]> granicus.if.org Git - sudo/commitdiff
Require that the first character after a comment not be a digit or
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 22 Aug 2007 22:28:20 +0000 (22:28 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 22 Aug 2007 22:28:20 +0000 (22:28 +0000)
a dash.  This allows us to remove the GOTRUNAS state and treat
uid/gids similar to other words.  It also means that we can now
specify uids in User_Lists and a User_Spec may now contain a uid.

toke.l

diff --git a/toke.l b/toke.l
index 0f306aa3df66f82c52c0596d026478babad011cc..cdf64e80684e44a9a6effb750bbfb2be5e837a0e 100644 (file)
--- a/toke.l
+++ b/toke.l
@@ -102,8 +102,6 @@ DEFVAR                      [a-z_]+
 %option nounput
 %option noyywrap
 
-/* XXX - convert GOTRUNAS to exclusive state (GOTDEFS cannot be) */
-%s     GOTRUNAS
 %s     GOTDEFS
 %x     GOTCMND
 %x     STARTDEFS
@@ -213,6 +211,7 @@ DEFVAR                      [a-z_]+
 }
 
 <INITIAL>^#include[[:blank:]]+\/.*\n {
+                           /* XXX - handle include lines in grammar */
                            char *cp, *ep;
                            ++sudolineno;
                            /* pull out path from #include line */
@@ -277,7 +276,6 @@ DEFVAR                      [a-z_]+
                                    return(USERALIAS);
                                case 'R':
                                    LEXTRACE("RUNASALIAS ");
-                                   BEGIN GOTRUNAS;
                                    return(RUNASALIAS);
                            }
                        }
@@ -358,12 +356,6 @@ NOSETENV[[:blank:]]*:      {
                            return(NTWKADDR);
                        }
 
-<INITIAL>\(            {
-                               BEGIN GOTRUNAS;
-                               LEXTRACE("( ");
-                               return (RUNAS);
-                       }
-
 [[:upper:]][[:upper:][:digit:]_]* {
                            if (strcmp(yytext, "ALL") == 0) {
                                LEXTRACE("ALL ");
@@ -376,26 +368,6 @@ NOSETENV[[:blank:]]*:      {
                            }
                        }
 
-<GOTRUNAS>({ID}|{WORD}) {
-                           /* username/uid that user can run command as */
-                           if (!fill(yytext, yyleng))
-                               yyterminate();
-                           LEXTRACE("WORD(3) ");
-                           return(WORD);
-                       }
-
-<GOTRUNAS>#[^0-9-].*\n {
-                           BEGIN INITIAL;
-                           ++sudolineno;
-                           LEXTRACE("\n");
-                           return(COMMENT);
-                       }
-
-<GOTRUNAS>\)           {
-                           BEGIN INITIAL;
-                           LEXTRACE(") ");
-                       }
-
 <GOTDEFS>({PATH}|sudoedit) {
                            /* no command args allowed for Defaults!/path */
                            if (!fill_cmnd(yytext, yyleng))
@@ -426,7 +398,7 @@ sudoedit            {
                            }
                        }                       /* a pathname */
 
-<INITIAL,GOTDEFS>{WORD} {
+<INITIAL,GOTDEFS>({ID}|{WORD}) {
                            /* a word */
                            if (!fill(yytext, yyleng))
                                yyterminate();
@@ -434,6 +406,16 @@ sudoedit           {
                            return(WORD);
                        }
 
+\(                     {
+                           LEXTRACE("( ");
+                           return ('(');
+                       }
+
+\)                     {
+                           LEXTRACE(") ");
+                           return(')');
+                       }
+
 ,                      {
                            LEXTRACE(", ");
                            return(',');
@@ -471,7 +453,7 @@ sudoedit            {
                            LEXTRACE("\n\t");
                        }                       /* throw away EOL after \ */
 
-<INITIAL,STARTDEFS,INDEFS>#.*\n        {
+<INITIAL,STARTDEFS,INDEFS>#[^0-9-].*\n {
                            BEGIN INITIAL;
                            ++sudolineno;
                            LEXTRACE("\n");