From ef454fd1936813fa45d3e3b459d43fa30be7bf49 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 10 Aug 2018 14:30:55 +0900 Subject: [PATCH] util: bind_remount_recursive_with_mountinfo(): ignore submounts which cannot be accessed Fixes #9844. --- src/basic/mount-util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index 54d911b..62f1ed4 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -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; -- 2.7.4