mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-11 00:09:03 -04:00
main, open: avoid a chown if it is not needed
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
0749dd7fb8
commit
a77edee351
9
main.c
9
main.c
@ -2837,6 +2837,8 @@ ovl_do_open (fuse_req_t req, fuse_ino_t parent, const char *name, int flags, mod
|
|||||||
cleanup_free char *path = NULL;
|
cleanup_free char *path = NULL;
|
||||||
cleanup_close int fd = -1;
|
cleanup_close int fd = -1;
|
||||||
const struct fuse_ctx *ctx = fuse_req_ctx (req);
|
const struct fuse_ctx *ctx = fuse_req_ctx (req);
|
||||||
|
uid_t uid;
|
||||||
|
gid_t gid;
|
||||||
|
|
||||||
flags |= O_NOFOLLOW;
|
flags |= O_NOFOLLOW;
|
||||||
|
|
||||||
@ -2898,11 +2900,16 @@ ovl_do_open (fuse_req_t req, fuse_ino_t parent, const char *name, int flags, mod
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (fchown (fd, get_uid (lo, ctx->uid), get_gid (lo, ctx->gid)) < 0)
|
uid = get_uid (lo, ctx->uid);
|
||||||
|
gid = get_gid (lo, ctx->gid);
|
||||||
|
if (uid != lo->uid || gid != lo->gid)
|
||||||
|
{
|
||||||
|
if (fchown (fd, uid, gid) < 0)
|
||||||
{
|
{
|
||||||
unlinkat (lo->workdir_fd, wd_tmp_file_name, 0);
|
unlinkat (lo->workdir_fd, wd_tmp_file_name, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = asprintf (&path, "%s/%s", p->path, name);
|
ret = asprintf (&path, "%s/%s", p->path, name);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user