LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-23-2022, 08:47 AM   #1
pchristy
Senior Member
 
Registered: Oct 2012
Location: South Devon, UK
Distribution: Slackware
Posts: 1,119

Rep: Reputation: Disabled
Luks encryption


If I plug a Luks encrypted external drive into my laptop, I enter the password and it opens. If I mount an internal Luks encrypted partition (noauto in fstab), as well as the password, it asks for the root password as well, despite the fact that I am the "owner" of the partition.

Why? And How do I stop it?

--
Pete
 
Old 05-23-2022, 11:32 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Does your fstab entry include the "user" option? You need that to allow a non-root user to mount. Using "users" instead of "user" allows any user to unmount, not just the user who mounted it.

Note: You really should include the "nosuid" and "nodev" options also. Think about the security implications of a user-mounted filesystem that might include suid and device inodes.

Last edited by rknichols; 05-23-2022 at 11:37 AM. Reason: add note
 
1 members found this post helpful.
Old 05-23-2022, 11:45 AM   #3
pchristy
Senior Member
 
Registered: Oct 2012
Location: South Devon, UK
Distribution: Slackware
Posts: 1,119

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
Does your fstab entry include the "user" option? You need that to allow a non-root user to mount. Using "users" instead of "user" allows any user to unmount, not just the user who mounted it.
I had "owner" in there instead of "user", but changing it to "user" has made no difference.

Quote:
Originally Posted by rknichols View Post
Note: You really should include the "nosuid" and "nodev" options also. Think about the security implications of a user-mounted filesystem that might include suid and device inodes.
I'll bear that in mind, once I get it working as I want! Its really irritating having to use two passwords when one ought to do it...!

Thanks for the advice!

--
Pete
 
Old 05-23-2022, 12:00 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by pchristy View Post
I had "owner" in there instead of "user", but changing it to "user" has made no difference.
Are you perhaps issuing the mount command with both the device and the mount point? You need to use just one of those and have the mount command get the other from /etc/fstab. When you supply both, /etc/fstab is ignored.
 
Old 05-23-2022, 12:14 PM   #5
pchristy
Senior Member
 
Registered: Oct 2012
Location: South Devon, UK
Distribution: Slackware
Posts: 1,119

Original Poster
Rep: Reputation: Disabled
I'm actually doing it from Dolphin (Plasma5's file manager).

If I plug in an encrypted external drive, it appears in the devices window, I click on it, enter the password and it opens. The external drive doesn't have a defined mount point, and gets mounted under /run/media/myname/ExtDrive. I've tried commenting out the line in fstab, hoping it would be treated the same way as an external drive, but it didn't make any difference. It still mounted, but only after supplying the root password as well.

But here's a thing that may be relevant: Even when the fstab line is active, it still mounts the drive under /run/media/myname/ rather than its designated mount point! I have no idea why. I'm assuming that the filesystem type should be ext4 (or whatever) in fstab, and not luks, or some derivation? I've not tried this before, so I'm guessing some stuff here!

I'll come back shortly and post an anonymised version of the fstab line, see if I've done everything right. I've never had a problem before adding drives or nfs shares.

--
Pete
 
Old 05-23-2022, 12:16 PM   #6
Markus Wiesner
Member
 
Registered: Mar 2016
Distribution: Slackware
Posts: 146

Rep: Reputation: 237Reputation: 237Reputation: 237
Quote:
Originally Posted by rknichols View Post
Note: You really should include the "nosuid" and "nodev" options also. Think about the security implications of a user-mounted filesystem that might include suid and device inodes.
That's already the default, see man mount:

Code:
       owner
           Allow an ordinary user to mount the filesystem if that user
           is the owner of the device. This option implies the
           options nosuid and nodev (unless overridden by subsequent
           options, as in the option line owner,dev,suid).
[..]
       users
           Allow any user to mount and to unmount the filesystem, even
           when some other ordinary user mounted it. This option
           implies the options noexec, nosuid, and nodev (unless
           overridden by subsequent options, as in the option line
           users,exec,dev,suid).
 
1 members found this post helpful.
Old 05-23-2022, 12:33 PM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by pchristy View Post
I'm actually doing it from Dolphin (Plasma5's file manager).
I think you'll find that mounting from the command line works just fine. For a GUI file manager, all bets are off!
 
Old 05-23-2022, 01:04 PM   #8
pchristy
Senior Member
 
Registered: Oct 2012
Location: South Devon, UK
Distribution: Slackware
Posts: 1,119

Original Poster
Rep: Reputation: Disabled
Here's the relevant line from fstab:
Code:
/dev/sdaX        /mnt/hd          ext4        rw,noauto,owner     1   2
Despite the /mnt/hd directory command, it still gets mounted to /run/media/myname which makes me think that the fstab entry is being ignored. But why?

I am the "owner" of the partition I'm trying to mount. I'm not sure if it should be necessary or not, but I'm in the sys and disk groups. I can't think of any other reason why this doesn't work!

All ideas welcome!

--
Pete
 
Old 05-23-2022, 03:19 PM   #9
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,785

Rep: Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463
Quote:
Originally Posted by pchristy View Post
I'm not sure if it should be necessary or not, but I'm in the sys and disk groups.
No user should be in the disk group. It means you can read, write and destroy anything on the disk.
 
2 members found this post helpful.
Old 05-23-2022, 03:47 PM   #10
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Quote:
Originally Posted by pchristy View Post
If I plug a Luks encrypted external drive into my laptop, I enter the password and it opens. If I mount an internal Luks encrypted partition (noauto in fstab), as well as the password, it asks for the root password as well, despite the fact that I am the "owner" of the partition.

Why? And How do I stop it?

--
Pete
I'm not 100% sure, because I just returned to Slackware, but I've been using KDE for a long time, and in other distroes it mounts in /var/run/media with owner/group as root. So you can't access the disk, even if everthing in there is owned by user user. I'm fairly sure polkit is the one causing the password prompt, and fairly sure polkit allows you to "escalate" you to do something you wouldn't normally be allowed to do.

You can write a polkit rule to get rid of the password prompt. Should be in /usr/share/polkit/rules.d.

Personally I didn't use an external disk much, so I would go into the folder and change the owner/group, and as far as I remember you only need to do that once for each disk. But that's only advisable if the disk is only for user owned stuff anyways.

Last edited by zeebra; 05-23-2022 at 03:48 PM.
 
1 members found this post helpful.
Old 05-23-2022, 04:08 PM   #11
pchristy
Senior Member
 
Registered: Oct 2012
Location: South Devon, UK
Distribution: Slackware
Posts: 1,119

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Petri Kaukasoina View Post
No user should be in the disk group. It means you can read, write and destroy anything on the disk.
Noted. Thanks!

Quote:
Originally Posted by zeebra
'm not 100% sure, because I just returned to Slackware, but I've been using KDE for a long time, and in other distroes it mounts in /var/run/media with owner/group as root. So you can't access the disk, even if everthing in there is owned by user user. I'm fairly sure polkit is the one causing the password prompt, and fairly sure polkit allows you to "escalate" you to do something you wouldn't normally be allowed to do.

You can write a polkit rule to get rid of the password prompt. Should be in /usr/share/polkit/rules.d.
There seems to be a rule in there already that allows those in the "plugdev" group to mount and unmount things. But perhaps that only applies to plugable devices? It would explain why I don't get asked for root password when I plug in an external drive. I think you are on to something here.

I need to figure out the syntax and apply it to a non-plugable partition, and looking at it now, it that looks above my pay-grade!

I'll have a look in the morning when I'm not half-asleep!

Many thanks for the suggestions!

--
Pete
 
Old 05-23-2022, 04:43 PM   #12
pchristy
Senior Member
 
Registered: Oct 2012
Location: South Devon, UK
Distribution: Slackware
Posts: 1,119

Original Poster
Rep: Reputation: Disabled
I found a suggestion over on the archlinux board from someone who was having a similar issue. The suggestion there was to create a "10-mount-system.rules" file containing:
Code:
polkit.addRule(function(action, subject) {
     if (action.id == "org.freedesktop.udisks2.filesystem-mount-system" &&
          subject.active &&
          subject.isInGroup("storage")) {
          return polkit.Result.YES;
     }
});
Tried it, but it didn't work. I'm not familiar with polkit rules, but from what I've read, it sounds like the right approach.

Any hints welcome!

--
Pete
 
Old 05-24-2022, 03:15 AM   #13
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Quote:
Originally Posted by pchristy View Post
I found a suggestion over on the archlinux board from someone who was having a similar issue. The suggestion there was to create a "10-mount-system.rules" file containing:
Code:
polkit.addRule(function(action, subject) {
     if (action.id == "org.freedesktop.udisks2.filesystem-mount-system" &&
          subject.active &&
          subject.isInGroup("storage")) {
          return polkit.Result.YES;
     }
});
Tried it, but it didn't work. I'm not familiar with polkit rules, but from what I've read, it sounds like the right approach.

Any hints welcome!

--
Pete
That doesn't change anything, because that's basically the same as the (first part of) plugdev rule you mentioned above, except the group under that rule in this case has another name. So in a way the group is irrelevant, if you read the rules backward (which makes it easier to understand). It's the long org.xy.z thing that actually matters.

Here is alot of information: (but the basics about how it works are at the start)
https://develop.kde.org/docs/use/kauth/
https://develop.kde.org/docs/use/kauth/using_kauth/

To list the actions you can use:
Code:
pkaction
And to get information on what they do:
Code:
pkaction --action-id org.freedesktop.udisks2.filesystem-mount-system --verbose
I would guess one of these could be relevant:
org.freedesktop.udisks2.filesystem-mount
org.freedesktop.udisks2.open-device
org.freedesktop.udisks2.open-device-system

So, you could test and make the same rule as above, but you can use a group like myusergroup or any group you're a member of by now.

But I'm no expert on polkit, and like I said I don't really use external disks very much, and when I do I don't use polkit for it.

Last edited by zeebra; 05-24-2022 at 04:25 AM.
 
1 members found this post helpful.
Old 05-24-2022, 04:23 AM   #14
pchristy
Senior Member
 
Registered: Oct 2012
Location: South Devon, UK
Distribution: Slackware
Posts: 1,119

Original Poster
Rep: Reputation: Disabled
Thanks for the info! I'll have a read of that documentation - thanks for the pointer! I'll also checkout that pkaction command.

I'm beginning to wonder if I'm looking at this from the wrong angle. The actual message that comes up is "Authentication is required to unlock the encrypted device", and I've just noticed that it is generated by "PolicyKit1 Kde Agent" (this latter only appears in the small box on the panel at the bottom of the screen, not the main window). To me, that is pointing to the pkaction command you mention. I'll go and have a closer look at this.

What is puzzling me is why I don't need the root password to mount external encrypted disks, but I do for internal ones.

<sigh!> Whoever said computers were logical!

UPDATE: All those polkit scripts seem to refer to removable devices, which aren't the problem. I'm beginning to think I'm asking the impossible! Google shows quite a few similar questions, but no solutions!

--
Pete

Last edited by pchristy; 05-24-2022 at 04:33 AM. Reason: UPDATE
 
Old 05-24-2022, 04:31 AM   #15
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Quote:
Originally Posted by pchristy View Post
The actual message that comes up is "Authentication is required to unlock the encrypted device",

<sigh!> Whoever said computers were logical!
It's only as logic as those who implement the logic
Sorry, I put the wrong link in there:
https://develop.kde.org/docs/use/kauth/

Anyways, looking at that message, I guess it would be one of these 2:
org.freedesktop.udisks2.encrypted-unlock
org.freedesktop.udisks2.encrypted-unlock-system

Quote:
Originally Posted by pchristy View Post
UPDATE: All those polkit scripts seem to refer to removable devices, which aren't the problem. I'm beginning to think I'm asking the impossible! Google shows quite a few similar questions, but no solutions!
Well, since it does that, it should mean that there is an action for that purpose. The purpose of making a polkit rule like above with "YES", is that it automatically grants the request (without password) to people in that particular group it refers to.

But I have no idea what action it is, sorry.

Btw. If you make/test rules, put a high leading number in front, so it's loaded last. Like 90-myrule.rules

Last edited by zeebra; 05-24-2022 at 05:04 AM.
 
3 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Uefi and full disk encryption with lvm on luks with luks keyfile lancsuk Slackware 2 04-02-2021 02:43 PM
How to have luks encryption with keyfile OR passphrase (efi full disk encryption including boot)? byroncollege Linux - Security 2 03-30-2017 07:45 AM
LUKS on RAID or RAID on LUKS? retch Linux - Server 3 05-05-2010 01:57 PM
luks encryption, swap and hibernate BCarey Slackware 6 04-15-2008 05:48 PM
System encryption with dm-crypt and luks? Zmyrgel Slackware 9 09-02-2006 10:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration