=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sudo/Attic/parse.yacc,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -u -r1.4 -r1.4.6.1 --- src/usr.bin/sudo/Attic/parse.yacc 2000/03/27 03:44:38 1.4 +++ src/usr.bin/sudo/Attic/parse.yacc 2002/01/18 17:20:23 1.4.6.1 @@ -1,6 +1,6 @@ %{ /* - * Copyright (c) 1996, 1998-2000 Todd C. Miller + * Copyright (c) 1996, 1998-2001 Todd C. Miller * All rights reserved. * * This code is derived from software contributed by Chris Jepeway @@ -45,30 +45,37 @@ */ #include "config.h" + +#include +#include #include #ifdef STDC_HEADERS -#include +# 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 +# include #endif /* HAVE_UNISTD_H */ #include -#include -#include -#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 +# include #endif /* HAVE_MALLOC_H && !STDC_HEADERS */ #if defined(YYBISON) && defined(HAVE_ALLOCA_H) && !defined(__GNUC__) -#include +# include #endif /* YYBISON && HAVE_ALLOCA_H && !__GNUC__ */ #ifdef HAVE_LSEARCH -#include +# include #endif /* HAVE_LSEARCH */ #include "sudo.h" @@ -79,7 +86,7 @@ #endif /* HAVE_LSEARCH */ #ifndef lint -static const char rcsid[] = "$Sudo: parse.yacc,v 1.173 2000/03/24 23:58:58 millert Exp $"; +static const char rcsid[] = "$Sudo: parse.yacc,v 1.179 2001/12/30 18:41:12 millert Exp $"; #endif /* lint */ /* @@ -91,6 +98,7 @@ int printmatches = FALSE; int pedantic = FALSE; int keepall = FALSE; +int quiet = FALSE; /* * Alias types @@ -189,10 +197,10 @@ yyerror(s) char *s; { - /* Save the line the first error occured on. */ + /* Save the line the first error occurred on. */ if (errorlineno == -1) errorlineno = sudolineno ? sudolineno - 1 : 0; - if (s) { + if (s && !quiet) { #ifndef TRACELEXER (void) fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s, sudolineno ? sudolineno - 1 : 0); @@ -214,6 +222,7 @@ %start file /* special start symbol */ %token COMMAND /* absolute pathname w/ optional args */ %token ALIAS /* an UPPERCASE alias name */ +%token DEFVAR /* a Defaults variable name */ %token NTWKADDR /* w.x.y.z */ %token NETGROUP /* a netgroup (+NAME) */ %token USERGROUP /* a usergroup (%NAME) */ @@ -230,7 +239,7 @@ %token CMNDALIAS /* Cmnd_Alias keyword */ %token USERALIAS /* User_Alias keyword */ %token RUNASALIAS /* Runas_Alias keyword */ -%token ':' '=' ',' '!' /* union member tokens */ +%token ':' '=' ',' '!' '+' '-' /* union member tokens */ %token ERROR /* @@ -290,32 +299,49 @@ defaults_list : defaults_entry | defaults_entry ',' defaults_list -defaults_entry : WORD { +defaults_entry : DEFVAR { if (defaults_matches == TRUE && - !set_default($1, NULL, 1)) { + !set_default($1, NULL, TRUE)) { yyerror(NULL); YYERROR; } free($1); } - | '!' WORD { + | '!' DEFVAR { if (defaults_matches == TRUE && - !set_default($2, NULL, 0)) { + !set_default($2, NULL, FALSE)) { yyerror(NULL); YYERROR; } free($2); } - | WORD '=' WORD { - /* XXX - need to support quoted values */ + | DEFVAR '=' WORD { if (defaults_matches == TRUE && - !set_default($1, $3, 1)) { + !set_default($1, $3, TRUE)) { yyerror(NULL); YYERROR; } free($1); free($3); } + | DEFVAR '+' WORD { + if (defaults_matches == TRUE && + !set_default($1, $3, '+')) { + yyerror(NULL); + YYERROR; + } + free($1); + free($3); + } + | DEFVAR '-' WORD { + if (defaults_matches == TRUE && + !set_default($1, $3, '-')) { + yyerror(NULL); + YYERROR; + } + free($1); + free($3); + } privileges : privilege | privileges ':' privilege @@ -463,7 +489,7 @@ */ if (runas_matches == -1) runas_matches = (strcmp(*user_runas, - def_str(I_RUNAS_DEF)) == 0); + def_str(I_RUNAS_DEFAULT)) == 0); } | RUNAS runaslist { runas_matches = ($2 == TRUE ? TRUE : FALSE); @@ -1002,7 +1028,7 @@ } while ((p = strtok(NULL, ", "))); (void) fputs(") ", stdout); } else { - (void) printf("(%s) ", def_str(I_RUNAS_DEF)); + (void) printf("(%s) ", def_str(I_RUNAS_DEFAULT)); } /* Is a password required? */