Skip to content

Commit e6a5c1c

Browse files
committed
Fix error message for files included by @includedir
After ff0b6be, the fname variable is no longer set when a single file (not a path) is opened. Fixes GitHub issue #525
1 parent e822b72 commit e6a5c1c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

plugins/sudoers/sudoers.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,20 +1283,22 @@ open_file(const char *path, int flags)
12831283
FILE *
12841284
open_sudoers(const char *path, char **outfile, bool doedit, bool *keepopen)
12851285
{
1286-
char fname[PATH_MAX];
1286+
char fnamebuf[PATH_MAX];
1287+
const char *fname = fnamebuf;
12871288
FILE *fp = NULL;
12881289
struct stat sb;
12891290
int error, fd;
12901291
debug_decl(open_sudoers, SUDOERS_DEBUG_PLUGIN);
12911292

12921293
if (outfile == NULL) {
12931294
/* Single file, do not treat as a path. */
1294-
fd = open_file(path, O_RDONLY|O_NONBLOCK);
1295+
fname = path;
1296+
fd = open_file(fname, O_RDONLY|O_NONBLOCK);
12951297
if (fd != -1)
12961298
(void)fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK);
12971299
} else {
12981300
/* Could be a colon-separated path of file names. */
1299-
fd = sudo_open_conf_path(path, fname, sizeof(fname), open_file);
1301+
fd = sudo_open_conf_path(path, fnamebuf, sizeof(fnamebuf), open_file);
13001302
}
13011303
if (sudoers_ctx.parser_conf.ignore_perms) {
13021304
/* Skip sudoers security checks when ignore_perms is set. */

0 commit comments

Comments
 (0)