[gdm] Port greeter to PolicyKit 1.0
- From: Ray Strode <halfline src gnome org>
- To: svn-commits-list gnome org
- Subject: [gdm] Port greeter to PolicyKit 1.0
- Date: Fri, 17 Jul 2009 02:24:23 +0000 (UTC)
commit 55e252f5deddaadbb71451a37bc3feeb764d764b
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jul 16 22:23:55 2009 -0400
Port greeter to PolicyKit 1.0
configure.ac | 25 ---
gui/simple-greeter/Makefile.am | 5 -
gui/simple-greeter/gdm-greeter-login-window.c | 237 +------------------------
3 files changed, 4 insertions(+), 263 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fe18675..22fff72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,6 @@ PANGO_REQUIRED_VERSION=1.3.0
LIBGLADE_REQUIRED_VERSION=1.99.2
SCROLLKEEPER_REQUIRED_VERSION=0.1.4
GCONF_REQUIRED_VERSION=2.6.1
-POLICYKIT_REQUIRED_VERSION=0.8
GNOME_PANEL_REQUIRED_VERSION=2.0.0
LIBXKLAVIER_REQUIRED_VERSION=4.0
#FONTCONFIG_REQUIRED_VERSION=2.6.0
@@ -118,30 +117,6 @@ AC_SUBST(HAVE_LIBXKLAVIER)
AC_SUBST(LIBXKLAVIER_CFLAGS)
AC_SUBST(LIBXKLAVIER_LIBS)
-PKG_CHECK_MODULES(POLKIT_GNOME,
- polkit-gnome >= $POLICYKIT_REQUIRED_VERSION,
- have_polkit=yes,
- have_polkit=no)
-
-AC_ARG_ENABLE([polkit],
- AS_HELP_STRING([--enable-polkit],
- [Enable PolicyKit support @<:@default=auto@:>@]),
- enable_polkit=$enableval, enable_polkit=auto)
-
-if test "x$enable_polkit" != "xno"; then
- if test "x$enable_polkit" = "xyes" -a "x$have_polkit" = "xno"; then
- AC_MSG_ERROR([PolicyKit support explicitly requested but dependencies not found])
- fi
-
- if test "x$have_polkit" = "xyes" ; then
- AC_DEFINE(HAVE_POLKIT_GNOME, [], [Define if we have polkit])
- fi
-fi
-AM_CONDITIONAL(HAVE_POLKIT_GNOME, test x$have_polkit = xyes)
-AC_SUBST(HAVE_POLKIT_GNOME)
-AC_SUBST(POLKIT_GNOME_CFLAGS)
-AC_SUBST(POLKIT_GNOME_LIBS)
-
PKG_CHECK_MODULES(SIMPLE_CHOOSER,
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
diff --git a/gui/simple-greeter/Makefile.am b/gui/simple-greeter/Makefile.am
index 9b5834d..b36aa28 100644
--- a/gui/simple-greeter/Makefile.am
+++ b/gui/simple-greeter/Makefile.am
@@ -20,7 +20,6 @@ AM_CPPFLAGS = \
$(DISABLE_DEPRECATED_CFLAGS) \
$(GTK_CFLAGS) \
$(SIMPLE_GREETER_CFLAGS) \
- $(POLKIT_GNOME_CFLAGS) \
$(NULL)
@INTLTOOL_SCHEMAS_RULE@
@@ -90,7 +89,6 @@ test_greeter_login_window_LDADD = \
libgdmuser.la \
$(COMMON_LIBS) \
$(SIMPLE_GREETER_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(RBAC_LIBS) \
$(NULL)
@@ -250,7 +248,6 @@ test_user_chooser_LDADD = \
libgdmuser.la \
$(COMMON_LIBS) \
$(SIMPLE_GREETER_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(NULL)
test_user_manager_SOURCES = \
@@ -261,7 +258,6 @@ test_user_manager_LDADD = \
libgdmuser.la \
$(COMMON_LIBS) \
$(SIMPLE_GREETER_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(NULL)
libexec_PROGRAMS = \
@@ -325,7 +321,6 @@ gdm_simple_greeter_LDADD = \
$(COMMON_LIBS) \
$(EXTRA_GREETER_LIBS) \
$(SIMPLE_GREETER_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(RBAC_LIBS) \
$(LIBXKLAVIER_LIBS) \
$(NULL)
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index ae95068..c7ea5d6 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -56,10 +56,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#ifdef HAVE_POLKIT_GNOME
-#include <polkit-gnome/polkit-gnome.h>
-#endif
-
#include "gdm-settings-client.h"
#include "gdm-settings-keys.h"
#include "gdm-profile.h"
@@ -1074,119 +1070,6 @@ try_system_restart (DBusGConnection *connection,
return res;
}
-#ifdef HAVE_POLKIT_GNOME
-static void
-system_restart_auth_cb (PolKitAction *action,
- gboolean gained_privilege,
- GError *error,
- GdmGreeterLoginWindow *login_window)
-{
- GError *local_error;
- DBusGConnection *connection;
- gboolean res;
-
- g_debug ("GdmGreeterLoginWindow: system restart auth callback gained=%s", gained_privilege ? "yes" : "no");
-
- if (! gained_privilege) {
- if (error != NULL) {
- g_warning ("GdmGreeterLoginWindow: system restart error: %s", error->message);
- }
- return;
- }
-
- local_error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &local_error);
- if (connection == NULL) {
- g_warning ("Unable to get system bus connection: %s", local_error->message);
- g_error_free (local_error);
- return;
- }
-
- res = try_system_restart (connection, &local_error);
- if (! res) {
- g_warning ("Unable to restart system: %s", local_error->message);
- g_error_free (local_error);
- return;
- }
-}
-
-static void
-system_stop_auth_cb (PolKitAction *action,
- gboolean gained_privilege,
- GError *error,
- GdmGreeterLoginWindow *login_window)
-{
- GError *local_error;
- DBusGConnection *connection;
- gboolean res;
-
- g_debug ("GdmGreeterLoginWindow: system stop auth callback gained=%s", gained_privilege ? "yes" : "no");
-
- if (! gained_privilege) {
- if (error != NULL) {
- g_warning ("GdmGreeterLoginWindow: system stop error: %s", error->message);
- }
- return;
- }
-
- local_error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &local_error);
- if (connection == NULL) {
- g_warning ("Unable to get system bus connection: %s", local_error->message);
- g_error_free (local_error);
- return;
- }
-
- res = try_system_stop (connection, &local_error);
- if (! res) {
- g_warning ("Unable to stop system: %s", local_error->message);
- g_error_free (local_error);
- return;
- }
-}
-
-static PolKitAction *
-get_action_from_error (GError *error)
-{
- PolKitAction *action;
- char *paction;
- char *p;
-
- action = polkit_action_new ();
-
- paction = NULL;
- if (g_str_has_prefix (error->message, "Not privileged for action: ")) {
- paction = g_strdup (error->message + strlen ("Not privileged for action: "));
- p = strchr (paction, ' ');
- if (p != NULL) {
- *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 != NULL) {
- p++;
- polkit_result_from_string_representation (p, &result);
- }
-
- return result;
-}
-#endif
-
static void
do_system_restart (GdmGreeterLoginWindow *login_window)
{
@@ -1203,69 +1086,12 @@ do_system_restart (GdmGreeterLoginWindow *login_window)
}
res = try_system_restart (connection, &error);
-#ifdef HAVE_POLKIT_GNOME
- if (! res) {
+ if (!res) {
g_debug ("GdmGreeterLoginWindow: unable to restart system: %s: %s",
dbus_g_error_get_name (error),
error->message);
-
- 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 (GTK_MESSAGE_DIALOG (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 ();
-
- g_error_free (error);
- error = NULL;
- res = polkit_gnome_auth_obtain (action,
- xid,
- pid,
- (PolKitGnomeAuthCB) system_restart_auth_cb,
- login_window,
- &error);
- polkit_action_unref (action);
-
- if (! res) {
- g_warning ("Unable to request privilege for action: %s", error->message);
- g_error_free (error);
- }
-
- }
+ g_error_free (error);
}
-#endif
}
static void
@@ -1284,67 +1110,12 @@ do_system_stop (GdmGreeterLoginWindow *login_window)
}
res = try_system_stop (connection, &error);
-#ifdef HAVE_POLKIT_GNOME
- if (! res) {
+ if (!res) {
g_debug ("GdmGreeterLoginWindow: unable to stop system: %s: %s",
dbus_g_error_get_name (error),
error->message);
-
- 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 (GTK_MESSAGE_DIALOG (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,
- xid,
- pid,
- (PolKitGnomeAuthCB) system_stop_auth_cb,
- login_window,
- &error);
- polkit_action_unref (action);
-
- if (! res) {
- g_warning ("Unable to request privilege for action: %s", error->message);
- g_error_free (error);
- }
-
- }
+ g_error_free (error);
}
-#endif
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]