X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fload-fragment.c;h=6b6f9908b58ddd8294a68fa796ec024eb228d302;hp=fda27becb50c29c874ea859e31e6d42f8411782a;hb=b1389b0d0805392570085acc7cb10eafcf885405;hpb=1e2fd62d70ff1a960551d28fce745847a9dbd3b7 diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index fda27becb..6b6f9908b 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -288,7 +288,8 @@ int config_parse_socket_listen(const char *unit, void *data, void *userdata) { - SocketPort *p, *tail; + _cleanup_free_ SocketPort *p = NULL; + SocketPort *tail; Socket *s; int r; @@ -315,10 +316,9 @@ int config_parse_socket_listen(const char *unit, r = unit_full_printf(UNIT(s), rvalue, &p->path); if (r < 0) { p->path = strdup(rvalue); - if (!p->path) { - free(p); + if (!p->path) return log_oom(); - } else + else log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r)); } @@ -334,11 +334,10 @@ int config_parse_socket_listen(const char *unit, log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r)); - r = socket_address_parse_netlink(&p->address, k ? k : rvalue); + r = socket_address_parse_netlink(&p->address, k ?: rvalue); if (r < 0) { log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to parse address value, ignoring: %s", rvalue); - free(p); return 0; } @@ -355,7 +354,6 @@ int config_parse_socket_listen(const char *unit, if (r < 0) { log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to parse address value, ignoring: %s", rvalue); - free(p); return 0; } @@ -371,7 +369,6 @@ int config_parse_socket_listen(const char *unit, if (socket_address_family(&p->address) != AF_LOCAL && p->address.type == SOCK_SEQPACKET) { log_syntax(unit, LOG_ERR, filename, line, ENOTSUP, "Address family not supported, ignoring: %s", rvalue); - free(p); return 0; } } @@ -384,6 +381,7 @@ int config_parse_socket_listen(const char *unit, LIST_INSERT_AFTER(port, s->ports, tail, p); } else LIST_PREPEND(port, s->ports, p); + p = NULL; return 0; } @@ -1367,8 +1365,11 @@ int config_parse_timer(const char *unit, } v = new0(TimerValue, 1); - if (!v) + if (!v) { + if (c) + calendar_spec_free(c); return log_oom(); + } v->base = b; v->value = u; @@ -1686,7 +1687,7 @@ int config_parse_busname_service( return 0; } -DEFINE_CONFIG_PARSE_ENUM(config_parse_bus_policy_world, busname_policy_access, BusNamePolicyAccess, "Failed to parse bus name policy access"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bus_policy_world, bus_policy_access, BusPolicyAccess, "Failed to parse bus name policy access"); int config_parse_bus_policy( const char *unit, @@ -1736,7 +1737,7 @@ int config_parse_bus_policy( access_str++; access_str += strspn(access_str, WHITESPACE); - p->access = busname_policy_access_from_string(access_str); + p->access = bus_policy_access_from_string(access_str); if (p->access < 0) { log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Invalid busname policy access type '%s'", access_str); @@ -1752,6 +1753,62 @@ int config_parse_bus_policy( return 0; } +int config_parse_bus_endpoint_policy( + const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + _cleanup_free_ char *name = NULL; + BusPolicyAccess access; + ExecContext *c = data; + char *access_str; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + name = strdup(rvalue); + if (!name) + return log_oom(); + + access_str = strpbrk(name, WHITESPACE); + if (!access_str) { + log_syntax(unit, LOG_ERR, filename, line, EINVAL, + "Invalid endpoint policy value '%s'", rvalue); + return 0; + } + + *access_str = '\0'; + access_str++; + access_str += strspn(access_str, WHITESPACE); + + access = bus_policy_access_from_string(access_str); + if (access <= _BUS_POLICY_ACCESS_INVALID || + access >= _BUS_POLICY_ACCESS_MAX) { + log_syntax(unit, LOG_ERR, filename, line, EINVAL, + "Invalid endpoint policy access type '%s'", access_str); + return 0; + } + + if (!c->bus_endpoint) { + r = bus_endpoint_new(&c->bus_endpoint); + + if (r < 0) + return r; + } + + return bus_endpoint_add_policy(c->bus_endpoint, name, access); +} + int config_parse_unit_env_file(const char *unit, const char *filename, unsigned line, @@ -2217,7 +2274,7 @@ int config_parse_syscall_filter( } if (!c->syscall_filter) { - c->syscall_filter = set_new(trivial_hash_func, trivial_compare_func); + c->syscall_filter = set_new(NULL); if (!c->syscall_filter) return log_oom(); @@ -2309,7 +2366,7 @@ int config_parse_syscall_archs( return 0; } - r = set_ensure_allocated(archs, trivial_hash_func, trivial_compare_func); + r = set_ensure_allocated(archs, NULL); if (r < 0) return log_oom(); @@ -2415,7 +2472,7 @@ int config_parse_address_families( } if (!c->address_families) { - c->address_families = set_new(trivial_hash_func, trivial_compare_func); + c->address_families = set_new(NULL); if (!c->address_families) return log_oom(); @@ -3033,7 +3090,7 @@ int config_parse_set_status( } } - r = set_ensure_allocated(&status_set->status, NULL, NULL); + r = set_ensure_allocated(&status_set->status, NULL); if (r < 0) return log_oom(); @@ -3364,7 +3421,7 @@ static int load_from_path(Unit *u, const char *path) { assert(u); assert(path); - symlink_names = set_new(string_hash_func, string_compare_func); + symlink_names = set_new(&string_hash_ops); if (!symlink_names) return -ENOMEM;