@@ -29,69 +29,69 @@ |
||
29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 30 | |
31 | 31 | class ListModules extends Base { |
32 | - /** @var IManager */ |
|
33 | - protected $encryptionManager; |
|
32 | + /** @var IManager */ |
|
33 | + protected $encryptionManager; |
|
34 | 34 | |
35 | - /** @var IConfig */ |
|
36 | - protected $config; |
|
35 | + /** @var IConfig */ |
|
36 | + protected $config; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IManager $encryptionManager |
|
40 | - * @param IConfig $config |
|
41 | - */ |
|
42 | - public function __construct( |
|
43 | - IManager $encryptionManager, |
|
44 | - IConfig $config |
|
45 | - ) { |
|
46 | - parent::__construct(); |
|
47 | - $this->encryptionManager = $encryptionManager; |
|
48 | - $this->config = $config; |
|
49 | - } |
|
38 | + /** |
|
39 | + * @param IManager $encryptionManager |
|
40 | + * @param IConfig $config |
|
41 | + */ |
|
42 | + public function __construct( |
|
43 | + IManager $encryptionManager, |
|
44 | + IConfig $config |
|
45 | + ) { |
|
46 | + parent::__construct(); |
|
47 | + $this->encryptionManager = $encryptionManager; |
|
48 | + $this->config = $config; |
|
49 | + } |
|
50 | 50 | |
51 | - protected function configure() { |
|
52 | - parent::configure(); |
|
51 | + protected function configure() { |
|
52 | + parent::configure(); |
|
53 | 53 | |
54 | - $this |
|
55 | - ->setName('encryption:list-modules') |
|
56 | - ->setDescription('List all available encryption modules') |
|
57 | - ; |
|
58 | - } |
|
54 | + $this |
|
55 | + ->setName('encryption:list-modules') |
|
56 | + ->setDescription('List all available encryption modules') |
|
57 | + ; |
|
58 | + } |
|
59 | 59 | |
60 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | - $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
62 | - if ($isMaintenanceModeEnabled) { |
|
63 | - $output->writeln("Maintenance mode must be disabled when listing modules"); |
|
64 | - $output->writeln("in order to list the relevant encryption modules correctly."); |
|
65 | - return; |
|
66 | - } |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
62 | + if ($isMaintenanceModeEnabled) { |
|
63 | + $output->writeln("Maintenance mode must be disabled when listing modules"); |
|
64 | + $output->writeln("in order to list the relevant encryption modules correctly."); |
|
65 | + return; |
|
66 | + } |
|
67 | 67 | |
68 | - $encryptionModules = $this->encryptionManager->getEncryptionModules(); |
|
69 | - $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); |
|
68 | + $encryptionModules = $this->encryptionManager->getEncryptionModules(); |
|
69 | + $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); |
|
70 | 70 | |
71 | - $encModules = array(); |
|
72 | - foreach ($encryptionModules as $module) { |
|
73 | - $encModules[$module['id']]['displayName'] = $module['displayName']; |
|
74 | - $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; |
|
75 | - } |
|
76 | - $this->writeModuleList($input, $output, $encModules); |
|
77 | - } |
|
71 | + $encModules = array(); |
|
72 | + foreach ($encryptionModules as $module) { |
|
73 | + $encModules[$module['id']]['displayName'] = $module['displayName']; |
|
74 | + $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; |
|
75 | + } |
|
76 | + $this->writeModuleList($input, $output, $encModules); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @param InputInterface $input |
|
81 | - * @param OutputInterface $output |
|
82 | - * @param array $items |
|
83 | - */ |
|
84 | - protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { |
|
85 | - if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
86 | - array_walk($items, function(&$item) { |
|
87 | - if (!$item['default']) { |
|
88 | - $item = $item['displayName']; |
|
89 | - } else { |
|
90 | - $item = $item['displayName'] . ' [default*]'; |
|
91 | - } |
|
92 | - }); |
|
93 | - } |
|
79 | + /** |
|
80 | + * @param InputInterface $input |
|
81 | + * @param OutputInterface $output |
|
82 | + * @param array $items |
|
83 | + */ |
|
84 | + protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { |
|
85 | + if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
86 | + array_walk($items, function(&$item) { |
|
87 | + if (!$item['default']) { |
|
88 | + $item = $item['displayName']; |
|
89 | + } else { |
|
90 | + $item = $item['displayName'] . ' [default*]'; |
|
91 | + } |
|
92 | + }); |
|
93 | + } |
|
94 | 94 | |
95 | - $this->writeArrayInOutputFormat($input, $output, $items); |
|
96 | - } |
|
95 | + $this->writeArrayInOutputFormat($input, $output, $items); |
|
96 | + } |
|
97 | 97 | } |
@@ -31,55 +31,55 @@ |
||
31 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
32 | 32 | |
33 | 33 | class SetDefaultModule extends Command { |
34 | - /** @var IManager */ |
|
35 | - protected $encryptionManager; |
|
34 | + /** @var IManager */ |
|
35 | + protected $encryptionManager; |
|
36 | 36 | |
37 | - /** @var IConfig */ |
|
38 | - protected $config; |
|
37 | + /** @var IConfig */ |
|
38 | + protected $config; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param IManager $encryptionManager |
|
42 | - * @param IConfig $config |
|
43 | - */ |
|
44 | - public function __construct( |
|
45 | - IManager $encryptionManager, |
|
46 | - IConfig $config |
|
47 | - ) { |
|
48 | - parent::__construct(); |
|
49 | - $this->encryptionManager = $encryptionManager; |
|
50 | - $this->config = $config; |
|
51 | - } |
|
40 | + /** |
|
41 | + * @param IManager $encryptionManager |
|
42 | + * @param IConfig $config |
|
43 | + */ |
|
44 | + public function __construct( |
|
45 | + IManager $encryptionManager, |
|
46 | + IConfig $config |
|
47 | + ) { |
|
48 | + parent::__construct(); |
|
49 | + $this->encryptionManager = $encryptionManager; |
|
50 | + $this->config = $config; |
|
51 | + } |
|
52 | 52 | |
53 | - protected function configure() { |
|
54 | - parent::configure(); |
|
53 | + protected function configure() { |
|
54 | + parent::configure(); |
|
55 | 55 | |
56 | - $this |
|
57 | - ->setName('encryption:set-default-module') |
|
58 | - ->setDescription('Set the encryption default module') |
|
59 | - ->addArgument( |
|
60 | - 'module', |
|
61 | - InputArgument::REQUIRED, |
|
62 | - 'ID of the encryption module that should be used' |
|
63 | - ) |
|
64 | - ; |
|
65 | - } |
|
56 | + $this |
|
57 | + ->setName('encryption:set-default-module') |
|
58 | + ->setDescription('Set the encryption default module') |
|
59 | + ->addArgument( |
|
60 | + 'module', |
|
61 | + InputArgument::REQUIRED, |
|
62 | + 'ID of the encryption module that should be used' |
|
63 | + ) |
|
64 | + ; |
|
65 | + } |
|
66 | 66 | |
67 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
68 | - $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
69 | - if ($isMaintenanceModeEnabled) { |
|
70 | - $output->writeln("Maintenance mode must be disabled when setting default module,"); |
|
71 | - $output->writeln("in order to load the relevant encryption modules correctly."); |
|
72 | - return; |
|
73 | - } |
|
67 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
68 | + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
69 | + if ($isMaintenanceModeEnabled) { |
|
70 | + $output->writeln("Maintenance mode must be disabled when setting default module,"); |
|
71 | + $output->writeln("in order to load the relevant encryption modules correctly."); |
|
72 | + return; |
|
73 | + } |
|
74 | 74 | |
75 | - $moduleId = $input->getArgument('module'); |
|
75 | + $moduleId = $input->getArgument('module'); |
|
76 | 76 | |
77 | - if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { |
|
78 | - $output->writeln('"' . $moduleId . '"" is already the default module'); |
|
79 | - } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { |
|
80 | - $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); |
|
81 | - } else { |
|
82 | - $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); |
|
83 | - } |
|
84 | - } |
|
77 | + if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { |
|
78 | + $output->writeln('"' . $moduleId . '"" is already the default module'); |
|
79 | + } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { |
|
80 | + $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); |
|
81 | + } else { |
|
82 | + $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); |
|
83 | + } |
|
84 | + } |
|
85 | 85 | } |
@@ -40,156 +40,156 @@ |
||
40 | 40 | |
41 | 41 | class DecryptAll extends Command { |
42 | 42 | |
43 | - /** @var IManager */ |
|
44 | - protected $encryptionManager; |
|
45 | - |
|
46 | - /** @var IAppManager */ |
|
47 | - protected $appManager; |
|
48 | - |
|
49 | - /** @var IConfig */ |
|
50 | - protected $config; |
|
51 | - |
|
52 | - /** @var QuestionHelper */ |
|
53 | - protected $questionHelper; |
|
54 | - |
|
55 | - /** @var bool */ |
|
56 | - protected $wasTrashbinEnabled; |
|
57 | - |
|
58 | - /** @var bool */ |
|
59 | - protected $wasMaintenanceModeEnabled; |
|
60 | - |
|
61 | - /** @var \OC\Encryption\DecryptAll */ |
|
62 | - protected $decryptAll; |
|
63 | - |
|
64 | - /** |
|
65 | - * @param IManager $encryptionManager |
|
66 | - * @param IAppManager $appManager |
|
67 | - * @param IConfig $config |
|
68 | - * @param \OC\Encryption\DecryptAll $decryptAll |
|
69 | - * @param QuestionHelper $questionHelper |
|
70 | - */ |
|
71 | - public function __construct( |
|
72 | - IManager $encryptionManager, |
|
73 | - IAppManager $appManager, |
|
74 | - IConfig $config, |
|
75 | - \OC\Encryption\DecryptAll $decryptAll, |
|
76 | - QuestionHelper $questionHelper |
|
77 | - ) { |
|
78 | - parent::__construct(); |
|
79 | - |
|
80 | - $this->appManager = $appManager; |
|
81 | - $this->encryptionManager = $encryptionManager; |
|
82 | - $this->config = $config; |
|
83 | - $this->decryptAll = $decryptAll; |
|
84 | - $this->questionHelper = $questionHelper; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Set maintenance mode and disable the trashbin app |
|
89 | - */ |
|
90 | - protected function forceMaintenanceAndTrashbin() { |
|
91 | - $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin'); |
|
92 | - $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
|
93 | - $this->config->setSystemValue('maintenance', true); |
|
94 | - $this->appManager->disableApp('files_trashbin'); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Reset the maintenance mode and re-enable the trashbin app |
|
99 | - */ |
|
100 | - protected function resetMaintenanceAndTrashbin() { |
|
101 | - $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled); |
|
102 | - if ($this->wasTrashbinEnabled) { |
|
103 | - $this->appManager->enableApp('files_trashbin'); |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - protected function configure() { |
|
108 | - parent::configure(); |
|
109 | - |
|
110 | - $this->setName('encryption:decrypt-all'); |
|
111 | - $this->setDescription('Disable server-side encryption and decrypt all files'); |
|
112 | - $this->setHelp( |
|
113 | - 'This will disable server-side encryption and decrypt all files for ' |
|
114 | - . 'all users if it is supported by your encryption module. ' |
|
115 | - . 'Please make sure that no user access his files during this process!' |
|
116 | - ); |
|
117 | - $this->addArgument( |
|
118 | - 'user', |
|
119 | - InputArgument::OPTIONAL, |
|
120 | - 'user for which you want to decrypt all files (optional)', |
|
121 | - '' |
|
122 | - ); |
|
123 | - } |
|
124 | - |
|
125 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
126 | - if ( !$input->isInteractive() ) { |
|
127 | - $output->writeln('Invalid TTY.'); |
|
128 | - $output->writeln('If you are trying to execute the command in a Docker '); |
|
129 | - $output->writeln("container, do not forget to execute 'docker exec' with"); |
|
130 | - $output->writeln("the '-i' and '-t' options."); |
|
131 | - $output->writeln(''); |
|
132 | - return; |
|
133 | - } |
|
134 | - |
|
135 | - $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
136 | - if ($isMaintenanceModeEnabled) { |
|
137 | - $output->writeln("Maintenance mode must be disabled when starting decryption,"); |
|
138 | - $output->writeln("in order to load the relevant encryption modules correctly."); |
|
139 | - $output->writeln("Your instance will automatically be put to maintenance mode"); |
|
140 | - $output->writeln("during the actual decryption of the files."); |
|
141 | - return; |
|
142 | - } |
|
143 | - |
|
144 | - try { |
|
145 | - if ($this->encryptionManager->isEnabled() === true) { |
|
146 | - $output->write('Disable server side encryption... '); |
|
147 | - $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
148 | - $output->writeln('done.'); |
|
149 | - } else { |
|
150 | - $output->writeln('Server side encryption not enabled. Nothing to do.'); |
|
151 | - return; |
|
152 | - } |
|
153 | - |
|
154 | - $uid = $input->getArgument('user'); |
|
155 | - if ($uid === '') { |
|
156 | - $message = 'your Nextcloud'; |
|
157 | - } else { |
|
158 | - $message = "$uid's account"; |
|
159 | - } |
|
160 | - |
|
161 | - $output->writeln("\n"); |
|
162 | - $output->writeln("You are about to start to decrypt all files stored in $message."); |
|
163 | - $output->writeln('It will depend on the encryption module and your setup if this is possible.'); |
|
164 | - $output->writeln('Depending on the number and size of your files this can take some time'); |
|
165 | - $output->writeln('Please make sure that no user access his files during this process!'); |
|
166 | - $output->writeln(''); |
|
167 | - $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); |
|
168 | - if ($this->questionHelper->ask($input, $output, $question)) { |
|
169 | - $this->forceMaintenanceAndTrashbin(); |
|
170 | - $user = $input->getArgument('user'); |
|
171 | - $result = $this->decryptAll->decryptAll($input, $output, $user); |
|
172 | - if ($result === false) { |
|
173 | - $output->writeln(' aborted.'); |
|
174 | - $output->writeln('Server side encryption remains enabled'); |
|
175 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
176 | - } else if ($uid !== '') { |
|
177 | - $output->writeln('Server side encryption remains enabled'); |
|
178 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
179 | - } |
|
180 | - $this->resetMaintenanceAndTrashbin(); |
|
181 | - } else { |
|
182 | - $output->write('Enable server side encryption... '); |
|
183 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
184 | - $output->writeln('done.'); |
|
185 | - $output->writeln('aborted'); |
|
186 | - } |
|
187 | - } catch (\Exception $e) { |
|
188 | - // enable server side encryption again if something went wrong |
|
189 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
190 | - $this->resetMaintenanceAndTrashbin(); |
|
191 | - throw $e; |
|
192 | - } |
|
193 | - |
|
194 | - } |
|
43 | + /** @var IManager */ |
|
44 | + protected $encryptionManager; |
|
45 | + |
|
46 | + /** @var IAppManager */ |
|
47 | + protected $appManager; |
|
48 | + |
|
49 | + /** @var IConfig */ |
|
50 | + protected $config; |
|
51 | + |
|
52 | + /** @var QuestionHelper */ |
|
53 | + protected $questionHelper; |
|
54 | + |
|
55 | + /** @var bool */ |
|
56 | + protected $wasTrashbinEnabled; |
|
57 | + |
|
58 | + /** @var bool */ |
|
59 | + protected $wasMaintenanceModeEnabled; |
|
60 | + |
|
61 | + /** @var \OC\Encryption\DecryptAll */ |
|
62 | + protected $decryptAll; |
|
63 | + |
|
64 | + /** |
|
65 | + * @param IManager $encryptionManager |
|
66 | + * @param IAppManager $appManager |
|
67 | + * @param IConfig $config |
|
68 | + * @param \OC\Encryption\DecryptAll $decryptAll |
|
69 | + * @param QuestionHelper $questionHelper |
|
70 | + */ |
|
71 | + public function __construct( |
|
72 | + IManager $encryptionManager, |
|
73 | + IAppManager $appManager, |
|
74 | + IConfig $config, |
|
75 | + \OC\Encryption\DecryptAll $decryptAll, |
|
76 | + QuestionHelper $questionHelper |
|
77 | + ) { |
|
78 | + parent::__construct(); |
|
79 | + |
|
80 | + $this->appManager = $appManager; |
|
81 | + $this->encryptionManager = $encryptionManager; |
|
82 | + $this->config = $config; |
|
83 | + $this->decryptAll = $decryptAll; |
|
84 | + $this->questionHelper = $questionHelper; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Set maintenance mode and disable the trashbin app |
|
89 | + */ |
|
90 | + protected function forceMaintenanceAndTrashbin() { |
|
91 | + $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin'); |
|
92 | + $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
|
93 | + $this->config->setSystemValue('maintenance', true); |
|
94 | + $this->appManager->disableApp('files_trashbin'); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Reset the maintenance mode and re-enable the trashbin app |
|
99 | + */ |
|
100 | + protected function resetMaintenanceAndTrashbin() { |
|
101 | + $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled); |
|
102 | + if ($this->wasTrashbinEnabled) { |
|
103 | + $this->appManager->enableApp('files_trashbin'); |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + protected function configure() { |
|
108 | + parent::configure(); |
|
109 | + |
|
110 | + $this->setName('encryption:decrypt-all'); |
|
111 | + $this->setDescription('Disable server-side encryption and decrypt all files'); |
|
112 | + $this->setHelp( |
|
113 | + 'This will disable server-side encryption and decrypt all files for ' |
|
114 | + . 'all users if it is supported by your encryption module. ' |
|
115 | + . 'Please make sure that no user access his files during this process!' |
|
116 | + ); |
|
117 | + $this->addArgument( |
|
118 | + 'user', |
|
119 | + InputArgument::OPTIONAL, |
|
120 | + 'user for which you want to decrypt all files (optional)', |
|
121 | + '' |
|
122 | + ); |
|
123 | + } |
|
124 | + |
|
125 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
126 | + if ( !$input->isInteractive() ) { |
|
127 | + $output->writeln('Invalid TTY.'); |
|
128 | + $output->writeln('If you are trying to execute the command in a Docker '); |
|
129 | + $output->writeln("container, do not forget to execute 'docker exec' with"); |
|
130 | + $output->writeln("the '-i' and '-t' options."); |
|
131 | + $output->writeln(''); |
|
132 | + return; |
|
133 | + } |
|
134 | + |
|
135 | + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
136 | + if ($isMaintenanceModeEnabled) { |
|
137 | + $output->writeln("Maintenance mode must be disabled when starting decryption,"); |
|
138 | + $output->writeln("in order to load the relevant encryption modules correctly."); |
|
139 | + $output->writeln("Your instance will automatically be put to maintenance mode"); |
|
140 | + $output->writeln("during the actual decryption of the files."); |
|
141 | + return; |
|
142 | + } |
|
143 | + |
|
144 | + try { |
|
145 | + if ($this->encryptionManager->isEnabled() === true) { |
|
146 | + $output->write('Disable server side encryption... '); |
|
147 | + $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
148 | + $output->writeln('done.'); |
|
149 | + } else { |
|
150 | + $output->writeln('Server side encryption not enabled. Nothing to do.'); |
|
151 | + return; |
|
152 | + } |
|
153 | + |
|
154 | + $uid = $input->getArgument('user'); |
|
155 | + if ($uid === '') { |
|
156 | + $message = 'your Nextcloud'; |
|
157 | + } else { |
|
158 | + $message = "$uid's account"; |
|
159 | + } |
|
160 | + |
|
161 | + $output->writeln("\n"); |
|
162 | + $output->writeln("You are about to start to decrypt all files stored in $message."); |
|
163 | + $output->writeln('It will depend on the encryption module and your setup if this is possible.'); |
|
164 | + $output->writeln('Depending on the number and size of your files this can take some time'); |
|
165 | + $output->writeln('Please make sure that no user access his files during this process!'); |
|
166 | + $output->writeln(''); |
|
167 | + $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); |
|
168 | + if ($this->questionHelper->ask($input, $output, $question)) { |
|
169 | + $this->forceMaintenanceAndTrashbin(); |
|
170 | + $user = $input->getArgument('user'); |
|
171 | + $result = $this->decryptAll->decryptAll($input, $output, $user); |
|
172 | + if ($result === false) { |
|
173 | + $output->writeln(' aborted.'); |
|
174 | + $output->writeln('Server side encryption remains enabled'); |
|
175 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
176 | + } else if ($uid !== '') { |
|
177 | + $output->writeln('Server side encryption remains enabled'); |
|
178 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
179 | + } |
|
180 | + $this->resetMaintenanceAndTrashbin(); |
|
181 | + } else { |
|
182 | + $output->write('Enable server side encryption... '); |
|
183 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
184 | + $output->writeln('done.'); |
|
185 | + $output->writeln('aborted'); |
|
186 | + } |
|
187 | + } catch (\Exception $e) { |
|
188 | + // enable server side encryption again if something went wrong |
|
189 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
190 | + $this->resetMaintenanceAndTrashbin(); |
|
191 | + throw $e; |
|
192 | + } |
|
193 | + |
|
194 | + } |
|
195 | 195 | } |
@@ -43,129 +43,129 @@ |
||
43 | 43 | $application->add(new OC\Core\Command\App\CheckCode()); |
44 | 44 | $application->add(new OC\Core\Command\L10n\CreateJs()); |
45 | 45 | $application->add(new \OC\Core\Command\Integrity\SignApp( |
46 | - \OC::$server->getIntegrityCodeChecker(), |
|
47 | - new \OC\IntegrityCheck\Helpers\FileAccessHelper(), |
|
48 | - \OC::$server->getURLGenerator() |
|
46 | + \OC::$server->getIntegrityCodeChecker(), |
|
47 | + new \OC\IntegrityCheck\Helpers\FileAccessHelper(), |
|
48 | + \OC::$server->getURLGenerator() |
|
49 | 49 | )); |
50 | 50 | $application->add(new \OC\Core\Command\Integrity\SignCore( |
51 | - \OC::$server->getIntegrityCodeChecker(), |
|
52 | - new \OC\IntegrityCheck\Helpers\FileAccessHelper() |
|
51 | + \OC::$server->getIntegrityCodeChecker(), |
|
52 | + new \OC\IntegrityCheck\Helpers\FileAccessHelper() |
|
53 | 53 | )); |
54 | 54 | $application->add(new \OC\Core\Command\Integrity\CheckApp( |
55 | - \OC::$server->getIntegrityCodeChecker() |
|
55 | + \OC::$server->getIntegrityCodeChecker() |
|
56 | 56 | )); |
57 | 57 | $application->add(new \OC\Core\Command\Integrity\CheckCore( |
58 | - \OC::$server->getIntegrityCodeChecker() |
|
58 | + \OC::$server->getIntegrityCodeChecker() |
|
59 | 59 | )); |
60 | 60 | |
61 | 61 | |
62 | 62 | if (\OC::$server->getConfig()->getSystemValue('installed', false)) { |
63 | - $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager())); |
|
64 | - $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getGroupManager())); |
|
65 | - $application->add(new OC\Core\Command\App\Install()); |
|
66 | - $application->add(new OC\Core\Command\App\GetPath()); |
|
67 | - $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager())); |
|
68 | - $application->add(new OC\Core\Command\App\Remove(\OC::$server->getAppManager(), \OC::$server->query(\OC\Installer::class), \OC::$server->getLogger())); |
|
69 | - $application->add(\OC::$server->query(\OC\Core\Command\App\Update::class)); |
|
63 | + $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager())); |
|
64 | + $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getGroupManager())); |
|
65 | + $application->add(new OC\Core\Command\App\Install()); |
|
66 | + $application->add(new OC\Core\Command\App\GetPath()); |
|
67 | + $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager())); |
|
68 | + $application->add(new OC\Core\Command\App\Remove(\OC::$server->getAppManager(), \OC::$server->query(\OC\Installer::class), \OC::$server->getLogger())); |
|
69 | + $application->add(\OC::$server->query(\OC\Core\Command\App\Update::class)); |
|
70 | 70 | |
71 | - $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Cleanup::class)); |
|
72 | - $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enforce::class)); |
|
73 | - $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enable::class)); |
|
74 | - $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Disable::class)); |
|
75 | - $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\State::class)); |
|
71 | + $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Cleanup::class)); |
|
72 | + $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enforce::class)); |
|
73 | + $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enable::class)); |
|
74 | + $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Disable::class)); |
|
75 | + $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\State::class)); |
|
76 | 76 | |
77 | - $application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig())); |
|
78 | - $application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig())); |
|
79 | - $application->add(new OC\Core\Command\Background\Ajax(\OC::$server->getConfig())); |
|
77 | + $application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig())); |
|
78 | + $application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig())); |
|
79 | + $application->add(new OC\Core\Command\Background\Ajax(\OC::$server->getConfig())); |
|
80 | 80 | |
81 | - $application->add(new OC\Core\Command\Config\App\DeleteConfig(\OC::$server->getConfig())); |
|
82 | - $application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->getConfig())); |
|
83 | - $application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->getConfig())); |
|
84 | - $application->add(new OC\Core\Command\Config\Import(\OC::$server->getConfig())); |
|
85 | - $application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->getSystemConfig(), \OC::$server->getAppConfig())); |
|
86 | - $application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->getSystemConfig())); |
|
87 | - $application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig())); |
|
88 | - $application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig())); |
|
81 | + $application->add(new OC\Core\Command\Config\App\DeleteConfig(\OC::$server->getConfig())); |
|
82 | + $application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->getConfig())); |
|
83 | + $application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->getConfig())); |
|
84 | + $application->add(new OC\Core\Command\Config\Import(\OC::$server->getConfig())); |
|
85 | + $application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->getSystemConfig(), \OC::$server->getAppConfig())); |
|
86 | + $application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->getSystemConfig())); |
|
87 | + $application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig())); |
|
88 | + $application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig())); |
|
89 | 89 | |
90 | - $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig()))); |
|
91 | - $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger())); |
|
92 | - $application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection())); |
|
93 | - $application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher())); |
|
94 | - $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection())); |
|
95 | - $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection())); |
|
96 | - $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager())); |
|
97 | - $application->add(new OC\Core\Command\Db\Migrations\GenerateFromSchemaFileCommand(\OC::$server->getConfig(), \OC::$server->getAppManager(), \OC::$server->getDatabaseConnection())); |
|
98 | - $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager(), \OC::$server->getConfig())); |
|
90 | + $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig()))); |
|
91 | + $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger())); |
|
92 | + $application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection())); |
|
93 | + $application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher())); |
|
94 | + $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection())); |
|
95 | + $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection())); |
|
96 | + $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager())); |
|
97 | + $application->add(new OC\Core\Command\Db\Migrations\GenerateFromSchemaFileCommand(\OC::$server->getConfig(), \OC::$server->getAppManager(), \OC::$server->getDatabaseConnection())); |
|
98 | + $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager(), \OC::$server->getConfig())); |
|
99 | 99 | |
100 | - $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig())); |
|
101 | - $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager())); |
|
102 | - $application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->getConfig())); |
|
103 | - $application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->getConfig())); |
|
104 | - $application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager())); |
|
105 | - $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper())); |
|
106 | - $application->add(new OC\Core\Command\Encryption\DecryptAll( |
|
107 | - \OC::$server->getEncryptionManager(), |
|
108 | - \OC::$server->getAppManager(), |
|
109 | - \OC::$server->getConfig(), |
|
110 | - new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()), |
|
111 | - new \Symfony\Component\Console\Helper\QuestionHelper()) |
|
112 | - ); |
|
100 | + $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig())); |
|
101 | + $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager())); |
|
102 | + $application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->getConfig())); |
|
103 | + $application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->getConfig())); |
|
104 | + $application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager())); |
|
105 | + $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper())); |
|
106 | + $application->add(new OC\Core\Command\Encryption\DecryptAll( |
|
107 | + \OC::$server->getEncryptionManager(), |
|
108 | + \OC::$server->getAppManager(), |
|
109 | + \OC::$server->getConfig(), |
|
110 | + new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()), |
|
111 | + new \Symfony\Component\Console\Helper\QuestionHelper()) |
|
112 | + ); |
|
113 | 113 | |
114 | - $application->add(new OC\Core\Command\Log\Manage(\OC::$server->getConfig())); |
|
115 | - $application->add(new OC\Core\Command\Log\File(\OC::$server->getConfig())); |
|
114 | + $application->add(new OC\Core\Command\Log\Manage(\OC::$server->getConfig())); |
|
115 | + $application->add(new OC\Core\Command\Log\File(\OC::$server->getConfig())); |
|
116 | 116 | |
117 | - $view = new \OC\Files\View(); |
|
118 | - $util = new \OC\Encryption\Util( |
|
119 | - $view, |
|
120 | - \OC::$server->getUserManager(), |
|
121 | - \OC::$server->getGroupManager(), |
|
122 | - \OC::$server->getConfig() |
|
123 | - ); |
|
124 | - $application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot( |
|
125 | - $view, |
|
126 | - \OC::$server->getUserManager(), |
|
127 | - \OC::$server->getConfig(), |
|
128 | - $util, |
|
129 | - new \Symfony\Component\Console\Helper\QuestionHelper() |
|
130 | - ) |
|
131 | - ); |
|
132 | - $application->add(new OC\Core\Command\Encryption\ShowKeyStorageRoot($util)); |
|
117 | + $view = new \OC\Files\View(); |
|
118 | + $util = new \OC\Encryption\Util( |
|
119 | + $view, |
|
120 | + \OC::$server->getUserManager(), |
|
121 | + \OC::$server->getGroupManager(), |
|
122 | + \OC::$server->getConfig() |
|
123 | + ); |
|
124 | + $application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot( |
|
125 | + $view, |
|
126 | + \OC::$server->getUserManager(), |
|
127 | + \OC::$server->getConfig(), |
|
128 | + $util, |
|
129 | + new \Symfony\Component\Console\Helper\QuestionHelper() |
|
130 | + ) |
|
131 | + ); |
|
132 | + $application->add(new OC\Core\Command\Encryption\ShowKeyStorageRoot($util)); |
|
133 | 133 | |
134 | - $application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->getConfig(), new \OC\AppFramework\Utility\TimeFactory())); |
|
135 | - $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader())); |
|
136 | - $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector())); |
|
137 | - $application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig())); |
|
138 | - $application->add(new OC\Core\Command\Maintenance\UpdateHtaccess()); |
|
139 | - $application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory())); |
|
134 | + $application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->getConfig(), new \OC\AppFramework\Utility\TimeFactory())); |
|
135 | + $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader())); |
|
136 | + $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector())); |
|
137 | + $application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig())); |
|
138 | + $application->add(new OC\Core\Command\Maintenance\UpdateHtaccess()); |
|
139 | + $application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory())); |
|
140 | 140 | |
141 | - $application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class))); |
|
142 | - $application->add(new OC\Core\Command\Maintenance\Repair( |
|
143 | - new \OC\Repair([], \OC::$server->getEventDispatcher()), |
|
144 | - \OC::$server->getConfig(), |
|
145 | - \OC::$server->getEventDispatcher(), |
|
146 | - \OC::$server->getAppManager() |
|
147 | - )); |
|
141 | + $application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class))); |
|
142 | + $application->add(new OC\Core\Command\Maintenance\Repair( |
|
143 | + new \OC\Repair([], \OC::$server->getEventDispatcher()), |
|
144 | + \OC::$server->getConfig(), |
|
145 | + \OC::$server->getEventDispatcher(), |
|
146 | + \OC::$server->getAppManager() |
|
147 | + )); |
|
148 | 148 | |
149 | - $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
150 | - $application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager())); |
|
151 | - $application->add(new OC\Core\Command\User\Disable(\OC::$server->getUserManager())); |
|
152 | - $application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager())); |
|
153 | - $application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager())); |
|
154 | - $application->add(new OC\Core\Command\User\Report(\OC::$server->getUserManager())); |
|
155 | - $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager())); |
|
156 | - $application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); |
|
157 | - $application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager())); |
|
158 | - $application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
149 | + $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
150 | + $application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager())); |
|
151 | + $application->add(new OC\Core\Command\User\Disable(\OC::$server->getUserManager())); |
|
152 | + $application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager())); |
|
153 | + $application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager())); |
|
154 | + $application->add(new OC\Core\Command\User\Report(\OC::$server->getUserManager())); |
|
155 | + $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager())); |
|
156 | + $application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); |
|
157 | + $application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager())); |
|
158 | + $application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
159 | 159 | |
160 | - $application->add(new OC\Core\Command\Group\Add(\OC::$server->getGroupManager())); |
|
161 | - $application->add(new OC\Core\Command\Group\Delete(\OC::$server->getGroupManager())); |
|
162 | - $application->add(new OC\Core\Command\Group\ListCommand(\OC::$server->getGroupManager())); |
|
163 | - $application->add(new OC\Core\Command\Group\AddUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
164 | - $application->add(new OC\Core\Command\Group\RemoveUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
160 | + $application->add(new OC\Core\Command\Group\Add(\OC::$server->getGroupManager())); |
|
161 | + $application->add(new OC\Core\Command\Group\Delete(\OC::$server->getGroupManager())); |
|
162 | + $application->add(new OC\Core\Command\Group\ListCommand(\OC::$server->getGroupManager())); |
|
163 | + $application->add(new OC\Core\Command\Group\AddUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
164 | + $application->add(new OC\Core\Command\Group\RemoveUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
165 | 165 | |
166 | - $application->add(new OC\Core\Command\Security\ListCertificates(\OC::$server->getCertificateManager(null), \OC::$server->getL10N('core'))); |
|
167 | - $application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager(null))); |
|
168 | - $application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager(null))); |
|
166 | + $application->add(new OC\Core\Command\Security\ListCertificates(\OC::$server->getCertificateManager(null), \OC::$server->getL10N('core'))); |
|
167 | + $application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager(null))); |
|
168 | + $application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager(null))); |
|
169 | 169 | } else { |
170 | - $application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getSystemConfig())); |
|
170 | + $application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getSystemConfig())); |
|
171 | 171 | } |