Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jun 2008 13:04:38 +0800
From:      Volker Stolz <vs@FreeBSD.org>
To:        gnome@FreeBSD.org
Subject:   Issue with gdmchooser (2.20.6)
Message-ID:  <7D63219B-DB97-41D1-B4DE-F191F0F93FD6@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--Apple-Mail-54--332922810
Content-Type: multipart/mixed; boundary=Apple-Mail-53--332922902


--Apple-Mail-53--332922902
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed;
	delsp=yes
Content-Transfer-Encoding: 7bit

Hi guys, I was playing with XDMCP and the gdmchooser drops the  
following in syslog when looking for local interfaces to broadcast on:

Jun 23 12:32:13 pc139 gdmchooser[37872]: CRITICAL: Could not get  
SIOCGIFFLAGS for ^\b
Jun 23 12:32:13 pc139 gdmchooser[37872]: CRITICAL: Could not get  
SIOCGIFFLAGS for 8^R^C

It looks like there's something going wrong (I'm on 7.0-R with a  
bge0,plip0,lo0), and we don't have the SIOCGIFNUM ioctl anyway. Is  
someone interested in getting something like the following patch into  
the port and/or upstream? [Note that I usually don't program in C ;)]

Volker


--Apple-Mail-53--332922902
Content-Disposition: attachment;
	filename=gdmchooser.diff
Content-Type: application/octet-stream; x-unix-mode=0700;
	name="gdmchooser.diff"
Content-Transfer-Encoding: 7bit

--- gdmchooser.c.orig	2008-06-23 12:20:46.000000000 +0800
+++ gdmchooser.c	2008-06-23 12:50:09.000000000 +0800
@@ -43,6 +43,7 @@
 #ifdef HAVE_SYS_SOCKIO_H
 #include <sys/sockio.h>
 #endif
+#include <ifaddrs.h>
 
 #include <X11/Xmd.h>
 #include <X11/Xdmcp.h>
@@ -688,64 +689,32 @@
 static void
 gdm_chooser_find_bcaddr (void)
 {
-	int i = 0, num;
-	int sock;
-	struct ifconf ifc;
-	char *buf;
-	struct ifreq *ifr;
+	struct ifaddrs *ifap;
+	struct ifaddrs *p;
 
-	sock = socket (AF_INET, SOCK_DGRAM, 0);
-#ifdef SIOCGIFNUM
-	if (ioctl (sock, SIOCGIFNUM, &num) < 0) {
-		num = 64;
-	}
-#else
-	num = 64;
-#endif
-
-	ifc.ifc_len = sizeof (struct ifreq) * num;
-	ifc.ifc_buf = buf = g_malloc0 (ifc.ifc_len);
-	if (ioctl (sock, SIOCGIFCONF, &ifc) < 0) {
-		g_free (buf);
-		gdm_common_error ("Could not get local addresses!");
-		close (sock);
+	if (getifaddrs(&ifap) != 0) {
+		gdm_common_error ("getifaddr() failed!");
 		return;
 	}
 
-	ifr = ifc.ifc_req;
-	num = ifc.ifc_len / sizeof (struct ifreq);
-	for (i = 0 ; i < num ; i++) {
-		if ( ! ve_string_empty (ifr[i].ifr_name)) {
-			struct ifreq ifreq;
-			struct sockaddr_in *ba = NULL;
-			struct sockaddr_in *sin = NULL;
-
-			memset (&ifreq, 0, sizeof (ifreq));
-
-			strncpy (ifreq.ifr_name, ifr[i].ifr_name,
-				 sizeof (ifreq.ifr_name));
-			/* paranoia */
-			ifreq.ifr_name[sizeof (ifreq.ifr_name) - 1] = '\0';
-
-			if (ioctl (sock, SIOCGIFFLAGS, &ifreq) < 0) 
-				gdm_common_error ("Could not get SIOCGIFFLAGS for %s", ifr[i].ifr_name);
-
-			if ((ifreq.ifr_flags & IFF_UP) == 0 ||
-			    (ifreq.ifr_flags & IFF_BROADCAST) == 0 ||
-			    ioctl (sock, SIOCGIFBRDADDR, &ifreq) < 0)
+	for (p = ifap ;  p->ifa_next != NULL; p=p->ifa_next) {
+                        struct sockaddr_in *ba = NULL;
+                        struct sockaddr_in *sin = NULL;
+
+			if ((p->ifa_flags & IFF_UP) == 0 ||
+			    (p->ifa_flags & IFF_BROADCAST) == 0 ||
+			    p->ifa_broadaddr == NULL)
 				continue;
 
-			ba = (struct sockaddr_in *) &ifreq.ifr_broadaddr;
+			ba = (struct sockaddr_in *) &p->ifa_broadaddr;
 
 			sin = g_new0 (struct sockaddr_in, 1);
 
 			sin->sin_family = AF_INET;
 			memcpy (&sin->sin_addr, &ba->sin_addr, sizeof (ba->sin_addr));
 			bcaddr =  g_slist_append (bcaddr, sin);
-		}
 	}
-
-	g_free (buf);
+	freeifaddrs(ifap);
 }
 
 /* Append multicast address into the list */

--Apple-Mail-53--332922902
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed
Content-Transfer-Encoding: 7bit


-- 
"In Macao ist alles besser!"
http://lambda.foldr.org/~vs/



--Apple-Mail-53--332922902--

--Apple-Mail-54--332922810
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQCVAwUBSF8u5hLpPok/0ba1AQJtvAQAxsg9x6rGUgoAhSXEVbCXr+sdW0UV0hKo
eJv2mZDkThzHrsyS+a/R8gLY7xfiFF9b+D7I/q48brzOr86S9Fev6vIINDVangu6
E/xpOgybWBTScj7D/Ji0xosEfsvQPcgha9CHJyiw+b2HgV7Y3KH6qRytA3msiZ7j
M4RyN1SX2w8=
=sLkL
-----END PGP SIGNATURE-----

--Apple-Mail-54--332922810--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7D63219B-DB97-41D1-B4DE-F191F0F93FD6>