From: Todd C. Miller Date: Wed, 24 Nov 2004 21:44:54 +0000 (+0000) Subject: Deal with user_stat being NULL as it is for visudo and testsudoers. X-Git-Tag: SUDO_1_7_0~785 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94f606fbf63721401e28cb973460ee304a702916;p=sudo Deal with user_stat being NULL as it is for visudo and testsudoers. --- diff --git a/match.c b/match.c index 0c32cfe5a..940491642 100644 --- a/match.c +++ b/match.c @@ -328,8 +328,9 @@ command_matches(sudoers_cmnd, sudoers_args) if (strcmp(user_base, base) != 0 || stat(*ap, &sudoers_stat) == -1) continue; - if (user_stat->st_dev == sudoers_stat.st_dev && - user_stat->st_ino == sudoers_stat.st_ino) { + if (user_stat == NULL || + (user_stat->st_dev == sudoers_stat.st_dev && + user_stat->st_ino == sudoers_stat.st_ino)) { if (safe_cmnd) free(safe_cmnd); safe_cmnd = estrdup(*ap); @@ -373,8 +374,9 @@ command_matches(sudoers_cmnd, sudoers_args) * b) there are no args on command line and none req by sudoers OR * c) there are args in sudoers and on command line and they match */ - if (user_stat->st_dev != sudoers_stat.st_dev || - user_stat->st_ino != sudoers_stat.st_ino) + if (user_stat != NULL && + (user_stat->st_dev != sudoers_stat.st_dev || + user_stat->st_ino != sudoers_stat.st_ino)) return(FALSE); if (!sudoers_args || (!user_args && sudoers_args && !strcmp("\"\"", sudoers_args)) || diff --git a/testsudoers.c b/testsudoers.c index 2615f964a..2ae467aaa 100644 --- a/testsudoers.c +++ b/testsudoers.c @@ -236,11 +236,12 @@ main(argc, argv) rval = cmnd_matches(cs->cmnd); if (rval != UNSPEC) matched = rval; - printf("\tcommand %s\n", rval == ALLOW ? "allowed" : + printf("\tcmnd %s\n", rval == ALLOW ? "allowed" : rval == DENY ? "denied" : "unmatched"); } } - } + } else + puts("\thost unmatched"); } } }