diff options
author | Michael Prokop <mika@grml.org> | 2010-08-07 11:12:58 -0400 |
---|---|---|
committer | martin f. krafft <madduck@debian.org> | 2010-09-02 11:57:51 +0200 |
commit | 0c11ed84d14081f75469493e33315fd02f6750dc (patch) | |
tree | 959007fa31ac09ccae083558dc514d0d8f8ec3d3 | |
parent | 1c3856eea930bb8d5c38bda27b436fcc6f55bbfb (diff) |
initamfs/hook: make sure configuration file exists before accessing it.
Debian bug: #589836
Signed-off-by: Michael Prokop <mika@grml.org>
Signed-off-by: martin f. krafft <madduck@debian.org>
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | debian/initramfs/hook | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog index f5718686..5c8cef55 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 368b3ae3..b7eab113 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 |