pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/libfetch libfetch-2.18:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/cbf8b84bae70
branches:  trunk
changeset: 548087:cbf8b84bae70
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Wed Oct 08 15:11:21 2008 +0000

description:
libfetch-2.18:
Change FTP backend to use passive mode by default and fallback to active
mode on syntax errors as discussed with and suggested by Luke Mewburn.
Retire 'p' now and introduce 'a' flag to get the old default behavior.

diffstat:

 net/libfetch/Makefile         |   4 +-
 net/libfetch/files/fetch.3    |  12 +++++--
 net/libfetch/files/fetch.cat3 |  58 ++++++++++++++++++++++--------------------
 net/libfetch/files/ftp.c      |  14 ++++++++-
 4 files changed, 52 insertions(+), 36 deletions(-)

diffs (238 lines):

diff -r a4ba164e18b3 -r cbf8b84bae70 net/libfetch/Makefile
--- a/net/libfetch/Makefile     Wed Oct 08 14:30:35 2008 +0000
+++ b/net/libfetch/Makefile     Wed Oct 08 15:11:21 2008 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.20 2008/10/06 23:37:56 joerg Exp $
+# $NetBSD: Makefile,v 1.21 2008/10/08 15:11:21 joerg Exp $
 #
 
-DISTNAME=      libfetch-2.17
+DISTNAME=      libfetch-2.18
 CATEGORIES=    net
 MASTER_SITES=  # empty
 DISTFILES=     # empty
diff -r a4ba164e18b3 -r cbf8b84bae70 net/libfetch/files/fetch.3
--- a/net/libfetch/files/fetch.3        Wed Oct 08 14:30:35 2008 +0000
+++ b/net/libfetch/files/fetch.3        Wed Oct 08 15:11:21 2008 +0000
@@ -24,7 +24,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD: fetch.3,v 1.64 2007/12/18 11:03:26 des Exp $
-.\" $NetBSD: fetch.3,v 1.9 2008/10/06 12:58:29 joerg Exp $
+.\" $NetBSD: fetch.3,v 1.10 2008/10/08 15:11:21 joerg Exp $
 .\"
 .Dd April 25, 2008
 .Dt FETCH 3
@@ -358,10 +358,14 @@
 .Fn fetchPutFTP
 implement the FTP protocol as described in RFC 959.
 .Pp
+By default
+.Nm libfetch
+will attempt to use passive mode first and only fallback to active mode
+if the server reports a syntax error.
 If the
-.Ql p
-(passive) flag is specified, a passive (rather than active) connection
-will be attempted.
+.Ql a
+(active) flag is specified, a passive connection is not tried and active mode
+is used directly.
 .Pp
 If the
 .Ql l
diff -r a4ba164e18b3 -r cbf8b84bae70 net/libfetch/files/fetch.cat3
--- a/net/libfetch/files/fetch.cat3     Wed Oct 08 14:30:35 2008 +0000
+++ b/net/libfetch/files/fetch.cat3     Wed Oct 08 15:11:21 2008 +0000
@@ -126,7 +126,7 @@
 
      ffeettcchhPPaarrsseeUURRLL() takes a URL in the form of a null-terminated string and
      splits it into its components function according to the Common Internet
-     Scheme Syntax detailed in RFC1738.  A regular expression which produces
+     Scheme Syntax detailed in RFC 1738.  A regular expression which produces
      this syntax is:
 
          <scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
@@ -140,7 +140,7 @@
      the URL automatically.  This is not done by ffeettcchhMMaakkeeUURRLL().
      ffeettcchhCCooppyyUURRLL() copies an existing _u_r_l structure.
 
-     ffeettcchhMMaakkeeUURRLL(), ffeettcchhPPaarrsseeUURRLL() and ffeettcchhCCooppyyUURRLL() return a pointer to a
+     ffeettcchhMMaakkeeUURRLL(), ffeettcchhPPaarrsseeUURRLL(), and ffeettcchhCCooppyyUURRLL() return a pointer to a
      _u_r_l structure, which is defined as follows in <_f_e_t_c_h_._h>:
 
      #define URL_SCHEMELEN 16
@@ -159,7 +159,7 @@
          size_t       length;
      };
 
-     The pointer returned by ffeettcchhMMaakkeeUURRLL(), ffeettcchhCCooppyyUURRLL() and
+     The pointer returned by ffeettcchhMMaakkeeUURRLL(), ffeettcchhCCooppyyUURRLL(), and
      ffeettcchhPPaarrsseeUURRLL() should be freed using ffeettcchhFFrreeeeUURRLL().
 
      ffeettcchhXXGGeettUURRLL(), ffeettcchhGGeettUURRLL(), and ffeettcchhPPuuttUURRLL() constitute the recom-
@@ -201,23 +201,23 @@
          struct url  *urls;
      };
 
-     The list should be initialised by calling ffeettcchhIInniittUURRLLLLiisstt() and the
+     The list should be initialized by calling ffeettcchhIInniittUURRLLLLiisstt() and the
      entries be freed by calling ffeettcchhFFrreeeeUURRLLLLiisstt().
 
      ffeettcchhSSttrriinnggiiffyyUURRLL() returns the URL as string.  ffeettcchhUUnnqquuootteePPaatthh()
      returns the path name part of the URL with any quoting undone.  Query
      arguments and fragment identifiers are not included.
      ffeettcchhUUnnqquuootteeFFiilleennaammee() returns the last component of the path name as
-     returned by ffeettcchhUUnnqquuootteePPaatthh().  ffeettcchhSSttrriinnggiiffyyUURRLL(), ffeettcchhUUnnqquuootteePPaatthh()
+     returned by ffeettcchhUUnnqquuootteePPaatthh().  ffeettcchhSSttrriinnggiiffyyUURRLL(), ffeettcchhUUnnqquuootteePPaatthh(),
      and ffeettcchhUUnnqquuootteeFFiilleennaammee() return a string that should be deallocated
      with ffrreeee() after use.
 
-     ffeettcchhXXGGeett(), ffeettcchhGGeett(), ffeettcchhPPuutt() and ffeettcchhSSttaatt() are similar to
-     ffeettcchhXXGGeettUURRLL(), ffeettcchhGGeettUURRLL(), ffeettcchhPPuuttUURRLL() and ffeettcchhSSttaattUURRLL(), except
+     ffeettcchhXXGGeett(), ffeettcchhGGeett(), ffeettcchhPPuutt(), and ffeettcchhSSttaatt() are similar to
+     ffeettcchhXXGGeettUURRLL(), ffeettcchhGGeettUURRLL(), ffeettcchhPPuuttUURRLL(), and ffeettcchhSSttaattUURRLL(), except
      that they expect a pre-parsed URL in the form of a pointer to a _s_t_r_u_c_t
      _u_r_l rather than a string.
 
-     All of the ffeettcchhXXGGeettXXXXXX(), ffeettcchhGGeettXXXXXX() and ffeettcchhPPuuttXXXXXX() functions
+     All of the ffeettcchhXXGGeettXXXXXX(), ffeettcchhGGeettXXXXXX(), and ffeettcchhPPuuttXXXXXX() functions
      return a pointer to a stream which can be used to read or write data from
      or to the requested document, respectively.  Note that although the
      implementation details of the individual access methods vary, it can gen-
@@ -226,9 +226,9 @@
      of the ffeettcchhPPuuttXXXXXX() functions is write-only.
 
 FFIILLEE SSCCHHEEMMEE
-     ffeettcchhXXGGeettFFiillee(), ffeettcchhGGeettFFiillee() and ffeettcchhPPuuttFFiillee() provide access to doc-
-     uments which are files in a locally mounted file system.  Only the <docu-
-     ment> component of the URL is used.
+     ffeettcchhXXGGeettFFiillee(), ffeettcchhGGeettFFiillee(), and ffeettcchhPPuuttFFiillee() provide access to
+     documents which are files in a locally mounted file system.  Only the
+     <document> component of the URL is used.
 
      ffeettcchhXXGGeettFFiillee() and ffeettcchhGGeettFFiillee() do not accept any flags.
 
@@ -238,16 +238,18 @@
      them.
 
 FFTTPP SSCCHHEEMMEE
-     ffeettcchhXXGGeettFFTTPP(), ffeettcchhGGeettFFTTPP() and ffeettcchhPPuuttFFTTPP() implement the FTP proto-
-     col as described in RFC959.
+     ffeettcchhXXGGeettFFTTPP(), ffeettcchhGGeettFFTTPP(), and ffeettcchhPPuuttFFTTPP() implement the FTP proto-
+     col as described in RFC 959.
 
-     If the `p' (passive) flag is specified, a passive (rather than active)
-     connection will be attempted.
+     By default lliibbffeettcchh will attempt to use passive mode first and only fall-
+     back to active mode if the server reports a syntax error.  If the `a'
+     (active) flag is specified, a passive connection is not tried and active
+     mode is used directly.
 
      If the `l' (low) flag is specified, data sockets will be allocated in the
      low (or default) port range instead of the high port range (see ip(4)).
 
-     If the `d' (direct) flag is specified, ffeettcchhXXGGeettFFTTPP(), ffeettcchhGGeettFFTTPP() and
+     If the `d' (direct) flag is specified, ffeettcchhXXGGeettFFTTPP(), ffeettcchhGGeettFFTTPP(), and
      ffeettcchhPPuuttFFTTPP() will use a direct connection even if a proxy server is
      defined.
 
@@ -256,11 +258,11 @@
      mous@<hostname>".
 
 HHTTTTPP SSCCHHEEMMEE
-     The ffeettcchhXXGGeettHHTTTTPP(), ffeettcchhGGeettHHTTTTPP() and ffeettcchhPPuuttHHTTTTPP() functions imple-
+     The ffeettcchhXXGGeettHHTTTTPP(), ffeettcchhGGeettHHTTTTPP(), and ffeettcchhPPuuttHHTTTTPP() functions imple-
      ment the HTTP/1.1 protocol.  With a little luck, there is even a chance
-     that they comply with RFC2616 and RFC2617.
+     that they comply with RFC 2616 and RFC 2617.
 
-     If the `d' (direct) flag is specified, ffeettcchhXXGGeettHHTTTTPP(), ffeettcchhGGeettHHTTTTPP()
+     If the `d' (direct) flag is specified, ffeettcchhXXGGeettHHTTTTPP(), ffeettcchhGGeettHHTTTTPP(),
      and ffeettcchhPPuuttHHTTTTPP() will use a direct connection even if a proxy server is
      defined.
 
@@ -338,7 +340,7 @@
      and message, e.g. "File is not available (404 Not Found)"
 
 EENNVVIIRROONNMMEENNTT
-     FETCH_BIND_ADDRESS  Specifies a hostname or IP address to which sockets
+     FETCH_BIND_ADDRESS  Specifies a host name or IP address to which sockets
                          used for outgoing connections will be bound.
 
      FTP_LOGIN           Default FTP login if none was provided in the URL.
@@ -437,24 +439,24 @@
            NO_PROXY=localhost,127.0.0.1
 
 SSEEEE AALLSSOO
-     fetch(1), ftpio(3), ip(4)
+     ftp(1), ip(4)
 
-     J. Postel and J. K. Reynolds, _F_i_l_e _T_r_a_n_s_f_e_r _P_r_o_t_o_c_o_l, October 1985,
-     RFC959.
+     J. Postel and J. K. Reynolds, _F_i_l_e _T_r_a_n_s_f_e_r _P_r_o_t_o_c_o_l, October 1985, RFC
+     959.
 
-     P. Deutsch, A. Emtage, and A. Marine., _H_o_w _t_o _U_s_e _A_n_o_n_y_m_o_u_s _F_T_P, May
-     1994, RFC1635.
+     P. Deutsch, A. Emtage, and A. Marine, _H_o_w _t_o _U_s_e _A_n_o_n_y_m_o_u_s _F_T_P, May 1994,
+     RFC 1635.
 
      T. Berners-Lee, L. Masinter, and M. McCahill, _U_n_i_f_o_r_m _R_e_s_o_u_r_c_e _L_o_c_a_t_o_r_s
-     _(_U_R_L_), December 1994, RFC1738.
+     _(_U_R_L_), December 1994, RFC 1738.
 
      R. Fielding, J. Gettys, J. Mogul, H. Frystyk, L. Masinter, P. Leach, and
      T. Berners-Lee, _H_y_p_e_r_t_e_x_t _T_r_a_n_s_f_e_r _P_r_o_t_o_c_o_l _-_- _H_T_T_P_/_1_._1, January 1999,
-     RFC2616.
+     RFC 2616.
 
      J. Franks, P. Hallam-Baker, J. Hostetler, S. Lawrence, P. Leach, A.
      Luotonen, and L. Stewart, _H_T_T_P _A_u_t_h_e_n_t_i_c_a_t_i_o_n_: _B_a_s_i_c _a_n_d _D_i_g_e_s_t _A_c_c_e_s_s
-     _A_u_t_h_e_n_t_i_c_a_t_i_o_n, June 1999, RFC2617.
+     _A_u_t_h_e_n_t_i_c_a_t_i_o_n, June 1999, RFC 2617.
 
 HHIISSTTOORRYY
      The ffeettcchh library first appeared in FreeBSD 3.0.
diff -r a4ba164e18b3 -r cbf8b84bae70 net/libfetch/files/ftp.c
--- a/net/libfetch/files/ftp.c  Wed Oct 08 14:30:35 2008 +0000
+++ b/net/libfetch/files/ftp.c  Wed Oct 08 15:11:21 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp.c,v 1.23 2008/10/06 12:58:29 joerg Exp $   */
+/*     $NetBSD: ftp.c,v 1.24 2008/10/08 15:11:21 joerg Exp $   */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
@@ -629,7 +629,7 @@
 
        /* check flags */
        low = CHECK_FLAG('l');
-       pasv = CHECK_FLAG('p');
+       pasv = !CHECK_FLAG('a');
        verbose = CHECK_FLAG('v');
 
        /* passive mode */
@@ -651,6 +651,8 @@
        if (sa.ss_family == AF_INET6)
                unmappedaddr((struct sockaddr_in6 *)&sa, &l);
 
+retry_mode:
+
        /* open data socket */
        if ((sd = socket(sa.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
                fetch_syserr();
@@ -723,6 +725,14 @@
                                goto ouch;
                        }
                        break;
+               case FTP_SYNTAX_ERROR:
+                       if (verbose)
+                               fetch_info("passive mode failed");
+                       /* Close socket and retry with passive mode. */
+                       pasv = 0;
+                       close(sd);
+                       sd = -1;
+                       goto retry_mode;
                }
 
                /* seek to required offset */



Home | Main Index | Thread Index | Old Index