]> granicus.if.org Git - sudo/commitdiff
Strip whitespace around '!', '=', '+=' and '-=' in Defaults entries.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 8 Dec 2015 22:06:00 +0000 (15:06 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 8 Dec 2015 22:06:00 +0000 (15:06 -0700)
plugins/sudoers/sudoers2ldif

index 1a6951905c4d1bd1afcd1401a2b8b7f4f4f4ca39..3c165bc7c213fe653697fa5d42dfc4d8c5892413 100755 (executable)
@@ -58,12 +58,12 @@ while (<>){
   # ignore blank lines
   next if /^\s*$/;
 
-  if (/^Defaults\s+/i) {
-    my $opt=$';
-    $opt=~s/\s+$//; # remove trailing whitespace
-    push @options,$opt;
+  if (s/^Defaults\s+//) {
+    s/\s+$//; # remove trailing whitespace
+    # remove spaces between '!', '=', '+=' and '-='
+    s/^(\S+)\s*([\+-]?=)\s*(\S.*)$/$1$2$3/ unless s/^!\s*(\S.*)$/!$1/;
+    push @options, $_;
   } elsif (/^(\S+)\s+([^=]+)=\s*(.*)/) {
-
     # Aliases or Definitions
     my ($p1,$p2,$p3)=($1,$2,$3);
     $p2=~s/\s+$//; # remove trailing whitespace
@@ -117,7 +117,6 @@ while (<>){
       printf "sudoOrder: %d\n", ++$order;
       print "\n";
     }
-
   } else {
     print "parse error: $_\n";
   }