X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fload-fragment.c;h=0571d517b0113572ba4167eecd1a0d4b5e04020f;hp=6839da8817b5b78d6d2a2a34d3f2de2ec565286b;hb=3ecaa09bccd8a59c9f1e06756a1334a162206dc4;hpb=543295ad369793bdac510c6c3bf4afae8f1cdab5 diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 6839da881..0571d517b 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -46,7 +46,7 @@ #include "missing.h" #include "unit-name.h" #include "unit-printf.h" -#include "bus-errors.h" +#include "dbus-common.h" #include "utf8.h" #include "path-util.h" #include "syscall-list.h" @@ -91,7 +91,7 @@ int config_parse_unit_deps(const char* unit, assert(rvalue); FOREACH_WORD_QUOTED(w, l, rvalue, state) { - char _cleanup_free_ *t = NULL, *k = NULL; + _cleanup_free_ char *t = NULL, *k = NULL; int r; t = strndup(w, l); @@ -785,7 +785,7 @@ int config_parse_exec_cpu_affinity(const char *unit, } FOREACH_WORD_QUOTED(w, l, rvalue, state) { - char _cleanup_free_ *t = NULL; + _cleanup_free_ char *t = NULL; int r; unsigned cpu; @@ -927,7 +927,7 @@ int config_parse_bounding_set(const char *unit, * interface. */ FOREACH_WORD_QUOTED(w, l, rvalue, state) { - char _cleanup_free_ *t = NULL; + _cleanup_free_ char *t = NULL; int r; cap_value_t cap; @@ -1019,7 +1019,7 @@ int config_parse_unit_cgroup(const char *unit, } FOREACH_WORD_QUOTED(w, l, rvalue, state) { - char _cleanup_free_ *t = NULL, *k = NULL, *ku = NULL; + _cleanup_free_ char *t = NULL, *k = NULL, *ku = NULL; int r; t = strndup(w, l); @@ -1161,7 +1161,7 @@ int config_parse_exec_mount_flags(const char *unit, assert(data); FOREACH_WORD_SEPARATOR(w, l, rvalue, ", ", state) { - char _cleanup_free_ *t; + _cleanup_free_ char *t; t = strndup(w, l); if (!t) @@ -1254,50 +1254,57 @@ int config_parse_timer(const char *unit, return 0; } -int config_parse_timer_unit(const char *unit, - const char *filename, - unsigned line, - const char *section, - const char *lvalue, - int ltype, - const char *rvalue, - void *data, - void *userdata) { +int config_parse_trigger_unit( + const char *unit, + const char *filename, + unsigned line, + const char *section, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { - Timer *t = data; - int r; - DBusError error; - Unit *u; _cleanup_free_ char *p = NULL; + Unit *u = data; + UnitType type; + int r; assert(filename); assert(lvalue); assert(rvalue); assert(data); - dbus_error_init(&error); + if (!set_isempty(u->dependencies[UNIT_TRIGGERS])) { + log_syntax(unit, LOG_ERR, filename, line, EINVAL, + "Multiple units to trigger specified, ignoring: %s", rvalue); + return 0; + } - p = unit_name_printf(UNIT(t), rvalue); + p = unit_name_printf(u, rvalue); if (!p) return log_oom(); - if (endswith(p, ".timer")) { + type = unit_name_to_type(p); + if (type < 0) { log_syntax(unit, LOG_ERR, filename, line, EINVAL, - "Unit cannot be of type timer, ignoring: %s", rvalue); + "Unit type not valid, ignoring: %s", rvalue); return 0; } - r = manager_load_unit(UNIT(t)->manager, p, NULL, NULL, &u); + if (type == u->type) { + log_syntax(unit, LOG_ERR, filename, line, EINVAL, + "Trigger cannot be of same type, ignoring: %s", rvalue); + return 0; + } + + r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_TRIGGERS, p, NULL, true); if (r < 0) { log_syntax(unit, LOG_ERR, filename, line, -r, - "Failed to load unit %s, ignoring: %s", - rvalue, bus_error(&error, r)); - dbus_error_free(&error); + "Failed to add trigger on %s, ignoring: %s", p, strerror(-r)); return 0; } - unit_ref_set(&t->unit, u); - return 0; } @@ -1314,7 +1321,7 @@ int config_parse_path_spec(const char *unit, Path *p = data; PathSpec *s; PathType b; - char _cleanup_free_ *k = NULL; + _cleanup_free_ char *k = NULL; assert(filename); assert(lvalue); @@ -1365,53 +1372,6 @@ int config_parse_path_spec(const char *unit, return 0; } -int config_parse_path_unit(const char *unit, - const char *filename, - unsigned line, - const char *section, - const char *lvalue, - int ltype, - const char *rvalue, - void *data, - void *userdata) { - - Path *t = data; - int r; - DBusError error; - Unit *u; - _cleanup_free_ char *p = NULL; - - assert(filename); - assert(lvalue); - assert(rvalue); - assert(data); - - dbus_error_init(&error); - - p = unit_name_printf(UNIT(t), rvalue); - if (!p) - return log_oom(); - - if (endswith(p, ".path")) { - log_syntax(unit, LOG_ERR, filename, line, EINVAL, - "Unit cannot be of type path, ignoring: %s", p); - return 0; - } - - r = manager_load_unit(UNIT(t)->manager, p, NULL, &error, &u); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, EINVAL, - "Failed to load unit %s, ignoring: %s", - p, bus_error(&error, r)); - dbus_error_free(&error); - return 0; - } - - unit_ref_set(&t->unit, u); - - return 0; -} - int config_parse_socket_service(const char *unit, const char *filename, unsigned line, @@ -1480,7 +1440,7 @@ int config_parse_service_sockets(const char *unit, assert(data); FOREACH_WORD_QUOTED(w, l, rvalue, state) { - char _cleanup_free_ *t = NULL, *k = NULL; + _cleanup_free_ char *t = NULL, *k = NULL; t = strndup(w, l); if (!t) @@ -2074,7 +2034,7 @@ int config_parse_syscall_filter(const char *unit, FOREACH_WORD_QUOTED(w, l, rvalue, state) { int id; - char _cleanup_free_ *t = NULL; + _cleanup_free_ char *t = NULL; t = strndup(w, l); if (!t) @@ -2480,10 +2440,9 @@ void unit_dump_config_items(FILE *f) { { config_parse_unit_requires_mounts_for, "PATH [...]" }, { config_parse_exec_mount_flags, "MOUNTFLAG [...]" }, { config_parse_unit_string_printf, "STRING" }, + { config_parse_trigger_unit, "UNIT" }, { config_parse_timer, "TIMER" }, - { config_parse_timer_unit, "NAME" }, { config_parse_path_spec, "PATH" }, - { config_parse_path_unit, "UNIT" }, { config_parse_notify_access, "ACCESS" }, { config_parse_ip_tos, "TOS" }, { config_parse_unit_condition_path, "CONDITION" },