Reading spam dir with PHP? {Scanned by HJMS}

Max Kipness mkipness at GENIANT.COM
Thu Oct 2 21:58:35 IST 2003


Sorry, I meant MailWatch...

________________________________

From: MailScanner mailing list on behalf of Max Kipness
Sent: Thu 10/2/2003 3:54 PM
To: MAILSCANNER at JISCMAIL.AC.UK
Subject: Re: Reading spam dir with PHP? {Scanned by HJMS}



Thanks to everyone that answered.

Does MailScanner allow you to send the mail through to the user in the case of a false-postitive?

The other thing I'm wanting to do is eventually allow individual users to see all spam collected for them (only) and send emails through.

Max

________________________________

From: MailScanner mailing list on behalf of Furnish, Trever G
Sent: Thu 10/2/2003 3:49 PM
To: MAILSCANNER at JISCMAIL.AC.UK
Subject: Re: Reading spam dir with PHP? {Scanned by HJMS}



Hmmm... I guess there are several routes you could take, including sudo.

But MailWatch is pretty straight-forward to install and it already offers
the functionality you want to create.

The approach taken by MailWatch was to run a cronjob every minute as root to
recursively chown/chmod the directory.

I think a combo of this and sudo might be better - sudo alone would be sort
of annoying because everything sudo does gets logged.  You could instead
check to see whether you can access the files you want (since that will
happen rarely) and if not, then use sudo to run a command to modify their
ownership/permissions and attempt the access again.  That way the
chown/chmod would only run when needed and you wouldn't be creating an
effectively suid root script that takes input from the web.

Your sudo script could be simply:
#!/bin/sh
chown -R root:apache /var/spool/MailScanner/quarantine
chmod -R g+rwx /var/spool/MailScanner/quarantine
exit 0

And your php page would only run it if it failed to open a file.  If the
failure recurs after running the sudo script, then it's not related to
permissions.

Having started to play with MailWatch though I'm very impressed with it and
would recommend trying it first.

-t.


> -----Original Message-----
> From: Max Kipness [mailto:mkipness at GENIANT.COM]
> Sent: Thursday, October 02, 2003 3:37 PM
> To: MAILSCANNER at JISCMAIL.AC.UK
> Subject: Reading spam dir with PHP? {Scanned by HJMS}
>
>
> Hello,
>
> Sorry if I'm off topic. This may be more of a PHP or general
> linux question.
>
> I'm trying to write a php page that reads the ../spam dir.
> I'm planning on having the page read each q* file and parse
> the From:, To: and Subject: lines and then have a button for
> each message that basically copies the q* and d* files to the
> sendmail queue.
>
> At this point I'm trying to figure out the best way to get
> access to that directory structure as user Apache. All of the
> dir/files under ./var/spool/MailScanner have rw for root
> only. Is the answer sudo?
>
> Thanks,
> Max
>




More information about the MailScanner mailing list