Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following sudo config entry which I added via sudo visudo:

mark ALL = NOPASSWD: /usr/bin/lxc-ls*

I can run lxc-ls with my user fine but I can't append any parameters without it demanding I prefix the command with sudo.

$ whoami
mark
$ lxc-ls
test-container
$ lxc-ls --fancy
lxc-ls: error: You must be root to access advanced container properties. Try running: sudo /usr/bin/lxc-ls

Any idea how I can edit via sudo visudo to allow for any argument after the command?

I don't want to prefix the command with sudo as I'm using a python library to execute the command and it's being funny about sudo prefixes.

Update:

I've tried removing the * but that didn't work either:

$ sudo grep '\-ls' /etc/sudoers
mark ALL = NOPASSWD: /usr/bin/lxc-ls
$ lxc-ls
test-container
$ lxc-ls --fancy
...
lxc-ls: error: You must be root to access advanced container properties. Try running: sudo /usr/bin/lxc-ls
share|improve this question

closed as off-topic by Iain, Jenny D, MadHatter, Nathan C, Wesley Nov 11 '13 at 18:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Iain, Jenny D, MadHatter, Nathan C, Wesley
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
This looks perfectly normal to me, perhaps you should read the information provided more carefully, they're sure to contain information that is pertinent to your current issue. –  Iain Nov 11 '13 at 7:07
add comment

2 Answers

From the sudoers manual :

A simple file name allows the user to run the command with any arguments he/she wishes

So, drop the *.

You will still need to prefix the lxc-ls command with sudo or write a simple wrapper that does it for you.

share|improve this answer
    
No joy, I've edited my question showing the output. –  Mark L Nov 11 '13 at 7:08
4  
Reading is fundamental. –  dmourati Nov 11 '13 at 7:12
add comment

That's not how sudo works. The sudoers file simply grants the user rights to a command when prefixed by the sudo command, not so you can run it without the sudo being prefixed. You'd need to write a wrapper script (like a simple bash file) to execute the command if your own script can't do it.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.