Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/
Date: Thu, 29 Oct 2020 15:47:43
Message-Id: 1603986376.1d692ee14f3c25eb56a1b35e11f160a1dbb724ac.mattst88@gentoo
1 commit: 1d692ee14f3c25eb56a1b35e11f160a1dbb724ac
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 29 14:39:35 2020 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 29 15:46:16 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=1d692ee1
7
8 catalyst: Remove mount_safety_check()
9
10 mount_safety_check() exists to prevent bad things from happening if a
11 previous catalyst invocation left bind mounts active in the chroot.
12 E.g., a previous catalyst invocation is interrupted without unmounting
13 the bind mounts. A new catalyst invocation runs and cleans the old
14 chroot, which inadvertently deletes files outside of the chroot via the
15 bind mounts.
16
17 With all the mounts now inside a namespace, it is no longer possible to
18 have mounts accessible outside the build sequence.
19
20 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
21
22 catalyst/base/stagebase.py | 37 -------------------------------------
23 1 file changed, 37 deletions(-)
24
25 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
26 index 605a9495..e9cf04c6 100644
27 --- a/catalyst/base/stagebase.py
28 +++ b/catalyst/base/stagebase.py
29 @@ -638,39 +638,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
30 assert self.settings[verify] == "blake2"
31 self.settings.setdefault("gk_mainargs", []).append("--b2sum")
32
33 - def mount_safety_check(self):
34 - """
35 - Check and verify that none of our paths in mypath are mounted. We don't
36 - want to clean up with things still mounted, and this allows us to check.
37 - Returns 1 on ok, 0 on "something is still mounted" case.
38 - """
39 -
40 - if not os.path.exists(self.settings["chroot_path"]):
41 - return
42 -
43 - log.debug('self.mount = %s', self.mount)
44 - for x in [x for x in self.mount if self.mount[x]['enable']]:
45 - target = normpath(self.settings['chroot_path'] +
46 - self.mount[x]['target'])
47 - log.debug('mount_safety_check() x = %s %s', x, target)
48 - if not os.path.exists(target):
49 - continue
50 -
51 - if ismount(target):
52 - # Something is still mounted
53 - try:
54 - log.warning(
55 - '%s is still mounted; performing auto-bind-umount...', target)
56 - # Try to umount stuff ourselves
57 - self.unbind()
58 - if ismount(target):
59 - raise CatalystError("Auto-unbind failed for " + target)
60 - log.notice('Auto-unbind successful...')
61 - except CatalystError:
62 - raise CatalystError("Unable to auto-unbind " + target)
63 -
64 def unpack(self):
65 -
66 clst_unpack_hash = self.resume.get("unpack")
67
68 # Set up all unpack info settings
69 @@ -755,8 +723,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
70 % self.settings["source_path"])
71
72 if _unpack:
73 - self.mount_safety_check()
74 -
75 if invalid_chroot:
76 if "autoresume" in self.settings["options"]:
77 log.notice(
78 @@ -1363,9 +1329,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
79 def run(self):
80 self.chroot_lock.write_lock()
81
82 - # Check for mounts right away and abort if we cannot unmount them
83 - self.mount_safety_check()
84 -
85 if "clear-autoresume" in self.settings["options"]:
86 self.clear_autoresume()