rpms/gdm/devel ck-multi.patch,NONE,1.1 gdm.spec,1.360,1.361

Matthias Clasen (mclasen) fedora-extras-commits at redhat.com
Sun Apr 6 03:18:16 UTC 2008


Author: mclasen

Update of /cvs/extras/rpms/gdm/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9139

Modified Files:
	gdm.spec 
Added Files:
	ck-multi.patch 
Log Message:
Improve handling of CK error messages


ck-multi.patch:

--- NEW FILE ck-multi.patch ---
diff -up gdm-2.21.10/gui/simple-greeter/gdm-greeter-login-window.c.ck-multi gdm-2.21.10/gui/simple-greeter/gdm-greeter-login-window.c
--- gdm-2.21.10/gui/simple-greeter/gdm-greeter-login-window.c.ck-multi	2008-04-05 20:39:49.000000000 -0400
+++ gdm-2.21.10/gui/simple-greeter/gdm-greeter-login-window.c	2008-04-05 20:42:23.000000000 -0400
@@ -1036,20 +1036,41 @@ static PolKitAction *
 get_action_from_error (GError *error)
 {
         PolKitAction *action;
-        const char   *paction;
+        char 	     *paction;
+	char	     *p;
 
         action = polkit_action_new ();
 
         paction = NULL;
         if (g_str_has_prefix (error->message, "Not privileged for action: ")) {
-                paction = error->message + strlen ("Not privileged for action: ");
+                paction = g_strdup (error->message + strlen ("Not privileged for action: "));
+		p = strchr (paction, ' ');
+		if (p) 
+			*p = '\0';
         }
         g_debug ("GdmGreeterLoginWindow: Requesting priv for '%s'", paction);
 
         polkit_action_set_action_id (action, paction);
 
+	g_free (paction);
+
         return action;
 }
+
+static PolKitResult
+get_result_from_error (GError *error)
+{
+	PolKitResult result = POLKIT_RESULT_UNKNOWN;
+	const char *p;
+
+	p = strrchr (error->message, ' ');
+	if (p) {
+		p++;
+		polkit_result_from_string_representation (p, &result);
+	}
+
+	return result;
+}
 #endif
 
 static void
@@ -1076,11 +1097,40 @@ do_system_restart (GdmGreeterLoginWindow
 
                 if (dbus_g_error_has_name (error, "org.freedesktop.ConsoleKit.Manager.NotPrivileged")) {
                         PolKitAction *action;
+                        PolKitAction *action2;
+			PolKitResult  result;
+			GtkWidget    *dialog;
                         guint         xid;
                         pid_t         pid;
 
+			result = get_result_from_error (error);
                         action = get_action_from_error (error);
 
+			if (result == POLKIT_RESULT_NO) {
+				action2 = polkit_action_new ();
+				polkit_action_set_action_id (action2,
+							     "org.freedesktop.consolekit.system.restart-multiple-users");
+				dialog = gtk_message_dialog_new (GTK_WINDOW (login_window),
+								 GTK_DIALOG_MODAL,
+								 GTK_MESSAGE_ERROR,
+								 GTK_BUTTONS_OK,
+								 _("Failed to restart computer"));
+				if (polkit_action_equal (action, action2)) {
+					gtk_message_dialog_format_secondary_text (dialog,
+										  _("You are not allowed to restart the computer "
+										    "because multiple users are logged in"));
+				}
+				gtk_dialog_run (GTK_DIALOG (dialog));
+				gtk_widget_destroy (dialog);
+
+				polkit_action_unref (action);
+				polkit_action_unref (action2);
+
+				g_error_free (error);
+
+				return;
+			}
+
                         xid = 0;
                         pid = getpid ();
 
@@ -1128,14 +1178,41 @@ do_system_stop (GdmGreeterLoginWindow *l
 
                 if (dbus_g_error_has_name (error, "org.freedesktop.ConsoleKit.Manager.NotPrivileged")) {
                         PolKitAction *action;
+                        PolKitAction *action2;
+			PolKitResult  result;
+			GtkWidget    *dialog;
                         guint         xid;
                         pid_t         pid;
 
                         xid = 0;
                         pid = getpid ();
 
+			result = get_result_from_error (error);
                         action = get_action_from_error (error);
 
+			if (result == POLKIT_RESULT_NO) {
+				action2 = polkit_action_new ();
+				polkit_action_set_action_id (action2,
+							     "org.freedesktop.consolekit.system.stop-multiple-users");
+				dialog = gtk_message_dialog_new (GTK_WINDOW (login_window),
+								 GTK_DIALOG_MODAL,
+								 GTK_MESSAGE_ERROR,
+								 GTK_BUTTONS_OK,
+								 _("Failed to stop computer"));
+				if (polkit_action_equal (action, action2)) {
+					gtk_message_dialog_format_secondary_text (dialog,
+										  _("You are not allowed to stop the computer "
+										    "because multiple users are logged in"));
+				}
+				gtk_dialog_run (GTK_DIALOG (dialog));
+				gtk_widget_destroy (dialog);
+
+				polkit_action_unref (action);
+				polkit_action_unref (action2);
+
+				return;
+			}
+
                         g_error_free (error);
                         error = NULL;
                         res = polkit_gnome_auth_obtain (action,


Index: gdm.spec
===================================================================
RCS file: /cvs/extras/rpms/gdm/devel/gdm.spec,v
retrieving revision 1.360
retrieving revision 1.361
diff -u -r1.360 -r1.361
--- gdm.spec	6 Apr 2008 02:22:46 -0000	1.360
+++ gdm.spec	6 Apr 2008 03:17:28 -0000	1.361
@@ -16,7 +16,7 @@
 Summary: The GNOME Display Manager
 Name: gdm
 Version: 2.21.10
-Release: 0.2008.04.04.1%{?dist}
+Release: 0.2008.04.04.2%{?dist}
 Epoch: 1
 License: GPLv2+
 Group: User Interface/X
@@ -75,6 +75,7 @@
 BuildRequires: gnome-panel-devel
 
 Requires: audit-libs >= %{libauditver}
+Patch0: ck-multi.patch
 Patch99: gdm-2.21.8-fedora-logo.patch
 
 %package user-switch-applet
@@ -94,7 +95,7 @@
 
 %prep
 %setup -q
-
+%patch0 -p1 -b .ck-multi
 %patch99 -p1 -b .fedora-logo
 
 %build
@@ -291,6 +292,9 @@
 %{_datadir}/gnome-2.0/ui/GNOME_FastUserSwitchApplet.xml
 
 %changelog
+* Sat Apr  5 2008 Matthias Clasen <mclasen at redhat.com> - 1:2.21.10-0.2008.04.04.2
+- Improve handling of CK error messages
+
 * Sat Apr  5 2008 Ray Strode <rstrode at redhat.com> - 1:2.21.10-0.2008.04.04.1
 - Fix jump in animation for autologin
 - Fix crash if LANG="somethingbogus"




More information about the fedora-extras-commits mailing list