Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / nsswitch.aug
1 (*
2 Module: Nsswitch
3   Parses /etc/nsswitch.conf
4
5 Author: Raphael Pinson <raphink@gmail.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man nsswitch.conf` where possible.
9
10 About: Licence
11   This file is licensed under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14
15 About: Configuration files
16   This lens applies to /etc/nsswitch.conf. See <filter>.
17 *)
18
19 module Nsswitch =
20 autoload xfm
21
22 (************************************************************************
23  * Group:                 USEFUL PRIMITIVES
24  *************************************************************************)
25
26 (* View: comment *)
27 let comment = Util.comment
28
29 (* View: empty *)
30 let empty = Util.empty
31
32 (* View: sep_colon
33     The separator for database entries *)
34 let sep_colon = del /:[ \t]*/ ": "
35
36 (* View: database_kw
37     The database specification like `passwd', `shadow', or `hosts' *)
38 let database_kw = Rx.word
39
40 (* View: service
41     The service specification like `files', `db', or `nis' *)
42 let service = [ label "service" . store Rx.word ]
43
44 (* View: reaction
45     The reaction on lookup result like `[NOTFOUND=return]'
46     TODO: Use case-insensitive regexps when ticket #147 is fixed.
47 *)
48 let reaction =
49   let status_kw = /[Ss][Uu][Cc][Cc][Ee][Ss][Ss]/
50                 | /[Nn][Oo][Tt][Ff][Oo][Uu][Nn][Dd]/
51                 | /[Uu][Nn][Aa][Vv][Aa][Ii][Ll]/
52                 | /[Tt][Rr][Yy][Aa][Gg][Aa][Ii][Nn]/
53     in let action_kw = /[Rr][Ee][Tt][Uu][Rr][Nn]/
54                      | /[Cc][Oo][Nn][Tt][Ii][Nn][Uu][Ee]/
55                      | /[Mm][Ee][Rr][Gg][Ee]/
56       in let negate = [ Util.del_str "!" . label "negate" ]
57         in let reaction_entry = [ label "status" . negate?
58                                 . store status_kw
59                                 . Util.del_str "="
60                                 . [ label "action" . store action_kw ] ]
61           in Util.del_str "["
62              . [ label "reaction"
63                . (Build.opt_list reaction_entry Sep.space) ]
64              . Util.del_str "]"
65
66 (* View: database *)
67 let database = 
68     [ label "database" . store database_kw
69        . sep_colon
70        . (Build.opt_list
71             (service|reaction)
72             Sep.space)
73        . Util.comment_or_eol ]
74
75 (* View: lns *)
76 let lns = ( empty | comment | database )*
77
78 (* Variable: filter *)
79 let filter = (incl "/etc/nsswitch.conf")
80
81 let xfm = transform lns filter