From d4769a48b4a0609bce011fab848e24a343936065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Thu, 5 May 2022 01:25:37 +0200 Subject: [PATCH] polkit-gnome: Get some usability patches from fedora MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Müller --- recipes-gnome/polkit-gnome/polkit-gnome.bb | 8 +- ...c-check.patch => 0001-gtk-doc-check.patch} | 0 .../0002-select-default-user.patch | 72 ++++++++ .../polkit-gnome/0003-autorestart.patch | 171 ++++++++++++++++++ .../0004-use-accountsservice.patch | 132 ++++++++++++++ .../0005-fresh-x11-timestamps.patch | 38 ++++ ...alog-make-the-label-wrap-at-70-chars.patch | 33 ++++ 7 files changed, 453 insertions(+), 1 deletion(-) rename recipes-gnome/polkit-gnome/polkit-gnome/{gtk-doc-check.patch => 0001-gtk-doc-check.patch} (100%) create mode 100644 recipes-gnome/polkit-gnome/polkit-gnome/0002-select-default-user.patch create mode 100644 recipes-gnome/polkit-gnome/polkit-gnome/0003-autorestart.patch create mode 100644 recipes-gnome/polkit-gnome/polkit-gnome/0004-use-accountsservice.patch create mode 100644 recipes-gnome/polkit-gnome/polkit-gnome/0005-fresh-x11-timestamps.patch create mode 100644 recipes-gnome/polkit-gnome/polkit-gnome/0006-auth-dialog-make-the-label-wrap-at-70-chars.patch diff --git a/recipes-gnome/polkit-gnome/polkit-gnome.bb b/recipes-gnome/polkit-gnome/polkit-gnome.bb index 4a762cf..f878569 100644 --- a/recipes-gnome/polkit-gnome/polkit-gnome.bb +++ b/recipes-gnome/polkit-gnome/polkit-gnome.bb @@ -17,9 +17,15 @@ inherit autotools pkgconfig gtk-doc features_check REQUIRED_DISTRO_FEATURES = "x11 polkit" +# 0002-0006 were taken from https://src.fedoraproject.org/rpms/polkit-gnome/tree/rawhide SRC_URI = " \ git://gitlab.gnome.org/Archive/policykit-gnome.git;branch=master;protocol=https \ - file://gtk-doc-check.patch \ + file://0001-gtk-doc-check.patch \ + file://0002-select-default-user.patch \ + file://0003-autorestart.patch \ + file://0004-use-accountsservice.patch \ + file://0005-fresh-x11-timestamps.patch \ + file://0006-auth-dialog-make-the-label-wrap-at-70-chars.patch \ " SRCREV = "a0763a246a81188f60b0f9810143e49224dc752f" S = "${WORKDIR}/git" diff --git a/recipes-gnome/polkit-gnome/polkit-gnome/gtk-doc-check.patch b/recipes-gnome/polkit-gnome/polkit-gnome/0001-gtk-doc-check.patch similarity index 100% rename from recipes-gnome/polkit-gnome/polkit-gnome/gtk-doc-check.patch rename to recipes-gnome/polkit-gnome/polkit-gnome/0001-gtk-doc-check.patch diff --git a/recipes-gnome/polkit-gnome/polkit-gnome/0002-select-default-user.patch b/recipes-gnome/polkit-gnome/polkit-gnome/0002-select-default-user.patch new file mode 100644 index 0000000..d8d4292 --- /dev/null +++ b/recipes-gnome/polkit-gnome/polkit-gnome/0002-select-default-user.patch @@ -0,0 +1,72 @@ +# 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/recipes-gnome/polkit-gnome/polkit-gnome/0003-autorestart.patch b/recipes-gnome/polkit-gnome/polkit-gnome/0003-autorestart.patch new file mode 100644 index 0000000..30a93b5 --- /dev/null +++ b/recipes-gnome/polkit-gnome/polkit-gnome/0003-autorestart.patch @@ -0,0 +1,171 @@ +## 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/recipes-gnome/polkit-gnome/polkit-gnome/0004-use-accountsservice.patch b/recipes-gnome/polkit-gnome/polkit-gnome/0004-use-accountsservice.patch new file mode 100644 index 0000000..47ee2c3 --- /dev/null +++ b/recipes-gnome/polkit-gnome/polkit-gnome/0004-use-accountsservice.patch @@ -0,0 +1,132 @@ +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/recipes-gnome/polkit-gnome/polkit-gnome/0005-fresh-x11-timestamps.patch b/recipes-gnome/polkit-gnome/polkit-gnome/0005-fresh-x11-timestamps.patch new file mode 100644 index 0000000..4c56a6f --- /dev/null +++ b/recipes-gnome/polkit-gnome/polkit-gnome/0005-fresh-x11-timestamps.patch @@ -0,0 +1,38 @@ +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,17 @@ + } + + gtk_widget_show_all (GTK_WIDGET (authenticator->dialog)); +- gtk_window_present (GTK_WINDOW (authenticator->dialog)); ++ GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (authenticator->dialog)); ++ ++ if (GDK_IS_X11_WINDOW (window)) ++ { ++ gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog), gdk_x11_get_server_time (window)); ++ } ++ else ++ { ++ gtk_window_present (GTK_WINDOW (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/recipes-gnome/polkit-gnome/polkit-gnome/0006-auth-dialog-make-the-label-wrap-at-70-chars.patch b/recipes-gnome/polkit-gnome/polkit-gnome/0006-auth-dialog-make-the-label-wrap-at-70-chars.patch new file mode 100644 index 0000000..bc2853f --- /dev/null +++ b/recipes-gnome/polkit-gnome/polkit-gnome/0006-auth-dialog-make-the-label-wrap-at-70-chars.patch @@ -0,0 +1,33 @@ +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 */ +