diff options
author | Werner Koch <[email protected]> | 2008-12-05 12:01:01 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2008-12-05 12:01:01 +0000 |
commit | 041c764672705c842b43f4978b4a4dfd32a5977b (patch) | |
tree | 915666ed83407455549136af3b404b2238a8b79e /scd | |
parent | Translate the oktext (yes/no). (diff) | |
download | gnupg-041c764672705c842b43f4978b4a4dfd32a5977b.tar.gz gnupg-041c764672705c842b43f4978b4a4dfd32a5977b.zip |
Add option --card-timeout.
Add a new attribyte to app-openpgp.c
Fix two portability bugs.
Have gpg-connect-agent autostart gpg-agent on W32.
Diffstat (limited to 'scd')
-rw-r--r-- | scd/ChangeLog | 12 | ||||
-rw-r--r-- | scd/app-openpgp.c | 9 | ||||
-rw-r--r-- | scd/command.c | 18 | ||||
-rw-r--r-- | scd/scdaemon.c | 83 | ||||
-rw-r--r-- | scd/scdaemon.h | 1 |
5 files changed, 78 insertions, 45 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog index 8c63f3b20..9ac21d66b 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,3 +1,15 @@ +2008-12-05 Werner Koch <[email protected]> + + * app-openpgp.c (app_local_s): Add field ALGO_ATTR_CHANGE. + (app_select_openpgp): Parse new capability. + (show_caps): Show new capability. + +2008-12-03 Werner Koch <[email protected]> + + * scdaemon.c (opts): Use ARGPARSE_ macros. Add option + --card-timeout. + * command.c (update_reader_status_file): Implement it. + 2008-11-18 Werner Koch <[email protected]> * scdaemon.c (make_libversion): New. diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index a64d77cde..6b90795bb 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -167,13 +167,14 @@ struct app_local_s { /* Keep track of extended card capabilities. */ struct { - unsigned int is_v2:1; /* This is a v2.0 compatible card. */ + unsigned int is_v2:1; /* This is a v2.0 compatible card. */ unsigned int get_challenge:1; unsigned int key_import:1; unsigned int change_force_chv:1; unsigned int private_dos:1; - unsigned int sm_supported:1; /* Secure Messaging is supported. */ - unsigned int sm_aes128:1; /* Use AES-128 for SM. */ + unsigned int algo_attr_change:1; /* Algorithm attributes changeable. */ + unsigned int sm_supported:1; /* Secure Messaging is supported. */ + unsigned int sm_aes128:1; /* Use AES-128 for SM. */ unsigned int max_certlen_3:16; unsigned int max_get_challenge:16; /* Maximum size for get_challenge. */ unsigned int max_cmd_data:16; /* Maximum data size for a command. */ @@ -3154,6 +3155,7 @@ show_caps (struct app_local_s *s) log_info ("Key-Import .....: %s\n", s->extcap.key_import? "yes":"no"); log_info ("Change-Force-PW1: %s\n", s->extcap.change_force_chv? "yes":"no"); log_info ("Private-DOs ....: %s\n", s->extcap.private_dos? "yes":"no"); + log_info ("Algo-Attr-Change: %s\n", s->extcap.algo_attr_change? "yes":"no"); log_info ("SM-Support .....: %s", s->extcap.sm_supported? "yes":"no"); if (s->extcap.sm_supported) log_printf (" (%s)", s->extcap.sm_aes128? "AES-128":"3DES"); @@ -3376,6 +3378,7 @@ app_select_openpgp (app_t app) app->app_local->extcap.key_import = !!(*buffer & 0x20); app->app_local->extcap.change_force_chv = !!(*buffer & 0x10); app->app_local->extcap.private_dos = !!(*buffer & 0x08); + app->app_local->extcap.algo_attr_change = !!(*buffer & 0x04); } if (buflen >= 10) { diff --git a/scd/command.c b/scd/command.c index 7e1a12a5d..d94612daa 100644 --- a/scd/command.c +++ b/scd/command.c @@ -2095,14 +2095,18 @@ update_reader_status_file (int set_card_removed_flag) } /* Check whether a disconnect is pending. */ - for (sl=session_list; sl; sl = sl->next_session) - if (!sl->disconnect_allowed) - break; - if (session_list && !sl) + if (opt.card_timeout) { - /* At least one connection and all allow a disconnect. */ - log_debug ("disconnecting card in slot %d\n", ss->slot); - apdu_disconnect (ss->slot); + for (sl=session_list; sl; sl = sl->next_session) + if (!sl->disconnect_allowed) + break; + if (session_list && !sl) + { + /* FIXME: Use a real timeout. */ + /* At least one connection and all allow a disconnect. */ + log_debug ("disconnecting card in slot %d\n", ss->slot); + apdu_disconnect (ss->slot); + } } } diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 8cabec5e6..fc33be3a6 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -80,6 +80,7 @@ enum cmd_and_opt_values oDaemon, oBatch, oReaderPort, + oCardTimeout, octapiDriver, opcscDriver, oDisableCCID, @@ -94,46 +95,53 @@ enum cmd_and_opt_values static ARGPARSE_OPTS opts[] = { - - { aGPGConfList, "gpgconf-list", 256, "@" }, - { aGPGConfTest, "gpgconf-test", 256, "@" }, + ARGPARSE_c (aGPGConfList, "gpgconf-list", "@"), + ARGPARSE_c (aGPGConfTest, "gpgconf-test", "@"), - { 301, NULL, 0, N_("@Options:\n ") }, - - { oServer, "server", 0, N_("run in server mode (foreground)") }, - { oMultiServer, "multi-server", 0, - N_("run in multi server mode (foreground)") }, - { oDaemon, "daemon", 0, N_("run in daemon mode (background)") }, - { oVerbose, "verbose", 0, N_("verbose") }, - { oQuiet, "quiet", 0, N_("be somewhat more quiet") }, - { oSh, "sh", 0, N_("sh-style command output") }, - { oCsh, "csh", 0, N_("csh-style command output") }, - { oOptions, "options" , 2, N_("read options from file")}, - { oDebug, "debug" ,4|16, "@"}, - { oDebugAll, "debug-all" ,0, "@"}, - { oDebugLevel, "debug-level" ,2, "@"}, - { oDebugWait,"debug-wait",1, "@"}, - { oDebugAllowCoreDump, "debug-allow-core-dump", 0, "@" }, - { oDebugCCIDDriver, "debug-ccid-driver", 0, "@"}, - { oDebugDisableTicker, "debug-disable-ticker", 0, "@"}, - { oNoDetach, "no-detach" ,0, N_("do not detach from the console")}, - { oLogFile, "log-file" ,2, N_("use a log file for the server")}, - { oReaderPort, "reader-port", 2, N_("|N|connect to reader at port N")}, - { octapiDriver, "ctapi-driver", 2, N_("|NAME|use NAME as ct-API driver")}, - { opcscDriver, "pcsc-driver", 2, N_("|NAME|use NAME as PC/SC driver")}, - { oDisableCCID, "disable-ccid", 0, + ARGPARSE_group (301, N_("@Options:\n ")), + + ARGPARSE_s_n (oServer,"server", N_("run in server mode (foreground)")), + ARGPARSE_s_n (oMultiServer, "multi-server", + N_("run in multi server mode (foreground)")), + ARGPARSE_s_n (oDaemon, "daemon", N_("run in daemon mode (background)")), + ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")), + ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")), + ARGPARSE_s_n (oSh, "sh", N_("sh-style command output")), + ARGPARSE_s_n (oCsh, "csh", N_("csh-style command output")), + ARGPARSE_s_s (oOptions, "options", N_("|FILE|read options from FILE")), + ARGPARSE_p_u (oDebug, "debug", "@"), + ARGPARSE_s_n (oDebugAll, "debug-all", "@"), + ARGPARSE_s_s (oDebugLevel, "debug-level" , + N_("|LEVEL|set the debugging level to LEVEL")), + ARGPARSE_s_i (oDebugWait, "debug-wait", "@"), + ARGPARSE_s_n (oDebugAllowCoreDump, "debug-allow-core-dump", "@"), + ARGPARSE_s_n (oDebugCCIDDriver, "debug-ccid-driver", "@"), + ARGPARSE_s_n (oDebugDisableTicker, "debug-disable-ticker", "@"), + ARGPARSE_s_n (oNoDetach, "no-detach", N_("do not detach from the console")), + ARGPARSE_s_s (oLogFile, "log-file", N_("|FILE|write a log to FILE")), + ARGPARSE_s_s (oReaderPort, "reader-port", + N_("|N|connect to reader at port N")), + ARGPARSE_s_s (octapiDriver, "ctapi-driver", + N_("|NAME|use NAME as ct-API driver")), + ARGPARSE_s_s (opcscDriver, "pcsc-driver", + N_("|NAME|use NAME as PC/SC driver")), + ARGPARSE_s_n (oDisableCCID, "disable-ccid", #ifdef HAVE_LIBUSB N_("do not use the internal CCID driver") #else "@" #endif - /* end --disable-ccid */}, - { oDisableKeypad, "disable-keypad", 0, N_("do not use a reader's keypad")}, - { oAllowAdmin, "allow-admin", 0, N_("allow the use of admin card commands")}, - { oDenyAdmin, "deny-admin", 0, "@" }, - { oDisableApplication, "disable-application", 2, "@"}, - - {0} + /* end --disable-ccid */), + ARGPARSE_s_u (oCardTimeout, "card-timeout", + N_("|N|disconnect the card after N seconds of inactivity")), + ARGPARSE_s_n (oDisableKeypad, "disable-keypad", + N_("do not use a reader's keypad")), + ARGPARSE_s_n (oAllowAdmin, "allow-admin", + N_("allow the use of admin card commands")), + ARGPARSE_s_n (oDenyAdmin, "deny-admin", "@"), + ARGPARSE_s_s (oDisableApplication, "disable-application", "@"), + + ARGPARSE_end () }; @@ -528,12 +536,16 @@ main (int argc, char **argv ) case oAllowAdmin: opt.allow_admin = 1; break; case oDenyAdmin: opt.allow_admin = 0; break; + + case oCardTimeout: opt.card_timeout = pargs.r.ret_ulong; break; case oDisableApplication: add_to_strlist (&opt.disabled_applications, pargs.r.ret_str); break; - default : pargs.err = configfp? 1:2; break; + default: + pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; + break; } } if (configfp) @@ -619,6 +631,7 @@ main (int argc, char **argv ) #endif printf ("allow-admin:%lu:\n", GC_OPT_FLAG_NONE ); printf ("disable-keypad:%lu:\n", GC_OPT_FLAG_NONE ); + printf ("card-timeout:%lu:%d:\n", GC_OPT_FLAG_DEFAULT, 0); scd_exit (0); } diff --git a/scd/scdaemon.h b/scd/scdaemon.h index c0857e91b..221f84fe0 100644 --- a/scd/scdaemon.h +++ b/scd/scdaemon.h @@ -61,6 +61,7 @@ struct cards. */ strlist_t disabled_applications; /* Card applications we do not want to use. */ + unsigned long card_timeout; /* Disconnect after N seconds of inactivity. */ } opt; |