[augeas-devel] [PATCH] Lens for /etc/exports
David Lutterkort
dlutter at redhat.com
Fri Jul 4 05:22:57 UTC 2008
2 files changed, 54 insertions(+)
lenses/exports.aug | 25 +++++++++++++++++++++++++
lenses/tests/test_exports.aug | 29 +++++++++++++++++++++++++++++
# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1215148973 25200
# Node ID 0dae0cabcd63482e1e7a48c7334d13998cbd7c35
# Parent 13fdcd9bb18a45eb897cd67b8c506917f71605e2
Lens for /etc/exports
diff -r 13fdcd9bb18a -r 0dae0cabcd63 lenses/exports.aug
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lenses/exports.aug Thu Jul 03 22:22:53 2008 -0700
@@ -0,0 +1,25 @@
+(* Lens for Linux syntax of NFS exports(5) *)
+module Exports =
+ autoload xfm
+
+ let client_re = /[a-zA-Z0-9\-\.@\*\?\/]+/
+
+ let eol = del /[ \t]*\n/ "\n"
+
+ let comment = Hosts.comment
+
+ let option = [ label "option" . store /[^,)]+/ ]
+
+ let client = [ label "client" . store client_re .
+ ( Util.del_str "(" .
+ option .
+ ( Util.del_str "," . option ) * .
+ Util.del_str ")" )? ]
+
+ let entry = [ label "dir" . store /\/[^ \t]*/ .
+ Util.del_ws_spc .
+ client . (Util.del_ws_spc . client)* . eol ]
+
+ let lns = (entry | comment)*
+
+ let xfm = transform lns (incl "/etc/exports")
diff -r 13fdcd9bb18a -r 0dae0cabcd63 lenses/tests/test_exports.aug
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lenses/tests/test_exports.aug Thu Jul 03 22:22:53 2008 -0700
@@ -0,0 +1,29 @@
+module Test_exports =
+
+ let s = "/local 172.31.0.0/16(rw,sync) \t
+
+/home 172.31.0.0/16(rw,root_squash,sync) @netgroup(rw) *.example.com
+# Yes, we export /tmp
+/tmp 172.31.0.0/16(rw,root_squash,sync)\n"
+
+ test Exports.lns get s =
+ { "dir" = "/local"
+ { "client" = "172.31.0.0/16"
+ { "option" = "rw" }
+ { "option" = "sync" } } }
+ { }
+ { "dir" = "/home"
+ { "client" = "172.31.0.0/16"
+ { "option" = "rw"}
+ { "option" = "root_squash" }
+ { "option" = "sync" } }
+ { "client" = "@netgroup"
+ { "option" = "rw" } }
+ { "client" = "*.example.com" } }
+ { }
+ { "dir" = "/tmp"
+ { "client" = "172.31.0.0/16"
+ { "option" = "rw" }
+ { "option" = "root_squash" }
+ { "option" = "sync" } } }
+
More information about the augeas-devel
mailing list