]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use --close with flock and drop --no-fork
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 12 Mar 2024 08:38:29 +0000 (09:38 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 12 Mar 2024 13:06:08 +0000 (14:06 +0100)
Let's make sure only flock holds the lock and it's not inherited by
the child process it spawns. This fixes an SELinux denial on some
systems.

mkosi/user.py

index aef9c68270c520a2ea568ffe851c782e9ba8ba2e..f456fbb8615abfbca774a4d724ee59117b6a524d 100644 (file)
@@ -135,14 +135,14 @@ def become_root() -> None:
         # generated files are owned by that user. We don't map to the last user in the range as the last user
         # is sometimes used in tests as a default value and mapping to that user might break those tests.
         newuidmap = [
-            "flock", "--exclusive", "--no-fork", lock, "newuidmap", pid,
+            "flock", "--exclusive", "--close", lock, "newuidmap", pid,
             0, subuid, SUBRANGE - 100,
             SUBRANGE - 100, os.getuid(), 1,
             SUBRANGE - 100 + 1, subuid + SUBRANGE - 100 + 1, 99
         ]
 
         newgidmap = [
-            "flock", "--exclusive", "--no-fork", lock, "newgidmap", pid,
+            "flock", "--exclusive", "--close", lock, "newgidmap", pid,
             0, subgid, SUBRANGE - 100,
             SUBRANGE - 100, os.getgid(), 1,
             SUBRANGE - 100 + 1, subgid + SUBRANGE - 100 + 1, 99