From 2732f2ff3f44a5aae969d5ce16a4de74478576a2 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 10 Jan 2011 11:37:57 +0100 Subject: [PATCH 1/6] Fix bug #1311. --- NEWS | 3 +++ common/ChangeLog | 5 +++++ common/session-env.c | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2cdf854bf..215373345 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ Noteworthy changes in version 2.1.0beta2 (unreleased) * Fixed CRL loading under W32 (bug#1010). + * Fixed TTY management for pinentries and session variable update + problem. + Noteworthy changes in version 2.1.0beta1 (2010-10-26) ----------------------------------------------------- diff --git a/common/ChangeLog b/common/ChangeLog index de96b8dc8..6a6f6e071 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Werner Koch + + * session-env.c (update_var): Fix same value detection. Fixes + bug#1311. + 2010-12-17 Werner Koch * asshelp.c (lock_spawning): Add arg VERBOSE. Improve timeout diff --git a/common/session-env.c b/common/session-env.c index 2dcf425b6..d719a7b87 100644 --- a/common/session-env.c +++ b/common/session-env.c @@ -183,10 +183,11 @@ update_var (session_env_t se, const char *string, size_t namelen, else if (!strncmp (se->array[idx]->name, string, namelen) && strlen (se->array[idx]->name) == namelen) { - /* Check if the value is the same; no need to update it, - except for updating the default flag. */ if (strlen (se->array[idx]->value) == valuelen) { + /* The new value has the same length. We can update it + in-place. */ + memcpy (se->array[idx]->value, value, valuelen); se->array[idx]->is_default = !!set_default; return 0; } From 8db3bf8c47a76e9f7d75863d49c172b5ddd94896 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 10 Jan 2011 14:38:32 +0100 Subject: [PATCH 2/6] Add ignore file --- .gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..699581b44 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +Makefile.in +aclocal.m4 +autom4te.cache/ +configure +config.h.in +config.h +common/audit-events.h +common/status-codes.h +doc/gnupg.info* +doc/stamp-vti +doc/version.texi +po/gnupg2.pot From 52b9761c8847523d35de3484e4b7fdefbb0e6a4e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 13 Jan 2011 15:32:11 +0100 Subject: [PATCH 3/6] ifset parts which are not in GnuPG 2.0 --- doc/debugging.texi | 4 ++-- doc/gnupg.texi | 8 +++++++- doc/tools.texi | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/debugging.texi b/doc/debugging.texi index 7b1d068d3..c83ab1ef9 100644 --- a/doc/debugging.texi +++ b/doc/debugging.texi @@ -103,7 +103,7 @@ used. Using the keyserver debug option as in is thus often helpful. Note that the actual output depends on the backend and may change from release to release. - +@ifset gpgtwoone @item Logging on WindowsCE For development, the best logging method on WindowsCE is the use of @@ -113,7 +113,7 @@ on the given port. (@pxref{option watchgnupg --tcp}). For in the field tests it is better to make use of the logging facility provided by the @command{gpgcedev} driver (part of libassuan); this is enabled by using a log file name of @file{GPG2:}. (@pxref{option --log-file}). - +@end ifset @end itemize diff --git a/doc/gnupg.texi b/doc/gnupg.texi index 86e192e0c..7bb54af51 100644 --- a/doc/gnupg.texi +++ b/doc/gnupg.texi @@ -34,7 +34,7 @@ Published by the Free Software Foundation@* Boston, MA 02110-1301 USA @end iftex -Copyright @copyright{} 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +Copyright @copyright{} 2002, 2004, 2005, 2006, 2007, 2010 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -51,8 +51,10 @@ section entitled ``Copying''. * gpg2: (gnupg). OpenPGP encryption and signing tool. * gpgsm: (gnupg). S/MIME encryption and signing tool. * gpg-agent: (gnupg). The secret key daemon. +@ifset gpgtwoone * dirmngr: (gnupg). X.509 CRL and OCSP server. * dirmngr-client: (gnupg). X.509 CRL and OCSP client. +@end ifset @end direntry @@ -124,7 +126,9 @@ the administration and the architecture. * Installation:: A short installation guide. * Invoking GPG-AGENT:: How to launch the secret key daemon. +@ifset gpgtwoone * Invoking DIRMNGR:: How to launch the CRL and OCSP daemon. +@end ifset * Invoking GPG:: Using the OpenPGP protocol. * Invoking GPGSM:: Using the S/MIME protocol. * Invoking SCDAEMON:: How to handle Smartcards. @@ -156,7 +160,9 @@ the administration and the architecture. @include instguide.texi @include gpg-agent.texi +@ifset gpgtwoone @include dirmngr.texi +@end ifset @include gpg.texi @include gpgsm.texi @include scdaemon.texi diff --git a/doc/tools.texi b/doc/tools.texi index a21f41353..c85f9e243 100644 --- a/doc/tools.texi +++ b/doc/tools.texi @@ -16,7 +16,9 @@ GnuPG comes with a couple of smaller tools: * gpgsm-gencert.sh:: Generate an X.509 certificate request. * gpg-preset-passphrase:: Put a passphrase into the cache. * gpg-connect-agent:: Communicate with a running agent. +@ifset gpgtwoone * dirmngr-client:: How to use the Dirmngr client tool. +@end ifset * gpgparsemail:: Parse a mail message into an annotated format * symcryptrun:: Call a simple symmetric encryption tool. * gpg-zip:: Encrypt or sign files into an archive. @@ -1434,6 +1436,7 @@ Print a list of available control commands. @include see-also-note.texi @end ifset +@ifset gpgtwoone @c @c DIRMNGR-CLIENT @c @@ -1594,7 +1597,7 @@ Squid's @option{external_acl_type} option. @command{gpgsm}(1) @include see-also-note.texi @end ifset - +@end ifset @c @c GPGPARSEMAIL From dcd20e18a5b581d93e8259722d5f1b69d3af992b Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 18 Jan 2011 12:26:05 +0100 Subject: [PATCH 4/6] Fix computation of NEWSIZE in es_func_mem_write. The function used to fail and return EINVAL when enlarging the buffer. --- common/ChangeLog | 4 ++++ common/estream.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/ChangeLog b/common/ChangeLog index 6a6f6e071..fe9eb4fc0 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,7 @@ +2011-01-18 Werner Koch + + * estream.c (es_func_mem_write): FIX computation of NEWSIZE. + 2011-01-10 Werner Koch * session-env.c (update_var): Fix same value detection. Fixes diff --git a/common/estream.c b/common/estream.c index bc25452ed..416aa8376 100644 --- a/common/estream.c +++ b/common/estream.c @@ -641,7 +641,7 @@ es_func_mem_write (void *cookie, const void *buffer, size_t size) if (!mem_cookie->memory_size) newsize = size; /* Not yet allocated. */ else - newsize = mem_cookie->memory_size + (nleft - size); + newsize = mem_cookie->memory_size + (size - nleft); if (newsize < mem_cookie->offset) { _set_errno (EINVAL); From af500f0ae490bc4262419fa52bac62677e1672fa Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 19 Jan 2011 16:29:30 +0100 Subject: [PATCH 5/6] Use estream for dirmngr's --gpgconf-list. Change insalled name of gpg2 for Wince. --- ChangeLog | 8 ++++++- autogen.sh | 3 ++- common/ChangeLog | 7 +++++- common/homedir.c | 2 +- configure.ac | 18 ++++++++++++++++ dirmngr/ChangeLog | 4 ++++ dirmngr/dirmngr.c | 54 +++++++++++++++++++++++------------------------ 7 files changed, 65 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 656fe7212..d36c23c43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-19 Werner Koch + + * configure.ac: Add new option --enable-gpg2-is-gpg. + (NAME_OF_INSTALLED_GPG): New ac_define. + * autogen.sh [--build-w32ce]: Use --enable-gpg2-is-gpg. + 2011-01-03 Werner Koch * README.SVN: Rename to README.GIT. @@ -16,7 +22,7 @@ 2010-11-17 Werner Koch - * configure.ac (ENABLE_CARD_SUPPORT): Define. + * configure.ac (ENABLE_CARD_SUPPORT): Define. 2010-10-27 Werner Koch diff --git a/autogen.sh b/autogen.sh index 72e5fee2c..d05415507 100755 --- a/autogen.sh +++ b/autogen.sh @@ -104,7 +104,8 @@ if [ "$myhost" = "w32" ]; then [ -z "$w32root" ] && w32root="$HOME/w32ce_root" toolprefixes="$w32ce_toolprefixes arm-mingw32ce" extraoptions="--enable-dirmngr-auto-start --disable-scdaemon " - extraoptions="$extraoptions --disable-zip $w32ce_extraoptions" + extraoptions="$extraoptions --disable-zip --enable-gpg2-is-gpg" + extraoptions="$extraoptions $w32ce_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" diff --git a/common/ChangeLog b/common/ChangeLog index fe9eb4fc0..3f38be1be 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,6 +1,11 @@ +2011-01-19 Werner Koch + + * homedir.c (gnupg_module_name): Use NAME_OF_INSTALLED_GPG instead + of "gpg2". + 2011-01-18 Werner Koch - * estream.c (es_func_mem_write): FIX computation of NEWSIZE. + * estream.c (es_func_mem_write): Fix computation of NEWSIZE. 2011-01-10 Werner Koch diff --git a/common/homedir.c b/common/homedir.c index a6364f8b5..3d31bd376 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -528,7 +528,7 @@ gnupg_module_name (int which) X(bindir, "gpgsm"); case GNUPG_MODULE_NAME_GPG: - X(bindir, "gpg2"); + X(bindir, NAME_OF_INSTALLED_GPG); case GNUPG_MODULE_NAME_CONNECT_AGENT: X(bindir, "gpg-connect-agent"); diff --git a/configure.ac b/configure.ac index b6ed4b34c..82d15096e 100644 --- a/configure.ac +++ b/configure.ac @@ -168,6 +168,24 @@ show_gnupg_dirmngr_ldap_pgm="(default)" test -n "$GNUPG_DIRMNGR_LDAP_PGM" \ && show_gnupg_dirmngr_ldap_pgm="$GNUPG_DIRMNGR_LDAP_PGM" +# +# On some platforms gpg2 is usually installed as gpg without using a +# symlink. For correct operation of gpgconf it needs to know the +# installed name of gpg. This option sets "gpg2"'s installed name to +# just "gpg". Note that it might be required to rename gpg2 to gpg +# manually after the build process. +# +AC_ARG_ENABLE(gpg2-is-gpg, + AC_HELP_STRING([--enable-gpg2-is-gpg],[Set installed name of gpg2 to gpg]), + gpg2_is_gpg=$enableval) +if test "$gpg2_is_gpg" = "yes"; then + name_of_installed_gpg=gpg +else + name_of_installed_gpg=gpg2 +fi +AC_DEFINE_UNQUOTED(NAME_OF_INSTALLED_GPG, "$name_of_installed_gpg", + [The name of the installed GPG tool]) + # Some folks want to use only the agent from this packet. Make it # easier for them by providing the configure option diff --git a/dirmngr/ChangeLog b/dirmngr/ChangeLog index 2c208755d..9711846c1 100644 --- a/dirmngr/ChangeLog +++ b/dirmngr/ChangeLog @@ -1,3 +1,7 @@ +2011-01-19 Werner Koch + + * dirmngr.c (main): Use es_printf for --gpgconf-list. + 2010-12-14 Werner Koch * cdb.h (struct cdb) [W32]: Add field CDB_MAPPING. diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c index 9b06851bd..ae922fa31 100644 --- a/dirmngr/dirmngr.c +++ b/dirmngr/dirmngr.c @@ -1019,7 +1019,7 @@ main (int argc, char **argv) start of the dirmngr. */ #ifdef HAVE_W32_SYSTEM pid = getpid (); - printf ("set DIRMNGR_INFO=%s;%lu;1\n", socket_name, (ulong) pid); + es_printf ("set DIRMNGR_INFO=%s;%lu;1\n", socket_name, (ulong) pid); #else pid = pth_fork (); if (pid == (pid_t)-1) @@ -1051,11 +1051,11 @@ main (int argc, char **argv) if (csh_style) { *strchr (infostr, '=') = ' '; - printf ( "setenv %s\n", infostr); + es_printf ( "setenv %s\n", infostr); } else { - printf ( "%s; export DIRMNGR_INFO;\n", infostr); + es_printf ( "%s; export DIRMNGR_INFO;\n", infostr); } free (infostr); exit (0); @@ -1220,15 +1220,15 @@ main (int argc, char **argv) "dirmngr.conf", NULL ); filename = percent_escape (opt.config_filename, NULL); - printf ("gpgconf-dirmngr.conf:%lu:\"%s\n", + es_printf ("gpgconf-dirmngr.conf:%lu:\"%s\n", GC_OPT_FLAG_DEFAULT, filename); xfree (filename); - printf ("verbose:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("quiet:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("debug-level:%lu:\"none\n", flags | GC_OPT_FLAG_DEFAULT); - printf ("log-file:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("force:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("verbose:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("quiet:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("debug-level:%lu:\"none\n", flags | GC_OPT_FLAG_DEFAULT); + es_printf ("log-file:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("force:%lu:\n", flags | GC_OPT_FLAG_NONE); /* --csh and --sh are mutually exclusive, something we can not express in GPG Conf. --options is only usable from the @@ -1241,34 +1241,34 @@ main (int argc, char **argv) "ldapservers.conf":"dirmngr_ldapservers.conf", NULL); filename_esc = percent_escape (filename, NULL); - printf ("ldapserverlist-file:%lu:\"%s\n", flags | GC_OPT_FLAG_DEFAULT, + es_printf ("ldapserverlist-file:%lu:\"%s\n", flags | GC_OPT_FLAG_DEFAULT, filename_esc); xfree (filename_esc); xfree (filename); - printf ("ldaptimeout:%lu:%u\n", + es_printf ("ldaptimeout:%lu:%u\n", flags | GC_OPT_FLAG_DEFAULT, DEFAULT_LDAP_TIMEOUT); - printf ("max-replies:%lu:%u\n", + es_printf ("max-replies:%lu:%u\n", flags | GC_OPT_FLAG_DEFAULT, DEFAULT_MAX_REPLIES); - printf ("allow-ocsp:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("ocsp-responder:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("ocsp-signer:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("allow-ocsp:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("ocsp-responder:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("ocsp-signer:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("faked-system-time:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("no-greeting:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("faked-system-time:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("no-greeting:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("disable-http:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("disable-ldap:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("honor-http-proxy:%lu\n", flags | GC_OPT_FLAG_NONE); - printf ("http-proxy:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("ldap-proxy:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("only-ldap-proxy:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("ignore-ldap-dp:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("ignore-http-dp:%lu:\n", flags | GC_OPT_FLAG_NONE); - printf ("ignore-ocsp-service-url:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("disable-http:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("disable-ldap:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("honor-http-proxy:%lu\n", flags | GC_OPT_FLAG_NONE); + es_printf ("http-proxy:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("ldap-proxy:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("only-ldap-proxy:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("ignore-ldap-dp:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("ignore-http-dp:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("ignore-ocsp-service-url:%lu:\n", flags | GC_OPT_FLAG_NONE); /* Note: The next one is to fix a typo in gpgconf - should be removed eventually. */ - printf ("ignore-ocsp-servic-url:%lu:\n", flags | GC_OPT_FLAG_NONE); + es_printf ("ignore-ocsp-servic-url:%lu:\n", flags | GC_OPT_FLAG_NONE); } cleanup (); return !!rc; From 13acd78a39750e3990684a5bb0951fe0db83fc5a Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 19 Jan 2011 18:05:15 +0100 Subject: [PATCH 6/6] Fixed a CR/LF problem on Windows --- agent/ChangeLog | 4 ++++ agent/trustlist.c | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/agent/ChangeLog b/agent/ChangeLog index ce1fdccd8..542695bea 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,7 @@ +2011-01-19 Werner Koch + + * trustlist.c (read_one_trustfile): Also chop an CR. + 2010-12-02 Werner Koch * gpg-agent.c (CHECK_OWN_SOCKET_INTERVAL) [W32CE]: Set to 60 diff --git a/agent/trustlist.c b/agent/trustlist.c index 791df9682..d56598245 100644 --- a/agent/trustlist.c +++ b/agent/trustlist.c @@ -139,8 +139,9 @@ read_one_trustfile (const char *fname, int allow_include, while (es_fgets (line, DIM(line)-1, fp)) { lnr++; - - if (!*line || line[strlen(line)-1] != '\n') + + n = strlen (line); + if (!n || line[n-1] != '\n') { /* Eat until end of line. */ while ( (c=es_getc (fp)) != EOF && c != '\n') @@ -151,7 +152,9 @@ read_one_trustfile (const char *fname, int allow_include, fname, lnr, gpg_strerror (err)); continue; } - line[strlen(line)-1] = 0; /* Chop the LF. */ + line[--n] = 0; /* Chop the LF. */ + if (n && line[n-1] == '\r') + line[--n] = 0; /* Chop an optional CR. */ /* Allow for empty lines and spaces */ for (p=line; spacep (p); p++)