Michael Prokop: initamfs/hook: make sure configuration file exists before accessing it.
Martin F. Krafft
madduck at alioth.debian.org
Fri Sep 3 09:54:50 UTC 2010
Module: mdadm
Branch: build
Commit: 0c11ed84d14081f75469493e33315fd02f6750dc
URL: http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=0c11ed84d14081f75469493e33315fd02f6750dc
Author: Michael Prokop <mika at grml.org>
Date: Sat Aug 7 11:12:58 2010 -0400
initamfs/hook: make sure configuration file exists before accessing it.
Debian bug: #589836
Signed-off-by: Michael Prokop <mika at grml.org>
Signed-off-by: martin f. krafft <madduck at debian.org>
---
debian/changelog | 2 ++
debian/initramfs/hook | 8 ++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index f571868..5c8cef5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ mdadm (3.1.4-1) unstable; urgency=low
or linear array (closes: #539154).
- prevent --remove faulty from skipping renumbered devices
(closes: #587550).
+ * initramfs/hook: make sure configuration file exists before accessing it;
+ thanks to Michael Prokop for the fix and NMU (closes: #589836).
* initramfs/hook: Match UUID case-insensitive while checking for running
arrays not listed in mdadm.conf; thanks to Mario 'BitKoenig' Holbe for the
patch (closes: #583545).
diff --git a/debian/initramfs/hook b/debian/initramfs/hook
index 368b3ae..b7eab11 100644
--- a/debian/initramfs/hook
+++ b/debian/initramfs/hook
@@ -90,7 +90,9 @@ INITRDSTART=all
DESTMDADMCONF=$DESTDIR/etc/mdadm/mdadm.conf
DESTCONFIG=$DESTDIR/conf/conf.d/md
-homehost="$(sed -ne 's,^[[:space:]]*HOMEHOST[[:space:]]*,,p' $CONFIG)"
+if [ -f $CONFIG ]; then
+ homehost="$(sed -ne 's,^[[:space:]]*HOMEHOST[[:space:]]*,,p' $CONFIG)"
+fi
if [ -z "${homehost:-}" ] || [ "${homehost:-}" = '<system>' ]; then
echo "MD_HOMEHOST='$(hostname)'" > $DESTCONFIG
fi
@@ -100,7 +102,9 @@ install_config()
# install the configuration file
mkdir -p ${2%/*}
# only copy ARRAY/DEVICE/HOMEHOST lines, and merge continuation lines into one
- sed -e :a -re '$!N;s/\n[[:space:]]+/ /;ta' -ne '/^(ARRAY|DEVICE|HOMEHOST)/P;D' $1 > $2
+ if [ -f "$1" ] ; then
+ sed -e :a -re '$!N;s/\n[[:space:]]+/ /;ta' -ne '/^(ARRAY|DEVICE|HOMEHOST)/P;D' $1 > $2
+ fi
}
if [ ! -f $CONFIG ]; then
More information about the pkg-mdadm-commits
mailing list