diff options
author | Jonathan Dieter <jdieter@lesbg.com> | 2012-09-14 10:51:59 +0300 |
---|---|---|
committer | Jonathan Dieter <jdieter@lesbg.com> | 2012-09-14 10:51:59 +0300 |
commit | 66f00111c4e886e244152e460ada62164c975d4d (patch) | |
tree | 1b1ebb9d61d4ac2f4f9ddce8651f12f9236605a3 | |
parent | f74ef968b07f99a8bbd4deccd932c5f3e62c77bd (diff) | |
download | bindfs-66f00111c4e886e244152e460ada62164c975d4d.tar.gz |
Respect setgid bit on directories when using --create-as-user
Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
-rw-r--r-- | src/bindfs.c | 12 |
1 files changed, 11 insertions, 1 deletions
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 <errno.h> #include <getopt.h> #include <assert.h> +#include <libgen.h> #include <pwd.h> #include <grp.h> #include <limits.h> @@ -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; |