Check open basedir for #1555

This commit is contained in:
the-djmaze 2024-04-21 03:52:30 +02:00
parent ff80235ee8
commit 325c748acc
2 changed files with 2 additions and 6 deletions

View file

@ -134,11 +134,7 @@ class Utils
{ {
static $open_basedir; static $open_basedir;
if (null === $open_basedir) { if (null === $open_basedir) {
$open_basedir = \ini_get('open_basedir'); $open_basedir = \array_filter(\explode(PATH_SEPARATOR, \ini_get('open_basedir')));
if ($open_basedir) {
\SnappyMail\Log::warning('OpenBasedir', "open_basedir restriction in effect. Allowed path(s): {$open_basedir}");
}
$open_basedir = \array_filter(\explode(PATH_SEPARATOR, $open_basedir));
} }
if ($open_basedir) { if ($open_basedir) {
foreach ($open_basedir as $dir) { foreach ($open_basedir as $dir) {

View file

@ -484,7 +484,7 @@ abstract class Base
protected static function findBinary($name) : ?string protected static function findBinary($name) : ?string
{ {
$binary = \trim((string) `which $name`); $binary = \trim((string) `which $name`);
if ($binary && \is_executable($binary)) { if ($binary && \RainLoop\Utils::inOpenBasedir($binary) && \is_executable($binary)) {
return $binary; return $binary;
} }
$locations = \array_filter([ $locations = \array_filter([