예제 #1
0
 public static function sendEmail($args)
 {
     $isEncrypted = OC_App::isEnabled('files_encryption');
     if (!$isEncrypted || isset($_POST['continue'])) {
         $continue = true;
     } else {
         $continue = false;
     }
     if (OC_User::userExists($_POST['user']) && $continue) {
         $token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', ''));
         OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
         // Hash the token again to prevent timing attacks
         $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
         if (!empty($email)) {
             $link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
             $link = OC_Helper::makeURLAbsolute($link);
             $tmpl = new OC_Template('core/lostpassword', 'email');
             $tmpl->assign('link', $link, false);
             $msg = $tmpl->fetchPage();
             $l = OC_L10N::get('core');
             $from = OCP\Util::getDefaultEmailAddress('lostpassword-noreply');
             try {
                 OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
             } catch (Exception $e) {
                 OC_Template::printErrorPage('A problem occurs during sending the e-mail please contact your administrator.');
             }
             self::displayLostPasswordPage(false, true);
         } else {
             self::displayLostPasswordPage(true, false);
         }
     } else {
         self::displayLostPasswordPage(true, false);
     }
 }
예제 #2
0
 function setUp()
 {
     \OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
     $this->userId = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1;
     $this->pass = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1;
     // set content for encrypting / decrypting in tests
     $this->dataUrl = realpath(dirname(__FILE__) . '/../lib/crypt.php');
     $this->dataShort = 'hats';
     $this->dataLong = file_get_contents(realpath(dirname(__FILE__) . '/../lib/crypt.php'));
     $this->legacyData = realpath(dirname(__FILE__) . '/legacy-text.txt');
     $this->legacyEncryptedData = realpath(dirname(__FILE__) . '/legacy-encrypted-text.txt');
     $this->legacyEncryptedDataKey = realpath(dirname(__FILE__) . '/encryption.key');
     $this->legacyKey = "30943623843030686906";
     $keypair = Encryption\Crypt::createKeypair();
     $this->genPublicKey = $keypair['publicKey'];
     $this->genPrivateKey = $keypair['privateKey'];
     $this->publicKeyDir = '/' . 'public-keys';
     $this->encryptionDir = '/' . $this->userId . '/' . 'files_encryption';
     $this->keyfilesPath = $this->encryptionDir . '/' . 'keyfiles';
     $this->publicKeyPath = $this->publicKeyDir . '/' . $this->userId . '.public.key';
     // e.g. data/public-keys/admin.public.key
     $this->privateKeyPath = $this->encryptionDir . '/' . $this->userId . '.private.key';
     // e.g. data/admin/admin.private.key
     $this->view = new \OC_FilesystemView('/');
     $this->util = new Encryption\Util($this->view, $this->userId);
     // remember files_trashbin state
     $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
 }
예제 #3
0
파일: json.php 프로젝트: ryanshoover/core
	/**
	* Check if the app is enabled, send json error msg if not
	*/
	public static function checkAppEnabled($app) {
		if( !OC_App::isEnabled($app)) {
			$l = OC_L10N::get('lib');
			self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled') )));
			exit();
		}
	}
예제 #4
0
파일: crypt.php 프로젝트: samj1912/repo
 protected function setUp()
 {
     parent::setUp();
     // set user id
     self::loginHelper(self::TEST_ENCRYPTION_CRYPT_USER1);
     $this->userId = self::TEST_ENCRYPTION_CRYPT_USER1;
     $this->pass = self::TEST_ENCRYPTION_CRYPT_USER1;
     // set content for encrypting / decrypting in tests
     $this->dataLong = file_get_contents(__DIR__ . '/../lib/crypt.php');
     $this->dataShort = 'hats';
     $this->dataUrl = __DIR__ . '/../lib/crypt.php';
     $this->legacyData = __DIR__ . '/legacy-text.txt';
     $this->legacyEncryptedData = __DIR__ . '/legacy-encrypted-text.txt';
     $this->legacyEncryptedDataKey = __DIR__ . '/encryption.key';
     $this->randomKey = \OCA\Files_Encryption\Crypt::generateKey();
     $keypair = \OCA\Files_Encryption\Crypt::createKeypair();
     $this->genPublicKey = $keypair['publicKey'];
     $this->genPrivateKey = $keypair['privateKey'];
     $this->view = new \OC\Files\View('/');
     // remember files_trashbin state
     $this->stateFilesTrashbin = \OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
     $this->config = \OC::$server->getConfig();
 }
예제 #5
0
 /**
  * Deletes the given file by moving it into the trashbin.
  *
  * @param string $path
  */
 public function unlink($path)
 {
     if (self::$disableTrash || !\OC_App::isEnabled('files_trashbin')) {
         return $this->storage->unlink($path);
     }
     $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
     $result = true;
     if (!isset($this->deletedFiles[$normalized])) {
         $view = Filesystem::getView();
         $this->deletedFiles[$normalized] = $normalized;
         if ($filesPath = $view->getRelativePath($normalized)) {
             $filesPath = trim($filesPath, '/');
             $result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath);
             // in cross-storage cases the file will be copied
             // but not deleted, so we delete it here
             if ($result) {
                 $this->storage->unlink($path);
             }
         } else {
             $result = $this->storage->unlink($path);
         }
         unset($this->deletedFiles[$normalized]);
     } else {
         if ($this->storage->file_exists($path)) {
             $result = $this->storage->unlink($path);
         }
     }
     return $result;
 }
예제 #6
0
파일: listapps.php 프로젝트: evanjt/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') {
         $shouldFilterShipped = true;
         $shippedFilter = $input->getOption('shipped') === 'true';
     } else {
         $shouldFilterShipped = false;
     }
     $apps = \OC_App::getAllApps();
     $enabledApps = $disabledApps = [];
     $versions = \OC_App::getAppVersions();
     //sort enabled apps above disabled apps
     foreach ($apps as $app) {
         if ($shouldFilterShipped && \OC_App::isShipped($app) !== $shippedFilter) {
             continue;
         }
         if (\OC_App::isEnabled($app)) {
             $enabledApps[] = $app;
         } else {
             $disabledApps[] = $app;
         }
     }
     $apps = ['enabled' => [], 'disabled' => []];
     sort($enabledApps);
     foreach ($enabledApps as $app) {
         $apps['enabled'][$app] = isset($versions[$app]) ? $versions[$app] : true;
     }
     sort($disabledApps);
     foreach ($disabledApps as $app) {
         $apps['disabled'][$app] = null;
     }
     $this->writeAppList($input, $output, $apps);
 }
예제 #7
0
 public function setUp()
 {
     // remember files_encryption state
     $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
     // we want to tests with the encryption app disabled
     \OC_App::disable('files_encryption');
     $this->storage = new \OC\Files\Storage\Temporary(array());
     $textData = "dummy file data\n";
     $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
     $this->storage->mkdir('folder');
     $this->storage->file_put_contents('foo.txt', $textData);
     $this->storage->file_put_contents('foo.png', $imgData);
     $this->storage->file_put_contents('folder/bar.txt', $textData);
     $this->storage->file_put_contents('folder/bar2.txt', $textData);
     $this->scanner = $this->storage->getScanner();
     $this->scanner->scan('');
     $this->cache = $this->storage->getCache();
     \OC\Files\Filesystem::tearDown();
     if (!self::$user) {
         self::$user = uniqid();
     }
     \OC_User::createUser(self::$user, 'password');
     \OC_User::setUserId(self::$user);
     \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
     Filesystem::clearMounts();
     Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
     \OC_Hook::clear('OC_Filesystem');
 }
예제 #8
0
 protected function setUp()
 {
     parent::setUp();
     // login user
     self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1);
     \OC_User::setUserId(self::TEST_ENCRYPTION_UTIL_USER1);
     $this->userId = self::TEST_ENCRYPTION_UTIL_USER1;
     $this->pass = self::TEST_ENCRYPTION_UTIL_USER1;
     // set content for encrypting / decrypting in tests
     $this->dataUrl = __DIR__ . '/../lib/crypt.php';
     $this->dataShort = 'hats';
     $this->dataLong = file_get_contents(__DIR__ . '/../lib/crypt.php');
     $this->legacyData = __DIR__ . '/legacy-text.txt';
     $this->legacyEncryptedData = __DIR__ . '/legacy-encrypted-text.txt';
     $this->legacyEncryptedDataKey = __DIR__ . '/encryption.key';
     $this->legacyKey = "30943623843030686906";
     $keypair = \OCA\Files_Encryption\Crypt::createKeypair();
     $this->genPublicKey = $keypair['publicKey'];
     $this->genPrivateKey = $keypair['privateKey'];
     $this->publicKeyDir = \OCA\Files_Encryption\Keymanager::getPublicKeyPath();
     $this->encryptionDir = '/' . $this->userId . '/' . 'files_encryption';
     $this->keysPath = $this->encryptionDir . '/' . 'keys';
     $this->publicKeyPath = $this->publicKeyDir . '/' . $this->userId . '.publicKey';
     // e.g. data/public-keys/admin.publicKey
     $this->privateKeyPath = $this->encryptionDir . '/' . $this->userId . '.privateKey';
     // e.g. data/admin/admin.privateKey
     $this->view = new \OC\Files\View('/');
     $this->util = new \OCA\Files_Encryption\Util($this->view, $this->userId);
     // remember files_trashbin state
     $this->stateFilesTrashbin = \OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
 }
예제 #9
0
 /**
  * Check if the app is enabled, send json error msg if not
  * @param string $app
  * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled.
  */
 public static function checkAppEnabled($app)
 {
     if (!OC_App::isEnabled($app)) {
         $l = \OC::$server->getL10N('lib');
         self::error(array('data' => array('message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled')));
         exit;
     }
 }
예제 #10
0
 function setUp()
 {
     $this->assertFalse(\OC_App::isEnabled('files_encryption'));
     //login as user1
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->data = 'foobar';
     $this->view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
 }
예제 #11
0
파일: server.php 프로젝트: pinoniq/core
 protected function httpGet($uri)
 {
     $range = $this->getHTTPRange();
     if (OC_App::isEnabled('files_encryption') && $range) {
         // encryption does not support range requests
         $this->ignoreRangeHeader = true;
     }
     return parent::httpGet($uri);
 }
예제 #12
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if (\OC_App::isEnabled($appId)) {
         \OC_App::disable($appId);
         $output->writeln($appId . ' disabled');
     } else {
         $output->writeln('No such app enabled: ' . $appId);
     }
 }
예제 #13
0
 public function __construct(array $urlParams = array())
 {
     parent::__construct('core', $urlParams);
     $container = $this->getContainer();
     /**
      * Controllers
      */
     $container->registerService('LostController', function ($c) {
         return new LostController($c->query('AppName'), $c->query('Request'), $c->query('ServerContainer')->getURLGenerator(), $c->query('ServerContainer')->getUserManager(), new \OC_Defaults(), $c->query('ServerContainer')->getL10N('core'), $c->query('ServerContainer')->getConfig(), $c->query('ServerContainer')->getUserSession(), \OCP\Util::getDefaultEmailAddress('lostpassword-noreply'), \OC_App::isEnabled('files_encryption'));
     });
 }
예제 #14
0
 function setUp()
 {
     //login as user1
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->data = 'foobar';
     $this->view = new \OC_FilesystemView('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
     // remember files_encryption state
     $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
     //we don't want to tests with app files_encryption enabled
     \OC_App::disable('files_encryption');
     $this->assertTrue(!\OC_App::isEnabled('files_encryption'));
 }
예제 #15
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // disable file proxy by default
     \OC_FileProxy::$enabled = false;
     // remember files_trashbin state
     self::$stateFilesTrashbin = \OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
     // create test user
     \OC_User::deleteUser(self::TEST_USER);
     parent::loginHelper(self::TEST_USER, true);
 }
예제 #16
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if (\OC_App::isEnabled($appId)) {
         $output->writeln($appId . ' is already enabled');
     } else {
         if (!\OC_App::getAppPath($appId)) {
             $output->writeln($appId . ' not found');
         } else {
             \OC_App::enable($appId);
             $output->writeln($appId . ' enabled');
         }
     }
 }
예제 #17
0
파일: share.php 프로젝트: Romua1d/core
 function setUp()
 {
     $this->dataShort = 'hats';
     $this->view = new \OC\Files\View('/');
     $this->folder1 = '/folder1';
     $this->subfolder = '/subfolder1';
     $this->subsubfolder = '/subsubfolder1';
     $this->filename = 'share-tmp.test';
     // remember files_trashbin state
     $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
     // login as first user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
 }
예제 #18
0
 function setUp()
 {
     // set user id
     \OC_User::setUserId(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1);
     $this->userId = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1;
     $this->pass = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1;
     // init filesystem view
     $this->view = new \OC_FilesystemView('/');
     // init short data
     $this->dataShort = 'hats';
     // remember files_trashbin state
     $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
 }
예제 #19
0
파일: disable.php 프로젝트: rosarion/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if (\OC_App::isEnabled($appId)) {
         try {
             \OC_App::disable($appId);
             $output->writeln($appId . ' disabled');
         } catch (\Exception $e) {
             $output->writeln($e->getMessage());
             return 2;
         }
     } else {
         $output->writeln('No such app enabled: ' . $appId);
     }
 }
예제 #20
0
파일: stream.php 프로젝트: samj1912/repo
 protected function setUp()
 {
     parent::setUp();
     // set user id
     \OC_User::setUserId(self::TEST_ENCRYPTION_STREAM_USER1);
     $this->userId = self::TEST_ENCRYPTION_STREAM_USER1;
     $this->pass = self::TEST_ENCRYPTION_STREAM_USER1;
     // init filesystem view
     $this->view = new \OC\Files\View('/');
     // init short data
     $this->dataShort = 'hats';
     // remember files_trashbin state
     $this->stateFilesTrashbin = \OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
 }
예제 #21
0
 protected function setUp()
 {
     parent::setUp();
     $this->dataShort = 'hats';
     $this->view = new \OC\Files\View('/');
     $this->folder1 = '/folder1';
     $this->subfolder = '/subfolder1';
     $this->subsubfolder = '/subsubfolder1';
     $this->filename = 'share-tmp.test';
     // remember files_trashbin state
     $this->stateFilesTrashbin = \OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
     // login as first user
     self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1);
     $this->createMocks();
 }
예제 #22
0
 function setUp()
 {
     // set user id
     \OC_User::setUserId(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1);
     $this->userId = \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1;
     $this->pass = \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1;
     // init filesystem view
     $this->view = new \OC_FilesystemView('/');
     // init short data
     $this->dataShort = 'hats';
     $this->folder1 = '/folder1';
     $this->subfolder = '/subfolder1';
     $this->subsubfolder = '/subsubfolder1';
     // remember files_trashbin state
     $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
     // we want to tests with app files_trashbin enabled
     \OC_App::enable('files_trashbin');
 }
예제 #23
0
 function setUp()
 {
     // reset backend
     \OC_User::useBackend('database');
     // set user id
     \OC_User::setUserId(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1);
     $this->userId = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1;
     $this->pass = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1;
     // init filesystem view
     $this->view = new \OC_FilesystemView('/');
     // init short data
     $this->dataShort = 'hats';
     // remember files_trashbin state
     $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
     // create test user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1);
 }
예제 #24
0
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // disable file proxy by default
     \OC_FileProxy::$enabled = false;
     // remember files_trashbin state
     self::$stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
     // create test user
     \OC_User::deleteUser(\Test_Encryption_Keymanager::TEST_USER);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Keymanager::TEST_USER, true);
 }
예제 #25
0
 /**
  * test deletion of a folder which contains share mount points. Share mount
  * points should be unshared before the folder gets deleted so
  * that the mount point doesn't end up at the trash bin
  */
 function testDeleteParentFolder()
 {
     $status = \OC_App::isEnabled('files_trashbin');
     \OC_App::enable('files_trashbin');
     \OCA\Files_Trashbin\Trashbin::registerHooks();
     OC_FileProxy::register(new OCA\Files\Share\Proxy());
     $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
     $this->assertTrue($fileinfo instanceof \OC\Files\FileInfo);
     \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     // check if user2 can see the shared folder
     $this->assertTrue($view->file_exists($this->folder));
     $foldersShared = \OCP\Share::getItemsSharedWith('folder');
     $this->assertSame(1, count($foldersShared));
     $view->mkdir("localFolder");
     $view->file_put_contents("localFolder/localFile.txt", "local file");
     $view->rename($this->folder, 'localFolder/' . $this->folder);
     // share mount point should now be moved to the subfolder
     $this->assertFalse($view->file_exists($this->folder));
     $this->assertTrue($view->file_exists('localFolder/' . $this->folder));
     $view->unlink('localFolder');
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // shared folder should be unshared
     $foldersShared = \OCP\Share::getItemsSharedWith('folder');
     $this->assertTrue(empty($foldersShared));
     // trashbin should contain the local file but not the mount point
     $rootView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
     $trashContent = \OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_FILES_SHARING_API_USER2);
     $this->assertSame(1, count($trashContent));
     $firstElement = reset($trashContent);
     $timestamp = $firstElement['mtime'];
     $this->assertTrue($rootView->file_exists('files_trashbin/files/localFolder.d' . $timestamp . '/localFile.txt'));
     $this->assertFalse($rootView->file_exists('files_trashbin/files/localFolder.d' . $timestamp . '/' . $this->folder));
     //cleanup
     $rootView->deleteAll('files_trashin');
     if ($status === false) {
         \OC_App::disable('files_trashbin');
     }
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
 }
예제 #26
0
 /**
  * @param array $urlParams
  */
 public function __construct(array $urlParams = array())
 {
     parent::__construct('core', $urlParams);
     $container = $this->getContainer();
     /**
      * Controllers
      */
     $container->registerService('LostController', function (SimpleContainer $c) {
         return new LostController($c->query('AppName'), $c->query('Request'), $c->query('URLGenerator'), $c->query('UserManager'), $c->query('Defaults'), $c->query('L10N'), $c->query('Config'), $c->query('SecureRandom'), $c->query('DefaultEmailAddress'), $c->query('IsEncryptionEnabled'));
     });
     $container->registerService('UserController', function (SimpleContainer $c) {
         return new UserController($c->query('AppName'), $c->query('Request'), $c->query('UserManager'), $c->query('Defaults'));
     });
     /**
      * Core class wrappers
      */
     $container->registerService('IsEncryptionEnabled', function () {
         return \OC_App::isEnabled('files_encryption');
     });
     $container->registerService('URLGenerator', function (SimpleContainer $c) {
         return $c->query('ServerContainer')->getURLGenerator();
     });
     $container->registerService('UserManager', function (SimpleContainer $c) {
         return $c->query('ServerContainer')->getUserManager();
     });
     $container->registerService('Config', function (SimpleContainer $c) {
         return $c->query('ServerContainer')->getConfig();
     });
     $container->registerService('L10N', function (SimpleContainer $c) {
         return $c->query('ServerContainer')->getL10N('core');
     });
     $container->registerService('SecureRandom', function (SimpleContainer $c) {
         return $c->query('ServerContainer')->getSecureRandom();
     });
     $container->registerService('Defaults', function () {
         return new \OC_Defaults();
     });
     $container->registerService('DefaultEmailAddress', function () {
         return Util::getDefaultEmailAddress('lostpassword-noreply');
     });
 }
예제 #27
0
 protected function setUp()
 {
     parent::setUp();
     // reset backend
     \OC_User::useBackend('database');
     // set user id
     \OC_User::setUserId(self::TEST_ENCRYPTION_WEBDAV_USER1);
     $this->userId = self::TEST_ENCRYPTION_WEBDAV_USER1;
     $this->pass = self::TEST_ENCRYPTION_WEBDAV_USER1;
     // init filesystem view
     $this->view = new \OC\Files\View('/');
     list($this->storage, ) = $this->view->resolvePath('/');
     // init short data
     $this->dataShort = 'hats';
     // remember files_trashbin state
     $this->stateFilesTrashbin = \OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
     // create test user
     self::loginHelper(self::TEST_ENCRYPTION_WEBDAV_USER1);
 }
예제 #28
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $includeExpensive = $input->getOption('include-expensive');
     if ($includeExpensive) {
         foreach ($this->repair->getExpensiveRepairSteps() as $step) {
             $this->repair->addStep($step);
         }
     }
     $apps = \OC::$server->getAppManager()->getInstalledApps();
     foreach ($apps as $app) {
         if (!\OC_App::isEnabled($app)) {
             continue;
         }
         $info = \OC_App::getAppInfo($app);
         if (!is_array($info)) {
             continue;
         }
         $steps = $info['repair-steps']['post-migration'];
         foreach ($steps as $step) {
             try {
                 $this->repair->addStep($step);
             } catch (Exception $ex) {
                 $output->writeln("<error>Failed to load repair step for {$app}: {$ex->getMessage()}</error>");
             }
         }
     }
     $maintenanceMode = $this->config->getSystemValue('maintenance', false);
     $this->config->setSystemValue('maintenance', true);
     $this->progress = new ProgressBar($output);
     $this->output = $output;
     $this->dispatcher->addListener('\\OC\\Repair::startProgress', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::advance', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::step', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::info', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::warning', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::error', [$this, 'handleRepairFeedBack']);
     $this->repair->run();
     $this->config->setSystemValue('maintenance', $maintenanceMode);
 }
예제 #29
0
파일: migration.php 프로젝트: samj1912/repo
 public function reorganizeFolderStructureForUser($user)
 {
     // backup all keys
     \OC_Util::setupFS($user);
     if ($this->backupUserKeys($user)) {
         // create new 'key' folder
         $this->view->mkdir($user . '/files_encryption/keys');
         // rename users private key
         $this->renameUsersPrivateKey($user);
         // rename file keys
         $path = $user . '/files_encryption/keyfiles';
         $this->renameFileKeys($user, $path);
         $trashPath = $user . '/files_trashbin/keyfiles';
         if (\OC_App::isEnabled('files_trashbin') && $this->view->is_dir($trashPath)) {
             $this->renameFileKeys($user, $trashPath, true);
             $this->view->deleteAll($trashPath);
             $this->view->deleteAll($user . '/files_trashbin/share-keys');
         }
         // delete old folders
         $this->deleteOldKeys($user);
     }
 }
예제 #30
0
 public function reorganizeFolderStructure()
 {
     $this->createPathForKeys('/files_encryption');
     // backup system wide folders
     $this->backupSystemWideKeys();
     // rename public keys
     $this->renamePublicKeys();
     // rename system wide mount point
     $this->renameFileKeys('', '/files_encryption/keyfiles');
     // rename system private keys
     $this->renameSystemPrivateKeys();
     // delete old system wide folders
     $this->view->deleteAll('/public-keys');
     $this->view->deleteAll('/owncloud_private_key');
     $this->view->deleteAll('/files_encryption/share-keys');
     $this->view->deleteAll('/files_encryption/keyfiles');
     $users = \OCP\User::getUsers();
     foreach ($users as $user) {
         // backup all keys
         if ($this->backupUserKeys($user)) {
             // create new 'key' folder
             $this->view->mkdir($user . '/files_encryption/keys');
             // rename users private key
             $this->renameUsersPrivateKey($user);
             // rename file keys
             $path = $user . '/files_encryption/keyfiles';
             $this->renameFileKeys($user, $path);
             $trashPath = $user . '/files_trashbin/keyfiles';
             if (\OC_App::isEnabled('files_trashbin') && $this->view->is_dir($trashPath)) {
                 $this->renameFileKeys($user, $trashPath, true);
                 $this->view->deleteAll($trashPath);
                 $this->view->deleteAll($user . '/files_trashbin/share-keys');
             }
             // delete old folders
             $this->deleteOldKeys($user);
         }
     }
 }