-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
passwd.go
35 lines (31 loc) · 942 Bytes
/
passwd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package narcissus
// Passwd maps /etc/passwd
type Passwd struct {
augeasPath string `default:"/files/etc/passwd"`
Users map[string]PasswdUser `narcissus:"*,key-from-label"`
}
// PasswdUser maps a Passwd user
type PasswdUser struct {
augeasPath string
Account string `narcissus:".,value-from-label"`
Password string `narcissus:"password"`
UID int `narcissus:"uid"`
GID int `narcissus:"gid"`
Name string `narcissus:"name"`
Home string `narcissus:"home"`
Shell string `narcissus:"shell"`
}
// NewPasswd returns a new Passwd structure
func (n *Narcissus) NewPasswd() (p *Passwd, err error) {
p = &Passwd{}
err = n.Parse(p)
return
}
// NewPasswdUser returns a new PasswdUser structure for given user
func (n *Narcissus) NewPasswdUser(user string) (p *PasswdUser, err error) {
p = &PasswdUser{
augeasPath: "/files/etc/passwd/" + user,
}
err = n.Parse(p)
return
}