note 77902 added to function.posix-getpwnam
| From: | DidarHossain at osu1 dot php dot net | Date: | Wed, 19 Sep 2007 10:05:05 +0000 |
| Subject: | note 77902 added to function.posix-getpwnam | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130588@lists.php.net to get a copy of this message | ||
My original code is an example of stupid code leading to a security vulnerability. The username and
password can be viewed using the *NIX command `ps'.
Here is a better approach:
<?php
$desc = array(
0 => array("pipe","r"),
1 => array("pipe","w"),
2 => array("file","/tmp/error.out","a")
);
$proc = proc_open('/opt/webpanel/bin/pam_auth -o -1',$desc, $pipes);
if (is_resource($proc)) {
fwrite($pipes[0],$_POST['usr']);
fwrite($pipes[0]," ");
fwrite($pipes[0],$_POST['pass']);
fwrite($pipes[0],"\n");
fclose($pipes[0]);
echo stream_get_contents($pipes[1]);
fclose($pipes[1]);
}
$retval = proc_close($proc);
?>
Example code is mostly a verbatim copy from the proc_open() page.
http://php.net/manual/en/function.proc-open.php
----
Server IP: 203.199.124.111
Probable Submitter: 219.91.185.148
----
Manual Page -- http://www.php.net/manual/en/function.posix-getpwnam.php
Edit -- https://master.php.net/note/edit/77902
Del: integrated -- https://master.php.net/note/delete/77902/integrated
Del: useless -- https://master.php.net/note/delete/77902/useless
Del: bad code -- https://master.php.net/note/delete/77902/bad+code
Del: spam -- https://master.php.net/note/delete/77902/spam
Del: non-english -- https://master.php.net/note/delete/77902/non-english
Del: in docs -- https://master.php.net/note/delete/77902/in+docs
Del: other reasons-- https://master.php.net/note/delete/77902
Reject -- https://master.php.net/note/reject/77902
Search -- https://master.php.net/manage/user-notes.php