[augeas-devel] augeas: master - Lokkit: make argument for --trust more permissive

David Lutterkort lutter at fedoraproject.org
Fri Oct 9 17:21:01 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=f20876e094081e77e3ec9b857bb824c10095bbbe
Commit:        f20876e094081e77e3ec9b857bb824c10095bbbe
Parent:        05b7dfdd948af00c7c9d1524b53517bc2e233567
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Fri Oct 9 10:15:12 2009 -0700
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Fri Oct 9 10:19:16 2009 -0700

Lokkit: make argument for --trust more permissive

The --trust option takes an interface name, whcih can be more than what
token accepts.

  * lenses/lokkit.aug (trust): new lens; (entry): use trust
  * lenses/rx.aug (device_name): new regexp
  * lenses/tests/test_lokkit.aug: new test for more permissive device names
---
 lenses/lokkit.aug            |    8 +++++++-
 lenses/rx.aug                |    6 ++++++
 lenses/tests/test_lokkit.aug |    6 ++++++
 3 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/lenses/lokkit.aug b/lenses/lokkit.aug
index 692f361..d68db5f 100644
--- a/lenses/lokkit.aug
+++ b/lenses/lokkit.aug
@@ -26,6 +26,12 @@ let option (l:string) (s:string) =
 let opt (l:string) (s:string) =
   [ option l s . token . eol ]
 
+(* trust directive
+   -t <interface>, --trust=<interface>
+*)
+let trust =
+  [ option "trust" "t" . store Rx.device_name . eol ]
+
 (* port directive
    -p <port>[-<port>]:<protocol>, --port=<port>[-<port>]:<protocol>
 *)
@@ -68,7 +74,7 @@ let entry =
  |flag /enabled|disabled/
  |opt "service" "s"
  |port
- |opt "trust" "t"
+ |trust
  |opt "masq" "m"
  |custom_rules
  |forward_port
diff --git a/lenses/rx.aug b/lenses/rx.aug
index 482a3ec..d79c897 100644
--- a/lenses/rx.aug
+++ b/lenses/rx.aug
@@ -65,3 +65,9 @@ let ipv6 =
   | /(([0-9A-Fa-f]{1,4}:){1,7}:)/
 
 let ip        = ipv4 | ipv6
+
+(*
+ * A Linux device name like eth0 or i2c-0. Might still be too restrictive
+ *)
+
+let device_name = /[a-zA-Z0-9_?.+:-]+/
diff --git a/lenses/tests/test_lokkit.aug b/lenses/tests/test_lokkit.aug
index d2c52ec..8302d9c 100644
--- a/lenses/tests/test_lokkit.aug
+++ b/lenses/tests/test_lokkit.aug
@@ -76,3 +76,9 @@ test Lokkit.custom_rules get
 test Lokkit.custom_rules get
 "--custom-rules=/some/file\n" =
   { "custom-rules" = "/some/file" }
+
+test Lokkit.lns get
+"--trust=tun+\n--trust=eth0.42\n--trust=eth0:1\n" =
+  { "trust" = "tun+" }
+  { "trust" = "eth0.42" }
+  { "trust" = "eth0:1" }




More information about the augeas-devel mailing list