MCPcopy Create free account
hub / github.com/bootc-dev/bootc / load_usernames

Function load_usernames

crates/lib/src/sysusers_cleanup.rs:30–42  ·  view source on GitHub ↗

Load usernames from a passwd-format file at `path` within `root`, returning an empty set if the file doesn't exist.

(root: &Dir, path: &str)

Source from the content-addressed store, hash-verified

28/// Load usernames from a passwd-format file at `path` within `root`, returning
29/// an empty set if the file doesn't exist.
30fn load_usernames(root: &Dir, path: &str) -> Result<HashSet<String>> {
31 use bootc_sysusers::nameservice::passwd::parse_passwd_content;
32 let mut names = HashSet::new();
33 if let Some(f) = root
34 .open_optional(path)
35 .with_context(|| format!("Opening {path}"))?
36 {
37 let entries = parse_passwd_content(std::io::BufReader::new(f))
38 .with_context(|| format!("Parsing {path}"))?;
39 names.extend(entries.into_iter().map(|e| e.name));
40 }
41 Ok(names)
42}
43
44/// Load group names from a group-format file at `path` within `root`, returning
45/// an empty set if the file doesn't exist.

Callers 1

runFunction · 0.85

Calls 3

parse_passwd_contentFunction · 0.85
extendMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected