changeset 169:d40f9db52cdf

2003-6-8 Brian Masney <masneyb@gftp.org> * lib/https.c lib/options.h lib/sslcommon.c - make sure USE_SSL is defined before using any SSL functions * lib/gftp.h lib/protocols.c lib/rfc2068.c lib/sshv2.c lib/sslcommon.c lib/rfc959.c - make sure we use request->datafd for the connection. Removed sockfd from gftp_request structure * lib/rfc959.c - add data_connection to rfc959_parms structure. Use this for the FTP data connection * src/text/gftp-text.c - fixes for username/password prompt * src/gtk/misc-gtk.c src/gtk/transfer.c - s/sockfd/datafd/g * configure.in - added lib/Makefile (forgot to commit last time) * Makefile.am - added intl to SUBDIRS
author masneyb
date Sun, 08 Jun 2003 15:49:02 +0000
parents c505d9ba9d53
children 14a41b1a3ac0
files Makefile.am configure.in lib/gftp.h lib/https.c lib/options.h lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c lib/sslcommon.c src/gtk/misc-gtk.c src/gtk/transfer.c src/text/gftp-text.c
diffstat 13 files changed, 201 insertions(+), 161 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.am	Sun Jun 08 15:04:40 2003 +0000
+++ b/Makefile.am	Sun Jun 08 15:49:02 2003 +0000
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS= docs lib po src
-EXTRA_DIST= ChangeLog-old README THANKS TODO \
+SUBDIRS= intl  docs intl lib po src
+EXTRA_DIST= config.rpath mkinstalldirs  ChangeLog-old README THANKS TODO \
 	gftp.spec.in debian/changelog debian/control debian/copyright \
 	debian/dirs debian/docs debian/menu debian/rules
 
--- a/configure.in	Sun Jun 08 15:04:40 2003 +0000
+++ b/configure.in	Sun Jun 08 15:49:02 2003 +0000
@@ -261,4 +261,4 @@
 
 AM_GNU_GETTEXT
 
-AC_OUTPUT(Makefile docs/Makefile docs/sample.gftp/Makefile src/gftp src/Makefile src/gtk/Makefile src/text/Makefile gftp.spec)
+AC_OUTPUT(Makefile docs/Makefile docs/sample.gftp/Makefile lib/Makefile src/gftp src/Makefile src/gtk/Makefile src/text/Makefile gftp.spec intl/Makefile po/Makefile.in )
--- a/lib/gftp.h	Sun Jun 08 15:04:40 2003 +0000
+++ b/lib/gftp.h	Sun Jun 08 15:49:02 2003 +0000
@@ -304,8 +304,7 @@
 
   unsigned int port;		/* Port of remote site */
 
-  int sockfd,			/* Control connection (read) */
-      datafd,			/* Data connection */
+  int datafd,			/* Data connection */
       cachefd;			/* For the directory cache */
   int wakeup_main_thread[2];	/* FD that gets written to by the threads
                                    to wakeup the parent */
@@ -665,7 +664,7 @@
 #define GFTP_BOOKMARK_NUM			5
 
 #define GFTP_IS_CONNECTED(request)		((request) != NULL && \
-                                                 ((request)->sockfd > 0 || \
+                                                 ((request)->datafd > 0 || \
                                                   (request)->cached || \
                                                   (request)->always_connected))
 
--- a/lib/https.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/lib/https.c	Sun Jun 08 15:49:02 2003 +0000
@@ -22,6 +22,7 @@
 
 static const char cvsid[] = "$Id$";
 
+#ifdef USE_SSL
 static int
 https_get_next_file (gftp_request * request, gftp_file * fle, int fd)
 {
@@ -48,18 +49,21 @@
 
   return (ret);
 }
-
+#endif
 
 void
 https_register_module (void)
 {
+#ifdef USE_SSL
   gftp_ssl_startup (NULL); /* FIXME - take out of here */
+#endif
 }
 
 
 void
 https_init (gftp_request * request)
 {
+#ifdef USE_SSL
   rfc2068_params * params;
 
   g_return_if_fail (request != NULL);
@@ -72,5 +76,11 @@
   request->write_function = gftp_ssl_write;
   request->get_next_file = https_get_next_file;
   request->url_prefix = g_strdup ("https");
+#else
+  gftp_protocols[GFTP_HTTP_NUM].init (request);
+
+  request->logging_function (gftp_logging_error, request->user_data,
+                             _("HTTPS Support unavailable since SSL support was not compiled in. Reverting back to plaintext\n"));
+#endif
 }
 
--- a/lib/options.h	Sun Jun 08 15:04:40 2003 +0000
+++ b/lib/options.h	Sun Jun 08 15:49:02 2003 +0000
@@ -179,7 +179,11 @@
 {
   {N_("FTP"), rfc959_init, rfc959_register_module, "ftp", 1},
   {N_("HTTP"), rfc2068_init, rfc2068_register_module, "http", 1},
+#ifdef USE_SSL
   {N_("HTTPS"), https_init, https_register_module, "https", 1},
+#else
+  {N_("HTTPS"), https_init, https_register_module, "https", 0},
+#endif
   {N_("Local"), local_init, local_register_module, "file", 1},
   {N_("SSH2"), sshv2_init, sshv2_register_module, "ssh2", 1},
   {N_("Bookmark"), bookmark_init, bookmark_register_module, "bookmark", 0},
--- a/lib/protocols.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/lib/protocols.c	Sun Jun 08 15:49:02 2003 +0000
@@ -26,7 +26,6 @@
   gftp_request *request;
 
   request = g_malloc0 (sizeof (*request));
-  request->sockfd = -1;
   request->datafd = -1;
   request->cachefd = -1;
   request->server_type = GFTP_DIRTYPE_OTHER;
@@ -71,7 +70,6 @@
     g_free (request);
   else
     {
-      request->sockfd = -1;
       request->datafd = -1;
       request->cachefd = -1;
     }
@@ -611,7 +609,11 @@
 
   if (request->username)
     g_free (request->username);
-  request->username = g_strdup (username);
+
+  if (username != NULL)
+    request->username = g_strdup (username);
+  else
+    request->username = NULL;
 }
 
 
@@ -623,7 +625,11 @@
 
   if (request->password)
     g_free (request->password);
-  request->password = g_strdup (password);
+
+  if (password != NULL)
+    request->password = g_strdup (password);
+  else
+    request->password = NULL;
 }
 
 
@@ -646,7 +652,7 @@
   g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
 
 
-  if (request->sockfd <= 0 && !request->always_connected)
+  if (request->datafd <= 0 && !request->always_connected)
     {
       if (directory != request->directory)
         {
@@ -1773,7 +1779,7 @@
       return (GFTP_ERETRYABLE);
     }
 
-  request->sockfd = sock;
+  request->datafd = sock;
 
   if (request->post_connect != NULL)
     return (request->post_connect (request));
@@ -2141,12 +2147,10 @@
   g_return_if_fail (source != NULL);
   g_return_if_fail (dest->protonum == source->protonum);
 
-  dest->sockfd = source->sockfd;
   dest->datafd = source->datafd;
   dest->cached = 0;
   if (!source->always_connected)
     {
-      source->sockfd = -1;
       source->datafd = -1;
       source->cached = 1;
     }
--- a/lib/rfc2068.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/lib/rfc2068.c	Sun Jun 08 15:49:02 2003 +0000
@@ -69,7 +69,7 @@
   do
     {
       if ((ret = gftp_get_line (request, &params->rbuf, tempstr, 
-                                sizeof (tempstr), request->sockfd)) < 0)
+                                sizeof (tempstr), request->datafd)) < 0)
         return (ret);
 
       if (request->last_ftp_response == NULL)
@@ -91,7 +91,7 @@
   if (chunked)
     {
       if ((ret = gftp_get_line (request, &params->rbuf, tempstr, 
-                                sizeof (tempstr), request->sockfd)) < 0)
+                                sizeof (tempstr), request->datafd)) < 0)
         return (ret);
 
       if (sscanf ((char *) tempstr, "%lx", &params->chunk_size) != 1)
@@ -139,7 +139,7 @@
                              "%s", tempstr);
 
   ret = request->write_function (request, tempstr, strlen (tempstr), 
-                                 request->sockfd);
+                                 request->datafd);
   g_free (tempstr);
 
   if (ret < 0)
@@ -158,7 +158,7 @@
 
       request->logging_function (gftp_logging_send, request->user_data,
                                  "Proxy-authorization: Basic xxxx:xxxx\n");
-      ret = gftp_writefmt (request, request->sockfd, 
+      ret = gftp_writefmt (request, request->datafd, 
                            "Proxy-authorization: Basic %s\n", str);
       g_free (str);
       if (ret < 0)
@@ -173,14 +173,14 @@
 
       request->logging_function (gftp_logging_send, request->user_data,
                                  "Authorization: Basic xxxx\n");
-      ret = gftp_writefmt (request, request->sockfd, 
+      ret = gftp_writefmt (request, request->datafd, 
                            "Authorization: Basic %s\n", str);
       g_free (str);
       if (ret < 0)
         return (ret);
     }
 
-  if ((ret = request->write_function (request, "\n", 1, request->sockfd)) < 0)
+  if ((ret = request->write_function (request, "\n", 1, request->datafd)) < 0)
     return (ret);
 
   return (rfc2068_read_response (request));
@@ -200,7 +200,7 @@
 
   params = request->protocol_data;
 
-  if (request->sockfd > 0)
+  if (request->datafd > 0)
     return (0);
 
   gftp_lookup_request_option (request, "proxy_config", &proxy_config);
@@ -236,18 +236,18 @@
   g_return_if_fail (request != NULL);
   g_return_if_fail (request->protonum == GFTP_HTTP_NUM);
 
-  if (request->sockfd > 0)
+  if (request->datafd > 0)
     {
       request->logging_function (gftp_logging_misc, request->user_data,
 				 _("Disconnecting from site %s\n"),
 				 request->hostname);
 
-      if (close (request->sockfd) < 0)
+      if (close (request->datafd) < 0)
         request->logging_function (gftp_logging_error, request->user_data,
                                    _("Error closing file descriptor: %s\n"),
                                    g_strerror (errno));
 
-      request->sockfd = -1;
+      request->datafd = -1;
     }
 }
 
@@ -270,9 +270,9 @@
   gftp_lookup_request_option (request, "use_http11", &use_http11);
 
   if (fd > 0)
-    request->sockfd = fd;
+    request->datafd = fd;
 
-  if (request->sockfd < 0 && (ret = rfc2068_connect (request)) != 0)
+  if (request->datafd < 0 && (ret = rfc2068_connect (request)) != 0)
     return (ret);
 
   if (request->username == NULL || *request->username == '\0')
@@ -344,7 +344,7 @@
 
   params = request->protocol_data;
 
-  if ((len = request->read_function (request, buf, size, request->sockfd)) < 0)
+  if ((len = request->read_function (request, buf, size, request->datafd)) < 0)
     return ((ssize_t) len);
 
   return (len);
@@ -359,14 +359,14 @@
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_HTTP_NUM, GFTP_EFATAL);
 
-  if (request->sockfd < 0)
+  if (request->datafd < 0)
     return (GFTP_EFATAL);
 
-  if (close (request->sockfd) < 0)
+  if (close (request->datafd) < 0)
     request->logging_function (gftp_logging_error, request->user_data,
                                _("Error closing file descriptor: %s\n"),
                                g_strerror (errno));
-  request->sockfd = -1;
+  request->datafd = -1;
 
   params = request->protocol_data;
   params->content_length = 0;
@@ -393,7 +393,7 @@
   params = request->protocol_data;
   gftp_lookup_request_option (request, "use_http11", &use_http11);
 
-  if (request->sockfd < 0 && (r = rfc2068_connect (request)) < 0)
+  if (request->datafd < 0 && (r = rfc2068_connect (request)) < 0)
     return (r);
 
   if (request->username == NULL || *request->username == '\0')
@@ -444,7 +444,7 @@
   params = request->protocol_data;
   gftp_lookup_request_option (request, "use_http11", &use_http11);
 
-  if (request->sockfd < 0 && (ret = rfc2068_connect (request)) != 0)
+  if (request->datafd < 0 && (ret = rfc2068_connect (request)) != 0)
     return (ret);
 
   if (request->username == NULL || *request->username == '\0')
@@ -611,7 +611,7 @@
     }
 
   if (fd < 0)
-    fd = request->sockfd;
+    fd = request->datafd;
 
   while (1)
     {
--- a/lib/rfc959.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/lib/rfc959.c	Sun Jun 08 15:49:02 2003 +0000
@@ -83,9 +83,10 @@
          
 typedef struct rfc959_params_tag
 {
-  gftp_getline_buffer * sockfd_rbuf,
-                      * datafd_rbuf;
+  gftp_getline_buffer * datafd_rbuf,
+                      * dataconn_rbuf;
   int is_ascii_transfer;
+  int data_connection;
 } rfc959_parms;
 
 
@@ -98,7 +99,7 @@
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   *code = '\0';
   if (request->last_ftp_response)
@@ -111,8 +112,8 @@
 
   do
     {
-      if ((num_read = gftp_get_line (request, &parms->sockfd_rbuf, tempstr, 
-                                     sizeof (tempstr), request->sockfd)) <= 0)
+      if ((num_read = gftp_get_line (request, &parms->datafd_rbuf, tempstr, 
+                                     sizeof (tempstr), request->datafd)) <= 0)
 	break;
 
       if (isdigit ((int) *tempstr) && isdigit ((int) *(tempstr + 1))
@@ -147,7 +148,7 @@
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (command != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   if (strncmp (command, "PASS", 4) == 0)
     {
@@ -166,7 +167,7 @@
     }
 
   if ((ret = gftp_fd_write (request, command, strlen (command), 
-                         request->sockfd)) < 0)
+                         request->datafd)) < 0)
     return (ret);
 
   return (rfc959_read_response (request));
@@ -376,7 +377,7 @@
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   ret = rfc959_send_command (request, "SYST\r\n");
 
@@ -418,7 +419,7 @@
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (request->hostname != NULL, GFTP_EFATAL);
 
-  if (request->sockfd > 0)
+  if (request->datafd > 0)
     return (0);
 
   parms = request->protocol_data;
@@ -436,7 +437,7 @@
     gftp_set_password (request, email);
    
   if (gftp_connect_server (request, "ftp", proxy_hostname, proxy_port) < 0)
-    return (request->sockfd);
+    return (request->datafd);
 
   /* Get the banner */
   if ((ret = rfc959_read_response (request)) != '2')
@@ -500,7 +501,7 @@
       return (GFTP_EFATAL);
     }
 
-  if ((ret = rfc959_syst (request)) < 0 && request->sockfd < 0)
+  if ((ret = rfc959_syst (request)) < 0 && request->datafd < 0)
     return (ret);
 
   gftp_lookup_request_option (request, "ascii_transfers", &ascii_transfers);
@@ -522,7 +523,7 @@
   if (request->directory != NULL && *request->directory != '\0')
     {
       ret = rfc959_chdir (request, request->directory);
-      if (request->sockfd < 0)
+      if (request->datafd < 0)
         return (ret);
     }
 
@@ -532,7 +533,7 @@
         return (ret);
     }
 
-  if (request->sockfd < 0)
+  if (request->datafd < 0)
     return (GFTP_EFATAL);
 
   return (0);
@@ -542,21 +543,26 @@
 static void
 rfc959_disconnect (gftp_request * request)
 {
+  rfc959_parms * parms;
+
   g_return_if_fail (request != NULL);
   g_return_if_fail (request->protonum == GFTP_FTP_NUM);
 
-  if (request->sockfd > 0)
+  parms = request->protocol_data;
+
+  if (request->datafd > 0)
     {
       request->logging_function (gftp_logging_misc, request->user_data,
 				 _("Disconnecting from site %s\n"),
 				 request->hostname);
-      close (request->sockfd);
-      request->sockfd = -1;
-      if (request->datafd > 0)
-	{
-	  close (request->datafd);
-	  request->datafd = -1;
-	}
+      close (request->datafd);
+      request->datafd = -1;
+    }
+
+  if (parms->data_connection > 0)
+    {
+      close (parms->data_connection);
+      parms->data_connection = -1;
     }
 }
 
@@ -567,11 +573,14 @@
   char *pos, *pos1, resp, *command;
   struct sockaddr_in data_addr;
   int i, passive_transfer;
+  rfc959_parms * parms;
   size_t data_addr_len;
   unsigned int temp[6];
   unsigned char ad[6];
 
-  if ((request->datafd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
+  parms = request->protocol_data;
+
+  if ((parms->data_connection = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
     {
       request->logging_function (gftp_logging_error, request->user_data,
 				 _("Failed to create a socket: %s\n"),
@@ -589,7 +598,7 @@
     {
       if ((resp = rfc959_send_command (request, "PASV\r\n")) != '2')
 	{
-          if (request->sockfd < 0)
+          if (request->datafd < 0)
             return (resp);
 
           gftp_set_request_option (request, "passive_transfer", GINT_TO_POINTER(0));
@@ -624,7 +633,7 @@
 
       memcpy (&data_addr.sin_addr, &ad[0], 4);
       memcpy (&data_addr.sin_port, &ad[4], 2);
-      if (connect (request->datafd, (struct sockaddr *) &data_addr, 
+      if (connect (parms->data_connection, (struct sockaddr *) &data_addr, 
                    data_addr_len) == -1)
         {
           request->logging_function (gftp_logging_error, request->user_data,
@@ -636,7 +645,7 @@
     }
   else
     {
-      if (getsockname (request->sockfd, (struct sockaddr *) &data_addr,
+      if (getsockname (request->datafd, (struct sockaddr *) &data_addr,
                        &data_addr_len) == -1)
         {
 	  request->logging_function (gftp_logging_error, request->user_data,
@@ -647,7 +656,7 @@
         }
 
       data_addr.sin_port = 0;
-      if (bind (request->datafd, (struct sockaddr *) &data_addr, 
+      if (bind (parms->data_connection, (struct sockaddr *) &data_addr, 
                 data_addr_len) == -1)
 	{
 	  request->logging_function (gftp_logging_error, request->user_data,
@@ -657,7 +666,7 @@
 	  return (GFTP_ERETRYABLE);
 	}
 
-      if (getsockname (request->datafd, (struct sockaddr *) &data_addr, 
+      if (getsockname (parms->data_connection, (struct sockaddr *) &data_addr, 
                        &data_addr_len) == -1)
         {
 	  request->logging_function (gftp_logging_error, request->user_data,
@@ -667,7 +676,7 @@
 	  return (GFTP_ERETRYABLE);
         }
 
-      if (listen (request->datafd, 1) == -1)
+      if (listen (parms->data_connection, 1) == -1)
 	{
 	  request->logging_function (gftp_logging_error, request->user_data,
 				     _("Cannot listen on port %d: %s\n"),
@@ -705,9 +714,11 @@
   struct sockaddr_in6 data_addr;
   int passive_transfer;
   size_t data_addr_len;
+  rfc959_parms * parms;
   unsigned int port;
 
-  if ((request->datafd = socket (AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0)
+  parms = request->protocol_data;
+  if ((parms->data_connection = socket (AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0)
     {
       request->logging_function (gftp_logging_error, request->user_data,
 				 _("Failed to create a socket: %s\n"),
@@ -734,7 +745,7 @@
     {
       if ((resp = rfc959_send_command (request, "EPSV\r\n")) != '2')
 	{
-          if (request->sockfd < 0)
+          if (request->datafd < 0)
             return (resp);
 
           gftp_set_request_option (request, "passive_transfer", 
@@ -768,7 +779,7 @@
       memcpy (&data_addr, request->hostp->ai_addr, data_addr_len);
       data_addr.sin6_port = htons (port);
 
-      if (connect (request->datafd, (struct sockaddr *) &data_addr, 
+      if (connect (parms->data_connection, (struct sockaddr *) &data_addr, 
                    data_addr_len) == -1)
         {
           request->logging_function (gftp_logging_error, request->user_data,
@@ -783,7 +794,7 @@
       memcpy (&data_addr, request->hostp->ai_addr, data_addr_len);
       data_addr.sin6_port = 0;
 
-      if (bind (request->datafd, (struct sockaddr *) &data_addr, 
+      if (bind (parms->data_connection, (struct sockaddr *) &data_addr, 
                 data_addr_len) == -1)
 	{
 	  request->logging_function (gftp_logging_error, request->user_data,
@@ -793,7 +804,7 @@
 	  return (GFTP_ERETRYABLE);
 	}
 
-      if (getsockname (request->datafd, (struct sockaddr *) &data_addr, 
+      if (getsockname (parms->data_connection, (struct sockaddr *) &data_addr, 
                        &data_addr_len) == -1)
         {
           request->logging_function (gftp_logging_error, request->user_data,
@@ -803,7 +814,7 @@
 	  return (GFTP_ERETRYABLE);
         }
 
-      if (listen (request->datafd, 1) == -1)
+      if (listen (parms->data_connection, 1) == -1)
 	{
 	  request->logging_function (gftp_logging_error, request->user_data,
 				     _("Cannot listen on port %d: %s\n"),
@@ -845,7 +856,7 @@
 {
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
 #ifdef HAVE_IPV6
   if (GFTP_GET_AI_FAMILY(request) == AF_INET6)
@@ -862,6 +873,7 @@
 rfc959_accept_active_connection (gftp_request * request)
 {
   int infd, ret, passive_transfer;
+  rfc959_parms * parms;
 #ifdef HAVE_IPV6
   struct sockaddr_in cli_addr;
 #else
@@ -869,19 +881,21 @@
 #endif
   size_t cli_addr_len;
 
+  parms = request->protocol_data;
+
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (parms->data_connection > 0, GFTP_EFATAL);
 
   gftp_lookup_request_option (request, "passive_transfer", &passive_transfer);
   g_return_val_if_fail (!passive_transfer, GFTP_EFATAL);
 
   cli_addr_len = sizeof (cli_addr);
 
-  if ((ret = gftp_fd_set_sockblocking (request, request->datafd, 0)) < 0)
+  if ((ret = gftp_fd_set_sockblocking (request, parms->data_connection, 0)) < 0)
     return (ret);
 
-  if ((infd = accept (request->datafd, (struct sockaddr *) &cli_addr,
+  if ((infd = accept (parms->data_connection, (struct sockaddr *) &cli_addr,
        &cli_addr_len)) == -1)
     {
       request->logging_function (gftp_logging_error, request->user_data,
@@ -891,10 +905,10 @@
       return (GFTP_ERETRYABLE);
     }
 
-  close (request->datafd);
+  close (parms->data_connection);
 
-  request->datafd = infd;
-  if ((ret = gftp_fd_set_sockblocking (request, request->datafd, 1)) < 0)
+  parms->data_connection = infd;
+  if ((ret = gftp_fd_set_sockblocking (request, parms->data_connection, 1)) < 0)
     return (ret);
 
   return (0);
@@ -943,7 +957,7 @@
   parms = request->protocol_data;
   new_ascii = rfc959_is_ascii_transfer (filename);
 
-  if (request->sockfd > 0 && new_ascii != parms->is_ascii_transfer)
+  if (request->datafd > 0 && new_ascii != parms->is_ascii_transfer)
     {
       if (new_ascii)
         {
@@ -969,22 +983,24 @@
 {
   char *command, *tempstr, resp;
   int ret, passive_transfer;
+  rfc959_parms * parms;
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
+  parms = request->protocol_data;
   if (fd > 0)
-    request->datafd = fd;
+    parms->data_connection = fd;
 
   rfc959_set_data_type (request, filename);
 
-  if (request->datafd < 0 && 
+  if (parms->data_connection < 0 && 
       (ret = rfc959_data_connection_new (request)) < 0)
     return (ret);
 
-  if ((ret = gftp_fd_set_sockblocking (request, request->datafd, 1)) < 0)
+  if ((ret = gftp_fd_set_sockblocking (request, parms->data_connection, 1)) < 0)
     return (ret);
 
   if (startsize > 0)
@@ -999,8 +1015,8 @@
 
       if (resp != '3')
         {
-          close (request->datafd);
-          request->datafd = -1;
+          close (parms->data_connection);
+          parms->data_connection = -1;
 	  return (GFTP_ERETRYABLE);
         }
     }
@@ -1011,8 +1027,8 @@
 
   if (ret != '1')
     {
-      close (request->datafd);
-      request->datafd = -1;
+      close (parms->data_connection);
+      parms->data_connection = -1;
       return (GFTP_ERETRYABLE);
     }
 
@@ -1040,22 +1056,24 @@
 {
   char *command, *tempstr, resp;
   int ret, passive_transfer;
+  rfc959_parms * parms;
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
+  parms = request->protocol_data;
   if (fd > 0)
-    fd = request->datafd;
+    fd = parms->data_connection;
 
   rfc959_set_data_type (request, filename);
 
-  if (request->datafd < 0 && 
+  if (parms->data_connection < 0 && 
       (ret = rfc959_data_connection_new (request)) < 0)
     return (ret);
 
-  if ((ret = gftp_fd_set_sockblocking (request, request->datafd, 1)) < 0)
+  if ((ret = gftp_fd_set_sockblocking (request, parms->data_connection, 1)) < 0)
     return (ret);
 
   if (startsize > 0)
@@ -1069,8 +1087,8 @@
       g_free (command);
       if (resp != '3')
         {
-          close (request->datafd);
-          request->datafd = -1;
+          close (parms->data_connection);
+          parms->data_connection = -1;
 	  return (GFTP_ERETRYABLE);
         }
     }
@@ -1080,8 +1098,8 @@
   g_free (tempstr);
   if (ret != '1')
     {
-      close (request->datafd);
-      request->datafd = -1;
+      close (parms->data_connection);
+      parms->data_connection = -1;
       return (GFTP_ERETRYABLE);
     }
 
@@ -1106,8 +1124,8 @@
   g_return_val_if_fail (fromfile != NULL, GFTP_EFATAL);
   g_return_val_if_fail (toreq != NULL, GFTP_EFATAL);
   g_return_val_if_fail (tofile != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (fromreq->sockfd > 0, GFTP_EFATAL);
-  g_return_val_if_fail (toreq->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (fromreq->datafd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (toreq->datafd > 0, GFTP_EFATAL);
 
   gftp_set_request_option (fromreq, "passive_transfer", GINT_TO_POINTER(1));
   gftp_set_request_option (toreq, "passive_transfer", GINT_TO_POINTER(0));
@@ -1137,7 +1155,7 @@
 
   tempstr = g_strconcat ("RETR ", fromfile, "\r\n", NULL);
   if ((ret = gftp_fd_write (fromreq, tempstr, strlen (tempstr), 
-                         fromreq->sockfd)) < 0)
+                         fromreq->datafd)) < 0)
     {
       g_free (tempstr);
       return (ret);
@@ -1146,7 +1164,7 @@
 
   tempstr = g_strconcat ("STOR ", tofile, "\r\n", NULL);
   if ((ret = gftp_fd_write (toreq, tempstr, strlen (tempstr), 
-                            toreq->sockfd)) < 0)
+                            toreq->datafd)) < 0)
     {
       g_free (tempstr);
       return (ret);
@@ -1166,16 +1184,18 @@
 static int
 rfc959_end_transfer (gftp_request * request)
 {
+  rfc959_parms * parms;
   int ret;
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
-  if (request->datafd > 0)
+  parms = request->protocol_data;
+  if (parms->data_connection > 0)
     {
-      close (request->datafd);
-      request->datafd = -1;
+      close (parms->data_connection);
+      parms->data_connection = -1;
     }
 
   ret = rfc959_read_response (request);
@@ -1192,16 +1212,18 @@
 static int
 rfc959_abort_transfer (gftp_request * request)
 {
+  rfc959_parms * parms;
   int ret;
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
-  if (request->datafd > 0)
+  parms = request->protocol_data;
+  if (parms->data_connection > 0)
     {
-      close (request->datafd);
-      request->datafd = -1;
+      close (parms->data_connection);
+      parms->data_connection = -1;
     }
 
   /* We need to read two lines of output. The first one is acknowleging
@@ -1209,7 +1231,7 @@
   if ((ret = rfc959_send_command (request, "ABOR\r\n")) < 0)
     return (ret);
 
-  if (request->sockfd > 0)
+  if (request->datafd > 0)
     {
       if ((ret = rfc959_read_response (request)) < 0)
         gftp_disconnect (request);
@@ -1227,7 +1249,7 @@
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   if ((ret = rfc959_data_connection_new (request)) < 0)
     return (ret);
@@ -1260,9 +1282,11 @@
 rfc959_get_next_file_chunk (gftp_request * request, char *buf, size_t size)
 {
   int i, j, ascii_transfers;
+  rfc959_parms * parms;
   ssize_t num_read;
 
-  num_read = gftp_fd_read (request, buf, size, request->datafd);
+  parms = request->protocol_data;
+  num_read = gftp_fd_read (request, buf, size, parms->data_connection);
   if (num_read < 0)
     return (num_read);
 
@@ -1286,6 +1310,7 @@
 rfc959_put_next_file_chunk (gftp_request * request, char *buf, size_t size)
 {
   int i, j, ascii_transfers;
+  rfc959_parms * parms;
   ssize_t num_wrote;
   char *tempstr;
   size_t rsize;
@@ -1293,6 +1318,8 @@
   if (size == 0)
     return (0);
 
+  parms = request->protocol_data;
+
   gftp_lookup_request_option (request, "ascii_transfers", &ascii_transfers);
   if (ascii_transfers)
     {
@@ -1324,7 +1351,7 @@
       tempstr = buf;
     }
 
-  num_wrote = gftp_fd_write (request, tempstr, rsize, request->datafd);
+  num_wrote = gftp_fd_write (request, tempstr, rsize, parms->data_connection);
 
   if (tempstr != buf)
     g_free (tempstr);
@@ -1353,9 +1380,12 @@
 
   parms = request->protocol_data;
 
+  if (fd == request->datafd)
+    fd = parms->data_connection;
+
   do
     {
-      if ((len = gftp_get_line (request, &parms->datafd_rbuf,
+      if ((len = gftp_get_line (request, &parms->dataconn_rbuf,
                                 tempstr, sizeof (tempstr), fd)) <= 0)
 	{
           gftp_file_destroy (fle);
@@ -1396,7 +1426,7 @@
   g_return_val_if_fail (request != NULL, 0);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (filename != NULL, 0);
-  g_return_val_if_fail (request->sockfd > 0, 0);
+  g_return_val_if_fail (request->datafd > 0, 0);
 
   tempstr = g_strconcat ("SIZE ", filename, "\r\n", NULL);
   ret = rfc959_send_command (request, tempstr);
@@ -1418,7 +1448,7 @@
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   tempstr = g_strconcat ("RMD ", directory, "\r\n", NULL);
   ret = rfc959_send_command (request, tempstr);
@@ -1441,7 +1471,7 @@
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (file != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   tempstr = g_strconcat ("DELE ", file, "\r\n", NULL);
   ret = rfc959_send_command (request, tempstr);
@@ -1464,7 +1494,7 @@
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   tempstr = g_strconcat ("MKD ", directory, "\r\n", NULL);
   ret = rfc959_send_command (request, tempstr);
@@ -1489,7 +1519,7 @@
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (oldname != NULL, GFTP_EFATAL);
   g_return_val_if_fail (newname != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   tempstr = g_strconcat ("RNFR ", oldname, "\r\n", NULL);
   ret = rfc959_send_command (request, tempstr);
@@ -1521,7 +1551,7 @@
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (file != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   tempstr = g_malloc (strlen (file) + (mode / 10) + 16);
   sprintf (tempstr, "SITE CHMOD %d %s\r\n", mode, file);
@@ -1545,7 +1575,7 @@
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, GFTP_EFATAL);
   g_return_val_if_fail (command != NULL, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   tempstr = g_strconcat ("SITE ", command, "\r\n", NULL);
   ret = rfc959_send_command (request, tempstr);
@@ -1604,6 +1634,8 @@
 void
 rfc959_init (gftp_request * request)
 {
+  rfc959_parms * parms;
+
   g_return_if_fail (request != NULL);
 
   request->protonum = GFTP_FTP_NUM;
@@ -1641,7 +1673,11 @@
   request->use_cache = 1;
   request->use_threads = 1;
   request->always_connected = 0;
+
   request->protocol_data = g_malloc0 (sizeof (rfc959_parms));
+  parms = request->protocol_data;
+  parms->data_connection = -1; 
+
   gftp_set_config_options (request);
 }
 
--- a/lib/sshv2.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/lib/sshv2.c	Sun Jun 08 15:49:02 2003 +0000
@@ -585,7 +585,7 @@
 
   sshv2_log_command (request, gftp_logging_send, type, buf + 5, len);
 
-  if ((ret = gftp_fd_write (request, buf, len + 5, request->sockfd)) < 0)
+  if ((ret = gftp_fd_write (request, buf, len + 5, request->datafd)) < 0)
     return (ret);
 
   return (0);
@@ -600,7 +600,7 @@
   char buf[5], *pos;
 
   if (fd <= 0)
-    fd = request->sockfd;
+    fd = request->datafd;
 
   pos = buf;
   rem = 5;
@@ -823,7 +823,7 @@
   g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
   g_return_val_if_fail (request->hostname != NULL, GFTP_EFATAL);
   
-  if (request->sockfd > 0)
+  if (request->datafd > 0)
     return (0);
 
   request->logging_function (gftp_logging_misc, request->user_data,
@@ -917,7 +917,7 @@
       sshv2_free_args (args);
       g_free (exepath);
 
-      request->sockfd = s[0];
+      request->datafd = s[0];
 
       version = htonl (SSH_MY_VERSION);
       if ((ret = sshv2_send_command (request, SSH_FXP_INIT, (char *) 
@@ -979,18 +979,18 @@
 
   params = request->protocol_data;
 
-  if (request->sockfd > 0)
+  if (request->datafd > 0)
     {
       request->logging_function (gftp_logging_misc, request->user_data,
 			         _("Disconnecting from site %s\n"),
                                  request->hostname);
 
-      if (close (request->sockfd) < 0)
+      if (close (request->datafd) < 0)
         request->logging_function (gftp_logging_error, request->user_data,
                                    _("Error closing file descriptor: %s\n"),
                                    g_strerror (errno));
 
-      request->sockfd = -1;
+      request->datafd = -1;
     }
 
   if (params->message.buffer != NULL)
@@ -1062,7 +1062,7 @@
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   params = request->protocol_data;
 
@@ -1882,7 +1882,7 @@
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
   /* fd ignored for this protocol */
 
   params = request->protocol_data;
@@ -1972,7 +1972,7 @@
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
   /* fd ignored for this protocol */
 
   params = request->protocol_data;
@@ -2068,7 +2068,7 @@
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
   g_return_val_if_fail (buf != NULL, GFTP_EFATAL);
 
   params = request->protocol_data;
@@ -2155,7 +2155,7 @@
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
   g_return_val_if_fail (buf != NULL, GFTP_EFATAL);
   g_return_val_if_fail (size <= 32500, GFTP_EFATAL);
 
--- a/lib/sslcommon.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/lib/sslcommon.c	Sun Jun 08 15:49:02 2003 +0000
@@ -24,9 +24,9 @@
 /* Some of the functions in here was taken either entirely or partially from
  * the O'Reilly book Network Security with OpenSSL */
 
+#ifdef USE_SSL
+
 static SSL_CTX * ctx = NULL;
- 
-#ifdef USE_SSL
 
 static volatile int gftp_ssl_initialized = 0;
 
@@ -184,7 +184,7 @@
   BIO * bio;
   long ret;
 
-  g_return_val_if_fail (request->sockfd > 0, GFTP_EFATAL);
+  g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
   if (!gftp_ssl_initialized)
     {
@@ -193,7 +193,7 @@
       return (GFTP_EFATAL);
     }
 
-  if (gftp_fd_set_sockblocking (request, request->sockfd, 0) < 0) /* FIXME */
+  if (gftp_fd_set_sockblocking (request, request->datafd, 0) < 0) /* FIXME */
     {
       gftp_disconnect (request);
       return (GFTP_ERETRYABLE);
@@ -206,7 +206,7 @@
       return (GFTP_EFATAL);
     }
 
-  BIO_set_fd (bio, request->sockfd, BIO_NOCLOSE);
+  BIO_set_fd (bio, request->datafd, BIO_NOCLOSE);
 
   if ((request->ssl = SSL_new (ctx)) == NULL)
     {
--- a/src/gtk/misc-gtk.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/src/gtk/misc-gtk.c	Sun Jun 08 15:49:02 2003 +0000
@@ -687,7 +687,7 @@
 int
 check_reconnect (gftp_window_data *wdata)
 {
-  return (wdata->request->cached && wdata->request->sockfd < 0 && 
+  return (wdata->request->cached && wdata->request->datafd < 0 && 
           !wdata->request->always_connected &&
 	  !ftp_connect (wdata, wdata->request, 0) ? -1 : 0);
 }
--- a/src/gtk/transfer.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/src/gtk/transfer.c	Sun Jun 08 15:49:02 2003 +0000
@@ -1206,8 +1206,8 @@
     {
       fromreq = tdata->fromwdata != NULL ? ((gftp_window_data *) tdata->fromwdata)->request : NULL;
       if (!tdata->fromreq->stopable && tdata->fromwdata &&
-          ((fromreq->sockfd < 0 && fromreq->cached) || fromreq->always_connected) &&
-          (tdata->fromreq->sockfd > 0 || tdata->fromreq->always_connected) &&
+          ((fromreq->datafd < 0 && fromreq->cached) || fromreq->always_connected) &&
+          (tdata->fromreq->datafd > 0 || tdata->fromreq->always_connected) &&
           compare_request (tdata->fromreq, fromreq, 0))
 	{
           gftp_swap_socks (((gftp_window_data *) tdata->towdata)->request, 
@@ -1263,7 +1263,7 @@
   if (!tdata->fromreq->stopable)
     {
       if (tdata->fromwdata && 
-          (((gftp_window_data *) tdata->fromwdata)->request->sockfd > 0 ||
+          (((gftp_window_data *) tdata->fromwdata)->request->datafd > 0 ||
            ((gftp_window_data *) tdata->fromwdata)->request->always_connected) && 
           !((gftp_window_data *) tdata->fromwdata)->request->stopable &&
           compare_request (tdata->fromreq, ((gftp_window_data *) tdata->fromwdata)->request, 0))
--- a/src/text/gftp-text.c	Sun Jun 08 15:04:40 2003 +0000
+++ b/src/text/gftp-text.c	Sun Jun 08 15:49:02 2003 +0000
@@ -335,42 +335,29 @@
       return (1);
     }
 
-  if (request->username == NULL)
+  if (request->need_userpass)
     {
-      if (request->need_userpass)
+      if (request->username == NULL || *request->username == '\0')
         {
           if ((pos = gftp_text_ask_question ("Username [anonymous]", 1, tempstr, 
                                              sizeof (tempstr))) != NULL)
             {
               gftp_set_username (request, pos);
-              if (request->password)
-                {
-                  g_free (request->password);
-                  request->password = NULL;
-                }
-            }
-          else
-            gftp_set_username (request, "anonymous");
-
-          if (strcmp (request->username, "anonymous") != 0 && 
-              (request->password == NULL || *request->password == '\0'))
-            {
-              if ((pos = gftp_text_ask_question ("Password", 0, tempstr, 
-                                                 sizeof (tempstr))) == NULL)
-                return (1);
-              gftp_set_password (request, pos);
+              gftp_set_password (request, NULL);
             }
         }
-      else
+
+      if (request->username != NULL &&
+          strcmp (request->username, "anonymous") != 0 && 
+          (request->password == NULL || *request->password == '\0'))
         {
-          request->username = g_strdup ("");
-          if (request->password != NULL)
-            g_free (request->password);
-          request->password = g_strdup ("");
+          if ((pos = gftp_text_ask_question ("Password", 0, tempstr, 
+                                             sizeof (tempstr))) == NULL)
+            return (1);
+          gftp_set_password (request, pos);
         }
     }
 
-
   gftp_connect (request);
   return (1);
 }