From b197a7ed3cd9b5ae6aec7dfbea706bdf4ccfced7 Mon Sep 17 00:00:00 2001 From: Eytan Heidingsfeld <{ID}+{username}@users.noreply.github.com> Date: Tue, 26 Mar 2019 21:09:54 +0000 Subject: Fix issue where sgid is set and gid-offset is used --- src/bindfs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/bindfs.c') diff --git a/src/bindfs.c b/src/bindfs.c index baacb82..b5455f1 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -450,13 +450,18 @@ static int chown_new_file(const char *path, struct fuse_context *fc, int (*chown file_owner = usermap_get_uid_or_default(settings.usermap_reverse, fc->uid, file_owner); file_group = usermap_get_gid_or_default(settings.usermap_reverse, fc->gid, file_group); - if (!unapply_uid_offset(&file_owner)) { - return -UID_GID_OVERFLOW_ERRNO; - } - if (!unapply_gid_offset(&file_group)) { - return -UID_GID_OVERFLOW_ERRNO; + if (file_owner != (uid_t)-1) { + if (!unapply_uid_offset(&file_owner)) { + return -UID_GID_OVERFLOW_ERRNO; + } } + if (file_group != (gid_t)-1) { + if (!unapply_gid_offset(&file_group)) { + return -UID_GID_OVERFLOW_ERRNO; + } + } + if (settings.create_for_uid != -1) file_owner = settings.create_for_uid; if (settings.create_for_gid != -1) -- cgit v1.2.3