[sudo-users] Quotation marks in command option.

Aaron Lewis aaron.lewis1989 at gmail.com
Wed Aug 18 10:02:40 EDT 2010


Bonjour Conde ,

> My problem is that sudo doesn't accept the quotation marks in the ``-c'' 
> option, it keeps asking the user for the password, and after entering it 
> gives an error that says ``Maybe you lack sudo permissions in the sudoers 
> file.''

Why not escape spaces ?

-c \"show\ storagesubsystem\ profile;\"

I did a simple test:

As your shell will handle quoted strings , so if i do like this , it
will require a credential.

* sudo /tmp/test.cmd -c "this is an arg"
Password:

So if space is also escaped , it will work.

* sudo /tmp/test.cmd -c \"this\ is\ an\ arg\"
Args: -c "this is an arg"

==================
/tmp/test.cmd

#!/usr/local/bin/bash
echo "Args: $1 $2"

==================
sudoers

Cmnd_Alias TESTCMDS = /tmp/test.cmd -c "this is an arg"
username hostname = NOPASSWD: TESTCMDS


--
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4R0NL3WI5 on freenode



More information about the sudo-users mailing list