core,w32: Show w32-spawn warning only once

* src/w32-io.c (_gpgme_io_spawn): Show MessageBox only once.

--
This prevents multiple message boxes from showing when
the GPGME installation is unworkable.

GnuPG-Bug-Id: T4453
This commit is contained in:
Andre Heinecke 2019-04-09 13:25:08 +02:00
parent 4a4680f890
commit 937adfdcbb
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -1389,6 +1389,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
int tmp_fd; int tmp_fd;
char *tmp_name; char *tmp_name;
const char *spawnhelper; const char *spawnhelper;
static int spawn_warning_shown = 0;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_spawn", path, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_spawn", path,
"path=%s", path); "path=%s", path);
@ -1456,20 +1457,24 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
up their installation this should also be properly communicated up their installation this should also be properly communicated
as otherwise calls to gnupg will result in unsupported protocol as otherwise calls to gnupg will result in unsupported protocol
errors that do not explain a lot. */ errors that do not explain a lot. */
char *msg; if (!spawn_warning_shown)
gpgrt_asprintf (&msg, "gpgme-w32spawn.exe was not found in the " {
"detected installation directory of GpgME" char *msg;
"\n\t\"%s\"\n\n" gpgrt_asprintf (&msg, "gpgme-w32spawn.exe was not found in the "
"Crypto operations will not work.\n\n" "detected installation directory of GpgME"
"If you see this it indicates a problem " "\n\t\"%s\"\n\n"
"with your installation.\n" "Crypto operations will not work.\n\n"
"Please report the problem to your " "If you see this it indicates a problem "
"distributor of GpgME.\n\n" "with your installation.\n"
"Developer's Note: The install dir can be " "Please report the problem to your "
"manually set with: gpgme_set_global_flag", "distributor of GpgME.\n\n"
_gpgme_get_inst_dir ()); "Developer's Note: The install dir can be "
MessageBoxA (NULL, msg, "GpgME not installed correctly", MB_OK); "manually set with: gpgme_set_global_flag",
gpgrt_free (msg); _gpgme_get_inst_dir ());
MessageBoxA (NULL, msg, "GpgME not installed correctly", MB_OK);
gpgrt_free (msg);
spawn_warning_shown = 1;
}
gpg_err_set_errno (EIO); gpg_err_set_errno (EIO);
close (tmp_fd); close (tmp_fd);
DeleteFileA (tmp_name); DeleteFileA (tmp_name);