Rename init_parser_ext() to init_parser() and remove old wrapper.

There was only one consumer of the init_parser() wrapper now that
reset_parser() has been introduced.
This commit is contained in:
Todd C. Miller
2023-05-02 13:29:49 -06:00
parent f258a15df5
commit bbbaea5b2f
7 changed files with 11 additions and 24 deletions

View File

@@ -770,7 +770,7 @@ parse_sudoers(const char *input_file, struct cvtsudoers_config *conf)
input_file = "stdin"; input_file = "stdin";
} else if ((sudoersin = fopen(input_file, "r")) == NULL) } else if ((sudoersin = fopen(input_file, "r")) == NULL)
sudo_fatal(U_("unable to open %s"), input_file); sudo_fatal(U_("unable to open %s"), input_file);
init_parser(input_file); init_parser(input_file, NULL, false, 1);
if (sudoersparse() && !parse_error) { if (sudoersparse() && !parse_error) {
sudo_warnx(U_("failed to parse %s file, unknown error"), input_file); sudo_warnx(U_("failed to parse %s file, unknown error"), input_file);
parse_error = true; parse_error = true;

View File

@@ -3965,7 +3965,7 @@ free_parse_tree(struct sudoers_parse_tree *parse_tree)
* the current sudoers file to path. * the current sudoers file to path.
*/ */
bool bool
init_parser_ext(const char *file, const char *path, bool strict, int verbose) init_parser(const char *file, const char *path, bool strict, int verbose)
{ {
bool ret = true; bool ret = true;
debug_decl(init_parser, SUDOERS_DEBUG_PARSER); debug_decl(init_parser, SUDOERS_DEBUG_PARSER);
@@ -4001,16 +4001,10 @@ init_parser_ext(const char *file, const char *path, bool strict, int verbose)
debug_return_bool(ret); debug_return_bool(ret);
} }
bool
init_parser(const char *file)
{
return init_parser_ext(file, NULL, false, 1);
}
bool bool
reset_parser(void) reset_parser(void)
{ {
return init_parser_ext(NULL, NULL, false, 1); return init_parser(NULL, NULL, false, 1);
} }
/* /*

View File

@@ -1782,7 +1782,7 @@ free_parse_tree(struct sudoers_parse_tree *parse_tree)
* the current sudoers file to path. * the current sudoers file to path.
*/ */
bool bool
init_parser_ext(const char *file, const char *path, bool strict, int verbose) init_parser(const char *file, const char *path, bool strict, int verbose)
{ {
bool ret = true; bool ret = true;
debug_decl(init_parser, SUDOERS_DEBUG_PARSER); debug_decl(init_parser, SUDOERS_DEBUG_PARSER);
@@ -1818,16 +1818,10 @@ init_parser_ext(const char *file, const char *path, bool strict, int verbose)
debug_return_bool(ret); debug_return_bool(ret);
} }
bool
init_parser(const char *file)
{
return init_parser_ext(file, NULL, false, 1);
}
bool bool
reset_parser(void) reset_parser(void)
{ {
return init_parser_ext(NULL, NULL, false, 1); return init_parser(NULL, NULL, false, 1);
} }
/* /*

View File

@@ -372,8 +372,7 @@ int check_aliases(struct sudoers_parse_tree *parse_tree, bool strict, bool quiet
/* gram.y */ /* gram.y */
extern struct sudoers_parse_tree parsed_policy; extern struct sudoers_parse_tree parsed_policy;
extern bool (*sudoers_error_hook)(const char *file, int line, int column, const char *fmt, va_list args); extern bool (*sudoers_error_hook)(const char *file, int line, int column, const char *fmt, va_list args);
bool init_parser(const char *file); bool init_parser(const char *file, const char *path, bool strict, int verbose);
bool init_parser_ext(const char *file, const char *path, bool strict, int verbose);
bool reset_parser(void); bool reset_parser(void);
void free_member(struct member *m); void free_member(struct member *m);
void free_members(struct member_list *members); void free_members(struct member_list *members);

View File

@@ -312,7 +312,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
/* Initialize defaults and parse sudoers. */ /* Initialize defaults and parse sudoers. */
init_defaults(); init_defaults();
init_parser_ext("sudoers", NULL, true, 1); init_parser("sudoers", NULL, true, 1);
sudoersrestart(fp); sudoersrestart(fp);
sudoersparse(); sudoersparse();
reparent_parse_tree(&parse_tree); reparent_parse_tree(&parse_tree);

View File

@@ -274,7 +274,7 @@ main(int argc, char *argv[])
} }
/* Initialize the parser and set sudoers filename to "sudoers". */ /* Initialize the parser and set sudoers filename to "sudoers". */
init_parser_ext("sudoers", NULL, true, 2); init_parser("sudoers", NULL, true, 2);
/* /*
* Set runas passwd/group entries based on command line or sudoers. * Set runas passwd/group entries based on command line or sudoers.

View File

@@ -288,7 +288,7 @@ main(int argc, char *argv[])
* Parse the existing sudoers file(s) to highlight any existing * Parse the existing sudoers file(s) to highlight any existing
* errors and to pull in editor and env_editor conf values. * errors and to pull in editor and env_editor conf values.
*/ */
init_parser_ext(NULL, path_sudoers, true, quiet ? 0 : 2); init_parser(NULL, path_sudoers, true, quiet ? 0 : 2);
if ((sudoersin = open_sudoers(path_sudoers, &sudoers, true, NULL)) == NULL) if ((sudoersin = open_sudoers(path_sudoers, &sudoers, true, NULL)) == NULL)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale); sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
@@ -651,7 +651,7 @@ reparse_sudoers(char *editor, int editor_argc, char **editor_argv,
/* Clean slate for each parse */ /* Clean slate for each parse */
if (!init_defaults()) if (!init_defaults())
sudo_fatalx("%s", U_("unable to initialize sudoers default values")); sudo_fatalx("%s", U_("unable to initialize sudoers default values"));
init_parser_ext(sp->opath, path_sudoers, true, quiet ? 0 : 2); init_parser(sp->opath, path_sudoers, true, quiet ? 0 : 2);
sp->errorline = -1; sp->errorline = -1;
/* Parse the sudoers temp file(s) */ /* Parse the sudoers temp file(s) */
@@ -1068,7 +1068,7 @@ check_syntax(const char *path, bool quiet, bool strict, bool check_owner,
goto done; goto done;
} }
} }
init_parser_ext(fname, path, true, quiet ? 0 : 2); init_parser(fname, path, true, quiet ? 0 : 2);
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale); sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
if (sudoersparse() && !parse_error) { if (sudoersparse() && !parse_error) {
if (!quiet) if (!quiet)