From cvs at cvs.gnupg.org Tue Jan 5 05:07:48 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 05 Jan 2010 05:07:48 +0100 Subject: [svn] assuan - r340 - trunk/src Message-ID: Author: marcus Date: 2010-01-05 05:07:48 +0100 (Tue, 05 Jan 2010) New Revision: 340 Modified: trunk/src/assuan-buffer.c Log: Add comments. Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2009-12-22 13:01:21 UTC (rev 339) +++ trunk/src/assuan-buffer.c 2010-01-05 04:07:48 UTC (rev 340) @@ -31,7 +31,11 @@ /* Extended version of write(2) to guarantee that all bytes are - written. Returns 0 on success or -1 and ERRNO on failure. */ + written. Returns 0 on success or -1 and ERRNO on failure. NOTE: + This function does not return the number of bytes written, so any + error must be treated as fatal for this connection as the state of + the receiver is unknown. This works best if blocking is allowed + (so EAGAIN cannot occur). */ static int writen (assuan_context_t ctx, const char *buffer, size_t length) { @@ -93,7 +97,8 @@ } -/* Function returns an Assuan error. */ +/* Read a line with buffering of partial lines. Function returns an + Assuan error. */ gpg_error_t _assuan_read_line (assuan_context_t ctx) { From cvs at cvs.gnupg.org Tue Jan 5 05:09:05 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 05 Jan 2010 05:09:05 +0100 Subject: [svn] assuan - r341 - trunk/src Message-ID: Author: marcus Date: 2010-01-05 05:09:05 +0100 (Tue, 05 Jan 2010) New Revision: 341 Modified: trunk/src/ChangeLog trunk/src/debug.c trunk/src/debug.h trunk/src/system.c Log: 2010-01-05 Marcus Brinkmann * debug.h (TRACE_LOG5): Add macro. * debug.c (_assuan_debug_buffer): Add newline * system.c: Add more debug output (conditioned on the compile-time DEBUG_SYSIO macro). Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-05 04:07:48 UTC (rev 340) +++ trunk/src/ChangeLog 2010-01-05 04:09:05 UTC (rev 341) @@ -1,3 +1,10 @@ +2010-01-05 Marcus Brinkmann + + * debug.h (TRACE_LOG5): Add macro. + * debug.c (_assuan_debug_buffer): Add newline + * system.c: Add more debug output (conditioned on the compile-time + DEBUG_SYSIO macro). + 2009-12-14 Werner Koch * assuan.h (ASSUAN_RESPONSE_COMMENT): New. Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2010-01-05 04:07:48 UTC (rev 340) +++ trunk/src/debug.c 2010-01-05 04:09:05 UTC (rev 341) @@ -173,8 +173,9 @@ *(strp++) = ' '; } *(strp++) = ' '; + *(strp2++) = '\n'; *(strp2) = '\0'; - + _assuan_debug (ctx, cat, fmt, func, tagname, tag, str); } } Modified: trunk/src/debug.h =================================================================== --- trunk/src/debug.h 2010-01-05 04:07:48 UTC (rev 340) +++ trunk/src/debug.h 2010-01-05 04:09:05 UTC (rev 341) @@ -236,6 +236,11 @@ "%s (%s=%p): check: " fmt "\n", \ _assuan_trace_func, _assuan_trace_tagname, \ _assuan_trace_tag, arg1, arg2, arg3, arg4), 0 +#define TRACE_LOG5(fmt, arg1, arg2, arg3, arg4, arg5) \ + _assuan_debug (_assuan_trace_context, _assuan_trace_level, \ + "%s (%s=%p): check: " fmt "\n", \ + _assuan_trace_func, _assuan_trace_tagname, \ + _assuan_trace_tag, arg1, arg2, arg3, arg4, arg5), 0 #define TRACE_LOG6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ _assuan_debug (_assuan_trace_context, _assuan_trace_level, \ "%s (%s=%p): check: " fmt "\n", \ Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2010-01-05 04:07:48 UTC (rev 340) +++ trunk/src/system.c 2010-01-05 04:09:05 UTC (rev 341) @@ -43,6 +43,8 @@ #define MAX_OPEN_FDS 20 #endif +#define DEBUG_SYSIO 0 + assuan_fd_t assuan_fdopen (int fd) @@ -349,7 +351,7 @@ ssize_t _assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size) { -#if 0 +#if DEBUG_SYSIO ssize_t res; TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_read", ctx, "fd=0x%x, buffer=%p, size=%i", fd, buffer, size); @@ -406,7 +408,7 @@ _assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size) { -#if 0 +#if DEBUG_SYSIO ssize_t res; TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_write", ctx, "fd=0x%x, buffer=%p, size=%i", fd, buffer, size); @@ -440,7 +442,33 @@ _assuan_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags) { +#if DEBUG_SYSIO + ssize_t res; + TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_recvmsg", ctx, + "fd=0x%x, msg=%p, flags=0x%x", fd, msg, flags); + res = (ctx->system.recvmsg) (ctx, fd, msg, flags); + if (res > 0) + { + struct cmsghdr *cmptr; + + TRACE_LOG2 ("msg->msg_iov[0] = { iov_base=%p, iov_len=%i }", + msg->msg_iov[0].iov_base, msg->msg_iov[0].iov_len); + TRACE_LOGBUF (msg->msg_iov[0].iov_base, res); + + cmptr = CMSG_FIRSTHDR (msg); + if (cmptr) + { + void *data = CMSG_DATA (cmptr); + TRACE_LOG5 ("cmsg_len=0x%x (0x%x data), cmsg_level=0x%x, " + "cmsg_type=0x%x, first data int=0x%x", cmptr->cmsg_len, + cmptr->cmsg_len - (((char *)data) - ((char *)cmptr)), + cmptr->cmsg_level, cmptr->cmsg_type, *(int *)data); + } + } + return TRACE_SYSRES (res); +#else return (ctx->system.recvmsg) (ctx, fd, msg, flags); +#endif } @@ -466,7 +494,32 @@ _assuan_sendmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags) { +#if DEBUG_SYSIO + ssize_t res; + TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_sendmsg", ctx, + "fd=0x%x, msg=%p, flags=0x%x", fd, msg, flags); + { + struct cmsghdr *cmptr; + + TRACE_LOG2 ("msg->iov[0] = { iov_base=%p, iov_len=%i }", + msg->msg_iov[0].iov_base, msg->msg_iov[0].iov_len); + TRACE_LOGBUF (msg->msg_iov[0].iov_base, msg->msg_iov[0].iov_len); + + cmptr = CMSG_FIRSTHDR (msg); + if (cmptr) + { + void *data = CMSG_DATA (cmptr); + TRACE_LOG5 ("cmsg_len=0x%x (0x%x data), cmsg_level=0x%x, " + "cmsg_type=0x%x, first data int=0x%x", cmptr->cmsg_len, + cmptr->cmsg_len - (((char *)data) - ((char *)cmptr)), + cmptr->cmsg_level, cmptr->cmsg_type, *(int *)data); + } + } + res = (ctx->system.sendmsg) (ctx, fd, msg, flags); + return TRACE_SYSRES (res); +#else return (ctx->system.sendmsg) (ctx, fd, msg, flags); +#endif } @@ -877,7 +930,16 @@ _assuan_waitpid (assuan_context_t ctx, pid_t pid, int action, int *status, int options) { +#if DEBUG_SYSIO + ssize_t res; + TRACE_BEG4 (ctx, ASSUAN_LOG_SYSIO, "_assuan_waitpid", ctx, + "pid=%i, action=%i, status=%p, options=%i", + pid, action, status, options); + res = (ctx->system.waitpid) (ctx, pid, action, status, options); + return TRACE_SYSRES (res); +#else return (ctx->system.waitpid) (ctx, pid, action, status, options); +#endif } From cvs at cvs.gnupg.org Tue Jan 5 06:05:17 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 05 Jan 2010 06:05:17 +0100 Subject: [svn] assuan - r342 - in trunk: . src Message-ID: Author: marcus Date: 2010-01-05 06:05:16 +0100 (Tue, 05 Jan 2010) New Revision: 342 Modified: trunk/ChangeLog trunk/configure.ac trunk/src/assuan-uds.c Log: 2010-01-05 Marcus Brinkmann * configure.ac (_DARWIN_C_SOURCE): Define on frapple. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-05 04:09:05 UTC (rev 341) +++ trunk/ChangeLog 2010-01-05 05:05:16 UTC (rev 342) @@ -1,3 +1,7 @@ +2010-01-05 Marcus Brinkmann + + * configure.ac (_DARWIN_C_SOURCE): Define on frapple. + 2009-12-22 Marcus Brinkmann * configure.ac: Do not use echo -n. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-05 04:09:05 UTC (rev 341) +++ trunk/configure.ac 2010-01-05 05:05:16 UTC (rev 342) @@ -92,6 +92,7 @@ ;; *-apple-darwin*) AC_DEFINE(_XOPEN_SOURCE, 500, Activate POSIX interface on MacOS X) + AC_DEFINE(_DARWIN_C_SOURCE, 1, Activate CMSG_LEN/CMSG_SPACE on MacOS X) ;; esac Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2010-01-05 04:09:05 UTC (rev 341) +++ trunk/src/assuan-uds.c 2010-01-05 05:05:16 UTC (rev 342) @@ -45,7 +45,9 @@ #ifdef USE_DESCRIPTOR_PASSING /* Provide replacement for missing CMSG maccros. We assume that - size_t matches the alignment requirement. */ + size_t matches the alignment requirement. NOTE: This is not true + on Mac OS X, so be extra careful to define _DARWIN_C_SOURCE to get + those definitions instead of using these. */ #define MY_ALIGN(n) ((((n))+ sizeof(size_t)-1) & (size_t)~(sizeof(size_t)-1)) #ifndef CMSG_SPACE #define CMSG_SPACE(n) (MY_ALIGN(sizeof(struct cmsghdr)) + MY_ALIGN((n))) From cvs at cvs.gnupg.org Tue Jan 5 11:18:51 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 05 Jan 2010 11:18:51 +0100 Subject: [svn] GpgOL - r327 - trunk Message-ID: Author: wk Date: 2010-01-05 11:18:51 +0100 (Tue, 05 Jan 2010) New Revision: 327 Modified: trunk/NEWS trunk/configure.ac Log: Preparing a release Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-12-22 16:35:20 UTC (rev 326) +++ trunk/NEWS 2010-01-05 10:18:51 UTC (rev 327) @@ -1,5 +1,5 @@ -Noteworthy changes for version 1.1.0 -=================================================== +Noteworthy changes for version 1.1.0 (2010-01-05) +================================================= * Replaced most ECE code by direct OOM code. This was required to support better icons; i.e. icons not limited to a 16 color palette. @@ -7,11 +7,11 @@ * New icons. * Removed protocol selection. The UI-server is now expected to select - the protocol (i.e. the auto selection modus is now the only one). + the protocol (i.e. the auto selection mode is now the only one). Noteworthy changes for version 1.0.1 (2009-09-28) -=================================================== +================================================= * No more event loop peeking to avoid problem with Office programs. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-12-22 16:35:20 UTC (rev 326) +++ trunk/configure.ac 2010-01-05 10:18:51 UTC (rev 327) @@ -17,7 +17,7 @@ # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. m4_define([my_version], [1.1.0]) -m4_define([my_issvn], [yes]) +m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Tue Jan 5 11:19:26 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 05 Jan 2010 11:19:26 +0100 Subject: [svn] GpgOL - r328 - trunk Message-ID: Author: wk Date: 2010-01-05 11:19:25 +0100 (Tue, 05 Jan 2010) New Revision: 328 Modified: trunk/ChangeLog Log: Log release date Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-05 10:18:51 UTC (rev 327) +++ trunk/ChangeLog 2010-01-05 10:19:25 UTC (rev 328) @@ -1,3 +1,7 @@ +2010-01-05 Werner Koch + + Release 1.1.0. + 2009-12-22 Werner Koch * forms/encr-l.ico, forms/encr-s.ico: Update. From cvs at cvs.gnupg.org Tue Jan 5 11:43:02 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 05 Jan 2010 11:43:02 +0100 Subject: [svn] GpgOL - r329 - tags Message-ID: Author: wk Date: 2010-01-05 11:43:02 +0100 (Tue, 05 Jan 2010) New Revision: 329 Added: tags/gpgol-1.1.0/ Log: Release tag. From cvs at cvs.gnupg.org Tue Jan 5 18:36:53 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 05 Jan 2010 18:36:53 +0100 Subject: [svn] gpgme - r1444 - in trunk: . doc src Message-ID: Author: wk Date: 2010-01-05 18:36:53 +0100 (Tue, 05 Jan 2010) New Revision: 1444 Added: trunk/src/passwd.c Modified: trunk/NEWS trunk/README trunk/configure.ac trunk/doc/ChangeLog trunk/doc/gpgme.texi trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/engine-backend.h trunk/src/engine-gpgsm.c trunk/src/engine.c trunk/src/engine.h trunk/src/gpgme-tool.c trunk/src/gpgme.c trunk/src/gpgme.def trunk/src/gpgme.h.in trunk/src/libgpgme.vers Log: Add an API to change passphrases. Currently only implemented for GPGSM. Requires GnuPG 2.1 Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/doc/ChangeLog 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,3 +1,7 @@ +2010-01-05 Werner Koch + + * gpgme.texi (Changing Passphrases): New. + 2009-07-21 Werner Koch * uiserver.texi (UI Server Encrypt): Add --expect-sign option to Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/ChangeLog 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,3 +1,21 @@ +2010-01-05 Werner Koch + + * gpgme-tool.c (gt_passwd, cmd_passwd): New. + (register_commands): Register. + + * gpgme.h.in (gpgme_op_passwd_start, gpgme_op_passwd): New. + * libgpgme.vers, gpgme.def: Add new functions. + * passwd.c: New. + * Makefile.am (main_sources): Add passwd.c + * engine.c, engine.h (_gpgme_engine_op_passwd): New. + * engine-backend.h (struct engine_ops): Add PASSWD. + * engine-gpgsm.c (gpgsm_passwd): New. + (_gpgme_engine_ops_gpgsm): Register. + (gpgsm_reset): Reset only if we have a conenction. + + * gpgme.h.in (GPGME_PK_ECDSA, GPGME_PK_ECDH): New. + * gpgme.c (gpgme_pubkey_algo_name): Add them. + 2009-12-22 Marcus Brinkmann * debug.c: Test for TLS, not __GNUC__ Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/NEWS 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,4 +1,4 @@ -Noteworthy changes in version 1.2.1 (unreleased) +Noteworthy changes in version 1.3.0 (unreleased) ------------------------------------------------ * GPGME does not come with an internal libassuan version anymore. @@ -10,15 +10,22 @@ * New engine GPGME_PROTOCOL_UISERVER to support UI Servers. + * New API to change the passpgrase of a key. + * Interface changes relative to the 1.2.0 release: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -GPGME_STATUS_INV_SGNR NEW -GPGME_STATUS_NO_SGNR NEW -GPGME_PROTOCOL_G13 NEW -gpgme_op_g13_mount NEW -gpgme_g13_result_t NEW -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + GPGME_STATUS_INV_SGNR NEW. + GPGME_STATUS_NO_SGNR NEW. + GPGME_PROTOCOL_G13 NEW. + gpgme_op_g13_mount NEW. + gpgme_g13_result_t NEW. + GPGME_PK_ECDSA NEW. + GPGME_PK_ECDH NEW. + gpgme_op_passwd_start NEW. + gpgme_op_passwd NEW. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Noteworthy changes in version 1.2.0 (2009-06-18) ------------------------------------------------ @@ -1321,7 +1328,8 @@ * Made the W32 support more robust. - Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008 g10 Code GmbH + Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, + 2010 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: trunk/README =================================================================== --- trunk/README 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/README 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,7 +1,7 @@ GPGME - GnuPG Made Easy --------------------------- - Copyright 2004, 2006 g10 Code GmbH + Copyright 2004, 2006, 2010 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/configure.ac 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,6 +1,7 @@ # configure.ac for GPGME # Copyright (C) 2000 Werner Koch (dd9jn) -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 g10 Code GmbH +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, +# 2009, 2010 g10 Code GmbH # # This file is part of GPGME. # @@ -31,7 +32,7 @@ # specific feature can already be done under the assumption that the # SVN version is the most recent one in a branch. To disable the SVN # version for the real release, set the my_issvn macro to no. -m4_define(my_version, [1.2.1]) +m4_define(my_version, [1.3.0]) m4_define(my_issvn, [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \ Modified: trunk/doc/gpgme.texi =================================================================== --- trunk/doc/gpgme.texi 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/doc/gpgme.texi 2010-01-05 17:36:53 UTC (rev 1444) @@ -13,7 +13,8 @@ @syncodeindex pg fn @copying -Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007, 2008 g10 Code GmbH. +Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007, +2008, 2010 g10 Code GmbH. @quotation Permission is granted to copy, distribute and/or modify this document @@ -1014,6 +1015,18 @@ @item GPGME_PK_ELG_E This value also indicates ElGamal and is used specifically in GnuPG. + + at item GPGME_PK_ELG_E +This value also indicates ElGamal and is used specifically in GnuPG. + + at item GPGME_PK_ECDSA +This value indicates ECDSA, the Elliptic Curve Digital Signature +Algorithm as defined by FIPS 186-2. + + at item GPGME_PK_ECDH +This value indicates ECDH, the Eliptic Curve Diffie-Hellmann encryption +algorithm as defined by the ECC in OpenPGP draft. + @end table @end deftp @@ -2737,6 +2750,7 @@ * Exporting Keys:: Retrieving key data from the key ring. * Importing Keys:: Adding keys to the key ring. * Deleting Keys:: Removing keys from the key ring. +* Changing Passphrases:: Change the passphrase of a key. * Advanced Key Editing:: Advanced key edit operation. @end menu @@ -3715,6 +3729,38 @@ @end deftypefun + at node Changing Passphrases + at subsection Changing Passphrases + at cindex passphrase, change + + at deftypefun gpgme_error_t gpgme_op_passwd @ + (@w{gpgme_ctx_t @var{ctx}}, @ + @w{const gpgme_key_t @var{key}}, @ + @w{unsigned int @var{flags}}) + +The function @code{gpgme_op_passwd} changes the passphrase of the +private key associated with @var{key}. The only allowed value for + at var{flags} is @code{0}. The backend engine will usually popup a window +to ask for the old and the new passphrase. Thus this function is not +useful in a server application (where passphrases are not required +anyway). + at end deftypefun + + at deftypefun gpgme_error_t gpgme_op_passwd_start @ + (@w{gpgme_ctx_t @var{ctx}}, @ + @w{const gpgme_key_t @var{key}}, @ + @w{unsigned int @var{flags}}) + +The function @code{gpgme_op_passwd_start} initiates a + at code{gpgme_op_passwd} operation. It can be completed by calling + at code{gpgme_wait} on the context. @xref{Waiting For Completion}. + +The function returns @code{0} if the operation was started successfully, +and an error code if one of the arguments is not valid or the oepration +could not be started. + at end deftypefun + + @node Advanced Key Editing @subsection Advanced Key Editing @cindex key, edit Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/Makefile.am 2010-01-05 17:36:53 UTC (rev 1444) @@ -115,7 +115,7 @@ sign.c passphrase.c progress.c \ key.c keylist.c trust-item.c trustlist.c \ import.c export.c genkey.c delete.c edit.c getauditlog.c \ - opassuan.c \ + opassuan.c passwd.c \ engine.h engine-backend.h engine.c engine-gpg.c status-table.h \ $(gpgsm_components) $(assuan_components) $(gpgconf_components) \ $(uiserver_components) \ Modified: trunk/src/engine-backend.h =================================================================== --- trunk/src/engine-backend.h 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/engine-backend.h 2010-01-05 17:36:53 UTC (rev 1444) @@ -118,6 +118,9 @@ /* Cancel only the current operation, not the whole session. */ gpgme_error_t (*cancel_op) (void *engine); + + /* Change the passphrase for KEY. */ + gpgme_error_t (*passwd) (void *engine, gpgme_key_t key, unsigned int flags); }; Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/engine-gpgsm.c 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,6 +1,7 @@ /* engine-gpgsm.c - GpgSM engine. Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009, + 2010 g10 Code GmbH This file is part of GPGME. @@ -1053,13 +1054,18 @@ { engine_gpgsm_t gpgsm = engine; - /* We must send a reset because we need to reset the list of - signers. Note that RESET does not reset OPTION commands. */ - return gpgsm_assuan_simple_command (gpgsm->assuan_ctx, "RESET", NULL, NULL); + /* IF we have an active connection we must send a reset because we + need to reset the list of signers. Note that RESET does not + reset OPTION commands. */ + return (gpgsm->assuan_ctx + ? gpgsm_assuan_simple_command (gpgsm->assuan_ctx, "RESET", + NULL, NULL) + : 0); } #endif + static gpgme_error_t gpgsm_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain) { @@ -1894,6 +1900,32 @@ } +static gpgme_error_t +gpgsm_passwd (void *engine, gpgme_key_t key, unsigned int flags) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err; + char *line; + + if (!key || !key->subkeys || !key->subkeys->fpr) + return gpg_error (GPG_ERR_INV_VALUE); + + if (asprintf (&line, "PASSWD -- %s", key->subkeys->fpr) < 0) + return gpg_error_from_syserror (); + + gpgsm_clear_fd (gpgsm, OUTPUT_FD); + gpgsm_clear_fd (gpgsm, INPUT_FD); + gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; + + err = start (gpgsm, line); + free (line); + + return err; +} + + + struct engine_ops _gpgme_engine_ops_gpgsm = { /* Static functions. */ @@ -1937,5 +1969,6 @@ gpgsm_set_io_cbs, gpgsm_io_event, gpgsm_cancel, - NULL /* cancel_op */ + NULL, /* cancel_op */ + gpgsm_passwd }; Modified: trunk/src/engine.c =================================================================== --- trunk/src/engine.c 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/engine.c 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,6 +1,6 @@ /* engine.c - GPGME engine support. Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2006, 2009 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2006, 2009, 2010 g10 Code GmbH This file is part of GPGME. @@ -906,3 +906,19 @@ return (*engine->ops->cancel_op) (engine->engine); } + + +/* Change the passphrase for KEY. */ +gpgme_error_t +_gpgme_engine_op_passwd (engine_t engine, gpgme_key_t key, + unsigned int flags) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->passwd) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->passwd) (engine->engine, key, flags); +} + Modified: trunk/src/engine.h =================================================================== --- trunk/src/engine.h 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/engine.h 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,6 +1,6 @@ /* engine.h - GPGME engine interface. Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2010 g10 Code GmbH This file is part of GPGME. @@ -157,4 +157,8 @@ gpgme_error_t _gpgme_engine_cancel_op (engine_t engine); +gpgme_error_t _gpgme_engine_op_passwd (engine_t engine, gpgme_key_t key, + unsigned int flags); + + #endif /* ENGINE_H */ Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/gpgme-tool.c 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,6 +1,5 @@ /* gpgme-tool.c - GnuPG Made Easy. - Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH + Copyright (C) 2009, 2010 g10 Code GmbH This file is part of GPGME. @@ -15,9 +14,8 @@ 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. */ + License along with this program; if not, see . + */ #if HAVE_CONFIG_H #include @@ -1119,7 +1117,30 @@ } -// TODO +static const char hlp_passwd[] = + "PASSWD \n" + "\n" + "Ask the backend to change the passphrase for the key\n" + "specified by USER-ID."; +gpg_error_t +gt_passwd (gpgme_tool_t gt, char *fpr) +{ + gpg_error_t err; + gpgme_key_t key; + + err = gpgme_get_key (gt->ctx, fpr, &key, 0); + if (err) + return err; + + err = gpgme_op_passwd (gt->ctx, key, 0); + gpgme_key_unref (key); + return err; +} + + + + +/* TODO */ #define GT_RESULT_ENCRYPT 0x1 #define GT_RESULT_DECRYPT 0x2 #define GT_RESULT_SIGN 0x4 @@ -1975,6 +1996,16 @@ static gpg_error_t +cmd_passwd (assuan_context_t ctx, char *line) +{ + struct server *server = assuan_get_pointer (ctx); + + return gt_passwd (server->gt, line); +} + + + +static gpg_error_t cmd_result (assuan_context_t ctx, char *line) { struct server *server = assuan_get_pointer (ctx); @@ -2076,6 +2107,7 @@ { "STRERROR", cmd_strerror }, { "PUBKEY_ALGO_NAME", cmd_pubkey_algo_name }, { "HASH_ALGO_NAME", cmd_hash_algo_name }, + { "PASSWD", cmd_passwd, hlp_passwd }, { NULL } }; int idx; Modified: trunk/src/gpgme.c =================================================================== --- trunk/src/gpgme.c 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/gpgme.c 2010-01-05 17:36:53 UTC (rev 1444) @@ -792,6 +792,12 @@ case GPGME_PK_ELG: return "ELG"; + case GPGME_PK_ECDSA: + return "ECDSA"; + + case GPGME_PK_ECDH: + return "ECDH"; + default: return NULL; } Modified: trunk/src/gpgme.def =================================================================== --- trunk/src/gpgme.def 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/gpgme.def 2010-01-05 17:36:53 UTC (rev 1444) @@ -196,5 +196,8 @@ gpgme_set_sub_protocol @150 gpgme_get_sub_protocol @151 + gpgme_op_passwd_start @152 + gpgme_op_passwd @153 + ; END Modified: trunk/src/gpgme.h.in =================================================================== --- trunk/src/gpgme.h.in 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/gpgme.h.in 2010-01-05 17:36:53 UTC (rev 1444) @@ -1,6 +1,7 @@ /* gpgme.h - Public interface to GnuPG Made Easy. -*- c -*- Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 + 2010 g10 Code GmbH This file is part of GPGME. @@ -209,7 +210,9 @@ GPGME_PK_RSA_S = 3, GPGME_PK_ELG_E = 16, GPGME_PK_DSA = 17, - GPGME_PK_ELG = 20 + GPGME_PK_ELG = 20, + GPGME_PK_ECDSA = 301, + GPGME_PK_ECDH = 302 } gpgme_pubkey_algo_t; @@ -1664,6 +1667,14 @@ /* Terminate a pending keylist operation within CTX. */ gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx); +/* Change the passphrase for KEY. FLAGS is reserved for future use + and must be passed as 0. */ +gpgme_error_t gpgme_op_passwd_start (gpgme_ctx_t ctx, gpgme_key_t key, + unsigned int flags); +gpgme_error_t gpgme_op_passwd (gpgme_ctx_t ctx, gpgme_key_t key, + unsigned int flags); + + /* Trust items and operations. */ Modified: trunk/src/libgpgme.vers =================================================================== --- trunk/src/libgpgme.vers 2009-12-22 13:00:30 UTC (rev 1443) +++ trunk/src/libgpgme.vers 2010-01-05 17:36:53 UTC (rev 1444) @@ -76,6 +76,9 @@ gpgme_key_from_uid; gpgme_set_sub_protocol; gpgme_get_sub_protocol; + + gpgme_op_passwd_start; + gpgme_op_passwd; }; Added: trunk/src/passwd.c =================================================================== --- trunk/src/passwd.c (rev 0) +++ trunk/src/passwd.c 2010-01-05 17:36:53 UTC (rev 1444) @@ -0,0 +1,95 @@ +/* passwd.c - Passphrase changing function + Copyright (C) 2010 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 . + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include "gpgme.h" +#include "debug.h" +#include "context.h" +#include "ops.h" + + +static gpgme_error_t +passwd_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + (void)priv; + (void)code; + (void)args; + return 0; +} + + +static gpgme_error_t +passwd_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t key, + unsigned int flags) +{ + gpgme_error_t err; + + if (!key) + return gpg_error (GPG_ERR_INV_VALUE); + if (flags) + return gpg_error (GPG_ERR_INV_FLAG); + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, passwd_status_handler, ctx); + + return _gpgme_engine_op_passwd (ctx->engine, key, flags); +} + + + +/* Change the passphrase for KEY. FLAGS is reserved for future use + and must be passed as 0. The engine is expected to present a user + interface to enter the old and the new passphrase. This is the + asynchronous variant. + + Note that if ever the need arises to supply a passphrase we can do + this with a flag value and the passphrase callback feature. */ +gpgme_error_t +gpgme_op_passwd_start (gpgme_ctx_t ctx, gpgme_key_t key, unsigned int flags) +{ + gpg_error_t err; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_passwd_start", ctx, + "key=%p, flags=0x%x", key, flags); + err = passwd_start (ctx, 0, key, flags); + return TRACE_ERR (err); +} + + +/* Change the passphrase for KEY. FLAGS is reserved for future use + and must be passed as 0. This is the synchronous variant. */ +gpgme_error_t +gpgme_op_passwd (gpgme_ctx_t ctx, gpgme_key_t key, unsigned int flags) +{ + gpgme_error_t err; + + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_passwd", ctx, + "key=%p, flags=0x%x", key, flags); + + err = passwd_start (ctx, 1, key, flags); + if (!err) + err = _gpgme_wait_one (ctx); + return TRACE_ERR (err); +} + From cvs at cvs.gnupg.org Thu Jan 7 19:16:54 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 07 Jan 2010 19:16:54 +0100 Subject: [svn] gpgme - r1445 - trunk/src Message-ID: Author: marcus Date: 2010-01-07 19:16:54 +0100 (Thu, 07 Jan 2010) New Revision: 1445 Modified: trunk/src/ChangeLog trunk/src/gpgme-tool.c Log: 2010-01-07 Marcus Brinkmann * gpgme-tool.c (result_xml_write_cb_t, struct result_xml_state): New types. (MAX_TAGS): New macro. (result_init, result_xml_indent, result_xml_tag_start) (result_xml_tag_data, result_xml_tag_end, result_add_error) (result_add_pubkey_algo, result_add_hash_algo, result_add_keyid) (result_add_fpr, result_add_timestamp, result_add_sig_mode) (result_add_value, result_add_string, result_encrypt_to_xml) (result_decrypt_to_xml, result_sign_to_xml) (result_verify_to_xml, result_import_to_xml) (result_genkey_to_xml, result_keylist_to_xml) (result_vfs_mount_to_xml): New functions. (gt_result): Rewritten. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-05 17:36:53 UTC (rev 1444) +++ trunk/src/ChangeLog 2010-01-07 18:16:54 UTC (rev 1445) @@ -1,3 +1,19 @@ +2010-01-07 Marcus Brinkmann + + * gpgme-tool.c (result_xml_write_cb_t, struct result_xml_state): + New types. + (MAX_TAGS): New macro. + (result_init, result_xml_indent, result_xml_tag_start) + (result_xml_tag_data, result_xml_tag_end, result_add_error) + (result_add_pubkey_algo, result_add_hash_algo, result_add_keyid) + (result_add_fpr, result_add_timestamp, result_add_sig_mode) + (result_add_value, result_add_string, result_encrypt_to_xml) + (result_decrypt_to_xml, result_sign_to_xml) + (result_verify_to_xml, result_import_to_xml) + (result_genkey_to_xml, result_keylist_to_xml) + (result_vfs_mount_to_xml): New functions. + (gt_result): Rewritten. + 2010-01-05 Werner Koch * gpgme-tool.c (gt_passwd, cmd_passwd): New. Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2010-01-05 17:36:53 UTC (rev 1444) +++ trunk/src/gpgme-tool.c 2010-01-07 18:16:54 UTC (rev 1445) @@ -498,6 +498,605 @@ +typedef gpg_error_t (*result_xml_write_cb_t) (void *hook, const void *buf, + size_t len); + +struct result_xml_state +{ + int indent; + result_xml_write_cb_t cb; + void *hook; + +#define MAX_TAGS 20 + int next_tag; + char *tag[MAX_TAGS]; + int had_data[MAX_TAGS]; +}; + + +void +result_init (struct result_xml_state *state, int indent, + result_xml_write_cb_t cb, void *hook) +{ + memset (state, '\0', sizeof (*state)); + state->indent = indent; + state->cb = cb; + state->hook = hook; +} + + +gpg_error_t +result_xml_indent (struct result_xml_state *state) +{ + char spaces[state->indent + 1]; + int i; + for (i = 0; i < state->indent; i++) + spaces[i] = ' '; + spaces[i] = '\0'; + return (*state->cb) (state->hook, spaces, i); +} + + +gpg_error_t +result_xml_tag_start (struct result_xml_state *state, char *name, ...) +{ + result_xml_write_cb_t cb = state->cb; + void *hook = state->hook; + va_list ap; + char *attr; + char *attr_val; + + va_start (ap, name); + + if (state->next_tag > 0) + { + if (! state->had_data[state->next_tag - 1]) + { + (*cb) (hook, ">\n", 2); + (*cb) (hook, NULL, 0); + } + state->had_data[state->next_tag - 1] = 1; + } + + result_xml_indent (state); + (*cb) (hook, "<", 1); + (*cb) (hook, name, strlen (name)); + + state->tag[state->next_tag] = name; + state->had_data[state->next_tag] = 0; + state->indent += 2; + state->next_tag++; + + while (1) + { + attr = va_arg (ap, char *); + if (attr == NULL) + break; + + attr_val = va_arg (ap, char *); + if (attr_val == NULL) + attr_val = "(null)"; + + (*cb) (hook, " ", 1); + (*cb) (hook, attr, strlen (attr)); + (*cb) (hook, "=\"", 2); + (*cb) (hook, attr_val, strlen (attr_val)); + (*cb) (hook, "\"", 1); + } + va_end (ap); + return 0; +} + + +gpg_error_t +result_xml_tag_data (struct result_xml_state *state, char *data) +{ + result_xml_write_cb_t cb = state->cb; + void *hook = state->hook; + + if (state->had_data[state->next_tag - 1]) + { + (*cb) (hook, "\n", 2); + (*cb) (hook, NULL, 0); + result_xml_indent (state); + } + else + (*cb) (hook, ">", 1); + state->had_data[state->next_tag - 1] = 2; + + (*cb) (hook, data, strlen (data)); + + return 0; +} + + +gpg_error_t +result_xml_tag_end (struct result_xml_state *state) +{ + result_xml_write_cb_t cb = state->cb; + void *hook = state->hook; + + state->next_tag--; + state->indent -= 2; + + if (state->had_data[state->next_tag]) + { + if (state->had_data[state->next_tag] == 1) + result_xml_indent (state); + (*cb) (hook, "tag[state->next_tag], + strlen (state->tag[state->next_tag])); + (*cb) (hook, ">\n", 2); + (*cb) (hook, NULL, 0); + } + else + { + (*cb) (hook, " />\n", 4); + (*cb) (hook, NULL, 0); + } + return 0; +} + + +gpg_error_t +result_add_error (struct result_xml_state *state, char *name, gpg_error_t err) +{ + char code[20]; + char msg[1024]; + snprintf (code, sizeof (code) - 1, "0x%x", err); + snprintf (msg, sizeof (msg) - 1, "%s <%s>", + gpg_strerror (err), gpg_strsource (err)); + result_xml_tag_start (state, name, "value", code, NULL); + result_xml_tag_data (state, msg); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_add_pubkey_algo (struct result_xml_state *state, + char *name, gpgme_pubkey_algo_t algo) +{ + char code[20]; + char msg[80]; + snprintf (code, sizeof (code) - 1, "0x%x", algo); + snprintf (msg, sizeof (msg) - 1, "%s", + gpgme_pubkey_algo_name (algo)); + result_xml_tag_start (state, name, "value", code, NULL); + result_xml_tag_data (state, msg); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_add_hash_algo (struct result_xml_state *state, + char *name, gpgme_hash_algo_t algo) +{ + char code[20]; + char msg[80]; + snprintf (code, sizeof (code) - 1, "0x%x", algo); + snprintf (msg, sizeof (msg) - 1, "%s", + gpgme_hash_algo_name (algo)); + result_xml_tag_start (state, name, "value", code, NULL); + result_xml_tag_data (state, msg); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_add_keyid (struct result_xml_state *state, char *name, char *keyid) +{ + result_xml_tag_start (state, name, NULL); + result_xml_tag_data (state, keyid); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_add_fpr (struct result_xml_state *state, char *name, char *fpr) +{ + result_xml_tag_start (state, name, NULL); + result_xml_tag_data (state, fpr); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_add_timestamp (struct result_xml_state *state, char *name, + unsigned int timestamp) +{ + char code[20]; + + snprintf (code, sizeof (code) - 1, "%ui", timestamp); + result_xml_tag_start (state, name, "unix", code); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_add_sig_mode (struct result_xml_state *state, char *name, + gpgme_sig_mode_t sig_mode) +{ + char *mode; + char code[20]; + + snprintf (code, sizeof (code) - 1, "%i", sig_mode); + switch (sig_mode) + { + case GPGME_SIG_MODE_NORMAL: + mode = "normal"; + break; + case GPGME_SIG_MODE_DETACH: + mode = "detach"; + break; + case GPGME_SIG_MODE_CLEAR: + mode = "clear"; + break; + default: + mode = "unknown"; + } + + result_xml_tag_start (state, name, "type", mode, "value", code, NULL); + result_xml_tag_data (state, mode); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_add_value (struct result_xml_state *state, + char *name, unsigned int val) +{ + char code[20]; + + snprintf (code, sizeof (code) - 1, "0x%x", val); + result_xml_tag_start (state, name, "value", code, NULL); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_add_string (struct result_xml_state *state, + char *name, char *str) +{ + result_xml_tag_start (state, name, NULL); + result_xml_tag_data (state, str); + result_xml_tag_end (state); + return 0; +} + + +gpg_error_t +result_encrypt_to_xml (gpgme_ctx_t ctx, int indent, + result_xml_write_cb_t cb, void *hook) +{ + struct result_xml_state state; + gpgme_encrypt_result_t res = gpgme_op_encrypt_result (ctx); + gpgme_invalid_key_t inv_recp; + + if (! res) + return 0; + + result_init (&state, indent, cb, hook); + result_xml_tag_start (&state, "encrypt-result", NULL); + + inv_recp = res->invalid_recipients; + if (inv_recp) + { + result_xml_tag_start (&state, "invalid-recipients", NULL); + + while (inv_recp) + { + result_xml_tag_start (&state, "invalid-key", NULL); + result_add_fpr (&state, "fpr", inv_recp->fpr); + result_add_error (&state, "reason", inv_recp->reason); + result_xml_tag_end (&state); + inv_recp = inv_recp->next; + } + result_xml_tag_end (&state); + } + result_xml_tag_end (&state); + + return 0; +} + + +gpg_error_t +result_decrypt_to_xml (gpgme_ctx_t ctx, int indent, + result_xml_write_cb_t cb, void *hook) +{ + struct result_xml_state state; + gpgme_decrypt_result_t res = gpgme_op_decrypt_result (ctx); + gpgme_recipient_t recp; + + if (! res) + return 0; + + result_init (&state, indent, cb, hook); + result_xml_tag_start (&state, "decrypt-result", NULL); + + if (res->file_name) + { + result_xml_tag_start (&state, "file-name", NULL); + result_xml_tag_data (&state, res->file_name); + result_xml_tag_end (&state); + } + if (res->unsupported_algorithm) + { + result_xml_tag_start (&state, "unsupported-alogorithm", NULL); + result_xml_tag_data (&state, res->unsupported_algorithm); + result_xml_tag_end (&state); + } + if (res->wrong_key_usage) + { + result_xml_tag_start (&state, "wrong-key-usage", NULL); + result_xml_tag_end (&state); + } + + recp = res->recipients; + if (recp) + { + result_xml_tag_start (&state, "recipients", NULL); + while (recp) + { + result_xml_tag_start (&state, "recipient", NULL); + result_add_keyid (&state, "keyid", recp->keyid); + result_add_pubkey_algo (&state, "pubkey-algo", recp->pubkey_algo); + result_add_error (&state, "status", recp->status); + result_xml_tag_end (&state); + recp = recp->next; + } + result_xml_tag_end (&state); + } + result_xml_tag_end (&state); + + return 0; +} + + +gpg_error_t +result_sign_to_xml (gpgme_ctx_t ctx, int indent, + result_xml_write_cb_t cb, void *hook) +{ + struct result_xml_state state; + gpgme_sign_result_t res = gpgme_op_sign_result (ctx); + gpgme_invalid_key_t inv_key; + gpgme_new_signature_t new_sig; + + if (! res) + return 0; + + result_init (&state, indent, cb, hook); + result_xml_tag_start (&state, "sign-result", NULL); + + inv_key = res->invalid_signers; + if (inv_key) + { + result_xml_tag_start (&state, "invalid-signers", NULL); + + while (inv_key) + { + result_xml_tag_start (&state, "invalid-key", NULL); + result_add_fpr (&state, "fpr", inv_key->fpr); + result_add_error (&state, "reason", inv_key->reason); + result_xml_tag_end (&state); + inv_key = inv_key->next; + } + result_xml_tag_end (&state); + } + + new_sig = res->signatures; + if (new_sig) + { + result_xml_tag_start (&state, "signatures", NULL); + + while (new_sig) + { + result_xml_tag_start (&state, "new-signature", NULL); + result_add_sig_mode (&state, "type", new_sig->type); + result_add_pubkey_algo (&state, "pubkey-algo", new_sig->pubkey_algo); + result_add_hash_algo (&state, "hash-algo", new_sig->hash_algo); + result_add_timestamp (&state, "timestamp", new_sig->timestamp); + result_add_fpr (&state, "fpr", new_sig->fpr); + result_add_value (&state, "sig-class", new_sig->sig_class); + + result_xml_tag_end (&state); + new_sig = new_sig->next; + } + result_xml_tag_end (&state); + } + + result_xml_tag_end (&state); + + return 0; +} + + +gpg_error_t +result_verify_to_xml (gpgme_ctx_t ctx, int indent, + result_xml_write_cb_t cb, void *hook) +{ + struct result_xml_state state; + gpgme_verify_result_t res = gpgme_op_verify_result (ctx); + gpgme_signature_t sig; + + if (! res) + return 0; + + result_init (&state, indent, cb, hook); + result_xml_tag_start (&state, "verify-result", NULL); + + if (res->file_name) + { + result_xml_tag_start (&state, "file-name", NULL); + result_xml_tag_data (&state, res->file_name); + result_xml_tag_end (&state); + } + + sig = res->signatures; + if (sig) + { + result_xml_tag_start (&state, "signatures", NULL); + + while (sig) + { + result_xml_tag_start (&state, "signature", NULL); + + // FIXME: Could be done better. + result_add_value (&state, "summary", sig->summary); + result_add_fpr (&state, "fpr", sig->fpr); + result_add_error (&state, "status", sig->status); + // FIXME: notations + result_add_timestamp (&state, "timestamp", sig->timestamp); + result_add_timestamp (&state, "exp-timestamp", sig->exp_timestamp); + result_add_value (&state, "wrong-key-usage", sig->wrong_key_usage); + result_add_value (&state, "pka-trust", sig->pka_trust); + result_add_value (&state, "chain-model", sig->chain_model); + result_add_value (&state, "validity", sig->validity); + result_add_error (&state, "validity-reason", sig->validity_reason); + result_add_pubkey_algo (&state, "pubkey-algo", sig->pubkey_algo); + result_add_hash_algo (&state, "hash-algo", sig->hash_algo); + if (sig->pka_address) + result_add_string (&state, "pka_address", sig->pka_address); + + result_xml_tag_end (&state); + sig = sig->next; + } + result_xml_tag_end (&state); + } + + result_xml_tag_end (&state); + + return 0; +} + + +gpg_error_t +result_import_to_xml (gpgme_ctx_t ctx, int indent, + result_xml_write_cb_t cb, void *hook) +{ + struct result_xml_state state; + gpgme_import_result_t res = gpgme_op_import_result (ctx); + gpgme_import_status_t stat; + + if (! res) + return 0; + + result_init (&state, indent, cb, hook); + result_xml_tag_start (&state, "import-result", NULL); + + result_add_value (&state, "considered", res->considered); + result_add_value (&state, "no-user-id", res->no_user_id); + result_add_value (&state, "imported", res->imported); + result_add_value (&state, "imported-rsa", res->imported_rsa); + result_add_value (&state, "unchanged", res->unchanged); + result_add_value (&state, "new-user-ids", res->new_user_ids); + result_add_value (&state, "new-sub-keys", res->new_sub_keys); + result_add_value (&state, "new-signatures", res->new_signatures); + result_add_value (&state, "new-revocations", res->new_revocations); + result_add_value (&state, "secret-read", res->secret_read); + result_add_value (&state, "secret-imported", res->secret_imported); + result_add_value (&state, "secret-unchanged", res->secret_unchanged); + result_add_value (&state, "skipped-new-keys", res->skipped_new_keys); + result_add_value (&state, "not-imported", res->not_imported); + + stat = res->imports; + if (stat) + { + result_xml_tag_start (&state, "imports", NULL); + + while (stat) + { + result_xml_tag_start (&state, "import-status", NULL); + + result_add_fpr (&state, "fpr", stat->fpr); + result_add_error (&state, "result", stat->result); + // FIXME: Could be done better. + result_add_value (&state, "status", stat->status); + + result_xml_tag_end (&state); + stat = stat->next; + } + result_xml_tag_end (&state); + } + + result_xml_tag_end (&state); + + return 0; +} + + +gpg_error_t +result_genkey_to_xml (gpgme_ctx_t ctx, int indent, + result_xml_write_cb_t cb, void *hook) +{ + struct result_xml_state state; + gpgme_genkey_result_t res = gpgme_op_genkey_result (ctx); + + if (! res) + return 0; + + result_init (&state, indent, cb, hook); + result_xml_tag_start (&state, "genkey-result", NULL); + + result_add_value (&state, "primary", res->primary); + result_add_value (&state, "sub", res->sub); + result_add_fpr (&state, "fpr", res->fpr); + + result_xml_tag_end (&state); + + return 0; +} + + +gpg_error_t +result_keylist_to_xml (gpgme_ctx_t ctx, int indent, + result_xml_write_cb_t cb, void *hook) +{ + struct result_xml_state state; + gpgme_keylist_result_t res = gpgme_op_keylist_result (ctx); + + if (! res) + return 0; + + result_init (&state, indent, cb, hook); + result_xml_tag_start (&state, "keylist-result", NULL); + + result_add_value (&state, "truncated", res->truncated); + + result_xml_tag_end (&state); + + return 0; +} + + +gpg_error_t +result_vfs_mount_to_xml (gpgme_ctx_t ctx, int indent, + result_xml_write_cb_t cb, void *hook) +{ + struct result_xml_state state; + gpgme_vfs_mount_result_t res = gpgme_op_vfs_mount_result (ctx); + + if (! res) + return 0; + + result_init (&state, indent, cb, hook); + result_xml_tag_start (&state, "vfs-mount-result", NULL); + + result_add_string (&state, "mount-dir", res->mount_dir); + + result_xml_tag_end (&state); + + return 0; +} + + typedef enum status { STATUS_PROTOCOL, @@ -769,7 +1368,7 @@ gpg_error_t -gt_write_data (gpgme_tool_t gt, void *buf, size_t len) +gt_write_data (gpgme_tool_t gt, const void *buf, size_t len) { return gt->write_data (gt->write_data_hook, buf, len); } @@ -968,9 +1567,9 @@ gpg_error_t err; if (sign) + err = gpgme_op_encrypt_sign (gt->ctx, gt->recipients, flags, plain, cipher); + else err = gpgme_op_encrypt (gt->ctx, gt->recipients, flags, plain, cipher); - else - err = gpgme_op_encrypt_sign (gt->ctx, gt->recipients, flags, plain, cipher); gt_recipients_clear (gt); @@ -1138,9 +1737,6 @@ } - - -/* TODO */ #define GT_RESULT_ENCRYPT 0x1 #define GT_RESULT_DECRYPT 0x2 #define GT_RESULT_SIGN 0x4 @@ -1154,31 +1750,41 @@ gpg_error_t gt_result (gpgme_tool_t gt, unsigned int flags) { + static const char xml_preamble1[] = "\n"; + static const char xml_preamble2[] = "\n"; + static const char xml_end[] = "\n"; + int indent = 2; + + gt_write_data (gt, xml_preamble1, sizeof (xml_preamble1)); + gt_write_data (gt, NULL, 0); + gt_write_data (gt, xml_preamble2, sizeof (xml_preamble2)); + gt_write_data (gt, NULL, 0); if (flags & GT_RESULT_ENCRYPT) - { - gpgme_encrypt_result_t res = gpgme_op_encrypt_result (gt->ctx); - if (res) - { - gpgme_invalid_key_t invrec = res->invalid_recipients; - while (invrec) - { - gt_write_status (gt, STATUS_ENCRYPT_RESULT, "invalid_recipient", - invrec->fpr, invrec->reason, NULL); - invrec = invrec->next; - } - } - } + result_encrypt_to_xml (gt->ctx, indent, + (result_xml_write_cb_t) gt_write_data, gt); + if (flags & GT_RESULT_DECRYPT) + result_decrypt_to_xml (gt->ctx, indent, + (result_xml_write_cb_t) gt_write_data, gt); + if (flags & GT_RESULT_SIGN) + result_sign_to_xml (gt->ctx, indent, + (result_xml_write_cb_t) gt_write_data, gt); + if (flags & GT_RESULT_VERIFY) + result_verify_to_xml (gt->ctx, indent, + (result_xml_write_cb_t) gt_write_data, gt); + if (flags & GT_RESULT_IMPORT) + result_import_to_xml (gt->ctx, indent, + (result_xml_write_cb_t) gt_write_data, gt); + if (flags & GT_RESULT_GENKEY) + result_genkey_to_xml (gt->ctx, indent, + (result_xml_write_cb_t) gt_write_data, gt); + if (flags & GT_RESULT_KEYLIST) + result_keylist_to_xml (gt->ctx, indent, + (result_xml_write_cb_t) gt_write_data, gt); if (flags & GT_RESULT_VFS_MOUNT) - { - gpgme_vfs_mount_result_t res = gpgme_op_vfs_mount_result (gt->ctx); - if (res) - { - gt_write_data (gt, "vfs_mount\n", 10); - gt_write_data (gt, "mount_dir:", 10); - gt_write_data (gt, res->mount_dir, strlen (res->mount_dir)); - gt_write_data (gt, "\n", 1); - } - } + result_vfs_mount_to_xml (gt->ctx, indent, + (result_xml_write_cb_t) gt_write_data, gt); + gt_write_data (gt, xml_end, sizeof (xml_end)); return 0; } From cvs at cvs.gnupg.org Fri Jan 8 03:54:06 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 08 Jan 2010 03:54:06 +0100 Subject: [svn] assuan - r343 - trunk Message-ID: Author: marcus Date: 2010-01-08 03:54:06 +0100 (Fri, 08 Jan 2010) New Revision: 343 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: Pre-release fixup. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-05 05:05:16 UTC (rev 342) +++ trunk/ChangeLog 2010-01-08 02:54:06 UTC (rev 343) @@ -1,3 +1,7 @@ +2010-01-08 Marcus Brinkmann + + Released 2.0.0. + 2010-01-05 Marcus Brinkmann * configure.ac (_DARWIN_C_SOURCE): Define on frapple. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-05 05:05:16 UTC (rev 342) +++ trunk/NEWS 2010-01-08 02:54:06 UTC (rev 343) @@ -1,7 +1,7 @@ -Noteworthy changes in version 2.0.0 (unreleased) +Noteworthy changes in version 2.0.0 (2009-01-08) ------------------------------------------------ - * Now using libtool and builds a DSO. + * Now using libtool and builds a DSO. * Lots of interface cleanups. See below for details of the most important changes. Here is a quick note on how to upgrade: Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-05 05:05:16 UTC (rev 342) +++ trunk/configure.ac 2010-01-08 02:54:06 UTC (rev 343) @@ -25,7 +25,7 @@ # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. m4_define([my_version], [2.0.0]) -m4_define([my_issvn], [yes]) +m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Fri Jan 8 04:11:22 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 08 Jan 2010 04:11:22 +0100 Subject: [svn] assuan - r344 - branches Message-ID: Author: marcus Date: 2010-01-08 04:11:22 +0100 (Fri, 08 Jan 2010) New Revision: 344 Added: branches/libassuan-2.0.0/ Log: Release tag. From cvs at cvs.gnupg.org Fri Jan 8 04:11:54 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 08 Jan 2010 04:11:54 +0100 Subject: [svn] assuan - r345 - trunk Message-ID: Author: marcus Date: 2010-01-08 04:11:54 +0100 (Fri, 08 Jan 2010) New Revision: 345 Modified: trunk/configure.ac Log: Post release fixup. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-08 03:11:22 UTC (rev 344) +++ trunk/configure.ac 2010-01-08 03:11:54 UTC (rev 345) @@ -24,8 +24,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [2.0.0]) -m4_define([my_issvn], [no]) +m4_define([my_version], [2.0.1]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Fri Jan 8 10:59:54 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 08 Jan 2010 10:59:54 +0100 Subject: [svn] assuan - r346 - tags Message-ID: Author: wk Date: 2010-01-08 10:59:54 +0100 (Fri, 08 Jan 2010) New Revision: 346 Added: tags/libassuan-2.0.0/ Log: Also ad a release tag From cvs at cvs.gnupg.org Fri Jan 8 16:36:10 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 08 Jan 2010 16:36:10 +0100 Subject: [svn] GpgEX - r75 - trunk/src Message-ID: Author: marcus Date: 2010-01-08 16:36:10 +0100 (Fri, 08 Jan 2010) New Revision: 75 Modified: trunk/src/ChangeLog trunk/src/icon-lock-12.bmp trunk/src/icon-lock-16.bmp Log: 2010-01-08 Marcus Brinkmann * icon-lock-12.bmp, icon-lock-16.bmp: Update. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-12-26 15:34:51 UTC (rev 74) +++ trunk/src/ChangeLog 2010-01-08 15:36:10 UTC (rev 75) @@ -1,3 +1,7 @@ +2010-01-08 Marcus Brinkmann + + * icon-lock-12.bmp, icon-lock-16.bmp: Update. + 2009-12-26 Marcus Brinkmann * icon-lock-12.bmp, icon-lock-16.bmp: New files. Modified: trunk/src/icon-lock-12.bmp =================================================================== (Binary files differ) Modified: trunk/src/icon-lock-16.bmp =================================================================== (Binary files differ) From cvs at cvs.gnupg.org Fri Jan 8 16:36:24 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 08 Jan 2010 16:36:24 +0100 Subject: [svn] GpgEX - r76 - trunk Message-ID: Author: marcus Date: 2010-01-08 16:36:24 +0100 (Fri, 08 Jan 2010) New Revision: 76 Modified: trunk/ChangeLog trunk/configure.ac Log: Pre-release fixup. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-08 15:36:10 UTC (rev 75) +++ trunk/ChangeLog 2010-01-08 15:36:24 UTC (rev 76) @@ -1,3 +1,7 @@ +2010-01-08 Marcus Brinkmann + + * Release 0.9.5. + 2009-12-26 Marcus Brinkmann * Release 0.9.4. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-08 15:36:10 UTC (rev 75) +++ trunk/configure.ac 2010-01-08 15:36:24 UTC (rev 76) @@ -16,7 +16,7 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [0.9.4]) +m4_define([my_version], [0.9.5]) m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ From cvs at cvs.gnupg.org Fri Jan 8 16:43:30 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 08 Jan 2010 16:43:30 +0100 Subject: [svn] GpgEX - r77 - trunk Message-ID: Author: marcus Date: 2010-01-08 16:43:30 +0100 (Fri, 08 Jan 2010) New Revision: 77 Modified: trunk/NEWS Log: For release. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-08 15:36:24 UTC (rev 76) +++ trunk/NEWS 2010-01-08 15:43:30 UTC (rev 77) @@ -1,3 +1,9 @@ +Noteworthy changes for version 0.9.5 (2010-01-08) +------------------------------------------------- + +* Fixed icon. + + Noteworthy changes for version 0.9.4 (2009-12-26) ------------------------------------------------- From cvs at cvs.gnupg.org Fri Jan 8 16:44:03 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 08 Jan 2010 16:44:03 +0100 Subject: [svn] GpgOL - r330 - in trunk: . forms src Message-ID: Author: wk Date: 2010-01-08 16:44:03 +0100 (Fri, 08 Jan 2010) New Revision: 330 Modified: trunk/ChangeLog trunk/forms/encr-s.ico trunk/forms/sign-s.ico trunk/src/ChangeLog trunk/src/README.icons Log: Fix forms icons Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-05 10:43:02 UTC (rev 329) +++ trunk/ChangeLog 2010-01-08 15:44:03 UTC (rev 330) @@ -1,6 +1,10 @@ +2010-01-08 Werner Koch + + * forms/encr-s.ico, forms/sign-s.ico: Fix them. + 2010-01-05 Werner Koch - Release 1.1.0. + Release 1.1.0. 2009-12-22 Werner Koch Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-05 10:43:02 UTC (rev 329) +++ trunk/src/ChangeLog 2010-01-08 15:44:03 UTC (rev 330) @@ -1,3 +1,7 @@ +2010-01-08 Werner Koch + + * README.icons: Fix instructions for forms icons. + 2009-12-22 Werner Koch * key-manager-16.bmp, key-manager-16m.bmp: Update. Modified: trunk/forms/encr-s.ico =================================================================== (Binary files differ) Modified: trunk/forms/sign-s.ico =================================================================== (Binary files differ) Modified: trunk/src/README.icons =================================================================== --- trunk/src/README.icons 2010-01-05 10:43:02 UTC (rev 329) +++ trunk/src/README.icons 2010-01-08 15:44:03 UTC (rev 330) @@ -89,7 +89,7 @@ 1. Load a 16x16 PNG version of the icon into The Gimp. 2. Select Image->Canvas_Size and enter a size of 32x32 pixel. Keep - offset at (0,0), don't use resize layers, click on "Resize". + offset at (0,0), select "Resize layers: All layers", click on "Resize". 3. Select File->SaveAs and enter a file name with the suffix ".ico". Click "Save" and you will be asked for the type. From the From cvs at cvs.gnupg.org Fri Jan 8 20:15:06 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 08 Jan 2010 20:15:06 +0100 Subject: [svn] gpgme - r1446 - in trunk: doc src Message-ID: Author: wk Date: 2010-01-08 20:15:06 +0100 (Fri, 08 Jan 2010) New Revision: 1446 Modified: trunk/doc/gpgme.texi trunk/src/ChangeLog trunk/src/context.h trunk/src/engine-gpg.c trunk/src/engine-gpgsm.c trunk/src/gpgme-tool.c trunk/src/passwd.c Log: Support gpgme_op_apsswd for GPG. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-07 18:16:54 UTC (rev 1445) +++ trunk/src/ChangeLog 2010-01-08 19:15:06 UTC (rev 1446) @@ -1,3 +1,10 @@ +2010-01-08 Werner Koch + + * engine-gpg.c (gpg_passwd): New. + (_gpgme_engine_ops_gpg): Register. + * passwd.c (parse_error): New. + (passwd_status_handler): Use it. + 2010-01-07 Marcus Brinkmann * gpgme-tool.c (result_xml_write_cb_t, struct result_xml_state): Modified: trunk/doc/gpgme.texi =================================================================== --- trunk/doc/gpgme.texi 2010-01-07 18:16:54 UTC (rev 1445) +++ trunk/doc/gpgme.texi 2010-01-08 19:15:06 UTC (rev 1446) @@ -3744,6 +3744,9 @@ to ask for the old and the new passphrase. Thus this function is not useful in a server application (where passphrases are not required anyway). + +Note that old @code{gpg} engines (before version 2.0.15) do not support +this comamnd and will silently ignore it. @end deftypefun @deftypefun gpgme_error_t gpgme_op_passwd_start @ Modified: trunk/src/context.h =================================================================== --- trunk/src/context.h 2010-01-07 18:16:54 UTC (rev 1445) +++ trunk/src/context.h 2010-01-08 19:15:06 UTC (rev 1446) @@ -1,6 +1,6 @@ /* context.h - Definitions for a GPGME context. Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2010 g10 Code GmbH This file is part of GPGME. @@ -15,9 +15,8 @@ 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. */ + License along with this program; if not, see . + */ #ifndef CONTEXT_H #define CONTEXT_H Modified: trunk/src/engine-gpg.c =================================================================== --- trunk/src/engine-gpg.c 2010-01-07 18:16:54 UTC (rev 1445) +++ trunk/src/engine-gpg.c 2010-01-08 19:15:06 UTC (rev 1446) @@ -1,7 +1,7 @@ /* engine-gpg.c - Gpg Engine. Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2009 g10 Code GmbH + 2009, 2010 g10 Code GmbH This file is part of GPGME. @@ -1437,6 +1437,24 @@ static gpgme_error_t +gpg_passwd (void *engine, gpgme_key_t key, unsigned int flags) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + if (!key || !key->subkeys || !key->subkeys->fpr) + return gpg_error (GPG_ERR_INV_CERT_OBJ); + + err = add_arg (gpg, "--passwd"); + if (!err) + err = add_arg (gpg, key->subkeys->fpr); + if (!err) + start (gpg); + return err; +} + + +static gpgme_error_t append_args_from_signers (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */) { gpgme_error_t err = 0; @@ -2370,5 +2388,6 @@ gpg_set_io_cbs, gpg_io_event, gpg_cancel, - NULL /* cancel_op */ + NULL, /* cancel_op */ + gpg_passwd }; Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2010-01-07 18:16:54 UTC (rev 1445) +++ trunk/src/engine-gpgsm.c 2010-01-08 19:15:06 UTC (rev 1446) @@ -1908,7 +1908,7 @@ char *line; if (!key || !key->subkeys || !key->subkeys->fpr) - return gpg_error (GPG_ERR_INV_VALUE); + return gpg_error (GPG_ERR_INV_CERT_OBJ); if (asprintf (&line, "PASSWD -- %s", key->subkeys->fpr) < 0) return gpg_error_from_syserror (); Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2010-01-07 18:16:54 UTC (rev 1445) +++ trunk/src/gpgme-tool.c 2010-01-08 19:15:06 UTC (rev 1446) @@ -1729,7 +1729,7 @@ err = gpgme_get_key (gt->ctx, fpr, &key, 0); if (err) - return err; + return gpg_err_code (err) == GPG_ERR_EOF? gpg_error (GPG_ERR_NO_PUBKEY):err; err = gpgme_op_passwd (gt->ctx, key, 0); gpgme_key_unref (key); Modified: trunk/src/passwd.c =================================================================== --- trunk/src/passwd.c 2010-01-07 18:16:54 UTC (rev 1445) +++ trunk/src/passwd.c 2010-01-08 19:15:06 UTC (rev 1446) @@ -20,6 +20,7 @@ #if HAVE_CONFIG_H #include #endif +#include #include "gpgme.h" #include "debug.h" @@ -27,17 +28,60 @@ #include "ops.h" +/* Parse an error status line and return the error code. */ static gpgme_error_t -passwd_status_handler (void *priv, gpgme_status_code_t code, char *args) +parse_error (char *args) { - (void)priv; - (void)code; - (void)args; + gpgme_error_t err; + char *where = strchr (args, ' '); + char *which; + + if (where) + { + *where = '\0'; + which = where + 1; + + where = strchr (which, ' '); + if (where) + *where = '\0'; + + where = args; + } + else + return gpg_error (GPG_ERR_INV_ENGINE); + + err = atoi (which); + + if (!strcmp (where, "keyedit.passwd")) + return err; + return 0; } static gpgme_error_t +passwd_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err = 0; + + (void)ctx; + + switch (code) + { + case GPGME_STATUS_ERROR: + err = parse_error (args); + break; + + default: + break; + } + + return err; +} + + +static gpgme_error_t passwd_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t key, unsigned int flags) { From cvs at cvs.gnupg.org Fri Jan 8 20:18:50 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 08 Jan 2010 20:18:50 +0100 Subject: [svn] GnuPG - r5247 - in trunk: . agent common doc g10 jnlib scd tests/openpgp Message-ID: Author: wk Date: 2010-01-08 20:18:49 +0100 (Fri, 08 Jan 2010) New Revision: 5247 Modified: trunk/README.maint trunk/agent/ChangeLog trunk/agent/command.c trunk/agent/divert-scd.c trunk/agent/minip12.c trunk/common/estream.c trunk/doc/DETAILS trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/g10/call-agent.h trunk/g10/card-util.c trunk/g10/cpr.c trunk/g10/gpg.c trunk/g10/keydb.h trunk/g10/keyedit.c trunk/g10/keygen.c trunk/g10/main.h trunk/g10/mainproc.c trunk/g10/options.h trunk/g10/passphrase.c trunk/g10/trustdb.c trunk/jnlib/argparse.c trunk/scd/app-p15.c trunk/scd/ccid-driver.c trunk/tests/openpgp/ChangeLog trunk/tests/openpgp/Makefile.am Log: Add dummu option --passwd for gpg. Collected changes. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/agent/ChangeLog 2010-01-08 19:18:49 UTC (rev 5247) @@ -1,3 +1,7 @@ +2009-12-21 Werner Koch + + * command.c (cmd_getinfo): Add sub-command s2k_count. + 2009-12-14 Werner Koch * protect.c (agent_unprotect): Decode the S2K count here and take Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/ChangeLog 2010-01-08 19:18:49 UTC (rev 5247) @@ -1,3 +1,29 @@ +2010-01-08 Werner Koch + + * cpr.c (write_status_error): Rename to write_status_errcode. + Change all callers. + (write_status_error): New. + + * gpg.c: Add option --passwd. + (aPasswd): New. + (main): Implement. + * keyedit.c (keyedit_passwd): New. + + * gpg.c (oPasswd, oPasswdFD, oPasswdFile, oPasswdRepeat): Change + to oPassphrase, oPassphraseFD, oPassphraseFile, oPassphraseRepeat. + * options.h (struct): s/passwd_repeat/passphrase_repeat/. + * gpg.c (main): Ditto. + * passphrase.c (passphrase_to_dek_ext): Ditto. + +2009-12-21 Werner Koch + + * call-agent.c (agent_get_s2k_count): New. + * gpg.c (main): Set s2k_count to 0. + * (encode_s2k_iterations): Move ... + * passphrase.c (encode_s2k_iterations): ... here. Call + agent_get_s2k_count if called with a 0 arg. + (passphrase_to_dek_ext): Set S2K_COUNT via encode_s2k_iterations. + 2009-12-17 Werner Koch * sig-check.c (do_check_messages): Evaluate the HAS_EXPIRED flag. Modified: trunk/tests/openpgp/ChangeLog =================================================================== --- trunk/tests/openpgp/ChangeLog 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/tests/openpgp/ChangeLog 2010-01-08 19:18:49 UTC (rev 5247) @@ -1,3 +1,8 @@ +2009-12-21 Werner Koch + + * Makefile.am (required_pgms): New. + (./gpg_dearmor): Depend on them. + 2009-06-05 David Shaw * defs.inc: Improved all_cipher_algos and all_hash_algos to work Modified: trunk/README.maint =================================================================== --- trunk/README.maint 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/README.maint 2010-01-08 19:18:49 UTC (rev 5247) @@ -26,7 +26,7 @@ * Run "make -C po update-po". * Write NEWS entries and set the release date in NEWS. * In configure.ac set "my_issvn" to "no". - * Put a "Released " line into the top level ChangeLog. + * Put a "Release " line into the top level ChangeLog. * Commit all changes to the SVN. * Update the SVN then (to sync the release number of all files). * Run "./autogen.sh --force" Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/agent/command.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1637,6 +1637,7 @@ " socket_name - Return the name of the socket.\n" " ssh_socket_name - Return the name of the ssh socket.\n" " scd_running - Return OK if the SCdaemon is already running.\n" + " s2k_count - Return the calibrated S2K count.\n" " cmd_has_option\n" " - Returns OK if the command CMD implements the option OPT."; static gpg_error_t @@ -1678,6 +1679,13 @@ { rc = agent_scd_check_running ()? 0 : gpg_error (GPG_ERR_GENERAL); } + else if (!strcmp (line, "s2k_count")) + { + char numbuf[50]; + + snprintf (numbuf, sizeof numbuf, "%lu", get_standard_s2k_count ()); + rc = assuan_send_data (ctx, numbuf, strlen (numbuf)); + } else if (!strncmp (line, "cmd_has_option", 14) && (line[14] == ' ' || line[14] == '\t' || !line[14])) { Modified: trunk/agent/divert-scd.c =================================================================== --- trunk/agent/divert-scd.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/agent/divert-scd.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -80,7 +80,7 @@ } else { - log_error ("error accesing card: %s\n", gpg_strerror (rc)); + log_error ("error accessing card: %s\n", gpg_strerror (rc)); } if (!rc) Modified: trunk/agent/minip12.c =================================================================== --- trunk/agent/minip12.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/agent/minip12.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1698,7 +1698,7 @@ } if (i != 8) { - log_error ("invalid paramters for p12_build\n"); + log_error ("invalid parameters for p12_build\n"); return NULL; } /* Now this all goes into a sequence. */ Modified: trunk/common/estream.c =================================================================== --- trunk/common/estream.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/common/estream.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1423,7 +1423,7 @@ } /* Try to unread DATA_N bytes from DATA into STREAM, storing the - amount of bytes succesfully unread in *BYTES_UNREAD. */ + amount of bytes successfully unread in *BYTES_UNREAD. */ static void es_unreadn (estream_t ES__RESTRICT stream, const unsigned char *ES__RESTRICT data, size_t data_n, Modified: trunk/doc/DETAILS =================================================================== --- trunk/doc/DETAILS 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/doc/DETAILS 2010-01-08 19:18:49 UTC (rev 5247) @@ -730,7 +730,9 @@ pubkey: the third field contains the public key algorithmdcaiphers this version of GnuPG supports, separated by semicolons. The - algorithm numbers are as specified in RFC-4880. + algorithm numbers are as specified in RFC-4880. Note that in + contrast to the --status-fd interface these are _not_ the + Libgcrypt identifiers. cfg:pubkey:1;2;3;16;17 Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/call-agent.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1254,3 +1254,38 @@ } +/* Return the S2K iteration count as computed by gpg-agent. */ +gpg_error_t +agent_get_s2k_count (unsigned long *r_count) +{ + gpg_error_t err; + membuf_t data; + char *buf; + + *r_count = 0; + + err = start_agent (0); + if (err) + return err; + + init_membuf (&data, 32); + err = assuan_transact (agent_ctx, "GETINFO s2k_count", + membuf_data_cb, &data, + NULL, NULL, NULL, NULL); + if (err) + xfree (get_membuf (&data, NULL)); + else + { + put_membuf (&data, "", 1); + buf = get_membuf (&data, NULL); + if (!buf) + err = gpg_error_from_syserror (); + else + { + *r_count = strtoul (buf, NULL, 10); + xfree (buf); + } + } + return err; +} + Modified: trunk/g10/call-agent.h =================================================================== --- trunk/g10/call-agent.h 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/call-agent.h 2010-01-08 19:18:49 UTC (rev 5247) @@ -137,6 +137,9 @@ /* Present the prompt DESC and ask the user to confirm. */ gpg_error_t gpg_agent_get_confirmation (const char *desc); +/* Return the S2K iteration count as computed by gpg-agent. */ +gpg_error_t agent_get_s2k_count (unsigned long *r_count); + #endif /*GNUPG_G10_CALL_AGENT_H*/ Modified: trunk/g10/card-util.c =================================================================== --- trunk/g10/card-util.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/card-util.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -948,7 +948,7 @@ } else { - tty_printf ("usage error: redirectrion to file required\n"); + tty_printf ("usage error: redirection to file required\n"); return -1; } @@ -977,7 +977,7 @@ } else { - tty_printf ("usage error: redirectrion to file required\n"); + tty_printf ("usage error: redirection to file required\n"); return -1; } Modified: trunk/g10/cpr.c =================================================================== --- trunk/g10/cpr.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/cpr.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1,6 +1,6 @@ /* status.c - Status message and command-fd interface * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, - * 2004, 2005, 2006 Free Software Foundation, Inc. + * 2004, 2005, 2006, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -157,13 +157,28 @@ } +/* Wrte an ERROR status line using a full gpg-error error value. */ void -write_status_error (const char *where, int errcode) +write_status_error (const char *where, gpg_error_t err) { if (!statusfp || !status_currently_allowed (STATUS_ERROR)) return; /* Not enabled or allowed. */ fprintf (statusfp, "[GNUPG:] %s %s %u\n", + get_status_string (STATUS_ERROR), where, err); + if (fflush (statusfp) && opt.exit_on_status_write_error) + g10_exit (0); +} + + +/* Same as above but only putputs the error code. */ +void +write_status_errcode (const char *where, int errcode) +{ + if (!statusfp || !status_currently_allowed (STATUS_ERROR)) + return; /* Not enabled or allowed. */ + + fprintf (statusfp, "[GNUPG:] %s %s %u\n", get_status_string (STATUS_ERROR), where, gpg_err_code (errcode)); if (fflush (statusfp) && opt.exit_on_status_write_error) g10_exit (0); Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/gpg.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1,6 +1,6 @@ /* gpg.c - The GnuPG utility (main for gpg) * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - * 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + * 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -146,6 +146,7 @@ aCardStatus, aCardEdit, aChangePIN, + aPasswd, aServer, oTextmode, @@ -207,10 +208,10 @@ oCompressLevel, oBZ2CompressLevel, oBZ2DecompressLowmem, - oPasswd, - oPasswdFD, - oPasswdFile, - oPasswdRepeat, + oPassphrase, + oPassphraseFD, + oPassphraseFile, + oPassphraseRepeat, oCommandFD, oCommandFile, oQuickRandom, @@ -390,6 +391,7 @@ ARGPARSE_c (oFingerprint, "fingerprint", N_("list keys and fingerprints")), ARGPARSE_c (aListSecretKeys, "list-secret-keys", N_("list secret keys")), ARGPARSE_c (aKeygen, "gen-key", N_("generate a new key pair")), + ARGPARSE_c (aGenRevoke, "gen-revoke",N_("generate a revocation certificate")), ARGPARSE_c (aDeleteKeys,"delete-keys", N_("remove keys from the public keyring")), ARGPARSE_c (aDeleteSecretKeys, "delete-secret-keys", @@ -398,7 +400,7 @@ ARGPARSE_c (aLSignKey, "lsign-key" ,N_("sign a key locally")), ARGPARSE_c (aEditKey, "edit-key" ,N_("sign or edit a key")), ARGPARSE_c (aEditKey, "key-edit" ,"@"), - ARGPARSE_c (aGenRevoke, "gen-revoke",N_("generate a revocation certificate")), + ARGPARSE_c (aPasswd, "passwd", N_("change a passphrase")), ARGPARSE_c (aDesigRevoke, "desig-revoke","@" ), ARGPARSE_c (aExport, "export" , N_("export keys") ), ARGPARSE_c (aSendKeys, "send-keys" , N_("export keys to a key server") ), @@ -600,10 +602,10 @@ "delete-secret-and-public-keys", "@"), ARGPARSE_c (aRebuildKeydbCaches, "rebuild-keydb-caches", "@"), - ARGPARSE_s_s (oPasswd, "passphrase", "@"), - ARGPARSE_s_i (oPasswdFD, "passphrase-fd", "@"), - ARGPARSE_s_s (oPasswdFile, "passphrase-file", "@"), - ARGPARSE_s_i (oPasswdRepeat, "passphrase-repeat", "@"), + ARGPARSE_s_s (oPassphrase, "passphrase", "@"), + ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"), + ARGPARSE_s_s (oPassphraseFile, "passphrase-file", "@"), + ARGPARSE_s_i (oPassphraseRepeat,"passphrase-repeat", "@"), ARGPARSE_s_i (oCommandFD, "command-fd", "@"), ARGPARSE_s_s (oCommandFile, "command-file", "@"), ARGPARSE_s_n (oQuickRandom, "debug-quick-random", "@"), @@ -1431,6 +1433,7 @@ } +/* Print the OpenPGP defined algo numbers. */ static void print_algo_numbers(int (*checker)(int)) { @@ -1795,33 +1798,6 @@ } -/* Pack an s2k iteration count into the form specified in 2440. If - we're in between valid values, round up. */ -static unsigned char -encode_s2k_iterations(int iterations) -{ - unsigned char c=0,result; - unsigned int count; - - if(iterations<=1024) - return 0; - - if(iterations>=65011712) - return 255; - - /* Need count to be in the range 16-31 */ - for(count=iterations>>6;count>=32;count>>=1) - c++; - - result=(c<<4)|(count-16); - - if(S2K_DECODE_COUNT(result)")); + else + { + username = make_username (fname); + keyedit_passwd (username); + xfree (username); + } + break; + case aDeleteKeys: case aDeleteSecretKeys: case aDeleteSecretAndPublicKeys: Modified: trunk/g10/keydb.h =================================================================== --- trunk/g10/keydb.h 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/keydb.h 2010-01-08 19:18:49 UTC (rev 5247) @@ -173,6 +173,7 @@ int unlock, unsigned use ); /*-- passphrase.h --*/ +unsigned char encode_s2k_iterations (int iterations); assuan_context_t agent_open (int try, const char *orig_codeset); void agent_close (assuan_context_t ctx); int have_static_passphrase(void); Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/keyedit.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1,6 +1,6 @@ /* keyedit.c - keyedit stuff * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - * 2008, 2009 Free Software Foundation, Inc. + * 2008, 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -2326,6 +2326,19 @@ xfree(answer); } + +/* Change the passphrase of the secret key identified by USERNAME. */ +void +keyedit_passwd (const char *username) +{ + gpg_error_t err = gpg_error (GPG_ERR_BUG); /* Not yet implemented. */ + + log_info ("error changing the passphrase for `%s': %s\n", + username, gpg_strerror (err)); + write_status_error ("keyedit.passwd", err); +} + + static void tty_print_notations(int indent,PKT_signature *sig) { Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/keygen.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -3683,7 +3683,7 @@ log_error ("key generation failed: %s\n", g10_errstr(rc) ); else tty_printf (_("Key generation failed: %s\n"), g10_errstr(rc) ); - write_status_error (card? "card_key_generate":"key_generate", rc); + write_status_errcode (card? "card_key_generate":"key_generate", rc); print_status_key_not_created ( get_parameter_value (para, pHANDLE) ); } else @@ -4116,7 +4116,7 @@ log_error (_("storing key onto card failed: %s\n"), g10_errstr (rc)); free_secret_key (sk_unprotected); free_secret_key (sk_protected); - write_status_error ("save_key_to_card", rc); + write_status_errcode ("save_key_to_card", rc); return rc; } Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/main.h 2010-01-08 19:18:49 UTC (rev 5247) @@ -1,6 +1,6 @@ /* main.h * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - * 2008, 2009 Free Software Foundation, Inc. + * 2008, 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -156,7 +156,8 @@ void set_status_fd ( int fd ); int is_status_enabled ( void ); void write_status ( int no ); -void write_status_error (const char *where, int errcode); +void write_status_error (const char *where, gpg_error_t err); +void write_status_errcode (const char *where, int errcode); void write_status_text ( int no, const char *text ); void write_status_buffer ( int no, const char *buffer, size_t len, int wrap ); @@ -215,6 +216,7 @@ /*-- keyedit.c --*/ void keyedit_menu( const char *username, strlist_t locusr, strlist_t commands, int quiet, int seckey_check ); +void keyedit_passwd (const char *username); void show_basic_key_info (KBNODE keyblock); /*-- keygen.c --*/ Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/mainproc.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -361,7 +361,13 @@ if( is_status_enabled() ) { char buf[50]; - sprintf(buf, "%08lX%08lX %d 0", + /* FIXME: For ECC support we need to map the OpenPGP algo + number to the Libgcrypt definef one. This is due a + chicken-egg problem: We need to have code in libgcrypt for + a new algorithm so to implement a proposed new algorithm + before the IANA will finally assign an OpenPGP + indentifier. */ + snprintf (buf, sizeof buf, "%08lX%08lX %d 0", (ulong)enc->keyid[0], (ulong)enc->keyid[1], enc->pubkey_algo ); write_status_text( STATUS_ENC_TO, buf ); } Modified: trunk/g10/options.h =================================================================== --- trunk/g10/options.h 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/options.h 2010-01-08 19:18:49 UTC (rev 5247) @@ -1,6 +1,6 @@ /* options.h * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007 Free Software Foundation, Inc. + * 2007, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -248,7 +248,7 @@ struct akl *next; } *auto_key_locate; - int passwd_repeat; + int passphrase_repeat; } opt; /* CTRL is used to keep some global variables we currently can't Modified: trunk/g10/passphrase.c =================================================================== --- trunk/g10/passphrase.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/passphrase.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -50,6 +50,58 @@ static char *last_pw = NULL; + +/* Pack an s2k iteration count into the form specified in 2440. If + we're in between valid values, round up. With value 0 return the + old default. */ +unsigned char +encode_s2k_iterations (int iterations) +{ + gpg_error_t err; + unsigned char c=0; + unsigned char result; + unsigned int count; + + if (!iterations) + { + unsigned long mycnt; + + /* Ask the gpg-agent for a useful iteration count. */ + err = agent_get_s2k_count (&mycnt); + if (err || mycnt < 65536) + { + /* Don't print an error if an older agent is used. */ + if (err && gpg_err_code (err) != GPG_ERR_ASS_PARAMETER) + log_error (_("problem with the agent: %s\n"), gpg_strerror (err)); + /* Default to 65536 which we used up to 2.0.13. */ + return 96; + } + else if (mycnt >= 65011712) + return 255; /* Largest possible value. */ + else + return encode_s2k_iterations ((int)mycnt); + } + + if (iterations <= 1024) + return 0; /* Command line arg compatibility. */ + + if (iterations >= 65011712) + return 255; + + /* Need count to be in the range 16-31 */ + for (count=iterations>>6; count>=32; count>>=1) + c++; + + result = (c<<4)|(count-16); + + if (S2K_DECODE_COUNT(result) < iterations) + result++; + + return result; +} + + + /* Hash a passphrase using the supplied s2k. Always needs: dek->algo, s2k->mode, s2k->hash_algo. */ static void @@ -374,7 +426,7 @@ if (canceled) *canceled = 1; - write_status_error ("get_passphrase", rc); + write_status_errcode ("get_passphrase", rc); } if (pk) @@ -474,7 +526,15 @@ { gcry_randomize (s2k->salt, 8, GCRY_STRONG_RANDOM); if ( s2k->mode == 3 ) - s2k->count = opt.s2k_count; + { + /* We delay the encoding until it is really needed. This is + if we are going to dynamically calibrate it, we need to + call out to gpg-agent and that should not be done during + option processing in main(). */ + if (!opt.s2k_count) + opt.s2k_count = encode_s2k_iterations (0); + s2k->count = opt.s2k_count; + } } /* If we do not have a passphrase available in NEXT_PW and status @@ -584,7 +644,7 @@ /* Divert to the gpg-agent. */ pw = passphrase_get (keyid, mode == 2, s2k_cacheid, - (mode == 2 || mode == 4)? opt.passwd_repeat : 0, + (mode == 2 || mode == 4)? opt.passphrase_repeat : 0, tryagain_text, custdesc, custprompt, canceled); if (*canceled) { Modified: trunk/g10/trustdb.c =================================================================== --- trunk/g10/trustdb.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/g10/trustdb.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1663,7 +1663,7 @@ /* Everything else we delete */ /* At this point, if 12 is set, the signing key was unavailable. - If 9 or 10 is set, it's superceded. Otherwise, it's + If 9 or 10 is set, it's superseded. Otherwise, it's invalid. */ if(noisy) @@ -1671,7 +1671,7 @@ keystr(node->pkt->pkt.signature->keyid), uidnode->pkt->pkt.user_id->name, node->flag&(1<<12)?"key unavailable": - node->flag&(1<<9)?"signature superceded":"invalid signature"); + node->flag&(1<<9)?"signature superseded":"invalid signature"); delete_kbnode(node); deleted++; Modified: trunk/jnlib/argparse.c =================================================================== --- trunk/jnlib/argparse.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/jnlib/argparse.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -1107,7 +1107,7 @@ break; case 11: p = "foo"; break; case 13: p = "0.0"; break; - case 14: p = "Copyright (C) 2009 Free Software Foundation, Inc."; break; + case 14: p = "Copyright (C) 2010 Free Software Foundation, Inc."; break; case 15: p = "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n"; Modified: trunk/scd/app-p15.c =================================================================== --- trunk/scd/app-p15.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/scd/app-p15.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -2909,7 +2909,7 @@ if (aodf->pinflags.integrity_protected || aodf->pinflags.confidentiality_protected) { - log_error ("PIN verification requires unsupported protecion method\n"); + log_error ("PIN verification requires unsupported protection method\n"); return gpg_error (GPG_ERR_BAD_PIN_METHOD); } if (!aodf->stored_length && aodf->pinflags.needs_padding) Modified: trunk/scd/ccid-driver.c =================================================================== --- trunk/scd/ccid-driver.c 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/scd/ccid-driver.c 2010-01-08 19:18:49 UTC (rev 5247) @@ -845,11 +845,11 @@ if ((us & 0x0020)) DEBUGOUT (" Auto baud rate change\n"); if ((us & 0x0040)) - DEBUGOUT (" Auto parameter negotation made by CCID\n"); + DEBUGOUT (" Auto parameter negotiation made by CCID\n"); else if ((us & 0x0080)) DEBUGOUT (" Auto PPS made by CCID\n"); else if ((us & (0x0040 | 0x0080))) - DEBUGOUT (" WARNING: conflicting negotation features\n"); + DEBUGOUT (" WARNING: conflicting negotiation features\n"); if ((us & 0x0100)) DEBUGOUT (" CCID can set ICC in clock stop mode\n"); Modified: trunk/tests/openpgp/Makefile.am =================================================================== --- trunk/tests/openpgp/Makefile.am 2009-12-21 19:17:41 UTC (rev 5246) +++ trunk/tests/openpgp/Makefile.am 2010-01-08 19:18:49 UTC (rev 5247) @@ -19,6 +19,10 @@ GPG_IMPORT = ../../g10/gpg2 --homedir . \ --quiet --yes --no-permission-warning --import +# Programs required before we can run these tests. +required_pgms = ../../g10/gpg2 ../../agent/gpg-agent \ + ../../tools/gpg-connect-agent + TESTS = version.test mds.test \ decrypt.test decrypt-dsa.test \ sigs.test sigs-dsa.test \ @@ -60,7 +64,9 @@ $(GPG_IMPORT) $(srcdir)/pubdemo.asc echo timestamp >./prepared.stamp -./gpg_dearmor: +# We need to depend on a couple of programs so that the tests don't +# start before all programs are built. +./gpg_dearmor: $(required_pgms) echo '#!/bin/sh' >./gpg_dearmor echo "../../g10/gpg2 --no-options --no-greeting \ --no-secmem-warning --batch --dearmor" >>./gpg_dearmor From cvs at cvs.gnupg.org Sat Jan 9 20:00:47 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Sat, 09 Jan 2010 20:00:47 +0100 Subject: [svn] GnuPG - r5248 - trunk/g10 Message-ID: Author: wk Date: 2010-01-09 20:00:46 +0100 (Sat, 09 Jan 2010) New Revision: 5248 Modified: trunk/g10/ChangeLog trunk/g10/getkey.c trunk/g10/keydb.c trunk/g10/keylist.c Log: Re-indent [The diff below has been truncated] Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-01-08 19:18:49 UTC (rev 5247) +++ trunk/g10/ChangeLog 2010-01-09 19:00:46 UTC (rev 5248) @@ -1,3 +1,7 @@ +2010-01-09 Werner Koch + + * getkey.c, keylist.c: Re-indent. + 2010-01-08 Werner Koch * cpr.c (write_status_error): Rename to write_status_errcode. @@ -11003,7 +11007,7 @@ Copyright 1998,1999,2000,2001,2002,2003,2004,2005, - 2006,2007,2008,2009 Free Software Foundation, Inc. + 2006,2007,2008,2009,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 Modified: trunk/g10/getkey.c =================================================================== --- trunk/g10/getkey.c 2010-01-08 19:18:49 UTC (rev 5247) +++ trunk/g10/getkey.c 2010-01-09 19:00:46 UTC (rev 5248) @@ -1,6 +1,6 @@ /* getkey.c - Get a key from the database * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008 Free Software Foundation, Inc. + * 2007, 2008, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -43,129 +43,136 @@ #error We need the cache for key creation #endif -struct getkey_ctx_s { - int exact; - KBNODE keyblock; - KBPOS kbpos; - KBNODE found_key; /* Pointer into some keyblock. */ - strlist_t extra_list; /* Will be freed when releasing the context. */ - int last_rc; - int req_usage; - int req_algo; - KEYDB_HANDLE kr_handle; - int not_allocated; - int nitems; - KEYDB_SEARCH_DESC items[1]; +struct getkey_ctx_s +{ + int exact; + KBNODE keyblock; + KBPOS kbpos; + KBNODE found_key; /* Pointer into some keyblock. */ + strlist_t extra_list; /* Will be freed when releasing the context. */ + int last_rc; + int req_usage; + int req_algo; + KEYDB_HANDLE kr_handle; + int not_allocated; + int nitems; + KEYDB_SEARCH_DESC items[1]; }; #if 0 -static struct { - int any; - int okay_count; - int nokey_count; - int error_count; +static struct +{ + int any; + int okay_count; + int nokey_count; + int error_count; } lkup_stats[21]; #endif -typedef struct keyid_list { - struct keyid_list *next; - u32 keyid[2]; +typedef struct keyid_list +{ + struct keyid_list *next; + u32 keyid[2]; } *keyid_list_t; #if MAX_PK_CACHE_ENTRIES - typedef struct pk_cache_entry { - struct pk_cache_entry *next; - u32 keyid[2]; - PKT_public_key *pk; - } *pk_cache_entry_t; - static pk_cache_entry_t pk_cache; - static int pk_cache_entries; /* number of entries in pk cache */ - static int pk_cache_disabled; +typedef struct pk_cache_entry +{ + struct pk_cache_entry *next; + u32 keyid[2]; + PKT_public_key *pk; +} *pk_cache_entry_t; +static pk_cache_entry_t pk_cache; +static int pk_cache_entries; /* Number of entries in pk cache. */ +static int pk_cache_disabled; #endif #if MAX_UID_CACHE_ENTRIES < 5 #error we really need the userid cache #endif -typedef struct user_id_db { - struct user_id_db *next; - keyid_list_t keyids; - int len; - char name[1]; +typedef struct user_id_db +{ + struct user_id_db *next; + keyid_list_t keyids; + int len; + char name[1]; } *user_id_db_t; static user_id_db_t user_id_db; -static int uid_cache_entries; /* number of entries in uid cache */ +static int uid_cache_entries; /* Number of entries in uid cache. */ -static void merge_selfsigs( KBNODE keyblock ); -static int lookup( GETKEY_CTX ctx, KBNODE *ret_keyblock, int secmode ); +static void merge_selfsigs (KBNODE keyblock); +static int lookup (GETKEY_CTX ctx, KBNODE * ret_keyblock, int secmode); #if 0 static void -print_stats() +print_stats () { - int i; - for(i=0; i < DIM(lkup_stats); i++ ) { - if( lkup_stats[i].any ) - fprintf(stderr, - "lookup stats: mode=%-2d ok=%-6d nokey=%-6d err=%-6d\n", - i, - lkup_stats[i].okay_count, - lkup_stats[i].nokey_count, - lkup_stats[i].error_count ); + int i; + for (i = 0; i < DIM (lkup_stats); i++) + { + if (lkup_stats[i].any) + fprintf (stderr, + "lookup stats: mode=%-2d ok=%-6d nokey=%-6d err=%-6d\n", + i, + lkup_stats[i].okay_count, + lkup_stats[i].nokey_count, lkup_stats[i].error_count); } } #endif void -cache_public_key( PKT_public_key *pk ) +cache_public_key (PKT_public_key * pk) { #if MAX_PK_CACHE_ENTRIES - pk_cache_entry_t ce; - u32 keyid[2]; + pk_cache_entry_t ce; + u32 keyid[2]; - if( pk_cache_disabled ) - return; + if (pk_cache_disabled) + return; - if( pk->dont_cache ) - return; + if (pk->dont_cache) + return; - if( is_ELGAMAL(pk->pubkey_algo) - || pk->pubkey_algo == PUBKEY_ALGO_DSA - || is_RSA(pk->pubkey_algo) ) { - keyid_from_pk( pk, keyid ); + if (is_ELGAMAL (pk->pubkey_algo) + || pk->pubkey_algo == PUBKEY_ALGO_DSA || is_RSA (pk->pubkey_algo)) + { + keyid_from_pk (pk, keyid); } - else - return; /* don't know how to get the keyid */ + else + return; /* Don't know how to get the keyid. */ - for( ce = pk_cache; ce; ce = ce->next ) - if( ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] ) { - if( DBG_CACHE ) - log_debug("cache_public_key: already in cache\n"); - return; - } + for (ce = pk_cache; ce; ce = ce->next) + if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1]) + { + if (DBG_CACHE) + log_debug ("cache_public_key: already in cache\n"); + return; + } - if( pk_cache_entries >= MAX_PK_CACHE_ENTRIES ) { - /* fixme: use another algorithm to free some cache slots */ - pk_cache_disabled=1; - if( opt.verbose > 1 ) - log_info(_("too many entries in pk cache - disabled\n")); - return; + if (pk_cache_entries >= MAX_PK_CACHE_ENTRIES) + { + /* fixme: Use another algorithm to free some cache slots. */ + pk_cache_disabled = 1; + if (opt.verbose > 1) + log_info (_("too many entries in pk cache - disabled\n")); + return; } - pk_cache_entries++; - ce = xmalloc( sizeof *ce ); - ce->next = pk_cache; - pk_cache = ce; - ce->pk = copy_public_key( NULL, pk ); - ce->keyid[0] = keyid[0]; - ce->keyid[1] = keyid[1]; + pk_cache_entries++; + ce = xmalloc (sizeof *ce); + ce->next = pk_cache; + pk_cache = ce; + ce->pk = copy_public_key (NULL, pk); + ce->keyid[0] = keyid[0]; + ce->keyid[1] = keyid[1]; #endif } /* Return a const utf-8 string with the text "[User ID not found]". - This fucntion is required so that we don't need to switch gettext's - encoding temporary. */ + This function is required so that we don't need to switch gettext's + encoding temporary. */ static const char * user_id_not_found_utf8 (void) { @@ -178,39 +185,40 @@ -/* - * Return the user ID from the given keyblock. +/* Return the user ID from the given keyblock. * We use the primary uid flag which has been set by the merge_selfsigs * function. The returned value is only valid as long as then given - * keyblock is not changed - */ + * keyblock is not changed. */ static const char * -get_primary_uid ( KBNODE keyblock, size_t *uidlen ) +get_primary_uid (KBNODE keyblock, size_t * uidlen) { - KBNODE k; - const char *s; + KBNODE k; + const char *s; - for (k=keyblock; k; k=k->next ) { - if ( k->pkt->pkttype == PKT_USER_ID - && !k->pkt->pkt.user_id->attrib_data - && k->pkt->pkt.user_id->is_primary ) { - *uidlen = k->pkt->pkt.user_id->len; - return k->pkt->pkt.user_id->name; - } - } - s = user_id_not_found_utf8 (); - *uidlen = strlen (s); - return s; + for (k = keyblock; k; k = k->next) + { + if (k->pkt->pkttype == PKT_USER_ID + && !k->pkt->pkt.user_id->attrib_data + && k->pkt->pkt.user_id->is_primary) + { + *uidlen = k->pkt->pkt.user_id->len; + return k->pkt->pkt.user_id->name; + } + } + s = user_id_not_found_utf8 (); + *uidlen = strlen (s); + return s; } static void -release_keyid_list ( keyid_list_t k ) +release_keyid_list (keyid_list_t k) { - while ( k ) { - keyid_list_t k2 = k->next; - xfree (k); - k = k2; + while (k) + { + keyid_list_t k2 = k->next; + xfree (k); + k = k2; } } @@ -219,203 +227,211 @@ * Feed only public keys to this function. */ static void -cache_user_id( KBNODE keyblock ) +cache_user_id (KBNODE keyblock) { - user_id_db_t r; - const char *uid; - size_t uidlen; - keyid_list_t keyids = NULL; - KBNODE k; + user_id_db_t r; + const char *uid; + size_t uidlen; + keyid_list_t keyids = NULL; + KBNODE k; - for (k=keyblock; k; k = k->next ) { - if ( k->pkt->pkttype == PKT_PUBLIC_KEY - || k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) { - keyid_list_t a = xmalloc_clear ( sizeof *a ); - /* Hmmm: For a long list of keyids it might be an advantage - * to append the keys */ - keyid_from_pk( k->pkt->pkt.public_key, a->keyid ); - /* first check for duplicates */ - for(r=user_id_db; r; r = r->next ) { - keyid_list_t b = r->keyids; - for ( b = r->keyids; b; b = b->next ) { - if( b->keyid[0] == a->keyid[0] - && b->keyid[1] == a->keyid[1] ) { - if( DBG_CACHE ) - log_debug("cache_user_id: already in cache\n"); - release_keyid_list ( keyids ); - xfree ( a ); - return; - } - } - } - /* now put it into the cache */ - a->next = keyids; - keyids = a; - } + for (k = keyblock; k; k = k->next) + { + if (k->pkt->pkttype == PKT_PUBLIC_KEY + || k->pkt->pkttype == PKT_PUBLIC_SUBKEY) + { + keyid_list_t a = xmalloc_clear (sizeof *a); + /* Hmmm: For a long list of keyids it might be an advantage + * to append the keys. */ + keyid_from_pk (k->pkt->pkt.public_key, a->keyid); + /* First check for duplicates. */ + for (r = user_id_db; r; r = r->next) + { + keyid_list_t b = r->keyids; + for (b = r->keyids; b; b = b->next) + { + if (b->keyid[0] == a->keyid[0] + && b->keyid[1] == a->keyid[1]) + { + if (DBG_CACHE) + log_debug ("cache_user_id: already in cache\n"); + release_keyid_list (keyids); + xfree (a); + return; + } + } + } + /* Now put it into the cache. */ + a->next = keyids; + keyids = a; + } } - if ( !keyids ) - BUG (); /* No key no fun */ + if (!keyids) + BUG (); /* No key no fun. */ - uid = get_primary_uid ( keyblock, &uidlen ); + uid = get_primary_uid (keyblock, &uidlen); - if( uid_cache_entries >= MAX_UID_CACHE_ENTRIES ) { - /* fixme: use another algorithm to free some cache slots */ - r = user_id_db; - user_id_db = r->next; - release_keyid_list ( r->keyids ); - xfree(r); - uid_cache_entries--; + if (uid_cache_entries >= MAX_UID_CACHE_ENTRIES) + { + /* fixme: use another algorithm to free some cache slots */ + r = user_id_db; + user_id_db = r->next; + release_keyid_list (r->keyids); + xfree (r); + uid_cache_entries--; } - r = xmalloc( sizeof *r + uidlen-1 ); - r->keyids = keyids; - r->len = uidlen; - memcpy(r->name, uid, r->len); - r->next = user_id_db; - user_id_db = r; - uid_cache_entries++; + r = xmalloc (sizeof *r + uidlen - 1); + r->keyids = keyids; + r->len = uidlen; + memcpy (r->name, uid, r->len); + r->next = user_id_db; + user_id_db = r; + uid_cache_entries++; } void -getkey_disable_caches() +getkey_disable_caches () { #if MAX_PK_CACHE_ENTRIES - { - pk_cache_entry_t ce, ce2; + { + pk_cache_entry_t ce, ce2; - for( ce = pk_cache; ce; ce = ce2 ) { - ce2 = ce->next; - free_public_key( ce->pk ); - xfree( ce ); - } - pk_cache_disabled=1; - pk_cache_entries = 0; - pk_cache = NULL; - } + for (ce = pk_cache; ce; ce = ce2) + { + ce2 = ce->next; + free_public_key (ce->pk); + xfree (ce); + } + pk_cache_disabled = 1; + pk_cache_entries = 0; + pk_cache = NULL; + } #endif - /* fixme: disable user id cache ? */ + /* fixme: disable user id cache ? */ } static void -pk_from_block ( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE keyblock ) +pk_from_block (GETKEY_CTX ctx, PKT_public_key * pk, KBNODE keyblock) { - KBNODE a = ctx->found_key ? ctx->found_key : keyblock; + KBNODE a = ctx->found_key ? ctx->found_key : keyblock; - assert ( a->pkt->pkttype == PKT_PUBLIC_KEY - || a->pkt->pkttype == PKT_PUBLIC_SUBKEY ); - - copy_public_key ( pk, a->pkt->pkt.public_key ); + assert (a->pkt->pkttype == PKT_PUBLIC_KEY + || a->pkt->pkttype == PKT_PUBLIC_SUBKEY); + + copy_public_key (pk, a->pkt->pkt.public_key); } static void -sk_from_block ( GETKEY_CTX ctx, - PKT_secret_key *sk, KBNODE keyblock ) +sk_from_block (GETKEY_CTX ctx, PKT_secret_key * sk, KBNODE keyblock) { - KBNODE a = ctx->found_key ? ctx->found_key : keyblock; + KBNODE a = ctx->found_key ? ctx->found_key : keyblock; - assert ( a->pkt->pkttype == PKT_SECRET_KEY - || a->pkt->pkttype == PKT_SECRET_SUBKEY ); - - copy_secret_key( sk, a->pkt->pkt.secret_key); + assert (a->pkt->pkttype == PKT_SECRET_KEY + || a->pkt->pkttype == PKT_SECRET_SUBKEY); + + copy_secret_key (sk, a->pkt->pkt.secret_key); } -/**************** - * Get a public key and store it into the allocated pk - * can be called with PK set to NULL to just read it into some - * internal structures. - */ +/* Get a public key and store it into the allocated pk can be called + * with PK set to NULL to just read it into some internal + * structures. */ int -get_pubkey( PKT_public_key *pk, u32 *keyid ) +get_pubkey (PKT_public_key * pk, u32 * keyid) { - int internal = 0; - int rc = 0; + int internal = 0; + int rc = 0; #if MAX_PK_CACHE_ENTRIES - if(pk) - { - /* Try to get it from the cache. We don't do this when pk is - NULL as it does not guarantee that the user IDs are - cached. */ - pk_cache_entry_t ce; - for( ce = pk_cache; ce; ce = ce->next ) - { - if( ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] ) - { - copy_public_key( pk, ce->pk ); - return 0; - } - } - } + if (pk) + { + /* Try to get it from the cache. We don't do this when pk is + NULL as it does not guarantee that the user IDs are + cached. */ + pk_cache_entry_t ce; + for (ce = pk_cache; ce; ce = ce->next) + { + if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1]) + { + copy_public_key (pk, ce->pk); + return 0; + } + } + } #endif - /* more init stuff */ - if( !pk ) { - pk = xmalloc_clear( sizeof *pk ); - internal++; + /* More init stuff. */ + if (!pk) + { + pk = xmalloc_clear (sizeof *pk); + internal++; } - /* do a lookup */ - { struct getkey_ctx_s ctx; - KBNODE kb = NULL; - memset( &ctx, 0, sizeof ctx ); - ctx.exact = 1; /* use the key ID exactly as given */ - ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (0); - ctx.nitems = 1; - ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; - ctx.items[0].u.kid[0] = keyid[0]; - ctx.items[0].u.kid[1] = keyid[1]; - ctx.req_algo = pk->req_algo; - ctx.req_usage = pk->req_usage; - rc = lookup( &ctx, &kb, 0 ); - if ( !rc ) { - pk_from_block ( &ctx, pk, kb ); - } - get_pubkey_end( &ctx ); - release_kbnode ( kb ); - } - if( !rc ) - goto leave; + /* Do a lookup. */ + { + struct getkey_ctx_s ctx; + KBNODE kb = NULL; + memset (&ctx, 0, sizeof ctx); + ctx.exact = 1; /* Use the key ID exactly as given. */ + ctx.not_allocated = 1; + ctx.kr_handle = keydb_new (0); + ctx.nitems = 1; + ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; + ctx.items[0].u.kid[0] = keyid[0]; + ctx.items[0].u.kid[1] = keyid[1]; + ctx.req_algo = pk->req_algo; + ctx.req_usage = pk->req_usage; + rc = lookup (&ctx, &kb, 0); + if (!rc) + { + pk_from_block (&ctx, pk, kb); + } + get_pubkey_end (&ctx); + release_kbnode (kb); + } + if (!rc) + goto leave; - rc = G10ERR_NO_PUBKEY; + rc = G10ERR_NO_PUBKEY; - leave: - if( !rc ) - cache_public_key( pk ); - if( internal ) - free_public_key(pk); - return rc; +leave: + if (!rc) + cache_public_key (pk); + if (internal) + free_public_key (pk); + return rc; } /* Get a public key and store it into the allocated pk. This function differs from get_pubkey() in that it does not do a check of the key to avoid recursion. It should be used only in very certain cases. - It will only retrieve primary keys. */ + It will only retrieve primary keys. */ int -get_pubkey_fast (PKT_public_key *pk, u32 *keyid) +get_pubkey_fast (PKT_public_key * pk, u32 * keyid) { int rc = 0; KEYDB_HANDLE hd; KBNODE keyblock; u32 pkid[2]; - + assert (pk); #if MAX_PK_CACHE_ENTRIES - { /* Try to get it from the cache */ + { + /* Try to get it from the cache */ pk_cache_entry_t ce; for (ce = pk_cache; ce; ce = ce->next) { - if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1]) - { - if (pk) - copy_public_key (pk, ce->pk); - return 0; - } + if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1]) + { + if (pk) + copy_public_key (pk, ce->pk); + return 0; + } } } #endif @@ -429,20 +445,20 @@ } rc = keydb_get_keyblock (hd, &keyblock); keydb_release (hd); - if (rc) + if (rc) { - log_error ("keydb_get_keyblock failed: %s\n", g10_errstr(rc)); + log_error ("keydb_get_keyblock failed: %s\n", g10_errstr (rc)); return G10ERR_NO_PUBKEY; } - assert ( keyblock->pkt->pkttype == PKT_PUBLIC_KEY - || keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY ); + assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY + || keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY); - keyid_from_pk(keyblock->pkt->pkt.public_key,pkid); - if(keyid[0]==pkid[0] && keyid[1]==pkid[1]) - copy_public_key (pk, keyblock->pkt->pkt.public_key ); + keyid_from_pk (keyblock->pkt->pkt.public_key, pkid); + if (keyid[0] == pkid[0] && keyid[1] == pkid[1]) + copy_public_key (pk, keyblock->pkt->pkt.public_key); else - rc=G10ERR_NO_PUBKEY; + rc = G10ERR_NO_PUBKEY; release_kbnode (keyblock); @@ -454,24 +470,24 @@ KBNODE -get_pubkeyblock( u32 *keyid ) +get_pubkeyblock (u32 * keyid) { - struct getkey_ctx_s ctx; - int rc = 0; - KBNODE keyblock = NULL; + struct getkey_ctx_s ctx; + int rc = 0; + KBNODE keyblock = NULL; - memset( &ctx, 0, sizeof ctx ); - /* no need to set exact here because we want the entire block */ - ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (0); - ctx.nitems = 1; - ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; - ctx.items[0].u.kid[0] = keyid[0]; - ctx.items[0].u.kid[1] = keyid[1]; - rc = lookup( &ctx, &keyblock, 0 ); - get_pubkey_end( &ctx ); + memset (&ctx, 0, sizeof ctx); + /* No need to set exact here because we want the entire block. */ + ctx.not_allocated = 1; + ctx.kr_handle = keydb_new (0); + ctx.nitems = 1; + ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; + ctx.items[0].u.kid[0] = keyid[0]; + ctx.items[0].u.kid[1] = keyid[1]; + rc = lookup (&ctx, &keyblock, 0); + get_pubkey_end (&ctx); - return rc ? NULL : keyblock; + return rc ? NULL : keyblock; } @@ -481,213 +497,222 @@ * Get a secret key and store it into sk */ int -get_seckey( PKT_secret_key *sk, u32 *keyid ) +get_seckey (PKT_secret_key * sk, u32 * keyid) { - int rc; - struct getkey_ctx_s ctx; - KBNODE kb = NULL; + int rc; + struct getkey_ctx_s ctx; + KBNODE kb = NULL; - memset( &ctx, 0, sizeof ctx ); - ctx.exact = 1; /* use the key ID exactly as given */ - ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (1); - ctx.nitems = 1; - ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; - ctx.items[0].u.kid[0] = keyid[0]; - ctx.items[0].u.kid[1] = keyid[1]; - ctx.req_algo = sk->req_algo; - ctx.req_usage = sk->req_usage; - rc = lookup( &ctx, &kb, 1 ); - if ( !rc ) { - sk_from_block ( &ctx, sk, kb ); + memset (&ctx, 0, sizeof ctx); + ctx.exact = 1; /* Use the key ID exactly as given. */ + ctx.not_allocated = 1; + ctx.kr_handle = keydb_new (1); + ctx.nitems = 1; + ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; + ctx.items[0].u.kid[0] = keyid[0]; + ctx.items[0].u.kid[1] = keyid[1]; + ctx.req_algo = sk->req_algo; + ctx.req_usage = sk->req_usage; + rc = lookup (&ctx, &kb, 1); + if (!rc) + { + sk_from_block (&ctx, sk, kb); } - get_seckey_end( &ctx ); - release_kbnode ( kb ); + get_seckey_end (&ctx); + release_kbnode (kb); - if( !rc ) { - /* check the secret key (this may prompt for a passprase to - * unlock the secret key - */ - rc = check_secret_key( sk, 0 ); + if (!rc) + { + /* Check the secret key (this may prompt for a passprase to + * unlock the secret key. */ + rc = check_secret_key (sk, 0); } - return rc; + return rc; } -/**************** - * Check whether the secret key is available. This is just a fast +/* Check whether the secret key is available. This is just a fast * check and does not tell us whether the secret key is valid. It * merely tells other whether there is some secret key. - * Returns: 0 := key is available - * G10ERR_NO_SECKEY := not availabe + * Returns: + * 0 := key is available + * G10ERR_NO_SECKEY := key not availabe */ int -seckey_available( u32 *keyid ) +seckey_available (u32 * keyid) { - int rc; - KEYDB_HANDLE hd = keydb_new (1); + int rc; + KEYDB_HANDLE hd = keydb_new (1); - rc = keydb_search_kid (hd, keyid); - if ( rc == -1 ) - rc = G10ERR_NO_SECKEY; - keydb_release (hd); - return rc; + rc = keydb_search_kid (hd, keyid); + if (rc == -1) + rc = G10ERR_NO_SECKEY; + keydb_release (hd); + return rc; } static int -skip_unusable (void *dummy, u32 *keyid, PKT_user_id *uid) +skip_unusable (void *dummy, u32 * keyid, PKT_user_id * uid) { - int unusable=0; + int unusable = 0; KBNODE keyblock; - - (void)dummy; - keyblock=get_pubkeyblock(keyid); - if(!keyblock) + (void) dummy; + + keyblock = get_pubkeyblock (keyid); + if (!keyblock) { - log_error("error checking usability status of %s\n",keystr(keyid)); + log_error ("error checking usability status of %s\n", keystr (keyid)); goto leave; } /* Is the user ID in question revoked/expired? */ - if(uid) + if (uid) { KBNODE node; - for(node=keyblock;node;node=node->next) + for (node = keyblock; node; node = node->next) { - if(node->pkt->pkttype==PKT_USER_ID) + if (node->pkt->pkttype == PKT_USER_ID) { - if(cmp_user_ids(uid,node->pkt->pkt.user_id)==0 - && (node->pkt->pkt.user_id->is_revoked - || node->pkt->pkt.user_id->is_expired)) + if (cmp_user_ids (uid, node->pkt->pkt.user_id) == 0 + && (node->pkt->pkt.user_id->is_revoked + || node->pkt->pkt.user_id->is_expired)) { - unusable=1; + unusable = 1; break; } } } } - if(!unusable) - unusable=pk_is_disabled(keyblock->pkt->pkt.public_key); + if (!unusable) + unusable = pk_is_disabled (keyblock->pkt->pkt.public_key); - leave: - release_kbnode(keyblock); +leave: + release_kbnode (keyblock); return unusable; } -/**************** - * Try to get the pubkey by the userid. This function looks for the + +/* Try to get the pubkey by the userid. This function looks for the * first pubkey certificate which has the given name in a user_id. if * pk/sk has the pubkey algo set, the function will only return a * pubkey with that algo. If namelist is NULL, the first key is * returned. The caller should provide storage for either the pk or * the sk. If ret_kb is not NULL the function will return the - * keyblock there. - */ - + * keyblock there. */ static int -key_byname( GETKEY_CTX *retctx, strlist_t namelist, - PKT_public_key *pk, PKT_secret_key *sk, +key_byname (GETKEY_CTX * retctx, strlist_t namelist, + PKT_public_key * pk, PKT_secret_key * sk, int secmode, int include_unusable, - KBNODE *ret_kb, KEYDB_HANDLE *ret_kdbhd ) + KBNODE * ret_kb, KEYDB_HANDLE * ret_kdbhd) { - int rc = 0; - int n; - strlist_t r; - GETKEY_CTX ctx; - KBNODE help_kb = NULL; - - if( retctx ) {/* reset the returned context in case of error */ - assert (!ret_kdbhd); /* not allowed because the handle is - stored in the context */ - *retctx = NULL; + int rc = 0; + int n; + strlist_t r; + GETKEY_CTX ctx; + KBNODE help_kb = NULL; + + if (retctx) + { + /* Reset the returned context in case of error. */ + assert (!ret_kdbhd); /* Not allowed because the handle is stored + in the context. */ + *retctx = NULL; } - if (ret_kdbhd) - *ret_kdbhd = NULL; + if (ret_kdbhd) + *ret_kdbhd = NULL; - if(!namelist) - { - ctx = xmalloc_clear (sizeof *ctx); - ctx->nitems = 1; - ctx->items[0].mode=KEYDB_SEARCH_MODE_FIRST; - if(!include_unusable) - ctx->items[0].skipfnc=skip_unusable; - } - else - { - /* build the search context */ - for(n=0, r=namelist; r; r = r->next ) - n++; + if (!namelist) + { + ctx = xmalloc_clear (sizeof *ctx); + ctx->nitems = 1; + ctx->items[0].mode = KEYDB_SEARCH_MODE_FIRST; + if (!include_unusable) + ctx->items[0].skipfnc = skip_unusable; + } + else + { + /* Build the search context. */ + for (n = 0, r = namelist; r; r = r->next) + n++; - ctx = xmalloc_clear (sizeof *ctx + (n-1)*sizeof ctx->items ); - ctx->nitems = n; + ctx = xmalloc_clear (sizeof *ctx + (n - 1) * sizeof ctx->items); + ctx->nitems = n; - for(n=0, r=namelist; r; r = r->next, n++ ) - { - gpg_error_t err; + for (n = 0, r = namelist; r; r = r->next, n++) + { + gpg_error_t err; - err = classify_user_id (r->d, &ctx->items[n]); - - if (ctx->items[n].exact) - ctx->exact = 1; - if (err) - { - xfree (ctx); - return gpg_err_code (err); /* FIXME: remove gpg_err_code. */ - } - if(!include_unusable - && ctx->items[n].mode!=KEYDB_SEARCH_MODE_SHORT_KID - && ctx->items[n].mode!=KEYDB_SEARCH_MODE_LONG_KID - && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR16 - && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR20 - && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR) - ctx->items[n].skipfnc=skip_unusable; - } - } + err = classify_user_id (r->d, &ctx->items[n]); - ctx->kr_handle = keydb_new (secmode); - if ( !ret_kb ) - ret_kb = &help_kb; + if (ctx->items[n].exact) + ctx->exact = 1; + if (err) + { + xfree (ctx); + return gpg_err_code (err); /* FIXME: remove gpg_err_code. */ + } + if (!include_unusable + && ctx->items[n].mode != KEYDB_SEARCH_MODE_SHORT_KID + && ctx->items[n].mode != KEYDB_SEARCH_MODE_LONG_KID + && ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR16 + && ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR20 + && ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR) + ctx->items[n].skipfnc = skip_unusable; + } + } - if( secmode ) { - if (sk) { - ctx->req_algo = sk->req_algo; - ctx->req_usage = sk->req_usage; - } - rc = lookup( ctx, ret_kb, 1 ); - if ( !rc && sk ) { - sk_from_block ( ctx, sk, *ret_kb ); - } + ctx->kr_handle = keydb_new (secmode); + if (!ret_kb) + ret_kb = &help_kb; + + if (secmode) + { + if (sk) + { + ctx->req_algo = sk->req_algo; + ctx->req_usage = sk->req_usage; + } + rc = lookup (ctx, ret_kb, 1); + if (!rc && sk) + { + sk_from_block (ctx, sk, *ret_kb); + } } - else { - if (pk) { - ctx->req_algo = pk->req_algo; - ctx->req_usage = pk->req_usage; - } - rc = lookup( ctx, ret_kb, 0 ); - if ( !rc && pk ) { - pk_from_block ( ctx, pk, *ret_kb ); - } + else + { + if (pk) + { + ctx->req_algo = pk->req_algo; + ctx->req_usage = pk->req_usage; + } + rc = lookup (ctx, ret_kb, 0); + if (!rc && pk) + { + pk_from_block (ctx, pk, *ret_kb); + } } - release_kbnode ( help_kb ); + release_kbnode (help_kb); - if (retctx) /* caller wants the context */ - *retctx = ctx; - else { - if (ret_kdbhd) { - *ret_kdbhd = ctx->kr_handle; - ctx->kr_handle = NULL; - } - get_pubkey_end (ctx); + if (retctx) /* Caller wants the context. */ + *retctx = ctx; + else + { + if (ret_kdbhd) + { + *ret_kdbhd = ctx->kr_handle; + ctx->kr_handle = NULL; + } + get_pubkey_end (ctx); } - return rc; + return rc; } @@ -700,10 +725,9 @@ to import the key via the online mechanisms defined by --auto-key-locate. */ int -get_pubkey_byname (GETKEY_CTX *retctx, PKT_public_key *pk, - const char *name, KBNODE *ret_keyblock, - KEYDB_HANDLE *ret_kdbhd, int include_unusable, - int no_akl) +get_pubkey_byname (GETKEY_CTX * retctx, PKT_public_key * pk, + const char *name, KBNODE * ret_keyblock, + KEYDB_HANDLE * ret_kdbhd, int include_unusable, int no_akl) { int rc; strlist_t namelist = NULL; @@ -719,7 +743,7 @@ /* Check whether we the default local search has been disabled. This is the case if either the "nodefault" or the "local" keyword - are in the list of auto key locate mechanisms. + are in the list of auto key locate mechanisms. ANYLOCALFIRST is set if the search order has the local method before any other or if "local" is used first by default. This @@ -728,19 +752,19 @@ a followup call to get_pubkey_next shall succeed. */ if (!no_akl) { - for (akl=opt.auto_key_locate; akl; akl=akl->next) - if (akl->type == AKL_NODEFAULT || akl->type == AKL_LOCAL) - { - nodefault = 1; - break; - } - for (akl=opt.auto_key_locate; akl; akl=akl->next) - if (akl->type != AKL_NODEFAULT) - { - if (akl->type == AKL_LOCAL) - anylocalfirst = 1; - break; - } + for (akl = opt.auto_key_locate; akl; akl = akl->next) + if (akl->type == AKL_NODEFAULT || akl->type == AKL_LOCAL) + { + nodefault = 1; + break; + } + for (akl = opt.auto_key_locate; akl; akl = akl->next) + if (akl->type != AKL_NODEFAULT) + { + if (akl->type == AKL_LOCAL) + anylocalfirst = 1; + break; + } } if (!nodefault) @@ -755,96 +779,98 @@ { add_to_strlist (&namelist, name); rc = key_byname (retctx, namelist, pk, NULL, 0, - include_unusable, ret_keyblock, ret_kdbhd); + include_unusable, ret_keyblock, ret_kdbhd); } /* If the requested name resembles a valid mailbox and automatic retrieval has been enabled, we try to import the key. */ if (gpg_err_code (rc) == G10ERR_NO_PUBKEY && !no_akl && is_mbox) { - for (akl=opt.auto_key_locate; akl; akl=akl->next) + for (akl = opt.auto_key_locate; akl; akl = akl->next) { unsigned char *fpr = NULL; size_t fpr_len; - int did_key_byname = 0; - int no_fingerprint = 0; - const char *mechanism = "?"; - - switch(akl->type) + int did_key_byname = 0; + int no_fingerprint = 0; + const char *mechanism = "?"; + + switch (akl->type) { - case AKL_NODEFAULT: - /* This is a dummy mechanism. */ - mechanism = "None"; - rc = G10ERR_NO_PUBKEY; - break; + case AKL_NODEFAULT: + /* This is a dummy mechanism. */ + mechanism = "None"; + rc = G10ERR_NO_PUBKEY; + break; - case AKL_LOCAL: - mechanism = "Local"; - did_key_byname = 1; - if (retctx) - { - get_pubkey_end (*retctx); - *retctx = NULL; - } - add_to_strlist (&namelist, name); - rc = key_byname (anylocalfirst? retctx:NULL, - namelist, pk, NULL, 0, - include_unusable, ret_keyblock, ret_kdbhd); - break; + case AKL_LOCAL: + mechanism = "Local"; + did_key_byname = 1; + if (retctx) + { + get_pubkey_end (*retctx); + *retctx = NULL; + } + add_to_strlist (&namelist, name); + rc = key_byname (anylocalfirst ? retctx : NULL, + namelist, pk, NULL, 0, + include_unusable, ret_keyblock, ret_kdbhd); + break; case AKL_CERT: - mechanism = "DNS CERT"; + mechanism = "DNS CERT"; glo_ctrl.in_auto_key_retrieve++; - rc=keyserver_import_cert(name,&fpr,&fpr_len); + rc = keyserver_import_cert (name, &fpr, &fpr_len); glo_ctrl.in_auto_key_retrieve--; break; case AKL_PKA: - mechanism = "PKA"; + mechanism = "PKA"; glo_ctrl.in_auto_key_retrieve++; - rc=keyserver_import_pka(name,&fpr,&fpr_len); + rc = keyserver_import_pka (name, &fpr, &fpr_len); glo_ctrl.in_auto_key_retrieve--; break; case AKL_LDAP: - mechanism = "LDAP"; + mechanism = "LDAP"; glo_ctrl.in_auto_key_retrieve++; - rc=keyserver_import_ldap(name,&fpr,&fpr_len); + rc = keyserver_import_ldap (name, &fpr, &fpr_len); glo_ctrl.in_auto_key_retrieve--; break; case AKL_KEYSERVER: /* Strictly speaking, we don't need to only use a valid - mailbox for the getname search, but it helps cut down - on the problem of searching for something like "john" - and getting a whole lot of keys back. */ - if(opt.keyserver) + mailbox for the getname search, but it helps cut down + on the problem of searching for something like "john" + and getting a whole lot of keys back. */ + if (opt.keyserver) { - mechanism = opt.keyserver->uri; + mechanism = opt.keyserver->uri; glo_ctrl.in_auto_key_retrieve++; - rc=keyserver_import_name(name,&fpr,&fpr_len,opt.keyserver); + rc = + keyserver_import_name (name, &fpr, &fpr_len, + opt.keyserver); glo_ctrl.in_auto_key_retrieve--; } - else - { - mechanism = "Unconfigured keyserver"; - rc = G10ERR_NO_PUBKEY; - } + else + { + mechanism = "Unconfigured keyserver"; + rc = G10ERR_NO_PUBKEY; + } break; case AKL_SPEC: { struct keyserver_spec *keyserver; - mechanism = akl->spec->uri; - keyserver=keyserver_match(akl->spec); + mechanism = akl->spec->uri; + keyserver = keyserver_match (akl->spec); glo_ctrl.in_auto_key_retrieve++; - rc=keyserver_import_name(name,&fpr,&fpr_len,keyserver); + rc = keyserver_import_name (name, &fpr, &fpr_len, keyserver); glo_ctrl.in_auto_key_retrieve--; } break; } - + /* Use the fingerprint of the key that we actually fetched. This helps prevent problems where the key that we fetched doesn't have the same name that we used to fetch it. In @@ -854,54 +880,55 @@ won't use the attacker's key here. */ if (!rc && fpr) { - char fpr_string[MAX_FINGERPRINT_LEN*2+1]; + char fpr_string[MAX_FINGERPRINT_LEN * 2 + 1]; - assert(fpr_len<=MAX_FINGERPRINT_LEN); + assert (fpr_len <= MAX_FINGERPRINT_LEN); - free_strlist(namelist); - namelist=NULL; + free_strlist (namelist); + namelist = NULL; - bin2hex (fpr, fpr_len, fpr_string); - - if(opt.verbose) - log_info("auto-key-locate found fingerprint %s\n",fpr_string); + bin2hex (fpr, fpr_len, fpr_string); - add_to_strlist( &namelist, fpr_string ); + if (opt.verbose) + log_info ("auto-key-locate found fingerprint %s\n", + fpr_string); + + add_to_strlist (&namelist, fpr_string); } - else if (!rc && !fpr && !did_key_byname) - { - no_fingerprint = 1; - rc = G10ERR_NO_PUBKEY; - } - xfree (fpr); - fpr = NULL; + else if (!rc && !fpr && !did_key_byname) + { + no_fingerprint = 1; + rc = G10ERR_NO_PUBKEY; + } + xfree (fpr); + fpr = NULL; - if (!rc && !did_key_byname) - { - if (retctx) - { - get_pubkey_end (*retctx); - *retctx = NULL; - } - rc = key_byname (anylocalfirst?retctx:NULL, - namelist, pk, NULL, 0, - include_unusable, ret_keyblock, ret_kdbhd); - } + if (!rc && !did_key_byname) + { + if (retctx) + { + get_pubkey_end (*retctx); + *retctx = NULL; + } + rc = key_byname (anylocalfirst ? retctx : NULL, + namelist, pk, NULL, 0, + include_unusable, ret_keyblock, ret_kdbhd); + } if (!rc) - { - /* Key found. */ - log_info (_("automatically retrieved `%s' via %s\n"), - name, mechanism); - break; - } - if (rc != G10ERR_NO_PUBKEY || opt.verbose || no_fingerprint) - log_info (_("error retrieving `%s' via %s: %s\n"), - name, mechanism, - no_fingerprint? _("No fingerprint"):g10_errstr(rc)); + { + /* Key found. */ + log_info (_("automatically retrieved `%s' via %s\n"), + name, mechanism); + break; + } + if (rc != G10ERR_NO_PUBKEY || opt.verbose || no_fingerprint) + log_info (_("error retrieving `%s' via %s: %s\n"), + name, mechanism, + no_fingerprint ? _("No fingerprint") : g10_errstr (rc)); } } - + if (rc && retctx) { get_pubkey_end (*retctx); @@ -920,70 +947,71 @@ int -get_pubkey_bynames( GETKEY_CTX *retctx, PKT_public_key *pk, - strlist_t names, KBNODE *ret_keyblock ) +get_pubkey_bynames (GETKEY_CTX * retctx, PKT_public_key * pk, + strlist_t names, KBNODE * ret_keyblock) { - return key_byname( retctx, names, pk, NULL, 0, 1, ret_keyblock, NULL); + return key_byname (retctx, names, pk, NULL, 0, 1, ret_keyblock, NULL); } int -get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock ) +get_pubkey_next (GETKEY_CTX ctx, PKT_public_key * pk, KBNODE * ret_keyblock) { - int rc; + int rc; - rc = lookup( ctx, ret_keyblock, 0 ); - if ( !rc && pk && ret_keyblock ) - pk_from_block ( ctx, pk, *ret_keyblock ); - - return rc; + rc = lookup (ctx, ret_keyblock, 0); + if (!rc && pk && ret_keyblock) + pk_from_block (ctx, pk, *ret_keyblock); + + return rc; } void -get_pubkey_end( GETKEY_CTX ctx ) +get_pubkey_end (GETKEY_CTX ctx) { - if( ctx ) { - memset (&ctx->kbpos, 0, sizeof ctx->kbpos); - keydb_release (ctx->kr_handle); - free_strlist (ctx->extra_list); - if( !ctx->not_allocated ) - xfree( ctx ); + if (ctx) + { + memset (&ctx->kbpos, 0, sizeof ctx->kbpos); + keydb_release (ctx->kr_handle); + free_strlist (ctx->extra_list); + if (!ctx->not_allocated) + xfree (ctx); } } -/**************** - * Search for a key with the given fingerprint. +/* Search for a key with the given fingerprint. * FIXME: - * We should replace this with the _byname function. Thiscsan be done - * by creating a userID conforming to the unified fingerprint style. + * We should replace this with the _byname function. This can be done + * by creating a userID conforming to the unified fingerprint style. */ int -get_pubkey_byfprint( PKT_public_key *pk, - const byte *fprint, size_t fprint_len) +get_pubkey_byfprint (PKT_public_key * pk, + const byte * fprint, size_t fprint_len) { - int rc; + int rc; - if( fprint_len == 20 || fprint_len == 16 ) { - struct getkey_ctx_s ctx; - KBNODE kb = NULL; + if (fprint_len == 20 || fprint_len == 16) + { + struct getkey_ctx_s ctx; + KBNODE kb = NULL; - memset( &ctx, 0, sizeof ctx ); - ctx.exact = 1 ; - ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (0); - ctx.nitems = 1; - ctx.items[0].mode = fprint_len==16? KEYDB_SEARCH_MODE_FPR16 - : KEYDB_SEARCH_MODE_FPR20; - memcpy( ctx.items[0].u.fpr, fprint, fprint_len ); - rc = lookup( &ctx, &kb, 0 ); - if (!rc && pk ) - pk_from_block ( &ctx, pk, kb ); - release_kbnode ( kb ); - get_pubkey_end( &ctx ); + memset (&ctx, 0, sizeof ctx); + ctx.exact = 1; + ctx.not_allocated = 1; + ctx.kr_handle = keydb_new (0); + ctx.nitems = 1; + ctx.items[0].mode = fprint_len == 16 ? KEYDB_SEARCH_MODE_FPR16 + : KEYDB_SEARCH_MODE_FPR20; + memcpy (ctx.items[0].u.fpr, fprint, fprint_len); + rc = lookup (&ctx, &kb, 0); + if (!rc && pk) + pk_from_block (&ctx, pk, kb); + release_kbnode (kb); + get_pubkey_end (&ctx); } - else - rc = G10ERR_GENERAL; /* Oops */ - return rc; + else + rc = G10ERR_GENERAL; /* Oops */ + return rc; } @@ -991,20 +1019,20 @@ differs from get_pubkey_byfprint() in that it does not do a check of the key to avoid recursion. It should be used only in very certain cases. PK may be NULL to check just for the existance of - the key. */ + the key. */ int -get_pubkey_byfprint_fast (PKT_public_key *pk, - const byte *fprint, size_t fprint_len) +get_pubkey_byfprint_fast (PKT_public_key * pk, From cvs at cvs.gnupg.org Sun Jan 10 15:06:50 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Sun, 10 Jan 2010 15:06:50 +0100 Subject: [svn] GnuPG - r5249 - branches/STABLE-BRANCH-2-0/tools Message-ID: Author: wk Date: 2010-01-10 15:06:49 +0100 (Sun, 10 Jan 2010) New Revision: 5249 Modified: branches/STABLE-BRANCH-2-0/tools/ChangeLog branches/STABLE-BRANCH-2-0/tools/symcryptrun.c Log: Remove unused utmp.h. Modified: branches/STABLE-BRANCH-2-0/tools/ChangeLog =================================================================== --- branches/STABLE-BRANCH-2-0/tools/ChangeLog 2010-01-09 19:00:46 UTC (rev 5248) +++ branches/STABLE-BRANCH-2-0/tools/ChangeLog 2010-01-10 14:06:49 UTC (rev 5249) @@ -1,3 +1,7 @@ +2010-01-10 Werner Koch + + * symcryptrun.c (utmp.h): Remove header; it is not used. + 2009-12-18 Werner Koch * applygnupgdefaults (errorfile): Use mktemp. Fixes bug#1146. Modified: branches/STABLE-BRANCH-2-0/tools/symcryptrun.c =================================================================== --- branches/STABLE-BRANCH-2-0/tools/symcryptrun.c 2010-01-09 19:00:46 UTC (rev 5248) +++ branches/STABLE-BRANCH-2-0/tools/symcryptrun.c 2010-01-10 14:06:49 UTC (rev 5249) @@ -74,7 +74,6 @@ #ifdef HAVE_PTY_H #include #endif -#include #include #ifdef HAVE_LOCALE_H #include From cvs at cvs.gnupg.org Mon Jan 11 13:30:22 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 11 Jan 2010 13:30:22 +0100 Subject: [svn] gpgme - r1447 - trunk Message-ID: Author: marcus Date: 2010-01-11 13:30:22 +0100 (Mon, 11 Jan 2010) New Revision: 1447 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: 2010-01-11 Marcus Brinkmann Release 1.3.0. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-08 19:15:06 UTC (rev 1446) +++ trunk/ChangeLog 2010-01-11 12:30:22 UTC (rev 1447) @@ -1,3 +1,7 @@ +2010-01-11 Marcus Brinkmann + + Release 1.3.0. + 2009-12-22 Marcus Brinkmann * configure.ac: Do not use echo -n. Test for __thread. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-08 19:15:06 UTC (rev 1446) +++ trunk/NEWS 2010-01-11 12:30:22 UTC (rev 1447) @@ -1,4 +1,4 @@ -Noteworthy changes in version 1.3.0 (unreleased) +Noteworthy changes in version 1.3.0 (2010-01-11) ------------------------------------------------ * GPGME does not come with an internal libassuan version anymore. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-08 19:15:06 UTC (rev 1446) +++ trunk/configure.ac 2010-01-11 12:30:22 UTC (rev 1447) @@ -33,7 +33,7 @@ # SVN version is the most recent one in a branch. To disable the SVN # version for the real release, set the my_issvn macro to no. m4_define(my_version, [1.3.0]) -m4_define(my_issvn, [yes]) +m4_define(my_issvn, [no]) m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Mon Jan 11 13:31:08 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 11 Jan 2010 13:31:08 +0100 Subject: [svn] assuan - r347 - trunk Message-ID: Author: marcus Date: 2010-01-11 13:31:07 +0100 (Mon, 11 Jan 2010) New Revision: 347 Modified: trunk/NEWS Log: Change history. Urgs. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-08 09:59:54 UTC (rev 346) +++ trunk/NEWS 2010-01-11 12:31:07 UTC (rev 347) @@ -1,4 +1,4 @@ -Noteworthy changes in version 2.0.0 (2009-01-08) +Noteworthy changes in version 2.0.0 (2010-01-08) ------------------------------------------------ * Now using libtool and builds a DSO. From cvs at cvs.gnupg.org Mon Jan 11 13:41:54 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 11 Jan 2010 13:41:54 +0100 Subject: [svn] gpgme - r1448 - branches Message-ID: Author: marcus Date: 2010-01-11 13:41:54 +0100 (Mon, 11 Jan 2010) New Revision: 1448 Added: branches/gpgme-1.3.0/ Log: Tag release. From cvs at cvs.gnupg.org Mon Jan 11 13:43:00 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 11 Jan 2010 13:43:00 +0100 Subject: [svn] gpgme - r1449 - trunk Message-ID: Author: marcus Date: 2010-01-11 13:42:59 +0100 (Mon, 11 Jan 2010) New Revision: 1449 Modified: trunk/NEWS trunk/configure.ac Log: Post-release fixup. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-11 12:41:54 UTC (rev 1448) +++ trunk/NEWS 2010-01-11 12:42:59 UTC (rev 1449) @@ -1,3 +1,9 @@ +Noteworthy changes in version 1.3.1 (unreleased) +------------------------------------------------ + + * Under development. + + Noteworthy changes in version 1.3.0 (2010-01-11) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-11 12:41:54 UTC (rev 1448) +++ trunk/configure.ac 2010-01-11 12:42:59 UTC (rev 1449) @@ -32,8 +32,8 @@ # specific feature can already be done under the assumption that the # SVN version is the most recent one in a branch. To disable the SVN # version for the real release, set the my_issvn macro to no. -m4_define(my_version, [1.3.0]) -m4_define(my_issvn, [no]) +m4_define(my_version, [1.3.1]) +m4_define(my_issvn, [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Mon Jan 11 13:44:34 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 11 Jan 2010 13:44:34 +0100 Subject: [svn] assuan - r348 - trunk Message-ID: Author: marcus Date: 2010-01-11 13:44:33 +0100 (Mon, 11 Jan 2010) New Revision: 348 Modified: trunk/NEWS Log: Post release fixup. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-11 12:31:07 UTC (rev 347) +++ trunk/NEWS 2010-01-11 12:44:33 UTC (rev 348) @@ -1,3 +1,9 @@ +Noteworthy changes in version 2.0.1 (unreleased) +------------------------------------------------ + + * Under development. + + Noteworthy changes in version 2.0.0 (2010-01-08) ------------------------------------------------ From cvs at cvs.gnupg.org Mon Jan 11 14:47:42 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 11 Jan 2010 14:47:42 +0100 Subject: [svn] gpgme - r1450 - tags Message-ID: Author: wk Date: 2010-01-11 14:47:42 +0100 (Mon, 11 Jan 2010) New Revision: 1450 Added: tags/gpgme-1.3.0/ Log: Release tags should be done below tags/ From cvs at cvs.gnupg.org Mon Jan 11 17:05:27 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 11 Jan 2010 17:05:27 +0100 Subject: [svn] GnuPG - r5250 - in branches/STABLE-BRANCH-2-0: . doc g10 Message-ID: Author: wk Date: 2010-01-11 17:05:26 +0100 (Mon, 11 Jan 2010) New Revision: 5250 Modified: branches/STABLE-BRANCH-2-0/NEWS branches/STABLE-BRANCH-2-0/doc/gpg.texi branches/STABLE-BRANCH-2-0/g10/ChangeLog branches/STABLE-BRANCH-2-0/g10/gpg.c branches/STABLE-BRANCH-2-0/g10/keyedit.c branches/STABLE-BRANCH-2-0/g10/main.h branches/STABLE-BRANCH-2-0/g10/options.h branches/STABLE-BRANCH-2-0/g10/passphrase.c Log: Implement command --passwd for GPG. Modified: branches/STABLE-BRANCH-2-0/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-2-0/g10/ChangeLog 2010-01-10 14:06:49 UTC (rev 5249) +++ branches/STABLE-BRANCH-2-0/g10/ChangeLog 2010-01-11 16:05:26 UTC (rev 5250) @@ -1,3 +1,16 @@ +2010-01-11 Werner Koch + + * gpg.c: Add option --passwd. + (aPasswd): New. + (main): Implement. + * keyedit.c (keyedit_passwd): New. + + * gpg.c (oPasswd, oPasswdFD, oPasswdFile, oPasswdRepeat): Change + to oPassphrase, oPassphraseFD, oPassphraseFile, oPassphraseRepeat. + * options.h (struct): s/passwd_repeat/passphrase_repeat/. + * gpg.c (main): Ditto. + * passphrase.c (passphrase_to_dek_ext): Ditto. + 2009-12-21 Werner Koch * gpg.c (main): Add dummy options --skip-hidden-recipients and no Modified: branches/STABLE-BRANCH-2-0/NEWS =================================================================== --- branches/STABLE-BRANCH-2-0/NEWS 2010-01-10 14:06:49 UTC (rev 5249) +++ branches/STABLE-BRANCH-2-0/NEWS 2010-01-11 16:05:26 UTC (rev 5250) @@ -1,7 +1,9 @@ Noteworthy changes in version 2.0.15 (unreleased) ------------------------------------------------- + * New command --passwd for GPG. + Noteworthy changes in version 2.0.14 (2009-12-21) ------------------------------------------------- Modified: branches/STABLE-BRANCH-2-0/doc/gpg.texi =================================================================== --- branches/STABLE-BRANCH-2-0/doc/gpg.texi 2010-01-10 14:06:49 UTC (rev 5249) +++ branches/STABLE-BRANCH-2-0/doc/gpg.texi 2010-01-11 16:05:26 UTC (rev 5250) @@ -586,6 +586,7 @@ related tasks. It expects the specification of a key on the command line. + @c ******** Begin Edit-key Options ********** @table @asis @@ -888,6 +889,13 @@ non-exportable. This is a shortcut version of the subcommand "lsign" from @option{--edit-key}. + at ifclear gpgone + at item --passwd @var{user_id} + at opindex passwd +Change the passphrase of the secret key belonging to the certificate +specified as @var{user_id}. This is a shortcut for the sub-command + at code{passwd} in the edit key menu. + at end ifclear @end table Modified: branches/STABLE-BRANCH-2-0/g10/gpg.c =================================================================== --- branches/STABLE-BRANCH-2-0/g10/gpg.c 2010-01-10 14:06:49 UTC (rev 5249) +++ branches/STABLE-BRANCH-2-0/g10/gpg.c 2010-01-11 16:05:26 UTC (rev 5250) @@ -1,6 +1,6 @@ /* gpg.c - The GnuPG utility (main for gpg) * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - * 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + * 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -146,6 +146,7 @@ aCardStatus, aCardEdit, aChangePIN, + aPasswd, aServer, oTextmode, @@ -207,10 +208,10 @@ oCompressLevel, oBZ2CompressLevel, oBZ2DecompressLowmem, - oPasswd, - oPasswdFD, - oPasswdFile, - oPasswdRepeat, + oPassphrase, + oPassphraseFD, + oPassphraseFile, + oPassphraseRepeat, oCommandFD, oCommandFile, oQuickRandom, @@ -389,6 +390,7 @@ ARGPARSE_c (oFingerprint, "fingerprint", N_("list keys and fingerprints")), ARGPARSE_c (aListSecretKeys, "list-secret-keys", N_("list secret keys")), ARGPARSE_c (aKeygen, "gen-key", N_("generate a new key pair")), + ARGPARSE_c (aGenRevoke, "gen-revoke",N_("generate a revocation certificate")), ARGPARSE_c (aDeleteKeys,"delete-keys", N_("remove keys from the public keyring")), ARGPARSE_c (aDeleteSecretKeys, "delete-secret-keys", @@ -397,7 +399,7 @@ ARGPARSE_c (aLSignKey, "lsign-key" ,N_("sign a key locally")), ARGPARSE_c (aEditKey, "edit-key" ,N_("sign or edit a key")), ARGPARSE_c (aEditKey, "key-edit" ,"@"), - ARGPARSE_c (aGenRevoke, "gen-revoke",N_("generate a revocation certificate")), + ARGPARSE_c (aPasswd, "passwd", N_("change a passphrase")), ARGPARSE_c (aDesigRevoke, "desig-revoke","@" ), ARGPARSE_c (aExport, "export" , N_("export keys") ), ARGPARSE_c (aSendKeys, "send-keys" , N_("export keys to a key server") ), @@ -599,10 +601,10 @@ "delete-secret-and-public-keys", "@"), ARGPARSE_c (aRebuildKeydbCaches, "rebuild-keydb-caches", "@"), - ARGPARSE_s_s (oPasswd, "passphrase", "@"), - ARGPARSE_s_i (oPasswdFD, "passphrase-fd", "@"), - ARGPARSE_s_s (oPasswdFile, "passphrase-file", "@"), - ARGPARSE_s_i (oPasswdRepeat, "passphrase-repeat", "@"), + ARGPARSE_s_s (oPassphrase, "passphrase", "@"), + ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"), + ARGPARSE_s_s (oPassphraseFile, "passphrase-file", "@"), + ARGPARSE_s_i (oPassphraseRepeat,"passphrase-repeat", "@"), ARGPARSE_s_i (oCommandFD, "command-fd", "@"), ARGPARSE_s_s (oCommandFile, "command-file", "@"), ARGPARSE_s_n (oQuickRandom, "debug-quick-random", "@"), @@ -628,7 +630,6 @@ ARGPARSE_s_n (aListSigs, "list-sig", "@"), /* alias */ ARGPARSE_s_n (aCheckKeys, "check-sig", "@"), /* alias */ ARGPARSE_s_n (oSkipVerify, "skip-verify", "@"), - ARGPARSE_s_n (oSkipVerify, "skip-verify", "@"), ARGPARSE_s_n (oSkipHiddenRecipients, "skip-hidden-recipients", "@"), ARGPARSE_s_n (oNoSkipHiddenRecipients, "no-skip-hidden-recipients", "@"), ARGPARSE_s_n (oCompressKeys, "compress-keys", "@"), @@ -1430,6 +1431,7 @@ } +/* Print the OpenPGP defined algo numbers. */ static void print_algo_numbers(int (*checker)(int)) { @@ -1997,7 +1999,7 @@ opt.def_sig_expire="0"; opt.def_cert_expire="0"; set_homedir ( default_homedir () ); - opt.passwd_repeat=1; + opt.passphrase_repeat=1; /* Check whether we have a config file on the command line. */ orig_argc = argc; @@ -2179,6 +2181,7 @@ case aDeleteSecretKeys: case aDeleteSecretAndPublicKeys: case aDeleteKeys: + case aPasswd: set_cmd (&cmd, pargs.r_opt); greeting=1; break; @@ -2558,16 +2561,16 @@ case oCompressLevel: opt.compress_level = pargs.r.ret_int; break; case oBZ2CompressLevel: opt.bz2_compress_level = pargs.r.ret_int; break; case oBZ2DecompressLowmem: opt.bz2_decompress_lowmem=1; break; - case oPasswd: + case oPassphrase: set_passphrase_from_string(pargs.r.ret_str); break; - case oPasswdFD: + case oPassphraseFD: pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); break; - case oPasswdFile: + case oPassphraseFile: pwfd = open_info_file (pargs.r.ret_str, 0, 1); break; - case oPasswdRepeat: opt.passwd_repeat=pargs.r.ret_int; break; + case oPassphraseRepeat: opt.passphrase_repeat=pargs.r.ret_int; break; case oCommandFD: opt.command_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); break; @@ -3621,6 +3624,17 @@ xfree(username); break; + case aPasswd: + if (argc != 1) + wrong_args (_("--passwd ")); + else + { + username = make_username (fname); + keyedit_passwd (username); + xfree (username); + } + break; + case aDeleteKeys: case aDeleteSecretKeys: case aDeleteSecretAndPublicKeys: Modified: branches/STABLE-BRANCH-2-0/g10/keyedit.c =================================================================== --- branches/STABLE-BRANCH-2-0/g10/keyedit.c 2010-01-10 14:06:49 UTC (rev 5249) +++ branches/STABLE-BRANCH-2-0/g10/keyedit.c 2010-01-11 16:05:26 UTC (rev 5250) @@ -1,6 +1,6 @@ /* keyedit.c - keyedit stuff * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - * 2008, 2009 Free Software Foundation, Inc. + * 2008, 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -2299,6 +2299,72 @@ xfree(answer); } + +/* Change the passphrase of the secret key identified by USERNAME. */ +void +keyedit_passwd (const char *username) +{ + gpg_error_t err; + PKT_public_key *pk; + unsigned char fpr[MAX_FINGERPRINT_LEN]; + size_t fprlen; + KEYDB_HANDLE kdh = NULL; + KBNODE keyblock = NULL; + + pk = xtrycalloc (1, sizeof *pk); + if (!pk) + { + err = gpg_error_from_syserror (); + goto leave; + } + err = get_pubkey_byname (NULL, pk, username, NULL, NULL, 1, 1); + if (err) + goto leave; + fingerprint_from_pk (pk, fpr, &fprlen); + while (fprlen < MAX_FINGERPRINT_LEN) + fpr[fprlen++] = 0; + + kdh = keydb_new (1); + if (!kdh) + { + err = gpg_error (GPG_ERR_GENERAL); + goto leave; + } + + err = keydb_search_fpr (kdh, fpr); + if (err == -1 || gpg_err_code (err) == GPG_ERR_EOF) + err = gpg_error (GPG_ERR_NO_SECKEY); + if (err) + goto leave; + + err = keydb_get_keyblock (kdh, &keyblock); + if (err) + goto leave; + + if (!change_passphrase (keyblock)) + { + err = gpg_error (GPG_ERR_GENERAL); + goto leave; + } + + err = keydb_update_keyblock (kdh, keyblock); + if (err) + log_error( _("update secret failed: %s\n"), gpg_strerror (err)); + + leave: + release_kbnode (keyblock); + if (pk) + free_public_key (pk); + keydb_release (kdh); + if (err) + { + log_info ("error changing the passphrase for `%s': %s\n", + username, gpg_strerror (err)); + write_status_error ("keyedit.passwd", gpg_err_code (err)); + } +} + + static void tty_print_notations(int indent,PKT_signature *sig) { Modified: branches/STABLE-BRANCH-2-0/g10/main.h =================================================================== --- branches/STABLE-BRANCH-2-0/g10/main.h 2010-01-10 14:06:49 UTC (rev 5249) +++ branches/STABLE-BRANCH-2-0/g10/main.h 2010-01-11 16:05:26 UTC (rev 5250) @@ -213,6 +213,7 @@ /*-- keyedit.c --*/ void keyedit_menu( const char *username, strlist_t locusr, strlist_t commands, int quiet, int seckey_check ); +void keyedit_passwd (const char *username); void show_basic_key_info (KBNODE keyblock); /*-- keygen.c --*/ Modified: branches/STABLE-BRANCH-2-0/g10/options.h =================================================================== --- branches/STABLE-BRANCH-2-0/g10/options.h 2010-01-10 14:06:49 UTC (rev 5249) +++ branches/STABLE-BRANCH-2-0/g10/options.h 2010-01-11 16:05:26 UTC (rev 5250) @@ -246,7 +246,7 @@ struct akl *next; } *auto_key_locate; - int passwd_repeat; + int passphrase_repeat; } opt; /* CTRL is used to keep some global variables we currently can't Modified: branches/STABLE-BRANCH-2-0/g10/passphrase.c =================================================================== --- branches/STABLE-BRANCH-2-0/g10/passphrase.c 2010-01-10 14:06:49 UTC (rev 5249) +++ branches/STABLE-BRANCH-2-0/g10/passphrase.c 2010-01-11 16:05:26 UTC (rev 5250) @@ -644,7 +644,7 @@ /* Divert to the gpg-agent. */ pw = passphrase_get (keyid, mode == 2, s2k_cacheid, - (mode == 2 || mode == 4)? opt.passwd_repeat : 0, + (mode == 2 || mode == 4)? opt.passphrase_repeat : 0, tryagain_text, custdesc, custprompt, canceled); if (*canceled) { From cvs at cvs.gnupg.org Tue Jan 12 21:27:13 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 12 Jan 2010 21:27:13 +0100 Subject: [svn] GpgOL - r331 - in trunk: . po src Message-ID: Author: wk Date: 2010-01-12 21:27:12 +0100 (Tue, 12 Jan 2010) New Revision: 331 Modified: trunk/ChangeLog trunk/po/POTFILES.in trunk/po/de.po trunk/po/sv.po trunk/src/ChangeLog trunk/src/decrypt-verify-16.bmp trunk/src/decrypt-verify-16m.bmp trunk/src/decrypt-verify-32.bmp trunk/src/decrypt-verify-32m.bmp trunk/src/verify-16.bmp trunk/src/verify-32.bmp trunk/src/verify-32m.bmp Log: Icon updates and icnlude new source files into POTFILES Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-08 15:44:03 UTC (rev 330) +++ trunk/ChangeLog 2010-01-12 20:27:12 UTC (rev 331) @@ -1,3 +1,7 @@ +2010-01-12 Werner Koch + + * po/POTFILES.in (explorers.cpp, inspectors.cpp, mailitem.cpp): New. + 2010-01-08 Werner Koch * forms/encr-s.ico, forms/sign-s.ico: Fix them. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-08 15:44:03 UTC (rev 330) +++ trunk/src/ChangeLog 2010-01-12 20:27:12 UTC (rev 331) @@ -1,3 +1,10 @@ +2010-01-12 Werner Koch + + * decrypt-verify-16.bmp, decrypt-verify-16m.bmp: Update. + * decrypt-verify-32.bmp, decrypt-verify-32m.bmp: Update. + * verify-16.bmp, verify-16m.bmp: Update. + * verify-32m.bmp, verify-32.bmp: Update. + 2010-01-08 Werner Koch * README.icons: Fix instructions for forms icons. Modified: trunk/po/POTFILES.in =================================================================== --- trunk/po/POTFILES.in 2010-01-08 15:44:03 UTC (rev 330) +++ trunk/po/POTFILES.in 2010-01-12 20:27:12 UTC (rev 331) @@ -21,3 +21,7 @@ src/rfc822parse.c src/verify-dialog.c src/w32-gettext.c +src/inspectors.cpp +src/explorers.cpp +src/mailitem.cpp + Modified: trunk/po/de.po [not shown] Modified: trunk/po/sv.po [not shown] Modified: trunk/src/decrypt-verify-16.bmp =================================================================== (Binary files differ) Modified: trunk/src/decrypt-verify-16m.bmp =================================================================== (Binary files differ) Modified: trunk/src/decrypt-verify-32.bmp =================================================================== (Binary files differ) Modified: trunk/src/decrypt-verify-32m.bmp =================================================================== (Binary files differ) Modified: trunk/src/verify-16.bmp =================================================================== (Binary files differ) Modified: trunk/src/verify-32.bmp =================================================================== (Binary files differ) Modified: trunk/src/verify-32m.bmp =================================================================== (Binary files differ) From cvs at cvs.gnupg.org Wed Jan 13 12:17:33 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 13 Jan 2010 12:17:33 +0100 Subject: [svn] GpgOL - r332 - in trunk: . src Message-ID: Author: wk Date: 2010-01-13 12:17:32 +0100 (Wed, 13 Jan 2010) New Revision: 332 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac trunk/src/ChangeLog trunk/src/README.icons Log: Prepare a release Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-12 20:27:12 UTC (rev 331) +++ trunk/ChangeLog 2010-01-13 11:17:32 UTC (rev 332) @@ -1,3 +1,7 @@ +2010-01-13 Werner Koch + + Release 1.1.1. + 2010-01-12 Werner Koch * po/POTFILES.in (explorers.cpp, inspectors.cpp, mailitem.cpp): New. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-12 20:27:12 UTC (rev 331) +++ trunk/src/ChangeLog 2010-01-13 11:17:32 UTC (rev 332) @@ -1,3 +1,8 @@ +2010-01-13 Werner Koch + + * README.icons: Change instructions to better cope with alpha + channels. + 2010-01-12 Werner Koch * decrypt-verify-16.bmp, decrypt-verify-16m.bmp: Update. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-12 20:27:12 UTC (rev 331) +++ trunk/NEWS 2010-01-13 11:17:32 UTC (rev 332) @@ -1,3 +1,9 @@ +Noteworthy changes for version 1.1.1 (2010-01-13) +================================================= + + * Cleaned up some icons. + + Noteworthy changes for version 1.1.0 (2010-01-05) ================================================= Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-12 20:27:12 UTC (rev 331) +++ trunk/configure.ac 2010-01-13 11:17:32 UTC (rev 332) @@ -16,7 +16,7 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [1.1.0]) +m4_define([my_version], [1.1.1]) m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ Modified: trunk/src/README.icons =================================================================== --- trunk/src/README.icons 2010-01-12 20:27:12 UTC (rev 331) +++ trunk/src/README.icons 2010-01-13 11:17:32 UTC (rev 332) @@ -39,40 +39,36 @@ This PNG should have a transparent background. If not, you may use Gimp to wipe the background out. - 2. Select Select->By_Color, click on the transparent area. Use - "Bucket Fill" to fill with white (0xffffff). + 2. Select Select->By_Color, click on the transparent area. + Change the background color to white (0xffffff) and run + Layer->Transparency->Remove_Alpha_Channel. - 3. Run Image->Flatten_Image. - - 4. Select Image->Mode->Indexed, click "Generate optimum palette with + 3. Select Image->Mode->Indexed, click "Generate optimum palette with 255 colors", click "Convert". - 5. Select File->SaveAs and enter a file name with suffix ".bmp". + 4. Select File->SaveAs and enter a file name with suffix ".bmp". The name should be like "foo-16.bmp". Do _not_ select "Run-Length Encoded". Click "Save". - 6. Undo all or reload the image. Note that if you don't undo step 2 - you may skip step 7. + 5. Undo all or reload the image. Note that if you don't undo step 2 + you may skip step 6. - 7. Select Select->By_Color, click on the transparent area. Use - "Bucket Fill" to fill with white (0xffffff). + 6. Select Select->By_Color, click on the transparent area. + Change the background color to white (0xffffff) and run + Layer->Transparency->Remove_Alpha_Channel. - 8. Select Select->Invert. Use "Bucket Fill" to fill the now + 7. Select Select->Invert. Use "Bucket Fill" to fill the now selected non-transparent area with black (0x000000). "Fill whole selection" comes handy here. Make sure that you have a only black and white and no other colored pixels. - 9. Run Image->Flatten_Image. - - 10. Select Image->Mode->Indexed, click "Use black and white (1-bit) + 8. Select Image->Mode->Indexed, click "Use black and white (1-bit) palette", click "Convert". - 11. Select File->SaveAs and enter a file name with suffix ".bmp". + 9. Select File->SaveAs and enter a file name with suffix ".bmp". This is the mask thus the name should be like "foo-16m.bmp". Do _not_ select "Run-Length Encoded". Click "Save". - 12. Done. - If required, do this also for 32x32 and 64x64. From cvs at cvs.gnupg.org Wed Jan 13 12:33:40 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 13 Jan 2010 12:33:40 +0100 Subject: [svn] GpgOL - r333 - tags Message-ID: Author: wk Date: 2010-01-13 12:33:39 +0100 (Wed, 13 Jan 2010) New Revision: 333 Added: tags/gpgol-1.1.1/ Log: Release tag. From cvs at cvs.gnupg.org Thu Jan 14 22:16:56 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 14 Jan 2010 22:16:56 +0100 Subject: [svn] assuan - r349 - trunk/src Message-ID: Author: wk Date: 2010-01-14 22:16:55 +0100 (Thu, 14 Jan 2010) New Revision: 349 Modified: trunk/src/ChangeLog trunk/src/assuan.c trunk/src/debug.c Log: Fix NULL de-reference in debug code. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-11 12:44:33 UTC (rev 348) +++ trunk/src/ChangeLog 2010-01-14 21:16:55 UTC (rev 349) @@ -1,3 +1,10 @@ +2010-01-14 Werner Koch + + * debug.c (_assuan_debug, _assuan_debug_begin) + (_assuan_debug_buffer): Check CTX before dereferencing. + + * assuan.c (assuan_release): Immediately leave on NULL CTX. + 2010-01-05 Marcus Brinkmann * debug.h (TRACE_LOG5): Add macro. Modified: trunk/src/assuan.c =================================================================== --- trunk/src/assuan.c 2010-01-11 12:44:33 UTC (rev 348) +++ trunk/src/assuan.c 2010-01-14 21:16:55 UTC (rev 349) @@ -176,11 +176,11 @@ void assuan_release (assuan_context_t ctx) { - TRACE (ctx, ASSUAN_LOG_CTX, "assuan_release", ctx); - if (! ctx) return; + TRACE (ctx, ASSUAN_LOG_CTX, "assuan_release", ctx); + _assuan_reset (ctx); /* None of the members that are our responsibility requires deallocation. */ Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2010-01-11 12:44:33 UTC (rev 348) +++ trunk/src/debug.c 2010-01-14 21:16:55 UTC (rev 349) @@ -49,7 +49,7 @@ char *msg; int res; - if (ctx->log_cb == NULL) + if (!ctx || !ctx->log_cb) return; saved_errno = errno; @@ -75,8 +75,9 @@ *line = NULL; /* Probe if this wants to be logged based on category. */ - if (! ctx->log_cb || - ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL)) + if (! ctx + || ! ctx->log_cb + || ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL)) return; va_start (arg_ptr, format); @@ -144,8 +145,9 @@ int j; /* Probe if this wants to be logged based on category. */ - if (! ctx->log_cb || - ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL)) + if (!ctx + || ! ctx->log_cb + || ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL)) return; while (idx < len) From cvs at cvs.gnupg.org Mon Jan 18 16:10:38 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 18 Jan 2010 16:10:38 +0100 Subject: [svn] gpg-error - r226 - in trunk: . src src/gpg-extra tests Message-ID: Author: wk Date: 2010-01-18 16:10:37 +0100 (Mon, 18 Jan 2010) New Revision: 226 Added: trunk/src/gpg-error.def.in trunk/src/gpg-extra/ trunk/src/gpg-extra/errno.h trunk/src/w32ce-add.h Removed: trunk/src/gpg-error.def Modified: trunk/ChangeLog trunk/NEWS trunk/autogen.sh trunk/configure.ac trunk/ltmain.sh trunk/src/Makefile.am trunk/src/gpg-error-config.in trunk/src/gpg-error.c trunk/src/gpg-error.h.in trunk/src/init.c trunk/src/mkheader.awk trunk/src/w32-gettext.c trunk/src/w32-gettext.h trunk/tests/Makefile.am trunk/tests/t-syserror.c Log: Add some code to build nativley under WindowsCE - not finished. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/ChangeLog 2010-01-18 15:10:37 UTC (rev 226) @@ -1,3 +1,40 @@ +2010-01-18 Werner Koch + + * ltmain.sh (wrappers_required): Don't set for mingw32ce. + + * tests/Makefile.am (extra_includes): New. + * tests/t-syserror.c (main): Use gpg_err_set_errno. + + * src/w32ce-add.h: New. + * src/Makefile.am (EXTRA_DIST): Add it + (extra-h.in): New rule + (gpg-error.h): Pass extra-h.in to mkheader. + * src/mkheader.awk (extra_body): New. + + * src/gpg-error.c (get_err_from_number): Use gpg_err_set_errno. + + * src/mkw32errmap.c: New + * src/gpg-error.def: Rename to .. + * src/gpg-error.def.in: .. this. + (_gpg_errno_location): New. + * src/init.c (struct tls_space_s, tls_index): New. + (get_tls, _gpg_errno_location, DllMain): New. + (read_w32_registry_string) [W32CE]: Don't expand envvars. + (_gpg_w32ce_strerror): New. + * src/Makefile.am (extra_headers, extra_cppflags): New. + (include_HEADERS): Add extra_headers. Prefix with nobase_. + (libgpg_error_la_CPPFLAGS, gpg_error_CPPFLAGS) + (mkerrcodes.h): Add extra_cppflags. + (RCCOMPILE): Replace libgpg_error_la_CPPFLAGS by direct inclusion + of -DLOCALEDIR. + * configure.ac (HAVE_W32CE_SYSTEM): New AM_CONDITIONAL and + AC_DEFINE. + (GPG_ERROR_CONFIG_ISUBDIRAFTER): New. + * src/gpg-error-config.in <--libs>: Replace fixed -lgpg-error + by subst variable. + (isubdirafter): New. + <--cflags>: Take subst variable in account. Add idirafter stuff. + 2009-10-26 Marcus Brinkmann * src/gpg-error.h.in (GPG_ERR_SOURCE_DIM): Reduce to 128. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/NEWS 2010-01-18 15:10:37 UTC (rev 226) @@ -1,13 +1,16 @@ Noteworthy changes in version 1.8 ---------------------------------------------- + * Preliminary support for WindowsCE. + * Interface changes relative to the 1.7 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - GPG_ERR_NOT_ENABLED NEW - GPG_ERR_SOURCE_G13 NEW + GPG_ERR_NOT_ENABLED NEW. + GPG_ERR_SOURCE_G13 NEW. GPG_ERR_NO_ENGINE NEW. + gpg_err_set_errno NEW. + - Noteworthy changes in version 1.7 (2008-11-26) ---------------------------------------------- Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/autogen.sh 2010-01-18 15:10:37 UTC (rev 226) @@ -35,9 +35,26 @@ shift fi +# Convenience option to use certain configure options for some hosts. +myhost="" +myhostsub="" +case "$1" in + --build-w32) + myhost="w32" + ;; + --build-w32ce) + myhost="w32" + myhostsub="ce" + ;; + *) + ;; +esac + + + # ***** W32 build script ******* # Used to cross-compile for Windows. -if test "$1" = "--build-w32"; then +if [ "$myhost" = "w32" ]; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift @@ -47,12 +64,21 @@ fi build=`$tsdir/config.guess` - [ -z "$w32root" ] && w32root="$HOME/w32root" + case $myhostsub in + ce) + [ -z "$w32root" ] && w32root="$HOME/w32ce_root" + toolprefixes="arm-mingw32ce" + ;; + *) + [ -z "$w32root" ] && w32root="$HOME/w32root" + toolprefixes="i586-mingw32msvc i386-mingw32msvc" + ;; + esac echo "Using $w32root as standard install directory" >&2 # Locate the cross compiler crossbindir= - for host in i586-mingw32msvc i386-mingw32msvc; do + for host in $toolprefixes; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -61,8 +87,10 @@ done if [ -z "$crossbindir" ]; then echo "Cross compiler kit not installed" >&2 - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + if [ -z "$sub" ]; then + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fi echo "Stop." >&2 exit 1 fi Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/configure.ac 2010-01-18 15:10:37 UTC (rev 226) @@ -87,6 +87,10 @@ # Set some internal variables depending on the platform for later use. have_w32_system=no case "${host}" in + *-mingw32ce*) + have_w32_system=yes + have_w32ce_system=yes + ;; *-mingw32*) have_w32_system=yes ;; @@ -129,16 +133,21 @@ # Substitution used for gpg-error-config GPG_ERROR_CONFIG_LIBS="-lgpg-error" GPG_ERROR_CONFIG_CFLAGS="" +GPG_ERROR_CONFIG_ISUBDIRAFTER="" AC_SUBST(GPG_ERROR_CONFIG_LIBS) AC_SUBST(GPG_ERROR_CONFIG_CFLAGS) +AC_SUBST(GPG_ERROR_CONFIG_ISUBDIRAFTER) AC_CONFIG_FILES([src/gpg-error-config], [chmod +x src/gpg-error-config]) # Special defines for certain platforms if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1,[Defined if we run on a W32 API based system]) + if test "$have_w32ce_system" = yes; then + AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE]) + GPG_ERROR_CONFIG_ISUBDIRAFTER="gpg-extra" + fi BUILD_TIMESTAMP=`date --iso-8601=minutes` - AC_SUBST(BUILD_TIMESTAMP) changequote(,)dnl BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` changequote([,])dnl @@ -152,6 +161,7 @@ AC_SUBST(BUILD_TIMESTAMP) AC_SUBST(BUILD_FILEVERSION) AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) +AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes) AC_ARG_ENABLE(languages, Modified: trunk/ltmain.sh =================================================================== --- trunk/ltmain.sh 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/ltmain.sh 2010-01-18 15:10:37 UTC (rev 226) @@ -7680,15 +7680,15 @@ wrappers_required=yes case $host in + *cegcc | *mingw32ce* ) + # Disable wrappers for cegcc, we are cross compiling anyway. + wrappers_required=no + ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; - *cegcc) - # Disable wrappers for cegcc, we are cross compiling anyway. - wrappers_required=no - ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/src/Makefile.am 2010-01-18 15:10:37 UTC (rev 226) @@ -21,10 +21,19 @@ # because they are needed to build the po directory, and they don't # depend on the configuration anyway. + +if HAVE_W32CE_SYSTEM +extra_headers = gpg-extra/errno.h +extra_cppflags = -idirafter gpg-extra +else +extra_headers = +extra_cppflags = +endif + localedir = $(datadir)/locale bin_PROGRAMS = gpg-error lib_LTLIBRARIES = libgpg-error.la -include_HEADERS = gpg-error.h +nobase_include_HEADERS = gpg-error.h $(extra_headers) bin_SCRIPTS = gpg-error-config m4datadir = $(datadir)/aclocal m4data_DATA = gpg-error.m4 @@ -33,25 +42,26 @@ EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \ mkerrnos.awk errnos.in README \ mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \ - mkheader.awk gpg-error.h.in \ + mkheader.awk gpg-error.h.in mkw32errmap.c w32ce-add.h \ err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \ - gpg-error.def versioninfo.rc.in + gpg-error.def.in versioninfo.rc.in BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ - err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h + err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \ + gpg-error.def gpg-extra/errno.h extra-h.in -tmp_files = _mkerrcodes.h +tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ - gpg-error.h mkerrcodes mkerrcodes.h \ - err-sources-sym.h err-codes-sym.h errnos-sym.h $(tmp_files) + gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ + err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-extra/errno.h \ + extra-h.in $(tmp_files) - if HAVE_W32_SYSTEM arch_sources = w32-gettext.h w32-gettext.c RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(libgpg_error_la_CPPFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) + -DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS) LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE) SUFFIXES = .rc .lo @@ -63,7 +73,7 @@ no_undefined = -no-undefined export_symbols = -export-symbols $(srcdir)/gpg-error.def -install-def-file: +install-def-file: gpg-error.def $(INSTALL) gpg-error.def $(DESTDIR)$(libdir)/gpg-error.def uninstall-def-file: @@ -92,11 +102,14 @@ libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \ init.c strsource.c strerror.c code-to-errno.c code-from-errno.c -libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" +# Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but +# without the extra_cppflags because they may include am -idirafter +# which is not supported by the RC compiler. +libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags) libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c $(arch_sources) -gpg_error_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" +gpg_error_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags) gpg_error_LDADD = ./libgpg-error.la @LTLIBINTL@ err-sources.h: Makefile mkstrtable.awk err-sources.h.in @@ -119,16 +132,41 @@ $(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@ # It is correct to use $(CPP). We want the host's idea of the error codes. -mkerrcodes.h: Makefile mkerrcodes.awk +mkerrcodes.h: Makefile mkerrcodes.awk $(extra_headers) $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@ - $(CPP) _$@ | grep GPG_ERR_ | $(AWK) -f $(srcdir)/mkerrcodes.awk >$@ + $(CPP) $(extra_cppflags) _$@ | grep GPG_ERR_ | \ + $(AWK) -f $(srcdir)/mkerrcodes.awk >$@ -rm _$@ +if HAVE_W32CE_SYSTEM +# It is correct to use $(CPP). We want the host's idea of the error codes. +mkw32errmap.tab.h: Makefile mkw32errmap.c + $(CPP) -DRESOLVE_MACROS $(srcdir)/mkw32errmap.c | \ + grep '{&mkw32errmap_marker' >$@ +gpg-extra/errno.h: mkw32errmap + ./mkw32errmap > $@ +endif + +# We use CC proper for preprocessing thus we have to convince it that +# the data is really to be preprocessed. +gpg-error.def: Makefile gpg-error.def.in + cat $(srcdir)/gpg-error.def.in >_$@.h + $(CPP) $(DEFAULT_INCLUDES) $(INCLUDES) $(extra_cppflags) _$@.h | \ + grep -v '^#' >$@ + -rm _$@.h + # It is correct to use $(CC_FOR_BUILD) here. We want to run the # program at build time. mkerrcodes: mkerrcodes.c mkerrcodes.h Makefile $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c +if HAVE_W32CE_SYSTEM +# It is correct to use $(CC_FOR_BUILD) here. We want to run the +# program at build time. +mkw32errmap: mkw32errmap.c mkw32errmap.tab.h Makefile + $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkw32errmap.c +endif + code-from-errno.h: mkerrcodes Makefile ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@ @@ -137,10 +175,18 @@ -v prefix=GPG_ERR_ -v namespace=errnos_ \ $(srcdir)/errnos.in >$@ -gpg-error.h: Makefile mkheader.awk \ - err-sources.h.in err-codes.h.in errnos.in gpg-error.h.in +extra-h.in: Makefile w32ce-add.h + -rm extra-h.in +if HAVE_W32CE_SYSTEM + cat $(srcdir)/w32ce-add.h >extra-h.in +endif + echo EOF >>extra-h.in + +gpg-error.h: Makefile mkheader.awk err-sources.h.in err-codes.h.in \ + errnos.in extra-h.in gpg-error.h.in $(AWK) -f $(srcdir)/mkheader.awk \ $(srcdir)/err-sources.h.in \ $(srcdir)/err-codes.h.in \ $(srcdir)/errnos.in \ + extra-h.in \ $(srcdir)/gpg-error.h.in > $@ Modified: trunk/src/gpg-error-config.in =================================================================== --- trunk/src/gpg-error-config.in 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/src/gpg-error-config.in 2010-01-18 15:10:37 UTC (rev 226) @@ -14,6 +14,7 @@ exec_prefix=@exec_prefix@ includedir=@includedir@ libdir=@libdir@ +isubdirafter="@GPG_ERROR_CONFIG_ISUBDIRAFTER@" output="" @@ -60,12 +61,18 @@ if test "x$includedir" != "x/usr/include" -a "x$includedir" != "x/include"; then output="$output -I$includedir" fi + # Note: -idirafter is a gcc extension. It is only used on + # systems where gcc is the only compiler we support. + for i in $isubdirafter; do + output="$output -idirafter ${includedir}/${i}" + done + output="$output @GPG_ERROR_CONFIG_CFLAGS@" ;; --libs) if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/lib"; then output="$output -L$libdir" fi - output="$output -lgpg-error" + output="$output @GPG_ERROR_CONFIG_LIBS@" ;; *) usage 1 1>&2 Modified: trunk/src/gpg-error.c =================================================================== --- trunk/src/gpg-error.c 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/src/gpg-error.c 2010-01-18 15:10:37 UTC (rev 226) @@ -71,7 +71,11 @@ setlocale (LC_TIME, ""); setlocale (LC_MESSAGES, ""); # else - setlocale (LC_ALL, "" ); +# ifdef HAVE_W32_SYSTEM +# warning setlocal is missing +# else + setlocale (LC_ALL, "" ); +# endif # endif locale_dir = get_locale_dir (); @@ -158,6 +162,7 @@ goto leave; } result[nbytes] = 0; /* make sure it is really a string */ +#ifndef HAVE_W32CE_SYSTEM if (type == REG_EXPAND_SZ && strchr (result, '%')) { char *tmp; @@ -196,6 +201,7 @@ free (tmp); } } +#endif /*HAVE_W32CE_SYSTEM*/ leave: RegCloseKey( key_handle ); @@ -255,7 +261,7 @@ unsigned long nr; char *tail; - errno = 0; + gpg_err_set_errno (0); nr = strtoul (str, &tail, 0); if (errno) return 0; Deleted: trunk/src/gpg-error.def Copied: trunk/src/gpg-error.def.in (from rev 225, trunk/src/gpg-error.def) =================================================================== --- trunk/src/gpg-error.def.in (rev 0) +++ trunk/src/gpg-error.def.in 2010-01-18 15:10:37 UTC (rev 226) @@ -0,0 +1,20 @@ +/* gpg-error.def.in - Exported symbols + * Needs to be processed by CPP. + */ + +#include + +EXPORTS + gpg_strerror @1 + gpg_strerror_r @2 + gpg_strsource @3 + gpg_err_code_from_errno @4 + gpg_err_code_to_errno @5 + gpg_err_init @6 + gpg_err_code_from_syserror @7 +#ifdef HAVE_W32CE_SYSTEM + _gpg_w32ce_strerror @8 + _gpg_w32ce_get_errno @9 +#endif + gpg_err_set_errno @10 + Property changes on: trunk/src/gpg-error.def.in ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:mergeinfo + Name: svn:eol-style + native Modified: trunk/src/gpg-error.h.in =================================================================== --- trunk/src/gpg-error.h.in 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/src/gpg-error.h.in 2010-01-18 15:10:37 UTC (rev 226) @@ -1,5 +1,5 @@ /* gpg-error.h - Public interface to libgpg-error. - Copyright (C) 2003, 2004 g10 Code GmbH + Copyright (C) 2003, 2004, 2010 g10 Code GmbH This file is part of libgpg-error. @@ -14,10 +14,10 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with libgpg-error; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + License along with this program; if not, see . + */ + #ifndef GPG_ERROR_H #define GPG_ERROR_H 1 @@ -231,7 +231,11 @@ gpg_err_code_t gpg_err_code_from_syserror (void); +/* Set the ERRNO variable. This function is the preferred way to set + ERRNO due to peculiarities on WindowsCE. */ +void gpg_err_set_errno (int err); + at include extra-h.in /* Self-documenting convenience functions. */ Added: trunk/src/gpg-extra/errno.h =================================================================== --- trunk/src/gpg-extra/errno.h (rev 0) +++ trunk/src/gpg-extra/errno.h 2010-01-18 15:10:37 UTC (rev 226) @@ -0,0 +1,60 @@ +/* errno.h - WindowsCE errno.h substitute + Copyright (C) 2010 g10 Code GmbH + + 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. + + +++ Do not edit! File has been generated by mkw32errmap.c +++ + + This file is intended to be used with ming32ce-gcc to implement an + errno substitute under WindowsCE. It must be included via gcc's + -idirafter option. The gpg-error-config script emits the + appropriate option snippet. The actual implementation of the errno + related functions are part of libgpg-error. A separate header file + is required because errno.h is often included before gpg-error.h. + */ + +#ifndef _GPG_ERROR_EXTRA_ERRNO_H +#define _GPG_ERROR_EXTRA_ERRNO_H + +/* Due to peculiarities in W32 we can't implement ERRNO as an + writable lvalue. This also allows us to easily find places + where ERRNO is being written to. See also gpg_err_set_errno. */ +int _gpg_w32ce_get_errno (void); +#define errno (_gpg_w32ce_get_errno ()) + +#define ENOENT 2 +#define EMFILE 4 +#define EACCES 5 +#define EBADF 6 +#define ENOMEM 8 +#define EXDEV 17 +#define ENFILE 18 +#define EROFS 19 +#define ENOLCK 36 +#define ENOSYS 50 +#define EEXIST 80 +#define EPERM 82 +#define EINVAL 87 +#define EINTR 104 +#define EPIPE 109 +#define ENOSPC 112 +#define ENOTEMPTY 145 +#define EBUSY 170 +#define ENAMETOOLONG 206 +#define EAGAIN 234 +#define ENOTDIR 267 +#define ERANGE 534 +#define ENXIO 1006 +#define EFAULT 1067 +#define EIO 1117 +#define EDEADLOCK 1131 +#define ENODEV 1200 + +#endif /*_GPG_ERROR_EXTRA_ERRNO_H*/ Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/src/init.c 2010-01-18 15:10:37 UTC (rev 226) @@ -35,14 +35,26 @@ /* Locale directory support. */ #if HAVE_W32_SYSTEM -/* The implementation follows below. */ +/* The TLS space definition. */ +struct tls_space_s +{ + /* 119 bytes for an error message should be enough. With this size + we can assume that the allocation does not take up more than 128 + bytes per thread. */ + char strerror_buffer[120]; +}; +static int tls_index; /* Index for the TLS functions. */ + static char *get_locale_dir (void); static void drop_locale_dir (char *locale_dir); -#else + +#else /*!HAVE_W32_SYSTEM*/ + #define get_locale_dir() LOCALEDIR #define drop_locale_dir(dir) -#endif +#endif /*!HAVE_W32_SYSTEM*/ + /* Initialize the library. This function should be run early. */ gpg_error_t @@ -121,62 +133,72 @@ } 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( 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; - } + 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); +#ifndef HAVE_W32CE_SYSTEM /* W32CE has no environment variables. */ + if (type == REG_EXPAND_SZ && strchr (result, '%')) + { + char *tmp; + + n1 += 1000; + tmp = malloc (n1+1); if (!tmp) - goto leave; + 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; + 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); + } } - 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); - } - } +#endif /*HAVE_W32CE_SYSTEM*/ leave: RegCloseKey( key_handle ); @@ -223,4 +245,132 @@ free (locale_dir); } -#endif /* HAVE_W32_SYSTEM */ + +/* Return the tls object. This function is guaranteed to return a + valid non-NULL object. */ +#ifdef HAVE_W32CE_SYSTEM +static struct tls_space_s * +get_tls (void) +{ + struct tls_space_s *tls; + + tls = TlsGetValue (tls_index); + if (!tls) + { + /* Called by a thread which existed before this DLL was loaded. + Allocate the space. */ + tls = LocalAlloc (LPTR, sizeof *tls); + if (!tls) + { + /* No way to continue - commit suicide. */ + abort (); + } + TlsSetValue (tls_index, tls); + } + + return tls; +} +#endif /*HAVE_W32CE_SYSTEM*/ + +/* Return the value of the ERRNO variable. This needs to be a + function so that we can have a per-thread ERRNO. This is used only + on WindowsCE because that OS misses an errno. */ +#ifdef HAVE_W32CE_SYSTEM +int +_gpg_w32ce_get_errno (void) +{ + int err; + + err = GetLastError (); + /* FIXME: Should we fold some W32 error codes into the same errno + value? */ + return err; +} +#endif /*HAVE_W32CE_SYSTEM*/ + + +/* Replacement strerror function for WindowsCE. */ +#ifdef HAVE_W32CE_SYSTEM +char * +_gpg_w32ce_strerror (int err) +{ + struct tls_space_s *tls = get_tls (); + + if (err == -1) + err = _gpg_w32ce_get_errno (); + if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + tls->strerror_buffer, sizeof tls->strerror_buffer -1, + NULL)) + snprintf (tls->strerror_buffer, sizeof tls->strerror_buffer -1, + "[w32err=%d]", err); + return tls->strerror_buffer; +} +#endif /*HAVE_W32CE_SYSTEM*/ + + +void +gpg_err_set_errno (int err) +{ +#ifdef HAVE_W32CE_SYSTEM + SetLastError (err); +#else /*!HAVE_W32CE_SYSTEM*/ + errno = err; +#endif /*!HAVE_W32CE_SYSTEM*/ +} + + +/* Entry point called by the DLL loader. This is only used by + WindowsCE for now; we might eventually use TLS to implement a + thread safe strerror. */ +#ifdef HAVE_W32CE_SYSTEM +int WINAPI +DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved) +{ + struct tls_space_s *tls; + (void)reserved; + + switch (reason) + { + case DLL_PROCESS_ATTACH: + tls_index = TlsAlloc (); + if (tls_index == TLS_OUT_OF_INDEXES) + return FALSE; + /* falltru. */ + case DLL_THREAD_ATTACH: + tls = LocalAlloc (LPTR, sizeof *tls); + if (!tls) + return FALSE; + TlsSetValue (tls_index, tls); + break; + + case DLL_THREAD_DETACH: + tls = TlsGetValue (tls_index); + if (tls) + LocalFree (tls); + break; + + case DLL_PROCESS_DETACH: + tls = TlsGetValue (tls_index); + if (tls) + LocalFree (tls); + TlsFree (tls_index); + break; + + default: + break; + } + + return TRUE; +} +#endif /*HAVE_W32CE_SYSTEM*/ + +#else /*!HAVE_W32_SYSTEM*/ + +void +gpg_err_set_errno (int err) +{ + errno = err; +} + +#endif /*!HAVE_W32_SYSTEM*/ Modified: trunk/src/mkheader.awk =================================================================== --- trunk/src/mkheader.awk 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/src/mkheader.awk 2010-01-18 15:10:37 UTC (rev 226) @@ -58,6 +58,8 @@ codes_nr = 0; # errnos_nr holds the number of system errors. errnos_nr = 0; +# extra_nr holds the number of extra lines to be included. + extra_nr = 0 # These variables walk us through our input. sources_header = 1; @@ -66,6 +68,7 @@ codes_body = 0; between_codes_and_errnos = 0; errnos_body = 0; + extra_body = 0; gpg_error_h = 0; print "/* Output of mkheader.awk. DO NOT EDIT. */"; @@ -148,9 +151,9 @@ if ($1 !~ /^[0-9]/) { -# Note that this assumes that gpg-error.h.in doesn't start with a digit. +# Note that this assumes that extra_body.in doesn't start with a digit. errnos_body = 0; - gpg_error_h = 1; + extra_body = 1; } else { @@ -160,6 +163,23 @@ } } +extra_body { + if (/^##/) + next + + if (/^EOF/) + { + extra_body = 0; + gpg_error_h = 1; + next; + } + else + { + extra_line[extra_nr] = $0; + extra_nr++; + } +} + gpg_error_h { if ($0 ~ /^@include err-sources/) { @@ -180,9 +200,16 @@ else if ($0 ~ /^@include errnos/) { for (i = 0; i < errnos_nr; i++) + { + print " " errnos_sym[i] " = " errnos_idx[i] ","; +# print "#define " errnos_sym[i] " (" errnos_idx[i] ")"; + } + } + else if ($0 ~ /^@include extra-h.in/) + { + for (i = 0; i < extra_nr; i++) { - print " " errnos_sym[i] " = " errnos_idx[i] ","; -# print "#define " errnos_sym[i] " (" errnos_idx[i] ")"; + print extra_line[i]; } } else Modified: trunk/src/w32-gettext.c =================================================================== --- trunk/src/w32-gettext.c 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/src/w32-gettext.c 2010-01-18 15:10:37 UTC (rev 226) @@ -68,7 +68,9 @@ #endif #include -#include +#ifndef HAVE_W32CE_SYSTEM +# include +#endif #ifdef HAVE_W32_SYSTEM # include @@ -776,6 +778,7 @@ /* Let the user override the system settings through environment variables, as on POSIX systems. */ +#ifndef HAVE_W32CE_SYSTEM retval = getenv ("LC_ALL"); if (retval != NULL && retval[0] != '\0') return retval; @@ -785,9 +788,14 @@ retval = getenv ("LANG"); if (retval != NULL && retval[0] != '\0') return retval; +#endif /*!HAVE_W32CE_SYSTEM*/ /* Use native Win32 API locale ID. */ +#ifdef HAVE_W32CE_SYSTEM + lcid = GetSystemDefaultLCID (); +#else lcid = GetThreadLocale (); +#endif /* Strip off the sorting rules, keep only the language part. */ langid = LANGIDFROMLCID (lcid); Modified: trunk/src/w32-gettext.h =================================================================== --- trunk/src/w32-gettext.h 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/src/w32-gettext.h 2010-01-18 15:10:37 UTC (rev 226) @@ -20,7 +20,11 @@ #if ENABLE_NLS -#include +#ifdef HAVE_W32CE_SYSTEM +# define LC_ALL 0 +#else +# include +#endif #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) # define LC_MESSAGES 1729 #endif Added: trunk/src/w32ce-add.h =================================================================== --- trunk/src/w32ce-add.h (rev 0) +++ trunk/src/w32ce-add.h 2010-01-18 15:10:37 UTC (rev 226) @@ -0,0 +1,7 @@ +## w32ce-add.h - Snippet to be be included into gpg-error.h. +## (Comments are indicated by a double hash mark) + +/* Substitute for strerror - this one is thread safe. */ +char *_gpg_w32ce_strerror (int err); +#define strerror(a) _gpg_w32ce_strerror (a) + Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/tests/Makefile.am 2010-01-18 15:10:37 UTC (rev 226) @@ -19,9 +19,16 @@ ## Process this file with automake to produce Makefile.in +if HAVE_W32CE_SYSTEM +extra_includes = -idirafter $(top_builddir)/src/gpg-extra +else +extra_includes = +endif + + TESTS = t-strerror t-syserror -INCLUDES = -I$(top_builddir)/src +INCLUDES = -I$(top_builddir)/src $(extra_includes) LDADD = ../src/libgpg-error.la Modified: trunk/tests/t-syserror.c =================================================================== --- trunk/tests/t-syserror.c 2009-11-03 19:54:06 UTC (rev 225) +++ trunk/tests/t-syserror.c 2010-01-18 15:10:37 UTC (rev 226) @@ -64,7 +64,7 @@ return 1; } - errno = 0; + gpg_err_set_errno (0); ec = gpg_err_code_from_syserror (); if (ec != GPG_ERR_MISSING_ERRNO) From cvs at cvs.gnupg.org Mon Jan 18 21:14:25 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 18 Jan 2010 21:14:25 +0100 Subject: [svn] gpg-error - r227 - in trunk: . src src/gpg-extra Message-ID: Author: wk Date: 2010-01-18 21:14:25 +0100 (Mon, 18 Jan 2010) New Revision: 227 Removed: trunk/src/gpg-extra/errno.h Modified: trunk/ChangeLog trunk/NEWS trunk/src/Makefile.am trunk/src/gpg-error.c trunk/src/init.c Log: Fix w32ce strerror. Fix non-w32ce dependency problem. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-18 15:10:37 UTC (rev 226) +++ trunk/ChangeLog 2010-01-18 20:14:25 UTC (rev 227) @@ -1,5 +1,11 @@ 2010-01-18 Werner Koch + * src/init.c (wchar_to_utf8, utf8_to_wchar): New. + + * src/gpg-error.c (main): Add option --list. + +2010-01-18 Werner Koch + * ltmain.sh (wrappers_required): Don't set for mingw32ce. * tests/Makefile.am (extra_includes): New. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-18 15:10:37 UTC (rev 226) +++ trunk/NEWS 2010-01-18 20:14:25 UTC (rev 227) @@ -3,6 +3,8 @@ * Preliminary support for WindowsCE. + * New option --list for gpg-error. + * Interface changes relative to the 1.7 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPG_ERR_NOT_ENABLED NEW. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-01-18 15:10:37 UTC (rev 226) +++ trunk/src/Makefile.am 2010-01-18 20:14:25 UTC (rev 227) @@ -48,7 +48,7 @@ BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \ - gpg-error.def gpg-extra/errno.h extra-h.in + gpg-error.def extra-h.in $(extra_headers) tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h Modified: trunk/src/gpg-error.c =================================================================== --- trunk/src/gpg-error.c 2010-01-18 15:10:37 UTC (rev 226) +++ trunk/src/gpg-error.c 2010-01-18 20:14:25 UTC (rev 227) @@ -462,6 +462,10 @@ main (int argc, char *argv[]) { int i = 1; + int listmode = 0; + const char *source_sym; + const char *error_sym; + gpg_error_t err; #ifndef GPG_ERR_INITIALIZED gpg_err_init (); @@ -481,18 +485,46 @@ fputs ("gpg-error (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stdout); exit (0); } + else if (argc == 2 && !strcmp (argv[1], "--list")) + { + listmode = 1; + } + if (listmode) + { + for (i=0; i < GPG_ERR_SOURCE_DIM; i++) + { + /* We use error code 1 because gpg_err_make requires a + non-zero error code. */ + err = gpg_err_make (i, 1); + err -= 1; + source_sym = gpg_strsource_sym (err); + if (source_sym) + printf ("%u = (%u, -) = (%s, -) = (%s, -)\n", + err, gpg_err_source (err), + source_sym, gpg_strsource (err)); + } + for (i=0; i < GPG_ERR_CODE_DIM; i++) + { + err = gpg_err_make (GPG_ERR_SOURCE_UNKNOWN, i); + error_sym = gpg_strerror_sym (err); + if (error_sym) + printf ("%u = (-, %u) = (-, %s) = (-, %s)\n", + err, gpg_err_code (err), + error_sym, gpg_strerror (err)); + } + + i = argc; /* Don't run the usual stuff. */ + } while (i < argc) { - gpg_error_t err; - if (get_err_from_number (argv[i], &err) || get_err_from_symbol (argv[i], &err) || get_err_from_str (argv[i], &err)) { - const char *source_sym = gpg_strsource_sym (err); - const char *error_sym = gpg_strerror_sym (err); + source_sym = gpg_strsource_sym (err); + error_sym = gpg_strerror_sym (err); printf ("%u = (%u, %u) = (%s, %s) = (%s, %s)\n", err, gpg_err_source (err), gpg_err_code (err), Deleted: trunk/src/gpg-extra/errno.h Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2010-01-18 15:10:37 UTC (rev 226) +++ trunk/src/init.c 2010-01-18 20:14:25 UTC (rev 227) @@ -35,13 +35,16 @@ /* Locale directory support. */ #if HAVE_W32_SYSTEM + +/* 119 bytes for an error message should be enough. With this size we + can assume that the allocation does not take up more than 128 bytes + per thread. */ +#define STRBUFFER_SIZE 120 + /* The TLS space definition. */ struct tls_space_s { - /* 119 bytes for an error message should be enough. With this size - we can assume that the allocation does not take up more than 128 - bytes per thread. */ - char strerror_buffer[120]; + char strerror_buffer[STRBUFFER_SIZE]; }; static int tls_index; /* Index for the TLS functions. */ @@ -82,6 +85,68 @@ #include +/* Return a malloced string encoded in UTF-8 from the wide char input + string STRING. Caller must free this value. Returns NULL on + failure. Caller may use GetLastError to get the actual error + number. The result of calling this function with STRING set to + NULL is not defined. */ +static char * +wchar_to_utf8 (const wchar_t *string) +{ + int n; + char *result; + + /* Note, that CP_UTF8 is not defined in Windows versions earlier + than NT. */ + n = WideCharToMultiByte (CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL); + if (n < 0) + return NULL; + + result = malloc (n+1); + if (result) + { + n = WideCharToMultiByte (CP_UTF8, 0, string, -1, result, n, NULL, NULL); + if (n < 0) + { + free (result); + result = NULL; + } + } + return result; +} + + +/* Return a malloced wide char string from an UTF-8 encoded input + string STRING. Caller must free this value. Returns NULL on + failure. Caller may use GetLastError to get the actual error + number. The result of calling this function with STRING set to + NULL is not defined. */ +static wchar_t * +utf8_to_wchar (const char *string) +{ + int n; + wchar_t *result; + + n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0); + if (n < 0) + return NULL; + + result = malloc ((n+1) * sizeof *result); + if (result) + { + n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n); + if (n < 0) + { + free (result); + result = NULL; + } + return NULL; + } + return result; +} + + + static HKEY get_root_key(const char *root) { @@ -295,13 +360,25 @@ _gpg_w32ce_strerror (int err) { struct tls_space_s *tls = get_tls (); + wchar_t tmpbuf[STRBUFFER_SIZE]; + int n; if (err == -1) err = _gpg_w32ce_get_errno (); - if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + if (FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - tls->strerror_buffer, sizeof tls->strerror_buffer -1, + tmpbuf, STRBUFFER_SIZE -1, NULL)) + { + n = WideCharToMultiByte (CP_UTF8, 0, tmpbuf, -1, + tls->strerror_buffer, + sizeof tls->strerror_buffer -1, + NULL, NULL); + } + else + n = -1; + + if (n < 0) snprintf (tls->strerror_buffer, sizeof tls->strerror_buffer -1, "[w32err=%d]", err); return tls->strerror_buffer; From cvs at cvs.gnupg.org Thu Jan 21 13:41:22 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 21 Jan 2010 13:41:22 +0100 Subject: [svn] gpg-error - r228 - in trunk: . src Message-ID: Author: wk Date: 2010-01-21 13:41:21 +0100 (Thu, 21 Jan 2010) New Revision: 228 Added: trunk/src/init.h trunk/src/w32-add.h Removed: trunk/src/w32-gettext.h Modified: trunk/ChangeLog trunk/README trunk/src/Makefile.am trunk/src/errnos.in trunk/src/gettext.h trunk/src/gpg-error.c trunk/src/gpg-error.def.in trunk/src/init.c trunk/src/mkstrtable.awk trunk/src/w32-gettext.c Log: Finished W32CE support. [The diff below has been truncated] Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/ChangeLog 2010-01-21 12:41:21 UTC (rev 228) @@ -1,3 +1,52 @@ +2010-01-21 Werner Koch + + * src/mkstrtable.awk (END): Do not print PREFIX before + LAST_MSGSTR. + + * src/init.c (get_locale_dir): Rework to match what gnupg is doing. + (get_root_key, read_w32_registry_string): Remove. + * src/gpg-error.c (get_locale_dir): Replace by code from init.c + (get_root_key, read_w32_registry_string): Remove. + +2010-01-20 Werner Koch + + * src/init.c (gpg_err_init): Factor code out to .. + (real_init): .. new. + + * src/Makefile.am (gpg_error_SOURCES): Remove arch_sources. + (export_symbols): Do not prefix gpg-error-def with srcdir. + +2010-01-19 Werner Koch + + * src/init.c (DllMain): Call _w32_gettext_init. + (get_tls): Use it also for standard Windows. + (DllMain): Ditto. + (struct tls_space_s): Move to .. + (get_tls): Make global. + * src/init.h: .. New. + * src/gettext.h: Do not include w32-gettext.h. + * src/w32-gettext.c: Replace by version from GnuPG. + (my_nl_locale_name) [W32CE]: Do not use getenv. Use + GetSystemDefaultLCID. + (struct loaded_domain): Use uint16_t for NSTRINGS and MAPPED to + save space. + (load_domain): Check for too large MO files. + (utf8_to_wchar): Use gpg_err_set_errno. + (bindtextdomain): Rename to _gpg_w32_bindtextdomain. + (textdomain): Rename to _gpg_w32_textdomain. + (gettext): Rename to _gpg_w32_gettext. + (dgettext): Rename to _gpg_w32_dgettext. + (ngettext): Remove. + (gettext_localename): Rename to _gpg_w32_gettext_localename. + (gettext_select_utf8): Rename to _gpg_w32_gettext_use_utf8. + (_gpg_w32_bindtextdomain): Change to only register the directory. + Return the current directory if asked to. + (do_gettext): Add DOMAINNAME arg and take care of it. + * src/w32-add.h: New. + * src/w32-gettext.h: Remove. + * src/Makefile.am (extra-h.in): Process w32-add.h. + (arch_sources): Remove w32-gettext.h. + 2010-01-18 Werner Koch * src/init.c (wchar_to_utf8, utf8_to_wchar): New. Modified: trunk/README =================================================================== --- trunk/README 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/README 2010-01-21 12:41:21 UTC (rev 228) @@ -76,6 +76,19 @@ published via the announcement list and probably via Usenet. +Hints +----- + +To build for Windows you you may use the convenience command: + + ./autogen.sh --build-w32 + +which runs configure with suitable options. For WindowsCE the command +is: + + ./autogen.sh --build-w32ce + + Known Problems -------------- Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/src/Makefile.am 2010-01-21 12:41:21 UTC (rev 228) @@ -38,11 +38,10 @@ m4datadir = $(datadir)/aclocal m4data_DATA = gpg-error.m4 - EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \ mkerrnos.awk errnos.in README \ mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \ - mkheader.awk gpg-error.h.in mkw32errmap.c w32ce-add.h \ + mkheader.awk gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \ err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \ gpg-error.def.in versioninfo.rc.in @@ -58,7 +57,7 @@ extra-h.in $(tmp_files) if HAVE_W32_SYSTEM -arch_sources = w32-gettext.h w32-gettext.c +arch_sources = w32-gettext.c RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ -DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS) @@ -71,7 +70,7 @@ gpg_error_res = versioninfo.lo no_undefined = -no-undefined -export_symbols = -export-symbols $(srcdir)/gpg-error.def +export_symbols = -export-symbols gpg-error.def install-def-file: gpg-error.def $(INSTALL) gpg-error.def $(DESTDIR)$(libdir)/gpg-error.def @@ -100,7 +99,7 @@ $(no_undefined) $(export_symbols) libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \ - init.c strsource.c strerror.c code-to-errno.c code-from-errno.c + init.c init.h strsource.c strerror.c code-to-errno.c code-from-errno.c # Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but # without the extra_cppflags because they may include am -idirafter @@ -108,7 +107,7 @@ libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags) libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) -gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c $(arch_sources) +gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c gpg_error_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags) gpg_error_LDADD = ./libgpg-error.la @LTLIBINTL@ @@ -175,10 +174,13 @@ -v prefix=GPG_ERR_ -v namespace=errnos_ \ $(srcdir)/errnos.in >$@ -extra-h.in: Makefile w32ce-add.h +extra-h.in: Makefile w32-add.h w32ce-add.h -rm extra-h.in +if HAVE_W32_SYSTEM + cat $(srcdir)/w32-add.h >>extra-h.in +endif if HAVE_W32CE_SYSTEM - cat $(srcdir)/w32ce-add.h >extra-h.in + cat $(srcdir)/w32ce-add.h >>extra-h.in endif echo EOF >>extra-h.in Modified: trunk/src/errnos.in =================================================================== --- trunk/src/errnos.in 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/src/errnos.in 2010-01-21 12:41:21 UTC (rev 228) @@ -169,4 +169,4 @@ 137 EUSERS 138 EWOULDBLOCK 139 EXDEV -140 EXFULL +140 EXFULL \ No newline at end of file Modified: trunk/src/gettext.h =================================================================== --- trunk/src/gettext.h 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/src/gettext.h 2010-01-21 12:41:21 UTC (rev 228) @@ -23,15 +23,14 @@ #if ENABLE_NLS #if HAVE_W32_SYSTEM -/* Redirect the gettext calls to an internal implementation on W32 - targets. */ -# include "w32-gettext.h" -#else -/* Get declarations of GNU message catalog functions. */ + /* We have a gettext implementation in gpg-error.h which get + included anyway. */ +#else /*!HAVE_W32_SYSTEM*/ + /* Get declarations of GNU message catalog functions. */ # include -#endif +#endif /*!HAVE_W32_SYSTEM*/ -#else +#else /*!ENABLE_NLS*/ /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which chokes if dcgettext is defined as a macro. So include it now, to make @@ -61,7 +60,7 @@ # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) # define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) -#endif +#endif /*!ENABLE_NLS*/ /* A pseudo function call that serves as a marker for the automated extraction of messages, but does not call gettext(). The run-time @@ -72,4 +71,6 @@ initializer for static 'char[]' or 'const char[]' variables. */ #define gettext_noop(String) String + + #endif /* _LIBGETTEXT_H */ Modified: trunk/src/gpg-error.c =================================================================== --- trunk/src/gpg-error.c 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/src/gpg-error.c 2010-01-21 12:41:21 UTC (rev 228) @@ -66,17 +66,22 @@ { #ifdef ENABLE_NLS char *locale_dir; - -# ifdef HAVE_LC_MESSAGES + +#ifdef HAVE_LC_MESSAGES setlocale (LC_TIME, ""); setlocale (LC_MESSAGES, ""); -# else -# ifdef HAVE_W32_SYSTEM -# warning setlocal is missing -# else - setlocale (LC_ALL, "" ); -# endif +#else +# ifndef HAVE_W32_SYSTEM + setlocale (LC_ALL, "" ); # endif +#endif + + /* Note that for this program we would only need the textdomain call + because libgpg-error already initializes itself to its locale dir + (via gpg_err_init or a constructor). However this is only done + for the static standard locale and thus if the above setlocale + calls select a different locale the bindtext below will do + something else. */ locale_dir = get_locale_dir (); if (locale_dir) @@ -93,155 +98,57 @@ #include -static HKEY -get_root_key(const char *root) -{ - HKEY root_key; - 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; - return root_key; -} - -/**************** - * Return a string from the Win32 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. - * NOTE: The value is allocated with a plain malloc() - use free() and not - * the usual xfree()!!! - */ static char * -read_w32_registry_string( const char *root, const char *dir, const char *name ) +get_locale_dir (void) { - HKEY root_key, key_handle; - DWORD n1, nbytes, type; - char *result = NULL; + static wchar_t moddir[MAX_PATH+5]; + char *result, *p; + int nbytes; - if ( !(root_key = get_root_key(root) ) ) - return NULL; + if (!GetModuleFileNameW (NULL, moddir, MAX_PATH)) + *moddir = 0; - if( RegOpenKeyEx( root_key, dir, 0, KEY_READ, &key_handle ) ) +#define SLDIR "\\share\\locale" + if (*moddir) { - 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 = WideCharToMultiByte (CP_UTF8, 0, moddir, -1, NULL, 0, NULL, NULL); + if (nbytes < 0) + return NULL; + + result = malloc (nbytes + strlen (SLDIR) + 1); + if (result) + { + nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1, + result, nbytes, NULL, NULL); + if (nbytes < 0) + { + free (result); + result = NULL; + } + else + { + p = strrchr (result, '\\'); + if (p) + *p = 0; + strcat (result, SLDIR); + } + } } - - 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 */ -#ifndef HAVE_W32CE_SYSTEM - 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); - } - } -#endif /*HAVE_W32CE_SYSTEM*/ - - leave: - RegCloseKey( key_handle ); + else /* Use the old default value. */ + { + result = malloc (10 + strlen (SLDIR) + 1); + if (result) + { + strcpy (result, "c:\\gnupg"); + strcat (result, SLDIR); + } + } +#undef SLDIR return result; } -#define REGKEY "Software\\GNU\\GnuPG" - -static char * -get_locale_dir (void) -{ - char *instdir; - char *p; - char *dname; - - instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", REGKEY, - "Install Directory"); - if (!instdir) - return NULL; - - /* Build the key: "/share/locale". */ -#define SLDIR "\\share\\locale" - dname = malloc (strlen (instdir) + strlen (SLDIR) + 1); - if (!dname) - { - free (instdir); - return NULL; - } - p = dname; - strcpy (p, instdir); - p += strlen (instdir); - strcpy (p, SLDIR); - - free (instdir); - - return dname; -} - - static void drop_locale_dir (char *locale_dir) { Modified: trunk/src/gpg-error.def.in =================================================================== --- trunk/src/gpg-error.def.in 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/src/gpg-error.def.in 2010-01-21 12:41:21 UTC (rev 228) @@ -5,16 +5,24 @@ #include EXPORTS - gpg_strerror @1 - gpg_strerror_r @2 - gpg_strsource @3 - gpg_err_code_from_errno @4 - gpg_err_code_to_errno @5 - gpg_err_init @6 - gpg_err_code_from_syserror @7 + gpg_strerror @1 + gpg_strerror_r @2 + gpg_strsource @3 + gpg_err_code_from_errno @4 + gpg_err_code_to_errno @5 + gpg_err_init @6 + gpg_err_code_from_syserror @7 + gpg_err_set_errno @8 #ifdef HAVE_W32CE_SYSTEM - _gpg_w32ce_strerror @8 - _gpg_w32ce_get_errno @9 + _gpg_w32ce_get_errno @9 + _gpg_w32ce_strerror @10 #endif - gpg_err_set_errno @10 - +#ifdef HAVE_W32_SYSTEM + _gpg_w32_bindtextdomain @11 + _gpg_w32_textdomain @12 + _gpg_w32_gettext @13 + _gpg_w32_dgettext @14 + _gpg_w32_dngettext @15 + _gpg_w32_gettext_localename @16 + _gpg_w32_gettext_use_utf8 @17 +#endif Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/src/init.c 2010-01-21 12:41:21 UTC (rev 228) @@ -1,5 +1,5 @@ /* init.c - Initialize the GnuPG error library. - Copyright (C) 2005 g10 Code GmbH + Copyright (C) 2005, 2010 g10 Code GmbH This file is part of libgpg-error. @@ -14,9 +14,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with libgpg-error; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + License along with this program; if not, see . + */ #if HAVE_CONFIG_H #include @@ -30,22 +29,13 @@ #include #include "gettext.h" +#include "init.h" /* Locale directory support. */ #if HAVE_W32_SYSTEM -/* 119 bytes for an error message should be enough. With this size we - can assume that the allocation does not take up more than 128 bytes - per thread. */ -#define STRBUFFER_SIZE 120 - -/* The TLS space definition. */ -struct tls_space_s -{ - char strerror_buffer[STRBUFFER_SIZE]; -}; static int tls_index; /* Index for the TLS functions. */ static char *get_locale_dir (void); @@ -59,15 +49,13 @@ #endif /*!HAVE_W32_SYSTEM*/ -/* Initialize the library. This function should be run early. */ -gpg_error_t -gpg_err_init (void) +static void +real_init (void) { #ifdef ENABLE_NLS char *locale_dir; /* We only have to bind our locale directory to our text domain. */ - locale_dir = get_locale_dir (); if (locale_dir) { @@ -75,7 +63,22 @@ drop_locale_dir (locale_dir); } #endif +} +/* Initialize the library. This function should be run early. */ +gpg_error_t +gpg_err_init (void) +{ +#ifdef HAVE_W32_SYSTEM + /* We always have a constructor and thus this function is called + automatically. Due to the way the C init code of mingw works, + the constructors are called before our DllMain function is + called. The problem with that is that the TLS has not been setup + and w32-gettext.c requires TLS. To solve this we do nothing here + but call the actual init code from our DllMain. */ +#else + real_init (); +#endif return 0; } @@ -146,164 +149,56 @@ } - -static HKEY -get_root_key(const char *root) -{ - HKEY root_key; - - 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; - return root_key; -} - -/**************** - * Return a string from the Win32 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. - * NOTE: The value is allocated with a plain malloc() - use free() and not - * the usual xfree()!!! - */ static char * -read_w32_registry_string( const char *root, const char *dir, const char *name ) +get_locale_dir (void) { - HKEY root_key, key_handle; - DWORD n1, nbytes, type; - char *result = NULL; + static wchar_t moddir[MAX_PATH+5]; + char *result, *p; + int nbytes; - if ( !(root_key = get_root_key(root) ) ) - return NULL; + if (!GetModuleFileNameW (NULL, moddir, MAX_PATH)) + *moddir = 0; - if( RegOpenKeyEx( root_key, dir, 0, KEY_READ, &key_handle ) ) +#define SLDIR "\\share\\locale" + if (*moddir) { - 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 */ - -#ifndef HAVE_W32CE_SYSTEM /* W32CE has no environment variables. */ - if (type == REG_EXPAND_SZ && strchr (result, '%')) - { - char *tmp; + nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1, NULL, 0, NULL, NULL); + if (nbytes < 0) + return NULL; - n1 += 1000; - tmp = malloc (n1+1); - if (!tmp) - goto leave; - nbytes = ExpandEnvironmentStrings (result, tmp, n1); - if (nbytes && nbytes > n1) + result = malloc (nbytes + strlen (SLDIR) + 1); + if (result) { - free (tmp); - n1 = nbytes; - tmp = malloc (n1 + 1); - if (!tmp) - goto leave; - nbytes = ExpandEnvironmentStrings (result, tmp, n1); - if (nbytes && nbytes > n1) + nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1, + result, nbytes, NULL, NULL); + if (nbytes < 0) { - free (tmp); /* oops - truncated, better don't expand at all */ - goto leave; + free (result); + result = NULL; } - tmp[nbytes] = 0; - free (result); - result = tmp; + else + { + p = strrchr (result, '\\'); + if (p) + *p = 0; + strcat (result, SLDIR); + } } - else if (nbytes) /* okay, reduce the length */ + } + else /* Use the old default value. */ + { + result = malloc (10 + strlen (SLDIR) + 1); + if (result) { - tmp[nbytes] = 0; - free (result); - result = malloc (strlen (tmp)+1); - if (!result) - result = tmp; - else { - strcpy (result, tmp); - free (tmp); - } + strcpy (result, "c:\\gnupg"); + strcat (result, SLDIR); } - else /* error - don't expand */ - { - free (tmp); - } - } -#endif /*HAVE_W32CE_SYSTEM*/ - - leave: - RegCloseKey( key_handle ); + } +#undef SLDIR return result; } -#define REGKEY "Software\\GNU\\GnuPG" - -static char * -get_locale_dir (void) -{ - char *instdir; - char *p; - char *dname; - - instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", REGKEY, - "Install Directory"); - if (!instdir) - return NULL; - - /* Build the key: "/share/locale". */ -#define SLDIR "\\share\\locale" - dname = malloc (strlen (instdir) + strlen (SLDIR) + 1); - if (!dname) - { - free (instdir); - return NULL; - } - p = dname; - strcpy (p, instdir); - p += strlen (instdir); - strcpy (p, SLDIR); - - free (instdir); - - return dname; -} - - static void drop_locale_dir (char *locale_dir) { @@ -313,8 +208,7 @@ /* Return the tls object. This function is guaranteed to return a valid non-NULL object. */ -#ifdef HAVE_W32CE_SYSTEM -static struct tls_space_s * +struct tls_space_s * get_tls (void) { struct tls_space_s *tls; @@ -330,13 +224,14 @@ /* No way to continue - commit suicide. */ abort (); } + tls->gt_use_utf8 = 0; TlsSetValue (tls_index, tls); } return tls; } -#endif /*HAVE_W32CE_SYSTEM*/ + /* Return the value of the ERRNO variable. This needs to be a function so that we can have a per-thread ERRNO. This is used only on WindowsCE because that OS misses an errno. */ @@ -397,10 +292,7 @@ } -/* Entry point called by the DLL loader. This is only used by - WindowsCE for now; we might eventually use TLS to implement a - thread safe strerror. */ -#ifdef HAVE_W32CE_SYSTEM +/* Entry point called by the DLL loader. */ int WINAPI DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved) { @@ -418,7 +310,12 @@ tls = LocalAlloc (LPTR, sizeof *tls); if (!tls) return FALSE; + tls->gt_use_utf8 = 0; TlsSetValue (tls_index, tls); + if (reason == DLL_PROCESS_ATTACH) + { + real_init (); + } break; case DLL_THREAD_DETACH: @@ -440,8 +337,8 @@ return TRUE; } -#endif /*HAVE_W32CE_SYSTEM*/ + #else /*!HAVE_W32_SYSTEM*/ void Added: trunk/src/init.h =================================================================== --- trunk/src/init.h (rev 0) +++ trunk/src/init.h 2010-01-21 12:41:21 UTC (rev 228) @@ -0,0 +1,65 @@ +/* init.h - Declarations for init.c + Copyright (C) 2010 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error 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. + + libgpg-error 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 INIT_H +#define INIT_H + +#if HAVE_W32_SYSTEM + +/* Forward declaration - defined in w32-gettext.c. */ +struct loaded_domain; + +/* An item for a linked list of loaded domains. */ +struct domainlist_s +{ + struct domainlist_s *next; + char *dname; /* Directory name for the mo file. */ + char *fname; /* File name for the MO file. */ + int load_failed; /* True if loading the domain failed. */ + struct loaded_domain *domain; /* NULL if not loaded. Never changed + once set to non-NULL. */ + char name[1]; /* Name of the domain. Never changed + once set. */ +}; + + + +/* 119 bytes for an error message should be enough. With this size we + can assume that the allocation does not take up more than 128 bytes + per thread. Note that this is only used for W32CE. */ +#define STRBUFFER_SIZE 120 + +/* The TLS space definition. */ +struct tls_space_s +{ + /* Flag used by w32-gettext. */ + int gt_use_utf8; + +#ifdef HAVE_W32CE_SYSTEM + char strerror_buffer[STRBUFFER_SIZE]; +#endif +}; + +/* Return the TLS. */ +struct tls_space_s *get_tls (void); + + +#endif /*HAVE_W32_SYSTEM*/ + +#endif /*INIT_H*/ Modified: trunk/src/mkstrtable.awk =================================================================== --- trunk/src/mkstrtable.awk 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/src/mkstrtable.awk 2010-01-21 12:41:21 UTC (rev 228) @@ -146,9 +146,9 @@ coded_msgs = msg; if (nogettext) - print " \"" prefix last_msgstr "\";"; + print " \"" last_msgstr "\";"; else - print " gettext_noop (\"" prefix last_msgstr "\");"; + print " gettext_noop (\"" last_msgstr "\");"; print ""; print "static const int " namespace "msgidx[] ="; print " {"; Added: trunk/src/w32-add.h =================================================================== --- trunk/src/w32-add.h (rev 0) +++ trunk/src/w32-add.h 2010-01-21 12:41:21 UTC (rev 228) @@ -0,0 +1,24 @@ +## w32-add.h - Snippet to be be included into gpg-error.h. +## (Comments are indicated by a double hash mark) + +/* A lean gettext implementation based on GNU style mo files which are + required to be encoded in UTF-8. There is a limit on 65534 entries + to save some RAM. Only Germanic plural rules are supported. */ +const char *_gpg_w32_bindtextdomain (const char *domainname, + const char *dirname); +const char *_gpg_w32_textdomain (const char *domainname); +const char *_gpg_w32_gettext (const char *msgid); +const char *_gpg_w32_dgettext (const char *domainname, const char *msgid); +const char *_gpg_w32_dngettext (const char *domainname, const char *msgid1, + const char *msgid2, unsigned long int n); +const char *_gpg_w32_gettext_localename (void); +int _gpg_w32_gettext_use_utf8 (int value); + +#define bindtextdomain(a,b) _gpg_w32_bindtextdomain ((a), (b)) +#define textdomain(a) _gpg_w32_textdomain ((a)) +#define gettext(a) _gpg_w32_gettext ((a)) +#define dgettext(a,b) _gpg_w32_dgettext ((a), (b)) +#define ngettext(a,b,c) _gpg_w32_dngettext (NULL, (a), (b), (c)) +#define dngettext(a,b,c,d) _gpg_w32_dngettext ((a), (b), (c), (d)) +#define gettext_localname() _gpg_w32_gettext_localename () +#define gettext_use_utf8(a) _gpg_w32_gettext_use_utf8 (a) Modified: trunk/src/w32-gettext.c =================================================================== --- trunk/src/w32-gettext.c 2010-01-18 20:14:25 UTC (rev 227) +++ trunk/src/w32-gettext.c 2010-01-21 12:41:21 UTC (rev 228) @@ -1,6 +1,6 @@ /* w32-gettext.h - A simple gettext implementation for Windows targets. - Copyright (C) 1995,1996,1997,1999,2005 Free Software Foundation, Inc. - Copyright (C) 2005 g10 Code GmbH + Copyright (C) 1995, 1996, 1997, 1999, 2005, 2007, +2 2008, 2010 Free Software Foundation, Inc. This file is part of libgpg-error. @@ -15,13 +15,15 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with libgpg-error; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + License along with this program; if not, see . + */ #if HAVE_CONFIG_H #include #endif +#if !defined (_WIN32) && !defined (__CYGWIN32__) +# error This module may only be build for Windows or Cygwin32 +#endif #include #include @@ -31,17 +33,28 @@ #include #include #include +#ifndef HAVE_W32CE_SYSTEM +# include +#endif /*HAVE_W32CE_SYSTEM*/ +#include -#include +#ifdef JNLIB_IN_JNLIB +#include "libjnlib-config.h" +#endif -#include "gettext.h" +#ifndef jnlib_malloc +# define jnlib_malloc(a) malloc ((a)) +# define jnlib_calloc(a,b) calloc ((a), (b)) +# define jnlib_free(a) free ((a)) +# define jnlib_xstrdup(a) not_used +#endif /*!jnlib_malloc*/ +#include "init.h" + + -/* localname.c from gettext. */ +/* localname.c from gettext BEGIN. */ -/* Edit: Added a "static" to _nl_locale_name. Note that the category - argument is ignored on w32. */ - /* Determine the current selected locale. Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. @@ -62,716 +75,543 @@ /* Written by Ulrich Drepper , 1995. */ /* Win32 code written by Tor Lillqvist . */ +/* Renamed _nl_locale_name, removed unsed args, removed include files, + non-W32 code and changed comments . */ -#ifdef HAVE_CONFIG_H -# include +/* Mingw headers don't have latest language and sublanguage codes. */ +#ifndef LANG_AFRIKAANS +#define LANG_AFRIKAANS 0x36 #endif - -#include -#ifndef HAVE_W32CE_SYSTEM -# include +#ifndef LANG_ALBANIAN +#define LANG_ALBANIAN 0x1c #endif - -#ifdef HAVE_W32_SYSTEM -# include -/* List of language codes, sorted by value: - 0x01 LANG_ARABIC - 0x02 LANG_BULGARIAN - 0x03 LANG_CATALAN - 0x04 LANG_CHINESE - 0x05 LANG_CZECH - 0x06 LANG_DANISH - 0x07 LANG_GERMAN - 0x08 LANG_GREEK - 0x09 LANG_ENGLISH - 0x0a LANG_SPANISH - 0x0b LANG_FINNISH - 0x0c LANG_FRENCH - 0x0d LANG_HEBREW - 0x0e LANG_HUNGARIAN - 0x0f LANG_ICELANDIC - 0x10 LANG_ITALIAN - 0x11 LANG_JAPANESE - 0x12 LANG_KOREAN - 0x13 LANG_DUTCH - 0x14 LANG_NORWEGIAN - 0x15 LANG_POLISH - 0x16 LANG_PORTUGUESE - 0x17 LANG_RHAETO_ROMANCE - 0x18 LANG_ROMANIAN - 0x19 LANG_RUSSIAN - 0x1a LANG_CROATIAN == LANG_SERBIAN - 0x1b LANG_SLOVAK - 0x1c LANG_ALBANIAN - 0x1d LANG_SWEDISH - 0x1e LANG_THAI - 0x1f LANG_TURKISH - 0x20 LANG_URDU - 0x21 LANG_INDONESIAN - 0x22 LANG_UKRAINIAN - 0x23 LANG_BELARUSIAN - 0x24 LANG_SLOVENIAN - 0x25 LANG_ESTONIAN - 0x26 LANG_LATVIAN - 0x27 LANG_LITHUANIAN - 0x28 LANG_TAJIK - 0x29 LANG_FARSI - 0x2a LANG_VIETNAMESE - 0x2b LANG_ARMENIAN - 0x2c LANG_AZERI - 0x2d LANG_BASQUE - 0x2e LANG_SORBIAN - 0x2f LANG_MACEDONIAN - 0x30 LANG_SUTU - 0x31 LANG_TSONGA - 0x32 LANG_TSWANA - 0x33 LANG_VENDA - 0x34 LANG_XHOSA - 0x35 LANG_ZULU - 0x36 LANG_AFRIKAANS - 0x37 LANG_GEORGIAN - 0x38 LANG_FAEROESE - 0x39 LANG_HINDI - 0x3a LANG_MALTESE - 0x3b LANG_SAAMI - 0x3c LANG_GAELIC - 0x3d LANG_YIDDISH - 0x3e LANG_MALAY - 0x3f LANG_KAZAK - 0x40 LANG_KYRGYZ - 0x41 LANG_SWAHILI - 0x42 LANG_TURKMEN - 0x43 LANG_UZBEK - 0x44 LANG_TATAR - 0x45 LANG_BENGALI - 0x46 LANG_PUNJABI - 0x47 LANG_GUJARATI - 0x48 LANG_ORIYA - 0x49 LANG_TAMIL - 0x4a LANG_TELUGU - 0x4b LANG_KANNADA - 0x4c LANG_MALAYALAM - 0x4d LANG_ASSAMESE - 0x4e LANG_MARATHI - 0x4f LANG_SANSKRIT - 0x50 LANG_MONGOLIAN - 0x51 LANG_TIBETAN - 0x52 LANG_WELSH - 0x53 LANG_CAMBODIAN - 0x54 LANG_LAO - 0x55 LANG_BURMESE - 0x56 LANG_GALICIAN - 0x57 LANG_KONKANI - 0x58 LANG_MANIPURI - 0x59 LANG_SINDHI - 0x5a LANG_SYRIAC - 0x5b LANG_SINHALESE - 0x5c LANG_CHEROKEE - 0x5d LANG_INUKTITUT - 0x5e LANG_AMHARIC - 0x5f LANG_TAMAZIGHT - 0x60 LANG_KASHMIRI - 0x61 LANG_NEPALI - 0x62 LANG_FRISIAN - 0x63 LANG_PASHTO - 0x64 LANG_TAGALOG - 0x65 LANG_DIVEHI - 0x66 LANG_EDO - 0x67 LANG_FULFULDE - 0x68 LANG_HAUSA - 0x69 LANG_IBIBIO - 0x6a LANG_YORUBA - 0x70 LANG_IGBO - 0x71 LANG_KANURI - 0x72 LANG_OROMO - 0x73 LANG_TIGRINYA - 0x74 LANG_GUARANI - 0x75 LANG_HAWAIIAN - 0x76 LANG_LATIN - 0x77 LANG_SOMALI - 0x78 LANG_YI - 0x79 LANG_PAPIAMENTU -*/ -/* Mingw headers don't have latest language and sublanguage codes. */ -# ifndef LANG_AFRIKAANS -# define LANG_AFRIKAANS 0x36 -# endif -# ifndef LANG_ALBANIAN -# define LANG_ALBANIAN 0x1c -# endif -# ifndef LANG_AMHARIC -# define LANG_AMHARIC 0x5e -# endif -# ifndef LANG_ARABIC -# define LANG_ARABIC 0x01 -# endif -# ifndef LANG_ARMENIAN -# define LANG_ARMENIAN 0x2b -# endif -# ifndef LANG_ASSAMESE -# define LANG_ASSAMESE 0x4d -# endif -# ifndef LANG_AZERI -# define LANG_AZERI 0x2c -# endif -# ifndef LANG_BASQUE -# define LANG_BASQUE 0x2d -# endif -# ifndef LANG_BELARUSIAN -# define LANG_BELARUSIAN 0x23 -# endif -# ifndef LANG_BENGALI -# define LANG_BENGALI 0x45 -# endif -# ifndef LANG_BURMESE -# define LANG_BURMESE 0x55 -# endif -# ifndef LANG_CAMBODIAN -# define LANG_CAMBODIAN 0x53 -# endif -# ifndef LANG_CATALAN -# define LANG_CATALAN 0x03 -# endif -# ifndef LANG_CHEROKEE -# define LANG_CHEROKEE 0x5c -# endif -# ifndef LANG_DIVEHI -# define LANG_DIVEHI 0x65 -# endif -# ifndef LANG_EDO -# define LANG_EDO 0x66 -# endif -# ifndef LANG_ESTONIAN -# define LANG_ESTONIAN 0x25 -# endif -# ifndef LANG_FAEROESE -# define LANG_FAEROESE 0x38 -# endif -# ifndef LANG_FARSI -# define LANG_FARSI 0x29 -# endif -# ifndef LANG_FRISIAN -# define LANG_FRISIAN 0x62 -# endif -# ifndef LANG_FULFULDE -# define LANG_FULFULDE 0x67 -# endif -# ifndef LANG_GAELIC -# define LANG_GAELIC 0x3c -# endif -# ifndef LANG_GALICIAN -# define LANG_GALICIAN 0x56 -# endif -# ifndef LANG_GEORGIAN -# define LANG_GEORGIAN 0x37 -# endif -# ifndef LANG_GUARANI -# define LANG_GUARANI 0x74 -# endif -# ifndef LANG_GUJARATI -# define LANG_GUJARATI 0x47 -# endif -# ifndef LANG_HAUSA -# define LANG_HAUSA 0x68 -# endif -# ifndef LANG_HAWAIIAN -# define LANG_HAWAIIAN 0x75 -# endif -# ifndef LANG_HEBREW -# define LANG_HEBREW 0x0d -# endif -# ifndef LANG_HINDI -# define LANG_HINDI 0x39 -# endif -# ifndef LANG_IBIBIO -# define LANG_IBIBIO 0x69 -# endif -# ifndef LANG_IGBO -# define LANG_IGBO 0x70 -# endif -# ifndef LANG_INDONESIAN -# define LANG_INDONESIAN 0x21 -# endif -# ifndef LANG_INUKTITUT -# define LANG_INUKTITUT 0x5d -# endif -# ifndef LANG_KANNADA -# define LANG_KANNADA 0x4b -# endif -# ifndef LANG_KANURI -# define LANG_KANURI 0x71 -# endif -# ifndef LANG_KASHMIRI -# define LANG_KASHMIRI 0x60 -# endif -# ifndef LANG_KAZAK -# define LANG_KAZAK 0x3f -# endif -# ifndef LANG_KONKANI -# define LANG_KONKANI 0x57 -# endif -# ifndef LANG_KYRGYZ -# define LANG_KYRGYZ 0x40 -# endif -# ifndef LANG_LAO -# define LANG_LAO 0x54 -# endif -# ifndef LANG_LATIN -# define LANG_LATIN 0x76 -# endif -# ifndef LANG_LATVIAN -# define LANG_LATVIAN 0x26 -# endif -# ifndef LANG_LITHUANIAN -# define LANG_LITHUANIAN 0x27 -# endif -# ifndef LANG_MACEDONIAN -# define LANG_MACEDONIAN 0x2f -# endif -# ifndef LANG_MALAY -# define LANG_MALAY 0x3e -# endif -# ifndef LANG_MALAYALAM -# define LANG_MALAYALAM 0x4c -# endif -# ifndef LANG_MALTESE -# define LANG_MALTESE 0x3a -# endif -# ifndef LANG_MANIPURI -# define LANG_MANIPURI 0x58 -# endif -# ifndef LANG_MARATHI -# define LANG_MARATHI 0x4e -# endif -# ifndef LANG_MONGOLIAN -# define LANG_MONGOLIAN 0x50 -# endif -# ifndef LANG_NEPALI -# define LANG_NEPALI 0x61 -# endif -# ifndef LANG_ORIYA -# define LANG_ORIYA 0x48 -# endif -# ifndef LANG_OROMO -# define LANG_OROMO 0x72 -# endif -# ifndef LANG_PAPIAMENTU -# define LANG_PAPIAMENTU 0x79 -# endif -# ifndef LANG_PASHTO -# define LANG_PASHTO 0x63 -# endif -# ifndef LANG_PUNJABI -# define LANG_PUNJABI 0x46 -# endif -# ifndef LANG_RHAETO_ROMANCE -# define LANG_RHAETO_ROMANCE 0x17 -# endif -# ifndef LANG_SAAMI -# define LANG_SAAMI 0x3b -# endif -# ifndef LANG_SANSKRIT -# define LANG_SANSKRIT 0x4f -# endif -# ifndef LANG_SERBIAN -# define LANG_SERBIAN 0x1a -# endif -# ifndef LANG_SINDHI -# define LANG_SINDHI 0x59 -# endif -# ifndef LANG_SINHALESE -# define LANG_SINHALESE 0x5b -# endif -# ifndef LANG_SLOVAK -# define LANG_SLOVAK 0x1b -# endif -# ifndef LANG_SOMALI -# define LANG_SOMALI 0x77 -# endif -# ifndef LANG_SORBIAN -# define LANG_SORBIAN 0x2e -# endif -# ifndef LANG_SUTU -# define LANG_SUTU 0x30 -# endif -# ifndef LANG_SWAHILI -# define LANG_SWAHILI 0x41 -# endif -# ifndef LANG_SYRIAC -# define LANG_SYRIAC 0x5a -# endif -# ifndef LANG_TAGALOG -# define LANG_TAGALOG 0x64 -# endif -# ifndef LANG_TAJIK -# define LANG_TAJIK 0x28 -# endif -# ifndef LANG_TAMAZIGHT -# define LANG_TAMAZIGHT 0x5f -# endif -# ifndef LANG_TAMIL -# define LANG_TAMIL 0x49 -# endif -# ifndef LANG_TATAR -# define LANG_TATAR 0x44 -# endif -# ifndef LANG_TELUGU -# define LANG_TELUGU 0x4a -# endif -# ifndef LANG_THAI -# define LANG_THAI 0x1e -# endif -# ifndef LANG_TIBETAN -# define LANG_TIBETAN 0x51 -# endif -# ifndef LANG_TIGRINYA -# define LANG_TIGRINYA 0x73 -# endif -# ifndef LANG_TSONGA -# define LANG_TSONGA 0x31 -# endif -# ifndef LANG_TSWANA -# define LANG_TSWANA 0x32 -# endif -# ifndef LANG_TURKMEN -# define LANG_TURKMEN 0x42 -# endif -# ifndef LANG_UKRAINIAN -# define LANG_UKRAINIAN 0x22 -# endif -# ifndef LANG_URDU -# define LANG_URDU 0x20 -# endif -# ifndef LANG_UZBEK -# define LANG_UZBEK 0x43 -# endif -# ifndef LANG_VENDA -# define LANG_VENDA 0x33 -# endif -# ifndef LANG_VIETNAMESE -# define LANG_VIETNAMESE 0x2a -# endif -# ifndef LANG_WELSH -# define LANG_WELSH 0x52 -# endif -# ifndef LANG_XHOSA -# define LANG_XHOSA 0x34 -# endif -# ifndef LANG_YI -# define LANG_YI 0x78 -# endif -# ifndef LANG_YIDDISH -# define LANG_YIDDISH 0x3d -# endif -# ifndef LANG_YORUBA -# define LANG_YORUBA 0x6a -# endif -# ifndef LANG_ZULU -# define LANG_ZULU 0x35 -# endif -# ifndef SUBLANG_ARABIC_SAUDI_ARABIA -# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01 -# endif -# ifndef SUBLANG_ARABIC_IRAQ -# define SUBLANG_ARABIC_IRAQ 0x02 -# endif -# ifndef SUBLANG_ARABIC_EGYPT -# define SUBLANG_ARABIC_EGYPT 0x03 -# endif -# ifndef SUBLANG_ARABIC_LIBYA -# define SUBLANG_ARABIC_LIBYA 0x04 -# endif -# ifndef SUBLANG_ARABIC_ALGERIA -# define SUBLANG_ARABIC_ALGERIA 0x05 -# endif -# ifndef SUBLANG_ARABIC_MOROCCO -# define SUBLANG_ARABIC_MOROCCO 0x06 -# endif -# ifndef SUBLANG_ARABIC_TUNISIA -# define SUBLANG_ARABIC_TUNISIA 0x07 -# endif -# ifndef SUBLANG_ARABIC_OMAN -# define SUBLANG_ARABIC_OMAN 0x08 -# endif -# ifndef SUBLANG_ARABIC_YEMEN -# define SUBLANG_ARABIC_YEMEN 0x09 -# endif -# ifndef SUBLANG_ARABIC_SYRIA -# define SUBLANG_ARABIC_SYRIA 0x0a -# endif -# ifndef SUBLANG_ARABIC_JORDAN -# define SUBLANG_ARABIC_JORDAN 0x0b -# endif -# ifndef SUBLANG_ARABIC_LEBANON -# define SUBLANG_ARABIC_LEBANON 0x0c -# endif -# ifndef SUBLANG_ARABIC_KUWAIT -# define SUBLANG_ARABIC_KUWAIT 0x0d -# endif -# ifndef SUBLANG_ARABIC_UAE -# define SUBLANG_ARABIC_UAE 0x0e -# endif -# ifndef SUBLANG_ARABIC_BAHRAIN -# define SUBLANG_ARABIC_BAHRAIN 0x0f -# endif -# ifndef SUBLANG_ARABIC_QATAR -# define SUBLANG_ARABIC_QATAR 0x10 -# endif -# ifndef SUBLANG_AZERI_LATIN -# define SUBLANG_AZERI_LATIN 0x01 -# endif -# ifndef SUBLANG_AZERI_CYRILLIC -# define SUBLANG_AZERI_CYRILLIC 0x02 -# endif -# ifndef SUBLANG_BENGALI_INDIA -# define SUBLANG_BENGALI_INDIA 0x01 -# endif -# ifndef SUBLANG_BENGALI_BANGLADESH -# define SUBLANG_BENGALI_BANGLADESH 0x02 -# endif -# ifndef SUBLANG_CHINESE_MACAU -# define SUBLANG_CHINESE_MACAU 0x05 -# endif -# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA -# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07 -# endif -# ifndef SUBLANG_ENGLISH_JAMAICA -# define SUBLANG_ENGLISH_JAMAICA 0x08 -# endif -# ifndef SUBLANG_ENGLISH_CARIBBEAN -# define SUBLANG_ENGLISH_CARIBBEAN 0x09 -# endif -# ifndef SUBLANG_ENGLISH_BELIZE -# define SUBLANG_ENGLISH_BELIZE 0x0a -# endif -# ifndef SUBLANG_ENGLISH_TRINIDAD -# define SUBLANG_ENGLISH_TRINIDAD 0x0b -# endif -# ifndef SUBLANG_ENGLISH_ZIMBABWE -# define SUBLANG_ENGLISH_ZIMBABWE 0x0c -# endif -# ifndef SUBLANG_ENGLISH_PHILIPPINES -# define SUBLANG_ENGLISH_PHILIPPINES 0x0d -# endif -# ifndef SUBLANG_ENGLISH_INDONESIA -# define SUBLANG_ENGLISH_INDONESIA 0x0e -# endif -# ifndef SUBLANG_ENGLISH_HONGKONG -# define SUBLANG_ENGLISH_HONGKONG 0x0f -# endif -# ifndef SUBLANG_ENGLISH_INDIA -# define SUBLANG_ENGLISH_INDIA 0x10 -# endif -# ifndef SUBLANG_ENGLISH_MALAYSIA -# define SUBLANG_ENGLISH_MALAYSIA 0x11 -# endif -# ifndef SUBLANG_ENGLISH_SINGAPORE -# define SUBLANG_ENGLISH_SINGAPORE 0x12 -# endif -# ifndef SUBLANG_FRENCH_LUXEMBOURG -# define SUBLANG_FRENCH_LUXEMBOURG 0x05 -# endif -# ifndef SUBLANG_FRENCH_MONACO -# define SUBLANG_FRENCH_MONACO 0x06 -# endif -# ifndef SUBLANG_FRENCH_WESTINDIES -# define SUBLANG_FRENCH_WESTINDIES 0x07 -# endif -# ifndef SUBLANG_FRENCH_REUNION -# define SUBLANG_FRENCH_REUNION 0x08 -# endif -# ifndef SUBLANG_FRENCH_CONGO -# define SUBLANG_FRENCH_CONGO 0x09 -# endif -# ifndef SUBLANG_FRENCH_SENEGAL -# define SUBLANG_FRENCH_SENEGAL 0x0a -# endif -# ifndef SUBLANG_FRENCH_CAMEROON -# define SUBLANG_FRENCH_CAMEROON 0x0b -# endif -# ifndef SUBLANG_FRENCH_COTEDIVOIRE -# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c -# endif -# ifndef SUBLANG_FRENCH_MALI -# define SUBLANG_FRENCH_MALI 0x0d From cvs at cvs.gnupg.org Thu Jan 21 14:33:34 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 21 Jan 2010 14:33:34 +0100 Subject: [svn] gcry - r1419 - in trunk: . cipher src Message-ID: Author: wk Date: 2010-01-21 14:33:34 +0100 (Thu, 21 Jan 2010) New Revision: 1419 Modified: trunk/NEWS trunk/THANKS trunk/cipher/Makefile.am trunk/cipher/sha256.c trunk/cipher/sha512.c trunk/src/ChangeLog trunk/src/gcrypt.h.in Log: Add an identifier for ECDH. Fixed some NEWS entries. Updated copyright lines. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-12-11 17:48:06 UTC (rev 1418) +++ trunk/src/ChangeLog 2010-01-21 13:33:34 UTC (rev 1419) @@ -1,3 +1,7 @@ +2010-01-05 Werner Koch + + * gcrypt.h.in (GCRY_PK_ECDH): New. + 2009-12-08 Werner Koch * gcrypt.h.in (GCRY_CIPHER_MODE_AESWRAP): New. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-12-11 17:48:06 UTC (rev 1418) +++ trunk/NEWS 2010-01-21 13:33:34 UTC (rev 1419) @@ -3,20 +3,21 @@ * New cipher algorithm mode for AES-WRAP. - * Fix minor memory leak in DSA key generation. + * Fixed minor memory leak in DSA key generation. - * No switch into FIPS mode if /proc/version is not readable. + * No more switching to FIPS mode if /proc/version is not readable. - * Fix sigill during Padlock detection on old CPUs. + * Fixed sigill during Padlock detection on old CPUs. - * Fix a hang on some W2000 machines. + * Fixed a hang on some W2000 machines. - * Boost SHA-512 performance by 30% on ia32 boxes and gcc 4.3; SHA-256 - goes up by 25%. + * Boosted SHA-512 performance by 30% on ia32 boxes and gcc 4.3; + SHA-256 went up by 25%. * Interface changes relative to the 1.4.2 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GCRY_CIPHER_MODE_AESWRAP NEW. + GCRY_PK_ECDH NEW. Noteworthy changes in version 1.4.4 (2009-01-22) Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2009-12-11 17:48:06 UTC (rev 1418) +++ trunk/THANKS 2010-01-21 13:33:34 UTC (rev 1419) @@ -18,7 +18,7 @@ Cees van de Griend cees-list at griend.xs4all.nl Charles Levert charles at comm.polymtl.ca Christian Biere christianbiere at gmx.de -Christian Grothoff grothoff at cs.purdue.edu +Christian Grothoff christian at grothoff org Christian von Roques roques at pond.sub.org Christopher Oliver oliver at fritz.traverse.net Christian Recktenwald chris at citecs.de Modified: trunk/cipher/Makefile.am =================================================================== --- trunk/cipher/Makefile.am 2009-12-11 17:48:06 UTC (rev 1418) +++ trunk/cipher/Makefile.am 2010-01-21 13:33:34 UTC (rev 1419) @@ -1,6 +1,6 @@ # Makefile for cipher modules # Copyright (C) 1998, 1999, 2000, 2001, 2002, -# 2003 Free Software Foundation, Inc. +# 2003, 2009 Free Software Foundation, Inc. # # This file is part of Libgcrypt. # Modified: trunk/cipher/sha256.c =================================================================== --- trunk/cipher/sha256.c 2009-12-11 17:48:06 UTC (rev 1418) +++ trunk/cipher/sha256.c 2010-01-21 13:33:34 UTC (rev 1419) @@ -1,5 +1,5 @@ /* sha256.c - SHA256 hash function - * Copyright (C) 2003, 2006, 2008 Free Software Foundation, Inc. + * Copyright (C) 2003, 2006, 2008, 2009 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * Modified: trunk/cipher/sha512.c =================================================================== --- trunk/cipher/sha512.c 2009-12-11 17:48:06 UTC (rev 1418) +++ trunk/cipher/sha512.c 2010-01-21 13:33:34 UTC (rev 1419) @@ -1,5 +1,5 @@ /* sha512.c - SHA384 and SHA512 hash functions - * Copyright (C) 2003, 2008 Free Software Foundation, Inc. + * Copyright (C) 2003, 2008, 2009 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * Modified: trunk/src/gcrypt.h.in =================================================================== --- trunk/src/gcrypt.h.in 2009-12-11 17:48:06 UTC (rev 1418) +++ trunk/src/gcrypt.h.in 2010-01-21 13:33:34 UTC (rev 1419) @@ -970,7 +970,8 @@ GCRY_PK_ELG_E = 16, GCRY_PK_DSA = 17, GCRY_PK_ELG = 20, - GCRY_PK_ECDSA = 301 + GCRY_PK_ECDSA = 301, + GCRY_PK_ECDH = 302 }; /* Flags describing usage capabilities of a PK algorithm. */ From cvs at cvs.gnupg.org Thu Jan 21 22:36:43 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 21 Jan 2010 22:36:43 +0100 Subject: [svn] gcry - r1420 - in trunk: . compat m4 random src tests Message-ID: Author: wk Date: 2010-01-21 22:36:43 +0100 (Thu, 21 Jan 2010) New Revision: 1420 Added: trunk/compat/ trunk/compat/Makefile.am trunk/compat/clock.c trunk/compat/compat.c trunk/compat/getpid.c trunk/compat/libcompat.h Modified: trunk/ChangeLog trunk/Makefile.am trunk/NEWS trunk/TODO trunk/autogen.sh trunk/configure.ac trunk/ltmain.sh trunk/m4/ltversion.m4 trunk/random/ChangeLog trunk/random/random-csprng.c trunk/random/rndw32.c trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/dumpsexp.c trunk/src/g10lib.h trunk/src/global.c trunk/src/hmac256.c trunk/src/secmem.c trunk/tests/ChangeLog trunk/tests/Makefile.am trunk/tests/benchmark.c Log: Support WindowsCE. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/ChangeLog 2010-01-21 21:36:43 UTC (rev 1420) @@ -1,3 +1,22 @@ +2010-01-21 Werner Koch + + * compat/Makefile.am: New. + * compat/compat.c: New. + * compat/libcompat.h: New. + * compat/getpid.c, compat/clock.c: New. + + * configure.ac: Require libgpg-error 1.8. + (HAVE_W32CE_SYSTEM): New am_defines and am_conditionals. + (getpid): Check for replacement function. + (AC_CONFIG_LIBOBJ_DIR): New. + (AC_TYPE_PID_T): New. + (AM_INIT_AUTOMAKE): Use modern variant. + (AC_CONFIG_FILES): Add compat/Makfile. + * autogen.sh: Support W32CE. + * ltmain.sh: Update to 2.2.6b + (wrappers_required): Don't set for mingw32ce. + * Makefile.am (DIST_SUBDIRS, SUBDIRS): Add compat. + 2009-12-10 Werner Koch * configure.ac: Add option --disable-O-flag-munging. @@ -29,7 +48,7 @@ 2009-01-22 Werner Koch Release 1.4.4. - + * configure.ac: Bump LT version to C16/A5/R2. 2008-10-30 Werner Koch Modified: trunk/random/ChangeLog =================================================================== --- trunk/random/ChangeLog 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/random/ChangeLog 2010-01-21 21:36:43 UTC (rev 1420) @@ -1,3 +1,10 @@ +2010-01-21 Werner Koch + + * rndw32.c (read_mbm_data) [W32CE]: Do not build. + (slow_gatherer) [W32CE]: Do not call read_mbm_data. + (_gcry_rndw32_gather_random_fast) [W32CE]: Exclude some calls. + (_gcry_rndw32_gather_random): Adjust version test for WindowsCE. + 2009-12-10 Werner Koch * rndw32.c (system_is_w2000): New. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/src/ChangeLog 2010-01-21 21:36:43 UTC (rev 1420) @@ -1,3 +1,20 @@ +2010-01-21 Werner Koch + + * Makefile.am (arch_gpg_error_cflags, arch_gpg_error_libs): New. + (dumpsexp_CFLAGS): New. + (dumpsexp_LDADD): Add arch_gpg_error_libs. + (hmac256_CFLAGS, hmac256_LDADD): Add the arch variables. + (libgcrypt_la_DEPENDENCIES): Add libcompat. + * secmem.c (lock_pool): Mark unused args. + * global.c (do_malloc, gcry_realloc, gcry_free, gcry_calloc) + (gcry_calloc_secure, gcry_xcalloc, gcry_xcalloc_secure): Use + gpg_err_set_errno. + (_gcry_vcontrol): Call _gcry_compat_identification. + * hmac256.c [__MINGW32CE__]: Include gpg-error.h. + (_gcry_hmac256_file): Use gpg_err_set_errno. + (gpg_err_set_errno) [!GPG_ERR_INLINE]: Add macro. + * g10lib.h: Include libcompat.h. + 2010-01-05 Werner Koch * gcrypt.h.in (GCRY_PK_ECDH): New. Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/tests/ChangeLog 2010-01-21 21:36:43 UTC (rev 1420) @@ -1,3 +1,9 @@ +2010-01-21 Werner Koch + + * benchmark.c [_GCRYPT_IN_LIBGCRYPT]: Include libcompat.h. + (start_timer, stop_timer) [__MINGW32CE__]: Use GetThreadTimes. + * Makefile.am (LDADD): Add libcompat. + 2009-12-10 Werner Koch * basic.c (check_ctr_cipher): Add some return code checks. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/Makefile.am 2010-01-21 21:36:43 UTC (rev 1420) @@ -22,8 +22,8 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-random-daemon \ --enable-ciphers=arcfour:blowfish:cast5:des:aes:twofish:serpent:rfc2268:seed:camellia -DIST_SUBDIRS = m4 mpi cipher random src doc tests -SUBDIRS = mpi cipher random src doc tests +DIST_SUBDIRS = m4 compat mpi cipher random src doc tests +SUBDIRS = compat mpi cipher random src doc tests EXTRA_DIST = autogen.sh README.SVN DISTCLEANFILES = Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/NEWS 2010-01-21 21:36:43 UTC (rev 1420) @@ -14,6 +14,8 @@ * Boosted SHA-512 performance by 30% on ia32 boxes and gcc 4.3; SHA-256 went up by 25%. + * Support for WindowsCE. + * Interface changes relative to the 1.4.2 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GCRY_CIPHER_MODE_AESWRAP NEW. Modified: trunk/TODO =================================================================== --- trunk/TODO 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/TODO 2010-01-21 21:36:43 UTC (rev 1420) @@ -1,4 +1,4 @@ -What's left to do -*- outline -*- +# What's left to do -*- org -*- * Next API break: ** gcry_ac_io_t Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/autogen.sh 2010-01-21 21:36:43 UTC (rev 1420) @@ -36,9 +36,28 @@ shift fi +# Convenience option to use certain configure options for some hosts. +myhost="" +myhostsub="" +case "$1" in + --build-w32) + myhost="w32" + ;; + --build-w32ce) + myhost="w32" + myhostsub="ce" + ;; + --build-amd64) + myhost="amd64" + ;; + *) + ;; +esac + + # ***** W32 build script ******* # Used to cross-compile for Windows. -if test "$1" = "--build-w32"; then +if [ "$myhost" = "w32" ]; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift @@ -48,12 +67,21 @@ fi build=`$tsdir/config.guess` - [ -z "$w32root" ] && w32root="$HOME/w32root" + case $myhostsub in + ce) + [ -z "$w32root" ] && w32root="$HOME/w32ce_root" + toolprefixes="arm-mingw32ce" + ;; + *) + [ -z "$w32root" ] && w32root="$HOME/w32root" + toolprefixes="i586-mingw32msvc i386-mingw32msvc" + ;; + esac echo "Using $w32root as standard install directory" >&2 # Locate the cross compiler crossbindir= - for host in i586-mingw32msvc i386-mingw32msvc; do + for host in $toolprefixes; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -62,8 +90,10 @@ done if [ -z "$crossbindir" ]; then echo "Cross compiler kit not installed" >&2 - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + if [ -z "$sub" ]; then + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fi echo "Stop." >&2 exit 1 fi @@ -85,7 +115,7 @@ # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) -if test "$1" = "--build-amd64"; then +if [ "$myhost" = "amd64" ]; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift Added: trunk/compat/Makefile.am =================================================================== --- trunk/compat/Makefile.am (rev 0) +++ trunk/compat/Makefile.am 2010-01-21 21:36:43 UTC (rev 1420) @@ -0,0 +1,50 @@ +# Makefile for compat directory +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This file is part of Libgcrypt. +# +# Libgcrypt 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. +# +# Libgcrypt 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 . + +# Process this file with automake to produce Makefile.in + +# We use this libcompat to work around problems with LIBOBJ stuff. +# For example, we need some of the compat files also in tests/ but the +# suggested way to do this (using the automake option subdir-objects) +# leads to problems with "make distclean": The distclean target in +# tests is run before the one src and it removes the deps files of the +# libobj files which are in src. Now when it comes to run make in src +# the icnluded files are gone - bummer. Instead of try to fix this +# issue it seems better not to use subdir-objects but build them all +# into a compat library and always link against that library. This +# also avoids the problem that a dependency on LTLIBOBJ is not setup +# if -- disable-static was used. + +# Need to include ../src in addition to top_srcdir because gcrypt.h is +# a built header. +AM_CPPFLAGS = -I../src -I$(top_srcdir)/src $(GPG_ERROR_CFLAGS) + +noinst_LTLIBRARIES = libcompat.la + +# We only need one file so that the library is guaranteed to have at +# least one member. +libcompat_la_SOURCES = compat.c libcompat.h +libcompat_la_DEPENDENCIES = @LTLIBOBJS@ +libcompat_la_LIBADD = @LTLIBOBJS@ + +# AC_LIBOBJ files are: +# getpid.c +# clock.c +# + + Added: trunk/compat/clock.c =================================================================== --- trunk/compat/clock.c (rev 0) +++ trunk/compat/clock.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -0,0 +1,36 @@ +/* clock.c - Replacement for WindowsCE + Copyright (C) 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_W32CE_SYSTEM +#include +#include +#include + +clock_t +_gcry_clock (void) +{ + assert (CLOCKS_PER_SEC == 1000); +#warning Replace by a correct implementaion. + /* It seems that GetProcessTimes is available in the kernel but + without a declaration. If that fails we would need to walk over + all threads and tally up the GetThreadTimes. */ + + return GetTickCount (); +} + +#else +# error No replacement function for clock known +#endif Property changes on: trunk/compat/clock.c ___________________________________________________________________ Name: svn:mergeinfo + Added: trunk/compat/compat.c =================================================================== --- trunk/compat/compat.c (rev 0) +++ trunk/compat/compat.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -0,0 +1,36 @@ +/* compat.c - Dummy file to avoid an empty library. + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * This file is part of Libgcrypt. + * + * Libgcrypt 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. + * + * Libgcrypt 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 . + */ + +#include + +#include "../src/g10lib.h" + + +const char * +_gcry_compat_identification (void) +{ + static const char blurb[] = + "\n\n" + "This is Libgcrypt - The GNU Crypto Library\n" + "Copyright 2000, 2002, 2003, 2004, 2007, 2008, 2009,\n" + " 2010 Free Software Foundation, Inc.\n" + "\n\n"; + return blurb; +} + Added: trunk/compat/getpid.c =================================================================== --- trunk/compat/getpid.c (rev 0) +++ trunk/compat/getpid.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -0,0 +1,29 @@ +/* getpid.c - Replacement for WindowsCE + Copyright (C) 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_W32CE_SYSTEM +#include +#include + +pid_t +_gcry_getpid (void) +{ + return GetCurrentProcessId (); +} + +#else +# error No replacement function for getpid known +#endif Property changes on: trunk/compat/getpid.c ___________________________________________________________________ Name: svn:mergeinfo + Added: trunk/compat/libcompat.h =================================================================== --- trunk/compat/libcompat.h (rev 0) +++ trunk/compat/libcompat.h 2010-01-21 21:36:43 UTC (rev 1420) @@ -0,0 +1,37 @@ +/* libcomapt.h - Prototypes for AC_REPLACE_FUNCtions. + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * This file is part of Libgcrypt. + * + * Libgcrypt 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. + * + * Libgcrypt 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 GCRY_LIBCOMPAT_H +#define GCRY_LIBCOMPAT_H + +const char *_gcry_compat_identification (void); + + +#ifndef HAVE_GETPID +pid_t _gcry_getpid (void); +#define getpid() _gcry_getpid () +#endif + +#ifndef HAVE_CLOCK +clock_t _gcry_clock (void); +#define clock() _gcry_clock () +#endif + + +#endif /*GCRY_LIBCOMPAT_H*/ Property changes on: trunk/compat/libcompat.h ___________________________________________________________________ Name: svn:mergeinfo + Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/configure.ac 2010-01-21 21:36:43 UTC (rev 1420) @@ -47,7 +47,7 @@ # If the API is changed in an incompatible way: increment the next counter. LIBGCRYPT_CONFIG_API_VERSION=1 -NEED_GPG_ERROR_VERSION=1.4 +NEED_GPG_ERROR_VERSION=1.8 is_development_version=my_issvn BUILD_REVISION=svn_revision @@ -55,9 +55,10 @@ VERSION=$PACKAGE_VERSION AC_CONFIG_SRCDIR([src/libgcrypt.vers]) -AM_INIT_AUTOMAKE($PACKAGE, $VERSION) +AM_INIT_AUTOMAKE([]) AM_CONFIG_HEADER(config.h) AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_LIBOBJ_DIR([compat]) AC_CANONICAL_HOST AM_MAINTAINER_MODE @@ -170,6 +171,7 @@ # Other definitions. print_egd_notice=no have_w32_system=no +have_w32ce_system=no # Setup some stuff depending on host. case "${host}" in @@ -177,6 +179,7 @@ available_random_modules="w32" ac_cv_have_dev_random=no have_w32_system=yes + case "${host}" in *-mingw32ce*) have_w32ce_system=yes ;; esac AC_DEFINE(USE_ONLY_8DOT3,1, [set this to limit filenames to the 8.3 format]) AC_DEFINE(HAVE_DRIVE_LETTERS,1, @@ -227,13 +230,21 @@ if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) + if test "$have_w32ce_system" = yes; then + AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE]) + fi fi AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) +AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes) # A printable OS Name is sometimes useful. case "${host}" in + *-*-mingw32ce*) + PRINTABLE_OS_NAME="MingW32CE" + ;; + *-*-mingw32*) PRINTABLE_OS_NAME="MingW32" ;; @@ -595,6 +606,7 @@ AC_TYPE_SIZE_T AC_TYPE_SIGNAL AC_DECL_SYS_SIGLIST +AC_TYPE_PID_T GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF) GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF) @@ -718,7 +730,12 @@ GNUPG_CHECK_MLOCK +# +# Replacement functions. +# +AC_REPLACE_FUNCS([getpid clock]) + # # Check wether it is necessary to link against libdl. # @@ -1128,6 +1145,7 @@ AC_CONFIG_FILES([ Makefile m4/Makefile +compat/Makefile mpi/Makefile cipher/Makefile random/Makefile Modified: trunk/ltmain.sh =================================================================== --- trunk/ltmain.sh 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/ltmain.sh 2010-01-21 21:36:43 UTC (rev 1420) @@ -1,6 +1,6 @@ # Generated from ltmain.m4sh. -# ltmain.sh (GNU libtool) 2.2.6 +# ltmain.sh (GNU libtool) 2.2.6b # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. @@ -65,7 +65,7 @@ # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.2.6 Debian-2.2.6a-4 +# $progname: (GNU libtool) 2.2.6b Debian-2.2.6b-2 # automake: $automake_version # autoconf: $autoconf_version # @@ -73,9 +73,9 @@ PROGRAM=ltmain.sh PACKAGE=libtool -VERSION="2.2.6 Debian-2.2.6a-4" +VERSION="2.2.6b Debian-2.2.6b-2" TIMESTAMP="" -package_revision=1.3012 +package_revision=1.3017 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then @@ -7681,15 +7681,15 @@ wrappers_required=yes case $host in + *cegcc | *mingw32ce* ) + # Disable wrappers for cegcc, we are cross compiling anyway. + wrappers_required=no + ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; - *cegcc) - # Disable wrappers for cegcc, we are cross compiling anyway. - wrappers_required=no - ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no Modified: trunk/m4/ltversion.m4 =================================================================== --- trunk/m4/ltversion.m4 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/m4/ltversion.m4 2010-01-21 21:36:43 UTC (rev 1420) @@ -9,15 +9,15 @@ # Generated from ltversion.in. -# serial 3012 ltversion.m4 +# serial 3017 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.2.6]) -m4_define([LT_PACKAGE_REVISION], [1.3012]) +m4_define([LT_PACKAGE_VERSION], [2.2.6b]) +m4_define([LT_PACKAGE_REVISION], [1.3017]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.2.6' -macro_revision='1.3012' +[macro_version='2.2.6b' +macro_revision='1.3017' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) Modified: trunk/random/random-csprng.c =================================================================== --- trunk/random/random-csprng.c 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/random/random-csprng.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -682,6 +682,7 @@ static int lock_seed_file (int fd, const char *fname, int for_write) { +#warning Check whether we can lock on Windows. #if LOCK_SEED_FILE struct flock lck; struct timeval tv; @@ -709,7 +710,7 @@ if (backoff < 10) backoff++ ; } -#endif /*LOCK_SEED_FILE*/ +#endif /*!LOCK_SEED_FILE*/ return 0; } Modified: trunk/random/rndw32.c =================================================================== --- trunk/random/rndw32.c 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/random/rndw32.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -1,5 +1,6 @@ /* rndw32.c - W32 entropy gatherer - * Copyright (C) 1999, 2000, 2002, 2003, 2007 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000, 2002, 2003, 2007, + * 2010 Free Software Foundation, Inc. * Copyright Peter Gutmann, Matt Thomlinson and Blake Coverett 1996-2006 * * This file is part of Libgcrypt. @@ -328,6 +329,7 @@ /* Read data from MBM. This communicates via shared memory, so all we need to do is map a file and read the data out. */ +#ifndef HAVE_W32CE_SYSTEM static void read_mbm_data (void (*add)(const void*, size_t, enum random_origins), enum random_origins requester) @@ -350,6 +352,7 @@ CloseHandle (hMBMData); } } +#endif /*!HAVE_W32CE_SYSTEM*/ /* Fallback method using the registry to poll the statistics. */ @@ -556,8 +559,10 @@ } read_system_rng ( add, requester ); +#ifndef HAVE_W32CE_SYSTEM read_mbm_data ( add, requester ); - +#endif + /* Get network statistics. Note: Both NT Workstation and NT Server by default will be running both the workstation and server services. The heuristic below is probably useful though on the assumption that the @@ -774,8 +779,13 @@ OSVERSIONINFO osvi = { sizeof( osvi ) }; GetVersionEx( &osvi ); - if ( osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) +#ifdef HAVE_W32CE_SYSTEM + if (osvi.dwPlatformId != VER_PLATFORM_WIN32_CE) + log_fatal ("can only run on a Windows CE platform\n" ); +#else + if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) log_fatal ("can only run on a Windows NT platform\n" ); +#endif system_is_w2000 = (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0); init_system_rng (); is_initialized = 1; @@ -821,23 +831,28 @@ memcpy (bufptr, &along, sizeof (along) ); \ bufptr += sizeof (along); \ } while (0) +#ifdef HAVE_W32CE_SYSTEM +# define ADD_NO_CE(f) +#else +# define ADD_NO_CE(f) ADD(f) +#endif ADD ( GetActiveWindow ()); ADD ( GetCapture ()); ADD ( GetClipboardOwner ()); - ADD ( GetClipboardViewer ()); + ADD_NO_CE ( GetClipboardViewer ()); ADD ( GetCurrentProcess ()); ADD ( GetCurrentProcessId ()); ADD ( GetCurrentThread ()); ADD ( GetCurrentThreadId ()); ADD ( GetDesktopWindow ()); ADD ( GetFocus ()); - ADD ( GetInputState ()); + ADD_NO_CE ( GetInputState ()); ADD ( GetMessagePos ()); - ADD ( GetMessageTime ()); + ADD_NO_CE ( GetMessageTime ()); ADD ( GetOpenClipboardWindow ()); ADD ( GetProcessHeap ()); - ADD ( GetProcessWindowStation ()); + ADD_NO_CE ( GetProcessWindowStation ()); ADD ( GetQueueStatus (QS_ALLEVENTS)); ADD ( GetTickCount ()); @@ -883,9 +898,15 @@ (*add) ( &kernelTime, sizeof (kernelTime), origin ); (*add) ( &userTime, sizeof (userTime), origin ); +#ifdef HAVE_W32CE_SYSTEM + handle = GetCurrentThread (); + GetThreadTimes (handle, &creationTime, &exitTime, + &kernelTime, &userTime); +#else handle = GetCurrentProcess (); GetProcessTimes (handle, &creationTime, &exitTime, &kernelTime, &userTime); +#endif (*add) ( &creationTime, sizeof (creationTime), origin ); (*add) ( &exitTime, sizeof (exitTime), origin ); (*add) ( &kernelTime, sizeof (kernelTime), origin ); @@ -893,17 +914,20 @@ /* Get the minimum and maximum working set size for the current process. */ +#ifndef HAVE_W32CE_SYSTEM GetProcessWorkingSetSize (handle, &minimumWorkingSetSize, &maximumWorkingSetSize); (*add) ( &minimumWorkingSetSize, sizeof (minimumWorkingSetSize), origin ); (*add) ( &maximumWorkingSetSize, sizeof (maximumWorkingSetSize), origin ); +#endif /*!HAVE_W32CE_SYSTEM*/ } /* The following are fixed for the lifetime of the process so we only * add them once */ +#ifndef HAVE_W32CE_SYSTEM if (!addedFixedItems) { STARTUPINFO startupInfo; @@ -916,6 +940,7 @@ (*add) ( &startupInfo, sizeof (STARTUPINFO), origin ); addedFixedItems = 1; } +#endif /*!HAVE_W32CE_SYSTEM*/ /* The performance of QPC varies depending on the architecture it's running on and on the OS, the MS documentation is vague about the Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/src/Makefile.am 2010-01-21 21:36:43 UTC (rev 1420) @@ -14,14 +14,15 @@ # 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 +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . + ## Process this file with automake to produce Makefile.in EXTRA_DIST = Manifest libgcrypt-config.in libgcrypt.m4 libgcrypt.vers \ gcrypt.h.in libgcrypt.def + bin_SCRIPTS = libgcrypt-config m4datadir = $(datadir)/aclocal m4data_DATA = libgcrypt.m4 @@ -34,14 +35,23 @@ bin_PROGRAMS += getrandom endif USE_RANDOM_DAEMON +# Depending on the architecture some targets require libgpg-error. +if HAVE_W32CE_SYSTEM +arch_gpg_error_cflags = $(GPG_ERROR_CFLAGS) +arch_gpg_error_libs = $(GPG_ERROR_LIBS) +else +arch_gpg_error_cflags = +arch_gpg_error_libs = +endif + if HAVE_LD_VERSION_SCRIPT libgcrypt_version_script_cmd = -Wl,--version-script=$(srcdir)/libgcrypt.vers else libgcrypt_version_script_cmd = endif -libgcrypt_la_CFLAGS = @GPG_ERROR_CFLAGS@ +libgcrypt_la_CFLAGS = $(GPG_ERROR_CFLAGS) libgcrypt_la_SOURCES = g10lib.h visibility.c visibility.h types.h \ cipher.h cipher-proto.h \ misc.c global.c sexp.c hwfeatures.c \ @@ -94,19 +104,22 @@ ../cipher/libcipher.la \ ../random/librandom.la \ ../mpi/libmpi.la \ - $(srcdir)/libgcrypt.vers $(gcrypt_deps) + ../compat/libcompat.la \ + $(srcdir)/libgcrypt.vers $(gcrypt_deps) libgcrypt_la_LIBADD = $(gcrypt_res) \ ../cipher/libcipher.la \ ../random/librandom.la \ - ../mpi/libmpi.la @LTLIBOBJS@ @GPG_ERROR_LIBS@ + ../mpi/libmpi.la \ + ../compat/libcompat.la $(GPG_ERROR_LIBS) dumpsexp_SOURCES = dumpsexp.c -dumpsexp_LDADD = +dumpsexp_CFLAGS = $(arch_gpg_error_cflags) +dumpsexp_LDADD = $(arch_gpg_error_libs) hmac256_SOURCES = hmac256.c -hmac256_CFLAGS = -DSTANDALONE -hmac256_LDADD = +hmac256_CFLAGS = -DSTANDALONE $(arch_gpg_error_cflags) +hmac256_LDADD = $(arch_gpg_error_libs) if USE_RANDOM_DAEMON gcryptrnd_SOURCES = gcryptrnd.c Modified: trunk/src/dumpsexp.c =================================================================== --- trunk/src/dumpsexp.c 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/src/dumpsexp.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -22,6 +22,11 @@ #include #include #include +/* For a native WindowsCE binary we need to include gpg-error.h to + provide a replacement for strerror. */ +#ifdef __MINGW32CE__ +# include +#endif #define PGM "dumpsexp" #define MYVERSION_LINE PGM " (Libgcrypt) " VERSION Modified: trunk/src/g10lib.h =================================================================== --- trunk/src/g10lib.h 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/src/g10lib.h 2010-01-21 21:36:43 UTC (rev 1420) @@ -201,6 +201,9 @@ int strcasecmp (const char *a, const char *b) _GCRY_GCC_ATTR_PURE; #endif +#include "../compat/libcompat.h" + + /* Macros used to rename missing functions. */ #ifndef HAVE_STRTOUL #define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c))) Modified: trunk/src/global.c =================================================================== --- trunk/src/global.c 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/src/global.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -566,6 +566,8 @@ default: + /* A call to make sure that the dummy code is linked in. */ + _gcry_compat_identification (); err = GPG_ERR_INV_OP; } @@ -742,7 +744,7 @@ /* Make sure that ERRNO has been set in case a user supplied memory handler didn't it correctly. */ if (!errno) - errno = ENOMEM; + gpg_err_set_errno (ENOMEM); err = gpg_err_code_from_errno (errno); } else @@ -805,7 +807,7 @@ else p = _gcry_private_realloc (a, n); if (!p && !errno) - errno = ENOMEM; + gpg_err_set_errno (ENOMEM); return p; } @@ -827,7 +829,7 @@ _gcry_private_free (p); if (save_errno) - errno = save_errno; + gpg_err_set_errno (save_errno); } void * @@ -840,7 +842,7 @@ defined. */ if (m && bytes / m != n) { - errno = ENOMEM; + gpg_err_set_errno (ENOMEM); return NULL; } @@ -860,7 +862,7 @@ defined. */ if (m && bytes / m != n) { - errno = ENOMEM; + gpg_err_set_errno (ENOMEM); return NULL; } @@ -958,7 +960,7 @@ nbytes = n * m; if (m && nbytes / m != n) { - errno = ENOMEM; + gpg_err_set_errno (ENOMEM); _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL ); } @@ -976,7 +978,7 @@ nbytes = n * m; if (m && nbytes / m != n) { - errno = ENOMEM; + gpg_err_set_errno (ENOMEM); _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL ); } Modified: trunk/src/hmac256.c =================================================================== --- trunk/src/hmac256.c 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/src/hmac256.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -56,6 +56,15 @@ # include /* We need setmode(). */ #endif +/* For a native WindowsCE binary we need to include gpg-error.h to + provide a replacement for strerror. In other cases we need a + replacement macro for gpg_err_set_errno. */ +#ifdef __MINGW32CE__ +# include +#else +# define gpg_err_set_errno(a) (errno = (a)) +#endif + #include "hmac256.h" @@ -502,7 +511,7 @@ if (digestlen > resultsize) { _gcry_hmac256_release (hd); - errno = EINVAL; + gpg_err_set_errno (EINVAL); return -1; } memcpy (result, digest, digestlen); Modified: trunk/src/secmem.c =================================================================== --- trunk/src/secmem.c 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/src/secmem.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -319,18 +319,23 @@ /* QNX does not page at all, so the whole secure memory stuff does * not make much sense. However it is still of use because it * wipes out the memory on a free(). - * Therefore it is sufficient to suppress the warning - */ + * Therefore it is sufficient to suppress the warning. */ + (void)p; + (void)n; #elif defined (HAVE_DOSISH_SYSTEM) || defined (__CYGWIN__) /* It does not make sense to print such a warning, given the fact that - * this whole Windows !@#$% and their user base are inherently insecure - */ + * this whole Windows !@#$% and their user base are inherently insecure. */ + (void)p; + (void)n; #elif defined (__riscos__) - /* no virtual memory on RISC OS, so no pages are swapped to disc, + /* No virtual memory on RISC OS, so no pages are swapped to disc, * besides we don't have mmap, so we don't use it! ;-) - * But don't complain, as explained above. - */ + * But don't complain, as explained above. */ + (void)p; + (void)n; #else + (void)p; + (void)n; log_info ("Please note that you don't have secure memory on this system\n"); #endif } Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/tests/Makefile.am 2010-01-21 21:36:43 UTC (rev 1420) @@ -36,7 +36,7 @@ AM_CPPFLAGS = -I../src -I$(top_srcdir)/src AM_CFLAGS = $(GPG_ERROR_CFLAGS) -LDADD = ../src/libgcrypt.la $(DL_LIBS) +LDADD = ../src/libgcrypt.la $(DL_LIBS) ../compat/libcompat.la EXTRA_PROGRAMS = testapi pkbench noinst_PROGRAMS = $(TESTS) fipsdrv rsacvt Modified: trunk/tests/benchmark.c =================================================================== --- trunk/tests/benchmark.c 2010-01-21 13:33:34 UTC (rev 1419) +++ trunk/tests/benchmark.c 2010-01-21 21:36:43 UTC (rev 1420) @@ -32,6 +32,7 @@ #ifdef _GCRYPT_IN_LIBGCRYPT # include "../src/gcrypt.h" +# include "../compat/libcompat.h" #else # include #endif @@ -290,9 +291,15 @@ start_timer (void) { #ifdef _WIN32 +#ifdef __MINGW32CE__ + GetThreadTimes (GetCurrentThread (), + &started_at.creation_time, &started_at.exit_time, + &started_at.kernel_time, &started_at.user_time); +#else GetProcessTimes (GetCurrentProcess (), &started_at.creation_time, &started_at.exit_time, &started_at.kernel_time, &started_at.user_time); +#endif stopped_at = started_at; #else struct tms tmp; @@ -306,9 +313,15 @@ stop_timer (void) { #ifdef _WIN32 +#ifdef __MINGW32CE__ + GetThreadTimes (GetCurrentThread (), + &stopped_at.creation_time, &stopped_at.exit_time, + &stopped_at.kernel_time, &stopped_at.user_time); +#else GetProcessTimes (GetCurrentProcess (), &stopped_at.creation_time, &stopped_at.exit_time, &stopped_at.kernel_time, &stopped_at.user_time); +#endif #else struct tms tmp; From cvs at cvs.gnupg.org Fri Jan 22 13:09:42 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 22 Jan 2010 13:09:42 +0100 Subject: [svn] ksba - r315 - in trunk: . src tests Message-ID: Author: wk Date: 2010-01-22 13:09:42 +0100 (Fri, 22 Jan 2010) New Revision: 315 Modified: trunk/ChangeLog trunk/NEWS trunk/autogen.sh trunk/configure.ac trunk/ltmain.sh trunk/src/ChangeLog trunk/src/ber-decoder.c trunk/src/util.c trunk/tests/ChangeLog trunk/tests/cert-basic.c Log: Support WindowsCE. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/ChangeLog 2010-01-22 12:09:42 UTC (rev 315) @@ -1,3 +1,13 @@ +2010-01-22 Werner Koch + + * autogen.sh: Support --build-w32ce. + + * configure.ac: Require libgpg-error 1.8. + (HAVE_W32CE_SYSTEM): New am_defines and am_conditionals. + (AC_CHECK_FUNCS): Check for getenv. + + * ltmain.sh (wrappers_required): Don't set for mingw32ce. + 2009-12-08 Marcus Brinkmann Update to libtool 2.2.6a. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/src/ChangeLog 2010-01-22 12:09:42 UTC (rev 315) @@ -1,3 +1,10 @@ +2010-01-22 Werner Koch + + * util.c (ksba_calloc): Use gpg_er_set_errno. + + * ber-decoder.c (_ksba_ber_decoder_dump) + (_ksba_ber_decoder_decode) [!HAVE_GETENV]: Set debug to 0. + 2009-12-08 Marcus Brinkmann * src/Makefile.am (LTRCCOMPILE): Refactor with ... Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/tests/ChangeLog 2010-01-22 12:09:42 UTC (rev 315) @@ -1,3 +1,8 @@ +2010-01-22 Werner Koch + + * cert-basic.c (getenv) [__MINGW32CE__]: Add dummy. + (one_file): Use binary flag for fopen. + 2008-10-30 Werner Koch * t-cms-parser.c (dummy_hash_fnc): Mark unused args. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/NEWS 2010-01-22 12:09:42 UTC (rev 315) @@ -1,7 +1,9 @@ Noteworthy changes in version 1.0.8 (unreleased) ------------------------------------------------ + * Support for WindowsCE. + Noteworthy changes in version 1.0.7 (2009-07-03) ------------------------------------------------ Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/autogen.sh 2010-01-22 12:09:42 UTC (rev 315) @@ -35,10 +35,25 @@ shift fi +# Convenience option to use certain configure options for some hosts. +myhost="" +myhostsub="" +case "$1" in + --build-w32) + myhost="w32" + ;; + --build-w32ce) + myhost="w32" + myhostsub="ce" + ;; + *) + ;; +esac + # ***** W32 build script ******* # Used to cross-compile for Windows. -if test "$1" = "--build-w32"; then +if [ "$myhost" = "w32" ]; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift @@ -48,11 +63,20 @@ fi build=`$tsdir/config.guess` - [ -z "$w32root" ] && w32root="$HOME/w32root" + case $myhostsub in + ce) + [ -z "$w32root" ] && w32root="$HOME/w32ce_root" + toolprefixes="arm-mingw32ce" + ;; + *) + [ -z "$w32root" ] && w32root="$HOME/w32root" + toolprefixes="i586-mingw32msvc i386-mingw32msvc" + ;; + esac echo "Using $w32root as standard install directory" >&2 crossbindir= - for host in i586-mingw32msvc i386-mingw32msvc mingw32; do + for host in $toolprefixes; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -61,8 +85,10 @@ done if [ -z "$crossbindir" ]; then echo "Cross compiler kit not installed" >&2 - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + if [ -z "$sub" ]; then + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fi echo "Stop." >&2 exit 1 fi Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/configure.ac 2010-01-22 12:09:42 UTC (rev 315) @@ -46,7 +46,7 @@ KSBA_CONFIG_API_VERSION=1 -NEED_GPG_ERROR_VERSION=1.4 +NEED_GPG_ERROR_VERSION=1.8 BUILD_REVISION=svn_revision PACKAGE=$PACKAGE_NAME @@ -163,7 +163,12 @@ # Setup some stuff depending on host. have_w32_system=no +have_w32ce_system=no case "${host}" in + *-*-mingw32ce*) + have_w32_system=yes + have_w32ce_system=yes + ;; *-*-mingw32*) have_w32_system=yes ;; @@ -172,8 +177,12 @@ esac if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) + if test "$have_w32ce_system" = yes; then + AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE]) + fi fi AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) +AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes) # For some systems we know that we have ld_version scripts. @@ -308,7 +317,7 @@ # Checks for library functions. -AC_CHECK_FUNCS([memmove strchr strtol strtoul stpcpy gmtime_r]) +AC_CHECK_FUNCS([memmove strchr strtol strtoul stpcpy gmtime_r getenv]) # GNUlib checks Modified: trunk/ltmain.sh =================================================================== --- trunk/ltmain.sh 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/ltmain.sh 2010-01-22 12:09:42 UTC (rev 315) @@ -7681,15 +7681,15 @@ wrappers_required=yes case $host in + *cegcc | *mingw32ce*) + # Disable wrappers for Windows CE, we are cross compiling anyway. + wrappers_required=no + ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; - *cegcc) - # Disable wrappers for cegcc, we are cross compiling anyway. - wrappers_required=no - ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no Modified: trunk/src/ber-decoder.c =================================================================== --- trunk/src/ber-decoder.c 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/src/ber-decoder.c 2010-01-22 12:09:42 UTC (rev 315) @@ -1021,7 +1021,11 @@ if (!d) return gpg_error (GPG_ERR_INV_VALUE); +#ifdef HAVE_GETENV d->debug = !!getenv("KSBA_DEBUG_BER_DECODER"); +#else + d->debug = 0; +#endif d->use_image = 0; d->image.buf = NULL; err = decoder_init (d, NULL); @@ -1123,7 +1127,11 @@ if (r_root) *r_root = NULL; +#ifdef HAVE_GETENV d->debug = !!getenv("KSBA_DEBUG_BER_DECODER"); +#else + d->debug = 0; +#endif d->honor_module_end = 1; d->use_image = 1; d->image.buf = NULL; Modified: trunk/src/util.c =================================================================== --- trunk/src/util.c 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/src/util.c 2010-01-22 12:09:42 UTC (rev 315) @@ -128,7 +128,7 @@ nbytes = n * m; if ( m && nbytes / m != n) { - errno = ENOMEM; + gpg_err_set_errno (ENOMEM); p = NULL; } else Modified: trunk/tests/cert-basic.c =================================================================== --- trunk/tests/cert-basic.c 2009-12-08 20:21:21 UTC (rev 314) +++ trunk/tests/cert-basic.c 2010-01-22 12:09:42 UTC (rev 315) @@ -29,6 +29,10 @@ #include "oidtranstbl.h" +#ifdef __MINGW32CE__ +#define getenv(a) (NULL) +#endif + #define digitp(p) (*(p) >= '0' && *(p) <= '9') #define fail_if_err(a) do { if(a) { \ @@ -508,7 +512,7 @@ ksba_sexp_t sexp; const char *oid, *s; - fp = fopen (fname, "r"); + fp = fopen (fname, "rb"); if (!fp) { fprintf (stderr, "%s:%d: can't open `%s': %s\n", @@ -566,6 +570,8 @@ s = get_oid_desc (oid); printf (" hash algo.: %s%s%s%s\n", oid, s?" (":"",s?s:"",s?")":""); + /* Under Windows the _ksba_keyinfo_from_sexp are not exported. */ +#ifndef __WIN32 /* check that the sexp to keyinfo conversion works */ { ksba_sexp_t public; @@ -641,6 +647,7 @@ } } } +#endif if (verbose) { From cvs at cvs.gnupg.org Fri Jan 22 16:52:41 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 22 Jan 2010 16:52:41 +0100 Subject: [svn] assuan - r350 - in trunk: . src Message-ID: Author: wk Date: 2010-01-22 16:52:40 +0100 (Fri, 22 Jan 2010) New Revision: 350 Modified: trunk/ChangeLog trunk/NEWS trunk/autogen.sh trunk/configure.ac trunk/ltmain.sh trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-handler.c trunk/src/assuan-logging.c trunk/src/assuan-socket.c trunk/src/assuan-uds.c trunk/src/debug.c trunk/src/system.c Log: Prepare for a port to WindowsCE. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/ChangeLog 2010-01-22 15:52:40 UTC (rev 350) @@ -1,3 +1,15 @@ +2010-01-22 Werner Koch + + * (libtool): + + * configure.ac: Require libgpg-error 1.8. + (HAVE_W32CE_SYSTEM): New am_defines and am_conditionals. + + * ltmain.sh (wrappers_required): Don't set for mingw32ce. + + * autogen.sh: Add option --build-w32ce. Remove --disable-shared + from --build-w32. + 2010-01-08 Marcus Brinkmann Released 2.0.0. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/src/ChangeLog 2010-01-22 15:52:40 UTC (rev 350) @@ -1,3 +1,10 @@ +2010-01-22 Werner Koch + + * assuan-socket.c (read_port_and_nonce): Replace ENOFILE by a + proper ENOENT. + + Replace all assignments to ERRNO by a call to gpg_err_set_errno. + 2010-01-14 Werner Koch * debug.c (_assuan_debug, _assuan_debug_begin) Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/NEWS 2010-01-22 15:52:40 UTC (rev 350) @@ -3,7 +3,9 @@ * Under development. + * Support for WindowsCE. + Noteworthy changes in version 2.0.0 (2010-01-08) ------------------------------------------------ Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/autogen.sh 2010-01-22 15:52:40 UTC (rev 350) @@ -36,10 +36,28 @@ shift fi +# Convenience option to use certain configure options for some hosts. +myhost="" +myhostsub="" +case "$1" in + --build-w32) + myhost="w32" + ;; + --build-w32ce) + myhost="w32" + myhostsub="ce" + ;; + --build-amd64) + myhost="amd64" + ;; + *) + ;; +esac + # ***** W32 build script ******* # Used to cross-compile for Windows. -if test "$1" = "--build-w32"; then +if [ "$myhost" = "w32" ]; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift @@ -49,11 +67,20 @@ fi build=`$tsdir/config.guess` - [ -z "$w32root" ] && w32root="$HOME/w32root" + case $myhostsub in + ce) + [ -z "$w32root" ] && w32root="$HOME/w32ce_root" + toolprefixes="arm-mingw32ce" + ;; + *) + [ -z "$w32root" ] && w32root="$HOME/w32root" + toolprefixes="i586-mingw32msvc i386-mingw32msvc" + ;; + esac echo "Using $w32root as standard install directory" >&2 crossbindir= - for host in i586-mingw32msvc i386-mingw32msvc mingw32; do + for host in $toolprefixes; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -62,8 +89,10 @@ done if [ -z "$crossbindir" ]; then echo "Cross compiler kit not installed" >&2 - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + if [ -z "$sub" ]; then + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fi echo "Stop." >&2 exit 1 fi @@ -77,7 +106,7 @@ ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=${host} --build=${build} \ - --disable-shared + --with-gpg-error-prefix=${w32root} "$@" exit $? fi @@ -86,7 +115,7 @@ # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) -if test "$1" = "--build-amd64"; then +if [ "$myhost" = "amd64" ]; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/configure.ac 2010-01-22 15:52:40 UTC (rev 350) @@ -138,12 +138,18 @@ # have_dosish_system=no have_w32_system=no +have_w32ce_system=no case "${host}" in *-linux*) if test "$GCC" = yes; then CFLAGS="$CFLAGS -fPIC -DPIC" fi ;; + *-mingw32de*) + have_dosish_system=yes + have_w32_system=yes + have_w32ce_system=yes + ;; *-mingw32*) have_dosish_system=yes have_w32_system=yes @@ -165,6 +171,9 @@ if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1,[Defined if we run on a W32 API based system]) + if test "$have_w32ce_system" = yes; then + AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE]) + fi BUILD_TIMESTAMP=`date --iso-8601=minutes` AC_SUBST(BUILD_TIMESTAMP) changequote(,)dnl @@ -181,6 +190,7 @@ AC_SUBST(BUILD_TIMESTAMP) AC_SUBST(BUILD_FILEVERSION) AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) +AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes) # Check for network libraries. They are needed for tests. @@ -247,7 +257,7 @@ # Checking for libgpg-error. -AM_PATH_GPG_ERROR(1.4,, AC_MSG_ERROR([libgpg-error was not found])) +AM_PATH_GPG_ERROR(1.8,, AC_MSG_ERROR([libgpg-error was not found])) # # Checks for library functions. Modified: trunk/ltmain.sh =================================================================== --- trunk/ltmain.sh 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/ltmain.sh 2010-01-22 15:52:40 UTC (rev 350) @@ -7680,15 +7680,15 @@ wrappers_required=yes case $host in + *cegcc | *mingw32ce*) + # Disable wrappers for cegcc/mingw32ce, we are cross compiling anyway. + wrappers_required=no + ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; - *cegcc) - # Disable wrappers for cegcc, we are cross compiling anyway. - wrappers_required=no - ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/src/assuan-buffer.c 2010-01-22 15:52:40 UTC (rev 350) @@ -155,7 +155,7 @@ ctx->inbound.attic.linelen = atticlen + nread; } - errno = saved_errno; + gpg_err_set_errno (saved_errno); return _assuan_error (ctx, gpg_err_code_from_syserror ()); } if (!nread) Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/src/assuan-handler.c 2010-01-22 15:52:40 UTC (rev 350) @@ -864,7 +864,7 @@ ctx->outbound.data.error = 0; return ctx->outbound.data.fp; #else - errno = ENOSYS; + gpg_err_set_errno (ENOSYS); return NULL; #endif } Modified: trunk/src/assuan-logging.c =================================================================== --- trunk/src/assuan-logging.c 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/src/assuan-logging.c 2010-01-22 15:52:40 UTC (rev 350) @@ -137,7 +137,7 @@ with a LF. */ if (msg && *msg && msg[strlen (msg) - 1] == '\n') fflush (fp); - errno = saved_errno; + gpg_err_set_errno (saved_errno); return 0; } Modified: trunk/src/assuan-socket.c =================================================================== --- trunk/src/assuan-socket.c 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/src/assuan-socket.c 2010-01-22 15:52:40 UTC (rev 350) @@ -89,11 +89,11 @@ if (!CryptAcquireContext (&prov, NULL, NULL, PROV_RSA_FULL, (CRYPT_VERIFYCONTEXT|CRYPT_SILENT)) ) - errno = ENODEV; + gpg_err_set_errno (ENODEV); else { if (!CryptGenRandom (prov, nbytes, (unsigned char *) buffer)) - errno = ENODEV; + gpg_err_set_errno (ENODEV); else ret = 0; CryptReleaseContext (prov, 0); @@ -119,14 +119,14 @@ fclose (fp); if (!nread) { - errno = ENOFILE; + gpg_err_set_errno (ENOENT); return -1; } buffer[nread] = 0; aval = atoi (buffer); if (aval < 1 || aval > 65535) { - errno = EINVAL; + gpg_err_set_errno (EINVAL); return -1; } *port = (unsigned int)aval; @@ -134,7 +134,7 @@ ; if (*p != '\n' || nread != 17) { - errno = EINVAL; + gpg_err_set_errno (EINVAL); return -1; } p++; nread--; @@ -156,7 +156,7 @@ domain = AF_INET; res = SOCKET2HANDLE(socket (domain, type, proto)); if (res == ASSUAN_INVALID_FD) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); + gpg_err_set_errno (_assuan_sock_wsa2errno (WSAGetLastError ())); return res; #else return socket (domain, type, proto); @@ -198,7 +198,7 @@ ret = _assuan_write (ctx, sockfd, nonce, 16); if (ret >= 0 && ret != 16) { - errno = EIO; + gpg_err_set_errno (EIO); ret = -1; } } @@ -209,7 +209,7 @@ int res; res = connect (HANDLE2SOCKET (sockfd), addr, addrlen); if (res < 0) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); + gpg_err_set_errno (_assuan_sock_wsa2errno (WSAGetLastError ())); return res; } #else @@ -248,7 +248,7 @@ if (filefd == -1) { if (errno == EEXIST) - errno = WSAEADDRINUSE; + gpg_err_set_errno (WSAEADDRINUSE); return -1; } fp = fdopen (filefd, "wb"); @@ -256,7 +256,7 @@ { int save_e = errno; close (filefd); - errno = save_e; + gpg_err_set_errno (save_e); return -1; } @@ -269,7 +269,7 @@ int save_e = errno; fclose (fp); remove (unaddr->sun_path); - errno = save_e; + gpg_err_set_errno (save_e); return rc; } fprintf (fp, "%d\n", ntohs (myaddr.sin_port)); @@ -282,7 +282,7 @@ { int res = bind (HANDLE2SOCKET(sockfd), addr, addrlen); if (res < 0) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); + gpg_err_set_errno ( _assuan_sock_wsa2errno (WSAGetLastError ())); return res; } #else @@ -303,7 +303,7 @@ if (sizeof nonce->nonce != 16) { - errno = EINVAL; + gpg_err_set_errno (EINVAL); return -1; } nonce->length = 16; @@ -336,7 +336,7 @@ if (sizeof nonce->nonce != 16) { - errno = EINVAL; + gpg_err_set_errno (EINVAL); return -1; } @@ -345,7 +345,7 @@ if (nonce->length != 16) { - errno = EINVAL; + gpg_err_set_errno (EINVAL); return -1; } @@ -362,7 +362,7 @@ return -1; else if (!n) { - errno = EIO; + gpg_err_set_errno (EIO); return -1; } else @@ -373,7 +373,7 @@ } if (memcmp (buffer, nonce->nonce, 16)) { - errno = EACCES; + gpg_err_set_errno (EACCES); return -1; } #else Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/src/assuan-uds.c 2010-01-22 15:52:40 UTC (rev 350) @@ -136,7 +136,7 @@ #else /*HAVE_W32_SYSTEM*/ int res = recvfrom (HANDLE2SOCKET(ctx->inbound.fd), buf, buflen, 0, NULL, NULL); if (res < 0) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); + gpg_err_set_errno (_assuan_sock_wsa2errno (WSAGetLastError ())); return res; #endif /*HAVE_W32_SYSTEM*/ } @@ -168,7 +168,7 @@ (struct sockaddr *)&ctx->serveraddr, sizeof (struct sockaddr_in)); if (res < 0) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); + gpg_err_set_errno ( _assuan_sock_wsa2errno (WSAGetLastError ())); return res; #endif /*HAVE_W32_SYSTEM*/ } Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/src/debug.c 2010-01-22 15:52:40 UTC (rev 350) @@ -60,7 +60,7 @@ return; ctx->log_cb (ctx, ctx->log_cb_data, cat, msg); free (msg); - errno = saved_errno; + gpg_err_set_errno (saved_errno); } Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2010-01-14 21:16:55 UTC (rev 349) +++ trunk/src/system.c 2010-01-22 15:52:40 UTC (rev 350) @@ -57,7 +57,7 @@ GetCurrentProcess(), &ofd, 0, TRUE, DUPLICATE_SAME_ACCESS)) { - errno = EIO; + gpg_err_set_errno (EIO); return ASSUAN_INVALID_FD; } return ofd; @@ -92,7 +92,7 @@ /* Check for overflow. */ if (elsize && nbytes / elsize != cnt) { - errno = ENOMEM; + gpg_err_set_errno (ENOMEM); return NULL; } @@ -203,7 +203,7 @@ { TRACE1 (ctx, ASSUAN_LOG_SYSIO, "__assuan_pipe", ctx, "CreatePipe failed: %s", _assuan_w32_strerror (ctx, -1)); - errno = EIO; + gpg_err_set_errno (EIO); return -1; } @@ -215,7 +215,7 @@ "DuplicateHandle failed: %s", _assuan_w32_strerror (ctx, -1)); CloseHandle (rh); CloseHandle (wh); - errno = EIO; + gpg_err_set_errno (EIO); return -1; } if (inherit_idx == 0) @@ -264,13 +264,13 @@ #ifdef HAVE_W32_SYSTEM int rc = closesocket (HANDLE2SOCKET(fd)); if (rc) - errno = _assuan_sock_wsa2errno (WSAGetLastError ()); + gpg_err_set_errno ( _assuan_sock_wsa2errno (WSAGetLastError ()) ); if (rc && WSAGetLastError () == WSAENOTSOCK) { rc = CloseHandle (fd); if (rc) /* FIXME. */ - errno = EIO; + gpg_err_set_errno (EIO); } return rc; #else @@ -315,11 +315,11 @@ switch (GetLastError ()) { case ERROR_BROKEN_PIPE: - errno = EPIPE; + gpg_err_set_errno (EPIPE); break; default: - errno = EIO; + gpg_err_set_errno (EIO); } res = -1; } @@ -329,15 +329,15 @@ break; case WSAEWOULDBLOCK: - errno = EAGAIN; + gpg_err_set_errno (EAGAIN); break; case ERROR_BROKEN_PIPE: - errno = EPIPE; + gpg_err_set_errno (EPIPE); break; default: - errno = EIO; + gpg_err_set_errno (EIO); break; } } @@ -385,11 +385,11 @@ { case ERROR_BROKEN_PIPE: case ERROR_NO_DATA: - errno = EPIPE; + gpg_err_set_errno (EPIPE); break; default: - errno = EIO; + gpg_err_set_errno (EIO); break; } res = -1; @@ -425,7 +425,7 @@ int flags) { #ifdef HAVE_W32_SYSTEM - errno = ENOSYS; + gpg_err_set_errno (ENOSYS); return -1; #else int ret; @@ -477,7 +477,7 @@ int flags) { #ifdef HAVE_W32_SYSTEM - errno = ENOSYS; + gpg_err_set_errno (ENOSYS); return -1; #else int ret; @@ -640,7 +640,7 @@ TRACE1 (ctx, ASSUAN_LOG_SYSIO, "__assuan_spawn", ctx, "can't open `nul': %s", _assuan_w32_strerror (ctx, -1)); _assuan_free (ctx, cmdline); - errno = EIO; + gpg_err_set_errno (EIO); return -1; } si.hStdError = nullfd; @@ -675,7 +675,7 @@ if (nullfd != INVALID_HANDLE_VALUE) CloseHandle (nullfd); - errno = EIO; + gpg_err_set_errno (EIO); return -1; } @@ -818,7 +818,7 @@ if (!(fdp && *fdp != -1)) close (i); } - errno = 0; + gpg_err_set_errno (0); if (! name) { @@ -948,7 +948,7 @@ int protocol, assuan_fd_t filedes[2]) { #if HAVE_W32_SYSTEM - errno = ENOSYS; + gpg_err_set_errno (ENOSYS); return -1; #else return socketpair (namespace, style, protocol, filedes); From cvs at cvs.gnupg.org Fri Jan 22 19:55:16 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 22 Jan 2010 19:55:16 +0100 Subject: [svn] assuan - r351 - in trunk: . doc src Message-ID: Author: wk Date: 2010-01-22 19:55:16 +0100 (Fri, 22 Jan 2010) New Revision: 351 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-pipe-connect.c trunk/src/setenv.c trunk/src/system.c Log: Changes to build for W32CE - does not yet work, though. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-22 15:52:40 UTC (rev 350) +++ trunk/ChangeLog 2010-01-22 18:55:16 UTC (rev 351) @@ -1,12 +1,8 @@ 2010-01-22 Werner Koch - * (libtool): - * configure.ac: Require libgpg-error 1.8. (HAVE_W32CE_SYSTEM): New am_defines and am_conditionals. - * ltmain.sh (wrappers_required): Don't set for mingw32ce. - * autogen.sh: Add option --build-w32ce. Remove --disable-shared from --build-w32. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-22 15:52:40 UTC (rev 350) +++ trunk/src/ChangeLog 2010-01-22 18:55:16 UTC (rev 351) @@ -1,5 +1,12 @@ 2010-01-22 Werner Koch + * setenv.c [W32CE]: Make it a dummy. + + * assuan-pipe-connect.c: Remove signal.h. + + * system.c (__assuan_spawn): Use CreateFileW. + (DETACHED_PROCESS) [W32CE]: Define to 0. + * assuan-socket.c (read_port_and_nonce): Replace ENOFILE by a proper ENOENT. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-01-22 15:52:40 UTC (rev 350) +++ trunk/NEWS 2010-01-22 18:55:16 UTC (rev 351) @@ -1,7 +1,7 @@ Noteworthy changes in version 2.0.1 (unreleased) ------------------------------------------------ - * Under development. + Under development: * Support for WindowsCE. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-22 15:52:40 UTC (rev 350) +++ trunk/configure.ac 2010-01-22 18:55:16 UTC (rev 351) @@ -145,7 +145,7 @@ CFLAGS="$CFLAGS -fPIC -DPIC" fi ;; - *-mingw32de*) + *-mingw32ce*) have_dosish_system=yes have_w32_system=yes have_w32ce_system=yes @@ -295,7 +295,6 @@ AC_REPLACE_FUNCS(putc_unlocked) AC_REPLACE_FUNCS(memrchr) AC_REPLACE_FUNCS(stpcpy) -# Check for unistd.h for setenv replacement function. AC_CHECK_HEADERS(unistd.h) AC_REPLACE_FUNCS(setenv) AC_REPLACE_FUNCS(vasprintf) Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2010-01-22 15:52:40 UTC (rev 350) +++ trunk/doc/assuan.texi 2010-01-22 18:55:16 UTC (rev 351) @@ -921,7 +921,7 @@ If set and there is a need to start the server it will be started as a background process. This flag is useful under W32 systems, so that no new console is created and pops up a console window when starting the -server. +server. On W32CE systems this flag is ignored. @end table @item pid_t (*waitpid) (assuan_context_t ctx, pid_t pid, int action, int *status, int options) @@ -1087,7 +1087,7 @@ If set and there is a need to start the server it will be started as a background process. This flag is useful under W32 systems, so that no new console is created and pops up a console window when starting the -server. +server. On W32CE systems this flag is ignored. @end table @end deftypefun Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2010-01-22 15:52:40 UTC (rev 350) +++ trunk/src/assuan-pipe-connect.c 2010-01-22 18:55:16 UTC (rev 351) @@ -24,7 +24,11 @@ #include #include #include -#include +/* On Windows systems signal.h is not needed and even not supported on + WindowsCE. */ +#ifndef HAVE_DOSISH_SYSTEM +# include +#endif #include #include #include Modified: trunk/src/setenv.c =================================================================== --- trunk/src/setenv.c 2010-01-22 15:52:40 UTC (rev 350) +++ trunk/src/setenv.c 2010-01-22 18:55:16 UTC (rev 351) @@ -20,6 +20,8 @@ # include #endif +#ifndef HAVE_W32CE_SYSTEM + #define setenv _assuan_setenv #define unsetenv _assuan_unsetenv #define clearenv _assuan_clearenv @@ -352,4 +354,4 @@ weak_alias (__clearenv, clearenv) #endif - +#endif /*!HAVE_W32CE_SYSTEM*/ Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2010-01-22 15:52:40 UTC (rev 350) +++ trunk/src/system.c 2010-01-22 18:55:16 UTC (rev 351) @@ -632,7 +632,7 @@ } if (!fdp || *fdp == ASSUAN_INVALID_FD) { - nullfd = CreateFile ("nul", GENERIC_WRITE, + nullfd = CreateFileW (L"nul", GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (nullfd == INVALID_HANDLE_VALUE) @@ -648,7 +648,9 @@ else si.hStdError = fd; - +#ifdef HAVE_W32CE_SYSTEM +# define DETACHED_PROCESS (0) +#endif /* Note: We inherit all handles flagged as inheritable. This seems to be a security flaw but there seems to be no way of selecting handles to inherit. */ From cvs at cvs.gnupg.org Mon Jan 25 17:04:28 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 25 Jan 2010 17:04:28 +0100 Subject: [svn] gpgme - r1451 - in trunk: . doc src Message-ID: Author: wk Date: 2010-01-25 17:04:27 +0100 (Mon, 25 Jan 2010) New Revision: 1451 Modified: trunk/ChangeLog trunk/autogen.sh trunk/doc/gpgme.texi trunk/src/ChangeLog trunk/src/version.c trunk/src/w32-io.c Log: Allow the native W32 version to properly work with sockets. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-11 13:47:42 UTC (rev 1450) +++ trunk/ChangeLog 2010-01-25 16:04:27 UTC (rev 1451) @@ -1,3 +1,7 @@ +2010-01-22 Werner Koch + + * autogen.sh (--build-w32): Add --with-libassuan-prefix. + 2010-01-11 Marcus Brinkmann Release 1.3.0. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-11 13:47:42 UTC (rev 1450) +++ trunk/src/ChangeLog 2010-01-25 16:04:27 UTC (rev 1451) @@ -1,3 +1,15 @@ +2010-01-25 Werner Koch + + * w32-io.c (_gpgme_io_connect): Fix return code check to make it work. + + * version.c (do_subsystem_inits): Remove superfluous second + WSAStartup. + +2010-01-22 Werner Koch + + * w32-io.c (writer): Try to use send first. + (reader): Try to use recv first. + 2010-01-08 Werner Koch * engine-gpg.c (gpg_passwd): New. @@ -727,7 +739,7 @@ * opassuan.c, dirinfo.c, engine-assuan.c: New. * Makefile.am: Add them. - * engine-backend.h: Add _gpgme_engine_ops_assuan. + * engine-backend.h: Add _gpgme_engine_ops_assuan. (struct engine_ops): Add field OPASSUAN_TRANSACT. Update all engine intializers. * Makefile.am (gpgsm_components): Add engine-assuan.c. Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-01-11 13:47:42 UTC (rev 1450) +++ trunk/autogen.sh 2010-01-25 16:04:27 UTC (rev 1451) @@ -81,6 +81,7 @@ ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=i586-mingw32msvc --build=${build} \ --with-gpg-error-prefix=${w32root} \ + --with-libassuan-prefix=${w32root} \ --enable-shared --enable-static --enable-w32-glib \ PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig" @@ -162,3 +163,4 @@ echo "You may now run: ./configure --enable-maintainer-mode && make " + Modified: trunk/doc/gpgme.texi =================================================================== --- trunk/doc/gpgme.texi 2010-01-11 13:47:42 UTC (rev 1450) +++ trunk/doc/gpgme.texi 2010-01-25 16:04:27 UTC (rev 1451) @@ -3746,7 +3746,7 @@ anyway). Note that old @code{gpg} engines (before version 2.0.15) do not support -this comamnd and will silently ignore it. +this command and will silently ignore it. @end deftypefun @deftypefun gpgme_error_t gpgme_op_passwd_start @ Modified: trunk/src/version.c =================================================================== --- trunk/src/version.c 2010-01-11 13:47:42 UTC (rev 1450) +++ trunk/src/version.c 2010-01-25 16:04:27 UTC (rev 1451) @@ -65,25 +65,18 @@ return; #ifdef HAVE_W32_SYSTEM - { - WSADATA wsadat; - - WSAStartup (0x202, &wsadat); - } -#endif - - _gpgme_sema_subsystem_init (); - _gpgme_debug_subsystem_init (); - _gpgme_io_subsystem_init (); -#if defined(HAVE_W32_SYSTEM) && defined(HAVE_ASSUAN_H) /* We need to make sure that the sockets are initialized. */ { WSADATA wsadat; WSAStartup (0x202, &wsadat); } -#endif /*HAVE_W32_SYSTEM && HAVE_ASSUAN_H*/ +#endif + _gpgme_sema_subsystem_init (); + _gpgme_debug_subsystem_init (); + _gpgme_io_subsystem_init (); + done = 1; } Modified: trunk/src/w32-io.c =================================================================== --- trunk/src/w32-io.c 2010-01-11 13:47:42 UTC (rev 1450) +++ trunk/src/w32-io.c 2010-01-25 16:04:27 UTC (rev 1451) @@ -49,6 +49,7 @@ #define handle_to_fd(a) ((int)(a)) #define pid_to_handle(a) ((HANDLE)(a)) #define handle_to_pid(a) ((int)(a)) +#define handle_to_socket(a) ((unsigned int)(a)) #define READBUF_SIZE 4096 #define WRITEBUF_SIZE 4096 @@ -180,6 +181,7 @@ struct reader_context_s *ctx = arg; int nbytes; DWORD nread; + int try_recv = 1; TRACE_BEG1 (DEBUG_SYSIO, "gpgme:reader", ctx->file_hd, "thread=%p", ctx->thread_hd); @@ -211,21 +213,52 @@ UNLOCK (ctx->mutex); TRACE_LOG1 ("reading %d bytes", nbytes); - if (!ReadFile (ctx->file_hd, - ctx->buffer + ctx->writepos, nbytes, &nread, NULL)) - { - ctx->error_code = (int) GetLastError (); - if (ctx->error_code == ERROR_BROKEN_PIPE) - { - ctx->eof = 1; - TRACE_LOG ("got EOF (broken pipe)"); + + if (try_recv) + { + int n; + + n = recv (handle_to_socket (ctx->file_hd), + ctx->buffer + ctx->writepos, nbytes, 0); + if (n < 0 && WSAGetLastError () == WSAENOTSOCK) + try_recv = 0; + else if (n < 0) + { + ctx->error_code = (int) WSAGetLastError (); + if (ctx->error_code == ERROR_BROKEN_PIPE) + { + ctx->eof = 1; + TRACE_LOG ("got EOF (broken connection)"); + } + else + { + ctx->error = 1; + TRACE_LOG1 ("recv error: ec=%d", ctx->error_code); + } + break; } - else - { - ctx->error = 1; - TRACE_LOG1 ("read error: ec=%d", ctx->error_code); + else + nread = n; + + } + if (!try_recv) + { + if (!ReadFile (ctx->file_hd, + ctx->buffer + ctx->writepos, nbytes, &nread, NULL)) + { + ctx->error_code = (int) GetLastError (); + if (ctx->error_code == ERROR_BROKEN_PIPE) + { + ctx->eof = 1; + TRACE_LOG ("got EOF (broken pipe)"); + } + else + { + ctx->error = 1; + TRACE_LOG1 ("read error: ec=%d", ctx->error_code); + } + break; } - break; } if (!nread) { @@ -507,6 +540,7 @@ { struct writer_context_s *ctx = arg; DWORD nwritten; + int try_send = 1; TRACE_BEG1 (DEBUG_SYSIO, "gpgme:writer", ctx->file_hd, "thread=%p", ctx->thread_hd); @@ -541,14 +575,37 @@ /* Note that CTX->nbytes is not zero at this point, because _gpgme_io_write always writes at least 1 byte before waking us up, unless CTX->stop_me is true, which we catch above. */ - if (!WriteFile (ctx->file_hd, ctx->buffer, - ctx->nbytes, &nwritten, NULL)) - { - ctx->error_code = (int) GetLastError (); - ctx->error = 1; - TRACE_LOG1 ("write error: ec=%d", ctx->error_code); - break; - } + if (try_send) + { + /* We need to try send first because a socket handle can't + be used with WriteFile. */ + int n; + + n = send (handle_to_socket (ctx->file_hd), + ctx->buffer, ctx->nbytes, 0); + if (n < 0 && WSAGetLastError () == WSAENOTSOCK) + try_send = 0; + else if (n < 0) + { + ctx->error_code = (int) WSAGetLastError (); + ctx->error = 1; + TRACE_LOG1 ("send error: ec=%d", ctx->error_code); + break; + } + else + nwritten = n; + } + if (!try_send) + { + if (!WriteFile (ctx->file_hd, ctx->buffer, + ctx->nbytes, &nwritten, NULL)) + { + ctx->error_code = (int) GetLastError (); + ctx->error = 1; + TRACE_LOG1 ("write error: ec=%d", ctx->error_code); + break; + } + } TRACE_LOG1 ("wrote %d bytes", (int) nwritten); LOCK (ctx->mutex); @@ -1563,7 +1620,7 @@ "addr=%p, addrlen=%i", addr, addrlen); res = connect (fd, addr, addrlen); - if (!res) + if (res) { errno = wsa2errno (WSAGetLastError ()); return TRACE_SYSRES (-1); From cvs at cvs.gnupg.org Tue Jan 26 17:15:13 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 26 Jan 2010 17:15:13 +0100 Subject: [svn] GnuPG - r5251 - trunk/agent Message-ID: Author: wk Date: 2010-01-26 17:15:12 +0100 (Tue, 26 Jan 2010) New Revision: 5251 Modified: trunk/agent/ChangeLog trunk/agent/protect.c Log: Fixed a regression introduced with 2.0.14. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-01-11 16:05:26 UTC (rev 5250) +++ trunk/agent/ChangeLog 2010-01-26 16:15:12 UTC (rev 5251) @@ -1,3 +1,8 @@ +2010-01-26 Werner Koch + + * protect.c (do_encryption): Encode the s2kcount and no not use a + static value of 96. + 2009-12-21 Werner Koch * command.c (cmd_getinfo): Add sub-command s2k_count. Modified: trunk/agent/protect.c =================================================================== --- trunk/agent/protect.c 2010-01-11 16:05:26 UTC (rev 5250) +++ trunk/agent/protect.c 2010-01-26 16:15:12 UTC (rev 5251) @@ -360,19 +360,25 @@ in canoncical format of course. We use asprintf and %n modifier and dummy values as placeholders. */ - p = xtryasprintf - ("(9:protected%d:%s((4:sha18:%n_8bytes_2:96)%d:%n%*s)%d:%n%*s)", - (int)strlen (modestr), modestr, - &saltpos, - blklen, &ivpos, blklen, "", - enclen, &encpos, enclen, ""); - if (!p) - { - gpg_error_t tmperr = out_of_core (); - xfree (iv); - xfree (outbuf); - return tmperr; - } + { + char countbuf[35]; + + snprintf (countbuf, sizeof countbuf, "%lu", get_standard_s2k_count ()); + p = xtryasprintf + ("(9:protected%d:%s((4:sha18:%n_8bytes_%u:%s)%d:%n%*s)%d:%n%*s)", + (int)strlen (modestr), modestr, + &saltpos, + (unsigned int)strlen (countbuf), countbuf, + blklen, &ivpos, blklen, "", + enclen, &encpos, enclen, ""); + if (!p) + { + gpg_error_t tmperr = out_of_core (); + xfree (iv); + xfree (outbuf); + return tmperr; + } + } *resultlen = strlen (p); *result = (unsigned char*)p; memcpy (p+saltpos, iv+2*blklen, 8); From cvs at cvs.gnupg.org Tue Jan 26 17:33:59 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 26 Jan 2010 17:33:59 +0100 Subject: [svn] GnuPG - r5252 - in branches/STABLE-BRANCH-2-0: . agent Message-ID: Author: wk Date: 2010-01-26 17:33:58 +0100 (Tue, 26 Jan 2010) New Revision: 5252 Modified: branches/STABLE-BRANCH-2-0/NEWS branches/STABLE-BRANCH-2-0/agent/ChangeLog branches/STABLE-BRANCH-2-0/agent/protect.c Log: Fixed a regression in 2.0.14 Modified: branches/STABLE-BRANCH-2-0/agent/ChangeLog =================================================================== --- branches/STABLE-BRANCH-2-0/agent/ChangeLog 2010-01-26 16:15:12 UTC (rev 5251) +++ branches/STABLE-BRANCH-2-0/agent/ChangeLog 2010-01-26 16:33:58 UTC (rev 5252) @@ -1,3 +1,8 @@ +2010-01-26 Werner Koch + + * protect.c (do_encryption): Encode the s2kcount and do not use a + static value of 96. + 2009-12-21 Werner Koch * command.c (cmd_getinfo): Add sub-command "s2k_count". Modified: branches/STABLE-BRANCH-2-0/NEWS =================================================================== --- branches/STABLE-BRANCH-2-0/NEWS 2010-01-26 16:15:12 UTC (rev 5251) +++ branches/STABLE-BRANCH-2-0/NEWS 2010-01-26 16:33:58 UTC (rev 5252) @@ -3,7 +3,10 @@ * New command --passwd for GPG. + * Fixes a regression in 2.0.14 which prevented unprotection of new + or changed gpg-agent passphrases. + Noteworthy changes in version 2.0.14 (2009-12-21) ------------------------------------------------- Modified: branches/STABLE-BRANCH-2-0/agent/protect.c =================================================================== --- branches/STABLE-BRANCH-2-0/agent/protect.c 2010-01-26 16:15:12 UTC (rev 5251) +++ branches/STABLE-BRANCH-2-0/agent/protect.c 2010-01-26 16:33:58 UTC (rev 5252) @@ -360,19 +360,25 @@ in canoncical format of course. We use asprintf and %n modifier and dummy values as placeholders. */ - p = xtryasprintf - ("(9:protected%d:%s((4:sha18:%n_8bytes_2:96)%d:%n%*s)%d:%n%*s)", - (int)strlen (modestr), modestr, - &saltpos, - blklen, &ivpos, blklen, "", - enclen, &encpos, enclen, ""); - if (!p) - { - gpg_error_t tmperr = out_of_core (); - xfree (iv); - xfree (outbuf); - return tmperr; - } + { + char countbuf[35]; + + snprintf (countbuf, sizeof countbuf, "%lu", get_standard_s2k_count ()); + p = xtryasprintf + ("(9:protected%d:%s((4:sha18:%n_8bytes_%u:%s)%d:%n%*s)%d:%n%*s)", + (int)strlen (modestr), modestr, + &saltpos, + (unsigned int)strlen (countbuf), countbuf, + blklen, &ivpos, blklen, "", + enclen, &encpos, enclen, ""); + if (!p) + { + gpg_error_t tmperr = out_of_core (); + xfree (iv); + xfree (outbuf); + return tmperr; + } + } *resultlen = strlen (p); *result = (unsigned char*)p; memcpy (p+saltpos, iv+2*blklen, 8); From cvs at cvs.gnupg.org Tue Jan 26 17:35:38 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 26 Jan 2010 17:35:38 +0100 Subject: [svn] gpg-error - r229 - trunk/src Message-ID: Author: wk Date: 2010-01-26 17:35:37 +0100 (Tue, 26 Jan 2010) New Revision: 229 Added: trunk/src/mkw32errmap.c Log: Add missing file. From cvs at cvs.gnupg.org Thu Jan 28 16:31:26 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 28 Jan 2010 16:31:26 +0100 Subject: [svn] assuan - r352 - in trunk: . doc src tests Message-ID: Author: wk Date: 2010-01-28 16:31:25 +0100 (Thu, 28 Jan 2010) New Revision: 352 Added: trunk/src/sysutils.c Modified: trunk/ChangeLog trunk/configure.ac trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan-logging.c trunk/src/assuan-socket-server.c trunk/src/assuan-socket.c trunk/src/assuan.h trunk/src/system.c trunk/tests/Makefile.am trunk/tests/common.h Log: Cleanups for W32CE. Implement getenv replacement for W32CE. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/ChangeLog 2010-01-28 15:31:25 UTC (rev 352) @@ -1,3 +1,11 @@ +2010-01-27 Werner Koch + + * tests/common.h (SOCKET2HANDLE, HANDLE2SOCKET): New. + +2010-01-26 Werner Koch + + * configure.ac (NETLIBS) [W32CE]: Use -lws2. + 2010-01-22 Werner Koch * configure.ac: Require libgpg-error 1.8. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/ChangeLog 2010-01-28 15:31:25 UTC (rev 352) @@ -1,3 +1,24 @@ +2010-01-28 Werner Koch + + * assuan.h: Remove ranges in list of copyright years. + (getenv) [W32CE]: Provide macro. + * sysutils.c: New. + (_assuan_sysutils_blurb): New. + (_assuan_getenv): new. + * assuan-logging.c: Call _assuan_sysutils_blurb. + +2010-01-27 Werner Koch + + * assuan-socket.c (_assuan_sock_bind): Replace remove by DeleteFile. + + * assuan-handler.c (assuan_get_active_fds) [W32CE]: Remove use of + _get_osfhandle. + * assuan.h (assuan_fd_from_posix_fd) [__MINGW32CE__]: Ditto. + * system.c (assuan_fdopen): Ditto. + (__assuan_spawn) [W32CE]: Do not use GetPriorityClass. + + * assuan-defs.h (getpid) [W32CE]: New. + 2010-01-22 Werner Koch * setenv.c [W32CE]: Make it a dummy. @@ -691,7 +712,7 @@ 2007-10-04 Werner Koch * mkerrors: Map EAGAIN to GPG_ERR_EAGAIN for read and write - errors. + errors. 2007-10-02 Werner Koch @@ -707,7 +728,7 @@ * assuan.h (ASSUAN_INT2FD, ASSUAN_FD2INT): New. * assuan-socket.c: Rewritten. - (assuan_sock_new, assuan_sock_connect, assuan_sock_bind) + (assuan_sock_new, assuan_sock_connect, assuan_sock_bind) (assuan_sock_get_nonce, assuan_sock_check_nonce): New APIs. * assuan-io.c (_assuan_simple_read, _assuan_simple_write): Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/configure.ac 2010-01-28 15:31:25 UTC (rev 352) @@ -199,7 +199,12 @@ AC_SUBST(NETLIBS) if test "$have_w32_system" = yes; then - NETLIBS="-lws2_32 $NETLIBS" + if test "$have_w32ce_system" = yes; then + NETLIBS="-lws2 $NETLIBS" + else + # FIXME: Check why we need to use ws2_32 and document that. + NETLIBS="-lws2_32 $NETLIBS" + fi fi Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/doc/assuan.texi 2010-01-28 15:31:25 UTC (rev 352) @@ -1889,7 +1889,7 @@ of the socket wrapper functions are used. @end deftypefun - at deftypefun gpg_error_t assuan_sock_init (void) + at deftypefun gpg_error_t assuan_sock_deinit (void) Deinitialize the socket wrappers. @end deftypefun @@ -1933,11 +1933,18 @@ @w{assuan_fd_t @var{fd}}, @ @w{assuan_sock_nonce_t *@var{nonce}}) -On Windows this is used by the server after an accept to read the nonce -from the client and compare it with the saved @var{nonce}. If this -function fails the server should immediatly drop the connection. To -keep the code readable this may also be used on POSIX system; it is a -dummy function then. See also @code{assuan_set_sock_nonce}. +If the option @code{ASSUAN_SOCKET_SERVER_ACCEPTED} has been used, +Libassuan has no way to check the nonce of the server. Thus an explicit +check of the saved nonce using this function is required. If this +function fails the server should immediately drop the connection. This +function may not be used if Libassuan does the accept call itself +(i.e. @code{ASSUAN_SOCKET_SERVER_ACCEPTED} has not been used) because +in this case Libassuan calls this function internally. See also + at code{assuan_set_sock_nonce}. + +Actually this mechanism is only required on Windows but for cleanness of +code it may be used on POSIX systems as well, where this function is +a nop. @end deftypefun Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/Makefile.am 2010-01-28 15:31:25 UTC (rev 352) @@ -37,7 +37,7 @@ common_sources = \ assuan-defs.h \ assuan.c context.c system.c \ - debug.c debug.h conversion.c \ + debug.c debug.h conversion.c sysutils.c \ client.c server.c \ assuan-error.c \ assuan-buffer.c \ Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/assuan-defs.h 2010-01-28 15:31:25 UTC (rev 352) @@ -335,6 +335,16 @@ #define funopen(a,r,w,s,c) _assuan_funopen ((a), (r), (w), (s), (c)) #endif /*HAVE_FOPENCOOKIE*/ +/*-- sysutils.c --*/ +const char *_assuan_sysutils_blurb (void); + +#ifdef HAVE_W32CE_SYSTEM +#define getpid() GetCurrentProcessId () +char *_assuan_getenv (const char *name); +#define getenv(a) _assuan_getenv ((a)) +#endif + + /* Prototypes for replacement functions. */ #ifndef HAVE_MEMRCHR void *memrchr (const void *block, int c, size_t size); Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/assuan-handler.c 2010-01-28 15:31:25 UTC (rev 352) @@ -811,7 +811,9 @@ if (ctx->outbound.fd != ASSUAN_INVALID_FD) fdarray[n++] = ctx->outbound.fd; if (ctx->outbound.data.fp) -#ifdef HAVE_W32_SYSTEM +#if defined(HAVE_W32CE_SYSTEM) + fdarray[n++] = (void*)fileno (ctx->outbound.data.fp); +#elif defined(HAVE_W32_SYSTEM) fdarray[n++] = (void*)_get_osfhandle (fileno (ctx->outbound.data.fp)); #else fdarray[n++] = fileno (ctx->outbound.data.fp); Modified: trunk/src/assuan-logging.c =================================================================== --- trunk/src/assuan-logging.c 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/assuan-logging.c 2010-01-28 15:31:25 UTC (rev 352) @@ -65,6 +65,8 @@ flagstr = getenv ("ASSUAN_DEBUG"); if (flagstr) log_cats = atoi (flagstr); + + _assuan_sysutils_blurb (); /* Make sure this code gets linked in. */ } Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/assuan-socket-server.c 2010-01-28 15:31:25 UTC (rev 352) @@ -46,6 +46,8 @@ { assuan_fd_t fd = ctx->connected_fd; + TRACE (ctx, ASSUAN_LOG_SYSIO, "accept_connection_bottom", ctx); + ctx->peercred_valid = 0; #ifdef HAVE_SO_PEERCRED { @@ -90,12 +92,17 @@ struct sockaddr_un clnt_addr; socklen_t len = sizeof clnt_addr; + TRACE1 (ctx, ASSUAN_LOG_SYSIO, "accept_connection", ctx, + "listen_fd=0x%x", ctx->listen_fd); + fd = SOCKET2HANDLE(accept (HANDLE2SOCKET(ctx->listen_fd), (struct sockaddr*)&clnt_addr, &len )); if (fd == ASSUAN_INVALID_FD) { return _assuan_error (ctx, gpg_err_code_from_syserror ()); } + TRACE1 (ctx, ASSUAN_LOG_SYSIO, "accept_connection", ctx, + "fd->0x%x", fd); if (_assuan_sock_check_nonce (ctx, fd, &ctx->listen_nonce)) { _assuan_close (ctx, fd); Modified: trunk/src/assuan-socket.c =================================================================== --- trunk/src/assuan-socket.c 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/assuan-socket.c 2010-01-28 15:31:25 UTC (rev 352) @@ -38,6 +38,7 @@ #include #include "assuan-defs.h" +#include "debug.h" /* Hacks for Slowaris. */ #ifndef PF_LOCAL @@ -268,7 +269,7 @@ { int save_e = errno; fclose (fp); - remove (unaddr->sun_path); + DeleteFile (unaddr->sun_path); gpg_err_set_errno (save_e); return rc; } @@ -313,7 +314,7 @@ } else { - nonce->length = 42; /* Arbitrary valuie to detect unitialized nonce. */ + nonce->length = 42; /* Arbitrary value to detect unitialized nonce. */ nonce->nonce[0] = 42; } #else Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/assuan.h 2010-01-28 15:31:25 UTC (rev 352) @@ -1,5 +1,6 @@ /* assuan.h - Definitions for the Assuan IPC library - Copyright (C) 2001-2003, 2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2005, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. This file is part of Assuan. @@ -88,10 +89,14 @@ static inline assuan_fd_t assuan_fd_from_posix_fd (int fd) { +#ifdef __MINGW32CE__ + return (assuan_fd_t)(fd); +#else if (fd < 0) return ASSUAN_INVALID_FD; else return (assuan_fd_t) _get_osfhandle (fd); +#endif } #else typedef int assuan_fd_t; @@ -109,7 +114,7 @@ /* Assuan features an emulation of Unix domain sockets based on a local TCP connections. To implement access permissions based on - file permissions a nonce is used which is expected by th server as + file permissions a nonce is used which is expected by the server as the first bytes received. This structure is used by the server to save the nonce created initially by bind. On POSIX systems this is a dummy operation. */ Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/src/system.c 2010-01-28 15:31:25 UTC (rev 352) @@ -50,7 +50,11 @@ assuan_fdopen (int fd) { #ifdef HAVE_W32_SYSTEM +#ifdef HAVE_W32CE_SYSTEM + assuan_fd_t ifd = (assuan_fd_t)fd; +#else assuan_fd_t ifd = (assuan_fd_t) _get_osfhandle (fd); +#endif assuan_fd_t ofd; if (! DuplicateHandle(GetCurrentProcess(), ifd, @@ -199,6 +203,11 @@ sec_attr.nLength = sizeof (sec_attr); sec_attr.bInheritHandle = FALSE; +#ifdef HAVE_W32CE_SYSTEM +# warning Implement a CreatePipe Replacement. + gpg_err_set_errno (EIO); + return -1; +#else if (! CreatePipe (&rh, &wh, &sec_attr, 0)) { TRACE1 (ctx, ASSUAN_LOG_SYSIO, "__assuan_pipe", ctx, @@ -206,6 +215,7 @@ gpg_err_set_errno (EIO); return -1; } +#endif if (! DuplicateHandle (GetCurrentProcess(), (inherit_idx == 0) ? rh : wh, GetCurrentProcess(), &th, 0, @@ -663,7 +673,9 @@ TRUE, /* Inherit handles. */ (CREATE_DEFAULT_ERROR_MODE | ((flags & 128)? DETACHED_PROCESS : 0) +#ifndef HAVE_W32CE_SYSTEM | GetPriorityClass (GetCurrentProcess ()) +#endif | CREATE_SUSPENDED), /* Creation flags. */ NULL, /* Environment. */ NULL, /* Use current drive/directory. */ Added: trunk/src/sysutils.c =================================================================== --- trunk/src/sysutils.c (rev 0) +++ trunk/src/sysutils.c 2010-01-28 15:31:25 UTC (rev 352) @@ -0,0 +1,130 @@ +/* sysutils.c - System utilities + Copyright (C) 2010 Free Software Foundation, Inc. + + This file is part of Assuan. + + Assuan 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. + + Assuan 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 +#endif +#include +#include +#include +#include +#ifdef HAVE_W32_SYSTEM +#include +#endif /*HAVE_W32_SYSTEM*/ + +#include "assuan-defs.h" + + +/* This is actually a dummy function to make sure that is module is + not empty. Sokme compilers barf on that. */ +const char * +_assuan_sysutils_blurb (void) +{ + static const char blurb[] = + "\n\n" + "This is Libassuan - The GnuPG IPC Library\n" + "Copyright 2000, 2002, 2003, 2004, 2007, 2008, 2009,\n" + " 2010 Free Software Foundation, Inc.\n" + "\n\n"; + return blurb; +} + + +/* Return a string from the Win32 Registry or NULL in case of error. + The returned string is allocated using a plain malloc and thus the + caller needs to call the standard free(). The string is looked up + under HKEY_LOCAL_MACHINE. */ +#ifdef HAVE_W32CE_SYSTEM +static char * +w32_read_registry (const wchar_t *dir, const wchar_t *name) +{ + HKEY handle; + DWORD n, nbytes; + wchar_t *buffer = NULL; + char *result = NULL; + + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &handle)) + return NULL; /* No need for a RegClose, so return immediately. */ + + nbytes = 1; + if (RegQueryValueEx (handle, name, 0, NULL, NULL, &nbytes)) + goto leave; + buffer = malloc ((n=nbytes+2)); + if (!buffer) + goto leave; + if (RegQueryValueEx (handle, name, 0, NULL, (PBYTE)buffer, &n)) + { + free (buffer); + buffer = NULL; + goto leave; + } + + n = WideCharToMultiByte (CP_UTF8, 0, buffer, nbytes, NULL, 0, NULL, NULL); + if (n < 0 || (n+1) <= 0) + goto leave; + result = malloc (n+1); + if (!result) + goto leave; + n = WideCharToMultiByte (CP_UTF8, 0, buffer, nbytes, result, n, NULL, NULL); + if (n < 0) + { + free (result); + result = NULL; + goto leave; + } + result[n] = 0; + + leave: + free (buffer); + RegCloseKey (handle); + return result; +} +#endif /*HAVE_W32CE_SYSTEM*/ + + + +#ifdef HAVE_W32CE_SYSTEM +/* Replacement for getenv which takes care of the our use of getenv. + The code is not thread safe but we expect it to work in all cases + because it is called for the first time early enough. */ +char * +_assuan_getenv (const char *name) +{ + static int initialized; + static char *val_debug; + static char *val_full_logging; + + if (!initialized) + { + val_debug = w32_read_registry (L"\\Software\\GNU\\libassuan", + L"debug"); + val_full_logging = w32_read_registry (L"\\Software\\GNU\\libassuan", + L"full_logging"); + initialized = 1; + } + + + if (!strcmp (name, "ASSUAN_DEBUG")) + return val_debug; + else if (!strcmp (name, "ASSUAN_FULL_LOGGING")) + return val_full_logging; + else + return NULL; +} +#endif /*HAVE_W32CE_SYSTEM*/ Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/tests/Makefile.am 2010-01-28 15:31:25 UTC (rev 352) @@ -25,7 +25,7 @@ BUILT_SOURCES = CLEANFILES = -TESTS = +TESTS = ce-server if USE_DESCRIPTOR_PASSING TESTS += fdpassing @@ -35,5 +35,5 @@ noinst_HEADERS = common.h noinst_PROGRAMS = $(TESTS) -LDADD = ../src/libassuan.la $(NETLIBS) $(GPG_ERROR_LIBS) +LDADD = ../src/libassuan.la $(NETLIBS) $(GPG_ERROR_LIBS) Modified: trunk/tests/common.h =================================================================== --- trunk/tests/common.h 2010-01-22 18:55:16 UTC (rev 351) +++ trunk/tests/common.h 2010-01-28 15:31:25 UTC (rev 352) @@ -19,19 +19,33 @@ #include +#ifdef HAVE_W32CE_SYSTEM +#define getpid() GetCurrentProcessId () +#define getenv(a) (NULL) +#endif +#if HAVE_W32_SYSTEM +#define SOCKET2HANDLE(s) ((void *)(s)) +#define HANDLE2SOCKET(h) ((unsigned int)(h)) +#else +#define SOCKET2HANDLE(s) (s) +#define HANDLE2SOCKET(h) (h) +#endif + + static const char *log_prefix; static int errorcount; static int verbose; static int debug; - void * xmalloc (size_t n) { char *p = malloc (n); if (!p) { + if (log_prefix) + fprintf (stderr, "%s[%u]: ", log_prefix, (unsigned int)getpid ()); fprintf (stderr, "out of core\n"); exit (1); } @@ -44,6 +58,8 @@ char *p = calloc (n, m); if (!p) { + if (log_prefix) + fprintf (stderr, "%s[%u]: ", log_prefix, (unsigned int)getpid ()); fprintf (stderr, "out of core\n"); exit (1); } @@ -69,6 +85,13 @@ } +const char * +log_get_prefix (void) +{ + return log_prefix? log_prefix:""; +} + + void log_info (const char *format, ...) { From cvs at cvs.gnupg.org Thu Jan 28 16:32:11 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 28 Jan 2010 16:32:11 +0100 Subject: [svn] assuan - r353 - trunk/tests Message-ID: Author: wk Date: 2010-01-28 16:32:11 +0100 (Thu, 28 Jan 2010) New Revision: 353 Added: trunk/tests/ce-server.c Log: First take on Server for W32CE From cvs at cvs.gnupg.org Thu Jan 28 21:48:51 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 28 Jan 2010 21:48:51 +0100 Subject: [svn] assuan - r354 - trunk/tests Message-ID: Author: wk Date: 2010-01-28 21:48:51 +0100 (Thu, 28 Jan 2010) New Revision: 354 Modified: trunk/tests/ce-server.c trunk/tests/common.h Log: Add some commands to the test server. Modified: trunk/tests/ce-server.c =================================================================== --- trunk/tests/ce-server.c 2010-01-28 15:32:11 UTC (rev 353) +++ trunk/tests/ce-server.c 2010-01-28 20:48:51 UTC (rev 354) @@ -38,6 +38,11 @@ #endif #include +#ifdef HAVE_W32CE_SYSTEM +#ifndef FILE_ATTRIBUTE_ROMSTATICREF +#define FILE_ATTRIBUTE_ROMSTATICREF FILE_ATTRIBUTE_OFFLINE +#endif +#endif #include "../src/assuan.h" @@ -49,8 +54,25 @@ /* Flag set to indicate a shutdown. */ static int shutdown_pending; +/* The local state of a connection. */ +struct state_s +{ + char *cwd; /* The current working directory - access using get_cwd(). */ +}; +typedef struct state_s *state_t; + +static void +release_state (state_t state) +{ + if (!state) + return; + xfree (state->cwd); + xfree (state); +} + + /* Helper to print a message while leaving a command. */ static gpg_error_t leave_cmd (assuan_context_t ctx, gpg_error_t err) @@ -70,8 +92,116 @@ } +#ifdef HAVE_W32CE_SYSTEM +static char * +wchar_to_utf8 (const wchar_t *string) +{ + int n; + size_t length = wcslen (string); + char *result; + n = WideCharToMultiByte (CP_UTF8, 0, string, length, NULL, 0, NULL, NULL); + if (n < 0 || (n+1) <= 0) + log_fatal ("WideCharToMultiByte failed\n"); + result = xmalloc (n+1); + n = WideCharToMultiByte (CP_ACP, 0, string, length, result, n, NULL, NULL); + if (n < 0) + log_fatal ("WideCharToMultiByte failed\n"); + + result[n] = 0; + return result; +} + +static wchar_t * +utf8_to_wchar (const char *string) +{ + int n; + size_t length = strlen (string); + wchar_t *result; + size_t nbytes; + + n = MultiByteToWideChar (CP_UTF8, 0, string, length, NULL, 0); + if (n < 0 || (n+1) <= 0) + log_fatal ("MultiByteToWideChar failed\n"); + + nbytes = (size_t)(n+1) * sizeof(*result); + if (nbytes / sizeof(*result) != (n+1)) + log_fatal ("utf8_to_wchar: integer overflow\n"); + result = xmalloc (nbytes); + n = MultiByteToWideChar (CP_UTF8, 0, string, length, result, n); + if (n < 0) + log_fatal ("MultiByteToWideChar failed\n"); + result[n] = 0; + + return result; +} +#endif /*HAVE_W32CE_SYSTEM*/ + +#ifndef HAVE_W32CE_SYSTEM +static char * +gnu_getcwd (void) +{ + size_t size = 100; + + while (1) + { + char *buffer = xmalloc (size); + if (getcwd (buffer, size) == buffer) + return buffer; + xfree (buffer); + if (errno != ERANGE) + return 0; + size *= 2; + } +} +#endif /*!HAVE_W32CE_SYSTEM*/ + + +/* Return the current working directory. The returned string is valid + as long as STATE->cwd is not changed. */ +static const char * +get_cwd (state_t state) +{ + if (!state->cwd) + { + /* No working directory yet. On WindowsCE make it the module + directory of this process. */ + char *p; +#ifdef HAVE_W32CE_SYSTEM + wchar_t buf[MAX_PATH+1]; + size_t n; + + n = GetModuleFileName (NULL, buf, MAX_PATH); + if (!n) + state->cwd = xstrdup ("/"); + else + { + buf[n] = 0; + state->cwd = wchar_to_utf8 (buf); + p = strrchr (state->cwd, '\\'); + if (p) + *p = 0; + } +#else + state->cwd = gnu_getcwd (); +#endif +#ifdef HAVE_W32_SYSTEM + for (p=state->cwd; *p; p++) + if (*p == '\\') + *p = '/'; +#endif /*HAVE_W32_SYSTEM*/ + } + + return state->cwd; +} + + + + + + + static const char hlp_echo[] = "ECHO \n" @@ -88,14 +218,156 @@ } +static const char hlp_pwd[] = + "PWD\n" + "\n" + "Print the curent working directory of this session.\n"; +static gpg_error_t +cmd_pwd (assuan_context_t ctx, char *line) +{ + state_t state = assuan_get_pointer (ctx); + gpg_error_t err; + const char *string; + + string = get_cwd (state); + err = assuan_send_data (ctx, string, strlen (string)); -static const char hlp_killserver[] = - "KILLSERVER\n" + return leave_cmd (ctx, err); +} + + +static const char hlp_cd[] = + "CD [dir]\n" "\n" - "Kill the server process.\n"; + "Change the curretn directory of the session.\n"; static gpg_error_t -cmd_killserver (assuan_context_t ctx, char *line) +cmd_cd (assuan_context_t ctx, char *line) { + state_t state = assuan_get_pointer (ctx); + gpg_error_t err = 0; + char *newdir, *p; + + for (p=line; *p; p++) + if (*p == '\\') + *p = '/'; + + if (!*line) + { + xfree (state->cwd); + state->cwd = NULL; + get_cwd (state); + } + else + { + if (*line == '/') + newdir = xstrdup (line); + else + newdir = xstrconcat (get_cwd (state), "/", line, NULL); + + while (strlen(newdir) > 1 && line[strlen(newdir)-1] == '/') + line[strlen(newdir)-1] = 0; + xfree (state->cwd); + state->cwd = newdir; + } + + return leave_cmd (ctx, err); +} + + + + + +#ifdef HAVE_W32CE_SYSTEM +static const char hlp_ls[] = + "LS []\n" + "\n" + "List the files described by PATTERN.\n"; +static gpg_error_t +cmd_ls (assuan_context_t ctx, char *line) +{ + state_t state = assuan_get_pointer (ctx); + gpg_error_t err; + WIN32_FIND_DATA fi; + char buf[500]; + HANDLE hd; + char *p, *fname; + wchar_t *wfname; + + if (!*line) + fname = xstrconcat (get_cwd (state), "/*", NULL); + else if (*line == '/' || *line == '\\') + fname = xstrdup (line); + else + fname = xstrconcat (get_cwd (state), "/", line, NULL); + for (p=fname; *p; p++) + if (*p == '/') + *p = '\\'; + assuan_write_status (ctx, "PATTERN", fname); + wfname = utf8_to_wchar (fname); + xfree (fname); + hd = FindFirstFile (wfname, &fi); + free (wfname); + if (hd == INVALID_HANDLE_VALUE) + { + log_info ("FindFirstFile returned %d\n", GetLastError ()); + err = gpg_error_from_syserror (); /* Works for W32CE. */ + goto leave; + } + + do + { + DWORD attr = fi.dwFileAttributes; + + fname = wchar_to_utf8 (fi.cFileName); + snprintf (buf, sizeof buf, + "%c%c%c%c%c%c%c%c%c%c%c%c%c %7lu%c %s\n", + (attr & FILE_ATTRIBUTE_DIRECTORY) + ? ((attr & FILE_ATTRIBUTE_DEVICE)? 'c':'d'):'-', + (attr & FILE_ATTRIBUTE_READONLY)? 'r':'-', + (attr & FILE_ATTRIBUTE_HIDDEN)? 'h':'-', + (attr & FILE_ATTRIBUTE_SYSTEM)? 's':'-', + (attr & FILE_ATTRIBUTE_ARCHIVE)? 'a':'-', + (attr & FILE_ATTRIBUTE_COMPRESSED)? 'c':'-', + (attr & FILE_ATTRIBUTE_ENCRYPTED)? 'e':'-', + (attr & FILE_ATTRIBUTE_INROM)? 'R':'-', + (attr & FILE_ATTRIBUTE_REPARSE_POINT)? 'P':'-', + (attr & FILE_ATTRIBUTE_ROMMODULE)? 'M':'-', + (attr & FILE_ATTRIBUTE_ROMSTATICREF)? 'R':'-', + (attr & FILE_ATTRIBUTE_SPARSE_FILE)? 'S':'-', + (attr & FILE_ATTRIBUTE_TEMPORARY)? 't':'-', + (unsigned long)fi.nFileSizeLow, + fi.nFileSizeHigh? 'X':' ', + fname); + free (fname); + err = assuan_send_data (ctx, buf, strlen (buf)); + if (!err) + err = assuan_send_data (ctx, NULL, 0); + } + while (!err && FindNextFile (hd, &fi)); + if (err) + ; + else if (GetLastError () == ERROR_NO_MORE_FILES) + err = 0; + else + { + log_info ("FindNextFile returned %d\n", GetLastError ()); + err = gpg_error_from_syserror (); + } + FindClose (hd); + + leave: + return leave_cmd (ctx, err); +} +#endif /*HAVE_W32CE_SYSTEM*/ + + +static const char hlp_shutdown[] = + "SHUTDOWN\n" + "\n" + "Shutdown the server process after ending this connection\n"; +static gpg_error_t +cmd_shutdown (assuan_context_t ctx, char *line) +{ (void)ctx; (void)line; shutdown_pending = 1; @@ -113,10 +385,15 @@ const char * const help; } table[] = { +#ifdef HAVE_W32CE_SYSTEM + { "LS", cmd_ls, hlp_ls }, +#endif + { "PWD", cmd_pwd, hlp_pwd }, + { "CD", cmd_cd, hlp_cd }, { "ECHO", cmd_echo, hlp_echo }, { "INPUT", NULL }, { "OUTPUT", NULL }, - { "KILLSERVER", cmd_killserver, hlp_killserver }, + { "SHUTDOWN", cmd_shutdown, hlp_shutdown }, { NULL, NULL } }; int i; @@ -143,6 +420,7 @@ int one = 1; struct sockaddr_in name; assuan_context_t ctx; + state_t state = NULL; err = assuan_new (&ctx); if (err) @@ -184,8 +462,13 @@ if (err) log_fatal ("register_commands failed: %s\n", gpg_strerror(err)); - assuan_set_log_stream (ctx, stderr); + if (debug) + assuan_set_log_stream (ctx, stderr); + + state = xcalloc (1, sizeof state); + assuan_set_pointer (ctx, state); + while (!shutdown_pending) { err = assuan_accept (ctx); @@ -206,6 +489,7 @@ assuan_sock_close (server_fd); assuan_release (ctx); + release_state (state); } @@ -254,7 +538,8 @@ } assuan_set_assuan_log_prefix (log_prefix); - assuan_set_assuan_log_stream (stderr); + if (debug) + assuan_set_assuan_log_stream (stderr); err = assuan_sock_init (); if (err) Modified: trunk/tests/common.h =================================================================== --- trunk/tests/common.h 2010-01-28 15:32:11 UTC (rev 353) +++ trunk/tests/common.h 2010-01-28 20:48:51 UTC (rev 354) @@ -19,6 +19,13 @@ #include +#if __GNUC__ >= 4 +# define MY_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a))) +#else +# define MY_GCC_A_SENTINEL(a) +#endif + + #ifdef HAVE_W32CE_SYSTEM #define getpid() GetCurrentProcessId () #define getenv(a) (NULL) @@ -32,7 +39,13 @@ #define HANDLE2SOCKET(h) (h) #endif +#define DIM(v) (sizeof(v)/sizeof((v)[0])) +#define DIMof(type,member) DIM(((type *)0)->member) + +char *xstrconcat (const char *s1, ...) MY_GCC_A_SENTINEL(0); + + static const char *log_prefix; static int errorcount; static int verbose; @@ -73,7 +86,15 @@ free (a); } +void * +xstrdup (const char *string) +{ + char *p = xmalloc (strlen (string) + 1); + strcpy (p, string); + return p; +} + void log_set_prefix (const char *s) { @@ -168,3 +189,81 @@ return result; } + +#ifndef HAVE_STPCPY +#undef __stpcpy +#undef stpcpy +#ifndef weak_alias +# define __stpcpy stpcpy +#endif +char * +__stpcpy (char *a,const char *b) +{ + while (*b) + *a++ = *b++; + *a = 0; + return (char*)a; +} +#ifdef libc_hidden_def +libc_hidden_def (__stpcpy) +#endif +#ifdef weak_alias +weak_alias (__stpcpy, stpcpy) +#endif +#ifdef libc_hidden_builtin_def +libc_hidden_builtin_def (stpcpy) +#endif +#endif + + +static char * +do_strconcat (const char *s1, va_list arg_ptr) +{ + const char *argv[48]; + size_t argc; + size_t needed; + char *buffer, *p; + + argc = 0; + argv[argc++] = s1; + needed = strlen (s1); + while (((argv[argc] = va_arg (arg_ptr, const char *)))) + { + needed += strlen (argv[argc]); + if (argc >= DIM (argv)-1) + { + fprintf (stderr, "too many args in strconcat\n"); + exit (1); + } + argc++; + } + needed++; + buffer = xmalloc (needed); + if (buffer) + { + for (p = buffer, argc=0; argv[argc]; argc++) + p = stpcpy (p, argv[argc]); + } + return buffer; +} + + +/* Concatenate the string S1 with all the following strings up to a + NULL. Returns a malloced buffer or dies on malloc error. */ +char * +xstrconcat (const char *s1, ...) +{ + va_list arg_ptr; + char *result; + + if (!s1) + result = xstrdup (""); + else + { + va_start (arg_ptr, s1); + result = do_strconcat (s1, arg_ptr); + va_end (arg_ptr); + } + return result; +} + From cvs at cvs.gnupg.org Fri Jan 29 11:37:12 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 29 Jan 2010 11:37:12 +0100 Subject: [svn] GnuPG - r5253 - branches/STABLE-BRANCH-1-4/doc Message-ID: Author: wk Date: 2010-01-29 11:37:12 +0100 (Fri, 29 Jan 2010) New Revision: 5253 Modified: branches/STABLE-BRANCH-1-4/doc/ChangeLog branches/STABLE-BRANCH-1-4/doc/gnupg1.texi Log: Fix bug#1183 Modified: branches/STABLE-BRANCH-1-4/doc/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/doc/ChangeLog 2010-01-26 16:33:58 UTC (rev 5252) +++ branches/STABLE-BRANCH-1-4/doc/ChangeLog 2010-01-29 10:37:12 UTC (rev 5253) @@ -1,3 +1,7 @@ +2010-01-29 Werner Koch + + * gnupg1.texi: Fix dir entry. Fixes bug#1183. + 2009-09-02 Werner Koch * gpgv.texi, gpg.texi: Update from GnuPG-2. Modified: branches/STABLE-BRANCH-1-4/doc/gnupg1.texi =================================================================== --- branches/STABLE-BRANCH-1-4/doc/gnupg1.texi 2010-01-26 16:33:58 UTC (rev 5252) +++ branches/STABLE-BRANCH-1-4/doc/gnupg1.texi 2010-01-29 10:37:12 UTC (rev 5253) @@ -48,7 +48,7 @@ @dircategory GNU Utilities @direntry -* gpg: (gpg). OpenPGP encryption and signing tool (v1). +* gpg: (gnupg1). OpenPGP encryption and signing tool (v1). @end direntry From cvs at cvs.gnupg.org Fri Jan 29 18:04:50 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 29 Jan 2010 18:04:50 +0100 Subject: [svn] assuan - r355 - trunk/tests Message-ID: Author: wk Date: 2010-01-29 18:04:49 +0100 (Fri, 29 Jan 2010) New Revision: 355 Modified: trunk/tests/ce-server.c Log: Add a run command. Modified: trunk/tests/ce-server.c =================================================================== --- trunk/tests/ce-server.c 2010-01-28 20:48:51 UTC (rev 354) +++ trunk/tests/ce-server.c 2010-01-29 17:04:49 UTC (rev 355) @@ -361,6 +361,112 @@ #endif /*HAVE_W32CE_SYSTEM*/ +#ifdef HAVE_W32CE_SYSTEM +static const char hlp_run[] = + "RUN []\n" + "\n" + "Run the program in FILENAME with the arguments ARGS.\n" + "This creates a new process and waits for it to finish.\n" + "FIXME: The process' stdin is connected to the file set by the\n" + "INPUT command; stdout and stderr to the one set by OUTPUT.\n"; +static gpg_error_t +cmd_run (assuan_context_t ctx, char *line) +{ + /* state_t state = assuan_get_pointer (ctx); */ + gpg_error_t err; + PROCESS_INFORMATION pi = { NULL, 0, 0, 0 }; + char *p; + wchar_t *pgmname = NULL; + wchar_t *cmdline = NULL; + int code; + DWORD exc; + + p = strchr (line, ' '); + if (p) + { + *p = 0; + pgmname = utf8_to_wchar (line); + for (p++; *p && *p == ' '; p++) + ; + cmdline = utf8_to_wchar (p); + } + else + pgmname = utf8_to_wchar (line); + { + char *tmp1 = wchar_to_utf8 (pgmname); + char *tmp2 = wchar_to_utf8 (cmdline); + log_info ("CreateProcess, path=`%s' cmdline=`%s'\n", tmp1, tmp2); + xfree (tmp2); + xfree (tmp1); + } + if (!CreateProcess (pgmname, /* Program to start. */ + cmdline, /* Command line arguments. */ + NULL, /* Process security attributes. notsup. */ + NULL, /* Thread security attributes. notsup. */ + FALSE, /* Inherit handles. notsup. */ + CREATE_SUSPENDED, /* Creation flags. */ + NULL, /* Environment. notsup. */ + NULL, /* Use current drive/directory. notsup. */ + NULL, /* Startup information. notsup. */ + &pi /* Returns process information. */ + )) + { + log_error ("CreateProcess failed: %d", GetLastError ()); + err = gpg_error_from_syserror (); + goto leave; + } + + log_info ("CreateProcess ready: hProcess=%p hThread=%p" + " dwProcessID=%d dwThreadId=%d\n", + pi.hProcess, pi.hThread, + (int) pi.dwProcessId, (int) pi.dwThreadId); + + ResumeThread (pi.hThread); + CloseHandle (pi.hThread); + + code = WaitForSingleObject (pi.hProcess, INFINITE); + switch (code) + { + case WAIT_FAILED: + err = gpg_error_from_syserror ();; + log_error ("waiting for process %d to terminate failed: %d\n", + (int)pi.dwProcessId, GetLastError ()); + break; + + case WAIT_OBJECT_0: + if (!GetExitCodeProcess (pi.hProcess, &exc)) + { + err = gpg_error_from_syserror ();; + log_error ("error getting exit code of process %d: %s\n", + (int)pi.dwProcessId, GetLastError () ); + } + else if (exc) + { + log_info ("error running process: exit status %d\n", (int)exc); + err = gpg_error (GPG_ERR_GENERAL); + } + else + { + err = 0; + } + break; + + default: + err = gpg_error_from_syserror ();; + log_error ("WaitForSingleObject returned unexpected " + "code %d for pid %d\n", code, (int)pi.dwProcessId); + break; + } + CloseHandle (pi.hProcess); + + leave: + xfree (cmdline); + xfree (pgmname); + return leave_cmd (ctx, err); +} +#endif /*HAVE_W32CE_SYSTEM*/ + + static const char hlp_shutdown[] = "SHUTDOWN\n" "\n" @@ -387,6 +493,7 @@ { #ifdef HAVE_W32CE_SYSTEM { "LS", cmd_ls, hlp_ls }, + { "RUN", cmd_run, hlp_run }, #endif { "PWD", cmd_pwd, hlp_pwd }, { "CD", cmd_cd, hlp_cd },