MCPcopy Create free account
hub / github.com/foxcpp/maddy / Read

Function Read

internal/auth/shadow/read.go:36–56  ·  view source on GitHub ↗

Read reads system shadow passwords database and returns all entires in it.

()

Source from the content-addressed store, hash-verified

34
35// Read reads system shadow passwords database and returns all entires in it.
36func Read() ([]Entry, error) {
37 f, err := os.Open("/etc/shadow")
38 if err != nil {
39 return nil, err
40 }
41 scnr := bufio.NewScanner(f)
42
43 var res []Entry
44 for scnr.Scan() {
45 ent, err := parseEntry(scnr.Text())
46 if err != nil {
47 return res, err
48 }
49
50 res = append(res, *ent)
51 }
52 if err := scnr.Err(); err != nil {
53 return res, err
54 }
55 return res, nil
56}
57
58func parseEntry(line string) (*Entry, error) {
59 parts := strings.Split(line, ":")

Callers 1

LookupFunction · 0.70

Calls 3

parseEntryFunction · 0.85
ErrMethod · 0.80
OpenMethod · 0.65

Tested by

no test coverage detected