Skip to content

Commit 3c0a1b1

Browse files
committed
core: Imply DefaultDependencies=no for credential mounts
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.
1 parent 381c3b6 commit 3c0a1b1

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/core/mount.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,7 @@ static int mount_add_default_ordering_dependencies(Mount *m, MountParameters *p,
463463
after = SPECIAL_LOCAL_FS_PRE_TARGET;
464464
before = SPECIAL_INITRD_USR_FS_TARGET;
465465

466-
} else if (mount_is_credentials(m))
467-
after = before = NULL;
468-
469-
else if (mount_is_network(p)) {
466+
} else if (mount_is_network(p)) {
470467
after = SPECIAL_REMOTE_FS_PRE_TARGET;
471468
before = SPECIAL_REMOTE_FS_TARGET;
472469

@@ -653,6 +650,9 @@ static int mount_add_extras(Mount *m) {
653650
return r;
654651
}
655652

653+
if (mount_is_credentials(m))
654+
u->default_dependencies = false;
655+
656656
r = unit_patch_contexts(u);
657657
if (r < 0)
658658
return r;

test/TEST-82-SOFTREBOOT/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ TEST_SKIP_SHUTDOWN=yes
1010
IMAGE_NAME="softreboot"
1111
TEST_NO_NSPAWN=1
1212
TEST_INSTALL_VERITY_MINIMAL=1
13+
KERNEL_APPEND="${KERNEL_APPEND:-} systemd.set_credential=kernelcmdlinecred:uff"
1314

1415
# shellcheck source=test/test-functions
1516
. "$TEST_BASE_DIR/test-functions"

test/units/testsuite-82.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ elif [ -f /run/testsuite82.touch ]; then
113113
cat /run/testsuite82.signal
114114
test "$(jq -r '.payload.data[1].type.data' </run/testsuite82.signal)" = "soft-reboot"
115115

116+
# Check that the system credentials survived the soft reboot.
117+
test "$(systemd-creds cat --system kernelcmdlinecred)" = "uff"
118+
116119
# Upload another entry
117120
T="/dev/shm/fdstore.$RANDOM"
118121
echo "miaumiau" >"$T"

0 commit comments

Comments
 (0)