[Xcb] Bug#486530: libxcb: does not work on GNU/kFreeBSD

Petr Salinger Petr.Salinger at seznam.cz
Mon Jun 16 09:57:35 PDT 2008


Package: libxcb
Severity: important
Version: 1.1-1.1
Tags: patch
User: glibc-bsd-devel at lists.alioth.debian.org
Usertags: kfreebsd


Hi,

the current version does not work on GNU/kFreeBSD.

The GNU/kFreeBSD (and BSDs in general) have a different
layout of struct sockaddr, sockaddr_in, sockaddr_un ...

The first member do not have to be "sa_family",
they also have "sa_len" field.

Please apply attached patch and run

   ./autogen.sh

It would also be nice if you can ask upstream
to include this change.

Thanks in advance

                         Petr
-------------- next part --------------
only in patch2:
unchanged:
--- libxcb-1.1.orig/configure.ac
+++ libxcb-1.1/configure.ac
@@ -62,6 +62,14 @@
 AC_SEARCH_LIBS(getaddrinfo, socket)
 AC_SEARCH_LIBS(connect, socket)
 
+dnl check for the sockaddr_un.sun_len member
+AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
+		[AC_DEFINE(HAVE_SOCKADDR_SUN_LEN,1,[Have the sockaddr_un.sun_len member.])],
+		[],
+		[ #include <sys/types.h>
+		  #include <sys/un.h>
+		])
+								 										
 xcbincludedir='${includedir}/xcb'
 AC_SUBST(xcbincludedir)
 
only in patch2:
unchanged:
--- libxcb-1.1.orig/src/xcb_util.c
+++ libxcb-1.1/src/xcb_util.c
@@ -244,13 +244,16 @@
 static int _xcb_open_unix(char *protocol, const char *file)
 {
     int fd;
-    struct sockaddr_un addr = { AF_UNIX };
+    struct sockaddr_un addr;
 
     if (protocol && strcmp("unix",protocol))
         return -1;
 
     strcpy(addr.sun_path, file);
-
+    addr.sun_family = AF_UNIX;
+#if HAVE_SOCKADDR_SUN_LEN
+    addr.sun_len = SUN_LEN(&addr);
+#endif
     fd = socket(AF_UNIX, SOCK_STREAM, 0);
     if(fd == -1)
         return -1;


More information about the Xcb mailing list