Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / inetd.aug
1 (* inetd.conf lens definition for Augeas
2    Auther: Matt Palmer <mpalmer@hezmatt.org>
3
4    Copyright (C) 2009 Matt Palmer, All Rights Reserved
5
6    This program is free software: you can redistribute it and/or modify it
7    under the terms of the GNU Lesser General Public License version 2.1 as
8    published by the Free Software Foundation.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
13    Public License for more details.
14
15    You should have received a copy of the GNU General Public License along
16    with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 This lens parses /etc/inetd.conf.  The current format is based on the
19 syntax documented in the inetd manpage shipped with Debian's openbsd-inetd
20 package version 0.20080125-2.  Apologies if your inetd.conf doesn't follow
21 the same format.
22
23 Each top-level entry will have a key being that of the service name (the
24 first column in the service definition, which is the name or number of the
25 port that the service should listen on).  The attributes for the service all
26 sit under that.  In regular Augeas style, the order of the attributes
27 matter, and attempts to set things in a different order will fail miserably.
28 The defined attribute names (and the order in which they must appear) are as
29 follows (with mandatory parameters indicated by [*]):
30
31 address -- a sequence of IP addresses or hostnames on which this service
32         should listen.
33
34 socket[*] -- The type of the socket that will be created (either stream or
35         dgram, although the lens doesn't constrain the possibilities here)
36
37 protocol[*] -- The socket protocol.  I believe that the usual possibilities
38         are "tcp", "udp", or "unix", but no restriction is made on what you
39         can actually put here.
40
41 sndbuf -- Specify a non-default size for the send buffer of the connection.
42
43 rcvbuf -- Specify a non-default size for the receive buffer of the connection.
44
45 wait[*] -- Whether to wait for new connections ("wait"), or just terminate
46         immediately ("nowait").
47
48 max -- The maximum number of times that a service can be invoked in one minute.
49
50 user[*] -- The user to run the service as.
51
52 group -- A group to set the running service to, rather than the primary
53         group of the previously specified user.
54
55 command[*] -- What program to run.
56
57 arguments -- A sequence of arguments to pass to the command.
58
59 In addition to this straightforward tree, inetd has the ability to set
60 "default" listen addresses; this is a little used feature which nonetheless
61 comes in handy sometimes.  The key for entries of this type is "address"
62 , and the subtree should be a sequence of addresses.  "*" can
63 always be used to return the default behaviour of listening on INADDR_ANY.
64
65 *)
66
67 module Inetd =
68         autoload xfm
69
70         (***************************
71          * PRIMITIVES
72          ***************************)
73
74         (* Store whitespace *)
75         let wsp = del /[ \t]+/ " "
76         let sep = del /[ \t]+/ "        "
77         let owsp(t:string) = del /[ \t]*/ t
78
79         (* It's the end of the line as we know it... doo, doo, dooooo *)
80         let eol = Util.eol
81
82         (* In the beginning, the earth was without form, and void *)
83         let empty = Util.empty
84
85         let comment = Util.comment
86
87         let del_str = Util.del_str
88
89         let address = [ seq "addrseq" . store /([a-zA-Z0-9.-]+|\[[A-Za-z0-9:?*%]+\]|\*)/ ]
90         let address_list = ( counter "addrseq" . (address . del_str ",")* . address )
91
92         let argument = [ seq "argseq" . store /[^ \t\n]+/ ]
93         let argument_list = ( counter "argseq" . [ label "arguments" . (argument . wsp)* . argument ] )
94
95         (***************************
96          * ELEMENTS
97          ***************************)
98
99         let service (l:string) = ( label l . [label "address" . address_list . del_str ":" ]? . store /[^ \t\n\/:#]+/ )
100
101         let socket = [ label "socket" . store /[^ \t\n#]+/ ]
102
103         let protocol = ( [ label "protocol" . store /[^ \t\n,#]+/ ]
104                          . [ del_str "," . key /sndbuf/ . del_str "=" . store /[^ \t\n,]+/ ]?
105                          . [ del_str "," . key /rcvbuf/ . del_str "=" . store /[^ \t\n,]+/ ]?
106                        )
107
108         let wait = ( [ label "wait" . store /(wait|nowait)/ ]
109                      . [ del_str "." . label "max" . store /[0-9]+/ ]?
110                    )
111
112         let usergroup = ( [ label "user" . store /[^ \t\n:.]+/ ]
113                           . [ del /[:.]/ ":" . label "group" . store /[^ \t\n:.]+/ ]?
114                         )
115
116         let command = ( [ label "command" . store /[^ \t\n]+/ ]
117                         . (wsp . argument_list)?
118                       )
119
120         (***************************
121          * SERVICE LINES
122          ***************************)
123
124         let service_line = [ service "service"
125                              . sep
126                              . socket
127                              . sep
128                              . protocol
129                              . sep
130                              . wait
131                              . sep
132                              . usergroup
133                              . sep
134                              . command
135                              . eol
136                            ]
137
138
139         (***************************
140          * RPC LINES
141          ***************************)
142
143         let rpc_service = service "rpc_service" . Util.del_str "/"
144                         . [ label "version" . store Rx.integer ]
145
146         let rpc_endpoint = [ label "endpoint-type" . store Rx.word ]
147         let rpc_protocol = Util.del_str "rpc/"
148                          . (Build.opt_list
149                              [label "protocol" . store /[^ \t\n,#]+/ ]
150                              Sep.comma)
151
152         let rpc_line = [ rpc_service
153                              . sep
154                              . rpc_endpoint
155                              . sep
156                              . rpc_protocol
157                              . sep
158                              . wait
159                              . sep
160                              . usergroup
161                              . sep
162                              . command
163                              . eol
164                            ]
165
166
167         (***************************
168          * DEFAULT LISTEN ADDRESSES
169          ***************************)
170
171         let default_listen_address = [ label "address"
172                                        . address_list
173                                        . del_str ":"
174                                        . eol
175                                      ]
176
177         (***********************
178          * LENS / FILTER
179          ***********************)
180
181         let lns = (comment|empty|service_line|rpc_line|default_listen_address)*
182
183         let filter = incl "/etc/inetd.conf"
184
185         let xfm = transform lns filter