View previous topic :: View next topic |
Author |
Message |
Linx_ n00b
Joined: 01 Jul 2018 Posts: 68
|
Posted: Sun Sep 15, 2024 2:30 am Post subject: Udev rule for user disk mounting |
|
|
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 |
|
|
rab0171610 Guru
Joined: 24 Dec 2022 Posts: 419
|
Posted: Sun Sep 15, 2024 3:02 pm Post subject: |
|
|
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 |
|
|
Linx_ n00b
Joined: 01 Jul 2018 Posts: 68
|
Posted: Sun Sep 15, 2024 3:29 pm Post subject: |
|
|
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. _________________ I occasionally post sober.
My overlay of Mate tools and desktop apps is here. |
|
Back to top |
|
|
Linx_ n00b
Joined: 01 Jul 2018 Posts: 68
|
Posted: Mon Sep 16, 2024 3:09 am Post subject: |
|
|
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 |
|
|
rab0171610 Guru
Joined: 24 Dec 2022 Posts: 419
|
Posted: Mon Sep 16, 2024 4:22 am Post subject: |
|
|
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 |
|
|
Linx_ n00b
Joined: 01 Jul 2018 Posts: 68
|
Posted: Mon Sep 16, 2024 5:46 pm Post subject: |
|
|
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 |
|
|
lars_the_bear Guru
Joined: 05 Jun 2024 Posts: 515
|
Posted: Mon Sep 16, 2024 6:09 pm Post subject: |
|
|
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 |
|
|
Linx_ n00b
Joined: 01 Jul 2018 Posts: 68
|
Posted: Mon Sep 16, 2024 6:40 pm Post subject: |
|
|
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 |
|
|
lars_the_bear Guru
Joined: 05 Jun 2024 Posts: 515
|
Posted: Tue Sep 17, 2024 9:01 am Post subject: |
|
|
@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 |
|
|
rab0171610 Guru
Joined: 24 Dec 2022 Posts: 419
|
Posted: Tue Sep 17, 2024 2:31 pm Post subject: |
|
|
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 |
|
|
|