From: Peter Avalos Date: Wed, 11 Jul 2012 07:07:04 +0000 (-0700) Subject: Merge branch 'vendor/TNFTP' X-Git-Tag: v3.2.0~617 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/a78853d5175ec736deede808ffc6c1114342c42f?hp=-c Merge branch 'vendor/TNFTP' --- a78853d5175ec736deede808ffc6c1114342c42f diff --combined contrib/tnftp/cmds.c index 0ae0a0ec9e,633ab0060f..02cf021898 --- a/contrib/tnftp/cmds.c +++ b/contrib/tnftp/cmds.c @@@ -1,4 -1,4 +1,4 @@@ - /* $NetBSD: cmds.c,v 1.132 2011/09/16 15:39:26 joerg Exp $ */ + /* $NetBSD: cmds.c,v 1.134 2012/01/15 20:43:24 christos Exp $ */ /*- * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. @@@ -96,7 -96,7 +96,7 @@@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else - __RCSID("$NetBSD: cmds.c,v 1.132 2011/09/16 15:39:26 joerg Exp $"); + __RCSID("$NetBSD: cmds.c,v 1.134 2012/01/15 20:43:24 christos Exp $"); #endif #endif /* not lint */ @@@ -111,13 -111,13 +111,14 @@@ #include #include + #include #include #include #include #include #include #include +#include #include #include #include @@@ -557,14 -557,14 +558,14 @@@ voi reget(int argc, char *argv[]) { - (void)getit(argc, argv, 1, "r+"); + (void)getit(argc, argv, 1, restart_point ? "r+" : "a"); } void get(int argc, char *argv[]) { - (void)getit(argc, argv, 0, restart_point ? "r+" : "w" ); + (void)getit(argc, argv, 0, restart_point ? "r+" : "w"); } /* @@@ -613,10 -613,14 +614,14 @@@ getit(int argc, char *argv[], int resta ret = stat(locfile, &stbuf); if (restartit == 1) { if (ret < 0) { - warn("Can't stat `%s'", locfile); - goto freegetit; + if (errno != ENOENT) { + warn("Can't stat `%s'", locfile); + goto freegetit; + } + restart_point = 0; } - restart_point = stbuf.st_size; + else + restart_point = stbuf.st_size; } else { if (ret == 0) { time_t mtime; diff --combined contrib/tnftp/fetch.c index 47575a8607,30087f894d..ac3d62f078 --- a/contrib/tnftp/fetch.c +++ b/contrib/tnftp/fetch.c @@@ -1,4 -1,4 +1,4 @@@ - /* $NetBSD: fetch.c,v 1.195 2011/12/10 05:53:58 lukem Exp $ */ + /* $NetBSD: fetch.c,v 1.198 2012/07/04 06:09:37 is Exp $ */ /*- * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. @@@ -34,7 -34,7 +34,7 @@@ #include #ifndef lint - __RCSID("$NetBSD: fetch.c,v 1.195 2011/12/10 05:53:58 lukem Exp $"); + __RCSID("$NetBSD: fetch.c,v 1.198 2012/07/04 06:09:37 is Exp $"); #endif /* not lint */ /* @@@ -59,7 -59,6 +59,7 @@@ #include #include #include +#include #include #include #include @@@ -701,7 -700,7 +701,7 @@@ fetch_url(const char *url, const char * hints.ai_protocol = 0; error = getaddrinfo(host, port, &hints, &res0); if (error) { - warnx("Can't lookup `%s:%s': %s", host, port, + warnx("Can't LOOKUP `%s:%s': %s", host, port, (error == EAI_SYSTEM) ? strerror(errno) : gai_strerror(error)); goto cleanup_fetch_url; @@@ -735,7 -734,8 +735,8 @@@ continue; } - if (ftp_connect(s, res->ai_addr, res->ai_addrlen) < 0) { + if (ftp_connect(s, res->ai_addr, res->ai_addrlen, + verbose || !res->ai_next) < 0) { close(s); s = -1; continue; @@@ -1688,6 -1688,7 +1689,7 @@@ static in go_fetch(const char *url) { char *proxyenv; + char *p; #ifndef NO_ABOUT /* @@@ -1731,6 -1732,18 +1733,18 @@@ if (STRNEQUAL(url, HTTP_URL) || STRNEQUAL(url, FILE_URL)) return (fetch_url(url, NULL, NULL, NULL)); + /* + * If it contains "://" but does not begin with ftp:// + * or something that was already handled, then it's + * unsupported. + * + * If it contains ":" but not "://" then we assume the + * part before the colon is a host name, not an URL scheme, + * so we don't try to match that here. + */ + if ((p = strstr(url, "://")) != NULL && ! STRNEQUAL(url, FTP_URL)) + errx(1, "Unsupported URL scheme `%.*s'", (int)(p - url), url); + /* * Try FTP URL-style and host:file arguments next. * If ftpproxy is set with an FTP URL, use fetch_url() diff --combined contrib/tnftp/util.c index 63fab33e00,b0e990dcff..c4d86e73bd --- a/contrib/tnftp/util.c +++ b/contrib/tnftp/util.c @@@ -1,4 -1,4 +1,4 @@@ - /* $NetBSD: util.c,v 1.156 2011/12/10 05:53:58 lukem Exp $ */ + /* $NetBSD: util.c,v 1.157 2012/07/04 06:09:37 is Exp $ */ /*- * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. @@@ -64,7 -64,7 +64,7 @@@ #include #ifndef lint - __RCSID("$NetBSD: util.c,v 1.156 2011/12/10 05:53:58 lukem Exp $"); + __RCSID("$NetBSD: util.c,v 1.157 2012/07/04 06:09:37 is Exp $"); #endif /* not lint */ /* @@@ -1351,7 -1351,7 +1351,7 @@@ get_line(FILE *stream, char *buf, size_ * error message displayed.) */ int - ftp_connect(int sock, const struct sockaddr *name, socklen_t namelen) + ftp_connect(int sock, const struct sockaddr *name, socklen_t namelen, int pe) { int flags, rv, timeout, error; socklen_t slen; @@@ -1417,8 -1417,9 +1417,9 @@@ rv = connect(sock, name, namelen); /* inititate the connection */ if (rv == -1) { /* connection error */ if (errno != EINPROGRESS) { /* error isn't "please wait" */ + if (pe || (errno != EHOSTUNREACH)) connecterror: - warn("Can't connect to `%s:%s'", hname, sname); + warn("Can't connect to `%s:%s'", hname, sname); return -1; } @@@ -1526,7 -1527,8 +1527,7 @@@ voi ftp_sl_add(StringList *sl, char *i) { - if (sl_add(sl, i) == -1) - err(1, "Unable to add `%s' to stringlist", i); + sl_add(sl, i); } /*