From c799c93c620e794f83a78ca1f02b5263305c812f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 13:11:17 +0900 Subject: [PATCH 01/20] udev: fix indentation Follow-up for 90e30d767a32dc93c9ee94ad8b8d665eecf79e96. --- src/udev/udev-builtin.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index fdb98101d3..b13c1bffe5 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -118,8 +118,7 @@ int udev_builtin_run(sd_device *dev, UdevBuiltinCommand cmd, const char *command if (!builtins[cmd]) return -EOPNOTSUPP; - r = strv_split_full(&argv, command, NULL, - EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_RETAIN_ESCAPE); + r = strv_split_full(&argv, command, NULL, EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_RETAIN_ESCAPE); if (r < 0) return r; From 02241e4339f5f911601ab7979f81adbdf0c588f4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 13:37:02 +0900 Subject: [PATCH 02/20] network: unify config_parse_wireguard_public_key() and config_parse_wireguard_preshared_key() --- src/network/netdev/netdev-gperf.gperf | 4 +-- src/network/netdev/wireguard.c | 44 ++++++--------------------- src/network/netdev/wireguard.h | 4 +-- 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf index 0e2a9ce045..c532dfd268 100644 --- a/src/network/netdev/netdev-gperf.gperf +++ b/src/network/netdev/netdev-gperf.gperf @@ -220,8 +220,8 @@ WireGuard.PrivateKey, config_parse_wireguard_private_key, WireGuard.PrivateKeyFile, config_parse_wireguard_private_key_file, 0, 0 WireGuardPeer.AllowedIPs, config_parse_wireguard_allowed_ips, 0, 0 WireGuardPeer.Endpoint, config_parse_wireguard_endpoint, 0, 0 -WireGuardPeer.PublicKey, config_parse_wireguard_public_key, 0, 0 -WireGuardPeer.PresharedKey, config_parse_wireguard_preshared_key, 0, 0 +WireGuardPeer.PublicKey, config_parse_wireguard_peer_key, 0, 0 +WireGuardPeer.PresharedKey, config_parse_wireguard_peer_key, 0, 0 WireGuardPeer.PresharedKeyFile, config_parse_wireguard_preshared_key_file, 0, 0 WireGuardPeer.PersistentKeepalive, config_parse_wireguard_keepalive, 0, 0 Xfrm.InterfaceId, config_parse_uint32, 0, offsetof(Xfrm, if_id) diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c index f833cfb61a..5a6eb80d34 100644 --- a/src/network/netdev/wireguard.c +++ b/src/network/netdev/wireguard.c @@ -564,7 +564,7 @@ int config_parse_wireguard_private_key_file( return free_and_replace(w->private_key_file, path); } -int config_parse_wireguard_preshared_key( +int config_parse_wireguard_peer_key( const char *unit, const char *filename, unsigned line, @@ -576,7 +576,7 @@ int config_parse_wireguard_preshared_key( void *data, void *userdata) { - WireguardPeer *peer; + _cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL; Wireguard *w; int r; @@ -588,7 +588,13 @@ int config_parse_wireguard_preshared_key( if (r < 0) return log_oom(); - (void) wireguard_decode_key_and_warn(rvalue, peer->preshared_key, unit, filename, line, lvalue); + r = wireguard_decode_key_and_warn(rvalue, + streq(lvalue, "PublicKey") ? peer->public_key : peer->preshared_key, + unit, filename, line, lvalue); + if (r < 0) + return r; + + TAKE_PTR(peer); return 0; } @@ -635,38 +641,6 @@ int config_parse_wireguard_preshared_key_file( return 0; } -int config_parse_wireguard_public_key( - 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_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL; - Wireguard *w; - int r; - - assert(data); - w = WIREGUARD(data); - assert(w); - - r = wireguard_peer_new_static(w, filename, section_line, &peer); - if (r < 0) - return log_oom(); - - r = wireguard_decode_key_and_warn(rvalue, peer->public_key, unit, filename, line, lvalue); - if (r < 0) - return 0; - - TAKE_PTR(peer); - return 0; -} - int config_parse_wireguard_allowed_ips( const char *unit, const char *filename, diff --git a/src/network/netdev/wireguard.h b/src/network/netdev/wireguard.h index ce336c985a..61113113e4 100644 --- a/src/network/netdev/wireguard.h +++ b/src/network/netdev/wireguard.h @@ -61,10 +61,8 @@ extern const NetDevVTable wireguard_vtable; CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_allowed_ips); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_endpoint); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_listen_port); - -CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_public_key); +CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_peer_key); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key_file); -CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_preshared_key); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_preshared_key_file); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_keepalive); From a8a50f4fb7099f7458dcfc8a801e1b91e4467fc4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 13:38:31 +0900 Subject: [PATCH 03/20] network: do not ignore OOM error in wireguard_decode_key_and_warn() --- src/network/netdev/wireguard.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c index 5a6eb80d34..314fceb715 100644 --- a/src/network/netdev/wireguard.c +++ b/src/network/netdev/wireguard.c @@ -492,6 +492,8 @@ static int wireguard_decode_key_and_warn( (void) warn_file_is_world_accessible(filename, NULL, unit, line); r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len); + if (r == -ENOMEM) + return log_oom(); if (r < 0) { log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to decode wireguard key provided by %s=, ignoring assignment: %m", lvalue); @@ -526,8 +528,7 @@ int config_parse_wireguard_private_key( w = WIREGUARD(data); assert(w); - (void) wireguard_decode_key_and_warn(rvalue, w->private_key, unit, filename, line, lvalue); - return 0; + return wireguard_decode_key_and_warn(rvalue, w->private_key, unit, filename, line, lvalue); } int config_parse_wireguard_private_key_file( From 696c0832e272adb15c9d914b17017e1b970c6554 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 13:39:01 +0900 Subject: [PATCH 04/20] network: use _cleanup_ attribute at one more place --- src/network/netdev/wireguard.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c index 314fceb715..f1de5d41de 100644 --- a/src/network/netdev/wireguard.c +++ b/src/network/netdev/wireguard.c @@ -796,7 +796,7 @@ int config_parse_wireguard_keepalive( void *data, void *userdata) { - WireguardPeer *peer; + _cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL; uint16_t keepalive = 0; Wireguard *w; int r; @@ -824,6 +824,8 @@ int config_parse_wireguard_keepalive( } peer->persistent_keepalive_interval = keepalive; + + TAKE_PTR(peer); return 0; } From 2ca601d8cbf6376db6512383ebd94ed6efc18338 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 13:40:50 +0900 Subject: [PATCH 05/20] network do not ignore OOM error in config_parse_macsec_key_id() --- src/network/netdev/macsec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c index 2776605b1c..702e674ca2 100644 --- a/src/network/netdev/macsec.c +++ b/src/network/netdev/macsec.c @@ -847,6 +847,8 @@ int config_parse_macsec_key_id( return log_oom(); r = unhexmem(rvalue, strlen(rvalue), &p, &l); + if (r == -ENOMEM) + return log_oom(); if (r < 0) { log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse KeyId \"%s\": %m", rvalue); return 0; From e3489e96b3f230c07369707a4bd34b07aca99713 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 13:43:47 +0900 Subject: [PATCH 06/20] network: slightly update log message --- src/network/netdev/macsec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c index 702e674ca2..9d3b8d6e4c 100644 --- a/src/network/netdev/macsec.c +++ b/src/network/netdev/macsec.c @@ -850,12 +850,13 @@ int config_parse_macsec_key_id( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse KeyId \"%s\": %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse KeyId=%s, ignoring assignment: %m", rvalue); return 0; } if (l > MACSEC_KEYID_LEN) { log_syntax(unit, LOG_WARNING, filename, line, 0, - "Specified KeyId is larger then the allowed maximum (%zu > %u), ignoring: %s", + "Specified KeyId= is larger then the allowed maximum (%zu > %u), ignoring: %s", l, MACSEC_KEYID_LEN, rvalue); return 0; } From 4c382a87721f0014b4f15525efdc92779f00f65c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 13:50:10 +0900 Subject: [PATCH 07/20] ethtool: downgrade log level when the error will be ignored --- src/shared/ethtool-util.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c index 14e91e3e4d..9326d2856e 100644 --- a/src/shared/ethtool-util.c +++ b/src/shared/ethtool-util.c @@ -938,12 +938,13 @@ int config_parse_channel(const char *unit, r = safe_atou32(rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse channel value, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse channel value for %s=, ignoring: %s", lvalue, rvalue); return 0; } - if (k < 1) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid %s value, ignoring: %s", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Invalid %s= value, ignoring: %s", lvalue, rvalue); return 0; } @@ -998,24 +999,24 @@ int config_parse_advertise(const char *unit, if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to split advertise modes '%s', ignoring: %m", rvalue); - break; + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to split advertise modes '%s', ignoring assignment: %m", rvalue); + return 0; } if (r == 0) - break; + return 0; mode = ethtool_link_mode_bit_from_string(w); /* We reuse the kernel provided enum which does not contain negative value. So, the cast * below is mandatory. Otherwise, the check below always passes and access an invalid address. */ if ((int) mode < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse advertise mode, ignoring: %s", w); + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Failed to parse advertise mode, ignoring: %s", w); continue; } advertise[mode / 32] |= 1UL << (mode % 32); } - - return 0; } int config_parse_nic_buffer_size(const char *unit, @@ -1040,12 +1041,13 @@ int config_parse_nic_buffer_size(const char *unit, r = safe_atou32(rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse interface buffer value, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse interface buffer value, ignoring: %s", rvalue); return 0; } - if (k < 1) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid %s value, ignoring: %s", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Invalid %s= value, ignoring: %s", lvalue, rvalue); return 0; } From 8add8b508d2838dbc25649f6b4345922f1c896c4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 13:52:27 +0900 Subject: [PATCH 08/20] vlan: downgrade error level if the error will be ignored --- src/shared/vlan-util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shared/vlan-util.c b/src/shared/vlan-util.c index a4b42df85b..180f56ede8 100644 --- a/src/shared/vlan-util.c +++ b/src/shared/vlan-util.c @@ -86,11 +86,13 @@ int config_parse_vlanid( r = parse_vlanid(rvalue, id); if (r == -ERANGE) { - log_syntax(unit, LOG_ERR, filename, line, r, "VLAN identifier outside of valid range 0…4094, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "VLAN identifier outside of valid range 0…4094, ignoring: %s", rvalue); return 0; } if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse VLAN identifier value, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse VLAN identifier value, ignoring: %s", rvalue); return 0; } From 40f04cde5bd15eb63094a6a7dc4d061fc4051939 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 14:07:56 +0900 Subject: [PATCH 09/20] xdg-autostart-generator: downgrade error level when the error will be ignored --- src/xdg-autostart-generator/xdg-autostart-service.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c index 80643236d5..c6f39f25bd 100644 --- a/src/xdg-autostart-generator/xdg-autostart-service.c +++ b/src/xdg-autostart-generator/xdg-autostart-service.c @@ -166,7 +166,7 @@ static int xdg_config_parse_string( /* XDG does not allow duplicate definitions. */ if (*out) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Key %s was defined multiple times, ignoring.", lvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Key %s was defined multiple times, ignoring.", lvalue); return 0; } @@ -238,7 +238,7 @@ static int xdg_config_parse_strv( /* XDG does not allow duplicate definitions. */ if (*ret_sv) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Key %s was already defined, ignoring.", lvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Key %s was already defined, ignoring.", lvalue); return 0; } @@ -256,7 +256,7 @@ static int xdg_config_parse_strv( /* Move forward, and ensure it is a valid escape. */ end++; if (!strchr("sntr\\;", *end)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Undefined escape sequence \\%c.", *end); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Undefined escape sequence \\%c.", *end); return 0; } continue; From c56566530b8635e19105b33bbbd6d1e9a2fa53ea Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 14:13:26 +0900 Subject: [PATCH 10/20] timesync: downgrade error level when the error will be ignored --- src/timesync/timesyncd-conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c index 532d6ea7ec..d7ec94e487 100644 --- a/src/timesync/timesyncd-conf.c +++ b/src/timesync/timesyncd-conf.c @@ -89,7 +89,8 @@ int config_parse_servers( else { r = manager_parse_server_string(m, ltype, rvalue); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse NTP server string '%s'. Ignoring.", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse NTP server string '%s', ignoring: %m", rvalue); return 0; } } From 3de39a1ad4ffa2279683882613077867f8182974 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 14:13:56 +0900 Subject: [PATCH 11/20] conf-parser: use SYNTHETIC_ERRNO() at one more place --- src/shared/conf-parser.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 0fec79f3d7..f4ef7269a8 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -183,10 +183,8 @@ static int parse_line( k = strlen(l); assert(k > 0); - if (l[k-1] != ']') { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid section header '%s'", l); - return -EBADMSG; - } + if (l[k-1] != ']') + return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EBADMSG), "Invalid section header '%s'", l); n = strndup(l+1, k-2); if (!n) From 7a602af0414a1a2dcedf3513c8d1bd14cf11ff2f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 14:14:19 +0900 Subject: [PATCH 12/20] conf-parser: logs about OOM error --- src/shared/conf-parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index f4ef7269a8..90f08252ab 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -188,7 +188,7 @@ static int parse_line( n = strndup(l+1, k-2); if (!n) - return -ENOMEM; + return log_oom(); if (sections && !nulstr_contains(sections, n)) { bool ignore = flags & CONFIG_PARSE_RELAXED; From 34136e1503cf60852051adbd8b9a002d6282b750 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 15:05:19 +0900 Subject: [PATCH 13/20] resolve: check DNSSD service name template before assigning it --- src/resolve/resolved-bus.c | 9 +++---- src/resolve/resolved-conf.c | 48 +++++++++++++++++------------------- src/resolve/resolved-dnssd.c | 18 ++++++-------- src/resolve/resolved-dnssd.h | 2 +- 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c index ca01e5f50b..b60a0fd1f2 100644 --- a/src/resolve/resolved-bus.c +++ b/src/resolve/resolved-bus.c @@ -1754,7 +1754,6 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata, _cleanup_(dnssd_service_freep) DnssdService *service = NULL; _cleanup_(sd_bus_track_unrefp) sd_bus_track *bus_track = NULL; _cleanup_free_ char *path = NULL; - _cleanup_free_ char *instance_name = NULL; Manager *m = userdata; DnssdService *s = NULL; const char *name; @@ -1795,6 +1794,10 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata, if (!dnssd_srv_type_is_valid(type)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service type '%s' is invalid", type); + r = dnssd_render_instance_name(name_template, NULL); + if (r < 0) + return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service name '%s' is invalid", name_template); + service->name = strdup(name); if (!service->name) return log_oom(); @@ -1807,10 +1810,6 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata, if (!service->type) return log_oom(); - r = dnssd_render_instance_name(service, &instance_name); - if (r < 0) - return r; - r = sd_bus_message_enter_container(message, SD_BUS_TYPE_ARRAY, "a{say}"); if (r < 0) return r; diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index 184df0337f..3850db0931 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -222,21 +222,19 @@ int config_parse_search_domains( return 0; } -int config_parse_dnssd_service_name(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) { - static const Specifier specifier_table[] = { - { 'm', specifier_machine_id, NULL }, - { 'b', specifier_boot_id, NULL }, - { 'H', specifier_host_name, NULL }, - { 'v', specifier_kernel_release, NULL }, - { 'a', specifier_architecture, NULL }, - { 'o', specifier_os_id, NULL }, - { 'w', specifier_os_version_id, NULL }, - { 'B', specifier_os_build_id, NULL }, - { 'W', specifier_os_variant_id, NULL }, - {} - }; +int config_parse_dnssd_service_name( + 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) { + DnssdService *s = userdata; - _cleanup_free_ char *name = NULL; int r; assert(filename); @@ -245,23 +243,23 @@ int config_parse_dnssd_service_name(const char *unit, const char *filename, unsi assert(s); if (isempty(rvalue)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name can't be empty. Ignoring."); - return -EINVAL; + s->name_template = mfree(s->name_template); + return 0; + } + + r = dnssd_render_instance_name(rvalue, NULL); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Invalid service instance name template '%s', ignoring: %m", rvalue); + return 0; } r = free_and_strdup(&s->name_template, rvalue); if (r < 0) return log_oom(); - r = specifier_printf(s->name_template, specifier_table, NULL, &name); - if (r < 0) - return log_debug_errno(r, "Failed to replace specifiers: %m"); - - if (!dns_service_name_is_valid(name)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name template renders to invalid name '%s'. Ignoring.", name); - return -EINVAL; - } - return 0; } diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c index 945be07740..8ffe45e744 100644 --- a/src/resolve/resolved-dnssd.c +++ b/src/resolve/resolved-dnssd.c @@ -155,7 +155,7 @@ static int specifier_dnssd_host_name(char specifier, const void *data, const voi return 0; } -int dnssd_render_instance_name(DnssdService *s, char **ret_name) { +int dnssd_render_instance_name(const char *name_template, char **ret_name) { static const Specifier specifier_table[] = { { 'm', specifier_machine_id, NULL }, { 'b', specifier_boot_id, NULL }, @@ -171,19 +171,17 @@ int dnssd_render_instance_name(DnssdService *s, char **ret_name) { _cleanup_free_ char *name = NULL; int r; - assert(s); - assert(s->name_template); + assert(name_template); - r = specifier_printf(s->name_template, specifier_table, s, &name); + r = specifier_printf(name_template, specifier_table, NULL, &name); if (r < 0) - return log_debug_errno(r, "Failed to replace specifiers: %m"); + return r; if (!dns_service_name_is_valid(name)) - return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), - "Service instance name '%s' is invalid.", - name); + return -EINVAL; - *ret_name = TAKE_PTR(name); + if (ret_name) + *ret_name = TAKE_PTR(name); return 0; } @@ -227,7 +225,7 @@ int dnssd_update_rrs(DnssdService *s) { LIST_FOREACH(items, txt_data, s->txt_data_items) txt_data->rr = dns_resource_record_unref(txt_data->rr); - r = dnssd_render_instance_name(s, &n); + r = dnssd_render_instance_name(s->name_template, &n); if (r < 0) return r; diff --git a/src/resolve/resolved-dnssd.h b/src/resolve/resolved-dnssd.h index f2e101452d..304bd890c9 100644 --- a/src/resolve/resolved-dnssd.h +++ b/src/resolve/resolved-dnssd.h @@ -51,7 +51,7 @@ DnssdTxtData *dnssd_txtdata_free_all(DnssdTxtData *txt_data); DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdService*, dnssd_service_free); DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdTxtData*, dnssd_txtdata_free); -int dnssd_render_instance_name(DnssdService *s, char **ret_name); +int dnssd_render_instance_name(const char *name_template, char **ret_name); int dnssd_load(Manager *manager); int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtItem **ret_item); int dnssd_txt_item_new_from_data(const char *key, const void *value, const size_t size, DnsTxtItem **ret_item); From 94069bef23d4e8be1d3927e7c1e8d92e03a9c706 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 15:06:29 +0900 Subject: [PATCH 14/20] resolve: downgrade error level when the error will be ignored --- src/resolve/resolved-conf.c | 64 ++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index 3850db0931..00cea964b4 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -168,7 +168,8 @@ int config_parse_dns_servers( /* Otherwise, add to the list */ r = manager_parse_dns_server_string_and_warn(m, ltype, rvalue); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse DNS server string '%s'. Ignoring.", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse DNS server string '%s', ignoring.", rvalue); return 0; } } @@ -210,7 +211,8 @@ int config_parse_search_domains( /* Otherwise, add to the list */ r = manager_parse_search_domains_and_warn(m, rvalue); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse search domains string '%s'. Ignoring.", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse search domains string '%s', ignoring.", rvalue); return 0; } } @@ -263,7 +265,18 @@ int config_parse_dnssd_service_name( return 0; } -int config_parse_dnssd_service_type(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) { +int config_parse_dnssd_service_type( + 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) { + DnssdService *s = userdata; int r; @@ -273,13 +286,13 @@ int config_parse_dnssd_service_type(const char *unit, const char *filename, unsi assert(s); if (isempty(rvalue)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Service type can't be empty. Ignoring."); - return -EINVAL; + s->type = mfree(s->type); + return 0; } if (!dnssd_srv_type_is_valid(rvalue)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Service type is invalid. Ignoring."); - return -EINVAL; + log_syntax(unit, LOG_WARNING, filename, line, 0, "Service type is invalid. Ignoring."); + return 0; } r = free_and_strdup(&s->type, rvalue); @@ -289,7 +302,18 @@ int config_parse_dnssd_service_type(const char *unit, const char *filename, unsi return 0; } -int config_parse_dnssd_txt(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) { +int config_parse_dnssd_txt( + 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_(dnssd_txtdata_freep) DnssdTxtData *txt_data = NULL; DnssdService *s = userdata; DnsTxtItem *last = NULL; @@ -310,9 +334,7 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line return log_oom(); for (;;) { - _cleanup_free_ char *word = NULL; - _cleanup_free_ char *key = NULL; - _cleanup_free_ char *value = NULL; + _cleanup_free_ char *word = NULL, *key = NULL, *value = NULL; _cleanup_free_ void *decoded = NULL; size_t length = 0; DnsTxtItem *i; @@ -324,8 +346,10 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line break; if (r == -ENOMEM) return log_oom(); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); + return 0; + } r = split_pair(word, "=", &key, &value); if (r == -ENOMEM) @@ -334,8 +358,8 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line key = TAKE_PTR(word); if (!ascii_is_valid(key)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid syntax, ignoring: %s", key); - return -EINVAL; + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid key, ignoring: %s", key); + continue; } switch (ltype) { @@ -345,9 +369,11 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line r = unbase64mem(value, strlen(value), &decoded, &length); if (r == -ENOMEM) return log_oom(); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, - "Invalid base64 encoding, ignoring: %s", value); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Invalid base64 encoding, ignoring: %s", value); + continue; + } } r = dnssd_txt_item_new_from_data(key, decoded, length, &i); @@ -371,7 +397,7 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line if (!LIST_IS_EMPTY(txt_data->txt)) { LIST_PREPEND(items, s->txt_data_items, txt_data); - txt_data = NULL; + TAKE_PTR(txt_data); } return 0; From e459258f196bc9b4c8fa6aa3c7910b03962c0017 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 15:08:13 +0900 Subject: [PATCH 15/20] repart: downgrade log level --- src/partition/repart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index f5015b73a1..0c31c36f88 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -947,7 +947,7 @@ static int config_parse_label( r = specifier_printf(rvalue, specifier_table, NULL, &resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to expand specifiers in Label=, ignoring: %s", rvalue); return 0; } From a86417074516ace24986d36070658fba0339a03a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 15:16:14 +0900 Subject: [PATCH 16/20] nspawn: downgrade log level if the error will be ignored --- src/nspawn/nspawn-settings.c | 91 +++++++++++++++--------------------- 1 file changed, 37 insertions(+), 54 deletions(-) diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c index 2fa5cc40a3..bd8062d3ec 100644 --- a/src/nspawn/nspawn-settings.c +++ b/src/nspawn/nspawn-settings.c @@ -233,14 +233,10 @@ int config_parse_expose_port( assert(rvalue); r = expose_port_parse(&s->expose_ports, rvalue); - if (r == -EEXIST) { - log_syntax(unit, LOG_ERR, filename, line, r, "Duplicate port specification, ignoring: %s", rvalue); - return 0; - } - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse host port %s: %m", rvalue); - return 0; - } + if (r == -EEXIST) + log_syntax(unit, LOG_WARNING, filename, line, r, "Duplicate port specification, ignoring: %s", rvalue); + else if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse host port %s: %m", rvalue); return 0; } @@ -268,8 +264,10 @@ int config_parse_capability( _cleanup_free_ char *word = NULL; r = extract_first_word(&rvalue, &word, NULL, 0); + if (r == -ENOMEM) + return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract capability string, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract capability string, ignoring: %s", rvalue); return 0; } if (r == 0) @@ -280,7 +278,7 @@ int config_parse_capability( else { r = capability_from_name(word); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse capability, ignoring: %s", word); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse capability, ignoring: %s", word); continue; } @@ -315,10 +313,8 @@ int config_parse_pivot_root( assert(rvalue); r = pivot_root_parse(&settings->pivot_root_new, &settings->pivot_root_old, rvalue); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid pivot root mount specification %s: %m", rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid pivot root mount specification %s: %m", rvalue); return 0; } @@ -343,10 +339,8 @@ int config_parse_bind( assert(rvalue); r = bind_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue, ltype); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid bind mount specification %s: %m", rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid bind mount specification %s: %m", rvalue); return 0; } @@ -371,10 +365,8 @@ int config_parse_tmpfs( assert(rvalue); r = tmpfs_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid temporary file system specification %s: %m", rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid temporary file system specification %s: %m", rvalue); return 0; } @@ -399,10 +391,8 @@ int config_parse_inaccessible( assert(rvalue); r = inaccessible_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid inaccessible file system specification %s: %m", rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid inaccessible file system specification %s: %m", rvalue); return 0; } @@ -428,7 +418,7 @@ int config_parse_overlay( r = overlay_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue, ltype); if (r < 0) - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid overlay file system specification %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid overlay file system specification %s, ignoring: %m", rvalue); return 0; } @@ -453,10 +443,8 @@ int config_parse_veth_extra( assert(rvalue); r = veth_extra_parse(&settings->network_veth_extra, rvalue); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid extra virtual Ethernet link specification %s: %m", rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid extra virtual Ethernet link specification %s: %m", rvalue); return 0; } @@ -482,13 +470,11 @@ int config_parse_network_zone( j = strjoin("vz-", rvalue); if (!ifname_valid(j)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid network zone name, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid network zone name, ignoring: %s", rvalue); return 0; } - free_and_replace(settings->network_zone, j); - - return 0; + return free_and_replace(settings->network_zone, j); } int config_parse_boot( @@ -512,11 +498,11 @@ int config_parse_boot( r = parse_boolean(rvalue); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Boot= parameter %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Boot= parameter %s, ignoring: %m", rvalue); return 0; } - if (r > 0) { + if (r) { if (settings->start_mode == START_PID2) goto conflict; @@ -532,7 +518,7 @@ int config_parse_boot( return 0; conflict: - log_syntax(unit, LOG_ERR, filename, line, r, "Conflicting Boot= or ProcessTwo= setting found. Ignoring."); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Conflicting Boot= or ProcessTwo= setting found. Ignoring."); return 0; } @@ -557,11 +543,11 @@ int config_parse_pid2( r = parse_boolean(rvalue); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse ProcessTwo= parameter %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse ProcessTwo= parameter %s, ignoring: %m", rvalue); return 0; } - if (r > 0) { + if (r) { if (settings->start_mode == START_BOOT) goto conflict; @@ -577,7 +563,7 @@ int config_parse_pid2( return 0; conflict: - log_syntax(unit, LOG_ERR, filename, line, r, "Conflicting Boot= or ProcessTwo= setting found. Ignoring."); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Conflicting Boot= or ProcessTwo= setting found. Ignoring."); return 0; } @@ -629,7 +615,7 @@ int config_parse_private_users( r = safe_atou32(range, &rn); if (r < 0 || rn <= 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "UID/GID range invalid, ignoring: %s", range); + log_syntax(unit, LOG_WARNING, filename, line, r, "UID/GID range invalid, ignoring: %s", range); return 0; } } else { @@ -639,7 +625,7 @@ int config_parse_private_users( r = parse_uid(shift, &sh); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "UID/GID shift invalid, ignoring: %s", range); + log_syntax(unit, LOG_WARNING, filename, line, r, "UID/GID shift invalid, ignoring: %s", range); return 0; } @@ -680,11 +666,12 @@ int config_parse_syscall_filter( r = extract_first_word(&items, &word, NULL, 0); if (r == 0) - break; + return 0; if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse SystemCallFilter= parameter %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse SystemCallFilter= parameter %s, ignoring: %m", rvalue); return 0; } @@ -695,8 +682,6 @@ int config_parse_syscall_filter( if (r < 0) return log_oom(); } - - return 0; } int config_parse_hostname( @@ -717,7 +702,7 @@ int config_parse_hostname( assert(s); if (!hostname_is_valid(rvalue, false)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid hostname, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid hostname, ignoring: %s", rvalue); return 0; } @@ -752,11 +737,11 @@ int config_parse_oom_score_adjust( r = parse_oom_score_adjust(rvalue, &oa); if (r == -ERANGE) { - log_syntax(unit, LOG_ERR, filename, line, r, "OOM score adjust value out of range, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "OOM score adjust value out of range, ignoring: %s", rvalue); return 0; } if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse the OOM score adjust value, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse the OOM score adjust value, ignoring: %s", rvalue); return 0; } @@ -863,10 +848,8 @@ int config_parse_link_journal( assert(settings); r = parse_link_journal(rvalue, &settings->link_journal, &settings->link_journal_try); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse link journal mode, ignoring: %s", rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse link journal mode, ignoring: %s", rvalue); return 0; } From 196d41bcde646b8f60260351440dcbb636fb17fc Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 15:18:26 +0900 Subject: [PATCH 17/20] login: downgrade log level if the error will be ignored --- src/login/logind-core.c | 6 ++++-- src/login/logind-user.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/login/logind-core.c b/src/login/logind-core.c index a2b9738fc4..a685b8e5b8 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -466,12 +466,14 @@ int config_parse_n_autovts( r = safe_atou(rvalue, &o); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse number of autovts, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse number of autovts, ignoring: %s", rvalue); return 0; } if (o > 15) { - log_syntax(unit, LOG_ERR, filename, line, r, "A maximum of 15 autovts are supported, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, + "A maximum of 15 autovts are supported, ignoring: %s", rvalue); return 0; } diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 9ceb33cde9..e62f37d58c 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -919,7 +919,7 @@ int config_parse_tmpfs_size( if (r >= 0 && (k <= 0 || (uint64_t) (size_t) k != k)) r = -ERANGE; if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue); return 0; } From adb584870655f75d695a96570b475a47c6cd8970 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 15:20:35 +0900 Subject: [PATCH 18/20] journal: downgrade log level --- src/journal/journald-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 105aefdd6e..34ba24daf6 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -2551,7 +2551,7 @@ int config_parse_line_max( r = parse_size(rvalue, 1024, &v); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse LineMax= value, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse LineMax= value, ignoring: %s", rvalue); return 0; } @@ -2606,7 +2606,7 @@ int config_parse_compress( if (r < 0) { r = parse_size(rvalue, 1024, &compress->threshold_bytes); if (r < 0) - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Compress= value, ignoring: %s", rvalue); else compress->enabled = true; From 144fb165fd365d2a89f8e8b13012d21a6057fe15 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 15:21:43 +0900 Subject: [PATCH 19/20] homed: downgrade log level --- src/home/homed-conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/home/homed-conf.c b/src/home/homed-conf.c index df3a17358b..c6c2e1787f 100644 --- a/src/home/homed-conf.c +++ b/src/home/homed-conf.c @@ -45,7 +45,7 @@ int config_parse_default_file_system_type( assert(s); if (!isempty(rvalue) && !supported_fstype(rvalue)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Unsupported file system, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Unsupported file system, ignoring: %s", rvalue); return 0; } From 323dda7806f3cbfd13119186e0ead336fdcf33c1 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Sep 2020 16:24:31 +0900 Subject: [PATCH 20/20] core: downgrade error level and ignore several non-critical errors --- src/core/load-fragment.c | 544 ++++++++++++++++++++------------------- 1 file changed, 279 insertions(+), 265 deletions(-) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 404a85e1ae..d3919adddf 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -154,39 +154,35 @@ int config_parse_unit_deps( UnitDependency d = ltype; Unit *u = userdata; - const char *p; assert(filename); assert(lvalue); assert(rvalue); - p = rvalue; - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; int r; r = extract_first_word(&p, &word, NULL, EXTRACT_RETAIN_ESCAPE); if (r == 0) - break; + return 0; if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); - break; + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); + return 0; } r = unit_name_printf(u, word, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word); continue; } r = unit_add_dependency_by_name(u, d, k, true, UNIT_DEPENDENCY_FILE); if (r < 0) - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k); } - - return 0; } int config_parse_obsolete_unit_deps( @@ -230,7 +226,7 @@ int config_parse_unit_string_printf( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } @@ -260,7 +256,7 @@ int config_parse_unit_strv_printf( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } @@ -291,7 +287,7 @@ int config_parse_unit_path_printf( /* Let's not bother with anything that is too long */ if (strlen(rvalue) >= PATH_MAX) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, fatal ? LOG_ERR : LOG_WARNING, filename, line, 0, "%s value too long%s.", lvalue, fatal ? "" : ", ignoring"); return fatal ? -ENAMETOOLONG : 0; @@ -299,7 +295,7 @@ int config_parse_unit_path_printf( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, fatal ? LOG_ERR : LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, fatal ? "" : ", ignoring"); return fatal ? -ENOEXEC : 0; @@ -323,7 +319,6 @@ int config_parse_unit_path_strv_printf( char ***x = data; const Unit *u = userdata; int r; - const char *p; assert(filename); assert(lvalue); @@ -335,7 +330,7 @@ int config_parse_unit_path_strv_printf( return 0; } - for (p = rvalue;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); @@ -351,7 +346,7 @@ int config_parse_unit_path_strv_printf( r = unit_full_printf(u, word, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word); return 0; } @@ -432,7 +427,7 @@ int config_parse_socket_listen( r = unit_full_printf(UNIT(s), rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } @@ -454,13 +449,13 @@ int config_parse_socket_listen( r = unit_full_printf(UNIT(s), rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } r = socket_address_parse_netlink(&p->address, k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse address value in '%s', ignoring: %m", k); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse address value in '%s', ignoring: %m", k); return 0; } @@ -471,7 +466,7 @@ int config_parse_socket_listen( r = unit_full_printf(UNIT(s), rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } @@ -484,7 +479,7 @@ int config_parse_socket_listen( r = socket_address_parse_and_warn(&p->address, k); if (r < 0) { if (r != -EAFNOSUPPORT) - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse address value in '%s', ignoring: %m", k); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse address value in '%s', ignoring: %m", k); return 0; } @@ -498,7 +493,7 @@ int config_parse_socket_listen( } if (socket_address_family(&p->address) != AF_LOCAL && p->address.type == SOCK_SEQPACKET) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Address family not supported, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Address family not supported, ignoring: %s", rvalue); return 0; } @@ -546,9 +541,9 @@ int config_parse_exec_nice( r = parse_nice(rvalue, &priority); if (r < 0) { if (r == -ERANGE) - log_syntax(unit, LOG_ERR, filename, line, r, "Nice priority out of range, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Nice priority out of range, ignoring: %s", rvalue); else - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse nice priority '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse nice priority '%s', ignoring: %m", rvalue); return 0; } @@ -586,9 +581,9 @@ int config_parse_exec_oom_score_adjust( r = parse_oom_score_adjust(rvalue, &oa); if (r < 0) { if (r == -ERANGE) - log_syntax(unit, LOG_ERR, filename, line, r, "OOM score adjust value out of range, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "OOM score adjust value out of range, ignoring: %s", rvalue); else - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse the OOM score adjust value '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse the OOM score adjust value '%s', ignoring: %m", rvalue); return 0; } @@ -762,7 +757,7 @@ int config_parse_exec( r = unit_full_printf(u, f, &path); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s'%s: %m", f, ignore ? ", ignoring" : ""); return ignore ? 0 : -ENOEXEC; @@ -770,19 +765,19 @@ int config_parse_exec( if (isempty(path)) { /* First word is either "-" or "@" with no command. */ - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, 0, "Empty path in command line%s: '%s'", ignore ? ", ignoring" : "", rvalue); return ignore ? 0 : -ENOEXEC; } if (!string_is_safe(path)) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, 0, "Executable name contains special characters%s: %s", ignore ? ", ignoring" : "", path); return ignore ? 0 : -ENOEXEC; } if (endswith(path, "/")) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, 0, "Executable path specifies a directory%s: %s", ignore ? ", ignoring" : "", path); return ignore ? 0 : -ENOEXEC; @@ -793,7 +788,7 @@ int config_parse_exec( bool found = false; if (!filename_is_valid(path)) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, 0, "Neither a valid executable name nor an absolute path%s: %s", ignore ? ", ignoring" : "", path); return ignore ? 0 : -ENOEXEC; @@ -815,7 +810,7 @@ int config_parse_exec( } if (!found) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, 0, "Executable \"%s\" not found in path \"%s\"%s", path, DEFAULT_PATH, ignore ? ", ignoring" : ""); return ignore ? 0 : -ENOEXEC; @@ -876,7 +871,7 @@ int config_parse_exec( r = unit_full_printf(u, word, &resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s%s: %m", word, ignore ? ", ignoring" : ""); return ignore ? 0 : -ENOEXEC; @@ -890,7 +885,7 @@ int config_parse_exec( } if (!n || !n[0]) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, 0, "Empty executable name or zeroeth argument%s: %s", ignore ? ", ignoring" : "", rvalue); return ignore ? 0 : -ENOEXEC; @@ -940,7 +935,7 @@ int config_parse_socket_bindtodevice( } if (!ifname_valid(rvalue)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid interface name, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid interface name, ignoring: %s", rvalue); return 0; } @@ -978,14 +973,16 @@ int config_parse_exec_input( _cleanup_free_ char *resolved = NULL; r = unit_full_printf(u, n, &resolved); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s': %m", n); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", n); + return 0; + } if (isempty(resolved)) resolved = mfree(resolved); else if (!fdname_is_valid(resolved)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid file descriptor name: %s", resolved); - return -ENOEXEC; + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid file descriptor name, ignoring: %s", resolved); + return 0; } free_and_replace(c->stdio_fdname[STDIN_FILENO], resolved); @@ -996,12 +993,14 @@ int config_parse_exec_input( _cleanup_free_ char *resolved = NULL; r = unit_full_printf(u, n, &resolved); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s': %m", n); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", n); + return 0; + } r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE | PATH_CHECK_FATAL, unit, filename, line, lvalue); if (r < 0) - return -ENOEXEC; + return 0; free_and_replace(c->stdio_file[STDIN_FILENO], resolved); @@ -1010,7 +1009,7 @@ int config_parse_exec_input( } else { ei = exec_input_from_string(rvalue); if (ei < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse input specifier, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse input specifier, ignoring: %s", rvalue); return 0; } } @@ -1051,18 +1050,26 @@ int config_parse_exec_input_text( } r = cunescape(rvalue, 0, &unescaped); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to decode C escaped text '%s': %m", rvalue); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to decode C escaped text '%s', ignoring: %m", rvalue); + return 0; + } r = unit_full_printf(u, unescaped, &resolved); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s': %m", unescaped); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to resolve unit specifiers in '%s', ignoring: %m", unescaped); + return 0; + } sz = strlen(resolved); if (c->stdin_data_size + sz + 1 < c->stdin_data_size || /* check for overflow */ c->stdin_data_size + sz + 1 > EXEC_STDIN_DATA_MAX) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Standard input data too large (%zu), maximum of %zu permitted, ignoring.", c->stdin_data_size + sz, (size_t) EXEC_STDIN_DATA_MAX); - return -E2BIG; + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Standard input data too large (%zu), maximum of %zu permitted, ignoring.", + c->stdin_data_size + sz, (size_t) EXEC_STDIN_DATA_MAX); + return 0; } p = realloc(c->stdin_data, c->stdin_data_size + sz + 1); @@ -1108,15 +1115,20 @@ int config_parse_exec_input_data( } r = unbase64mem(rvalue, (size_t) -1, &p, &sz); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to decode base64 data, ignoring: %s", rvalue); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to decode base64 data, ignoring: %s", rvalue); + return 0; + } assert(sz > 0); if (c->stdin_data_size + sz < c->stdin_data_size || /* check for overflow */ c->stdin_data_size + sz > EXEC_STDIN_DATA_MAX) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Standard input data too large (%zu), maximum of %zu permitted, ignoring.", c->stdin_data_size + sz, (size_t) EXEC_STDIN_DATA_MAX); - return -E2BIG; + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Standard input data too large (%zu), maximum of %zu permitted, ignoring.", + c->stdin_data_size + sz, (size_t) EXEC_STDIN_DATA_MAX); + return 0; } q = realloc(c->stdin_data, c->stdin_data_size + sz); @@ -1160,14 +1172,16 @@ int config_parse_exec_output( n = startswith(rvalue, "fd:"); if (n) { r = unit_full_printf(u, n, &resolved); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", n); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s: %m", n); + return 0; + } if (isempty(resolved)) resolved = mfree(resolved); else if (!fdname_is_valid(resolved)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid file descriptor name: %s", resolved); - return -ENOEXEC; + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid file descriptor name, ignoring: %s", resolved); + return 0; } eo = EXEC_OUTPUT_NAMED_FD; @@ -1183,30 +1197,34 @@ int config_parse_exec_output( } else if ((n = startswith(rvalue, "file:"))) { r = unit_full_printf(u, n, &resolved); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", n); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", n); + return 0; + } r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE | PATH_CHECK_FATAL, unit, filename, line, lvalue); if (r < 0) - return -ENOEXEC; + return 0; eo = EXEC_OUTPUT_FILE; } else if ((n = startswith(rvalue, "append:"))) { r = unit_full_printf(u, n, &resolved); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", n); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", n); + return 0; + } r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE | PATH_CHECK_FATAL, unit, filename, line, lvalue); if (r < 0) - return -ENOEXEC; + return 0; eo = EXEC_OUTPUT_FILE_APPEND; } else { eo = exec_output_from_string(rvalue); if (eo < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse output specifier, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse output specifier, ignoring: %s", rvalue); return 0; } } @@ -1265,7 +1283,7 @@ int config_parse_exec_io_class(const char *unit, x = ioprio_class_from_string(rvalue); if (x < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse IO scheduling class, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse IO scheduling class, ignoring: %s", rvalue); return 0; } @@ -1302,7 +1320,7 @@ int config_parse_exec_io_priority(const char *unit, r = ioprio_parse_priority(rvalue, &i); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse IO priority, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse IO priority, ignoring: %s", rvalue); return 0; } @@ -1340,7 +1358,7 @@ int config_parse_exec_cpu_sched_policy(const char *unit, x = sched_policy_from_string(rvalue); if (x < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse CPU scheduling policy, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse CPU scheduling policy, ignoring: %s", rvalue); return 0; } @@ -1372,19 +1390,16 @@ int config_parse_numa_mask(const char *unit, if (streq(rvalue, "all")) { r = numa_mask_add_all(&p->nodes); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to create NUMA mask representing \"all\" NUMA nodes, ignoring: %m"); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to create NUMA mask representing \"all\" NUMA nodes, ignoring: %m"); } else { r = parse_cpu_set_extend(rvalue, &p->nodes, true, unit, filename, line, lvalue); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse NUMA node mask, ignoring: %s", rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse NUMA node mask, ignoring: %s", rvalue); } - return r; + return 0; } int config_parse_exec_cpu_sched_prio(const char *unit, @@ -1408,7 +1423,7 @@ int config_parse_exec_cpu_sched_prio(const char *unit, r = safe_atoi(rvalue, &i); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse CPU scheduling priority, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse CPU scheduling priority, ignoring: %s", rvalue); return 0; } @@ -1417,7 +1432,7 @@ int config_parse_exec_cpu_sched_prio(const char *unit, max = sched_get_priority_max(c->cpu_sched_policy); if (i < min || i > max) { - log_syntax(unit, LOG_ERR, filename, line, 0, "CPU scheduling priority is out of range, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "CPU scheduling priority is out of range, ignoring: %s", rvalue); return 0; } @@ -1460,7 +1475,7 @@ int config_parse_root_image_options( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue); return 0; } @@ -1479,12 +1494,12 @@ int config_parse_root_image_options( partition_designator = partition_designator_from_string(partition); if (partition_designator < 0) { - log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Invalid partition name %s, ignoring", partition); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid partition name %s, ignoring", partition); continue; } r = unit_full_printf(u, mount_options, &mount_options_resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", mount_options); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", mount_options); continue; } @@ -1553,10 +1568,14 @@ int config_parse_exec_root_hash( /* We have a roothash to decode, eg: RootHash=012345789abcdef */ r = unhexmem(rvalue, strlen(rvalue), &roothash_decoded, &roothash_decoded_size); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to decode RootHash=, ignoring: %s", rvalue); - if (roothash_decoded_size < sizeof(sd_id128_t)) - return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "RootHash= is too short, ignoring: %s", rvalue); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to decode RootHash=, ignoring: %s", rvalue); + return 0; + } + if (roothash_decoded_size < sizeof(sd_id128_t)) { + log_syntax(unit, LOG_WARNING, filename, line, 0, "RootHash= is too short, ignoring: %s", rvalue); + return 0; + } free_and_replace(c->root_hash, roothash_decoded); c->root_hash_size = roothash_decoded_size; @@ -1602,7 +1621,7 @@ int config_parse_exec_root_hash_sig( p = strdup(rvalue); if (!p) - return -ENOMEM; + return log_oom(); free_and_replace(c->root_hash_sig_path, p); c->root_hash_sig = mfree(c->root_hash_sig); @@ -1610,13 +1629,18 @@ int config_parse_exec_root_hash_sig( return 0; } - if (!(value = startswith(rvalue, "base64:"))) - return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Failed to decode RootHashSignature=, not a path but doesn't start with 'base64:', ignoring: %s", rvalue); + if (!(value = startswith(rvalue, "base64:"))) { + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Failed to decode RootHashSignature=, not a path but doesn't start with 'base64:', ignoring: %s", rvalue); + return 0; + } /* We have a roothash signature to decode, eg: RootHashSignature=base64:012345789abcdef */ r = unbase64mem(value, strlen(value), &roothash_sig_decoded, &roothash_sig_decoded_size); - if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to decode RootHashSignature=, ignoring: %s", rvalue); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to decode RootHashSignature=, ignoring: %s", rvalue); + return 0; + } free_and_replace(c->root_hash_sig, roothash_sig_decoded); c->root_hash_sig_size = roothash_sig_decoded_size; @@ -1691,7 +1715,7 @@ int config_parse_capability_set( r = capability_set_from_string(rvalue, &sum); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= specifier '%s', ignoring: %m", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s= specifier '%s', ignoring: %m", lvalue, rvalue); return 0; } @@ -1746,7 +1770,7 @@ int config_parse_exec_selinux_context( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : ""); return ignore ? 0 : -ENOEXEC; @@ -1795,7 +1819,7 @@ int config_parse_exec_apparmor_profile( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : ""); return ignore ? 0 : -ENOEXEC; @@ -1844,7 +1868,7 @@ int config_parse_exec_smack_process_label( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : ""); return ignore ? 0 : -ENOEXEC; @@ -1889,20 +1913,20 @@ int config_parse_timer( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } if (ltype == TIMER_CALENDAR) { r = calendar_spec_from_string(k, &c); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse calendar specification, ignoring: %s", k); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse calendar specification, ignoring: %s", k); return 0; } } else { r = parse_sec(k, &usec); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse timer value, ignoring: %s", k); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse timer value, ignoring: %s", k); return 0; } } @@ -1945,29 +1969,29 @@ int config_parse_trigger_unit( assert(data); if (!hashmap_isempty(u->dependencies[UNIT_TRIGGERS])) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Multiple units to trigger specified, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Multiple units to trigger specified, ignoring: %s", rvalue); return 0; } r = unit_name_printf(u, rvalue, &p); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); return 0; } type = unit_name_to_type(p); if (type < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Unit type not valid, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Unit type not valid, ignoring: %s", rvalue); return 0; } if (unit_has_name(u, p)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Units cannot trigger themselves, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Units cannot trigger themselves, ignoring: %s", rvalue); return 0; } r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_TRIGGERS, p, true, UNIT_DEPENDENCY_FILE); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add trigger on %s, ignoring: %m", p); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to add trigger on %s, ignoring: %m", p); return 0; } @@ -2004,13 +2028,13 @@ int config_parse_path_spec(const char *unit, b = path_type_from_string(lvalue); if (b < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse path type, ignoring: %s", lvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse path type, ignoring: %s", lvalue); return 0; } r = unit_full_printf(UNIT(p), rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); return 0; } @@ -2057,19 +2081,19 @@ int config_parse_socket_service( r = unit_name_printf(UNIT(s), rvalue, &p); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", rvalue); - return -ENOEXEC; + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); + return 0; } if (!endswith(p, ".service")) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Unit must be of type service: %s", rvalue); - return -ENOEXEC; + log_syntax(unit, LOG_WARNING, filename, line, 0, "Unit must be of type service, ignoring: %s", rvalue); + return 0; } r = manager_load_unit(UNIT(s)->manager, p, NULL, &error, &x); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load unit %s: %s", rvalue, bus_error_message(&error, r)); - return -ENOEXEC; + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to load unit %s, ignoring: %s", rvalue, bus_error_message(&error, r)); + return 0; } unit_ref_set(&s->service, UNIT(s), x); @@ -2105,12 +2129,12 @@ int config_parse_fdname( r = unit_full_printf(UNIT(s), rvalue, &p); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } if (!fdname_is_valid(p)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid file descriptor name, ignoring: %s", p); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid file descriptor name, ignoring: %s", p); return 0; } @@ -2130,7 +2154,6 @@ int config_parse_service_sockets( void *userdata) { Service *s = data; - const char *p; int r; assert(filename); @@ -2138,41 +2161,38 @@ int config_parse_service_sockets( assert(rvalue); assert(data); - p = rvalue; - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; r = extract_first_word(&p, &word, NULL, 0); if (r == 0) - break; + return 0; if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Trailing garbage in sockets, ignoring: %s", rvalue); - break; + log_syntax(unit, LOG_WARNING, filename, line, r, "Trailing garbage in sockets, ignoring: %s", rvalue); + return 0; } r = unit_name_printf(UNIT(s), word, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word); continue; } if (!endswith(k, ".socket")) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Unit must be of type socket, ignoring: %s", k); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Unit must be of type socket, ignoring: %s", k); continue; } r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_WANTS, UNIT_AFTER, k, true, UNIT_DEPENDENCY_FILE); if (r < 0) - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k); r = unit_add_dependency_by_name(UNIT(s), UNIT_TRIGGERED_BY, k, true, UNIT_DEPENDENCY_FILE); if (r < 0) - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k); } - - return 0; } int config_parse_bus_name( @@ -2198,12 +2218,12 @@ int config_parse_bus_name( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); return 0; } if (!sd_bus_service_name_is_valid(k)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid bus name, ignoring: %s", k); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid bus name, ignoring: %s", k); return 0; } @@ -2238,7 +2258,7 @@ int config_parse_service_timeout( * all other timeouts. */ r = parse_sec_fix_0(rvalue, &usec); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue); return 0; } @@ -2280,7 +2300,7 @@ int config_parse_timeout_abort( r = parse_sec(rvalue, ret); if (r < 0) - return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= setting, ignoring: %s", lvalue, rvalue); + return log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s= setting, ignoring: %s", lvalue, rvalue); return 1; /* "set" */ } @@ -2334,10 +2354,8 @@ int config_parse_sec_fix_0( * timeout. */ r = parse_sec_fix_0(rvalue, usec); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue); return 0; } @@ -2406,7 +2424,6 @@ int config_parse_user_group_strv_compat( char ***users = data; const Unit *u = userdata; - const char *p = rvalue; int r; assert(filename); @@ -2419,12 +2436,12 @@ int config_parse_user_group_strv_compat( return 0; } - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; r = extract_first_word(&p, &word, NULL, 0); if (r == 0) - break; + return 0; if (r == -ENOMEM) return log_oom(); if (r < 0) { @@ -2449,8 +2466,6 @@ int config_parse_user_group_strv_compat( k = NULL; } - - return 0; } int config_parse_working_directory( @@ -2496,7 +2511,7 @@ int config_parse_working_directory( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, missing_ok ? LOG_WARNING : LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in working directory path '%s'%s: %m", rvalue, missing_ok ? ", ignoring" : ""); return missing_ok ? 0 : -ENOEXEC; @@ -2543,7 +2558,7 @@ int config_parse_unit_env_file(const char *unit, r = unit_full_printf(u, rvalue, &n); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } @@ -2574,7 +2589,6 @@ int config_parse_environ( const Unit *u = userdata; char ***env = data; - const char *p; int r; assert(filename); @@ -2588,7 +2602,7 @@ int config_parse_environ( return 0; } - for (p = rvalue;; ) { + for (const char *p = rvalue;; ) { _cleanup_free_ char *word = NULL, *k = NULL; r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); @@ -2605,7 +2619,7 @@ int config_parse_environ( if (u) { r = unit_full_printf(u, word, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", word); continue; } @@ -2613,7 +2627,7 @@ int config_parse_environ( k = TAKE_PTR(word); if (!env_assignment_is_valid(k)) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid environment assignment, ignoring: %s", k); continue; } @@ -2641,7 +2655,6 @@ int config_parse_pass_environ( _cleanup_strv_free_ char **n = NULL; size_t nlen = 0, nbufsize = 0; char*** passenv = data; - const char *p = rvalue; const Unit *u = userdata; int r; @@ -2656,7 +2669,7 @@ int config_parse_pass_environ( return 0; } - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); @@ -2665,7 +2678,7 @@ int config_parse_pass_environ( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Trailing garbage in %s, ignoring: %s", lvalue, rvalue); break; } @@ -2673,7 +2686,7 @@ int config_parse_pass_environ( if (u) { r = unit_full_printf(u, word, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve specifiers in %s, ignoring: %m", word); continue; } @@ -2681,7 +2694,7 @@ int config_parse_pass_environ( k = TAKE_PTR(word); if (!env_name_is_valid(k)) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid environment name for %s, ignoring: %s", lvalue, k); continue; } @@ -2717,7 +2730,6 @@ int config_parse_unset_environ( _cleanup_strv_free_ char **n = NULL; size_t nlen = 0, nbufsize = 0; char*** unsetenv = data; - const char *p = rvalue; const Unit *u = userdata; int r; @@ -2732,7 +2744,7 @@ int config_parse_unset_environ( return 0; } - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); @@ -2741,7 +2753,7 @@ int config_parse_unset_environ( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Trailing garbage in %s, ignoring: %s", lvalue, rvalue); break; } @@ -2749,7 +2761,7 @@ int config_parse_unset_environ( if (u) { r = unit_full_printf(u, word, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", word); continue; } @@ -2757,7 +2769,7 @@ int config_parse_unset_environ( k = TAKE_PTR(word); if (!env_assignment_is_valid(k) && !env_name_is_valid(k)) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid environment name or assignment %s, ignoring: %s", lvalue, k); continue; } @@ -2792,7 +2804,6 @@ int config_parse_log_extra_fields( ExecContext *c = data; const Unit *u = userdata; - const char *p = rvalue; int r; assert(filename); @@ -2805,7 +2816,7 @@ int config_parse_log_extra_fields( return 0; } - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; struct iovec *t; const char *eq; @@ -2822,18 +2833,18 @@ int config_parse_log_extra_fields( r = unit_full_printf(u, word, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", word); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", word); continue; } eq = strchr(k, '='); if (!eq) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Log field lacks '=' character, ignoring: %s", k); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Log field lacks '=' character, ignoring: %s", k); continue; } if (!journal_field_valid(k, eq-k, false)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Log field name is invalid, ignoring: %s", k); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Log field name is invalid, ignoring: %s", k); continue; } @@ -2877,12 +2888,12 @@ int config_parse_log_namespace( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); return 0; } if (!log_namespace_name_valid(k)) { - log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Specified log namespace name is not valid: %s", k); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Specified log namespace name is not valid, ignoring: %s", k); return 0; } @@ -2930,7 +2941,7 @@ int config_parse_unit_condition_path( r = unit_full_printf(u, rvalue, &p); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); return 0; } @@ -2986,7 +2997,7 @@ int config_parse_unit_condition_string( r = unit_full_printf(u, rvalue, &s); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } @@ -3011,7 +3022,6 @@ int config_parse_unit_requires_mounts_for( void *data, void *userdata) { - const char *p = rvalue; Unit *u = userdata; int r; @@ -3020,7 +3030,7 @@ int config_parse_unit_requires_mounts_for( assert(rvalue); assert(data); - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *resolved = NULL; r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); @@ -3036,7 +3046,7 @@ int config_parse_unit_requires_mounts_for( r = unit_full_printf(u, word, &resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word); continue; } @@ -3046,7 +3056,7 @@ int config_parse_unit_requires_mounts_for( r = unit_require_mounts_for(u, resolved, UNIT_DEPENDENCY_FILE); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add required mount '%s', ignoring: %m", resolved); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to add required mount '%s', ignoring: %m", resolved); continue; } } @@ -3088,7 +3098,7 @@ int config_parse_documentation(const char *unit, if (documentation_url_is_valid(*a)) *(b++) = *a; else { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid URL, ignoring: %s", *a); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid URL, ignoring: %s", *a); free(*a); } } @@ -3114,7 +3124,6 @@ int config_parse_syscall_filter( ExecContext *c = data; _unused_ const Unit *u = userdata; bool invert = false; - const char *p; int r; assert(filename); @@ -3157,8 +3166,7 @@ int config_parse_syscall_filter( } } - p = rvalue; - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *name = NULL; int num; @@ -3201,7 +3209,6 @@ int config_parse_syscall_archs( void *data, void *userdata) { - const char *p = rvalue; Set **archs = data; int r; @@ -3210,7 +3217,7 @@ int config_parse_syscall_archs( return 0; } - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL; uint32_t a; @@ -3227,7 +3234,7 @@ int config_parse_syscall_archs( r = seccomp_arch_from_string(word, &a); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse system call architecture \"%s\", ignoring: %m", word); continue; } @@ -3265,7 +3272,7 @@ int config_parse_syscall_errno( e = parse_errno(rvalue); if (e <= 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse error number, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse error number, ignoring: %s", rvalue); return 0; } @@ -3287,7 +3294,6 @@ int config_parse_address_families( ExecContext *c = data; bool invert = false; - const char *p; int r; assert(filename); @@ -3314,7 +3320,7 @@ int config_parse_address_families( c->address_families_allow_list = !invert; } - for (p = rvalue;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL; int af; @@ -3331,7 +3337,7 @@ int config_parse_address_families( af = af_from_name(word); if (af < 0) { - log_syntax(unit, LOG_ERR, filename, line, af, + log_syntax(unit, LOG_WARNING, filename, line, af, "Failed to parse address family, ignoring: %s", word); continue; } @@ -3389,7 +3395,7 @@ int config_parse_restrict_namespaces( /* Not a boolean argument, in this case it's a list of namespace types. */ r = namespace_flags_from_string(rvalue, &flags); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse namespace type string, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse namespace type string, ignoring: %s", rvalue); return 0; } @@ -3428,19 +3434,19 @@ int config_parse_unit_slice( r = unit_name_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue); return 0; } r = manager_load_unit(u->manager, k, NULL, &error, &slice); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load slice unit %s, ignoring: %s", k, bus_error_message(&error, r)); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to load slice unit %s, ignoring: %s", k, bus_error_message(&error, r)); return 0; } r = unit_set_slice(u, slice); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to assign slice %s to unit %s, ignoring: %m", slice->id, u->id); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to assign slice %s to unit %s, ignoring: %m", slice->id, u->id); return 0; } @@ -3473,7 +3479,7 @@ int config_parse_cpu_quota( r = parse_permille_unbounded(rvalue); if (r <= 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid CPU quota '%s', ignoring.", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid CPU quota '%s', ignoring.", rvalue); return 0; } @@ -3546,7 +3552,7 @@ int config_parse_memory_limit( if (r < 0) { r = parse_size(rvalue, 1024, &bytes); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid memory limit '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid memory limit '%s', ignoring: %m", rvalue); return 0; } } else @@ -3554,7 +3560,7 @@ int config_parse_memory_limit( if (bytes >= UINT64_MAX || (bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Memory limit '%s' out of range, ignoring.", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Memory limit '%s' out of range, ignoring.", rvalue); return 0; } } @@ -3618,12 +3624,12 @@ int config_parse_tasks_max( else { r = safe_atou64(rvalue, &v); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid maximum tasks value '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid maximum tasks value '%s', ignoring: %m", rvalue); return 0; } if (v <= 0 || v >= UINT64_MAX) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Maximum tasks value '%s' out of range, ignoring.", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Maximum tasks value '%s' out of range, ignoring.", rvalue); return 0; } @@ -3653,7 +3659,7 @@ int config_parse_delegate( assert(t != _UNIT_TYPE_INVALID); if (!unit_vtable[t]->can_delegate) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Delegate= setting not supported for this unit type, ignoring."); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Delegate= setting not supported for this unit type, ignoring."); return 0; } @@ -3670,10 +3676,9 @@ int config_parse_delegate( r = parse_boolean(rvalue); if (r < 0) { - const char *p = rvalue; CGroupMask mask = 0; - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL; CGroupController cc; @@ -3683,13 +3688,13 @@ int config_parse_delegate( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); return 0; } cc = cgroup_controller_from_string(word); if (cc < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid controller name '%s', ignoring", word); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid controller name '%s', ignoring", word); continue; } @@ -3762,13 +3767,13 @@ int config_parse_device_allow( return 0; if (!valid_device_node_path(resolved)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid device node path '%s', ignoring.", resolved); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid device node path '%s', ignoring.", resolved); return 0; } } if (!isempty(p) && !in_charset(p, "rwm")) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid device rights '%s', ignoring.", p); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid device rights '%s', ignoring.", p); return 0; } @@ -3832,7 +3837,7 @@ int config_parse_io_device_weight( r = cg_weight_parse(p, &u); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "IO weight '%s' invalid, ignoring: %m", p); + log_syntax(unit, LOG_WARNING, filename, line, r, "IO weight '%s' invalid, ignoring: %m", p); return 0; } @@ -3904,8 +3909,9 @@ int config_parse_io_device_latency( if (r < 0) return 0; - if (parse_sec(p, &usec) < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse timer value, ignoring: %s", p); + r = parse_sec(p, &usec); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse timer value, ignoring: %s", p); return 0; } @@ -3983,7 +3989,7 @@ int config_parse_io_limit( else { r = parse_size(p, 1000, &num); if (r < 0 || num <= 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid IO limit '%s', ignoring.", p); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid IO limit '%s', ignoring.", p); return 0; } } @@ -4071,7 +4077,7 @@ int config_parse_blockio_device_weight( r = cg_blkio_weight_parse(p, &u); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid block IO weight '%s', ignoring: %m", p); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid block IO weight '%s', ignoring: %m", p); return 0; } @@ -4149,7 +4155,7 @@ int config_parse_blockio_bandwidth( r = parse_size(p, 1000, &bytes); if (r < 0 || bytes <= 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid Block IO Bandwidth '%s', ignoring.", p); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid Block IO Bandwidth '%s', ignoring.", p); return 0; } @@ -4201,7 +4207,7 @@ int config_parse_job_mode_isolate( r = parse_boolean(rvalue); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse boolean, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse boolean, ignoring: %s", rvalue); return 0; } @@ -4225,7 +4231,6 @@ int config_parse_exec_directories( char***rt = data; const Unit *u = userdata; - const char *p; int r; assert(filename); @@ -4239,7 +4244,7 @@ int config_parse_exec_directories( return 0; } - for (p = rvalue;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); @@ -4457,8 +4462,13 @@ int config_parse_set_status( Bitmap *bitmap; r = extract_first_word(&p, &word, NULL, 0); - if (r < 0) - return log_error_errno(r, "Failed to parse %s: %m", lvalue); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse %s=%s, ignoring: %m", lvalue, rvalue); + return 0; + } if (r == 0) return 0; @@ -4472,7 +4482,7 @@ int config_parse_set_status( } else { r = signal_from_string(word); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, + log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse value, ignoring: %s", word); continue; } @@ -4481,7 +4491,8 @@ int config_parse_set_status( r = bitmap_set(bitmap, r); if (r < 0) - return log_error_errno(r, "Failed to set signal or status %s: %m", word); + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to set signal or status %s, ignoring: %m", word); } } @@ -4499,7 +4510,6 @@ int config_parse_namespace_path_strv( const Unit *u = userdata; char*** sv = data; - const char *p = rvalue; int r; assert(filename); @@ -4513,7 +4523,7 @@ int config_parse_namespace_path_strv( return 0; } - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *resolved = NULL, *joined = NULL; const char *w; bool ignore_enoent = false, shall_prefix = false; @@ -4524,7 +4534,7 @@ int config_parse_namespace_path_strv( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue); return 0; } @@ -4540,7 +4550,7 @@ int config_parse_namespace_path_strv( r = unit_full_printf(u, w, &resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", w); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s: %m", w); continue; } @@ -4576,7 +4586,6 @@ int config_parse_temporary_filesystems( const Unit *u = userdata; ExecContext *c = data; - const char *p = rvalue; int r; assert(filename); @@ -4592,7 +4601,7 @@ int config_parse_temporary_filesystems( return 0; } - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *path = NULL, *resolved = NULL; const char *w; @@ -4602,7 +4611,7 @@ int config_parse_temporary_filesystems( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue); return 0; } @@ -4611,17 +4620,17 @@ int config_parse_temporary_filesystems( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract first word, ignoring: %s", word); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract first word, ignoring: %s", word); continue; } if (r == 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid syntax, ignoring: %s", word); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid syntax, ignoring: %s", word); continue; } r = unit_full_printf(u, path, &resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", path); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", path); continue; } @@ -4649,7 +4658,6 @@ int config_parse_bind_paths( ExecContext *c = data; const Unit *u = userdata; - const char *p; int r; assert(filename); @@ -4665,8 +4673,7 @@ int config_parse_bind_paths( return 0; } - p = rvalue; - for (;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *source = NULL, *destination = NULL; _cleanup_free_ char *sresolved = NULL, *dresolved = NULL; char *s = NULL, *d = NULL; @@ -4678,13 +4685,13 @@ int config_parse_bind_paths( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue); return 0; } r = unit_full_printf(u, source, &sresolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in \"%s\", ignoring: %m", source); continue; } @@ -4705,17 +4712,17 @@ int config_parse_bind_paths( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue); return 0; } if (r == 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Missing argument after ':', ignoring: %s", s); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Missing argument after ':', ignoring: %s", s); continue; } r = unit_full_printf(u, destination, &dresolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve specifiers in \"%s\", ignoring: %m", destination); continue; } @@ -4734,7 +4741,7 @@ int config_parse_bind_paths( if (r == -ENOMEM) return log_oom(); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s: %s", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s: %s", lvalue, rvalue); return 0; } @@ -4743,7 +4750,7 @@ int config_parse_bind_paths( else if (streq(options, "norbind")) rbind = false; else { - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid option string, ignoring setting: %s", options); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid option string, ignoring setting: %s", options); continue; } } @@ -4779,7 +4786,6 @@ int config_parse_mount_images( ExecContext *c = data; const Unit *u = userdata; - const char *p = rvalue; int r; assert(filename); @@ -4793,7 +4799,7 @@ int config_parse_mount_images( return 0; } - for (;;) { + for (const char *p = rvalue;;) { _cleanup_(mount_options_free_allp) MountOptions *options = NULL; _cleanup_free_ char *first = NULL, *second = NULL, *tuple = NULL; _cleanup_free_ char *sresolved = NULL, *dresolved = NULL; @@ -4802,21 +4808,31 @@ int config_parse_mount_images( bool permissive = false; r = extract_first_word(&p, &tuple, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE); - if (r < 0) - return r; + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Invalid syntax %s=%s, ignoring: %m", lvalue, rvalue); + return 0; + } if (r == 0) - break; + return 0; q = tuple; r = extract_many_words(&q, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS, &first, &second, NULL); - if (r < 0) - return r; + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Invalid syntax in %s=, ignoring: %s", lvalue, tuple); + return 0; + } if (r == 0) continue; r = unit_full_printf(u, first, &sresolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in \"%s\", ignoring: %m", first); continue; } @@ -4832,13 +4848,13 @@ int config_parse_mount_images( continue; if (isempty(second)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Missing destination in %s, ignoring: %s", lvalue, rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Missing destination in %s, ignoring: %s", lvalue, rvalue); continue; } r = unit_full_printf(u, second, &dresolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve specifiers in \"%s\", ignoring: %m", second); continue; } @@ -4853,15 +4869,19 @@ int config_parse_mount_images( int partition_designator; r = extract_many_words(&q, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS, &partition, &mount_options, NULL); - if (r < 0) - return r; + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", q); + return 0; + } if (r == 0) break; /* Single set of options, applying to the root partition/single filesystem */ if (r == 1) { r = unit_full_printf(u, partition, &mount_options_resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", first); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", first); continue; } @@ -4879,12 +4899,12 @@ int config_parse_mount_images( partition_designator = partition_designator_from_string(partition); if (partition_designator < 0) { - log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Invalid partition name %s, ignoring", partition); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid partition name %s, ignoring", partition); continue; } r = unit_full_printf(u, mount_options, &mount_options_resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", mount_options); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", mount_options); continue; } @@ -4908,8 +4928,6 @@ int config_parse_mount_images( if (r < 0) return log_oom(); } - - return 0; } int config_parse_job_timeout_sec( @@ -4935,7 +4953,7 @@ int config_parse_job_timeout_sec( r = parse_sec_fix_0(rvalue, &usec); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse JobTimeoutSec= parameter, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse JobTimeoutSec= parameter, ignoring: %s", rvalue); return 0; } @@ -4974,7 +4992,7 @@ int config_parse_job_running_timeout_sec( r = parse_sec_fix_0(rvalue, &usec); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse JobRunningTimeoutSec= parameter, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse JobRunningTimeoutSec= parameter, ignoring: %s", rvalue); return 0; } @@ -5023,11 +5041,11 @@ int config_parse_emergency_action( } if (r == -EOPNOTSUPP) - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "%s= specified as %s mode action, ignoring: %s", lvalue, MANAGER_IS_SYSTEM(m) ? "user" : "system", rvalue); else - log_syntax(unit, LOG_ERR, filename, line, r, + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s=, ignoring: %s", lvalue, rvalue); return 0; } @@ -5065,7 +5083,7 @@ int config_parse_pid_file( r = unit_full_printf(u, rvalue, &k); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } @@ -5114,7 +5132,7 @@ int config_parse_exit_status( r = safe_atou8(rvalue, &u); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse exit status '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse exit status '%s', ignoring: %m", rvalue); return 0; } @@ -5148,7 +5166,7 @@ int config_parse_disable_controllers( r = cg_mask_from_string(rvalue, &disabled_mask); if (r < 0 || disabled_mask <= 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid cgroup string: %s, ignoring", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid cgroup string: %s, ignoring", rvalue); return 0; } @@ -5186,7 +5204,7 @@ int config_parse_ip_filter_bpf_progs( r = unit_full_printf(u, rvalue, &resolved); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue); return 0; } @@ -5534,10 +5552,8 @@ int config_parse_show_status( assert(data); k = parse_show_status(rvalue, b); - if (k < 0) { - log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse show status setting, ignoring: %s", rvalue); - return 0; - } + if (k < 0) + log_syntax(unit, LOG_WARNING, filename, line, k, "Failed to parse show status setting, ignoring: %s", rvalue); return 0; } @@ -5571,12 +5587,12 @@ int config_parse_output_restricted( } else { t = exec_output_from_string(rvalue); if (t < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse output type, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse output type, ignoring: %s", rvalue); return 0; } if (IN_SET(t, EXEC_OUTPUT_SOCKET, EXEC_OUTPUT_NAMED_FD, EXEC_OUTPUT_FILE, EXEC_OUTPUT_FILE_APPEND)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Standard output types socket, fd:, file:, append: are not supported as defaults, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Standard output types socket, fd:, file:, append: are not supported as defaults, ignoring: %s", rvalue); return 0; } } @@ -5610,10 +5626,8 @@ int config_parse_crash_chvt( assert(data); r = parse_crash_chvt(rvalue, data); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse CrashChangeVT= setting, ignoring: %s", rvalue); - return 0; - } + if (r < 0) + log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse CrashChangeVT= setting, ignoring: %s", rvalue); return 0; } @@ -5647,17 +5661,17 @@ int config_parse_swap_priority( r = safe_atoi(rvalue, &priority); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Invalid swap priority '%s', ignoring.", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid swap priority '%s', ignoring.", rvalue); return 0; } if (priority < -1) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Sorry, swap priorities smaller than -1 may only be assigned by the kernel itself, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Sorry, swap priorities smaller than -1 may only be assigned by the kernel itself, ignoring: %s", rvalue); return 0; } if (priority > 32767) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Swap priority out of range, ignoring: %s", rvalue); + log_syntax(unit, LOG_WARNING, filename, line, 0, "Swap priority out of range, ignoring: %s", rvalue); return 0; }