From cvs at cvs.gnupg.org Tue Sep 1 16:25:10 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 01 Sep 2009 16:25:10 +0200 Subject: [svn] assuan - r297 - in trunk: . src Message-ID: Author: marcus Date: 2009-09-01 16:25:10 +0200 (Tue, 01 Sep 2009) New Revision: 297 Modified: trunk/ChangeLog trunk/configure.ac trunk/src/Makefile.am trunk/src/assuan-defs.h trunk/src/assuan-pipe-connect.c trunk/src/assuan-socket-server.c trunk/src/libassuan.def trunk/src/setenv.c trunk/src/versioninfo.rc.in Log: 2009-09-01 Marcus Brinkmann * configure.ac: Set BUILD_REVISION and update calculation of data for build info. Update libtool macros. Set NETLIBS for W32 targets. src/ 2009-09-01 Marcus Brinkmann * setenv.c: Do not include "assuan-defs.h", instead redefine setenv, unsetenv, clearenv in place. * assuan-socket-server.c: Use _assuan_free instead of xfree. * assuan-pipe-connect.c: Fix syntax error. * assuan-defs.h: Remove some duplicated W32 stuff. * Makefile.am (libassuan_la_LIBADD, libassuan_pth_la_LIBADD): Add @NETLIBS at . * versioninfo.rc.in (FILEVERSION): Set to @BUILD_FILEVERSION at . ("FileDescription", "FileVersion", "InternalName") ("LegalCopyright", "OriginalFilename", "ProductName"): Replace c&p garbage. * libassuan.def: Remove assuan_get_peercred. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/ChangeLog 2009-09-01 14:25:10 UTC (rev 297) @@ -1,3 +1,9 @@ +2009-09-01 Marcus Brinkmann + + * configure.ac: Set BUILD_REVISION and update calculation of data + for build info. Update libtool macros. Set NETLIBS for W32 + targets. + 2009-08-26 Marcus Brinkmann * configure.ac: Test for versioned symbols support. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/configure.ac 2009-09-01 14:25:10 UTC (rev 297) @@ -52,6 +52,7 @@ AC_SUBST(LIBASSUAN_LT_AGE) AC_SUBST(LIBASSUAN_LT_REVISION) +BUILD_REVISION=svn_revision PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION @@ -75,10 +76,9 @@ # Don't default to build static libs. -AC_DISABLE_STATIC -AC_LIBTOOL_WIN32_DLL -AC_LIBTOOL_RC -AC_PROG_LIBTOOL +LT_PREREQ([2.2.6]) +LT_INIT([win32-dll disable-static]) +LT_LANG([Windows Resource]) # For now we hardcode the use of version scripts. It would be better # to write a test for this or even implement this within libtool. @@ -173,8 +173,22 @@ dnl AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes) if test "$have_w32_system" = yes; then - AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) + AC_DEFINE(HAVE_W32_SYSTEM,1,[Defined if we run on a W32 API based system]) + 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 + case "$VERSION" in + *-svn*) BUILD_FILEVERSION="${BUILD_FILEVERSION}0" ;; + *-cvs) BUILD_FILEVERSION="${BUILD_FILEVERSION}0" ;; + *-rc*) BUILD_FILEVERSION="${BUILD_FILEVERSION}1" ;; + *) BUILD_FILEVERSION="${BUILD_FILEVERSION}2" ;; + esac fi +AC_SUBST(BUILD_REVISION) +AC_SUBST(BUILD_TIMESTAMP) +AC_SUBST(BUILD_FILEVERSION) AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) # @@ -189,6 +203,11 @@ [NETLIBS="-lsocket $NETLIBS"])) AC_SUBST(NETLIBS) +if test "$have_w32_system" = yes; then + NETLIBS="-lws2_32 $NETLIBS" +fi + + # For src/libassuan-config.in LIBASSUAN_CONFIG_LIB="-lassuan" LIBASSUAN_CONFIG_CFLAGS="" @@ -197,9 +216,6 @@ LIBASSUAN_CONFIG_THREAD_MODULES="pth" fi LIBASSUAN_CONFIG_EXTRA_LIBS= -if test "$have_w32_system" = yes; then - LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS -lws2_32" -fi if test x"$NETLIBS" != x; then LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS $NETLIBS" fi Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/src/Makefile.am 2009-09-01 14:25:10 UTC (rev 297) @@ -102,12 +102,12 @@ @LIBASSUAN_LT_CURRENT@:@LIBASSUAN_LT_REVISION@:@LIBASSUAN_LT_AGE@ libassuan_la_DEPENDENCIES = @LTLIBOBJS@ \ $(srcdir)/libassuan.vers $(libassuan_deps) -libassuan_la_LIBADD = @LTLIBOBJS@ @GPG_ERROR_LIBS@ +libassuan_la_LIBADD = @LTLIBOBJS@ @NETLIBS@ @GPG_ERROR_LIBS@ if HAVE_PTH libassuan_pth_la_SOURCES = $(common_sources) assuan-io-pth.c libassuan_pth_la_CPPFLAGS = $(AM_CPPFLAGS) @GPG_ERROR_CFLAGS@ @PTH_CFLAGS@ libassuan_pth_la_CFLAGS = $(AM_CFLAGS) @GPG_ERROR_CFLAGS@ $(PTH_CFLAGS) -libassuan_pth_la_LIBADD = @LTLIBOBJS@ @GPG_ERROR_LIBS@ @PTH_LIBS@ +libassuan_pth_la_LIBADD = @LTLIBOBJS@ @NETLIBS@ @GPG_ERROR_LIBS@ @PTH_LIBS@ endif Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/src/assuan-defs.h 2009-09-01 14:25:10 UTC (rev 297) @@ -37,17 +37,6 @@ #define DIRSEP_C '\\' #endif -#ifdef HAVE_W32_SYSTEM -/* Not needed anymore because the current mingw32 defines this in - sys/types.h */ -/* typedef int ssize_t; */ - -/* Missing W32 functions */ -int putc_unlocked (int c, FILE *stream); -void * memrchr (const void *block, int c, size_t size); -char * stpcpy (char *dest, const char *src); -#endif - #define LINELENGTH ASSUAN_LINELENGTH Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/src/assuan-pipe-connect.c 2009-09-01 14:25:10 UTC (rev 297) @@ -677,7 +677,7 @@ /* Build the command line. */ if (build_w32_commandline (argv, &cmdline)) - return _assuan_error (gpg_err_code from_syserror ()); + return _assuan_error (gpg_err_code_from_syserror ()); /* Create thew two pipes. */ if (create_inheritable_pipe (rp, 0)) Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/src/assuan-socket-server.c 2009-09-01 14:25:10 UTC (rev 297) @@ -191,7 +191,7 @@ rc = _assuan_register_std_commands (ctx); if (rc) - xfree (ctx); + _assuan_free (ctx); else *r_ctx = ctx; return rc; Modified: trunk/src/libassuan.def =================================================================== --- trunk/src/libassuan.def 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/src/libassuan.def 2009-09-01 14:25:10 UTC (rev 297) @@ -34,55 +34,54 @@ assuan_get_flag @13 assuan_get_input_fd @14 assuan_get_output_fd @15 - assuan_get_peercred @16 - assuan_get_pid @17 - assuan_get_pointer @18 - assuan_init_pipe_server @19 - assuan_init_socket_server @21 - assuan_init_socket_server_ext @22 - assuan_inquire @23 - assuan_inquire_ext @24 - assuan_pending_line @25 - assuan_pipe_connect @27 - assuan_pipe_connect_ext @28 - assuan_process @29 - assuan_process_done @30 - assuan_process_next @31 - assuan_read_line @32 - assuan_receivefd @33 - assuan_register_bye_notify @34 - assuan_register_cancel_notify @35 - assuan_register_command @36 - assuan_register_input_notify @37 - assuan_register_option_handler @38 - assuan_register_output_notify @39 - assuan_register_post_cmd_notify @40 - assuan_register_reset_notify @41 - assuan_send_data @42 - assuan_sendfd @43 - assuan_set_assuan_err_source @44 - assuan_set_assuan_log_prefix @45 - assuan_set_assuan_log_stream @46 - assuan_set_error @47 - assuan_set_flag @48 - assuan_set_hello_line @49 - assuan_set_io_hooks @50 - assuan_set_io_monitor @51 - assuan_set_log_stream @52 - assuan_set_malloc_hooks @53 - assuan_set_okay_line @54 - assuan_set_pointer @55 - assuan_sock_bind @56 - assuan_sock_check_nonce @57 - assuan_sock_close @58 - assuan_sock_connect @59 - assuan_sock_get_nonce @60 - assuan_sock_new @61 - assuan_socket_connect @62 - assuan_socket_connect_ext @63 - assuan_transact @64 - assuan_write_line @65 - assuan_write_status @66 + assuan_get_pid @16 + assuan_get_pointer @17 + assuan_init_pipe_server @18 + assuan_init_socket_server @19 + assuan_init_socket_server_ext @20 + assuan_inquire @21 + assuan_inquire_ext @22 + assuan_pending_line @23 + assuan_pipe_connect @24 + assuan_pipe_connect_ext @25 + assuan_process @26 + assuan_process_done @27 + assuan_process_next @28 + assuan_read_line @29 + assuan_receivefd @30 + assuan_register_bye_notify @31 + assuan_register_cancel_notify @32 + assuan_register_command @33 + assuan_register_input_notify @34 + assuan_register_option_handler @35 + assuan_register_output_notify @36 + assuan_register_post_cmd_notify @37 + assuan_register_reset_notify @38 + assuan_send_data @39 + assuan_sendfd @40 + assuan_set_assuan_err_source @41 + assuan_set_assuan_log_prefix @42 + assuan_set_assuan_log_stream @43 + assuan_set_error @44 + assuan_set_flag @45 + assuan_set_hello_line @46 + assuan_set_io_hooks @47 + assuan_set_io_monitor @48 + assuan_set_log_stream @49 + assuan_set_malloc_hooks @50 + assuan_set_okay_line @51 + assuan_set_pointer @52 + assuan_sock_bind @53 + assuan_sock_check_nonce @54 + assuan_sock_close @55 + assuan_sock_connect @56 + assuan_sock_get_nonce @57 + assuan_sock_new @58 + assuan_socket_connect @59 + assuan_socket_connect_ext @60 + assuan_transact @61 + assuan_write_line @62 + assuan_write_status @63 ; END Modified: trunk/src/setenv.c =================================================================== --- trunk/src/setenv.c 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/src/setenv.c 2009-09-01 14:25:10 UTC (rev 297) @@ -20,8 +20,11 @@ # include #endif -#include "assuan-defs.h" +#define setenv _assuan_setenv +#define unsetenv _assuan_unsetenv +#define clearenv _assuan_clearenv + #define __builtin_expect(cond,val) (cond) #include Modified: trunk/src/versioninfo.rc.in =================================================================== --- trunk/src/versioninfo.rc.in 2009-08-26 18:36:49 UTC (rev 296) +++ trunk/src/versioninfo.rc.in 2009-09-01 14:25:10 UTC (rev 297) @@ -1,4 +1,4 @@ -/* versioninfo.rc.in - for gpgme +/* versioninfo.rc.in - for assuan * Copyright (C) 2005 g10 Code GmbH * * This file is free software; as a special exception the author gives @@ -18,7 +18,7 @@ VS_VERSION_INFO VERSIONINFO - FILEVERSION @LIBGPGME_LT_CURRENT@, at LIBGPGME_LT_AGE@, at LIBGPGME_LT_REVISION@, at BUILD_REVISION@ + FILEVERSION @BUILD_FILEVERSION@ PRODUCTVERSION @BUILD_FILEVERSION@ FILEFLAGSMASK 0x3fL #ifdef _DEBUG @@ -36,14 +36,14 @@ BEGIN VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License.\0" VALUE "CompanyName", "g10 Code GmbH\0" - VALUE "FileDescription", "GPGME - GnuPG Made Easy\0" - VALUE "FileVersion", "@LIBGPGME_LT_CURRENT at .@LIBGPGME_LT_AGE at .@LIBGPGME_LT_REVISION at .@BUILD_REVISION@\0" - VALUE "InternalName", "gpgme\0" - VALUE "LegalCopyright", "Copyright ? 2005 g10 Code GmbH\0" + VALUE "FileDescription", "Assuan - GnuPG IPC\0" + VALUE "FileVersion", "@LIBASSUAN_LT_CURRENT at .@LIBASSUAN_LT_AGE at .@LIBASSUAN_LT_REVISION at .@BUILD_REVISION@\0" + VALUE "InternalName", "libassuan\0" + VALUE "LegalCopyright", "Copyright ? 2003-2009 g10 Code GmbH\0" VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "gpgme.dll\0" + VALUE "OriginalFilename", "libassuan.dll\0" VALUE "PrivateBuild", "\0" - VALUE "ProductName", "GPGME\0" + VALUE "ProductName", "Assuan\0" VALUE "ProductVersion", "@VERSION@\0" VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0" END From cvs at cvs.gnupg.org Tue Sep 1 16:41:00 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 01 Sep 2009 16:41:00 +0200 Subject: [svn] assuan - r298 - trunk/src Message-ID: Author: marcus Date: 2009-09-01 16:41:00 +0200 (Tue, 01 Sep 2009) New Revision: 298 Modified: trunk/src/ChangeLog Log: Add to last commit. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-09-01 14:25:10 UTC (rev 297) +++ trunk/src/ChangeLog 2009-09-01 14:41:00 UTC (rev 298) @@ -1,3 +1,18 @@ +2009-09-01 Marcus Brinkmann + + * setenv.c: Do not include "assuan-defs.h", instead redefine + setenv, unsetenv, clearenv in place. + * assuan-socket-server.c: Use _assuan_free instead of xfree. + * assuan-pipe-connect.c: Fix syntax error. + * assuan-defs.h: Remove some duplicated W32 stuff. + * Makefile.am (libassuan_la_LIBADD, libassuan_pth_la_LIBADD): Add + @NETLIBS at . + * versioninfo.rc.in (FILEVERSION): Set to @BUILD_FILEVERSION at . + ("FileDescription", "FileVersion", "InternalName") + ("LegalCopyright", "OriginalFilename", "ProductName"): Replace c&p + garbage. + * libassuan.def: Remove assuan_get_peercred. + 2009-08-26 Marcus Brinkmann * libassuan-config.in: Add gpg-error. From cvs at cvs.gnupg.org Tue Sep 1 16:42:17 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 01 Sep 2009 16:42:17 +0200 Subject: [svn] assuan - r299 - trunk/src Message-ID: Author: marcus Date: 2009-09-01 16:42:17 +0200 (Tue, 01 Sep 2009) New Revision: 299 Modified: trunk/src/ChangeLog trunk/src/assuan-defs.h trunk/src/assuan.h Log: 2009-09-01 Marcus Brinkmann * assuan.h (ASSUAN_INT2FD, ASSUAN_FD2INT): Remove macros. * assuan-defs.h (DIMof): Remove macro. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-09-01 14:41:00 UTC (rev 298) +++ trunk/src/ChangeLog 2009-09-01 14:42:17 UTC (rev 299) @@ -1,5 +1,8 @@ 2009-09-01 Marcus Brinkmann + * assuan.h (ASSUAN_INT2FD, ASSUAN_FD2INT): Remove macros. + * assuan-defs.h (DIMof): Remove macro. + * setenv.c: Do not include "assuan-defs.h", instead redefine setenv, unsetenv, clearenv in place. * assuan-socket-server.c: Use _assuan_free instead of xfree. Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-09-01 14:41:00 UTC (rev 298) +++ trunk/src/assuan-defs.h 2009-09-01 14:42:17 UTC (rev 299) @@ -47,13 +47,12 @@ }; -/* A structure to dispatch I/O functions. All these functions need to - return 0 on success and set ERRNO on failure. */ +/* A structure to dispatch I/O functions. */ struct assuan_io { - /* Routine to read from input_fd. */ + /* Routine to read from input_fd. Sets errno on failure. */ ssize_t (*readfnc) (assuan_context_t, void *, size_t); - /* Routine to write to output_fd. */ + /* Routine to write to output_fd. Sets errno on failure. */ ssize_t (*writefnc) (assuan_context_t, const void *, size_t); /* Send a file descriptor. */ gpg_error_t (*sendfd) (assuan_context_t, assuan_fd_t); @@ -75,7 +74,7 @@ /* Context specific flags (cf. assuan_flag_t). */ struct { - unsigned int no_waitpid:1; /* See ASSUAN_NO_WAITPID. */ + unsigned int no_waitpid : 1; /* See ASSUAN_NO_WAITPID. */ } flags; int confidential; @@ -313,9 +312,7 @@ #endif #define DIM(v) (sizeof(v)/sizeof((v)[0])) -#define DIMof(type,member) DIM(((type *)0)->member) - #if HAVE_W32_SYSTEM #define SOCKET2HANDLE(s) ((void *)(s)) #define HANDLE2SOCKET(h) ((unsigned int)(h)) Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-09-01 14:41:00 UTC (rev 298) +++ trunk/src/assuan.h 2009-09-01 14:42:17 UTC (rev 299) @@ -243,13 +243,9 @@ #ifdef _WIN32 typedef void *assuan_fd_t; #define ASSUAN_INVALID_FD ((void*)(-1)) -#define ASSUAN_INT2FD(s) ((void *)(s)) -#define ASSUAN_FD2INT(h) ((unsigned int)(h)) #else typedef int assuan_fd_t; #define ASSUAN_INVALID_FD (-1) -#define ASSUAN_INT2FD(s) ((s)) -#define ASSUAN_FD2INT(h) ((h)) #endif From cvs at cvs.gnupg.org Tue Sep 1 16:42:54 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 01 Sep 2009 16:42:54 +0200 Subject: [svn] assuan - r300 - trunk/doc Message-ID: Author: marcus Date: 2009-09-01 16:42:54 +0200 (Tue, 01 Sep 2009) New Revision: 300 Modified: trunk/doc/ChangeLog trunk/doc/assuan.texi Log: 2009-08-28 Marcus Brinkmann * assuan.texi: Update to API changes. (Data Types): Remove assuan_error_t. (Utilities): Remove assuan_strerror. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-09-01 14:42:17 UTC (rev 299) +++ trunk/doc/ChangeLog 2009-09-01 14:42:54 UTC (rev 300) @@ -1,3 +1,9 @@ +2009-08-28 Marcus Brinkmann + + * assuan.texi: Update to API changes. + (Data Types): Remove assuan_error_t. + (Utilities): Remove assuan_strerror. + 2008-10-29 Marcus Brinkmann * assuan.texi: Change return type of callback handlers in Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2009-09-01 14:42:17 UTC (rev 299) +++ trunk/doc/assuan.texi 2009-09-01 14:42:54 UTC (rev 300) @@ -186,7 +186,7 @@ @item Common framework for module communication @item Easy debugging @item Easy module testing - at item Extendible + at item Extensible @item Optional authentication and encryption facility @item Usable to access external hardware @end itemize @@ -195,7 +195,7 @@ Design criteria: @itemize @bullet - at item Client server with back channel + at item Client/Server with back channel @item Use a mainly text based protocol @item Escape certain control characters @item Allow indefinite data length @@ -206,14 +206,15 @@ @item Subliminal channels are not an issue @end itemize + @node Implementation @chapter Implementation The implementation is line based with a maximum line size of 1000 -octets. The default IPC mechanism are Unix Domain Sockets. +octets. The default IPC mechanism is Unix Domain Sockets. On a connect request the server responds either with an okay or an -error status. For authentication check the server may send an Inquiry +error status. For authentication-check the server may send an Inquiry Response prior to the first Okay, and it may also issue Status messages. The server must check that the client is allowed to connect, this is done by requesting the credentials for the peer and @@ -243,8 +244,8 @@ Request was successful. @item ERR @var{errorcode} [] -Request could not be fulfilled. The error codes are mostly application -specific except for a few common ones. +Request could not be fulfilled. The possible error codes are defined +by @code{libgpg-error}. @item S @var{keyword} Informational output by the server, still processing the request. A @@ -310,27 +311,24 @@ Raw data to the server. There must be exactly one space after the 'D'. The values for '%', CR and LF must be percent escaped; this is encoded as %25, %0D and %0A. Only uppercase letters should be used in the -hexadecimal representation. Other characters may be percent escaped for -easier debugging. All these Data lines are considered one data stream -up to the OKAY or ERROR response. Status and Inquiry Responses may be -mixed with the Data lines. +hexadecimal representation. Other characters may be percent escaped +for easier debugging. All these Data lines are considered one data +stream up to the @code{OK} or @code{ERR} response. Status and Inquiry +Responses may be mixed with the Data lines. @example END @end example - - Lines beginning with a @code{#} or empty lines are ignored. This is useful to comment test scripts. - Although the commands are application specific, some of them are used by all protocols and partly directly supported by the Assuan library: @table @code @item BYE -Close the connect, the server will reply with an @code{OK}. +Close the connection. The server will reply with @code{OK}. @item RESET Reset the connection but not any existing authentication. The server @@ -358,11 +356,11 @@ but suggested if @var{value} is given. @item CANCEL -This command is reserved for future extensions. +This command is reserved for future extensions. @item AUTH This command is reserved for future extensions. Not yet specified as -we don't implement it in the first phase. See my mail to gpa-dev on +we don't implement it in the first phase. See Werner's mail to gpa-dev on 2001-10-25 about the rationale for measurements against local attacks. @item NOP @@ -373,12 +371,10 @@ @node Error codes @section Error codes -In general Libassuan should be used with gpg-error style error codes. -For compatibility reasons and for applications not wanting to use these -error codes, the old Assuan error codes may still be used. In fact they -are used by default. To switch to gpg-error style error codes, -applications should call the @ref{function assuan_set_assuan_err_source} -right after startup. +Libassuan is used with gpg-error style error codes. It is recommended +to set the error source to a different value than the default + at code{GPG_ERR_SOURCE_UNKNOWN} by calling @ref{function +assuan_set_assuan_err_source} early. @c @@ -387,7 +383,7 @@ @node Preparation @chapter Preparation -To use `@sc{libassuan}', you have to perform some changes to your +To use @sc{Assuan}, you have to perform some changes to your sources and the build system. The necessary changes are small and explained in the following sections. @@ -396,13 +392,13 @@ * Header:: What header file you need to include. * Building sources:: How to build sources using the library. * Automake:: How to build sources with the help of Automake. -* Multi Threading:: How @sc{libassuan} can be used in a MT environment. +* Multi Threading:: How @code{libassuan} can be used in a MT environment. @end menu @node Header @section Header -All interfaces (data types and functions) of @sc{libassuan} are defined +All interfaces (data types and functions) of @code{libassuan} are defined in the header file @file{assuan.h}. You must include this in all source files using the library, either directly or through some other header file, like this: @@ -411,11 +407,17 @@ #include @end example -The name space of `@sc{assuan}' is @code{assuan_*} for function +The name space of @code{libassuan} is @code{assuan_*} for function and type names and @code{ASSUAN*} for other symbols. In addition the same name prefixes with one prepended underscore are reserved for internal use and should never be used by an application. +Because @code{libassuan} makes use of the GPG Error library, using + at code{libassuan} will also use the @code{GPG_ERR_*} name space +directly, and the @code{gpg_err*} and @code{gpg_str*} name space +indirectly. + + @node Building sources @section Building sources @@ -447,9 +449,9 @@ search path (via the @option{-L} option). For this, the option @option{--libs} to @command{libassuan-config} can be used. For convenience, this option also outputs all other options that are -required to link the program with the @sc{libassuan} libraries (in +required to link the program with the @code{libassuan} libraries (in particular, the @option{-lassuan} option). The example shows how to -link @file{foo.o} with the @sc{libassuan} library to a program +link @file{foo.o} with the @code{libassuan} library to a program @command{foo}. @example @@ -473,18 +475,19 @@ It is much easier if you use GNU Automake instead of writing your own Makefiles. If you do that you do not have to worry about finding and -invoking the @command{libassuan-config} script at all. @sc{libassuan} +invoking the @command{libassuan-config} script at all. @code{libassuan} provides an Automake macro that does all the work for you. @defmac AM_PATH_LIBASSUAN (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found}) -Check whether @sc{libassuan} (at least version @var{minimum-version}, if -given) exists on the host system. If it is found, execute - at var{action-if-found}, otherwise do @var{action-if-not-found}, if given. +Check whether @code{libassuan} (at least version + at var{minimum-version}, if given) exists on the host system. If it is +found, execute @var{action-if-found}, otherwise do + at var{action-if-not-found}, if given. Additionally, the function defines @code{LIBASSUAN_CFLAGS} to the flags needed for compilation of the program to find the @file{assuan.h} header file, and @code{LIBASSUAN_LIBS} to the linker -flags needed to link the program to the @sc{libassuan} library. +flags needed to link the program to the @code{libassuan} library. @end defmac You can use the defined Autoconf variables like this in your @@ -522,7 +525,7 @@ @itemize @bullet @item Run the initialization functions before you actually start to use threads. - at item Only one thread at a time may access an @sc{libassuan} context. + at item Only one thread at a time may access an @code{libassuan} context. @item Use @code{assuan_set_assuan_log_stream} to setup a default log stream. @end itemize @@ -534,7 +537,7 @@ @chapter Generalities @menu -* Data Types:: Data types used by @sc{libassuan}. +* Data Types:: Data types used by @code{libassuan}. * Initializing the library:: How to initialize the library. * Reading and Writing:: How to communicate with the peer. @end menu @@ -544,25 +547,22 @@ @node Data Types @section Data Types used by the library - at sc{libassuan} uses a context approach to keep state. The following -data type is used all over the place: + at sc{Assuan} uses a context to keep the state for a connection. The +following data type is used ace: @deftp {Data type} assuan_context_t The @code{assuan_context_t} type is a pointer to an object maintained -internally by the library. Certain Assuan functions allocate such a -context and return it to the caller using this data type. Other +internally by the library. Certain @sc{Assuan} functions allocate +such a context and return it to the caller using this data type. Other functions take this data type to access the state created by these functions. @end deftp - at noindent -For compatibility with older versions of @sc{libassuan} a data -type for error return values exists: - at deftp {Data type} assuan_error_t -This has originally been an @code{enum} but applications should either -view it as an @code{int} or if possible use the @code{gpg_error_t} data -type as defined by the @sc{libgpg-error} package. + at deftp {Data type} assuan_fd_t +The @code{assuan_fd_t} is a file descriptor (in Unix) or a system +handle (in Windows). The special value @code{ASSUAN_INVALID_FD} is +used to specify invalid Assuan file descriptors. @end deftp @@ -575,13 +575,13 @@ application before a second thread is created. If your application uses its own memory allocation functions or wrappers -it is good idea to tell @sc{libassuan} about it so it can make use of the +it is good idea to tell @code{libassuan} about it so it can make use of the same functions or wrappers. You do this with @deftypefun void assuan_set_malloc_hooks (@w{void *(*@var{malloc_func})(size_t)}, @w{void *(*@var{realloc_func})(void *, size_t)}, @w{void (*@var{free_func})(void*)}) You need to provide all three functions. Those functions need to behave exactly as their standard counterparts (@code{malloc}, @code{realloc} -and @code{free}). If you write your own functions please take care to +and @code{free}). If you write your own functions, please take care to set @code{errno} whenever an error has occurred. @end deftypefun @@ -590,7 +590,7 @@ system, you may use the following two functions: @deftypefun void assuan_set_assuan_log_stream (FILE *@var{fp}) -This sets the stream to which @sc{libassuan} should log messages not +This sets the stream to which @code{libassuan} should log messages not associated with a specific context to @var{fp}. The default is to log to @code{stderr}. This default value is also changed by using @code{assuan_set_log_stream} (to set a logging stream for a specific @@ -604,17 +604,11 @@ on the log stream to @var{text}. The default is the empty string. @end deftypefun -If you intend to use @sc{libassuan} along with the package - at sc{libgpg-error} it is recommended to switch @sc{libassuan} into a mode -which directly makes use of error codes provided by @sc{libgpg-error}. -Because the Assuan error codes and those of gpg-error overlap, it is -required to explicitly request this. You do this by calling the function - @anchor{function assuan_set_assuan_err_source} @deftypefun void assuan_set_assuan_err_source (@w{int @var{errsource}}) -Enable gpg-error style error codes. @var{errsource} is one of the -gpg-error sources. Switching back to the old style mode is not -possible. The usual way to call this function is +Set the error source for error values generated by @code{libassuan}. + at var{errsource} is one of the @code{libgpg-error} sources. The usual +way to call this function is @smallexample assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); @end smallexample @@ -625,50 +619,52 @@ What would be an IPC library without the ability to read and write data? Not very useful. Libassuan has high level functions to take -care of of the more boring stuff but eventually data needs to be +care of of the more boring stuff, but eventually data needs to be written and read. @noindent The basic read and write functions are: - at deftypefun assuan_error_t assuan_read_line (@w{assuan_context_t @var{ctx}}, @w{char **@var{line}}, @w{size_t *@var{linelen}}) + at deftypefun gpg_error_t assuan_read_line (@w{assuan_context_t @var{ctx}}, @w{char **@var{line}}, @w{size_t *@var{linelen}}) -Read the next line from the client or server and store a pointer to the -buffer holding that line at the address @var{line}. The valid length of -the lines is stored at the address of @var{linelen}. This buffer is -valid until the next read operation on the same context @var{ctx}. You -may modify the context of this buffer. The buffer is invalid (i.e. must -not be used) if an error is returned. This function returns @code{0} on -success or an error code. +Read the next line written by the peer and store a pointer to the +buffer holding that line at the address @var{line}. The valid length +of the lines is stored at the address of @var{linelen}. This buffer +is valid until the next read operation on the same context @var{ctx}. +You may modify the context of this buffer. The buffer is invalid +(i.e. must not be used) if an error is returned. This function +returns @code{0} on success or an error value. @end deftypefun - at deftypefun assuan_error_t assuan_write_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}}) + at deftypefun gpg_error_t assuan_write_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}}) -Write the string @var{line} to the other end. This string needs to be a -proper formatted Assuan protocol line and should not include a linefeed. -Sending linefeed or Nul characters is not possible and not allowed by the -assuan protocol. This function shall not be used for sending data (D) -lines. This function returns @code{0} on success or an error code. +Write the string @var{line} to the other end. This string needs to be +a proper formatted Assuan protocol line and should not include a +linefeed. Sending linefeed or @code{Nul} characters is not possible +and not allowed by the assuan protocol. This function shall not be +used for sending data (@code{D}) lines. This function returns + at code{0} on success or an error value. @end deftypefun @noindent To actually send bulk data lines a specialized function is available: - at deftypefun assuan_error_t assuan_send_data (@w{assuan_context_t @var{ctx}}, @w{const void *@var{buffer}}, @w{size_t @var{length}}) + at deftypefun gpg_error_t assuan_send_data (@w{assuan_context_t @var{ctx}}, @w{const void *@var{buffer}}, @w{size_t @var{length}}) This function is used by a server or a client to send @var{length} bytes of bulk data in @var{buffer} to the other end. The data will be escaped as required by the Assuan protocol and -may get buffered until a line is full. To force sending the data out +may get buffered until a line is full. To flush any pending data, @var{buffer} may be passed as @code{NULL} and @var{length} be @code{0}. -When used by a client this flush operation does also send the -terminating @code{END} command to terminate the response on an -``INQUIRE'' response. Note that the function @code{assuan_transact} -takes care of sending this @code{END} itself. + at noindent +When used by a client, this flush operation does also send the + at code{END} command to terminate the response on an @command{INQUIRE} +request. Note that the function @code{assuan_transact} takes care of +sending this @code{END} itself. @noindent -This function returns @code{0} on success or an error code. +This function returns @code{0} on success or an error value. @end deftypefun @@ -683,29 +679,17 @@ Depending on the type of the server you want to connect you need to use different functions. -For a pipe based server you fork and exec yourself, you use: +If the peer is not a simple pipe server but one using full-duplex +sockets, the full-fledged variant of the above function should be +used: - at deftypefun assuan_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *const @var{argv}[]}, @w{int *@var{fd_child_list}}) + at deftypefun gpg_error_t assuan_pipe_connect_ext (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *const @var{argv}[]}, @w{int *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}}) A call to this functions forks the current process and executes the program @var{name}, passing the arguments given in the NULL-terminated list @var{argv}. A list of file descriptors not to be closed may be given using the @code{-1} terminated array @var{fd_child_list}. -On success a new assuan context is returned at @var{ctx}. - - at end deftypefun - -If it is not a simple pipe server but one using full-duplex sockets, the -full-fledged variant of the above function should be used: - - at deftypefun assuan_error_t assuan_pipe_connect_ext (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *const @var{argv}[]}, @w{int *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}}) - -A call to this functions forks the current process and executes the -program @var{name}, passing the arguments given in the NULL-terminated -list @var{argv}. A list of file descriptors not to be closed may be -given using the @code{-1} terminated array @var{fd_child_list}. - If @var{name} as well as @var{argv} are given as @code{NULL}, only a fork but no exec is done. Thus the child continues to run. However all file descriptors are closed and some special environment variables are @@ -722,7 +706,6 @@ @var{flags} is a bit vector and controls how the function acts: @table @code - @item bit 0 (value 1) If cleared a simple pipe based server is expected and the function behaves similar to @code{assuan_pipe_connect}. @@ -732,44 +715,54 @@ features only available with such servers. @item bit 7 (value 128) -If set and there is a need to start ther server it will be started as a +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 - @end table + at end deftypefun + +For a pipe-based server you can also use the following legacy function: + + at deftypefun gpg_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *const @var{argv}[]}, @w{int *@var{fd_child_list}}) + +A call to @code{assuan_pipe_connect} is equivalent to a call to + at code{assuan_pipe_connect_ext} with @code{flags} being 0 and without +an at-fork handler. @end deftypefun If you are using a long running server listening either on a TCP or a Unix domain socket, the following function is used to connect to the server: - at deftypefun assuan_error_t assuan_socket_connect_ext (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}, @w{unsigned int @var{flags}}) + at deftypefun gpg_error_t assuan_socket_connect_ext (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}, @w{unsigned int @var{flags}}) Make a connection to the Unix domain socket @var{name} and return a new Assuan context at @var{ctx}. @var{server_pid} is currently not used but may become handy in the future; if you don't know the -server's pid, pass @code{-1}. With @var{flags} set to @code{1}, - at code{sendmsg} and @code{recvmesg} are used for input and output and -thereby enabling the the use of descriptor passing. +server's process ID (PID), pass @code{-1}. With @var{flags} set to + at code{1}, @code{sendmsg} and @code{recvmesg} are used for input and +output and thereby enable the use of descriptor passing. Connecting to a TCP server is not yet implemented. Standard URL schemes are reserved for @var{name} specifying a TCP server. - @end deftypefun - at deftypefun assuan_error_t assuan_socket_connect (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}) + at deftypefun gpg_error_t assuan_socket_connect (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}) +A call to @code{assuan_socket_connect} is equivalent to a call to + at code{assuan_socket_connect_ext} with @code{flags} being 0. + Same as above but no way to specify flags. @end deftypefun -Finally, after using the Assuan connection, the resources should be +Eventually, after using the Assuan connection, the resources should be deallocated: @deftypefun void assuan_disconnect (@w{assuan_context_t @var{ctx}}) Close the connection described by the Assuan context @var{ctx} and release all resources. This function also tries to send the BYE command -to the server but won't fail on error. It is explicitly allowed to pass +to the server but won't fail on error. It is explicitly allowed to pass @code{NULL} for @var{ctx}, in which case the function does nothing. @end deftypefun @@ -777,10 +770,10 @@ conveniently done using a couple of callbacks and the transact function: - at deftypefun assuan_error_t assuan_transact (@w{assuan_context_t @var{ctx}}, @w{const char *@var{command}}, @w{assuan_error_t (*@var{data_cb})(void *, const void *, size_t)}, @w{void *@var{data_cb_arg}}, @w{assuan_error_t (*@var{inquire_cb})(void*, const char *)}, @w{void *@var{inquire_cb_arg}}, @w{assuan_error_t (*@var{status_cb})(void*, const char *)}, @w{void *@var{status_cb_arg}}) + at deftypefun gpg_error_t assuan_transact (@w{assuan_context_t @var{ctx}}, @w{const char *@var{command}}, @w{gpg_error_t (*@var{data_cb})(void *, const void *, size_t)}, @w{void *@var{data_cb_arg}}, @w{gpg_error_t (*@var{inquire_cb})(void*, const char *)}, @w{void *@var{inquire_cb_arg}}, @w{gpg_error_t (*@var{status_cb})(void*, const char *)}, @w{void *@var{status_cb_arg}}) Here @var{ctx} is the Assuan context opened by one of the connect -calls. @var{command} is the actual one liner Assuan command. It +calls. @var{command} is the actual Assuan command string. It shall not end with a line feed and its length is limited to @code{ASSUAN_LINELENGTH} (~1000 bytes) @@ -796,31 +789,31 @@ callback. @var{status_cb} is called by Libassuan for each status line it receives -from the server. @var{status_cb_arg} is passed along with the status +from the server. @var{status_cb_arg} is passed along with the status line to the callback. -The function returns @code{0} success or an error code. The error code +The function returns @code{0} success or an error value. The error value may be the one one returned by the server in error lines or one generated by the callback functions. - @end deftypefun Libassuan supports descriptor passing on some platforms. The next two functions are used with this feature: @anchor{function assuan_sendfd} - at deftypefun assuan_error_t assuan_sendfd (@w{assuan_context_t @var{ctx}}, @w{int @var{fd}}) + at deftypefun gpg_error_t assuan_sendfd (@w{assuan_context_t @var{ctx}}, @w{int @var{fd}}) Send the descriptor @var{fd} to the peer using the context @var{ctx}. -Note, that calling this function with a @var{ctx} of @code{NULL} and - at var{fd} of @code{-1} is a valid runtime test to check whether -descriptor passing is available on the platform. The descriptor must -be sent before the command is issued that makes use of the descriptor. +The descriptor must be sent before the command is issued that makes +use of the descriptor. +Note that calling this function with a @var{ctx} of @code{NULL} and + at var{fd} of @code{-1} can be used as a runtime test to check whether +descriptor passing is available on the platform. If it is, 0 is returned, otherwise an error with the error code @code{GPG_ERR_NOT_IMPLEMENTED}. @end deftypefun - at anchor{fun-assuan_receivedfd} - at deftypefun assuan_error_t assuan_receivefd (@w{assuan_context_t @var{ctx}}, @w{int *@var{fd}}) + at anchor{function assuan_receivefd} + at deftypefun gpg_error_t assuan_receivefd (@w{assuan_context_t @var{ctx}}, @w{int *@var{fd}}) Receive a descriptor pending for the context @var{ctx} from the peer. The descriptor must be pending before this function is called. To @@ -835,9 +828,9 @@ @node Server code @chapter How to develop an Assuan server -Implementing a server for Assuan is a bit more complex than a -client. However it is a straightforward task we are going to explain -using a commented example. +Implementing a server for Assuan is a bit more complex than a client. +However, it is a straightforward task we are going to explain using a +commented example. @noindent The list of the implemented server commands is defined by a table like: @@ -845,24 +838,25 @@ @smallexample static struct @{ const char *name; - int (*handler)(assuan_context_t, char *line); + int (*handler) (assuan_context_t, char *line); @} command_table[] = @{ - @{ "FOO", cmd_foo @}, - @{ "BAR", cmd_bar @}, - @{ "INPUT", NULL @}, - @{ "OUTPUT", NULL @}, - @{ NULL @}@}; + @{ "FOO", cmd_foo @}, + @{ "BAR", cmd_bar @}, + @{ "INPUT", NULL @}, + @{ "OUTPUT", NULL @}, + @{ NULL @}@}; @end smallexample For convenience this table is usually put after the actual command -handlers (cmd_foo, cmd_bar) or even put inside the command_handler. -Note that commands with the name ``INPUT'' and ``OUTPUT'' do not require -a handler because Libassuan provides a default handler for them. It is -however possible to assign a custom handler. +handlers (@code{cmd_foo}, @code{cmd_bar}) or even put inside + at code{command_handler} (see below). Note that the commands + at code{INPUT} and @code{OUTPUT} do not require a handler because +Libassuan provides a default handler for them. It is however possible +to assign a custom handler. A prerequisite for this example code is that a client has already connected to the server. Often there are two modes combined in one -program: A pipe based server, where a client has forked the server +program: A pipe-based server, where a client has forked the server process, or a Unix domain socket based server that is listening on the socket. @@ -885,7 +879,7 @@ rc = assuan_init_socket_server_ext (&ctx, fd, 2); if (rc) @{ - fprintf (stderr, "server init failed: %s\n", gpg_strerror(rc)); + fprintf (stderr, "server init failed: %s\n", gpg_strerror (rc)); return; @} @end example @@ -897,12 +891,12 @@ handles are connected to a pipe. The initialization is thus done using the function: - at deftypefun assuan_error_t assuan_init_pipe_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{filedes}[2]}) + at deftypefun gpg_error_t assuan_init_pipe_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{filedes}[2]}) The function takes the two file descriptors from @var{filedes} and returns a new Assuan context at @var{r_ctx}. As usual, a return value of @code{0} indicates success and a failure is indicated by a -returning an error code. In case of error, @code{NULL} will be stored +returning an error value. In case of error, @code{NULL} will be stored at @var{r_ctx}. In case the server has been called using a bi-directional pipe @@ -917,7 +911,7 @@ If a file descriptor has been passed, the assuan context gets initialized by the function: - at deftypefun assuan_error_t assuan_init_socket_server_ext (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}}) + at deftypefun gpg_error_t assuan_init_socket_server_ext (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}}) The function takes the file descriptor @var{fd} which is expected to be associated with a socket and returns a new Assuan context at @@ -934,7 +928,7 @@ @end table As usual, a return value of @code{0} indicates success and a failure -is indicated by a returning an error code. In case of error, +is indicated by a returning an error value. In case of error, @code{NULL} will be stored at @var{r_ctx}. @end deftypefun @@ -973,19 +967,20 @@ @end example - at deftypefun assuan_error_t assuan_register_command (@w{assuan_context_t @var{ctx}}, @w{const char *@var{cmd_string}}, @w{int (*@var{handler}) (assuan_context_t, char *)}) + at deftypefun gpg_error_t assuan_register_command (@w{assuan_context_t @var{ctx}}, @w{const char *@var{cmd_string}}, @w{int (*@var{handler}) (assuan_context_t, char *)}) This registers the command named @var{cmd_string} with the Assuan context @var{ctx}. @var{handler} is the function called by Libassuan if this command is received from the client. @var{NULL} may be used for @var{handler} to use a default handler (this only works with a few pre-defined commands). Note that several default handlers have -already been registered when the context has been created: ``NOP'', -``CANCEL'', ``OPTION'', ``BYE'', ``AUTH'', ``RESET'' and ``END''. It -is possible, but not recommended, to override these commands. +already been registered when the context has been created: @code{NOP}, + at code{CANCEL}, @code{OPTION}, @code{BYE}, @code{AUTH}, @code{RESET} +and @code{END}. It is possible, but not recommended, to override +these commands. @end deftypefun - at deftypefun assuan_error_t assuan_register_post_cmd_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}, @w{int @var{err}}) + at deftypefun gpg_error_t assuan_register_post_cmd_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}, @w{int @var{err}}) Register a function to be called right after a command has been processed. @var{err} is the result code from the last internal assuan @@ -993,25 +988,25 @@ command-related cleanup. @end deftypefun - at deftypefun assuan_error_t assuan_register_bye_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) + at deftypefun gpg_error_t assuan_register_bye_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) Register function @var{fnc} with context @var{ctx} to be called right -before the standard handler for the ``BYE'' command is being called. +before the standard handler for the @code{BYE} command is being called. @end deftypefun - at deftypefun assuan_error_t assuan_register_reset_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) + at deftypefun gpg_error_t assuan_register_reset_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) Register function @var{fnc} with context @var{ctx} to be called right -before the standard handler for the ``RESET'' command is being called. +before the standard handler for the @code{RESET} command is being called. @end deftypefun - at deftypefun assuan_error_t assuan_register_cancel_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) + at deftypefun gpg_error_t assuan_register_cancel_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) Register function @var{fnc} with context @var{ctx} to be called right -before the standard handler for the ``RESET'' command is being called. +before the standard handler for the @code{RESET} command is being called. @end deftypefun - at deftypefun assuan_error_t assuan_register_option_handler (@w{assuan_context_t @var{ctx}}, @w{int (*@var{fnc})(assuan_context_t, const char*, const char*)}) + at deftypefun gpg_error_t assuan_register_option_handler (@w{assuan_context_t @var{ctx}}, @w{int (*@var{fnc})(assuan_context_t, const char*, const char*)}) Register function @var{fnc} with context @var{ctx} for processing options. That function is being called with the context, the name and @@ -1023,29 +1018,29 @@ @end deftypefun - at deftypefun assuan_error_t assuan_register_input_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t, const char*)}) + at deftypefun gpg_error_t assuan_register_input_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t, const char*)}) Although the input function may be overridden with a custom handler, it is often more convenient to use the default handler and to know whether -an ``INPUT'' command has been seen and successfully parsed. The second +an @code{INPUT} command has been seen and successfully parsed. The second argument passed to that function is the entire line. Because that line has already been parsed when the function gets called, a file descriptor -set with the ``INPUT'' command may already be used. That file +set with the @code{INPUT} command may already be used. That file descriptor is available by calling @code{assuan_get_input_fd}. @end deftypefun - at deftypefun assuan_error_t assuan_register_output_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t, const char*)}) + at deftypefun gpg_error_t assuan_register_output_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t, const char*)}) Although the output function may be overridden with a custom handler, it is often more convenient to use the default handler and to know whether -an ``OUTPUT'' command has been seen and successfully parsed. The second +an @code{OUTPUT} command has been seen and successfully parsed. The second argument passed to that function is the entire line. Because that line has already been parsed when the function gets called, a file descriptor -set with the ``OUTPUT'' command may already be used. That file +set with the @code{OUTPUT} command may already be used. That file descriptor is available by calling @code{assuan_get_output_fd}. @end deftypefun - at deftypefun assuan_error_t assuan_set_hello_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}}) + at deftypefun gpg_error_t assuan_set_hello_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}}) This is not actually a register function but may be called also after registering commands. It changes the ``Hello'' line, sent by the @@ -1101,24 +1096,24 @@ connection the core of the server should loop over the accept and process calls. - at deftypefun assuan_error_t assuan_accept (@w{assuan_context_t @var{ctx}}) + at deftypefun gpg_error_t assuan_accept (@w{assuan_context_t @var{ctx}}) A call to this function cancel any existing connection and waits for a connection from a client (that might be skipped, depending on the type of the server). The initial handshake is performed which may include an initial authentication or encryption negotiation. On success @code{0} -is returned. An error code will be returned if the connection could for -some reason not be established. An error code of @code{-1} indicates +is returned. An error value will be returned if the connection could for +some reason not be established. An error code of @code{GPG_ERR_EOF} indicates the end of the connection. @end deftypefun - at deftypefun assuan_error_t assuan_process (@w{assuan_context_t @var{ctx}}) + at deftypefun gpg_error_t assuan_process (@w{assuan_context_t @var{ctx}}) This function is used to handle the Assuan protocol after a connection has been established using @code{assuan_accept}. It is the main protocol handler responsible for reading the client commands and calling the appropriate handlers. The function returns @code{0} on success or -an error code if something went seriously wrong. Error codes from the +an error value if something went seriously wrong. Error values from the individual command handlers, i.e. operational error, are not seen here. @end deftypefun @@ -1286,7 +1281,7 @@ readable, but Assuan does not check this. The function @code{assuan_process_next} returns 0 if it can not make -progress reliably, and it returns an end of file error code if the +progress reliably, and it returns an end of file error value if the client closed the connection. See below for more information on this function. @@ -1299,7 +1294,7 @@ When the command is finished, irregardless if this happens directly in the command handler or later, you must call @code{assuan_process_done} -with an appropriate error code (or 0 for success) to return an +with an appropriate error value (or 0 for success) to return an appropriate status line to the client. You can do this at the end of the command handler, for example by ending it with @code{return assuan_process_done (error_code);}. Another possibility is to invoke @@ -1319,24 +1314,24 @@ continuation could complete the command and eventually call @code{assuan_process_done}. -Cancellation is supported by returning an appropriate error code to +Cancellation is supported by returning an appropriate error value to the client with @code{assuan_process_done}. For long running operations, the server should send progress status messages to the client in regular intervals to notice when the client disconnects. - at deftypefun assuan_error_t assuan_process_next (@w{assuan_context_t @var{ctx}}) + at deftypefun gpg_error_t assuan_process_next (@w{assuan_context_t @var{ctx}}) This is the same as @code{assuan_process} but the caller has to provide the outer loop. He should loop as long as the return code is zero and stop otherwise; @code{-1} or @code{GPG_ERR_EOF} indicate a regular end. @end deftypefun - at deftypefun assuan_error_t assuan_inquire_ext (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{size_t @var{maxlen}}, @w{int (*@var{cb}) (void *cb_data, int rc, unsigned char *buffer, size_t buffer_len)}, @w{void *@var{cb_data}}) + at deftypefun gpg_error_t assuan_inquire_ext (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{size_t @var{maxlen}}, @w{int (*@var{cb}) (void *cb_data, int rc, unsigned char *buffer, size_t buffer_len)}, @w{void *@var{cb_data}}) This is similar to @code{assuan_inquire} but the caller has to provide the outer loop (using @code{assuan_process_next}). The caller should specify a continuation with @var{cb}, which receives @var{cb_data} as -its first argument, and the error code as well as the inquired data as +its first argument, and the error value as well as the inquired data as its remaining arguments. @end deftypefun @@ -1380,7 +1375,7 @@ - at deftypefun assuan_error_t assuan_write_status (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{const char *@var{text}}) + at deftypefun gpg_error_t assuan_write_status (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{const char *@var{text}}) This is a convenience function for a server to send a status line. You need to pass it the @var{keyword} and the content of the status line in @@ -1388,21 +1383,21 @@ @end deftypefun - at deftypefun assuan_error_t assuan_inquire (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{unsigned char **@var{r_buffer}}, @w{size_t *@var{r_length}}, @w{size_t @var{maxlen}}) + at deftypefun gpg_error_t assuan_inquire (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{unsigned char **@var{r_buffer}}, @w{size_t *@var{r_length}}, @w{size_t @var{maxlen}}) A server may use this function to inquire data from a client. It sends -an ``INQUIRE'' command back to the server and returns the response +an @code{INQUIRE} command back to the server and returns the response conveniently in a newly allocated buffer. You need to pass at least the server's context @var{ctx} and the @var{keyword} describing the requested data. All other parameters may be @code{NULL} or @code{0}, although this is rarely useful. On success the result is stored in a newly allocated buffer stored at - at var{r_buffer}. The length of the data is stored at @var{r_length}. If - at var{maxlen} has not been given as @code{0}, it describes an upper size -limited of the expected data. If the client returns too much data the -function fails and the error code @code{GPG_ERR_ASS_TOO_MUCH_DATA} will -be returned. + at var{r_buffer}. The length of the data is stored at @var{r_length}. +If @var{maxlen} has not been given as @code{0}, it describes an upper +size limited of the expected data. If the client returns too much +data the function fails and an error with the error code + at code{GPG_ERR_ASS_TOO_MUCH_DATA} will be returned. @end deftypefun @@ -1420,24 +1415,24 @@ @end deftypefun - at deftypefun assuan_error_t assuan_set_okay_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}}) + at deftypefun gpg_error_t assuan_set_okay_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}}) -Set the text used for the next ``OK'' response to @var{line}. This is +Set the text used for the next @code{OK} response to @var{line}. This is sometimes useful to send additional human readable information along with the OK line. The string is automatically reset at the end of the current handler. @end deftypefun - at deftypefun assuan_error_t assuan_command_parse_fd (@w{assuan_context_t @var{ctx}}, @w{char *@var{line}}, @w{int *@var{rfd}}) + at deftypefun gpg_error_t assuan_command_parse_fd (@w{assuan_context_t @var{ctx}}, @w{char *@var{line}}, @w{int *@var{rfd}}) -This is the core of the default ``INPUT'' and ``OUTPUT'' handler. It -may be used in custom commands as well to negotiate a file descriptor. -If @var{line} contains @code{FD=@var{n}}, it returns @var{n} in - at var{rfd} assuming a local file descriptor. If @var{line} contains -just @code{FD} it returns a file descriptor at @var{rfd}; this file -descriptor needs to have been sent by the client right before using - at code{assuan_sendfd}. +This is the core of the default @code{INPUT} and @code{OUTPUT} +handler. It may be used in custom commands as well to negotiate a +file descriptor. If @var{line} contains @code{FD=@var{n}}, it returns + at var{n} in @var{rfd} assuming a local file descriptor. If @var{line} +contains just @code{FD} it returns a file descriptor at @var{rfd}; +this file descriptor needs to have been sent by the client right +before using @code{assuan_sendfd}. On W32 systems the returned file descriptor is a system handle and not a libc low level I/O file descriptor. Thus applications need to use @@ -1448,28 +1443,28 @@ @deftypefun int assuan_get_input_fd (@w{assuan_context_t @var{ctx}}) -Return the file descriptor sent by the client using the last ``INPUT'' +Return the file descriptor sent by the client using the last @code{INPUT} command. Returns @code{-1} if no file descriptor is available. @end deftypefun @deftypefun int assuan_get_output_fd (@w{assuan_context_t @var{ctx}}) Return the file descriptor sent by the client using the last -``OUTPUT'' command. Returns @code{-1} if no file descriptor is + at code{OUTPUT} command. Returns @code{-1} if no file descriptor is available. @end deftypefun - at deftypefun assuan_error_t assuan_close_input_fd (@w{assuan_context_t @var{ctx}}) + at deftypefun gpg_error_t assuan_close_input_fd (@w{assuan_context_t @var{ctx}}) -Close the file descriptor set by the last ``INPUT'' command. This +Close the file descriptor set by the last @code{INPUT} command. This function has the advantage over a simple @code{close} that it can do some sanity checks and make sure that a following @code{assuan_get_input_fd} won't return an already closed descriptor. @end deftypefun - at deftypefun assuan_error_t assuan_close_output_fd (@w{assuan_context_t @var{ctx}}) + at deftypefun gpg_error_t assuan_close_output_fd (@w{assuan_context_t @var{ctx}}) -Close the file descriptor set by the last ``OUTPUT'' command. This +Close the file descriptor set by the last @code{OUTPUT} command. This function has the advantage over a simple @code{close} that it can do some sanity checks and make sure that a following @code{assuan_get_input_fd} won't return an already closed descriptor. @@ -1477,7 +1472,7 @@ @deftypefun int assuan_set_error (@w{assuan_context_t @var{ctx}}, @w{int @var{err}}, @w{const char *@var{text}}) -This is a helper to provide a more descriptive error text with ``ERR'' +This is a helper to provide a more descriptive error text with @code{ERR} lines. For this to work, the text needs to be stored in the context @var{ctx} while still being in the command handler. This function is commonly called this way @@ -1486,7 +1481,7 @@ @end smallexample The value @var{err} is passed through and thus the return value of the command handler in the example. The provided text further explains -that error code to humans. +that error to humans. @end deftypefun @@ -1518,16 +1513,7 @@ Return the value of @var{flag} in context @var{ctx}. @end deftypefun - at deftypefun @w{const char*} assuan_strerror (@w{assuan_error_t @var{err}}) -This function returns a textual representation of the given error code - at var{err}. If this is an unknown value, a string with the value is -returned. (Beware: it is hold in a static buffer). It is suggested that -gpg-error style error numbers should be used and thus - at code{gpg_strerror} be called. @xref{function -assuan_set_assuan_err_source}, on how to enable these error codes. - at end deftypefun - @deftypefun pid_t assuan_get_pid (@w{assuan_context_t @var{ctx}}) This function returns the pid of the connected connected peer. If that @@ -1535,12 +1521,12 @@ possible to learn the pid of the other process. For a pipe based server the client knows it instantly and a mechanism is in place to let the server learn it. For socket based servers the pid is only available on -systems providing the ``SO_PEERCRED'' socket option @footnote{to our +systems providing the @code{SO_PEERCRED} socket option @footnote{to our knowledge only the Linux kernel has this feature}. @end deftypefun - at deftypefun assuan_error_t assuan_get_peercred (@w{assuan_context_t @var{ctx}}, @w{pid_t *@var{pid}}, @w{uid_t *@var{uid}}, @w{gid_t *@var{pid}}) + at deftypefun gpg_error_t assuan_get_peercred (@w{assuan_context_t @var{ctx}}, @w{pid_t *@var{pid}}, @w{uid_t *@var{uid}}, @w{gid_t *@var{pid}}) Return user credentials of the peer. This will work only on certain systems and only when connected over a socket. If you are not From cvs at cvs.gnupg.org Tue Sep 1 19:19:45 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 01 Sep 2009 19:19:45 +0200 Subject: [svn] assuan - r301 - in trunk: doc src Message-ID: Author: marcus Date: 2009-09-01 19:19:45 +0200 (Tue, 01 Sep 2009) New Revision: 301 Modified: trunk/doc/ChangeLog trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan-inquire.c trunk/src/assuan-listen.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-pipe-server.c trunk/src/assuan-socket-server.c trunk/src/assuan-util.c trunk/src/assuan.h Log: doc/ 2009-09-01 Marcus Brinkmann * assuan.texi: (External I/O Loop Server): Document assuan_process_done. (assuan_register_post_cmd_notify): Change type of ERR from int to gpg_error_t. (assuan_set_error): Likewise. (assuan_register_option_handler): Change types in callback handler from int to gpg_error_t. (assuan_inquire_ext): Likewise. src/ 2009-09-01 Marcus Brinkmann * assuan.h: Change types in all functions from int to gpg_error_t where relevant. * assuan-listen.c (assuan_accept): Change type of RC from int to gpg_error_t. * assuan-pipe-server.c (accept_connection, finish_connection): Change return type to gpg_error_t. * assuan-socket-server.c (accept_connection_bottom) (accept_connection, finish_connection): Likewise. (assuan_init_connected_socket_server): Remove. * assuan-defs.h (struct assuan_context_s): Change return type of accept_handler and finish_handler to gpg_error_t. * assuan-pipe-connect.c (do_finish): Change to void. * assuan-inquire.c (_assuan_inquire_ext_cb): Change type of RC from int to gpg_error_t. * assuan-handler.c: Change return codes and RC variables from int to gpg_error_t where appropriate. * assuan-buffer.c (_assuan_read_line): Fix error code on EOF. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/doc/ChangeLog 2009-09-01 17:19:45 UTC (rev 301) @@ -1,3 +1,14 @@ +2009-09-01 Marcus Brinkmann + + * assuan.texi: (External I/O Loop Server): Document + assuan_process_done. + (assuan_register_post_cmd_notify): Change type of ERR from int to + gpg_error_t. + (assuan_set_error): Likewise. + (assuan_register_option_handler): Change types in callback handler + from int to gpg_error_t. + (assuan_inquire_ext): Likewise. + 2009-08-28 Marcus Brinkmann * assuan.texi: Update to API changes. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/ChangeLog 2009-09-01 17:19:45 UTC (rev 301) @@ -1,5 +1,23 @@ 2009-09-01 Marcus Brinkmann + * assuan.h: Change types in all functions from int to gpg_error_t + where relevant. + * assuan-listen.c (assuan_accept): Change type of RC from int to + gpg_error_t. + * assuan-pipe-server.c (accept_connection, finish_connection): + Change return type to gpg_error_t. + * assuan-socket-server.c (accept_connection_bottom) + (accept_connection, finish_connection): Likewise. + (assuan_init_connected_socket_server): Remove. + * assuan-defs.h (struct assuan_context_s): Change return type of + accept_handler and finish_handler to gpg_error_t. + * assuan-pipe-connect.c (do_finish): Change to void. + * assuan-inquire.c (_assuan_inquire_ext_cb): Change type of RC + from int to gpg_error_t. + * assuan-handler.c: Change return codes and RC variables from int + to gpg_error_t where appropriate. + * assuan-buffer.c (_assuan_read_line): Fix error code on EOF. + * assuan.h (ASSUAN_INT2FD, ASSUAN_FD2INT): Remove macros. * assuan-defs.h (DIMof): Remove macro. Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/doc/assuan.texi 2009-09-01 17:19:45 UTC (rev 301) @@ -864,7 +864,8 @@ void command_handler (int fd) @{ - int i, rc; + gpg_error_t rc; + int i; assuan_context_t ctx; if (fd == -1) @@ -980,7 +981,7 @@ these commands. @end deftypefun - at deftypefun gpg_error_t assuan_register_post_cmd_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}, @w{int @var{err}}) + at deftypefun gpg_error_t assuan_register_post_cmd_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}, @w{gpg_error_t @var{err}}) Register a function to be called right after a command has been processed. @var{err} is the result code from the last internal assuan @@ -1006,7 +1007,7 @@ before the standard handler for the @code{RESET} command is being called. @end deftypefun - at deftypefun gpg_error_t assuan_register_option_handler (@w{assuan_context_t @var{ctx}}, @w{int (*@var{fnc})(assuan_context_t, const char*, const char*)}) + at deftypefun gpg_error_t assuan_register_option_handler (@w{assuan_context_t @var{ctx}}, @w{gpg_error_t (*@var{fnc})(assuan_context_t, const char*, const char*)}) Register function @var{fnc} with context @var{ctx} for processing options. That function is being called with the context, the name and @@ -1326,8 +1327,12 @@ regular end. @end deftypefun - at deftypefun gpg_error_t assuan_inquire_ext (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{size_t @var{maxlen}}, @w{int (*@var{cb}) (void *cb_data, int rc, unsigned char *buffer, size_t buffer_len)}, @w{void *@var{cb_data}}) + at deftypefun gpg_error_t assuan_process_done (@w{assuan_context_t @var{ctx}}, @w{gpg_error_t @var{rc}}) +Finish a pending command and return the error code @var{rc} to the +client. + at end deftypefun + at deftypefun gpg_error_t assuan_inquire_ext (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{size_t @var{maxlen}}, @w{gpg_error_t (*@var{cb}) (void *cb_data, gpg_error_t rc, unsigned char *buffer, size_t buffer_len)}, @w{void *@var{cb_data}}) This is similar to @code{assuan_inquire} but the caller has to provide the outer loop (using @code{assuan_process_next}). The caller should specify a continuation with @var{cb}, which receives @var{cb_data} as @@ -1470,8 +1475,7 @@ @code{assuan_get_input_fd} won't return an already closed descriptor. @end deftypefun - at deftypefun int assuan_set_error (@w{assuan_context_t @var{ctx}}, @w{int @var{err}}, @w{const char *@var{text}}) - + at deftypefun gpg_error_t assuan_set_error (@w{assuan_context_t @var{ctx}}, @w{gpg_error_t @var{err}}, @w{const char *@var{text}}) This is a helper to provide a more descriptive error text with @code{ERR} lines. For this to work, the text needs to be stored in the context @var{ctx} while still being in the command handler. This function is Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-buffer.c 2009-09-01 17:19:45 UTC (rev 301) @@ -97,13 +97,13 @@ gpg_error_t _assuan_read_line (assuan_context_t ctx) { + gpg_error_t rc = 0; char *line = ctx->inbound.line; int nread, atticlen; - int rc; char *endp = 0; if (ctx->inbound.eof) - return _assuan_error (-1); + return _assuan_error (GPG_ERR_EOF); atticlen = ctx->inbound.attic.linelen; if (atticlen) @@ -113,15 +113,14 @@ endp = memchr (line, '\n', atticlen); if (endp) - /* Found another line in the attic. */ { - rc = 0; + /* Found another line in the attic. */ nread = atticlen; atticlen = 0; } else - /* There is pending data but not a full line. */ { + /* There is pending data but not a full line. */ assert (atticlen < LINELENGTH); rc = readline (ctx, line + atticlen, LINELENGTH - atticlen, &nread, &ctx->inbound.eof); @@ -336,21 +335,21 @@ assuan_write_line (assuan_context_t ctx, const char *line) { size_t len; - const char *s; + const char *str; - if (!ctx) + if (! ctx) return _assuan_error (GPG_ERR_ASS_INV_VALUE); /* Make sure that we never take a LF from the user - this might violate the protocol. */ - s = strchr (line, '\n'); - len = s? (s-line) : strlen (line); + str = strchr (line, '\n'); + len = str ? (str - line) : strlen (line); - if (ctx->log_fp && s) + if (ctx->log_fp && str) fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> " "[supplied line contained a LF - truncated]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), (int)ctx->inbound.fd); + (unsigned int) getpid (), (int) ctx->inbound.fd); return _assuan_write_line (ctx, NULL, line, len); } @@ -439,7 +438,7 @@ } ctx->outbound.data.linelen = linelen; - return (int)orig_size; + return (int) orig_size; } @@ -481,7 +480,7 @@ } *line++ = '\n'; linelen++; - if ( !(monitor_result & 2) + if (! (monitor_result & 2) && writen (ctx, ctx->outbound.data.line, linelen)) { ctx->outbound.data.error = gpg_err_code_from_syserror (); Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-defs.h 2009-09-01 17:19:45 UTC (rev 301) @@ -43,7 +43,7 @@ struct cmdtbl_s { const char *name; - int (*handler)(assuan_context_t, char *line); + gpg_error_t (*handler)(assuan_context_t, char *line); }; @@ -154,8 +154,8 @@ } uds; void (*deinit_handler)(assuan_context_t); - int (*accept_handler)(assuan_context_t); - int (*finish_handler)(assuan_context_t); + gpg_error_t (*accept_handler)(assuan_context_t); + gpg_error_t (*finish_handler)(assuan_context_t); struct cmdtbl_s *cmdtbl; size_t cmdtbl_used; /* used entries */ @@ -164,7 +164,7 @@ void (*bye_notify_fnc)(assuan_context_t); void (*reset_notify_fnc)(assuan_context_t); void (*cancel_notify_fnc)(assuan_context_t); - int (*option_handler_fnc)(assuan_context_t,const char*, const char*); + gpg_error_t (*option_handler_fnc)(assuan_context_t,const char*, const char*); void (*input_notify_fnc)(assuan_context_t, const char *); void (*output_notify_fnc)(assuan_context_t, const char *); @@ -190,7 +190,7 @@ }; /*-- assuan-pipe-server.c --*/ -int _assuan_new_context (assuan_context_t *r_ctx); +gpg_error_t _assuan_new_context (assuan_context_t *r_ctx); void _assuan_release_context (assuan_context_t ctx); /*-- assuan-uds.c --*/ @@ -200,7 +200,7 @@ /*-- assuan-handler.c --*/ -int _assuan_register_std_commands (assuan_context_t ctx); +gpg_error_t _assuan_register_std_commands (assuan_context_t ctx); /*-- assuan-buffer.c --*/ gpg_error_t _assuan_read_line (assuan_context_t ctx); @@ -216,7 +216,7 @@ /*-- assuan-error.c --*/ /*-- assuan-inquire.c --*/ -int _assuan_inquire_ext_cb (assuan_context_t ctx); +gpg_error_t _assuan_inquire_ext_cb (assuan_context_t ctx); void _assuan_inquire_release (assuan_context_t ctx); /* Check if ERR means EAGAIN. */ Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-handler.c 2009-09-01 17:19:45 UTC (rev 301) @@ -39,7 +39,7 @@ #define PROCESS_DONE(ctx, rc) \ ((ctx)->in_process_next ? assuan_process_done ((ctx), (rc)) : (rc)) -static int +static gpg_error_t dummy_handler (assuan_context_t ctx, char *line) { return @@ -48,13 +48,13 @@ } -static int +static gpg_error_t std_handler_nop (assuan_context_t ctx, char *line) { return PROCESS_DONE (ctx, 0); /* okay */ } -static int +static gpg_error_t std_handler_cancel (assuan_context_t ctx, char *line) { if (ctx->cancel_notify_fnc) @@ -62,7 +62,7 @@ return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL)); } -static int +static gpg_error_t std_handler_option (assuan_context_t ctx, char *line) { char *key, *value, *p; @@ -115,7 +115,7 @@ return PROCESS_DONE (ctx, 0); } -static int +static gpg_error_t std_handler_bye (assuan_context_t ctx, char *line) { if (ctx->bye_notify_fnc) @@ -126,13 +126,13 @@ return PROCESS_DONE (ctx, _assuan_error (GPG_ERR_EOF)); } -static int +static gpg_error_t std_handler_auth (assuan_context_t ctx, char *line) { return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL)); } -static int +static gpg_error_t std_handler_reset (assuan_context_t ctx, char *line) { if (ctx->reset_notify_fnc) @@ -143,7 +143,7 @@ return PROCESS_DONE (ctx, 0); } -static int +static gpg_error_t std_handler_help (assuan_context_t ctx, char *line) { unsigned int i; @@ -160,7 +160,7 @@ } -static int +static gpg_error_t std_handler_end (assuan_context_t ctx, char *line) { return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL)); @@ -204,10 +204,10 @@ /* Format is INPUT FD= */ -static int +static gpg_error_t std_handler_input (assuan_context_t ctx, char *line) { - int rc; + gpg_error_t rc; assuan_fd_t fd; rc = assuan_command_parse_fd (ctx, line, &fd); @@ -220,10 +220,10 @@ } /* Format is OUTPUT FD= */ -static int +static gpg_error_t std_handler_output (assuan_context_t ctx, char *line) { - int rc; + gpg_error_t rc; assuan_fd_t fd; rc = assuan_command_parse_fd (ctx, line, &fd); @@ -244,7 +244,7 @@ with default handlers */ static struct { const char *name; - int (*handler)(assuan_context_t, char *line); + gpg_error_t (*handler)(assuan_context_t, char *line); int always; /* always initialize this command */ } std_cmd_table[] = { { "NOP", std_handler_nop, 1 }, @@ -275,10 +275,10 @@ * * Return value: 0 on success or an error code **/ -int +gpg_error_t assuan_register_command (assuan_context_t ctx, const char *cmd_name, - int (*handler)(assuan_context_t, char *)) + gpg_error_t (*handler)(assuan_context_t, char *)) { int i; const char *s; @@ -330,9 +330,9 @@ return 0; } -int +gpg_error_t assuan_register_post_cmd_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, int)) + void (*fnc)(assuan_context_t, gpg_error_t)) { if (!ctx) return _assuan_error (GPG_ERR_ASS_INV_VALUE); @@ -340,7 +340,7 @@ return 0; } -int +gpg_error_t assuan_register_bye_notify (assuan_context_t ctx, void (*fnc)(assuan_context_t)) { @@ -350,7 +350,7 @@ return 0; } -int +gpg_error_t assuan_register_reset_notify (assuan_context_t ctx, void (*fnc)(assuan_context_t)) { @@ -360,7 +360,7 @@ return 0; } -int +gpg_error_t assuan_register_cancel_notify (assuan_context_t ctx, void (*fnc)(assuan_context_t)) { @@ -370,10 +370,10 @@ return 0; } -int +gpg_error_t assuan_register_option_handler (assuan_context_t ctx, - int (*fnc)(assuan_context_t, - const char*, const char*)) + gpg_error_t (*fnc)(assuan_context_t, + const char*, const char*)) { if (!ctx) return _assuan_error (GPG_ERR_ASS_INV_VALUE); @@ -381,7 +381,7 @@ return 0; } -int +gpg_error_t assuan_register_input_notify (assuan_context_t ctx, void (*fnc)(assuan_context_t, const char *)) { @@ -391,7 +391,7 @@ return 0; } -int +gpg_error_t assuan_register_output_notify (assuan_context_t ctx, void (*fnc)(assuan_context_t, const char *)) { @@ -403,12 +403,13 @@ /* Helper to register the standards commands */ -int +gpg_error_t _assuan_register_std_commands (assuan_context_t ctx) { - int i, rc; + gpg_error_t rc; + int i; - for (i=0; std_cmd_table[i].name; i++) + for (i = 0; std_cmd_table[i].name; i++) { if (std_cmd_table[i].always) { @@ -424,7 +425,7 @@ /* Process the special data lines. The "D " has already been removed from the line. As all handlers this function may modify the line. */ -static int +static gpg_error_t handle_data_line (assuan_context_t ctx, char *line, int linelen) { return set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL); @@ -449,7 +450,7 @@ /* Parse the line, break out the command, find it in the command table, remove leading and white spaces from the arguments, call the handler with the argument line and return the error. */ -static int +static gpg_error_t dispatch_command (assuan_context_t ctx, char *line, int linelen) { char *p; @@ -503,8 +504,8 @@ /* Call this to acknowledge the current command. */ -int -assuan_process_done (assuan_context_t ctx, int rc) +gpg_error_t +assuan_process_done (assuan_context_t ctx, gpg_error_t rc) { if (!ctx->in_command) return _assuan_error (GPG_ERR_ASS_GENERAL); @@ -567,10 +568,10 @@ } -static int +static gpg_error_t process_next (assuan_context_t ctx) { - int rc; + gpg_error_t rc; /* What the next thing to do is depends on the current state. However, we will always first read the next line. The client is @@ -626,10 +627,10 @@ should be invoked the next time the connected FD is readable. Eventually, the caller will finish by invoking assuan_process_done. */ -int +gpg_error_t assuan_process_next (assuan_context_t ctx) { - int rc; + gpg_error_t rc; do { @@ -645,7 +646,7 @@ static gpg_error_t process_request (assuan_context_t ctx) { - int rc; + gpg_error_t rc; if (ctx->in_inquire) return _assuan_error (GPG_ERR_ASS_NESTED_COMMANDS); @@ -683,7 +684,7 @@ gpg_error_t assuan_process (assuan_context_t ctx) { - int rc; + gpg_error_t rc; do { rc = process_request (ctx); Modified: trunk/src/assuan-inquire.c =================================================================== --- trunk/src/assuan-inquire.c 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-inquire.c 2009-09-01 17:19:45 UTC (rev 301) @@ -253,10 +253,10 @@ } -int +gpg_error_t _assuan_inquire_ext_cb (assuan_context_t ctx) { - int rc; + gpg_error_t rc; unsigned char *line; int linelen; struct membuf *mb; @@ -350,8 +350,8 @@ **/ gpg_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword, size_t maxlen, - int (*cb) (void *cb_data, int rc, unsigned char *buf, - size_t len), + gpg_error_t (*cb) (void *cb_data, gpg_error_t rc, + unsigned char *buf, size_t len), void *cb_data) { gpg_error_t rc; Modified: trunk/src/assuan-listen.c =================================================================== --- trunk/src/assuan-listen.c 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-listen.c 2009-09-01 17:19:45 UTC (rev 301) @@ -72,7 +72,7 @@ gpg_error_t assuan_accept (assuan_context_t ctx) { - int rc; + gpg_error_t rc; const char *p, *pend; if (!ctx) Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-pipe-connect.c 2009-09-01 17:19:45 UTC (rev 301) @@ -106,7 +106,7 @@ } #endif -static int +static void do_finish (assuan_context_t ctx) { if (ctx->inbound.fd != ASSUAN_INVALID_FD) @@ -134,7 +134,6 @@ ctx->pid = (pid_t) INVALID_HANDLE_VALUE; #endif /*HAVE_W32_SYSTEM*/ } - return 0; } Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-pipe-server.c 2009-09-01 17:19:45 UTC (rev 301) @@ -40,14 +40,14 @@ /* nothing to do for this simple server */ } -static int +static gpg_error_t accept_connection (assuan_context_t ctx) { /* This is a NOP for a pipe server */ return 0; } -static int +static gpg_error_t finish_connection (assuan_context_t ctx) { /* This is a NOP for a pipe server */ @@ -56,7 +56,7 @@ /* Create a new context. Note that the handlers are set up for a pipe server/client - this way we don't need extra dummy functions */ -int +gpg_error_t _assuan_new_context (assuan_context_t *r_ctx) { static struct assuan_io io = { _assuan_simple_read, @@ -64,7 +64,7 @@ 0, 0 }; assuan_context_t ctx; - int rc; + gpg_error_t rc; *r_ctx = NULL; ctx = _assuan_calloc (1, sizeof *ctx); @@ -106,7 +106,7 @@ #endif /*!HAVE_W32_SYSTEM*/ -int +gpg_error_t assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]) { int rc; Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-socket-server.c 2009-09-01 17:19:45 UTC (rev 301) @@ -44,7 +44,7 @@ static struct assuan_io io = { _assuan_simple_read, _assuan_simple_write, NULL, NULL }; -static int +static gpg_error_t accept_connection_bottom (assuan_context_t ctx) { assuan_fd_t fd = ctx->connected_fd; @@ -86,7 +86,7 @@ } -static int +static gpg_error_t accept_connection (assuan_context_t ctx) { assuan_fd_t fd; @@ -109,7 +109,7 @@ return accept_connection_bottom (ctx); } -static int +static gpg_error_t finish_connection (assuan_context_t ctx) { if (ctx->inbound.fd != ASSUAN_INVALID_FD) @@ -130,26 +130,18 @@ /* Initialize a server for the socket LISTEN_FD which has already be put into listen mode */ -int +gpg_error_t assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd) { return assuan_init_socket_server_ext (r_ctx, listen_fd, 0); } -/* Initialize a server using the already accepted socket FD. This - function is deprecated. */ -int -assuan_init_connected_socket_server (assuan_context_t *r_ctx, assuan_fd_t fd) -{ - return assuan_init_socket_server_ext (r_ctx, fd, 2); -} - /* Flag bits: 0 - use sendmsg/recvmsg to allow descriptor passing 1 - FD has already been accepted. */ -int +gpg_error_t assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd, unsigned int flags) { Modified: trunk/src/assuan-util.c =================================================================== --- trunk/src/assuan-util.c 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan-util.c 2009-09-01 17:19:45 UTC (rev 301) @@ -102,8 +102,8 @@ /* Store the error in the context so that the error sending function can take out a descriptive text. Inside the assuan code, use the macro set_error instead of this function. */ -int -assuan_set_error (assuan_context_t ctx, int err, const char *text) +gpg_error_t +assuan_set_error (assuan_context_t ctx, gpg_error_t err, const char *text) { ctx->err_no = err; ctx->err_str = text; Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-09-01 14:42:54 UTC (rev 300) +++ trunk/src/assuan.h 2009-09-01 17:19:45 UTC (rev 301) @@ -293,29 +293,29 @@ /*-- assuan-handler.c --*/ -int assuan_register_command (assuan_context_t ctx, - const char *cmd_string, - int (*handler)(assuan_context_t, char *)); -int assuan_register_post_cmd_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, int)); -int assuan_register_bye_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_reset_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_cancel_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_input_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)); -int assuan_register_output_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)); +gpg_error_t assuan_register_command (assuan_context_t ctx, + const char *cmd_string, + gpg_error_t (*handler)(assuan_context_t, char *)); +gpg_error_t assuan_register_post_cmd_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t, gpg_error_t)); +gpg_error_t assuan_register_bye_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)); +gpg_error_t assuan_register_reset_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)); +gpg_error_t assuan_register_cancel_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)); +gpg_error_t assuan_register_input_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t, const char *)); +gpg_error_t assuan_register_output_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t, const char *)); -int assuan_register_option_handler (assuan_context_t ctx, - int (*fnc)(assuan_context_t, - const char*, const char*)); +gpg_error_t assuan_register_option_handler (assuan_context_t ctx, + gpg_error_t (*fnc)(assuan_context_t, + const char*, const char*)); gpg_error_t assuan_process (assuan_context_t ctx); -int assuan_process_next (assuan_context_t ctx); -int assuan_process_done (assuan_context_t ctx, int rc); +gpg_error_t assuan_process_next (assuan_context_t ctx); +gpg_error_t assuan_process_done (assuan_context_t ctx, gpg_error_t rc); int assuan_get_active_fds (assuan_context_t ctx, int what, assuan_fd_t *fdarray, int fdarraysize); @@ -344,36 +344,38 @@ /*-- assuan-pipe-server.c --*/ -int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]); +gpg_error_t assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]); void assuan_deinit_server (assuan_context_t ctx); /*-- assuan-socket-server.c --*/ -int assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd); -int assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd, - unsigned int flags); +gpg_error_t assuan_init_socket_server (assuan_context_t *r_ctx, + assuan_fd_t listen_fd); +gpg_error_t assuan_init_socket_server_ext (assuan_context_t *r_ctx, + assuan_fd_t fd, + unsigned int flags); void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce); /*-- assuan-pipe-connect.c --*/ gpg_error_t assuan_pipe_connect (assuan_context_t *ctx, - const char *name, - const char *const argv[], - int *fd_child_list); + const char *name, + const char *const argv[], + int *fd_child_list); gpg_error_t assuan_pipe_connect_ext (assuan_context_t *ctx, - const char *name, - const char *const argv[], - int *fd_child_list, - void (*atfork) (void *, int), - void *atforkvalue, - unsigned int flags); + const char *name, + const char *const argv[], + int *fd_child_list, + void (*atfork) (void *, int), + void *atforkvalue, + unsigned int flags); /*-- assuan-socket-connect.c --*/ gpg_error_t assuan_socket_connect (assuan_context_t *ctx, - const char *name, - pid_t server_pid); + const char *name, + pid_t server_pid); gpg_error_t assuan_socket_connect_ext (assuan_context_t *ctx, - const char *name, - pid_t server_pid, - unsigned int flags); + const char *name, + pid_t server_pid, + unsigned int flags); /*-- assuan-connect.c --*/ void assuan_disconnect (assuan_context_t ctx); @@ -401,9 +403,10 @@ size_t maxlen); gpg_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword, size_t maxlen, - int (*cb) (void *cb_data, int rc, - unsigned char *buf, - size_t buf_len), + gpg_error_t (*cb) (void *cb_data, + gpg_error_t rc, + unsigned char *buf, + size_t buf_len), void *cb_data); /*-- assuan-buffer.c --*/ gpg_error_t assuan_read_line (assuan_context_t ctx, @@ -426,7 +429,7 @@ void (*new_free_func)(void*) ); void assuan_set_io_hooks (assuan_io_hooks_t io_hooks); void assuan_set_log_stream (assuan_context_t ctx, FILE *fp); -int assuan_set_error (assuan_context_t ctx, int err, const char *text); +gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err, const char *text); void assuan_set_pointer (assuan_context_t ctx, void *pointer); void *assuan_get_pointer (assuan_context_t ctx); @@ -445,7 +448,7 @@ void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value); /* Return the VALUE of FLAG in context CTX. */ -int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag); +int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag); /*-- assuan-errors.c --*/ From cvs at cvs.gnupg.org Wed Sep 2 17:02:05 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 02 Sep 2009 17:02:05 +0200 Subject: [svn] GnuPG - r5135 - in branches/STABLE-BRANCH-1-4: . doc g10 po Message-ID: Author: wk Date: 2009-09-02 17:02:01 +0200 (Wed, 02 Sep 2009) New Revision: 5135 Modified: branches/STABLE-BRANCH-1-4/ChangeLog branches/STABLE-BRANCH-1-4/NEWS branches/STABLE-BRANCH-1-4/README branches/STABLE-BRANCH-1-4/configure.ac branches/STABLE-BRANCH-1-4/doc/ChangeLog branches/STABLE-BRANCH-1-4/doc/gpg.texi branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/compress-bz2.c branches/STABLE-BRANCH-1-4/g10/compress.c branches/STABLE-BRANCH-1-4/po/be.po branches/STABLE-BRANCH-1-4/po/ca.po branches/STABLE-BRANCH-1-4/po/cs.po branches/STABLE-BRANCH-1-4/po/da.po branches/STABLE-BRANCH-1-4/po/de.po branches/STABLE-BRANCH-1-4/po/el.po branches/STABLE-BRANCH-1-4/po/eo.po branches/STABLE-BRANCH-1-4/po/es.po branches/STABLE-BRANCH-1-4/po/et.po branches/STABLE-BRANCH-1-4/po/fi.po branches/STABLE-BRANCH-1-4/po/fr.po branches/STABLE-BRANCH-1-4/po/gl.po branches/STABLE-BRANCH-1-4/po/hu.po branches/STABLE-BRANCH-1-4/po/id.po branches/STABLE-BRANCH-1-4/po/it.po branches/STABLE-BRANCH-1-4/po/ja.po branches/STABLE-BRANCH-1-4/po/nb.po branches/STABLE-BRANCH-1-4/po/nl.po branches/STABLE-BRANCH-1-4/po/pl.po branches/STABLE-BRANCH-1-4/po/pt.po branches/STABLE-BRANCH-1-4/po/pt_BR.po branches/STABLE-BRANCH-1-4/po/ro.po branches/STABLE-BRANCH-1-4/po/ru.po branches/STABLE-BRANCH-1-4/po/sk.po branches/STABLE-BRANCH-1-4/po/sv.po branches/STABLE-BRANCH-1-4/po/tr.po branches/STABLE-BRANCH-1-4/po/zh_CN.po branches/STABLE-BRANCH-1-4/po/zh_TW.po Log: Preparing 1.4.10. Modified: branches/STABLE-BRANCH-1-4/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/ChangeLog 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/ChangeLog 2009-09-02 15:02:01 UTC (rev 5135) @@ -1,3 +1,11 @@ +2009-09-02 Werner Koch + + Release 1.4.10. + + * configure.ac (AC_RG_ENABLE): Don't disable try_gettext in + --enable-minimal. + * README <--enable-minimal>: Mention --disable-nls. + 2009-08-13 Werner Koch Release 1.4.10rc1. Modified: branches/STABLE-BRANCH-1-4/doc/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/doc/ChangeLog 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/doc/ChangeLog 2009-09-02 15:02:01 UTC (rev 5135) @@ -1,3 +1,7 @@ +2009-09-02 Werner Koch + + * gpgv.texi, gpg.texi: Update from GnuPG-2. + 2009-08-18 Werner Koch * Makefile.am (sources_from_trunk): New. @@ -40,7 +44,7 @@ * gpg.texi: Updated from gnupg-2. * gpl.texi: Replace by GPLv3 version. - + * Makefile.am: Use standard suffix rules. 2006-12-04 Werner Koch @@ -212,7 +216,7 @@ Corp. * gpg.ru.sgml: Updated from upstream. Added a closing PARA. - + * gpg.sgml: Add bkuptocard command for --edit-key. 2005-02-05 David Shaw @@ -792,7 +796,7 @@ 2002-06-03 Timo Schulz * DETAILS: Add ATTRIBUTE. - + 2002-05-31 David Shaw * gpg.sgml: Add "edit/addrevoker". Document --desig-revoke. Note @@ -831,7 +835,7 @@ 2002-04-30 Timo Schulz * gpg.sgml: Add an entry for --encrypt-files and --decrypt-files. - + 2002-04-29 David Shaw * gpg.sgml: Fix minor error in --pgp6 documentation: it does not @@ -870,7 +874,7 @@ SIGEXPIRED (deprecated), and VALIDSIG (added expiration date). Add "Preferences" command to unattended key generation instructions. Also fixed a few typos. - + * samplekeys.asc: new (added to EXTRA_DIST in Makefile.am as well) 2002-01-31 Marcus Brinkmann @@ -882,7 +886,7 @@ * gpg.sgml: auto-key-retrieve is a keyserver-option (noted by Roger Sondermann). - + 2002-03-27 David Shaw * gpg.sgml: --pgp2 also means --disable-mdc, --no-ask-sig-expire, @@ -912,7 +916,7 @@ 2002-01-26 Timo Schulz * gnupg-w32.reg: New. Registry file for W32 in registry format. - + 2002-01-26 Werner Koch * gpg.sgml: A few words about --gpg-agent-info and GPG_AGENT_INFO. @@ -921,7 +925,7 @@ * README.W32: Modify the filename because now the .exe extension is automatically added to the binary. - + 2002-01-14 Werner Koch * gpg.sgml: Talk about PGP 5 and higher. @@ -1147,7 +1151,7 @@ * DETAILS: Ditto. - Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001, 2009 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: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2009-09-02 15:02:01 UTC (rev 5135) @@ -1,3 +1,8 @@ +2009-09-02 Werner Koch + + * compress-bz2.c (do_uncompress): Detect unexpected EOF. Fixes + bug#1011. + 2009-08-26 Werner Koch * keyedit.c (menu_revsig): Check for signature right away. Fix Modified: branches/STABLE-BRANCH-1-4/NEWS =================================================================== --- branches/STABLE-BRANCH-1-4/NEWS 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/NEWS 2009-09-02 15:02:01 UTC (rev 5135) @@ -1,4 +1,4 @@ -Noteworthy changes in version 1.4.10 (unreleased) +Noteworthy changes in version 1.4.10 (2009-09-02) ------------------------------------------------- * 2048 bit RSA keys are now generated by default. The default Modified: branches/STABLE-BRANCH-1-4/README =================================================================== --- branches/STABLE-BRANCH-1-4/README 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/README 2009-09-02 15:02:01 UTC (rev 5135) @@ -37,10 +37,9 @@ Because GnuPG does not use use any patented algorithms it is not by default fully compatible with PGP 2.x, which uses the patented IDEA algorithm. See http://www.gnupg.org/why-not-idea.html for - more information on this subject, including what to do if you are - legally entitled to use IDEA. + more information on this subject. - The default public key algorithms are DSA and Elgamal, but RSA is + The default public key algorithm is RSA, but DSA and Elgamal are also supported. Symmetric algorithms available are AES (with 128, 192, and 256 bit keys), 3DES, Blowfish, CAST5 and Twofish. Digest algorithms available are MD5, RIPEMD/160, SHA-1, SHA-256, SHA-384, @@ -73,7 +72,9 @@ 8) To avoid swapping out of sensitive data, you can install "gpg" setuid root. If you don't do so, you may want to add the - option "no-secmem-warning" to ~/.gnupg/gpg.conf + option "no-secmem-warning" to ~/.gnupg/gpg.conf. Note that on + modern GNU/Linux systems swapping protection does not anymore + require GPG to be installed setuid root. How to Verify the Source @@ -601,7 +602,8 @@ right, so if you want to have an "almost minimal" configuration, you can do (for example) "--enable-minimal --enable-rsa" to have RSA added - to the minimal build. + to the minimal build. Adding the option + --disable-nls may be useful too. --enable-key-cache=SIZE Set the internal key and UID cache size. This has Modified: branches/STABLE-BRANCH-1-4/configure.ac =================================================================== --- branches/STABLE-BRANCH-1-4/configure.ac 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/configure.ac 2009-09-02 15:02:01 UTC (rev 5135) @@ -25,7 +25,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 --force" right before creating a distribution. -m4_define([my_version], [1.4.10rc1]) +m4_define([my_version], [1.4.10]) m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \ | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) @@ -150,7 +150,6 @@ AC_ARG_ENABLE(minimal, AC_HELP_STRING([--enable-minimal],[build the smallest gpg binary possible]), - try_gettext=no try_dns=no use_rsa=no use_idea=no Modified: branches/STABLE-BRANCH-1-4/doc/gpg.texi =================================================================== --- branches/STABLE-BRANCH-1-4/doc/gpg.texi 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/doc/gpg.texi 2009-09-02 15:02:01 UTC (rev 5135) @@ -589,6 +589,16 @@ @c ******** Begin Edit-key Options ********** @table @asis + at item uid @code{n} + at opindex keyedit:uid +Toggle selection of user ID or photographic user ID with index @code{n}. +Use 0 to deselect all. + + at item key @code{n} + at opindex keyedit:key +Toggle selection of subkey with index @code{n}. +Use 0 to deselect all. + @item sign @opindex keyedit:sign Make a signature on key of user @code{name} If the key is not yet @@ -625,107 +635,48 @@ @table @asis + at item delsig + at opindex keyedit:delsig +Delete a signature. Note that it is not possible to retract a signature, +once it has been send to the public (i.e. to a keyserver). In that case +you better use @code{revsig}. + @item revsig @opindex keyedit:revsig Revoke a signature. For every signature which has been generated by one of the secret keys, GnuPG asks whether a revocation certificate should be generated. - at item trust - at opindex keyedit:trust -Change the owner trust value. This updates the -trust-db immediately and no save is required. + at item check + at opindex keyedit:check +Check the signatures on all selected user IDs. - at item disable - at itemx enable - at opindex keyedit:disable - at opindex keyedit:enable -Disable or enable an entire key. A disabled key can not normally be -used for encryption. - @item adduid @opindex keyedit:adduid -Create an alternate user id. +Create an additional user ID. @item addphoto @opindex keyedit:addphoto -Create a photographic user id. This will prompt for a JPEG file that +Create a photographic user ID. This will prompt for a JPEG file that will be embedded into the user ID. Note that a very large JPEG will make for a very large key. Also note that some programs will display your JPEG unchanged (GnuPG), and some programs will scale it to fit in a dialog box (PGP). + at item showphoto + at opindex keyedit:showphoto +Display the selected photographic user ID. + @item deluid @opindex keyedit:deluid -Delete a user id. Note that it is not possible to retract a user id, -once it has been send to the public (i.e. to a keyserver). In that case -you better use @code{revuid}. +Delete a user ID or photographic user ID. Note that it is not +possible to retract a user id, once it has been send to the public +(i.e. to a keyserver). In that case you better use @code{revuid}. - at item delsig - at opindex keyedit:delsig -Delete a signature. Note that it is not possible to retract a signature, -once it has been send to the public (i.e. to a keyserver). In that case -you better use @code{revsig}. - @item revuid @opindex keyedit:revuid -Revoke a user id. +Revoke a user ID or photographic user ID. - at item addkey - at opindex keyedit:addkey -Add a subkey to this key. - - at item addcardkey - at opindex keyedit:addcardkey -Generate a key on a card and add it to this key. - - at item keytocard - at opindex keyedit:keytocard -Transfer the selected secret key (or the primary key if no key has been -selected) to a smartcard. The secret key in the keyring will be replaced -by a stub if the key could be stored successfully on the card and you -use the save command later. Only certain key types may be transferred to -the card. A sub menu allows you to select on what card to store the -key. Note that it is not possible to get that key back from the card - -if the card gets broken your secret key will be lost unless you have a -backup somewhere. - - at item bkuptocard @code{file} - at opindex keyedit:bkuptocard -Restore the given file to a card. This command may be used to restore a -backup key (as generated during card initialization) to a new card. In -almost all cases this will be the encryption key. You should use this -command only with the corresponding public key and make sure that the -file given as argument is indeed the backup to restore. You should then -select 2 to restore as encryption key. You will first be asked to enter -the passphrase of the backup key and then for the Admin PIN of the card. - - at item delkey - at opindex keyedit:delkey -Remove a subkey (secondart key). Note that it is not possible to retract -a subkey, once it has been send to the public (i.e. to a keyserver). In -that case you better use @code{revkey}. - - at item addrevoker - at opindex keyedit:addrevoker -Add a designated revoker. This takes one optional argument: -"sensitive". If a designated revoker is marked as sensitive, it will not -be exported by default (see export-options). - - at item revkey - at opindex keyedit:revkey -Revoke a subkey. - - at item expire - at opindex keyedit:expire -Change the key expiration time. If a subkey is selected, the -expiration time of this subkey will be changed. With no selection, -the key expiration of the primary key is changed. - - at item passwd - at opindex keyedit:passwd -Change the passphrase of the secret key. - @item primary @opindex keyedit:primary Flag the current user id as the primary one, removes the primary user @@ -735,25 +686,22 @@ regular user ID as primary makes it primary over other regular user IDs. - at item uid @code{n} - at opindex keyedit:uid -Toggle selection of user id with index @code{n}. -Use 0 to deselect all. + at item keyserver + at opindex keyedit:keyserver +Set a preferred keyserver for the specified user ID(s). This allows +other users to know where you prefer they get your key from. See + at option{--keyserver-options honor-keyserver-url} for more on how this +works. Setting a value of "none" removes an existing preferred +keyserver. - at item key @code{n} - at opindex keyedit:key -Toggle selection of subkey with index @code{n}. -Use 0 to deselect all. + at item notation + at opindex keyedit:notation +Set a name=value notation for the specified user ID(s). See + at option{--cert-notation} for more on how this works. Setting a value of +"none" removes all notations, setting a notation prefixed with a minus +sign (-) removes that notation, and setting a notation name (without the +=value) prefixed with a minus sign removes all notations with that name. - at item check - at opindex keyedit:check -Check all selected user ids. - - at item showphoto - at opindex keyedit:showphoto -Display the selected photographic user -id. - @item pref @opindex keyedit:pref List preferences from the selected user ID. This shows the actual @@ -790,22 +738,73 @@ on the preference list of every recipient key. See also the INTEROPERABILITY WITH OTHER OPENPGP PROGRAMS section below. - at item keyserver - at opindex keyedit:keyserver -Set a preferred keyserver for the specified user ID(s). This allows -other users to know where you prefer they get your key from. See - at option{--keyserver-options honor-keyserver-url} for more on how this -works. Setting a value of "none" removes an existing preferred -keyserver. + at item addkey + at opindex keyedit:addkey +Add a subkey to this key. - at item notation - at opindex keyedit:notation -Set a name=value notation for the specified user ID(s). See - at option{--cert-notation} for more on how this works. Setting a value of -"none" removes all notations, setting a notation prefixed with a minus -sign (-) removes that notation, and setting a notation name (without the -=value) prefixed with a minus sign removes all notations with that name. + at item addcardkey + at opindex keyedit:addcardkey +Generate a subkey on a card and add it to this key. + at item keytocard + at opindex keyedit:keytocard +Transfer the selected secret subkey (or the primary key if no subkey +has been selected) to a smartcard. The secret key in the keyring will +be replaced by a stub if the key could be stored successfully on the +card and you use the save command later. Only certain key types may be +transferred to the card. A sub menu allows you to select on what card +to store the key. Note that it is not possible to get that key back +from the card - if the card gets broken your secret key will be lost +unless you have a backup somewhere. + + at item bkuptocard @code{file} + at opindex keyedit:bkuptocard +Restore the given file to a card. This command may be used to restore a +backup key (as generated during card initialization) to a new card. In +almost all cases this will be the encryption key. You should use this +command only with the corresponding public key and make sure that the +file given as argument is indeed the backup to restore. You should then +select 2 to restore as encryption key. You will first be asked to enter +the passphrase of the backup key and then for the Admin PIN of the card. + + at item delkey + at opindex keyedit:delkey +Remove a subkey (secondart key). Note that it is not possible to retract +a subkey, once it has been send to the public (i.e. to a keyserver). In +that case you better use @code{revkey}. + + at item revkey + at opindex keyedit:revkey +Revoke a subkey. + + at item expire + at opindex keyedit:expire +Change the key or subkey expiration time. If a subkey is selected, the +expiration time of this subkey will be changed. With no selection, the +key expiration of the primary key is changed. + + at item trust + at opindex keyedit:trust +Change the owner trust value for the key. This updates the trust-db +immediately and no save is required. + + at item disable + at itemx enable + at opindex keyedit:disable + at opindex keyedit:enable +Disable or enable an entire key. A disabled key can not normally be +used for encryption. + + at item addrevoker + at opindex keyedit:addrevoker +Add a designated revoker to the key. This takes one optional argument: +"sensitive". If a designated revoker is marked as sensitive, it will +not be exported by default (see export-options). + + at item passwd + at opindex keyedit:passwd +Change the passphrase of the secret key. + @item toggle @opindex keyedit:toggle Toggle between public and secret key listing. @@ -829,7 +828,9 @@ Add cross-certification signatures to signing subkeys that may not currently have them. Cross-certification signatures protect against a subtle attack against signing subkeys. See - at option{--require-cross-certification}. + at option{--require-cross-certification}. All new keys generated have +this signature by default, so this option is only useful to bring +older keys up to date. @item save @opindex keyedit:save Modified: branches/STABLE-BRANCH-1-4/g10/compress-bz2.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/compress-bz2.c 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/g10/compress-bz2.c 2009-09-02 15:02:01 UTC (rev 5135) @@ -117,6 +117,7 @@ size_t n; int nread, count; int refill = !bzs->avail_in; + int eofseen = 0; if( DBG_FILTER ) log_debug("begin bzDecompress: avail_in=%u, avail_out=%u, inbuf=%u\n", @@ -131,13 +132,17 @@ bzs->next_in = zfx->inbuf; count = zfx->inbufsize - n; nread = iobuf_read( a, zfx->inbuf + n, count ); - if( nread == -1 ) nread = 0; + if( nread == -1 ) + { + eofseen = 1; + nread = 0; + } n += nread; bzs->avail_in = n; } + if (!eofseen) + refill = 1; - refill = 1; - if( DBG_FILTER ) log_debug("enter bzDecompress: avail_in=%u, avail_out=%u\n", (unsigned)bzs->avail_in, (unsigned)bzs->avail_out); @@ -150,6 +155,13 @@ rc = -1; /* eof */ else if( zrc != BZ_OK && zrc != BZ_PARAM_ERROR ) log_fatal("bz2lib inflate problem: rc=%d\n", zrc ); + else if (zrc == BZ_OK && eofseen + && !bzs->avail_in && bzs->avail_out > 0) + { + log_error ("unexpected EOF in bz2lib\n"); + rc = G10ERR_READ_FILE; + break; + } } while( bzs->avail_out && zrc != BZ_STREAM_END && zrc != BZ_PARAM_ERROR ); Modified: branches/STABLE-BRANCH-1-4/g10/compress.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/compress.c 2009-08-26 10:58:13 UTC (rev 5134) +++ branches/STABLE-BRANCH-1-4/g10/compress.c 2009-09-02 15:02:01 UTC (rev 5135) @@ -175,7 +175,8 @@ #endif /* __riscos__ */ count = zfx->inbufsize - n; nread = iobuf_read( a, zfx->inbuf + n, count ); - if( nread == -1 ) nread = 0; + if( nread == -1 ) + nread = 0; n += nread; /* If we use the undocumented feature to suppress * the zlib header, we have to give inflate an Modified: branches/STABLE-BRANCH-1-4/po/be.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/ca.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/cs.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/da.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/de.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/el.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/eo.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/es.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/et.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/fi.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/fr.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/gl.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/hu.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/id.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/it.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/ja.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/nb.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/nl.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/pl.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/pt.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/pt_BR.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/ro.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/ru.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/sk.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/sv.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/tr.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/zh_CN.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/zh_TW.po [not shown] From cvs at cvs.gnupg.org Wed Sep 2 19:30:54 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 02 Sep 2009 19:30:54 +0200 Subject: [svn] GnuPG - r5136 - in branches/STABLE-BRANCH-1-4: g10 keyserver Message-ID: Author: wk Date: 2009-09-02 19:30:53 +0200 (Wed, 02 Sep 2009) New Revision: 5136 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/app-openpgp.c branches/STABLE-BRANCH-1-4/g10/iso7816.c branches/STABLE-BRANCH-1-4/g10/iso7816.h branches/STABLE-BRANCH-1-4/keyserver/ChangeLog branches/STABLE-BRANCH-1-4/keyserver/Makefile.am Log: Last minute fixes Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2009-09-02 15:02:01 UTC (rev 5135) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2009-09-02 17:30:53 UTC (rev 5136) @@ -1,5 +1,8 @@ 2009-09-02 Werner Koch + * app-openpgp.c (do_decipher): Compute required Le. + * iso7816.c (iso7816_decipher): Add new arg LE. + * compress-bz2.c (do_uncompress): Detect unexpected EOF. Fixes bug#1011. Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2009-09-02 15:02:01 UTC (rev 5135) +++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2009-09-02 17:30:53 UTC (rev 5136) @@ -1,3 +1,8 @@ +2009-09-02 Werner Koch + + * Makefile.am (gpgkeys_curl_SOURCES, gpgkeys_ldap_SOURCES) + (gpgkeys_finger_SOURCES): Add ksmalloc.c only with non-faked cURL. + 2009-08-25 Werner Koch * ksmalloc.c: New Modified: branches/STABLE-BRANCH-1-4/g10/app-openpgp.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/app-openpgp.c 2009-09-02 15:02:01 UTC (rev 5135) +++ branches/STABLE-BRANCH-1-4/g10/app-openpgp.c 2009-09-02 17:30:53 UTC (rev 5136) @@ -3316,7 +3316,7 @@ const char *s; int n; const char *fpr = NULL; - int exmode; + int exmode, le_value; if (!keyidstr || !*keyidstr || !indatalen) return gpg_error (GPG_ERR_INV_VALUE); @@ -3399,16 +3399,22 @@ indatalen = fixuplen + indatalen; padind = -1; /* Already padded. */ } - + if (app->app_local->cardcap.ext_lc_le && indatalen > 254 ) - exmode = 1; /* Extended length w/o a limit. */ + { + exmode = 1; /* Extended length w/o a limit. */ + le_value = app->app_local->extcap.max_rsp_data; + } else if (app->app_local->cardcap.cmd_chaining && indatalen > 254) - exmode = -254; /* Command chaining with max. 254 bytes. */ + { + exmode = -254; /* Command chaining with max. 254 bytes. */ + le_value = 0; + } else - exmode = 0; + exmode = le_value = 0; rc = iso7816_decipher (app->slot, exmode, - indata, indatalen, padind, + indata, indatalen, le_value, padind, outdata, outdatalen); xfree (fixbuf); } Modified: branches/STABLE-BRANCH-1-4/g10/iso7816.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/iso7816.c 2009-09-02 15:02:01 UTC (rev 5135) +++ branches/STABLE-BRANCH-1-4/g10/iso7816.c 2009-09-02 17:30:53 UTC (rev 5136) @@ -545,10 +545,11 @@ indicator to be used. It should be 0 if no padding is required, a value of -1 suppresses the padding byte. On success 0 is returned and the plaintext is available in a newly allocated buffer stored - at RESULT with its length stored at RESULTLEN. */ + at RESULT with its length stored at RESULTLEN. For LE see + do_generate_keypair. */ gpg_error_t iso7816_decipher (int slot, int extended_mode, - const unsigned char *data, size_t datalen, + const unsigned char *data, size_t datalen, int le, int padind, unsigned char **result, size_t *resultlen) { int sw; @@ -559,6 +560,11 @@ *result = NULL; *resultlen = 0; + if (!extended_mode) + le = 256; /* Ignore provided Le and use what apdu_send uses. */ + else if (le >= 0 && le < 256) + le = 256; + if (padind >= 0) { /* We need to prepend the padding indicator. */ @@ -568,18 +574,18 @@ *buf = padind; /* Padding indicator. */ memcpy (buf+1, data, datalen); - sw = apdu_send (slot, extended_mode, - 0x00, CMD_PSO, 0x80, 0x86, - datalen+1, (char*)buf, - result, resultlen); + sw = apdu_send_le (slot, extended_mode, + 0x00, CMD_PSO, 0x80, 0x86, + datalen+1, (char*)buf, le, + result, resultlen); xfree (buf); } else { - sw = apdu_send (slot, extended_mode, - 0x00, CMD_PSO, 0x80, 0x86, - datalen, (const char *)data, - result, resultlen); + sw = apdu_send_le (slot, extended_mode, + 0x00, CMD_PSO, 0x80, 0x86, + datalen, (const char *)data, le, + result, resultlen); } if (sw != SW_SUCCESS) { Modified: branches/STABLE-BRANCH-1-4/g10/iso7816.h =================================================================== --- branches/STABLE-BRANCH-1-4/g10/iso7816.h 2009-09-02 15:02:01 UTC (rev 5135) +++ branches/STABLE-BRANCH-1-4/g10/iso7816.h 2009-09-02 17:30:53 UTC (rev 5136) @@ -99,7 +99,7 @@ unsigned char **result, size_t *resultlen); gpg_error_t iso7816_decipher (int slot, int extended_mode, const unsigned char *data, size_t datalen, - int padind, + int le, int padind, unsigned char **result, size_t *resultlen); gpg_error_t iso7816_internal_authenticate (int slot, int extended_mode, const unsigned char *data, size_t datalen, Modified: branches/STABLE-BRANCH-1-4/keyserver/Makefile.am =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/Makefile.am 2009-09-02 15:02:01 UTC (rev 5135) +++ branches/STABLE-BRANCH-1-4/keyserver/Makefile.am 2009-09-02 17:30:53 UTC (rev 5136) @@ -28,9 +28,9 @@ noinst_SCRIPTS = gpgkeys_test gpgkeys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h ksmalloc.c -gpgkeys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h ksmalloc.c +gpgkeys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h gpgkeys_finger_SOURCES = gpgkeys_finger.c ksutil.c ksutil.h -gpgkeys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h ksmalloc.c +gpgkeys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) @@ -45,8 +45,10 @@ gpgkeys_hkp_SOURCES += curl-shim.c curl-shim.h gpgkeys_hkp_LDADD = ../util/libutil.a @NETLIBS@ @DNSLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ else +gpgkeys_curl_SOURCES += ksmalloc.c gpgkeys_curl_CPPFLAGS = @LIBCURL_CPPFLAGS@ gpgkeys_curl_LDADD = ../util/libcompat.a @LIBCURL@ @GETOPT@ +gpgkeys_hkp_SOURCES += ksmalloc.c gpgkeys_hkp_CPPFLAGS = @LIBCURL_CPPFLAGS@ gpgkeys_hkp_LDADD = ../util/libcompat.a @DNSLIBS@ @LIBCURL@ @GETOPT@ gpgkeys_finger_CPPFLAGS = @LIBCURL_CPPFLAGS@ From cvs at cvs.gnupg.org Wed Sep 2 19:32:46 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 02 Sep 2009 19:32:46 +0200 Subject: [svn] GnuPG - r5137 - branches/STABLE-BRANCH-1-4/po Message-ID: Author: wk Date: 2009-09-02 19:32:43 +0200 (Wed, 02 Sep 2009) New Revision: 5137 Modified: branches/STABLE-BRANCH-1-4/po/be.po branches/STABLE-BRANCH-1-4/po/ca.po branches/STABLE-BRANCH-1-4/po/cs.po branches/STABLE-BRANCH-1-4/po/da.po branches/STABLE-BRANCH-1-4/po/de.po branches/STABLE-BRANCH-1-4/po/el.po branches/STABLE-BRANCH-1-4/po/eo.po branches/STABLE-BRANCH-1-4/po/es.po branches/STABLE-BRANCH-1-4/po/et.po branches/STABLE-BRANCH-1-4/po/fi.po branches/STABLE-BRANCH-1-4/po/fr.po branches/STABLE-BRANCH-1-4/po/gl.po branches/STABLE-BRANCH-1-4/po/hu.po branches/STABLE-BRANCH-1-4/po/id.po branches/STABLE-BRANCH-1-4/po/it.po branches/STABLE-BRANCH-1-4/po/ja.po branches/STABLE-BRANCH-1-4/po/nb.po branches/STABLE-BRANCH-1-4/po/nl.po branches/STABLE-BRANCH-1-4/po/pl.po branches/STABLE-BRANCH-1-4/po/pt.po branches/STABLE-BRANCH-1-4/po/pt_BR.po branches/STABLE-BRANCH-1-4/po/ro.po branches/STABLE-BRANCH-1-4/po/ru.po branches/STABLE-BRANCH-1-4/po/sk.po branches/STABLE-BRANCH-1-4/po/sv.po branches/STABLE-BRANCH-1-4/po/tr.po branches/STABLE-BRANCH-1-4/po/zh_CN.po branches/STABLE-BRANCH-1-4/po/zh_TW.po Log: Update line numbers - arghhh Modified: branches/STABLE-BRANCH-1-4/po/be.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/ca.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/cs.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/da.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/de.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/el.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/eo.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/es.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/et.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/fi.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/fr.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/gl.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/hu.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/id.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/it.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/ja.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/nb.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/nl.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/pl.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/pt.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/pt_BR.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/ro.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/ru.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/sk.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/sv.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/tr.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/zh_CN.po [not shown] Modified: branches/STABLE-BRANCH-1-4/po/zh_TW.po [not shown] From cvs at cvs.gnupg.org Wed Sep 2 20:19:02 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 02 Sep 2009 20:19:02 +0200 Subject: [svn] GnuPG - r5138 - tags Message-ID: Author: wk Date: 2009-09-02 20:19:01 +0200 (Wed, 02 Sep 2009) New Revision: 5138 Added: tags/gnupg-1.4.10/ Log: Release tag From cvs at cvs.gnupg.org Wed Sep 2 20:21:13 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 02 Sep 2009 20:21:13 +0200 Subject: [svn] GnuPG - r5139 - branches/STABLE-BRANCH-1-4 Message-ID: Author: wk Date: 2009-09-02 20:21:13 +0200 (Wed, 02 Sep 2009) New Revision: 5139 Modified: branches/STABLE-BRANCH-1-4/NEWS branches/STABLE-BRANCH-1-4/configure.ac Log: Post release version number bump Modified: branches/STABLE-BRANCH-1-4/NEWS =================================================================== --- branches/STABLE-BRANCH-1-4/NEWS 2009-09-02 18:19:01 UTC (rev 5138) +++ branches/STABLE-BRANCH-1-4/NEWS 2009-09-02 18:21:13 UTC (rev 5139) @@ -1,3 +1,7 @@ +Noteworthy changes in version 1.4.11 +------------------------------------------------- + + Noteworthy changes in version 1.4.10 (2009-09-02) ------------------------------------------------- Modified: branches/STABLE-BRANCH-1-4/configure.ac =================================================================== --- branches/STABLE-BRANCH-1-4/configure.ac 2009-09-02 18:19:01 UTC (rev 5138) +++ branches/STABLE-BRANCH-1-4/configure.ac 2009-09-02 18:21:13 UTC (rev 5139) @@ -25,8 +25,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 --force" right before creating a distribution. -m4_define([my_version], [1.4.10]) -m4_define([my_issvn], [no]) +m4_define([my_version], [1.4.11]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \ | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) AC_INIT([gnupg], From cvs at cvs.gnupg.org Thu Sep 3 10:32:42 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 Sep 2009 10:32:42 +0200 Subject: [svn] GnuPG - r5140 - branches/STABLE-BRANCH-1-4/po Message-ID: Author: wk Date: 2009-09-03 10:32:42 +0200 (Thu, 03 Sep 2009) New Revision: 5140 Modified: branches/STABLE-BRANCH-1-4/po/ChangeLog branches/STABLE-BRANCH-1-4/po/zh_TW.po Log: Update from Jedi Modified: branches/STABLE-BRANCH-1-4/po/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/po/ChangeLog 2009-09-02 18:21:13 UTC (rev 5139) +++ branches/STABLE-BRANCH-1-4/po/ChangeLog 2009-09-03 08:32:42 UTC (rev 5140) @@ -1,3 +1,7 @@ +2009-09-03 Jedi Lin (wk) + + * zh_TW.po: Update. + 2009-08-18 Werner Koch * fr.po: Fix regression. See bug#922. Modified: branches/STABLE-BRANCH-1-4/po/zh_TW.po [not shown] From cvs at cvs.gnupg.org Thu Sep 3 10:59:41 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 Sep 2009 10:59:41 +0200 Subject: [svn] GnuPG - r5141 - in branches/STABLE-BRANCH-1-4: m4 po util Message-ID: Author: wk Date: 2009-09-03 10:59:41 +0200 (Thu, 03 Sep 2009) New Revision: 5141 Modified: branches/STABLE-BRANCH-1-4/m4/estream.m4 branches/STABLE-BRANCH-1-4/po/zh_TW.po branches/STABLE-BRANCH-1-4/util/ChangeLog branches/STABLE-BRANCH-1-4/util/estream-printf.c Log: Update zH_TW and check for stdint.h Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/util/ChangeLog 2009-09-03 08:32:42 UTC (rev 5140) +++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2009-09-03 08:59:41 UTC (rev 5141) @@ -1,3 +1,12 @@ +2009-09-03 Werner Koch + + * estream-printf.c: Include stdint.h only if HAVE_STDINT_H is + defined. Problem reported by Nelson H. F. Beebe. + * estream.m4: Check for stdint.h. + + * estream-printf.c: Remove all test code. Use macro DEBUG instead + of TEST for debugging. + 2009-08-25 Werner Koch * compat.c: Change license to all-permissive. The GPL and the Modified: branches/STABLE-BRANCH-1-4/m4/estream.m4 =================================================================== --- branches/STABLE-BRANCH-1-4/m4/estream.m4 2009-09-03 08:32:42 UTC (rev 5140) +++ branches/STABLE-BRANCH-1-4/m4/estream.m4 2009-09-03 08:59:41 UTC (rev 5141) @@ -16,6 +16,7 @@ AC_DEFUN([estream_PRINTF_INIT], [ AC_MSG_NOTICE([checking system features for estream-printf]) + AC_CHECK_HEADERS(stdint.h) AC_TYPE_LONG_LONG_INT AC_TYPE_LONG_DOUBLE AC_TYPE_INTMAX_T Modified: branches/STABLE-BRANCH-1-4/po/zh_TW.po [not shown] Modified: branches/STABLE-BRANCH-1-4/util/estream-printf.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/estream-printf.c 2009-09-03 08:32:42 UTC (rev 5140) +++ branches/STABLE-BRANCH-1-4/util/estream-printf.c 2009-09-03 08:59:41 UTC (rev 5141) @@ -1,5 +1,5 @@ /* estream-printf.c - Versatile C-99 compliant printf formatting - * Copyright (C) 2007, 2008 g10 Code GmbH + * Copyright (C) 2007, 2008, 2009 g10 Code GmbH * * This file is part of Libestream. * @@ -34,6 +34,7 @@ Missing stuff: wchar and wint_t thousands_sep in pr_float. + */ #ifdef HAVE_CONFIG_H @@ -49,27 +50,28 @@ #include #include #if defined(HAVE_INTMAX_T) || defined(HAVE_UINTMAX_T) -# include +# ifdef HAVE_STDINT_H +# include +# endif #endif #ifdef HAVE_LANGINFO_THOUSANDS_SEP #include #endif -#ifdef TEST -# include -#else -# ifdef _ESTREAM_PRINTF_EXTRA_INCLUDE -# include _ESTREAM_PRINTF_EXTRA_INCLUDE -# endif +#ifdef _ESTREAM_PRINTF_EXTRA_INCLUDE +# include _ESTREAM_PRINTF_EXTRA_INCLUDE #endif #include "estream-printf.h" +/* #define DEBUG 1 */ + + /* Allow redefinition of asprintf used malloc functions. */ -#if defined(_ESTREAM_PRINTF_MALLOC) && !defined(TEST) +#if defined(_ESTREAM_PRINTF_MALLOC) #define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a)) #else #define my_printf_malloc(a) malloc((a)) #endif -#if defined(_ESTREAM_PRINTF_FREE) && !defined(TEST) +#if defined(_ESTREAM_PRINTF_FREE) #define my_printf_free(a) _ESTREAM_PRINTF_FREE((a)) #else #define my_printf_free(a) free((a)) @@ -257,9 +259,7 @@ typedef struct valueitem_s *valueitem_t; -#ifdef TEST -static int verbose; - +#ifdef DEBUG static void dump_argspecs (argspec_t arg, size_t argcount) { @@ -281,7 +281,7 @@ arg->width_pos, arg->precision_pos); } -#endif /*TEST*/ +#endif /*DEBUG*/ /* Set the vt field for ARG. */ @@ -1482,8 +1482,7 @@ if (max_pos < 0 || max_pos >= strlen (format)) goto leave_einval; -#ifdef TEST - if (verbose > 1) +#ifdef DEBUG dump_argspecs (argspecs, argspecs_len); #endif @@ -1787,324 +1786,3 @@ } -#ifdef TEST - -static int -one_test (const char *format, ...) -{ -#ifdef _WIN32 - { - static int show; - - if (!show) - { - /* We do not have a system vasprintf. */ - printf ("one-test: disabled under W32\n"); - show = 1; - } - } -#else - int rc1, rc2; - va_list arg_ptr; - char *buf1, *buf2; - - if (verbose) - printf ("format: ->%s<-\n", format); - - va_start (arg_ptr, format); - rc1 = vasprintf (&buf1, format, arg_ptr); - va_end (arg_ptr); - if (rc1 == -1) - { - printf (" sys: errno=%d (%s)\n", errno, strerror (errno)); - buf1 = NULL; - } - else if (verbose) - printf (" sys: ->%s<-\n", buf1); - - va_start (arg_ptr, format); - rc2 = estream_vasprintf (&buf2, format, arg_ptr); - va_end (arg_ptr); - if (rc2 == -1) - printf (" our: errno=%d (%s)\n", errno, strerror (errno)); - else if (verbose) - printf (" our: ->%s<-\n", buf2); - - if (rc1 != -1 && rc2 != -1 && strcmp (buf1, buf2)) - printf ("error: output does not match\n" - "format: ->%s<-\n sys: ->%s<-\n our: ->%s<-\n", - format, buf1, buf2); - else if ( rc1 != rc2 ) - printf ("error: return codes are different: sys_rc=%d our_rc=%d\n", - rc1, rc2); - - free (buf2); - free (buf1); -#endif - return 0; -} - - -static void -run_tests (void) -{ - /*one_test ("%d %% %'d", 17, 19681977);*/ - - one_test ("%d %% %d", 17, 768114563); - one_test ("%d %% %d", 17, -768114563); - - one_test ("%d", 17); - one_test ("%4d", 17); - one_test ("%40d", 17); - one_test ("%-d", 17); - one_test ("%-4d", 17); - one_test ("%-140d", 17); - one_test ("%d", -17); - one_test ("%4d", -17); - one_test ("%40d", -17); - one_test ("%-d", -17); - one_test ("%-4d", -17); - one_test ("%-40d", -17); - - one_test ("%+4d", 17); - one_test ("%+4d", -17); - one_test ("%-+4d", 17); - one_test ("%-+4d", -17); - one_test ("% 4d", 17); - one_test ("% 4d", -17); - one_test ("%- +4d", 17); - one_test ("%- +4d", -17); - - one_test ("%.4d", 17); - one_test ("%.0d", 17); - one_test ("%.0d", 0); - one_test ("%.4d", -17); - one_test ("%.0d", -17); - one_test ("%6.4d", 17); - one_test ("%6.4d", -17); - one_test ("%6.0d", 0); - one_test ("%4.6d", 17); - one_test ("%4.6d", -17); - - one_test ("% 4.6d", 17); - one_test ("% 6.0d", 0); - - one_test ("%.4d", 17); - one_test ("%04d", 17); - one_test ("%.4d", -17); - one_test ("%04d", -17); - one_test ("%0.d", 0); - - one_test ("%*d", 7, 42); - one_test ("%*d", -7, 42); - one_test ("%.*d", 7, 42); - one_test ("%.*d", -7, 42); - one_test ("%*.*d", 10, 7, 42); - one_test ("%*.*d", 10, -7, 42); - one_test ("%*.*d", -10, 7, 42); - one_test ("%*.*d", -10, -7, 42); - - one_test ("%*x", 7, 42); - one_test ("%*x", -7, 42); - one_test ("%.*x", 7, 42); - one_test ("%.*x", -7, 42); - one_test ("%*.*x", 10, 7, 42); - one_test ("%*.*x", 10, -7, 42); - one_test ("%*.*x", -10, 7, 42); - one_test ("%*.*x", -10, -7, 42); - one_test ("%#*x", 7, 42); - one_test ("%#*x", -7, 42); - one_test ("%#.*x", 7, 42); - one_test ("%#.*x", -7, 42); - one_test ("%#*.*x", 10, 7, 42); - one_test ("%#*.*x", 10, -7, 42); - one_test ("%#*.*x", -10, 7, 42); - one_test ("%#*.*x", -10, -7, 42); - - one_test ("%*X", 7, 42); - one_test ("%*X", -7, 42); - one_test ("%.*X", 7, 42); - one_test ("%.*X", -7, 42); - one_test ("%*.*X", 10, 7, 42); - one_test ("%*.*X", 10, -7, 42); - one_test ("%*.*X", -10, 7, 42); - one_test ("%*.*X", -10, -7, 42); - one_test ("%#*X", 7, 42); - one_test ("%#*X", -7, 42); - one_test ("%#.*X", 7, 42); - one_test ("%#.*X", -7, 42); - one_test ("%#*.*X", 10, 7, 42); - one_test ("%#*.*X", 10, -7, 42); - one_test ("%#*.*X", -10, 7, 42); - one_test ("%#*.*X", -10, -7, 42); - - one_test ("%*o", 7, 42); - one_test ("%*o", -7, 42); - one_test ("%.*o", 7, 42); - one_test ("%.*o", -7, 42); - one_test ("%*.*o", 10, 7, 42); - one_test ("%*.*o", 10, -7, 42); - one_test ("%*.*o", -10, 7, 42); - one_test ("%*.*o", -10, -7, 42); - one_test ("%#*o", 7, 42); - one_test ("%#*o", -7, 42); - one_test ("%#.*o", 7, 42); - one_test ("%#.*o", -7, 42); - one_test ("%#*.*o", 10, 7, 42); - one_test ("%#*.*o", 10, -7, 42); - one_test ("%#*.*o", -10, 7, 42); - one_test ("%#*.*o", -10, -7, 42); - - one_test ("%s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.0s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.10s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.48s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.49s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.50s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.51s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%48s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%49s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%50s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%51s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%-51s", "the quick brown fox jumps over the lazy dogs back"); - - one_test ("/%s=", "CN"); - - one_test ("%f", 3.1415926535); - one_test ("%f", -3.1415926535); - one_test ("%.10f", 3.1415926535); - one_test ("%.2f", 3.1415926535); - one_test ("%.1f", 3.1415926535); - one_test ("%.0f", 3.1415926535); - one_test ("%.20f", 3.1415926535); - one_test ("%10.10f", 3.1415926535); - one_test ("%10.2f", 3.1415926535); - one_test ("%10.1f", 3.1415926535); - one_test ("%10.0f", 3.1415926535); - one_test ("%30.20f", 3.1415926535); - one_test ("%10.10f", -3.1415926535); - one_test ("%10.2f", -3.1415926535); - one_test ("%10.1f", -3.1415926535); - one_test ("%10.0f", -3.1415926535); - one_test ("%30.20f", -3.1415926535); - - one_test ("%-10f", 3.1415926535); - one_test ("%-10.10f", 3.1415926535); - one_test ("%-10.2f", 3.1415926535); - one_test ("%-10.1f", 3.1415926535); - one_test ("%-10.0f", 3.1415926535); - one_test ("%-30.20f", 3.1415926535); - one_test ("%-10f", -3.1415926535); - one_test ("%-10.10f", -3.1415926535); - one_test ("%-10.2f", -3.1415926535); - one_test ("%-10.1f", -3.1415926535); - one_test ("%-10.0f", -3.1415926535); - one_test ("%-30.20f", -3.1415926535); - - one_test ("%#.0f", 3.1415926535); - one_test ("%#10.0f", 3.1415926535); - one_test ("%#10.0f", -3.1415926535); - one_test ("%-#10.0f", 3.1415926535); - one_test ("%-#10.0f", -3.1415926535); - - one_test ("%e", 3.1415926535); - one_test ("%g", 3.1415926535); - - one_test ("%a", 1); - one_test ("%a", -1); - one_test ("%a", 3.1415926535); - -#ifdef HAVE_LONG_DOUBLE - one_test ("%La", 1); - one_test ("%La", -1); - one_test ("%La", 3.1415926535); -#endif - -#ifdef __GLIBC__ - /* "%m" is a glibc extension so this _test_ will only work on such a - system. */ - errno = ENOENT; - one_test ("%m"); - errno = ENOENT; - one_test ("%d=%m", 17); - errno = ENOENT; - one_test ("%2$d:%m:%1$d", 42, 17); -#endif /*__GLIBC__*/ - -} - -static void -check_snprintf (void) -{ - char buffer[20]; - int rc, rc2; - size_t tmplen, blen, blen2; - - rc = estream_snprintf (buffer, 0, "%*s", 18, ""); - if (rc != 18) - printf ("rc=%d\n", rc ); - rc = estream_snprintf (buffer, sizeof buffer, "%*s", 18, ""); - if (rc != 18) - printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); - rc = estream_snprintf (buffer, sizeof buffer, "%*s", 19, ""); - if (rc != 19) - printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); - rc = estream_snprintf (buffer, sizeof buffer, "%*s", 20, ""); - if (rc != 20) - printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); - rc = estream_snprintf (buffer, sizeof buffer, "%*s", 21, ""); - if (rc != 21) - printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); - - for (tmplen = 0; tmplen <= sizeof buffer; tmplen++) - { - rc = estream_snprintf (buffer, tmplen, "%04d%02d%02dT%02d%02d%02d", - 1998, 9, 7, 16, 56, 05); - blen = strlen (buffer); - rc2 = snprintf (buffer, tmplen, "%04d%02d%02dT%02d%02d%02d", - 1998, 9, 7, 16, 56, 05); - blen2 = strlen (buffer); - if (rc != rc2 || blen != blen2) - printf ("snprintf test with len %u gives %d instead of %d (%d,%d)\n", - (unsigned int)tmplen, rc, rc2, blen, blen2); - } -} - - - -int -main (int argc, char **argv) -{ - int rc; - - if (argc) {argc--; argv++; } - - setlocale (LC_NUMERIC, ""); - - while (argc && !strcmp (*argv, "--verbose")) - { - verbose++; - argc--; - argv++; - } - - if (!argc) - { - run_tests (); - check_snprintf () ; - } - else - { - rc = estream_vfprintf (stdout, argv[0], NULL); - fflush (stdout); - fprintf (stderr, "[estream_vfprintf returns: %d]\n", rc); - } - - return 0; -} -#endif /*TEST*/ -/* -Local Variables: -compile-command: "cc -Wall -O3 -g -I.. -DHAVE_CONFIG_H -DTEST -o estream-printf estream-printf.c" -End: -*/ From cvs at cvs.gnupg.org Thu Sep 3 12:44:14 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 Sep 2009 12:44:14 +0200 Subject: [svn] GnuPG - r5142 - trunk/common Message-ID: Author: wk Date: 2009-09-03 12:44:13 +0200 (Thu, 03 Sep 2009) New Revision: 5142 Modified: trunk/common/ChangeLog trunk/common/estream-printf.c trunk/common/estream.c Log: Update estream. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2009-09-03 08:59:41 UTC (rev 5141) +++ trunk/common/ChangeLog 2009-09-03 10:44:13 UTC (rev 5142) @@ -1,3 +1,13 @@ +2009-09-03 Werner Koch + + Update from libestream: + * estream-printf.c: Include stdint.h only if HAVE_STDINT_H is + defined. + * estream-printf.c: Remove all test code. Use macro DEBUG instead + of TEST for debugging. + * estream-printf.c (pr_float): Make buffer larger for silly high + numbers. + 2009-08-11 David Shaw * ttyio.h, ttyio.c (tty_enable_completion): Some ifdefs around @@ -72,14 +82,14 @@ 2009-05-28 David Shaw From 1.4: - + * http.h, http.c (send_request) Pass in a STRLIST for additional headers. Change all callers. 2009-05-27 David Shaw From 1.4: - + * http.h, http.c (send_request): Pass in srvtag and make its presence sufficient to turn the feature on. (http_open): From here. Modified: trunk/common/estream-printf.c =================================================================== --- trunk/common/estream-printf.c 2009-09-03 08:59:41 UTC (rev 5141) +++ trunk/common/estream-printf.c 2009-09-03 10:44:13 UTC (rev 5142) @@ -1,5 +1,5 @@ /* estream-printf.c - Versatile C-99 compliant printf formatting - * Copyright (C) 2007, 2008 g10 Code GmbH + * Copyright (C) 2007, 2008, 2009 g10 Code GmbH * * This file is part of Libestream. * @@ -34,6 +34,7 @@ Missing stuff: wchar and wint_t thousands_sep in pr_float. + */ #ifdef HAVE_CONFIG_H @@ -49,27 +50,28 @@ #include #include #if defined(HAVE_INTMAX_T) || defined(HAVE_UINTMAX_T) -# include +# ifdef HAVE_STDINT_H +# include +# endif #endif #ifdef HAVE_LANGINFO_THOUSANDS_SEP #include #endif -#ifdef TEST -# include -#else -# ifdef _ESTREAM_PRINTF_EXTRA_INCLUDE -# include _ESTREAM_PRINTF_EXTRA_INCLUDE -# endif +#ifdef _ESTREAM_PRINTF_EXTRA_INCLUDE +# include _ESTREAM_PRINTF_EXTRA_INCLUDE #endif #include "estream-printf.h" +/* #define DEBUG 1 */ + + /* Allow redefinition of asprintf used malloc functions. */ -#if defined(_ESTREAM_PRINTF_MALLOC) && !defined(TEST) +#if defined(_ESTREAM_PRINTF_MALLOC) #define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a)) #else #define my_printf_malloc(a) malloc((a)) #endif -#if defined(_ESTREAM_PRINTF_FREE) && !defined(TEST) +#if defined(_ESTREAM_PRINTF_FREE) #define my_printf_free(a) _ESTREAM_PRINTF_FREE((a)) #else #define my_printf_free(a) free((a)) @@ -257,9 +259,7 @@ typedef struct valueitem_s *valueitem_t; -#ifdef TEST -static int verbose; - +#ifdef DEBUG static void dump_argspecs (argspec_t arg, size_t argcount) { @@ -281,7 +281,7 @@ arg->width_pos, arg->precision_pos); } -#endif /*TEST*/ +#endif /*DEBUG*/ /* Set the vt field for ARG. */ @@ -995,7 +995,7 @@ int use_dbl = 0; #endif double afloat; - char numbuf[200]; + char numbuf[350]; char formatstr[20]; char *p, *pend; size_t n; @@ -1482,8 +1482,7 @@ if (max_pos < 0 || max_pos >= strlen (format)) goto leave_einval; -#ifdef TEST - if (verbose > 1) +#ifdef DEBUG dump_argspecs (argspecs, argspecs_len); #endif @@ -1787,324 +1786,3 @@ } -#ifdef TEST - -static int -one_test (const char *format, ...) -{ -#ifdef _WIN32 - { - static int show; - - if (!show) - { - /* We do not have a system vasprintf. */ - printf ("one-test: disabled under W32\n"); - show = 1; - } - } -#else - int rc1, rc2; - va_list arg_ptr; - char *buf1, *buf2; - - if (verbose) - printf ("format: ->%s<-\n", format); - - va_start (arg_ptr, format); - rc1 = vasprintf (&buf1, format, arg_ptr); - va_end (arg_ptr); - if (rc1 == -1) - { - printf (" sys: errno=%d (%s)\n", errno, strerror (errno)); - buf1 = NULL; - } - else if (verbose) - printf (" sys: ->%s<-\n", buf1); - - va_start (arg_ptr, format); - rc2 = estream_vasprintf (&buf2, format, arg_ptr); - va_end (arg_ptr); - if (rc2 == -1) - printf (" our: errno=%d (%s)\n", errno, strerror (errno)); - else if (verbose) - printf (" our: ->%s<-\n", buf2); - - if (rc1 != -1 && rc2 != -1 && strcmp (buf1, buf2)) - printf ("error: output does not match\n" - "format: ->%s<-\n sys: ->%s<-\n our: ->%s<-\n", - format, buf1, buf2); - else if ( rc1 != rc2 ) - printf ("error: return codes are different: sys_rc=%d our_rc=%d\n", - rc1, rc2); - - free (buf2); - free (buf1); -#endif - return 0; -} - - -static void -run_tests (void) -{ - /*one_test ("%d %% %'d", 17, 19681977);*/ - - one_test ("%d %% %d", 17, 768114563); - one_test ("%d %% %d", 17, -768114563); - - one_test ("%d", 17); - one_test ("%4d", 17); - one_test ("%40d", 17); - one_test ("%-d", 17); - one_test ("%-4d", 17); - one_test ("%-140d", 17); - one_test ("%d", -17); - one_test ("%4d", -17); - one_test ("%40d", -17); - one_test ("%-d", -17); - one_test ("%-4d", -17); - one_test ("%-40d", -17); - - one_test ("%+4d", 17); - one_test ("%+4d", -17); - one_test ("%-+4d", 17); - one_test ("%-+4d", -17); - one_test ("% 4d", 17); - one_test ("% 4d", -17); - one_test ("%- +4d", 17); - one_test ("%- +4d", -17); - - one_test ("%.4d", 17); - one_test ("%.0d", 17); - one_test ("%.0d", 0); - one_test ("%.4d", -17); - one_test ("%.0d", -17); - one_test ("%6.4d", 17); - one_test ("%6.4d", -17); - one_test ("%6.0d", 0); - one_test ("%4.6d", 17); - one_test ("%4.6d", -17); - - one_test ("% 4.6d", 17); - one_test ("% 6.0d", 0); - - one_test ("%.4d", 17); - one_test ("%04d", 17); - one_test ("%.4d", -17); - one_test ("%04d", -17); - one_test ("%0.d", 0); - - one_test ("%*d", 7, 42); - one_test ("%*d", -7, 42); - one_test ("%.*d", 7, 42); - one_test ("%.*d", -7, 42); - one_test ("%*.*d", 10, 7, 42); - one_test ("%*.*d", 10, -7, 42); - one_test ("%*.*d", -10, 7, 42); - one_test ("%*.*d", -10, -7, 42); - - one_test ("%*x", 7, 42); - one_test ("%*x", -7, 42); - one_test ("%.*x", 7, 42); - one_test ("%.*x", -7, 42); - one_test ("%*.*x", 10, 7, 42); - one_test ("%*.*x", 10, -7, 42); - one_test ("%*.*x", -10, 7, 42); - one_test ("%*.*x", -10, -7, 42); - one_test ("%#*x", 7, 42); - one_test ("%#*x", -7, 42); - one_test ("%#.*x", 7, 42); - one_test ("%#.*x", -7, 42); - one_test ("%#*.*x", 10, 7, 42); - one_test ("%#*.*x", 10, -7, 42); - one_test ("%#*.*x", -10, 7, 42); - one_test ("%#*.*x", -10, -7, 42); - - one_test ("%*X", 7, 42); - one_test ("%*X", -7, 42); - one_test ("%.*X", 7, 42); - one_test ("%.*X", -7, 42); - one_test ("%*.*X", 10, 7, 42); - one_test ("%*.*X", 10, -7, 42); - one_test ("%*.*X", -10, 7, 42); - one_test ("%*.*X", -10, -7, 42); - one_test ("%#*X", 7, 42); - one_test ("%#*X", -7, 42); - one_test ("%#.*X", 7, 42); - one_test ("%#.*X", -7, 42); - one_test ("%#*.*X", 10, 7, 42); - one_test ("%#*.*X", 10, -7, 42); - one_test ("%#*.*X", -10, 7, 42); - one_test ("%#*.*X", -10, -7, 42); - - one_test ("%*o", 7, 42); - one_test ("%*o", -7, 42); - one_test ("%.*o", 7, 42); - one_test ("%.*o", -7, 42); - one_test ("%*.*o", 10, 7, 42); - one_test ("%*.*o", 10, -7, 42); - one_test ("%*.*o", -10, 7, 42); - one_test ("%*.*o", -10, -7, 42); - one_test ("%#*o", 7, 42); - one_test ("%#*o", -7, 42); - one_test ("%#.*o", 7, 42); - one_test ("%#.*o", -7, 42); - one_test ("%#*.*o", 10, 7, 42); - one_test ("%#*.*o", 10, -7, 42); - one_test ("%#*.*o", -10, 7, 42); - one_test ("%#*.*o", -10, -7, 42); - - one_test ("%s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.0s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.10s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.48s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.49s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.50s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%.51s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%48s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%49s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%50s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%51s", "the quick brown fox jumps over the lazy dogs back"); - one_test ("%-51s", "the quick brown fox jumps over the lazy dogs back"); - - one_test ("/%s=", "CN"); - - one_test ("%f", 3.1415926535); - one_test ("%f", -3.1415926535); - one_test ("%.10f", 3.1415926535); - one_test ("%.2f", 3.1415926535); - one_test ("%.1f", 3.1415926535); - one_test ("%.0f", 3.1415926535); - one_test ("%.20f", 3.1415926535); - one_test ("%10.10f", 3.1415926535); - one_test ("%10.2f", 3.1415926535); - one_test ("%10.1f", 3.1415926535); - one_test ("%10.0f", 3.1415926535); - one_test ("%30.20f", 3.1415926535); - one_test ("%10.10f", -3.1415926535); - one_test ("%10.2f", -3.1415926535); - one_test ("%10.1f", -3.1415926535); - one_test ("%10.0f", -3.1415926535); - one_test ("%30.20f", -3.1415926535); - - one_test ("%-10f", 3.1415926535); - one_test ("%-10.10f", 3.1415926535); - one_test ("%-10.2f", 3.1415926535); - one_test ("%-10.1f", 3.1415926535); - one_test ("%-10.0f", 3.1415926535); - one_test ("%-30.20f", 3.1415926535); - one_test ("%-10f", -3.1415926535); - one_test ("%-10.10f", -3.1415926535); - one_test ("%-10.2f", -3.1415926535); - one_test ("%-10.1f", -3.1415926535); - one_test ("%-10.0f", -3.1415926535); - one_test ("%-30.20f", -3.1415926535); - - one_test ("%#.0f", 3.1415926535); - one_test ("%#10.0f", 3.1415926535); - one_test ("%#10.0f", -3.1415926535); - one_test ("%-#10.0f", 3.1415926535); - one_test ("%-#10.0f", -3.1415926535); - - one_test ("%e", 3.1415926535); - one_test ("%g", 3.1415926535); - - one_test ("%a", 1); - one_test ("%a", -1); - one_test ("%a", 3.1415926535); - -#ifdef HAVE_LONG_DOUBLE - one_test ("%La", 1); - one_test ("%La", -1); - one_test ("%La", 3.1415926535); -#endif - -#ifdef __GLIBC__ - /* "%m" is a glibc extension so this _test_ will only work on such a - system. */ - errno = ENOENT; - one_test ("%m"); - errno = ENOENT; - one_test ("%d=%m", 17); - errno = ENOENT; - one_test ("%2$d:%m:%1$d", 42, 17); -#endif /*__GLIBC__*/ - -} - -static void -check_snprintf (void) -{ - char buffer[20]; - int rc, rc2; - size_t tmplen, blen, blen2; - - rc = estream_snprintf (buffer, 0, "%*s", 18, ""); - if (rc != 18) - printf ("rc=%d\n", rc ); - rc = estream_snprintf (buffer, sizeof buffer, "%*s", 18, ""); - if (rc != 18) - printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); - rc = estream_snprintf (buffer, sizeof buffer, "%*s", 19, ""); - if (rc != 19) - printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); - rc = estream_snprintf (buffer, sizeof buffer, "%*s", 20, ""); - if (rc != 20) - printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); - rc = estream_snprintf (buffer, sizeof buffer, "%*s", 21, ""); - if (rc != 21) - printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); - - for (tmplen = 0; tmplen <= sizeof buffer; tmplen++) - { - rc = estream_snprintf (buffer, tmplen, "%04d%02d%02dT%02d%02d%02d", - 1998, 9, 7, 16, 56, 05); - blen = strlen (buffer); - rc2 = snprintf (buffer, tmplen, "%04d%02d%02dT%02d%02d%02d", - 1998, 9, 7, 16, 56, 05); - blen2 = strlen (buffer); - if (rc != rc2 || blen != blen2) - printf ("snprintf test with len %u gives %d instead of %d (%d,%d)\n", - (unsigned int)tmplen, rc, rc2, blen, blen2); - } -} - - - -int -main (int argc, char **argv) -{ - int rc; - - if (argc) {argc--; argv++; } - - setlocale (LC_NUMERIC, ""); - - while (argc && !strcmp (*argv, "--verbose")) - { - verbose++; - argc--; - argv++; - } - - if (!argc) - { - run_tests (); - check_snprintf () ; - } - else - { - rc = estream_vfprintf (stdout, argv[0], NULL); - fflush (stdout); - fprintf (stderr, "[estream_vfprintf returns: %d]\n", rc); - } - - return 0; -} -#endif /*TEST*/ -/* -Local Variables: -compile-command: "cc -Wall -O3 -g -I.. -DHAVE_CONFIG_H -DTEST -o estream-printf estream-printf.c" -End: -*/ Modified: trunk/common/estream.c =================================================================== --- trunk/common/estream.c 2009-09-03 08:59:41 UTC (rev 5141) +++ trunk/common/estream.c 2009-09-03 10:44:13 UTC (rev 5142) @@ -2756,7 +2756,7 @@ out: - return err ? err : line_n; + return err ? err : (ssize_t)line_n; } @@ -2929,7 +2929,45 @@ return ret; } +/* A variant of asprintf. The function returns the allocated buffer + or NULL on error; ERRNO is set in the error case. The caller + should use es_free to release the buffer. This function actually + belongs into estream-printf but we put it here as a convenience + and because es_free is required anyway. */ +char * +es_asprintf (const char *ES__RESTRICT format, ...) +{ + int rc; + va_list ap; + char *buf; + va_start (ap, format); + rc = estream_vasprintf (&buf, format, ap); + va_end (ap); + if (rc < 0) + return NULL; + return buf; +} + + +/* A variant of vasprintf. The function returns the allocated buffer + or NULL on error; ERRNO is set in the error case. The caller + should use es_free to release the buffer. This function actually + belongs into estream-printf but we put it here as a convenience + and because es_free is required anyway. */ +char * +es_vasprintf (const char *ES__RESTRICT format, va_list ap) +{ + int rc; + char *buf; + + rc = estream_vasprintf (&buf, format, ap); + if (rc < 0) + return NULL; + return buf; +} + + static int tmpfd (void) { From cvs at cvs.gnupg.org Thu Sep 3 12:57:24 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 Sep 2009 12:57:24 +0200 Subject: [svn] GnuPG - r5143 - trunk/scd Message-ID: Author: wk Date: 2009-09-03 12:57:23 +0200 (Thu, 03 Sep 2009) New Revision: 5143 Modified: trunk/scd/ChangeLog trunk/scd/apdu.c trunk/scd/app-geldkarte.c trunk/scd/app-nks.c trunk/scd/app-openpgp.c trunk/scd/iso7816.c trunk/scd/iso7816.h Log: Fix for extended length Le in decipher Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2009-09-03 10:44:13 UTC (rev 5142) +++ trunk/scd/ChangeLog 2009-09-03 10:57:23 UTC (rev 5143) @@ -1,3 +1,12 @@ +2009-09-03 Werner Koch + + * app-openpgp.c (do_decipher): Compute required Le. + * iso7816.c (iso7816_decipher): Add new arg LE. + * app-nks.c (do_decipher): Adjust for change. + + * iso7816.c (iso7816_put_data, iso7816_put_data_odd): Turn DATA + into a void ptr. + 2009-08-05 Werner Koch * app-openpgp.c (change_keyattr_from_string): New. @@ -138,7 +147,7 @@ (iso7816_generate_keypair, iso7816_read_public_key): Ditto. Changed all callers. * apdu.c (send_le): Implement extended length return values. - + * ccid-driver.c (bulk_in): Retry on EAGAIN. (abort_cmd): Change seqno handling. Modified: trunk/scd/apdu.c =================================================================== --- trunk/scd/apdu.c 2009-09-03 10:44:13 UTC (rev 5142) +++ trunk/scd/apdu.c 2009-09-03 10:57:23 UTC (rev 5143) @@ -15,8 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . - * - * $Id$ */ /* NOTE: This module is also used by other software, thus the use of Modified: trunk/scd/app-geldkarte.c =================================================================== --- trunk/scd/app-geldkarte.c 2009-09-03 10:44:13 UTC (rev 5142) +++ trunk/scd/app-geldkarte.c 2009-09-03 10:57:23 UTC (rev 5143) @@ -274,7 +274,7 @@ gpg_error_t app_select_geldkarte (app_t app) { - static unsigned char const aid[] = + static char const aid[] = { 0xD2, 0x76, 0x00, 0x00, 0x25, 0x45, 0x50, 0x02, 0x00 }; gpg_error_t err; int slot = app->slot; Modified: trunk/scd/app-nks.c =================================================================== --- trunk/scd/app-nks.c 2009-09-03 10:44:13 UTC (rev 5142) +++ trunk/scd/app-nks.c 2009-09-03 10:57:23 UTC (rev 5143) @@ -271,7 +271,8 @@ command[2] = 0x00; command[3] = pwid; - if (apdu_send_direct (app->slot, 0, command, 4, 0, &result, &resultlen)) + if (apdu_send_direct (app->slot, 0, (unsigned char *)command, + 4, 0, &result, &resultlen)) rc = -1; /* Error. */ else if (resultlen < 2) rc = -1; /* Error. */ @@ -1055,7 +1056,7 @@ Command chaining does not work. */ if (!rc) rc = iso7816_decipher (app->slot, app->app_local->nks_version > 2? 1:0, - indata, indatalen, 0x81, + indata, indatalen, 0, 0x81, outdata, outdatalen); return rc; } Modified: trunk/scd/app-openpgp.c =================================================================== --- trunk/scd/app-openpgp.c 2009-09-03 10:44:13 UTC (rev 5142) +++ trunk/scd/app-openpgp.c 2009-09-03 10:57:23 UTC (rev 5143) @@ -16,8 +16,6 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . - * - * $Id$ */ /* Some notes: @@ -3316,7 +3314,7 @@ const char *s; int n; const char *fpr = NULL; - int exmode; + int exmode, le_value; if (!keyidstr || !*keyidstr || !indatalen) return gpg_error (GPG_ERR_INV_VALUE); @@ -3399,16 +3397,22 @@ indatalen = fixuplen + indatalen; padind = -1; /* Already padded. */ } - + if (app->app_local->cardcap.ext_lc_le && indatalen > 254 ) - exmode = 1; /* Extended length w/o a limit. */ + { + exmode = 1; /* Extended length w/o a limit. */ + le_value = app->app_local->extcap.max_rsp_data; + } else if (app->app_local->cardcap.cmd_chaining && indatalen > 254) - exmode = -254; /* Command chaining with max. 254 bytes. */ + { + exmode = -254; /* Command chaining with max. 254 bytes. */ + le_value = 0; + } else - exmode = 0; + exmode = le_value = 0; rc = iso7816_decipher (app->slot, exmode, - indata, indatalen, padind, + indata, indatalen, le_value, padind, outdata, outdatalen); xfree (fixbuf); } Modified: trunk/scd/iso7816.c =================================================================== --- trunk/scd/iso7816.c 2009-09-03 10:44:13 UTC (rev 5142) +++ trunk/scd/iso7816.c 2009-09-03 10:57:23 UTC (rev 5143) @@ -15,8 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . - * - * $Id$ */ #include @@ -460,7 +458,7 @@ bytes. */ gpg_error_t iso7816_put_data (int slot, int extended_mode, int tag, - const unsigned char *data, size_t datalen) + const void *data, size_t datalen) { int sw; @@ -473,7 +471,7 @@ /* Same as iso7816_put_data but uses an odd instruction byte. */ gpg_error_t iso7816_put_data_odd (int slot, int extended_mode, int tag, - const unsigned char *data, size_t datalen) + const void *data, size_t datalen) { int sw; @@ -545,10 +543,11 @@ indicator to be used. It should be 0 if no padding is required, a value of -1 suppresses the padding byte. On success 0 is returned and the plaintext is available in a newly allocated buffer stored - at RESULT with its length stored at RESULTLEN. */ + at RESULT with its length stored at RESULTLEN. For LE see + do_generate_keypair. */ gpg_error_t iso7816_decipher (int slot, int extended_mode, - const unsigned char *data, size_t datalen, + const unsigned char *data, size_t datalen, int le, int padind, unsigned char **result, size_t *resultlen) { int sw; @@ -559,6 +558,11 @@ *result = NULL; *resultlen = 0; + if (!extended_mode) + le = 256; /* Ignore provided Le and use what apdu_send uses. */ + else if (le >= 0 && le < 256) + le = 256; + if (padind >= 0) { /* We need to prepend the padding indicator. */ @@ -568,18 +572,18 @@ *buf = padind; /* Padding indicator. */ memcpy (buf+1, data, datalen); - sw = apdu_send (slot, extended_mode, - 0x00, CMD_PSO, 0x80, 0x86, - datalen+1, (char*)buf, - result, resultlen); + sw = apdu_send_le (slot, extended_mode, + 0x00, CMD_PSO, 0x80, 0x86, + datalen+1, (char*)buf, le, + result, resultlen); xfree (buf); } else { - sw = apdu_send (slot, extended_mode, - 0x00, CMD_PSO, 0x80, 0x86, - datalen, (const char *)data, - result, resultlen); + sw = apdu_send_le (slot, extended_mode, + 0x00, CMD_PSO, 0x80, 0x86, + datalen, (const char *)data, le, + result, resultlen); } if (sw != SW_SUCCESS) { Modified: trunk/scd/iso7816.h =================================================================== --- trunk/scd/iso7816.h 2009-09-03 10:44:13 UTC (rev 5142) +++ trunk/scd/iso7816.h 2009-09-03 10:57:23 UTC (rev 5143) @@ -15,8 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . - * - * $Id$ */ #ifndef ISO7816_H @@ -87,9 +85,9 @@ gpg_error_t iso7816_get_data (int slot, int extended_mode, int tag, unsigned char **result, size_t *resultlen); gpg_error_t iso7816_put_data (int slot, int extended_mode, int tag, - const unsigned char *data, size_t datalen); + const void *data, size_t datalen); gpg_error_t iso7816_put_data_odd (int slot, int extended_mode, int tag, - const unsigned char *data, size_t datalen); + const void *data, size_t datalen); gpg_error_t iso7816_manage_security_env (int slot, int p1, int p2, const unsigned char *data, size_t datalen); @@ -99,7 +97,7 @@ unsigned char **result, size_t *resultlen); gpg_error_t iso7816_decipher (int slot, int extended_mode, const unsigned char *data, size_t datalen, - int padind, + int le, int padind, unsigned char **result, size_t *resultlen); gpg_error_t iso7816_internal_authenticate (int slot, int extended_mode, const unsigned char *data, size_t datalen, From cvs at cvs.gnupg.org Thu Sep 3 13:29:26 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 Sep 2009 13:29:26 +0200 Subject: [svn] GnuPG - r5144 - trunk/g10 Message-ID: Author: wk Date: 2009-09-03 13:29:25 +0200 (Thu, 03 Sep 2009) New Revision: 5144 Modified: trunk/g10/ChangeLog trunk/g10/compress-bz2.c Log: Fix bug#1011. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-09-03 10:57:23 UTC (rev 5143) +++ trunk/g10/ChangeLog 2009-09-03 11:29:25 UTC (rev 5144) @@ -1,3 +1,8 @@ +2009-09-03 Werner Koch + + * compress-bz2.c (do_uncompress): Detect unexpected EOF. Fix + bug#1011. + 2009-08-26 Werner Koch * keyedit.c (menu_revsig): Check for signature right away. Fix @@ -191,7 +196,7 @@ * keygen.c (ask_key_flags): Fix bug in the translation check. Fixes bug#1056. - + 2009-05-18 Daiki Ueno (wk) * encode.c (encode_simple): Tell passphrase_to_dek to cache @@ -826,7 +831,7 @@ * gpg.c (reopen_std): Moved to ../common and renamed to gnupg_reopen_std. - + * gpg.c: Remove second inclusion of fcntl.h. 2007-11-19 Werner Koch @@ -874,7 +879,7 @@ alias to it. --rfc2440 now stands alone. For now, use the old 2440 defaults for 4880. * misc.c (compliance_option_string): Ditto. - + * keyedit.c (keyedit_menu): Use compliance_option_string() instead of printing the compliance modes here. @@ -888,7 +893,7 @@ 2007-10-25 David Shaw (wk) From 1.4 (July): - + * armor.c (parse_header_line): Improve test so that the header test only allows "Hash" in the signed data section. @@ -979,7 +984,6 @@ * gpg.c, gpgv.c: Include sysutils.h. (main): Replace iobuf_translate_file_handle by translate_sys2libc_fd. - 2007-06-21 Werner Koch @@ -994,7 +998,7 @@ * misc.c (setsysinfo, trap_unaligned): Remove. It is also in common/sysutils.c. - (disable_core_dumps, get_session_marker): + (disable_core_dumps, get_session_marker): * sign.c (sleep): Remove sleep wrapper. Modified: trunk/g10/compress-bz2.c =================================================================== --- trunk/g10/compress-bz2.c 2009-09-03 10:57:23 UTC (rev 5143) +++ trunk/g10/compress-bz2.c 2009-09-03 11:29:25 UTC (rev 5144) @@ -118,6 +118,7 @@ size_t n; int nread, count; int refill = !bzs->avail_in; + int eofseen = 0; if( DBG_FILTER ) log_debug("begin bzDecompress: avail_in=%u, avail_out=%u, inbuf=%u\n", @@ -132,13 +133,17 @@ bzs->next_in = zfx->inbuf; count = zfx->inbufsize - n; nread = iobuf_read( a, zfx->inbuf + n, count ); - if( nread == -1 ) nread = 0; + if( nread == -1 ) + { + eofseen = 1; + nread = 0; + } n += nread; bzs->avail_in = n; } + if (!eofseen) + refill = 1; - refill = 1; - if( DBG_FILTER ) log_debug("enter bzDecompress: avail_in=%u, avail_out=%u\n", (unsigned)bzs->avail_in, (unsigned)bzs->avail_out); @@ -151,6 +156,13 @@ rc = -1; /* eof */ else if( zrc != BZ_OK && zrc != BZ_PARAM_ERROR ) log_fatal("bz2lib inflate problem: rc=%d\n", zrc ); + else if (zrc == BZ_OK && eofseen + && !bzs->avail_in && bzs->avail_out > 0) + { + log_error ("unexpected EOF in bz2lib\n"); + rc = GPG_ERR_BAD_DATA; + break; + } } while( bzs->avail_out && zrc != BZ_STREAM_END && zrc != BZ_PARAM_ERROR ); From cvs at cvs.gnupg.org Thu Sep 3 16:08:31 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 Sep 2009 16:08:31 +0200 Subject: [svn] GnuPG - r5145 - in trunk: doc m4 po Message-ID: Author: wk Date: 2009-09-03 16:08:25 +0200 (Thu, 03 Sep 2009) New Revision: 5145 Modified: trunk/doc/ChangeLog trunk/m4/ChangeLog trunk/m4/estream.m4 trunk/po/ChangeLog trunk/po/be.po trunk/po/ca.po trunk/po/cs.po trunk/po/da.po trunk/po/de.po trunk/po/el.po trunk/po/eo.po trunk/po/es.po trunk/po/et.po trunk/po/fi.po trunk/po/fr.po trunk/po/gl.po trunk/po/hu.po trunk/po/id.po trunk/po/it.po trunk/po/ja.po trunk/po/nb.po trunk/po/pl.po trunk/po/pt.po trunk/po/pt_BR.po trunk/po/ro.po trunk/po/ru.po trunk/po/sk.po trunk/po/sv.po trunk/po/tr.po trunk/po/zh_CN.po trunk/po/zh_TW.po Log: Updated the german translation Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-09-03 11:29:25 UTC (rev 5144) +++ trunk/doc/ChangeLog 2009-09-03 14:08:25 UTC (rev 5145) @@ -1,6 +1,6 @@ 2009-08-24 David Shaw - * gpg.text: Suggested new ordering for --edit-key. + * gpg.texi: Suggested new ordering for --edit-key. 2009-08-17 David Shaw Modified: trunk/m4/ChangeLog =================================================================== --- trunk/m4/ChangeLog 2009-09-03 11:29:25 UTC (rev 5144) +++ trunk/m4/ChangeLog 2009-09-03 14:08:25 UTC (rev 5145) @@ -1,3 +1,7 @@ +2009-09-03 Werner Koch + + * estream.m4: Update for limestream. + 2008-04-23 Werner Koch * socklen.m4, sys_socket_h.m4: New. Taken from libassuan. Modified: trunk/po/ChangeLog =================================================================== --- trunk/po/ChangeLog 2009-09-03 11:29:25 UTC (rev 5144) +++ trunk/po/ChangeLog 2009-09-03 14:08:25 UTC (rev 5145) @@ -1,3 +1,11 @@ +2009-09-03 Werner Koch + + * de.po: Translate new strings. + +2009-09-03 Jedi Lin (wk) + + * zh_TW.po: Update. + 2009-07-14 Werner Koch * de.po: s/nicht-exportf?hig/unwiderrufbar/. Reported by Simon Modified: trunk/m4/estream.m4 =================================================================== --- trunk/m4/estream.m4 2009-09-03 11:29:25 UTC (rev 5144) +++ trunk/m4/estream.m4 2009-09-03 14:08:25 UTC (rev 5145) @@ -16,6 +16,7 @@ AC_DEFUN([estream_PRINTF_INIT], [ AC_MSG_NOTICE([checking system features for estream-printf]) + AC_CHECK_HEADERS(stdint.h) AC_TYPE_LONG_LONG_INT AC_TYPE_LONG_DOUBLE AC_TYPE_INTMAX_T Modified: trunk/po/be.po [not shown] Modified: trunk/po/ca.po [not shown] Modified: trunk/po/cs.po [not shown] Modified: trunk/po/da.po [not shown] Modified: trunk/po/de.po [not shown] Modified: trunk/po/el.po [not shown] Modified: trunk/po/eo.po [not shown] Modified: trunk/po/es.po [not shown] Modified: trunk/po/et.po [not shown] Modified: trunk/po/fi.po [not shown] Modified: trunk/po/fr.po [not shown] Modified: trunk/po/gl.po [not shown] Modified: trunk/po/hu.po [not shown] Modified: trunk/po/id.po [not shown] Modified: trunk/po/it.po [not shown] Modified: trunk/po/ja.po [not shown] Modified: trunk/po/nb.po [not shown] Modified: trunk/po/pl.po [not shown] Modified: trunk/po/pt.po [not shown] Modified: trunk/po/pt_BR.po [not shown] Modified: trunk/po/ro.po [not shown] Modified: trunk/po/ru.po [not shown] Modified: trunk/po/sk.po [not shown] Modified: trunk/po/sv.po [not shown] Modified: trunk/po/tr.po [not shown] Modified: trunk/po/zh_CN.po [not shown] Modified: trunk/po/zh_TW.po [not shown] From cvs at cvs.gnupg.org Thu Sep 3 17:27:31 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 Sep 2009 17:27:31 +0200 Subject: [svn] GnuPG - r5146 - in branches/STABLE-BRANCH-1-4: include scripts util Message-ID: Author: wk Date: 2009-09-03 17:27:30 +0200 (Thu, 03 Sep 2009) New Revision: 5146 Modified: branches/STABLE-BRANCH-1-4/include/ChangeLog branches/STABLE-BRANCH-1-4/include/util.h branches/STABLE-BRANCH-1-4/scripts/ChangeLog branches/STABLE-BRANCH-1-4/scripts/w32installer.nsi branches/STABLE-BRANCH-1-4/util/ChangeLog branches/STABLE-BRANCH-1-4/util/argparse.c branches/STABLE-BRANCH-1-4/util/strgutil.c branches/STABLE-BRANCH-1-4/util/ttyio.c Log: Fix a W32 problem Modified: branches/STABLE-BRANCH-1-4/include/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/include/ChangeLog 2009-09-03 14:08:25 UTC (rev 5145) +++ branches/STABLE-BRANCH-1-4/include/ChangeLog 2009-09-03 15:27:30 UTC (rev 5146) @@ -1,3 +1,7 @@ +2009-09-03 Werner Koch + + * util.h (xtryvasprintf): New. + 2009-08-25 Werner Koch * compat.h: Add xstrconcat. Modified: branches/STABLE-BRANCH-1-4/scripts/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/scripts/ChangeLog 2009-09-03 14:08:25 UTC (rev 5145) +++ branches/STABLE-BRANCH-1-4/scripts/ChangeLog 2009-09-03 15:27:30 UTC (rev 5146) @@ -1,3 +1,7 @@ +2009-09-03 Werner Koch + + * w32installer.nsi: Set the final OutPath to Doc/. + 2008-01-30 Werner Koch * w32installer.nsi: Set the OutPath back. Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/util/ChangeLog 2009-09-03 14:08:25 UTC (rev 5145) +++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2009-09-03 15:27:30 UTC (rev 5146) @@ -1,5 +1,8 @@ 2009-09-03 Werner Koch + * ttyio.c (tty_printf) [_WIN32]: s/xtryasprintf/xtryvasprint/ + * strgutil.c (xtryvasprintf): New. + * estream-printf.c: Include stdint.h only if HAVE_STDINT_H is defined. Problem reported by Nelson H. F. Beebe. * estream.m4: Check for stdint.h. Modified: branches/STABLE-BRANCH-1-4/include/util.h =================================================================== --- branches/STABLE-BRANCH-1-4/include/util.h 2009-09-03 14:08:25 UTC (rev 5145) +++ branches/STABLE-BRANCH-1-4/include/util.h 2009-09-03 15:27:30 UTC (rev 5146) @@ -20,9 +20,7 @@ #ifndef G10_UTIL_H #define G10_UTIL_H -#if defined (_WIN32) || defined (__CYGWIN32__) #include -#endif #include "types.h" #include "errors.h" @@ -245,6 +243,7 @@ /*-- strgutil.c --*/ char *xasprintf (const char *fmt, ...); char *xtryasprintf (const char *fmt, ...); +char *xtryvasprintf (const char *fmt, va_list arg_ptr); /*-- pka.c --*/ Modified: branches/STABLE-BRANCH-1-4/scripts/w32installer.nsi =================================================================== --- branches/STABLE-BRANCH-1-4/scripts/w32installer.nsi 2009-09-03 14:08:25 UTC (rev 5145) +++ branches/STABLE-BRANCH-1-4/scripts/w32installer.nsi 2009-09-03 15:27:30 UTC (rev 5146) @@ -352,7 +352,7 @@ ;; # Set the Outpath pack so that the README file can be displayed. - SetOutPath "$INSTDIR" + SetOutPath "$INSTDIR\Doc" SectionEnd ; "-Finish" Modified: branches/STABLE-BRANCH-1-4/util/argparse.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/argparse.c 2009-09-03 14:08:25 UTC (rev 5145) +++ branches/STABLE-BRANCH-1-4/util/argparse.c 2009-09-03 15:27:30 UTC (rev 5146) @@ -917,7 +917,7 @@ break; case 11: p = "foo"; break; case 13: p = "0.0"; break; - case 14: p = "Copyright (C) 2008 Free Software Foundation, Inc."; break; + case 14: p = "Copyright (C) 2009 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: branches/STABLE-BRANCH-1-4/util/strgutil.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/strgutil.c 2009-09-03 14:08:25 UTC (rev 5145) +++ branches/STABLE-BRANCH-1-4/util/strgutil.c 2009-09-03 15:27:30 UTC (rev 5146) @@ -1153,6 +1153,19 @@ } +char * +xtryvasprintf (const char *fmt, va_list arg_ptr) +{ + int rc; + char *buf; + + rc = estream_vasprintf (&buf, fmt, arg_ptr); + if (rc < 0) + return NULL; + return buf; +} + + /**************************************************** ******** locale insensitive ctype functions ******** ****************************************************/ Modified: branches/STABLE-BRANCH-1-4/util/ttyio.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/ttyio.c 2009-09-03 14:08:25 UTC (rev 5145) +++ branches/STABLE-BRANCH-1-4/util/ttyio.c 2009-09-03 15:27:30 UTC (rev 5146) @@ -243,9 +243,9 @@ int n; DWORD nwritten; - buf = xtryasprintf(fmt, arg_ptr); + buf = xtryvasprintf(fmt, arg_ptr); if (!buf) - log_bug("xtryasprintf() failed\n"); + log_bug("xtryvasprintf() failed\n"); n = strlen (buf); if (!WriteConsoleA (con.out, buf, n, &nwritten, NULL)) @@ -291,9 +291,9 @@ int n; DWORD nwritten; - buf = xtryasprintf (fmt, arg_ptr); + buf = xtryvasprintf (fmt, arg_ptr); if (!buf) - log_bug ("xtryasprintf() failed\n"); + log_bug ("xtryvasprintf() failed\n"); n = strlen (buf); if (!WriteConsoleA (con.out, buf, n, &nwritten, NULL)) From cvs at cvs.gnupg.org Thu Sep 3 22:51:59 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 Sep 2009 22:51:59 +0200 Subject: [svn] GnuPG - r5147 - in trunk: g10 po Message-ID: Author: wk Date: 2009-09-03 22:51:55 +0200 (Thu, 03 Sep 2009) New Revision: 5147 Modified: trunk/g10/ChangeLog trunk/g10/Makefile.am trunk/g10/keyedit.c trunk/g10/keygen.c trunk/g10/packet.h trunk/g10/photoid.c trunk/po/be.po trunk/po/ca.po trunk/po/cs.po trunk/po/da.po trunk/po/de.po trunk/po/el.po trunk/po/eo.po trunk/po/es.po trunk/po/et.po trunk/po/fi.po trunk/po/fr.po trunk/po/gl.po trunk/po/hu.po trunk/po/id.po trunk/po/it.po trunk/po/ja.po trunk/po/nb.po trunk/po/pl.po trunk/po/pt.po trunk/po/pt_BR.po trunk/po/ro.po trunk/po/ru.po trunk/po/sk.po trunk/po/sv.po trunk/po/tr.po trunk/po/zh_CN.po trunk/po/zh_TW.po Log: Fix bug#1122. Note that msgmerge 0.17 is completely broken as it always prepends a fuzzy null entry to all po files. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-09-03 15:27:30 UTC (rev 5146) +++ trunk/g10/ChangeLog 2009-09-03 20:51:55 UTC (rev 5147) @@ -1,5 +1,14 @@ 2009-09-03 Werner Koch + * keyedit.c (menu_adduid): Pass keyblock to generate_user_id. + * keygen.c (generate_user_id): Add arg KEYBLOCK. Factor code out + to ... + (uid_from_string): ... new. + (ask_user_id): Add arg KEYBLOCK and check for duplicates. Fix + bug#1122. + + * Makefile.am (uninstall-local): New. + * compress-bz2.c (do_uncompress): Detect unexpected EOF. Fix bug#1011. Modified: trunk/g10/Makefile.am =================================================================== --- trunk/g10/Makefile.am 2009-09-03 15:27:30 UTC (rev 5146) +++ trunk/g10/Makefile.am 2009-09-03 20:51:55 UTC (rev 5147) @@ -137,3 +137,5 @@ $(INSTALL_DATA) $(srcdir)/options.skel \ $(DESTDIR)$(pkgdatadir)/gpg-conf.skel +uninstall-local: + - at rm $(DESTDIR)$(pkgdatadir)/gpg-conf.skel Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2009-09-03 15:27:30 UTC (rev 5146) +++ trunk/g10/keyedit.c 2009-09-03 20:51:55 UTC (rev 5147) @@ -3073,7 +3073,7 @@ uid = generate_photo_id(pk,photo_name); } else - uid = generate_user_id(); + uid = generate_user_id (pub_keyblock); if( !uid ) return 0; Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2009-09-03 15:27:30 UTC (rev 5146) +++ trunk/g10/keygen.c 2009-09-03 20:51:55 UTC (rev 5147) @@ -2017,8 +2017,28 @@ } + +static PKT_user_id * +uid_from_string (const char *string) +{ + size_t n; + PKT_user_id *uid; + + n = strlen (string); + uid = xmalloc_clear (sizeof *uid + n); + uid->len = n; + strcpy (uid->name, string); + uid->ref = 1; + return uid; +} + + +/* Ask for a user ID. With a MODE of 1 an extra help prompt is + printed for use during a new key creation. If KEYBLOCK is not NULL + the function prevents the creation of an already existing user + ID. */ static char * -ask_user_id( int mode ) +ask_user_id (int mode, KBNODE keyblock) { char *answer; char *aname, *acomment, *amail, *uid; @@ -2134,14 +2154,29 @@ } tty_printf(_("You selected this USER-ID:\n \"%s\"\n\n"), uid); - /* fixme: add a warning if this user-id already exists */ + if( !*amail && !opt.allow_freeform_uid && (strchr( aname, '@' ) || strchr( acomment, '@'))) { fail = 1; - tty_printf(_("Please don't put the email address " - "into the real name or the comment\n") ); + tty_printf(_("Please don't put the email address " + "into the real name or the comment\n") ); } + if (!fail && keyblock) + { + PKT_user_id *uidpkt = uid_from_string (uid); + KBNODE node; + + for (node=keyblock; node && !fail; node=node->next) + if (!is_deleted_kbnode (node) + && node->pkt->pkttype == PKT_USER_ID + && !cmp_user_ids (uidpkt, node->pkt->pkt.user_id)) + fail = 1; + if (fail) + tty_printf (_("Such a user ID already exists on this key!\n")); + free_user_id (uidpkt); + } + for(;;) { /* TRANSLATORS: These are the allowed answers in lower and uppercase. Below you will find the matching @@ -2296,25 +2331,18 @@ } -/**************** - * Generate a new user id packet, or return NULL if canceled - */ +/* Generate a new user id packet or return NULL if canceled. If + KEYBLOCK is not NULL the function prevents the creation of an + already existing user ID. */ PKT_user_id * -generate_user_id() +generate_user_id (KBNODE keyblock) { - PKT_user_id *uid; - char *p; - size_t n; - - p = ask_user_id( 1 ); - if( !p ) - return NULL; - n = strlen(p); - uid = xmalloc_clear( sizeof *uid + n ); - uid->len = n; - strcpy(uid->name, p); - uid->ref = 1; - return uid; + char *p; + + p = ask_user_id (1, keyblock); + if (!p) + return NULL; /* Canceled. */ + return uid_from_string (p); } @@ -3143,7 +3171,7 @@ r->next = para; para = r; - uid = ask_user_id(0); + uid = ask_user_id (0, NULL); if( !uid ) { log_error(_("Key generation canceled.\n")); Modified: trunk/g10/packet.h =================================================================== --- trunk/g10/packet.h 2009-09-03 15:27:30 UTC (rev 5146) +++ trunk/g10/packet.h 2009-09-03 20:51:55 UTC (rev 5147) @@ -509,6 +509,6 @@ void *opaque ); /*-- keygen.c --*/ -PKT_user_id *generate_user_id(void); +PKT_user_id *generate_user_id (KBNODE keyblock); #endif /*G10_PACKET_H*/ Modified: trunk/g10/photoid.c =================================================================== --- trunk/g10/photoid.c 2009-09-03 15:27:30 UTC (rev 5146) +++ trunk/g10/photoid.c 2009-09-03 20:51:55 UTC (rev 5147) @@ -42,7 +42,8 @@ #include "ttyio.h" #include "trustdb.h" -/* Generate a new photo id packet, or return NULL if canceled */ +/* Generate a new photo id packet, or return NULL if canceled. + FIXME: Should we add a duplicates check similar to generate_user_id? */ PKT_user_id * generate_photo_id(PKT_public_key *pk,const char *photo_name) { Modified: trunk/po/be.po [not shown] Modified: trunk/po/ca.po [not shown] Modified: trunk/po/cs.po [not shown] Modified: trunk/po/da.po [not shown] Modified: trunk/po/de.po [not shown] Modified: trunk/po/el.po [not shown] Modified: trunk/po/eo.po [not shown] Modified: trunk/po/es.po [not shown] Modified: trunk/po/et.po [not shown] Modified: trunk/po/fi.po [not shown] Modified: trunk/po/fr.po [not shown] Modified: trunk/po/gl.po [not shown] Modified: trunk/po/hu.po [not shown] Modified: trunk/po/id.po [not shown] Modified: trunk/po/it.po [not shown] Modified: trunk/po/ja.po [not shown] Modified: trunk/po/nb.po [not shown] Modified: trunk/po/pl.po [not shown] Modified: trunk/po/pt.po [not shown] Modified: trunk/po/pt_BR.po [not shown] Modified: trunk/po/ro.po [not shown] Modified: trunk/po/ru.po [not shown] Modified: trunk/po/sk.po [not shown] Modified: trunk/po/sv.po [not shown] Modified: trunk/po/tr.po [not shown] Modified: trunk/po/zh_CN.po [not shown] Modified: trunk/po/zh_TW.po [not shown] From cvs at cvs.gnupg.org Fri Sep 4 13:52:04 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 13:52:04 +0200 Subject: [svn] GnuPG - r5148 - in trunk: doc g10 Message-ID: Author: wk Date: 2009-09-04 13:52:03 +0200 (Fri, 04 Sep 2009) New Revision: 5148 Modified: trunk/doc/gpg.texi trunk/g10/ChangeLog trunk/g10/keyedit.c Log: Allow uid sand key election using a '*'. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-09-03 20:51:55 UTC (rev 5147) +++ trunk/g10/ChangeLog 2009-09-04 11:52:03 UTC (rev 5148) @@ -1,3 +1,9 @@ +2009-09-04 Werner Koch + + * keyedit.c (menu_select_uid): Use IDX ==-1 t select all. + (menu_select_key): Ditto. + (keyedit_menu) : Allow '*' to select all. + 2009-09-03 Werner Koch * keyedit.c (menu_adduid): Pass keyblock to generate_user_id. Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2009-09-03 20:51:55 UTC (rev 5147) +++ trunk/doc/gpg.texi 2009-09-04 11:52:03 UTC (rev 5148) @@ -592,12 +592,12 @@ @item uid @code{n} @opindex keyedit:uid Toggle selection of user ID or photographic user ID with index @code{n}. -Use 0 to deselect all. +Use @code{*} to select all and @code{0} to deselect all. @item key @code{n} @opindex keyedit:key Toggle selection of subkey with index @code{n}. -Use 0 to deselect all. +Use @code{*} to select all and @code{0} to deselect all. @item sign @opindex keyedit:sign Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2009-09-03 20:51:55 UTC (rev 5147) +++ trunk/g10/keyedit.c 2009-09-04 11:52:03 UTC (rev 5148) @@ -1,6 +1,6 @@ /* keyedit.c - keyedit stuff * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - * 2008 Free Software Foundation, Inc. + * 2008, 2009 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1743,12 +1743,22 @@ if(strlen(arg_string)==NAMEHASH_LEN*2) redisplay=menu_select_uid_namehash(cur_keyblock,arg_string); else - redisplay=menu_select_uid(cur_keyblock,arg_number); + { + if (*arg_string == '*' + && (!arg_string[1] || spacep (arg_string+1))) + arg_number = -1; /* Select all. */ + redisplay = menu_select_uid (cur_keyblock, arg_number); + } break; case cmdSELKEY: - if( menu_select_key( cur_keyblock, arg_number ) ) + { + if (*arg_string == '*' + && (!arg_string[1] || spacep (arg_string+1))) + arg_number = -1; /* Select all. */ + if (menu_select_key( cur_keyblock, arg_number)) redisplay = 1; + } break; case cmdCHECK: @@ -4437,51 +4447,62 @@ } -/**************** - * Select one user id or remove all selection if index is 0. - * Returns: True if the selection changed; +/* + * Select one user id or remove all selection if IDX is 0 or select + * all if IDX is -1. Returns: True if the selection changed. */ static int -menu_select_uid( KBNODE keyblock, int idx ) +menu_select_uid (KBNODE keyblock, int idx) { - KBNODE node; - int i; - - /* first check that the index is valid */ - if( idx ) { - for( i=0, node = keyblock; node; node = node->next ) { - if( node->pkt->pkttype == PKT_USER_ID ) { - if( ++i == idx ) - break; - } + KBNODE node; + int i; + + if (idx == -1) /* Select all. */ + { + for (node = keyblock; node; node = node->next) + if (node->pkt->pkttype == PKT_USER_ID) + node->flag |= NODFLG_SELUID; + return 1; + } + else if (idx) /* Toggle. */ + { + for (i=0, node = keyblock; node; node = node->next) + { + if (node->pkt->pkttype == PKT_USER_ID) + if (++i == idx) + break; } - if( !node ) { - tty_printf(_("No user ID with index %d\n"), idx ); - return 0; + if (!node) + { + tty_printf (_("No user ID with index %d\n"), idx ); + return 0; } + + for (i=0, node = keyblock; node; node = node->next) + { + if (node->pkt->pkttype == PKT_USER_ID) + { + if (++i == idx) + { + if ((node->flag & NODFLG_SELUID)) + node->flag &= ~NODFLG_SELUID; + else + node->flag |= NODFLG_SELUID; + } + } + } } - else { /* reset all */ - for (node = keyblock; node; node = node->next) { - if( node->pkt->pkttype == PKT_USER_ID ) - node->flag &= ~NODFLG_SELUID; - } - return 1; + else /* Unselect all */ + { + for (node = keyblock; node; node = node->next) + if (node->pkt->pkttype == PKT_USER_ID) + node->flag &= ~NODFLG_SELUID; } - /* and toggle the new index */ - for( i=0, node = keyblock; node; node = node->next ) { - if( node->pkt->pkttype == PKT_USER_ID ) { - if( ++i == idx ) { - if( (node->flag & NODFLG_SELUID) ) - node->flag &= ~NODFLG_SELUID; - else - node->flag |= NODFLG_SELUID; - } - } - } - - return 1; + + return 1; } + /* Search in the keyblock for a uid that matches namehash */ static int menu_select_uid_namehash( KBNODE keyblock, const char *namehash ) @@ -4523,50 +4544,58 @@ /**************** * Select secondary keys - * Returns: True if the selection changed; + * Returns: True if the selection changed. */ static int -menu_select_key( KBNODE keyblock, int idx ) +menu_select_key (KBNODE keyblock, int idx) { - KBNODE node; - int i; + KBNODE node; + int i; - /* first check that the index is valid */ - if( idx ) { - for( i=0, node = keyblock; node; node = node->next ) { - if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY - || node->pkt->pkttype == PKT_SECRET_SUBKEY ) { - if( ++i == idx ) - break; - } - } - if( !node ) { - tty_printf(_("No subkey with index %d\n"), idx ); - return 0; - } + if (idx == -1) /* Select all. */ + { + for (node = keyblock; node; node = node->next) + if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY + || node->pkt->pkttype == PKT_SECRET_SUBKEY) + node->flag |= NODFLG_SELKEY; } - else { /* reset all */ - for ( node = keyblock; node; node = node->next ) { - if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY - || node->pkt->pkttype == PKT_SECRET_SUBKEY ) - node->flag &= ~NODFLG_SELKEY; - } - return 1; + else if (idx) /* Toggle selection. */ + { + for (i=0, node = keyblock; node; node = node->next) + { + if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY + || node->pkt->pkttype == PKT_SECRET_SUBKEY) + if (++i == idx) + break; + } + if (!node) + { + tty_printf (_("No subkey with index %d\n"), idx ); + return 0; + } + + for (i=0, node = keyblock; node; node = node->next) + { + if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY + || node->pkt->pkttype == PKT_SECRET_SUBKEY ) + if (++i == idx) + { + if ((node->flag & NODFLG_SELKEY)) + node->flag &= ~NODFLG_SELKEY; + else + node->flag |= NODFLG_SELKEY; + } + } } - /* and set the new index */ - for( i=0, node = keyblock; node; node = node->next ) { - if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY - || node->pkt->pkttype == PKT_SECRET_SUBKEY ) { - if( ++i == idx ) { - if( (node->flag & NODFLG_SELKEY) ) - node->flag &= ~NODFLG_SELKEY; - else - node->flag |= NODFLG_SELKEY; - } - } + else /* Unselect all. */ + { + for (node = keyblock; node; node = node->next) + if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY + || node->pkt->pkttype == PKT_SECRET_SUBKEY) + node->flag &= ~NODFLG_SELKEY; } - return 1; + return 1; } From cvs at cvs.gnupg.org Fri Sep 4 15:38:20 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 15:38:20 +0200 Subject: [svn] GnuPG - r5149 - in trunk: . po Message-ID: Author: wk Date: 2009-09-04 15:38:16 +0200 (Fri, 04 Sep 2009) New Revision: 5149 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac trunk/po/be.po trunk/po/ca.po trunk/po/cs.po trunk/po/da.po trunk/po/de.po trunk/po/el.po trunk/po/eo.po trunk/po/es.po trunk/po/et.po trunk/po/fi.po trunk/po/fr.po trunk/po/gl.po trunk/po/hu.po trunk/po/id.po trunk/po/it.po trunk/po/ja.po trunk/po/nb.po trunk/po/pl.po trunk/po/pt.po trunk/po/pt_BR.po trunk/po/ro.po trunk/po/ru.po trunk/po/sk.po trunk/po/sv.po trunk/po/tr.po trunk/po/zh_CN.po trunk/po/zh_TW.po Log: preparae release Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-04 11:52:03 UTC (rev 5148) +++ trunk/ChangeLog 2009-09-04 13:38:16 UTC (rev 5149) @@ -1,3 +1,7 @@ +2009-09-04 Werner Koch + + Release 2.0.13. + 2009-06-29 Werner Koch * configure.ac: Take care of --without-adns. Suggested by @@ -5,7 +9,7 @@ 2009-06-17 Werner Koch - Released 2.0.12. + Release 2.0.12. 2009-06-05 David Shaw Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-09-04 11:52:03 UTC (rev 5148) +++ trunk/NEWS 2009-09-04 13:38:16 UTC (rev 5149) @@ -1,4 +1,4 @@ -Noteworthy changes in version 2.0.13 +Noteworthy changes in version 2.0.13 (2009-09-04) ------------------------------------------------- * GPG now generates 2048 bit RSA keys by default. The default hash Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-09-04 11:52:03 UTC (rev 5148) +++ trunk/configure.ac 2009-09-04 13:38:16 UTC (rev 5149) @@ -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.13]) -m4_define([my_issvn], [yes]) +m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \ | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) Modified: trunk/po/be.po [not shown] Modified: trunk/po/ca.po [not shown] Modified: trunk/po/cs.po [not shown] Modified: trunk/po/da.po [not shown] Modified: trunk/po/de.po [not shown] Modified: trunk/po/el.po [not shown] Modified: trunk/po/eo.po [not shown] Modified: trunk/po/es.po [not shown] Modified: trunk/po/et.po [not shown] Modified: trunk/po/fi.po [not shown] Modified: trunk/po/fr.po [not shown] Modified: trunk/po/gl.po [not shown] Modified: trunk/po/hu.po [not shown] Modified: trunk/po/id.po [not shown] Modified: trunk/po/it.po [not shown] Modified: trunk/po/ja.po [not shown] Modified: trunk/po/nb.po [not shown] Modified: trunk/po/pl.po [not shown] Modified: trunk/po/pt.po [not shown] Modified: trunk/po/pt_BR.po [not shown] Modified: trunk/po/ro.po [not shown] Modified: trunk/po/ru.po [not shown] Modified: trunk/po/sk.po [not shown] Modified: trunk/po/sv.po [not shown] Modified: trunk/po/tr.po [not shown] Modified: trunk/po/zh_CN.po [not shown] Modified: trunk/po/zh_TW.po [not shown] From cvs at cvs.gnupg.org Fri Sep 4 18:03:27 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 18:03:27 +0200 Subject: [svn] GnuPG - r5150 - trunk/po Message-ID: Author: wk Date: 2009-09-04 18:03:23 +0200 (Fri, 04 Sep 2009) New Revision: 5150 Modified: trunk/po/be.po trunk/po/ca.po trunk/po/cs.po trunk/po/da.po trunk/po/de.po trunk/po/el.po trunk/po/eo.po trunk/po/es.po trunk/po/et.po trunk/po/fi.po trunk/po/fr.po trunk/po/gl.po trunk/po/hu.po trunk/po/id.po trunk/po/it.po trunk/po/ja.po trunk/po/nb.po trunk/po/pl.po trunk/po/pt.po trunk/po/pt_BR.po trunk/po/ro.po trunk/po/ru.po trunk/po/sk.po trunk/po/sv.po trunk/po/tr.po trunk/po/zh_CN.po trunk/po/zh_TW.po Log: From cvs at cvs.gnupg.org Fri Sep 4 18:06:59 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 18:06:59 +0200 Subject: [svn] GnuPG - r5151 - in trunk: m4 po Message-ID: Author: wk Date: 2009-09-04 18:06:56 +0200 (Fri, 04 Sep 2009) New Revision: 5151 Modified: trunk/m4/ChangeLog trunk/po/be.po trunk/po/ca.po trunk/po/cs.po trunk/po/da.po trunk/po/de.po trunk/po/el.po trunk/po/eo.po trunk/po/es.po trunk/po/et.po trunk/po/fi.po trunk/po/fr.po trunk/po/gl.po trunk/po/hu.po trunk/po/id.po trunk/po/it.po trunk/po/ja.po trunk/po/nb.po trunk/po/pl.po trunk/po/pt.po trunk/po/pt_BR.po trunk/po/ro.po trunk/po/ru.po trunk/po/sk.po trunk/po/sv.po trunk/po/tr.po trunk/po/zh_CN.po trunk/po/zh_TW.po Log: From cvs at cvs.gnupg.org Fri Sep 4 19:11:38 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 19:11:38 +0200 Subject: [svn] GnuPG - r5152 - trunk Message-ID: Author: wk Date: 2009-09-04 19:11:38 +0200 (Fri, 04 Sep 2009) New Revision: 5152 Modified: trunk/README.maint Log: Add a gotcha section after trapped again. Modified: trunk/README.maint =================================================================== --- trunk/README.maint 2009-09-04 16:06:56 UTC (rev 5151) +++ trunk/README.maint 2009-09-04 17:11:38 UTC (rev 5152) @@ -53,6 +53,18 @@ * Write an announcement. Update https://savannah.gnu.org/projects/gnupg . +Gotchas +======= +- If during "make distcheck" you get an error about a permission + problem moving foo.new.po to foo.po; this is caused by a check + whether the po files can be re-created. Now if the first tarball + has been created in a different top directory and if there exists a + no distributed file with the string "GNU gnupg" (e.g. a log file + from running make) you end up with different comments in the po + files. Check out /usr/lib/gettext/project-id for that silliness. + + + From cvs at cvs.gnupg.org Fri Sep 4 19:12:56 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 19:12:56 +0200 Subject: [svn] GnuPG - r5153 - trunk/po Message-ID: Author: wk Date: 2009-09-04 19:12:53 +0200 (Fri, 04 Sep 2009) New Revision: 5153 Modified: trunk/po/be.po trunk/po/ca.po trunk/po/cs.po trunk/po/da.po trunk/po/de.po trunk/po/el.po trunk/po/eo.po trunk/po/es.po trunk/po/et.po trunk/po/fi.po trunk/po/fr.po trunk/po/gl.po trunk/po/hu.po trunk/po/id.po trunk/po/it.po trunk/po/ja.po trunk/po/nb.po trunk/po/pl.po trunk/po/pt.po trunk/po/pt_BR.po trunk/po/ro.po trunk/po/ru.po trunk/po/sk.po trunk/po/sv.po trunk/po/tr.po trunk/po/zh_CN.po trunk/po/zh_TW.po Log: Arggg. gettext again Modified: trunk/po/be.po [not shown] Modified: trunk/po/ca.po [not shown] Modified: trunk/po/cs.po [not shown] Modified: trunk/po/da.po [not shown] Modified: trunk/po/de.po [not shown] Modified: trunk/po/el.po [not shown] Modified: trunk/po/eo.po [not shown] Modified: trunk/po/es.po [not shown] Modified: trunk/po/et.po [not shown] Modified: trunk/po/fi.po [not shown] Modified: trunk/po/fr.po [not shown] Modified: trunk/po/gl.po [not shown] Modified: trunk/po/hu.po [not shown] Modified: trunk/po/id.po [not shown] Modified: trunk/po/it.po [not shown] Modified: trunk/po/ja.po [not shown] Modified: trunk/po/nb.po [not shown] Modified: trunk/po/pl.po [not shown] Modified: trunk/po/pt.po [not shown] Modified: trunk/po/pt_BR.po [not shown] Modified: trunk/po/ro.po [not shown] Modified: trunk/po/ru.po [not shown] Modified: trunk/po/sk.po [not shown] Modified: trunk/po/sv.po [not shown] Modified: trunk/po/tr.po [not shown] Modified: trunk/po/zh_CN.po [not shown] Modified: trunk/po/zh_TW.po [not shown] From cvs at cvs.gnupg.org Fri Sep 4 19:21:40 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 19:21:40 +0200 Subject: [svn] GnuPG - r5154 - trunk Message-ID: Author: wk Date: 2009-09-04 19:21:40 +0200 (Fri, 04 Sep 2009) New Revision: 5154 Modified: trunk/README.maint trunk/configure.ac Log: Avoid catch-22 with README.main not being distributed but having the project-id marker string. Modified: trunk/README.maint =================================================================== --- trunk/README.maint 2009-09-04 17:12:53 UTC (rev 5153) +++ trunk/README.maint 2009-09-04 17:21:40 UTC (rev 5154) @@ -53,6 +53,7 @@ * Write an announcement. Update https://savannah.gnu.org/projects/gnupg . + Gotchas ======= @@ -63,8 +64,8 @@ no distributed file with the string "GNU gnupg" (e.g. a log file from running make) you end up with different comments in the po files. Check out /usr/lib/gettext/project-id for that silliness. + As a hack we added this string into configure.ac. - Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-09-04 17:12:53 UTC (rev 5153) +++ trunk/configure.ac 2009-09-04 17:21:40 UTC (rev 5154) @@ -919,6 +919,9 @@ # # Check for gettext # +# This is "GNU gnupg" - The project-id script from gettext +# needs this string +# AC_MSG_NOTICE([checking for gettext]) AM_PO_SUBDIRS AM_GNU_GETTEXT_VERSION([0.17]) From cvs at cvs.gnupg.org Fri Sep 4 19:39:50 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 04 Sep 2009 19:39:50 +0200 Subject: [svn] GnuPG - r5155 - trunk/agent Message-ID: Author: marcus Date: 2009-09-04 19:39:50 +0200 (Fri, 04 Sep 2009) New Revision: 5155 Modified: trunk/agent/ChangeLog trunk/agent/command.c Log: 2009-09-04 Marcus Brinkmann * command.c (start_command_handler): Add comment about gap in implementation (in dead code), for future reference. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-09-04 17:21:40 UTC (rev 5154) +++ trunk/agent/ChangeLog 2009-09-04 17:39:50 UTC (rev 5155) @@ -1,3 +1,8 @@ +2009-09-04 Marcus Brinkmann + + * command.c (start_command_handler): Add comment about gap in + implementation (in dead code), for future reference. + 2009-08-11 Werner Koch * divert-scd.c (ask_for_card): I18n a prompt string. Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-09-04 17:21:40 UTC (rev 5154) +++ trunk/agent/command.c 2009-09-04 17:39:50 UTC (rev 5155) @@ -1895,6 +1895,8 @@ else if (listen_fd != GNUPG_INVALID_FD) { rc = assuan_init_socket_server_ext (&ctx, listen_fd, 0); + /* FIXME: Need to call assuan_sock_set_nonce for Windows. But + this branch is currently not used. */ } else { From cvs at cvs.gnupg.org Fri Sep 4 19:49:21 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 19:49:21 +0200 Subject: [svn] GnuPG - r5156 - tags Message-ID: Author: wk Date: 2009-09-04 19:49:21 +0200 (Fri, 04 Sep 2009) New Revision: 5156 Added: tags/gnupg-2.0.13/ Log: Release tag From cvs at cvs.gnupg.org Fri Sep 4 19:52:40 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 Sep 2009 19:52:40 +0200 Subject: [svn] GnuPG - r5157 - trunk Message-ID: Author: wk Date: 2009-09-04 19:52:40 +0200 (Fri, 04 Sep 2009) New Revision: 5157 Modified: trunk/NEWS trunk/configure.ac Log: Post release version bumb Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-09-04 17:49:21 UTC (rev 5156) +++ trunk/NEWS 2009-09-04 17:52:40 UTC (rev 5157) @@ -1,3 +1,7 @@ +Noteworthy changes in version 2.0.14 +------------------------------------------------- + + Noteworthy changes in version 2.0.13 (2009-09-04) ------------------------------------------------- Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-09-04 17:49:21 UTC (rev 5156) +++ trunk/configure.ac 2009-09-04 17:52:40 UTC (rev 5157) @@ -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.13]) -m4_define([my_issvn], [no]) +m4_define([my_version], [2.0.14]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \ | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) From cvs at cvs.gnupg.org Sat Sep 5 20:07:01 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Sat, 05 Sep 2009 20:07:01 +0200 Subject: [svn] GnuPG - r5158 - branches/STABLE-BRANCH-1-4/scripts Message-ID: Author: wk Date: 2009-09-05 20:07:00 +0200 (Sat, 05 Sep 2009) New Revision: 5158 Modified: branches/STABLE-BRANCH-1-4/scripts/ChangeLog branches/STABLE-BRANCH-1-4/scripts/autogen.sh branches/STABLE-BRANCH-1-4/scripts/mk-w32-dist branches/STABLE-BRANCH-1-4/scripts/w32installer.nsi Log: Make it easier to distribute bzip2 Modified: branches/STABLE-BRANCH-1-4/scripts/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/scripts/ChangeLog 2009-09-04 17:52:40 UTC (rev 5157) +++ branches/STABLE-BRANCH-1-4/scripts/ChangeLog 2009-09-05 18:07:00 UTC (rev 5158) @@ -1,3 +1,7 @@ +2009-09-05 Werner Koch + + * autogen.sh <--build-w32>: Pass --with-bzip2. + 2009-09-03 Werner Koch * w32installer.nsi: Set the final OutPath to Doc/. Modified: branches/STABLE-BRANCH-1-4/scripts/autogen.sh =================================================================== --- branches/STABLE-BRANCH-1-4/scripts/autogen.sh 2009-09-04 17:52:40 UTC (rev 5157) +++ branches/STABLE-BRANCH-1-4/scripts/autogen.sh 2009-09-05 18:07:00 UTC (rev 5158) @@ -51,6 +51,9 @@ fi build=`$tsdir/scripts/config.guess` + [ -z "$w32root" ] && w32root="$HOME/w32root" + echo "Using $w32root as standard install directory" >&2 + # Locate the cross compiler crossbindir= for host in i586-mingw32msvc i386-mingw32msvc; do @@ -92,6 +95,7 @@ [ $DIE = yes ] && exit 1 $tsdir/configure ${conf_CC} --build=${build} --host=${host} \ + --with-bzip2=${w32root} \ ${disable_foo_tests} $* exit $? fi Modified: branches/STABLE-BRANCH-1-4/scripts/mk-w32-dist =================================================================== --- branches/STABLE-BRANCH-1-4/scripts/mk-w32-dist 2009-09-04 17:52:40 UTC (rev 5157) +++ branches/STABLE-BRANCH-1-4/scripts/mk-w32-dist 2009-09-05 18:07:00 UTC (rev 5158) @@ -142,7 +142,7 @@ todos README-W32.txt patches_defs= -for i in `find "$topdir/patches" -type f -name '*.diff'`; do +for i in `find "$topdir/patches" -type f \( -name '*.diff' -o -name '*.tar.gz' \)`; do cp $i . patches_defs="-DWITH_PATCHES" done Modified: branches/STABLE-BRANCH-1-4/scripts/w32installer.nsi =================================================================== --- branches/STABLE-BRANCH-1-4/scripts/w32installer.nsi 2009-09-04 17:52:40 UTC (rev 5157) +++ branches/STABLE-BRANCH-1-4/scripts/w32installer.nsi 2009-09-05 18:07:00 UTC (rev 5158) @@ -229,6 +229,7 @@ !ifdef WITH_PATCHES SetOutPath "$INSTDIR\Src" File '*.diff' + File '*.tar.gz' !endif SectionEnd ; Section Documentation From cvs at cvs.gnupg.org Tue Sep 8 18:47:28 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 08 Sep 2009 18:47:28 +0200 Subject: [svn] assuan - r302 - in trunk: . m4 Message-ID: Author: marcus Date: 2009-09-08 18:47:28 +0200 (Tue, 08 Sep 2009) New Revision: 302 Added: trunk/m4/gpg-error.m4 Modified: trunk/ChangeLog Log: 2009-09-08 Marcus Brinkmann * m4/gpg-error.m4: New file. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-01 17:19:45 UTC (rev 301) +++ trunk/ChangeLog 2009-09-08 16:47:28 UTC (rev 302) @@ -1,3 +1,7 @@ +2009-09-08 Marcus Brinkmann + + * m4/gpg-error.m4: New file. + 2009-09-01 Marcus Brinkmann * configure.ac: Set BUILD_REVISION and update calculation of data Added: trunk/m4/gpg-error.m4 =================================================================== --- trunk/m4/gpg-error.m4 (rev 0) +++ trunk/m4/gpg-error.m4 2009-09-08 16:47:28 UTC (rev 302) @@ -0,0 +1,65 @@ +# gpg-error.m4 - autoconf macro to detect libgpg-error. +# Copyright (C) 2002, 2003, 2004 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. + +dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) +dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS +dnl +AC_DEFUN([AM_PATH_GPG_ERROR], +[ AC_ARG_WITH(gpg-error-prefix, + AC_HELP_STRING([--with-gpg-error-prefix=PFX], + [prefix where GPG Error is installed (optional)]), + gpg_error_config_prefix="$withval", gpg_error_config_prefix="") + if test x$gpg_error_config_prefix != x ; then + if test x${GPG_ERROR_CONFIG+set} != xset ; then + GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config + fi + fi + + AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no) + min_gpg_error_version=ifelse([$1], ,0.0,$1) + AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version) + ok=no + if test "$GPG_ERROR_CONFIG" != "no" ; then + req_major=`echo $min_gpg_error_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` + req_minor=`echo $min_gpg_error_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` + gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version` + major=`echo $gpg_error_config_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` + minor=`echo $gpg_error_config_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` + if test "$major" -gt "$req_major"; then + ok=yes + else + if test "$major" -eq "$req_major"; then + if test "$minor" -ge "$req_minor"; then + ok=yes + fi + fi + fi + fi + if test $ok = yes; then + GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags` + GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs` + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + GPG_ERROR_CFLAGS="" + GPG_ERROR_LIBS="" + AC_MSG_RESULT(no) + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GPG_ERROR_CFLAGS) + AC_SUBST(GPG_ERROR_LIBS) +]) + From cvs at cvs.gnupg.org Mon Sep 21 03:08:08 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 21 Sep 2009 03:08:08 +0200 Subject: [svn] assuan - r303 - in trunk: . doc src tests Message-ID: Author: marcus Date: 2009-09-21 03:08:08 +0200 (Mon, 21 Sep 2009) New Revision: 303 Added: trunk/src/assuan.c trunk/src/context.c trunk/src/conversion.c trunk/src/debug.c trunk/src/debug.h trunk/src/system.c Modified: trunk/ChangeLog trunk/NEWS trunk/TODO trunk/configure.ac trunk/doc/ChangeLog trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/assuan-buffer.c trunk/src/assuan-client.c trunk/src/assuan-connect.c trunk/src/assuan-defs.h trunk/src/assuan-error.c trunk/src/assuan-handler.c trunk/src/assuan-inquire.c trunk/src/assuan-io-pth.c trunk/src/assuan-io.c trunk/src/assuan-listen.c trunk/src/assuan-logging.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-pipe-server.c trunk/src/assuan-socket-connect.c trunk/src/assuan-socket-server.c trunk/src/assuan-uds.c trunk/src/assuan-util.c trunk/src/assuan.h trunk/src/libassuan.def trunk/src/libassuan.vers trunk/tests/fdpassing.c Log: 2009-09-19 Marcus Brinkmann * tests/fdpassing.c: Update to new API. * configure.ac: Check for stdint.h and inttypes.h. Invoke AC_TYPE_UINTPTR_T. doc/ 2009-09-21 Marcus Brinkmann * assuan.texi: Update to new API. src/ 2009-09-19 Marcus Brinkmann * src/libassuan.vers, src/libassuan.def: Update to new API. * assuan.c, context.c, system.c, debug.c: New files. * Makefile.am (common_sources): Add assuan.c, context.c, system.c and debug.c. * assuan.h: Include . Fix inclusion of . (_ASSUAN_EXT_SYM_PREFIX, _ASSUAN_PREFIX1, _ASSUAN_PREFIX2) (_ASSUAN_PREFIX): Remove support for renaming the whole library, now that we have a stable shared library interface that can evolve to cover all needs (particularly those of GPGME). (assuan_malloc_hooks, assuan_malloc_hooks_t, assuan_log_cb_t) (assuan_io_monitor_t): New types. (ASSUAN_LOG_INIT, ASSUAN_LOG_CTX, ASSUAN_LOG_ENGINE) (ASSUAN_LOG_DATA, ASSUAN_LOG_SYSIO, ASSUAN_IO_FROM_PEER) (ASSUAN_IO_TO_PEER, ASSUAN_IO_MONITOR_NOLOG) (ASSUAN_IO_MONITOR_IGNORE): New symbols. (assuan_set_gpg_err_source, assuan_get_gpg_err_source) (assuan_get_malloc_hooks, assuan_set_log_cb, assuan_get_log_cb) (assuan_new, assuan_new_ext, assuan_release): New function prototypes. (assuan_init_pipe_server, assuan_init_socket_server) (assuan_init_socket_server_ext, assuan_pipe_connect) (assuan_pipe_connect_ext, assuan_socket_connect) (assuan_socket_connect_ext): Take a context argument instead of pointer to context. (assuan_deinit_server, assuan_disconnect) (assuan_set_assuan_err_source): Remove function prototypes. * assuan-defs.h (ASSUAN_GCC_A_PURE): Moved here from XXX (_assuan_error): New macro. (struct assuan_context_s): New members err_source, w32_strerror, malloc_hooks, log_cb, log_cb_data: New members. Move confidential into flags. New member engine. (_assuan_log_handler, _assuan_error_default, _assuan_disconnect): New prototypes. (_assuan_new_context): Remove prototype. (_assuan_malloc, _assuan_calloc, _assuan_realloc, _assuan_free): Add context argument to prototype. * assuan-util.c (alloc_func, realloc_func, free_func): Remove global variables. (assuan_set_malloc_hooks, _assuan_malloc, _assuan_realloc) (_assuan_calloc, _assuan_free, assuan_set_pointer) (assuan_get_pointer, assuan_begin_confidential) (assuan_end_confidential, assuan_set_io_monitor, assuan_set_flag) (assuan_get_flag): Move functions to ... * assuan-client.c: Add ctx argument to all invocations of _assuan_error. * assuan-socket-server.c, assuan-socket-connect.c, assuan-connect.c: Likewise. * assuan-buffer.c: Likewise. Also update access to confidential flag. * assuan-uds.c: Add ctx argument to all invocations of _assuan_malloc, _assuan_realloc, _assuan_calloc, _assuan_free and _assuan_error. * assuan_listen.c, assuan-inquire.c, assuan-handler.c: Likewise. * assuan-error.c (err_source): Remove global variable. (assuan_set_assuan_err_source): Removed function. (_assuan_w32_strerror): Moved here from assuan-logging.c and made thread-safe. (_assuan_error): Removed function (is now macro). * assuan-handler.c: Update access to confidential flag. * assuan-socket-server.c (accept_connection_bottom): Update access to confidential flag in context. (assuan_init_socket_server, assuan_init_socket_server_ext): Take ctx argument instead of pointer to ctx. * assuan-inquire.c (init_membuf, put_membuf, get_membuf) (free_membuf): Take context argument and change all callers. * assuan-socket-server.c (assuan_socket_connect) (assuan_socket_connect_ext): Take ctx argument instead of pointer to ctx. * assuan-pipe-connect.c (initial_handshake, pipe_connect_unix) (socketpair_connect, assuan_pipe_connect) (assuan_pipe_connect_ext): Likewise. (socketpair_connect): Now that ctx is not a pointer argument anymore, return if we are server or client in the argv argument. * assuan-logging.c (_assuan_log_handler): New function. (_assuan_w32_strerror): Move to assuan-error.c * assuan-connect.c (assuan_disconnect): Renamed to ... (_assuan_disconnect): ... this. * assuan-pipe-server.c (_assuan_new_context): Removed function. (assuan_init_pipe_server): Take ctx argument instead of pointer to ctx. (_assuan_release_context): Removed function. (_assuan_deinit_server): Reimplement. [The diff below has been truncated] Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/ChangeLog 2009-09-21 01:08:08 UTC (rev 303) @@ -1,3 +1,9 @@ +2009-09-19 Marcus Brinkmann + + * tests/fdpassing.c: Update to new API. + * configure.ac: Check for stdint.h and inttypes.h. Invoke + AC_TYPE_UINTPTR_T. + 2009-09-08 Marcus Brinkmann * m4/gpg-error.m4: New file. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/doc/ChangeLog 2009-09-21 01:08:08 UTC (rev 303) @@ -1,3 +1,7 @@ +2009-09-21 Marcus Brinkmann + + * assuan.texi: Update to new API. + 2009-09-01 Marcus Brinkmann * assuan.texi: (External I/O Loop Server): Document Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/src/ChangeLog 2009-09-21 01:08:08 UTC (rev 303) @@ -1,3 +1,88 @@ +2009-09-19 Marcus Brinkmann + + * src/libassuan.vers, src/libassuan.def: Update to new API. + * assuan.c, context.c, system.c, debug.c: New files. + * Makefile.am (common_sources): Add assuan.c, context.c, system.c + and debug.c. + * assuan.h: Include . Fix inclusion of . + (_ASSUAN_EXT_SYM_PREFIX, _ASSUAN_PREFIX1, _ASSUAN_PREFIX2) + (_ASSUAN_PREFIX): Remove support for renaming the whole library, + now that we have a stable shared library interface that can evolve + to cover all needs (particularly those of GPGME). + (assuan_malloc_hooks, assuan_malloc_hooks_t, assuan_log_cb_t) + (assuan_io_monitor_t): New types. + (ASSUAN_LOG_INIT, ASSUAN_LOG_CTX, ASSUAN_LOG_ENGINE) + (ASSUAN_LOG_DATA, ASSUAN_LOG_SYSIO, ASSUAN_IO_FROM_PEER) + (ASSUAN_IO_TO_PEER, ASSUAN_IO_MONITOR_NOLOG) + (ASSUAN_IO_MONITOR_IGNORE): New symbols. + (assuan_set_gpg_err_source, assuan_get_gpg_err_source) + (assuan_get_malloc_hooks, assuan_set_log_cb, assuan_get_log_cb) + (assuan_new, assuan_new_ext, assuan_release): New function + prototypes. + (assuan_init_pipe_server, assuan_init_socket_server) + (assuan_init_socket_server_ext, assuan_pipe_connect) + (assuan_pipe_connect_ext, assuan_socket_connect) + (assuan_socket_connect_ext): Take a context argument instead of + pointer to context. + (assuan_deinit_server, assuan_disconnect) + (assuan_set_assuan_err_source): Remove function prototypes. + * assuan-defs.h (ASSUAN_GCC_A_PURE): Moved here from XXX + (_assuan_error): New macro. + (struct assuan_context_s): New members err_source, w32_strerror, + malloc_hooks, log_cb, log_cb_data: New members. Move confidential + into flags. New member engine. + (_assuan_log_handler, _assuan_error_default, _assuan_disconnect): + New prototypes. + (_assuan_new_context): Remove prototype. + (_assuan_malloc, _assuan_calloc, _assuan_realloc, _assuan_free): + Add context argument to prototype. + * assuan-util.c (alloc_func, realloc_func, free_func): Remove + global variables. + (assuan_set_malloc_hooks, _assuan_malloc, _assuan_realloc) + (_assuan_calloc, _assuan_free, assuan_set_pointer) + (assuan_get_pointer, assuan_begin_confidential) + (assuan_end_confidential, assuan_set_io_monitor, assuan_set_flag) + (assuan_get_flag): Move functions to ... + * assuan-client.c: Add ctx argument to all invocations of + _assuan_error. + * assuan-socket-server.c, assuan-socket-connect.c, + assuan-connect.c: Likewise. + * assuan-buffer.c: Likewise. Also update access to confidential + flag. + * assuan-uds.c: Add ctx argument to all invocations of + _assuan_malloc, _assuan_realloc, _assuan_calloc, _assuan_free and + _assuan_error. + * assuan_listen.c, assuan-inquire.c, assuan-handler.c: Likewise. + * assuan-error.c (err_source): Remove global variable. + (assuan_set_assuan_err_source): Removed function. + (_assuan_w32_strerror): Moved here from assuan-logging.c and made + thread-safe. + (_assuan_error): Removed function (is now macro). + * assuan-handler.c: Update access to confidential flag. + * assuan-socket-server.c (accept_connection_bottom): Update access + to confidential flag in context. + (assuan_init_socket_server, assuan_init_socket_server_ext): Take + ctx argument instead of pointer to ctx. + * assuan-inquire.c (init_membuf, put_membuf, get_membuf) + (free_membuf): Take context argument and change all callers. + * assuan-socket-server.c (assuan_socket_connect) + (assuan_socket_connect_ext): Take ctx argument instead of pointer + to ctx. + * assuan-pipe-connect.c (initial_handshake, pipe_connect_unix) + (socketpair_connect, assuan_pipe_connect) + (assuan_pipe_connect_ext): Likewise. + (socketpair_connect): Now that ctx is not a pointer argument + anymore, return if we are server or client in the argv argument. + * assuan-logging.c (_assuan_log_handler): New function. + (_assuan_w32_strerror): Move to assuan-error.c + * assuan-connect.c (assuan_disconnect): Renamed to ... + (_assuan_disconnect): ... this. + * assuan-pipe-server.c (_assuan_new_context): Removed function. + (assuan_init_pipe_server): Take ctx argument instead of pointer to + ctx. + (_assuan_release_context): Removed function. + (_assuan_deinit_server): Reimplement. + 2009-09-01 Marcus Brinkmann * assuan.h: Change types in all functions from int to gpg_error_t @@ -10,7 +95,7 @@ (accept_connection, finish_connection): Likewise. (assuan_init_connected_socket_server): Remove. * assuan-defs.h (struct assuan_context_s): Change return type of - accept_handler and finish_handler to gpg_error_t. + accept_handler and finish_handler to gpg_error_t. Add io_monitor_data. * assuan-pipe-connect.c (do_finish): Change to void. * assuan-inquire.c (_assuan_inquire_ext_cb): Change type of RC from int to gpg_error_t. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/NEWS 2009-09-21 01:08:08 UTC (rev 303) @@ -1,23 +1,55 @@ -Noteworthy changes in version 1.1.0 +Noteworthy changes in version 1.1.0 (unreleased) ------------------------------------------------ * Now using libtool and builds a DSO. * Lots of interface cleanups. See below for details of the most - important changes. + important changes. Here is a quick note on how to upgrade: + For each invocation of the connect or server functions, allocate a + context with assuan_new and use that. Instead of assuan_disconnect + or assuan_deinit_server, call assuan_release. Use + assuan_set_gpg_err_source instead of assuan_set_assuan_err_source. + If you use assuan_pipe_connect or assuan_pipe_connect_ext with NAME + of NULL, you have to provide a non-NULL ARGV argument and check + that against "server" or "client" to determine which end you got + after fork(). + * Interface changes relative to the 1.0.5 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -_ASSUAN_ONLY_GPG_ERRORS Removed. -assuan_init_connected_socket_server Removed. -assuan_strerror Removed. -assuan_pipe_connect2 Removed. +_ASSUAN_ONLY_GPG_ERRORS REMOVED +assuan_set_assuan_err_source REMOVED: Use assuan_set_gpg_err_source. +assuan_set_gpg_err_source NEW +assuan_get_gpg_err_source NEW +assuan_strerror REMOVED ASSUAN_* Error values removed. -assuan_error_t Removed. -AssuanError Removed. -AssuanCommand Removed. -assuan_flag_t Changed from enum to unsigned int. -ASSUAN_CONTENT Removed. +assuan_error_t REMOVED +AssuanError REMOVED +assuan_init_connected_socket_server REMOVED +assuan_pipe_connect2 REMOVED +AssuanCommand REMOVED +assuan_flag_t CHANGED: From enum to unsigned int. +ASSUAN_CONTENT REMOVED +assuan_disconnect REMOVED: Use assuan_release. +assuan_deinit_server REMOVED: Use assuan_release. +assuan_get_malloc_hooks NEW +assuan_set_log_cb NEW +assuan_get_log_cb NEW +assuan_new_ext NEW +assuan_new NEW +assuan_release NEW +assuan_init_socket_server CHANGED: Take ctx arg instead of pointer to ctx. +assuan_init_socket_server_ext CHANGED: Take ctx arg instead of pointer to ctx. +assuan_socket_connect CHANGED: Take ctx arg instead of pointer to ctx. +assuan_socket_connect_ext CHANGED: Take ctx arg instead of pointer to ctx. +assuan_pipe_connect CHANGED: Take ctx arg instead of pointer to ctx. + If NAME is NULL, ARGV will contain fork result. +assuan_pipe_connect_ext CHANGED: Take ctx arg instead of pointer to ctx. + If NAME is NULL, ARGV will contain fork result. +assuan_init_pipe_server CHANGED: Take ctx arg instead of pointer to ctx. +assuan_set_io_hooks REMOVED: Will come back in expanded form. +assuan_io_hooks_t REMOVED: Will come back in expanded form. +assuan_io_monitor_t CHANGED: Add a hook data argument. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.0.5 (2008-05-25) Modified: trunk/TODO =================================================================== --- trunk/TODO 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/TODO 2009-09-21 01:08:08 UTC (rev 303) @@ -2,13 +2,14 @@ * Check that we have Pth-ed all blocking fucntions. * When turning libassuan into a shared library, provide a general version as well as a Pth-enabled one. +* Even better, allow replacing all these I/O and spawn functions on + a per-context basis at runtime (like the old assuan_set_io_hooks but better). * assuan_transact returns immediately on an error in the callback function. It might be better to return the error to the caller. As an example see dirmngr-client, where we need to send empty responses for unknown inquiries, albeit dirmngr itself would handle the returns for assuan_inquire gracefully. We need to check all applications whether it is safe to change this. - * XOPEN_SOURCE and snprintf See Peter O'Gorman's mail. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/configure.ac 2009-09-21 01:08:08 UTC (rev 303) @@ -227,7 +227,8 @@ # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([string.h locale.h sys/uio.h]) +AC_CHECK_HEADERS([string.h locale.h sys/uio.h stdint.h inttypes.h]) +AC_TYPE_UINTPTR_T # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/doc/assuan.texi 2009-09-21 01:08:08 UTC (rev 303) @@ -374,7 +374,7 @@ Libassuan is used with gpg-error style error codes. It is recommended to set the error source to a different value than the default @code{GPG_ERR_SOURCE_UNKNOWN} by calling @ref{function -assuan_set_assuan_err_source} early. +assuan_set_gpg_err_source} early. @c @@ -428,7 +428,7 @@ file search path (via the @option{-I} option). However, the path to the include file is determined at the time the -source is configured. To solve this problem, @sc{libgcrypt} ships with +source is configured. To solve this problem, @code{libassuan} ships with a small helper program @command{libassuan-config} that knows the path to the include file and other configuration options. The options that need to be added to the compiler invocation at compile time are output by the @@ -519,14 +519,15 @@ @node Multi Threading @section Multi Threading -The @sc{libgcrypt} library is thread-safe if you adhere to the following +The @code{libassuan} library is thread-safe if you adhere to the following requirements: @itemize @bullet @item Run the initialization functions before you actually start to use threads. @item Only one thread at a time may access an @code{libassuan} context. - at item Use @code{assuan_set_assuan_log_stream} to setup a default log stream. + at item If you use the default log handler, use + at code{assuan_set_assuan_log_stream} to setup a default log stream. @end itemize @@ -537,9 +538,11 @@ @chapter Generalities @menu -* Data Types:: Data types used by @code{libassuan}. -* Initializing the library:: How to initialize the library. -* Reading and Writing:: How to communicate with the peer. +* Data Types:: Data types used by @code{libassuan}. +* Initializing the library:: How to initialize the library. +* Default Log Handler:: How to configure the default log handler. +* Contexts:: How to work with contexts. +* Reading and Writing:: How to communicate with the peer. @end menu @@ -548,14 +551,14 @@ @section Data Types used by the library @sc{Assuan} uses a context to keep the state for a connection. The -following data type is used ace: +following data type is used for that: @deftp {Data type} assuan_context_t The @code{assuan_context_t} type is a pointer to an object maintained -internally by the library. Certain @sc{Assuan} functions allocate -such a context and return it to the caller using this data type. Other -functions take this data type to access the state created by these -functions. +internally by the library. Contexts are allocated with + at code{assuan_new} or @code{assuan_new_ext} and released with + at code{assuan_release}. Other functions take this data type to access +the state created by these functions. @end deftp @@ -574,23 +577,139 @@ should be called as early as possible and in a multi-threaded application before a second thread is created. +These functions initialize default values that are used at context +creation with @code{assuan_new}. As there can only be one default, +all values can also be set directly with @code{assuan_new_ext} or with +context-specific functions after context creation. + If your application uses its own memory allocation functions or wrappers it is good idea to tell @code{libassuan} about it so it can make use of the -same functions or wrappers. You do this with +same functions or wrappers: - at deftypefun void assuan_set_malloc_hooks (@w{void *(*@var{malloc_func})(size_t)}, @w{void *(*@var{realloc_func})(void *, size_t)}, @w{void (*@var{free_func})(void*)}) -You need to provide all three functions. Those functions need to behave -exactly as their standard counterparts (@code{malloc}, @code{realloc} -and @code{free}). If you write your own functions, please take care to -set @code{errno} whenever an error has occurred. + at deftp {Data type} {struct assuan_malloc_hooks} +This structure is used to store the memory allocation callback +interface functions. It has the following members, whose semantics +are identical to the corresponding system functions: + + at table @code + at item void *(*malloc) (size_t cnt) +This is the function called by @sc{Assuan} to allocate memory for a context. + + at item void *(*realloc) (void *ptr, size_t cnt) +This is the function called by @sc{Assuan} to reallocate memory for a context. + + at item void (*free) (void *ptr) +This is the function called by @sc{Assuan} to release memory for a context. + at end table + at end deftp + + at deftp {Data type} {assuan_malloc_hooks_t} +This is a pointer to a @code{struct assuan_malloc_hooks}. + at end deftp + +/* Get the default malloc hooks. */ +assuan_malloc_hooks_t assuan_get_malloc_hooks (void); + + at deftypefun void assuan_set_malloc_hooks (@w{assuan_malloc_hooks_t @var{malloc_hooks}}) +This function sets the default allocation hooks for new contexts +allocated with @code{assuan_new}. You need to provide all three +functions. Those functions need to behave exactly as their standard +counterparts @code{malloc}, @code{realloc} and @code{free}. If you +write your own functions, please take care to set @code{errno} +whenever an error has occurred. @end deftypefun + at deftypefun assuan_malloc_hooks_t assuan_get_malloc_hooks () +This function gets the default allocation hooks for new contexts +allocated with @code{assuan_new}. The result structure is statically +allocated and should not be modified. + at end deftypefun + +The @sc{Assuan} library uses @code{libgpg-error} error values, which +consist and error code and an error source. The default source used +by contexts allocated with @code{assuan_new} can be set with the +following function. + + at anchor{function assuan_set_gpg_err_source} + at deftypefun void assuan_set_gpg_err_source (@w{gpg_err_source_t @var{err_source}}) +This function sets the default error source for errors generated by +contexts allocated with @code{assuan_new}. + +One way to call this function is + at smallexample +assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); + at end smallexample + at end deftypefun + + at deftypefun gpg_err_source_t assuan_get_gpg_err_source (void) +This function gets the default error source for errors generated by +contexts allocated with @code{assuan_new}. + at end deftypefun + @noindent To integrate assuan logging and diagnostics into your own logging system, you may use the following two functions: + at deftp {Data type} {int (*assuan_log_cb_t) (@w{assuan_context_t @var{ctx}}, @w{void *@var{hook_value}}, @w{unsigned int @var{cat}}, @w{const char *@var{msg}})} +The user-provided callback function takes a context @var{ctx}, for +which the message @var{msg} was generated, and a hook value + at var{hook_value} that was supplied when the log handler was registered +for the context with @code{assuan_set_log_cb}, and a category + at var{cat}. The category is one of: + + at table @code + at item ASSUAN_LOG_INIT + at item ASSUAN_LOG_CTX + at item ASSUAN_LOG_ENGINE + at item ASSUAN_LOG_DATA + at item ASSUAN_LOG_SYSIO + at end table + +The user may then, depending on the category, write the message to a +log file or treat it in some other way. + +If @var{msg} is a null pointer, then no message should be logged, but +the function should return 1 if it is interested in log messages with +the category @var{cat}. If it is not interested, 0 should be +returned. This allows @code{libassuan} to suppress the generation of +expensive debug output. + at end deftp + + at deftypefun void assuan_set_log_cb (@w{assuan_log_cb_t @var{log_cb}}, @w{void *@var{log_cb_data}}) +This function sets the default logging handler for log messages +generated by contexts allocated with @code{assuan_new}. + at end deftypefun + + at deftypefun void assuan_get_log_cb (@w{assuan_log_cb_t *@var{log_cb}}, @w{void **@var{log_cb_data}}) +This function gets the default logging handler for log messages +generated by contexts allocated with @code{assuan_new}. + at end deftypefun + +You do not need to set a log handler, as @sc{Assuan} provides a +configurable default log handler that should be suitable for most +purposes. Logging can be disabled completely by setting the log +handler to a null pointer. + + at node Default Log Handler + at section Default Log Handler + +The default log handler can be configured by the following functions: + + at deftypefun void assuan_set_assuan_log_prefix (@w{const char *@var{text}}) +Set the prefix to be used at the start of a line emitted by assuan +on the log stream to @var{text}. The default is the empty string. + at end deftypefun + + + at deftypefun @w{const char *} assuan_get_assuan_log_prefix (void) +Return the prefix to be used at the start of a line emitted by assuan +on the log stream. The default implementation returns the empty +string. + at end deftypefun + + @deftypefun void assuan_set_assuan_log_stream (FILE *@var{fp}) -This sets the stream to which @code{libassuan} should log messages not +This sets the default log stream to which @code{libassuan} should log messages not associated with a specific context to @var{fp}. The default is to log to @code{stderr}. This default value is also changed by using @code{assuan_set_log_stream} (to set a logging stream for a specific @@ -599,21 +718,145 @@ setup a proper default. @end deftypefun - at deftypefun void assuan_set_assuan_log_prefix (@w{const char *@var{text}}) -Set the prefix to be used at the start of a line emitted by assuan -on the log stream to @var{text}. The default is the empty string. + + at deftypefun @w{FILE *} assuan_get_assuan_log_stream (void) +Return the stream which is currently being using for global logging. @end deftypefun - at anchor{function assuan_set_assuan_err_source} - at deftypefun void assuan_set_assuan_err_source (@w{int @var{errsource}}) -Set the error source for error values generated by @code{libassuan}. - at var{errsource} is one of the @code{libgpg-error} sources. The usual -way to call this function is +The log stream used by the default log handler can also be set on a +per context basis. + + at deftypefun void assuan_set_log_stream (@w{assuan_context_t @var{ctx}}, @w{FILE *@var{fp}}) +Enable debugging for the context @var{ctx} and write all debugging +output to the stdio stream @var{fp}. If the default log stream (used +for non-context specific events) has not yet been set, a call to this +functions implicitly sets this stream also to @var{fp}. + at end deftypefun + + + at node Contexts + at section How to work with contexts + +Some operations work globally on the library, but most operate in a +context, which saves state across operations. To allow the use of + at code{libassuan} in mixed environments, such as in a library using +GPGME and an application using GPGME, the context is very extensive +and covers utilitary information like memory allocation callbacks as +well as specific information associated with client/server operations. + + at deftypefun gpg_error_t assuan_new (@w{assuan_context_t *@var{ctx_p}}) +The function @code{assuan_new} creates a new context, using the global +default memory allocation, log handler and @code{libgpg-error} source. +It is equivalent to + @smallexample -assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); +gpg_error_t err; +assuan_log_cb_t log_cb; +void *log_cb_data; + +assuan_get_log_cb (&log_cb, &log_cb_data); +err = assuan_new_ext (ctx_p, assuan_get_gpg_err_source (), + assuan_get_malloc_hooks (), log_cb, log_cb_data); @end smallexample + +As you can see, this is not thread-safe. Take care not to modify the +memory allocation hooks or log callback handler concurrently with + at code{assuan_new}. + +The function returns an error if a memory allocation error occurs, and +0 with the new context in @var{ctx_p} otherwise. @end deftypefun + at deftypefun gpg_error_t assuan_new_ext (@w{assuan_context_t *@var{ctx_p}}, @w{gpg_err_source_t @var{err_source}}, @w{assuan_malloc_hooks_t @var{malloc_hooks}}, @w{assuan_log_cb_t @var{log_cb}}, @w{void *@var{log_cb_data}}) +The function @code{assuan_new_ext} creates a new context using the +supplied @code{libgpg-error} error source @var{err_source}, the memory +allocation hooks @var{malloc_hooks} and the log handler @var{log_cb} +with the user data @var{log_cb_data}. + at end deftypefun + +After the context has been used, it can be destroyed again. + + at deftypefun void assuan_release (assuan_context_t ctx) +The function @code{assuan_release} destroys the context CTX and +releases all associated resources. + at end deftypefun + +Other properties of the context beside the memory allocation handler, +the log handler, and the @code{libgpg-error} source can be set after +context creation. Here are some of them: + + at deftypefun void assuan_set_pointer (@w{assuan_context_t @var{ctx}}, @w{void *@var{pointer}}) + +Store the arbitrary pointer value @var{pointer} into the context + at var{ctx}. This is useful to provide command handlers with additional +application context. + at end deftypefun + + at deftypefun void* assuan_get_pointer (@w{assuan_context_t @var{ctx}}) + +This returns the pointer for context @var{ctx} which has been set using +the above function. A common way to use it is by setting the pointer +before starting the processing loop and to retrieve it right at the +start of a command handler: + at smallexample +static int +cmd_foo (assuan_context_t ctx, char *line) +@{ + ctrl_t ctrl = assuan_get_pointer (ctx); + ... +@} + at end smallexample + at end deftypefun + + + at deftypefun void assuan_set_flag (@w{assuan_context_t @var{ctx}}, @w{assuan_flag_t @var{flag}}, @w{int @var{value}}) + +Set the the @var{flag} for context @var{ctx} to @var{value}. Values for +flags are usually 1 or 0 but certain flags might need other values. + + at deftp {Data type} assuan_flag_t +The flags are all named and collected in an @code{enum} for better readability. +Currently only one flag is defined: + + at table @code + at item ASSUAN_NO_WAITPID +When using a pipe server, by default Libassuan will wait for the forked +process to die in @code{assuan_disconnect}. In certain cases this is +not desirable. By setting this flag, a call to @code{waitpid} will be +suppressed and the caller is responsible to cleanup the child process. + at item ASSUAN_CONFIDENTIAL +Uses to return the state of the confidential logging mode. + at end table + at end deftp + at end deftypefun + + at deftypefun int assuan_get_flag (@w{assuan_context_t @var{ctx}}, @w{assuan_flag_t @var{flag}}) +Return the value of @var{flag} in context @var{ctx}. + at end deftypefun + + + at deftypefun void assuan_begin_confidential (@w{assuan_context_t @var{ctx}}) +Put the logging feature into confidential mode. This is to avoid +logging of sensitive data. + +This is identical to: + at smallexample +assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 1); + at end smallexample + at end deftypefun + + + at deftypefun void assuan_end_confidential (@w{assuan_context_t @var{ctx}}) +Get the logging feature out of confidential mode. All data will be +logged again (if logging is enabled). + +This is identical to: + at smallexample +assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 0); + at end smallexample + at end deftypefun + + @node Reading and Writing @section How to communicate with the peer @@ -667,9 +910,33 @@ This function returns @code{0} on success or an error value. @end deftypefun +The input and output of data can be controlled at a higher level using +an I/O monitor. + at deftp {Data type} {unsigned int (*assuan_io_monitor_t) (@w{assuan_context_t @var{ctx}}, @w{void *@var{hook_value}}, @w{int @var{inout}}, @w{const char *@var{line}}, @w{size_t @var{linelen}})} +The monitor function is called right after a line has been received, +if @var{inout} is @code{ASSUAN_IO_FROM_PEER}, or just before it is +send, if @var{inout} is @code{ASSUAN_IO_TO_PEER}. The + at var{hook_value} is provided by the user when registering the I/O +monitor function with a context using @code{assuan_set_io_monitor}. +The callback function should return the bitwise OR of some (or none) of the +following flags: + at table @code + at item ASSUAN_IO_MONITOR_NOLOG +Active logging of this line is suppressed. This can reduce debug +output in the case of a frequent message. + at item ASSUAN_IO_MONITOR_IGNORE +The whole output line is discarded. + at end table + at end deftp + at deftypefun void assuan_set_io_monitor (@w{assuan_context_t @var{ctx}}, @w{assuan_io_monitor_t @var{io_monitor}}, @w{void *@var{hook_data}}) +This function registers an I/O monitor @var{io_monitor} for the +context @var{ctx} with the hook value @var{hook_data}. + at end deftypefun + + @c @c C L I E N T C O D E @c @@ -683,18 +950,19 @@ sockets, the full-fledged variant of the above function should be used: - at deftypefun gpg_error_t assuan_pipe_connect_ext (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *const @var{argv}[]}, @w{int *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}}) + at deftypefun gpg_error_t assuan_pipe_connect_ext (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *@var{argv}[]}, @w{int *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}}) A call to this functions forks the current process and executes the program @var{name}, passing the arguments given in the NULL-terminated list @var{argv}. A list of file descriptors not to be closed may be given using the @code{-1} terminated array @var{fd_child_list}. -If @var{name} as well as @var{argv} are given as @code{NULL}, only a -fork but no exec is done. Thus the child continues to run. However all -file descriptors are closed and some special environment variables are -set. To let the caller detect whether the child or the parent continues, -the child returns with a @var{ctx} set to @code{NULL}. +If @var{name} is a null pointer, only a fork but no exec is done. +Thus the child continues to run. However all file descriptors are +closed and some special environment variables are set. To let the +caller detect whether the child or the parent continues, the parent +returns with @code{"client"} returned in @var{argv} and the child +returns with @code{"server"} in @var{argv}. If @var{atfork} is not NULL, this function is called in the child right after the fork and the value @var{atforkvalue} is passed as the first @@ -724,7 +992,7 @@ For a pipe-based server you can also use the following legacy function: - at deftypefun gpg_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *const @var{argv}[]}, @w{int *@var{fd_child_list}}) + at deftypefun gpg_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *@var{argv}[]}, @w{int *@var{fd_child_list}}) A call to @code{assuan_pipe_connect} is equivalent to a call to @code{assuan_pipe_connect_ext} with @code{flags} being 0 and without @@ -1050,22 +1318,9 @@ such a custom hello line which may tell version numbers and such. Linefeeds are allowed in this string, however, each line needs to be shorter than the Assuan line length limit. - @end deftypefun @noindent -As a last initialization step, debugging may be enabled for the -current connection. This is done using - - at deftypefun void assuan_set_log_stream (@w{assuan_context_t @var{ctx}}, @w{FILE *@var{fp}}) - -Enable debugging for the context @var{ctx} and write all debugging -output to the stdio stream @var{fp}. If the default log stream (used -for non-context specific events) has not yet been set, a call to this -functions implicitly sets this stream also to @var{fp}. - at end deftypefun - - at noindent Now that everything has been setup, we can start to process our clients requests. @@ -1354,32 +1609,6 @@ general functions. - - at deftypefun void assuan_set_pointer (@w{assuan_context_t @var{ctx}}, @w{void *@var{pointer}}) - -Store the arbitrary pointer value @var{pointer} into the context - at var{ctx}. This is useful to provide command handlers with additional -application context. - at end deftypefun - - at deftypefun void* assuan_get_pointer (@w{assuan_context_t @var{ctx}}) - -This returns the pointer for context @var{ctx} which has been set using -the above function. A common way to use it is by setting the pointer -before starting the processing loop and to retrieve it right at the -start of a command handler: - at smallexample -static int -cmd_foo (assuan_context_t ctx, char *line) -@{ - ctrl_t ctrl = assuan_get_pointer (ctx); - ... -@} - at end smallexample - at end deftypefun - - - @deftypefun gpg_error_t assuan_write_status (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{const char *@var{text}}) This is a convenience function for a server to send a status line. You @@ -1489,35 +1718,7 @@ @end deftypefun - at deftypefun void assuan_set_flag (@w{assuan_context_t @var{ctx}}, @w{assuan_flag_t @var{flag}}, @w{int @var{value}}) -Set the the @var{flag} for context @var{ctx} to @var{value}. Values for -flags are usually 1 or 0 but certain flags might need other values. - - at deftp {Data type} assuan_flag_t -The flags are all named and collected in an @code{enum} for better readability. -Currently only one flag is defined: - - at table @code - at item ASSUAN_NO_WAITPID -When using a pipe server, by default Libassuan will wait for the forked -process to die in @code{assuan_disconnect}. In certain cases this is -not desirable. By setting this flag, a call to @code{waitpid} will be -suppressed and the caller is responsible to cleanup the child process. - at item ASSUAN_CONFIDENTIAL -Uses to return the state of the confidential logging mode. For changing -this mode the functions @code{assuan_begin_confidential} and - at code{assuan_end_confidential} should be used. - at end table - at end deftp - - at end deftypefun - - at deftypefun int assuan_get_flag (@w{assuan_context_t @var{ctx}}, @w{assuan_flag_t @var{flag}}) -Return the value of @var{flag} in context @var{ctx}. - at end deftypefun - - @deftypefun pid_t assuan_get_pid (@w{assuan_context_t @var{ctx}}) This function returns the pid of the connected connected peer. If that @@ -1570,42 +1771,8 @@ I/O. @end deftypefun - at deftypefun void assuan_set_io_monitor (@w{assuan_context_t @var{ctx}}, @w{unsigned int} (*@var{monitor})(@w{assuan_context_t @var{ctx}}, @w{int @var{direction}}, @w{const char *@var{line}}, @w{size_t @var{linelen}})) -This function registers an I/O monitor for the context @var{ctx}. Such -a monitor function is called right after a line has been received or -just before it is send. With @var{direction} set to 1 the monitor has -been called for an output operation; 0 obviosuly means it has been -called for an input operation. If the monitor sets bit 0 in the return -value, any active logging of the line will be suppressed. With bit 1 -set, the entire line will be ignored. - at end deftypefun - at deftypefun void assuan_begin_confidential (@w{assuan_context_t @var{ctx}}) - -Put the logging feature into confidential mode. This is to avoid -logging of sensitive data. - at end deftypefun - - at deftypefun void assuan_end_confidential (@w{assuan_context_t @var{ctx}}) - -Get the logging feature out of confidential mode. All data will be -logged again (if logging is enabled). - at end deftypefun - - at deftypefun FILE* assuan_get_assuan_log_stream (void) - -Return the stream which is currently being using for global logging. - at end deftypefun - - at deftypefun @w{const char*} assuan_get_assuan_log_prefix (void) - -Return the prefix to be used at the start of a line emitted by assuan -on the log stream. The default implementation returns the empty -string. - at end deftypefun - - @c @c S O C K E T W R A P P E R S @c Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/src/Makefile.am 2009-09-21 01:08:08 UTC (rev 303) @@ -42,7 +42,11 @@ common_sources = \ assuan-defs.h \ - assuan-util.c \ + assuan.c \ + context.c \ + system.c \ + debug.c \ + conversion.c \ assuan-error.c \ assuan-buffer.c \ assuan-handler.c \ Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/src/assuan-buffer.c 2009-09-21 01:08:08 UTC (rev 303) @@ -103,7 +103,7 @@ char *endp = 0; if (ctx->inbound.eof) - return _assuan_error (GPG_ERR_EOF); + return _assuan_error (ctx, GPG_ERR_EOF); atticlen = ctx->inbound.attic.linelen; if (atticlen) @@ -149,7 +149,7 @@ } errno = saved_errno; - return _assuan_error (gpg_err_code_from_syserror ()); + return _assuan_error (ctx, gpg_err_code_from_syserror ()); } if (!nread) { @@ -159,7 +159,7 @@ assuan_get_assuan_log_prefix (), (unsigned int)getpid (), (int)ctx->inbound.fd); - return _assuan_error (GPG_ERR_EOF); + return _assuan_error (ctx, GPG_ERR_EOF); } ctx->inbound.attic.pending = 0; @@ -190,20 +190,20 @@ ctx->inbound.linelen = endp - line; - monitor_result = (ctx->io_monitor - ? ctx->io_monitor (ctx, 0, - ctx->inbound.line, - ctx->inbound.linelen) - : 0); - if ( (monitor_result & 2) ) + monitor_result = 0; + if (ctx->io_monitor) + monitor_result = ctx->io_monitor (ctx, ctx->io_monitor_data, 0, + ctx->inbound.line, + ctx->inbound.linelen); + if (monitor_result & ASSUAN_IO_MONITOR_IGNORE) ctx->inbound.linelen = 0; - if (ctx->log_fp && !(monitor_result & 1)) + if (ctx->log_fp && !(monitor_result & ASSUAN_IO_MONITOR_NOLOG)) { fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- ", assuan_get_assuan_log_prefix (), (unsigned int)getpid (), (int)ctx->inbound.fd); - if (ctx->confidential) + if (ctx->flags.confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else _assuan_log_print_buffer (ctx->log_fp, @@ -221,9 +221,9 @@ (unsigned int)getpid (), (int)ctx->inbound.fd); *line = 0; ctx->inbound.linelen = 0; - return _assuan_error (ctx->inbound.eof - ? GPG_ERR_ASS_INCOMPLETE_LINE - : GPG_ERR_ASS_LINE_TOO_LONG); + return _assuan_error (ctx, ctx->inbound.eof + ? GPG_ERR_ASS_INCOMPLETE_LINE + : GPG_ERR_ASS_LINE_TOO_LONG); } } @@ -243,7 +243,7 @@ gpg_error_t err; if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); do { @@ -288,17 +288,17 @@ len = ASSUAN_LINELENGTH - prefixlen - 2 - 1; } - monitor_result = (ctx->io_monitor - ? ctx->io_monitor (ctx, 1, line, len) - : 0); + monitor_result = 0; + if (ctx->io_monitor) + monitor_result = ctx->io_monitor (ctx, ctx->io_monitor_data, 1, line, len); /* Fixme: we should do some kind of line buffering. */ - if (ctx->log_fp && !(monitor_result & 1)) + if (ctx->log_fp && !(monitor_result & ASSUAN_IO_MONITOR_NOLOG)) { fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), (unsigned int)getpid (), (int)ctx->inbound.fd); - if (ctx->confidential) + if (ctx->flags.confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else { @@ -309,22 +309,22 @@ putc ('\n', ctx->log_fp); } - if (prefixlen && !(monitor_result & 2)) + if (prefixlen && !(monitor_result & ASSUAN_IO_MONITOR_IGNORE)) { rc = writen (ctx, prefix, prefixlen); if (rc) - rc = _assuan_error (gpg_err_code_from_syserror ()); + rc = _assuan_error (ctx, gpg_err_code_from_syserror ()); } - if (!rc && !(monitor_result & 2)) + if (!rc && !(monitor_result & ASSUAN_IO_MONITOR_IGNORE)) { rc = writen (ctx, line, len); if (rc) - rc = _assuan_error (gpg_err_code_from_syserror ()); + rc = _assuan_error (ctx, gpg_err_code_from_syserror ()); if (!rc) { rc = writen (ctx, "\n", 1); if (rc) - rc = _assuan_error (gpg_err_code_from_syserror ()); + rc = _assuan_error (ctx, gpg_err_code_from_syserror ()); } } return rc; @@ -338,7 +338,7 @@ const char *str; if (! ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); /* Make sure that we never take a LF from the user - this might violate the protocol. */ @@ -403,20 +403,20 @@ } - monitor_result = (ctx->io_monitor - ? ctx->io_monitor (ctx, 1, - ctx->outbound.data.line, linelen) - : 0); + monitor_result = 0; + if (ctx->io_monitor) + monitor_result = ctx->io_monitor (ctx, ctx->io_monitor_data, 1, + ctx->outbound.data.line, linelen); if (linelen >= LINELENGTH-2-2) { - if (ctx->log_fp && !(monitor_result & 1)) + if (ctx->log_fp && !(monitor_result & ASSUAN_IO_MONITOR_NOLOG)) { fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), (unsigned int)getpid (), (int)ctx->inbound.fd); - if (ctx->confidential) + if (ctx->flags.confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else _assuan_log_print_buffer (ctx->log_fp, @@ -426,7 +426,7 @@ } *line++ = '\n'; linelen++; - if ( !(monitor_result & 2) + if ( !(monitor_result & ASSUAN_IO_MONITOR_IGNORE) && writen (ctx, ctx->outbound.data.line, linelen)) { ctx->outbound.data.error = gpg_err_code_from_syserror (); @@ -459,19 +459,19 @@ linelen = ctx->outbound.data.linelen; line += linelen; - monitor_result = (ctx->io_monitor - ? ctx->io_monitor (ctx, 1, - ctx->outbound.data.line, linelen) - : 0); + monitor_result = 0; + if (ctx->io_monitor) + monitor_result = ctx->io_monitor (ctx, ctx->io_monitor_data, 1, + ctx->outbound.data.line, linelen); if (linelen) { - if (ctx->log_fp && !(monitor_result & 1)) + if (ctx->log_fp && !(monitor_result & ASSUAN_IO_MONITOR_NOLOG)) { fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), (unsigned int)getpid (), (int)ctx->inbound.fd); - if (ctx->confidential) + if (ctx->flags.confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else _assuan_log_print_buffer (ctx->log_fp, @@ -480,7 +480,7 @@ } *line++ = '\n'; linelen++; - if (! (monitor_result & 2) + if (! (monitor_result & ASSUAN_IO_MONITOR_IGNORE) && writen (ctx, ctx->outbound.data.line, linelen)) { ctx->outbound.data.error = gpg_err_code_from_syserror (); @@ -517,9 +517,9 @@ assuan_send_data (assuan_context_t ctx, const void *buffer, size_t length) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); if (!buffer && length > 1) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); if (!buffer) { /* flush what we have */ @@ -548,7 +548,7 @@ #ifdef USE_DESCRIPTOR_PASSING return 0; #else - return _assuan_error (GPG_ERR_NOT_IMPLEMENTED); + return _assuan_error (ctx, GPG_ERR_NOT_IMPLEMENTED); #endif if (! ctx->io->sendfd) Modified: trunk/src/assuan-client.c =================================================================== --- trunk/src/assuan-client.c 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/src/assuan-client.c 2009-09-21 01:08:08 UTC (rev 303) @@ -109,7 +109,7 @@ *off = 3; } else - rc = _assuan_error (GPG_ERR_ASS_INV_RESPONSE); + rc = _assuan_error (ctx, GPG_ERR_ASS_INV_RESPONSE); return rc; } @@ -169,7 +169,7 @@ else if (okay == 2) { if (!data_cb) - rc = _assuan_error (GPG_ERR_ASS_NO_DATA_CB); + rc = _assuan_error (ctx, GPG_ERR_ASS_NO_DATA_CB); else { char *s, *d; @@ -198,7 +198,7 @@ { assuan_write_line (ctx, "END"); /* get out of inquire mode */ _assuan_read_from_server (ctx, &okay, &off); /* dummy read */ - rc = _assuan_error (GPG_ERR_ASS_NO_INQUIRE_CB); + rc = _assuan_error (ctx, GPG_ERR_ASS_NO_INQUIRE_CB); } else { @@ -219,7 +219,7 @@ else if (okay == 5) { if (!data_cb) - rc = _assuan_error (GPG_ERR_ASS_NO_DATA_CB); + rc = _assuan_error (ctx, GPG_ERR_ASS_NO_DATA_CB); else { rc = data_cb (data_cb_arg, NULL, 0); Modified: trunk/src/assuan-connect.c =================================================================== --- trunk/src/assuan-connect.c 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/src/assuan-connect.c 2009-09-21 01:08:08 UTC (rev 303) @@ -36,18 +36,24 @@ /* Disconnect and release the context CTX. */ void -assuan_disconnect (assuan_context_t ctx) +_assuan_disconnect (assuan_context_t ctx) { - if (ctx) - { - assuan_write_line (ctx, "BYE"); - ctx->finish_handler (ctx); - ctx->deinit_handler (ctx); - ctx->deinit_handler = NULL; - _assuan_release_context (ctx); - } + assuan_write_line (ctx, "BYE"); + ctx->finish_handler (ctx); + ctx->finish_handler = NULL; + ctx->deinit_handler (ctx); + ctx->deinit_handler = NULL; + + _assuan_inquire_release (ctx); + _assuan_free (ctx, ctx->hello_line); + ctx->hello_line = NULL; + _assuan_free (ctx, ctx->okay_line); + ctx->okay_line = NULL; + _assuan_free (ctx, ctx->cmdtbl); + ctx->cmdtbl = NULL; } + /* Return the PID of the peer or -1 if not known. This function works in some situations where assuan_get_ucred fails. */ pid_t @@ -65,9 +71,9 @@ assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); if (!ctx->peercred.valid) - return _assuan_error (GPG_ERR_ASS_GENERAL); + return _assuan_error (ctx, GPG_ERR_ASS_GENERAL); #ifdef HAVE_SO_PEERCRED if (pid) Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/src/assuan-defs.h 2009-09-21 01:08:08 UTC (rev 303) @@ -31,6 +31,12 @@ #include "assuan.h" +#if __GNUC__ > 2 +# define ASSUAN_GCC_A_PURE __attribute__ ((__pure__)) +#else +# define ASSUAN_GCC_A_PURE +#endif + #ifndef HAVE_W32_SYSTEM #define DIRSEP_C '/' #else @@ -39,7 +45,10 @@ #define LINELENGTH ASSUAN_LINELENGTH +/* Generate an error code specific to a context. */ +#define _assuan_error(ctx, errcode) gpg_err_make ((ctx)->err_source, errcode) + struct cmdtbl_s { const char *name; @@ -60,41 +69,72 @@ gpg_error_t (*receivefd) (assuan_context_t, assuan_fd_t *); }; - -/* The global variable with the optional hook fucntions. */ -extern struct assuan_io_hooks _assuan_io_hooks; - - + /* The context we use with most functions. */ struct assuan_context_s { - gpg_error_t err_no; - const char *err_str; + /* Members managed by the generic routines in assuan.c. */ + /* The error source for errors generated from this context. */ + gpg_err_source_t err_source; + +#ifdef HAVE_W32_SYSTEM + /* The per-context w32 error string. */ + char w32_strerror[256]; +#endif + + /* The allocation hooks. */ + struct assuan_malloc_hooks malloc_hooks; + + /* Logging callback handler. */ + assuan_log_cb_t log_cb; + void *log_cb_data; + + void *user_pointer; + /* Context specific flags (cf. assuan_flag_t). */ struct { - unsigned int no_waitpid : 1; /* See ASSUAN_NO_WAITPID. */ + unsigned int no_waitpid : 1; + unsigned int confidential : 1; } flags; - int confidential; + /* If set, this is called right before logging an I/O line. */ + assuan_io_monitor_t io_monitor; + void *io_monitor_data; + + /* Now come the members specific to subsystems or engines. FIXME: + This is not developed yet. See below for the legacy members. */ + struct + { + void (*release) (assuan_context_t ctx); + } engine; + + + /* Engine specific or other subsystem members. */ + + /* assuan-logging.c. Does not require deallocation from us. */ + FILE *log_fp; + + /* assuan-util.c */ + gpg_error_t err_no; + const char *err_str; + int is_server; /* Set if this is context belongs to a server */ int in_inquire; int in_process_next; int in_command; /* The following members are used by assuan_inquire_ext. */ - int (*inquire_cb) (void *cb_data, int rc, unsigned char *buf, size_t len); + gpg_error_t (*inquire_cb) (void *cb_data, gpg_error_t rc, + unsigned char *buf, size_t len); void *inquire_cb_data; void *inquire_membuf; char *hello_line; char *okay_line; /* See assuan_set_okay_line() */ - void *user_pointer; /* For assuan_get_pointer and assuan_set_pointer (). */ - FILE *log_fp; - struct { assuan_fd_t fd; int eof; @@ -155,7 +195,7 @@ void (*deinit_handler)(assuan_context_t); gpg_error_t (*accept_handler)(assuan_context_t); - gpg_error_t (*finish_handler)(assuan_context_t); + void (*finish_handler)(assuan_context_t); struct cmdtbl_s *cmdtbl; size_t cmdtbl_used; /* used entries */ @@ -170,27 +210,35 @@ /* This function is called right after a command has been processed. It may be used to command related cleanup. */ - void (*post_cmd_notify_fnc)(assuan_context_t, int); + void (*post_cmd_notify_fnc)(assuan_context_t, gpg_error_t); - /* If set, this is called right before logging an I/O line. With - DIRECTION set to 1 it is called for an output oeration; 0 means - an input operation. If bit 0 is set in the return value, the - logging of the line will be suppressed. With bit 1 set, the - entire line will be ignored. */ - unsigned int (*io_monitor)(assuan_context_t ctx, - int direction, - const char *line, - size_t linelen); assuan_fd_t input_fd; /* Set by the INPUT command. */ assuan_fd_t output_fd; /* Set by the OUTPUT command. */ /* io routines. */ struct assuan_io *io; + + }; + +/* Release all resources associated with an engine operation. */ +void _assuan_reset (assuan_context_t ctx); + +/* Default log handler. */ +int _assuan_log_handler (assuan_context_t ctx, void *hook, + unsigned int cat, const char *msg); + + +/* Manage memory specific to a context. */ +void *_assuan_malloc (assuan_context_t ctx, size_t cnt); +void *_assuan_realloc (assuan_context_t ctx, void *ptr, size_t cnt); +void *_assuan_calloc (assuan_context_t ctx, size_t cnt, size_t elsize); +void _assuan_free (assuan_context_t ctx, void *ptr); + + /*-- assuan-pipe-server.c --*/ -gpg_error_t _assuan_new_context (assuan_context_t *r_ctx); void _assuan_release_context (assuan_context_t ctx); /*-- assuan-uds.c --*/ @@ -223,16 +271,9 @@ int _assuan_error_is_eagain (gpg_error_t err); -/*-- assuan-util.c --*/ -void *_assuan_malloc (size_t n); -void *_assuan_calloc (size_t n, size_t m); -void *_assuan_realloc (void *p, size_t n); -void _assuan_free (void *p); -gpg_error_t _assuan_error (gpg_err_code_t errcode); - #define set_error(c,e,t) \ - assuan_set_error ((c), _assuan_error (e), (t)) + assuan_set_error ((c), _assuan_error (c,e), (t)) #ifdef HAVE_W32_SYSTEM const char *_assuan_w32_strerror (int ec); @@ -241,17 +282,9 @@ /*-- assuan-logging.c --*/ -void _assuan_set_default_log_stream (FILE *fp); +void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); -void _assuan_log_printf (const char *format, ...) -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) - __attribute__ ((format (printf,1,2))) -#endif - ; -void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); -void _assuan_log_sanitized_string (const char *string); - /*-- assuan-io.c --*/ pid_t _assuan_waitpid (pid_t pid, int *status, int options); @@ -322,4 +355,10 @@ #endif +void _assuan_disconnect (assuan_context_t ctx); + +/* Encode the C formatted string SRC and return the malloc'ed result. */ +char *_assuan_encode_c_string (assuan_context_t ctx, const char *src); + + #endif /*ASSUAN_DEFS_H*/ Modified: trunk/src/assuan-error.c =================================================================== --- trunk/src/assuan-error.c 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/src/assuan-error.c 2009-09-21 01:08:08 UTC (rev 303) @@ -29,31 +29,7 @@ #include "assuan.h" #include "assuan-defs.h" -/* If true the modern gpg-error style error codes are used in the - API. */ -static gpg_err_source_t err_source; -/* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error - sources. Note, that this function is not thread-safe and should be - used right at startup. Switching back to the old style mode is not - supported. */ -void -assuan_set_assuan_err_source (gpg_err_source_t errsource) -{ - errsource &= 0xff; - err_source = errsource ? errsource : 31 /*GPG_ERR_SOURCE_ANY*/; -} - - -/* Helper to map old style Assuan error codes to gpg-error codes. - This is used internally to keep an compatible ABI. */ -gpg_error_t -_assuan_error (gpg_err_code_t errcode) -{ - return gpg_err_make (err_source, errcode); -} - - /* A small helper function to treat EAGAIN transparently to the caller. */ int @@ -68,3 +44,20 @@ else return 0; } + + + +#ifdef HAVE_W32_SYSTEM +char * +_assuan_w32_strerror (assuan_context_t ctx, int ec) +{ + if (ec == -1) + ec = (int)GetLastError (); + FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec, + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + ctx->w32_strerror, sizeof (ctx->w32_strerror) - 1, NULL); + + return ctx->w32_strerror; +} +#endif + Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2009-09-08 16:47:28 UTC (rev 302) +++ trunk/src/assuan-handler.c 2009-09-21 01:08:08 UTC (rev 303) @@ -27,9 +27,9 @@ #include #include "assuan-defs.h" +#include "debug.h" - #define spacep(p) (*(p) == ' ' || *(p) == '\t') #define digitp(a) ((a) >= '0' && (a) <= '9') @@ -123,7 +123,7 @@ assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); /* pretty simple :-) */ - return PROCESS_DONE (ctx, _assuan_error (GPG_ERR_EOF)); + return PROCESS_DONE (ctx, _assuan_error (ctx, GPG_ERR_EOF)); } static gpg_error_t @@ -287,7 +287,7 @@ cmd_name = NULL; if (!cmd_name) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); if (!handler) { /* find a default handler. */ @@ -308,18 +308,18 @@ if (!ctx->cmdtbl) { ctx->cmdtbl_size = 50; - ctx->cmdtbl = _assuan_calloc (ctx->cmdtbl_size, sizeof *ctx->cmdtbl); + ctx->cmdtbl = _assuan_calloc (ctx, ctx->cmdtbl_size, sizeof *ctx->cmdtbl); if (!ctx->cmdtbl) - return _assuan_error (gpg_err_code_from_syserror ()); + return _assuan_error (ctx, gpg_err_code_from_syserror ()); ctx->cmdtbl_used = 0; } else if (ctx->cmdtbl_used >= ctx->cmdtbl_size) { struct cmdtbl_s *x; - x = _assuan_realloc ( ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x); + x = _assuan_realloc (ctx, ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x); if (!x) - return _assuan_error (gpg_err_code_from_syserror ()); + return _assuan_error (ctx, gpg_err_code_from_syserror ()); ctx->cmdtbl = x; ctx->cmdtbl_size += 50; } @@ -335,7 +335,7 @@ void (*fnc)(assuan_context_t, gpg_error_t)) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); ctx->post_cmd_notify_fnc = fnc; return 0; } @@ -345,7 +345,7 @@ void (*fnc)(assuan_context_t)) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); ctx->bye_notify_fnc = fnc; return 0; } @@ -355,7 +355,7 @@ void (*fnc)(assuan_context_t)) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); ctx->reset_notify_fnc = fnc; return 0; } @@ -365,7 +365,7 @@ void (*fnc)(assuan_context_t)) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); ctx->cancel_notify_fnc = fnc; return 0; } @@ -376,7 +376,7 @@ const char*, const char*)) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); ctx->option_handler_fnc = fnc; return 0; } @@ -386,7 +386,7 @@ void (*fnc)(assuan_context_t, const char *)) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); ctx->input_notify_fnc = fnc; return 0; } @@ -396,7 +396,7 @@ void (*fnc)(assuan_context_t, const char *)) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); ctx->output_notify_fnc = fnc; return 0; } @@ -508,7 +508,7 @@ assuan_process_done (assuan_context_t ctx, gpg_error_t rc) { if (!ctx->in_command) - return _assuan_error (GPG_ERR_ASS_GENERAL); + return _assuan_error (ctx, GPG_ERR_ASS_GENERAL); ctx->in_command = 0; @@ -557,10 +557,10 @@ if (ctx->post_cmd_notify_fnc) ctx->post_cmd_notify_fnc (ctx, rc); - ctx->confidential = 0; + ctx->flags.confidential = 0; if (ctx->okay_line) { - _assuan_free (ctx->okay_line); + _assuan_free (ctx, ctx->okay_line); ctx->okay_line = NULL; } @@ -613,7 +613,8 @@ /* Should not happen. The client is sending data while we are in a command and not waiting for an inquire. We log an error and discard it. */ - _assuan_log_printf ("unexpected client data\n"); + TRACE0 (ctx, ASSUAN_LOG_DATA, "process_next", ctx, + "unexpected client data"); rc = 0; } @@ -649,7 +650,7 @@ gpg_error_t rc; if (ctx->in_inquire) - return _assuan_error (GPG_ERR_ASS_NESTED_COMMANDS); + return _assuan_error (ctx, GPG_ERR_ASS_NESTED_COMMANDS); do { @@ -798,22 +799,22 @@ assuan_set_okay_line (assuan_context_t ctx, const char *line) { if (!ctx) - return _assuan_error (GPG_ERR_ASS_INV_VALUE); + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); if (!line) { - _assuan_free (ctx->okay_line); + _assuan_free (ctx, ctx->okay_line); ctx->okay_line = NULL; } else { /* FIXME: we need to use gcry_is_secure() to test whether we should allocate the entire line in secure memory */ - char *buf = _assuan_malloc (3 + strlen(line) + 1); + char *buf = _assuan_malloc (ctx, 3 + strlen(line) + 1); if (!buf) - return _assuan_error (gpg_err_code_from_syserror ()); + return _assuan_error (ctx, gpg_err_code_from_syserror ()); strcpy (buf, "OK "); strcpy (buf+3, line); - _assuan_free (ctx->okay_line); + _assuan_free (ctx, ctx->okay_line); ctx->okay_line = buf; } return 0; From cvs at cvs.gnupg.org Mon Sep 21 20:07:28 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 21 Sep 2009 20:07:28 +0200 Subject: [svn] GnuPG - r5159 - branches Message-ID: Author: wk Date: 2009-09-21 20:07:28 +0200 (Mon, 21 Sep 2009) New Revision: 5159 Added: branches/STABLE-BRANCH-2-0/ Log: Create a branch for 2.0. From cvs at cvs.gnupg.org Mon Sep 21 20:26:52 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 21 Sep 2009 20:26:52 +0200 Subject: [svn] GnuPG - r5160 - in trunk: . po Message-ID: Author: wk Date: 2009-09-21 20:26:52 +0200 (Mon, 21 Sep 2009) New Revision: 5160 Modified: trunk/ChangeLog trunk/NEWS trunk/README trunk/configure.ac trunk/po/LINGUAS Log: Start a new development branch. Translations are for now disabled. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-21 18:07:28 UTC (rev 5159) +++ trunk/ChangeLog 2009-09-21 18:26:52 UTC (rev 5160) @@ -1,3 +1,8 @@ +2009-09-21 Werner Koch + + Start a new development branch in the SVN trunk. The stable one + is now known in the SVN as branches/GNUPG-STABLE-2-0. + 2009-09-04 Werner Koch Release 2.0.13. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-09-21 18:07:28 UTC (rev 5159) +++ trunk/NEWS 2009-09-21 18:26:52 UTC (rev 5160) @@ -1,4 +1,4 @@ -Noteworthy changes in version 2.0.14 +Noteworthy changes in version 2.1 (under development) ------------------------------------------------- Modified: trunk/README =================================================================== --- trunk/README 2009-09-21 18:07:28 UTC (rev 5159) +++ trunk/README 2009-09-21 18:26:52 UTC (rev 5160) @@ -1,11 +1,15 @@ The GNU Privacy Guard 2 ========================= - Version 2.0 + Version 2.1 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + THIS IS A DEVELOPMENT VERSION AND NOT INTENDED FOR REGULAR USE. + THIS IS A DEVELOPMENT VERSION AND NOT INTENDED FOR REGULAR USE. + THIS IS A DEVELOPMENT VERSION AND NOT INTENDED FOR REGULAR USE. + INTRODUCTION ============ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-09-21 18:07:28 UTC (rev 5159) +++ trunk/configure.ac 2009-09-21 18:26:52 UTC (rev 5160) @@ -1,6 +1,6 @@ -# configure.ac - for GnuPG 2.0 +# configure.ac - for GnuPG 2.1 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. +# 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # # This file is part of GnuPG. # @@ -24,7 +24,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], [2.0.14]) +m4_define([my_version], [2.1.0]) m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \ Modified: trunk/po/LINGUAS =================================================================== --- trunk/po/LINGUAS 2009-09-21 18:07:28 UTC (rev 5159) +++ trunk/po/LINGUAS 2009-09-21 18:26:52 UTC (rev 5160) @@ -1,29 +1,29 @@ -en at quot -en at boldquot -be -ca -cs -da -de -eo -el -es -et -fi -fr -gl -hu -id -it -ja -nb -pl -pt_BR -pt -ro -ru -sk -sv -tr -zh_TW -zh_CN +#en at quot +#en at boldquot +#be +#ca +#cs +#da +#de +#eo +#el +#es +#et +#fi +#fr +#gl +#hu +#id +#it +#ja +#nb +#pl +#pt_BR +#pt +#ro +#ru +#sk +#sv +#tr +#zh_TW +#zh_CN From cvs at cvs.gnupg.org Mon Sep 21 20:59:13 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 21 Sep 2009 20:59:13 +0200 Subject: [svn] gpg-error - r222 - in trunk: . src Message-ID: Author: wk Date: 2009-09-21 20:59:12 +0200 (Mon, 21 Sep 2009) New Revision: 222 Modified: trunk/ChangeLog trunk/NEWS trunk/src/err-sources.h.in Log: Add a new erroro source Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-08-20 08:27:40 UTC (rev 221) +++ trunk/ChangeLog 2009-09-21 18:59:12 UTC (rev 222) @@ -1,3 +1,7 @@ +2009-09-21 Werner Koch + + * src/err-sources.h.in (GPG_ERR_SOURCE_G13): New. + 2009-08-20 Werner Koch * src/err-codes.h.in: s/octadecimal/octal/. Reported by Petr Pisar. @@ -16,7 +20,7 @@ transparently translated. * src/code-from-errno.c [HAVE_W32_SYSTEM]: Don't include winsock2.h. (w32_special_errnos) [HAVE_W32_SYSTEM]: Removed. - (gpg_err_code_from_errno) [HAVE_W32_SYSTEM]: Remove special case. + (gpg_err_code_from_errno) [HAVE_W32_SYSTEM]: Remove special case. * README: Document problem with printing some WSA Errors. 2009-06-23 Marcus Brinkmann Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-08-20 08:27:40 UTC (rev 221) +++ trunk/NEWS 2009-09-21 18:59:12 UTC (rev 222) @@ -4,6 +4,7 @@ * Interface changes relative to the 1.7 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPG_ERR_NOT_ENABLED NEW + GPG_ERR_SOURCE_G13 NEW Noteworthy changes in version 1.7 (2008-11-26) Modified: trunk/src/err-sources.h.in =================================================================== --- trunk/src/err-sources.h.in 2009-08-20 08:27:40 UTC (rev 221) +++ trunk/src/err-sources.h.in 2009-09-21 18:59:12 UTC (rev 222) @@ -43,8 +43,9 @@ 11 GPG_ERR_SOURCE_GSTI GSTI 12 GPG_ERR_SOURCE_GPA GPA 13 GPG_ERR_SOURCE_KLEO Kleopatra +14 GPG_ERR_SOURCE_G13 G13 -# 14 to 30 are free to be used. +# 15 to 30 are free to be used. 31 GPG_ERR_SOURCE_ANY Any source 32 GPG_ERR_SOURCE_USER_1 User defined source 1 From cvs at cvs.gnupg.org Wed Sep 23 01:14:12 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 23 Sep 2009 01:14:12 +0200 Subject: [svn] dirmngr - r325 - in trunk: . src tests Message-ID: Author: marcus Date: 2009-09-23 01:14:11 +0200 (Wed, 23 Sep 2009) New Revision: 325 Modified: trunk/configure.ac trunk/src/ChangeLog trunk/src/dirmngr-client.c trunk/src/dirmngr.c trunk/src/server.c trunk/tests/test-dirmngr.c Log: 2009-09-22 Marcus Brinkmann * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Bump to new Assuan interface (2, 1.1.0). * tests/test-dirmngr.c: Update to new Assuan interface. (print_assuan_error): Use gpg_strerror instead of assuan_strerror. (start_dirmngr): Allocate context with assuan_new before connecting to server. Release on error. (sendcert): Return gpg_error_t instead of int. src/ 2009-09-22 Marcus Brinkmann * dirmngr.c (main): Update to new Assuan interface. * server.c (option_handler, cmd_ldapserver, cmd_isvalid) (cmd_checkcrl, cmd_checkocsp, cmd_lookup, cmd_loadcrl) (cmd_listcrls, cmd_cachecert, cmd_validate): Return gpg_error_t instead int. (register_commands): Likewise for member HANDLER. (start_command_handler): Allocate context with assuan_new before starting server. Release on error. * dirmngr-client.c (main): Update to new Assuan interface. (start_dirmngr): Allocate context with assuan_new before connecting to server. Release on error. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-08-12 19:29:31 UTC (rev 324) +++ trunk/src/ChangeLog 2009-09-22 23:14:11 UTC (rev 325) @@ -1,3 +1,17 @@ +2009-09-22 Marcus Brinkmann + + * dirmngr.c (main): Update to new Assuan interface. + * server.c (option_handler, cmd_ldapserver, cmd_isvalid) + (cmd_checkcrl, cmd_checkocsp, cmd_lookup, cmd_loadcrl) + (cmd_listcrls, cmd_cachecert, cmd_validate): Return gpg_error_t + instead int. + (register_commands): Likewise for member HANDLER. + (start_command_handler): Allocate context with assuan_new before + starting server. Release on error. + * dirmngr-client.c (main): Update to new Assuan interface. + (start_dirmngr): Allocate context with assuan_new before + connecting to server. Release on error. + 2009-08-12 Werner Koch * dirmngr-client.c (squid_loop_body): Flush stdout. Suggested by Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-08-12 19:29:31 UTC (rev 324) +++ trunk/configure.ac 2009-09-22 23:14:11 UTC (rev 325) @@ -41,8 +41,8 @@ NEED_LIBGCRYPT_API=1 NEED_LIBGCRYPT_VERSION=1.4.0 -NEED_LIBASSUAN_API=1 -NEED_LIBASSUAN_VERSION=1.0.4 +NEED_LIBASSUAN_API=2 +NEED_LIBASSUAN_VERSION=1.1.0 NEED_KSBA_API=1 NEED_KSBA_VERSION=1.0.2 Modified: trunk/src/dirmngr-client.c =================================================================== --- trunk/src/dirmngr-client.c 2009-08-12 19:29:31 UTC (rev 324) +++ trunk/src/dirmngr-client.c 2009-09-22 23:14:11 UTC (rev 325) @@ -211,9 +211,8 @@ #endif /*HAVE_W32_SYSTEM*/ /* Init Assuan. */ - assuan_set_assuan_log_stream (log_get_stream ()); assuan_set_assuan_log_prefix (log_get_prefix (NULL)); - assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); + assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); /* Setup I18N. */ i18n_init(); @@ -367,7 +366,7 @@ xfree (certbuf); } - assuan_disconnect (ctx); + assuan_release (ctx); if (cmd_ping) { @@ -463,6 +462,14 @@ infostr = xstrdup (default_socket_name ()); try_default = 1; } + + rc = assuan_new (&ctx); + if (rc) + { + log_error (_("can't create assuan context: %s\n"), gpg_strerror (rc)); + return NULL; + } + if (!infostr || !*infostr) { const char *pgmname; @@ -497,7 +504,7 @@ no_close_list[i] = -1; /* Connect to the agent and perform initial handshaking. */ - rc = assuan_pipe_connect (&ctx, opt.dirmngr_program, argv, + rc = assuan_pipe_connect (ctx, opt.dirmngr_program, argv, no_close_list); } else /* Connect to a daemon. */ @@ -537,7 +544,7 @@ else pid = -1; - rc = assuan_socket_connect (&ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid); xfree (infostr); if (gpg_err_code(rc) == GPG_ERR_ASS_CONNECT_FAILED && !only_daemon) { @@ -549,6 +556,7 @@ if (rc) { + assuan_release (ctx); log_error (_("can't connect to the dirmngr: %s\n"), gpg_strerror (rc)); return NULL; Modified: trunk/src/dirmngr.c =================================================================== --- trunk/src/dirmngr.c 2009-08-12 19:29:31 UTC (rev 324) +++ trunk/src/dirmngr.c 2009-09-22 23:14:11 UTC (rev 325) @@ -592,6 +592,7 @@ int debug_wait = 0; int rc; int homedir_seen = 0; + struct assuan_malloc_hooks malloc_hooks; #ifdef HAVE_W32_SYSTEM /* The option will be set by main() below if we should run as a @@ -654,10 +655,12 @@ /* Init Assuan. */ - assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free); - assuan_set_assuan_log_stream (log_get_stream ()); + malloc_hooks.malloc = gcry_malloc; + malloc_hooks.realloc = gcry_realloc; + malloc_hooks.free = gcry_free; + assuan_set_malloc_hooks (&malloc_hooks); assuan_set_assuan_log_prefix (log_get_prefix (NULL)); - assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); + assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); /* Setup I18N. */ i18n_init(); @@ -914,7 +917,6 @@ { log_set_file (logfile); log_set_prefix (NULL, 2|4); - assuan_set_assuan_log_stream (log_get_stream ()); } if (debug_wait) @@ -949,7 +951,6 @@ |JNLIB_LOG_WITH_TIME |JNLIB_LOG_WITH_PID)); current_logfile = xstrdup (logfile); - assuan_set_assuan_log_stream (log_get_stream ()); } #ifndef HAVE_W32_SYSTEM Modified: trunk/src/server.c =================================================================== --- trunk/src/server.c 2009-08-12 19:29:31 UTC (rev 324) +++ trunk/src/server.c 2009-09-22 23:14:11 UTC (rev 325) @@ -416,7 +416,7 @@ /* Handle OPTION commands. */ -static int +static gpg_error_t option_handler (assuan_context_t ctx, const char *key, const char *value) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -438,7 +438,7 @@ } -static int +static gpg_error_t cmd_ldapserver (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -486,7 +486,7 @@ OCSP responder URL won't be used. */ -static int +static gpg_error_t cmd_isvalid (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -635,7 +635,7 @@ The return value is the usual gpg-error code or 0 for ducesss; i.e. the certificate validity has been confirmed by a valid CRL. */ -static int +static gpg_error_t cmd_checkcrl (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -719,7 +719,7 @@ The return value is the usual gpg-error code or 0 for ducesss; i.e. the certificate validity has been confirmed by a valid CRL. */ -static int +static gpg_error_t cmd_checkocsp (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1045,7 +1045,7 @@ certificates from the cache may get returned. */ -static int +static gpg_error_t cmd_lookup (assuan_context_t ctx, char *line) { gpg_error_t err; @@ -1084,7 +1084,7 @@ is not useful because gpgsm might need to callback gpgsm to ask for the CA's certificate. */ -static int +static gpg_error_t cmd_loadcrl (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1139,7 +1139,7 @@ --list-crls". */ -static int +static gpg_error_t cmd_listcrls (assuan_context_t ctx, char *line) { gpg_error_t err; @@ -1170,7 +1170,7 @@ and the caller is expected to return the certificate for the request as a binary blob. */ -static int +static gpg_error_t cmd_cachecert (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1223,7 +1223,7 @@ and the caller is expected to return the certificate for the request as a binary blob. */ -static int +static gpg_error_t cmd_validate (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1287,7 +1287,7 @@ { static struct { const char *name; - int (*handler)(assuan_context_t, char *line); + gpg_error_t (*handler)(assuan_context_t, char *line); } table[] = { { "LDAPSERVER", cmd_ldapserver }, { "ISVALID", cmd_isvalid }, @@ -1348,21 +1348,30 @@ dirmngr_init_default_ctrl (ctrl); + rc = assuan_new (&ctx); + if (rc) + { + log_error (_("failed to allocate assuan context: %s\n"), + gpg_strerror (rc)); + dirmngr_exit (2); + } + if (fd == ASSUAN_INVALID_FD) { int filedes[2]; - + filedes[0] = 0; filedes[1] = 1; - rc = assuan_init_pipe_server (&ctx, filedes); + rc = assuan_init_pipe_server (ctx, filedes); } else { - rc = assuan_init_socket_server_ext (&ctx, fd, 2); + rc = assuan_init_socket_server_ext (ctx, fd, 2); } if (rc) { + assuan_release (ctx); log_error (_("failed to initialize the server: %s\n"), gpg_strerror(rc)); dirmngr_exit (2); @@ -1445,7 +1454,7 @@ ctrl->server_local->ldapservers = NULL; ctrl->server_local->assuan_ctx = NULL; - assuan_deinit_server (ctx); + assuan_release (ctx); if (ctrl->refcount) log_error ("oops: connection control structure still referenced (%d)\n", Modified: trunk/tests/test-dirmngr.c =================================================================== --- trunk/tests/test-dirmngr.c 2009-08-12 19:29:31 UTC (rev 324) +++ trunk/tests/test-dirmngr.c 2009-09-22 23:14:11 UTC (rev 325) @@ -15,7 +15,7 @@ assuan_context_t entry_ctx; -#define print_assuan_error( rc ) fprintf(stderr, "Error: %s", assuan_strerror( rc ) ) +#define print_assuan_error( rc ) fprintf(stderr, "Error: %s", gpg_strerror (rc)) #define fail_if_err(a) do { if(a) { \ fprintf (stderr, "%s:%d: KSBA error: %s\n", \ @@ -55,11 +55,19 @@ argv[0] = pgmname; argv[1] = NULL; - rc = assuan_pipe_connect (&ctx, pgmname, argv, 0); + rc = assuan_new (&ctx); if (rc) { + log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc)); + return -1; + } + + rc = assuan_pipe_connect (ctx, pgmname, argv, 0); + if (rc) + { + assuan_release (ctx); log_error ("can't connect to the DirMngr module: %s\n", - assuan_strerror (rc)); + gpg_strerror (rc)); return -1; } entry_ctx = ctx; @@ -131,31 +139,31 @@ static int inquire_done = 0; -static int -sendcert( void* ctx, const char* line) +static gpg_error_t +sendcert (void* ctx, const char* line) { FILE* infp; char buf[4096]; int len = 0; fprintf(stderr, "######## Got inquiry \"%s\"\n", line ); -/* This hack is because we only want to send */ -/* the cert. Dirmngr will ask a second time */ -/* -- this time for the issuer cert. */ -/* We dont know that, so we return nothing */ - if( inquire_done ) return ASSUAN_No_Error; + /* This hack is because we only want to send the cert. Dirmngr will + ask a second time -- this time for the issuer cert. We dont know + that, so we return nothing. */ + if (inquire_done) + return 0; inquire_done = 1; infp = fopen( fname, "r" ); if( infp == NULL ) { perror("Error opening cert file"); - return ASSUAN_General_Error; + return gpg_error (GPG_ERR_GENERAL); } while( !feof( infp ) ) { len += fread( buf+len, 1, sizeof(buf)-len, infp ); } assuan_send_data( ctx, buf, len); fclose( infp ); - return ASSUAN_No_Error; + return 0; } @@ -231,7 +239,8 @@ fprintf(stderr, "sending \"%s\"\n", line ); - rc = assuan_transact (entry_ctx, line, NULL, NULL, sendcert, entry_ctx, NULL, NULL); + rc = assuan_transact (entry_ctx, line, NULL, NULL, + sendcert, entry_ctx, NULL, NULL); if( rc ) { fprintf(stderr,"\n#######"); print_assuan_error(rc); From cvs at cvs.gnupg.org Wed Sep 23 01:15:15 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 23 Sep 2009 01:15:15 +0200 Subject: [svn] dirmngr - r326 - trunk Message-ID: Author: marcus Date: 2009-09-23 01:15:15 +0200 (Wed, 23 Sep 2009) New Revision: 326 Modified: trunk/ChangeLog Log: 2009-09-22 Marcus Brinkmann * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Bump to new Assuan interface (2, 1.1.0). * tests/test-dirmngr.c: Update to new Assuan interface. (print_assuan_error): Use gpg_strerror instead of assuan_strerror. (start_dirmngr): Allocate context with assuan_new before connecting to server. Release on error. (sendcert): Return gpg_error_t instead of int. src/ 2009-09-22 Marcus Brinkmann * dirmngr.c (main): Update to new Assuan interface. * server.c (option_handler, cmd_ldapserver, cmd_isvalid) (cmd_checkcrl, cmd_checkocsp, cmd_lookup, cmd_loadcrl) (cmd_listcrls, cmd_cachecert, cmd_validate): Return gpg_error_t instead int. (register_commands): Likewise for member HANDLER. (start_command_handler): Allocate context with assuan_new before starting server. Release on error. * dirmngr-client.c (main): Update to new Assuan interface. (start_dirmngr): Allocate context with assuan_new before connecting to server. Release on error. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-22 23:14:11 UTC (rev 325) +++ trunk/ChangeLog 2009-09-22 23:15:15 UTC (rev 326) @@ -1,3 +1,14 @@ +2009-09-22 Marcus Brinkmann + + * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Bump + to new Assuan interface (2, 1.1.0). + * tests/test-dirmngr.c: Update to new Assuan interface. + (print_assuan_error): Use gpg_strerror + instead of assuan_strerror. + (start_dirmngr): Allocate context with assuan_new before + connecting to server. Release on error. + (sendcert): Return gpg_error_t instead of int. + 2009-08-07 Werner Koch * configure.ac: Check for strtoull. From cvs at cvs.gnupg.org Wed Sep 23 02:01:26 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 23 Sep 2009 02:01:26 +0200 Subject: [svn] GnuPG - r5161 - in trunk: . agent common g10 scd sm tools Message-ID: Author: marcus Date: 2009-09-23 02:01:25 +0200 (Wed, 23 Sep 2009) New Revision: 5161 Modified: trunk/ChangeLog trunk/agent/ChangeLog trunk/agent/call-pinentry.c trunk/agent/call-scd.c trunk/agent/command.c trunk/agent/gpg-agent.c trunk/common/ChangeLog trunk/common/asshelp.c trunk/configure.ac trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/g10/gpg.c trunk/g10/server.c trunk/scd/ChangeLog trunk/scd/command.c trunk/scd/scdaemon.c trunk/sm/ChangeLog trunk/sm/call-dirmngr.c trunk/sm/gpgsm.c trunk/sm/server.c trunk/tools/ChangeLog trunk/tools/gpg-connect-agent.c Log: 2009-09-23 Marcus Brinkmann * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Update to new API (2, 1.1.0). agent/ 2009-09-23 Marcus Brinkmann * gpg-agent.c (parse_rereadable_options): Don't set global assuan log file (there ain't one anymore). (main): Update to new API. (check_own_socket_pid_cb): Return gpg_error_t instead of int. (check_own_socket_thread, check_for_running_agent): Create assuan context before connecting to server. * command.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (write_and_clear_outbuf): Use gpg_error_t instead of assuan_error_t. (cmd_geteventcounter, cmd_istrusted, cmd_listtrusted) (cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc) (cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey) (cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase) (cmd_get_confirmation, cmd_learn, cmd_passwd) (cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval) (cmd_updatestartuptty, cmd_killagent, cmd_reloadagent) (cmd_getinfo, option_handler): Return gpg_error_t instead of int. (post_cmd_notify): Change type of ERR to gpg_error_t from int. (io_monitor): Add hook argument. Use symbols for constants. (register_commands): Change return type of HANDLER to gpg_error_t. (start_command_handler): Allocate assuan context before starting server. * call-pinentry.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (unlock_pinentry): Call assuan_release instead of assuan_disconnect. (getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int. (start_pinentry): Allocate assuan context before connecting to server. * call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb) (membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru) (pass_data_thru): Change return type to gpg_error_t. (start_scd): Allocate assuan context before connecting to server. common/ 2009-09-23 Marcus Brinkmann * asshelp.c (start_new_gpg_agent): Allocate assuan context before starting server. g10/ 2009-09-23 Marcus Brinkmann * call-agent.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb) (learn_status_cb, inq_writecert_parms, inq_writekey_parms) (scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of int. * gpg.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (main): Update to new Assuan API. * server.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (option_handler, cmd_recipient, cmd_signer, cmd_encrypt) (cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export) (cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys) (cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t instead of int. (register_commands): Allocate assuan context before starting server. (gpg_server): Allocate assuan_context before starting server. scd/ 2009-09-23 Marcus Brinkmann * command.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert) (cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt) (cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey) (cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock) (cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu) (cmd_killscd): Return gpg_error_t instead of int. (scd_command_handler): Allocate assuan context before starting server. * scdaemon.c (main): Update to new Assuan API. sm/ 2009-09-23 Marcus Brinkmann * gpgsm.c (main): Update to new assuan API. * server.c: Include "gpgsm.h" before due to check for GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h. (option_handler, cmd_recipient, cmd_signer, cmd_encrypt) (cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export) (cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys) (cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey) (cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int. (register_commands): Same for member HANDLER in table. (gpgsm_server): Allocate assuan context before starting server. * sm/call-dirmngr.c: * call-dirmngr.c (prepare_dirmngr): Check for CTX and error before setting LDAPSERVER. (start_dirmngr_ext): Allocate assuan context before starting server. (inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb) (run_command_cb, run_command_inq_cb, run_command_status_cb): Return gpg_error_t instead of int. tools/ 2009-09-23 Marcus Brinkmann * gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response) (main): Update to new Assuan API. [The diff below has been truncated] Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) @@ -1,3 +1,8 @@ +2009-09-23 Marcus Brinkmann + + * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): + Update to new API (2, 1.1.0). + 2009-09-21 Werner Koch Start a new development branch in the SVN trunk. The stable one Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/agent/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) @@ -1,3 +1,40 @@ +2009-09-23 Marcus Brinkmann + + * gpg-agent.c (parse_rereadable_options): Don't set global assuan + log file (there ain't one anymore). + (main): Update to new API. + (check_own_socket_pid_cb): Return gpg_error_t instead of int. + (check_own_socket_thread, check_for_running_agent): Create assuan + context before connecting to server. + * command.c: Include "scdaemon.h" before because of + GPG_ERR_SOURCE_DEFAULT check. + (write_and_clear_outbuf): Use gpg_error_t instead of + assuan_error_t. + (cmd_geteventcounter, cmd_istrusted, cmd_listtrusted) + (cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc) + (cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey) + (cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase) + (cmd_get_confirmation, cmd_learn, cmd_passwd) + (cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval) + (cmd_updatestartuptty, cmd_killagent, cmd_reloadagent) + (cmd_getinfo, option_handler): Return gpg_error_t instead of int. + (post_cmd_notify): Change type of ERR to gpg_error_t from int. + (io_monitor): Add hook argument. Use symbols for constants. + (register_commands): Change return type of HANDLER to gpg_error_t. + (start_command_handler): Allocate assuan context before starting + server. + * call-pinentry.c: Include "scdaemon.h" before because + of GPG_ERR_SOURCE_DEFAULT check. + (unlock_pinentry): Call assuan_release instead of + assuan_disconnect. + (getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int. + (start_pinentry): Allocate assuan context before connecting to + server. + * call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb) + (membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru) + (pass_data_thru): Change return type to gpg_error_t. + (start_scd): Allocate assuan context before connecting to server. + 2009-09-04 Marcus Brinkmann * command.c (start_command_handler): Add comment about gap in Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/common/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) @@ -1,3 +1,8 @@ +2009-09-23 Marcus Brinkmann + + * asshelp.c (start_new_gpg_agent): Allocate assuan context before + starting server. + 2009-09-03 Werner Koch Update from libestream: Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/g10/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) @@ -1,3 +1,25 @@ +2009-09-23 Marcus Brinkmann + + * call-agent.c: Include "scdaemon.h" before because of + GPG_ERR_SOURCE_DEFAULT check. + (learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb) + (learn_status_cb, inq_writecert_parms, inq_writekey_parms) + (scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of + int. + * gpg.c: Include "scdaemon.h" before because of + GPG_ERR_SOURCE_DEFAULT check. + (main): Update to new Assuan API. + * server.c: Include "scdaemon.h" before because of + GPG_ERR_SOURCE_DEFAULT check. + (option_handler, cmd_recipient, cmd_signer, cmd_encrypt) + (cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export) + (cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys) + (cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t + instead of int. + (register_commands): Allocate assuan context before starting + server. + (gpg_server): Allocate assuan_context before starting server. + 2009-09-04 Werner Koch * keyedit.c (menu_select_uid): Use IDX ==-1 t select all. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/scd/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) @@ -1,3 +1,16 @@ +2009-09-23 Marcus Brinkmann + + * command.c: Include "scdaemon.h" before because of + GPG_ERR_SOURCE_DEFAULT check. + (option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert) + (cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt) + (cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey) + (cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock) + (cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu) + (cmd_killscd): Return gpg_error_t instead of int. + (scd_command_handler): Allocate assuan context before starting server. + * scdaemon.c (main): Update to new Assuan API. + 2009-09-03 Werner Koch * app-openpgp.c (do_decipher): Compute required Le. Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/sm/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) @@ -1,3 +1,24 @@ +2009-09-23 Marcus Brinkmann + + * gpgsm.c (main): Update to new assuan API. + * server.c: Include "gpgsm.h" before due to check for + GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h. + (option_handler, cmd_recipient, cmd_signer, cmd_encrypt) + (cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export) + (cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys) + (cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey) + (cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int. + (register_commands): Same for member HANDLER in table. + (gpgsm_server): Allocate assuan context before starting server. + * sm/call-dirmngr.c: + * call-dirmngr.c (prepare_dirmngr): Check for CTX and error before + setting LDAPSERVER. + (start_dirmngr_ext): Allocate assuan context before starting + server. + (inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb) + (run_command_cb, run_command_inq_cb, run_command_status_cb): + Return gpg_error_t instead of int. + 2009-08-06 Werner Koch * sign.c (gpgsm_sign): Print INV_SNDR for a bad default key. Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/tools/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) @@ -1,3 +1,8 @@ +2009-09-23 Marcus Brinkmann + + * gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response) + (main): Update to new Assuan API. + 2009-07-21 Werner Koch * gpgsplit.c (my_strusage): Remove i18n stuff. Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/agent/call-pinentry.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -32,9 +32,9 @@ # include #endif #include -#include #include "agent.h" +#include #include "setenv.h" #include "i18n.h" @@ -158,7 +158,7 @@ if (!rc) rc = gpg_error (GPG_ERR_INTERNAL); } - assuan_disconnect (ctx); + assuan_release (ctx); return rc; } @@ -196,7 +196,7 @@ } -static int +static gpg_error_t getinfo_pid_cb (void *opaque, const void *buffer, size_t length) { unsigned long *pid = opaque; @@ -309,16 +309,24 @@ } no_close_list[i] = -1; + rc = assuan_new (&ctx); + if (rc) + { + log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc)); + return rc; + } + /* Connect to the pinentry and perform initial handshaking. Note that atfork is used to change the environment for pinentry. We start the server in detached mode to suppress the console window under Windows. */ - rc = assuan_pipe_connect_ext (&ctx, opt.pinentry_program, argv, + rc = assuan_pipe_connect_ext (ctx, opt.pinentry_program, argv, no_close_list, atfork_cb, ctrl, 128); if (rc) { log_error ("can't connect to the PIN entry module: %s\n", gpg_strerror (rc)); + assuan_release (ctx); return unlock_pinentry (gpg_error (GPG_ERR_NO_PIN_ENTRY)); } entry_ctx = ctx; @@ -463,7 +471,7 @@ } -static int +static gpg_error_t getpin_cb (void *opaque, const void *buffer, size_t length) { struct entry_parm_s *parm = opaque; @@ -553,7 +561,7 @@ /* Handle the QUALITY inquiry. */ -static int +static gpg_error_t inq_quality (void *opaque, const char *line) { assuan_context_t ctx = opaque; Modified: trunk/agent/call-scd.c =================================================================== --- trunk/agent/call-scd.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/agent/call-scd.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -108,8 +108,8 @@ /* Local prototypes. */ -static assuan_error_t membuf_data_cb (void *opaque, - const void *buffer, size_t length); +static gpg_error_t membuf_data_cb (void *opaque, + const void *buffer, size_t length); @@ -209,7 +209,7 @@ { gpg_error_t err = 0; const char *pgmname; - assuan_context_t ctx; + assuan_context_t ctx = NULL; const char *argv[3]; int no_close_list[3]; int i; @@ -268,9 +268,17 @@ goto leave; } + rc = assuan_new (&ctx); + if (rc) + { + log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc)); + err = rc; + goto leave; + } + if (socket_name) { - rc = assuan_socket_connect (&ctx, socket_name, 0); + rc = assuan_socket_connect (ctx, socket_name, 0); if (rc) { log_error ("can't connect to socket `%s': %s\n", @@ -333,7 +341,7 @@ /* Connect to the pinentry and perform initial handshaking. Use detached flag (128) so that under W32 SCDAEMON does not show up a new window. */ - rc = assuan_pipe_connect_ext (&ctx, opt.scdaemon_program, argv, + rc = assuan_pipe_connect_ext (ctx, opt.scdaemon_program, argv, no_close_list, atfork_cb, NULL, 128); if (rc) { @@ -399,6 +407,8 @@ if (err) { unlock_scd (ctrl, err); + if (ctx) + assuan_release (ctx); } else { @@ -477,14 +487,14 @@ struct scd_local_s *sl; assuan_set_flag (primary_scd_ctx, ASSUAN_NO_WAITPID, 1); - assuan_disconnect (primary_scd_ctx); + assuan_release (primary_scd_ctx); for (sl=scd_local_list; sl; sl = sl->next_local) { if (sl->ctx) { if (sl->ctx != primary_scd_ctx) - assuan_disconnect (sl->ctx); + assuan_release (sl->ctx); sl->ctx = NULL; } } @@ -534,7 +544,7 @@ primary_scd_ctx_reusable = 1; } else - assuan_disconnect (ctrl->scd_local->ctx); + assuan_release (ctrl->scd_local->ctx); ctrl->scd_local->ctx = NULL; } @@ -563,7 +573,7 @@ -static int +static gpg_error_t learn_status_cb (void *opaque, const char *line) { struct learn_parm_s *parm = opaque; @@ -626,7 +636,7 @@ -static int +static gpg_error_t get_serialno_cb (void *opaque, const char *line) { char **serialno = opaque; @@ -684,7 +694,7 @@ -static assuan_error_t +static gpg_error_t membuf_data_cb (void *opaque, const void *buffer, size_t length) { membuf_t *data = opaque; @@ -695,7 +705,7 @@ } /* Handle the NEEDPIN inquiry. */ -static int +static gpg_error_t inq_needpin (void *opaque, const char *line) { struct inq_needpin_s *parm = opaque; @@ -991,7 +1001,7 @@ }; /* Callback function for agent_card_getattr. */ -static assuan_error_t +static gpg_error_t card_getattr_cb (void *opaque, const char *line) { struct card_getattr_parm_s *parm = opaque; @@ -1067,7 +1077,7 @@ -static int +static gpg_error_t pass_status_thru (void *opaque, const char *line) { assuan_context_t ctx = opaque; @@ -1087,7 +1097,7 @@ return 0; } -static int +static gpg_error_t pass_data_thru (void *opaque, const void *buffer, size_t length) { assuan_context_t ctx = opaque; Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/agent/command.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -34,10 +34,9 @@ #include #include +#include "agent.h" #include - #include "i18n.h" -#include "agent.h" /* maximum allowed size of the inquired ciphertext */ #define MAXLEN_CIPHERTEXT 4096 @@ -133,7 +132,7 @@ static gpg_error_t write_and_clear_outbuf (assuan_context_t ctx, membuf_t *mb) { - assuan_error_t ae; + gpg_error_t ae; void *p; size_t n; @@ -354,7 +353,7 @@ KEY - Incremented for added or removed private keys. CARD - Incremented for changes of the card readers stati. */ -static int +static gpg_error_t cmd_geteventcounter (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -403,7 +402,7 @@ Return OK when we have an entry with this fingerprint in our trustlist */ -static int +static gpg_error_t cmd_istrusted (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -440,7 +439,7 @@ /* LISTTRUSTED List all entries from the trustlist */ -static int +static gpg_error_t cmd_listtrusted (assuan_context_t ctx, char *line) { int rc; @@ -457,7 +456,7 @@ /* MARKTRUSTED Store a new key in into the trustlist*/ -static int +static gpg_error_t cmd_marktrusted (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -501,7 +500,7 @@ /* HAVEKEY Return success when the secret key is available */ -static int +static gpg_error_t cmd_havekey (assuan_context_t ctx, char *line) { int rc; @@ -522,7 +521,7 @@ SETKEY Set the key used for a sign or decrypt operation */ -static int +static gpg_error_t cmd_sigkey (assuan_context_t ctx, char *line) { int rc; @@ -550,7 +549,7 @@ The description is only valid for the next PKSIGN or PKDECRYPT operation. */ -static int +static gpg_error_t cmd_setkeydesc (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -584,7 +583,7 @@ The client can use this command to tell the server about the data (which usually is a hash) to be signed. */ -static int +static gpg_error_t cmd_sethash (assuan_context_t ctx, char *line) { int rc; @@ -662,7 +661,7 @@ Perform the actual sign operation. Neither input nor output are sensitive to eavesdropping. */ -static int +static gpg_error_t cmd_pksign (assuan_context_t ctx, char *line) { int rc; @@ -696,7 +695,7 @@ Perform the actual decrypt operation. Input is not sensitive to eavesdropping */ -static int +static gpg_error_t cmd_pkdecrypt (assuan_context_t ctx, char *line) { int rc; @@ -744,7 +743,7 @@ S OK key created */ -static int +static gpg_error_t cmd_genkey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -779,7 +778,7 @@ /* READKEY Return the public key for the given keygrip. */ -static int +static gpg_error_t cmd_readkey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -892,7 +891,7 @@ } -static int +static gpg_error_t cmd_keyinfo (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1014,7 +1013,7 @@ length has been configured.) */ -static int +static gpg_error_t cmd_get_passphrase (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1167,7 +1166,7 @@ function returns with OK even when there is no cached passphrase. */ -static int +static gpg_error_t cmd_clear_passphrase (assuan_context_t ctx, char *line) { char *cacheid = NULL; @@ -1200,7 +1199,7 @@ as '+'. */ -static int +static gpg_error_t cmd_get_confirmation (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1241,7 +1240,7 @@ Learn something about the currently inserted smartcard. With --send the new certificates are send back. */ -static int +static gpg_error_t cmd_learn (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1258,7 +1257,7 @@ /* PASSWD Change the passphrase/PIN for the key identified by keygrip in LINE. */ -static int +static gpg_error_t cmd_passwd (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1304,7 +1303,7 @@ the default (currently only a timeout of -1 is allowed, which means to never expire it). If passwd is not provided, ask for it via the pinentry module. */ -static int +static gpg_error_t cmd_preset_passphrase (assuan_context_t ctx, char *line) { int rc; @@ -1367,7 +1366,7 @@ This is a general quote command to redirect everything to the SCDAEMON. */ -static int +static gpg_error_t cmd_scd (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1385,7 +1384,7 @@ Return the value for KEY from the special environment as created by PUTVAL. */ -static int +static gpg_error_t cmd_getval (assuan_context_t ctx, char *line) { int rc = 0; @@ -1442,7 +1441,7 @@ restrictions. If that value is not given any value under that KEY is removed from this special environment. */ -static int +static gpg_error_t cmd_putval (assuan_context_t ctx, char *line) { int rc = 0; @@ -1517,7 +1516,7 @@ session. This command is useful to pull future pinentries to another screen. It is only required because there is no way in the ssh-agent protocol to convey this information. */ -static int +static gpg_error_t cmd_updatestartuptty (assuan_context_t ctx, char *line) { static const char *names[] = @@ -1576,7 +1575,7 @@ Under Windows we start the agent on the fly. Thus it also make sense to allow a client to stop the agent. */ -static int +static gpg_error_t cmd_killagent (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1591,7 +1590,7 @@ As signals are inconvenient under Windows, we provide this command to allow reloading of the configuration. */ -static int +static gpg_error_t cmd_reloadagent (assuan_context_t ctx, char *line) { (void)ctx; @@ -1615,10 +1614,10 @@ ssh_socket_name - Return the name of the ssh socket. scd_running - Return OK if the SCdaemon is already running. - cmd_has_option CMD OPT + gpg_error_t - Returns OK if the command CMD implements the option OPT. */ -static int +static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { int rc = 0; @@ -1696,7 +1695,7 @@ -static int +static gpg_error_t option_handler (assuan_context_t ctx, const char *key, const char *value) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1766,7 +1765,7 @@ /* Called by libassuan after all commands. ERR is the error from the last assuan operation and not the one returned from the command. */ static void -post_cmd_notify (assuan_context_t ctx, int err) +post_cmd_notify (assuan_context_t ctx, gpg_error_t err) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1782,15 +1781,17 @@ that the debug output won't get cluttered by this primitive command. */ static unsigned int -io_monitor (assuan_context_t ctx, int direction, +io_monitor (assuan_context_t ctx, void *hook, int direction, const char *line, size_t linelen) { ctrl_t ctrl = assuan_get_pointer (ctx); + (void) hook; + /* Note that we only check for the uppercase name. This allows to see the logging for debugging if using a non-upercase command name. */ - if (ctx && !direction + if (ctx && direction == ASSUAN_IO_FROM_PEER && linelen >= 15 && !strncmp (line, "GETEVENTCOUNTER", 15) && (linelen == 15 || spacep (line+15))) @@ -1798,7 +1799,7 @@ ctrl->server_local->pause_io_logging = 1; } - return ctrl->server_local->pause_io_logging? 1:0; + return ctrl->server_local->pause_io_logging? ASSUAN_IO_MONITOR_NOLOG : 0; } @@ -1822,7 +1823,7 @@ { static struct { const char *name; - int (*handler)(assuan_context_t, char *line); + gpg_error_t (*handler)(assuan_context_t, char *line); } table[] = { { "GETEVENTCOUNTER",cmd_geteventcounter }, { "ISTRUSTED", cmd_istrusted }, @@ -1882,25 +1883,32 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd) { int rc; - assuan_context_t ctx; + assuan_context_t ctx = NULL; + rc = assuan_new (&ctx); + if (rc) + { + log_error ("failed to allocate assuan context: %s\n", gpg_strerror (rc)); + agent_exit (2); + } + if (listen_fd == GNUPG_INVALID_FD && fd == GNUPG_INVALID_FD) { int filedes[2]; filedes[0] = 0; filedes[1] = 1; - rc = assuan_init_pipe_server (&ctx, filedes); + rc = assuan_init_pipe_server (ctx, filedes); } else if (listen_fd != GNUPG_INVALID_FD) { - rc = assuan_init_socket_server_ext (&ctx, listen_fd, 0); + rc = assuan_init_socket_server_ext (ctx, listen_fd, 0); /* FIXME: Need to call assuan_sock_set_nonce for Windows. But this branch is currently not used. */ } else { - rc = assuan_init_socket_server_ext (&ctx, fd, 2); + rc = assuan_init_socket_server_ext (ctx, fd, 2); } if (rc) { @@ -1927,7 +1935,7 @@ assuan_set_log_stream (ctx, log_get_stream ()); #ifdef HAVE_ASSUAN_SET_IO_MONITOR - assuan_set_io_monitor (ctx, io_monitor); + assuan_set_io_monitor (ctx, io_monitor, NULL); #endif for (;;) @@ -1958,7 +1966,7 @@ agent_reset_query (ctrl); /* Cleanup. */ - assuan_deinit_server (ctx); + assuan_release (ctx); #ifdef HAVE_W32_SYSTEM if (ctrl->server_local->stopme) agent_exit (0); Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/agent/gpg-agent.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -471,7 +471,6 @@ || strcmp (current_logfile, pargs->r.ret_str)) { log_set_file (pargs->r.ret_str); - assuan_set_assuan_log_stream (log_get_stream ()); xfree (current_logfile); current_logfile = xtrystrdup (pargs->r.ret_str); } @@ -545,8 +544,8 @@ int gpgconf_list = 0; gpg_error_t err; const char *env_file_name = NULL; + struct assuan_malloc_hooks malloc_hooks; - /* Before we do anything else we save the list of currently open file descriptors and the signal mask. This info is required to do the exec call properly. */ @@ -588,10 +587,12 @@ NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) ); } - assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free); - assuan_set_assuan_log_stream (log_get_stream ()); + malloc_hooks.malloc = gcry_malloc; + malloc_hooks.realloc = gcry_realloc; + malloc_hooks.free = gcry_free; + assuan_set_malloc_hooks (&malloc_hooks); assuan_set_assuan_log_prefix (log_get_prefix (NULL)); - assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); + assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); setup_libgcrypt_logging (); gcry_control (GCRYCTL_USE_SECURE_RNDPOOL); @@ -917,7 +918,6 @@ |JNLIB_LOG_WITH_TIME |JNLIB_LOG_WITH_PID)); current_logfile = xstrdup (logfile); - assuan_set_assuan_log_stream (log_get_stream ()); } /* Make sure that we have a default ttyname. */ @@ -2048,7 +2048,7 @@ /* Helper for check_own_socket. */ -static int +static gpg_error_t check_own_socket_pid_cb (void *opaque, const void *buffer, size_t length) { membuf_t *mb = opaque; @@ -2065,16 +2065,23 @@ { int rc; char *sockname = arg; - assuan_context_t ctx; + assuan_context_t ctx = NULL; membuf_t mb; char *buffer; check_own_socket_running++; - rc = assuan_socket_connect (&ctx, sockname, (pid_t)(-1)); + rc = assuan_new (&ctx); xfree (sockname); if (rc) { + log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc)); + goto leave; + } + + rc = assuan_socket_connect (ctx, sockname, (pid_t)(-1)); + if (rc) + { log_error ("can't connect my own socket: %s\n", gpg_strerror (rc)); goto leave; } @@ -2099,9 +2106,10 @@ log_error ("socket is still served by this server\n"); xfree (buffer); - assuan_disconnect (ctx); leave: + if (ctx) + assuan_release (ctx); if (rc) { /* We may not remove the socket as it is now in use by another @@ -2159,7 +2167,7 @@ { int rc; char *infostr, *p; - assuan_context_t ctx; + assuan_context_t ctx = NULL; int prot, pid; if (!mode) @@ -2207,8 +2215,9 @@ pid = (pid_t)(-1); } - - rc = assuan_socket_connect (&ctx, infostr, pid); + rc = assuan_new (&ctx); + if (! rc) + rc = assuan_socket_connect (&ctx, infostr, pid); xfree (infostr); if (rc) { @@ -2217,12 +2226,15 @@ if (!mode && !silent) log_error ("can't connect to the agent: %s\n", gpg_strerror (rc)); + + if (ctx) + assuan_release (ctx); return -1; } if (!opt.quiet && !silent) log_info ("gpg-agent running and available\n"); - assuan_disconnect (ctx); + assuan_release (ctx); return 0; } Modified: trunk/common/asshelp.c =================================================================== --- trunk/common/asshelp.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/common/asshelp.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -183,6 +183,13 @@ *r_ctx = NULL; + rc = assuan_new (&ctx); + if (rc) + { + log_error ("error allocating assuan context: %s\n", gpg_strerror (rc)); + return rc; + } + restart: infostr = force_pipe_server? NULL : getenv ("GPG_AGENT_INFO"); if (!infostr || !*infostr) @@ -192,7 +199,7 @@ /* First check whether we can connect at the standard socket. */ sockname = make_filename (homedir, "S.gpg-agent", NULL); - rc = assuan_socket_connect (&ctx, sockname, 0); + rc = assuan_socket_connect (ctx, sockname, 0); if (rc) { @@ -210,6 +217,7 @@ log_error ("error flushing pending output: %s\n", strerror (errno)); xfree (sockname); + assuan_release (ctx); return tmperr; } @@ -239,7 +247,7 @@ /* Give the agent some time to prepare itself. */ gnupg_sleep (3); /* Now try again to connect the agent. */ - rc = assuan_socket_connect (&ctx, sockname, 0); + rc = assuan_socket_connect (ctx, sockname, 0); } } #else /*!HAVE_W32_SYSTEM*/ @@ -265,7 +273,7 @@ no_close_list[i] = -1; /* Connect to the agent and perform initial handshaking. */ - rc = assuan_pipe_connect (&ctx, agent_program, argv, + rc = assuan_pipe_connect (ctx, agent_program, argv, no_close_list); } #endif /*!HAVE_W32_SYSTEM*/ @@ -299,7 +307,7 @@ goto restart; } - rc = assuan_socket_connect (&ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid); xfree (infostr); if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED) { @@ -312,6 +320,7 @@ if (rc) { log_error ("can't connect to the agent: %s\n", gpg_strerror (rc)); + assuan_release (ctx); return gpg_error (GPG_ERR_NO_AGENT); } @@ -326,7 +335,7 @@ session_env); if (rc) { - assuan_disconnect (ctx); + assuan_release (ctx); return rc; } Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/configure.ac 2009-09-23 00:01:25 UTC (rev 5161) @@ -42,8 +42,8 @@ NEED_LIBGCRYPT_API=1 NEED_LIBGCRYPT_VERSION=1.4.0 -NEED_LIBASSUAN_API=1 -NEED_LIBASSUAN_VERSION=1.0.4 +NEED_LIBASSUAN_API=2 +NEED_LIBASSUAN_VERSION=1.1.0 NEED_KSBA_API=1 NEED_KSBA_VERSION=1.0.2 Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/g10/call-agent.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -29,9 +29,9 @@ #ifdef HAVE_LOCALE_H #include #endif -#include #include "gpg.h" +#include #include "util.h" #include "membuf.h" #include "options.h" @@ -77,7 +77,7 @@ }; -static int learn_status_cb (void *opaque, const char *line); +static gpg_error_t learn_status_cb (void *opaque, const char *line); @@ -230,7 +230,7 @@ /* This is a dummy data line callback. */ -static int +static gpg_error_t dummy_data_cb (void *opaque, const void *buffer, size_t length) { (void)opaque; @@ -240,7 +240,7 @@ } /* A simple callback used to return the serialnumber of a card. */ -static int +static gpg_error_t get_serialno_cb (void *opaque, const char *line) { char **serialno = opaque; @@ -274,7 +274,7 @@ /* This is the default inquiry callback. It mainly handles the Pinentry notifications. */ -static int +static gpg_error_t default_inq_cb (void *opaque, const char *line) { (void)opaque; @@ -312,7 +312,7 @@ info->fpr1valid = info->fpr2valid = info->fpr3valid = 0; } -static int +static gpg_error_t learn_status_cb (void *opaque, const char *line) { struct agent_card_info_s *parm = opaque; @@ -597,7 +597,7 @@ /* Handle a CERTDATA inquiry. Note, we only send the data, assuan_transact takes care of flushing and writing the END command. */ -static int +static gpg_error_t inq_writecert_parms (void *opaque, const char *line) { int rc; @@ -645,7 +645,7 @@ /* Handle a KEYDATA inquiry. Note, we only send the data, assuan_transact takes care of flushing and writing the end */ -static int +static gpg_error_t inq_writekey_parms (void *opaque, const char *line) { int rc; @@ -695,7 +695,7 @@ /* Status callback for the SCD GENKEY command. */ -static int +static gpg_error_t scd_genkey_cb (void *opaque, const char *line) { struct agent_card_genkey_s *parm = opaque; @@ -882,7 +882,7 @@ -static int +static gpg_error_t membuf_data_cb (void *opaque, const void *buffer, size_t length) { membuf_t *data = opaque; Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/g10/gpg.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -30,13 +30,13 @@ #include /* for stat() */ #endif #include -#include #ifdef HAVE_W32_SYSTEM #include #endif #define INCLUDED_BY_MAIN_MODULE 1 #include "gpg.h" +#include #include "packet.h" #include "../common/iobuf.h" #include "util.h" @@ -1905,6 +1905,7 @@ int fpr_maybe_cmd = 0; /* --fingerprint maybe a command. */ int any_explicit_recipient = 0; int require_secmem=0,got_secmem=0; + struct assuan_malloc_hooks malloc_hooks; #ifdef __riscos__ opt.lock_once = 1; @@ -2054,8 +2055,11 @@ /* Okay, we are now working under our real uid */ /* malloc hooks go here ... */ - assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free); - assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); + malloc_hooks.malloc = gcry_malloc; + malloc_hooks.realloc = gcry_realloc; + malloc_hooks.free = gcry_free; + assuan_set_malloc_hooks (&malloc_hooks); + assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); /* Try for a version specific config file first */ Modified: trunk/g10/server.c =================================================================== --- trunk/g10/server.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/g10/server.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -26,9 +26,9 @@ #include #include -#include #include "gpg.h" +#include #include "util.h" #include "i18n.h" #include "options.h" @@ -64,7 +64,7 @@ /* Called by libassuan for Assuan options. See the Assuan manual for details. */ -static int +static gpg_error_t option_handler (assuan_context_t ctx, const char *key, const char *value) { /* ctrl_t ctrl = assuan_get_pointer (ctx); */ @@ -168,7 +168,7 @@ encrypt at all if not all recipients are valid, the client has to take care of this. All RECIPIENT commands are cumulative until a RESET or an successful ENCRYPT command. */ -static int +static gpg_error_t cmd_recipient (assuan_context_t ctx, char *line) { (void)ctx; @@ -193,7 +193,7 @@ Note that this command returns an INV_RECP status which is a bit strange, but they are very similar. */ -static int +static gpg_error_t cmd_signer (assuan_context_t ctx, char *line) { (void)ctx; @@ -216,7 +216,7 @@ This command should in general not fail, as all necessary checks have been done while setting the recipients. The input and output pipes are closed. */ -static int +static gpg_error_t cmd_encrypt (assuan_context_t ctx, char *line) { (void)ctx; @@ -230,7 +230,7 @@ This performs the decrypt operation after doing some checks on the internal state (e.g. that only needed data has been set). */ -static int +static gpg_error_t cmd_decrypt (assuan_context_t ctx, char *line) { (void)ctx; @@ -249,7 +249,7 @@ If the signature is a detached one, the server will inquire about the signed material and the client must provide it. */ -static int +static gpg_error_t cmd_verify (assuan_context_t ctx, char *line) { int rc; @@ -296,7 +296,7 @@ Sign the data set with the INPUT command and write it to the sink set by OUTPUT. With "--detached" specified, a detached signature is created. */ -static int +static gpg_error_t cmd_sign (assuan_context_t ctx, char *line) { (void)ctx; @@ -310,7 +310,7 @@ Import keys as read from the input-fd, return status message for each imported one. The import checks the validity of the key. */ -static int +static gpg_error_t cmd_import (assuan_context_t ctx, char *line) { (void)ctx; @@ -330,7 +330,7 @@ Recall that in general the output format is set with the OUTPUT command. */ -static int +static gpg_error_t cmd_export (assuan_context_t ctx, char *line) { (void)ctx; @@ -344,7 +344,7 @@ Fixme */ -static int +static gpg_error_t cmd_delkeys (assuan_context_t ctx, char *line) { (void)ctx; @@ -358,7 +358,7 @@ Set the file descriptor to read a message which is used with detached signatures. */ -static int +static gpg_error_t cmd_message (assuan_context_t ctx, char *line) { int rc; @@ -381,7 +381,7 @@ fixme */ -static int +static gpg_error_t do_listkeys (assuan_context_t ctx, char *line, int mode) { (void)ctx; @@ -392,14 +392,14 @@ } -static int +static gpg_error_t cmd_listkeys (assuan_context_t ctx, char *line) { return do_listkeys (ctx, line, 3); } -static int +static gpg_error_t cmd_listsecretkeys (assuan_context_t ctx, char *line) { return do_listkeys (ctx, line, 2); @@ -412,7 +412,7 @@ Read the parameters in native format from the input fd and create a new OpenPGP key. */ -static int +static gpg_error_t cmd_genkey (assuan_context_t ctx, char *line) { (void)ctx; @@ -430,7 +430,7 @@ pid - Return the process id of the server. */ -static int +static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { int rc; @@ -461,7 +461,7 @@ static struct { const char *name; - int (*handler)(assuan_context_t, char *line); + gpg_error_t (*handler)(assuan_context_t, char *line); } table[] = { { "RECIPIENT", cmd_recipient }, { "SIGNER", cmd_signer }, @@ -502,7 +502,7 @@ { int rc; int filedes[2]; - assuan_context_t ctx; + assuan_context_t ctx = NULL; static const char hello[] = ("GNU Privacy Guard's OpenPGP server " VERSION " ready"); @@ -511,9 +511,17 @@ called with a socketpair and ignore FILEDES in this case. */ filedes[0] = 0; filedes[1] = 1; - rc = assuan_init_pipe_server (&ctx, filedes); + rc = assuan_new (&ctx); if (rc) { + log_error ("failed to allocate the assuan context: %s\n", + gpg_strerror (rc)); + goto leave; + } + + rc = assuan_init_pipe_server (ctx, filedes); + if (rc) + { log_error ("failed to initialize the server: %s\n", gpg_strerror (rc)); goto leave; } @@ -590,7 +598,7 @@ leave: xfree (ctrl->server_local); ctrl->server_local = NULL; - assuan_deinit_server (ctx); + assuan_release (ctx); return rc; } Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/scd/command.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -30,9 +30,8 @@ # include #endif +#include "scdaemon.h" #include - -#include "scdaemon.h" #include #include "app-common.h" #include "apdu.h" /* Required for apdu_*_reader (). */ @@ -348,7 +347,7 @@ } -static int +static gpg_error_t option_handler (assuan_context_t ctx, const char *key, const char *value) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -401,7 +400,7 @@ /* If the card has not yet been opened, do it. Note that this function returns an Assuan error, so don't map the error a second time. */ -static assuan_error_t +static gpg_error_t open_card (ctrl_t ctrl, const char *apptype) { gpg_error_t err; @@ -483,7 +482,7 @@ changes between operations; i.e. the client can assume that all operations are done on the same card unless he calls this function. */ -static int +static gpg_error_t cmd_serialno (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -590,7 +589,7 @@ Note, that this function may even be used on a locked card. */ -static int +static gpg_error_t cmd_learn (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -662,7 +661,7 @@ Note, that this function may even be used on a locked card. */ -static int +static gpg_error_t cmd_readcert (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -699,7 +698,7 @@ Note, that this function may even be used on a locked card. */ -static int +static gpg_error_t cmd_readkey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -780,7 +779,7 @@ The client should use this command to tell us the data he want to sign. */ -static int +static gpg_error_t cmd_setdata (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -878,7 +877,7 @@ The --hash option is optional; the default is SHA1. */ -static int +static gpg_error_t cmd_pksign (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -948,7 +947,7 @@ /* PKAUTH */ -static int +static gpg_error_t cmd_pkauth (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -998,7 +997,7 @@ /* PKDECRYPT */ -static int +static gpg_error_t cmd_pkdecrypt (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1052,7 +1051,7 @@ Note, that this function may even be used on a locked card. */ -static int +static gpg_error_t cmd_getattr (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1091,7 +1090,7 @@ A PIN will be requested for most NAMEs. See the corresponding setattr function of the actually used application (app-*.c) for details. */ -static int +static gpg_error_t cmd_setattr (assuan_context_t ctx, char *orig_line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1142,7 +1141,7 @@ In almost all cases a a PIN will be requested. See the related writecert function of the actually used application (app-*.c) for details. */ -static int +static gpg_error_t cmd_writecert (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1207,7 +1206,7 @@ A PIN will be requested for most NAMEs. See the corresponding writekey function of the actually used application (app-*.c) for details. */ -static int +static gpg_error_t cmd_writekey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1283,7 +1282,7 @@ READKEY command. */ -static int +static gpg_error_t cmd_genkey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1342,7 +1341,7 @@ Note, that this function may be even be used on a locked card. */ -static int +static gpg_error_t cmd_random (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1384,7 +1383,7 @@ the card holder verfication vector CHVNO. The option --nullpin is used for TCOS cards to set the initial PIN. The format of CHVNO depends on the card application. */ -static int +static gpg_error_t cmd_passwd (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1461,7 +1460,7 @@ unblock each other. */ -static int +static gpg_error_t cmd_checkpin (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1504,7 +1503,7 @@ If the option --wait is given the command will wait until a lock has been released. */ -static int +static gpg_error_t cmd_lock (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1542,7 +1541,7 @@ Release exclusive card access. */ -static int +static gpg_error_t cmd_unlock (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1594,7 +1593,7 @@ first field is the name. */ -static int +static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { int rc = 0; @@ -1685,7 +1684,7 @@ command; i.e. to select another application. */ -static int +static gpg_error_t cmd_restart (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1711,7 +1710,7 @@ Disconnect the card if it is not any longer used by other connections and the backend supports a disconnect operation. */ -static int +static gpg_error_t cmd_disconnect (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1743,7 +1742,7 @@ length up to N bytes. If N is not given a default value is used (currently 4096). */ -static int +static gpg_error_t cmd_apdu (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1824,7 +1823,7 @@ /* KILLSCD - Commit suicide. */ -static int +static gpg_error_t cmd_killscd (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1843,7 +1842,7 @@ { static struct { const char *name; - int (*handler)(assuan_context_t, char *line); + gpg_error_t (*handler)(assuan_context_t, char *line); } table[] = { { "SERIALNO", cmd_serialno }, { "LEARN", cmd_learn }, @@ -1895,20 +1894,28 @@ scd_command_handler (ctrl_t ctrl, int fd) { int rc; - assuan_context_t ctx; + assuan_context_t ctx = NULL; int stopme; + rc = assuan_new (&ctx); + if (rc) + { + log_error ("failed to allocate assuan context: %s\n", + gpg_strerror (rc)); + scd_exit (2); + } + if (fd == -1) { int filedes[2]; filedes[0] = 0; filedes[1] = 1; - rc = assuan_init_pipe_server (&ctx, filedes); + rc = assuan_init_pipe_server (ctx, filedes); } else { - rc = assuan_init_socket_server_ext (&ctx, INT2FD(fd), 2); + rc = assuan_init_socket_server_ext (ctx, INT2FD(fd), 2); } if (rc) { @@ -1987,7 +1994,7 @@ ctrl->server_local = NULL; /* Release the Assuan context. */ - assuan_deinit_server (ctx); + assuan_release (ctx); if (stopme) scd_exit (0); Modified: trunk/scd/scdaemon.c =================================================================== --- trunk/scd/scdaemon.c 2009-09-21 18:26:52 UTC (rev 5160) +++ trunk/scd/scdaemon.c 2009-09-23 00:01:25 UTC (rev 5161) @@ -370,7 +370,8 @@ const char *config_filename = NULL; int allow_coredump = 0; int standard_socket = 0; - + struct assuan_malloc_hooks malloc_hooks; + set_strusage (my_strusage); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); /* Please note that we may running SUID(ROOT), so be very CAREFUL @@ -403,10 +404,12 @@ ksba_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free); - assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free); - assuan_set_assuan_log_stream (log_get_stream ()); + malloc_hooks.malloc = gcry_malloc; + malloc_hooks.realloc = gcry_realloc; + malloc_hooks.free = gcry_free; + assuan_set_malloc_hooks (&malloc_hooks); assuan_set_assuan_log_prefix (log_get_prefix (NULL)); - assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); + assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); setup_libgcrypt_logging (); gcry_control (GCRYCTL_USE_SECURE_RNDPOOL); Modified: trunk/sm/call-dirmngr.c =================================================================== From cvs at cvs.gnupg.org Wed Sep 23 12:28:41 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 23 Sep 2009 12:28:41 +0200 Subject: [svn] GnuPG - r5162 - in trunk: . agent g10 g13 jnlib sm Message-ID: Author: wk Date: 2009-09-23 12:28:41 +0200 (Wed, 23 Sep 2009) New Revision: 5162 Added: trunk/g13/ trunk/g13/ChangeLog trunk/g13/Makefile.am trunk/g13/create.h trunk/g13/g13.c trunk/g13/g13.h Modified: trunk/ChangeLog trunk/Makefile.am trunk/agent/ChangeLog trunk/agent/command.c trunk/configure.ac trunk/g10/gpgv.c trunk/g10/keydb.c trunk/g10/keyring.c trunk/g10/tdbio.c trunk/jnlib/ChangeLog trunk/jnlib/dotlock.c trunk/jnlib/dotlock.h trunk/sm/keydb.c Log: s/DOTLOCK/dotlock_t/. Add some stuff for g13. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/ChangeLog 2009-09-23 10:28:41 UTC (rev 5162) @@ -1,3 +1,8 @@ +2009-09-23 Werner Koch + + * configure.ac (HAVE_ASSUAN_SET_IO_MONITOR): Remove test. + (_ASSUAN_ONLY_GPG_ERRORS): Remove. + 2009-09-23 Marcus Brinkmann * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/agent/ChangeLog 2009-09-23 10:28:41 UTC (rev 5162) @@ -1,3 +1,9 @@ +2009-09-23 Werner Koch + + * command.c (register_commands) [HAVE_ASSUAN_SET_IO_MONITOR]: + Remove cpp condition. + (start_command_handler) [HAVE_ASSUAN_SET_IO_MONITOR]: Ditto. + 2009-09-23 Marcus Brinkmann * gpg-agent.c (parse_rereadable_options): Don't set global assuan Modified: trunk/jnlib/ChangeLog =================================================================== --- trunk/jnlib/ChangeLog 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/jnlib/ChangeLog 2009-09-23 10:28:41 UTC (rev 5162) @@ -1,3 +1,7 @@ +2009-09-22 Werner Koch + + * dotlock.h (DOTLOCK): Rename to dotlock_t. Change all users. + 2009-08-26 Werner Koch * stringhelp.c (do_make_filename): Factor some code out to .. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/Makefile.am 2009-09-23 10:28:41 UTC (rev 5162) @@ -54,6 +54,11 @@ else scd = endif +if BUILD_G13 +g13 = g13 +else +g13 = +endif if BUILD_TOOLS tools = tools else @@ -72,7 +77,7 @@ endif SUBDIRS = m4 gl include jnlib common ${kbx} \ - ${gpg} ${keyserver} ${sm} ${agent} ${scd} ${tools} po ${doc} ${tests} + ${gpg} ${keyserver} ${sm} ${agent} ${scd} ${g13} ${tools} po ${doc} ${tests} dist_doc_DATA = README Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/agent/command.c 2009-09-23 10:28:41 UTC (rev 5162) @@ -1866,9 +1866,7 @@ if (rc) return rc; } -#ifdef HAVE_ASSUAN_SET_IO_MONITOR assuan_register_post_cmd_notify (ctx, post_cmd_notify); -#endif assuan_register_reset_notify (ctx, reset_notify); assuan_register_option_handler (ctx, option_handler); return 0; @@ -1934,9 +1932,7 @@ if (DBG_ASSUAN) assuan_set_log_stream (ctx, log_get_stream ()); -#ifdef HAVE_ASSUAN_SET_IO_MONITOR assuan_set_io_monitor (ctx, io_monitor, NULL); -#endif for (;;) { Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/configure.ac 2009-09-23 10:28:41 UTC (rev 5162) @@ -80,6 +80,7 @@ GNUPG_BUILD_PROGRAM(gpgsm, yes) GNUPG_BUILD_PROGRAM(agent, yes) GNUPG_BUILD_PROGRAM(scdaemon, yes) +GNUPG_BUILD_PROGRAM(g13, yes) GNUPG_BUILD_PROGRAM(tools, yes) GNUPG_BUILD_PROGRAM(doc, yes) GNUPG_BUILD_PROGRAM(symcryptrun, no) @@ -417,9 +418,6 @@ /* We always include support for the OpenPGP card. */ #define ENABLE_CARD_SUPPORT 1 -/* We don't want the old assuan codes anymore. */ -#define _ASSUAN_ONLY_GPG_ERRORS 1 - /* We explicitly need to disable PTH's soft mapping as Debian currently enables it by default for no reason. */ #define PTH_SYSCALL_SOFT 0 @@ -616,11 +614,8 @@ have_libassuan=no AM_PATH_LIBASSUAN_PTH("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION", have_libassuan=yes,have_libassuan=no) - AM_CHECK_LIBASSUAN("$NEED_LIBASSUAN_API:1.0.1", - [AC_DEFINE(HAVE_ASSUAN_SET_IO_MONITOR, 1, - [Define to 1 if you have the `assuan_set_io_monitor' function.])],) AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version", - [version of the libbassuan library]) + [version of the libassuan library]) fi @@ -1351,6 +1346,7 @@ AM_CONDITIONAL(BUILD_GPGSM, test "$build_gpgsm" = "yes") AM_CONDITIONAL(BUILD_AGENT, test "$build_agent" = "yes") AM_CONDITIONAL(BUILD_SCDAEMON, test "$build_scdaemon" = "yes") +AM_CONDITIONAL(BUILD_G13, test "$build_g13" = "yes") AM_CONDITIONAL(BUILD_TOOLS, test "$build_tools" = "yes") AM_CONDITIONAL(BUILD_DOC, test "$build_doc" = "yes") AM_CONDITIONAL(BUILD_SYMCRYPTRUN, test "$build_symcryptrun" = "yes") @@ -1441,6 +1437,7 @@ sm/Makefile agent/Makefile scd/Makefile +g13/Makefile keyserver/Makefile keyserver/gpg2keys_mailto keyserver/gpg2keys_test @@ -1463,7 +1460,9 @@ S/MIME: $build_gpgsm Agent: $build_agent $build_agent_threaded Smartcard: $build_scdaemon $build_scdaemon_extra + G13: $build_g13 + Protect tool: $show_gnupg_protect_tool_pgm Default agent: $show_gnupg_agent_pgm Default pinentry: $show_gnupg_pinentry_pgm Modified: trunk/g10/gpgv.c =================================================================== --- trunk/g10/gpgv.c 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/g10/gpgv.c 2009-09-23 10:28:41 UTC (rev 5162) @@ -500,7 +500,7 @@ { } -DOTLOCK +dotlock_t create_dotlock (const char *file_to_lock) { (void)file_to_lock; @@ -508,13 +508,13 @@ } void -destroy_dotlock (DOTLOCK h) +destroy_dotlock (dotlock_t h) { (void)h; } int -make_dotlock (DOTLOCK h, long timeout) +make_dotlock (dotlock_t h, long timeout) { (void)h; (void)timeout; @@ -522,7 +522,7 @@ } int -release_dotlock (DOTLOCK h) +release_dotlock (dotlock_t h) { (void)h; return 0; Modified: trunk/g10/keydb.c =================================================================== --- trunk/g10/keydb.c 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/g10/keydb.c 2009-09-23 10:28:41 UTC (rev 5162) @@ -78,7 +78,7 @@ static int maybe_create_keyring (char *filename, int force) { - DOTLOCK lockhd = NULL; + dotlock_t lockhd = NULL; IOBUF iobuf; int rc; mode_t oldmask; Modified: trunk/g10/keyring.c =================================================================== --- trunk/g10/keyring.c 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/g10/keyring.c 2009-09-23 10:28:41 UTC (rev 5162) @@ -55,7 +55,7 @@ struct keyring_name *next; int secret; int readonly; - DOTLOCK lockhd; + dotlock_t lockhd; int is_locked; int did_full_scan; char fname[1]; Modified: trunk/g10/tdbio.c =================================================================== --- trunk/g10/tdbio.c 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/g10/tdbio.c 2009-09-23 10:28:41 UTC (rev 5162) @@ -86,7 +86,7 @@ static char *db_name; -static DOTLOCK lockhandle; +static dotlock_t lockhandle; static int is_locked; static int db_fd = -1; static int in_transaction; Added: trunk/g13/ChangeLog =================================================================== Added: trunk/g13/Makefile.am =================================================================== --- trunk/g13/Makefile.am (rev 0) +++ trunk/g13/Makefile.am 2009-09-23 10:28:41 UTC (rev 5162) @@ -0,0 +1,35 @@ +# g13/Makefile.am +# Copyright (C) 2009 Free Software Foundation, Inc. +# +# This file is part of GnuPG. +# +# GnuPG is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GnuPG is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . + +## Process this file with automake to produce Makefile.in + +bin_PROGRAMS = g13 + +AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common + +include $(top_srcdir)/am/cmacros.am + +AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) + +g13_SOURCES = \ + g13.c g13.h + +g13_LDADD = $(libcommon) ../jnlib/libjnlib.a ../gl/libgnu.a \ + $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ + $(LIBINTL) + Added: trunk/g13/create.h =================================================================== --- trunk/g13/create.h (rev 0) +++ trunk/g13/create.h 2009-09-23 10:28:41 UTC (rev 5162) @@ -0,0 +1,26 @@ +/* create.h - Defs to create a new crypto container + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GnuPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef G13_CREATE_H +#define G13_CREATE_H + +gpg_error_t create_new_container (ctrl_t ctrl, const char *filename); + + +#endif /*G13_CREATE_H*/ Added: trunk/g13/g13.c =================================================================== --- trunk/g13/g13.c (rev 0) +++ trunk/g13/g13.c 2009-09-23 10:28:41 UTC (rev 5162) @@ -0,0 +1,692 @@ +/* g13.c - Disk Key management with GnuPG + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GnuPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "g13.h" + +#include + +#include "i18n.h" +#include "sysutils.h" +#include "gc-opt-flags.h" + + +enum cmd_and_opt_values { + aNull = 0, + oQuiet = 'q', + oVerbose = 'v', + + aGPGConfList = 500, + aGPGConfTest, + aCreate, + aMount, + aUmount, + + oOptions, + oDebug, + oDebugLevel, + oDebugAll, + oDebugNone, + oDebugWait, + oDebugAllowCoreDump, + oLogFile, + oNoLogFile, + oAuditLog, + + oOutput, + + oAgentProgram, + oDisplay, + oTTYname, + oTTYtype, + oLCctype, + oLCmessages, + oXauthority, + + oStatusFD, + oLoggerFD, + + oNoVerbose, + oNoSecmemWarn, + oNoGreeting, + oNoTTY, + oNoOptions, + oHomedir, + oWithColons, + oDryRun, + + oRecipient, + + oNoRandomSeedFile, + oFakedSystemTime + }; + + +static ARGPARSE_OPTS opts[] = { + + ARGPARSE_group (300, N_("@Commands:\n ")), + + ARGPARSE_c (aCreate, "create", N_("Create a new file system container")), + ARGPARSE_c (aMount, "mount", N_("Mount a file system container") ), + ARGPARSE_c (aUmount, "umount", N_("Unmount a file system container") ), + + ARGPARSE_c (aGPGConfList, "gpgconf-list", "@"), + ARGPARSE_c (aGPGConfTest, "gpgconf-test", "@"), + + ARGPARSE_group (301, N_("@\nOptions:\n ")), + + ARGPARSE_s_s (oRecipient, "recipient", N_("|USER-ID|encrypt for USER-ID")), + + ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")), + ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")), + ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")), + ARGPARSE_s_n (oNoTTY, "no-tty", N_("don't use the terminal at all")), + ARGPARSE_s_s (oLogFile, "log-file", N_("|FILE|write log output to FILE")), + ARGPARSE_s_n (oNoLogFile, "no-log-file", "@"), + ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"), + + ARGPARSE_s_s (oAuditLog, "audit-log", + N_("|FILE|write an audit log to FILE")), + ARGPARSE_s_n (oDryRun, "dry-run", N_("do not make any changes")), + + ARGPARSE_s_s (oOptions, "options", N_("|FILE|read options from FILE")), + + ARGPARSE_p_u (oDebug, "debug", "@"), + ARGPARSE_s_s (oDebugLevel, "debug-level", + N_("|LEVEL|set the debugging level to LEVEL")), + ARGPARSE_s_n (oDebugAll, "debug-all", "@"), + ARGPARSE_s_n (oDebugNone, "debug-none", "@"), + ARGPARSE_s_i (oDebugWait, "debug-wait", "@"), + ARGPARSE_s_n (oDebugAllowCoreDump, "debug-allow-core-dump", "@"), + + ARGPARSE_s_i (oStatusFD, "status-fd", + N_("|FD|write status info to this FD")), + + ARGPARSE_group (302, N_( + "@\n(See the man page for a complete listing of all commands and options)\n" + )), + + ARGPARSE_group (303, N_("@\nExamples:\n\n" + " blurb\n" + " blurb\n")), + + /* Hidden options. */ + ARGPARSE_s_n (oNoVerbose, "no-verbose", "@"), + ARGPARSE_s_n (oNoSecmemWarn, "no-secmem-warning", "@"), + ARGPARSE_s_n (oNoGreeting, "no-greeting", "@"), + ARGPARSE_s_n (oNoOptions, "no-options", "@"), + ARGPARSE_s_s (oHomedir, "homedir", "@"), + ARGPARSE_s_s (oAgentProgram, "agent-program", "@"), + ARGPARSE_s_s (oDisplay, "display", "@"), + ARGPARSE_s_s (oTTYname, "ttyname", "@"), + ARGPARSE_s_s (oTTYtype, "ttytype", "@"), + ARGPARSE_s_s (oLCctype, "lc-ctype", "@"), + ARGPARSE_s_s (oLCmessages, "lc-messages", "@"), + ARGPARSE_s_s (oXauthority, "xauthority", "@"), + ARGPARSE_s_s (oFakedSystemTime, "faked-system-time", "@"), + ARGPARSE_s_n (oWithColons, "with-colons", "@"), + ARGPARSE_s_n (oNoRandomSeedFile, "no-random-seed-file", "@"), + + /* Command aliases. */ + + ARGPARSE_end () +}; + + +/* Global variable to keep an error count. */ +int g13_errors_seen = 0; + +/* It is possible that we are currently running under setuid permissions. */ +static int maybe_setuid = 1; + +/* Helper to implement --debug-level and --debug. */ +static const char *debug_level; +static unsigned int debug_value; + +static void set_cmd (enum cmd_and_opt_values *ret_cmd, + enum cmd_and_opt_values new_cmd ); + +static void emergency_cleanup (void); + + +static const char * +my_strusage( int level ) +{ + const char *p; + + switch (level) + { + case 11: p = "g13 (GnuPG)"; + break; + case 13: p = VERSION; break; + case 17: p = PRINTABLE_OS_NAME; break; + case 19: p = _("Please report bugs to <" PACKAGE_BUGREPORT ">.\n"); + break; + case 1: + case 40: p = _("Usage: g13 [options] [files] (-h for help)"); + break; + case 41: + p = _("Syntax: g13 [options] [files]\n" + "Create, mount or unmount an encrypted file system container\n"); + break; + + case 31: p = "\nHome: "; break; + case 32: p = opt.homedir; break; + + default: p = NULL; break; + } + return p; +} + + +static void +wrong_args (const char *text) +{ + fputs (_("usage: g13 [options] "), stderr); + fputs (text, stderr); + putc ('\n', stderr); + g13_exit (2); +} + + +/* Setup the debugging. With a DEBUG_LEVEL of NULL only the active + debug flags are propagated to the subsystems. With DEBUG_LEVEL + set, a specific set of debug flags is set; and individual debugging + flags will be added on top. */ +static void +set_debug (void) +{ + if (!debug_level) + ; + else if (!strcmp (debug_level, "none")) + opt.debug = 0; + else if (!strcmp (debug_level, "basic")) + opt.debug = DBG_ASSUAN_VALUE|DBG_MOUNT_VALUE; + else if (!strcmp (debug_level, "advanced")) + opt.debug = DBG_ASSUAN_VALUE|DBG_MOUNT_VALUE; + else if (!strcmp (debug_level, "expert")) + opt.debug = (DBG_ASSUAN_VALUE|DBG_MOUNT_VALUE|DBG_CRYPTO_VALUE); + else if (!strcmp (debug_level, "guru")) + opt.debug = ~0; + else + { + log_error (_("invalid debug-level `%s' given\n"), debug_level); + g13_exit(2); + } + + opt.debug |= debug_value; + + if (opt.debug && !opt.verbose) + opt.verbose = 1; + if (opt.debug) + opt.quiet = 0; + + if (opt.debug & DBG_CRYPTO_VALUE ) + gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1); + gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose); +} + + + +static void +set_cmd (enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd) +{ + enum cmd_and_opt_values cmd = *ret_cmd; + + if (!cmd || cmd == new_cmd) + cmd = new_cmd; + else + { + log_error (_("conflicting commands\n")); + g13_exit (2); + } + + *ret_cmd = cmd; +} + + +/* Helper to add recipients to a list. */ +static int +add_encryption_key (ctrl_t ctrl, const char *name, + void /*FIXME*/ *keylist, int is_cms) +{ + /* FIXME: Decide whether to add a CMS or OpenPGP key and then add + the key to a list. */ + /* int rc = foo_add_to_certlist (ctrl, name, 0, recplist, is_encrypt_to); */ + /* if (rc) */ + /* { */ + /* if (recp_required) */ + /* { */ + /* log_error ("can't encrypt to `%s': %s\n", name, gpg_strerror (rc)); */ + /* gpgsm_status2 (ctrl, STATUS_INV_RECP, */ + /* get_inv_recpsgnr_code (rc), name, NULL); */ + /* } */ + /* else */ + /* log_info (_("NOTE: won't be able to encrypt to `%s': %s\n"), */ + /* name, gpg_strerror (rc)); */ + /* } */ + return 0; /* Key is good. */ +} + + +int +main ( int argc, char **argv) +{ + ARGPARSE_ARGS pargs; + int orig_argc; + char **orig_argv; + const char *fname; + int may_coredump; + FILE *configfp = NULL; + char *configname = NULL; + unsigned configlineno; + int parse_debug = 0; + int no_more_options = 0; + int default_config =1; + char *logfile = NULL; + char *auditlog = NULL; + int greeting = 0; + int nogreeting = 0; + int debug_wait = 0; + int use_random_seed = 1; + int nokeysetup = 0; + enum cmd_and_opt_values cmd = 0; + struct server_control_s ctrl; + estream_t auditfp = NULL; + strlist_t recipients = NULL; + + /*mtrace();*/ + + gnupg_reopen_std ("g13"); + set_strusage (my_strusage); + gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); + gcry_control (GCRYCTL_DISABLE_INTERNAL_LOCKING); + + log_set_prefix ("g13", 1); + + /* Make sure that our subsystems are ready. */ + i18n_init(); + init_common_subsystems (); + + /* Check that the Libgcrypt is suitable. */ + if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) ) + log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt", + NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) ); + + /* Take extra care of the random pool. */ + gcry_control (GCRYCTL_USE_SECURE_RNDPOOL); + + may_coredump = disable_core_dumps (); + + gnupg_init_signals (0, emergency_cleanup); + + create_dotlock (NULL); /* Register locking cleanup. */ + + opt.homedir = default_homedir (); + + /* First check whether we have a config file on the commandline. */ + orig_argc = argc; + orig_argv = argv; + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags= 1|(1<<6); /* Do not remove the args, ignore version. */ + while (arg_parse( &pargs, opts)) + { + if (pargs.r_opt == oDebug || pargs.r_opt == oDebugAll) + parse_debug++; + else if (pargs.r_opt == oOptions) + { /* Yes, there is one, so we do not try the default one but + read the config file when it is encountered at the + commandline. */ + default_config = 0; + } + else if (pargs.r_opt == oNoOptions) + default_config = 0; /* --no-options */ + else if (pargs.r_opt == oHomedir) + opt.homedir = pargs.r.ret_str; + } + + /* Initialize the secure memory. */ + gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); + maybe_setuid = 0; + + /* + Now we are now working under our real uid + */ + + + /* Setup a default control structure for command line mode. */ + memset (&ctrl, 0, sizeof ctrl); + g13_init_default_ctrl (&ctrl); + + /* Set the default option file */ + if (default_config ) + configname = make_filename (opt.homedir, "g13.conf", NULL); + + argc = orig_argc; + argv = orig_argv; + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags = 1; /* Do not remove the args. */ + + next_pass: + if (configname) { + configlineno = 0; + configfp = fopen (configname, "r"); + if (!configfp) + { + if (default_config) + { + if (parse_debug) + log_info (_("NOTE: no default option file `%s'\n"), configname); + } + else + { + log_error (_("option file `%s': %s\n"), configname, strerror(errno)); + g13_exit(2); + } + xfree (configname); + configname = NULL; + } + if (parse_debug && configname) + log_info (_("reading options from `%s'\n"), configname); + default_config = 0; + } + + while (!no_more_options + && optfile_parse (configfp, configname, &configlineno, &pargs, opts)) + { + switch (pargs.r_opt) + { + case aGPGConfList: + case aGPGConfTest: + set_cmd (&cmd, pargs.r_opt); + nogreeting = 1; + nokeysetup = 1; + break; + + case aMount: + case aUmount: + nokeysetup = 1; + case aCreate: + set_cmd (&cmd, pargs.r_opt); + break; + + case oOutput: opt.outfile = pargs.r.ret_str; break; + + case oQuiet: opt.quiet = 1; break; + case oNoGreeting: nogreeting = 1; break; + case oNoTTY: break; + + case oDryRun: opt.dry_run = 1; break; + + case oVerbose: + opt.verbose++; + gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose); + break; + case oNoVerbose: + opt.verbose = 0; + gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose); + break; + + case oLogFile: logfile = pargs.r.ret_str; break; + case oNoLogFile: logfile = NULL; break; + + case oAuditLog: auditlog = pargs.r.ret_str; break; + + case oDebug: debug_value |= pargs.r.ret_ulong; break; + case oDebugAll: debug_value = ~0; break; + case oDebugNone: debug_value = 0; break; + case oDebugLevel: debug_level = pargs.r.ret_str; break; + case oDebugWait: debug_wait = pargs.r.ret_int; break; + case oDebugAllowCoreDump: + may_coredump = enable_core_dumps (); + break; + + case oStatusFD: ctrl.status_fd = pargs.r.ret_int; break; + case oLoggerFD: log_set_fd (pargs.r.ret_int ); break; + + case oNoOptions: break; /* no-options */ + case oOptions: + /* Config files may not be nested (silently ignore them). */ + if (!configfp) + { + xfree(configname); + configname = xstrdup (pargs.r.ret_str); + goto next_pass; + } + break; + + case oHomedir: opt.homedir = pargs.r.ret_str; break; + + case oAgentProgram: opt.agent_program = pargs.r.ret_str; break; + case oDisplay: opt.display = xstrdup (pargs.r.ret_str); break; + case oTTYname: opt.ttyname = xstrdup (pargs.r.ret_str); break; + case oTTYtype: opt.ttytype = xstrdup (pargs.r.ret_str); break; + case oLCctype: opt.lc_ctype = xstrdup (pargs.r.ret_str); break; + case oLCmessages: opt.lc_messages = xstrdup (pargs.r.ret_str); break; + case oXauthority: opt.xauthority = xstrdup (pargs.r.ret_str); break; + + case oFakedSystemTime: + { + time_t faked_time = isotime2epoch (pargs.r.ret_str); + if (faked_time == (time_t)(-1)) + faked_time = (time_t)strtoul (pargs.r.ret_str, NULL, 10); + gnupg_set_time (faked_time, 0); + } + break; + + case oNoSecmemWarn: gcry_control (GCRYCTL_DISABLE_SECMEM_WARN); break; + + case oNoRandomSeedFile: use_random_seed = 0; break; + + case oRecipient: /* Store the encryption key. */ + add_to_strlist (&recipients, pargs.r.ret_str); + break; + + + default: + pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; + break; + } + } + + if (configfp) + { + fclose (configfp); + configfp = NULL; + /* Keep a copy of the config filename. */ + opt.config_filename = configname; + configname = NULL; + goto next_pass; + } + xfree (configname); + configname = NULL; + + if (!opt.config_filename) + opt.config_filename = make_filename (opt.homedir, "g13.conf", NULL); + + if (log_get_errorcount(0)) + g13_exit(2); + + /* Now that we have the options parsed we need to update the default + control structure. */ + g13_init_default_ctrl (&ctrl); + + if (nogreeting) + greeting = 0; + + if (greeting) + { + fprintf(stderr, "%s %s; %s\n", + strusage(11), strusage(13), strusage(14) ); + fprintf(stderr, "%s\n", strusage(15) ); + } + + if (may_coredump && !opt.quiet) + log_info (_("WARNING: program may create a core file!\n")); + + if (logfile) + { + log_set_file (logfile); + log_set_prefix (NULL, 1|2|4); + } + + if (gnupg_faked_time_p ()) + { + gnupg_isotime_t tbuf; + + log_info (_("WARNING: running with faked system time: ")); + gnupg_get_isotime (tbuf); + dump_isotime (tbuf); + log_printf ("\n"); + } + + /* Print any pending secure memory warnings. */ + gcry_control (GCRYCTL_RESUME_SECMEM_WARN); + + /* Setup the debug flags for all subsystems. */ + set_debug (); + + /* Install a regular exit handler to make real sure that the secure + memory gets wiped out. */ + if (atexit (emergency_cleanup)) + { + log_error ("atexit failed\n"); + g13_exit (2); + } + + /* Terminate if we found any error until now. */ + if (log_get_errorcount(0)) + g13_exit (2); + + /* Set the standard GnuPG random seed file. */ + if (use_random_seed) + { + char *p = make_filename (opt.homedir, "random_seed", NULL); + gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p); + xfree(p); + } + + /* Store given filename into FNAME. */ + fname = argc? *argv : NULL; + + /* Parse all given encryption keys. This does a lookup of the keys + and stops if any of the given keys was not found. */ + if (!nokeysetup) + { + strlist_t sl; + int failed = 0; + + for (sl = recipients; sl; sl = sl->next) + if (add_encryption_key (&ctrl, sl->d, NULL /* FIXME*/, 0)) + failed = 1; + if (failed) + g13_exit (1); + } + + /* Dispatch command. */ + switch (cmd) + { + case aGPGConfList: + { /* List options and default values in the GPG Conf format. */ + char *config_filename_esc = percent_escape (opt.config_filename, NULL); + + printf ("gpgconf-g13.conf:%lu:\"%s\n", + GC_OPT_FLAG_DEFAULT, config_filename_esc); + xfree (config_filename_esc); + + printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE); + printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE); + printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT); + printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE); + } + break; + case aGPGConfTest: + /* This is merely a dummy command to test whether the + configuration file is valid. */ + break; + + case aCreate: /* Create a new container. */ + { + if (argc != 1) + wrong_args ("--create filename"); + + } + break; + + default: + log_error (_("invalid command (there is no implicit command)\n")); + break; + } + + /* Print the audit result if needed. */ + if (auditlog && auditfp) + { + audit_print_result (ctrl.audit, auditfp, 0); + audit_release (ctrl.audit); + ctrl.audit = NULL; + es_fclose (auditfp); + } + + /* Cleanup. */ + g13_exit (0); + return 8; /*NOTREACHED*/ +} + +/* Note: This function is used by signal handlers!. */ +static void +emergency_cleanup (void) +{ + gcry_control (GCRYCTL_TERM_SECMEM ); +} + + +void +g13_exit (int rc) +{ + gcry_control (GCRYCTL_UPDATE_RANDOM_SEED_FILE); + if (opt.debug & DBG_MEMSTAT_VALUE) + { + gcry_control( GCRYCTL_DUMP_MEMORY_STATS ); + gcry_control( GCRYCTL_DUMP_RANDOM_STATS ); + } + if (opt.debug) + gcry_control (GCRYCTL_DUMP_SECMEM_STATS ); + emergency_cleanup (); + rc = rc? rc : log_get_errorcount(0)? 2 : g13_errors_seen? 1 : 0; + exit (rc); +} + + +void +g13_init_default_ctrl (struct server_control_s *ctrl) +{ + (void)ctrl; +} + + Added: trunk/g13/g13.h =================================================================== --- trunk/g13/g13.h (rev 0) +++ trunk/g13/g13.h 2009-09-23 10:28:41 UTC (rev 5162) @@ -0,0 +1,96 @@ +/* g13.h - Global definitions for G13. + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GnuPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef G13_H +#define G13_H + +#ifdef GPG_ERR_SOURCE_DEFAULT +#error GPG_ERR_SOURCE_DEFAULT already defined +#endif +#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_G13 +#include + +#include "../common/util.h" +#include "../common/status.h" +#include "../common/estream.h" +#include "../common/audit.h" + +/* A large struct named "opt" to keep global flags. */ +struct +{ + unsigned int debug; /* Debug flags (DBG_foo_VALUE). */ + int verbose; /* Verbosity level. */ + int quiet; /* Be as quiet as possible. */ + int dry_run; /* Don't change any persistent data. */ + + const char *homedir; /* Configuration directory name. */ + const char *config_filename; /* Name of the used config file. */ + const char *agent_program; + char *display; + char *ttyname; + char *ttytype; + char *lc_ctype; + char *lc_messages; + char *xauthority; + char *pinentry_user_data; + + char *outfile; /* Name of the output file. */ +} opt; + + +/* Debug values and macros. */ +#define DBG_MOUNT_VALUE 1 /* Debug mount or device stuff. */ +#define DBG_CRYPTO_VALUE 4 /* Debug low level crypto. */ +#define DBG_MEMORY_VALUE 32 /* Debug memory allocation stuff. */ +#define DBG_MEMSTAT_VALUE 128 /* Show memory statistics. */ +#define DBG_ASSUAN_VALUE 1024 /* Debug assuan communication. */ + +#define DBG_MOUNT (opt.debug & DBG_MOUNT_VALUE) +#define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE) +#define DBG_MEMORY (opt.debug & DBG_MEMORY_VALUE) +#define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE) + +/* Forward declaration for an object defined in server.c. */ +struct server_local_s; + +/* Session control object. This object is passed down to most + functions. The default values for it are set by + g13_init_default_ctrl(). */ +struct server_control_s +{ + int no_server; /* We are not running under server control */ + int status_fd; /* Only for non-server mode */ + struct server_local_s *server_local; + + audit_ctx_t audit; /* NULL or a context for the audit subsystem. */ + int agent_seen; /* Flag indicating that the gpg-agent has been + accessed. */ + + int with_colons; /* Use column delimited output format */ +}; + + + +/*-- g13.c --*/ +void g13_exit (int rc); +void g13_init_default_ctrl (struct server_control_s *ctrl); + + + +#endif /*G13_H*/ Modified: trunk/jnlib/dotlock.c =================================================================== --- trunk/jnlib/dotlock.c 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/jnlib/dotlock.c 2009-09-23 10:28:41 UTC (rev 5162) @@ -76,7 +76,7 @@ /* A list of of all lock handles. */ -static volatile DOTLOCK all_lockfiles; +static volatile dotlock_t all_lockfiles; /* If this has the value true all locking is disabled. */ static int never_lock; @@ -84,7 +84,7 @@ /* Local protototypes. */ #ifndef HAVE_DOSISH_SYSTEM -static int read_lockfile (DOTLOCK h, int *same_node); +static int read_lockfile (dotlock_t h, int *same_node); #endif /*!HAVE_DOSISH_SYSTEM*/ @@ -102,7 +102,7 @@ /* Create a lockfile for a file name FILE_TO_LOCK and returns an - object of type DOTLOCK which may be used later to actually acquire + object of type dotlock_t which may be used later to actually acquire the lock. A cleanup routine gets installed to cleanup left over locks or other files used internally by the lock mechanism. @@ -119,11 +119,11 @@ destroy_dotlock but gets also released at the termination of the process. On error NULL is returned. */ -DOTLOCK +dotlock_t create_dotlock (const char *file_to_lock) { static int initialized; - DOTLOCK h; + dotlock_t h; #ifndef HAVE_DOSISH_SYSTEM int fd = -1; char pidstr[16]; @@ -321,9 +321,9 @@ /* Destroy the local handle H and release the lock. */ void -destroy_dotlock ( DOTLOCK h ) +destroy_dotlock (dotlock_t h) { - DOTLOCK hprev, htmp; + dotlock_t hprev, htmp; if ( !h ) return; @@ -364,9 +364,9 @@ #ifndef HAVE_DOSISH_SYSTEM static int -maybe_deadlock( DOTLOCK h ) +maybe_deadlock (dotlock_t h) { - DOTLOCK r; + dotlock_t r; for ( r=all_lockfiles; r; r = r->next ) { @@ -383,7 +383,7 @@ forever (hopefully not), other values are reserved (should then be timeouts in milliseconds). Returns: 0 on success */ int -make_dotlock ( DOTLOCK h, long timeout ) +make_dotlock (dotlock_t h, long timeout) { int backoff = 0; #ifndef HAVE_DOSISH_SYSTEM @@ -513,7 +513,7 @@ /* Release a lock. Returns 0 on success. */ int -release_dotlock( DOTLOCK h ) +release_dotlock (dotlock_t h) { #ifndef HAVE_DOSISH_SYSTEM int pid, same_node; @@ -585,7 +585,7 @@ has been created on the same node. */ #ifndef HAVE_DOSISH_SYSTEM static int -read_lockfile (DOTLOCK h, int *same_node ) +read_lockfile (dotlock_t h, int *same_node ) { char buffer_space[10+1+70+1]; /* 70 is just an estimated value; node name are usually shorter. */ @@ -680,9 +680,9 @@ installed by this module but may also be called by other termination handlers. */ void -dotlock_remove_lockfiles() +dotlock_remove_lockfiles (void) { - DOTLOCK h, h2; + dotlock_t h, h2; h = all_lockfiles; all_lockfiles = NULL; Modified: trunk/jnlib/dotlock.h =================================================================== --- trunk/jnlib/dotlock.h 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/jnlib/dotlock.h 2009-09-23 10:28:41 UTC (rev 5162) @@ -21,13 +21,13 @@ #define LIBJNLIB_DOTLOCK_H struct dotlock_handle; -typedef struct dotlock_handle *DOTLOCK; +typedef struct dotlock_handle *dotlock_t; void disable_dotlock (void); -DOTLOCK create_dotlock(const char *file_to_lock); -void destroy_dotlock ( DOTLOCK h ); -int make_dotlock (DOTLOCK h, long timeout); -int release_dotlock (DOTLOCK h); +dotlock_t create_dotlock (const char *file_to_lock); +void destroy_dotlock ( dotlock_t h ); +int make_dotlock (dotlock_t h, long timeout); +int release_dotlock (dotlock_t h); void dotlock_remove_lockfiles (void); #endif /*LIBJNLIB_DOTLOCK_H*/ Modified: trunk/sm/keydb.c =================================================================== --- trunk/sm/keydb.c 2009-09-23 00:01:25 UTC (rev 5161) +++ trunk/sm/keydb.c 2009-09-23 10:28:41 UTC (rev 5162) @@ -47,7 +47,7 @@ } u; void *token; int secret; - DOTLOCK lockhandle; + dotlock_t lockhandle; }; static struct resource_item all_resources[MAX_KEYDB_RESOURCES]; From cvs at cvs.gnupg.org Fri Sep 25 19:09:31 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 25 Sep 2009 19:09:31 +0200 Subject: [svn] GnuPG - r5163 - branches/STABLE-BRANCH-2-0/g10 Message-ID: Author: wk Date: 2009-09-25 19:09:31 +0200 (Fri, 25 Sep 2009) New Revision: 5163 Modified: branches/STABLE-BRANCH-2-0/g10/ChangeLog branches/STABLE-BRANCH-2-0/g10/pkglue.c Log: Fix bug#1139. Modified: branches/STABLE-BRANCH-2-0/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-2-0/g10/ChangeLog 2009-09-23 10:28:41 UTC (rev 5162) +++ branches/STABLE-BRANCH-2-0/g10/ChangeLog 2009-09-25 17:09:31 UTC (rev 5163) @@ -1,3 +1,9 @@ +2009-09-25 Werner Koch + + * pkglue.c (pk_sign, pk_verify, pk_encrypt, pk_decrypt) + (pk_check_secret_key): Allow deprecated RSA identifiers 2 and 3. + Fixes bug#1139. + 2009-09-04 Werner Koch * keyedit.c (menu_select_uid): Use IDX ==-1 t select all. Modified: branches/STABLE-BRANCH-2-0/g10/pkglue.c =================================================================== --- branches/STABLE-BRANCH-2-0/g10/pkglue.c 2009-09-23 10:28:41 UTC (rev 5162) +++ branches/STABLE-BRANCH-2-0/g10/pkglue.c 2009-09-25 17:09:31 UTC (rev 5163) @@ -61,7 +61,7 @@ "(private-key(dsa(p%m)(q%m)(g%m)(y%m)(x%m)))", skey[0], skey[1], skey[2], skey[3], skey[4]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_S) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", @@ -90,7 +90,7 @@ if (rc) ; - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_S) data[0] = mpi_from_sexp (s_sig, "s"); else { @@ -125,7 +125,7 @@ "(public-key(elg(p%m)(g%m)(y%m)))", pkey[0], pkey[1], pkey[2]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_S) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(rsa(n%m)(e%m)))", pkey[0], pkey[1]); @@ -158,7 +158,7 @@ rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(elg(r%m)(s%m)))", data[0], data[1]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_S) { if (!data[0]) rc = gpg_error (GPG_ERR_BAD_MPI); @@ -197,7 +197,7 @@ "(public-key(elg(p%m)(g%m)(y%m)))", pkey[0], pkey[1], pkey[2]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_E) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(rsa(n%m)(e%m)))", @@ -223,7 +223,7 @@ else { /* add better error handling or make gnupg use S-Exp directly */ resarr[0] = mpi_from_sexp (s_ciph, "a"); - if (algo != GCRY_PK_RSA) + if (algo != GCRY_PK_RSA && algo != GCRY_PK_RSA_E) resarr[1] = mpi_from_sexp (s_ciph, "b"); } @@ -252,7 +252,7 @@ "(private-key(elg(p%m)(g%m)(y%m)(x%m)))", skey[0], skey[1], skey[2], skey[3]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_E) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", @@ -274,7 +274,7 @@ rc = gcry_sexp_build (&s_data, NULL, "(enc-val(elg(a%m)(b%m)))", data[0], data[1]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_E) { if (!data[0]) rc = gpg_error (GPG_ERR_BAD_MPI); @@ -321,7 +321,8 @@ "(private-key(elg(p%m)(g%m)(y%m)(x%m)))", skey[0], skey[1], skey[2], skey[3]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA + || algo == GCRY_PK_RSA_S || algo == GCRY_PK_RSA_E) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", From cvs at cvs.gnupg.org Mon Sep 28 11:40:58 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 28 Sep 2009 11:40:58 +0200 Subject: [svn] GpgOL - r309 - in trunk: . src Message-ID: Author: wk Date: 2009-09-28 11:40:57 +0200 (Mon, 28 Sep 2009) New Revision: 309 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac trunk/src/ChangeLog trunk/src/main.c Log: prepare 1.0.1 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-08-28 18:28:29 UTC (rev 308) +++ trunk/ChangeLog 2009-09-28 09:40:57 UTC (rev 309) @@ -1,3 +1,7 @@ +2009-09-28 Werner Koch + + Release 1.0.1. + 2009-08-28 Werner Koch * configure.ac [GCC]: Test for -Wno-pointer-sign. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-08-28 18:28:29 UTC (rev 308) +++ trunk/src/ChangeLog 2009-09-28 09:40:57 UTC (rev 309) @@ -1,3 +1,7 @@ +2009-09-25 Werner Koch + + * main.c (read_options): Enable Smime by default. + 2009-08-28 Werner Koch * mimemaker.c (do_mime_sign): Comment cleanup. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-08-28 18:28:29 UTC (rev 308) +++ trunk/NEWS 2009-09-28 09:40:57 UTC (rev 309) @@ -1,7 +1,11 @@ -Noteworthy changes for version 1.0.1 (not released) +Noteworthy changes for version 1.0.1 (2009-09-28) =================================================== + * No more event loop peeking to avoid problem with Office programs. + * S/MIME support is now enabled by default. + + Noteworthy changes for version 1.0.0 (2009-06-18) ================================================= Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-08-28 18:28:29 UTC (rev 308) +++ trunk/configure.ac 2009-09-28 09:40:57 UTC (rev 309) @@ -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.0.1]) -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;}')])) Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-08-28 18:28:29 UTC (rev 308) +++ trunk/src/main.c 2009-09-28 09:40:57 UTC (rev 309) @@ -584,7 +584,7 @@ load_extension_value ("enableSmime", &val); - opt.enable_smime = val == NULL || *val != '1' ? 0 : 1; + opt.enable_smime = (!val || atoi (val)); xfree (val); val = NULL; load_extension_value ("defaultProtocol", &val); From cvs at cvs.gnupg.org Mon Sep 28 11:51:57 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 28 Sep 2009 11:51:57 +0200 Subject: [svn] GpgOL - r310 - tags Message-ID: Author: wk Date: 2009-09-28 11:51:56 +0200 (Mon, 28 Sep 2009) New Revision: 310 Added: tags/gpgol-1.0.1/ Log: Release tag. From cvs at cvs.gnupg.org Mon Sep 28 16:37:49 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 28 Sep 2009 16:37:49 +0200 Subject: [svn] GnuPG - r5164 - trunk/g10 Message-ID: Author: wk Date: 2009-09-28 16:37:48 +0200 (Mon, 28 Sep 2009) New Revision: 5164 Added: trunk/g10/encrypt.c Removed: trunk/g10/encode.c Modified: trunk/g10/ChangeLog trunk/g10/Makefile.am trunk/g10/gpg.c trunk/g10/main.h trunk/g10/pkglue.c trunk/g10/server.c trunk/g10/trustdb.c Log: Rename encode.c to encrypt.c. Rename function in a simlar way. Re-indent encrypt.c Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-09-25 17:09:31 UTC (rev 5163) +++ trunk/g10/ChangeLog 2009-09-28 14:37:48 UTC (rev 5164) @@ -1,3 +1,20 @@ +2009-09-28 Werner Koch + + * encode.c: Rename to encrypt.c. Re-indent all. + * encrypt.c (encode_symmetric, encode_store, encode_seskey) + (encode_simple, encode_crypt, encode_filter) + (encode_crypt_files): Rename all to encrypt_*. Change all callers. + + * trustdb.c (get_validity_info): Take care of a NULL PK. Fixes + bug#1138. + (get_validity_string): Ditto. + +2009-09-25 Werner Koch + + * pkglue.c (pk_sign, pk_verify, pk_encrypt, pk_decrypt) + (pk_check_secret_key): Allow deprecated RSA identifiers 2 and 3. + Fixes bug#1139. + 2009-09-23 Marcus Brinkmann * call-agent.c: Include "scdaemon.h" before because of @@ -153,7 +170,7 @@ * options.h: Include session_env.h. (opt): Add field SESSION_ENV, remove obsolete fields. - + * call-agent.c (start_agent): Adjust start_new_gpg_agent for changed args. @@ -174,7 +191,7 @@ * parse-packet.c (parse): Use a casted -1 instead of a 32 bit constant to check for a garbled package. Fixes bug#1040. - * card-util.c (put_data_to_file, read_cert): New. + * card-util.c (put_data_to_file, read_cert): New. (card_edit): Add command "readcert". (fetch_url): Allow code also for this gnupg major version 2. * call-agent.c (agent_scd_readcert): New. @@ -316,12 +333,12 @@ * keydb.c (keydb_add_resource): Add readonly flag bit. (keydb_rebuild_caches): Don't act on readonly resources. - * keyring.c (keyring_register_filename): Add arg READONLY. + * keyring.c (keyring_register_filename): Add arg READONLY. (struct keyring_name): Add field READONLY. (keyring_is_writable): Implement readonly feature. (keyring_update_keyblock): Return GPG_ERR_EACCES for readonly keyrings. - (keyring_insert_keyblock, keyring_delete_keyblock): + (keyring_insert_keyblock, keyring_delete_keyblock): Ditto. 2009-04-01 Werner Koch @@ -394,7 +411,7 @@ 2009-01-26 Werner Koch - * card-util.c (card_status): Detect a Geldkarte. + * card-util.c (card_status): Detect a Geldkarte. 2009-01-13 Werner Koch @@ -467,7 +484,7 @@ * gpgv.c (main): Ditto. * keylist.c (set_attrib_fd): Do not close ATTRIB_FP if it is the - log stream. + log stream. (set_attrib_fd) [W32]: Set to binary mode. (dump_attribs): Flush the stream after writing. @@ -503,7 +520,7 @@ * card-util.c (generate_card_keys): Remove unused arg SERIALNO and adjust caller. - + * build-packet.c (write_sign_packet_header): Mark unused arg. * gpg.c (gpg_init_default_ctrl, gpg_deinit_default_ctrl): Ditto. * getkey.c (skip_unusable): Ditto. @@ -536,8 +553,8 @@ * server.c (option_handler): Mark non yet used arg. (input_notify, output_notify): Ditto. - (cmd_recipient, cmd_signer, cmd_encrypt, cmd_decrypt, cmd_verify) - (cmd_sign, cmd_import, cmd_export, cmd_delkeys, do_listkeys) + (cmd_recipient, cmd_signer, cmd_encrypt, cmd_decrypt, cmd_verify) + (cmd_sign, cmd_import, cmd_export, cmd_delkeys, do_listkeys) (cmd_genkey): Ditto. * verify.c (gpg_verify): Ditto. @@ -578,7 +595,7 @@ * parse-packet.c (parse): Remove special treatment for compressed new style packets. Fixes bug#931. - + * card-util.c (change_pin): Support setting of the reset code. 2008-09-24 Werner Koch @@ -650,8 +667,8 @@ * gpg.c: Make --fixed-list-mode a dummy. * options.h (struct): Removed FIXED_LIST_MODE. - * keyid.c (colon_strtime, colon_datestr_from_pk) - (colon_datestr_from_sk, colon_datestr_from_sig) + * keyid.c (colon_strtime, colon_datestr_from_pk) + (colon_datestr_from_sk, colon_datestr_from_sig) (colon_expirestr_from_sig): Remove fixed_list_mode case. * keylist.c (list_keyblock_colon): Ditto. Remove all now unsed code and reindent. @@ -680,7 +697,7 @@ 2008-04-18 Werner Koch - * misc.c (map_cipher_openpgp_to_gcry, map_cipher_gcry_to_openpgp) + * misc.c (map_cipher_openpgp_to_gcry, map_cipher_gcry_to_openpgp) (openpgp_cipher_test_algo): Add camellia-192. (openpgp_cipher_blocklen): New. * parse-packet.c (parse_key): Use new function here. @@ -757,16 +774,16 @@ 2008-02-14 Werner Koch * call-agent.c (default_inq_cb): New. - (agent_learn, agent_scd_getattr, agent_scd_pksign) - (agent_scd_pkdecrypt, agent_scd_change_pin, agent_scd_checkpin) + (agent_learn, agent_scd_getattr, agent_scd_pksign) + (agent_scd_pkdecrypt, agent_scd_change_pin, agent_scd_checkpin) (agent_get_passphrase, agent_clear_passphrase): Use new callback. (inq_writekey_parms): Fall back to the new callback for other - inquiries. + inquiries. (start_agent): Tell agent that we accept pinentry notifications. 2008-02-11 Werner Koch - * server.c (cmd_getinfo): New. + * server.c (cmd_getinfo): New. (register_commands): Register GETINFO. 2008-02-09 Marcus Brinkmann @@ -803,7 +820,7 @@ * misc.c (print_pubkey_algo_note): Print a warning if a type 20 key is used. - (openpgp_pk_test_algo, openpgp_pk_test_algo2) + (openpgp_pk_test_algo, openpgp_pk_test_algo2) (openpgp_pk_algo_usage): Allow type 20 keys only in rfc2440 mode. 2007-12-12 David Shaw (wk) @@ -825,7 +842,7 @@ (map_cipher_gcry_to_openpgp): New. (string_to_cipher_algo): Use it. * gpg.c (main): Print a warning if Camellia support is build in. - + * gpg.c (print_algo_names): New. From the 1.4 branch by David. (list_config): Use it here for the "ciphername" and "digestname" config items so we can get a script-parseable list of the names. @@ -1173,7 +1190,7 @@ 2007-03-05 Werner Koch Converted this file to UTF-8. - + Ported David and my multiple messages changes from 1.4.7. * options.h, gpg.c (main), mainproc.c (check_sig_and_print): Allow @@ -1184,7 +1201,7 @@ * status.c (get_status_string): Ditto. * mainproc.c (proc_plaintext): Emit it if multiple messages are detected. Error out if more than one plaintext packet is - encountered. + encountered. * mainproc.c (literals_seen): New. 2007-02-26 Werner Koch @@ -1227,12 +1244,12 @@ required. * gpg.c (main): Let --no-use-agent and --gpg-agent-info print a - warning. + warning. * misc.c (obsolete_option): New. 2007-01-29 Werner Koch - * pkclist.c (do_we_trust_pre): Issue a user-id-hint status code. + * pkclist.c (do_we_trust_pre): Issue a user-id-hint status code. 2007-01-15 Werner Koch @@ -1318,7 +1335,7 @@ * sign.c (sign_file, clearsign_file, sign_symencrypt_file): Ditto. * plaintext.c (ask_for_detached_datafile, hash_datafiles): Ditto. * encode.c (encode_simple, encode_crypt): Ditto. - * decrypt.c (decrypt_message, decrypt_messages): Ditto. + * decrypt.c (decrypt_message, decrypt_messages): Ditto. * keyedit.c (menu_clean): Made strings translatable. @@ -1339,7 +1356,7 @@ * encr-data.c: Allocate DFX context on the heap and not on the stack. Changes at several places. Fixes CVE-2006-6235. - + 2006-11-27 Werner Koch * openfile.c (ask_outfile_name): Fixed buffer overflow occurring @@ -1359,10 +1376,10 @@ (do_check): Made NDATA a size_t. (protect_secret_key): Made NARR a size_t. (protect_secret_key): Made NVYES a size_t. - * pubkey-enc.c (get_it): Made INDATALEN a size_t. + * pubkey-enc.c (get_it): Made INDATALEN a size_t. (get_it): Made NFRAME a size_t. * keyid.c (hash_public_key): Made NBITS an unsigned int. - * misc.c (checksum_mpi): Made NBYTES a size_t. + * misc.c (checksum_mpi): Made NBYTES a size_t. (openpgp_pk_test_algo2): Made USE_BUF a size_t. * seskey.c (encode_session_key): Made NFRAME a size_t. (do_encode_md): Ditto. @@ -1372,7 +1389,7 @@ 2006-11-10 Werner Koch * parse-packet.c (mpi_read): Changed NREAD to size_t to match the - gcry_mpi-scan prototype. + gcry_mpi-scan prototype. (mpi_read): Fixed double increment of bytes read to correctly detect overlong MPIs. @@ -1418,7 +1435,7 @@ * import.c (import_print_stats): Use log_printf. * build-packet.c (do_public_key): Care about mpi_write errors. - (do_secret_key, do_pubkey_enc, do_signature): Ditto. + (do_secret_key, do_pubkey_enc, do_signature): Ditto. (mpi_write): Print an extra warning on error. 2006-10-17 Werner Koch @@ -1459,12 +1476,12 @@ (set_status_fd): Register the progress cb. * seskey.c (encode_md_value): Check that the hash algo is valid - before getting the OID. + before getting the OID. 2006-10-04 Werner Koch * passphrase.c: Allow for a static passphrase in batch mode. - + * call-agent.c (agent_havekey): Removed. (percent_plus_escape): New. (agent_get_passphrase): New. @@ -1525,7 +1542,7 @@ 2006-09-13 Werner Koch - * gpg.c (main): Made --require-cross-certification the default. + * gpg.c (main): Made --require-cross-certification the default. 2006-09-06 Marcus Brinkmann @@ -1586,7 +1603,7 @@ (parse_gpg_control): Skip too large control packets. 2006-07-24 David Shaw (wk) - + * keydb.h, pkclist.c (select_algo_from_prefs, algo_available): Pass a union for preference hints rather than doing void * games. @@ -1609,7 +1626,7 @@ 2006-06-29 Werner Koch * parse-packet.c (parse_signature, parse_key): Need store the - length of opaque data as number of bits. + length of opaque data as number of bits. * card-util.c (card_store_subkey): Ditto. * mainproc.c (print_pkenc_list, check_sig_and_print): Replaced @@ -1668,7 +1685,7 @@ happened, and fail completely if we cannot reopen (should never happen). (main): Call it here. - + * parse-packet.c (dump_sig_subpkt, parse_signature): Fix meaning of key expiration and sig expiration subpackets - zero means "never expire" according to 2440, not "expire instantly". @@ -1734,10 +1751,10 @@ but kept option. 2006-04-28 David Shaw (wk) - + * keyserver.c (direct_uri_map): New. (keyserver_spawn): Used here to add "_uri" to certain gpgkeys_xxx - helpers when the meaning is different if a path is provided (i.e. + helpers when the meaning is different if a path is provided (i.e. ldap). (keyserver_import_cert): Show warning if there is a CERT fingerprint, but no --keyserver set. @@ -1767,7 +1784,7 @@ * sign.c (write_plaintext_packet): Factor common literal packet setup code from here, to... * encode.c (encode_simple): .. there. - + * main.h, plaintext.c (setup_plaintext_name): Here. New. Make sure the literal packet filename field is UTF-8 encoded. @@ -1799,7 +1816,7 @@ * status.c: Removed shared memory coprocess stuff Merged with current gpg 1.4.3 code. - + * keygen.c, keyid.c, misc.c, openfile.c, verify.c, trustdb.c * textfilter.c, tdbio.c, tdbdump.c, status.c, skclist.c, signal.c * sign.c, sig-check.c, seskey.c, seckey-cert.c, revoke.c @@ -1818,7 +1835,7 @@ * comment.c, pipemode.c: Removed. * card-util.c: Updated from gnupg-1.4.3. * compress-bz2.c: New. - + 2005-06-15 Werner Koch * g10.c (print_hashline, add_group): Fixes for signed/unsigned @@ -1953,7 +1970,7 @@ * keyedit.c (trustsig_prompt): Removed a "> 255" term; it is always false due to the data type. - + * passphrase.c (agent_get_passphrase): Use xasprintf and avoid non-literal format strings. @@ -2004,7 +2021,7 @@ 2003-10-01 Werner Koch - * card-util.c: Tweaked to use this source also under 1.3. + * card-util.c: Tweaked to use this source also under 1.3. 2003-09-30 Werner Koch @@ -2013,14 +2030,14 @@ * card-util.c (toggle_forcesig): New. (card_edit): New command "forcesig". - + * card-util.c (print_name, print_isoname): Use 0 and not LF fro the max_n arg of tty_print_utf8_string2. * call-agent.c (agent_scd_getattr): New. (learn_status_cb): Release values before assignment so that it can be used by getattr to update the structure. - + * card-util.c (change_pin): Simplified. We now have only a PIN and an Admin PIN. @@ -2032,7 +2049,7 @@ * card_status (card_status): Do not use fputs since the fp parameter can be NULL. This fixes a segv. - + 2003-09-24 Werner Koch * card-util.c (print_isoname,card_status): Handle opt.with_colons. @@ -2041,7 +2058,7 @@ 2003-09-23 Werner Koch Merged most of David Shaw's changes in 1.3 since 2003-06-03. - + * Makefile.am: Include W32LIBS where appropriate. * armor.c (parse_hash_header,armor_filter): Drop TIGER/192 support. @@ -2062,13 +2079,13 @@ * encode.c (use_mdc), g10.c (main): Use RFC1991 and RFC2440 directly to check for MDC usability. Do not set the force_mdc or disable_mdc flags since there is no point any longer. - + * g10.c (main): Use "keyserver-url" instead of "preferred-keyserver" for the sake of short and simple commands. (add_keyserver_url): Clarify a few strings. It's a "preferred keyserver URL". * keyedit.c (keyedit_menu): Ditto. - * sign.c (mk_notation_policy_etc): Ditto. + * sign.c (mk_notation_policy_etc): Ditto. * main.h, keygen.c (keygen_add_keyserver_url): Signature callback for adding a keyserver URL. @@ -2268,7 +2285,7 @@ (get_parameter_algo): Ditto. * keyedit.c (keyedit_menu): Ditto. * tdbdump.c (import_ownertrust): Ditto. s/isxdigit/hexdigitp/. - * revoke.c (ask_revocation_reason): + * revoke.c (ask_revocation_reason): * keyserver.c (keyserver_spawn): Dito. * parse-packet.c (parse): Disallow old style partial length for @@ -2306,7 +2323,7 @@ * card-util.c (card_status): Free pk in case of an error and return if the card is no OpenPGP card. - + 2003-09-18 Werner Koch * g10.c: New command --card-edit. @@ -2314,8 +2331,8 @@ (print_sha1_fpr, print_isoname): Ditto. (get_one_name,change_name, change_url, change_login,change_lang) (change_sex): New; taken from keygen.c. - * keygen.c (smartcard_get_one_name, smartcard_change_name) - (smartcard_change_url, smartcard_change_login_data) + * keygen.c (smartcard_get_one_name, smartcard_change_name) + (smartcard_change_url, smartcard_change_login_data) (smartcard_change_lang, smartcard_change_sex): Removed. (check_smartcard): Removed most menu items. @@ -2328,9 +2345,9 @@ 2003-09-04 Werner Koch - * keygen.c (do_add_key_flags, parse_parameter_usage) + * keygen.c (do_add_key_flags, parse_parameter_usage) (do_generate_keypair): Add support the proposed AUTH key flag. - * getkey.c (fixup_uidnode, merge_selfsigs_main) + * getkey.c (fixup_uidnode, merge_selfsigs_main) (merge_selfsigs_subkey, premerge_public_with_secret): Ditto. * keylist.c (print_capabilities): Ditto. @@ -2338,7 +2355,7 @@ * pkglue.c (mpi_from_sexp): New. Used to factor out some common code. - + 2003-08-24 Werner Koch * keygen.c (do_generate_keypair): Print a reminder to use --gen-revoke. @@ -2350,7 +2367,7 @@ * mainproc.c (symkey_decrypt_sesskey): Better check for the algorithm and check the return values of some functions. * mdc.c (use_mdc): Simplified. - + 2003-08-07 Werner Koch * pkglue.c (pk_sign): Fix last change. @@ -2443,7 +2460,7 @@ 2003-07-03 Werner Koch - * options.h (DBG_CIPHER): Reintroduced it. + * options.h (DBG_CIPHER): Reintroduced it. * seskey.c (encode_session_key): Debug output of the session key. * pubkey-enc.c (get_it): Handle card case. @@ -2514,9 +2531,9 @@ Fixed all "==" comparisons against error code constants to use gpg_err_code(). - * import.c (import_secret_one): - (import_revoke_cert): - (chk_self_sigs): + * import.c (import_secret_one): + (import_revoke_cert): + (chk_self_sigs): * misc.c (openpgp_md_map_name): Check also for the Hx format. (openpgp_cipher_map_name): Check also for the Sx format. @@ -2535,7 +2552,7 @@ listed below becuause they are too similar and done at far too many places. As of today the code builds using the current libgcrypt from CVS but it is very unlikely that it actually works. - + * sig-check.c (cmp_help): Removed. Was never used. * pkglue.c: New. Most stuff taken from gnupg 1.1.2. @@ -2588,7 +2605,7 @@ s/g10_errstr/gpg_strerror/ s/MPI/gcry_mpi_t/ Adjusted all md_open calls to the libgcrypt API. - + * build-packet.c (do_comment): Return error code from iobuf write function. (do_user_id): Ditto. @@ -2698,7 +2715,7 @@ * seckey-cert.c (do_check): Issue the RSA_OR_IDEA status when the cipher algo is IDEA to make it easier to track down the problem. (From twoaday on stable branch) - + 2003-05-24 David Shaw * armor.c, g10.c, kbnode.c, misc.c, pkclist.c, sign.c, @@ -2717,10 +2734,10 @@ re-fetch a key when we already have that key handy. Cache the result of the check so we don't need to hit the trustdb more than once. - + * getkey.c (skip_disabled): New function to get a pk and call is_disabled on it. (key_byname): Use it here. - + * packet.h, getkey.c (skip_disabled), keylist.c (print_capabilities): New "pk_is_disabled" macro to retrieve the cached disabled value if available, and fill it in via @@ -2747,7 +2764,7 @@ * main.h, keylist.c (dump_attribs), mainproc.c (check_sig_and_print): Dump attribs if --attrib-fd is set when verifying signatures. - + * g10.c (main): New --gnupg option to disable the various --openpgp, --pgpX, etc. options. This is the same as --no-XXXX for those options. @@ -2825,7 +2842,7 @@ * g10.c (main): Use string_to_trust_value here for --force-ownertrust. - + * options.h, g10.c (main), trustdb.c (trust_model_string, init_trustdb, check_trustdb, update_trustdb, get_validity, validate_one_keyblock): An "OpenPGP" trust model is misleading @@ -2875,7 +2892,7 @@ * mainproc.c (check_sig_and_print): Show digest algorithm and sig class when verifying a sig with --verbose on, and add version, pk and hash algorithms and sig class to VALIDSIG. - + * parse-packet.c (enum_sig_subpkt): Make a warning message a --verbose warning message since we don't need to warn every time we see an unknown critical (we only need to invalidate the @@ -3355,14 +3372,14 @@ don't repeat some key information twice. 2002-12-22 Timo Schulz - + * import.c (print_import_check): New. (import_one): Use it here. Use merge_keys_and_selfsig in the interactive mode to avoid wrong key information. * status.h: Add new status code. * status.c: Ditto. - + 2002-12-13 David Shaw * pkclist.c (do_we_trust): Tweak language to refer to the "named @@ -3578,7 +3595,7 @@ list-key operations. This is required because getkey needs to know whether a a key is ultimately trusted. From Werner on stable branch. - + * exec.c [__CYGWIN32__]: Keep cygwin separate from Mingw32; we don't need it here as it behaves more like a Posix system. From Werner on stable branch. @@ -3591,7 +3608,7 @@ * g10.c, gpgv.c (main) [__CYGWIN32__]: Don't get the homedir from the registry. From Werner on stable branch. - + * keyedit.c (show_key_with_all_names_colon): Make --with-colons --edit display match the validity and trust of --with-colons --list-keys. @@ -3819,10 +3836,10 @@ * keylist.c: (print_pubkey_info): New. (print_seckey_info): New. - * main.h: Prototypes for the new functions. + * main.h: Prototypes for the new functions. * delkey.c (do_delete_key): Use it here. * revoke.c (gen_desig_revoke): Ditto. - + 2002-10-17 Werner Koch * pkclist.c (do_edit_ownertrust): Show all user IDs. This should @@ -4234,7 +4251,7 @@ * import.c (import_one): Ask the user if the key shall be imported when the interactive mode is used. Useful to extract selected keys from a file. - + 2002-08-16 Werner Koch * seckey-cert.c: Workaround to allow decryption of v3 keys created @@ -4303,7 +4320,7 @@ checked. The options file and any extension files are checked wherever they are, as well as their enclosing directories. This is Debian bug 147760. - + 2002-08-06 Stefan Bellon * g10.c (main): Use of EXTSEP_S in new gpg.conf string. @@ -4526,7 +4543,7 @@ * photoid.c: Use __MINGW32__ to include windows because HAVE_DOSISH_SYSTEM is also set for OS/2 and plain DOS. Provide - constant missing in older mingw installations. + constant missing in older mingw installations. 2002-06-21 Stefan Bellon @@ -4640,7 +4657,7 @@ 2002-06-14 Timo Schulz * skclist.c (is_insecure): Implemented. - + 2002-06-12 David Shaw * keyserver.c (keyserver_spawn): Properly handle PROGRAM responses @@ -4688,7 +4705,7 @@ * encode.c (encode_symmetric): Disable the compat flag when the expert mode is enabled. - + 2002-06-07 David Shaw * options.skel, options.h, main.h, keydb.h, pkclist.c @@ -4752,18 +4769,18 @@ * encode.c (encode_simple): Ignore the new mode for RFC1991. * mainproc.c (symkey_decrypt_sesskey): Better check for weird keysizes. - + 2002-06-05 Timo Schulz * encode.c (encode_sesskey): New. (encode_simple): Use it here. But by default we use the compat mode which supress to generate encrypted session keys. - + 2002-06-05 Timo Schulz * mainproc.c (symkey_decrypt_sesskey): New. (proc_symkey_enc): Support for encrypted session keys. - + 2002-06-04 David Shaw * sign.c (hash_for, sign_file): When encrypting and signing at the @@ -4791,7 +4808,7 @@ * keylist.c (show_policy_url, show_notation): Display if the policy or notation is critical. - + 2002-06-03 David Shaw * main.h, g10.c (main), keylist.c (dump_attribs, set_attrib_fd, @@ -4811,7 +4828,7 @@ showing the photo for confirmation is not safe when noninteractive since the "user" may not be able to dismiss a viewer window. Noted by Timo Schulz. - + 2002-06-03 David Shaw * options.skel: Sample photo viewers for Win32. @@ -4849,7 +4866,7 @@ letters for non-interactive output. (show_revocation_reason): Now it is global. * pubkey-enc.c (get_it): Show if the key has been revoked. - + 2002-05-30 David Shaw * sign.c (write_signature_packets, sign_file, clearsign_file, @@ -5017,7 +5034,7 @@ 2002-05-14 Timo Schulz * exec.c (make_tempdir) [MINGW32]: Added missing '\'. - + 2002-05-14 Stefan Bellon * exec.c (make_tempdir): Make use of EXTSEP_S instead of hardcoded @@ -5151,7 +5168,7 @@ * mainproc.c (proc_symkey_enc): Don't ask for a passphrase in the list only mode. - + 2002-05-05 David Shaw * keyserver.c (keyserver_refresh): --refresh-keys implies @@ -5238,7 +5255,7 @@ * g10.c, options.h: New options --display, --ttyname, --ttytype, --lc-ctype, --lc-messages to be used with future versions of the - gpg-agent. + gpg-agent. * passphrase.c (agent_send_option,agent_send_all_options): New. (agent_open): Send options to the agent. @@ -5329,7 +5346,7 @@ sync operation done by its callers. (get_validity): Add logic for maintaining a pending_check flag. (clear_ownertrust): New. - + * keyedit.c (sign_uids): Don't call revalidation_mark depending on primary_pk. (keyedit_menu): Call revalidation_mark after "trust". @@ -5338,7 +5355,7 @@ * delkey.c (do_delete_key): Clear the owenertrust information when deleting a public key. - + 2002-04-18 Werner Koch * seskey.c (encode_md_value): Print an error message if a wrong @@ -5515,7 +5532,7 @@ 2002-04-02 Werner Koch * Makefile.am (EXTRA_DIST): Removed OPTIONS an pubring.asc - they - are no longer of any use. + are no longer of any use. 2002-04-03 David Shaw @@ -5654,7 +5671,7 @@ * import.c (import_one): call revocation_present after importing a new key. Note that this applies to --import, --recv-keys, and --search-keys. - + * keyserver-internal.h, keyserver.c (keyserver_import_fprint): import via fingerprint (for revocation keys). @@ -5721,7 +5738,7 @@ * packet.h, parse-packet.c (parse_one_sig_subpkt, can_handle_critical, parse_signature): Get revocation key information out of direct sigs. - + * keylist.c (list_keyblock_print): don't assume that the presence of a 0x20 signature means the key is revoked. With revocation keys, this may not be true if the revocation key is not around to @@ -5736,7 +5753,7 @@ * import.c (import_revoke_cert): don't keep processing after a revocation is rejected. - + * import.c (delete_inv_parts): Allow importing a revocation signature even if it was not issued by the key. This allows a revocation key to issue it. Of course, the sig still needs to be @@ -5801,7 +5818,7 @@ 2002-02-14 Werner Koch - * g10.c: New option --no-use-agent. + * g10.c: New option --no-use-agent. * pkclist.c (check_signatures_trust): Always print the warning for unknown and undefined trust. Removed the did_add cruft. Reported @@ -5828,7 +5845,7 @@ * options.h, g10.c (main), cipher.c (write_header): Add a knob to --disable-mdc/--no-disable-mdc. Off by default, of course, but is used in --pgp2 and --pgp6 modes. - + * pkclist.c (build_pk_list): Allow specifying multiple users in the "Enter the user ID" loop. Enter a blank line to stop. Show each key+id as it is added. @@ -5836,7 +5853,7 @@ * keylist.c (show_policy_url), mainproc.c (print_notation_data): It is not illegal (though possibly silly) to have multiple policy URLs in a given signature, so print all that are present. - + * hkp.c (hkp_search): More efficient implementation of URL-ifying code. @@ -5847,7 +5864,7 @@ * photoid.c (show_photo): Call the new pct_expando function rather than expand strings internally. - + * sign.c (mk_notation_and_policy): Show policy URLs and notations when making a signature if show-policy/show-notation is on. %-expand policy URLs during generation. This lets the user have @@ -5976,7 +5993,7 @@ * helptext.c: Revise the sign_uid.class help text as suggested by Stefan. - + 2002-01-20 Werner Koch * passphrase.c (passphrase_to_dek): Add tryagain_text arg to be @@ -5988,7 +6005,7 @@ * keyedit.c (change_passphrase): Ditto. * passphrase.c (agent_open): Disable opt.use_agent in case of a - problem with the agent. + problem with the agent. (agent_get_passphrase): Ditto. (passphrase_clear_cache): Ditto. @@ -5999,15 +6016,15 @@ (agent_get_passphrase): Implemented new protocol here. (passphrase_clear_cache): Ditto. (readline): New. - + 2002-01-15 Timo Schulz * encode.c (encode_crypt_files): Fail if --output is used. - + * g10.c: New command --decrypt-files. * decrypt.c (decrypt_messages): New. - + 2002-01-09 David Shaw * g10.c, misc.c, gpgv.c: move idea_cipher_warn to misc.c so gpgv.c @@ -6024,7 +6041,7 @@ 2002-01-09 Timo Schulz * encode.c (encode_crypt_files): Now it behaves like verify_files. - + * g10.c (main): We don't need to check argc for encode_crypt_files any longer. @@ -6112,7 +6129,7 @@ 2002-01-03 Timo Schulz * g10.c: New command --encrypt-files. - + * verify.c (print_file_status): Removed the static because encode_crypt_files also uses this function. @@ -6216,7 +6233,7 @@ * encode.c (encode_simple, encode_crypt): i18n 2 strings. 2001-12-22 Timo Schulz - + * encode.c (encode_simple, encode_crypt): Use is_file_compressed to avoid to compress compressed files. @@ -6251,9 +6268,9 @@ * free-packet.c (free_attributes (new)): function to free an attribute packet. - + * gpgv.c: added stub show_photo - + * keyedit.c (keyedit_menu, menu_adduid, menu_showphoto): can add a photo (calls generate_photo_id), or display a photo (calls show_photo) from the --edit menu. New commands are "addphoto", @@ -6261,7 +6278,7 @@ * keylist.c (list_keyblock_print): show photos during key list if --show-photos enabled. - + * keyserver.c (keyserver_spawn): use the generic exec_xxx functions to call keyserver helper. @@ -6269,7 +6286,7 @@ --photo-viewer to give the command line to display a picture. * options.skel: instructions for the photo viewer - + * parse-packet.c (parse_user_id, setup_user_id (new)): common code for both user IDs and attribute IDs moved to setup_user_id. @@ -6317,7 +6334,7 @@ * g10.c. options.h : New option --show-keyring * getkey.c (get_ctx_handle): New. - * keylist.c (list_one): Implement option here. By David Champion. + * keylist.c (list_one): Implement option here. By David Champion. 2001-12-20 David Shaw @@ -6344,7 +6361,7 @@ the permission warning message(s). This also permits use of the keyserver if it had been disabled (see above). Also check the permissions/ownership of random_seed. - + * keyserver.c (keyserver_spawn): The new glibc prints a warning when using mktemp() (the code was already secure, but the warning was bound to cause confusion). Use a different implementation @@ -6417,7 +6434,7 @@ (hkp_search): Ditto for the char* vars. * g10.c (main): Print the IDEA warning also for -c and -se. - + * g10.c (get_temp_dir): Assert that we have dropped privs * encode.c (encode_crypt): Include the first key into the --pgp2 @@ -6569,10 +6586,10 @@ selected. Based on a patch by W Lewis. * pkclist.c (do_edit_ownertrust): Allow to skip over keys, the non - working "show info" is now assigned to "i" + working "show info" is now assigned to "i" * trustdb.c (ask_ownertrust, validate_keys): Implement a real quit here. Both are by David Shaw. - + * trustdb.c (validate_keys): Make sure next_exipire is initialized. * sign.c (make_keysig_packet): Use SHA-1 with v4 RSA keys. @@ -6619,18 +6636,18 @@ (keydb_locate_writable): Make a real implementation. * keyring.c (next_kr): Removed and changed all callers to set the resource directly from the one given with the handle. - (keyring_is_writable): New. + (keyring_is_writable): New. (keyring_rebuild_cache): Add an arg to pass the token from keydb. 2001-10-17 Werner Koch * keyring.c (keyring_search): Enabled word search mode but print a warning that it is buggy. - + 2001-10-11 Werner Koch * hkp.c (hkp_ask_import): No more need to set the port number for - the x-hkp scheme. + the x-hkp scheme. (hkp_export): Ditto. 2001-10-06 Stefan Bellon @@ -6643,7 +6660,7 @@ * export.c (do_export_stream): Do not push the compress filter here because the context would run out of scope due to the iobuf_close done by the caller. - (do_export): Do it here instead. + (do_export): Do it here instead. 2001-09-28 Werner Koch @@ -6657,7 +6674,7 @@ (validate_one_keyblock): this and changed args for direct calling. (mark_usable_uid_certs, validate_one_keyblock) (validate_key_list): Add next_expire arg to keep track of - expiration times. + expiration times. (validate_keys): Ditto for UTKs and write the stamp. * tdbio.c (migrate_from_v2): Check return code of tbdio_sync. @@ -6739,18 +6756,18 @@ PREF, SIG, SDIR and CACH. Changed migration function to work direct on the file. (tdbio_read_nextcheck): New. - (tdbio_write_nextcheck): New. + (tdbio_write_nextcheck): New. 2001-09-21 Werner Koch Revamped the entire key validation system. * trustdb.c: Complete rewrite. No more validation on demand, - removed some functions, adjusted to all callers to use the new + removed some functions, adjusted to all callers to use the new and much simpler interface. Does not use the LID anymore. * tdbio.c, tdbio.h: Add new record types trust and valid. Wrote a migration function to convert to the new trustdb layout. * getkey.c (classify_user_id2): Do not allow the use of the "#" - prefix. + prefix. * keydb.h: Removed the TDBIDX mode add a skipfnc to the descriptor. * keyring.c (keyring_search): Implemented skipfnc. @@ -6761,7 +6778,7 @@ * keylist.c (print_fingerprint): Renamed from fingerprint, made global available. Added new arg to control the print style. - * mainproc.c (print_fingerprint): Removed. + * mainproc.c (print_fingerprint): Removed. * pkclist.c (print_fpr, fpr_info): Removed and changed callers to use print_fingerprint. * keyedit.c (show_fingerprint): Ditto. @@ -6776,7 +6793,7 @@ * keyring.c (keyring_release): Close the iobuf. (keyring_get_keyblock): Init ret_kb to NULL and store error contidion. - * import.c (import_new_stats_handle): New. + * import.c (import_new_stats_handle): New. (import_release_stats_handle): New. (import_print_stats): Renamed from static fnc print_stats. (import_keys, import_keys_stream): Add an optional status handle @@ -6797,7 +6814,7 @@ * mainproc.c (print_notation_data): Wrap notation data status lines after 50 chars. - + * mainproc.c (proc_pubkey_enc): Make option try-all-secrets work. By disastry at saiknes.lv. @@ -6833,7 +6850,7 @@ * keyedit.c (sign_uids): Added experimental ALREADY_SIGNED * hkp.c (hkp_import): Use log_error. Bug reported by Neal H - Walfield. + Walfield. * getkey.c (classify_user_id2): Change args to take the desc union direct. It was a stupid idea to pass the individual fields of an @@ -6852,7 +6869,7 @@ * keyring.c, keyring.h: New. * ringedit.c: Removed. Moved some stuff to keyring.c * getkey.c: Changed everything related to the key retrieving - functions which are now using the keydb_ functions. + functions which are now using the keydb_ functions. (prepare_search, word_match_chars, word_match) (prepare_word_match, compare_name): Moved to keyring.c (get_pubkey_byname): Removed ctx arg and add ret_kdbhd @@ -6864,19 +6881,19 @@ * import.c (import_one): Updated to use the new keydb interface. (import_secret_one): Ditto. (import_revoke_cert): Ditto. - * delkey.c (do_delete_key): Ditto. + * delkey.c (do_delete_key): Ditto. * keyedit.c (keyedit_menu): Ditto. (get_keyblock_byname): Removed. - * revoke.c (gen_revoke): Ditto. + * revoke.c (gen_revoke): Ditto. * export.c (do_export_stream): Ditto. * trustdb.c (update_trustdb): Ditto. * g10.c, gpgv.c (main): Renamed add_keyblock_resource to - keydb_add_resource. + keydb_add_resource. * Makefile.am: Added and removed files. * keydb.h: Moved KBNODE typedef and MAX_FINGERPRINT_LEN to * global.h: this new header. - + 2001-09-03 Werner Koch * passphrase.c (agent_get_passphrase): Changed nread to size_t. @@ -6898,7 +6915,7 @@ * parse-packet.c (parse_key,parse_pubkeyenc) (parse_signature): Return error on reading bad MPIs. - + * mainproc.c (check_sig_and_print): Always print the user ID even if it is not bound by a signature. Use the primary UID in the status messages and encode them in UTF-8 @@ -6952,12 +6969,12 @@ (sign_file, sign_symencrypt_file): Moved common code to .. (write_onepass_sig_packets): .. this new function. (sign_file, clearsign_file, sign_symencrypt_file): Moved common - code to + code to (write_signature_packets): this new function. (write_signature_packets, make_keysig_packet) - (update_keysig_packet): Moved common code to + (update_keysig_packet): Moved common code to (hash_uid, hash_sigclass_to_magic): these new functions - (sign_file, sign_symencrypt_file): Moved common code to + (sign_file, sign_symencrypt_file): Moved common code to (write_plaintext_packet): this new function. 2001-08-21 Stefan Bellon @@ -6987,7 +7004,7 @@ * g10.c [__riscos__]: Some patches and new options foo-file similar to all foo-fd options. * gpgv.c, openfile.c, ringedit.c, tdbio.c: Minor fixes. Mainly - replaced hardcoded path separators with EXTSEP_S like macros. + replaced hardcoded path separators with EXTSEP_S like macros. * passprase.c [__riscos__]: Disabled agent stuff * trustdb.c (check_trust): Changed r_trustlevel to signed int to avoid mismatch problems in pkclist.c @@ -6997,7 +7014,7 @@ * options.h [__riscos__]: Use an extern unless included from the main module. * signal.c (got_fatal_signal) [__riscos__]: Close all files. - + 2001-08-14 Werner Koch * keygen.c (ask_algo): New arg r_usage. Allow for RSA keys. @@ -7015,7 +7032,7 @@ (write_selfsig, write_keybinding): Handle new usage arg. * build-packet.c (build_sig_subpkt): Make sure that key flags go into the hashed area. - + * keygen.c (write_uid): Initialize the reference cunter. * keyedit.c (keyedit_menu): No more need to update the trustdb for @@ -7034,7 +7051,7 @@ * parse-packet.c (parse_user_id,parse_photo_id): Initialize them * free-packet.c (free_user_id): Free them. (copy_user_id): Removed. - (scopy_user_id): New. + (scopy_user_id): New. (cmp_user_ids): Optimized for identical pointers. (release_public_key_parts): Release the uid. (copy_public_key_with_new_namehash): Removed. @@ -7055,7 +7072,7 @@ * pkclist.c (select_algo_from_prefs): Adjusted for the new preference implementation. * pubkey-enc.c (is_algo_in_prefs): New. - (get_it): Use that new function. + (get_it): Use that new function. 2001-08-09 Werner Koch @@ -7176,12 +7193,12 @@ * getkey.c (merge_selfsigs): Exit gracefully when a secret key is encountered. May happen if a secret key is in public keyring. Reported by Francesco Potorti. - + 2001-06-12 Werner Koch * getkey.c (compare_name): Use ascii_memistr(), ascii_memcasecmp() * keyedit.c (keyedit_menu): Use ascii_strcasecmp(). - * armor.c (radix64_read): Use ascii_toupper(). + * armor.c (radix64_read): Use ascii_toupper(). * ringedit.c (do_bm_search): Ditto. * keygen.c (read_parameter_file): Ditto. * openfile.c (CMP_FILENAME): Ditto. @@ -7233,7 +7250,7 @@ 2001-05-01 Werner Koch - * passphrase.c (writen): Replaced ssize_t by int. Thanks to + * passphrase.c (writen): Replaced ssize_t by int. Thanks to to Robert Joop for reporting that SunOS 4.1.4 does not have it. 2001-04-28 Werner Koch @@ -7263,10 +7280,10 @@ 2001-04-23 Werner Koch - * hkp.c (hkp_ask_import): Allow to specify a port number for the + * hkp.c (hkp_ask_import): Allow to specify a port number for the keyserver. Add a kudge to set the no_shutdown flag. (hkp_export): Ditto. - * options.skel: Document the changes + * options.skel: Document the changes 2001-04-20 Werner Koch @@ -7309,7 +7326,7 @@ 2001-04-05 Werner Koch * armor.c (unarmor_pump_new,unarmor_pump_release): New. - (unarmor_pump): New. + (unarmor_pump): New. * pipemode.c (pipemode_filter): Use the unarmor_pump to handle armored or non-armored detached signatures. We can't use the regular armor_filter because this does only check for armored @@ -7412,7 +7429,7 @@ 2001-03-19 Werner Koch * g10.c (main): the default keyring is no always used unless - --no-default-keyring is given. + --no-default-keyring is given. * ringedit.c (add_keyblock_resource): invalidate cache after file creation. @@ -7454,7 +7471,7 @@ function so that we can adjust for the next read. * options.skel: Fixed 3 typos. By Thomas Klausner. Replaced the - keyserver example by a better working server. + keyserver example by a better working server. * parse-packet.c (parse_symkeyenc): Return Invalid_Packet on error. (parse_pubkeyenc): Ditto. @@ -7471,7 +7488,7 @@ * signal.c (do_sigaction): Removed. (init_one_signal): New to replace the above. Needed to support systems without sigactions. Suggested by Dave Dykstra. - (got_fatal_signal,init_signals): Use the above here. + (got_fatal_signal,init_signals): Use the above here. (do_block): Use sigset() if sigprocmask() is not available. * armor.c (parse_hash_header): Test on TIGER192, which is the @@ -7487,7 +7504,7 @@ * getkey.c (merge_selfsigs_main): Set expire date and continue processing even if we found a revoked key. (merge_selfsigs_subkeys): Ditto. - + * packet.h: Add an is_revoked flag to the user_id packet. * getkey.c (fixup_uidnode): Set that flag here. (merge_selfsigs_main): Fix so that the latest signature is used to @@ -7496,9 +7513,9 @@ * mainproc.c (check_sig_and_print): Print the primary user ID according the the node flag and then all other non-revoked user IDs. (is_uid_revoked): Removed; it is now handled by the key selection code. - + Changed the year list of all copyright notices. - + 2001-03-07 Werner Koch * getkey.c (finish_lookup): Print an info message only in verbose mode. @@ -7517,11 +7534,11 @@ (cache_selfsig_result): New. * export.c (do_export_stream): Delete that sig subpkt before exporting. * import.c (remove_bad_stuff): New. - (import): Apply that function to all imported data + (import): Apply that function to all imported data 2001-03-03 Werner Koch - * getkey.c: Introduced a new lookup context flag "exact" and used + * getkey.c: Introduced a new lookup context flag "exact" and used it in all place where we once used primary. (classify_user_id2): Replaced the old function and add an extra argument to return whether an exact keyID has been requested. @@ -7531,7 +7548,7 @@ 2001-03-02 Werner Koch - * keylist.c (list_one): Remove the merge key calls. + * keylist.c (list_one): Remove the merge key calls. 2001-03-01 Werner Koch @@ -7543,7 +7560,7 @@ * import.c (import_one): Take UNU_PUBKEY into account. * mainproc.c (list_node): Ditto. * keylist.c (list_keyblock): Ditto. - * keyedit.c (print_and_check_one_sig): Ditto. + * keyedit.c (print_and_check_one_sig): Ditto. 2001-02-09 Werner Koch @@ -7608,7 +7625,7 @@ 2001-01-09 Werner Koch - * status.c, status.h: New status USERID_HINT. + * status.c, status.h: New status USERID_HINT. (write_status_text): Replace LF and CR int text by C-escape sequence. * passphrase.c (passphrase_to_dek): Fixed the NEED_PASSPHRASE @@ -7636,7 +7653,7 @@ atexit stuff does not work due to the use of raise. Suggested by Peter Fales. * gpgv.c (remove_lockfiles): New stub. - + 2000-12-19 Werner Koch * status.c, status.h (cpr_get_no_help): New. @@ -7726,11 +7743,11 @@ * status.c, status.h: Add 3 status lcodes for notaions and policy. * mainproc.c (print_notation_data): Do status output of notations. - + 2000-11-13 Werner Koch * sign.c (clearsign_file): Use LF macro to print linefeed. - + 2000-11-11 Paul Eggert Clean up the places in the code that incorrectly use "long" or @@ -7755,7 +7772,7 @@ * g10.c (main): New option --enable-special-filenames. 2000-11-07 Werner Koch - + * g10.c (main): New command --pipemode. * pipemode.c: New. @@ -7766,7 +7783,7 @@ * keygen.c (read_parameter_file): Add a cast for isspace(). - * status.c (myread): Use SIGINT instead of SIGHUP for DOS. + * status.c (myread): Use SIGINT instead of SIGHUP for DOS. 2000-10-19 Werner Koch @@ -7775,7 +7792,7 @@ (radix64_read): Act on new option. * openfile.c (try_make_homedir): Klaus Singvogel fixed a stupid - error introduced on Sep 6th. + error introduced on Sep 6th. 2000-10-18 Werner Koch @@ -7787,7 +7804,7 @@ * mainproc.c (do_proc_packets): Hack to fix the problem that signatures are not detected when there is a MDC packet but no compression packet. - + * g10.c (print_hashline): New. (print_mds): Use above func with --with-colons. @@ -7816,7 +7833,7 @@ * armor.c (armor_filter): Replaced the faked 1-pass packet by the new control packet. - * keyedit.c (keyedit_menu): Allow batchmode with a command_fd. + * keyedit.c (keyedit_menu): Allow batchmode with a command_fd. * status.c (my_read): New. (do_get_from_fd): use it. @@ -7861,7 +7878,7 @@ * g10.c (main): Default S2K algorithms are now SHA1 and CAST5 - this should solve a lot of compatibility problems with other OpenPGP apps because those algorithms are SHOULD and not optional. The old - way to force it was by using the --openpgp option whith the drawback + way to force it was by using the --openpgp option whith the drawback that this would disable a couple of workarounds for PGP. * g10.c (main): Don't set --quite along with --no-tty. By Frank Tobin. @@ -7904,7 +7921,7 @@ * parse-packet.c (dump_sig_subpkt): Print info about the ARR. * openfile.c (overwrite_filep): Always return okay if the file is - called /dev/null. + called /dev/null. (make_outfile_name): Add ".sign" to the list of know extensions. (open_sigfile): Ditto. Modified: trunk/g10/Makefile.am =================================================================== --- trunk/g10/Makefile.am 2009-09-25 17:09:31 UTC (rev 5163) +++ trunk/g10/Makefile.am 2009-09-28 14:37:48 UTC (rev 5164) @@ -81,7 +81,7 @@ seckey-cert.c \ encr-data.c \ cipher.c \ - encode.c \ + encrypt.c \ sign.c \ verify.c \ revoke.c \ Deleted: trunk/g10/encode.c Copied: trunk/g10/encrypt.c (from rev 5161, trunk/g10/encode.c) =================================================================== --- trunk/g10/encrypt.c (rev 0) +++ trunk/g10/encrypt.c 2009-09-28 14:37:48 UTC (rev 5164) @@ -0,0 +1,957 @@ +/* encrypt.c - Main encryption driver + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006, 2009 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GnuPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include +#include +#include +#include +#include +#include + +#include "gpg.h" +#include "options.h" +#include "packet.h" +#include "status.h" +#include "iobuf.h" +#include "keydb.h" +#include "util.h" +#include "main.h" +#include "filter.h" +#include "trustdb.h" +#include "i18n.h" +#include "status.h" +#include "pkglue.h" + + +static int encrypt_simple( const char *filename, int mode, int use_seskey ); +static int write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, iobuf_t out ); + +/**************** + * Encrypt FILENAME with only the symmetric cipher. Take input from + * stdin if FILENAME is NULL. + */ +int +encrypt_symmetric (const char *filename) +{ + return encrypt_simple( filename, 1, 0 ); +} + + +/**************** + * Encrypt FILENAME as a literal data packet only. Take input from + * stdin if FILENAME is NULL. + */ +int +encrypt_store (const char *filename) +{ + return encrypt_simple( filename, 0, 0 ); +} + + +static void +encrypt_seskey (DEK *dek, DEK **seskey, byte *enckey) +{ + gcry_cipher_hd_t hd; + byte buf[33]; + + assert ( dek->keylen <= 32 ); + if (!*seskey) + { + *seskey=xmalloc_clear(sizeof(DEK)); + (*seskey)->keylen=dek->keylen; + (*seskey)->algo=dek->algo; + make_session_key(*seskey); + /*log_hexdump( "thekey", c->key, c->keylen );*/ + } + + /* The encrypted session key is prefixed with a one-octet algorithm id. */ + buf[0] = (*seskey)->algo; + memcpy( buf + 1, (*seskey)->key, (*seskey)->keylen ); + + /* We only pass already checked values to the following fucntion, + thus we consider any failure as fatal. */ + if (openpgp_cipher_open (&hd, dek->algo, GCRY_CIPHER_MODE_CFB, 1)) + BUG (); + if (gcry_cipher_setkey (hd, dek->key, dek->keylen)) + BUG (); + gcry_cipher_setiv (hd, NULL, 0); + gcry_cipher_encrypt (hd, buf, (*seskey)->keylen + 1, NULL, 0); + gcry_cipher_close (hd); + + memcpy( enckey, buf, (*seskey)->keylen + 1 ); + wipememory( buf, sizeof buf ); /* burn key */ +} + + +/* We try very hard to use a MDC */ +static int +use_mdc(PK_LIST pk_list,int algo) +{ + /* RFC-1991 and 2440 don't have MDC */ + if(RFC1991 || RFC2440) + return 0; + + /* --force-mdc overrides --disable-mdc */ + if(opt.force_mdc) + return 1; + + if(opt.disable_mdc) + return 0; + + /* Do the keys really support MDC? */ + + if(select_mdc_from_pklist(pk_list)) + return 1; + + /* The keys don't support MDC, so now we do a bit of a hack - if any + of the AESes or TWOFISH are in the prefs, we assume that the user + can handle a MDC. This is valid for PGP 7, which can handle MDCs + though it will not generate them. 2440bis allows this, by the + way. */ + + if(select_algo_from_prefs(pk_list,PREFTYPE_SYM, + CIPHER_ALGO_AES,NULL)==CIPHER_ALGO_AES) + return 1; + + if(select_algo_from_prefs(pk_list,PREFTYPE_SYM, + CIPHER_ALGO_AES192,NULL)==CIPHER_ALGO_AES192) + return 1; + + if(select_algo_from_prefs(pk_list,PREFTYPE_SYM, + CIPHER_ALGO_AES256,NULL)==CIPHER_ALGO_AES256) + return 1; + + if(select_algo_from_prefs(pk_list,PREFTYPE_SYM, + CIPHER_ALGO_TWOFISH,NULL)==CIPHER_ALGO_TWOFISH) + return 1; + + /* Last try. Use MDC for the modern ciphers. */ + + if (openpgp_cipher_get_algo_blklen (algo) != 8) + return 1; + + if (opt.verbose) + warn_missing_mdc_from_pklist (pk_list); + + return 0; /* No MDC */ +} + + +/* We don't want to use use_seskey yet because older gnupg versions + can't handle it, and there isn't really any point unless we're + making a message that can be decrypted by a public key or + passphrase. */ +static int +encrypt_simple (const char *filename, int mode, int use_seskey) +{ + iobuf_t inp, out; + PACKET pkt; + PKT_plaintext *pt = NULL; + STRING2KEY *s2k = NULL; + byte enckey[33]; + int rc = 0; + int seskeylen = 0; + u32 filesize; + cipher_filter_context_t cfx; + armor_filter_context_t *afx = NULL; + compress_filter_context_t zfx; + text_filter_context_t tfx; + progress_filter_context_t *pfx; + int do_compress = !RFC1991 && default_compress_algo(); + + pfx = new_progress_context (); + memset( &cfx, 0, sizeof cfx); + memset( &zfx, 0, sizeof zfx); + memset( &tfx, 0, sizeof tfx); + init_packet(&pkt); + + /* Prepare iobufs. */ + inp = iobuf_open(filename); + if (inp) + iobuf_ioctl (inp,3,1,NULL); /* disable fd caching */ + if (inp && is_secured_file (iobuf_get_fd (inp))) + { + iobuf_close (inp); + inp = NULL; + errno = EPERM; + } + if (!inp) + { + rc = gpg_error_from_syserror (); + log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]", + strerror(errno) ); + release_progress_context (pfx); + return rc; + } + + handle_progress (pfx, inp, filename); + + if (opt.textmode) + iobuf_push_filter( inp, text_filter, &tfx ); + + /* Due the the fact that we use don't use an IV to encrypt the + session key we can't use the new mode with RFC1991 because it has + no S2K salt. RFC1991 always uses simple S2K. */ + if ( RFC1991 && use_seskey ) + use_seskey = 0; + + cfx.dek = NULL; + if ( mode ) + { + int canceled; + + s2k = xmalloc_clear( sizeof *s2k ); + s2k->mode = RFC1991? 0:opt.s2k_mode; + s2k->hash_algo = S2K_DIGEST_ALGO; + cfx.dek = passphrase_to_dek (NULL, 0, + default_cipher_algo(), s2k, 4, + NULL, &canceled); + if ( !cfx.dek || !cfx.dek->keylen ) + { + rc = gpg_error (canceled? GPG_ERR_CANCELED:GPG_ERR_INV_PASSPHRASE); + xfree (cfx.dek); + xfree (s2k); + iobuf_close (inp); + log_error (_("error creating passphrase: %s\n"), gpg_strerror (rc)); + release_progress_context (pfx); + return rc; + } + if (use_seskey && s2k->mode != 1 && s2k->mode != 3) + { + use_seskey = 0; + log_info (_("can't use a symmetric ESK packet " + "due to the S2K mode\n")); + } + + if ( use_seskey ) + { + DEK *dek = NULL; + + seskeylen = openpgp_cipher_get_algo_keylen (default_cipher_algo ()); + encrypt_seskey( cfx.dek, &dek, enckey ); + xfree( cfx.dek ); cfx.dek = dek; + } + + if (opt.verbose) + log_info(_("using cipher %s\n"), + openpgp_cipher_algo_name (cfx.dek->algo)); + + cfx.dek->use_mdc=use_mdc(NULL,cfx.dek->algo); + } + + if (do_compress && cfx.dek && cfx.dek->use_mdc + && is_file_compressed(filename, &rc)) + { + if (opt.verbose) + log_info(_("`%s' already compressed\n"), filename); + do_compress = 0; + } + + if ( rc || (rc = open_outfile( filename, opt.armor? 1:0, &out ))) + { + iobuf_cancel (inp); + xfree (cfx.dek); + xfree (s2k); + release_progress_context (pfx); + return rc; + } + + if ( opt.armor ) + { + afx = new_armor_context (); + push_armor_filter (afx, out); + } + + if ( s2k && !RFC1991 ) + { + PKT_symkey_enc *enc = xmalloc_clear( sizeof *enc + seskeylen + 1 ); + enc->version = 4; + enc->cipher_algo = cfx.dek->algo; + enc->s2k = *s2k; + if ( use_seskey && seskeylen ) + { + enc->seskeylen = seskeylen + 1; /* algo id */ + memcpy (enc->seskey, enckey, seskeylen + 1 ); + } + pkt.pkttype = PKT_SYMKEY_ENC; + pkt.pkt.symkey_enc = enc; + if ((rc = build_packet( out, &pkt ))) + log_error("build symkey packet failed: %s\n", g10_errstr(rc) ); + xfree (enc); + } + + if (!opt.no_literal) + pt = setup_plaintext_name (filename, inp); + + /* Note that PGP 5 has problems decrypting symmetrically encrypted + data if the file length is in the inner packet. It works when + only partial length headers are use. In the past, we always used + partial body length here, but since PGP 2, PGP 6, and PGP 7 need + the file length, and nobody should be using PGP 5 nowadays + anyway, this is now set to the file length. Note also that this + only applies to the RFC-1991 style symmetric messages, and not + the RFC-2440 style. PGP 6 and 7 work with either partial length + or fixed length with the new style messages. */ + + if ( !iobuf_is_pipe_filename (filename) && *filename && !opt.textmode ) + { + off_t tmpsize; + int overflow; + + if ( !(tmpsize = iobuf_get_filelength(inp, &overflow)) + && !overflow && opt.verbose) + log_info(_("WARNING: `%s' is an empty file\n"), filename ); + /* We can't encode the length of very large files because + OpenPGP uses only 32 bit for file sizes. So if the the + size of a file is larger than 2^32 minus some bytes for + packet headers, we switch to partial length encoding. */ + if ( tmpsize < (IOBUF_FILELENGTH_LIMIT - 65536) ) + filesize = tmpsize; + else + filesize = 0; + } + else + filesize = opt.set_filesize ? opt.set_filesize : 0; /* stdin */ + + if (!opt.no_literal) + { + pt->timestamp = make_timestamp(); + pt->mode = opt.textmode? 't' : 'b'; + pt->len = filesize; + pt->new_ctb = !pt->len && !RFC1991; + pt->buf = inp; + pkt.pkttype = PKT_PLAINTEXT; + pkt.pkt.plaintext = pt; + cfx.datalen = filesize && !do_compress ? calc_packet_length( &pkt ) : 0; + } + else + { + cfx.datalen = filesize && !do_compress ? filesize : 0; + pkt.pkttype = 0; + pkt.pkt.generic = NULL; + } + + /* Register the cipher filter. */ + if (mode) + iobuf_push_filter ( out, cipher_filter, &cfx ); + + /* Register the compress filter. */ + if ( do_compress ) + { + if (cfx.dek && cfx.dek->use_mdc) + zfx.new_ctb = 1; + push_compress_filter (out, &zfx, default_compress_algo()); + } + + /* Do the work. */ + if (!opt.no_literal) + { + if ( (rc = build_packet( out, &pkt )) ) + log_error("build_packet failed: %s\n", g10_errstr(rc) ); + } + else + { + /* User requested not to create a literal packet, so we copy the + plain data. */ + byte copy_buffer[4096]; + int bytes_copied; + while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) + if ( (rc=iobuf_write(out, copy_buffer, bytes_copied)) ) { + log_error ("copying input to output failed: %s\n", + gpg_strerror (rc) ); + break; + } + wipememory (copy_buffer, 4096); /* burn buffer */ + } + + /* Finish the stuff. */ + iobuf_close (inp); + if (rc) + iobuf_cancel(out); + else + { + iobuf_close (out); /* fixme: check returncode */ + if (mode) + write_status ( STATUS_END_ENCRYPTION ); + } + if (pt) + pt->buf = NULL; + free_packet (&pkt); + xfree (cfx.dek); + xfree (s2k); + release_armor_context (afx); + release_progress_context (pfx); + return rc; +} + + +int +setup_symkey (STRING2KEY **symkey_s2k,DEK **symkey_dek) +{ + int canceled; + + *symkey_s2k=xmalloc_clear(sizeof(STRING2KEY)); + (*symkey_s2k)->mode = opt.s2k_mode; + (*symkey_s2k)->hash_algo = S2K_DIGEST_ALGO; + + *symkey_dek=passphrase_to_dek(NULL,0,opt.s2k_cipher_algo, + *symkey_s2k, 4, NULL, &canceled); + if(!*symkey_dek || !(*symkey_dek)->keylen) + { + xfree(*symkey_dek); + xfree(*symkey_s2k); + return gpg_error (canceled?GPG_ERR_CANCELED:GPG_ERR_BAD_PASSPHRASE); + } + + return 0; +} + + +static int +write_symkey_enc (STRING2KEY *symkey_s2k, DEK *symkey_dek, DEK *dek, + iobuf_t out) +{ + int rc, seskeylen = openpgp_cipher_get_algo_keylen (dek->algo); + + PKT_symkey_enc *enc; + byte enckey[33]; + PACKET pkt; + + enc=xmalloc_clear(sizeof(PKT_symkey_enc)+seskeylen+1); + encrypt_seskey(symkey_dek,&dek,enckey); + + enc->version = 4; + enc->cipher_algo = opt.s2k_cipher_algo; + enc->s2k = *symkey_s2k; + enc->seskeylen = seskeylen + 1; /* algo id */ + memcpy( enc->seskey, enckey, seskeylen + 1 ); + + pkt.pkttype = PKT_SYMKEY_ENC; + pkt.pkt.symkey_enc = enc; + + if ((rc=build_packet(out,&pkt))) + log_error("build symkey_enc packet failed: %s\n",g10_errstr(rc)); + + xfree(enc); + return rc; +} + + +/* + * Encrypt the file with the given userids (or ask if none + * is supplied). + */ +int +encrypt_crypt (const char *filename, strlist_t remusr, int use_symkey) +{ + iobuf_t inp = NULL; + iobuf_t out = NULL; + PACKET pkt; + PKT_plaintext *pt = NULL; + DEK *symkey_dek = NULL; + STRING2KEY *symkey_s2k = NULL; + int rc = 0, rc2 = 0; + u32 filesize; + cipher_filter_context_t cfx; + armor_filter_context_t *afx = NULL; + compress_filter_context_t zfx; + text_filter_context_t tfx; + progress_filter_context_t *pfx; + PK_LIST pk_list, work_list; + int do_compress; + + do_compress = opt.compress_algo && !RFC1991; + + pfx = new_progress_context (); + memset( &cfx, 0, sizeof cfx); + memset( &zfx, 0, sizeof zfx); + memset( &tfx, 0, sizeof tfx); + init_packet(&pkt); + + if (use_symkey + && (rc=setup_symkey(&symkey_s2k,&symkey_dek))) + { + release_progress_context (pfx); + return rc; + } + + if ((rc = build_pk_list (remusr, &pk_list, PUBKEY_USAGE_ENC))) + { + release_progress_context (pfx); + return rc; + } + + if(PGP2) + { + for (work_list=pk_list; work_list; work_list=work_list->next) + if (!(is_RSA (work_list->pk->pubkey_algo) + && nbits_from_pk (work_list->pk) <= 2048)) + { + log_info(_("you can only encrypt to RSA keys of 2048 bits or " + "less in --pgp2 mode\n")); + compliance_failure(); + break; + } + } + + /* Prepare iobufs. */ + inp = iobuf_open(filename); + if (inp) + iobuf_ioctl (inp, 3, 1, NULL); /* Disable fd caching. */ + if (inp && is_secured_file (iobuf_get_fd (inp))) + { + iobuf_close (inp); + inp = NULL; + errno = EPERM; + } + if (!inp) + { + rc = gpg_error_from_syserror (); + log_error (_("can't open `%s': %s\n"), + filename? filename: "[stdin]", gpg_strerror (rc) ); + goto leave; + } + else if (opt.verbose) + log_info (_("reading from `%s'\n"), filename? filename: "[stdin]"); + + handle_progress (pfx, inp, filename); + + if (opt.textmode) + iobuf_push_filter (inp, text_filter, &tfx); + + if ((rc = open_outfile( filename, opt.armor? 1:0, &out ))) + goto leave; + + if (opt.armor) + { + afx = new_armor_context (); + push_armor_filter (afx, out); + } + + /* Create a session key. */ + cfx.dek = xmalloc_secure_clear (sizeof *cfx.dek); + if (!opt.def_cipher_algo) + { + /* Try to get it from the prefs. */ + cfx.dek->algo = select_algo_from_prefs (pk_list, PREFTYPE_SYM, -1, NULL); + /* The only way select_algo_from_prefs can fail here is when + mixing v3 and v4 keys, as v4 keys have an implicit preference + entry for 3DES, and the pk_list cannot be empty. In this + case, use 3DES anyway as it's the safest choice - perhaps the + v3 key is being used in an OpenPGP implementation and we know + that the implementation behind any v4 key can handle 3DES. */ + if (cfx.dek->algo == -1) + { + cfx.dek->algo = CIPHER_ALGO_3DES; + + if (PGP2) + { + log_info(_("unable to use the IDEA cipher for all of the keys " + "you are encrypting to.\n")); + compliance_failure(); + } + } + + /* In case 3DES has been selected, print a warning if any key + does not have a preference for AES. This should help to + indentify why encrypting to several recipients falls back to + 3DES. */ + if (opt.verbose && cfx.dek->algo == CIPHER_ALGO_3DES) + warn_missing_aes_from_pklist (pk_list); + } + else + { + if (!opt.expert + && (select_algo_from_prefs (pk_list, PREFTYPE_SYM, + opt.def_cipher_algo, NULL) + != opt.def_cipher_algo)) + { + log_info(_("WARNING: forcing symmetric cipher %s (%d)" + " violates recipient preferences\n"), + openpgp_cipher_algo_name (opt.def_cipher_algo), + opt.def_cipher_algo); + } + + cfx.dek->algo = opt.def_cipher_algo; + } + + cfx.dek->use_mdc = use_mdc (pk_list,cfx.dek->algo); + + /* Only do the is-file-already-compressed check if we are using a + MDC. This forces compressed files to be re-compressed if we do + not have a MDC to give some protection against chosen ciphertext + attacks. */ + + if (do_compress && cfx.dek->use_mdc && is_file_compressed(filename, &rc2)) + { + if (opt.verbose) + log_info(_("`%s' already compressed\n"), filename); + do_compress = 0; + } + if (rc2) + { + rc = rc2; + goto leave; + } + + make_session_key (cfx.dek); + if (DBG_CIPHER) + log_printhex ("DEK is: ", cfx.dek->key, cfx.dek->keylen ); + + rc = write_pubkey_enc_from_list (pk_list, cfx.dek, out); + if (rc) + goto leave; + + /* We put the passphrase (if any) after any public keys as this + seems to be the most useful on the recipient side - there is no + point in prompting a user for a passphrase if they have the + secret key needed to decrypt. */ + if(use_symkey && (rc = write_symkey_enc(symkey_s2k,symkey_dek,cfx.dek,out))) + goto leave; + + if (!opt.no_literal) + pt = setup_plaintext_name (filename, inp); + + if (!iobuf_is_pipe_filename (filename) && *filename && !opt.textmode ) + { + off_t tmpsize; + int overflow; + + if ( !(tmpsize = iobuf_get_filelength(inp, &overflow)) + && !overflow && opt.verbose) + log_info(_("WARNING: `%s' is an empty file\n"), filename ); + /* We can't encode the length of very large files because + OpenPGP uses only 32 bit for file sizes. So if the the size + of a file is larger than 2^32 minus some bytes for packet + headers, we switch to partial length encoding. */ + if (tmpsize < (IOBUF_FILELENGTH_LIMIT - 65536) ) + filesize = tmpsize; + else + filesize = 0; + } + else + filesize = opt.set_filesize ? opt.set_filesize : 0; /* stdin */ + + if (!opt.no_literal) + { + pt->timestamp = make_timestamp(); + pt->mode = opt.textmode ? 't' : 'b'; + pt->len = filesize; + pt->new_ctb = !pt->len && !RFC1991; + pt->buf = inp; + pkt.pkttype = PKT_PLAINTEXT; + pkt.pkt.plaintext = pt; + cfx.datalen = filesize && !do_compress? calc_packet_length( &pkt ) : 0; + } + else + cfx.datalen = filesize && !do_compress ? filesize : 0; + + /* Register the cipher filter. */ + iobuf_push_filter (out, cipher_filter, &cfx); + + /* Register the compress filter. */ + if (do_compress) + { + int compr_algo = opt.compress_algo; + + if (compr_algo == -1) + { + compr_algo = select_algo_from_prefs (pk_list, PREFTYPE_ZIP, -1, NULL); + if (compr_algo == -1) + compr_algo = DEFAULT_COMPRESS_ALGO; + /* Theoretically impossible to get here since uncompressed + is implicit. */ + } + else if (!opt.expert + && select_algo_from_prefs(pk_list, PREFTYPE_ZIP, + compr_algo, NULL) != compr_algo) + { + log_info (_("WARNING: forcing compression algorithm %s (%d)" + " violates recipient preferences\n"), + compress_algo_to_string(compr_algo), compr_algo); + } + + /* Algo 0 means no compression. */ + if (compr_algo) + { + if (cfx.dek && cfx.dek->use_mdc) + zfx.new_ctb = 1; + push_compress_filter (out,&zfx,compr_algo); + } + } + + /* Do the work. */ + if (!opt.no_literal) + { + if ((rc = build_packet( out, &pkt ))) + log_error ("build_packet failed: %s\n", g10_errstr(rc)); + } + else + { + /* User requested not to create a literal packet, so we copy the + plain data. */ + byte copy_buffer[4096]; + int bytes_copied; + while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) + if ((rc=iobuf_write(out, copy_buffer, bytes_copied))) + { + log_error ("copying input to output failed: %s\n", + gpg_strerror (rc)); + break; + } + wipememory (copy_buffer, 4096); /* Burn the buffer. */ + } + + /* Finish the stuff. */ + leave: + iobuf_close (inp); + if (rc) + iobuf_cancel (out); + else + { + iobuf_close (out); /* fixme: check returncode */ + write_status (STATUS_END_ENCRYPTION); + } + if (pt) + pt->buf = NULL; + free_packet (&pkt); + xfree (cfx.dek); + xfree (symkey_dek); + xfree (symkey_s2k); + release_pk_list (pk_list); + release_armor_context (afx); + release_progress_context (pfx); + return rc; +} + + +/* + * Filter to do a complete public key encryption. + */ +int +encrypt_filter (void *opaque, int control, + iobuf_t a, byte *buf, size_t *ret_len) +{ + size_t size = *ret_len; + encrypt_filter_context_t *efx = opaque; + int rc = 0; + + if (control == IOBUFCTRL_UNDERFLOW) /* decrypt */ + { + BUG(); /* not used */ + } + else if ( control == IOBUFCTRL_FLUSH ) /* encrypt */ + { + if ( !efx->header_okay ) + { + efx->cfx.dek = xmalloc_secure_clear ( sizeof *efx->cfx.dek ); + if ( !opt.def_cipher_algo ) + { + /* Try to get it from the prefs. */ + efx->cfx.dek->algo = + select_algo_from_prefs (efx->pk_list, PREFTYPE_SYM, -1, NULL); + if (efx->cfx.dek->algo == -1 ) + { + /* Because 3DES is implicitly in the prefs, this can + only happen if we do not have any public keys in + the list. */ + efx->cfx.dek->algo = DEFAULT_CIPHER_ALGO; + } + + /* In case 3DES has been selected, print a warning if + any key does not have a preference for AES. This + should help to indentify why encrypting to several + recipients falls back to 3DES. */ + if (opt.verbose + && efx->cfx.dek->algo == CIPHER_ALGO_3DES) + warn_missing_aes_from_pklist (efx->pk_list); + } + else + { + if (!opt.expert + && select_algo_from_prefs (efx->pk_list,PREFTYPE_SYM, + opt.def_cipher_algo, + NULL) != opt.def_cipher_algo) + log_info(_("forcing symmetric cipher %s (%d) " + "violates recipient preferences\n"), + openpgp_cipher_algo_name (opt.def_cipher_algo), + opt.def_cipher_algo); + + efx->cfx.dek->algo = opt.def_cipher_algo; + } + + efx->cfx.dek->use_mdc = use_mdc (efx->pk_list,efx->cfx.dek->algo); + + make_session_key ( efx->cfx.dek ); + if (DBG_CIPHER) + log_printhex ("DEK is: ", efx->cfx.dek->key, efx->cfx.dek->keylen); + + rc = write_pubkey_enc_from_list (efx->pk_list, efx->cfx.dek, a); + if (rc) + return rc; + + if(efx->symkey_s2k && efx->symkey_dek) + { + rc=write_symkey_enc(efx->symkey_s2k,efx->symkey_dek, + efx->cfx.dek,a); + if(rc) + return rc; + } + + iobuf_push_filter (a, cipher_filter, &efx->cfx); + + efx->header_okay = 1; + } + rc = iobuf_write (a, buf, size); + + } + else if (control == IOBUFCTRL_FREE) + { + xfree (efx->symkey_dek); + xfree (efx->symkey_s2k); + } + else if ( control == IOBUFCTRL_DESC ) + { + *(char**)buf = "encrypt_filter"; + } + return rc; +} + + +/* + * Write pubkey-enc packets from the list of PKs to OUT. + */ +static int +write_pubkey_enc_from_list (PK_LIST pk_list, DEK *dek, iobuf_t out) +{ + PACKET pkt; + PKT_public_key *pk; + PKT_pubkey_enc *enc; + int rc; + + for ( ; pk_list; pk_list = pk_list->next ) + { + gcry_mpi_t frame; + + pk = pk_list->pk; + + print_pubkey_algo_note ( pk->pubkey_algo ); + enc = xmalloc_clear ( sizeof *enc ); + enc->pubkey_algo = pk->pubkey_algo; + keyid_from_pk( pk, enc->keyid ); + enc->throw_keyid = (opt.throw_keyid || (pk_list->flags&1)); + + if (opt.throw_keyid && (PGP2 || PGP6 || PGP7 || PGP8)) + { + log_info(_("you may not use %s while in %s mode\n"), + "--throw-keyid",compliance_option_string()); + compliance_failure(); + } + + /* Okay, what's going on: We have the session key somewhere in + * the structure DEK and want to encode this session key in an + * integer value of n bits. pubkey_nbits gives us the number of + * bits we have to use. We then encode the session key in some + * way and we get it back in the big intger value FRAME. Then + * we use FRAME, the public key PK->PKEY and the algorithm + * number PK->PUBKEY_ALGO and pass it to pubkey_encrypt which + * returns the encrypted value in the array ENC->DATA. This + * array has a size which depends on the used algorithm (e.g. 2 + * for Elgamal). We don't need frame anymore because we have + * everything now in enc->data which is the passed to + * build_packet(). */ + frame = encode_session_key (dek, + pubkey_nbits (pk->pubkey_algo, pk->pkey)); + rc = pk_encrypt (pk->pubkey_algo, enc->data, frame, pk->pkey); + gcry_mpi_release (frame); + if (rc) + log_error ("pubkey_encrypt failed: %s\n", gpg_strerror (rc) ); + else + { + if ( opt.verbose ) + { + char *ustr = get_user_id_string_native (enc->keyid); + log_info (_("%s/%s encrypted for: \"%s\"\n"), + gcry_pk_algo_name (enc->pubkey_algo), + openpgp_cipher_algo_name (dek->algo), + ustr ); + xfree (ustr); + } + /* And write it. */ + init_packet (&pkt); + pkt.pkttype = PKT_PUBKEY_ENC; + pkt.pkt.pubkey_enc = enc; + rc = build_packet (out, &pkt); + if (rc) + log_error ("build_packet(pubkey_enc) failed: %s\n", + g10_errstr (rc)); + } + free_pubkey_enc(enc); + if (rc) + return rc; + } + return 0; +} + + +void +encrypt_crypt_files (int nfiles, char **files, strlist_t remusr) +{ + int rc = 0; + + if (opt.outfile) + { + log_error(_("--output doesn't work for this command\n")); + return; + } + + if (!nfiles) + { + char line[2048]; + unsigned int lno = 0; + while ( fgets(line, DIM(line), stdin) ) + { + lno++; + if (!*line || line[strlen(line)-1] != '\n') + { + log_error("input line %u too long or missing LF\n", lno); + return; + } + line[strlen(line)-1] = '\0'; + print_file_status(STATUS_FILE_START, line, 2); + if ( (rc = encrypt_crypt(line, remusr, 0)) ) + log_error("encryption of `%s' failed: %s\n", + print_fname_stdin(line), g10_errstr(rc) ); + write_status( STATUS_FILE_DONE ); + } + } + else + { + while (nfiles--) + { + print_file_status(STATUS_FILE_START, *files, 2); + if ( (rc = encrypt_crypt(*files, remusr, 0)) ) + log_error("encryption of `%s' failed: %s\n", + print_fname_stdin(*files), g10_errstr(rc) ); + write_status( STATUS_FILE_DONE ); + files++; + } + } +} Property changes on: trunk/g10/encrypt.c ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:mergeinfo + Name: svn:eol-style + native Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2009-09-25 17:09:31 UTC (rev 5163) +++ trunk/g10/gpg.c 2009-09-28 14:37:48 UTC (rev 5164) @@ -2059,9 +2059,9 @@ malloc_hooks.realloc = gcry_realloc; malloc_hooks.free = gcry_free; assuan_set_malloc_hooks (&malloc_hooks); + assuan_set_assuan_log_prefix (log_get_prefix (NULL)); assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); - /* Try for a version specific config file first */ default_configname = get_default_configname (); if (default_config) @@ -3418,26 +3418,26 @@ case aStore: /* only store the file */ if( argc > 1 ) wrong_args(_("--store [filename]")); - if( (rc = encode_store(fname)) ) + if( (rc = encrypt_store(fname)) ) log_error ("storing `%s' failed: %s\n", print_fname_stdin(fname),g10_errstr(rc) ); break; case aSym: /* encrypt the given file only with the symmetric cipher */ if( argc > 1 ) wrong_args(_("--symmetric [filename]")); - if( (rc = encode_symmetric(fname)) ) + if( (rc = encrypt_symmetric(fname)) ) log_error (_("symmetric encryption of `%s' failed: %s\n"), print_fname_stdin(fname),g10_errstr(rc) ); break; case aEncr: /* encrypt the given file */ if(multifile) - encode_crypt_files(argc, argv, remusr); + encrypt_crypt_files(argc, argv, remusr); else { if( argc > 1 ) wrong_args(_("--encrypt [filename]")); - if( (rc = encode_crypt(fname,remusr,0)) ) + if( (rc = encrypt_crypt(fname,remusr,0)) ) log_error("%s: encryption failed: %s\n", print_fname_stdin(fname), g10_errstr(rc) ); } @@ -3458,7 +3458,7 @@ " while in %s mode\n"),compliance_option_string()); else { - if( (rc = encode_crypt(fname,remusr,1)) ) + if( (rc = encrypt_crypt(fname,remusr,1)) ) log_error("%s: encryption failed: %s\n", print_fname_stdin(fname), g10_errstr(rc) ); } Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2009-09-25 17:09:31 UTC (rev 5163) +++ trunk/g10/main.h 2009-09-28 14:37:48 UTC (rev 5164) @@ -182,12 +182,12 @@ void display_online_help( const char *keyword ); /*-- encode.c --*/ -int setup_symkey(STRING2KEY **symkey_s2k,DEK **symkey_dek); -int encode_symmetric( const char *filename ); -int encode_store( const char *filename ); -int encode_crypt( const char *filename, strlist_t remusr, int use_symkey ); -void encode_crypt_files(int nfiles, char **files, strlist_t remusr); -int encrypt_filter( void *opaque, int control, +int setup_symkey (STRING2KEY **symkey_s2k,DEK **symkey_dek); +int encrypt_symmetric (const char *filename ); +int encrypt_store (const char *filename ); +int encrypt_crypt (const char *filename, strlist_t remusr, int use_symkey ); +void encrypt_crypt_files (int nfiles, char **files, strlist_t remusr); +int encrypt_filter (void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len); Modified: trunk/g10/pkglue.c =================================================================== --- trunk/g10/pkglue.c 2009-09-25 17:09:31 UTC (rev 5163) +++ trunk/g10/pkglue.c 2009-09-28 14:37:48 UTC (rev 5164) @@ -61,7 +61,7 @@ "(private-key(dsa(p%m)(q%m)(g%m)(y%m)(x%m)))", skey[0], skey[1], skey[2], skey[3], skey[4]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_S) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", @@ -90,7 +90,7 @@ if (rc) ; - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_S) data[0] = mpi_from_sexp (s_sig, "s"); else { @@ -125,7 +125,7 @@ "(public-key(elg(p%m)(g%m)(y%m)))", pkey[0], pkey[1], pkey[2]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_S) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(rsa(n%m)(e%m)))", pkey[0], pkey[1]); @@ -158,7 +158,7 @@ rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(elg(r%m)(s%m)))", data[0], data[1]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_S) { if (!data[0]) rc = gpg_error (GPG_ERR_BAD_MPI); @@ -197,7 +197,7 @@ "(public-key(elg(p%m)(g%m)(y%m)))", pkey[0], pkey[1], pkey[2]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_E) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(rsa(n%m)(e%m)))", @@ -223,7 +223,7 @@ else { /* add better error handling or make gnupg use S-Exp directly */ resarr[0] = mpi_from_sexp (s_ciph, "a"); - if (algo != GCRY_PK_RSA) + if (algo != GCRY_PK_RSA && algo != GCRY_PK_RSA_E) resarr[1] = mpi_from_sexp (s_ciph, "b"); } @@ -252,7 +252,7 @@ "(private-key(elg(p%m)(g%m)(y%m)(x%m)))", skey[0], skey[1], skey[2], skey[3]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_E) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", @@ -274,7 +274,7 @@ rc = gcry_sexp_build (&s_data, NULL, "(enc-val(elg(a%m)(b%m)))", data[0], data[1]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_E) { if (!data[0]) rc = gpg_error (GPG_ERR_BAD_MPI); @@ -321,7 +321,8 @@ "(private-key(elg(p%m)(g%m)(y%m)(x%m)))", skey[0], skey[1], skey[2], skey[3]); } - else if (algo == GCRY_PK_RSA) + else if (algo == GCRY_PK_RSA + || algo == GCRY_PK_RSA_S || algo == GCRY_PK_RSA_E) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", Modified: trunk/g10/server.c =================================================================== --- trunk/g10/server.c 2009-09-25 17:09:31 UTC (rev 5163) +++ trunk/g10/server.c 2009-09-28 14:37:48 UTC (rev 5164) @@ -540,18 +540,18 @@ char *tmp = NULL; const char *s1 = getenv ("GPG_AGENT_INFO"); - if (asprintf (&tmp, - "Home: %s\n" - "Config: %s\n" - "AgentInfo: %s\n" - "%s", - opt.homedir, - "fixme: need config filename", - s1?s1:"[not set]", - hello) > 0) + tmp = xtryasprintf ("Home: %s\n" + "Config: %s\n" + "AgentInfo: %s\n" + "%s", + opt.homedir, + "fixme: need config filename", + s1?s1:"[not set]", + hello); + if (tmp) { assuan_set_hello_line (ctx, tmp); - free (tmp); + xfree (tmp); } } else Modified: trunk/g10/trustdb.c =================================================================== --- trunk/g10/trustdb.c 2009-09-25 17:09:31 UTC (rev 5163) +++ trunk/g10/trustdb.c 2009-09-28 14:37:48 UTC (rev 5164) @@ -1176,12 +1176,15 @@ int get_validity_info (PKT_public_key *pk, PKT_user_id *uid) { - int trustlevel; - - trustlevel = get_validity (pk, uid); - if( trustlevel & TRUST_FLAG_REVOKED ) - return 'r'; - return trust_letter ( trustlevel ); + int trustlevel; + + if (!pk) + return '?'; /* Just in case a NULL PK is passed. */ + + trustlevel = get_validity (pk, uid); + if ( (trustlevel & TRUST_FLAG_REVOKED) ) + return 'r'; + return trust_letter (trustlevel); } const char * @@ -1189,6 +1192,9 @@ { int trustlevel; + if (!pk) + return "err"; /* Just in case a NULL PK is passed. */ + trustlevel = get_validity (pk, uid); if( trustlevel & TRUST_FLAG_REVOKED ) return _("revoked"); From cvs at cvs.gnupg.org Mon Sep 28 19:11:11 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 28 Sep 2009 19:11:11 +0200 Subject: [svn] GnuPG - r5165 - branches/STABLE-BRANCH-2-0/g10 Message-ID: Author: wk Date: 2009-09-28 19:11:10 +0200 (Mon, 28 Sep 2009) New Revision: 5165 Modified: branches/STABLE-BRANCH-2-0/g10/ChangeLog branches/STABLE-BRANCH-2-0/g10/trustdb.c Log: Fix bug#1138. Modified: branches/STABLE-BRANCH-2-0/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-2-0/g10/ChangeLog 2009-09-28 14:37:48 UTC (rev 5164) +++ branches/STABLE-BRANCH-2-0/g10/ChangeLog 2009-09-28 17:11:10 UTC (rev 5165) @@ -1,3 +1,9 @@ +2009-09-28 Werner Koch + + * trustdb.c (get_validity_info): Take care of a NULL PK. Fixes + bug#1138. + (get_validity_string): Ditto. + 2009-09-25 Werner Koch * pkglue.c (pk_sign, pk_verify, pk_encrypt, pk_decrypt) Modified: branches/STABLE-BRANCH-2-0/g10/trustdb.c =================================================================== --- branches/STABLE-BRANCH-2-0/g10/trustdb.c 2009-09-28 14:37:48 UTC (rev 5164) +++ branches/STABLE-BRANCH-2-0/g10/trustdb.c 2009-09-28 17:11:10 UTC (rev 5165) @@ -1176,12 +1176,15 @@ int get_validity_info (PKT_public_key *pk, PKT_user_id *uid) { - int trustlevel; - - trustlevel = get_validity (pk, uid); - if( trustlevel & TRUST_FLAG_REVOKED ) - return 'r'; - return trust_letter ( trustlevel ); + int trustlevel; + + if (!pk) + return '?'; /* Just in case a NULL PK is passed. */ + + trustlevel = get_validity (pk, uid); + if ( (trustlevel & TRUST_FLAG_REVOKED) ) + return 'r'; + return trust_letter (trustlevel); } const char * @@ -1189,6 +1192,9 @@ { int trustlevel; + if (!pk) + return "err"; /* Just in case a NULL PK is passed. */ + trustlevel = get_validity (pk, uid); if( trustlevel & TRUST_FLAG_REVOKED ) return _("revoked"); From cvs at cvs.gnupg.org Mon Sep 28 19:11:33 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 28 Sep 2009 19:11:33 +0200 Subject: [svn] GnuPG - r5166 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: wk Date: 2009-09-28 19:11:32 +0200 (Mon, 28 Sep 2009) New Revision: 5166 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/photoid.c branches/STABLE-BRANCH-1-4/g10/trustdb.c Log: Fix bug#1138. Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2009-09-28 17:11:10 UTC (rev 5165) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2009-09-28 17:11:32 UTC (rev 5166) @@ -1,3 +1,9 @@ +2009-09-28 Werner Koch + + * trustdb.c (get_validity_info): Take care of a NULL PK. Fixes + bug#1138. + (get_validity_string): Ditto. + 2009-09-02 Werner Koch * app-openpgp.c (do_decipher): Compute required Le. @@ -108,7 +114,7 @@ TIMESTAMP. (write_direct_sig, write_selfsigs, write_keybinding) (make_backsig): Ditto. - (do_generate_keypair): Pass timestamp to all signing functions. + (do_generate_keypair): Pass timestamp to all signing functions. (generate_card_subkeypair): Ditto. * keyedit.c (menu_backsign): Pass a new timestamp to all backsisg. Modified: branches/STABLE-BRANCH-1-4/g10/photoid.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/photoid.c 2009-09-28 17:11:10 UTC (rev 5165) +++ branches/STABLE-BRANCH-1-4/g10/photoid.c 2009-09-28 17:11:32 UTC (rev 5166) @@ -194,7 +194,8 @@ } /* Returns 0 for error, 1 for valid */ -int parse_image_header(const struct user_attribute *attr,byte *type,u32 *len) +int +parse_image_header(const struct user_attribute *attr,byte *type,u32 *len) { u16 headerlen; @@ -229,7 +230,8 @@ make sure it is not too big (see parse-packet.c:parse_attribute). Extensions should be 3 characters long for the best cross-platform compatibility. */ -char *image_type_to_string(byte type,int style) +char * +image_type_to_string(byte type,int style) { char *string; Modified: branches/STABLE-BRANCH-1-4/g10/trustdb.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/trustdb.c 2009-09-28 17:11:10 UTC (rev 5165) +++ branches/STABLE-BRANCH-1-4/g10/trustdb.c 2009-09-28 17:11:32 UTC (rev 5166) @@ -1182,6 +1182,9 @@ { int trustlevel; + if (!pk) + return '?'; /* Just in case a NULL PK is passed. */ + trustlevel = get_validity (pk, uid); if( trustlevel & TRUST_FLAG_REVOKED ) return 'r'; @@ -1193,6 +1196,9 @@ { int trustlevel; + if (!pk) + return "err"; /* Just in case a NULL PK is passed. */ + trustlevel = get_validity (pk, uid); if( trustlevel & TRUST_FLAG_REVOKED ) return _("revoked"); From cvs at cvs.gnupg.org Tue Sep 29 15:48:15 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 29 Sep 2009 15:48:15 +0200 Subject: [svn] assuan - r304 - trunk/src Message-ID: Author: wk Date: 2009-09-29 15:48:15 +0200 (Tue, 29 Sep 2009) New Revision: 304 Modified: trunk/src/ChangeLog trunk/src/assuan.c Log: Allow apssing NULL to assuan_release. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-09-21 01:08:08 UTC (rev 303) +++ trunk/src/ChangeLog 2009-09-29 13:48:15 UTC (rev 304) @@ -1,3 +1,7 @@ +2009-09-29 Werner Koch + + * assuan.c (assuan_release): Allow passing a NULL ctx. + 2009-09-19 Marcus Brinkmann * src/libassuan.vers, src/libassuan.def: Update to new API. Modified: trunk/src/assuan.c =================================================================== --- trunk/src/assuan.c 2009-09-21 01:08:08 UTC (rev 303) +++ trunk/src/assuan.c 2009-09-29 13:48:15 UTC (rev 304) @@ -168,10 +168,13 @@ void assuan_release (assuan_context_t ctx) { - TRACE (ctx, ASSUAN_LOG_CTX, "assuan_release", ctx); - - _assuan_reset (ctx); - /* None of the members that are our responsibility requires - deallocation. */ - _assuan_free (ctx, ctx); + if (ctx) + { + TRACE (ctx, ASSUAN_LOG_CTX, "assuan_release", ctx); + + _assuan_reset (ctx); + /* None of the members that are our responsibility requires + deallocation. */ + _assuan_free (ctx, ctx); + } } From cvs at cvs.gnupg.org Tue Sep 29 21:13:26 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 29 Sep 2009 21:13:26 +0200 Subject: [svn] assuan - r305 - trunk/src Message-ID: Author: wk Date: 2009-09-29 21:13:26 +0200 (Tue, 29 Sep 2009) New Revision: 305 Modified: trunk/src/ChangeLog trunk/src/assuan.h Log: Comment fix. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-09-29 13:48:15 UTC (rev 304) +++ trunk/src/ChangeLog 2009-09-29 19:13:26 UTC (rev 305) @@ -1,5 +1,7 @@ 2009-09-29 Werner Koch + * assuan.h: Comment fix. + * assuan.c (assuan_release): Allow passing a NULL ctx. 2009-09-19 Marcus Brinkmann Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-09-29 13:48:15 UTC (rev 304) +++ trunk/src/assuan.h 2009-09-29 19:13:26 UTC (rev 305) @@ -218,10 +218,10 @@ int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag); -/* Same as assuan_set_flag (ctx, ASSUAN_NO_WAITPID, 1). */ +/* Same as assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 1). */ void assuan_begin_confidential (assuan_context_t ctx); -/* Same as assuan_set_flag (ctx, ASSUAN_NO_WAITPID, 0). */ +/* Same as assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 0). */ void assuan_end_confidential (assuan_context_t ctx); From cvs at cvs.gnupg.org Wed Sep 30 17:28:40 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 30 Sep 2009 17:28:40 +0200 Subject: [svn] GnuPG - r5167 - in trunk: common g10 g13 sm Message-ID: Author: wk Date: 2009-09-30 17:28:38 +0200 (Wed, 30 Sep 2009) New Revision: 5167 Added: trunk/g13/backend.c trunk/g13/backend.h trunk/g13/be-encfs.c trunk/g13/be-encfs.h trunk/g13/be-truecrypt.c trunk/g13/be-truecrypt.h trunk/g13/call-gpg.c trunk/g13/call-gpg.h trunk/g13/create.c trunk/g13/keyblob.h trunk/g13/utils.c trunk/g13/utils.h Modified: trunk/common/ChangeLog trunk/common/audit.h trunk/common/exechelp.c trunk/common/exechelp.h trunk/common/iobuf.c trunk/common/iobuf.h trunk/g10/ChangeLog trunk/g10/compress.c trunk/g10/dearmor.c trunk/g10/encrypt.c trunk/g10/export.c trunk/g10/gpg.c trunk/g10/keydb.h trunk/g10/main.h trunk/g10/openfile.c trunk/g10/parse-packet.c trunk/g10/pkclist.c trunk/g10/revoke.c trunk/g10/server.c trunk/g10/sign.c trunk/g13/Makefile.am trunk/g13/g13.c trunk/g13/g13.h trunk/sm/ChangeLog trunk/sm/gpgsm.c Log: Some changes to suport g13. [The diff below has been truncated] Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/common/ChangeLog 2009-09-30 15:28:38 UTC (rev 5167) @@ -1,3 +1,15 @@ +2009-09-29 Werner Koch + + * exechelp.c (create_inheritable_pipe): Rename to + create_inheritable_pipe_w. + (create_inheritable_pipe_r): New. + (gnupg_create_outbound_pipe): New. + + * iobuf.h: Include "sysutils.h" + + * iobuf.c (iobuf_open_fd_or_name): New. + (iobuf_get_fname_nonnull): New. + 2009-09-23 Marcus Brinkmann * asshelp.c (start_new_gpg_agent): Allocate assuan context before Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/ChangeLog 2009-09-30 15:28:38 UTC (rev 5167) @@ -1,5 +1,33 @@ +2009-09-30 Werner Koch + + * parse-packet.c (skip_packet, parse_gpg_control) : Take + care of premature EOFs. + + * gpg.c (main): Remove obsolete GCRYCTL_DISABLE_INTERNAL_LOCKING. + +2009-09-29 Werner Koch + + * openfile.c (open_outfile): Re-indent. Use xstrconcat. + (NAME_OF_DEV_NULL): New. + (open_outfile): Use it. + (overwrite_filep): Use it. Also use case insensitive compare + when needed. Re-indent. + (open_outfile): Add arg INP_FD. Change all callers. + + * encrypt.c (encrypt_crypt): Add new args FILEFD, OUTPUTFD and + PROVIDED_KEYS. Change all callers. + 2009-09-28 Werner Koch + * server.c (skip_options, has_option): New. + (cmd_recipient): Implement. + + * keydb.h (pk_list_t): New. + + * pkclist.c (send_status_inv_recp): New. Replace direct calls. + (build_pk_list): Factor some code out to ... + (find_and_check_key): ... new. + * encode.c: Rename to encrypt.c. Re-indent all. * encrypt.c (encode_symmetric, encode_store, encode_seskey) (encode_simple, encode_crypt, encode_filter) Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/sm/ChangeLog 2009-09-30 15:28:38 UTC (rev 5167) @@ -1,3 +1,7 @@ +2009-09-30 Werner Koch + + * gpgsm.c (main): Remove obsolete GCRYCTL_DISABLE_INTERNAL_LOCKING. + 2009-09-23 Marcus Brinkmann * gpgsm.c (main): Update to new assuan API. Modified: trunk/common/audit.h =================================================================== --- trunk/common/audit.h 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/common/audit.h 2009-09-30 15:28:38 UTC (rev 5167) @@ -62,6 +62,15 @@ operations the Dirmngr is not required and thus no such event will be logged. */ + AUDIT_GPG_READY, /* err */ + /* Indicates whether the Gpg engine is available. */ + + AUDIT_GPGSM_READY, /* err */ + /* Indicates whether the Gpgsm engine is available. */ + + AUDIT_G13_READY, /* err */ + /* Indicates whether the G13 engine is available. */ + AUDIT_GOT_DATA, /* Data to be processed has been seen. */ Modified: trunk/common/exechelp.c =================================================================== --- trunk/common/exechelp.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/common/exechelp.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -304,7 +304,7 @@ #ifdef HAVE_W32_SYSTEM /* Create pipe where the write end is inheritable. */ static int -create_inheritable_pipe (int filedes[2]) +create_inheritable_pipe_w (int filedes[2]) { HANDLE r, w, h; SECURITY_ATTRIBUTES sec_attr; @@ -332,6 +332,37 @@ filedes[1] = handle_to_fd (w); return 0; } + +/* Create pipe where the read end is inheritable. */ +static int +create_inheritable_pipe_r (int filedes[2]) +{ + HANDLE r, w, h; + SECURITY_ATTRIBUTES sec_attr; + + memset (&sec_attr, 0, sizeof sec_attr ); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + if (!CreatePipe (&r, &w, &sec_attr, 0)) + return -1; + + if (!DuplicateHandle (GetCurrentProcess(), r, + GetCurrentProcess(), &h, 0, + TRUE, DUPLICATE_SAME_ACCESS )) + { + log_error ("DuplicateHandle failed: %s\n", w32_strerror (-1)); + CloseHandle (r); + CloseHandle (w); + return -1; + } + CloseHandle (r); + r = h; + + filedes[0] = handle_to_fd (r); + filedes[1] = handle_to_fd (w); + return 0; +} #endif /*HAVE_W32_SYSTEM*/ @@ -425,7 +456,7 @@ filedes[0] = filedes[1] = -1; err = gpg_error (GPG_ERR_GENERAL); - if (!create_inheritable_pipe (fds)) + if (!create_inheritable_pipe_w (fds)) { filedes[0] = _open_osfhandle (fds[0], 0); if (filedes[0] == -1) @@ -458,6 +489,50 @@ } +/* Portable function to create a pipe. Under Windows the read end is + inheritable. */ +gpg_error_t +gnupg_create_outbound_pipe (int filedes[2]) +{ + gpg_error_t err = 0; +#if HAVE_W32_SYSTEM + int fds[2]; + + filedes[0] = filedes[1] = -1; + err = gpg_error (GPG_ERR_GENERAL); + if (!create_inheritable_pipe_r (fds)) + { + filedes[0] = _open_osfhandle (fds[0], 0); + if (filedes[0] == -1) + { + log_error ("failed to translate osfhandle %p\n", (void*)fds[0]); + CloseHandle (fd_to_handle (fds[1])); + } + else + { + filedes[1] = _open_osfhandle (fds[1], 1); + if (filedes[1] == -1) + { + log_error ("failed to translate osfhandle %p\n", (void*)fds[1]); + close (filedes[0]); + filedes[0] = -1; + CloseHandle (fd_to_handle (fds[1])); + } + else + err = 0; + } + } +#else + if (pipe (filedes) == -1) + { + err = gpg_error_from_syserror (); + filedes[0] = filedes[1] = -1; + } +#endif + return err; +} + + /* Fork and exec the PGMNAME, connect the file descriptor of INFILE to stdin, write the output to OUTFILE, return a new stream in STATUSFILE for stderr and the pid of the process in PID. The @@ -522,7 +597,7 @@ return err; /* Create a pipe. */ - if (create_inheritable_pipe (rp)) + if (create_inheritable_pipe_w (rp)) { err = gpg_error (GPG_ERR_GENERAL); log_error (_("error creating a pipe: %s\n"), gpg_strerror (err)); Modified: trunk/common/exechelp.h =================================================================== --- trunk/common/exechelp.h 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/common/exechelp.h 2009-09-30 15:28:38 UTC (rev 5167) @@ -44,7 +44,11 @@ inheritable. */ gpg_error_t gnupg_create_inbound_pipe (int filedes[2]); +/* Portable function to create a pipe. Under Windows the read end is + inheritable. */ +gpg_error_t gnupg_create_outbound_pipe (int filedes[2]); + /* Fork and exec the PGMNAME, connect the file descriptor of INFILE to stdin, write the output to OUTFILE, return a new stream in STATUSFILE for stderr and the pid of the process in PID. The Modified: trunk/common/iobuf.c =================================================================== --- trunk/common/iobuf.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/common/iobuf.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -1260,6 +1260,32 @@ return check_special_filename (fname) != -1; } + +/* Either open the file specified by the file descriptor FD or - if FD + is GNUPG_INVALID_FD - the file with name FNAME. As of now MODE is + assumed to be "rb" if FNAME is used. In contrast to iobuf_fdopen + the fiel descriptor FD will not be closed during an iobuf_close. */ +iobuf_t +iobuf_open_fd_or_name (gnupg_fd_t fd, const char *fname, const char *mode) +{ + iobuf_t a; + + if (fd == GNUPG_INVALID_FD) + a = iobuf_open (fname); + else + { + gnupg_fd_t fd2; + + fd2 = dup (fd); + if (fd2 == GNUPG_INVALID_FD) + a = NULL; + else + a = iobuf_fdopen (fd2, mode); + } + return a; +} + + /**************** * Create a head iobuf for reading from a file * returns: NULL if an error occures and sets errno @@ -1306,8 +1332,8 @@ } /**************** - * Create a head iobuf for reading from a file - * returns: NULL if an error occures and sets errno + * Create a head iobuf for reading or writing from/to a file + * Returns: NULL if an error occures and sets ERRNO. */ iobuf_t iobuf_fdopen (int fd, const char *mode) @@ -2355,7 +2381,9 @@ /**************** - * Retrieve the real filename + * Retrieve the real filename. This is the filename actually used on + * disk and not a made up one. Returns NULL if no real filename is + * available. */ const char * iobuf_get_real_fname (iobuf_t a) @@ -2376,7 +2404,7 @@ /**************** - * Retrieve the filename + * Retrieve the filename. This name should only be used in diagnostics. */ const char * iobuf_get_fname (iobuf_t a) @@ -2390,7 +2418,17 @@ return NULL; } +/* Same as iobuf_get_fname but never returns NULL. */ +const char * +iobuf_get_fname_nonnull (iobuf_t a) +{ + const char *fname; + fname = iobuf_get_fname (a); + return fname? fname : "[?]"; +} + + /**************** * enable partial block mode as described in the OpenPGP draft. * LEN is the first length byte on read, but ignored on writes. Modified: trunk/common/iobuf.h =================================================================== --- trunk/common/iobuf.h 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/common/iobuf.h 2009-09-30 15:28:38 UTC (rev 5167) @@ -21,8 +21,8 @@ #define GNUPG_COMMON_IOBUF_H #include "../include/types.h" /* fixme: should be moved elsewhere. */ +#include "../common/sysutils.h" - #define DBG_IOBUF iobuf_debug_mode @@ -85,6 +85,8 @@ iobuf_t iobuf_alloc (int use, size_t bufsize); iobuf_t iobuf_temp (void); iobuf_t iobuf_temp_with_content (const char *buffer, size_t length); +iobuf_t iobuf_open_fd_or_name (gnupg_fd_t fd, const char *fname, + const char *mode); iobuf_t iobuf_open (const char *fname); iobuf_t iobuf_fdopen (int fd, const char *mode); iobuf_t iobuf_sockopen (int fd, const char *mode); @@ -131,6 +133,7 @@ int iobuf_get_fd (iobuf_t a); const char *iobuf_get_real_fname (iobuf_t a); const char *iobuf_get_fname (iobuf_t a); +const char *iobuf_get_fname_nonnull (iobuf_t a); void iobuf_set_partial_block_mode (iobuf_t a, size_t len); Modified: trunk/g10/compress.c =================================================================== --- trunk/g10/compress.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/compress.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -245,6 +245,9 @@ memset( &cd, 0, sizeof cd ); cd.len = 0; cd.algorithm = zfx->algo; + /* Fixme: We should force a new CTB here: + cd.new_ctb = zfx->new_ctb; + */ init_packet( &pkt ); pkt.pkttype = PKT_COMPRESSED; pkt.pkt.compressed = &cd; Modified: trunk/g10/dearmor.c =================================================================== --- trunk/g10/dearmor.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/dearmor.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -64,7 +64,7 @@ push_armor_filter ( afx, inp ); - if( (rc = open_outfile( fname, 0, &out )) ) + if( (rc = open_outfile (GNUPG_INVALID_FD, fname, 0, &out )) ) goto leave; while( (c = iobuf_get(inp)) != -1 ) @@ -110,7 +110,7 @@ } - if( (rc = open_outfile( fname, 1, &out )) ) + if( (rc = open_outfile (GNUPG_INVALID_FD, fname, 1, &out )) ) goto leave; afx->what = 4; Modified: trunk/g10/encrypt.c =================================================================== --- trunk/g10/encrypt.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/encrypt.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -264,7 +264,8 @@ do_compress = 0; } - if ( rc || (rc = open_outfile( filename, opt.armor? 1:0, &out ))) + if ( rc || (rc = open_outfile (GNUPG_INVALID_FD, filename, + opt.armor? 1:0, &out ))) { iobuf_cancel (inp); xfree (cfx.dek); @@ -455,11 +456,15 @@ /* - * Encrypt the file with the given userids (or ask if none - * is supplied). + * Encrypt the file with the given userids (or ask if none is + * supplied). Either FILENAME or FILEFD must be given, but not both. + * The caller may provide a checked list of public keys in + * PROVIDED_PKS; if not the function builds a list of keys on its own. */ int -encrypt_crypt (const char *filename, strlist_t remusr, int use_symkey) +encrypt_crypt (gnupg_fd_t filefd, const char *filename, + strlist_t remusr, int use_symkey, pk_list_t provided_keys, + gnupg_fd_t outputfd) { iobuf_t inp = NULL; iobuf_t out = NULL; @@ -477,6 +482,9 @@ PK_LIST pk_list, work_list; int do_compress; + if (filefd != GNUPG_INVALID_FD && filename) + return gpg_error (GPG_ERR_INV_ARG); + do_compress = opt.compress_algo && !RFC1991; pfx = new_progress_context (); @@ -492,10 +500,15 @@ return rc; } - if ((rc = build_pk_list (remusr, &pk_list, PUBKEY_USAGE_ENC))) + if (provided_keys) + pk_list = provided_keys; + else { - release_progress_context (pfx); - return rc; + if ((rc = build_pk_list (remusr, &pk_list, PUBKEY_USAGE_ENC))) + { + release_progress_context (pfx); + return rc; + } } if(PGP2) @@ -512,7 +525,7 @@ } /* Prepare iobufs. */ - inp = iobuf_open(filename); + inp = iobuf_open_fd_or_name (filefd, filename, "rb"); if (inp) iobuf_ioctl (inp, 3, 1, NULL); /* Disable fd caching. */ if (inp && is_secured_file (iobuf_get_fd (inp))) @@ -523,20 +536,30 @@ } if (!inp) { + char xname[64]; + rc = gpg_error_from_syserror (); + if (filefd != GNUPG_INVALID_FD) + snprintf (xname, sizeof xname, "[fd %d]", filefd); + else if (!filename) + strcpy (xname, "[stdin]"); + else + *xname = 0; log_error (_("can't open `%s': %s\n"), - filename? filename: "[stdin]", gpg_strerror (rc) ); + *xname? xname : filename, gpg_strerror (rc) ); goto leave; } - else if (opt.verbose) - log_info (_("reading from `%s'\n"), filename? filename: "[stdin]"); + if (opt.verbose) + log_info (_("reading from `%s'\n"), iobuf_get_fname_nonnull (inp)); + handle_progress (pfx, inp, filename); if (opt.textmode) iobuf_push_filter (inp, text_filter, &tfx); - if ((rc = open_outfile( filename, opt.armor? 1:0, &out ))) + rc = open_outfile (outputfd, filename, opt.armor? 1:0, &out); + if (rc) goto leave; if (opt.armor) @@ -629,7 +652,8 @@ if (!opt.no_literal) pt = setup_plaintext_name (filename, inp); - if (!iobuf_is_pipe_filename (filename) && *filename && !opt.textmode ) + if (filefd != GNUPG_INVALID_FD + && !iobuf_is_pipe_filename (filename) && *filename && !opt.textmode ) { off_t tmpsize; int overflow; @@ -709,13 +733,16 @@ plain data. */ byte copy_buffer[4096]; int bytes_copied; - while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) - if ((rc=iobuf_write(out, copy_buffer, bytes_copied))) - { - log_error ("copying input to output failed: %s\n", - gpg_strerror (rc)); - break; - } + while ((bytes_copied = iobuf_read (inp, copy_buffer, 4096)) != -1) + { + rc = iobuf_write (out, copy_buffer, bytes_copied); + if (rc) + { + log_error ("copying input to output failed: %s\n", + gpg_strerror (rc)); + break; + } + } wipememory (copy_buffer, 4096); /* Burn the buffer. */ } @@ -735,7 +762,8 @@ xfree (cfx.dek); xfree (symkey_dek); xfree (symkey_s2k); - release_pk_list (pk_list); + if (!provided_keys) + release_pk_list (pk_list); release_armor_context (afx); release_progress_context (pfx); return rc; @@ -936,9 +964,11 @@ } line[strlen(line)-1] = '\0'; print_file_status(STATUS_FILE_START, line, 2); - if ( (rc = encrypt_crypt(line, remusr, 0)) ) - log_error("encryption of `%s' failed: %s\n", - print_fname_stdin(line), g10_errstr(rc) ); + rc = encrypt_crypt (GNUPG_INVALID_FD, line, remusr, 0, + NULL, GNUPG_INVALID_FD); + if (rc) + log_error ("encryption of `%s' failed: %s\n", + print_fname_stdin(line), g10_errstr(rc) ); write_status( STATUS_FILE_DONE ); } } @@ -947,7 +977,8 @@ while (nfiles--) { print_file_status(STATUS_FILE_START, *files, 2); - if ( (rc = encrypt_crypt(*files, remusr, 0)) ) + if ( (rc = encrypt_crypt (GNUPG_INVALID_FD, *files, remusr, 0, + NULL, GNUPG_INVALID_FD)) ) log_error("encryption of `%s' failed: %s\n", print_fname_stdin(*files), g10_errstr(rc) ); write_status( STATUS_FILE_DONE ); Modified: trunk/g10/export.c =================================================================== --- trunk/g10/export.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/export.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -140,7 +140,7 @@ memset( &zfx, 0, sizeof zfx); - rc = open_outfile( NULL, 0, &out ); + rc = open_outfile (GNUPG_INVALID_FD, NULL, 0, &out ); if (rc) return rc; Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/gpg.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -1920,9 +1920,6 @@ gnupg_rl_initialize (); set_strusage (my_strusage); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); - /* We don't need any locking in libgcrypt unless we use any kind of - threading. */ - gcry_control (GCRYCTL_DISABLE_INTERNAL_LOCKING); log_set_prefix ("gpg", 1); /* Make sure that our subsystems are ready. */ @@ -3437,7 +3434,8 @@ { if( argc > 1 ) wrong_args(_("--encrypt [filename]")); - if( (rc = encrypt_crypt(fname,remusr,0)) ) + if( (rc = encrypt_crypt (GNUPG_INVALID_FD, fname, + remusr, 0, NULL, GNUPG_INVALID_FD)) ) log_error("%s: encryption failed: %s\n", print_fname_stdin(fname), g10_errstr(rc) ); } @@ -3458,7 +3456,8 @@ " while in %s mode\n"),compliance_option_string()); else { - if( (rc = encrypt_crypt(fname,remusr,1)) ) + if( (rc = encrypt_crypt (GNUPG_INVALID_FD, fname, + remusr, 1, NULL, GNUPG_INVALID_FD)) ) log_error("%s: encryption failed: %s\n", print_fname_stdin(fname), g10_errstr(rc) ); } Modified: trunk/g10/keydb.h =================================================================== --- trunk/g10/keydb.h 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/keydb.h 2009-09-30 15:28:38 UTC (rev 5167) @@ -83,12 +83,14 @@ }; typedef struct keyblock_pos_struct KBPOS; -/* structure to hold a couple of public key certificates */ -typedef struct pk_list *PK_LIST; -struct pk_list { - PK_LIST next; - PKT_public_key *pk; - int flags; /* flag bit 1==throw_keyid */ +/* Structure to hold a couple of public key certificates. */ +typedef struct pk_list *PK_LIST; /* Deprecated. */ +typedef struct pk_list *pk_list_t; +struct pk_list +{ + PK_LIST next; + PKT_public_key *pk; + int flags; /* flag bit 1==throw_keyid */ }; /* structure to hold a couple of secret key certificates */ @@ -179,8 +181,12 @@ /*-- pkclist.c --*/ void show_revocation_reason( PKT_public_key *pk, int mode ); int check_signatures_trust( PKT_signature *sig ); -void release_pk_list( PK_LIST pk_list ); -int build_pk_list( strlist_t rcpts, PK_LIST *ret_pk_list, unsigned use ); + +void release_pk_list (PK_LIST pk_list); +int build_pk_list (strlist_t rcpts, PK_LIST *ret_pk_list, unsigned use); +gpg_error_t find_and_check_key (const char *name, unsigned int use, + int mark_hidden, pk_list_t *pk_list_addr); + int algo_available( preftype_t preftype, int algo, const union pref_hint *hint ); int select_algo_from_prefs( PK_LIST pk_list, int preftype, Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/main.h 2009-09-30 15:28:38 UTC (rev 5167) @@ -185,7 +185,9 @@ int setup_symkey (STRING2KEY **symkey_s2k,DEK **symkey_dek); int encrypt_symmetric (const char *filename ); int encrypt_store (const char *filename ); -int encrypt_crypt (const char *filename, strlist_t remusr, int use_symkey ); +int encrypt_crypt (gnupg_fd_t filefd, const char *filename, + strlist_t remusr, int use_symkey, pk_list_t provided_keys, + gnupg_fd_t outputfd); void encrypt_crypt_files (int nfiles, char **files, strlist_t remusr); int encrypt_filter (void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len); @@ -243,7 +245,7 @@ int overwrite_filep( const char *fname ); char *make_outfile_name( const char *iname ); char *ask_outfile_name( const char *name, size_t namelen ); -int open_outfile( const char *iname, int mode, iobuf_t *a ); +int open_outfile (gnupg_fd_t inp_fd, const char *iname, int mode, iobuf_t *a); iobuf_t open_sigfile( const char *iname, progress_filter_context_t *pfx ); void try_make_homedir( const char *fname ); Modified: trunk/g10/openfile.c =================================================================== --- trunk/g10/openfile.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/openfile.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -1,6 +1,6 @@ /* openfile.c * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * 2005, 2009 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -43,6 +43,13 @@ #define SKELEXT EXTSEP_S "skel" #endif +#ifdef HAVE_W32_SYSTEM +#define NAME_OF_DEV_NULL "nul" +#else +#define NAME_OF_DEV_NULL "/dev/null" +#endif + + #if defined (HAVE_DRIVE_LETTERS) || defined (__riscos__) #define CMP_FILENAME(a,b) ascii_strcasecmp( (a), (b) ) #else @@ -65,34 +72,27 @@ int overwrite_filep( const char *fname ) { - if( iobuf_is_pipe_filename (fname) ) - return 1; /* Writing to stdout is always okay */ + if ( iobuf_is_pipe_filename (fname) ) + return 1; /* Writing to stdout is always okay. */ + + if ( access( fname, F_OK ) ) + return 1; /* Does not exist. */ + + if ( !compare_filenames (fname, NAME_OF_DEV_NULL) ) + return 1; /* Does not do any harm. */ - if( access( fname, F_OK ) ) - return 1; /* does not exist */ + if (opt.answer_yes) + return 1; + if (opt.answer_no || opt.batch) + return 0; /* Do not overwrite. */ -#ifndef HAVE_DOSISH_SYSTEM - if ( !strcmp ( fname, "/dev/null" ) ) - return 1; /* does not do any harm */ -#endif -#ifdef HAVE_W32_SYSTEM - if ( !strcmp ( fname, "nul" ) ) - return 1; -#endif - - /* fixme: add some backup stuff in case of overwrite */ - if( opt.answer_yes ) - return 1; - if( opt.answer_no || opt.batch ) - return 0; /* do not overwrite */ - - tty_printf(_("File `%s' exists. "), fname); - if( cpr_enabled () ) - tty_printf ("\n"); - if( cpr_get_answer_is_yes("openfile.overwrite.okay", - _("Overwrite? (y/N) ")) ) - return 1; - return 0; + tty_printf (_("File `%s' exists. "), fname); + if (cpr_enabled ()) + tty_printf ("\n"); + if (cpr_get_answer_is_yes ("openfile.overwrite.okay", + _("Overwrite? (y/N) ")) ) + return 1; + return 0; } @@ -178,110 +178,134 @@ * Mode 0 = use ".gpg" * 1 = use ".asc" * 2 = use ".sig" + + * If INP_FD is not GNUPG_INVALID_FD the function will simply create + * an IOBUF for that file descriptor and ignore a INAME and MODE. + * Note that INP_FD won't be closed if the returned IOBUF is closed. */ int -open_outfile( const char *iname, int mode, IOBUF *a ) +open_outfile (gnupg_fd_t inp_fd, const char *iname, int mode, iobuf_t *a) { int rc = 0; *a = NULL; - if( iobuf_is_pipe_filename (iname) && !opt.outfile ) { - *a = iobuf_create(NULL); - if( !*a ) { - rc = gpg_error_from_syserror (); - log_error(_("can't open `%s': %s\n"), "[stdout]", strerror(errno) ); + if (inp_fd != GNUPG_INVALID_FD) + { + char xname[64]; + gnupg_fd_t fd2; + + fd2 = INT2FD (dup (FD2INT (inp_fd))); + if (fd2 == GNUPG_INVALID_FD) + *a = NULL; + else + *a = iobuf_fdopen (fd2, "wb"); + if (!*a) + { + rc = gpg_error_from_syserror (); + snprintf (xname, sizeof xname, "[fd %d]", inp_fd); + log_error (_("can't open `%s': %s\n"), xname, gpg_strerror (rc)); + } + else if (opt.verbose) + { + snprintf (xname, sizeof xname, "[fd %d]", inp_fd); + log_info (_("writing to `%s'\n"), xname); + } } - else if( opt.verbose ) - log_info(_("writing to stdout\n")); - } - else { - char *buf = NULL; - const char *name; + else if (iobuf_is_pipe_filename (iname) && !opt.outfile) + { + *a = iobuf_create(NULL); + if ( !*a ) + { + rc = gpg_error_from_syserror (); + log_error (_("can't open `%s': %s\n"), "[stdout]", strerror(errno) ); + } + else if ( opt.verbose ) + log_info (_("writing to stdout\n")); + } + else + { + char *buf = NULL; + const char *name; - if ( opt.dry_run ) - { -#ifdef HAVE_W32_SYSTEM - name = "nul"; -#else - name = "/dev/null"; -#endif - } - else if( opt.outfile ) - name = opt.outfile; - else { + if (opt.dry_run) + name = NAME_OF_DEV_NULL; + else if (opt.outfile) + name = opt.outfile; + else + { #ifdef USE_ONLY_8DOT3 - if (opt.mangle_dos_filenames) - { - /* It is quite common DOS system to have only one dot in a - * a filename So if we have something like this, we simple - * replace the suffix execpt in cases where the suffix is - * larger than 3 characters and not the same as. - * We should really map the filenames to 8.3 but this tends to - * be more complicated and is probaly a duty of the filesystem - */ - char *dot; - const char *newsfx = mode==1 ? ".asc" : - mode==2 ? ".sig" : ".gpg"; + if (opt.mangle_dos_filenames) + { + /* It is quite common for DOS systems to have only one + dot in a filename. If we have something like this, + we simple replace the suffix except in cases where + the suffix is larger than 3 characters and not the + same as the new one. We don't map the filenames to + 8.3 because this is a duty of the file system. */ + char *dot; + const char *newsfx; + + newsfx = (mode==1 ? ".asc" : + mode==2 ? ".sig" : ".gpg"); - buf = xmalloc(strlen(iname)+4+1); - strcpy(buf,iname); - dot = strchr(buf, '.' ); - if ( dot && dot > buf && dot[1] && strlen(dot) <= 4 - && CMP_FILENAME(newsfx, dot) ) + buf = xmalloc (strlen(iname)+4+1); + strcpy (buf, iname); + dot = strchr (buf, '.' ); + if ( dot && dot > buf && dot[1] && strlen(dot) <= 4 + && CMP_FILENAME (newsfx, dot) ) + strcpy (dot, newsfx); + else if (dot && !dot[1]) /* Do not duplicate a dot. */ + strcpy (dot, newsfx+1); + else + strcat (buf, newsfx); + } + if (!buf) +#endif /* USE_ONLY_8DOT3 */ { - strcpy(dot, newsfx ); + buf = xstrconcat (iname, + (mode==1 ? EXTSEP_S "asc" : + mode==2 ? EXTSEP_S "sig" : EXTSEP_S "gpg"), + NULL); } - else if ( dot && !dot[1] ) /* don't duplicate a dot */ - strcpy( dot, newsfx+1 ); - else - strcat ( buf, newsfx ); + name = buf; } - if (!buf) -#endif /* USE_ONLY_8DOT3 */ + + rc = 0; + while ( !overwrite_filep (name) ) { - buf = xmalloc(strlen(iname)+4+1); - strcpy(stpcpy(buf,iname), mode==1 ? EXTSEP_S "asc" : - mode==2 ? EXTSEP_S "sig" : EXTSEP_S "gpg"); + char *tmp = ask_outfile_name (NULL, 0); + if ( !tmp || !*tmp ) + { + xfree (tmp); + rc = gpg_error (GPG_ERR_EEXIST); + break; + } + xfree (buf); + name = buf = tmp; } - name = buf; + + if ( !rc ) + { + if (is_secured_filename (name) ) + { + *a = NULL; + errno = EPERM; + } + else + *a = iobuf_create (name); + if (!*a) + { + rc = gpg_error_from_syserror (); + log_error(_("can't create `%s': %s\n"), name, strerror(errno) ); + } + else if( opt.verbose ) + log_info (_("writing to `%s'\n"), name ); + } + xfree(buf); } - - rc = 0; - while( !overwrite_filep (name) ) - { - char *tmp = ask_outfile_name (NULL, 0); - if ( !tmp || !*tmp ) - { - xfree (tmp); - rc = gpg_error (GPG_ERR_EEXIST); - break; - } - xfree (buf); - name = buf = tmp; - } - - if( !rc ) - { - if (is_secured_filename (name) ) - { - *a = NULL; - errno = EPERM; - } - else - *a = iobuf_create( name ); - if( !*a ) - { - rc = gpg_error_from_syserror (); - log_error(_("can't create `%s': %s\n"), name, strerror(errno) ); - } - else if( opt.verbose ) - log_info(_("writing to `%s'\n"), name ); - } - xfree(buf); - } - + if (*a) - iobuf_ioctl (*a,3,1,NULL); /* disable fd caching */ + iobuf_ioctl (*a, 3, 1, NULL); /* Disable fd caching. */ return rc; } Modified: trunk/g10/parse-packet.c =================================================================== --- trunk/g10/parse-packet.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/parse-packet.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -682,7 +682,11 @@ else { for( ; pktlen; pktlen-- ) - dump_hex_line(iobuf_get(inp), &i); + { + dump_hex_line( (c=iobuf_get(inp)), &i); + if (c == -1) + break; + } } putc ('\n', listfp); return; @@ -2529,7 +2533,11 @@ } else { for( ; pktlen; pktlen-- ) - dump_hex_line(iobuf_get(inp), &i); + { + dump_hex_line ((c=iobuf_get (inp)), &i); + if (c == -1) + break; + } } putc ('\n', listfp); } Modified: trunk/g10/pkclist.c =================================================================== --- trunk/g10/pkclist.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/pkclist.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -1,6 +1,6 @@ /* pkclist.c - create a list of public keys * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - * 2008 Free Software Foundation, Inc. + * 2008, 2009 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -40,6 +40,18 @@ #define CONTROL_D ('D' - 'A' + 1) +static void +send_status_inv_recp (int reason, const char *name) +{ + char buf[40]; + + snprintf (buf, sizeof buf, "%d ", reason); + write_status_text_and_buffer (STATUS_INV_RECP, buf, + name, strlen (name), + -1); +} + + /**************** * Show the revocation reason as it is stored with the given signature */ @@ -656,14 +668,15 @@ void -release_pk_list( PK_LIST pk_list ) +release_pk_list (pk_list_t pk_list) { - PK_LIST pk_rover; - - for( ; pk_list; pk_list = pk_rover ) { - pk_rover = pk_list->next; - free_public_key( pk_list->pk ); - xfree( pk_list ); + PK_LIST pk_rover; + + for ( ; pk_list; pk_list = pk_rover) + { + pk_rover = pk_list->next; + free_public_key ( pk_list->pk ); + xfree ( pk_list ); } } @@ -680,7 +693,7 @@ /**************** - * Return a malloced string with a default reciepient if there is any + * Return a malloced string with a default recipient if there is any */ static char * default_recipient(void) @@ -760,6 +773,96 @@ } +/* Helper for build_pk_list to find and check one key. This helper is + also used directly in server mode by the RECIPIENTS command. On + success the new key is added to PK_LIST_ADDR. NAME is the user id + of the key. USE the requested usage and a set MARK_HIDDEN will mark + the key in the updated list as a hidden recipient. */ +gpg_error_t +find_and_check_key (const char *name, unsigned int use, + int mark_hidden, pk_list_t *pk_list_addr) +{ + int rc; + PKT_public_key *pk; + int trustlevel; + + if (!name || !*name) + return gpg_error (GPG_ERR_INV_NAME); + + pk = xtrycalloc (1, sizeof *pk); + if (!pk) + return gpg_error_from_syserror (); + pk->req_usage = use; + + rc = get_pubkey_byname (NULL, pk, name, NULL, NULL, 0, 0); + if (rc) + { + /* Key not found or other error. */ + log_error (_("%s: skipped: %s\n"), name, g10_errstr(rc) ); + send_status_inv_recp (0, name); + free_public_key (pk); + return rc; + } + + rc = openpgp_pk_test_algo2 (pk->pubkey_algo, use); + if (rc) + { + /* Key found but not usable for us (e.g. sign-only key). */ + send_status_inv_recp (0, name); + log_error (_("%s: skipped: %s\n"), name, g10_errstr(rc) ); + free_public_key (pk); + return rc; + } + + /* Key found and usable. Check validity. */ + trustlevel = get_validity (pk, pk->user_id); + if ( (trustlevel & TRUST_FLAG_DISABLED) ) + { + /* Key has been disabled. */ + send_status_inv_recp (0, name); + log_info (_("%s: skipped: public key is disabled\n"), name); + free_public_key (pk); + return G10ERR_UNU_PUBKEY; + } + + if ( !do_we_trust_pre (pk, trustlevel) ) + { + /* We don't trust this key. */ + send_status_inv_recp (10, name); + free_public_key (pk); + return G10ERR_UNU_PUBKEY; + } + /* Note: do_we_trust may have changed the trustlevel. */ + + /* Skip the actual key if the key is already present in the + list. */ + if (!key_present_in_pk_list (*pk_list_addr, pk)) + { + log_info (_("%s: skipped: public key already present\n"), name); + free_public_key (pk); + } + else + { + pk_list_t r; + + r = xtrymalloc (sizeof *r); + if (!r) + { + rc = gpg_error_from_syserror (); + free_public_key (pk); + return rc; + } + r->pk = pk; + r->next = *pk_list_addr; + r->flags = mark_hidden? 1:0; + *pk_list_addr = r; + } + + return 0; +} + + + /* This is the central function to collect the keys for recipients. It is thus used to prepare a public key encryption. encrypt-to keys, default keys and the keys for the actual recipients are all @@ -831,8 +934,7 @@ { free_public_key ( pk ); pk = NULL; log_error (_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) ); - write_status_text_and_buffer (STATUS_INV_RECP, "0 ", - rov->d, strlen (rov->d), -1); + send_status_inv_recp (0, rov->d); goto fail; } else if ( !(rc=openpgp_pk_test_algo2 (pk->pubkey_algo, use)) ) @@ -873,8 +975,7 @@ available. */ free_public_key( pk ); pk = NULL; log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) ); - write_status_text_and_buffer (STATUS_INV_RECP, "0 ", - rov->d, strlen (rov->d), -1); + send_status_inv_recp (0, rov->d); goto fail; } } @@ -1078,85 +1179,11 @@ if ( (remusr->flags & 1) ) continue; /* encrypt-to keys are already handled. */ - pk = xmalloc_clear( sizeof *pk ); - pk->req_usage = use; - if ((rc = get_pubkey_byname (NULL, pk, remusr->d, NULL, NULL, 0, 0))) - { - /* Key not found or other error. */ - free_public_key( pk ); pk = NULL; - log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) ); - write_status_text_and_buffer (STATUS_INV_RECP, "0 ", - remusr->d, strlen (remusr->d), - -1); - goto fail; - } - else if ( !(rc=openpgp_pk_test_algo2(pk->pubkey_algo, use )) ) - { - /* Key found and usable. Check validity. */ - int trustlevel; - - trustlevel = get_validity (pk, pk->user_id); - if ( (trustlevel & TRUST_FLAG_DISABLED) ) - { - /*Key has been disabled. */ - free_public_key(pk); pk = NULL; - log_info(_("%s: skipped: public key is disabled\n"), - remusr->d); - write_status_text_and_buffer (STATUS_INV_RECP, "0 ", - remusr->d, - strlen (remusr->d), - -1); - rc=G10ERR_UNU_PUBKEY; - goto fail; - } - else if ( do_we_trust_pre( pk, trustlevel ) ) - { - /* Note: do_we_trust may have changed the trustlevel */ - - /* We have at least one valid recipient. It doesn't - * matters if this recipient is already present. */ - any_recipients = 1; - - /* Skip the actual key if the key is already present - * in the list */ - if (!key_present_in_pk_list(pk_list, pk)) - { - free_public_key(pk); pk = NULL; - log_info(_("%s: skipped: public key already present\n"), - remusr->d); - } - else - { - PK_LIST r; - r = xmalloc( sizeof *r ); - r->pk = pk; pk = NULL; - r->next = pk_list; - r->flags = (remusr->flags&2)?1:0; - pk_list = r; - } - } - else - { /* We don't trust this key. */ - free_public_key( pk ); pk = NULL; - write_status_text_and_buffer (STATUS_INV_RECP, "10 ", - remusr->d, - strlen (remusr->d), - -1); - rc=G10ERR_UNU_PUBKEY; - goto fail; - } - } - else - { - /* Key found but not usable for us (e.g. sign-only key). */ - free_public_key( pk ); pk = NULL; - write_status_text_and_buffer (STATUS_INV_RECP, "0 ", - remusr->d, - strlen (remusr->d), - -1); - log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) ); - goto fail; - } + rc = find_and_check_key (remusr->d, use, !!(remusr->flags&2), + &pk_list); + if (rc) + goto fail; + any_recipients = 1; } } Modified: trunk/g10/revoke.c =================================================================== --- trunk/g10/revoke.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/revoke.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -326,7 +326,7 @@ if( !opt.armor ) tty_printf(_("ASCII armored output forced.\n")); - if( (rc = open_outfile( NULL, 0, &out )) ) + if( (rc = open_outfile (GNUPG_INVALID_FD, NULL, 0, &out )) ) goto leave; afx->what = 1; @@ -550,7 +550,7 @@ if( !opt.armor ) tty_printf(_("ASCII armored output forced.\n")); - if( (rc = open_outfile( NULL, 0, &out )) ) + if( (rc = open_outfile (GNUPG_INVALID_FD, NULL, 0, &out )) ) goto leave; afx->what = 1; Modified: trunk/g10/server.c =================================================================== --- trunk/g10/server.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/server.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -33,6 +33,7 @@ #include "i18n.h" #include "options.h" #include "../common/sysutils.h" +#include "status.h" #define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t)) @@ -45,6 +46,10 @@ assuan_context_t assuan_ctx; /* File descriptor as set by the MESSAGE command. */ gnupg_fd_t message_fd; + + /* List of prepared recipients. */ + pk_list_t recplist; + }; @@ -61,6 +66,39 @@ } +/* Skip over options. Blanks after the options are also removed. */ +static char * +skip_options (const char *line) +{ + while (spacep (line)) + line++; + while ( *line == '-' && line[1] == '-' ) + { + while (*line && !spacep (line)) + line++; + while (spacep (line)) + line++; + } + return (char*)line; +} + + +/* Check whether the option NAME appears in LINE. */ +static int +has_option (const char *line, const char *name) +{ + const char *s; + int n = strlen (name); + + s = strstr (line, name); + if (s && s >= skip_options (line)) + return 0; + return (s && (s == line || spacep (s-1)) && (!s[n] || spacep (s+n))); +} + + + + /* Called by libassuan for Assuan options. See the Assuan manual for details. */ @@ -111,6 +149,9 @@ { ctrl_t ctrl = assuan_get_pointer (ctx); + release_pk_list (ctrl->server_local->recplist); + ctrl->server_local->recplist = NULL; + close_message_fd (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); @@ -157,7 +198,7 @@ -/* RECIPIENT +/* RECIPIENT [--hidden] Set the recipient for the encryption. should be the internal representation of the key; the server may accept any other @@ -171,9 +212,26 @@ static gpg_error_t cmd_recipient (assuan_context_t ctx, char *line) { - (void)ctx; - (void)line; - return gpg_error (GPG_ERR_NOT_SUPPORTED); + ctrl_t ctrl = assuan_get_pointer (ctx); + gpg_error_t err; + int hidden; + + hidden = has_option (line,"--hidden"); + line = skip_options (line); + + /* FIXME: Expand groups + if (opt.grouplist) + remusr = expand_group (rcpts); + else + remusr = rcpts; + */ + + err = find_and_check_key (line, PUBKEY_USAGE_ENC, hidden, + &ctrl->server_local->recplist); + + if (err) + log_error ("command '%s' failed: %s\n", "RECIPIENT", gpg_strerror (err)); + return err; } @@ -206,22 +264,81 @@ /* ENCRYPT Do the actual encryption process. Takes the plaintext from the - INPUT command, writes to the ciphertext to the file descriptor set - with the OUTPUT command, take the recipients form all the - recipients set so far. If this command fails the clients should - try to delete all output currently done or otherwise mark it as - invalid. GPG does ensure that there won't be any security problem - with leftover data on the output in this case. + INPUT command, writes the ciphertext to the file descriptor set + with the OUTPUT command, take the recipients from all the + recipients set so far with RECIPIENTS. - This command should in general not fail, as all necessary checks - have been done while setting the recipients. The input and output - pipes are closed. */ + If this command fails the clients should try to delete all output + currently done or otherwise mark it as invalid. GPG does ensure + that there won't be any security problem with leftover data on the + output in this case. + + In most cases this command won't fail because most necessary checks + have been done while setting the recipients. However some checks + can only be done right here and thus error may occur anyway (for + example, no recipients at all). + + The input, output and message pipes are closed after this + command. */ static gpg_error_t cmd_encrypt (assuan_context_t ctx, char *line) { - (void)ctx; - (void)line; - return gpg_error (GPG_ERR_NOT_SUPPORTED); + ctrl_t ctrl = assuan_get_pointer (ctx); + gpg_error_t err; + int inp_fd, out_fd; + + (void)line; /* LINE is not used. */ + + if ( !ctrl->server_local->recplist ) + { + write_status_text (STATUS_NO_RECP, "0"); + err = gpg_error (GPG_ERR_NO_USER_ID); + goto leave; + } + + inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0); + if (inp_fd == -1) + { + err = set_error (GPG_ERR_ASS_NO_INPUT, NULL); + goto leave; + } + out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); + if (out_fd == -1) + { + err = set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); + goto leave; + } + + /* Fixme: Check that we are using real files and not pipes if in + PGP-2 mode. Do all the other checks we do in gpg.c for aEncr. + Maybe we should drop the PGP2 compatibility. */ + + + /* FIXME: GPGSM does this here: Add all encrypt-to marked recipients + from the default list. */ + + /* fixme: err = ctrl->audit? 0 : start_audit_session (ctrl);*/ + + err = encrypt_crypt (inp_fd, NULL, NULL, 0, + ctrl->server_local->recplist, + out_fd); + + leave: + /* Release the recipient list on success. */ + if (!err) + { + release_pk_list (ctrl->server_local->recplist); + ctrl->server_local->recplist = NULL; + } + + /* Close and reset the fds. */ + close_message_fd (ctrl); + assuan_close_input_fd (ctx); + assuan_close_output_fd (ctx); + + if (err) + log_error ("command '%s' failed: %s\n", "ENCRYPT", gpg_strerror (err)); + return err; } @@ -258,6 +375,9 @@ gnupg_fd_t out_fd = assuan_get_output_fd (ctx); FILE *out_fp = NULL; + /* FIXME: Revamp this code it is nearly to 3 years old and was only + intended as a quick test. */ + (void)line; if (fd == GNUPG_INVALID_FD) @@ -270,8 +390,8 @@ return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed"); } - log_debug ("WARNING: The server mode work " - "in progress and not ready for use\n"); + log_debug ("WARNING: The server mode is WORK " + "iN PROGRESS and not ready for use\n"); /* Need to dup it because it might get closed and libassuan won't know about it then. */ @@ -596,8 +716,13 @@ } leave: - xfree (ctrl->server_local); - ctrl->server_local = NULL; + if (ctrl->server_local) + { + release_pk_list (ctrl->server_local->recplist); + + xfree (ctrl->server_local); + ctrl->server_local = NULL; + } assuan_release (ctx); return rc; } Modified: trunk/g10/sign.c =================================================================== --- trunk/g10/sign.c 2009-09-28 17:11:32 UTC (rev 5166) +++ trunk/g10/sign.c 2009-09-30 15:28:38 UTC (rev 5167) @@ -801,7 +801,8 @@ else if( opt.verbose ) log_info(_("writing to `%s'\n"), outfile ); } - else if( (rc = open_outfile( fname, opt.armor? 1: detached? 2:0, &out ))) + else if( (rc = open_outfile (GNUPG_INVALID_FD, fname, + opt.armor? 1: detached? 2:0, &out ))) goto leave; /* prepare to calculate the MD over the input */ @@ -1110,7 +1111,7 @@ else if( opt.verbose ) log_info(_("writing to `%s'\n"), outfile ); } - else if( (rc = open_outfile( fname, 1, &out )) ) + else if( (rc = open_outfile (GNUPG_INVALID_FD, fname, 1, &out )) ) From cvs at cvs.gnupg.org Wed Sep 30 20:47:11 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 30 Sep 2009 20:47:11 +0200 Subject: [svn] GnuPG - r5168 - trunk/g10 Message-ID: Author: wk Date: 2009-09-30 20:47:11 +0200 (Wed, 30 Sep 2009) New Revision: 5168 Modified: trunk/g10/decrypt.c trunk/g10/server.c Log: Re-indentation Modified: trunk/g10/decrypt.c =================================================================== --- trunk/g10/decrypt.c 2009-09-30 15:28:38 UTC (rev 5167) +++ trunk/g10/decrypt.c 2009-09-30 18:47:11 UTC (rev 5168) @@ -1,6 +1,6 @@ -/* decrypt.c - verify signed data +/* decrypt.c - decrypt and verify data * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007 Free Software Foundation, Inc. + * 2007, 2009 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -36,67 +36,69 @@ #include "status.h" #include "i18n.h" - - -/**************** - * Assume that the input is an encrypted message and decrypt +/* Assume that the input is an encrypted message and decrypt * (and if signed, verify the signature on) it. * This command differs from the default operation, as it never * writes to the filename which is included in the file and it * rejects files which don't begin with an encrypted message. */ - int -decrypt_message( const char *filename ) +decrypt_message (const char *filename) { - IOBUF fp; - armor_filter_context_t *afx = NULL; - progress_filter_context_t *pfx; - int rc; - int no_out = 0; + IOBUF fp; + armor_filter_context_t *afx = NULL; + progress_filter_context_t *pfx; + int rc; + int no_out = 0; - pfx = new_progress_context (); - - /* Open the message file. */ - fp = iobuf_open(filename); - if (fp && is_secured_file (iobuf_get_fd (fp))) - { - iobuf_close (fp); - fp = NULL; - errno = EPERM; - } - if( !fp ) { - rc = gpg_error_from_syserror (); - log_error (_("can't open `%s': %s\n"), print_fname_stdin(filename), - gpg_strerror (rc)); - release_progress_context (pfx); - return rc; + pfx = new_progress_context (); + + /* Open the message file. */ + fp = iobuf_open (filename); + if (fp && is_secured_file (iobuf_get_fd (fp))) + { + iobuf_close (fp); + fp = NULL; + errno = EPERM; } + if ( !fp ) + { + rc = gpg_error_from_syserror (); + log_error (_("can't open `%s': %s\n"), print_fname_stdin(filename), + gpg_strerror (rc)); + release_progress_context (pfx); + return rc; + } - handle_progress (pfx, fp, filename); + handle_progress (pfx, fp, filename); - if( !opt.no_armor ) { - if( use_armor_filter( fp ) ) { - afx = new_armor_context (); - push_armor_filter ( afx, fp ); + if ( !opt.no_armor ) + { + if ( use_armor_filter( fp ) ) + { + afx = new_armor_context (); + push_armor_filter ( afx, fp ); } } - if( !opt.outfile ) { - no_out = 1; - opt.outfile = "-"; + if (!opt.outfile) + { + no_out = 1; + opt.outfile = "-"; } - rc = proc_encryption_packets( NULL, fp ); - if( no_out ) - opt.outfile = NULL; - iobuf_close(fp); - release_armor_context (afx); - release_progress_context (pfx); - return rc; + rc = proc_encryption_packets ( NULL, fp ); + if (no_out) + opt.outfile = NULL; + + iobuf_close (fp); + release_armor_context (afx); + release_progress_context (pfx); + return rc; } + void -decrypt_messages(int nfiles, char *files[]) +decrypt_messages (int nfiles, char *files[]) { IOBUF fp; armor_filter_context_t *afx = NULL; Modified: trunk/g10/server.c =================================================================== --- trunk/g10/server.c 2009-09-30 15:28:38 UTC (rev 5167) +++ trunk/g10/server.c 2009-09-30 18:47:11 UTC (rev 5168) @@ -345,14 +345,33 @@ /* DECRYPT - This performs the decrypt operation after doing some checks on the - internal state (e.g. that only needed data has been set). */ + This performs the decrypt operation. */ static gpg_error_t cmd_decrypt (assuan_context_t ctx, char *line) { - (void)ctx; - (void)line; - return gpg_error (GPG_ERR_NOT_SUPPORTED); + ctrl_t ctrl = assuan_get_pointer (ctx); + gpg_error_t err; + int inp_fd, out_fd; + + (void)line; /* LINE is not used. */ + + inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0); + if (inp_fd == -1) + return set_error (GPG_ERR_ASS_NO_INPUT, NULL); + out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); + if (out_fd == -1) + return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); + + err = gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + /* Close and reset the fds. */ + close_message_fd (ctrl); + assuan_close_input_fd (ctx); + assuan_close_output_fd (ctx); + + if (err) + log_error ("command '%s' failed: %s\n", "DECRYPT", gpg_strerror (err)); + return err; } @@ -406,6 +425,8 @@ assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); + if (rc) + log_error ("command '%s' failed: %s\n", "VERIFY", gpg_strerror (rc)); return rc; }