[augeas-devel] [PATCH] group lens

free at 64studio.com free at 64studio.com
Sat Dec 20 11:32:12 UTC 2008


commit 5658eb76a4a1d51c1a381a262bbacacc375767f3
Author: Free Ekanayaka <free at 64studio.com>
Date:   Sat Dec 20 00:20:52 2008 +0000

    Add lens and test for /etc/group

diff --git a/lenses/group.aug b/lenses/group.aug
new file mode 100644
index 0000000..0b19aec
--- /dev/null
+++ b/lenses/group.aug
@@ -0,0 +1,48 @@
+(* Group module for Augeas
+ Author: Free Ekanayaka <free at 64studio.com>
+
+ Reference: man 5 group
+
+*)
+
+module Group =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let comment    = Util.comment
+let empty      = Util.empty
+
+let colon      = del /:/ ":"
+
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+let word       = /[A-Za-z0-9_.-]+/
+let integer    = /[0-9]+/
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry     = [ key word
+                . colon
+                . [ label "password" . store word    . colon ]
+                . [ label "gid"      . store integer . colon ]
+                . [ label "users"    . sto_to_eol? ]
+                . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter
+               = incl "/etc/group"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/tests/test_group.aug b/lenses/tests/test_group.aug
new file mode 100644
index 0000000..41af11f
--- /dev/null
+++ b/lenses/tests/test_group.aug
@@ -0,0 +1,20 @@
+module Test_group =
+
+let conf = "bin:x:2:
+audio:x:29:joe
+avahi-autoipd:x:113:bill,martha
+"
+
+test Group.lns get conf =
+   { "bin"
+     { "password" = "x" }
+     { "gid" = "2" }
+     { "users" } }
+   { "audio"
+     { "password" = "x" }
+     { "gid" = "29" }
+     { "users" = "joe" } }
+   { "avahi-autoipd"
+     { "password" = "x" }
+     { "gid" = "113" }
+     { "users" = "bill,martha"} }




More information about the augeas-devel mailing list