]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
namespace: don't make the root directory of a namespace a mount if it already is one
authorLennart Poettering <lennart@poettering.net>
Fri, 26 Aug 2016 09:27:38 +0000 (11:27 +0200)
committerDjalal Harouni <tixxdz@opendz.org>
Sun, 25 Sep 2016 08:42:18 +0000 (10:42 +0200)
Let's not stack mounts needlessly.

src/core/namespace.c

index d3ab2e8e3e60564b30d28a5d4af5e5746c266dcc..a7451ffbdc2f5f794e1a65ce9e852e5470a6edb0 100644 (file)
@@ -650,10 +650,15 @@ int setup_namespace(
         }
 
         if (root_directory) {
-                /* Turn directory into bind mount */
-                if (mount(root_directory, root_directory, NULL, MS_BIND|MS_REC, NULL) < 0) {
-                        r = -errno;
+                /* Turn directory into bind mount, if it isn't one yet */
+                r = path_is_mount_point(root_directory, AT_SYMLINK_FOLLOW);
+                if (r < 0)
                         goto finish;
+                if (r == 0) {
+                        if (mount(root_directory, root_directory, NULL, MS_BIND|MS_REC, NULL) < 0) {
+                                r = -errno;
+                                goto finish;
+                        }
                 }
         }