[PATCH] Status output for "no card available"

Werner Koch wk at gnupg.org
Mon Jun 6 16:29:02 CEST 2005


On Sat, 04 Jun 2005 17:21:16 +0200, Patrick Brunschwig said:

> Here is a small patch to get parseable status output in case accessing a
> smartcard fails. It the status does not distinguish if the card reader
> is not attached or just the card is missing.

I changed it to output  

  $ gpg --card-status --status-fd 2 --batch --no-use-agent
  gpg: pcsc_establish_context failed: no service (0x8010001d)
  [GNUPG:] CARDCTRL 5
  gpg: card reader not available
  gpg: OpenPGP card not available: general error
  
with no reader attached and to 

  gpg: apdu_send_simple(0) failed: no card
  [GNUPG:] CARDCTRL 4
  gpg: selecting openpgp failed: no card
  gpg: OpenPGP card not available: general error
  
if a reader is attached but no card inserted.

    CARDCTRL <what> [<serialno>]
        This is used to control smartcard operations.
        Defined values for WHAT are:
           1 = Request insertion of a card.  Serialnumber may be given
               to request a specific card.
           2 = Request removal of a card.
           3 = Card with serialnumber detected
           4 = No card available.
           5 = No card reader available


diff -u -p -r1.33 cardglue.c
--- g10/cardglue.c      31 May 2005 10:11:01 -0000      1.33
+++ g10/cardglue.c      6 Jun 2005 14:45:57 -0000
@@ -412,6 +412,7 @@ open_card (void)
       slot = apdu_open_reader (default_reader_port);
       if (slot == -1)
         {
+          write_status_text (STATUS_CARDCTRL, "5");
           log_error ("card reader not available\n");
           return NULL;
         }


Shalom-Salam,

   Werner




More information about the Gnupg-devel mailing list