Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm currently setting up e-mail piping to a PHP script in a directory not accessible by others (it's set to 750). Postfix runs the pipe command under the user 'nobody', who naturally won't be able to access the script. I'm a bit hesitant in adding execute permissions to that folder, since I don't want other users to be able to access it (even if they don't know the path). So, what I do want, is to have the pipe command run under a different user, that does have access to that folder.

The server I want to do this on has Virtualmin installed. I've set everything up with Virtualmin, including the alias that is fed to the PHP script. There's several threads on the Virtualmin forum about this issue, but there's no solution there yet other than making the folder executable by others.

So, how can I let the pipe command run under a different user than nobody?

share|improve this question
1  
cmd1 | sudo -u otheruser cmd2, if you setup sudo to allow nobody to run cmd2. –  forcefsck Nov 29 '12 at 13:04
    
You don't really know what postfix is, do you ? :) –  adaptr Nov 29 '12 at 13:31
add comment

1 Answer

As documented, pipe(8) can execute as any user you tell it to - except root.
That, and only that, will execute as nobody.

yourscript unix - - n - - pipe user=<uid> argv=<yourexecutable>

The user= takes any existing unix user, and runs the pipe(8) instance under those credentials.

share|improve this answer
    
Thanks for your response. It doesn't completely answer my question, though. How do I "link" (for the lack of a better word) my alias to that command? So when an e-mail is sent to support@example.com, that specific command gets executed? I've already got an alias in /etc/aliases which looks like: support-example.com: "|php -q /home/user/public_html/subfolder/script.php". –  mpkossen Nov 29 '12 at 14:01
    
If you alias that to the user you want the script to run under, you can then pipe it to PHP in their .forward file. –  adaptr Nov 29 '12 at 14:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.