diff options
author | Werner Koch <[email protected]> | 2002-04-25 08:30:35 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2002-04-25 08:30:35 +0000 |
commit | ecbf6f4d46d0ab77755546c221d45268eb03da94 (patch) | |
tree | 88e7b45b2b875650756a25c64ab73f3357498b77 | |
parent | Update NEWS with recent changes (diff) | |
download | gnupg-ecbf6f4d46d0ab77755546c221d45268eb03da94.tar.gz gnupg-ecbf6f4d46d0ab77755546c221d45268eb03da94.zip |
g10/
* g10.c, options.h: New options --display, --ttyname, --ttytype,
--lc-ctype, --lc-messages to be used with future versions of the
gpg-agent.
* passphrase.c (agent_send_option,agent_send_all_options): New.
(agent_open): Send options to the agent.
* trustdb.c (update_ownertrust, clear_ownertrust): Do an explicit
do_sync because revalidation_mark does it only if when the
timestamp actually changes.
/
* configure.ac: Check for locale.h and setlocale
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | g10/ChangeLog | 12 | ||||
-rw-r--r-- | g10/g10.c | 15 | ||||
-rw-r--r-- | g10/options.h | 7 | ||||
-rw-r--r-- | g10/passphrase.c | 120 | ||||
-rw-r--r-- | g10/trustdb.c | 3 |
8 files changed, 166 insertions, 3 deletions
@@ -1,3 +1,7 @@ +2002-04-25 Werner Koch <[email protected]> + + * configure.ac: Check for locale.h and setlocale + 2002-04-24 David Shaw <[email protected]> * Update NEWS with recent changes. @@ -109,6 +109,9 @@ packet (See bug report 817). This is not easy to do as we don't store the one-pass packets. + * cat foo | gpg --sign | gpg --list-packets + Does not list the signature packet. + Things we won't do diff --git a/configure.ac b/configure.ac index d40aba9ab..e46cafe3b 100644 --- a/configure.ac +++ b/configure.ac @@ -449,8 +449,7 @@ AC_SUBST(DYNLINK_MOD_CFLAGS) dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(unistd.h langinfo.h termio.h) - +AC_CHECK_HEADERS(unistd.h langinfo.h termio.h locale.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -485,7 +484,7 @@ AC_FUNC_VPRINTF AC_FUNC_FORK AC_CHECK_FUNCS(strerror stpcpy strsep strlwr stricmp tcgetattr strtoul mmap) AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime) -AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime nl_langinfo) +AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime nl_langinfo setlocale) AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat) AC_REPLACE_FUNCS(mkdtemp) diff --git a/g10/ChangeLog b/g10/ChangeLog index 3af58952b..e34c9691d 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,15 @@ +2002-04-25 Werner Koch <[email protected]> + + * g10.c, options.h: New options --display, --ttyname, --ttytype, + --lc-ctype, --lc-messages to be used with future versions of the + gpg-agent. + * passphrase.c (agent_send_option,agent_send_all_options): New. + (agent_open): Send options to the agent. + + * trustdb.c (update_ownertrust, clear_ownertrust): Do an explicit + do_sync because revalidation_mark does it only if when the + timestamp actually changes. + 2002-04-23 David Shaw <[email protected]> * main.h, keygen.c (do_generate_keypair), keylist.c @@ -274,6 +274,11 @@ enum cmd_and_opt_values { aNull = 0, oPreferenceList, oEmu3DESS2KBug, /* will be removed in 1.1 */ oEmuMDEncodeBug, + oDisplay, + oTTYname, + oTTYtype, + oLCctype, + oLCmessages, aTest }; @@ -537,6 +542,11 @@ static ARGPARSE_OPTS opts[] = { { oPreferenceList, "preference-list", 2, "@"}, { oEmu3DESS2KBug, "emulate-3des-s2k-bug", 0, "@"}, { oEmuMDEncodeBug, "emulate-md-encode-bug", 0, "@"}, + { oDisplay, "display", 2, "@" }, + { oTTYname, "ttyname", 2, "@" }, + { oTTYtype, "ttytype", 2, "@" }, + { oLCctype, "lc-ctype", 2, "@" }, + { oLCmessages, "lc-messages", 2, "@" }, {0} }; @@ -1277,6 +1287,11 @@ main( int argc, char **argv ) case oNoAutoCheckTrustDB: opt.no_auto_check_trustdb=1; break; case oPreservePermissions: opt.preserve_permissions=1; break; case oPreferenceList: preference_list = pargs.r.ret_str; break; + case oDisplay: opt.display = pargs.r.ret_str; break; + case oTTYname: opt.ttyname = pargs.r.ret_str; break; + case oTTYtype: opt.ttytype = pargs.r.ret_str; break; + case oLCctype: opt.lc_ctype = pargs.r.ret_str; break; + case oLCmessages: opt.lc_messages = pargs.r.ret_str; break; default : pargs.err = configfp? 1:2; break; } } diff --git a/g10/options.h b/g10/options.h index 4e3c28e5a..7d5976a46 100644 --- a/g10/options.h +++ b/g10/options.h @@ -75,6 +75,13 @@ struct { int completes_needed; int max_cert_depth; const char *homedir; + + char *display; /* 5 options to be passed to the gpg-agent */ + char *ttyname; + char *ttytype; + char *lc_ctype; + char *lc_messages; + int skip_verify; int compress_keys; int compress_sigs; diff --git a/g10/passphrase.c b/g10/passphrase.c index 38629e758..371d22ddc 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -33,6 +33,9 @@ # include <windows.h> #endif #include <errno.h> +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif #include "util.h" #include "memory.h" @@ -309,6 +312,115 @@ readline (int fd, char *buf, size_t buflen) #if !defined (__riscos__) + +#if !defined (__MINGW32__) && !defined (__CYGWIN32__) +/* For the new Assuan protocol we may have to send options */ +static int +agent_send_option (int fd, const char *name, const char *value) +{ + char buf[200]; + int nread; + char *line; + int i; + + line = m_alloc (7 + strlen (name) + 1 + strlen (value) + 2); + strcpy (stpcpy (stpcpy (stpcpy ( + stpcpy (line, "OPTION "), name), "="), value), "\n"); + i = writen (fd, line, strlen (line)); + m_free (line); + if (i) + return -1; + + /* get response */ + nread = readline (fd, buf, DIM(buf)-1); + if (nread < 3) + return -1; + + if (buf[0] == 'O' && buf[1] == 'K' && (buf[2] == ' ' || buf[2] == '\n')) + return 0; /* okay */ + + return -1; +} + +static int +agent_send_all_options (int fd) +{ + char *dft_display = NULL; + char *dft_ttyname = NULL; + char *dft_ttytype = NULL; + char *old_lc = NULL; + char *dft_lc = NULL; + int rc = 0; + + dft_display = getenv ("DISPLAY"); + if (opt.display || dft_display) + { + if (agent_send_option (fd, "display", + opt.display ? opt.display : dft_display)) + return -1; + } + + if (!opt.ttyname && ttyname (1)) + dft_ttyname = ttyname (1); + if (opt.ttyname || dft_ttyname) + { + if (agent_send_option (fd, "ttyname", + opt.ttyname ? opt.ttyname : dft_ttyname)) + return -1; + } + + dft_ttytype = getenv ("TERM"); + if (opt.ttytype || (dft_ttyname && dft_ttytype)) + { + if (agent_send_option (fd, "ttytype", + opt.ttyname ? opt.ttytype : dft_ttytype)) + return -1; + } + +#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE) + old_lc = setlocale (LC_CTYPE, NULL); + if (old_lc) + old_lc = m_strdup (old_lc); + dft_lc = setlocale (LC_CTYPE, ""); +#endif + if (opt.lc_ctype || (dft_ttyname && dft_lc)) + { + rc = agent_send_option (fd, "lc-ctype", + opt.lc_ctype ? opt.lc_ctype : dft_lc); + } +#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE) + if (old_lc) + { + setlocale (LC_CTYPE, old_lc); + m_free (old_lc); + } +#endif + if (rc) + return rc; + +#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES) + old_lc = setlocale (LC_MESSAGES, NULL); + if (old_lc) + old_lc = m_strdup (old_lc); + dft_lc = setlocale (LC_MESSAGES, ""); +#endif + if (opt.lc_messages || (dft_ttyname && dft_lc)) + { + rc = agent_send_option (fd, "lc-messages", + opt.lc_messages ? opt.lc_messages : dft_lc); + } +#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES) + if (old_lc) + { + setlocale (LC_MESSAGES, old_lc); + m_free (old_lc); + } +#endif + return rc; +} +#endif /*!__MINGW32__ && !__CYGWIN32__*/ + + /* * Open a connection to the agent and send the magic string * Returns: -1 on error or an filedescriptor for urther processing @@ -444,6 +556,13 @@ agent_open (int *ret_prot) opt.use_agent = 0; return -1; } + + if (agent_send_all_options (fd)) { + log_error (_("problem with the agent - disabling agent use\n")); + close (fd); + opt.use_agent = 0; + return -1; + } } #endif @@ -465,6 +584,7 @@ agent_close ( int fd ) #endif /* !__riscos__ */ + /* * Ask the GPG Agent for the passphrase. * Mode 0: Allow cached passphrase diff --git a/g10/trustdb.c b/g10/trustdb.c index 4abdeeef1..14dad3220 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -593,6 +593,7 @@ update_ownertrust (PKT_public_key *pk, unsigned int new_trust ) rec.r.trust.ownertrust = new_trust; write_record( &rec ); revalidation_mark (); + do_sync (); } } else if (rc == -1) @@ -609,6 +610,7 @@ update_ownertrust (PKT_public_key *pk, unsigned int new_trust ) rec.r.trust.ownertrust = new_trust; write_record (&rec); revalidation_mark (); + do_sync (); rc = 0; } else @@ -635,6 +637,7 @@ clear_ownertrust (PKT_public_key *pk) rec.r.trust.ownertrust = 0; write_record( &rec ); revalidation_mark (); + do_sync (); return 1; } } |