core: Support all components with dirinfo()

* src/dirinfo.c (WANT_KEYBOXD_NAME, WANT_AGENT_NAME, WANT_SCDAEMON_NAME,
WANT_DIRMNGR_NAME, WANT_PINENTRY_NAME): New.
(dirinfo): Add fields keyboxd_name, agent_name, scdaemon_name,
dirmngr_name, pinentry_name.
(parse_output): Support "keyboxd", "gpg-agent", "scdaemon", "dirmngr",
"pinentry".
(get_gpgconf_item): Return new components.

tests/t-engine-info.c (main): Add new components to the output.
--

GnuPG-bug-id: 5727
This commit is contained in:
Ingo Klöcker 2021-12-10 12:04:05 +01:00
parent 0eddc867c3
commit 0ac3679a74
3 changed files with 75 additions and 0 deletions

View File

@ -990,6 +990,21 @@ Return the file name of the CMS engine.
@item g13-name @item g13-name
Return the name of the file container encryption engine. Return the name of the file container encryption engine.
@item keyboxd-name
Return the name of the key database daemon.
@item agent-name
Return the name of gpg-agent.
@item scdaemon-name
Return the name of the smart card daemon.
@item dirmngr-name
Return the name of dirmngr.
@item pinentry-name
Return the name of the pinentry program.
@item gpg-wks-client-name @item gpg-wks-client-name
Return the name of the Web Key Service tool. Return the name of the Web Key Service tool.

View File

@ -53,6 +53,11 @@ enum
WANT_GPG_NAME, WANT_GPG_NAME,
WANT_GPGSM_NAME, WANT_GPGSM_NAME,
WANT_G13_NAME, WANT_G13_NAME,
WANT_KEYBOXD_NAME,
WANT_AGENT_NAME,
WANT_SCDAEMON_NAME,
WANT_DIRMNGR_NAME,
WANT_PINENTRY_NAME,
WANT_GPG_WKS_CLIENT_NAME, WANT_GPG_WKS_CLIENT_NAME,
WANT_GPG_ONE_MODE WANT_GPG_ONE_MODE
}; };
@ -77,6 +82,11 @@ static struct {
char *gpg_name; char *gpg_name;
char *gpgsm_name; char *gpgsm_name;
char *g13_name; char *g13_name;
char *keyboxd_name;
char *agent_name;
char *scdaemon_name;
char *dirmngr_name;
char *pinentry_name;
char *gpg_wks_client_name; char *gpg_wks_client_name;
int gpg_one_mode; /* System is in gpg1 mode. */ int gpg_one_mode; /* System is in gpg1 mode. */
} dirinfo; } dirinfo;
@ -137,6 +147,16 @@ parse_output (char *line, int components)
dirinfo.gpgsm_name = strdup (value); dirinfo.gpgsm_name = strdup (value);
else if (!strcmp (line, "g13") && !dirinfo.g13_name) else if (!strcmp (line, "g13") && !dirinfo.g13_name)
dirinfo.g13_name = strdup (value); dirinfo.g13_name = strdup (value);
else if (!strcmp (line, "keyboxd") && !dirinfo.keyboxd_name)
dirinfo.keyboxd_name = strdup (value);
else if (!strcmp (line, "gpg-agent") && !dirinfo.agent_name)
dirinfo.agent_name = strdup (value);
else if (!strcmp (line, "scdaemon") && !dirinfo.scdaemon_name)
dirinfo.scdaemon_name = strdup (value);
else if (!strcmp (line, "dirmngr") && !dirinfo.dirmngr_name)
dirinfo.dirmngr_name = strdup (value);
else if (!strcmp (line, "pinentry") && !dirinfo.pinentry_name)
dirinfo.pinentry_name = strdup (value);
} }
else else
{ {
@ -310,6 +330,26 @@ get_gpgconf_item (int what)
_gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: gpgsm='%s'\n", "gpgme-dinfo: gpgsm='%s'\n",
dirinfo.gpgsm_name); dirinfo.gpgsm_name);
if (dirinfo.keyboxd_name)
_gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: keyboxd='%s'\n",
dirinfo.keyboxd_name);
if (dirinfo.agent_name)
_gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: gpg-agent='%s'\n",
dirinfo.agent_name);
if (dirinfo.scdaemon_name)
_gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: scdaemon='%s'\n",
dirinfo.scdaemon_name);
if (dirinfo.dirmngr_name)
_gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: dirmngr='%s'\n",
dirinfo.dirmngr_name);
if (dirinfo.pinentry_name)
_gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: pinentry='%s'\n",
dirinfo.pinentry_name);
if (dirinfo.homedir) if (dirinfo.homedir)
_gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: homedir='%s'\n", "gpgme-dinfo: homedir='%s'\n",
@ -352,6 +392,11 @@ get_gpgconf_item (int what)
case WANT_GPG_NAME: result = dirinfo.gpg_name; break; case WANT_GPG_NAME: result = dirinfo.gpg_name; break;
case WANT_GPGSM_NAME: result = dirinfo.gpgsm_name; break; case WANT_GPGSM_NAME: result = dirinfo.gpgsm_name; break;
case WANT_G13_NAME: result = dirinfo.g13_name; break; case WANT_G13_NAME: result = dirinfo.g13_name; break;
case WANT_KEYBOXD_NAME: result = dirinfo.keyboxd_name; break;
case WANT_AGENT_NAME: result = dirinfo.agent_name; break;
case WANT_SCDAEMON_NAME: result = dirinfo.scdaemon_name; break;
case WANT_DIRMNGR_NAME: result = dirinfo.dirmngr_name; break;
case WANT_PINENTRY_NAME: result = dirinfo.pinentry_name; break;
case WANT_UISRV_SOCKET: result = dirinfo.uisrv_socket; break; case WANT_UISRV_SOCKET: result = dirinfo.uisrv_socket; break;
case WANT_GPG_ONE_MODE: result = dirinfo.gpg_one_mode? "1":NULL; break; case WANT_GPG_ONE_MODE: result = dirinfo.gpg_one_mode? "1":NULL; break;
case WANT_GPG_WKS_CLIENT_NAME: case WANT_GPG_WKS_CLIENT_NAME:
@ -467,6 +512,16 @@ gpgme_get_dirinfo (const char *what)
return get_gpgconf_item (WANT_GPGSM_NAME); return get_gpgconf_item (WANT_GPGSM_NAME);
else if (!strcmp (what, "g13-name")) else if (!strcmp (what, "g13-name"))
return get_gpgconf_item (WANT_G13_NAME); return get_gpgconf_item (WANT_G13_NAME);
else if (!strcmp (what, "keyboxd-name"))
return get_gpgconf_item (WANT_KEYBOXD_NAME);
else if (!strcmp (what, "agent-name"))
return get_gpgconf_item (WANT_AGENT_NAME);
else if (!strcmp (what, "scdaemon-name"))
return get_gpgconf_item (WANT_SCDAEMON_NAME);
else if (!strcmp (what, "dirmngr-name"))
return get_gpgconf_item (WANT_DIRMNGR_NAME);
else if (!strcmp (what, "pinentry-name"))
return get_gpgconf_item (WANT_PINENTRY_NAME);
else if (!strcmp (what, "gpg-wks-client-name")) else if (!strcmp (what, "gpg-wks-client-name"))
return get_gpgconf_item (WANT_GPG_WKS_CLIENT_NAME); return get_gpgconf_item (WANT_GPG_WKS_CLIENT_NAME);
else if (!strcmp (what, "agent-ssh-socket")) else if (!strcmp (what, "agent-ssh-socket"))

View File

@ -127,6 +127,11 @@ main (int argc, char **argv )
"gpg-name", "gpg-name",
"gpgsm-name", "gpgsm-name",
"g13-name", "g13-name",
"keyboxd-name",
"agent-name",
"scdaemon-name",
"dirmngr-name",
"pinentry-name",
"gpg-wks-client-name", "gpg-wks-client-name",
NULL }; NULL };
const char *s; const char *s;