From cvs at cvs.gnupg.org Mon Nov 1 15:57:14 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 01 Nov 2010 15:57:14 +0100 Subject: [svn] assuan - r390 - in trunk: . contrib contrib/conf-w32ce-msc src Message-ID: Author: wk Date: 2010-11-01 15:57:12 +0100 (Mon, 01 Nov 2010) New Revision: 390 Added: trunk/contrib/ trunk/contrib/conf-w32ce-msc/ trunk/contrib/conf-w32ce-msc/build.mk trunk/contrib/conf-w32ce-msc/config.h Modified: trunk/ChangeLog trunk/configure.ac trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-defs.h 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-socket.c trunk/src/assuan-uds.c trunk/src/assuan.h.in trunk/src/debug.c trunk/src/debug.h trunk/src/mkheader.c trunk/src/posix-fd-t.inc.h trunk/src/system-w32ce.c trunk/src/system.c trunk/src/sysutils.c trunk/src/w32-fd-t.inc.h trunk/src/w32-types.inc.h trunk/src/w32ce-fd-t.inc.h Log: Changes to allow building the CE version with MSC. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/ChangeLog 2010-11-01 14:57:12 UTC (rev 390) @@ -1,3 +1,11 @@ +2010-11-01 Werner Koch + + * configure.ac: Check for sys/types.h, sys/stat.h, sys/time and + unistd.h + + * contrib/conf-w32ce-msc/build.mk: New. + * contrib/conf-w32ce-msc/config.h: New. + 2010-08-19 Werner Koch * configure.ac (AH_TOP, AH_BOTTOM): New. Define Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/ChangeLog 2010-11-01 14:57:12 UTC (rev 390) @@ -1,3 +1,31 @@ +2010-11-01 Werner Koch + + * assuan-socket.c (S_IRUSR) [W32]: Define if not defined. + + * sysutils.c: Remove include of devload.h. + + * assuan-defs.h [HAVE_WINSOCK2_H]: Include winsock2.h prior to + windows.h. + * assuan-pipe-server.c: Ditto. + * sysutils.c: Ditto. + * assuan-socket-server.c: Ditto. + * assuan-pipe-connect.c: Ditto. + * assuan-socket-connect.c: Ditto. + * assuan-uds.c: Ditto. + * assuan-logging.c: Ditto. + * system-w32ce.c: Ditto. + * assuan-io.c: Ditto. + + * w32-types.inc.h [_MSC_VER]: Define ssize_t and pid_t. + + * w32ce-fd-t.inc.h, w32-fd-t.inc.h, posix-fd-t.inc.h, debug.h: + s/inline/GPG_ERR_INLINE/. + * assuan.h.in: Let mkheader write the sys/types.h and unistd.h + include lines. + * mkheader.c: Change accordingly. + + Guard include of sys/types.h, sys/stat.h, sys/time.h and unistd.h. + 2010-09-17 Werner Koch * assuan-socket-connect.c (INADDR_NONE): New replacement. Fixes Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/configure.ac 2010-11-01 14:57:12 UTC (rev 390) @@ -249,7 +249,8 @@ # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([string.h locale.h sys/uio.h stdint.h inttypes.h]) +AC_CHECK_HEADERS([string.h locale.h sys/uio.h stdint.h inttypes.h \ + sys/types.h sys/stat.h unistd.h sys/time.h]) AC_TYPE_UINTPTR_T AC_TYPE_UINT16_T Added: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk (rev 0) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-01 14:57:12 UTC (rev 390) @@ -0,0 +1,158 @@ +# build.mk - Makefile to build libgpg-error using Visual-C +# Copyright 2010 g10 Code GmbH +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This file is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This is a helper make script to build libgpg-error for WindowsCE +# using the Microsoft Visual C compiler. + +# The target build directry where we run the Visual C compiler/ +# This needs to be an absolute directory name. +targetdir = /home/smb/xppro-gnu/src/libassuan + + +help: + @echo "Run " + @echo " make -f ../contrib/conf-w32ce-msc/build.mk copy-source" + @echo "on the POSIX system and then" + @echo " nmake -f build.mk all" + @echo "on the Windows system" + +ce_defines = -DWINCE -D_WIN32_WCE=0x502 -DUNDER_CE \ + -DWIN32_PLATFORM_PSPC -D_UNICODE -DUNICODE \ + -D_CONSOLE -DARM -D_ARM_ +#-D_DEBUG -DDEBUG + +# Some options of Visual-C: +# -W3 Set warning level 3 +# -Zi Generate debug info +# -Od Disable optimization +# -Gm Enable minimal rebuild (for C++) +# -EHsc Exception handling model sc +# -MTd Create a debug multithreaded executable +# -fp: Floating point behaviour +# -GR- Disable runtime type information +# -Os Favor small code +# -LD Create a DLL +# -Fe Set executable output name (may be only a directory) +CFLAGS = -nologo -W3 -fp:fast -Os $(ce_defines) \ + -DHAVE_CONFIG_H -DDLL_EXPORT -D_CRT_SECURE_NO_WARNINGS \ + -I. -Igpg-extra -I../libgpg-error + +LDFLAGS = + +# Standard source files +sources = \ + assuan.c \ + context.c \ + system.c \ + debug.c \ + conversion.c \ + sysutils.c \ + client.c \ + server.c \ + assuan-error.c \ + assuan-buffer.c \ + assuan-handler.c \ + assuan-inquire.c \ + assuan-listen.c \ + assuan-pipe-server.c \ + assuan-socket-server.c \ + assuan-pipe-connect.c \ + assuan-socket-connect.c \ + assuan-uds.c \ + assuan-logging.c \ + assuan-socket.c \ + system-w32ce.c \ + assuan-io.c \ + putc_unlocked.c \ + memrchr.c \ + stpcpy.c \ + setenv.c \ + vasprintf.c \ + assuan-defs.h \ + debug.h \ + libassuan.def + +# The object files we need to create from sources. +objs = \ + assuan.obj \ + context.obj \ + system.obj \ + debug.obj \ + conversion.obj \ + sysutils.obj \ + client.obj \ + server.obj \ + assuan-error.obj \ + assuan-buffer.obj \ + assuan-handler.obj \ + assuan-inquire.obj \ + assuan-listen.obj \ + assuan-pipe-server.obj \ + assuan-socket-server.obj \ + assuan-pipe-connect.obj \ + assuan-socket-connect.obj \ + assuan-uds.obj \ + assuan-logging.obj \ + assuan-socket.obj \ + system-w32ce.obj \ + assuan-io.obj \ + putc_unlocked.obj \ + memrchr.obj \ + stpcpy.obj \ + setenv.obj \ + vasprintf.obj + + +# Sources files in this directory inclduing this Makefile +conf_sources = \ + build.mk \ + config.h + +# Source files built by running the standard build system. +built_sources = \ + assuan.h + +copy-static-source: + @if [ ! -f ./assuan-defs.h ]; then \ + echo "Please cd to the src/ directory first"; \ + exit 1; \ + fi + cp -t $(targetdir) $(sources); + cd ../contrib/conf-w32ce-msc ; cp -t $(targetdir) $(conf_sources) + + +copy-built-source: + @if [ ! -f ./assuan.h ]; then \ + echo "Please build using ./autogen.sh --build-w32ce first"; \ + exit 1; \ + fi + cp -t $(targetdir) $(built_sources) + +copy-source: copy-static-source copy-built-source + + +.c.obj: + $(CC) $(CFLAGS) -c $< + +all: $(sources) $(conf_sources) $(built_sources) $(objs) + link /DLL /IMPLIB:libassuan-0-msc.lib \ + /OUT:libassuan-0-msc.dll \ + /DEF:libassuan.def /NOLOGO /MANIFEST:NO \ + /NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE:NO \ + $(objs) \ + coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \ + commctrl.lib /subsystem:windowsce,5.02 + +# Note that install needs to be run on the POSIX platform and the all +# is only to make sure we build everything; it won't compile anything +# because Visual-C is probably not installed on that platform. +install: all + @echo fixme Install the files Property changes on: trunk/contrib/conf-w32ce-msc/build.mk ___________________________________________________________________ Added: svn:executable + * Added: trunk/contrib/conf-w32ce-msc/config.h =================================================================== --- trunk/contrib/conf-w32ce-msc/config.h (rev 0) +++ trunk/contrib/conf-w32ce-msc/config.h 2010-11-01 14:57:12 UTC (rev 390) @@ -0,0 +1,184 @@ +/* config.h for building with Visual-C for WindowsCE. + * Copyright 2010 g10 Code GmbH + * + * This file is free software; as a special exception the author gives + * unlimited permission to copy and/or distribute it, with or without + * modifications, as long as this notice is preserved. + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* This file was originally created by running + * ./autogen.sh --build-w32ce + * on svn revision 389 (libassuan 2.0.2-svn389) and then adjusted to work + * with Visual-C. + */ + +#ifndef _ASSUAN_CONFIG_H_INCLUDED +#define _ASSUAN_CONFIG_H_INCLUDED + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.0.2-svn389-msc1" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libassuan " PACKAGE_VERSION + +/* Name of this package */ +#define PACKAGE "libassuan" + +/* Bug report address */ +#define PACKAGE_BUGREPORT "bug-libassuan at gnupg.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libassuan" + + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libassuan" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Version of this package */ +#define VERSION PACKAGE_VERSION + + +/* Enable gpg-error's strerror macro under W32CE. */ +#define GPG_ERR_ENABLE_ERRNO_MACROS 1 + + +/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you + don't. */ +#define HAVE_DECL_SYS_SIGLIST 0 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2) + with special properties like no file modes */ +#define HAVE_DOSISH_SYSTEM 1 + +/* Define to 1 if you have the `flockfile' function. */ +/* #undef HAVE_FLOCKFILE */ + +/* Define to 1 if you have the `fopencookie' function. */ +/* #undef HAVE_FOPENCOOKIE */ + +/* Define to 1 if you have the `funlockfile' function. */ +/* #undef HAVE_FUNLOCKFILE */ + +/* Define to 1 if you have the `funopen' function. */ +/* #undef HAVE_FUNOPEN */ + +/* Define to 1 if you have the `inet_pton' function. */ +/* #undef HAVE_INET_PTON */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_INTTYPES_H */ + +/* Define to 1 if you have the `isascii' function. */ +#define HAVE_ISASCII 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LOCALE_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +/* #undef HAVE_MEMRCHR */ + +/* Define to 1 if you have the `nanosleep' function in libc. */ +/* #undef HAVE_NANOSLEEP */ + +/* Define to 1 if you have the `putc_unlocked' function. */ +/* #undef HAVE_PUTC_UNLOCKED */ + +/* Define to 1 if you have the `setenv' function. */ +/* #undef HAVE_SETENV */ + +/* Defined if SO_PEERCRED is supported (Linux specific) */ +/* #undef HAVE_SO_PEERCRED */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +/* #undef HAVE_STPCPY */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STRINGS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STAT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TYPES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UIO_H */ + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UNISTD_H */ + +/* Define to 1 if you have the `vasprintf' function. */ +/* #undef HAVE_VASPRINTF */ + +/* Defined if we run on WindowsCE */ +#define HAVE_W32CE_SYSTEM 1 + +/* Defined if we run on a W32 API based system */ +#define HAVE_W32_SYSTEM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WINSOCK2_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WS2TCPIP_H 1 + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Defined if descriptor passing is supported */ +/* #undef USE_DESCRIPTOR_PASSING */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif + + +/* snprintf is not part of oldnames.lib thus we redefine it here. */ +#define snprintf _snprintf + + +#endif /*_ASSUAN_CONFIG_H_INCLUDED*/ + Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-buffer.c 2010-11-01 14:57:12 UTC (rev 390) @@ -22,10 +22,12 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #ifdef HAVE_W32_SYSTEM -#include +# include #endif #include "assuan-defs.h" Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-defs.h 2010-11-01 14:57:12 UTC (rev 390) @@ -21,14 +21,22 @@ #ifndef ASSUAN_DEFS_H #define ASSUAN_DEFS_H -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #ifndef HAVE_W32_SYSTEM -#include -#include +# include +# include #else -#include +# ifdef HAVE_WINSOCK2_H +# /* Avoid inclusion of winsock.h via windows.h. */ +# include +# endif +# include #endif -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include "assuan.h" Modified: trunk/src/assuan-io.c =================================================================== --- trunk/src/assuan-io.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-io.c 2010-11-01 14:57:12 UTC (rev 390) @@ -22,14 +22,23 @@ #endif #include -#include -#include +#ifdef HAVE_SYS_TIME_H +# include +#endif +#ifdef HAVE_SYS_TYPES_H +# include +#endif #ifdef HAVE_SYS_SOCKET_H # include #endif -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #ifdef HAVE_W32_SYSTEM +# ifdef HAVE_WINSOCK2_H +# include +# endif # include #else # include Modified: trunk/src/assuan-listen.c =================================================================== --- trunk/src/assuan-listen.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-listen.c 2010-11-01 14:57:12 UTC (rev 390) @@ -24,7 +24,9 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include "assuan-defs.h" Modified: trunk/src/assuan-logging.c =================================================================== --- trunk/src/assuan-logging.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-logging.c 2010-11-01 14:57:12 UTC (rev 390) @@ -26,7 +26,10 @@ #include #include #ifdef HAVE_W32_SYSTEM -#include +# ifdef HAVE_WINSOCK2_H +# include +# endif +# include #endif /*HAVE_W32_SYSTEM*/ #include #include Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-pipe-connect.c 2010-11-01 14:57:12 UTC (rev 390) @@ -29,14 +29,21 @@ #ifndef HAVE_DOSISH_SYSTEM # include #endif -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #ifndef HAVE_W32_SYSTEM -#include +# include #else -#include +# ifdef HAVE_WINSOCK2_H +# include +# endif +# include #endif #include "assuan-defs.h" Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-pipe-server.c 2010-11-01 14:57:12 UTC (rev 390) @@ -23,12 +23,21 @@ #include #include -#include -#include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif #ifdef HAVE_W32_SYSTEM -#include -#include +# ifdef HAVE_WINSOCK2_H +# include +# endif +# include +# include #endif #include "assuan-defs.h" Modified: trunk/src/assuan-socket-connect.c =================================================================== --- trunk/src/assuan-socket-connect.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-socket-connect.c 2010-11-01 14:57:12 UTC (rev 390) @@ -26,9 +26,16 @@ #ifdef HAVE_STDINT_H # include #endif -#include -#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_TYPES_H +# include +#endif #ifdef HAVE_W32_SYSTEM +# ifdef HAVE_WINSOCK2_H +# include +# endif # include #else # include Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-socket-server.c 2010-11-01 14:57:12 UTC (rev 390) @@ -24,9 +24,16 @@ #include #include #include -#include -#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_TYPES_H +# include +#endif #ifdef HAVE_W32_SYSTEM +# ifdef HAVE_WINSOCK2_H +# include +# endif # include # if HAVE_SYS_SOCKET_H # include Modified: trunk/src/assuan-socket.c =================================================================== --- trunk/src/assuan-socket.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-socket.c 2010-11-01 14:57:12 UTC (rev 390) @@ -24,16 +24,18 @@ #include #include #ifdef HAVE_W32_SYSTEM -#define WIN32_LEAN_AND_MEAN -#include -#include -#include +# define WIN32_LEAN_AND_MEAN +# include +# include +# include #else -#include -#include +# include +# include #endif #include -#include +#ifdef HAVE_SYS_STAT_H +# include +#endif #include #include @@ -53,6 +55,10 @@ #endif #ifdef HAVE_W32_SYSTEM +#ifndef S_IRUSR +# define S_IRUSR 0 +# define S_IWUSR 0 +#endif #ifndef S_IRGRP # define S_IRGRP 0 # define S_IWGRP 0 Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan-uds.c 2010-11-01 14:57:12 UTC (rev 390) @@ -25,17 +25,24 @@ #include #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #ifndef HAVE_W32_SYSTEM -#include -#include +# include +# include #else -#include +# ifdef HAVE_WINSOCK2_H +# include +# endif +# include #endif #if HAVE_SYS_UIO_H #include #endif -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include #include Modified: trunk/src/assuan.h.in =================================================================== --- trunk/src/assuan.h.in 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/assuan.h.in 2010-11-01 14:57:12 UTC (rev 390) @@ -24,8 +24,8 @@ #define ASSUAN_H #include -#include -#include + at include:sys/types.h@ + at include:unistd.h@ #include #ifndef _ASSUAN_NO_SOCKET_WRAPPER Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/debug.c 2010-11-01 14:57:12 UTC (rev 390) @@ -26,13 +26,15 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include #ifndef HAVE_DOSISH_SYSTEM -# include -# include -# include +# include +# include +# include #endif #include Modified: trunk/src/debug.h =================================================================== --- trunk/src/debug.h 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/debug.h 2010-11-01 14:57:12 UTC (rev 390) @@ -39,10 +39,10 @@ /* Remove path components from filenames (i.e. __FILE__) for cleaner logs. */ -static inline const char *_assuan_debug_srcname (const char *file) +static GPG_ERR_INLINE const char *_assuan_debug_srcname (const char *file) ASSUAN_GCC_A_PURE; -static inline const char * +static GPG_ERR_INLINE const char * _assuan_debug_srcname (const char *file) { const char *s = strrchr (file, '/'); Modified: trunk/src/mkheader.c =================================================================== --- trunk/src/mkheader.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/mkheader.c 2010-11-01 14:57:12 UTC (rev 390) @@ -82,6 +82,24 @@ else include_file (fname, lnr, "posix-includes.inc.h"); } + else if (!strcmp (tag, "include:sys/types.h")) + { + if (!strcmp (host_os, "mingw32ce")) + fputs ("#ifdef __MINGW32CE__\n" + "# include \n" + "#endif\n", stdout); + else + fputs ("#include \n", stdout); + } + else if (!strcmp (tag, "include:unistd.h")) + { + if (!strcmp (host_os, "mingw32ce")) + fputs ("#ifdef __MINGW32CE__\n" + "# include \n" + "#endif\n", stdout); + else + fputs ("#include \n", stdout); + } else if (!strcmp (tag, "include:types")) { if (strstr (host_os, "mingw32")) Modified: trunk/src/posix-fd-t.inc.h =================================================================== --- trunk/src/posix-fd-t.inc.h 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/posix-fd-t.inc.h 2010-11-01 14:57:12 UTC (rev 390) @@ -23,7 +23,7 @@ typedef int assuan_fd_t; #define ASSUAN_INVALID_FD (-1) #define ASSUAN_INVALID_PID ((pid_t) -1) -static inline assuan_fd_t +static GPG_ERR_INLINE assuan_fd_t assuan_fd_from_posix_fd (int fd) { return fd; Modified: trunk/src/system-w32ce.c =================================================================== --- trunk/src/system-w32ce.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/system-w32ce.c 2010-11-01 14:57:12 UTC (rev 390) @@ -26,6 +26,9 @@ #include #include #include +# ifdef HAVE_WINSOCK2_H +# include +# endif #include #include #include Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/system.c 2010-11-01 14:57:12 UTC (rev 390) @@ -24,8 +24,10 @@ #include #include -/* Solaris 8 needs sys/types.h before time.h. */ -#include +#ifdef HAVE_SYS_TYPES_H + /* Solaris 8 needs sys/types.h before time.h. */ +# include +#endif #include #include Modified: trunk/src/sysutils.c =================================================================== --- trunk/src/sysutils.c 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/sysutils.c 2010-11-01 14:57:12 UTC (rev 390) @@ -25,10 +25,12 @@ #include #include #ifdef HAVE_W32_SYSTEM -#include +# ifdef HAVE_WINSOCK2_H +# include +# endif +# include # ifdef HAVE_W32CE_SYSTEM # include -# include # endif /*HAVE_W32CE_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/ Modified: trunk/src/w32-fd-t.inc.h =================================================================== --- trunk/src/w32-fd-t.inc.h 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/w32-fd-t.inc.h 2010-11-01 14:57:12 UTC (rev 390) @@ -27,7 +27,7 @@ typedef void *assuan_fd_t; #define ASSUAN_INVALID_FD ((void*)(-1)) #define ASSUAN_INVALID_PID ((pid_t) -1) -static inline assuan_fd_t +static GPG_ERR_INLINE assuan_fd_t assuan_fd_from_posix_fd (int fd) { if (fd < 0) Modified: trunk/src/w32-types.inc.h =================================================================== --- trunk/src/w32-types.inc.h 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/w32-types.inc.h 2010-11-01 14:57:12 UTC (rev 390) @@ -20,4 +20,10 @@ ## This file is included by the mkheader tool. Lines starting with ## a double hash mark are not copied to the destination file. typedef void *assuan_msghdr_t; + +#ifdef _MSC_VER + typedef long ssize_t; + typedef int pid_t; +#endif + ##EOF## Modified: trunk/src/w32ce-fd-t.inc.h =================================================================== --- trunk/src/w32ce-fd-t.inc.h 2010-10-11 19:20:25 UTC (rev 389) +++ trunk/src/w32ce-fd-t.inc.h 2010-11-01 14:57:12 UTC (rev 390) @@ -23,7 +23,7 @@ typedef void *assuan_fd_t; #define ASSUAN_INVALID_FD ((void*)(-1)) #define ASSUAN_INVALID_PID ((pid_t) -1) -static inline assuan_fd_t +static GPG_ERR_INLINE assuan_fd_t assuan_fd_from_posix_fd (int fd) { return (assuan_fd_t)(fd); From cvs at cvs.gnupg.org Mon Nov 1 16:08:21 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 01 Nov 2010 16:08:21 +0100 Subject: [svn] gpg-error - r261 - trunk/contrib/conf-w32ce-msc Message-ID: Author: wk Date: 2010-11-01 16:08:20 +0100 (Mon, 01 Nov 2010) New Revision: 261 Modified: trunk/contrib/conf-w32ce-msc/build.mk Log: Chnage name of libgpg-error DLL. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-10-31 10:30:16 UTC (rev 260) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-01 15:08:20 UTC (rev 261) @@ -102,7 +102,8 @@ $(CC) $(CFLAGS) -c strerror.c $(CC) $(CFLAGS) -c code-to-errno.c $(CC) $(CFLAGS) -c code-from-errno.c - link.exe /DLL /IMPLIB:libgpg-error-0.lib /OUT:libgpg-error-0.dll \ + link.exe /DLL /IMPLIB:libgpg-error-0-msc.lib \ + /OUT:libgpg-error-0-msc.dll \ /DEF:gpg-error.def /NOLOGO /MANIFEST:NO \ /NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE:NO \ w32-gettext.obj init.obj strsource.obj strerror.obj \ From cvs at cvs.gnupg.org Mon Nov 1 16:48:53 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 01 Nov 2010 16:48:53 +0100 Subject: [svn] gpg-error - r262 - in trunk: . src Message-ID: Author: marcus Date: 2010-11-01 16:48:52 +0100 (Mon, 01 Nov 2010) New Revision: 262 Modified: trunk/ChangeLog trunk/src/w32-gettext.c Log: 2010-11-01 Marcus Brinkmann * src/w32-gettext.c (CreateFileA): Rename to ... (MyCreateFileA): ... this, but provide macro CreateFileA. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-01 15:08:20 UTC (rev 261) +++ trunk/ChangeLog 2010-11-01 15:48:52 UTC (rev 262) @@ -1,3 +1,8 @@ +2010-11-01 Marcus Brinkmann + + * src/w32-gettext.c (CreateFileA): Rename to ... + (MyCreateFileA): ... this, but provide macro CreateFileA. + 2010-10-31 Werner Koch * src/init.c (abort): Use TerminateProcess; exit would call atexit Modified: trunk/src/w32-gettext.c =================================================================== --- trunk/src/w32-gettext.c 2010-11-01 15:08:20 UTC (rev 261) +++ trunk/src/w32-gettext.c 2010-11-01 15:48:52 UTC (rev 262) @@ -58,7 +58,7 @@ static wchar_t *utf8_to_wchar (const char *string, size_t length, size_t *retlen); static HANDLE -CreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode, +MyCreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) @@ -81,6 +81,8 @@ SetLastError (err); return result; } +#undef CreateFileA +#define CreateFileA MyCreateFileA #endif From cvs at cvs.gnupg.org Mon Nov 1 17:23:05 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 01 Nov 2010 17:23:05 +0100 Subject: [svn] assuan - r391 - trunk Message-ID: Author: marcus Date: 2010-11-01 17:23:05 +0100 (Mon, 01 Nov 2010) New Revision: 391 Modified: trunk/ChangeLog trunk/configure.ac Log: 2010-11-01 Marcus Brinkmann * configure.ac: Check for fcntl.h. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-01 14:57:12 UTC (rev 390) +++ trunk/ChangeLog 2010-11-01 16:23:05 UTC (rev 391) @@ -1,3 +1,7 @@ +2010-11-01 Marcus Brinkmann + + * configure.ac: Check for fcntl.h. + 2010-11-01 Werner Koch * configure.ac: Check for sys/types.h, sys/stat.h, sys/time and Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-11-01 14:57:12 UTC (rev 390) +++ trunk/configure.ac 2010-11-01 16:23:05 UTC (rev 391) @@ -250,7 +250,7 @@ # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([string.h locale.h sys/uio.h stdint.h inttypes.h \ - sys/types.h sys/stat.h unistd.h sys/time.h]) + sys/types.h sys/stat.h unistd.h sys/time.h fcntl.h]) AC_TYPE_UINTPTR_T AC_TYPE_UINT16_T From cvs at cvs.gnupg.org Mon Nov 1 17:23:35 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 01 Nov 2010 17:23:35 +0100 Subject: [svn] assuan - r392 - in trunk: contrib/conf-w32ce-msc src Message-ID: Author: marcus Date: 2010-11-01 17:23:33 +0100 (Mon, 01 Nov 2010) New Revision: 392 Modified: trunk/contrib/conf-w32ce-msc/build.mk trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-inquire.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-pipe-server.c trunk/src/assuan-socket.c trunk/src/assuan-uds.c trunk/src/system-w32ce.c trunk/src/system.c trunk/src/sysutils.c trunk/src/w32-includes.inc.h Log: 2010-11-01 Marcus Brinkmann * configure.ac: Check for fcntl.h. 2010-11-01 Marcus Brinkmann * assuan-socket.c, assuan-uds.c, system.c, assuan-pipe-server.c, assuan-pipe-connect.c [!HAVE_FCNTL_H]: Don't include fcntl.h. * assuan-buffer.c [!HAVE_W32CE_SYSTEM]: Do not include process.h. * assuan-socket.c [!HAVE_W32CE_SYSTEM]: Do not include io.h. * w32-includes.inc.h: Include winsock2.h before ws2tcpip.h. * sysutils.c (w32_read_registry): Replace goto label "leave" by "out" (as leave is defined by some Windows header file). * assuan-inquire.c: Likewise. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/ChangeLog 2010-11-01 16:23:33 UTC (rev 392) @@ -1,3 +1,14 @@ +2010-11-01 Marcus Brinkmann + + * assuan-socket.c, assuan-uds.c, system.c, assuan-pipe-server.c, + assuan-pipe-connect.c [!HAVE_FCNTL_H]: Don't include fcntl.h. + * assuan-buffer.c [!HAVE_W32CE_SYSTEM]: Do not include process.h. + * assuan-socket.c [!HAVE_W32CE_SYSTEM]: Do not include io.h. + * w32-includes.inc.h: Include winsock2.h before ws2tcpip.h. + * sysutils.c (w32_read_registry): Replace goto label "leave" by + "out" (as leave is defined by some Windows header file). + * assuan-inquire.c: Likewise. + 2010-11-01 Werner Koch * assuan-socket.c (S_IRUSR) [W32]: Define if not defined. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-01 16:23:33 UTC (rev 392) @@ -43,7 +43,7 @@ # -Fe Set executable output name (may be only a directory) CFLAGS = -nologo -W3 -fp:fast -Os $(ce_defines) \ -DHAVE_CONFIG_H -DDLL_EXPORT -D_CRT_SECURE_NO_WARNINGS \ - -I. -Igpg-extra -I../libgpg-error + -I. -I../../libgpg-error/src -I../../libgpg-error/src/gpg-extra LDFLAGS = Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/assuan-buffer.c 2010-11-01 16:23:33 UTC (rev 392) @@ -27,8 +27,10 @@ #endif #include #ifdef HAVE_W32_SYSTEM +#ifndef HAVE_W32CE_SYSTEM # include #endif +#endif #include "assuan-defs.h" Modified: trunk/src/assuan-inquire.c =================================================================== --- trunk/src/assuan-inquire.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/assuan-inquire.c 2010-11-01 16:23:33 UTC (rev 392) @@ -168,7 +168,7 @@ strcpy (stpcpy (cmdbuf, "INQUIRE "), keyword); rc = assuan_write_line (ctx, cmdbuf); if (rc) - goto leave; + goto out; for (;;) { @@ -178,7 +178,7 @@ rc = _assuan_read_line (ctx); while (_assuan_error_is_eagain (ctx, rc)); if (rc) - goto leave; + goto out; line = (unsigned char *) ctx->inbound.line; linelen = ctx->inbound.linelen; } @@ -196,13 +196,13 @@ && (line[2] == 'N' || line[2] == 'n')) { rc = _assuan_error (ctx, GPG_ERR_ASS_CANCELED); - goto leave; + goto out; } if ((line[0] != 'D' && line[0] != 'd') || line[1] != ' ' || nodataexpected) { rc = _assuan_error (ctx, GPG_ERR_ASS_UNEXPECTED_CMD); - goto leave; + goto out; } if (linelen < 3) continue; @@ -229,7 +229,7 @@ if (mb.too_large) { rc = _assuan_error (ctx, GPG_ERR_ASS_TOO_MUCH_DATA); - goto leave; + goto out; } } @@ -240,7 +240,7 @@ rc = _assuan_error (ctx, gpg_err_code_from_syserror ()); } - leave: + out: if (!nodataexpected) free_membuf (ctx, &mb); ctx->in_inquire = 0; @@ -281,7 +281,7 @@ && (line[2] == 'N' || line[2] == 'n')) { rc = _assuan_error (ctx, GPG_ERR_ASS_CANCELED); - goto leave; + goto out; } if ((line[0] == 'E'||line[0] == 'e') && (line[1] == 'N' || line[1] == 'n') @@ -289,13 +289,13 @@ && (!line[3] || line[3] == ' ')) { rc = 0; - goto leave; + goto out; } if ((line[0] != 'D' && line[0] != 'd') || line[1] != ' ' || mb == NULL) { rc = _assuan_error (ctx, GPG_ERR_ASS_UNEXPECTED_CMD); - goto leave; + goto out; } if (linelen < 3) @@ -323,12 +323,12 @@ if (mb->too_large) { rc = _assuan_error (ctx, GPG_ERR_ASS_TOO_MUCH_DATA); - goto leave; + goto out; } return 0; - leave: + out: { size_t buf_len = 0; unsigned char *buf = NULL; Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/assuan-pipe-connect.c 2010-11-01 16:23:33 UTC (rev 392) @@ -33,7 +33,9 @@ # include #endif #include +#ifdef HAVE_FCNTL_H #include +#endif #ifdef HAVE_SYS_TYPES_H # include #endif Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/assuan-pipe-server.c 2010-11-01 16:23:33 UTC (rev 392) @@ -37,8 +37,10 @@ # include # endif # include +#ifdef HAVE_FCNTL_H # include #endif +#endif #include "assuan-defs.h" #include "debug.h" Modified: trunk/src/assuan-socket.c =================================================================== --- trunk/src/assuan-socket.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/assuan-socket.c 2010-11-01 16:23:33 UTC (rev 392) @@ -27,7 +27,9 @@ # define WIN32_LEAN_AND_MEAN # include # include +#ifndef HAVE_W32CE_SYSTEM # include +#endif #else # include # include @@ -36,7 +38,9 @@ #ifdef HAVE_SYS_STAT_H # include #endif +#ifdef HAVE_FCNTL_H #include +#endif #include #include "assuan-defs.h" Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/assuan-uds.c 2010-11-01 16:23:33 UTC (rev 392) @@ -43,7 +43,9 @@ #ifdef HAVE_UNISTD_H # include #endif +#ifdef HAVE_FCNTL_H #include +#endif #include #include Modified: trunk/src/system-w32ce.c =================================================================== --- trunk/src/system-w32ce.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/system-w32ce.c 2010-11-01 16:23:33 UTC (rev 392) @@ -25,7 +25,6 @@ #include #include #include -#include # ifdef HAVE_WINSOCK2_H # include # endif Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/system.c 2010-11-01 16:23:33 UTC (rev 392) @@ -29,7 +29,9 @@ # include #endif #include +#ifdef HAVE_FCNTL_H #include +#endif #include "assuan-defs.h" #include "debug.h" Modified: trunk/src/sysutils.c =================================================================== --- trunk/src/sysutils.c 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/sysutils.c 2010-11-01 16:23:33 UTC (rev 392) @@ -70,33 +70,33 @@ nbytes = 1; if (RegQueryValueEx (handle, name, 0, NULL, NULL, &nbytes)) - goto leave; + goto out; buffer = malloc ((n=nbytes+2)); if (!buffer) - goto leave; + goto out; if (RegQueryValueEx (handle, name, 0, NULL, (PBYTE)buffer, &n)) { free (buffer); buffer = NULL; - goto leave; + goto out; } n = WideCharToMultiByte (CP_UTF8, 0, buffer, nbytes, NULL, 0, NULL, NULL); if (n < 0 || (n+1) <= 0) - goto leave; + goto out; result = malloc (n+1); if (!result) - goto leave; + goto out; n = WideCharToMultiByte (CP_UTF8, 0, buffer, nbytes, result, n, NULL, NULL); if (n < 0) { free (result); result = NULL; - goto leave; + goto out; } result[n] = 0; - leave: + out: free (buffer); RegCloseKey (handle); return result; Modified: trunk/src/w32-includes.inc.h =================================================================== --- trunk/src/w32-includes.inc.h 2010-11-01 16:23:05 UTC (rev 391) +++ trunk/src/w32-includes.inc.h 2010-11-01 16:23:33 UTC (rev 392) @@ -19,5 +19,6 @@ ## ## This file is included by the mkheader tool. Lines starting with ## a double hash mark are not copied to the destination file. +#include #include ##EOF## From cvs at cvs.gnupg.org Mon Nov 1 20:12:33 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 01 Nov 2010 20:12:33 +0100 Subject: [svn] assuan - r393 - trunk/src Message-ID: Author: wk Date: 2010-11-01 20:12:32 +0100 (Mon, 01 Nov 2010) New Revision: 393 Modified: trunk/src/ChangeLog trunk/src/assuan-socket.c Log: Replace open/fdopen stuff by CreateFile et al. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-01 16:23:33 UTC (rev 392) +++ trunk/src/ChangeLog 2010-11-01 19:12:32 UTC (rev 393) @@ -1,3 +1,9 @@ +2010-11-01 Werner Koch + + * assuan-socket.c (_assuan_sock_bind): Replace open/fdopen by + CreateFile for building with MSC for W32CE. + (utf8_to_wchar, MyCreateFile, MyDeleteFile) [W32CE]: New. + 2010-11-01 Marcus Brinkmann * assuan-socket.c, assuan-uds.c, system.c, assuan-pipe-server.c, Modified: trunk/src/assuan-socket.c =================================================================== --- trunk/src/assuan-socket.c 2010-11-01 16:23:33 UTC (rev 392) +++ trunk/src/assuan-socket.c 2010-11-01 19:12:32 UTC (rev 393) @@ -71,6 +71,86 @@ #ifdef HAVE_W32_SYSTEM + +#ifdef HAVE_W32CE_SYSTEM +static wchar_t * +utf8_to_wchar (const char *string) +{ + int n; + size_t nbytes; + wchar_t *result; + + if (!string) + return NULL; + + n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0); + if (n < 0) + return NULL; + + nbytes = (size_t)(n+1) * sizeof(*result); + if (nbytes / sizeof(*result) != (n+1)) + { + SetLastError (ERROR_INVALID_PARAMETER); + return NULL; + } + result = malloc (nbytes); + if (!result) + return NULL; + + n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n); + if (n < 0) + { + n = GetLastError (); + free (result); + result = NULL; + SetLastError (n); + } + return result; +} + +static HANDLE +MyCreateFile (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile) +{ + wchar_t *filename; + HANDLE result; + int err; + + filename = utf8_to_wchar (lpFileName); + if (!filename) + return INVALID_HANDLE_VALUE; + + result = CreateFileW (filename, dwDesiredAccess, dwSharedMode, + lpSecurityAttributes, dwCreationDisposition, + dwFlagsAndAttributes, hTemplateFile); + err = GetLastError (); + free (filename); + SetLastError (err); + return result; +} +static int +MyDeleteFile (LPCSTR lpFileName) +{ + wchar_t *filename; + int result, err; + + filename = utf8_to_wchar (lpFileName); + if (!filename) + return 0; + + result = DeleteFileW (filename); + err = GetLastError (); + free (filename); + SetLastError (err); + return result; +} +#else /*!HAVE_W32CE_SYSTEM*/ +#define MyCreateFile CreateFileA +#define MyDeleteFile DeleteFileA +#endif /*!HAVE_W32CE_SYSTEM*/ + int _assuan_sock_wsa2errno (int err) { @@ -238,11 +318,12 @@ { struct sockaddr_in myaddr; struct sockaddr_un *unaddr; - int filefd; - FILE *fp; + HANDLE filehd; int len = sizeof myaddr; int rc; char nonce[16]; + char tmpbuf[33+16]; + DWORD nwritten; if (get_nonce (nonce, 16)) return -1; @@ -253,23 +334,19 @@ myaddr.sin_family = AF_INET; myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - filefd = open (unaddr->sun_path, - (O_WRONLY|O_CREAT|O_EXCL|O_BINARY), - (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)); - if (filefd == -1) + filehd = MyCreateFile (unaddr->sun_path, + GENERIC_WRITE, + FILE_SHARE_READ, + NULL, + CREATE_NEW, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (filehd == INVALID_HANDLE_VALUE) { - if (errno == EEXIST) + if (GetLastError () == ERROR_FILE_EXISTS) gpg_err_set_errno (WSAEADDRINUSE); return -1; } - fp = fdopen (filefd, "wb"); - if (!fp) - { - int save_e = errno; - close (filefd); - gpg_err_set_errno (save_e); - return -1; - } rc = bind (HANDLE2SOCKET (sockfd), (struct sockaddr *)&myaddr, len); if (!rc) @@ -278,15 +355,24 @@ if (rc) { int save_e = errno; - fclose (fp); - DeleteFile (unaddr->sun_path); + CloseHandle (filehd); + MyDeleteFile (unaddr->sun_path); gpg_err_set_errno (save_e); return rc; } - fprintf (fp, "%d\n", ntohs (myaddr.sin_port)); - fwrite (nonce, 16, 1, fp); - fclose (fp); - + snprintf (tmpbuf, sizeof tmpbuf, "%d\n", ntohs (myaddr.sin_port)); + len = strlen (tmpbuf); + memcpy (tmpbuf+len, nonce,16); + len += 16; + + if (!WriteFile (filehd, tmpbuf, len, &nwritten, NULL)) + { + CloseHandle (filehd); + MyDeleteFile (unaddr->sun_path); + gpg_err_set_errno (EIO); + return -1; + } + CloseHandle (filehd); return 0; } else From cvs at cvs.gnupg.org Mon Nov 1 20:25:21 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 01 Nov 2010 20:25:21 +0100 Subject: [svn] assuan - r394 - in trunk: . contrib Message-ID: Author: wk Date: 2010-11-01 20:25:20 +0100 (Mon, 01 Nov 2010) New Revision: 394 Added: trunk/contrib/ChangeLog Modified: trunk/ChangeLog Log: New ChangeLog file for contrib. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-01 19:12:32 UTC (rev 393) +++ trunk/ChangeLog 2010-11-01 19:25:20 UTC (rev 394) @@ -7,9 +7,6 @@ * configure.ac: Check for sys/types.h, sys/stat.h, sys/time and unistd.h - * contrib/conf-w32ce-msc/build.mk: New. - * contrib/conf-w32ce-msc/config.h: New. - 2010-08-19 Werner Koch * configure.ac (AH_TOP, AH_BOTTOM): New. Define Added: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog (rev 0) +++ trunk/contrib/ChangeLog 2010-11-01 19:25:20 UTC (rev 394) @@ -0,0 +1,4 @@ +2010-11-01 Werner Koch + + * conf-w32ce-msc/build.mk: New. + * conf-w32ce-msc/config.h: New. From cvs at cvs.gnupg.org Mon Nov 1 20:27:31 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 01 Nov 2010 20:27:31 +0100 Subject: [svn] gpg-error - r263 - in trunk: . contrib Message-ID: Author: wk Date: 2010-11-01 20:27:30 +0100 (Mon, 01 Nov 2010) New Revision: 263 Added: trunk/contrib/ChangeLog Modified: trunk/ChangeLog Log: New ChangeLog file Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-01 15:48:52 UTC (rev 262) +++ trunk/ChangeLog 2010-11-01 19:27:30 UTC (rev 263) @@ -8,7 +8,7 @@ * src/init.c (abort): Use TerminateProcess; exit would call atexit functions. -2010-10-29 Marcus Brinkmann +2010-10-29 Marcus Brinkmann * src/w32-gettext.c: Guard include of . Do not include . @@ -21,9 +21,6 @@ 2010-10-28 Werner Koch - * contrib/conf-w32ce-msc/build.mk: New. - * contrib/conf-w32ce-msc/config.h: New. - * src/mkstrtable.awk: s/inline/GPG_ERR_INLINE/ * src/w32-gettext.c: Include gpg-error.h and replace all __inline__ by GPG_ERR_INLINE. Added: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog (rev 0) +++ trunk/contrib/ChangeLog 2010-11-01 19:27:30 UTC (rev 263) @@ -0,0 +1,5 @@ +2010-10-28 Werner Koch + + * contrib/conf-w32ce-msc/build.mk: New. + * contrib/conf-w32ce-msc/config.h: New. + From cvs at cvs.gnupg.org Tue Nov 2 09:58:12 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 02 Nov 2010 09:58:12 +0100 Subject: [svn] gpg-error - r264 - in trunk: . contrib contrib/conf-w32ce-msc Message-ID: Author: wk Date: 2010-11-02 09:58:11 +0100 (Tue, 02 Nov 2010) New Revision: 264 Modified: trunk/ChangeLog trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk Log: Chnage directory layout for MSC builds Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-01 19:27:30 UTC (rev 263) +++ trunk/ChangeLog 2010-11-02 08:58:11 UTC (rev 264) @@ -1,4 +1,4 @@ -2010-11-01 Marcus Brinkmann +2010-11-01 Marcus Brinkmann * src/w32-gettext.c (CreateFileA): Rename to ... (MyCreateFileA): ... this, but provide macro CreateFileA. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-01 19:27:30 UTC (rev 263) +++ trunk/contrib/ChangeLog 2010-11-02 08:58:11 UTC (rev 264) @@ -1,3 +1,8 @@ +2010-11-02 Werner Koch + + * conf-w32ce-msc/build.mk: Change directory layout. Provide + install target. + 2010-10-28 Werner Koch * contrib/conf-w32ce-msc/build.mk: New. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-01 19:27:30 UTC (rev 263) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-02 08:58:11 UTC (rev 264) @@ -12,16 +12,29 @@ # This is a helper make script to build libgpg-error for WindowsCE # using the Microsoft Visual C compiler. -# The target build directry where we run the Visual C compiler/ -# This needs to be an absolute directory name. -targetdir = /home/smb/xppro-gnu/src/libgpg-error +# The target build directory where we run the Visual C compiler/ This +# needs to be an absolute directory name. Further we expect this +# structure of the tree: +# +# TARGET/src - Source directories: One directory for each project +# /bin - Installed DLLs +# /lib - Installed import libs. +# /include - Instaled header files. +targetdir = /home/smb/xppro-gnu +targetsrc = $(targetdir)/src +# Install directories (relative) +bindir = ../../bin +libdir = ../../lib +incdir = ../../include + help: @echo "Run " @echo " make -f ../contrib/conf-w32ce-msc/build.mk copy-source" @echo "on the POSIX system and then" @echo " nmake -f build.mk all" + @echo " nmake -f build.mk install" @echo "on the Windows system" ce_defines = -DWINCE -D_WIN32_WCE=0x502 -DUNDER_CE \ @@ -81,8 +94,9 @@ echo "Please cd to the src/ directory first"; \ exit 1; \ fi - cp -t $(targetdir) $(sources); - cd ../contrib/conf-w32ce-msc ; cp -t $(targetdir) $(conf_sources) + cp -t $(targetsrc)/libgpg-error/src $(sources); + cd ../contrib/conf-w32ce-msc ; \ + cp -t $(targetsrc)/libgpg-error/src $(conf_sources) copy-built-source: @@ -90,7 +104,10 @@ echo "Please build using ./autogen.sh --build-w32ce first"; \ exit 1; \ fi - cp -t $(targetdir) $(built_sources) + cp -t $(targetsrc)/libgpg-error/src $(built_sources) + -mkdir $(targetsrc)/libgpg-error/src/gpg-extra + mv $(targetsrc)/libgpg-error/src/errno.h \ + $(targetsrc)/libgpg-error/src/gpg-extra copy-source: copy-static-source copy-built-source @@ -111,8 +128,12 @@ coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \ commctrl.lib /subsystem:windowsce,5.02 -# Note that install needs to be run on the POSIX platform and the all -# is only to make sure we build everything; it won't compile anything -# because Visual-C is probably not installed on that platform. install: all - @echo fixme Install the files + -mkdir $(bindir:/=\) + -mkdir $(libdir:/=\) + -mkdir $(incdir:/=\) + -mkdir $(incdir:/=\)\gpg-extra + copy /y libgpg-error-0-msc.dll $(bindir:/=\) + copy /y libgpg-error-0-msc.lib $(libdir:/=\) + copy /y gpg-error.h $(incdir:/=\) + copy /y gpg-extra\errno.h $(incdir:/=\)\gpg-extra From cvs at cvs.gnupg.org Tue Nov 2 10:19:04 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 02 Nov 2010 10:19:04 +0100 Subject: [svn] assuan - r395 - in trunk: . contrib contrib/conf-w32ce-msc src Message-ID: Author: wk Date: 2010-11-02 10:19:03 +0100 (Tue, 02 Nov 2010) New Revision: 395 Modified: trunk/ChangeLog trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk trunk/src/ChangeLog Log: Chnage directory layout for MSC builds Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-01 19:25:20 UTC (rev 394) +++ trunk/ChangeLog 2010-11-02 09:19:03 UTC (rev 395) @@ -1,4 +1,4 @@ -2010-11-01 Marcus Brinkmann +2010-11-01 Marcus Brinkmann * configure.ac: Check for fcntl.h. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-01 19:25:20 UTC (rev 394) +++ trunk/contrib/ChangeLog 2010-11-02 09:19:03 UTC (rev 395) @@ -1,3 +1,7 @@ +2010-11-02 Werner Koch + + * conf-w32ce-msc/build.mk: Change directory layout. + 2010-11-01 Werner Koch * conf-w32ce-msc/build.mk: New. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-01 19:25:20 UTC (rev 394) +++ trunk/src/ChangeLog 2010-11-02 09:19:03 UTC (rev 395) @@ -4,7 +4,7 @@ CreateFile for building with MSC for W32CE. (utf8_to_wchar, MyCreateFile, MyDeleteFile) [W32CE]: New. -2010-11-01 Marcus Brinkmann +2010-11-01 Marcus Brinkmann * assuan-socket.c, assuan-uds.c, system.c, assuan-pipe-server.c, assuan-pipe-connect.c [!HAVE_FCNTL_H]: Don't include fcntl.h. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-01 19:25:20 UTC (rev 394) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-02 09:19:03 UTC (rev 395) @@ -12,16 +12,29 @@ # This is a helper make script to build libgpg-error for WindowsCE # using the Microsoft Visual C compiler. -# The target build directry where we run the Visual C compiler/ -# This needs to be an absolute directory name. -targetdir = /home/smb/xppro-gnu/src/libassuan +# The target build directory where we run the Visual C compiler/ This +# needs to be an absolute directory name. Further we expect this +# structure of the tree: +# +# TARGET/src - Source directories: One directory for each project +# /bin - Installed DLLs +# /lib - Installed import libs. +# /include - Instaled header files. +targetdir = /home/smb/xppro-gnu +targetsrc = $(targetdir)/src +# Install directories (relative) +bindir = ../../../bin +libdir = ../../../lib +incdir = ../../../include + help: @echo "Run " @echo " make -f ../contrib/conf-w32ce-msc/build.mk copy-source" @echo "on the POSIX system and then" @echo " nmake -f build.mk all" + @echo " nmake -f build.mk install" @echo "on the Windows system" ce_defines = -DWINCE -D_WIN32_WCE=0x502 -DUNDER_CE \ @@ -29,21 +42,10 @@ -D_CONSOLE -DARM -D_ARM_ #-D_DEBUG -DDEBUG -# Some options of Visual-C: -# -W3 Set warning level 3 -# -Zi Generate debug info -# -Od Disable optimization -# -Gm Enable minimal rebuild (for C++) -# -EHsc Exception handling model sc -# -MTd Create a debug multithreaded executable -# -fp: Floating point behaviour -# -GR- Disable runtime type information -# -Os Favor small code -# -LD Create a DLL -# -Fe Set executable output name (may be only a directory) +# See libgpg-error's build-mk for a list of compiler options. CFLAGS = -nologo -W3 -fp:fast -Os $(ce_defines) \ -DHAVE_CONFIG_H -DDLL_EXPORT -D_CRT_SECURE_NO_WARNINGS \ - -I. -I../../libgpg-error/src -I../../libgpg-error/src/gpg-extra + -I. -I$(incdir) -I$(incdir)/gpg-extra LDFLAGS = @@ -125,8 +127,9 @@ echo "Please cd to the src/ directory first"; \ exit 1; \ fi - cp -t $(targetdir) $(sources); - cd ../contrib/conf-w32ce-msc ; cp -t $(targetdir) $(conf_sources) + cp -t $(targetsrc)/libassuan/src $(sources); + cd ../contrib/conf-w32ce-msc ; \ + cp -t $(targetsrc)/libassuan/src $(conf_sources) copy-built-source: @@ -134,7 +137,7 @@ echo "Please build using ./autogen.sh --build-w32ce first"; \ exit 1; \ fi - cp -t $(targetdir) $(built_sources) + cp -t $(targetsrc)/libassuan/src $(built_sources) copy-source: copy-static-source copy-built-source @@ -147,12 +150,14 @@ /OUT:libassuan-0-msc.dll \ /DEF:libassuan.def /NOLOGO /MANIFEST:NO \ /NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE:NO \ - $(objs) \ + $(objs) $(libdir)/libgpg-error-0-msc.lib \ coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \ commctrl.lib /subsystem:windowsce,5.02 -# Note that install needs to be run on the POSIX platform and the all -# is only to make sure we build everything; it won't compile anything -# because Visual-C is probably not installed on that platform. +# Note that we don't need to create the install directories because +# libgpg-error must have been build and installed prior to this +# package. install: all - @echo fixme Install the files + copy /y libassuan-0-msc.dll $(bindir:/=\) + copy /y libassuan-0-msc.lib $(libdir:/=\) + copy /y assuan.h $(incdir:/=\) From cvs at cvs.gnupg.org Tue Nov 2 10:19:28 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 02 Nov 2010 10:19:28 +0100 Subject: [svn] gpg-error - r265 - trunk/contrib/conf-w32ce-msc Message-ID: Author: wk Date: 2010-11-02 10:19:28 +0100 (Tue, 02 Nov 2010) New Revision: 265 Modified: trunk/contrib/conf-w32ce-msc/build.mk Log: Fix last change Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-02 08:58:11 UTC (rev 264) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-02 09:19:28 UTC (rev 265) @@ -25,9 +25,9 @@ targetsrc = $(targetdir)/src # Install directories (relative) -bindir = ../../bin -libdir = ../../lib -incdir = ../../include +bindir = ../../../bin +libdir = ../../../lib +incdir = ../../../include help: @echo "Run " @@ -133,7 +133,7 @@ -mkdir $(libdir:/=\) -mkdir $(incdir:/=\) -mkdir $(incdir:/=\)\gpg-extra + copy /y gpg-error.h $(incdir:/=\) + copy /y gpg-extra\errno.h $(incdir:/=\)\gpg-extra copy /y libgpg-error-0-msc.dll $(bindir:/=\) copy /y libgpg-error-0-msc.lib $(libdir:/=\) - copy /y gpg-error.h $(incdir:/=\) - copy /y gpg-extra\errno.h $(incdir:/=\)\gpg-extra From cvs at cvs.gnupg.org Tue Nov 2 17:27:50 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 02 Nov 2010 17:27:50 +0100 Subject: [svn] gpgme - r1496 - in trunk: . contrib contrib/conf-w32ce-msc src Message-ID: Author: wk Date: 2010-11-02 17:27:46 +0100 (Tue, 02 Nov 2010) New Revision: 1496 Added: trunk/contrib/ trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/ trunk/contrib/conf-w32ce-msc/build.mk trunk/contrib/conf-w32ce-msc/config.h Modified: trunk/ChangeLog trunk/autogen.sh trunk/configure.ac trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/ath-pthread.c trunk/src/ath.c trunk/src/ath.h trunk/src/data-compat.c trunk/src/data-fd.c trunk/src/data-mem.c trunk/src/data.c trunk/src/debug.c trunk/src/encrypt-sign.c trunk/src/engine-assuan.c trunk/src/engine-g13.c trunk/src/engine-gpg.c trunk/src/engine-gpgconf.c trunk/src/engine-gpgsm.c trunk/src/engine-uiserver.c trunk/src/gpgme.c trunk/src/posix-io.c trunk/src/posix-sema.c trunk/src/priv-io.h trunk/src/ttyname_r.c trunk/src/util.h trunk/src/vfs-create.c trunk/src/w32-ce.c trunk/src/w32-ce.h trunk/src/w32-glib-io.c trunk/src/w32-io.c trunk/src/w32-sema.c trunk/src/w32-util.c Log: First take on changes to allow building with MSC for W32CE. Fixed regression in plain W32 build. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/ChangeLog 2010-11-02 16:27:46 UTC (rev 1496) @@ -1,3 +1,7 @@ +2010-11-02 Werner Koch + + * configure.ac (AC_CHECK_HEADERS): Check for sys.time.h. + 2010-08-19 Werner Koch * configure.ac (AH_BOTTOM): Define GPG_ERR_ENABLE_ERRNO_MACROS. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/ChangeLog 2010-11-02 16:27:46 UTC (rev 1496) @@ -1,5 +1,30 @@ -2010-10-28 Marcus Brinkmann +2010-11-02 Werner Koch + * w32-io.c (handle_to_fd, fd_tohandle): Add. We need them for W32. + * w32-util.c (_WIN32_IE): Define to 0x0400. + + * util.h [W32]: Include windows.h. + * w32-sema.c: Do not include windows.h directly. + * ath.c (ssize_t, pid_t)[_MSC_VER]: Add new types. + * gpgme.c (gpgme_result_ref, gpgme_result_unref): Do not use a + void pointer in pointer arithmetic. + * w32-util.c: Include util.h prior to ath.h. Don't include + windows.h directly. + (F_OK): Define if not defined. + * w32-ce.c: Include string.h. + (RegQueryValueExA): Use WINAPI modifier to match the declaration. + * vfs-create.c: Include string.h because under W32CE with MSC we + get a warning related to our strerror replacement. + * encrypt-sign.c: Include stdlib.h, string.h and errno.h. + * priv-io.h [W32CE]: Include w32-ce.h + * w32-ce.h: Include winsock2.h and ws2tcpip.h. + (_MSV_VER): Remove useless macro. + (pid_t): Add typedef. + + Guard all includes of unistd.h and sys/time.h. + +2010-10-28 Marcus Brinkmann + * opassuan.c (gpgme_op_assuan_transact_ext): Fix uninitialized value use. Reported by Marc Mutz. Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/autogen.sh 2010-11-02 16:27:46 UTC (rev 1496) @@ -127,7 +127,7 @@ fi fi - ./configure --enable-maintainer-mode --prefix=${w32root} \ + $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ --host=${host} --build=${build} \ --with-gpg-error-prefix=${w32root} \ --with-libassuan-prefix=${w32root} "$@" Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/configure.ac 2010-11-02 16:27:46 UTC (rev 1496) @@ -774,7 +774,7 @@ # Replacement functions. AC_REPLACE_FUNCS(stpcpy) # Check for unistd.h for setenv replacement function. -AC_CHECK_HEADERS(unistd.h) +AC_CHECK_HEADERS([unistd.h sys/time.h]) AC_REPLACE_FUNCS(setenv) # Assuan check for descriptor passing. Added: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog (rev 0) +++ trunk/contrib/ChangeLog 2010-11-02 16:27:46 UTC (rev 1496) @@ -0,0 +1,5 @@ +2010-11-01 Werner Koch + + * conf-w32ce-msc/config.h: New. + * conf-w32ce-msc/build.mk: New. + Added: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk (rev 0) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-02 16:27:46 UTC (rev 1496) @@ -0,0 +1,253 @@ +# build.mk - Makefile to build libgpg-error using Visual-C +# Copyright 2010 g10 Code GmbH +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This file is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This is a helper make script to build libgpg-error for WindowsCE +# using the Microsoft Visual C compiler. + +targetdir = /home/smb/xppro-gnu/src/gpgme/src +# The target build directory where we run the Visual C compiler/ This +# needs to be an absolute directory name. Further we expect this +# structure of the tree: +# +# TARGET/src - Source directories: One directory for each project +# /bin - Installed DLLs +# /lib - Installed import libs. +# /include - Instaled header files. + +targetdir = /home/smb/xppro-gnu +targetsrc = $(targetdir)/src + +# Install directories (relative) +bindir = ../../../bin +libdir = ../../../lib +incdir = ../../../include + + +help: + @echo "Run " + @echo " make -f ../contrib/conf-w32ce-msc/build.mk copy-source" + @echo "on the POSIX system and then" + @echo " nmake -f build.mk all" + @echo " nmake -f build.mk install" + @echo "on the Windows system" + +ce_defines = -DWINCE -D_WIN32_WCE=0x502 -DUNDER_CE \ + -DWIN32_PLATFORM_PSPC -D_UNICODE -DUNICODE \ + -D_CONSOLE -DARM -D_ARM_ +#-D_DEBUG -DDEBUG + +CFLAGS = -nologo -W3 -fp:fast -Os $(ce_defines) \ + -DHAVE_CONFIG_H -DDLL_EXPORT -D_CRT_SECURE_NO_WARNINGS \ + -I. -I$(incdir) -I$(incdir)/gpg-extra + +LDFLAGS = + +# Standard source files +sources = \ + assuan-support.c \ + ath-pth.c \ + ath-pthread.c \ + ath.c \ + ath.h \ + context.h \ + conversion.c \ + data-compat.c \ + data-fd.c \ + data-mem.c \ + data-stream.c \ + data-user.c \ + data.c \ + data.h \ + debug.c \ + debug.h \ + decrypt-verify.c \ + decrypt.c \ + delete.c \ + dirinfo.c \ + edit.c \ + encrypt-sign.c \ + encrypt.c \ + engine-assuan.c \ + engine-backend.h \ + engine-g13.c \ + engine-gpg.c \ + engine-gpgconf.c \ + engine-gpgsm.c \ + engine-uiserver.c \ + engine.c \ + engine.h \ + error.c \ + export.c \ + funopen.c \ + genkey.c \ + get-env.c \ + getauditlog.c \ + gpgconf.c \ + gpgme-tool.c \ + gpgme-w32spawn.c \ + gpgme.c \ + import.c \ + isascii.c \ + kdpipeiodevice.h \ + key.c \ + keylist.c \ + memrchr.c \ + op-support.c \ + opassuan.c \ + ops.h \ + passphrase.c \ + passwd.c \ + priv-io.h \ + progress.c \ + putc_unlocked.c \ + sema.h \ + setenv.c \ + sig-notation.c \ + sign.c \ + signers.c \ + stpcpy.c \ + trust-item.c \ + trustlist.c \ + ttyname_r.c \ + util.h \ + vasprintf.c \ + verify.c \ + version.c \ + vfs-create.c \ + vfs-mount.c \ + w32-ce.c \ + w32-ce.h \ + w32-glib-io.c \ + w32-io.c \ + w32-sema.c \ + w32-util.c \ + wait-global.c \ + wait-private.c \ + wait-user.c \ + wait.c \ + wait.h \ + gpgme.def + +# The object files we need to create from sources. +objs = \ + conversion.obj \ + get-env.obj \ + data.obj \ + data-fd.obj \ + data-stream.obj \ + data-mem.obj \ + data-user.obj \ + data-compat.obj \ + signers.obj \ + sig-notation.obj \ + wait.obj \ + wait-global.obj \ + wait-private.obj \ + wait-user.obj \ + op-support.obj \ + encrypt.obj \ + encrypt-sign.obj \ + decrypt.obj \ + decrypt-verify.obj \ + verify.obj \ + sign.obj \ + passphrase.obj \ + progress.obj \ + key.obj \ + keylist.obj \ + trust-item.obj \ + trustlist.obj \ + import.obj \ + export.obj \ + genkey.obj \ + delete.obj \ + edit.obj \ + getauditlog.obj \ + opassuan.obj \ + passwd.obj \ + engine.obj \ + engine-gpg.obj \ + engine-gpgsm.obj \ + assuan-support.obj \ + engine-assuan.obj \ + engine-gpgconf.obj \ + engine-g13.obj \ + vfs-mount.obj \ + vfs-create.obj \ + gpgconf.obj \ + w32-ce.obj \ + w32-util.obj \ + w32-sema.obj \ + w32-io.obj \ + dirinfo.obj \ + debug.obj \ + gpgme.obj \ + version.obj \ + error.obj \ + ath.obj \ + vasprintf.obj \ + ttyname_r.obj \ + stpcpy.obj \ + setenv.obj + + +# Sources files in this directory inclduing this Makefile +conf_sources = \ + build.mk \ + config.h + +# Source files built by running the standard build system. +built_sources = \ + gpgme.h \ + status-table.h + + +copy-static-source: + @if [ ! -f ./gpgme.c ]; then \ + echo "Please cd to the src/ directory first"; \ + exit 1; \ + fi + cp -t $(targetsrc)/gpgme/src $(sources); + cd ../contrib/conf-w32ce-msc ; \ + cp -t $(targetsrc)/gpgme/src $(conf_sources) + + +copy-built-source: + @if [ ! -f ./gpgme.h ]; then \ + echo "Please build using ./autogen.sh --build-w32ce first"; \ + exit 1; \ + fi + cp -t $(targetsrc)/gpgme/src $(built_sources) + +copy-source: copy-static-source copy-built-source + + +.c.obj: + $(CC) $(CFLAGS) -c $< + +all: $(sources) $(conf_sources) $(built_sources) $(objs) + link /DLL /IMPLIB:libgpgme-11-msc.lib \ + /OUT:libgpgme-11-msc.dll \ + /DEF:gpgme.def /NOLOGO /MANIFEST:NO \ + /NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE:NO \ + $(objs) \ + $(libdir)/libgpg-error-0-msc.lib \ + $(libdir)/libassuan-0-msc.lib \ + coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \ + commctrl.lib /subsystem:windowsce,5.02 + +# Note that we don't need to create the install directories because +# libgpg-error must have been build and installed prior to this +# package. +install: all + copy /y gpgme.h $(incdir:/=\) + copy /y libgpgme-11-msc.dll $(bindir:/=\) + copy /y libgpgme-11-msc.lib $(libdir:/=\) Property changes on: trunk/contrib/conf-w32ce-msc/build.mk ___________________________________________________________________ Added: svn:executable + * Added: trunk/contrib/conf-w32ce-msc/config.h =================================================================== --- trunk/contrib/conf-w32ce-msc/config.h (rev 0) +++ trunk/contrib/conf-w32ce-msc/config.h 2010-11-02 16:27:46 UTC (rev 1496) @@ -0,0 +1,314 @@ +/* config.h for building with Visual-C for WindowsCE. + * Copyright 2010 g10 Code GmbH + * + * This file is free software; as a special exception the author gives + * unlimited permission to copy and/or distribute it, with or without + * modifications, as long as this notice is preserved. + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* This file was originally created by running + * ./autogen.sh --build-w32ce + * on svn revision 1495 (gpgme 1.3.1-svn1495) and then adjusted to work + * with Visual-C. + */ + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.3.1-svn1495-msc1" + +/* Name of this package */ +#define PACKAGE "gpgme" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "bug-gpgme at gnupg.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "gpgme" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "gpgme " PACKAGE_VERSION + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "gpgme" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + + + +/* Whether Assuan support is enabled */ +#define ENABLE_ASSUAN 1 + +/* Whether G13 support is enabled */ +#define ENABLE_G13 1 + +/* Whether GPGCONF support is enabled */ +#define ENABLE_GPGCONF 1 + +/* Whether GPGSM support is enabled */ +#define ENABLE_GPGSM 1 + +/* Defined if we are building with uiserver support. */ +/* #undef ENABLE_UISERVER */ + +/* Path to the G13 binary. */ +#define G13_PATH "c:\\gnupg\\g13.exe" + +/* Path to the GPGCONF binary. */ +#define GPGCONF_PATH "c:\\gnupg\\gpgconf.exe" + +/* version of the libassuan library */ +#define GPGME_LIBASSUAN_VERSION "2.0.2-svn381" + +/* Path to the GPGSM binary. */ +#define GPGSM_PATH "c:\\gnupg\\gpgsm.exe" + +/* The default error source for GPGME. */ +#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_GPGME + +/* Path to the GnuPG binary. */ +#define GPG_PATH "c:\\gnupg\\gpg.exe" + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2) + with special properties like no file modes */ +#define HAVE_DOSISH_SYSTEM 1 + +/* Define to 1 if the system has the type `error_t'. */ +/* #undef HAVE_ERROR_T */ + +/* Define to 1 if you have the `fopencookie' function. */ +/* #undef HAVE_FOPENCOOKIE */ + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +/* #undef HAVE_FSEEKO */ + +/* Define to 1 if you have the `funopen' function. */ +/* #undef HAVE_FUNOPEN */ + +/* Define to 1 if you have the `getegid' function. */ +/* #undef HAVE_GETEGID */ + +/* Define to 1 if you have the `getenv_r' function. */ +/* #undef HAVE_GETENV_R */ + +/* Define to 1 if you have the `getgid' function. */ +/* #undef HAVE_GETGID */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LOCALE_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if we have Pth. */ +/* #undef HAVE_PTH */ + +/* Define if we have pthread. */ +/* #undef HAVE_PTHREAD */ + +/* Define to 1 if you have the `setenv' function. */ +/* #undef HAVE_SETENV */ + +/* Define to 1 if you have the `setlocale' function. */ +/* #undef HAVE_SETLOCALE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +/* #undef HAVE_STPCPY */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STRINGS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STAT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TYPES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UIO_H */ + +/* Define if getenv() is thread-safe */ +/* #undef HAVE_THREAD_SAFE_GETENV */ + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define if __thread is supported */ +/* #define HAVE_TLS 1 */ + +/* Define to 1 if you have the `ttyname_r' function. */ +/* #undef HAVE_TTYNAME_R */ + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_UNISTD_H 1 */ + +/* Define to 1 if you have the `vasprintf' function. */ +/* #undef HAVE_VASPRINTF */ + +/* Defined if we run on a W32 CE API based system */ +#define HAVE_W32CE_SYSTEM 1 + +/* Defined if we run on a W32 API based system */ +#define HAVE_W32_SYSTEM 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* used to implement the va_copy macro */ +/* #undef MUST_COPY_VA_BYVAL */ + +/* Min. needed G13 version. */ +#define NEED_G13_VERSION "2.1.0" + +/* Min. needed GPGCONF version. */ +#define NEED_GPGCONF_VERSION "2.0.4" + +/* Min. needed GPGSM version. */ +#define NEED_GPGSM_VERSION "1.9.6" + +/* Min. needed GnuPG version. */ +#define NEED_GPG_VERSION "1.4.0" + + +/* Separators as used in $PATH. */ +#ifdef HAVE_DOSISH_SYSTEM +#define PATHSEP_C ';' +#else +#define PATHSEP_C ':' +#endif + + +/* The size of `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Defined if descriptor passing is enabled and supported */ +/* #undef USE_DESCRIPTOR_PASSING */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Version of this package */ +#define VERSION PACKAGE_VERSION + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* To allow the use of GPGME in multithreaded programs we have to use + special features from the library. + IMPORTANT: gpgme is not yet fully reentrant and you should use it + only from one thread. */ +#ifndef _REENTRANT +# define _REENTRANT 1 +#endif + +/* Activate POSIX interface on MacOS X */ +/* #undef _XOPEN_SOURCE */ + +/* Define to a type to use for `error_t' if it is not otherwise available. */ +#define error_t int + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#define inline __inline +#endif + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +/* #undef uintptr_t */ + + +/* Definition of GCC specific attributes. */ +#if __GNUC__ > 2 +# define GPGME_GCC_A_PURE __attribute__ ((__pure__)) +#else +# define GPGME_GCC_A_PURE +#endif + +/* Under WindowsCE we need gpg-error's strerror macro. */ +#define GPG_ERR_ENABLE_ERRNO_MACROS 1 + +/* snprintf is not part of oldnames.lib thus we redefine it here. */ +#define snprintf _snprintf + +/* We don't want warnings like this: + + warning C4996: e.g. "The POSIX name for this item is + deprecated. Instead, use the ISO C++ conformant name: _fileno" + + warning C4018: '<' : signed/unsigned mismatch + + warning C4244: '=' : conversion from 'time_t' to + 'unsigned long', possible loss of data + + */ +#pragma warning(disable:4996 4018 4244) + + + Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/Makefile.am 2010-11-02 16:27:46 UTC (rev 1496) @@ -203,7 +203,8 @@ $(libgpgme_version_script_cmd) -version-info \ @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@ libgpgme_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps) -libgpgme_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ @GPG_ERROR_LIBS@ +libgpgme_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \ + @GPG_ERROR_LIBS@ libgpgme_pthread_la_LDFLAGS = $(no_undefined) $(export_symbols) \ $(libgpgme_version_script_cmd) -version-info \ Modified: trunk/src/ath-pthread.c =================================================================== --- trunk/src/ath-pthread.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/ath-pthread.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -24,11 +24,15 @@ #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #ifdef HAVE_SYS_SELECT_H # include #else -# include +# ifdef HAVE_SYS_TIME_H +# include +# endif #endif #include #include Modified: trunk/src/ath.c =================================================================== --- trunk/src/ath.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/ath.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -23,17 +23,26 @@ #endif #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #ifdef HAVE_SYS_SELECT_H # include #else -# include +# ifdef HAVE_SYS_TIME_H +# include +# endif #endif #include #ifndef HAVE_W32_SYSTEM #include #endif +#ifdef _MSC_VER + typedef long ssize_t; + typedef int pid_t; +#endif + #include "ath.h" Modified: trunk/src/ath.h =================================================================== --- trunk/src/ath.h 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/ath.h 2010-11-02 16:27:46 UTC (rev 1496) @@ -36,7 +36,9 @@ # ifdef HAVE_SYS_SELECT_H # include # else -# include +# ifdef HAVE_SYS_TIME_H +# include +# endif # endif # include # include Modified: trunk/src/data-compat.c =================================================================== --- trunk/src/data-compat.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/data-compat.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -23,7 +23,9 @@ #endif #include -#include +#ifdef HAVE_SYS_TIME_H +# include +#endif #include #include Modified: trunk/src/data-fd.c =================================================================== --- trunk/src/data-fd.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/data-fd.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -22,7 +22,9 @@ #include #endif -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include "debug.h" Modified: trunk/src/data-mem.c =================================================================== --- trunk/src/data-mem.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/data-mem.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -24,7 +24,9 @@ #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include Modified: trunk/src/data.c =================================================================== --- trunk/src/data.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/data.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -23,7 +23,9 @@ #endif #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/debug.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -26,7 +26,9 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include #include Modified: trunk/src/encrypt-sign.c =================================================================== --- trunk/src/encrypt-sign.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/encrypt-sign.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -22,6 +22,9 @@ #if HAVE_CONFIG_H #include #endif +#include +#include +#include #include "gpgme.h" #include "debug.h" Modified: trunk/src/engine-assuan.c =================================================================== --- trunk/src/engine-assuan.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/engine-assuan.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -32,7 +32,9 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #ifdef HAVE_LOCALE_H #include #endif Modified: trunk/src/engine-g13.c =================================================================== --- trunk/src/engine-g13.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/engine-g13.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -27,7 +27,9 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #ifdef HAVE_LOCALE_H #include #endif Modified: trunk/src/engine-gpg.c =================================================================== --- trunk/src/engine-gpg.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/engine-gpg.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -27,7 +27,9 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #ifdef HAVE_LOCALE_H #include #endif Modified: trunk/src/engine-gpgconf.c =================================================================== --- trunk/src/engine-gpgconf.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/engine-gpgconf.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -26,7 +26,9 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include /* FIXME */ #include Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/engine-gpgsm.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -28,7 +28,9 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #ifdef HAVE_LOCALE_H #include #endif Modified: trunk/src/engine-uiserver.c =================================================================== --- trunk/src/engine-uiserver.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/engine-uiserver.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -31,7 +31,9 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include #include /* FIXME */ #include Modified: trunk/src/gpgme.c =================================================================== --- trunk/src/gpgme.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/gpgme.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -211,7 +211,7 @@ if (! result) return; - data = result - sizeof (struct ctx_op_data); + data = (void*)((char*)result - sizeof (struct ctx_op_data)); assert (data->magic == CTX_OP_DATA_MAGIC); @@ -229,7 +229,7 @@ if (! result) return; - data = result - sizeof (struct ctx_op_data); + data = (void*)((char*)result - sizeof (struct ctx_op_data)); assert (data->magic == CTX_OP_DATA_MAGIC); Modified: trunk/src/posix-io.c =================================================================== --- trunk/src/posix-io.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/posix-io.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -28,8 +28,12 @@ #include #include #include -#include -#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif #include #include #ifdef HAVE_SYS_UIO_H @@ -37,7 +41,6 @@ #endif #include #include -#include #include "util.h" #include "priv-io.h" Modified: trunk/src/posix-sema.c =================================================================== --- trunk/src/posix-sema.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/posix-sema.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -29,8 +29,12 @@ #include #include #include -#include -#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif #include #include "util.h" Modified: trunk/src/priv-io.h =================================================================== --- trunk/src/priv-io.h 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/priv-io.h 2010-11-02 16:27:46 UTC (rev 1496) @@ -23,6 +23,9 @@ #define IO_H #ifdef HAVE_W32_SYSTEM +# ifdef HAVE_W32CE_SYSTEM +# include "w32-ce.h" +# endif # include #else # include Modified: trunk/src/ttyname_r.c =================================================================== --- trunk/src/ttyname_r.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/ttyname_r.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -24,10 +24,14 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif -#warning ttyname is not thread-safe, and ttyname_r is missing +#ifdef __GNUC__ +# warning ttyname is not thread-safe, and ttyname_r is missing +#endif int ttyname_r (int fd, char *buf, size_t buflen) Modified: trunk/src/util.h =================================================================== --- trunk/src/util.h 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/util.h 2010-11-02 16:27:46 UTC (rev 1496) @@ -22,8 +22,12 @@ #ifndef UTIL_H #define UTIL_H -#ifdef HAVE_W32CE_SYSTEM -#include "w32-ce.h" +#ifdef HAVE_W32_SYSTEM +# ifdef HAVE_W32CE_SYSTEM +# include "w32-ce.h" +# else +# include "windows.h" +# endif #endif /* For pid_t. */ Modified: trunk/src/vfs-create.c =================================================================== --- trunk/src/vfs-create.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/vfs-create.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -23,6 +23,7 @@ #endif #include +#include #include "gpgme.h" #include "debug.h" Modified: trunk/src/w32-ce.c =================================================================== --- trunk/src/w32-ce.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/w32-ce.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -22,6 +22,7 @@ #include #endif +#include #include #include @@ -248,7 +249,7 @@ } -LONG +LONG WINAPI RegQueryValueExA (HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData) { Modified: trunk/src/w32-ce.h =================================================================== --- trunk/src/w32-ce.h 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/w32-ce.h 2010-11-02 16:27:46 UTC (rev 1496) @@ -24,8 +24,12 @@ #include #include -/* For getaddrinfo. */ -#define _MSV_VER 0x401 +#ifdef _MSC_VER +typedef int pid_t; +#endif + +#include +#include /* For getaddrinfo. */ #include Modified: trunk/src/w32-glib-io.c =================================================================== --- trunk/src/w32-glib-io.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/w32-glib-io.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -28,8 +28,12 @@ #include #include #include -#include -#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif #include #include #include Modified: trunk/src/w32-io.c =================================================================== --- trunk/src/w32-io.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/w32-io.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -28,11 +28,14 @@ #include #include #include -#include +#ifdef HAVE_SYS_TIME_H +# include +#endif #include -#include #include +#include "util.h" + #ifdef HAVE_W32CE_SYSTEM #include #include @@ -42,7 +45,6 @@ CTL_CODE (FILE_DEVICE_STREAMS, 2051, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif -#include "util.h" #include "sema.h" #include "priv-io.h" #include "debug.h" @@ -123,6 +125,8 @@ #define pid_to_handle(a) ((HANDLE)(a)) #define handle_to_pid(a) ((int)(a)) +#define fd_to_handle(a) ((HANDLE)(a)) +#define handle_to_fd(a) ((int)(a)) #define READBUF_SIZE 4096 #define WRITEBUF_SIZE 4096 Modified: trunk/src/w32-sema.c =================================================================== --- trunk/src/w32-sema.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/w32-sema.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -28,9 +28,10 @@ #include #include #include -#include +#ifdef HAVE_SYS_TIME_H +# include +#endif #include -#include #include #include "util.h" Modified: trunk/src/w32-util.c =================================================================== --- trunk/src/w32-util.c 2010-10-28 14:00:14 UTC (rev 1495) +++ trunk/src/w32-util.c 2010-11-02 16:27:46 UTC (rev 1496) @@ -29,17 +29,22 @@ #include #include #include -#include +#ifdef HAVE_SYS_TIME_H +# include +#endif #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include -#include -#include #include +#define _WIN32_IE 0x0400 /* Required for SHGetSpecialFolderPathA. */ + +#include "util.h" +#include #include "ath.h" -#include "util.h" #include "sema.h" #include "debug.h" @@ -47,6 +52,9 @@ #ifndef HAVE_W32CE_SYSTEM #define HAVE_ALLOW_SET_FOREGROUND_WINDOW 1 #endif +#ifndef F_OK +# define F_OK 0 +#endif DEFINE_STATIC_LOCK (get_path_lock); From cvs at cvs.gnupg.org Tue Nov 2 21:17:58 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 02 Nov 2010 21:17:58 +0100 Subject: [svn] gpgme - r1497 - trunk/src Message-ID: Author: wk Date: 2010-11-02 21:17:57 +0100 (Tue, 02 Nov 2010) New Revision: 1497 Modified: trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/data-fd.c trunk/src/w32-ce.c trunk/src/w32-ce.h trunk/src/w32-util.c Log: Might now build for CE using MSC. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-02 16:27:46 UTC (rev 1496) +++ trunk/src/ChangeLog 2010-11-02 20:17:57 UTC (rev 1497) @@ -1,5 +1,18 @@ 2010-11-02 Werner Koch + * data-fd.c (read, write, lseek) [W32CE && ! __MINGW32CE__]: New. + Taken from Pedro Alves Public Domain code. + + * w32-ce.h (SHGetSpecialFolderPath): Remove our defines and + prototypes. We use the system provided prototypes now. + * w32-ce.c: Include shlobj.h + (_WIN32_IE): Define to 0x0400 + (CreateFileA): New. + * w32-util.c: Explicitly include windows headers before util.h. + (_gpgme_w32ce_get_debug_envvar): Do not use wchar_t strings for + read_w32_registry_string. + (mkstemp): Use CreateFile instead of open. + * w32-io.c (handle_to_fd, fd_tohandle): Add. We need them for W32. * w32-util.c (_WIN32_IE): Define to 0x0400. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-11-02 16:27:46 UTC (rev 1496) +++ trunk/src/Makefile.am 2010-11-02 20:17:57 UTC (rev 1497) @@ -102,7 +102,6 @@ uiserver_components = endif - # These are the source files common to all library versions. We used # to build a non-installed library for that, but that does not work # correctly on all platforms (in particular, one can not specify the Modified: trunk/src/data-fd.c =================================================================== --- trunk/src/data-fd.c 2010-11-02 16:27:46 UTC (rev 1496) +++ trunk/src/data-fd.c 2010-11-02 20:17:57 UTC (rev 1497) @@ -30,7 +30,63 @@ #include "debug.h" #include "data.h" + +#if defined(HAVE_W32CE_SYSTEM) && !defined(__MINGW32CE__) +/* We need to provide replacements for read, write and lseek. They + are taken from the cegcc runtime files, written by Pedro Alves + in Feb 2007 and placed in the public + domain. (cf. cegcc/src/mingw/mingwex/wince/) */ + +#include + +static int +read (int fildes, void *buf, unsigned int bufsize) +{ + DWORD NumberOfBytesRead; + if (bufsize > 0x7fffffff) + bufsize = 0x7fffffff; + if (!ReadFile ((HANDLE) fildes, buf, bufsize, &NumberOfBytesRead, NULL)) + return -1; + return (int) NumberOfBytesRead; +} + +static int +write (int fildes, const void *buf, unsigned int bufsize) +{ + DWORD NumberOfBytesWritten; + if (bufsize > 0x7fffffff) + bufsize = 0x7fffffff; + if (!WriteFile ((HANDLE) fildes, buf, bufsize, &NumberOfBytesWritten, NULL)) + return -1; + return (int) NumberOfBytesWritten; +} + +static long +lseek (int fildes, long offset, int whence) +{ + DWORD mode; + switch (whence) + { + case SEEK_SET: + mode = FILE_BEGIN; + break; + case SEEK_CUR: + mode = FILE_CURRENT; + break; + case SEEK_END: + mode = FILE_END; + break; + default: + /* Specify an invalid mode so SetFilePointer catches it. */ + mode = (DWORD)-1; + } + return (long) SetFilePointer ((HANDLE) fildes, offset, NULL, mode); +} +#endif /*HAVE_W32CE_SYSTEM && !__MINGW32CE__*/ + + + static ssize_t fd_read (gpgme_data_t dh, void *buffer, size_t size) { Modified: trunk/src/w32-ce.c =================================================================== --- trunk/src/w32-ce.c 2010-11-02 16:27:46 UTC (rev 1496) +++ trunk/src/w32-ce.c 2010-11-02 20:17:57 UTC (rev 1497) @@ -28,9 +28,19 @@ #include +#define _WIN32_IE 0x0400 /* Required for SHGetSpecialFolderPathW. */ + +/* We need to include the windows stuff here prior to shlobj.h so that + we get the right winsock version. This is usually done in w32-ce.h + but that header also redefines some Windows functions which we need + to avoid unless having included shlobj.h. */ +#include +#include +#include +#include + #include "w32-ce.h" - /* Return a malloced string encoded in UTF-8 from the wide char input string STRING. Caller must free this value. Returns NULL and sets ERRNO on failure. Calling this function with STRING set to NULL is @@ -175,6 +185,31 @@ } +HANDLE +CreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile) +{ + wchar_t *filename; + HANDLE result; + int err; + + filename = utf8_to_wchar (lpFileName); + if (!filename) + return INVALID_HANDLE_VALUE; + + result = CreateFileW (filename, dwDesiredAccess, dwSharedMode, + lpSecurityAttributes, dwCreationDisposition, + dwFlagsAndAttributes, hTemplateFile); + + err = GetLastError (); + free (filename); + SetLastError (err); + return result; +} + + BOOL CreateProcessA (LPCSTR pszImageName, LPSTR pszCmdLine, LPSECURITY_ATTRIBUTES psaProcess, @@ -382,6 +417,12 @@ } +/* The symbol is named SHGetSpecialFolderPath and not + SHGetSpecialFolderPathW but shlobj.h from cegcc redefines it to *W + which is a bug. Work around it. */ +#ifdef __MINGW32CE__ +# undef SHGetSpecialFolderPath +#endif BOOL SHGetSpecialFolderPathA (HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate) @@ -391,7 +432,7 @@ BOOL result; path[0] = (wchar_t) 0; - result = SHGetSpecialFolderPathW (hwndOwner, path, nFolder, fCreate); + result = SHGetSpecialFolderPath (hwndOwner, path, nFolder, fCreate); /* Note: May return false even if succeeds. */ path[MAX_PATH - 1] = (wchar_t) 0; Modified: trunk/src/w32-ce.h =================================================================== --- trunk/src/w32-ce.h 2010-11-02 16:27:46 UTC (rev 1496) +++ trunk/src/w32-ce.h 2010-11-02 20:17:57 UTC (rev 1497) @@ -33,13 +33,6 @@ #include -/* shlobj.h declares these only for _WIN32_IE that we don't want to define. - In any case, with mingw32ce we only get a SHGetSpecialFolderPath. */ -#define SHGetSpecialFolderPathW SHGetSpecialFolderPath -BOOL WINAPI SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL); -BOOL WINAPI SHGetSpecialFolderPathW(HWND,LPWSTR,int,BOOL); - - #define getenv _gpgme_wince_getenv char *getenv (const char *name); @@ -55,6 +48,10 @@ #define DeleteFileA _gpgme_wince_DeleteFileA BOOL DeleteFileA(LPCSTR); +#define CreateFileA _gpgme_wince_CreateFileA +HANDLE CreateFileA (LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, + DWORD, DWORD, HANDLE); + #define CreateProcessA _gpgme_wince_CreateProcessA BOOL CreateProcessA(LPCSTR,LPSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,PVOID,LPCSTR,LPSTARTUPINFOA,LPPROCESS_INFORMATION); Modified: trunk/src/w32-util.c =================================================================== --- trunk/src/w32-util.c 2010-11-02 16:27:46 UTC (rev 1496) +++ trunk/src/w32-util.c 2010-11-02 20:17:57 UTC (rev 1497) @@ -42,8 +42,16 @@ #define _WIN32_IE 0x0400 /* Required for SHGetSpecialFolderPathA. */ +/* We need to include the windows stuff here prior to shlobj.h so that + we get the right winsock version. This is usually done in util.h + but that header also redefines some Windows functions which we need + to avoid unless having included shlobj.h. */ +#include +#include +#include +#include + #include "util.h" -#include #include "ath.h" #include "sema.h" #include "debug.h" @@ -488,7 +496,7 @@ static uint64_t value; uint64_t random_time_bits; unsigned int count; - int fd = -1; + HANDLE fd = INVALID_HANDLE_VALUE; int save_errno = errno; /* A lower bound on the number of temporary files to attempt to @@ -544,14 +552,23 @@ v /= 62; XXXXXX[5] = letters[v % 62]; - fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); - if (fd >= 0) + fd = CreateFileA (tmpl, + GENERIC_WRITE|GENERIC_READ, + FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL, + CREATE_NEW, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (fd != INVALID_HANDLE_VALUE) { gpg_err_set_errno (save_errno); - return fd; + return (int)fd; } - else if (errno != EEXIST) - return -1; + else if (GetLastError () != ERROR_FILE_EXISTS) + { + gpg_err_set_errno (EIO); + return -1; + } } /* We got out of the loop because we ran out of combinations to try. */ @@ -608,7 +625,7 @@ { char *tmp; - tmp = read_w32_registry_string (NULL, L"\\Software\\GNU\\gpgme", L"debug"); + tmp = read_w32_registry_string (NULL, "\\Software\\GNU\\gpgme", "debug"); if (tmp && !*tmp) { free (tmp); From cvs at cvs.gnupg.org Wed Nov 3 10:56:31 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 03 Nov 2010 10:56:31 +0100 Subject: [svn] gpgme - r1498 - in trunk: . contrib contrib/conf-w32ce-msc src Message-ID: Author: wk Date: 2010-11-03 10:56:27 +0100 (Wed, 03 Nov 2010) New Revision: 1498 Modified: trunk/ChangeLog trunk/configure.ac trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk trunk/src/ChangeLog trunk/src/ath.c trunk/src/ath.h trunk/src/conversion.c trunk/src/data-compat.c trunk/src/data-fd.c trunk/src/data-stream.c trunk/src/data-user.c trunk/src/data.h trunk/src/debug.c trunk/src/engine-assuan.c trunk/src/engine-g13.c trunk/src/engine-gpgconf.c trunk/src/engine-gpgsm.c trunk/src/engine-uiserver.c trunk/src/gpgme-w32spawn.c trunk/src/keylist.c trunk/src/memrchr.c trunk/src/posix-io.c trunk/src/posix-sema.c trunk/src/priv-io.h trunk/src/setenv.c trunk/src/util.h trunk/src/w32-ce.c trunk/src/w32-ce.h trunk/src/w32-glib-io.c trunk/src/w32-io.c trunk/src/w32-sema.c trunk/src/w32-util.c trunk/src/wait.c Log: More include guards. Provide access for Wince. Install dummy sehmap.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/ChangeLog 2010-11-03 09:56:27 UTC (rev 1498) @@ -1,3 +1,8 @@ +2010-11-03 Werner Koch + + * configure.ac (AC_CHECK_HEADERS): Check for sys/types.h and + sys.stat.h. + 2010-11-02 Werner Koch * configure.ac (AC_CHECK_HEADERS): Check for sys.time.h. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/contrib/ChangeLog 2010-11-03 09:56:27 UTC (rev 1498) @@ -1,3 +1,7 @@ +2010-11-03 Werner Koch + + * conf-w32ce-msc/build.mk (copy-built-source): Create dummy sehmap.h. + 2010-11-01 Werner Koch * conf-w32ce-msc/config.h: New. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/ChangeLog 2010-11-03 09:56:27 UTC (rev 1498) @@ -1,3 +1,13 @@ +2010-11-03 Werner Koch + + * setenv.c: Include string.h due to our strerror replacement. + + * w32-ce.h (access): New macro. + * w32-ce.c (_gpgme_wince_access): New. + (RegQueryValueExA): Change DATA to a void*. + + Guard include of sys/stat.h and sys/types.h. + 2010-11-02 Werner Koch * data-fd.c (read, write, lseek) [W32CE && ! __MINGW32CE__]: New. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/configure.ac 2010-11-03 09:56:27 UTC (rev 1498) @@ -774,7 +774,7 @@ # Replacement functions. AC_REPLACE_FUNCS(stpcpy) # Check for unistd.h for setenv replacement function. -AC_CHECK_HEADERS([unistd.h sys/time.h]) +AC_CHECK_HEADERS([unistd.h sys/time.h sys/types.h sys/stat.h]) AC_REPLACE_FUNCS(setenv) # Assuan check for descriptor passing. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-03 09:56:27 UTC (rev 1498) @@ -219,15 +219,21 @@ cd ../contrib/conf-w32ce-msc ; \ cp -t $(targetsrc)/gpgme/src $(conf_sources) - +# We create a dummy sehmap.h which will be included first due to -I. . +# For some reasons sehmap.h is included by MSC for WindowsCE and +# introduces a macro "leave" which conflicts of our use of "leave" for +# a label (leave and enter are pretty common names for pro- and epilog +# code). copy-built-source: @if [ ! -f ./gpgme.h ]; then \ echo "Please build using ./autogen.sh --build-w32ce first"; \ exit 1; \ fi cp -t $(targetsrc)/gpgme/src $(built_sources) + echo '/* Dummy replacement for useless header. */' \ + > $(targetsrc)/gpgme/src/sehmap.h -copy-source: copy-static-source copy-built-source +copy-source: copy-static-source copy-built-source .c.obj: Modified: trunk/src/ath.c =================================================================== --- trunk/src/ath.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/ath.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -33,7 +33,9 @@ # include # endif #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #ifndef HAVE_W32_SYSTEM #include #endif @@ -60,7 +62,6 @@ } #else # ifdef __linux -#include #include uintptr_t ath_self (void) Modified: trunk/src/ath.h =================================================================== --- trunk/src/ath.h 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/ath.h 2010-11-03 09:56:27 UTC (rev 1498) @@ -40,7 +40,9 @@ # include # endif # endif -# include +# ifdef HAVE_SYS_TYPES_H +# include +# endif # include #endif /*!HAVE_W32_SYSTEM*/ Modified: trunk/src/conversion.c =================================================================== --- trunk/src/conversion.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/conversion.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -25,8 +25,10 @@ #include #include -/* Solaris 8 needs sys/types.h before time.h. */ -#include +#ifdef HAVE_SYS_TYPES_H + /* Solaris 8 needs sys/types.h before time.h. */ +# include +#endif #include #include Modified: trunk/src/data-compat.c =================================================================== --- trunk/src/data-compat.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/data-compat.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -26,7 +26,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_STAT_H +# include +#endif #include #include "data.h" Modified: trunk/src/data-fd.c =================================================================== --- trunk/src/data-fd.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/data-fd.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -25,7 +25,9 @@ #ifdef HAVE_UNISTD_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "debug.h" #include "data.h" Modified: trunk/src/data-stream.c =================================================================== --- trunk/src/data-stream.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/data-stream.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -23,7 +23,9 @@ #endif #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "debug.h" #include "data.h" Modified: trunk/src/data-user.c =================================================================== --- trunk/src/data-user.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/data-user.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -22,7 +22,9 @@ #include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include "debug.h" Modified: trunk/src/data.h =================================================================== --- trunk/src/data.h 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/data.h 2010-11-03 09:56:27 UTC (rev 1498) @@ -25,7 +25,9 @@ #include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include "gpgme.h" Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/debug.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -33,9 +33,13 @@ #include #include #ifndef HAVE_DOSISH_SYSTEM +# ifdef HAVE_SYS_TYPES_H # include +# endif +# ifdef HAVE_SYS_STAT_H # include -# include +# endif +# include #endif #include Modified: trunk/src/engine-assuan.c =================================================================== --- trunk/src/engine-assuan.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/engine-assuan.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -30,7 +30,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include Modified: trunk/src/engine-g13.c =================================================================== --- trunk/src/engine-g13.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/engine-g13.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -25,7 +25,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include Modified: trunk/src/engine-gpgconf.c =================================================================== --- trunk/src/engine-gpgconf.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/engine-gpgconf.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -24,7 +24,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/engine-gpgsm.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -26,7 +26,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include Modified: trunk/src/engine-uiserver.c =================================================================== --- trunk/src/engine-uiserver.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/engine-uiserver.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -29,7 +29,9 @@ #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_UNISTD_H # include Modified: trunk/src/gpgme-w32spawn.c =================================================================== --- trunk/src/gpgme-w32spawn.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/gpgme-w32spawn.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -28,8 +28,12 @@ #include #include #include -#include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif #include #include #include Modified: trunk/src/keylist.c =================================================================== --- trunk/src/keylist.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/keylist.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -25,8 +25,10 @@ #include #include #include -/* Solaris 8 needs sys/types.h before time.h. */ -#include +#ifdef HAVE_SYS_TYPES_H + /* Solaris 8 needs sys/types.h before time.h. */ +# include +#endif #include #include #include Modified: trunk/src/memrchr.c =================================================================== --- trunk/src/memrchr.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/memrchr.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -52,7 +52,9 @@ # define LONG_MAX LONG_MAX_32_BITS #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #undef __memrchr #undef memrchr Modified: trunk/src/posix-io.c =================================================================== --- trunk/src/posix-io.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/posix-io.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -34,7 +34,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #ifdef HAVE_SYS_UIO_H # include Modified: trunk/src/posix-sema.c =================================================================== --- trunk/src/posix-sema.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/posix-sema.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -35,7 +35,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "util.h" #include "sema.h" Modified: trunk/src/priv-io.h =================================================================== --- trunk/src/priv-io.h 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/priv-io.h 2010-11-03 09:56:27 UTC (rev 1498) @@ -32,7 +32,9 @@ #endif /* For pid_t. */ -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif /* A single file descriptor passed to spawn. For child fds, dup_to Modified: trunk/src/setenv.c =================================================================== --- trunk/src/setenv.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/setenv.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -20,6 +20,7 @@ # include #endif +#include #include #define __set_errno(ev) (gpg_err_set_errno (ev)) Modified: trunk/src/util.h =================================================================== --- trunk/src/util.h 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/util.h 2010-11-03 09:56:27 UTC (rev 1498) @@ -31,7 +31,9 @@ #endif /* For pid_t. */ -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "gpgme.h" Modified: trunk/src/w32-ce.c =================================================================== --- trunk/src/w32-ce.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/w32-ce.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -290,7 +290,7 @@ { wchar_t *name; LONG err; - BYTE *data; + void *data; DWORD data_len; DWORD type; @@ -335,8 +335,8 @@ int data_c_len; /* This is valid since we allocated one more above. */ - data[data_len] = '\0'; - data[data_len + 1] = '\0'; + ((char*)data)[data_len] = '\0'; + ((char*)data)[data_len + 1] = '\0'; data_c = wchar_to_utf8 ((wchar_t*) data); if (!data_c) @@ -445,3 +445,31 @@ lpszPath[MAX_PATH - 1] = '\0'; return result; } + +/* Replacement for the access function. Note that we can't use fopen + here because wince might now allow to have a shared read for an + executable; it is better to to read the file attributes. + + Limitation: Only F_OK is supported. +*/ +int +_gpgme_wince_access (const char *fname, int mode) +{ + DWORD attr; + wchar_t *wfname; + + (void)mode; + + wfname = utf8_to_wchar (fname); + if (!wfname) + return -1; + + attr = GetFileAttributes (wfname); + free (wfname); + if (attr == (DWORD)(-1)) + { + gpg_err_set_errno (ENOENT); + return -1; + } + return 0; +} Modified: trunk/src/w32-ce.h =================================================================== --- trunk/src/w32-ce.h 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/w32-ce.h 2010-11-03 09:56:27 UTC (rev 1498) @@ -67,5 +67,9 @@ #define SHGetSpecialFolderPathA _gpgme_wince_SHGetSpecialFolderPathA BOOL SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL); +int _gpgme_wince_access (const char *fname, int mode); +#define access(a,b) _gpgme_wince_access ((a), (b)) + + #endif /* GPGME_W32_CE_H */ Modified: trunk/src/w32-glib-io.c =================================================================== --- trunk/src/w32-glib-io.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/w32-glib-io.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -34,7 +34,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include #include Modified: trunk/src/w32-io.c =================================================================== --- trunk/src/w32-io.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/w32-io.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -31,7 +31,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include "util.h" Modified: trunk/src/w32-sema.c =================================================================== --- trunk/src/w32-sema.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/w32-sema.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -31,7 +31,9 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include "util.h" Modified: trunk/src/w32-util.c =================================================================== --- trunk/src/w32-util.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/w32-util.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -32,8 +32,12 @@ #ifdef HAVE_SYS_TIME_H # include #endif -#include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif #ifdef HAVE_UNISTD_H # include #endif @@ -104,7 +108,6 @@ } #endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */ - void _gpgme_allow_set_foreground_window (pid_t pid) { Modified: trunk/src/wait.c =================================================================== --- trunk/src/wait.c 2010-11-02 20:17:57 UTC (rev 1497) +++ trunk/src/wait.c 2010-11-03 09:56:27 UTC (rev 1498) @@ -26,7 +26,9 @@ #include #include #include -#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include "util.h" #include "context.h" From cvs at cvs.gnupg.org Wed Nov 3 11:33:11 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 03 Nov 2010 11:33:11 +0100 Subject: [svn] gpgme - r1499 - trunk/src Message-ID: Author: wk Date: 2010-11-03 11:33:10 +0100 (Wed, 03 Nov 2010) New Revision: 1499 Modified: trunk/src/ChangeLog trunk/src/debug.c trunk/src/signers.c trunk/src/w32-ce.c trunk/src/w32-ce.h trunk/src/w32-util.c Log: Hopefully last changes for building with MSC. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-03 09:56:27 UTC (rev 1498) +++ trunk/src/ChangeLog 2010-11-03 10:33:10 UTC (rev 1499) @@ -1,10 +1,18 @@ 2010-11-03 Werner Koch + * debug.c (_gpgme_debug) [W32CE]: Replace locatime by GetLocalTime. + + * signers.c (gpgme_signers_clear): Remove useless return. + Reported by Patrick Spendrin. + + * w32-util.c: s/__inline__/GPG_ERR_INLINE/ + * setenv.c: Include string.h due to our strerror replacement. - * w32-ce.h (access): New macro. + * w32-ce.h (access, bsearch): New macros. * w32-ce.c (_gpgme_wince_access): New. (RegQueryValueExA): Change DATA to a void*. + (_gpgme_wince_bsearch): New. Taken from glibc 2.6. Guard include of sys/stat.h and sys/types.h. Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2010-11-03 09:56:27 UTC (rev 1498) +++ trunk/src/debug.c 2010-11-03 10:33:10 UTC (rev 1499) @@ -209,6 +209,15 @@ va_start (arg_ptr, format); LOCK (debug_lock); { +#ifdef HAVE_W32CE_SYSTEM + SYSTEMTIME t; + + GetLocalTime (&t); + fprintf (errfp, "GPGME %04d-%02d-%02d %02d:%02d:%02d <0x%04llx> ", + t.wYear, t.wMonth, t.wDay, + t.wHour, t.wMinute, t.wSecond, + (unsigned long long) ath_self ()); +#else struct tm *tp; time_t atime = time (NULL); @@ -217,6 +226,7 @@ 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, (unsigned long long) ath_self ()); +#endif } #ifdef FRAME_NR { Modified: trunk/src/signers.c =================================================================== --- trunk/src/signers.c 2010-11-03 09:56:27 UTC (rev 1498) +++ trunk/src/signers.c 2010-11-03 10:33:10 UTC (rev 1499) @@ -57,7 +57,7 @@ gpgme_signers_clear (gpgme_ctx_t ctx) { TRACE (DEBUG_CTX, "gpgme_signers_clear", ctx); - return _gpgme_signers_clear (ctx); + _gpgme_signers_clear (ctx); } Modified: trunk/src/w32-ce.c =================================================================== --- trunk/src/w32-ce.c 2010-11-03 09:56:27 UTC (rev 1498) +++ trunk/src/w32-ce.c 2010-11-03 10:33:10 UTC (rev 1499) @@ -1,5 +1,6 @@ /* w32-ce.h Copyright (C) 2010 g10 Code GmbH + Copyright (C) 1991,92,97,2000,02 Free Software Foundation, Inc. This file is part of GPGME. @@ -14,9 +15,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + License along with this program; if not, see . + */ #ifdef HAVE_CONFIG_H #include @@ -473,3 +473,35 @@ } return 0; } + + +/* Perform a binary search for KEY in BASE which has NMEMB elements + of SIZE bytes each. The comparisons are done by (*COMPAR)(). + Code taken from glibc-2.6. */ +void * +_gpgme_wince_bsearch (const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *)) +{ + size_t l, u, idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p); + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} + Modified: trunk/src/w32-ce.h =================================================================== --- trunk/src/w32-ce.h 2010-11-03 09:56:27 UTC (rev 1498) +++ trunk/src/w32-ce.h 2010-11-03 10:33:10 UTC (rev 1499) @@ -70,6 +70,11 @@ int _gpgme_wince_access (const char *fname, int mode); #define access(a,b) _gpgme_wince_access ((a), (b)) +void *_gpgme_wince_bsearch (const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *)); +#define bsearch(a,b,c,d,e) _gpgme_wince_bsearch ((a),(b),(c),(d),(e)) + #endif /* GPGME_W32_CE_H */ Modified: trunk/src/w32-util.c =================================================================== --- trunk/src/w32-util.c 2010-11-03 09:56:27 UTC (rev 1498) +++ trunk/src/w32-util.c 2010-11-03 10:33:10 UTC (rev 1499) @@ -76,14 +76,14 @@ #define RTLD_LAZY 0 -static __inline__ void * +static GPG_ERR_INLINE void * dlopen (const char * name, int flag) { void * hd = LoadLibrary (name); return hd; } -static __inline__ void * +static GPG_ERR_INLINE void * dlsym (void * hd, const char * sym) { if (hd && sym) @@ -96,7 +96,7 @@ return NULL; } -static __inline__ int +static GPG_ERR_INLINE int dlclose (void * hd) { if (hd) From cvs at cvs.gnupg.org Thu Nov 4 09:16:59 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 04 Nov 2010 09:16:59 +0100 Subject: [svn] gpgme - r1500 - in trunk: . contrib contrib/conf-w32ce-msc src Message-ID: Author: wk Date: 2010-11-04 09:16:57 +0100 (Thu, 04 Nov 2010) New Revision: 1500 Removed: trunk/src/memrchr.c Modified: trunk/THANKS trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk trunk/src/ChangeLog trunk/src/export.c trunk/src/w32-ce.h Log: More changes for W32CE with MSC. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-03 10:33:10 UTC (rev 1499) +++ trunk/contrib/ChangeLog 2010-11-04 08:16:57 UTC (rev 1500) @@ -1,3 +1,8 @@ +2010-11-04 Werner Koch + + * conf-w32ce-msc/build.mk (copy-built-source): Revert last + change. Does not work with W32CE where MSC defines it in except.h. + 2010-11-03 Werner Koch * conf-w32ce-msc/build.mk (copy-built-source): Create dummy sehmap.h. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-03 10:33:10 UTC (rev 1499) +++ trunk/src/ChangeLog 2010-11-04 08:16:57 UTC (rev 1500) @@ -1,3 +1,11 @@ +2010-11-04 Werner Koch + + * w32-ce.h [_MSC_VER && W32CE]: Undef leave. + * export.c: Include util.h so that we get the above undef. + + * memrchr.c: Remove. Used to be a replacement function required + by the formerly included assuan code. + 2010-11-03 Werner Koch * debug.c (_gpgme_debug) [W32CE]: Replace locatime by GetLocalTime. Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2010-11-03 10:33:10 UTC (rev 1499) +++ trunk/THANKS 2010-11-04 08:16:57 UTC (rev 1500) @@ -17,12 +17,13 @@ Mark Mutz mutz at kde.org Miguel Coca mcoca at gnu.org Noel Torres envite at rolamasao.org +Patrick Spendrin patrick.spendrin at kdab.com St?phane Corth?sy stephane at sente.ch Timo Schulz twoaday at freakmail.de Tommy Reynolds reynolds at redhat.com - Copyright 2001, 2002, 2004 g10 Code GmbH + Copyright 2001, 2002, 2004, 2010 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-03 10:33:10 UTC (rev 1499) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-04 08:16:57 UTC (rev 1500) @@ -219,19 +219,13 @@ cd ../contrib/conf-w32ce-msc ; \ cp -t $(targetsrc)/gpgme/src $(conf_sources) -# We create a dummy sehmap.h which will be included first due to -I. . -# For some reasons sehmap.h is included by MSC for WindowsCE and -# introduces a macro "leave" which conflicts of our use of "leave" for -# a label (leave and enter are pretty common names for pro- and epilog -# code). copy-built-source: @if [ ! -f ./gpgme.h ]; then \ echo "Please build using ./autogen.sh --build-w32ce first"; \ exit 1; \ fi cp -t $(targetsrc)/gpgme/src $(built_sources) - echo '/* Dummy replacement for useless header. */' \ - > $(targetsrc)/gpgme/src/sehmap.h + echo '/* Dummy io.h header. */' > $(targetsrc)/gpgme/src/io.h copy-source: copy-static-source copy-built-source Modified: trunk/src/export.c =================================================================== --- trunk/src/export.c 2010-11-03 10:33:10 UTC (rev 1499) +++ trunk/src/export.c 2010-11-04 08:16:57 UTC (rev 1500) @@ -25,6 +25,7 @@ #include #include "gpgme.h" +#include "util.h" #include "debug.h" #include "context.h" #include "ops.h" Modified: trunk/src/w32-ce.h =================================================================== --- trunk/src/w32-ce.h 2010-11-03 10:33:10 UTC (rev 1499) +++ trunk/src/w32-ce.h 2010-11-04 08:16:57 UTC (rev 1500) @@ -75,6 +75,11 @@ int (*compar) (const void *, const void *)); #define bsearch(a,b,c,d,e) _gpgme_wince_bsearch ((a),(b),(c),(d),(e)) +/* Remove the redefined __leave keyword. It is defined by MSC for W32 + in excpt.h and not in sehmap.h as for the plain windows + version. */ +#if defined(_MSC_VER) && defined(HAVE_W32CE_SYSTEM) +# undef leave +#endif - #endif /* GPGME_W32_CE_H */ From cvs at cvs.gnupg.org Thu Nov 4 15:56:18 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 04 Nov 2010 15:56:18 +0100 Subject: [svn] gcry - r1448 - in trunk: cipher random src Message-ID: Author: wk Date: 2010-11-04 15:56:17 +0100 (Thu, 04 Nov 2010) New Revision: 1448 Modified: trunk/cipher/pubkey.c trunk/random/random.c trunk/src/dumpsexp.c trunk/src/global.c Log: Doc fixes. Started some work on dumpsexp. Modified: trunk/cipher/pubkey.c =================================================================== --- trunk/cipher/pubkey.c 2010-10-18 10:12:23 UTC (rev 1447) +++ trunk/cipher/pubkey.c 2010-11-04 14:56:17 UTC (rev 1448) @@ -2503,8 +2503,8 @@ care or a combination of the GCRY_PK_USAGE_xxx flags; GCRYCTL_GET_ALGO_USAGE: - Return the usage glafs for the give algo. An invalid alog - does return 0. Disabled algos are ignored here because we + Return the usage flags for the given algo. An invalid algo + returns 0. Disabled algos are ignored here because we only want to know whether the algo is at all capable of the usage. Modified: trunk/random/random.c =================================================================== --- trunk/random/random.c 2010-10-18 10:12:23 UTC (rev 1447) +++ trunk/random/random.c 2010-11-04 14:56:17 UTC (rev 1448) @@ -92,14 +92,14 @@ } -/* This function should be called during initialization and beore +/* This function should be called during initialization and before initialization of this module to place the random pools into secure memory. */ void _gcry_secure_random_alloc (void) { if (fips_mode ()) - ; /* Not used; the fips rng is allows in secure mode. */ + ; /* Not used; the FIPS RNG is always in secure mode. */ else _gcry_rngcsprng_secure_alloc (); } Modified: trunk/src/dumpsexp.c =================================================================== --- trunk/src/dumpsexp.c 2010-10-18 10:12:23 UTC (rev 1447) +++ trunk/src/dumpsexp.c 2010-11-04 14:56:17 UTC (rev 1448) @@ -1,12 +1,12 @@ /* dumpsexp.c - Dump S-expressions. - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007, 2010 Free Software Foundation, Inc. * - * Getrandom is free software; you can redistribute it and/or modify + * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, + * by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * - * Getrandom is distributed in the hope that it will be useful, but + * This program 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. @@ -36,14 +36,15 @@ static int verbose; /* Verbose mode. */ static int decimal; /* Print addresses in decimal. */ static int assume_hex; /* Assume input is hexencoded. */ +static int advanced; /* Advanced format output. */ static void print_version (int with_help) { fputs (MYVERSION_LINE "\n" - "Copyright (C) 2007 Free Software Foundation, Inc.\n" - "License GPLv2+: GNU GPL version 2 or later " - "\n" + "Copyright (C) 2010 Free Software Foundation, Inc.\n" + "License GPLv3+: GNU GPL version 3 or later " + "\n" "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n", stdout); @@ -55,6 +56,7 @@ "\n" " --decimal Print offsets using decimal notation\n" " --assume-hex Assume input is a hex dump\n" + " --advanced Print file in advanced format\n" " --verbose Show what we are doing\n" " --version Print version of the program and exit\n" " --help Display this help and exit\n" @@ -258,7 +260,7 @@ static void printctl (const char *text) { - if (verbose) + if (verbose && !advanced) { printcursor (0); printf ("%s\n", text); @@ -268,19 +270,125 @@ static void printchr (int c) { - (void)c; + putchar (c); } static void printhex (int c) { - (void)c; + printf ("\\x%02x", c); } +#if 0 +/**************** + * Print SEXP to buffer using the MODE. Returns the length of the + * SEXP in buffer or 0 if the buffer is too short (We have at least an + * empty list consisting of 2 bytes). If a buffer of NULL is provided, + * the required length is returned. + */ +size_t +gcry_sexp_sprint (const gcry_sexp_t list, + void *buffer, size_t maxlength ) +{ + static unsigned char empty[3] = { ST_OPEN, ST_CLOSE, ST_STOP }; + const unsigned char *s; + char *d; + DATALEN n; + char numbuf[20]; + int i, indent = 0; + + s = list? list->d : empty; + d = buffer; + while ( *s != ST_STOP ) + { + switch ( *s ) + { + case ST_OPEN: + s++; + if (indent) + putchar ('\n'); + for (i=0; i < indent; i++) + putchar (' '); + putchar ('('); + indent++; + break; + case ST_CLOSE: + s++; + putchar (')'); + indent--; + if (*s != ST_OPEN && *s != ST_STOP) + { + putchar ('\n'); + for (i=0; i < indent; i++) + putchar (' '); + } + break; + case ST_DATA: + s++; + memcpy (&n, s, sizeof n); + s += sizeof n; + { + int type; + size_t nn; + + switch ( (type=suitable_encoding (s, n))) + { + case 1: nn = convert_to_string (s, n, NULL); break; + case 2: nn = convert_to_token (s, n, NULL); break; + default: nn = convert_to_hex (s, n, NULL); break; + } + switch (type) + { + case 1: convert_to_string (s, n, d); break; + case 2: convert_to_token (s, n, d); break; + default: convert_to_hex (s, n, d); break; + } + d += nn; + if (s[n] != ST_CLOSE) + putchar (' '); + } + else + { + snprintf (numbuf, sizeof numbuf, "%u:", (unsigned int)n ); + d = stpcpy (d, numbuf); + memcpy (d, s, n); + d += n; + } + s += n; + break; + default: + BUG (); + } + } + putchar ('\n'); + return len; +} +#endif +/* Prepare for saving a chunk of data. */ +static void +init_data (void) +{ +} + +/* Push C on the current data chunk. */ +static void +push_data (int c) +{ + +} + +/* Flush and thus print the current data chunk. */ +static void +flush_data (void) +{ + +} + + /* Returns 0 on success. */ static int parse_and_print (FILE *fp) @@ -346,17 +454,20 @@ { state = IN_STRING; printctl ("beginstring"); + init_data (); } else if (c == '#') { state = IN_HEXFMT; hexcount = 0; printctl ("beginhex"); + init_data (); } else if (c == '|') { state = IN_BASE64; printctl ("beginbase64"); + init_data (); } else if (c == '[') { @@ -434,16 +545,18 @@ case PRE_DATA: state = IN_DATA; printctl ("begindata"); + init_data (); case IN_DATA: if (datalen) { - printhex (c); + push_data (c); datalen--; } if (!datalen) { state = INIT_STATE; printctl ("enddata"); + flush_data (); } break; @@ -451,22 +564,27 @@ if (c == '\"') { printctl ("endstring"); + flush_data (); state = INIT_STATE; } else if (c == '\\') state = IN_ESCAPE; else - printchr (c); + push_data (c); break; case IN_ESCAPE: switch (c) { - case 'b': case 't': case 'v': case 'n': case 'f': - case 'r': case '"': case '\'': case '\\': - printhex (c); - state = IN_STRING; - break; + case 'b': push_data ('\b'); state = IN_STRING; break; + case 't': push_data ('\t'); state = IN_STRING; break; + case 'v': push_data ('\v'); state = IN_STRING; break; + case 'n': push_data ('\n'); state = IN_STRING; break; + case 'f': push_data ('\f'); state = IN_STRING; break; + case 'r': push_data ('\r'); state = IN_STRING; break; + case '"': push_data ('"'); state = IN_STRING; break; + case '\'': push_data ('\''); state = IN_STRING; break; + case '\\': push_data ('\\'); state = IN_STRING; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': @@ -501,9 +619,9 @@ quote_buf[quote_idx++] = c; if (quote_idx == 3) { - printchr ((unsigned int)quote_buf[0] * 8 * 8 - + (unsigned int)quote_buf[1] * 8 - + (unsigned int)quote_buf[2]); + push_data ((unsigned int)quote_buf[0] * 8 * 8 + + (unsigned int)quote_buf[1] * 8 + + (unsigned int)quote_buf[2]); state = IN_STRING; } } @@ -516,9 +634,8 @@ quote_buf[quote_idx++] = c; if (quote_idx == 2) { - printchr (xtoi_1 (quote_buf[0]) * 16 - + xtoi_1 (quote_buf[1])); - + push_data (xtoi_1 (quote_buf[0]) * 16 + + xtoi_1 (quote_buf[1])); state = IN_STRING; } } @@ -535,7 +652,7 @@ case IN_HEXFMT: if (hexdigit_p (c)) { - printchr (c); + push_data (c); hexcount++; } else if (c == '#') @@ -543,6 +660,7 @@ if ((hexcount & 1)) printerr ("odd number of hex digits"); printctl ("endhex"); + flush_data (); state = INIT_STATE; } else if (!whitespace_p (c)) @@ -553,10 +671,11 @@ if (c == '|') { printctl ("endbase64"); + flush_data (); state = INIT_STATE; } else - printchr (c); + push_data (c); break; default: @@ -610,6 +729,11 @@ argc--; argv++; assume_hex = 1; } + else if (!strcmp (*argv, "--advanced")) + { + argc--; argv++; + advanced = 1; + } else print_usage (); } Modified: trunk/src/global.c =================================================================== --- trunk/src/global.c 2010-10-18 10:12:23 UTC (rev 1447) +++ trunk/src/global.c 2010-11-04 14:56:17 UTC (rev 1448) @@ -501,7 +501,7 @@ case GCRYCTL_FORCE_FIPS_MODE: /* Performing this command puts the library into fips mode. If the library has already been initialized into fips mode, a - selftest is triggered. it is not possible to put the libraty + selftest is triggered. It is not possible to put the libraty into fips mode after having passed the initialization. */ if (!any_init_done) { From cvs at cvs.gnupg.org Mon Nov 8 10:18:48 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 08 Nov 2010 10:18:48 +0100 Subject: [svn] GnuPG - r5479 - trunk/common Message-ID: Author: wk Date: 2010-11-08 10:18:47 +0100 (Mon, 08 Nov 2010) New Revision: 5479 Modified: trunk/common/ChangeLog trunk/common/logging.c Log: A merged changes Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-10-29 19:54:56 UTC (rev 5478) +++ trunk/common/ChangeLog 2010-11-08 09:18:47 UTC (rev 5479) @@ -1,3 +1,8 @@ +2010-11-04 Werner Koch + + * logging.c (do_logv) [W32]: Don't set a default log stream if the + registry entry is empty. + 2010-10-27 Werner Koch * gettime.c (gnupg_get_isotime): Compare to (time_t)-1. Modified: trunk/common/logging.c =================================================================== --- trunk/common/logging.c 2010-10-29 19:54:56 UTC (rev 5478) +++ trunk/common/logging.c 2010-11-08 09:18:47 UTC (rev 5479) @@ -577,7 +577,7 @@ tmp = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", "DefaultLogFile"); - log_set_file (tmp); + log_set_file (tmp && *tmp? tmp : NULL); jnlib_free (tmp); #else log_set_file (NULL); /* Make sure a log stream has been set. */ From cvs at cvs.gnupg.org Wed Nov 10 13:49:39 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 10 Nov 2010 13:49:39 +0100 Subject: [svn] GnuPG - r5480 - trunk/g13 Message-ID: Author: wk Date: 2010-11-10 13:49:39 +0100 (Wed, 10 Nov 2010) New Revision: 5480 Added: trunk/g13/encfs-1.5_annotate.diff trunk/g13/encfs-1.7.3_annotate.diff Log: Add patches for EncFs From cvs at cvs.gnupg.org Thu Nov 11 16:07:38 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 11 Nov 2010 16:07:38 +0100 Subject: [svn] GnuPG - r5481 - in trunk: . agent Message-ID: Author: wk Date: 2010-11-11 16:07:37 +0100 (Thu, 11 Nov 2010) New Revision: 5481 Modified: trunk/NEWS trunk/agent/ChangeLog trunk/agent/agent.h trunk/agent/call-scd.c trunk/agent/gpg-agent.c Log: Fix bug where scdaemon kills a non-daemon gpg-agent. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-11-10 12:49:39 UTC (rev 5480) +++ trunk/agent/ChangeLog 2010-11-11 15:07:37 UTC (rev 5481) @@ -1,3 +1,9 @@ +2010-11-11 Werner Koch + + * agent.h (opt): Add field SIGUSR2_ENABLED. + * gpg-agent.c (handle_connections): Set that flag. + * call-scd.c (start_scd): Enable events depending on this flag. + 2010-10-27 Werner Koch * gpg-agent.c (create_socket_name): Use TMPDIR. Change callers. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-11-10 12:49:39 UTC (rev 5480) +++ trunk/NEWS 2010-11-11 15:07:37 UTC (rev 5481) @@ -4,7 +4,10 @@ * TMPDIR is now also honored when creating a socket using --no-standard-socket and with symcryptrun's temp files. + * Fixed a bug where Scdaemon sends a signal to Gpg-agent running in + non-daemon mode. + Noteworthy changes in version 2.1.0beta1 (2010-10-26) ----------------------------------------------------- Modified: trunk/agent/agent.h =================================================================== --- trunk/agent/agent.h 2010-11-10 12:49:39 UTC (rev 5480) +++ trunk/agent/agent.h 2010-11-11 15:07:37 UTC (rev 5481) @@ -58,6 +58,9 @@ /* True if we are listening on the standard socket. */ int use_standard_socket; + /* True if we handle sigusr2. */ + int sigusr2_enabled; + /* Environment setting gathered at program start or changed using the Assuan command UPDATESTARTUPTTY. */ session_env_t startup_env; Modified: trunk/agent/call-scd.c =================================================================== --- trunk/agent/call-scd.c 2010-11-10 12:49:39 UTC (rev 5480) +++ trunk/agent/call-scd.c 2010-11-11 15:07:37 UTC (rev 5481) @@ -399,17 +399,18 @@ /* Tell the scdaemon we want him to send us an event signal. We don't support this for W32CE. */ #ifndef HAVE_W32CE_SYSTEM - { - char buf[100]; - + if (opt.sigusr2_enabled) + { + char buf[100]; + #ifdef HAVE_W32_SYSTEM - snprintf (buf, sizeof buf, "OPTION event-signal=%lx", - (unsigned long)get_agent_scd_notify_event ()); + snprintf (buf, sizeof buf, "OPTION event-signal=%lx", + (unsigned long)get_agent_scd_notify_event ()); #else - snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2); + snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2); #endif - assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); - } + assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); + } #endif /*HAVE_W32CE_SYSTEM*/ primary_scd_ctx = ctx; Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2010-11-10 12:49:39 UTC (rev 5480) +++ trunk/agent/gpg-agent.c 2010-11-11 15:07:37 UTC (rev 5481) @@ -1894,6 +1894,10 @@ #endif time_ev = NULL; + /* Set a flag to tell call-scd.c that it may enable event + notifications. */ + opt.sigusr2_enabled = 1; + FD_ZERO (&fdset); FD_SET (FD2INT (listen_fd), &fdset); nfd = FD2INT (listen_fd); From cvs at cvs.gnupg.org Thu Nov 11 16:08:50 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 11 Nov 2010 16:08:50 +0100 Subject: [svn] GnuPG - r5482 - in branches/STABLE-BRANCH-2-0: . agent doc Message-ID: Author: wk Date: 2010-11-11 16:08:48 +0100 (Thu, 11 Nov 2010) New Revision: 5482 Modified: branches/STABLE-BRANCH-2-0/NEWS branches/STABLE-BRANCH-2-0/agent/ChangeLog branches/STABLE-BRANCH-2-0/agent/agent.h branches/STABLE-BRANCH-2-0/agent/call-scd.c branches/STABLE-BRANCH-2-0/agent/findkey.c branches/STABLE-BRANCH-2-0/agent/gpg-agent.c branches/STABLE-BRANCH-2-0/doc/gpg.texi Log: Fix a bug where scdaemon kills a non-daemon gpg-agent. Fix a passphrase cache annoyance. Modified: branches/STABLE-BRANCH-2-0/agent/ChangeLog =================================================================== --- branches/STABLE-BRANCH-2-0/agent/ChangeLog 2010-11-11 15:07:37 UTC (rev 5481) +++ branches/STABLE-BRANCH-2-0/agent/ChangeLog 2010-11-11 15:08:48 UTC (rev 5482) @@ -1,3 +1,14 @@ +2010-11-11 Werner Koch + + * agent.h (opt): Add field SIGUSR2_ENABLED. + * gpg-agent.c (handle_connections): Set that flag. + * call-scd.c (start_scd): Enable events depending on this flag. + +2010-09-30 Werner Koch + + * findkey.c (unprotect): Do not put the passphrase into the cache + if it has been changed. + 2010-09-24 Werner Koch * gpg-agent.c (main, reread_configuration): Always test whether @@ -2551,7 +2562,7 @@ Copyright 2001, 2002, 2003, 2004, 2005, - 2007, 2008, 2009 Free Software Foundation, Inc. + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: branches/STABLE-BRANCH-2-0/NEWS =================================================================== --- branches/STABLE-BRANCH-2-0/NEWS 2010-11-11 15:07:37 UTC (rev 5481) +++ branches/STABLE-BRANCH-2-0/NEWS 2010-11-11 15:08:48 UTC (rev 5482) @@ -7,7 +7,10 @@ * Allow more hash algorithms with the OpenPGP v2 card. + * Fixed a bug where Scdaemon sends a signal to Gpg-agent running in + non-daemon mode. + Noteworthy changes in version 2.0.16 (2010-07-19) ------------------------------------------------- Modified: branches/STABLE-BRANCH-2-0/agent/agent.h =================================================================== --- branches/STABLE-BRANCH-2-0/agent/agent.h 2010-11-11 15:07:37 UTC (rev 5481) +++ branches/STABLE-BRANCH-2-0/agent/agent.h 2010-11-11 15:08:48 UTC (rev 5482) @@ -64,6 +64,9 @@ /* True if we are listening on the standard socket. */ int use_standard_socket; + /* True if we handle sigusr2. */ + int sigusr2_enabled; + const char *pinentry_program; /* Filename of the program to start as pinentry. */ const char *scdaemon_program; /* Filename of the program to handle Modified: branches/STABLE-BRANCH-2-0/agent/call-scd.c =================================================================== --- branches/STABLE-BRANCH-2-0/agent/call-scd.c 2010-11-11 15:07:37 UTC (rev 5481) +++ branches/STABLE-BRANCH-2-0/agent/call-scd.c 2010-11-11 15:08:48 UTC (rev 5482) @@ -408,17 +408,18 @@ } /* Tell the scdaemon we want him to send us an event signal. */ - { - char buf[100]; - + if (opt.sigusr2_enabled) + { + char buf[100]; + #ifdef HAVE_W32_SYSTEM - snprintf (buf, sizeof buf, "OPTION event-signal=%lx", - (unsigned long)get_agent_scd_notify_event ()); + snprintf (buf, sizeof buf, "OPTION event-signal=%lx", + (unsigned long)get_agent_scd_notify_event ()); #else - snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2); + snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2); #endif - assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); - } + assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); + } primary_scd_ctx = ctx; primary_scd_ctx_reusable = 0; Modified: branches/STABLE-BRANCH-2-0/agent/findkey.c =================================================================== --- branches/STABLE-BRANCH-2-0/agent/findkey.c 2010-11-11 15:07:37 UTC (rev 5481) +++ branches/STABLE-BRANCH-2-0/agent/findkey.c 2010-11-11 15:08:48 UTC (rev 5482) @@ -407,8 +407,9 @@ return rc; } } - agent_put_cache (hexgrip, cache_mode, pi->pin, - lookup_ttl? lookup_ttl (hexgrip) : 0); + else + agent_put_cache (hexgrip, cache_mode, pi->pin, + lookup_ttl? lookup_ttl (hexgrip) : 0); xfree (*keybuf); *keybuf = arg.unprotected_key; } Modified: branches/STABLE-BRANCH-2-0/agent/gpg-agent.c =================================================================== --- branches/STABLE-BRANCH-2-0/agent/gpg-agent.c 2010-11-11 15:07:37 UTC (rev 5481) +++ branches/STABLE-BRANCH-2-0/agent/gpg-agent.c 2010-11-11 15:08:48 UTC (rev 5482) @@ -1892,6 +1892,10 @@ #endif time_ev = NULL; + /* Set a flag to tell call-scd.c that it may enable event + notifications. */ + opt.sigusr2_enabled = 1; + FD_ZERO (&fdset); FD_SET (FD2INT (listen_fd), &fdset); nfd = FD2INT (listen_fd); Modified: branches/STABLE-BRANCH-2-0/doc/gpg.texi =================================================================== --- branches/STABLE-BRANCH-2-0/doc/gpg.texi 2010-11-11 15:07:37 UTC (rev 5481) +++ branches/STABLE-BRANCH-2-0/doc/gpg.texi 2010-11-11 15:08:48 UTC (rev 5482) @@ -1,5 +1,5 @@ @c Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - at c 2008, 2009 Free Software Foundation, Inc. + at c 2008, 2009, 2010 Free Software Foundation, Inc. @c This is part of the GnuPG manual. @c For copying conditions, see the file gnupg.texi. @@ -415,8 +415,10 @@ command has the special property to render the secret part of the primary key useless; this is a GNU extension to OpenPGP and other implementations can not be expected to successfully import such a key. + at ifclear gpgtwoone See the option @option{--simple-sk-checksum} if you want to import such an exported key with an older OpenPGP implementation. + at end ifclear @item --import @itemx --fast-import @@ -527,12 +529,13 @@ With the second form (or a deprecated "*" as algo) digests for all available algorithms are printed. - at item --gen-random @code{0|1|2} + at item --gen-random @code{0|1|2} @code{count} @opindex gen-random -Emit @var{count} random bytes of the given quality level. If count is -not given or zero, an endless sequence of random bytes will be emitted. -PLEASE, don't use this command unless you know what you are doing; it -may remove precious entropy from the system! +Emit @var{count} random bytes of the given quality level 0, 1 or 2. If + at var{count} is not given or zero, an endless sequence of random bytes +will be emitted. If used with @option{--armor} the output will be +base64 encoded. PLEASE, don't use this command unless you know what +you are doing; it may remove precious entropy from the system! @item --gen-prime @code{mode} @code{bits} @opindex gen-prime @@ -1044,7 +1047,7 @@ @option{--check-sigs} listings. Defaults to no. @item show-uid-validity -Display the calculated validity of user IDs during public key listings. +Display the calculated validity of user IDs during key listings. Defaults to no. @item show-unusable-uids @@ -1549,6 +1552,7 @@ @item --max-cert-depth @code{n} Maximum depth of a certification chain (default is 5). + at ifclear gpgtwoone @item --simple-sk-checksum Secret keys are integrity protected by using a SHA-1 checksum. This method is part of the upcoming enhanced OpenPGP specification but @@ -1559,6 +1563,7 @@ the secret key is encrypted - the simplest way to make this happen is to change the passphrase on the key (even changing it to the same value is acceptable). + at end ifclear @item --no-sig-cache Do not cache the verification status of key signatures. @@ -1883,11 +1888,17 @@ Include designated revoker information that was marked as "sensitive". Defaults to no. + at c Since GnuPG 2.1 gpg-agent manages the secret key and thus the + at c export-reset-subkey-passwd hack is not anymore justified. Such use + at c cases need to be implemented using a specialized secret key export + at c tool. + at ifclear gpgtwoone @item export-reset-subkey-passwd When using the @option{--export-secret-subkeys} command, this option resets the passphrases for all exported subkeys to empty. This is useful when the exported subkey is to be used on an unattended machine where a passphrase doesn't necessarily make sense. Defaults to no. + at end ifclear @item export-clean Compact (remove all signatures from) user IDs on the key being @@ -1963,10 +1974,11 @@ OpenPGP states that an implementation should generate v4 signatures but PGP versions 5 through 7 only recognize v4 signatures on key material. This option forces v3 signatures for signatures on data. -Note that this option implies @option{--ask-sig-expire}, +Note that this option implies @option{--no-ask-sig-expire}, and unsets @option{--sig-policy-url}, @option{--sig-notation}, and @option{--sig-keyserver-url}, as these features cannot be used with v3 signatures. @option{--no-force-v3-sigs} disables this option. +Defaults to no. @item --force-v4-certs @itemx --no-force-v4-certs @@ -2196,6 +2208,13 @@ Note that this option is only available on some system. @end ifset + at item --faked-system-time @var{epoch} + at opindex faked-system-time +This option is only useful for testing; it sets the system time back or +forth to @var{epoch} which is the number of seconds elapsed since the year +1970. Alternatively @var{epoch} may be given as a full ISO time string +(e.g. "20070924T154812"). + @item --enable-progress-filter Enable certain PROGRESS status outputs. This option allows frontends to display a progress indicator while gpg is processing larger files. @@ -2533,10 +2552,7 @@ When making a data signature, prompt for an expiration time. If this option is not specified, the expiration time set via @option{--default-sig-expire} is used. @option{--no-ask-sig-expire} -disables this option. Note that by default, @option{--force-v3-sigs} is -set which also disables this option. If you want signature expiration, -you must set @option{--no-force-v3-sigs} as well as turning - at option{--ask-sig-expire} on. +disables this option. @item --default-sig-expire The default expiration time to use for signature expiration. Valid From cvs at cvs.gnupg.org Mon Nov 15 07:54:15 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 15 Nov 2010 07:54:15 +0100 Subject: [svn] assuan - r396 - in trunk: . src Message-ID: Author: wk Date: 2010-11-15 07:54:15 +0100 (Mon, 15 Nov 2010) New Revision: 396 Modified: trunk/NEWS trunk/src/ChangeLog trunk/src/gpgcedev.c trunk/src/gpgcemgr.c Log: Add log device to gpgcedev Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-02 09:19:03 UTC (rev 395) +++ trunk/src/ChangeLog 2010-11-15 06:54:15 UTC (rev 396) @@ -1,3 +1,30 @@ +2010-11-15 Werner Koch + + * gpgcedev.c (GPG_Init): Read debug settings. + + * gpgcemgr.c (enable_debug, enable_log): New. + (main): Add options --enable-debug, --disable-debug, --enable-log, + --disable-log. + +2010-11-12 Werner Koch + + * gpgcedev.c (DEVCTX_VALUE): Rename to PIPECTX_VALUE. + (LOGCTX_VALUE): New. + (allocate_opnctx): Add arg IS_LOG. + (logimpl_t): New. + (openctx_t): Add field IS_LOG. + (struct logcontrol): New. + (enable_debug, enable_logging): New. + (log_debug): Make use of the ENABLE_DEBUG flag. + (create_log_id): New. + (logimpl_new, logimpl_unref, logimpl_flush, assert_logimpl): New. + (GPG_Init): Check for GPG2 device. + (GPG_Deinit): Close log stream. + (GPG_Open): Implement log device. + (GPG_Read): Return EOF for the GPG2 device + (GPG_Write): Implement GPG2 device. + (dllmain): Init logcontrol CS. + 2010-11-01 Werner Koch * assuan-socket.c (_assuan_sock_bind): Replace open/fdopen by Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-11-02 09:19:03 UTC (rev 395) +++ trunk/NEWS 2010-11-15 06:54:15 UTC (rev 396) @@ -5,6 +5,8 @@ * A new flag value may now be used to disable logging. + * The gpgcedev.c driver now provides a log device. + * Interface changes relative to the 2.0.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ASSUAN_CONVEY_COMMENTS NEW. Modified: trunk/src/gpgcedev.c =================================================================== --- trunk/src/gpgcedev.c 2010-11-02 09:19:03 UTC (rev 395) +++ trunk/src/gpgcedev.c 2010-11-15 06:54:15 UTC (rev 396) @@ -1,4 +1,4 @@ -/* gpgcedrv.c - WindowsCE device driver to implement a pipe. +/* gpgcedrv.c - WindowsCE device driver to implement pipe and syslog. Copyright (C) 2010 Free Software Foundation, Inc. This file is part of Assuan. @@ -20,14 +20,19 @@ #include #include +#include #include #include #include -#define ENABLE_DEBUG -#warning Cancel not handled. +/* FIXME Cancel not handled. */ +#define DBGFILENAME "\\gpgcedev.dbg" +#define LOGFILENAME L"\\gpgcedev.log" +#define GPGCEDEV_KEY_NAME L"Drivers\\GnuPG_Device" +#define GPGCEDEV_KEY_NAME2 L"Drivers\\GnuPG_Log" + /* Missing IOCTLs in the current mingw32ce. */ #ifndef IOCTL_PSL_NOTIFY # define FILE_DEVICE_PSL 259 @@ -74,6 +79,7 @@ CTL_CODE (FILE_DEVICE_STREAMS, 2051, METHOD_BUFFERED, FILE_ANY_ACCESS) +/* An object to describe a pipe. */ struct pipeimpl_s { CRITICAL_SECTION critsect; /* Lock for all members. */ @@ -101,18 +107,39 @@ typedef struct pipeimpl_s *pipeimpl_t; +/* An object to describe a logging context. We can't write directly + to the log stream because we want to do line buffering and thus we + need to store data until we see LF. */ +struct logimpl_s; +typedef struct logimpl_s *logimpl_t; +struct logimpl_s +{ + unsigned long logid; /* An identifier for a log source. */ + unsigned long dsec; /* Tenth of a second since system start. */ + char *line; /* Malloced line buffer. */ + size_t linesize; /* Allocated size of LINE. */ + size_t linelen; /* Used length of the line. */ + int truncated; /* Indicates a truncated log line. */ +}; + + + /* An object to store information pertaining to an open-context. */ struct opnctx_s; typedef struct opnctx_s *opnctx_t; struct opnctx_s { int inuse; /* True if this object has valid data. */ + int is_log; /* True if this describes a log device. */ LONG rvid; /* The unique rendezvous identifier. */ DWORD access_code;/* Value from OpenFile. */ DWORD share_mode; /* Value from OpenFile. */ - /* The state shared by all users. */ + /* The state shared by all pipe users. Only used if IS_LOG is false. */ pipeimpl_t pipeimpl; + + /* The state used to implement a log stream. Only used if IS_LOG is true. */ + logimpl_t logimpl; }; /* A malloced table of open-context and the number of allocated slots. */ @@ -126,38 +153,52 @@ /* A criticial section object used to protect the OPNCTX_TABLE. */ static CRITICAL_SECTION opnctx_table_cs; -/* We don't need a device context thus we use the adress of the - critical section object for it. */ -#define DEVCTX_VALUE ((DWORD)(&opnctx_table_cs)) -/* Constants used for our lock functions. */ -#define LOCK_TRY 0 -#define LOCK_WAIT 1 +/* A global object to control the logging. */ +struct { + CRITICAL_SECTION lock; /* Lock for this structure. */ + HANDLE filehd; /* Handle of the log output file. */ + int references; /* Number of objects references this one. */ +} logcontrol; +/* We don't need a device context for the pipe thus we use the adress + of the critical section object for it. */ +#define PIPECTX_VALUE ((DWORD)(&opnctx_table_cs)) + +/* The device context for the log device is the address of our + control structure. */ +#define LOGCTX_VALUE ((DWORD)(&logcontrol)) + + +/* True if we have enabled debugging. */ +static int enable_debug; + +/* True if logging has been enabled. */ +static int enable_logging; + + static void log_debug (const char *fmt, ...) { -#ifndef ENABLE_DEBUG - (void)fmt; -#else - va_list arg_ptr; - FILE *fp; - - fp = fopen ("\\gpgcedev.log", "a+"); - if (!fp) - return; - va_start (arg_ptr, fmt); - vfprintf (fp, fmt, arg_ptr); - va_end (arg_ptr); - fclose (fp); -#endif + if (enable_debug) + { + va_list arg_ptr; + FILE *fp; + + fp = fopen (DBGFILENAME, "a+"); + if (!fp) + return; + va_start (arg_ptr, fmt); + vfprintf (fp, fmt, arg_ptr); + va_end (arg_ptr); + fclose (fp); + } } -/* Return a new rendezvous next command id. Command Ids are used to group - resources of one command. We will never return an RVID of 0. */ +/* Return a new rendezvous id. We will never return an RVID of 0. */ static LONG create_rendezvous_id (void) { @@ -169,7 +210,21 @@ return rvid; } +/* Return a new log id. These log ids are used to identify log lines + send to the same device; ie. for each CreateFile("GPG2:") a new log + id is assigned. We will ever return a log id of 0. */ +static LONG +create_log_id (void) +{ + static LONG log_id; + LONG lid; + while (!(lid = InterlockedIncrement (&log_id))) + ; + return lid; +} + + pipeimpl_t pipeimpl_new (void) @@ -201,6 +256,9 @@ { int release = 0; + if (!pimpl) + return; + log_debug ("pipeimpl_unref (%p): dereference\n", pimpl); if (--pimpl->refcnt == 0) @@ -232,14 +290,83 @@ } + +/* Allocate a new log structure. */ +logimpl_t +logimpl_new (void) +{ + logimpl_t limpl; + limpl = calloc (1, sizeof *limpl); + if (!limpl) + return NULL; + limpl->logid = create_log_id (); + limpl->linesize = 256; + limpl->line = malloc (limpl->linesize); + if (!limpl->line) + { + free (limpl); + return NULL; + } + + return limpl; +} + + +/* There is no need to lock LIMPL, thus is a dummy function. */ +void +logimpl_unref (logimpl_t limpl) +{ + (void)limpl; +} + + +/* Flush a pending log line. */ +static void +logimpl_flush (logimpl_t limpl) +{ + if (!limpl->linelen || !enable_logging) + return; + + EnterCriticalSection (&logcontrol.lock); + if (logcontrol.filehd == INVALID_HANDLE_VALUE) + logcontrol.filehd = CreateFile (LOGFILENAME, GENERIC_WRITE, + FILE_SHARE_READ, + NULL, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); + if (!logcontrol.filehd) + log_debug ("can't open log file: rc=%d\n", (int)GetLastError ()); + else + { + char buf[50]; + DWORD nwritten; + + snprintf (buf, sizeof buf, + "%06lu/%lu//", limpl->dsec % 1000000, limpl->logid); + if (!WriteFile (logcontrol.filehd, buf, strlen (buf), &nwritten, NULL)) + log_debug ("error writing log file: rc=%d\n", (int)GetLastError ()); + else if (!WriteFile (logcontrol.filehd, + limpl->line, limpl->linelen, &nwritten, NULL)) + log_debug ("error writing log file: rc=%d\n", (int)GetLastError ()); + + snprintf (buf, sizeof buf, "%s\n", limpl->truncated? "[...]":""); + if (!WriteFile (logcontrol.filehd, buf, strlen (buf), &nwritten, NULL)) + log_debug ("error writing log file: rc=%d\n", (int)GetLastError ()); + } + + LeaveCriticalSection (&logcontrol.lock); + limpl->linelen = 0; + limpl->truncated = 0; +} + + /* Return a new opnctx handle and mark it as used. Returns NULL and sets LastError on memory failure etc. opnctx_table_cs must be locked on entry and is locked on exit. Note that the returned pointer is only valid as long as opnctx_table_cs stays locked, as it is not stable under table reallocation. */ static opnctx_t -allocate_opnctx (void) +allocate_opnctx (int is_log) { opnctx_t opnctx = NULL; int idx; @@ -265,10 +392,12 @@ } opnctx = &opnctx_table[idx]; opnctx->inuse = 1; + opnctx->is_log = is_log; opnctx->rvid = 0; opnctx->access_code = 0; opnctx->share_mode = 0; opnctx->pipeimpl = 0; + opnctx->logimpl = 0; leave: return opnctx; @@ -305,6 +434,12 @@ { DWORD ctx_arg = OPNCTX_TO_IDX (ctx); + if (ctx->is_log) + { + log_debug (" assert_pipeimpl (ctx=%i): " + "error: not valid for a log device\n", ctx_arg); + return NULL; + } if (! ctx->pipeimpl) { ctx->pipeimpl = pipeimpl_new (); @@ -321,42 +456,89 @@ } +static logimpl_t +assert_logimpl (opnctx_t ctx) +{ + DWORD ctx_arg = OPNCTX_TO_IDX (ctx); + + if (!ctx->is_log) + { + log_debug (" assert_logimpl (ctx=%i): " + "error: not valid for a pipe device\n", ctx_arg); + return NULL; + } + if (!ctx->logimpl) + { + ctx->logimpl = logimpl_new (); + if (!ctx->logimpl) + { + log_debug (" assert_logimpl (ctx=%i): error: can't create log\n", + ctx_arg); + return NULL; + } + log_debug (" assert_logimpl (ctx=%i): created log 0x%p\n", + ctx_arg, ctx->logimpl); + } + return ctx->logimpl; +} + + /* Verify access CODE for context CTX_ARG, returning a reference to - the locked pipe implementation. opnctx_table_cs must be unlocked - on entry and is unlocked on exit. */ -pipeimpl_t -access_opnctx (DWORD ctx_arg, DWORD code) + the locked pipe or the locked log implementation. opnctx_table_cs + must be unlocked on entry and is unlocked on exit. */ +int +access_opnctx (DWORD ctx_arg, DWORD code, pipeimpl_t *r_pipe, logimpl_t *r_log) { opnctx_t ctx; - pipeimpl_t pimpl; + *r_pipe = NULL; + *r_log = NULL; + EnterCriticalSection (&opnctx_table_cs); ctx = verify_opnctx (ctx_arg); if (! ctx) { /* Error is set by verify_opnctx. */ LeaveCriticalSection (&opnctx_table_cs); - return NULL; + return -1; } if (! (ctx->access_code & code)) { SetLastError (ERROR_INVALID_ACCESS); LeaveCriticalSection (&opnctx_table_cs); - return NULL; + return -1; } - pimpl = assert_pipeimpl (ctx); - if (! pimpl) + if (ctx->is_log) { - LeaveCriticalSection (&opnctx_table_cs); - return NULL; + logimpl_t limpl; + + limpl = assert_logimpl (ctx); + if (!limpl) + { + LeaveCriticalSection (&opnctx_table_cs); + return -1; + } + *r_log = limpl; } + else + { + pipeimpl_t pimpl; - EnterCriticalSection (&pimpl->critsect); - pimpl->refcnt++; + pimpl = assert_pipeimpl (ctx); + if (! pimpl) + { + LeaveCriticalSection (&opnctx_table_cs); + return -1; + } + EnterCriticalSection (&pimpl->critsect); + pimpl->refcnt++; + *r_pipe = pimpl; + } + LeaveCriticalSection (&opnctx_table_cs); - return pimpl; + return 0; } @@ -388,16 +570,92 @@ DWORD GPG_Init (LPCTSTR active_key, DWORD bus_context) { - char *tmpbuf; + static int firsttimedone; + HKEY handle; + wchar_t buffer[25]; + DWORD buflen; + DWORD result; + (void)bus_context; - - tmpbuf = wchar_to_utf8 (active_key); - log_debug ("GPG_Init (devctx=0x%p, %s)\n", DEVCTX_VALUE, tmpbuf); - free (tmpbuf); - /* We don't need any global data. However, we need to return - something. */ - return DEVCTX_VALUE; + EnterCriticalSection (&logcontrol.lock); + if (!firsttimedone) + { + firsttimedone++; + if (!RegOpenKeyEx (HKEY_LOCAL_MACHINE, GPGCEDEV_KEY_NAME, + 0, KEY_READ, &handle)) + { + buflen = sizeof buffer; + if (!RegQueryValueEx (handle, L"debugDriver", 0, NULL, + (PBYTE)buffer, &buflen) + && wcstol (buffer, NULL, 10) > 0) + enable_debug = 1; + RegCloseKey (handle); + } + if (!RegOpenKeyEx (HKEY_LOCAL_MACHINE, GPGCEDEV_KEY_NAME2, + 0, KEY_READ, &handle)) + { + buflen = sizeof buffer; + if (!RegQueryValueEx (handle, L"enableLog", 0, NULL, + (PBYTE)buffer, &buflen) + && wcstol (buffer, NULL, 10) > 0) + enable_logging = 1; + RegCloseKey (handle); + } + } + LeaveCriticalSection (&logcontrol.lock); + + if (enable_debug) + { + char *tmpbuf; + tmpbuf = wchar_to_utf8 (active_key); + log_debug ("GPG_Init (%s)\n", tmpbuf); + free (tmpbuf); + } + + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, active_key, 0, KEY_READ, &handle)) + { + log_debug ("GPG_Init: error reading registry: rc=%d\n", + (int)GetLastError ()); + return 0; + } + + buflen = sizeof buffer; + if (RegQueryValueEx (handle, L"Name", 0, NULL, (PBYTE)buffer, &buflen)) + { + log_debug ("GPG_Init: error reading registry value 'Name': rc=%d\n", + (int)GetLastError ()); + result = 0; + } + else if (!wcscmp (buffer, L"GPG1:")) + { + /* This is the pipe device: We don't need any global data. + However, we need to return something. */ + log_debug ("GPG_Init: created pipe device (devctx=%p)\n", PIPECTX_VALUE); + result = PIPECTX_VALUE; + } + else if (!wcscmp (buffer, L"GPG2:")) + { + /* This is the log device. Clear the object and return something. */ + logcontrol.filehd = INVALID_HANDLE_VALUE; + log_debug ("GPG_Init: created log device (devctx=%p)\n", 0); + result = LOGCTX_VALUE; + } + else + { + if (enable_debug) + { + char *tmpbuf; + tmpbuf = wchar_to_utf8 (buffer); + log_debug ("GPG_Init: device '%s' is not supported\n", tmpbuf); + free (tmpbuf); + } + SetLastError (ERROR_DEV_NOT_EXIST); + result = 0; + } + + RegCloseKey (handle); + return result; } @@ -407,29 +665,46 @@ GPG_Deinit (DWORD devctx) { log_debug ("GPG_Deinit (devctx=0x%p)\n", (void*)devctx); - if (devctx != DEVCTX_VALUE) + if (devctx == PIPECTX_VALUE) { + /* No need to release resources. */ + } + else if (devctx == LOGCTX_VALUE) + { + EnterCriticalSection (&logcontrol.lock); + if (logcontrol.filehd != INVALID_HANDLE_VALUE) + { + CloseHandle (logcontrol.filehd); + logcontrol.filehd = INVALID_HANDLE_VALUE; + } + LeaveCriticalSection (&logcontrol.lock); + } + else + { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; /* Error. */ } - /* FIXME: Release resources. */ - return TRUE; /* Success. */ } -/* Create a new open context. This fucntion is called due to a +/* Create a new open context. This function is called due to a CreateFile from the application. */ DWORD GPG_Open (DWORD devctx, DWORD access_code, DWORD share_mode) { opnctx_t opnctx; DWORD ctx_arg = 0; + int is_log; log_debug ("GPG_Open (devctx=%p)\n", (void*)devctx); - if (devctx != DEVCTX_VALUE) + if (devctx == PIPECTX_VALUE) + is_log = 0; + else if (devctx == LOGCTX_VALUE) + is_log = 1; + else { log_debug ("GPG_Open (devctx=%p): error: wrong devctx (expected 0x%p)\n", (void*) devctx); @@ -438,7 +713,7 @@ } EnterCriticalSection (&opnctx_table_cs); - opnctx = allocate_opnctx (); + opnctx = allocate_opnctx (is_log); if (!opnctx) { log_debug ("GPG_Open (devctx=%p): error: could not allocate context\n", @@ -451,8 +726,14 @@ ctx_arg = OPNCTX_TO_IDX (opnctx); - log_debug ("GPG_Open (devctx=%p): success: created context %i\n", - (void*) devctx, ctx_arg); + log_debug ("GPG_Open (devctx=%p, is_log=%d): success: created context %i\n", + (void*) devctx, is_log, ctx_arg); + if (is_log) + { + EnterCriticalSection (&logcontrol.lock); + logcontrol.references++; + LeaveCriticalSection (&logcontrol.lock); + } leave: LeaveCriticalSection (&opnctx_table_cs); @@ -496,6 +777,24 @@ pipeimpl_unref (pimpl); opnctx->pipeimpl = 0; } + if (opnctx->logimpl) + { + logimpl_t limpl = opnctx->logimpl; + + logimpl_flush (limpl); + logimpl_unref (limpl); + free (limpl->line); + free (limpl); + opnctx->logimpl = 0; + EnterCriticalSection (&logcontrol.lock); + logcontrol.references--; + if (!logcontrol.references && logcontrol.filehd) + { + CloseHandle (logcontrol.filehd); + logcontrol.filehd = INVALID_HANDLE_VALUE; + } + LeaveCriticalSection (&logcontrol.lock); + } opnctx->access_code = 0; opnctx->share_mode = 0; opnctx->rvid = 0; @@ -514,6 +813,7 @@ GPG_Read (DWORD opnctx_arg, void *buffer, DWORD count) { pipeimpl_t pimpl; + logimpl_t limpl; const char *src; char *dst; int result = -1; @@ -521,14 +821,20 @@ log_debug ("GPG_Read (ctx=%i, buffer=0x%p, count=%d)\n", opnctx_arg, buffer, count); - pimpl = access_opnctx (opnctx_arg, GENERIC_READ); - if (!pimpl) + if (access_opnctx (opnctx_arg, GENERIC_READ, &pimpl, &limpl)) { log_debug ("GPG_Read (ctx=%i): error: could not access context\n", opnctx_arg); return -1; } + if (limpl) + { + /* Reading from a log stream does not make sense. Return EOF. */ + result = 0; + goto leave; + } + retry: if (pimpl->buffer_pos == pimpl->buffer_len) { @@ -584,6 +890,7 @@ leave: pipeimpl_unref (pimpl); + logimpl_unref (limpl); return result; } @@ -593,6 +900,7 @@ GPG_Write (DWORD opnctx_arg, const void *buffer, DWORD count) { pipeimpl_t pimpl; + logimpl_t limpl; int result = -1; const char *src; char *dst; @@ -601,8 +909,7 @@ log_debug ("GPG_Write (ctx=%i, buffer=0x%p, count=%d)\n", opnctx_arg, buffer, count); - pimpl = access_opnctx (opnctx_arg, GENERIC_WRITE); - if (!pimpl) + if (access_opnctx (opnctx_arg, GENERIC_WRITE, &pimpl, &limpl)) { log_debug ("GPG_Write (ctx=%i): error: could not access context\n", opnctx_arg); @@ -617,58 +924,86 @@ } retry: - /* Check for broken pipe. */ - if (pimpl->flags & PIPE_FLAG_NO_READER) + if (limpl) { - log_debug ("GPG_Write (ctx=%i): error: broken pipe\n", opnctx_arg); - SetLastError (ERROR_BROKEN_PIPE); - goto leave; + /* Store it in our buffer up to a LF and print complete lines. */ + result = count; + if (!limpl->linelen) + limpl->dsec = GetTickCount () / 100; + dst = limpl->line + limpl->linelen; + for (src = buffer; count; count--, src++) + { + if (*src == '\n') + { + logimpl_flush (limpl); + dst = limpl->line + limpl->linelen; + } + else if (limpl->linelen >= limpl->linesize) + limpl->truncated = 1; + else + { + *dst++ = *src; + limpl->linelen++; + } + } } - - /* Check for request to unblock once. */ - if (pimpl->flags & PIPE_FLAG_UNBLOCK_WRITER) + else /* pimpl */ { - log_debug ("GPG_Write (ctx=%i): success: EBUSY (due to unblock)\n", - opnctx_arg); - pimpl->flags &= ~PIPE_FLAG_UNBLOCK_WRITER; - SetLastError (ERROR_BUSY); - result = -1; - goto leave; + /* Check for broken pipe. */ + if (pimpl->flags & PIPE_FLAG_NO_READER) + { + log_debug ("GPG_Write (ctx=%i): error: broken pipe\n", opnctx_arg); + SetLastError (ERROR_BROKEN_PIPE); + goto leave; + } + + /* Check for request to unblock once. */ + if (pimpl->flags & PIPE_FLAG_UNBLOCK_WRITER) + { + log_debug ("GPG_Write (ctx=%i): success: EBUSY (due to unblock)\n", + opnctx_arg); + pimpl->flags &= ~PIPE_FLAG_UNBLOCK_WRITER; + SetLastError (ERROR_BUSY); + result = -1; + goto leave; + } + + /* Write to our buffer. */ + if (pimpl->buffer_len == pimpl->buffer_size) + { + /* Buffer is full. */ + HANDLE space_available = pimpl->space_available; + LeaveCriticalSection (&pimpl->critsect); + log_debug ("GPG_Write (ctx=%i): waiting: space_available\n", + opnctx_arg); + WaitForSingleObject (space_available, INFINITE); + log_debug ("GPG_Write (ctx=%i): resuming: space_available\n", + opnctx_arg); + EnterCriticalSection (&pimpl->critsect); + goto retry; + } + + src = buffer; + dst = pimpl->buffer + pimpl->buffer_len; + while (count > 0 && pimpl->buffer_len < pimpl->buffer_size) + { + *dst++ = *src++; + count--; + pimpl->buffer_len++; + nwritten++; + } + result = nwritten; + + if (!SetEvent (pimpl->data_available)) + log_debug ("GPG_Write (ctx=%i): warning: SetEvent(data_available) " + "failed: rc=%d\n", opnctx_arg, (int)GetLastError ()); } - - /* Write to our buffer. */ - if (pimpl->buffer_len == pimpl->buffer_size) - { - /* Buffer is full. */ - HANDLE space_available = pimpl->space_available; - LeaveCriticalSection (&pimpl->critsect); - log_debug ("GPG_Write (ctx=%i): waiting: space_available\n", opnctx_arg); - WaitForSingleObject (space_available, INFINITE); - log_debug ("GPG_Write (ctx=%i): resuming: space_available\n", - opnctx_arg); - EnterCriticalSection (&pimpl->critsect); - goto retry; - } - - src = buffer; - dst = pimpl->buffer + pimpl->buffer_len; - while (count > 0 && pimpl->buffer_len < pimpl->buffer_size) - { - *dst++ = *src++; - count--; - pimpl->buffer_len++; - nwritten++; - } - result = nwritten; - - if (!SetEvent (pimpl->data_available)) - log_debug ("GPG_Write (ctx=%i): warning: SetEvent(data_available) " - "failed: rc=%d\n", opnctx_arg, (int)GetLastError ()); - + log_debug ("GPG_Write (ctx=%i): success: result=%d\n", opnctx_arg, result); leave: pipeimpl_unref (pimpl); + logimpl_unref (limpl); return result; } @@ -977,6 +1312,13 @@ opnctx_arg); goto leave; } + if (opnctx->is_log) + { + log_debug ("GPG_IOControl (ctx=%i): error: invalid code for log device\n", + opnctx_arg); + SetLastError (ERROR_INVALID_PARAMETER); + goto leave; + } switch (code) { @@ -1081,6 +1423,7 @@ void GPG_PowerUp (DWORD devctx) { + log_debug ("GPG_PowerUp (devctx=%i)\n", devctx); } @@ -1088,9 +1431,12 @@ void GPG_PowerDown (DWORD devctx) { + log_debug ("GPG_PowerDown (devctx=%i)\n", devctx); } + + /* Entry point called by the DLL loader. */ int WINAPI @@ -1102,6 +1448,7 @@ { case DLL_PROCESS_ATTACH: InitializeCriticalSection (&opnctx_table_cs); + InitializeCriticalSection (&logcontrol.lock); break; case DLL_THREAD_ATTACH: Modified: trunk/src/gpgcemgr.c =================================================================== --- trunk/src/gpgcemgr.c 2010-11-02 09:19:03 UTC (rev 395) +++ trunk/src/gpgcemgr.c 2010-11-15 06:54:15 UTC (rev 396) @@ -24,9 +24,10 @@ #define PGM "gpgcemgr" -#define GPGCEDEV_KEY_NAME L"Drivers\\GnuPG_Device" -#define GPGCEDEV_DLL_NAME L"gpgcedev.dll" -#define GPGCEDEV_PREFIX L"GPG" +#define GPGCEDEV_KEY_NAME L"Drivers\\GnuPG_Device" +#define GPGCEDEV_KEY_NAME2 L"Drivers\\GnuPG_Log" +#define GPGCEDEV_DLL_NAME L"gpgcedev.dll" +#define GPGCEDEV_PREFIX L"GPG" static int @@ -38,7 +39,7 @@ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, GPGCEDEV_KEY_NAME, 0, NULL, 0, KEY_WRITE, NULL, &handle, &disp)) { - fprintf (stderr, PGM": error creating registry key: rc=%d\n", + fprintf (stderr, PGM": error creating registry key 1: rc=%d\n", (int)GetLastError ()); return 1; } @@ -53,15 +54,35 @@ RegCloseKey (handle); - fprintf (stderr, PGM": registry key created\n"); + fprintf (stderr, PGM": registry key 1 created\n"); + if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, GPGCEDEV_KEY_NAME2, 0, NULL, 0, + KEY_WRITE, NULL, &handle, &disp)) + { + fprintf (stderr, PGM": error creating registry key 2: rc=%d\n", + (int)GetLastError ()); + return 1; + } + RegSetValueEx (handle, L"dll", 0, REG_SZ, + (void*)GPGCEDEV_DLL_NAME, sizeof (GPGCEDEV_DLL_NAME)); + RegSetValueEx (handle, L"prefix", 0, REG_SZ, + (void*)GPGCEDEV_PREFIX, sizeof (GPGCEDEV_PREFIX)); + + dw = 2; + RegSetValueEx (handle, L"Index", 0, REG_DWORD, (void*)&dw, sizeof dw); + + RegCloseKey (handle); + + fprintf (stderr, PGM": registry key 2 created\n"); + + return 0; } static int -deinstall (void) +deinstall (wchar_t *name) { int result = 0; HANDLE shd; @@ -69,7 +90,7 @@ memset (&dinfo, 0, sizeof dinfo); dinfo.dwSize = sizeof dinfo; - shd = FindFirstDevice (DeviceSearchByLegacyName, L"GPG1:", &dinfo); + shd = FindFirstDevice (DeviceSearchByLegacyName, name, &dinfo); if (shd == INVALID_HANDLE_VALUE) { if (GetLastError () == 18) @@ -102,6 +123,49 @@ } +static int +enable_debug (int yes) +{ + HKEY handle; + DWORD disp; + + if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, GPGCEDEV_KEY_NAME, 0, NULL, 0, + KEY_WRITE, NULL, &handle, &disp)) + { + fprintf (stderr, PGM": error creating debug registry key: rc=%d\n", + (int)GetLastError ()); + return 1; + } + + RegSetValueEx (handle, L"debugDriver", 0, REG_SZ, + (void*)(yes? L"1":L"0"), sizeof L"0"); + RegCloseKey (handle); + return 0; +} + + +static int +enable_log (int yes) +{ + HKEY handle; + DWORD disp; + + if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, GPGCEDEV_KEY_NAME2, 0, NULL, 0, + KEY_WRITE, NULL, &handle, &disp)) + { + fprintf (stderr, PGM": error creating debug registry key: rc=%d\n", + (int)GetLastError ()); + return 1; + } + + RegSetValueEx (handle, L"enableLog", 0, REG_SZ, + (void*)(yes? L"1":L"0"), sizeof L"0"); + RegCloseKey (handle); + return 0; +} + + + /* Kudos to Scott Seligman for his work on the reverse engineering. */ struct htc_sensor_s @@ -280,24 +344,111 @@ if (argc > 1 && !strcmp (argv[1], "--register")) result = install (); else if (argc > 1 && !strcmp (argv[1], "--deactivate")) - result = deinstall (); + { + if (deinstall (L"GPG1:")) + result = 1; + if (deinstall (L"GPG2:")) + result = 1; + } else if (argc > 1 && !strcmp (argv[1], "--activate")) { + HANDLE hd; + /* This is mainly for testing. The activation is usually done right before the device is opened. */ - if (ActivateDevice (GPGCEDEV_DLL_NAME, 0) == INVALID_HANDLE_VALUE) + if (ActivateDevice (GPGCEDEV_KEY_NAME, 0) == INVALID_HANDLE_VALUE) { - fprintf (stderr, PGM": ActivateDevice failed: rc=%d\n", + fprintf (stderr, PGM": ActivateDevice 1 failed: rc=%d\n", (int)GetLastError ()); result = 1; } + else if (ActivateDevice (GPGCEDEV_KEY_NAME2, 0) == INVALID_HANDLE_VALUE) + { + fprintf (stderr, PGM": ActivateDevice 2 failed: rc=%d\n", + (int)GetLastError ()); + result = 1; + } else - fprintf (stderr, PGM": device activated\n"); + { + fprintf (stderr, PGM": devices activated\n"); + hd = CreateFile (L"GPG1:", GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hd == INVALID_HANDLE_VALUE) + { + fprintf (stderr, PGM": opening `GPG1:' failed: rc=%d\n", + (int)GetLastError ()); + result = 1; + } + else + { + fprintf (stderr, PGM": device `GPG1:' seems to work\n"); + CloseHandle (hd); + } + + hd = CreateFile (L"GPG2:", GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hd == INVALID_HANDLE_VALUE) + { + fprintf (stderr, PGM": opening `GPG2:' failed: rc=%d\n", + (int)GetLastError ()); + result = 1; + } + else + { + fprintf (stderr, PGM": device `GPG2:' seems to work\n"); + CloseHandle (hd); + } + + } } else if (argc > 1 && !strcmp (argv[1], "--gravity")) result = gravity (); /* else if (argc > 1 && !strcmp (argv[1], "--gps")) */ /* result = gps (); */ + else if (argc > 1 && !strcmp (argv[1], "--log")) + { + HANDLE hd; + + hd = CreateFile (L"GPG2:", GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hd == INVALID_HANDLE_VALUE) + { + fprintf (stderr, PGM": opening `GPG2:' failed: rc=%d\n", + (int)GetLastError ()); + result = 1; + } + else + { + char marktwain[] = "I have never let my schooling interfere" + " with my education.\n"; + DWORD nwritten; + int i; + + for (i=0; i < 5; i++) + { + if (!WriteFile (hd, marktwain, strlen (marktwain), + &nwritten, NULL)) + { + fprintf (stderr, PGM": writing `GPG2:' failed: rc=%d\n", + (int)GetLastError ()); + result = 1; + } + Sleep (200); + } + CloseHandle (hd); + } + } + else if (argc > 1 && !strcmp (argv[1], "--enable-debug")) + result = enable_debug (1); + else if (argc > 1 && !strcmp (argv[1], "--disable-debug")) + result = enable_debug (0); + else if (argc > 1 && !strcmp (argv[1], "--enable-log")) + result = enable_log (1); + else if (argc > 1 && !strcmp (argv[1], "--disable-log")) + result = enable_log (0); else { fprintf (stderr, "usage: " PGM " --register|--deactivate|--activate\n"); From cvs at cvs.gnupg.org Mon Nov 15 08:28:58 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 15 Nov 2010 08:28:58 +0100 Subject: [svn] assuan - r397 - in trunk/contrib: . conf-w32ce-msc Message-ID: Author: wk Date: 2010-11-15 08:28:58 +0100 (Mon, 15 Nov 2010) New Revision: 397 Modified: trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk Log: Fixes for the MSC build Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-15 06:54:15 UTC (rev 396) +++ trunk/contrib/ChangeLog 2010-11-15 07:28:58 UTC (rev 397) @@ -1,3 +1,9 @@ +2010-11-15 Werner Koch + + * conf-w32ce-msc/build.mk (copy-static-source): Create stdint.h. + (all): Add ws2.lib + (clean): New. + 2010-11-02 Werner Koch * conf-w32ce-msc/build.mk: Change directory layout. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 06:54:15 UTC (rev 396) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 07:28:58 UTC (rev 397) @@ -122,6 +122,8 @@ built_sources = \ assuan.h +my_stdint = $(targetsrc)/libassuan/src/stdint.h + copy-static-source: @if [ ! -f ./assuan-defs.h ]; then \ echo "Please cd to the src/ directory first"; \ @@ -130,6 +132,14 @@ cp -t $(targetsrc)/libassuan/src $(sources); cd ../contrib/conf-w32ce-msc ; \ cp -t $(targetsrc)/libassuan/src $(conf_sources) + @echo typedef unsigned long long uint64_t; >$(my_stdint) + @echo typedef long long int64_t; >>$(my_stdint) + @echo typedef unsigned int uint32_t; >>$(my_stdint) + @echo typedef int int32_t; >>$(my_stdint) + @echo typedef unsigned short uint16_t; >>$(my_stdint) + @echo typedef short int16_t; >>$(my_stdint) + @echo typedef unsigned int uintptr_t; >>$(my_stdint) + @echo typedef int intptr_t; >>$(my_stdint) copy-built-source: @@ -152,7 +162,7 @@ /NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE:NO \ $(objs) $(libdir)/libgpg-error-0-msc.lib \ coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \ - commctrl.lib /subsystem:windowsce,5.02 + commctrl.lib ws2.lib /subsystem:windowsce,5.02 # Note that we don't need to create the install directories because # libgpg-error must have been build and installed prior to this @@ -161,3 +171,7 @@ copy /y libassuan-0-msc.dll $(bindir:/=\) copy /y libassuan-0-msc.lib $(libdir:/=\) copy /y assuan.h $(incdir:/=\) + +clean: + del *.obj libassuan-0-msc.lib libassuan-0-msc.dll libassuan-0-msc.exp + From cvs at cvs.gnupg.org Mon Nov 15 08:30:36 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 15 Nov 2010 08:30:36 +0100 Subject: [svn] gpg-error - r266 - in trunk/contrib: . conf-w32ce-msc Message-ID: Author: wk Date: 2010-11-15 08:30:36 +0100 (Mon, 15 Nov 2010) New Revision: 266 Modified: trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk Log: Add clean target for the MSC build Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-02 09:19:28 UTC (rev 265) +++ trunk/contrib/ChangeLog 2010-11-15 07:30:36 UTC (rev 266) @@ -1,3 +1,7 @@ +2010-11-15 Werner Koch + + * conf-w32ce-msc/build.mk (clean): New. + 2010-11-02 Werner Koch * conf-w32ce-msc/build.mk: Change directory layout. Provide Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-02 09:19:28 UTC (rev 265) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 07:30:36 UTC (rev 266) @@ -137,3 +137,7 @@ copy /y gpg-extra\errno.h $(incdir:/=\)\gpg-extra copy /y libgpg-error-0-msc.dll $(bindir:/=\) copy /y libgpg-error-0-msc.lib $(libdir:/=\) + +clean: + del *.obj libgpg-error-0-msc.lib \ + libgpg-error-0-msc.dll libgpg-error-0-msc.exe From cvs at cvs.gnupg.org Mon Nov 15 09:40:32 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 15 Nov 2010 09:40:32 +0100 Subject: [svn] gpgme - r1501 - in trunk: contrib contrib/conf-w32ce-msc src Message-ID: Author: wk Date: 2010-11-15 09:40:30 +0100 (Mon, 15 Nov 2010) New Revision: 1501 Modified: trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk trunk/src/ChangeLog trunk/src/ath.c trunk/src/ath.h trunk/src/data-compat.c trunk/src/w32-ce.h Log: Fixes for the MSC build Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-04 08:16:57 UTC (rev 1500) +++ trunk/contrib/ChangeLog 2010-11-15 08:40:30 UTC (rev 1501) @@ -1,3 +1,9 @@ +2010-11-15 Werner Koch + + * conf-w32ce-msc/build.mk (copy-static-source): Create stdint.h. + (all): Add ws2.lib + (clean): New. + 2010-11-04 Werner Koch * conf-w32ce-msc/build.mk (copy-built-source): Revert last Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-04 08:16:57 UTC (rev 1500) +++ trunk/src/ChangeLog 2010-11-15 08:40:30 UTC (rev 1501) @@ -1,3 +1,17 @@ +2010-11-15 Werner Koch + + * data-compat.c (gpgme_data_new_from_filepart) + (gpgme_data_new_from_file) [W32CE && _MSC_VER]: Return not + GPG_ERR_NOT_IMPLEMENTED. + + * w32-ce.h (HKEY_PERFORMANCE_DATA, HKEY_CURRENT_CONFIG, _IOLBF) + (abort) [_MSC_VER]: Provide these macros. + + * ath.h [W32CE && _MSC_VER]: Include winsock2.h. + + * ath.c (ath_read, ath_write) [W32CE && _MSC_VER]: Do not call + non-available functions. + 2010-11-04 Werner Koch * w32-ce.h [_MSC_VER && W32CE]: Undef leave. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-04 08:16:57 UTC (rev 1500) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 08:40:30 UTC (rev 1501) @@ -209,6 +209,7 @@ gpgme.h \ status-table.h +my_stdint = $(targetsrc)/libassuan/src/stdint.h copy-static-source: @if [ ! -f ./gpgme.c ]; then \ @@ -218,6 +219,14 @@ cp -t $(targetsrc)/gpgme/src $(sources); cd ../contrib/conf-w32ce-msc ; \ cp -t $(targetsrc)/gpgme/src $(conf_sources) + @echo typedef unsigned long long uint64_t; >$(my_stdint) + @echo typedef long long int64_t; >>$(my_stdint) + @echo typedef unsigned int uint32_t; >>$(my_stdint) + @echo typedef int int32_t; >>$(my_stdint) + @echo typedef unsigned short uint16_t; >>$(my_stdint) + @echo typedef short int16_t; >>$(my_stdint) + @echo typedef unsigned int uintptr_t; >>$(my_stdint) + @echo typedef int intptr_t; >>$(my_stdint) copy-built-source: @if [ ! -f ./gpgme.h ]; then \ @@ -242,7 +251,7 @@ $(libdir)/libgpg-error-0-msc.lib \ $(libdir)/libassuan-0-msc.lib \ coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \ - commctrl.lib /subsystem:windowsce,5.02 + commctrl.lib ws2.lib /subsystem:windowsce,5.02 # Note that we don't need to create the install directories because # libgpg-error must have been build and installed prior to this @@ -251,3 +260,8 @@ copy /y gpgme.h $(incdir:/=\) copy /y libgpgme-11-msc.dll $(bindir:/=\) copy /y libgpgme-11-msc.lib $(libdir:/=\) + + +clean: + del *.obj libgpgme-11-msc.lib libgpgme-11-msc.dll libgpgme-11-msc.exp + Modified: trunk/src/ath.c =================================================================== --- trunk/src/ath.c 2010-11-04 08:16:57 UTC (rev 1500) +++ trunk/src/ath.c 2010-11-15 08:40:30 UTC (rev 1501) @@ -128,14 +128,22 @@ ssize_t ath_read (int fd, void *buf, size_t nbytes) { +#if defined(HAVE_W32CE_SYSTEM) && defined(_MSC_VER) + return -1; /* Not supported. */ +#else return read (fd, buf, nbytes); +#endif } ssize_t ath_write (int fd, const void *buf, size_t nbytes) { +#if defined(HAVE_W32CE_SYSTEM) && defined(_MSC_VER) + return -1; /* Not supported. */ +#else return write (fd, buf, nbytes); +#endif } Modified: trunk/src/ath.h =================================================================== --- trunk/src/ath.h 2010-11-04 08:16:57 UTC (rev 1500) +++ trunk/src/ath.h 2010-11-15 08:40:30 UTC (rev 1501) @@ -28,6 +28,9 @@ /* fixme: Check how we did it in libgcrypt. */ struct msghdr { int dummy; }; typedef int socklen_t; +# if defined(HAVE_W32CE_SYSTEM) && defined(_MSC_VER) +# include +# endif # include # include Modified: trunk/src/data-compat.c =================================================================== --- trunk/src/data-compat.c 2010-11-04 08:16:57 UTC (rev 1500) +++ trunk/src/data-compat.c 2010-11-15 08:40:30 UTC (rev 1501) @@ -43,6 +43,9 @@ gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname, FILE *stream, off_t offset, size_t length) { +#if defined (HAVE_W32CE_SYSTEM) && defined (_MSC_VER) + return gpgme_error (GPG_ERR_NOT_IMPLEMENTED); +#else gpgme_error_t err; char *buf = NULL; int res; @@ -111,6 +114,7 @@ (*r_dh)->data.mem.length = length; return TRACE_SUC1 ("r_dh=%p", *r_dh); +#endif } @@ -119,6 +123,9 @@ gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh, const char *fname, int copy) { +#if defined (HAVE_W32CE_SYSTEM) && defined (_MSC_VER) + return gpgme_error (GPG_ERR_NOT_IMPLEMENTED); +#else gpgme_error_t err; struct stat statbuf; TRACE_BEG3 (DEBUG_DATA, "gpgme_data_new_from_filepart", r_dh, @@ -132,6 +139,7 @@ err = gpgme_data_new_from_filepart (r_dh, fname, NULL, 0, statbuf.st_size); return TRACE_ERR (err); +#endif } Modified: trunk/src/w32-ce.h =================================================================== --- trunk/src/w32-ce.h 2010-11-04 08:16:57 UTC (rev 1500) +++ trunk/src/w32-ce.h 2010-11-15 08:40:30 UTC (rev 1501) @@ -32,7 +32,6 @@ #include /* For getaddrinfo. */ #include - #define getenv _gpgme_wince_getenv char *getenv (const char *name); @@ -75,11 +74,16 @@ int (*compar) (const void *, const void *)); #define bsearch(a,b,c,d,e) _gpgme_wince_bsearch ((a),(b),(c),(d),(e)) -/* Remove the redefined __leave keyword. It is defined by MSC for W32 - in excpt.h and not in sehmap.h as for the plain windows - version. */ -#if defined(_MSC_VER) && defined(HAVE_W32CE_SYSTEM) +#if defined(_MSC_VER) + /* Remove the redefined __leave keyword. It is defined by MSC for + W32 in excpt.h and not in sehmap.h as for the plain windows + version. */ # undef leave +# define HKEY_PERFORMANCE_DATA ((HKEY)0x80000004) +# define HKEY_CURRENT_CONFIG ((HKEY)0x80000005) + /* Replace the Mingw32CE provided abort function. */ +# define abort() do { TerminateProcess (GetCurrentProcess(), 8); } while (0) +# define _IOLBF 0x40 #endif #endif /* GPGME_W32_CE_H */ From cvs at cvs.gnupg.org Mon Nov 15 15:52:45 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 15 Nov 2010 15:52:45 +0100 Subject: [svn] assuan - r398 - in trunk/contrib: . conf-w32ce-msc Message-ID: Author: marcus Date: 2010-11-15 15:52:45 +0100 (Mon, 15 Nov 2010) New Revision: 398 Added: trunk/contrib/conf-w32ce-msc/stdint.h Modified: trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk Log: 2010-11-15 Marcus Brinkmann * conf-w32ce-msc/stdint.h: New file. * conf-w32ce-msc/build.mk (conf_sources): Add stdint.h. (copy-static-source): Revert last change. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-15 07:28:58 UTC (rev 397) +++ trunk/contrib/ChangeLog 2010-11-15 14:52:45 UTC (rev 398) @@ -1,3 +1,9 @@ +2010-11-15 Marcus Brinkmann + + * conf-w32ce-msc/stdint.h: New file. + * conf-w32ce-msc/build.mk (conf_sources): Add stdint.h. + (copy-static-source): Revert last change. + 2010-11-15 Werner Koch * conf-w32ce-msc/build.mk (copy-static-source): Create stdint.h. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 07:28:58 UTC (rev 397) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 14:52:45 UTC (rev 398) @@ -116,13 +116,13 @@ # Sources files in this directory inclduing this Makefile conf_sources = \ build.mk \ - config.h + config.h \ + stdint.h # Source files built by running the standard build system. built_sources = \ assuan.h -my_stdint = $(targetsrc)/libassuan/src/stdint.h copy-static-source: @if [ ! -f ./assuan-defs.h ]; then \ @@ -132,14 +132,6 @@ cp -t $(targetsrc)/libassuan/src $(sources); cd ../contrib/conf-w32ce-msc ; \ cp -t $(targetsrc)/libassuan/src $(conf_sources) - @echo typedef unsigned long long uint64_t; >$(my_stdint) - @echo typedef long long int64_t; >>$(my_stdint) - @echo typedef unsigned int uint32_t; >>$(my_stdint) - @echo typedef int int32_t; >>$(my_stdint) - @echo typedef unsigned short uint16_t; >>$(my_stdint) - @echo typedef short int16_t; >>$(my_stdint) - @echo typedef unsigned int uintptr_t; >>$(my_stdint) - @echo typedef int intptr_t; >>$(my_stdint) copy-built-source: Added: trunk/contrib/conf-w32ce-msc/stdint.h =================================================================== --- trunk/contrib/conf-w32ce-msc/stdint.h (rev 0) +++ trunk/contrib/conf-w32ce-msc/stdint.h 2010-11-15 14:52:45 UTC (rev 398) @@ -0,0 +1,9 @@ +typedef unsigned long long uint64_t; +typedef long long int64_t; +typedef unsigned int uint32_t; +typedef int int32_t; +typedef unsigned short uint16_t; +typedef short int16_t; +typedef unsigned int uintptr_t; +typedef int intptr_t; + Property changes on: trunk/contrib/conf-w32ce-msc/stdint.h ___________________________________________________________________ Added: svn:executable + * From cvs at cvs.gnupg.org Mon Nov 15 16:01:18 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 15 Nov 2010 16:01:18 +0100 Subject: [svn] gpgme - r1502 - in trunk/contrib: . conf-w32ce-msc Message-ID: Author: marcus Date: 2010-11-15 16:01:17 +0100 (Mon, 15 Nov 2010) New Revision: 1502 Added: trunk/contrib/conf-w32ce-msc/stdint.h Modified: trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk Log: 2010-11-15 Marcus Brinkmann * conf-w32ce-msc/stdint.h: New file. * conf-w32ce-msc/build.mk (conf_sources): Add stdint.h. * conf-w32ce-msc/build.mk (copy-static-source): Revert last change. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-15 08:40:30 UTC (rev 1501) +++ trunk/contrib/ChangeLog 2010-11-15 15:01:17 UTC (rev 1502) @@ -1,3 +1,9 @@ +2010-11-15 Marcus Brinkmann + + * conf-w32ce-msc/stdint.h: New file. + * conf-w32ce-msc/build.mk (conf_sources): Add stdint.h. + * conf-w32ce-msc/build.mk (copy-static-source): Revert last change. + 2010-11-15 Werner Koch * conf-w32ce-msc/build.mk (copy-static-source): Create stdint.h. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 08:40:30 UTC (rev 1501) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 15:01:17 UTC (rev 1502) @@ -202,15 +202,14 @@ # Sources files in this directory inclduing this Makefile conf_sources = \ build.mk \ - config.h + config.h \ + stdint.h # Source files built by running the standard build system. built_sources = \ gpgme.h \ status-table.h -my_stdint = $(targetsrc)/libassuan/src/stdint.h - copy-static-source: @if [ ! -f ./gpgme.c ]; then \ echo "Please cd to the src/ directory first"; \ @@ -219,14 +218,6 @@ cp -t $(targetsrc)/gpgme/src $(sources); cd ../contrib/conf-w32ce-msc ; \ cp -t $(targetsrc)/gpgme/src $(conf_sources) - @echo typedef unsigned long long uint64_t; >$(my_stdint) - @echo typedef long long int64_t; >>$(my_stdint) - @echo typedef unsigned int uint32_t; >>$(my_stdint) - @echo typedef int int32_t; >>$(my_stdint) - @echo typedef unsigned short uint16_t; >>$(my_stdint) - @echo typedef short int16_t; >>$(my_stdint) - @echo typedef unsigned int uintptr_t; >>$(my_stdint) - @echo typedef int intptr_t; >>$(my_stdint) copy-built-source: @if [ ! -f ./gpgme.h ]; then \ Added: trunk/contrib/conf-w32ce-msc/stdint.h =================================================================== --- trunk/contrib/conf-w32ce-msc/stdint.h (rev 0) +++ trunk/contrib/conf-w32ce-msc/stdint.h 2010-11-15 15:01:17 UTC (rev 1502) @@ -0,0 +1,9 @@ +typedef unsigned long long uint64_t; +typedef long long int64_t; +typedef unsigned int uint32_t; +typedef int int32_t; +typedef unsigned short uint16_t; +typedef short int16_t; +typedef unsigned int uintptr_t; +typedef int intptr_t; + Property changes on: trunk/contrib/conf-w32ce-msc/stdint.h ___________________________________________________________________ Added: svn:executable + * From cvs at cvs.gnupg.org Mon Nov 15 16:02:55 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 15 Nov 2010 16:02:55 +0100 Subject: [svn] gpgme - r1503 - in trunk/contrib: . conf-w32ce-msc Message-ID: Author: marcus Date: 2010-11-15 16:02:54 +0100 (Mon, 15 Nov 2010) New Revision: 1503 Added: trunk/contrib/conf-w32ce-msc/io.h Modified: trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk Log: 2010-11-15 Marcus Brinkmann * conf-w32ce-msc/io.h: New file. * conf-w32ce-msc/build.mk (conf_sources): Add io.h. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-15 15:01:17 UTC (rev 1502) +++ trunk/contrib/ChangeLog 2010-11-15 15:02:54 UTC (rev 1503) @@ -1,5 +1,8 @@ 2010-11-15 Marcus Brinkmann + * conf-w32ce-msc/io.h: New file. + * conf-w32ce-msc/build.mk (conf_sources): Add io.h. + * conf-w32ce-msc/stdint.h: New file. * conf-w32ce-msc/build.mk (conf_sources): Add stdint.h. * conf-w32ce-msc/build.mk (copy-static-source): Revert last change. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 15:01:17 UTC (rev 1502) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 15:02:54 UTC (rev 1503) @@ -203,7 +203,7 @@ conf_sources = \ build.mk \ config.h \ - stdint.h + stdint.h io.h # Source files built by running the standard build system. built_sources = \ @@ -225,7 +225,6 @@ exit 1; \ fi cp -t $(targetsrc)/gpgme/src $(built_sources) - echo '/* Dummy io.h header. */' > $(targetsrc)/gpgme/src/io.h copy-source: copy-static-source copy-built-source Added: trunk/contrib/conf-w32ce-msc/io.h =================================================================== --- trunk/contrib/conf-w32ce-msc/io.h (rev 0) +++ trunk/contrib/conf-w32ce-msc/io.h 2010-11-15 15:02:54 UTC (rev 1503) @@ -0,0 +1,2 @@ +/* Dummy io.h header. */ + Property changes on: trunk/contrib/conf-w32ce-msc/io.h ___________________________________________________________________ Added: svn:executable + * From cvs at cvs.gnupg.org Mon Nov 15 16:09:24 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 15 Nov 2010 16:09:24 +0100 Subject: [svn] gpg-error - r267 - in trunk/contrib: . conf-w32ce-msc Message-ID: Author: marcus Date: 2010-11-15 16:09:24 +0100 (Mon, 15 Nov 2010) New Revision: 267 Added: trunk/contrib/conf-w32ce-msc/stdint.h Modified: trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk Log: 2010-11-15 Marcus Brinkmann * conf-w32ce-msc/stdint.h: New file. * conf-w32ce-msc/build.mk (conf_sources): Add stdint.h. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-15 07:30:36 UTC (rev 266) +++ trunk/contrib/ChangeLog 2010-11-15 15:09:24 UTC (rev 267) @@ -1,3 +1,8 @@ +2010-11-15 Marcus Brinkmann + + * conf-w32ce-msc/stdint.h: New file. + * conf-w32ce-msc/build.mk (conf_sources): Add stdint.h. + 2010-11-15 Werner Koch * conf-w32ce-msc/build.mk (clean): New. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 07:30:36 UTC (rev 266) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 15:09:24 UTC (rev 267) @@ -74,7 +74,8 @@ # Sources files in this directory inclduing this Makefile conf_sources = \ build.mk \ - config.h + config.h \ + stdint.h # Source files built by running the standard build system. built_sources = \ Added: trunk/contrib/conf-w32ce-msc/stdint.h =================================================================== --- trunk/contrib/conf-w32ce-msc/stdint.h (rev 0) +++ trunk/contrib/conf-w32ce-msc/stdint.h 2010-11-15 15:09:24 UTC (rev 267) @@ -0,0 +1,9 @@ +typedef unsigned long long uint64_t; +typedef long long int64_t; +typedef unsigned int uint32_t; +typedef int int32_t; +typedef unsigned short uint16_t; +typedef short int16_t; +typedef unsigned int uintptr_t; +typedef int intptr_t; + Property changes on: trunk/contrib/conf-w32ce-msc/stdint.h ___________________________________________________________________ Added: svn:executable + * From cvs at cvs.gnupg.org Mon Nov 15 16:12:00 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 15 Nov 2010 16:12:00 +0100 Subject: [svn] gpgme - r1504 - trunk/src Message-ID: Author: marcus Date: 2010-11-15 16:11:59 +0100 (Mon, 15 Nov 2010) New Revision: 1504 Modified: trunk/src/ChangeLog trunk/src/w32-util.c Log: 2010-11-15 Marcus Brinkmann * w32-util.c (_gpgme_w32ce_get_debug_envvar): Fix return value. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-15 15:02:54 UTC (rev 1503) +++ trunk/src/ChangeLog 2010-11-15 15:11:59 UTC (rev 1504) @@ -1,3 +1,7 @@ +2010-11-15 Marcus Brinkmann + + * w32-util.c (_gpgme_w32ce_get_debug_envvar): Fix return value. + 2010-11-15 Werner Koch * data-compat.c (gpgme_data_new_from_filepart) Modified: trunk/src/w32-util.c =================================================================== --- trunk/src/w32-util.c 2010-11-15 15:02:54 UTC (rev 1503) +++ trunk/src/w32-util.c 2010-11-15 15:11:59 UTC (rev 1504) @@ -634,6 +634,6 @@ free (tmp); tmp = NULL; } - return NULL; + return tmp; } #endif /*HAVE_W32CE_SYSTEM*/ From cvs at cvs.gnupg.org Mon Nov 15 16:29:17 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 15 Nov 2010 16:29:17 +0100 Subject: [svn] gpgme - r1505 - in trunk/contrib: . conf-w32ce-msc Message-ID: Author: marcus Date: 2010-11-15 16:29:17 +0100 (Mon, 15 Nov 2010) New Revision: 1505 Added: trunk/contrib/conf-w32ce-msc/fcntl.h Modified: trunk/contrib/ChangeLog trunk/contrib/conf-w32ce-msc/build.mk Log: 2010-11-15 Marcus Brinkmann * conf-w32ce-msc/fcntl.h: New file. * conf-w32ce-msc/build.mk (conf_sources): Add fnctl.h. (sources): Remove memrchr.c. Modified: trunk/contrib/ChangeLog =================================================================== --- trunk/contrib/ChangeLog 2010-11-15 15:11:59 UTC (rev 1504) +++ trunk/contrib/ChangeLog 2010-11-15 15:29:17 UTC (rev 1505) @@ -1,5 +1,9 @@ 2010-11-15 Marcus Brinkmann + * conf-w32ce-msc/fcntl.h: New file. + * conf-w32ce-msc/build.mk (conf_sources): Add fnctl.h. + (sources): Remove memrchr.c. + * conf-w32ce-msc/io.h: New file. * conf-w32ce-msc/build.mk (conf_sources): Add io.h. Modified: trunk/contrib/conf-w32ce-msc/build.mk =================================================================== --- trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 15:11:59 UTC (rev 1504) +++ trunk/contrib/conf-w32ce-msc/build.mk 2010-11-15 15:29:17 UTC (rev 1505) @@ -99,7 +99,6 @@ kdpipeiodevice.h \ key.c \ keylist.c \ - memrchr.c \ op-support.c \ opassuan.c \ ops.h \ @@ -203,7 +202,7 @@ conf_sources = \ build.mk \ config.h \ - stdint.h io.h + stdint.h io.h fcntl.h # Source files built by running the standard build system. built_sources = \ Added: trunk/contrib/conf-w32ce-msc/fcntl.h =================================================================== --- trunk/contrib/conf-w32ce-msc/fcntl.h (rev 0) +++ trunk/contrib/conf-w32ce-msc/fcntl.h 2010-11-15 15:29:17 UTC (rev 1505) @@ -0,0 +1 @@ +/* Dummy fcntl.h header. */ Property changes on: trunk/contrib/conf-w32ce-msc/fcntl.h ___________________________________________________________________ Added: svn:executable + * From cvs at cvs.gnupg.org Mon Nov 15 16:30:05 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 15 Nov 2010 16:30:05 +0100 Subject: [svn] gpgme - r1506 - trunk/src Message-ID: Author: marcus Date: 2010-11-15 16:30:04 +0100 (Mon, 15 Nov 2010) New Revision: 1506 Modified: trunk/src/ChangeLog trunk/src/genkey.c trunk/src/passphrase.c trunk/src/w32-ce.h Log: 2010-11-15 Marcus Brinkmann * w32-ce.h (strcasecmp, strdup) [_MSC_VER]: Define. * genkey.c, passphrase.c: Include util.h. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-15 15:29:17 UTC (rev 1505) +++ trunk/src/ChangeLog 2010-11-15 15:30:04 UTC (rev 1506) @@ -1,5 +1,8 @@ 2010-11-15 Marcus Brinkmann + * w32-ce.h (strcasecmp, strdup) [_MSC_VER]: Define. + * genkey.c, passphrase.c: Include util.h. + * w32-util.c (_gpgme_w32ce_get_debug_envvar): Fix return value. 2010-11-15 Werner Koch Modified: trunk/src/genkey.c =================================================================== --- trunk/src/genkey.c 2010-11-15 15:29:17 UTC (rev 1505) +++ trunk/src/genkey.c 2010-11-15 15:30:04 UTC (rev 1506) @@ -30,6 +30,7 @@ #include "debug.h" #include "context.h" #include "ops.h" +#include "util.h" typedef struct Modified: trunk/src/passphrase.c =================================================================== --- trunk/src/passphrase.c 2010-11-15 15:29:17 UTC (rev 1505) +++ trunk/src/passphrase.c 2010-11-15 15:30:04 UTC (rev 1506) @@ -31,6 +31,7 @@ #include "gpgme.h" #include "context.h" #include "ops.h" +#include "util.h" typedef struct Modified: trunk/src/w32-ce.h =================================================================== --- trunk/src/w32-ce.h 2010-11-15 15:29:17 UTC (rev 1505) +++ trunk/src/w32-ce.h 2010-11-15 15:30:04 UTC (rev 1506) @@ -26,6 +26,8 @@ #ifdef _MSC_VER typedef int pid_t; +#define strdup _strdup +#define strcasecmp _stricmp #endif #include From cvs at cvs.gnupg.org Tue Nov 16 10:24:23 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 16 Nov 2010 10:24:23 +0100 Subject: [svn] dirmngr - r345 - in trunk: . jnlib src Message-ID: Author: wk Date: 2010-11-16 10:24:21 +0100 (Tue, 16 Nov 2010) New Revision: 345 Modified: trunk/AUTHORS trunk/COPYING trunk/ChangeLog trunk/Makefile.am trunk/configure.ac trunk/jnlib/ChangeLog trunk/jnlib/argparse.c trunk/src/ChangeLog trunk/src/dirmngr-client.c trunk/src/dirmngr.c Log: Switch license to GPLv3+. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/ChangeLog 2010-11-16 09:24:21 UTC (rev 345) @@ -1,3 +1,9 @@ +2010-11-16 Werner Koch + + Change the license to GPLv3+. + + * COPYING: Replace by GPLv3 version. + 2010-06-14 Werner Koch Release 1.1.0. Modified: trunk/jnlib/ChangeLog =================================================================== --- trunk/jnlib/ChangeLog 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/jnlib/ChangeLog 2010-11-16 09:24:21 UTC (rev 345) @@ -1,3 +1,8 @@ +2010-11-16 Werner Koch + + * argparse.c (show_version): Print license string. + (strusage): Set default license string to GPLv3+. + 2009-07-20 Werner Koch * logging.c (pid_suffix_cb): New. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/src/ChangeLog 2010-11-16 09:24:21 UTC (rev 345) @@ -1,3 +1,8 @@ +2010-11-16 Werner Koch + + Change license to GPLv3+. This is required because we are using + some file from GnuPG which are under GPLv3+. + 2010-06-07 Werner Koch * vasprintf.c: Remove. Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/AUTHORS 2010-11-16 09:24:21 UTC (rev 345) @@ -2,7 +2,7 @@ Maintainer: Werner Koch Bug reports: bug-dirmngr at gnupg.org Security related bug reports: security at gnupg.org -License: GPLv2+ +License: GPLv3+ Steffen Hansen @@ -21,8 +21,8 @@ - src/cdb.h and src/cdblib.c from the public domain tinycdb 0.73. -The actual code is under the GNU GPL, except for src/cdb.h and -src/cdblib.h which are in the public domain. +The actual code is under the GNU GPL version 3 or later, except for +src/cdb.h and src/cdblib.h which are in the public domain. Copyright 2003, 2004, 2006, 2007, 2008, 2010 g10 Code GmbH Modified: trunk/COPYING =================================================================== --- trunk/COPYING 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/COPYING 2010-11-16 09:24:21 UTC (rev 345) @@ -1,284 +1,626 @@ + GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". + TERMS AND CONDITIONS -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. + 0. Definitions. - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. + "This License" refers to version 3 of the GNU General Public License. -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. + A "covered work" means either the unmodified Program or a work based +on the Program. - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. + 1. Source Code. - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. + The Corresponding Source for a work in source code form is that +same work. - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. + 2. Basic Permissions. - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. + 13. Use with the GNU Affero General Public License. -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. + 14. Revised Versions of this License. - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. - NO WARRANTY + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. + 15. Disclaimer of Warranty. - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + END OF TERMS AND CONDITIONS - + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest @@ -287,15 +629,15 @@ To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -304,37 +646,31 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + along with this program. If not, see . - Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/Makefile.am 2010-11-16 09:24:21 UTC (rev 345) @@ -5,7 +5,7 @@ # # DirMngr is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # DirMngr is distributed in the hope that it will be useful, Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/configure.ac 2010-11-16 09:24:21 UTC (rev 345) @@ -1,13 +1,13 @@ # configure.ac - for DirMngr # Copyright (C) 2002 Klar?lvdalens Datakonsult AB # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, -# 2009 g10 Code GmbH +# 2009, 2010 g10 Code GmbH # # This file is part of DirMngr. # # DirMngr is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # DirMngr is distributed in the hope that it will be useful, Modified: trunk/jnlib/argparse.c =================================================================== --- trunk/jnlib/argparse.c 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/jnlib/argparse.c 2010-11-16 09:24:21 UTC (rev 345) @@ -875,6 +875,9 @@ /* copyright string */ if( (s=strusage(14)) ) printf("%s\n", s ); + /* Licence string. */ + if( (s=strusage (10)) ) + printf ("%s\n", s); /* copying conditions */ if( (s=strusage(15)) ) fputs(s, stdout); @@ -911,6 +914,7 @@ * 0: Copyright String auf stderr ausgeben * 1: Kurzusage auf stderr ausgeben und beenden * 2: Langusage auf stdout ausgeben und beenden + * 10: Return license info string * 11: name of program * 12: optional name of package which includes this program. * 13: version string @@ -934,26 +938,27 @@ return p; switch( level ) { + case 10: p = ("License GPLv3+: GNU GPL version 3 or later " + ""); + break; case 11: p = "foo"; break; case 13: p = "0.0"; break; case 14: p = "Copyright (C) 2010 Free Software Foundation, Inc."; break; case 15: p = -"This program comes with ABSOLUTELY NO WARRANTY.\n" -"This is free software, and you are welcome to redistribute it\n" -"under certain conditions. See the file COPYING for details.\n"; break; +"This is free software: you are free to change and redistribute it.\n" +"There is NO WARRANTY, to the extent permitted by law.\n"; + break; case 16: p = "This is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" -"the Free Software Foundation; either version 2 of the License, or\n" +"the Free Software Foundation; either version 3 of the License, or\n" "(at your option) any later version.\n\n" "It is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n\n" "You should have received a copy of the GNU General Public License\n" -"along with this program; if not, write to the Free Software\n" -"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n" -"USA.\n"; +"along with this software. If not, see .\n"; break; case 40: /* short and long usage */ case 41: p = ""; break; Modified: trunk/src/dirmngr-client.c =================================================================== --- trunk/src/dirmngr-client.c 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/src/dirmngr-client.c 2010-11-16 09:24:21 UTC (rev 345) @@ -1,12 +1,12 @@ /* dirmngr-client.c - A client for the dirmngr daemon - * Copyright (C) 2004, 2007 g10 Code GmbH + * Copyright (C) 2004, 2007, 2010 g10 Code GmbH * Copyright (C) 2002, 2003 Free Software Foundation, Inc. * * This file is part of DirMngr. * * DirMngr is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * DirMngr is distributed in the hope that it will be useful, Modified: trunk/src/dirmngr.c =================================================================== --- trunk/src/dirmngr.c 2010-06-14 07:59:28 UTC (rev 344) +++ trunk/src/dirmngr.c 2010-11-16 09:24:21 UTC (rev 345) @@ -6,7 +6,7 @@ * * DirMngr is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * DirMngr is distributed in the hope that it will be useful, From cvs at cvs.gnupg.org Tue Nov 16 11:38:13 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 16 Nov 2010 11:38:13 +0100 Subject: [svn] GnuPG - r5483 - trunk/doc Message-ID: Author: wk Date: 2010-11-16 11:38:13 +0100 (Tue, 16 Nov 2010) New Revision: 5483 Modified: trunk/doc/faq.org Log: Update FAQ Modified: trunk/doc/faq.org =================================================================== --- trunk/doc/faq.org 2010-11-11 15:08:48 UTC (rev 5482) +++ trunk/doc/faq.org 2010-11-16 10:38:13 UTC (rev 5483) @@ -20,10 +20,9 @@ *WARNING: This FAQ is heavily outdated*. Mentioned versions of GnuPG have reached end of life many years ago. Almost all bugs and problems have been fixed in the now current versions of GnuPG. We will try to -update this FAQ in the next month. +update this FAQ in the next month. See the section "Changes" for recent updates. - * Welcome :PROPERTIES: :CUSTOM_ID: welcome @@ -919,7 +918,33 @@ :CUSTOM_ID: why-do-i-get-gpg_warning_using_insecure_memory :END: - On many systems this program should be installed as setuid(root). + You see this warning if GPG is not able to lock pages against being + swapped out to disk. + + However, on most modern system you should not see this message + anymore because these systems allow any process to prevent a small + number of memory pages from being swapped out to disk (using the + mlock system call). Other (mostly older) systems don't allow this + unless you install GPG as setuid(root). + + Locking pages against being swapped out is not necessary if your + system uses an encrypted swap partition. In fact that is the best + way to protect sensitive data from ending up on a disk. If your + system allows for encrypted swap partitions, please make use of + that feature. Note that GPG does not know about encrypted swap + partitions and might print the warning; thus you should disabled + the warning if your swap partition is encrypted. You may also want + to disable this warning if you can't or don't want to install GnuPG + setuid(root). To disable the warning you put a line + + : no-secmem-warning + + into your ~/.gnupg/gpg.conf file. + + What follows is a short description on how to install GPG + setuid(root); for those who need this. + + On some systems this program should be installed as setuid(root). This is necessary to lock memory pages. Locking memory pages prevents the operating system from writing them to disk and thereby keeping your secret keys really secret. If you get no warning @@ -944,14 +969,6 @@ : $ filepriv -f plock /path/to/gpg - If you can't or don't want to install GnuPG setuid(root), you can - use the option "--no-secmem-warning" or put: - - : no-secmem-warning - - in your ~/.gnupg/options or ~/.gnupg/gpg.conf file (this disables - the warning). - On some systems (e.g., Windows) GnuPG does not lock memory pages and older GnuPG versions (<=1.0.4) issue the warning: @@ -1456,6 +1473,13 @@ unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. +* Changes + + - 2010-11-14: Update "gpg: Warning: using insecure memory!" + + + + * COMMENT HTML style specifications #+begin_src emacs-lisp From cvs at cvs.gnupg.org Wed Nov 17 03:08:14 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 17 Nov 2010 03:08:14 +0100 Subject: [svn] assuan - r399 - trunk/src Message-ID: Author: marcus Date: 2010-11-17 03:08:13 +0100 (Wed, 17 Nov 2010) New Revision: 399 Modified: trunk/src/ChangeLog trunk/src/gpgcedev.c Log: 2010-11-17 Marcus Brinkmann * gpgcedev.c (struct pipeimpl_s): Add member monitor_rvid. (struct monitor_s, monitor_t): New types. (monitor_table, monitor_table_size): New static variables. (pipeimpl_new): Initialize monitor_rvid. (allocate_monitor): New function. (make_pipe): Also try the monitor_table if the opnctx_table fails. (monitor): Renamed to ... (monitor_main): ... this. Remove from monitor_table when done. (assign_rvid): Add to monitor table when creating monitor thread. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-15 14:52:45 UTC (rev 398) +++ trunk/src/ChangeLog 2010-11-17 02:08:13 UTC (rev 399) @@ -1,3 +1,15 @@ +2010-11-17 Marcus Brinkmann + + * gpgcedev.c (struct pipeimpl_s): Add member monitor_rvid. + (struct monitor_s, monitor_t): New types. + (monitor_table, monitor_table_size): New static variables. + (pipeimpl_new): Initialize monitor_rvid. + (allocate_monitor): New function. + (make_pipe): Also try the monitor_table if the opnctx_table fails. + (monitor): Renamed to ... + (monitor_main): ... this. Remove from monitor_table when done. + (assign_rvid): Add to monitor table when creating monitor thread. + 2010-11-15 Werner Koch * gpgcedev.c (GPG_Init): Read debug settings. Modified: trunk/src/gpgcedev.c =================================================================== --- trunk/src/gpgcedev.c 2010-11-15 14:52:45 UTC (rev 398) +++ trunk/src/gpgcedev.c 2010-11-17 02:08:13 UTC (rev 399) @@ -103,6 +103,7 @@ /* For the monitor thread started by ASSIGN_RVID. */ HANDLE monitor_proc; int monitor_access; + LONG monitor_rvid; }; typedef struct pipeimpl_s *pipeimpl_t; @@ -150,10 +151,21 @@ #define OPNCTX_FROM_IDX(idx) (&opnctx_table[(idx) - 1]) #define OPNCTX_VALID_IDX_P(idx) ((idx) > 0 && (idx) <= opnctx_table_size) -/* A criticial section object used to protect the OPNCTX_TABLE. */ +typedef struct monitor_s *monitor_t; +struct monitor_s +{ + int inuse; /* True if this object has valid data. */ + pipeimpl_t pipeimpl; +}; +static monitor_t monitor_table; +static size_t monitor_table_size; + +/* A criticial section object used to protect the OPNCTX_TABLE and + MONITOR_TABLE. */ static CRITICAL_SECTION opnctx_table_cs; + /* A global object to control the logging. */ struct { CRITICAL_SECTION lock; /* Lock for this structure. */ @@ -246,6 +258,7 @@ pimpl->data_available = CreateEvent (NULL, FALSE, FALSE, NULL); pimpl->monitor_proc = INVALID_HANDLE_VALUE; pimpl->monitor_access = 0; + pimpl->monitor_rvid = 0; return pimpl; } @@ -429,6 +442,45 @@ } +/* Return a new monitor handle and mark it as used. Returns NULL and + sets LastError on memory failure etc. opnctx_table_cs must be + locked on entry and is locked on exit. Note that the returned + pointer is only valid as long as opnctx_table_cs stays locked, as + it is not stable under table reallocation. */ +static monitor_t +allocate_monitor (void) +{ + monitor_t monitor = NULL; + int idx; + + for (idx = 0; idx < monitor_table_size; idx++) + if (! monitor_table[idx].inuse) + break; + if (idx == monitor_table_size) + { + /* We need to increase the size of the table. The approach we + take is straightforward to minimize the risk of bugs. */ + monitor_t newtbl; + size_t newsize = monitor_table_size + 16; + + newtbl = calloc (newsize, sizeof *newtbl); + if (!newtbl) + goto leave; + memcpy (newtbl, monitor_table, monitor_table_size * sizeof (*newtbl)); + free (monitor_table); + monitor_table = newtbl; + idx = monitor_table_size; + monitor_table_size = newsize; + } + monitor = &monitor_table[idx]; + monitor->inuse = 1; + monitor->pipeimpl = 0; + + leave: + return monitor; +} + + static pipeimpl_t assert_pipeimpl (opnctx_t ctx) { @@ -1036,62 +1088,117 @@ return FALSE; } + /* GnuPG and other programs don't use the safe ASSIGN_RVID call + because they guarantee that the context exists during the whole + time the child process runs. GPGME is more asynchronous and + relies on ASSIGN_RVID monitors. So, first check for open + contexts, then check for monitors. */ + for (idx = 0; idx < opnctx_table_size; idx++) if (opnctx_table[idx].inuse && opnctx_table[idx].rvid == rvid) { peerctx = &opnctx_table[idx]; break; } - if (! peerctx) + if (peerctx) { - log_debug (" make_pipe (ctx=%i): error: not found\n", ctx_arg); - SetLastError (ERROR_NOT_FOUND); - return FALSE; - } + /* This is the GnuPG etc case, where the context is still open. + It may also cover the GPGME case if GPGME is still using its + own end of the pipe at the time of this call. */ + if (peerctx == ctx) + { + log_debug (" make_pipe (ctx=%i): error: target and source identical\n", + ctx_arg); + SetLastError (ERROR_INVALID_TARGET_HANDLE); + return FALSE; + } - if (peerctx == ctx) - { - log_debug (" make_pipe (ctx=%i): error: target and source identical\n", - ctx_arg); - SetLastError (ERROR_INVALID_TARGET_HANDLE); - return FALSE; + if ((ctx->access_code & GENERIC_READ)) + { + /* Check that the peer is a write end. */ + if (!(peerctx->access_code & GENERIC_WRITE)) + { + log_debug (" make_pipe (ctx=%i): error: peer is not writer\n", + ctx_arg); + SetLastError (ERROR_INVALID_ACCESS); + return FALSE; + } + } + else if ((ctx->access_code & GENERIC_WRITE)) + { + /* Check that the peer is a read end. */ + if (!(peerctx->access_code & GENERIC_READ)) + { + log_debug (" make_pipe (ctx=%i): error: peer is not reader\n", + ctx_arg); + SetLastError (ERROR_INVALID_ACCESS); + return FALSE; + } + } + else + { + log_debug (" make_pipe (ctx=%i): error: invalid access\n", ctx_arg); + SetLastError (ERROR_INVALID_ACCESS); + return FALSE; + } + + /* Make sure the peer has a pipe implementation to be shared. If + not yet, create one. */ + pimpl = assert_pipeimpl (peerctx); + if (! pimpl) + return FALSE; } - - if ((ctx->access_code & GENERIC_READ)) - { - /* Check that the peer is a write end. */ - if (!(peerctx->access_code & GENERIC_WRITE)) - { - SetLastError (ERROR_INVALID_ACCESS); - log_debug (" make_pipe (ctx=%i): error: peer is not writer\n", - ctx_arg); - return FALSE; - } - } - else if ((ctx->access_code & GENERIC_WRITE)) - { - /* Check that the peer is a read end. */ - if (!(peerctx->access_code & GENERIC_READ)) - { - SetLastError (ERROR_INVALID_ACCESS); - log_debug (" make_pipe (ctx=%i): error: peer is not reader\n", - ctx_arg); - return FALSE; - } - } else { - SetLastError (ERROR_INVALID_ACCESS); - log_debug (" make_pipe (ctx=%i): error: invalid access\n", ctx_arg); - return FALSE; + /* This is the case where ASSIGN_RVID was called to create a + monitor, and the pipe is already closed at the parent side. + For example GPGME verify detached plain text, where GPG calls + MAKE_PIPE very late. */ + + for (idx = 0; idx < monitor_table_size; idx++) + if (monitor_table[idx].inuse + && monitor_table[idx].pipeimpl->monitor_rvid == rvid) + { + pimpl = monitor_table[idx].pipeimpl; + break; + } + if (idx == monitor_table_size) + { + log_debug (" make_pipe (ctx=%i): error: not found\n", ctx_arg); + SetLastError (ERROR_NOT_FOUND); + return FALSE; + } + + if (ctx->access_code & GENERIC_READ) + { + /* Check that the peer is a write end. */ + if (!(pimpl->monitor_access & GENERIC_READ)) + { + log_debug (" make_pipe (ctx=%i): error: monitor is not reader\n", + ctx_arg); + SetLastError (ERROR_INVALID_ACCESS); + return FALSE; + } + } + else if ((ctx->access_code & GENERIC_WRITE)) + { + /* Check that the peer is a read end. */ + if (!(pimpl->monitor_access & GENERIC_WRITE)) + { + log_debug (" make_pipe (ctx=%i): error: monitor is not writer\n", + ctx_arg); + SetLastError (ERROR_INVALID_ACCESS); + return FALSE; + } + } + else + { + log_debug (" make_pipe (ctx=%i): error: invalid access\n", ctx_arg); + SetLastError (ERROR_INVALID_ACCESS); + return FALSE; + } } - /* Make sure the peer has a pipe implementation to be shared. If - not yet, create one. */ - pimpl = assert_pipeimpl (peerctx); - if (! pimpl) - return FALSE; - EnterCriticalSection (&pimpl->critsect); pimpl->refcnt++; if (pimpl->monitor_proc != INVALID_HANDLE_VALUE) @@ -1110,8 +1217,16 @@ ctx->pipeimpl = pimpl; - log_debug (" make_pipe (ctx=%i): success: combined with peer ctx=%i " - "(pipe 0x%p)\n", ctx_arg, OPNCTX_TO_IDX (peerctx), pimpl); + if (peerctx) + { + log_debug (" make_pipe (ctx=%i): success: combined with peer ctx=%i " + "(pipe 0x%p)\n", ctx_arg, OPNCTX_TO_IDX (peerctx), pimpl); + } + else + { + log_debug (" make_pipe (ctx=%i): success: combined with " + "pipe 0x%p\n", ctx_arg, OPNCTX_TO_IDX (peerctx), pimpl); + } return TRUE; } @@ -1143,10 +1258,11 @@ static DWORD CALLBACK -monitor (void *arg) +monitor_main (void *arg) { pipeimpl_t pimpl = (pipeimpl_t) arg; HANDLE handles[2]; + int idx; log_debug ("starting monitor (pimpl=0x%p)\n", pimpl); @@ -1198,9 +1314,28 @@ } log_debug ("ending monitor (pimpl=0x%p)\n", pimpl); + + /* Remove the monitor from the monitor table. */ + LeaveCriticalSection (&pimpl->critsect); + EnterCriticalSection (&opnctx_table_cs); + for (idx = 0; idx < monitor_table_size; idx++) + if (monitor_table[idx].inuse + && monitor_table[idx].pipeimpl == pimpl) + { + monitor_table[idx].pipeimpl = NULL; + monitor_table[idx].inuse = 0; + break; + } + if (idx == monitor_table_size) + log_debug ("can not find monitor in table (pimpl=0x%p)\n", pimpl); + LeaveCriticalSection (&opnctx_table_cs); + EnterCriticalSection (&pimpl->critsect); + + /* Now do the rest of the cleanup. */ CloseHandle (pimpl->monitor_proc); pimpl->monitor_proc = INVALID_HANDLE_VALUE; pimpl->monitor_access = 0; + pimpl->monitor_rvid = 0; pimpl->flags &= ~PIPE_FLAG_HALT_MONITOR; pipeimpl_unref (pimpl); @@ -1218,6 +1353,7 @@ HANDLE monitor_hnd; HANDLE proc; pipeimpl_t pimpl; + monitor_t monitor; log_debug (" assign_rvid (ctx=%i, rvid=%08lx, pid=%08lx)\n", ctx_arg, rvid, pid); @@ -1261,6 +1397,16 @@ return FALSE; } + monitor = allocate_monitor (); + if (!monitor) + { + log_debug (" assign_rvid (ctx=%i): error: could not allocate monitor\n", + ctx_arg); + CloseHandle (proc); + return FALSE; + } + monitor->pipeimpl = pimpl; + EnterCriticalSection (&pimpl->critsect); pimpl->refcnt++; @@ -1271,14 +1417,18 @@ pimpl->monitor_access = GENERIC_WRITE; else pimpl->monitor_access = GENERIC_READ; + pimpl->monitor_rvid = rvid; - monitor_hnd = CreateThread (NULL, 0, monitor, pimpl, 0, NULL); + monitor_hnd = CreateThread (NULL, 0, monitor_main, pimpl, 0, NULL); if (monitor_hnd == INVALID_HANDLE_VALUE) { pimpl->monitor_access = 0; pimpl->monitor_proc = INVALID_HANDLE_VALUE; LeaveCriticalSection (&pimpl->critsect); + monitor->pipeimpl = NULL; + monitor->inuse = 0; + CloseHandle (proc); log_debug (" assign_rvid (ctx=%i): error: can not create monitor\n", ctx_arg); From cvs at cvs.gnupg.org Wed Nov 17 03:11:06 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 17 Nov 2010 03:11:06 +0100 Subject: [svn] gpgme - r1507 - trunk/src Message-ID: Author: marcus Date: 2010-11-17 03:11:05 +0100 (Wed, 17 Nov 2010) New Revision: 1507 Modified: trunk/src/ChangeLog trunk/src/vasprintf.c Log: 2010-11-17 Marcus Brinkmann * vasprintf.c (int_vasprintf) [HAVE_W32CE_SYSTEM]: Just use a fixed size buffer, as va_copy is not easy to fake. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-15 15:30:04 UTC (rev 1506) +++ trunk/src/ChangeLog 2010-11-17 02:11:05 UTC (rev 1507) @@ -1,3 +1,8 @@ +2010-11-17 Marcus Brinkmann + + * vasprintf.c (int_vasprintf) [HAVE_W32CE_SYSTEM]: Just use a + fixed size buffer, as va_copy is not easy to fake. + 2010-11-15 Marcus Brinkmann * w32-ce.h (strcasecmp, strdup) [_MSC_VER]: Define. Modified: trunk/src/vasprintf.c =================================================================== --- trunk/src/vasprintf.c 2010-11-15 15:30:04 UTC (rev 1506) +++ trunk/src/vasprintf.c 2010-11-17 02:11:05 UTC (rev 1507) @@ -51,6 +51,19 @@ const char *format; va_list *args; { +#ifdef HAVE_W32CE_SYSTEM + /* No va_copy and the replacement above doesn't work. */ +#define MAX_STRLEN 256 + *result = malloc (MAX_STRLEN); + if (*result != NULL) + { + int res = _vsnprintf (*result, MAX_STRLEN, format, *args); + (*result)[MAX_STRLEN - 1] = '\0'; + return res; + } + else + return 0; +#else const char *p = format; /* Add one to make sure that it is never zero, which might cause malloc to return NULL. */ @@ -133,6 +146,7 @@ return vsprintf (*result, format, *args); else return 0; +#endif } int From cvs at cvs.gnupg.org Wed Nov 17 14:21:26 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 17 Nov 2010 14:21:26 +0100 Subject: [svn] GnuPG - r5484 - in trunk: . doc g10 scd Message-ID: Author: wk Date: 2010-11-17 14:21:24 +0100 (Wed, 17 Nov 2010) New Revision: 5484 Modified: trunk/ChangeLog trunk/configure.ac trunk/doc/DETAILS trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/g10/card-util.c trunk/g10/gpg.c trunk/g10/keyedit.c trunk/g10/keygen.c trunk/g10/keylist.c trunk/g10/main.h trunk/g10/misc.c trunk/scd/ChangeLog trunk/scd/apdu.c Log: Smartcard related updates Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/ChangeLog 2010-11-17 13:21:24 UTC (rev 5484) @@ -1,3 +1,7 @@ +2010-11-17 Werner Koch + + * configure.ac (ENABLE_CARD_SUPPORT): Define. + 2010-10-27 Werner Koch * acinclude.m4 (GNUPG_TIME_T_UNSIGNED): New. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/ChangeLog 2010-11-17 13:21:24 UTC (rev 5484) @@ -1,3 +1,24 @@ +2010-11-17 Werner Koch + + * keyedit.c (find_pk_from_sknode): Remove. + * misc.c (get_signature_count): Call agent. + * keygen.c (gen_card_key): Rework. Remove arg PARA. + (generate_keypair): Change arg BACKUP_ENCRYPTION_DIR to the flag + CARD_BACKUP_KEY. + (pBACKUPENCDIR): Change to pCARDBACKUPKEY. + (struct output_control_s): Remove struct SEC. Remove all usages + of it. + (gen_card_key_with_backup): Remove arg BACKUP_DIR. + + * call-agent.c (agent_scd_genkey): Remove extra memset. + +2010-11-16 Werner Koch + + * keygen.c (generate_card_subkeypair): Remove arg SEC_KEYBLOCK and + change to return an error code. Rework for removed secring code. + * card-util.c (card_generate_subkey): Remove arg SEC_KEYBLOCK. + Return an error code instead of a success flag. Change caller. + 2010-10-29 David Shaw * pkclist.c (select_algo_from_prefs): Make sure the scores can't Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/scd/ChangeLog 2010-11-17 13:21:24 UTC (rev 5484) @@ -1,3 +1,8 @@ +2010-11-16 Werner Koch + + * apdu.c (PCSC_UNKNOWN) [W32]: Fix all these values which don't + match those of libpcsc. Reported by Michael Petig. + 2010-10-27 Werner Koch * scdaemon.c (create_socket_name): Use TMPDIR. Change callers. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/configure.ac 2010-11-17 13:21:24 UTC (rev 5484) @@ -485,7 +485,7 @@ #define HTTP_NO_WSASTARTUP /* We always include support for the OpenPGP card. */ -/* Disabled for now ENABLE_CARD_SUPPORT 1 */ +#define ENABLE_CARD_SUPPORT 1 /* We explicitly need to disable PTH's soft mapping as Debian currently enables it by default for no reason. */ Modified: trunk/doc/DETAILS =================================================================== --- trunk/doc/DETAILS 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/doc/DETAILS 2010-11-17 13:21:24 UTC (rev 5484) @@ -817,7 +817,8 @@ The filename is used until a new filename is used (at commit points) and all keys are written to that file. If a new filename is given, this file is created (and overwrites an existing one). - Both control statements must be given. + GnuPG < 2.1: Both control statements must be given. + GnuPG >= 2.1: "%secring" is now a no-op. %ask-passphrase Enable a mode where the command "passphrase" is ignored and instead the usual passphrase dialog is used. This does not Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/call-agent.c 2010-11-17 13:21:24 UTC (rev 5484) @@ -771,10 +771,9 @@ } /* Send a GENKEY command to the SCdaemon. SERIALNO is not used in - this implementation. If CREATEDATE has been given, it will be - passed to SCDAEMON so that the key can be created with this - timestamp; note the user needs to use the returned timestamp as old - versions of scddaemon don't support this option. */ + this implementation. If CREATEDATE is not 0, it will be passed to + SCDAEMON so that the key is created with this timestamp. INFO will + receive information about the generated key. */ int agent_scd_genkey (struct agent_card_genkey_s *info, int keyno, int force, const char *serialno, u32 createtime) @@ -794,7 +793,6 @@ else *tbuf = 0; - memset (info, 0, sizeof *info); snprintf (line, DIM(line)-1, "SCD GENKEY %s%s %s %d", *tbuf? "--timestamp=":"", tbuf, force? "--force":"", Modified: trunk/g10/card-util.c =================================================================== --- trunk/g10/card-util.c 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/card-util.c 2010-11-17 13:21:24 UTC (rev 5484) @@ -581,29 +581,31 @@ if ( thefpr && !fpr_is_ff (thefpr) && !get_pubkey_byfprint (pk, thefpr, 20)) { - KBNODE keyblock = NULL; - print_pubkey_info (fp, pk); #if GNUPG_MAJOR_VERSION == 1 - if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) ) - print_card_key_info (fp, keyblock); - else if ( !get_keyblock_byfprint (&keyblock, thefpr, 20) ) - { - release_kbnode (keyblock); - keyblock = NULL; - - if (!auto_create_card_key_stub (info.serialno, - info.fpr1valid? info.fpr1:NULL, - info.fpr2valid? info.fpr2:NULL, - info.fpr3valid? info.fpr3:NULL)) - { - if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) ) - print_card_key_info (fp, keyblock); - } - } - - release_kbnode (keyblock); + { + kbnode_t keyblock = NULL; + + if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) ) + print_card_key_info (fp, keyblock); + else if ( !get_keyblock_byfprint (&keyblock, thefpr, 20) ) + { + release_kbnode (keyblock); + keyblock = NULL; + + if (!auto_create_card_key_stub (info.serialno, + info.fpr1valid? info.fpr1:NULL, + info.fpr2valid? info.fpr2:NULL, + info.fpr3valid? info.fpr3:NULL)) + { + if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) ) + print_card_key_info (fp, keyblock); + } + } + + release_kbnode (keyblock); + } #endif /* GNUPG_MAJOR_VERSION == 1 */ } else @@ -1431,7 +1433,7 @@ the serialnumber and thus it won't harm. */ } - generate_keypair (NULL, info.serialno, want_backup? opt.homedir:NULL); + generate_keypair (NULL, info.serialno, want_backup); leave: agent_release_card_info (&info); @@ -1441,17 +1443,18 @@ /* This function is used by the key edit menu to generate an arbitrary subkey. */ -int -card_generate_subkey (KBNODE pub_keyblock, KBNODE sec_keyblock) +gpg_error_t +card_generate_subkey (KBNODE pub_keyblock) { + gpg_error_t err; struct agent_card_info_s info; - int okay = 0; int forced_chv1 = 0; int keyno; - - if (get_info_for_key_operation (&info)) - return 0; - + + err = get_info_for_key_operation (&info); + if (err) + return err; + show_card_key_info (&info); tty_printf (_("Please select the type of key to generate:\n")); @@ -1468,6 +1471,7 @@ if (*answer == CONTROL_D) { xfree (answer); + err = gpg_error (GPG_ERR_CANCELED); goto leave; } keyno = *answer? atoi(answer): 0; @@ -1476,40 +1480,44 @@ break; /* Okay. */ tty_printf(_("Invalid selection.\n")); } - + if (replace_existing_key_p (&info, keyno)) + { + err = gpg_error (GPG_ERR_CANCELED); + goto leave; + } + + err = check_pin_for_key_operation (&info, &forced_chv1); + if (err) goto leave; - - if (check_pin_for_key_operation (&info, &forced_chv1)) - goto leave; - + /* If the cards features changeable key attributes, we ask for the key size. */ if (info.is_v2 && info.extcap.aac) { unsigned int nbits; - + ask_again: nbits = ask_card_keysize (keyno-1, info.key_attr[keyno-1].nbits); if (nbits && do_change_keysize (keyno-1, nbits)) { /* Error: Better read the default key size again. */ agent_release_card_info (&info); - if (get_info_for_key_operation (&info)) + err = get_info_for_key_operation (&info); + if (err) goto leave; goto ask_again; } /* Note that INFO has not be synced. However we will only use the serialnumber and thus it won't harm. */ } - - /* xxx = generate_card_subkeypair (pub_keyblock, sec_keyblock, */ - /* keyno, info.serialno); */ - + + err = generate_card_subkeypair (pub_keyblock, keyno, info.serialno); + leave: agent_release_card_info (&info); restore_forced_chv1 (&forced_chv1); - return okay; + return err; } @@ -1520,6 +1528,7 @@ int card_store_subkey (KBNODE node, int use) { + log_info ("FIXME: card_store_subkey has not yet been implemented\n"); /* struct agent_card_info_s info; */ /* int okay = 0; */ /* int rc; */ Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/gpg.c 2010-11-17 13:21:24 UTC (rev 5484) @@ -3705,12 +3705,12 @@ if( opt.batch ) { if( argc > 1 ) wrong_args("--gen-key [parameterfile]"); - generate_keypair( argc? *argv : NULL, NULL, NULL ); + generate_keypair (argc? *argv : NULL, NULL, 0); } else { if( argc ) wrong_args("--gen-key"); - generate_keypair(NULL, NULL, NULL); + generate_keypair (NULL, NULL, 0); } break; Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/keyedit.c 2010-11-17 13:21:24 UTC (rev 5484) @@ -108,36 +108,7 @@ }; -#ifdef ENABLE_CARD_SUPPORT -/* Given a node SEC_NODE with a secret key or subkey, locate the - corresponding public key from pub_keyblock. */ -static PKT_public_key * -find_pk_from_sknode (KBNODE pub_keyblock, KBNODE sec_node) -{ - KBNODE node = pub_keyblock; - PKT_secret_key *sk; - PKT_public_key *pk; -#warning: This is not anymore needed. - if (sec_node->pkt->pkttype == PKT_SECRET_KEY - && node->pkt->pkttype == PKT_PUBLIC_KEY) - return node->pkt->pkt.public_key; - if (sec_node->pkt->pkttype != PKT_SECRET_SUBKEY) - return NULL; - sk = sec_node->pkt->pkt.secret_key; - for (; node; node = node->next) - if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY) - { - pk = node->pkt->pkt.public_key; - if (pk->keyid[0] == sk->keyid[0] && pk->keyid[1] == sk->keyid[1]) - return pk; - } - - return NULL; -} -#endif /* ENABLE_CARD_SUPPORT */ - - /* TODO: Fix duplicated code between here and the check-sigs/list-sigs code in keylist.c. */ static int @@ -1833,7 +1804,7 @@ #ifdef ENABLE_CARD_SUPPORT case cmdADDCARDKEY: - if (card_generate_subkey (keyblock)) + if (!card_generate_subkey (keyblock)) { redisplay = 1; modified = 1; @@ -1868,7 +1839,7 @@ } if (node) { - PKT_public_key *xxpk = find_pk_from_sknode (keyblock, node); + PKT_public_key *xxpk = node->pkt->pkt.public_key; if (card_store_subkey (node, xxpk ? xxpk->pubkey_usage : 0)) { redisplay = 1; @@ -1934,25 +1905,25 @@ if (cmd == cmdCHECKBKUPKEY) { - PKT_secret_key *sk = node->pkt->pkt.secret_key; - switch (is_secret_key_protected (sk)) - { - case 0: /* Not protected. */ - tty_printf (_("This key is not protected.\n")); - break; - case -1: - log_error (_("unknown key protection algorithm\n")); - break; - default: - if (sk->protect.s2k.mode == 1001) - tty_printf (_("Secret parts of key" - " are not available.\n")); - if (sk->protect.s2k.mode == 1002) - tty_printf (_("Secret parts of key" - " are stored on-card.\n")); + /* PKT_public_key *sk = node->pkt->pkt.secret_key; */ + /* switch (is_secret_key_protected (sk)) */ + /* { */ + /* case 0: /\* Not protected. *\/ */ + /* tty_printf (_("This key is not protected.\n")); */ + /* break; */ + /* case -1: */ + /* log_error (_("unknown key protection algorithm\n")); */ + /* break; */ + /* default: */ + /* if (sk->protect.s2k.mode == 1001) */ + /* tty_printf (_("Secret parts of key" */ + /* " are not available.\n")); */ + /* if (sk->protect.s2k.mode == 1002) */ + /* tty_printf (_("Secret parts of key" */ + /* " are stored on-card.\n")); */ /* else */ /* check_secret_key (sk, 0); */ - } + /* } */ } else /* Store it. */ { Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/keygen.c 2010-11-17 13:21:24 UTC (rev 5484) @@ -78,7 +78,7 @@ pPASSPHRASE_DEK, pPASSPHRASE_S2K, pSERIALNO, - pBACKUPENCDIR, + pCARDBACKUPKEY, pHANDLE, pKEYSERVER }; @@ -98,24 +98,19 @@ } u; }; -struct output_control_s { - int lnr; - int dryrun; - int ask_passphrase; - unsigned int keygen_flags; - int use_files; - struct { - char *fname; - char *newfname; - IOBUF stream; - armor_filter_context_t *afx; - } pub; - struct { - char *fname; - char *newfname; - IOBUF stream; - armor_filter_context_t *afx; - } sec; +struct output_control_s +{ + int lnr; + int dryrun; + int ask_passphrase; + unsigned int keygen_flags; + int use_files; + struct { + char *fname; + char *newfname; + IOBUF stream; + armor_filter_context_t *afx; + } pub; }; @@ -137,13 +132,12 @@ static void do_generate_keypair( struct para_data_s *para, struct output_control_s *outctrl, int card ); static int write_keyblock (iobuf_t out, kbnode_t node); -static int gen_card_key (int algo, int keyno, int is_primary, kbnode_t pub_root, - u32 *timestamp, u32 expireval, - struct para_data_s *para); +static gpg_error_t gen_card_key (int algo, int keyno, int is_primary, + kbnode_t pub_root, + u32 *timestamp, u32 expireval); static int gen_card_key_with_backup (int algo, int keyno, int is_primary, kbnode_t pub_root, u32 timestamp, - u32 expireval, struct para_data_s *para, - const char *backup_dir); + u32 expireval, struct para_data_s *para); static void @@ -2217,18 +2211,19 @@ static void -release_parameter_list( struct para_data_s *r ) +release_parameter_list (struct para_data_s *r) { - struct para_data_s *r2; - - for( ; r ; r = r2 ) { - r2 = r->next; - if( r->key == pPASSPHRASE_DEK ) - xfree( r->u.dek ); - else if( r->key == pPASSPHRASE_S2K ) - xfree( r->u.s2k ); - - xfree(r); + struct para_data_s *r2; + + for (; r ; r = r2) + { + r2 = r->next; + if (r->key == pPASSPHRASE_DEK) + xfree (r->u.dek); + else if (r->key == pPASSPHRASE_S2K ) + xfree (r->u.s2k); + + xfree (r); } } @@ -2657,11 +2652,6 @@ para = r; } - if( !!outctrl->pub.newfname ^ !!outctrl->sec.newfname ) { - log_error("%s:%d: only one ring name is set\n", fname, outctrl->lnr ); - return -1; - } - do_generate_keypair( para, outctrl, card ); return 0; } @@ -2708,7 +2698,6 @@ memset( &outctrl, 0, sizeof( outctrl ) ); outctrl.pub.afx = new_armor_context (); - outctrl.sec.afx = new_armor_context (); if( !fname || !*fname) fname = "-"; @@ -2783,13 +2772,7 @@ } } else if( !ascii_strcasecmp( keyword, "%secring" ) ) { - if( outctrl.sec.fname && !strcmp( outctrl.sec.fname, value ) ) - ; /* still the same file - ignore it */ - else { - xfree( outctrl.sec.newfname ); - outctrl.sec.newfname = xstrdup( value ); - outctrl.use_files = 1; - } + /* Ignore this command. */ } else log_info("skipping control `%s' (%s)\n", keyword, value ); @@ -2865,40 +2848,32 @@ if( outctrl.use_files ) { /* close open streams */ iobuf_close( outctrl.pub.stream ); - iobuf_close( outctrl.sec.stream ); /* Must invalidate that ugly cache to actually close it. */ if (outctrl.pub.fname) iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)outctrl.pub.fname); - if (outctrl.sec.fname) - iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, - 0, (char*)outctrl.sec.fname); xfree( outctrl.pub.fname ); xfree( outctrl.pub.newfname ); - xfree( outctrl.sec.fname ); - xfree( outctrl.sec.newfname ); } release_parameter_list( para ); iobuf_close (fp); release_armor_context (outctrl.pub.afx); - release_armor_context (outctrl.sec.afx); } /* * Generate a keypair (fname is only used in batch mode) If * CARD_SERIALNO is not NULL the function will create the keys on an - * OpenPGP Card. If BACKUP_ENCRYPTION_DIR has been set and - * CARD_SERIALNO is NOT NULL, the encryption key for the card gets - * generate in software, imported to the card and a backup file - * written to directory given by this argument . + * OpenPGP Card. If CARD_BACKUP_KEY has been set and CARD_SERIALNO is + * NOT NULL, the encryption key for the card is generated on the host, + * imported to the card and a backup file created by gpg-agent. */ void generate_keypair (const char *fname, const char *card_serialno, - const char *backup_encryption_dir) + int card_backup_key) { unsigned int nbits; char *uid = NULL; @@ -2964,11 +2939,11 @@ r->next = para; para = r; - if (backup_encryption_dir) + if (card_backup_key) { - r = xcalloc (1, sizeof *r + strlen (backup_encryption_dir) ); - r->key = pBACKUPENCDIR; - strcpy (r->u.value, backup_encryption_dir); + r = xcalloc (1, sizeof *r + 1); + r->key = pCARDBACKUPKEY; + strcpy (r->u.value, "1"); r->next = para; para = r; } @@ -3071,7 +3046,7 @@ } -#ifdef ENABLE_CARD_SUPPORT +#if 0 /* not required */ /* Generate a raw key and return it as a secret key packet. The function will ask for the passphrase and return a protected as well as an unprotected copy of a new secret key packet. 0 is returned @@ -3270,7 +3245,7 @@ else err = gen_card_key (PUBKEY_ALGO_RSA, 1, 1, pub_root, ×tamp, - get_parameter_u32 (para, pKEYEXPIRE), para); + get_parameter_u32 (para, pKEYEXPIRE)); /* Get the pointer to the generated public key packet. */ if (!err) @@ -3301,7 +3276,7 @@ { err = gen_card_key (PUBKEY_ALGO_RSA, 3, 0, pub_root, ×tamp, - get_parameter_u32 (para, pKEYEXPIRE), para); + get_parameter_u32 (para, pKEYEXPIRE)); if (!err) err = write_keybinding (pub_root, pri_psk, NULL, PUBKEY_USAGE_AUTH, timestamp, cache_nonce); @@ -3331,23 +3306,20 @@ } else { - if ((s = get_parameter_value (para, pBACKUPENCDIR))) + if ((s = get_parameter_value (para, pCARDBACKUPKEY))) { /* A backup of the encryption key has been requested. Generate the key in software and import it then to the card. Write a backup file. */ - err = gen_card_key_with_backup (PUBKEY_ALGO_RSA, 2, 0, - pub_root, - timestamp, - get_parameter_u32 (para, - pKEYEXPIRE), - para, s); + err = gen_card_key_with_backup + (PUBKEY_ALGO_RSA, 2, 0, pub_root, timestamp, + get_parameter_u32 (para, pKEYEXPIRE), para); } else { err = gen_card_key (PUBKEY_ALGO_RSA, 2, 0, pub_root, ×tamp, - get_parameter_u32 (para, pKEYEXPIRE), para); + get_parameter_u32 (para, pKEYEXPIRE)); } } @@ -3551,81 +3523,65 @@ #ifdef ENABLE_CARD_SUPPORT /* Generate a subkey on a card. */ -int -generate_card_subkeypair (KBNODE pub_keyblock, KBNODE sec_keyblock, +gpg_error_t +generate_card_subkeypair (kbnode_t pub_keyblock, int keyno, const char *serialno) { gpg_error_t err = 0; - int okay = 0; kbnode_t node; - PKT_secret_key *pri_sk = NULL, *sub_sk; + PKT_public_key *pri_pk = NULL; int algo; unsigned int use; u32 expire; - char *passphrase = NULL; u32 cur_time; struct para_data_s *para = NULL; assert (keyno >= 1 && keyno <= 3); - para = xcalloc (1, sizeof *para + strlen (serialno) ); + para = xtrycalloc (1, sizeof *para + strlen (serialno) ); + if (!para) + { + err = gpg_error_from_syserror (); + goto leave; + } para->key = pSERIALNO; strcpy (para->u.value, serialno); /* Break out the primary secret key */ - node = find_kbnode (sec_keyblock, PKT_SECRET_KEY); + node = find_kbnode (pub_keyblock, PKT_PUBLIC_KEY); if (!node) { - log_error("Oops; secret key not found anymore!\n"); + log_error ("Oops; publkic key lost!\n"); + err = gpg_error (GPG_ERR_INTERNAL); goto leave; } + pri_pk = node->pkt->pkt.public_key; - /* Make a copy of the sk to keep the protected one in the keyblock */ - pri_sk = copy_secret_key (NULL, node->pkt->pkt.secret_key); - cur_time = make_timestamp(); - if (pri_sk->timestamp > cur_time) + if (pri_pk->timestamp > cur_time) { - ulong d = pri_sk->timestamp - cur_time; + ulong d = pri_pk->timestamp - cur_time; log_info (d==1 ? _("key has been created %lu second " "in future (time warp or clock problem)\n") : _("key has been created %lu seconds " "in future (time warp or clock problem)\n"), d ); if (!opt.ignore_time_conflict) { - err = G10ERR_TIME_CONFLICT; + err = gpg_error (GPG_ERR_TIME_CONFLICT); goto leave; } } - if (pri_sk->version < 4) + if (pri_pk->version < 4) { log_info (_("NOTE: creating subkeys for v3 keys " "is not OpenPGP compliant\n")); + err = gpg_error (GPG_ERR_NOT_SUPPORTED); goto leave; } - /* Unprotect to get the passphrase. */ - switch( is_secret_key_protected (pri_sk) ) - { - case -1: - err = G10ERR_PUBKEY_ALGO; - break; - case 0: - tty_printf("This key is not protected.\n"); - break; - default: - tty_printf("Key is protected.\n"); - err = check_secret_key( pri_sk, 0 ); - if (!err) - passphrase = get_last_passphrase(); - break; - } - if (err) - goto leave; - algo = PUBKEY_ALGO_RSA; - expire = ask_expire_interval (0,NULL); + expire = ask_expire_interval (0, NULL); if (keyno == 1) use = PUBKEY_USAGE_SIG; else if (keyno == 2) @@ -3634,40 +3590,37 @@ use = PUBKEY_USAGE_AUTH; if (!cpr_enabled() && !cpr_get_answer_is_yes("keygen.cardsub.okay", _("Really create? (y/N) "))) - goto leave; + { + err = gpg_error (GPG_ERR_CANCELED); + goto leave; + } - if (passphrase) - set_next_passphrase (passphrase); - /* Note, that depending on the backend, the card key generation may update CUR_TIME. */ - err = gen_card_key (algo, keyno, 0, pub_keyblock, &cur_time, expire, para); + err = gen_card_key (algo, keyno, 0, pub_keyblock, &cur_time, expire); + /* Get the pointer to the generated public subkey packet. */ if (!err) - err = write_keybinding (pub_keyblock, pub_keyblock, pri_sk, sub_sk, - use, cur_time); - if (!err) - err = write_keybinding (sec_keyblock, pub_keyblock, pri_sk, sub_sk, - use, cur_time); - if (!err) { - okay = 1; - write_status_text (STATUS_KEY_CREATED, "S"); + PKT_public_key *sub_pk = NULL; + + for (node = pub_keyblock; node; node = node->next) + if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY) + sub_pk = node->pkt->pkt.public_key; + assert (sub_pk); + err = write_keybinding (pub_keyblock, pri_pk, sub_pk, + use, cur_time, NULL); } leave: if (err) log_error (_("Key generation failed: %s\n"), g10_errstr(err) ); - xfree (passphrase); - /* Release the copy of the (now unprotected) secret keys. */ - if (pri_sk) - free_secret_key (pri_sk); - set_next_passphrase( NULL ); + else + write_status_text (STATUS_KEY_CREATED, "S"); release_parameter_list (para); - return okay; + return err; } #endif /* !ENABLE_CARD_SUPPORT */ - /* * Write a keyblock to an output stream */ @@ -3693,84 +3646,74 @@ /* Note that timestamp is an in/out arg. */ -static int -gen_card_key (int algo, int keyno, int is_primary, KBNODE pub_root, - u32 *timestamp, u32 expireval, struct para_data_s *para) +static gpg_error_t +gen_card_key (int algo, int keyno, int is_primary, kbnode_t pub_root, + u32 *timestamp, u32 expireval) { #ifdef ENABLE_CARD_SUPPORT - int rc; - const char *s; + gpg_error_t err; struct agent_card_genkey_s info; PACKET *pkt; - PKT_secret_key *sk; PKT_public_key *pk; - assert (algo == PUBKEY_ALGO_RSA); - - /* Fixme: We don't have the serialnumber available, thus passing NULL. */ - rc = agent_scd_genkey (&info, keyno, 1, NULL, *timestamp); -/* if (gpg_err_code (rc) == GPG_ERR_EEXIST) */ -/* { */ -/* tty_printf ("\n"); */ -/* log_error ("WARNING: key does already exists!\n"); */ -/* tty_printf ("\n"); */ -/* if ( cpr_get_answer_is_yes( "keygen.card.replace_key", */ -/* _("Replace existing key? "))) */ -/* rc = agent_scd_genkey (&info, keyno, 1); */ -/* } */ + if (algo != PUBKEY_ALGO_RSA) + return gpg_error (GPG_ERR_PUBKEY_ALGO); - if (rc) + pk = xtrycalloc (1, sizeof *pk ); + if (!pk) + return gpg_error_from_syserror (); + pkt = xtrycalloc (1, sizeof *pkt); + if (!pkt) { - log_error ("key generation failed: %s\n", gpg_strerror (rc)); - return rc; + xfree (pk); + return gpg_error_from_syserror (); } - if ( !info.n || !info.e ) + + /* Note: SCD knows the serialnumber, thus there is no point in passing it. */ + err = agent_scd_genkey (&info, keyno, 1, NULL, *timestamp); + /* The code below is not used because we force creation of + * the a card key (3rd arg). + * if (gpg_err_code (rc) == GPG_ERR_EEXIST) + * { + * tty_printf ("\n"); + * log_error ("WARNING: key does already exists!\n"); + * tty_printf ("\n"); + * if ( cpr_get_answer_is_yes( "keygen.card.replace_key", + * _("Replace existing key? "))) + * rc = agent_scd_genkey (&info, keyno, 1); + * } + */ + if (!err && (!info.n || !info.e)) { log_error ("communication error with SCD\n"); gcry_mpi_release (info.n); gcry_mpi_release (info.e); - return gpg_error (GPG_ERR_GENERAL); + err = gpg_error (GPG_ERR_GENERAL); } + if (err) + { + log_error ("key generation failed: %s\n", gpg_strerror (err)); + xfree (pkt); + xfree (pk); + return err; + } if (*timestamp != info.created_at) - log_info ("Note that the key does not use the suggested creation date\n"); + log_info ("NOTE: the key does not use the suggested creation date\n"); *timestamp = info.created_at; - pk = xcalloc (1, sizeof *pk ); - sk = xcalloc (1, sizeof *sk ); - sk->timestamp = pk->timestamp = info.created_at; - sk->version = pk->version = 4; + pk->timestamp = info.created_at; + pk->version = 4; if (expireval) - sk->expiredate = pk->expiredate = pk->timestamp + expireval; - sk->pubkey_algo = pk->pubkey_algo = algo; + pk->expiredate = pk->timestamp + expireval; + pk->pubkey_algo = algo; pk->pkey[0] = info.n; pk->pkey[1] = info.e; - sk->skey[0] = gcry_mpi_copy (pk->pkey[0]); - sk->skey[1] = gcry_mpi_copy (pk->pkey[1]); - sk->skey[2] = gcry_mpi_set_opaque (NULL, xstrdup ("dummydata"), 10*8); - sk->is_protected = 1; - sk->protect.s2k.mode = 1002; - s = get_parameter_value (para, pSERIALNO); - if (s) - { - for (sk->protect.ivlen=0; sk->protect.ivlen < 16 && *s && s[1]; - sk->protect.ivlen++, s += 2) - sk->protect.iv[sk->protect.ivlen] = xtoi_2 (s); - } - if( ret_sk ) - *ret_sk = sk; - - pkt = xcalloc (1,sizeof *pkt); pkt->pkttype = is_primary ? PKT_PUBLIC_KEY : PKT_PUBLIC_SUBKEY; pkt->pkt.public_key = pk; - add_kbnode(pub_root, new_kbnode( pkt )); + add_kbnode (pub_root, new_kbnode (pkt)); - pkt = xcalloc (1,sizeof *pkt); - pkt->pkttype = is_primary ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY; - pkt->pkt.secret_key = sk; - add_kbnode(sec_root, new_kbnode( pkt )); - return 0; #else return gpg_error (GPG_ERR_NOT_SUPPORTED); @@ -3782,10 +3725,9 @@ static int gen_card_key_with_backup (int algo, int keyno, int is_primary, KBNODE pub_root, u32 timestamp, - u32 expireval, struct para_data_s *para, - const char *backup_dir) + u32 expireval, struct para_data_s *para) { -#ifdef ENABLE_CARD_SUPPORT +#if 0 /* FIXME: Move this to gpg-agent. */ int rc; const char *s; PACKET *pkt; @@ -3947,9 +3889,9 @@ } -#ifdef ENABLE_CARD_SUPPORT +#if 0 int -save_unprotected_key_to_card (PKT_secret_key *sk, int keyno) +save_unprotected_key_to_card (PKT_public_key *sk, int keyno) { int rc; unsigned char *rsa_n = NULL; Modified: trunk/g10/keylist.c =================================================================== --- trunk/g10/keylist.c 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/keylist.c 2010-11-17 13:21:24 UTC (rev 5484) @@ -182,8 +182,7 @@ { /* KBNODE node; */ /* int i; */ - - log_debug ("Fixme: Needs to be adjusted to gpg-agent\n"); +#warning Fixme: Needs to be adjusted to gpg-agent /* for (node = keyblock; node; node = node->next) */ /* { */ /* if (node->pkt->pkttype == PKT_SECRET_KEY */ Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/main.h 2010-11-17 13:21:24 UTC (rev 5484) @@ -231,8 +231,8 @@ u32 parse_expire_string(const char *string); u32 ask_expire_interval(int object,const char *def_expire); u32 ask_expiredate(void); -void generate_keypair( const char *fname, const char *card_serialno, - const char *backup_encryption_dir ); +void generate_keypair (const char *fname, const char *card_serialno, + int card_backup_key); int keygen_set_std_prefs (const char *string,int personal); PKT_user_id *keygen_get_std_prefs (void); int keygen_add_key_expire( PKT_signature *sig, void *opaque ); @@ -246,9 +246,9 @@ u32 timestamp, const char *cache_nonce); gpg_error_t generate_subkeypair (kbnode_t pub_keyblock); #ifdef ENABLE_CARD_SUPPORT -int generate_card_subkeypair (KBNODE pub_keyblock, KBNODE sec_keyblock, - int keyno, const char *serialno); -int save_unprotected_key_to_card (PKT_secret_key *sk, int keyno); +gpg_error_t generate_card_subkeypair (kbnode_t pub_keyblock, + int keyno, const char *serialno); +int save_unprotected_key_to_card (PKT_public_key *sk, int keyno); #endif /*-- openfile.c --*/ @@ -348,7 +348,7 @@ void change_pin (int no, int allow_admin); void card_status (estream_t fp, char *serialno, size_t serialnobuflen); void card_edit (ctrl_t ctrl, strlist_t commands); -int card_generate_subkey (KBNODE pub_keyblock, KBNODE sec_keyblock); +gpg_error_t card_generate_subkey (KBNODE pub_keyblock); int card_store_subkey (KBNODE node, int use); #endif Modified: trunk/g10/misc.c =================================================================== --- trunk/g10/misc.c 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/g10/misc.c 2010-11-17 13:21:24 UTC (rev 5484) @@ -548,13 +548,12 @@ get_signature_count (PKT_public_key *pk) { #ifdef ENABLE_CARD_SUPPORT - /* FIXME: Need to call the agent. */ - /* if(sk && sk->is_protected && sk->protect.s2k.mode==1002) */ - /* { */ - /* struct agent_card_info_s info; */ - /* if(agent_scd_getattr("SIG-COUNTER",&info)==0) */ - /* return info.sig_counter; */ - /* } */ + struct agent_card_info_s info; +#warning fixme: We should check that the correct card has been inserted + if (!agent_scd_getattr ("SIG-COUNTER",&info)) + return info.sig_counter; + else + return 0; #else (void)pk; return 0; Modified: trunk/scd/apdu.c =================================================================== --- trunk/scd/apdu.c 2010-11-16 10:38:13 UTC (rev 5483) +++ trunk/scd/apdu.c 2010-11-17 13:21:24 UTC (rev 5484) @@ -1,5 +1,5 @@ /* apdu.c - ISO 7816 APDU functions and low level I/O - * Copyright (C) 2003, 2004, 2008, 2009 Free Software Foundation, Inc. + * Copyright (C) 2003, 2004, 2008, 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -165,7 +165,11 @@ #define PCSC_PROTOCOL_T0 1 #define PCSC_PROTOCOL_T1 2 -#define PCSC_PROTOCOL_RAW 4 +#ifdef HAVE_W32_SYSTEM +# define PCSC_PROTOCOL_RAW 0x00010000 /* The active protocol. */ +#else +# define PCSC_PROTOCOL_RAW 4 +#endif #define PCSC_SHARE_EXCLUSIVE 1 #define PCSC_SHARE_SHARED 2 @@ -176,13 +180,23 @@ #define PCSC_UNPOWER_CARD 2 #define PCSC_EJECT_CARD 3 -#define PCSC_UNKNOWN 0x0001 -#define PCSC_ABSENT 0x0002 /* Card is absent. */ -#define PCSC_PRESENT 0x0004 /* Card is present. */ -#define PCSC_SWALLOWED 0x0008 /* Card is present and electrical connected. */ -#define PCSC_POWERED 0x0010 /* Card is powered. */ -#define PCSC_NEGOTIABLE 0x0020 /* Card is awaiting PTS. */ -#define PCSC_SPECIFIC 0x0040 /* Card is ready for use. */ +#ifdef HAVE_W32_SYSTEM +# define PCSC_UNKNOWN 0x0000 /* The driver is not aware of the status. */ +# define PCSC_ABSENT 0x0001 /* Card is absent. */ +# define PCSC_PRESENT 0x0002 /* Card is present. */ +# define PCSC_SWALLOWED 0x0003 /* Card is present and electrical connected. */ +# define PCSC_POWERED 0x0004 /* Card is powered. */ +# define PCSC_NEGOTIABLE 0x0005 /* Card is awaiting PTS. */ +# define PCSC_SPECIFIC 0x0006 /* Card is ready for use. */ +#else +# define PCSC_UNKNOWN 0x0001 +# define PCSC_ABSENT 0x0002 /* Card is absent. */ +# define PCSC_PRESENT 0x0004 /* Card is present. */ +# define PCSC_SWALLOWED 0x0008 /* Card is present and electrical connected. */ +# define PCSC_POWERED 0x0010 /* Card is powered. */ +# define PCSC_NEGOTIABLE 0x0020 /* Card is awaiting PTS. */ +# define PCSC_SPECIFIC 0x0040 /* Card is ready for use. */ +#endif #define PCSC_STATE_UNAWARE 0x0000 /* Want status. */ #define PCSC_STATE_IGNORE 0x0001 /* Ignore this reader. */ @@ -195,6 +209,9 @@ #define PCSC_STATE_EXCLUSIVE 0x0080 /* Exclusive Mode. */ #define PCSC_STATE_INUSE 0x0100 /* Shared mode. */ #define PCSC_STATE_MUTE 0x0200 /* Unresponsive card. */ +#ifdef HAVE_W32_SYSTEM +# define PCSC_STATE_UNPOWERED 0x0400 /* Card not powerred up. */ +#endif /* Some PC/SC error codes. */ #define PCSC_E_CANCELLED 0x80100002 From cvs at cvs.gnupg.org Wed Nov 17 17:32:12 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 17 Nov 2010 17:32:12 +0100 Subject: [svn] GnuPG - r5485 - trunk/tools Message-ID: Author: marcus Date: 2010-11-17 17:32:11 +0100 (Wed, 17 Nov 2010) New Revision: 5485 Modified: trunk/tools/ChangeLog trunk/tools/gpgconf.c Log: 2010-11-17 Marcus Brinkmann * gogconf.c: Revert accidental debug output commit. Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2010-11-17 13:21:24 UTC (rev 5484) +++ trunk/tools/ChangeLog 2010-11-17 16:32:11 UTC (rev 5485) @@ -1,3 +1,7 @@ +2010-11-17 Marcus Brinkmann + + * gogconf.c: Revert accidental debug output commit. + 2010-10-27 Werner Koch * symcryptrun.c (confucius_mktmpdir): Use TMPDIR. Modified: trunk/tools/gpgconf.c =================================================================== --- trunk/tools/gpgconf.c 2010-11-17 13:21:24 UTC (rev 5484) +++ trunk/tools/gpgconf.c 2010-11-17 16:32:11 UTC (rev 5485) @@ -189,9 +189,6 @@ if (log_get_errorcount (0)) exit (2); - - fprintf (stderr, "My error: %d (%s)\n", GPG_ERR_ENOENT, - gpg_strerror (GPG_ERR_ENOENT)); fname = argc ? *argv : NULL; From cvs at cvs.gnupg.org Wed Nov 17 17:49:53 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 17 Nov 2010 17:49:53 +0100 Subject: [svn] assuan - r400 - trunk/src Message-ID: Author: marcus Date: 2010-11-17 17:49:53 +0100 (Wed, 17 Nov 2010) New Revision: 400 Modified: trunk/src/ChangeLog trunk/src/vasprintf.c Log: 2010-11-17 Marcus Brinkmann * vasprintf.c (int_vasprintf) [HAVE_W32CE_SYSTEM && _MSC_VER]: Just use a fixed size buffer, as va_copy is not easy to fake. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-17 02:08:13 UTC (rev 399) +++ trunk/src/ChangeLog 2010-11-17 16:49:53 UTC (rev 400) @@ -1,5 +1,8 @@ 2010-11-17 Marcus Brinkmann + * vasprintf.c (int_vasprintf) [HAVE_W32CE_SYSTEM && _MSC_VER]: + Just use a fixed size buffer, as va_copy is not easy to fake. + * gpgcedev.c (struct pipeimpl_s): Add member monitor_rvid. (struct monitor_s, monitor_t): New types. (monitor_table, monitor_table_size): New static variables. Modified: trunk/src/vasprintf.c =================================================================== --- trunk/src/vasprintf.c 2010-11-17 02:08:13 UTC (rev 399) +++ trunk/src/vasprintf.c 2010-11-17 16:49:53 UTC (rev 400) @@ -51,6 +51,19 @@ const char *format; va_list *args; { +#if defined(HAVE_W32CE_SYSTEM) && defined(_MSC_VER) + /* No va_copy and the replacement above doesn't work. */ +#define MAX_STRLEN 256 + *result = malloc (MAX_STRLEN); + if (*result != NULL) + { + int res = _vsnprintf (*result, MAX_STRLEN, format, *args); + (*result)[MAX_STRLEN - 1] = '\0'; + return res; + } + else + return 0; +#else const char *p = format; /* Add one to make sure that it is never zero, which might cause malloc to return NULL. */ @@ -133,6 +146,7 @@ return vsprintf (*result, format, *args); else return 0; +#endif } From cvs at cvs.gnupg.org Fri Nov 19 17:06:44 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 19 Nov 2010 17:06:44 +0100 Subject: [svn] gpgme - r1508 - trunk/src Message-ID: Author: marcus Date: 2010-11-19 17:06:43 +0100 (Fri, 19 Nov 2010) New Revision: 1508 Modified: trunk/src/ChangeLog trunk/src/engine-gpgconf.c Log: 2010-11-19 Marcus Brinkmann * engine-gpgconf.c (_gpgme_conf_opt_change): Support self-assignment. Requested by Marc Mutz. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-17 02:11:05 UTC (rev 1507) +++ trunk/src/ChangeLog 2010-11-19 16:06:43 UTC (rev 1508) @@ -1,3 +1,8 @@ +2010-11-19 Marcus Brinkmann + + * engine-gpgconf.c (_gpgme_conf_opt_change): Support + self-assignment. Requested by Marc Mutz. + 2010-11-17 Marcus Brinkmann * vasprintf.c (int_vasprintf) [HAVE_W32CE_SYSTEM]: Just use a Modified: trunk/src/engine-gpgconf.c =================================================================== --- trunk/src/engine-gpgconf.c 2010-11-17 02:11:05 UTC (rev 1507) +++ trunk/src/engine-gpgconf.c 2010-11-19 16:06:43 UTC (rev 1508) @@ -618,17 +618,22 @@ gpgme_error_t _gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg) { - if (opt->new_value) - release_arg (opt->new_value, opt->alt_type); - if (reset) { - opt->new_value = NULL; + if (opt->new_value) + release_arg (opt->new_value, opt->alt_type); + opt->new_value = NULL; opt->change_value = 0; } else { - opt->new_value = arg; + /* Support self-assignment, for example for adding an item to an + existing list. */ + if (opt->new_value && arg != opt->new_value) + { + release_arg (opt->new_value, opt->alt_type); + opt->new_value = arg; + } opt->change_value = 1; } return 0; From cvs at cvs.gnupg.org Tue Nov 23 10:46:53 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 23 Nov 2010 10:46:53 +0100 Subject: [svn] gpgme - r1509 - trunk/src Message-ID: Author: marcus Date: 2010-11-23 10:46:52 +0100 (Tue, 23 Nov 2010) New Revision: 1509 Modified: trunk/src/ChangeLog trunk/src/engine-gpgconf.c trunk/src/gpgconf.c trunk/src/gpgme.h.in Log: 2010-11-23 Marcus Brinkmann * gpgme.h.in (gpgme_conf_arg_new): Make VALUE arg const void *. * gpgconf.c (_gpgme_conf_arg_new): Likewise. (gpgme_conf_arg_new): Likewise. * engine-gpgconf.c (_gpgme_conf_arg_new): Likewise. (gpgconf_write): Remove debug hack. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-19 16:06:43 UTC (rev 1508) +++ trunk/src/ChangeLog 2010-11-23 09:46:52 UTC (rev 1509) @@ -1,3 +1,11 @@ +2010-11-23 Marcus Brinkmann + + * gpgme.h.in (gpgme_conf_arg_new): Make VALUE arg const void *. + * gpgconf.c (_gpgme_conf_arg_new): Likewise. + (gpgme_conf_arg_new): Likewise. + * engine-gpgconf.c (_gpgme_conf_arg_new): Likewise. + (gpgconf_write): Remove debug hack. + 2010-11-19 Marcus Brinkmann * engine-gpgconf.c (_gpgme_conf_opt_change): Support Modified: trunk/src/engine-gpgconf.c =================================================================== --- trunk/src/engine-gpgconf.c 2010-11-19 16:06:43 UTC (rev 1508) +++ trunk/src/engine-gpgconf.c 2010-11-23 09:46:52 UTC (rev 1509) @@ -537,7 +537,7 @@ gpgme_error_t _gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, - gpgme_conf_type_t type, void *value) + gpgme_conf_type_t type, const void *value) { gpgme_conf_arg_t arg; @@ -660,7 +660,6 @@ /* _gpgme_engine_new guarantees that this is not NULL. */ argv[0] = gpgconf->file_name; - argv[0] = "/nowhere/path-needs-to-be-fixed/gpgconf"; if (_gpgme_io_pipe (rp, 0) < 0) return gpg_error_from_syserror (); Modified: trunk/src/gpgconf.c =================================================================== --- trunk/src/gpgconf.c 2010-11-19 16:06:43 UTC (rev 1508) +++ trunk/src/gpgconf.c 2010-11-23 09:46:52 UTC (rev 1509) @@ -30,7 +30,7 @@ #ifdef ENABLE_GPGCONF /* engine-gpgconf.c. */ gpgme_error_t _gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, - gpgme_conf_type_t type, void *value); + gpgme_conf_type_t type, const void *value); void _gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type); gpgme_error_t _gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg); @@ -44,7 +44,7 @@ /* Allocate a new gpgme_conf_arg_t. */ gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, - gpgme_conf_type_t type, void *value) + gpgme_conf_type_t type, const void *value) { #ifdef ENABLE_GPGCONF return _gpgme_conf_arg_new (arg_p, type, value); Modified: trunk/src/gpgme.h.in =================================================================== --- trunk/src/gpgme.h.in 2010-11-19 16:06:43 UTC (rev 1508) +++ trunk/src/gpgme.h.in 2010-11-23 09:46:52 UTC (rev 1509) @@ -1999,7 +1999,7 @@ to the string. Else, it should point to an unsigned or signed integer respectively. */ gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, - gpgme_conf_type_t type, void *value); + gpgme_conf_type_t type, const void *value); /* This also releases all chained argument structures! */ void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type); From cvs at cvs.gnupg.org Tue Nov 23 11:48:00 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 23 Nov 2010 11:48:00 +0100 Subject: [svn] gpgme - r1510 - trunk/src Message-ID: Author: marcus Date: 2010-11-23 11:47:59 +0100 (Tue, 23 Nov 2010) New Revision: 1510 Modified: trunk/src/ChangeLog trunk/src/w32-io.c Log: 2010-11-23 Marcus Brinkmann * w32-io.c (create_reader, create_writer): Use small stack size on Windows CE. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-11-23 09:46:52 UTC (rev 1509) +++ trunk/src/ChangeLog 2010-11-23 10:47:59 UTC (rev 1510) @@ -1,5 +1,10 @@ 2010-11-23 Marcus Brinkmann + * w32-io.c (create_reader, create_writer): Use small stack size on + Windows CE. + +2010-11-23 Marcus Brinkmann + * gpgme.h.in (gpgme_conf_arg_new): Make VALUE arg const void *. * gpgconf.c (_gpgme_conf_arg_new): Likewise. (gpgme_conf_arg_new): Likewise. Modified: trunk/src/w32-io.c =================================================================== --- trunk/src/w32-io.c 2010-11-23 09:46:52 UTC (rev 1509) +++ trunk/src/w32-io.c 2010-11-23 10:47:59 UTC (rev 1510) @@ -464,7 +464,13 @@ ctx->have_data_ev = set_synchronize (ctx->have_data_ev); INIT_LOCK (ctx->mutex); +#ifdef HAVE_W32CE_SYSTEM + ctx->thread_hd = CreateThread (&sec_attr, 64 * 1024, reader, ctx, + STACK_SIZE_PARAM_IS_A_RESERVATION, &tid); +#else ctx->thread_hd = CreateThread (&sec_attr, 0, reader, ctx, 0, &tid); +#endif + if (!ctx->thread_hd) { TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ()); @@ -824,7 +830,13 @@ ctx->is_empty = set_synchronize (ctx->is_empty); INIT_LOCK (ctx->mutex); +#ifdef HAVE_W32CE_SYSTEM + ctx->thread_hd = CreateThread (&sec_attr, 64 * 1024, writer, ctx, + STACK_SIZE_PARAM_IS_A_RESERVATION, &tid); +#else ctx->thread_hd = CreateThread (&sec_attr, 0, writer, ctx, 0, &tid ); +#endif + if (!ctx->thread_hd) { TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ()); From cvs at cvs.gnupg.org Tue Nov 23 19:46:44 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 23 Nov 2010 19:46:44 +0100 Subject: [svn] GnuPG - r5486 - in trunk: . agent am common dirmngr g10 sm tools Message-ID: Author: wk Date: 2010-11-23 19:46:41 +0100 (Tue, 23 Nov 2010) New Revision: 5486 Modified: trunk/ChangeLog trunk/NEWS trunk/agent/ChangeLog trunk/agent/Makefile.am trunk/am/cmacros.am trunk/common/ChangeLog trunk/common/asshelp.c trunk/dirmngr/ChangeLog trunk/dirmngr/Makefile.am trunk/g10/ChangeLog trunk/g10/Makefile.am trunk/g10/decrypt.c trunk/g10/options.h trunk/g10/plaintext.c trunk/sm/ChangeLog trunk/sm/Makefile.am trunk/tools/ChangeLog trunk/tools/Makefile.am Log: Change stack size for Wince. Allow for a longer agent atartup under wince. Print gpg output via estream. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/ChangeLog 2010-11-23 18:46:41 UTC (rev 5486) @@ -1,3 +1,8 @@ +2010-11-23 Werner Koch + + * am/cmacros.am (extra_bin_ldflags): New. For W32CE set the stack + size to 256k. + 2010-11-17 Werner Koch * configure.ac (ENABLE_CARD_SUPPORT): Define. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/agent/ChangeLog 2010-11-23 18:46:41 UTC (rev 5486) @@ -1,3 +1,7 @@ +2010-11-23 Werner Koch + + * Makefile.am (gpg_agent_LDFLAGS): Add extra_bin_ldflags. + 2010-11-11 Werner Koch * agent.h (opt): Add field SIGUSR2_ENABLED. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/common/ChangeLog 2010-11-23 18:46:41 UTC (rev 5486) @@ -1,3 +1,10 @@ +2010-11-23 Werner Koch + + * asshelp.c (SECS_TO_WAIT_FOR_AGENT, SECS_TO_WAIT_FOR_DIRMNGR): + Use these constants. For W32CE increase them to 30 seconds. + (start_new_gpg_agent): Print time to startup agent. + (start_new_dirmngr): Ditto. + 2010-11-04 Werner Koch * logging.c (do_logv) [W32]: Don't set a default log stream if the Modified: trunk/dirmngr/ChangeLog =================================================================== --- trunk/dirmngr/ChangeLog 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/dirmngr/ChangeLog 2010-11-23 18:46:41 UTC (rev 5486) @@ -1,3 +1,8 @@ +2010-11-23 Werner Koch + + * Makefile.am (dirmngr_LDFLAGS): Add extra_bin_ldflags. + (dirmngr_client_LDFLAGS): Ditto. + 2010-10-21 Werner Koch * dirmngr.c (main): Changed faked system time warning Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/g10/ChangeLog 2010-11-23 18:46:41 UTC (rev 5486) @@ -1,3 +1,13 @@ +2010-11-23 Werner Koch + + * Makefile.am (gpg2_LDFLAGS, gpgv2_LDFLAGS): Add extra_bin_ldflags. + + * plaintext.c (handle_plaintext): Change to use estream. + s/rc/err/. Replace some xmalloc by xtrymalloc. Use more + gpg_strerror. + * options.h (struct): Change type of OUTFP to estream_t. + * decrypt.c (decrypt_message_fd): Adjust accordingly. + 2010-11-17 Werner Koch * keyedit.c (find_pk_from_sknode): Remove. Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/sm/ChangeLog 2010-11-23 18:46:41 UTC (rev 5486) @@ -1,3 +1,7 @@ +2010-11-23 Werner Koch + + * Makefile.am (gpgsm_LDADD): Add extra_bin_ldflags. + 2010-10-08 Werner Koch * gpgsm.c: Add option --with-keygrip. Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/tools/ChangeLog 2010-11-23 18:46:41 UTC (rev 5486) @@ -1,3 +1,7 @@ +2010-11-23 Werner Koch + + * Makefile.am (gpgconf_LDFLAGS): Add extra_bin_ldflags. + 2010-11-17 Marcus Brinkmann * gogconf.c: Revert accidental debug output commit. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/NEWS 2010-11-23 18:46:41 UTC (rev 5486) @@ -4,7 +4,7 @@ * TMPDIR is now also honored when creating a socket using --no-standard-socket and with symcryptrun's temp files. - * Fixed a bug where Scdaemon sends a signal to Gpg-agent running in + * Fixed a bug where SCdaemon sends a signal to Gpg-agent running in non-daemon mode. Modified: trunk/agent/Makefile.am =================================================================== --- trunk/agent/Makefile.am 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/agent/Makefile.am 2010-11-23 18:46:41 UTC (rev 5486) @@ -75,7 +75,7 @@ gpg_agent_LDADD = $(commonpth_libs) \ $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \ $(GPG_ERROR_LIBS) $(LIBINTL) $(NETLIBS) $(LIBICONV) -gpg_agent_LDFLAGS = $(gpg_agent_res_ldflags) +gpg_agent_LDFLAGS = $(extra_bin_ldflags) $(gpg_agent_res_ldflags) gpg_agent_DEPENDENCIES = $(gpg_agent_res_deps) gpg_protect_tool_SOURCES = \ Modified: trunk/am/cmacros.am =================================================================== --- trunk/am/cmacros.am 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/am/cmacros.am 2010-11-23 18:46:41 UTC (rev 5486) @@ -54,11 +54,15 @@ # Under Windows we use LockFileEx. WindowsCE provides this only on # the WindowsMobile 6 platform and thus we need to use the coredll6 -# import library. +# import library. We also want to use a stacksize of 256k instead of +# the 2MB which is the default with cegcc. 256k is the largest stack +# we use with pth. if HAVE_W32CE_SYSTEM extra_sys_libs = -lcoredll6 +extra_bin_ldflags = -Wl,--stack=0x40000 else extra_sys_libs = +extra_bin_ldflags = endif Modified: trunk/common/asshelp.c =================================================================== --- trunk/common/asshelp.c 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/common/asshelp.c 2010-11-23 18:46:41 UTC (rev 5486) @@ -42,6 +42,15 @@ # define lock_spawn_t dotlock_t #endif +/* The time we wait until the agent or the dirmngr are ready for + operation after we started them before giving up. */ +#ifdef HAVE_W32CE_SYSTEM +# define SECS_TO_WAIT_FOR_AGENT 30 +# define SECS_TO_WAIT_FOR_DIRMNGR 30 +#else +# define SECS_TO_WAIT_FOR_AGENT 5 +# define SECS_TO_WAIT_FOR_DIRMNGR 5 +#endif /* A bitfield that specifies the assuan categories to log. This is identical to the default log handler of libassuan. We need to do @@ -335,6 +344,7 @@ gpg_error_t err = 0; char *infostr, *p; assuan_context_t ctx; + int did_success_msg = 0; *r_ctx = NULL; @@ -423,16 +433,19 @@ if (verbose) log_info (_("waiting %d seconds for the agent " - "to come up\n"), 5); - for (i=0; i < 5; i++) + "to come up\n"), SECS_TO_WAIT_FOR_AGENT); + for (i=0; i < SECS_TO_WAIT_FOR_AGENT; i++) { gnupg_sleep (1); err = assuan_socket_connect (ctx, sockname, 0, 0); if (!err) { - if (verbose && !debug) - log_info (_("connection to agent" - " established\n")); + if (verbose) + { + log_info (_("connection to agent " + "established (%ds)\n"), i+1); + did_success_msg = 1; + } break; } } @@ -517,7 +530,7 @@ return gpg_err_make (errsource, GPG_ERR_NO_AGENT); } - if (debug) + if (debug && !did_success_msg) log_debug (_("connection to agent established\n")); err = assuan_transact (ctx, "RESET", @@ -552,6 +565,7 @@ gpg_error_t err; assuan_context_t ctx; const char *sockname; + int did_success_msg = 0; *r_ctx = NULL; @@ -612,16 +626,19 @@ if (verbose) log_info (_("waiting %d seconds for the dirmngr to come up\n"), - 5); - for (i=0; i < 5; i++) + SECS_TO_WAIT_FOR_DIRMNGR); + for (i=0; i < SECS_TO_WAIT_FOR_DIRMNGR; i++) { gnupg_sleep (1); err = assuan_socket_connect (ctx, sockname, 0, 0); if (!err) { - if (verbose && !debug) - log_info (_("connection to the dirmngr" - " established\n")); + if (verbose) + { + log_info (_("connection to the dirmngr" + " established (%ds)\n"), i+1); + did_success_msg = 1; + } break; } } @@ -646,7 +663,7 @@ return gpg_err_make (errsource, GPG_ERR_NO_DIRMNGR); } - if (debug) + if (debug && !did_success_msg) log_debug (_("connection to the dirmngr established\n")); *r_ctx = ctx; Modified: trunk/dirmngr/Makefile.am =================================================================== --- trunk/dirmngr/Makefile.am 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/dirmngr/Makefile.am 2010-11-23 18:46:41 UTC (rev 5486) @@ -63,8 +63,8 @@ if !USE_LDAPWRAPPER dirmngr_LDADD += $(LDAPLIBS) endif +dirmngr_LDFLAGS = $(extra_bin_ldflags) - if USE_LDAPWRAPPER dirmngr_ldap_SOURCES = dirmngr_ldap.c $(ldap_url) dirmngr_ldap_CFLAGS = $(GPG_ERROR_CFLAGS) @@ -76,7 +76,9 @@ dirmngr_client_SOURCES = dirmngr-client.c dirmngr_client_LDADD = $(libcommon) no-libgcrypt.o \ ../gl/libgnu.a $(LIBASSUAN_LIBS) \ - $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) + $(GPG_ERROR_LIBS) $(LIBINTL) \ + $(LIBICONV) +dirmngr_client_LDFLAGS = $(extra_bin_ldflags) no-libgcrypt.c : $(top_srcdir)/tools/no-libgcrypt.c Modified: trunk/g10/Makefile.am =================================================================== --- trunk/g10/Makefile.am 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/g10/Makefile.am 2010-11-23 18:46:41 UTC (rev 5486) @@ -123,8 +123,10 @@ $(LIBINTL) $(CAPLIBS) $(NETLIBS) gpg2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ $(LIBICONV) $(extra_sys_libs) +gpg2_LDFLAGS = $(extra_bin_ldflags) gpgv2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ $(LIBICONV) $(extra_sys_libs) +gpgv2_LDFLAGS = $(extra_bin_ldflags) t_common_ldadd = module_tests = t-rmd160 Modified: trunk/g10/decrypt.c =================================================================== --- trunk/g10/decrypt.c 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/g10/decrypt.c 2010-11-23 18:46:41 UTC (rev 5486) @@ -135,7 +135,7 @@ #warning Need to fix this if we want to use g13 opt.outfp = NULL; #else - opt.outfp = fdopen (dup (output_fd), "wb"); + opt.outfp = es_fdopen_nc (output_fd, "wb"); #endif if (!opt.outfp) { @@ -161,7 +161,7 @@ err = proc_encryption_packets (ctrl, NULL, fp ); iobuf_close (fp); - fclose (opt.outfp); + es_fclose (opt.outfp); opt.outfp = NULL; release_armor_context (afx); release_progress_context (pfx); Modified: trunk/g10/options.h =================================================================== --- trunk/g10/options.h 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/g10/options.h 2010-11-23 18:46:41 UTC (rev 5486) @@ -43,7 +43,7 @@ unsigned debug; int armor; char *outfile; - FILE *outfp; /* Hack, sometimes used in place of outfile. */ + estream_t outfp; /* Hack, sometimes used in place of outfile. */ off_t max_output; int dry_run; int list_only; Modified: trunk/g10/plaintext.c =================================================================== --- trunk/g10/plaintext.c 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/g10/plaintext.c 2010-11-23 18:46:41 UTC (rev 5486) @@ -49,9 +49,9 @@ int nooutput, int clearsig) { char *fname = NULL; - FILE *fp = NULL; + estream_t fp = NULL; static off_t count = 0; - int rc = 0; + int err = 0; int c; int convert = (pt->mode == 't' || pt->mode == 'u'); #ifdef __riscos__ @@ -69,7 +69,7 @@ output will be written to it. This is to make sure that no not-yet-flushed stuff will be written after the plaintext status message. */ - fflush (stdout); + es_fflush (es_stdout); snprintf (status, sizeof status, "%X %lu ", (byte) pt->mode, (ulong) pt->timestamp); @@ -78,7 +78,7 @@ if (!pt->is_partial) { - sprintf (status, "%lu", (ulong) pt->len); + snprintf (status, sizeof status, "%lu", (ulong) pt->len); write_status_text (STATUS_PLAINTEXT_LENGTH, status); } } @@ -88,11 +88,21 @@ ; else if (opt.outfp) { - fname = xstrdup ("[FP]"); + fname = xtrystrdup ("[FP]"); + if (!fname) + { + err = gpg_error_from_syserror (); + goto leave; + } } else if (opt.outfile) { - fname = xstrdup (opt.outfile); + fname = xtrystrdup (opt.outfile); + if (!fname) + { + err = gpg_error_from_syserror (); + goto leave; + } } else if (pt->namelen == 8 && !memcmp (pt->name, "_CONSOLE", 8)) { @@ -106,7 +116,7 @@ fname = ask_outfile_name (pt->name, pt->namelen); if (!fname) { - rc = gpg_error (GPG_ERR_GENERAL); /* Can't create file. */ + err = gpg_error (GPG_ERR_GENERAL); /* Can't create file. */ goto leave; } } @@ -118,17 +128,13 @@ else if (opt.outfp) { fp = opt.outfp; -#ifdef HAVE_DOSISH_SYSTEM - setmode (fileno (fp), O_BINARY); -#endif + es_set_binary (fp); } else if (iobuf_is_pipe_filename (fname) || !*fname) { /* No filename or "-" given; write to stdout. */ - fp = stdout; -#ifdef HAVE_DOSISH_SYSTEM - setmode (fileno (fp), O_BINARY); -#endif + fp = es_stdout; + es_set_binary (fp); } else { @@ -139,7 +145,7 @@ { xfree (tmp); /* FIXME: Below used to be G10ERR_CREATE_FILE */ - rc = gpg_error (GPG_ERR_GENERAL); + err = gpg_error (GPG_ERR_GENERAL); goto leave; } xfree (fname); @@ -148,10 +154,10 @@ } #ifndef __riscos__ - if (opt.outfp && is_secured_file (fileno (opt.outfp))) + if (opt.outfp && is_secured_file (es_fileno (opt.outfp))) { - rc = gpg_error (GPG_ERR_EPERM); - log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (rc)); + err = gpg_error (GPG_ERR_EPERM); + log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err)); goto leave; } else if (fp || nooutput) @@ -159,14 +165,14 @@ else if (is_secured_filename (fname)) { gpg_err_set_errno (EPERM); - rc = gpg_error_from_syserror (); - log_error (_("error creating `%s': %s\n"), fname, strerror (errno)); + err = gpg_error_from_syserror (); + log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err)); goto leave; } - else if (!(fp = fopen (fname, "wb"))) + else if (!(fp = es_fopen (fname, "wb"))) { - rc = gpg_error_from_syserror (); - log_error (_("error creating `%s': %s\n"), fname, strerror (errno)); + err = gpg_error_from_syserror (); + log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err)); goto leave; } #else /* __riscos__ */ @@ -182,11 +188,15 @@ ; else { + /* Note: riscos stuff is not expected to wrok anymore. If we + want to port it again to riscos we should do most of the suff + in estream. FIXME: Consider to remove all riscos special + cases. */ fp = fopen (fname, "wb"); if (!fp) { - log_error (_("error creating `%s': %s\n"), fname, strerror (errno)); - rc = G10ERR_CREATE_FILE; + log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err)); + err = G10ERR_CREATE_FILE; if (errno == 106) log_info ("Do output file and input file have the same name?\n"); goto leave; @@ -210,7 +220,7 @@ if (clearsig) { log_error ("clearsig encountered while not expected\n"); - rc = G10ERR_UNEXPECTED; + err = gpg_error (GPG_ERR_UNEXPECTED); goto leave; } @@ -220,7 +230,7 @@ { if ((c = iobuf_get (pt->buf)) == -1) { - rc = gpg_error_from_syserror (); + err = gpg_error_from_syserror (); log_error ("problem reading source (%u bytes remaining)\n", (unsigned) pt->len); goto leave; @@ -237,17 +247,17 @@ { log_error ("error writing to `%s': %s\n", fname, "exceeded --max-output limit\n"); - rc = gpg_error (GPG_ERR_TOO_LARGE); + err = gpg_error (GPG_ERR_TOO_LARGE); goto leave; } - else if (putc (c, fp) == EOF) + else if (es_putc (c, fp) == EOF) { - if (ferror (fp)) - rc = gpg_error_from_syserror (); + if (es_ferror (fp)) + err = gpg_error_from_syserror (); else - rc = gpg_error (GPG_ERR_EOF); + err = gpg_error (GPG_ERR_EOF); log_error ("error writing to `%s': %s\n", - fname, strerror (errno)); + fname, gpg_strerror (err)); goto leave; } } @@ -262,7 +272,7 @@ len = iobuf_read (pt->buf, buffer, len); if (len == -1) { - rc = gpg_error_from_syserror (); + err = gpg_error_from_syserror (); log_error ("problem reading source (%u bytes remaining)\n", (unsigned) pt->len); xfree (buffer); @@ -276,15 +286,15 @@ { log_error ("error writing to `%s': %s\n", fname, "exceeded --max-output limit\n"); - rc = gpg_error (GPG_ERR_TOO_LARGE); + err = gpg_error (GPG_ERR_TOO_LARGE); xfree (buffer); goto leave; } - else if (fwrite (buffer, 1, len, fp) != len) + else if (es_fwrite (buffer, 1, len, fp) != len) { - rc = gpg_error_from_syserror (); + err = gpg_error_from_syserror (); log_error ("error writing to `%s': %s\n", - fname, strerror (errno)); + fname, gpg_strerror (err)); xfree (buffer); goto leave; } @@ -312,17 +322,17 @@ { log_error ("Error writing to `%s': %s\n", fname, "exceeded --max-output limit\n"); - rc = gpg_error (GPG_ERR_TOO_LARGE); + err = gpg_error (GPG_ERR_TOO_LARGE); goto leave; } - else if (putc (c, fp) == EOF) + else if (es_putc (c, fp) == EOF) { - if (ferror (fp)) - rc = gpg_error_from_syserror (); + if (es_ferror (fp)) + err = gpg_error_from_syserror (); else - rc = gpg_error (GPG_ERR_EOF); + err = gpg_error (GPG_ERR_EOF); log_error ("error writing to `%s': %s\n", - fname, strerror (errno)); + fname, gpg_strerror (err)); goto leave; } } @@ -330,9 +340,16 @@ } else { /* binary mode */ - byte *buffer = xmalloc (32768); + byte *buffer; int eof_seen = 0; + buffer = xtrymalloc (32768); + if (!buffer) + { + err = gpg_error_from_syserror (); + goto leave; + } + while (!eof_seen) { /* Why do we check for len < 32768: @@ -354,16 +371,15 @@ { log_error ("error writing to `%s': %s\n", fname, "exceeded --max-output limit\n"); - rc = gpg_error (GPG_ERR_TOO_LARGE); + err = gpg_error (GPG_ERR_TOO_LARGE); xfree (buffer); goto leave; } - else if (fwrite (buffer, 1, len, fp) != len) + else if (es_fwrite (buffer, 1, len, fp) != len) { - rc = (errno ? gpg_error_from_syserror () - : gpg_error (GPG_ERR_INTERNAL)); + err = gpg_error_from_syserror (); log_error ("error writing to `%s': %s\n", - fname, strerror (errno)); + fname, gpg_strerror (err)); xfree (buffer); goto leave; } @@ -385,15 +401,14 @@ { log_error ("error writing to `%s': %s\n", fname, "exceeded --max-output limit\n"); - rc = gpg_error (GPG_ERR_TOO_LARGE); + err = gpg_error (GPG_ERR_TOO_LARGE); goto leave; } - else if (putc (c, fp) == EOF) + else if (es_putc (c, fp) == EOF) { - rc = (errno ? gpg_error_from_syserror () - : gpg_error (GPG_ERR_INTERNAL)); + err = gpg_error_from_syserror (); log_error ("error writing to `%s': %s\n", - fname, strerror (errno)); + fname, gpg_strerror (err)); goto leave; } } @@ -434,11 +449,10 @@ pt->buf = NULL; } - if (fp && fp != stdout && fp != opt.outfp && fclose (fp)) + if (fp && fp != es_stdout && fp != opt.outfp && es_fclose (fp)) { - rc = (errno ? gpg_error_from_syserror () - : gpg_error (GPG_ERR_INTERNAL)); - log_error ("error closing `%s': %s\n", fname, strerror (errno)); + err = gpg_error_from_syserror (); + log_error ("error closing `%s': %s\n", fname, gpg_strerror (err)); fp = NULL; goto leave; } @@ -448,20 +462,21 @@ /* Make sure that stdout gets flushed after the plaintext has been handled. This is for extra security as we do a flush anyway before checking the signature. */ - if (fflush (stdout)) + if (es_fflush (es_stdout)) { /* We need to check the return code to detect errors like disk full for short plaintexts. See bug#1207. Checking return values is a good idea in any case. */ - if (!rc) - rc = gpg_error_from_syserror (); - log_error ("error flushing `%s': %s\n", "[stdout]", strerror (errno)); + if (!err) + err = gpg_error_from_syserror (); + log_error ("error flushing `%s': %s\n", "[stdout]", + gpg_strerror (err)); } - if (fp && fp != stdout && fp != opt.outfp) - fclose (fp); + if (fp && fp != es_stdout && fp != opt.outfp) + es_fclose (fp); xfree (fname); - return rc; + return err; } Modified: trunk/sm/Makefile.am =================================================================== --- trunk/sm/Makefile.am 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/sm/Makefile.am 2010-11-23 18:46:41 UTC (rev 5486) @@ -59,6 +59,7 @@ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) \ $(GPG_ERROR_LIBS) $(LIBREADLINE) $(LIBINTL) $(ZLIBS) \ $(LIBICONV) $(extra_sys_libs) +gpgsm_LDFLAGS = $(extra_bin_ldflags) # Make sure that all libs are build before we use them. This is # important for things like make -j2. Modified: trunk/tools/Makefile.am =================================================================== --- trunk/tools/Makefile.am 2010-11-17 16:32:11 UTC (rev 5485) +++ trunk/tools/Makefile.am 2010-11-23 18:46:41 UTC (rev 5486) @@ -96,6 +96,7 @@ gpgconf_LDADD = $(maybe_commonpth_libs) $(opt_libassuan_libs) \ $(LIBINTL) $(GPG_ERROR_LIBS) $(PTH_LIBS) $(NETLIBS) \ $(LIBICONV) $(W32SOCKLIBS) +gpgconf_LDFLAGS = $(extra_bin_ldflags) gpgparsemail_SOURCES = gpgparsemail.c rfc822parse.c rfc822parse.h gpgparsemail_LDADD = From cvs at cvs.gnupg.org Tue Nov 23 19:51:43 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 23 Nov 2010 19:51:43 +0100 Subject: [svn] GnuPG - r5487 - trunk/po Message-ID: Author: wk Date: 2010-11-23 19:51:43 +0100 (Tue, 23 Nov 2010) New Revision: 5487 Modified: trunk/po/de.po Log: Fix two fuzzies Modified: trunk/po/de.po [not shown] From cvs at cvs.gnupg.org Fri Nov 26 10:42:57 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 26 Nov 2010 10:42:57 +0100 Subject: [svn] GnuPG - r5488 - in trunk: agent common sm Message-ID: Author: wk Date: 2010-11-26 10:42:56 +0100 (Fri, 26 Nov 2010) New Revision: 5488 Modified: trunk/agent/ChangeLog trunk/agent/gpg-agent.c trunk/common/ChangeLog trunk/common/asshelp.c trunk/sm/ChangeLog trunk/sm/base64.c trunk/sm/certreqgen.c trunk/sm/decrypt.c trunk/sm/encrypt.c trunk/sm/export.c trunk/sm/gpgsm.h trunk/sm/sign.c trunk/sm/verify.c Log: Remove superfluous parameter. Make self-check interval larger Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/agent/ChangeLog 2010-11-26 09:42:56 UTC (rev 5488) @@ -1,3 +1,7 @@ +2010-11-26 Werner Koch + + * gpg-agent.c (CHECK_OWN_SOCKET_INTERVAL): New. + 2010-11-23 Werner Koch * Makefile.am (gpg_agent_LDFLAGS): Add extra_bin_ldflags. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/common/ChangeLog 2010-11-26 09:42:56 UTC (rev 5488) @@ -1,3 +1,8 @@ +2010-11-25 Werner Koch + + * asshelp.c (start_new_gpg_agent): Change style of startup info. + (start_new_dirmngr): Ditto. + 2010-11-23 Werner Koch * asshelp.c (SECS_TO_WAIT_FOR_AGENT, SECS_TO_WAIT_FOR_DIRMNGR): Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/ChangeLog 2010-11-26 09:42:56 UTC (rev 5488) @@ -1,3 +1,11 @@ +2010-11-25 Werner Koch + + * base64.c (gpgsm_create_writer): Remove arg FP which is not used + by any caller. Change all callers. + (struct writer_cb_parm_s): Remove field FP. + (do_putc, do_fputs): Remove and replace callers by direct calls to + es_ functions. + 2010-11-23 Werner Koch * Makefile.am (gpgsm_LDADD): Add extra_bin_ldflags. Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/agent/gpg-agent.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -202,6 +202,14 @@ #define TIMERTICK_INTERVAL (2) /* Seconds. */ #endif +/* How often shall we check our own socket in standard socket mode. + For WindowsCE be use a longer interval because we don't expect any + problems and resources are anyway scare. */ +#ifdef HAVE_W32_SYSTEM +# define CHECK_OWN_SOCKET_INTERVAL (300) +#else +# define CHECK_OWN_SOCKET_INTERVAL (60) /* Seconds. */ +#endif /* The list of open file descriptors at startup. Note that this list has been allocated using the standard malloc. */ @@ -1682,8 +1690,8 @@ } #endif /*HAVE_W32_SYSTEM*/ - /* Code to be run every minute. */ - if (last_minute + 60 <= time (NULL)) + /* Code to be run from time to time. */ + if (last_minute + CHECK_OWN_SOCKET_INTERVAL <= time (NULL)) { check_own_socket (); last_minute = time (NULL); @@ -2179,7 +2187,7 @@ /* Check whether we are still listening on our own socket. In case another gpg-agent process started after us has taken ownership of - our socket, we woulf linger around without any real task. Thus we + our socket, we would linger around without any real task. Thus we better check once in a while whether we are really needed. */ static void check_own_socket (void) Modified: trunk/common/asshelp.c =================================================================== --- trunk/common/asshelp.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/common/asshelp.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -431,11 +431,12 @@ { int i; - if (verbose) - log_info (_("waiting %d seconds for the agent " - "to come up\n"), SECS_TO_WAIT_FOR_AGENT); for (i=0; i < SECS_TO_WAIT_FOR_AGENT; i++) { + if (verbose) + log_info (_("waiting for the agent " + "to come up ... (%ds)\n"), + SECS_TO_WAIT_FOR_AGENT - i); gnupg_sleep (1); err = assuan_socket_connect (ctx, sockname, 0, 0); if (!err) @@ -443,7 +444,7 @@ if (verbose) { log_info (_("connection to agent " - "established (%ds)\n"), i+1); + "established\n")); did_success_msg = 1; } break; @@ -624,11 +625,12 @@ { int i; - if (verbose) - log_info (_("waiting %d seconds for the dirmngr to come up\n"), - SECS_TO_WAIT_FOR_DIRMNGR); for (i=0; i < SECS_TO_WAIT_FOR_DIRMNGR; i++) { + if (verbose) + log_info (_("waiting for the dirmngr " + "to come up ... (%ds)\n"), + SECS_TO_WAIT_FOR_DIRMNGR - i); gnupg_sleep (1); err = assuan_socket_connect (ctx, sockname, 0, 0); if (!err) @@ -636,7 +638,7 @@ if (verbose) { log_info (_("connection to the dirmngr" - " established (%ds)\n"), i+1); + " established\n")); did_success_msg = 1; } break; Modified: trunk/sm/base64.c =================================================================== --- trunk/sm/base64.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/base64.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -72,10 +72,10 @@ /* Data used by the writer callbacks. */ -struct writer_cb_parm_s { - FILE *fp; /* FP is only used if STREAM is NULL. */ - estream_t stream; /* Alternative output if not NULL. */ - +struct writer_cb_parm_s +{ + estream_t stream; /* Output stream. */ + const char *pem_name; int wrote_begin; @@ -404,27 +404,6 @@ -/* Call either es_putc or the plain putc. */ -static void -do_putc (int value, FILE *fp, estream_t stream) -{ - if (stream) - es_putc (value, stream); - else - putc (value, fp); -} - -/* Call either es_fputs or the plain fputs. */ -static void -do_fputs (const char *string, FILE *fp, estream_t stream) -{ - if (stream) - es_fputs (string, stream); - else - fputs (string, fp); -} - - static int base64_writer_cb (void *cb_value, const void *buffer, size_t count) { @@ -432,7 +411,6 @@ unsigned char radbuf[4]; int i, c, idx, quad_count; const unsigned char *p; - FILE *fp = parm->fp; estream_t stream = parm->stream; if (!count) @@ -442,9 +420,9 @@ { if (parm->pem_name) { - do_fputs ("-----BEGIN ", fp, stream); - do_fputs (parm->pem_name, fp, stream); - do_fputs ("-----\n", fp, stream); + es_fputs ("-----BEGIN ", stream); + es_fputs (parm->pem_name, stream); + es_fputs ("-----\n", stream); } parm->wrote_begin = 1; parm->base64.idx = 0; @@ -463,16 +441,16 @@ { idx = 0; c = bintoasc[(*radbuf >> 2) & 077]; - do_putc (c, fp, stream); + es_putc (c, stream); c = bintoasc[(((*radbuf<<4)&060)|((radbuf[1] >> 4)&017))&077]; - do_putc (c, fp, stream); + es_putc (c, stream); c = bintoasc[(((radbuf[1]<<2)&074)|((radbuf[2]>>6)&03))&077]; - do_putc (c, fp, stream); + es_putc (c, stream); c = bintoasc[radbuf[2]&077]; - do_putc (c, fp, stream); + es_putc (c, stream); if (++quad_count >= (64/4)) { - do_fputs (LF, fp, stream); + es_fputs (LF, stream); quad_count = 0; } } @@ -482,39 +460,32 @@ parm->base64.idx = idx; parm->base64.quad_count = quad_count; - return ((stream? es_ferror (stream) : ferror (fp)) - ? gpg_error_from_syserror () - : 0); + return es_ferror (stream)? gpg_error_from_syserror () : 0; } + /* This callback is only used in stream mode. Hiowever, we don't restrict it to this. */ static int plain_writer_cb (void *cb_value, const void *buffer, size_t count) { struct writer_cb_parm_s *parm = cb_value; - FILE *fp = parm->fp; estream_t stream = parm->stream; if (!count) return 0; - if (stream) - es_write (stream, buffer, count, NULL); - else - fwrite (buffer, count, 1, fp); + es_write (stream, buffer, count, NULL); - return ((stream? es_ferror (stream) : ferror (fp)) - ? gpg_error_from_syserror () - : 0); + return es_ferror (stream)? gpg_error_from_syserror () : 0; } + static int base64_finish_write (struct writer_cb_parm_s *parm) { unsigned char radbuf[4]; int i, c, idx, quad_count; - FILE *fp = parm->fp; estream_t stream = parm->stream; if (!parm->wrote_begin) @@ -529,43 +500,41 @@ if (idx) { c = bintoasc[(*radbuf>>2)&077]; - do_putc (c, fp, stream); + es_putc (c, stream); if (idx == 1) { c = bintoasc[((*radbuf << 4) & 060) & 077]; - do_putc (c, fp, stream); - do_putc ('=', fp, stream); - do_putc ('=', fp, stream); + es_putc (c, stream); + es_putc ('=', stream); + es_putc ('=', stream); } else { c = bintoasc[(((*radbuf<<4)&060)|((radbuf[1]>>4)&017))&077]; - do_putc (c, fp, stream); + es_putc (c, stream); c = bintoasc[((radbuf[1] << 2) & 074) & 077]; - do_putc (c, fp, stream); - do_putc ('=', fp, stream); + es_putc (c, stream); + es_putc ('=', stream); } if (++quad_count >= (64/4)) { - do_fputs (LF, fp, stream); + es_fputs (LF, stream); quad_count = 0; } } if (quad_count) - do_fputs (LF, fp, stream); + es_fputs (LF, stream); if (parm->pem_name) { - do_fputs ("-----END ", fp, stream); - do_fputs (parm->pem_name, fp, stream); - do_fputs ("-----\n", fp, stream); + es_fputs ("-----END ", stream); + es_fputs (parm->pem_name, stream); + es_fputs ("-----\n", stream); } - return ((stream? es_ferror (stream) : ferror (fp)) - ? gpg_error_from_syserror () - : 0); + return es_ferror (stream)? gpg_error_from_syserror () : 0; } @@ -651,15 +620,14 @@ -/* Create a writer for the given stream FP or STREAM. Depending on +/* Create a writer for the given STREAM. Depending on the control information an output encoding is automagically choosen. The function returns a Base64Context object which must be passed to the gpgme_destroy_writer function. The created KsbaWriter object is also returned, but the caller must not call - the ksba_reader_release function on. */ + the ksba_reader_release function on it. */ int -gpgsm_create_writer (Base64Context *ctx, - ctrl_t ctrl, FILE *fp, estream_t stream, +gpgsm_create_writer (Base64Context *ctx, ctrl_t ctrl, estream_t stream, ksba_writer_t *r_writer) { int rc; @@ -679,7 +647,6 @@ if (ctrl->create_pem || ctrl->create_base64) { - (*ctx)->u.wparm.fp = fp; (*ctx)->u.wparm.stream = stream; if (ctrl->create_pem) (*ctx)->u.wparm.pem_name = ctrl->pem_name? ctrl->pem_name @@ -688,12 +655,11 @@ } else if (stream) { - (*ctx)->u.wparm.fp = fp; (*ctx)->u.wparm.stream = stream; rc = ksba_writer_set_cb (w, plain_writer_cb, &(*ctx)->u.wparm); } else - rc = ksba_writer_set_file (w, fp); + rc = gpg_error (GPG_ERR_INV_ARG); if (rc) { @@ -719,7 +685,7 @@ if (parm->did_finish) return 0; /* Already done. */ parm->did_finish = 1; - if (!parm->fp && !parm->stream) + if (!parm->stream) return 0; /* Callback was not used. */ return base64_finish_write (parm); } Modified: trunk/sm/certreqgen.c =================================================================== --- trunk/sm/certreqgen.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/certreqgen.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -854,7 +854,7 @@ ksba_writer_t writer; ctrl->pem_name = "CERTIFICATE REQUEST"; - rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_stream, &writer); + rc = gpgsm_create_writer (&b64writer, ctrl, out_stream, &writer); if (rc) { log_error ("can't create writer: %s\n", gpg_strerror (rc)); Modified: trunk/sm/decrypt.c =================================================================== --- trunk/sm/decrypt.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/decrypt.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -279,7 +279,7 @@ goto leave; } - rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_fp, &writer); + rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer); if (rc) { log_error ("can't create writer: %s\n", gpg_strerror (rc)); Modified: trunk/sm/encrypt.c =================================================================== --- trunk/sm/encrypt.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/encrypt.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -361,7 +361,7 @@ encparm.fp = data_fp; ctrl->pem_name = "ENCRYPTED MESSAGE"; - rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_fp, &writer); + rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer); if (rc) { log_error ("can't create writer: %s\n", gpg_strerror (rc)); Modified: trunk/sm/export.c =================================================================== --- trunk/sm/export.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/export.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -262,8 +262,7 @@ if (!b64writer) { ctrl->pem_name = "CERTIFICATE"; - rc = gpgsm_create_writer (&b64writer, ctrl, - NULL, stream, &writer); + rc = gpgsm_create_writer (&b64writer, ctrl, stream, &writer); if (rc) { log_error ("can't create writer: %s\n", gpg_strerror (rc)); @@ -424,7 +423,7 @@ } ctrl->pem_name = "PKCS12"; - err = gpgsm_create_writer (&b64writer, ctrl, NULL, stream, &writer); + err = gpgsm_create_writer (&b64writer, ctrl, stream, &writer); if (err) { log_error ("can't create writer: %s\n", gpg_strerror (err)); Modified: trunk/sm/gpgsm.h =================================================================== --- trunk/sm/gpgsm.h 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/gpgsm.h 2010-11-26 09:42:56 UTC (rev 5488) @@ -261,7 +261,7 @@ int gpgsm_reader_eof_seen (Base64Context ctx); void gpgsm_destroy_reader (Base64Context ctx); int gpgsm_create_writer (Base64Context *ctx, - ctrl_t ctrl, FILE *fp, estream_t stream, + ctrl_t ctrl, estream_t stream, ksba_writer_t *r_writer); int gpgsm_finish_writer (Base64Context ctx); void gpgsm_destroy_writer (Base64Context ctx); Modified: trunk/sm/sign.c =================================================================== --- trunk/sm/sign.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/sign.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -340,7 +340,7 @@ } ctrl->pem_name = "SIGNED MESSAGE"; - rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_fp, &writer); + rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer); if (rc) { log_error ("can't create writer: %s\n", gpg_strerror (rc)); Modified: trunk/sm/verify.c =================================================================== --- trunk/sm/verify.c 2010-11-23 18:51:43 UTC (rev 5487) +++ trunk/sm/verify.c 2010-11-26 09:42:56 UTC (rev 5488) @@ -134,7 +134,7 @@ if (out_fp) { - rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_fp, &writer); + rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer); if (rc) { log_error ("can't create writer: %s\n", gpg_strerror (rc)); From cvs at cvs.gnupg.org Fri Nov 26 22:38:01 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 26 Nov 2010 22:38:01 +0100 Subject: [svn] w32pth - r45 - trunk Message-ID: Author: wk Date: 2010-11-26 22:38:00 +0100 (Fri, 26 Nov 2010) New Revision: 45 Modified: trunk/ChangeLog trunk/debug.h trunk/w32-io.c trunk/w32-pth.c Log: Improved debug output. Changed Wince debugging Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-08-31 22:52:35 UTC (rev 44) +++ trunk/ChangeLog 2010-11-26 21:38:00 UTC (rev 45) @@ -1,3 +1,13 @@ +2010-11-26 Werner Koch + + * w32-pth.c: Repalce all fprintf to DBGFP my _pth-debug calls. + (pth_init): Ignore a debug-level of 0. + (pth_init) [W32CE]: Open the GPG2 device. + (log_get_prefix): Remove. Change all callers. + (do_pth_write): Instrument with trace calls. + * w32-io.c (_pth_debug) [W32CE]: Use the GPG2 device. + * debug.h (dbghd) [W32CE]: New. + 2010-09-01 Marcus Brinkmann * configure.ac: Define GPG_ERR_ENABLE_ERRNO_MACROS. Modified: trunk/debug.h =================================================================== --- trunk/debug.h 2010-08-31 22:52:35 UTC (rev 44) +++ trunk/debug.h 2010-11-26 21:38:00 UTC (rev 45) @@ -26,7 +26,11 @@ /* Keeps the current debug level. Define marcos to test them. */ extern int debug_level; +#ifdef HAVE_W32CE_SYSTEM +extern HANDLE dbghd; +#else extern FILE *dbgfp; +#endif #define DBG_ERROR (debug_level >= 1) #define DBG_INFO (debug_level >= 2) #define DBG_CALLS (debug_level >= 3) Modified: trunk/w32-io.c =================================================================== --- trunk/w32-io.c 2010-08-31 22:52:35 UTC (rev 44) +++ trunk/w32-io.c 2010-11-26 21:38:00 UTC (rev 45) @@ -180,10 +180,32 @@ if (debug_level < level) return; - + +#ifdef HAVE_W32CE_SYSTEM + if (dbghd) + { + LOCK (debug_lock); + va_start (arg_ptr, format); + { + char buffer[256]; + DWORD n, nwritten; + + _snprintf (buffer, 30, "%lu/w32pth: ", + (unsigned long)GetCurrentThreadId ()); + buffer[29] = 0; + n = strlen (buffer); + _vsnprintf (buffer + n, sizeof buffer - n, format, arg_ptr); + buffer[sizeof buffer - 1] = 0; + n = strlen (buffer); + WriteFile (dbghd, buffer, n, &nwritten, NULL); + } + va_end (arg_ptr); + UNLOCK (debug_lock); + } +#else va_start (arg_ptr, format); LOCK (debug_lock); - fprintf (dbgfp, "%05lu/%lu.%lu/libw32pth: ", + fprintf (dbgfp, "%05lu/%lu.%lu/w32pth: ", ((unsigned long)GetTickCount () % 100000), (unsigned long)GetCurrentProcessId (), (unsigned long)GetCurrentThreadId ()); @@ -193,7 +215,7 @@ putc ('\n', dbgfp); UNLOCK (debug_lock); fflush (dbgfp); - +#endif set_errno (saved_errno); } Modified: trunk/w32-pth.c =================================================================== --- trunk/w32-pth.c 2010-08-31 22:52:35 UTC (rev 44) +++ trunk/w32-pth.c 2010-11-26 21:38:00 UTC (rev 45) @@ -67,7 +67,11 @@ /* Debug helpers. */ int debug_level; +#ifdef HAVE_W32CE_SYSTEM +HANDLE dbghd = INVALID_HANDLE_VALUE; +#else FILE *dbgfp; +#endif /* Variables to support event handling. */ static int pth_signo; @@ -173,14 +177,6 @@ - -static const char * -log_get_prefix (const void *dummy) -{ - return "libw32pth"; -} - - /* Our own malloc function. Eventually we will use HeapCreate to use a private heap here. */ void * @@ -221,14 +217,20 @@ char *result = NULL; if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &handle)) - return NULL; /* No need for a RegClose, so return immediately. */ + { + return NULL; /* No need for a RegClose, so return immediately. */ + } nbytes = 1; if (RegQueryValueEx (handle, name, 0, NULL, NULL, &nbytes)) - goto leave; + { + goto leave; + } buffer = malloc ((n=nbytes+2)); if (!buffer) - goto leave; + { + goto leave; + } if (RegQueryValueEx (handle, name, 0, NULL, (PBYTE)buffer, &n)) { free (buffer); @@ -238,10 +240,14 @@ n = WideCharToMultiByte (CP_UTF8, 0, buffer, nbytes, NULL, 0, NULL, NULL); if (n < 0 || (n+1) <= 0) - goto leave; + { + goto leave; + } result = malloc (n+1); if (!result) - goto leave; + { + goto leave; + } n = WideCharToMultiByte (CP_UTF8, 0, buffer, nbytes, result, n, NULL, NULL); if (n < 0) { @@ -411,8 +417,8 @@ } if (DBG_INFO) - fprintf (dbgfp, "%s: fd_is_socket: fd %i is a %s.\n", - log_get_prefix (NULL), fd, is_socket ? "socket" : "file"); + _pth_debug (0, "fd_is_socket: fd %i is a %s.\n", + fd, is_socket ? "socket" : "file"); return is_socket; } @@ -434,9 +440,8 @@ if (!h) { if (DBG_ERROR) - fprintf (dbgfp, "%s: CreateEvent failed: %s\n", - log_get_prefix (NULL), - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0, "CreateEvent failed: %s\n", + w32_strerror (strerr, sizeof strerr)); return NULL; } #ifdef HAVE_W32CE_SYSTEM @@ -447,10 +452,8 @@ EVENT_MODIFY_STATE|SYNCHRONIZE, FALSE, 0 ) ) { if (DBG_ERROR) - fprintf (dbgfp, "%s: " - "setting synchronize for event object %p failed: %s\n", - log_get_prefix (NULL), h, - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0, "setting synchronize for event object %p failed: %s\n", + h, w32_strerror (strerr, sizeof strerr)); CloseHandle (h); return NULL; } @@ -458,8 +461,7 @@ #endif if (DBG_INFO) { - fprintf (dbgfp, "%s: CreateEvent(%p) succeeded\n", - log_get_prefix (NULL), h2); + _pth_debug (0, "CreateEvent(%p) succeeded\n", h2); } return h2; } @@ -474,14 +476,12 @@ if (!SetEvent (h)) { if (DBG_ERROR) - fprintf (dbgfp, "%s: SetEvent(%p) failed: %s\n", - log_get_prefix (NULL), h, - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0, "SetEvent(%p) failed: %s\n", + h, w32_strerror (strerr, sizeof strerr)); } else if (DBG_INFO) { - fprintf (dbgfp, "%s: SetEvent(%p) succeeded\n", - log_get_prefix (NULL), h); + _pth_debug (0, "SetEvent(%p) succeeded\n", h); } } #endif @@ -494,14 +494,12 @@ if (!ResetEvent (h)) { if (DBG_ERROR) - fprintf (dbgfp, "%s: ResetEvent(%p) failed: %s\n", - log_get_prefix (NULL), h, - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0, "ResetEvent(%p) failed: %s\n", + h, w32_strerror (strerr, sizeof strerr)); } else if (DBG_INFO) { - fprintf (dbgfp, "%s: ResetEvent(%p) succeeded\n", - log_get_prefix (NULL), h); + _pth_debug (0, "ResetEvent(%p) succeeded\n", h); } } @@ -545,9 +543,9 @@ break; default: if (DBG_ERROR) - fprintf (dbgfp, - "%s:w32ce_timer_thread: WFSO failed: rc=%d\n", - log_get_prefix (NULL), (int)GetLastError ()); + _pth_debug (0, + "w32ce_timer_thread: WFSO failed: rc=%d\n", + (int)GetLastError ()); Sleep (500); /* Failsafe pause. */ break; } @@ -567,9 +565,9 @@ if (!SetEvent (w32ce_timer[idx].event)) { if (DBG_ERROR) - fprintf (dbgfp, "%s:w32ce_timer_thread: SetEvent(%p) " + _pth_debug (0, "w32ce_timer_thread: SetEvent(%p) " "failed: rc=%d\n", - log_get_prefix (NULL), (int)GetLastError ()); + (int)GetLastError ()); } } } @@ -598,8 +596,8 @@ if (!h) { if (DBG_ERROR) - fprintf (dbgfp, "%s:create_timer: CreateThread failed: rc=%d\n", - log_get_prefix (NULL), (int)GetLastError ()); + _pth_debug (0, "create_timer: CreateThread failed: rc=%d\n", + (int)GetLastError ()); goto leave; } CloseHandle (h); @@ -639,13 +637,13 @@ if (!h) { if (DBG_ERROR) - fprintf (dbgfp, "%s: CreateWaitableTimer failed: rc=%d\n", - log_get_prefix (NULL), (int)GetLastError ()); + _pth_debug (0, "CreateWaitableTimer failed: rc=%d\n", + (int)GetLastError ()); } else if (DBG_INFO) { - fprintf (dbgfp, "%s: CreateWaitableTimer(%p) succeeded\n", - log_get_prefix (NULL), h); + _pth_debug (0, "CreateWaitableTimer(%p) succeeded\n", + h); } return h; } @@ -665,14 +663,14 @@ if (!ResetEvent (w32ce_timer[idx].event)) { if (DBG_ERROR) - fprintf (dbgfp, "%s:set_timer: ResetEvent(%p) failed: rc=%d\n", - log_get_prefix (NULL), (int)GetLastError ()); + _pth_debug (0, "set_timer: ResetEvent(%p) failed: rc=%d\n", + (int)GetLastError ()); } else if (!SetEvent (w32ce_timer_ev)) { if (DBG_ERROR) - fprintf (dbgfp, "%s:set_timer: SetEvent(%p) failed: rc=%d\n", - log_get_prefix (NULL), (int)GetLastError ()); + _pth_debug (0, "set_timer: SetEvent(%p) failed: rc=%d\n", + (int)GetLastError ()); } else { @@ -697,9 +695,9 @@ if (!SetWaitableTimer (hd, &ll, 0, NULL, NULL, FALSE)) { if (DBG_ERROR) - fprintf (dbgfp,"%s: %s: SetWaitableTimer failed: %s\n", - log_get_prefix (NULL), __func__, - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0,"%s: SetWaitableTimer failed: %s\n", + __func__, + w32_strerror (strerr, sizeof strerr)); return -1; } return 0; @@ -736,8 +734,7 @@ pth_init (void) { WSADATA wsadat; - const char *s, *s1, *s2; - char *p; + const char *s; if (pth_initialized) return TRUE; @@ -745,9 +742,19 @@ _pth_sema_subsystem_init (); s = getenv ("PTH_DEBUG"); - if (s) + if (s && (debug_level = atoi (s))) { - debug_level = atoi (s); +#ifdef HAVE_W32CE_SYSTEM + ActivateDevice (L"Drivers\\GnuPG_Log", 0); + /* Ignore a filename and write the debug output to the GPG2: + device. */ + dbghd = CreateFile (L"GPG2:", GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +#else + const char *s1, *s2; + char *p; + s1 = strchr (s, ';'); if (s1) { @@ -765,9 +772,12 @@ _pth_free (p); } } +#endif } +#ifndef HAVE_W32CE_SYSTEM if (!dbgfp) dbgfp = stderr; +#endif if (debug_level) _pth_debug (DEBUG_ERROR, "pth_init called (level=%d)\n", debug_level); @@ -984,13 +994,16 @@ /* We have to check for internal pipes first, as socket operations can block on these. */ hd = _pth_get_reader_ev (fd); + TRACE_LOG1 (" hd=%p", hd); if (hd != INVALID_HANDLE_VALUE) n = _pth_io_read (fd, buffer, size); else { if (is_socket_2 (fd)) { + TRACE_LOG1 (" recv size=%d", (int)size); n = recv (fd, buffer, size, 0); + TRACE_LOG1 (" recv res=%d", n); #ifdef HAVE_W32CE_SYSTEM if (n == -1 && WSAGetLastError () == WSAENOTSOCK) use_readfile = 1; /* Fallback to ReadFile. */ @@ -998,6 +1011,7 @@ } else { + TRACE_LOG1 (" use readfile size=%d", (int)size); n = -1; use_readfile = 1; } @@ -1018,9 +1032,8 @@ char strerr[256]; if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_read(0x%x) ReadFile failed: %s\n", - log_get_prefix (NULL), fd, - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0, "pth_read(0x%x) ReadFile failed: %s\n", + fd, w32_strerror (strerr, sizeof strerr)); n = -1; set_errno (map_w32_to_errno (GetLastError ())); } @@ -1030,8 +1043,8 @@ else if (n == -1) { if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_read(0x%x) recv failed: ec=%d\n", - log_get_prefix (NULL), fd, (int)WSAGetLastError ()); + _pth_debug (0, "pth_read(0x%x) recv failed: ec=%d\n", + fd, (int)WSAGetLastError ()); set_errno (map_wsa_to_errno (WSAGetLastError ())); } } @@ -1112,16 +1125,21 @@ HANDLE hd; int use_writefile = 0; + TRACE_BEG (DEBUG_INFO, "do_pth_write", fd); + /* We have to check for internal pipes first, as socket operations can block on these. */ hd = _pth_get_writer_ev (fd); + TRACE_LOG1 (" hd=%p", hd); if (hd != INVALID_HANDLE_VALUE) n = _pth_io_write (fd, buffer, size); else { if (is_socket_2 (fd)) { + TRACE_LOG1 (" send size=%d", (int)size); n = send (fd, buffer, size, 0); + TRACE_LOG1 (" send res=%d", n); #ifdef HAVE_W32CE_SYSTEM if (n == -1 && WSAGetLastError () == WSAENOTSOCK) use_writefile = 1; /* Fallback to ReadFile. */ @@ -1129,6 +1147,7 @@ } else { + TRACE_LOG1 (" use writefile size=%d", (int)size); n = -1; use_writefile = 1; } @@ -1139,27 +1158,31 @@ /* This is no real error because we first need to figure out if we have a handle or a socket. */ + TRACE_LOG2 (" WriteFile on %p size=%d", (HANDLE)fd, (int)size); if (!WriteFile ((HANDLE)fd, buffer, size, &nwrite, NULL)) { n = -1; set_errno (map_w32_to_errno (GetLastError ())); if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_write(0x%x) failed in write: %s\n", - log_get_prefix (NULL), fd, - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0, "pth_write(0x%x) failed in write: %s\n", + fd, w32_strerror (strerr, sizeof strerr)); } else - n = (int) nwrite; + { + TRACE_LOG2 (" n=%d nwritten=%d", n, (int)nwrite); + n = (int) nwrite; + } } else if (n == -1) { if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_write(0x%x) send failed: ec=%d\n", - log_get_prefix (NULL), fd, (int)WSAGetLastError ()); + _pth_debug (0, "pth_write(0x%x) send failed: ec=%d\n", + fd, (int)WSAGetLastError ()); set_errno (map_wsa_to_errno (WSAGetLastError ())); } } + TRACE_SYSRES (n); return n; } @@ -1235,14 +1258,14 @@ if (!ev) { - fprintf (dbgfp, "show_event_ring(%s): No ring\n", text); + _pth_debug (0, "show_event_ring(%s): No ring\n", text); return; } r = ev; do { - fprintf (dbgfp, "show_event_ring(%s): type=%d r=%p prev=%p next=%p\n", + _pth_debug (0, "show_event_ring(%s): type=%d r=%p prev=%p next=%p\n", text, r->u_type, r, r->prev, r->next); } while (r=r->next, r != ev); @@ -1470,9 +1493,8 @@ char strerr[256]; if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_release_mutex %p failed: %s\n", - log_get_prefix (NULL), *mutex, - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0, "pth_release_mutex %p failed: %s\n", + *mutex, w32_strerror (strerr, sizeof strerr)); rc = FALSE; } else @@ -1502,9 +1524,8 @@ char strerr[256]; if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_mutex_acquire for %p failed: %s\n", - log_get_prefix (NULL), *mutex, - w32_strerror (strerr, sizeof strerr)); + _pth_debug (0, "pth_mutex_acquire for %p failed: %s\n", + *mutex, w32_strerror (strerr, sizeof strerr)); } rc = FALSE; break; @@ -1515,9 +1536,9 @@ default: if (DBG_ERROR) - fprintf (dbgfp, "%s: WaitForSingleObject returned unexpected " - "code %d for mutex %p\n", - log_get_prefix (NULL), code, *mutex); + _pth_debug (0, "WaitForSingleObject returned unexpected " + "code %d for mutex %p\n", + code, *mutex); rc = FALSE; break; } @@ -1632,8 +1653,7 @@ { hd->flags |= PTH_ATTR_JOINABLE; if (DBG_INFO) - fprintf (dbgfp, "%s: pth_attr_set: PTH_ATTR_JOINABLE\n", - log_get_prefix (NULL)); + _pth_debug (0, "pth_attr_set: PTH_ATTR_JOINABLE\n"); } break; @@ -1644,8 +1664,8 @@ hd->flags |= PTH_ATTR_STACK_SIZE; hd->stack_size = val; if (DBG_INFO) - fprintf (dbgfp, "%s: pth_attr_set: PTH_ATTR_STACK_SIZE %d\n", - log_get_prefix (NULL), val); + _pth_debug (0, "pth_attr_set: PTH_ATTR_STACK_SIZE %d\n", + val); } break; @@ -1660,8 +1680,8 @@ return FALSE; hd->flags |= PTH_ATTR_NAME; if (DBG_INFO) - fprintf (dbgfp, "%s: pth_attr_set: PTH_ATTR_NAME %s\n", - log_get_prefix (NULL), hd->name); + _pth_debug (0, "pth_attr_set: PTH_ATTR_NAME %s\n", + hd->name); } break; @@ -1706,15 +1726,13 @@ FIXME: We should not use W32's thread handle directly but keep our own thread control structure. CTX may be used for that. */ if (DBG_INFO) - fprintf (dbgfp, "%s: do_pth_spawn creating thread ...\n", - log_get_prefix (NULL)); + _pth_debug (0, "do_pth_spawn creating thread ...\n"); th = CreateThread (&sa, hd->stack_size, (LPTHREAD_START_ROUTINE)launch_thread, ctx, CREATE_SUSPENDED, &tid); ctx->th = th; if (DBG_INFO) - fprintf (dbgfp, "%s: do_pth_spawn created thread %p\n", - log_get_prefix (NULL),th); + _pth_debug (0, "do_pth_spawn created thread %p\n", th); if (!th) _pth_free (ctx); else @@ -1877,7 +1895,7 @@ /* Fixme: We can keep only track of one signal at a time. */ set_event (pth_signo_ev); if (DBG_INFO) - fprintf (dbgfp, "%s: sig_handler=%d\n", log_get_prefix (NULL), pth_signo); + _pth_debug (0, "sig_handler=%d\n", pth_signo); return TRUE; } #endif @@ -1921,13 +1939,13 @@ if ((spec & (PTH_MODE_CHAIN|PTH_MODE_REUSE))) { if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_event spec=%lx - not supported\n", - log_get_prefix (NULL), spec); + _pth_debug (0, "pth_event spec=%lx - not supported\n", + spec); return NULL; /* Not supported. */ } if (DBG_INFO) - fprintf (dbgfp, "%s: pth_event spec=%lx\n", log_get_prefix (NULL), spec); + _pth_debug (0, "pth_event spec=%lx\n", spec); ev = _pth_calloc (1, sizeof *ev); if (!ev) @@ -1972,8 +1990,7 @@ /* The signal handler is disabled for now. */ rc = 0/*SetConsoleCtrlHandler (sig_handler, TRUE)*/; if (DBG_INFO) - fprintf (dbgfp, "%s: pth_event: sigs rc=%d\n", - log_get_prefix (NULL), rc); + _pth_debug (0, "pth_event: sigs rc=%d\n", rc); } else if (spec & PTH_EVENT_FD) { @@ -1982,8 +1999,7 @@ ev->u_type = PTH_EVENT_FD; ev->u.fd = va_arg (arg, int); if (DBG_INFO) - fprintf (dbgfp, "%s: pth_event: fd=0x%x\n", - log_get_prefix (NULL), ev->u.fd); + _pth_debug (0, "pth_event: fd=0x%x\n", ev->u.fd); } else if (spec & PTH_EVENT_TIME) { @@ -2022,10 +2038,10 @@ if (WSAEventSelect (fdarray[i].fd, ev->hd, fdarray[i].netevents)) { if (DBG_ERROR) - fprintf (dbgfp, - "%s: pth_event: WSAEventSelect(%d[%d]) failed: %s\n", - log_get_prefix (NULL), i, fdarray[i].fd, - wsa_strerror (strerr, sizeof strerr)); + _pth_debug (0, + "pth_event: WSAEventSelect(%d[%d]) failed: %s\n", + i, fdarray[i].fd, + wsa_strerror (strerr, sizeof strerr)); } } } @@ -2347,8 +2363,8 @@ if (res) { if (DBG_ERROR) - fprintf (dbgfp, "%s: can't set event for FD 0x%x " - "(ignored)\n", log_get_prefix (NULL), fd); + _pth_debug (0, "can't set event for FD 0x%x " + "(ignored)\n", fd); } else { @@ -2367,8 +2383,8 @@ if (reader_ev == INVALID_HANDLE_VALUE) { if (DBG_ERROR) - fprintf (dbgfp, "%s: no reader for FD 0x%x " - "(ignored)\n", log_get_prefix (NULL), fd); + _pth_debug (0, "no reader for FD 0x%x " + "(ignored)\n", fd); } else { @@ -2384,8 +2400,8 @@ if (writer_ev == INVALID_HANDLE_VALUE) { if (DBG_ERROR) - fprintf (dbgfp, "%s: no writer for FD 0x%x " - "(ignored)\n", log_get_prefix (NULL), fd); + _pth_debug (0, "no writer for FD 0x%x " + "(ignored)\n", fd); } else { @@ -2421,12 +2437,12 @@ case PTH_EVENT_MUTEX: if (DBG_ERROR) - fprintf (dbgfp, "pth_wait: ignoring mutex event.\n"); + _pth_debug (0, "pth_wait: ignoring mutex event.\n"); break; default: if (DBG_ERROR) - fprintf (dbgfp, "pth_wait: unhandled event type 0x%x.\n", + _pth_debug (0, "pth_wait: unhandled event type 0x%x.\n", r->u_type); break; } @@ -2488,11 +2504,11 @@ if (WSAEnumNetworkEvents (fdarray[i].fd, NULL, &ne)) { if (DBG_ERROR) - fprintf (dbgfp, - "%s: pth_wait: " - "WSAEnumNetworkEvents(%d[%d]) failed: %s\n", - log_get_prefix (NULL), i, fdarray[i].fd, - wsa_strerror (strerr, sizeof strerr)); + _pth_debug (0, + "pth_wait: WSAEnumNetworkEvents(%d[%d])" + " failed: %s\n", + i, fdarray[i].fd, + wsa_strerror (strerr, sizeof strerr)); continue; } @@ -2521,10 +2537,10 @@ if (WSAEventSelect (fdarray[i].fd, NULL, 0)) { if (DBG_ERROR) - fprintf (dbgfp, - "%s: pth_wait: WSAEventSelect(%d[%d]-clear)" + _pth_debug (0, + "pth_wait: WSAEventSelect(%d[%d]-clear)" " failed: %s\n", - log_get_prefix (NULL), i, fdarray[i].fd, + i, fdarray[i].fd, wsa_strerror (strerr, sizeof strerr)); } @@ -2533,10 +2549,10 @@ == SOCKET_ERROR) { if (DBG_ERROR) - fprintf (dbgfp, - "%s: pth_wait: ioctlsocket(%d[%d])" + _pth_debug (0, + "pth_wait: ioctlsocket(%d[%d])" " failed: %s\n", - log_get_prefix (NULL), i, fdarray[i].fd, + i, fdarray[i].fd, wsa_strerror (strerr, sizeof strerr)); } } From cvs at cvs.gnupg.org Mon Nov 29 07:49:45 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 29 Nov 2010 07:49:45 +0100 Subject: [svn] GnuPG - r5489 - trunk/agent Message-ID: Author: wk Date: 2010-11-29 07:49:44 +0100 (Mon, 29 Nov 2010) New Revision: 5489 Modified: trunk/agent/ChangeLog trunk/agent/cache.c trunk/agent/gpg-agent.c Log: Init cache encryption on the fly. add some debug code Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-11-26 09:42:56 UTC (rev 5488) +++ trunk/agent/ChangeLog 2010-11-29 06:49:44 UTC (rev 5489) @@ -1,6 +1,13 @@ +2010-11-29 Werner Koch + + * cache.c (initialize_module_cache): Factor code out to ... + (init_encryption): new. + (new_data, agent_get_cache): Init encryption on on the fly. + 2010-11-26 Werner Koch * gpg-agent.c (CHECK_OWN_SOCKET_INTERVAL): New. + (handle_tick) [W32CE]: Don't check own socket. 2010-11-23 Werner Koch Modified: trunk/agent/cache.c =================================================================== --- trunk/agent/cache.c 2010-11-26 09:42:56 UTC (rev 5488) +++ trunk/agent/cache.c 2010-11-29 06:49:44 UTC (rev 5489) @@ -71,15 +71,42 @@ void initialize_module_cache (void) { - static int initialized; + if (!pth_mutex_init (&encryption_lock)) + { + gpg_error_t err = gpg_error_from_syserror (); + log_fatal ("error initializing cache module: %s\n", gpg_strerror (err)); + } +} + + +void +deinitialize_module_cache (void) +{ + gcry_cipher_close (encryption_handle); + encryption_handle = NULL; +} + + +/* We do the encryption init on the fly. We can't do it in the module + init code because that is run before we listen for connections and + in case we are started on demand by gpg etc. it will only wait for + a few seconds to decide whether the agent may now accept + connections. Thus we should get into listen state as soon as + possible. */ +static gpg_error_t +init_encryption (void) +{ gpg_error_t err; void *key; - if (!pth_mutex_init (&encryption_lock)) - err = gpg_error_from_syserror (); - else - err = gcry_cipher_open (&encryption_handle, GCRY_CIPHER_AES128, - GCRY_CIPHER_MODE_AESWRAP, GCRY_CIPHER_SECURE); + if (encryption_handle) + return 0; /* Shortcut - Already initialized. */ + + if (!pth_mutex_acquire (&encryption_lock, 0, NULL)) + log_fatal ("failed to acquire cache encryption mutex\n"); + + err = gcry_cipher_open (&encryption_handle, GCRY_CIPHER_AES128, + GCRY_CIPHER_MODE_AESWRAP, GCRY_CIPHER_SECURE); if (!err) { key = gcry_random_bytes (ENCRYPTION_KEYSIZE, GCRY_STRONG_RANDOM); @@ -90,22 +117,24 @@ err = gcry_cipher_setkey (encryption_handle, key, ENCRYPTION_KEYSIZE); xfree (key); } + if (err) + { + gcry_cipher_close (encryption_handle); + encryption_handle = NULL; + } } if (err) - log_fatal ("error initializing cache encryption context: %s\n", - gpg_strerror (err)); - initialized = 1; + log_error ("error initializing cache encryption context: %s\n", + gpg_strerror (err)); + + if (!pth_mutex_release (&encryption_lock)) + log_fatal ("failed to release cache encryption mutex\n"); + + return err? gpg_error (GPG_ERR_NOT_INITIALIZED) : 0; } -void -deinitialize_module_cache (void) -{ - gcry_cipher_close (encryption_handle); - encryption_handle = NULL; -} - static void release_data (struct secret_data_s *data) { @@ -122,8 +151,9 @@ *r_data = NULL; - if (!encryption_handle) - return gpg_error (GPG_ERR_NOT_INITIALIZED); + err = init_encryption (); + if (err) + return err; length = strlen (string) + 1; @@ -369,8 +399,8 @@ log_debug ("... hit\n"); if (r->pw->totallen < 32) err = gpg_error (GPG_ERR_INV_LENGTH); - else if (!encryption_handle) - err = gpg_error (GPG_ERR_NOT_INITIALIZED); + else if ((err = init_encryption ())) + ; else if (!(value = xtrymalloc_secure (r->pw->totallen - 8))) err = gpg_error_from_syserror (); else Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2010-11-26 09:42:56 UTC (rev 5488) +++ trunk/agent/gpg-agent.c 2010-11-29 06:49:44 UTC (rev 5489) @@ -203,10 +203,9 @@ #endif /* How often shall we check our own socket in standard socket mode. - For WindowsCE be use a longer interval because we don't expect any - problems and resources are anyway scare. */ + If that value is 0 we don't check at all. */ #ifdef HAVE_W32_SYSTEM -# define CHECK_OWN_SOCKET_INTERVAL (300) +# define CHECK_OWN_SOCKET_INTERVAL (0) #else # define CHECK_OWN_SOCKET_INTERVAL (60) /* Seconds. */ #endif @@ -1691,11 +1690,13 @@ #endif /*HAVE_W32_SYSTEM*/ /* Code to be run from time to time. */ +#if CHECK_OWN_SOCKET_INTERVAL > 0 if (last_minute + CHECK_OWN_SOCKET_INTERVAL <= time (NULL)) { check_own_socket (); last_minute = time (NULL); } +#endif } @@ -1799,8 +1800,13 @@ { ctrl_t ctrl = arg; + if (opt.verbose) + log_debug ("handler 0x%lx checking nonce\n", pth_thread_id ()); if (check_nonce (ctrl, &socket_nonce)) - return NULL; + { + log_debug ("handler 0x%lx nonce check FAILED\n", pth_thread_id ()); + return NULL; + } agent_init_default_ctrl (ctrl); if (opt.verbose) @@ -1918,6 +1924,7 @@ for (;;) { + log_debug ("%s: Begin main loop\n", __func__); /* Make sure that our signals are not blocked. */ pth_sigmask (SIG_UNBLOCK, &sigs, NULL); @@ -1927,6 +1934,7 @@ if (pth_ctrl (PTH_CTRL_GETTHREADS) == 1) break; /* ready */ + log_debug ("%s: shutdown pending\n", __func__); /* Do not accept new connections but keep on running the loop to cope with the timer events. */ FD_ZERO (&fdset); @@ -1945,6 +1953,7 @@ nexttick.tv_usec = 0; } time_ev = pth_event (PTH_EVENT_TIME, nexttick); + log_debug ("%s: time event created\n", __func__); } /* POSIX says that fd_set should be implemented as a structure, @@ -1953,7 +1962,10 @@ if (time_ev) pth_event_concat (ev, time_ev, NULL); + + log_debug ("%s: Pre-select\n", __func__); ret = pth_select_ev (nfd+1, &read_fdset, NULL, NULL, NULL, ev); + log_debug ("%s: Post-select res=%d\n", __func__, ret); if (time_ev) pth_event_isolate (time_ev); @@ -1984,8 +1996,10 @@ continue; } + log_debug ("%s: Checking events\n", __func__); if (pth_event_occurred (ev)) { + log_debug ("%s: Got event\n", __func__); #if defined(HAVE_W32_SYSTEM) && defined(PTH_EVENT_HANDLE) agent_sigusr2_action (); #else @@ -1995,12 +2009,14 @@ if (time_ev && pth_event_occurred (time_ev)) { + log_debug ("%s: Got tick event\n", __func__); pth_event_free (time_ev, PTH_FREE_ALL); time_ev = NULL; handle_tick (); } + log_debug ("%s: Restore mask\n", __func__); /* We now might create new threads and because we don't want any signals (as we are handling them here) to be delivered to a new thread. Thus we need to block those signals. */ @@ -2010,9 +2026,11 @@ { ctrl_t ctrl; + log_debug ("%s: Pre-accept\n", __func__); plen = sizeof paddr; fd = INT2FD (pth_accept (FD2INT(listen_fd), (struct sockaddr *)&paddr, &plen)); + log_debug ("%s: Post-accept fd=%d\n", __func__, fd); if (fd == GNUPG_INVALID_FD) { log_error ("accept failed: %s\n", strerror (errno)); @@ -2034,6 +2052,7 @@ { char threadname[50]; + log_debug ("%s: Spawning handler\n", __func__); snprintf (threadname, sizeof threadname-1, "conn fd=%d (gpg)", FD2INT(fd)); threadname[sizeof threadname -1] = 0; @@ -2046,6 +2065,7 @@ assuan_sock_close (fd); xfree (ctrl); } + log_debug ("%s: handler spawned\n", __func__); } fd = GNUPG_INVALID_FD; } @@ -2055,6 +2075,7 @@ { ctrl_t ctrl; + log_debug ("%s: SSH STUFF!\n", __func__); plen = sizeof paddr; fd = INT2FD(pth_accept (FD2INT(listen_fd_ssh), (struct sockaddr *)&paddr, &plen)); @@ -2095,8 +2116,10 @@ } fd = GNUPG_INVALID_FD; } + log_debug ("%s: End main loop\n", __func__); } + log_debug ("%s: main loop terminated\n", __func__); pth_event_free (ev, PTH_FREE_ALL); if (time_ev) pth_event_free (time_ev, PTH_FREE_ALL);