use crate::{read_value, write_value, ProcResult};
pub fn gc_delay() -> ProcResult<u32> {
read_value("/proc/sys/kernel/keys/gc_delay")
}
pub fn persistent_keyring_expiry() -> ProcResult<u32> {
read_value("/proc/sys/kernel/keys/persistent_keyring_expiry")
}
pub fn maxbytes() -> ProcResult<u32> {
read_value("/proc/sys/kernel/keys/maxbytes")
}
pub fn set_maxbytes(bytes: u32) -> ProcResult<()> {
write_value("/proc/sys/kernel/keys/maxbytes", bytes)
}
pub fn maxkeys() -> ProcResult<u32> {
read_value("/proc/sys/kernel/keys/maxkeys")
}
pub fn set_maxkeys(keys: u32) -> ProcResult<()> {
write_value("/proc/sys/kernel/keys/maxkeys", keys)
}
pub fn root_maxbytes() -> ProcResult<u32> {
read_value("/proc/sys/kernel/keys/root_maxbytes")
}
pub fn set_root_maxbytes(bytes: u32) -> ProcResult<()> {
write_value("/proc/sys/kernel/keys/root_maxbytes", bytes)
}
pub fn root_maxkeys() -> ProcResult<u32> {
read_value("/proc/sys/kernel/keys/root_maxkeys")
}
pub fn set_root_maxkeys(keys: u32) -> ProcResult<()> {
write_value("/proc/sys/kernel/keys/root_maxkeys", keys)
}
#[cfg(test)]
mod tests {
use crate::{ProcError, ProcResult};
fn check_unwrap<T>(val: ProcResult<T>) {
match val {
Ok(_) => {}
Err(ProcError::NotFound(_)) => {
}
Err(e) => {
panic!("Unexpected proc error: {:?}", e);
}
}
}
#[test]
fn test_keys() {
check_unwrap(super::gc_delay());
check_unwrap(super::persistent_keyring_expiry());
check_unwrap(super::maxbytes());
check_unwrap(super::maxkeys());
check_unwrap(super::root_maxbytes());
check_unwrap(super::root_maxkeys());
}
}