From: Todd C. Miller Date: Wed, 29 Sep 2004 18:33:06 +0000 (+0000) Subject: Add errorfile global that contains the name of the file that caused the X-Git-Tag: SUDO_1_7_0~921 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9b23cdee1220bb924371d0d616ad22f9c7e926e;p=sudo Add errorfile global that contains the name of the file that caused the error. --- diff --git a/parse.yacc b/parse.yacc index 929df5895..ed91212a0 100644 --- a/parse.yacc +++ b/parse.yacc @@ -79,13 +79,14 @@ static const char rcsid[] = "$Sudo$"; */ extern int sudolineno, parse_error; extern char *sudoers; -int errorlineno = -1; int clearaliases = TRUE; int printmatches = FALSE; int pedantic = FALSE; int keepall = FALSE; int quiet = FALSE; int used_runas = FALSE; +int errorlineno = -1; +char *errorfile = NULL; /* * Alias types @@ -206,8 +207,10 @@ yyerror(s) const char *s; { /* Save the line the first error occurred on. */ - if (errorlineno == -1) + if (errorlineno == -1) { errorlineno = sudolineno ? sudolineno - 1 : 0; + errorfile = estrdup(sudoers); + } if (s && !quiet) { #ifndef TRACELEXER (void) fprintf(stderr, ">>> %s: %s, line %d <<<\n", sudoers, s, diff --git a/sudo.c b/sudo.c index e63dc5f31..81a62f270 100644 --- a/sudo.c +++ b/sudo.c @@ -127,6 +127,7 @@ int num_interfaces; int tgetpass_flags; uid_t timestamp_uid; extern int errorlineno; +extern char *errorfile; #if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL) static struct rlimit corelimit; #endif /* RLIMIT_CORE && !SUDO_DEVEL */ @@ -313,8 +314,7 @@ main(argc, argv, envp) } if (ISSET(validated, VALIDATE_ERROR)) - log_error(0, "parse error in %s near line %d", _PATH_SUDOERS, - errorlineno); + log_error(0, "parse error in %s near line %d", errorfile, errorlineno); /* Is root even allowed to run sudo? */ if (user_uid == 0 && !def_root_sudo) {