core, w32: Add w64 handling for regkeys

* src/w32-util.c (_gpgme_get_gpg_path): Use new defines.
(GNUPG_REGKEY_2): x64 aware regkey as used by GnuPG in Gpg4win 2.x
(GNUPG_REGKEY_3): x64 aware regkey as used by GnuPG in Gpg4win 3.x
(_gpgme_get_gpgconf_path): Use new regkeys. Add another fallback.

--
This should fix more "unsupported protocol" issues if Gpg4win /
GnuPG is installed in a non standard path on 64bit systems.

The regkey handling is similar to that of gpgex and gpgol.

GnuPG-Bug-Id: T3988
This commit is contained in:
Andre Heinecke 2018-05-17 17:41:53 +02:00
parent 8a0c8c5251
commit e04b8142df
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -72,6 +72,17 @@
# define F_OK 0
#endif
/* The Registry key used by GNUPG. */
#ifdef _WIN64
# define GNUPG_REGKEY_2 "Software\\Wow6432Node\\GNU\\GnuPG"
#else
# define GNUPG_REGKEY_2 "Software\\GNU\\GnuPG"
#endif
#ifdef _WIN64
# define GNUPG_REGKEY_3 "Software\\Wow6432Node\\GnuPG"
#else
# define GNUPG_REGKEY_3 "Software\\GnuPG"
#endif
DEFINE_STATIC_LOCK (get_path_lock);
@ -513,7 +524,7 @@ _gpgme_get_gpg_path (void)
char *dir;
dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
"Software\\GNU\\GnuPG",
GNUPG_REGKEY_2,
"Install Directory");
if (dir)
{
@ -568,12 +579,12 @@ _gpgme_get_gpgconf_path (void)
char *dir;
dir = read_w32_registry_string (NULL,
"Software\\GNU\\GnuPG",
GNUPG_REGKEY_2,
"Install Directory");
if (!dir)
{
char *tmp = read_w32_registry_string (NULL,
"Software\\GnuPG",
GNUPG_REGKEY_3,
"Install Directory");
if (tmp)
{
@ -596,6 +607,14 @@ _gpgme_get_gpgconf_path (void)
gpgconf = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe");
}
/* 5. Try to find gpgconf.exe relative to us. */
if (!gpgconf && inst_dir)
{
char *dir = _gpgme_strconcat (inst_dir, "\\..\\..\\GnuPG\\bin");
gpgconf = find_program_in_dir (dir, name);
free (dir);
}
/* 5. Print a debug message if not found. */
if (!gpgconf)
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpgconf_path: '%s' not found",name);