* assuan/: Update files to 2007-07-04 version of assuan.
2007-07-04 Marcus Brinkmann <marcus@g10code.de>
+ * assuan/: Update files to 2007-07-04 version of assuan.
+
* autogen.sh: Use = not == in test.
2007-03-05 Werner Koch <wk@g10code.com>
+2007-07-04 Marcus Brinkmann <marcus@g10code.de>
+
+ 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 <wk@g10code.com>
+
+ * 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 <wk@g10code.com>
+
+ * assuan-io.c (_assuan_simple_read): Hack to allow reading from a
+ socket.
+ (_assuan_simple_write): Likewise.
+
+2007-06-11 Werner Koch <wk@g10code.com>
+
+ * assuan-io-pth.c (_assuan_simple_read, _assuan_simple_write): Use
+ pth versions also for W32.
+
+2007-05-29 Werner Koch <wk@g10code.com>
+
+ * 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 <wk@g10code.com>
+
+ * libassuan.m4: Print found version on success.
+
+2007-05-01 Werner Koch <wk@g10code.com>
+
+ * assuan-uds.c (uds_reader): Cast void ptr for arithmetics.
+ Reported by Peter O'Gorman.
+
+2006-12-03 Marcus Brinkmann <marcus@g10code.de>
+
+ * assuan-handler.c (assuan_command_parse_fd): Also allow white
+ space after FD.
+
+2006-12-02 Marcus Brinkmann <marcus@g10code.de>
+
+ * assuan-uds.c (uds_reader): Return 0 if recvmsg returns 0.
+
+2006-12-01 Marcus Brinkmann <marcus@g10code.de>
+
+ * assuan-client.c (assuan_transact): Also translate some of the
+ legacy error codes.
+
2006-11-22 Werner Koch <wk@g10code.com>
* assuan-handler.c (fun1_cookie_write, fun2_cookie_write): New.
* assuan-buffer.c (assuan_write_line): If the line is longer than
the maximum line length, bail out early.
+2004-04-21 Werner Koch <wk@gnupg.org>
+
+ * 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 <wk@gnupg.org>
- * 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 <wk@gnupg.org>
+
+ * assuan-util.c (_assuan_log_print_buffer): Relaxed quoting.
+ (_assuan_log_sanitized_string): Ditto.
+
+2004-03-14 Werner Koch <wk@gnupg.org>
+
+ * assuan-handler.c: Include <errno.h>. Reported by Bernd Kuhls.
+
2004-02-18 Werner Koch <wk@gnupg.org>
+ * 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 <wk@gnupg.org>
+
+ * memrchr.c (memrchr): Fixed implementation. Taken from gpgme.
+
2004-02-13 Werner Koch <wk@gnupg.org>
- * assuan-domain-connect.c: Removed the unneeded alloca.h
+ * assuan-domain-connect.c: Removed the unneeded alloca.h.
+
+2004-01-24 Werner Koch <wk@gnupg.org>
+
+ * 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 <wk@gnupg.org>
+
+ * 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 <wk@gnupg.org>
+
+ * assuan.h (ASSUAN_Locale_Problem): Added.
+ * assuan-errors.c (assuan_strerror): Ditto.
+
+2003-12-18 Werner Koch <wk@gnupg.org>
+
+ * 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 <wk@gnupg.org>
+
+ * 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 <wk@gnupg.org>
+
+ * 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 <wk@gnupg.org>
+
+ * TODO: Removed.
+
+2003-11-12 Werner Koch <wk@gnupg.org>
+
+ * assuan-handler.c (process_request): Kludge to print better error
+ messages for gpg-error enabled programs.
+
+2003-11-06 Werner Koch <wk@gnupg.org>
+
+ * 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 <mo@g10code.com>
+
+ * assuan-socket-connect.c (assuan_socket_connect): Fix computation
+ of socket address length.
2003-08-13 Werner Koch <wk@gnupg.org>
* 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
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
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)
/* 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)
{
*gid = ctx->peercred.gid;
return 0;
}
+#endif /* HAVE_W32_SYSTEM */
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;
#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*/
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);
{
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[=<n>] expected");
line += 2;
if (*line == '=')
{
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
__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
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/socket.h>
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
#include <unistd.h>
#include <errno.h>
#ifdef HAVE_W32_SYSTEM
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);
}
+#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);
/* 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.
*
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*/
/* 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;
/* Returns true if atoi(S) denotes a valid socket. */
+#ifndef HAVE_W32_SYSTEM
static int
is_valid_socket (const char *s)
{
return 0;
return S_ISSOCK (buf.st_mode);
}
+#endif /*!HAVE_W32_SYSTEM*/
int
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
-#ifndef HAVE_W32_SYSTEM
-#include <sys/socket.h>
-#include <sys/un.h>
+#ifdef HAVE_W32_SYSTEM
+# include <windows.h>
+# if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+# elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+# endif
#else
-#include <windows.h>
+# include <sys/socket.h>
+# include <sys/un.h>
#endif
+
#include "assuan-defs.h"
static struct assuan_io io = { _assuan_simple_read,
len = _assuan_simple_recvmsg (ctx, &msg);
if (len < 0)
return -1;
+ if (len == 0)
+ return 0;
ctx->uds.buffersize = len;
ctx->uds.bufferoffset = 0;
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;
/*-- 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
DIE=no
FORCE=
-if test "$1" == "--force"; then
+if test "$1" = "--force"; then
FORCE=" --force"
shift
fi