From ea73350dac9ff0028aa766eafb0089c4ae5c6937 Mon Sep 17 00:00:00 2001 From: lukem Date: Wed, 11 Apr 2007 05:03:25 +0000 Subject: [PATCH] Suppress printing non-COMPLETE reply strings from EPSV and EPRT, as we're going to fall back to PASV / PORT (respectively) if the former fail, and this avoids printing a failure reply followed by a success reply. Should fix a problem with the emacs ftp wrapper. --- usr.bin/ftp/ftp.c | 29 +++++++++++++++++++++++++---- usr.bin/ftp/version.h | 4 ++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index 8cc06412f659..00df48b3b9c2 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,7 +1,7 @@ -/* $NetBSD: ftp.c,v 1.143 2006/12/13 18:04:08 christos Exp $ */ +/* $NetBSD: ftp.c,v 1.144 2007/04/11 05:03:25 lukem Exp $ */ /*- - * Copyright (c) 1996-2005 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2007 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -99,7 +99,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.143 2006/12/13 18:04:08 christos Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.144 2007/04/11 05:03:25 lukem Exp $"); #endif #endif /* not lint */ @@ -455,7 +455,7 @@ getreply(int expecteof) midx = 1; else midx = 2; - (void)fprintf(ttyout, + (void)fprintf(ttyout, "421 Service not available, %s.\n", m421[midx]); (void)fflush(ttyout); } @@ -1267,6 +1267,7 @@ initconn(void) unsigned int af, hal, pal; socklen_t len; char *pasvcmd = NULL; + int overbose; #ifdef INET6 #ifndef NO_DEBUG @@ -1295,7 +1296,14 @@ initconn(void) case AF_INET: if (epsv4 && !epsv4bad) { pasvcmd = "EPSV"; + overbose = verbose; + if (ftp_debug == 0) + verbose = -1; result = command("EPSV"); + verbose = overbose; + if (verbose && + (result == COMPLETE || !connected)) + fprintf(ttyout, "%s\n", reply_string); if (!connected) return (1); /* @@ -1324,7 +1332,13 @@ initconn(void) #ifdef INET6 case AF_INET6: pasvcmd = "EPSV"; + overbose = verbose; + if (ftp_debug == 0) + verbose = -1; result = command("EPSV"); + verbose = overbose; + if (verbose && (result == COMPLETE || !connected)) + fprintf(ttyout, "%s\n", reply_string); if (!connected) return (1); /* this code is to be friendly with broken BSDI ftpd */ @@ -1596,8 +1610,15 @@ initconn(void) sizeof(sname), NI_NUMERICHOST | NI_NUMERICSERV)) { result = ERROR; } else { + overbose = verbose; + if (ftp_debug == 0) + verbose = -1; result = command("EPRT |%d|%s|%s|", af, hname, sname); + verbose = overbose; + if (verbose && + (result == COMPLETE || !connected)) + fprintf(ttyout, "%s\n", reply_string); if (!connected) return (1); if (result != COMPLETE) { diff --git a/usr.bin/ftp/version.h b/usr.bin/ftp/version.h index 13f2809ebee9..7b978d8cfa01 100644 --- a/usr.bin/ftp/version.h +++ b/usr.bin/ftp/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.59 2007/04/11 00:52:38 lukem Exp $ */ +/* $NetBSD: version.h,v 1.60 2007/04/11 05:03:25 lukem Exp $ */ /*- * Copyright (c) 1999-2007 The NetBSD Foundation, Inc. * All rights reserved. @@ -40,5 +40,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20070410" +#define FTP_VERSION "20070411" #endif