From: Mike Yuan Date: Thu, 12 Dec 2024 21:03:25 +0000 (+0100) Subject: core/mount: don't keep cred mounts around after mounted X-Git-Tag: v258-rc1~1880 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8abeebdf83721086724e85a05738cb5b10d2d2db;p=thirdparty%2Fsystemd.git core/mount: don't keep cred mounts around after mounted Follow-up for 6577cf1ba96027053cedce97ebb22d4ea96887bd --- diff --git a/src/core/mount.c b/src/core/mount.c index c3a2f7ab7e6..4b47092c1d9 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -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); }