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.
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:
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:
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.
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:
And then this is what we saw in the log:
As far as I can tell, this path is getting hard-coded somewhere in the packaging process:
Any suggestions?
cc: @nshalman