3 Parses /etc/nsswitch.conf
5 Author: Raphael Pinson <raphink@gmail.com>
8 This lens tries to keep as close as possible to `man nsswitch.conf` where possible.
11 This file is licensed under the LGPL v2+, like the rest of Augeas.
15 About: Configuration files
16 This lens applies to /etc/nsswitch.conf. See <filter>.
22 (************************************************************************
23 * Group: USEFUL PRIMITIVES
24 *************************************************************************)
27 let comment = Util.comment
30 let empty = Util.empty
33 The separator for database entries *)
34 let sep_colon = del /:[ \t]*/ ": "
37 The database specification like `passwd', `shadow', or `hosts' *)
38 let database_kw = Rx.word
41 The service specification like `files', `db', or `nis' *)
42 let service = [ label "service" . store Rx.word ]
45 The reaction on lookup result like `[NOTFOUND=return]'
46 TODO: Use case-insensitive regexps when ticket #147 is fixed.
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?
60 . [ label "action" . store action_kw ] ]
63 . (Build.opt_list reaction_entry Sep.space) ]
68 [ label "database" . store database_kw
73 . Util.comment_or_eol ]
76 let lns = ( empty | comment | database )*
78 (* Variable: filter *)
79 let filter = (incl "/etc/nsswitch.conf")
81 let xfm = transform lns filter