diff options
author | Werner Koch <wk@gnupg.org> | 2004-08-18 14:47:33 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2004-08-18 14:47:33 +0200 |
commit | aac85ca3141533d3dae12f82d2189a63ec981d1b (patch) | |
tree | 7c60bc944eca4b090d83a7bf88ba1e79eca33502 /agent | |
parent | 2004-08-18 Marcus Brinkmann <marcus@g10code.de> (diff) | |
download | gnupg2-aac85ca3141533d3dae12f82d2189a63ec981d1b.tar.xz gnupg2-aac85ca3141533d3dae12f82d2189a63ec981d1b.zip |
(get_passphrase): Make sure that the default
prompts passed to gpg-agent are utf-8 encoded.
Diffstat (limited to 'agent')
-rw-r--r-- | agent/ChangeLog | 5 | ||||
-rw-r--r-- | agent/protect-tool.c | 34 |
2 files changed, 39 insertions, 0 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog index d616b1544..8305ec4af 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,8 @@ +2004-08-18 Werner Koch <wk@g10code.de> + + * protect-tool.c (get_passphrase): Make sure that the default + prompts passed to gpg-agent are utf-8 encoded. + 2004-07-22 Werner Koch <wk@g10code.de> * trustlist.c (read_list): Allow colons in the fingerprint. diff --git a/agent/protect-tool.c b/agent/protect-tool.c index c33d21094..d4c2accfc 100644 --- a/agent/protect-tool.c +++ b/agent/protect-tool.c @@ -29,6 +29,12 @@ #include <assert.h> #include <sys/stat.h> #include <unistd.h> +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif +#ifdef HAVE_LANGINFO_CODESET +#include <langinfo.h> +#endif #define JNLIB_NEED_LOG_LOGV #include "agent.h" @@ -1138,10 +1144,29 @@ get_passphrase (int promptno) char *pw; int err; const char *desc; + char *orig_codeset = NULL; if (opt_passphrase) return xstrdup (opt_passphrase); +#ifdef ENABLE_NLS + /* The Assuan agent protocol requires us to transmit utf-8 strings */ + orig_codeset = bind_textdomain_codeset (PACKAGE_GT, NULL); +#ifdef HAVE_LANGINFO_CODESET + if (!orig_codeset) + orig_codeset = nl_langinfo (CODESET); +#endif + if (orig_codeset && !strcmp (orig_codeset, "UTF-8")) + orig_codeset = NULL; + if (orig_codeset) + { + /* We only switch when we are able to restore the codeset later. */ + orig_codeset = xstrdup (orig_codeset); + if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) + orig_codeset = NULL; + } +#endif + if (promptno == 1 && opt_prompt) desc = opt_prompt; else @@ -1149,6 +1174,15 @@ get_passphrase (int promptno) "needed to complete this operation."); pw = simple_pwquery (NULL,NULL, _("Passphrase:"), desc, &err); + +#ifdef ENABLE_NLS + if (orig_codeset) + { + bind_textdomain_codeset (PACKAGE_GT, orig_codeset); + xfree (orig_codeset); + } +#endif + if (!pw) { if (err) |