about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-11-28 03:14:45 +0100
committerGitHub <noreply@github.com>2024-11-28 03:14:45 +0100
commit10193a347ada2c6a01b8552e775baf2ecbd21fcc (patch)
tree5e1795a2c6023b0bbdf6a15d99c05e866712dcfd
parent66adeaf46b7a646daeed29518ef76235fcdb9726 (diff)
parent451c8cdb06b5d4033fe245ce19fdd9bfabd13f1f (diff)
downloadrust-10193a347ada2c6a01b8552e775baf2ecbd21fcc.tar.gz
rust-10193a347ada2c6a01b8552e775baf2ecbd21fcc.zip
Rollup merge of #129409 - grinapo:patch-1, r=Amanieu
Expand std::os::unix::fs::chown() doc with a warning

Include warning about losing setuid/gid when chowning, per POSIX.

It is about the underlying system call but it is rather useful to mention it in the help in case someone accidentally forgets (don't look at me :)).
-rw-r--r--library/std/src/os/unix/fs.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/os/unix/fs.rs b/library/std/src/os/unix/fs.rs
index ba6481f052c..04a45fd035a 100644
--- a/library/std/src/os/unix/fs.rs
+++ b/library/std/src/os/unix/fs.rs
@@ -987,6 +987,11 @@ impl DirBuilderExt for fs::DirBuilder {
 /// Changing the group typically requires either being the owner and a member of the group, or
 /// having privileges.
 ///
+/// Be aware that changing owner clears the `suid` and `sgid` permission bits in most cases
+/// according to POSIX, usually even if the user is root. The sgid is not cleared when
+/// the file is non-group-executable. See: <https://www.man7.org/linux/man-pages/man2/chown.2.html>
+/// This call may also clear file capabilities, if there was any.
+///
 /// If called on a symbolic link, this will change the owner and group of the link target. To
 /// change the owner and group of the link itself, see [`lchown`].
 ///