~ubuntu-branches/ubuntu/vivid/augeas/vivid-proposed

« back to all changes in this revision

Viewing changes to lenses/passwd.aug

  • Committer: Package Import Robot
  • Author(s): Raphaël Pinson
  • Date: 2014-12-01 10:49:19 UTC
  • mfrom: (1.6.1) (24.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20141201104919-lalkacyk0i5fndg5
Tags: 1.3.0-0ubuntu1
* New upstream version
* Include d/p/0003_Link_pthread.patch again

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
(* Passwd module for Augeas
 
1
(*
 
2
 Module: Passwd
 
3
 Parses /etc/passwd
 
4
 
2
5
 Author: Free Ekanayaka <free@64studio.com>
3
6
 
4
 
 Reference: man 5 passwd
 
7
 About: Reference
 
8
        - man 5 passwd
 
9
        - man 3 getpwnam
 
10
 
 
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
5
13
 
6
14
*)
7
15
 
10
18
   autoload xfm
11
19
 
12
20
(************************************************************************
13
 
 *                           USEFUL PRIMITIVES
 
21
 * Group:                    USEFUL PRIMITIVES
14
22
 *************************************************************************)
15
23
 
 
24
(* Group: Comments and empty lines *)
 
25
 
16
26
let eol        = Util.eol
17
27
let comment    = Util.comment
18
28
let empty      = Util.empty
19
29
let dels       = Util.del_str
20
30
 
21
 
let colon      = del /:/ ":"
22
 
 
23
 
let sto_to_col  = store /[^:\n]+/
24
 
let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
25
 
 
26
 
let word       = /[A-Za-z0-9_.-]+/
27
 
let integer    = /[0-9]+/
 
31
let word       = Rx.word
 
32
let integer    = Rx.integer
 
33
 
 
34
let colon      = Sep.colon
 
35
 
 
36
let sto_to_eol = store Rx.space_in
 
37
let sto_to_col = store /[^:\r\n]+/
28
38
 
29
39
(************************************************************************
30
 
 *                               ENTRIES
 
40
 * Group:                        ENTRIES
31
41
 *************************************************************************)
32
42
 
 
43
(* View: password
 
44
        pw_passwd *)
 
45
let password  = [ label "password" . sto_to_col?   . colon ]
 
46
 
 
47
(* View: uid
 
48
        pw_uid *)
 
49
let uid       = [ label "uid"      . store integer . colon ]
 
50
 
 
51
(* View: gid
 
52
        pw_gid *)
 
53
let gid       = [ label "gid"      . store integer . colon ]
 
54
 
 
55
(* View: name
 
56
        pw_gecos; the user's full name *)
 
57
let name      = [ label "name"     . sto_to_col? . colon ]
 
58
 
 
59
(* View: home
 
60
        pw_dir *)
 
61
let home      = [ label "home"     . sto_to_col?   . colon ]
 
62
 
 
63
(* View: shell
 
64
        pw_shell *)
 
65
let shell     = [ label "shell"    . sto_to_eol? ]
 
66
 
 
67
(* View: entry
 
68
        struct passwd *)
33
69
let entry     = [ key word
34
70
                . colon
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? ]
 
71
                . password
 
72
                . uid
 
73
                . gid
 
74
                . name
 
75
                . home
 
76
                . shell
41
77
                . eol ]
42
78
 
43
79
(* A NIS entry has nothing bar the +@:::::: bits. *)
44
80
let nisentry =
45
 
  let nisuser = /\+\@[A-Za-z0-9_.-]+/ in
46
 
  let colons = "::::::" in
47
 
  [ dels "+@" . label "@nis" . store word . dels colons . eol ]
 
81
  let overrides =
 
82
        colon
 
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 ]
48
90
 
49
91
let nisdefault =
50
92
  let overrides =
63
105
 
64
106
let lns        = (comment|empty|entry|nisentry|nisdefault) *
65
107
 
66
 
let filter
67
 
               = incl "/etc/passwd"
68
 
               . Util.stdexcl
 
108
let filter     = incl "/etc/passwd"
69
109
 
70
110
let xfm        = transform lns filter