diff options
author | Daniil Baturin <daniil@vyos.io> | 2020-09-09 04:31:20 +0300 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2020-09-09 04:31:20 +0300 |
commit | 7b73a065f598ef0ddc7a27adde6e401757e6254c (patch) | |
tree | be9f48394373ca388af86a8ea04536202b5f57a5 /scripts | |
parent | 23ff9798a80f5f619398af7edd4b18827f8b6cfb (diff) | |
download | vyatta-op-7b73a065f598ef0ddc7a27adde6e401757e6254c.tar.gz vyatta-op-7b73a065f598ef0ddc7a27adde6e401757e6254c.zip |
T2303: correctly delete images with quotes in GRUB entries.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-boot-image.pl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index 568fbc0..0ecb442 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -459,6 +459,14 @@ sub doDelete { } my $boot_dir; + my $del_ver_pure = $del_ver; + $del_ver_pure =~ s/["']*//g; + + if(!$del_ver_pure) { + print "Version string is empty!\n"; + exit 1; + } + my $cver = curVer(); if (!defined($cver)) { print "Cannot verify current version. Exiting...\n"; @@ -491,7 +499,7 @@ sub doDelete { $boot_dir = $DISK_BOOT; } - if (($del_ver ne $OLD_IMG_VER_STR) && (! -d "$boot_dir/$del_ver")) { + if (($del_ver ne $OLD_IMG_VER_STR) && (! -d "$boot_dir/$del_ver_pure")) { print "Cannot find the target image. Exiting...\n"; exit 1; } @@ -502,7 +510,7 @@ sub doDelete { if ($del_ver eq $OLD_IMG_VER_STR) { del_non_image_files(); } else { - system("rm -rf '$boot_dir/$del_ver'"); + system("rm -rf '$boot_dir/$del_ver_pure'"); if ($? >> 8) { print "Error deleting the image. Exiting...\n"; exit 1; |