From eb37d6469e722ae5ff187962c216474b5ec476de Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 22 Sep 2021 10:18:30 +0200 Subject: [PATCH] core: Support dirinfo("socketdir") * src/dirinfo.c (WANT_SOCKETDIR): New. (dirinfo): Add field socketdir. (parse_output): Support "socketdir". (get_gpgconf_item): Return socketdir. * tests/t-engine-info.c (main): Add socketdir to the output. * src/w32-util.c (_gpgme_create_process_utf8): Fix indentation. -- GnuPG-bug-id: 5613 This is not strictly necessary because we could deduce this from one of the other socket info items but it is more clean to have a dedicated info item. The socketdir item is available for 5 years now (GnuPG commit 8e3fa5a4b205c534de2142e5d071712f957cf06a) --- lang/cpp/src/global.h | 2 +- src/dirinfo.c | 11 +++++++++++ src/w32-util.c | 21 +++++++++++---------- tests/t-engine-info.c | 1 + 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lang/cpp/src/global.h b/lang/cpp/src/global.h index 7d9f9d66..d7430e2b 100644 --- a/lang/cpp/src/global.h +++ b/lang/cpp/src/global.h @@ -91,7 +91,7 @@ GPGMEPP_EXPORT EngineInfo engineInfo(Engine engine); homedir, sysconfdir, bindir, libexecdir, libdir, datadir, localedir, agent-socket, agent-ssh-socket, dirmngr-socket, uiserver-socket, gpgconf-name, gpg-name, -gpgsm-name, g13-name +gpgsm-name, g13-name, socketdir. This may be extended in the future. */ diff --git a/src/dirinfo.c b/src/dirinfo.c index c4f0e4a0..c6b7d718 100644 --- a/src/dirinfo.c +++ b/src/dirinfo.c @@ -44,6 +44,7 @@ enum WANT_LIBDIR, WANT_DATADIR, WANT_LOCALEDIR, + WANT_SOCKETDIR, WANT_AGENT_SOCKET, WANT_AGENT_SSH_SOCKET, WANT_DIRMNGR_SOCKET, @@ -67,6 +68,7 @@ static struct { char *libdir; char *datadir; char *localedir; + char *socketdir; char *agent_socket; char *agent_ssh_socket; char *dirmngr_socket; @@ -152,6 +154,8 @@ parse_output (char *line, int components) dirinfo.datadir = strdup (value); else if (!strcmp (line, "localedir") && !dirinfo.localedir) dirinfo.localedir = strdup (value); + else if (!strcmp (line, "socketdir") && !dirinfo.socketdir) + dirinfo.socketdir = strdup (value); else if (!strcmp (line, "agent-socket") && !dirinfo.agent_socket) { const char name[] = "S.uiserver"; @@ -310,6 +314,10 @@ get_gpgconf_item (int what) _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: homedir='%s'\n", dirinfo.homedir); + if (dirinfo.socketdir) + _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL, + "gpgme-dinfo: sockdir='%s'\n", + dirinfo.socketdir); if (dirinfo.agent_socket) _gpgme_debug (NULL,DEBUG_INIT, -1, NULL, NULL, NULL, "gpgme-dinfo: agent='%s'\n", @@ -336,6 +344,7 @@ get_gpgconf_item (int what) case WANT_LIBDIR: result = dirinfo.libdir; break; case WANT_DATADIR: result = dirinfo.datadir; break; case WANT_LOCALEDIR: result = dirinfo.localedir; break; + case WANT_SOCKETDIR: result = dirinfo.socketdir; break; case WANT_AGENT_SOCKET: result = dirinfo.agent_socket; break; case WANT_AGENT_SSH_SOCKET: result = dirinfo.agent_ssh_socket; break; case WANT_DIRMNGR_SOCKET: result = dirinfo.dirmngr_socket; break; @@ -476,6 +485,8 @@ gpgme_get_dirinfo (const char *what) return get_gpgconf_item (WANT_DATADIR); else if (!strcmp (what, "localedir")) return get_gpgconf_item (WANT_LOCALEDIR); + else if (!strcmp (what, "socketdir")) + return get_gpgconf_item (WANT_SOCKETDIR); else return NULL; } diff --git a/src/w32-util.c b/src/w32-util.c index 2631ae7c..e4757a21 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -841,16 +841,17 @@ _gpgme_access (const char *path, int mode) /* Like CreateProcessA but mapping the arguments to wchar API */ -int _gpgme_create_process_utf8 (const char *application_name_utf8, - char *command_line_utf8, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - void *lpEnvironment, - char *working_directory_utf8, - LPSTARTUPINFOA si, - LPPROCESS_INFORMATION lpProcessInformation) +int +_gpgme_create_process_utf8 (const char *application_name_utf8, + char *command_line_utf8, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, + DWORD dwCreationFlags, + void *lpEnvironment, + char *working_directory_utf8, + LPSTARTUPINFOA si, + LPPROCESS_INFORMATION lpProcessInformation) { BOOL ret; wchar_t *application_name = utf8_to_wchar0 (application_name_utf8); diff --git a/tests/t-engine-info.c b/tests/t-engine-info.c index db46bf86..654cf843 100644 --- a/tests/t-engine-info.c +++ b/tests/t-engine-info.c @@ -118,6 +118,7 @@ main (int argc, char **argv ) "libdir", "datadir", "localedir", + "socketdir", "agent-socket", "agent-ssh-socket", "dirmngr-socket",