|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: MasterPasswd
|
|
Packit Service |
a2ae7a |
Parses /etc/master.passwd
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Matt Dainty <matt@bodgit-n-scarper.com>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
- man 5 master.passwd
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Each line in the master.passwd file represents a single user record, whose
|
|
Packit Service |
a2ae7a |
colon-separated attributes correspond to the members of the passwd struct
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module MasterPasswd =
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: USEFUL PRIMITIVES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Comments and empty lines *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let eol = Util.eol
|
|
Packit Service |
a2ae7a |
let comment = Util.comment
|
|
Packit Service |
a2ae7a |
let empty = Util.empty
|
|
Packit Service |
a2ae7a |
let dels = Util.del_str
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let word = Rx.word
|
|
Packit Service |
a2ae7a |
let integer = Rx.integer
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let colon = Sep.colon
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let sto_to_eol = Passwd.sto_to_eol
|
|
Packit Service |
a2ae7a |
let sto_to_col = Passwd.sto_to_col
|
|
Packit Service |
a2ae7a |
(* Store an empty string if nothing matches *)
|
|
Packit Service |
a2ae7a |
let sto_to_col_or_empty = Passwd.sto_to_col_or_empty
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: ENTRIES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let username = /[_.A-Za-z0-9][-_.A-Za-z0-9]*\$?/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: password
|
|
Packit Service |
a2ae7a |
pw_passwd *)
|
|
Packit Service |
a2ae7a |
let password = [ label "password" . sto_to_col? . colon ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: uid
|
|
Packit Service |
a2ae7a |
pw_uid *)
|
|
Packit Service |
a2ae7a |
let uid = [ label "uid" . store integer . colon ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: gid
|
|
Packit Service |
a2ae7a |
pw_gid *)
|
|
Packit Service |
a2ae7a |
let gid = [ label "gid" . store integer . colon ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: class
|
|
Packit Service |
a2ae7a |
pw_class *)
|
|
Packit Service |
a2ae7a |
let class = [ label "class" . sto_to_col? . colon ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: change
|
|
Packit Service |
a2ae7a |
pw_change *)
|
|
Packit Service |
a2ae7a |
let change_date = [ label "change_date" . store integer? . colon ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: expire
|
|
Packit Service |
a2ae7a |
pw_expire *)
|
|
Packit Service |
a2ae7a |
let expire_date = [ label "expire_date" . store integer? . colon ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: name
|
|
Packit Service |
a2ae7a |
pw_gecos; the user's full name *)
|
|
Packit Service |
a2ae7a |
let name = [ label "name" . sto_to_col? . colon ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: home
|
|
Packit Service |
a2ae7a |
pw_dir *)
|
|
Packit Service |
a2ae7a |
let home = [ label "home" . sto_to_col? . colon ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: shell
|
|
Packit Service |
a2ae7a |
pw_shell *)
|
|
Packit Service |
a2ae7a |
let shell = [ label "shell" . sto_to_eol? ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: entry
|
|
Packit Service |
a2ae7a |
struct passwd *)
|
|
Packit Service |
a2ae7a |
let entry = [ key username
|
|
Packit Service |
a2ae7a |
. colon
|
|
Packit Service |
a2ae7a |
. password
|
|
Packit Service |
a2ae7a |
. uid
|
|
Packit Service |
a2ae7a |
. gid
|
|
Packit Service |
a2ae7a |
. class
|
|
Packit Service |
a2ae7a |
. change_date
|
|
Packit Service |
a2ae7a |
. expire_date
|
|
Packit Service |
a2ae7a |
. name
|
|
Packit Service |
a2ae7a |
. home
|
|
Packit Service |
a2ae7a |
. shell
|
|
Packit Service |
a2ae7a |
. eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* NIS entries *)
|
|
Packit Service |
a2ae7a |
let niscommon = [ label "password" . sto_to_col ]? . colon
|
|
Packit Service |
a2ae7a |
. [ label "uid" . store integer ]? . colon
|
|
Packit Service |
a2ae7a |
. [ label "gid" . store integer ]? . colon
|
|
Packit Service |
a2ae7a |
. [ label "class" . sto_to_col ]? . colon
|
|
Packit Service |
a2ae7a |
. [ label "change_date" . store integer ]? . colon
|
|
Packit Service |
a2ae7a |
. [ label "expire_date" . store integer ]? . colon
|
|
Packit Service |
a2ae7a |
. [ label "name" . sto_to_col ]? . colon
|
|
Packit Service |
a2ae7a |
. [ label "home" . sto_to_col ]? . colon
|
|
Packit Service |
a2ae7a |
. [ label "shell" . sto_to_eol ]?
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let nisentry =
|
|
Packit Service |
a2ae7a |
let overrides =
|
|
Packit Service |
a2ae7a |
colon
|
|
Packit Service |
a2ae7a |
. niscommon in
|
|
Packit Service |
a2ae7a |
[ dels "+@" . label "@nis" . store username . overrides . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let nisuserplus =
|
|
Packit Service |
a2ae7a |
let overrides =
|
|
Packit Service |
a2ae7a |
colon
|
|
Packit Service |
a2ae7a |
. niscommon in
|
|
Packit Service |
a2ae7a |
[ dels "+" . label "@+nisuser" . store username . overrides . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let nisuserminus =
|
|
Packit Service |
a2ae7a |
let overrides =
|
|
Packit Service |
a2ae7a |
colon
|
|
Packit Service |
a2ae7a |
. niscommon in
|
|
Packit Service |
a2ae7a |
[ dels "-" . label "@-nisuser" . store username . overrides . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let nisdefault =
|
|
Packit Service |
a2ae7a |
let overrides =
|
|
Packit Service |
a2ae7a |
colon
|
|
Packit Service |
a2ae7a |
. [ label "password" . sto_to_col_or_empty . colon ]
|
|
Packit Service |
a2ae7a |
. [ label "uid" . store integer? . colon ]
|
|
Packit Service |
a2ae7a |
. [ label "gid" . store integer? . colon ]
|
|
Packit Service |
a2ae7a |
. [ label "class" . sto_to_col? . colon ]
|
|
Packit Service |
a2ae7a |
. [ label "change_date" . store integer? . colon ]
|
|
Packit Service |
a2ae7a |
. [ label "expire_date" . store integer? . colon ]
|
|
Packit Service |
a2ae7a |
. [ label "name" . sto_to_col? . colon ]
|
|
Packit Service |
a2ae7a |
. [ label "home" . sto_to_col? . colon ]
|
|
Packit Service |
a2ae7a |
. [ label "shell" . sto_to_eol? ] in
|
|
Packit Service |
a2ae7a |
[ dels "+" . label "@nisdefault" . overrides? . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* LENS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let lns = (comment|empty|entry|nisentry|nisdefault|nisuserplus|nisuserminus) *
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let filter = incl "/etc/master.passwd"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns filter
|