-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standard library masks away bits in permissions struct #44147
Labels
C-bug
Category: This is a bug.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Comments
I guess the solution depends on whether Unix's std::fs::Permissions is supposed to care about 9 bits or 12 (this is not an implementation detail since it's exposed to the programmer via |
It seems to me like we should extend the mask to the full 12 bits. |
Seems reasonable to me to avoid masking where it makes sense! |
tmerr
added a commit
to tmerr/rust
that referenced
this issue
Sep 16, 2017
Most users would expect set_permissions(Metadata.permissions()) to be non-destructive. While we can't guarantee this, we can at least pass the needed info to chmod. Also update the PermissionsExt documentation to disambiguate what it contains, and to refer to the underlying value as `st_mode` rather than its type `mode_t`. Closes rust-lang#44147
bors
added a commit
that referenced
this issue
Sep 22, 2017
Retain suid/sgid/sticky bits in Metadata.permissions Most users would expect set_permissions(Metadata.permissions()) to be non-destructive. While we can't guarantee this, we can at least pass the needed info to chmod. Also update the PermissionsExt documentation to disambiguate what it contains, and to refer to the underlying value as `st_mode` rather than its type `mode_t`. Closes #44147
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: This is a bug.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Behavior
On linux,
mkdir mydir
,chmod 2777 mydir
then run:This changes the permissions of
mydir
to777
. Is this expected?The cause
Metadata.permissions()
masks away everything other than the lower 3 triads when it calls out to this code:rust/src/libstd/sys/unix/fs.rs
Lines 95 to 97 in d2d5069
Then
std::fs::set_permissions
sends these mode bits into into chmod which considers four triads, not three. Possibly useful references: chmod and mode_tShould we change Metadata.permissions to preserve that triad, maybe by masking with
0o7777
instead of0o777
?The text was updated successfully, but these errors were encountered: