[svn] assuan - r218 - in trunk: . doc src tests

svn author wk cvs at cvs.gnupg.org
Tue Oct 10 12:47:05 CEST 2006


Author: wk
Date: 2006-10-10 12:47:04 +0200 (Tue, 10 Oct 2006)
New Revision: 218

Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/README
   trunk/THANKS
   trunk/configure.ac
   trunk/doc/assuan.texi
   trunk/src/ChangeLog
   trunk/src/assuan-buffer.c
   trunk/src/assuan-defs.h
   trunk/src/assuan-handler.c
   trunk/src/assuan-io.c
   trunk/src/assuan-uds.c
   trunk/tests/Makefile.am
Log:
portability fixes


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/ChangeLog	2006-10-10 10:47:04 UTC (rev 218)
@@ -1,3 +1,12 @@
+2006-10-10  Werner Koch  <wk at 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 at g10code.com>
 
 	* m4/gnupg-pth.m4: New.  Taked from GnuPG.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/NEWS	2006-10-10 10:47:04 UTC (rev 218)
@@ -1,8 +1,17 @@
-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)
 ------------------------------------------------
 

Modified: trunk/README
===================================================================
--- trunk/README	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/README	2006-10-10 10:47:04 UTC (rev 218)
@@ -13,3 +13,4 @@
 
 
 
+

Modified: trunk/THANKS
===================================================================
--- trunk/THANKS	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/THANKS	2006-10-10 10:47:04 UTC (rev 218)
@@ -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 at iki.fi
 
 
 
+

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/configure.ac	2006-10-10 10:47:04 UTC (rev 218)
@@ -25,7 +25,7 @@
 
 # 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 at gnupg.org)
+AC_INIT(libassuan, 0.9.3, gnupg-devel at gnupg.org)
 # Note, that this is not yet available as a shared library.
 
 PACKAGE=$PACKAGE_NAME
@@ -113,10 +113,10 @@
 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,7 +152,32 @@
 
 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.
 
 AC_CHECK_FUNCS(flockfile funlockfile)

Modified: trunk/doc/assuan.texi
===================================================================
--- trunk/doc/assuan.texi	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/doc/assuan.texi	2006-10-10 10:47:04 UTC (rev 218)
@@ -769,6 +769,12 @@
    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
+ at code{-1} is a valid runtime test to check whether descripor passing is
+available.
+
+ at anchor{fun-assuan_receivedfd}
 assuan_error_t assuan_receivefd (assuan_context_t ctx, int *fd);
 
 

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/src/ChangeLog	2006-10-10 10:47:04 UTC (rev 218)
@@ -1,5 +1,17 @@
+2006-10-10  Werner Koch  <wk at 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 at 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
 

Modified: trunk/src/assuan-buffer.c
===================================================================
--- trunk/src/assuan-buffer.c	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/src/assuan-buffer.c	2006-10-10 10:47:04 UTC (rev 218)
@@ -490,6 +490,15 @@
 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 "

Modified: trunk/src/assuan-defs.h
===================================================================
--- trunk/src/assuan-defs.h	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/src/assuan-defs.h	2006-10-10 10:47:04 UTC (rev 218)
@@ -299,7 +299,7 @@
 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]))

Modified: trunk/src/assuan-handler.c
===================================================================
--- trunk/src/assuan-handler.c	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/src/assuan-handler.c	2006-10-10 10:47:04 UTC (rev 218)
@@ -506,14 +506,20 @@
              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);

Modified: trunk/src/assuan-io.c
===================================================================
--- trunk/src/assuan-io.c	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/src/assuan-io.c	2006-10-10 10:47:04 UTC (rev 218)
@@ -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

Modified: trunk/src/assuan-uds.c
===================================================================
--- trunk/src/assuan-uds.c	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/src/assuan-uds.c	2006-10-10 10:47:04 UTC (rev 218)
@@ -44,7 +44,27 @@
 
 #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. 
 
    FIXME: We don't need the buffering. It is a leftover from the time
@@ -55,7 +75,6 @@
   int len = ctx->uds.buffersize;
 
 #ifndef HAVE_W32_SYSTEM
-
   if (!ctx->uds.bufferallocated)
     {
       ctx->uds.buffer = xtrymalloc (2048);
@@ -68,11 +87,13 @@
     {
       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 @@
       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 @@
       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 @@
                 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 @@
   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 @@
 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 @@
 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)

Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am	2006-10-09 11:35:35 UTC (rev 217)
+++ trunk/tests/Makefile.am	2006-10-10 10:47:04 UTC (rev 218)
@@ -27,11 +27,15 @@
 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)
 




More information about the Gnupg-commits mailing list