Search code examples
bashunixcronsignalssudo

How do I create bash script that listens for signal


I need a non-sudoer user to be able to run a couple sudo commands on a regular basis. One of those commands is kill, but I only want it to be able to kill in a very specific way. I don't want to allow the user to kill whatever it wants.

It seems that I would be able to create a root cronjob that listens for some sort of signal, and it could execute those particular commands upon receiving the signal. The non-root user could send the signal, and the root-level commands could be executed by the root cronjob.

How can I do something like this? Are there other options I'm not thinking of?

It will be running on Raspbian.


Solution

  • I would write a shell script that calls the kill command and give the user sudo permissions for that script only.

    theuser ALL=(ALL) NOPASSWD:/usr/local/sbin/specific_kill