- (djm) Tweak gnome-ssh-askpass2:
- Retry kb and mouse grab a couple of times, so passphrase dialog doesn't immediately fail if you are doing something else when it appears (e.g. dragging a window) - Perform server grab after we have the keyboard and/or pointer to avoid races.
This commit is contained in:
parent
c8936acfe1
commit
0775976dc6
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,11 @@
|
||||||
|
20030224
|
||||||
|
- (djm) Tweak gnome-ssh-askpass2:
|
||||||
|
- Retry kb and mouse grab a couple of times, so passphrase dialog doesn't
|
||||||
|
immediately fail if you are doing something else when it appears (e.g.
|
||||||
|
dragging a window)
|
||||||
|
- Perform server grab after we have the keyboard and/or pointer to avoid
|
||||||
|
races.
|
||||||
|
|
||||||
20030211
|
20030211
|
||||||
- (djm) Cygwin needs libcrypt too. Patch from vinschen@redhat.com
|
- (djm) Cygwin needs libcrypt too. Patch from vinschen@redhat.com
|
||||||
|
|
||||||
|
@ -1097,4 +1105,4 @@
|
||||||
save auth method before monitor_reset_key_state(); bugzilla bug #284;
|
save auth method before monitor_reset_key_state(); bugzilla bug #284;
|
||||||
ok provos@
|
ok provos@
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.2593 2003/02/10 23:04:03 djm Exp $
|
$Id: ChangeLog,v 1.2594 2003/02/24 00:48:22 djm Exp $
|
||||||
|
|
|
@ -36,10 +36,13 @@
|
||||||
* you don't trust your X server. We grab the keyboard always.
|
* you don't trust your X server. We grab the keyboard always.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define GRAB_TRIES 16
|
||||||
|
#define GRAB_WAIT 250 /* milliseconds */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compile with:
|
* Compile with:
|
||||||
*
|
*
|
||||||
* cc `pkg-config --cflags gtk+-2.0` \
|
* cc -Wall `pkg-config --cflags gtk+-2.0` \
|
||||||
* gnome-ssh-askpass2.c -o gnome-ssh-askpass \
|
* gnome-ssh-askpass2.c -o gnome-ssh-askpass \
|
||||||
* `pkg-config --libs gtk+-2.0`
|
* `pkg-config --libs gtk+-2.0`
|
||||||
*
|
*
|
||||||
|
@ -48,6 +51,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
|
@ -84,13 +88,13 @@ passphrase_dialog(char *message)
|
||||||
{
|
{
|
||||||
const char *failed;
|
const char *failed;
|
||||||
char *passphrase, *local;
|
char *passphrase, *local;
|
||||||
char **messages;
|
int result, grab_tries, grab_server, grab_pointer;
|
||||||
int result, i, grab_server, grab_pointer;
|
GtkWidget *dialog, *entry;
|
||||||
GtkWidget *dialog, *entry, *label;
|
|
||||||
GdkGrabStatus status;
|
GdkGrabStatus status;
|
||||||
|
|
||||||
grab_server = (getenv("GNOME_SSH_ASKPASS_GRAB_SERVER") != NULL);
|
grab_server = (getenv("GNOME_SSH_ASKPASS_GRAB_SERVER") != NULL);
|
||||||
grab_pointer = (getenv("GNOME_SSH_ASKPASS_GRAB_POINTER") != NULL);
|
grab_pointer = (getenv("GNOME_SSH_ASKPASS_GRAB_POINTER") != NULL);
|
||||||
|
grab_tries = 0;
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(NULL, 0,
|
dialog = gtk_message_dialog_new(NULL, 0,
|
||||||
GTK_MESSAGE_QUESTION,
|
GTK_MESSAGE_QUESTION,
|
||||||
|
@ -117,23 +121,35 @@ passphrase_dialog(char *message)
|
||||||
|
|
||||||
/* Grab focus */
|
/* Grab focus */
|
||||||
gtk_widget_show_now(dialog);
|
gtk_widget_show_now(dialog);
|
||||||
if (grab_server) {
|
|
||||||
gdk_x11_grab_server();
|
|
||||||
}
|
|
||||||
if (grab_pointer) {
|
if (grab_pointer) {
|
||||||
status = gdk_pointer_grab((GTK_WIDGET(dialog))->window, TRUE,
|
for(;;) {
|
||||||
0, NULL, NULL, GDK_CURRENT_TIME);
|
status = gdk_pointer_grab(
|
||||||
if (status != GDK_GRAB_SUCCESS) {
|
(GTK_WIDGET(dialog))->window, TRUE, 0, NULL,
|
||||||
|
NULL, GDK_CURRENT_TIME);
|
||||||
|
if (status == GDK_GRAB_SUCCESS)
|
||||||
|
break;
|
||||||
|
usleep(GRAB_WAIT * 1000);
|
||||||
|
if (++grab_tries > GRAB_TRIES) {
|
||||||
failed = "mouse";
|
failed = "mouse";
|
||||||
goto nograb;
|
goto nograb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status = gdk_keyboard_grab((GTK_WIDGET(dialog))->window, FALSE,
|
}
|
||||||
GDK_CURRENT_TIME);
|
for(;;) {
|
||||||
if (status != GDK_GRAB_SUCCESS) {
|
status = gdk_keyboard_grab((GTK_WIDGET(dialog))->window,
|
||||||
|
FALSE, GDK_CURRENT_TIME);
|
||||||
|
if (status == GDK_GRAB_SUCCESS)
|
||||||
|
break;
|
||||||
|
usleep(GRAB_WAIT * 1000);
|
||||||
|
if (++grab_tries > GRAB_TRIES) {
|
||||||
failed = "keyboard";
|
failed = "keyboard";
|
||||||
goto nograbkb;
|
goto nograbkb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (grab_server) {
|
||||||
|
gdk_x11_grab_server();
|
||||||
|
}
|
||||||
|
|
||||||
result = gtk_dialog_run(GTK_DIALOG(dialog));
|
result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
|
|
||||||
/* Ungrab */
|
/* Ungrab */
|
||||||
|
|
Loading…
Reference in New Issue