Discussion:
Bug#662159: bash and dash play ping-pong with the /bin/sh diversion
Andreas Beckmann
2012-03-04 14:15:32 UTC
Permalink
Package: bash,dash
Severity: important
User: debian-***@lists.debian.org
Usertags: piuparts

Hi,

the owner of the /bin/sh diversion after a lenny->squeeze->wheezy
upgrade is either bash or dash depending on unrelated packages (seen
this on freebsd-buildutils and ash so far) being installed.

Excerpts from the attached logfile, a piuparts test for
lenny->squeeze->wheezy upgrades:

Preparation: create minimal lenny chroot

Part 1:
* clone the minimal lenny,
* distupgrade to squeeze,
* distupgrade to wheezy:

[...]
Selecting previously deselected package dash.
Unpacking dash (from .../dash_0.5.5.1-7.4_amd64.deb) ...
Adding 'diversion of /bin/sh to /bin/sh.distrib by dash'
Adding 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
Setting up dash (0.5.5.1-7.4) ...
[...]
Preparing to replace bash 3.2-4 (using .../archives/bash_4.1-3_amd64.deb) ...
Unpacking replacement bash ...
Setting up bash (4.1-3) ...
Installing new version of config file /etc/bash.bashrc ...
Installing new version of config file /etc/skel/.bashrc ...
update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode.
[...]
Preparing to replace bash 4.1-3 (using .../archives/bash_4.2-1_amd64.deb) ...
Unpacking replacement bash ...
Setting up bash (4.2-1) ...
Installing new version of config file /etc/bash.bashrc ...
Installing new version of config file /etc/skel/.bashrc ...
update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode.
[...]
Preparing to replace dash 0.5.5.1-7.4 (using .../dash_0.5.7-2_amd64.deb) ...
Unpacking replacement dash ...
Setting up dash (0.5.7-2) ...
[...]
0m43.0s DEBUG: Starting command: ['chroot', '/tmp/piupartss/tmpVcIWWC', 'dpkg-divert', '--list']
0m43.0s DUMP:
diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash
diversion of /bin/sh to /bin/sh.distrib by dash


Part 2:
* clone the minimal lenny,
* *install extra packages*,
* distupgrade to squeeze,
* distupgrade to wheezy:

[...]
Selecting previously deselected package dash.
Unpacking dash (from .../dash_0.5.4-12_amd64.deb) ...
[...]
Setting up dash (0.5.4-12) ...
[...]
Preparing to replace dash 0.5.4-12 (using .../dash_0.5.5.1-7.4_amd64.deb) ...
Adding 'diversion of /bin/sh to /bin/sh.distrib by dash'
Adding 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
Unpacking replacement dash ...
Setting up dash (0.5.5.1-7.4) ...
Removing 'diversion of /bin/sh to /bin/sh.distrib by dash'
Adding 'diversion of /bin/sh to /bin/sh.distrib by bash'
Removing 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
Adding 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by bash'
[...]
Preparing to replace bash 3.2-4 (using .../archives/bash_4.1-3_amd64.deb) ...
Unpacking replacement bash ...
Setting up bash (4.1-3) ...
Installing new version of config file /etc/bash.bashrc ...
Installing new version of config file /etc/skel/.bashrc ...
update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode.
[...]
Preparing to replace bash 4.1-3 (using .../archives/bash_4.2-1_amd64.deb) ...
Removing 'diversion of /bin/sh to /bin/sh.distrib by bash'
Adding 'diversion of /bin/sh to /bin/sh.distrib by dash'
Removing 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by bash'
Adding 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
Unpacking replacement bash ...
Setting up bash (4.2-1) ...
Installing new version of config file /etc/bash.bashrc ...
Installing new version of config file /etc/skel/.bashrc ...
update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode.
[...]
Preparing to replace dash 0.5.5.1-7.4 (using .../dash_0.5.7-2_amd64.deb) ...
Unpacking replacement dash ...
Setting up dash (0.5.7-2) ...
Removing 'diversion of /bin/sh to /bin/sh.distrib by dash'
Adding 'diversion of /bin/sh to /bin/sh.distrib by bash'
Removing 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
Adding 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by bash'
[...]
1m36.3s DEBUG: Starting command: ['chroot', '/tmp/piupartss/tmpeN6s2x', 'dpkg-divert', '--list']
1m36.3s DUMP:
diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by bash
diversion of /bin/sh to /bin/sh.distrib by bash
1m36.3s DEBUG: Command ok: ['chroot', '/tmp/piupartss/tmpeN6s2x', 'dpkg-divert', '--list']
1m36.3s ERROR: FAIL: Installed diversions (dpkg-divert) not removed by purge:
diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by bash
diversion of /bin/sh to /bin/sh.distrib by bash
1m36.3s ERROR: FAIL: Existing diversions (dpkg-divert) removed/modified:
diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash
diversion of /bin/sh to /bin/sh.distrib by dash


Cheers,

Andreas

PS: I'll set
Affects: freebsd-buildutils
Found: freebsd-buildutils/9.0-2
on this bug s.t. piuparts can automatically classify that failure as
bugged/affected.
Jonathan Nieder
2012-03-04 16:06:58 UTC
Permalink
reassign 662159 dash 0.5.7-2
affects 662159 + bash
retitle 662159 bash and dash play ping-pong with the /bin/sh symlink
quit

Hi Andreas,
Post by Andreas Beckmann
the owner of the /bin/sh diversion after a lenny->squeeze->wheezy
upgrade is either bash or dash depending on unrelated packages (seen
this on freebsd-buildutils and ash so far) being installed.
Thanks for reporting it. I suspect the other packages are a red
herring. It is the upgrade order (i.e., whether bash or dash is
upgraded first) that matters.

Do I understand correctly that this is not causing problems in
everyday use for you (and in particular /bin/sh points to the right
shell) and you are reporting it because it creates noise in piuparts
reports?

Some details below for the morbidly curious[*]. If you have any
questions, just ask.

Thanks and hope that helps,
Jonathan

[*] Making both bash and ash provide /bin/sh, though it was probably
the right choice at the time, put us into a little mess. It is not
scalable --- no other shell can provide /bin/sh (bug#540512) since
that would mean two copies of /bin/sh being diverted to the same
filename and a file conflict. The diversion cannot be removed
(bug#538822), since that would mean two undiverted copies of /bin/sh
and a file conflict.

To escape this tangle, bash no longer provides the /bin/sh symlink in
wheezy --- it's completely dash's responsibility now.

As a detail of mechanics, bash's pre-installation script diverts
/bin/sh on behalf of dash. If it didn't do this, while unpacking the
new version dpkg would notice that /bin/sh has been removed from the
files list and remove it. This is a somewhat nontraditional use of
diversions.

The downside is that in the following sequence:

0. configure dash to make /bin/sh symlink point to bash
1. upgrade bash
2. unpack dash
3. configure dash

at step 2 the symlink points to dash for a few moments until step 3
where it is made to point back to bash again.

There is some code in the dash packaging's experimental branch that
prevents that by making a suitable adjustment to the /bin/sh diversion
in dash's pre-installation script. So dash 0.5.7-2~exp1 from
snapshot.debian.org does not have that problem (but it does still
fiddle with diversions in order to remove /bin/sh from bash safely).
Loading...