Patrick Williams | 3f0e7fe | 2023-05-01 12:32:19 -0500 | [diff] [blame^] | 1 | From: Jeffrey Knockel <jeff250@gmail.com> |
| 2 | Date: Mon, 30 Apr 2018 18:05:20 +0000 |
| 3 | Subject: Use fresh X11 timestamps when displaying authentication dialog |
| 4 | |
| 5 | This circumvents focus-stealing prevention. |
| 6 | |
| 7 | Bug: https://bugzilla.gnome.org/show_bug.cgi?id=676076 |
| 8 | Bug-Debian: https://bugs.debian.org/684300 |
| 9 | Bug-Ubuntu: https://launchpad.net/bugs/946171 |
| 10 | |
| 11 | Upstream-Status: Pending |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | --- |
| 14 | src/polkitgnomeauthenticator.c | 4 +++- |
| 15 | 1 file changed, 3 insertions(+), 1 deletion(-) |
| 16 | |
| 17 | diff --git a/src/polkitgnomeauthenticator.c b/src/polkitgnomeauthenticator.c |
| 18 | index 23163b4..e57d76e 100644 |
| 19 | --- a/src/polkitgnomeauthenticator.c |
| 20 | +++ b/src/polkitgnomeauthenticator.c |
| 21 | @@ -26,6 +26,7 @@ |
| 22 | #include <sys/types.h> |
| 23 | #include <pwd.h> |
| 24 | #include <glib/gi18n.h> |
| 25 | +#include <gdk/gdkx.h> |
| 26 | |
| 27 | #include <polkit/polkit.h> |
| 28 | #include <polkitagent/polkitagent.h> |
| 29 | @@ -306,7 +307,17 @@ session_request (PolkitAgentSession *session, |
| 30 | } |
| 31 | |
| 32 | gtk_widget_show_all (GTK_WIDGET (authenticator->dialog)); |
| 33 | - gtk_window_present (GTK_WINDOW (authenticator->dialog)); |
| 34 | + GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (authenticator->dialog)); |
| 35 | + |
| 36 | + if (GDK_IS_X11_WINDOW (window)) |
| 37 | + { |
| 38 | + gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog), gdk_x11_get_server_time (window)); |
| 39 | + } |
| 40 | + else |
| 41 | + { |
| 42 | + gtk_window_present (GTK_WINDOW (authenticator->dialog)); |
| 43 | + } |
| 44 | + |
| 45 | password = polkit_gnome_authentication_dialog_run_until_response_for_prompt (POLKIT_GNOME_AUTHENTICATION_DIALOG (authenticator->dialog), |
| 46 | modified_request, |
| 47 | echo_on, |
| 48 | |