diff options
author | Werner Koch <wk@gnupg.org> | 2006-10-10 10:47:04 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2006-10-10 10:47:04 +0000 |
commit | 51eedb216b8191094bb625017bb9f0c357a1d171 (patch) | |
tree | 149263e7a4188a3c59110a943b0c7a2a343f462f | |
parent | fa35790126e1d8246cb91ec3b4b0995902703698 (diff) | |
download | libassuan-51eedb216b8191094bb625017bb9f0c357a1d171.tar.gz |
portability fixeslibassuan-0.9.3
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | NEWS | 11 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | THANKS | 3 | ||||
-rw-r--r-- | configure.ac | 33 | ||||
-rw-r--r-- | doc/assuan.texi | 6 | ||||
-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 | ||||
-rw-r--r-- | tests/Makefile.am | 8 |
13 files changed, 125 insertions, 19 deletions
@@ -1,3 +1,12 @@ +2006-10-10 Werner Koch <wk@g10code.com> + + Released 0.9.3. + + * tests/Makefile.am (LDADD): Add NETLIBS. + + * configure.ac: Check for cmsghdr. + (USE_DESCRIPTOR_PASSING): Define it then. + 2006-10-09 Werner Koch <wk@g10code.com> * m4/gnupg-pth.m4: New. Taked from GnuPG. @@ -1,6 +1,15 @@ -Noteworthy changes in version 0.9.3 +Noteworthy changes in version 0.9.3 (2006-10-10) ------------------------------------------------ + * Portability fixes. + + * Pth is not anymore linked by means of weak symbol tricks. It is + now required to link to the pth version of libassuan. New aufoconf + macros are provided to to check for this. The pth version is only + build if Pth is available. + + * configure does now check that descripotor passing is available. A + way to check at runtime for this is also provided Noteworthy changes in version 0.9.2 (2006-10-04) @@ -13,3 +13,4 @@ software itself and COPYING for the documentation. + @@ -1,7 +1,10 @@ +Alain Guibert alguibert+gpd at free.fr Marc Mutz mutz at kde.org Michael Nottebrock michaelnottebrock at gmx.net +Nelson H. F. Beebe beebe at math dot utah dot edu Ville Skyttä ville.skytta@iki.fi + diff --git a/configure.ac b/configure.ac index 0c8bdff..44d0b9b 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ min_automake_version="1.9.3" # Version number: Remember to change it immediately *after* a release. # Add a "-cvs" prefix for non-released code. -AC_INIT(libassuan, 0.9.3-cvs, gnupg-devel@gnupg.org) +AC_INIT(libassuan, 0.9.3, gnupg-devel@gnupg.org) # Note, that this is not yet available as a shared library. PACKAGE=$PACKAGE_NAME @@ -113,10 +113,10 @@ GNUPG_PATH_PTH AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes") -# Check for network libraries. -NETLIBS= +# Check for network libraries. They are needed for tests. AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt, - [NETLIBS="-lsocket"])) + [NETLIBS="-lsocket $NETLIBS"])) +AC_SUBST(NETLIBS) # For src/libassuan-config.in LIBASSUAN_CONFIG_LIB="-lassuan" @@ -152,6 +152,31 @@ AC_DECL_SYS_SIGLIST gl_TYPE_SOCKLEN_T +AC_CHECK_MEMBER(struct cmsghdr.cmsg_len, + [use_descriptor_passing=yes], + [use_descriptor_passing=no + AC_MSG_WARN([ +*** +*** Data structure for sending ancillary data missing. +*** Descriptor passing won't work. +***])],[ +#include <stdlib.h> +#include <stddef.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/un.h> +#if HAVE_SYS_UIO_H +#include <sys/uio.h> +#endif +#include <unistd.h> + ]) +if test "$use_descriptor_passing" = "yes"; then + AC_DEFINE(USE_DESCRIPTOR_PASSING, 1, + [Defined if descriptor passing is supported]) +fi +AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes") + # Checks for library functions. diff --git a/doc/assuan.texi b/doc/assuan.texi index d83a812..7bd3ba1 100644 --- a/doc/assuan.texi +++ b/doc/assuan.texi @@ -769,6 +769,12 @@ assuan_transact (assuan_context_t ctx, trigger is sent (normally via assuan_write_line ("INPUT FD")). */ @anchor{fun-assuan_sendfd} assuan_error_t assuan_sendfd (assuan_context_t ctx, int fd); + +Note, that calling this with a @var{ctx} of @code{NULL} and @var{fd} of +@code{-1} is a valid runtime test to check whether descripor passing is +available. + +@anchor{fun-assuan_receivedfd} assuan_error_t assuan_receivefd (assuan_context_t ctx, int *fd); 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 <wk@g10code.com> + + * 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 <wk@g10code.com> + * 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) diff --git a/tests/Makefile.am b/tests/Makefile.am index 4a9ab81..1a8418a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,11 +27,15 @@ EXTRA_DIST = motd BUILT_SOURCES = CLEANFILES = -TESTS = fdpassing +TESTS = + +if USE_DESCRIPTOR_PASSING +TESTS += fdpassing +endif AM_CFLAGS = # $(GPG_ERROR_CFLAGS) noinst_HEADERS = common.h noinst_PROGRAMS = $(TESTS) -LDADD = ../src/libassuan.a # $(GPG_ERROR_LIBS) +LDADD = ../src/libassuan.a $(NETLIBS) # $(GPG_ERROR_LIBS) |