php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67552 proc_open is using a wrong initial working dir
Submitted: 2014-07-02 08:47 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: iron at mail dot ua Assigned:
Status: Open Package: Program Execution
PHP Version: 5.5.14 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: iron at mail dot ua
New email:
PHP Version: OS:

 

 [2014-07-02 08:47 UTC] iron at mail dot ua
Description:
------------
I have the same issue under FreeBSD 10 with php-5.5.14 as #50524 but only with proc_open(). Under Linux I got the expected result.

Test script:
---------------
<?php
chdir('/home/webadmin/test');
$fdSpecs = array(
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes);
echo 'Without $cwd argument:', PHP_EOL;
echo stream_get_contents($pipes[1]);

echo PHP_EOL;

$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes, NULL);
echo 'With NULL as $cwd argument:', PHP_EOL;
echo stream_get_contents($pipes[1]);

echo PHP_EOL;

$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes, getcwd());
echo 'With getcwd() as $cwd argument:', PHP_EOL;
echo stream_get_contents($pipes[1]);

echo PHP_EOL;

$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes, '/');
echo 'With "/" as $cwd argument:', PHP_EOL;
echo stream_get_contents($pipes[1]);

echo PHP_EOL;

echo 'Exec $CWD: ', PHP_EOL;
echo exec('php -r "var_dump(getcwd());"'), PHP_EOL;
?>

Expected result:
----------------
Without $cwd argument:
string(14) "/home/webadmin/test"

With NULL as $cwd argument:
string(14) "/home/webadmin/test"

With getcwd() as $cwd argument:
string(19) "/home/webadmin/test"

With "/" as $cwd argument:
string(1) "/"

Exec $CWD: 
string(19) "/home/webadmin/test"

Actual result:
--------------
Without $cwd argument:
string(14) "/home/webadmin"

With NULL as $cwd argument:
string(14) "/home/webadmin"

With getcwd() as $cwd argument:
string(19) "/home/webadmin/test"

With "/" as $cwd argument:
string(1) "/"

Exec $CWD: 
string(19) "/home/webadmin/test"

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Nov 18 22:01:39 2019 UTC