mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
#208 improved GPG open_basedir
This commit is contained in:
parent
25d946b873
commit
ad269597d6
1 changed files with 25 additions and 15 deletions
|
|
@ -1381,22 +1381,32 @@ class GPG
|
|||
|
||||
private static function findBinary($name) : ?string
|
||||
{
|
||||
if (!\ini_get('open_basedir')) {
|
||||
$binary = \trim(`which $name`);
|
||||
if ($binary && \is_executable($binary)) {
|
||||
return $binary;
|
||||
}
|
||||
$locations = [
|
||||
'/sw/bin/',
|
||||
'/usr/bin/',
|
||||
'/usr/local/bin/',
|
||||
'/opt/local/bin/',
|
||||
'/run/current-system/sw/bin/'
|
||||
];
|
||||
foreach ($locations as $location) {
|
||||
if (\is_executable($location . $name)) {
|
||||
return $location . $name;
|
||||
$binary = \trim(`which $name`);
|
||||
if ($binary && \is_executable($binary)) {
|
||||
return $binary;
|
||||
}
|
||||
$locations = [
|
||||
'/sw/bin/',
|
||||
'/usr/bin/',
|
||||
'/usr/local/bin/',
|
||||
'/opt/local/bin/',
|
||||
'/run/current-system/sw/bin/'
|
||||
];
|
||||
$open_basedir = \ini_get('open_basedir');
|
||||
if ($open_basedir) {
|
||||
$open_basedir = \explode(PATH_SEPARATOR, $open_basedir);
|
||||
$locations = \array_filter($locations, function($path) use ($open_basedir) {
|
||||
foreach ($open_basedir as $dir) {
|
||||
if (\str_starts_with($path, $open_basedir)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
foreach ($locations as $location) {
|
||||
if (\is_executable($location . $name)) {
|
||||
return $location . $name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue