minor code cleanup

git-svn: trunk@2656
remotes/push_mirror/metadata
Tomasz Kojm 19 years ago
parent 7a2997f190
commit a57e3d41e1
  1. 4
      clamav-devel/ChangeLog
  2. 10
      clamav-devel/clamd/clamd.c
  3. 2
      clamav-devel/clamd/clamuko.c
  4. 2
      clamav-devel/clamd/localserver.c
  5. 20
      clamav-devel/clamd/scanner.c
  6. 8
      clamav-devel/clamd/scanner.h
  7. 50
      clamav-devel/clamd/server-th.c
  8. 8
      clamav-devel/clamd/server.h
  9. 28
      clamav-devel/clamd/session.c
  10. 2
      clamav-devel/clamd/session.h

@ -1,3 +1,7 @@
Tue Jan 30 22:25:36 CET 2007 (tk)
---------------------------------
* clamd: minor code cleanup
Tue Jan 30 22:08:22 CET 2007 (tk) Tue Jan 30 22:08:22 CET 2007 (tk)
--------------------------------- ---------------------------------
* clamscan: code cleanup * clamscan: code cleanup

@ -88,7 +88,7 @@ int main(int argc, char **argv)
struct cfgstruct *copt, *cpt; struct cfgstruct *copt, *cpt;
struct passwd *user; struct passwd *user;
time_t currtime; time_t currtime;
struct cl_node *root = NULL; struct cl_engine *engine = NULL;
const char *dbdir, *cfgfile; const char *dbdir, *cfgfile;
int ret, tcpsock = 0, localsock = 0; int ret, tcpsock = 0, localsock = 0;
unsigned int sigs = 0; unsigned int sigs = 0;
@ -329,14 +329,14 @@ int main(int argc, char **argv)
#endif #endif
} }
if((ret = cl_load(dbdir, &root, &sigs, dboptions))) { if((ret = cl_load(dbdir, &engine, &sigs, dboptions))) {
logg("!%s\n", cl_strerror(ret)); logg("!%s\n", cl_strerror(ret));
logg_close(); logg_close();
freecfg(copt); freecfg(copt);
return 1; return 1;
} }
if(!root) { if(!engine) {
logg("!Database initialization error.\n"); logg("!Database initialization error.\n");
logg_close(); logg_close();
freecfg(copt); freecfg(copt);
@ -344,7 +344,7 @@ int main(int argc, char **argv)
} }
logg("#Loaded %d signatures.\n", sigs); logg("#Loaded %d signatures.\n", sigs);
if((ret = cl_build(root)) != 0) { if((ret = cl_build(engine)) != 0) {
logg("!Database initialization error: %s\n", cl_strerror(ret));; logg("!Database initialization error: %s\n", cl_strerror(ret));;
logg_close(); logg_close();
freecfg(copt); freecfg(copt);
@ -383,7 +383,7 @@ int main(int argc, char **argv)
nlsockets++; nlsockets++;
} }
ret = acceptloop_th(lsockets, nlsockets, root, dboptions, copt); ret = acceptloop_th(lsockets, nlsockets, engine, dboptions, copt);
#ifdef C_WINDOWS #ifdef C_WINDOWS
if(tcpsock) if(tcpsock)

@ -169,7 +169,7 @@ void *clamukoth(void *arg)
} }
} }
if(scan && cl_scanfile(acc->filename, &virname, NULL, tharg->root, tharg->limits, tharg->options) == CL_VIRUS) { if(scan && cl_scanfile(acc->filename, &virname, NULL, tharg->engine, tharg->limits, tharg->options) == CL_VIRUS) {
logg("Clamuko: %s: %s FOUND\n", acc->filename, virname); logg("Clamuko: %s: %s FOUND\n", acc->filename, virname);
virusaction(acc->filename, virname, tharg->copt); virusaction(acc->filename, virname, tharg->copt);
acc->deny = 1; acc->deny = 1;

@ -42,7 +42,7 @@
#include "output.h" #include "output.h"
#ifdef C_WINDOWS #ifdef C_WINDOWS
int localserver(const struct cfgstruct *copt, struct cl_node *root) int localserver(const struct cfgstruct *copt)
{ {
logg("!Localserver is not supported on this platform"); logg("!Localserver is not supported on this platform");
return -1; return -1;

@ -89,7 +89,7 @@ int checksymlink(const char *path)
} }
/* :set nowrap, if you don't like this style ;)) */ /* :set nowrap, if you don't like this style ;)) */
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) 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)
{ {
DIR *dd; DIR *dd;
struct dirent *dent; struct dirent *dent;
@ -139,7 +139,7 @@ int dirscan(const char *dirname, const char **virname, unsigned long int *scanne
/* stat the file */ /* stat the file */
if(lstat(fname, &statbuf) != -1) { if(lstat(fname, &statbuf) != -1) {
if((S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) || (S_ISLNK(statbuf.st_mode) && (checksymlink(fname) == 1) && cfgopt(copt, "FollowDirectorySymlinks")->enabled)) { if((S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) || (S_ISLNK(statbuf.st_mode) && (checksymlink(fname) == 1) && cfgopt(copt, "FollowDirectorySymlinks")->enabled)) {
if(dirscan(fname, virname, scanned, root, limits, options, copt, odesc, reclev, contscan) == 1) { if(dirscan(fname, virname, scanned, engine, limits, options, copt, odesc, reclev, contscan) == 1) {
free(fname); free(fname);
closedir(dd); closedir(dd);
return 1; return 1;
@ -152,7 +152,7 @@ int dirscan(const char *dirname, const char **virname, unsigned long int *scanne
scanret = CL_CLEAN; scanret = CL_CLEAN;
else else
#endif #endif
scanret = cl_scanfile(fname, virname, scanned, root, limits, options); scanret = cl_scanfile(fname, virname, scanned, engine, limits, options);
if(scanret == CL_VIRUS) { if(scanret == CL_VIRUS) {
@ -196,7 +196,7 @@ int dirscan(const char *dirname, const char **virname, unsigned long int *scanne
} }
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) 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)
{ {
struct stat sb; struct stat sb;
int ret = 0; int ret = 0;
@ -233,7 +233,7 @@ int scan(const char *filename, unsigned long int *scanned, const struct cl_node
ret = CL_CLEAN; ret = CL_CLEAN;
else else
#endif #endif
ret = cl_scanfile(filename, &virname, scanned, root, limits, options); ret = cl_scanfile(filename, &virname, scanned, engine, limits, options);
if(ret == CL_VIRUS) { if(ret == CL_VIRUS) {
mdprintf(odesc, "%s: %s FOUND\n", filename, virname); 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
} }
break; break;
case S_IFDIR: case S_IFDIR:
ret = dirscan(filename, &virname, scanned, root, limits, options, copt, odesc, &reclev, contscan); ret = dirscan(filename, &virname, scanned, engine, limits, options, copt, odesc, &reclev, contscan);
break; break;
default: default:
mdprintf(odesc, "%s: Not supported file type. ERROR\n", filename); 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
return ret; return ret;
} }
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) 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)
{ {
int ret; int ret;
const char *virname; const char *virname;
@ -279,7 +279,7 @@ int scanfd(const int fd, unsigned long int *scanned, const struct cl_node *root,
snprintf(fdstr, sizeof(fdstr), "fd[%d]", fd); snprintf(fdstr, sizeof(fdstr), "fd[%d]", fd);
ret = cl_scandesc(fd, &virname, scanned, root, limits, options); ret = cl_scandesc(fd, &virname, scanned, engine, limits, options);
if(ret == CL_VIRUS) { if(ret == CL_VIRUS) {
mdprintf(odesc, "%s: %s FOUND\n", fdstr, virname); 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,
return ret; return ret;
} }
int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt) 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)
{ {
int ret, portscan = 1000, sockfd, port = 0, acceptd; int ret, portscan = 1000, sockfd, port = 0, acceptd;
int tmpd, bread, retval, timeout, btread, min_port, max_port; 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
if(retval == 1) { if(retval == 1) {
lseek(tmpd, 0, SEEK_SET); lseek(tmpd, 0, SEEK_SET);
ret = cl_scandesc(tmpd, &virname, scanned, root, limits, options); ret = cl_scandesc(tmpd, &virname, scanned, engine, limits, options);
} else { } else {
ret = -1; ret = -1;
} }

@ -23,13 +23,13 @@
#include "libclamav/clamav.h" #include "libclamav/clamav.h"
#include "shared/cfgparser.h" #include "shared/cfgparser.h"
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); 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);
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); 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);
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); 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);
int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt); 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);
int checksymlink(const char *path); int checksymlink(const char *path);

@ -74,10 +74,10 @@ static struct cl_stat *dbstat = NULL;
typedef struct client_conn_tag { typedef struct client_conn_tag {
int sd; int sd;
int options; unsigned int options;
const struct cfgstruct *copt; const struct cfgstruct *copt;
struct cl_node *root; struct cl_engine *engine;
time_t root_timestamp; time_t engine_timestamp;
const struct cl_limits *limits; const struct cl_limits *limits;
int *socketds; int *socketds;
int nsockets; int nsockets;
@ -103,7 +103,7 @@ void scanner_thread(void *arg)
timeout = -1; timeout = -1;
do { do {
ret = command(conn->sd, conn->root, conn->limits, conn->options, conn->copt, timeout); ret = command(conn->sd, conn->engine, conn->limits, conn->options, conn->copt, timeout);
if (ret < 0) { if (ret < 0) {
break; break;
} }
@ -140,7 +140,7 @@ void scanner_thread(void *arg)
} }
pthread_mutex_unlock(&exit_mutex); pthread_mutex_unlock(&exit_mutex);
pthread_mutex_lock(&reload_mutex); pthread_mutex_lock(&reload_mutex);
if (conn->root_timestamp != reloaded_time) { if (conn->engine_timestamp != reloaded_time) {
session = FALSE; session = FALSE;
} }
pthread_mutex_unlock(&reload_mutex); pthread_mutex_unlock(&reload_mutex);
@ -148,7 +148,7 @@ void scanner_thread(void *arg)
} while (session); } while (session);
closesocket(conn->sd); closesocket(conn->sd);
cl_free(conn->root); cl_free(conn->engine);
free(conn); free(conn);
return; return;
} }
@ -178,7 +178,7 @@ void sighandler_th(int sig)
} }
} }
static struct cl_node *reload_db(struct cl_node *root, unsigned int dboptions, const struct cfgstruct *copt, int do_check, int *ret) static struct cl_engine *reload_db(struct cl_engine *engine, unsigned int dboptions, const struct cfgstruct *copt, int do_check, int *ret)
{ {
const char *dbdir; const char *dbdir;
int retval; int retval;
@ -188,12 +188,12 @@ static struct cl_node *reload_db(struct cl_node *root, unsigned int dboptions, c
if(do_check) { if(do_check) {
if(dbstat == NULL) { if(dbstat == NULL) {
logg("No stats for Database check - forcing reload\n"); logg("No stats for Database check - forcing reload\n");
return root; return engine;
} }
if(cl_statchkdir(dbstat) == 1) { if(cl_statchkdir(dbstat) == 1) {
logg("SelfCheck: Database modification detected. Forcing reload.\n"); logg("SelfCheck: Database modification detected. Forcing reload.\n");
return root; return engine;
} else { } else {
logg("SelfCheck: Database status OK.\n"); logg("SelfCheck: Database status OK.\n");
return NULL; return NULL;
@ -201,9 +201,9 @@ static struct cl_node *reload_db(struct cl_node *root, unsigned int dboptions, c
} }
/* release old structure */ /* release old structure */
if(root) { if(engine) {
cl_free(root); cl_free(engine);
root = NULL; engine = NULL;
} }
dbdir = cfgopt(copt, "DatabaseDirectory")->strarg; dbdir = cfgopt(copt, "DatabaseDirectory")->strarg;
@ -223,29 +223,29 @@ static struct cl_node *reload_db(struct cl_node *root, unsigned int dboptions, c
memset(dbstat, 0, sizeof(struct cl_stat)); memset(dbstat, 0, sizeof(struct cl_stat));
cl_statinidir(dbdir, dbstat); cl_statinidir(dbdir, dbstat);
if((retval = cl_load(dbdir, &root, &sigs, dboptions))) { if((retval = cl_load(dbdir, &engine, &sigs, dboptions))) {
logg("!reload db failed: %s\n", cl_strerror(retval)); logg("!reload db failed: %s\n", cl_strerror(retval));
*ret = 1; *ret = 1;
return NULL; return NULL;
} }
if(!root) { if(!engine) {
logg("!reload db failed: %s\n", cl_strerror(retval)); logg("!reload db failed: %s\n", cl_strerror(retval));
*ret = 1; *ret = 1;
return NULL; return NULL;
} }
if((retval = cl_build(root)) != 0) { if((retval = cl_build(engine)) != 0) {
logg("!Database initialization error: can't build engine: %s\n", cl_strerror(retval)); logg("!Database initialization error: can't build engine: %s\n", cl_strerror(retval));
*ret = 1; *ret = 1;
return NULL; return NULL;
} }
logg("Database correctly reloaded (%d signatures)\n", sigs); logg("Database correctly reloaded (%d signatures)\n", sigs);
return root; return engine;
} }
int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned int dboptions, const struct cfgstruct *copt) int acceptloop_th(int *socketds, int nsockets, struct cl_engine *engine, unsigned int dboptions, const struct cfgstruct *copt)
{ {
int new_sd, max_threads, i, ret = 0; int new_sd, max_threads, i, ret = 0;
unsigned int options = 0; unsigned int options = 0;
@ -459,7 +459,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in
tharg = (struct thrarg *) mmalloc(sizeof(struct thrarg)); tharg = (struct thrarg *) mmalloc(sizeof(struct thrarg));
tharg->copt = copt; tharg->copt = copt;
tharg->root = root; tharg->engine = engine;
tharg->limits = &limits; tharg->limits = &limits;
tharg->options = options; tharg->options = options;
@ -560,8 +560,8 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in
client_conn->sd = new_sd; client_conn->sd = new_sd;
client_conn->options = options; client_conn->options = options;
client_conn->copt = copt; client_conn->copt = copt;
client_conn->root = cl_dup(root); client_conn->engine = cl_dup(engine);
client_conn->root_timestamp = reloaded_time; client_conn->engine_timestamp = reloaded_time;
client_conn->limits = &limits; client_conn->limits = &limits;
client_conn->socketds = socketds; client_conn->socketds = socketds;
client_conn->nsockets = nsockets; client_conn->nsockets = nsockets;
@ -585,7 +585,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in
if(selfchk) { if(selfchk) {
time(&current_time); time(&current_time);
if((current_time - start_time) > (time_t)selfchk) { if((current_time - start_time) > (time_t)selfchk) {
if(reload_db(root, dboptions, copt, TRUE, &ret)) { if(reload_db(engine, dboptions, copt, TRUE, &ret)) {
pthread_mutex_lock(&reload_mutex); pthread_mutex_lock(&reload_mutex);
reload = 1; reload = 1;
pthread_mutex_unlock(&reload_mutex); pthread_mutex_unlock(&reload_mutex);
@ -597,7 +597,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in
pthread_mutex_lock(&reload_mutex); pthread_mutex_lock(&reload_mutex);
if(reload) { if(reload) {
pthread_mutex_unlock(&reload_mutex); pthread_mutex_unlock(&reload_mutex);
root = reload_db(root, dboptions, copt, FALSE, &ret); engine = reload_db(engine, dboptions, copt, FALSE, &ret);
if(ret) { if(ret) {
logg("Terminating because of a fatal error."); logg("Terminating because of a fatal error.");
if(new_sd >= 0) if(new_sd >= 0)
@ -613,7 +613,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in
logg("Stopping and restarting Clamuko.\n"); logg("Stopping and restarting Clamuko.\n");
pthread_kill(clamuko_pid, SIGUSR1); pthread_kill(clamuko_pid, SIGUSR1);
pthread_join(clamuko_pid, NULL); pthread_join(clamuko_pid, NULL);
tharg->root = root; tharg->engine = engine;
pthread_create(&clamuko_pid, &clamuko_attr, clamukoth, tharg); pthread_create(&clamuko_pid, &clamuko_attr, clamukoth, tharg);
} }
#endif #endif
@ -633,8 +633,8 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in
pthread_join(clamuko_pid, NULL); pthread_join(clamuko_pid, NULL);
} }
#endif #endif
if(root) if(engine)
cl_free(root); cl_free(engine);
if(dbstat) if(dbstat)
cl_statfree(dbstat); cl_statfree(dbstat);

@ -30,7 +30,7 @@ struct thrarg {
int sid; int sid;
int options; int options;
const struct cfgstruct *copt; const struct cfgstruct *copt;
const struct cl_node *root; const struct cl_engine *engine;
const struct cl_limits *limits; const struct cl_limits *limits;
}; };
@ -45,13 +45,13 @@ struct thrsession {
/* thread watcher arguments */ /* thread watcher arguments */
struct thrwarg { struct thrwarg {
int socketd; int socketd;
struct cl_node **root; struct cl_engine **engine;
const struct cfgstruct *copt; const struct cfgstruct *copt;
const struct cl_limits *limits; const struct cl_limits *limits;
int options; unsigned int options;
}; };
int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned int dboptions, const struct cfgstruct *copt); int acceptloop_th(int *socketds, int nsockets, struct cl_engine *engine, unsigned int dboptions, const struct cfgstruct *copt);
void sighandler(int sig); void sighandler(int sig);
void sighandler_th(int sig); void sighandler_th(int sig);
void daemonize(void); void daemonize(void);

@ -64,10 +64,10 @@ extern int progexit;
struct multi_tag { struct multi_tag {
int sd; int sd;
int options; unsigned int options;
const struct cfgstruct *copt; const struct cfgstruct *copt;
char *fname; char *fname;
const struct cl_node *root; const struct cl_engine *engine;
const struct cl_limits *limits; const struct cl_limits *limits;
}; };
@ -87,7 +87,7 @@ void multiscanfile(void *arg)
pthread_sigmask(SIG_SETMASK, &sigset, NULL); pthread_sigmask(SIG_SETMASK, &sigset, NULL);
#endif #endif
ret = cl_scanfile(tag->fname, &virname, NULL, tag->root, tag->limits, tag->options); ret = cl_scanfile(tag->fname, &virname, NULL, tag->engine, tag->limits, tag->options);
if(ret == CL_VIRUS) { if(ret == CL_VIRUS) {
mdprintf(tag->sd, "%s: %s FOUND\n", tag->fname, virname); mdprintf(tag->sd, "%s: %s FOUND\n", tag->fname, virname);
@ -105,7 +105,7 @@ void multiscanfile(void *arg)
return; return;
} }
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) 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)
{ {
DIR *dd; DIR *dd;
struct dirent *dent; struct dirent *dent;
@ -167,7 +167,7 @@ static int multiscan(const char *dirname, const struct cl_node *root, const stru
/* stat the file */ /* stat the file */
if(lstat(fname, &statbuf) != -1) { if(lstat(fname, &statbuf) != -1) {
if((S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) || (S_ISLNK(statbuf.st_mode) && (checksymlink(fname) == 1) && cfgopt(copt, "FollowDirectorySymlinks")->enabled)) { if((S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) || (S_ISLNK(statbuf.st_mode) && (checksymlink(fname) == 1) && cfgopt(copt, "FollowDirectorySymlinks")->enabled)) {
if(multiscan(fname, root, limits, options, copt, odesc, reclev, multi_pool) == -1) { if(multiscan(fname, engine, limits, options, copt, odesc, reclev, multi_pool) == -1) {
free(fname); free(fname);
closedir(dd); closedir(dd);
return -1; return -1;
@ -193,7 +193,7 @@ static int multiscan(const char *dirname, const struct cl_node *root, const stru
scandata->options = options; scandata->options = options;
scandata->copt = copt; scandata->copt = copt;
scandata->fname = fname; scandata->fname = fname;
scandata->root = root; scandata->engine = engine;
scandata->limits = limits; scandata->limits = limits;
if(!thrmgr_dispatch(multi_pool, scandata)) { if(!thrmgr_dispatch(multi_pool, scandata)) {
logg("!multiscan: thread dispatch failed for multi_pool (file %s)\n", fname); 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
return 0; return 0;
} }
int command(int desc, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int timeout) int command(int desc, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int timeout)
{ {
char buff[1025]; char buff[1025];
int bread, opt; int bread, opt;
@ -249,13 +249,13 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits
cli_chomp(buff); cli_chomp(buff);
if(!strncmp(buff, CMD1, strlen(CMD1))) { /* SCAN */ if(!strncmp(buff, CMD1, strlen(CMD1))) { /* SCAN */
if(scan(buff + strlen(CMD1) + 1, NULL, root, limits, options, copt, desc, 0) == -2) if(scan(buff + strlen(CMD1) + 1, NULL, engine, limits, options, copt, desc, 0) == -2)
if(cfgopt(copt, "ExitOnOOM")->enabled) if(cfgopt(copt, "ExitOnOOM")->enabled)
return COMMAND_SHUTDOWN; return COMMAND_SHUTDOWN;
} else if(!strncmp(buff, CMD2, strlen(CMD2))) { /* RAWSCAN */ } else if(!strncmp(buff, CMD2, strlen(CMD2))) { /* RAWSCAN */
opt = options & ~CL_SCAN_ARCHIVE; opt = options & ~CL_SCAN_ARCHIVE;
if(scan(buff + strlen(CMD2) + 1, NULL, root, NULL, opt, copt, desc, 0) == -2) if(scan(buff + strlen(CMD2) + 1, NULL, engine, NULL, opt, copt, desc, 0) == -2)
if(cfgopt(copt, "ExitOnOOM")->enabled) if(cfgopt(copt, "ExitOnOOM")->enabled)
return COMMAND_SHUTDOWN; return COMMAND_SHUTDOWN;
@ -270,7 +270,7 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits
mdprintf(desc, "PONG\n"); mdprintf(desc, "PONG\n");
} else if(!strncmp(buff, CMD6, strlen(CMD6))) { /* CONTSCAN */ } else if(!strncmp(buff, CMD6, strlen(CMD6))) { /* CONTSCAN */
if(scan(buff + strlen(CMD6) + 1, NULL, root, limits, options, copt, desc, 1) == -2) if(scan(buff + strlen(CMD6) + 1, NULL, engine, limits, options, copt, desc, 1) == -2)
if(cfgopt(copt, "ExitOnOOM")->enabled) if(cfgopt(copt, "ExitOnOOM")->enabled)
return COMMAND_SHUTDOWN; return COMMAND_SHUTDOWN;
@ -304,7 +304,7 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits
free(path); free(path);
} else if(!strncmp(buff, CMD8, strlen(CMD8))) { /* STREAM */ } else if(!strncmp(buff, CMD8, strlen(CMD8))) { /* STREAM */
if(scanstream(desc, NULL, root, limits, options, copt) == CL_EMEM) if(scanstream(desc, NULL, engine, limits, options, copt) == CL_EMEM)
if(cfgopt(copt, "ExitOnOOM")->enabled) if(cfgopt(copt, "ExitOnOOM")->enabled)
return COMMAND_SHUTDOWN; return COMMAND_SHUTDOWN;
@ -320,7 +320,7 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits
} else if(!strncmp(buff, CMD12, strlen(CMD12))) { /* FD */ } else if(!strncmp(buff, CMD12, strlen(CMD12))) { /* FD */
int fd = atoi(buff + strlen(CMD12) + 1); int fd = atoi(buff + strlen(CMD12) + 1);
scanfd(fd, NULL, root, limits, options, copt, desc); scanfd(fd, NULL, engine, limits, options, copt, desc);
close(fd); /* FIXME: should we close it here? */ close(fd); /* FIXME: should we close it here? */
} else if(!strncmp(buff, CMD13, strlen(CMD13))) { /* MULTISCAN */ } 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
return -1; return -1;
} }
ret = multiscan(path, root, limits, options, copt, desc, &reclev, multi_pool); ret = multiscan(path, engine, limits, options, copt, desc, &reclev, multi_pool);
thrmgr_destroy(multi_pool); thrmgr_destroy(multi_pool);
if(ret < 0) if(ret < 0)
return -1; return -1;
} else { } else {
ret = cl_scanfile(path, &virname, NULL, root, limits, options); ret = cl_scanfile(path, &virname, NULL, engine, limits, options);
if(ret == CL_VIRUS) { if(ret == CL_VIRUS) {
mdprintf(desc, "%s: %s FOUND\n", path, virname); mdprintf(desc, "%s: %s FOUND\n", path, virname);

@ -42,6 +42,6 @@
#include "libclamav/clamav.h" #include "libclamav/clamav.h"
#include "shared/cfgparser.h" #include "shared/cfgparser.h"
int command(int desc, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int timeout); int command(int desc, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt, int timeout);
#endif #endif

Loading…
Cancel
Save