Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locking LUKS device: Not authorized #227

Open
cyberpunkrocker-zero opened this issue Nov 10, 2021 · 4 comments
Open

Locking LUKS device: Not authorized #227

cyberpunkrocker-zero opened this issue Nov 10, 2021 · 4 comments

Comments

@cyberpunkrocker-zero
Copy link

cyberpunkrocker-zero commented Nov 10, 2021

I have an encrypted laptop (Arch Linux), with LUKS encrypted /boot partition on an USB stick. After booting I'm usually removing the USB stick. I can unmount and close the LUKS partition on the USB stick via a root terminal before that, but because I'm lazy, and because udiskie already seems to have the functionality, I'd like to use udiskie tray app for that.

However, when I click the 'Lock /dev/sdb1', I get the following error:

$ udiskie --tray
unmounted /org/freedesktop/UDisks2/block_devices/dm_2d0
failed to lock /org/freedesktop/UDisks2/block_devices/sdb1: GDBus.Error:org.freedesktop.UDisks2.Error.NotAuthorizedCanObtain: Not authorized to perform operation

When I plug the USB stick back in, udiskie mounts it and asks for the LUKS passphrase, and then unlocks the partition. Just as it is supposed to do...

How come udiskie has permissions to unlock a device, but not to lock it? Is this an udiskie issue, or should I make some adjustments somewhere to my system?

@coldfix
Copy link
Owner

coldfix commented Nov 10, 2021

The permissions are defined using polkit rules, see Permissions. It's possible to give yourself only unlocking but no unlocking authorization. It also plays a role from which seat (ssh/tty/desktop/systemd) you unlock/lock the device. If you lock/unmount a device from a different seat than was used to lock it, you may need the XXX-other-seat permissions.

On the other hand, it could also be that udisks has misjudged whether the unlocked device is e.g. a system-internal device or external device. In any case, it doesn't look like a udiskie issue to me. You can check whether you can lock/unlock using udisksctl:

udisksctl unlock -b /dev/sdX

# later:

udisksctl lock -b /dev/sdX

I expect the same problem will occur. If you need further insight, keep another terminal window open while un-/locking with the following command running:

journalctl -n 20 -f -u udisks2.service

@coldfix
Copy link
Owner

coldfix commented Nov 10, 2021

Oh wait, I didn't fully read through your post.

So your situation is that first you unlock+mount the USB drive as root as part of your boot process, and then later try to lock it as user using udisks? In that case it's not surprising that this won't with default permissions.

You definitely also need at least the org.freedesktop.udisks2.encrypted-lock-others permission, but I can't promise this will be sufficient.

@coldfix
Copy link
Owner

coldfix commented Nov 15, 2021

Another possibility that may prevent locking even in case of sufficient authorizations is if your device is known in /etc/crypttab under a different mapper name than it was opened as. That will completely confuse udisks2 for some reason.

@joooeey
Copy link

joooeey commented Mar 16, 2023

You definitely also need at least the org.freedesktop.udisks2.encrypted-lock-others permission, but I can't promise this will be sufficient.

This didn't work for me on a Linux Mint. I'm using Udiskie because Lightdm and hence Thunar keeps crashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants