1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

conf: New option --show-socket.

* tools/gpgconf-comp.c (gc_component_t): Move this enum to ...
* tools/gpgconf.h: here.
* tools/gpgconf.c (oShowSocket): New.
(opts): Add new option.
(main): Implement new option.
--

This is a convenience options for software which directly connects to
gpg-agent and thus needs to new the socket.  By using --show-socket
along with --launch that software can also autostart the agent or the
dirmngr.  Without this two calls to gpgconf would be required.

Actually the same behaviour can be achieved by running
gpg-connect-agent to query the running gpg-agent's socket via GETINFO.
The gpg-connect also makes sure that the agent is started.  This is
not anymore suggested because gpgconf shall in future be used for all
such things.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-02-25 15:55:13 +01:00
parent 371ae25f8f
commit ac485b4f25
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 48 additions and 29 deletions

View File

@ -1066,34 +1066,6 @@ static gc_option_t gc_options_pinentry[] =
/* Component system. Each component is a set of options that can be
configured at the same time. If you change this, don't forget to
update GC_COMPONENT below. */
typedef enum
{
/* The classic GPG for OpenPGP. */
GC_COMPONENT_GPG,
/* The GPG Agent. */
GC_COMPONENT_GPG_AGENT,
/* The Smardcard Daemon. */
GC_COMPONENT_SCDAEMON,
/* GPG for S/MIME. */
GC_COMPONENT_GPGSM,
/* The LDAP Directory Manager for CRLs. */
GC_COMPONENT_DIRMNGR,
/* The external Pinentry. */
GC_COMPONENT_PINENTRY,
/* The number of components. */
GC_COMPONENT_NR
} gc_component_t;
/* The information associated with each component. */ /* The information associated with each component. */
static const struct static const struct
{ {

View File

@ -47,6 +47,7 @@ enum cmd_and_opt_values
oHomedir, oHomedir,
oBuilddir, oBuilddir,
oStatusFD, oStatusFD,
oShowSocket,
aListComponents, aListComponents,
aCheckPrograms, aCheckPrograms,
@ -108,6 +109,7 @@ static ARGPARSE_OPTS opts[] =
{ oBuilddir, "build-prefix", 2, "@" }, { oBuilddir, "build-prefix", 2, "@" },
{ oNull, "null", 0, "@" }, { oNull, "null", 0, "@" },
{ oNoVerbose, "no-verbose", 0, "@"}, { oNoVerbose, "no-verbose", 0, "@"},
ARGPARSE_s_n (oShowSocket, "show-socket", "@"),
ARGPARSE_end(), ARGPARSE_end(),
}; };
@ -525,6 +527,7 @@ main (int argc, char **argv)
int no_more_options = 0; int no_more_options = 0;
enum cmd_and_opt_values cmd = 0; enum cmd_and_opt_values cmd = 0;
estream_t outfp = NULL; estream_t outfp = NULL;
int show_socket = 0;
early_system_init (); early_system_init ();
gnupg_reopen_std (GPGCONF_NAME); gnupg_reopen_std (GPGCONF_NAME);
@ -558,6 +561,7 @@ main (int argc, char **argv)
case oStatusFD: case oStatusFD:
set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
break; break;
case oShowSocket: show_socket = 1; break;
case aListDirs: case aListDirs:
case aListComponents: case aListComponents:
@ -682,7 +686,22 @@ main (int argc, char **argv)
} }
else if (cmd == aLaunch) else if (cmd == aLaunch)
{ {
if (gc_component_launch (idx)) err = gc_component_launch (idx);
if (show_socket)
{
char *names[2];
if (idx == GC_COMPONENT_GPG_AGENT)
names[0] = "agent-socket";
else if (idx == GC_COMPONENT_DIRMNGR)
names[0] = "dirmngr-socket";
else
names[0] = NULL;
names[1] = NULL;
get_outfp (&outfp);
list_dirs (outfp, names);
}
if (err)
gpgconf_failure (0); gpgconf_failure (0);
} }
else else

View File

@ -43,6 +43,34 @@ void gpgconf_failure (gpg_error_t err) GPGRT_ATTR_NORETURN;
/*-- gpgconf-comp.c --*/ /*-- gpgconf-comp.c --*/
/* Component system. Each component is a set of options that can be
* configured at the same time. If you change this, don't forget to
* update GC_COMPONENT in gpgconf-comp.c. */
typedef enum
{
/* The classic GPG for OpenPGP. */
GC_COMPONENT_GPG,
/* The GPG Agent. */
GC_COMPONENT_GPG_AGENT,
/* The Smardcard Daemon. */
GC_COMPONENT_SCDAEMON,
/* GPG for S/MIME. */
GC_COMPONENT_GPGSM,
/* The LDAP Directory Manager for CRLs. */
GC_COMPONENT_DIRMNGR,
/* The external Pinentry. */
GC_COMPONENT_PINENTRY,
/* The number of components. */
GC_COMPONENT_NR
} gc_component_t;
/* Initialize the components. */ /* Initialize the components. */
void gc_components_init (void); void gc_components_init (void);