From 66f00111c4e886e244152e460ada62164c975d4d Mon Sep 17 00:00:00 2001 From: Jonathan Dieter Date: Fri, 14 Sep 2012 10:51:59 +0300 Subject: Respect setgid bit on directories when using --create-as-user Signed-off-by: Jonathan Dieter --- src/bindfs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/bindfs.c') diff --git a/src/bindfs.c b/src/bindfs.c index 34067eb..754bc0e 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -294,10 +295,19 @@ static void chown_new_file(const char *path, struct fuse_context *fc, int (*chow { uid_t file_owner; gid_t file_group; - + if (settings.create_policy == CREATE_AS_USER) { + char *path_copy, *dir_path; + struct stat stbuf; + file_owner = fc->uid; file_group = fc->gid; + + path_copy = strdup(path); + dir_path = dirname(path_copy); + if (lstat(dir_path, &stbuf) != -1 && stbuf.st_mode & S_ISGID) + file_group = -1; + free(path_copy); } else { file_owner = -1; file_group = -1; -- cgit v1.2.3