Blame SOURCES/0007-Dhcpd-revert-Dhcpd-module-to-1.1.0-compatible-add-Dh.patch

84dac3
From c93dc5ca4c87f38772c98e3134ddc6662a98bc02 Mon Sep 17 00:00:00 2001
84dac3
From: Dominic Cleal <dcleal@redhat.com>
84dac3
Date: Fri, 12 Jun 2015 11:09:09 +0100
84dac3
Subject: [PATCH] Dhcpd: revert Dhcpd module to 1.1.0-compatible, add Dhcpd_140
84dac3
84dac3
In order to keep the default sshd config lens compatible with 1.1.0,
84dac3
the lens from 1.4.0 has been kept in the Dhcpd_140 module and is not
84dac3
loaded by default.  Use aug_transform, augtool --transform etc. to use
84dac3
it instead of Dhcpd.
84dac3
---
c5f980
 lenses/dhcpd.aug                | 182 ++--------
c5f980
 lenses/dhcpd_140.aug            | 512 +++++++++++++++++++++++++++
c5f980
 lenses/tests/test_dhcpd.aug     | 214 +----------
c5f980
 lenses/tests/test_dhcpd_140.aug | 606 ++++++++++++++++++++++++++++++++
84dac3
 tests/Makefile.am               |   1 +
84dac3
 5 files changed, 1152 insertions(+), 363 deletions(-)
84dac3
 create mode 100644 lenses/dhcpd_140.aug
84dac3
 create mode 100644 lenses/tests/test_dhcpd_140.aug
84dac3
84dac3
diff --git a/lenses/dhcpd.aug b/lenses/dhcpd.aug
84dac3
index f84a409c..21a5ce60 100644
84dac3
--- a/lenses/dhcpd.aug
84dac3
+++ b/lenses/dhcpd.aug
84dac3
@@ -65,12 +65,12 @@ let eos               = comment?
84dac3
 let sep_spc           = del /[ \t]+/ " "
84dac3
 let sep_osp           = del /[ \t]*/ ""
84dac3
 let sep_scl           = del /[ \t]*;([ \t]*\n)*/ ";\n"
84dac3
-let sep_obr           = del /[ \t\n]*\{([ \t]*\n)*/ " {\n"
84dac3
+let sep_obr           = del /[ \t]*\{([ \t]*\n)*/ " {\n"
84dac3
 let sep_cbr           = del /[ \t]*\}([ \t]*\n)*/ "}\n"
84dac3
 let sep_com           = del /[ \t\n]*,[ \t\n]*/ ", "
84dac3
 let sep_slh           = del "\/" "/"
84dac3
 let sep_col           = del ":" ":"
84dac3
-let sep_eq            = del /[ \t\n]*=[ \t\n]*/ "="
84dac3
+let sep_eq            = del /[ \t]*=[ \t]*/ "="
84dac3
 let scl               = del ";" ";"
84dac3
 
84dac3
 (* Define basic types *)
84dac3
@@ -94,11 +94,6 @@ let ip                = Rx.ipv4
84dac3
   let bare = del qchar? "" . store (bchar+) . del qchar? ""
84dac3
   let quote = Quote.do_quote (store (bchar* . /[ \t'\/]/ . bchar*)+)
84dac3
   let dquote = Quote.do_dquote (store (bchar+))
84dac3
-  (* these two are for special cases.  bare_to_scl is for any bareword that is
84dac3
-   * space or semicolon terminated.  dquote_any allows almost any character in
84dac3
-   * between the quotes. *)
84dac3
-  let bare_to_scl = Quote.do_dquote_opt (store /[^" \t\n;]+/)
84dac3
-  let dquote_any = Quote.do_dquote (store /[^"\n]*[ \t]+[^"\n]*/)
84dac3
 
84dac3
 let sto_to_spc        = store /[^\\#,;\{\}" \t\n]+|"[^\\#"\n]+"/
84dac3
 let sto_to_scl        = store /[^ \t;][^;\n=]+[^ \t;]|[^ \t;=]+/
84dac3
@@ -197,7 +192,6 @@ let stmt_string_re    = "ddns-update-style"
84dac3
                       | "use-lease-addr-for-default-route"
84dac3
                       | "vendor-option-space"
84dac3
                       | "primary"
84dac3
-                      | "omapi-key"
84dac3
 
84dac3
 let stmt_string_tpl (kw:regexp) (l:lens) = [ indent
84dac3
                         . key kw
84dac3
@@ -230,51 +224,26 @@ let stmt_range        = [ indent
84dac3
 let stmt_hardware     = [ indent
84dac3
                         . key "hardware"
84dac3
                         . sep_spc
84dac3
-                        . [ label "type" . store /ethernet|tokenring|fddi/ ]
84dac3
+                        . [ label "type" . store /ethernet|tokenring/ ]
84dac3
                         . sep_spc
84dac3
                         . [ label "address" . store /[a-fA-F0-9:-]+/ ]
84dac3
                         . sep_scl
84dac3
                         . eos ]
84dac3
 
7b8067
-(************************************************************************
84dac3
- *                         SET STATEMENTS
84dac3
- *************************************************************************)
84dac3
-let stmt_set          = [ indent
84dac3
-                        . key "set"
84dac3
-                        . sep_spc
84dac3
-                        . store word
84dac3
-                        . sep_spc
84dac3
-                        . Sep.equal
84dac3
-                        . sep_spc
84dac3
-                        . [ label "value" . sto_to_scl ]
84dac3
-                        . sep_scl
84dac3
-                        . eos ]
84dac3
-
7b8067
 (************************************************************************
84dac3
  *                         OPTION STATEMENTS
84dac3
  *************************************************************************)
84dac3
 (* The general case is considering options as a list *)
84dac3
 
84dac3
+let stmt_option_code  = [ label "label" . store word . sep_spc ]
84dac3
+                        . [ key "code" . sep_spc . store word ]
84dac3
+                        . sep_eq
84dac3
+                        . [ label "type" . store word ]
84dac3
 
84dac3
-let stmt_option_value = /((array of[ \t]+)?(((un)?signed[ \t]+)?integer (8|16|32)|string|ip6?-address|boolean|domain-list|text)|encapsulate [A-Za-z0-9_.-]+)/
84dac3
 
84dac3
 let stmt_option_list  = ([ label "arg" . bare ] | [ label "arg" . quote ])
84dac3
                         . ( sep_com . ([ label "arg" . bare ] | [ label "arg" . quote ]))*
84dac3
 
84dac3
-let del_trail_spc = del /[ \t\n]*/ ""
84dac3
-
84dac3
-let stmt_record = counter "record" . Util.del_str "{"
84dac3
-                . sep_spc
84dac3
-                . ([seq "record" . store stmt_option_value . sep_com]*
84dac3
-                .  [seq "record" . store stmt_option_value . del_trail_spc])?
84dac3
-                . Util.del_str "}"
84dac3
-
84dac3
-let stmt_option_code  = [ label "label" . store word . sep_spc ]
84dac3
-                        . [ key "code" . sep_spc . store word ]
84dac3
-                        . sep_eq
84dac3
-                        . ([ label "type" . store stmt_option_value ]
84dac3
-                          |[ label "record" . stmt_record ]) 
84dac3
-
84dac3
 let stmt_option_basic = [ key word . sep_spc . stmt_option_list ]
84dac3
 let stmt_option_extra = [ key word . sep_spc . store /true|false/ . sep_spc . stmt_option_list ]
84dac3
 
84dac3
@@ -302,13 +271,10 @@ let stmt_option = stmt_option1 | stmt_option2
84dac3
 (* this statement is not well documented in the manual dhcpd.conf
84dac3
    we support basic use case *)
84dac3
 
84dac3
-let stmt_subclass = [ indent . key "subclass" . sep_spc 
84dac3
-                      . ( [ label "name" .  bare_to_scl ]|[ label "name" .  dquote_any ] )
84dac3
-                      . sep_spc 
84dac3
-                      . ( [ label "value" . bare_to_scl ]|[ label "value" . dquote_any ] ) 
84dac3
-                      . sep_scl 
84dac3
-                      . eos ]
84dac3
-
84dac3
+let stmt_subclass = [ indent . key "subclass" . sep_spc .
84dac3
+                      ([ label "name" . quote ]|
84dac3
+                       [ label "name" . bare ]) . sep_spc .
84dac3
+                       [ label "value" . bare ] . sep_scl . eos ]
84dac3
 
84dac3
 (************************************************************************
84dac3
  *                         ALLOW/DENY STATEMENTS
84dac3
@@ -316,18 +282,10 @@ let stmt_subclass = [ indent . key "subclass" . sep_spc
84dac3
 (* We have to use special key for allow/deny members of
84dac3
   to avoid ambiguity in the put direction *)
84dac3
 
84dac3
-let allow_deny_re     = /unknown(-|[ ]+)clients/
84dac3
-                      | /known(-|[ ]+)clients/
84dac3
-                      | /all[ ]+clients/
84dac3
+let allow_deny_re     = "unknown-clients"
84dac3
                       | /dynamic[ ]+bootp[ ]+clients/
84dac3
                       | /authenticated[ ]+clients/
84dac3
                       | /unauthenticated[ ]+clients/
84dac3
-                      | "bootp"
84dac3
-                      | "booting"
84dac3
-                      | "duplicates"
84dac3
-                      | "declines"
84dac3
-                      | "client-updates"
84dac3
-                      | "leasequery"
84dac3
 
84dac3
 let stmt_secu_re      = "allow"
84dac3
                       | "deny"
84dac3
@@ -335,17 +293,9 @@ let stmt_secu_re      = "allow"
84dac3
 let del_allow = del /allow[ ]+members[ ]+of/ "allow members of"
84dac3
 let del_deny  = del /deny[ \t]+members[ \t]+of/ "deny members of"
84dac3
 
84dac3
-(* bare is anything but whitespace, quote marks or semicolon.
84dac3
- * technically this should be locked down to mostly alphanumerics, but the
84dac3
- * idea right now is just to make things work.  Also ideally I would use
84dac3
- * dquote_space but I had a whale of a time with it.  It doesn't like
84dac3
- * semicolon termination and my attempts to fix that led me to 3 hours of
84dac3
- * frustration and back to this :)
84dac3
- *)
84dac3
 let stmt_secu_tpl (l:lens) (s:string) =
84dac3
-                  [ indent . l . sep_spc . label s . bare_to_scl . sep_scl . eos ] |
84dac3
-                  [ indent . l . sep_spc . label s . dquote_any . sep_scl . eos ]
84dac3
-
84dac3
+                  [ indent . l . sep_spc . label s . bare . sep_scl . eos ] |
84dac3
+                  [ indent . l . sep_spc . label s . quote . sep_scl . eos ]
84dac3
 
84dac3
 let stmt_secu         = [ indent . key stmt_secu_re . sep_spc .
84dac3
                           store allow_deny_re . sep_scl . eos ] |
84dac3
@@ -356,62 +306,17 @@ let stmt_secu         = [ indent . key stmt_secu_re . sep_spc .
84dac3
  *                         MATCH STATEMENTS
84dac3
  *************************************************************************)
84dac3
 
84dac3
+let sto_fct = store (word . /[ \t]*\([^)]*\)/)
84dac3
+let sto_option = store (/option[ ]+/ . word)
84dac3
 let sto_com = /[^ \t\n,\(\)][^,\(\)]*[^ \t\n,\(\)]|[^ \t\n,\(\)]+/ | word . /[ \t]*\([^)]*\)/
84dac3
-(* this is already the most complicated part of this module and it's about to
84dac3
- * get worse.  match statements can be way more complicated than this
84dac3
- *
84dac3
- * examples:
84dac3
- *      using or:
84dac3
- *      match if ((option vendor-class-identifier="Banana Bready") or (option vendor-class-identifier="Cherry Sunfire"));
84dac3
- *      unneeded parenthesis:
84dac3
- *      match if (option vendor-class-identifier="Hello");
84dac3
- *
84dac3
- *      and of course the fact that the above two rules used one of infinately
84dac3
- *      many potential options instead of a builtin function.
84dac3
- *)
84dac3
-(* sto_com doesn't support quoted strings as arguments.  It also doesn't
84dac3
-   support single arguments (needs to match a comma) It will need to be
84dac3
-   updated for lcase, ucase and log to be workable.
84dac3
-
84dac3
-   it also doesn't support no arguments, so gethostbyname() doesn't work.
84dac3
-
84dac3
-   option and config-option are considered operators.  They should be matched
84dac3
-   in stmt_entry but also available under "match if" and "if" conditionals
84dac3
-   leased-address, host-decl-name, both take no args and return a value.  We
84dac3
-   might need to treat them as variable names in the parser.
84dac3
-
84dac3
-   things like this may be near-impossible to parse even with recursion
84dac3
-   because we have no way of knowing when or if a subfunction takes arguments
84dac3
-   set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
84dac3
-
84dac3
-   even if we could parse it, they could get arbitrarily complicated like:
84dac3
-   binary-to-ascii(16, 8, ":", substring(hardware, 1, 6) and substring(hardware, 2, 3));
84dac3
-
84dac3
-   so at some point we may need to programmatically knock it off and tell
84dac3
-   people to put weird stuff in an include file that augeas doesn't parse.
84dac3
-
84dac3
-   the other option is to change the API to not parse the if statement at all,
84dac3
-   just pull in the conditional as a string.
84dac3
- *)
84dac3
-
84dac3
-let fct_re = "substring" | "binary-to-ascii" | "suffix" | "lcase" | "ucase"
84dac3
-             | "gethostbyname" | "packet"
84dac3
-             | "concat" | "reverse" | "encode-int"
84dac3
-             | "extract-int" | "lease-time" | "client-state" | "exists" | "known" | "static"
84dac3
-             | "pick-first-value" | "log" | "execute"
84dac3
-
84dac3
-(* not needs to be different because it's a negation of whatever happens next *)
84dac3
-let op_re = "~="|"="|"~~"|"and"|"or"
84dac3
+let fct_re = "substring" | "binary-to-ascii"
84dac3
 
84dac3
 let fct_args = [ label "args" . dels "(" . sep_osp .
84dac3
                  ([ label "arg" . store sto_com ] . [ label "arg" . sep_com . store sto_com ]+) .
84dac3
                         sep_osp . dels ")" ]
84dac3
 
84dac3
-let stmt_match_ifopt = [ dels "if" . sep_spc . key "option" . sep_spc . store word .
84dac3
-                      sep_eq . ([ label "value" . bare_to_scl ]|[ label "value" . dquote_any ]) ]
84dac3
-
84dac3
-let stmt_match_func = [ store fct_re . sep_osp . label "function" . fct_args ] .
84dac3
-                      sep_eq . ([ label "value" . bare_to_scl ]|[ label "value" . dquote_any ])
84dac3
+let stmt_match_if = [ dels "if" . sep_spc . store fct_re . sep_osp . label "function" . fct_args ] .
84dac3
+                      sep_eq . ([ label "value" . bare ]|[ label "value" . quote ])
84dac3
 
84dac3
 let stmt_match_pfv = [ label "function" . store "pick-first-value" . sep_spc .
84dac3
                        dels "(" . sep_osp .
84dac3
@@ -422,7 +327,7 @@ let stmt_match_pfv = [ label "function" . store "pick-first-value" . sep_spc .
84dac3
 
84dac3
 let stmt_match_tpl (l:lens) = [ indent . key "match" . sep_spc . l . sep_scl . eos ]
84dac3
 
84dac3
-let stmt_match = stmt_match_tpl (dels "if" . sep_spc . stmt_match_func | stmt_match_pfv | stmt_match_ifopt)
84dac3
+let stmt_match = stmt_match_tpl (stmt_match_if | stmt_match_pfv )
84dac3
 
84dac3
 (************************************************************************
84dac3
  *                         BLOCK STATEMENTS
84dac3
@@ -438,11 +343,12 @@ let stmt_entry        =   stmt_secu
84dac3
                         | stmt_noarg
84dac3
                         | stmt_match
84dac3
                         | stmt_subclass
84dac3
-                        | stmt_set
84dac3
                         | empty
84dac3
                         | comment
84dac3
 
84dac3
-let stmt_block_noarg_re = "pool" | "group"
84dac3
+let stmt_block_noarg_re = "pool"
84dac3
+                        | "group"
84dac3
+                        | "allow-update"
84dac3
 
84dac3
 let stmt_block_noarg (body:lens)
84dac3
                         = [ indent
84dac3
@@ -456,14 +362,16 @@ let stmt_block_arg_re = "host"
84dac3
                       | "shared-network"
84dac3
                       | /failover[ ]+peer/
84dac3
                       | "zone"
84dac3
-                      | "group"
84dac3
-                      | "on"
84dac3
+                      | "key"
84dac3
 
84dac3
 let stmt_block_arg (body:lens)
84dac3
-                      = ([ indent . key stmt_block_arg_re . sep_spc . dquote_any . sep_obr . body* . sep_cbr ]
84dac3
-                         |[ indent . key stmt_block_arg_re . sep_spc . bare_to_scl . sep_obr . body* . sep_cbr ]
84dac3
-                         |[ indent . del /key/ "key" . label "key_block" . sep_spc . dquote_any . sep_obr . body* . sep_cbr . del /(;([ \t]*\n)*)?/ ""  ]
84dac3
-                         |[ indent . del /key/ "key" . label "key_block" . sep_spc . bare_to_scl . sep_obr . body* . sep_cbr . del /(;([ \t]*\n)*)?/ "" ])
84dac3
+                      = [ indent
84dac3
+                        . key stmt_block_arg_re
84dac3
+                        . sep_spc
84dac3
+                        . sto_to_spc
84dac3
+                        . sep_obr
84dac3
+                        . body*
84dac3
+                        . sep_cbr ]
84dac3
 
84dac3
 let stmt_block_subnet (body:lens)
84dac3
                       = [ indent
84dac3
@@ -476,37 +384,11 @@ let stmt_block_subnet (body:lens)
84dac3
                         . body*
84dac3
                         . sep_cbr ]
84dac3
 
84dac3
-let conditional (body:lens) =
84dac3
-     let condition         = /[^{ \r\t\n][^{\n]*[^{ \r\t\n]|[^{ \t\n\r]/
84dac3
-  in let elsif = [ indent
84dac3
-                 . Build.xchgs "elsif" "@elsif"
84dac3
-                 . sep_spc
84dac3
-                 . store condition
84dac3
-                 . sep_obr
84dac3
-                 . body*
84dac3
-                 . sep_cbr ]
84dac3
-  in let else = [  indent
84dac3
-                 . Build.xchgs "else" "@else"
84dac3
-                 . sep_obr
84dac3
-                 . body*
84dac3
-                 . sep_cbr ]
84dac3
-  in [ indent
84dac3
-     . Build.xchgs "if" "@if"
84dac3
-     . sep_spc
84dac3
-     . store condition
84dac3
-     . sep_obr
84dac3
-     . body*
84dac3
-     . sep_cbr
84dac3
-     . elsif*
84dac3
-     . else? ]
84dac3
-
84dac3
-
84dac3
 let all_block (body:lens) =
84dac3
     let lns1 = stmt_block_subnet body in
84dac3
     let lns2 = stmt_block_arg body in
84dac3
     let lns3 = stmt_block_noarg body in
84dac3
-    let lns4 = conditional body in
84dac3
-    (lns1 | lns2 | lns3 | lns4 | stmt_entry)
84dac3
+    (lns1 | lns2 | lns3 | stmt_entry)
84dac3
 
84dac3
 let rec lns_staging = stmt_entry|all_block lns_staging
84dac3
 let lns = (lns_staging)*
84dac3
diff --git a/lenses/dhcpd_140.aug b/lenses/dhcpd_140.aug
84dac3
new file mode 100644
84dac3
index 00000000..c9072990
84dac3
--- /dev/null
84dac3
+++ b/lenses/dhcpd_140.aug
84dac3
@@ -0,0 +1,512 @@
84dac3
+(*
84dac3
+Module: Dhcpd_140
84dac3
+  BIND dhcp 3 server configuration module for Augeas
84dac3
+
84dac3
+  This module is compatible with Augeas 1.4.0, but is not loaded by default.
84dac3
+
84dac3
+Author: Francis Giraldeau <francis.giraldeau@usherbrooke.ca>
84dac3
+
84dac3
+About: Reference
84dac3
+  Reference: manual of dhcpd.conf and dhcp-eval
84dac3
+  Follow dhclient module for tree structure
84dac3
+
84dac3
+About: License
84dac3
+    This file is licensed under the GPL.
84dac3
+
84dac3
+About: Lens Usage
84dac3
+  Sample usage of this lens in augtool
84dac3
+
84dac3
+  Directive without argument.
84dac3
+  Set this dhcpd server authoritative on the domain.
84dac3
+  > clear /files/etc/dhcp3/dhcpd.conf/authoritative
84dac3
+
84dac3
+  Directives with integer or string argument.
84dac3
+  Set max-lease-time to one hour:
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/max-lease-time 3600
84dac3
+
84dac3
+  Options are declared as a list, even for single values.
84dac3
+  Set the domain of the network:
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name/arg example.org
84dac3
+  Set two name server:
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name-servers/arg[1] foo.example.org
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name-servers/arg[2] bar.example.org
84dac3
+
84dac3
+  Create the subnet 172.16.0.1 with 10 addresses:
84dac3
+  > clear /files/etc/dhcp3/dhcpd.conf/subnet[last() + 1]
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/network 172.16.0.0
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/netmask 255.255.255.0
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/range/from 172.16.0.10
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/range/to 172.16.0.20
84dac3
+
84dac3
+  Create a new group "foo" with one static host. Nodes type and address are ordered.
84dac3
+  > ins group after /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/*[last()]
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[last()]/host foo
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/hardware/type "ethernet"
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/hardware/address "00:00:00:aa:bb:cc"
84dac3
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/fixed-address 172.16.0.100
84dac3
+
84dac3
+About: Configuration files
84dac3
+  This lens applies to /etc/dhcpd3/dhcpd.conf. See <filter>.
84dac3
+*)
84dac3
+
84dac3
+module Dhcpd_140 =
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                           USEFUL PRIMITIVES
84dac3
+ *************************************************************************)
84dac3
+let dels (s:string)   = del s s
84dac3
+let eol               = Util.eol
84dac3
+let comment           = Util.comment
84dac3
+let empty             = Util.empty
84dac3
+let indent            = Util.indent
84dac3
+let eos               = comment?
84dac3
+
84dac3
+(* Define separators *)
84dac3
+let sep_spc           = del /[ \t]+/ " "
84dac3
+let sep_osp           = del /[ \t]*/ ""
84dac3
+let sep_scl           = del /[ \t]*;([ \t]*\n)*/ ";\n"
84dac3
+let sep_obr           = del /[ \t\n]*\{([ \t]*\n)*/ " {\n"
84dac3
+let sep_cbr           = del /[ \t]*\}([ \t]*\n)*/ "}\n"
84dac3
+let sep_com           = del /[ \t\n]*,[ \t\n]*/ ", "
84dac3
+let sep_slh           = del "\/" "/"
84dac3
+let sep_col           = del ":" ":"
84dac3
+let sep_eq            = del /[ \t\n]*=[ \t\n]*/ "="
84dac3
+let scl               = del ";" ";"
84dac3
+
84dac3
+(* Define basic types *)
84dac3
+let word              = /[A-Za-z0-9_.-]+(\[[0-9]+\])?/
84dac3
+let ip                = Rx.ipv4
84dac3
+
84dac3
+(* Define fields *)
84dac3
+
84dac3
+(* adapted from sysconfig.aug *)
84dac3
+  (* Chars allowed in a bare string *)
84dac3
+  let bchar = /[^ \t\n"'\\{}#,()\/]|\\\\./
84dac3
+  let qchar = /["']/  (* " *)
84dac3
+
84dac3
+  (* We split the handling of right hand sides into a few cases:
84dac3
+   *   bare  - strings that contain no spaces, optionally enclosed in
84dac3
+   *           single or double quotes
84dac3
+   *   dquot - strings that contain at least one space, apostrophe or slash
84dac3
+   *           which must be enclosed in double quotes
84dac3
+   *   squot - strings that contain an unescaped double quote
84dac3
+   *)
84dac3
+  let bare = del qchar? "" . store (bchar+) . del qchar? ""
84dac3
+  let quote = Quote.do_quote (store (bchar* . /[ \t'\/]/ . bchar*)+)
84dac3
+  let dquote = Quote.do_dquote (store (bchar+))
84dac3
+  (* these two are for special cases.  bare_to_scl is for any bareword that is
84dac3
+   * space or semicolon terminated.  dquote_any allows almost any character in
84dac3
+   * between the quotes. *)
84dac3
+  let bare_to_scl = Quote.do_dquote_opt (store /[^" \t\n;]+/)
84dac3
+  let dquote_any = Quote.do_dquote (store /[^"\n]*[ \t]+[^"\n]*/)
84dac3
+
84dac3
+let sto_to_spc        = store /[^\\#,;\{\}" \t\n]+|"[^\\#"\n]+"/
84dac3
+let sto_to_scl        = store /[^ \t;][^;\n=]+[^ \t;]|[^ \t;=]+/
84dac3
+
84dac3
+let sto_number        = store /[0-9][0-9]*/
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         NO ARG STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+
84dac3
+let stmt_noarg_re     =   "authoritative"
84dac3
+                        | "primary"
84dac3
+                        | "secondary"
84dac3
+
84dac3
+let stmt_noarg        = [ indent
84dac3
+                        . key stmt_noarg_re
84dac3
+                        . sep_scl
84dac3
+                        . eos ]
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         INT ARG STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+
84dac3
+let stmt_integer_re   = "default-lease-time"
84dac3
+                      | "max-lease-time"
84dac3
+                      | "min-lease-time"
84dac3
+                      | /lease[ ]+limit/
84dac3
+                      | "port"
84dac3
+                      | /peer[ ]+port/
84dac3
+                      | "max-response-delay"
84dac3
+                      | "max-unacked-updates"
84dac3
+                      | "mclt"
84dac3
+                      | "split"
84dac3
+                      | /load[ ]+balance[ ]+max[ ]+seconds/
84dac3
+                      | "max-lease-misbalance"
84dac3
+                      | "max-lease-ownership"
84dac3
+                      | "min-balance"
84dac3
+                      | "max-balance"
84dac3
+                      | "adaptive-lease-time-threshold"
84dac3
+                      | "dynamic-bootp-lease-length"
84dac3
+                      | "local-port"
84dac3
+                      | "min-sec"
84dac3
+                      | "omapi-port"
84dac3
+                      | "ping-timeout"
84dac3
+                      | "remote-port"
84dac3
+
84dac3
+let stmt_integer      = [ indent
84dac3
+                        . key stmt_integer_re
84dac3
+                        . sep_spc
84dac3
+                        . sto_number
84dac3
+                        . sep_scl
84dac3
+                        . eos ]
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         STRING ARG STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+
84dac3
+let stmt_string_re    = "ddns-update-style"
84dac3
+                      | "ddns-updates"
84dac3
+                      | "ddns-hostname"
84dac3
+                      | "ddns-domainname"
84dac3
+                      | "ddns-rev-domainname"
84dac3
+                      | "log-facility"
84dac3
+                      | "server-name"
84dac3
+                      | "fixed-address"
84dac3
+                      | /failover[ ]+peer/
84dac3
+                      | "use-host-decl-names"
84dac3
+                      | "next-server"
84dac3
+                      | "address"
84dac3
+                      | /peer[ ]+address/
84dac3
+                      | "type"
84dac3
+                      | "file"
84dac3
+                      | "algorithm"
84dac3
+                      | "secret"
84dac3
+                      | "key"
84dac3
+                      | "include"
84dac3
+                      | "hba"
84dac3
+                      | "boot-unknown-clients"
84dac3
+                      | "db-time-format"
84dac3
+                      | "do-forward-updates"
84dac3
+                      | "dynamic-bootp-lease-cutoff"
84dac3
+                      | "get-lease-hostnames"
84dac3
+                      | "infinite-is-reserved"
84dac3
+                      | "lease-file-name"
84dac3
+                      | "local-address"
84dac3
+                      | "one-lease-per-client"
84dac3
+                      | "pid-file-name"
84dac3
+                      | "ping-check"
84dac3
+                      | "server-identifier"
84dac3
+                      | "site-option-space"
84dac3
+                      | "stash-agent-options"
84dac3
+                      | "update-conflict-detection"
84dac3
+                      | "update-optimization"
84dac3
+                      | "update-static-leases"
84dac3
+                      | "use-host-decl-names"
84dac3
+                      | "use-lease-addr-for-default-route"
84dac3
+                      | "vendor-option-space"
84dac3
+                      | "primary"
84dac3
+                      | "omapi-key"
84dac3
+
84dac3
+let stmt_string_tpl (kw:regexp) (l:lens) = [ indent
84dac3
+                        . key kw
84dac3
+                        . sep_spc
84dac3
+                        . l
84dac3
+                        . sep_scl
84dac3
+                        . eos ]
84dac3
+
84dac3
+let stmt_string  = stmt_string_tpl stmt_string_re bare
84dac3
+                 | stmt_string_tpl stmt_string_re quote
84dac3
+                 | stmt_string_tpl "filename" dquote
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         RANGE STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+
84dac3
+let stmt_range        = [ indent
84dac3
+                        . key "range"
84dac3
+                        . sep_spc
84dac3
+                        . [ label "flag" . store /dynamic-bootp/ . sep_spc ]?
84dac3
+                        . [ label "from" . store ip . sep_spc ]?
84dac3
+                        . [ label "to" . store ip ]
84dac3
+                        . sep_scl
84dac3
+                        . eos ]
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         HARDWARE STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+
84dac3
+let stmt_hardware     = [ indent
84dac3
+                        . key "hardware"
84dac3
+                        . sep_spc
84dac3
+                        . [ label "type" . store /ethernet|tokenring|fddi/ ]
84dac3
+                        . sep_spc
84dac3
+                        . [ label "address" . store /[a-fA-F0-9:-]+/ ]
84dac3
+                        . sep_scl
84dac3
+                        . eos ]
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         SET STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+let stmt_set          = [ indent
84dac3
+                        . key "set"
84dac3
+                        . sep_spc
84dac3
+                        . store word
84dac3
+                        . sep_spc
84dac3
+                        . Sep.equal
84dac3
+                        . sep_spc
84dac3
+                        . [ label "value" . sto_to_scl ]
84dac3
+                        . sep_scl
84dac3
+                        . eos ]
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         OPTION STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+(* The general case is considering options as a list *)
84dac3
+
84dac3
+
84dac3
+let stmt_option_value = /((array of[ \t]+)?(((un)?signed[ \t]+)?integer (8|16|32)|string|ip6?-address|boolean|domain-list|text)|encapsulate [A-Za-z0-9_.-]+)/
84dac3
+
84dac3
+let stmt_option_list  = ([ label "arg" . bare ] | [ label "arg" . quote ])
84dac3
+                        . ( sep_com . ([ label "arg" . bare ] | [ label "arg" . quote ]))*
84dac3
+
84dac3
+let del_trail_spc = del /[ \t\n]*/ ""
84dac3
+
84dac3
+let stmt_record = counter "record" . Util.del_str "{"
84dac3
+                . sep_spc
84dac3
+                . ([seq "record" . store stmt_option_value . sep_com]*
84dac3
+                .  [seq "record" . store stmt_option_value . del_trail_spc])?
84dac3
+                . Util.del_str "}"
84dac3
+
84dac3
+let stmt_option_code  = [ label "label" . store word . sep_spc ]
84dac3
+                        . [ key "code" . sep_spc . store word ]
84dac3
+                        . sep_eq
84dac3
+                        . ([ label "type" . store stmt_option_value ]
84dac3
+                          |[ label "record" . stmt_record ]) 
84dac3
+
84dac3
+let stmt_option_basic = [ key word . sep_spc . stmt_option_list ]
84dac3
+let stmt_option_extra = [ key word . sep_spc . store /true|false/ . sep_spc . stmt_option_list ]
84dac3
+
84dac3
+let stmt_option_body = stmt_option_basic | stmt_option_extra
84dac3
+
84dac3
+let stmt_option1  = [ indent
84dac3
+                        . key "option"
84dac3
+                        . sep_spc
84dac3
+                        . stmt_option_body
84dac3
+                        . sep_scl
84dac3
+                        . eos ]
84dac3
+
84dac3
+let stmt_option2  = [ indent
84dac3
+                        . dels "option" . label "rfc-code"
84dac3
+                        . sep_spc
84dac3
+                        . stmt_option_code
84dac3
+                        . sep_scl
84dac3
+                        . eos ]
84dac3
+
84dac3
+let stmt_option = stmt_option1 | stmt_option2
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         SUBCLASS STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+(* this statement is not well documented in the manual dhcpd.conf
84dac3
+   we support basic use case *)
84dac3
+
84dac3
+let stmt_subclass = [ indent . key "subclass" . sep_spc 
84dac3
+                      . ( [ label "name" .  bare_to_scl ]|[ label "name" .  dquote_any ] )
84dac3
+                      . sep_spc 
84dac3
+                      . ( [ label "value" . bare_to_scl ]|[ label "value" . dquote_any ] ) 
84dac3
+                      . sep_scl 
84dac3
+                      . eos ]
84dac3
+
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         ALLOW/DENY STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+(* We have to use special key for allow/deny members of
84dac3
+  to avoid ambiguity in the put direction *)
84dac3
+
84dac3
+let allow_deny_re     = /unknown(-|[ ]+)clients/
84dac3
+                      | /known(-|[ ]+)clients/
84dac3
+                      | /all[ ]+clients/
84dac3
+                      | /dynamic[ ]+bootp[ ]+clients/
84dac3
+                      | /authenticated[ ]+clients/
84dac3
+                      | /unauthenticated[ ]+clients/
84dac3
+                      | "bootp"
84dac3
+                      | "booting"
84dac3
+                      | "duplicates"
84dac3
+                      | "declines"
84dac3
+                      | "client-updates"
84dac3
+                      | "leasequery"
84dac3
+
84dac3
+let stmt_secu_re      = "allow"
84dac3
+                      | "deny"
84dac3
+
84dac3
+let del_allow = del /allow[ ]+members[ ]+of/ "allow members of"
84dac3
+let del_deny  = del /deny[ \t]+members[ \t]+of/ "deny members of"
84dac3
+
84dac3
+(* bare is anything but whitespace, quote marks or semicolon.
84dac3
+ * technically this should be locked down to mostly alphanumerics, but the
84dac3
+ * idea right now is just to make things work.  Also ideally I would use
84dac3
+ * dquote_space but I had a whale of a time with it.  It doesn't like
84dac3
+ * semicolon termination and my attempts to fix that led me to 3 hours of
84dac3
+ * frustration and back to this :)
84dac3
+ *)
84dac3
+let stmt_secu_tpl (l:lens) (s:string) =
84dac3
+                  [ indent . l . sep_spc . label s . bare_to_scl . sep_scl . eos ] |
84dac3
+                  [ indent . l . sep_spc . label s . dquote_any . sep_scl . eos ]
84dac3
+
84dac3
+
84dac3
+let stmt_secu         = [ indent . key stmt_secu_re . sep_spc .
84dac3
+                          store allow_deny_re . sep_scl . eos ] |
84dac3
+                        stmt_secu_tpl del_allow "allow-members-of" |
84dac3
+                        stmt_secu_tpl del_deny "deny-members-of"
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         MATCH STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+
84dac3
+let sto_com = /[^ \t\n,\(\)][^,\(\)]*[^ \t\n,\(\)]|[^ \t\n,\(\)]+/ | word . /[ \t]*\([^)]*\)/
84dac3
+(* this is already the most complicated part of this module and it's about to
84dac3
+ * get worse.  match statements can be way more complicated than this
84dac3
+ *
84dac3
+ * examples:
84dac3
+ *      using or:
84dac3
+ *      match if ((option vendor-class-identifier="Banana Bready") or (option vendor-class-identifier="Cherry Sunfire"));
84dac3
+ *      unneeded parenthesis:
84dac3
+ *      match if (option vendor-class-identifier="Hello");
84dac3
+ *
84dac3
+ *      and of course the fact that the above two rules used one of infinately
84dac3
+ *      many potential options instead of a builtin function.
84dac3
+ *)
84dac3
+(* sto_com doesn't support quoted strings as arguments.  It also doesn't
84dac3
+   support single arguments (needs to match a comma) It will need to be
84dac3
+   updated for lcase, ucase and log to be workable.
84dac3
+
84dac3
+   it also doesn't support no arguments, so gethostbyname() doesn't work.
84dac3
+
84dac3
+   option and config-option are considered operators.  They should be matched
84dac3
+   in stmt_entry but also available under "match if" and "if" conditionals
84dac3
+   leased-address, host-decl-name, both take no args and return a value.  We
84dac3
+   might need to treat them as variable names in the parser.
84dac3
+
84dac3
+   things like this may be near-impossible to parse even with recursion
84dac3
+   because we have no way of knowing when or if a subfunction takes arguments
84dac3
+   set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
84dac3
+
84dac3
+   even if we could parse it, they could get arbitrarily complicated like:
84dac3
+   binary-to-ascii(16, 8, ":", substring(hardware, 1, 6) and substring(hardware, 2, 3));
84dac3
+
84dac3
+   so at some point we may need to programmatically knock it off and tell
84dac3
+   people to put weird stuff in an include file that augeas doesn't parse.
84dac3
+
84dac3
+   the other option is to change the API to not parse the if statement at all,
84dac3
+   just pull in the conditional as a string.
84dac3
+ *)
84dac3
+
84dac3
+let fct_re = "substring" | "binary-to-ascii" | "suffix" | "lcase" | "ucase"
84dac3
+             | "gethostbyname" | "packet"
84dac3
+             | "concat" | "reverse" | "encode-int"
84dac3
+             | "extract-int" | "lease-time" | "client-state" | "exists" | "known" | "static"
84dac3
+             | "pick-first-value" | "log" | "execute"
84dac3
+
84dac3
+(* not needs to be different because it's a negation of whatever happens next *)
84dac3
+let op_re = "~="|"="|"~~"|"and"|"or"
84dac3
+
84dac3
+let fct_args = [ label "args" . dels "(" . sep_osp .
84dac3
+                 ([ label "arg" . store sto_com ] . [ label "arg" . sep_com . store sto_com ]+) .
84dac3
+                        sep_osp . dels ")" ]
84dac3
+
84dac3
+let stmt_match_ifopt = [ dels "if" . sep_spc . key "option" . sep_spc . store word .
84dac3
+                      sep_eq . ([ label "value" . bare_to_scl ]|[ label "value" . dquote_any ]) ]
84dac3
+
84dac3
+let stmt_match_func = [ store fct_re . sep_osp . label "function" . fct_args ] .
84dac3
+                      sep_eq . ([ label "value" . bare_to_scl ]|[ label "value" . dquote_any ])
84dac3
+
84dac3
+let stmt_match_pfv = [ label "function" . store "pick-first-value" . sep_spc .
84dac3
+                       dels "(" . sep_osp .
84dac3
+                       [ label "args" .
84dac3
+                         [ label "arg" . store sto_com ] .
84dac3
+                         [ sep_com . label "arg" . store sto_com ]+ ] .
84dac3
+                       dels ")" ]
84dac3
+
84dac3
+let stmt_match_tpl (l:lens) = [ indent . key "match" . sep_spc . l . sep_scl . eos ]
84dac3
+
84dac3
+let stmt_match = stmt_match_tpl (dels "if" . sep_spc . stmt_match_func | stmt_match_pfv | stmt_match_ifopt)
84dac3
+
84dac3
+(************************************************************************
84dac3
+ *                         BLOCK STATEMENTS
84dac3
+ *************************************************************************)
84dac3
+(* Blocks doesn't support comments at the end of the closing bracket *)
84dac3
+
84dac3
+let stmt_entry        =   stmt_secu
84dac3
+                        | stmt_option
84dac3
+                        | stmt_hardware
84dac3
+                        | stmt_range
84dac3
+                        | stmt_string
84dac3
+                        | stmt_integer
84dac3
+                        | stmt_noarg
84dac3
+                        | stmt_match
84dac3
+                        | stmt_subclass
84dac3
+                        | stmt_set
84dac3
+                        | empty
84dac3
+                        | comment
84dac3
+
84dac3
+let stmt_block_noarg_re = "pool" | "group"
84dac3
+
84dac3
+let stmt_block_noarg (body:lens)
84dac3
+                        = [ indent
84dac3
+                        . key stmt_block_noarg_re
84dac3
+                        . sep_obr
84dac3
+                        . body*
84dac3
+                        . sep_cbr ]
84dac3
+
84dac3
+let stmt_block_arg_re = "host"
84dac3
+                      | "class"
84dac3
+                      | "shared-network"
84dac3
+                      | /failover[ ]+peer/
84dac3
+                      | "zone"
84dac3
+                      | "group"
84dac3
+                      | "on"
84dac3
+
84dac3
+let stmt_block_arg (body:lens)
84dac3
+                      = ([ indent . key stmt_block_arg_re . sep_spc . dquote_any . sep_obr . body* . sep_cbr ]
84dac3
+                         |[ indent . key stmt_block_arg_re . sep_spc . bare_to_scl . sep_obr . body* . sep_cbr ]
84dac3
+                         |[ indent . del /key/ "key" . label "key_block" . sep_spc . dquote_any . sep_obr . body* . sep_cbr . del /(;([ \t]*\n)*)?/ ""  ]
84dac3
+                         |[ indent . del /key/ "key" . label "key_block" . sep_spc . bare_to_scl . sep_obr . body* . sep_cbr . del /(;([ \t]*\n)*)?/ "" ])
84dac3
+
84dac3
+let stmt_block_subnet (body:lens)
84dac3
+                      = [ indent
84dac3
+                        . key "subnet"
84dac3
+                        . sep_spc
84dac3
+                        . [ label "network" . store ip ]
84dac3
+                        . sep_spc
84dac3
+                        . [ key "netmask" . sep_spc . store ip ]
84dac3
+                        . sep_obr
84dac3
+                        . body*
84dac3
+                        . sep_cbr ]
84dac3
+
84dac3
+let conditional (body:lens) =
84dac3
+     let condition         = /[^{ \r\t\n][^{\n]*[^{ \r\t\n]|[^{ \t\n\r]/
84dac3
+  in let elsif = [ indent
84dac3
+                 . Build.xchgs "elsif" "@elsif"
84dac3
+                 . sep_spc
84dac3
+                 . store condition
84dac3
+                 . sep_obr
84dac3
+                 . body*
84dac3
+                 . sep_cbr ]
84dac3
+  in let else = [  indent
84dac3
+                 . Build.xchgs "else" "@else"
84dac3
+                 . sep_obr
84dac3
+                 . body*
84dac3
+                 . sep_cbr ]
84dac3
+  in [ indent
84dac3
+     . Build.xchgs "if" "@if"
84dac3
+     . sep_spc
84dac3
+     . store condition
84dac3
+     . sep_obr
84dac3
+     . body*
84dac3
+     . sep_cbr
84dac3
+     . elsif*
84dac3
+     . else? ]
84dac3
+
84dac3
+
84dac3
+let all_block (body:lens) =
84dac3
+    let lns1 = stmt_block_subnet body in
84dac3
+    let lns2 = stmt_block_arg body in
84dac3
+    let lns3 = stmt_block_noarg body in
84dac3
+    let lns4 = conditional body in
84dac3
+    (lns1 | lns2 | lns3 | lns4 | stmt_entry)
84dac3
+
84dac3
+let rec lns_staging = stmt_entry|all_block lns_staging
84dac3
+let lns = (lns_staging)*
84dac3
diff --git a/lenses/tests/test_dhcpd.aug b/lenses/tests/test_dhcpd.aug
84dac3
index 0af337c2..96630296 100644
84dac3
--- a/lenses/tests/test_dhcpd.aug
84dac3
+++ b/lenses/tests/test_dhcpd.aug
84dac3
@@ -28,9 +28,6 @@ max-lease-time 7200;
84dac3
 # network, the authoritative directive should be uncommented.
84dac3
 authoritative;
84dac3
 
84dac3
-allow booting;
84dac3
-allow bootp;
84dac3
-
84dac3
 # Use this to send dhcp log messages to a different log file (you also
84dac3
 # have to hack syslog.conf to complete the redirection).
84dac3
 log-facility local7;
84dac3
@@ -182,12 +179,7 @@ fixed-address 10.1.1.1;}}" =
84dac3
     }
84dac3
   }
84dac3
 
84dac3
-test lns get "group fan-tas_tic { }" =
84dac3
-  { "group" = "fan-tas_tic" }
84dac3
-
84dac3
 test Dhcpd.stmt_secu get "allow members of \"foo\";" =  { "allow-members-of" = "foo" }
84dac3
-test Dhcpd.stmt_secu get "allow booting;" =  { "allow" = "booting" }
84dac3
-test Dhcpd.stmt_secu get "allow bootp;" =  { "allow" = "bootp" }
84dac3
 test Dhcpd.stmt_option get "option voip-boot-server code 66 = string;" =
84dac3
   { "rfc-code"
84dac3
     { "label" = "voip-boot-server" }
84dac3
@@ -195,30 +187,6 @@ test Dhcpd.stmt_option get "option voip-boot-server code 66 = string;" =
84dac3
     { "type" = "string" }
84dac3
   }
84dac3
 
84dac3
-test Dhcpd.stmt_option get "option special-option code 25 = array of string;" =
84dac3
-  { "rfc-code"
84dac3
-    { "label" = "special-option" }
84dac3
-    { "code" = "25" }
84dac3
-    { "type" = "array of string" }
84dac3
-  }
84dac3
-
84dac3
-test Dhcpd.stmt_option get "option special-option code 25 = integer 32;" =
84dac3
-  { "rfc-code"
84dac3
-    { "label" = "special-option" }
84dac3
-    { "code" = "25" }
84dac3
-    { "type" = "integer 32" }
84dac3
-  }
84dac3
-
84dac3
-
84dac3
-test Dhcpd.stmt_option get "option special-option code 25 = array of integer 32;" =
84dac3
-  { "rfc-code"
84dac3
-    { "label" = "special-option" }
84dac3
-    { "code" = "25" }
84dac3
-    { "type" = "array of integer 32" }
84dac3
-  }
84dac3
-
84dac3
-
84dac3
-
84dac3
 test Dhcpd.lns get "authoritative;
84dac3
 log-facility local7;
84dac3
 ddns-update-style none;
84dac3
@@ -274,7 +242,7 @@ failover peer \"redondance01\" {
84dac3
     }
84dac3
   }
84dac3
   { "next-server" = "10.1.1.1" }
84dac3
-  { "failover peer" = "redondance01"
84dac3
+  { "failover peer" = "\"redondance01\""
84dac3
     { "primary" }
84dac3
     { "address" = "10.1.1.1" }
84dac3
     { "port" = "647" }
84dac3
@@ -291,26 +259,6 @@ failover peer \"redondance01\" {
84dac3
     { "load balance max seconds" = "3" }
84dac3
   }
84dac3
 
84dac3
-
84dac3
-(* test get and put for record types *)
84dac3
-let record_test = "option test_records code 123 = { string, ip-address, integer 32, ip6-address, domain-list };"
84dac3
-
84dac3
-test Dhcpd.lns get record_test =
84dac3
- { "rfc-code"
84dac3
-   { "label" = "test_records" }
84dac3
-   { "code" = "123" }
84dac3
-     { "record"
84dac3
-        { "1" = "string" }
84dac3
-        { "2" = "ip-address" }
84dac3
-        { "3" = "integer 32" }
84dac3
-        { "4" = "ip6-address" }
84dac3
-        { "5" = "domain-list" }
84dac3
-     }
84dac3
- }
84dac3
-
84dac3
-test Dhcpd.lns put record_test after set "/rfc-code[1]/code" "124" = 
84dac3
-  "option test_records code 124 = { string, ip-address, integer 32, ip6-address, domain-list };"
84dac3
-
84dac3
 test Dhcpd.lns get "
84dac3
 option CallManager code 150 = ip-address;
84dac3
 option slp-directory-agent true 10.1.1.1, 10.2.2.2;
84dac3
@@ -386,25 +334,6 @@ test Dhcpd.stmt_match get "match if substring (option dhcp-client-identifier, 1,
84dac3
     { "value" = "RAS" }
84dac3
   }
84dac3
 
84dac3
-test Dhcpd.stmt_match get "match if suffix (option dhcp-client-identifier, 4) = \"RAS\";" =
84dac3
-  { "match"
84dac3
-    { "function" = "suffix"
84dac3
-      { "args"
84dac3
-        { "arg" = "option dhcp-client-identifier" }
84dac3
-        { "arg" = "4" }
84dac3
-      }
84dac3
-    }
84dac3
-    { "value" = "RAS" }
84dac3
-  }
84dac3
-
84dac3
-test Dhcpd.stmt_match get "match if option vendor-class-identifier=\"RAS\";" =
84dac3
-  { "match"
84dac3
-    { "option" = "vendor-class-identifier"
84dac3
-      { "value" = "RAS" }
84dac3
-    }
84dac3
-  }
84dac3
-
84dac3
-
84dac3
 test Dhcpd.lns get "match pick-first-value (option dhcp-client-identifier, hardware);" =
84dac3
   { "match"
84dac3
     { "function" = "pick-first-value"
84dac3
@@ -436,26 +365,12 @@ test Dhcpd.stmt_match get "match if binary-to-ascii(16, 32, \"\", substring(hard
84dac3
     { "value" = "1525400" }
84dac3
   }
84dac3
 
84dac3
-test Dhcpd.lns get "subclass allocation-class-1 1:8:0:2b:4c:39:ad;" =
84dac3
-  { "subclass"
84dac3
-    { "name" = "allocation-class-1" }
84dac3
-    { "value" = "1:8:0:2b:4c:39:ad" }
84dac3
-  }
84dac3
-
84dac3
-
84dac3
 test Dhcpd.lns get "subclass \"allocation-class-1\" 1:8:0:2b:4c:39:ad;" =
84dac3
   { "subclass"
84dac3
     { "name" = "allocation-class-1" }
84dac3
     { "value" = "1:8:0:2b:4c:39:ad" }
84dac3
   }
84dac3
 
84dac3
-test Dhcpd.lns get "subclass \"quoted class\" \"quoted value\";" =
84dac3
-  { "subclass"
84dac3
-    { "name" = "quoted class" }
84dac3
-    { "value" = "quoted value" }
84dac3
-  }
84dac3
-
84dac3
-
84dac3
 (* overall test *)
84dac3
 test Dhcpd.lns put conf after rm "/x" = conf
84dac3
 
84dac3
@@ -477,130 +392,3 @@ filename \"pxelinux.0\";
84dac3
 test Dhcpd.lns put "subnet 172.16.0.0 netmask 255.255.255.0 {
84dac3
 }" after
84dac3
   set "subnet/filename" "pxelinux.0" = input311
84dac3
-
84dac3
-(* GH issue #34: support conditional structures *)
84dac3
-let gh34_empty = "if exists dhcp-parameter-request-list {
84dac3
-}\n"
84dac3
-
84dac3
-test Dhcpd.lns get gh34_empty =
84dac3
-  { "@if" = "exists dhcp-parameter-request-list" }
84dac3
-
84dac3
-let gh34_empty_multi = "subnet 192.168.100.0 netmask 255.255.255.0 {
84dac3
- if true {
84dac3
- } elsif false {
84dac3
- } else {
84dac3
- }
84dac3
-}\n"
84dac3
-
84dac3
-test Dhcpd.lns get gh34_empty_multi =
84dac3
-  { "subnet"
84dac3
-    { "network" = "192.168.100.0" }
84dac3
-    { "netmask" = "255.255.255.0" }
84dac3
-    { "@if" = "true"
84dac3
-      { "@elsif" = "false" }
84dac3
-      { "@else" } }
84dac3
-  }
84dac3
-
84dac3
-let gh34_simple = "if exists dhcp-parameter-request-list {
84dac3
-  default-lease-time 600;
84dac3
-  } else {
84dac3
-default-lease-time 200;
84dac3
-}\n"
84dac3
-
84dac3
-test Dhcpd.lns get gh34_simple =
84dac3
-  { "@if" = "exists dhcp-parameter-request-list"
84dac3
-    { "default-lease-time" = "600" }
84dac3
-    { "@else"
84dac3
-      { "default-lease-time" = "200" } } }
84dac3
-
84dac3
-test Dhcpd.lns get "omapi-key fookey;" =
84dac3
-  { "omapi-key" = "fookey" }
84dac3
-
84dac3
-(* almost all DHCP groups should support braces starting on the next line *)
84dac3
-test Dhcpd.lns get "class introduction
84dac3
-{
84dac3
-}" =
84dac3
-  { "class" = "introduction" }
84dac3
-
84dac3
-(* equals should work the same *)
84dac3
-test Dhcpd.lns get "option test_records code 123 =
84dac3
-                             string;" =
84dac3
- { "rfc-code"
84dac3
-   { "label" = "test_records" }
84dac3
-   { "code" = "123" }
84dac3
-   { "type" = "string" }
84dac3
- }
84dac3
-
84dac3
-test Dhcpd.lns get "deny members of \"Are things like () allowed?\";" =
84dac3
-  { "deny-members-of" = "Are things like () allowed?" }
84dac3
-
84dac3
-test Dhcpd.lns get "deny unknown clients;" =
84dac3
-  { "deny" = "unknown clients" }
84dac3
-test Dhcpd.lns get "deny known-clients;" =
84dac3
-  { "deny" = "known-clients" }
84dac3
-
84dac3
-test Dhcpd.lns get "set ClientMac = binary-to-ascii(16, 8, \":\" , substring(hardware, 1, 6));" =
84dac3
-  { "set" = "ClientMac"
84dac3
-    { "value" = "binary-to-ascii(16, 8, \":\" , substring(hardware, 1, 6))" }
84dac3
-  }
84dac3
-
84dac3
-test Dhcpd.lns get "set myvariable = foo;" =
84dac3
-  { "set" = "myvariable"
84dac3
-    { "value" = "foo" }
84dac3
-  }
84dac3
-
84dac3
-test Dhcpd.stmt_hardware get "hardware fddi 00:01:02:03:04:05;" =
84dac3
-  { "hardware"
84dac3
-    { "type" = "fddi" }
84dac3
-    { "address" = "00:01:02:03:04:05" }
84dac3
-  }
84dac3
-
84dac3
-test Dhcpd.lns get "on commit
84dac3
-{
84dac3
-  set test = thing;
84dac3
-}" =
84dac3
-  { "on" = "commit"
84dac3
-    { "set" = "test"
84dac3
-      { "value" = "thing" }
84dac3
-    }
84dac3
-  }
84dac3
-
84dac3
-(* key block get/put/set test *)
84dac3
-let key_tests = "key sample {
84dac3
-    algorithm hmac-md5;
84dac3
-    secret \"secret==\";
84dac3
-}
84dac3
-
84dac3
-key \"interesting\" { };
84dac3
-
84dac3
-key \"third key\" {
84dac3
-    secret \"two==\";
84dac3
-}"
84dac3
-
84dac3
-test Dhcpd.lns get key_tests =
84dac3
-  { "key_block" = "sample"
84dac3
-    { "algorithm"  = "hmac-md5" }
84dac3
-    { "secret" = "secret==" }
84dac3
-  }
84dac3
-  { "key_block" = "interesting" }
84dac3
-  { "key_block" = "third key"
84dac3
-    { "secret" = "two==" }
84dac3
-  }
84dac3
-
84dac3
-test Dhcpd.lns put key_tests after set "/key_block[1]" "sample2" =
84dac3
-  "key sample2 {
84dac3
-    algorithm hmac-md5;
84dac3
-    secret \"secret==\";
84dac3
-}
84dac3
-
84dac3
-key \"interesting\" { };
84dac3
-
84dac3
-key \"third key\" {
84dac3
-    secret \"two==\";
84dac3
-}"
84dac3
-
84dac3
-test Dhcpd.lns get "group \"hello\" { }" =
84dac3
-  { "group" = "hello" }
84dac3
-
84dac3
-test Dhcpd.lns get "class \"testing class with spaces and quotes and ()\" {}" =
84dac3
-  { "class" = "testing class with spaces and quotes and ()" }
84dac3
diff --git a/lenses/tests/test_dhcpd_140.aug b/lenses/tests/test_dhcpd_140.aug
84dac3
new file mode 100644
84dac3
index 00000000..9d6fdc88
84dac3
--- /dev/null
84dac3
+++ b/lenses/tests/test_dhcpd_140.aug
84dac3
@@ -0,0 +1,606 @@
84dac3
+module Test_dhcpd_140 =
84dac3
+
84dac3
+let lns = Dhcpd_140.lns
84dac3
+
84dac3
+let conf = "#
84dac3
+# Sample configuration file for ISC dhcpd for Debian
84dac3
+#
84dac3
+# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
84dac3
+# configuration file instead of this file.
84dac3
+#
84dac3
+# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
84dac3
+#
84dac3
+
84dac3
+# The ddns-updates-style parameter controls whether or not the server will
84dac3
+# attempt to do a DNS update when a lease is confirmed. We default to the
84dac3
+# behavior of the version 2 packages ('none', since DHCP v2 didn't
84dac3
+# have support for DDNS.)
84dac3
+ddns-update-style none;
84dac3
+
84dac3
+# option definitions common to all supported networks...
84dac3
+option domain-name \"example.org\";
84dac3
+option domain-name-servers ns1.example.org, ns2.example.org;
84dac3
+
84dac3
+default-lease-time 600;
84dac3
+max-lease-time 7200;
84dac3
+
84dac3
+# If this DHCP server is the official DHCP server for the local
84dac3
+# network, the authoritative directive should be uncommented.
84dac3
+authoritative;
84dac3
+
84dac3
+allow booting;
84dac3
+allow bootp;
84dac3
+
84dac3
+# Use this to send dhcp log messages to a different log file (you also
84dac3
+# have to hack syslog.conf to complete the redirection).
84dac3
+log-facility local7;
84dac3
+
84dac3
+# No service will be given on this subnet, but declaring it helps the
84dac3
+# DHCP server to understand the network topology.
84dac3
+
84dac3
+subnet 10.152.187.0 netmask 255.255.255.0 {
84dac3
+}
84dac3
+
84dac3
+# This is a very basic subnet declaration.
84dac3
+
84dac3
+subnet 10.254.239.0 netmask 255.255.255.224 {
84dac3
+  range 10.254.239.10 10.254.239.20;
84dac3
+  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
84dac3
+}
84dac3
+
84dac3
+# This declaration allows BOOTP clients to get dynamic addresses,
84dac3
+# which we don't really recommend.
84dac3
+
84dac3
+subnet 10.254.239.32 netmask 255.255.255.224 {
84dac3
+  range dynamic-bootp 10.254.239.40 10.254.239.60;
84dac3
+  option broadcast-address 10.254.239.31;
84dac3
+  option routers rtr-239-32-1.example.org;
84dac3
+}
84dac3
+
84dac3
+# A slightly different configuration for an internal subnet.
84dac3
+subnet 10.5.5.0 netmask 255.255.255.224 {
84dac3
+  range 10.5.5.26 10.5.5.30;
84dac3
+  option domain-name-servers ns1.internal.example.org;
84dac3
+  option domain-name \"internal.example.org\";
84dac3
+  option routers 10.5.5.1;
84dac3
+  option broadcast-address 10.5.5.31;
84dac3
+  default-lease-time 600;
84dac3
+  max-lease-time 7200;
84dac3
+}
84dac3
+
84dac3
+# Hosts which require special configuration options can be listed in
84dac3
+# host statements.   If no address is specified, the address will be
84dac3
+# allocated dynamically (if possible), but the host-specific information
84dac3
+# will still come from the host declaration.
84dac3
+
84dac3
+host passacaglia {
84dac3
+  hardware ethernet 0:0:c0:5d:bd:95;
84dac3
+  filename \"vmunix.passacaglia\";
84dac3
+  server-name \"toccata.fugue.com\";
84dac3
+}
84dac3
+
84dac3
+# Fixed IP addresses can also be specified for hosts.   These addresses
84dac3
+# should not also be listed as being available for dynamic assignment.
84dac3
+# Hosts for which fixed IP addresses have been specified can boot using
84dac3
+# BOOTP or DHCP.   Hosts for which no fixed address is specified can only
84dac3
+# be booted with DHCP, unless there is an address range on the subnet
84dac3
+# to which a BOOTP client is connected which has the dynamic-bootp flag
84dac3
+# set.
84dac3
+host fantasia {
84dac3
+  hardware ethernet 08:00:07:26:c0:a5;
84dac3
+  fixed-address fantasia.fugue.com;
84dac3
+}
84dac3
+
84dac3
+# You can declare a class of clients and then do address allocation
84dac3
+# based on that.   The example below shows a case where all clients
84dac3
+# in a certain class get addresses on the 10.17.224/24 subnet, and all
84dac3
+# other clients get addresses on the 10.0.29/24 subnet.
84dac3
+
84dac3
+#class \"foo\" {
84dac3
+#  match if substring (option vendor-class-identifier, 0, 4) = \"SUNW\";
84dac3
+#}
84dac3
+
84dac3
+shared-network 224-29 {
84dac3
+  subnet 10.17.224.0 netmask 255.255.255.0 {
84dac3
+    option routers rtr-224.example.org;
84dac3
+  }
84dac3
+  subnet 10.0.29.0 netmask 255.255.255.0 {
84dac3
+    option routers rtr-29.example.org;
84dac3
+  }
84dac3
+  pool {
84dac3
+    allow members of \"foo\";
84dac3
+    range 10.17.224.10 10.17.224.250;
84dac3
+  }
84dac3
+  pool {
84dac3
+    deny members of \"foo\";
84dac3
+    range 10.0.29.10 10.0.29.230;
84dac3
+  }
84dac3
+}
84dac3
+"
84dac3
+
84dac3
+test lns get "authoritative;" = { "authoritative" }
84dac3
+test lns get "ddns-update-style none;" = { "ddns-update-style" = "none" }
84dac3
+test lns get "option domain-name \"example.org\";" =
84dac3
+  { "option"
84dac3
+    { "domain-name"
84dac3
+      { "arg" = "example.org" }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+test lns get "option domain-name-servers ns1.example.org, ns2.example.org;" =
84dac3
+  { "option"
84dac3
+    { "domain-name-servers"
84dac3
+      { "arg" = "ns1.example.org" }
84dac3
+      { "arg" = "ns2.example.org" }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+test lns get "default-lease-time 600;" = { "default-lease-time" = "600" }
84dac3
+test lns get "range 10.254.239.60;" =
84dac3
+{ "range"
84dac3
+    { "to" = "10.254.239.60" }
84dac3
+  }
84dac3
+
84dac3
+test lns get "range dynamic-bootp 10.254.239.60;" =
84dac3
+  { "range"
84dac3
+    { "flag" = "dynamic-bootp" }
84dac3
+    { "to" = "10.254.239.60" }
84dac3
+  }
84dac3
+
84dac3
+test lns get "range dynamic-bootp 10.254.239.40 10.254.239.60;" =
84dac3
+  { "range"
84dac3
+    { "flag" = "dynamic-bootp" }
84dac3
+    { "from" = "10.254.239.40" }
84dac3
+    { "to" = "10.254.239.60" }
84dac3
+  }
84dac3
+
84dac3
+test lns get "subnet 10.152.187.0 netmask 255.255.255.0 {}\n" =
84dac3
+  { "subnet"
84dac3
+    { "network" = "10.152.187.0" }
84dac3
+    { "netmask" = "255.255.255.0" }
84dac3
+  }
84dac3
+
84dac3
+test lns get " pool {
84dac3
+    pool {
84dac3
+
84dac3
+    }
84dac3
+}
84dac3
+" =
84dac3
+  { "pool"
84dac3
+    { "pool" }
84dac3
+  }
84dac3
+
84dac3
+test lns get "group { host some-host {hardware ethernet 00:00:aa:bb:cc:dd;
84dac3
+fixed-address 10.1.1.1;}}" =
84dac3
+  { "group"
84dac3
+    { "host" = "some-host"
84dac3
+      { "hardware"
84dac3
+        { "type" = "ethernet" }
84dac3
+        { "address" = "00:00:aa:bb:cc:dd" }
84dac3
+      }
84dac3
+      { "fixed-address" = "10.1.1.1" }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+test lns get "group fan-tas_tic { }" =
84dac3
+  { "group" = "fan-tas_tic" }
84dac3
+
84dac3
+test Dhcpd_140.stmt_secu get "allow members of \"foo\";" =  { "allow-members-of" = "foo" }
84dac3
+test Dhcpd_140.stmt_secu get "allow booting;" =  { "allow" = "booting" }
84dac3
+test Dhcpd_140.stmt_secu get "allow bootp;" =  { "allow" = "bootp" }
84dac3
+test Dhcpd_140.stmt_option get "option voip-boot-server code 66 = string;" =
84dac3
+  { "rfc-code"
84dac3
+    { "label" = "voip-boot-server" }
84dac3
+    { "code" = "66" }
84dac3
+    { "type" = "string" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.stmt_option get "option special-option code 25 = array of string;" =
84dac3
+  { "rfc-code"
84dac3
+    { "label" = "special-option" }
84dac3
+    { "code" = "25" }
84dac3
+    { "type" = "array of string" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.stmt_option get "option special-option code 25 = integer 32;" =
84dac3
+  { "rfc-code"
84dac3
+    { "label" = "special-option" }
84dac3
+    { "code" = "25" }
84dac3
+    { "type" = "integer 32" }
84dac3
+  }
84dac3
+
84dac3
+
84dac3
+test Dhcpd_140.stmt_option get "option special-option code 25 = array of integer 32;" =
84dac3
+  { "rfc-code"
84dac3
+    { "label" = "special-option" }
84dac3
+    { "code" = "25" }
84dac3
+    { "type" = "array of integer 32" }
84dac3
+  }
84dac3
+
84dac3
+
84dac3
+
84dac3
+test Dhcpd_140.lns get "authoritative;
84dac3
+log-facility local7;
84dac3
+ddns-update-style none;
84dac3
+default-lease-time 21600;
84dac3
+max-lease-time 43200;
84dac3
+
84dac3
+# Additional options for VOIP
84dac3
+option voip-boot-server code 66 = string;
84dac3
+option voip-vlan-id code 128 = string;
84dac3
+" =
84dac3
+  { "authoritative" }
84dac3
+  { "log-facility" = "local7" }
84dac3
+  { "ddns-update-style" = "none" }
84dac3
+  { "default-lease-time" = "21600" }
84dac3
+  { "max-lease-time" = "43200"
84dac3
+    { "#comment" = "Additional options for VOIP" }
84dac3
+  }
84dac3
+  { "rfc-code"
84dac3
+    { "label" = "voip-boot-server" }
84dac3
+    { "code" = "66" }
84dac3
+    { "type" = "string" }
84dac3
+  }
84dac3
+  { "rfc-code"
84dac3
+    { "label" = "voip-vlan-id" }
84dac3
+    { "code" = "128" }
84dac3
+    { "type" = "string" }
84dac3
+  }
84dac3
+
84dac3
+
84dac3
+test Dhcpd_140.lns get "
84dac3
+option domain-name-servers 10.1.1.1, 10.11.2.1, 10.1.3.1;
84dac3
+next-server 10.1.1.1;
84dac3
+
84dac3
+failover peer \"redondance01\" {
84dac3
+         primary;
84dac3
+         address 10.1.1.1;
84dac3
+         port 647;
84dac3
+         peer address 10.1.1.1;
84dac3
+         peer port 647;
84dac3
+         max-response-delay 20;
84dac3
+         max-unacked-updates 10;
84dac3
+         mclt 3600;         #comment.
84dac3
+         split 128;         #comment.
84dac3
+         load balance max seconds 3;
84dac3
+       }
84dac3
+" =
84dac3
+  {  }
84dac3
+  { "option"
84dac3
+    { "domain-name-servers"
84dac3
+      { "arg" = "10.1.1.1" }
84dac3
+      { "arg" = "10.11.2.1" }
84dac3
+      { "arg" = "10.1.3.1" }
84dac3
+    }
84dac3
+  }
84dac3
+  { "next-server" = "10.1.1.1" }
84dac3
+  { "failover peer" = "redondance01"
84dac3
+    { "primary" }
84dac3
+    { "address" = "10.1.1.1" }
84dac3
+    { "port" = "647" }
84dac3
+    { "peer address" = "10.1.1.1" }
84dac3
+    { "peer port" = "647" }
84dac3
+    { "max-response-delay" = "20" }
84dac3
+    { "max-unacked-updates" = "10" }
84dac3
+    { "mclt" = "3600"
84dac3
+      { "#comment" = "comment." }
84dac3
+    }
84dac3
+    { "split" = "128"
84dac3
+      { "#comment" = "comment." }
84dac3
+    }
84dac3
+    { "load balance max seconds" = "3" }
84dac3
+  }
84dac3
+
84dac3
+
84dac3
+(* test get and put for record types *)
84dac3
+let record_test = "option test_records code 123 = { string, ip-address, integer 32, ip6-address, domain-list };"
84dac3
+
84dac3
+test Dhcpd_140.lns get record_test =
84dac3
+ { "rfc-code"
84dac3
+   { "label" = "test_records" }
84dac3
+   { "code" = "123" }
84dac3
+     { "record"
84dac3
+        { "1" = "string" }
84dac3
+        { "2" = "ip-address" }
84dac3
+        { "3" = "integer 32" }
84dac3
+        { "4" = "ip6-address" }
84dac3
+        { "5" = "domain-list" }
84dac3
+     }
84dac3
+ }
84dac3
+
84dac3
+test Dhcpd_140.lns put record_test after set "/rfc-code[1]/code" "124" = 
84dac3
+  "option test_records code 124 = { string, ip-address, integer 32, ip6-address, domain-list };"
84dac3
+
84dac3
+test Dhcpd_140.lns get "
84dac3
+option CallManager code 150 = ip-address;
84dac3
+option slp-directory-agent true 10.1.1.1, 10.2.2.2;
84dac3
+option slp-service-scope true \"SLP-GLOBAL\";
84dac3
+option nds-context \"EXAMPLE\";
84dac3
+option nds-tree-name \"EXAMPLE\";
84dac3
+" =
84dac3
+  {  }
84dac3
+  { "rfc-code"
84dac3
+    { "label" = "CallManager" }
84dac3
+    { "code" = "150" }
84dac3
+    { "type" = "ip-address" }
84dac3
+  }
84dac3
+  { "option"
84dac3
+    { "slp-directory-agent" = "true"
84dac3
+      { "arg" = "10.1.1.1" }
84dac3
+      { "arg" = "10.2.2.2" }
84dac3
+    }
84dac3
+  }
84dac3
+  { "option"
84dac3
+    { "slp-service-scope" = "true"
84dac3
+      { "arg" = "SLP-GLOBAL" }
84dac3
+    }
84dac3
+  }
84dac3
+  { "option"
84dac3
+    { "nds-context"
84dac3
+      { "arg" = "EXAMPLE" }
84dac3
+    }
84dac3
+  }
84dac3
+  { "option"
84dac3
+    { "nds-tree-name"
84dac3
+      { "arg" = "EXAMPLE" }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+
84dac3
+test Dhcpd_140.lns get "option voip-vlan-id \"VLAN=1234;\";" =
84dac3
+  { "option"
84dac3
+    { "voip-vlan-id"
84dac3
+      { "arg" = "VLAN=1234;" }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.lns get "option domain-name \"x.example.com y.example.com z.example.com\";" =
84dac3
+  { "option"
84dac3
+    { "domain-name"
84dac3
+      { "arg" = "x.example.com y.example.com z.example.com" }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.lns get "include \"/etc/dhcpd.master\";" =
84dac3
+  { "include" = "/etc/dhcpd.master" }
84dac3
+
84dac3
+test Dhcpd_140.lns put "\n" after set "/include" "/etc/dhcpd.master" =
84dac3
+  "\ninclude \"/etc/dhcpd.master\";\n"
84dac3
+
84dac3
+test Dhcpd_140.fct_args get "(option dhcp-client-identifier, 1, 3)" =
84dac3
+  { "args"
84dac3
+    { "arg" = "option dhcp-client-identifier" }
84dac3
+    { "arg" = "1" }
84dac3
+    { "arg" = "3" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.stmt_match get "match if substring (option dhcp-client-identifier, 1, 3) = \"RAS\";" =
84dac3
+  { "match"
84dac3
+    { "function" = "substring"
84dac3
+      { "args"
84dac3
+        { "arg" = "option dhcp-client-identifier" }
84dac3
+        { "arg" = "1" }
84dac3
+        { "arg" = "3" }
84dac3
+      }
84dac3
+    }
84dac3
+    { "value" = "RAS" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.stmt_match get "match if suffix (option dhcp-client-identifier, 4) = \"RAS\";" =
84dac3
+  { "match"
84dac3
+    { "function" = "suffix"
84dac3
+      { "args"
84dac3
+        { "arg" = "option dhcp-client-identifier" }
84dac3
+        { "arg" = "4" }
84dac3
+      }
84dac3
+    }
84dac3
+    { "value" = "RAS" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.stmt_match get "match if option vendor-class-identifier=\"RAS\";" =
84dac3
+  { "match"
84dac3
+    { "option" = "vendor-class-identifier"
84dac3
+      { "value" = "RAS" }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+
84dac3
+test Dhcpd_140.lns get "match pick-first-value (option dhcp-client-identifier, hardware);" =
84dac3
+  { "match"
84dac3
+    { "function" = "pick-first-value"
84dac3
+      { "args"
84dac3
+        { "arg" = "option dhcp-client-identifier" }
84dac3
+        { "arg" = "hardware"  }
84dac3
+      }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.fct_args get "(16, 32, \"\", substring(hardware, 0, 4))" =
84dac3
+  { "args"
84dac3
+    { "arg" = "16" }
84dac3
+    { "arg" = "32" }
84dac3
+    { "arg" = "\"\"" }
84dac3
+    { "arg" = "substring(hardware, 0, 4)" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.stmt_match get "match if binary-to-ascii(16, 32, \"\", substring(hardware, 0, 4)) = \"1525400\";" =
84dac3
+  { "match"
84dac3
+    { "function" = "binary-to-ascii"
84dac3
+      { "args"
84dac3
+        { "arg" = "16" }
84dac3
+        { "arg" = "32" }
84dac3
+        { "arg" = "\"\"" }
84dac3
+        { "arg" = "substring(hardware, 0, 4)" }
84dac3
+      }
84dac3
+    }
84dac3
+    { "value" = "1525400" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.lns get "subclass allocation-class-1 1:8:0:2b:4c:39:ad;" =
84dac3
+  { "subclass"
84dac3
+    { "name" = "allocation-class-1" }
84dac3
+    { "value" = "1:8:0:2b:4c:39:ad" }
84dac3
+  }
84dac3
+
84dac3
+
84dac3
+test Dhcpd_140.lns get "subclass \"allocation-class-1\" 1:8:0:2b:4c:39:ad;" =
84dac3
+  { "subclass"
84dac3
+    { "name" = "allocation-class-1" }
84dac3
+    { "value" = "1:8:0:2b:4c:39:ad" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.lns get "subclass \"quoted class\" \"quoted value\";" =
84dac3
+  { "subclass"
84dac3
+    { "name" = "quoted class" }
84dac3
+    { "value" = "quoted value" }
84dac3
+  }
84dac3
+
84dac3
+
84dac3
+(* overall test *)
84dac3
+test Dhcpd_140.lns put conf after rm "/x" = conf
84dac3
+
84dac3
+(* bug #293: primary should support argument *)
84dac3
+let input293 = "zone EXAMPLE.ORG. {
84dac3
+  primary 127.0.0.1;
84dac3
+}"
84dac3
+
84dac3
+test Dhcpd_140.lns get input293 = 
84dac3
+  { "zone" = "EXAMPLE.ORG."
84dac3
+    { "primary" = "127.0.0.1" }
84dac3
+  }
84dac3
+
84dac3
+(* bug #311: filename should be quoted *)
84dac3
+let input311 = "subnet 172.16.0.0 netmask 255.255.255.0 {
84dac3
+filename \"pxelinux.0\";
84dac3
+}"
84dac3
+
84dac3
+test Dhcpd_140.lns put "subnet 172.16.0.0 netmask 255.255.255.0 {
84dac3
+}" after
84dac3
+  set "subnet/filename" "pxelinux.0" = input311
84dac3
+
84dac3
+(* GH issue #34: support conditional structures *)
84dac3
+let gh34_empty = "if exists dhcp-parameter-request-list {
84dac3
+}\n"
84dac3
+
84dac3
+test Dhcpd_140.lns get gh34_empty =
84dac3
+  { "@if" = "exists dhcp-parameter-request-list" }
84dac3
+
84dac3
+let gh34_empty_multi = "subnet 192.168.100.0 netmask 255.255.255.0 {
84dac3
+ if true {
84dac3
+ } elsif false {
84dac3
+ } else {
84dac3
+ }
84dac3
+}\n"
84dac3
+
84dac3
+test Dhcpd_140.lns get gh34_empty_multi =
84dac3
+  { "subnet"
84dac3
+    { "network" = "192.168.100.0" }
84dac3
+    { "netmask" = "255.255.255.0" }
84dac3
+    { "@if" = "true"
84dac3
+      { "@elsif" = "false" }
84dac3
+      { "@else" } }
84dac3
+  }
84dac3
+
84dac3
+let gh34_simple = "if exists dhcp-parameter-request-list {
84dac3
+  default-lease-time 600;
84dac3
+  } else {
84dac3
+default-lease-time 200;
84dac3
+}\n"
84dac3
+
84dac3
+test Dhcpd_140.lns get gh34_simple =
84dac3
+  { "@if" = "exists dhcp-parameter-request-list"
84dac3
+    { "default-lease-time" = "600" }
84dac3
+    { "@else"
84dac3
+      { "default-lease-time" = "200" } } }
84dac3
+
84dac3
+test Dhcpd_140.lns get "omapi-key fookey;" =
84dac3
+  { "omapi-key" = "fookey" }
84dac3
+
84dac3
+(* almost all DHCP groups should support braces starting on the next line *)
84dac3
+test Dhcpd_140.lns get "class introduction
84dac3
+{
84dac3
+}" =
84dac3
+  { "class" = "introduction" }
84dac3
+
84dac3
+(* equals should work the same *)
84dac3
+test Dhcpd_140.lns get "option test_records code 123 =
84dac3
+                             string;" =
84dac3
+ { "rfc-code"
84dac3
+   { "label" = "test_records" }
84dac3
+   { "code" = "123" }
84dac3
+   { "type" = "string" }
84dac3
+ }
84dac3
+
84dac3
+test Dhcpd_140.lns get "deny members of \"Are things like () allowed?\";" =
84dac3
+  { "deny-members-of" = "Are things like () allowed?" }
84dac3
+
84dac3
+test Dhcpd_140.lns get "deny unknown clients;" =
84dac3
+  { "deny" = "unknown clients" }
84dac3
+test Dhcpd_140.lns get "deny known-clients;" =
84dac3
+  { "deny" = "known-clients" }
84dac3
+
84dac3
+test Dhcpd_140.lns get "set ClientMac = binary-to-ascii(16, 8, \":\" , substring(hardware, 1, 6));" =
84dac3
+  { "set" = "ClientMac"
84dac3
+    { "value" = "binary-to-ascii(16, 8, \":\" , substring(hardware, 1, 6))" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.lns get "set myvariable = foo;" =
84dac3
+  { "set" = "myvariable"
84dac3
+    { "value" = "foo" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.stmt_hardware get "hardware fddi 00:01:02:03:04:05;" =
84dac3
+  { "hardware"
84dac3
+    { "type" = "fddi" }
84dac3
+    { "address" = "00:01:02:03:04:05" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.lns get "on commit
84dac3
+{
84dac3
+  set test = thing;
84dac3
+}" =
84dac3
+  { "on" = "commit"
84dac3
+    { "set" = "test"
84dac3
+      { "value" = "thing" }
84dac3
+    }
84dac3
+  }
84dac3
+
84dac3
+(* key block get/put/set test *)
84dac3
+let key_tests = "key sample {
84dac3
+    algorithm hmac-md5;
84dac3
+    secret \"secret==\";
84dac3
+}
84dac3
+
84dac3
+key \"interesting\" { };
84dac3
+
84dac3
+key \"third key\" {
84dac3
+    secret \"two==\";
84dac3
+}"
84dac3
+
84dac3
+test Dhcpd_140.lns get key_tests =
84dac3
+  { "key_block" = "sample"
84dac3
+    { "algorithm"  = "hmac-md5" }
84dac3
+    { "secret" = "secret==" }
84dac3
+  }
84dac3
+  { "key_block" = "interesting" }
84dac3
+  { "key_block" = "third key"
84dac3
+    { "secret" = "two==" }
84dac3
+  }
84dac3
+
84dac3
+test Dhcpd_140.lns put key_tests after set "/key_block[1]" "sample2" =
84dac3
+  "key sample2 {
84dac3
+    algorithm hmac-md5;
84dac3
+    secret \"secret==\";
84dac3
+}
84dac3
+
84dac3
+key \"interesting\" { };
84dac3
+
84dac3
+key \"third key\" {
84dac3
+    secret \"two==\";
84dac3
+}"
84dac3
+
84dac3
+test Dhcpd_140.lns get "group \"hello\" { }" =
84dac3
+  { "group" = "hello" }
84dac3
+
84dac3
+test Dhcpd_140.lns get "class \"testing class with spaces and quotes and ()\" {}" =
84dac3
+  { "class" = "testing class with spaces and quotes and ()" }
84dac3
diff --git a/tests/Makefile.am b/tests/Makefile.am
84dac3
index 387ac7d2..315cac9c 100644
84dac3
--- a/tests/Makefile.am
84dac3
+++ b/tests/Makefile.am
84dac3
@@ -58,6 +58,7 @@ lens_tests =			\
84dac3
   lens-device_map.sh    \
84dac3
   lens-dhclient.sh		\
84dac3
   lens-dhcpd.sh		\
84dac3
+  lens-dhcpd_140.sh		\
84dac3
   lens-dns_zone.sh		\
84dac3
   lens-dnsmasq.sh		\
84dac3
   lens-dovecot.sh		\
84dac3
-- 
c5f980
2.17.2
84dac3