| 1 |
// Allow the unprivileged "barman" system user to manage (start, stop, |
| 2 |
// restart) only the per-server WAL receiver units that "barman cron" |
| 3 |
// reconciles. Without this rule, the barman user could not control these |
| 4 |
// system units and the systemd integration would require running the cron |
| 5 |
// service as root. |
| 6 |
polkit.addRule(function(action, subject) { |
| 7 |
if (action.id == "org.freedesktop.systemd1.manage-units" && |
| 8 |
subject.user == "barman") { |
| 9 |
var unit = action.lookup("unit"); |
| 10 |
var verb = action.lookup("verb"); |
| 11 |
// Match the per-server template instances only: the name must start |
| 12 |
// with the prefix AND be a .service (not a .timer/.socket/... the |
| 13 |
// package never ships), and only the verbs barman actually uses |
| 14 |
// (start/stop, plus restart), not e.g. kill with an arbitrary signal. |
| 15 |
if (unit && |
| 16 |
unit.indexOf("barman-receive-wal@") == 0 && |
| 17 |
unit.substr(-8) == ".service" && |
| 18 |
(verb == "start" || verb == "stop" || verb == "restart")) { |
| 19 |
return polkit.Result.YES; |
| 20 |
} |
| 21 |
} |
| 22 |
}); |