[augeas-devel] [PATCH] Dhcpd: slashes must be double-quoted

Michael Chapman mike at very.puzzling.org
Sat Oct 22 13:01:33 UTC 2011


In dhcpd.conf, tokens containing slashes must be double-quoted.

Fixes the following dhcpd error:

  /etc/dhcpd.conf line 4: filename string expected.
  include /
          ^
  Configuration file errors encountered -- exiting

Signed-off-by: Michael Chapman <mike at very.puzzling.org>
---
 lenses/dhcpd.aug            |   10 +++++-----
 lenses/tests/test_dhcpd.aug |    3 +++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/lenses/dhcpd.aug b/lenses/dhcpd.aug
index 8cbc3db..09cb0ef 100644
--- a/lenses/dhcpd.aug
+++ b/lenses/dhcpd.aug
@@ -79,23 +79,23 @@ let ip                = Rx.ipv4
 
 (* Define fields *)
 
-(* borrowed from sysconfig.aug *)
+(* adapted from sysconfig.aug *)
   (* Chars allowed in a bare string *)
-  let bchar = /[^ \t\n"'\\{}#,()]|\\\\./
+  let bchar = /[^ \t\n"'\\{}#,()\/]|\\\\./
   let qchar = /["']/  (* " *)
 
   (* We split the handling of right hand sides into a few cases:
    *   bare  - strings that contain no spaces, optionally enclosed in
    *           single or double quotes
-   *   dquot - strings that contain at least one space or apostrophe,
+   *   dquot - strings that contain at least one space, apostrophe or slash
    *           which must be enclosed in double quotes
    *   squot - strings that contain an unescaped double quote
    *)
   let bare = del qchar? "" . store (bchar+) . del qchar? ""
   let dquot =
-    del qchar "\"" . store (bchar* . /[ \t']/ . bchar*)+ . del qchar "\""
+    del qchar "\"" . store (bchar* . /[ \t'\/]/ . bchar*)+ . del qchar "\""
   let squot =
-    dels "'" . store ((bchar|/[ \t]/)* . "\"" . (bchar|/[ \t]/)*)+ . dels "'"
+    dels "'" . store ((bchar|/[ \t\/]/)* . "\"" . (bchar|/[ \t\/]/)*)+ . dels "'"
 
 let sto_to_spc        = store /[^\\#,;\{\}" \t\n]+|"[^\\#"\n]+"/
 let sto_to_scl        = store /[^ \t;][^;\n=]+[^ \t;]|[^ \t;=]+/
diff --git a/lenses/tests/test_dhcpd.aug b/lenses/tests/test_dhcpd.aug
index e49ee86..c1f3cee 100644
--- a/lenses/tests/test_dhcpd.aug
+++ b/lenses/tests/test_dhcpd.aug
@@ -312,6 +312,9 @@ test Dhcpd.lns get "option domain-name \"x.example.com y.example.com z.example.c
 test Dhcpd.lns get "include \"/etc/dhcpd.master\";" =
   { "include" = "/etc/dhcpd.master" }
 
+test Dhcpd.lns put "\n" after set "/include" "/etc/dhcpd.master" =
+  "\ninclude \"/etc/dhcpd.master\";\n"
+
 test Dhcpd.fct_args get "(option dhcp-client-identifier, 1, 3)" =
   { "args"
     { "arg" = "option dhcp-client-identifier" }
-- 
1.7.6.4




More information about the augeas-devel mailing list