diff options
| author | Marti Raudsepp <marti@juffo.org> | 2024-09-13 01:14:22 +0300 |
|---|---|---|
| committer | Marti Raudsepp <marti@juffo.org> | 2024-12-22 20:47:41 +0200 |
| commit | edfdfbe832db3495b242a31c405cdb0d77bd45d3 (patch) | |
| tree | e5c464781c59252dc1d9de9bbe70843a038c7f09 | |
| parent | b22856d192567a55a1d2788fbc3084e3f9cb220f (diff) | |
| download | rust-edfdfbe832db3495b242a31c405cdb0d77bd45d3.tar.gz rust-edfdfbe832db3495b242a31c405cdb0d77bd45d3.zip | |
docs: Permissions.readonly() also ignores root user special permissions
The root user can write to files without any (write) access bits set. But this is not taken into account by `std::fs::Permissions.readonly()`.
| -rw-r--r-- | library/std/src/fs.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 0178691c0e5..9b752ed1443 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1869,8 +1869,10 @@ impl Permissions { /// /// # Note /// - /// This function does not take Access Control Lists (ACLs) or Unix group - /// membership into account. + /// This function does not take Access Control Lists (ACLs), Unix group + /// membership and other nuances into account. + /// Therefore the return value of this function cannot be relied upon + /// to predict whether attempts to read or write the file will actually succeed. /// /// # Windows /// @@ -1885,10 +1887,13 @@ impl Permissions { /// # Unix (including macOS) /// /// On Unix-based platforms this checks if *any* of the owner, group or others - /// write permission bits are set. It does not check if the current - /// user is in the file's assigned group. It also does not check ACLs. - /// Therefore the return value of this function cannot be relied upon - /// to predict whether attempts to read or write the file will actually succeed. + /// write permission bits are set. It does not consider anything else, including: + /// + /// * Whether the current user is in the file's assigned group. + /// * Permissions granted by ACL. + /// * That `root` user can write to files that do not have any write bits set. + /// * Writable files on a filesystem that is mounted read-only. + /// /// The [`PermissionsExt`] trait gives direct access to the permission bits but /// also does not read ACLs. /// |
