84b277
From 4971e2c8438da1a95cdc306e01e9a3c2349342ad Mon Sep 17 00:00:00 2001
84b277
From: Chris Leech <cleech@redhat.com>
84b277
Date: Sun, 23 Nov 2014 20:33:38 -0800
84b277
Subject: [PATCH] mount: check options as well as fstype for network mounts
84b277
84b277
When creating a new mount unit after an event on /proc/self/mountinfo,
84b277
check the mount options as well as the fstype to determine if this is a
84b277
remote mount that requires network access.
84b277
84b277
Conflicts:
84b277
	src/core/mount.c
84b277
84b277
(cherry-picked from affc3d834347076e8616948978e70ed1fca84db4)
84b277
84b277
Resolves: #1161417
84b277
---
84b277
 src/core/mount.c | 33 ++++++++++++++++++++-------------
84b277
 1 file changed, 20 insertions(+), 13 deletions(-)
84b277
84b277
diff --git a/src/core/mount.c b/src/core/mount.c
84b277
index a7987bf..6c3c7be 100644
84b277
--- a/src/core/mount.c
84b277
+++ b/src/core/mount.c
84b277
@@ -75,18 +75,22 @@ static char* mount_test_option(const char *haystack, const char *needle) {
84b277
         return hasmntopt(&me, needle);
84b277
 }
84b277
 
84b277
-static bool mount_is_network(MountParameters *p) {
84b277
-        assert(p);
84b277
-
84b277
-        if (mount_test_option(p->options, "_netdev"))
84b277
+static bool mount_needs_network(const char *options, const char *fstype) {
84b277
+        if (mount_test_option(options, "_netdev"))
84b277
                 return true;
84b277
 
84b277
-        if (p->fstype && fstype_is_network(p->fstype))
84b277
+        if (fstype && fstype_is_network(fstype))
84b277
                 return true;
84b277
 
84b277
         return false;
84b277
 }
84b277
 
84b277
+static bool mount_is_network(MountParameters *p) {
84b277
+        assert(p);
84b277
+
84b277
+        return mount_needs_network(p->options, p->fstype);
84b277
+}
84b277
+
84b277
 static bool mount_is_bind(MountParameters *p) {
84b277
         assert(p);
84b277
 
84b277
@@ -1446,9 +1450,6 @@ static int mount_add_one(
84b277
 
84b277
         u = manager_get_unit(m, e);
84b277
         if (!u) {
84b277
-                const char* const target =
84b277
-                        fstype_is_network(fstype) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET;
84b277
-
84b277
                 delete = true;
84b277
 
84b277
                 u = unit_new(m, sizeof(Mount));
84b277
@@ -1475,14 +1476,20 @@ static int mount_add_one(
84b277
                         goto fail;
84b277
                 }
84b277
 
84b277
-                r = unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true);
84b277
-                if (r < 0)
84b277
-                        goto fail;
84b277
 
84b277
-                if (should_umount(MOUNT(u))) {
84b277
-                        r = unit_add_dependency_by_name(u, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
84b277
+                if (m->running_as == SYSTEMD_SYSTEM) {
84b277
+                        const char* target;
84b277
+
84b277
+                        target = mount_needs_network(options, fstype) ?  SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET;
84b277
+                        r = unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true);
84b277
                         if (r < 0)
84b277
                                 goto fail;
84b277
+
84b277
+                        if (should_umount(MOUNT(u))) {
84b277
+                                r = unit_add_dependency_by_name(u, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
84b277
+                                if (r < 0)
84b277
+                                        goto fail;
84b277
+                        }
84b277
                 }
84b277
 
84b277
                 unit_add_to_load_queue(u);