git-svn: trunk@89
Tomasz Kojm authored on 2003/10/28 06:17:16... | ... |
@@ -45,5 +45,6 @@ Andreas Piesk <Andreas.Piesk@heise.de> |
45 | 45 |
Ant La Porte <ant@dvere.net> |
46 | 46 |
Thomas Quinot <thomas@cuivre.fr.eu.org> |
47 | 47 |
Gernot Tenchio <g.tenchio@telco-tech.de> |
48 |
+Laurent Wacrenier <lwa@teaser.fr> |
|
48 | 49 |
David Woakes <david@mitredata.co.uk> |
49 | 50 |
Andoni Zubimendi <andoni@lpsat.net> |
... | ... |
@@ -1,12 +1,19 @@ |
1 |
+Mon Oct 27 22:08:53 CET 2003 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * freshclam: fixed a segmentation fault (thanks to Graham Murray); only |
|
4 |
+ use a one mirror for a full update; display IP addresses |
|
5 |
+ * clamd: use SO_REUSEADDR in tcpserver (Laurent Wacrenier) |
|
6 |
+ * configure: set $sysconfdir with respect to --prefix (thanks NERvOus) |
|
7 |
+ |
|
1 | 8 |
Sun Oct 26 06:26:14 CET 2003 (tk) |
9 |
+--------------------------------- |
|
2 | 10 |
* clamd: report file errors with CONTSCAN (suggested by Daniel Fraga) |
3 | 11 |
* libclamav: cvd and general cleanups |
4 | 12 |
* freshclam: rewritten to use cvd, cleanups; --debug added |
5 | 13 |
* mirrors.txt: only use database.clamav.net |
6 | 14 |
|
7 | 15 |
Fri Oct 24 02:19:54 CEST 2003 (tk) |
16 |
+--------------------------------- |
|
8 | 17 |
* clamd: initialize the virus-number variable (Igor Brezac) |
9 | 18 |
* sigtool: fixed compilation issue on Solaris (bug reported by |
10 | 19 |
Christopher X. Candreva) |
... | ... |
@@ -37,11 +37,13 @@ int tcpserver(const struct optstruct *opt, const struct cfgstruct *copt, struct |
37 | 37 |
struct cfgstruct *cpt; |
38 | 38 |
struct cfgstruct *taddr; |
39 | 39 |
char *estr; |
40 |
+ int true = 1; |
|
40 | 41 |
|
41 | 42 |
memset((char *) &server, 0, sizeof(server)); |
42 | 43 |
server.sin_family = AF_INET; |
43 | 44 |
server.sin_port = htons(cfgopt(copt, "TCPSocket")->numarg); |
44 | 45 |
|
46 |
+ |
|
45 | 47 |
if (taddr = cfgopt(copt, "TCPAddr")) |
46 | 48 |
{ |
47 | 49 |
server.sin_addr.s_addr = inet_addr( taddr->strarg ); |
... | ... |
@@ -58,6 +60,10 @@ int tcpserver(const struct optstruct *opt, const struct cfgstruct *copt, struct |
58 | 58 |
exit(1); |
59 | 59 |
} |
60 | 60 |
|
61 |
+ if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void *) &true, sizeof(true)) == -1) { |
|
62 |
+ logg("!setsocktopt(SO_REUSEADDR) error: %s\n", strerror(errno)); |
|
63 |
+ } |
|
64 |
+ |
|
61 | 65 |
if(bind(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_in)) == -1) { |
62 | 66 |
estr = strerror(errno); |
63 | 67 |
//fprintf(stderr, "ERROR: can't bind(): %s\n", estr); |
... | ... |
@@ -9065,8 +9065,14 @@ DBDIR="$db_dir" |
9065 | 9065 |
|
9066 | 9066 |
# config file |
9067 | 9067 |
cfg_dir=`echo $sysconfdir | grep prefix` |
9068 |
+ |
|
9068 | 9069 |
if test -n "$cfg_dir"; then |
9069 |
- cfg_dir="$ac_default_prefix/etc" |
|
9070 |
+ if test "$prefix" = "NONE" |
|
9071 |
+ then |
|
9072 |
+ cfg_dir="$ac_default_prefix/etc" |
|
9073 |
+ else |
|
9074 |
+ cfg_dir="$prefix/etc" |
|
9075 |
+ fi |
|
9070 | 9076 |
else |
9071 | 9077 |
cfg_dir="$sysconfdir" |
9072 | 9078 |
fi |
... | ... |
@@ -176,8 +176,14 @@ AC_SUBST(DBDIR) |
176 | 176 |
|
177 | 177 |
# config file |
178 | 178 |
cfg_dir=`echo $sysconfdir | grep prefix` |
179 |
+ |
|
179 | 180 |
if test -n "$cfg_dir"; then |
180 |
- cfg_dir="$ac_default_prefix/etc" |
|
181 |
+ if test "$prefix" = "NONE" |
|
182 |
+ then |
|
183 |
+ cfg_dir="$ac_default_prefix/etc" |
|
184 |
+ else |
|
185 |
+ cfg_dir="$prefix/etc" |
|
186 |
+ fi |
|
181 | 187 |
else |
182 | 188 |
cfg_dir="$sysconfdir" |
183 | 189 |
fi |
... | ... |
@@ -46,6 +46,7 @@ int downloadmanager(const struct optstruct *opt, const char *hostname) |
46 | 46 |
{ |
47 | 47 |
time_t currtime; |
48 | 48 |
int ret, updated = 0, signo = 0; |
49 |
+ char ipaddr[16]; |
|
49 | 50 |
|
50 | 51 |
|
51 | 52 |
time(&currtime); |
... | ... |
@@ -57,19 +58,19 @@ int downloadmanager(const struct optstruct *opt, const char *hostname) |
57 | 57 |
logg("SECURITY WARNING: NO SUPPORT FOR DIGITAL SIGNATURES\n"); |
58 | 58 |
#endif |
59 | 59 |
|
60 |
- if((ret = downloaddb(DB1NAME, "main.cvd", hostname, &signo, opt)) > 50) |
|
60 |
+ if((ret = downloaddb(DB1NAME, "main.cvd", hostname, ipaddr, &signo, opt)) > 50) |
|
61 | 61 |
return ret; |
62 | 62 |
else if(ret == 0) |
63 | 63 |
updated = 1; |
64 | 64 |
|
65 |
- if((ret = downloaddb(DB2NAME, "daily.cvd", hostname, &signo, opt)) > 50) |
|
65 |
+ if((ret = downloaddb(DB2NAME, "daily.cvd", ipaddr, NULL, &signo, opt)) > 50) |
|
66 | 66 |
return ret; |
67 | 67 |
else if(ret == 0) |
68 | 68 |
updated = 1; |
69 | 69 |
|
70 | 70 |
if(updated) { |
71 |
- mprintf("Database updated (%d signatures) from %s.\n", signo, hostname); |
|
72 |
- logg("Database updated (%d signatures) from %s.\n", signo, hostname); |
|
71 |
+ mprintf("Database updated (%d signatures) from %s (%s).\n", signo, hostname, ipaddr); |
|
72 |
+ logg("Database updated (%d signatures) from %s (%s).\n", signo, hostname, ipaddr); |
|
73 | 73 |
|
74 | 74 |
#ifdef BUILD_CLAMD |
75 | 75 |
if(optl(opt, "daemon-notify")) { |
... | ... |
@@ -90,11 +91,11 @@ int downloadmanager(const struct optstruct *opt, const char *hostname) |
90 | 90 |
return 1; |
91 | 91 |
} |
92 | 92 |
|
93 |
-int downloaddb(const char *localname, const char *remotename, const char *hostname, int *signo, const struct optstruct *opt) |
|
93 |
+int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct optstruct *opt) |
|
94 | 94 |
{ |
95 | 95 |
struct cl_cvd *current, *remote; |
96 | 96 |
int hostfd, nodb = 0, ret; |
97 |
- char *tempname; |
|
97 |
+ char *tempname, ipaddr[16]; |
|
98 | 98 |
const char *proxy, *user; |
99 | 99 |
|
100 | 100 |
|
... | ... |
@@ -133,22 +134,24 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
133 | 133 |
if(proxy) |
134 | 134 |
mprintf("Connecting via %s\n", proxy); |
135 | 135 |
|
136 |
- hostfd = wwwconnect(hostname, proxy); |
|
136 |
+ hostfd = wwwconnect(hostname, proxy, ipaddr); |
|
137 | 137 |
|
138 | 138 |
if(hostfd < 0) { |
139 |
- mprintf("@Connection with %s failed.\n", hostname); |
|
139 |
+ mprintf("@Connection with %s (%s) failed.\n", hostname, ipaddr); |
|
140 | 140 |
return 52; |
141 | 141 |
} else |
142 |
- mprintf("*Connected to %s.\n", hostname); |
|
142 |
+ mprintf("*Connected to %s (%s).\n", hostname, ipaddr); |
|
143 | 143 |
|
144 |
+ if(ip) |
|
145 |
+ strcpy(ip, ipaddr); |
|
144 | 146 |
|
145 | 147 |
if(!(remote = remote_cvdhead(remotename, hostfd, hostname, proxy, user))) { |
146 |
- mprintf("@Can't read %s header from %s\n", remotename, hostname); |
|
148 |
+ mprintf("@Can't read %s header from %s (%s)\n", remotename, hostname, ipaddr); |
|
147 | 149 |
close(hostfd); |
148 | 150 |
return 52; |
149 | 151 |
} |
150 | 152 |
|
151 |
- *signo += current->sigs; /* we need to do it just here */ |
|
153 |
+ *signo += remote->sigs; /* we need to do it just here */ |
|
152 | 154 |
|
153 | 155 |
if(current && (current->version >= remote->version)) { |
154 | 156 |
mprintf("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
... | ... |
@@ -164,16 +167,18 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
164 | 164 |
|
165 | 165 |
cl_cvdfree(remote); |
166 | 166 |
|
167 |
- /* FIXME: We need to reconnect, because we won't be able to donwload |
|
167 |
+ /* FIXME: We need to reconnect, because we may not be able to download |
|
168 | 168 |
* the database. The problem doesn't exist with my local apache. |
169 | 169 |
* Some code change is needed in get_md5_checksum(). |
170 | 170 |
*/ |
171 | 171 |
/* begin bug work-around */ |
172 | 172 |
close(hostfd); |
173 |
- hostfd = wwwconnect(hostname, proxy); |
|
173 |
+ hostfd = wwwconnect(ipaddr, proxy, NULL); /* we use ipaddr to connect |
|
174 |
+ * to the same mirror |
|
175 |
+ */ |
|
174 | 176 |
|
175 | 177 |
if(hostfd < 0) { |
176 |
- mprintf("@Connection with %s failed.\n", hostname); |
|
178 |
+ mprintf("@Connection with %s failed.\n", ipaddr); |
|
177 | 179 |
return 52; |
178 | 180 |
}; |
179 | 181 |
/* end */ |
... | ... |
@@ -184,7 +189,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
184 | 184 |
tempname = cl_gentemp("."); |
185 | 185 |
|
186 | 186 |
if(get_database(remotename, hostfd, tempname, hostname, proxy, user)) { |
187 |
- mprintf("@Can't download %s from %s\n", remotename, hostname); |
|
187 |
+ mprintf("@Can't download %s from %s\n", remotename, ipaddr); |
|
188 | 188 |
unlink(tempname); |
189 | 189 |
free(tempname); |
190 | 190 |
close(hostfd); |
... | ... |
@@ -223,16 +228,19 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
223 | 223 |
|
224 | 224 |
/* this function returns socket descriptor */ |
225 | 225 |
/* proxy support finshed by njh@bandsman.co.uk */ |
226 |
-int |
|
227 |
-wwwconnect(const char *server, const char *proxy) |
|
226 |
+int wwwconnect(const char *server, const char *proxy, char *ip) |
|
228 | 227 |
{ |
229 | 228 |
int socketfd, port; |
230 | 229 |
struct sockaddr_in name; |
231 | 230 |
struct hostent *host; |
232 |
- char *portpt, *proxycpy = NULL; |
|
231 |
+ char *portpt, *proxycpy = NULL, ipaddr[16]; |
|
232 |
+ unsigned char *ia; |
|
233 | 233 |
const char *hostpt; |
234 | 234 |
|
235 | 235 |
|
236 |
+ if(ip) |
|
237 |
+ strcpy(ip, "???"); |
|
238 |
+ |
|
236 | 239 |
/* njh@bandsman.co.uk: for BEOS */ |
237 | 240 |
#ifdef PF_INET |
238 | 241 |
socketfd = socket(PF_INET, SOCK_STREAM, 0); |
... | ... |
@@ -275,11 +283,18 @@ wwwconnect(const char *server, const char *proxy) |
275 | 275 |
return -1; |
276 | 276 |
} |
277 | 277 |
|
278 |
+ /* this dirty hack comes from pink - Nosuid TCP/IP ping 1.6 */ |
|
279 |
+ ia = (unsigned char *) host->h_addr; |
|
280 |
+ sprintf(ipaddr, "%u.%u.%u.%u", ia[0], ia[1], ia[2], ia[3]); |
|
281 |
+ |
|
282 |
+ if(ip) |
|
283 |
+ strcpy(ip, ipaddr); |
|
284 |
+ |
|
278 | 285 |
name.sin_addr = *((struct in_addr *) host->h_addr); |
279 | 286 |
name.sin_port = htons(port); |
280 | 287 |
|
281 | 288 |
if(connect(socketfd, (struct sockaddr *) &name, sizeof(struct sockaddr_in)) == -1) { |
282 |
- mprintf("@Can't connect to port %d of host %s\n", port, hostpt); |
|
289 |
+ mprintf("@Can't connect to port %d of host %s (IP: %s)\n", port, hostpt, ipaddr); |
|
283 | 290 |
close(socketfd); |
284 | 291 |
if(proxycpy) |
285 | 292 |
free(proxycpy); |
... | ... |
@@ -24,9 +24,9 @@ |
24 | 24 |
|
25 | 25 |
int downloadmanager(const struct optstruct *opt, const char *hostname); |
26 | 26 |
|
27 |
-int downloaddb(const char *localname, const char *remotename, const char *hostname, int *signo, const struct optstruct *opt); |
|
27 |
+int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct optstruct *opt); |
|
28 | 28 |
|
29 |
-int wwwconnect(const char *server, const char *proxy); |
|
29 |
+int wwwconnect(const char *server, const char *proxy, char *ip); |
|
30 | 30 |
|
31 | 31 |
struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostname, const char *proxy, const char *user); |
32 | 32 |
|