Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 18 additions & 1 deletion src/fs/feature/xattr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -665,6 +671,17 @@ fn display_macl(attribute: &Attribute) -> Option<String> {
})
}

// "security.capability" attribute represents capabilities in a binary format.
// See "capabilities(7)"
#[cfg(target_os = "linux")]
fn display_capability(attribute: &Attribute) -> Option<String> {
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.
Expand Down
Loading