X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Funit.c;h=0ad679ba622f6154f742a9cacee2a794c1872a24;hp=81d21622d08f50cc146250757d408fc0e2fada94;hb=58ea275a68cd242ad60161bcb7582614d1d89f13;hpb=6a371e23ee0e47827fb4e3aa469ed84da2599304 diff --git a/src/core/unit.c b/src/core/unit.c index 81d21622d..0ad679ba6 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -119,7 +119,7 @@ int unit_add_name(Unit *u, const char *text) { if (!s) return -ENOMEM; - if (!unit_name_is_valid(s, false)) { + if (!unit_name_is_valid(s, TEMPLATE_INVALID)) { r = -EINVAL; goto fail; } @@ -671,6 +671,18 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) { assert(u); assert(c); + if (c->working_directory) { + r = unit_require_mounts_for(u, c->working_directory); + if (r < 0) + return r; + } + + if (c->root_directory) { + r = unit_require_mounts_for(u, c->root_directory); + if (r < 0) + return r; + } + if (c->std_output != EXEC_OUTPUT_KMSG && c->std_output != EXEC_OUTPUT_SYSLOG && c->std_output != EXEC_OUTPUT_JOURNAL && @@ -1125,6 +1137,8 @@ _pure_ static const char *unit_get_status_message_format_try_harder(Unit *u, Job return NULL; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" static void unit_status_print_starting_stopping(Unit *u, JobType t) { const char *format; @@ -1139,6 +1153,7 @@ static void unit_status_print_starting_stopping(Unit *u, JobType t) { unit_status_printf(u, "", format); } +#pragma GCC diagnostic pop #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" @@ -1848,7 +1863,7 @@ static const char *resolve_template(Unit *u, const char *name, const char*path, assert(p); if (!name) - name = path_get_file_name(path); + name = basename(path); if (!unit_name_is_template(name)) { *p = NULL; @@ -2615,7 +2630,7 @@ UnitFileState unit_get_unit_file_state(Unit *u) { if (u->unit_file_state < 0 && u->fragment_path) u->unit_file_state = unit_file_get_state( u->manager->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, - NULL, path_get_file_name(u->fragment_path)); + NULL, basename(u->fragment_path)); return u->unit_file_state; } @@ -2951,7 +2966,7 @@ int unit_kill_context( } } - if (c->kill_mode == KILL_CONTROL_GROUP && u->cgroup_path) { + if ((c->kill_mode == KILL_CONTROL_GROUP || (c->kill_mode == KILL_MIXED && sigkill)) && u->cgroup_path) { _cleanup_set_free_ Set *pid_set = NULL; /* Exclude the main/control pids from being killed via the cgroup */ @@ -2965,6 +2980,7 @@ int unit_kill_context( log_warning_unit(u->id, "Failed to kill control group: %s", strerror(-r)); } else if (r > 0) { wait_for_exit = true; + if (c->send_sighup) { set_free(pid_set); @@ -2994,17 +3010,15 @@ int unit_require_mounts_for(Unit *u, const char *path) { * units can easily determine which units to make themselves a * dependency of. */ + if (!path_is_absolute(path)) + return -EINVAL; + p = strdup(path); if (!p) return -ENOMEM; path_kill_slashes(p); - if (!path_is_absolute(p)) { - free(p); - return -EINVAL; - } - if (!path_is_safe(p)) { free(p); return -EPERM;