summaryrefslogtreecommitdiff
path: root/plugins/sudoers/gram.c
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@sudo.ws>2023-05-02 10:47:11 -0600
committerTodd C. Miller <Todd.Miller@sudo.ws>2023-05-02 10:47:11 -0600
commita4811f21f880af67461db113377b289461c3fc23 (patch)
tree81c50231e84e40807926de2260582a3f950b922b /plugins/sudoers/gram.c
parent9588d46fae9d6ad6cfb25b74ace786ed392dd15c (diff)
downloadsudo-a4811f21f880af67461db113377b289461c3fc23.tar.gz
Support adminconfdir for relative include paths in sudoers.
Diffstat (limited to 'plugins/sudoers/gram.c')
-rw-r--r--plugins/sudoers/gram.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c
index c606408f6..5cbdaca34 100644
--- a/plugins/sudoers/gram.c
+++ b/plugins/sudoers/gram.c
@@ -3965,7 +3965,7 @@ free_parse_tree(struct sudoers_parse_tree *parse_tree)
* the current sudoers file to path.
*/
bool
-init_parser_ext(const char *path, bool strict, int verbose)
+init_parser_ext(const char *file, const char *path, bool strict, int verbose)
{
bool ret = true;
debug_decl(init_parser, SUDOERS_DEBUG_PARSER);
@@ -3975,8 +3975,8 @@ init_parser_ext(const char *path, bool strict, int verbose)
init_lexer();
sudo_rcstr_delref(sudoers);
- if (path != NULL) {
- if ((sudoers = sudo_rcstr_dup(path)) == NULL) {
+ if (file != NULL) {
+ if ((sudoers = sudo_rcstr_dup(file)) == NULL) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
ret = false;
}
@@ -3984,6 +3984,16 @@ init_parser_ext(const char *path, bool strict, int verbose)
sudoers = NULL;
}
+ sudo_rcstr_delref(sudoers_search_path);
+ if (path != NULL) {
+ if ((sudoers_search_path = sudo_rcstr_dup(path)) == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ ret = false;
+ }
+ } else {
+ sudoers_search_path = NULL;
+ }
+
parse_error = false;
sudoers_strict = strict;
sudoers_verbose = verbose;
@@ -3992,9 +4002,9 @@ init_parser_ext(const char *path, bool strict, int verbose)
}
bool
-init_parser(const char *path)
+init_parser(const char *file)
{
- return init_parser_ext(path, false, 1);
+ return init_parser_ext(file, NULL, false, 1);
}
/*