assets/polkit: add policy + example rules

This commit is contained in:
2026-07-30 19:09:34 +09:00
parent bdc5121fab
commit 89bf5a831a
4 changed files with 51 additions and 0 deletions
@@ -0,0 +1,17 @@
// Example site policy, layered on top of the <defaults> in no.ntnu.pvv.roowho2.policy.
polkit.addRule(function (action, subject) {
if (action.id !== "no.ntnu.pvv.roowho2.wall" && action.id !== "no.ntnu.pvv.roowho2.write") {
return polkit.Result.NOT_HANDLED;
}
// `wall -g <group>` restricted to members of that same group.
if (action.id === "no.ntnu.pvv.roowho2.wall") {
var group = action.lookup("group");
if (group && !subject.isInGroup(group)) {
return polkit.Result.NO;
}
}
return polkit.Result.NOT_HANDLED;
});
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>Programvareverkstedet</vendor>
<vendor_url>https://git.pvv.ntnu.no/Projects/roowho2</vendor_url>
<action id="no.ntnu.pvv.roowho2.wall">
<description>Broadcast a message to logged in users</description>
<message>Authentication is required to broadcast a message to all users</message>
<defaults>
<allow_any>auth_self</allow_any>
<allow_inactive>auth_self</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.owner">unix-user:roowho2</annotate>
</action>
<action id="no.ntnu.pvv.roowho2.write">
<description>Send a message to another user's terminal</description>
<message>Authentication is required to send a message to another user</message>
<defaults>
<allow_any>auth_self</allow_any>
<allow_inactive>auth_self</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.owner">unix-user:roowho2</annotate>
</action>
</policyconfig>
+1
View File
@@ -92,6 +92,7 @@
fileset = lib.fileset.unions [
(craneLib.fileset.commonCargoSources ./.)
./assets/systemd
./assets/polkit
];
};
+3
View File
@@ -93,6 +93,9 @@ buildFunction ({
install -Dm444 assets/systemd/roowho2.service "$out/lib/systemd/system/roowho2.service"
substituteInPlace "$out/lib/systemd/system/roowho2.service" \
--replace "/usr/bin/roowhod" "${placeholder "out"}/bin/${mainProgram}"
install -Dm444 assets/polkit/no.ntnu.pvv.roowho2.policy "$out/share/polkit-1/actions/no.ntnu.pvv.roowho2.policy"
install -Dm444 assets/polkit/10-no.ntnu.pvv.roowho2.rules "$out/share/polkit-1/rules.d/10-no.ntnu.pvv.roowho2.rules"
'';
meta = with lib; {