(entry string)
| 42 | } |
| 43 | |
| 44 | func parsePasswdEntry(entry string) (*User, error) { |
| 45 | entry = strings.TrimSpace(entry) |
| 46 | fields := strings.Split(entry, ":") |
| 47 | if len(fields) < 7 { |
| 48 | return nil, xerrors.Errorf("user info (%s) contained an unexpected number of fields", fields) |
| 49 | } |
| 50 | |
| 51 | return &User{ |
| 52 | User: user.User{ |
| 53 | Username: fields[0], |
| 54 | Uid: fields[2], |
| 55 | Gid: fields[3], |
| 56 | HomeDir: fields[5], |
| 57 | }, |
| 58 | Shell: fields[6], |
| 59 | }, nil |
| 60 | } |