[gdm] Fix up XDMCP for Solaris



commit e533f4b72568cdc3d7f7ec6cec09d9392b11d54c
Author: Brian Cameron <Brian Cameron sun com>
Date:   Wed Jan 13 09:33:23 2010 -0500

    Fix up XDMCP for Solaris
    
    After doing further testing, I notice that XDMCP still does not work on
    Solaris.  This commit fixes:
    
    - In gdm-address.c, there was a problem where a failure in
      gdm_address_get_hostname could cause an infinite loop since it would call
      gdm_address_debug, which would then call gdm_address_get_hostname again.  I
      fixed this by making gdm_address_debug call a private _gdm_address_debug
      function and gdm_address_get_hostname calls _gdm_adress_debug rather than
      gdm_address_debug.
    
    - Two calls in gdm-address.c were using "sizeof (struct sockaddr_storage)"
      and changing this to "(int) gdm_sockaddr_len (address->ss)" works better.
      This is the same issue as fixed in the previous patch.  I just missed these
      spots before.
    
    - In daemon/gdm-xdmcp-display-factory.c in the on_hostname_selected() function
      it is necessary to set hints.ai_socktype to "SOCK_DGRAM" or else I would get
      this error:
    
      WARNING: Unable get address: service name not available for the specified
      socket type
    
    - In daemon/gdm-xdmcp-display-factory.c in the decode_packet() function
      and in gui/simple-chooser/gdm-host-chooser-widget.c it is necessary to set
      ss_len to "gdm_sockaddr_len (&clnt_ss)" instead of "sizeof (clnt_ss)".
    
    - In gui/simple-chooser/gdm-host-chooser-widget.c in find_broacast_address
      it is also necessary to check for "(errno != ENXIO)".
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=494817

 common/gdm-address.c                         |    2 +-
 daemon/gdm-xdmcp-display-factory.c           |   15 ++++++++++-----
 gui/simple-chooser/gdm-host-chooser-widget.c |    4 ++--
 3 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/common/gdm-address.c b/common/gdm-address.c
index 2426b9c..ce87d98 100644
--- a/common/gdm-address.c
+++ b/common/gdm-address.c
@@ -270,7 +270,7 @@ gdm_address_get_hostname (GdmAddress *address,
 
         host [0] = '\0';
         res = getnameinfo ((const struct sockaddr *)address->ss,
-                           sizeof (struct sockaddr_storage),
+                           (int) gdm_sockaddr_len (address->ss),
                            host, sizeof (host),
                            NULL, 0,
                            0);
diff --git a/daemon/gdm-xdmcp-display-factory.c b/daemon/gdm-xdmcp-display-factory.c
index f557eda..7b5fb53 100644
--- a/daemon/gdm-xdmcp-display-factory.c
+++ b/daemon/gdm-xdmcp-display-factory.c
@@ -1518,9 +1518,12 @@ create_address_from_request (ARRAY8      *req_addr,
 
         memset (&hints, 0, sizeof (hints));
         hints.ai_family = family;
-        hints.ai_flags = AI_V4MAPPED; /* this should convert IPv4 address to IPv6 if needed */
+        /* this should convert IPv4 address to IPv6 if needed */
+        hints.ai_flags = AI_V4MAPPED;
+        hints.ai_socktype = SOCK_DGRAM;
+
         if ((gaierr = getaddrinfo (host, serv, &hints, &ai_list)) != 0) {
-                g_warning ("Unable get address: %s", gai_strerror (gaierr));
+                g_warning ("Unable to get address: %s", gai_strerror (gaierr));
                 return FALSE;
         }
 
@@ -1997,9 +2000,11 @@ on_hostname_selected (GdmXdmcpChooserDisplay *display,
 
         memset (&hints, 0, sizeof (hints));
         hints.ai_family = gdm_address_get_family_type (address);
-        hints.ai_flags = AI_V4MAPPED; /* this should convert IPv4 address to IPv6 if needed */
+        /* this should convert IPv4 address to IPv6 if needed */
+        hints.ai_flags = AI_V4MAPPED;
+
         if ((gaierr = getaddrinfo (hostname, NULL, &hints, &ai_list)) != 0) {
-                g_warning ("Unable get address: %s", gai_strerror (gaierr));
+                g_warning ("Unable to get address: %s", gai_strerror (gaierr));
                 return;
         }
 
@@ -2837,12 +2842,12 @@ decode_packet (GIOChannel             *source,
                 return TRUE;
         }
 
-        ss_len = sizeof (clnt_ss);
         res = XdmcpFill (factory->priv->socket_fd, &factory->priv->buf, (XdmcpNetaddr)&clnt_ss, &ss_len);
         if G_UNLIKELY (! res) {
                 g_debug ("GdmXdmcpDisplayFactory: Could not create XDMCP buffer!");
                 return TRUE;
         }
+        ss_len = (int)gdm_sockaddr_len (&clnt_ss);
 
         res = XdmcpReadHeader (&factory->priv->buf, &header);
         if G_UNLIKELY (! res) {
diff --git a/gui/simple-chooser/gdm-host-chooser-widget.c b/gui/simple-chooser/gdm-host-chooser-widget.c
index 085cf5d..e694728 100644
--- a/gui/simple-chooser/gdm-host-chooser-widget.c
+++ b/gui/simple-chooser/gdm-host-chooser-widget.c
@@ -208,12 +208,12 @@ decode_packet (GIOChannel           *source,
                 return TRUE;
         }
 
-        ss_len = sizeof (clnt_ss);
         res = XdmcpFill (widget->priv->socket_fd, &buf, (XdmcpNetaddr)&clnt_ss, &ss_len);
         if G_UNLIKELY (! res) {
                 g_debug (_("XDMCP: Could not create XDMCP buffer!"));
                 return TRUE;
         }
+        ss_len = (int)gdm_sockaddr_len (&clnt_ss);
 
         res = XdmcpReadHeader (&buf, &header);
         if G_UNLIKELY (! res) {
@@ -443,7 +443,7 @@ find_broadcast_addresses (GdmHostChooserWidget *widget)
                         /* paranoia */
                         ifreq.ifr_name[sizeof (ifreq.ifr_name) - 1] = '\0';
 
-                        if (ioctl (sock, SIOCGIFFLAGS, &ifreq) < 0) {
+                        if ((ioctl (sock, SIOCGIFFLAGS, &ifreq) < 0) && (errno != ENXIO)) {
                                 g_warning ("Could not get SIOCGIFFLAGS for %s", ifr[i].ifr_name);
                         }
 



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