summaryrefslogtreecommitdiff
path: root/contrib/gnome-ssh-askpass.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-12-21 10:28:07 +1100
committerDamien Miller <djm@mindrot.org>2001-12-21 10:28:07 +1100
commitfaf2f6483a344a3f7d73181dd5f154a9c7fa0c7c (patch)
tree8da5c84786b99291c9f5579556ab0aba5e3b5c54 /contrib/gnome-ssh-askpass.c
parent366298c696e8c5b27bd27d683ea7b8bf30564362 (diff)
- (djm) Add option to gnome-ssh-askpass to stop it from grabbing the X
server. I have found this necessary to avoid server hangs with X input extensions (e.g. kinput2). Enable by setting the environment variable "GNOME_SSH_ASKPASS_NOGRAB"
Diffstat (limited to 'contrib/gnome-ssh-askpass.c')
-rw-r--r--contrib/gnome-ssh-askpass.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/contrib/gnome-ssh-askpass.c b/contrib/gnome-ssh-askpass.c
index 27e5ccaa1..31aec46b7 100644
--- a/contrib/gnome-ssh-askpass.c
+++ b/contrib/gnome-ssh-askpass.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000 Damien Miller. All rights reserved. 2 * Copyright (c) 2000-2001 Damien Miller. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
@@ -23,6 +23,17 @@
23 */ 23 */
24 24
25/* 25/*
26 * This is a simple GNOME SSH passphrase grabber. To use it, set the
27 * environment variable SSH_ASKPASS to point to the location of
28 * gnome-ssh-askpass before calling "ssh-add < /dev/null".
29 *
30 * There is only one run-time option: if you set the environment variable
31 * "GNOME_SSH_ASKPASS_NOGRAB=true" then gnome-ssh-askpass will not grab
32 * the X server. I have found this necessary to avoid server hangs with
33 * X input extensions (e.g. kinput2) enabled. - djm
34 */
35
36/*
26 * Compile with: 37 * Compile with:
27 * 38 *
28 * cc `gnome-config --cflags gnome gnomeui` \ 39 * cc `gnome-config --cflags gnome gnomeui` \
@@ -57,10 +68,11 @@ passphrase_dialog(char *message)
57{ 68{
58 char *passphrase; 69 char *passphrase;
59 char **messages; 70 char **messages;
60 int result, i; 71 int result, i, grab_server;
61
62 GtkWidget *dialog, *entry, *label; 72 GtkWidget *dialog, *entry, *label;
63 73
74 grab_server = (getenv("GNOME_SSH_ASKPASS_NOGRAB") == NULL);
75
64 dialog = gnome_dialog_new("OpenSSH", GNOME_STOCK_BUTTON_OK, 76 dialog = gnome_dialog_new("OpenSSH", GNOME_STOCK_BUTTON_OK,
65 GNOME_STOCK_BUTTON_CANCEL, NULL); 77 GNOME_STOCK_BUTTON_CANCEL, NULL);
66 78
@@ -89,7 +101,8 @@ passphrase_dialog(char *message)
89 gtk_widget_show_all(dialog); 101 gtk_widget_show_all(dialog);
90 102
91 /* Grab focus */ 103 /* Grab focus */
92 XGrabServer(GDK_DISPLAY()); 104 if (grab_server)
105 XGrabServer(GDK_DISPLAY());
93 if (gdk_pointer_grab(dialog->window, TRUE, 0, NULL, NULL, 106 if (gdk_pointer_grab(dialog->window, TRUE, 0, NULL, NULL,
94 GDK_CURRENT_TIME)) 107 GDK_CURRENT_TIME))
95 goto nograb; 108 goto nograb;
@@ -103,7 +116,8 @@ passphrase_dialog(char *message)
103 result = gnome_dialog_run(GNOME_DIALOG(dialog)); 116 result = gnome_dialog_run(GNOME_DIALOG(dialog));
104 117
105 /* Ungrab */ 118 /* Ungrab */
106 XUngrabServer(GDK_DISPLAY()); 119 if (grab_server)
120 XUngrabServer(GDK_DISPLAY());
107 gdk_pointer_ungrab(GDK_CURRENT_TIME); 121 gdk_pointer_ungrab(GDK_CURRENT_TIME);
108 gdk_keyboard_ungrab(GDK_CURRENT_TIME); 122 gdk_keyboard_ungrab(GDK_CURRENT_TIME);
109 gdk_flush(); 123 gdk_flush();
@@ -126,7 +140,8 @@ passphrase_dialog(char *message)
126 nograbkb: 140 nograbkb:
127 gdk_pointer_ungrab(GDK_CURRENT_TIME); 141 gdk_pointer_ungrab(GDK_CURRENT_TIME);
128 nograb: 142 nograb:
129 XUngrabServer(GDK_DISPLAY()); 143 if (grab_server)
144 XUngrabServer(GDK_DISPLAY());
130 gnome_dialog_close(GNOME_DIALOG(dialog)); 145 gnome_dialog_close(GNOME_DIALOG(dialog));
131 146
132 report_failed_grab(); 147 report_failed_grab();