static bool push_include_int(char *, bool);
static bool pop_include(void);
-static char *parse_include(char *);
+static char *parse_include_int(const char *, bool);
int (*trace_print)(const char *msg) = sudoers_trace_print;
#define ECHO ignore_result(fwrite(sudoerstext, sudoersleng, 1, sudoersout))
+#define parse_include(_p) (parse_include_int((_p), false))
+#define parse_includedir(_p) (parse_include_int((_p), true))
#define push_include(_p) (push_include_int((_p), false))
#define push_includedir(_p) (push_include_int((_p), true))
#define YY_NO_INPUT 1
#define WANTDIGEST 6
-#line 2048 "lex.sudoers.c"
+#line 2050 "lex.sudoers.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
register char *yy_cp, *yy_bp;
register int yy_act;
-#line 120 "toke.l"
+#line 122 "toke.l"
-#line 2204 "lex.sudoers.c"
+#line 2206 "lex.sudoers.c"
if ( yy_init )
{
case 1:
YY_RULE_SETUP
-#line 121 "toke.l"
+#line 123 "toke.l"
{
LEXTRACE(", ");
LEXRETURN(',');
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 126 "toke.l"
+#line 128 "toke.l"
BEGIN STARTDEFS;
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 128 "toke.l"
+#line 130 "toke.l"
{
BEGIN INDEFS;
LEXTRACE("DEFVAR ");
case 4:
YY_RULE_SETUP
-#line 137 "toke.l"
+#line 139 "toke.l"
{
BEGIN STARTDEFS;
LEXTRACE(", ");
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 143 "toke.l"
+#line 145 "toke.l"
{
LEXTRACE("= ");
LEXRETURN('=');
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 148 "toke.l"
+#line 150 "toke.l"
{
LEXTRACE("+= ");
LEXRETURN('+');
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 153 "toke.l"
+#line 155 "toke.l"
{
LEXTRACE("-= ");
LEXRETURN('-');
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 158 "toke.l"
+#line 160 "toke.l"
{
LEXTRACE("BEGINSTR ");
sudoerslval.string = NULL;
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 165 "toke.l"
+#line 167 "toke.l"
{
LEXTRACE("WORD(2) ");
if (!fill(sudoerstext, sudoersleng))
case 10:
YY_RULE_SETUP
-#line 174 "toke.l"
+#line 176 "toke.l"
{
/* Line continuation char followed by newline. */
sudolineno++;
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 180 "toke.l"
+#line 182 "toke.l"
{
LEXTRACE("ENDSTR ");
BEGIN prev_state;
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 212 "toke.l"
+#line 214 "toke.l"
{
LEXTRACE("BACKSLASH ");
if (!append(sudoerstext, sudoersleng))
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 218 "toke.l"
+#line 220 "toke.l"
{
LEXTRACE("STRBODY ");
if (!append(sudoerstext, sudoersleng))
case 14:
YY_RULE_SETUP
-#line 226 "toke.l"
+#line 228 "toke.l"
{
/* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 234 "toke.l"
+#line 236 "toke.l"
{
/* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 242 "toke.l"
+#line 244 "toke.l"
{
BEGIN INITIAL;
yyless(0);
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 248 "toke.l"
+#line 250 "toke.l"
{
LEXTRACE("ARG ");
if (!fill_args(sudoerstext, sudoersleng, sawspace))
case 18:
YY_RULE_SETUP
-#line 256 "toke.l"
+#line 258 "toke.l"
{
/* Only return DIGEST if the length is correct. */
if ((yy_size_t)sudoersleng == digest_len * 2) {
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 269 "toke.l"
+#line 271 "toke.l"
{
/* Only return DIGEST if the length is correct. */
yy_size_t len;
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 290 "toke.l"
+#line 292 "toke.l"
{
char *path;
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 308 "toke.l"
+#line 310 "toke.l"
{
char *path;
LEXRETURN(ERROR);
}
- if ((path = parse_include(sudoerstext)) == NULL)
+ if ((path = parse_includedir(sudoerstext)) == NULL)
yyterminate();
LEXTRACE("INCLUDEDIR\n");
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 329 "toke.l"
+#line 331 "toke.l"
{
char deftype;
int n;
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 369 "toke.l"
+#line 371 "toke.l"
{
int n;
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 395 "toke.l"
+#line 397 "toke.l"
{
/* cmnd does not require passwd for this user */
LEXTRACE("NOPASSWD ");
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 401 "toke.l"
+#line 403 "toke.l"
{
/* cmnd requires passwd for this user */
LEXTRACE("PASSWD ");
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 407 "toke.l"
+#line 409 "toke.l"
{
LEXTRACE("NOEXEC ");
LEXRETURN(NOEXEC);
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 412 "toke.l"
+#line 414 "toke.l"
{
LEXTRACE("EXEC ");
LEXRETURN(EXEC);
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 417 "toke.l"
+#line 419 "toke.l"
{
LEXTRACE("SETENV ");
LEXRETURN(SETENV);
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 422 "toke.l"
+#line 424 "toke.l"
{
LEXTRACE("NOSETENV ");
LEXRETURN(NOSETENV);
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 427 "toke.l"
+#line 429 "toke.l"
{
LEXTRACE("LOG_OUTPUT ");
LEXRETURN(LOG_OUTPUT);
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 432 "toke.l"
+#line 434 "toke.l"
{
LEXTRACE("NOLOG_OUTPUT ");
LEXRETURN(NOLOG_OUTPUT);
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 437 "toke.l"
+#line 439 "toke.l"
{
LEXTRACE("LOG_INPUT ");
LEXRETURN(LOG_INPUT);
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 442 "toke.l"
+#line 444 "toke.l"
{
LEXTRACE("NOLOG_INPUT ");
LEXRETURN(NOLOG_INPUT);
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 447 "toke.l"
+#line 449 "toke.l"
{
LEXTRACE("MAIL ");
LEXRETURN(MAIL);
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 452 "toke.l"
+#line 454 "toke.l"
{
LEXTRACE("NOMAIL ");
LEXRETURN(NOMAIL);
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 457 "toke.l"
+#line 459 "toke.l"
{
LEXTRACE("FOLLOW ");
LEXRETURN(FOLLOW);
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 462 "toke.l"
+#line 464 "toke.l"
{
LEXTRACE("NOFOLLOW ");
LEXRETURN(NOFOLLOW);
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 467 "toke.l"
+#line 469 "toke.l"
{
/* empty group or netgroup */
LEXTRACE("ERROR ");
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 473 "toke.l"
+#line 475 "toke.l"
{
/* netgroup */
if (!fill(sudoerstext, sudoersleng))
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 481 "toke.l"
+#line 483 "toke.l"
{
/* group */
if (!fill(sudoerstext, sudoersleng))
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 489 "toke.l"
+#line 491 "toke.l"
{
if (!fill(sudoerstext, sudoersleng))
yyterminate();
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 496 "toke.l"
+#line 498 "toke.l"
{
if (!fill(sudoerstext, sudoersleng))
yyterminate();
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 503 "toke.l"
+#line 505 "toke.l"
{
if (!ipv6_valid(sudoerstext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 514 "toke.l"
+#line 516 "toke.l"
{
if (!ipv6_valid(sudoerstext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 525 "toke.l"
+#line 527 "toke.l"
{
LEXTRACE("ALL ");
LEXRETURN(ALL);
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 531 "toke.l"
+#line 533 "toke.l"
{
#ifdef HAVE_SELINUX
LEXTRACE("ROLE ");
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 540 "toke.l"
+#line 542 "toke.l"
{
#ifdef HAVE_SELINUX
LEXTRACE("TYPE ");
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 548 "toke.l"
+#line 550 "toke.l"
{
#ifdef HAVE_PRIV_SET
LEXTRACE("PRIVS ");
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 557 "toke.l"
+#line 559 "toke.l"
{
#ifdef HAVE_PRIV_SET
LEXTRACE("LIMITPRIVS ");
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 566 "toke.l"
+#line 568 "toke.l"
{
got_alias:
if (!fill(sudoerstext, sudoersleng))
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 574 "toke.l"
+#line 576 "toke.l"
{
/* XXX - no way to specify digest for command */
/* no command args allowed for Defaults!/path */
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 583 "toke.l"
+#line 585 "toke.l"
{
digest_len = SHA224_DIGEST_LENGTH;
BEGIN WANTDIGEST;
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 590 "toke.l"
+#line 592 "toke.l"
{
digest_len = SHA256_DIGEST_LENGTH;
BEGIN WANTDIGEST;
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 597 "toke.l"
+#line 599 "toke.l"
{
digest_len = SHA384_DIGEST_LENGTH;
BEGIN WANTDIGEST;
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 604 "toke.l"
+#line 606 "toke.l"
{
digest_len = SHA512_DIGEST_LENGTH;
BEGIN WANTDIGEST;
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 611 "toke.l"
+#line 613 "toke.l"
{
BEGIN GOTCMND;
LEXTRACE("COMMAND ");
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 618 "toke.l"
+#line 620 "toke.l"
{
/* directories can't have args... */
if (sudoerstext[sudoersleng - 1] == '/') {
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 633 "toke.l"
+#line 635 "toke.l"
{
LEXTRACE("BEGINSTR ");
sudoerslval.string = NULL;
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 640 "toke.l"
+#line 642 "toke.l"
{
/* a word */
if (!fill(sudoerstext, sudoersleng))
YY_BREAK
case 60:
YY_RULE_SETUP
-#line 648 "toke.l"
+#line 650 "toke.l"
{
LEXTRACE("( ");
LEXRETURN('(');
YY_BREAK
case 61:
YY_RULE_SETUP
-#line 653 "toke.l"
+#line 655 "toke.l"
{
LEXTRACE(") ");
LEXRETURN(')');
YY_BREAK
case 62:
YY_RULE_SETUP
-#line 658 "toke.l"
+#line 660 "toke.l"
{
LEXTRACE(", ");
LEXRETURN(',');
YY_BREAK
case 63:
YY_RULE_SETUP
-#line 663 "toke.l"
+#line 665 "toke.l"
{
LEXTRACE("= ");
LEXRETURN('=');
YY_BREAK
case 64:
YY_RULE_SETUP
-#line 668 "toke.l"
+#line 670 "toke.l"
{
LEXTRACE(": ");
LEXRETURN(':');
YY_BREAK
case 65:
YY_RULE_SETUP
-#line 673 "toke.l"
+#line 675 "toke.l"
{
if (sudoersleng & 1) {
LEXTRACE("!");
YY_BREAK
case 66:
YY_RULE_SETUP
-#line 680 "toke.l"
+#line 682 "toke.l"
{
if (YY_START == INSTR) {
LEXTRACE("ERROR ");
YY_BREAK
case 67:
YY_RULE_SETUP
-#line 692 "toke.l"
+#line 694 "toke.l"
{ /* throw away space/tabs */
sawspace = true; /* but remember for fill_args */
}
YY_BREAK
case 68:
YY_RULE_SETUP
-#line 696 "toke.l"
+#line 698 "toke.l"
{
sawspace = true; /* remember for fill_args */
sudolineno++;
YY_BREAK
case 69:
YY_RULE_SETUP
-#line 702 "toke.l"
+#line 704 "toke.l"
{
if (sudoerstext[sudoersleng - 1] == '\n') {
/* comment ending in a newline */
YY_BREAK
case 70:
YY_RULE_SETUP
-#line 716 "toke.l"
+#line 718 "toke.l"
{
LEXTRACE("ERROR ");
LEXRETURN(ERROR);
case YY_STATE_EOF(INDEFS):
case YY_STATE_EOF(INSTR):
case YY_STATE_EOF(WANTDIGEST):
-#line 721 "toke.l"
+#line 723 "toke.l"
{
if (YY_START != INITIAL) {
BEGIN INITIAL;
YY_BREAK
case 71:
YY_RULE_SETUP
-#line 731 "toke.l"
+#line 733 "toke.l"
ECHO;
YY_BREAK
-#line 3122 "lex.sudoers.c"
+#line 3124 "lex.sudoers.c"
case YY_END_OF_BUFFER:
{
return 0;
}
#endif
-#line 731 "toke.l"
+#line 733 "toke.l"
struct path_list {
SLIST_ENTRY(path_list) entries;
}
static char *
-parse_include(char *base)
+parse_include_int(const char *base, bool isdir)
{
- char *cp, *ep, *path, *pp;
+ const char *cp, *ep;
+ char *path, *pp;
int dirlen = 0, len = 0, subst = 0;
size_t shost_len = 0;
debug_decl(parse_include, SUDOERS_DEBUG_PARSER)
/* Pull out path from #include line. */
- cp = base + sizeof("#include");
- if (*cp == 'i')
- cp += 3; /* includedir */
+ cp = base + (isdir ? sizeof("#includedir") : sizeof("#include"));
while (isblank((unsigned char) *cp))
cp++;
ep = cp;
static bool push_include_int(char *, bool);
static bool pop_include(void);
-static char *parse_include(char *);
+static char *parse_include_int(const char *, bool);
int (*trace_print)(const char *msg) = sudoers_trace_print;
#define ECHO ignore_result(fwrite(sudoerstext, sudoersleng, 1, sudoersout))
+#define parse_include(_p) (parse_include_int((_p), false))
+#define parse_includedir(_p) (parse_include_int((_p), true))
#define push_include(_p) (push_include_int((_p), false))
#define push_includedir(_p) (push_include_int((_p), true))
%}
LEXRETURN(ERROR);
}
- if ((path = parse_include(sudoerstext)) == NULL)
+ if ((path = parse_includedir(sudoerstext)) == NULL)
yyterminate();
LEXTRACE("INCLUDEDIR\n");
}
static char *
-parse_include(char *base)
+parse_include_int(const char *base, bool isdir)
{
- char *cp, *ep, *path, *pp;
+ const char *cp, *ep;
+ char *path, *pp;
int dirlen = 0, len = 0, subst = 0;
size_t shost_len = 0;
debug_decl(parse_include, SUDOERS_DEBUG_PARSER)
/* Pull out path from #include line. */
- cp = base + sizeof("#include");
- if (*cp == 'i')
- cp += 3; /* includedir */
+ cp = base + (isdir ? sizeof("#includedir") : sizeof("#include"));
while (isblank((unsigned char) *cp))
cp++;
ep = cp;