Sample Header Ad - 728x90

How to make the script, configured via sendmail aliases file, run as the user to whom that email is addressed?

1 vote
1 answer
154 views
I have a FreeBSD box running sendmail 8.16. I have several system users (test robots): robot1, robot2 and robot3 and I would like them to be controlled by emails. First of all they should be able to _receive_ emails. So I have the following lines in /etc/mail/aliases: robot1: "| /usr/local/project/script" robot2: "| /usr/local/project/script" robot3: "| /usr/local/project/script" Those robots should process mail in quite the same way, hence the same script is used for them all. The problem is: sendmail always invoke that script with bogus uid 26 (which is "mailnull" special user) for all three recepients. It looks like sendmail daemon downgrades its effective gid/uid on fork, before starting an external script. That's perfectly reasonable, but: The question is: **how do I make sendmail run the script as the respective recepient user**, i.e. as robot1 when the message is for robot1@localhost, as robot2 when the message is for robot2@localhost and as robot3 when the message is for robot3@localhost? Obvious solution is to have three copies of the script, make each copy suid its respective user, and alias each robot user to its copy of the script. That should do the trick, I suppose, but it's kind of ugly. So I wonder if there's some better, more elegant, solution?
Asked by Igor G (133 rep)
Jan 9, 2024, 10:10 AM
Last activity: Jan 9, 2024, 11:20 PM