git-svn: trunk@2656
Tomasz Kojm authored on 2007/01/31 06:26:43... | ... |
@@ -88,7 +88,7 @@ int main(int argc, char **argv) |
88 | 88 |
struct cfgstruct *copt, *cpt; |
89 | 89 |
struct passwd *user; |
90 | 90 |
time_t currtime; |
91 |
- struct cl_node *root = NULL; |
|
91 |
+ struct cl_engine *engine = NULL; |
|
92 | 92 |
const char *dbdir, *cfgfile; |
93 | 93 |
int ret, tcpsock = 0, localsock = 0; |
94 | 94 |
unsigned int sigs = 0; |
... | ... |
@@ -329,14 +329,14 @@ int main(int argc, char **argv) |
329 | 329 |
#endif |
330 | 330 |
} |
331 | 331 |
|
332 |
- if((ret = cl_load(dbdir, &root, &sigs, dboptions))) { |
|
332 |
+ if((ret = cl_load(dbdir, &engine, &sigs, dboptions))) { |
|
333 | 333 |
logg("!%s\n", cl_strerror(ret)); |
334 | 334 |
logg_close(); |
335 | 335 |
freecfg(copt); |
336 | 336 |
return 1; |
337 | 337 |
} |
338 | 338 |
|
339 |
- if(!root) { |
|
339 |
+ if(!engine) { |
|
340 | 340 |
logg("!Database initialization error.\n"); |
341 | 341 |
logg_close(); |
342 | 342 |
freecfg(copt); |
... | ... |
@@ -344,7 +344,7 @@ int main(int argc, char **argv) |
344 | 344 |
} |
345 | 345 |
|
346 | 346 |
logg("#Loaded %d signatures.\n", sigs); |
347 |
- if((ret = cl_build(root)) != 0) { |
|
347 |
+ if((ret = cl_build(engine)) != 0) { |
|
348 | 348 |
logg("!Database initialization error: %s\n", cl_strerror(ret));; |
349 | 349 |
logg_close(); |
350 | 350 |
freecfg(copt); |
... | ... |
@@ -383,7 +383,7 @@ int main(int argc, char **argv) |
383 | 383 |
nlsockets++; |
384 | 384 |
} |
385 | 385 |
|
386 |
- ret = acceptloop_th(lsockets, nlsockets, root, dboptions, copt); |
|
386 |
+ ret = acceptloop_th(lsockets, nlsockets, engine, dboptions, copt); |
|
387 | 387 |
|
388 | 388 |
#ifdef C_WINDOWS |
389 | 389 |
if(tcpsock) |
... | ... |
@@ -169,7 +169,7 @@ void *clamukoth(void *arg) |
169 | 169 |
} |
170 | 170 |
} |
171 | 171 |
|
172 |
- if(scan && cl_scanfile(acc->filename, &virname, NULL, tharg->root, tharg->limits, tharg->options) == CL_VIRUS) { |
|
172 |
+ if(scan && cl_scanfile(acc->filename, &virname, NULL, tharg->engine, tharg->limits, tharg->options) == CL_VIRUS) { |
|
173 | 173 |
logg("Clamuko: %s: %s FOUND\n", acc->filename, virname); |
174 | 174 |
virusaction(acc->filename, virname, tharg->copt); |
175 | 175 |
acc->deny = 1; |
... | ... |
@@ -89,7 +89,7 @@ int checksymlink(const char *path) |
89 | 89 |
} |
90 | 90 |
|
91 | 91 |
/* :set nowrap, if you don't like this style ;)) */ |
92 |
-int dirscan(const char *dirname, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int odesc, unsigned int *reclev, short contscan) |
|
92 |
+int dirscan(const char *dirname, const char **virname, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc, unsigned int *reclev, short contscan) |
|
93 | 93 |
{ |
94 | 94 |
DIR *dd; |
95 | 95 |
struct dirent *dent; |
... | ... |
@@ -139,7 +139,7 @@ int dirscan(const char *dirname, const char **virname, unsigned long int *scanne |
139 | 139 |
/* stat the file */ |
140 | 140 |
if(lstat(fname, &statbuf) != -1) { |
141 | 141 |
if((S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) || (S_ISLNK(statbuf.st_mode) && (checksymlink(fname) == 1) && cfgopt(copt, "FollowDirectorySymlinks")->enabled)) { |
142 |
- if(dirscan(fname, virname, scanned, root, limits, options, copt, odesc, reclev, contscan) == 1) { |
|
142 |
+ if(dirscan(fname, virname, scanned, engine, limits, options, copt, odesc, reclev, contscan) == 1) { |
|
143 | 143 |
free(fname); |
144 | 144 |
closedir(dd); |
145 | 145 |
return 1; |
... | ... |
@@ -152,7 +152,7 @@ int dirscan(const char *dirname, const char **virname, unsigned long int *scanne |
152 | 152 |
scanret = CL_CLEAN; |
153 | 153 |
else |
154 | 154 |
#endif |
155 |
- scanret = cl_scanfile(fname, virname, scanned, root, limits, options); |
|
155 |
+ scanret = cl_scanfile(fname, virname, scanned, engine, limits, options); |
|
156 | 156 |
|
157 | 157 |
if(scanret == CL_VIRUS) { |
158 | 158 |
|
... | ... |
@@ -196,7 +196,7 @@ int dirscan(const char *dirname, const char **virname, unsigned long int *scanne |
196 | 196 |
|
197 | 197 |
} |
198 | 198 |
|
199 |
-int scan(const char *filename, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int odesc, short contscan) |
|
199 |
+int scan(const char *filename, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc, short contscan) |
|
200 | 200 |
{ |
201 | 201 |
struct stat sb; |
202 | 202 |
int ret = 0; |
... | ... |
@@ -233,7 +233,7 @@ int scan(const char *filename, unsigned long int *scanned, const struct cl_node |
233 | 233 |
ret = CL_CLEAN; |
234 | 234 |
else |
235 | 235 |
#endif |
236 |
- ret = cl_scanfile(filename, &virname, scanned, root, limits, options); |
|
236 |
+ ret = cl_scanfile(filename, &virname, scanned, engine, limits, options); |
|
237 | 237 |
|
238 | 238 |
if(ret == CL_VIRUS) { |
239 | 239 |
mdprintf(odesc, "%s: %s FOUND\n", filename, virname); |
... | ... |
@@ -249,7 +249,7 @@ int scan(const char *filename, unsigned long int *scanned, const struct cl_node |
249 | 249 |
} |
250 | 250 |
break; |
251 | 251 |
case S_IFDIR: |
252 |
- ret = dirscan(filename, &virname, scanned, root, limits, options, copt, odesc, &reclev, contscan); |
|
252 |
+ ret = dirscan(filename, &virname, scanned, engine, limits, options, copt, odesc, &reclev, contscan); |
|
253 | 253 |
break; |
254 | 254 |
default: |
255 | 255 |
mdprintf(odesc, "%s: Not supported file type. ERROR\n", filename); |
... | ... |
@@ -263,7 +263,7 @@ int scan(const char *filename, unsigned long int *scanned, const struct cl_node |
263 | 263 |
return ret; |
264 | 264 |
} |
265 | 265 |
|
266 |
-int scanfd(const int fd, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int odesc) |
|
266 |
+int scanfd(const int fd, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc) |
|
267 | 267 |
{ |
268 | 268 |
int ret; |
269 | 269 |
const char *virname; |
... | ... |
@@ -279,7 +279,7 @@ int scanfd(const int fd, unsigned long int *scanned, const struct cl_node *root, |
279 | 279 |
|
280 | 280 |
snprintf(fdstr, sizeof(fdstr), "fd[%d]", fd); |
281 | 281 |
|
282 |
- ret = cl_scandesc(fd, &virname, scanned, root, limits, options); |
|
282 |
+ ret = cl_scandesc(fd, &virname, scanned, engine, limits, options); |
|
283 | 283 |
|
284 | 284 |
if(ret == CL_VIRUS) { |
285 | 285 |
mdprintf(odesc, "%s: %s FOUND\n", fdstr, virname); |
... | ... |
@@ -297,7 +297,7 @@ int scanfd(const int fd, unsigned long int *scanned, const struct cl_node *root, |
297 | 297 |
return ret; |
298 | 298 |
} |
299 | 299 |
|
300 |
-int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt) |
|
300 |
+int scanstream(int odesc, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt) |
|
301 | 301 |
{ |
302 | 302 |
int ret, portscan = 1000, sockfd, port = 0, acceptd; |
303 | 303 |
int tmpd, bread, retval, timeout, btread, min_port, max_port; |
... | ... |
@@ -451,7 +451,7 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root |
451 | 451 |
|
452 | 452 |
if(retval == 1) { |
453 | 453 |
lseek(tmpd, 0, SEEK_SET); |
454 |
- ret = cl_scandesc(tmpd, &virname, scanned, root, limits, options); |
|
454 |
+ ret = cl_scandesc(tmpd, &virname, scanned, engine, limits, options); |
|
455 | 455 |
} else { |
456 | 456 |
ret = -1; |
457 | 457 |
} |
... | ... |
@@ -23,13 +23,13 @@ |
23 | 23 |
#include "libclamav/clamav.h" |
24 | 24 |
#include "shared/cfgparser.h" |
25 | 25 |
|
26 |
-int dirscan(const char *dirname, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int odesc, unsigned int *reclev, short contscan); |
|
26 |
+int dirscan(const char *dirname, const char **virname, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc, unsigned int *reclev, short contscan); |
|
27 | 27 |
|
28 |
-int scan(const char *filename, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int odesc, short contscan); |
|
28 |
+int scan(const char *filename, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc, short contscan); |
|
29 | 29 |
|
30 |
-int scanfd(const int fd, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int odesc); |
|
30 |
+int scanfd(const int fd, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc); |
|
31 | 31 |
|
32 |
-int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt); |
|
32 |
+int scanstream(int odesc, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt); |
|
33 | 33 |
|
34 | 34 |
int checksymlink(const char *path); |
35 | 35 |
|
... | ... |
@@ -74,10 +74,10 @@ static struct cl_stat *dbstat = NULL; |
74 | 74 |
|
75 | 75 |
typedef struct client_conn_tag { |
76 | 76 |
int sd; |
77 |
- int options; |
|
77 |
+ unsigned int options; |
|
78 | 78 |
const struct cfgstruct *copt; |
79 |
- struct cl_node *root; |
|
80 |
- time_t root_timestamp; |
|
79 |
+ struct cl_engine *engine; |
|
80 |
+ time_t engine_timestamp; |
|
81 | 81 |
const struct cl_limits *limits; |
82 | 82 |
int *socketds; |
83 | 83 |
int nsockets; |
... | ... |
@@ -103,7 +103,7 @@ void scanner_thread(void *arg) |
103 | 103 |
timeout = -1; |
104 | 104 |
|
105 | 105 |
do { |
106 |
- ret = command(conn->sd, conn->root, conn->limits, conn->options, conn->copt, timeout); |
|
106 |
+ ret = command(conn->sd, conn->engine, conn->limits, conn->options, conn->copt, timeout); |
|
107 | 107 |
if (ret < 0) { |
108 | 108 |
break; |
109 | 109 |
} |
... | ... |
@@ -140,7 +140,7 @@ void scanner_thread(void *arg) |
140 | 140 |
} |
141 | 141 |
pthread_mutex_unlock(&exit_mutex); |
142 | 142 |
pthread_mutex_lock(&reload_mutex); |
143 |
- if (conn->root_timestamp != reloaded_time) { |
|
143 |
+ if (conn->engine_timestamp != reloaded_time) { |
|
144 | 144 |
session = FALSE; |
145 | 145 |
} |
146 | 146 |
pthread_mutex_unlock(&reload_mutex); |
... | ... |
@@ -148,7 +148,7 @@ void scanner_thread(void *arg) |
148 | 148 |
} while (session); |
149 | 149 |
|
150 | 150 |
closesocket(conn->sd); |
151 |
- cl_free(conn->root); |
|
151 |
+ cl_free(conn->engine); |
|
152 | 152 |
free(conn); |
153 | 153 |
return; |
154 | 154 |
} |
... | ... |
@@ -178,7 +178,7 @@ void sighandler_th(int sig) |
178 | 178 |
} |
179 | 179 |
} |
180 | 180 |
|
181 |
-static struct cl_node *reload_db(struct cl_node *root, unsigned int dboptions, const struct cfgstruct *copt, int do_check, int *ret) |
|
181 |
+static struct cl_engine *reload_db(struct cl_engine *engine, unsigned int dboptions, const struct cfgstruct *copt, int do_check, int *ret) |
|
182 | 182 |
{ |
183 | 183 |
const char *dbdir; |
184 | 184 |
int retval; |
... | ... |
@@ -188,12 +188,12 @@ static struct cl_node *reload_db(struct cl_node *root, unsigned int dboptions, c |
188 | 188 |
if(do_check) { |
189 | 189 |
if(dbstat == NULL) { |
190 | 190 |
logg("No stats for Database check - forcing reload\n"); |
191 |
- return root; |
|
191 |
+ return engine; |
|
192 | 192 |
} |
193 | 193 |
|
194 | 194 |
if(cl_statchkdir(dbstat) == 1) { |
195 | 195 |
logg("SelfCheck: Database modification detected. Forcing reload.\n"); |
196 |
- return root; |
|
196 |
+ return engine; |
|
197 | 197 |
} else { |
198 | 198 |
logg("SelfCheck: Database status OK.\n"); |
199 | 199 |
return NULL; |
... | ... |
@@ -201,9 +201,9 @@ static struct cl_node *reload_db(struct cl_node *root, unsigned int dboptions, c |
201 | 201 |
} |
202 | 202 |
|
203 | 203 |
/* release old structure */ |
204 |
- if(root) { |
|
205 |
- cl_free(root); |
|
206 |
- root = NULL; |
|
204 |
+ if(engine) { |
|
205 |
+ cl_free(engine); |
|
206 |
+ engine = NULL; |
|
207 | 207 |
} |
208 | 208 |
|
209 | 209 |
dbdir = cfgopt(copt, "DatabaseDirectory")->strarg; |
... | ... |
@@ -223,29 +223,29 @@ static struct cl_node *reload_db(struct cl_node *root, unsigned int dboptions, c |
223 | 223 |
memset(dbstat, 0, sizeof(struct cl_stat)); |
224 | 224 |
cl_statinidir(dbdir, dbstat); |
225 | 225 |
|
226 |
- if((retval = cl_load(dbdir, &root, &sigs, dboptions))) { |
|
226 |
+ if((retval = cl_load(dbdir, &engine, &sigs, dboptions))) { |
|
227 | 227 |
logg("!reload db failed: %s\n", cl_strerror(retval)); |
228 | 228 |
*ret = 1; |
229 | 229 |
return NULL; |
230 | 230 |
} |
231 | 231 |
|
232 |
- if(!root) { |
|
232 |
+ if(!engine) { |
|
233 | 233 |
logg("!reload db failed: %s\n", cl_strerror(retval)); |
234 | 234 |
*ret = 1; |
235 | 235 |
return NULL; |
236 | 236 |
} |
237 | 237 |
|
238 |
- if((retval = cl_build(root)) != 0) { |
|
238 |
+ if((retval = cl_build(engine)) != 0) { |
|
239 | 239 |
logg("!Database initialization error: can't build engine: %s\n", cl_strerror(retval)); |
240 | 240 |
*ret = 1; |
241 | 241 |
return NULL; |
242 | 242 |
} |
243 | 243 |
logg("Database correctly reloaded (%d signatures)\n", sigs); |
244 | 244 |
|
245 |
- return root; |
|
245 |
+ return engine; |
|
246 | 246 |
} |
247 | 247 |
|
248 |
-int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned int dboptions, const struct cfgstruct *copt) |
|
248 |
+int acceptloop_th(int *socketds, int nsockets, struct cl_engine *engine, unsigned int dboptions, const struct cfgstruct *copt) |
|
249 | 249 |
{ |
250 | 250 |
int new_sd, max_threads, i, ret = 0; |
251 | 251 |
unsigned int options = 0; |
... | ... |
@@ -459,7 +459,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
459 | 459 |
|
460 | 460 |
tharg = (struct thrarg *) mmalloc(sizeof(struct thrarg)); |
461 | 461 |
tharg->copt = copt; |
462 |
- tharg->root = root; |
|
462 |
+ tharg->engine = engine; |
|
463 | 463 |
tharg->limits = &limits; |
464 | 464 |
tharg->options = options; |
465 | 465 |
|
... | ... |
@@ -560,8 +560,8 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
560 | 560 |
client_conn->sd = new_sd; |
561 | 561 |
client_conn->options = options; |
562 | 562 |
client_conn->copt = copt; |
563 |
- client_conn->root = cl_dup(root); |
|
564 |
- client_conn->root_timestamp = reloaded_time; |
|
563 |
+ client_conn->engine = cl_dup(engine); |
|
564 |
+ client_conn->engine_timestamp = reloaded_time; |
|
565 | 565 |
client_conn->limits = &limits; |
566 | 566 |
client_conn->socketds = socketds; |
567 | 567 |
client_conn->nsockets = nsockets; |
... | ... |
@@ -585,7 +585,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
585 | 585 |
if(selfchk) { |
586 | 586 |
time(¤t_time); |
587 | 587 |
if((current_time - start_time) > (time_t)selfchk) { |
588 |
- if(reload_db(root, dboptions, copt, TRUE, &ret)) { |
|
588 |
+ if(reload_db(engine, dboptions, copt, TRUE, &ret)) { |
|
589 | 589 |
pthread_mutex_lock(&reload_mutex); |
590 | 590 |
reload = 1; |
591 | 591 |
pthread_mutex_unlock(&reload_mutex); |
... | ... |
@@ -597,7 +597,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
597 | 597 |
pthread_mutex_lock(&reload_mutex); |
598 | 598 |
if(reload) { |
599 | 599 |
pthread_mutex_unlock(&reload_mutex); |
600 |
- root = reload_db(root, dboptions, copt, FALSE, &ret); |
|
600 |
+ engine = reload_db(engine, dboptions, copt, FALSE, &ret); |
|
601 | 601 |
if(ret) { |
602 | 602 |
logg("Terminating because of a fatal error."); |
603 | 603 |
if(new_sd >= 0) |
... | ... |
@@ -613,7 +613,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
613 | 613 |
logg("Stopping and restarting Clamuko.\n"); |
614 | 614 |
pthread_kill(clamuko_pid, SIGUSR1); |
615 | 615 |
pthread_join(clamuko_pid, NULL); |
616 |
- tharg->root = root; |
|
616 |
+ tharg->engine = engine; |
|
617 | 617 |
pthread_create(&clamuko_pid, &clamuko_attr, clamukoth, tharg); |
618 | 618 |
} |
619 | 619 |
#endif |
... | ... |
@@ -633,8 +633,8 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
633 | 633 |
pthread_join(clamuko_pid, NULL); |
634 | 634 |
} |
635 | 635 |
#endif |
636 |
- if(root) |
|
637 |
- cl_free(root); |
|
636 |
+ if(engine) |
|
637 |
+ cl_free(engine); |
|
638 | 638 |
|
639 | 639 |
if(dbstat) |
640 | 640 |
cl_statfree(dbstat); |
... | ... |
@@ -30,7 +30,7 @@ struct thrarg { |
30 | 30 |
int sid; |
31 | 31 |
int options; |
32 | 32 |
const struct cfgstruct *copt; |
33 |
- const struct cl_node *root; |
|
33 |
+ const struct cl_engine *engine; |
|
34 | 34 |
const struct cl_limits *limits; |
35 | 35 |
}; |
36 | 36 |
|
... | ... |
@@ -45,13 +45,13 @@ struct thrsession { |
45 | 45 |
/* thread watcher arguments */ |
46 | 46 |
struct thrwarg { |
47 | 47 |
int socketd; |
48 |
- struct cl_node **root; |
|
48 |
+ struct cl_engine **engine; |
|
49 | 49 |
const struct cfgstruct *copt; |
50 | 50 |
const struct cl_limits *limits; |
51 |
- int options; |
|
51 |
+ unsigned int options; |
|
52 | 52 |
}; |
53 | 53 |
|
54 |
-int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned int dboptions, const struct cfgstruct *copt); |
|
54 |
+int acceptloop_th(int *socketds, int nsockets, struct cl_engine *engine, unsigned int dboptions, const struct cfgstruct *copt); |
|
55 | 55 |
void sighandler(int sig); |
56 | 56 |
void sighandler_th(int sig); |
57 | 57 |
void daemonize(void); |
... | ... |
@@ -64,10 +64,10 @@ extern int progexit; |
64 | 64 |
|
65 | 65 |
struct multi_tag { |
66 | 66 |
int sd; |
67 |
- int options; |
|
67 |
+ unsigned int options; |
|
68 | 68 |
const struct cfgstruct *copt; |
69 | 69 |
char *fname; |
70 |
- const struct cl_node *root; |
|
70 |
+ const struct cl_engine *engine; |
|
71 | 71 |
const struct cl_limits *limits; |
72 | 72 |
}; |
73 | 73 |
|
... | ... |
@@ -87,7 +87,7 @@ void multiscanfile(void *arg) |
87 | 87 |
pthread_sigmask(SIG_SETMASK, &sigset, NULL); |
88 | 88 |
#endif |
89 | 89 |
|
90 |
- ret = cl_scanfile(tag->fname, &virname, NULL, tag->root, tag->limits, tag->options); |
|
90 |
+ ret = cl_scanfile(tag->fname, &virname, NULL, tag->engine, tag->limits, tag->options); |
|
91 | 91 |
|
92 | 92 |
if(ret == CL_VIRUS) { |
93 | 93 |
mdprintf(tag->sd, "%s: %s FOUND\n", tag->fname, virname); |
... | ... |
@@ -105,7 +105,7 @@ void multiscanfile(void *arg) |
105 | 105 |
return; |
106 | 106 |
} |
107 | 107 |
|
108 |
-static int multiscan(const char *dirname, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int odesc, unsigned int *reclev, threadpool_t *multi_pool) |
|
108 |
+static int multiscan(const char *dirname, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int odesc, unsigned int *reclev, threadpool_t *multi_pool) |
|
109 | 109 |
{ |
110 | 110 |
DIR *dd; |
111 | 111 |
struct dirent *dent; |
... | ... |
@@ -167,7 +167,7 @@ static int multiscan(const char *dirname, const struct cl_node *root, const stru |
167 | 167 |
/* stat the file */ |
168 | 168 |
if(lstat(fname, &statbuf) != -1) { |
169 | 169 |
if((S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) || (S_ISLNK(statbuf.st_mode) && (checksymlink(fname) == 1) && cfgopt(copt, "FollowDirectorySymlinks")->enabled)) { |
170 |
- if(multiscan(fname, root, limits, options, copt, odesc, reclev, multi_pool) == -1) { |
|
170 |
+ if(multiscan(fname, engine, limits, options, copt, odesc, reclev, multi_pool) == -1) { |
|
171 | 171 |
free(fname); |
172 | 172 |
closedir(dd); |
173 | 173 |
return -1; |
... | ... |
@@ -193,7 +193,7 @@ static int multiscan(const char *dirname, const struct cl_node *root, const stru |
193 | 193 |
scandata->options = options; |
194 | 194 |
scandata->copt = copt; |
195 | 195 |
scandata->fname = fname; |
196 |
- scandata->root = root; |
|
196 |
+ scandata->engine = engine; |
|
197 | 197 |
scandata->limits = limits; |
198 | 198 |
if(!thrmgr_dispatch(multi_pool, scandata)) { |
199 | 199 |
logg("!multiscan: thread dispatch failed for multi_pool (file %s)\n", fname); |
... | ... |
@@ -228,7 +228,7 @@ static int multiscan(const char *dirname, const struct cl_node *root, const stru |
228 | 228 |
return 0; |
229 | 229 |
} |
230 | 230 |
|
231 |
-int command(int desc, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int timeout) |
|
231 |
+int command(int desc, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int timeout) |
|
232 | 232 |
{ |
233 | 233 |
char buff[1025]; |
234 | 234 |
int bread, opt; |
... | ... |
@@ -249,13 +249,13 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits |
249 | 249 |
cli_chomp(buff); |
250 | 250 |
|
251 | 251 |
if(!strncmp(buff, CMD1, strlen(CMD1))) { /* SCAN */ |
252 |
- if(scan(buff + strlen(CMD1) + 1, NULL, root, limits, options, copt, desc, 0) == -2) |
|
252 |
+ if(scan(buff + strlen(CMD1) + 1, NULL, engine, limits, options, copt, desc, 0) == -2) |
|
253 | 253 |
if(cfgopt(copt, "ExitOnOOM")->enabled) |
254 | 254 |
return COMMAND_SHUTDOWN; |
255 | 255 |
|
256 | 256 |
} else if(!strncmp(buff, CMD2, strlen(CMD2))) { /* RAWSCAN */ |
257 | 257 |
opt = options & ~CL_SCAN_ARCHIVE; |
258 |
- if(scan(buff + strlen(CMD2) + 1, NULL, root, NULL, opt, copt, desc, 0) == -2) |
|
258 |
+ if(scan(buff + strlen(CMD2) + 1, NULL, engine, NULL, opt, copt, desc, 0) == -2) |
|
259 | 259 |
if(cfgopt(copt, "ExitOnOOM")->enabled) |
260 | 260 |
return COMMAND_SHUTDOWN; |
261 | 261 |
|
... | ... |
@@ -270,7 +270,7 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits |
270 | 270 |
mdprintf(desc, "PONG\n"); |
271 | 271 |
|
272 | 272 |
} else if(!strncmp(buff, CMD6, strlen(CMD6))) { /* CONTSCAN */ |
273 |
- if(scan(buff + strlen(CMD6) + 1, NULL, root, limits, options, copt, desc, 1) == -2) |
|
273 |
+ if(scan(buff + strlen(CMD6) + 1, NULL, engine, limits, options, copt, desc, 1) == -2) |
|
274 | 274 |
if(cfgopt(copt, "ExitOnOOM")->enabled) |
275 | 275 |
return COMMAND_SHUTDOWN; |
276 | 276 |
|
... | ... |
@@ -304,7 +304,7 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits |
304 | 304 |
free(path); |
305 | 305 |
|
306 | 306 |
} else if(!strncmp(buff, CMD8, strlen(CMD8))) { /* STREAM */ |
307 |
- if(scanstream(desc, NULL, root, limits, options, copt) == CL_EMEM) |
|
307 |
+ if(scanstream(desc, NULL, engine, limits, options, copt) == CL_EMEM) |
|
308 | 308 |
if(cfgopt(copt, "ExitOnOOM")->enabled) |
309 | 309 |
return COMMAND_SHUTDOWN; |
310 | 310 |
|
... | ... |
@@ -320,7 +320,7 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits |
320 | 320 |
} else if(!strncmp(buff, CMD12, strlen(CMD12))) { /* FD */ |
321 | 321 |
int fd = atoi(buff + strlen(CMD12) + 1); |
322 | 322 |
|
323 |
- scanfd(fd, NULL, root, limits, options, copt, desc); |
|
323 |
+ scanfd(fd, NULL, engine, limits, options, copt, desc); |
|
324 | 324 |
close(fd); /* FIXME: should we close it here? */ |
325 | 325 |
|
326 | 326 |
} else if(!strncmp(buff, CMD13, strlen(CMD13))) { /* MULTISCAN */ |
... | ... |
@@ -345,14 +345,14 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits |
345 | 345 |
return -1; |
346 | 346 |
} |
347 | 347 |
|
348 |
- ret = multiscan(path, root, limits, options, copt, desc, &reclev, multi_pool); |
|
348 |
+ ret = multiscan(path, engine, limits, options, copt, desc, &reclev, multi_pool); |
|
349 | 349 |
thrmgr_destroy(multi_pool); |
350 | 350 |
|
351 | 351 |
if(ret < 0) |
352 | 352 |
return -1; |
353 | 353 |
|
354 | 354 |
} else { |
355 |
- ret = cl_scanfile(path, &virname, NULL, root, limits, options); |
|
355 |
+ ret = cl_scanfile(path, &virname, NULL, engine, limits, options); |
|
356 | 356 |
|
357 | 357 |
if(ret == CL_VIRUS) { |
358 | 358 |
mdprintf(desc, "%s: %s FOUND\n", path, virname); |
... | ... |
@@ -42,6 +42,6 @@ |
42 | 42 |
#include "libclamav/clamav.h" |
43 | 43 |
#include "shared/cfgparser.h" |
44 | 44 |
|
45 |
-int command(int desc, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int timeout); |
|
45 |
+int command(int desc, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int timeout); |
|
46 | 46 |
|
47 | 47 |
#endif |