strip setuid/setgid/sticky bits when restoring archived modes#410
Merged
Conversation
Contributor
Author
|
good catch. mingw and msvc dont define S_ISUID/S_ISGID/S_ISVTX, so both the mask in zip.c and the new test failed to compile.
local build + test_permissions pass. |
kuba--
approved these changes
Jun 14, 2026
Comment on lines
+68
to
+78
| /* setuid/setgid/sticky bits are not defined on every toolchain (e.g. MinGW) */ | ||
| #ifndef S_ISUID | ||
| #define S_ISUID 04000 | ||
| #endif | ||
| #ifndef S_ISGID | ||
| #define S_ISGID 02000 | ||
| #endif | ||
| #ifndef S_ISVTX | ||
| #define S_ISVTX 01000 | ||
| #endif | ||
|
|
Owner
There was a problem hiding this comment.
I would get rid of this.
Because (04000 | 02000 | 01000 = 07000) and just:
xattr &= ~(mz_uint32)07000;
...or you can define on the top sth. like:
#define ZIP_SETID_MASK 07000
Contributor
Author
There was a problem hiding this comment.
done. dropped the #ifndef block and added a single ZIP_SETID_MASK 07000, used at both chmod sites. no more dependency on S_ISUID/S_ISGID being defined, so the windows build is fine. test_permissions still passes.
kuba--
approved these changes
Jun 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
extract applies the archived unix mode as-is, so an archive can restore setuid/setgid on a file it owns:
masked setuid/setgid/sticky before chmod at both sites; ordinary perms still round-trip. added a regression test under test_permissions.