From e49a2f0ca2f00f8672813b8b7f6846c1bb1dc0f9 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 20 Mar 2023 13:01:02 -0600 Subject: Split push_include() into push_include() and push_includedir(). This moves the "isdir" function argument to the internal version. --- plugins/sudoers/gram.c | 4 ++-- plugins/sudoers/gram.y | 4 ++-- plugins/sudoers/toke.c | 16 ++++++++++++++-- plugins/sudoers/toke.h | 3 ++- plugins/sudoers/toke.l | 16 ++++++++++++++-- 5 files changed, 34 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c index 04f4f6983..13a79cc86 100644 --- a/plugins/sudoers/gram.c +++ b/plugins/sudoers/gram.c @@ -1675,7 +1675,7 @@ yyreduce: case 8: /* entry: include */ #line 218 "gram.y" { - const bool success = push_include((yyvsp[0].string), false); + const bool success = push_include((yyvsp[0].string)); parser_leak_remove(LEAK_PTR, (yyvsp[0].string)); free((yyvsp[0].string)); if (!success && !sudoers_recovery) @@ -1687,7 +1687,7 @@ yyreduce: case 9: /* entry: includedir */ #line 225 "gram.y" { - const bool success = push_include((yyvsp[0].string), true); + const bool success = push_includedir((yyvsp[0].string)); parser_leak_remove(LEAK_PTR, (yyvsp[0].string)); free((yyvsp[0].string)); if (!success && !sudoers_recovery) diff --git a/plugins/sudoers/gram.y b/plugins/sudoers/gram.y index da7960440..66c7ccad5 100644 --- a/plugins/sudoers/gram.y +++ b/plugins/sudoers/gram.y @@ -216,14 +216,14 @@ entry : '\n' { yyerrok; } | include { - const bool success = push_include($1, false); + const bool success = push_include($1); parser_leak_remove(LEAK_PTR, $1); free($1); if (!success && !sudoers_recovery) YYERROR; } | includedir { - const bool success = push_include($1, true); + const bool success = push_includedir($1); parser_leak_remove(LEAK_PTR, $1); free($1); if (!success && !sudoers_recovery) diff --git a/plugins/sudoers/toke.c b/plugins/sudoers/toke.c index aa909ca29..700579302 100644 --- a/plugins/sudoers/toke.c +++ b/plugins/sudoers/toke.c @@ -5744,8 +5744,8 @@ oflow: * A missing or insecure include dir is simply ignored. * Returns false on error, else true. */ -bool -push_include(const char *opath, bool isdir) +static bool +push_include_int(const char *opath, bool isdir) { struct path_list *pl; char *path; @@ -5851,6 +5851,18 @@ push_include(const char *opath, bool isdir) debug_return_bool(true); } +bool +push_include(const char *opath) +{ + return push_include_int(opath, false); +} + +bool +push_includedir(const char *opath) +{ + return push_include_int(opath, true); +} + /* * Restore the previous sudoers file and buffer, or, in the case * of an includedir, switch to the next file in the dir. diff --git a/plugins/sudoers/toke.h b/plugins/sudoers/toke.h index 2b9f111b2..a15715956 100644 --- a/plugins/sudoers/toke.h +++ b/plugins/sudoers/toke.h @@ -38,7 +38,8 @@ bool ipv6_valid(const char *s); int sudoers_trace_print(const char *); void sudoerserrorf(const char *, ...) sudo_printf0like(1, 2); void sudoerserror(const char *); -bool push_include(const char *, bool); +bool push_include(const char *); +bool push_includedir(const char *); #ifndef FLEX_SCANNER extern int (*trace_print)(const char *msg); diff --git a/plugins/sudoers/toke.l b/plugins/sudoers/toke.l index 9e9231672..91f00eebc 100644 --- a/plugins/sudoers/toke.l +++ b/plugins/sudoers/toke.l @@ -1197,8 +1197,8 @@ oflow: * A missing or insecure include dir is simply ignored. * Returns false on error, else true. */ -bool -push_include(const char *opath, bool isdir) +static bool +push_include_int(const char *opath, bool isdir) { struct path_list *pl; char *path; @@ -1304,6 +1304,18 @@ push_include(const char *opath, bool isdir) debug_return_bool(true); } +bool +push_include(const char *opath) +{ + return push_include_int(opath, false); +} + +bool +push_includedir(const char *opath) +{ + return push_include_int(opath, true); +} + /* * Restore the previous sudoers file and buffer, or, in the case * of an includedir, switch to the next file in the dir. -- cgit v1.2.1