diff lib/sshv2.c @ 460:075f89b4395c

2004-4-14 Brian Masney <masneyb@gftp.org> * lib/sshv2.c lib/gftp.h src/text/textui.c src/gtk/gtkui.c - when connecting with the SSH protocol, if the user is asked a question, relay that question back to the user and allow them to answer it. * doc/gftp-faq.sgml - moved the SSH troubleshooting section to the issues for older releases section. All of the issues that this talks about have been fixed in CVS. * src/gtk/gftp-gtk.c (main) - call gdk_threads_init() on startup * lib/cache.c lib/config_file.c lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c - removed some uses of strlen() so that they only occur once on a string instead of multiple times in some cases * lib/sslcommon.c - fixed typo * configure.in lib/gftp.h - added configure check for inttypes.h * docs/gftp.lsm - updated with 2.0.17 information
author masneyb
date Thu, 15 Apr 2004 00:59:23 +0000
parents 656a0b3d1403
children 632036c6e4a4
line wrap: on
line diff
--- a/lib/sshv2.c	Sat Apr 10 20:39:06 2004 +0000
+++ b/lib/sshv2.c	Thu Apr 15 00:59:23 2004 +0000
@@ -260,12 +260,13 @@
 static int
 sshv2_start_login_sequence (gftp_request * request, int fdm, int ptymfd)
 {
+  char *tempstr, *pwstr, *tmppos, *yesstr = "yes\n", *question_pos;
   size_t rem, len, diff, lastdiff;
-  char *tempstr, *pwstr, *tmppos;
   int wrotepw, ok, maxfd, ret;
   fd_set rset, eset;
   ssize_t rd;
 
+  question_pos = NULL;
   rem = len = SSH_LOGIN_BUFSIZE;
   tempstr = g_malloc0 (len + 1);
   diff = lastdiff = 0;
@@ -385,13 +386,23 @@
         }
       else if (diff > 10 && strcmp (tempstr + diff - 10, "(yes/no)? ") == 0)
         {
-          ok = SSH_ERROR_QUESTION;
-          break;
+          question_pos = tempstr + diff;
+          if (!gftpui_protocol_ask_yes_no (request, request->hostname, tempstr))
+            {
+              ok = SSH_ERROR_QUESTION;
+              break;
+            }
+          else
+            {
+              if (gftp_fd_write (request, yesstr, strlen (yesstr), ptymfd) < 0)
+                {
+                  ok = 0;
+                  break;
+                }
+            }
         }
       else if (rem <= 1)
         {
-          request->logging_function (gftp_logging_recv, request,
-                                     "%s", tempstr + lastdiff);
           len += SSH_LOGIN_BUFSIZE;
           rem += SSH_LOGIN_BUFSIZE;
           lastdiff = diff;
@@ -402,9 +413,14 @@
 
   g_free (pwstr);
 
-  if (*(tempstr + lastdiff) != '\0')
-    request->logging_function (gftp_logging_recv, request,
-                               "%s\n", tempstr + lastdiff);
+  if (question_pos != NULL)
+    {
+      if (*question_pos != '\0')
+        request->logging_function (gftp_logging_recv, request, "%s\n",
+                                   question_pos);
+    }
+  else if (*tempstr != '\0')
+    request->logging_function (gftp_logging_recv, request, "%s\n", tempstr);
 
   g_free (tempstr);
 
@@ -413,13 +429,11 @@
       if (ok == SSH_ERROR_BADPASS)
         request->logging_function (gftp_logging_error, request,
                                _("Error: An incorrect password was entered\n"));
-      else if (ok == SSH_ERROR_QUESTION)
-        request->logging_function (gftp_logging_error, request,
-                               _("Please connect to this host with the command line SSH utility and answer this question appropriately.\n"));
       else if (ok == SSH_WARNING)
         request->logging_function (gftp_logging_error, request,
                                    _("Please correct the above warning to connect to this host.\n"));
 
+      gftp_disconnect (request);
       return (GFTP_EFATAL);
     }