diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 34 | ||||
-rw-r--r-- | src/assuan-connect.c | 2 | ||||
-rw-r--r-- | src/assuan-defs.h | 7 | ||||
-rw-r--r-- | src/assuan-io-pth.c | 23 | ||||
-rw-r--r-- | src/assuan-io.c | 60 | ||||
-rw-r--r-- | src/assuan-pipe-connect.c | 2 | ||||
-rw-r--r-- | src/assuan-pipe-server.c | 2 | ||||
-rw-r--r-- | src/assuan-socket-server.c | 14 | ||||
-rw-r--r-- | src/assuan.h | 2 | ||||
-rw-r--r-- | src/libassuan.m4 | 2 |
10 files changed, 130 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d1bc5fc..9928072 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,37 @@ +2007-06-12 Werner Koch <[email protected]> + + * assuan-io.c (_assuan_simple_read): Hack to allow reading from a + socket. + (_assuan_simple_write): Likewise. + +2007-06-11 Werner Koch <[email protected]> + + * assuan-io-pth.c (_assuan_simple_read, _assuan_simple_write): Use + pth versions also for W32. + +2007-05-29 Werner Koch <[email protected]> + + * 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 <[email protected]> + + * libassuan.m4: Print found version on success. + 2007-05-01 Werner Koch <[email protected]> * assuan-uds.c (uds_reader): Cast void ptr for arithmetics. diff --git a/src/assuan-connect.c b/src/assuan-connect.c index 92995d8..e7f01bd 100644 --- a/src/assuan-connect.c +++ b/src/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 _WIN32 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 /*_WIN32*/ diff --git a/src/assuan-defs.h b/src/assuan-defs.h index fa04f0b..58c30d4 100644 --- a/src/assuan-defs.h +++ b/src/assuan-defs.h @@ -142,9 +142,11 @@ struct assuan_context_s struct { int valid; /* Whether this structure has valid information. */ +#ifdef HAVE_SO_PEERCRED pid_t pid; /* The pid of the peer. */ uid_t uid; /* The uid of the peer. */ gid_t gid; /* The gid of the peer. */ +#endif /*HAVE_SO_PEERCRED*/ } peercred; /* Used for Unix domain sockets. */ @@ -280,8 +282,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 _WIN32 +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/src/assuan-io-pth.c b/src/assuan-io-pth.c index 13f8794..53840e5 100644 --- a/src/assuan-io-pth.c +++ b/src/assuan-io-pth.c @@ -25,8 +25,9 @@ #include <sys/time.h> #include <sys/types.h> +#ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> -#include <sys/wait.h> +#endif #if HAVE_SYS_UIO_H # include <sys/uio.h> #endif @@ -55,26 +56,22 @@ _assuan_waitpid (pid_t pid, int *status, int options) ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) { -#ifndef HAVE_W32_SYSTEM return pth_read (ctx->inbound.fd, buffer, size); -#else - return recv (ctx->inbound.fd, buffer, size, 0); -#endif } ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size) { -#ifndef HAVE_W32_SYSTEM return pth_write (ctx->outbound.fd, buffer, size); -#else - return send (ctx->outbound.fd, buffer, size, 0); -#endif } - +#ifdef _WIN32 +int +_assuan_simple_sendmsg (assuan_context_t ctx, void *msg) +#else ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg) +#endif { #if defined(HAVE_W32_SYSTEM) return _assuan_error (ASSUAN_Not_Implemented); @@ -109,9 +106,13 @@ _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg) #endif } - +#ifdef _WIN32 +int +_assuan_simple_recvmsg (assuan_context_t ctx, void *msg) +#else ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg) +#endif { #if defined(HAVE_W32_SYSTEM) return _assuan_error (ASSUAN_Not_Implemented); diff --git a/src/assuan-io.c b/src/assuan-io.c index d1f0d5e..6d89579 100644 --- a/src/assuan-io.c +++ b/src/assuan-io.c @@ -25,7 +25,9 @@ #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 @@ -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/src/assuan-pipe-connect.c b/src/assuan-pipe-connect.c index 8ee9c74..867dc84 100644 --- a/src/assuan-pipe-connect.c +++ b/src/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/src/assuan-pipe-server.c b/src/assuan-pipe-server.c index f885161..1b47def 100644 --- a/src/assuan-pipe-server.c +++ b/src/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/src/assuan-socket-server.c b/src/assuan-socket-server.c index 45c227d..5c46164 100644 --- a/src/assuan-socket-server.c +++ b/src/assuan-socket-server.c @@ -25,13 +25,19 @@ #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, diff --git a/src/assuan.h b/src/assuan.h index 9080fd3..6343ae9 100644 --- a/src/assuan.h +++ b/src/assuan.h @@ -425,8 +425,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 _WIN32 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/src/libassuan.m4 b/src/libassuan.m4 index e099b66..004eee3 100644 --- a/src/libassuan.m4 +++ b/src/libassuan.m4 @@ -74,7 +74,7 @@ AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON], fi if test $ok = yes; then - AC_MSG_RESULT(yes) + AC_MSG_RESULT([yes ($libassuan_version)]) else AC_MSG_RESULT(no) fi |