mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
common: New common option no-autostart.
* common/comopt.c (opts): Add "no-autostart". (parse_comopt): Set it. * common/comopt.h (comopt): Add no_autostart. * g10/gpg.c (main): Take care of the new option. * sm/gpgsm.c (main): Ditto. * tools/gpg-connect-agent.c (INCLUDED_BY_MAIN_MODULE): Add. (main): Parse common options and handle new option. * tools/gpg-card.c (main): Ditto. (cmd_yubikey): Fix minor error reporting issue. * common/util.h (GNUPG_MODULE_NAME_CARD): New const. * common/homedir.c (gnupg_module_name): Support it. -- Having a global option makes it easier to use disable autostart on a server which is required to use a remote gpg-agent reliable.
This commit is contained in:
parent
bca00f1fba
commit
203dcc19eb
@ -45,6 +45,7 @@ enum opt_values
|
|||||||
oLogFile = 500,
|
oLogFile = 500,
|
||||||
oUseKeyboxd,
|
oUseKeyboxd,
|
||||||
oKeyboxdProgram,
|
oKeyboxdProgram,
|
||||||
|
oNoAutostart,
|
||||||
|
|
||||||
oNoop
|
oNoop
|
||||||
};
|
};
|
||||||
@ -52,6 +53,7 @@ enum opt_values
|
|||||||
static gpgrt_opt_t opts[] = {
|
static gpgrt_opt_t opts[] = {
|
||||||
ARGPARSE_s_s (oLogFile, "log-file", "@"),
|
ARGPARSE_s_s (oLogFile, "log-file", "@"),
|
||||||
ARGPARSE_s_n (oUseKeyboxd, "use-keyboxd", "@"),
|
ARGPARSE_s_n (oUseKeyboxd, "use-keyboxd", "@"),
|
||||||
|
ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
|
||||||
ARGPARSE_s_s (oKeyboxdProgram, "keyboxd-program", "@"),
|
ARGPARSE_s_s (oKeyboxdProgram, "keyboxd-program", "@"),
|
||||||
|
|
||||||
ARGPARSE_end ()
|
ARGPARSE_end ()
|
||||||
@ -60,7 +62,7 @@ static gpgrt_opt_t opts[] = {
|
|||||||
|
|
||||||
|
|
||||||
/* Parse the common options in the homedir and etc. This needs to be
|
/* 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 GNUPG_MODULE_NAME_ constants. If verbose is true info about
|
||||||
* the parsing is printed. Note that this function is not
|
* the parsing is printed. Note that this function is not
|
||||||
* thread-safe. */
|
* thread-safe. */
|
||||||
@ -102,6 +104,10 @@ parse_comopt (int module_id, int verbose)
|
|||||||
comopt.use_keyboxd = 1;
|
comopt.use_keyboxd = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case oNoAutostart:
|
||||||
|
comopt.no_autostart = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case oKeyboxdProgram:
|
case oKeyboxdProgram:
|
||||||
comopt.keyboxd_program = pargs.r.ret_str;
|
comopt.keyboxd_program = pargs.r.ret_str;
|
||||||
break;
|
break;
|
||||||
|
@ -40,6 +40,7 @@ struct
|
|||||||
{
|
{
|
||||||
char *logfile; /* Socket used by daemons for logging. */
|
char *logfile; /* Socket used by daemons for logging. */
|
||||||
int use_keyboxd; /* Use the keyboxd as storage backend. */
|
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. */
|
char *keyboxd_program; /* Use this as keyboxd program. */
|
||||||
} comopt;
|
} comopt;
|
||||||
|
|
||||||
|
@ -1592,6 +1592,9 @@ gnupg_module_name (int which)
|
|||||||
case GNUPG_MODULE_NAME_GPGCONF:
|
case GNUPG_MODULE_NAME_GPGCONF:
|
||||||
X(bindir, "tools", "gpgconf");
|
X(bindir, "tools", "gpgconf");
|
||||||
|
|
||||||
|
case GNUPG_MODULE_NAME_CARD:
|
||||||
|
X(bindir, "tools", "gpg-card");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BUG ();
|
BUG ();
|
||||||
}
|
}
|
||||||
|
@ -297,6 +297,7 @@ char *_gnupg_socketdir_internal (int skip_checks, unsigned *r_info);
|
|||||||
#define GNUPG_MODULE_NAME_GPGV 12
|
#define GNUPG_MODULE_NAME_GPGV 12
|
||||||
#define GNUPG_MODULE_NAME_KEYBOXD 13
|
#define GNUPG_MODULE_NAME_KEYBOXD 13
|
||||||
#define GNUPG_MODULE_NAME_TPM2DAEMON 14
|
#define GNUPG_MODULE_NAME_TPM2DAEMON 14
|
||||||
|
#define GNUPG_MODULE_NAME_CARD 15
|
||||||
const char *gnupg_module_name (int which);
|
const char *gnupg_module_name (int which);
|
||||||
void gnupg_module_name_flush_some (void);
|
void gnupg_module_name_flush_some (void);
|
||||||
void gnupg_set_builddir (const char *newdir);
|
void gnupg_set_builddir (const char *newdir);
|
||||||
|
@ -3784,6 +3784,8 @@ main (int argc, char **argv)
|
|||||||
comopt.keyboxd_program = NULL;
|
comopt.keyboxd_program = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comopt.no_autostart)
|
||||||
|
opt.autostart = 0;
|
||||||
|
|
||||||
/* The command --gpgconf-list is pretty simple and may be called
|
/* The command --gpgconf-list is pretty simple and may be called
|
||||||
directly after the option parsing. */
|
directly after the option parsing. */
|
||||||
|
@ -1534,6 +1534,9 @@ main ( int argc, char **argv)
|
|||||||
comopt.keyboxd_program = NULL;
|
comopt.keyboxd_program = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comopt.no_autostart)
|
||||||
|
opt.autostart = 0;
|
||||||
|
|
||||||
if (pwfd != -1) /* Read the passphrase now. */
|
if (pwfd != -1) /* Read the passphrase now. */
|
||||||
read_passphrase_from_fd (pwfd);
|
read_passphrase_from_fd (pwfd);
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "../common/server-help.h"
|
#include "../common/server-help.h"
|
||||||
#include "../common/openpgpdefs.h"
|
#include "../common/openpgpdefs.h"
|
||||||
#include "../common/tlv.h"
|
#include "../common/tlv.h"
|
||||||
|
#include "../common/comopt.h"
|
||||||
|
|
||||||
#include "gpg-card.h"
|
#include "gpg-card.h"
|
||||||
|
|
||||||
@ -292,6 +293,17 @@ main (int argc, char **argv)
|
|||||||
if (log_get_errorcount (0))
|
if (log_get_errorcount (0))
|
||||||
exit (2);
|
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. */
|
/* Set defaults for non given options. */
|
||||||
if (!opt.gpg_program)
|
if (!opt.gpg_program)
|
||||||
opt.gpg_program = gnupg_module_name (GNUPG_MODULE_NAME_GPG);
|
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);
|
err = yubikey_commands (info, fp, nwords, words);
|
||||||
err2 = scd_learn (info, 0);
|
err2 = scd_learn (info, 0);
|
||||||
if (err2)
|
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:
|
leave:
|
||||||
return err;
|
return err;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#define INCLUDED_BY_MAIN_MODULE 1
|
||||||
#include "../common/i18n.h"
|
#include "../common/i18n.h"
|
||||||
#include "../common/util.h"
|
#include "../common/util.h"
|
||||||
#include "../common/asshelp.h"
|
#include "../common/asshelp.h"
|
||||||
@ -39,6 +40,7 @@
|
|||||||
# include "../common/exechelp.h"
|
# include "../common/exechelp.h"
|
||||||
#endif
|
#endif
|
||||||
#include "../common/init.h"
|
#include "../common/init.h"
|
||||||
|
#include "../common/comopt.h"
|
||||||
|
|
||||||
|
|
||||||
#define CONTROL_D ('D' - 'A' + 1)
|
#define CONTROL_D ('D' - 'A' + 1)
|
||||||
@ -1255,6 +1257,13 @@ main (int argc, char **argv)
|
|||||||
if (log_get_errorcount (0))
|
if (log_get_errorcount (0))
|
||||||
exit (2);
|
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
|
/* --uiserver is a shortcut for a specific raw socket. This comes
|
||||||
in particular handy on Windows. */
|
in particular handy on Windows. */
|
||||||
if (opt.use_uiserver)
|
if (opt.use_uiserver)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user