version 1.4, 2000/03/27 03:44:38 |
version 1.4.6.1, 2002/01/18 17:20:23 |
|
|
%{ |
%{ |
/* |
/* |
* Copyright (c) 1996, 1998-2000 Todd C. Miller <Todd.Miller@courtesan.com> |
* Copyright (c) 1996, 1998-2001 Todd C. Miller <Todd.Miller@courtesan.com> |
* All rights reserved. |
* All rights reserved. |
* |
* |
* This code is derived from software contributed by Chris Jepeway |
* This code is derived from software contributed by Chris Jepeway |
|
|
*/ |
*/ |
|
|
#include "config.h" |
#include "config.h" |
|
|
|
#include <sys/types.h> |
|
#include <sys/param.h> |
#include <stdio.h> |
#include <stdio.h> |
#ifdef STDC_HEADERS |
#ifdef STDC_HEADERS |
#include <stdlib.h> |
# include <stdlib.h> |
|
# include <stddef.h> |
|
#else |
|
# ifdef HAVE_STDLIB_H |
|
# include <stdlib.h> |
|
# endif |
#endif /* STDC_HEADERS */ |
#endif /* STDC_HEADERS */ |
|
#ifdef HAVE_STRING_H |
|
# include <string.h> |
|
#else |
|
# ifdef HAVE_STRINGS_H |
|
# include <strings.h> |
|
# endif |
|
#endif /* HAVE_STRING_H */ |
#ifdef HAVE_UNISTD_H |
#ifdef HAVE_UNISTD_H |
#include <unistd.h> |
# include <unistd.h> |
#endif /* HAVE_UNISTD_H */ |
#endif /* HAVE_UNISTD_H */ |
#include <pwd.h> |
#include <pwd.h> |
#include <sys/types.h> |
|
#include <sys/param.h> |
|
#ifdef HAVE_STRING_H |
|
#include <string.h> |
|
#endif /* HAVE_STRING_H */ |
|
#ifdef HAVE_STRINGS_H |
|
#include <strings.h> |
|
#endif /* HAVE_STRINGS_H */ |
|
#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS) |
#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS) |
#include <malloc.h> |
# include <malloc.h> |
#endif /* HAVE_MALLOC_H && !STDC_HEADERS */ |
#endif /* HAVE_MALLOC_H && !STDC_HEADERS */ |
#if defined(YYBISON) && defined(HAVE_ALLOCA_H) && !defined(__GNUC__) |
#if defined(YYBISON) && defined(HAVE_ALLOCA_H) && !defined(__GNUC__) |
#include <alloca.h> |
# include <alloca.h> |
#endif /* YYBISON && HAVE_ALLOCA_H && !__GNUC__ */ |
#endif /* YYBISON && HAVE_ALLOCA_H && !__GNUC__ */ |
#ifdef HAVE_LSEARCH |
#ifdef HAVE_LSEARCH |
#include <search.h> |
# include <search.h> |
#endif /* HAVE_LSEARCH */ |
#endif /* HAVE_LSEARCH */ |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#endif /* HAVE_LSEARCH */ |
#endif /* HAVE_LSEARCH */ |
|
|
#ifndef lint |
#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 */ |
#endif /* lint */ |
|
|
/* |
/* |
|
|
int printmatches = FALSE; |
int printmatches = FALSE; |
int pedantic = FALSE; |
int pedantic = FALSE; |
int keepall = FALSE; |
int keepall = FALSE; |
|
int quiet = FALSE; |
|
|
/* |
/* |
* Alias types |
* Alias types |
|
|
yyerror(s) |
yyerror(s) |
char *s; |
char *s; |
{ |
{ |
/* Save the line the first error occured on. */ |
/* Save the line the first error occurred on. */ |
if (errorlineno == -1) |
if (errorlineno == -1) |
errorlineno = sudolineno ? sudolineno - 1 : 0; |
errorlineno = sudolineno ? sudolineno - 1 : 0; |
if (s) { |
if (s && !quiet) { |
#ifndef TRACELEXER |
#ifndef TRACELEXER |
(void) fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s, |
(void) fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s, |
sudolineno ? sudolineno - 1 : 0); |
sudolineno ? sudolineno - 1 : 0); |
|
|
%start file /* special start symbol */ |
%start file /* special start symbol */ |
%token <command> COMMAND /* absolute pathname w/ optional args */ |
%token <command> COMMAND /* absolute pathname w/ optional args */ |
%token <string> ALIAS /* an UPPERCASE alias name */ |
%token <string> ALIAS /* an UPPERCASE alias name */ |
|
%token <string> DEFVAR /* a Defaults variable name */ |
%token <string> NTWKADDR /* w.x.y.z */ |
%token <string> NTWKADDR /* w.x.y.z */ |
%token <string> NETGROUP /* a netgroup (+NAME) */ |
%token <string> NETGROUP /* a netgroup (+NAME) */ |
%token <string> USERGROUP /* a usergroup (%NAME) */ |
%token <string> USERGROUP /* a usergroup (%NAME) */ |
|
|
%token <tok> CMNDALIAS /* Cmnd_Alias keyword */ |
%token <tok> CMNDALIAS /* Cmnd_Alias keyword */ |
%token <tok> USERALIAS /* User_Alias keyword */ |
%token <tok> USERALIAS /* User_Alias keyword */ |
%token <tok> RUNASALIAS /* Runas_Alias keyword */ |
%token <tok> RUNASALIAS /* Runas_Alias keyword */ |
%token <tok> ':' '=' ',' '!' /* union member tokens */ |
%token <tok> ':' '=' ',' '!' '+' '-' /* union member tokens */ |
%token <tok> ERROR |
%token <tok> ERROR |
|
|
/* |
/* |
|
|
defaults_list : defaults_entry |
defaults_list : defaults_entry |
| defaults_entry ',' defaults_list |
| defaults_entry ',' defaults_list |
|
|
defaults_entry : WORD { |
defaults_entry : DEFVAR { |
if (defaults_matches == TRUE && |
if (defaults_matches == TRUE && |
!set_default($1, NULL, 1)) { |
!set_default($1, NULL, TRUE)) { |
yyerror(NULL); |
yyerror(NULL); |
YYERROR; |
YYERROR; |
} |
} |
free($1); |
free($1); |
} |
} |
| '!' WORD { |
| '!' DEFVAR { |
if (defaults_matches == TRUE && |
if (defaults_matches == TRUE && |
!set_default($2, NULL, 0)) { |
!set_default($2, NULL, FALSE)) { |
yyerror(NULL); |
yyerror(NULL); |
YYERROR; |
YYERROR; |
} |
} |
free($2); |
free($2); |
} |
} |
| WORD '=' WORD { |
| DEFVAR '=' WORD { |
/* XXX - need to support quoted values */ |
|
if (defaults_matches == TRUE && |
if (defaults_matches == TRUE && |
!set_default($1, $3, 1)) { |
!set_default($1, $3, TRUE)) { |
yyerror(NULL); |
yyerror(NULL); |
YYERROR; |
YYERROR; |
} |
} |
free($1); |
free($1); |
free($3); |
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 |
| privileges ':' privilege |
| privileges ':' privilege |
|
|
*/ |
*/ |
if (runas_matches == -1) |
if (runas_matches == -1) |
runas_matches = (strcmp(*user_runas, |
runas_matches = (strcmp(*user_runas, |
def_str(I_RUNAS_DEF)) == 0); |
def_str(I_RUNAS_DEFAULT)) == 0); |
} |
} |
| RUNAS runaslist { |
| RUNAS runaslist { |
runas_matches = ($2 == TRUE ? TRUE : FALSE); |
runas_matches = ($2 == TRUE ? TRUE : FALSE); |
|
|
} while ((p = strtok(NULL, ", "))); |
} while ((p = strtok(NULL, ", "))); |
(void) fputs(") ", stdout); |
(void) fputs(") ", stdout); |
} else { |
} else { |
(void) printf("(%s) ", def_str(I_RUNAS_DEF)); |
(void) printf("(%s) ", def_str(I_RUNAS_DEFAULT)); |
} |
} |
|
|
/* Is a password required? */ |
/* Is a password required? */ |