Skip to content

cp -p preserves extended attributes #9704

@sylvestre

Description

@sylvestre

Component

cp

Description

uutils cp -p preserves extended attributes, but GNU cp -p does not. GNU only preserves mode, ownership, and timestamps with -p; xattrs require explicit --preserve=xattr or -a.

Test / Reproduction Steps

Not necessary.

pub const DEFAULT: Self = Self {
    #[cfg(unix)]
    ownership: Preserve::Yes { required: true },
    mode: Preserve::Yes { required: true },
    timestamps: Preserve::Yes { required: true },
    xattr: Preserve::Yes { required: true },  // <----

Impact

This breaks compatibility with scripts expecting GNU behavior and creates a security risk when run as root.

File capabilities and SELinux labels stored as xattrs get copied unintentionally. It also causes hard failures on filesystems that don't support xattrs, while GNU cp -p would succeed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions