aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/comopt.c8
-rw-r--r--common/comopt.h1
-rw-r--r--common/homedir.c3
-rw-r--r--common/util.h1
-rw-r--r--g10/gpg.c2
-rw-r--r--sm/gpgsm.c3
-rw-r--r--tools/gpg-card.c14
-rw-r--r--tools/gpg-connect-agent.c9
8 files changed, 39 insertions, 2 deletions
diff --git a/common/comopt.c b/common/comopt.c
index 764df57c6..470cdac61 100644
--- a/common/comopt.c
+++ b/common/comopt.c
@@ -45,6 +45,7 @@ enum opt_values
oLogFile = 500,
oUseKeyboxd,
oKeyboxdProgram,
+ oNoAutostart,
oNoop
};
@@ -52,6 +53,7 @@ enum opt_values
static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oLogFile, "log-file", "@"),
ARGPARSE_s_n (oUseKeyboxd, "use-keyboxd", "@"),
+ ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
ARGPARSE_s_s (oKeyboxdProgram, "keyboxd-program", "@"),
ARGPARSE_end ()
@@ -60,7 +62,7 @@ static gpgrt_opt_t opts[] = {
/* Parse the common options in the homedir and etc. This needs to be
- * called after the gpgrt config directories are. MODULE_ID is one of
+ * called after the gpgrt config directories are set. MODULE_ID is one of
* the GNUPG_MODULE_NAME_ constants. If verbose is true info about
* the parsing is printed. Note that this function is not
* thread-safe. */
@@ -102,6 +104,10 @@ parse_comopt (int module_id, int verbose)
comopt.use_keyboxd = 1;
break;
+ case oNoAutostart:
+ comopt.no_autostart = 1;
+ break;
+
case oKeyboxdProgram:
comopt.keyboxd_program = pargs.r.ret_str;
break;
diff --git a/common/comopt.h b/common/comopt.h
index 1cdf25fe7..7947f35b3 100644
--- a/common/comopt.h
+++ b/common/comopt.h
@@ -40,6 +40,7 @@ struct
{
char *logfile; /* Socket used by daemons for logging. */
int use_keyboxd; /* Use the keyboxd as storage backend. */
+ int no_autostart; /* Do not start gpg-agent. */
char *keyboxd_program; /* Use this as keyboxd program. */
} comopt;
diff --git a/common/homedir.c b/common/homedir.c
index 260aeb2fa..dd4963c32 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -1592,6 +1592,9 @@ gnupg_module_name (int which)
case GNUPG_MODULE_NAME_GPGCONF:
X(bindir, "tools", "gpgconf");
+ case GNUPG_MODULE_NAME_CARD:
+ X(bindir, "tools", "gpg-card");
+
default:
BUG ();
}
diff --git a/common/util.h b/common/util.h
index 62e5af51d..6978ab896 100644
--- a/common/util.h
+++ b/common/util.h
@@ -297,6 +297,7 @@ char *_gnupg_socketdir_internal (int skip_checks, unsigned *r_info);
#define GNUPG_MODULE_NAME_GPGV 12
#define GNUPG_MODULE_NAME_KEYBOXD 13
#define GNUPG_MODULE_NAME_TPM2DAEMON 14
+#define GNUPG_MODULE_NAME_CARD 15
const char *gnupg_module_name (int which);
void gnupg_module_name_flush_some (void);
void gnupg_set_builddir (const char *newdir);
diff --git a/g10/gpg.c b/g10/gpg.c
index 397f4cc87..35ffaf339 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -3784,6 +3784,8 @@ main (int argc, char **argv)
comopt.keyboxd_program = NULL;
}
+ if (comopt.no_autostart)
+ opt.autostart = 0;
/* The command --gpgconf-list is pretty simple and may be called
directly after the option parsing. */
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index 4c7c28c3e..bc22d68b3 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -1534,6 +1534,9 @@ main ( int argc, char **argv)
comopt.keyboxd_program = NULL;
}
+ if (comopt.no_autostart)
+ opt.autostart = 0;
+
if (pwfd != -1) /* Read the passphrase now. */
read_passphrase_from_fd (pwfd);
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index 9c83f556c..1ccace478 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -43,6 +43,7 @@
#include "../common/server-help.h"
#include "../common/openpgpdefs.h"
#include "../common/tlv.h"
+#include "../common/comopt.h"
#include "gpg-card.h"
@@ -292,6 +293,17 @@ main (int argc, char **argv)
if (log_get_errorcount (0))
exit (2);
+ /* Process common component options. */
+ if (parse_comopt (GNUPG_MODULE_NAME_CARD, opt.debug))
+ {
+ gnupg_status_printf (STATUS_FAILURE, "option-parser %u",
+ gpg_error (GPG_ERR_GENERAL));
+ exit(2);
+ }
+
+ if (comopt.no_autostart)
+ opt.autostart = 0;
+
/* Set defaults for non given options. */
if (!opt.gpg_program)
opt.gpg_program = gnupg_module_name (GNUPG_MODULE_NAME_GPG);
@@ -3505,7 +3517,7 @@ cmd_yubikey (card_info_t info, char *argstr)
err = yubikey_commands (info, fp, nwords, words);
err2 = scd_learn (info, 0);
if (err2)
- log_error ("Error re-reading card: %s\n", gpg_strerror (err));
+ log_error ("Error re-reading card: %s\n", gpg_strerror (err2));
leave:
return err;
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index 6132ef0eb..8d9e83fa8 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <assert.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/i18n.h"
#include "../common/util.h"
#include "../common/asshelp.h"
@@ -39,6 +40,7 @@
# include "../common/exechelp.h"
#endif
#include "../common/init.h"
+#include "../common/comopt.h"
#define CONTROL_D ('D' - 'A' + 1)
@@ -1255,6 +1257,13 @@ main (int argc, char **argv)
if (log_get_errorcount (0))
exit (2);
+ /* Process common component options. */
+ if (parse_comopt (GNUPG_MODULE_NAME_CONNECT_AGENT, opt.verbose > 1))
+ exit(2);
+
+ if (comopt.no_autostart)
+ opt.autostart = 0;
+
/* --uiserver is a shortcut for a specific raw socket. This comes
in particular handy on Windows. */
if (opt.use_uiserver)