Imposing quotes/escapes on command allowed by sudo
Hi,
I want to allow a user to be able to execute one of the following commands: Code:
sudo grep -i connect\ time /var/log/messages Code:
sudo grep -i connect time /var/log/messages Code:
somebody ALL=NOPASSWD: /bin/grep -i connect\ time /var/log/messages Any suggestions? Thanks in advance. |
Offhand I can't think of a way to do that. But you could create a script that only root can run containing the command you want to allow (without sudo) and add that script to /etc/sudoers.
|
OK. Thanks for the response.
|
Sorry, retesting my answer it didn't work. One thing you could try is replacing the space with a dot which would match. The user would have to enter the dot in the command as well however.
|
Quote:
|
Hello,
You can create script1 with commands and arguments with quotes like: /usr/sbin/asterisk -rx "sip show peers" Allow the user to run this script by adding him to sudoers "visudo" user ALL= NOPASSWD: /path/script1 Create script2 and put inside it #!/bin/bash sudo /path/script1 Run the script2 normally without sudo. ./script2 use script2 to be called by other services. I have tested this solution. I hope this will help. |
All times are GMT -5. The time now is 07:37 PM. |