diff options
author | Wayne Davison <wayned@samba.org> | 2007-09-15 19:58:15 +0000 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2007-09-15 19:58:15 +0000 |
commit | 2dc7b91dd240db5de85d0f9e189d7293db19cae0 (patch) | |
tree | c2915211b68949818b7effc3b0ccda759e943d4b /rsync.c | |
parent | 288b12eefe6c342551c0c1c5da93ac5bbbd0fed2 (diff) | |
download | rsync-2dc7b91dd240db5de85d0f9e189d7293db19cae0.tar.gz |
Handle inheritance of SGID bit on dirs marked with FLAG_DIR_CREATED.
Diffstat (limited to 'rsync.c')
-rw-r--r-- | rsync.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -274,6 +274,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, statx *sxp, statx sx2; int change_uid, change_gid; mode_t new_mode = file->mode; + int inherit; if (!sxp) { if (dry_run) @@ -289,13 +290,15 @@ int set_file_attrs(const char *fname, struct file_struct *file, statx *sxp, #ifdef SUPPORT_XATTRS sx2.xattr = NULL; #endif - if (!preserve_perms && S_ISDIR(new_mode) - && sx2.st.st_mode & S_ISGID) { - /* We just created this directory and its setgid - * bit is on, so make sure it stays on. */ - new_mode |= S_ISGID; - } sxp = &sx2; + inherit = !preserve_perms; + } else + inherit = !preserve_perms && file->flags & FLAG_DIR_CREATED; + + if (inherit && S_ISDIR(new_mode) && sxp->st.st_mode & S_ISGID) { + /* We just created this directory and its setgid + * bit is on, so make sure it stays on. */ + new_mode |= S_ISGID; } #ifdef SUPPORT_ACLS |