... | ... |
@@ -73,6 +73,9 @@ Print mirror details from mirrors.dat (cache file for the mirror manager). |
73 | 73 |
.TP |
74 | 74 |
\fB\-\-submit\-stats[=/path/to/clamd.conf]\fR |
75 | 75 |
Upload detection statistics to the ClamAV Project (see freshclam.conf(5):SubmitDetectionStats for more details). No database update will be performed. This option only works in the interactive mode. |
76 |
+.TP |
|
77 |
+\fB\-\-update\-db=DBNAME\fR |
|
78 |
+With this option you can limit updates to a subset of database files. The DBNAME should be "main", "daily", "bytecode", "safebrowsing" or one of the 3rd party database names. This option can be used multiple times. |
|
76 | 79 |
.SH "EXAMPLES" |
77 | 80 |
.LP |
78 | 81 |
.TP |
... | ... |
@@ -160,6 +160,7 @@ static void help(void) |
160 | 160 |
mprintf(" --on-outdated-execute=COMMAND execute COMMAND when software is outdated\n"); |
161 | 161 |
mprintf(" --list-mirrors print mirrors from mirrors.dat\n"); |
162 | 162 |
mprintf(" --submit-stats[=/path/clamd.conf] only submit detection statistics\n"); |
163 |
+ mprintf(" --update-db=DBNAME only update database DBNAME\n"); |
|
163 | 164 |
|
164 | 165 |
mprintf("\n"); |
165 | 166 |
} |
... | ... |
@@ -2173,112 +2173,133 @@ int downloadmanager(const struct optstruct *opts, const char *hostname, int loge |
2173 | 2173 |
|
2174 | 2174 |
memset(ipaddr, 0, sizeof(ipaddr)); |
2175 | 2175 |
|
2176 |
- if((ret = updatedb("main", hostname, ipaddr, &signo, opts, dnsreply, localip, outdated, &mdat, logerr, 0)) > 50) { |
|
2177 |
- if(dnsreply) |
|
2178 |
- free(dnsreply); |
|
2176 |
+ if((opt = optget(opts, "update-db"))->enabled) { |
|
2177 |
+ const char *u_dnsreply; |
|
2178 |
+ int u_extra; |
|
2179 | 2179 |
|
2180 |
- if(newver) |
|
2181 |
- free(newver); |
|
2182 |
- |
|
2183 |
- mirman_write("mirrors.dat", dbdir, &mdat); |
|
2184 |
- mirman_free(&mdat); |
|
2185 |
- cli_rmdirs(updtmpdir); |
|
2186 |
- return ret; |
|
2187 |
- |
|
2188 |
- } else if(ret == 0) |
|
2189 |
- updated = 1; |
|
2190 |
- |
|
2191 |
- /* if ipaddr[0] != 0 it will use it to connect to the web host */ |
|
2192 |
- if((ret = updatedb("daily", hostname, ipaddr, &signo, opts, dnsreply, localip, outdated, &mdat, logerr, 0)) > 50) { |
|
2193 |
- if(dnsreply) |
|
2194 |
- free(dnsreply); |
|
2195 |
- |
|
2196 |
- if(newver) |
|
2197 |
- free(newver); |
|
2198 |
- |
|
2199 |
- mirman_write("mirrors.dat", dbdir, &mdat); |
|
2200 |
- mirman_free(&mdat); |
|
2201 |
- cli_rmdirs(updtmpdir); |
|
2202 |
- return ret; |
|
2180 |
+ while(opt) { |
|
2181 |
+ if(!strcmp(opt->strarg, "main") || !strcmp(opt->strarg, "daily") || !strcmp(opt->strarg, "safebrowsing") || !strcmp(opt->strarg, "bytecode")) { |
|
2182 |
+ u_dnsreply = dnsreply; |
|
2183 |
+ u_extra = 0; |
|
2184 |
+ } else { |
|
2185 |
+ u_dnsreply = NULL; |
|
2186 |
+ u_extra = 1; |
|
2187 |
+ } |
|
2188 |
+ if((ret = updatedb(opt->strarg, hostname, ipaddr, &signo, opts, u_dnsreply, localip, outdated, &mdat, logerr, u_extra)) > 50) { |
|
2189 |
+ if(dnsreply) |
|
2190 |
+ free(dnsreply); |
|
2191 |
+ if(newver) |
|
2192 |
+ free(newver); |
|
2193 |
+ mirman_write("mirrors.dat", dbdir, &mdat); |
|
2194 |
+ mirman_free(&mdat); |
|
2195 |
+ cli_rmdirs(updtmpdir); |
|
2196 |
+ return ret; |
|
2197 |
+ } else if(ret == 0) |
|
2198 |
+ updated = 1; |
|
2203 | 2199 |
|
2204 |
- } else if(ret == 0) |
|
2205 |
- updated = 1; |
|
2200 |
+ opt = opt->nextarg; |
|
2201 |
+ } |
|
2206 | 2202 |
|
2207 |
- /* if ipaddr[0] != 0 it will use it to connect to the web host */ |
|
2208 |
- if(!optget(opts, "SafeBrowsing")->enabled) { |
|
2209 |
- const char *safedb = NULL; |
|
2203 |
+ } else { |
|
2204 |
+ if((ret = updatedb("main", hostname, ipaddr, &signo, opts, dnsreply, localip, outdated, &mdat, logerr, 0)) > 50) { |
|
2205 |
+ if(dnsreply) |
|
2206 |
+ free(dnsreply); |
|
2207 |
+ if(newver) |
|
2208 |
+ free(newver); |
|
2209 |
+ mirman_write("mirrors.dat", dbdir, &mdat); |
|
2210 |
+ mirman_free(&mdat); |
|
2211 |
+ cli_rmdirs(updtmpdir); |
|
2212 |
+ return ret; |
|
2213 |
+ } else if(ret == 0) |
|
2214 |
+ updated = 1; |
|
2210 | 2215 |
|
2211 |
- if(!access("safebrowsing.cvd", R_OK)) |
|
2212 |
- safedb = "safebrowsing.cvd"; |
|
2213 |
- else if(!access("safebrowsing.cld", R_OK)) |
|
2214 |
- safedb = "safebrowsing.cld"; |
|
2216 |
+ /* if ipaddr[0] != 0 it will use it to connect to the web host */ |
|
2217 |
+ if((ret = updatedb("daily", hostname, ipaddr, &signo, opts, dnsreply, localip, outdated, &mdat, logerr, 0)) > 50) { |
|
2218 |
+ if(dnsreply) |
|
2219 |
+ free(dnsreply); |
|
2220 |
+ if(newver) |
|
2221 |
+ free(newver); |
|
2222 |
+ mirman_write("mirrors.dat", dbdir, &mdat); |
|
2223 |
+ mirman_free(&mdat); |
|
2224 |
+ cli_rmdirs(updtmpdir); |
|
2225 |
+ return ret; |
|
2226 |
+ } else if(ret == 0) |
|
2227 |
+ updated = 1; |
|
2215 | 2228 |
|
2216 |
- if(safedb) { |
|
2217 |
- if(unlink(safedb)) |
|
2218 |
- logg("^SafeBrowsing is disabled but can't remove old %s\n", safedb); |
|
2219 |
- else |
|
2220 |
- logg("*%s removed\n", safedb); |
|
2221 |
- } |
|
2222 |
- } else if((ret = updatedb("safebrowsing", hostname, ipaddr, &signo, opts, dnsreply, localip, outdated, &mdat, logerr, 0)) > 50) { |
|
2223 |
- if(dnsreply) |
|
2224 |
- free(dnsreply); |
|
2229 |
+ if(!optget(opts, "SafeBrowsing")->enabled) { |
|
2230 |
+ const char *safedb = NULL; |
|
2225 | 2231 |
|
2226 |
- if(newver) |
|
2227 |
- free(newver); |
|
2232 |
+ if(!access("safebrowsing.cvd", R_OK)) |
|
2233 |
+ safedb = "safebrowsing.cvd"; |
|
2234 |
+ else if(!access("safebrowsing.cld", R_OK)) |
|
2235 |
+ safedb = "safebrowsing.cld"; |
|
2228 | 2236 |
|
2229 |
- mirman_write("mirrors.dat", dbdir, &mdat); |
|
2230 |
- mirman_free(&mdat); |
|
2231 |
- cli_rmdirs(updtmpdir); |
|
2232 |
- return ret; |
|
2233 |
- } else if(ret == 0) |
|
2234 |
- updated = 1; |
|
2237 |
+ if(safedb) { |
|
2238 |
+ if(unlink(safedb)) |
|
2239 |
+ logg("^SafeBrowsing is disabled but can't remove old %s\n", safedb); |
|
2240 |
+ else |
|
2241 |
+ logg("*%s removed\n", safedb); |
|
2242 |
+ } |
|
2243 |
+ } else if((ret = updatedb("safebrowsing", hostname, ipaddr, &signo, opts, dnsreply, localip, outdated, &mdat, logerr, 0)) > 50) { |
|
2244 |
+ if(dnsreply) |
|
2245 |
+ free(dnsreply); |
|
2246 |
+ if(newver) |
|
2247 |
+ free(newver); |
|
2248 |
+ mirman_write("mirrors.dat", dbdir, &mdat); |
|
2249 |
+ mirman_free(&mdat); |
|
2250 |
+ cli_rmdirs(updtmpdir); |
|
2251 |
+ return ret; |
|
2252 |
+ } else if(ret == 0) |
|
2253 |
+ updated = 1; |
|
2235 | 2254 |
|
2236 |
- if(!optget(opts, "Bytecode")->enabled) { |
|
2237 |
- const char *dbname = NULL; |
|
2255 |
+ if(!optget(opts, "Bytecode")->enabled) { |
|
2256 |
+ const char *dbname = NULL; |
|
2238 | 2257 |
|
2239 |
- if(!access("bytecode.cvd", R_OK)) |
|
2240 |
- dbname = "bytecode.cvd"; |
|
2241 |
- else if(!access("bytecode.cld", R_OK)) |
|
2242 |
- dbname = "bytecode.cld"; |
|
2258 |
+ if(!access("bytecode.cvd", R_OK)) |
|
2259 |
+ dbname = "bytecode.cvd"; |
|
2260 |
+ else if(!access("bytecode.cld", R_OK)) |
|
2261 |
+ dbname = "bytecode.cld"; |
|
2243 | 2262 |
|
2244 |
- if(dbname) { |
|
2245 |
- if(unlink(dbname)) |
|
2246 |
- logg("^Bytecode is disabled but can't remove old %s\n", dbname); |
|
2247 |
- else |
|
2248 |
- logg("*%s removed\n", dbname); |
|
2263 |
+ if(dbname) { |
|
2264 |
+ if(unlink(dbname)) |
|
2265 |
+ logg("^Bytecode is disabled but can't remove old %s\n", dbname); |
|
2266 |
+ else |
|
2267 |
+ logg("*%s removed\n", dbname); |
|
2268 |
+ } |
|
2269 |
+ } else if((ret = updatedb("bytecode", hostname, ipaddr, &signo, opts, dnsreply, localip, outdated, &mdat, logerr, 0)) > 50) { |
|
2270 |
+ if(dnsreply) |
|
2271 |
+ free(dnsreply); |
|
2272 |
+ if(newver) |
|
2273 |
+ free(newver); |
|
2274 |
+ mirman_write("mirrors.dat", dbdir, &mdat); |
|
2275 |
+ mirman_free(&mdat); |
|
2276 |
+ cli_rmdirs(updtmpdir); |
|
2277 |
+ return ret; |
|
2278 |
+ } else if(ret == 0) |
|
2279 |
+ updated = 1; |
|
2280 |
+ |
|
2281 |
+ /* handle extra dbs */ |
|
2282 |
+ if((opt = optget(opts, "ExtraDatabase"))->enabled) { |
|
2283 |
+ while(opt) { |
|
2284 |
+ if((ret = updatedb(opt->strarg, hostname, ipaddr, &signo, opts, NULL, localip, outdated, &mdat, logerr, 1)) > 50) { |
|
2285 |
+ if(dnsreply) |
|
2286 |
+ free(dnsreply); |
|
2287 |
+ if(newver) |
|
2288 |
+ free(newver); |
|
2289 |
+ mirman_write("mirrors.dat", dbdir, &mdat); |
|
2290 |
+ mirman_free(&mdat); |
|
2291 |
+ cli_rmdirs(updtmpdir); |
|
2292 |
+ return ret; |
|
2293 |
+ } else if(ret == 0) |
|
2294 |
+ updated = 1; |
|
2295 |
+ opt = opt->nextarg; |
|
2296 |
+ } |
|
2249 | 2297 |
} |
2250 |
- } else if((ret = updatedb("bytecode", hostname, ipaddr, &signo, opts, dnsreply, localip, outdated, &mdat, logerr, 0)) > 50) { |
|
2251 |
- if(dnsreply) |
|
2252 |
- free(dnsreply); |
|
2253 |
- |
|
2254 |
- if(newver) |
|
2255 |
- free(newver); |
|
2298 |
+ } |
|
2256 | 2299 |
|
2257 |
- mirman_write("mirrors.dat", dbdir, &mdat); |
|
2258 |
- mirman_free(&mdat); |
|
2259 |
- cli_rmdirs(updtmpdir); |
|
2260 |
- return ret; |
|
2261 |
- } else if(ret == 0) |
|
2262 |
- updated = 1; |
|
2263 | 2300 |
if(dnsreply) |
2264 | 2301 |
free(dnsreply); |
2265 | 2302 |
|
2266 |
- /* handle extra dbs */ |
|
2267 |
- if((opt = optget(opts, "ExtraDatabase"))->enabled) { |
|
2268 |
- while(opt) { |
|
2269 |
- if((ret = updatedb(opt->strarg, hostname, ipaddr, &signo, opts, NULL, localip, outdated, &mdat, logerr, 1)) > 50) { |
|
2270 |
- if(newver) |
|
2271 |
- free(newver); |
|
2272 |
- mirman_write("mirrors.dat", dbdir, &mdat); |
|
2273 |
- mirman_free(&mdat); |
|
2274 |
- cli_rmdirs(updtmpdir); |
|
2275 |
- return ret; |
|
2276 |
- } else if(ret == 0) |
|
2277 |
- updated = 1; |
|
2278 |
- opt = opt->nextarg; |
|
2279 |
- } |
|
2280 |
- } |
|
2281 |
- |
|
2282 | 2303 |
mirman_write("mirrors.dat", dbdir, &mdat); |
2283 | 2304 |
mirman_free(&mdat); |
2284 | 2305 |
|
... | ... |
@@ -76,6 +76,7 @@ const struct clam_option __clam_options[] = { |
76 | 76 |
{ NULL, "no-dns", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "", "" }, |
77 | 77 |
{ NULL, "list-mirrors", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "", "" }, |
78 | 78 |
{ NULL, "submit-stats", 0, TYPE_STRING, NULL, 0, CONFDIR_CLAMD, 0, OPT_FRESHCLAM, "", "" }, /* Don't merge this one with SubmitDetectionStats */ |
79 |
+ { NULL, "update-db", 0, TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_FRESHCLAM, "", "" }, |
|
79 | 80 |
{ NULL, "reload", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDSCAN, "", "" }, |
80 | 81 |
{ NULL, "multiscan", 'm', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDSCAN, "", "" }, |
81 | 82 |
{ NULL, "fdpass", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDSCAN, "", "" }, |