Last active
July 6, 2024 20:18
-
-
Save Scrumplex/8f528c1f63b5f4bfabe14b0804adaba7 to your computer and use it in GitHub Desktop.
Polkit rules for udisks, and udisks2. Compatible with udiskie and Dolphin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original rules: https://github.com/coldfix/udiskie/wiki/Permissions | |
// Changes: Added org.freedesktop.udisks2.filesystem-mount-system, as this is used by Dolphin. | |
polkit.addRule(function(action, subject) { | |
var YES = polkit.Result.YES; | |
// NOTE: there must be a comma at the end of each line except for the last: | |
var permission = { | |
// required for udisks1: | |
"org.freedesktop.udisks.filesystem-mount": YES, | |
"org.freedesktop.udisks.luks-unlock": YES, | |
"org.freedesktop.udisks.drive-eject": YES, | |
"org.freedesktop.udisks.drive-detach": YES, | |
// required for udisks2: | |
"org.freedesktop.udisks2.filesystem-mount": YES, | |
"org.freedesktop.udisks2.encrypted-unlock": YES, | |
"org.freedesktop.udisks2.eject-media": YES, | |
"org.freedesktop.udisks2.power-off-drive": YES, | |
// Dolphin specific | |
"org.freedesktop.udisks2.filesystem-mount-system": YES, | |
// required for udisks2 if using udiskie from another seat (e.g. systemd): | |
"org.freedesktop.udisks2.filesystem-mount-other-seat": YES, | |
"org.freedesktop.udisks2.filesystem-unmount-others": YES, | |
"org.freedesktop.udisks2.encrypted-unlock-other-seat": YES, | |
"org.freedesktop.udisks2.eject-media-other-seat": YES, | |
"org.freedesktop.udisks2.power-off-drive-other-seat": YES | |
}; | |
if (subject.isInGroup("storage")) { | |
return permission[action.id]; | |
} | |
}); |
You can simplify this by using a "catch all" on org.freedesktop.udisks2.
permissions like this:
polkit.addRule(function(action, subject) {
if (subject.isInGroup("wheel")) {
if (action.id.startsWith("org.freedesktop.udisks2.")) {
return polkit.Result.YES;
}
}
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, looks like the
filesystem-mount-system
is just what I needed for Thunar too. Thanks for this! 👍