Source-Changes-HG archive

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

[src/netbsd-6]: src/usr.bin/ftp Pull up following revision(s) (requested by n...



details:   https://anonhg.NetBSD.org/src/rev/d0d7df62e3dc
branches:  netbsd-6
changeset: 777173:d0d7df62e3dc
user:      snj <snj%NetBSD.org@localhost>
date:      Thu Jul 06 15:22:41 2017 +0000

description:
Pull up following revision(s) (requested by nonaka in ticket #1423):
        usr.bin/ftp/fetch.c: revision 1.226
handle proxy authentication correctly.

diffstat:

 usr.bin/ftp/fetch.c |  47 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 6 deletions(-)

diffs (103 lines):

diff -r 9ebb580bea40 -r d0d7df62e3dc usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c       Thu Jul 06 15:21:32 2017 +0000
+++ b/usr.bin/ftp/fetch.c       Thu Jul 06 15:22:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fetch.c,v 1.195.2.4 2016/11/16 17:56:42 snj Exp $      */
+/*     $NetBSD: fetch.c,v 1.195.2.5 2017/07/06 15:22:41 snj Exp $      */
 
 /*-
  * Copyright (c) 1997-2015 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.195.2.4 2016/11/16 17:56:42 snj Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.195.2.5 2017/07/06 15:22:41 snj Exp $");
 #endif /* not lint */
 
 /*
@@ -855,8 +855,7 @@
 #define C_OK 0
 #define C_CLEANUP 1
 #define C_IMPROPER 2
-#define C_PROXY 3
-#define C_NOPROXY 4
+#define C_RESTART 3
 
 static int
 getresponseline(FETCH *fin, char *buf, size_t buflen, int *len)
@@ -1087,7 +1086,7 @@
        case 401:
        case 407:
            {
-               struct  authinfo aauth;
+               struct authinfo aauth;
                char **authp;
 
                if (hcode == 401)
@@ -1122,7 +1121,8 @@
                authp = &aauth.auth;
                if (auth_url(*auth, authp, &aauth) == 0) {
                        *rval = fetch_url(url, penv,
-                           pauth->auth, wauth->auth);
+                           hcode == 401 ? pauth->auth : aauth.auth,
+                           hcode == 401 ? aauth.auth : wauth->auth);
                        memset(*authp, 0, strlen(*authp));
                        FREEPTR(*authp);
                }
@@ -1217,6 +1217,34 @@
        switch (hcode) {
        case 200:
                break;
+#ifndef NO_AUTH
+       case 407:
+               if (verbose || pauth->auth == NULL ||
+                   pauth->user == NULL || pauth->pass == NULL)
+                       fprintf(ttyout, "%s\n", message);
+               if (EMPTYSTRING(*auth)) {
+                       warnx("No authentication challenge provided by server");
+                       goto cleanup_fetch_url;
+               }
+
+               if (pauth->auth != NULL) {
+                       char reply[10];
+
+                       fprintf(ttyout, "Authorization failed. Retry (y/n)? ");
+                       if (get_line(stdin, reply, sizeof(reply), NULL)
+                           < 0) {
+                               goto cleanup_fetch_url;
+                       }
+                       if (tolower((unsigned char)reply[0]) != 'y')
+                               goto cleanup_fetch_url;
+                       pauth->user = NULL;
+                       pauth->pass = NULL;
+               }
+
+               if (auth_url(*auth, &pauth->auth, pauth) == 0)
+                       goto restart_fetch_url;
+               goto cleanup_fetch_url;
+#endif
        default:
                if (message)
                        warnx("Error proxy connect " "`%s'", message);
@@ -1237,6 +1265,9 @@
 cleanup_fetch_url:
        rv = C_CLEANUP;
        goto out;
+restart_fetch_url:
+       rv = C_RESTART;
+       goto out;
 out:
        FREEPTR(message);
        return rv;
@@ -1445,6 +1476,10 @@
                if (isproxy && oui.utype == HTTPS_URL_T) {
                        switch (connectmethod(s, fin, &oui, &ui, &pauth, &auth,
                            &hasleading)) {
+                       case C_RESTART:
+                               rval = fetch_url(url, penv, pauth.auth,
+                                   wauth.auth);
+                               /*FALLTHROUGH*/
                        case C_CLEANUP:
                                goto cleanup_fetch_url;
                        case C_IMPROPER:



Home | Main Index | Thread Index | Old Index