diff options
author | Reno Reckling <e-github@wthack.de> | 2024-03-06 14:24:00 +0100 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2024-09-20 17:00:06 +0200 |
commit | ef7e857881b72b607f36a41c9f178c12db068b7a (patch) | |
tree | f697f622ce17ecaee56e69c70072c8f23f720566 /lib | |
parent | bc5222726b7f6f04308231ff55b8e89ade582d37 (diff) | |
download | nextcloud-server-ef7e857881b72b607f36a41c9f178c12db068b7a.tar.gz nextcloud-server-ef7e857881b72b607f36a41c9f178c12db068b7a.zip |
feat: make search path for BinaryFinder customizable.
This feature is important for nextcloud running on
distributions like NixOS, where all the standard
search paths do not exist.
Also added tests.
This fixes issue #43922
Co-authored-by: Daniel <mail@danielkesselberg.de>
Signed-off-by: Reno Reckling <e-github@wthack.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/BinaryFinder.php | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/private/BinaryFinder.php b/lib/private/BinaryFinder.php index f7ac7a5195c..3dad245ff0d 100644 --- a/lib/private/BinaryFinder.php +++ b/lib/private/BinaryFinder.php @@ -11,15 +11,28 @@ namespace OC; use OCP\IBinaryFinder; use OCP\ICache; use OCP\ICacheFactory; +use OCP\IConfig; use Symfony\Component\Process\ExecutableFinder; /** * Service that find the binary path for a program */ class BinaryFinder implements IBinaryFinder { + public const DEFAULT_BINARY_SEARCH_PATHS = [ + '/usr/local/sbin', + '/usr/local/bin', + '/usr/sbin', + '/usr/bin', + '/sbin', + '/bin', + '/opt/bin', + ]; private ICache $cache; - public function __construct(ICacheFactory $cacheFactory) { + public function __construct( + ICacheFactory $cacheFactory, + private IConfig $config, + ) { $this->cache = $cacheFactory->createLocal('findBinaryPath'); } @@ -37,15 +50,10 @@ class BinaryFinder implements IBinaryFinder { if (\OCP\Util::isFunctionEnabled('exec')) { $exeSniffer = new ExecutableFinder(); // Returns null if nothing is found - $result = $exeSniffer->find($program, null, [ - '/usr/local/sbin', - '/usr/local/bin', - '/usr/sbin', - '/usr/bin', - '/sbin', - '/bin', - '/opt/bin', - ]); + $result = $exeSniffer->find( + $program, + null, + $this->config->getSystemValue('binary_search_paths', self::DEFAULT_BINARY_SEARCH_PATHS)); if ($result === null) { $result = false; } |