Bug 1480793

Summary: ecryptfs-mount-private fails to mount if passphrase is not on root's keyring
Product: [Fedora] Fedora Reporter: Andre Costa <andre.ocosta>
Component: ecryptfs-utilsAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: csdietz123, esandeen, mhlavink, projects.rg, ray, sebp
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-07-19 21:32:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andre Costa 2017-08-11 21:53:34 UTC
Description of problem:
I can't get ecryptfs-mount-private to work on F26 (it worked on F25). After a lot of testing (and help from peers on ask.fedoraproject.org [*]), I figured out a pattern. Actually, there seems to be more than one bug involved, but I'll concentrate on the keyring issue.

[*] https://ask.fedoraproject.org/en/question/109144/ecryptfs-mount-private-not-working-on-f26/?answer=109452#post-id-109452


Version-Release number of selected component (if applicable):
ecryptfs-utils-111-2.fc25.x86_64


How reproducible:
Always.

Steps to Reproduce:
1. run ecryptfs-mount-private (after configuring it with ecryptfs-setup-private --no-fnek --noautomount) as a regular user
2.
3.

Actual results:
Enter your login passphrase:
Inserted auth tok with sig [XXX] into the user session keyring
mount: No such file or directory

Expected results:
~/.Private should be properly mounted on ~/Private

Additional info:
If I add mount passphrase signature on root's keyring, it works as expected:
~ sudo ecryptfs-add-passphrase
[sudo] password for costa: 
Passphrase: 
Inserted auth tok with sig [XXX] into the user session keyring
~ ecryptfs-mount-private 
Enter your login passphrase:
Inserted auth tok with sig [XXX] into the user session keyring
# mount worked

If I remove the key, it starts failing again:

~ sudo keyctl list @u
1 key in keyring:
438925633: --alswrv     0     0 user: XXX
~ sudo keyctl unlink 438925633 @u
~ sudo keyctl list @u
keyring is empty
~ ecryptfs-mount-private 
Enter your login passphrase:
Inserted auth tok with sig [XXX] into the user session keyring
mount: No such file or directory

The other issue is that both ecryptfs-mount-private and ecryptfs-umount-private increment/decrement /dev/shm/ecryptfs-$USER-Private even if they fail. I will file a separate issue for this.

Comment 1 Andre Costa 2017-08-11 22:05:52 UTC
Filed bug #1480795

Comment 2 Michal Hlavinka 2017-08-14 12:32:11 UTC
Do you have something "different" on your machine? I'm not able to reproduce this.

Fresh new virtual machine with Fedora 26, new user "qemuser", added to group ecryptfs


[qemuser@f26 ~]$ ecryptfs-setup-private --no-fnek --noautomount
Enter your login passphrase [qemuser]: 
Enter your mount passphrase [leave blank to generate one]: 

************************************************************************
YOU SHOULD RECORD YOUR MOUNT PASSPHRASE AND STORE IT IN A SAFE LOCATION.
  ecryptfs-unwrap-passphrase ~/.ecryptfs/wrapped-passphrase
THIS WILL BE REQUIRED IF YOU NEED TO RECOVER YOUR DATA AT A LATER TIME.
************************************************************************

INFO: /home/qemuser/Private will not be mounted on login
/usr/sbin/restorecon
/usr/sbin/restorecon

Done configuring.

Testing mount/write/umount/read...
Inserted auth tok with sig [ad1cef28d3a3ba22] into the user session keyring
Inserted auth tok with sig [ad1cef28d3a3ba22] into the user session keyring
Testing succeeded.

Logout, and log back in to begin using your encrypted directory.


[qemuser@f26 ~]$ ecryptfs-mount-private
Enter your login passphrase:
Inserted auth tok with sig [ad1cef28d3a3ba22] into the user session keyring


[qemuser@f26 ~]$ mount | grep ecryptfs
/home/qemuser/.Private on /home/qemuser/Private type ecryptfs (rw,nosuid,nodev,relatime,ecryptfs_sig=ad1cef28d3a3ba22,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs)


Even SElinux is enabled in enforcing mode.


------
I CAN reproduce this, when I become qemuser from root with "su qemuser", in that case it will fail the same way as you've described. But it's to be expected, as after "su qemuser" environment was not (re)set correctly for qemuser and you are still partially original user (root in this case).

Comment 3 Andre Costa 2017-08-14 23:37:54 UTC
As far as I am concerned, there is nothing different with this machine -- but there could be something different with my user.

I also tried creating a new user on my machine, and did the same process of creating ~/.Private for him. To my surprise, it worked out of the box. The only difference I can see is that my user has sudo rights (it has been created as a "Administrator"), while this test user I created was a regular account.

The upgrade to F26 has followed the same procedure I've been using for quite some time already: I preserve /home (which is on a separate partition), and reformat / and swap. I'm using ext4 on LVM.

What kind of info can I provide you to help you narrow down the cause of the problem? Any SELinux data? LVM?

Comment 4 Sebastian Pölsterl 2017-08-31 20:08:49 UTC
I'm experiencing the same problem.

It seems to be related to an issue in systemd: https://github.com/systemd/systemd/pull/6286 (via https://bugs.archlinux.org/task/54670).

Comment 5 Sebastian Pölsterl 2017-10-09 20:16:36 UTC
The fix from the systemd issue above (https://github.com/systemd/systemd/pull/6342) can be applied manually by manually linking the user and session keyring via

keyctl link @u @s

before running ecryptfs-mount-private

Comment 6 Fedora End Of Life 2018-05-03 08:19:40 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 7 Fedora End Of Life 2018-05-29 11:45:21 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 8 Raphael Groner 2018-06-23 12:58:29 UTC
Maybe dup of bug #1538760?
Reporter, can you still reproduce in a current branch?

Comment 9 Raphael Groner 2018-07-19 21:32:58 UTC
No response so far from reporter. Closing again.