Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Udev rule for user disk mounting
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Linx_
n00b
n00b


Joined: 01 Jul 2018
Posts: 68

PostPosted: Sun Sep 15, 2024 2:30 am    Post subject: Udev rule for user disk mounting Reply with quote

I've just reinstalled Gentoo after simply ages, and I've forgotten how to do something. Regular users are not allowed to mount disks and partitions via the gui, e.g. by double-clicking on the caja icon. I solved this in the past with a custom udev rule, but for the life of me I can't remember what was in it. Can somebody refresh my memory? ~amd64, systemd, and mate.
_________________
I occasionally post sober.
My overlay of Mate tools and desktop apps is here.
Back to top
View user's profile Send private message
rab0171610
Guru
Guru


Joined: 24 Dec 2022
Posts: 423

PostPosted: Sun Sep 15, 2024 3:02 pm    Post subject: Reply with quote

I don't know how you did it in the past. In the file /etc/polkit-1/rules.d/mount-iso.rules, I have the following (where FOO is name of the group that you want the permissions to apply to):
Code:
polkit.addRule(function(action, subject) {
    if ( (action.id.indexOf("org.freedesktop.udisks2.filesystem-mount-system") == 0) ||
         (action.id.indexOf("org.freedesktop.udisks2.loop-modify-others") == 0) ) {
        polkit.log("action=" + action);
        polkit.log("subject=" + subject);
        if (subject.isInGroup("FOO")) {
            return polkit.Result.YES;
        }
    }

Personally, I use a single user system so I use the group with the same name as the username in place of 'FOO' which suffices for my use case.
There may be other, possibly better ways depending on your security needs and setup.
Back to top
View user's profile Send private message
Linx_
n00b
n00b


Joined: 01 Jul 2018
Posts: 68

PostPosted: Sun Sep 15, 2024 3:29 pm    Post subject: Reply with quote

rab0171610 wrote:
There may be other, possibly better ways depending on your security needs and setup.

It's just a single user desktop in my house, the only security threats are some shifty cats. :wink:
_________________
I occasionally post sober.
My overlay of Mate tools and desktop apps is here.
Back to top
View user's profile Send private message
Linx_
n00b
n00b


Joined: 01 Jul 2018
Posts: 68

PostPosted: Mon Sep 16, 2024 3:09 am    Post subject: Reply with quote

That works, but it asks for superuser authentication each time. Can it be modified to not ask for authentication, more like other desktop distros like Mint and Ubuntu?
_________________
I occasionally post sober.
My overlay of Mate tools and desktop apps is here.
Back to top
View user's profile Send private message
rab0171610
Guru
Guru


Joined: 24 Dec 2022
Posts: 423

PostPosted: Mon Sep 16, 2024 4:22 am    Post subject: Reply with quote

You can also try /etc/polkit-1/rules.d/10-udisks2.rules:
Code:
polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.udisks2.filesystem-mount-system" ||
         action.id == "org.freedesktop.udisks2.filesystem-mount") &&
        subject.isInGroup("FOO")) {
        return polkit.Result.YES;
    }
});
Back to top
View user's profile Send private message
Linx_
n00b
n00b


Joined: 01 Jul 2018
Posts: 68

PostPosted: Mon Sep 16, 2024 5:46 pm    Post subject: Reply with quote

That's still asking for authentication every time I mount a drive. It's not the end of the world, but it's annoying. Any other suggestions?
_________________
I occasionally post sober.
My overlay of Mate tools and desktop apps is here.
Back to top
View user's profile Send private message
lars_the_bear
Guru
Guru


Joined: 05 Jun 2024
Posts: 521

PostPosted: Mon Sep 16, 2024 6:09 pm    Post subject: Reply with quote

Can't you just use the 'user' flag in `/etc/fstab`? Or are these removable devices that don't have /etc/fstab entries?

BR, Lars.
Back to top
View user's profile Send private message
Linx_
n00b
n00b


Joined: 01 Jul 2018
Posts: 68

PostPosted: Mon Sep 16, 2024 6:40 pm    Post subject: Reply with quote

lars_the_bear wrote:
Can't you just use the 'user' flag in `/etc/fstab`? Or are these removable devices that don't have /etc/fstab entries?

BR, Lars.


Both. It's mostly internal media drives, but also some external devices. If I specify them in fstab, they have a predetermined mount point, no? I want them to mount via udisks like they do in, for example, Mint Mate. You open caja, click on a device, and it mounts in /run/media/user/ and appears on the desktop. That's what I'm after. I've had this working before, but it's been so long I can't remember how I did it.
_________________
I occasionally post sober.
My overlay of Mate tools and desktop apps is here.
Back to top
View user's profile Send private message
lars_the_bear
Guru
Guru


Joined: 05 Jun 2024
Posts: 521

PostPosted: Tue Sep 17, 2024 9:01 am    Post subject: Reply with quote

@Linx_

Yeah. I think you can't use fstab settings for devices that don't have a fixed mount point. I run Gnome gfvsd for this, even though I don't use Gnome itself, or any other Gnome components. To be honest, I have no idea what arcane magic it uses to get around the permissions issue :/

BR, Lars.
Back to top
View user's profile Send private message
rab0171610
Guru
Guru


Joined: 24 Dec 2022
Posts: 423

PostPosted: Tue Sep 17, 2024 2:31 pm    Post subject: Reply with quote

https://github.com/coldfix/udiskie/wiki/Permissions
Refer to that and see if it is of any help to you.
The only alternatives I can think of is to investigate how other distros allow user disk mounting and unmounting without a password or look for ways to create local polkit override rules that
do not require a password for the mount command.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum