Skip to contentSkip to conversation

Remove SHELL from preserved_envvars_exported?

DISCUSSION Phil Blundell 2 participants 2 messages Jun 27, 2011

lore
Share & tools
lore
#0 lore raw

One of my colleagues pointed out to me just now that $SHELL is, somewhat surprisingly, passed through to bitbake subprocesses from the calling environment. Under most circumstances this would be fairly benign since few things actually care about that variable, but it turns out that:

a) flock(1) has the misfeature of using $SHELL rather than /bin/sh if the former is set in the environment (in contrast to system(3), which always uses /bin/sh); and

b) zsh has the misfeature of always reading ~/.zshenv even if it was invoked as "zsh -c ...".

So the net result of all this is that, if you are using zsh as your interactive shell, the contents of your .zshenv end up in the environment for everything that's run under flock and bad results can potentially ensue. In our particular case my colleague was setting $PATH from his .zshenv with predictably unfortunate consequences.

It isn't very obvious to me that having SHELL whitelisted is sensible for anything except interactive tasks. Does anybody know of a reason why it needs to be included everywhere?

p.

#1 lore raw
Quoted 18 lines · Phil Blundell

One of my colleagues pointed out to me just now that $SHELL is, somewhat surprisingly, passed through to bitbake subprocesses from the calling environment.  Under most circumstances this would be fairly benign since few things actually care about that variable, but it turns out that:

a) flock(1) has the misfeature of using $SHELL rather than /bin/sh if the former is set in the environment (in contrast to system(3), which always uses /bin/sh); and

b) zsh has the misfeature of always reading ~/.zshenv even if it was invoked as "zsh -c ...".

So the net result of all this is that, if you are using zsh as your interactive shell, the contents of your .zshenv end up in the environment for everything that's run under flock and bad results can potentially ensue.  In our particular case my colleague was setting $PATH from his .zshenv with predictably unfortunate consequences.

Quoted 4 lines

It isn't very obvious to me that having SHELL whitelisted is sensible for anything except interactive tasks.  Does anybody know of a reason why it needs to be included everywhere?

I don't know why it is the way it is right now, but I want to jump in here and say that as another zsh user, this has bitten me multiple times before as well. I actually have SHELL overridden in my ~/.oe/conf/site.conf to work around it for now. I agree that it should probably not be exported other than for interactive tasks, for what it's worth.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics