From 2f8a6e1f2d00755719eec44bef6af2462b4a23f6 Mon Sep 17 00:00:00 2001 From: leigh123linux Date: Wed, 9 Sep 2015 11:44:32 +0100 Subject: [PATCH] add ububtu fixes as upstream is dead --- ...alog-make-the-label-wrap-at-70-chars.patch | 32 ++++ 02-select-default-user.patch | 71 ++++++++ 04-autorestart.patch | 170 ++++++++++++++++++ 06-authentication-failure-string.patch | 17 ++ 07-use-accountsservice.patch | 131 ++++++++++++++ 08-fresh-x11-timestamps.patch | 28 +++ polkit-gnome.spec | 18 +- remove_g_type_init.patch | 10 ++ 8 files changed, 474 insertions(+), 3 deletions(-) create mode 100644 0001-auth-dialog-make-the-label-wrap-at-70-chars.patch create mode 100644 02-select-default-user.patch create mode 100644 04-autorestart.patch create mode 100644 06-authentication-failure-string.patch create mode 100644 07-use-accountsservice.patch create mode 100644 08-fresh-x11-timestamps.patch create mode 100644 remove_g_type_init.patch diff --git a/0001-auth-dialog-make-the-label-wrap-at-70-chars.patch b/0001-auth-dialog-make-the-label-wrap-at-70-chars.patch new file mode 100644 index 0000000..5a5f288 --- /dev/null +++ b/0001-auth-dialog-make-the-label-wrap-at-70-chars.patch @@ -0,0 +1,32 @@ +From 277ab6123451d2d1c15a1f851dd2e038905814a5 Mon Sep 17 00:00:00 2001 +From: Lars Uebernickel +Date: Fri, 17 Oct 2014 15:35:25 +0200 +Subject: [PATCH] auth dialog: make the label wrap at 70 chars + +Because GtkWindow doesn't have a default width anymore. + +https://bugzilla.gnome.org/show_bug.cgi?id=738688 +--- + src/polkitgnomeauthenticationdialog.c | 2 ++ + 1 file changed, 2 insertions(+) + +Index: policykit-1-gnome-0.105/src/polkitgnomeauthenticationdialog.c +=================================================================== +--- policykit-1-gnome-0.105.orig/src/polkitgnomeauthenticationdialog.c ++++ policykit-1-gnome-0.105/src/polkitgnomeauthenticationdialog.c +@@ -661,6 +661,7 @@ polkit_gnome_authentication_dialog_const + g_free (s); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); ++ gtk_label_set_max_width_chars (GTK_LABEL (label), 70); + gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); + + /* secondary message */ +@@ -688,6 +689,7 @@ polkit_gnome_authentication_dialog_const + } + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); ++ gtk_label_set_max_width_chars (GTK_LABEL (label), 70); + gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); + + /* user combobox */ diff --git a/02-select-default-user.patch b/02-select-default-user.patch new file mode 100644 index 0000000..d19f87d --- /dev/null +++ b/02-select-default-user.patch @@ -0,0 +1,71 @@ +# Description: Select the current user to authenticate with by default +# Ubuntu: https://launchpad.net/bugs/435227 +# Upstream: http://bugzilla.gnome.org/show_bug.cgi?id=596188 + +Index: policykit-1-gnome/src/polkitgnomeauthenticationdialog.c +=================================================================== +--- policykit-1-gnome.orig/src/polkitgnomeauthenticationdialog.c 2011-03-04 00:06:46.599981036 +0100 ++++ policykit-1-gnome/src/polkitgnomeauthenticationdialog.c 2011-03-04 00:07:11.211981036 +0100 +@@ -138,7 +138,7 @@ + static void + create_user_combobox (PolkitGnomeAuthenticationDialog *dialog) + { +- int n; ++ int n, i, selected_index = 0; + GtkComboBox *combo; + GtkTreeIter iter; + GtkCellRenderer *renderer; +@@ -162,7 +162,7 @@ + + + /* For each user */ +- for (n = 0; dialog->priv->users[n] != NULL; n++) ++ for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++) + { + gchar *gecos; + gchar *real_name; +@@ -224,6 +224,14 @@ + USERNAME_COL, dialog->priv->users[n], + -1); + ++ i++; ++ if (passwd->pw_uid == getuid ()) ++ { ++ selected_index = i; ++ g_free (dialog->priv->selected_user); ++ dialog->priv->selected_user = g_strdup (dialog->priv->users[n]); ++ } ++ + g_free (real_name); + g_object_unref (pixbuf); + } +@@ -252,8 +260,8 @@ + user_combobox_set_sensitive, + NULL, NULL); + +- /* Initially select the "Select user..." ... */ +- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); ++ /* Select the default user */ ++ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index); + + /* Listen when a new user is selected */ + g_signal_connect (GTK_WIDGET (combo), +@@ -719,16 +727,13 @@ + gtk_widget_set_tooltip_markup (label, s); + g_free (s); + +- if (have_user_combobox) ++ /* Disable password entry and authenticate until have a user selected */ ++ if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0) + { +- /* ... and make the password entry and "Authenticate" button insensitive */ + gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE); + gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE); + gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE); + } +- else +- { +- } + + gtk_widget_realize (GTK_WIDGET (dialog)); + diff --git a/04-autorestart.patch b/04-autorestart.patch new file mode 100644 index 0000000..df7e7a0 --- /dev/null +++ b/04-autorestart.patch @@ -0,0 +1,170 @@ +## Description: Add gnome session restart support to ensure we always have +## a authentication agent running +## Author: Michael Vogt +## Origin: inspired by the at-spi dbus support code +## Bug: http://launchpad.net/bugs/623819 +Index: policykit-1-gnome-0.105/src/main.c +=================================================================== +--- policykit-1-gnome-0.105.orig/src/main.c 2011-10-25 11:30:59.000000000 -0400 ++++ policykit-1-gnome-0.105/src/main.c 2011-12-19 09:23:47.635697248 -0500 +@@ -38,11 +38,150 @@ + + static GDBusConnection *session_bus_connection = NULL; + ++// session management support for auto-restart ++#define SM_DBUS_NAME "org.gnome.SessionManager" ++#define SM_DBUS_PATH "/org/gnome/SessionManager" ++#define SM_DBUS_INTERFACE "org.gnome.SessionManager" ++#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate" ++ ++static GDBusProxy *sm_proxy; ++static GDBusProxy *client_proxy = NULL; ++ ++static GMainLoop *loop; ++ ++ ++static void ++stop_cb (void) ++{ ++ g_main_loop_quit (loop); ++} ++ ++static gboolean ++end_session_response (gboolean is_okay, const gchar *reason) ++{ ++ GVariant *res; ++ GError *error = NULL; ++ ++ res = g_dbus_proxy_call_sync (client_proxy, ++ "EndSessionResponse", ++ g_variant_new ("(bs)", ++ is_okay, ++ reason), ++ G_DBUS_CALL_FLAGS_NONE, ++ -1, /* timeout */ ++ NULL, /* GCancellable */ ++ &error); ++ if (! res) { ++ g_warning ("Failed to call EndSessionResponse: %s", error->message); ++ g_error_free (error); ++ return FALSE; ++ } ++ ++ g_variant_unref (res); ++ return TRUE; ++} ++ ++static void ++query_end_session_cb (void) ++{ ++ end_session_response (TRUE, ""); ++} ++ ++static void ++end_session_cb (void) ++{ ++ end_session_response (TRUE, ""); ++ g_main_loop_quit (loop); ++} ++ ++static void ++signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name, ++ GVariant *parameters, gpointer user_data) ++{ ++ if (strcmp (signal_name, "Stop") == 0) { ++ stop_cb (); ++ } else if (strcmp (signal_name, "QueryEndSession") == 0) { ++ query_end_session_cb (); ++ } else if (strcmp (signal_name, "EndSession") == 0) { ++ end_session_cb (); ++ } ++} ++ ++static gboolean ++register_client_to_gnome_session (void) ++{ ++ GError *error = NULL; ++ GVariant *res; ++ const char *startup_id; ++ const char *app_id; ++ char *client_id; ++ ++ startup_id = g_getenv ("DESKTOP_AUTOSTART_ID"); ++ app_id = "polkit-gnome-authentication-agent-1.desktop"; ++ ++ sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, ++ G_DBUS_PROXY_FLAGS_NONE, ++ NULL, /* GDBusInterfaceInfo */ ++ SM_DBUS_NAME, ++ SM_DBUS_PATH, ++ SM_DBUS_INTERFACE, ++ NULL, /* GCancellable */ ++ &error); ++ if (sm_proxy == NULL) { ++ g_message("Failed to get session manager: %s", error->message); ++ g_error_free (error); ++ return FALSE; ++ } ++ ++ res = g_dbus_proxy_call_sync (sm_proxy, ++ "RegisterClient", ++ g_variant_new ("(ss)", ++ app_id, ++ startup_id), ++ G_DBUS_CALL_FLAGS_NONE, ++ -1, /* timeout */ ++ NULL, /* GCancellable */ ++ &error); ++ if (! res) { ++ g_warning ("Failed to register client: %s", error->message); ++ g_error_free (error); ++ return FALSE; ++ } ++ ++ if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) { ++ g_warning ("RegisterClient returned unexpected type %s", ++ g_variant_get_type_string (res)); ++ return FALSE; ++ } ++ ++ g_variant_get (res, "(&o)", &client_id); ++ ++ // implement the signals to fix "policykit agent not responding" ++ // error (LP: #623819) ++ client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, ++ G_DBUS_PROXY_FLAGS_NONE, ++ NULL, /* GDBusInterfaceInfo */ ++ SM_DBUS_NAME, ++ client_id, ++ SM_CLIENT_DBUS_INTERFACE, ++ NULL, /* GCancellable */ ++ &error); ++ g_variant_unref (res); ++ if (client_proxy == NULL) { ++ g_message("Failed to get client proxy: %s", error->message); ++ g_error_free (error); ++ return FALSE; ++ } ++ ++ g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL); ++ ++ return TRUE; ++} ++ + int + main (int argc, char **argv) + { + gint ret; +- GMainLoop *loop; + PolkitAgentListener *listener; + GError *error; + +@@ -101,6 +240,8 @@ + */ + session_bus_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); + ++ register_client_to_gnome_session(); ++ + g_main_loop_run (loop); + + ret = 0; diff --git a/06-authentication-failure-string.patch b/06-authentication-failure-string.patch new file mode 100644 index 0000000..d5ce982 --- /dev/null +++ b/06-authentication-failure-string.patch @@ -0,0 +1,17 @@ +Description: Improve error message displayed when authentication fails +Bug: https://bugzilla.gnome.org/show_bug.cgi?id=592978 +Bug-Ubuntu: http://launchpad.net/bugs/411559 + +Index: policykit-1-gnome-0.105/src/polkitgnomeauthenticator.c +=================================================================== +--- policykit-1-gnome-0.105.orig/src/polkitgnomeauthenticator.c 2011-12-19 09:25:02.275695807 -0500 ++++ policykit-1-gnome-0.105/src/polkitgnomeauthenticator.c 2011-12-19 09:25:02.343695805 -0500 +@@ -454,7 +454,7 @@ + { + gchar *s; + +- s = g_strconcat ("", _("Authentication Failure"), "", NULL); ++ s = g_strconcat ("", _("Your authentication attempt was unsuccessful. Please try again."), "", NULL); + polkit_gnome_authentication_dialog_set_info_message ( + POLKIT_GNOME_AUTHENTICATION_DIALOG (authenticator->dialog), + s); diff --git a/07-use-accountsservice.patch b/07-use-accountsservice.patch new file mode 100644 index 0000000..c5e5d17 --- /dev/null +++ b/07-use-accountsservice.patch @@ -0,0 +1,131 @@ +Description: get user icon from accountsservice instead of looking in ~/.face +Author: Marc Deslauriers +Forwarded: yes +Bug: https://bugzilla.gnome.org/show_bug.cgi?id=669857 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/policykit-1-gnome/+bug/928249 + +Index: policykit-1-gnome-0.105/src/polkitgnomeauthenticationdialog.c +=================================================================== +--- policykit-1-gnome-0.105.orig/src/polkitgnomeauthenticationdialog.c 2012-02-11 00:10:48.850913210 -0500 ++++ policykit-1-gnome-0.105/src/polkitgnomeauthenticationdialog.c 2012-02-11 00:22:04.462930509 -0500 +@@ -135,6 +135,102 @@ + } + } + ++static GdkPixbuf * ++get_user_icon (char *username) ++{ ++ GError *error; ++ GDBusConnection *connection; ++ GVariant *find_user_result; ++ GVariant *get_icon_result; ++ GVariant *icon_result_variant; ++ const gchar *user_path; ++ const gchar *icon_filename; ++ GdkPixbuf *pixbuf; ++ ++ error = NULL; ++ connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); ++ ++ if (connection == NULL) ++ { ++ g_warning ("Unable to connect to system bus: %s", error->message); ++ g_error_free (error); ++ return NULL; ++ } ++ ++ find_user_result = g_dbus_connection_call_sync (connection, ++ "org.freedesktop.Accounts", ++ "/org/freedesktop/Accounts", ++ "org.freedesktop.Accounts", ++ "FindUserByName", ++ g_variant_new ("(s)", ++ username), ++ G_VARIANT_TYPE ("(o)"), ++ G_DBUS_CALL_FLAGS_NONE, ++ -1, ++ NULL, ++ &error); ++ ++ if (find_user_result == NULL) ++ { ++ g_warning ("Accounts couldn't find user: %s", error->message); ++ g_error_free (error); ++ return NULL; ++ } ++ ++ user_path = g_variant_get_string (g_variant_get_child_value (find_user_result, 0), ++ NULL); ++ ++ get_icon_result = g_dbus_connection_call_sync (connection, ++ "org.freedesktop.Accounts", ++ user_path, ++ "org.freedesktop.DBus.Properties", ++ "Get", ++ g_variant_new ("(ss)", ++ "org.freedesktop.Accounts.User", ++ "IconFile"), ++ G_VARIANT_TYPE ("(v)"), ++ G_DBUS_CALL_FLAGS_NONE, ++ -1, ++ NULL, ++ &error); ++ ++ g_variant_unref (find_user_result); ++ ++ if (get_icon_result == NULL) ++ { ++ g_warning ("Accounts couldn't find user icon: %s", error->message); ++ g_error_free (error); ++ return NULL; ++ } ++ ++ g_variant_get_child (get_icon_result, 0, "v", &icon_result_variant); ++ icon_filename = g_variant_get_string (icon_result_variant, NULL); ++ ++ if (icon_filename == NULL) ++ { ++ g_warning ("Accounts didn't return a valid filename for user icon"); ++ pixbuf = NULL; ++ } ++ else ++ { ++ /* TODO: we probably shouldn't hard-code the size to 16x16 */ ++ pixbuf = gdk_pixbuf_new_from_file_at_size (icon_filename, ++ 16, ++ 16, ++ &error); ++ if (pixbuf == NULL) ++ { ++ g_warning ("Couldn't open user icon: %s", error->message); ++ g_error_free (error); ++ } ++ } ++ ++ g_variant_unref (icon_result_variant); ++ g_variant_unref (get_icon_result); ++ ++ return pixbuf; ++} ++ + static void + create_user_combobox (PolkitGnomeAuthenticationDialog *dialog) + { +@@ -197,16 +293,7 @@ + g_free (gecos); + + /* Load users face */ +- pixbuf = NULL; +- if (passwd->pw_dir != NULL) +- { +- gchar *path; +- path = g_strdup_printf ("%s/.face", passwd->pw_dir); +- /* TODO: we probably shouldn't hard-code the size to 16x16 */ +- pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL); +- g_free (path); +- } +- ++ pixbuf = get_user_icon (dialog->priv->users[n]); + /* fall back to avatar-default icon */ + if (pixbuf == NULL) + { diff --git a/08-fresh-x11-timestamps.patch b/08-fresh-x11-timestamps.patch new file mode 100644 index 0000000..9a282e3 --- /dev/null +++ b/08-fresh-x11-timestamps.patch @@ -0,0 +1,28 @@ +Description: use fresh X11 timestamps when displaying authentication dialog + to circumvent focus-stealing prevention. +Author: Jeffrey Knockel +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/policykit-gnome/+bug/946171 +Bug: https://bugzilla.gnome.org/show_bug.cgi?id=676076 + +Index: policykit-1-gnome-0.105/src/polkitgnomeauthenticator.c +=================================================================== +--- policykit-1-gnome-0.105.orig/src/polkitgnomeauthenticator.c 2012-07-27 00:39:09.000000000 -0600 ++++ policykit-1-gnome-0.105/src/polkitgnomeauthenticator.c 2012-07-27 00:40:27.185547436 -0600 +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -307,7 +308,8 @@ + } + + gtk_widget_show_all (GTK_WIDGET (authenticator->dialog)); +- gtk_window_present (GTK_WINDOW (authenticator->dialog)); ++ gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog), ++ gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog)))); + password = polkit_gnome_authentication_dialog_run_until_response_for_prompt (POLKIT_GNOME_AUTHENTICATION_DIALOG (authenticator->dialog), + modified_request, + echo_on, diff --git a/polkit-gnome.spec b/polkit-gnome.spec index bc6855c..955a9f4 100644 --- a/polkit-gnome.spec +++ b/polkit-gnome.spec @@ -1,11 +1,18 @@ Summary: PolicyKit integration for the GNOME desktop Name: polkit-gnome Version: 0.105 -Release: 8%{?dist} +Release: 9%{?dist} License: LGPLv2+ URL: http://www.freedesktop.org/wiki/Software/PolicyKit Group: Applications/System Source0: http://hal.freedesktop.org/releases/%{name}-%{version}.tar.xz +Patch0: 02-select-default-user.patch +Patch1: 04-autorestart.patch +Patch2: 06-authentication-failure-string.patch +Patch3: 07-use-accountsservice.patch +Patch4: 08-fresh-x11-timestamps.patch +Patch5: 0001-auth-dialog-make-the-label-wrap-at-70-chars.patch +Patch6: remove_g_type_init.patch BuildRequires: gtk3-devel BuildRequires: glib2-devel >= 2.25.11 @@ -13,6 +20,7 @@ BuildRequires: polkit-devel >= 0.97-1 BuildRequires: desktop-file-utils BuildRequires: intltool BuildRequires: gobject-introspection-devel +BuildRequires: gnome-common BuildRequires: gtk-doc Obsoletes: PolicyKit-gnome <= 0.10 @@ -33,11 +41,12 @@ polkit-gnome provides an authentication agent for PolicyKit that matches the look and feel of the GNOME desktop. %prep -%setup -q +%autosetup -p1 +NOCONFIGURE=1 ./autogen.sh %build %configure -make %{?_smp_mflags} +make %{?_smp_mflags} V=1 %install %{make_install} @@ -58,6 +67,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la %changelog +* Thu Aug 27 2015 Leigh Scott - 0.105-9 +- add ububtu fixes as upstream is dead + * Thu Jun 18 2015 Leigh Scott - 0.105-8 - use license tag for COPYING diff --git a/remove_g_type_init.patch b/remove_g_type_init.patch new file mode 100644 index 0000000..6297ad7 --- /dev/null +++ b/remove_g_type_init.patch @@ -0,0 +1,10 @@ +--- a/src/main.c ++++ b/src/main.c +@@ -46,7 +46,6 @@ + PolkitAgentListener *listener; + GError *error; + +- g_type_init (); + gtk_init (&argc, &argv); + + loop = NULL;