1 |
commit: c5af7adf780ce42670b0beda24c2dbfd4d39f34d |
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 19:05:45 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=c5af7adf |
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. In fact, I think this |
19 |
code has been unnecessary since commit e5a53e42 ("catalyst: create |
20 |
namespaces for building"). |
21 |
|
22 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
23 |
|
24 |
catalyst/base/stagebase.py | 37 ------------------------------------- |
25 |
1 file changed, 37 deletions(-) |
26 |
|
27 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
28 |
index bd5ba8d0..b9c220d0 100644 |
29 |
--- a/catalyst/base/stagebase.py |
30 |
+++ b/catalyst/base/stagebase.py |
31 |
@@ -638,39 +638,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
32 |
assert self.settings[verify] == "blake2" |
33 |
self.settings.setdefault("gk_mainargs", []).append("--b2sum") |
34 |
|
35 |
- def mount_safety_check(self): |
36 |
- """ |
37 |
- Check and verify that none of our paths in mypath are mounted. We don't |
38 |
- want to clean up with things still mounted, and this allows us to check. |
39 |
- Returns 1 on ok, 0 on "something is still mounted" case. |
40 |
- """ |
41 |
- |
42 |
- if not os.path.exists(self.settings["chroot_path"]): |
43 |
- return |
44 |
- |
45 |
- log.debug('self.mount = %s', self.mount) |
46 |
- for x in [x for x in self.mount if self.mount[x]['enable']]: |
47 |
- target = normpath(self.settings['chroot_path'] + |
48 |
- self.mount[x]['target']) |
49 |
- log.debug('mount_safety_check() x = %s %s', x, target) |
50 |
- if not os.path.exists(target): |
51 |
- continue |
52 |
- |
53 |
- if ismount(target): |
54 |
- # Something is still mounted |
55 |
- try: |
56 |
- log.warning( |
57 |
- '%s is still mounted; performing auto-bind-umount...', target) |
58 |
- # Try to umount stuff ourselves |
59 |
- self.unbind() |
60 |
- if ismount(target): |
61 |
- raise CatalystError("Auto-unbind failed for " + target) |
62 |
- log.notice('Auto-unbind successful...') |
63 |
- except CatalystError: |
64 |
- raise CatalystError("Unable to auto-unbind " + target) |
65 |
- |
66 |
def unpack(self): |
67 |
- |
68 |
clst_unpack_hash = self.resume.get("unpack") |
69 |
|
70 |
# Set up all unpack info settings |
71 |
@@ -755,8 +723,6 @@ class StageBase(TargetBase, ClearBase, GenBase): |
72 |
% self.settings["source_path"]) |
73 |
|
74 |
if _unpack: |
75 |
- self.mount_safety_check() |
76 |
- |
77 |
if invalid_chroot: |
78 |
if "autoresume" in self.settings["options"]: |
79 |
log.notice( |
80 |
@@ -1363,9 +1329,6 @@ class StageBase(TargetBase, ClearBase, GenBase): |
81 |
def run(self): |
82 |
self.chroot_lock.write_lock() |
83 |
|
84 |
- # Check for mounts right away and abort if we cannot unmount them |
85 |
- self.mount_safety_check() |
86 |
- |
87 |
if "clear-autoresume" in self.settings["options"]: |
88 |
self.clear_autoresume() |