Add mode::Parser and constructors
This commit is contained in:
parent
68a4c08fe9
commit
c727a1b6f8
@ -1,5 +1,11 @@
|
||||
//! Functions for parsing and managing permissions
|
||||
|
||||
pub fn get_umask() -> u32 {
|
||||
let mask = unsafe { libc::umask(0) };
|
||||
let umask = unsafe {libc::umask(mask) };
|
||||
umask
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Bits {
|
||||
Suid = 0o4000,
|
||||
@ -33,6 +39,29 @@ pub enum Who {
|
||||
|
||||
pub struct Parser {
|
||||
mode: u32,
|
||||
op: Op,
|
||||
who: Who,
|
||||
op: Option<Op>,
|
||||
who: Option<Who>,
|
||||
}
|
||||
|
||||
impl Default for Parser {
|
||||
fn default() -> Self {
|
||||
let umask = get_umask();
|
||||
let mut mode = 0o0777;
|
||||
mode &= umask;
|
||||
Self {
|
||||
mode,
|
||||
op: None,
|
||||
who: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parser {
|
||||
fn new(mode: u32) -> Self {
|
||||
Self {
|
||||
mode,
|
||||
op: None,
|
||||
who: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user