chiark / gitweb /
main: don't try to mount api dirs if we are not root
[elogind.git] / src / mount.c
index 921984c1c116a6446ed4bb6facad915b5ac4a87b..dfe4f875e15ecafec55294325c74fa261dd3a0d2 100644 (file)
@@ -167,6 +167,19 @@ static int mount_add_swap_links(Mount *m) {
         return 0;
 }
 
+static int mount_add_path_links(Mount *m) {
+        Meta *other;
+        int r;
+
+        assert(m);
+
+        LIST_FOREACH(units_per_type, other, m->meta.manager->units_per_type[UNIT_PATH])
+                if ((r = path_add_one_mount_link((Path*) other, m)) < 0)
+                        return r;
+
+        return 0;
+}
+
 static int mount_add_automount_links(Mount *m) {
         Meta *other;
         int r;
@@ -267,9 +280,12 @@ static int mount_verify(Mount *m) {
         char *e;
         assert(m);
 
-        if (UNIT(m)->meta.load_state != UNIT_LOADED)
+        if (m->meta.load_state != UNIT_LOADED)
                 return 0;
 
+        if (!m->from_etc_fstab && !m->from_fragment && !m->from_proc_self_mountinfo)
+                return -ENOENT;
+
         if (!(e = unit_name_from_path(m->where, ".mount")))
                 return -ENOMEM;
 
@@ -338,6 +354,9 @@ static int mount_load(Unit *u) {
                 if ((r = mount_add_swap_links(m)) < 0)
                         return r;
 
+                if ((r = mount_add_path_links(m)) < 0)
+                        return r;
+
                 if ((r = mount_add_automount_links(m)) < 0)
                         return r;
 
@@ -933,7 +952,7 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
         case MOUNT_REMOUNTING_SIGKILL:
         case MOUNT_REMOUNTING_SIGTERM:
 
-                if (success && m->from_proc_self_mountinfo)
+                if (success)
                         mount_enter_mounted(m, true);
                 else if (m->from_proc_self_mountinfo)
                         mount_enter_mounted(m, false);