Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postfix export_environment bug #11

Open
njones11 opened this issue Jul 21, 2014 · 0 comments
Open

Postfix export_environment bug #11

njones11 opened this issue Jul 21, 2014 · 0 comments

Comments

@njones11
Copy link

Postfix provides the 'export_environment' option to define which environment variables should be passed to processes it calls.

See here: http://www.postfix.org/postconf.5.html#export_environment

In our case, we're using Postfix to deliver mail to a local system account. Inside the system account's .forward file, we have something like this:

|/home/mlm/test.py

Basically, postfix pipes all the mail to this script which does further processing. Inside /opt/local/etc/postfix/main.cf, we have several environment variables defined that our script needs to see.

export_environment = PATH=/home/mlm/virtualenv/bin PYTHONPATH=/home/mlm/virtualenv/lib/python2.7/site-packages/

We know that PYTHONPATH is being set correctly. However, for some reason, PATH is not getting correctly passed to the script. As far as I can tell, this looks like a packaging bug.

Inside test.py, we added this for debugging:

    for key in os.environ:
        logging.info("%s: %s" % (key, os.environ[key]))

And then this is what we saw in the log:

2014-07-21 11:02:48,112 - root - INFO - PATH: /usr/bin:/usr/ucb
2014-07-21 11:02:48,113 - root - INFO - PYTHONPATH: /home/mlm/virtualenv/lib/python2.7/site-packages/

As far as I can tell, this path is getting hard-coded somewhere in the packaging process:

# for i in `ls /opt/local/libexec/postfix/`;do echo $i: `strings /opt/local/libexec/postfix/$i | grep ucb` ;done
anvil:
bounce:
cleanup: /usr/bin:/usr/ucb
discard:
dnsblog:
error:
flush:
lmtp:
local: /usr/bin:/usr/ucb
main.cf:
master:
master.cf:
nqmgr:
oqmgr:
pickup:
pipe: /usr/bin:/usr/ucb
post-install: PATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd
postfix-files:
postfix-script:
postfix-wrapper:
postmulti-script:
postscreen:
proxymap:
qmgr:
qmqpd: /usr/bin:/usr/ucb
scache:
showq:
smtp:
smtpd: /usr/bin:/usr/ucb
spawn: /usr/bin:/usr/ucb
tlsmgr:
tlsproxy:
trivial-rewrite:
verify:
virtual:

Any suggestions?

cc: @nshalman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant