LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to edit /etc/sudoers so that I can run another users script (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-edit-etc-sudoers-so-that-i-can-run-another-users-script-880839/)

vanish78 05-15-2011 11:01 AM

How to edit /etc/sudoers so that I can run another users script
 
Hi,

I'm a newbie so please help, and if this is the wrong forum guide me to the correct one thanks.

I want to run a script owned by another user. It should not be run by root.
I have edited the sudoers file but it runs the script as root, I want it to run it as user grid?

This is what I have so far :

udo -l
User oracle may run the following commands on this host:
(root) /home/grid/asm_test.sh


cat /etc/sudoers

# User_Alias ADMINS = jsmith, mikem
User_Alias MAINTAINERS = oracle

## Command Aliases
## These are groups of related commands...
Cmnd_Alias DEB = /home/grid/asm_test.sh



## Allow root to run any commands anywhere
root ALL=(ALL) ALL
MAINTAINERS ALL=DEB

Please help, I'm stuck

jamescondron 05-15-2011 11:03 AM

What about:
Code:

su - grid -c $command

TobiSGD 05-15-2011 11:05 AM

To run a script as another user with sudo you have to use the -u option, for example
Code:

sudo -u user2 myscript
To learn more about sudo's option try
Code:

man sudo

ButterflyMelissa 05-15-2011 11:10 AM

Hi,

Welcome to the forum...as far as I'm concerned, this is the right place, dont worry. ;)

Okay, SUDO means that if you do this

Quote:

sudo somecommand
that you must have the rights to run somecommand as ... root. So far you're correct in editting the sudoers, but, as you become root (temp) you try to run the command as ... root.

Quote:

I want to run a script owned by another user. It should not be run by root.
As you say yourself, it should not be run as root.

What I can suggest is two things:

- place the script in a system-wide accessible spot (/opt/somefolder for example) and set the rights to the corect group, you and the "other user" belong to a group, well then. Make sure you're both in the same user group...
- copy the script to your own space, very quick, but very-very dirty...not the cleanest plan...

Good luck with this!

Thor

vanish78 05-15-2011 01:37 PM

Thanks for the fast responses!

jamescondron : su - grid -c /home/grid/asm_test.sh , still asks for a password, I need to run it so it doesn't ask for a password

TobiSGD : I tried that but complains that the user is not in the sudoers file -

sudo -u grid /home/grid/asm_test.sh
Sorry, user oracle is not allowed to execute '/home/grid/asm_test.sh' as grid on avgo2db01.theavenggroup.com.

Thor_2.0 : I created a scripts directory /opt/scripts, moved the script but gives me the same permissions error:

/u01/app/grid/product/11.2.0/grid/bin/asmcmd: line 122: /u01/app/grid/product/11.2.0/grid/perl/bin/perl: Permission denied

Both users belong to the same group.

TobiSGD 05-15-2011 01:46 PM

Deleted: Have read the previous post wrong. Sorry.

ButterflyMelissa 05-15-2011 02:28 PM

Quote:

/u01/app/grid/product/11.2.0/grid/bin/asmcmd: line 122
Wow, wait a sec! You problem could well be in line 122, and not the script as a whole. Check what is being called there, and see if you're allowed to do that...

Thor


All times are GMT -5. The time now is 12:18 PM.