summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ftp/cmds.c20
-rw-r--r--usr.bin/ftp/cmdtab.c6
-rw-r--r--usr.bin/ftp/extern.h3
-rw-r--r--usr.bin/ftp/ftp.14
-rw-r--r--usr.bin/ftp/ftp.c39
-rw-r--r--usr.bin/ftp/ftp_var.h4
-rw-r--r--usr.bin/ftp/main.c10
7 files changed, 70 insertions, 16 deletions
diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c
index b3f46775d01..4761703adb2 100644
--- a/usr.bin/ftp/cmds.c
+++ b/usr.bin/ftp/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.33 2000/06/13 21:28:38 millert Exp $ */
+/* $OpenBSD: cmds.c,v 1.34 2000/06/21 19:22:54 itojun Exp $ */
/* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */
/*
@@ -67,7 +67,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: cmds.c,v 1.33 2000/06/13 21:28:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmds.c,v 1.34 2000/06/21 19:22:54 itojun Exp $";
#endif
#endif /* not lint */
@@ -709,6 +709,8 @@ status(argc, argv)
fprintf(ttyout, "Hash mark printing: %s; Mark count: %d; Progress bar: %s.\n",
onoff(hash), mark, onoff(progress));
fprintf(ttyout, "Use of PORT/LPRT cmds: %s.\n", onoff(sendport));
+ fprintf(ttyout, "Use of EPSV/EPRT cmds for IPv4: %s%s.\n", onoff(epsv4),
+ epsv4bad ? " (disabled for this connection)" : "");
#ifndef SMALL
fprintf(ttyout, "Command line editing: %s.\n", onoff(editing));
#endif /* !SMALL */
@@ -776,6 +778,20 @@ setedit(argc, argv)
#endif /* !SMALL */
/*
+ * Toggle use of IPv4 EPSV/EPRT
+ */
+/*VARARGS*/
+void
+setepsv4(argc, argv)
+ int argc;
+ char *argv[];
+{
+
+ code = togglevar(argc, argv, &epsv4, "EPSV/EPRT on IPv4");
+ epsv4bad = 0;
+}
+
+/*
* Turn on packet tracing.
*/
/*VARARGS*/
diff --git a/usr.bin/ftp/cmdtab.c b/usr.bin/ftp/cmdtab.c
index 792654fd70d..2d0d7a0cca8 100644
--- a/usr.bin/ftp/cmdtab.c
+++ b/usr.bin/ftp/cmdtab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmdtab.c,v 1.13 1999/12/08 12:57:06 itojun Exp $ */
+/* $OpenBSD: cmdtab.c,v 1.14 2000/06/21 19:22:54 itojun Exp $ */
/* $NetBSD: cmdtab.c,v 1.17 1997/08/18 10:20:17 lukem Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.13 1999/12/08 12:57:06 itojun Exp $";
+static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.14 2000/06/21 19:22:54 itojun Exp $";
#endif
#endif /* not lint */
@@ -68,6 +68,7 @@ char domachelp[] = "execute macro";
#ifndef SMALL
char edithelp[] = "toggle command line editing";
#endif /* !SMALL */
+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";
@@ -157,6 +158,7 @@ struct cmd cmdtab[] = {
#ifndef SMALL
{ "edit", edithelp, 0, 0, 0, CMPL0 setedit },
#endif /* !SMALL */
+ { "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 --git a/usr.bin/ftp/extern.h b/usr.bin/ftp/extern.h
index 0c6fd13a007..9224691cf3d 100644
--- a/usr.bin/ftp/extern.h
+++ b/usr.bin/ftp/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.19 1999/12/08 12:57:06 itojun Exp $ */
+/* $OpenBSD: extern.h,v 1.20 2000/06/21 19:22:54 itojun Exp $ */
/* $NetBSD: extern.h,v 1.17 1997/08/18 10:20:19 lukem Exp $ */
/*
@@ -162,6 +162,7 @@ void setcase __P((int, char **));
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 --git a/usr.bin/ftp/ftp.1 b/usr.bin/ftp/ftp.1
index 8d027fd5ed8..0851c77f012 100644
--- a/usr.bin/ftp/ftp.1
+++ b/usr.bin/ftp/ftp.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ftp.1,v 1.30 2000/06/13 21:28:38 millert Exp $
+.\" $OpenBSD: ftp.1,v 1.31 2000/06/21 19:22:54 itojun Exp $
.\" $NetBSD: ftp.1,v 1.22 1997/08/18 10:20:22 lukem Exp $
.\"
.\" Copyright (c) 1985, 1989, 1990, 1993
@@ -298,6 +298,8 @@ Toggle command line editing, and context sensitive command and file
completion.
This is automatically enabled if input is from a terminal, and
disabled otherwise.
+.It Ic epsv4
+Toggle use of EPSV/EPRT command on IPv4 connection.
.It Ic exit
A synonym for
.Ic bye .
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c
index ff7d41394d4..9be5c86f8fa 100644
--- a/usr.bin/ftp/ftp.c
+++ b/usr.bin/ftp/ftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp.c,v 1.35 2000/05/03 19:50:41 deraadt Exp $ */
+/* $OpenBSD: ftp.c,v 1.36 2000/06/21 19:22:54 itojun Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */
/*
@@ -67,7 +67,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
-static char rcsid[] = "$OpenBSD: ftp.c,v 1.35 2000/05/03 19:50:41 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ftp.c,v 1.36 2000/06/21 19:22:54 itojun Exp $";
#endif
#endif /* not lint */
@@ -138,6 +138,8 @@ hookup(host, port)
char hbuf[MAXHOSTNAMELEN];
char *cause = "unknown";
+ epsv4bad = 0;
+
memset((char *)&hisctladdr, 0, sizeof (hisctladdr));
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
@@ -1217,12 +1219,22 @@ reinit:
warn("setsockopt (ignored)");
switch (data_addr.su_family) {
case AF_INET:
- result = command(pasvcmd = "EPSV");
- if (code / 10 == 22 && code != 229) {
- fputs(
+ if (epsv4 && !epsv4bad) {
+ result = command(pasvcmd = "EPSV");
+ if (code / 10 == 22 && code != 229) {
+ fputs(
"wrong server: return code must be 229\n",
- ttyout);
- result = COMPLETE + 1;
+ ttyout);
+ result = COMPLETE + 1;
+ }
+ if (result != COMPLETE) {
+ epsv4bad = 1;
+ if (debug) {
+ fputs(
+"disabling epsv4 for this connection\n",
+ ttyout);
+ }
+ }
}
if (result != COMPLETE)
result = command(pasvcmd = "PASV");
@@ -1464,6 +1476,11 @@ noport:
switch (data_addr.su_family) {
case AF_INET:
+ if (!epsv4 || epsv4bad) {
+ result = COMPLETE +1;
+ break;
+ }
+ /*FALLTHROUGH*/
case AF_INET6:
af = (data_addr.su_family == AF_INET) ? 1 : 2;
if (getnameinfo((struct sockaddr *)&data_addr,
@@ -1473,6 +1490,14 @@ noport:
} else {
result = command("EPRT |%d|%s|%d|",
af, hname, ntohs(data_addr.su_port));
+ if (result != COMPLETE) {
+ epsv4bad = 1;
+ if (debug) {
+ fputs(
+"disabling epsv4 for this connection\n",
+ ttyout);
+ }
+ }
}
break;
default:
diff --git a/usr.bin/ftp/ftp_var.h b/usr.bin/ftp/ftp_var.h
index 635abee5728..5ba60d43145 100644
--- a/usr.bin/ftp/ftp_var.h
+++ b/usr.bin/ftp/ftp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp_var.h,v 1.18 1999/12/08 12:57:06 itojun Exp $ */
+/* $OpenBSD: ftp_var.h,v 1.19 2000/06/21 19:22:54 itojun Exp $ */
/* $NetBSD: ftp_var.h,v 1.18 1997/08/18 10:20:25 lukem Exp $ */
/*
@@ -152,6 +152,8 @@ int anonftp; /* automatic anonymous login */
int dirchange; /* remote directory changed by cd command */
unsigned int retry_connect; /* retry connect if failed */
int ttywidth; /* width of tty */
+int epsv4; /* use EPSV/EPRT on IPv4 connections */
+int epsv4bad; /* EPSV doesn't work on the current server */
#ifndef SMALL
int editing; /* command line editing enabled */
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index 73dc06ae729..5361a56b58e 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.46 2000/06/11 09:03:32 fgsch Exp $ */
+/* $OpenBSD: main.c,v 1.47 2000/06/21 19:22:54 itojun Exp $ */
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */
/*
@@ -73,7 +73,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.46 2000/06/11 09:03:32 fgsch Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.47 2000/06/21 19:22:54 itojun Exp $";
#endif
#endif /* not lint */
@@ -129,6 +129,12 @@ main(argc, argv)
#endif
mark = HASHBYTES;
marg_sl = sl_init();
+#ifdef INET6
+ epsv4 = 1;
+#else
+ epsv4 = 0;
+#endif
+ epsv4bad = 0;
/* Set default operation mode based on FTPMODE environment variable */
if ((cp = getenv("FTPMODE")) != NULL) {