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

Re: "dpkg-reconfigure" dash no longer works



On 2023-06-09 12:06 -0400, The Wanderer wrote:

> On 2023-06-09 at 12:00, Charles Curley wrote:
>
>> On Fri, 9 Jun 2023 13:38:25 +0000
>> S M <mythrowy777@hotmail.com> wrote:
>>
>>> I noticed on a newly installed system with Debian 12 that
>>> dpkg-reconfigure no longer allows to switch the /bin/sh symlink from
>>> dash to bash.
>>
>> You can still change it manually (rm ; ln -s).
>
> Or just 'ln -sf', to do it in something closer to an atomic fashion.
>
> Except that, since (at least from what I can see on a quick check) the
> /bin/sh symlink appears to be shipped explicitly in the dash package,
> next time that package gets upgraded the symlink will probably be
> overwritten with one pointing back to dash again.
>
> If the system is smart enough to not replace a sysadmin-edited symlink
> during package upgrade, then that wouldn't happen - but I'd honestly
> expect that it would, since otherwise if a symlink got messed up and
> broke things, reinstalling the package it came from wouldn't be
> guaranteed to fix those things.

That is true.  However, you can avoid that by diverting the /bin/sh
symlink which tells dpkg to unpack it under a different name.  To do so,
you have to first remove the diversion that dash itself sets up.  The
following six commands change the /bin/sh symlink permanently to bash
and also take care of the manpage:

# dpkg-divert --remove --no-rename /usr/share/man/man1/sh.1.gz
# dpkg-divert --remove --no-rename /bin/sh
# ln -sf bash.1.gz /usr/share/man/man1/sh.1.gz
# ln -sf bash /bin/sh
# dpkg-divert --add --local --no-rename /usr/share/man/man1/sh.1.gz
# dpkg-divert --add --local --no-rename /bin/sh

The version of dash in experimental no longer diverts the /bin/sh
symlink itself, so in the future the first two steps will not be
necessary.  The dash maintainer wanted to include this change in
bookworm, but was turned down by the release team[1].

> Of course, there's still the question of the *reason* why this change
> was made and why using anything but dash for /bin/sh is now considered
> no longer supported. I don't have any explanation for that, and until
> the maintainers actually give one, neither do the rest of us - but in
> the absence of one, it's hard to be sure that pointing the symlink to
> /bin/bash won't break something.

Unfortunately neither the Debian changelog of dash nor the commit
message for this change[2] give an explanation.  Removing the debconf
handling certainly simplifies the package, and there are not too many
scripts around that start with "#!/bin/sh" and fail to work with dash -
these are the reasons I can think of.

There is also an open bug against the release notes[3] filed by the dash
maintainer.

Cheers,
       Sven

1. https://bugs.debian.org/1035745
2. https://salsa.debian.org/debian/dash/-/commit/c322a1c9fc6be11d7eb4439407c0a398aba8bbb7
3. https://bugs.debian.org/1036907


Reply to: