diff options
Diffstat (limited to 'core/Command')
-rw-r--r-- | core/Command/Config/App/Base.php | 2 | ||||
-rw-r--r-- | core/Command/Config/App/SetConfig.php | 25 | ||||
-rw-r--r-- | core/Command/Config/ListConfigs.php | 7 | ||||
-rw-r--r-- | core/Command/Config/System/CastHelper.php | 76 | ||||
-rw-r--r-- | core/Command/Config/System/SetConfig.php | 77 | ||||
-rw-r--r-- | core/Command/Memcache/DistributedClear.php | 47 | ||||
-rw-r--r-- | core/Command/Memcache/DistributedDelete.php | 43 | ||||
-rw-r--r-- | core/Command/Memcache/DistributedGet.php | 40 | ||||
-rw-r--r-- | core/Command/Memcache/DistributedSet.php | 57 | ||||
-rw-r--r-- | core/Command/Router/ListRoutes.php | 129 | ||||
-rw-r--r-- | core/Command/Router/MatchRoute.php | 100 | ||||
-rw-r--r-- | core/Command/User/Add.php | 6 | ||||
-rw-r--r-- | core/Command/User/AuthTokens/Add.php | 4 | ||||
-rw-r--r-- | core/Command/User/ResetPassword.php | 6 |
14 files changed, 515 insertions, 104 deletions
diff --git a/core/Command/Config/App/Base.php b/core/Command/Config/App/Base.php index 07341c4faf9..e90a8e78f5b 100644 --- a/core/Command/Config/App/Base.php +++ b/core/Command/Config/App/Base.php @@ -7,12 +7,14 @@ declare(strict_types=1); */ namespace OC\Core\Command\Config\App; +use OC\Config\ConfigManager; use OCP\IAppConfig; use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; abstract class Base extends \OC\Core\Command\Base { public function __construct( protected IAppConfig $appConfig, + protected readonly ConfigManager $configManager, ) { parent::__construct(); } diff --git a/core/Command/Config/App/SetConfig.php b/core/Command/Config/App/SetConfig.php index 345067cfd45..1f4ab81bf05 100644 --- a/core/Command/Config/App/SetConfig.php +++ b/core/Command/Config/App/SetConfig.php @@ -9,7 +9,6 @@ declare(strict_types=1); namespace OC\Core\Command\Config\App; use OC\AppConfig; -use OCP\Exceptions\AppConfigIncorrectTypeException; use OCP\Exceptions\AppConfigUnknownKeyException; use OCP\IAppConfig; use Symfony\Component\Console\Helper\QuestionHelper; @@ -161,7 +160,6 @@ class SetConfig extends Base { } $value = (string)$input->getOption('value'); - switch ($type) { case IAppConfig::VALUE_MIXED: $updated = $this->appConfig->setValueMixed($appName, $configName, $value, $lazy, $sensitive); @@ -172,34 +170,19 @@ class SetConfig extends Base { break; case IAppConfig::VALUE_INT: - if ($value !== ((string)((int)$value))) { - throw new AppConfigIncorrectTypeException('Value is not an integer'); - } - $updated = $this->appConfig->setValueInt($appName, $configName, (int)$value, $lazy, $sensitive); + $updated = $this->appConfig->setValueInt($appName, $configName, $this->configManager->convertToInt($value), $lazy, $sensitive); break; case IAppConfig::VALUE_FLOAT: - if ($value !== ((string)((float)$value))) { - throw new AppConfigIncorrectTypeException('Value is not a float'); - } - $updated = $this->appConfig->setValueFloat($appName, $configName, (float)$value, $lazy, $sensitive); + $updated = $this->appConfig->setValueFloat($appName, $configName, $this->configManager->convertToFloat($value), $lazy, $sensitive); break; case IAppConfig::VALUE_BOOL: - if (in_array(strtolower($value), ['true', '1', 'on', 'yes'])) { - $valueBool = true; - } elseif (in_array(strtolower($value), ['false', '0', 'off', 'no'])) { - $valueBool = false; - } else { - throw new AppConfigIncorrectTypeException('Value is not a boolean, please use \'true\' or \'false\''); - } - $updated = $this->appConfig->setValueBool($appName, $configName, $valueBool, $lazy); + $updated = $this->appConfig->setValueBool($appName, $configName, $this->configManager->convertToBool($value), $lazy); break; case IAppConfig::VALUE_ARRAY: - $valueArray = json_decode($value, true, flags: JSON_THROW_ON_ERROR); - $valueArray = (is_array($valueArray)) ? $valueArray : throw new AppConfigIncorrectTypeException('Value is not an array'); - $updated = $this->appConfig->setValueArray($appName, $configName, $valueArray, $lazy, $sensitive); + $updated = $this->appConfig->setValueArray($appName, $configName, $this->configManager->convertToArray($value), $lazy, $sensitive); break; } } diff --git a/core/Command/Config/ListConfigs.php b/core/Command/Config/ListConfigs.php index 094348dd9ba..b81bfbf4d18 100644 --- a/core/Command/Config/ListConfigs.php +++ b/core/Command/Config/ListConfigs.php @@ -7,6 +7,7 @@ */ namespace OC\Core\Command\Config; +use OC\Config\ConfigManager; use OC\Core\Command\Base; use OC\SystemConfig; use OCP\IAppConfig; @@ -22,6 +23,7 @@ class ListConfigs extends Base { public function __construct( protected SystemConfig $systemConfig, protected IAppConfig $appConfig, + protected ConfigManager $configManager, ) { parent::__construct(); } @@ -44,6 +46,7 @@ class ListConfigs extends Base { InputOption::VALUE_NONE, 'Use this option when you want to include sensitive configs like passwords, salts, ...' ) + ->addOption('migrate', null, InputOption::VALUE_NONE, 'Rename config keys of all enabled apps, based on ConfigLexicon') ; } @@ -51,6 +54,10 @@ class ListConfigs extends Base { $app = $input->getArgument('app'); $noSensitiveValues = !$input->getOption('private'); + if ($input->getOption('migrate')) { + $this->configManager->migrateConfigLexiconKeys(($app === 'all') ? null : $app); + } + if (!is_string($app)) { $output->writeln('<error>Invalid app value given</error>'); return 1; diff --git a/core/Command/Config/System/CastHelper.php b/core/Command/Config/System/CastHelper.php new file mode 100644 index 00000000000..f2b838bdf9b --- /dev/null +++ b/core/Command/Config/System/CastHelper.php @@ -0,0 +1,76 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\Command\Config\System; + +class CastHelper { + /** + * @return array{value: mixed, readable-value: string} + */ + public function castValue(?string $value, string $type): array { + switch ($type) { + case 'integer': + case 'int': + if (!is_numeric($value)) { + throw new \InvalidArgumentException('Non-numeric value specified'); + } + return [ + 'value' => (int)$value, + 'readable-value' => 'integer ' . (int)$value, + ]; + + case 'double': + case 'float': + if (!is_numeric($value)) { + throw new \InvalidArgumentException('Non-numeric value specified'); + } + return [ + 'value' => (float)$value, + 'readable-value' => 'double ' . (float)$value, + ]; + + case 'boolean': + case 'bool': + $value = strtolower($value); + return match ($value) { + 'true' => [ + 'value' => true, + 'readable-value' => 'boolean ' . $value, + ], + 'false' => [ + 'value' => false, + 'readable-value' => 'boolean ' . $value, + ], + default => throw new \InvalidArgumentException('Unable to parse value as boolean'), + }; + + case 'null': + return [ + 'value' => null, + 'readable-value' => 'null', + ]; + + case 'string': + $value = (string)$value; + return [ + 'value' => $value, + 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, + ]; + + case 'json': + $value = json_decode($value, true); + return [ + 'value' => $value, + 'readable-value' => 'json ' . json_encode($value), + ]; + + default: + throw new \InvalidArgumentException('Invalid type'); + } + } +} diff --git a/core/Command/Config/System/SetConfig.php b/core/Command/Config/System/SetConfig.php index 62ab7f7120f..1b1bdc66a6e 100644 --- a/core/Command/Config/System/SetConfig.php +++ b/core/Command/Config/System/SetConfig.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Output\OutputInterface; class SetConfig extends Base { public function __construct( SystemConfig $systemConfig, + private CastHelper $castHelper, ) { parent::__construct($systemConfig); } @@ -57,7 +58,7 @@ class SetConfig extends Base { protected function execute(InputInterface $input, OutputInterface $output): int { $configNames = $input->getArgument('name'); $configName = $configNames[0]; - $configValue = $this->castValue($input->getOption('value'), $input->getOption('type')); + $configValue = $this->castHelper->castValue($input->getOption('value'), $input->getOption('type')); $updateOnly = $input->getOption('update-only'); if (count($configNames) > 1) { @@ -81,80 +82,6 @@ class SetConfig extends Base { } /** - * @param string $value - * @param string $type - * @return mixed - * @throws \InvalidArgumentException - */ - protected function castValue($value, $type) { - switch ($type) { - case 'integer': - case 'int': - if (!is_numeric($value)) { - throw new \InvalidArgumentException('Non-numeric value specified'); - } - return [ - 'value' => (int)$value, - 'readable-value' => 'integer ' . (int)$value, - ]; - - case 'double': - case 'float': - if (!is_numeric($value)) { - throw new \InvalidArgumentException('Non-numeric value specified'); - } - return [ - 'value' => (float)$value, - 'readable-value' => 'double ' . (float)$value, - ]; - - case 'boolean': - case 'bool': - $value = strtolower($value); - switch ($value) { - case 'true': - return [ - 'value' => true, - 'readable-value' => 'boolean ' . $value, - ]; - - case 'false': - return [ - 'value' => false, - 'readable-value' => 'boolean ' . $value, - ]; - - default: - throw new \InvalidArgumentException('Unable to parse value as boolean'); - } - - // no break - case 'null': - return [ - 'value' => null, - 'readable-value' => 'null', - ]; - - case 'string': - $value = (string)$value; - return [ - 'value' => $value, - 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, - ]; - - case 'json': - $value = json_decode($value, true); - return [ - 'value' => $value, - 'readable-value' => 'json ' . json_encode($value), - ]; - - default: - throw new \InvalidArgumentException('Invalid type'); - } - } - - /** * @param array $configNames * @param mixed $existingValues * @param mixed $value diff --git a/core/Command/Memcache/DistributedClear.php b/core/Command/Memcache/DistributedClear.php new file mode 100644 index 00000000000..424f21f1e81 --- /dev/null +++ b/core/Command/Memcache/DistributedClear.php @@ -0,0 +1,47 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\Command\Memcache; + +use OC\Core\Command\Base; +use OCP\ICacheFactory; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class DistributedClear extends Base { + public function __construct( + protected ICacheFactory $cacheFactory, + ) { + parent::__construct(); + } + + protected function configure(): void { + $this + ->setName('memcache:distributed:clear') + ->setDescription('Clear values from the distributed memcache') + ->addOption('prefix', null, InputOption::VALUE_REQUIRED, 'Only remove keys matching the prefix'); + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $cache = $this->cacheFactory->createDistributed(); + $prefix = $input->getOption('prefix'); + if ($cache->clear($prefix)) { + if ($prefix) { + $output->writeln('<info>Distributed cache matching prefix ' . $prefix . ' cleared</info>'); + } else { + $output->writeln('<info>Distributed cache cleared</info>'); + } + return 0; + } else { + $output->writeln('<error>Failed to clear cache</error>'); + return 1; + } + } +} diff --git a/core/Command/Memcache/DistributedDelete.php b/core/Command/Memcache/DistributedDelete.php new file mode 100644 index 00000000000..ae0855acb03 --- /dev/null +++ b/core/Command/Memcache/DistributedDelete.php @@ -0,0 +1,43 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\Command\Memcache; + +use OC\Core\Command\Base; +use OCP\ICacheFactory; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class DistributedDelete extends Base { + public function __construct( + protected ICacheFactory $cacheFactory, + ) { + parent::__construct(); + } + + protected function configure(): void { + $this + ->setName('memcache:distributed:delete') + ->setDescription('Delete a value in the distributed memcache') + ->addArgument('key', InputArgument::REQUIRED, 'The key to delete'); + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $cache = $this->cacheFactory->createDistributed(); + $key = $input->getArgument('key'); + if ($cache->remove($key)) { + $output->writeln('<info>Distributed cache key <info>' . $key . '</info> deleted</info>'); + return 0; + } else { + $output->writeln('<error>Failed to delete cache key ' . $key . '</error>'); + return 1; + } + } +} diff --git a/core/Command/Memcache/DistributedGet.php b/core/Command/Memcache/DistributedGet.php new file mode 100644 index 00000000000..bf1b00d312d --- /dev/null +++ b/core/Command/Memcache/DistributedGet.php @@ -0,0 +1,40 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\Command\Memcache; + +use OC\Core\Command\Base; +use OCP\ICacheFactory; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class DistributedGet extends Base { + public function __construct( + protected ICacheFactory $cacheFactory, + ) { + parent::__construct(); + } + + protected function configure(): void { + $this + ->setName('memcache:distributed:get') + ->setDescription('Get a value from the distributed memcache') + ->addArgument('key', InputArgument::REQUIRED, 'The key to retrieve'); + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $cache = $this->cacheFactory->createDistributed(); + $key = $input->getArgument('key'); + + $value = $cache->get($key); + $this->writeMixedInOutputFormat($input, $output, $value); + return 0; + } +} diff --git a/core/Command/Memcache/DistributedSet.php b/core/Command/Memcache/DistributedSet.php new file mode 100644 index 00000000000..0f31c22f730 --- /dev/null +++ b/core/Command/Memcache/DistributedSet.php @@ -0,0 +1,57 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\Command\Memcache; + +use OC\Core\Command\Base; +use OC\Core\Command\Config\System\CastHelper; +use OCP\ICacheFactory; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class DistributedSet extends Base { + public function __construct( + protected ICacheFactory $cacheFactory, + private CastHelper $castHelper, + ) { + parent::__construct(); + } + + protected function configure(): void { + $this + ->setName('memcache:distributed:set') + ->setDescription('Set a value in the distributed memcache') + ->addArgument('key', InputArgument::REQUIRED, 'The key to set') + ->addArgument('value', InputArgument::REQUIRED, 'The value to set') + ->addOption( + 'type', + null, + InputOption::VALUE_REQUIRED, + 'Value type [string, integer, float, boolean, json, null]', + 'string' + ); + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $cache = $this->cacheFactory->createDistributed(); + $key = $input->getArgument('key'); + $value = $input->getArgument('value'); + $type = $input->getOption('type'); + ['value' => $value, 'readable-value' => $readable] = $this->castHelper->castValue($value, $type); + if ($cache->set($key, $value)) { + $output->writeln('Distributed cache key <info>' . $key . '</info> set to <info>' . $readable . '</info>'); + return 0; + } else { + $output->writeln('<error>Failed to set cache key ' . $key . '</error>'); + return 1; + } + } +} diff --git a/core/Command/Router/ListRoutes.php b/core/Command/Router/ListRoutes.php new file mode 100644 index 00000000000..8932b549a65 --- /dev/null +++ b/core/Command/Router/ListRoutes.php @@ -0,0 +1,129 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\Command\Router; + +use OC\Core\Command\Base; +use OC\Route\Router; +use OCP\App\AppPathNotFoundException; +use OCP\App\IAppManager; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class ListRoutes extends Base { + + public function __construct( + protected IAppManager $appManager, + protected Router $router, + ) { + parent::__construct(); + } + + protected function configure(): void { + parent::configure(); + $this + ->setName('router:list') + ->setDescription('Find the target of a route or all routes of an app') + ->addArgument( + 'app', + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, + 'Only list routes of these apps', + ) + ->addOption( + 'ocs', + null, + InputOption::VALUE_NONE, + 'Only list OCS routes', + ) + ->addOption( + 'index', + null, + InputOption::VALUE_NONE, + 'Only list index.php routes', + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $apps = $input->getArgument('app'); + if (empty($apps)) { + $this->router->loadRoutes(); + } else { + foreach ($apps as $app) { + if ($app === 'core') { + $this->router->loadRoutes($app, false); + continue; + } + + try { + $this->appManager->getAppPath($app); + } catch (AppPathNotFoundException $e) { + $output->writeln('<comment>App ' . $app . ' not found</comment>'); + return self::FAILURE; + } + + if (!$this->appManager->isEnabledForAnyone($app)) { + $output->writeln('<comment>App ' . $app . ' is not enabled</comment>'); + return self::FAILURE; + } + + $this->router->loadRoutes($app, true); + } + } + + $ocsOnly = $input->getOption('ocs'); + $indexOnly = $input->getOption('index'); + + $rows = []; + $collection = $this->router->getRouteCollection(); + foreach ($collection->all() as $routeName => $route) { + if (str_starts_with($routeName, 'ocs.')) { + if ($indexOnly) { + continue; + } + $routeName = substr($routeName, 4); + } elseif ($ocsOnly) { + continue; + } + + $path = $route->getPath(); + if (str_starts_with($path, '/ocsapp/')) { + $path = '/ocs/v2.php/' . substr($path, strlen('/ocsapp/')); + } + $row = [ + 'route' => $routeName, + 'request' => implode(', ', $route->getMethods()), + 'path' => $path, + ]; + + if ($output->isVerbose()) { + $row['requirements'] = json_encode($route->getRequirements()); + } + + $rows[] = $row; + } + + usort($rows, static function (array $a, array $b): int { + $aRoute = $a['route']; + if (str_starts_with($aRoute, 'ocs.')) { + $aRoute = substr($aRoute, 4); + } + $bRoute = $b['route']; + if (str_starts_with($bRoute, 'ocs.')) { + $bRoute = substr($bRoute, 4); + } + return $aRoute <=> $bRoute; + }); + + $this->writeTableInOutputFormat($input, $output, $rows); + return self::SUCCESS; + } +} diff --git a/core/Command/Router/MatchRoute.php b/core/Command/Router/MatchRoute.php new file mode 100644 index 00000000000..3b90463c7b2 --- /dev/null +++ b/core/Command/Router/MatchRoute.php @@ -0,0 +1,100 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\Command\Router; + +use OC\Core\Command\Base; +use OC\Route\Router; +use OCP\App\IAppManager; +use OCP\Server; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Routing\Exception\MethodNotAllowedException; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; +use Symfony\Component\Routing\RequestContext; + +class MatchRoute extends Base { + + public function __construct( + private Router $router, + ) { + parent::__construct(); + } + + protected function configure(): void { + parent::configure(); + $this + ->setName('router:match') + ->setDescription('Match a URL to the target route') + ->addArgument( + 'path', + InputArgument::REQUIRED, + 'Path of the request', + ) + ->addOption( + 'method', + null, + InputOption::VALUE_REQUIRED, + 'HTTP method', + 'GET', + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $context = new RequestContext(method: strtoupper($input->getOption('method'))); + $this->router->setContext($context); + + $path = $input->getArgument('path'); + if (str_starts_with($path, '/index.php/')) { + $path = substr($path, 10); + } + if (str_starts_with($path, '/ocs/v1.php/') || str_starts_with($path, '/ocs/v2.php/')) { + $path = '/ocsapp' . substr($path, strlen('/ocs/v2.php')); + } + + try { + $route = $this->router->findMatchingRoute($path); + } catch (MethodNotAllowedException) { + $output->writeln('<error>Method not allowed on this path</error>'); + return self::FAILURE; + } catch (ResourceNotFoundException) { + $output->writeln('<error>Path not matched</error>'); + if (preg_match('/\/apps\/([^\/]+)\//', $path, $matches)) { + $appManager = Server::get(IAppManager::class); + if (!$appManager->isEnabledForAnyone($matches[1])) { + $output->writeln(''); + $output->writeln('<comment>App ' . $matches[1] . ' is not enabled</comment>'); + } + } + return self::FAILURE; + } + + $row = [ + 'route' => $route['_route'], + 'appid' => $route['caller'][0] ?? null, + 'controller' => $route['caller'][1] ?? null, + 'method' => $route['caller'][2] ?? null, + ]; + + if ($output->isVerbose()) { + $route = $this->router->getRouteCollection()->get($row['route']); + $row['path'] = $route->getPath(); + if (str_starts_with($row['path'], '/ocsapp/')) { + $row['path'] = '/ocs/v2.php/' . substr($row['path'], strlen('/ocsapp/')); + } + $row['requirements'] = json_encode($route->getRequirements()); + } + + $this->writeTableInOutputFormat($input, $output, [$row]); + return self::SUCCESS; + } +} diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php index 033d2bdc9a2..4de4e247991 100644 --- a/core/Command/User/Add.php +++ b/core/Command/User/Add.php @@ -52,7 +52,7 @@ class Add extends Command { 'password-from-env', null, InputOption::VALUE_NONE, - 'read password from environment variable OC_PASS' + 'read password from environment variable NC_PASS/OC_PASS' ) ->addOption( 'generate-password', @@ -91,10 +91,10 @@ class Add extends Command { // Setup password. if ($input->getOption('password-from-env')) { - $password = getenv('OC_PASS'); + $password = getenv('NC_PASS') ?: getenv('OC_PASS'); if (!$password) { - $output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>'); + $output->writeln('<error>--password-from-env given, but NC_PASS/OC_PASS is empty!</error>'); return 1; } } elseif ($input->getOption('generate-password')) { diff --git a/core/Command/User/AuthTokens/Add.php b/core/Command/User/AuthTokens/Add.php index ad4bf732bd0..89b20535c63 100644 --- a/core/Command/User/AuthTokens/Add.php +++ b/core/Command/User/AuthTokens/Add.php @@ -62,9 +62,9 @@ class Add extends Command { } if ($input->getOption('password-from-env')) { - $password = getenv('NC_PASS') ?? getenv('OC_PASS'); + $password = getenv('NC_PASS') ?: getenv('OC_PASS'); if (!$password) { - $output->writeln('<error>--password-from-env given, but NC_PASS is empty!</error>'); + $output->writeln('<error>--password-from-env given, but NC_PASS/OC_PASS is empty!</error>'); return 1; } } elseif ($input->isInteractive()) { diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php index 2f18c3d473e..0e8b1325770 100644 --- a/core/Command/User/ResetPassword.php +++ b/core/Command/User/ResetPassword.php @@ -41,7 +41,7 @@ class ResetPassword extends Base { 'password-from-env', null, InputOption::VALUE_NONE, - 'read password from environment variable OC_PASS' + 'read password from environment variable NC_PASS/OC_PASS' ) ; } @@ -56,9 +56,9 @@ class ResetPassword extends Base { } if ($input->getOption('password-from-env')) { - $password = getenv('OC_PASS'); + $password = getenv('NC_PASS') ?: getenv('OC_PASS'); if (!$password) { - $output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>'); + $output->writeln('<error>--password-from-env given, but NC_PASS/OC_PASS is empty!</error>'); return 1; } } elseif ($input->isInteractive()) { |