[systemd-devel] Restarting a service as user instead as root

Tomasz Torcz tomek at pipebreaker.pl
Mon Aug 13 10:06:35 UTC 2018


On Mon, Aug 13, 2018 at 11:51:46AM +0200, Silvio Knizek wrote:
> Am Montag, den 13.08.2018, 11:28 +0200 schrieb Cecil Westerhof:
> > I have a service that is run as a different user as root. But only
> > root can
> > restart the service. Is there a way to make 'systemctl restart' work
> > for
> > the user that runs the service?
> 
> Hi,
> 
> you can either define a sudo-rule or you use policykit (polkit) for
> this. See 
> https://wiki.archlinux.org/index.php/Polkit#Allow_management_of_individual_systemd_units_by_regular_users
>  for an example. Keep in mind that the polkit feature depends on your
> available systemd version.

Or, if the service has Restart= setting, user can kill the MainPID.
-- 
Tomasz Torcz                "Funeral in the morning, IDE hacking
xmpp: zdzichubg at chrome.pl    in the afternoon and evening." - Alan Cox



More information about the systemd-devel mailing list