|
Posted by 4site on 01/02/06 20:53
After a little research into proc_open and pipes, I've re-worked a
function written by 'mendoza', found in the online PHP Manual at
http://www.php.net/manual/en/function.proc-open.php.
With some judicious form data error checking, this actually works:
function authenticate($user,$old_password,$password) {
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("file","/tmp/error-output.txt", "a")
);
$process = proc_open("passwd ".escapeshellarg($user), $descriptorspec,
$pipes);
if (is_resource($process)) {
fwrite($pipes[0], $old_password."\n");
fwrite($pipes[0], $password."\n");
fwrite($pipes[0], $password."\n");
fclose($pipes[0]);
fclose($pipes[1]);
$return_value = proc_close($process);
return !$return_value;
}
}
Thanks to Colin for pointing me in the right direction...
Navigation:
[Reply to this message]
|