diff options
author | Alban Crequy <alban@kinvolk.io> | 2016-07-25 15:39:46 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-06-16 10:13:01 +0200 |
commit | 122eed2f37fe5fe8419147130731f5681358766c (patch) | |
tree | b8251acbd925e783fdabff1a4be08aa5ca93189d /src/basic/mount-util.c | |
parent | 66c622e4c2c1cbfb287033ce8045d0988ac6a78e (diff) |
namespace: don't fail on masked mounts (#3794)
Before this patch, a service file with ReadWriteDirectories=/file...
could fail if the file exists but is not a mountpoint, despite being
listed in /proc/self/mountinfo. It could happen with masked mounts.
Fixes https://github.com/elogind/elogind/issues/3793
Diffstat (limited to 'src/basic/mount-util.c')
-rw-r--r-- | src/basic/mount-util.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index de12453c5..d04a49e2f 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -449,21 +449,21 @@ int bind_remount_recursive(const char *prefix, bool ro) { if (r < 0) return r; - /* Try to reuse the original flag set, but - * don't care for errors, in case of - * obstructed mounts */ + /* Deal with mount points that are obstructed by a + * later mount */ + r = path_is_mount_point(x, 0); + if (r == -ENOENT || r == 0) + continue; + if (r < 0) + return r; + + /* Try to reuse the original flag set */ orig_flags = 0; (void) get_mount_flags(x, &orig_flags); orig_flags &= ~MS_RDONLY; - if (mount(NULL, x, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0) { - - /* Deal with mount points that are - * obstructed by a later mount */ - - if (errno != ENOENT) - return -errno; - } + if (mount(NULL, x, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0) + return -errno; } } |