Bug#189026: debconf protocol gobbles whitespace
Package: debconf
Version: 1.2.34
Severity: normal
Tags: patch
[Cc'ed to debian-boot since this issue has been raised there]
Hi Joey,
in #182287 you fixed debconf so that returned values do not gobble
leading spaces. But there are (at least) 2 other situations where
spaces are currently discarded:
* when setting values (with SET, FSET or SUBST),
* or when reading config files.
This is a real problem since a sequence of GET+SET changes quation
value, which is certainly not the desired result.
Here is a patch, and test files.
Denis
Index: ConfModule.pm
===================================================================
RCS file: /home/cvs/repository/joey-cvs/public/packages/debconf/Debconf/ConfModule.pm,v
retrieving revision 1.34
diff -u -r1.34 ConfModule.pm
--- ConfModule.pm 7 Dec 2002 21:05:36 -0000 1.34
+++ ConfModule.pm 14 Apr 2003 19:54:16 -0000
@@ -188,6 +188,7 @@
return 1 unless defined && ! /^\s*#/; # Skip blank lines, comments.
chomp;
my ($command, @params)=split(' ', $_);
+ s/^\S+ //;
$command=lc($command);
# This command could not be handled by a sub.
if (lc($command) eq "stop") {
@@ -200,7 +201,7 @@
}
# Now call the subroutine for the command.
$command="command_$command";
- my $ret=join(' ', $this->$command(@params));
+ my $ret=join(' ', $this->$command($_, @params));
debug developer => "--> $ret";
if ($ret=~/\n/) {
debug developer => 'Warning: return value is multiline, and would break the debconf protocol. Truncating to first line.';
@@ -248,6 +249,7 @@
sub command_input {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 2;
my $priority=shift;
my $question_name=shift;
@@ -323,6 +325,7 @@
sub command_clear {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 0;
$this->frontend->clear;
@@ -339,6 +342,7 @@
sub command_version {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ > 1;
my $version=shift;
if (defined $version) {
@@ -361,6 +365,7 @@
sub command_capb {
my $this=shift;
+ my $litteral=shift;
$this->client_capb([@_]);
# Set capb_backup on the frontend if the client can backup.
$this->frontend->capb_backup(1) if grep { $_ eq 'backup' } @_;
@@ -379,6 +384,7 @@
sub command_title {
my $this=shift;
+ my $litteral=shift;
$this->frontend->title(join ' ', @_);
return $codes{success};
@@ -408,6 +414,7 @@
sub command_go {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ > 0;
my $ret=$this->frontend->go;
@@ -442,6 +449,7 @@
sub command_get {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 1;
my $question_name=shift;
my $question=Debconf::Question->get($question_name) ||
@@ -463,9 +471,9 @@
sub command_set {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ < 1;
- my $question_name=shift;
- my $value=join(" ", @_);
+ my ($question_name, $value) = ($litteral=~m/(\S+) (.*)/);
my $question=Debconf::Question->get($question_name) ||
return $codes{badparams}, "$question_name doesn't exist";
@@ -481,6 +489,7 @@
sub command_reset {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 1;
my $question_name=shift;
@@ -501,10 +510,9 @@
sub command_subst {
my $this = shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ < 2;
- my $question_name = shift;
- my $variable = shift;
- my $value = (join ' ', @_);
+ my ($question_name, $variable, $value) = ($litteral=~m/(\S+) +(\S+) (.*)/);
my $question=Debconf::Question->get($question_name) ||
return $codes{badparams}, "$question_name doesn't exist";
@@ -522,6 +530,7 @@
sub command_register {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 2;
my $template=shift;
my $name=shift;
@@ -554,6 +563,7 @@
sub command_unregister {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 1;
my $name=shift;
@@ -574,6 +584,7 @@
sub command_purge {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ > 0;
my $iterator=Debconf::Question->iterator;
@@ -593,6 +604,7 @@
sub command_metaget {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 2;
my $question_name=shift;
my $field=shift;
@@ -615,6 +627,7 @@
sub command_fget {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 2;
my $question_name=shift;
my $flag=shift;
@@ -634,10 +647,9 @@
sub command_fset {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ < 3;
- my $question_name=shift;
- my $flag=shift;
- my $value=(join ' ', @_);
+ my ($question_name, $flag, $value) = ($litteral=~m/(\S+) +(\S+) (.*)/);
my $question=Debconf::Question->get($question_name) ||
return $codes{badparams}, "$question_name doesn't exist";
@@ -663,6 +675,7 @@
sub command_visible {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 2;
my $priority=shift;
my $question_name=shift;
@@ -680,6 +693,7 @@
sub command_exist {
my $this=shift;
+ my $litteral=shift;
return $codes{syntaxerror}, "Incorrect number of arguments" if @_ != 1;
my $question_name=shift;
Index: Format/822.pm
===================================================================
RCS file: /home/cvs/repository/joey-cvs/public/packages/debconf/Debconf/Format/822.pm,v
retrieving revision 1.6
diff -u -r1.6 822.pm
--- Format/822.pm 6 Jul 2002 02:26:08 -0000 1.6
+++ Format/822.pm 14 Apr 2003 19:54:17 -0000
@@ -45,7 +45,7 @@
if ($invars) {
if ($line =~ /^\s/) {
$line =~ s/^\s+//;
- my ($var, $value)=split(/\s*=\s*/, $line, 2);
+ my ($var, $value)=split(/\s*=\s?/, $line, 2);
$value=~s/\\n/\n/g;
$ret{variables}->{$var}=$value;
next;
@@ -56,7 +56,7 @@
}
# Process the main structure.
- my ($key, $value)=split(/:\s*/, $line, 2);
+ my ($key, $value)=split(/:\s?/, $line, 2);
$key=lc($key);
if ($key eq 'owners') {
foreach my $owner (split(/,\s+/, $value)) {
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
db_fset test/string seen false
db_input critical test/string || true
db_go
db_get test/string
db_set test/string "$RET"
db_get test/string
echo "GET=$RET="
db_fset test/string foo " bar baz "
db_fget test/string foo
echo "FGET=$RET="
db_fset test/string seen false
db_subst test/string foo " sub st "
db_input critical test/string || true
db_go
db_get test/string
echo "GET=$RET="
Template: test/string
Type: string
Description: Enter a string ${foo} bar
Reply to: