Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Problem writing when running script from Postfix mail to script

by Xxaxx (Monk)
on Jul 12, 2006 at 06:20 UTC ( [id://560624]=perlquestion: print w/replies, xml ) Need Help??

Xxaxx has asked for the wisdom of the Perl Monks concerning the following question:

I have a script which accepts input via email. The content drives the update of a news page on my website.

The script runs fine on old colocated server. Slackware, Apache, Qmail.

On the new server my script receives the input okay, but I can't write to files because of permissions issue.

Apparently qmail was performing a little magic (i.e. I didn't set the config, it just happened to work straight out of the box) such that when an email was passed into a perl script the user was set to be the domain user. Thus the script had all the necessary permissions.

With Postfix I am not so lucky. When the email calls the perl script it is running as a different user which does not have permissions to write.

I've been off in the world of Java for a while and more than a bit rusty on the finer points of perl. I would be most appreciative of a clue about where to look to solve this problem.

Thanks in advance, Claude

  • Comment on Problem writing when running script from Postfix mail to script

Replies are listed 'Best First'.
Re: Problem writing when running script from Postfix mail to script
by grinder (Bishop) on Jul 12, 2006 at 06:46 UTC

    This is not a Perl problem.

    Postfix processes run with the minimum privileges required to get the job done. Handing off a message from the Postfix core to an external process is done via the master.cf file. You can specify under which account name the process should be run. That should solve your permissions issue. Note that you will require root access to edit the file and signal the changes with a postfix reload.

    • another intruder with the mooring in the heart of the Perl

Re: Problem writing when running script from Postfix mail to script
by Khen1950fx (Canon) on Jul 12, 2006 at 08:11 UTC
Re: Problem writing when running script from Postfix mail to script
by Anonymous Monk on Jul 16, 2006 at 20:39 UTC
    Qmail is executing the script as the mailbox owner. Postfix can probably be made to do it, but changing that definitely requires root access and a look in the Postfix docs.

    Your script is probably running as 'nobody' or a similar non-privileged account.

    A work around:
    1. The email script writes files in a public directory: /tmp/news-update or similar.
    2. A cron job is run every 1-5 minutes, as the user who owns the web directory, it reads /tmp/news-updates and incorporate changes.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://560624]
Approved by shmem
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (9)
As of 2024-04-23 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found