Skip to content

[Compatibility BUG] install calls chown() if it thinks it is running as root, when GNU coreutils did not. Breaks builds. #9116

@original-birdman

Description

@original-birdman

If I run the command:

install -d -m 755 /some/directory/to/create

then I just expect a directory to be created. Whether I run it as root or as myself.
This is what GNU install does.

However, Rust install does something different, but only when run by root (or rather, when it thinks the effective uid is root)
Having created the directory it chowns it to 0:0.
This breaks code running under pseudo (such as OpenEmbedded Yocto builds).

The culprit is likely to be chown_optional_user_group(), which hasd this code:

    // 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.
        return Ok(());
    };

That "Special case for root user" looks more like "Screw-up for root user"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions