git-svn: trunk@1678
Tomasz Kojm authored on 2005/08/03 11:59:29... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Wed Aug 3 04:57:36 CEST 2005 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * freshclam: add new option --on-update-execute (OnUpdateExecute). Requested |
|
4 |
+ by Per Jessen |
|
5 |
+ |
|
1 | 6 |
Sat Jul 30 11:09:47 BST 2005 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav/pdf.c: Improved parsing |
... | ... |
@@ -59,6 +59,9 @@ Execute COMMAND if error occurred. Remember, that virus database freshness is th |
59 | 59 |
.TP |
60 | 60 |
\fB\-\-on\-update\-execute=COMMAND\fR |
61 | 61 |
Execute COMMAND after successful update. |
62 |
+.TP |
|
63 |
+\fB\-\-on\-outdated\-execute=COMMAND\fR |
|
64 |
+Execute COMMAND when freshclam reports outdated version. |
|
62 | 65 |
.SH "EXAMPLES" |
63 | 66 |
.LP |
64 | 67 |
.TP |
... | ... |
@@ -93,6 +93,10 @@ DatabaseMirror database.clamav.net |
93 | 93 |
# Default: disabled |
94 | 94 |
#OnErrorExecute command |
95 | 95 |
|
96 |
+# Run command when freshclam reports outdated version. |
|
97 |
+# Default: disabled |
|
98 |
+#OnOutdatedExecute command |
|
99 |
+ |
|
96 | 100 |
# Don't fork into background. |
97 | 101 |
# Default: no |
98 | 102 |
#Foreground yes |
... | ... |
@@ -448,6 +448,7 @@ void help(void) |
448 | 448 |
mprintf(" --local-address=IP -a IP bind to IP for HTTP downloads\n"); |
449 | 449 |
mprintf(" --on-update-execute=COMMAND execute COMMAND after successful update\n"); |
450 | 450 |
mprintf(" --on-error-execute=COMMAND execute COMMAND if errors occured\n"); |
451 |
+ mprintf(" --on-outdated-execute=COMMAND execute COMMAND when software is outdated\n"); |
|
451 | 452 |
|
452 | 453 |
mprintf("\n"); |
453 | 454 |
exit(0); |
... | ... |
@@ -55,7 +55,7 @@ |
55 | 55 |
int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname) |
56 | 56 |
{ |
57 | 57 |
time_t currtime; |
58 |
- int ret, updated = 0, signo = 0, ttl = -1; |
|
58 |
+ int ret, updated = 0, outdated = 0, signo = 0, ttl = -1; |
|
59 | 59 |
char ipaddr[16], *dnsreply = NULL, *pt; |
60 | 60 |
struct cfgstruct *cpt; |
61 | 61 |
char *localip = NULL; |
... | ... |
@@ -118,6 +118,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
118 | 118 |
logg("^Your ClamAV installation is OUTDATED!\n"); |
119 | 119 |
logg("^Local version: %s Recommended version: %s\n", cl_retver(), pt); |
120 | 120 |
logg("DON'T PANIC! Read http://www.clamav.net/faq.html\n"); |
121 |
+ outdated = 1; |
|
121 | 122 |
} |
122 | 123 |
} |
123 | 124 |
free(pt); |
... | ... |
@@ -145,7 +146,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
145 | 145 |
|
146 | 146 |
memset(ipaddr, 0, sizeof(ipaddr)); |
147 | 147 |
|
148 |
- if((ret = downloaddb(DB1NAME, "main.cvd", hostname, ipaddr, &signo, copt, dnsreply, localip)) > 50) { |
|
148 |
+ if((ret = downloaddb(DB1NAME, "main.cvd", hostname, ipaddr, &signo, copt, dnsreply, localip, &outdated)) > 50) { |
|
149 | 149 |
if(dnsreply) |
150 | 150 |
free(dnsreply); |
151 | 151 |
|
... | ... |
@@ -155,7 +156,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
155 | 155 |
updated = 1; |
156 | 156 |
|
157 | 157 |
/* if ipaddr[0] != 0 it will use it to connect to the web host */ |
158 |
- if((ret = downloaddb(DB2NAME, "daily.cvd", hostname, ipaddr, &signo, copt, dnsreply, localip)) > 50) { |
|
158 |
+ if((ret = downloaddb(DB2NAME, "daily.cvd", hostname, ipaddr, &signo, copt, dnsreply, localip, &outdated)) > 50) { |
|
159 | 159 |
if(dnsreply) |
160 | 160 |
free(dnsreply); |
161 | 161 |
|
... | ... |
@@ -197,14 +198,26 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
197 | 197 |
else |
198 | 198 |
system(arg); |
199 | 199 |
} |
200 |
+ } |
|
200 | 201 |
|
201 |
- return 0; |
|
202 |
+ if(outdated) { |
|
203 |
+ if(optl(opt, "on-outdated-execute")) |
|
204 |
+ arg = getargl(opt, "on-outdated-execute"); |
|
205 |
+ else if((cpt = cfgopt(copt, "OnOutdatedExecute"))->enabled) |
|
206 |
+ arg = cpt->strarg; |
|
202 | 207 |
|
203 |
- } else |
|
204 |
- return 1; |
|
208 |
+ if(arg) { |
|
209 |
+ if(optc(opt, 'd')) |
|
210 |
+ execute("OnOutdatedExecute", arg); |
|
211 |
+ else |
|
212 |
+ system(arg); |
|
213 |
+ } |
|
214 |
+ } |
|
215 |
+ |
|
216 |
+ return updated ? 0 : 1; |
|
205 | 217 |
} |
206 | 218 |
|
207 |
-int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt, const char *dnsreply, char *localip) |
|
219 |
+int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt, const char *dnsreply, char *localip, int *outdated) |
|
208 | 220 |
{ |
209 | 221 |
struct cl_cvd *current, *remote; |
210 | 222 |
struct cfgstruct *cpt; |
... | ... |
@@ -312,11 +325,12 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
312 | 312 |
if(!nodb && (current->version >= dbver)) { |
313 | 313 |
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); |
314 | 314 |
|
315 |
- if(flevel < current->fl) { |
|
315 |
+ if(!*outdated && flevel < current->fl) { |
|
316 | 316 |
/* display warning even for already installed database */ |
317 | 317 |
logg("^Your ClamAV installation is OUTDATED!\n"); |
318 | 318 |
logg("^Current functionality level = %d, recommended = %d\n", flevel, current->fl); |
319 | 319 |
logg("DON'T PANIC! Read http://www.clamav.net/faq.html\n"); |
320 |
+ *outdated = 1; |
|
320 | 321 |
} |
321 | 322 |
|
322 | 323 |
*signo += current->sigs; |
... | ... |
@@ -24,7 +24,7 @@ |
24 | 24 |
|
25 | 25 |
int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname); |
26 | 26 |
|
27 |
-int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt, const char *dnsreply, char *localip); |
|
27 |
+int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt, const char *dnsreply, char *localip, int *outdated); |
|
28 | 28 |
|
29 | 29 |
int wwwconnect(const char *server, const char *proxy, int pport, char *remoteip, char *localip); |
30 | 30 |
|
... | ... |
@@ -111,6 +111,7 @@ struct cfgstruct *getcfg(const char *cfgfile, int verbose) |
111 | 111 |
{"NotifyClamd", OPT_STR, -1, NULL, 0}, /* freshclam */ |
112 | 112 |
{"OnUpdateExecute", OPT_FULLSTR, -1, NULL, 0}, /* freshclam */ |
113 | 113 |
{"OnErrorExecute", OPT_FULLSTR, -1, NULL, 0}, /* freshclam */ |
114 |
+ {"OnOutdatedExecute", OPT_FULLSTR, -1, NULL, 0}, /* freshclam */ |
|
114 | 115 |
{"LocalIPAddress", OPT_STR, -1, NULL, 0}, /* freshclam */ |
115 | 116 |
{0, 0} |
116 | 117 |
}; |