[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#338290: Can't start X twice on GNU/kFreeBSD



Package: xorg-x11
Version: 6.8.2.dfsg.1-10
Tags: patch

Hi,

this bug started as 
http://lists.alioth.debian.org/pipermail/glibc-bsd-devel/2005-November/000628.html

On debian/kFreeBSD is not defined HasBSD44Sockets.
It shouldn't be problem because FreeBSD kernel 5.4 and 6.0 
tries to be compatible with older (BSD43) source code
and at least in connect(), bind() ignores value in the field sun_len.
It uses only the value addrlen from function in system call.

Unfortunately, we are hitted by computing the whole name length as
namelen = strlen(sockname.sun_path) + sizeof(sockname.sun_family);
instead of portable
namelen = strlen(sockname.sun_path) + offsetof(struct sockaddr_un, sun_path);

Therefore, it is sufficient to correct calculation with sun_path in 
whole xorg-x11. Moreover, it is mainly correct, only 2 files need fix.

ok      programs/xdm/prngc.c
ok      programs/xdm/xdmcp.c
ok      programs/xdm/netaddr.c
patch   lib/dps/csconndi.c
patch   lib/xtrans/Xtranssock.c
ok      lib/xtrans/Xtranstli.c
ok      lib/xtrans/Xtranslcl.c
ok      lib/xtrans/Xtransutil.c
ok      extras/Mesa/src/glx/mini/miniglx_events.c       

Submitted also upstream in 
https://bugs.freedesktop.org/show_bug.cgi?id=4982

The enclosed patch adds debian/patches/freebsd/004_gnu-kbsd_sock_un.diff
and inserts it in debian/patches/series.
Could you please apply it.
Thanks in advance

			Petr


The patch have been tested:

---------- Forwarded message ----------
Date: Wed, 9 Nov 2005 03:37:01 +0000
From: Brian M. Carlson <sandals@crustytoothpaste.ath.cx>

> I converted my patch into appropriate form.
> Can you please test it ?

It works, very nicely.  A couple caveats: if you rebuild, you must reinstall 
at least all of the binary packages with the fixed version, otherwise, it 
doesn't work.  Also, after installing the fixed version, I'd consider 
restarting, otherwise it can't connect.  Other than that, no problem.  BTW, I 
don't think these problems are specific to your patch, just that X is finicky 
like that.  You have my vote to submit.

-- 
Brian M. Carlson <sandals@crustytoothpaste.ath.cx>
Running on GNU/kFreeBSD; i686-pc-kfreebsd-gnu
Support alternative kernels in Debian!
diff -u xorg-x11-6.8.2.dfsg.1/debian/patches/series xorg-x11-6.8.2.dfsg.1/debian/patches/series
--- xorg-x11-6.8.2.dfsg.1/debian/patches/series
+++ xorg-x11-6.8.2.dfsg.1/debian/patches/series
@@ -149,6 +149,7 @@
 freebsd/001_gnu-kbsd.diff -p0
 freebsd/002_gnu-kbsd_wacom.diff -p0
 freebsd/003_gnu-kbsd_sessreg.diff -p0
+freebsd/004_gnu-kbsd_sock_un.diff -p0
 debian/900_debian_config.diff -p0
 debian/902_debian_startx_manpage.diff -p0
 debian/903_debian_system.twmrc.diff -p0
--- xorg-x11-6.8.2.dfsg.1.orig/debian/patches/freebsd/004_gnu-kbsd_sock_un.diff
+++ xorg-x11-6.8.2.dfsg.1/debian/patches/freebsd/004_gnu-kbsd_sock_un.diff
@@ -0,0 +1,44 @@
+Index: xc/lib/dps/csconndi.c
+===================================================================
+--- xc/lib/dps/csconndi.c.orig	2005-02-28 17:35:18.000000000 +0000
++++ xc/lib/dps/csconndi.c	2005-11-08 08:21:30.000000000 +0000
+@@ -506,7 +506,7 @@
+     sprintf (unaddr.sun_path, "%s_%d", CSDPS_UNIX_PATH, port);
+ 
+     addr = (struct sockaddr *) &unaddr;
+-    addrlen = strlen(unaddr.sun_path) + sizeof(unaddr.sun_family);
++    addrlen = strlen(unaddr.sun_path) + offsetof(struct sockaddr_un, sun_path);
+ 
+     /*
+      * Open the network connection.
+Index: xc/lib/xtrans/Xtranssock.c
+===================================================================
+--- xc/lib/xtrans/Xtranssock.c.orig	2005-11-08 08:20:49.000000000 +0000
++++ xc/lib/xtrans/Xtranssock.c	2005-11-08 08:21:30.000000000 +0000
+@@ -1096,7 +1096,7 @@
+     sockname.sun_len = strlen(sockname.sun_path);
+     namelen = SUN_LEN(&sockname);
+ #else
+-    namelen = strlen(sockname.sun_path) + sizeof(sockname.sun_family);
++    namelen = strlen(sockname.sun_path) + offsetof(struct sockaddr_un, sun_path);
+ #endif
+ 
+     unlink (sockname.sun_path);
+@@ -1979,7 +1979,7 @@
+     sockname.sun_len = strlen (sockname.sun_path);
+     namelen = SUN_LEN (&sockname);
+ #else
+-    namelen = strlen (sockname.sun_path) + sizeof (sockname.sun_family);
++    namelen = strlen (sockname.sun_path) + offsetof(struct sockaddr_un, sun_path);
+ #endif
+ 
+ 
+@@ -1993,7 +1993,7 @@
+ 	return TRANS_CONNECT_FAILED;
+     }
+     old_namelen = strlen (old_sockname.sun_path) +
+-	sizeof (old_sockname.sun_family);
++    	offsetof(struct sockaddr_un, sun_path);
+ #endif
+ 
+ 

Reply to: