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: 2021-04-18 04:22 UTC
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: cmb (profile)
Status: No Feedback Package: Program Execution
PHP Version: 5.5.14 OS: FreeBSD
Private report: No CVE-ID: None
 [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

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-06 11:30 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-04-06 11:30 UTC] cmb@php.net
Did you use a thread-safe (ZTS) PHP build?  In this case the
behavior is expected since the CWD is virtual and not really set
for the OS.
 [2021-04-18 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC