mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-07 06:08:54 -04:00
main: Do not set -1 for owner overriding xattrs
ovl_setattr () used to pass -1 as uid or gid when either of them is not changed for do_fchown () / do_chown (), but if these functions use overriding xattrs instead of real fchown () or chown (), it causes -1 to be written in owner overriding xattrs and break them. Replace -1 with the current uid or gid before calling do_fchown () / do_chown (). Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
This commit is contained in:
parent
136aefd2f6
commit
9610adf7ab
18
main.c
18
main.c
@ -4158,6 +4158,24 @@ ovl_setattr (fuse_req_t req, fuse_ino_t ino, struct stat *attr, int to_set, stru
|
|||||||
|
|
||||||
if (uid != -1 || gid != -1)
|
if (uid != -1 || gid != -1)
|
||||||
{
|
{
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if (do_stat (node, fd, NULL, &st) < 0)
|
||||||
|
{
|
||||||
|
fuse_reply_err (req, errno);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uid == -1)
|
||||||
|
{
|
||||||
|
uid = st.st_uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gid == -1)
|
||||||
|
{
|
||||||
|
gid = st.st_gid;
|
||||||
|
}
|
||||||
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
ret = do_fchown (lo, fd, uid, gid, node->ino->mode);
|
ret = do_fchown (lo, fd, uid, gid, node->ino->mode);
|
||||||
else
|
else
|
||||||
|
@ -29,3 +29,21 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
fusermount -u merged || [ $? -eq "${EXPECT_UMOUNT_STATUS:-0}" ]
|
fusermount -u merged || [ $? -eq "${EXPECT_UMOUNT_STATUS:-0}" ]
|
||||||
|
|
||||||
|
# xattr_permissions=2
|
||||||
|
rm -rf lower upper workdir merged
|
||||||
|
mkdir lower upper workdir merged
|
||||||
|
|
||||||
|
touch upper/file
|
||||||
|
|
||||||
|
fuse-overlayfs -o lowerdir=lower,upperdir=upper,workdir=workdir,xattr_permissions=2 merged
|
||||||
|
|
||||||
|
# Ensure UID is preserved with chgrp.
|
||||||
|
podman unshare chgrp 1 merged/file
|
||||||
|
test $(podman unshare stat -c %u:%g merged/file) = 0:1
|
||||||
|
|
||||||
|
# Ensure UID and GID are preserved with chmod.
|
||||||
|
chmod 600 merged/file
|
||||||
|
test $(podman unshare stat -c %u:%g merged/file) = 0:1
|
||||||
|
|
||||||
|
fusermount -u merged || [ $? -eq "${EXPECT_UMOUNT_STATUS:-0}" ]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user