when keyring returns ENOENT, treat it as ENOKEY#94
Conversation
|
I think this makes sense. I'm still a bit unsure why this sometimes return Or |
|
Here is the strace output. You can see how |
|
Mhm actually it seems to be expected that restarting ssh-tpm-agent resets the pin. So I think with this patch everything seems to work? |
|
Yes, killing the process should nuke the underlying process keyring we allocate for the cache. I suspect there is nothing wrong with the patch, I'm just confused why ENOENT are sometimes encountered. |
|
It's not sometimes but always for me. |
|
I'm thinking generally. Are you running a hardened kernel setup or a weird thing with nixos? The issue has not been reported previously so i'm a bit at a loss. |
|
Pretty boring kernel with few patches: Here is the kernel config: https://gist.github.com/Mic92/1f2a7084be6278f38a64db31a5413b81 |
|
Interesting: ~/git/nixpkgs main* Maybe something is wrong here. |
|
The keyring subsystem is a bit interesting as they do some implicit calls to binaries when dealing with keys. It's a bit opaque to me how this exactly works. |
Seems suspicious to me at least. |
|
After installing globally keyctl in NixOS, it works. Added some better error logging for users. |
When keyctl is not available, the kernel keyring may return ENOENT when trying to load a key. This commit adds a warning to inform the user that the keyutils package is required for caching keys.
Then maybe that should be fixed in the test suite for RE the patch. |
|
Maybe we should in NixOS just have keyutils always installed by default, because builds like this would fail otherwise. At least on builders that need to build software. |
|
Regardless, I'm happy we solved this as we should handle this gracefully in |
Would love to implement that but don't know how you exactly envision that to look like. My attempt doesn't really seem to improve. |
|
That's fine. I'll merge this as-is and clean it up if I feel like it :) thanks for the patch! |
|
switch/case seemed cleaner to me. |
I get this error on this kernel:
Jun 02 15:26:27 turingmachine systemd[2442]: Started SSH Agent.
Jun 02 15:26:27 turingmachine ssh-tpm-agent[110960]: time=2025-06-02T15:26:27.740+02:00 level=INFO msg="Activated agent by socket"
Jun 02 15:27:00 turingmachine ssh-tpm-agent[110960]: time=2025-06-02T15:27:00.135+02:00 level=INFO msg="agent 13: failed getting pin for key: no such file or directory"
$ uname -a
Linux turingmachine 6.14.8 #1-NixOS SMP PREEMPT_DYNAMIC Thu May 22 12:31:58 UTC 2025 x86_64 GNU/Linux
It overall seems that caching doesn't seem to work for me with the kernel, but it's better to be able to type in the password instead of breaking ssh-agent-tpm
Open for better suggestions, but I need to have something working now, so I will use this patch until than.