]> granicus.if.org Git - sudo/commitdiff
Print line number when there is a parser error.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 6 Nov 2011 22:00:40 +0000 (17:00 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 6 Nov 2011 22:00:40 +0000 (17:00 -0500)
plugins/sudoers/regress/sudoers/test4.out.ok
plugins/sudoers/regress/sudoers/test5.out.ok
plugins/sudoers/regress/sudoers/test7.out.ok
plugins/sudoers/regress/sudoers/test8.out.ok
plugins/sudoers/testsudoers.c

index 851e64426a4f617c17aabc4264eb34153e0b11c2..1c0bc4b436124ae2fbcb15b317f051f3992484a0 100644 (file)
@@ -1,4 +1,4 @@
-Does not parse.
+Parse error in sudoers near line 7.
 
 
 User_Alias     BAR = bar
index 6b6f2619b7182a67877d5c0aea91d972d172ff6a..3f6e2f215e2b21429c6d6a64143bfc55bdce4c6c 100644 (file)
@@ -1,4 +1,4 @@
-Does not parse.
+Parse error in sudoers near line 2.
 
 
 
index 6b6f2619b7182a67877d5c0aea91d972d172ff6a..3f6e2f215e2b21429c6d6a64143bfc55bdce4c6c 100644 (file)
@@ -1,4 +1,4 @@
-Does not parse.
+Parse error in sudoers near line 2.
 
 
 
index ccea9044c3ddd6e7075b6cc291545392d5a581e6..2f07300776701f056bc3e7c4d79050f694d62a44 100644 (file)
@@ -1,4 +1,4 @@
-Does not parse.
+Parse error in sudoers near line 8.
 
 
 User_Alias     UA1 = xy
index 2a315d72dfec77394a0f0be28ce701a5b3f2b9f4..d58e3538a917ec18b0df795dc25a89ce6f25ce6a 100644 (file)
@@ -109,7 +109,8 @@ struct interface *interfaces;
 struct sudo_user sudo_user;
 struct passwd *list_pw;
 static char *runas_group, *runas_user;
-extern int parse_error;
+extern int errorlineno, parse_error;
+extern char *errorfile;
 sudo_printf_t sudo_printf = testsudoers_printf;
 
 /* For getopt(3) */
@@ -251,7 +252,11 @@ main(int argc, char *argv[])
 
     if (yyparse() != 0 || parse_error) {
        parse_error = TRUE;
-       (void) fputs("Does not parse", stdout);
+       if (errorlineno != -1)
+           (void) printf("Parse error in %s near line %d",
+               errorfile, errorlineno);
+       else
+           (void) printf("Parse error in %s", errorfile);
     } else {
        (void) fputs("Parses OK", stdout);
     }