Bug#994042: libc6: debconf text fallback failed to accept input, had to be killed leading to broken dist-upgrade
On 2021-09-10 20:39, Colin Watson wrote:
> On Fri, Sep 10, 2021 at 09:03:32PM +0200, Aurelien Jarno wrote:
> > On 2021-09-10 16:51, Colin Watson wrote:
> > > The only way to fix what libc.preinst is currently trying to do would
> > > be:
> > >
> > > * Fetch the current debconf frontend *without* first sourcing the
> > > confmodule, e.g. using something like "echo GET debconf/frontend |
> > > debconf-communicate" which I *think* is safe as long as you haven't
> > > sourced the confmodule yet;
> > >
> > > * Decide whether to use debconf based on this and other information;
> > >
> > > * Only source the confmodule if you've positively decided to use it.
> >
> > debconf-communicate might be safe, but its manpage explicitly says it
> > should not be used in maintainer scripts.
>
> Strictly, it says "a maintainer script of a package that uses debconf".
> I think what that really means is that it shouldn't be used after
> sourcing the debconf confmodule (which is normally the same as using
> debconf since nearly everything sources it right at the top - but this
> is a weird edge case). The point is to avoid having multiple processes
> with the debconf database open at the same time.
>
> Put another way, for this purpose, libc6.preinst isn't really a
> maintainer script that uses debconf until it sources the confmodule.
>
> > I gave a try with debconf-show instead. I have attached a totally
> > untested patch to check that we agree on the way to do it.
>
> I think you forgot to attach the patch?
Dooh. Please find a new version attached.
> I wouldn't completely veto using debconf-show in this very specialized
> situation, as long as it came with a substantial comment explaining
> what's going on so that nobody else is tempted to copy it. However, the
> output format of debconf-show isn't guaranteed, so I'm not very happy
> about it being used mechanically like this. I'd prefer
> debconf-communicate if we can ensure that it works in this context,
> notwithstanding its documentation.
Ok, I have updated my patch to use that method.
> > > But a simpler approach might be to update debconf in buster with the
> > > change from 1.5.76 to check whether whiptail/dialog is usable before
> > > trying to use it, and then remove at least some of this fragile and
> > > broken code from libc.preinst. At the very least, USE_DEBCONF=1 must
> > > always be set if (and only if) the debconf confmodule has been sourced.
> >
> > While it is probably a good idea to backport that change in buster to
> > limit to reduce the risk, we don't require people to upgrade to the
> > latest buster release before starting an upgrade.
> >
> > On the other hand, given that bullseye has a fixed debconf, I fully
> > agree that we should drop that fragile code for bookworm.
>
> We probably agree on both points here.
Great.
> > > I'm currently seeing if I can construct a reduced reproduction recipe
> > > based on Neil's logs, since it evidently depends on exactly which order
> > > apt chooses to unpack things early on, and it would be very helpful to
> > > be able to test fixes properly.
> >
> > Thanks, tell me if you need help on that.
>
> I managed to reproduce the reported bug by taking Neil's full package
> list, mangling it to roughly make sense on buster, installing all of
> that, and then doing "apt upgrade && apt full-upgrade" (my own habit is
> just to do "apt full-upgrade", but in this case the initial "apt
> upgrade" is crucial). I'm now trying to more or less bisect the package
> list to find something rather more minimal; this is a slow process, but
> no roadblocks so far, and I'll let you know when I have something.
>
Thanks a lot for your help.
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://www.aurel32.net
commit d67e52a7d1997a3e461b6971b00ce94a136a5b2d
Author: Aurelien Jarno <aurelien@aurel32.net>
Date: Fri Sep 10 20:58:48 2021 +0200
first fix for #994042
diff --git a/debian/debhelper.in/libc.preinst b/debian/debhelper.in/libc.preinst
index d679db4f..e7808a44 100644
--- a/debian/debhelper.in/libc.preinst
+++ b/debian/debhelper.in/libc.preinst
@@ -21,23 +21,22 @@ kfreebsd_compare_versions () {
if [ "$type" != abort-upgrade -a -z "$DPKG_ROOT" ]
then
- # Load debconf module if available and usable
+ # Check if the debconf module is available and usable
if [ -f /usr/share/debconf/confmodule ]; then
# cdebconf has a working fallback mechanism in case dialog
# is not usable, so do not try to do anything smart here
if [ "$DEBCONF_USE_CDEBCONF" ] ; then
- . /usr/share/debconf/confmodule
USE_DEBCONF=1
# debconf requires perl
elif perl -e "" 2>/dev/null ; then
- . /usr/share/debconf/confmodule
# Check that the selected frontend will work
if [ -n "$DEBIAN_FRONTEND" ] ; then
frontend="$DEBIAN_FRONTEND"
else
- db_version 2.0
- db_get debconf/frontend || RET="Dialog"
- frontend="$RET"
+ # Query the frontend without first sourcing the confmodule to avoid
+ # loosing control of the tty. This snipped must not be copied blindly.
+ frontend="$(echo 'GET debconf/frontend' | debconf-communicate | sed '/^0 /!d;s/^0 //')"
+ frontend="${frontend:-Dialog}"
fi
frontend=`echo $frontend | tr '[:upper:]' '[:lower:]'`
case "$frontend" in
@@ -61,6 +60,11 @@ then
fi
fi
+ # Load debconf module if available and usable
+ if [ "$USE_DEBCONF" ]
+ . /usr/share/debconf/confmodule
+ fi
+
# See if LD_LIBRARY_PATH contains the traditional /lib, but not the
# multiarch path
dirs=$(echo $LD_LIBRARY_PATH | sed 's/:/ /g')
Reply to: