]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/resolved-manager.c
networkd: simplify signal handling of SIGTERM/SIGINT
[thirdparty/systemd.git] / src / resolve / resolved-manager.c
index ae173991da2ca11cbb18102ea5fdd7650d3d690f..0e2b85b5a9201dd8e684e390eb4b3cb1a6526dc4 100644 (file)
@@ -30,7 +30,6 @@
 #include "dhcp-lease-internal.h"
 #include "network-internal.h"
 #include "conf-parser.h"
-#include "mkdir.h"
 
 static int set_fallback_dns(Manager *m, const char *string) {
         char *word, *state;
@@ -98,23 +97,13 @@ int config_parse_dnsv(
 }
 
 static int manager_parse_config_file(Manager *m) {
-        static const char fn[] = "/etc/systemd/resolved.conf";
-        _cleanup_fclose_ FILE *f = NULL;
         int r;
 
         assert(m);
 
-        f = fopen(fn, "re");
-        if (!f) {
-                if (errno == ENOENT)
-                        return 0;
-
-                log_warning("Failed to open configuration file %s: %m", fn);
-                return -errno;
-        }
-
-        r = config_parse(NULL, fn, f, "Resolve\0", config_item_perf_lookup,
-                         (void*) resolved_gperf_lookup, false, false, m);
+        r = config_parse(NULL, "/etc/systemd/resolved.conf", NULL,
+                         "Resolve\0", config_item_perf_lookup, (void*) resolved_gperf_lookup,
+                         false, false, m);
         if (r < 0)
                 log_warning("Failed to parse configuration file: %s", strerror(-r));
 
@@ -192,6 +181,7 @@ static void append_dns(FILE *f, void *dns, unsigned char family, unsigned *count
 }
 
 int manager_update_resolv_conf(Manager *m) {
+        const char *path = "/run/systemd/resolve/resolv.conf";
         _cleanup_free_ char *temp_path = NULL;
         _cleanup_fclose_ FILE *f = NULL;
          _cleanup_free_ unsigned *indices = NULL;
@@ -201,7 +191,7 @@ int manager_update_resolv_conf(Manager *m) {
 
         assert(m);
 
-        r = fopen_temporary("/run/systemd/network/resolv.conf", &f, &temp_path);
+        r = fopen_temporary(path, &f, &temp_path);
         if (r < 0)
                 return r;
 
@@ -263,9 +253,9 @@ int manager_update_resolv_conf(Manager *m) {
 
         fflush(f);
 
-        if (ferror(f) || rename(temp_path, "/run/systemd/network/resolv.conf") < 0) {
+        if (ferror(f) || rename(temp_path, path) < 0) {
                 r = -errno;
-                unlink("/run/systemd/network/resolv.conf");
+                unlink(path);
                 unlink(temp_path);
                 return r;
         }