chiark / gitweb /
mount: add implicit umount.target conflicts only in system mode
[elogind.git] / src / automount.c
index b5003b3a756babf4a5f77979dd67662cbbf3ade2..934aa5f35d78dc83716a56433d0ff3d4e8e28838 100644 (file)
@@ -154,6 +154,11 @@ static int automount_verify(Automount *a) {
         if (a->meta.load_state != UNIT_LOADED)
                 return 0;
 
         if (a->meta.load_state != UNIT_LOADED)
                 return 0;
 
+        if (path_equal(a->where, "/")) {
+                log_error("Cannot have an automount unit for the root directory. Refusing.");
+                return -EINVAL;
+        }
+
         if (!(e = unit_name_from_path(a->where, ".automount")))
                 return -ENOMEM;
 
         if (!(e = unit_name_from_path(a->where, ".automount")))
                 return -ENOMEM;
 
@@ -196,7 +201,8 @@ static int automount_load(Unit *u) {
                 if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(a->mount), true)) < 0)
                         return r;
 
                 if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(a->mount), true)) < 0)
                         return r;
 
-                if (a->meta.default_dependencies)
+                if (a->meta.default_dependencies &&
+                    a->meta.manager->running_as == MANAGER_SYSTEM)
                         if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
                                 return r;
         }
                         if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
                                 return r;
         }