Le 05/04/2020 à 16:40, Paride Legovini a écrit :
Hello Ludovic,

On Fri, 3 Apr 2020 15:37:20 +0200 Ludovic Rousseau <ludovic.rouss...@free.fr> 
wrote:

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.

pcscd can remove the /var/run/pcscd/pcscd.comm socket but only when NOT started 
by systemd. This is done on init and exit of pcscd.
When pcscd is started by systemd you have a log message like:
Apr 03 12:51:52 stramonio pcscd[98472]: 00000032 pcscdaemon.c:451:main() 
Started by systemd

Maybe, sometimes, pcscd does not detect it is started by systemd. But in this 
case the socket should be re-created by pcscd so that should not be the correct 
explanation.

Or maybe the problem is on the systemd side?

You can continue generating logs. They are a good indication of what is 
happening.
You can limit logs to the info level using --info instead of --debug. You can 
also remove the --apdu argument.

If I read correctly your previous message you have logs with:
- pcscd is started by systemd
- pcscd correctly indicates "Started by systemd"
- but the communication is broken (pcsc_scan fails) and I guess the file 
/var/run/pcscd/pcscd.comm is missing
- you stop pcscd: systemctl stop pcscd
- you start pcscd: systemctl start pcscd
- pcscd correctly indicates "Started by systemd"
- the communication is still broken and, I guess, the file 
/var/run/pcscd/pcscd.comm is still missing

To re-create the file /var/run/pcscd/pcscd.comm you need to use:
systemctl stop pcscd.socket
systemctl start pcscd.socket

See also 
https://ludovicrousseau.blogspot.com/2011/11/pcscd-auto-start-using-systemd.html

I still have no clue when and why the socket file is removed.

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.

Good point. Done.

Bye

--
Dr. Ludovic Rousseau

Reply via email to