Syncthing: allow the syncthing user to stop syncthing service

This commit is contained in:
Toast 2023-09-02 23:12:37 +02:00
parent 008f1bc36f
commit 5f983678dc

View file

@ -8,4 +8,18 @@
dataDir = config.users.users.toast.home; dataDir = config.users.users.toast.home;
folders."passwords".path = "~/Documents/Passwords"; folders."passwords".path = "~/Documents/Passwords";
}; };
# Allow regular users to stop syncthing
# https://stackoverflow.com/questions/61480914/using-policykit-to-allow-non-root-users-to-start-and-stop-a-service
security.polkit.extraConfig = ''
polkit.addRule(function(action, subject) {
if (
action.id == "org.freedesktop.systemd1.manage-units" &&
action.lookup("unit") == "syncthing.service" &&
subject.user == "${config.services.syncthing.user}"
)
{
return polkit.Result.YES;
}
})
'';
} }