From:             carsten_sttgt at gmx dot de
Operating system: Windows_NT
PHP version:      5.3.1
PHP Bug Type:     Program Execution
Bug description:  proc_open is using a wrong initial working dir

Description:
------------
Hello,

each program execution function:
- exec()
- passthru()
- shell_exec()
- system()
- backtick operator
or popen() is using the current script (working) directory as working
directory for the command which is executed.

Only proc_open() is using a different directory:
- for apache2handler it the Apache ServerRoot
- for CGI it's the php-cgi.exe directory
- for FastCGI (mod_fgcid) it's also the php-cgi.exe directory

On *nix (mod_fcgid) the proc_open() working directory is as expected also
the script (working) directory.

Regards,
Carsten


Reproduce code:
---------------
<?php
header('Content-Type: text/plain');
echo "------getcwd()---------\n";
echo getcwd()."\n\n";


echo "\n\n-------popen()---------\n";
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    $cmd = 'dir';
} else {
    $cmd = 'ls';
}
$process = popen($cmd, 'r');
while (!feof($process)) {
    echo fread($process, 80);
}
pclose($process);


echo "\n\n-------passthru()------\n";
passthru($cmd);


echo "\n\n------proc_open()------\n";
$descriptorspec = array(
   0 => array('pipe', 'r'),
   1 => array('pipe', 'w'),
   2 => array('pipe', 'w')
);
$process = proc_open($cmd, $descriptorspec, $pipes);
while (!feof($pipes[1])) {
   echo fread($pipes[1], 80);
}
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
?>


Expected result:
----------------
getcwd:
C:\Apache2.2\htdocs

3 times a directory listing of:
C:\Apache2.2\htdocs

Actual result:
--------------
getcwd:
C:\Apache2.2\htdocs

2 times (popen, passthru) a directory listing of:
C:\Apache2.2\htdocs

1 time (proc_open) a directory listing of:
apache2handler: C:\Apache2.2
or CGI/FastCGI: C:\PHP


-- 
Edit bug report at http://bugs.php.net/?id=50524&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50524&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50524&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50524&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50524&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50524&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50524&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50524&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50524&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50524&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50524&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50524&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50524&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50524&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50524&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50524&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50524&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50524&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50524&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50524&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50524&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50524&r=mysqlcfg

Reply via email to