Hi there,

This problem seems to happen when using the 'stack' driver because
Debconf::DbDriver uses $this->getfield to look up the template for a
given question. Consider the following scenario:

 - /etc/debconf.conf sets up the config database as a stack consisting
   of 'foo' and 'bar'.

 - 'bar' contains an answer to question 'mypackage/tweakable', but does
   not contain the 'seen' flag.

 - A package maintainer script prompts the user for an answer to
   'mypackage/tweakable', and the user chooses a different answer to
   what is in 'bar'.

 - 'foo' has 'Reject-Type: password' set, so on line 207 of
   Debconf/DbDriver.pm, we enter the conditional block and try to find
   the type of 'mypackage/tweakable'.

 - Because 'foo' (referred to by '$this') has no answer to
   'mypackage/tweakable', there is no record of a template for it, and
   so 'Debconf::Template->get' is called with an empty argument (the
   result of '$this->getfield'). This produces the warnings shown in the
   original bug report.

The problem here is that $this refers to 'foo', not the stacked
database on top of 'foo', and thus the record in 'bar' is never
consulted.

I am attaching a patch which fixes this problem by calling 'getfield'
on $Debconf::Db::config rather than $this. This will do a full search
through the config database for a template for the question, which
makes things work correctly with stacked databases.

Please let me know if you need any further information, or if you think
this can be done in a better way.

Thanks,
Steven.
>From c8a9435f96947998544056982670e9fe6f39b0dd Mon Sep 17 00:00:00 2001
From: Steven McDonald <ste...@steven-mcdonald.id.au>
Date: Tue, 29 Apr 2014 15:51:22 +1000
Subject: [PATCH] Search the full config database for a question's template

Currently, Debconf::DbDriver only searches the current database
(referred to by $this) for a template, which doesn't always work
correctly when using stacked databases.
---
 Debconf/DbDriver.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Debconf/DbDriver.pm b/Debconf/DbDriver.pm
index ef6bdd6..b0db2fa 100644
--- a/Debconf/DbDriver.pm
+++ b/Debconf/DbDriver.pm
@@ -206,7 +206,7 @@ sub accept {
 
 	if (exists $this->{accept_type} || exists $this->{reject_type}) {
 		if (! defined $type || ! length $type) {
-			my $template = Debconf::Template->get($this->getfield($name, 'template'));
+			my $template = Debconf::Template->get($Debconf::Db::config->getfield($name, 'template'));
 			return 1 unless $template; # no type to act on
 			$type=$template->type || '';
 		}
@@ -228,7 +228,7 @@ sub ispassword {
 	my $this=shift;
 	my $item=shift;
 
-	my $template=$this->getfield($item, 'template');
+	my $template=$Debconf::Db::config->getfield($item, 'template');
 	return unless defined $template;
 	$template=Debconf::Template->get($template);
 	return unless $template;
-- 
2.0.0.rc0

Reply via email to