From 98ea424f3976635a856371b1e8986208fc1f8a78 Mon Sep 17 00:00:00 2001 From: Chen Date: Tue, 23 Oct 2018 10:42:08 +0800 Subject: [PATCH] lvm-backup: Normalize path when comparing current path and mount point Before umounting and removing lvm volume, we need to make sure we are not within the mount point that is to be removed. Previous logic lacks consideration that path can have parts like trailing slashes, which could end up skipping changing dir when it is needed. This patch proposes to normalize the path before doing the check to avoid such mistakes. Closes-Bug: #1799334 Story: 2004153 Task: 27625 Change-Id: Iaa8c8ff523b1d29a1addeaa3d802053d63aba80a --- freezer/snapshot/lvm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freezer/snapshot/lvm.py b/freezer/snapshot/lvm.py index e0575173..6f457f50 100644 --- a/freezer/snapshot/lvm.py +++ b/freezer/snapshot/lvm.py @@ -303,7 +303,8 @@ def validate_lvm_params(backup_opt_dict): def _umount(path): - if os.getcwd().startswith(path): + # Change dir if we are within the mount point to be removed. + if os.getcwd().startswith(os.path.normpath(path)): os.chdir('/') umount_proc = subprocess.Popen('{0} -l -f {1}'.format( utils.find_executable('umount'), path),