[augeas-devel] [PATCH] Deal with empty comments in empty

Raphael Pinson raphink at gmail.com
Tue Aug 12 11:42:38 UTC 2008


# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# Date 1218541328 -7200
# Node ID f5cfb9fc03f4a7eeefb2a8633bfd3159e4b1e6be
# Parent  b0d925644377c3d1ae7d2fc3e657ee18f87af0e6
Deal with empty comments in empty.
Add "!" as a valid parameter delimiter in Defaults.
Make tests a bit more interesting in test_sudoers.aug.

diff -r b0d925644377 -r f5cfb9fc03f4 lenses/sudoers.aug
--- a/lenses/sudoers.aug	Tue Aug 12 12:14:17 2008 +0200
+++ b/lenses/sudoers.aug	Tue Aug 12 13:42:08 2008 +0200
@@ -47,13 +47,11 @@ module Sudoers =
 
 
     (* define comments and empty lines *)
-    let real_comment = 
+    let comment = 
         let value_to_eol = del /[ \t]*/ " " . store /([^ \t\n].*[^ \t\n]|[^ \t\n])/ in
         [ label "comment" . del /[ \t]*#/ "# " .  value_to_eol . eol ]
-    let empty_comment = del /[ \t]*#/ "#" . eol
-    let comment = real_comment | empty_comment
 
-    let empty   = [ del /[ \t]*\n/ "" ]
+    let empty   = [ del /[ \t]*#?[ \t]*\n/ "" ]
 
 
     (***********************************************************************************
@@ -111,9 +109,15 @@ module Sudoers =
     *                   'Defaults' '@' Host_List |
     *                   'Defaults' ':' User_List |
     *                   'Defaults' '>' Runas_List
+    *
+    *  The manpage has the following example, which is not in the spec:
+    *     Defaults!PAGERS        noexec
+    *  This seems to be specified as follows:
+    *     'Defaults' '!' Cmnd_List
+    *  Since it is used in the examples, I consider "!" to be a valid parameter type delimiter
     **********************************************************************************)
     let default_type     = 
-        let value = store /[@:>][^ \t\n\\\\]+/ in
+        let value = store /[@:>!][^ \t\n\\\\]+/ in
 	[ label "type" . value ] 
 
     (***********************************************************************************
diff -r b0d925644377 -r f5cfb9fc03f4 lenses/tests/test_sudoers.aug
--- a/lenses/tests/test_sudoers.aug	Tue Aug 12 12:14:17 2008 +0200
+++ b/lenses/tests/test_sudoers.aug	Tue Aug 12 13:42:08 2008 +0200
@@ -29,7 +29,7 @@ root    ALL=(ALL) ALL
 %admin  ALL=(ALL) ALL, NOPASSWD  :	NOSETENV: \
    DEBIAN_TOOLS
 %pbuilder       LOCALNET = NOPASSWD: PBUILDER
-www-data ALL=(rpinson)NOEXEC: ICAL \
+www-data +biglab=(rpinson)NOEXEC: ICAL \
         : \
         localhost = NOPASSWD: 	/usr/bin/test
 "
@@ -100,7 +100,7 @@ www-data ALL=(rpinson)NOEXEC: ICAL \
       { "spec" 
           { "user"    = "www-data" }
 	  { "host_group"
-	      { "host" = "ALL" }
+	      { "host" = "+biglab" }
 	      { "command" = "ICAL"
 	          { "runas_user" = "rpinson" }
 		  { "tag" = "NOEXEC" } } }




More information about the augeas-devel mailing list