PHP script to write to /home/userid/ dir. popen not working. how?
| From: | gaukia 345 | Date: | Fri, 12 Apr 2002 06:36:49 +0000 |
| Subject: | PHP script to write to /home/userid/ dir. popen not working. how? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-92725@lists.php.net to get a copy of this message | ||
Hi,
I'm using PHP 4.1.2 to write a webmail. I'm using Procmail along with Sendmail. PHP runs as user nobody or user apache. Note that I have the user id and password in my PHP script from using HTTP authentication. FYI I'm running Mandrake Linux 8.1.
The problem is:
I want to write to some files (procmail recipe files) that'll reside in /home/userid. I tested running su using the below code
$fp=popen("su userid","w");
fputs($fp,"userpassword");
fputs($fp,"cd /home/db/");
fputs($fp,"mkdir THIS_IS_GOOD"); //just testing if I can write to dir
fclose($fp);
exit(done);
1) Even when I enter the wrong password, my PHP code doesn't complain. It dutifully echoes done. Why?
2) Doesn't seem like it's running as it should. How can I achieve what I want to do - to write to a file (specifically to create procmail files called .forward and .procmailrc file) to /home/userid/ dir from a PHP script?
PS: If you're not familiar with procmail, don't worry abt the procmail jargons!
Gaukia
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com