Struct linux_keyutils::KeyPermissions
source · pub struct KeyPermissions(_);
Expand description
Construct key permissions for use with Key::set_perms or returned by Metadata::get_perms.
Usage:
use linux_keyutils::{Permission, KeyPermissions};
let mut perms = KeyPermissions::new();
perms.set_user_perms(Permission::ALL);
perms.set_group_perms(Permission::VIEW);
Implementations§
source§impl KeyPermissions
impl KeyPermissions
sourcepub fn from_u32(raw: u32) -> Self
pub fn from_u32(raw: u32) -> Self
Construct the permissions manually
Examples found in repository?
src/metadata.rs (line 67)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
fn from_str(s: &str) -> Result<Self, Self::Err> {
// Begin parsing
let mut iter = s.split(';');
// Parse type into KeyType
let ktype: KeyType = iter
.next()
.and_then(|v| v.try_into().ok())
.ok_or(KeyError::InvalidDescription)?;
// Parse the UID
let uid = iter
.next()
.and_then(|v| v.parse().ok())
.ok_or(KeyError::InvalidDescription)?;
// Parse the GID
let gid = iter
.next()
.and_then(|v| v.parse().ok())
.ok_or(KeyError::InvalidDescription)?;
// Parse the permissions
let perms: u32 = iter
.next()
.and_then(|v| u32::from_str_radix(v, 16).ok())
.ok_or(KeyError::InvalidDescription)?;
// Copy the actual description
let description = iter.next().ok_or(KeyError::InvalidDescription)?.to_string();
// Create the description
Ok(Self {
ktype,
uid,
gid,
perm: KeyPermissions::from_u32(perms),
description,
})
}
sourcepub fn set_posessor_perms(&mut self, perm: Permission)
pub fn set_posessor_perms(&mut self, perm: Permission)
Set the permissions available to the key’s possessor
sourcepub fn set_user_perms(&mut self, perm: Permission)
pub fn set_user_perms(&mut self, perm: Permission)
Set the permissions available to the key’s owning user (UID)
sourcepub fn set_group_perms(&mut self, perm: Permission)
pub fn set_group_perms(&mut self, perm: Permission)
Set the permissions available to the key’s owning group (GID)
sourcepub fn set_world_perms(&mut self, perm: Permission)
pub fn set_world_perms(&mut self, perm: Permission)
Set the permissions available to any 3rd party
Trait Implementations§
source§impl Clone for KeyPermissions
impl Clone for KeyPermissions
source§fn clone(&self) -> KeyPermissions
fn clone(&self) -> KeyPermissions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more