--- gnome-session-2.6.2.old/gnome-session/logout.c	2004-07-26 20:15:50.000000000 +0200
+++ gnome-session-2.6.2/gnome-session/logout.c	2004-07-31 12:21:00.000000000 +0200
@@ -37,12 +37,17 @@
 
 static gchar *halt_command[] =
 {
-  HALT_COMMAND, NULL
+  "/usr/bin/gdmflexiserver", "--sm-disable", "-a", "-c", "SET_SAFE_LOGOUT_ACTION HALT", NULL
 };
 
 static gchar *reboot_command[] =
 {
-  REBOOT_COMMAND, NULL
+  "/usr/bin/gdmflexiserver", "--sm-disable", "-a", "-c", "SET_SAFE_LOGOUT_ACTION REBOOT", NULL
+};
+
+static gchar *gdm_query_command[] =
+{
+  "/usr/bin/gdmflexiserver", "--sm-disable", "-a", "-c", "QUERY_LOGOUT_ACTION", NULL
 };
 
 /* What action to take upon shutdown */
@@ -286,6 +291,31 @@
   return label;
 }
 
+/* returns true if we are running under a GDM that
+   supports shutdown upon exit */
+static gboolean
+gdm_shutdown_available (void)
+{
+  gchar *output = NULL;
+  gchar *err = NULL;
+  gint status;
+  gboolean ret;
+
+  if (!g_file_test ("/var/run/gdm.pid", G_FILE_TEST_IS_REGULAR))
+    return FALSE;
+  
+  ret = g_spawn_sync (NULL, gdm_query_command, NULL, 0, NULL, NULL, &output,
+  		      &err, &status, NULL);
+
+  if (ret && status)
+    ret = FALSE;
+  if (ret && g_str_has_prefix (output, "ERROR"))
+    ret = FALSE;
+
+  g_free (output);
+  return ret;
+}
+
 static gboolean
 display_gui (void)
 {
@@ -296,7 +326,6 @@
   GtkWidget *image;
   GtkWidget *toggle_button = NULL;
   gint response;
-  gchar *s, *t;
   GtkWidget *halt = NULL;
   GtkWidget *reboot = NULL;
   GtkWidget *invisible;
@@ -395,14 +424,7 @@
 			  FALSE, TRUE, 0);
     }
 
-  /* Red Hat specific code to check if the user has a
-   * good chance of being able to shutdown the system,
-   * and if so, give them that option
-   */
-  s = g_strconcat ("/var/lock/console/", g_get_user_name (), NULL);
-  t = g_strconcat ("/var/run/console/", g_get_user_name (), NULL);
-  if (((geteuid () == 0) || g_file_exists (t) || g_file_exists(s)) &&
-      access (halt_command[0], X_OK) == 0)
+  if (gdm_shutdown_available ())
     {
       GtkWidget *title, *spacer;
       GtkWidget *action_vbox, *hbox;
@@ -442,8 +464,6 @@
       gtk_box_pack_start (GTK_BOX (action_vbox), r, FALSE, FALSE, 0);
       gtk_widget_show (r);
     }
-  g_free (s);
-  g_free (t);
 
   gsm_center_window_on_screen (GTK_WINDOW (box), screen, monitor);
 
