diff options
author | Damien Miller <djm@mindrot.org> | 2000-03-15 12:13:01 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-03-15 12:13:01 +1100 |
commit | 8b1c22b7758511461b359461926e47b093a349d3 (patch) | |
tree | 482ba5094683dac130413f7c2d4971e9b2a31761 /gnome-ssh-askpass.c | |
parent | f09b07a971f64cf69f2c45a364c3d56559f7c1c3 (diff) |
- Created contrib/ subdirectory. Included helpers from Phil Hands'
Debian package, README file and chroot patch from Ricardo Cerqueira
<rmcc@clix.pt>
- Moved gnome-ssh-askpass.c to contrib directory and reomved config
option.
- Slight cleanup to doc files
Diffstat (limited to 'gnome-ssh-askpass.c')
-rw-r--r-- | gnome-ssh-askpass.c | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/gnome-ssh-askpass.c b/gnome-ssh-askpass.c deleted file mode 100644 index 97e9cc3e2..000000000 --- a/gnome-ssh-askpass.c +++ /dev/null | |||
@@ -1,125 +0,0 @@ | |||
1 | /* | ||
2 | ** | ||
3 | ** GNOME ssh passphrase requestor | ||
4 | ** | ||
5 | ** Damien Miller <djm@ibs.com.au> | ||
6 | ** | ||
7 | ** Copyright 1999 Internet Business Solutions | ||
8 | ** | ||
9 | ** Permission is hereby granted, free of charge, to any person | ||
10 | ** obtaining a copy of this software and associated documentation | ||
11 | ** files (the "Software"), to deal in the Software without | ||
12 | ** restriction, including without limitation the rights to use, copy, | ||
13 | ** modify, merge, publish, distribute, sublicense, and/or sell copies | ||
14 | ** of the Software, and to permit persons to whom the Software is | ||
15 | ** furnished to do so, subject to the following conditions: | ||
16 | ** | ||
17 | ** The above copyright notice and this permission notice shall be | ||
18 | ** included in all copies or substantial portions of the Software. | ||
19 | ** | ||
20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | ||
21 | ** KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
22 | ** WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE | ||
23 | ** AND NONINFRINGEMENT. IN NO EVENT SHALL DAMIEN MILLER OR INTERNET | ||
24 | ** BUSINESS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
25 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
26 | ** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE | ||
27 | ** OR OTHER DEALINGS IN THE SOFTWARE. | ||
28 | ** | ||
29 | ** Except as contained in this notice, the name of Internet Business | ||
30 | ** Solutions shall not be used in advertising or otherwise to promote | ||
31 | ** the sale, use or other dealings in this Software without prior | ||
32 | ** written authorization from Internet Business Solutions. | ||
33 | ** | ||
34 | */ | ||
35 | |||
36 | #include <stdlib.h> | ||
37 | #include <stdio.h> | ||
38 | #include <string.h> | ||
39 | #include <gnome.h> | ||
40 | #include <X11/Xlib.h> | ||
41 | #include <gdk/gdkx.h> | ||
42 | |||
43 | int passphrase_dialog(char **passphrase_p, char *message) | ||
44 | { | ||
45 | char *passphrase; | ||
46 | int result; | ||
47 | |||
48 | GtkWidget *dialog, *entry, *label; | ||
49 | |||
50 | dialog = gnome_dialog_new("OpenSSH", GNOME_STOCK_BUTTON_OK, | ||
51 | GNOME_STOCK_BUTTON_CANCEL, NULL); | ||
52 | |||
53 | label = gtk_label_new(message); | ||
54 | gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), label, FALSE, | ||
55 | FALSE, 0); | ||
56 | |||
57 | entry = gtk_entry_new(); | ||
58 | gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), entry, FALSE, | ||
59 | FALSE, 0); | ||
60 | gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); | ||
61 | gtk_widget_grab_focus(entry); | ||
62 | |||
63 | /* Center window and prepare for grab */ | ||
64 | gtk_object_set(GTK_OBJECT(dialog), "type", GTK_WINDOW_POPUP, NULL); | ||
65 | gnome_dialog_set_default(GNOME_DIALOG(dialog), 0); | ||
66 | gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); | ||
67 | gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, TRUE); | ||
68 | gnome_dialog_close_hides(GNOME_DIALOG(dialog), TRUE); | ||
69 | gtk_container_set_border_width(GTK_CONTAINER(GNOME_DIALOG(dialog)->vbox), GNOME_PAD); | ||
70 | gtk_widget_show_all(dialog); | ||
71 | |||
72 | /* Grab focus */ | ||
73 | XGrabServer(GDK_DISPLAY()); | ||
74 | gdk_pointer_grab(dialog->window, TRUE, 0, NULL, NULL, GDK_CURRENT_TIME); | ||
75 | gdk_keyboard_grab(dialog->window, FALSE, GDK_CURRENT_TIME); | ||
76 | |||
77 | /* Make <enter> close dialog */ | ||
78 | gnome_dialog_editable_enters(GNOME_DIALOG(dialog), GTK_EDITABLE(entry)); | ||
79 | |||
80 | /* Run dialog */ | ||
81 | result = gnome_dialog_run(GNOME_DIALOG(dialog)); | ||
82 | |||
83 | /* Ungrab */ | ||
84 | XUngrabServer(GDK_DISPLAY()); | ||
85 | gdk_pointer_ungrab(GDK_CURRENT_TIME); | ||
86 | gdk_keyboard_ungrab(GDK_CURRENT_TIME); | ||
87 | gdk_flush(); | ||
88 | |||
89 | passphrase = gtk_entry_get_text(GTK_ENTRY(entry)); | ||
90 | |||
91 | /* Take copy of passphrase if user selected OK */ | ||
92 | if (result == 0) | ||
93 | *passphrase_p = strdup(passphrase); | ||
94 | else | ||
95 | *passphrase_p = NULL; | ||
96 | |||
97 | /* Zero existing passphrase */ | ||
98 | memset(passphrase, '\0', strlen(passphrase)); | ||
99 | gtk_entry_set_text(GTK_ENTRY(entry), passphrase); | ||
100 | |||
101 | gnome_dialog_close(GNOME_DIALOG(dialog)); | ||
102 | |||
103 | return (result == 0); | ||
104 | } | ||
105 | |||
106 | int main(int argc, char **argv) | ||
107 | { | ||
108 | char *passphrase; | ||
109 | char *message; | ||
110 | |||
111 | gnome_init("GNOME ssh-askpass", "0.1", argc, argv); | ||
112 | |||
113 | if (argc == 2) | ||
114 | message = argv[1]; | ||
115 | else | ||
116 | message = "Enter your OpenSSH passphrase:"; | ||
117 | |||
118 | if (passphrase_dialog(&passphrase, message)) | ||
119 | { | ||
120 | puts(passphrase); | ||
121 | memset(passphrase, '\0', strlen(passphrase)); | ||
122 | } | ||
123 | |||
124 | return 0; | ||
125 | } | ||