--- gdm2/ChangeLog.org	2006-10-29 13:42:11.000000000 +0000
+++ gdm2/ChangeLog	2006-10-29 13:54:49.000000000 +0000
@@ -0,0 +1,19 @@
+2006-10-29  Lukasz Zalewski  <lukas@dcs.qmul.ac.uk>
+
+	Fixes enhancement request #358114.
+	* daemon/gdm.h: Added command_is_persistent variable to
+	   _GdmCustomCmd structure	
+	* daemon/gdm.c (gdm_handle_user_message): Added two new commands
+
+2006-10-26  Brian Cameron  <brian.cameron@sun.com>
+
+	* gui/gdmcommon.c, gui/greeter/greeter.c:  Never die if
+	  at-spi-registryd can not be started.  Fixes bug #345434.  Patch by
+	  Ariel Rios  <ariel@gnu.org>.
+
+2006-10-26 Erwann Chenede - <erwann.chenede@sun.com>
+
+	* gui/greeter/greeter_parser.c: introduced altfile[n] property
+	  to cater for alternate image file definition.
+	* docs/C/gdm.xml: added documentation for the new property.
+
@@ -36,12 +54,0 @@
-2006-10-26  Brian Cameron  <brian.cameron@sun.com>
-
-	* gui/gdmcommon.c, gui/greeter/greeter.c:  Never die if
-	  at-spi-registryd can not be started.  Fixes bug #345434.  Patch by
-	  Ariel Rios  <ariel@gnu.org>.
-
-2006-10-26 Erwann Chenede - <erwann.chenede@sun.com>
-
-	* gui/greeter/greeter_parser.c: introduced altfile[n] property
-	  to cater for alternate image file definition.
-	* docs/C/gdm.xml: added documentation for the new property.
-
--- gdm2/docs/C/gdm.xml.org	2006-10-29 12:59:52.000000000 +0000
+++ gdm2/docs/C/gdm.xml	2006-10-29 13:40:22.000000000 +0000
@@ -3999,6 +3999,21 @@
           </varlistentry>
           
           <varlistentry>
+            <term>CustomCommandIsPersistent[0-9]</term>
+            <listitem>
+              <synopsis>CustomCommandIsPersistent[0-9]=</synopsis>
+              <para>
+                Specifies if <filename>n-th</filename> &quot;Custom Command&quot;
+                will appear outside the login manager, for example on the desktop through the Log Out/Shut Down
+                dialogs. If not specified the default value is &quot;false&quot;. This option is only valid if
+                corresponding <filename>CustomCommand</filename> is defined. 
+                [0-9] represents <filename>CustomCommand</filename> suffix
+                and can be an integer between 0 and 9.
+              </para>
+            </listitem>
+          </varlistentry>
+          
+          <varlistentry>
             <term>CustomCommandLabel[0-9]</term>
             <listitem>
               <synopsis>CustomCommandLabel[0-9]=</synopsis>
@@ -4006,10 +4021,11 @@
                 Specifies the stock label that will be displayed on the
                 <filename>n-th</filename> &quot;Custom Command&quot;
                 buttons and menu items. If not specified the default value is
-                &quot;_Custom[0-9]&quot;. This option is only valid if
+                &quot;Custom_[0-9]&quot;. This option is only valid if
                 corresponding <filename>CustomCommand</filename> is defined. 
                 [0-9] represents <filename>CustomCommand</filename> suffix
-                and can be an integer between 0 and 9.
+                and can be an integer between 0 and 9. This option can't contain
+                any semicolon characters (i.e. &quot;;&quot;).
               </para>
             </listitem>
           </varlistentry>
@@ -4022,7 +4038,7 @@
                 Specifies the stock label that will be displayed on the
                 <filename>n-th</filename> &quot;Custom Command&quot;
                 list items and radio buttons.  If not specified the default
-                value is  &quot;Execute _custom command [0-9]&quot;. This 
+                value is  &quot;Execute custom command _[0-9]&quot;. This 
                 option is only valid if corresponding
                 <filename>CustomCommand</filename> is defined.  [0-9]
                 represents <filename>CustomCommand</filename> suffix and
@@ -4042,7 +4058,12 @@
                 &quot;false&quot;. This option is only valid if corresponding
                 <filename>CustomCommand</filename> is defined.  [0-9]
                 represents <filename>CustomCommand</filename> suffix and
-                can be an integer between 0 and 9.
+                can be an integer between 0 and 9. 
+                In addition when corresponding <filename>CustomCommandIsPersistent</filename> 
+                is set to true,  setting CustomCommandNoRestart to false will place 
+                corresponding <filename>CustomCommand</filename> in the 
+                Shut Down dialog set of actions, setting it to true will place corresponding 
+                <filename>CustomCommand</filename> in the Log Out dialog set of actions.
               </para>
             </listitem>
           </varlistentry>
@@ -4796,6 +4817,46 @@
 </screen>
       </sect3>
       
+      <sect3 id="querycustomcmdlabels">
+        <title>QUERY_CUSTOM_CMD_LABELS</title>
+<screen>
+ QUERY_CUSTOM_CMD_LABELS: Query labels belonging to exported custom commands
+                          Only supported on connections that passed
+                          AUTH_LOCAL.
+ Supported since: 2.5.90.0
+ Answers:
+   OK &lt;label1&gt;;&lt;label2&gt;;...
+      Where labelX is one of the labels belonging to CUSTOM_CMDX (where X in [0,GDM_CUSTOM_COMMAND_MAX)).
+      An empty list can also be returned if none of the custom commands are 
+      exported outside login manager (no CustomCommandIsPersistent options are set to true).  
+   ERROR &lt;err number&gt; &lt;english error description&gt;
+      0 = Not implemented
+      100 = Not authenticated
+      200 = Too many messages
+      999 = Unknown error
+</screen>
+      </sect3>
+      
+      <sect3 id="querycustomcmdnorestartstatus">
+        <title>QUERY_CUSTOM_CMD_NO_RESTART_STATUS</title>
+<screen>
+QUERY_CUSTOM_CMD_NO_RESTART_STATUS: Query NoRestart config options for each of custom commands
+                                    Only supported on connections that passed
+                                    AUTH_LOCAL.
+Supported since: 2.5.90.0
+Answers:
+  OK &lt;status&gt;
+     Where each bit of the status represents NoRestart value for each of the custom commands.
+     bit on (1):  NoRestart = true, 
+     bit off (0): NoRestart = false.
+  ERROR &lt;err number&gt; &lt;english error description&gt;
+     0 = Not implemented
+     100 = Not authenticated
+     200 = Too many messages
+     999 = Unknown error
+</screen>
+      </sect3>
+      
       <sect3 id="queryvt">
       <title>QUERY_VT</title>
 <screen>
@@ -6530,7 +6591,7 @@
           <filename>config</filename>, _(&quot;_Configure&quot;
         </para>
         <para>
-          <filename>custom_cmd[0-9]</filename>, _(&quot;_Custom[0-9]&quot;
+          <filename>custom_cmd[0-9]</filename>, _(&quot;Custom_[0-9]&quot;
         </para>
         <para>
           <filename>disconnect</filename>, _(&quot;D_isconnect&quot;
@@ -7084,6 +7145,7 @@
           CustomCommandLRLabel0=Reboot into _Windoze
           CustomCommandText0=Are you sure you want to restart the computer into Windoze?
           CustomCommandTooltip0=Restarts the computer into Windoze
+          CustomCommandIsPersistent0=true
         </screen>
 
         CustomCommand0 specifies two commands separated by a semicolon:
@@ -7122,6 +7184,7 @@
           CustomCommandLRLabel0=Reboot into _Windoze
           CustomCommandText0=Are you sure you want to restart the computer into Windoze?
           CustomCommandTooltip0=Restarts the computer into Windoze
+          CustomCommandIsPersistent0=true
           
           CustomCommand1=/sbin/updatesystem;/usr/local/sbin/updatesystem
           CustomCommandLabel1=_Update Me
@@ -7142,6 +7205,7 @@
           CustomCommandLRLabel0=Reboot into _Windoze
           CustomCommandText0=Are you sure you want to restart the computer into Windoze?
           CustomCommandTooltip0=Restarts the computer into Windoze
+          CustomCommandIsPersistent0=true
           
           CustomCommand1=/sbin/updatesystem;/usr/local/sbin/updatesystem
           CustomCommandLabel1=_Update Me
--- gdm2/daemon/gdm.h.org	2006-10-29 11:19:22.000000000 +0000
+++ gdm2/daemon/gdm.h	2006-10-29 11:59:22.000000000 +0000
@@ -241,6 +241,7 @@
 #define GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE "customcommand/CustomCommandText"
 #define GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE "customcommand/CustomCommandTooltip"
 #define GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE "customcommand/CustomCommandNoRestart"
+#define GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE "customcommand/CustomCommandIsPersistent"
 #define GDM_KEY_ROOT_PATH "daemon/RootPath=/sbin:/usr/sbin:" GDM_USER_PATH
 #define GDM_KEY_SERV_AUTHDIR "daemon/ServAuthDir=" AUTHDIR
 #define GDM_KEY_SESSION_DESKTOP_DIR "daemon/SessionDesktopDir=/etc/X11/sessions/:" DMCONFDIR "/Sessions/:" DATADIR "/gdm/BuiltInSessions/:" DATADIR "/xsessions/"
@@ -452,6 +453,7 @@
     gchar *command_text; /* warning dialog text */
     gchar *command_tooltip; /* tooltip string */
     gboolean command_no_restart; /* no restart flag */
+    gboolean command_is_persistent; /* persistence flag */
 };
 
 #define GDM_CUSTOM_COMMAND_MAX 10 /* maximum number of supported custom commands */
@@ -1177,6 +1179,38 @@
  *      200 = Too many messages
  *      999 = Unknown error
  */
+#define GDM_SUP_QUERY_CUSTOM_CMD_LABELS "QUERY_CUSTOM_CMD_LABELS" /* None */
+/* QUERY_CUSTOM_CMD_LABELS: Query labels belonging to exported custom commands
+ *                          Only supported on connections that passed
+ *                          AUTH_LOCAL.
+ * Supported since: 2.5.90.0
+ * Answers:
+ *   OK <label1>;<label2>;...
+ *      Where labelX is one of the labels belonging to CUSTOM_CMDX (where X in [0,GDM_CUSTOM_COMMAND_MAX)).
+ *      An empty list can also be returned if none of the custom commands are 
+ *      exported outside login manager (no CustomCommandIsPersistent options are set to true).  
+ *   ERROR <err number> <english error description>
+ *      0 = Not implemented
+ *      100 = Not authenticated
+ *      200 = Too many messages
+ *      999 = Unknown error
+ */
+#define GDM_SUP_QUERY_CUSTOM_CMD_NO_RESTART_STATUS "QUERY_CUSTOM_CMD_NO_RESTART_STATUS" /* None */
+/* QUERY_CUSTOM_CMD_NO_RESTART_STATUS: Query NoRestart config options for each of custom commands
+ *                                     Only supported on connections that passed
+ *                                     AUTH_LOCAL.
+ * Supported since: 2.5.90.0
+ * Answers:
+ *   OK <status>
+ *      Where each bit of the status represents NoRestart value for each of the custom commands.
+ *      bit on (1):  NoRestart = true, 
+ *      bit off (0): NoRestart = false.
+ *   ERROR <err number> <english error description>
+ *      0 = Not implemented
+ *      100 = Not authenticated
+ *      200 = Too many messages
+ *      999 = Unknown error
+ */
 #define GDM_SUP_SET_LOGOUT_ACTION "SET_LOGOUT_ACTION" /* <action> */
 /* SET_LOGOUT_ACTION: Tell the daemon to halt/restart/suspend after
  *                    slave process exits.  Only supported on
--- gdm2/daemon/gdm.c.org	2006-10-29 11:47:32.000000000 +0000
+++ gdm2/daemon/gdm.c	2006-10-29 14:38:45.000000000 +0000
@@ -714,10 +714,10 @@
 custom_cmd (long cmd_id)
 {	
         if (cmd_id < 0 || cmd_id >= GDM_CUSTOM_COMMAND_MAX) {
-	    /* We are just feeling very paranoid */
-	    gdm_error (_("custom_cmd: Custom command index %ld outside permitted range [0,%d)"), 
-		       cmd_id, GDM_CUSTOM_COMMAND_MAX);
-	    return;
+		/* We are just feeling very paranoid */
+		gdm_error (_("custom_cmd: Custom command index %ld outside permitted range [0,%d)"), 
+			   cmd_id, GDM_CUSTOM_COMMAND_MAX);
+		return;
 	}
 
         gchar * key_string = g_strdup_printf (_("%s%ld="), GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE, cmd_id);
@@ -725,7 +725,7 @@
 	        custom_cmd_no_restart (cmd_id);
 	else
 	        custom_cmd_restart (cmd_id);
-    
+	
 	g_free(key_string);
 }
 
@@ -747,7 +747,7 @@
 	argv = ve_split (gdm_get_value_string (key_string));
 	g_free(key_string);
 	if (argv != NULL && argv[0] != NULL)
-	    VE_IGNORE_EINTR (execv (argv[0], argv));
+		VE_IGNORE_EINTR (execv (argv[0], argv));
 	
 	g_strfreev (argv);	      
 	
@@ -769,32 +769,32 @@
 		return;
 	}
 	else if (pid == 0) {
-	      /* child */
-	      char **argv;
-	      gchar * key_string = g_strdup_printf (_("%s%ld="), GDM_KEY_CUSTOM_CMD_TEMPLATE, cmd_id);
-	      argv = ve_split (gdm_get_value_string (key_string));
-	      g_free(key_string);
-	      if (argv != NULL && argv[0] != NULL)
-		      VE_IGNORE_EINTR (execv (argv[0], argv));
+		/* child */
+		char **argv;
+		gchar * key_string = g_strdup_printf (_("%s%ld="), GDM_KEY_CUSTOM_CMD_TEMPLATE, cmd_id);
+		argv = ve_split (gdm_get_value_string (key_string));
+		g_free(key_string);
+		if (argv != NULL && argv[0] != NULL)
+			VE_IGNORE_EINTR (execv (argv[0], argv));
 	    
-	      g_strfreev (argv);	      
-	      
-	      gdm_error (_("%s: Execution of custom command failed: %s"), 
-			 "gdm_child_action", strerror (errno));
-	    	    
-	      _exit (0);	    
+		g_strfreev (argv);	      
+		
+		gdm_error (_("%s: Execution of custom command failed: %s"), 
+			   "gdm_child_action", strerror (errno));
+		
+		_exit (0);	    
 	}
 	else {
-	      /* parent */
-	      gint exitstatus = 0, status;
-	      pid_t p_stat = waitpid (1, &exitstatus, WNOHANG);
-	      if(p_stat > 0){
-		  if G_LIKELY (WIFEXITED (exitstatus)){
-		      status = WEXITSTATUS (exitstatus);
-		      gdm_debug (_("custom_cmd: child %d returned %d"), p_stat, status);
-		  }	
-		  return;
-	      }
+		/* parent */
+		gint exitstatus = 0, status;
+		pid_t p_stat = waitpid (1, &exitstatus, WNOHANG);
+		if (p_stat > 0) {
+			if G_LIKELY (WIFEXITED (exitstatus)){
+				status = WEXITSTATUS (exitstatus);
+				gdm_debug (_("custom_cmd: child %d returned %d"), p_stat, status);
+			}	
+			return;
+		}
 	}	
 }
 
@@ -1173,7 +1173,7 @@
 		   check for the range of values */
 	        if (logout_action >= GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST &&
 		    logout_action <= GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST)		    
-		         custom_cmd (logout_action - GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST);	    
+			custom_cmd (logout_action - GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST);	    
 		break;
 	}
 }
@@ -2979,6 +2979,8 @@
 static void
 gdm_handle_user_message (GdmConnection *conn, const gchar *msg, gpointer data)
 {
+	gint i;
+
 	gdm_debug ("Handling user message: '%s'", msg);
 
 	if (gdm_connection_get_message_count (conn) > GDM_SUP_MAX_MESSAGES) {
@@ -3372,23 +3374,109 @@
 			sep = ";";
 		}
 
-		register int i = 0;
-		for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
-		     gchar *key_string = NULL; 
-		     key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i); 
-		     if (sysmenu && disp->attached &&
-			 ! ve_string_empty (gdm_get_value_string (key_string))) {
-			     g_string_append_printf (msg, "%s%s%d", sep, GDM_SUP_LOGOUT_ACTION_CUSTOM_CMD_TEMPLATE, i);
-			     if (logout_action == (GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST + i))
-				       g_string_append (msg, "!");
-			     sep = ";";
-		     }
-		     g_free(key_string);		     
+		for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+			gchar *key_string = NULL; 
+			key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i); 
+			if (sysmenu && disp->attached &&
+			    ! ve_string_empty (gdm_get_value_string (key_string))) {
+				g_free (key_string);
+				key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE, i); 
+				if (gdm_get_value_bool (key_string)) {
+					g_string_append_printf (msg, "%s%s%d", sep, GDM_SUP_LOGOUT_ACTION_CUSTOM_CMD_TEMPLATE, i);
+					if (logout_action == (GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST + i))
+						g_string_append (msg, "!");
+					sep = ";";
+				}
+			}
+			g_free(key_string);		     
+		}
+
+		g_string_append (msg, "\n");
+		gdm_connection_write (conn, msg->str);
+		g_string_free (msg, TRUE);
+	} else if (strcmp (msg, GDM_SUP_QUERY_CUSTOM_CMD_LABELS) == 0) {
+		GdmDisplay *disp;
+		GString *msg;
+		const gchar *sep = " ";
+		gboolean sysmenu;
+
+		disp = gdm_connection_get_display (conn);
+		sysmenu = gdm_get_value_bool_per_display (disp->name, GDM_KEY_SYSTEM_MENU);
+
+		/* Only allow locally authenticated connections */
+		if ( ! GDM_CONN_AUTHENTICATED (conn) ||
+		     disp == NULL) {
+			gdm_info (_("%s request denied: "
+				    "Not authenticated"), "QUERY_LOGOUT_ACTION");
+			gdm_connection_write (conn,
+					      "ERROR 100 Not authenticated\n");
+			return;
+		}
+		
+		msg = g_string_new ("OK");		
+
+		for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+			gchar *key_string = NULL; 
+			key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i); 
+			if (sysmenu && disp->attached &&
+			    ! ve_string_empty (gdm_get_value_string (key_string))) {
+				g_free (key_string);
+				key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE, i); 
+				if (gdm_get_value_bool (key_string)) {
+					g_free (key_string);
+					key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i); 
+					g_string_append_printf (msg, "%s%s",  sep, gdm_get_value_string (key_string));
+					sep = ";";
+				}
+			}
+			g_free(key_string);		     
 		}
 
 		g_string_append (msg, "\n");
 		gdm_connection_write (conn, msg->str);
 		g_string_free (msg, TRUE);
+	} else if (strcmp (msg, GDM_SUP_QUERY_CUSTOM_CMD_NO_RESTART_STATUS) == 0) {
+		GdmDisplay *disp;
+		GString *msg;
+		gboolean sysmenu;
+
+		disp = gdm_connection_get_display (conn);
+		sysmenu = gdm_get_value_bool_per_display (disp->name, GDM_KEY_SYSTEM_MENU);
+
+		/* Only allow locally authenticated connections */
+		if ( ! GDM_CONN_AUTHENTICATED (conn) ||
+		     disp == NULL) {
+			gdm_info (_("%s request denied: "
+				    "Not authenticated"), "QUERY_LOGOUT_ACTION");
+			gdm_connection_write (conn,
+					      "ERROR 100 Not authenticated\n");
+			return;
+		}
+		
+		msg = g_string_new ("OK ");
+
+		unsigned long no_restart_status_flag = 0; /* we can store up-to 32 commands this way */
+		
+		for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+			gchar *key_string = NULL; 
+			key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i); 
+			if (sysmenu && disp->attached &&
+			    ! ve_string_empty (gdm_get_value_string (key_string))) {
+				g_free (key_string);
+				key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE, i); 
+				if (gdm_get_value_bool (key_string)) {
+					g_free (key_string);
+					key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE, i); 
+					if(gdm_get_value_bool (key_string))
+						no_restart_status_flag |= (1 << i);				 
+				}
+			}
+			g_free(key_string);		     
+		}
+
+		g_string_append_printf (msg, "%ld\n", no_restart_status_flag);
+		gdm_connection_write (conn, msg->str);
+		g_string_free (msg, TRUE);
 	} else if (strncmp (msg, GDM_SUP_SET_LOGOUT_ACTION " ",
 		     strlen (GDM_SUP_SET_LOGOUT_ACTION " ")) == 0) {
 		const gchar *action = 
--- gdm2/daemon/gdmconfig.c.org	2006-10-29 12:02:11.000000000 +0000
+++ gdm2/daemon/gdmconfig.c	2006-10-29 14:37:41.000000000 +0000
@@ -345,6 +345,8 @@
 static void 
 gdm_config_init (void)
 {
+   gint i;
+
    type_hash    = g_hash_table_new (g_str_hash, g_str_equal);
    val_hash     = g_hash_table_new (g_str_hash, g_str_equal);
    realkey_hash = g_hash_table_new (g_str_hash, g_str_equal);
@@ -509,33 +511,36 @@
 
    /* custom command string values */
    GdmCustomCommands = g_new0 (GdmCustomCmd, GDM_CUSTOM_COMMAND_MAX);   
-   register int i = 0;
    gchar *key_string = NULL; 
-   for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
-       /* For each possible custom command */      
-       key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i); 
-       GdmCustomCommands[i].command = NULL;
-       gdm_config_add_hash (key_string, &GdmCustomCommands[i].command, &string_type);
-
-       key_string = g_strdup_printf (_("%s%d=_Custom%d"), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i, i); 
-       GdmCustomCommands[i].command_label = NULL;
-       gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_label, &string_type);
-
-       key_string = g_strdup_printf (_("%s%d=Execute _custom command %d"), GDM_KEY_CUSTOM_CMD_LR_LABEL_TEMPLATE, i, i);
-       GdmCustomCommands[i].command_lr_label = NULL;
-       gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_lr_label, &string_type);
-
-       key_string = g_strdup_printf (_("%s%d=Are you sure?"), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, i);
-       GdmCustomCommands[i].command_text = NULL;
-       gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_text, &string_type);
-        
-       key_string = g_strdup_printf (_("%s%d=Execute custom command %d"), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i, i);
-       GdmCustomCommands[i].command_tooltip = NULL;
-       gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_tooltip, &string_type);
-
-       key_string = g_strdup_printf (_("%s%d=false"), GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE, i);
-       GdmCustomCommands[i].command_no_restart = FALSE;
-       gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_no_restart, &bool_type);  
+   for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+	   /* For each possible custom command */      
+	   key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i); 
+	   GdmCustomCommands[i].command = NULL;
+	   gdm_config_add_hash (key_string, &GdmCustomCommands[i].command, &string_type);
+	   
+	   key_string = g_strdup_printf (_("%s%d=Custom_%d"), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i, i); 
+	   GdmCustomCommands[i].command_label = NULL;
+	   gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_label, &string_type);
+	   
+	   key_string = g_strdup_printf (_("%s%d=Execute custom command _%d"), GDM_KEY_CUSTOM_CMD_LR_LABEL_TEMPLATE, i, i);
+	   GdmCustomCommands[i].command_lr_label = NULL;
+	   gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_lr_label, &string_type);
+	   
+	   key_string = g_strdup_printf (_("%s%d=Are you sure?"), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, i);
+	   GdmCustomCommands[i].command_text = NULL;
+	   gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_text, &string_type);
+	   
+	   key_string = g_strdup_printf (_("%s%d=Execute custom command %d"), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i, i);
+	   GdmCustomCommands[i].command_tooltip = NULL;
+	   gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_tooltip, &string_type);
+	   
+	   key_string = g_strdup_printf (_("%s%d=false"), GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE, i);
+	   GdmCustomCommands[i].command_no_restart = FALSE;
+	   gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_no_restart, &bool_type);  
+
+	   key_string = g_strdup_printf(_("%s%d=false"), GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE, i);
+	   GdmCustomCommands[i].command_is_persistent = FALSE;
+	   gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_is_persistent, &bool_type); 
    }   
 
    /* int values */
@@ -1059,6 +1064,7 @@
    gchar *setting_copy = NULL;
    gchar *temp_string;
    gchar *value;
+   gint i;
 
    if (! ve_string_empty (value_in))
       value = value_in;
@@ -1191,23 +1197,21 @@
 
    /* All others */
    } else {
-       register int i = 0;
-       gchar * key_string = NULL;
-       for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {	   
-	   /* For each possible custom command */     
-	   key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
-	   if(is_key (key, key_string)) {	       
-	       if (value != NULL)
-		  *setting = ve_get_first_working_command (value, FALSE);
-	       else
-		  *setting = NULL;
-
-	       break;
-	   }
+       for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {	   
+	       gchar * key_string = NULL;
+	       /* For each possible custom command */     
+	       key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+	       if(is_key (key, key_string)) {	       
+		       if (value != NULL)
+			       *setting = ve_get_first_working_command (value, FALSE);
+		       else
+			       *setting = NULL;
+		       
+		       break;
+	       }
+	       g_free(key_string);
        }
 
-       g_free(key_string);
-
        if (value != NULL)
           *setting = g_strdup (value);
        else {
@@ -1242,18 +1246,18 @@
       else if (is_key (key, GDM_KEY_TIMED_LOGIN))
          notify_displays_string (GDM_NOTIFY_TIMED_LOGIN, *setting);
 
-      register int i = 0;
-      gchar * key_string = NULL;
-      for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {	   	   
-	  /* For each possible custom command */     
-	   key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i); 
-	   if (is_key (key, key_string)) {
-	       g_free(key_string);
-	       key_string = g_strdup_printf (_("%s%d"), GDM_NOTIFY_CUSTOM_CMD_TEMPLATE, i);
-	       notify_displays_string (key_string, *setting);
-	   }
+      for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {	   	   
+	      gchar * key_string = NULL;
+	      /* For each possible custom command */     
+	      key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i); 
+	      if (is_key (key, key_string)) {
+		      g_free(key_string);
+		      key_string = g_strdup_printf (_("%s%d"), GDM_NOTIFY_CUSTOM_CMD_TEMPLATE, i);
+		      notify_displays_string (key_string, *setting);
+		      break;
+	      }
+	      g_free(key_string);
       }       
-      g_free(key_string);
    }
 
    if (setting_copy != NULL)
--- gdm2/config/gdm.conf.in.org	2006-10-29 12:37:33.000000000 +0000
+++ gdm2/config/gdm.conf.in	2006-10-29 13:24:36.000000000 +0000
@@ -600,17 +600,18 @@
 
 [customcommand]
 # This section allows you specify up to 10 custom commands. Each of the
-# commands can be defined by the six parameters listed below. In each of the
+# commands can be defined by the seven parameters listed below. In each of the
 # descriptions of the parameters N can take on any values between 0 and 9,
 # i.e. CustomCommand0=,CustomCommand1=,...,CustomCommand9=.  The  numbers
 # can have gaps as long as they fit within predefined set of 10, and their
 # placement order within this section and with respect to each other is
 # not important.
 #
-# CustomCommandN, CustomCommandTextN, CustomCommandLabelN,
-# CustomCommandLRLabelN, CustomCommandTooltipN, and CustomCommandNoRestartN
-# must all be defined for a given integer N, where N can be a number from
-# 0-9.
+# CustomCommandN, CustomCommandTextN, CustomCommandLabelN, 
+# CustomCommandLRLabelN, CustomCommandTooltipN, CustomCommandIsPersistentN
+# and CustomCommandNoRestartN should all be defined for a given integer N, 
+# where N can be a number from 0-9 (if not the default values will be 
+# assigned except CustomCommandN for which no default exists).
 
 # Custom command to run.  Multiple commands may be specified separated by 
 # semicolons.  GDM will use the first valid command.  Examples:
@@ -626,6 +627,7 @@
 #CustomCommandTextN=
 
 # Custom command label that will appear as stock label on buttons/menu items.
+# This option can't contain any semicolon characters (i.e. ";").
 # Examples:
 # _Windoze, or
 # _Update Me
@@ -642,10 +644,19 @@
 # Updates the computer software to the most recent version(s)
 #CustomCommandTooltipN=
 
+# Custom command persistence option. Setting it to true will allow this
+# command to appear outside the login manager, e.g. on the desktop through 
+# Log Out/Shut Down dialogs. The default value is false.
+#CustomCommandIsPersistentN=
+
 # Custom command gdm/system restart option. Setting it to true will not
 # restart gdm after command execution.  The default commands (reboot, shut
 # down) all reboot the system by default which is why the default setting
 # is true.
+# In addition when corresponding CustomCommandIsPersistentN option is set to true, 
+# setting CustomCommandNoRestartN to false will place CustomCommandN in the 
+# Shut Down dialog set of actions, setting it to true will place CustomCommandN in the 
+# Log Out dialog set of actions.
 #CustomCommandNoRestartN=
 #
 # Example layout for more than one command:
@@ -654,6 +665,7 @@
 #CustomCommandLabel0=
 #CustomCommandLRLabel0=
 #CustomCommandTooltip0=
+#CustomCommandIsPersistent0=
 #CustomCommandNoRestart0=
 #
 #CustomCommand1=
@@ -661,6 +673,7 @@
 #CustomCommandLabel1=
 #CustomCommandLRLabel1=
 #CustomCommandTooltip1=
+#CustomCommandIsPersistent1=
 #CustomCommandNoRestart1=
 #
 # and so on
--- gdm2/gui/greeter/greeter_item.c.org	2006-10-29 12:18:00.000000000 +0000
+++ gdm2/gui/greeter/greeter_item.c	2006-10-29 14:45:15.000000000 +0000
@@ -157,9 +157,8 @@
   static gboolean checked = FALSE;
   static gboolean GDM_IS_LOCAL = FALSE;
   static gboolean GDM_FLEXI_SERVER = FALSE;
-  gboolean sysmenu = FALSE;
-  gchar *key_string = NULL;	
-  int i = 0;
+  gboolean sysmenu = FALSE;	
+  gint i = 0;
 
   if ( ! checked)
     {
@@ -213,16 +212,16 @@
        strcmp (info->show_type, "suspend") == 0))
 	  return FALSE;
 
-  for (i=0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
-      key_string = g_strdup_printf (_("custom_cmd%d"), i);
+  for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {      
+      gchar * key_string = g_strdup_printf (_("custom_cmd%d"), i);
       if (( ! sysmenu || ! GdmCustomCmdsFound[i]) &&
-      (info->show_type != NULL &&
-       strcmp (info->show_type, key_string) == 0)) {
+          (info->show_type != NULL &&
+           strcmp (info->show_type, key_string) == 0)) {
 	      g_free (key_string);
 	      return FALSE;
-	  }
+      }
+      g_free (key_string);
   }
-  g_free (key_string);
 
   if (( ! gdm_config_get_bool (GDM_KEY_TIMED_LOGIN_ENABLE) ||
           ve_string_empty (gdm_config_get_string (GDM_KEY_TIMED_LOGIN)) ||
--- gdm2/gui/greeter/greeter_system.c.org	2006-10-29 12:22:15.000000000 +0000
+++ gdm2/gui/greeter/greeter_system.c	2006-10-29 14:46:07.000000000 +0000
@@ -81,9 +81,10 @@
 }
 
 static void
-query_greeter_custom_cmd_handler (GtkWidget *widget, gint *cmd_id)
+query_greeter_custom_cmd_handler (GtkWidget *widget, gpointer data)
 {
-        if (cmd_id) {
+        if (data) {
+		gint *cmd_id = (gint*)data;
 	        gchar * key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, *cmd_id);
 		if (gdm_wm_warn_dialog (gdm_config_get_string (key_string) , "", 
 					GTK_STOCK_OK, NULL, TRUE) == GTK_RESPONSE_YES) {
@@ -171,6 +172,7 @@
 greeter_system_append_system_menu (GtkWidget *menu)
 {
 	GtkWidget *w, *sep;
+	gint i = 0;
 
 	/* should never be allowed by the UI */
 	if ( ! gdm_config_get_bool (GDM_KEY_SYSTEM_MENU) ||
@@ -214,20 +216,19 @@
 	}
 
 	if (GdmAnyCustomCmdsFound) {
-	        register int i = 0;
-		for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+		for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
 		        if (GdmCustomCmdsFound[i]){
-			         gint * cmd_index = g_new0(gint, 1);
-				 *cmd_index = i;
-				 gchar * key_string = NULL;
-				 key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
-				 w = gtk_menu_item_new_with_mnemonic (gdm_config_get_string(key_string));
-				 gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
-				 gtk_widget_show (GTK_WIDGET (w));
-				 g_signal_connect (G_OBJECT (w), "activate",
-						   G_CALLBACK (query_greeter_custom_cmd_handler),
-						   cmd_index);
-				 g_free (key_string);
+				gint * cmd_index = g_new0(gint, 1);
+				*cmd_index = i;
+				gchar * key_string = NULL;
+				key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
+				w = gtk_menu_item_new_with_mnemonic (gdm_config_get_string(key_string));
+				gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
+				gtk_widget_show (GTK_WIDGET (w));
+				g_signal_connect (G_OBJECT (w), "activate",
+						  G_CALLBACK (query_greeter_custom_cmd_handler),
+						  cmd_index);
+				g_free (key_string);
 			}
 		}
 	}
@@ -283,7 +284,8 @@
   GtkWidget *config_radio = NULL;
   GtkWidget *chooser_radio = NULL;
   gchar *s;
-  int ret, i;
+  int ret;
+  gint i;
   GSList *radio_group = NULL;
   static GtkTooltips *tooltips = NULL;
 
@@ -492,7 +494,9 @@
 
 void
 greeter_item_system_setup (void)
-{
+{  
+  gint i;
+	
   greeter_item_register_action_callback ("reboot_button",
 					 (ActionFunc)query_greeter_restart_handler,
 					 NULL);  
@@ -512,14 +516,13 @@
 					 (ActionFunc)greeter_chooser_handler,
 					 NULL);
 
-  register int i = 0;
-  for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
-      gint * cmd_index = g_new0(gint, 1);
-      *cmd_index = i;
-      gchar * key_string = g_strdup_printf (_("custom_cmd_button%d"), i);
-      greeter_item_register_action_callback (key_string,
-					     (ActionFunc)query_greeter_custom_cmd_handler,
-					     cmd_index);
-      g_free (key_string);
+  for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+	  gint * cmd_index = g_new0(gint, 1);
+	  *cmd_index = i;
+	  gchar * key_string = g_strdup_printf (_("custom_cmd_button%d"), i);
+	  greeter_item_register_action_callback (key_string,
+						 (ActionFunc)query_greeter_custom_cmd_handler,
+						 cmd_index);
+	  g_free (key_string);
   }
 }
--- gdm2/gui/greeter/greeter.c.org	2006-10-29 12:14:30.000000000 +0000
+++ gdm2/gui/greeter/greeter.c	2006-10-29 14:44:37.000000000 +0000
@@ -719,6 +719,8 @@
 static void
 gdm_read_config (void)
 {
+	gint i;
+
 	/* Read config data in bulk */
 	gdmcomm_comm_bulk_start ();
 
@@ -778,9 +780,8 @@
 	gdm_config_get_bool   (GDM_KEY_ADD_GTK_MODULES);
 
 	/* Keys for custom commands */
-	register int i = 0;
-	gchar * key_string = NULL;	
-	for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+	for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+		gchar * key_string = NULL;
 		key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
 		gdm_config_get_string (key_string);
 
@@ -795,9 +796,9 @@
         
 		key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
 		gdm_config_get_string (key_string);
-	}     
 
-	g_free (key_string);
+		g_free (key_string);
+	}     
 
 	/* Keys not to include in reread_config */
 	gdm_config_get_string (GDM_KEY_SESSION_DESKTOP_DIR);
@@ -810,6 +811,9 @@
 static gboolean
 greeter_reread_config (int sig, gpointer data)
 {
+	gint i;
+	gboolean custom_changed = FALSE;
+
 	/* Read config data in bulk */
 	gdmcomm_comm_bulk_start ();
 
@@ -869,41 +873,39 @@
 		_exit (DISPLAY_RESTARTGREETER);
 	}
 
-	register int i = 0;
-	gboolean custom_changed = FALSE;
-	gchar *key_string = NULL;
-	for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
-  	    key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
-	    if (gdm_config_reload_string (key_string))
-		custom_changed = TRUE;
-	    
-	    key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
-	    if (gdm_config_reload_string (key_string))
-		custom_changed = TRUE;
-	    
-	    key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LR_LABEL_TEMPLATE, i);
-	    if (gdm_config_reload_string (key_string))
-		custom_changed = TRUE;
-	    
-	    key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, i);
-	    if (gdm_config_reload_string (key_string))
-		custom_changed = TRUE;
-	    
-	    key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
-	    if (gdm_config_reload_string (key_string))
-		custom_changed = TRUE;
-	}     
-	
-	g_free (key_string);			
+	for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+		gchar *key_string = NULL;
+		key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+		if (gdm_config_reload_string (key_string))
+			custom_changed = TRUE;
+		
+		key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
+		if (gdm_config_reload_string (key_string))
+			custom_changed = TRUE;
+		
+		key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LR_LABEL_TEMPLATE, i);
+		if (gdm_config_reload_string (key_string))
+			custom_changed = TRUE;
+		
+		key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, i);
+		if (gdm_config_reload_string (key_string))
+			custom_changed = TRUE;
+		
+		key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
+		if (gdm_config_reload_string (key_string))
+			custom_changed = TRUE;
 
+		g_free (key_string);
+	}     	
+	
 	if(custom_changed){
-	    /* Set busy cursor */
-	    gdm_common_setup_cursor (GDK_WATCH);
-	    
-	    gdm_wm_save_wm_order ();
-	    gdmcomm_comm_bulk_stop ();
-	    
-	    _exit (DISPLAY_RESTARTGREETER);
+		/* Set busy cursor */
+		gdm_common_setup_cursor (GDK_WATCH);
+		
+		gdm_wm_save_wm_order ();
+		gdmcomm_comm_bulk_stop ();
+		
+		_exit (DISPLAY_RESTARTGREETER);
 	}
 
 	gdm_config_reload_string (GDM_KEY_SOUND_PROGRAM);
@@ -1088,6 +1090,7 @@
   const char *gdm_gtk_theme;
   guint sid;
   int r;
+  gint i;
 
   if (g_getenv ("DOING_GDM_DEVELOPMENT") != NULL)
     DOING_GDM_DEVELOPMENT = TRUE;
@@ -1226,17 +1229,17 @@
   GdmConfiguratorFound    = gdm_working_command_exists (gdm_config_get_string (GDM_KEY_CONFIGURATOR));
 
   GdmCustomCmdsFound = g_new0 (gboolean, GDM_CUSTOM_COMMAND_MAX);
-  register int i = 0;
-  gchar * key_string = NULL;	
-  for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
-      /*  For each possible custom command */      
-      key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
-      GdmCustomCmdsFound[i] = gdm_working_command_exists (gdm_config_get_string (key_string));
-      if (GdmCustomCmdsFound[i])
-	  GdmAnyCustomCmdsFound = TRUE;
-  }
-  g_free (key_string);
+  for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+	  gchar * key_string = NULL;
+	  /*  For each possible custom command */      
+	  key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+	  GdmCustomCmdsFound[i] = gdm_working_command_exists (gdm_config_get_string (key_string));
+	  if (GdmCustomCmdsFound[i])
+		  GdmAnyCustomCmdsFound = TRUE;
 
+	  g_free (key_string);
+  }
+  
   if (g_getenv ("GDM_THEME") != NULL)
      gdm_graphical_theme = g_strdup (g_getenv ("GDM_THEME"));
   else if (gdm_config_get_bool (GDM_KEY_GRAPHICAL_THEME_RAND))
--- gdm2/gui/gdmlogin.c.org	2006-10-29 12:05:52.000000000 +0000
+++ gdm2/gui/gdmlogin.c	2006-10-29 14:40:05.000000000 +0000
@@ -670,18 +670,19 @@
 }
 
 static void
-gdm_custom_cmd_handler (GtkWidget *widget, gint *cmd_id)
+gdm_custom_cmd_handler (GtkWidget *widget, gpointer data)
 {	
-	if (cmd_id) {
-	    gchar * key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, *cmd_id);
-	    if (gdm_wm_warn_dialog (
-		gdm_config_get_string (key_string) , "", GTK_STOCK_OK, NULL, TRUE) == GTK_RESPONSE_YES) {
-		    
-		    printf ("%c%c%c%d\n", STX, BEL, GDM_INTERRUPT_CUSTOM_CMD, *cmd_id);
-		    fflush (stdout);
-	    }
-
-	    g_free (key_string);		
+	if (data) {
+		int *cmd_id = (int*)data;
+		gchar * key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, *cmd_id);
+		if (gdm_wm_warn_dialog (
+			    gdm_config_get_string (key_string) , "", GTK_STOCK_OK, NULL, TRUE) == GTK_RESPONSE_YES) {
+			
+			printf ("%c%c%c%d\n", STX, BEL, GDM_INTERRUPT_CUSTOM_CMD, *cmd_id);
+			fflush (stdout);
+		}
+		
+		g_free (key_string);		
 	}
 }
 
@@ -2274,7 +2275,7 @@
     GtkWidget *stack, *hline1, *hline2, *handle;
     GtkWidget *bbox = NULL;
     GtkWidget /**help_button,*/ *button_box;
-    gint rows;
+    gint rows, i;
     GdkPixbuf *pb;
     GtkWidget *frame;
     int lw, lh;
@@ -2394,9 +2395,8 @@
 		got_anything = TRUE;
 	}
 	
-	register int i = 0;
-	gchar * key_string = NULL;
-	for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+	for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+		gchar * key_string = NULL;
 		key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
 		if (gdm_working_command_exists (gdm_config_get_string (key_string))) {
 			gint * cmd_index = g_new0(gint, 1);
@@ -2410,8 +2410,8 @@
 			gtk_widget_show (GTK_WIDGET (item));
 			got_anything = TRUE;			
 		}
+		g_free (key_string);
 	}
-	g_free (key_string);	
 
 	if (gdm_working_command_exists (gdm_config_get_string (GDM_KEY_HALT))) {
 		item = gtk_menu_item_new_with_mnemonic (_("Shut _Down"));
@@ -2975,6 +2975,8 @@
 static void
 gdm_read_config (void)
 {
+	gint i;
+
 	/* Read config data in bulk */
 	gdmcomm_comm_bulk_start ();
 
@@ -3010,10 +3012,9 @@
 	gdm_config_get_string (GDM_KEY_USE_24_CLOCK);
 	gdm_config_get_string (GDM_KEY_WELCOME);
 
-	/* String keys for custom commands */
-	register int i = 0;
-	gchar * key_string = NULL;	
-	for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {		
+	/* String keys for custom commands */	
+	for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {		
+		gchar * key_string = NULL;
 		key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
 		gdm_config_get_string (key_string);
 
@@ -3028,8 +3029,9 @@
         
 		key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
 		gdm_config_get_string (key_string);
+
+		g_free (key_string);
 	}     
-	g_free (key_string);
 
 	gdm_config_get_int    (GDM_KEY_BACKGROUND_TYPE);
 	gdm_config_get_int    (GDM_KEY_BACKGROUND_PROGRAM_INITIAL_DELAY);
@@ -3081,6 +3083,8 @@
 gdm_reread_config (int sig, gpointer data)
 {
 	gboolean resize = FALSE;
+	gboolean custom_changed = FALSE;
+	gint i;
 
 	/* Read config data in bulk */
 	gdmcomm_comm_bulk_start ();
@@ -3160,10 +3164,8 @@
 	}
 
 	/* Keys for custom commands */
-	register int i = 0;
-	gboolean custom_changed = FALSE;
-	gchar *key_string = NULL;
-	for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+	for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+		gchar *key_string = NULL;
 		key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
 		if(gdm_config_reload_string (key_string))
 			custom_changed = TRUE;
@@ -3183,8 +3185,9 @@
 		key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
 		if(gdm_config_reload_string (key_string))
 			custom_changed = TRUE;
+
+		g_free (key_string);
 	}     
-	g_free (key_string);			
 
 	if(custom_changed){
 		/* Set busy cursor */
