New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve program path detection by using system path and PHP_BINDIR #3184
Comments
Can you be more specific about how it is failing with examples of configuration and more description of the problem |
Will add some screenshots once I'm back in the office tomorrow morning. |
Thanks, I'll take a look tomorrow then. |
So, I've improved the program path detection code so that it now has our predefined list of folders, but it will also include the system path and PHP_BINDIR as a priority. php > include('/usr/share/cacti/site/install/functions.php');
php > print_r (find_search_paths());
Array
(
[0] => /usr/local/sbin
[1] => /usr/local/bin
[2] => /usr/sbin
[3] => /usr/bin
[4] => /sbin
[5] => /bin
[6] => /usr/games
[7] => /usr/local/games
[14] => /usr/local/spine/bin
[15] => /usr/spine/bin
) php > putenv('PHP_BINDIR=/bin');
php > print_r (find_search_paths());
Array
(
[0] => /bin
[1] => /usr/local/sbin
[2] => /usr/local/bin
[3] => /usr/sbin
[4] => /usr/bin
[5] => /sbin
[7] => /usr/games
[8] => /usr/local/games
[15] => /usr/local/spine/bin
[16] => /usr/spine/bin
) php > putenv('PATH=/my/path1:/usr/local/bin:/mypath2');
php > print_r (find_search_paths());
Array
(
[0] => /bin
[1] => /my/path1
[2] => /usr/local/bin
[3] => /mypath2
[5] => /sbin
[6] => /usr/bin
[7] => /usr/sbin
[9] => /usr/local/sbin
[10] => /usr/local/spine/bin
[11] => /usr/spine/bin
) As you can see, by setting the PATH or PHP_BINDIR changes the order of searching but also includes directories that might have been otherwise missed. |
@BSOD2600 may want to double check this on the windows side but I did specify that the path separator is a semi colon (;) rather than colon (:) which unix uses so in theory the code should work the same. |
I've found some customers who have their own PHP versions installed on NFS and added to their PATHs that don't match the install requirements of Cacti, and that this messes up the CLI but not the GUI. We should be compensating for that somehow. I would prefer we always pick local paths, though that would be hard to detect, though not impossible. Maybe forcing a path in config.php is an option too. |
Setting PHP_BINDIR will override all else. We could add a similar config variable as another step, but then which takes priority? |
I would say if you set it in config.php, it is right at the top of the array. |
php > putenv('PHP_BINDIR=1');
php > $config = array('php_path'=>'2');
php > print_r(find_search_paths());
Array
(
[0] => 2
[1] => 1
[2] => /usr/local/sbin
[3] => /usr/local/bin
[4] => /usr/sbin
[5] => /usr/bin
[6] => /sbin
[7] => /bin
[8] => /usr/games
[9] => /usr/local/games
[16] => /usr/local/spine/bin
[17] => /usr/spine/bin
) So, this should now be in effect. |
Module detection fails on a blank system if PHP has been installed in non-default location and in combination with PHP-FPM. path_php_binary is empty per default.
The text was updated successfully, but these errors were encountered: