Hello Ludovic,

On Fri, 3 Apr 2020 15:37:20 +0200 Ludovic Rousseau <ludovic.rouss...@free.fr> 
wrote:
> Hello Paride,
> 
> Le 03/04/2020 à 13:20, Paride Legovini a écrit :
> > Hi,
> > 
> > I'm also hitting this issue, but after trying a few things I'm not
> > convinced it is strictly a "resume after suspend" problem. But
> > let's proceed with order.
> > 
> > I normally keep a OpenPGP smartcard in my laptop's smartcard reader and
> > I use it via scdaemon with disable-ccid. Sometimes when I suspend and
> > resume my laptop I lose access to the smartcard: gnupg/scdaemon can't
> > find it anymore. Restarting pcscd helps (systemctl restart pcscd) often
> > but *not always* helps.
> > 
> > I tried to collect logs running pcscd in foreground in a shell, but
> > guess what, it *never* happens if I run it like this. The problem seems
> > to happen only when pcscd is started by systemd, and I found out that I
> > can reproduce it by restarting pcscd several time with systemctl. So I
> > modified pcscd.service like this:
> > 
> > 
> > [Service]
> > Environment=LIBCCID_ifdLogLevel=0x000F
> > ExecStart=/usr/sbin/pcscd --foreground --debug --apdu
> > #ExecStart=/usr/sbin/pcscd --foreground --auto-exit
> > #ExecReload=/usr/sbin/pcscd --hotplug
> > 
> > 
> > in order to collect the relevant logs. Here they are.
> 
> Thanks a lot for your tests and logs.

> When it fails:
> - is the socket /var/run/pcscd/pcscd.comm still present?

This was a hint in the right direction and I think it makes most of the
logs I collected useless. Apparently when the problem occurs the
/var/run/pcscd/pcscd.comm socket is not there anymore, but systemd still
have a file descriptor open for it, as I found out using lsof:

COMMAND  PID  TID TASKCMD  USER  FD   TYPE             DEVICE  SIZE/OFF     
NODE NAME
systemd    1               root  45u  unix 0xffffa066a5154400       0t0  
3172053 /run/pcscd/pcscd.comm type=STREAM

I think the systemd socket unit (pcscd.socket) does not recreate the
socket because of this, and passes a "dead" file descriptor to pcscd.
What exactly deletes the pcscd.comm socket is not clear to me. Now after
fiddling with pcscd I don't think I have clean logs to provide, I prefer
to wait for the problem to happen again and then check if anything
relevant is logged. I did try to suspend/resume a few times but but I
didn't manage to reproduce the issue. But maybe you know what could be
deleting the socket.

> - what do you get when you run pcsc_scan? (from the pcsc-tools package)

It fails with:

SCardEstablishContext: Service not available.

as it can't find the socket.

> PS: maybe you should change your smart card password if it starts with "c".

That was already a temporary password as I did fear the debugging logs might
leak it, but thanks for the warning :) Adding a note on the website where 
the instructions on how to collect logs are given might be a good idea.

Thank again,

Paride

Reply via email to