Discussion Locked

Solaris 8 Script Question

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I would like userA to be able to run a script that switches to userB in the script, because I do not want userA to have access to certain files. My problem is that I can't get the su command to work in the script without being prompted to enter the password when userA runs the script. Is there a way to code the password in the script?

9 replies

by cmorris

If you want just part of the script to run as userB, I believe you will have to create a script or program containing just the commands to be executed as userB. When you run a setuid program or script, the effective user id of the person running thescript becomes the same as the owner of the setuid script. Effective user id works for reading and writing files and does not work for remote commands such as rsh or rcp. That call for using setreuid() which is not available in a shell script. It isgenerally considered poor security to have a setuid script. If so, be very careful that you don't accidently execute something hidden in a supposed file name or argument obtained from the user running the script. Hope this helps

by ghislain.levesque

Your script need to be own by USERB and you need to do a chmod 4755 on your script. When any user run that script, they will become USERB. You have to be VERY carefull with this. If you are calling any external scripts, verify the permissions on these scripts....

by charl3m

Why not try the following in your script.
su userB -c "your_script_to_run" &

This discussion is closed to new replies.