aboutsummaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2005-02-24 21:40:48 +0000
committerWerner Koch <[email protected]>2005-02-24 21:40:48 +0000
commit1f1f28555a19f76a97824ad7e5a85228b1c16ea9 (patch)
tree4f72836c650fe9ba1b3c1451d420858641ac827d /scd
parent* gpg-agent.c (handle_connections): Need to check for events if (diff)
downloadgnupg-1f1f28555a19f76a97824ad7e5a85228b1c16ea9.tar.gz
gnupg-1f1f28555a19f76a97824ad7e5a85228b1c16ea9.zip
* call-scd.c (unescape_status_string): New. Actual a copy of
../g10/call-agent.c (card_getattr_cb, agent_card_getattr): New. * command-ssh.c (card_key_available): New. (ssh_handler_request_identities): First see whether a card key is available. * app.c (app_getattr): Return APPTYPE or SERIALNO type even if the application does dot support the getattr call. * app.c (select_application): Return an error code and the application context in an new arg. * command.c (open_card): Adjusted for that. Don't use the fallback if no card is present. Return an error if the card has been removed without a reset. (do_reset, cmd_serialno): Clear that error flag. (TEST_CARD_REMOVAL): New. Use it with all command handlers. (scd_update_reader_status_file): Set the error flag on all changes.
Diffstat (limited to 'scd')
-rw-r--r--scd/ChangeLog4
-rw-r--r--scd/app.c29
-rw-r--r--scd/command.c24
3 files changed, 49 insertions, 8 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog
index c78bd011f..dc394b677 100644
--- a/scd/ChangeLog
+++ b/scd/ChangeLog
@@ -1,5 +1,8 @@
2005-02-24 Werner Koch <[email protected]>
+ * app.c (app_getattr): Return APPTYPE or SERIALNO type even if the
+ application does dot support the getattr call.
+
* app-openpgp.c (get_one_do): Never try to get a non cacheable
object from the cache.
(get_one_do): Add new arg to return an error code. Changed all
@@ -13,6 +16,7 @@
been removed without a reset.
(do_reset, cmd_serialno): Clear that error flag.
(TEST_CARD_REMOVAL): New. Use it with all command handlers.
+ (scd_update_reader_status_file): Set the error flag on all changes.
* scdaemon.c (ticker_thread): Termintate if a shutdown is pending.
diff --git a/scd/app.c b/scd/app.c
index 857f9e10b..384ee2143 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -305,6 +305,35 @@ app_getattr (APP app, CTRL ctrl, const char *name)
return gpg_error (GPG_ERR_INV_VALUE);
if (!app->initialized)
return gpg_error (GPG_ERR_CARD_NOT_INITIALIZED);
+
+ if (app->apptype && name && !strcmp (name, "APPTYPE"))
+ {
+ send_status_info (ctrl, "APPTYPE",
+ app->apptype, strlen (app->apptype), NULL, 0);
+ return 0;
+ }
+ if (name && !strcmp (name, "SERIALNO"))
+ {
+ char *serial_and_stamp;
+ char *serial;
+ time_t stamp;
+ int rc;
+
+ rc = app_get_serial_and_stamp (app, &serial, &stamp);
+ if (rc)
+ return rc;
+ rc = asprintf (&serial_and_stamp, "%s %lu",
+ serial, (unsigned long)stamp);
+ rc = (rc < 0)? gpg_error_from_errno (errno) : 0;
+ xfree (serial);
+ if (rc)
+ return rc;
+ send_status_info (ctrl, "SERIALNO",
+ serial_and_stamp, strlen (serial_and_stamp), NULL, 0);
+ free (serial_and_stamp);
+ return 0;
+ }
+
if (!app->fnc.getattr)
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
return app->fnc.getattr (app, ctrl, name);
diff --git a/scd/command.c b/scd/command.c
index a4fb968cf..63e3e28e1 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -239,7 +239,7 @@ percent_plus_unescape (unsigned char *string)
operations are done on the same card unless he calls this function.
*/
static int
-cmd_serialno (ASSUAN_CONTEXT ctx, char *line)
+cmd_serialno (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc = 0;
@@ -248,7 +248,8 @@ cmd_serialno (ASSUAN_CONTEXT ctx, char *line)
time_t stamp;
/* Clear the remove flag so that the open_card is able to reread it. */
- ctrl->server_local->card_removed = 0;
+ if (ctrl->server_local->card_removed)
+ do_reset (ctrl, 0);
if ((rc = open_card (ctrl, *line? line:NULL)))
return rc;
@@ -1092,7 +1093,6 @@ cmd_checkpin (ASSUAN_CONTEXT ctx, char *line)
-
/* Tell the assuan library about our commands */
static int
@@ -1299,10 +1299,6 @@ scd_update_reader_status_file (void)
char templ[50];
FILE *fp;
- last[slot].any = 1;
- last[slot].status = status;
- last[slot].changed = changed;
-
log_info ("updating status of slot %d to 0x%04X\n", slot, status);
sprintf (templ, "reader_%d.status", slot);
@@ -1318,7 +1314,19 @@ scd_update_reader_status_file (void)
}
xfree (fname);
- /* Send a signal to the primary client, if any. */
+ /* Set the card removed flag. We will set this on any
+ card change because a reset or SERIALNO request must be
+ done in any case. */
+ if (primary_connection && primary_connection->server_local
+ && last[slot].any )
+ primary_connection->server_local->card_removed = 1;
+
+ last[slot].any = 1;
+ last[slot].status = status;
+ last[slot].changed = changed;
+
+
+ /* Send a signal to the primary client, if any. */
if (primary_connection && primary_connection->server_local
&& primary_connection->server_local->assuan_ctx)
{