Skip to content

Instantly share code, notes, and snippets.

@Hi-Angel Hi-Angel/50-udiskie.rules
Last active Aug 26, 2017

Embed
What would you like to do?
Make polkit allow mounting by user in "storage" group
// Tested with ArchLinux. Cures dolphin/nautilus error "Not authorized to perform action" upon mounting.
// Sources: http://smcv.pseudorandom.co.uk/2015/why_polkit/ and https://github.com/coldfix/udiskie/wiki/Permissions
// 1. make sure you are in "storage" group
// 2. create /etc/polkit-1/rules.d/50-udiskie.rules file with the following content
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.filesystem-mount-system": YES,
"org.freedesktop.udisks2.encrypted-unlock": YES,
"org.freedesktop.udisks2.encrypted-unlock-system": YES,
"org.freedesktop.udisks2.eject-media": YES,
"org.freedesktop.udisks2.eject-media-system": YES,
"org.freedesktop.udisks2.power-off-drive": YES,
"org.freedesktop.udisks2.power-off-drive-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];
}
});
// 3. Try again to mount. No reboot is needed (except if you were not in the "storage" group,
// this one might require reboot or relogin, and is irrelevant to polkit).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.