]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/mount: don't keep cred mounts around after mounted
authorMike Yuan <me@yhndnzj.com>
Thu, 12 Dec 2024 21:03:25 +0000 (22:03 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 13 Dec 2024 10:29:27 +0000 (10:29 +0000)
Follow-up for 6577cf1ba96027053cedce97ebb22d4ea96887bd

src/core/mount.c

index c3a2f7ab7e64fe57ed0d85438f9327cf5eeaece8..4b47092c1d9c547b0046993be35512f364240da2 100644 (file)
@@ -935,6 +935,14 @@ static void mount_enter_mounted(Mount *m, MountResult f) {
         if (m->result == MOUNT_SUCCESS)
                 m->result = f;
 
+        /* Refer to service_set_state() handling of SERVICE_EXITED state for rationale. In particular
+         * for mount units let's not leave cred mounts around, otherwise the actual number of mounts would be
+         * somewhat doubled.
+         *
+         * Note that this effectively means fresh creds are used during remount, but that's mostly what
+         * users would expect anyways. */
+        unit_destroy_runtime_data(UNIT(m), &m->exec_context, /* destroy_runtime_dir = */ false);
+
         mount_set_state(m, MOUNT_MOUNTED);
 }