php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49716 unable to fork using passthru, exec, system when executing page through iis
Submitted: 2009-09-29 20:54 UTC Modified: 2010-02-17 14:14 UTC
From: jbreiding at Hotmail dot com Assigned: pajoye (profile)
Status: Not a bug Package: IIS related
PHP Version: 5.3.0 OS: windows server 2008 x64
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: jbreiding at Hotmail dot com
New email:
PHP Version: OS:

 

 [2009-09-29 20:54 UTC] jbreiding at Hotmail dot com
Description:
------------
i am no longer running this configuration as i found that moving back to 5.2.11 solved this problem.

php 5.3.2 (x86 fastcgi)

windows server 2k8 (x64)

 I have spent a good few days googling around and trying things so let me give you the current state.

cmd.exe copied to php folder, all instances of cmd.exe, including syswow64, given read execute permissions to domain users, local users, iis_iusrs, network service in addition to the defaults

from my users command prompt i can execute php c:\inetpub\wwwroot\forktest.php, as well the same with php-cgi -f c:\inetpub\wwwroot\forktest.php

 system() is giving  a return_val of -1

in procmon.exe i can actually see the create call succeed. the application being executed has also been given the same permissions as cmd.exe, however it is not in the php folder but the full path has been given.

 my application pool, default setup, runs under network service.

here is a snippet that is failing from forktest.php

<?php 
$result = 0;
$resultstr = system('echo %PATH%', $result);
echo "return value is $result \n"; 
echo "output string is $resultstr \n";
?> 

 output:

Warning: system() [function.system]: Unable to fork [echo %PATH%] in C:\inetpub\wwwroot\forktest.php on line 25
return value is -1 output string is 

 i went ahead and deleted the cmd.exe in my php folder and in procmon i am seeing exactly what should be happening, c:\windows\syswow64\cmd.exe.

 it seems my problem is actually executing cmd.exe, not the application i am attempting to execute.




Reproduce code:
---------------
<?php 
$result = 0;
$resultstr = system('echo %PATH%', $result);
echo "return value is $result \n"; 
echo "output string is $resultstr \n";
?> 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-29 21:09 UTC] pajoye@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-10-06 20:26 UTC] jbreiding at Hotmail dot com
unfortunately this is a production system now and i cannot test this at the moment. i was hoping others had stumbled across this problem. my future plans are just to move this entire system to a redhat box.
 [2009-10-07 07:50 UTC] pajoye@php.net
OK, anyway this bug is fixed and there was already another bug report about it. I close it as duplicated (bogus).
 [2010-02-17 14:14 UTC] pajoye@php.net
Quick note here. It is necessary to give a given IUSR_* the permission to use cmd.exe (%COMSPEC%). It is recommended not to do it as it may introduce security issues, obviously. But if you really want to do it, use:

cacls %COMSPEC% /E /G IUSR_xxxx:R
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Feb 04 16:05:48 2023 UTC