Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.8

Bug #1985 [PATCH] default shell not set
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)    
Subscription  


 [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/

Comments

 [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-09-01 12:57 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-09-17 21:14 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [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; } ...