X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fload-fragment.c;h=c48d764a31c4a51c9e766941ca69655f81af3e2e;hp=05d858e86a74e9a57f51b58f5b80f02437e3f754;hb=49f91047afb48b8ee5728c68ba75782463176fd4;hpb=7d76f312889d54dcfe6fdde6eb055e890e7a615b diff --git a/src/load-fragment.c b/src/load-fragment.c index 05d858e86..c48d764a3 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include "unit.h" #include "strv.h" @@ -196,7 +198,7 @@ static int config_parse_listen( void *data, void *userdata) { - SocketPort *p; + SocketPort *p, *tail; Socket *s; assert(filename); @@ -218,6 +220,15 @@ static int config_parse_listen( } path_kill_slashes(p->path); + } else if (streq(lvalue, "ListenNetlink")) { + p->type = SOCKET_SOCKET; + + if (socket_address_parse_netlink(&p->address, rvalue) < 0) { + log_error("[%s:%u] Failed to parse address value, ignoring: %s", filename, line, rvalue); + free(p); + return 0; + } + } else { p->type = SOCKET_SOCKET; @@ -244,7 +255,12 @@ static int config_parse_listen( } p->fd = -1; - LIST_PREPEND(SocketPort, port, s->ports, p); + + if (s->ports) { + LIST_FIND_TAIL(SocketPort, port, s->ports, tail); + LIST_INSERT_AFTER(SocketPort, port, s->ports, tail, p); + } else + LIST_PREPEND(SocketPort, port, s->ports, p); return 0; } @@ -965,7 +981,9 @@ static int config_parse_limit( assert(rvalue); assert(data); - if (safe_atollu(rvalue, &u) < 0) { + if (streq(rvalue, "infinity")) + u = (unsigned long long) RLIM_INFINITY; + else if (safe_atollu(rvalue, &u) < 0) { log_error("[%s:%u] Failed to parse resource value, ignoring: %s", filename, line, rvalue); return 0; } @@ -1479,7 +1497,7 @@ static int config_parse_condition_path( return 0; } -static int config_parse_condition_kernel( +static int config_parse_condition_string( const char *filename, unsigned line, const char *section, @@ -1489,6 +1507,7 @@ static int config_parse_condition_kernel( void *data, void *userdata) { + ConditionType cond = ltype; Unit *u = data; bool trigger, negate; Condition *c; @@ -1504,39 +1523,7 @@ static int config_parse_condition_kernel( if ((negate = rvalue[0] == '!')) rvalue++; - if (!(c = condition_new(CONDITION_KERNEL_COMMAND_LINE, rvalue, trigger, negate))) - return -ENOMEM; - - LIST_PREPEND(Condition, conditions, u->meta.conditions, c); - return 0; -} - -static int config_parse_condition_virt( - const char *filename, - unsigned line, - const char *section, - const char *lvalue, - int ltype, - const char *rvalue, - void *data, - void *userdata) { - - Unit *u = data; - bool trigger, negate; - Condition *c; - - assert(filename); - assert(lvalue); - assert(rvalue); - assert(data); - - if ((trigger = rvalue[0] == '|')) - rvalue++; - - if ((negate = rvalue[0] == '!')) - rvalue++; - - if (!(c = condition_new(CONDITION_VIRTUALIZATION, rvalue, trigger, negate))) + if (!(c = condition_new(cond, rvalue, trigger, negate))) return -ENOMEM; LIST_PREPEND(Condition, conditions, u->meta.conditions, c); @@ -1756,9 +1743,8 @@ static void dump_items(FILE *f, const ConfigItem *items) { { config_parse_notify_access, "ACCESS" }, { config_parse_ip_tos, "TOS" }, { config_parse_condition_path, "CONDITION" }, - { config_parse_condition_kernel, "CONDITION" }, + { config_parse_condition_string, "CONDITION" }, { config_parse_condition_null, "CONDITION" }, - { config_parse_condition_virt, "CONDITION" }, }; assert(f); @@ -1879,12 +1865,15 @@ static int load_from_path(Unit *u, const char *path) { { "RefuseManualStop", config_parse_bool, 0, &u->meta.refuse_manual_stop, "Unit" }, { "AllowIsolate", config_parse_bool, 0, &u->meta.allow_isolate, "Unit" }, { "DefaultDependencies", config_parse_bool, 0, &u->meta.default_dependencies, "Unit" }, + { "OnFailureIsolate", config_parse_bool, 0, &u->meta.on_failure_isolate, "Unit" }, + { "IgnoreOnIsolate", config_parse_bool, 0, &u->meta.ignore_on_isolate, "Unit" }, { "JobTimeoutSec", config_parse_usec, 0, &u->meta.job_timeout, "Unit" }, { "ConditionPathExists", config_parse_condition_path, CONDITION_PATH_EXISTS, u, "Unit" }, { "ConditionPathIsDirectory", config_parse_condition_path, CONDITION_PATH_IS_DIRECTORY, u, "Unit" }, { "ConditionDirectoryNotEmpty", config_parse_condition_path, CONDITION_DIRECTORY_NOT_EMPTY, u, "Unit" }, - { "ConditionKernelCommandLine", config_parse_condition_kernel, 0, u, "Unit" }, - { "ConditionVirtualization",config_parse_condition_virt, 0, u, "Unit" }, + { "ConditionKernelCommandLine", config_parse_condition_string, CONDITION_KERNEL_COMMAND_LINE, u, "Unit" }, + { "ConditionVirtualization", config_parse_condition_string, CONDITION_VIRTUALIZATION, u, "Unit" }, + { "ConditionSecurity", config_parse_condition_string, CONDITION_SECURITY, u, "Unit" }, { "ConditionNull", config_parse_condition_null, 0, u, "Unit" }, { "PIDFile", config_parse_path, 0, &u->service.pid_file, "Service" }, @@ -1918,6 +1907,7 @@ static int load_from_path(Unit *u, const char *path) { { "ListenDatagram", config_parse_listen, 0, &u->socket, "Socket" }, { "ListenSequentialPacket", config_parse_listen, 0, &u->socket, "Socket" }, { "ListenFIFO", config_parse_listen, 0, &u->socket, "Socket" }, + { "ListenNetlink", config_parse_listen, 0, &u->socket, "Socket" }, { "BindIPv6Only", config_parse_socket_bind, 0, &u->socket, "Socket" }, { "Backlog", config_parse_unsigned, 0, &u->socket.backlog, "Socket" }, { "BindToDevice", config_parse_bindtodevice, 0, &u->socket, "Socket" }, @@ -1970,6 +1960,8 @@ static int load_from_path(Unit *u, const char *path) { { "PathChanged", config_parse_path_spec, 0, &u->path, "Path" }, { "DirectoryNotEmpty", config_parse_path_spec, 0, &u->path, "Path" }, { "Unit", config_parse_path_unit, 0, &u->path, "Path" }, + { "MakeDirectory", config_parse_bool, 0, &u->path.make_directory, "Path" }, + { "DirectoryMode", config_parse_mode, 0, &u->path.directory_mode, "Path" }, /* The [Install] section is ignored here. */ { "Alias", NULL, 0, NULL, "Install" },