[augeas-devel] Re: [PATCH] Added rsyncd.conf lens and associated test.
Free Ekanayaka
free at 64studio.com
Tue Dec 23 10:43:00 UTC 2008
Hi Marc,
|--==> On Tue, 23 Dec 2008 09:17:46 +0100, Marc Fournier <marc.fournier at camptocamp.com> said:
MF> rsyncd.conf is an ini file which allows indented parameters (like smb.conf) as
MF> well as entries outside any section (like php.ini). This is just a merge of
MF> bits and pieces taken from these 2 lenses. I would like to thank Raphaël and
MF> Free for their respective work !
Thank you too, very useful lens :)
Ciao,
Free
MF> ---
MF> lenses/rsyncd.aug | 67 ++++++++++++++++++++++++++++++++++++++++++
MF> lenses/tests/test_rsyncd.aug | 56 +++++++++++++++++++++++++++++++++++
MF> 2 files changed, 123 insertions(+), 0 deletions(-)
MF> create mode 100644 lenses/rsyncd.aug
MF> create mode 100644 lenses/tests/test_rsyncd.aug
MF> diff --git a/lenses/rsyncd.aug b/lenses/rsyncd.aug
MF> new file mode 100644
MF> index 0000000..bd47cfa
MF> --- /dev/null
MF> +++ b/lenses/rsyncd.aug
MF> @@ -0,0 +1,67 @@
MF> +(* Rsyncd module for Augeas
MF> + Author: Marc Fournier <marc.fournier at camptocamp.com>
MF> +
MF> + Reference: man rsyncd.conf(5)
MF> +
MF> +*)
MF> +
MF> +module Rsyncd =
MF> + autoload xfm
MF> +
MF> +(************************************************************************
MF> + * INI File settings
MF> + *************************************************************************)
MF> +let comment = IniFile.comment IniFile.comment_re "#"
MF> +let sep = IniFile.sep IniFile.sep_re IniFile.sep_default
MF> +let indent = del /[ \t]*/ " "
MF> +
MF> +(* Import useful INI File primitives *)
MF> +let eol = IniFile.eol
MF> +let empty = IniFile.empty
MF> +let sto_to_comment
MF> + = Util.del_opt_ws " "
MF> + . store /[^;# \t\n][^;#\n]*[^;# \t\n]|[^;# \t\n]/
MF> +
MF> +
MF> +(************************************************************************
MF> + * ENTRY
MF> + * rsyncd.conf allows indented entries, but by default entries outside
MF> + * sections are unindented
MF> + *************************************************************************)
MF> +let entry_re = /[A-Za-z0-9_.-][A-Za-z0-9 _.-]*[A-Za-z0-9_.-]/
MF> +
MF> +let entry = let kw = entry_re in
MF> + [ indent
MF> + . key kw
MF> + . sep
MF> + . sto_to_comment?
MF> + . (comment|eol) ]
MF> + | comment
MF> +
MF> +let anon_entry = let kw = entry_re in
MF> + [ key kw
MF> + . sep
MF> + . sto_to_comment?
MF> + . (comment|eol) ]
MF> + | comment
MF> +
MF> +(************************************************************************
MF> + * RECORD & TITLE
MF> + * We use IniFile.title_label because there can be entries
MF> + * outside of sections whose labels would conflict with section names
MF> + *************************************************************************)
MF> +let title = IniFile.title ( IniFile.record_re - /.anon/ )
MF> +let record = IniFile.record title entry
MF> +
MF> +let record_anon = [ label ".anon" . ( anon_entry | empty )+ ]
MF> +
MF> +(************************************************************************
MF> + * LENS & FILTER
MF> + * There can be entries before any section
MF> + * IniFile.entry includes comment management, so we just pass entry to lns
MF> + *************************************************************************)
MF> +let lns = record_anon? . record*
MF> +
MF> +let filter = (incl "/etc/rsyncd.conf")
MF> +
MF> +let xfm = transform lns filter
MF> diff --git a/lenses/tests/test_rsyncd.aug b/lenses/tests/test_rsyncd.aug
MF> new file mode 100644
MF> index 0000000..1eb62be
MF> --- /dev/null
MF> +++ b/lenses/tests/test_rsyncd.aug
MF> @@ -0,0 +1,56 @@
MF> +module Test_rsyncd =
MF> +
MF> + let conf = "
MF> +# A more sophisticated example would be:
MF> +
MF> +uid = nobody
MF> +gid = nobody
MF> +use chroot = yes
MF> +max connections = 4
MF> +syslog facility = local5
MF> +pid file = /var/run/rsyncd.pid
MF> +
MF> +[ftp]
MF> + # this is a comment
MF> + path = /var/ftp/./pub
MF> + comment = whole ftp area (approx 6.1 GB)
MF> +
MF> +[cvs]
MF> + ; comment with semicolon
MF> + path = /data/cvs
MF> + comment = CVS repository (requires authentication)
MF> + auth users = tridge, susan # comment at EOL
MF> + secrets file = /etc/rsyncd.secrets
MF> +
MF> +"
MF> +
MF> + test Rsyncd.lns get conf =
MF> + { ".anon"
MF> + {}
MF> + { "#comment" = "A more sophisticated example would be:" }
MF> + {}
MF> + { "uid" = "nobody" }
MF> + { "gid" = "nobody" }
MF> + { "use chroot" = "yes" }
MF> + { "max connections" = "4" }
MF> + { "syslog facility" = "local5" }
MF> + { "pid file" = "/var/run/rsyncd.pid" }
MF> + {}
MF> + }
MF> + { "ftp"
MF> + { "#comment" = "this is a comment" }
MF> + { "path" = "/var/ftp/./pub" }
MF> + { "comment" = "whole ftp area (approx 6.1 GB)" }
MF> + {}
MF> + }
MF> + { "cvs"
MF> + { "#comment" = "comment with semicolon" }
MF> + { "path" = "/data/cvs" }
MF> + { "comment" = "CVS repository (requires authentication)" }
MF> + { "auth users" = "tridge, susan"
MF> + { "#comment" = "comment at EOL" }
MF> + }
MF> + { "secrets file" = "/etc/rsyncd.secrets" }
MF> + {}
MF> + }
MF> +
More information about the augeas-devel
mailing list