]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Imply DefaultDependencies=no for credential mounts
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 14 May 2024 08:25:33 +0000 (10:25 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 14 May 2024 10:42:45 +0000 (12:42 +0200)
Currently, on soft-reboot, /run/credentials/@system is unmounted
because it has DefaultDependencies=yes and as such will have
Conflicts=umount.target and Before=umount.target. Let's make sure
credential mounts survive soft-reboot by implying DefaultDependencies=no
for credential mounts.

src/core/mount.c
test/TEST-82-SOFTREBOOT/test.sh
test/units/testsuite-82.sh

index 3bf7e89e38f3bc7ce408c9a534a8381be9dcc2ab..e43a93ac21e2433f124bedc7710f642348f19ee7 100644 (file)
@@ -463,10 +463,7 @@ static int mount_add_default_ordering_dependencies(Mount *m, MountParameters *p,
                 after = SPECIAL_LOCAL_FS_PRE_TARGET;
                 before = SPECIAL_INITRD_USR_FS_TARGET;
 
-        } else if (mount_is_credentials(m))
-                after = before = NULL;
-
-        else if (mount_is_network(p)) {
+        } else if (mount_is_network(p)) {
                 after = SPECIAL_REMOTE_FS_PRE_TARGET;
                 before = SPECIAL_REMOTE_FS_TARGET;
 
@@ -653,6 +650,9 @@ static int mount_add_extras(Mount *m) {
                         return r;
         }
 
+        if (mount_is_credentials(m))
+                u->default_dependencies = false;
+
         r = unit_patch_contexts(u);
         if (r < 0)
                 return r;
index 3c0676b39b24f73684f3171cd3d7890e70aeca48..2109cc84a0e5bc02472ee380b96383c851d1abcc 100755 (executable)
@@ -10,6 +10,7 @@ TEST_SKIP_SHUTDOWN=yes
 IMAGE_NAME="softreboot"
 TEST_NO_NSPAWN=1
 TEST_INSTALL_VERITY_MINIMAL=1
+KERNEL_APPEND="${KERNEL_APPEND:-} systemd.set_credential=kernelcmdlinecred:uff"
 
 # shellcheck source=test/test-functions
 . "$TEST_BASE_DIR/test-functions"
index ea96f05b38a8f4d918340f19a4c7d3d83b9ee20c..9747602d192cc2b541c38fe0b6cbb9a6ae94802f 100755 (executable)
@@ -113,6 +113,9 @@ elif [ -f /run/testsuite82.touch ]; then
     cat /run/testsuite82.signal
     test "$(jq -r '.payload.data[1].type.data' </run/testsuite82.signal)" = "soft-reboot"
 
+    # Check that the system credentials survived the soft reboot.
+    test "$(systemd-creds cat --system kernelcmdlinecred)" = "uff"
+
     # Upload another entry
     T="/dev/shm/fdstore.$RANDOM"
     echo "miaumiau" >"$T"