diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-06-21 19:22:55 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-06-21 19:22:55 +0000 |
commit | f6802f211aa961083acb34be065507924fa6363f (patch) | |
tree | 0a51618e8388978fdb2cc37a63518313b3a51c35 /usr.bin/ftp/ftp.c | |
parent | 0d20db6bf333b04aaa72b23c998bc33aef690186 (diff) |
add epsv4 command, which turns off epsv on ipv4 (off by dfeault)
automagicaslly disable epsv on ipv4, if epsv fails for single connection.
merge from netbsd-current.
req from fgs.
Diffstat (limited to 'usr.bin/ftp/ftp.c')
-rw-r--r-- | usr.bin/ftp/ftp.c | 39 |
1 files changed, 32 insertions, 7 deletions
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: |