Fix for GDM and ConsoleKit modules gnome-2-30-s11rr-sru S11SRU8_03
authoran230044
Tue, 22 May 2012 09:47:58 +0000
branchgnome-2-30-s11rr-sru
changeset 22458 c4117c9bd9e0
parent 22457 9cc9e01bb036
Fix for GDM and ConsoleKit modules CRs 7121864 7120515 7116014 7110596 7094175 7093681 7096672 7146593 RTIs 362787, 362788 and 362785
patches/gdm-35-restart.diff
patches/gdm-36-no-remote-layout.diff
patches/gdm-37-strndup.diff
patches/gdm-38-bindtextdomaincodeset.diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/gdm-35-restart.diff	Tue May 22 09:47:58 2012 +0000
@@ -0,0 +1,84 @@
+--- gdm-2.30.7/daemon/gdm-display.c-orig	2011-11-07 14:42:01.572478571 -0600
++++ gdm-2.30.7/daemon/gdm-display.c	2011-11-07 15:24:09.006440701 -0600
+@@ -62,7 +62,8 @@ struct GdmDisplayPrivate
+         char                 *x11_display_type;
+         int                   status;
+         time_t                creation_time;
+-        GTimer               *slave_timer;
++        int                   num_failures;
++        gint64                time_last_start;
+         char                 *slave_command;
+ 
+         char                 *x11_cookie;
+@@ -654,8 +655,6 @@ gdm_display_real_manage (GdmDisplay *dis
+ 
+         g_assert (display->priv->slave_proxy != NULL);
+ 
+-        g_timer_start (display->priv->slave_timer);
+-
+         gdm_slave_proxy_start (display->priv->slave_proxy);
+ 
+         return TRUE;
+@@ -670,6 +669,10 @@ gdm_display_manage (GdmDisplay *display)
+ 
+         g_debug ("GdmDisplay: Managing display: %s", display->priv->id);
+ 
++        if (display->priv->time_last_start == 0) {
++                display->priv->time_last_start = g_get_monotonic_time();
++        }
++
+         g_object_ref (display);
+         ret = GDM_DISPLAY_GET_CLASS (display)->manage (display);
+         g_object_unref (display);
+@@ -714,8 +717,6 @@ gdm_display_real_unmanage (GdmDisplay *d
+ 
+         g_debug ("GdmDisplay: unmanage display");
+ 
+-        g_timer_stop (display->priv->slave_timer);
+-
+         if (display->priv->slave_proxy != NULL) {
+                 gdm_slave_proxy_stop (display->priv->slave_proxy);
+ 
+@@ -735,9 +736,18 @@ gdm_display_real_unmanage (GdmDisplay *d
+                 display->priv->access_file = NULL;
+         }
+ 
+-        elapsed = g_timer_elapsed (display->priv->slave_timer, NULL);
+-        if (elapsed < 3) {
+-                g_warning ("GdmDisplay: display lasted %lf seconds", elapsed);
++        elapsed = (g_get_monotonic_time() - display->priv->time_last_start) / 1000000;
++        g_debug ("GdmDisplay: Elapsed time since last start: %lf", elapsed);
++        if (elapsed > 60) {
++                display->priv->num_failures = 0;
++                display->priv->time_last_start = g_get_monotonic_time();
++        } else {
++                display->priv->num_failures++;
++                g_debug ("GdmDisplay: Number of failures=%d", display->priv->num_failures);
++        }
++            
++        if (display->priv->num_failures >= 5) {
++                g_warning ("GdmDisplay: Display %s failed 5 times in %lf seconds, no longer managing display", display->priv->id, elapsed);
+                 _gdm_display_set_status (display, GDM_DISPLAY_FAILED);
+         } else {
+                 _gdm_display_set_status (display, GDM_DISPLAY_UNMANAGED);
+@@ -1302,7 +1312,8 @@ gdm_display_init (GdmDisplay *display)
+         display->priv = GDM_DISPLAY_GET_PRIVATE (display);
+ 
+         display->priv->creation_time = time (NULL);
+-        display->priv->slave_timer = g_timer_new ();
++        display->priv->time_last_start = 0;
++        display->priv->num_failures = 0;
+ }
+ 
+ static void
+@@ -1336,10 +1347,6 @@ gdm_display_finalize (GObject *object)
+                 g_object_unref (display->priv->user_access_file);
+         }
+ 
+-        if (display->priv->slave_timer != NULL) {
+-                g_timer_destroy (display->priv->slave_timer);
+-        }
+-
+         G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object);
+ }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/gdm-36-no-remote-layout.diff	Tue May 22 09:47:58 2012 +0000
@@ -0,0 +1,183 @@
+--- gdm-2.30.7/gui/simple-greeter/gdm-greeter-panel.c	2012-02-01 14:18:54.932680691 +0100
++++ gdm-2.30.7/gui/simple-greeter/gdm-greeter-panel.c	2012-02-01 14:29:27.255918276 +0100
+@@ -1096,6 +1096,11 @@
+                                        const char      *layout_name)
+ {
+ #ifdef HAVE_LIBXKLAVIER
++	/* Unless we have both xclient/xserver running in the local */
++	/* machine we won't display the keyboard layout tab         */
++
++    	if (!is_xclient_local() || !is_xserver_local())
++				return;
+         g_return_if_fail (GDM_IS_GREETER_PANEL (panel));
+ 
+         if (layout_name != NULL &&
+--- gdm-2.30.7/gui/simple-greeter/gdm-layouts.c	2012-02-01 14:18:54.967140816 +0100
++++ gdm-2.30.7/gui/simple-greeter/gdm-layouts.c	2012-02-01 15:13:14.159363229 +0100
+@@ -29,6 +29,7 @@
+ 
+ #ifdef HAVE_LIBXKLAVIER
+ #include <libxklavier/xklavier.h>
++#include <ucred.h>
+ #endif
+ 
+ #include <gconf/gconf-client.h>
+@@ -46,9 +47,67 @@
+ static XklConfigRegistry *config_registry = NULL;
+ static XklConfigRec      *initial_config = NULL;
+ 
++/*
++ * Function to determine if a connection is local or not.
++ * Returns: FALSE for remote, TRUE for local
++ */
++gboolean
++is_xclient_local (void)
++{
++		Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
++		int c = ConnectionNumber(dpy);
++		struct stat statbuf;
++		gboolean rv = FALSE;
++		ucred_t *ucred = NULL;
++		const char *disp_name;
++
++		if (c >= 0) { 
++				/*   
++				* stat the connection fd.  If we succeed and the type of file
++				* is a FIFO, then we must be local.
++				*/
++				if ((fstat(c, &statbuf) >= 0) && S_ISFIFO(statbuf.st_mode)) {
++						return TRUE;
++				}    
++				/*   
++				* Then call getpeerucred - if it succeeds, the other end of the
++				* connection must be on the same machine (though possibly in a
++				* different zone).
++				*/
++				if (getpeerucred(c, &ucred) == 0) {
++						if (ucred_getzoneid(ucred) != -1)
++								rv = TRUE;
++						ucred_free(ucred);
++				}
++		}
++		return rv;
++}
++
++gboolean
++is_xserver_local (void)
++{
++		const char *dt_xserver_loc;
++		const char *gdm_xserver_loc;
++
++		dt_xserver_loc = g_getenv ("DTXSERVERLOCATION");
++		gdm_xserver_loc = g_getenv ("GDM_XSERVER_LOCATION");
++
++		if ((dt_xserver_loc && strcmp (dt_xserver_loc, "remote") == 0) ||
++			(gdm_xserver_loc && strcmp (gdm_xserver_loc, "xdmcp") == 0))
++				return FALSE;
++
++		return TRUE;
++}
++
+ static void
+ init_xkl (void)
+ {
++		/* Unless we have both xclient/xserver running in the local */
++		/* machine we won't display the keyboard layout tab         */
++
++		if (!is_xclient_local() || !is_xserver_local())
++				return;
++
+         if (config_registry == NULL) {
+                 engine = xkl_engine_get_instance (GDK_DISPLAY ());
+                 config_registry = xkl_config_registry_get_instance (engine);
+@@ -66,6 +125,8 @@
+ xci_desc_to_utf8 (XklConfigItem * ci)
+ {
+         char *sd = g_strstrip (ci->description);
++		if (!is_xclient_local() || !is_xserver_local())
++				return NULL;
+         return sd[0] == 0 ? g_strdup (ci->name) :
+                 g_locale_to_utf8 (sd, -1, NULL, NULL, NULL);
+ }
+@@ -77,6 +138,9 @@
+ {
+         LayoutData *ldata = data;
+ 
++		if (!is_xclient_local() || !is_xserver_local())
++				return;
++
+         ldata->list = g_slist_prepend (ldata->list, g_strdup_printf  ("%s\t%s", ldata->layout, item->name));
+ }
+ 
+@@ -87,6 +151,9 @@
+ {
+         LayoutData *ldata = data;
+ 
++		if (!is_xclient_local() || !is_xserver_local())
++				return;
++
+         ldata->layout = item->name;
+         ldata->list = g_slist_prepend (ldata->list, g_strdup (item->name));
+         xkl_config_registry_foreach_layout_variant (config, item->name, add_variant, data);
+@@ -106,6 +173,9 @@
+         char          *id2;
+         char          *p;
+ 
++		if (!is_xclient_local() || !is_xserver_local())
++				return NULL;
++
+         init_xkl ();
+ 
+         id1 = g_strdup (name);
+@@ -168,6 +238,9 @@
+         data.list = NULL;
+         data.layout = NULL;
+ 
++		if (!is_xclient_local() || !is_xserver_local())
++				return NULL;
++
+         init_xkl ();
+ 
+         xkl_config_registry_foreach_layout (config_registry, add_layout, &data);
+@@ -198,6 +271,9 @@
+         char          *variant;
+         gboolean       retval;
+ 
++		if (!is_xclient_local() || !is_xserver_local())
++				return TRUE;
++
+         if (layout_variant != NULL && strcmp (layout_variant, GDM_LAST_LAYOUT) == 0) {
+                 return TRUE;
+         }
+@@ -232,6 +308,10 @@
+ gdm_layout_get_default_layout (void)
+ {
+ #ifdef HAVE_LIBXKLAVIER
++
++		if (!is_xclient_local() || !is_xserver_local())
++				return NULL;
++
+         init_xkl ();
+ 
+         if (initial_config->layouts)
+@@ -250,6 +330,9 @@
+         XklConfigRec *config;
+         char         *p;
+ 
++		if (!is_xclient_local() || !is_xserver_local())
++				return;
++
+         if (layout != NULL && strcmp (layout, GDM_LAST_LAYOUT) == 0) {
+                 return;
+         }
+--- gdm-2.30.7/gui/simple-greeter/gdm-layouts.h	2012-02-01 14:18:54.926446809 +0100
++++ gdm-2.30.7/gui/simple-greeter/gdm-layouts.h	2012-02-01 15:14:04.894492766 +0100
+@@ -29,6 +29,8 @@
+ gboolean      gdm_layout_is_valid        (const char *layout);
+ const char *  gdm_layout_get_default_layout (void);
+ void          gdm_layout_activate        (const char *layout);
++gboolean	  is_xclient_local			 (void);
++gboolean	  is_xserver_local			 (void);
+ 
+ G_END_DECLS
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/gdm-37-strndup.diff	Tue May 22 09:47:58 2012 +0000
@@ -0,0 +1,18 @@
+--- gdm-2.30.7/daemon/gdm-session-worker.c-orig	2012-02-21 20:27:25.469131407 -0600
++++ gdm-2.30.7/daemon/gdm-session-worker.c	2012-02-21 20:52:54.218996258 -0600
+@@ -983,11 +983,12 @@ gdm_session_worker_process_pam_message (
+         }
+ 
+         if (user_answer != NULL) {
+-                /* we strdup and g_free to make sure we return malloc'd
+-                 * instead of g_malloc'd memory
++                /* we strndup and g_free to make sure we return malloc'd
++                 * instead of g_malloc'd memory.  PAM_MAX_RESP_SIZE includes
++                 * the '\0' terminating character, thus the "-1".
+                  */
+                 if (res && response_text != NULL) {
+-                        *response_text = strdup (user_answer);
++                        *response_text = strndup (user_answer, PAM_MAX_RESP_SIZE-1);
+                 }
+ 
+                 memset (user_answer, '\0', strlen (user_answer));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/gdm-38-bindtextdomaincodeset.diff	Tue May 22 09:47:58 2012 +0000
@@ -0,0 +1,10 @@
+--- gdm-2.30.7/daemon/main.c.orig	2012-03-23 13:52:17.581432411 +0800
++++ gdm-2.30.7/daemon/main.c	2012-03-23 13:52:18.509432457 +0800
+@@ -637,6 +637,7 @@
+ #endif
+ 
+         bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
++        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+         textdomain (GETTEXT_PACKAGE);
+         setlocale (LC_ALL, "");
+