TritonDataCenter / TritonDataCenter/pkgsrc-joyent
Postfix export_environment bug
Nobody has claimed this yet.
- Dominant language
- Makefile
- Stars
- 32
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with /opt/local/etc/postfix/main.cf and the packaging files or entry points producing /opt/local/libexec/postfix/; compare the embedded PATH in the affected binaries with the export_environment setting. Use /home/mlm/test.py and its logged environment as the reproduction, and consider the issue done when the configured PATH reaches the piped process without the hard-coded value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100