Bug 942

Summary: visudo fails if $EDITOR contains quotes
Product: Sudo Reporter: Peter Oliver <mavit+bugzilla.sudo.ws>
Component: VisudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: low CC: mehmetgelisin
Priority: low    
Version: 1.9.2   
Hardware: PC   
OS: Linux   
Attachments: Patch to honor quotes in EDITOR and collapse backslashes.

Description Peter Oliver 2020-10-27 15:49:48 MDT
visudo fails if $EDITOR isn't a simple space-separated list of arguments.  For example:

# env EDITOR='sh -c "vi \$1"' visudo
\$1": -c: line 0: unexpected EOF while looking for matching `"'
\$1": -c: line 1: syntax error: unexpected end of file
visudo: /etc/sudoers.tmp unchanged

(This is a simplified example, but my actual use-case it to send a message to an already-running instance of Emacs to tell it to open visudo's temporary file.  Background at https://github.com/magit/with-editor/issues/84)
Comment 1 Todd C. Miller 2020-11-12 16:24:56 MST
Created attachment 547 [details]
Patch to honor quotes in EDITOR and collapse backslashes.

Can you try the following patch and verify that it fixes your use case?  It can be applied to either sudo 1.9.3 or the current sources in mercurial or github.
Comment 2 Peter Oliver 2020-11-15 07:01:50 MST
Yes, the patch works for me.  Thanks!
Comment 3 Todd C. Miller 2020-11-30 13:24:33 MST
Fixed in sudo 1.9.4