Bug 372 - Sudo incorrectly passing through arguments with -i and -- options
Sudo incorrectly passing through arguments with -i and -- options
Status: RESOLVED INVALID
Product: Sudo
Classification: Unclassified
Component: Sudo
1.7.0
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-10-25 12:39 MDT by Rick Helmus
Modified: 2010-05-07 14:10 MDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Helmus 2009-10-25 12:39:59 MDT
It seems that starting from version 1.7.0 sudo is incorrectly passing through shell arguments.

The following command gives an error while it didn't before (<= 1.6.9):
sudo -u root -i -- -c 'echo hi'

will display the following error:
"-bash: - : invalid option"

I tested the following versions:
1.6.9: Default install on OpenSuse (x86_64) and manually installed on Ubuntu 9.10 rc (x86). This version works.
1.7.0: Default install from Ubuntu 9.10 rc (x86). Will give the reported error.
1.7.2: Fresh install on OpenSuse (x86_64). Will give the reported error.
Comment 1 Todd C. Miller 2010-05-07 14:10:23 MDT
The way the -i option works has changed in sudo 1.7.0.  Sudo now supports running a command in conjunction with the -i flag so instead of:

sudo -u root -i -- -c 'echo hi'

You would simply do:

sudo -u root -i echo hi

and sudo will wrap add the -c for you.  The "--" is not being ignored, but what ends up being run is effectively:

/bin/bash -c '-c echo hi'

Which results in the error.