diff --git a/ChangeLog b/ChangeLog index a2fd496a..e3a2e2e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2007-07-04 Marcus Brinkmann + * assuan/: Update files to 2007-07-04 version of assuan. + * autogen.sh: Use = not == in test. 2007-03-05 Werner Koch diff --git a/assuan/ChangeLog b/assuan/ChangeLog index a3b3f928..2a4611e6 100644 --- a/assuan/ChangeLog +++ b/assuan/ChangeLog @@ -1,3 +1,71 @@ +2007-07-04 Marcus Brinkmann + + Change _WIN32 to HAVE_W32_SYSTEM for consistency. + + * assuan-defs.h (struct assuan_context_s): Have full peercred + structure even if not HAVE_SO_PEERCRED, but not if + HAVE_W32_SYSTEM. + +2007-06-18 Werner Koch + + * assuan-logging.c (load_libgpg_error, _assuan_gpg_strerror_r) + (_assuan_gpg_strsource): New. + * assuan-handler.c (process_request) [W32]: Use these new + functions for human understable error codes. + +2007-06-12 Werner Koch + + * assuan-io.c (_assuan_simple_read): Hack to allow reading from a + socket. + (_assuan_simple_write): Likewise. + +2007-06-11 Werner Koch + + * assuan-io-pth.c (_assuan_simple_read, _assuan_simple_write): Use + pth versions also for W32. + +2007-05-29 Werner Koch + + * assuan-io-pth.c: Include sys/socket.h only if available. Remove + double inclusion of sys/wait.h + + * assuan-pipe-connect.c (build_w32_commandline): Make ARGV const. + + * assuan-pipe-server.c (is_valid_socket) [W32]: Do not define. + + * assuan-socket-server.c [W32]: Include ws2tcpip.h to define + socklen_t. + * assuan-defs.h (struct assuan_context_s): Define most peercred + members only if we can really set them. + (_assuan_simple_sendmsg, _assuan_simple_recvmsg) [W32]: Use a + different prototype. + * assuan.h (assuan_get_peercred) [W32]: Do not define. + * assuan-io.c (_assuan_simple_sendmsg, _assuan_simple_recvmsg) + [w32]: Use another prototype. + +2007-05-09 Werner Koch + + * libassuan.m4: Print found version on success. + +2007-05-01 Werner Koch + + * assuan-uds.c (uds_reader): Cast void ptr for arithmetics. + Reported by Peter O'Gorman. + +2006-12-03 Marcus Brinkmann + + * assuan-handler.c (assuan_command_parse_fd): Also allow white + space after FD. + +2006-12-02 Marcus Brinkmann + + * assuan-uds.c (uds_reader): Return 0 if recvmsg returns 0. + +2006-12-01 Marcus Brinkmann + + * assuan-client.c (assuan_transact): Also translate some of the + legacy error codes. + 2006-11-22 Werner Koch * assuan-handler.c (fun1_cookie_write, fun2_cookie_write): New. @@ -328,20 +396,106 @@ * assuan-buffer.c (assuan_write_line): If the line is longer than the maximum line length, bail out early. +2004-04-21 Werner Koch + + * assuan-socket-server.c (accept_connection_bottom): Save the pid + of the peer if it is available. + * assuan-socket-connect.c (assuan_socket_connect): Do not save the + dummy SERVED_PID arg. + * assuan-pipe-connect.c (do_finish): Don't wait if the pid is 0. + (assuan_pipe_connect2): Store the parents pid in the environment + of the child. + * assuan-pipe-server.c (assuan_init_pipe_server): Initialize the + peer's pid from the environment. + * assuan-connect.c (assuan_get_pid): Do not return 0 as a PID. + 2004-04-19 Werner Koch - * assuan-socket-connect.c: Include sys/types.h - * assuan-socket-server.c: Ditto + * assuan-socket-server.c, assuan-socket-connect.c: Includes + sys/types.h. Reported by Michael Nottebrock. * assuan-domain-connect.c: Ditto. +2004-04-13 Werner Koch + + * assuan-util.c (_assuan_log_print_buffer): Relaxed quoting. + (_assuan_log_sanitized_string): Ditto. + +2004-03-14 Werner Koch + + * assuan-handler.c: Include . Reported by Bernd Kuhls. + 2004-02-18 Werner Koch + * libassuan-config.in: Ignore setting of --prefix. + * assuan-handler.c (assuan_get_data_fp): Fail with ENOSYS if we can't implement this. +2004-02-15 Werner Koch + + * memrchr.c (memrchr): Fixed implementation. Taken from gpgme. + 2004-02-13 Werner Koch - * assuan-domain-connect.c: Removed the unneeded alloca.h + * assuan-domain-connect.c: Removed the unneeded alloca.h. + +2004-01-24 Werner Koch + + * assuan-pipe-connect.c (assuan_pipe_connect2): New as an + extension of assuan_pipe_connect. Made the latter call this one. + +2004-01-14 Werner Koch + + * assuan-buffer.c (_assuan_cookie_write_data): Return the + requested size to indicate successful operation. Fixes a spurious + bug we previously fixed using fflush(). + +2003-12-22 Werner Koch + + * assuan.h (ASSUAN_Locale_Problem): Added. + * assuan-errors.c (assuan_strerror): Ditto. + +2003-12-18 Werner Koch + + * assuan.h (AssuanCommand): Clarified that these are now + deprecated and actually useless. + (assuan_error_t): Clarified and added ASSUAN_USER_ERROR_FIRST, + ASSUAN_USER_ERROR_LAST. + +2003-12-16 Werner Koch + + * assuan-buffer.c: Changed formatting of the debug output prefix. + * assuan-util.c (assuan_set_log_stream): Set global log stream if + it has not been done yet. + * assuan-logging.c (_assuan_set_default_log_stream): New. + (assuan_set_assuan_log_prefix): New. + +2003-12-11 Werner Koch + + * funopen.c (_assuan_funopen): Renamed from funopen, to keep the + name space clean and avoid duplicate definitions if another + library uses the same replacement. + * assuan-defs.h (funopen): Renamed prototype and add a macro. + +2003-12-08 Werner Koch + + * TODO: Removed. + +2003-11-12 Werner Koch + + * assuan-handler.c (process_request): Kludge to print better error + messages for gpg-error enabled programs. + +2003-11-06 Werner Koch + + * assuan.h (assuan_context_t): New. Should be used in favor of + ASSUAN_CONTEXT. + (assuan_error_t): New. To be used instead of AssuanError. + +2003-11-11 Moritz Schulte + + * assuan-socket-connect.c (assuan_socket_connect): Fix computation + of socket address length. 2003-08-13 Werner Koch @@ -818,7 +972,7 @@ * assuan-defs.h: Add space in the context for this. - Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright 2001, 2002, 2006 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 diff --git a/assuan/README.1st b/assuan/README.1st index 670efb57..c755cfec 100644 --- a/assuan/README.1st +++ b/assuan/README.1st @@ -23,6 +23,9 @@ updating this directory, are: namespace. It also wraps all system functions that are wrapped by GNU Pth to _gpgme wrappers. +* assuan-io-pth.c + We don't need this file as GPGME doesn't use sendmsg and recvmsg. + If it would, we would need to pick up the W32 implementation. Copyright 2004 g10 Code GmbH diff --git a/assuan/assuan-client.c b/assuan/assuan-client.c index 978c6954..7b3d2662 100644 --- a/assuan/assuan-client.c +++ b/assuan/assuan-client.c @@ -164,7 +164,7 @@ assuan_transact (assuan_context_t ctx, rc = atoi (line); if (rc > 0 && rc < 100) rc = _assuan_error (ASSUAN_Server_Fault); - else if (rc > 0 && rc <= 128) + else if (rc > 0 && rc <= 405) rc = _assuan_error (rc); } else if (okay == 2) diff --git a/assuan/assuan-connect.c b/assuan/assuan-connect.c index 92995d8c..15fc51b9 100644 --- a/assuan/assuan-connect.c +++ b/assuan/assuan-connect.c @@ -62,6 +62,7 @@ assuan_get_pid (assuan_context_t ctx) /* Return user credentials. PID, UID and GID amy be gived as NULL if you are not interested in this value. For getting the pid of the peer the assuan_get_pid is usually better suited. */ +#ifndef HAVE_W32_SYSTEM assuan_error_t assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) { @@ -77,3 +78,4 @@ assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) *gid = ctx->peercred.gid; return 0; } +#endif /* HAVE_W32_SYSTEM */ diff --git a/assuan/assuan-defs.h b/assuan/assuan-defs.h index fa04f0b2..33cdfa3d 100644 --- a/assuan/assuan-defs.h +++ b/assuan/assuan-defs.h @@ -140,12 +140,14 @@ struct assuan_context_s int listen_fd; /* The fd we are listening on (used by socket servers) */ int connected_fd; /* helper */ +#ifndef HAVE_W32_SYSTEM struct { - int valid; /* Whether this structure has valid information. */ + int valid; /* Whether this structure has valid information. */ pid_t pid; /* The pid of the peer. */ uid_t uid; /* The uid of the peer. */ gid_t gid; /* The gid of the peer. */ } peercred; +#endif /* HAVE_W32_SYSTEM */ /* Used for Unix domain sockets. */ struct sockaddr_un myaddr; @@ -259,6 +261,8 @@ void _assuan_free (void *p); #ifdef HAVE_W32_SYSTEM const char *_assuan_w32_strerror (int ec); #define w32_strerror(e) _assuan_w32_strerror ((e)) +int _assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen); +const char *_assuan_gpg_strsource (unsigned int err); #endif /*HAVE_W32_SYSTEM*/ @@ -280,8 +284,13 @@ pid_t _assuan_waitpid (pid_t pid, int *status, int options); ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size); ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size); +#ifdef HAVE_W32_SYSTEM +int _assuan_simple_sendmsg (assuan_context_t ctx, void *msg); +int _assuan_simple_recvmsg (assuan_context_t ctx, void *msg); +#else ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg); ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg); +#endif /*-- assuan-socket.c --*/ int _assuan_close (int fd); diff --git a/assuan/assuan-handler.c b/assuan/assuan-handler.c index 866db225..45a901c7 100644 --- a/assuan/assuan-handler.c +++ b/assuan/assuan-handler.c @@ -142,8 +142,8 @@ assuan_command_parse_fd (assuan_context_t ctx, char *line, int *rfd) { char *endp; - if ( (strncmp (line, "FD", 2) && strncmp (line, "fd", 2)) - || (line[2] != '=' && line[2] != '\0')) + if ((strncmp (line, "FD", 2) && strncmp (line, "fd", 2)) + || (line[2] != '=' && line[2] != '\0' && !spacep(&line[2]))) return set_error (ctx, Syntax_Error, "FD[=] expected"); line += 2; if (*line == '=') @@ -509,7 +509,24 @@ process_request (assuan_context_t ctx) { const char *text = ctx->err_no == rc? ctx->err_str:NULL; -#if defined(__GNUC__) && defined(__ELF__) +#if defined(HAVE_W32_SYSTEM) + unsigned int source, code; + char ebuf[50]; + const char *esrc; + + source = ((rc >> 24) & 0xff); + code = (rc & 0x00ffffff); + if (source + && !_assuan_gpg_strerror_r (rc, ebuf, sizeof ebuf) + && (esrc=_assuan_gpg_strsource (rc))) + { + /* Assume this is an libgpg-error. */ + sprintf (errline, "ERR %d %.50s <%.30s>%s%.100s", + rc, ebuf, esrc, + text? " - ":"", text?text:""); + } + else +#elif defined(__GNUC__) && defined(__ELF__) /* If we have weak symbol support we try to use the error strings from libgpg-error without creating a dependency. They are used for debugging purposes only, so there is no @@ -526,7 +543,7 @@ process_request (assuan_context_t ctx) __attribute__ ((weak)); const char *gpg_strsource (unsigned int err) __attribute__ ((weak)); -#if !defined(HAVE_W32_SYSTEM) && __GNUC__ < 3 +#if __GNUC__ < 3 #pragma weak gpg_strerror_r #pragma weak gpg_strsource #endif diff --git a/assuan/assuan-io.c b/assuan/assuan-io.c index d1f0d5e4..6d895791 100644 --- a/assuan/assuan-io.c +++ b/assuan/assuan-io.c @@ -25,7 +25,9 @@ #include #include -#include +#ifdef HAVE_SYS_SOCKET_H +# include +#endif #include #include #ifdef HAVE_W32_SYSTEM @@ -49,18 +51,69 @@ _assuan_waitpid (pid_t pid, int *status, int options) ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) { +#ifdef HAVE_W32_SYSTEM + /* Due to the peculiarities of the W32 API we can't use read for a + network socket and thus we try to use recv first and fallback to + read if recv detects that it is not a network socket. */ + int n; + + n = recv (ctx->inbound.fd, buffer, size, 0); + if (n == -1 && WSAGetLastError () == WSAENOTSOCK) + { + DWORD nread = 0; + + n = ReadFile ((HANDLE)ctx->inbound.fd, buffer, size, &nread, NULL); + if (!n) + { + errno = EIO; /* FIXME: We should have a proper mapping. */ + n = -1; + } + else + n = (int)nread; + } + return n; +#else /*!HAVE_W32_SYSTEM*/ return read (ctx->inbound.fd, buffer, size); +#endif /*!HAVE_W32_SYSTEM*/ } ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size) { +#ifdef HAVE_W32_SYSTEM + /* Due to the peculiarities of the W32 API we can't use write for a + network socket and thus we try to use send first and fallback to + write if send detects that it is not a network socket. */ + int n; + + n = send (ctx->outbound.fd, buffer, size, 0); + if (n == -1 && WSAGetLastError () == WSAENOTSOCK) + { + DWORD nwrite; + + n = WriteFile ((HANDLE)ctx->outbound.fd, buffer, size, &nwrite, NULL); + if (!n) + { + errno = EIO; /* FIXME: We should have a proper mapping. */ + n = -1; + } + else + n = (int)nwrite; + } + return n; +#else /*!HAVE_W32_SYSTEM*/ return write (ctx->outbound.fd, buffer, size); +#endif /*!HAVE_W32_SYSTEM*/ } +#ifdef HAVE_W32_SYSTEM +int +_assuan_simple_sendmsg (assuan_context_t ctx, void *msg) +#else ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg) +#endif { #ifdef HAVE_W32_SYSTEM return _assuan_error (ASSUAN_Not_Implemented); @@ -73,8 +126,13 @@ _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg) } +#ifdef HAVE_W32_SYSTEM +int +_assuan_simple_recvmsg (assuan_context_t ctx, void *msg) +#else ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg) +#endif { #ifdef HAVE_W32_SYSTEM return _assuan_error (ASSUAN_Not_Implemented); diff --git a/assuan/assuan-logging.c b/assuan/assuan-logging.c index cfc3d846..5d4f2bb1 100644 --- a/assuan/assuan-logging.c +++ b/assuan/assuan-logging.c @@ -1,5 +1,5 @@ /* assuan-logging.c - Default logging function. - * Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + * Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. * * This file is part of Assuan. * @@ -238,4 +238,51 @@ _assuan_w32_strerror (int ec) strerr, sizeof (strerr)-1, NULL); return strerr; } + +static int (*my_strerror_r) (unsigned int err, char *buf, size_t buflen); +static const char * (*my_strsource) (unsigned int err); + +static int +load_libgpg_error (void) +{ + /* This code is not race free but suitable for our purpose. */ + static volatile int initialized; + void *handle; + + if (initialized) + return (my_strerror_r && my_strsource)? 0:-1; + handle = LoadLibrary ("libgpg-error-0.dll"); + if (handle) + { + void *foo, *bar; + foo = GetProcAddress (handle, "gpg_strerror_r"); + bar = GetProcAddress (handle, "gpg_strsource"); + if (foo && bar) + { + my_strerror_r = foo; + my_strsource = bar; + } + else + CloseHandle (handle); + } + initialized = 1; + return 0; +} + +int +_assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen) +{ + if (load_libgpg_error ()) + return -1; + return my_strerror_r (err, buf, buflen); +} + + +const char * +_assuan_gpg_strsource (unsigned int err) +{ + if (load_libgpg_error ()) + return NULL; + return my_strsource (err); +} #endif /*HAVE_W32_SYSTEM*/ diff --git a/assuan/assuan-pipe-connect.c b/assuan/assuan-pipe-connect.c index 8ee9c748..867dc84f 100644 --- a/assuan/assuan-pipe-connect.c +++ b/assuan/assuan-pipe-connect.c @@ -554,7 +554,7 @@ socketpair_connect (assuan_context_t *ctx, /* Build a command line for use with W32's CreateProcess. On success CMDLINE gets the address of a newly allocated string. */ static int -build_w32_commandline (char * const *argv, char **cmdline) +build_w32_commandline (const char * const *argv, char **cmdline) { int i, n; const char *s; diff --git a/assuan/assuan-pipe-server.c b/assuan/assuan-pipe-server.c index f8851614..1b47def5 100644 --- a/assuan/assuan-pipe-server.c +++ b/assuan/assuan-pipe-server.c @@ -92,6 +92,7 @@ _assuan_new_context (assuan_context_t *r_ctx) /* Returns true if atoi(S) denotes a valid socket. */ +#ifndef HAVE_W32_SYSTEM static int is_valid_socket (const char *s) { @@ -101,6 +102,7 @@ is_valid_socket (const char *s) return 0; return S_ISSOCK (buf.st_mode); } +#endif /*!HAVE_W32_SYSTEM*/ int diff --git a/assuan/assuan-socket-server.c b/assuan/assuan-socket-server.c index 45c227d6..5c461644 100644 --- a/assuan/assuan-socket-server.c +++ b/assuan/assuan-socket-server.c @@ -25,13 +25,19 @@ #include #include #include -#ifndef HAVE_W32_SYSTEM -#include -#include +#ifdef HAVE_W32_SYSTEM +# include +# if HAVE_SYS_SOCKET_H +# include +# elif HAVE_WS2TCPIP_H +# include +# endif #else -#include +# include +# include #endif + #include "assuan-defs.h" static struct assuan_io io = { _assuan_simple_read, diff --git a/assuan/assuan-uds.c b/assuan/assuan-uds.c index 77945fb5..70ec8ccc 100644 --- a/assuan/assuan-uds.c +++ b/assuan/assuan-uds.c @@ -111,6 +111,8 @@ uds_reader (assuan_context_t ctx, void *buf, size_t buflen) len = _assuan_simple_recvmsg (ctx, &msg); if (len < 0) return -1; + if (len == 0) + return 0; ctx->uds.buffersize = len; ctx->uds.bufferoffset = 0; @@ -150,7 +152,7 @@ uds_reader (assuan_context_t ctx, void *buf, size_t buflen) if (len > buflen) /* We have more than the user requested. */ len = buflen; - memcpy (buf, ctx->uds.buffer + ctx->uds.bufferoffset, len); + memcpy (buf, (char*)ctx->uds.buffer + ctx->uds.bufferoffset, len); ctx->uds.buffersize -= len; assert (ctx->uds.buffersize >= 0); ctx->uds.bufferoffset += len; diff --git a/assuan/assuan.h b/assuan/assuan.h index cdf0445a..5aa91854 100644 --- a/assuan/assuan.h +++ b/assuan/assuan.h @@ -460,8 +460,10 @@ assuan_error_t assuan_socket_connect_ext (assuan_context_t *ctx, /*-- assuan-connect.c --*/ void assuan_disconnect (assuan_context_t ctx); pid_t assuan_get_pid (assuan_context_t ctx); +#ifndef HAVE_W32_SYSTEM assuan_error_t assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid); +#endif /*-- assuan-client.c --*/ assuan_error_t diff --git a/autogen.sh b/autogen.sh index 5650a695..fc61c5f3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -31,7 +31,7 @@ check_version () { DIE=no FORCE= -if test "$1" == "--force"; then +if test "$1" = "--force"; then FORCE=" --force" shift fi