freshclam cleanups

git-svn: trunk@446
remotes/push_mirror/metadata
Tomasz Kojm 21 years ago
parent b8cdcd2e12
commit d6a56e7033
  1. 5
      clamav-devel/ChangeLog
  2. 12
      clamav-devel/docs/man/freshclam.1
  3. 16
      clamav-devel/freshclam/freshclam.c
  4. 19
      clamav-devel/freshclam/manager.c

@ -1,3 +1,8 @@
Sat Mar 27 19:55:52 CET 2004 (tk)
---------------------------------
* freshclam: remove timeout code; clean up return codes
* docs: freshclam.1 updated
Fri Mar 26 23:23:21 CET 2004 (tk)
---------------------------------
* clamdscan: don't call getcwd() in streaming mode (patch by Dale Woolridge

@ -77,16 +77,24 @@ Execute COMMAND after succesful update.
.TP
50: Can't change directory.
.TP
51: Can't check MD5 sum of file.
51: Can't check MD5 sum.
.TP
52: Connection (network) problem.
.TP
53: Can't unlink file.
53: Can't unlink a file.
.TP
54: MD5 or digital signature verification error.
.TP
55: Error reading file.
.TP
56: Config file error.
.TP
57: Can't create a new file.
.TP
58: Can't read database from remote server.
.TP
59: Mirrors are not fully synchronized (try again later).
.TP
60: Can't get information about clamav user from /etc/passwd.
.SH "CREDITS"
Please check the full documentation for credits.

@ -17,7 +17,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* TODO: Handle SIGALRM more gently */
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -47,7 +46,6 @@
#include "defaults.h"
#include "freshclam.h"
#define TIMEOUT 1200
static short terminate = 0;
@ -56,7 +54,6 @@ static void daemon_sighandler(int sig) {
char *action = NULL;
switch(sig) {
case SIGALRM:
case SIGUSR1:
action = "wake up";
terminate = -1;
@ -315,21 +312,11 @@ int freshclam(struct optstruct *opt)
return(ret);
}
void d_timeout(int sig)
{
mprintf("@Maximal time (%d seconds) reached.\n", TIMEOUT);
exit(1);
}
int download(const struct cfgstruct *copt, const struct optstruct *opt)
{
int ret = 0, try = 0, maxattempts = 0;
struct sigaction sigalrm;
struct cfgstruct *cpt;
memset(&sigalrm, 0, sizeof(struct sigaction));
sigalrm.sa_handler = d_timeout;
sigaction(SIGALRM, &sigalrm, NULL);
if((cpt = cfgopt(copt, "MaxAttempts")))
maxattempts = cpt->numarg;
@ -338,11 +325,10 @@ int download(const struct cfgstruct *copt, const struct optstruct *opt)
if((cpt = cfgopt(copt, "DatabaseMirror")) == NULL) {
mprintf("@You must specify at least one database mirror.\n");
return 57;
return 56;
} else {
while(cpt) {
alarm(TIMEOUT);
ret = downloadmanager(copt, opt, cpt->strarg);
alarm(0);

@ -131,7 +131,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna
pass = cpt->strarg;
} else {
mprintf("HTTPProxyUsername requires HTTPProxyPassword\n");
return 57;
return 56;
}
}
@ -165,7 +165,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna
if(!(remote = remote_cvdhead(remotename, hostfd, hostname, proxy, user, pass))) {
mprintf("@Can't read %s header from %s (%s)\n", remotename, hostname, ipaddr);
close(hostfd);
return 52;
return 58;
}
*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
*/
tempname = cl_gentemp(".");
if(get_database(remotename, hostfd, tempname, hostname, proxy, user, pass)) {
if((ret = get_database(remotename, hostfd, tempname, hostname, proxy, user, pass))) {
mprintf("@Can't download %s from %s\n", remotename, ipaddr);
unlink(tempname);
free(tempname);
close(hostfd);
return 52;
return ret;
}
close(hostfd);
@ -245,7 +245,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna
cl_cvdfree(current);
unlink(tempname);
free(tempname);
return 54;
return 59;
}
if(!nodb && unlink(localname)) {
@ -478,7 +478,7 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char
#endif
mprintf("@Can't open new file %s to write\n", file);
perror("open");
return -1;
return 57;
}
#ifdef NO_SNPRINTF
@ -503,12 +503,12 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char
if ((bread = recv(socketfd, buffer, FILEBUFF, 0)) == -1) {
mprintf("@Error while reading database from %s\n", hostname);
return -1;
return 52;
}
if ((strstr(buffer, "HTTP/1.1 404")) != NULL) {
mprintf("@%s not found on remote server\n", dbfile);
return -1;
return 58;
}
ch = buffer;
@ -521,14 +521,13 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char
}
ch++;
i++;
}
}
write(fd, ch, bread - i);
while((bread = read(socketfd, buffer, FILEBUFF))) {
write(fd, buffer, bread);
mprintf("Downloading %s [%c]\r", dbfile, rotation[rot]);
fflush(stdout);
/* rot = ++rot % 4; -> operation on `rot' may be undefined (why ?) */
rot++;
rot %= 4;
}

Loading…
Cancel
Save