3 ** GNOME ssh passphrase requestor
5 ** Damien Miller <djm@ibs.com.au>
7 ** Copyright 1999 Internet Business Solutions
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:
17 ** The above copyright notice and this permission notice shall be
18 ** included in all copies or substantial portions of the Software.
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.
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.
41 int passphrase_dialog(char **passphrase_p, char *message)
46 GtkWidget *dialog, *entry, *label;
48 dialog = gnome_dialog_new("OpenSSH", GNOME_STOCK_BUTTON_OK,
49 GNOME_STOCK_BUTTON_CANCEL, NULL);
51 label = gtk_label_new(message);
52 gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), label, FALSE,
54 gtk_widget_show(label);
56 entry = gtk_entry_new();
57 gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), entry, FALSE,
59 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
60 gtk_widget_grab_focus(entry);
61 gtk_widget_show(entry);
64 result = gnome_dialog_run(GNOME_DIALOG(dialog));
66 passphrase = gtk_entry_get_text(GTK_ENTRY(entry));
68 /* Take copy of passphrase if user selected OK */
70 *passphrase_p = strdup(passphrase);
74 /* Zero existing passphrase */
75 memset(passphrase, '\0', strlen(passphrase));
76 gtk_entry_set_text(GTK_ENTRY(entry), passphrase);
78 gnome_dialog_close(GNOME_DIALOG(dialog));
83 int main(int argc, char **argv)
88 gnome_init("GNOME ssh-askpass", "0.1", argc, argv);
93 message = "Enter your OpenSSH passphrase:";
95 if (passphrase_dialog(&passphrase, message))
97 printf("%s\n", passphrase);
98 memset(passphrase, '\0', strlen(passphrase));