Bugzilla – Bug 372
Sudo incorrectly passing through arguments with -i and -- options
Last modified: 2010-05-07 14:10:23 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.
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.