]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab-generator: set mode=0755 with root=tmpfs
authorLuca Boccassi <luca.boccassi@gmail.com>
Mon, 16 Jun 2025 22:28:57 +0000 (23:28 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 17 Jun 2025 07:13:45 +0000 (16:13 +0900)
If mode= is not set in rootflags= add mode=0755 when a tmpfs
is used on the rootfs, otherwise it will be group/world writable
as that's the default mode for tmpfs filesystems.

Follow-up for 725ad3b06288b2beeaaf178120010612a30646e4

src/fstab-generator/fstab-generator.c
test/test-fstab-generator/test-16-tmpfs.expected/sysroot.mount

index 8c9352c349258ff06982350154fe9bd6afc4afaa..3a3af31a49494b969c3d2f9984ffaa51fc4cb303 100644 (file)
@@ -1197,6 +1197,8 @@ static int add_sysroot_mount(void) {
                         return log_oom();
 
                 fstype = arg_root_fstype ?: "tmpfs"; /* tmpfs, unless overridden */
+                if (streq(fstype, "tmpfs") && !fstab_test_option(arg_root_options, "mode\0"))
+                        extra_opts = "mode=0755"; /* root directory should not be world/group writable, unless overridden */
         } else {
 
                 what = fstab_node_to_udev_node(arg_root_what);
index 99728fd0ca3c6150a3f051548fafafe1eac69358..4d8b0fee3ad587982bb5069f657862a4bf1942a8 100644 (file)
@@ -10,4 +10,4 @@ After=imports.target
 What=rootfs
 Where=/sysroot
 Type=tmpfs
-Options=rw
+Options=rw,mode=0755