diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-10-15 09:15:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 09:15:58 +0200 |
commit | e36d4a990d19113cd763e5893faaa4d1877d4022 (patch) | |
tree | 0a245efb1e06fe0e998b8a66b31c5f934aa0c642 | |
parent | 82a5833217d8fb1a74e7838b3e2ccf2cb9e1b90c (diff) | |
parent | ec2f02f4a06412218738cd94e6e91bae7f28ac48 (diff) | |
download | nextcloud-server-e36d4a990d19113cd763e5893faaa4d1877d4022.tar.gz nextcloud-server-e36d4a990d19113cd763e5893faaa4d1877d4022.zip |
Merge pull request #10439 from eugulixes/improve-encrypt-all-and-decrypt-all-commands
Check if TTY is invalid in encryption:encrypt-all and encryption:decrypt-all
-rw-r--r-- | core/Command/Encryption/DecryptAll.php | 8 | ||||
-rw-r--r-- | core/Command/Encryption/EncryptAll.php | 8 | ||||
-rw-r--r-- | tests/Core/Command/Encryption/DecryptAllTest.php | 3 | ||||
-rw-r--r-- | tests/Core/Command/Encryption/EncryptAllTest.php | 3 |
4 files changed, 22 insertions, 0 deletions
diff --git a/core/Command/Encryption/DecryptAll.php b/core/Command/Encryption/DecryptAll.php index 9931a279ff4..253223f9529 100644 --- a/core/Command/Encryption/DecryptAll.php +++ b/core/Command/Encryption/DecryptAll.php @@ -123,6 +123,14 @@ class DecryptAll extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { + if ( !$input->isInteractive() ) { + $output->writeln('Invalid TTY.'); + $output->writeln('If you are trying to execute the command in a Docker '); + $output->writeln("container, do not forget to execute 'docker exec' with"); + $output->writeln("the '-i' and '-t' options."); + $output->writeln(''); + return; + } try { if ($this->encryptionManager->isEnabled() === true) { diff --git a/core/Command/Encryption/EncryptAll.php b/core/Command/Encryption/EncryptAll.php index a2b56683324..b16fa0af2c7 100644 --- a/core/Command/Encryption/EncryptAll.php +++ b/core/Command/Encryption/EncryptAll.php @@ -105,6 +105,14 @@ class EncryptAll extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { + if ( !$input->isInteractive() ) { + $output->writeln('Invalid TTY.'); + $output->writeln('If you are trying to execute the command in a Docker '); + $output->writeln("container, do not forget to execute 'docker exec' with"); + $output->writeln("the '-i' and '-t' options."); + $output->writeln(''); + return; + } if ($this->encryptionManager->isEnabled() === false) { throw new \Exception('Server side encryption is not enabled'); diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php index 1b01231ac57..c8572864060 100644 --- a/tests/Core/Command/Encryption/DecryptAllTest.php +++ b/tests/Core/Command/Encryption/DecryptAllTest.php @@ -73,6 +73,9 @@ class DecryptAllTest extends TestCase { $this->decryptAll = $this->getMockBuilder(\OC\Encryption\DecryptAll::class) ->disableOriginalConstructor()->getMock(); $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); + $this->consoleInput->expects($this->any()) + ->method('isInteractive') + ->willReturn(true); $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); $this->config->expects($this->any()) diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php index 554560a35b7..ca7b264c98f 100644 --- a/tests/Core/Command/Encryption/EncryptAllTest.php +++ b/tests/Core/Command/Encryption/EncryptAllTest.php @@ -78,6 +78,9 @@ class EncryptAllTest extends TestCase { ->disableOriginalConstructor() ->getMock(); $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); + $this->consoleInput->expects($this->any()) + ->method('isInteractive') + ->willReturn(true); $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); } |