From 08136d882670b56ec663cd6a090c52ffc3f6ad44 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 15 Aug 2019 21:51:22 +0200 Subject: [PATCH 1/2] main: if the path is a dir, work on the proc path when reading xattr, if the path cannot be open as it is a directory, operate on the /proc/fd/FD path. Closes: https://github.com/containers/fuse-overlayfs/issues/104 Signed-off-by: Giuseppe Scrivano --- main.c | 2 +- tests/fedora-installs.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index b93d023..d44049c 100644 --- a/main.c +++ b/main.c @@ -554,7 +554,7 @@ open_fd_or_get_path (struct ovl_data *lo, struct ovl_node *n, char *path, int *f path[0] = '\0'; *fd = TEMP_FAILURE_RETRY (openat (node_dirfd (n), n->path, O_NONBLOCK|O_NOFOLLOW|mode)); - if (*fd < 0 && errno == ELOOP) + if (*fd < 0 && (errno == ELOOP || errno == EISDIR)) { get_node_path (lo, n, path); return 0; diff --git a/tests/fedora-installs.sh b/tests/fedora-installs.sh index c917080..4ddfcbc 100755 --- a/tests/fedora-installs.sh +++ b/tests/fedora-installs.sh @@ -45,5 +45,11 @@ fuse-overlayfs -o fast_ino_check=1,sync=0,lowerdir=lower,upperdir=upper,workdir= docker run --rm -ti -v $(pwd)/merged:/merged centos:6 yum --installroot /merged -y --releasever 6 install nano +mkdir merged/a-directory + +setfattr -n user.foo -v bar merged/a-directory +getfattr -d merged/a-directory | grep bar +getfattr --only-values -n user.foo merged/a-directory | grep bar +getfattr --only-values -n user.foo upper/a-directory | grep bar umount merged From 9e110ad55cf29c22af3b5149cbe79de586587c86 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 15 Aug 2019 21:54:54 +0200 Subject: [PATCH 2/2] main, listxattr: open the file in read only mode Signed-off-by: Giuseppe Scrivano --- .travis.yml | 1 + main.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b176bcc..20cece6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ dist: xenial addons: apt: packages: + - attr - automake - autotools-dev - git diff --git a/main.c b/main.c index d44049c..6f49a62 100644 --- a/main.c +++ b/main.c @@ -2038,7 +2038,7 @@ ovl_listxattr (fuse_req_t req, fuse_ino_t ino, size_t size) } path[0] = '\0'; - ret = open_fd_or_get_path (lo, node, path, &fd, O_WRONLY); + ret = open_fd_or_get_path (lo, node, path, &fd, O_RDONLY); if (ret < 0) { fuse_reply_err (req, errno);