Set yacc prefix to "sudoers" to avoid conflicts other yacc parsers.

This commit is contained in:
Todd C. Miller
2012-09-14 16:19:25 -04:00
parent 0c9083b141
commit 5276ab3a5f
12 changed files with 291 additions and 247 deletions

View File

@@ -218,7 +218,7 @@ $(devdir)/gram.c $(devdir)/gram.h: $(srcdir)/gram.y
else \ else \
gram_y="$(srcdir)/gram.y"; \ gram_y="$(srcdir)/gram.y"; \
fi; \ fi; \
cmd='$(YACC) -d '"$$gram_y"'; echo "#include <config.h>" > $(devdir)/gram.c; sed "s/^\\(#line .*\\) \"y\\.tab\\.c\"/\1 \"gram.c\"/" y.tab.c >> $(devdir)/gram.c; rm -f y.tab.c; mv -f y.tab.h $(devdir)/gram.h'; \ cmd='$(YACC) -d -p sudoers '"$$gram_y"'; echo "#include <config.h>" > $(devdir)/gram.c; sed "s/^\\(#line .*\\) \"y\\.tab\\.c\"/\1 \"gram.c\"/" y.tab.c >> $(devdir)/gram.c; rm -f y.tab.c; mv -f y.tab.h $(devdir)/gram.h'; \
echo "$$cmd"; eval $$cmd; \ echo "$$cmd"; eval $$cmd; \
fi fi
@@ -229,7 +229,7 @@ $(devdir)/toke.c: $(srcdir)/toke.l
else \ else \
toke_l="$(srcdir)/toke.l"; \ toke_l="$(srcdir)/toke.l"; \
fi; \ fi; \
cmd='$(FLEX) '"$$toke_l"'; echo "#include <config.h>" > $(devdir)/toke.c; cat lex.yy.c >> $(devdir)/toke.c; rm -f lex.yy.c'; \ cmd='$(FLEX) '"$$toke_l"'; echo "#include <config.h>" > $(devdir)/toke.c; cat lex.sudoers.c >> $(devdir)/toke.c; rm -f lex.sudoers.c'; \
echo "$$cmd"; eval $$cmd; \ echo "$$cmd"; eval $$cmd; \
fi fi

View File

@@ -9,7 +9,33 @@
#define yyclearin (yychar=(YYEMPTY)) #define yyclearin (yychar=(YYEMPTY))
#define yyerrok (yyerrflag=0) #define yyerrok (yyerrflag=0)
#define YYRECOVERING() (yyerrflag!=0) #define YYRECOVERING() (yyerrflag!=0)
#define YYPREFIX "yy" #define yyparse sudoersparse
#define yylex sudoerslex
#define yyerror sudoerserror
#define yychar sudoerschar
#define yyval sudoersval
#define yylval sudoerslval
#define yydebug sudoersdebug
#define yynerrs sudoersnerrs
#define yyerrflag sudoerserrflag
#define yyss sudoersss
#define yysslim sudoerssslim
#define yyssp sudoersssp
#define yyvs sudoersvs
#define yyvsp sudoersvsp
#define yystacksize sudoersstacksize
#define yylhs sudoerslhs
#define yylen sudoerslen
#define yydefred sudoersdefred
#define yydgoto sudoersdgoto
#define yysindex sudoerssindex
#define yyrindex sudoersrindex
#define yygindex sudoersgindex
#define yytable sudoerstable
#define yycheck sudoerscheck
#define yyname sudoersname
#define yyrule sudoersrule
#define YYPREFIX "sudoers"
#line 2 "gram.y" #line 2 "gram.y"
/* /*
* Copyright (c) 1996, 1998-2005, 2007-2012 * Copyright (c) 1996, 1998-2005, 2007-2012
@@ -146,7 +172,7 @@ typedef union {
int tok; int tok;
} YYSTYPE; } YYSTYPE;
#endif /* YYSTYPE_DEFINED */ #endif /* YYSTYPE_DEFINED */
#line 149 "gram.c" #line 175 "gram.c"
#define COMMAND 257 #define COMMAND 257
#define ALIAS 258 #define ALIAS 258
#define DEFVAR 259 #define DEFVAR 259
@@ -183,9 +209,9 @@ typedef union {
#define MYSELF 290 #define MYSELF 290
#define YYERRCODE 256 #define YYERRCODE 256
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yylhs[] = const short sudoerslhs[] =
#else #else
short yylhs[] = short sudoerslhs[] =
#endif #endif
{ -1, { -1,
0, 0, 28, 28, 29, 29, 29, 29, 29, 29, 0, 0, 28, 28, 29, 29, 29, 29, 29, 29,
@@ -201,9 +227,9 @@ short yylhs[] =
14, 14, 15, 15, 15, 14, 14, 15, 15, 15,
}; };
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yylen[] = const short sudoerslen[] =
#else #else
short yylen[] = short sudoerslen[] =
#endif #endif
{ 2, { 2,
0, 1, 1, 2, 1, 2, 2, 2, 2, 2, 0, 1, 1, 2, 1, 2, 2, 2, 2, 2,
@@ -219,9 +245,9 @@ short yylen[] =
1, 2, 1, 1, 1, 1, 2, 1, 1, 1,
}; };
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yydefred[] = const short sudoersdefred[] =
#else #else
short yydefred[] = short sudoersdefred[] =
#endif #endif
{ 0, { 0,
0, 94, 96, 97, 98, 0, 0, 0, 0, 0, 0, 94, 96, 97, 98, 0, 0, 0, 0, 0,
@@ -242,9 +268,9 @@ short yydefred[] =
63, 64, 65, 66, 67, 68, 69, 70, 36, 63, 64, 65, 66, 67, 68, 69, 70, 36,
}; };
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yydgoto[] = const short sudoersdgoto[] =
#else #else
short yydgoto[] = short sudoersdgoto[] =
#endif #endif
{ 18, { 18,
104, 105, 27, 28, 44, 45, 46, 35, 61, 37, 104, 105, 27, 28, 44, 45, 46, 35, 61, 37,
@@ -253,9 +279,9 @@ short yydgoto[] =
48, 51, 57, 49, 52, 58, 55, 48, 51, 57, 49, 52, 58, 55,
}; };
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yysindex[] = const short sudoerssindex[] =
#else #else
short yysindex[] = short sudoerssindex[] =
#endif #endif
{ 541, { 541,
-270, 0, 0, 0, 0, -21, -5, 553, 553, 20, -270, 0, 0, 0, 0, -21, -5, 553, 553, 20,
@@ -275,9 +301,9 @@ short yysindex[] =
-169, -168, 569, 0, 0, 0, 0, 0, 0, 0, -169, -168, 569, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,}; 0, 0, 0, 0, 0, 0, 0, 0, 0,};
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yyrindex[] = const short sudoersrindex[] =
#else #else
short yyrindex[] = short sudoersrindex[] =
#endif #endif
{ 96, { 96,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -297,9 +323,9 @@ short yyrindex[] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,}; 0, 0, 0, 0, 0, 0, 0, 0, 0,};
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yygindex[] = const short sudoersgindex[] =
#else #else
short yygindex[] = short sudoersgindex[] =
#endif #endif
{ 0, { 0,
-11, 0, 39, 12, 66, -72, 27, 76, -4, 40, -11, 0, 39, 12, 66, -72, 27, 76, -4, 40,
@@ -309,9 +335,9 @@ short yygindex[] =
}; };
#define YYTABLESIZE 932 #define YYTABLESIZE 932
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yytable[] = const short sudoerstable[] =
#else #else
short yytable[] = short sudoerstable[] =
#endif #endif
{ 26, { 26,
19, 26, 36, 94, 41, 34, 38, 39, 26, 24, 19, 26, 36, 94, 41, 34, 38, 39, 26, 24,
@@ -410,9 +436,9 @@ short yytable[] =
50, 50, 50, 50,
}; };
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const short yycheck[] = const short sudoerscheck[] =
#else #else
short yycheck[] = short sudoerscheck[] =
#endif #endif
{ 33, { 33,
0, 33, 7, 76, 33, 33, 8, 9, 33, 280, 0, 33, 7, 76, 33, 33, 8, 9, 33, 280,
@@ -517,9 +543,9 @@ short yycheck[] =
#define YYMAXTOKEN 290 #define YYMAXTOKEN 290
#if YYDEBUG #if YYDEBUG
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const char * const yyname[] = const char * const sudoersname[] =
#else #else
char *yyname[] = char *sudoersname[] =
#endif #endif
{ {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -536,9 +562,9 @@ char *yyname[] =
"RUNASALIAS","ERROR","TYPE","ROLE","PRIVS","LIMITPRIVS","MYSELF", "RUNASALIAS","ERROR","TYPE","ROLE","PRIVS","LIMITPRIVS","MYSELF",
}; };
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
const char * const yyrule[] = const char * const sudoersrule[] =
#else #else
char *yyrule[] = char *sudoersrule[] =
#endif #endif
{"$accept : file", {"$accept : file",
"file :", "file :",
@@ -876,7 +902,7 @@ init_parser(const char *path, bool quiet)
debug_return; debug_return;
} }
#line 827 "gram.c" #line 853 "gram.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
static int yygrowstack(void) static int yygrowstack(void)
@@ -1716,7 +1742,7 @@ case 105:
yyval.member = new_member(yyvsp[0].string, WORD); yyval.member = new_member(yyvsp[0].string, WORD);
} }
break; break;
#line 1667 "gram.c" #line 1693 "gram.c"
} }
yyssp -= yym; yyssp -= yym;
yystate = *yyssp; yystate = *yyssp;

View File

@@ -48,4 +48,4 @@ typedef union {
int tok; int tok;
} YYSTYPE; } YYSTYPE;
#endif /* YYSTYPE_DEFINED */ #endif /* YYSTYPE_DEFINED */
extern YYSTYPE yylval; extern YYSTYPE sudoerslval;

View File

@@ -68,7 +68,7 @@ struct sudo_nss sudo_nss_file = {
/* /*
* Parser externs. * Parser externs.
*/ */
extern FILE *yyin; extern FILE *sudoersin;
extern char *errorfile; extern char *errorfile;
extern int errorlineno; extern int errorlineno;
extern bool parse_error; extern bool parse_error;
@@ -100,7 +100,7 @@ sudo_file_close(struct sudo_nss *nss)
if (nss->handle != NULL) { if (nss->handle != NULL) {
fclose(nss->handle); fclose(nss->handle);
nss->handle = NULL; nss->handle = NULL;
yyin = NULL; sudoersin = NULL;
} }
debug_return_int(0); debug_return_int(0);
} }
@@ -117,8 +117,8 @@ sudo_file_parse(struct sudo_nss *nss)
debug_return_int(-1); debug_return_int(-1);
init_parser(sudoers_file, false); init_parser(sudoers_file, false);
yyin = nss->handle; sudoersin = nss->handle;
if (yyparse() != 0 || parse_error) { if (sudoersparse() != 0 || parse_error) {
if (errorlineno != -1) { if (errorlineno != -1) {
log_error(0, _("parse error in %s near line %d"), log_error(0, _("parse error in %s near line %d"),
errorfile, errorlineno); errorfile, errorlineno);

View File

@@ -54,7 +54,7 @@
sudo_conv_t sudo_conv; /* NULL in non-plugin */ sudo_conv_t sudo_conv; /* NULL in non-plugin */
YYSTYPE yylval; YYSTYPE sudoerslval;
struct fill_test { struct fill_test {
const char *input; const char *input;
@@ -106,8 +106,8 @@ check_fill(const char *input, int len, int addspace, const char *expect, char **
{ {
if (!fill(input, len)) if (!fill(input, len))
return -1; return -1;
*resultp = yylval.string; *resultp = sudoerslval.string;
return !strcmp(yylval.string, expect); return !strcmp(sudoerslval.string, expect);
} }
static int static int
@@ -115,8 +115,8 @@ check_fill_cmnd(const char *input, int len, int addspace, const char *expect, ch
{ {
if (!fill_cmnd(input, len)) if (!fill_cmnd(input, len))
return -1; return -1;
*resultp = yylval.command.cmnd; *resultp = sudoerslval.command.cmnd;
return !strcmp(yylval.command.cmnd, expect); return !strcmp(sudoerslval.command.cmnd, expect);
} }
static int static int
@@ -124,8 +124,8 @@ check_fill_args(const char *input, int len, int addspace, const char *expect, ch
{ {
if (!fill_args(input, len, addspace)) if (!fill_args(input, len, addspace))
return -1; return -1;
*resultp = yylval.command.args; *resultp = sudoerslval.command.args;
return !strcmp(yylval.command.args, expect); return !strcmp(sudoerslval.command.args, expect);
} }
static int static int
@@ -191,7 +191,7 @@ cleanup(int gotsig)
/* STUB */ /* STUB */
void void
yyerror(const char *s) sudoerserror(const char *s)
{ {
return; return;
} }

View File

@@ -221,7 +221,7 @@ struct timeval;
/* /*
* Function prototypes * Function prototypes
*/ */
#define YY_DECL int yylex(void) #define YY_DECL int sudoerslex(void)
/* goodpath.c */ /* goodpath.c */
bool sudo_goodpath(const char *, struct stat *); bool sudo_goodpath(const char *, struct stat *);
@@ -259,7 +259,7 @@ void restore_perms(void);
int pam_prep_user(struct passwd *); int pam_prep_user(struct passwd *);
/* gram.y */ /* gram.y */
int yyparse(void); int sudoersparse(void);
/* toke.l */ /* toke.l */
YY_DECL; YY_DECL;

View File

@@ -124,7 +124,7 @@ extern int optind;
extern char *malloc_options; extern char *malloc_options;
#endif #endif
#ifdef YYDEBUG #ifdef YYDEBUG
extern int yydebug; extern int sudoersdebug;
#endif #endif
int int
@@ -143,7 +143,7 @@ main(int argc, char *argv[])
malloc_options = "AFGJPR"; malloc_options = "AFGJPR";
#endif #endif
#ifdef YYDEBUG #ifdef YYDEBUG
yydebug = 1; sudoersdebug = 1;
#endif #endif
#if !defined(HAVE_GETPROGNAME) && !defined(HAVE___PROGNAME) #if !defined(HAVE_GETPROGNAME) && !defined(HAVE___PROGNAME)
@@ -270,7 +270,7 @@ main(int argc, char *argv[])
/* Allocate space for data structures in the parser. */ /* Allocate space for data structures in the parser. */
init_parser("sudoers", false); init_parser("sudoers", false);
if (yyparse() != 0 || parse_error) { if (sudoersparse() != 0 || parse_error) {
parse_error = true; parse_error = true;
if (errorlineno != -1) if (errorlineno != -1)
(void) printf("Parse error in %s near line %d", (void) printf("Parse error in %s near line %d",

View File

@@ -1,4 +1,21 @@
#include <config.h> #include <config.h>
#define yy_create_buffer sudoers_create_buffer
#define yy_delete_buffer sudoers_delete_buffer
#define yy_scan_buffer sudoers_scan_buffer
#define yy_scan_string sudoers_scan_string
#define yy_scan_bytes sudoers_scan_bytes
#define yy_flex_debug sudoers_flex_debug
#define yy_init_buffer sudoers_init_buffer
#define yy_flush_buffer sudoers_flush_buffer
#define yy_load_buffer_state sudoers_load_buffer_state
#define yy_switch_to_buffer sudoers_switch_to_buffer
#define yyin sudoersin
#define yyleng sudoersleng
#define yylex sudoerslex
#define yyout sudoersout
#define yyrestart sudoersrestart
#define yytext sudoerstext
/* $OpenBSD: flex.skl,v 1.11 2010/08/04 18:24:50 millert Exp $ */ /* $OpenBSD: flex.skl,v 1.11 2010/08/04 18:24:50 millert Exp $ */
/* A lexical scanner generated by flex */ /* A lexical scanner generated by flex */
@@ -1468,7 +1485,7 @@ char *yytext;
#include "lbuf.h" #include "lbuf.h"
#include "secure_path.h" #include "secure_path.h"
extern YYSTYPE yylval; extern YYSTYPE sudoerslval;
extern bool parse_error; extern bool parse_error;
extern bool sudoers_warnings; extern bool sudoers_warnings;
int sudolineno; int sudolineno;
@@ -1495,7 +1512,7 @@ int (*trace_print)(const char *msg) = sudoers_trace_print;
return (n); \ return (n); \
} while (0) } while (0)
#define ECHO ignore_result(fwrite(yytext, yyleng, 1, yyout)) #define ECHO ignore_result(fwrite(sudoerstext, sudoersleng, 1, sudoersout))
#define push_include(_p) (_push_include((_p), false)) #define push_include(_p) (_push_include((_p), false))
#define push_includedir(_p) (_push_include((_p), true)) #define push_includedir(_p) (_push_include((_p), true))
@@ -1511,7 +1528,7 @@ int (*trace_print)(const char *msg) = sudoers_trace_print;
#define INSTR 5 #define INSTR 5
#line 1514 "lex.yy.c" #line 1531 "lex.sudoers.c"
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
@@ -1665,9 +1682,9 @@ YY_DECL
register char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
register int yy_act; register int yy_act;
#line 132 "toke.l" #line 133 "toke.l"
#line 1670 "lex.yy.c" #line 1687 "lex.sudoers.c"
if ( yy_init ) if ( yy_init )
{ {
@@ -1753,7 +1770,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 133 "toke.l" #line 134 "toke.l"
{ {
LEXTRACE(", "); LEXTRACE(", ");
LEXRETURN(','); LEXRETURN(',');
@@ -1761,16 +1778,16 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 138 "toke.l" #line 139 "toke.l"
BEGIN STARTDEFS; BEGIN STARTDEFS;
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 140 "toke.l" #line 141 "toke.l"
{ {
BEGIN INDEFS; BEGIN INDEFS;
LEXTRACE("DEFVAR "); LEXTRACE("DEFVAR ");
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXRETURN(DEFVAR); LEXRETURN(DEFVAR);
} }
@@ -1778,7 +1795,7 @@ YY_RULE_SETUP
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 149 "toke.l" #line 150 "toke.l"
{ {
BEGIN STARTDEFS; BEGIN STARTDEFS;
LEXTRACE(", "); LEXTRACE(", ");
@@ -1787,7 +1804,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 155 "toke.l" #line 156 "toke.l"
{ {
LEXTRACE("= "); LEXTRACE("= ");
LEXRETURN('='); LEXRETURN('=');
@@ -1795,7 +1812,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 160 "toke.l" #line 161 "toke.l"
{ {
LEXTRACE("+= "); LEXTRACE("+= ");
LEXRETURN('+'); LEXRETURN('+');
@@ -1803,7 +1820,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 165 "toke.l" #line 166 "toke.l"
{ {
LEXTRACE("-= "); LEXTRACE("-= ");
LEXRETURN('-'); LEXRETURN('-');
@@ -1811,20 +1828,20 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 170 "toke.l" #line 171 "toke.l"
{ {
LEXTRACE("BEGINSTR "); LEXTRACE("BEGINSTR ");
yylval.string = NULL; sudoerslval.string = NULL;
prev_state = YY_START; prev_state = YY_START;
BEGIN INSTR; BEGIN INSTR;
} }
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 177 "toke.l" #line 178 "toke.l"
{ {
LEXTRACE("WORD(2) "); LEXTRACE("WORD(2) ");
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXRETURN(WORD); LEXRETURN(WORD);
} }
@@ -1833,7 +1850,7 @@ YY_RULE_SETUP
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 186 "toke.l" #line 187 "toke.l"
{ {
/* Line continuation char followed by newline. */ /* Line continuation char followed by newline. */
sudolineno++; sudolineno++;
@@ -1842,28 +1859,28 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 192 "toke.l" #line 193 "toke.l"
{ {
LEXTRACE("ENDSTR "); LEXTRACE("ENDSTR ");
BEGIN prev_state; BEGIN prev_state;
if (yylval.string == NULL) { if (sudoerslval.string == NULL) {
LEXTRACE("ERROR "); /* empty string */ LEXTRACE("ERROR "); /* empty string */
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if (prev_state == INITIAL) { if (prev_state == INITIAL) {
switch (yylval.string[0]) { switch (sudoerslval.string[0]) {
case '%': case '%':
if (yylval.string[1] == '\0' || if (sudoerslval.string[1] == '\0' ||
(yylval.string[1] == ':' && (sudoerslval.string[1] == ':' &&
yylval.string[2] == '\0')) { sudoerslval.string[2] == '\0')) {
LEXTRACE("ERROR "); /* empty group */ LEXTRACE("ERROR "); /* empty group */
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
LEXTRACE("USERGROUP "); LEXTRACE("USERGROUP ");
LEXRETURN(USERGROUP); LEXRETURN(USERGROUP);
case '+': case '+':
if (yylval.string[1] == '\0') { if (sudoerslval.string[1] == '\0') {
LEXTRACE("ERROR "); /* empty netgroup */ LEXTRACE("ERROR "); /* empty netgroup */
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
@@ -1877,19 +1894,19 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 224 "toke.l" #line 225 "toke.l"
{ {
LEXTRACE("BACKSLASH "); LEXTRACE("BACKSLASH ");
if (!append(yytext, yyleng)) if (!append(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
} }
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 230 "toke.l" #line 231 "toke.l"
{ {
LEXTRACE("STRBODY "); LEXTRACE("STRBODY ");
if (!append(yytext, yyleng)) if (!append(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
} }
YY_BREAK YY_BREAK
@@ -1897,29 +1914,29 @@ YY_RULE_SETUP
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 238 "toke.l" #line 239 "toke.l"
{ {
/* quoted fnmatch glob char, pass verbatim */ /* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR "); LEXTRACE("QUOTEDCHAR ");
if (!fill_args(yytext, 2, sawspace)) if (!fill_args(sudoerstext, 2, sawspace))
yyterminate(); yyterminate();
sawspace = false; sawspace = false;
} }
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 246 "toke.l" #line 247 "toke.l"
{ {
/* quoted sudoers special char, strip backslash */ /* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR "); LEXTRACE("QUOTEDCHAR ");
if (!fill_args(yytext + 1, 1, sawspace)) if (!fill_args(sudoerstext + 1, 1, sawspace))
yyterminate(); yyterminate();
sawspace = false; sawspace = false;
} }
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 254 "toke.l" #line 255 "toke.l"
{ {
BEGIN INITIAL; BEGIN INITIAL;
yyless(0); yyless(0);
@@ -1928,10 +1945,10 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 260 "toke.l" #line 261 "toke.l"
{ {
LEXTRACE("ARG "); LEXTRACE("ARG ");
if (!fill_args(yytext, yyleng, sawspace)) if (!fill_args(sudoerstext, sudoersleng, sawspace))
yyterminate(); yyterminate();
sawspace = false; sawspace = false;
} /* a command line arg */ } /* a command line arg */
@@ -1939,7 +1956,7 @@ YY_RULE_SETUP
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 268 "toke.l" #line 269 "toke.l"
{ {
char *path; char *path;
@@ -1948,7 +1965,7 @@ YY_RULE_SETUP
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if ((path = parse_include(yytext)) == NULL) if ((path = parse_include(sudoerstext)) == NULL)
yyterminate(); yyterminate();
LEXTRACE("INCLUDE\n"); LEXTRACE("INCLUDE\n");
@@ -1960,7 +1977,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 286 "toke.l" #line 287 "toke.l"
{ {
char *path; char *path;
@@ -1969,7 +1986,7 @@ YY_RULE_SETUP
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if ((path = parse_include(yytext)) == NULL) if ((path = parse_include(sudoerstext)) == NULL)
yyterminate(); yyterminate();
LEXTRACE("INCLUDEDIR\n"); LEXTRACE("INCLUDEDIR\n");
@@ -1984,7 +2001,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
#line 307 "toke.l" #line 308 "toke.l"
{ {
char deftype; char deftype;
int n; int n;
@@ -1994,11 +2011,11 @@ YY_RULE_SETUP
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
for (n = 0; isblank((unsigned char)yytext[n]); n++) for (n = 0; isblank((unsigned char)sudoerstext[n]); n++)
continue; continue;
n += sizeof("Defaults") - 1; n += sizeof("Defaults") - 1;
if ((deftype = yytext[n++]) != '\0') { if ((deftype = sudoerstext[n++]) != '\0') {
while (isblank((unsigned char)yytext[n])) while (isblank((unsigned char)sudoerstext[n]))
n++; n++;
} }
BEGIN GOTDEFS; BEGIN GOTDEFS;
@@ -2027,7 +2044,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 347 "toke.l" #line 348 "toke.l"
{ {
int n; int n;
@@ -2036,9 +2053,9 @@ YY_RULE_SETUP
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
for (n = 0; isblank((unsigned char)yytext[n]); n++) for (n = 0; isblank((unsigned char)sudoerstext[n]); n++)
continue; continue;
switch (yytext[n]) { switch (sudoerstext[n]) {
case 'H': case 'H':
LEXTRACE("HOSTALIAS "); LEXTRACE("HOSTALIAS ");
LEXRETURN(HOSTALIAS); LEXRETURN(HOSTALIAS);
@@ -2056,7 +2073,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 373 "toke.l" #line 374 "toke.l"
{ {
/* cmnd does not require passwd for this user */ /* cmnd does not require passwd for this user */
LEXTRACE("NOPASSWD "); LEXTRACE("NOPASSWD ");
@@ -2065,7 +2082,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 379 "toke.l" #line 380 "toke.l"
{ {
/* cmnd requires passwd for this user */ /* cmnd requires passwd for this user */
LEXTRACE("PASSWD "); LEXTRACE("PASSWD ");
@@ -2074,7 +2091,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 385 "toke.l" #line 386 "toke.l"
{ {
LEXTRACE("NOEXEC "); LEXTRACE("NOEXEC ");
LEXRETURN(NOEXEC); LEXRETURN(NOEXEC);
@@ -2082,7 +2099,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 390 "toke.l" #line 391 "toke.l"
{ {
LEXTRACE("EXEC "); LEXTRACE("EXEC ");
LEXRETURN(EXEC); LEXRETURN(EXEC);
@@ -2090,7 +2107,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 395 "toke.l" #line 396 "toke.l"
{ {
LEXTRACE("SETENV "); LEXTRACE("SETENV ");
LEXRETURN(SETENV); LEXRETURN(SETENV);
@@ -2098,7 +2115,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 400 "toke.l" #line 401 "toke.l"
{ {
LEXTRACE("NOSETENV "); LEXTRACE("NOSETENV ");
LEXRETURN(NOSETENV); LEXRETURN(NOSETENV);
@@ -2106,7 +2123,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 405 "toke.l" #line 406 "toke.l"
{ {
LEXTRACE("LOG_OUTPUT "); LEXTRACE("LOG_OUTPUT ");
LEXRETURN(LOG_OUTPUT); LEXRETURN(LOG_OUTPUT);
@@ -2114,7 +2131,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 410 "toke.l" #line 411 "toke.l"
{ {
LEXTRACE("NOLOG_OUTPUT "); LEXTRACE("NOLOG_OUTPUT ");
LEXRETURN(NOLOG_OUTPUT); LEXRETURN(NOLOG_OUTPUT);
@@ -2122,7 +2139,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 415 "toke.l" #line 416 "toke.l"
{ {
LEXTRACE("LOG_INPUT "); LEXTRACE("LOG_INPUT ");
LEXRETURN(LOG_INPUT); LEXRETURN(LOG_INPUT);
@@ -2130,7 +2147,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 31: case 31:
YY_RULE_SETUP YY_RULE_SETUP
#line 420 "toke.l" #line 421 "toke.l"
{ {
LEXTRACE("NOLOG_INPUT "); LEXTRACE("NOLOG_INPUT ");
LEXRETURN(NOLOG_INPUT); LEXRETURN(NOLOG_INPUT);
@@ -2138,7 +2155,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 32: case 32:
YY_RULE_SETUP YY_RULE_SETUP
#line 425 "toke.l" #line 426 "toke.l"
{ {
/* empty group or netgroup */ /* empty group or netgroup */
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
@@ -2147,10 +2164,10 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 33: case 33:
YY_RULE_SETUP YY_RULE_SETUP
#line 431 "toke.l" #line 432 "toke.l"
{ {
/* netgroup */ /* netgroup */
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NETGROUP "); LEXTRACE("NETGROUP ");
LEXRETURN(NETGROUP); LEXRETURN(NETGROUP);
@@ -2158,10 +2175,10 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 439 "toke.l" #line 440 "toke.l"
{ {
/* group */ /* group */
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("USERGROUP "); LEXTRACE("USERGROUP ");
LEXRETURN(USERGROUP); LEXRETURN(USERGROUP);
@@ -2169,9 +2186,9 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 447 "toke.l" #line 448 "toke.l"
{ {
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NTWKADDR "); LEXTRACE("NTWKADDR ");
LEXRETURN(NTWKADDR); LEXRETURN(NTWKADDR);
@@ -2179,9 +2196,9 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 454 "toke.l" #line 455 "toke.l"
{ {
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NTWKADDR "); LEXTRACE("NTWKADDR ");
LEXRETURN(NTWKADDR); LEXRETURN(NTWKADDR);
@@ -2189,13 +2206,13 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 461 "toke.l" #line 462 "toke.l"
{ {
if (!ipv6_valid(yytext)) { if (!ipv6_valid(sudoerstext)) {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NTWKADDR "); LEXTRACE("NTWKADDR ");
LEXRETURN(NTWKADDR); LEXRETURN(NTWKADDR);
@@ -2203,13 +2220,13 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 472 "toke.l" #line 473 "toke.l"
{ {
if (!ipv6_valid(yytext)) { if (!ipv6_valid(sudoerstext)) {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NTWKADDR "); LEXTRACE("NTWKADDR ");
LEXRETURN(NTWKADDR); LEXRETURN(NTWKADDR);
@@ -2217,7 +2234,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP YY_RULE_SETUP
#line 483 "toke.l" #line 484 "toke.l"
{ {
LEXTRACE("ALL "); LEXTRACE("ALL ");
LEXRETURN(ALL); LEXRETURN(ALL);
@@ -2226,7 +2243,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 40: case 40:
YY_RULE_SETUP YY_RULE_SETUP
#line 489 "toke.l" #line 490 "toke.l"
{ {
#ifdef HAVE_SELINUX #ifdef HAVE_SELINUX
LEXTRACE("ROLE "); LEXTRACE("ROLE ");
@@ -2238,7 +2255,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 41: case 41:
YY_RULE_SETUP YY_RULE_SETUP
#line 498 "toke.l" #line 499 "toke.l"
{ {
#ifdef HAVE_SELINUX #ifdef HAVE_SELINUX
LEXTRACE("TYPE "); LEXTRACE("TYPE ");
@@ -2250,7 +2267,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 42: case 42:
YY_RULE_SETUP YY_RULE_SETUP
#line 506 "toke.l" #line 507 "toke.l"
{ {
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET
LEXTRACE("PRIVS "); LEXTRACE("PRIVS ");
@@ -2262,7 +2279,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 43: case 43:
YY_RULE_SETUP YY_RULE_SETUP
#line 515 "toke.l" #line 516 "toke.l"
{ {
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET
LEXTRACE("LIMITPRIVS "); LEXTRACE("LIMITPRIVS ");
@@ -2274,10 +2291,10 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 44: case 44:
YY_RULE_SETUP YY_RULE_SETUP
#line 524 "toke.l" #line 525 "toke.l"
{ {
got_alias: got_alias:
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("ALIAS "); LEXTRACE("ALIAS ");
LEXRETURN(ALIAS); LEXRETURN(ALIAS);
@@ -2285,10 +2302,10 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 45: case 45:
YY_RULE_SETUP YY_RULE_SETUP
#line 532 "toke.l" #line 533 "toke.l"
{ {
/* no command args allowed for Defaults!/path */ /* no command args allowed for Defaults!/path */
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
LEXRETURN(COMMAND); LEXRETURN(COMMAND);
@@ -2296,48 +2313,48 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 46: case 46:
YY_RULE_SETUP YY_RULE_SETUP
#line 540 "toke.l" #line 541 "toke.l"
{ {
BEGIN GOTCMND; BEGIN GOTCMND;
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
} /* sudo -e */ } /* sudo -e */
YY_BREAK YY_BREAK
case 47: case 47:
YY_RULE_SETUP YY_RULE_SETUP
#line 547 "toke.l" #line 548 "toke.l"
{ {
/* directories can't have args... */ /* directories can't have args... */
if (yytext[yyleng - 1] == '/') { if (sudoerstext[sudoersleng - 1] == '/') {
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXRETURN(COMMAND); LEXRETURN(COMMAND);
} else { } else {
BEGIN GOTCMND; BEGIN GOTCMND;
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
} }
} /* a pathname */ } /* a pathname */
YY_BREAK YY_BREAK
case 48: case 48:
YY_RULE_SETUP YY_RULE_SETUP
#line 562 "toke.l" #line 563 "toke.l"
{ {
LEXTRACE("BEGINSTR "); LEXTRACE("BEGINSTR ");
yylval.string = NULL; sudoerslval.string = NULL;
prev_state = YY_START; prev_state = YY_START;
BEGIN INSTR; BEGIN INSTR;
} }
YY_BREAK YY_BREAK
case 49: case 49:
YY_RULE_SETUP YY_RULE_SETUP
#line 569 "toke.l" #line 570 "toke.l"
{ {
/* a word */ /* a word */
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("WORD(5) "); LEXTRACE("WORD(5) ");
LEXRETURN(WORD); LEXRETURN(WORD);
@@ -2345,7 +2362,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 50: case 50:
YY_RULE_SETUP YY_RULE_SETUP
#line 577 "toke.l" #line 578 "toke.l"
{ {
LEXTRACE("( "); LEXTRACE("( ");
LEXRETURN('('); LEXRETURN('(');
@@ -2353,7 +2370,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 51: case 51:
YY_RULE_SETUP YY_RULE_SETUP
#line 582 "toke.l" #line 583 "toke.l"
{ {
LEXTRACE(") "); LEXTRACE(") ");
LEXRETURN(')'); LEXRETURN(')');
@@ -2361,7 +2378,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 52: case 52:
YY_RULE_SETUP YY_RULE_SETUP
#line 587 "toke.l" #line 588 "toke.l"
{ {
LEXTRACE(", "); LEXTRACE(", ");
LEXRETURN(','); LEXRETURN(',');
@@ -2369,7 +2386,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 53: case 53:
YY_RULE_SETUP YY_RULE_SETUP
#line 592 "toke.l" #line 593 "toke.l"
{ {
LEXTRACE("= "); LEXTRACE("= ");
LEXRETURN('='); LEXRETURN('=');
@@ -2377,7 +2394,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 54: case 54:
YY_RULE_SETUP YY_RULE_SETUP
#line 597 "toke.l" #line 598 "toke.l"
{ {
LEXTRACE(": "); LEXTRACE(": ");
LEXRETURN(':'); LEXRETURN(':');
@@ -2385,9 +2402,9 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 55: case 55:
YY_RULE_SETUP YY_RULE_SETUP
#line 602 "toke.l" #line 603 "toke.l"
{ {
if (yyleng & 1) { if (sudoersleng & 1) {
LEXTRACE("!"); LEXTRACE("!");
LEXRETURN('!'); /* return '!' */ LEXRETURN('!'); /* return '!' */
} }
@@ -2395,7 +2412,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 56: case 56:
YY_RULE_SETUP YY_RULE_SETUP
#line 609 "toke.l" #line 610 "toke.l"
{ {
if (YY_START == INSTR) { if (YY_START == INSTR) {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
@@ -2410,14 +2427,14 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 57: case 57:
YY_RULE_SETUP YY_RULE_SETUP
#line 621 "toke.l" #line 622 "toke.l"
{ /* throw away space/tabs */ { /* throw away space/tabs */
sawspace = true; /* but remember for fill_args */ sawspace = true; /* but remember for fill_args */
} }
YY_BREAK YY_BREAK
case 58: case 58:
YY_RULE_SETUP YY_RULE_SETUP
#line 625 "toke.l" #line 626 "toke.l"
{ {
sawspace = true; /* remember for fill_args */ sawspace = true; /* remember for fill_args */
sudolineno++; sudolineno++;
@@ -2426,7 +2443,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 59: case 59:
YY_RULE_SETUP YY_RULE_SETUP
#line 631 "toke.l" #line 632 "toke.l"
{ {
BEGIN INITIAL; BEGIN INITIAL;
sudolineno++; sudolineno++;
@@ -2437,7 +2454,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 60: case 60:
YY_RULE_SETUP YY_RULE_SETUP
#line 639 "toke.l" #line 640 "toke.l"
{ {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
LEXRETURN(ERROR); LEXRETURN(ERROR);
@@ -2449,7 +2466,7 @@ case YY_STATE_EOF(GOTCMND):
case YY_STATE_EOF(STARTDEFS): case YY_STATE_EOF(STARTDEFS):
case YY_STATE_EOF(INDEFS): case YY_STATE_EOF(INDEFS):
case YY_STATE_EOF(INSTR): case YY_STATE_EOF(INSTR):
#line 644 "toke.l" #line 645 "toke.l"
{ {
if (YY_START != INITIAL) { if (YY_START != INITIAL) {
BEGIN INITIAL; BEGIN INITIAL;
@@ -2462,10 +2479,10 @@ case YY_STATE_EOF(INSTR):
YY_BREAK YY_BREAK
case 61: case 61:
YY_RULE_SETUP YY_RULE_SETUP
#line 654 "toke.l" #line 655 "toke.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 2468 "lex.yy.c" #line 2485 "lex.sudoers.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
@@ -3356,7 +3373,7 @@ int main()
return 0; return 0;
} }
#endif #endif
#line 654 "toke.l" #line 655 "toke.l"
struct path_list { struct path_list {
char *path; char *path;
@@ -3396,10 +3413,10 @@ switch_dir(struct include_stack *stack, char *dirpath)
if (errno != ENOENT) { if (errno != ENOENT) {
char *errbuf; char *errbuf;
if (asprintf(&errbuf, _("%s: %s"), dirpath, strerror(errno)) != -1) { if (asprintf(&errbuf, _("%s: %s"), dirpath, strerror(errno)) != -1) {
yyerror(errbuf); sudoerserror(errbuf);
free(errbuf); free(errbuf);
} else { } else {
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
} }
} }
goto done; goto done;
@@ -3498,7 +3515,7 @@ init_lexer(void)
efree(istack[idepth].path); efree(istack[idepth].path);
if (idepth && !istack[idepth].keepopen) if (idepth && !istack[idepth].keepopen)
fclose(istack[idepth].bs->yy_input_file); fclose(istack[idepth].bs->yy_input_file);
yy_delete_buffer(istack[idepth].bs); sudoers_delete_buffer(istack[idepth].bs);
} }
efree(istack); efree(istack);
istack = NULL; istack = NULL;
@@ -3522,14 +3539,14 @@ _push_include(char *path, bool isdir)
/* push current state onto stack */ /* push current state onto stack */
if (idepth >= istacksize) { if (idepth >= istacksize) {
if (idepth > MAX_SUDOERS_DEPTH) { if (idepth > MAX_SUDOERS_DEPTH) {
yyerror(_("too many levels of includes")); sudoerserror(_("too many levels of includes"));
debug_return_bool(false); debug_return_bool(false);
} }
istacksize += SUDOERS_STACK_INCREMENT; istacksize += SUDOERS_STACK_INCREMENT;
istack = (struct include_stack *) realloc(istack, istack = (struct include_stack *) realloc(istack,
sizeof(*istack) * istacksize); sizeof(*istack) * istacksize);
if (istack == NULL) { if (istack == NULL) {
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
debug_return_bool(false); debug_return_bool(false);
} }
} }
@@ -3570,7 +3587,7 @@ _push_include(char *path, bool isdir)
debug_return_bool(false); debug_return_bool(false);
} }
if (!(path = switch_dir(&istack[idepth], path))) { if (!(path = switch_dir(&istack[idepth], path))) {
/* switch_dir() called yyerror() for us */ /* switch_dir() called sudoerserror() for us */
debug_return_bool(false); debug_return_bool(false);
} }
while ((fp = open_sudoers(path, false, &keepopen)) == NULL) { while ((fp = open_sudoers(path, false, &keepopen)) == NULL) {
@@ -3585,7 +3602,7 @@ _push_include(char *path, bool isdir)
} else { } else {
if ((fp = open_sudoers(path, true, &keepopen)) == NULL) { if ((fp = open_sudoers(path, true, &keepopen)) == NULL) {
/* The error was already printed by open_sudoers() */ /* The error was already printed by open_sudoers() */
yyerror(NULL); sudoerserror(NULL);
debug_return_bool(false); debug_return_bool(false);
} }
istack[idepth].more = NULL; istack[idepth].more = NULL;
@@ -3598,7 +3615,7 @@ _push_include(char *path, bool isdir)
idepth++; idepth++;
sudolineno = 1; sudolineno = 1;
sudoers = path; sudoers = path;
yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); sudoers_switch_to_buffer(sudoers_create_buffer(fp, YY_BUF_SIZE));
debug_return_bool(true); debug_return_bool(true);
} }
@@ -3615,7 +3632,7 @@ pop_include(void)
if (!keepopen) if (!keepopen)
fclose(YY_CURRENT_BUFFER->yy_input_file); fclose(YY_CURRENT_BUFFER->yy_input_file);
yy_delete_buffer(YY_CURRENT_BUFFER); sudoers_delete_buffer(YY_CURRENT_BUFFER);
/* If we are in an include dir, move to the next file. */ /* If we are in an include dir, move to the next file. */
while ((pl = istack[idepth - 1].more) != NULL) { while ((pl = istack[idepth - 1].more) != NULL) {
fp = open_sudoers(pl->path, false, &keepopen); fp = open_sudoers(pl->path, false, &keepopen);
@@ -3624,7 +3641,7 @@ pop_include(void)
efree(sudoers); efree(sudoers);
sudoers = pl->path; sudoers = pl->path;
sudolineno = 1; sudolineno = 1;
yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); sudoers_switch_to_buffer(sudoers_create_buffer(fp, YY_BUF_SIZE));
efree(pl); efree(pl);
break; break;
} }
@@ -3636,7 +3653,7 @@ pop_include(void)
/* If no path list, just pop the last dir on the stack. */ /* If no path list, just pop the last dir on the stack. */
if (pl == NULL) { if (pl == NULL) {
idepth--; idepth--;
yy_switch_to_buffer(istack[idepth].bs); sudoers_switch_to_buffer(istack[idepth].bs);
efree(sudoers); efree(sudoers);
sudoers = istack[idepth].path; sudoers = istack[idepth].path;
sudolineno = istack[idepth].lineno; sudolineno = istack[idepth].lineno;
@@ -3680,7 +3697,7 @@ parse_include(char *base)
len += (int)(ep - cp); len += (int)(ep - cp);
path = pp = malloc(len + dirlen + 1); path = pp = malloc(len + dirlen + 1);
if (path == NULL) { if (path == NULL) {
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
debug_return_str(NULL); debug_return_str(NULL);
} }
if (dirlen) { if (dirlen) {

View File

@@ -23,7 +23,7 @@ bool fill_cmnd(const char *, int);
bool fill_txt(const char *, int, int); bool fill_txt(const char *, int, int);
bool ipv6_valid(const char *s); bool ipv6_valid(const char *s);
int sudoers_trace_print(const char *msg); int sudoers_trace_print(const char *msg);
void yyerror(const char *); void sudoerserror(const char *);
#ifndef FLEX_SCANNER #ifndef FLEX_SCANNER
extern int (*trace_print)(const char *msg); extern int (*trace_print)(const char *msg);

View File

@@ -74,7 +74,7 @@
#include "lbuf.h" #include "lbuf.h"
#include "secure_path.h" #include "secure_path.h"
extern YYSTYPE yylval; extern YYSTYPE sudoerslval;
extern bool parse_error; extern bool parse_error;
extern bool sudoers_warnings; extern bool sudoers_warnings;
int sudolineno; int sudolineno;
@@ -101,7 +101,7 @@ int (*trace_print)(const char *msg) = sudoers_trace_print;
return (n); \ return (n); \
} while (0) } while (0)
#define ECHO ignore_result(fwrite(yytext, yyleng, 1, yyout)) #define ECHO ignore_result(fwrite(sudoerstext, sudoersleng, 1, sudoersout))
#define push_include(_p) (_push_include((_p), false)) #define push_include(_p) (_push_include((_p), false))
#define push_includedir(_p) (_push_include((_p), true)) #define push_includedir(_p) (_push_include((_p), true))
@@ -122,6 +122,7 @@ DEFVAR [a-z_]+
%option noinput %option noinput
%option nounput %option nounput
%option noyywrap %option noyywrap
%option prefix="sudoers"
%s GOTDEFS %s GOTDEFS
%x GOTCMND %x GOTCMND
@@ -140,7 +141,7 @@ DEFVAR [a-z_]+
<STARTDEFS>{DEFVAR} { <STARTDEFS>{DEFVAR} {
BEGIN INDEFS; BEGIN INDEFS;
LEXTRACE("DEFVAR "); LEXTRACE("DEFVAR ");
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXRETURN(DEFVAR); LEXRETURN(DEFVAR);
} }
@@ -169,14 +170,14 @@ DEFVAR [a-z_]+
\" { \" {
LEXTRACE("BEGINSTR "); LEXTRACE("BEGINSTR ");
yylval.string = NULL; sudoerslval.string = NULL;
prev_state = YY_START; prev_state = YY_START;
BEGIN INSTR; BEGIN INSTR;
} }
{ENVAR} { {ENVAR} {
LEXTRACE("WORD(2) "); LEXTRACE("WORD(2) ");
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXRETURN(WORD); LEXRETURN(WORD);
} }
@@ -193,23 +194,23 @@ DEFVAR [a-z_]+
LEXTRACE("ENDSTR "); LEXTRACE("ENDSTR ");
BEGIN prev_state; BEGIN prev_state;
if (yylval.string == NULL) { if (sudoerslval.string == NULL) {
LEXTRACE("ERROR "); /* empty string */ LEXTRACE("ERROR "); /* empty string */
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if (prev_state == INITIAL) { if (prev_state == INITIAL) {
switch (yylval.string[0]) { switch (sudoerslval.string[0]) {
case '%': case '%':
if (yylval.string[1] == '\0' || if (sudoerslval.string[1] == '\0' ||
(yylval.string[1] == ':' && (sudoerslval.string[1] == ':' &&
yylval.string[2] == '\0')) { sudoerslval.string[2] == '\0')) {
LEXTRACE("ERROR "); /* empty group */ LEXTRACE("ERROR "); /* empty group */
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
LEXTRACE("USERGROUP "); LEXTRACE("USERGROUP ");
LEXRETURN(USERGROUP); LEXRETURN(USERGROUP);
case '+': case '+':
if (yylval.string[1] == '\0') { if (sudoerslval.string[1] == '\0') {
LEXTRACE("ERROR "); /* empty netgroup */ LEXTRACE("ERROR "); /* empty netgroup */
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
@@ -223,13 +224,13 @@ DEFVAR [a-z_]+
\\ { \\ {
LEXTRACE("BACKSLASH "); LEXTRACE("BACKSLASH ");
if (!append(yytext, yyleng)) if (!append(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
} }
([^\"\n\\]|\\\")+ { ([^\"\n\\]|\\\")+ {
LEXTRACE("STRBODY "); LEXTRACE("STRBODY ");
if (!append(yytext, yyleng)) if (!append(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
} }
} }
@@ -238,7 +239,7 @@ DEFVAR [a-z_]+
\\[\*\?\[\]\!] { \\[\*\?\[\]\!] {
/* quoted fnmatch glob char, pass verbatim */ /* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR "); LEXTRACE("QUOTEDCHAR ");
if (!fill_args(yytext, 2, sawspace)) if (!fill_args(sudoerstext, 2, sawspace))
yyterminate(); yyterminate();
sawspace = false; sawspace = false;
} }
@@ -246,7 +247,7 @@ DEFVAR [a-z_]+
\\[:\\,= \t#] { \\[:\\,= \t#] {
/* quoted sudoers special char, strip backslash */ /* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR "); LEXTRACE("QUOTEDCHAR ");
if (!fill_args(yytext + 1, 1, sawspace)) if (!fill_args(sudoerstext + 1, 1, sawspace))
yyterminate(); yyterminate();
sawspace = false; sawspace = false;
} }
@@ -259,7 +260,7 @@ DEFVAR [a-z_]+
[^#\\:, \t\n]+ { [^#\\:, \t\n]+ {
LEXTRACE("ARG "); LEXTRACE("ARG ");
if (!fill_args(yytext, yyleng, sawspace)) if (!fill_args(sudoerstext, sudoersleng, sawspace))
yyterminate(); yyterminate();
sawspace = false; sawspace = false;
} /* a command line arg */ } /* a command line arg */
@@ -273,7 +274,7 @@ DEFVAR [a-z_]+
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if ((path = parse_include(yytext)) == NULL) if ((path = parse_include(sudoerstext)) == NULL)
yyterminate(); yyterminate();
LEXTRACE("INCLUDE\n"); LEXTRACE("INCLUDE\n");
@@ -291,7 +292,7 @@ DEFVAR [a-z_]+
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if ((path = parse_include(yytext)) == NULL) if ((path = parse_include(sudoerstext)) == NULL)
yyterminate(); yyterminate();
LEXTRACE("INCLUDEDIR\n"); LEXTRACE("INCLUDEDIR\n");
@@ -313,11 +314,11 @@ DEFVAR [a-z_]+
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
for (n = 0; isblank((unsigned char)yytext[n]); n++) for (n = 0; isblank((unsigned char)sudoerstext[n]); n++)
continue; continue;
n += sizeof("Defaults") - 1; n += sizeof("Defaults") - 1;
if ((deftype = yytext[n++]) != '\0') { if ((deftype = sudoerstext[n++]) != '\0') {
while (isblank((unsigned char)yytext[n])) while (isblank((unsigned char)sudoerstext[n]))
n++; n++;
} }
BEGIN GOTDEFS; BEGIN GOTDEFS;
@@ -352,9 +353,9 @@ DEFVAR [a-z_]+
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
for (n = 0; isblank((unsigned char)yytext[n]); n++) for (n = 0; isblank((unsigned char)sudoerstext[n]); n++)
continue; continue;
switch (yytext[n]) { switch (sudoerstext[n]) {
case 'H': case 'H':
LEXTRACE("HOSTALIAS "); LEXTRACE("HOSTALIAS ");
LEXRETURN(HOSTALIAS); LEXRETURN(HOSTALIAS);
@@ -430,7 +431,7 @@ NOLOG_INPUT[[:blank:]]*: {
\+{WORD} { \+{WORD} {
/* netgroup */ /* netgroup */
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NETGROUP "); LEXTRACE("NETGROUP ");
LEXRETURN(NETGROUP); LEXRETURN(NETGROUP);
@@ -438,43 +439,43 @@ NOLOG_INPUT[[:blank:]]*: {
\%:?({WORD}|{ID}) { \%:?({WORD}|{ID}) {
/* group */ /* group */
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("USERGROUP "); LEXTRACE("USERGROUP ");
LEXRETURN(USERGROUP); LEXRETURN(USERGROUP);
} }
{IPV4ADDR}(\/{IPV4ADDR})? { {IPV4ADDR}(\/{IPV4ADDR})? {
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NTWKADDR "); LEXTRACE("NTWKADDR ");
LEXRETURN(NTWKADDR); LEXRETURN(NTWKADDR);
} }
{IPV4ADDR}\/([12]?[0-9]|3[0-2]) { {IPV4ADDR}\/([12]?[0-9]|3[0-2]) {
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NTWKADDR "); LEXTRACE("NTWKADDR ");
LEXRETURN(NTWKADDR); LEXRETURN(NTWKADDR);
} }
{IPV6ADDR}(\/{IPV6ADDR})? { {IPV6ADDR}(\/{IPV6ADDR})? {
if (!ipv6_valid(yytext)) { if (!ipv6_valid(sudoerstext)) {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NTWKADDR "); LEXTRACE("NTWKADDR ");
LEXRETURN(NTWKADDR); LEXRETURN(NTWKADDR);
} }
{IPV6ADDR}\/([0-9]|[1-9][0-9]|1[01][0-9]|12[0-8]) { {IPV6ADDR}\/([0-9]|[1-9][0-9]|1[01][0-9]|12[0-8]) {
if (!ipv6_valid(yytext)) { if (!ipv6_valid(sudoerstext)) {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
LEXRETURN(ERROR); LEXRETURN(ERROR);
} }
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("NTWKADDR "); LEXTRACE("NTWKADDR ");
LEXRETURN(NTWKADDR); LEXRETURN(NTWKADDR);
@@ -523,7 +524,7 @@ ALL {
[[:upper:]][[:upper:][:digit:]_]* { [[:upper:]][[:upper:][:digit:]_]* {
got_alias: got_alias:
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("ALIAS "); LEXTRACE("ALIAS ");
LEXRETURN(ALIAS); LEXRETURN(ALIAS);
@@ -531,7 +532,7 @@ ALL {
<GOTDEFS>({PATH}|sudoedit) { <GOTDEFS>({PATH}|sudoedit) {
/* no command args allowed for Defaults!/path */ /* no command args allowed for Defaults!/path */
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
LEXRETURN(COMMAND); LEXRETURN(COMMAND);
@@ -540,35 +541,35 @@ ALL {
sudoedit { sudoedit {
BEGIN GOTCMND; BEGIN GOTCMND;
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
} /* sudo -e */ } /* sudo -e */
{PATH} { {PATH} {
/* directories can't have args... */ /* directories can't have args... */
if (yytext[yyleng - 1] == '/') { if (sudoerstext[sudoersleng - 1] == '/') {
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXRETURN(COMMAND); LEXRETURN(COMMAND);
} else { } else {
BEGIN GOTCMND; BEGIN GOTCMND;
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
} }
} /* a pathname */ } /* a pathname */
<INITIAL,GOTDEFS>\" { <INITIAL,GOTDEFS>\" {
LEXTRACE("BEGINSTR "); LEXTRACE("BEGINSTR ");
yylval.string = NULL; sudoerslval.string = NULL;
prev_state = YY_START; prev_state = YY_START;
BEGIN INSTR; BEGIN INSTR;
} }
<INITIAL,GOTDEFS>({ID}|{WORD}) { <INITIAL,GOTDEFS>({ID}|{WORD}) {
/* a word */ /* a word */
if (!fill(yytext, yyleng)) if (!fill(sudoerstext, sudoersleng))
yyterminate(); yyterminate();
LEXTRACE("WORD(5) "); LEXTRACE("WORD(5) ");
LEXRETURN(WORD); LEXRETURN(WORD);
@@ -600,7 +601,7 @@ sudoedit {
} /* return ':' */ } /* return ':' */
<*>!+ { <*>!+ {
if (yyleng & 1) { if (sudoersleng & 1) {
LEXTRACE("!"); LEXTRACE("!");
LEXRETURN('!'); /* return '!' */ LEXRETURN('!'); /* return '!' */
} }
@@ -690,10 +691,10 @@ switch_dir(struct include_stack *stack, char *dirpath)
if (errno != ENOENT) { if (errno != ENOENT) {
char *errbuf; char *errbuf;
if (asprintf(&errbuf, _("%s: %s"), dirpath, strerror(errno)) != -1) { if (asprintf(&errbuf, _("%s: %s"), dirpath, strerror(errno)) != -1) {
yyerror(errbuf); sudoerserror(errbuf);
free(errbuf); free(errbuf);
} else { } else {
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
} }
} }
goto done; goto done;
@@ -792,7 +793,7 @@ init_lexer(void)
efree(istack[idepth].path); efree(istack[idepth].path);
if (idepth && !istack[idepth].keepopen) if (idepth && !istack[idepth].keepopen)
fclose(istack[idepth].bs->yy_input_file); fclose(istack[idepth].bs->yy_input_file);
yy_delete_buffer(istack[idepth].bs); sudoers_delete_buffer(istack[idepth].bs);
} }
efree(istack); efree(istack);
istack = NULL; istack = NULL;
@@ -816,14 +817,14 @@ _push_include(char *path, bool isdir)
/* push current state onto stack */ /* push current state onto stack */
if (idepth >= istacksize) { if (idepth >= istacksize) {
if (idepth > MAX_SUDOERS_DEPTH) { if (idepth > MAX_SUDOERS_DEPTH) {
yyerror(_("too many levels of includes")); sudoerserror(_("too many levels of includes"));
debug_return_bool(false); debug_return_bool(false);
} }
istacksize += SUDOERS_STACK_INCREMENT; istacksize += SUDOERS_STACK_INCREMENT;
istack = (struct include_stack *) realloc(istack, istack = (struct include_stack *) realloc(istack,
sizeof(*istack) * istacksize); sizeof(*istack) * istacksize);
if (istack == NULL) { if (istack == NULL) {
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
debug_return_bool(false); debug_return_bool(false);
} }
} }
@@ -864,7 +865,7 @@ _push_include(char *path, bool isdir)
debug_return_bool(false); debug_return_bool(false);
} }
if (!(path = switch_dir(&istack[idepth], path))) { if (!(path = switch_dir(&istack[idepth], path))) {
/* switch_dir() called yyerror() for us */ /* switch_dir() called sudoerserror() for us */
debug_return_bool(false); debug_return_bool(false);
} }
while ((fp = open_sudoers(path, false, &keepopen)) == NULL) { while ((fp = open_sudoers(path, false, &keepopen)) == NULL) {
@@ -879,7 +880,7 @@ _push_include(char *path, bool isdir)
} else { } else {
if ((fp = open_sudoers(path, true, &keepopen)) == NULL) { if ((fp = open_sudoers(path, true, &keepopen)) == NULL) {
/* The error was already printed by open_sudoers() */ /* The error was already printed by open_sudoers() */
yyerror(NULL); sudoerserror(NULL);
debug_return_bool(false); debug_return_bool(false);
} }
istack[idepth].more = NULL; istack[idepth].more = NULL;
@@ -892,7 +893,7 @@ _push_include(char *path, bool isdir)
idepth++; idepth++;
sudolineno = 1; sudolineno = 1;
sudoers = path; sudoers = path;
yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); sudoers_switch_to_buffer(sudoers_create_buffer(fp, YY_BUF_SIZE));
debug_return_bool(true); debug_return_bool(true);
} }
@@ -909,7 +910,7 @@ pop_include(void)
if (!keepopen) if (!keepopen)
fclose(YY_CURRENT_BUFFER->yy_input_file); fclose(YY_CURRENT_BUFFER->yy_input_file);
yy_delete_buffer(YY_CURRENT_BUFFER); sudoers_delete_buffer(YY_CURRENT_BUFFER);
/* If we are in an include dir, move to the next file. */ /* If we are in an include dir, move to the next file. */
while ((pl = istack[idepth - 1].more) != NULL) { while ((pl = istack[idepth - 1].more) != NULL) {
fp = open_sudoers(pl->path, false, &keepopen); fp = open_sudoers(pl->path, false, &keepopen);
@@ -918,7 +919,7 @@ pop_include(void)
efree(sudoers); efree(sudoers);
sudoers = pl->path; sudoers = pl->path;
sudolineno = 1; sudolineno = 1;
yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); sudoers_switch_to_buffer(sudoers_create_buffer(fp, YY_BUF_SIZE));
efree(pl); efree(pl);
break; break;
} }
@@ -930,7 +931,7 @@ pop_include(void)
/* If no path list, just pop the last dir on the stack. */ /* If no path list, just pop the last dir on the stack. */
if (pl == NULL) { if (pl == NULL) {
idepth--; idepth--;
yy_switch_to_buffer(istack[idepth].bs); sudoers_switch_to_buffer(istack[idepth].bs);
efree(sudoers); efree(sudoers);
sudoers = istack[idepth].path; sudoers = istack[idepth].path;
sudolineno = istack[idepth].lineno; sudolineno = istack[idepth].lineno;
@@ -974,7 +975,7 @@ parse_include(char *base)
len += (int)(ep - cp); len += (int)(ep - cp);
path = pp = malloc(len + dirlen + 1); path = pp = malloc(len + dirlen + 1);
if (path == NULL) { if (path == NULL) {
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
debug_return_str(NULL); debug_return_str(NULL);
} }
if (dirlen) { if (dirlen) {

View File

@@ -108,12 +108,12 @@ fill_txt(const char *src, int len, int olen)
char *dst; char *dst;
debug_decl(fill_txt, SUDO_DEBUG_PARSER) debug_decl(fill_txt, SUDO_DEBUG_PARSER)
dst = olen ? realloc(yylval.string, olen + len + 1) : malloc(len + 1); dst = olen ? realloc(sudoerslval.string, olen + len + 1) : malloc(len + 1);
if (dst == NULL) { if (dst == NULL) {
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
debug_return_bool(false); debug_return_bool(false);
} }
yylval.string = dst; sudoerslval.string = dst;
/* Copy the string and collapse any escaped characters. */ /* Copy the string and collapse any escaped characters. */
dst += olen; dst += olen;
@@ -144,8 +144,8 @@ append(const char *src, int len)
int olen = 0; int olen = 0;
debug_decl(append, SUDO_DEBUG_PARSER) debug_decl(append, SUDO_DEBUG_PARSER)
if (yylval.string != NULL) if (sudoerslval.string != NULL)
olen = strlen(yylval.string); olen = strlen(sudoerslval.string);
debug_return_bool(fill_txt(src, len, olen)); debug_return_bool(fill_txt(src, len, olen));
} }
@@ -162,9 +162,9 @@ fill_cmnd(const char *src, int len)
arg_len = arg_size = 0; arg_len = arg_size = 0;
dst = yylval.command.cmnd = (char *) malloc(len + 1); dst = sudoerslval.command.cmnd = (char *) malloc(len + 1);
if (yylval.command.cmnd == NULL) { if (sudoerslval.command.cmnd == NULL) {
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
debug_return_bool(false); debug_return_bool(false);
} }
@@ -177,7 +177,7 @@ fill_cmnd(const char *src, int len)
} }
*dst = '\0'; *dst = '\0';
yylval.command.args = NULL; sudoerslval.command.args = NULL;
debug_return_bool(true); debug_return_bool(true);
} }
@@ -188,7 +188,7 @@ fill_args(const char *s, int len, int addspace)
char *p; char *p;
debug_decl(fill_args, SUDO_DEBUG_PARSER) debug_decl(fill_args, SUDO_DEBUG_PARSER)
if (yylval.command.args == NULL) { if (sudoerslval.command.args == NULL) {
addspace = 0; addspace = 0;
new_len = len; new_len = len;
} else } else
@@ -199,23 +199,23 @@ fill_args(const char *s, int len, int addspace)
while (new_len >= (arg_size += COMMANDARGINC)) while (new_len >= (arg_size += COMMANDARGINC))
; ;
p = yylval.command.args ? p = sudoerslval.command.args ?
(char *) realloc(yylval.command.args, arg_size) : (char *) realloc(sudoerslval.command.args, arg_size) :
(char *) malloc(arg_size); (char *) malloc(arg_size);
if (p == NULL) { if (p == NULL) {
efree(yylval.command.args); efree(sudoerslval.command.args);
yyerror(_("unable to allocate memory")); sudoerserror(_("unable to allocate memory"));
debug_return_bool(false); debug_return_bool(false);
} else } else
yylval.command.args = p; sudoerslval.command.args = p;
} }
/* Efficiently append the arg (with a leading space if needed). */ /* Efficiently append the arg (with a leading space if needed). */
p = yylval.command.args + arg_len; p = sudoerslval.command.args + arg_len;
if (addspace) if (addspace)
*p++ = ' '; *p++ = ' ';
if (strlcpy(p, s, arg_size - (p - yylval.command.args)) != len) { if (strlcpy(p, s, arg_size - (p - sudoerslval.command.args)) != len) {
yyerror(_("fill_args: buffer overflow")); /* paranoia */ sudoerserror(_("fill_args: buffer overflow")); /* paranoia */
debug_return_bool(false); debug_return_bool(false);
} }
arg_len = new_len; arg_len = new_len;

View File

@@ -118,14 +118,14 @@ static void usage(int);
void cleanup(int); void cleanup(int);
extern void yyerror(const char *); extern void sudoerserror(const char *);
extern void yyrestart(FILE *); extern void sudoersrestart(FILE *);
/* /*
* External globals exported by the parser * External globals exported by the parser
*/ */
extern struct rbtree *aliases; extern struct rbtree *aliases;
extern FILE *yyin; extern FILE *sudoersin;
extern char *sudoers, *errorfile; extern char *sudoers, *errorfile;
extern int errorlineno; extern int errorlineno;
extern bool parse_error; extern bool parse_error;
@@ -232,11 +232,11 @@ main(int argc, char *argv[])
* Parse the existing sudoers file(s) in quiet mode to highlight any * Parse the existing sudoers file(s) in quiet mode to highlight any
* existing errors and to pull in editor and env_editor conf values. * existing errors and to pull in editor and env_editor conf values.
*/ */
if ((yyin = open_sudoers(sudoers_path, true, NULL)) == NULL) { if ((sudoersin = open_sudoers(sudoers_path, true, NULL)) == NULL) {
error(1, "%s", sudoers_path); error(1, "%s", sudoers_path);
} }
init_parser(sudoers_path, false); init_parser(sudoers_path, false);
yyparse(); sudoersparse();
(void) update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER); (void) update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER);
editor = get_editor(&args); editor = get_editor(&args);
@@ -491,14 +491,14 @@ reparse_sudoers(char *editor, char *args, bool strict, bool quiet)
init_parser(sp->path, quiet); init_parser(sp->path, quiet);
/* Parse the sudoers temp file */ /* Parse the sudoers temp file */
yyrestart(fp); sudoersrestart(fp);
if (yyparse() && !parse_error) { if (sudoersparse() && !parse_error) {
warningx(_("unabled to parse temporary file (%s), unknown error"), warningx(_("unabled to parse temporary file (%s), unknown error"),
sp->tpath); sp->tpath);
parse_error = true; parse_error = true;
errorfile = sp->path; errorfile = sp->path;
} }
fclose(yyin); fclose(sudoersin);
if (!parse_error) { if (!parse_error) {
if (!check_defaults(SETDEF_ALL, quiet) || if (!check_defaults(SETDEF_ALL, quiet) ||
check_aliases(strict, quiet) != 0) { check_aliases(strict, quiet) != 0) {
@@ -812,15 +812,15 @@ check_syntax(char *sudoers_path, bool quiet, bool strict, bool oldperms)
debug_decl(check_syntax, SUDO_DEBUG_UTIL) debug_decl(check_syntax, SUDO_DEBUG_UTIL)
if (strcmp(sudoers_path, "-") == 0) { if (strcmp(sudoers_path, "-") == 0) {
yyin = stdin; sudoersin = stdin;
sudoers_path = "stdin"; sudoers_path = "stdin";
} else if ((yyin = fopen(sudoers_path, "r")) == NULL) { } else if ((sudoersin = fopen(sudoers_path, "r")) == NULL) {
if (!quiet) if (!quiet)
warning(_("unable to open %s"), sudoers_path); warning(_("unable to open %s"), sudoers_path);
goto done; goto done;
} }
init_parser(sudoers_path, quiet); init_parser(sudoers_path, quiet);
if (yyparse() && !parse_error) { if (sudoersparse() && !parse_error) {
if (!quiet) if (!quiet)
warningx(_("failed to parse %s file, unknown error"), sudoers_path); warningx(_("failed to parse %s file, unknown error"), sudoers_path);
parse_error = true; parse_error = true;