]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
portable: Make sure mountpoints exist in the image
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 16 Dec 2025 15:43:37 +0000 (16:43 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 16 Dec 2025 18:17:22 +0000 (19:17 +0100)
Fixes #4012

mkosi/__init__.py

index b11eedb779154ec339d7423370dbe3381940136f..98771a9ad1f8dc40fc1315b97a08402288531d1c 100644 (file)
@@ -530,6 +530,17 @@ def configure_verity_certificate(context: Context) -> None:
         shutil.copy(context.config.verity_certificate, dest)
 
 
+def configure_mountpoints(context: Context) -> None:
+    if context.config.output_format != OutputFormat.portable:
+        return
+
+    for f in ("passwd", "group", "shadow", "gshadow", "nsswitch.conf", "resolv.conf", "machine-id"):
+        with umask(~0o600 if f in ("shadow", "gshadow") else ~0o644):
+            p = context.root / "etc" / f
+            if not p.is_symlink():
+                (context.root / "etc" / f).touch(exist_ok=True)
+
+
 @contextlib.contextmanager
 def setup_build_overlay(context: Context, volatile: bool = False) -> Iterator[None]:
     d = context.workspace / "build-overlay"
@@ -4005,6 +4016,7 @@ def build_image(context: Context) -> None:
         configure_ssh(context)
         configure_clock(context)
         configure_verity_certificate(context)
+        configure_mountpoints(context)
 
         if manifest:
             manifest.record_extension_release()