From: vdlaag at natlab dot research dot philips dot com Operating system: RedHat 9.0 PHP version: 5.0.2 PHP Bug Type: Unknown/Other Function Bug description: exec fails for command that works ate the command line
Description: ------------ I have a command line tool that adds records to a database. This is the only way for me to access this database. The command line tool works as follows: createRequest -p -i "value1" -l "value2" etc Each option is followed by the value for the record. The -p option is there so that the ID of the new inserted record is returned to standard output. At the command line this works fine. But as soon as a value contains a & the exec function fails. When a value contains parentheses, they are escaped (so that the escape characters are inserted in the database as well). The configure script for php: './configure' '--prefix=/usr/local/php5' '--enable-safe-mode' '--with-apxs2=/usr/local/httpd/bin/apxs' '--with-gd' '--with-mssql=/usr/local/freetds' '--with-pgsql=/usr/local/pgsql' '--with-mysql=/usr/local/mysql' '--with-ldap=/usr/local/openldap' '--with-png-dir=/usr/local/libpng' '--with-zlib-dir=/usr/local/zlib' '--with-jpeg-dir=/usr/local/jpeg' '--with-freetype-dir=/usr/local/freetype/include/freetype2/freetype' '--with-curl=/usr/local/curl' '--with-mime-magic=/usr/share/magic.mime' '--with-xslt-sablot=/usr/local/Sablot' '--with-expat-dir=/usr/local/expat' '--with-libxml-dir=/usr/local/libxml' '--with-pear' I added the folder that holds the cretaeRequest tool to safe_mode_exec_dir in php.ini Reproduce code: --------------- //These options go OK $Options['-i'] = "Add user to group X"; $Options['-l'] = "vdlaag"; //This option makes the exec command fail $Options['-O] = "IP&S"; //This option results in extra slashes // it yields: Great stuff \(is it not\) $Options['-a'] = "Great stuff (is it not)" $Exec = $_SERVER['DOCUMENT_ROOT'] . "/vdlaag/NewUserForm/IPS/createRequest -p"; foreach ($Options as $option => $value) { $Exec .= " " . $option . " '" . $value . "'"; } $HDTCase = exec($Exec); Expected result: ---------------- I expect to get a number back from the exec command. This happens OK if there are no "weird" charachters in any of the values (like &). Actual result: -------------- It returns nothing and the rest of my script fails as a result. -- Edit bug report at http://bugs.php.net/?id=31088&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31088&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31088&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31088&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31088&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31088&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31088&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31088&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31088&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31088&r=support Expected behavior: http://bugs.php.net/fix.php?id=31088&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31088&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31088&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31088&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31088&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31088&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31088&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31088&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31088&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=31088&r=mysqlcfg