diff options
author | ache <ache@FreeBSD.org> | 1997-08-05 20:18:39 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-08-05 20:18:39 +0000 |
commit | fbd1e32f9160ae4d4343706bf63cb07a2452250c (patch) | |
tree | 296ba1ca95bbef22a77abfbcdbb6c46fded9a911 | |
parent | ee162dd22f64c7b9653b65be570f0a70fc2607bd (diff) | |
download | FreeBSD-src-fbd1e32f9160ae4d4343706bf63cb07a2452250c.zip FreeBSD-src-fbd1e32f9160ae4d4343706bf63cb07a2452250c.tar.gz |
Add -t option which turns T/TCP off as workaround for some broken servers
Submitted by: Marc Slemko <marcs@znep.com>
-rw-r--r-- | usr.bin/fetch/fetch.1 | 6 | ||||
-rw-r--r-- | usr.bin/fetch/fetch.h | 3 | ||||
-rw-r--r-- | usr.bin/fetch/http.c | 16 | ||||
-rw-r--r-- | usr.bin/fetch/main.c | 8 |
4 files changed, 28 insertions, 5 deletions
diff --git a/usr.bin/fetch/fetch.1 b/usr.bin/fetch/fetch.1 index 8fe3e0b5..323128a 100644 --- a/usr.bin/fetch/fetch.1 +++ b/usr.bin/fetch/fetch.1 @@ -1,4 +1,4 @@ -.\" $Id: fetch.1,v 1.17 1997/03/05 18:57:15 fenner Exp $ +.\" $Id: fetch.1,v 1.18 1997/07/25 19:35:41 wollman Exp $ .Dd July 2, 1996 .Dt FETCH 1 .Os FreeBSD 2.2 @@ -99,6 +99,10 @@ The filenames specified are ``precious'', and should not be deleted under any circumstances, even if the transfer failed or was incomplete. .It Fl r Restart a previously interrupted transfer. +.It Fl t +Ensure that the use of T/TCP is not attempted for connections. This is +used to workaround bugs in some remote OS stacks that give improper +replies to T/TCP connections. .It Fl T Ar seconds Set timeout value to .Ar seconds. diff --git a/usr.bin/fetch/fetch.h b/usr.bin/fetch/fetch.h index d885b23..dc265be 100644 --- a/usr.bin/fetch/fetch.h +++ b/usr.bin/fetch/fetch.h @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: fetch.h,v 1.3 1997/02/05 19:59:10 wollman Exp $ + * $Id: fetch.h,v 1.4 1997/07/25 19:35:42 wollman Exp $ */ #ifndef fetch_h @@ -50,6 +50,7 @@ struct fetch_state { int fs_precious; /* -R option */ int fs_auto_retry; /* -a option */ int fs_linux_bug; /* -b option */ + int fs_use_connect; /* -t option */ time_t fs_modtime; void *fs_proto; int (*fs_retrieve)(struct fetch_state *); diff --git a/usr.bin/fetch/http.c b/usr.bin/fetch/http.c index 6f4211d..fcb221c 100644 --- a/usr.bin/fetch/http.c +++ b/usr.bin/fetch/http.c @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: http.c,v 1.9 1997/07/26 20:00:05 wollman Exp $ + * $Id: http.c,v 1.10 1997/07/26 20:18:43 wollman Exp $ */ #include <sys/types.h> @@ -581,6 +581,20 @@ retry: fs->fs_status = "sending request message"; setup_sigalrm(); alarm(timo); + + /* some hosts do not properly handle T/TCP connections. If + * sendmsg() is used to establish the connection, the OS may + * choose to try to use one which could cause the transfer + * to fail. Doing a connect() first ensures that the OS + * does not attempt T/TCP. + */ + if (fs->fs_use_connect && (connect(s, (struct sockaddr *)&sin, + sizeof(struct sockaddr_in)) < 0)) { + warn("connect: %s", https->http_hostname); + fclose(remote); + return EX_OSERR; + } + if (sendmsg(s, &msg, fs->fs_linux_bug ? 0 : MSG_EOF) < 0) { warn("sendmsg: %s", https->http_hostname); fclose(remote); diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c index a45486e..c584065 100644 --- a/usr.bin/fetch/main.c +++ b/usr.bin/fetch/main.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -/* $Id: main.c,v 1.40 1997/07/02 06:28:32 charnier Exp $ */ +/* $Id: main.c,v 1.41 1997/07/25 19:35:44 wollman Exp $ */ #include <sys/types.h> @@ -73,7 +73,7 @@ main(int argc, char *const *argv) fs.fs_verbose = 1; change_to_dir = file_to_get = hostname = 0; - while ((c = getopt(argc, argv, "abc:D:f:h:HilLmMnNo:pPqRrT:vV:")) != -1) { + while ((c = getopt(argc, argv, "abc:D:f:h:HilLmMnNo:pPqRrtT:vV:")) != -1) { switch (c) { case 'D': case 'H': case 'I': case 'N': case 'L': case 'V': break; /* ncftp compatibility */ @@ -130,6 +130,10 @@ main(int argc, char *const *argv) fs.fs_precious = 1; break; + case 't': + fs.fs_use_connect = 1; + break; + case 'T': /* strtol sets errno to ERANGE in the case of overflow */ errno = 0; |