diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 12 | ||||
-rw-r--r-- | src/assuan-buffer.c | 9 | ||||
-rw-r--r-- | src/assuan-defs.h | 2 | ||||
-rw-r--r-- | src/assuan-handler.c | 10 | ||||
-rw-r--r-- | src/assuan-io.c | 4 | ||||
-rw-r--r-- | src/assuan-uds.c | 36 |
6 files changed, 61 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index bd91192..8f83288 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,17 @@ +2006-10-10 Werner Koch <[email protected]> + + * assuan-buffer.c (assuan_sendfd): Implement a runtime detection + of implemented descripotr passing. + + * assuan-uds.c: Take care of USE_DESCRIPTOR_PASSING. + + * assuan-defs.h: Add missing semicolon. + 2006-10-09 Werner Koch <[email protected]> + * assuan-handler.c (process_request): Use weak pragma for the sake + of old gcc's. Reported by Alain Guibert. + * assuan-io.c: Removed Pth support. * assuan-io-pth.c: New. Based on assuan-io.c diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c index 5580392..228aa7c 100644 --- a/src/assuan-buffer.c +++ b/src/assuan-buffer.c @@ -490,6 +490,15 @@ assuan_send_data (assuan_context_t ctx, const void *buffer, size_t length) assuan_error_t assuan_sendfd (assuan_context_t ctx, int fd) { + /* It is explicitly allowed to use (NULL, -1) as a runtime test to + check whether descriptor passing is available. */ + if (!ctx && fd == -1) +#ifdef USE_DESCRIPTOR_PASSING + return 0; +#else + return _assuan_error (ASSUAN_Not_Implemented); +#endif + if (! ctx->io->sendfd) return set_error (ctx, Not_Implemented, "server does not support sending and receiving " diff --git a/src/assuan-defs.h b/src/assuan-defs.h index 7a96c0f..5bf1b9e 100644 --- a/src/assuan-defs.h +++ b/src/assuan-defs.h @@ -299,7 +299,7 @@ char *stpcpy (char *dest, const char *src); int setenv (const char *name, const char *value, int replace); #endif #ifndef HAVE_PUTC_UNLOCKED -int putc_unlocked (int c, FILE *stream) +int putc_unlocked (int c, FILE *stream); #endif #define DIM(v) (sizeof(v)/sizeof((v)[0])) diff --git a/src/assuan-handler.c b/src/assuan-handler.c index bf00d1a..19dab71 100644 --- a/src/assuan-handler.c +++ b/src/assuan-handler.c @@ -506,14 +506,20 @@ process_request (assuan_context_t ctx) problem if they are not available. We need to make sure that we are using ELF because only this guarantees that weak symbol support is available in case GNU ld is not - used. */ + used. It seems that old gcc versions don't implement the + weak attribute properly but it works with the weak + pragma. */ + unsigned int source, code; int gpg_strerror_r (unsigned int err, char *buf, size_t buflen) __attribute__ ((weak)); - const char *gpg_strsource (unsigned int err) __attribute__ ((weak)); +#if !defined(HAVE_W32_SYSTEM) && __GNUC__ < 3 +#pragma weak gpg_strerror_r +#pragma weak gpg_strsource +#endif source = ((rc >> 24) & 0xff); code = (rc & 0x00ffffff); diff --git a/src/assuan-io.c b/src/assuan-io.c index a1be67d..d1f0d5e 100644 --- a/src/assuan-io.c +++ b/src/assuan-io.c @@ -26,10 +26,6 @@ #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> -#include <sys/wait.h> -#if HAVE_SYS_UIO_H -# include <sys/uio.h> -#endif #include <unistd.h> #include <errno.h> #ifdef HAVE_W32_SYSTEM diff --git a/src/assuan-uds.c b/src/assuan-uds.c index c725392..77945fb 100644 --- a/src/assuan-uds.c +++ b/src/assuan-uds.c @@ -44,6 +44,26 @@ #include "assuan-defs.h" +#ifdef USE_DESCRIPTOR_PASSING +/* Provide replacement for missing CMSG maccros. We assume that + size_t matches the alignment requirement. */ +#define MY_ALIGN(n) ((((n))+ sizeof(size_t)-1) & (size_t)~(sizeof(size_t)-1)) +#ifndef CMSG_SPACE +#define CMSG_SPACE(n) (MY_ALIGN(sizeof(struct cmsghdr)) + MY_ALIGN((n))) +#endif +#ifndef CMSG_LEN +#define CMSG_LEN(n) (MY_ALIGN(sizeof(struct cmsghdr)) + (n)) +#endif +#ifndef CMSG_FIRSTHDR +#define CMSG_FIRSTHDR(mhdr) \ + ((size_t)(mhdr)->msg_controllen >= sizeof (struct cmsghdr) \ + ? (struct cmsghdr*) (mhdr)->msg_control : (struct cmsghdr*)NULL) +#endif +#ifndef CMSG_DATA +#define CMSG_DATA(cmsg) ((unsigned char*)((struct cmsghdr*)(cmsg)+1)) +#endif +#endif /*USE_DESCRIPTOR_PASSING*/ + /* Read from a unix domain socket using sendmsg. @@ -55,7 +75,6 @@ uds_reader (assuan_context_t ctx, void *buf, size_t buflen) int len = ctx->uds.buffersize; #ifndef HAVE_W32_SYSTEM - if (!ctx->uds.bufferallocated) { ctx->uds.buffer = xtrymalloc (2048); @@ -68,11 +87,13 @@ uds_reader (assuan_context_t ctx, void *buf, size_t buflen) { struct msghdr msg; struct iovec iovec; +#ifdef USE_DESCRIPTOR_PASSING union { struct cmsghdr cm; char control[CMSG_SPACE(sizeof (int))]; } control_u; struct cmsghdr *cmptr; +#endif /*USE_DESCRIPTOR_PASSING*/ memset (&msg, 0, sizeof (msg)); @@ -82,8 +103,10 @@ uds_reader (assuan_context_t ctx, void *buf, size_t buflen) msg.msg_iovlen = 1; iovec.iov_base = ctx->uds.buffer; iovec.iov_len = ctx->uds.bufferallocated; +#ifdef USE_DESCRIPTOR_PASSING msg.msg_control = control_u.control; msg.msg_controllen = sizeof (control_u.control); +#endif len = _assuan_simple_recvmsg (ctx, &msg); if (len < 0) @@ -92,6 +115,7 @@ uds_reader (assuan_context_t ctx, void *buf, size_t buflen) ctx->uds.buffersize = len; ctx->uds.bufferoffset = 0; +#ifdef USE_DESCRIPTOR_PASSING cmptr = CMSG_FIRSTHDR (&msg); if (cmptr && cmptr->cmsg_len == CMSG_LEN (sizeof(int))) { @@ -112,9 +136,13 @@ uds_reader (assuan_context_t ctx, void *buf, size_t buflen) ctx->uds.pendingfds[ctx->uds.pendingfdscount++] = fd; } } +#endif /*USE_DESCRIPTOR_PASSING*/ } + #else /*HAVE_W32_SYSTEM*/ + len = recvfrom (ctx->inbound.fd, buf, buflen, 0, NULL, NULL); + #endif /*HAVE_W32_SYSTEM*/ /* Return some data to the user. */ @@ -149,8 +177,6 @@ uds_writer (assuan_context_t ctx, const void *buf, size_t buflen) msg.msg_iov = &iovec; iovec.iov_base = (void*)buf; iovec.iov_len = buflen; - msg.msg_control = 0; - msg.msg_controllen = 0; len = _assuan_simple_sendmsg (ctx, &msg); #else /*HAVE_W32_SYSTEM*/ @@ -167,7 +193,7 @@ uds_writer (assuan_context_t ctx, const void *buf, size_t buflen) static assuan_error_t uds_sendfd (assuan_context_t ctx, int fd) { -#ifndef HAVE_W32_SYSTEM +#ifdef USE_DESCRIPTOR_PASSING struct msghdr msg; struct iovec iovec; union { @@ -217,7 +243,7 @@ uds_sendfd (assuan_context_t ctx, int fd) static assuan_error_t uds_receivefd (assuan_context_t ctx, int *fd) { -#ifndef HAVE_W32_SYSTEM +#ifdef USE_DESCRIPTOR_PASSING int i; if (!ctx->uds.pendingfdscount) |