src/tools/xattr.rs: add functions name_store and security_capability

These functions allow to check if the name for xattrs/fcaps are valid.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-05-17 14:23:33 +02:00 committed by Dietmar Maurer
parent a09c0e38d8
commit bee8d8ea78
1 changed files with 12 additions and 0 deletions

View File

@ -91,3 +91,15 @@ pub fn fsetxattr_fcaps(fd: RawFd, fcaps: CaFormatFCaps) -> Result<(), nix::errno
Ok(()) Ok(())
} }
pub fn 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
}