severity 723843 normal
tags 723843 + patch
thanks

Hi,

On Fri, 20 Sep 2013 13:46:57 +0200 Niels Thykier <ni...@thykier.net>
wrote:
> On 2013-09-20 13:38, Niels Thykier wrote:
> > Package: debconf
> > Version: 1.5.51
> > Severity: minor
> > 
> > Hi,
> > 
> > During a "dpkg-reconfigure localepurge", I hit "EOF" (^D) to one of
> > the questions and it triggered a warning about using an
uninitialized
> > value.  If it is relevant, I was using the "readline" frontend.
> > 
> > """
> > Selecting locale files 
> > Use of uninitialized value $_[1] in join or string at
/usr/share/perl5/Debconf/DbDriver/Stack.pm line 111.
> > You chose not to keep any locales. This means that all locales will
be removed from your system. Are you sure this really is what you want?
> > """
> > 
> > ~Niels
> > 
> 
> 
> So, turns out I can trigger similar warnings in other places too by
> ^D'ing the remaining questions (see warnings.log).

This is not only a warning, but a bug that breaks tzdata. ^D'ing the
debconf question or installing it without a TTY in a container will set
a broken timezone (luckily `/ETC` is a valid one, because `ETC` exists)
[1]:

When a user hits ^D on a `readline` or `teletype` front end,
`Debconf::FrontEnd::Teletype->prompt` will return `undef`. The function
description says: "Anything that uses this function should catch that
and handle it, probably by exiting any read/validate loop it is in."

Checking the return value of the `show` function in the `readline`
front end will fix the warning and revert to the backup (if the debconf
is backup capable) (see attached patch). The bug should probably be
fixed in a different location to also cover the `teletype` front end. I
leave this exercise to the maintainer since I already spend enough time
debugging.

[1] https://launchpad.net/bugs/1899343

-- 
Benjamin Drung
Debian & Ubuntu Developer
From 0f524fc4a48128b6d81fae0f92aca177a6e33bb2 Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.dr...@canonical.com>
Date: Mon, 9 Jan 2023 10:48:40 +0100
Subject: [PATCH] Fix uninitialized value on "EOF" (^D)

During a `dpkg-reconfigure localepurge`, hitting "EOF" (^D) to one of
the questions will trigger a warning about using an uninitialized value:

```
Use of uninitialized value $_[1] in join or string at /usr/share/perl5/Debconf/DbDriver/Stack.pm line 111.
```

The same happens when hitting "EOF" (^D) when reconfiguring tzdata
(`dpkg-reconfigure --frontend readline tzdata`).

When a user hits ^D on a `readline` or `teletype` front end,
`Debconf::FrontEnd::Teletype->prompt` will return `undef`. The function
description says: "Anything that uses this function should catch that
and handle it, probably by exiting any read/validate loop it is in."

Checking the return value of the `show` function in the `readline`
front end will fix the warning and revert to the backup (if the debconf
is backup capable). The bug should probably fixed in a different
location to also cover the `teletype` front end.

Closes: #723843
LP: #1899343
Signed-off-by: Benjamin Drung <benjamin.dr...@canonical.com>
---
 Debconf/FrontEnd/Readline.pm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Debconf/FrontEnd/Readline.pm b/Debconf/FrontEnd/Readline.pm
index 62b3c6c9..2116ba83 100644
--- a/Debconf/FrontEnd/Readline.pm
+++ b/Debconf/FrontEnd/Readline.pm
@@ -151,6 +151,10 @@ sub go {
 	$this->_direction(1);
 	for (; $current > -1 && $current < @elements; $current += $this->_direction) {
 		my $value=$elements[$current]->show;
+		if (not defined $value) {
+			$this->_didbackup(1);
+			return;
+		}
 	}
 
 	if ($current < 0) {
-- 
2.37.2

Reply via email to