Bug 428546

Summary: visudo reports wrong line number on syntax error
Product: [Fedora] Fedora Reporter: Jonathan Wakely <fedoration>
Component: sudoAssignee: Peter Vrabec <pvrabec>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 8CC: krahn, kzak
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 1.6.9p4-4.fc8 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-02-26 00:24:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jonathan Wakely 2008-01-13 03:02:13 UTC
Description of problem:

If you create a syntax error near the end of /etc/sudoers then visudo will say:

>>> sudoers file: syntax error, line 95 <<<

If you choose to edit the file it conveniently moves you to the specified line.
 Unfortunately the line number is wrong.

Version-Release number of selected component (if applicable):

sudo-1.6.9p4-3.fc8

How reproducible:
Always

Steps to Reproduce:
1. visudo
2. add a new line at the end, containing a syntax error
3. save and quit
4. choose to re-edit the file
  
Actual results:

Cursor is automatically placed on the wrong line.

Expected results:

Cursor should be on the line containing the syntax error.

Additional info:

This is caused by the following lines:

Defaults    env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
                        LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
                        LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
                        LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
                        LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
                        _XKB_CHARSET XAUTHORITY"

The escaped newlines confuse the line counter so that any syntax error after
env_keep will report the wrong line number.

Comment 1 Jonathan Wakely 2008-01-13 03:33:32 UTC
Using += allows you to break the lines up without confusing the line numbers:

Defaults    env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR"       
Defaults    env_keep += "LS_COLORS MAIL PS1 PS2 QTDIR USERNAME"                
Defaults    env_keep += "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION"
Defaults    env_keep += "LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME
LC_NUMERIC"                                                                    
        Defaults    env_keep += "LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE
LINGUAS" Defaults    env_keep += "_XKB_CHARSET XAUTHORITY"

but I'll leave this bug open since the problem still exists


Comment 2 Peter Vrabec 2008-02-21 16:46:23 UTC
*** Bug 432395 has been marked as a duplicate of this bug. ***

Comment 3 Fedora Update System 2008-02-21 17:51:08 UTC
sudo-1.6.9p4-4.fc8 has been submitted as an update for Fedora 8

Comment 4 Fedora Update System 2008-02-26 00:24:55 UTC
sudo-1.6.9p4-4.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.