Home » System » System_Command » Bug #1985
[PATCH] default shell not set
Details
| Submitted | 2004-07-26 21:05 UTC |
|---|---|
| From | ieure at php dot net |
| Assigned | arnaud |
| Status | Closed |
| Package | System_Command |
| PHP Version | 4.3.8 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2004-07-26 21:05 UTC] ieure at php dot net
Description:
------------
When System_Command is instantiated, $options['SHELL']
doesn't have a path to a valid shell, which causes all
commands to fail.
The problem is that which() is called with the (possibly
null) $in_shell parameter to the constructor. which() only
checks if a path is executable, not if it is a file which
is executable. This causes it to return the (bare) first
directory with the execute bit listed in the path when it
is called with no arguments.
The attached patch adds a call to is_file(), and fixes the
issue for me. It may be a good idea to have a check for a
null argument before any processing is done in which(), but
this change seemed less intrusive.
--- Command.php.orig 2004-07-26 13:56:28.000000000 -0700
+++ Command.php 2004-07-26 13:58:49.000000000 -0700
@@ -417,7 +417,7 @@
foreach ($paths as $path) {
$location = $path . '/' . $in_cmd;
- if (is_executable($location)) {
+ if (is_file($location) &&
is_executable($location)) {
return $location;
}
}
Reproduce code:
---------------
<?php
require 'System/Command.php';
$sc = new System_Command;
print $sc->options['SHELL'];
?>
Expected result:
----------------
'SHELL' should be set to /bin/sh
Actual result:
--------------
'SHELL' is set to /bin/
[2005-02-19 11:45 UTC] stephan at wentz dot it
This is really a showstopper, shouldn't be to hard to fix this and roll out a new release?! The patched line works fine here...
[2005-12-01 07:23 UTC] cweiske at cweiske dot de
This bug is not fixed. I still have the same error, just because no NULL check is done - which was described as a possible solution by Ian.
It can be fixed some simple lines at the beginning of the function:
function which($program, $fallback = false)
{
if ($program === null) {
return false;
}
...