Re: PHP script to write to /home/userid/ dir. popen not working. how?
| From: | Jason Wong | Date: | Fri, 12 Apr 2002 07:28:58 +0000 |
| Subject: | Re: PHP script to write to /home/userid/ dir. popen not working. how? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92729@lists.php.net to get a copy of this message | ||
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.
*/