chiark / gitweb /
resolved: fix typo in sd_notify() call
[elogind.git] / src / resolve / resolved.c
index 275f99c924fab6de5f4f4b6fb5a1b7ae06d02476..6dd4cade05e9346043afb9d087457bde30f2079b 100644 (file)
 
 #include "sd-event.h"
 #include "sd-daemon.h"
-
-#include "resolved.h"
-
 #include "mkdir.h"
+#include "label.h"
 #include "capability.h"
 
+#include "resolved-manager.h"
+#include "resolved-conf.h"
+
 int main(int argc, char *argv[]) {
         _cleanup_(manager_freep) Manager *m = NULL;
         const char *user = "systemd-resolve";
@@ -38,14 +39,20 @@ int main(int argc, char *argv[]) {
         log_parse_environment();
         log_open();
 
-        umask(0022);
-
         if (argc != 1) {
                 log_error("This program takes no arguments.");
                 r = -EINVAL;
                 goto finish;
         }
 
+        umask(0022);
+
+        r = mac_selinux_init(NULL);
+        if (r < 0) {
+                log_error("SELinux setup failed: %s", strerror(-r));
+                goto finish;
+        }
+
         r = get_user_creds(&user, &uid, &gid, NULL, NULL);
         if (r < 0) {
                 log_error("Cannot resolve user name %s: %s", user, strerror(-r));
@@ -55,8 +62,7 @@ int main(int argc, char *argv[]) {
         /* Always create the directory where resolv.conf will live */
         r = mkdir_safe_label("/run/systemd/resolve", 0755, uid, gid);
         if (r < 0) {
-                log_error("Could not create runtime directory: %s",
-                          strerror(-r));
+                log_error("Could not create runtime directory: %s", strerror(-r));
                 goto finish;
         }
 
@@ -74,16 +80,20 @@ int main(int argc, char *argv[]) {
 
         r = manager_parse_config_file(m);
         if (r < 0)
-                return r;
+                log_warning("Failed to parse configuration file: %s", strerror(-r));
 
-        /* write finish default resolv.conf to avoid a dangling
-         * symlink */
-        r = manager_write_resolv_conf(m);
+        r = manager_start(m);
         if (r < 0) {
-                log_error("Could not create resolv.conf: %s", strerror(-r));
+                log_error("Failed to start manager: %s", strerror(-r));
                 goto finish;
         }
 
+        /* Write finish default resolv.conf to avoid a dangling
+         * symlink */
+        r = manager_write_resolv_conf(m);
+        if (r < 0)
+                log_warning("Could not create resolv.conf: %s", strerror(-r));
+
         sd_notify(false,
                   "READY=1\n"
                   "STATUS=Processing requests...");
@@ -94,8 +104,12 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
+        sd_event_get_exit_code(m->event, &r);
+
 finish:
-        sd_notify(false, "STATUS=Shutting down...");
+        sd_notify(false,
+                  "STOPPING=1\n"
+                  "STATUS=Shutting down...");
 
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }