]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: downgrade error level when the error will be ignored
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Sep 2020 06:06:29 +0000 (15:06 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Sep 2020 06:06:29 +0000 (15:06 +0900)
src/resolve/resolved-conf.c

index 3850db0931720a1bc797456bf6d3ec89ff7ea6b8..00cea964b47fda36f765dd6803b2b11c0424899b 100644 (file)
@@ -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;