Skip to content

Commit a9ecd0f

Browse files
authored
Expand std::os::unix::fs::chown() doc with a warning
Include warning about losing setuid/gid when chowning, per POSIX.
1 parent 8269be1 commit a9ecd0f

File tree

1 file changed

+4
-0
lines changed
  • library/std/src/os/unix

1 file changed

+4
-0
lines changed

library/std/src/os/unix/fs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,10 @@ impl DirBuilderExt for fs::DirBuilder {
985985
/// Changing the owner typically requires privileges, such as root or a specific capability.
986986
/// Changing the group typically requires either being the owner and a member of the group, or
987987
/// having privileges.
988+
///
989+
/// Be aware that changing owner clears the `suid` and `sgid` permission bits in most cases
990+
/// according to POSIX, usually even if the user is root. The sgid is not cleared when
991+
/// the file is non-group-executable.
988992
///
989993
/// If called on a symbolic link, this will change the owner and group of the link target. To
990994
/// change the owner and group of the link itself, see [`lchown`].

0 commit comments

Comments
 (0)