diff --git a/usr.bin/fetch/fetch.1 b/usr.bin/fetch/fetch.1 index 8fe3e0b561f0..323128a9b7c0 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 d885b23999a3..dc265bee4c6f 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 6f4211dcd802..fcb221c250a8 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 @@ -581,6 +581,20 @@ http_retrieve(struct fetch_state *fs) 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 a45486e71d72..c5840651dbe7 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 @@ -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;