From a289a24accc39d8b5dd9be6caf336ded6298f345 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 6 Nov 2018 00:48:53 +0100 Subject: [PATCH] fuse-overlayfs: read correctly inode for dangling symlinks do not follow symlinks when stat'ing a path, so that we read the inode of the symlink itself. Closes: https://github.com/containers/fuse-overlayfs/issues/23 Signed-off-by: Giuseppe Scrivano --- main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 5cdf566..38a5602 100644 --- a/main.c +++ b/main.c @@ -765,13 +765,18 @@ make_ovl_node (const char *path, struct ovl_layer *layer, const char *name, ino_ for (it = layer; it; it = it->next) { ssize_t s; - int fd = TEMP_FAILURE_RETRY (openat (it->fd, path, O_RDONLY|O_NONBLOCK)); + int fd = TEMP_FAILURE_RETRY (openat (it->fd, path, O_RDONLY|O_NONBLOCK|O_NOFOLLOW|O_PATH)); if (fd < 0) continue; if (fstat (fd, &st) == 0) ret->ino = st.st_ino; + close (fd); + + fd = TEMP_FAILURE_RETRY (openat (it->fd, path, O_RDONLY|O_NONBLOCK|O_NOFOLLOW)); + if (fd < 0) + continue; s = fgetxattr (fd, PRIVILEGED_ORIGIN_XATTR, path, sizeof (path) - 1); if (s > 0) {