Re: How to find out which process is accessing the card?

Ludovic Rousseau <[email protected]> Thu, 28 Sep 2017 14:45:42 +0200
Newsgroups gmane.comp.lib.muscle
Message-ID <CAGstE8C_Bp_WZowT_nvQD91G4aAKd+_OrCkuGk2_uwniSwksrw@mail.gmail.com>
--===============7272651779614181239==
Content-Type: multipart/alternative; boundary="94eb2c11151a2d39ef055a3f4a6c"

--94eb2c11151a2d39ef055a3f4a6c
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

2017-09-27 21:58 GMT+02:00 Franti=C5=A1ek =C5=98ez=C3=A1=C4=8D <frantisek.r=
[email protected]>:

> Hi,
>

Hello,


>
> I'm using smart card for almost everything in my daily work, but I have a
> problem which drives me crazy. I'm using YubiKey in two scenarios: pkcs11
> based PAM and SSH authentication and also as a GPG=E2=80=8E smart card. I
> understand that accesing one card via pkcs11 and scdaemon in turns is
> troubling, because GPG tends to lock the access to the card for itself fu=
ll
> time, but I can handle that by manualy terminating scdaemon.
>
> But I have also come across the opossite situation many times - something
> locks access to the card via pkcs11 which prevents the access from scdaem=
on
> with the dreaded "PC/SC OPEN failed: sharing violation". The problem is
> that I don't know which process is using the card so I don't know how to
> deal with it except for restarting the whole pcscd. Also this problem see=
ms
> to happen randomly so I don't have any clue if it's pam module or ssh age=
nt
> or something else and it also randomly disappears. If I know what is usin=
g
> the card, I could try to configure it better or deal with it more gently.
>
> And that's my question - how to find out what is currently
> accessing/locking the card at a given time? I tried to figure it out
> myself, but after I have seen this schema https://blog.flameeyes.
> eu/2011/04/additional-notes-about-the-smartcard-components-diagram/ I
> realized that I don't even know at which level I should look for that
> information.
>

I just wrote a script for you.
https://github.com/LudovicRousseau/contrib/blob/master/list_pcsc_applicatio=
ns.sh

Please tell me if it works for you or if you need something different.

Bye

--=20
 Dr. Ludovic Rousseau

--94eb2c11151a2d39ef055a3f4a6c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">2017=
-09-27 21:58 GMT+02:00 Franti=C5=A1ek =C5=98ez=C3=A1=C4=8D <span dir=3D"ltr=
">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">fr=
[email protected]</a>&gt;</span>:<br><blockquote class=3D"gmail_q=
uote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,2=
04);padding-left:1ex"><div dir=3D"ltr">Hi,</div></blockquote><div><br></div=
><div>Hello,<br>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef=
t:1ex"><div dir=3D"ltr"><div><br>I&#39;m using smart card for almost everyt=
hing in my daily work, but I have a problem which drives me crazy. I&#39;m =
using YubiKey in two scenarios: pkcs11 based PAM and SSH authentication and=
 also as a GPG=E2=80=8E smart card. I understand that accesing one card via=
 pkcs11 and scdaemon in turns is troubling, because GPG tends to lock the a=
ccess to the card for itself full time, but I can handle that by manualy te=
rminating scdaemon.</div><div><br></div><div>But I have also come across th=
e opossite situation many times - something locks access to the card via pk=
cs11 which prevents the access from scdaemon with the dreaded &quot;PC/SC O=
PEN failed: sharing violation&quot;. The problem is that I don&#39;t know w=
hich process is using the card so I don&#39;t know how to deal with it exce=
pt for restarting the whole pcscd. Also this problem seems to happen random=
ly so I don&#39;t have any clue if it&#39;s pam module or ssh agent or some=
thing else and it also randomly disappears. If I know what is using the car=
d, I could try to configure it better or deal with it more gently.</div><di=
v><br></div><div>And that&#39;s my question - how to find out what is curre=
ntly accessing/locking the card at a given time? I tried to figure it out m=
yself, but after I have seen this schema=C2=A0<a href=3D"https://blog.flame=
eyes.eu/2011/04/additional-notes-about-the-smartcard-components-diagram/" t=
arget=3D"_blank">https://blog.flameeyes.<wbr>eu/2011/04/additional-notes-<w=
br>about-the-smartcard-<wbr>components-diagram/</a> I realized that I don&#=
39;t even know at which level I should look for that information.<br></div>=
</div></blockquote></div><br></div><div class=3D"gmail_extra">I just wrote =
a script for you.<br><a href=3D"https://github.com/LudovicRousseau/contrib/=
blob/master/list_pcsc_applications.sh">https://github.com/LudovicRousseau/c=
ontrib/blob/master/list_pcsc_applications.sh</a><br></div><div class=3D"gma=
il_extra"><br></div><div class=3D"gmail_extra">Please tell me if it works f=
or you or if you need something different.<br><br></div><div class=3D"gmail=
_extra">Bye<br clear=3D"all"></div><div class=3D"gmail_extra"><br>-- <br><d=
iv class=3D"gmail_signature">=C2=A0Dr. Ludovic Rousseau</div>
</div></div>

--94eb2c11151a2d39ef055a3f4a6c--


--===============7272651779614181239==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Pcsclite-muscle mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
--===============7272651779614181239==--