Support sudoers_file being a colon-separated path of files.

The first file found is used.
This commit is contained in:
Todd C. Miller
2023-05-02 10:37:38 -06:00
parent 4363d03ef7
commit f17b35471f
10 changed files with 131 additions and 55 deletions

View File

@@ -59,6 +59,7 @@ sudo_file_open(struct sudo_nss *nss)
{
debug_decl(sudo_file_open, SUDOERS_DEBUG_NSS);
struct sudo_file_handle *handle;
char *outfile = NULL;
/* Note: relies on defaults being initialized early. */
if (def_ignore_local_sudoers)
@@ -72,9 +73,14 @@ sudo_file_open(struct sudo_nss *nss)
handle = malloc(sizeof(*handle));
if (handle != NULL) {
handle->fp = open_sudoers(sudoers_file, false, NULL);
handle->fp = open_sudoers(sudoers_file, &outfile, false, NULL);
if (handle->fp != NULL) {
init_parse_tree(&handle->parse_tree, NULL, NULL, nss);
if (outfile != NULL) {
/* Update path to open sudoers file. */
sudo_rcstr_delref(sudoers);
sudoers = outfile;
}
} else {
free(handle);
handle = NULL;