From cvs at cvs.gnupg.org Thu Aug 1 12:02:50 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 01 Aug 2013 12:02:50 +0200 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-230-gef6a6d9 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via ef6a6d973c2bcc54006c04dc41f978ff01005c97 (commit) via 9ff72e4e7e4f56c241a525479a94ed4c95efc23f (commit) via db4651734fe91935b17876dc9194329b00066eff (commit) via 6ce54a18c2a625b89d5453129d5b9d1ad9d59473 (commit) via ef2e2e54020c3475bf2129c3ec8360c7bad3a6c9 (commit) via 25b0357bf0a4861a751cfbc3e0335ae05c8b2b1b (commit) via ffa7472db551f12f66b9789c31fabb5fc80cc13a (commit) via f101f34fffee4a02e7a5f62b59667e45e50e8325 (commit) via 2830fcb83c99289a49da0e111766daf2d9a1fa3b (commit) via f254497e09fa4e0e24e63d14f7316fc31c938844 (commit) from 82c25e67a1669febb5332b3e9bc4652e6855fdca (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ef6a6d973c2bcc54006c04dc41f978ff01005c97 Author: Werner Koch Date: Thu Aug 1 11:32:05 2013 +0200 agent: Include missing prototype. * agent/protect.c: Include cvt-openpgp.h. diff --git a/agent/protect.c b/agent/protect.c index cb2c098..b29f494 100644 --- a/agent/protect.c +++ b/agent/protect.c @@ -36,6 +36,7 @@ #include "agent.h" +#include "cvt-openpgp.h" #include "sexp-parse.h" #define PROT_CIPHER GCRY_CIPHER_AES commit 9ff72e4e7e4f56c241a525479a94ed4c95efc23f Author: Werner Koch Date: Thu Aug 1 11:20:48 2013 +0200 w32: Add code to support a portable use of GnuPG. * common/homedir.c (w32_bin_is_bin, w32_portable_app) [W32]: New. (check_portable_app) [W32]: New. (standard_homedir, default_homedir) [W32]: Support the portable flag. (w32_rootdir, w32_commondir) [W32]: Ditto. (gnupg_bindir, gnupg_cachedir, dirmngr_socket_name) [W32]: Ditto. * common/logging.h (JNLIB_LOG_NO_REGISTRY): New. * common/logging.c (no_registry): New variable. (log_set_prefix, log_get_prefix): Set/get that variable. (do_logv): Do not check the registry if that variable is set. -- Beware: This code has not been tested because it is not yet possible to build GnuPG 2.1 for Windows. However, the code will be the base for an implementation in 2.0. A portable use of GnuPG under Windows means that GnuPG uses a home directory depending on the location of the actual binary. No registry variables are considered. The portable mode is enabled if in the installation directory of the the binary "gpgconf.exe" and a file "gpgconf.ctl" are found. The latter file is empty or consists only of empty or '#' comment lines. Signed-off-by: Werner Koch diff --git a/NEWS b/NEWS index 370d9c4..3b2016f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Noteworthy changes in version 2.1.0beta4 (unreleased) +Noteworthy changes in version 2.1.0-betaN (unreleased) ----------------------------------------------------- * GPG now accepts a space separated fingerprint as a user ID. This @@ -20,6 +20,8 @@ Noteworthy changes in version 2.1.0beta4 (unreleased) * Better support fo CCID readers. Now, internal CCID driver supports readers with no auto configuration feature. + * Support installation as portable application under Windows. + Noteworthy changes in version 2.1.0beta3 (2011-12-20) ----------------------------------------------------- diff --git a/common/homedir.c b/common/homedir.c index 28e5c9a..9fec78f 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -1,5 +1,6 @@ /* homedir.c - Setup the home directory. * Copyright (C) 2004, 2006, 2007, 2010 Free Software Foundation, Inc. + * Copyright (C) 2013 Werner Koch * * This file is part of GnuPG. * @@ -33,6 +34,9 @@ #include #ifdef HAVE_W32_SYSTEM +#include /* Due to the stupid mingw64 requirement to + include this header before windows.h which + is often implicitly included. */ #include #ifndef CSIDL_APPDATA #define CSIDL_APPDATA 0x001a @@ -53,6 +57,33 @@ #include "util.h" #include "sysutils.h" +#ifdef HAVE_W32_SYSTEM +/* A flag used to indicate that a control file for gpgconf has been + detected. Under Windows the presence of this file indicates a + portable installations and triggers several changes: + + - The GNUGHOME directory is fixed relative to installation + directory. All other means to set the home directory are ignore. + + - All registry variables will be ignored. + + This flag is not used on Unix systems. + */ +static int w32_portable_app; +#endif /*HAVE_W32_SYSTEM*/ + +#ifdef HAVE_W32_SYSTEM +/* This flag is true if this process' binary has been installed under + bin and not in the root directory. */ +static int w32_bin_is_bin; +#endif /*HAVE_W32_SYSTEM*/ + + +#ifdef HAVE_W32_SYSTEM +static const char *w32_rootdir (void); +#endif + + #ifdef HAVE_W32_SYSTEM static void @@ -124,28 +155,39 @@ standard_homedir (void) if (!dir) { - char path[MAX_PATH]; + const char *rdir; - /* It might be better to use LOCAL_APPDATA because this is - defined as "non roaming" and thus more likely to be kept - locally. For private keys this is desired. However, given - that many users copy private keys anyway forth and back, - using a system roaming services might be better than to let - them do it manually. A security conscious user will anyway - use the registry entry to have better control. */ - if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, - NULL, 0, path) >= 0) + rdir = w32_rootdir (); + if (w32_portable_app) { - char *tmp = xmalloc (strlen (path) + 6 +1); - strcpy (stpcpy (tmp, path), "\\gnupg"); - dir = tmp; - - /* Try to create the directory if it does not yet exists. */ - if (access (dir, F_OK)) - w32_try_mkdir (dir); + dir = xstrconcat (rdir, DIRSEP_S "home", NULL); } else - dir = GNUPG_DEFAULT_HOMEDIR; + { + char path[MAX_PATH]; + + /* It might be better to use LOCAL_APPDATA because this is + defined as "non roaming" and thus more likely to be kept + locally. For private keys this is desired. However, + given that many users copy private keys anyway forth and + back, using a system roaming services might be better + than to let them do it manually. A security conscious + user will anyway use the registry entry to have better + control. */ + if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, + NULL, 0, path) >= 0) + { + char *tmp = xmalloc (strlen (path) + 6 +1); + strcpy (stpcpy (tmp, path), "\\gnupg"); + dir = tmp; + + /* Try to create the directory if it does not yet exists. */ + if (access (dir, F_OK)) + w32_try_mkdir (dir); + } + else + dir = GNUPG_DEFAULT_HOMEDIR; + } } return dir; #else/*!HAVE_W32_SYSTEM*/ @@ -160,6 +202,13 @@ default_homedir (void) { const char *dir; +#ifdef HAVE_W32_SYSTEM + /* For a portable application we only use the standard homedir. */ + w32_rootdir (); + if (w32_portable_app) + return standard_homedir (); +#endif /*HAVE_W32_SYSTEM*/ + dir = getenv ("GNUPGHOME"); #ifdef HAVE_W32_SYSTEM if (!dir || !*dir) @@ -197,6 +246,37 @@ default_homedir (void) #ifdef HAVE_W32_SYSTEM +/* Check whether gpgconf is installed and if so read the gpgconf.ctl + file. */ +static void +check_portable_app (const char *dir) +{ + char *fname; + + fname = xstrconcat (dir, DIRSEP_S "gpgconf.exe", NULL); + if (access (fname, F_OK)) + log_error ("required binary '%s' is not installed\n", fname); + else + { + strcpy (fname + strlen (fname) - 3, ".ctl"); + if (!access (fname, F_OK)) + { + /* gpgconf.ctl file found. Record this fact. */ + w32_portable_app = 1; + { + unsigned int flags; + log_get_prefix (&flags); + log_set_prefix (NULL, (flags | JNLIB_LOG_NO_REGISTRY)); + } + /* FIXME: We should read the file to detect special flags + and print a warning if we don't understand them */ + } + } + xfree (fname); +} + + +/* Determine the root directory of the gnupg installation on Windows. */ static const char * w32_rootdir (void) { @@ -229,11 +309,17 @@ w32_rootdir (void) if (p) { *p = 0; + + check_portable_app (dir); + /* If we are installed below "bin" we strip that and use the top directory instead. */ p = strrchr (dir, DIRSEP_C); if (p && !strcmp (p+1, "bin")) - *p = 0; + { + *p = 0; + w32_bin_is_bin = 1; + } } if (!p) { @@ -255,8 +341,17 @@ w32_commondir (void) if (!dir) { + const char *rdir; char path[MAX_PATH]; + /* Make sure that w32_rootdir has been called so that we are + able to check the portable application flag. The common dir + is the identical to the rootdir. In that case there is also + no need to strdup its value. */ + rdir = w32_rootdir (); + if (w32_portable_app) + return rdir; + if (w32_shgetfolderpath (NULL, CSIDL_COMMON_APPDATA, NULL, 0, path) >= 0) { @@ -270,7 +365,7 @@ w32_commondir (void) { /* Ooops: Not defined - probably an old Windows version. Use the installation directory instead. */ - dir = xstrdup (w32_rootdir ()); + dir = xstrdup (rdir); } } @@ -315,7 +410,19 @@ gnupg_bindir (void) name = xstrconcat (w32_rootdir (), DIRSEP_S "bin", NULL); return name; #elif defined(HAVE_W32_SYSTEM) - return w32_rootdir (); + const char *rdir; + + rdir = w32_rootdir (); + if (w32_bin_is_bin) + { + static char *name; + + if (!name) + name = xstrconcat (rdir, DIRSEP_S "bin", NULL); + return name; + } + else + return rdir; #else /*!HAVE_W32_SYSTEM*/ return GNUPG_BINDIR; #endif /*!HAVE_W32_SYSTEM*/ @@ -390,41 +497,54 @@ gnupg_cachedir (void) if (!dir) { - char path[MAX_PATH]; - const char *s1[] = { "GNU", "cache", "gnupg", NULL }; - int s1_len; - const char **comp; - - s1_len = 0; - for (comp = s1; *comp; comp++) - s1_len += 1 + strlen (*comp); + const char *rdir; - if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, - NULL, 0, path) >= 0) + rdir = w32_rootdir (); + if (w32_portable_app) + { + dir = xstrconcat (rdir, + DIRSEP_S, "var", + DIRSEP_S, "cache", + DIRSEP_S, "gnupg", NULL); + } + else { - char *tmp = xmalloc (strlen (path) + s1_len + 1); - char *p; + char path[MAX_PATH]; + const char *s1[] = { "GNU", "cache", "gnupg", NULL }; + int s1_len; + const char **comp; - p = stpcpy (tmp, path); + s1_len = 0; for (comp = s1; *comp; comp++) - { - p = stpcpy (p, "\\"); - p = stpcpy (p, *comp); + s1_len += 1 + strlen (*comp); - if (access (tmp, F_OK)) - w32_try_mkdir (tmp); - } + if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, + NULL, 0, path) >= 0) + { + char *tmp = xmalloc (strlen (path) + s1_len + 1); + char *p; - dir = tmp; - } - else - { - dir = "c:\\temp\\cache\\gnupg"; + p = stpcpy (tmp, path); + for (comp = s1; *comp; comp++) + { + p = stpcpy (p, "\\"); + p = stpcpy (p, *comp); + + if (access (tmp, F_OK)) + w32_try_mkdir (tmp); + } + + dir = tmp; + } + else + { + dir = "c:\\temp\\cache\\gnupg"; #ifdef HAVE_W32CE_SYSTEM - dir += 2; - w32_try_mkdir ("\\temp\\cache"); - w32_try_mkdir ("\\temp\\cache\\gnupg"); + dir += 2; + w32_try_mkdir ("\\temp\\cache"); + w32_try_mkdir ("\\temp\\cache\\gnupg"); #endif + } } } return dir; @@ -449,16 +569,21 @@ dirmngr_socket_name (void) s1 = default_homedir (); # else - char s1[MAX_PATH]; - const char *s2; - - /* We need something akin CSIDL_COMMON_PROGRAMS, but local - (non-roaming). This is becuase the file needs to be on the - local machine and makes only sense on that machine. - CSIDL_WINDOWS seems to be the only location which guarantees - that. */ - if (w32_shgetfolderpath (NULL, CSIDL_WINDOWS, NULL, 0, s1) < 0) - strcpy (s1, "C:\\WINDOWS"); + char s1buf[MAX_PATH]; + const char *s1, *s2; + + s1 = default_homedir (); + if (!w32_portable_app) + { + /* We need something akin CSIDL_COMMON_PROGRAMS, but local + (non-roaming). This is because the file needs to be on + the local machine and makes only sense on that machine. + CSIDL_WINDOWS seems to be the only location which + guarantees that. */ + if (w32_shgetfolderpath (NULL, CSIDL_WINDOWS, NULL, 0, s1buf) < 0) + strcpy (s1buf, "C:\\WINDOWS"); + s1 = s1buf; + } # endif s2 = DIRSEP_S "S.dirmngr"; name = xmalloc (strlen (s1) + strlen (s2) + 1); diff --git a/common/logging.c b/common/logging.c index 73b0dbe..f78df91 100644 --- a/common/logging.c +++ b/common/logging.c @@ -96,6 +96,9 @@ static char prefix_buffer[80]; static int with_time; static int with_prefix; static int with_pid; +#ifdef HAVE_W32_SYSTEM +static int no_registry; +#endif static int (*get_pid_suffix_cb)(unsigned long *r_value); static int running_detached; static int force_prefixes; @@ -561,6 +564,9 @@ log_set_prefix (const char *text, unsigned int flags) with_time = (flags & JNLIB_LOG_WITH_TIME); with_pid = (flags & JNLIB_LOG_WITH_PID); running_detached = (flags & JNLIB_LOG_RUN_DETACHED); +#ifdef HAVE_W32_SYSTEM + no_registry = (flags & JNLIB_LOG_NO_REGISTRY); +#endif } @@ -578,6 +584,10 @@ log_get_prefix (unsigned int *flags) *flags |= JNLIB_LOG_WITH_PID; if (running_detached) *flags |= JNLIB_LOG_RUN_DETACHED; +#ifdef HAVE_W32_SYSTEM + if (no_registry) + *flags |= JNLIB_LOG_NO_REGISTRY; +#endif } return prefix_buffer; } @@ -624,8 +634,10 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr) #ifdef HAVE_W32_SYSTEM char *tmp; - tmp = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", - "DefaultLogFile"); + tmp = (no_registry + ? NULL + : read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", + "DefaultLogFile")); log_set_file (tmp && *tmp? tmp : NULL); jnlib_free (tmp); #else diff --git a/common/logging.h b/common/logging.h index 89913e6..3b38f73 100644 --- a/common/logging.h +++ b/common/logging.h @@ -42,6 +42,7 @@ #define JNLIB_LOG_WITH_TIME 2 #define JNLIB_LOG_WITH_PID 4 #define JNLIB_LOG_RUN_DETACHED 256 +#define JNLIB_LOG_NO_REGISTRY 512 int log_get_errorcount (int clear); void log_inc_errorcount (void); diff --git a/doc/opt-homedir.texi b/doc/opt-homedir.texi index e382f63..033a901 100644 --- a/doc/opt-homedir.texi +++ b/doc/opt-homedir.texi @@ -5,6 +5,18 @@ Set the name of the home directory to @var{dir}. If this option is not used, the home directory defaults to @file{~/.gnupg}. It is only recognized when given on the command line. It also overrides any home directory stated through the environment variable @env{GNUPGHOME} or -(on W32 systems) by means of the Registry entry +(on Windows systems) by means of the Registry entry @var{HKCU\Software\GNU\GnuPG:HomeDir}. +On Windows systems it is possible to install GnuPG as a portable +application. In this case only this command line option is +considered, all other ways to set a home directory are ignored. + +To install GnuPG as a portable application under Windows, create an +empty file name @file{gpgconf.ctl} in the same directory as the tool + at file{gpgconf.exe}. The root of the installation is than that +directory; or, if @file{gpgconf.exe} has been installed directly below +a directory named @file{bin}, its parent directory. You also need to +make sure that the following directories exist and are writable: + at file{ROOT/home} for the GnuPG home and @file{ROOT/var/cache/gnupg} +for internal cache files. commit db4651734fe91935b17876dc9194329b00066eff Author: Werner Koch Date: Thu Aug 1 11:06:22 2013 +0200 Silence compiler warning about deprecated Libgcrypt symbols * configure.ac (AH_BOTTOM): Define GCRYPT_NO_DEPRECATED. -- Some gcc versions emit deprecated warning for such flagged Libgcrypt symbols; even if they are not used. diff --git a/configure.ac b/configure.ac index 01530e0..5a5e9f4 100644 --- a/configure.ac +++ b/configure.ac @@ -500,6 +500,9 @@ AH_BOTTOM([ /* Tell libgcrypt not to use its own libgpg-error implementation. */ #define USE_LIBGPG_ERROR 1 +/* Tell Libgcrypt not to include deprecated definitions. */ +#define GCRYPT_NO_DEPRECATED 1 + /* We use jnlib, so tell other modules about it. */ #define HAVE_JNLIB_LOGGING 1 commit 6ce54a18c2a625b89d5453129d5b9d1ad9d59473 Author: Werner Koch Date: Thu Aug 1 11:03:24 2013 +0200 w32: Change autogen.sh to use npth. -- diff --git a/autogen.sh b/autogen.sh index dcb3834..935a456 100755 --- a/autogen.sh +++ b/autogen.sh @@ -170,7 +170,7 @@ if [ "$myhost" = "w32" ]; then --with-libassuan-prefix=${w32root} \ --with-zlib=${w32root} \ --with-regex=${w32root} \ - --with-pth-prefix=${w32root} \ + --with-npth-prefix=${w32root} \ --with-adns=${w32root} \ ${extraoptions} --disable-g13 "$@" rc=$? commit ef2e2e54020c3475bf2129c3ec8360c7bad3a6c9 Author: Werner Koch Date: Thu Aug 1 11:02:03 2013 +0200 dirmngr: Define missing LDAP constant * dirmngr/ldap-url.c (LDAP_SCOPE_DEFAULT): Define if missing. diff --git a/dirmngr/ldap-url.c b/dirmngr/ldap-url.c index 2dc186b..e5a7d94 100644 --- a/dirmngr/ldap-url.c +++ b/dirmngr/ldap-url.c @@ -96,6 +96,11 @@ software is provided `'as is'' without express or implied warranty. */ void ldap_pvt_hex_unescape( char *s ); +#ifndef LDAP_SCOPE_DEFAULT +# define LDAP_SCOPE_DEFAULT -1 +#endif + + /* $OpenLDAP: pkg/ldap/libraries/libldap/charray.c,v 1.9.2.2 2003/03/03 17:10:04 kurt Exp $ */ /* commit 25b0357bf0a4861a751cfbc3e0335ae05c8b2b1b Author: Werner Koch Date: Thu Aug 1 11:01:01 2013 +0200 scd: Fix a syntax error for Apple and Windows. * scd/apdu.c (pcsc_dword_t) [W32]: Fix syntax error. diff --git a/scd/apdu.c b/scd/apdu.c index 92c9864..133058d 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -83,7 +83,7 @@ #endif #if defined(__APPLE__) || defined(_WIN32) || defined(__CYGWIN__) -typedef unsinged int pcsc_dword_t; +typedef unsigned int pcsc_dword_t; #else typedef unsigned long pcsc_dword_t; #endif commit ffa7472db551f12f66b9789c31fabb5fc80cc13a Author: Werner Koch Date: Thu Aug 1 10:30:27 2013 +0200 common: Fix a build error when using adns. * common/dns-cert.c (get_dns_cert) [USE_ADNS]: Fix synatx error. -- (fixes commit 31f548a18aed729c05ea367f2d8a8104480430d5) Signed-off-by: Werner Koch diff --git a/common/dns-cert.c b/common/dns-cert.c index 114e61d..dca15b1 100644 --- a/common/dns-cert.c +++ b/common/dns-cert.c @@ -148,7 +148,7 @@ get_dns_cert (const char *name, estream_t *r_key, goto leave; } else if (ctype == CERTTYPE_IPGP && datalen && datalen < 1023 - && datalen >= data[0] + 1 && fpr && fpr_len && url) + && datalen >= data[0] + 1 && r_fpr && r_fprlen && r_url) { /* CERT type is IPGP. We made sure that the data is plausible and that the caller requested this @@ -170,7 +170,7 @@ get_dns_cert (const char *name, estream_t *r_key, if (datalen > *r_fprlen + 1) { - *url = xtrymalloc (datalen - (*r_fprlen + 1) + 1); + *r_url = xtrymalloc (datalen - (*r_fprlen + 1) + 1); if (!*r_url) { err = gpg_err_make (default_errsource, @@ -179,8 +179,9 @@ get_dns_cert (const char *name, estream_t *r_key, *r_fpr = NULL; goto leave; } - memcpy (*url, data + (*r_fprlen + 1), datalen - (*r_fprlen + 1)); - (*url)[datalen - (*r_fprlen + 1)] = '\0'; + memcpy (*r_url, + data + (*r_fprlen + 1), datalen - (*r_fprlen + 1)); + (*r_url)[datalen - (*r_fprlen + 1)] = '\0'; } else *r_url = NULL; commit f101f34fffee4a02e7a5f62b59667e45e50e8325 Author: Werner Koch Date: Wed Jul 31 16:15:01 2013 +0200 common: Comment out unused code. * common/w32-reg.c (write_w32_registry_string): Comment out. diff --git a/common/w32-reg.c b/common/w32-reg.c index d3cb815..3ef7a0a 100644 --- a/common/w32-reg.c +++ b/common/w32-reg.c @@ -225,6 +225,7 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) /* Note: This code is not well tested. However, it is not used in GnuPG. */ +#if 0 int write_w32_registry_string (const char *root, const char *dir, const char *name, const char *value) @@ -319,5 +320,5 @@ write_w32_registry_string (const char *root, const char *dir, return 0; #endif /*!HAVE_W32CE_SYSTEM*/ } - +#endif /*0*/ #endif /*HAVE_W32_SYSTEM*/ diff --git a/common/w32help.h b/common/w32help.h index 50eda67..b9b7c44 100644 --- a/common/w32help.h +++ b/common/w32help.h @@ -35,9 +35,6 @@ /*-- w32-reg.c --*/ char *read_w32_registry_string (const char *root, const char *dir, const char *name ); -int write_w32_registry_string (const char *root, const char *dir, - const char *name, const char *value); - /* Other stuff. */ #ifdef HAVE_W32CE_SYSTEM commit 2830fcb83c99289a49da0e111766daf2d9a1fa3b Author: Werner Koch Date: Wed Jul 31 16:14:00 2013 +0200 dirmngr: Remove unused file. * dirmngr/get-path.c: Remove. diff --git a/dirmngr/get-path.c b/dirmngr/get-path.c deleted file mode 100644 index e5a1fdf..0000000 --- a/dirmngr/get-path.c +++ /dev/null @@ -1,620 +0,0 @@ -/* get-path.c - Utility functions for the W32 API - Copyright (C) 1999 Free Software Foundation, Inc - Copyright (C) 2001 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH - - This file is part of DirMngr. - - DirMngr is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DirMngr is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA */ - -#error Code has been replaced by common/homedir.c - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_W32_SYSTEM -#include -#include -#include -#endif - -#include "util.h" - -#ifdef HAVE_W32_SYSTEM -#define GNUPG_DEFAULT_HOMEDIR "c:/gnupg" -#elif defined(__VMS) -#define GNUPG_DEFAULT_HOMEDIR "/SYS\$LOGIN/gnupg" -#else -#define GNUPG_DEFAULT_HOMEDIR "~/.gnupg" -#endif - -#ifdef HAVE_DOSISH_SYSTEM -#define DIRSEP_C '\\' -#define DIRSEP_S "\\" -#else -#define DIRSEP_C '/' -#define DIRSEP_S "/" -#endif - - -#ifdef HAVE_W32_SYSTEM -#define RTLD_LAZY 0 - -static __inline__ void * -dlopen (const char * name, int flag) -{ - void * hd = LoadLibrary (name); - return hd; -} - -static __inline__ void * -dlsym (void * hd, const char * sym) -{ - if (hd && sym) - { - void * fnc = GetProcAddress (hd, sym); - if (!fnc) - return NULL; - return fnc; - } - return NULL; -} - -static __inline__ int -dlclose (void * hd) -{ - if (hd) - { - FreeLibrary (hd); - return 0; - } - return -1; -} - - -/* Return a string from the W32 Registry or NULL in case of error. - Caller must release the return value. A NULL for root is an alias - for HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE in turn. */ -static char * -read_w32_registry_string (const char *root, const char *dir, const char *name) -{ - HKEY root_key, key_handle; - DWORD n1, nbytes, type; - char *result = NULL; - - if ( !root ) - root_key = HKEY_CURRENT_USER; - else if ( !strcmp( root, "HKEY_CLASSES_ROOT" ) ) - root_key = HKEY_CLASSES_ROOT; - else if ( !strcmp( root, "HKEY_CURRENT_USER" ) ) - root_key = HKEY_CURRENT_USER; - else if ( !strcmp( root, "HKEY_LOCAL_MACHINE" ) ) - root_key = HKEY_LOCAL_MACHINE; - else if ( !strcmp( root, "HKEY_USERS" ) ) - root_key = HKEY_USERS; - else if ( !strcmp( root, "HKEY_PERFORMANCE_DATA" ) ) - root_key = HKEY_PERFORMANCE_DATA; - else if ( !strcmp( root, "HKEY_CURRENT_CONFIG" ) ) - root_key = HKEY_CURRENT_CONFIG; - else - return NULL; - - if ( RegOpenKeyEx ( root_key, dir, 0, KEY_READ, &key_handle ) ) - { - if (root) - return NULL; /* no need for a RegClose, so return direct */ - /* It seems to be common practise to fall back to HKLM. */ - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle) ) - return NULL; /* still no need for a RegClose, so return direct */ - } - - nbytes = 1; - if ( RegQueryValueEx( key_handle, name, 0, NULL, NULL, &nbytes ) ) - { - if (root) - goto leave; - /* Try to fallback to HKLM also vor a missing value. */ - RegCloseKey (key_handle); - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle) ) - return NULL; /* Nope. */ - if (RegQueryValueEx ( key_handle, name, 0, NULL, NULL, &nbytes)) - goto leave; - } - result = malloc ( (n1=nbytes+1) ); - if ( !result ) - goto leave; - if ( RegQueryValueEx ( key_handle, name, 0, &type, result, &n1 ) ) - { - free(result); result = NULL; - goto leave; - } - result[nbytes] = 0; /* Make sure it is really a string. */ - if (type == REG_EXPAND_SZ && strchr (result, '%')) - { - char *tmp; - - n1 += 1000; - tmp = malloc (n1+1); - if (!tmp) - goto leave; - nbytes = ExpandEnvironmentStrings (result, tmp, n1); - if (nbytes && nbytes > n1) - { - free (tmp); - n1 = nbytes; - tmp = malloc (n1 + 1); - if (!tmp) - goto leave; - nbytes = ExpandEnvironmentStrings (result, tmp, n1); - if (nbytes && nbytes > n1) { - free (tmp); /* Oops - truncated, better don't expand at all. */ - goto leave; - } - tmp[nbytes] = 0; - free (result); - result = tmp; - } - else if (nbytes) /* Okay, reduce the length. */ - { - tmp[nbytes] = 0; - free (result); - result = malloc (strlen (tmp)+1); - if (!result) - result = tmp; - else - { - strcpy (result, tmp); - free (tmp); - } - } - else /* Error - don't expand. */ - { - free (tmp); - } - } - - leave: - RegCloseKey( key_handle ); - return result; -} - - -/* This is a helper function to load and run a Windows function from - either of one DLLs. */ -static HRESULT -w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e) -{ - static int initialized; - static HRESULT (WINAPI * func)(HWND,int,HANDLE,DWORD,LPSTR); - - if (!initialized) - { - static char *dllnames[] = { "shell32.dll", "shfolder.dll", NULL }; - void *handle; - int i; - - initialized = 1; - - for (i=0, handle = NULL; !handle && dllnames[i]; i++) - { - handle = dlopen (dllnames[i], RTLD_LAZY); - if (handle) - { - func = dlsym (handle, "SHGetFolderPathA"); - if (!func) - { - dlclose (handle); - handle = NULL; - } - } - } - } - - if (func) - return func (a,b,c,d,e); - else - return -1; -} - - -#if 0 -static char * -find_program_in_inst_dir (const char *name) -{ - char *result = NULL; - char *tmp; - - tmp = read_w32_registry_string ("HKEY_LOCAL_MACHINE", - "Software\\GNU\\GnuPG", - "Install Directory"); - if (!tmp) - return NULL; - - result = malloc (strlen (tmp) + 1 + strlen (name) + 1); - if (!result) - { - free (tmp); - return NULL; - } - - strcpy (stpcpy (stpcpy (result, tmp), "\\"), name); - free (tmp); - if (access (result, F_OK)) - { - free (result); - return NULL; - } - - return result; -} - - -static char * -find_program_at_standard_place (const char *name) -{ - char path[MAX_PATH]; - char *result = NULL; - - if (w32_shgetfolderpath (NULL, CSIDL_PROGRAM_FILES, NULL, 0, path) >= 0) - { - result = malloc (strlen (path) + 1 + strlen (name) + 1); - if (result) - { - strcpy (stpcpy (stpcpy (result, path), "\\"), name); - if (access (result, F_OK)) - { - free (result); - result = NULL; - } - } - } - return result; -} -#endif -#endif - - -const char * -get_dirmngr_ldap_path (void) -{ - static char *pgmname; - -#ifdef HAVE_W32_SYSTEM - if (! pgmname) - { - const char *dir = dirmngr_libexecdir (); - const char *exe = "\\dirmngr_ldap.exe"; - pgmname = malloc (strlen (dir) + strlen (exe) + 1); - if (pgmname) - strcpy (stpcpy (pgmname, dir), exe); - } -#endif - if (!pgmname) - pgmname = DIRMNGR_LIBEXECDIR "/dirmngr_ldap"; - return pgmname; -} - - - -/* Home directory. */ - -#ifdef HAVE_W32_SYSTEM -#ifndef CSIDL_APPDATA -#define CSIDL_APPDATA 0x001a -#endif -#ifndef CSIDL_LOCAL_APPDATA -#define CSIDL_LOCAL_APPDATA 0x001c -#endif -#ifndef CSIDL_COMMON_APPDATA -#define CSIDL_COMMON_APPDATA 0x0023 -#endif -#ifndef CSIDL_FLAG_CREATE -#define CSIDL_FLAG_CREATE 0x8000 -#endif -#endif /*HAVE_W32_SYSTEM*/ - -/* Get the standard home directory. In general this function should - not be used as it does not consider a registry value (under W32) or - the GNUPGHOME environment variable. It is better to use - default_homedir(). */ -const char * -standard_homedir (void) -{ -#ifdef HAVE_W32_SYSTEM - static const char *dir; - - if (!dir) - { - char path[MAX_PATH]; - - /* It might be better to use LOCAL_APPDATA because this is - defined as "non roaming" and thus more likely to be kept - locally. For private keys this is desired. However, given - that many users copy private keys anyway forth and back, - using a system roaming services might be better than to let - them do it manually. A security conscious user will anyway - use the registry entry to have better control. */ - if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, - NULL, 0, path) >= 0) - { - char *tmp = xmalloc (strlen (path) + 6 +1); - strcpy (stpcpy (tmp, path), "\\gnupg"); - dir = tmp; - - /* Try to create the directory if it does not yet exists. */ - if (access (dir, F_OK)) - CreateDirectory (dir, NULL); - } - else - dir = GNUPG_DEFAULT_HOMEDIR; - } - return dir; -#else/*!HAVE_W32_SYSTEM*/ - return GNUPG_DEFAULT_HOMEDIR; -#endif /*!HAVE_W32_SYSTEM*/ -} - -/* Set up the default home directory. The usual --homedir option - should be parsed later. */ -const char * -default_homedir (void) -{ - const char *dir; - - dir = getenv ("GNUPGHOME"); -#ifdef HAVE_W32_SYSTEM - if (!dir || !*dir) - { - static const char *saved_dir; - - if (!saved_dir) - { - if (!dir || !*dir) - { - char *tmp; - - tmp = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", - "HomeDir"); - if (tmp && *tmp) - { - xfree (tmp); - tmp = NULL; - } - if (tmp) - saved_dir = tmp; - } - - if (!saved_dir) - saved_dir = standard_homedir (); - } - dir = saved_dir; - } -#endif /*HAVE_W32_SYSTEM*/ - if (!dir || !*dir) - dir = GNUPG_DEFAULT_HOMEDIR; - - return dir; -} - - -#ifdef HAVE_W32_SYSTEM -static const char * -w32_rootdir (void) -{ - static int got_dir; - static char dir[MAX_PATH+5]; - - if (!got_dir) - { - char *p; - - if ( !GetModuleFileName ( NULL, dir, MAX_PATH) ) - { - log_debug ("GetModuleFileName failed: %s\n", w32_strerror (0)); - *dir = 0; - } - got_dir = 1; - p = strrchr (dir, DIRSEP_C); - if (p) - *p = 0; - else - { - log_debug ("bad filename '%s' returned for this process\n", dir); - *dir = 0; - } - } - - if (*dir) - return dir; - /* Fallback to the hardwired value. */ - return DIRMNGR_LIBEXECDIR; -} - -static const char * -w32_commondir (void) -{ - static char *dir; - - if (!dir) - { - char path[MAX_PATH]; - - if (w32_shgetfolderpath (NULL, CSIDL_COMMON_APPDATA, - NULL, 0, path) >= 0) - { - char *tmp = xmalloc (strlen (path) + 4 +1); - strcpy (stpcpy (tmp, path), "\\GNU"); - dir = tmp; - /* No auto create of the directory. Either the installer or - the admin has to create these directories. */ - } - else - { - /* Ooops: Not defined - probably an old Windows version. - Use the installation directory instead. */ - dir = xstrdup (w32_rootdir ()); - } - } - - return dir; -} -#endif /*HAVE_W32_SYSTEM*/ - - - - -/* Return the name of the sysconfdir. This is a static string. This - function is required because under Windows we can't simply compile - it in. */ -const char * -dirmngr_sysconfdir (void) -{ -#ifdef HAVE_W32_SYSTEM - static char *name; - - if (!name) - { - const char *s1, *s2; - s1 = w32_commondir (); - s2 = DIRSEP_S "etc" DIRSEP_S "dirmngr"; - name = xmalloc (strlen (s1) + strlen (s2) + 1); - strcpy (stpcpy (name, s1), s2); - } - return name; -#else /*!HAVE_W32_SYSTEM*/ - return DIRMNGR_SYSCONFDIR; -#endif /*!HAVE_W32_SYSTEM*/ -} - - -/* Return the name of the libexec directory. The name is allocated in - a static area on the first use. This function won't fail. */ -const char * -dirmngr_libexecdir (void) -{ -#ifdef HAVE_W32_SYSTEM - return w32_rootdir (); -#else /*!HAVE_W32_SYSTEM*/ - return DIRMNGR_LIBEXECDIR; -#endif /*!HAVE_W32_SYSTEM*/ -} - - -const char * -dirmngr_datadir (void) -{ -#ifdef HAVE_W32_SYSTEM - static char *name; - - if (!name) - { - const char *s1, *s2; - s1 = w32_commondir (); - s2 = DIRSEP_S "lib" DIRSEP_S "dirmngr"; - name = xmalloc (strlen (s1) + strlen (s2) + 1); - strcpy (stpcpy (name, s1), s2); - } - return name; -#else /*!HAVE_W32_SYSTEM*/ - return DIRMNGR_DATADIR; -#endif /*!HAVE_W32_SYSTEM*/ -} - - -const char * -dirmngr_cachedir (void) -{ -#ifdef HAVE_W32_SYSTEM - static const char *dir; - - if (!dir) - { - char path[MAX_PATH]; - const char *s1[] = { "GNU", "cache", "dirmngr", NULL }; - int s1_len; - const char **comp; - - s1_len = 0; - for (comp = s1; *comp; comp++) - { - /* Take account for the separator. */ - s1_len += 1 + strlen (*comp); - } - - if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, - NULL, 0, path) >= 0) - { - char *tmp = xmalloc (strlen (path) + s1_len + 1); - char *p; - - p = stpcpy (tmp, path); - for (comp = s1; *comp; comp++) - { - p = stpcpy (p, "\\"); - p = stpcpy (p, *comp); - - if (access (tmp, F_OK)) - CreateDirectory (tmp, NULL); - } - - dir = tmp; - } - else - dir = "c:\\temp\\cache\\dirmngr"; - } - return dir; -#else /*!HAVE_W32_SYSTEM*/ - return DIRMNGR_CACHEDIR; -#endif /*!HAVE_W32_SYSTEM*/ -} - - -const char * -default_socket_name (void) -{ -#ifdef HAVE_W32_SYSTEM - static char *name; - - if (!name) - { - char s1[MAX_PATH]; - const char *s2; - - /* We need something akin CSIDL_COMMON_PROGRAMS, but local - (non-roaming). This is becuase the file needs to be on the - local machine and makes only sense on that machine. - CSIDL_WINDOWS seems to be the only location which guarantees - that. */ - if (w32_shgetfolderpath (NULL, CSIDL_WINDOWS, NULL, 0, s1) < 0) - strcpy (s1, "C:\\WINDOWS"); - s2 = DIRSEP_S "S.dirmngr"; - name = xmalloc (strlen (s1) + strlen (s2) + 1); - strcpy (stpcpy (name, s1), s2); - } - return name; -#else /*!HAVE_W32_SYSTEM*/ - return DIRMNGR_SOCKETDIR "/socket"; -#endif /*!HAVE_W32_SYSTEM*/ -} commit f254497e09fa4e0e24e63d14f7316fc31c938844 Author: Werner Koch Date: Thu Jun 27 11:40:12 2013 +0200 sm: Remove cruft from source files. * sm/keydb.c, sm/keydb.h: Remove disabled code parts. diff --git a/sm/keydb.c b/sm/keydb.c index 6912b42..de9c95c 100644 --- a/sm/keydb.c +++ b/sm/keydb.c @@ -477,113 +477,6 @@ unlock_all (KEYDB_HANDLE hd) } -#if 0 -/* - * Return the last found keybox. Caller must free it. - * The returned keyblock has the kbode flag bit 0 set for the node with - * the public key used to locate the keyblock or flag bit 1 set for - * the user ID node. - */ -int -keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb) -{ - int rc = 0; - - if (!hd) - return G10ERR_INV_ARG; - - if ( hd->found < 0 || hd->found >= hd->used) - return -1; /* nothing found */ - - switch (hd->active[hd->found].type) { - case KEYDB_RESOURCE_TYPE_NONE: - rc = G10ERR_GENERAL; /* oops */ - break; - case KEYDB_RESOURCE_TYPE_KEYBOX: - rc = keybox_get_keyblock (hd->active[hd->found].u.kr, ret_kb); - break; - } - - return rc; -} - -/* - * update the current keyblock with KB - */ -int -keydb_update_keyblock (KEYDB_HANDLE hd, KBNODE kb) -{ - int rc = 0; - - if (!hd) - return G10ERR_INV_ARG; - - if ( hd->found < 0 || hd->found >= hd->used) - return -1; /* nothing found */ - - if( opt.dry_run ) - return 0; - - if (!hd->locked) - return gpg_error (GPG_ERR_NOT_LOCKED); - - switch (hd->active[hd->found].type) { - case KEYDB_RESOURCE_TYPE_NONE: - rc = G10ERR_GENERAL; /* oops */ - break; - case KEYDB_RESOURCE_TYPE_KEYBOX: - rc = keybox_update_keyblock (hd->active[hd->found].u.kr, kb); - break; - } - - unlock_all (hd); - return rc; -} - - -/* - * Insert a new KB into one of the resources. - */ -int -keydb_insert_keyblock (KEYDB_HANDLE hd, KBNODE kb) -{ - int rc = -1; - int idx; - - if (!hd) - return G10ERR_INV_ARG; - - if( opt.dry_run ) - return 0; - - if ( hd->found >= 0 && hd->found < hd->used) - idx = hd->found; - else if ( hd->current >= 0 && hd->current < hd->used) - idx = hd->current; - else - return G10ERR_GENERAL; - - rc = lock_all (hd); - if (rc) - return rc; - - switch (hd->active[idx].type) { - case KEYDB_RESOURCE_TYPE_NONE: - rc = G10ERR_GENERAL; /* oops */ - break; - case KEYDB_RESOURCE_TYPE_KEYBOX: - rc = keybox_insert_keyblock (hd->active[idx].u.kr, kb); - break; - } - - unlock_all (hd); - return rc; -} - -#endif /*disabled code*/ - - - /* Return the last found object. Caller must free it. The returned keyblock has the kbode flag bit 0 set for the node with the public diff --git a/sm/keydb.h b/sm/keydb.h index 33876ce..6e432f8 100644 --- a/sm/keydb.h +++ b/sm/keydb.h @@ -39,12 +39,6 @@ int keydb_set_ephemeral (KEYDB_HANDLE hd, int yes); const char *keydb_get_resource_name (KEYDB_HANDLE hd); gpg_error_t keydb_lock (KEYDB_HANDLE hd); -#if 0 /* pgp stuff */ -int keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb); -int keydb_update_keyblock (KEYDB_HANDLE hd, KBNODE kb); -int keydb_insert_keyblock (KEYDB_HANDLE hd, KBNODE kb); -#endif - gpg_error_t keydb_get_flags (KEYDB_HANDLE hd, int which, int idx, unsigned int *value); gpg_error_t keydb_set_flags (KEYDB_HANDLE hd, int which, int idx, ----------------------------------------------------------------------- Summary of changes: NEWS | 4 +- agent/protect.c | 1 + autogen.sh | 2 +- common/dns-cert.c | 9 +- common/homedir.c | 241 +++++++++++++++----- common/logging.c | 16 ++- common/logging.h | 1 + common/w32-reg.c | 3 +- common/w32help.h | 3 - configure.ac | 3 + dirmngr/get-path.c | 620 -------------------------------------------------- dirmngr/ldap-url.c | 5 + doc/opt-homedir.texi | 14 +- scd/apdu.c | 2 +- sm/keydb.c | 107 --------- sm/keydb.h | 6 - 16 files changed, 232 insertions(+), 805 deletions(-) delete mode 100644 dirmngr/get-path.c hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Thu Aug 1 15:26:13 2013 From: cvs at cvs.gnupg.org (by Andre Heinecke) Date: Thu, 01 Aug 2013 15:26:13 +0200 Subject: [git] GpgOL - branch, master, updated. gpgol-1.1.3-47-ge5f2b3f Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG extension for MS Outlook". The branch, master has been updated via e5f2b3f718ab56c1ecc0528d9117cbdd953815f6 (commit) via bce68bff2375e9a2a756074aade51542a341d7e2 (commit) from 1b5a49b6039d86989f5154ea0fd6e45d9c912d37 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e5f2b3f718ab56c1ecc0528d9117cbdd953815f6 Author: Andre Heinecke Date: Thu Aug 1 12:55:33 2013 +0000 Fix accessing uninitialized memory When called to decrypt the full body the wordApplication, wordEditor and selection would be uninitalized and but when they are not NULL they would still be released in the end. * src/ribbon-callbacks.cpp (decryptInspector): Initialize dispatcher pointers. diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp index 1f0ac46..529cdf2 100644 --- a/src/ribbon-callbacks.cpp +++ b/src/ribbon-callbacks.cpp @@ -445,11 +445,11 @@ decryptAttachments (LPDISPATCH ctrl) HRESULT decryptInspector (LPDISPATCH ctrl, int flags) { - LPDISPATCH context; - LPDISPATCH selection; - LPDISPATCH wordEditor; - LPDISPATCH mailItem; - LPDISPATCH wordApplication; + LPDISPATCH context = NULL; + LPDISPATCH selection = NULL; + LPDISPATCH wordEditor = NULL; + LPDISPATCH mailItem = NULL; + LPDISPATCH wordApplication = NULL; struct sink_s decsinkmem; sink_t decsink = &decsinkmem; commit bce68bff2375e9a2a756074aade51542a341d7e2 Author: Andre Heinecke Date: Wed Jul 31 14:27:32 2013 +0000 Factor out recipient lookup and some cleanups * src/oomhelp.cpp, src/oomhelp.h (get_oom_recipients): New. * src/ribbon-callbacks.cpp (encrypt_inspector): Move out recipient handling code. Fix indentation. (decrypt_inspector): Clean up some comments. diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp index 73270f2..21be27f 100644 --- a/src/oomhelp.cpp +++ b/src/oomhelp.cpp @@ -789,3 +789,38 @@ get_oom_context_window (LPDISPATCH context) return ret; } +/* Gets a malloced NULL terminated array of recipent strings from + an OOM recipients Object. */ +char ** +get_oom_recipients (LPDISPATCH recipients) +{ + int recipientsCnt = get_oom_int (recipients, "Count"); + char **recipientAddrs = NULL; + int i; + + if (!recipientsCnt) + { + return NULL; + } + + /* Get the recipients */ + recipientAddrs = (char**) xmalloc((recipientsCnt + 1) * sizeof(char*)); + recipientAddrs[recipientsCnt] = NULL; + for (i = 1; i <= recipientsCnt; i++) + { + char buf[16]; + LPDISPATCH recipient; + snprintf (buf, sizeof (buf), "Item(%i)", i); + recipient = get_oom_object (recipients, buf); + if (!recipient) + { + /* Should be impossible */ + recipientAddrs[i-1] = NULL; + log_error ("%s:%s: could not find Item %i;", + SRCNAME, __func__, i); + break; + } + recipientAddrs[i-1] = get_oom_string (recipient, "Address"); + } + return recipientAddrs; +} diff --git a/src/oomhelp.h b/src/oomhelp.h index 1f62cbf..231c27d 100644 --- a/src/oomhelp.h +++ b/src/oomhelp.h @@ -121,6 +121,10 @@ void del_oom_button (LPDISPATCH button); /* Get the HWND of the active window in the current context */ HWND get_oom_context_window (LPDISPATCH context); +/* Get the address of the recipients as string list */ +char ** +get_oom_recipients (LPDISPATCH recipients); + #ifdef __cplusplus } #endif diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp index 2b6d809..1f0ac46 100644 --- a/src/ribbon-callbacks.cpp +++ b/src/ribbon-callbacks.cpp @@ -81,12 +81,12 @@ encryptInspector (LPDISPATCH ctrl, int flags) struct sink_s sinkmem; sink_t sink = &sinkmem; char* senderAddr = NULL; + char** recipientAddrs = NULL; LPSTREAM tmpstream = NULL; engine_filter_t filter = NULL; char* plaintext = NULL; int rc = 0; HRESULT hr; - int recipientsCnt; HWND curWindow; protocol_t protocol; unsigned int session_number; @@ -128,7 +128,6 @@ encryptInspector (LPDISPATCH ctrl, int flags) if (!plaintext || strlen (plaintext) <= 1) { - /* TODO more usable if we just use all text in this case? */ MessageBox (NULL, _("Please select text to encrypt."), _("GpgOL"), @@ -141,7 +140,6 @@ encryptInspector (LPDISPATCH ctrl, int flags) plaintext = get_oom_string (mailItem, "Body"); if (!plaintext || strlen (plaintext) <= 1) { - /* TODO more usable if we just use all text in this case? */ MessageBox (NULL, _("Textbody empty."), _("GpgOL"), @@ -169,9 +167,9 @@ encryptInspector (LPDISPATCH ctrl, int flags) senderAddr = get_oom_string (sender, "Address"); - recipientsCnt = get_oom_int (recipients, "Count"); + recipientAddrs = get_oom_recipients (recipients); - if (!recipientsCnt) + if (!recipientAddrs || !(*recipientAddrs)) { MessageBox (NULL, _("Please add at least one recipent."), @@ -180,92 +178,64 @@ encryptInspector (LPDISPATCH ctrl, int flags) goto failure; } - { - /* Get the recipients */ - char *recipientAddrs[recipientsCnt + 1]; - recipientAddrs[recipientsCnt] = NULL; - for (i = 1; i <= recipientsCnt; i++) - { - char buf[16]; - LPDISPATCH recipient; - snprintf (buf, sizeof (buf), "Item(%i)", i); - recipient = get_oom_object (recipients, buf); - if (!recipient) - { - /* Should be impossible */ - recipientAddrs[i-1] = NULL; - log_error ("%s:%s: could not find Item %i;", - SRCNAME, __func__, i); - break; - } - recipientAddrs[i-1] = get_oom_string (recipient, "Address"); - } - - /* Not lets prepare our encryption */ - session_number = engine_new_session_number (); + /* Now lets prepare our encryption */ + session_number = engine_new_session_number (); - /* Prepare the encryption sink */ + /* Prepare the encryption sink */ - if (engine_create_filter (&filter, write_buffer_for_cb, sink)) - { - for (i = 0; i < recipientsCnt; i++) - xfree (recipientAddrs[i]); - goto failure; - } + if (engine_create_filter (&filter, write_buffer_for_cb, sink)) + { + goto failure; + } - encsink->cb_data = filter; - encsink->writefnc = sink_encryption_write; + encsink->cb_data = filter; + encsink->writefnc = sink_encryption_write; - engine_set_session_number (filter, session_number); - engine_set_session_title (filter, _("GpgOL")); + engine_set_session_number (filter, session_number); + engine_set_session_title (filter, _("GpgOL")); - if ((rc=engine_encrypt_prepare (filter, curWindow, - PROTOCOL_UNKNOWN, - 0 /* ENGINE_FLAG_SIGN_FOLLOWS */, - senderAddr, recipientAddrs, &protocol))) - { - for (i = 0; i < recipientsCnt; i++) - xfree (recipientAddrs[i]); - log_error ("%s:%s: engine encrypt prepare failed : %s", - SRCNAME, __func__, gpg_strerror (rc)); - goto failure; - } - for (i = 0; i < recipientsCnt; i++) - xfree (recipientAddrs[i]); + if ((rc=engine_encrypt_prepare (filter, curWindow, + PROTOCOL_UNKNOWN, + 0 /* ENGINE_FLAG_SIGN_FOLLOWS */, + senderAddr, recipientAddrs, &protocol))) + { + log_error ("%s:%s: engine encrypt prepare failed : %s", + SRCNAME, __func__, gpg_strerror (rc)); + goto failure; + } - /* lets go */ + /* lets go */ - if ((rc=engine_encrypt_start (filter, 0))) - { - log_error ("%s:%s: engine encrypt start failed: %s", - SRCNAME, __func__, gpg_strerror (rc)); - goto failure; - } + if ((rc=engine_encrypt_start (filter, 0))) + { + log_error ("%s:%s: engine encrypt start failed: %s", + SRCNAME, __func__, gpg_strerror (rc)); + goto failure; + } - /* Write the text in the encryption sink. */ - rc = write_buffer (encsink, plaintext, strlen (plaintext)); + /* Write the text in the encryption sink. */ + rc = write_buffer (encsink, plaintext, strlen (plaintext)); - if (rc) - { - log_error ("%s:%s: writing tmpstream to encsink failed: %s", - SRCNAME, __func__, gpg_strerror (rc)); - goto failure; - } - /* Flush the encryption sink and wait for the encryption to get - ready. */ - if ((rc = write_buffer (encsink, NULL, 0))) - goto failure; - if ((rc = engine_wait (filter))) + if (rc) + { + log_error ("%s:%s: writing tmpstream to encsink failed: %s", + SRCNAME, __func__, gpg_strerror (rc)); goto failure; - filter = NULL; /* Not valid anymore. */ - encsink->cb_data = NULL; /* Not needed anymore. */ + } + /* Flush the encryption sink and wait for the encryption to get + ready. */ + if ((rc = write_buffer (encsink, NULL, 0))) + goto failure; + if ((rc = engine_wait (filter))) + goto failure; + filter = NULL; /* Not valid anymore. */ + encsink->cb_data = NULL; /* Not needed anymore. */ - if (!sink->enc_counter) - { - log_debug ("%s:%s: nothing received from engine", SRCNAME, __func__); - goto failure; - } - } + if (!sink->enc_counter) + { + log_debug ("%s:%s: nothing received from engine", SRCNAME, __func__); + goto failure; + } /* Check the size of the encrypted data */ tmpstream->Stat (&tmpStat, 0); @@ -344,7 +314,7 @@ encryptInspector (LPDISPATCH ctrl, int flags) } } - failure: +failure: if (rc) log_debug ("%s:%s: failed rc=%d (%s) <%s>", SRCNAME, __func__, rc, gpg_strerror (rc), gpg_strsource (rc)); @@ -358,6 +328,11 @@ encryptInspector (LPDISPATCH ctrl, int flags) RELDISP(tmpstream); xfree (plaintext); xfree (senderAddr); + while (recipientAddrs && *recipientAddrs) + { + xfree (*recipientAddrs++); + } + xfree (recipientAddrs); return S_OK; } @@ -610,7 +585,7 @@ decryptInspector (LPDISPATCH ctrl, int flags) /* Write the text in the decryption sink. */ rc = write_buffer (decsink, encData, encDataLen); - /* Flush the decryption sink and wait for the encryption to get + /* Flush the decryption sink and wait for the decryption to get ready. */ if ((rc = write_buffer (decsink, NULL, 0))) goto failure; @@ -635,7 +610,7 @@ decryptInspector (LPDISPATCH ctrl, int flags) goto failure; } - /* Copy the encrypted stream to the message editor. */ + /* Copy the decrypted stream to the message editor. */ { LARGE_INTEGER off; ULONG nread; @@ -660,7 +635,7 @@ decryptInspector (LPDISPATCH ctrl, int flags) } if (strlen (buffer) > 1) { - /* Now replace the crypto data with the encData or show it + /* Now replace the crypto data with the decrypted data or show it somehow.*/ int err; if (flags & DECRYPT_INSPECTOR_SELECTION) ----------------------------------------------------------------------- Summary of changes: src/oomhelp.cpp | 35 +++++++++++ src/oomhelp.h | 4 + src/ribbon-callbacks.cpp | 153 +++++++++++++++++++--------------------------- 3 files changed, 103 insertions(+), 89 deletions(-) hooks/post-receive -- GnuPG extension for MS Outlook http://git.gnupg.org From cvs at cvs.gnupg.org Thu Aug 1 15:38:04 2013 From: cvs at cvs.gnupg.org (by Andre Heinecke) Date: Thu, 01 Aug 2013 15:38:04 +0200 Subject: [git] GpgOL - branch, master, updated. gpgol-1.1.3-48-g1a9124f Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG extension for MS Outlook". The branch, master has been updated via 1a9124f08d88a4549623b45146870fe7125ab60d (commit) from e5f2b3f718ab56c1ecc0528d9117cbdd953815f6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1a9124f08d88a4549623b45146870fe7125ab60d Author: Andre Heinecke Date: Thu Aug 1 13:05:45 2013 +0000 Be more agressive in fix linebreaks This now replaces all consecutive break indicating characters by a single \n. * src/common.c (fix_linebreaks): Replace all consecutive linebreaks. -- There are problems that some messages can not be decrypted because the line endings are so messed up. \r\r\n\r\r\n is an example of a line break I get when I've sent an encrypted message with KMail. Outlook shows only one break but returns that if you access the body over the OOM. diff --git a/src/common.c b/src/common.c index f458b15..9818ae5 100644 --- a/src/common.c +++ b/src/common.c @@ -1023,10 +1023,11 @@ percent_escape (const char *str, const char *extra) } /* Fix linebreaks. - This either removes the \r if it is followed by a \n - or replaces it by a \n. This is neccessary because - Micrsoft Word buffers appearently use only the \r - to indicate line breaks. + This replaces all consecutive \r or \n characters + by a single \n. + There can be extremly weird combinations of linebreaks + like \r\r\n\r\r\n at the end of each line when + getting the body of a mail message. */ void fix_linebreaks (char *str, int *len) @@ -1038,11 +1039,17 @@ fix_linebreaks (char *str, int *len) dst = str; while (*src) { - if (src[0] == '\r' && src[1] == '\n') - src++; - else if (src[0] == '\r') - src[0] = '\n'; - *(dst++) = *(src++); + if (*src == '\r' || *src == '\n') + { + do + src++; + while (*src == '\r' || *src == '\n'); + *(dst++) = '\n'; + } + else + { + *(dst++) = *(src++); + } } *dst = '\0'; *len = dst - str; ----------------------------------------------------------------------- Summary of changes: src/common.c | 25 ++++++++++++++++--------- 1 files changed, 16 insertions(+), 9 deletions(-) hooks/post-receive -- GnuPG extension for MS Outlook http://git.gnupg.org From cvs at cvs.gnupg.org Thu Aug 1 20:22:28 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 01 Aug 2013 20:22:28 +0200 Subject: [git] GnuPG - branch, STABLE-BRANCH-2-0, updated. gnupg-2.0.20-23-g4f90c7b Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, STABLE-BRANCH-2-0 has been updated via 4f90c7b914693b72341fa1e93dda7e075f9717c0 (commit) via aff557409cde6ee38ac086046d9bb5eb2dc5c95b (commit) via 1b89863ec195dbfdbc33432569a7b2e7f0f83821 (commit) from c3a57d767719a58ec791a0791842bcc80c859081 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4f90c7b914693b72341fa1e93dda7e075f9717c0 Author: Werner Koch Date: Thu Aug 1 19:50:52 2013 +0200 w32: Add code to support a portable use of GnuPG. * common/homedir.c (w32_bin_is_bin, w32_portable_app) [W32]: New. (check_portable_app) [W32]: New. (standard_homedir, default_homedir) [W32]: Support the portable flag. (w32_rootdir, w32_commondir) [W32]: Ditto. (gnupg_bindir) [W32]: Ditto. -- A portable use of GnuPG under Windows means that GnuPG uses a home directory depending on the location of the actual binary. No registry variables are considered. The portable mode is enabled if in the installation directory of the the binary "gpgconf.exe" and a file "gpgconf.ctl" are found. The latter file shall be empty or consist only of empty or '#'-style comment lines. Signed-off-by: Werner Koch diff --git a/NEWS b/NEWS index 782a54b..990e241 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ Noteworthy changes in version 2.0.21 (unreleased) * The new option --enable-putty-support allows gpg-agent on Windows to act as a Pageant replacement with full smartcard support. + * Support installation as portable application under Windows. + Noteworthy changes in version 2.0.20 (2013-05-10) ------------------------------------------------- diff --git a/common/homedir.c b/common/homedir.c index 5adf46a..4b03cfe 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -1,5 +1,6 @@ /* homedir.c - Setup the home directory. - * Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + * Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + * Copyright (C) 2013 Werner Koch * * This file is part of GnuPG. * @@ -47,6 +48,33 @@ #include "sysutils.h" +#ifdef HAVE_W32_SYSTEM +/* A flag used to indicate that a control file for gpgconf has been + detected. Under Windows the presence of this file indicates a + portable installations and triggers several changes: + + - The GNUGHOME directory is fixed relative to installation + directory. All other means to set the home directory are + ignored. + + - All registry variables are ignored. + + This flag is not used on Unix systems. + */ +static int w32_portable_app; + +/* This flag is true if this process' binary has been installed under + bin and not in the root directory. */ +static int w32_bin_is_bin; + +/* Just a little prototype. */ +static const char *w32_rootdir (void); + +#endif /*HAVE_W32_SYSTEM*/ + + + + /* This is a helper function to load a Windows function from either of one DLLs. */ #ifdef HAVE_W32_SYSTEM @@ -99,28 +127,39 @@ standard_homedir (void) if (!dir) { - char path[MAX_PATH]; + const char *rdir; - /* It might be better to use LOCAL_APPDATA because this is - defined as "non roaming" and thus more likely to be kept - locally. For private keys this is desired. However, given - that many users copy private keys anyway forth and back, - using a system roaming services might be better than to let - them do it manually. A security conscious user will anyway - use the registry entry to have better control. */ - if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, - NULL, 0, path) >= 0) + rdir = w32_rootdir (); + if (w32_portable_app) { - char *tmp = xmalloc (strlen (path) + 6 +1); - strcpy (stpcpy (tmp, path), "\\gnupg"); - dir = tmp; - - /* Try to create the directory if it does not yet exists. */ - if (access (dir, F_OK)) - CreateDirectory (dir, NULL); + dir = xstrconcat (rdir, DIRSEP_S "home", NULL); } else - dir = GNUPG_DEFAULT_HOMEDIR; + { + char path[MAX_PATH]; + + /* It might be better to use LOCAL_APPDATA because this is + defined as "non roaming" and thus more likely to be kept + locally. For private keys this is desired. However, + given that many users copy private keys anyway forth and + back, using a system roaming services might be better + than to let them do it manually. A security conscious + user will anyway use the registry entry to have better + control. */ + if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, + NULL, 0, path) >= 0) + { + char *tmp = xmalloc (strlen (path) + 6 +1); + strcpy (stpcpy (tmp, path), "\\gnupg"); + dir = tmp; + + /* Try to create the directory if it does not yet exists. */ + if (access (dir, F_OK)) + CreateDirectory (dir, NULL); + } + else + dir = GNUPG_DEFAULT_HOMEDIR; + } } return dir; #else/*!HAVE_W32_SYSTEM*/ @@ -135,6 +174,13 @@ default_homedir (void) { const char *dir; +#ifdef HAVE_W32_SYSTEM + /* For a portable application we only use the standard homedir. */ + w32_rootdir (); + if (w32_portable_app) + return standard_homedir (); +#endif /*HAVE_W32_SYSTEM*/ + dir = getenv ("GNUPGHOME"); #ifdef HAVE_W32_SYSTEM if (!dir || !*dir) @@ -172,6 +218,31 @@ default_homedir (void) #ifdef HAVE_W32_SYSTEM +/* Check whether gpgconf is installed and if so read the gpgconf.ctl + file. */ +static void +check_portable_app (const char *dir) +{ + char *fname; + + fname = xstrconcat (dir, DIRSEP_S "gpgconf.exe", NULL); + if (access (fname, F_OK)) + log_error ("required binary '%s' is not installed\n", fname); + else + { + strcpy (fname + strlen (fname) - 3, "ctl"); + if (!access (fname, F_OK)) + { + /* gpgconf.ctl file found. Record this fact. */ + w32_portable_app = 1; + + /* FIXME: We should read the file to detect special flags + and print a warning if we don't understand them. */ + } + } + xfree (fname); +} + static const char * w32_rootdir (void) { @@ -190,8 +261,22 @@ w32_rootdir (void) got_dir = 1; p = strrchr (dir, DIRSEP_C); if (p) - *p = 0; - else + { + *p = 0; + + check_portable_app (dir); + + /* If we are installed below "bin" we strip that and use + the top directory instead. */ + p = strrchr (dir, DIRSEP_C); + + if (p && !strcmp (p+1, "bin")) + { + *p = 0; + w32_bin_is_bin = 1; + } + } + if (!p) { log_debug ("bad filename `%s' returned for this process\n", dir); *dir = 0; @@ -211,8 +296,17 @@ w32_commondir (void) if (!dir) { + const char *rdir; char path[MAX_PATH]; + /* Make sure that w32_rootdir has been called so that we are + able to check the portable application flag. The common dir + is identical to the rootdir. In that case there is also no + need to strdup its value. */ + rdir = w32_rootdir (); + if (w32_portable_app) + return rdir; + if (w32_shgetfolderpath (NULL, CSIDL_COMMON_APPDATA, NULL, 0, path) >= 0) { @@ -226,7 +320,7 @@ w32_commondir (void) { /* Ooops: Not defined - probably an old Windows version. Use the installation directory instead. */ - dir = xstrdup (w32_rootdir ()); + dir = xstrdup (rdir); } } @@ -235,8 +329,6 @@ w32_commondir (void) #endif /*HAVE_W32_SYSTEM*/ - - /* Return the name of the sysconfdir. This is a static string. This function is required because under Windows we can't simply compile it in. */ @@ -265,7 +357,19 @@ const char * gnupg_bindir (void) { #ifdef HAVE_W32_SYSTEM - return w32_rootdir (); + const char *rdir; + + rdir = w32_rootdir (); + if (w32_bin_is_bin) + { + static char *name; + + if (!name) + name = xstrconcat (rdir, DIRSEP_S "bin", NULL); + return name; + } + else + return rdir; #else /*!HAVE_W32_SYSTEM*/ return GNUPG_BINDIR; #endif /*!HAVE_W32_SYSTEM*/ @@ -278,7 +382,7 @@ const char * gnupg_libexecdir (void) { #ifdef HAVE_W32_SYSTEM - return w32_rootdir (); + return gnupg_bindir (); #else /*!HAVE_W32_SYSTEM*/ return GNUPG_LIBEXECDIR; #endif /*!HAVE_W32_SYSTEM*/ diff --git a/doc/gpg-agent.texi b/doc/gpg-agent.texi index dcd96fb..f832b8e 100644 --- a/doc/gpg-agent.texi +++ b/doc/gpg-agent.texi @@ -449,6 +449,16 @@ Do not make use of the scdaemon tool. This option has the effect of disabling the ability to do smartcard operations. Note, that enabling this option at runtime does not kill an already forked scdaemon. + at ifset gpgtwoone + at item --disable-check-own-socket + at opindex disable-check-own-socket + at command{gpg-agent} employs a periodic self-test to detect a stolen +socket. This usually means a second instance of @command{gpg-agent} +has taken over the socket and @command{gpg-agent} will then terminate +itself. This option may be used to disable this self-test for +debugging purposes. + at end ifset + @item --use-standard-socket @itemx --no-use-standard-socket @opindex use-standard-socket @@ -695,14 +705,16 @@ Here is a list of supported signals: @item SIGHUP @cpindex SIGHUP This signal flushes all cached passphrases and if the program has been -started with a configuration file, the configuration file is read again. -Only certain options are honored: @code{quiet}, @code{verbose}, - at code{debug}, @code{debug-all}, @code{debug-level}, @code{no-grab}, - at code{pinentry-program}, @code{default-cache-ttl}, @code{max-cache-ttl}, - at code{ignore-cache-for-signing}, @code{allow-mark-trusted} and - at code{disable-scdaemon}. @code{scdaemon-program} is also supported but -due to the current implementation, which calls the scdaemon only once, -it is not of much use unless you manually kill the scdaemon. +started with a configuration file, the configuration file is read +again. Only certain options are honored: @code{quiet}, + at code{verbose}, @code{debug}, @code{debug-all}, @code{debug-level}, + at code{no-grab}, @code{pinentry-program}, @code{default-cache-ttl}, + at code{max-cache-ttl}, @code{ignore-cache-for-signing}, + at code{allow-mark-trusted}, @code{disable-scdaemon}, and + at code{disable-check-own-socket}. @code{scdaemon-program} is also +supported but due to the current implementation, which calls the +scdaemon only once, it is not of much use unless you manually kill the +scdaemon. @item SIGTERM commit aff557409cde6ee38ac086046d9bb5eb2dc5c95b Author: Werner Koch Date: Thu Aug 1 19:48:00 2013 +0200 w32: Always require libiconv. * configure.ac (missing_iconv): Set and die if we have no libiconv. * m4/iconv.m4: Update from libiconv 1.14. * tools/Makefile.am (gpgtar_LDADD): Add LIBICONV. * jnlib/utf8conv.c: Always include iconv.h (load_libiconv): Remove this w32 only function. (iconv_open, iconv, iconv_close): Remove W32 function pointer. (set_native_charset): Do not call load_libiconv. (jnlib_iconv_open, jnlib_iconv, jnlib_iconv_close): Ditto. -- This patch removes the on-demand-loading of libiconv which we did for 13 years or so. The rationale back then was that libiconv is too large and often not used. Nowadays all kind of Unix software has been ported to Windows and many of them require libiconv. Thus in the end there is no saving from not requiring it. It also remove a common source of trouble with awrong or missing iconv.dll. Signed-off-by: Werner Koch diff --git a/autogen.sh b/autogen.sh index b81a6b2..605babf 100755 --- a/autogen.sh +++ b/autogen.sh @@ -94,6 +94,7 @@ if test "$1" = "--build-w32"; then --with-zlib=${w32root} \ --with-regex=${w32root} \ --with-pth-prefix=${w32root} \ + --with-libiconv-prefix=${w32root} \ --with-adns=${w32root} "$@" rc=$? exit $rc diff --git a/configure.ac b/configure.ac index 702b8d3..4080699 100644 --- a/configure.ac +++ b/configure.ac @@ -979,7 +979,11 @@ AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME", # # Checking for iconv # +missing_iconv=no AM_ICONV +if test "$am_cv_func_iconv" != yes; then + missing_iconv=yes +fi # @@ -1498,6 +1502,14 @@ if test "$missing_pth" = "yes"; then ***]]) die=yes fi +if test "$missing_iconv" = "yes"; then + AC_MSG_NOTICE([[ +*** +*** It is now required to build with support for iconv +*** Please install a suitable iconv implementation. +***]]) + die=yes +fi if test "$die" = "yes"; then AC_MSG_ERROR([[ diff --git a/jnlib/utf8conv.c b/jnlib/utf8conv.c index fee4dc6..b5cf6a8 100644 --- a/jnlib/utf8conv.c +++ b/jnlib/utf8conv.c @@ -27,9 +27,7 @@ #include #endif #include -#ifndef HAVE_W32_SYSTEM -# include -#endif +#include #include "libjnlib-config.h" #include "stringhelp.h" @@ -45,59 +43,6 @@ static int no_translation; /* Set to true if we let simply pass through. */ static int use_iconv; /* iconv comversion fucntions required. */ -/* Under W32 we dlopen the iconv dll and don't require any iconv - related headers at all. However we need to define some stuff. */ -#ifdef HAVE_W32_SYSTEM -typedef void *iconv_t; -#ifndef ICONV_CONST -#define ICONV_CONST const -#endif -static iconv_t (* __stdcall iconv_open) (const char *tocode, - const char *fromcode); -static size_t (* __stdcall iconv) (iconv_t cd, - const char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft); -static int (* __stdcall iconv_close) (iconv_t cd); - -static int -load_libiconv (void) -{ - static int done; - - if (!done) - { - void *handle; - - done = 1; /* Do it right now because we might get called recursivly - through gettext. */ - - handle = dlopen ("iconv.dll", RTLD_LAZY); - if (handle) - { - iconv_open = dlsym (handle, "libiconv_open"); - if (iconv_open) - iconv = dlsym (handle, "libiconv"); - if (iconv) - iconv_close = dlsym (handle, "libiconv_close"); - } - if (!handle || !iconv_close) - { - log_info (_("error loading `%s': %s\n"), - "iconv.dll", dlerror ()); - log_info (_("please see %s for more information\n"), - "http://www.gnupg.org/download/iconv.html"); - iconv_open = NULL; - iconv = NULL; - iconv_close = NULL; - if (handle) - dlclose (handle); - } - } - return iconv_open? 0: -1; -} -#endif /*HAVE_W32_SYSTEM*/ - - /* Error handler for iconv failures. This is needed to not clutter the output with repeated diagnostics about a missing conversion. */ static void @@ -152,13 +97,13 @@ set_native_charset (const char *newset) { const char *full_newset; - if (!newset) + if (!newset) { #ifdef HAVE_W32_SYSTEM static char codepage[30]; unsigned int cpno; const char *aliases; - + /* We are a console program thus we need to use the GetConsoleOutputCP function and not the the GetACP which would give the codepage for a GUI program. Note this is not @@ -201,7 +146,7 @@ set_native_charset (const char *newset) } #else /*!HAVE_W32_SYSTEM*/ - + #ifdef HAVE_LANGINFO_CODESET newset = nl_langinfo (CODESET); #else /*!HAVE_LANGINFO_CODESET*/ @@ -225,7 +170,7 @@ set_native_charset (const char *newset) mod = strchr (++dot, '@'); if (!mod) mod = dot + strlen (dot); - if (mod - dot < sizeof codepage && dot != mod) + if (mod - dot < sizeof codepage && dot != mod) { memcpy (codepage, dot, mod - dot); codepage [mod - dot] = 0; @@ -272,21 +217,16 @@ set_native_charset (const char *newset) else { iconv_t cd; - -#ifdef HAVE_W32_SYSTEM - if (load_libiconv ()) - return -1; -#endif /*HAVE_W32_SYSTEM*/ cd = iconv_open (full_newset, "utf-8"); - if (cd == (iconv_t)-1) + if (cd == (iconv_t)-1) { handle_iconv_error (full_newset, "utf-8", 0); return -1; } iconv_close (cd); cd = iconv_open ("utf-8", full_newset); - if (cd == (iconv_t)-1) + if (cd == (iconv_t)-1) { handle_iconv_error ("utf-8", full_newset, 0); return -1; @@ -306,7 +246,7 @@ get_native_charset () } /* Return true if the native charset is utf-8. */ -int +int is_native_utf8 (void) { return no_translation; @@ -353,13 +293,13 @@ native_to_utf8 (const char *orig_string) *p = 0; } else - { + { /* Need to use iconv. */ iconv_t cd; const char *inptr; char *outptr; size_t inbytes, outbytes; - + cd = iconv_open ("utf-8", active_charset_name); if (cd == (iconv_t)-1) { @@ -367,14 +307,14 @@ native_to_utf8 (const char *orig_string) return native_to_utf8 (string); } - for (s=string; *s; s++ ) + for (s=string; *s; s++ ) { length++; if ((*s & 0x80)) length += 5; /* We may need up to 6 bytes for the utf8 output. */ } buffer = jnlib_xmalloc (length + 1); - + inptr = string; inbytes = strlen (string); outptr = buffer; @@ -448,10 +388,10 @@ do_utf8_to_native (const char *string, size_t length, int delim, if (!nleft) { if (!(*s & 0x80)) - { + { /* Plain ascii. */ if ( delim != -1 - && (*s < 0x20 || *s == 0x7f || *s == delim + && (*s < 0x20 || *s == 0x7f || *s == delim || (delim && *s == '\\'))) { n++; @@ -490,35 +430,35 @@ do_utf8_to_native (const char *string, size_t length, int delim, encbuf[encidx++] = *s; } else if ((*s & 0xf0) == 0xe0) /* 1110 xxxx */ - { + { val = *s & 0x0f; nleft = 2; encidx = 0; encbuf[encidx++] = *s; } else if ((*s & 0xf8) == 0xf0) /* 1111 0xxx */ - { + { val = *s & 0x07; nleft = 3; encidx = 0; encbuf[encidx++] = *s; } else if ((*s & 0xfc) == 0xf8) /* 1111 10xx */ - { + { val = *s & 0x03; nleft = 4; encidx = 0; encbuf[encidx++] = *s; } else if ((*s & 0xfe) == 0xfc) /* 1111 110x */ - { + { val = *s & 0x01; nleft = 5; encidx = 0; encbuf[encidx++] = *s; } else /* Invalid encoding: print as \xNN. */ - { + { if (p) { sprintf (p, "\\x%02x", *s); @@ -551,7 +491,7 @@ do_utf8_to_native (const char *string, size_t length, int delim, val <<= 6; val |= *s & 0x3f; if (!--nleft) /* Ready. */ - { + { if (no_translation) { if (p) @@ -590,12 +530,12 @@ do_utf8_to_native (const char *string, size_t length, int delim, if (val >= 0x80 && val < 256) { /* We can simply print this character */ - n++; + n++; if (p) *p++ = val; } else - { + { /* We do not have a translation: print utf8. */ if (p) { @@ -625,7 +565,7 @@ do_utf8_to_native (const char *string, size_t length, int delim, const char *inptr; char *outbuf, *outptr; size_t inbytes, outbytes; - + *p = 0; /* Terminate the buffer. */ cd = iconv_open (active_charset_name, "utf-8"); @@ -642,14 +582,14 @@ do_utf8_to_native (const char *string, size_t length, int delim, inbytes = n - 1;; inptr = buffer; outbytes = n * MB_LEN_MAX; - if (outbytes / MB_LEN_MAX != n) + if (outbytes / MB_LEN_MAX != n) BUG (); /* Actually an overflow. */ outbuf = outptr = jnlib_xmalloc (outbytes); if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes, - &outptr, &outbytes) == (size_t)-1) + &outptr, &outbytes) == (size_t)-1) { static int shown; - + if (!shown) log_info (_("conversion from `%s' to `%s' failed: %s\n"), "utf-8", active_charset_name, strerror (errno)); @@ -661,7 +601,7 @@ do_utf8_to_native (const char *string, size_t length, int delim, outbuf = do_utf8_to_native (string, length, delim, 0); } else /* Success. */ - { + { *outptr = 0; /* Make sure it is a string. */ /* We could realloc the buffer now but I doubt that it makes much sense given that it will get freed @@ -694,45 +634,29 @@ utf8_to_native (const char *string, size_t length, int delim) -/* Wrapper function for iconv_open, required for W32 as we dlopen that - library on that system. */ -jnlib_iconv_t +/* Wrapper function for iconv_open, formerly required for W32 as we + used to dlopen that library on that system. */ +jnlib_iconv_t jnlib_iconv_open (const char *tocode, const char *fromcode) { -#ifdef HAVE_W32_SYSTEM - if (load_libiconv ()) - return (jnlib_iconv_t)(-1); -#endif /*HAVE_W32_SYSTEM*/ - return (jnlib_iconv_t)iconv_open (tocode, fromcode); } -/* Wrapper function for iconv, required for W32 as we dlopen that - library on that system. */ +/* Wrapper function for iconv, formerly required for W32 as we used to + dlopen that library on that system. */ size_t jnlib_iconv (jnlib_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { - -#ifdef HAVE_W32_SYSTEM - if (load_libiconv ()) - return 0; -#endif /*HAVE_W32_SYSTEM*/ - return iconv ((iconv_t)cd, (char**)inbuf, inbytesleft, outbuf, outbytesleft); } -/* Wrapper function for iconv_close, required for W32 as we dlopen that - library on that system. */ +/* Wrapper function for iconv_close, formerly required for W32 as we + used to dlopen that library on that system. */ int jnlib_iconv_close (jnlib_iconv_t cd) { -#ifdef HAVE_W32_SYSTEM - if (load_libiconv ()) - return 0; -#endif /*HAVE_W32_SYSTEM*/ - return iconv_close ((iconv_t)cd); } diff --git a/m4/iconv.m4 b/m4/iconv.m4 index 66bc76f..085cd06 100644 --- a/m4/iconv.m4 +++ b/m4/iconv.m4 @@ -1,5 +1,5 @@ -# iconv.m4 serial AM6 (gettext-0.17) -dnl Copyright (C) 2000-2002, 2007 Free Software Foundation, Inc. +# iconv.m4 serial 17 (gettext-0.18.2) +dnl Copyright (C) 2000-2002, 2007-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -30,44 +30,55 @@ AC_DEFUN([AM_ICONV_LINK], dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first - dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. + dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) - AC_CACHE_CHECK([for iconv], am_cv_func_iconv, [ + AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no - AC_TRY_LINK([#include -#include ], - [iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], - am_cv_func_iconv=yes) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], + [am_cv_func_iconv=yes]) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" - AC_TRY_LINK([#include -#include ], - [iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], - am_cv_lib_iconv=yes - am_cv_func_iconv=yes) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], + [am_cv_lib_iconv=yes] + [am_cv_func_iconv=yes]) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then - AC_CACHE_CHECK([for working iconv], am_cv_func_iconv_works, [ - dnl This tests against bugs in AIX 5.1 and HP-UX 11.11. + AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ + dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, + dnl Solaris 10. am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include #include int main () { + int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { @@ -84,7 +95,47 @@ int main () (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) - return 1; + result |= 1; + iconv_close (cd_utf8_to_88591); + } + } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\263"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + result |= 2; + iconv_close (cd_ascii_to_88591); + } + } + /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304"; + static char buf[2] = { (char)0xDE, (char)0xAD }; + const char *inptr = input; + size_t inbytesleft = 1; + char *outptr = buf; + size_t outbytesleft = 1; + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) + result |= 4; + iconv_close (cd_88591_to_utf8); } } #if 0 /* This bug could be worked around by the caller. */ @@ -103,7 +154,8 @@ int main () (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) - return 1; + result |= 8; + iconv_close (cd_88591_to_utf8); } } #endif @@ -117,13 +169,19 @@ int main () && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - return 1; - return 0; -}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], - [case "$host_os" in + result |= 16; + return result; +}]])], + [am_cv_func_iconv_works=yes], + [am_cv_func_iconv_works=no], + [ +changequote(,)dnl + case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; - esac]) + esac +changequote([,])dnl + ]) LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in @@ -134,7 +192,7 @@ int main () am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then - AC_DEFINE(HAVE_ICONV, 1, + AC_DEFINE([HAVE_ICONV], [1], [Define if you have the iconv() function and it works.]) fi if test "$am_cv_lib_iconv" = yes; then @@ -147,17 +205,37 @@ int main () LIBICONV= LTLIBICONV= fi - AC_SUBST(LIBICONV) - AC_SUBST(LTLIBICONV) + AC_SUBST([LIBICONV]) + AC_SUBST([LTLIBICONV]) ]) -AC_DEFUN([AM_ICONV], +dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to +dnl avoid warnings like +dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". +dnl This is tricky because of the way 'aclocal' is implemented: +dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. +dnl Otherwise aclocal's initial scan pass would miss the macro definition. +dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. +dnl Otherwise aclocal would emit many "Use of uninitialized value $1" +dnl warnings. +m4_define([gl_iconv_AC_DEFUN], + m4_version_prereq([2.64], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [m4_ifdef([gl_00GNULIB], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [[AC_DEFUN( + [$1], [$2])]])])) +gl_iconv_AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL(am_cv_proto_iconv, [ - AC_TRY_COMPILE([ + AC_CACHE_VAL([am_cv_proto_iconv], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ #include #include extern @@ -169,12 +247,22 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si #else size_t iconv(); #endif -], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") + ]], + [[]])], + [am_cv_proto_iconv_arg1=""], + [am_cv_proto_iconv_arg1="const"]) am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - AC_MSG_RESULT([$]{ac_t:- - }[$]am_cv_proto_iconv) - AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, + AC_MSG_RESULT([ + $am_cv_proto_iconv]) + AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], [Define as const if the declaration of iconv() needs const.]) + dnl Also substitute ICONV_CONST in the gnulib generated . + m4_ifdef([gl_ICONV_H_DEFAULTS], + [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) + if test -n "$am_cv_proto_iconv_arg1"; then + ICONV_CONST="const" + fi + ]) fi ]) diff --git a/tools/Makefile.am b/tools/Makefile.am index bacdaf3..a94fbcd 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -118,7 +118,8 @@ gpgtar_SOURCES = \ gpgtar-list.c \ no-libgcrypt.c gpgtar_CFLAGS = $(GPG_ERROR_CFLAGS) $(PTH_CFLAGS) -gpgtar_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(W32SOCKLIBS) +gpgtar_LDADD = $(common_libs) $(GPG_ERROR_LIBS) \ + $(NETLIBS) $(LIBICONV) $(W32SOCKLIBS) # Make sure that all libs are build before we use them. This is # important for things like make -j2. commit 1b89863ec195dbfdbc33432569a7b2e7f0f83821 Author: Werner Koch Date: Thu Aug 1 14:02:50 2013 +0200 w32: Remove unused code. * jnlib/w32-reg.c (write_w32_registry_string): Remove. diff --git a/jnlib/w32-reg.c b/jnlib/w32-reg.c index a6e2395..e55f806 100644 --- a/jnlib/w32-reg.c +++ b/jnlib/w32-reg.c @@ -148,38 +148,4 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) } -int -write_w32_registry_string (const char *root, const char *dir, - const char *name, const char *value) -{ - HKEY root_key, reg_key; - - if ( !(root_key = get_root_key(root) ) ) - return -1; - - if ( RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, ®_key ) - != ERROR_SUCCESS ) - return -1; - - if ( RegSetValueEx (reg_key, name, 0, REG_SZ, (BYTE *)value, - strlen( value ) ) != ERROR_SUCCESS ) - { - if ( RegCreateKey( root_key, name, ®_key ) != ERROR_SUCCESS ) - { - RegCloseKey(reg_key); - return -1; - } - if ( RegSetValueEx (reg_key, name, 0, REG_SZ, (BYTE *)value, - strlen( value ) ) != ERROR_SUCCESS ) - { - RegCloseKey(reg_key); - return -1; - } - } - - RegCloseKey (reg_key); - - return 0; -} - #endif /*HAVE_W32_SYSTEM*/ diff --git a/jnlib/w32help.h b/jnlib/w32help.h index c503ad2..c7aa5cb 100644 --- a/jnlib/w32help.h +++ b/jnlib/w32help.h @@ -24,8 +24,6 @@ /*-- w32-reg.c --*/ char *read_w32_registry_string (const char *root, const char *dir, const char *name ); -int write_w32_registry_string (const char *root, const char *dir, - const char *name, const char *value); #ifdef USE_SIMPLE_GETTEXT char *bindtextdomain (const char *domainname, const char *dirname); ----------------------------------------------------------------------- Summary of changes: NEWS | 2 + autogen.sh | 1 + common/homedir.c | 156 +++++++++++++++++++++++++++++++++++++++++-------- configure.ac | 12 ++++ doc/gpg-agent.texi | 28 +++++++--- jnlib/utf8conv.c | 144 +++++++++++----------------------------------- jnlib/w32-reg.c | 34 ----------- jnlib/w32help.h | 2 - m4/iconv.m4 | 162 ++++++++++++++++++++++++++++++++++++++++------------ tools/Makefile.am | 3 +- 10 files changed, 326 insertions(+), 218 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Thu Aug 1 20:24:47 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 01 Aug 2013 20:24:47 +0200 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-231-gca6fe88 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via ca6fe88c0068f8d45ef39df0fc7b161998a91fe9 (commit) from ef6a6d973c2bcc54006c04dc41f978ff01005c97 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ca6fe88c0068f8d45ef39df0fc7b161998a91fe9 Author: Werner Koch Date: Thu Aug 1 19:54:11 2013 +0200 w32: Fix recent patch 9ff72e4. * common/homedir.c (check_portable_app): Fix the name of the control file. diff --git a/common/homedir.c b/common/homedir.c index 9fec78f..faf9787 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -258,7 +258,7 @@ check_portable_app (const char *dir) log_error ("required binary '%s' is not installed\n", fname); else { - strcpy (fname + strlen (fname) - 3, ".ctl"); + strcpy (fname + strlen (fname) - 3, "ctl"); if (!access (fname, F_OK)) { /* gpgconf.ctl file found. Record this fact. */ ----------------------------------------------------------------------- Summary of changes: common/homedir.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Aug 2 09:49:04 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 02 Aug 2013 09:49:04 +0200 Subject: [git] GnuPG - branch, STABLE-BRANCH-1-4, updated. gnupg-1.4.14-2-ga1a59e6 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, STABLE-BRANCH-1-4 has been updated via a1a59e6a539e597996976d0afb6aa3062e954188 (commit) from 6f634b0e089f253f07a470670449ba0722408d46 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a1a59e6a539e597996976d0afb6aa3062e954188 Author: Werner Koch Date: Fri Aug 2 09:17:52 2013 +0200 gpg: No need to create a trustdb when encrypting with --always-trust. * g10/gpg.c (main): Special case setup_trustdb for --encrypt. -- (back ported from commit 498b9a95dc65c43240835d64cc92d8fb43014d53) Signed-off-by: Werner Koch diff --git a/g10/gpg.c b/g10/gpg.c index 96f9086..b310308 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -3318,6 +3318,12 @@ main (int argc, char **argv ) case aFixTrustDB: case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break; case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break; + case aEncr: + case aEncrFiles: + /* No need to create the trust model if we are using the + * always trust model. */ + rc = setup_trustdb (opt.trust_model != TM_ALWAYS, trustdb_name); + break; default: rc = setup_trustdb(1, trustdb_name ); break; } if( rc ) ----------------------------------------------------------------------- Summary of changes: g10/gpg.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Aug 2 09:50:11 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 02 Aug 2013 09:50:11 +0200 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-232-g498b9a9 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 498b9a95dc65c43240835d64cc92d8fb43014d53 (commit) from ca6fe88c0068f8d45ef39df0fc7b161998a91fe9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 498b9a95dc65c43240835d64cc92d8fb43014d53 Author: Werner Koch Date: Fri Aug 2 09:10:17 2013 +0200 gpg: No need to create a trustdb when encrypting with --always-trust. * g10/gpg.c (main): Special case setup_trustdb for --encrypt. Signed-off-by: Werner Koch diff --git a/g10/gpg.c b/g10/gpg.c index a141164..599948f 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -3440,7 +3440,8 @@ main (int argc, char **argv) ctrl = xcalloc (1, sizeof *ctrl); gpg_init_default_ctrl (ctrl); - switch( cmd ) { + switch (cmd) + { case aPrimegen: case aPrintMD: case aPrintMDs: @@ -3449,12 +3450,24 @@ main (int argc, char **argv) case aEnArmor: break; case aFixTrustDB: - case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break; - case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break; - default: rc = setup_trustdb(1, trustdb_name ); break; - } - if( rc ) - log_error(_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc)); + case aExportOwnerTrust: + rc = setup_trustdb (0, trustdb_name); + break; + case aListTrustDB: + rc = setup_trustdb (argc? 1:0, trustdb_name); + break; + case aEncr: + case aEncrFiles: + /* If we are using TM_ALWAYS, we do not need to create the + trustdb. */ + rc = setup_trustdb (opt.trust_model != TM_ALWAYS, trustdb_name); + break; + default: + rc = setup_trustdb (1, trustdb_name ); + break; + } + if (rc) + log_error (_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc)); switch (cmd) ----------------------------------------------------------------------- Summary of changes: g10/gpg.c | 27 ++++++++++++++++++++------- 1 files changed, 20 insertions(+), 7 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Aug 2 09:57:12 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 02 Aug 2013 09:57:12 +0200 Subject: [git] GnuPG - branch, STABLE-BRANCH-2-0, updated. gnupg-2.0.20-24-g7c028ef Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, STABLE-BRANCH-2-0 has been updated via 7c028efc182234cd28bbfbeccff0107f334064f2 (commit) from 4f90c7b914693b72341fa1e93dda7e075f9717c0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7c028efc182234cd28bbfbeccff0107f334064f2 Author: Werner Koch Date: Fri Aug 2 09:10:17 2013 +0200 gpg: No need to create a trustdb when encrypting with --always-trust. * g10/gpg.c (main): Special case setup_trustdb for --encrypt. -- Signed-off-by: Werner Koch (cherry picked from commit 498b9a95dc65c43240835d64cc92d8fb43014d53) diff --git a/g10/gpg.c b/g10/gpg.c index ffe964e..1238f47 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -3389,7 +3389,8 @@ main (int argc, char **argv) if(fname && utf8_strings) opt.flags.utf8_filename=1; - switch( cmd ) { + switch (cmd) + { case aPrimegen: case aPrintMD: case aPrintMDs: @@ -3398,12 +3399,24 @@ main (int argc, char **argv) case aEnArmor: break; case aFixTrustDB: - case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break; - case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break; - default: rc = setup_trustdb(1, trustdb_name ); break; - } - if( rc ) - log_error(_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc)); + case aExportOwnerTrust: + rc = setup_trustdb (0, trustdb_name); + break; + case aListTrustDB: + rc = setup_trustdb (argc? 1:0, trustdb_name); + break; + case aEncr: + case aEncrFiles: + /* If we are using TM_ALWAYS, we do not need to create the + trustdb. */ + rc = setup_trustdb (opt.trust_model != TM_ALWAYS, trustdb_name); + break; + default: + rc = setup_trustdb (1, trustdb_name ); + break; + } + if (rc) + log_error (_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc)); switch (cmd) ----------------------------------------------------------------------- Summary of changes: g10/gpg.c | 27 ++++++++++++++++++++------- 1 files changed, 20 insertions(+), 7 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Aug 2 12:28:36 2013 From: cvs at cvs.gnupg.org (by Andre Heinecke) Date: Fri, 02 Aug 2013 12:28:36 +0200 Subject: [git] GpgOL - branch, master, updated. gpgol-1.1.3-50-ga81d689 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG extension for MS Outlook". The branch, master has been updated via a81d6897e302fa0fceb73647d41ee27370bf1a57 (commit) via 8a668dc4eb5e6451f09dccfa4981db0c17d648dc (commit) from 1a9124f08d88a4549623b45146870fe7125ab60d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a81d6897e302fa0fceb73647d41ee27370bf1a57 Author: Andre Heinecke Date: Fri Aug 2 09:57:03 2013 +0000 Fix possible crash in encryptInspector The recipientAddr pointer got moved to an invalid location before free. * src/ribbons-callbacks.cpp (encryptInspector): Fix free of recipients. -- Thats what you get when you let Python / Java coders write C diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp index adf24f1..0afead1 100644 --- a/src/ribbon-callbacks.cpp +++ b/src/ribbon-callbacks.cpp @@ -93,6 +93,8 @@ encryptInspector (LPDISPATCH ctrl, int flags) int i; STATSTG tmpStat; + log_debug ("%s:%s: enter", SRCNAME, __func__); + hr = getContext (ctrl, &context); if (FAILED(hr)) return hr; @@ -328,11 +330,13 @@ failure: RELDISP(tmpstream); xfree (plaintext); xfree (senderAddr); - while (recipientAddrs && *recipientAddrs) - { - xfree (*recipientAddrs++); - } - xfree (recipientAddrs); + if (recipientAddrs) + { + for (i=0; recipientAddrs && recipientAddrs[i]; i++) + xfree (recipientAddrs[i]); + xfree (recipientAddrs); + } + log_debug ("%s:%s: leave", SRCNAME, __func__); return S_OK; } commit 8a668dc4eb5e6451f09dccfa4981db0c17d648dc Author: Andre Heinecke Date: Fri Aug 2 09:55:51 2013 +0000 Add some more initalization also for encryption * src/ribbon-callbacks.cpp (encryptInspector): Initialize dispatcher pointers diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp index 529cdf2..adf24f1 100644 --- a/src/ribbon-callbacks.cpp +++ b/src/ribbon-callbacks.cpp @@ -69,12 +69,12 @@ HRESULT encryptInspector (LPDISPATCH ctrl, int flags) { LPDISPATCH context = NULL; - LPDISPATCH selection; - LPDISPATCH wordEditor; - LPDISPATCH application; - LPDISPATCH mailItem; - LPDISPATCH sender; - LPDISPATCH recipients; + LPDISPATCH selection = NULL; + LPDISPATCH wordEditor = NULL; + LPDISPATCH application = NULL; + LPDISPATCH mailItem = NULL; + LPDISPATCH sender = NULL; + LPDISPATCH recipients = NULL; struct sink_s encsinkmem; sink_t encsink = &encsinkmem; ----------------------------------------------------------------------- Summary of changes: src/ribbon-callbacks.cpp | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-) hooks/post-receive -- GnuPG extension for MS Outlook http://git.gnupg.org From cvs at cvs.gnupg.org Fri Aug 2 13:19:07 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 02 Aug 2013 13:19:07 +0200 Subject: [git] GPGME - branch, master, updated. gpgme-1.4.2-5-g3881ea4 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG Made Easy". The branch, master has been updated via 3881ea4e83d1533ef497b7332398fc1850e29205 (commit) from 393a9471f2f3ac0a5b14f3534a5bfc7ffe948567 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3881ea4e83d1533ef497b7332398fc1850e29205 Author: Werner Koch Date: Fri Aug 2 12:48:30 2013 +0200 w32: Try to locate gpg in the gpgme installation dir. * src/w32-util.c (my_hmodule): New. (wchar_to_utf8): New. (DllMain): New. (_gpgme_get_inst_dir): New. (find_program_in_dir): New. (find_program_in_inst_dir): Add arg INST_DIR. (_gpgme_get_gpg_path): Get inst_dir before acquiring the lock. (_gpgme_get_gpgconf_path): Ditto. (_gpgme_get_g13_path): Ditto. (_gpgme_get_w32spawn_path): Ditto. diff --git a/src/w32-util.c b/src/w32-util.c index a90f405..27dc5bc 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -1,24 +1,23 @@ /* w32-util.c - Utility functions for the W32 API - Copyright (C) 1999 Free Software Foundation, Inc - Copyright (C) 2001 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH - - This file is part of GPGME. - - GPGME is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of - the License, or (at your option) any later version. - - GPGME is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + * Copyright (C) 1999 Free Software Foundation, Inc + * Copyright (C) 2001 Werner Koch (dd9jn) + * Copyright (C) 2001, 2002, 2003, 2004, 2007, 2013 g10 Code GmbH + * + * This file is part of GPGME. + * + * GPGME is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * GPGME is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see . + **/ #ifdef HAVE_CONFIG_H #include @@ -75,6 +74,12 @@ DEFINE_STATIC_LOCK (get_path_lock); +/* The module handle of this DLL. If we are linked statically, + dllmain does not exists and thus the value of my_hmodule will be + NULL. The effect is that a GetModuleFileName always returns the + file name of the DLL or executable which contains the gpgme code. */ +static HMODULE my_hmodule; + #ifdef HAVE_ALLOW_SET_FOREGROUND_WINDOW @@ -112,6 +117,39 @@ dlclose (void * hd) } #endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */ + +/* Return a malloced string encoded in UTF-8 from the wide char input + string STRING. Caller must free this value. Returns NULL and sets + ERRNO on failure. Calling this function with STRING set to NULL is + not defined. */ +static char * +wchar_to_utf8 (const wchar_t *string) +{ + int n; + char *result; + + n = WideCharToMultiByte (CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL); + if (n < 0) + { + gpg_err_set_errno (EINVAL); + return NULL; + } + + result = malloc (n+1); + if (!result) + return NULL; + + n = WideCharToMultiByte (CP_UTF8, 0, string, -1, result, n, NULL, NULL); + if (n < 0) + { + free (result); + gpg_err_set_errno (EINVAL); + result = NULL; + } + return result; +} + + void _gpgme_allow_set_foreground_window (pid_t pid) { @@ -270,51 +308,53 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) } -#if 0 -static char * -find_program_in_registry (const char *name) +/* Return the name of the directory with the gpgme DLL or the EXE (if + statically linked). May return NULL on severe errors. */ +const char * +_gpgme_get_inst_dir (void) { - char *program = NULL; + static char *inst_dir; - program = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", name); - if (program) + LOCK (get_path_lock); + if (!inst_dir) { - int i; + wchar_t *moddir; - TRACE2 (DEBUG_CTX, "gpgme:find_program_in_registry", 0, - "found %s in registry: `%s'", name, program); - for (i = 0; program[i]; i++) - { - if (program[i] == '/') - program[i] = '\\'; - } + moddir = malloc ((MAX_PATH+5) * sizeof *moddir); + if (moddir) + { + if (!GetModuleFileNameW (my_hmodule, moddir, MAX_PATH)) + *moddir = 0; + if (!*moddir) + gpg_err_set_errno (ENOENT); + else + { + inst_dir = wchar_to_utf8 (moddir); + if (inst_dir) + { + char *p = strrchr (inst_dir, '\\'); + if (p) + *p = 0; + } + } + free (moddir); + } } - return program; + UNLOCK (get_path_lock); + return inst_dir; } -#endif static char * -find_program_in_inst_dir (const char *name) +find_program_in_dir (const char *dir, const char *name) { - char *result = NULL; - char *tmp; + char *result; - tmp = read_w32_registry_string ("HKEY_LOCAL_MACHINE", - "Software\\GNU\\GnuPG", - "Install Directory"); - if (!tmp) - return NULL; - - result = malloc (strlen (tmp) + 1 + strlen (name) + 1); + result = malloc (strlen (dir) + 1 + strlen (name) + 1); if (!result) - { - free (tmp); - return NULL; - } + return NULL; - strcpy (stpcpy (stpcpy (result, tmp), "\\"), name); - free (tmp); + strcpy (stpcpy (stpcpy (result, dir), "\\"), name); if (access (result, F_OK)) { free (result); @@ -326,6 +366,40 @@ find_program_in_inst_dir (const char *name) static char * +find_program_in_inst_dir (const char *inst_dir, const char *name) +{ + char *result; + char *dir; + + /* If an installation directory has been passed, this overrides a + location given bu the registry. The idea here is that we prefer + a a program installed alongside with gpgme. We don't want the + registry to override this to have a better isolation of an gpgme + aware applications for other effects. Note that the "Install + Directory" registry item has been used for ages in Gpg4win and + earlier GnuPG windows installers. It is technically not anymore + required. */ + if (inst_dir) + { + result = find_program_in_dir (inst_dir, name); + if (result) + return result; + } + + dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", + "Software\\GNU\\GnuPG", + "Install Directory"); + if (dir) + { + result = find_program_in_dir (dir, name); + free (dir); + return result; + } + return NULL; +} + + +static char * find_program_at_standard_place (const char *name) { char path[MAX_PATH]; @@ -353,14 +427,12 @@ const char * _gpgme_get_gpg_path (void) { static char *gpg_program; + const char *inst_dir; + inst_dir = _gpgme_get_inst_dir (); LOCK (get_path_lock); -#if 0 if (!gpg_program) - gpg_program = find_program_in_registry ("gpgProgram"); -#endif - if (!gpg_program) - gpg_program = find_program_in_inst_dir ("gpg.exe"); + gpg_program = find_program_in_inst_dir (inst_dir, "gpg.exe"); if (!gpg_program) gpg_program = find_program_at_standard_place ("GNU\\GnuPG\\gpg.exe"); UNLOCK (get_path_lock); @@ -372,14 +444,12 @@ const char * _gpgme_get_gpgsm_path (void) { static char *gpgsm_program; + const char *inst_dir; + inst_dir = _gpgme_get_inst_dir (); LOCK (get_path_lock); -#if 0 if (!gpgsm_program) - gpgsm_program = find_program_in_registry ("gpgsmProgram"); -#endif - if (!gpgsm_program) - gpgsm_program = find_program_in_inst_dir ("gpgsm.exe"); + gpgsm_program = find_program_in_inst_dir (inst_dir, "gpgsm.exe"); if (!gpgsm_program) gpgsm_program = find_program_at_standard_place ("GNU\\GnuPG\\gpgsm.exe"); UNLOCK (get_path_lock); @@ -391,14 +461,12 @@ const char * _gpgme_get_gpgconf_path (void) { static char *gpgconf_program; + const char *inst_dir; + inst_dir = _gpgme_get_inst_dir (); LOCK (get_path_lock); -#if 0 if (!gpgconf_program) - gpgconf_program = find_program_in_registry ("gpgconfProgram"); -#endif - if (!gpgconf_program) - gpgconf_program = find_program_in_inst_dir ("gpgconf.exe"); + gpgconf_program = find_program_in_inst_dir (inst_dir, "gpgconf.exe"); if (!gpgconf_program) gpgconf_program = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe"); @@ -411,14 +479,12 @@ const char * _gpgme_get_g13_path (void) { static char *g13_program; + const char *inst_dir; + inst_dir = _gpgme_get_inst_dir (); LOCK (get_path_lock); -#if 0 - if (!g13_program) - g13_program = find_program_in_registry ("g13Program"); -#endif if (!g13_program) - g13_program = find_program_in_inst_dir ("g13.exe"); + g13_program = find_program_in_inst_dir (inst_dir, "g13.exe"); if (!g13_program) g13_program = find_program_at_standard_place ("GNU\\GnuPG\\g13.exe"); UNLOCK (get_path_lock); @@ -453,10 +519,12 @@ const char * _gpgme_get_w32spawn_path (void) { static char *w32spawn_program; + const char *inst_dir; + inst_dir = _gpgme_get_inst_dir (); LOCK (get_path_lock); if (!w32spawn_program) - w32spawn_program = find_program_in_inst_dir ("gpgme-w32spawn.exe"); + w32spawn_program = find_program_in_inst_dir (inst_dir,"gpgme-w32spawn.exe"); if (!w32spawn_program) w32spawn_program = find_program_at_standard_place ("GNU\\GnuPG\\gpgme-w32spawn.exe"); @@ -641,3 +709,18 @@ _gpgme_w32ce_get_debug_envvar (void) return tmp; } #endif /*HAVE_W32CE_SYSTEM*/ + + +/* Entry point called by the DLL loader. */ +#ifdef DLL_EXPORT +int WINAPI +DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved) +{ + (void)reserved; + + if (reason == DLL_PROCESS_ATTACH) + my_hmodule = hinst; + + return TRUE; +} +#endif /*DLL_EXPORT*/ ----------------------------------------------------------------------- Summary of changes: src/w32-util.c | 229 ++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 156 insertions(+), 73 deletions(-) hooks/post-receive -- GnuPG Made Easy http://git.gnupg.org From cvs at cvs.gnupg.org Fri Aug 2 15:56:25 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 02 Aug 2013 15:56:25 +0200 Subject: [git] GPGME - branch, master, updated. gpgme-1.4.2-6-ga4c8012 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG Made Easy". The branch, master has been updated via a4c80126ae4754c8478c69a8a24a6ffd975485fc (commit) from 3881ea4e83d1533ef497b7332398fc1850e29205 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a4c80126ae4754c8478c69a8a24a6ffd975485fc Author: Werner Koch Date: Fri Aug 2 15:25:23 2013 +0200 Prefer GnuPG-2 engines over GnuPG-1. * src/util.h: Move some prototypes to ... * src/sys-util.h: New. * src/Makefile.am (main_sources): Add sys-util.h. * configure.ac (AH_VERBATIM): Add DIRSEP_C and DIRSEP_S. * src/dirinfo.c: Include sys-util.h. (WANT_GPG_NAME, WANT_GPGSM_NAME, WANT_G13_NAME) (WANT_UISRV_SOCKET): New. (dirinfo): Add corresponding fields. (parse_output): Add arg COMPONENTS and set new fields. (read_gpgconf_dirs): Add arg components and act upon it. (get_gpgconf_item): Call read_gpgconf_dirs two times. Add debug output. (_gpgme_get_default_gpg_name): New. (_gpgme_get_default_gpgsm_name): New. (_gpgme_get_default_g13_name): New. (_gpgme_get_default_gpgconf_name): New. (_gpgme_get_default_uisrv_socket): New. * src/engine-gpg.c, src/engine-g13.c, src/engine-gpgconf.c * src/engine-gpgsm.c, src/engine-uiserver.c: Change to use _gpgme_get_default_ instead of those from sys-util.h. * src/posix-util.c (_gpgme_get_gpg_path): Include sys-util.h. (_gpgme_get_uiserver_socket_path): Remove. * src/w32-util.c (_gpgme_get_gpg_path): Include sys-util.h. (_gpgme_get_uiserver_socket_path): Remove. -- The default engines names are now taken from the output of gpgconf. If gpgconf is not installed gpg 1 is assumed and locate the same was as gpgconf. diff --git a/NEWS b/NEWS index 55c8660..5c871dd 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ Noteworthy changes in version 1.4.3 (unreleased) ------------------------------------------------ + * The default engine names are now taken from the output of gpgconf. + If gpgconf is not found the use of gpg 1 is assumed. + + * Under Windows the default engines names are first searched in the + installation directory of the gpgme DLL. + * Interface changes relative to the 1.4.2 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_signers_count NEW. diff --git a/configure.ac b/configure.ac index 2d26dbb..d3258be 100644 --- a/configure.ac +++ b/configure.ac @@ -920,11 +920,15 @@ AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no") # Add a few constants to help porting to W32 AH_VERBATIM([SEPCONSTANTS], [ -/* Separators as used in $PATH. */ +/* Separators as used in $PATH and file name. */ #ifdef HAVE_DOSISH_SYSTEM #define PATHSEP_C ';' +#define DIRSEP_C '\\' +#define DIRSEP_S "\\" #else #define PATHSEP_C ':' +#define DIRSEP_C '/' +#define DIRSEP_S "/" #endif ]) diff --git a/src/Makefile.am b/src/Makefile.am index fa3b077..37e3407 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -118,7 +118,7 @@ main_sources = \ $(uiserver_components) \ $(g13_components) vfs-mount.c vfs-create.c \ gpgconf.c \ - sema.h priv-io.h $(system_components) dirinfo.c \ + sema.h priv-io.h $(system_components) sys-util.h dirinfo.c \ debug.c debug.h gpgme.c version.c error.c libgpgme_la_SOURCES = $(main_sources) \ diff --git a/src/dirinfo.c b/src/dirinfo.c index 267e988..27c0dd7 100644 --- a/src/dirinfo.c +++ b/src/dirinfo.c @@ -1,5 +1,5 @@ /* dirinfo.c - Get directory information - * Copyright (C) 2009 g10 Code GmbH + * Copyright (C) 2009, 2013 g10 Code GmbH * * This file is part of GPGME. * @@ -29,6 +29,7 @@ #include "priv-io.h" #include "debug.h" #include "sema.h" +#include "sys-util.h" DEFINE_STATIC_LOCK (dirinfo_lock); @@ -36,7 +37,11 @@ DEFINE_STATIC_LOCK (dirinfo_lock); enum { WANT_HOMEDIR, - WANT_AGENT_SOCKET + WANT_AGENT_SOCKET, + WANT_GPG_NAME, + WANT_GPGSM_NAME, + WANT_G13_NAME, + WANT_UISRV_SOCKET }; /* Values retrieved via gpgconf and cached here. */ @@ -44,13 +49,18 @@ static struct { int valid; /* Cached information is valid. */ char *homedir; char *agent_socket; + char *gpg_name; + char *gpgsm_name; + char *g13_name; + char *uisrv_socket; } dirinfo; /* Parse the output of "gpgconf --list-dirs". This function expects - that DIRINFO_LOCK is held by the caller. */ + that DIRINFO_LOCK is held by the caller. If COMPONENTS is set, the + output of --list-components is expected. */ static void -parse_output (char *line) +parse_output (char *line, int components) { char *value, *p; @@ -58,6 +68,14 @@ parse_output (char *line) if (!value) return; *value++ = 0; + if (components) + { + /* Skip the second field. */ + value = strchr (value, ':'); + if (!value) + return; + *value++ = 0; + } p = strchr (value, ':'); if (p) *p = 0; @@ -66,19 +84,45 @@ parse_output (char *line) if (!*value) return; - if (!strcmp (line, "homedir") && !dirinfo.homedir) - dirinfo.homedir = strdup (value); - else if (!strcmp (line, "agent-socket") && !dirinfo.agent_socket) - dirinfo.agent_socket = strdup (value); + if (components) + { + if (!strcmp (line, "gpg") && !dirinfo.gpg_name) + dirinfo.gpg_name = strdup (value); + else if (!strcmp (line, "gpgsm") && !dirinfo.gpgsm_name) + dirinfo.gpgsm_name = strdup (value); + else if (!strcmp (line, "g13") && !dirinfo.g13_name) + dirinfo.g13_name = strdup (value); + } + else + { + if (!strcmp (line, "homedir") && !dirinfo.homedir) + { + const char name[] = "S.uiserver"; + + dirinfo.homedir = strdup (value); + if (dirinfo.homedir) + { + dirinfo.uisrv_socket = malloc (strlen (dirinfo + .homedir) + + 1 + strlen (name) + 1); + if (dirinfo.uisrv_socket) + strcpy (stpcpy (stpcpy (dirinfo.uisrv_socket, dirinfo.homedir), + DIRSEP_S), name); + } + } + else if (!strcmp (line, "agent-socket") && !dirinfo.agent_socket) + dirinfo.agent_socket = strdup (value); + } } /* Read the directory information from gpgconf. This function expects - that DIRINFO_LOCK is held by the caller. */ + that DIRINFO_LOCK is held by the caller. PGNAME is the name of the + gpgconf binary. If COMPONENTS is set, not the directories bit the + name of the componeNts are read. */ static void -read_gpgconf_dirs (void) +read_gpgconf_dirs (const char *pgmname, int components) { - const char *pgmname; char linebuf[1024] = {0}; int linelen = 0; char * argv[3]; @@ -89,12 +133,8 @@ read_gpgconf_dirs (void) int nread; char *mark = NULL; - pgmname = _gpgme_get_gpgconf_path (); - if (!pgmname) - return; /* No way. */ - argv[0] = (char *)pgmname; - argv[1] = "--list-dirs"; + argv[1] = components? "--list-components" : "--list-dirs"; argv[2] = NULL; if (_gpgme_io_pipe (rp, 1) < 0) @@ -132,7 +172,7 @@ read_gpgconf_dirs (void) else mark[0] = '\0'; - parse_output (line); + parse_output (line, components); } nused = lastmark? (lastmark + 1 - linebuf) : 0; @@ -147,14 +187,38 @@ read_gpgconf_dirs (void) static const char * -get_gpgconf_dir (int what) +get_gpgconf_item (int what) { const char *result = NULL; LOCK (dirinfo_lock); if (!dirinfo.valid) { - read_gpgconf_dirs (); + const char *pgmname; + + pgmname = _gpgme_get_gpgconf_path (); + if (pgmname && access (pgmname, F_OK)) + { + _gpgme_debug (DEBUG_INIT, + "gpgme_dinfo: gpgconf='%s' [not installed]\n", pgmname); + pgmname = NULL; /* Not available. */ + } + else + _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: gpgconf='%s'\n", + pgmname? pgmname : "[null]"); + if (!pgmname) + { + /* Probably gpgconf is not installed. Assume we are using + GnuPG-1. */ + pgmname = _gpgme_get_gpg_path (); + if (pgmname) + dirinfo.gpg_name = strdup (pgmname); + } + else + { + read_gpgconf_dirs (pgmname, 0); + read_gpgconf_dirs (pgmname, 1); + } /* Even if the reading of the directories failed (e.g. due to an too old version gpgconf or no gpgconf at all), we need to mark the entries as valid so that we won't try over and over @@ -162,11 +226,33 @@ get_gpgconf_dir (int what) the read values later because they are practically statically allocated. */ dirinfo.valid = 1; + if (dirinfo.gpg_name) + _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: gpg='%s'\n", + dirinfo.gpg_name); + if (dirinfo.g13_name) + _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: g13='%s'\n", + dirinfo.g13_name); + if (dirinfo.gpgsm_name) + _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: gpgsm='%s'\n", + dirinfo.gpgsm_name); + if (dirinfo.homedir) + _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: homedir='%s'\n", + dirinfo.homedir); + if (dirinfo.agent_socket) + _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: agent='%s'\n", + dirinfo.agent_socket); + if (dirinfo.uisrv_socket) + _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: uisrv='%s'\n", + dirinfo.uisrv_socket); } switch (what) { case WANT_HOMEDIR: result = dirinfo.homedir; break; case WANT_AGENT_SOCKET: result = dirinfo.agent_socket; break; + case WANT_GPG_NAME: result = dirinfo.gpg_name; break; + case WANT_GPGSM_NAME: result = dirinfo.gpgsm_name; break; + case WANT_G13_NAME: result = dirinfo.g13_name; break; + case WANT_UISRV_SOCKET: result = dirinfo.uisrv_socket; break; } UNLOCK (dirinfo_lock); return result; @@ -177,13 +263,51 @@ get_gpgconf_dir (int what) const char * _gpgme_get_default_homedir (void) { - return get_gpgconf_dir (WANT_HOMEDIR); + return get_gpgconf_item (WANT_HOMEDIR); } /* Return the default gpg-agent socket name. Returns NULL if not known. */ const char * _gpgme_get_default_agent_socket (void) { - return get_gpgconf_dir (WANT_AGENT_SOCKET); + return get_gpgconf_item (WANT_AGENT_SOCKET); +} + +/* Return the default gpg file name. Returns NULL if not known. */ +const char * +_gpgme_get_default_gpg_name (void) +{ + return get_gpgconf_item (WANT_GPG_NAME); +} + +/* Return the default gpgsm file name. Returns NULL if not known. */ +const char * +_gpgme_get_default_gpgsm_name (void) +{ + return get_gpgconf_item (WANT_GPGSM_NAME); +} + +/* Return the default g13 file name. Returns NULL if not known. */ +const char * +_gpgme_get_default_g13_name (void) +{ + return get_gpgconf_item (WANT_G13_NAME); } +/* Return the default gpgconf file name. Returns NULL if not known. + Because gpgconf is the binary used to retrieved all these default + names, this function is merely a simple wrapper around the function + used to locate this binary. */ +const char * +_gpgme_get_default_gpgconf_name (void) +{ + return _gpgme_get_gpgconf_path (); +} + +/* Return the default UI-server socket name. Returns NULL if not + known. */ +const char * +_gpgme_get_default_uisrv_socket (void) +{ + return get_gpgconf_item (WANT_UISRV_SOCKET); +} diff --git a/src/engine-g13.c b/src/engine-g13.c index de0aac8..b97e0b4 100644 --- a/src/engine-g13.c +++ b/src/engine-g13.c @@ -100,7 +100,7 @@ static char * g13_get_version (const char *file_name) { return _gpgme_get_program_version (file_name ? file_name - : _gpgme_get_g13_path ()); + : _gpgme_get_default_g13_name ()); } @@ -251,11 +251,11 @@ g13_new (void **engine, const char *file_name, const char *home_dir) #if USE_DESCRIPTOR_PASSING err = assuan_pipe_connect - (g13->assuan_ctx, file_name ? file_name : _gpgme_get_g13_path (), + (g13->assuan_ctx, file_name ? file_name : _gpgme_get_default_g13_name (), argv, NULL, NULL, NULL, ASSUAN_PIPE_CONNECT_FDPASSING); #else err = assuan_pipe_connect - (g13->assuan_ctx, file_name ? file_name : _gpgme_get_g13_path (), + (g13->assuan_ctx, file_name ? file_name : _gpgme_get_default_g13_name (), argv, NULL, NULL, NULL, 0); #endif if (err) @@ -757,7 +757,7 @@ g13_io_event (void *engine, gpgme_event_io_t type, void *type_data) struct engine_ops _gpgme_engine_ops_g13 = { /* Static functions. */ - _gpgme_get_g13_path, + _gpgme_get_default_g13_name, NULL, g13_get_version, g13_get_req_version, diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 72d3ad1..3bc9f66 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -296,7 +296,7 @@ static char * gpg_get_version (const char *file_name) { return _gpgme_get_program_version (file_name ? file_name - : _gpgme_get_gpg_path ()); + : _gpgme_get_default_gpg_name ()); } @@ -1296,7 +1296,7 @@ start (engine_gpg_t gpg) if (!gpg) return gpg_error (GPG_ERR_INV_VALUE); - if (!gpg->file_name && !_gpgme_get_gpg_path ()) + if (!gpg->file_name && !_gpgme_get_default_gpg_name ()) return trace_gpg_error (GPG_ERR_INV_ENGINE); if (gpg->lc_ctype) @@ -1352,7 +1352,7 @@ start (engine_gpg_t gpg) fd_list[n].dup_to = -1; status = _gpgme_io_spawn (gpg->file_name ? gpg->file_name : - _gpgme_get_gpg_path (), gpg->argv, + _gpgme_get_default_gpg_name (), gpg->argv, IOSPAWN_FLAG_ALLOW_SET_FG, fd_list, NULL, NULL, &pid); { @@ -2401,7 +2401,7 @@ gpg_set_pinentry_mode (void *engine, gpgme_pinentry_mode_t mode) struct engine_ops _gpgme_engine_ops_gpg = { /* Static functions. */ - _gpgme_get_gpg_path, + _gpgme_get_default_gpg_name, NULL, gpg_get_version, gpg_get_req_version, diff --git a/src/engine-gpgconf.c b/src/engine-gpgconf.c index 3a1c1c1..1d457bb 100644 --- a/src/engine-gpgconf.c +++ b/src/engine-gpgconf.c @@ -61,7 +61,7 @@ static char * gpgconf_get_version (const char *file_name) { return _gpgme_get_program_version (file_name ? file_name - : _gpgme_get_gpgconf_path ()); + : _gpgme_get_default_gpgconf_name ()); } @@ -100,7 +100,7 @@ gpgconf_new (void **engine, const char *file_name, const char *home_dir) return gpg_error_from_syserror (); gpgconf->file_name = strdup (file_name ? file_name - : _gpgme_get_gpgconf_path ()); + : _gpgme_get_default_gpgconf_name ()); if (!gpgconf->file_name) err = gpg_error_from_syserror (); @@ -923,7 +923,7 @@ _gpgme_conf_release (gpgme_conf_comp_t conf) struct engine_ops _gpgme_engine_ops_gpgconf = { /* Static functions. */ - _gpgme_get_gpgconf_path, + _gpgme_get_default_gpgconf_name, NULL, gpgconf_get_version, gpgconf_get_req_version, diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 391b632..cee20e3 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -120,7 +120,7 @@ static char * gpgsm_get_version (const char *file_name) { return _gpgme_get_program_version (file_name ? file_name - : _gpgme_get_gpgsm_path ()); + : _gpgme_get_default_gpgsm_name ()); } @@ -340,7 +340,8 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) #if USE_DESCRIPTOR_PASSING err = assuan_pipe_connect - (gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (), + (gpgsm->assuan_ctx, + file_name ? file_name : _gpgme_get_default_gpgsm_name (), argv, NULL, NULL, NULL, ASSUAN_PIPE_CONNECT_FDPASSING); #else { @@ -352,7 +353,8 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) achild_fds[i] = (assuan_fd_t) child_fds[i]; err = assuan_pipe_connect - (gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (), + (gpgsm->assuan_ctx, + file_name ? file_name : _gpgme_get_default_gpgsm_name (), argv, achild_fds, NULL, NULL, 0); /* For now... */ @@ -1945,7 +1947,7 @@ gpgsm_passwd (void *engine, gpgme_key_t key, unsigned int flags) struct engine_ops _gpgme_engine_ops_gpgsm = { /* Static functions. */ - _gpgme_get_gpgsm_path, + _gpgme_get_default_gpgsm_name, NULL, gpgsm_get_version, gpgsm_get_req_version, diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c index a0008e4..bd140f9 100644 --- a/src/engine-uiserver.c +++ b/src/engine-uiserver.c @@ -296,7 +296,7 @@ uiserver_new (void **engine, const char *file_name, const char *home_dir) err = assuan_socket_connect (uiserver->assuan_ctx, file_name ? - file_name : _gpgme_get_uiserver_socket_path (), + file_name : _gpgme_get_default_uisrv_socket (), 0, ASSUAN_SOCKET_SERVER_FDPASSING); if (err) goto leave; @@ -1302,7 +1302,7 @@ uiserver_io_event (void *engine, gpgme_event_io_t type, void *type_data) struct engine_ops _gpgme_engine_ops_uiserver = { /* Static functions. */ - _gpgme_get_uiserver_socket_path, + _gpgme_get_default_uisrv_socket, NULL, uiserver_get_version, uiserver_get_req_version, diff --git a/src/posix-util.c b/src/posix-util.c index 478055a..fd44507 100644 --- a/src/posix-util.c +++ b/src/posix-util.c @@ -28,6 +28,7 @@ #include #include "util.h" +#include "sys-util.h" const char * _gpgme_get_gpg_path (void) @@ -70,29 +71,6 @@ _gpgme_get_g13_path (void) } -const char * -_gpgme_get_uiserver_socket_path (void) -{ - static char *socket_path; - const char *homedir; - const char name[] = "S.uiserver"; - - if (socket_path) - return socket_path; - - homedir = _gpgme_get_default_homedir (); - if (! homedir) - return NULL; - - socket_path = malloc (strlen (homedir) + 1 + strlen (name) + 1); - if (! socket_path) - return NULL; - - strcpy (stpcpy (stpcpy (socket_path, homedir), "/"), name); - return socket_path; -} - - /* See w32-util.c */ int _gpgme_get_conf_int (const char *key, int *value) diff --git a/src/sys-util.h b/src/sys-util.h new file mode 100644 index 0000000..f6506d3 --- /dev/null +++ b/src/sys-util.h @@ -0,0 +1,29 @@ +/* sys-util.h - System utilities not generally used. + * Copyright (C) 2013 g10 Code GmbH + * + * This file is part of GPGME. + * + * GPGME is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * GPGME is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see . + */ + +#ifndef SYS_UTIL_H +#define SYS_UTIL_H + +/*-- {posix,w32}-util.c --*/ +const char *_gpgme_get_gpg_path (void); +const char *_gpgme_get_gpgsm_path (void); +const char *_gpgme_get_gpgconf_path (void); +const char *_gpgme_get_g13_path (void); + +#endif /* SYS_UTIL_H */ diff --git a/src/util.h b/src/util.h index db8dc39..c432980 100644 --- a/src/util.h +++ b/src/util.h @@ -47,18 +47,17 @@ /*-- {posix,w32}-util.c --*/ -const char *_gpgme_get_gpg_path (void); -const char *_gpgme_get_gpgsm_path (void); -const char *_gpgme_get_gpgconf_path (void); -const char *_gpgme_get_g13_path (void); -const char *_gpgme_get_uiserver_socket_path (void); - int _gpgme_get_conf_int (const char *key, int *value); void _gpgme_allow_set_foreground_window (pid_t pid); /*-- dirinfo.c --*/ const char *_gpgme_get_default_homedir (void); const char *_gpgme_get_default_agent_socket (void); +const char *_gpgme_get_default_gpg_name (void); +const char *_gpgme_get_default_gpgsm_name (void); +const char *_gpgme_get_default_g13_name (void); +const char *_gpgme_get_default_gpgconf_name (void); +const char *_gpgme_get_default_uisrv_socket (void); diff --git a/src/w32-util.c b/src/w32-util.c index 27dc5bc..4cee1cb 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -62,6 +62,7 @@ #include "ath.h" #include "sema.h" #include "debug.h" +#include "sys-util.h" #ifndef HAVE_W32CE_SYSTEM @@ -493,29 +494,6 @@ _gpgme_get_g13_path (void) const char * -_gpgme_get_uiserver_socket_path (void) -{ - static char *socket_path; - const char *homedir; - const char name[] = "S.uiserver"; - - if (socket_path) - return socket_path; - - homedir = _gpgme_get_default_homedir (); - if (! homedir) - return NULL; - - socket_path = malloc (strlen (homedir) + 1 + strlen (name) + 1); - if (! socket_path) - return NULL; - - strcpy (stpcpy (stpcpy (socket_path, homedir), "\\"), name); - return socket_path; -} - - -const char * _gpgme_get_w32spawn_path (void) { static char *w32spawn_program; ----------------------------------------------------------------------- Summary of changes: NEWS | 6 ++ configure.ac | 6 ++- src/Makefile.am | 2 +- src/dirinfo.c | 166 ++++++++++++++++++++++++++++++++++++++++++------ src/engine-g13.c | 8 +- src/engine-gpg.c | 8 +- src/engine-gpgconf.c | 6 +- src/engine-gpgsm.c | 10 ++- src/engine-uiserver.c | 4 +- src/posix-util.c | 24 +------- src/sys-util.h | 29 +++++++++ src/util.h | 11 ++-- src/w32-util.c | 24 +------- 13 files changed, 212 insertions(+), 92 deletions(-) create mode 100644 src/sys-util.h hooks/post-receive -- GnuPG Made Easy http://git.gnupg.org From cvs at cvs.gnupg.org Mon Aug 5 19:29:40 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 05 Aug 2013 19:29:40 +0200 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-178-gd8e99a0 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via d8e99a04dba6a606e879464cd11deee760d1e000 (commit) from 10dfa41b43a906031bc674ea41cd3073701011f3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d8e99a04dba6a606e879464cd11deee760d1e000 Author: Werner Koch Date: Mon Aug 5 18:58:41 2013 +0200 mpi: Improve gcry_mpi_invm to detect bad input. * mpi/mpi-inv.c (gcry_mpi_invm): Return 0 for bad input. -- Without this patch the function may enter and endless loop. Signed-off-by: Werner Koch diff --git a/mpi/mpi-inv.c b/mpi/mpi-inv.c index 5d26946..15fa58f 100644 --- a/mpi/mpi-inv.c +++ b/mpi/mpi-inv.c @@ -165,6 +165,11 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) int sign; int odd ; + if (!mpi_cmp_ui (a, 0)) + return 0; /* Inverse does not exists. */ + if (!mpi_cmp_ui (n, 1)) + return 0; /* Inverse does not exists. */ + u = mpi_copy(a); v = mpi_copy(n); ----------------------------------------------------------------------- Summary of changes: mpi/mpi-inv.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Tue Aug 6 10:40:22 2013 From: cvs at cvs.gnupg.org (by NIIBE Yutaka) Date: Tue, 06 Aug 2013 10:40:22 +0200 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-181-g9a42181 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 9a421813123a2f5db0a91eaee4a45138efc9ad34 (commit) via 87eddc31ccba6decbddd1761dd42a208666cd311 (commit) via ae6ffd9af38cbcac57c220960f683aab91db85cb (commit) from d8e99a04dba6a606e879464cd11deee760d1e000 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9a421813123a2f5db0a91eaee4a45138efc9ad34 Author: NIIBE Yutaka Date: Tue Aug 6 14:38:51 2013 +0900 cipher: fix another memory leak. * cipher/ecc.c (ecc_get_curve): Free TMP. diff --git a/cipher/ecc.c b/cipher/ecc.c index 375eeaf..b694d76 100644 --- a/cipher/ecc.c +++ b/cipher/ecc.c @@ -1319,6 +1319,7 @@ ecc_get_curve (gcry_mpi_t *pkey, int iterator, unsigned int *r_nbits) tmp = scanval (domain_parms[idx].g_y); if (!mpi_cmp (tmp, E.G.y)) { + mpi_free (tmp); result = domain_parms[idx].desc; if (r_nbits) *r_nbits = domain_parms[idx].nbits; commit 87eddc31ccba6decbddd1761dd42a208666cd311 Author: NIIBE Yutaka Date: Tue Aug 6 12:59:35 2013 +0900 tests: fix memory leaks. * tests/pubkey.c (check_keys_crypt): Release L, X0, and X1. (check_keys): Release X. diff --git a/tests/pubkey.c b/tests/pubkey.c index ffaecb3..baf234c 100644 --- a/tests/pubkey.c +++ b/tests/pubkey.c @@ -144,6 +144,7 @@ check_keys_crypt (gcry_sexp_t pkey, gcry_sexp_t skey, /* Extract data from plaintext. */ l = gcry_sexp_find_token (plain0, "value", 0); x0 = gcry_sexp_nth_mpi (l, 1, GCRYMPI_FMT_USG); + gcry_sexp_release (l); /* Encrypt data. */ rc = gcry_pk_encrypt (&cipher, plain0, pkey); @@ -160,7 +161,10 @@ check_keys_crypt (gcry_sexp_t pkey, gcry_sexp_t skey, if (rc) { if (decrypt_fail_code && gpg_err_code (rc) == decrypt_fail_code) - return; /* This is the expected failure code. */ + { + gcry_mpi_release (x0); + return; /* This is the expected failure code. */ + } die ("decryption failed: %s\n", gcry_strerror (rc)); } @@ -189,6 +193,8 @@ check_keys_crypt (gcry_sexp_t pkey, gcry_sexp_t skey, /* Compare. */ if (gcry_mpi_cmp (x0, x1)) die ("data corrupted\n"); + gcry_mpi_release (x0); + gcry_mpi_release (x1); } static void @@ -218,6 +224,7 @@ check_keys (gcry_sexp_t pkey, gcry_sexp_t skey, unsigned int nbits_data, rc = gcry_sexp_build (&plain, NULL, "(data (flags raw no-blinding) (value %m))", x); + gcry_mpi_release (x); if (rc) die ("converting data for encryption failed: %s\n", gcry_strerror (rc)); commit ae6ffd9af38cbcac57c220960f683aab91db85cb Author: NIIBE Yutaka Date: Tue Aug 6 12:57:10 2013 +0900 cipher: fix memory leaks. * cipher/elgamal.c (elg_generate_ext): Free XVALUE. * cipher/pubkey.c (sexp_elements_extract): Don't use IDX for loop. Call mpi_free. (sexp_elements_extract_ecc): Call mpi_free. diff --git a/cipher/elgamal.c b/cipher/elgamal.c index b40d132..7540e3f 100644 --- a/cipher/elgamal.c +++ b/cipher/elgamal.c @@ -641,7 +641,10 @@ elg_generate_ext (int algo, unsigned int nbits, unsigned long evalue, } if (xvalue) - ec = generate_using_x (&sk, nbits, xvalue, retfactors); + { + ec = generate_using_x (&sk, nbits, xvalue, retfactors); + mpi_free (xvalue); + } else { generate (&sk, nbits, retfactors); diff --git a/cipher/pubkey.c b/cipher/pubkey.c index b540bd5..e867169 100644 --- a/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -1832,8 +1832,8 @@ sexp_elements_extract (gcry_sexp_t key_sexp, const char *element_names, if (!err) { /* Check that all elements are available. */ - for (name = element_names, idx = 0; *name; name++, idx++) - if (!elements[idx]) + for (name = element_names, i = 0; *name; name++, i++) + if (!elements[i]) break; if (*name) { @@ -1857,7 +1857,7 @@ sexp_elements_extract (gcry_sexp_t key_sexp, const char *element_names, { for (i = 0; i < idx; i++) if (elements[i]) - gcry_free (elements[i]); + mpi_free (elements[i]); } return err; } @@ -1963,7 +1963,7 @@ sexp_elements_extract_ecc (gcry_sexp_t key_sexp, const char *element_names, { for (name = element_names, idx = 0; *name; name++, idx++) if (elements[idx]) - gcry_free (elements[idx]); + mpi_free (elements[idx]); } return err; } ----------------------------------------------------------------------- Summary of changes: cipher/ecc.c | 1 + cipher/elgamal.c | 5 ++++- cipher/pubkey.c | 8 ++++---- tests/pubkey.c | 9 ++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Tue Aug 6 11:06:04 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 06 Aug 2013 11:06:04 +0200 Subject: [git] GnuPG - branch, STABLE-BRANCH-2-0, updated. gnupg-2.0.20-26-g110b52f Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, STABLE-BRANCH-2-0 has been updated via 110b52fffa77b339e6d59eba939408f7e87e7138 (commit) via f3c5cc8bcd37e38b5d65db6a50466e22d03d1f0c (commit) from 7c028efc182234cd28bbfbeccff0107f334064f2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 110b52fffa77b339e6d59eba939408f7e87e7138 Author: Werner Koch Date: Tue Aug 6 10:31:54 2013 +0200 Improve libcurl detection. * m4/libcurl.m4: Do not use AC_PATH_PROG if --with-libcurl as been given. Suggested by John Marshall. -- GnuPG-bug-id: 1510 diff --git a/m4/libcurl.m4 b/m4/libcurl.m4 index fe9809e..6299501 100644 --- a/m4/libcurl.m4 +++ b/m4/libcurl.m4 @@ -75,7 +75,11 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], if test -d "$_libcurl_with" ; then LIBCURL_CPPFLAGS="-I$withval/include" _libcurl_ldflags="-L$withval/lib" - AC_PATH_PROG([_libcurl_config],["$withval/bin/curl-config"]) + if test -x "$withval/bin/curl-config" ; then + _libcurl_config="$withval/bin/curl-config" + else + _libcurl_config= + fi else AC_PATH_PROG([_libcurl_config],[curl-config]) fi commit f3c5cc8bcd37e38b5d65db6a50466e22d03d1f0c Author: Werner Koch Date: Tue Aug 6 10:04:12 2013 +0200 gpg: Remove legacy keyserver examples from the template conf file. * g10/options.skel: Update. diff --git a/g10/options.skel b/g10/options.skel index 534affc..e21431b 100644 --- a/g10/options.skel +++ b/g10/options.skel @@ -4,11 +4,11 @@ # Options for GnuPG # Copyright 1998, 1999, 2000, 2001, 2002, 2003, # 2010 Free Software Foundation, Inc. -# +# # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# +# # This file is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -101,14 +101,9 @@ require-cross-certification # # Example HKP keyservers: # hkp://keys.gnupg.net -# hkp://subkeys.pgp.net -# -# Example email keyserver: -# mailto:pgp-public-keys at keys.pgp.net # # Example LDAP keyservers: # ldap://pgp.surfnet.nl:11370 -# ldap://keyserver.pgp.com # # Regular URL syntax applies, and you can set an alternate port # through the usual method: @@ -131,8 +126,6 @@ require-cross-certification keyserver hkp://keys.gnupg.net #keyserver http://http-keys.gnupg.net #keyserver mailto:pgp-public-keys at keys.nl.pgp.net -#keyserver ldap://pgp.surfnet.nl:11370 -#keyserver ldap://keyserver.pgp.com # Common options for keyserver functions: # ----------------------------------------------------------------------- Summary of changes: g10/options.skel | 11 ++--------- m4/libcurl.m4 | 6 +++++- 2 files changed, 7 insertions(+), 10 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Tue Aug 6 18:41:54 2013 From: cvs at cvs.gnupg.org (by Andre Heinecke) Date: Tue, 06 Aug 2013 18:41:54 +0200 Subject: [git] GpgOL - branch, master, updated. gpgol-1.1.3-51-gd1a9b54 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG extension for MS Outlook". The branch, master has been updated via d1a9b54ba57016d0194ada1778f09126af1e9afd (commit) from a81d6897e302fa0fceb73647d41ee27370bf1a57 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d1a9b54ba57016d0194ada1778f09126af1e9afd Author: Andre Heinecke Date: Tue Aug 6 16:04:17 2013 +0000 Implement add encrypted attachment Add a binary encrypted attachment to a Message object using OOM. The binary option requires very recent Versions of GPA or Kleopatra. * src/common.c, src/common.h (get_pretty_attachment_name), (get_tmp_outfile): New. Helper functions for attachments. * src/engine-assuan.c (op_assuan_encrypt): Handle binary option. * src/engine.h (ENGINE_FLAG_BINARY_OUTPUT): New. * src/mimemaker.c, src/mimemaker.h (sink_file_write): New. Sink to work on a file handle. * src/oomhelp.cpp, src/oomhelp.h (add_oom_attachment): New. Add an attachment to an Object with an Attachments collection. * src/ribbon-callbacks.cpp (addEncSignedAttachment): Implment adding an encrypted attachment. -- Although it is still possible to add an attachment over MAPI I found no way to update the Inspector of the Message Object aside from closing it / opening a new inspector. diff --git a/src/common.c b/src/common.c index 9818ae5..dd8b2d7 100644 --- a/src/common.c +++ b/src/common.c @@ -1054,3 +1054,116 @@ fix_linebreaks (char *str, int *len) *dst = '\0'; *len = dst - str; } + +/* Get a pretty name for the file at path path. File extension + will be set to work for the protocol as provided in protocol. + Returns NULL on success. + Caller must free result. */ +wchar_t * +get_pretty_attachment_name (wchar_t *path, protocol_t protocol) +{ + wchar_t* pretty; + wchar_t* buf; + + if (!path || !wcslen (path)) + { + log_error("%s:%s: No path given", SRCNAME, __func__); + return NULL; + } + + pretty = (wchar_t*) xmalloc ((MAX_PATH + 1) * sizeof (wchar_t)); + memset (pretty, 0, (MAX_PATH + 1) * sizeof (wchar_t)); + + buf = wcsrchr (path, '\\') + 1; + + if (!buf || !*buf) + { + log_error("%s:%s: No filename found in path", SRCNAME, __func__); + xfree (pretty); + return NULL; + } + + wcscpy (pretty, buf); + + buf = pretty + wcslen(pretty); + if (protocol == PROTOCOL_SMIME) + { + *(buf++) = '.'; + *(buf++) = 'p'; + *(buf++) = '7'; + *(buf++) = 'm'; + + } + else + { + *(buf++) = '.'; + *(buf++) = 'g'; + *(buf++) = 'p'; + *(buf++) = 'g'; + } + + return pretty; +} + +/* Open a file in a temporary directory, take name as a + suggestion and put the open Handle in outHandle. + Returns the actually used file name in case there + were other files with that name. */ +wchar_t* +get_tmp_outfile (wchar_t *name, HANDLE *outHandle) +{ + wchar_t tmpPath[MAX_PATH]; + wchar_t *outName; + wchar_t *fileExt = NULL; + int tries = 1; + + if (!name || !wcslen(name)) + { + log_error ("%s:%s: Needs a name.", + SRCNAME, __func__); + return NULL; + } + + /* We should probably use the unicode variants here + but this would mean adding OpenStreamOnFileW to + out mapi */ + + if (!GetTempPathW (MAX_PATH, tmpPath)) + { + log_error ("%s:%s: Could not get tmp path.", + SRCNAME, __func__); + return NULL; + } + + outName = (wchar_t*) xmalloc ((MAX_PATH + 1) * sizeof(wchar_t)); + memset (outName, 0, (MAX_PATH + 1) * sizeof (wchar_t)); + + snwprintf (outName, MAX_PATH, L"%s%s", tmpPath, name); + fileExt = wcschr (wcschr(outName, '\\'), '.'); + + while ((*outHandle = CreateFileW (outName, + GENERIC_WRITE | GENERIC_READ, + 0, /* We do not share this */ + NULL, + CREATE_NEW, + FILE_ATTRIBUTE_TEMPORARY, + NULL)) == INVALID_HANDLE_VALUE) + { + wchar_t fnameBuf[MAX_PATH]; + wchar_t origName[MAX_PATH]; + snwprintf (origName, MAX_PATH, L"%s%s", tmpPath, name); + fileExt = wcschr (wcsrchr(origName, '\\'), '.'); + wcsncpy (fnameBuf, origName, fileExt - origName); + snwprintf (outName, MAX_PATH, L"%s%i%s", fnameBuf, tries++, fileExt); + if (tries > 100) + { + /* You have to know when to give up,.. */ + log_error ("%s:%s: Could not get a name out of 100 tries", + SRCNAME, __func__); + xfree (outName); + return NULL; + } + } + + return outName; +} diff --git a/src/common.h b/src/common.h index 265a470..a3efad6 100644 --- a/src/common.h +++ b/src/common.h @@ -190,6 +190,11 @@ size_t qp_decode (char *buffer, size_t length, int *r_slbrk); void b64_init (b64_state_t *state); size_t b64_decode (b64_state_t *state, char *buffer, size_t length); +/* Get a temporary filename with and its name */ +wchar_t *get_tmp_outfile (wchar_t *name, HANDLE *outHandle); + +wchar_t *get_pretty_attachment_name (wchar_t *path, protocol_t protocol); + /* The length of the boundary - the buffer needs to be allocated one byte larger. */ #define BOUNDARYSIZE 20 diff --git a/src/engine-assuan.c b/src/engine-assuan.c index 6523e1b..9af3782 100644 --- a/src/engine-assuan.c +++ b/src/engine-assuan.c @@ -1704,7 +1704,11 @@ op_assuan_encrypt (protocol_t protocol, err = assuan_transact (ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); if (err) goto leave; - snprintf (line, sizeof line, "OUTPUT FD=%d", (unsigned int)outpipe[1]); + if (flags & ENGINE_FLAG_BINARY_OUTPUT) + snprintf (line, sizeof line, "OUTPUT FD=%d --binary", + (unsigned int)outpipe[1]); + else + snprintf (line, sizeof line, "OUTPUT FD=%d", (unsigned int)outpipe[1]); err = assuan_transact (ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); if (err) goto leave; diff --git a/src/engine.h b/src/engine.h index f92dc4f..0dd07fc 100644 --- a/src/engine.h +++ b/src/engine.h @@ -44,8 +44,9 @@ typedef struct engine_keyinfo_s *engine_keyinfo_t; struct engine_filter_s; typedef struct engine_filter_s *engine_filter_t; -/* Flag values used by the engine functions. */ -#define ENGINE_FLAG_SIGN_FOLLOWS 1 /* Expect a sign+encrypt operation. */ +/* Flag values used by the engine functions. */ +#define ENGINE_FLAG_SIGN_FOLLOWS 1 /* Expect a sign+encrypt operation. */ +#define ENGINE_FLAG_BINARY_OUTPUT 2 /* Create binary output */ diff --git a/src/mimemaker.c b/src/mimemaker.c index 6a358a4..93450db 100644 --- a/src/mimemaker.c +++ b/src/mimemaker.c @@ -95,6 +95,29 @@ sink_std_write (sink_t sink, const void *data, size_t datalen) return 0; } +/* Write method used with a sink_t that contains a file object. */ +int +sink_file_write (sink_t sink, const void *data, size_t datalen) +{ + HANDLE hFile = sink->cb_data; + DWORD written = NULL; + + if (!hFile || hFile == INVALID_HANDLE_VALUE) + { + log_error ("%s:%s: sink not setup for writing", SRCNAME, __func__); + return -1; + } + if (!data) + return 0; /* Flush - nothing to do here. */ + + if (!WriteFile (hFile, data, datalen, &written, NULL)) + { + log_error ("%s:%s: Write failed: ", SRCNAME, __func__); + return -1; + } + return 0; +} + /* Make sure that PROTOCOL is usable or return a suitable protocol. On error PROTOCOL_UNKNOWN is returned. */ diff --git a/src/mimemaker.h b/src/mimemaker.h index 0c804b3..fa7eca7 100644 --- a/src/mimemaker.h +++ b/src/mimemaker.h @@ -50,6 +50,7 @@ int mime_encrypt (LPMESSAGE message, HWND hwnd, int mime_sign_encrypt (LPMESSAGE message, HWND hwnd, protocol_t protocol, char **recipients); int sink_std_write (sink_t sink, const void *data, size_t datalen); +int sink_file_write (sink_t sink, const void *data, size_t datalen); int sink_encryption_write (sink_t encsink, const void *data, size_t datalen); int write_buffer_for_cb (void *opaque, const void *data, size_t datalen); int write_buffer (sink_t sink, const void *data, size_t datalen); diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp index 21be27f..a0e25ff 100644 --- a/src/oomhelp.cpp +++ b/src/oomhelp.cpp @@ -824,3 +824,75 @@ get_oom_recipients (LPDISPATCH recipients) } return recipientAddrs; } + +/* Add an attachment to the outlook dispatcher disp + that has an Attachment property. + inFile is the path to the attachment. Name is the + name that should be used in outlook. */ +int +add_oom_attachment (LPDISPATCH disp, wchar_t* inFileW) +{ + LPDISPATCH attachments = get_oom_object (disp, "Attachments"); + + DISPID dispid; + DISPPARAMS dispparams; + VARIANT vtResult; + VARIANT aVariant[4]; + HRESULT hr; + BSTR inFileB = NULL; + unsigned int argErr = 0; + EXCEPINFO execpinfo; + + if (!inFileW || !wcslen (inFileW)) + { + log_error ("%s:%s: no filename provided", SRCNAME, __func__); + return -1; + } + + dispid = lookup_oom_dispid (attachments, "Add"); + + if (dispid == DISPID_UNKNOWN) + { + log_error ("%s:%s: could not find attachment dispatcher", + SRCNAME, __func__); + return -1; + } + + inFileB = SysAllocString (inFileW); + + dispparams.rgvarg = aVariant; + + /* Contrary to the documentation the Source is the last + parameter and not the first. Additionally DisplayName + is documented but gets ignored by Outlook since Outlook + 2003 */ + + dispparams.rgvarg[0].vt = VT_BSTR; /* DisplayName */ + dispparams.rgvarg[0].bstrVal = NULL; + dispparams.rgvarg[1].vt = VT_INT; /* Position */ + dispparams.rgvarg[1].intVal = 1; + dispparams.rgvarg[2].vt = VT_INT; /* Type */ + dispparams.rgvarg[2].intVal = 1; + dispparams.rgvarg[3].vt = VT_BSTR; /* Source */ + dispparams.rgvarg[3].bstrVal = inFileB; + dispparams.cArgs = 4; + dispparams.cNamedArgs = 0; + VariantInit (&vtResult); + hr = attachments->Invoke (dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_METHOD, &dispparams, + &vtResult, &execpinfo, &argErr); + if (hr != S_OK) + { + log_debug ("%s:%s: error: invoking Add p=%p vt=%d hr=0x%x argErr=0x%x", + SRCNAME, __func__, + vtResult.pdispVal, vtResult.vt, (unsigned int)hr, + (unsigned int)argErr); + dump_excepinfo (execpinfo); + } + + SysFreeString (inFileB); + VariantClear (&vtResult); + RELDISP (attachments); + + return hr == S_OK ? 0 : -1; +} diff --git a/src/oomhelp.h b/src/oomhelp.h index 231c27d..7858b42 100644 --- a/src/oomhelp.h +++ b/src/oomhelp.h @@ -122,8 +122,11 @@ void del_oom_button (LPDISPATCH button); HWND get_oom_context_window (LPDISPATCH context); /* Get the address of the recipients as string list */ -char ** -get_oom_recipients (LPDISPATCH recipients); +char ** get_oom_recipients (LPDISPATCH recipients); + +/* Add an attachment to a dispatcher */ +int +add_oom_attachment (LPDISPATCH disp, wchar_t* inFile); #ifdef __cplusplus } diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp index 0afead1..966d74f 100644 --- a/src/ribbon-callbacks.cpp +++ b/src/ribbon-callbacks.cpp @@ -825,6 +825,216 @@ encryptSelection (LPDISPATCH ctrl) HRESULT addEncSignedAttachment (LPDISPATCH ctrl) { - /* TODO */ + LPDISPATCH context = NULL; + LPDISPATCH mailItem = NULL; + LPDISPATCH sender = NULL; + LPDISPATCH recipients = NULL; + HRESULT hr; + char* senderAddr = NULL; + char** recipientAddrs = NULL; + + HWND curWindow; + char *fileToEncrypt = NULL; + wchar_t *fileToEncryptW = NULL; + wchar_t *encryptedFile = NULL; + wchar_t *attachName = NULL; + HANDLE hFile = NULL; + HANDLE hEncFile = NULL; + + unsigned int session_number; + struct sink_s encsinkmem; + sink_t encsink = &encsinkmem; + struct sink_s sinkmem; + sink_t sink = &sinkmem; + engine_filter_t filter = NULL; + protocol_t protocol; + STATSTG tmpStat; + int rc = 0; + int i = 0; + LPSTREAM tmpstream = NULL; + + memset (encsink, 0, sizeof *encsink); + memset (sink, 0, sizeof *sink); + + hr = getContext (ctrl, &context); + if (FAILED(hr)) + return hr; + + /* First do the check for recipients as this is likely + to fail */ + mailItem = get_oom_object (context, "CurrentItem"); + sender = get_oom_object (mailItem, "Session.CurrentUser"); + recipients = get_oom_object (mailItem, "Recipients"); + recipientAddrs = get_oom_recipients (recipients); + + if (!recipientAddrs || !(*recipientAddrs)) + { + MessageBox (NULL, + _("Please add at least one recipent."), + _("GpgOL"), + MB_ICONINFORMATION|MB_OK); + goto failure; + } + + /* Get a file handle to read from */ + fileToEncrypt = get_open_filename (NULL, _("Select file to encrypt")); + + if (!fileToEncrypt) + { + log_debug ("No file selected"); + goto failure; + } + + fileToEncryptW = utf8_to_wchar2 (fileToEncrypt, strlen(fileToEncrypt)); + xfree (fileToEncrypt); + + hFile = CreateFileW (fileToEncryptW, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hFile == INVALID_HANDLE_VALUE) + { + /* Should not happen as the Open File dialog + should have prevented this. + Maybe this also happens when a file is + not readable. In that case we might want + to switch to a localized error naming the file. */ + MessageBox (NULL, + "Internal error in GpgOL.\n" + "Could not open File.", + _("GpgOL"), + MB_ICONERROR|MB_OK); + return S_OK; + } + + /* Now do the encryption preperations */ + + if (!mailItem || !sender || !recipients) + { + MessageBox (NULL, + "Internal error in GpgOL.\n" + "Could not find all objects.", + _("GpgOL"), + MB_ICONERROR|MB_OK); + log_error ("%s:%s: Could not find all objects.", + SRCNAME, __func__); + goto failure; + } + + senderAddr = get_oom_string (sender, "Address"); + + session_number = engine_new_session_number (); + + /* Prepare the encryption sink */ + if ((rc = engine_create_filter (&filter, write_buffer_for_cb, sink))) + { + goto failure; + } + + encsink->cb_data = filter; + encsink->writefnc = sink_encryption_write; + + engine_set_session_number (filter, session_number); + engine_set_session_title (filter, _("GpgOL")); + if ((rc=engine_encrypt_prepare (filter, curWindow, + PROTOCOL_UNKNOWN, + ENGINE_FLAG_BINARY_OUTPUT, + senderAddr, recipientAddrs, &protocol))) + { + log_error ("%s:%s: engine encrypt prepare failed : %s", + SRCNAME, __func__, gpg_strerror (rc)); + goto failure; + } + + attachName = get_pretty_attachment_name (fileToEncryptW, protocol); + + if (!attachName) + { + log_error ("%s:%s: Could not get a decent attachment name", + SRCNAME, __func__); + goto failure; + } + + encryptedFile = get_tmp_outfile (attachName, &hEncFile); + sink->cb_data = hEncFile; + sink->writefnc = sink_file_write; + + if ((rc=engine_encrypt_start (filter, 0))) + { + log_error ("%s:%s: engine encrypt start failed: %s", + SRCNAME, __func__, gpg_strerror (rc)); + goto failure; + } + + /* Read the file in chunks and write them to the encryption + buffer */ + { + char buf[4096]; + DWORD bytesRead = 0; + do + { + if (!ReadFile (hFile, buf, sizeof buf, &bytesRead, NULL)) + { + rc = -1; + log_error ("%s:%s: Could not read source file: %s", + SRCNAME, __func__); + goto failure; + } + if ((rc = write_buffer (encsink, bytesRead ? buf : NULL, bytesRead))) + { + rc = -1; + log_error ("%s:%s: Could not wirte out buffer", + SRCNAME, __func__); + goto failure; + } + } + while (bytesRead); + } + /* Lets hope the user did not select a huge file. We are hanging + here until encryption is completed.. */ + if ((rc = engine_wait (filter))) + goto failure; + + filter = NULL; /* Not valid anymore. */ + encsink->cb_data = NULL; /* Not needed anymore. */ + + if (!sink->enc_counter) + { + log_error ("%s:%s: nothing received from engine", SRCNAME, __func__); + goto failure; + } + + /* Now we have an encrypted file behind encryptedFile. Let's add it */ + add_oom_attachment (mailItem, encryptedFile); + +failure: + if (filter) + engine_cancel (filter); + + if (hEncFile) + { + CloseHandle (hEncFile); + DeleteFileW (encryptedFile); + } + xfree (senderAddr); + xfree (encryptedFile); + xfree (fileToEncryptW); + xfree (attachName); + RELDISP (mailItem); + RELDISP (sender); + RELDISP (recipients); + + if (hFile) + CloseHandle (hFile); + if (recipientAddrs) + { + for (i=0; recipientAddrs && recipientAddrs[i]; i++) + xfree (recipientAddrs[i]); + xfree (recipientAddrs); + } + return S_OK; } ----------------------------------------------------------------------- Summary of changes: src/common.c | 113 ++++++++++++++++++++++++ src/common.h | 5 + src/engine-assuan.c | 6 +- src/engine.h | 5 +- src/mimemaker.c | 23 +++++ src/mimemaker.h | 1 + src/oomhelp.cpp | 72 ++++++++++++++++ src/oomhelp.h | 7 +- src/ribbon-callbacks.cpp | 212 +++++++++++++++++++++++++++++++++++++++++++++- 9 files changed, 438 insertions(+), 6 deletions(-) hooks/post-receive -- GnuPG extension for MS Outlook http://git.gnupg.org From cvs at cvs.gnupg.org Wed Aug 7 10:18:55 2013 From: cvs at cvs.gnupg.org (by Jussi Kivilinna) Date: Wed, 07 Aug 2013 10:18:55 +0200 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-182-g065d446 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 065d446478bf68553339fc77a89b8369bd110a18 (commit) from 9a421813123a2f5db0a91eaee4a45138efc9ad34 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 065d446478bf68553339fc77a89b8369bd110a18 Author: Jussi Kivilinna Date: Wed Aug 7 10:36:41 2013 +0300 Fix building on W32 (cannot export symbol 'gcry_sexp_get_buffer') * src/libgcrypt.def: Change 'gcry_sexp_get_buffer' to 'gcry_sexp_nth_buffer'. -- Commit 2d3e8d4d9 "sexp: Add function gcry_sexp_nth_buffer." added 'gcry_sexp_get_buffer' to libgcrypt.def, when it should have been 'gcry_sexp_nth_buffer'. Signed-off-by: Jussi Kivilinna diff --git a/src/libgcrypt.def b/src/libgcrypt.def index bbc8f43..f275ae9 100644 --- a/src/libgcrypt.def +++ b/src/libgcrypt.def @@ -237,7 +237,7 @@ EXPORTS _gcry_mpi_get_const @213 - gcry_sexp_get_buffer @214 + gcry_sexp_nth_buffer @214 ;; end of file with public symbols for Windows. ----------------------------------------------------------------------- Summary of changes: src/libgcrypt.def | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Aug 7 11:30:05 2013 From: cvs at cvs.gnupg.org (by NIIBE Yutaka) Date: Wed, 07 Aug 2013 11:30:05 +0200 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-183-gcc08264 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via cc082642c1b0f2a3e9ca78e1ffd3f64417c204bd (commit) from 065d446478bf68553339fc77a89b8369bd110a18 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cc082642c1b0f2a3e9ca78e1ffd3f64417c204bd Author: NIIBE Yutaka Date: Wed Aug 7 08:56:18 2013 +0900 tests: fix memory leaks. * tests/benchmark.c (dsa_bench): Release SIG. * tests/mpitests.c (test_powm): Release BASE, EXP, MOD, and RES. * tests/prime.c (check_primes): Release PRIME. * tests/tsexp.c (basic): Use intermediate variable M for constant. Release S1, S2 and A. diff --git a/tests/benchmark.c b/tests/benchmark.c index 79048a3..f332003 100644 --- a/tests/benchmark.c +++ b/tests/benchmark.c @@ -864,7 +864,7 @@ dsa_bench (int iterations, int print_header) int p_sizes[3] = { 1024, 2048, 3072 }; int q_sizes[3] = { 160, 224, 256 }; gcry_sexp_t data; - gcry_sexp_t sig; + gcry_sexp_t sig = NULL; int i, j; err = gcry_sexp_sscan (pub_key+0, NULL, sample_public_dsa_key_1024, @@ -916,6 +916,7 @@ dsa_bench (int iterations, int print_header) start_timer (); for (j=0; j < iterations; j++) { + gcry_sexp_release (sig); err = gcry_pk_sign (&sig, data, sec_key[i]); if (err) { @@ -947,6 +948,7 @@ dsa_bench (int iterations, int print_header) gcry_sexp_release (sig); gcry_sexp_release (data); + sig = NULL; } diff --git a/tests/mpitests.c b/tests/mpitests.c index 432f3e8..03c15b9 100644 --- a/tests/mpitests.c +++ b/tests/mpitests.c @@ -362,6 +362,10 @@ test_powm (void) if (gcry_mpi_cmp (res, base)) die ("test_powm failed at %d\n", __LINE__); + gcry_mpi_release (base); + gcry_mpi_release (exp); + gcry_mpi_release (mod); + gcry_mpi_release (res); /* Fixme: We should add the rest of the cases of course. */ diff --git a/tests/prime.c b/tests/prime.c index 6e825ae..89800e8 100644 --- a/tests/prime.c +++ b/tests/prime.c @@ -95,6 +95,7 @@ check_primes (void) gcry_mpi_add_ui (prime, prime, 1); err = gcry_prime_check (prime, 0); assert (err); + gcry_mpi_release (prime); prime = NULL; } } diff --git a/tests/tsexp.c b/tests/tsexp.c index cef3ed1..7c4f7c8 100644 --- a/tests/tsexp.c +++ b/tests/tsexp.c @@ -89,44 +89,52 @@ basic (void) for (pass=0;;pass++) { + gcry_mpi_t m; + switch (pass) { case 0: string = ("(public-key (dsa (p #41424344#) (y this_is_y) " "(q #61626364656667#) (g %m)))"); - if ( gcry_sexp_build (&sexp, NULL, string, - gcry_mpi_set_ui (NULL, 42)) ) + m = gcry_mpi_set_ui (NULL, 42); + if ( gcry_sexp_build (&sexp, NULL, string, m ) ) { + gcry_mpi_release (m); fail (" scanning `%s' failed\n", string); return; } + gcry_mpi_release (m); break; case 1: string = ("(public-key (dsa (p #41424344#) (y this_is_y) " "(q %b) (g %m)))"); + m = gcry_mpi_set_ui (NULL, 42); if ( gcry_sexp_build (&sexp, NULL, string, - 15, "foo\0\x01\0x02789012345", - gcry_mpi_set_ui (NULL, 42)) ) + 15, "foo\0\x01\0x02789012345", m) ) { + gcry_mpi_release (m); fail (" scanning `%s' failed\n", string); return; } + gcry_mpi_release (m); break; case 2: string = ("(public-key (dsa (p #41424344#) (y silly_y_value) " "(q %b) (g %m)))"); + m = gcry_mpi_set_ui (NULL, 17); if ( gcry_sexp_build (&sexp, NULL, string, - secure_buffer_len, secure_buffer, - gcry_mpi_set_ui (NULL, 17)) ) + secure_buffer_len, secure_buffer, m) ) { + gcry_mpi_release (m); fail (" scanning `%s' failed\n", string); return; } + gcry_mpi_release (m); if (!gcry_is_secure (sexp)) fail ("gcry_sexp_build did not switch to secure memory\n"); break; @@ -144,13 +152,15 @@ basic (void) string = ("(public-key (dsa (p #41424344#) (parm %S) " "(y dummy)(q %b) (g %m)))"); + m = gcry_mpi_set_ui (NULL, 17); if ( gcry_sexp_build (&sexp, NULL, string, help_sexp, - secure_buffer_len, secure_buffer, - gcry_mpi_set_ui (NULL, 17)) ) + secure_buffer_len, secure_buffer, m) ) { + gcry_mpi_release (m); fail (" scanning `%s' failed\n", string); return; } + gcry_mpi_release (m); gcry_sexp_release (help_sexp); } break; @@ -181,6 +191,7 @@ basic (void) p = gcry_sexp_nth_data (s1, 0, &n); if (!p) { + gcry_sexp_release (s1); fail ("no car for `%s'\n", token); continue; } @@ -189,13 +200,16 @@ basic (void) s2 = gcry_sexp_cdr (s1); if (!s2) { + gcry_sexp_release (s1); fail ("no cdr for `%s'\n", token); continue; } p = gcry_sexp_nth_data (s2, 0, &n); + gcry_sexp_release (s2); if (p) { + gcry_sexp_release (s1); fail ("data at car of `%s'\n", token); continue; } @@ -203,6 +217,7 @@ basic (void) if (parm) { s2 = gcry_sexp_find_token (s1, parm, strlen (parm)); + gcry_sexp_release (s1); if (!s2) { fail ("didn't found `%s'\n", parm); @@ -211,6 +226,7 @@ basic (void) p = gcry_sexp_nth_data (s2, 0, &n); if (!p) { + gcry_sexp_release (s2); fail("no car for `%s'\n", parm ); continue; } @@ -218,18 +234,23 @@ basic (void) p = gcry_sexp_nth_data (s2, 1, &n); if (!p) { + gcry_sexp_release (s2); fail("no cdr for `%s'\n", parm ); continue; } info ("cdr=`%.*s'\n", (int)n, p); a = gcry_sexp_nth_mpi (s2, 0, GCRYMPI_FMT_USG); + gcry_sexp_release (s2); if (!a) { fail("failed to cdr the mpi for `%s'\n", parm); continue; } + gcry_mpi_release (a); } + else + gcry_sexp_release (s1); } gcry_sexp_release (sexp); ----------------------------------------------------------------------- Summary of changes: tests/benchmark.c | 4 +++- tests/mpitests.c | 4 ++++ tests/prime.c | 1 + tests/tsexp.c | 37 +++++++++++++++++++++++++++++-------- 4 files changed, 37 insertions(+), 9 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Thu Aug 8 15:48:39 2013 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 08 Aug 2013 15:48:39 +0200 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-184-g426cbc9 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 426cbc9feca0c8f46208fb3670adab95f9e46087 (commit) from cc082642c1b0f2a3e9ca78e1ffd3f64417c204bd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 426cbc9feca0c8f46208fb3670adab95f9e46087 Author: Werner Koch Date: Thu Aug 8 15:16:48 2013 +0200 mpi: Clear immutable flag on the result of gcry_mpi_set. * mpi/mpiutil.c (gcry_mpi_set): Reset immutable and const flags. * tests/mpitests.c (test_const_and_immutable): Add a test for this. -- gcry_mpi_set shall behave like gcry_mpi_copy and thus reset those special flags. Problem reported by Christian Grothoff. Signed-off-by: Werner Koch diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index cff15b7..a65d236 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -397,6 +397,7 @@ gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u) MPN_COPY( wp, up, usize ); w->nlimbs = usize; w->flags = u->flags; + w->flags &= ~(16|32); /* Reset the immutable and constant flags. */ w->sign = usign; return w; } diff --git a/tests/mpitests.c b/tests/mpitests.c index 03c15b9..e1c51d1 100644 --- a/tests/mpitests.c +++ b/tests/mpitests.c @@ -143,6 +143,23 @@ test_const_and_immutable (void) if (!gcry_mpi_get_flag (one, GCRYMPI_FLAG_CONST)) die ("const flag unexpectly cleared\n"); + + second_one = gcry_mpi_set (NULL, GCRYMPI_CONST_ONE); + if (gcry_mpi_get_flag (second_one, GCRYMPI_FLAG_IMMUTABLE)) + die ("immutable flag not cleared by mpi_set (NULL,x)\n"); + if (gcry_mpi_get_flag (second_one, GCRYMPI_FLAG_CONST)) + die ("const flag not cleared by mpi_set (NULL,x)\n"); + gcry_mpi_release (second_one); + + second_one = gcry_mpi_set_ui (NULL, 42); + gcry_mpi_set (second_one, GCRYMPI_CONST_ONE); + if (gcry_mpi_get_flag (second_one, GCRYMPI_FLAG_IMMUTABLE)) + die ("immutable flag not cleared after mpi_set (a,x)\n"); + if (gcry_mpi_get_flag (second_one, GCRYMPI_FLAG_CONST)) + die ("const flag not cleared mpi_set (a,x)\n"); + gcry_mpi_release (second_one); + + /* Due to the the constant flag the release below should be a NOP and will leak memory. */ gcry_mpi_release (one); ----------------------------------------------------------------------- Summary of changes: mpi/mpiutil.c | 1 + tests/mpitests.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Thu Aug 8 16:52:21 2013 From: cvs at cvs.gnupg.org (by Andre Heinecke) Date: Thu, 08 Aug 2013 16:52:21 +0200 Subject: [git] GpgOL - branch, master, updated. gpgol-1.1.3-56-gc607ce5 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG extension for MS Outlook". The branch, master has been updated via c607ce5551ec261b0c51daf10c32142cd7c60eb2 (commit) via d7e589d22a2bce76847d7f77ae89b45d7b911eb2 (commit) via 08984c034b6e04a5f49c5705eac1499fd94f06ad (commit) via eb4a8b909508994236fcb8e967fe90a1ddbcf8b5 (commit) via 02c82f9197d0fa7dabce2e9fda1f8ca6514eec3b (commit) from d1a9b54ba57016d0194ada1778f09126af1e9afd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c607ce5551ec261b0c51daf10c32142cd7c60eb2 Author: Andre Heinecke Date: Thu Aug 8 14:10:36 2013 +0000 Add signature support for files and text For files a detached signature is created and additionally attached. This also generalizes the encryptInspector and uses it as a more generic interface to the message composer context. * src/common.c, src/common.h (get_pretty_attachment_name): Add Parameter to query for the name of a detached signature. * src/dialogs.h: Define ID for sign-48.png * src/engine-assuan.c, src/engine-assuan.h (op_assuan_sign): Add flags parameter to control signature options. * src/engine.c (engine_sign_start): Create detached signatures by default. (engine_sign_opaque_start): New. Creates an opaque signature. * src/engine.h (ENGINE_FLAG_DETACHED): New. * src/gpgoladdin.cpp (GetIDsOfNames, Invoke, GetCustomUI): Add sign Action. * src/sign-48.png: New. * src/Makefile.am (EXTRA_DIST): Add sing-48.png * src/ribbon-callbacks.cpp (copyFileToSink): New. Helper function to copy the contents of a file into a sink. (attachSignature): New. Helper function to add a detached signature of a File to a MailItem. (encryptInspector, do_composer_action): Renamed. Actions and data is now controled by flags. Added sign action. (decryptInspector): Use subject as session title. (attachEncryptedFile): New. Attaches an encrypted file. Optionally also attaches the signature of that file. * src/ribbon-callbacks.h: Update accordingly. -- It is not clear how we will handle text sign. For now you can just dump opaque signed data in the messagecomposer if you want to. Some clients like Kmail handle this gracefully. But we also need support for verify in Outlook. diff --git a/src/Makefile.am b/src/Makefile.am index 1c01565..c61a5d6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,6 +34,7 @@ EXTRA_DIST = \ key-manager-64.png \ decrypt-16.png decrypt-48.png \ encrypt-sign-file-48.png \ + sign-48.png \ logo.bmp README.icons EXEEXT = .dll diff --git a/src/common.c b/src/common.c index 199103f..8473fee 100644 --- a/src/common.c +++ b/src/common.c @@ -1056,11 +1056,14 @@ fix_linebreaks (char *str, int *len) } /* Get a pretty name for the file at path path. File extension - will be set to work for the protocol as provided in protocol. + will be set to work for the protocol as provided in protocol and + depends on the signature setting. Set signature to 0 if the + extension should not be a signature extension. Returns NULL on success. Caller must free result. */ wchar_t * -get_pretty_attachment_name (wchar_t *path, protocol_t protocol) +get_pretty_attachment_name (wchar_t *path, protocol_t protocol, + int signature) { wchar_t* pretty; wchar_t* buf; @@ -1086,20 +1089,39 @@ get_pretty_attachment_name (wchar_t *path, protocol_t protocol) wcscpy (pretty, buf); buf = pretty + wcslen(pretty); - if (protocol == PROTOCOL_SMIME) + if (signature) { - *(buf++) = '.'; - *(buf++) = 'p'; - *(buf++) = '7'; - *(buf++) = 'm'; - + if (protocol == PROTOCOL_SMIME) + { + *(buf++) = '.'; + *(buf++) = 'p'; + *(buf++) = '7'; + *(buf++) = 's'; + } + else + { + *(buf++) = '.'; + *(buf++) = 's'; + *(buf++) = 'i'; + *(buf++) = 'g'; + } } else { - *(buf++) = '.'; - *(buf++) = 'g'; - *(buf++) = 'p'; - *(buf++) = 'g'; + if (protocol == PROTOCOL_SMIME) + { + *(buf++) = '.'; + *(buf++) = 'p'; + *(buf++) = '7'; + *(buf++) = 'm'; + } + else + { + *(buf++) = '.'; + *(buf++) = 'g'; + *(buf++) = 'p'; + *(buf++) = 'g'; + } } return pretty; diff --git a/src/common.h b/src/common.h index a3efad6..c525a17 100644 --- a/src/common.h +++ b/src/common.h @@ -193,7 +193,8 @@ size_t b64_decode (b64_state_t *state, char *buffer, size_t length); /* Get a temporary filename with and its name */ wchar_t *get_tmp_outfile (wchar_t *name, HANDLE *outHandle); -wchar_t *get_pretty_attachment_name (wchar_t *path, protocol_t protocol); +wchar_t *get_pretty_attachment_name (wchar_t *path, protocol_t protocol, + int signature); /* The length of the boundary - the buffer needs to be allocated one byte larger. */ diff --git a/src/dialogs.h b/src/dialogs.h index e140507..7da915a 100644 --- a/src/dialogs.h +++ b/src/dialogs.h @@ -141,5 +141,6 @@ #define IDI_DECRYPT_48_PNG 6011 #define IDI_KEY_MANAGER_64_PNG 6020 #define IDI_ENCSIGN_FILE_48_PNG 6030 +#define IDI_SIGN_48_PNG 6040 #endif /*DIALOGS_H*/ diff --git a/src/dialogs.rc b/src/dialogs.rc index a5ba635..48ab013 100644 --- a/src/dialogs.rc +++ b/src/dialogs.rc @@ -34,6 +34,7 @@ IDB_SIGN_16 BITMAP DISCARDABLE "sign-16.bmp" IDB_SIGN_16M BITMAP DISCARDABLE "sign-16m.bmp" IDB_SIGN_32 BITMAP DISCARDABLE "sign-32.bmp" IDB_SIGN_32M BITMAP DISCARDABLE "sign-32m.bmp" +IDI_SIGN_48_PNG RCDATA "sign-48.png" IDB_KEY_MANAGER_16 BITMAP DISCARDABLE "key-manager-16.bmp" IDB_KEY_MANAGER_16M BITMAP DISCARDABLE "key-manager-16m.bmp" diff --git a/src/engine-assuan.c b/src/engine-assuan.c index 9af3782..c7f3312 100644 --- a/src/engine-assuan.c +++ b/src/engine-assuan.c @@ -1805,11 +1805,12 @@ sign_closure (closure_data_t cld) called with FILTER as the first argument. SENDER is the sender's mail address (a mailbox). The used protocol will be stored at R_USED_PROTOCOL on return. */ -int -op_assuan_sign (protocol_t protocol, +int +op_assuan_sign (protocol_t protocol, gpgme_data_t indata, gpgme_data_t outdata, engine_filter_t filter, void *hwnd, - const char *sender, protocol_t *r_used_protocol) + const char *sender, protocol_t *r_used_protocol, + int flags) { gpg_error_t err; closure_data_t cld; @@ -1894,8 +1895,11 @@ op_assuan_sign (protocol_t protocol, enqueue_callback ("output", ctx, outdata, outpipe[0], 0, finalize_handler, cmdid, NULL, 1 /* Wait on success */, 0); - snprintf (line, sizeof line, "SIGN --protocol=%s --detached", - protocol_name); + if (flags & ENGINE_FLAG_DETACHED) + snprintf (line, sizeof line, "SIGN --protocol=%s --detached", + protocol_name); + else + snprintf (line, sizeof line, "SIGN --protocol=%s", protocol_name); err = start_command (ctx, cld, cmdid, line); cld = NULL; /* Now owned by start_command. */ if (err) diff --git a/src/engine-assuan.h b/src/engine-assuan.h index de2a144..237bd85 100644 --- a/src/engine-assuan.h +++ b/src/engine-assuan.h @@ -37,7 +37,7 @@ int op_assuan_init (void); void op_assuan_deinit (void); void engine_assuan_cancel (void *cancel_data); -int op_assuan_encrypt (protocol_t protocol, +int op_assuan_encrypt (protocol_t protocol, gpgme_data_t indata, gpgme_data_t outdata, engine_filter_t notify_data, void *hwnd, unsigned int flags, @@ -46,15 +46,16 @@ int op_assuan_encrypt (protocol_t protocol, struct engine_assuan_encstate_s **r_encstate); int op_assuan_encrypt_bottom (struct engine_assuan_encstate_s *encstate, int cancel); -int op_assuan_sign (protocol_t protocol, +int op_assuan_sign (protocol_t protocol, gpgme_data_t indata, gpgme_data_t outdata, engine_filter_t filter, void *hwnd, - const char *sender, protocol_t *r_used_protocol); + const char *sender, protocol_t *r_used_protocol, + int flags); int op_assuan_decrypt (protocol_t protocol, - gpgme_data_t indata, gpgme_data_t outdata, + gpgme_data_t indata, gpgme_data_t outdata, engine_filter_t filter, void *hwnd, int with_verify, const char *from_address); -int op_assuan_verify (gpgme_protocol_t protocol, +int op_assuan_verify (gpgme_protocol_t protocol, gpgme_data_t data, const char *signature, size_t sig_len, gpgme_data_t outdata, engine_filter_t filter, void *hwnd, diff --git a/src/engine.c b/src/engine.c index 04c45ef..1dc471e 100644 --- a/src/engine.c +++ b/src/engine.c @@ -906,7 +906,8 @@ engine_sign_start (engine_filter_t filter, HWND hwnd, protocol_t protocol, if (filter->use_assuan) { err = op_assuan_sign (protocol, filter->indata, filter->outdata, - filter, hwnd, sender, &used_protocol); + filter, hwnd, sender, &used_protocol, + ENGINE_FLAG_DETACHED); if (!err) *r_protocol = used_protocol; } @@ -921,6 +922,30 @@ engine_sign_start (engine_filter_t filter, HWND hwnd, protocol_t protocol, return err; } +/* Start an inline signing operation. Same as engine_sign_start but + without the detatched option. */ +int +engine_sign_opaque_start (engine_filter_t filter, HWND hwnd, + protocol_t protocol, const char *sender, + protocol_t *r_protocol) +{ + gpg_error_t err; + protocol_t used_protocol; + + if (filter->use_assuan) + { + err = op_assuan_sign (protocol, filter->indata, filter->outdata, + filter, hwnd, sender, &used_protocol, + 0); + if (!err) + *r_protocol = used_protocol; + } + else + return gpg_error (GPG_ERR_NOT_SUPPORTED); + + return err; +} + /* Start an decrypt operation. FILTER is an object created by engine_create_filter. The caller needs to call engine_wait to diff --git a/src/engine.h b/src/engine.h index 0dd07fc..bba50c3 100644 --- a/src/engine.h +++ b/src/engine.h @@ -47,6 +47,7 @@ typedef struct engine_filter_s *engine_filter_t; /* Flag values used by the engine functions. */ #define ENGINE_FLAG_SIGN_FOLLOWS 1 /* Expect a sign+encrypt operation. */ #define ENGINE_FLAG_BINARY_OUTPUT 2 /* Create binary output */ +#define ENGINE_FLAG_DETACHED 4 /* Create detached signature */ @@ -81,6 +82,9 @@ int engine_encrypt_prepare (engine_filter_t filter, HWND hwnd, int engine_encrypt_start (engine_filter_t filter, int cancel); int engine_sign_start (engine_filter_t filter, HWND hwnd, protocol_t protocol, const char *sender, protocol_t *r_protocol); +int engine_sign_opaque_start (engine_filter_t filter, HWND hwnd, + protocol_t protocol, const char *sender, + protocol_t *r_protocol); int engine_decrypt_start (engine_filter_t filter, HWND hwnd, protocol_t protocol, int with_verify, diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp index 74bafcf..35e1f72 100644 --- a/src/gpgoladdin.cpp +++ b/src/gpgoladdin.cpp @@ -451,9 +451,11 @@ GpgolRibbonExtender::GetIDsOfNames (REFIID riid, LPOLESTR *rgszNames, ID_MAPPER (L"btnEncrypt", ID_BTN_ENCRYPT) ID_MAPPER (L"btnEncryptLarge", ID_BTN_ENCRYPT_LARGE) ID_MAPPER (L"btnEncryptFileLarge", ID_BTN_ENCSIGN_LARGE) + ID_MAPPER (L"btnSignLarge", ID_BTN_SIGN_LARGE) ID_MAPPER (L"encryptBody", ID_CMD_ENCRYPT_BODY) ID_MAPPER (L"decryptBody", ID_CMD_DECRYPT_BODY) ID_MAPPER (L"addEncSignedAttachment", ID_CMD_ATT_ENCSIGN_FILE) + ID_MAPPER (L"signBody", ID_CMD_SIGN_BODY) } if (cNames > 1) @@ -497,12 +499,15 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid, return decryptBody (parms->rgvarg[0].pdispVal); case ID_CMD_ATT_ENCSIGN_FILE: return addEncSignedAttachment (parms->rgvarg[0].pdispVal); + case ID_CMD_SIGN_BODY: + return signBody (parms->rgvarg[0].pdispVal); case ID_BTN_CERTMANAGER: case ID_BTN_ENCRYPT: case ID_BTN_DECRYPT: case ID_BTN_DECRYPT_LARGE: case ID_BTN_ENCRYPT_LARGE: case ID_BTN_ENCSIGN_LARGE: + case ID_BTN_SIGN_LARGE: return getIcon (dispid, result); } @@ -560,6 +565,11 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml) L" size=\"large\"" L" label=\"%S\"" L" onAction=\"decryptBody\"/>" + L"