From 12e490d97f2e7064bc9b5bea0d197790d10db106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Wed, 18 Jan 2023 10:30:17 +0100 Subject: [PATCH] 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 --- doc/gpgme.texi | 3 +++ src/dirinfo.c | 19 +++++++++++++++++++ src/util.h | 1 + tests/t-engine-info.c | 1 + 4 files changed, 24 insertions(+) diff --git a/doc/gpgme.texi b/doc/gpgme.texi index f19b8325..eeb865aa 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -1024,6 +1024,9 @@ Return the name of the pinentry program. @item gpg-wks-client-name Return the name of the Web Key Service tool. +@item gpgtar-name +Return the name of the gpgtar program. + @end table @end deftypefun diff --git a/src/dirinfo.c b/src/dirinfo.c index 8ea15d81..60e536f5 100644 --- a/src/dirinfo.c +++ b/src/dirinfo.c @@ -59,6 +59,7 @@ enum WANT_DIRMNGR_NAME, WANT_PINENTRY_NAME, WANT_GPG_WKS_CLIENT_NAME, + WANT_GPGTAR_NAME, WANT_GPG_ONE_MODE }; @@ -88,6 +89,7 @@ static struct { char *dirmngr_name; char *pinentry_name; char *gpg_wks_client_name; + char *gpgtar_name; int gpg_one_mode; /* System is in gpg1 mode. */ } dirinfo; @@ -407,6 +409,14 @@ get_gpgconf_item (int what) NULL); result = dirinfo.gpg_wks_client_name; 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); return result; @@ -455,6 +465,13 @@ _gpgme_get_default_gpgconf_name (void) 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 known. */ const char * @@ -524,6 +541,8 @@ gpgme_get_dirinfo (const char *what) return get_gpgconf_item (WANT_PINENTRY_NAME); else if (!strcmp (what, "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")) return get_gpgconf_item (WANT_AGENT_SSH_SOCKET); else if (!strcmp (what, "dirmngr-socket")) diff --git a/src/util.h b/src/util.h index 89075848..90213b10 100644 --- a/src/util.h +++ b/src/util.h @@ -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_g13_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); int _gpgme_in_gpg_one_mode (void); diff --git a/tests/t-engine-info.c b/tests/t-engine-info.c index 3f8d0037..1a351391 100644 --- a/tests/t-engine-info.c +++ b/tests/t-engine-info.c @@ -133,6 +133,7 @@ main (int argc, char **argv ) "dirmngr-name", "pinentry-name", "gpg-wks-client-name", + "gpgtar-name", NULL }; const char *s; int i;