util: bind_remount_recursive_with_mountinfo(): ignore submounts which cannot be accessed
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 10 Aug 2018 05:30:55 +0000 (14:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 10 Aug 2018 05:30:55 +0000 (14:30 +0900)
Fixes #9844.

src/basic/mount-util.c

index 54d911b..62f1ed4 100644 (file)
@@ -517,7 +517,7 @@ int bind_remount_recursive_with_mountinfo(const char *prefix, bool ro, char **bl
                         (void) get_mount_flags(cleaned, &orig_flags);
                         orig_flags &= ~MS_RDONLY;
 
-                        if (mount(NULL, prefix, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0)
+                        if (mount(NULL, cleaned, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0)
                                 return -errno;
 
                         log_debug("Made top-level directory %s a mount point.", prefix);
@@ -543,6 +543,11 @@ int bind_remount_recursive_with_mountinfo(const char *prefix, bool ro, char **bl
                         r = path_is_mount_point(x, NULL, 0);
                         if (IN_SET(r, 0, -ENOENT))
                                 continue;
+                        if (IN_SET(r, -EACCES, -EPERM)) {
+                                /* Even if root user invoke this, FUSE or NFS mount points may not be acceessed. */
+                                log_debug_errno(r, "Failed to determine '%s' is mount point or not, ignoring: %m", x);
+                                continue;
+                        }
                         if (r < 0)
                                 return r;