lftp-devel  

FW: Random: SSL problem with lftp

Lenga, Yair
Thu, 07 Feb 2008 13:52:33 -0800

Hi,

We have encountered a problem with "active" FTP (using the PORT
command). We were getting random error on "vsf_sysutil_bind". We noticed
that the messages only came when we used Solaris 5.8 clients (using
Active FTP). Newer clients (curl, lftp, ...) do not trigger this error.
We verified that the problems occurs with "ACTIVE" FTP, and does not
occur with Passive FTP.

We have modified the function below (from privops.c) - added the logic
that exists in the "Passive" FTP handle_pasv in postlogin.c. 

I'll appreciate if someone can comment on the change. Is it possible it
integrate it into future versions of vsftpd ?

Thanks
Yair Lenga

int
vsf_privop_get_ftp_port_sock(struct vsf_session* p_sess)
{
  static struct vsf_sysutil_sockaddr* p_sockaddr;
  int retval;
  int s = vsf_sysutil_get_ipsock(p_sess->p_local_addr);
  int bind_retries = 10;

  vsf_sysutil_activate_reuseaddr(s);
  vsf_sysutil_sockaddr_clone(&p_sockaddr, p_sess->p_local_addr);
  vsf_sysutil_sockaddr_set_port(p_sockaddr, tunable_ftp_data_port);

//  retval = vsf_sysutil_bind(s, p_sockaddr);

  while (--bind_retries)
  {
    retval = vsf_sysutil_bind(s, p_sockaddr);
    if (!vsf_sysutil_retval_is_error(retval))
    {
      break;
    }
    if (vsf_sysutil_get_error() == kVSFSysUtilErrADDRINUSE)
    {
      continue;
    }
    die("vsf_sysutil_bind");
  }
  return s;
}