[augeas-devel] [PATCH] postfix lenses

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


commit 6cf38d1c8696035e44646a69a3acc91c6b9ddc37
Author: Free Ekanayaka <free at 64studio.com>
Date:   Sat Dec 20 00:26:31 2008 +0000

    Add lenses and tests for postfix's main.cf and master.cf

diff --git a/lenses/postfix_main.aug b/lenses/postfix_main.aug
new file mode 100644
index 0000000..8c290de
--- /dev/null
+++ b/lenses/postfix_main.aug
@@ -0,0 +1,45 @@
+(* Postfix_Main module for Augeas
+ Author: Free Ekanayaka <free at 64studio.com>
+
+ Reference:
+
+
+*)
+
+module Postfix_Main =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let spc        = Util.del_ws_spc
+let indent     = del /[ \t]*/ " "
+let comment    = Util.comment
+let empty      = Util.empty
+let eq         = del /[ \t]*=/ " ="
+
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+let sto_to_spc = store /[^ \t\n]+/
+
+let word       = /[A-Za-z0-9_.-]+/
+let value      = [ key word . spc . sto_to_eol . eol ]
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry     = [ key word . eq . (indent . sto_to_eol)? . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter     = incl "/etc/postfix/main.cf"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/postfix_master.aug b/lenses/postfix_master.aug
new file mode 100644
index 0000000..afe20bf
--- /dev/null
+++ b/lenses/postfix_master.aug
@@ -0,0 +1,54 @@
+(* Postfix_Master module for Augeas
+ Author: Free Ekanayaka <free at 64studio.com>
+
+ Reference:
+
+*)
+
+module Postfix_Master =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let ws         = del /[ \t\n]+/ " "
+let comment    = Util.comment
+let empty      = Util.empty
+
+let word       = /[A-Za-z0-9_.-]+/
+let words      = /[A-Za-z0-9$(){}=!_.-][A-Za-z0-9$!(){} =\/_.-]*[A-Za-z0-9$!(){}=\/_.-]/
+
+let bool       = /y|n|-/
+let integer    = /([0-9]+|-)\??/
+let command   = words . (/\n[ \t]+/ . words)*
+
+let field (l:string) (r:regexp)
+               = [ label l . store r ]
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry     = [ key word . ws
+                . field "type"         /inet|unix|fifo|pass/  . ws
+                . field "private"      bool                   . ws
+                . field "unpriviliged" bool                   . ws
+                . field "chroot"       bool                   . ws
+                . field "wakeup"       integer                . ws
+                . field "limit"        integer                . ws
+                . field "command"      command
+                . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter     = incl "/etc/postfix/master.cf"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/tests/test_postfix_main.aug b/lenses/tests/test_postfix_main.aug
new file mode 100644
index 0000000..6a9f7d4
--- /dev/null
+++ b/lenses/tests/test_postfix_main.aug
@@ -0,0 +1,17 @@
+module Test_postfix_main =
+
+let conf = "# main.cf
+myorigin = /etc/mailname
+
+smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
+mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
+relayhost = 
+"
+
+test Postfix_Main.lns get conf =
+   { "#comment"  = "main.cf" }
+   { "myorigin"  = "/etc/mailname" }
+   {}
+   { "smtpd_banner" = "$myhostname ESMTP $mail_name (Ubuntu)" }
+   { "mynetworks" = "127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128" }
+   { "relayhost"  }
diff --git a/lenses/tests/test_postfix_master.aug b/lenses/tests/test_postfix_master.aug
new file mode 100644
index 0000000..285ec3a
--- /dev/null
+++ b/lenses/tests/test_postfix_master.aug
@@ -0,0 +1,26 @@
+module Test_postfix_master =
+
+let conf = "# master.cf
+smtp      inet  n       -       -       10?       -       smtpd
+maildrop  unix  -       n       n       -       -       pipe
+  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
+"
+
+test Postfix_Master.lns get conf =
+   { "#comment"  = "master.cf" }
+   { "smtp"
+     { "type" = "inet" }
+     { "private" = "n" }
+     { "unpriviliged" = "-" }
+     { "chroot" = "-" }
+     { "wakeup" = "10?" }
+     { "limit" = "-" } 
+     { "command" = "smtpd" } }
+   { "maildrop"
+     { "type" = "unix" }
+     { "private" = "-" }
+     { "unpriviliged" = "n" }
+     { "chroot" = "n" }
+     { "wakeup" = "-" }
+     { "limit" = "-" } 
+     { "command" = "pipe\n  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}" } }




More information about the augeas-devel mailing list