=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sudo/Attic/parse.lex,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -c -r1.3 -r1.3.6.1 *** src/usr.bin/sudo/Attic/parse.lex 2000/03/27 03:44:38 1.3 --- src/usr.bin/sudo/Attic/parse.lex 2002/01/18 17:20:23 1.3.6.1 *************** *** 1,6 **** %{ /* ! * Copyright (c) 1996, 1998, 1999 Todd C. Miller * All rights reserved. * * This code is derived from software contributed by Chris Jepeway --- 1,6 ---- %{ /* ! * Copyright (c) 1996, 1998-2001 Todd C. Miller * All rights reserved. * * This code is derived from software contributed by Chris Jepeway *************** *** 39,68 **** #include "config.h" #ifdef STDC_HEADERS ! #include #endif /* STDC_HEADERS */ - #ifdef HAVE_UNISTD_H - #include - #endif /* HAVE_UNISTD_H */ #ifdef HAVE_STRING_H ! #include #endif /* HAVE_STRING_H */ ! #ifdef HAVE_STRINGS_H ! #include ! #endif /* HAVE_STRINGS_H */ #if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS) ! #include #endif /* HAVE_MALLOC_H && !STDC_HEADERS */ #include - #include - #include #include "sudo.h" #include "parse.h" ! #include "sudo.tab.h" #ifndef lint ! static const char rcsid[] = "$Sudo: parse.lex,v 1.111 2000/03/23 04:38:20 millert Exp $"; #endif /* lint */ #undef yywrap /* guard against a yywrap macro */ --- 39,75 ---- #include "config.h" + #include + #include + #include #ifdef STDC_HEADERS ! # include ! # include ! #else ! # ifdef HAVE_STDLIB_H ! # include ! # endif #endif /* STDC_HEADERS */ #ifdef HAVE_STRING_H ! # include ! #else ! # ifdef HAVE_STRINGS_H ! # include ! # endif #endif /* HAVE_STRING_H */ ! #ifdef HAVE_UNISTD_H ! # include ! #endif /* HAVE_UNISTD_H */ #if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS) ! # include #endif /* HAVE_MALLOC_H && !STDC_HEADERS */ #include #include "sudo.h" #include "parse.h" ! #include #ifndef lint ! static const char rcsid[] = "$Sudo: parse.lex,v 1.118 2002/01/15 18:16:31 millert Exp $"; #endif /* lint */ #undef yywrap /* guard against a yywrap macro */ *************** *** 93,179 **** OCTET (1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]) DOTTEDQUAD {OCTET}(\.{OCTET}){3} HOSTNAME [[:alnum:]_-]+ ! WORD ([^@!=:,\(\) \t\n\\]|\\[^\n])+ ! %s GOTCMND %s GOTRUNAS %s GOTDEFS %% ! [ \t]+ { /* throw away space/tabs */ ! sawspace = TRUE; /* but remember for fill_args */ } ! \\[ \t]*\n { ! sawspace = TRUE; /* remember for fill_args */ ! ++sudolineno; ! LEXTRACE("\n\t"); ! } /* throw away EOL after \ */ ! \\[:\,=\\ \t] { ! LEXTRACE("QUOTEDCHAR "); ! fill_args(yytext + 1, 1, sawspace); ! sawspace = FALSE; ! } ! \"([^\"]|\\\")+\" { LEXTRACE("WORD(1) "); fill(yytext + 1, yyleng - 2); return(WORD); } ! (#.*)?\n { ! BEGIN INITIAL; ! ++sudolineno; ! LEXTRACE("\n"); ! return(COMMENT); } ! [:\,=\n] { BEGIN INITIAL; unput(*yytext); return(COMMAND); } /* end of command line args */ ! \n { ! ++sudolineno; ! LEXTRACE("\n"); ! BEGIN INITIAL; ! return(COMMENT); ! } /* return newline */ ! ! #.*\n { ! ++sudolineno; ! LEXTRACE("\n"); ! return(COMMENT); ! } /* return comments */ ! ! [^\\:, \t\n]+ { LEXTRACE("ARG "); fill_args(yytext, yyleng, sawspace); sawspace = FALSE; ! } /* a command line arg */ ! , { ! LEXTRACE(", "); ! return(','); ! } /* return ',' */ ! !+ { ! if (yyleng % 2 == 1) ! return('!'); /* return '!' */ } - = { - LEXTRACE("= "); - return('='); - } /* return '=' */ - - : { - LEXTRACE(": "); - return(':'); - } /* return ':' */ - NOPASSWD[[:blank:]]*: { /* cmnd does not require passwd for this user */ LEXTRACE("NOPASSWD "); --- 100,215 ---- OCTET (1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]) DOTTEDQUAD {OCTET}(\.{OCTET}){3} HOSTNAME [[:alnum:]_-]+ ! WORD ([^#@!=:,\(\) \t\n\\]|\\[^\n])+ ! ENVAR ([^#!=, \t\n\\]|\\[^\n])([^#=, \t\n\\]|\\[^\n])* ! DEFVAR [a-z_]+ ! /* XXX - convert GOTRUNAS to exclusive state (GOTDEFS cannot be) */ %s GOTRUNAS %s GOTDEFS + %x GOTCMND + %x STARTDEFS + %x INDEFS %% ! [[:blank:]]+ BEGIN STARTDEFS; ! ! {DEFVAR} { ! BEGIN INDEFS; ! LEXTRACE("DEFVAR "); ! fill(yytext, yyleng); ! return(DEFVAR); } ! { ! , { ! BEGIN STARTDEFS; ! LEXTRACE(", "); ! return(','); ! } /* return ',' */ ! = { ! LEXTRACE("= "); ! return('='); ! } /* return '=' */ ! \+= { ! LEXTRACE("+= "); ! return('+'); ! } /* return '+' */ ! ! -= { ! LEXTRACE("-= "); ! return('-'); ! } /* return '-' */ ! ! \"([^\"]|\\\")+\" { LEXTRACE("WORD(1) "); fill(yytext + 1, yyleng - 2); return(WORD); } ! {ENVAR} { ! LEXTRACE("WORD(2) "); ! fill(yytext, yyleng); ! return(WORD); } + } ! { ! \\[:\\,= \t#] { ! LEXTRACE("QUOTEDCHAR "); ! fill_args(yytext + 1, 1, sawspace); ! sawspace = FALSE; ! } ! ! [#:\,=\n] { BEGIN INITIAL; unput(*yytext); return(COMMAND); } /* end of command line args */ ! [^\\:, \t\n]+ { LEXTRACE("ARG "); fill_args(yytext, yyleng, sawspace); sawspace = FALSE; ! } /* a command line arg */ ! } ! ^Defaults[:@]? { ! BEGIN GOTDEFS; ! switch (yytext[8]) { ! case ':': ! LEXTRACE("DEFAULTS_USER "); ! return(DEFAULTS_USER); ! case '@': ! LEXTRACE("DEFAULTS_HOST "); ! return(DEFAULTS_HOST); ! default: ! LEXTRACE("DEFAULTS "); ! return(DEFAULTS); ! } ! } ! ^(Host|Cmnd|User|Runas)_Alias { ! fill(yytext, yyleng); ! switch (*yytext) { ! case 'H': ! LEXTRACE("HOSTALIAS "); ! return(HOSTALIAS); ! case 'C': ! LEXTRACE("CMNDALIAS "); ! return(CMNDALIAS); ! case 'U': ! LEXTRACE("USERALIAS "); ! return(USERALIAS); ! case 'R': ! LEXTRACE("RUNASALIAS "); ! BEGIN GOTRUNAS; ! return(RUNASALIAS); ! } } NOPASSWD[[:blank:]]*: { /* cmnd does not require passwd for this user */ LEXTRACE("NOPASSWD "); *************** *** 218,225 **** return (RUNAS); } ! [[:upper:]][[:upper:][:digit:]_]* { ! /* Runas_Alias user can run command as or ALL */ if (strcmp(yytext, "ALL") == 0) { LEXTRACE("ALL "); return(ALL); --- 254,260 ---- return (RUNAS); } ! [[:upper:]][[:upper:][:digit:]_]* { if (strcmp(yytext, "ALL") == 0) { LEXTRACE("ALL "); return(ALL); *************** *** 230,239 **** } } ! #?{WORD} { /* username/uid that user can run command as */ fill(yytext, yyleng); ! LEXTRACE("WORD(2) "); return(WORD); } --- 265,274 ---- } } ! (#[0-9-]+|{WORD}) { /* username/uid that user can run command as */ fill(yytext, yyleng); ! LEXTRACE("WORD(3) "); return(WORD); } *************** *** 241,302 **** BEGIN INITIAL; } ! [[:upper:]][[:upper:][:digit:]_]* { ! if (strcmp(yytext, "ALL") == 0) { ! LEXTRACE("ALL "); ! return(ALL); ! } else { ! fill(yytext, yyleng); ! LEXTRACE("ALIAS "); ! return(ALIAS); ! } ! } ! ! {WORD} { ! LEXTRACE("WORD(3) "); ! fill(yytext, yyleng); ! return(WORD); ! } ! ! ^Defaults[:@]? { ! BEGIN GOTDEFS; ! if (yyleng == 9) { ! switch (yytext[8]) { ! case ':' : ! LEXTRACE("DEFAULTS_USER "); ! return(DEFAULTS_USER); ! case '@' : ! LEXTRACE("DEFAULTS_HOST "); ! return(DEFAULTS_HOST); ! } ! } else { ! LEXTRACE("DEFAULTS "); ! return(DEFAULTS); ! } ! } ! ! ^(Host|Cmnd|User|Runas)_Alias { ! fill(yytext, yyleng); ! if (*yytext == 'H') { ! LEXTRACE("HOSTALIAS "); ! return(HOSTALIAS); ! } ! if (*yytext == 'C') { ! LEXTRACE("CMNDALIAS "); ! return(CMNDALIAS); ! } ! if (*yytext == 'U') { ! LEXTRACE("USERALIAS "); ! return(USERALIAS); ! } ! if (*yytext == 'R') { ! LEXTRACE("RUNASALIAS "); ! BEGIN GOTRUNAS; ! return(RUNASALIAS); ! } ! } ! ! \/[^\,:=\\ \t\n#]+ { /* directories can't have args... */ if (yytext[yyleng - 1] == '/') { LEXTRACE("COMMAND "); --- 276,282 ---- BEGIN INITIAL; } ! \/(\\[\,:= \t#]|[^\,:=\\ \t\n#])+ { /* directories can't have args... */ if (yytext[yyleng - 1] == '/') { LEXTRACE("COMMAND "); *************** *** 309,322 **** } } /* a pathname */ ! {WORD} { /* a word */ fill(yytext, yyleng); LEXTRACE("WORD(4) "); return(WORD); } ! . { LEXTRACE("ERROR "); return(ERROR); } /* parse error */ --- 289,346 ---- } } /* a pathname */ ! {WORD} { /* a word */ fill(yytext, yyleng); LEXTRACE("WORD(4) "); return(WORD); } ! , { ! LEXTRACE(", "); ! return(','); ! } /* return ',' */ ! ! = { ! LEXTRACE("= "); ! return('='); ! } /* return '=' */ ! ! : { ! LEXTRACE(": "); ! return(':'); ! } /* return ':' */ ! ! <*>!+ { ! if (yyleng % 2 == 1) ! return('!'); /* return '!' */ ! } ! ! <*>\n { ! BEGIN INITIAL; ! ++sudolineno; ! LEXTRACE("\n"); ! return(COMMENT); ! } /* return newline */ ! ! <*>[[:blank:]]+ { /* throw away space/tabs */ ! sawspace = TRUE; /* but remember for fill_args */ ! } ! ! <*>\\[[:blank:]]*\n { ! sawspace = TRUE; /* remember for fill_args */ ! ++sudolineno; ! LEXTRACE("\n\t"); ! } /* throw away EOL after \ */ ! ! #.*\n { ! BEGIN INITIAL; ! ++sudolineno; ! LEXTRACE("\n"); ! return(COMMENT); ! } /* return comments */ ! ! <*>. { LEXTRACE("ERROR "); return(ERROR); } /* parse error */ *************** *** 354,360 **** if (yylval.command.cmnd == NULL) yyerror("unable to allocate memory"); ! /* copy the string and NULL-terminate it */ (void) strncpy(yylval.command.cmnd, s, len); yylval.command.cmnd[len] = '\0'; --- 378,384 ---- if (yylval.command.cmnd == NULL) yyerror("unable to allocate memory"); ! /* copy the string and NULL-terminate it (escapes handled by fnmatch) */ (void) strncpy(yylval.command.cmnd, s, len); yylval.command.cmnd[len] = '\0';