From 24e121ef261731069868ca403b818f1168237f53 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 13 Dec 2011 16:55:42 +0100 Subject: scd: Introduce a virtual reader table. The vreader table makes the code more clear by explicitly talking about APDU slots and reader indices. It also accommodates for future extensions. * scd/scdaemon.h (server_control_s): Remove READER_SLOT. * scd/scdaemon.c (scd_init_default_ctrl): Do not init READER_SLOT. * scd/app.c (check_application_conflict): Add arg SLOT. * scd/command.c (slot_status_s): Rename to vreader_s. (server_local_s): Add field VREADER_IDX as replacement for the READER_SLOT in server_control_s. Change all users. (slot_table): Rename to vreader_table. Change all users. (vreader_slot): New. (do_reset, cmd_apdu): Map vreader to apdu slot. (get_reader_slot): Rename to get_current_reader. Return -1 on error. (open_card): Map vreader toapdu slot. Pass slot to check_application_conflict. (scd_command_handler): Init VREADER_IDX. (update_reader_status_file): Reset SLOT field on error. --- scd/scdaemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scd/scdaemon.c') diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 0999847ef..b4eee396e 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -913,7 +913,7 @@ scd_exit (int rc) static void scd_init_default_ctrl (ctrl_t ctrl) { - ctrl->reader_slot = -1; + (void)ctrl; } static void -- cgit v1.2.3 From 00c760f628f4cf0fc11e79d305c172f98123f815 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 13 Dec 2011 17:59:00 +0100 Subject: scd: New option --debug-assuan-log-cats. * scd/scdaemon.c (oDebugAssuanLogCats): New. (opts): Add option --debug-assuan-log-cats. (main): Implement option. * common/asshelp.c (set_libassuan_log_cats): New. -- The old way of setting the logging categories with an environment variable is awkward if sdaemon is spawned from a running gpg-agent. --- scd/scdaemon.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scd/scdaemon.c') diff --git a/scd/scdaemon.c b/scd/scdaemon.c index b4eee396e..c8905d4f0 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -72,6 +72,7 @@ enum cmd_and_opt_values oDebugAllowCoreDump, oDebugCCIDDriver, oDebugLogTid, + oDebugAssuanLogCats, oNoGreeting, oNoOptions, oHomedir, @@ -121,6 +122,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oDebugCCIDDriver, "debug-ccid-driver", "@"), ARGPARSE_s_n (oDebugDisableTicker, "debug-disable-ticker", "@"), ARGPARSE_s_n (oDebugLogTid, "debug-log-tid", "@"), + ARGPARSE_p_u (oDebugAssuanLogCats, "debug-assuan-log-cats", "@"), 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", @@ -553,6 +555,9 @@ main (int argc, char **argv ) case oDebugLogTid: log_set_pid_suffix_cb (tid_log_callback); break; + case oDebugAssuanLogCats: + set_libassuan_log_cats (pargs.r.ret_ulong); + break; case oOptions: /* config files may not be nested (silently ignore them) */ -- cgit v1.2.3 From a2d9e48fcca6cfc2dfadef6dbd3579a30314676b Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 2 Jan 2012 22:15:00 +0100 Subject: Only set gcrypt thread callback for older version of gcrypt. * agent/gpg-agent.c, dirmngr/dirmngr.c, g13/g13.c, scd/scdaemon.c (USE_GCRY_THREAD_CBS): New macro, defined if GCRY_THREAD_OPTION_VERSION is 0. (fixed_gcry_pth_init) [!USE_GCRY_THREAD_CBS]: Don't define. (main) [!USE_GCRY_THREAD_CBS]: Do not install thread callbacks. --- scd/scdaemon.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'scd/scdaemon.c') diff --git a/scd/scdaemon.c b/scd/scdaemon.c index c8905d4f0..128ecc31d 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -208,12 +208,18 @@ static void handle_connections (int listen_fd); /* Pth wrapper function definitions. */ ASSUAN_SYSTEM_PTH_IMPL; +#if defined(GCRY_THREAD_OPTION_VERSION) && (GCRY_THREAD_OPTION_VERSION == 0) +#define USE_GCRY_THREAD_CBS 1 +#endif + +#ifdef USE_GCRY_THREAD_CBS GCRY_THREAD_OPTION_PTH_IMPL; + static int fixed_gcry_pth_init (void) { return pth_self ()? 0 : (pth_init () == FALSE) ? errno : 0; } - +#endif static char * @@ -413,6 +419,7 @@ main (int argc, char **argv ) /* Libgcrypt requires us to register the threading model first. Note that this will also do the pth_init. */ +#ifdef USE_GCRY_THREAD_CBS gcry_threads_pth.init = fixed_gcry_pth_init; err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth); if (err) @@ -420,6 +427,7 @@ main (int argc, char **argv ) log_fatal ("can't register GNU Pth with Libgcrypt: %s\n", gpg_strerror (err)); } +#endif /* Check that the libraries are suitable. Do it here because the option parsing may need services of the library */ -- cgit v1.2.3 From d01d9ff11f46cbd61b7b8c0e04431e4f0c4a8580 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 3 Jan 2012 11:13:30 +0100 Subject: Terminate csh commands with a semicolon. Fixes bug#1386. * agent/gpg-agent.c (main): Terminate csh style output with a semicolon. * scd/scdaemon.c: Ditto. --- scd/scdaemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scd/scdaemon.c') diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 128ecc31d..6f8d01049 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -843,7 +843,7 @@ main (int argc, char **argv ) if (csh_style) { *strchr (infostr, '=') = ' '; - es_printf ( "setenv %s\n", infostr); + es_printf ( "setenv %s;\n", infostr); } else { -- cgit v1.2.3 From 0dce26778ef8abd4fc40de689d7ec9b720d26430 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 3 Jan 2012 17:08:01 +0100 Subject: Fix compiler warnings. * common/dotlock.c (use_hardlinks_p, dotlock_take_unix): Check return value of link(). * g13/g13.c: Make sure err is initialized. * scd/scdaemon.c (main) [!USE_GCRY_THREAD_CBS]: Do not define ERR. --- scd/scdaemon.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scd/scdaemon.c') diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 6f8d01049..e26beba13 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -382,7 +382,9 @@ main (int argc, char **argv ) { ARGPARSE_ARGS pargs; int orig_argc; +#ifdef USE_GCRY_THREAD_CBS gpg_error_t err; +#endif char **orig_argv; FILE *configfp = NULL; char *configname = NULL; -- cgit v1.2.3