Package: nbd-server
Version: 1:2.8.7-3
Severity: normal
Tags: patch
I have the following /etc/nbd-server file:
NBD_PORT[0]=21544
NBD_FILE[0]=/var/lib/nbd/pulk-pull/swap
NBD_SERVER_OPTS[0]="-l /var/lib/nbd/pulk-pull/swap.nbd-allow"
NBD_PORT[1]=37417
NBD_FILE[1]=/var/lib/nbd/oomingmak/swap
NBD_SERVER_OPTS[1]="-l /var/lib/nbd/oomingmak/swap.nbd-allow"
[comments omitted]
The following occurs when I run "dpkg-reconfigure nbd-server", or
reinstall nbd-server:
/var/lib/dpkg/info/nbd-server.postinst: line 52: [: -l: binary operator expected
/var/lib/dpkg/info/nbd-server.postinst: line 52: [: -l: binary operator expected
/etc/nbd-server: line 3: /var/lib/nbd/pulk-pull/swap.nbd-allow: Permission
denied
/etc/nbd-server: line 6: /var/lib/nbd/oomingmak/swap.nbd-allow: Permission
denied
Starting Network Block Device server: /var/lib/nbd/pulk-pull/swap
/var/lib/nbd/oomingmak/swap nbd-server.
/etc/nbd-server then becomes:
NBD_PORT[0]=21544
NBD_FILE[0]=/var/lib/nbd/pulk-pull/swap
NBD_SERVER_OPTS[0]=-l /var/lib/nbd/pulk-pull/swap.nbd-allow
NBD_PORT[1]=37417
NBD_FILE[1]=/var/lib/nbd/oomingmak/swap
NBD_SERVER_OPTS[1]=-l /var/lib/nbd/oomingmak/swap.nbd-allow
[comments omitted]
Note that the NBD_SERVER_OPTS* lines lose proper quoting. The
"Permission denied" errors on startup happen because bash is trying to
execute the "swap.nbd-allow" files as a result of the improper
serialization.
This modification to /var/lib/dpkg/info/nbd-server.postinst properly
serializes these values, and also corrects the error reported on line
52:
---8<---8<---
--- nbd-server.postinst.orig 2006-12-31 06:20:08.000000000 -0800
+++ /var/lib/dpkg/info/nbd-server.postinst 2007-01-15 02:07:52.000000000
-0800
@@ -9,6 +9,21 @@
[ -e /etc/nbd-server ] && . /etc/nbd-server
+# Quotes each argument for shell expression inclusion, to prevent
+# interpretation of special characters.
+function shell_quote () {
+ local first=true
+ while [ "$#" -gt 0 ]; do
+ if [ ! "$first" ]; then
+ echo -n ' '
+ fi
+ # sed expression transforms instances of ' to '\''
+ echo -n "'$(echo "$1" | sed -e "s/'/'\\\\''/g")'"
+ first=
+ shift
+ done
+}
+
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
@@ -49,12 +64,12 @@
umask 066
( echo "NBD_PORT[$(( $i + 0 ))]="$PORT
echo "NBD_FILE[$(( $i + 0 ))]="$FN
- if [ -z ${NBD_SERVER_OPTS[$(( $i + 0))]} ]
+ if [ -z "${NBD_SERVER_OPTS[$(( $i + 0))]}" ]
then
echo "#NBD_SERVER_OPTS[$(( $i + 0))] is unset, but
can contain -r, -m, -c or -a."
echo "#See nbd-server(1) for their meanings"
else
- echo "NBD_SERVER_OPTS[$(( $i +
0))]="${NBD_SERVER_OPTS[$(( $i + 0))]}
+ echo "NBD_SERVER_OPTS[$(( $i + 0))]=$(shell_quote
"${NBD_SERVER_OPTS[$(( $i + 0))]}")"
fi
) >> $TMPFILE
done
--->8--->8---
Two subsequent iterations of "dpkg-reconfigure nbd-server" preserve
the semantic meaning of the NBD_SERVER_OPTS* lines (though harmlessly
changing my original double-quoted strings to single-quoted strings),
and report no errors.
I've also commented out NBD_SERVER_OPTS[0] and reconfigured nbd-server
to ensure my patch works correctly when such a value is not set.
On what perhaps should be filed in a separate bug report: Why aren't
the NBD_SERVER_OPTS* lines configurable with debconf?
-- System Information:
Debian Release: 4.0
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16.29-xen
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages nbd-server depends on:
ii debconf [debconf-2.0] 1.5.11 Debian configuration management sy
ii libc6 2.3.6.ds1-8 GNU C Library: Shared libraries
ii libglib2.0-0 2.12.4-2 The GLib library of C routines
nbd-server recommends no packages.
-- debconf information:
* nbd-server/filename: /var/lib/nbd/pulk-pull/swap
* nbd-server/port: 21544
* nbd-server/filename1: /var/lib/nbd/oomingmak/swap
* nbd-server/port1: 37417
nbd-server/autogen:
* nbd-server/number: 2
--
J.P. Larocque: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]