Let scdaemon exit when no reader is available

NIIBE Yutaka gniibe at fsij.org
Thu Nov 22 03:08:47 CET 2012


Thank you for your reply.

Let me iterate the problem again.  After removal of a card reader,
scdaemon keeps opening card reader (again and again) which may cause
many error logs.

On 2012-11-21 at 10:12 +0100, Werner Koch wrote:
> On Wed, 21 Nov 2012 02:37, gniibe at fsij.org said:
> Thus your patch is a hack which works because gpg-agent will start
> scdaemon anyway if it requires it.

Well, it would be a hack or a dirty patch from the viewpoint of
"smartcard daemon".  Generally speaking, daemon should be independent
and responsible for all cases, and should never exit.  It is also true
that the patch works well because gpg-agent watches scdaemon's death
by the function agent_scd_check_aliveness, and handles it gracefully.

However, please note that after a card reader removal (reader_disabled
== 1), scdaemon will exit at the end of next session of gpg-agent, in
the function scd_command_handler, anyway.  From this viewpoint, the
patch could be considered a fix for consistent handling of
reader_disabled state.

> We can give it a try for 2.1.  Can you please add a comment in the code,
> explaining why it is useful to exit.

Umm... Adding another "exit" to a daemon sounds guilty...

OK, I'll try another approach:

  (1) (As original proposal) Fix the function
      update_reader_status_file not to call get_current_reader.  This
      fix has a impact that the insertion of a card reader will be
      detected only when user tries to access his card.

  (2) Fix not to give up in the case of reader_disabled == 1 in the
      function scd_command_handler.  (In the first place.)

  (3) (Optionally, or in future) Fix the main routine of scdaemon to
      enable the timer only when there is a card reader available.

With this approach, scdaemon will be more robust and it will have same
good result as "adding exit to scdaemon" patch (mostly).
-- 





More information about the Gnupg-devel mailing list