From 2d8613e7f5f85afb9077f2d9e3eadb48249fedf1 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 30 Oct 2023 18:07:11 +0100 Subject: [PATCH 1/2] fuse-overlayfs: honor mode for devices with xattr_permissions Signed-off-by: Giuseppe Scrivano --- main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 93105ef..fb6f7e9 100644 --- a/main.c +++ b/main.c @@ -4914,6 +4914,7 @@ ovl_mknod (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, dev struct fuse_entry_param e; const struct fuse_ctx *ctx = fuse_req_ctx (req); char wd_tmp_file_name[32]; + mode_t backing_file_mode = mode | (lo->xattr_permissions ? 0755 : 0); if (UNLIKELY (ovl_debug (req))) fprintf (stderr, "ovl_mknod(ino=%" PRIu64 ", name=%s, mode=%d, rdev=%lu)\n", @@ -4927,9 +4928,6 @@ ovl_mknod (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, dev mode = mode & ~ctx->umask; - if (lo->xattr_permissions) - mode |= 0755; - node = do_lookup_file (lo, parent, name); if (node != NULL && ! node->whiteout) { @@ -4951,7 +4949,7 @@ ovl_mknod (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, dev return; } sprintf (wd_tmp_file_name, "%lu", get_next_wd_counter ()); - ret = mknodat (lo->workdir_fd, wd_tmp_file_name, mode, rdev); + ret = mknodat (lo->workdir_fd, wd_tmp_file_name, backing_file_mode, rdev); if (ret < 0) { fuse_reply_err (req, errno); From f73fd2db7ce3e0501cfb725f9c9c52bdef8b052c Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 30 Oct 2023 18:10:19 +0100 Subject: [PATCH 2/2] fuse-overlayfs: honor mode for dirs with xattr_permissions Signed-off-by: Giuseppe Scrivano --- main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index fb6f7e9..16f674a 100644 --- a/main.c +++ b/main.c @@ -2864,9 +2864,7 @@ create_directory (struct ovl_data *lo, int dirfd, const char *name, const struct cleanup_free char *buf = NULL; char wd_tmp_file_name[32]; bool need_rename; - - if (lo->xattr_permissions) - mode |= 0755; + mode_t backing_file_mode = mode | (lo->xattr_permissions ? 0755 : 0); need_rename = set_opaque || times || xattr_sfd >= 0 || uid != lo->uid || gid != lo->gid; if (! need_rename) @@ -2890,7 +2888,7 @@ create_directory (struct ovl_data *lo, int dirfd, const char *name, const struct sprintf (wd_tmp_file_name, "%lu", get_next_wd_counter ()); - ret = mkdirat (lo->workdir_fd, wd_tmp_file_name, mode); + ret = mkdirat (lo->workdir_fd, wd_tmp_file_name, backing_file_mode); if (ret < 0) goto out; @@ -5053,8 +5051,6 @@ ovl_mkdir (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode) fuse_reply_err (req, ENAMETOOLONG); return; } - if (lo->xattr_permissions) - mode |= 0755; node = do_lookup_file (lo, parent, name); if (node != NULL && ! node->whiteout)