src/lib.rs aktualisiert
Add required ACLs if they don't exist (default value mode, this should be changed!)
This commit is contained in:
parent
29a51767c8
commit
367678b804
40
src/lib.rs
40
src/lib.rs
@ -176,6 +176,46 @@ impl PosixACL {
|
||||
entries.push(ACLEntry(qual, permset));
|
||||
}
|
||||
|
||||
// There should be at leas a UserObj, GroupObj, Other and Mask on the non default ACL entries. If they dont exist, create them
|
||||
|
||||
if !default {
|
||||
let mut found_user = false;
|
||||
let mut found_group = false;
|
||||
let mut found_other = false;
|
||||
let mut found_mask: Option<PermSet> = None;
|
||||
|
||||
for ent in entries.iter() {
|
||||
match ent.0 {
|
||||
Qualifier::UserObj => {
|
||||
found_user = true;
|
||||
}
|
||||
Qualifier::GroupObj => {
|
||||
found_group = true;
|
||||
}
|
||||
Qualifier::Other => {
|
||||
found_other = true;
|
||||
}
|
||||
Qualifier::Mask => found_mask = Some(ent.1),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
let def_perm = found_mask.unwrap_or(ACL_RWX);
|
||||
|
||||
if !found_user {
|
||||
entries.push(ACLEntry(Qualifier::UserObj, def_perm.clone()));
|
||||
}
|
||||
if !found_group {
|
||||
entries.push(ACLEntry(Qualifier::GroupObj, def_perm.clone()));
|
||||
}
|
||||
if !found_other {
|
||||
entries.push(ACLEntry(Qualifier::Other, def_perm.clone()));
|
||||
}
|
||||
if found_mask.is_none() {
|
||||
entries.push(ACLEntry(Qualifier::Mask, def_perm.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(PosixACL { entries })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user