Port to PolicyKit 1

This commit is contained in:
Matthias Clasen 2009-06-09 16:58:07 +00:00
parent 47a938ef6e
commit 09ba6905d3
2 changed files with 370 additions and 4 deletions

View File

@ -8,7 +8,7 @@
%define desktop_file_utils_version 0.2.90 %define desktop_file_utils_version 0.2.90
%define gail_version 1.2.0 %define gail_version 1.2.0
%define nss_version 3.11.1 %define nss_version 3.11.1
%define consolekit_version 0.2.7 %define consolekit_version 0.3.0-9
%define hal_version 0.5.9 %define hal_version 0.5.9
%define fontconfig_version 2.6.0 %define fontconfig_version 2.6.0
%define _default_patch_fuzz 999 %define _default_patch_fuzz 999
@ -16,7 +16,7 @@
Summary: The GNOME Display Manager Summary: The GNOME Display Manager
Name: gdm Name: gdm
Version: 2.26.1 Version: 2.26.1
Release: 5%{?dist} Release: 8%{?dist}
Epoch: 1 Epoch: 1
License: GPLv2+ License: GPLv2+
Group: User Interface/X Group: User Interface/X
@ -46,7 +46,6 @@ Requires: xorg-x11-xkb-utils
Requires: xorg-x11-xinit Requires: xorg-x11-xinit
Requires: hal >= %{hal_version} Requires: hal >= %{hal_version}
Requires: ConsoleKit >= %{consolekit_version} Requires: ConsoleKit >= %{consolekit_version}
Requires: PolicyKit-authentication-agent
Requires: gnome-settings-daemon >= 2.21.92 Requires: gnome-settings-daemon >= 2.21.92
Requires: iso-codes Requires: iso-codes
Requires: gnome-session Requires: gnome-session
@ -79,7 +78,6 @@ BuildRequires: xorg-x11-server-Xorg
%endif %endif
BuildRequires: nss-devel >= %{nss_version} BuildRequires: nss-devel >= %{nss_version}
BuildRequires: ConsoleKit BuildRequires: ConsoleKit
BuildRequires: PolicyKit-gnome-devel >= %{polkit_version}
BuildRequires: libselinux-devel BuildRequires: libselinux-devel
BuildRequires: check-devel BuildRequires: check-devel
BuildRequires: iso-codes-devel BuildRequires: iso-codes-devel
@ -98,6 +96,9 @@ Patch13: gdm-system-keyboard.patch
Patch19: gdm-2.26.1-multistack.patch Patch19: gdm-2.26.1-multistack.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=498361
Patch20: polkit1.patch
# fixed upstream, rh 502778 # fixed upstream, rh 502778
Patch22: gdm-2.26.0-fix-lang-regex.patch Patch22: gdm-2.26.0-fix-lang-regex.patch
@ -144,6 +145,7 @@ The GDM fingerprint plugin provides functionality necessary to use a fingerprint
%patch13 -p1 -b .system-keyboard %patch13 -p1 -b .system-keyboard
%patch19 -p1 -b .multistack %patch19 -p1 -b .multistack
%patch20 -p1 -b .polkit1
%patch22 -p1 -b .fix-lang-regex %patch22 -p1 -b .fix-lang-regex
%patch99 -p1 -b .fedora-logo %patch99 -p1 -b .fedora-logo
@ -386,6 +388,9 @@ fi
%{_libdir}/gdm/simple-greeter/plugins/fingerprint.so %{_libdir}/gdm/simple-greeter/plugins/fingerprint.so
%changelog %changelog
* Tue May 12 2009 Matthias Clasen <mclasen@redhat.com> - 1:2.26.1-8
- Port to PolicyKit 1
* Wed Jun 03 2009 Ray Strode <rstrode@redhat.com> - 1:2.26.1-5 * Wed Jun 03 2009 Ray Strode <rstrode@redhat.com> - 1:2.26.1-5
- Fix language parsing code (bug 502778) - Fix language parsing code (bug 502778)

361
polkit1.patch Normal file
View File

@ -0,0 +1,361 @@
diff -up gdm-2.26.1/configure.ac.polkit1 gdm-2.26.1/configure.ac
--- gdm-2.26.1/configure.ac.polkit1 2009-05-13 18:15:11.618938539 -0400
+++ gdm-2.26.1/configure.ac 2009-05-13 18:15:58.034936628 -0400
@@ -62,7 +62,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=3.5
#FONTCONFIG_REQUIRED_VERSION=2.6.0
@@ -142,30 +141,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 -up gdm-2.26.1/gui/simple-greeter/gdm-greeter-login-window.c.polkit1 gdm-2.26.1/gui/simple-greeter/gdm-greeter-login-window.c
--- gdm-2.26.1/gui/simple-greeter/gdm-greeter-login-window.c.polkit1 2009-05-13 18:15:11.730937911 -0400
+++ gdm-2.26.1/gui/simple-greeter/gdm-greeter-login-window.c 2009-05-13 18:15:11.811971897 -0400
@@ -59,10 +59,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-marshal.h"
#include "gdm-settings-client.h"
@@ -1292,119 +1288,6 @@ try_system_restart (DBusGConnection *con
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)
{
@@ -1421,69 +1304,12 @@ do_system_restart (GdmGreeterLoginWindow
}
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
@@ -1502,67 +1328,12 @@ do_system_stop (GdmGreeterLoginWindow *l
}
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
diff -up gdm-2.26.1/gui/simple-greeter/Makefile.am.polkit1 gdm-2.26.1/gui/simple-greeter/Makefile.am
--- gdm-2.26.1/gui/simple-greeter/Makefile.am.polkit1 2009-05-13 18:15:11.512938382 -0400
+++ gdm-2.26.1/gui/simple-greeter/Makefile.am 2009-05-13 18:15:11.814939276 -0400
@@ -24,7 +24,6 @@ AM_CPPFLAGS = \
$(DISABLE_DEPRECATED_CFLAGS) \
$(GTK_CFLAGS) \
$(SIMPLE_GREETER_CFLAGS) \
- $(POLKIT_GNOME_CFLAGS) \
$(NULL)
@INTLTOOL_SCHEMAS_RULE@
@@ -101,7 +100,6 @@ test_greeter_login_window_LDADD = \
libgdmuser.la \
$(COMMON_LIBS) \
$(SIMPLE_GREETER_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(RBAC_LIBS) \
$(NULL)
@@ -262,7 +260,6 @@ test_user_chooser_LDADD = \
libgdmuser.la \
$(COMMON_LIBS) \
$(SIMPLE_GREETER_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(NULL)
test_user_manager_SOURCES = \
@@ -273,7 +270,6 @@ test_user_manager_LDADD = \
libgdmuser.la \
$(COMMON_LIBS) \
$(SIMPLE_GREETER_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(NULL)
libexec_PROGRAMS = \
@@ -344,7 +340,6 @@ gdm_simple_greeter_LDADD = \
$(COMMON_LIBS) \
$(EXTRA_GREETER_LIBS) \
$(SIMPLE_GREETER_LIBS) \
- $(POLKIT_GNOME_LIBS) \
$(RBAC_LIBS) \
$(LIBXKLAVIER_LIBS) \
$(NULL)