diff options
author | Taylor Blau <me@ttaylorr.com> | 2022-11-09 01:14:49 +0300 |
---|---|---|
committer | Taylor Blau <me@ttaylorr.com> | 2022-11-09 01:14:49 +0300 |
commit | 06e76960253c01fd5c3b454e7500ef2be6c6b73a (patch) | |
tree | e75a060ee5874b6f67be295bc8b01bf44a89fb41 | |
parent | bdd42e34e3fdca79e20e30bcc03e99138e59c992 (diff) | |
parent | 671bbf7b9da70bad0307d616e7f6717a28300ffc (diff) |
Merge branch 'jc/set-gid-bit-less-aggressively'
The adjust_shared_perm() helper function learned to refrain from
setting the "g+s" bit on directories when it is not necessary.
* jc/set-gid-bit-less-aggressively:
adjust_shared_perm(): leave g+s alone when the group does not matter
-rw-r--r-- | path.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -901,7 +901,13 @@ int adjust_shared_perm(const char *path) if (S_ISDIR(old_mode)) { /* Copy read bits to execute bits */ new_mode |= (new_mode & 0444) >> 2; - new_mode |= FORCE_DIR_SET_GID; + + /* + * g+s matters only if any extra access is granted + * based on group membership. + */ + if (FORCE_DIR_SET_GID && (new_mode & 060)) + new_mode |= FORCE_DIR_SET_GID; } if (((old_mode ^ new_mode) & ~S_IFMT) && |