Skip to content

Commit 68ed52e

Browse files
committed
install: do not call chown when called as root
- GNU coreutils does not do that - this `chown` call does not work when running with `pseudo` - this behavior was added in #5735 to make the test `install-C-root.sh` pass Fixes #9116 Signed-off-by: Etienne Cordonnier <[email protected]>
1 parent 876ac06 commit 68ed52e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/uu/install/src/install.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,9 @@ fn copy_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR
711711
Ok(())
712712
}
713713

714-
/// Handle incomplete user/group parings for chown.
714+
/// Handle ownership changes when -o/--owner or -g/--group flags are used.
715715
///
716716
/// Returns a Result type with the Err variant containing the error message.
717-
/// If the user is root, revert the uid & gid
718717
///
719718
/// # Parameters
720719
///
@@ -735,11 +734,8 @@ fn chown_optional_user_group(path: &Path, b: &Behavior) -> UResult<()> {
735734
// Determine the owner and group IDs to be used for chown.
736735
let (owner_id, group_id) = if b.owner_id.is_some() || b.group_id.is_some() {
737736
(b.owner_id, b.group_id)
738-
} else if geteuid() == 0 {
739-
// Special case for root user.
740-
(Some(0), Some(0))
741737
} else {
742-
// No chown operation needed.
738+
// No chown operation needed - file ownership comes from process naturally.
743739
return Ok(());
744740
};
745741

0 commit comments

Comments
 (0)