ddreian
ddreian

Reputation: 1856

How to pipe postfix input to a specific script with user and path?

How can I pipe emails for a specific user to a script AND that script to be ran with a specific user's login.

I have this in my /etc/postfix/master.cf file:

my_transport unix  - n n - 50 pipe
  flags=R user=deploy argv=/srv/www/myscript

My script prints $PATH and whoami to a file and this is what I get

PATH=/usr/bin:/bin
whoami = deploy

If I run sudo su - deploy and run echo "PATH=$PATH" and echo "whoami = $(whoami)" I get

PATH=/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
whoami = deploy

How do I make postfix run myscript as deploy user but with it's real path, not the short one.

Thank you!

Upvotes: 1

Views: 373

Answers (1)

ddreian
ddreian

Reputation: 1856

I made a dirty hack with a new script that I use to call my old script

PATH=/home/deploy/.rbenv/bin:/home/deploy/.rbenv/shims:$PATH
source "$1"
exit $?

More info in this diff

Hope this will be useful to somebody else :D

Upvotes: 1

Related Questions