Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoking executables as a certain user 2

Status
Not open for further replies.

ddrillich

Technical User
Jun 11, 2003
546
0
0
US
Good Day,

I have a shell script that looks like:

cd /VZ/opt/vignette/autonomy/Dre
nohup Dre 1> /dev/null 2> /dev/null &
echo ""
echo "Started."
echo ""
echo "--------------------------------------------------------------------"
cd /VZ/opt/vignette/autonomy/AutoIndexer
./Start.sh

I want the two executables to run as a certain user, let's say x.

What do I need to change?

Thanks a lot,
Dan

 
You need to make them SETUID scripts or programs. First, you need to make them owned by the userid you want them run by. Then you need to set the SUID bit.

Say the username you want them run by is "[tt]joeuser[/tt]" and the executables are "[tt]programA[/tt]" and "[tt]scriptB[/tt]". As [tt]root[/tt], do the following...
Code:
chown joeuser programA scriptB
chmod 4777 programA scriptB
Then, when these are run, they will be run with the effective userid of [tt]joeuser[/tt], no matter who is running it.

Hope this helps.
 
Another option is:

Use "su" command to the spacific user.

For ex.
Your above scripts to run as user x :

login to root :
#su - x -c "cd /VZ/opt/vignette/autonomy/AutoIndexer; \
./Start.sh"

For more info read man su

Hope this helps.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top