summaryrefslogtreecommitdiff
path: root/usr.bin/ftp
diff options
context:
space:
mode:
authorHeikki Korpela <heko@cvs.openbsd.org>2001-10-27 10:31:28 +0000
committerHeikki Korpela <heko@cvs.openbsd.org>2001-10-27 10:31:28 +0000
commitb9f30a964a9df9c40b23f5dbc262449bd2695f97 (patch)
tree5bf72be99205441bd86ae161a84036d9e13f56c3 /usr.bin/ftp
parentd2d659b6ab223f98616bbc33e0f12ffc24e787d8 (diff)
Send User-Agent: OpenBSD ftp to WWW servers and proxies.
``User agents SHOULD include this field with requests'', from RFC 2616: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 Patch from and problem reported by Diana Eichert <deicher@sandia.gov> when using proxies with specific browser requirements. Tested by me with the ports mirror-maker makefile / fetch-all script (with and without a proxy). ok millert@
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r--usr.bin/ftp/fetch.c22
-rw-r--r--usr.bin/ftp/ftp_var.h3
2 files changed, 13 insertions, 12 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index b61542768ae..8bf028b56a8 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.35 2001/10/03 18:49:39 heko Exp $ */
+/* $OpenBSD: fetch.c,v 1.36 2001/10/27 10:31:27 heko Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -38,7 +38,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: fetch.c,v 1.35 2001/10/03 18:49:39 heko Exp $";
+static char rcsid[] = "$OpenBSD: fetch.c,v 1.36 2001/10/27 10:31:27 heko Exp $";
#endif /* not lint */
/*
@@ -349,7 +349,7 @@ again:
if (verbose)
fprintf(ttyout, "Requesting %s (via %s)\n",
origline, proxyenv);
- snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n", path);
+ snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n%s\r\n\r\n", path, HTTP_USER_AGENT);
} else {
if (verbose)
fprintf(ttyout, "Requesting %s\n", origline);
@@ -369,22 +369,22 @@ again:
*/
if (port && strcmp(port, "80") != 0)
snprintf(buf, sizeof(buf),
- "GET /%s HTTP/1.0\r\nHost: [%s]:%s\r\n\r\n",
- path, h, port);
+ "GET /%s HTTP/1.0\r\nHost: [%s]:%s\r\n%s\r\n\r\n",
+ path, h, port, HTTP_USER_AGENT);
else
snprintf(buf, sizeof(buf),
- "GET /%s HTTP/1.0\r\nHost: [%s]\r\n\r\n",
- path, h);
+ "GET /%s HTTP/1.0\r\nHost: [%s]\r\n%s\r\n\r\n",
+ path, h, HTTP_USER_AGENT);
free(h);
} else {
if (port && strcmp(port, "80") != 0)
snprintf(buf, sizeof(buf),
- "GET /%s HTTP/1.0\r\nHost: %s:%s\r\n\r\n",
- path, host, port);
+ "GET /%s HTTP/1.0\r\nHost: %s:%s\r\n%s\r\n\r\n",
+ path, host, port, HTTP_USER_AGENT);
else
snprintf(buf, sizeof(buf),
- "GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n",
- path, host);
+ "GET /%s HTTP/1.0\r\nHost: %s\r\n%s\r\n\r\n",
+ path, host, HTTP_USER_AGENT);
}
}
len = strlen(buf);
diff --git a/usr.bin/ftp/ftp_var.h b/usr.bin/ftp/ftp_var.h
index 5ba60d43145..ac74f4c6314 100644
--- a/usr.bin/ftp/ftp_var.h
+++ b/usr.bin/ftp/ftp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp_var.h,v 1.19 2000/06/21 19:22:54 itojun Exp $ */
+/* $OpenBSD: ftp_var.h,v 1.20 2001/10/27 10:31:27 heko Exp $ */
/* $NetBSD: ftp_var.h,v 1.18 1997/08/18 10:20:25 lukem Exp $ */
/*
@@ -91,6 +91,7 @@ int fclose(FILE *);
#define FTP_PORT 21 /* default if ! getservbyname("ftp/tcp") */
#define HTTP_PORT 80 /* default if ! getservbyname("http/tcp") */
+#define HTTP_USER_AGENT "User-Agent: OpenBSD ftp" /* User-Agent string sent to web server */
#ifndef GATE_PORT
#define GATE_PORT 21 /* default if ! getservbyname("ftpgate/tcp") */
#endif