Score:0

Restart rspamd.service as non-root user

ng flag

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?

djdomi avatar
za flag
well sudo could handle this. but remember that it is and will be always a wonderful security issue for ever
Score:0
ng flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.