From 72a19f689e43318589a7c2614848778a59629b76 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 9 Oct 2007 00:24:11 +0200 Subject: [PATCH] Merging casper 1.108. --- docs/ChangeLog.casper | 10 ++++++++++ hooks/live | 6 ++++++ manpages/live-initramfs.en.7.txt | 5 +++++ scripts/live | 25 +++++++++++++++++++++++-- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/docs/ChangeLog.casper b/docs/ChangeLog.casper index b1f55c9..bfd3c50 100644 --- a/docs/ChangeLog.casper +++ b/docs/ChangeLog.casper @@ -1,3 +1,13 @@ +casper (1.108) gutsy; urgency=low + + * If CASPER_GENERATE_UUID is set, generate a random UUID in the initramfs, + and check it against the discovered medium (unless booting with the + ignore_uuid parameter). This allows live CD images to be safely copied + to the hard disk without causing problems when booting future live CDs + (LP: #144800). + + -- Colin Watson Thu, 04 Oct 2007 14:23:37 +0100 + casper (1.107) gutsy; urgency=low * Fix gconf keys for suspend and hibernate (thanks, Oliver Grawert; diff --git a/hooks/live b/hooks/live index a59fe3b..e692690 100755 --- a/hooks/live +++ b/hooks/live @@ -120,3 +120,9 @@ if [ -x /usr/bin/wget ] then copy_exec /usr/bin/wget /bin fi + +if [ "$CASPER_GENERATE_UUID" ]; then + # Unique ID + mkdir -p $DESTDIR/conf + uuidgen -r > $DESTDIR/conf/uuid.conf +fi diff --git a/manpages/live-initramfs.en.7.txt b/manpages/live-initramfs.en.7.txt index c197abb..238c810 100644 --- a/manpages/live-initramfs.en.7.txt +++ b/manpages/live-initramfs.en.7.txt @@ -60,6 +60,11 @@ copying to ram and booting it. Those parameters lets you override values read from the config file. + ignore_uuid + +Do not check that any UUID embedded in the initramfs matches the discovered medium. +casper may be told to generate a UUID by setting CASPER_GENERATE_UUID=1 when building the initramfs. + integrity-check:: If specified, an MD5 sum is calculated on the live media during boot and diff --git a/scripts/live b/scripts/live index ebac3ae..16a54c2 100755 --- a/scripts/live +++ b/scripts/live @@ -79,6 +79,9 @@ Arguments () export USERFULLNAME LIVECONF ;; + ignore_uuid) + IGNORE_UUID="Yes" ;; + ip=*) STATICIP="${ARGUMENT#ip=}" @@ -434,6 +437,22 @@ is_live_path () return 1 } +matches_uuid() { + if [ "$IGNORE_UUID" ] || [ ! -e /conf/uuid.conf ]; then + return 0 + fi + path="$1" + uuid="$(cat /conf/uuid.conf)" + for try_uuid_file in "$mountpoint/.disk/casper-uuid"*; do + [ -e "$try_uuid_file" ] || continue + try_uuid="$(cat "$try_uuid_file")" + if [ "$uuid" = "$try_uuid" ]; then + return 0 + fi + done + return 1 +} + get_backing_device () { case "${1}" in @@ -983,6 +1002,7 @@ check_dev () { sysdev="${1}" devname="${2}" + skip_uuid_check="${3}" if [ -z "${devname}" ] then @@ -1002,7 +1022,8 @@ check_dev () mount -t ${fstype} -o ro,noatime,nodiratime "${devname}" ${mountpoint} || continue if is_live_path ${mountpoint} - then + if is_live_path $mountpoint && \ + ([ "$skip_uuid_check" ] || matches_uuid $mountpoint); then echo ${mountpoint} return 0 else @@ -1025,7 +1046,7 @@ find_livefs () # first look at the one specified in the command line if [ ! -z "${LIVE_MEDIA}" ] then - if check_dev "null" "${LIVE_MEDIA}" + if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check" then return 0 fi -- 2.1.4