diff options
author | Michal Sekletar <msekleta@redhat.com> | 2013-03-14 18:12:27 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-15 22:56:40 -0400 |
commit | c17ec25e4d9bd6c8e8617416f813e25b2ebbafc5 (patch) | |
tree | 6a414a30460e6a362180a059bc93e88cea946916 /src/core/service.c | |
parent | 3b953d68c628c6ae70adba871719ac0f16083b51 (diff) |
core: reuse the same /tmp, /var/tmp and inaccessible dir
All Execs within the service, will get mounted the same
/tmp and /var/tmp directories, if service is configured with
PrivateTmp=yes. Temporary directories are cleaned up by service
itself in addition to systemd-tmpfiles. Directory which is mounted
as inaccessible is created at runtime in /run/systemd.
Diffstat (limited to 'src/core/service.c')
-rw-r--r-- | src/core/service.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/core/service.c b/src/core/service.c index fd90ceba05..080d583b69 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -283,7 +283,7 @@ static void service_done(Unit *u) { free(s->status_text); s->status_text = NULL; - exec_context_done(&s->exec_context); + exec_context_done(&s->exec_context, manager_is_reloading_or_reexecuting(u->manager)); exec_command_free_array(s->exec_command, _SERVICE_EXEC_COMMAND_MAX); s->control_command = NULL; s->main_command = NULL; @@ -1932,6 +1932,9 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart) s->forbid_restart = false; + /* we want fresh tmpdirs in case service is started again immediately */ + exec_context_tmp_dirs_done(&s->exec_context); + return; fail: @@ -2638,6 +2641,12 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) { dual_timestamp_serialize(f, "watchdog-timestamp", &s->watchdog_timestamp); + if (s->exec_context.tmp_dir) + unit_serialize_item(u, f, "tmp-dir", s->exec_context.tmp_dir); + + if (s->exec_context.var_tmp_dir) + unit_serialize_item(u, f, "var-tmp-dir", s->exec_context.var_tmp_dir); + return 0; } @@ -2756,7 +2765,23 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, dual_timestamp_deserialize(value, &s->main_exec_status.exit_timestamp); else if (streq(key, "watchdog-timestamp")) dual_timestamp_deserialize(value, &s->watchdog_timestamp); - else + else if (streq(key, "tmp-dir")) { + char *t; + + t = strdup(value); + if (!t) + return log_oom(); + + s->exec_context.tmp_dir = t; + } else if (streq(key, "var-tmp-dir")) { + char *t; + + t = strdup(value); + if (!t) + return log_oom(); + + s->exec_context.var_tmp_dir = t; + } else log_debug_unit(u->id, "Unknown serialization key '%s'", key); return 0; |