Skip to content

Commit 37c4a37

Browse files
committed
clarify std::fs::set_permissions symlink behavior
nest under platform-specific behavior, factor rationale into its own section, and tweak language.
1 parent 8808d5a commit 37c4a37

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

library/std/src/fs.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -2980,19 +2980,21 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
29802980
///
29812981
/// [changes]: io#platform-specific-behavior
29822982
///
2983-
/// # Symlinks
2984-
/// On UNIX systems, it is impossible to manipulate the permission bits of a symlink itself[^1].
2985-
/// Because of this, on those systems, this function will update the permission bits
2983+
/// ## Symlinks
2984+
/// On UNIX-like systems, this function will update the permission bits
29862985
/// of the file pointed to by the symlink.
29872986
///
29882987
/// Note that this behavior can lead to privalage escalation vulnerabilites,
2989-
/// where the ability to write a symlink in one directory allows you to
2990-
/// cause the permissions of another directory to be modified.
2988+
/// where the ability to create a symlink in one directory allows you to
2989+
/// cause the permissions of another file or directory to be modified.
29912990
///
29922991
/// For this reason, using this function with symlinks should be avoided.
29932992
/// When possible, permissions should be set at creation time instead.
29942993
///
2995-
/// [^1]: even if it were possible, the permissions on a symlink are ignored.
2994+
/// # Rationale
2995+
/// POSIX does not specify an `lchown` function,
2996+
/// and symlinks can be followed regardless of what permission bits are set.
2997+
///
29962998
/// # Errors
29972999
///
29983000
/// This function will return an error in the following situations, but is not

0 commit comments

Comments
 (0)