From 844646baca27e96313b05a32a781d2eb09a817c4 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 20 Dec 2021 04:21:09 +0100 Subject: [PATCH] Chroot.mount(): don't purely rely on ismount(), also check self.active_mounts as we should. --- chroot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chroot.py b/chroot.py index 6001394..07f9b74 100644 --- a/chroot.py +++ b/chroot.py @@ -278,7 +278,8 @@ class Chroot: """returns the absolute path `relative_target` was mounted at""" relative_destination = relative_destination.lstrip('/') absolute_destination = self.get_path(relative_destination) - if os.path.ismount(absolute_destination): + pseudo_absolute = make_abs_path(relative_destination) + if os.path.ismount(absolute_destination) or pseudo_absolute in self.active_mounts: if fail_if_mounted: raise Exception(f'{self.name}: {absolute_destination} is already mounted') logging.debug(f'{self.name}: {absolute_destination} already mounted. Skipping.') @@ -289,7 +290,7 @@ class Chroot: if result.returncode != 0: raise Exception(f'{self.name}: failed to mount {absolute_source} to {absolute_destination}') logging.debug(f'{self.name}: {absolute_source} successfully mounted to {absolute_destination}.') - self.active_mounts += [make_abs_path(relative_destination)] + self.active_mounts += [pseudo_absolute] atexit.register(self.deactivate) return absolute_destination