[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

A problem with bash and a policy solution



Due to  bash bug #23857, the  installation ofsome packages  will fail if
`set -a'  or `set  -o allexport' has  been used  in the root  shell that
executes dpkg.   I submited  many bug reports  about this matter  to the
package  maintainers, until Martin  Schulze suggested  that I  bring the
issue here.

In the  current bash,  if I  ever  use `set  -a',  or `set -o allexport'
(which I  do in  /etc/profile),  even if  I  then reset that  flag, bash
enters a state where all sub shells (including scripts called from other
scripts) inherit the -e option.  This is a bug in bash.

This implies that the pre-  and post-install scripts, which use `set -e'
will export that  option to any scripts they  call.  Usually scripts are
not written to work with `set -e' and fail.  Unfortunately, bash is here
to stay  until it's fixed, so  I think that pre-  and post- installation
scripts should be written with this bug in mind.

In order to see if a  particular installation script is affected by this
bug, you add these two lines anywhere in your /etc/profile:
      set -o allexport
      set +o allexport
This is  a no-op, except that  it triggers the bash  bug.  Then run your
installation scripts and see what happens.

This  bug only hits relatively sophisticated  bash users, but the reason
is not  however  obvious, so  the  user may not  be able  at all to find
what's wrong.  Moreover, even when  the bash bug  is fixed, old versions
of bash will be around for a long time.

A trick to make installation scripts resilient to this bug is to use the
following sequence for  calling  any  script.sh from  inside a  pre-  or
post-installation script:

	set + e
	script.sh || exit $?
	set -e

I propose  that package  maintainers are made  aware of the  problem and
take some action against it.

Thanks for your attention
F.


Reply to: