[augeas-devel] [PATCH 1 of 2] Do not allow "Defaults.*" as user name for spec (instead of "Defaults")

Raphael Pinson raphink at gmail.com
Tue Aug 12 09:58:00 UTC 2008


# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# Date 1218534737 -7200
# Node ID 6e219c839734abe4d9aea1462846b62be10e987e
# Parent  fe8236ec9a82e500be65689abd79de394c253e8a
Do not allow "Defaults.*" as user name for spec (instead of "Defaults").
Simplify Defaults type from (@|:|>) into [@:>].
Make a specific regexp for Defaults value to allow spaces.
Add a test line in test_sudoers.aug to test a more complex Defaults line.

diff -r fe8236ec9a82 -r 6e219c839734 lenses/sudoers.aug
--- a/lenses/sudoers.aug	Tue Aug 12 11:27:24 2008 +0200
+++ b/lenses/sudoers.aug	Tue Aug 12 11:52:17 2008 +0200
@@ -41,7 +41,7 @@ module Sudoers =
 
     (* sto_to_com does not begin or end with a space *)
     (* TODO: there could be a \ in the middle of a command... *)
-    let sto_to_com_user = store ( /[^,=:#() \t\n]+/ - /(User|Runas|Host|Cmnd)_Alias|Defaults/ )
+    let sto_to_com_user = store ( /[^,=:#() \t\n]+/ - /(User|Runas|Host|Cmnd)_Alias|Defaults.*/ )
     let sto_to_eq  = store /[^,=:#() \t\n\\\\]+/
     let sto_to_spc = store /[^() \t\n\\\\]+/
 
@@ -111,7 +111,7 @@ module Sudoers =
     *                   'Defaults' '>' Runas_List
     **********************************************************************************)
     let default_type     = 
-        let value = store /(@|:|>)[^ \t\n\\\\]+/ in
+        let value = store /[@:>][^ \t\n\\\\]+/ in
 	[ label "type" . value ] 
 
     (***********************************************************************************
@@ -120,7 +120,9 @@ module Sudoers =
     *                Parameter '-=' Value |
     *                '!'* Parameter
     ***********************************************************************************)
-    let parameter        = [ label "parameter" . sto_to_com ]
+    let parameter        = 
+          let value = /([^,:= \t\n\\\\][^,\n\\\\]*[^, \t\n\\\\])|[^,:= \t\n\\\\]/ in
+	  [ label "parameter" . store value ]
 
     (***********************************************************************************
     *  Parameter_List ::= Parameter |
diff -r fe8236ec9a82 -r 6e219c839734 lenses/tests/test_sudoers.aug
--- a/lenses/tests/test_sudoers.aug	Tue Aug 12 11:27:24 2008 +0200
+++ b/lenses/tests/test_sudoers.aug	Tue Aug 12 11:52:17 2008 +0200
@@ -19,6 +19,8 @@ Cmnd_Alias ICAL = /bin/cat /home/rpinson
 
 Defaults at LOCALNET        !lecture, \
    	tty_tickets,!fqdn
+
+Defaults:buildd env_keep+=\"APT_CONFIG DEBIAN_FRONTEND SHELL\"
 
 # User privilege specification
 root    ALL=(ALL) ALL
@@ -67,6 +69,10 @@ www-data ALL=(rpinson) NOEXEC: ICAL \
           { "parameter" = "tty_tickets" }
           { "parameter" = "!fqdn" } }
       {}
+      { "Defaults"
+          { "type"      = ":buildd" }
+	  { "parameter" = "env_keep+=\"APT_CONFIG DEBIAN_FRONTEND SHELL\"" } }
+      {}
       { "comment" = "User privilege specification" }
       { "spec"
           { "user" = "root" }




More information about the augeas-devel mailing list