Troubleshooting gentoo box require root password to mount any drive

It’s has been like that recently. I didn’t notice at first until Mom told me that a password require message pop up every time she plugs in the usb drive.

After googling around I narrow that problem  down to udisks (the one make the mounting process) and polkit  (the authorization mechanism). In ideal situation udisks would ask polkit to elevate its permission so that it can run just the mounting, but somehow it stuck in my case and polkit require root password to be provided before it can elevate permission.

Small and hideous problems like this one sometime pop up and in rolling release system and most of the time they will be gone  after a few rounds of updating. But it has been months and with no update for either udisks or polkit insight, I will have to investigate.

It turns out that polkit allow user to write custom rule in JavaScript syntax to customize how an action can be authorized. It has a very detail guide about how to do that in man page man 8 polkit And relate to the mounting problem back in 2012, people tend to add this line of code in /etc/polkit-1/rules.d/10-mounting.rules

polkit.addRule (function (action, subject) {
    if ( == 'org.freedesktop.udisks2.filesystem-mount-system' && subject.isInGroup('users'))
        return polkit.Result.YES;

And it turned out that I’ve already got this  code in place since some good old time. Damn! They clearly failed to work now. A bit more of googling lead me to udisks Authorization checks reference page and with some basic coding tweaking, I got this:

function(action, subject) {
//        polkit.log(action);
//        polkit.log(subject);
if ("org.freedesktop.udisks2") > -1
&& action.lookup("drive.removable")
//            && subject.isInGroup("storage")
) {
return polkit.Result.YES;


The new and “enhanced” code will authroize every udisk action as long as the drive in question is removable and it works like charm for usb, taking care of not only the mounting but unmounting as well. However it fails miserably for hot swap HDD.

So I guess I will have to accept some mask package of later version of polkit and udisks to see if the problem was already fixed because it’s sure don’t have to be that hard on the more bleeding edge archlinux.