<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2018-08-13 11:51 GMT+02:00 Michael Chapman <span dir="ltr"><<a href="mailto:mike@very.puzzling.org" target="_blank">mike@very.puzzling.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Mon, 13 Aug 2018, Cecil Westerhof wrote:<br>
> I have a service that is run as a different user as root. But only root can<br>
> restart the service. Is there a way to make 'systemctl restart' work for<br>
> the user that runs the service?<br>
<br>
</span>You could simply add some Sudo rules allowing the user to perform that <br>
command.<br>
<br>
Alternatively, you can write a polkit rule to describe the permissions. <br>
For example, the following would give permission for a particular <br>
user to restart a particular service:<br>
<br>
    polkit.addRule(function(<wbr>action, subject) {<br>
        if (<a href="http://action.id" rel="noreferrer" target="_blank">action.id</a> == "org.freedesktop.systemd1.<wbr>manage-units" &&<br>
            action.lookup("unit") == "example.service" &&<br>
            action.lookup("verb") == "restart" &&<br>
            subject.user == "username") {<br>
            return polkit.Result.YES;<br>
        }<br>
    });<br>
<br>
See the AUTHORIZATION RULES section of the polkit(8) manpage for further <br>
details.<br>
</blockquote></div><br><div style="font-family: courier\ new, monospace;" class="gmail_default">I tried to put this in:<br>    /etc/polkit-1/rules.d/10-auth.rules<br><br></div><div style="font-family: courier\ new, monospace;" class="gmail_default">When reading:<br>    <a href="https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html">https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html</a><br>    AUTHORIZATION RULES<br><br></div><div style="font-family: courier\ new, monospace;" class="gmail_default">It should work immediately after writing the file, but it does not.<br></div><div style="font-family: courier\ new, monospace;" class="gmail_default">Is there something else I should do?<br><br></div><div style="font-family: courier\ new, monospace;" class="gmail_default">I am using Debian 9.</div><br>-- <br><div class="gmail_signature">Cecil Westerhof</div>
</div></div>