Skip to content

Commit 890f350

Browse files
committed
cp: remove feat_acl & replace exacl by xattr
1 parent 197eac4 commit 890f350

4 files changed

Lines changed: 10 additions & 35 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ feat_systemd_logind = [
7474
"uucore/feat_systemd_logind",
7575
"who/feat_systemd_logind",
7676
]
77-
# "feat_acl" == enable support for ACLs (access control lists; by using`--features feat_acl`)
78-
# NOTE:
79-
# * On linux, the posix-acl/acl-sys crate requires `libacl` headers and shared library to be accessible in the C toolchain at compile time.
80-
# * On FreeBSD and macOS this is not required.
81-
feat_acl = ["cp/feat_acl"]
8277
# "feat_selinux" == enable support for SELinux Security Context (by using `--features feat_selinux`)
8378
# NOTE:
8479
# * The selinux(-sys) crate requires `libselinux` headers and shared library to be accessible in the C toolchain at compile time.

src/uu/cp/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ rustix = { workspace = true }
4444
selinux = { workspace = true, optional = true }
4545

4646
[target.'cfg(unix)'.dependencies]
47-
exacl = { workspace = true, optional = true }
4847
nix = { workspace = true, features = ["fs"] }
48+
xattr = { workspace = true }
4949

5050
[target.'cfg(target_os = "windows")'.dependencies]
5151
windows-sys = { workspace = true, features = [
@@ -68,4 +68,3 @@ harness = false
6868

6969
[features]
7070
feat_selinux = ["selinux", "uucore/selinux"]
71-
feat_acl = ["exacl"]

src/uu/cp/src/cp.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,11 +1883,14 @@ pub(crate) fn copy_attributes(
18831883

18841884
fs::set_permissions(dest, source_perms)
18851885
.map_err(|e| CpError::IoErrContext(e, context.to_owned()))?;
1886-
// FIXME: Implement this for windows as well
1887-
#[cfg(feature = "feat_acl")]
1888-
exacl::getfacl(source, None)
1889-
.and_then(|acl| exacl::setfacl(&[dest], &acl, None))
1890-
.map_err(|err| CpError::Error(err.to_string()))?;
1886+
#[cfg(any(target_os = "freebsd", target_os = "linux", target_vendor = "apple"))]
1887+
// exacl supports them at least for. todo: support acl for other targets
1888+
if let Some(acl) = xattr::get(source, "system.posix_acl_access")
1889+
.map_err(|e| CpError::Error(e.to_string()))?
1890+
{
1891+
xattr::set(dest, "system.posix_acl_access", &acl)
1892+
.map_err(|e| CpError::Error(e.to_string()))?;
1893+
}
18911894
// GNU `cp -p` preserves POSIX ACLs as part of mode. On Linux the
18921895
// ACLs are stored as `system.posix_acl_*` xattrs; copy just those
18931896
// so we keep ACL parity with GNU without preserving user xattrs

0 commit comments

Comments
 (0)