Skip to content
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

Documentation for PermissionsExt::set_mode should link to set_permissions #91707

Closed
0xpr03 opened this issue Dec 9, 2021 · 0 comments · Fixed by #136001
Closed

Documentation for PermissionsExt::set_mode should link to set_permissions #91707

0xpr03 opened this issue Dec 9, 2021 · 0 comments · Fixed by #136001
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools 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

@0xpr03
Copy link

0xpr03 commented Dec 9, 2021

I'm opening this issue because it took me far too much time to realize that set_mode isn't actually doing anything to the underlying file.
Based on the rust std docs I've first tried to set an executable bit with this code:

let file = std::fs::File::open(path)?;
let metadata = file.metadata()?;
let mut permissions = metadata.permissions();
permissions.set_mode(0o700);

I expected to see this happen: The code sets the permissions bit.

Instead, this happened: Obviously nothing, because you have to call std::fs::set_permissions

The docs for PermissionsExt::set_mode should link to std::fs::set_permissions so users know that set_mode doesn't actually perform anything on the file and instead something like this should be done:

fs::set_permissions(path, PermissionsExt::from_mode(0o700))?;

This may be relevant for more than only std::os::unix::fs::PermissionsExt.

Meta

rustc --version --verbose:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0
@0xpr03 0xpr03 added the C-bug Category: This is a bug. label Dec 9, 2021
@Dylan-DPC Dylan-DPC added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels May 4, 2023
hkBst added a commit to hkBst/rust that referenced this issue Jan 24, 2025
This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
hkBst added a commit to hkBst/rust that referenced this issue Jan 27, 2025
This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 14, 2025
Overhaul examples for PermissionsExt

This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
@bors bors closed this as completed in 0c10339 Mar 14, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 14, 2025
Rollup merge of rust-lang#136001 - hkBst:patch-21, r=cuviper

Overhaul examples for PermissionsExt

This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this issue Mar 19, 2025
This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this issue Mar 19, 2025
Overhaul examples for PermissionsExt

This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
tautschnig pushed a commit to model-checking/verify-rust-std that referenced this issue Mar 19, 2025
This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants