Skip to content

Commit c439543

Browse files
authored
Rollup merge of rust-lang#139546 - lolbinarycat:std-set_permissions-75942, r=thomcc
std(docs): clarify how std::fs::set_permisions works with symlinks fixes rust-lang#75942 fixes rust-lang#124201
2 parents 8ee9029 + 37c4a37 commit c439543

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

library/std/src/fs.rs

+15
Original file line numberDiff line numberDiff line change
@@ -2980,6 +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-like systems, this function will update the permission bits
2985+
/// of the file pointed to by the symlink.
2986+
///
2987+
/// Note that this behavior can lead to privalage escalation vulnerabilites,
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.
2990+
///
2991+
/// For this reason, using this function with symlinks should be avoided.
2992+
/// When possible, permissions should be set at creation time instead.
2993+
///
2994+
/// # Rationale
2995+
/// POSIX does not specify an `lchown` function,
2996+
/// and symlinks can be followed regardless of what permission bits are set.
2997+
///
29832998
/// # Errors
29842999
///
29853000
/// This function will return an error in the following situations, but is not

0 commit comments

Comments
 (0)