]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Avoid TOCTOU issue in start_journal_remote()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 23 Apr 2024 08:19:38 +0000 (10:19 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 23 Apr 2024 08:22:01 +0000 (10:22 +0200)
mkosi/qemu.py

index f663917b8540e2eca98628df98da5e0736877536..516f21bc0ea3e29eea0c58a98bba4446717afe0c 100644 (file)
@@ -426,7 +426,9 @@ def start_journal_remote(config: Config, sockfd: int) -> Iterator[None]:
 
     d = config.forward_journal.parent if config.forward_journal.suffix == ".journal" else config.forward_journal
     if not d.exists():
-        d.mkdir(parents=True)
+        # Pass exist_ok=True because multiple mkosi processes might be trying to create the parent directory at the
+        # same time.
+        d.mkdir(exist_ok=True, parents=True)
         # Make sure COW is disabled so systemd-journal-remote doesn't complain on btrfs filesystems.
         run(["chattr", "+C", d], check=False, stderr=subprocess.DEVNULL if not ARG_DEBUG.get() else None)
         INVOKING_USER.chown(d)