From: Peter Avalos Date: Sat, 9 Feb 2008 18:35:32 +0000 (+0000) Subject: Merge from vendor branch TNFTP: X-Git-Tag: v2.0.1~1144 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/de7b8ea980507045f9d50c5449ef717011d77970?hp=ef8ef949c390218ca15365448ef76adc6d1502a9 Merge from vendor branch TNFTP: Sync tnftp with NetBSD: Rename HAVE_STRUCT_SOCKADDR_SA_LEN to HAVE_STRUCT_SOCKADDR_IN_SIN_LEN to accurately reflect the structure member being used. Turn off the alarmtimer before resetting the SIGALRM handler back to SIG_DFL. --- diff --git a/contrib/tnftp/fetch.c b/contrib/tnftp/fetch.c index bd6073d107..be789365d8 100644 --- a/contrib/tnftp/fetch.c +++ b/contrib/tnftp/fetch.c @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.182 2007/08/22 23:47:13 lukem Exp $ */ +/* $NetBSD: fetch.c,v 1.183 2007/12/05 03:46:33 lukem Exp $ */ /*- * Copyright (c) 1997-2007 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.182 2007/08/22 23:47:13 lukem Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.183 2007/12/05 03:46:33 lukem Exp $"); #endif /* not lint */ /* @@ -329,6 +329,7 @@ parse_url(const char *url, const char *desc, url_t *type, || pass == NULL || host == NULL || port == NULL || portnum == NULL || path == NULL) errx(1, "parse_url: invoked with NULL argument!"); + DPRINTF("parse_url: %s `%s'\n", desc, url); origurl = url; *type = UNKNOWN_URL_T; @@ -453,9 +454,9 @@ parse_url(const char *url, const char *desc, url_t *type, DPRINTF("parse_url: user `%s' pass `%s' host %s port %s(%d) " "path `%s'\n", - *user ? *user : "", *pass ? *pass : "", - *host ? *host : "", *port ? *port : "", - *portnum ? *portnum : -1, *path ? *path : ""); + STRorNULL(*user), STRorNULL(*pass), + STRorNULL(*host), STRorNULL(*port), + *portnum ? *portnum : -1, STRorNULL(*path)); return (0); } @@ -506,6 +507,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) url_t urltype; in_port_t portnum; + DPRINTF("fetch_url: `%s' proxyenv `%s'\n", url, STRorNULL(proxyenv)); + oldintr = oldintp = NULL; closefunc = NULL; fin = fout = NULL; @@ -549,6 +552,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) else savefile = ftp_strdup(decodedpath); } + DPRINTF("fetch_url: savefile `%s'\n", savefile); if (EMPTYSTRING(savefile)) { if (urltype == FTP_URL_T) { rval = fetch_ftp(url); @@ -557,8 +561,6 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) warnx("No file after directory (you must specify an " "output file) `%s'", url); goto cleanup_fetch_url; - } else { - DPRINTF("savefile `%s'\n", savefile); } restart_point = 0; @@ -841,7 +843,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) } while (len > 0 && (ISLWS(buf[len-1]))) buf[--len] = '\0'; - DPRINTF("received `%s'\n", buf); + DPRINTF("fetch_url: received `%s'\n", buf); /* Determine HTTP response code */ cp = strchr(buf, ' '); @@ -867,7 +869,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) buf[--len] = '\0'; if (len == 0) break; - DPRINTF("received `%s'\n", buf); + DPRINTF("fetch_url: received `%s'\n", buf); /* * Look for some headers @@ -879,7 +881,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) filesize = STRTOLL(cp, &ep, 10); if (filesize < 0 || *ep != '\0') goto improper; - DPRINTF("parsed len as: " LLF "\n", + DPRINTF("fetch_url: parsed len as: " LLF "\n", (LLT)filesize); } else if (match_token(&cp, "Content-Range:")) { @@ -961,7 +963,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) } else if (match_token(&cp, "Location:")) { location = ftp_strdup(cp); - DPRINTF("parsed location as `%s'\n", cp); + DPRINTF("fetch_url: parsed location as `%s'\n", + cp); } else if (match_token(&cp, "Transfer-Encoding:")) { if (match_token(&cp, "binary")) { @@ -976,19 +979,19 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) goto cleanup_fetch_url; } ischunked++; - DPRINTF("using chunked encoding\n"); + DPRINTF("fetch_url: using chunked encoding\n"); } else if (match_token(&cp, "Proxy-Authenticate:") || match_token(&cp, "WWW-Authenticate:")) { if (! (token = match_token(&cp, "Basic"))) { DPRINTF( - "skipping unknown auth scheme `%s'\n", + "fetch_url: skipping unknown auth scheme `%s'\n", token); continue; } FREEPTR(auth); auth = ftp_strdup(token); - DPRINTF("parsed auth as `%s'\n", cp); + DPRINTF("fetch_url: parsed auth as `%s'\n", cp); } } @@ -1187,7 +1190,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) warnx("Unexpected data following chunk-size"); goto cleanup_fetch_url; } - DPRINTF("got chunk-size of " LLF "\n", (LLT)chunksize); + DPRINTF("fetch_url: got chunk-size of " LLF "\n", + (LLT)chunksize); if (chunksize == 0) { lastchunk = 1; goto chunkdone; @@ -1358,6 +1362,7 @@ fetch_ftp(const char *url) in_port_t portnum; url_t urltype; + DPRINTF("fetch_ftp: `%s'\n", url); host = path = dir = file = user = pass = NULL; port = NULL; rval = 1; @@ -1456,10 +1461,9 @@ fetch_ftp(const char *url) } DPRINTF("fetch_ftp: user `%s' pass `%s' host %s port %s " "path `%s' dir `%s' file `%s'\n", - user ? user : "", pass ? pass : "", - host ? host : "", port ? port : "", - path ? path : "", - dir ? dir : "", file ? file : ""); + STRorNULL(user), STRorNULL(pass), + STRorNULL(host), STRorNULL(port), + STRorNULL(path), STRorNULL(dir), STRorNULL(file)); dirhasglob = filehasglob = 0; if (doglob && urltype == CLASSIC_URL_T) { @@ -1584,9 +1588,8 @@ fetch_ftp(const char *url) url_decode(dir); } else nextpart = NULL; - DPRINTF("dir `%s', nextpart `%s'\n", - dir ? dir : "", - nextpart ? nextpart : ""); + DPRINTF("fetch_ftp: dir `%s', nextpart `%s'\n", + STRorNULL(dir), STRorNULL(nextpart)); if (urltype == FTP_URL_T || *dir != '\0') { xargv[0] = "cd"; xargv[1] = dir; @@ -1846,7 +1849,7 @@ auto_put(int argc, char **argv, const char *uploadserver) } } DPRINTF("auto_put: URL `%s' argv[2] `%s'\n", - path, uargv[2] ? uargv[2] : ""); + path, STRorNULL(uargv[2])); /* connect and cwd */ rval = auto_fetch(1, &path); diff --git a/contrib/tnftp/ftp.1 b/contrib/tnftp/ftp.1 index e7c193a497..82bd9e31ed 100644 --- a/contrib/tnftp/ftp.1 +++ b/contrib/tnftp/ftp.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.121 2007/08/20 16:07:05 perry Exp $ +.\" $NetBSD: ftp.1,v 1.123 2008/01/08 15:28:31 reed Exp $ .\" .\" Copyright (c) 1996-2007 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -73,7 +73,7 @@ Internet file transfer program .Sh SYNOPSIS .Nm -.Op Fl 46AadefginpRtvV +.Op Fl 46AadefginpRtVv .Bk -words .Op Fl N Ar netrc .Ek @@ -220,6 +220,14 @@ Disables file name globbing. .It Fl i Turns off interactive prompting during multiple file transfers. +.It Fl N Ar netrc +Use +.Ar netrc +instead of +.Pa ~/.netrc . +Refer to +.Sx THE .netrc FILE +for more information. .It Fl n Restrains .Nm @@ -239,14 +247,6 @@ identity on the local machine), and, if necessary, prompt for a password and an account with which to login. To override the auto-login for auto-fetch transfers, specify the username (and optionally, password) as appropriate. -.It Fl N Ar netrc -Use -.Ar netrc -instead of -.Pa ~/.netrc . -Refer to -.Sx THE .netrc FILE -for more information. .It Fl o Ar output When auto-fetching files, save the contents in .Ar output . @@ -264,25 +264,25 @@ then only the first file specified will be retrieved into .Ar output ; all other files will be retrieved into the basename of their remote name. +.It Fl P Ar port +Sets the port number to +.Ar port . .It Fl p Enable passive mode operation for use behind connection filtering firewalls. This option has been deprecated as .Nm now tries to use passive mode by default, falling back to active mode if the server does not support passive connections. -.It Fl P Ar port -Sets the port number to -.Ar port . .It Fl q Ar quittime Quit if the connection has stalled for .Ar quittime seconds. +.It Fl R +Restart all non-proxied auto-fetches. .It Fl r Ar wait Retry the connection attempt if it failed, pausing for .Ar wait seconds. -.It Fl R -Restart all non-proxied auto-fetches. .It Fl s Ar srcaddr Uses .Ar srcaddr @@ -317,6 +317,12 @@ is one of the ftp URL types as supported by auto-fetch (with an optional target filename for single file uploads), and .Ar file is one or more local files to be uploaded. +.It Fl V +Disable +.Ic verbose +and +.Ic progress , +overriding the default of enabled when output is to a terminal. .It Fl v Enable .Ic verbose @@ -330,12 +336,6 @@ Forces .Nm to show all responses from the remote server, as well as report on data transfer statistics. -.It Fl V -Disable -.Ic verbose -and -.Ic progress , -overriding the default of enabled when output is to a terminal. .El .Pp The client host with which @@ -460,16 +460,6 @@ when an ascii type transfer is made, these linefeeds may be distinguished from a record delimiter only when .Ic \&cr is off. -.It Ic ftp_debug Op Ar ftp_debug-value -Toggle debugging mode. -If an optional -.Ar ftp_debug-value -is specified it is used to set the debugging level. -When debugging is on, -.Nm -prints each command sent to the remote machine, preceded -by the string -.Ql \-\-\*[Gt] .It Ic delete Ar remote-file Delete the file .Ar remote-file @@ -543,6 +533,16 @@ format is .It Ic ftp Ar host Op Ar port A synonym for .Ic open . +.It Ic ftp_debug Op Ar ftp_debug-value +Toggle debugging mode. +If an optional +.Ar ftp_debug-value +is specified it is used to set the debugging level. +When debugging is on, +.Nm +prints each command sent to the remote machine, preceded +by the string +.Ql \-\-\*[Gt] . .It Ic gate Op Ar host Op Ar port Toggle gate-ftp mode, which used to connect through the TIS FWTK and Gauntlet ftp proxies. diff --git a/contrib/tnftp/ftp.c b/contrib/tnftp/ftp.c index aa44ff45f3..281ecbc162 100644 --- a/contrib/tnftp/ftp.c +++ b/contrib/tnftp/ftp.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.152 2007/07/22 05:02:50 lukem Exp $ */ +/* $NetBSD: ftp.c,v 1.153 2007/12/05 00:15:25 lukem Exp $ */ /*- * Copyright (c) 1996-2007 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.152 2007/07/22 05:02:50 lukem Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.153 2007/12/05 00:15:25 lukem Exp $"); #endif #endif /* not lint */ @@ -146,12 +146,12 @@ struct sockinet { struct sockaddr_in6 su_sin6; #endif } si_su; -#if !defined(HAVE_STRUCT_SOCKADDR_SA_LEN) +#if !defined(HAVE_STRUCT_SOCKADDR_IN_SIN_LEN) int si_len; #endif }; -#if !defined(HAVE_STRUCT_SOCKADDR_SA_LEN) +#if !defined(HAVE_STRUCT_SOCKADDR_IN_SIN_LEN) # define su_len si_len #else # define su_len si_su.su_sin.sin_len @@ -2114,7 +2114,7 @@ ai_unmapped(struct addrinfo *ai) sin.sin_port = sin6->sin6_port; ai->ai_family = AF_INET; -#if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) +#if defined(HAVE_STRUCT_SOCKADDR_IN_SIN_LEN) sin.sin_len = len; #endif memcpy(ai->ai_addr, &sin, len); diff --git a/contrib/tnftp/ftp_var.h b/contrib/tnftp/ftp_var.h index 990420ead3..efab4f65e4 100644 --- a/contrib/tnftp/ftp_var.h +++ b/contrib/tnftp/ftp_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: ftp_var.h,v 1.75 2007/07/22 05:02:50 lukem Exp $ */ +/* $NetBSD: ftp_var.h,v 1.77 2007/12/05 03:46:34 lukem Exp $ */ /*- * Copyright (c) 1996-2007 The NetBSD Foundation, Inc. @@ -328,7 +328,7 @@ extern struct option optiontab[]; #define FREEPTR(x) if ((x) != NULL) { free(x); (x) = NULL; } #ifdef BSD4_4 -# define HAVE_STRUCT_SOCKADDR_SA_LEN 1 +# define HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1 #endif #ifdef NO_LONG_LONG @@ -342,9 +342,11 @@ extern struct option optiontab[]; #define DWARN(...) #else #define DPRINTF(...) if (ftp_debug) (void)fprintf(ttyout, __VA_ARGS__) -#define DWARN(...) if (ftp_debug) warn(__VA_ARGS__) +#define DWARN(...) if (ftp_debug) warn(__VA_ARGS__) #endif +#define STRorNULL(s) ((s) ? (s) : "") + #ifdef NO_USAGE void xusage(void); #define UPRINTF(...) xusage() diff --git a/contrib/tnftp/main.c b/contrib/tnftp/main.c index 8805c368e5..22d3a075ac 100644 --- a/contrib/tnftp/main.c +++ b/contrib/tnftp/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.105 2007/05/22 05:16:48 lukem Exp $ */ +/* $NetBSD: main.c,v 1.106 2007/12/02 19:41:53 wiz Exp $ */ /*- * Copyright (c) 1996-2005 The NetBSD Foundation, Inc. @@ -104,7 +104,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: main.c,v 1.105 2007/05/22 05:16:48 lukem Exp $"); +__RCSID("$NetBSD: main.c,v 1.106 2007/12/02 19:41:53 wiz Exp $"); #endif #endif /* not lint */ @@ -1064,7 +1064,7 @@ usage(void) const char *progname = getprogname(); (void)fprintf(stderr, -"usage: %s [-46AadefginpRtvV] [-N netrc] [-o outfile] [-P port] [-q quittime]\n" +"usage: %s [-46AadefginpRtVv] [-N netrc] [-o outfile] [-P port] [-q quittime]\n" " [-r retry] [-s srcaddr] [-T dir,max[,inc]]\n" " [[user@]host [port]] [host:path[/]] [file:///file]\n" " [ftp://[user[:pass]@]host[:port]/path[/]]\n" diff --git a/contrib/tnftp/progressbar.c b/contrib/tnftp/progressbar.c index b9345cfadd..3f7e8df883 100644 --- a/contrib/tnftp/progressbar.c +++ b/contrib/tnftp/progressbar.c @@ -1,4 +1,4 @@ -/* $NetBSD: progressbar.c,v 1.17 2007/05/05 18:09:24 martin Exp $ */ +/* $NetBSD: progressbar.c,v 1.18 2008/01/21 10:31:28 lukem Exp $ */ /*- * Copyright (c) 1997-2007 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.17 2007/05/05 18:09:24 martin Exp $"); +__RCSID("$NetBSD: progressbar.c,v 1.18 2008/01/21 10:31:28 lukem Exp $"); #endif /* not lint */ /* @@ -180,8 +180,8 @@ progressmeter(int flag) "transfer aborted because stalled for %lu sec.\r\n", getprogname(), (unsigned long)wait.tv_sec); (void)write(fileno(ttyout), buf, len); - (void)xsignal(SIGALRM, SIG_DFL); alarmtimer(0); + (void)xsignal(SIGALRM, SIG_DFL); siglongjmp(toplevel, 1); } #endif /* !STANDALONE_PROGRESS */ @@ -198,8 +198,8 @@ progressmeter(int flag) (void)xsignal_restart(SIGALRM, updateprogressmeter, 1); alarmtimer(1); /* set alarm timer for 1 Hz */ } else if (flag == 1) { - (void)xsignal(SIGALRM, SIG_DFL); alarmtimer(0); + (void)xsignal(SIGALRM, SIG_DFL); } } #ifndef NO_PROGRESS diff --git a/contrib/tnftp/util.c b/contrib/tnftp/util.c index 05f0167a1d..2ab75b09e3 100644 --- a/contrib/tnftp/util.c +++ b/contrib/tnftp/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.143 2007/05/24 05:05:19 lukem Exp $ */ +/* $NetBSD: util.c,v 1.144 2007/12/05 03:46:34 lukem Exp $ */ /*- * Copyright (c) 1997-2007 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ #include #ifndef lint -__RCSID("$NetBSD: util.c,v 1.143 2007/05/24 05:05:19 lukem Exp $"); +__RCSID("$NetBSD: util.c,v 1.144 2007/12/05 03:46:34 lukem Exp $"); #endif /* not lint */ /* @@ -391,8 +391,7 @@ ftp_login(const char *host, const char *luser, const char *lpass) pass = ftp_strdup(lpass); DPRINTF("ftp_login: user `%s' pass `%s' host `%s'\n", - user ? user : "", pass ? pass : "", - host ? host : ""); + STRorNULL(user), STRorNULL(pass), STRorNULL(host)); /* * Set up arguments for an anonymous FTP session, if necessary. @@ -763,7 +762,8 @@ remotemodtime(const char *file, int noisy) else goto cleanup_parse_time; } else - DPRINTF("parsed date `%s' as " LLF ", %s", + DPRINTF("remotemodtime: parsed date `%s' as " LLF + ", %s", timestr, (LLT)rtime, rfc2822time(localtime(&rtime))); } else { @@ -805,7 +805,7 @@ updatelocalcwd(void) if (getcwd(localcwd, sizeof(localcwd)) == NULL) localcwd[0] = '\0'; - DPRINTF("got localcwd as `%s'\n", localcwd); + DPRINTF("updatelocalcwd: got `%s'\n", localcwd); } /* @@ -837,7 +837,7 @@ updateremotecwd(void) remotecwd[i] = *cp; } remotecwd[i] = '\0'; - DPRINTF("got remotecwd as `%s'\n", remotecwd); + DPRINTF("updateremotecwd: got `%s'\n", remotecwd); goto cleanupremotecwd; badremotecwd: remotecwd[0]='\0'; diff --git a/contrib/tnftp/version.h b/contrib/tnftp/version.h index e42140f9f0..82f8de4a24 100644 --- a/contrib/tnftp/version.h +++ b/contrib/tnftp/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.70 2007/08/22 06:51:41 lukem Exp $ */ +/* $NetBSD: version.h,v 1.72 2008/01/21 10:31:28 lukem Exp $ */ /*- * Copyright (c) 1999-2007 The NetBSD Foundation, Inc. * All rights reserved. @@ -40,5 +40,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20070822" +#define FTP_VERSION "20080121" #endif