load-fragment.c revision 19f6d710772305610b928bc2678b9d77fe11e770
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen This file is part of systemd.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen Copyright 2010 Lennart Poettering
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen Copyright 2012 Holger Hans Peter Freyther
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen systemd is free software; you can redistribute it and/or modify it
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen under the terms of the GNU Lesser General Public License as published by
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen the Free Software Foundation; either version 2.1 of the License, or
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen (at your option) any later version.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen systemd is distributed in the hope that it will be useful, but
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen WITHOUT ANY WARRANTY; without even the implied warranty of
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen Lesser General Public License for more details.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen You should have received a copy of the GNU Lesser General Public License
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_warn_compat(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_DEBUG, filename, line, EINVAL,
8fba1c8d4e3d05d2af2848b6570bdc09e725d06eZbigniew Jędrzejewski-Szmek "Support for option %s= has been disabled at compile time and is ignored",
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_unit_deps(const char* unit,
8fba1c8d4e3d05d2af2848b6570bdc09e725d06eZbigniew Jędrzejewski-Szmek FOREACH_WORD_QUOTED(w, l, rvalue, state) {
8fba1c8d4e3d05d2af2848b6570bdc09e725d06eZbigniew Jędrzejewski-Szmek _cleanup_free_ char *t = NULL, *k = NULL;
8fba1c8d4e3d05d2af2848b6570bdc09e725d06eZbigniew Jędrzejewski-Szmek r = unit_name_printf(u, t, &k);
8fba1c8d4e3d05d2af2848b6570bdc09e725d06eZbigniew Jędrzejewski-Szmek log_syntax(unit, LOG_ERR, filename, line, -r,
8fba1c8d4e3d05d2af2848b6570bdc09e725d06eZbigniew Jędrzejewski-Szmek "Failed to resolve specifiers, ignoring: %s", strerror(-r));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen r = unit_add_dependency_by_name(u, d, k, NULL, true);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -r,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to add dependency on %s, ignoring: %s", k, strerror(-r));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_unit_string_printf(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen _cleanup_free_ char *k = NULL;
b7e7184634d573fb73143210962acce205f37f61Michael Biebl "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
b7e7184634d573fb73143210962acce205f37f61Michael Biebl return config_parse_string(unit, filename, line, section, lvalue, ltype,
b7e7184634d573fb73143210962acce205f37f61Michael Bieblint config_parse_unit_strv_printf(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen _cleanup_free_ char *k = NULL;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen r = unit_full_printf(u, rvalue, &k);
260ad50f5b4a9795032e3119c64f838a2d03370dThomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -r,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
8fba1c8d4e3d05d2af2848b6570bdc09e725d06eZbigniew Jędrzejewski-Szmek return config_parse_strv(unit, filename, line, section, lvalue, ltype,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen k ? k : rvalue, data, userdata);
77354c7e6f096a447245a8781c1eaa4acbe67089Martin Pittint config_parse_unit_path_printf(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen _cleanup_free_ char *k = NULL;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen r = unit_full_printf(u, rvalue, &k);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -r,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
260ad50f5b4a9795032e3119c64f838a2d03370dThomas Hindoe Paaboel Andersen return config_parse_path(unit, filename, line, section, lvalue, ltype,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen k ? k : rvalue, data, userdata);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_socket_listen(const char *unit,
260ad50f5b4a9795032e3119c64f838a2d03370dThomas Hindoe Paaboel Andersen /* An empty assignment removes all ports */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (ltype != SOCKET_SOCKET) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen r = unit_full_printf(UNIT(s), rvalue, &p->path);
0b2ec8a3bfdd6118b3b4958d236ee203ad420f28David Herrmann log_syntax(unit, LOG_ERR, filename, line, -r,
0b2ec8a3bfdd6118b3b4958d236ee203ad420f28David Herrmann "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen } else if (streq(lvalue, "ListenNetlink")) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen r = unit_full_printf(UNIT(s), rvalue, &k);
0b2ec8a3bfdd6118b3b4958d236ee203ad420f28David Herrmann log_syntax(unit, LOG_ERR, filename, line, -r,
0b2ec8a3bfdd6118b3b4958d236ee203ad420f28David Herrmann "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen r = socket_address_parse_netlink(&p->address, k ? k : rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -r,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to parse address value, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen _cleanup_free_ char *k = NULL;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen r = unit_full_printf(UNIT(s), rvalue, &k);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -r,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen r = socket_address_parse(&p->address, k ? k : rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -r,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to parse address value, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (streq(lvalue, "ListenStream"))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen p->address.type = SOCK_STREAM;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen else if (streq(lvalue, "ListenDatagram"))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen p->address.type = SOCK_DGRAM;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen assert(streq(lvalue, "ListenSequentialPacket"));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen p->address.type = SOCK_SEQPACKET;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (socket_address_family(&p->address) != AF_LOCAL && p->address.type == SOCK_SEQPACKET) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, ENOTSUP,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Address family not supported, ignoring: %s", rvalue);
29e0e6d8c1f7f648b7c998880d034eaa3e58c53aMartin Pitt LIST_FIND_TAIL(SocketPort, port, s->ports, tail);
4e4885553447f6f4c014bfa3e5b5837a76a0e612Lennart Poettering LIST_INSERT_AFTER(SocketPort, port, s->ports, tail, p);
3315f085178f46155fda345d9526c09083b45946Lennart Poettering LIST_PREPEND(SocketPort, port, s->ports, p);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_socket_bind(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen b = socket_address_bind_ipv6_only_from_string(rvalue);
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek log_syntax(unit, LOG_ERR, filename, line, EINVAL,
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek "Failed to parse bind IPv6 only value, ignoring: %s", rvalue);
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek s->bind_ipv6_only = r ? SOCKET_ADDRESS_IPV6_ONLY : SOCKET_ADDRESS_BOTH;
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmekint config_parse_exec_nice(const char *unit,
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek r = safe_atoi(rvalue, &priority);
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek log_syntax(unit, LOG_ERR, filename, line, -r,
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek "Failed to parse nice priority, ignoring: %s. ", rvalue);
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek if (priority < PRIO_MIN || priority >= PRIO_MAX) {
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek log_syntax(unit, LOG_ERR, filename, line, ERANGE,
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek "Nice priority out of range, ignoring: %s", rvalue);
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmekint config_parse_exec_oom_score_adjust(const char* unit,
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek log_syntax(unit, LOG_ERR, filename, line, -r,
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek "Failed to parse the OOM score adjust value, ignoring: %s", rvalue);
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek if (oa < OOM_SCORE_ADJ_MIN || oa > OOM_SCORE_ADJ_MAX) {
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek log_syntax(unit, LOG_ERR, filename, line, ERANGE,
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmek "OOM score adjust value out of range, ignoring: %s", rvalue);
e987f2a809c6bab7e7bae4ca8f598ea5bafd5225Zbigniew Jędrzejewski-Szmek c->oom_score_adjust_set = true;
1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12eZbigniew Jędrzejewski-Szmekint config_parse_exec(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen ExecCommand **e = data, *nce;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* An empty assignment resets the list */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* We accept an absolute path as first argument, or
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen * alternatively an absolute prefixed with @ to allow
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen * overriding of argv[0]. */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen bool honour_argv0 = false, ignore = false;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen rvalue += strspn(rvalue, WHITESPACE);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen for (i = 0; i < 2; i++) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (rvalue[0] == '-' && !ignore) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (rvalue[0] == '@' && !honour_argv0) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, EINVAL,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Executable path is not absolute, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen FOREACH_WORD_QUOTED(w, l, rvalue, state) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (strneq(w, ";", MAX(l, 1U)))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen n = new(char*, k + !honour_argv0);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen FOREACH_WORD_QUOTED(w, l, rvalue, state) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (strneq(w, ";", MAX(l, 1U)))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen else if (strneq(w, "\\;", MAX(l, 1U)))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (honour_argv0 && w == rvalue) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, EINVAL,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Path is not UTF-8 clean, ignoring assignment: %s",
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c = n[k++] = cunescape_length(w, l);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, EINVAL,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Path is not UTF-8 clean, ignoring assignment: %s",
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, EINVAL,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Invalid command line, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen assert(path_is_absolute(path));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen path_kill_slashes(nce->path);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen exec_command_append_list(e, nce);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel AndersenDEFINE_CONFIG_PARSE_ENUM(config_parse_service_type, service_type, ServiceType, "Failed to parse service type");
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel AndersenDEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart, service_restart, ServiceRestart, "Failed to parse service restart specifier");
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_socket_bindtodevice(const char* unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (rvalue[0] && !streq(rvalue, "*")) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel AndersenDEFINE_CONFIG_PARSE_ENUM(config_parse_output, exec_output, ExecOutput, "Failed to parse output specifier");
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel AndersenDEFINE_CONFIG_PARSE_ENUM(config_parse_input, exec_input, ExecInput, "Failed to parse input specifier");
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_exec_io_class(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen x = ioprio_class_from_string(rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, EINVAL,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to parse IO scheduling class, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->ioprio = IOPRIO_PRIO_VALUE(x, IOPRIO_PRIO_DATA(c->ioprio));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_exec_io_priority(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (r < 0 || i < 0 || i >= IOPRIO_BE_NR) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -r,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to parse IO priority, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c->ioprio), i);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_exec_cpu_sched_policy(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen x = sched_policy_from_string(rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -x,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to parse CPU scheduling policy, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* Moving to or from real-time policy? We need to adjust the priority */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->cpu_sched_priority = CLAMP(c->cpu_sched_priority, sched_get_priority_min(x), sched_get_priority_max(x));
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_exec_cpu_sched_prio(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, -r,
805e5dda0a01c99d231824e1a9c4a208418bf342Lennart Poettering "Failed to parse CPU scheduling policy, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* On Linux RR/FIFO range from 1 to 99 and OTHER/BATCH may only be 0 */
805e5dda0a01c99d231824e1a9c4a208418bf342Lennart Poettering min = sched_get_priority_min(c->cpu_sched_policy);
805e5dda0a01c99d231824e1a9c4a208418bf342Lennart Poettering max = sched_get_priority_max(c->cpu_sched_policy);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, ERANGE,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "CPU scheduling priority is out of range, ignoring: %s", rvalue);
f4f01ec146d91cb6943828851d98eee6a1ad4dd9Martin Pittint config_parse_exec_cpu_affinity(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* An empty assignment resets the CPU list */
7a03974a6f4510dcb1850515a80c2063c767a80fThomas Hindoe Paaboel Andersen FOREACH_WORD_QUOTED(w, l, rvalue, state) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen _cleanup_free_ char *t = NULL;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->cpuset = cpu_set_malloc(&c->cpuset_ncpus);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (r < 0 || cpu >= c->cpuset_ncpus) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, ERANGE,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to parse CPU affinity '%s', ignoring: %s", t, rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen CPU_SET_S(cpu, CPU_ALLOC_SIZE(c->cpuset_ncpus), c->cpuset);
7a03974a6f4510dcb1850515a80c2063c767a80fThomas Hindoe Paaboel Andersenint config_parse_exec_capabilities(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, errno,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to parse capabilities, ignoring: %s", rvalue);
8c84621c25c563c7428f3d355136fc542389aab8Thomas Hindoe Paaboel Andersenint config_parse_exec_secure_bits(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* An empty assignment resets the field */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen FOREACH_WORD_QUOTED(w, l, rvalue, state) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen if (first_word(w, "keep-caps"))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->secure_bits |= 1<<SECURE_KEEP_CAPS;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen else if (first_word(w, "keep-caps-locked"))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->secure_bits |= 1<<SECURE_KEEP_CAPS_LOCKED;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen else if (first_word(w, "no-setuid-fixup"))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->secure_bits |= 1<<SECURE_NO_SETUID_FIXUP;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen else if (first_word(w, "no-setuid-fixup-locked"))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->secure_bits |= 1<<SECURE_NO_SETUID_FIXUP_LOCKED;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen else if (first_word(w, "noroot"))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->secure_bits |= 1<<SECURE_NOROOT;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen else if (first_word(w, "noroot-locked"))
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen c->secure_bits |= 1<<SECURE_NOROOT_LOCKED;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen log_syntax(unit, LOG_ERR, filename, line, EINVAL,
260ad50f5b4a9795032e3119c64f838a2d03370dThomas Hindoe Paaboel Andersen "Failed to parse secure bits, ignoring: %s", rvalue);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_bounding_set(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen uint64_t *capability_bounding_set_drop = data;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* Note that we store this inverted internally, since the
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen * kernel wants it like this. But we actually expose it
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen * non-inverted everywhere to have a fully normalized
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen FOREACH_WORD_QUOTED(w, l, rvalue, state) {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen _cleanup_free_ char *t = NULL;
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt log_syntax(unit, LOG_ERR, filename, line, errno,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen "Failed to parse capability in bounding set, ignoring: %s", t);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen sum |= ((uint64_t) 1ULL) << (uint64_t) cap;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen *capability_bounding_set_drop |= sum;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen *capability_bounding_set_drop |= ~sum;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint config_parse_limit(const char *unit,
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen unsigned long long u;
u = (unsigned long long) RLIM_INFINITY;
if (!*rl) {
if (!*rl)
return log_oom();
#ifdef HAVE_SYSV_COMPAT
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
*priority = (int) i;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
*passno = (int) i;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
*sig = r;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
size_t l;
char *state;
unsigned long flags = 0;
_cleanup_free_ char *t;
t = strndup(w, l);
return log_oom();
t, rvalue);
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
usec_t u = 0;
TimerValue *v;
TimerBase b;
if (b == TIMER_CALENDAR) {
rvalue);
rvalue);
return log_oom();
v->base = b;
v->value = u;
v->calendar_spec = c;
const char *unit,
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
if (type < 0) {
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
PathSpec *s;
PathType b;
path_free_specs(p);
return log_oom();
rvalue);
if (!path_is_absolute(k)) {
return log_oom();
k = NULL;
s->type = b;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Unit *x;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
char *state, *w;
size_t l;
t = strndup(w, l);
return log_oom();
k ?: t, strerror(-r));
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
assert(s);
s->start_timeout_defined = true;
s->start_timeout_defined = true;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
s = n ?: rvalue;
return log_oom();
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
size_t l;
return log_oom();
_cleanup_free_ char *n;
n = cunescape_length(w, l);
return log_oom();
if (!env_assignment_is_valid(n)) {
return log_oom();
*env = x;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
*ip_tos = x;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Condition *c;
if (trigger)
rvalue++;
if (negate)
rvalue++;
return log_oom();
if (!path_is_absolute(p)) {
return log_oom();
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Condition *c;
if (trigger)
rvalue++;
if (negate)
rvalue++;
return log_oom();
return log_oom();
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Condition *c;
if (trigger)
rvalue++;
if (negate)
rvalue++;
rvalue);
return log_oom();
DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access, notify_access, NotifyAccess, "Failed to parse notify access specifier");
DEFINE_CONFIG_PARSE_ENUM(config_parse_start_limit_action, start_limit_action, StartLimitAction, "Failed to parse start limit action specifier");
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
bool empty_before;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
assert(u);
for (a = b = u->documentation; a && *a; a++) {
if (is_valid_documentation_url(*a))
free(*a);
*b = NULL;
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
bool invert = false;
size_t l;
char *state;
assert(u);
invert = true;
rvalue++;
if (!c->syscall_filter) {
size_t n;
if (!c->syscall_filter)
return log_oom();
#ifdef __NR_sigreturn
int id;
t = strndup(w, l);
return log_oom();
if (id < 0) {
if (invert)
c->no_new_privileges = true;
const char *unit,
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
assert(u);
return log_oom();
DEFINE_CONFIG_PARSE_ENUM(config_parse_device_policy, cgroup_device_policy, CGroupDevicePolicy, "Failed to parse device policy");
const char *unit,
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
unsigned long lu;
if (r < 0 || lu <= 0) {
const char *unit,
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
const char *unit,
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
size_t n;
while (c->device_allow)
if (!path)
return log_oom();
if (isempty(m))
return log_oom();
const char *unit,
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
unsigned long lu;
const char *unit,
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
unsigned long lu;
const char *weight;
size_t n;
while (c->blockio_device_weights)
if (!*weight) {
if (!path)
return log_oom();
return log_oom();
const char *unit,
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
const char *bandwidth;
bool read;
size_t n;
if (!*bandwidth) {
if (!path)
return log_oom();
if (r < 0 || bytes <= 0) {
return log_oom();
int fd, r;
FILE *f;
if (c++ >= FOLLOW_MAX)
return -ELOOP;
if (!id) {
if (!id)
return -ENOMEM;
if (fd >= 0)
return -errno;
r = -errno;
*_f = f;
assert(u);
assert(*u);
r = unit_merge_by_name(*u, k);
free(k);
if (other) {
*u = other;
if (id == k)
free(k);
assert(u);
if (!symlink_names)
return -ENOMEM;
if (!filename) {
r = -ENOMEM;
goto finish;
if (r != -ENOENT)
goto finish;
if (!filename) {
r = -ENOMEM;
goto finish;
r = -ENOENT;
if (r != -ENOENT)
goto finish;
if (!filename) {
goto finish;
merged = u;
goto finish;
if (merged != u) {
goto finish;
r = -errno;
goto finish;
(void*) load_fragment_gperf_lookup, false, true, u);
goto finish;
if (u->source_path) {
u->source_mtime = 0;
fclose(f);
Iterator i;
assert(u);
if (t == u->id)
r = load_from_path(u, t);
return -ENOMEM;
r = load_from_path(u, k);
free(k);
if (t == u->id)
k = unit_name_template(t);
return -ENOMEM;
r = load_from_path(u, k);
free(k);
const char *rvalue;
} table[] = {
#ifdef HAVE_SYSV_COMPAT
assert(f);
const char *dot;
const ConfigPerfItem *p;
if (dot)
if (prev)
prev = i;