core/service: preserve RuntimeDirectory= even if oneshot service exits
Follow-up for c26948c6da
We only want to get rid of cred mount here, and RuntimeDirectory=
is documented to be retained for SERVICE_EXITED state.
Fixes #35427
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
d5df77b474
commit
703b1b7f24
+1
-1
@@ -910,7 +910,7 @@ static void mount_enter_dead(Mount *m, MountResult f, bool flush_result) {
|
||||
|
||||
m->exec_runtime = exec_runtime_destroy(m->exec_runtime);
|
||||
|
||||
unit_destroy_runtime_data(UNIT(m), &m->exec_context);
|
||||
unit_destroy_runtime_data(UNIT(m), &m->exec_context, /* destroy_runtime_dir = */ true);
|
||||
|
||||
unit_unref_uid_gid(UNIT(m), true);
|
||||
|
||||
|
||||
+2
-2
@@ -1341,7 +1341,7 @@ static void service_set_state(Service *s, ServiceState state) {
|
||||
}
|
||||
|
||||
if (start_only)
|
||||
unit_destroy_runtime_data(u, &s->exec_context);
|
||||
unit_destroy_runtime_data(u, &s->exec_context, /* destroy_runtime_dir = */ false);
|
||||
}
|
||||
|
||||
if (old_state != state)
|
||||
@@ -2163,7 +2163,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
|
||||
s->exec_runtime = exec_runtime_destroy(s->exec_runtime);
|
||||
|
||||
/* Also, remove the runtime directory */
|
||||
unit_destroy_runtime_data(UNIT(s), &s->exec_context);
|
||||
unit_destroy_runtime_data(UNIT(s), &s->exec_context, /* destroy_runtime_dir = */ true);
|
||||
|
||||
/* Also get rid of the fd store, if that's configured. */
|
||||
if (s->fd_store_preserve_mode == EXEC_PRESERVE_NO)
|
||||
|
||||
+1
-1
@@ -2070,7 +2070,7 @@ static void socket_enter_dead(Socket *s, SocketResult f) {
|
||||
|
||||
s->exec_runtime = exec_runtime_destroy(s->exec_runtime);
|
||||
|
||||
unit_destroy_runtime_data(UNIT(s), &s->exec_context);
|
||||
unit_destroy_runtime_data(UNIT(s), &s->exec_context, /* destroy_runtime_dir = */ true);
|
||||
|
||||
unit_unref_uid_gid(UNIT(s), true);
|
||||
}
|
||||
|
||||
+1
-1
@@ -676,7 +676,7 @@ static void swap_enter_dead(Swap *s, SwapResult f) {
|
||||
|
||||
s->exec_runtime = exec_runtime_destroy(s->exec_runtime);
|
||||
|
||||
unit_destroy_runtime_data(UNIT(s), &s->exec_context);
|
||||
unit_destroy_runtime_data(UNIT(s), &s->exec_context, /* destroy_runtime_dir = */ true);
|
||||
|
||||
unit_unref_uid_gid(UNIT(s), true);
|
||||
}
|
||||
|
||||
+2
-2
@@ -6148,13 +6148,13 @@ int unit_test_trigger_loaded(Unit *u) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unit_destroy_runtime_data(Unit *u, const ExecContext *context) {
|
||||
void unit_destroy_runtime_data(Unit *u, const ExecContext *context, bool destroy_runtime_dir) {
|
||||
assert(u);
|
||||
assert(u->manager);
|
||||
assert(context);
|
||||
|
||||
/* EXEC_PRESERVE_RESTART is handled via unit_release_resources()! */
|
||||
if (context->runtime_directory_preserve_mode == EXEC_PRESERVE_NO)
|
||||
if (destroy_runtime_dir && context->runtime_directory_preserve_mode == EXEC_PRESERVE_NO)
|
||||
exec_context_destroy_runtime_directory(context, u->manager->prefix[EXEC_DIRECTORY_RUNTIME]);
|
||||
|
||||
exec_context_destroy_credentials(context, u->manager->prefix[EXEC_DIRECTORY_RUNTIME], u->id);
|
||||
|
||||
+1
-1
@@ -1036,7 +1036,7 @@ int unit_failure_action_exit_status(Unit *u);
|
||||
|
||||
int unit_test_trigger_loaded(Unit *u);
|
||||
|
||||
void unit_destroy_runtime_data(Unit *u, const ExecContext *context);
|
||||
void unit_destroy_runtime_data(Unit *u, const ExecContext *context, bool destroy_runtime_dir);
|
||||
int unit_clean(Unit *u, ExecCleanMask mask);
|
||||
int unit_can_clean(Unit *u, ExecCleanMask *ret_mask);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user