From: Todd C. Miller Date: Sun, 6 Nov 2011 22:00:40 +0000 (-0500) Subject: Print line number when there is a parser error. X-Git-Tag: SUDO_1_8_4~170^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9fddb9eed7e75c7856d324c5e9f3a5115c035b77;p=sudo Print line number when there is a parser error. --- diff --git a/plugins/sudoers/regress/sudoers/test4.out.ok b/plugins/sudoers/regress/sudoers/test4.out.ok index 851e64426..1c0bc4b43 100644 --- a/plugins/sudoers/regress/sudoers/test4.out.ok +++ b/plugins/sudoers/regress/sudoers/test4.out.ok @@ -1,4 +1,4 @@ -Does not parse. +Parse error in sudoers near line 7. User_Alias BAR = bar diff --git a/plugins/sudoers/regress/sudoers/test5.out.ok b/plugins/sudoers/regress/sudoers/test5.out.ok index 6b6f2619b..3f6e2f215 100644 --- a/plugins/sudoers/regress/sudoers/test5.out.ok +++ b/plugins/sudoers/regress/sudoers/test5.out.ok @@ -1,4 +1,4 @@ -Does not parse. +Parse error in sudoers near line 2. diff --git a/plugins/sudoers/regress/sudoers/test7.out.ok b/plugins/sudoers/regress/sudoers/test7.out.ok index 6b6f2619b..3f6e2f215 100644 --- a/plugins/sudoers/regress/sudoers/test7.out.ok +++ b/plugins/sudoers/regress/sudoers/test7.out.ok @@ -1,4 +1,4 @@ -Does not parse. +Parse error in sudoers near line 2. diff --git a/plugins/sudoers/regress/sudoers/test8.out.ok b/plugins/sudoers/regress/sudoers/test8.out.ok index ccea9044c..2f0730077 100644 --- a/plugins/sudoers/regress/sudoers/test8.out.ok +++ b/plugins/sudoers/regress/sudoers/test8.out.ok @@ -1,4 +1,4 @@ -Does not parse. +Parse error in sudoers near line 8. User_Alias UA1 = xy diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index 2a315d72d..d58e3538a 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -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); }