git-svn: trunk@1832
Tomasz Kojm authored on 2006/01/28 00:04:55... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Fri Jan 27 16:01:31 CET 2006 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * freshclam: new option HTTPUserAgent to force different User-Agent header |
|
4 |
+ Patch by Andy Fiddaman <clam*fiddaman.net> |
|
5 |
+ |
|
1 | 6 |
Wed Jan 25 13:09:19 CET 2006 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* libclamav: add support for signature based self-protection mode |
... | ... |
@@ -92,6 +92,11 @@ Proxy usage is authenticated through given username and password. |
92 | 92 |
.br . |
93 | 93 |
Default: no proxy authentication |
94 | 94 |
.TP |
95 |
+\fBHTTPUserAgent STRING\fR |
|
96 |
+If your servers are behind a firewall/proxy which applies User-Agent filtering, you can use this option to force the use of a different User-Agent header. |
|
97 |
+.br . |
|
98 |
+Default: clamav/version_number |
|
99 |
+.TP |
|
95 | 100 |
\fBLocalIPAddress IP\fR |
96 | 101 |
Use \fBIP\fR as client address for downloading databases. Useful for multi homed systems. |
97 | 102 |
.br . |
... | ... |
@@ -76,6 +76,12 @@ DatabaseMirror database.clamav.net |
76 | 76 |
#HTTPProxyUsername myusername |
77 | 77 |
#HTTPProxyPassword mypass |
78 | 78 |
|
79 |
+# If your servers are behind a firewall/proxy which applies User-Agent |
|
80 |
+# filtering you can use this option to force the use of a different |
|
81 |
+# User-Agent header. |
|
82 |
+# Default: clamav/version_number |
|
83 |
+#HTTPUserAgent SomeUserAgentIdString |
|
84 |
+ |
|
79 | 85 |
# Use aaa.bbb.ccc.ddd as client address for downloading databases. Useful for |
80 | 86 |
# multi-homed systems. |
81 | 87 |
# Default: Use OS'es default outgoing IP address. |
... | ... |
@@ -245,7 +245,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
245 | 245 |
struct cfgstruct *cpt; |
246 | 246 |
int hostfd, nodb = 0, dbver = -1, ret, port = 0, ims = -1; |
247 | 247 |
char *tempname, ipaddr[16], *pt; |
248 |
- const char *proxy = NULL, *user = NULL, *pass = NULL; |
|
248 |
+ const char *proxy = NULL, *user = NULL, *pass = NULL, *uas = NULL; |
|
249 | 249 |
int flevel = cl_retflevel(); |
250 | 250 |
|
251 | 251 |
|
... | ... |
@@ -301,6 +301,9 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
301 | 301 |
logg("Connecting via %s\n", proxy); |
302 | 302 |
} |
303 | 303 |
|
304 |
+ if((cpt = cfgopt(copt, "HTTPUserAgent"))->enabled) |
|
305 |
+ uas = cpt->strarg; |
|
306 |
+ |
|
304 | 307 |
memset(ipaddr, 0, sizeof(ipaddr)); |
305 | 308 |
|
306 | 309 |
if(!nodb && dbver == -1) { |
... | ... |
@@ -321,7 +324,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
321 | 321 |
if(!ip[0]) |
322 | 322 |
strcpy(ip, ipaddr); |
323 | 323 |
|
324 |
- remote = remote_cvdhead(remotename, hostfd, hostname, proxy, user, pass, &ims); |
|
324 |
+ remote = remote_cvdhead(remotename, hostfd, hostname, proxy, user, pass, uas, &ims); |
|
325 | 325 |
|
326 | 326 |
if(!nodb && !ims) { |
327 | 327 |
logg("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
... | ... |
@@ -596,11 +599,12 @@ static int Rfc2822DateTime(char *buf, time_t mtime) |
596 | 596 |
return strftime(buf, 36, "%a, %d %b %Y %X GMT", time); |
597 | 597 |
} |
598 | 598 |
|
599 |
-struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostname, const char *proxy, const char *user, const char *pass, int *ims) |
|
599 |
+struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostname, const char *proxy, const char *user, const char *pass, const char *uas, int *ims) |
|
600 | 600 |
{ |
601 | 601 |
char cmd[512], head[513], buffer[FILEBUFF], *ch, *tmp; |
602 | 602 |
int i, j, bread, cnt; |
603 | 603 |
char *remotename = NULL, *authorization = NULL; |
604 |
+ const char *agent; |
|
604 | 605 |
struct cl_cvd *cvd; |
605 | 606 |
char last_modified[36]; |
606 | 607 |
struct stat sb; |
... | ... |
@@ -635,22 +639,28 @@ struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostna |
635 | 635 |
logg("*If-Modified-Since: %s\n", last_modified); |
636 | 636 |
|
637 | 637 |
logg("Reading CVD header (%s): ", file); |
638 |
+ |
|
639 |
+ if(uas) |
|
640 |
+ agent = uas; |
|
641 |
+ else |
|
642 |
+ agent = PACKAGE"/"VERSION; |
|
643 |
+ |
|
638 | 644 |
#ifdef NO_SNPRINTF |
639 | 645 |
sprintf(cmd, "GET %s/%s HTTP/1.1\r\n" |
640 | 646 |
"Host: %s\r\n%s" |
641 |
- "User-Agent: "PACKAGE"/"VERSION"\r\n" |
|
647 |
+ "User-Agent: %s\r\n" |
|
642 | 648 |
"Connection: close\r\n" |
643 | 649 |
"Range: bytes=0-511\r\n" |
644 | 650 |
"If-Modified-Since: %s\r\n" |
645 |
- "\r\n", (remotename != NULL)?remotename:"", file, hostname, (authorization != NULL)?authorization:"", last_modified); |
|
651 |
+ "\r\n", (remotename != NULL)?remotename:"", file, hostname, (authorization != NULL)?authorization:"", agent, last_modified); |
|
646 | 652 |
#else |
647 | 653 |
snprintf(cmd, sizeof(cmd), "GET %s/%s HTTP/1.1\r\n" |
648 | 654 |
"Host: %s\r\n%s" |
649 |
- "User-Agent: "PACKAGE"/"VERSION"\r\n" |
|
655 |
+ "User-Agent: %s\r\n" |
|
650 | 656 |
"Connection: close\r\n" |
651 | 657 |
"Range: bytes=0-511\r\n" |
652 | 658 |
"If-Modified-Since: %s\r\n" |
653 |
- "\r\n", (remotename != NULL)?remotename:"", file, hostname, (authorization != NULL)?authorization:"", last_modified); |
|
659 |
+ "\r\n", (remotename != NULL)?remotename:"", file, hostname, (authorization != NULL)?authorization:"", uas, last_modified); |
|
654 | 660 |
#endif |
655 | 661 |
write(socketfd, cmd, strlen(cmd)); |
656 | 662 |
|
... | ... |
@@ -28,7 +28,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
28 | 28 |
|
29 | 29 |
int wwwconnect(const char *server, const char *proxy, int pport, char *remoteip, char *localip); |
30 | 30 |
|
31 |
-struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostname, const char *proxy, const char *user, const char *pass, int *ims); |
|
31 |
+struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostname, const char *proxy, const char *user, const char *pass, const char *uas, int *ims); |
|
32 | 32 |
|
33 | 33 |
int get_database(const char *dbfile, int socketfd, const char *file, const char *hostname, const char *proxy, const char *user, const char *pass); |
34 | 34 |
|
... | ... |
@@ -110,6 +110,7 @@ struct cfgstruct *getcfg(const char *cfgfile, int verbose) |
110 | 110 |
{"HTTPProxyPort", OPT_NUM, -1, NULL, 0}, /* freshclam */ |
111 | 111 |
{"HTTPProxyUsername", OPT_STR, -1, NULL, 0}, /* freshclam */ |
112 | 112 |
{"HTTPProxyPassword", OPT_STR, -1, NULL, 0}, /* freshclam */ |
113 |
+ {"HTTPUserAgent", OPT_FULLSTR, -1, NULL, 0}, /* freshclam */ |
|
113 | 114 |
{"NotifyClamd", OPT_STR, -1, NULL, 0}, /* freshclam */ |
114 | 115 |
{"OnUpdateExecute", OPT_FULLSTR, -1, NULL, 0}, /* freshclam */ |
115 | 116 |
{"OnErrorExecute", OPT_FULLSTR, -1, NULL, 0}, /* freshclam */ |