note 84330 added to ref.exec
| From: | Anonymous at osu1 dot php dot net | Date: | Wed, 09 Jul 2008 17:34:37 +0000 |
| Subject: | note 84330 added to ref.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141319@lists.php.net to get a copy of this message | ||
I found this comment on this page:
[begin of quote]
Trying to us the following code failed badly with various results: like "unable to fork",
"access denied", "empty results", depending on what settings I used, ... even
though the same code worked from command line on the server itself.
$retstr = exec('nslookup -type=mx myhost.com', $retarr);
Instead of nslookup I believe this would apply to most programs from the \system32\ directory.
I had to learn that the following finally worked:
$retstr = exec('c:\php\safedir\nslookup -type=mx myhost.com', $retarr);
... but only under the listed preconditions:
1: nslookup.exe is placed (copied) in the directory \php\safedir\
2: the directory \php\safedir\ is included in the system PATH environement variable
3: the file cmd.exe is placed in \php\ as listed by other notes above
4: the directory "c:\php\safedir\" is set in the php.ini setting
safe_mode_exec_dir = "c:\php\safedir\"
.. maybe set in php-activescript.ini as well, depending on your system setup.
5: nslookup is referenced by the full path as otherwise the file from \windows\system32\ will be
called. This happend to me with empty result due to missing rights!
Hope this helps somebody saving some time and headaches.
[end of quote]
This is just to complicated. Only two things are needed:
1. Specific permissions for the IUSR account for read & execute to the cmd.exe in
C:\Windows\System32 directory
2. Specific permissions for the IUSR account for read & execute to the command that's
needed (example: nslookup.exe in C:\Widnows\System23 directory)
With just this two conditions the exec works fine
(This is for an IIS server running on a windows platform)
----
Server IP: 69.147.83.197
Probable Submitter: 148.245.111.80
----
Manual Page -- http://www.php.net/manual/en/ref.exec.php
Edit -- https://master.php.net/note/edit/84330
Del: integrated -- https://master.php.net/note/delete/84330/integrated
Del: useless -- https://master.php.net/note/delete/84330/useless
Del: bad code -- https://master.php.net/note/delete/84330/bad+code
Del: spam -- https://master.php.net/note/delete/84330/spam
Del: non-english -- https://master.php.net/note/delete/84330/non-english
Del: in docs -- https://master.php.net/note/delete/84330/in+docs
Del: other reasons-- https://master.php.net/note/delete/84330
Reject -- https://master.php.net/note/reject/84330
Search -- https://master.php.net/manage/user-notes.php