Strip invalid leading/trailing '/' from script params

This commit is contained in:
Francis Lam 2017-07-22 14:25:39 -04:00
parent 9d9af31e58
commit e8f3d206c5
No known key found for this signature in database
GPG Key ID: 0A59C698920806EB
8 changed files with 22 additions and 7 deletions

View File

@ -22,7 +22,7 @@ if [ -z "$bootdir" -o -z "$entry" ]; then
die "Usage: $0 -b /boot -e 'kexec params|...|...'"
fi
bootdir=${bootdir%%"/"}
bootdir="${bootdir%%/}"
kexectype=`echo $entry | cut -d\| -f2`
kexecparams=`echo $entry | cut -d\| -f3- | tr '|' '\n'`

View File

@ -15,6 +15,8 @@ if ! [ -r "$ISOSIG" ]; then
ISOSIG="$MOUNTED_ISO_PATH.asc"
fi
ISO_PATH="${ISO_PATH##/}"
gpgv "$ISOSIG" "$MOUNTED_ISO_PATH" \
|| die 'ISO signature failed'
@ -26,7 +28,7 @@ DEV_UUID=`blkid $DEV | tail -1 | tr " " "\n" | grep UUID | cut -d\" -f2`
ADD="fromiso=/dev/disk/by-uuid/$DEV_UUID/$ISO_PATH"
REMOVE=""
paramsdir="/media/kexec_iso/$ISO_PATH/"
paramsdir="/media/kexec_iso/$ISO_PATH"
check_config $paramsdir
ADD_FILE=/tmp/kexec/kexec_iso_add.txt
@ -43,7 +45,7 @@ if [ -r $REMOVE_FILE ]; then
fi
# Call kexec and indicate that hashes have been verified
kexec-select-boot -b /boot -d /media/ -p "$paramsdir" \
kexec-select-boot -b /boot -d /media -p "$paramsdir" \
-a "$ADD" -r "$REMOVE" -c "*.cfg" -u -i
die "Something failed in selecting boot"

View File

@ -17,9 +17,9 @@ reset_entry() {
}
filedir=`dirname $file`
bootdir=${bootdir%%"/"}
bootlen=${#bootdir}
appenddir=${filedir:$bootlen}
bootdir="${bootdir%%/}"
bootlen="${#bootdir}"
appenddir="${filedir:$bootlen}"
fix_path() {
path="$@"

View File

@ -24,6 +24,10 @@ if [ -z "$paramsdir" ]; then
paramsdir="$bootdir"
fi
bootdir="${bootdir%%/}"
paramsdev="${paramsdev%%/}"
paramsdir="${paramsdir%%/}"
TMP_MENU_FILE="/tmp/kexec/kexec_menu.txt"
ENTRY_FILE="$paramsdir/kexec_default.$index.txt"
HASH_FILE="$paramsdir/kexec_default_hashes.txt"

View File

@ -22,6 +22,9 @@ if [ -z "$paramsdev" ]; then
paramsdev="$paramsdir"
fi
paramsdev="${paramsdev%%/}"
paramsdir="${paramsdir%%/}"
if [ -n "$lvm_volume_group" ]; then
lvm vgchange -a y $lvm_volume_group \
|| die "Failed to activate the LVM group"

View File

@ -37,6 +37,10 @@ if [ -z "$paramsdir" ]; then
paramsdir="$bootdir"
fi
bootdir="${bootdir%%/}"
paramsdev="${paramsdev%%/}"
paramsdir="${paramsdir%%/}"
verify_global_hashes()
{
echo "+++ Checking verified boot hash file "

View File

@ -17,6 +17,8 @@ if [ -z "$paramsdir" ]; then
die "Usage: $0 -p /boot [ -u | -c counter ]"
fi
paramsdir="${paramsdir%%/}"
confirm_gpg_card
if [ "$rollback" = "y" ]; then

View File

@ -62,6 +62,6 @@ fi
echo "!!! Could not find any ISO, trying bootable USB"
# Attempt to pull verified config from device
kexec-select-boot -b /media/ -c "*.cfg" -u
kexec-select-boot -b /media -c "*.cfg" -u
die "Something failed in selecting boot"