git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@446 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/03/28 03:45:32... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Sat Mar 27 19:55:52 CET 2004 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * freshclam: remove timeout code; clean up return codes |
|
4 |
+ * docs: freshclam.1 updated |
|
5 |
+ |
|
1 | 6 |
Fri Mar 26 23:23:21 CET 2004 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* clamdscan: don't call getcwd() in streaming mode (patch by Dale Woolridge |
... | ... |
@@ -77,16 +77,24 @@ Execute COMMAND after succesful update. |
77 | 77 |
.TP |
78 | 78 |
50: Can't change directory. |
79 | 79 |
.TP |
80 |
-51: Can't check MD5 sum of file. |
|
80 |
+51: Can't check MD5 sum. |
|
81 | 81 |
.TP |
82 | 82 |
52: Connection (network) problem. |
83 | 83 |
.TP |
84 |
-53: Can't unlink file. |
|
84 |
+53: Can't unlink a file. |
|
85 | 85 |
.TP |
86 | 86 |
54: MD5 or digital signature verification error. |
87 | 87 |
.TP |
88 | 88 |
55: Error reading file. |
89 | 89 |
.TP |
90 |
+56: Config file error. |
|
91 |
+.TP |
|
92 |
+57: Can't create a new file. |
|
93 |
+.TP |
|
94 |
+58: Can't read database from remote server. |
|
95 |
+.TP |
|
96 |
+59: Mirrors are not fully synchronized (try again later). |
|
97 |
+.TP |
|
90 | 98 |
60: Can't get information about clamav user from /etc/passwd. |
91 | 99 |
.SH "CREDITS" |
92 | 100 |
Please check the full documentation for credits. |
... | ... |
@@ -17,7 +17,6 @@ |
17 | 17 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | 18 |
*/ |
19 | 19 |
|
20 |
-/* TODO: Handle SIGALRM more gently */ |
|
21 | 20 |
|
22 | 21 |
#if HAVE_CONFIG_H |
23 | 22 |
#include "clamav-config.h" |
... | ... |
@@ -47,7 +46,6 @@ |
47 | 47 |
#include "defaults.h" |
48 | 48 |
#include "freshclam.h" |
49 | 49 |
|
50 |
-#define TIMEOUT 1200 |
|
51 | 50 |
|
52 | 51 |
static short terminate = 0; |
53 | 52 |
|
... | ... |
@@ -56,7 +54,6 @@ static void daemon_sighandler(int sig) { |
56 | 56 |
char *action = NULL; |
57 | 57 |
|
58 | 58 |
switch(sig) { |
59 |
- case SIGALRM: |
|
60 | 59 |
case SIGUSR1: |
61 | 60 |
action = "wake up"; |
62 | 61 |
terminate = -1; |
... | ... |
@@ -315,21 +312,11 @@ int freshclam(struct optstruct *opt) |
315 | 315 |
return(ret); |
316 | 316 |
} |
317 | 317 |
|
318 |
-void d_timeout(int sig) |
|
319 |
-{ |
|
320 |
- mprintf("@Maximal time (%d seconds) reached.\n", TIMEOUT); |
|
321 |
- exit(1); |
|
322 |
-} |
|
323 |
- |
|
324 | 318 |
int download(const struct cfgstruct *copt, const struct optstruct *opt) |
325 | 319 |
{ |
326 | 320 |
int ret = 0, try = 0, maxattempts = 0; |
327 |
- struct sigaction sigalrm; |
|
328 | 321 |
struct cfgstruct *cpt; |
329 | 322 |
|
330 |
- memset(&sigalrm, 0, sizeof(struct sigaction)); |
|
331 |
- sigalrm.sa_handler = d_timeout; |
|
332 |
- sigaction(SIGALRM, &sigalrm, NULL); |
|
333 | 323 |
|
334 | 324 |
if((cpt = cfgopt(copt, "MaxAttempts"))) |
335 | 325 |
maxattempts = cpt->numarg; |
... | ... |
@@ -338,11 +325,10 @@ int download(const struct cfgstruct *copt, const struct optstruct *opt) |
338 | 338 |
|
339 | 339 |
if((cpt = cfgopt(copt, "DatabaseMirror")) == NULL) { |
340 | 340 |
mprintf("@You must specify at least one database mirror.\n"); |
341 |
- return 57; |
|
341 |
+ return 56; |
|
342 | 342 |
} else { |
343 | 343 |
|
344 | 344 |
while(cpt) { |
345 |
- alarm(TIMEOUT); |
|
346 | 345 |
ret = downloadmanager(copt, opt, cpt->strarg); |
347 | 346 |
alarm(0); |
348 | 347 |
|
... | ... |
@@ -131,7 +131,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
131 | 131 |
pass = cpt->strarg; |
132 | 132 |
} else { |
133 | 133 |
mprintf("HTTPProxyUsername requires HTTPProxyPassword\n"); |
134 |
- return 57; |
|
134 |
+ return 56; |
|
135 | 135 |
} |
136 | 136 |
} |
137 | 137 |
|
... | ... |
@@ -165,7 +165,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
165 | 165 |
if(!(remote = remote_cvdhead(remotename, hostfd, hostname, proxy, user, pass))) { |
166 | 166 |
mprintf("@Can't read %s header from %s (%s)\n", remotename, hostname, ipaddr); |
167 | 167 |
close(hostfd); |
168 |
- return 52; |
|
168 |
+ return 58; |
|
169 | 169 |
} |
170 | 170 |
|
171 | 171 |
*signo += remote->sigs; /* we need to do it just here */ |
... | ... |
@@ -216,12 +216,12 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
216 | 216 |
*/ |
217 | 217 |
tempname = cl_gentemp("."); |
218 | 218 |
|
219 |
- if(get_database(remotename, hostfd, tempname, hostname, proxy, user, pass)) { |
|
219 |
+ if((ret = get_database(remotename, hostfd, tempname, hostname, proxy, user, pass))) { |
|
220 | 220 |
mprintf("@Can't download %s from %s\n", remotename, ipaddr); |
221 | 221 |
unlink(tempname); |
222 | 222 |
free(tempname); |
223 | 223 |
close(hostfd); |
224 |
- return 52; |
|
224 |
+ return ret; |
|
225 | 225 |
} |
226 | 226 |
|
227 | 227 |
close(hostfd); |
... | ... |
@@ -245,7 +245,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
245 | 245 |
cl_cvdfree(current); |
246 | 246 |
unlink(tempname); |
247 | 247 |
free(tempname); |
248 |
- return 54; |
|
248 |
+ return 59; |
|
249 | 249 |
} |
250 | 250 |
|
251 | 251 |
if(!nodb && unlink(localname)) { |
... | ... |
@@ -478,7 +478,7 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
478 | 478 |
#endif |
479 | 479 |
mprintf("@Can't open new file %s to write\n", file); |
480 | 480 |
perror("open"); |
481 |
- return -1; |
|
481 |
+ return 57; |
|
482 | 482 |
} |
483 | 483 |
|
484 | 484 |
#ifdef NO_SNPRINTF |
... | ... |
@@ -503,12 +503,12 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
503 | 503 |
|
504 | 504 |
if ((bread = recv(socketfd, buffer, FILEBUFF, 0)) == -1) { |
505 | 505 |
mprintf("@Error while reading database from %s\n", hostname); |
506 |
- return -1; |
|
506 |
+ return 52; |
|
507 | 507 |
} |
508 | 508 |
|
509 | 509 |
if ((strstr(buffer, "HTTP/1.1 404")) != NULL) { |
510 | 510 |
mprintf("@%s not found on remote server\n", dbfile); |
511 |
- return -1; |
|
511 |
+ return 58; |
|
512 | 512 |
} |
513 | 513 |
|
514 | 514 |
ch = buffer; |
... | ... |
@@ -521,14 +521,13 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
521 | 521 |
} |
522 | 522 |
ch++; |
523 | 523 |
i++; |
524 |
- } |
|
524 |
+ } |
|
525 | 525 |
|
526 | 526 |
write(fd, ch, bread - i); |
527 | 527 |
while((bread = read(socketfd, buffer, FILEBUFF))) { |
528 | 528 |
write(fd, buffer, bread); |
529 | 529 |
mprintf("Downloading %s [%c]\r", dbfile, rotation[rot]); |
530 | 530 |
fflush(stdout); |
531 |
- /* rot = ++rot % 4; -> operation on `rot' may be undefined (why ?) */ |
|
532 | 531 |
rot++; |
533 | 532 |
rot %= 4; |
534 | 533 |
} |