Subject: bin/18535: ftp -V shouldn't show 401
To: None <gnats-bugs@gnats.netbsd.org>
From: None <reed@reedmedia.net>
List: netbsd-bugs
Date: 10/05/2002 01:34:26
>Number:         18535
>Category:       bin
>Synopsis:       ftp -V should not show 401
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 05 01:34:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.6
>Organization:
	
>Environment:
	
	
System: NetBSD kids.reedmedia.net 1.6 NetBSD 1.6 (GENERIC) #0: Sun Sep 8 19:43:40 UTC 2002 autobuild@tgm.daemon.org:/autobuild/i386/OBJ/autobuild/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
If using ftp(1) with -V switch and including user:password@ to
retrieve a 401-protected document, it shouldn't give a
"401 Authorization Required" message.

In other words, if verbose is disabled and no need for reporting 401
then don't display it.
>How-To-Repeat:
Use ftp to automatically fetch a document where 401 Authentication Required
with verbose disabled and wonder why you get needless 401 message.
>Fix:
Since I don't want it and don't want to sed(1) it out a patch is provided.
Please consider this patch.
Basically it adds one line, but moves some code around so
it can use some variables. Note that it will show the 401 message
if there is no username or no password or if previous attempt failed.

--- fetch.c.orig	Mon May  6 08:03:30 2002
+++ fetch.c	Sat Oct  5 01:24:28 2002
@@ -1003,12 +1003,6 @@
 			char **authp;
 			char *auser, *apass;
 
-			fprintf(ttyout, "%s\n", message);
-			if (EMPTYSTRING(auth)) {
-				warnx(
-			    "No authentication challenge provided by server");
-				goto cleanup_fetch_url;
-			}
 			if (hcode == 401) {
 				authp = &wwwauth;
 				auser = user;
@@ -1017,6 +1011,13 @@
 				authp = &proxyauth;
 				auser = puser;
 				apass = ppass;
+			}
+			if (verbose || *authp != NULL || !auser || !apass)
+				fprintf(ttyout, "%s\n", message);
+			if (EMPTYSTRING(auth)) {
+				warnx(
+			    "No authentication challenge provided by server");
+				goto cleanup_fetch_url;
 			}
 			if (*authp != NULL) {
 				char reply[10];
>Release-Note:
>Audit-Trail:
>Unformatted: