1

I have webpage with button, when user clicks on button, script restart.sh on server is executed. This script contains:

#!/bin/bash
systemctl restart rspamd.service

After clicking on the button, restart.sh is executed, but rspamd.service is not restarted: "Failed to restart rspamd.service: Access denied" Because the script is executed by click on button on webpage, the real user who runs it on server is www-data. I tried to set suid bit to run script as root, but it's not working. How can I restart rspamd.service as www-data user?

MTC11
  • 11
  • 2
  • well sudo could handle this. but remember that it is and will be always a wonderful security issue for ever – djdomi Apr 29 '22 at 17:11

1 Answers1

0

Solved with sudo. I tried it before, but I wrote it in wrong order. Edit sudoers with visudo and add this to end of file:

www-data ALL = NOPASSWD: /bin/systemctl restart rspamd.service

Then I can just run sudo systemctl restart rspamd.service and all goes well. Thanks.

MTC11
  • 11
  • 2