Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/ftp add epsv4 command, which enable/disable the use ...



details:   https://anonhg.NetBSD.org/src/rev/0960c1ff376d
branches:  trunk
changeset: 474572:0960c1ff376d
user:      itojun <itojun%NetBSD.org@localhost>
date:      Sun Jul 11 20:37:39 1999 +0000

description:
add epsv4 command, which enable/disable the use of EPSV/EPRT.

this is mainly for (hypothetical) ftp server which disconnect clients
that use EPSV/EPRT.  I've never seen any ftp server like this, but
epsv4 command may be of use when such an ftp server is found.

diffstat:

 usr.bin/ftp/cmds.c    |  15 +++++++++++++--
 usr.bin/ftp/cmdtab.c  |   6 ++++--
 usr.bin/ftp/extern.h  |   3 ++-
 usr.bin/ftp/ftp.1     |  13 ++++++++++++-
 usr.bin/ftp/ftp.c     |  15 +++++++++++----
 usr.bin/ftp/ftp_var.h |   9 ++-------
 usr.bin/ftp/main.c    |   5 +++--
 7 files changed, 47 insertions(+), 19 deletions(-)

diffs (229 lines):

diff -r ffacee069dba -r 0960c1ff376d usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c        Sun Jul 11 20:17:01 1999 +0000
+++ b/usr.bin/ftp/cmds.c        Sun Jul 11 20:37:39 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.54 1999/07/02 08:07:40 itojun Exp $ */
+/*     $NetBSD: cmds.c,v 1.55 1999/07/11 20:37:39 itojun Exp $ */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -107,7 +107,7 @@
 #if 0
 static char sccsid[] = "@(#)cmds.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: cmds.c,v 1.54 1999/07/02 08:07:40 itojun Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.55 1999/07/11 20:37:39 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -763,6 +763,7 @@
            "Put transfer rate throttle: %s; maximum: %d; increment %d.\n",
            onoff(rate_put), rate_put, rate_put_incr);
        fprintf(ttyout, "Use of PORT cmds: %s.\n", onoff(sendport));
+       fprintf(ttyout, "Use of EPSV/EPRT cmds on IPv4: %s.\n", onoff(epsv4));
 #ifndef NO_EDITCOMPLETE
        fprintf(ttyout, "Command line editing: %s.\n", onoff(editing));
 #endif /* !NO_EDITCOMPLETE */
@@ -2472,3 +2473,13 @@
        else
                rcvbuf_manual = 0;
 }
+
+void
+setepsv4(argc, argv)
+       int argc;
+       char *argv[];
+{
+
+       code = togglevar(argc, argv, &epsv4,
+           verbose ? "EPSV/EPRT on IPv4" : NULL);
+}
diff -r ffacee069dba -r 0960c1ff376d usr.bin/ftp/cmdtab.c
--- a/usr.bin/ftp/cmdtab.c      Sun Jul 11 20:17:01 1999 +0000
+++ b/usr.bin/ftp/cmdtab.c      Sun Jul 11 20:37:39 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmdtab.c,v 1.24 1999/07/02 08:07:41 itojun Exp $       */
+/*     $NetBSD: cmdtab.c,v 1.25 1999/07/11 20:37:39 itojun Exp $       */
 
 /*
  * Copyright (c) 1985, 1989, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)cmdtab.c   8.4 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: cmdtab.c,v 1.24 1999/07/02 08:07:41 itojun Exp $");
+__RCSID("$NetBSD: cmdtab.c,v 1.25 1999/07/11 20:37:39 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,6 +69,7 @@
 #ifndef NO_EDITCOMPLETE
 char   edithelp[] =    "toggle command line editing";
 #endif /* !NO_EDITCOMPLETE */
+char   epsv4help[] =   "toggle use of EPSV/EPRT on IPv4 ftp";
 char   formhelp[] =    "set file transfer format";
 char   gatehelp[] =    "toggle gate-ftp; specify host[:port] to change proxy";
 char   globhelp[] =    "toggle metacharacter expansion of local file names";
@@ -161,6 +162,7 @@
 #ifndef NO_EDITCOMPLETE
        { "edit",       edithelp,       0, 0, 0, CMPL0          setedit },
 #endif /* !NO_EDITCOMPLETE */
+       { "epsv4",      epsv4help,      0, 0, 0, CMPL0          setepsv4 },
        { "exit",       quithelp,       0, 0, 0, CMPL0          quit },
        { "form",       formhelp,       0, 1, 1, CMPL0          setform },
        { "ftp",        connecthelp,    0, 0, 1, CMPL0          setpeer },
diff -r ffacee069dba -r 0960c1ff376d usr.bin/ftp/extern.h
--- a/usr.bin/ftp/extern.h      Sun Jul 11 20:17:01 1999 +0000
+++ b/usr.bin/ftp/extern.h      Sun Jul 11 20:37:39 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.32 1999/07/02 08:07:41 itojun Exp $       */
+/*     $NetBSD: extern.h,v 1.33 1999/07/11 20:37:39 itojun Exp $       */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -168,6 +168,7 @@
 void   setcr __P((int, char **));
 void   setdebug __P((int, char **));
 void   setedit __P((int, char **));
+void   setepsv4 __P((int, char **));
 void   setform __P((int, char **));
 void   setftmode __P((int, char **));
 void   setgate __P((int, char **));
diff -r ffacee069dba -r 0960c1ff376d usr.bin/ftp/ftp.1
--- a/usr.bin/ftp/ftp.1 Sun Jul 11 20:17:01 1999 +0000
+++ b/usr.bin/ftp/ftp.1 Sun Jul 11 20:37:39 1999 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ftp.1,v 1.44 1999/07/02 08:07:41 itojun Exp $
+.\"    $NetBSD: ftp.1,v 1.45 1999/07/11 20:37:39 itojun Exp $
 .\"
 .\" Copyright (c) 1985, 1989, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -406,6 +406,17 @@
 completion.
 This is automatically enabled if input is from a terminal, and
 disabled otherwise.
+.It Ic epsv4
+Toggle the use of 
+.Li EPSV/EPRT
+command on IPv4 connections.
+This is enabled by default
+.Po
+first try
+.Li EPSV/EPRT ,
+then
+.Li PASV/PORT
+.Pc .
 .It Ic exit
 A synonym for
 .Ic bye .
diff -r ffacee069dba -r 0960c1ff376d usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Sun Jul 11 20:17:01 1999 +0000
+++ b/usr.bin/ftp/ftp.c Sun Jul 11 20:37:39 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp.c,v 1.53 1999/07/11 00:41:59 christos Exp $        */
+/*     $NetBSD: ftp.c,v 1.54 1999/07/11 20:37:39 itojun Exp $  */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c      8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.53 1999/07/11 00:41:59 christos Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.54 1999/07/11 20:37:39 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -1284,9 +1284,11 @@
                    setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
                               sizeof(on)) < 0)
                        warn("setsockopt (ignored)");
+               result = COMPLETE + 1;
                switch (data_addr.su_family) {
                case AF_INET:
-                       result = command(pasvcmd = "EPSV");
+                       if (epsv4)
+                               result = command(pasvcmd = "EPSV");
                        if (result != COMPLETE)
                                result = command(pasvcmd = "PASV");
                        break;
@@ -1296,7 +1298,7 @@
                                result = command(pasvcmd = "LPSV");
                        break;
                default:
-                       result = COMPLETE + 1;
+                       break;
                }
                if (result != COMPLETE) {
                        if (activefallback) {
@@ -1471,6 +1473,11 @@
 
                switch (data_addr.su_family) {
                case AF_INET:
+                       if (!epsv4) {
+                               result = COMPLETE + 1;
+                               break;
+                       }
+                       /* FALLTHROUGH */
                case AF_INET6:
                        af = (data_addr.su_family == AF_INET) ? 1 : 2;
                        if (getnameinfo((struct sockaddr *)&data_addr,
diff -r ffacee069dba -r 0960c1ff376d usr.bin/ftp/ftp_var.h
--- a/usr.bin/ftp/ftp_var.h     Sun Jul 11 20:17:01 1999 +0000
+++ b/usr.bin/ftp/ftp_var.h     Sun Jul 11 20:37:39 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp_var.h,v 1.34 1999/07/02 08:07:42 itojun Exp $      */
+/*     $NetBSD: ftp_var.h,v 1.35 1999/07/11 20:37:39 itojun Exp $      */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -168,6 +168,7 @@
 int    ttywidth;               /* width of tty */
 char   *tmpdir;                        /* temporary directory */
 FILE   *ttyout;                        /* stdout, or stderr if retrieving to stdout */
+int    epsv4;                  /* use EPSV/EPRT on IPv4 connections */
 
 #ifndef NO_EDITCOMPLETE
 int      editing;              /* command line editing enabled */
@@ -187,15 +188,9 @@
 int    unix_server;            /* server is unix, can use binary for ascii */
 int    unix_proxy;             /* proxy is unix, can use binary for ascii */
 
-#if 0
-in_port_t      ftpport;        /* port number to use for FTP connections */
-in_port_t      httpport;       /* port number to use for HTTP connections */
-in_port_t      gateport;       /* port number to use for gateftp connections */
-#else
 char   *ftpport;               /* port number to use for FTP connections */
 char   *httpport;              /* port number to use for HTTP connections */
 char   *gateport;              /* port number to use for gateftp connections */
-#endif
 
 const char     *ftpproxy;      /* ftp:// proxy server */
 const char     *httpproxy;     /* http:// proxy server */
diff -r ffacee069dba -r 0960c1ff376d usr.bin/ftp/main.c
--- a/usr.bin/ftp/main.c        Sun Jul 11 20:17:01 1999 +0000
+++ b/usr.bin/ftp/main.c        Sun Jul 11 20:37:39 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.46 1999/07/10 19:41:15 christos Exp $       */
+/*     $NetBSD: main.c,v 1.47 1999/07/11 20:37:39 itojun Exp $ */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -72,7 +72,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.46 1999/07/10 19:41:15 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.47 1999/07/11 20:37:39 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -143,6 +143,7 @@
        rate_get_incr = DEFAULTINCR;
        rate_put = 0;
        rate_put_incr = DEFAULTINCR;
+       epsv4 = 1;
 
        marg_sl = sl_init();
        if ((tmpdir = getenv("TMPDIR")) == NULL)



Home | Main Index | Thread Index | Old Index