Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / automaster.aug
1 (*
2 Module: Automaster
3   Parses autofs' auto.master files
4
5 Author: Dominic Cleal <dcleal@redhat.com>
6
7 About: Reference
8   See auto.master(5)
9
10 About: License
11    This file is licenced under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14    To be documented
15
16 About: Configuration files
17    This lens applies to /etc/auto.master, auto_master and /etc/auto.master.d/*
18    files.
19
20 About: Examples
21    The <Test_Automaster> file contains various examples and tests.
22 *)
23
24 module Automaster =
25 autoload xfm
26
27 (************************************************************************
28  * Group:                 USEFUL PRIMITIVES
29  *************************************************************************)
30
31 (* View: eol *)
32 let eol = Util.eol
33
34 (* View: empty *)
35 let empty   = Util.empty
36
37 (* View: comment *)
38 let comment = Util.comment
39
40 (* View mount *)
41 let mount = /[^+ \t\n#]+/
42
43 (* View: type
44    yp, file, dir etc but not ldap *)
45 let type = Rx.word - /ldap/
46
47 (* View: format
48    sun, hesoid *)
49 let format = Rx.word
50
51 (* View: name *)
52 let name = /[^: \t\n]+/
53
54 (* View: host *)
55 let host = /[^:# \n\t]+/
56
57 (* View: dn *)
58 let dn = /[^:# \n\t]+/
59
60 (* An option label can't contain comma, comment, equals, or space *)
61 let optlabel = /[^,#= \n\t]+/
62 let spec    = /[^,# \n\t][^ \n\t]*/
63
64 (* View: optsep *)
65 let optsep = del /[ \t,]+/ ","
66
67 (************************************************************************
68  * Group:                 ENTRIES
69  *************************************************************************)
70
71 (* View: map_format *)
72 let map_format = [ label "format" . store format ]
73
74 (* View: map_type *)
75 let map_type = [ label "type" . store type ]
76
77 (* View: map_name *)
78 let map_name = [ label "map" . store name ]
79
80 (* View: map_generic
81    Used for all except LDAP maps which are parsed further *)
82 let map_generic = ( map_type . ( Sep.comma . map_format )?  . Sep.colon )?
83                     . map_name
84
85 (* View: map_ldap_name
86    Split up host:dc=foo into host/map nodes *)
87 let map_ldap_name = ( [ label "host" . store host ] . Sep.colon )?
88                       . [ label "map" . store dn ]
89
90 (* View: map_ldap *)
91 let map_ldap      = [ label "type" . store "ldap" ]
92                       . ( Sep.comma . map_format )? . Sep.colon
93                       . map_ldap_name
94
95 (* View: comma_spc_sep_list
96    Parses options either for filesystems or autofs *)
97 let comma_spc_sep_list (l:string) =
98   let value = [ label "value" . Util.del_str "=" . store Rx.neg1 ] in
99     let lns = [ label l . store optlabel . value? ] in
100        Build.opt_list lns optsep
101
102 (* View: map_mount 
103    Mountpoint and whitespace, followed by the map info *)
104 let map_mount  = [ seq "map" . store mount . Util.del_ws_tab
105                    . ( map_generic | map_ldap )
106                    . ( Util.del_ws_spc . comma_spc_sep_list "opt" )?
107                    . Util.eol ]
108
109 (* map_master
110    "+" to include more master entries and optional whitespace *)
111 let map_master = [ seq "map" . store "+" . Util.del_opt_ws ""
112                    . ( map_generic | map_ldap )
113                    . ( Util.del_ws_spc . comma_spc_sep_list "opt" )?
114                    . Util.eol ]
115
116 (* View: lns *)
117 let lns = ( empty | comment | map_mount | map_master ) *
118
119 (* Variable: filter *)
120 let filter = incl "/etc/auto.master"
121            . incl "/etc/auto_master"
122            . incl "/etc/auto.master.d/*"
123            . Util.stdexcl
124
125 let xfm = transform lns filter