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