diff options
author | Werner Koch <[email protected]> | 2009-02-27 14:36:59 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2009-02-27 14:36:59 +0000 |
commit | ec4a3eb3c5b45321125a9b1fb2b8cd5ee20c52de (patch) | |
tree | 4ee2b19d3f5b44349fe36a40f28d0835e51d9fd8 /scd | |
parent | Fixed a nasty bug in scdaemon which led to a card reset if the card was (diff) | |
download | gnupg-ec4a3eb3c5b45321125a9b1fb2b8cd5ee20c52de.tar.gz gnupg-ec4a3eb3c5b45321125a9b1fb2b8cd5ee20c52de.zip |
Fix a gpg2 problem with removed cards.
Allow runtime conf change for scdaemon.
New commands for scdaemon.
Diffstat (limited to 'scd')
-rw-r--r-- | scd/ChangeLog | 9 | ||||
-rw-r--r-- | scd/app-common.h | 1 | ||||
-rw-r--r-- | scd/app.c | 35 | ||||
-rw-r--r-- | scd/command.c | 32 |
4 files changed, 75 insertions, 2 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog index 23544438c..1fd2de8c8 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,3 +1,12 @@ +2009-02-27 Werner Koch <[email protected]> + + * app.c (get_supported_applications): New. + * command.c (cmd_getinfo): New subcommand "app_list" + (cmd_killscd): New. + (register_commands): Register command KILLSCD. + (struct server_local_s): Add field STOPME. + (scd_command_handler): Act upon this. + 2009-02-25 Werner Koch <[email protected]> * apdu.c (apdu_get_status): Factor all code out to ... diff --git a/scd/app-common.h b/scd/app-common.h index 5a45fa05b..ad899a3b6 100644 --- a/scd/app-common.h +++ b/scd/app-common.h @@ -141,6 +141,7 @@ void application_notify_card_reset (int slot); gpg_error_t check_application_conflict (ctrl_t ctrl, const char *name); gpg_error_t select_application (ctrl_t ctrl, int slot, const char *name, app_t *r_app); +char *get_supported_applications (void); void release_application (app_t app); gpg_error_t app_munge_serialno (app_t app); gpg_error_t app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp); @@ -22,7 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -# include <pth.h> +#include <pth.h> #include "scdaemon.h" #include "app-common.h" @@ -373,7 +373,7 @@ select_application (ctrl_t ctrl, int slot, const char *name, app_t *r_app) } app->ref_count = 1; - log_debug ("USING application context (refcount=%u) (new)\n", app->ref_count); + lock_table[slot].app = app; *r_app = app; unlock_reader (slot); @@ -381,6 +381,37 @@ select_application (ctrl_t ctrl, int slot, const char *name, app_t *r_app) } +char * +get_supported_applications (void) +{ + const char *list[] = { + "openpgp", + "nks", + "p15", + "dinsig", + "geldkarte", + NULL + }; + int idx; + size_t nbytes; + char *buffer, *p; + + for (nbytes=1, idx=0; list[idx]; idx++) + nbytes += strlen (list[idx]) + 1 + 1; + + buffer = xtrymalloc (nbytes); + if (!buffer) + return NULL; + + for (p=buffer, idx=0; list[idx]; idx++) + if (is_app_allowed (list[idx])) + p = stpcpy (stpcpy (p, list[idx]), ":\n"); + *p = 0; + + return buffer; +} + + /* Deallocate the application. */ static void deallocate_app (app_t app) diff --git a/scd/command.c b/scd/command.c index f3e374c39..07a1e9b54 100644 --- a/scd/command.c +++ b/scd/command.c @@ -114,6 +114,11 @@ struct server_local_s /* A disconnect command has been sent. */ int disconnect_allowed; + + /* If set to true we will be terminate ourself at the end of the + this session. */ + int stopme; + }; @@ -1561,6 +1566,9 @@ cmd_unlock (assuan_context_t ctx, char *line) deny_admin - Returns OK if admin commands are not allowed or GPG_ERR_GENERAL if admin commands are allowed. + app_list - Return a list of supported applciations. One + application per line, fields delimited by colons, + first field is the name. */ static int @@ -1628,6 +1636,15 @@ cmd_getinfo (assuan_context_t ctx, char *line) } else if (!strcmp (line, "deny_admin")) rc = opt.allow_admin? gpg_error (GPG_ERR_GENERAL) : 0; + else if (!strcmp (line, "app_list")) + { + char *s = get_supported_applications (); + if (s) + rc = assuan_send_data (ctx, s, strlen (s)); + else + rc = 0; + xfree (s); + } else rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT"); return rc; @@ -1767,6 +1784,17 @@ cmd_apdu (assuan_context_t ctx, char *line) } +/* KILLSCD - Commit suicide. */ +static int +cmd_killscd (assuan_context_t ctx, char *line) +{ + ctrl_t ctrl = assuan_get_pointer (ctx); + + (void)line; + + ctrl->server_local->stopme = 1; + return gpg_error (GPG_ERR_EOF); +} @@ -1802,6 +1830,7 @@ register_commands (assuan_context_t ctx) { "RESTART", cmd_restart }, { "DISCONNECT", cmd_disconnect }, { "APDU", cmd_apdu }, + { "KILLSCD", cmd_killscd }, { NULL } }; int i, rc; @@ -1919,6 +1948,9 @@ scd_command_handler (ctrl_t ctrl, int fd) /* Release the Assuan context. */ assuan_deinit_server (ctx); + if (ctrl->server_local->stopme) + scd_exit (0); + /* If there are no more sessions return true. */ return !session_list; } |