Imported Upstream version 1.7.0
[platform/upstream/augeas.git] / lenses / pam.aug
1 (*
2 Module: Pam
3   Parses /etc/pam.conf and /etc/pam.d/* service files
4
5 Author: David Lutterkort <lutter@redhat.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man pam.conf` where
9   possible.
10
11 About: Licence
12   This file is licensed under the LGPL v2+, like the rest of Augeas.
13
14 About: Lens Usage
15
16 About: Configuration files
17   This lens autoloads /etc/pam.d/* for service specific files. See <filter>.
18   It provides a lens for /etc/pam.conf, which is used in the PamConf module.
19 *)
20 module Pam =
21   autoload xfm
22
23   let eol = Util.eol
24   let indent = Util.indent
25
26   (* For the control syntax of [key=value ..] we could split the key value *)
27   (* pairs into an array and generate a subtree control/N/KEY = VALUE      *)
28   let control = /(\[[^]#\n]*\]|[^[ \t][^ \t]*)/
29   let word = /[^# \t\n]+/
30   (* Allowed types *)
31   let types = /(auth|session|account|password)/i
32
33   (* This isn't entirely right: arguments enclosed in [ .. ] can contain  *)
34   (* a ']' if escaped with a '\' and can be on multiple lines ('\')       *)
35   let argument = /(\[[^]#\n]+\]|[^[#\n \t][^#\n \t]*)/
36
37   let comment = Util.comment
38   let comment_or_eol = Util.comment_or_eol
39   let empty   = Util.empty
40
41
42   (* Not mentioned in the man page, but Debian uses the syntax             *)
43   (*   @include module                                                     *)
44   (* quite a bit                                                           *)
45   let include = [ indent . Util.del_str "@" . key "include" .
46                   Util.del_ws_spc . store word . eol ]
47
48   (* Shared with PamConf *)
49   let record = [ label "optional" . del "-" "-" ]? .
50                [ label "type" . store types ] .
51                Sep.space .
52                [ label "control" . store control] .
53                Sep.space .
54                [ label "module" . store word ] .
55                [ Sep.space . label "argument" . store argument ]* .
56                comment_or_eol
57
58   let record_svc = [ seq "record" . indent . record ]
59
60   let lns = ( empty | comment | include | record_svc ) *
61
62   let filter = incl "/etc/pam.d/*"
63              . excl "/etc/pam.d/allow.pamlist"
64              . excl "/etc/pam.d/README"
65              . Util.stdexcl
66
67   let xfm = transform lns filter
68
69 (* Local Variables: *)
70 (* mode: caml       *)
71 (* End:             *)