|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Pg_Hba
|
|
Packit Service |
a2ae7a |
Parses PostgreSQL's pg_hba.conf
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Aurelien Bompard <aurelien@bompard.org>
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
The file format is described in PostgreSQL's documentation:
|
|
Packit Service |
a2ae7a |
http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licensed under the LGPL v2+, like the rest of Augeas.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Configuration files
|
|
Packit Service |
a2ae7a |
This lens applies to pg_hba.conf. See <filter> for exact locations.
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Pg_Hba =
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Generic primitives *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let eol = Util.eol
|
|
Packit Service |
a2ae7a |
let word = Rx.neg1
|
|
Packit Service |
a2ae7a |
(* Variable: ipaddr
|
|
Packit Service |
a2ae7a |
CIDR or ip+netmask *)
|
|
Packit Service |
a2ae7a |
let ipaddr = /[0-9a-fA-F:.]+(\/[0-9]+|[ \t]+[0-9.]+)/
|
|
Packit Service |
a2ae7a |
(* Variable: hostname
|
|
Packit Service |
a2ae7a |
Hostname, FQDN or part of an FQDN possibly
|
|
Packit Service |
a2ae7a |
starting with a dot. Taken from the syslog lens. *)
|
|
Packit Service |
a2ae7a |
let hostname = /\.?[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let comma_sep_list (l:string) =
|
|
Packit Service |
a2ae7a |
let lns = [ label l . store word ] in
|
|
Packit Service |
a2ae7a |
Build.opt_list lns Sep.comma
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Columns definitions *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: ipaddr_or_hostname *)
|
|
Packit Service |
a2ae7a |
let ipaddr_or_hostname = ipaddr | hostname
|
|
Packit Service |
a2ae7a |
(* View: database
|
|
Packit Service |
a2ae7a |
TODO: support for quoted strings *)
|
|
Packit Service |
a2ae7a |
let database = comma_sep_list "database"
|
|
Packit Service |
a2ae7a |
(* View: user
|
|
Packit Service |
a2ae7a |
TODO: support for quoted strings *)
|
|
Packit Service |
a2ae7a |
let user = comma_sep_list "user"
|
|
Packit Service |
a2ae7a |
(* View: address *)
|
|
Packit Service |
a2ae7a |
let address = [ label "address" . store ipaddr_or_hostname ]
|
|
Packit Service |
a2ae7a |
(* View: option
|
|
Packit Service |
a2ae7a |
part of <method> *)
|
|
Packit Service |
a2ae7a |
let option =
|
|
Packit Service |
a2ae7a |
let value_start = label "value" . Sep.equal
|
|
Packit Service |
a2ae7a |
in [ label "option" . store Rx.word
|
|
Packit Service |
a2ae7a |
. (Quote.quote_spaces value_start)? ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: method
|
|
Packit Service |
a2ae7a |
can contain an <option> *)
|
|
Packit Service |
a2ae7a |
let method = [ label "method" . store /[A-Za-z][A-Za-z0-9]+/
|
|
Packit Service |
a2ae7a |
. ( Sep.tab . option )* ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Records definitions *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: record_local
|
|
Packit Service |
a2ae7a |
when type is "local", there is no "address" field *)
|
|
Packit Service |
a2ae7a |
let record_local = [ label "type" . store "local" ] . Sep.tab .
|
|
Packit Service |
a2ae7a |
database . Sep.tab . user . Sep.tab . method
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: remtypes
|
|
Packit Service |
a2ae7a |
non-local connection types *)
|
|
Packit Service |
a2ae7a |
let remtypes = "host" | "hostssl" | "hostnossl"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: record_remote *)
|
|
Packit Service |
a2ae7a |
let record_remote = [ label "type" . store remtypes ] . Sep.tab .
|
|
Packit Service |
a2ae7a |
database . Sep.tab . user . Sep.tab .
|
|
Packit Service |
a2ae7a |
address . Sep.tab . method
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: record
|
|
Packit Service |
a2ae7a |
A sequence of <record_local> or <record_remote> entries *)
|
|
Packit Service |
a2ae7a |
let record = [ seq "entries" . (record_local | record_remote) . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: filter
|
|
Packit Service |
a2ae7a |
The pg_hba.conf conf file *)
|
|
Packit Service |
a2ae7a |
let filter = (incl "/var/lib/pgsql/data/pg_hba.conf" .
|
|
Packit Service |
a2ae7a |
incl "/var/lib/pgsql/*/data/pg_hba.conf" .
|
|
Packit Service |
a2ae7a |
incl "/var/lib/postgresql/*/data/pg_hba.conf" .
|
|
Packit Service |
a2ae7a |
incl "/etc/postgresql/*/*/pg_hba.conf" )
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: lns
|
|
Packit Service |
a2ae7a |
The pg_hba.conf lens *)
|
|
Packit Service |
a2ae7a |
let lns = ( record | Util.comment | Util.empty ) *
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns filter
|