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 <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2018-11-06 00:48:53 +01:00
parent 50c7a50240
commit a289a24acc
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

7
main.c
View File

@ -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)
{