Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / shadow.aug
1 (*
2  Module: Shadow
3  Parses /etc/shadow
4
5  Author: Lorenzo M. Catucci <catucci@ccd.uniroma2.it>
6
7  Original Author: Free Ekanayaka <free@64studio.com>
8
9  About: Reference
10
11    - man 5 shadow
12    - man 3 getspnam
13
14  About: License
15    This file is licensed under the LGPL v2+, like the rest of Augeas.
16
17  About:
18
19  Each line in the shadow files represents the additional shadow-defined attributes
20  for the corresponding user, as defined in the passwd file.
21
22 *)
23
24 module Shadow =
25
26    autoload xfm
27
28 (************************************************************************
29  *                           USEFUL PRIMITIVES
30  *************************************************************************)
31
32 let eol        = Util.eol
33 let comment    = Util.comment
34 let empty      = Util.empty
35 let dels       = Util.del_str
36
37 let colon      = Sep.colon
38
39 let word       = Rx.word
40 let integer    = Rx.integer
41
42 let sto_to_col = Passwd.sto_to_col
43 let sto_to_eol = Passwd.sto_to_eol
44
45 (************************************************************************
46  * Group:                        ENTRIES
47  *************************************************************************)
48 (* Common for entry and nisdefault *)
49 let common =  [ label "lastchange_date" . store integer? . colon ]
50             . [ label "minage_days"     . store integer? . colon ]
51             . [ label "maxage_days"     . store integer? . colon ]
52             . [ label "warn_days"       . store integer? . colon ]
53             . [ label "inactive_days"   . store integer? . colon ]
54             . [ label "expire_date"     . store integer? . colon ]
55             . [ label "flag"            . store integer? ]
56               
57 (* View: entry *)
58 let entry  = [ key word
59                . colon
60                . [ label "password" . sto_to_col? . colon ]
61                . common
62                . eol ]
63
64 let nisdefault =
65            let overrides =
66              colon
67                . [ label "password" . store word? . colon ]
68                . common in
69            [ dels "+" . label "@nisdefault" . overrides? . eol ]
70
71 (************************************************************************
72  *                                LENS
73  *************************************************************************)
74
75 let lns        = (comment|empty|entry|nisdefault) *
76
77 let filter
78                = incl "/etc/shadow"
79                . Util.stdexcl
80
81 let xfm        = transform lns filter