note 48654 added to function.shell-exec
| From: | php-general at lists dot php dot net | Date: | Mon, 03 Jan 2005 17:10:58 +0000 |
| Subject: | note 48654 added to function.shell-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82649@lists.php.net to get a copy of this message | ||
Be careful as to how you elevate privileges to your php script. It's a good idea to use
caution and planing. It is easy to open up huge security holes. Here are a couple of helpful hints
I've gathered from experimentation and Unix documentation.
Things to think about:
1. If you are running php as an Apache module in Unix then every system command you run is run as
user apache. This just makes sense.. Unix won't allow privileges to be elevated in this
manner. If you need to run a system command with elevated privileges think through the problem
carefully!
2. You are absolutely insane if you decide to run apache as root. You may as well kick yourself in
the face. There is always a better way to do it.
3. If you decide to use a SUID it is best not to SUID a script. SUID is disabled for scripts on
many flavors of Unix. SUID scripts open up security holes, so you don't always want to go this
route even if it is an option. Write a simple binary and elevate the privileges of the binary as a
SUID. In my own opinion it is a horrible idea to pass a system command through a SUID-- ie have the
SUID accept the name of a command as a parameter. You may as well run Apache as root!
----
Manual Page -- http://www.php.net/manual/en/function.shell-exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48654
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48654&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48654&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48654&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48654&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48654&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48654&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48654&report=yes
Search -- http://master.php.net/manage/user-notes.php