Compare commits

..

2 Commits
0.1.5 ... main

Author SHA1 Message Date
1ab23ae085 Cargo.toml aktualisiert 2024-11-19 06:55:43 +00:00
367678b804 src/lib.rs aktualisiert
Add required ACLs if they don't exist (default value mode, this should be changed!)
2024-11-19 06:54:49 +00:00
2 changed files with 41 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "posix-acl"
version = "0.1.5"
version = "0.1.6"
edition = "2021"
[dependencies]

View File

@ -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 })
}