chiark / gitweb /
core: make sure we properly parse ProtectHome= and ProtectSystem=
[elogind.git] / src / network / networkd-manager.c
index 2e3b4bb885e010249ca56c582a28e6b1c5415ca5..2a0d5342daeb4672f84bc9aa3fda69e71d0cc2ea 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <sys/socket.h>
 #include <linux/if.h>
-#include <libkmod.h>
 
 #include "conf-parser.h"
 #include "path-util.h"
@@ -84,7 +83,7 @@ int manager_new(Manager **ret) {
         if (!m)
                 return -ENOMEM;
 
-        m->state_file = strdup("/run/systemd/network/state");
+        m->state_file = strdup("/run/systemd/netif/state");
         if (!m->state_file)
                 return -ENOMEM;
 
@@ -120,10 +119,6 @@ int manager_new(Manager **ret) {
                         return -ENOMEM;
         }
 
-        m->kmod_ctx = kmod_new(NULL, NULL);
-        if (!m->kmod_ctx)
-                return -ENOMEM;
-
         m->links = hashmap_new(uint64_hash_func, uint64_compare_func);
         if (!m->links)
                 return -ENOMEM;
@@ -150,7 +145,6 @@ void manager_free(Manager *m) {
 
         free(m->state_file);
 
-        kmod_unref(m->kmod_ctx);
         udev_monitor_unref(m->udev_monitor);
         udev_unref(m->udev);
         sd_bus_unref(m->bus);
@@ -424,8 +418,8 @@ int manager_save(Manager *m) {
         Iterator i;
         _cleanup_free_ char *temp_path = NULL;
         _cleanup_fclose_ FILE *f = NULL;
-        const char *oper_state = "unknown";
-        bool dormant = false, carrier = false;
+        LinkOperationalState operstate = LINK_OPERSTATE_UNKNOWN;
+        const char *operstate_str;
         int r;
 
         assert(m);
@@ -435,16 +429,12 @@ int manager_save(Manager *m) {
                 if (link->flags & IFF_LOOPBACK)
                         continue;
 
-                if (link_has_carrier(link->flags, link->operstate))
-                        carrier = true;
-                else if (link->operstate == IF_OPER_DORMANT)
-                        dormant = true;
+                if (link->operstate > operstate)
+                        operstate = link->operstate;
         }
 
-        if (carrier)
-                oper_state = "carrier";
-        else if (dormant)
-                oper_state = "dormant";
+        operstate_str = link_operstate_to_string(operstate);
+        assert(operstate_str);
 
         r = fopen_temporary(m->state_file, &f, &temp_path);
         if (r < 0)
@@ -454,7 +444,7 @@ int manager_save(Manager *m) {
 
         fprintf(f,
                 "# This is private data. Do not parse.\n"
-                "OPER_STATE=%s\n", oper_state);
+                "OPER_STATE=%s\n", operstate_str);
 
         fflush(f);