Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: "Nick Guenther" <nick.guenther@polymtl.ca>
To: linux-cifs@vger.kernel.org
Subject: Re: pam_cifscreds, tmux and session keyrings
Date: Fri, 29 Jul 2022 02:47:24 +0000	[thread overview]
Message-ID: <0371d16e831be9cd9595c443d142e5fc@polymtl.ca> (raw)
In-Reply-To: <705265ea-37a3-6029-362a-572bbaab6639@gmail.com>

July 22, 2022 2:38 PM, "Mantas Mikulėnas" <grawity@gmail.com> wrote:

> On 2022-07-21 23:45, Nick Guenther wrote:
> 
>> [...]
>> I see in this old thread https://www.spinics.net/lists/linux-cifs/msg18249.html that you actually
>> want to go the _other_ direction, and isolate your sessions even more:
>> multiuser SMB connections should also be initiated per session, same like the
>> keyring. Currently the cifs SMB connections are accessible also from other all
>> sessions.
>>> That needs to be implemented indeed.
>> 
>> but that doesn't sound like it would make my users happy. In their perspective, tmux should be the
>> same environment as ssh or as the GUI, just more persistent. And I tend to agree.
>> Anyway, I hope this isn't too intricate or confusing for you. I would really appreciate a second
>> opinion, and maybe a consideration of that patch, if that patch is actually the right answer.
> 
> As another user, I'd expect the keyring search to be done recursively -- start from the session
> keyring as now, but follow the link into the user keyring, which is usually present (and isn't that
> its whole purpose?)
> 
> Then pam_cifscreds could be told which one to insert keys to, allowing it to be used both ways
> depending on needs -- just like how Kerberos or AFS can also have either isolated credentials or
> user-wide ones.



I've figured out a workaround, but I'm unsure about it and I could really use some advice from people with more insight.


I said before that my servers (and yours too) have

# cat /etc/pam.d/sshd | grep keyinit
session    optional     pam_keyinit.so revoke force

And the problem shows up when I detach tmux, **log out**, log back in and reattach tmux; then I see


p115628@davis:~$ keyctl list @s
keyctl_read_alloc: Key has been revoked

The word 'revoked' was the obvious clue I: just to remove the 'revoke' option and the problem goes away:

# cat /etc/pam.d/sshd | grep keyinit
session    optional     pam_keyinit.so force


This keeps the session-keyring(7) working even after reattaching. Because it's the **log out** that is disabling the keyring; per pam_keyinit(8) [1]:

>   revoke
>           Causes the session keyring of the invoking process to be revoked when the invoking
>           process exits if the session keyring was created for this process in the first place.


This change seems to have solved the immediate complaints from my users. But I don't like overriding the default like this; I assume there's a series of good reasons for using 'revoke' that I don't understand.

Would there be interest in switching to KEY_SPEC_USER_KEYRING? Would it be a good idea? Can I assume the kernel CIFS code would need a matching change?


[1] https://manpages.ubuntu.com/manpages/focal/man8/pam_keyinit.8.html

  reply	other threads:[~2022-07-29  2:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21 20:45 pam_cifscreds, tmux and session keyrings Nick Guenther
2022-07-22 18:38 ` Mantas Mikulėnas
2022-07-29  2:47   ` Nick Guenther [this message]
2022-08-01  4:10     ` Steve French
2022-08-03 20:29       ` [PATCH] " Nick Guenther
2022-08-16 19:14         ` Nick Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0371d16e831be9cd9595c443d142e5fc@polymtl.ca \
    --to=nick.guenther@polymtl.ca \
    --cc=linux-cifs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox