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:
parent
a09c0e38d8
commit
bee8d8ea78
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue