core: Extend gpgme_get_dirinfo to return the gpgtar name

* src/dirinfo.c (WANT_GPGTAR_NAME): New.
(dirinfo): Add field gpgtar_name.
(get_gpgconf_item): Build gpgtar_name on demand and return it.
(_gpgme_get_default_gpgtar_name) : New.
(gpgme_get_dirinfo): New value "gpgtar-name" for WHAT.
* src/util.h (_gpgme_get_default_gpgtar_name): New.

* tests/t-engine-info.c (main): Add gpgtar-name to the output.

GnuPG-bug-id: 6342
This commit is contained in:
Ingo Klöcker 2023-01-18 10:30:17 +01:00
parent fbce7deb3b
commit 12e490d97f
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
4 changed files with 24 additions and 0 deletions

View File

@ -1024,6 +1024,9 @@ 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.
@item gpgtar-name
Return the name of the gpgtar program.
@end table @end table
@end deftypefun @end deftypefun

View File

@ -59,6 +59,7 @@ enum
WANT_DIRMNGR_NAME, WANT_DIRMNGR_NAME,
WANT_PINENTRY_NAME, WANT_PINENTRY_NAME,
WANT_GPG_WKS_CLIENT_NAME, WANT_GPG_WKS_CLIENT_NAME,
WANT_GPGTAR_NAME,
WANT_GPG_ONE_MODE WANT_GPG_ONE_MODE
}; };
@ -88,6 +89,7 @@ static struct {
char *dirmngr_name; char *dirmngr_name;
char *pinentry_name; char *pinentry_name;
char *gpg_wks_client_name; char *gpg_wks_client_name;
char *gpgtar_name;
int gpg_one_mode; /* System is in gpg1 mode. */ int gpg_one_mode; /* System is in gpg1 mode. */
} dirinfo; } dirinfo;
@ -407,6 +409,14 @@ get_gpgconf_item (int what)
NULL); NULL);
result = dirinfo.gpg_wks_client_name; result = dirinfo.gpg_wks_client_name;
break; break;
case WANT_GPGTAR_NAME:
if (!dirinfo.gpgtar_name && dirinfo.bindir)
dirinfo.gpgtar_name = _gpgme_strconcat (dirinfo.bindir,
"/",
"gpgtar",
NULL);
result = dirinfo.gpgtar_name;
break;
} }
UNLOCK (dirinfo_lock); UNLOCK (dirinfo_lock);
return result; return result;
@ -455,6 +465,13 @@ _gpgme_get_default_gpgconf_name (void)
return get_gpgconf_item (WANT_GPGCONF_NAME); return get_gpgconf_item (WANT_GPGCONF_NAME);
} }
/* Return the default gpgtar file name. Returns NULL if not known. */
const char *
_gpgme_get_default_gpgtar_name (void)
{
return get_gpgconf_item (WANT_GPGTAR_NAME);
}
/* Return the default UI-server socket name. Returns NULL if not /* Return the default UI-server socket name. Returns NULL if not
known. */ known. */
const char * const char *
@ -524,6 +541,8 @@ gpgme_get_dirinfo (const char *what)
return get_gpgconf_item (WANT_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, "gpgtar-name"))
return get_gpgconf_item (WANT_GPGTAR_NAME);
else if (!strcmp (what, "agent-ssh-socket")) else if (!strcmp (what, "agent-ssh-socket"))
return get_gpgconf_item (WANT_AGENT_SSH_SOCKET); return get_gpgconf_item (WANT_AGENT_SSH_SOCKET);
else if (!strcmp (what, "dirmngr-socket")) else if (!strcmp (what, "dirmngr-socket"))

View File

@ -56,6 +56,7 @@ const char *_gpgme_get_default_gpg_name (void);
const char *_gpgme_get_default_gpgsm_name (void); const char *_gpgme_get_default_gpgsm_name (void);
const char *_gpgme_get_default_g13_name (void); const char *_gpgme_get_default_g13_name (void);
const char *_gpgme_get_default_gpgconf_name (void); const char *_gpgme_get_default_gpgconf_name (void);
const char *_gpgme_get_default_gpgtar_name (void);
const char *_gpgme_get_default_uisrv_socket (void); const char *_gpgme_get_default_uisrv_socket (void);
int _gpgme_in_gpg_one_mode (void); int _gpgme_in_gpg_one_mode (void);

View File

@ -133,6 +133,7 @@ main (int argc, char **argv )
"dirmngr-name", "dirmngr-name",
"pinentry-name", "pinentry-name",
"gpg-wks-client-name", "gpg-wks-client-name",
"gpgtar-name",
NULL }; NULL };
const char *s; const char *s;
int i; int i;