php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9912 exec calls run programs in the document root: different than PHP3
Submitted: 2001-03-22 00:39 UTC Modified: 2002-06-02 13:36 UTC
From: ale at tana dot it Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.0.4pl1 OS: solaris 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ale at tana dot it
New email:
PHP Version: OS:

 

 [2001-03-22 00:39 UTC] ale at tana dot 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-22 01:27 UTC] ale at tana dot 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-06-14 16:03 UTC] sniper@php.net
Exec() works just fine for me. Could you please 
add a complete (but short!) example script?

 [2001-06-15 03:51 UTC] ale at tana dot 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>




 [2002-06-02 13:36 UTC] derick@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC