]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Do not allow dd to create the output file 307/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 14 Dec 2018 12:54:07 +0000 (13:54 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 30 Apr 2019 15:34:57 +0000 (17:34 +0200)
Something went wrong on my machine and /dev/loop8p2 was not present,
even though loop8 and loop8p1 were. (I think the loopback device was
mounted somewhere and the kernel wouldn't reread the partition table.)
Since we are running as root, we can easily create a new file in /dev.
Let's avoid this.

mkosi

diff --git a/mkosi b/mkosi
index fdb900b019c0cf226cb433f8d31706c9482f6434..bb1d152f2e95e9d2c3df6a3f3b309b039fff5503 100755 (executable)
--- a/mkosi
+++ b/mkosi
@@ -2490,8 +2490,9 @@ def insert_partition(args: CommandLineArguments,
     else:
         dev = None
 
+    path = dev if dev is not None else partition(loopdev, partno)
     try:
-        run(["dd", "if=" + blob.name, "of=" + (dev if dev is not None else partition(loopdev, partno))], check=True)
+        run(['dd', f'if={blob.name}', f'of={path}', 'conv=nocreat'], check=True)
     finally:
         luks_close(dev, "Closing LUKS root partition")