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

I thought I had set up postfix to receive email to a catchall address at my domain and run a command as a certain user (on my box).

This is not the case, because if I email 'brian@domain.com' and there is a 'brain' user on my box, postfix tries to send the email to his mailbox, when what I wanted was for it to execute a command as another user.

Here are some relevant configs:

main.cf:

myhostname = li133-75.members.linode.com
#alias_maps = hash:/etc/aliases
#alias_database = hash:/etc/aliases
mydestination = pcre:/etc/postfix/mydestinations
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

virtual_alias_maps = pcre:/etc/postfix/virtual
luser_relay = destructly
local_recipient_maps =  
mailbox_command = /usr/local/bin/node /home/destructly/parser/server.js
parent_domain_matches_subdomains=

mydestinations

/^li133-75\.members\.linode.com$/       ACCEPT
/^localhost\.members\.linode.com$/      ACCEPT
/^localhost$/                       ACCEPT
/^.*\.destructly\.com$/                 ACCEPT

virtual

/^.*@destructly\.com$/      destructly

I am a complete n00b at postfix, but my motivation for this config was that I would want to set up postfix to call other commands for other domains on my box, so I don't want to have one command for all emails that come into my box.

Edit: Logs

Here is a log of an email that worked as expected. i.e: i sent to a non-existing user and my mailbox_command was called:

Feb 14 16:49:57 dogself postfix/smtpd[793]: connect from mail-wi0-f173.google.com[209.85.212.173]
Feb 14 16:49:58 dogself postfix/smtpd[793]: 7C8738115: client=mail-wi0-f173.google.com[209.85.212.173]
Feb 14 16:49:58 dogself postfix/cleanup[796]: 7C8738115: message-id=<CALKwPdZn3tFFMz8QL-FKCXSA_-_Z0+AkxgeXB40gbJVn7GeN_Q@mail.gmail.com>
Feb 14 16:49:58 dogself postfix/qmgr[784]: 7C8738115: from=<misha@openmile.com>, size=2281, nrcpt=1 (queue active)
Feb 14 16:49:58 dogself postfix/local[797]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
Feb 14 16:49:58 dogself postfix/smtpd[793]: disconnect from mail-wi0-f173.google.com[209.85.212.173]
Feb 14 16:49:59 dogself postfix/local[797]: 7C8738115: to=<destructly@li133-75.members.linode.com>, orig_to=<petvirus@gmail.com.destructly.com>, relay=local, delay=1.3, delays=0.26/0.01/0/1, dsn=2.0.0, status=sent (delivered to command: /usr/local/bin/node /home/destructly/parser/server.js)
Feb 14 16:49:59 dogself postfix/qmgr[784]: 7C8738115: removed

Here is an email sent to an existing user on the box. My mailbox command is not called using the correct user, thus the error:

Feb 14 16:50:42 dogself postfix/smtpd[793]: connect from mail-wi0-f177.google.com[209.85.212.177]
Feb 14 16:50:42 dogself postfix/smtpd[793]: 9A78C8115: client=mail-wi0-f177.google.com[209.85.212.177]
Feb 14 16:50:42 dogself postfix/cleanup[796]: 9A78C8115: message-id=<CALKwPdZa064fWkc5U2YsaUM1m3bvdS-v-gBacefq1giD+MeaEw@mail.gmail.com>
Feb 14 16:50:42 dogself postfix/qmgr[784]: 9A78C8115: from=<misha@openmile.com>, size=2283, nrcpt=1 (queue active)
Feb 14 16:50:42 dogself postfix/local[797]: 9A78C8115: to=<brian@openmile.com.destructly.com>, relay=local, delay=0.31, delays=0.25/0/0/0.06, dsn=5.3.0, status=bounced (Command died with status 1: "/usr/local/bin/node /home/destructly/parser/server.js".  Command output:  module.js:340     throw err;           ^ Error: Cannot find module '/home/destructly/parser/server.js'     at Function.Module._resolveFilename (module.js:338:15)     at Function.Module._load (module.js:280:25)     at Module.runMain (module.js:492:10)     at process.startup.processNextTick.process._tickCallback (node.js:244:9))
Feb 14 16:50:42 dogself postfix/cleanup[796]: D0E9F8117: message-id=<20130214165042.D0E9F8117@li133-75.members.linode.com>
Feb 14 16:50:42 dogself postfix/bounce[803]: 9A78C8115: sender non-delivery notification: D0E9F8117
Feb 14 16:50:42 dogself postfix/qmgr[784]: D0E9F8117: from=<>, size=4959, nrcpt=1 (queue active)
Feb 14 16:50:42 dogself postfix/qmgr[784]: 9A78C8115: removed
Feb 14 16:50:42 dogself postfix/smtpd[793]: disconnect from mail-wi0-f177.google.com[209.85.212.177]
Feb 14 16:50:43 dogself postfix/smtp[804]: D0E9F8117: to=<misha@openmile.com>, relay=ASPMX.L.GOOGLE.com[74.125.134.26]:25, delay=0.66, delays=0/0.01/0.08/0.58, dsn=2.0.0, status=sent (250 2.0.0 OK 1360860643 z5si23425577ani.83 - gsmtp)
Feb 14 16:50:43 dogself postfix/qmgr[784]: D0E9F8117: removed
Feb 14 16:54:03 dogself postfix/anvil[787]: statistics: max connection rate 1/60s for (smtp:74.125.82.178) at Feb 14 16:48:06
Feb 14 16:54:03 dogself postfix/anvil[787]: statistics: max connection count 1 for (smtp:74.125.82.178) at Feb 14 16:48:06
Feb 14 16:54:03 dogself postfix/anvil[787]: statistics: max cache size 2 at Feb 14 16:50:42

(I was using mailbox_command_maps previously, and in that case the command was no called at all)

mailbox_command_maps:

destructly /usr/local/bin/node /home/destructly/parser/server.js

Here is the log of it not being called when using mailbox_command_maps:

Feb 14 16:36:26 dogself postfix/local[576]: 5A8108115: to=<destructly@li133-75.members.linode.com>, orig_to=<koryak@gmail.com.destructly.com>, relay=local, delay=1.3, delays=0.26/0.01/0/1.1, dsn=2.0.0, status=sent (delivered to command: /usr/local/bin/node /home/destructly/parser/server.js)
Feb 14 16:36:26 dogself postfix/qmgr[31228]: 5A8108115: removed
Feb 14 16:38:18 dogself postfix/smtpd[580]: connect from mail-wi0-f179.google.com[209.85.212.179]
Feb 14 16:38:19 dogself postfix/smtpd[580]: 5A6C08115: client=mail-wi0-f179.google.com[209.85.212.179]
Feb 14 16:38:19 dogself postfix/cleanup[583]: 5A6C08115: message-id=<CALKwPda6e3NDzzAxnqJaZGaD+38sfq94NG_Jy1VMLQOABMUmbw@mail.gmail.com>
Feb 14 16:38:19 dogself postfix/qmgr[31228]: 5A6C08115: from=<misha@openmile.com>, size=2305, nrcpt=1 (queue active)
Feb 14 16:38:19 dogself postfix/local[584]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
Feb 14 16:38:19 dogself postfix/local[584]: 5A6C08115: to=<brian@openmile.com.destructly.com>, relay=local, delay=0.25, delays=0.24/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 14 16:38:19 dogself postfix/qmgr[31228]: 5A6C08115: removed
Feb 14 16:38:19 dogself postfix/smtpd[580]: disconnect from mail-wi0-f179.google.com[209.85.212.179]
share|improve this question
    
But doesn't "catchall address" mean just that? If the address exists, deliver it normally. If it doesn't, deliver it to the catchall target. You may have to configure the check for existing users differently. Use a table only (don't know the details by heart) and leave that empty. Does your catchall work if you send mail to a non-existing user? –  Hauke Laging Feb 14 '13 at 17:07
    
Can you show a log entry of what happens when postfix receives an email? –  NickW Feb 14 '13 at 17:09
    
@hauke: you are right, a catchall does mean that. I need to modify it to always send to one user. Yes it does work as expected when i send emails to a non-existing user –  mkoryak Feb 14 '13 at 17:16
    
@NickW - i included a bunch or relevant info –  mkoryak Feb 14 '13 at 17:21
1  
Have a look at proper virtual domains, and virtual users, postfix has plenty of good documentation on the subject. What is also nice is delivery to virtual users is by default "nobody" which means it will run in the same manner as the email to unknown users. –  NickW Feb 14 '13 at 17:45

1 Answer 1

Postfix is trying to run your mailbox_command to deliver mail for brian, but it failed:

Feb 14 16:50:42 dogself postfix/local[797]: 9A78C8115: to=<brian@openmile.com.destructly.com>, relay=local, delay=0.31, delays=0.25/0/0/0.06, dsn=5.3.0, status=bounced
(Command died with status 1: "/usr/local/bin/node /home/destructly/parser/server.js". 
Command output:  module.js:340     throw err;           ^
Error: Cannot find module '/home/destructly/parser/server.js'
     at Function.Module._resolveFilename (module.js:338:15)
     at Function.Module._load (module.js:280:25)
     at Module.runMain (module.js:492:10)
     at process.startup.processNextTick.process._tickCallback (node.js:244:9))

This may be due to the user which Postfix runs the command as. From the documentation:

Optional external command that the local(8) delivery agent should use for mailbox delivery. The command is run with the user ID and the primary group ID privileges of the recipient. Exception: command delivery for root executes with $default_privs privileges.

So when mail is delivered for a real user like brian, the command is run as that use (i.e. as brian). When mail is delivered for a virtual user it probably runs it as default_privs (which is nobody by default).

Check that your command can successfully be run by the brian user.

share|improve this answer
    
this isnt the solution i am looking for, because i want my command to always run as one user that i specify. I have a bunch of users on my box, i do not want to make sure all those users can run my command –  mkoryak Feb 14 '13 at 18:19

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.