mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
Merge pull request #9477 from Ecordonnier/eco/fix-install-as-root
install: do not call chown when called as root
This commit is contained in:
commit
443c2014fb
1 changed files with 2 additions and 6 deletions
|
|
@ -711,10 +711,9 @@ fn copy_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Handle incomplete user/group parings for chown.
|
||||
/// Handle ownership changes when -o/--owner or -g/--group flags are used.
|
||||
///
|
||||
/// Returns a Result type with the Err variant containing the error message.
|
||||
/// If the user is root, revert the uid & gid
|
||||
///
|
||||
/// # Parameters
|
||||
///
|
||||
|
|
@ -735,11 +734,8 @@ fn chown_optional_user_group(path: &Path, b: &Behavior) -> UResult<()> {
|
|||
// Determine the owner and group IDs to be used for chown.
|
||||
let (owner_id, group_id) = if b.owner_id.is_some() || b.group_id.is_some() {
|
||||
(b.owner_id, b.group_id)
|
||||
} else if geteuid() == 0 {
|
||||
// Special case for root user.
|
||||
(Some(0), Some(0))
|
||||
} else {
|
||||
// No chown operation needed.
|
||||
// No chown operation needed - file ownership comes from process naturally.
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue