...
|
...
|
@@ -815,7 +815,7 @@ static int Rfc2822DateTime(char *buf, time_t mtime)
|
815
|
815
|
return strftime(buf, 36, "%a, %d %b %Y %X GMT", gmt);
|
816
|
816
|
}
|
817
|
817
|
|
818
|
|
-static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, char *ip, const char *localip, const char *proxy, int port, const char *user, const char *pass, const char *uas, int *ims, int ctimeout, int rtimeout, struct mirdat *mdat, int logerr, unsigned int can_whitelist)
|
|
818
|
+static struct cl_cvd *remote_cvdhead(const char *cvdfile, const char *localfile, const char *hostname, char *ip, const char *localip, const char *proxy, int port, const char *user, const char *pass, const char *uas, int *ims, int ctimeout, int rtimeout, struct mirdat *mdat, int logerr, unsigned int can_whitelist)
|
819
|
819
|
{
|
820
|
820
|
char cmd[512], head[513], buffer[FILEBUFF], ipaddr[46], *ch, *tmp;
|
821
|
821
|
int bread, cnt, sd;
|
...
|
...
|
@@ -823,7 +823,6 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha
|
823
|
823
|
char *remotename = NULL, *authorization = NULL;
|
824
|
824
|
struct cl_cvd *cvd;
|
825
|
825
|
char last_modified[36], uastr[128];
|
826
|
|
- struct stat sb;
|
827
|
826
|
|
828
|
827
|
|
829
|
828
|
if(proxy) {
|
...
|
...
|
@@ -843,8 +842,16 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha
|
843
|
843
|
}
|
844
|
844
|
}
|
845
|
845
|
|
846
|
|
- if(stat(file, &sb) != -1 && sb.st_mtime < time(NULL)) {
|
847
|
|
- Rfc2822DateTime(last_modified, sb.st_mtime);
|
|
846
|
+ if(!access(localfile, R_OK)) {
|
|
847
|
+ cvd = cl_cvdhead(localfile);
|
|
848
|
+ if(!cvd) {
|
|
849
|
+ logg("!remote_cvdhead: Can't parse file %s\n", localfile);
|
|
850
|
+ free(remotename);
|
|
851
|
+ free(authorization);
|
|
852
|
+ return NULL;
|
|
853
|
+ }
|
|
854
|
+ Rfc2822DateTime(last_modified, (time_t) cvd->stime);
|
|
855
|
+ cl_cvdfree(cvd);
|
848
|
856
|
} else {
|
849
|
857
|
time_t mtime = 1104119530;
|
850
|
858
|
|
...
|
...
|
@@ -854,7 +861,7 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha
|
854
|
854
|
|
855
|
855
|
logg("*If-Modified-Since: %s\n", last_modified);
|
856
|
856
|
|
857
|
|
- logg("Reading CVD header (%s): ", file);
|
|
857
|
+ logg("Reading CVD header (%s): ", cvdfile);
|
858
|
858
|
|
859
|
859
|
if(uas)
|
860
|
860
|
strncpy(uastr, uas, sizeof(uastr));
|
...
|
...
|
@@ -869,7 +876,7 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha
|
869
|
869
|
"Connection: close\r\n"
|
870
|
870
|
"Range: bytes=0-511\r\n"
|
871
|
871
|
"If-Modified-Since: %s\r\n"
|
872
|
|
- "\r\n", (remotename != NULL) ? remotename : "", file, hostname, (authorization != NULL) ? authorization : "", uastr, last_modified);
|
|
872
|
+ "\r\n", (remotename != NULL) ? remotename : "", cvdfile, hostname, (authorization != NULL) ? authorization : "", uastr, last_modified);
|
873
|
873
|
|
874
|
874
|
free(remotename);
|
875
|
875
|
free(authorization);
|
...
|
...
|
@@ -885,7 +892,7 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha
|
885
|
885
|
return NULL;
|
886
|
886
|
} else {
|
887
|
887
|
logg("*Connected to %s (IP: %s).\n", hostname, ipaddr);
|
888
|
|
- logg("*Trying to retrieve CVD header of http://%s/%s\n", hostname, file);
|
|
888
|
+ logg("*Trying to retrieve CVD header of http://%s/%s\n", hostname, cvdfile);
|
889
|
889
|
}
|
890
|
890
|
|
891
|
891
|
if(!ip[0])
|
...
|
...
|
@@ -1538,7 +1545,7 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig
|
1538
|
1538
|
|
1539
|
1539
|
if(!nodb && !newver) {
|
1540
|
1540
|
|
1541
|
|
- remote = remote_cvdhead(cvdfile, hostname, ip, localip, proxy, port, user, pass, uas, &ims, ctimeout, rtimeout, mdat, logerr, can_whitelist);
|
|
1541
|
+ remote = remote_cvdhead(cvdfile, localname, hostname, ip, localip, proxy, port, user, pass, uas, &ims, ctimeout, rtimeout, mdat, logerr, can_whitelist);
|
1542
|
1542
|
|
1543
|
1543
|
if(!nodb && !ims) {
|
1544
|
1544
|
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);
|