1

I am trying to pipe emails received to a script for processing. I have a custom Postfix transport defined in master.cf, as per the following.

transpire unix  -       n       n       -       -       pipe
  flags=Rq user=implantd argv=/opt/transpire/bin/implantproc.py $recipient > /dev/null 2>&1

This works, the emails defined in the local_recipient_map are piped to the script, however I have a permissions issue. It seems as though the script (implantproc.py) does not have write permission to a file, which it will need to run. For example, an NDR showing the permission error.

<test@company.com>: Command died with status 1:
    "/opt/transpire/bin/implantproc.py". Command output: Traceback (most recent
    call last):   File "/opt/transpire/bin/implantproc.py", line 11, in
    <module>     open("log.txt", 'a').write("test!") IOError: [Errno 13]
    Permission denied: 'log.txt'

Final-Recipient: rfc822; test@company.com
Original-Recipient: rfc822;test@company.com
Action: failed
Status: 5.3.0
Diagnostic-Code: x-unix; Traceback (most recent call last):   File
    "/opt/transpire/bin/implantproc.py", line 11, in <module>
    open("log.txt", 'a').write("test!") IOError: [Errno 13] Permission
    denied: 'log.txt'

It is/was my understanding that by default postfix runs under nobody/nogroup, but I have tried chowning the log.txt file with nobody. Also, you will note I have created a specific user, implantd, which should be used to invoke the transport script.

Can anyone advise what I am doing wrong?

  • Some extra information: in an attempt to figure out what user Postfix actually uses to invoke the script, I altered the script to write a simple text file to /tmp. This still failed... Now I am confused! – George Sep 4 '13 at 17:47
  • 1
    OK, some more interesting information. This seems to be limited only to Python. By having the transport call a bash script that simple outputs whoami to an arbitrary file, shows that it does indeed run as the designated implantd user as expected. Weird! – George Sep 5 '13 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.