Parses xinetd configuration files
The structure of the lens and allowed attributes are ripped directly from xinetd’s parser in xinetd/parse.c in xinetd’s source checkout The downside of being so precise here is that if attributes are added they need to be added here, too. Writing a catchall entry, and getting to typecheck correctly would be a huge pain.
A really enterprising soul could tighten this down even further by restricting the acceptable values for each attribute.
Author: David Lutterkort
Xinetd | Parses xinetd configuration files |
Augeas Variables | |
service_attr | It is much faster to combine, for example, all the attr_one attributes into one regexp and pass that to a lens instead of using lens union (attr_one “a” | attr_one “b”|..) |
Augeas Lenses | |
body | We would really like to say “the body can contain any of a list of a list of attributes, each of them at most once”; but that would require that we build a lens that matches the permutation of all attributes; with around 40 individual attributes, that’s not computationally feasible, even if we didn’t have to worry about how to write that down. |
includes | It would be nice if we could use the directories given in include and includedir directives to parse additional files instead of hardcoding all the places where xinetd config files can be found; but that is currently not possible, and implementing that has a good amount of hairy corner cases to consider. |
let service_attr = attr_one (/socket_type|protocol|wait|user|group|server|instances/i |/rpc_version|rpc_number|id|port|nice|banner|bind|interface/i |/per_source|groups|banner_success|banner_fail|disable|max_load/i |/rlimit_as|rlimit_cpu|rlimit_data|rlimit_rss|rlimit_stack|v6only/i |/deny_time|umask|mdns|libwrap/i)
It is much faster to combine, for example, all the attr_one attributes into one regexp and pass that to a lens instead of using lens union (attr_one “a” | attr_one “b”|..) because the latter causes the type checker to work very hard.
let body (attr:lens) = Build.block_newlines_spc (indent . attr . Util.eol) Util.comment
We would really like to say “the body can contain any of a list of a list of attributes, each of them at most once”; but that would require that we build a lens that matches the permutation of all attributes; with around 40 individual attributes, that’s not computationally feasible, even if we didn’t have to worry about how to write that down. The resulting regular expressions would simply be prohibitively large.
let includes = Build.key_value_line /include(dir)?/ Sep.space (store Rx.no_spaces)
It would be nice if we could use the directories given in include and includedir directives to parse additional files instead of hardcoding all the places where xinetd config files can be found; but that is currently not possible, and implementing that has a good amount of hairy corner cases to consider.
It is much faster to combine, for example, all the attr_one attributes into one regexp and pass that to a lens instead of using lens union (attr_one “a” | attr_one “b”|..)
let service_attr = attr_one (/socket_type|protocol|wait|user|group|server|instances/i |/rpc_version|rpc_number|id|port|nice|banner|bind|interface/i |/per_source|groups|banner_success|banner_fail|disable|max_load/i |/rlimit_as|rlimit_cpu|rlimit_data|rlimit_rss|rlimit_stack|v6only/i |/deny_time|umask|mdns|libwrap/i)
We would really like to say “the body can contain any of a list of a list of attributes, each of them at most once”; but that would require that we build a lens that matches the permutation of all attributes; with around 40 individual attributes, that’s not computationally feasible, even if we didn’t have to worry about how to write that down.
let body (attr:lens) = Build.block_newlines_spc (indent . attr . Util.eol) Util.comment
It would be nice if we could use the directories given in include and includedir directives to parse additional files instead of hardcoding all the places where xinetd config files can be found; but that is currently not possible, and implementing that has a good amount of hairy corner cases to consider.
let includes = Build.key_value_line /include(dir)?/ Sep.space (store Rx.no_spaces)