Added implementation on set_permissions_nofollow for all primary platforms#158168
Added implementation on set_permissions_nofollow for all primary platforms#158168asder8215 wants to merge 1 commit into
set_permissions_nofollow for all primary platforms#158168Conversation
|
r? @clarfonthey rustbot has assigned @clarfonthey. Use Why was this reviewer chosen?The reviewer was selected based on:
|
3411717 to
96bc9a1
Compare
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| pub fn set_perm_nofollow(path: &Path, perm: FilePermissions) -> io::Result<()> { | ||
| set_perm(path, perm) |
There was a problem hiding this comment.
Similar to UEFI, I would swap the method bodies here, so that set_perm defers to set_perm_nofollow plus a comment that says symlinks aren't supported.
|
@rustbot author CI failure appears to be a simple typo but I also left some feedback on other stuff to fix. Otherwise, implementation looks good, although I would add an extra comment on the tracking issue once this is merged to have some Windows folks double-check that opening all reparse points in this method doesn't do anything we don't want, since that technically includes more than just symlinks. It should work in pretty much all normal use cases, just want to double-check the edge cases before stabilisation. |
|
Reminder, once the PR becomes ready for a review, use |
96bc9a1 to
f9c87ed
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
f9c87ed to
feafe24
Compare
This comment has been minimized.
This comment has been minimized.
…pported (windows, unix, uefi, etc.); modified the Unix implementation to use fchmodat instead of open + fchmod; clarified documentations for set_permissions_nofollow; added a test case for set_permissions_nofollow
feafe24 to
b286acf
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
View all comments
For context, this PR is related to the tracking issue for
std::fs::set_permissions_nofollow. This PR does a few different things:std::fs::set_permissions_nofollow. On Windows, it usesOpenOptions::openwith the custom flagFILE_FLAG_OPEN_REPARSE_POINTenabled and then sets the permissions on the reparse point directly. All other platforms (hermit, motor, solid, uefi, etc.) defer to whatfs::set_permissionsdoes since symlinks aren't supported on those platforms, so they effectively do the same thing.fchmodatinstead of doing two separate calls (openand thenfchmodviaOpenOptions).fchmodinstead ofchmodunderneath the hood (as that's whatFile::set_permissions, which is not to be confused withfs::set_permissionsas that does usechmod, does underneath the hood), it actually had some incorrect documentation about the error returned byfchmodon symlinks. Instead ofio::ErrorKind::FilesystemLoop, it returnsio::ErrorKind::InvalidInput. You can read the documentation forfchmod.fchmodatdoes effectively the same thing as theopen+fchmodcombo, but it does return a different error,io::ErrorKind::Unsupported, that makes more sense. Regardless, I corrected the documentation forstd::fs::set_permissions_nofollowand added a lot more clarifying information.set_permissions_nofollowis operating correctly.cc @ChrisDenton and @lolbinarycat