Minor refactoring of pxars xattr encoder/decoder, mostly reformatting and renaming.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner
2019-05-23 11:58:40 +02:00
committed by Dietmar Maurer
parent c05a8c8d18
commit 357e4614e2
3 changed files with 44 additions and 38 deletions

View File

@ -92,17 +92,20 @@ pub fn fsetxattr_fcaps(fd: RawFd, fcaps: CaFormatFCaps) -> Result<(), nix::errno
Ok(())
}
pub fn security_capability(name: &[u8]) -> bool {
pub fn is_security_capability(name: &[u8]) -> bool {
name == b"security.capability"
}
pub fn name_store(name: &[u8]) -> bool {
if name.is_empty() { return false; }
if name.starts_with(b"user.") { return true; }
if name.starts_with(b"trusted.") { return true; }
if security_capability(name) { return true; }
false
/// Check if the passed name buffer starts with a valid xattr namespace prefix
/// and is within the length limit of 255 bytes
pub fn is_valid_xattr_name(name: &[u8]) -> bool {
if name.is_empty() || name.len() > 255 {
return false;
}
if name.starts_with(b"user.") || name.starts_with(b"trusted.") {
return true;
}
is_security_capability(name)
}
#[cfg(test)]