5 Author: Free Ekanayaka <free@64studio.com>
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
20 (************************************************************************
21 * Group: USEFUL PRIMITIVES
22 *************************************************************************)
24 (* Group: Comments and empty lines *)
27 let comment = Util.comment
28 let empty = Util.empty
29 let dels = Util.del_str
32 let integer = Rx.integer
36 let sto_to_eol = store Rx.space_in
37 let sto_to_col = store /[^:\r\n]+/
38 (* Store an empty string if nothing matches *)
39 let sto_to_col_or_empty = store /[^:\r\n]*/
41 (************************************************************************
43 *************************************************************************)
45 let username = /[_.A-Za-z0-9][-_.A-Za-z0-9]*\$?/
49 let password = [ label "password" . sto_to_col? . colon ]
53 let uid = [ label "uid" . store integer . colon ]
57 let gid = [ label "gid" . store integer . colon ]
60 pw_gecos; the user's full name *)
61 let name = [ label "name" . sto_to_col? . colon ]
65 let home = [ label "home" . sto_to_col? . colon ]
69 let shell = [ label "shell" . sto_to_eol? ]
73 let entry = [ key username
84 let niscommon = [ label "password" . sto_to_col ]? . colon
85 . [ label "uid" . store integer ]? . colon
86 . [ label "gid" . store integer ]? . colon
87 . [ label "name" . sto_to_col ]? . colon
88 . [ label "home" . sto_to_col ]? . colon
89 . [ label "shell" . sto_to_eol ]?
95 [ dels "+@" . label "@nis" . store username . overrides . eol ]
101 [ dels "+" . label "@+nisuser" . store username . overrides . eol ]
107 [ dels "-" . label "@-nisuser" . store username . overrides . eol ]
112 . [ label "password" . sto_to_col_or_empty . colon ]
113 . [ label "uid" . store integer? . colon ]
114 . [ label "gid" . store integer? . colon ]
115 . [ label "name" . sto_to_col? . colon ]
116 . [ label "home" . sto_to_col? . colon ]
117 . [ label "shell" . sto_to_eol? ] in
118 [ dels "+" . label "@nisdefault" . overrides? . eol ]
120 (************************************************************************
122 *************************************************************************)
124 let lns = (comment|empty|entry|nisentry|nisdefault|nisuserplus|nisuserminus) *
126 let filter = incl "/etc/passwd"
128 let xfm = transform lns filter