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

Bug #12791 Net_Ping does not properly fail when ping is not located
Submitted: 2007-12-28 16:31 UTC Modified: 2009-01-27 15:15 UTC
From: tswicegood Assigned: cconstantine
Status: Closed Package: Net_Ping (version CVS)
PHP Version: 5.2.5 OS: Mac OS X 10.4
Roadmaps: 2.4.4    
Subscription  


 [2007-12-28 16:31 UTC] tswicegood (Travis Swicegood)
Description: ------------ On OSX, "which" returns a successful status regardless of whether it found a suitable match found or not. _setPingPath(), the locator for the ping executable, relies on it returning a non-zero status, or failure, in order to determine if ping was located. This results in exec() attempting to execute "no" instead of /sbin/ping. Test script: --------------- Set PATH to include directory with just which but not ping (on OSX this is /usr/bin for which and /sbin for ping. $ export PATH=/usr/bin $ /path/to/php -f test/test_ping.php localhost Expected result: ---------------- Should see PEAR_Error printed out Actual result: -------------- this can take a few seconds; probably 5-10 seconds... sh: line 1: no: command not found Net_Ping Object ( [_ping_path] => no ping in /usr/bin /usr/local/bin [_result] => Array ( ) ... etc., etc. ...

Comments

 [2009-01-27 15:14 UTC] cconstantine (Craig Constantine)
...as far as I can tell, 'which' behaves correctly (here, on Mac OS 10.5): [craig@shrike]~ $ uname -v Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 [craig@shrike]~ $ which ping /sbin/ping [craig@shrike]~ $ echo $? 0 [craig@shrike]~ $ which notPing [craig@shrike]~ $ echo $? 1 That being said, it's trivial to add an is_executable() as a doublecheck on the results from which.
 [2009-01-27 15:15 UTC] cconstantine (Craig Constantine)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.