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

Function parseEntry

internal/auth/shadow/read.go:58–85  ·  view source on GitHub ↗
(line string)

Source from the content-addressed store, hash-verified

56}
57
58func parseEntry(line string) (*Entry, error) {
59 parts := strings.Split(line, ":")
60 if len(parts) != 9 {
61 return nil, errors.New("read: malformed entry")
62 }
63
64 res := &Entry{
65 Name: parts[0],
66 Pass: parts[1],
67 }
68
69 for i, value := range [...]*int{
70 &res.LastChange, &res.MinPassAge, &res.MaxPassAge,
71 &res.WarnPeriod, &res.InactivityPeriod, &res.AcctExpiry, &res.Flags,
72 } {
73 if parts[2+i] == "" {
74 *value = -1
75 } else {
76 var err error
77 *value, err = strconv.Atoi(parts[2+i])
78 if err != nil {
79 return nil, fmt.Errorf("read: invalid value for field %d", 2+i)
80 }
81 }
82 }
83
84 return res, nil
85}
86
87func Lookup(name string) (*Entry, error) {
88 entries, err := Read()

Callers 1

ReadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected