Parses a textual ACL specification and adds it to `add` or `remove.
(mut acl: String, add: &mut FileAcls, remove: &mut FileAcls)
| 307 | impl ShareCommand { |
| 308 | /// Parses a textual ACL specification and adds it to `add` or `remove. |
| 309 | fn parse_acl(mut acl: String, add: &mut FileAcls, remove: &mut FileAcls) -> Result<(), String> { |
| 310 | let change = if acl.len() < 3 { String::new() } else { acl.split_off(acl.len() - 2) }; |
| 311 | let username = acl; // For clarity after splitting off the ACL change request. |
| 312 | match (username, change.as_str()) { |
| 313 | (username, "+r") if !username.is_empty() => add.add_reader(username), |
| 314 | (username, "+R") if !username.is_empty() => add.add_reader(username), |
| 315 | (username, "-r") if !username.is_empty() => remove.add_reader(username), |
| 316 | (username, "-R") if !username.is_empty() => remove.add_reader(username), |
| 317 | (username, change) => { |
| 318 | return Err(format!( |
| 319 | "Invalid ACL '{}{}': must be of the form \"username+r\" or \"username-r\"", |
| 320 | username, change |
| 321 | )); |
| 322 | } |
| 323 | } |
| 324 | Ok(()) |
| 325 | } |
| 326 | |
| 327 | /// Checks if a file is publicly readable by inspecting a set of ACLs. |
| 328 | fn has_public_acl(acls: &FileAcls) -> bool { |
nothing calls this directly
no test coverage detected