diff --git a/Cargo.lock b/Cargo.lock index 2c247e3bf..543684025 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,6 +147,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.9.4" @@ -165,6 +171,17 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" +[[package]] +name = "capctl" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6e71767585f51c2a33fed6d67147ec0343725fc3c03bf4b89fe67fede56aa5" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + [[package]] name = "cast" version = "0.3.0" @@ -415,6 +432,7 @@ version = "0.23.4" dependencies = [ "ansi-width", "backtrace", + "capctl", "chrono", "criterion", "dirs", @@ -518,7 +536,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110" dependencies = [ - "bitflags", + "bitflags 2.9.4", "libc", "libgit2-sys", "log", @@ -789,7 +807,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ - "bitflags", + "bitflags 2.9.4", "libc", "redox_syscall", ] @@ -1172,7 +1190,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags", + "bitflags 2.9.4", ] [[package]] @@ -1227,7 +1245,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags", + "bitflags 2.9.4", "errno", "libc", "linux-raw-sys", diff --git a/Cargo.toml b/Cargo.toml index 8962d78e1..3ff97222f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,6 +118,7 @@ default-features = false [target.'cfg(target_os = "linux")'.dependencies] proc-mounts = "0.3" +capctl = "0.2.4" [target.'cfg(unix)'.dependencies] uzers = "0.12.1" diff --git a/src/fs/feature/xattr.rs b/src/fs/feature/xattr.rs index d064d67d1..d3fa2323a 100644 --- a/src/fs/feature/xattr.rs +++ b/src/fs/feature/xattr.rs @@ -588,7 +588,13 @@ const ATTRIBUTE_DISPLAYS: &[AttributeDisplay] = &[ }, ]; -#[cfg(not(target_os = "macos"))] +#[cfg(target_os = "linux")] +const ATTRIBUTE_DISPLAYS: &[AttributeDisplay] = &[AttributeDisplay { + attribute: "security.capability", + display: display_capability, +}]; + +#[cfg(not(any(target_os = "linux", target_os = "macos")))] const ATTRIBUTE_DISPLAYS: &[AttributeDisplay] = &[]; // com.apple.lastuseddate is two 64-bit values representing the seconds and nano seconds @@ -665,6 +671,17 @@ fn display_macl(attribute: &Attribute) -> Option { }) } +// "security.capability" attribute represents capabilities in a binary format. +// See "capabilities(7)" +#[cfg(target_os = "linux")] +fn display_capability(attribute: &Attribute) -> Option { + attribute + .value + .as_ref() + .and_then(|v| capctl::FileCaps::unpack_attrs(v).ok()) + .map(|caps| format!("{caps}")) +} + // plist::XmlWriter takes the writer instead of borrowing it. This is a // wrapper around a borrowed vector that just forwards the Write trait // calls to the borrowed vector.