From b2c456341a41b236e7a32b710f2e37fe1d7e68cd Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 16 Dec 2013 14:18:42 -0700 Subject: [PATCH] Move symbol extern defs into sudoers.h --- plugins/sudoers/auth/bsdauth.c | 2 - plugins/sudoers/gram.c | 201 ++++++++++++++-------------- plugins/sudoers/gram.y | 5 +- plugins/sudoers/parse.c | 8 -- plugins/sudoers/sudoers.c | 3 - plugins/sudoers/sudoers.h | 9 ++ plugins/sudoers/testsudoers.c | 7 - plugins/sudoers/toke.c | 159 +++++++++++----------- plugins/sudoers/toke.l | 9 +- plugins/sudoers/visudo.c | 11 +- plugins/sudoers/visudo_json.c | 8 -- src/regress/ttyname/check_ttyname.c | 1 + 12 files changed, 192 insertions(+), 231 deletions(-) diff --git a/plugins/sudoers/auth/bsdauth.c b/plugins/sudoers/auth/bsdauth.c index c2c44ed57..89516a116 100644 --- a/plugins/sudoers/auth/bsdauth.c +++ b/plugins/sudoers/auth/bsdauth.c @@ -54,8 +54,6 @@ # define LOGIN_DEFROOTCLASS "daemon" # endif -extern char *login_style; /* from sudoers.c */ - struct bsdauth_state { auth_session_t *as; login_cap_t *lc; diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c index 02d5418ed..020a86f38 100644 --- a/plugins/sudoers/gram.c +++ b/plugins/sudoers/gram.c @@ -109,13 +109,10 @@ /* * Globals */ -extern int sudolineno; -extern int last_token; -extern char *sudoers; bool sudoers_warnings = true; bool parse_error = false; int errorlineno = -1; -char *errorfile = NULL; +const char *errorfile = NULL; struct defaults_list defaults = TAILQ_HEAD_INITIALIZER(defaults); struct userspec_list userspecs = TAILQ_HEAD_INITIALIZER(userspecs); @@ -128,7 +125,7 @@ static void add_userspec(struct member *, struct privilege *); static struct defaults *new_default(char *, char *, int); static struct member *new_member(char *, int); static struct sudo_digest *new_digest(int, const char *); -#line 95 "gram.y" +#line 92 "gram.y" #ifndef YYSTYPE_DEFINED #define YYSTYPE_DEFINED typedef union { @@ -146,7 +143,7 @@ typedef union { int tok; } YYSTYPE; #endif /* YYSTYPE_DEFINED */ -#line 149 "gram.c" +#line 146 "gram.c" #define COMMAND 257 #define ALIAS 258 #define DEFVAR 259 @@ -699,7 +696,7 @@ short *yyss; short *yysslim; YYSTYPE *yyvs; unsigned int yystacksize; -#line 688 "gram.y" +#line 685 "gram.y" void sudoerserror(const char *s) { @@ -958,7 +955,7 @@ init_parser(const char *path, bool quiet) debug_return; } -#line 909 "gram.c" +#line 906 "gram.c" /* allocate initial stack or double stack size, up to YYMAXDEPTH */ #if defined(__cplusplus) || defined(__STDC__) static int yygrowstack(void) @@ -1167,127 +1164,127 @@ yyreduce: switch (yyn) { case 1: -#line 185 "gram.y" +#line 182 "gram.y" { ; } break; case 5: -#line 193 "gram.y" +#line 190 "gram.y" { ; } break; case 6: -#line 196 "gram.y" +#line 193 "gram.y" { yyerrok; } break; case 7: -#line 199 "gram.y" +#line 196 "gram.y" { add_userspec(yyvsp[-1].member, yyvsp[0].privilege); } break; case 8: -#line 202 "gram.y" +#line 199 "gram.y" { ; } break; case 9: -#line 205 "gram.y" +#line 202 "gram.y" { ; } break; case 10: -#line 208 "gram.y" +#line 205 "gram.y" { ; } break; case 11: -#line 211 "gram.y" +#line 208 "gram.y" { ; } break; case 12: -#line 214 "gram.y" +#line 211 "gram.y" { add_defaults(DEFAULTS, NULL, yyvsp[0].defaults); } break; case 13: -#line 217 "gram.y" +#line 214 "gram.y" { add_defaults(DEFAULTS_USER, yyvsp[-1].member, yyvsp[0].defaults); } break; case 14: -#line 220 "gram.y" +#line 217 "gram.y" { add_defaults(DEFAULTS_RUNAS, yyvsp[-1].member, yyvsp[0].defaults); } break; case 15: -#line 223 "gram.y" +#line 220 "gram.y" { add_defaults(DEFAULTS_HOST, yyvsp[-1].member, yyvsp[0].defaults); } break; case 16: -#line 226 "gram.y" +#line 223 "gram.y" { add_defaults(DEFAULTS_CMND, yyvsp[-1].member, yyvsp[0].defaults); } break; case 18: -#line 232 "gram.y" +#line 229 "gram.y" { HLTQ_CONCAT(yyvsp[-2].defaults, yyvsp[0].defaults, entries); yyval.defaults = yyvsp[-2].defaults; } break; case 19: -#line 238 "gram.y" +#line 235 "gram.y" { yyval.defaults = new_default(yyvsp[0].string, NULL, true); } break; case 20: -#line 241 "gram.y" +#line 238 "gram.y" { yyval.defaults = new_default(yyvsp[0].string, NULL, false); } break; case 21: -#line 244 "gram.y" +#line 241 "gram.y" { yyval.defaults = new_default(yyvsp[-2].string, yyvsp[0].string, true); } break; case 22: -#line 247 "gram.y" +#line 244 "gram.y" { yyval.defaults = new_default(yyvsp[-2].string, yyvsp[0].string, '+'); } break; case 23: -#line 250 "gram.y" +#line 247 "gram.y" { yyval.defaults = new_default(yyvsp[-2].string, yyvsp[0].string, '-'); } break; case 25: -#line 256 "gram.y" +#line 253 "gram.y" { HLTQ_CONCAT(yyvsp[-2].privilege, yyvsp[0].privilege, entries); yyval.privilege = yyvsp[-2].privilege; } break; case 26: -#line 262 "gram.y" +#line 259 "gram.y" { struct privilege *p = ecalloc(1, sizeof(*p)); HLTQ_TO_TAILQ(&p->hostlist, yyvsp[-2].member, entries); @@ -1297,51 +1294,51 @@ case 26: } break; case 27: -#line 271 "gram.y" +#line 268 "gram.y" { yyval.member = yyvsp[0].member; yyval.member->negated = false; } break; case 28: -#line 275 "gram.y" +#line 272 "gram.y" { yyval.member = yyvsp[0].member; yyval.member->negated = true; } break; case 29: -#line 281 "gram.y" +#line 278 "gram.y" { yyval.member = new_member(yyvsp[0].string, ALIAS); } break; case 30: -#line 284 "gram.y" +#line 281 "gram.y" { yyval.member = new_member(NULL, ALL); } break; case 31: -#line 287 "gram.y" +#line 284 "gram.y" { yyval.member = new_member(yyvsp[0].string, NETGROUP); } break; case 32: -#line 290 "gram.y" +#line 287 "gram.y" { yyval.member = new_member(yyvsp[0].string, NTWKADDR); } break; case 33: -#line 293 "gram.y" +#line 290 "gram.y" { yyval.member = new_member(yyvsp[0].string, WORD); } break; case 35: -#line 299 "gram.y" +#line 296 "gram.y" { struct cmndspec *prev; prev = HLTQ_LAST(yyvsp[-2].cmndspec, cmndspec, entries); @@ -1383,7 +1380,7 @@ case 35: } break; case 36: -#line 340 "gram.y" +#line 337 "gram.y" { struct cmndspec *cs = ecalloc(1, sizeof(*cs)); if (yyvsp[-4].runas != NULL) { @@ -1420,37 +1417,37 @@ case 36: } break; case 37: -#line 376 "gram.y" +#line 373 "gram.y" { yyval.digest = new_digest(SUDO_DIGEST_SHA224, yyvsp[0].string); } break; case 38: -#line 379 "gram.y" +#line 376 "gram.y" { yyval.digest = new_digest(SUDO_DIGEST_SHA256, yyvsp[0].string); } break; case 39: -#line 382 "gram.y" +#line 379 "gram.y" { yyval.digest = new_digest(SUDO_DIGEST_SHA384, yyvsp[0].string); } break; case 40: -#line 385 "gram.y" +#line 382 "gram.y" { yyval.digest = new_digest(SUDO_DIGEST_SHA512, yyvsp[0].string); } break; case 41: -#line 390 "gram.y" +#line 387 "gram.y" { yyval.member = yyvsp[0].member; } break; case 42: -#line 393 "gram.y" +#line 390 "gram.y" { /* XXX - yuck */ struct sudo_command *c = (struct sudo_command *)(yyvsp[0].member->name); @@ -1459,127 +1456,127 @@ case 42: } break; case 43: -#line 401 "gram.y" +#line 398 "gram.y" { yyval.member = yyvsp[0].member; yyval.member->negated = false; } break; case 44: -#line 405 "gram.y" +#line 402 "gram.y" { yyval.member = yyvsp[0].member; yyval.member->negated = true; } break; case 45: -#line 411 "gram.y" +#line 408 "gram.y" { yyval.string = yyvsp[0].string; } break; case 46: -#line 416 "gram.y" +#line 413 "gram.y" { yyval.string = yyvsp[0].string; } break; case 47: -#line 421 "gram.y" +#line 418 "gram.y" { yyval.seinfo.role = NULL; yyval.seinfo.type = NULL; } break; case 48: -#line 425 "gram.y" +#line 422 "gram.y" { yyval.seinfo.role = yyvsp[0].string; yyval.seinfo.type = NULL; } break; case 49: -#line 429 "gram.y" +#line 426 "gram.y" { yyval.seinfo.type = yyvsp[0].string; yyval.seinfo.role = NULL; } break; case 50: -#line 433 "gram.y" +#line 430 "gram.y" { yyval.seinfo.role = yyvsp[-1].string; yyval.seinfo.type = yyvsp[0].string; } break; case 51: -#line 437 "gram.y" +#line 434 "gram.y" { yyval.seinfo.type = yyvsp[-1].string; yyval.seinfo.role = yyvsp[0].string; } break; case 52: -#line 443 "gram.y" +#line 440 "gram.y" { yyval.string = yyvsp[0].string; } break; case 53: -#line 447 "gram.y" +#line 444 "gram.y" { yyval.string = yyvsp[0].string; } break; case 54: -#line 452 "gram.y" +#line 449 "gram.y" { yyval.privinfo.privs = NULL; yyval.privinfo.limitprivs = NULL; } break; case 55: -#line 456 "gram.y" +#line 453 "gram.y" { yyval.privinfo.privs = yyvsp[0].string; yyval.privinfo.limitprivs = NULL; } break; case 56: -#line 460 "gram.y" +#line 457 "gram.y" { yyval.privinfo.privs = NULL; yyval.privinfo.limitprivs = yyvsp[0].string; } break; case 57: -#line 464 "gram.y" +#line 461 "gram.y" { yyval.privinfo.privs = yyvsp[-1].string; yyval.privinfo.limitprivs = yyvsp[0].string; } break; case 58: -#line 468 "gram.y" +#line 465 "gram.y" { yyval.privinfo.limitprivs = yyvsp[-1].string; yyval.privinfo.privs = yyvsp[0].string; } break; case 59: -#line 474 "gram.y" +#line 471 "gram.y" { yyval.runas = NULL; } break; case 60: -#line 477 "gram.y" +#line 474 "gram.y" { yyval.runas = yyvsp[-1].runas; } break; case 61: -#line 482 "gram.y" +#line 479 "gram.y" { yyval.runas = ecalloc(1, sizeof(struct runascontainer)); yyval.runas->runasusers = new_member(NULL, MYSELF); @@ -1587,7 +1584,7 @@ case 61: } break; case 62: -#line 487 "gram.y" +#line 484 "gram.y" { yyval.runas = ecalloc(1, sizeof(struct runascontainer)); yyval.runas->runasusers = yyvsp[0].member; @@ -1595,7 +1592,7 @@ case 62: } break; case 63: -#line 492 "gram.y" +#line 489 "gram.y" { yyval.runas = ecalloc(1, sizeof(struct runascontainer)); yyval.runas->runasusers = yyvsp[-2].member; @@ -1603,7 +1600,7 @@ case 63: } break; case 64: -#line 497 "gram.y" +#line 494 "gram.y" { yyval.runas = ecalloc(1, sizeof(struct runascontainer)); /* $$->runasusers = NULL; */ @@ -1611,7 +1608,7 @@ case 64: } break; case 65: -#line 502 "gram.y" +#line 499 "gram.y" { yyval.runas = ecalloc(1, sizeof(struct runascontainer)); yyval.runas->runasusers = new_member(NULL, MYSELF); @@ -1619,86 +1616,86 @@ case 65: } break; case 66: -#line 509 "gram.y" +#line 506 "gram.y" { yyval.tag.nopasswd = yyval.tag.noexec = yyval.tag.setenv = yyval.tag.log_input = yyval.tag.log_output = UNSPEC; } break; case 67: -#line 513 "gram.y" +#line 510 "gram.y" { yyval.tag.nopasswd = true; } break; case 68: -#line 516 "gram.y" +#line 513 "gram.y" { yyval.tag.nopasswd = false; } break; case 69: -#line 519 "gram.y" +#line 516 "gram.y" { yyval.tag.noexec = true; } break; case 70: -#line 522 "gram.y" +#line 519 "gram.y" { yyval.tag.noexec = false; } break; case 71: -#line 525 "gram.y" +#line 522 "gram.y" { yyval.tag.setenv = true; } break; case 72: -#line 528 "gram.y" +#line 525 "gram.y" { yyval.tag.setenv = false; } break; case 73: -#line 531 "gram.y" +#line 528 "gram.y" { yyval.tag.log_input = true; } break; case 74: -#line 534 "gram.y" +#line 531 "gram.y" { yyval.tag.log_input = false; } break; case 75: -#line 537 "gram.y" +#line 534 "gram.y" { yyval.tag.log_output = true; } break; case 76: -#line 540 "gram.y" +#line 537 "gram.y" { yyval.tag.log_output = false; } break; case 77: -#line 545 "gram.y" +#line 542 "gram.y" { yyval.member = new_member(NULL, ALL); } break; case 78: -#line 548 "gram.y" +#line 545 "gram.y" { yyval.member = new_member(yyvsp[0].string, ALIAS); } break; case 79: -#line 551 "gram.y" +#line 548 "gram.y" { struct sudo_command *c = ecalloc(1, sizeof(*c)); c->cmnd = yyvsp[0].command.cmnd; @@ -1707,7 +1704,7 @@ case 79: } break; case 82: -#line 563 "gram.y" +#line 560 "gram.y" { char *s; if ((s = alias_add(yyvsp[-2].string, HOSTALIAS, yyvsp[0].member)) != NULL) { @@ -1717,14 +1714,14 @@ case 82: } break; case 84: -#line 573 "gram.y" +#line 570 "gram.y" { HLTQ_CONCAT(yyvsp[-2].member, yyvsp[0].member, entries); yyval.member = yyvsp[-2].member; } break; case 87: -#line 583 "gram.y" +#line 580 "gram.y" { char *s; if ((s = alias_add(yyvsp[-2].string, CMNDALIAS, yyvsp[0].member)) != NULL) { @@ -1734,14 +1731,14 @@ case 87: } break; case 89: -#line 593 "gram.y" +#line 590 "gram.y" { HLTQ_CONCAT(yyvsp[-2].member, yyvsp[0].member, entries); yyval.member = yyvsp[-2].member; } break; case 92: -#line 603 "gram.y" +#line 600 "gram.y" { char *s; if ((s = alias_add(yyvsp[-2].string, RUNASALIAS, yyvsp[0].member)) != NULL) { @@ -1751,7 +1748,7 @@ case 92: } break; case 95: -#line 616 "gram.y" +#line 613 "gram.y" { char *s; if ((s = alias_add(yyvsp[-2].string, USERALIAS, yyvsp[0].member)) != NULL) { @@ -1761,96 +1758,96 @@ case 95: } break; case 97: -#line 626 "gram.y" +#line 623 "gram.y" { HLTQ_CONCAT(yyvsp[-2].member, yyvsp[0].member, entries); yyval.member = yyvsp[-2].member; } break; case 98: -#line 632 "gram.y" +#line 629 "gram.y" { yyval.member = yyvsp[0].member; yyval.member->negated = false; } break; case 99: -#line 636 "gram.y" +#line 633 "gram.y" { yyval.member = yyvsp[0].member; yyval.member->negated = true; } break; case 100: -#line 642 "gram.y" +#line 639 "gram.y" { yyval.member = new_member(yyvsp[0].string, ALIAS); } break; case 101: -#line 645 "gram.y" +#line 642 "gram.y" { yyval.member = new_member(NULL, ALL); } break; case 102: -#line 648 "gram.y" +#line 645 "gram.y" { yyval.member = new_member(yyvsp[0].string, NETGROUP); } break; case 103: -#line 651 "gram.y" +#line 648 "gram.y" { yyval.member = new_member(yyvsp[0].string, USERGROUP); } break; case 104: -#line 654 "gram.y" +#line 651 "gram.y" { yyval.member = new_member(yyvsp[0].string, WORD); } break; case 106: -#line 660 "gram.y" +#line 657 "gram.y" { HLTQ_CONCAT(yyvsp[-2].member, yyvsp[0].member, entries); yyval.member = yyvsp[-2].member; } break; case 107: -#line 666 "gram.y" +#line 663 "gram.y" { yyval.member = yyvsp[0].member; yyval.member->negated = false; } break; case 108: -#line 670 "gram.y" +#line 667 "gram.y" { yyval.member = yyvsp[0].member; yyval.member->negated = true; } break; case 109: -#line 676 "gram.y" +#line 673 "gram.y" { yyval.member = new_member(yyvsp[0].string, ALIAS); } break; case 110: -#line 679 "gram.y" +#line 676 "gram.y" { yyval.member = new_member(NULL, ALL); } break; case 111: -#line 682 "gram.y" +#line 679 "gram.y" { yyval.member = new_member(yyvsp[0].string, WORD); } break; -#line 1801 "gram.c" +#line 1798 "gram.c" } yyssp -= yym; yystate = *yyssp; diff --git a/plugins/sudoers/gram.y b/plugins/sudoers/gram.y index 8af4ee9b5..1b1d40f50 100644 --- a/plugins/sudoers/gram.y +++ b/plugins/sudoers/gram.y @@ -71,13 +71,10 @@ /* * Globals */ -extern int sudolineno; -extern int last_token; -extern char *sudoers; bool sudoers_warnings = true; bool parse_error = false; int errorlineno = -1; -char *errorfile = NULL; +const char *errorfile = NULL; struct defaults_list defaults = TAILQ_HEAD_INITIALIZER(defaults); struct userspec_list userspecs = TAILQ_HEAD_INITIALIZER(userspecs); diff --git a/plugins/sudoers/parse.c b/plugins/sudoers/parse.c index 4daf9ab54..a5e42147f 100644 --- a/plugins/sudoers/parse.c +++ b/plugins/sudoers/parse.c @@ -63,14 +63,6 @@ struct sudo_nss sudo_nss_file = { sudo_file_display_privs }; -/* - * Parser externs. - */ -extern FILE *sudoersin; -extern char *errorfile; -extern int errorlineno; -extern bool parse_error; - /* * Local prototypes. */ diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 06a84ce3e..08d901eec 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -100,9 +100,6 @@ struct sudo_user sudo_user; struct passwd *list_pw; int long_list; uid_t timestamp_uid; -extern int errorlineno; -extern bool parse_error; -extern char *errorfile; #ifdef HAVE_BSD_AUTH_H char *login_style; #endif /* HAVE_BSD_AUTH_H */ diff --git a/plugins/sudoers/sudoers.h b/plugins/sudoers/sudoers.h index c8db21d42..59a1534f0 100644 --- a/plugins/sudoers/sudoers.h +++ b/plugins/sudoers/sudoers.h @@ -269,13 +269,22 @@ int pam_prep_user(struct passwd *); /* gram.y */ int sudoersparse(void); +extern char *login_style; +extern const char *errorfile; +extern int errorlineno; +extern bool parse_error; +extern bool sudoers_warnings; /* toke.l */ YY_DECL; +extern FILE *sudoersin; extern const char *sudoers_file; +extern char *sudoers; extern mode_t sudoers_mode; extern uid_t sudoers_uid; extern gid_t sudoers_gid; +extern int sudolineno; +extern int last_token; /* defaults.c */ void dump_defaults(void); diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index 936c4c27c..66ded058e 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -102,13 +102,6 @@ extern int (*trace_print)(const char *msg); struct sudo_user sudo_user; struct passwd *list_pw; static char *runas_group, *runas_user; -extern int errorlineno; -extern bool parse_error; -extern char *errorfile; - -/* For getopt(3) */ -extern char *optarg; -extern int optind; #if defined(SUDO_DEVEL) && defined(__OpenBSD__) extern char *malloc_options; diff --git a/plugins/sudoers/toke.c b/plugins/sudoers/toke.c index e337d8b1c..e31badf10 100644 --- a/plugins/sudoers/toke.c +++ b/plugins/sudoers/toke.c @@ -16,12 +16,12 @@ #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.12 2013/11/04 17:03:32 millert Exp $ */ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /home/cvs/openbsd/src/usr.bin/lex/flex.skl,v 1.11 2010/08/04 18:24:50 millert Exp $ + * $Header: /cvs/src/usr.bin/lex/flex.skl,v 1.12 2013/11/04 17:03:32 millert Exp $ */ #define FLEX_SCANNER @@ -2007,12 +2007,9 @@ char *yytext; #include "sha2.h" #include "secure_path.h" -extern YYSTYPE sudoerslval; -extern bool parse_error; -extern bool sudoers_warnings; -int sudolineno; -int last_token; -char *sudoers; +int sudolineno; /* current sudoers line number. */ +int last_token; /* last token that was parsed. */ +char *sudoers; /* sudoers file being parsed. */ /* Default sudoers path, mode and owner (may be set via sudo.conf) */ const char *sudoers_file = _PATH_SUDOERS; @@ -2053,7 +2050,7 @@ int (*trace_print)(const char *msg) = sudoers_trace_print; #define WANTDIGEST 6 -#line 2056 "lex.sudoers.c" +#line 2053 "lex.sudoers.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -2207,9 +2204,9 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 140 "toke.l" +#line 137 "toke.l" -#line 2212 "lex.sudoers.c" +#line 2209 "lex.sudoers.c" if ( yy_init ) { @@ -2295,7 +2292,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 141 "toke.l" +#line 138 "toke.l" { LEXTRACE(", "); LEXRETURN(','); @@ -2303,12 +2300,12 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 146 "toke.l" +#line 143 "toke.l" BEGIN STARTDEFS; YY_BREAK case 3: YY_RULE_SETUP -#line 148 "toke.l" +#line 145 "toke.l" { BEGIN INDEFS; LEXTRACE("DEFVAR "); @@ -2320,7 +2317,7 @@ YY_RULE_SETUP case 4: YY_RULE_SETUP -#line 157 "toke.l" +#line 154 "toke.l" { BEGIN STARTDEFS; LEXTRACE(", "); @@ -2329,7 +2326,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 163 "toke.l" +#line 160 "toke.l" { LEXTRACE("= "); LEXRETURN('='); @@ -2337,7 +2334,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 168 "toke.l" +#line 165 "toke.l" { LEXTRACE("+= "); LEXRETURN('+'); @@ -2345,7 +2342,7 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 173 "toke.l" +#line 170 "toke.l" { LEXTRACE("-= "); LEXRETURN('-'); @@ -2353,7 +2350,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 178 "toke.l" +#line 175 "toke.l" { LEXTRACE("BEGINSTR "); sudoerslval.string = NULL; @@ -2363,7 +2360,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 185 "toke.l" +#line 182 "toke.l" { LEXTRACE("WORD(2) "); if (!fill(sudoerstext, sudoersleng)) @@ -2375,7 +2372,7 @@ YY_RULE_SETUP case 10: YY_RULE_SETUP -#line 194 "toke.l" +#line 191 "toke.l" { /* Line continuation char followed by newline. */ sudolineno++; @@ -2384,7 +2381,7 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 200 "toke.l" +#line 197 "toke.l" { LEXTRACE("ENDSTR "); BEGIN prev_state; @@ -2419,7 +2416,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 232 "toke.l" +#line 229 "toke.l" { LEXTRACE("BACKSLASH "); if (!append(sudoerstext, sudoersleng)) @@ -2428,7 +2425,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 238 "toke.l" +#line 235 "toke.l" { LEXTRACE("STRBODY "); if (!append(sudoerstext, sudoersleng)) @@ -2439,7 +2436,7 @@ YY_RULE_SETUP case 14: YY_RULE_SETUP -#line 246 "toke.l" +#line 243 "toke.l" { /* quoted fnmatch glob char, pass verbatim */ LEXTRACE("QUOTEDCHAR "); @@ -2450,7 +2447,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 254 "toke.l" +#line 251 "toke.l" { /* quoted sudoers special char, strip backslash */ LEXTRACE("QUOTEDCHAR "); @@ -2461,7 +2458,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 262 "toke.l" +#line 259 "toke.l" { BEGIN INITIAL; yyless(0); @@ -2470,7 +2467,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 268 "toke.l" +#line 265 "toke.l" { LEXTRACE("ARG "); if (!fill_args(sudoerstext, sudoersleng, sawspace)) @@ -2481,7 +2478,7 @@ YY_RULE_SETUP case 18: YY_RULE_SETUP -#line 276 "toke.l" +#line 273 "toke.l" { /* Only return DIGEST if the length is correct. */ if (sudoersleng == digest_len * 2) { @@ -2497,7 +2494,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 289 "toke.l" +#line 286 "toke.l" { /* Only return DIGEST if the length is correct. */ int len; @@ -2521,7 +2518,7 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 310 "toke.l" +#line 307 "toke.l" { char *path; @@ -2542,7 +2539,7 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 328 "toke.l" +#line 325 "toke.l" { char *path; @@ -2566,7 +2563,7 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 349 "toke.l" +#line 346 "toke.l" { char deftype; int n; @@ -2609,7 +2606,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 389 "toke.l" +#line 386 "toke.l" { int n; @@ -2638,7 +2635,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 415 "toke.l" +#line 412 "toke.l" { /* cmnd does not require passwd for this user */ LEXTRACE("NOPASSWD "); @@ -2647,7 +2644,7 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 421 "toke.l" +#line 418 "toke.l" { /* cmnd requires passwd for this user */ LEXTRACE("PASSWD "); @@ -2656,7 +2653,7 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -#line 427 "toke.l" +#line 424 "toke.l" { LEXTRACE("NOEXEC "); LEXRETURN(NOEXEC); @@ -2664,7 +2661,7 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 432 "toke.l" +#line 429 "toke.l" { LEXTRACE("EXEC "); LEXRETURN(EXEC); @@ -2672,7 +2669,7 @@ YY_RULE_SETUP YY_BREAK case 28: YY_RULE_SETUP -#line 437 "toke.l" +#line 434 "toke.l" { LEXTRACE("SETENV "); LEXRETURN(SETENV); @@ -2680,7 +2677,7 @@ YY_RULE_SETUP YY_BREAK case 29: YY_RULE_SETUP -#line 442 "toke.l" +#line 439 "toke.l" { LEXTRACE("NOSETENV "); LEXRETURN(NOSETENV); @@ -2688,7 +2685,7 @@ YY_RULE_SETUP YY_BREAK case 30: YY_RULE_SETUP -#line 447 "toke.l" +#line 444 "toke.l" { LEXTRACE("LOG_OUTPUT "); LEXRETURN(LOG_OUTPUT); @@ -2696,7 +2693,7 @@ YY_RULE_SETUP YY_BREAK case 31: YY_RULE_SETUP -#line 452 "toke.l" +#line 449 "toke.l" { LEXTRACE("NOLOG_OUTPUT "); LEXRETURN(NOLOG_OUTPUT); @@ -2704,7 +2701,7 @@ YY_RULE_SETUP YY_BREAK case 32: YY_RULE_SETUP -#line 457 "toke.l" +#line 454 "toke.l" { LEXTRACE("LOG_INPUT "); LEXRETURN(LOG_INPUT); @@ -2712,7 +2709,7 @@ YY_RULE_SETUP YY_BREAK case 33: YY_RULE_SETUP -#line 462 "toke.l" +#line 459 "toke.l" { LEXTRACE("NOLOG_INPUT "); LEXRETURN(NOLOG_INPUT); @@ -2720,7 +2717,7 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 467 "toke.l" +#line 464 "toke.l" { /* empty group or netgroup */ LEXTRACE("ERROR "); @@ -2729,7 +2726,7 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 473 "toke.l" +#line 470 "toke.l" { /* netgroup */ if (!fill(sudoerstext, sudoersleng)) @@ -2740,7 +2737,7 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 481 "toke.l" +#line 478 "toke.l" { /* group */ if (!fill(sudoerstext, sudoersleng)) @@ -2751,7 +2748,7 @@ YY_RULE_SETUP YY_BREAK case 37: YY_RULE_SETUP -#line 489 "toke.l" +#line 486 "toke.l" { if (!fill(sudoerstext, sudoersleng)) yyterminate(); @@ -2761,7 +2758,7 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 496 "toke.l" +#line 493 "toke.l" { if (!fill(sudoerstext, sudoersleng)) yyterminate(); @@ -2771,7 +2768,7 @@ YY_RULE_SETUP YY_BREAK case 39: YY_RULE_SETUP -#line 503 "toke.l" +#line 500 "toke.l" { if (!ipv6_valid(sudoerstext)) { LEXTRACE("ERROR "); @@ -2785,7 +2782,7 @@ YY_RULE_SETUP YY_BREAK case 40: YY_RULE_SETUP -#line 514 "toke.l" +#line 511 "toke.l" { if (!ipv6_valid(sudoerstext)) { LEXTRACE("ERROR "); @@ -2799,7 +2796,7 @@ YY_RULE_SETUP YY_BREAK case 41: YY_RULE_SETUP -#line 525 "toke.l" +#line 522 "toke.l" { LEXTRACE("ALL "); LEXRETURN(ALL); @@ -2808,7 +2805,7 @@ YY_RULE_SETUP YY_BREAK case 42: YY_RULE_SETUP -#line 531 "toke.l" +#line 528 "toke.l" { #ifdef HAVE_SELINUX LEXTRACE("ROLE "); @@ -2820,7 +2817,7 @@ YY_RULE_SETUP YY_BREAK case 43: YY_RULE_SETUP -#line 540 "toke.l" +#line 537 "toke.l" { #ifdef HAVE_SELINUX LEXTRACE("TYPE "); @@ -2832,7 +2829,7 @@ YY_RULE_SETUP YY_BREAK case 44: YY_RULE_SETUP -#line 548 "toke.l" +#line 545 "toke.l" { #ifdef HAVE_PRIV_SET LEXTRACE("PRIVS "); @@ -2844,7 +2841,7 @@ YY_RULE_SETUP YY_BREAK case 45: YY_RULE_SETUP -#line 557 "toke.l" +#line 554 "toke.l" { #ifdef HAVE_PRIV_SET LEXTRACE("LIMITPRIVS "); @@ -2856,7 +2853,7 @@ YY_RULE_SETUP YY_BREAK case 46: YY_RULE_SETUP -#line 566 "toke.l" +#line 563 "toke.l" { got_alias: if (!fill(sudoerstext, sudoersleng)) @@ -2867,7 +2864,7 @@ YY_RULE_SETUP YY_BREAK case 47: YY_RULE_SETUP -#line 574 "toke.l" +#line 571 "toke.l" { /* XXX - no way to specify digest for command */ /* no command args allowed for Defaults!/path */ @@ -2879,7 +2876,7 @@ YY_RULE_SETUP YY_BREAK case 48: YY_RULE_SETUP -#line 583 "toke.l" +#line 580 "toke.l" { digest_len = SHA224_DIGEST_LENGTH; BEGIN WANTDIGEST; @@ -2889,7 +2886,7 @@ YY_RULE_SETUP YY_BREAK case 49: YY_RULE_SETUP -#line 590 "toke.l" +#line 587 "toke.l" { digest_len = SHA256_DIGEST_LENGTH; BEGIN WANTDIGEST; @@ -2899,7 +2896,7 @@ YY_RULE_SETUP YY_BREAK case 50: YY_RULE_SETUP -#line 597 "toke.l" +#line 594 "toke.l" { digest_len = SHA384_DIGEST_LENGTH; BEGIN WANTDIGEST; @@ -2909,7 +2906,7 @@ YY_RULE_SETUP YY_BREAK case 51: YY_RULE_SETUP -#line 604 "toke.l" +#line 601 "toke.l" { digest_len = SHA512_DIGEST_LENGTH; BEGIN WANTDIGEST; @@ -2919,7 +2916,7 @@ YY_RULE_SETUP YY_BREAK case 52: YY_RULE_SETUP -#line 611 "toke.l" +#line 608 "toke.l" { BEGIN GOTCMND; LEXTRACE("COMMAND "); @@ -2929,7 +2926,7 @@ YY_RULE_SETUP YY_BREAK case 53: YY_RULE_SETUP -#line 618 "toke.l" +#line 615 "toke.l" { /* directories can't have args... */ if (sudoerstext[sudoersleng - 1] == '/') { @@ -2947,7 +2944,7 @@ YY_RULE_SETUP YY_BREAK case 54: YY_RULE_SETUP -#line 633 "toke.l" +#line 630 "toke.l" { LEXTRACE("BEGINSTR "); sudoerslval.string = NULL; @@ -2957,7 +2954,7 @@ YY_RULE_SETUP YY_BREAK case 55: YY_RULE_SETUP -#line 640 "toke.l" +#line 637 "toke.l" { /* a word */ if (!fill(sudoerstext, sudoersleng)) @@ -2968,7 +2965,7 @@ YY_RULE_SETUP YY_BREAK case 56: YY_RULE_SETUP -#line 648 "toke.l" +#line 645 "toke.l" { LEXTRACE("( "); LEXRETURN('('); @@ -2976,7 +2973,7 @@ YY_RULE_SETUP YY_BREAK case 57: YY_RULE_SETUP -#line 653 "toke.l" +#line 650 "toke.l" { LEXTRACE(") "); LEXRETURN(')'); @@ -2984,7 +2981,7 @@ YY_RULE_SETUP YY_BREAK case 58: YY_RULE_SETUP -#line 658 "toke.l" +#line 655 "toke.l" { LEXTRACE(", "); LEXRETURN(','); @@ -2992,7 +2989,7 @@ YY_RULE_SETUP YY_BREAK case 59: YY_RULE_SETUP -#line 663 "toke.l" +#line 660 "toke.l" { LEXTRACE("= "); LEXRETURN('='); @@ -3000,7 +2997,7 @@ YY_RULE_SETUP YY_BREAK case 60: YY_RULE_SETUP -#line 668 "toke.l" +#line 665 "toke.l" { LEXTRACE(": "); LEXRETURN(':'); @@ -3008,7 +3005,7 @@ YY_RULE_SETUP YY_BREAK case 61: YY_RULE_SETUP -#line 673 "toke.l" +#line 670 "toke.l" { if (sudoersleng & 1) { LEXTRACE("!"); @@ -3018,7 +3015,7 @@ YY_RULE_SETUP YY_BREAK case 62: YY_RULE_SETUP -#line 680 "toke.l" +#line 677 "toke.l" { if (YY_START == INSTR) { LEXTRACE("ERROR "); @@ -3033,14 +3030,14 @@ YY_RULE_SETUP YY_BREAK case 63: YY_RULE_SETUP -#line 692 "toke.l" +#line 689 "toke.l" { /* throw away space/tabs */ sawspace = true; /* but remember for fill_args */ } YY_BREAK case 64: YY_RULE_SETUP -#line 696 "toke.l" +#line 693 "toke.l" { sawspace = true; /* remember for fill_args */ sudolineno++; @@ -3049,7 +3046,7 @@ YY_RULE_SETUP YY_BREAK case 65: YY_RULE_SETUP -#line 702 "toke.l" +#line 699 "toke.l" { if (sudoerstext[sudoersleng - 1] == '\n') { /* comment ending in a newline */ @@ -3066,7 +3063,7 @@ YY_RULE_SETUP YY_BREAK case 66: YY_RULE_SETUP -#line 716 "toke.l" +#line 713 "toke.l" { LEXTRACE("ERROR "); LEXRETURN(ERROR); @@ -3079,7 +3076,7 @@ case YY_STATE_EOF(STARTDEFS): case YY_STATE_EOF(INDEFS): case YY_STATE_EOF(INSTR): case YY_STATE_EOF(WANTDIGEST): -#line 721 "toke.l" +#line 718 "toke.l" { if (YY_START != INITIAL) { BEGIN INITIAL; @@ -3092,10 +3089,10 @@ case YY_STATE_EOF(WANTDIGEST): YY_BREAK case 67: YY_RULE_SETUP -#line 731 "toke.l" +#line 728 "toke.l" ECHO; YY_BREAK -#line 3098 "lex.sudoers.c" +#line 3095 "lex.sudoers.c" case YY_END_OF_BUFFER: { @@ -3986,7 +3983,7 @@ int main() return 0; } #endif -#line 731 "toke.l" +#line 728 "toke.l" struct path_list { SLIST_ENTRY(path_list) entries; diff --git a/plugins/sudoers/toke.l b/plugins/sudoers/toke.l index 0e9ce6ab3..aa459d905 100644 --- a/plugins/sudoers/toke.l +++ b/plugins/sudoers/toke.l @@ -79,12 +79,9 @@ #include "sha2.h" #include "secure_path.h" -extern YYSTYPE sudoerslval; -extern bool parse_error; -extern bool sudoers_warnings; -int sudolineno; -int last_token; -char *sudoers; +int sudolineno; /* current sudoers line number. */ +int last_token; /* last token that was parsed. */ +char *sudoers; /* sudoers file being parsed. */ /* Default sudoers path, mode and owner (may be set via sudo.conf) */ const char *sudoers_file = _PATH_SUDOERS; diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 6cb1c08ae..ff820df72 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -114,20 +114,11 @@ static void help(void) __attribute__((__noreturn__)); static void usage(int); static void visudo_cleanup(void); -extern bool export_sudoers(char *, bool, bool); +extern bool export_sudoers(const char *, bool, bool); extern void sudoerserror(const char *); extern void sudoersrestart(FILE *); -/* - * External globals exported by the parser - */ -extern struct rbtree *aliases; -extern FILE *sudoersin; -extern char *sudoers, *errorfile; -extern int errorlineno; -extern bool parse_error; - /* * Globals */ diff --git a/plugins/sudoers/visudo_json.c b/plugins/sudoers/visudo_json.c index 1ca79a57e..9565c8067 100644 --- a/plugins/sudoers/visudo_json.c +++ b/plugins/sudoers/visudo_json.c @@ -43,14 +43,6 @@ #include "gettext.h" #include -/* - * External globals exported by the parser - */ -extern FILE *sudoersin; -extern char *sudoers, *errorfile; -extern int errorlineno; -extern bool parse_error; - /* * JSON values may be of the following types. */ diff --git a/src/regress/ttyname/check_ttyname.c b/src/regress/ttyname/check_ttyname.c index f807f4a0b..40f4e6069 100644 --- a/src/regress/ttyname/check_ttyname.c +++ b/src/regress/ttyname/check_ttyname.c @@ -41,6 +41,7 @@ #include "missing.h" #include "alloc.h" #include "fatal.h" +#include "sudo_util.h" __dso_public int main(int argc, char *argv[]);