Bug #9912 Updated: exec calls run programs in the document root: different than PHP3
| From: | derick@php.net | Date: | Sun, 02 Jun 2002 17:36:39 +0000 |
| Subject: | Bug #9912 Updated: exec calls run programs in the document root: different than PHP3 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-9168@lists.php.net to get a copy of this message | ||
ID: 9912
Updated by: derick@php.net
Reported By: ale@tana.it
-Status: Open
+Status: Bogus
Bug Type: Program Execution
Operating System: solaris 7
PHP Version: 4.0.4pl1
New Comment:
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php
If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
Previous Comments:
------------------------------------------------------------------------
[2001-06-15 03:51:35] ale@tana.it
<?php
function my_example_func()
{
global $filename, $output;
$cmd = "ls -l " . escapeshellcmd($filename);
$out = array();
$rtc = 0;
exec($cmd, &$out, &$rtc);
if ($rtc == 0)
{
error_log("The file now exists", 0);
$output = implode("<br>", $out);
return 1;
}
else
{
error_log("Now it doesn't", 0);
return 0;
}
}
?>
<!doctype html public "-//W3C//DTD html 4.0 transitional//EN">
<html>
<head>
<title>Bug 9912</title>
</head>
<body>
<h1>Bug 9912</h1>
<p>This php script checks its own existence twice.
The log on my system is
<pre>
[Fri Jun 15 09:46:48 2001] [error] The file now exists
./bug9912.php: No such file or directory
Now it doesn't
</pre>
<p>The function expects the file name on
a global variable. To demonstrate the bug we use a
relative filename.
<?php
$filename = "./bug9912.php";
$output = "";
$bb = my_example_func();
register_shutdown_function("my_example_func");
printf("The filename \"$filename\" actually does%s exist",
$bb ? "" : " NOT");
printf("<p><code>%s</code></p>", $output);
?>
</body>
</html>
------------------------------------------------------------------------
[2001-06-14 16:03:16] sniper@php.net
Exec() works just fine for me. Could you please
add a complete (but short!) example script?
------------------------------------------------------------------------
[2001-03-22 01:27:00] ale@tana.it
Ok, it wasn't that. I'm sorry. The short/long desc should be
"exec calls run shutdown functions in root", and
A script that has a function with lines like
exec("mycommand ./myparam.filename etc", &$srtc, &$rtc);
and works when called regularly, stops working
if called in a registered shutdown function.
Execution is run in the filesystem root.
PHP3 scripts with such shutdown functions
are broken in php4.
------------------------------------------------------------------------
[2001-03-22 00:39:49] ale@tana.it
php3 scripts that have lines like
exec("mycommand ./myparam.filename etc", &$srtc, &$rtc);
are broken in php4, although easily fixed.
I was uncertain whether to post this as a bug or just add a
note in http://www.php.net/manual/en/migration4.php
I decided for the former since I saw there is a VIRTUAL_DIR
that might have expanded popen into virtual_popen, and if that stuff
works, perhaps next PHP4 release will have it turned on by default.
The workaround on unix might be, for each exec call not on the doc
root,
# cd /my/doc/root
# ln -n -s mydir/mysubdir/myparam.filename .
it allows taking further action whenever
this bug/feature will be fixed/documented
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=9912&edit=1