Kill Process not owned by other user

Hi Here is my problem:
1)I am login to unix server through my login id and do SU - xxx
2) Start the script which is running in background
I want that other user which login to there id and do SU - yyy(Different user) kill that
script.
Could you please help me in this.

Create another script (for example kill.sh) that will contain something like:

#!/bin/sh
pkill script-to-kill.sh

then set ownership on this script to user xxx:

chown xxx:other kill.sh

and set setuid bit on it:

chmod 4755 kill.sh

tell user yyy to run this script, and that should be it :wink:

Thanks for this ....

@bartus11

You cannot elevate the privilege of Shell by changing the permissions of a shell script.

It can be done with a SUID program written in C language which then invokes the shell.

Hmm, interesting. I admit I didn't test this solution..

So could you please send me that program

Sorry, I try not to put such programs in the public domain.

In your circumstance I usually create an account soley to run the background process and use that account to start/stop the process from cron. Then also have an locked down interactive login to that account solely for manual status/stop/start/kill . The password to the interactive login would only be known to those who need to know and they do not need access to any other users account.
This also avoids the issues if a process owner changes role.

setuid on shell scripts

I respectfully disagree. This can be a huge security problem if not done correctly. Use a utility like sudo which is built for things like this. It provides access control and logging.

---------- Post updated at 17:24 ---------- Previous update was at 17:22 ----------

this is a REALLY BAD idea for security reasons. Never use setuid/setgid shell scripts. Some systems will even ignore it.

The better way is to set sudo to another userid or group.