Bug#560125: freebsd-utils: Insufficient quoting in init.d script
Package: freebsd-utils
Version: 8.0-1
Severity: important
Tags: patch
Hi,
while debugging some stuff, I stumbled upon this:
| /etc/init.d/freebsd-utils: line 88: [: !=: unary operator expected
Indeed, the $(readlink …) part isn't quoted so if it returns nothing,
the test operates on “ != "/proc/mounts"” with a missing argument. That
may happen during debootstrapping.
Please find attached a trivial patch against glibc-bsd's trunk to fix
that.
[ As a side note: One may wonder, but even though the script is “set
-e”, later instructions are executed anyway (I was interested in such
operations). ]
As another (more interesting) side-note, that can break (I guess)
depending on the partitioning(?):
| + ln -f /proc/mounts /etc/mtab
| ln: creating hard link `/etc/mtab' => `/proc/mounts': Invalid cross-device link
I guess another bugreport about that is in order.
Mraw,
KiBi.
>From add2852d086fdfd78d55d5fecefcc99755d9b94f Mon Sep 17 00:00:00 2001
From: Cyril Brulebois <kibi@debian.org>
Date: Wed, 9 Dec 2009 06:09:49 +0100
Subject: [PATCH] Fix quoting in init script.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
$(readlink …) may return an empty string, resulting in a missing
parameter.
---
freebsd-utils/debian/freebsd-utils.init | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/freebsd-utils/debian/freebsd-utils.init b/freebsd-utils/debian/freebsd-utils.init
index 4924bb0..07ab0cf 100644
--- a/freebsd-utils/debian/freebsd-utils.init
+++ b/freebsd-utils/debian/freebsd-utils.init
@@ -85,7 +85,7 @@ case "$1" in
echo "done."
- if [ $(readlink /etc/mtab) != "/proc/mounts" ] ; then
+ if [ "$(readlink /etc/mtab)" != "/proc/mounts" ] ; then
echo "Warning: replacing /etc/mtab by a symlink to /proc/mounts."
rm -f /etc/mtab
ln -f /proc/mounts /etc/mtab
--
1.6.5.4
Reply to: