]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/resolved-dnssd.c
resolved: add missing error code check when initializing DNS-over-TLS
[thirdparty/systemd.git] / src / resolve / resolved-dnssd.c
index 18e61aaee32229e8f71aab648eac6967cfec436f..0e6fa1d0c96069365dedd1da0be3e741f35456eb 100644 (file)
@@ -1,39 +1,15 @@
-/***
-  This file is part of systemd.
-
-  Copyright 2017 Dmitry Rozhkov
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
+/* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include "conf-files.h"
 #include "conf-parser.h"
+#include "def.h"
 #include "resolved-dnssd.h"
 #include "resolved-dns-rr.h"
 #include "resolved-manager.h"
 #include "specifier.h"
 #include "strv.h"
 
-const char* const dnssd_service_dirs[] = {
-        "/etc/systemd/dnssd",
-        "/run/systemd/dnssd",
-        "/usr/lib/systemd/dnssd",
-#ifdef HAVE_SPLIT_USR
-        "/lib/systemd/dnssd",
-#endif
-    NULL
-};
+#define DNSSD_SERVICE_DIRS ((const char* const*) CONF_PATHS_STRV("systemd/dnssd"))
 
 DnssdTxtData *dnssd_txtdata_free(DnssdTxtData *txt_data) {
         if (!txt_data)
@@ -110,7 +86,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
 
         dropin_dirname = strjoina(service->name, ".dnssd.d");
 
-        r = config_parse_many(filename, dnssd_service_dirs, dropin_dirname,
+        r = config_parse_many(filename, DNSSD_SERVICE_DIRS, dropin_dirname,
                               "Service\0",
                               config_item_perf_lookup, resolved_dnssd_gperf_lookup,
                               false, service);
@@ -159,7 +135,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
         return 0;
 }
 
-static int specifier_dnssd_host_name(char specifier, void *data, void *userdata, char **ret) {
+static int specifier_dnssd_host_name(char specifier, const void *data, const void *userdata, char **ret) {
         DnssdService *s  = (DnssdService *) userdata;
         char *n;
 
@@ -179,7 +155,7 @@ int dnssd_render_instance_name(DnssdService *s, char **ret_name) {
         static const Specifier specifier_table[] = {
                 { 'b', specifier_boot_id,         NULL },
                 { 'H', specifier_dnssd_host_name, NULL },
-                { 'm', specifier_machine_id, NULL },
+                { 'm', specifier_machine_id,      NULL },
                 { 'v', specifier_kernel_release,  NULL },
                 {}
         };
@@ -193,10 +169,10 @@ int dnssd_render_instance_name(DnssdService *s, char **ret_name) {
         if (r < 0)
                 return log_debug_errno(r, "Failed to replace specifiers: %m");
 
-        if (!dns_service_name_is_valid(name)) {
-                log_debug("Service instance name '%s' is invalid.", name);
-                return -EINVAL;
-        }
+        if (!dns_service_name_is_valid(name))
+                return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
+                                       "Service instance name '%s' is invalid.",
+                                       name);
 
         *ret_name = TAKE_PTR(name);
 
@@ -213,7 +189,7 @@ int dnssd_load(Manager *manager) {
         if (manager->mdns_support != RESOLVE_SUPPORT_YES)
                 return 0;
 
-        r = conf_files_list_strv(&files, ".dnssd", NULL, 0, dnssd_service_dirs);
+        r = conf_files_list_strv(&files, ".dnssd", NULL, 0, DNSSD_SERVICE_DIRS);
         if (r < 0)
                 return log_error_errno(r, "Failed to enumerate .dnssd files: %m");
 
@@ -246,10 +222,10 @@ int dnssd_update_rrs(DnssdService *s) {
         if (r < 0)
                 return r;
 
-        r = dns_name_concat(s->type, "local", &service_name);
+        r = dns_name_concat(s->type, "local", 0, &service_name);
         if (r < 0)
                 return r;
-        r = dns_name_concat(n, service_name, &full_name);
+        r = dns_name_concat(n, service_name, 0, &full_name);
         if (r < 0)
                 return r;