diff options
author | Werner Koch <[email protected]> | 2015-02-04 09:09:28 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-02-04 09:28:38 +0000 |
commit | 0de5c6a9a783ed9dc69cecbf34eadcaace4be243 (patch) | |
tree | 62db1cc6a50ba5448a0dbe352e6b721efbca0d76 /common | |
parent | w32: Add manifest to gpg. (diff) | |
download | gnupg-0de5c6a9a783ed9dc69cecbf34eadcaace4be243.tar.gz gnupg-0de5c6a9a783ed9dc69cecbf34eadcaace4be243.zip |
gpg-agent: Use "pinentry-basic" as fallback.
* common/homedir.c (get_default_pinentry_name): New.
(gnupg_module_name): Use that for the default pinentry.
(gnupg_module_name_flush_some): New.
* agent/gpg-agent.c (agent_sighup_action): Flush some module names.
* agent/call-pinentry.c (start_pinentry): Do not modify
opt.pinentry_program.
--
The idea with this change is that under Windows we can install a
simple native Windows pinentry as "pinentry-basic" and a full GUI
version may then later install pinentry-gtk etc which would then
automatically be used.
Unfortunately installing another pinentry from a different package
would clobber the GnuPG core directory which is not nice. To fix that
we would need to agree on standard installation directories for GUIs
to also look there.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'common')
-rw-r--r-- | common/homedir.c | 49 | ||||
-rw-r--r-- | common/util.h | 1 |
2 files changed, 48 insertions, 2 deletions
diff --git a/common/homedir.c b/common/homedir.c index 27141eb75..e3efcee7b 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -32,6 +32,7 @@ #include <stdlib.h> #include <errno.h> #include <fcntl.h> +#include <unistd.h> #ifdef HAVE_W32_SYSTEM #include <winsock2.h> /* Due to the stupid mingw64 requirement to @@ -607,6 +608,41 @@ dirmngr_user_socket_name (void) } +/* Return the default pinentry name. If RESET is true the internal + cache is first flushed. */ +static const char * +get_default_pinentry_name (int reset) +{ + static char *name; + + if (reset) + { + xfree (name); + name = NULL; + } + + if (!name) + { + name = xstrconcat (gnupg_bindir (), + DIRSEP_S "pinentry" EXEEXT_S, NULL); + if (access (name, F_OK) && errno == ENOENT) + { + char *name2; + name2 = xstrconcat (gnupg_bindir (), + DIRSEP_S "pinentry-basic" EXEEXT_S, NULL); + if (access (name2, F_OK)) + xfree (name2); /* Does not exist. */ + else /* Switch to pinentry-basic. */ + { + xfree (name); + name = name2; + } + } + } + return name; +} + + /* Return the file name of a helper tool. WHICH is one of the GNUPG_MODULE_NAME_foo constants. */ const char * @@ -630,9 +666,9 @@ gnupg_module_name (int which) case GNUPG_MODULE_NAME_PINENTRY: #ifdef GNUPG_DEFAULT_PINENTRY - return GNUPG_DEFAULT_PINENTRY; + return GNUPG_DEFAULT_PINENTRY; /* (Set by a configure option) */ #else - X(bindir, "pinentry"); + return get_default_pinentry_name (0); #endif case GNUPG_MODULE_NAME_SCDAEMON: @@ -683,3 +719,12 @@ gnupg_module_name (int which) } #undef X } + + +/* Flush some of the cached module names. This is for example used by + gpg-agent to allow configuring a different pinentry. */ +void +gnupg_module_name_flush_some (void) +{ + (void)get_default_pinentry_name (1); +} diff --git a/common/util.h b/common/util.h index 24107f533..9103e094b 100644 --- a/common/util.h +++ b/common/util.h @@ -254,6 +254,7 @@ const char *dirmngr_user_socket_name (void); #define GNUPG_MODULE_NAME_GPGCONF 10 #define GNUPG_MODULE_NAME_DIRMNGR_LDAP 11 const char *gnupg_module_name (int which); +void gnupg_module_name_flush_some (void); |