summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2008-12-05 13:01:01 +0100
committerWerner Koch <wk@gnupg.org>2008-12-05 13:01:01 +0100
commit041c764672705c842b43f4978b4a4dfd32a5977b (patch)
tree915666ed83407455549136af3b404b2238a8b79e /tools
parentTranslate the oktext (yes/no). (diff)
downloadgnupg2-041c764672705c842b43f4978b4a4dfd32a5977b.tar.xz
gnupg2-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 '')
-rw-r--r--tools/ChangeLog10
-rw-r--r--tools/gpg-connect-agent.c75
-rw-r--r--tools/gpgconf-comp.c8
3 files changed, 71 insertions, 22 deletions
diff --git a/tools/ChangeLog b/tools/ChangeLog
index 7ab7dd82a..fc497bed1 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,3 +1,13 @@
+2008-12-05 Werner Koch <wk@g10code.com>
+
+ * gpg-connect-agent.c (opts): Use ARGPARSE_ macros.
+ (start_agent) [W32]: Start agent if not running.
+
+2008-12-03 Werner Koch <wk@g10code.com>
+
+ * gpgconf-comp.c <scdaemon>: Add option --card-timeout. Remove
+ unused option --disable-opensc.
+
2008-10-20 Werner Koch <wk@g10code.com>
* gpgsplit.c (write_part): Remove unused arg FNAME. Change caller.
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index 774abfad4..92a6e7001 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -34,6 +34,10 @@
#include "../common/sysutils.h"
#include "../common/membuf.h"
#include "../common/ttyio.h"
+#ifdef HAVE_W32_SYSTEM
+# include "../common/exechelp.h"
+#endif
+
#define CONTROL_D ('D' - 'A' + 1)
#define octdigitp(p) (*(p) >= '0' && *(p) <= '7')
@@ -59,25 +63,28 @@ enum cmd_and_opt_values
/* The list of commands and options. */
-static ARGPARSE_OPTS opts[] =
- {
- { 301, NULL, 0, N_("@\nOptions:\n ") },
+static ARGPARSE_OPTS opts[] = {
+ ARGPARSE_group (301, N_("@\nOptions:\n ")),
- { oVerbose, "verbose", 0, N_("verbose") },
- { oQuiet, "quiet", 0, N_("quiet") },
- { oHex, "hex", 0, N_("print data out hex encoded") },
- { oDecode,"decode", 0, N_("decode received data lines") },
- { oRawSocket, "raw-socket", 2, N_("|NAME|connect to Assuan socket NAME")},
- { oExec, "exec", 0, N_("run the Assuan server given on the command line")},
- { oNoExtConnect, "no-ext-connect",
- 0, N_("do not use extended connect mode")},
- { oRun, "run", 2, N_("|FILE|run commands from FILE on startup")},
- { oSubst, "subst", 0, N_("run /subst on startup")},
- /* hidden options */
- { oNoVerbose, "no-verbose", 0, "@"},
- { oHomedir, "homedir", 2, "@" },
- {0}
- };
+ ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
+ ARGPARSE_s_n (oQuiet, "quiet", N_("quiet")),
+ ARGPARSE_s_n (oHex, "hex", N_("print data out hex encoded")),
+ ARGPARSE_s_n (oDecode,"decode", N_("decode received data lines")),
+ ARGPARSE_s_s (oRawSocket, "raw-socket",
+ N_("|NAME|connect to Assuan socket NAME")),
+ ARGPARSE_s_n (oExec, "exec",
+ N_("run the Assuan server given on the command line")),
+ ARGPARSE_s_n (oNoExtConnect, "no-ext-connect",
+ N_("do not use extended connect mode")),
+ ARGPARSE_s_s (oRun, "run",
+ N_("|FILE|run commands from FILE on startup")),
+ ARGPARSE_s_n (oSubst, "subst", N_("run /subst on startup")),
+
+ ARGPARSE_s_n (oNoVerbose, "no-verbose", "@"),
+ ARGPARSE_s_s (oHomedir, "homedir", "@" ),
+
+ ARGPARSE_end ()
+};
/* We keep all global options in the structure OPT. */
@@ -2081,6 +2088,38 @@ start_agent (void)
/* Check whether we can connect at the standard socket. */
sockname = make_filename (opt.homedir, "S.gpg-agent", NULL);
rc = assuan_socket_connect (&ctx, sockname, 0);
+
+#ifdef HAVE_W32_SYSTEM
+ /* If we failed to connect under Windows, we fire up the agent. */
+ if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED)
+ {
+ const char *agent_program;
+ const char *argv[3];
+ int save_rc = rc;
+
+ if (opt.verbose)
+ log_info (_("no running gpg-agent - starting one\n"));
+ agent_program = gnupg_module_name (GNUPG_MODULE_NAME_AGENT);
+
+ argv[0] = "--daemon";
+ argv[1] = "--use-standard-socket";
+ argv[2] = NULL;
+
+ rc = gnupg_spawn_process_detached (agent_program, argv, NULL);
+ if (rc)
+ log_debug ("failed to start agent `%s': %s\n",
+ agent_program, gpg_strerror (rc));
+ else
+ {
+ /* Give the agent some time to prepare itself. */
+ gnupg_sleep (3);
+ /* Now try again to connect the agent. */
+ rc = assuan_socket_connect (&ctx, sockname, 0);
+ }
+ if (rc)
+ rc = save_rc;
+ }
+#endif /*HAVE_W32_SYSTEM*/
xfree (sockname);
}
else
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index f7c8af1d7..1084bda72 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -599,15 +599,15 @@ static gc_option_t gc_options_scdaemon[] =
{ "pcsc-driver", GC_OPT_FLAG_NONE, GC_LEVEL_ADVANCED,
"gnupg", "|NAME|use NAME as PC/SC driver",
GC_ARG_TYPE_STRING, GC_BACKEND_SCDAEMON },
- { "disable-opensc", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT,
- "gnupg", "do not use the OpenSC layer",
- GC_ARG_TYPE_NONE, GC_BACKEND_SCDAEMON },
{ "disable-ccid", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT,
"gnupg", "do not use the internal CCID driver",
GC_ARG_TYPE_NONE, GC_BACKEND_SCDAEMON },
{ "disable-keypad", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC,
"gnupg", "do not use a reader's keypad",
GC_ARG_TYPE_NONE, GC_BACKEND_SCDAEMON },
+ { "card-timeout", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC,
+ "gnupg", "|N|disconnect the card after N seconds of inactivity",
+ GC_ARG_TYPE_UINT32, GC_BACKEND_SCDAEMON },
{ "Debug",
GC_OPT_FLAG_GROUP, GC_LEVEL_ADVANCED,
@@ -616,7 +616,7 @@ static gc_option_t gc_options_scdaemon[] =
"gnupg", "|LEVEL|set the debugging level to LEVEL",
GC_ARG_TYPE_STRING, GC_BACKEND_SCDAEMON },
{ "log-file", GC_OPT_FLAG_NONE, GC_LEVEL_ADVANCED,
- "gnupg", N_("|FILE|write server mode logs to FILE"),
+ "gnupg", N_("|FILE|write a log to FILE"),
GC_ARG_TYPE_FILENAME, GC_BACKEND_SCDAEMON },
{ "Security",