1
(* Passwd module for Augeas
2
5
Author: Free Ekanayaka <free@64studio.com>
4
Reference: man 5 passwd
11
Each line in the unix passwd file represents a single user record, whose
12
colon-separated attributes correspond to the members of the passwd struct
12
20
(************************************************************************
21
* Group: USEFUL PRIMITIVES
14
22
*************************************************************************)
24
(* Group: Comments and empty lines *)
17
27
let comment = Util.comment
18
28
let empty = Util.empty
19
29
let dels = Util.del_str
21
let colon = del /:/ ":"
23
let sto_to_col = store /[^:\n]+/
24
let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
26
let word = /[A-Za-z0-9_.-]+/
27
let integer = /[0-9]+/
32
let integer = Rx.integer
36
let sto_to_eol = store Rx.space_in
37
let sto_to_col = store /[^:\r\n]+/
29
39
(************************************************************************
31
41
*************************************************************************)
45
let password = [ label "password" . sto_to_col? . colon ]
49
let uid = [ label "uid" . store integer . colon ]
53
let gid = [ label "gid" . store integer . colon ]
56
pw_gecos; the user's full name *)
57
let name = [ label "name" . sto_to_col? . colon ]
61
let home = [ label "home" . sto_to_col? . colon ]
65
let shell = [ label "shell" . sto_to_eol? ]
33
69
let entry = [ key word
35
. [ label "password" . sto_to_col? . colon ]
36
. [ label "uid" . store integer . colon ]
37
. [ label "gid" . store integer . colon ]
38
. [ label "name" . sto_to_col? . colon ]
39
. [ label "home" . sto_to_col? . colon ]
40
. [ label "shell" . sto_to_eol? ]
43
79
(* A NIS entry has nothing bar the +@:::::: bits. *)
45
let nisuser = /\+\@[A-Za-z0-9_.-]+/ in
46
let colons = "::::::" in
47
[ dels "+@" . label "@nis" . store word . dels colons . eol ]
83
. [ label "password" . sto_to_col ]? . colon
84
. [ label "uid" . store integer ]? . colon
85
. [ label "gid" . store integer ]? . colon
86
. [ label "name" . sto_to_col ]? . colon
87
. [ label "home" . sto_to_col ]? . colon
88
. [ label "shell" . sto_to_eol ]? in
89
[ dels "+@" . label "@nis" . store word . overrides . eol ]