# HG changeset patch # User masneyb # Date 1081990763 0 # Node ID 075f89b4395c8560b62c66475d5788d83eceea23 # Parent b4abf70c642541e91febe63c4feacde3bc568f0c 2004-4-14 Brian Masney * 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 diff -r b4abf70c6425 -r 075f89b4395c ChangeLog --- a/ChangeLog Sat Apr 10 20:39:06 2004 +0000 +++ b/ChangeLog Thu Apr 15 00:59:23 2004 +0000 @@ -1,3 +1,25 @@ +2004-4-14 Brian Masney + * 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 + 2004-04-10 Adam Weinberger * en_CA.po: Added en_CA to ALL_LINGUAS. @@ -2423,7 +2445,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.258 2004/04/10 20:39:06 adamw Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.259 2004/04/15 00:59:22 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r b4abf70c6425 -r 075f89b4395c configure.in --- a/configure.in Sat Apr 10 20:39:06 2004 +0000 +++ b/configure.in Thu Apr 15 00:59:23 2004 +0000 @@ -53,7 +53,7 @@ AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(fcntl.h libutil.h limits.h malloc.h pty.h strings.h sys/ioctl.h sys/time.h unistd.h stdint.h sys/mkdev.h) +AC_CHECK_HEADERS(fcntl.h libutil.h limits.h malloc.h pty.h strings.h sys/ioctl.h sys/time.h unistd.h stdint.h sys/mkdev.h inttypes.h) AC_TYPE_SOCKLEN_T AC_TYPE_MODE_T diff -r b4abf70c6425 -r 075f89b4395c docs/gftp-faq.sgml --- a/docs/gftp-faq.sgml Sat Apr 10 20:39:06 2004 +0000 +++ b/docs/gftp-faq.sgml Thu Apr 15 00:59:23 2004 +0000 @@ -6,7 +6,7 @@ - $Date: 2004/03/17 13:44:41 $ + $Date: 2004/04/15 00:59:23 $ gFTP FAQ @@ -318,52 +318,6 @@ -SSH Protocol - - -I'm having problems getting SSH2 transfers to work. I keep getting the -error: <emphasis>Error: Message size XXXXXXXX too big from server</emphasis> - - -What probably is the problem, sftp-server isn't in your path on the -remote server. When you try to connect to the remote server, you'll see the -command gFTP is trying to run, and it'll look something like: - -ssh -e none -l username hostname "echo -n xsftp ; sftp-server" - -Try running this command. If you get a prompt asking: - - -The authenticity of host 'hostname (###.###.###.###)' can't be established. -RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. -Are you sure you want to continue connecting (yes/no)? - - -Tell it yes. gFTP won't even try to answer this question for you at the -moment. Then, if you get the following output: - - -Enter passphrase for key '/home/brian/.ssh/id_dsa': -xsftp -bash: sftp-server: command not found - - -You'll have to set the path to the sftp-server program. Alternatively -you could go under FTP->Options->SSH and enable Use sftp subsys. If you enable -this, then you don't have to know the remote path to your sftp executable. -But if you enable this, gFTP won't be able to send your password over to -the ssh client. So if you're not using ssh-agent, then ssh will spawn the -ssh-askpass program to grab your password. - - - - - - - - - - HTTP Protocol @@ -444,7 +398,44 @@ Issues for older releases -What is the difference between the SSH and SSH2 protocols? +I'm having problems getting SSH2 transfers to work. I keep getting the +error: <emphasis>Error: Message size XXXXXXXX too big from server (only relevant for versions <= 2.0.17)</emphasis> + + +What probably is the problem, sftp-server isn't in your path on the +remote server. When you try to connect to the remote server, you'll see the +command gFTP is trying to run, and it'll look something like: + +ssh -e none -l username hostname "echo -n xsftp ; sftp-server" + +Try running this command. If you get a prompt asking: + + +The authenticity of host 'hostname (###.###.###.###)' can't be established. +RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. +Are you sure you want to continue connecting (yes/no)? + + +Tell it yes. gFTP won't even try to answer this question for you at the +moment. Then, if you get the following output: + + +Enter passphrase for key '/home/brian/.ssh/id_dsa': +xsftp +bash: sftp-server: command not found + + +You'll have to set the path to the sftp-server program. Alternatively +you could go under FTP->Options->SSH and enable Use sftp subsys. If you enable +this, then you don't have to know the remote path to your sftp executable. +But if you enable this, gFTP won't be able to send your password over to +the ssh client. So if you're not using ssh-agent, then ssh will spawn the +ssh-askpass program to grab your password. + + + + +What is the difference between the SSH and SSH2 protocols? (only relevant for versions <= 2.0.15) The SSH protocol uses sftp >= 0.7 from http://www.xbill.org/sftp. diff -r b4abf70c6425 -r 075f89b4395c docs/gftp.lsm --- a/docs/gftp.lsm Sat Apr 10 20:39:06 2004 +0000 +++ b/docs/gftp.lsm Thu Apr 15 00:59:23 2004 +0000 @@ -1,15 +1,17 @@ Begin3 Title: gFTP -Version: 2.0.6 -Entered-date: 20NOV99 -Description: gFTP is a multithreaded FTP client for X Windows written - using Gtk. It features simultaneous downloads, resuming of - interrupted file transfers, file transfer queues, downloading - of entire directories, ftp and http proxy support, remote - directory caching, passive and non-passive file transfers, - drag-n-drop support, bookmarks menu, stop button, and many - more features. -Keywords: ftp x windows gtk +Version: 2.0.17 +Entered-date: 28MAR04 +Description: gFTP is a free multithreaded file transfer client for *NIX + based machines running X11R6 or later. It has text and GTK+ + 1.2/2.x interfaces and supports the FTP, FTPS (control + connection only), HTTP, HTTPS, and SSH protocols and has FTP + and HTTP proxy server support. It supports UNIX, EPLF, Novell, + MacOS, VMS, MVS, and NT (DOS) style directory listings, and + has a bookmarks menu that allows you to quickly connect to + remote sites. The code is fully internationalized and there + are currently 40 translations available. +Keywords: ftp x windows gtk gftp Author: masneyb@gftp.org (Brian Masney) Maintained-by: masneyb@gftp.org (Brian Masney) Primary-site: http://www.gftp.org/ diff -r b4abf70c6425 -r 075f89b4395c lib/cache.c --- a/lib/cache.c Sat Apr 10 20:39:06 2004 +0000 +++ b/lib/cache.c Thu Apr 15 00:59:23 2004 +0000 @@ -299,6 +299,7 @@ gftp_getline_buffer * rbuf; gftp_cache_entry centry; int indexfd, newfd; + size_t len; time_t now; int remove; @@ -366,9 +367,10 @@ /* Make sure when we call gftp_get_line() that we pass the read size as sizeof(buf) - 1 so that we'll have room to put the newline */ - buf[strlen (buf)] = '\n'; + len = strlen (buf); + buf[len--] = '\n'; - if (gftp_fd_write (NULL, buf, strlen (buf), newfd) < 0) + if (gftp_fd_write (NULL, buf, len, newfd) < 0) break; } } diff -r b4abf70c6425 -r 075f89b4395c lib/config_file.c --- a/lib/config_file.c Sat Apr 10 20:39:06 2004 +0000 +++ b/lib/config_file.c Thu Apr 15 00:59:23 2004 +0000 @@ -201,7 +201,7 @@ newentry = NULL; while (fgets (buf, sizeof (buf), bmfile)) { - len = strlen (buf); + len = strlen (buf); if (len > 0 && buf[len - 1] == '\n') buf[--len] = '\0'; if (len > 0 && buf[len - 1] == '\r') diff -r b4abf70c6425 -r 075f89b4395c lib/gftp.h --- a/lib/gftp.h Sat Apr 10 20:39:06 2004 +0000 +++ b/lib/gftp.h Thu Apr 15 00:59:23 2004 +0000 @@ -70,6 +70,10 @@ #include #endif +#ifdef HAVE_INTTYPES_H +#include +#endif + #ifdef HAVE_STRING_H #include #else @@ -1031,5 +1035,10 @@ int fd ); #endif /* USE_SSL */ +/* UI dependent functions that must be implemented */ +int gftpui_protocol_ask_yes_no ( gftp_request * request, + char *title, + char *question ); + #endif diff -r b4abf70c6425 -r 075f89b4395c lib/misc.c --- a/lib/misc.c Sat Apr 10 20:39:06 2004 +0000 +++ b/lib/misc.c Thu Apr 15 00:59:23 2004 +0000 @@ -53,7 +53,8 @@ insert_commas (off_t number, char *dest_str, size_t dest_len) { char *frompos, *topos, src[50], *dest; - int len, num, rem, i; + size_t num, rem, srclen; + int len, i; #if defined (_LARGEFILE_SOURCE) g_snprintf (src, sizeof (src), "%lld", (long long) number); @@ -93,8 +94,10 @@ else dest = dest_str; - num = strlen (src) / 3 - 1; - rem = strlen (src) % 3; + srclen = strlen (src); + num = srclen / 3 - 1; + rem = srclen % 3; + frompos = src; topos = dest; for (i = 0; i < rem; i++) @@ -1018,7 +1021,8 @@ char *newstr, *newpos, *fillpos, *pos; unsigned char table[64], encode[3]; - int i, num; + size_t slen, num; + int i; for (i = 0; i < 26; i++) { @@ -1032,9 +1036,11 @@ table[62] = '+'; table[63] = '/'; - num = strlen (str) / 3; - if (strlen (str) % 3 > 0) + slen = strlen (str); + num = slen / 3; + if (slen % 3 > 0) num++; + newstr = g_malloc (num * 4 + 1); newstr[num * 4] = '\0'; newpos = newstr; @@ -1266,7 +1272,7 @@ if (strcmp (password, "@EMAIL@") == 0) return (g_strdup (password)); - newstr = g_malloc (strlen(password) * 2 + 2); + newstr = g_malloc (strlen (password) * 2 + 2); newpos = newstr; *newpos++ = '$'; diff -r b4abf70c6425 -r 075f89b4395c lib/protocols.c --- a/lib/protocols.c Sat Apr 10 20:39:06 2004 +0000 +++ b/lib/protocols.c Thu Apr 15 00:59:23 2004 +0000 @@ -1009,6 +1009,7 @@ { gftp_config_list_vars * proxy_hosts; gftp_proxy_hosts * hostname; + size_t hostlen, domlen; unsigned char addy[4]; struct sockaddr *addr; GList * templist; @@ -1077,13 +1078,16 @@ while (templist != NULL) { hostname = templist->data; - if (hostname->domain && - strlen (request->hostname) > strlen (hostname->domain)) + if (hostname->domain != NULL) { - pos = request->hostname + strlen (request->hostname) - - strlen (hostname->domain); - if (strcmp (hostname->domain, pos) == 0) - return (0); + hostlen = strlen (request->hostname); + domlen = strlen (hostname->domain); + if (hostlen > domlen) + { + pos = request->hostname + hostlen - domlen; + if (strcmp (hostname->domain, pos) == 0) + return (0); + } } if (hostname->ipv4_network_address != 0) @@ -1151,11 +1155,14 @@ struct tm curtime, *loctime; time_t t, ret; char *tmppos; + size_t slen; int i, num; + slen = strlen (str); memset (&curtime, 0, sizeof (curtime)); curtime.tm_isdst = -1; - if (strlen (str) > 4 && isdigit ((int) str[0]) && str[2] == '-' && + + if (slen > 4 && isdigit ((int) str[0]) && str[2] == '-' && isdigit ((int) str[3])) { /* This is how DOS will return the date/time */ @@ -1163,13 +1170,13 @@ tmppos = strptime (str, "%m-%d-%y %I:%M%p", &curtime); } - else if (strlen (str) > 4 && isdigit ((int) str[0]) && str[2] == '-' && + else if (slen > 4 && isdigit ((int) str[0]) && str[2] == '-' && isalpha (str[3])) { /* 10-Jan-2003 09:14 */ tmppos = strptime (str, "%d-%h-%Y %H:%M", &curtime); } - else if (strlen (str) > 4 && isdigit ((int) str[0]) && str[4] == '/') + else if (slen > 4 && isdigit ((int) str[0]) && str[4] == '/') { /* 2003/12/25 */ tmppos = strptime (str, "%Y/%m/%d", &curtime); @@ -1404,13 +1411,14 @@ static int -gftp_parse_ls_unix (gftp_request * request, char *str, gftp_file * fle) +gftp_parse_ls_unix (gftp_request * request, char *str, size_t slen, + gftp_file * fle) { char *endpos, *startpos, *pos; int cols; /* If there is no space between the attribs and links field, just make one */ - if (strlen (str) > 10) + if (slen > 10) str[10] = ' '; /* Determine the number of columns */ @@ -1615,7 +1623,7 @@ { case GFTP_DIRTYPE_CRAY: case GFTP_DIRTYPE_UNIX: - result = gftp_parse_ls_unix (request, str, fle); + result = gftp_parse_ls_unix (request, str, len, fle); break; case GFTP_DIRTYPE_EPLF: result = gftp_parse_ls_eplf (str, fle); @@ -1656,7 +1664,7 @@ if (is_vms) result = gftp_parse_ls_vms (str, fle); else - result = gftp_parse_ls_unix (request, str, fle); + result = gftp_parse_ls_unix (request, str, len, fle); } break; } diff -r b4abf70c6425 -r 075f89b4395c lib/rfc2068.c --- a/lib/rfc2068.c Sat Apr 10 20:39:06 2004 +0000 +++ b/lib/rfc2068.c Thu Apr 15 00:59:23 2004 +0000 @@ -272,9 +272,10 @@ off_t startsize) { char *tempstr, *oldstr, *hf; - int restarted; + rfc2068_params * params; intptr_t use_http11; - rfc2068_params * params; + int restarted; + size_t len; off_t size; g_return_val_if_fail (request != NULL, GFTP_EFATAL); @@ -326,11 +327,10 @@ return (size); restarted = 0; - if (strlen (request->last_ftp_response) > 9 - && strncmp (request->last_ftp_response + 9, "206", 3) == 0) + len = strlen (request->last_ftp_response); + if (len > 9 && strncmp (request->last_ftp_response + 9, "206", 3) == 0) restarted = 1; - else if (strlen (request->last_ftp_response) < 9 || - strncmp (request->last_ftp_response + 9, "200", 3) != 0) + else if (len < 9 || strncmp (request->last_ftp_response + 9, "200", 3) != 0) { request->logging_function (gftp_logging_error, request, _("Cannot retrieve file %s\n"), filename); diff -r b4abf70c6425 -r 075f89b4395c lib/rfc959.c --- a/lib/rfc959.c Sat Apr 10 20:39:06 2004 +0000 +++ b/lib/rfc959.c Thu Apr 15 00:59:23 2004 +0000 @@ -1514,7 +1514,7 @@ if (!request->cached) { request->last_dir_entry = g_strdup_printf ("%s\n", tempstr); - request->last_dir_entry_len = strlen (tempstr) + 1; + request->last_dir_entry_len = len + 1; } return (len); } diff -r b4abf70c6425 -r 075f89b4395c lib/sshv2.c --- 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); } diff -r b4abf70c6425 -r 075f89b4395c lib/sslcommon.c --- a/lib/sslcommon.c Sat Apr 10 20:39:06 2004 +0000 +++ b/lib/sslcommon.c Thu Apr 15 00:59:23 2004 +0000 @@ -292,7 +292,7 @@ if (!SSL_library_init ()) { request->logging_function (gftp_logging_error, request, - _("Cannot initialized the OpenSSL library\n")); + _("Cannot initialize the OpenSSL library\n")); return (GFTP_EFATAL); } diff -r b4abf70c6425 -r 075f89b4395c src/gtk/gftp-gtk.c --- a/src/gtk/gftp-gtk.c Sat Apr 10 20:39:06 2004 +0000 +++ b/src/gtk/gftp-gtk.c Thu Apr 15 00:59:23 2004 +0000 @@ -1229,6 +1229,8 @@ gftpui_common_init (&argc, &argv, ftp_log); g_thread_init (NULL); + gdk_threads_init(); + main_thread_id = pthread_self (); gtk_set_locale (); gtk_init (&argc, &argv); diff -r b4abf70c6425 -r 075f89b4395c src/gtk/gtkui.c --- a/src/gtk/gtkui.c Sat Apr 10 20:39:06 2004 +0000 +++ b/src/gtk/gtkui.c Thu Apr 15 00:59:23 2004 +0000 @@ -453,3 +453,55 @@ return (pos); } + +static void +_protocol_yes_answer (gpointer answer, gftp_dialog_data * ddata) +{ + *(int *) answer = 1; +} + + +static void +_protocol_no_answer (gpointer answer, gftp_dialog_data * ddata) +{ + *(int *) answer = 0; +} + + +int +gftpui_protocol_ask_yes_no (gftp_request * request, char *title, + char *question) +{ + int answer = -1; + + GDK_THREADS_ENTER (); + + MakeYesNoDialog (title, question, _protocol_yes_answer, &answer, + _protocol_no_answer, &answer); + + if (gftp_protocols[request->protonum].use_threads) + { + /* Otherwise let the main loop in the main thread run the events */ + GDK_THREADS_LEAVE (); + + while (answer == -1) + { + sleep (1); + } + } + else + { + while (answer == -1) + { + GDK_THREADS_LEAVE (); +#if GTK_MAJOR_VERSION == 1 + g_main_iteration (TRUE); +#else + g_main_context_iteration (NULL, TRUE); +#endif + } + } + + return (answer); +} + diff -r b4abf70c6425 -r 075f89b4395c src/text/textui.c --- a/src/text/textui.c Sat Apr 10 20:39:06 2004 +0000 +++ b/src/text/textui.c Thu Apr 15 00:59:23 2004 +0000 @@ -243,3 +243,25 @@ gftp_disconnect (request); } + +int +gftpui_protocol_ask_yes_no (gftp_request * request, char *title, char *question) +{ + char buf[10]; + int ret; + + do + { + gftp_text_ask_question (question, 1, buf, sizeof (buf)); + if (strcasecmp (buf, "yes") == 0) + ret = 1; + else if (strcasecmp (buf, "no") == 0) + ret = 0; + else + ret = -1; + } + while (ret == -1); + + return (ret); +} +