php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41361 shell_exec() does not find binaries
Submitted: 2007-05-11 04:57 UTC Modified: 2007-05-12 16:06 UTC
From: sebastian@php.net Assigned: bjori (profile)
Status: Closed Package: Program Execution
PHP Version: 5CVS-2007-05-11 (CVS) OS: Linux
Private report: No CVE-ID: None
 [2007-05-11 04:57 UTC] sebastian@php.net
Description:
------------
sb@vmware ~ % cat test.php 
<?php
shell_exec("php -v");
sb@vmware ~ % which php
/usr/local/php-5.2/bin/php
sb@vmware ~ % php -v
PHP 5.2.3-dev (cli) (built: May 11 2007 05:52:31) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with Xdebug v2.0.0RC4-dev, Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, by Derick Rethans
sb@vmware ~ % php test.php 
sh: php: not found
sb@vmware ~ % vim test.php 
sb@vmware ~ % cat test.php 
<?php
shell_exec("/usr/local/php-5.2/bin/php -v");
sb@vmware ~ % php test.php

Reproduce code:
---------------
<?php
shell_exec("php -v");

Expected result:
----------------
No output.

Actual result:
--------------
sh: php: not found

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-11 12:07 UTC] tony2001@php.net
Cannot reproduce.
What is the value of $PATH? 
Did you try disabling XDebug?
 [2007-05-11 14:46 UTC] sebastian@php.net
$PATH is set to PATH=/usr/local/src/phpunit/3.1:/usr/local/bin:/usr/local/php-5.2/bin:/usr/local/mysql-5.1/bin:/usr/lib/libming/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games, but $_ENV['PATH'] only has /usr/local/src/phpunit/3.1.

The problem also occurs without Xdebug.
 [2007-05-11 15:52 UTC] sebastian@php.net
sb@wopr-mobile ~ % cat test.php                                
<?php
print_r($_ENV);
sb@wopr-mobile ~ % valgrind php test.php                       
==32011== Memcheck, a memory error detector.
==32011== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==32011== Using LibVEX rev 1658, a library for dynamic binary translation.
==32011== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==32011== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework.
==32011== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==32011== For more details, rerun with: -v
==32011== 
Array
(
    [CVS_RSH] => ssh
    [USER] => sb
    [CXXFLAGS] => -march=prescott -O2 -pipe
    [GNOME_KEYRING_SOCKET] => /tmp/keyring-aV2Gx9/socket
    [SSH_AGENT_PID] => 5344
    [LD_LIBRARY_PATH] => /usr/lib/debug:/usr/X11R6/lib/debug
    [SHLVL] => 1
    [OLDPWD] => /usr/local/src/php
    [HOME] => /home/sb
    [DESKTOP_SESSION] => default
    [GTK_RC_FILES] => /etc/gtk/gtkrc:/home/sb/.gtkrc-1.2-gnome2
    [DBUS_SESSION_BUS_ADDRESS] => unix:abstract=/tmp/dbus-tyDNTTBGq8,guid=0589bce6a83acda7de032d0046448ed7
    [GDM_XSERVER_LOCATION] => local
    [COLORTERM] => gnome-terminal
    [LOGNAME] => sb
    [_] => /usr/bin/valgrind
    [WINDOWID] => 29360224
    [TERM] => xterm
    [GNOME_DESKTOP_SESSION_ID] => Default
    [SESSION_MANAGER] => local/wopr-mobile:/tmp/.ICE-unix/5345
    [PATH] => /usr/local/src/phpunit/3.1
    [GLIBCPP_FORCE_NEW] => 1
    [CFLAGS] => -march=prescott -O2 -pipe
    [DISPLAY] => :0.0
    [LANG] => en_US.UTF-8
    [XAUTHORITY] => /home/sb/.Xauthority
    [SSH_AUTH_SOCK] => /tmp/ssh-GSPQwR5343/agent.5343
    [SHELL] => /bin/zsh
    [GDMSESSION] => default
    [PWD] => /home/sb
    [GLIBCXX_FORCE_NEW] => 1
    [LD_PRELOAD] => /usr/lib/valgrind/x86-linux/vgpreload_core.so:/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so
)
==32011== 
==32011== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 49 from 1)
==32011== malloc/free: in use at exit: 0 bytes in 0 blocks.
==32011== malloc/free: 12,467 allocs, 12,467 frees, 1,654,668 bytes allocated.
==32011== For counts of detected errors, rerun with: -v
==32011== All heap blocks were freed -- no leaks are possible.
sb@wopr-mobile ~ % valgrind /usr/local/php-5.2/bin/php test.php
==32029== Memcheck, a memory error detector.
==32029== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==32029== Using LibVEX rev 1658, a library for dynamic binary translation.
==32029== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==32029== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework.
==32029== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==32029== For more details, rerun with: -v
==32029== 
Array
(
    [CVS_RSH] => ssh
    [USER] => sb
    [CXXFLAGS] => -march=prescott -O2 -pipe
    [GNOME_KEYRING_SOCKET] => /tmp/keyring-aV2Gx9/socket
    [SSH_AGENT_PID] => 5344
    [LD_LIBRARY_PATH] => /usr/lib/debug:/usr/X11R6/lib/debug
    [SHLVL] => 1
    [OLDPWD] => /usr/local/src/php
    [HOME] => /home/sb
    [DESKTOP_SESSION] => default
    [GTK_RC_FILES] => /etc/gtk/gtkrc:/home/sb/.gtkrc-1.2-gnome2
    [DBUS_SESSION_BUS_ADDRESS] => unix:abstract=/tmp/dbus-tyDNTTBGq8,guid=0589bce6a83acda7de032d0046448ed7
    [GDM_XSERVER_LOCATION] => local
    [COLORTERM] => gnome-terminal
    [LOGNAME] => sb
    [_] => /usr/bin/valgrind
    [WINDOWID] => 29360224
    [TERM] => xterm
    [GNOME_DESKTOP_SESSION_ID] => Default
    [SESSION_MANAGER] => local/wopr-mobile:/tmp/.ICE-unix/5345
    [PATH] => /usr/local/src/phpunit/3.1:/usr/local/bin:/usr/local/php-5.2/bin:/usr/local/mysql-5.1/bin:/usr/lib/libming/bin:/usr/local/httpd/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    [GLIBCPP_FORCE_NEW] => 1
    [CFLAGS] => -march=prescott -O2 -pipe
    [DISPLAY] => :0.0
    [LANG] => en_US.UTF-8
    [XAUTHORITY] => /home/sb/.Xauthority
    [SSH_AUTH_SOCK] => /tmp/ssh-GSPQwR5343/agent.5343
    [SHELL] => /bin/zsh
    [GDMSESSION] => default
    [PWD] => /home/sb
    [GLIBCXX_FORCE_NEW] => 1
    [LD_PRELOAD] => /usr/lib/valgrind/x86-linux/vgpreload_core.so:/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so
)
==32029== 
==32029== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 49 from 1)
==32029== malloc/free: in use at exit: 0 bytes in 0 blocks.
==32029== malloc/free: 12,465 allocs, 12,465 frees, 1,654,666 bytes allocated.
==32029== For counts of detected errors, rerun with: -v
==32029== All heap blocks were freed -- no leaks are possible.
 [2007-05-11 15:54 UTC] sebastian@php.net
Sorry for the noise, but I thought the valgrind outputs were different.
 [2007-05-12 06:18 UTC] sebastian@php.net
I think that the commit below is responsible for this:

bjori		Sun May  6 14:01:27 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/main	php_ini.c 
    /php-src	NEWS 
  Log:
  MFH: Fixed PHP CLI to use the php.ini from the binary location
 [2007-05-12 16:06 UTC] bjori@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed May 31 15:03:37 2023 UTC