[Debconf-devel] Bug#922279: debconf: Can't select long choices in dialog (whiptail) multiselect

Kevin Locke kevin at kevinlocke.name
Thu Feb 14 05:51:17 GMT 2019


Package: debconf
Version: 1.5.70
Severity: normal
Tags: patch

Dear Maintainer,

After upgrading libpam-cap, systemd user sessions stopped working.  I
traced the problem to pam-auth-update, which uses debconf to manage the
PAM configuration.  Using the dialog frontend with whiptail in a
terminal that is 80 characters wide, it is not possible to enable the
pam_systemd module, even if it is selected in whiptail.  To reproduce:

DEBIAN_FRONTEND=dialog DEBCONF_DEBUG=developer PERL_DL_NONLAZY=1 /usr/share/debconf/frontend sh -c '
. /usr/share/debconf/confmodule
db_x_loadtemplatefile /var/lib/dpkg/info/libpam-runtime.templates libpam-runtime
db_subst libpam-runtime/profiles profile_names unix, systemd, mkhomedir, cgfs, capability
db_subst libpam-runtime/profiles profiles Unix authentication, Register user sessions in the systemd control group hierarchy, Create home directory on login, Create cgroups for user login sessions, Inheritable Capabilities Management
db_fset libpam-runtime/profiles seen false
db_set libpam-runtime/profiles unix, systemd, cgfs, capability
db_input critical libpam-runtime/profiles || echo $RET
db_go
db_get libpam-runtime/profiles
echo "<$RET>"'

Which will produce output like the following:

debconf (developer): frontend started
debconf (developer): Trying to find a templates file..
debconf (developer): Trying sh.templates
debconf (developer): Trying /usr/share/debconf/templates/sh.templates
debconf (developer): Couldn't find a templates file.
debconf (developer): frontend running, package name is 
debconf (developer): starting sh -c 
. /usr/share/debconf/confmodule
db_x_loadtemplatefile /var/lib/dpkg/info/libpam-runtime.templates libpam-runtime
db_subst libpam-runtime/profiles profile_names unix, systemd, mkhomedir, cgfs, capability
db_subst libpam-runtime/profiles profiles Unix authentication, Register user sessions in the systemd control group hierarchy, Create home directory on login, Create cgroups for user login sessions, Inheritable Capabilities Management
db_fset libpam-runtime/profiles seen false
db_set libpam-runtime/profiles unix, systemd, cgfs, capability
db_input critical libpam-runtime/profiles || echo $RET
db_go
db_get libpam-runtime/profiles
echo "<$RET>"
debconf (developer): <-- X_LOADTEMPLATEFILE /var/lib/dpkg/info/libpam-runtime.templates libpam-runtime
debconf (developer): --> 0
debconf (developer): <-- SUBST libpam-runtime/profiles profile_names unix, systemd, mkhomedir, cgfs, capability
debconf (developer): --> 0
debconf (developer): <-- SUBST libpam-runtime/profiles profiles Unix authentication, Register user sessions in the systemd control group hierarchy, Create home directory on login, Create cgroups for user login sessions, Inheritable Capabilities Management
debconf (developer): --> 0
debconf (developer): <-- FSET libpam-runtime/profiles seen false
debconf (developer): --> 0 false
debconf (developer): <-- SET libpam-runtime/profiles unix, systemd, cgfs, capability
debconf (developer): --> 0 value set
debconf (developer): <-- INPUT critical libpam-runtime/profiles
debconf (developer): --> 0 question will be asked
debconf (developer): <-- GO 
debconf (developer): Input value, "Register user sessions in the systemd control group ..." not found in C choices! This should never happen. Perhaps the templates were incorrectly localized.
debconf (developer): --> 0 ok
debconf (developer): <-- GET libpam-runtime/profiles
debconf (developer): --> 0 unix, cgfs, capability
<unix, cgfs, capability>

Note that systemd does not appear in the output regardless of whether or
not the option is selected.  The problem is that the ellipsized choice
text can't be mapped back to the choice value.  I have attached a patch
which adds this mapping.  It also handles the case that ellipsized
options become ambiguous by allowing screen overflow instead of blindly
mapping both to a single value.

Thanks for considering,
Kevin

P.S.  I have set Severity: normal, but the systemd breakage was severe
and difficult to track down without familiarity with systemd user
sessions.  The issue may have significant impact.


-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (101, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.20.8 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8), LANGUAGE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages debconf depends on:
ii  perl-base  5.28.1-4

Versions of packages debconf recommends:
ii  apt-utils     1.8.0~rc2
ii  debconf-i18n  1.5.70

Versions of packages debconf suggests:
pn  debconf-doc                <none>
pn  debconf-kde-helper         <none>
pn  debconf-utils              <none>
pn  libgtk3-perl               <none>
pn  libnet-ldap-perl           <none>
ii  libterm-readline-gnu-perl  1.36-1
ii  perl                       5.28.1-4
ii  whiptail                   0.52.20-8

-- debconf information:
* debconf/frontend: Dialog
* debconf/priority: medium
  debconf-apt-progress/info:
  debconf-apt-progress/title:
  debconf-apt-progress/media-change:
  debconf-apt-progress/preparing:
-------------- next part --------------
>From aa4aaf42dca62a11ad3981312fc095f708192c18 Mon Sep 17 00:00:00 2001
Message-Id: <aa4aaf42dca62a11ad3981312fc095f708192c18.1550122022.git.kevin at kevinlocke.name>
From: Kevin Locke <kevin at kevinlocke.name>
Date: Wed, 13 Feb 2019 22:17:07 -0700
Subject: [PATCH] Dialog/Multiselect: Fix ellipsized selections

When displaying a multiselect using the dialog frontend with whiptail,
if any choices are changed by the ellipsize method (i.e. any choices are
longer than the available screen width to display choices) they can not
be selected.  Running with DEBCONF_DEBUG=developer prints the message:

    debconf (developer): Input value, "%s" not found in C choices! This should never happen. Perhaps the templates were incorrectly localized.

The cause is that translate_to_C is unable to map the ellipsized choice
text back to the choice value.  This commit adds a hash to do so.  It
also fixes the problem that choices may become ambiguous by allowing
screen overflow in this case.

Signed-off-by: Kevin Locke <kevin at kevinlocke.name>
---
 Debconf/Element/Dialog/Multiselect.pm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Debconf/Element/Dialog/Multiselect.pm b/Debconf/Element/Dialog/Multiselect.pm
index 781655c7..d3b6e4cf 100644
--- a/Debconf/Element/Dialog/Multiselect.pm
+++ b/Debconf/Element/Dialog/Multiselect.pm
@@ -10,6 +10,7 @@ package Debconf::Element::Dialog::Multiselect;
 use strict;
 use base qw(Debconf::Element::Multiselect);
 use Debconf::Encoding qw(width);
+use Debconf::Log qw(debug);
 
 =head1 DESCRIPTION
 
@@ -53,8 +54,18 @@ sub show {
 	$lines=$lines + $menu_height + $this->frontend->spacer;
 	my $selectspacer = $this->frontend->selectspacer;
 	my $c=1;
+	my %unellipsized;
 	foreach (@choices) {
 		my $choice = $this->frontend->ellipsize($_);
+
+		if (exists $unellipsized{$choice}) {
+		    debug 'developer' => sprintf
+			'Ambiguous ellipsized choice "%s": "%s" or "%s".  Overflow.',
+			$choice, $unellipsized{$choice}, $_;
+		    $choice = $_;
+		}
+		$unellipsized{$choice} = $_;
+
 		push @params, ($choice, "");
 		push @params, ($value{$_} ? 'on' : 'off');
 
@@ -78,7 +89,7 @@ sub show {
 		# Dialog returns the selected items, each on a line.
 		# Translate back to C, and turn into our internal format.
 		$this->value(join(", ", $this->order_values(
-					map { $this->translate_to_C($_) }
+					map { $this->translate_to_C($unellipsized{$_}) }
 					split(/\n/, $value))));
 	}
 	else {
-- 
2.20.1



More information about the Debconf-devel mailing list