Display column number in parse error messages too.

Bug #841
This commit is contained in:
Todd C. Miller
2020-11-01 15:34:11 -07:00
parent 6f7e5b104b
commit 982012dbb1
5 changed files with 15 additions and 15 deletions

View File

@@ -3135,8 +3135,8 @@ sudoerserror(const char *s)
/* Warnings are displayed in the user's locale. */ /* Warnings are displayed in the user's locale. */
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale); sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
sudo_printf(SUDO_CONV_ERROR_MSG, _("%s:%d: %s\n"), sudoers, sudo_printf(SUDO_CONV_ERROR_MSG, _("%s:%d:%d: %s\n"), sudoers,
this_lineno, _(s)); this_lineno, (int)sudolinebuf.toke_start + 1, _(s));
sudoers_setlocale(oldlocale, NULL); sudoers_setlocale(oldlocale, NULL);
/* Display the offending line and token if possible. */ /* Display the offending line and token if possible. */

View File

@@ -1050,8 +1050,8 @@ sudoerserror(const char *s)
/* Warnings are displayed in the user's locale. */ /* Warnings are displayed in the user's locale. */
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale); sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
sudo_printf(SUDO_CONV_ERROR_MSG, _("%s:%d: %s\n"), sudoers, sudo_printf(SUDO_CONV_ERROR_MSG, _("%s:%d:%d: %s\n"), sudoers,
this_lineno, _(s)); this_lineno, (int)sudolinebuf.toke_start + 1, _(s));
sudoers_setlocale(oldlocale, NULL); sudoers_setlocale(oldlocale, NULL);
/* Display the offending line and token if possible. */ /* Display the offending line and token if possible. */

View File

@@ -1,6 +1,6 @@
Testing @include with garbage after the path name Testing @include with garbage after the path name
sudoers:1: syntax error sudoers:1:24: syntax error
@include sudoers.local womp womp @include sudoers.local womp womp
^~~~ ^~~~
testsudoers: unable to stat sudoers.local: No such file or directory testsudoers: unable to stat sudoers.local: No such file or directory
@@ -11,7 +11,7 @@ Command unmatched
Testing #include with garbage after the path name Testing #include with garbage after the path name
sudoers:1: syntax error sudoers:1:24: syntax error
#include sudoers.local womp womp #include sudoers.local womp womp
^~~~ ^~~~
testsudoers: unable to stat sudoers.local: No such file or directory testsudoers: unable to stat sudoers.local: No such file or directory

View File

@@ -1,12 +1,12 @@
Testing sudoers with multiple syntax errors Testing sudoers with multiple syntax errors
sudoers:1: syntax error sudoers:1:20: syntax error
User_Alias A1 = u1 u2 : A2 = u3, u4 User_Alias A1 = u1 u2 : A2 = u3, u4
^~ ^~
sudoers:3: syntax error sudoers:3:26: syntax error
millert ALL = /fail : foo millert ALL = /fail : foo
^ ^
sudoers:5: syntax error sudoers:5:16: syntax error
root ALL = ALL bar root ALL = ALL bar
^~~ ^~~

View File

@@ -1,21 +1,21 @@
Testing alias definitions using reserved words Testing alias definitions using reserved words
sudoers:1: syntax error, reserved word used as an alias name sudoers:1:12: syntax error, reserved word used as an alias name
Cmnd_Alias ALL=ALL Cmnd_Alias ALL=ALL
^~~ ^~~
sudoers:2: syntax error, reserved word used as an alias name sudoers:2:12: syntax error, reserved word used as an alias name
Cmnd_Alias CHROOT=foo Cmnd_Alias CHROOT=foo
^~~~~~ ^~~~~~
sudoers:3: syntax error, reserved word used as an alias name sudoers:3:12: syntax error, reserved word used as an alias name
User_Alias TIMEOUT=foo User_Alias TIMEOUT=foo
^~~~~~~ ^~~~~~~
sudoers:4: syntax error, reserved word used as an alias name sudoers:4:13: syntax error, reserved word used as an alias name
Runas_Alias CWD=bar Runas_Alias CWD=bar
^~~ ^~~
sudoers:5: syntax error, reserved word used as an alias name sudoers:5:12: syntax error, reserved word used as an alias name
Host_Alias NOTBEFORE=baz Host_Alias NOTBEFORE=baz
^~~~~~~~~ ^~~~~~~~~
sudoers:6: syntax error, reserved word used as an alias name sudoers:6:12: syntax error, reserved word used as an alias name
Host_Alias NOTAFTER=biff Host_Alias NOTAFTER=biff
^~~~~~~~ ^~~~~~~~