summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2020-09-09 04:31:20 +0300
committerDaniil Baturin <daniil@vyos.io>2020-09-09 04:32:35 +0300
commiteeefbce59d69bd386de675e978e2e8c0ce11d400 (patch)
tree35239459dc58fa0f074f092863b62ad65a33137c
parent9f27802e9f634532d2924f3c0739c50938c79a5d (diff)
downloadvyatta-op-eeefbce59d69bd386de675e978e2e8c0ce11d400.tar.gz
vyatta-op-eeefbce59d69bd386de675e978e2e8c0ce11d400.zip
T2303: correctly delete images with quotes in GRUB entries.
-rwxr-xr-xscripts/vyatta-boot-image.pl12
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;