git-svn: trunk@2624
Tomasz Kojm authored on 2007/01/15 04:37:47... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Sun Jan 14 20:34:07 CET 2007 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * freshclam/manager.c: better handling of scripted updates (bb#129) |
|
4 |
+ |
|
1 | 5 |
Sun Jan 14 14:23:44 CET 2007 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* libclamav/scanners.c: cli_scanhtml: don't normalise files larger than 10 MB |
... | ... |
@@ -178,7 +178,7 @@ static int wwwconnect(const char *server, const char *proxy, int pport, char *ip |
178 | 178 |
herr = "Unknown error"; |
179 | 179 |
break; |
180 | 180 |
} |
181 |
- logg("^Can't get information about %s: %s\n", hostpt, herr); |
|
181 |
+ logg("!Can't get information about %s: %s\n", hostpt, herr); |
|
182 | 182 |
close(socketfd); |
183 | 183 |
return -1; |
184 | 184 |
} |
... | ... |
@@ -803,9 +803,9 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
803 | 803 |
{ |
804 | 804 |
struct cl_cvd *current, *remote; |
805 | 805 |
struct cfgstruct *cpt; |
806 |
- unsigned int nodb = 0, currver = 0, newver = 0, port = 0, ims = 0, i; |
|
806 |
+ unsigned int nodb = 0, currver = 0, newver = 0, port = 0, ims = 0, i, j; |
|
807 | 807 |
int ret; |
808 |
- char *pt, dbfile[32], dbinc[32]; |
|
808 |
+ char *pt, dbfile[32], dbinc[32], *bacinc = NULL; |
|
809 | 809 |
const char *proxy = NULL, *user = NULL, *pass = NULL, *uas = NULL; |
810 | 810 |
unsigned int flevel = cl_retflevel(), inc; |
811 | 811 |
struct stat sb; |
... | ... |
@@ -961,28 +961,55 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
961 | 961 |
} else { |
962 | 962 |
ret = 0; |
963 | 963 |
|
964 |
+ if(!access(dbinc, X_OK)) { |
|
965 |
+ if((bacinc = cli_gentemp("."))) { |
|
966 |
+ if(dircopy(dbinc, bacinc) == -1) { |
|
967 |
+ free(bacinc); |
|
968 |
+ bacinc = NULL; |
|
969 |
+ } |
|
970 |
+ } |
|
971 |
+ } |
|
972 |
+ |
|
964 | 973 |
for(i = currver + 1; i <= newver; i++) { |
965 |
- /* |
|
966 |
- * !!! FIXME !!!: Redesign this code to make more than one attempt |
|
967 |
- * to download a single cdiff. |
|
968 |
- */ |
|
969 |
- ret = getpatch(dbname, i, hostname, ip, localip, proxy, port, user, pass, uas, ctimeout, rtimeout, mdat); |
|
970 |
- if(ret) { |
|
971 |
- logg("^Removing incremental directory %s\n", dbinc); |
|
972 |
- rmdirs(dbinc); |
|
973 |
- break; |
|
974 |
+ for(j = 0; j < cfgopt(copt, "MaxAttempts")->numarg; j++) { |
|
975 |
+ ret = getpatch(dbname, i, hostname, ip, localip, proxy, port, user, pass, uas, ctimeout, rtimeout, mdat); |
|
976 |
+ if(ret == 52 || ret == 58) { |
|
977 |
+ memset(ip, 0, 16); |
|
978 |
+ continue; |
|
979 |
+ } else { |
|
980 |
+ break; |
|
981 |
+ } |
|
974 | 982 |
} |
983 |
+ if(ret) |
|
984 |
+ break; |
|
975 | 985 |
} |
976 | 986 |
|
977 | 987 |
if(ret) { |
978 |
- logg("^Incremental update failed, downloading complete database\n"); |
|
988 |
+ logg("^Incremental update failed, trying to download %s\n", dbfile); |
|
979 | 989 |
|
980 | 990 |
ret = getcvd(dbfile, hostname, ip, localip, proxy, port, user, pass, uas, 1, newver, ctimeout, rtimeout, mdat); |
981 |
- if(ret) |
|
991 |
+ if(ret) { |
|
992 |
+ if(bacinc) { |
|
993 |
+ logg("*Restoring incremental directory %s from backup\n", dbinc); |
|
994 |
+ rmdirs(dbinc); |
|
995 |
+ rename(bacinc, dbinc); |
|
996 |
+ free(bacinc); |
|
997 |
+ } |
|
982 | 998 |
return ret; |
999 |
+ } else { |
|
1000 |
+ logg("*Removing incremental directory %s\n", dbinc); |
|
1001 |
+ rmdirs(dbinc); |
|
1002 |
+ } |
|
1003 |
+ |
|
983 | 1004 |
} else { |
984 | 1005 |
unlink(dbfile); |
985 | 1006 |
} |
1007 |
+ |
|
1008 |
+ if(bacinc) { |
|
1009 |
+ logg("*Removing backup directory %s\n", bacinc); |
|
1010 |
+ rmdirs(bacinc); |
|
1011 |
+ free(bacinc); |
|
1012 |
+ } |
|
986 | 1013 |
} |
987 | 1014 |
|
988 | 1015 |
if(!(current = currentdb(dbname, &inc))) { |