Compare commits

...

3 Commits
0.1.4 ... 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
Fabian Stamm
29a51767c8 Remove printlns 2024-08-18 13:21:54 +02:00
3 changed files with 42 additions and 7 deletions

2
Cargo.lock generated
View File

@ -31,7 +31,7 @@ checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a"
[[package]] [[package]]
name = "posix-acl" name = "posix-acl"
version = "0.1.4" version = "0.1.5"
dependencies = [ dependencies = [
"acl-sys", "acl-sys",
"anyhow", "anyhow",

View File

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

View File

@ -123,8 +123,6 @@ impl PosixACL {
return Err(anyhow!("Failed to get ACL entry")); return Err(anyhow!("Failed to get ACL entry"));
} }
println!("entry: {:?}", entry);
let mut tag_type: i32 = 0; let mut tag_type: i32 = 0;
check_return( check_return(
unsafe { acl_get_tag_type(entry, &mut tag_type) }, unsafe { acl_get_tag_type(entry, &mut tag_type) },
@ -167,7 +165,6 @@ impl PosixACL {
"acl_get_permset", "acl_get_permset",
); );
println!("permset: {:?}", permset);
let perm = if permset.is_null() { let perm = if permset.is_null() {
0 0
} else { } else {
@ -179,6 +176,46 @@ impl PosixACL {
entries.push(ACLEntry(qual, permset)); 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 }) Ok(PosixACL { entries })
} }
@ -305,7 +342,6 @@ impl<T> Drop for AclPtr<T> {
} }
pub(crate) fn check_return(ret: i32, func: &str) { pub(crate) fn check_return(ret: i32, func: &str) {
println!("ret: {} fnc: {}", ret, func);
assert_eq!( assert_eq!(
ret, ret,
0, 0,
@ -340,7 +376,6 @@ mod test {
let mut acl_r = PosixACL::new_from_file(path, false).unwrap(); let mut acl_r = PosixACL::new_from_file(path, false).unwrap();
acl_r.entries.sort(); acl_r.entries.sort();
println!("{:?}", acl);
assert_eq!(acl.entries.len(), acl_r.entries.len()); assert_eq!(acl.entries.len(), acl_r.entries.len());
let missing = acl let missing = acl
.entries .entries