Need help about user access

Hi frds,

I have got a script restart.sh that kills and restarts a process. This scripts runs under a user called USER1 who is a normal user. Now my requirement is that i got other user named USER2 who should be able to run that script as USER1 as we dont want to share the password of user1 we created other user called user2 with similar access. Any inputs will be great.
OS: centos 5.4
Thanks in advance

You don't state the UNIX OS.

In general try one of these:
A. use sudo and /etc/sudoers to control running the script with setuid.
B. create a setuid executable (best using C/C++) to run the process as root which then becomes the user. Only allow USER1 and USER2 (put them in the same group) to run the executable.

For other systems like solaris there are other ways to do this. Next time, please be sure to include your OS.

Hi,

OS is centos 5.4. I was told this script should run as user1 instead of as root. This is what i have done so far. in sudoers file i have written as below

USER2 ALL=(USER1) NOPASSWD: /home/user1/restart.sh

I have assigned the USER2 primary group of USER1. I have set the suid and sgid on /home/user2/ by using chmod +s and given 774 permissions both on home dir and on script of user2. tried logging this way now from user2 and run script.
sudo -u user1 /home/user1/restart.sh

But still doesnt workout. anyhelp will be great as i want to restart the script as user1 by user2 so that in the process list it shows that the process has been started by same user called user1 so that the cronjobs associted with that script doesnt fail.