]> granicus.if.org Git - sudo/commitdiff
Add errorfile global that contains the name of the file that caused the
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 29 Sep 2004 18:33:06 +0000 (18:33 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 29 Sep 2004 18:33:06 +0000 (18:33 +0000)
error.

parse.yacc
sudo.c

index 929df589596f45101ba708ca4f268d9950f49258..ed91212a0a1cb7e8d0d570571a885c7700503cb6 100644 (file)
@@ -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 e63dc5f3139dac10480860ecb34a1f3057e98507..81a62f270ed7c57389a86d4c993dd98079ebc7be 100644 (file)
--- 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) {