|
Bugzilla – Full Text Bug Listing |
| Summary: | visudo could give a more precise error description | ||
|---|---|---|---|
| Product: | Sudo | Reporter: | Marcel Partap <mpartap> |
| Component: | Visudo | Assignee: | Todd C. Miller <Todd.Miller> |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | mavit+bugzilla.sudo.ws |
| Priority: | low | ||
| Version: | 1.8.23 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
|
Description
Marcel Partap
2018-07-15 05:31:57 MDT
I committed changes last week to provide more information about where in the sudoers line the error is. Currently, this will only show the location of the offending token in the line. In the future I hope to have more descriptive error messages as well in the form of "expected foo but got bar". It is a little more difficult to get that information out of the parser. Sudo 1.9.3 produces more detailed syntax error messages.
Here’s a brief look at the syntax error message changes, given a sudoers file with two errors:
millert ALL = /fail : foo
root ALL = ALL foo
Sudo 1.9.2:
>>> sudoers: syntax error near line 1 <<<
>>> sudoers: syntax error near line 2 <<<
parse error in sudoers near line 1
Sudo 1.9.3:
sudoers:1: syntax error, unexpected '\n', expecting '=' or ','
millert ALL = /fail : foo
^
sudoers:2: syntax error, unexpected WORD, expecting END or ':' or '\n'
root ALL = ALL foo
^~~
In the sudo 1.9.3 case, the first part of the privilege, “millert ALL = /fail” is still parsed. Only the part after the ‘:’ with the error is discarded.
That seems much better for figuring out problems, thanks for implementing this! : ) (In reply to Todd C. Miller from comment #1) > I committed changes last week to provide more information about > where in the sudoers line the error is. Currently, this will only > show the location of the offending token in the line. Additionally, would it be possible to give the column number as a number? I'd like to parse the output of visudo to highlight the error in my text editor, and this would make that easier. For example: sudoers:1:25: syntax error, unexpected '\n', expecting '=' or ',' millert ALL = /fail : foo ^ sudoers:2:16: syntax error, unexpected WORD, expecting END or ':' or '\n' root ALL = ALL foo ^~~ Sure, the information is already available so this is just a matter of adjusting the warning message format. The following commits add the column number: https://www.sudo.ws/repos/sudo/rev/0aea28dec8f2 https://www.sudo.ws/repos/sudo/rev/1c9d86b88517 |