diff options
author | Werner Koch <[email protected]> | 2020-01-13 14:20:49 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-01-13 14:20:49 +0000 |
commit | 14aa797bb8f3f7d3f4ef66b8fcdac7439000b49a (patch) | |
tree | 567994ec316fd28c8efa2c9b1849a4cd43052592 | |
parent | scd: Fix memory leak in command READKEY. (diff) | |
download | gnupg-14aa797bb8f3f7d3f4ef66b8fcdac7439000b49a.tar.gz gnupg-14aa797bb8f3f7d3f4ef66b8fcdac7439000b49a.zip |
gpg,sm: Avoid useless ASFW diagnostic in loopback mode.
* common/sysutils.c (inhibit_set_foregound_window): New var.
(gnupg_inhibit_set_foregound_window): New func.
(gnupg_allow_set_foregound_window): Use var.
* g10/gpg.c (main): Inhibit in loopback mode.
* sm/gpgsm.c (main): Ditto.
--
Signed-off-by: Werner Koch <[email protected]>
-rw-r--r-- | common/sysutils.c | 21 | ||||
-rw-r--r-- | common/sysutils.h | 1 | ||||
-rw-r--r-- | g10/gpg.c | 9 | ||||
-rw-r--r-- | sm/gpgsm.c | 8 |
4 files changed, 39 insertions, 0 deletions
diff --git a/common/sysutils.c b/common/sysutils.c index f2abd924e..df8ce9d1b 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -87,6 +87,11 @@ * an explanation of these file names. */ static int allow_special_filenames; +#ifdef HAVE_W32_SYSTEM +/* State of gnupg_inhibit_set_foregound_window. */ +static int inhibit_set_foregound_window; +#endif + static GPGRT_INLINE gpg_error_t my_error_from_syserror (void) @@ -612,6 +617,20 @@ gnupg_reopen_std (const char *pgmname) } +/* Inhibit calls to AllowSetForegroundWindow on Windows. Calling this + * with YES set to true calls to gnupg_allow_set_foregound_window are + * shunted. */ +void +gnupg_inhibit_set_foregound_window (int yes) +{ +#ifdef HAVE_W32_SYSTEM + inhibit_set_foregound_window = yes; +#else + (void)yes; +#endif +} + + /* Hack required for Windows. */ void gnupg_allow_set_foregound_window (pid_t pid) @@ -620,6 +639,8 @@ gnupg_allow_set_foregound_window (pid_t pid) log_info ("%s called with invalid pid %lu\n", "gnupg_allow_set_foregound_window", (unsigned long)pid); #if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM) + else if (inhibit_set_foregound_window) + ; else if (!AllowSetForegroundWindow ((pid_t)pid == (pid_t)(-1)?ASFW_ANY:pid)) log_info ("AllowSetForegroundWindow(%lu) failed: %s\n", (unsigned long)pid, w32_strerror (-1)); diff --git a/common/sysutils.h b/common/sysutils.h index 009b14b4a..c51bf7a9f 100644 --- a/common/sysutils.h +++ b/common/sysutils.h @@ -61,6 +61,7 @@ int translate_sys2libc_fd_int (int fd, int for_write); int check_special_filename (const char *fname, int for_write, int notranslate); FILE *gnupg_tmpfile (void); void gnupg_reopen_std (const char *pgmname); +void gnupg_inhibit_set_foregound_window (int yes); void gnupg_allow_set_foregound_window (pid_t pid); int gnupg_remove (const char *fname); gpg_error_t gnupg_rename_file (const char *oldname, const char *newname, @@ -4167,6 +4167,15 @@ main (int argc, char **argv) opt.passphrase_repeat = 0; } + /* If no pinentry is expected shunt + * gnupg_allow_set_foregound_window to avoid useless error + * messages on Windows. */ + if (opt.pinentry_mode != PINENTRY_MODE_ASK) + { + gnupg_inhibit_set_foregound_window (1); + } + + if (cmd == aGPGConfTest) g10_exit(0); diff --git a/sm/gpgsm.c b/sm/gpgsm.c index 2cd3b0c4f..2f4470ec0 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -1737,6 +1737,14 @@ main ( int argc, char **argv) if (!cmd && opt.fingerprint && !with_fpr) set_cmd (&cmd, aListKeys); + /* If no pinentry is expected shunt + * gnupg_allow_set_foregound_window to avoid useless error + * messages on Windows. */ + if (opt.pinentry_mode != PINENTRY_MODE_ASK) + { + gnupg_inhibit_set_foregound_window (1); + } + /* Add default keybox. */ if (!nrings && default_keyring) { |