Bug 942 - visudo fails if $EDITOR contains quotes
visudo fails if $EDITOR contains quotes
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Visudo
1.9.2
PC Linux
: low low
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-10-27 15:49 MDT by Peter Oliver
Modified: 2021-09-11 15:57 MDT (History)
1 user (show)

See Also:


Attachments
Patch to honor quotes in EDITOR and collapse backslashes. (5.42 KB, patch)
2020-11-12 16:24 MST, Todd C. Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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