chiark / gitweb /
util: rename parse_usec() to parse_sec() sinds the default unit is seconds
[elogind.git] / src / core / load-fragment.c
index d79e1d936cda712655ff2db4073dd56355a58125..42c181de4da6efbef91ad6f3463af6752a0f43e6 100644 (file)
@@ -127,9 +127,10 @@ int config_parse_unit_string_printf(
 
         k = unit_full_printf(u, rvalue);
         if (!k)
-                return log_oom();
+                log_error("[%s:%u] Failed to resolve unit specifiers on %s. Ignoring.",
+                          filename, line, rvalue);
 
-        return config_parse_string(filename, line, section, lvalue, ltype, k, data, userdata);
+        return config_parse_string(filename, line, section, lvalue, ltype, k ? k : rvalue, data, userdata);
 }
 
 int config_parse_unit_strv_printf(
@@ -152,9 +153,10 @@ int config_parse_unit_strv_printf(
 
         k = unit_full_printf(u, rvalue);
         if (!k)
-                return log_oom();
+                log_error("[%s:%u] Failed to resolve unit specifiers on %s. Ignoring.",
+                          filename, line, rvalue);
 
-        return config_parse_strv(filename, line, section, lvalue, ltype, k, data, userdata);
+        return config_parse_strv(filename, line, section, lvalue, ltype, k ? k : rvalue, data, userdata);
 }
 
 int config_parse_unit_path_printf(
@@ -177,9 +179,10 @@ int config_parse_unit_path_printf(
 
         k = unit_full_printf(u, rvalue);
         if (!k)
-                return log_oom();
+                log_error("[%s:%u] Failed to resolve unit specifiers on %s. Ignoring.",
+                          filename, line, rvalue);
 
-        return config_parse_path(filename, line, section, lvalue, ltype, k, data, userdata);
+        return config_parse_path(filename, line, section, lvalue, ltype, k ? k : rvalue, data, userdata);
 }
 
 int config_parse_socket_listen(
@@ -217,8 +220,13 @@ int config_parse_socket_listen(
                 p->type = ltype;
                 p->path = unit_full_printf(UNIT(s), rvalue);
                 if (!p->path) {
-                        free(p);
-                        return log_oom();
+                        p->path = strdup(rvalue);
+                        if (!p->path) {
+                                free(p);
+                                return log_oom();
+                        } else
+                                log_error("[%s:%u] Failed to resolve unit specifiers on %s. Ignoring.",
+                                          filename, line, rvalue);
                 }
 
                 path_kill_slashes(p->path);
@@ -229,12 +237,11 @@ int config_parse_socket_listen(
 
                 p->type = SOCKET_SOCKET;
                 k = unit_full_printf(UNIT(s), rvalue);
-                if (!k) {
-                        free(p);
-                        return log_oom();
-                }
+                if (!k)
+                        log_error("[%s:%u] Failed to resolve unit specifiers on %s. Ignoring.",
+                                  filename, line, rvalue);
 
-                r = socket_address_parse_netlink(&p->address, k);
+                r = socket_address_parse_netlink(&p->address, k ? k : rvalue);
                 if (r < 0) {
                         log_error("[%s:%u] Failed to parse address value, ignoring: %s", filename, line, rvalue);
                         free(p);
@@ -247,12 +254,11 @@ int config_parse_socket_listen(
 
                 p->type = SOCKET_SOCKET;
                 k = unit_full_printf(UNIT(s), rvalue);
-                if (!k) {
-                        free(p);
-                        return log_oom();
-                }
+                if (!k)
+                        log_error("[%s:%u] Failed to resolve unit specifiers on %s. Ignoring.",
+                                  filename, line, rvalue);
 
-                r = socket_address_parse(&p->address, k);
+                r = socket_address_parse(&p->address, k ? k : rvalue);
                 if (r < 0) {
                         log_error("[%s:%u] Failed to parse address value, ignoring: %s", filename, line, rvalue);
                         free(p);
@@ -840,17 +846,17 @@ int config_parse_exec_secure_bits(
 
         FOREACH_WORD_QUOTED(w, l, rvalue, state) {
                 if (first_word(w, "keep-caps"))
-                        c->secure_bits |= SECURE_KEEP_CAPS;
+                        c->secure_bits |= 1<<SECURE_KEEP_CAPS;
                 else if (first_word(w, "keep-caps-locked"))
-                        c->secure_bits |= SECURE_KEEP_CAPS_LOCKED;
+                        c->secure_bits |= 1<<SECURE_KEEP_CAPS_LOCKED;
                 else if (first_word(w, "no-setuid-fixup"))
-                        c->secure_bits |= SECURE_NO_SETUID_FIXUP;
+                        c->secure_bits |= 1<<SECURE_NO_SETUID_FIXUP;
                 else if (first_word(w, "no-setuid-fixup-locked"))
-                        c->secure_bits |= SECURE_NO_SETUID_FIXUP_LOCKED;
+                        c->secure_bits |= 1<<SECURE_NO_SETUID_FIXUP_LOCKED;
                 else if (first_word(w, "noroot"))
-                        c->secure_bits |= SECURE_NOROOT;
+                        c->secure_bits |= 1<<SECURE_NOROOT;
                 else if (first_word(w, "noroot-locked"))
-                        c->secure_bits |= SECURE_NOROOT_LOCKED;
+                        c->secure_bits |= 1<<SECURE_NOROOT_LOCKED;
                 else {
                         log_error("[%s:%u] Failed to parse secure bits, ignoring: %s",
                                   filename, line, rvalue);
@@ -883,12 +889,6 @@ int config_parse_bounding_set(
         assert(rvalue);
         assert(data);
 
-        if (isempty(rvalue)) {
-                /* An empty assignment resets */
-                *capability_bounding_set_drop = 0;
-                return 0;
-        }
-
         if (rvalue[0] == '~') {
                 invert = true;
                 rvalue++;
@@ -995,9 +995,10 @@ int config_parse_unit_cgroup(
 
                 k = unit_full_printf(u, t);
                 if (!k)
-                        return log_oom();
+                        log_error("[%s:%u] Failed to resolve unit specifiers on %s. Ignoring.",
+                                  filename, line, t);
 
-                ku = cunescape(k);
+                ku = cunescape(k ? k : t);
                 if (!ku)
                         return log_oom();
 
@@ -1185,7 +1186,7 @@ int config_parse_timer(
 
                 id = CLOCK_REALTIME;
         } else {
-                if (parse_usec(rvalue, &u) < 0) {
+                if (parse_sec(rvalue, &u) < 0) {
                         log_error("[%s:%u] Failed to parse timer value, ignoring: %s", filename, line, rvalue);
                         return 0;
                 }
@@ -1284,8 +1285,14 @@ int config_parse_path_spec(
         }
 
         k = unit_full_printf(UNIT(p), rvalue);
-        if (!k)
-                return log_oom();
+        if (!k) {
+                k = strdup(rvalue);
+                if (!k)
+                        return log_oom();
+                else
+                        log_error("[%s:%u] Failed to resolve unit specifiers on %s. Ignoring.",
+                                  filename, line, rvalue);
+        }
 
         if (!path_is_absolute(k)) {
                 log_error("[%s:%u] Path is not absolute, ignoring: %s", filename, line, k);
@@ -1464,7 +1471,7 @@ int config_parse_service_timeout(
         assert(rvalue);
         assert(s);
 
-        r = config_parse_usec(filename, line, section, lvalue, ltype, rvalue, data, userdata);
+        r = config_parse_sec(filename, line, section, lvalue, ltype, rvalue, data, userdata);
         if (r < 0)
                 return r;
 
@@ -2388,7 +2395,7 @@ void unit_dump_config_items(FILE *f) {
                 { config_parse_socket_listen,         "SOCKET [...]" },
                 { config_parse_socket_bind,           "SOCKETBIND" },
                 { config_parse_socket_bindtodevice,   "NETWORKINTERFACE" },
-                { config_parse_usec,                  "SECONDS" },
+                { config_parse_sec,                   "SECONDS" },
                 { config_parse_nsec,                  "NANOSECONDS" },
                 { config_parse_path_strv,             "PATH [...]" },
                 { config_parse_unit_requires_mounts_for, "PATH [...]" },