-
Notifications
You must be signed in to change notification settings - Fork 256
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
P11_CHILD: Make p11_child iterate over all slots #7817
base: master
Are you sure you want to change the base?
Conversation
d61a39d
to
86cf46e
Compare
@alexey-tikhonov I might be able to manually test with my card reader and a yubikey but, I don't have two separate readers and cards. And our test systems don't have multiple readers with cards to test this type of scenario. I'm looking into our virtual testing solutions to see if one will work for this. |
Maybe a combination of physical + virtual readers..? |
86cf46e
to
fea68ed
Compare
@georgij-sudo, could you please also rebase on the latest 'master'? |
That may work. I'll look into that today. |
fea68ed
to
b348f2d
Compare
b348f2d
to
7647c65
Compare
Looks like it's working and I think I'm able to easily reproduce the issue. Let me confirm this is indeed the case: On a Fedora 41 system I have 2 smart cards--1 physical and 1 virtual.
Here are the sssd and card configurations:
Now if I try to authenticate with the card mapped to localuser2, I see a failure:
If I stop the virtual card, authentication works:
Let me know if I missed a step to properly reproduce this. Otherwise, I think I should be able to verify the fix with my current setup. |
huh... but why does it even try to use "cert/key for localuser1"? @sumit-bose, is this currently expected?
Could you please try with a copr build from this PR? |
I just caught that when I was trying to re-run this to grab logs. I used the wrong PIN which explains the failure. I'm not sure about what happens when I use the correct PIN though because I didn't expect it to authenticate. Here's what I'm seeing now:
Above, sssd seems to have authenticated the user regardless of which card is used.
Trying with the copr build, I see neither card/cert working. And after several tries with the correct PINs, I now see this:
So the second card listed (the virtual one with |
On my Ubuntu everything is works on this commmit
$ p11tool --provider /opt/aktivco/rtlogon/lib/librtpkcs11ecp.so --list-token-urls
pkcs11:model=Rutoken%20ECP;manufacturer=Aktiv%20Co.;serial=3ac65cdd;token=Rutoken%20label
pkcs11:model=Rutoken%20ECP;manufacturer=Aktiv%20Co.;serial=3ac67ae9;token=kek3242 $ /usr/libexec/sssd/p11_child --pre --ca_db /etc/rtlogon/ca.pem
0
R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utR/Uc3B4dv I can auth via both certificates: $ sudo login [email protected]
PIN for Rutoken label:
...
[email protected]@ubuntu:~$ klist
Ticket cache: KEYRING:persistent:943803168:krb_ccache_6L559SB
Default principal: [email protected]
Valid starting Expires Service principal
02/04/2025 11:50:22 02/05/2025 11:12:43 krbtgt/[email protected] $ sudo login [email protected]
PIN for kek3242
...
[email protected]@ubuntu:~$ klist
Ticket cache: KEYRING:persistent:943803169:krb_ccache_d2vuFZm
Default principal: [email protected]
Valid starting Expires Service principal
02/04/2025 11:59:26 02/05/2025 11:47:01 krbtgt/[email protected] Everything is ok if I have 2 certs on different smart cards for the same user: $ sudo login [email protected]
Please select a certificate by typing the corresponding number
[1]:
b7fc45b4c04e3da3
CN=petya_fedora1,O=RTKN.TEST
[2]:
ce9ee843a6a61006
CN=petya_fedora1,O=RTKN.TEST
1
Certificate ‘B7FC45B4C04E3DA3’ selected
PIN for kek3242:
...
[email protected]@ubuntu:~$ klist
Ticket cache: KEYRING:persistent:943803168:krb_ccache_6L559SB
Default principal: [email protected]
Valid starting Expires Service principal
02/04/2025 12:12:03 02/05/2025 11:59:48 krbtgt/[email protected] $ sudo login [email protected]
Please select a certificate by typing the corresponding number
[1]:
b7fc45b4c04e3da3
CN=petya_fedora1,O=RTKN.TEST
[2]:
ce9ee843a6a61006
CN=petya_fedora1,O=RTKN.TEST
2
Certificate ‘CE9EE843A6A61006’ selected
PIN for Rutoken label:
...
[email protected]@ubuntu:~$ klist
Ticket cache: KEYRING:persistent:943803168:krb_ccache_6L559SB
Default principal: [email protected]
Valid starting Expires Service principal
02/04/2025 12:12:53 02/05/2025 11:18:57 krbtgt/[email protected] I tried to test it on Fedora, but I couldn't auth because a lot of problems. Even when only smart card was inserted and with sssd from repos. On Ubuntu I has sssd 2.9.5 and test it by replacing only p11_child executable. I tried to build and install the master, but service sssd doesn't starting after that |
I believe I found the issue with my previous testing. My certmap rule seems to be matching more because of the additional wildcard at the end of the CN in the maprule. Changing this does seem to get me closer to reproducing the issue. Now I'm seeing this:
Here's the sssd.conf now:
This is what I see in p11_child.log:
And I see this in sssd_pam.log:
After upgrading to the PR COPR build, it looks good when only 1 certificate is matched and that is the one mapped:
However, when you run with both cards, I see authentication failure in p11_child.log:
And I see "Bad item passed" in the sssd_pam.log:
|
May be there is some problems with scenario of local authentication and smart card visiable by opensc module. I will try to check it UPD:
I got a problem. During local auth p11_child is called with --auth flag. And it try to auth on both smart cards. During domain auth p11_child is called only with --pre flag. And authentication on token perform someone else (krb5-pkinit?) I think we have to add check choosen smart card for passed token_name and existing cert for passed key_id and label if p11_child run with |
In both cases - local and backend auth - 'p11_child' is first called in [pre-auth] mode to gather a list of available tokens.
Then 'sssd_be' applies mapping/matching rules and correctly identifies that "CERT:b8WUf/iAIP" maps to 'localuser2' Then it calls 'p11_child', this time to authenticate: sssd/src/responder/pam/pamsrv_cmd.c Line 1289 in 196ad92
-> sssd/src/responder/pam/pamsrv_cmd.c Line 1880 in 196ad92
-> sssd/src/responder/pam/pamsrv_p11.c Line 787 in 196ad92
Why both?
Correct (if backend is online, otherwise it can still fallback to local auth). |
I saw it in my logs. I added printing args into the log:
I had two cert on two different smart cards for the same account and I can't auth when both inserted. When I try to auth via one of this smart card -- p11_child can't auth fails on the first. When I try to auth via another smart card -- p11_child passes authentication on the first one, and fails on the second |
Resolves: #5905