[PHP] PHP script to write to /home/userid/ dir. popen not working. how?

2002-04-12 Thread gaukia 345

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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP script to write to /home/userid/ dir. popen not working. how?

2002-04-12 Thread Jason Wong

On Friday 12 April 2002 14:36, gaukia 345 wrote:

 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?

There's nothing in your script to check whether the su operation was 
successful or not. You will see done regardless.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Finally, Zippy drives his 1958 RAMBLER METROPOLITAN into the faculty
dining room.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php