]> andersk Git - openssh.git/blobdiff - contrib/gnome-ssh-askpass1.c
- (dtucker) Bug #1677: add conditionals around the source for ssh-askpass.
[openssh.git] / contrib / gnome-ssh-askpass1.c
index 7cece562011174099fea86f273c70ee3b4f006cc..4d51032d1d369afe1b17c9118b11b7911e5440f5 100644 (file)
  */
 
 /*
- * This is a simple GNOME SSH passphrase grabber. To use it, set the 
- * environment variable SSH_ASKPASS to point to the location of 
- * gnome-ssh-askpass before calling "ssh-add < /dev/null". 
+ * This is a simple GNOME SSH passphrase grabber. To use it, set the
+ * environment variable SSH_ASKPASS to point to the location of
+ * gnome-ssh-askpass before calling "ssh-add < /dev/null".
  *
  * There is only two run-time options: if you set the environment variable
  * "GNOME_SSH_ASKPASS_GRAB_SERVER=true" then gnome-ssh-askpass will grab
- * the X server. If you set "GNOME_SSH_ASKPASS_GRAB_POINTER=true", then the 
- * pointer will be grabbed too. These may have some benefit to security if 
+ * the X server. If you set "GNOME_SSH_ASKPASS_GRAB_POINTER=true", then the
+ * pointer will be grabbed too. These may have some benefit to security if
  * you don't trust your X server. We grab the keyboard always.
  */
 
@@ -38,7 +38,7 @@
  * Compile with:
  *
  * cc `gnome-config --cflags gnome gnomeui` \
- *    gnome-ssh-askpass.c -o gnome-ssh-askpass \
+ *    gnome-ssh-askpass1.c -o gnome-ssh-askpass \
  *    `gnome-config --libs gnome gnomeui`
  *
  */
@@ -64,7 +64,7 @@ report_failed_grab (void)
        gnome_dialog_run_and_close(GNOME_DIALOG(err));
 }
 
-void
+int
 passphrase_dialog(char *message)
 {
        char *passphrase;
@@ -87,7 +87,7 @@ passphrase_dialog(char *message)
                }
 
        entry = gtk_entry_new();
-       gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), entry, FALSE, 
+       gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), entry, FALSE,
            FALSE, 0);
        gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
        gtk_widget_grab_focus(entry);
@@ -105,7 +105,7 @@ passphrase_dialog(char *message)
        /* Grab focus */
        if (grab_server)
                XGrabServer(GDK_DISPLAY());
-       if (grab_pointer && gdk_pointer_grab(dialog->window, TRUE, 0, 
+       if (grab_pointer && gdk_pointer_grab(dialog->window, TRUE, 0,
            NULL, NULL, GDK_CURRENT_TIME))
                goto nograb;
        if (gdk_keyboard_grab(dialog->window, FALSE, GDK_CURRENT_TIME))
@@ -135,7 +135,7 @@ passphrase_dialog(char *message)
        gtk_entry_set_text(GTK_ENTRY(entry), passphrase);
                        
        gnome_dialog_close(GNOME_DIALOG(dialog));
-       return;
+       return (result == 0 ? 0 : -1);
 
        /* At least one grab failed - ungrab what we got, and report
           the failure to the user.  Note that XGrabServer() cannot
@@ -148,13 +148,15 @@ passphrase_dialog(char *message)
        gnome_dialog_close(GNOME_DIALOG(dialog));
        
        report_failed_grab();
+       return (-1);
 }
 
 int
 main(int argc, char **argv)
 {
        char *message;
-       
+       int result;
+
        gnome_init("GNOME ssh-askpass", "0.1", argc, argv);
 
        if (argc == 2)
@@ -163,6 +165,7 @@ main(int argc, char **argv)
                message = "Enter your OpenSSH passphrase:";
 
        setvbuf(stdout, 0, _IONBF, 0);
-       passphrase_dialog(message);
-       return 0;
+       result = passphrase_dialog(message);
+
+       return (result);
 }
This page took 0.044282 seconds and 4 git commands to generate.