w32: Expect gpgme-w32spawn.exe only in the gpgme installation dir.

* src/w32-util.c (find_program_at_standard_place): Remove.
(_gpgme_get_gpg_path): Make the search order more explicit.
(_gpgme_get_gpgconf_path): Ditto.
(_gpgme_get_w32spawn_path): Search only in the inst_dir.
--

This tries to avoid possible unclear bug reports by removing the
fallback to the current gpg4win installation directory for the gpgme
helper.  It is expected that users of gpgme installing their own gpgme
version also install the matching helper.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2015-08-24 16:34:29 +02:00
parent df098d6a43
commit 06d6fd8ca0
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -397,40 +397,6 @@ find_program_in_dir (const char *dir, const char *name)
} }
static char *
find_program_in_inst_dir (const char *inst_dir, const char *name)
{
char *result;
char *dir;
/* If an installation directory has been passed, this overrides a
location given by the registry. The idea here is that we prefer
a program installed alongside with gpgme. We don't want the
registry to override this to have a better isolation of an gpgme
aware applications for other effects. Note that the "Install
Directory" registry item has been used for ages in Gpg4win and
earlier GnuPG windows installers. It is technically not anymore
required. */
if (inst_dir)
{
result = find_program_in_dir (inst_dir, name);
if (result)
return result;
}
dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
"Software\\GNU\\GnuPG",
"Install Directory");
if (dir)
{
result = find_program_in_dir (dir, name);
free (dir);
return result;
}
return NULL;
}
static char * static char *
find_program_at_standard_place (const char *name) find_program_at_standard_place (const char *name)
{ {
@ -491,29 +457,50 @@ _gpgme_set_default_gpgconf_name (const char *name)
/* Return the full file name of the GPG binary. This function is used /* Return the full file name of the GPG binary. This function is used
if gpgconf was not found and thus it can be assumed that gpg2 is iff gpgconf was not found and thus it can be assumed that gpg2 is
not installed. This function is only called by get_gpgconf_item not installed. This function is only called by get_gpgconf_item
and may not be called concurrently. */ and may not be called concurrently. */
char * char *
_gpgme_get_gpg_path (void) _gpgme_get_gpg_path (void)
{ {
char *gpg; char *gpg = NULL;
const char *inst_dir, *name; const char *name, *inst_dir;
name = default_gpg_name? get_basename (default_gpg_name) : "gpg.exe";
/* 1. Try to find gpg.exe in the installation directory of gpgme. */
inst_dir = _gpgme_get_inst_dir (); inst_dir = _gpgme_get_inst_dir ();
gpg = find_program_in_inst_dir if (inst_dir)
(inst_dir, {
default_gpg_name? get_basename (default_gpg_name) : "gpg.exe"); gpg = find_program_in_dir (inst_dir, name);
}
/* 2. Try to find gpg.exe using that ancient registry key. */
if (!gpg) if (!gpg)
{ {
name = (default_gpg_name? default_gpg_name char *dir;
/* */ : "GNU\\GnuPG\\gpg.exe");
gpg = find_program_at_standard_place (name); dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
if (!gpg) "Software\\GNU\\GnuPG",
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpg_path: '%s' not found", "Install Directory");
name); if (dir)
{
gpg = find_program_in_dir (dir, name);
free (dir);
}
} }
/* 3. Try to find gpg.exe below CSIDL_PROGRAM_FILES. */
if (!gpg)
{
name = default_gpg_name? default_gpg_name : "GNU\\GnuPG\\gpg.exe";
gpg = find_program_at_standard_place (name);
}
/* 4. Print a debug message if not found. */
if (!gpg)
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpg_path: '%s' not found", name);
return gpg; return gpg;
} }
@ -523,22 +510,45 @@ _gpgme_get_gpg_path (void)
char * char *
_gpgme_get_gpgconf_path (void) _gpgme_get_gpgconf_path (void)
{ {
char *gpgconf; char *gpgconf = NULL;
const char *inst_dir, *name; const char *inst_dir, *name;
name = default_gpgconf_name? get_basename(default_gpgconf_name):"gpgconf.exe";
/* 1. Try to find gpgconf.exe in the installation directory of gpgme. */
inst_dir = _gpgme_get_inst_dir (); inst_dir = _gpgme_get_inst_dir ();
gpgconf = find_program_in_inst_dir if (inst_dir)
(inst_dir, {
default_gpgconf_name? get_basename (default_gpgconf_name) : "gpgconf.exe"); gpgconf = find_program_in_dir (inst_dir, name);
}
/* 2. Try to find gpgconf.exe using that ancient registry key. */
if (!gpgconf) if (!gpgconf)
{ {
name = (default_gpgconf_name? default_gpgconf_name char *dir;
/* */ : "GNU\\GnuPG\\gpgconf.exe");
gpgconf = find_program_at_standard_place (name); dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
if (!gpgconf) "Software\\GNU\\GnuPG",
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpgconf_path: '%s' not found", "Install Directory");
name); if (dir)
{
gpgconf = find_program_in_dir (dir, name);
free (dir);
}
} }
/* 3. Try to find gpgconf.exe below CSIDL_PROGRAM_FILES. */
if (!gpgconf)
{
name = (default_gpgconf_name ? default_gpgconf_name
/**/ : "GNU\\GnuPG\\gpgconf.exe");
gpgconf = find_program_at_standard_place (name);
}
/* 4. Print a debug message if not found. */
if (!gpgconf)
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpgconf_path: '%s' not found",name);
return gpgconf; return gpgconf;
} }
@ -552,10 +562,7 @@ _gpgme_get_w32spawn_path (void)
inst_dir = _gpgme_get_inst_dir (); inst_dir = _gpgme_get_inst_dir ();
LOCK (get_path_lock); LOCK (get_path_lock);
if (!w32spawn_program) if (!w32spawn_program)
w32spawn_program = find_program_in_inst_dir (inst_dir,"gpgme-w32spawn.exe"); w32spawn_program = find_program_in_dir (inst_dir, "gpgme-w32spawn.exe");
if (!w32spawn_program)
w32spawn_program
= find_program_at_standard_place ("GNU\\GnuPG\\gpgme-w32spawn.exe");
UNLOCK (get_path_lock); UNLOCK (get_path_lock);
return w32spawn_program; return w32spawn_program;
} }