I have this code (it's part of the leash shell that list all exec files from $PATH)
private function executables($paths = array()) {
$execs = array();
foreach ($paths as $path) {
foreach (scandir($path) as $item) {
$full_path = $path . "/" . $item;
if (!is_dir($full_path) && is_executable($full_path)) {
$execs[] = $item;
}
}
}
return $execs;
}
it use exec function with 'echo -n $PATH'
$path = $this->shell($token, 'echo -n $PATH', '/');
$settings['path'] = $path['output'];
$paths = explode(":", $settings['path']);
$settings['executables'] = $this->executables($paths);
but php display error "scandir(): open_basedir restriction in effect. File(/usr/local/bin) is not within the allowed path(s)"
, how to prevent it, I've try to wrap the code with try .. finaly with no success.