本文整理汇总了C++中cl_strerror函数的典型用法代码示例。如果您正苦于以下问题:C++ cl_strerror函数的具体用法?C++ cl_strerror怎么用?C++ cl_strerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cl_strerror函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: load_db
/* Must be called with engine_mutex locked ! */
static int load_db(void) {
unsigned int signo = 0;
size_t used, total;
int ret;
INFN();
cl_engine_set_clcb_sigload(engine, sigload_callback, NULL);
official_sigs = custom_sigs = 0;
if((ret = cl_load(dbdir, engine, &signo, CL_DB_STDOPT & ~CL_DB_PHISHING & ~CL_DB_PHISHING_URLS)) != CL_SUCCESS) {
cl_engine_free(engine);
engine = NULL;
FAIL(ret, "Failed to load database: %s", cl_strerror(ret));
}
if((ret = cl_engine_compile(engine))) {
cl_engine_free(engine);
engine = NULL;
FAIL(ret, "Failed to compile engine: %s", cl_strerror(ret));
}
logg("load_db: loaded %d signatures (%u official, %u custom)\n", signo, official_sigs, custom_sigs);
if (!mpool_getstats(engine, &used, &total))
logg("load_db: memory %.3f MB / %.3f MB\n", used/(1024*1024.0), total/(1024*1024.0));
touch_last_update(signo);
WIN();
}
开发者ID:Yuyue,项目名称:clamav-devel,代码行数:31,代码来源:interface.c
示例2: clamav_scanfile
int clamav_scanfile(void *state, const char *fname,
const char **virname)
{
struct clamav_state *st = (struct clamav_state *) state;
int r;
/* scan file */
r = cl_scanfile(fname, virname, NULL, st->av_engine,
CL_SCAN_STDOPT);
switch (r) {
case CL_CLEAN:
/* do nothing */
break;
case CL_VIRUS:
return 1;
break;
default:
printf("cl_scanfile error: %s\n", cl_strerror(r));
syslog(LOG_ERR, "cl_scanfile error: %s\n", cl_strerror(r));
break;
}
return 0;
}
开发者ID:ajwans,项目名称:cyrus-imapd,代码行数:26,代码来源:cyr_virusscan.c
示例3: clamav_load_database
static int clamav_load_database()
{
int ret = 0; /* return value */
int reload = 0;
/* libclamav initialization */
if (CLAMAV_G(cl_initcalled) == 0){
if((ret = cl_init(CL_INIT_DEFAULT)) != CL_SUCCESS) {
php_error(E_WARNING, "cl_init: failed : error code %i (%s)\n", ret, cl_strerror(ret));
return FAILURE;
} else {
CLAMAV_G(cl_initcalled) = 1;
}
}
/* database reload */
if (CLAMAV_G(dbstat.dir) != NULL && cl_statchkdir(&CLAMAV_G(dbstat)) == 1) {
reload = 1;
cl_statfree(&CLAMAV_G(dbstat));
}
/* load engine */
if (!(CLAMAV_G(dbengine) = cl_engine_new())){
php_error(E_WARNING, "Can’t create new engine\n");
return FAILURE;
}
if (CLAMAV_G(dbpath) == NULL) CLAMAV_G(dbpath) = (char *) cl_retdbdir();
/* database loading */
if ((ret = cl_load(CLAMAV_G(dbpath), CLAMAV_G(dbengine), &CLAMAV_G(sig_num), CL_DB_STDOPT)) != CL_SUCCESS) {
php_error(E_WARNING, "cl_load: failed : error code %i (%s)\n", ret, cl_strerror(ret));
return FAILURE;
}
/* compile signature database */
if ((ret = cl_engine_compile(CLAMAV_G(dbengine))) != CL_SUCCESS) {
php_error(E_WARNING, "cl_engine_compile : error code %i (%s\n", ret, cl_strerror(ret));
return FAILURE;
}
/* allocate cl_stat */
if (!reload) memset(&CLAMAV_G(dbstat), 0, sizeof(struct cl_stat));
/* database stats */
if ((ret = cl_statinidir(CLAMAV_G(dbpath), &CLAMAV_G(dbstat))) != CL_SUCCESS) {
php_error(E_WARNING, "cl_statinidir : error code %i (%s\n", ret, cl_strerror(ret));
return FAILURE;
}
/* set engine parameters */
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_MAX_FILES, CLAMAV_G(maxfiles));
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_MAX_FILESIZE, CLAMAV_G(maxfilesize));
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_MAX_SCANSIZE, CLAMAV_G(maxscansize));
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_MAX_RECURSION, CLAMAV_G(maxreclevel));
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_KEEPTMP, CLAMAV_G(keeptmp));
cl_engine_set_str(CLAMAV_G(dbengine), CL_ENGINE_TMPDIR, CLAMAV_G(tmpdir));
return ret;
}
开发者ID:argos66,项目名称:php-clamav,代码行数:60,代码来源:clamav.c
示例4: cl_init
VirusScan::VirusScan(TrayNotify *tn)
{
numSignatures = 0;
fTypes[0] = ".EXE";
fTypes[1] = ".BAT";
fTypes[2] = ".BIN";
fTypes[3] = ".DLL";
fTypes[4] = ".COM";
fTypes[5] = ".INF";
fTypes[6] = ".INI";
fTypes[7] = ".PDF";
fTypes[8] = ".DOC";
fTypes[9] = ".DOCX";
fTypes[10] = ".PPT";
fTypes[11] = ".PPTX";
fTypes[12] = ".SYS";
fTypes[13] = ".VBS";
/* Init AV engine */
int res = cl_init(0);
cl = cl_engine_new();
if (res != CL_SUCCESS)
{
ErrorLog::logErrorToFile("*CRITICAL*", "Unable to initialize AV engine: ", (char*)cl_strerror(res));
std::cout << cl_strerror(res);
return;
}
res = cl_load(cl_retdbdir(), cl, &numSignatures, CL_DB_STDOPT);
if (res != CL_SUCCESS)
{
ErrorLog::logErrorToFile("*CRITICAL*", "Unable to load AV engine signatures. Check for db folder?: ", (char*)cl_strerror(res));
std::cout << cl_strerror(res);
return;
}
res = cl_engine_compile(cl);
if (res != CL_SUCCESS)
{
ErrorLog::logErrorToFile("*CRITICAL*", "Unable to compile AV engine rules: ", (char*)cl_strerror(res));
std::cout << cl_strerror(res);
return;
}
char msgStr[100];
sprintf(msgStr, "ClamAV engine initialized. %d signatures loaded.", numSignatures);
ErrorLog::logErrorToFile("*INFO*", msgStr);
tn->sendMessage(msgStr, "ClamAV");
tn->setHoverMessage("UsbNinja Daemon\nClamAV Loaded");
}
开发者ID:gfoudree,项目名称:usbninja,代码行数:52,代码来源:virusscan.cpp
示例5: init_errors
int init_errors(void) {
int i;
logg("*in init_errors\n");
clerrors = calloc(CL_ELAST_ERROR, sizeof(*clerrors));
if(!clerrors) {
logg("!init_errors: failed to allocate the error array, aborting\n");
return 1;
}
for(i=0; i<CL_ELAST_ERROR; i++) {
const char *cerr = cl_strerror(i);
wchar_t *werr;
int len;
if(!cerr)
continue;
len = strlen(cerr)+1;
werr = (wchar_t *)malloc(len * sizeof(wchar_t));
if(!werr) {
free_errors();
logg("!init_errors: failed to allocate string buffer, aborting\n");
return 1;
}
if(!MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cerr, -1, werr, len)) {
free_errors();
logg("!init_errors: failed to convert ascii error <%s> to wide, aborting\n", cerr);
return 1;
}
logg("*init_errors: error %d is %S\n", i, werr);
clerrors[i] = werr;
}
return 0;
}
开发者ID:rossguide,项目名称:clamav-devel,代码行数:33,代码来源:iface_errors.c
示例6: Scan_SetLimit
int CLAMAPI Scan_SetLimit(int option, unsigned int value) {
enum cl_engine_field limit;
int err;
INFN();
if(lock_engine())
FAIL(CL_ELOCK, "Failed to lock engine");
if(!engine) {
unlock_engine();
FAIL(CL_ESTATE, "Engine is NULL");
}
switch((enum CLAM_LIMIT_TYPE)option) {
case CLAM_LIMIT_FILESIZE:
logg("CLAM_LIMIT_FILESIZE: set to %u\n", value);
limit = CL_ENGINE_MAX_FILESIZE;
break;
case CLAM_LIMIT_SCANSIZE:
logg("CLAM_LIMIT_SCANSIZE: set to %u\n", value);
limit = CL_ENGINE_MAX_SCANSIZE;
break;
case CLAM_LIMIT_RECURSION:
logg("CLAM_LIMIT_RECURSION: set to %u\n", value);
limit = CL_ENGINE_MAX_SCANSIZE;
break;
default:
unlock_engine();
FAIL(CL_EARG, "Unsupported limit type: %d", option);
}
err = cl_engine_set_num(engine, limit, (long long)value);
unlock_engine();
if(err)
FAIL(err, "Failed to set engine value: %s", cl_strerror(err));
WIN();
}
开发者ID:Yuyue,项目名称:clamav-devel,代码行数:34,代码来源:interface.c
示例7: xzmalloc
void *clamav_init()
{
unsigned int sigs = 0;
int r;
struct clamav_state *st = xzmalloc(sizeof(struct clamav_state));
if (st == NULL) {
fatal("memory allocation failed", EC_SOFTWARE);
}
st->av_engine = cl_engine_new();
if ( ! st->av_engine ) {
fatal("Failed to initialize AV engine", EC_SOFTWARE);
}
/* load all available databases from default directory */
if ((r = cl_load(cl_retdbdir(), st->av_engine, &sigs, CL_DB_STDOPT))) {
syslog(LOG_ERR, "cl_load: %s", cl_strerror(r));
fatal(cl_strerror(r), EC_SOFTWARE);
}
if (verbose) printf("Loaded %d virus signatures.\n", sigs);
/* build av_engine */
if((r = cl_engine_compile(st->av_engine))) {
syslog(LOG_ERR,
"Database initialization error: %s", cl_strerror(r));
cl_engine_free(st->av_engine);
fatal(cl_strerror(r), EC_SOFTWARE);
}
/* set up archive av_limits */
/* max files */
cl_engine_set_num(st->av_engine, CL_ENGINE_MAX_FILES, 10000);
/* during the scanning of archives, this size (100 MB) will
* never be exceeded
*/
cl_engine_set_num(st->av_engine, CL_ENGINE_MAX_SCANSIZE, 100 * 1048576);
/* compressed files will only be decompressed and scanned up to
* this size (10 MB)
*/
cl_engine_set_num(st->av_engine, CL_ENGINE_MAX_FILESIZE, 10 * 1048576);
/* maximum recursion level for archives */
cl_engine_set_num(st->av_engine, CL_ENGINE_MAX_RECURSION, 16);
return (void *) st;
}
开发者ID:ajwans,项目名称:cyrus-imapd,代码行数:47,代码来源:cyr_virusscan.c
示例8: Scan_GetLimit
int CLAMAPI Scan_GetLimit(int option, unsigned int *value) {
enum cl_engine_field limit;
long long curlimit;
int err;
INFN();
if(lock_engine())
FAIL(CL_ELOCK, "Failed to lock engine");
if(!engine) {
unlock_engine();
FAIL(CL_ESTATE, "Engine is NULL");
}
switch((enum CLAM_LIMIT_TYPE)option) {
case CLAM_LIMIT_FILESIZE:
limit = CL_ENGINE_MAX_FILESIZE;
break;
case CLAM_LIMIT_SCANSIZE:
limit = CL_ENGINE_MAX_SCANSIZE;
break;
case CLAM_LIMIT_RECURSION:
limit = CL_ENGINE_MAX_SCANSIZE;
break;
default:
unlock_engine();
FAIL(CL_EARG, "Unsupported limit type: %d", option);
}
curlimit = cl_engine_get_num(engine, limit, &err);
if(err) {
unlock_engine();
FAIL(err, "Failed to get engine value: %s", cl_strerror(err));
}
if(curlimit > 0xffffffff)
*value = 0xffffffff;
else
*value = (unsigned int)curlimit;
unlock_engine();
WIN();
}
开发者ID:Yuyue,项目名称:clamav-devel,代码行数:38,代码来源:interface.c
示例9: START_TEST
END_TEST
//* int cl_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options) */
START_TEST (test_cl_scanfile)
{
const char *virname = NULL;
char file[256];
unsigned long size;
unsigned long int scanned = 0;
int ret;
int fd = get_test_file(_i, file, sizeof(file), &size);
close(fd);
cli_dbgmsg("scanning (scanfile) %s\n", file);
ret = cl_scanfile(file, &virname, &scanned, g_engine, CL_SCAN_STDOPT);
cli_dbgmsg("scan end (scanfile) %s\n", file);
if (!FALSE_NEGATIVE) {
fail_unless_fmt(ret == CL_VIRUS , "cl_scanfile failed for %s: %s", file, cl_strerror(ret));
fail_unless_fmt(virname && !strcmp(virname, "ClamAV-Test-File.UNOFFICIAL"), "virusname: %s", virname);
}
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:23,代码来源:check_clamav.c
示例10: init_virusdb
int init_virusdb()
{
int ret;
unsigned int no = 0;
virusdb = malloc(sizeof(struct virus_db));
memset(virusdb, 0, sizeof(struct virus_db));
if (!virusdb)
return 0;
#ifdef HAVE_LIBCLAMAV_095
if((ret = cl_init(CL_INIT_DEFAULT))) {
ci_debug_printf(1, "!Can't initialize libclamav: %s\n", cl_strerror(ret));
return 0;
}
if(!(virusdb->db = cl_engine_new())) {
ci_debug_printf(1, "Clamav DB load: Cannot create new clamav engine\n");
return 0;
}
if ((ret = cl_load(cl_retdbdir(), virusdb->db, &no, CL_DB_STDOPT))) {
ci_debug_printf(1, "Clamav DB load: cl_load failed: %s\n",
cl_strerror(ret));
#elif defined(HAVE_LIBCLAMAV_09X)
if ((ret = cl_load(cl_retdbdir(), &(virusdb->db), &no, CL_DB_STDOPT))) {
ci_debug_printf(1, "Clamav DB load: cl_load failed: %s\n",
cl_strerror(ret));
#else
if ((ret = cl_loaddbdir(cl_retdbdir(), &(virusdb->db), &no))) {
ci_debug_printf(1, "cl_loaddbdir: %s\n", cl_perror(ret));
#endif
return 0;
}
#ifdef HAVE_LIBCLAMAV_095
if ((ret = cl_engine_compile(virusdb->db))) {
#else
if ((ret = cl_build(virusdb->db))) {
#endif
ci_debug_printf(1, "Database initialization error: %s\n",
cl_strerror(ret));
#ifdef HAVE_LIBCLAMAV_095
cl_engine_free(virusdb->db);
#else
cl_free(virusdb->db);
#endif
free(virusdb);
virusdb = NULL;
return 0;
}
ci_thread_mutex_init(&db_mutex);
virusdb->refcount = 1;
old_virusdb = NULL;
return 1;
}
/*
Instead of using struct virus_db and refcount's someone can use the cl_dup function
of clamav library, but it is undocumented so I did not use it.
The following implementation we are starting to reload clamav db while threads are
scanning for virus but we are not allow any child to start a new scan until we are
loading DB.
*/
/*#define DB_NO_FULL_LOCK 1*/
#undef DB_NO_FULL_LOCK
int reload_virusdb()
{
struct virus_db *vdb = NULL;
int ret;
unsigned int no = 0;
ci_thread_mutex_lock(&db_mutex);
if (old_virusdb) {
ci_debug_printf(1, "Clamav DB reload pending, cancelling.\n");
ci_thread_mutex_unlock(&db_mutex);
return 0;
}
#ifdef DB_NO_FULL_LOCK
ci_thread_mutex_unlock(&db_mutex);
#endif
vdb = malloc(sizeof(struct virus_db));
if (!vdb)
return 0;
memset(vdb, 0, sizeof(struct virus_db));
ci_debug_printf(9, "db_reload going to load db\n");
#ifdef HAVE_LIBCLAMAV_095
if(!(vdb->db = cl_engine_new())) {
ci_debug_printf(1, "Clamav DB load: Cannot create new clamav engine\n");
return 0;
}
if ((ret = cl_load(cl_retdbdir(), vdb->db, &no, CL_DB_STDOPT))) {
ci_debug_printf(1, "Clamav DB reload: cl_load failed: %s\n",
cl_strerror(ret));
#elif defined(HAVE_LIBCLAMAV_09X)
if ((ret = cl_load(cl_retdbdir(), &(vdb->db), &no, CL_DB_STDOPT))) {
ci_debug_printf(1, "Clamav DB reload: cl_load failed: %s\n",
cl_strerror(ret));
#else
if ((ret = cl_loaddbdir(cl_retdbdir(), &(vdb->db), &no))) {
ci_debug_printf(1, "Clamav DB reload: cl_loaddbdir failed: %s\n",
cl_perror(ret));
#endif
return 0;
//.........这里部分代码省略.........
开发者ID:p1rate5s,项目名称:c-icap,代码行数:101,代码来源:srv_clamav.c
示例11: main
int main(int argc, char *argv[])
{
FILE *f;
struct cli_bc *bc;
struct cli_bc_ctx *ctx;
int rc, dbgargc, bc_stats=0;
struct optstruct *opts;
const struct optstruct *opt;
unsigned funcid=0, i;
struct cli_all_bc bcs;
int fd = -1;
unsigned tracelevel;
if(check_flevel())
exit(1);
opts = optparse(NULL, argc, argv, 1, OPT_CLAMBC, 0, NULL);
if (!opts) {
fprintf(stderr, "ERROR: Can't parse command line options\n");
exit(1);
}
if(optget(opts, "version")->enabled) {
printf("Clam AntiVirus Bytecode Testing Tool %s\n", get_version());
cl_init(CL_INIT_DEFAULT);
cli_bytecode_printversion();
optfree(opts);
exit(0);
}
if(optget(opts, "help")->enabled || !opts->filename) {
optfree(opts);
help();
exit(0);
}
f = fopen(opts->filename[0], "r");
if (!f) {
fprintf(stderr, "Unable to load %s\n", argv[1]);
optfree(opts);
exit(2);
}
bc = malloc(sizeof(*bc));
if (!bc) {
fprintf(stderr, "Out of memory\n");
optfree(opts);
exit(3);
}
if (optget(opts,"debug")->enabled) {
cl_debug();
debug_flag=1;
}
rc = cl_init(CL_INIT_DEFAULT);
if (rc != CL_SUCCESS) {
fprintf(stderr,"Unable to init libclamav: %s\n", cl_strerror(rc));
optfree(opts);
exit(4);
}
dbgargc=1;
while (opts->filename[dbgargc]) dbgargc++;
if (dbgargc > 1)
cli_bytecode_debug(dbgargc, opts->filename);
if (optget(opts, "force-interpreter")->enabled) {
bcs.engine = NULL;
} else {
rc = cli_bytecode_init(&bcs);
if (rc != CL_SUCCESS) {
fprintf(stderr,"Unable to init bytecode engine: %s\n", cl_strerror(rc));
optfree(opts);
exit(4);
}
}
bcs.all_bcs = bc;
bcs.count = 1;
if((opt = optget(opts, "statistics"))->enabled) {
while(opt) {
if (!strcasecmp(opt->strarg, "bytecode"))
bc_stats=1;
opt = opt->nextarg;
}
}
rc = cli_bytecode_load(bc, f, NULL, optget(opts, "trust-bytecode")->enabled, bc_stats);
if (rc != CL_SUCCESS) {
fprintf(stderr,"Unable to load bytecode: %s\n", cl_strerror(rc));
optfree(opts);
exit(4);
}
fclose(f);
if (bc->state == bc_skip) {
fprintf(stderr,"bytecode load skipped\n");
exit(0);
}
if (debug_flag)
printf("[clambc] Bytecode loaded\n");
if (optget(opts, "info")->enabled) {
//.........这里部分代码省略.........
开发者ID:vrtadmin,项目名称:clamav-devel,代码行数:101,代码来源:bcrun.c
示例12: submitstats
//.........这里部分代码省略.........
int status;
waitpid(pid, &status, 0);
if (! WIFEXITED(status) || WEXITSTATUS(status) != 0) {
logg("!getfile: Filter failed\n");
return 57;
}
}
#endif
if(totalsize > 0)
logg("Downloading %s [%i%%]\n", srcfile, percentage);
else
logg("Downloading %s [*]\n", srcfile);
mirman_update(mdat->currip, mdat->af, mdat, 0);
return 0;
}
static int getcvd(const char *cvdfile, const char *newfile, const char *hostname, char *ip, const char *localip, const char *proxy, int port, const char *user, const char *pass, const char *uas, unsigned int newver, int ctimeout, int rtimeout, struct mirdat *mdat, int logerr, unsigned int can_whitelist)
{
struct cl_cvd *cvd;
int ret;
logg("*Retrieving http://%s/%s\n", hostname, cvdfile);
if((ret = getfile(cvdfile, newfile, hostname, ip, localip, proxy, port, user, pass, uas, ctimeout, rtimeout, mdat, logerr, can_whitelist))) {
logg("%cCan't download %s from %s\n", logerr ? '!' : '^', cvdfile, hostname);
unlink(newfile);
return ret;
}
if((ret = cl_cvdverify(newfile))) {
logg("!Verification: %s\n", cl_strerror(ret));
unlink(newfile);
return 54;
}
if(!(cvd = cl_cvdhead(newfile))) {
logg("!Can't read CVD header of new %s database.\n", cvdfile);
unlink(newfile);
return 54;
}
if(cvd->version < newver) {
logg("^Mirror %s is not synchronized.\n", ip);
mirman_update(mdat->currip, mdat->af, mdat, 2);
cl_cvdfree(cvd);
unlink(newfile);
return 59;
}
cl_cvdfree(cvd);
return 0;
}
static int chdir_tmp(const char *dbname, const char *tmpdir)
{
char cvdfile[32];
if(access(tmpdir, R_OK|W_OK) == -1) {
sprintf(cvdfile, "%s.cvd", dbname);
if(access(cvdfile, R_OK) == -1) {
sprintf(cvdfile, "%s.cld", dbname);
if(access(cvdfile, R_OK) == -1) {
开发者ID:OPSF,项目名称:uClinux,代码行数:67,代码来源:manager.c
示例13: scanfile
//.........这里部分代码省略.........
logg("~%s: Excluded\n", filename);
return;
}
}
/* argh, don't scan /proc files */
if(CLAMSTAT(filename, &sb) != -1) {
#ifdef C_LINUX
if(procdev && sb.st_dev == procdev) {
if(!printinfected)
logg("~%s: Excluded (/proc)\n", filename);
return;
}
#endif
if(!sb.st_size) {
if(!printinfected)
logg("~%s: Empty file\n", filename);
return;
}
info.rblocks += sb.st_size / CL_COUNT_PRECISION;
}
#ifndef _WIN32
if(geteuid()) {
if(checkaccess(filename, NULL, R_OK) != 1) {
if(!printinfected)
logg("~%s: Access denied\n", filename);
info.errors++;
return;
}
}
#endif
memset(&chain, 0, sizeof(chain));
if(optget(opts, "archive-verbose")->enabled) {
chain.chains = malloc(sizeof(char **));
if (chain.chains) {
chain.chains[0] = strdup(filename);
if (!chain.chains[0]) {
free(chain.chains);
logg("Unable to allocate memory in scanfile()\n");
info.errors++;
return;
}
chain.nchains = 1;
}
}
logg("*Scanning %s\n", filename);
if((fd = safe_open(filename, O_RDONLY|O_BINARY)) == -1) {
logg("^Can't open file %s: %s\n", filename, strerror(errno));
info.errors++;
return;
}
data.chain = &chain;
data.filename = filename;
if((ret = cl_scandesc_callback(fd, &virname, &info.blocks, engine, options, &data)) == CL_VIRUS) {
if(optget(opts, "archive-verbose")->enabled) {
if (chain.nchains > 1) {
char str[128];
int toolong = print_chain(&chain, str, sizeof(str));
logg("~%s%s!(%llu)%s: %s FOUND\n", str, toolong ? "..." : "", (long long unsigned)(chain.lastvir-1), chain.chains[chain.nchains-1], virname);
} else if (chain.lastvir) {
logg("~%s!(%llu): %s FOUND\n", filename, (long long unsigned)(chain.lastvir-1), virname);
}
}
info.files++;
info.ifiles++;
if(bell)
fprintf(stderr, "\007");
} else if(ret == CL_CLEAN) {
if(!printinfected && printclean)
mprintf("~%s: OK\n", filename);
info.files++;
} else {
if(!printinfected)
logg("~%s: %s ERROR\n", filename, cl_strerror(ret));
info.errors++;
}
for (i=0;i<chain.nchains;i++)
free(chain.chains[i]);
free(chain.chains);
close(fd);
if(ret == CL_VIRUS && action)
action(filename);
}
开发者ID:lattera,项目名称:clamav-devel,代码行数:101,代码来源:manager.c
示例14: main
//.........这里部分代码省略.........
/* initialize logger */
logg_lock = !optget(opts, "LogFileUnlock")->enabled;
logg_time = optget(opts, "LogTime")->enabled;
logok = optget(opts, "LogClean")->enabled;
logg_size = optget(opts, "LogFileMaxSize")->numarg;
logg_verbose = mprintf_verbose = optget(opts, "LogVerbose")->enabled;
if (logg_size)
logg_rotate = optget(opts, "LogRotate")->enabled;
mprintf_send_timeout = optget(opts, "SendBufTimeout")->numarg;
do { /* logger initialized */
if((opt = optget(opts, "LogFile"))->enabled) {
char timestr[32];
logg_file = opt->strarg;
if(!cli_is_abspath(logg_file)) {
fprintf(stderr, "ERROR: LogFile requires full path.\n");
ret = 1;
break;
}
time(&currtime);
if(logg("#+++ Started at %s", cli_ctime(&currtime, timestr, sizeof(timestr)))) {
fprintf(stderr, "ERROR: Can't initialize the internal logger\n");
ret = 1;
break;
}
} else
logg_file = NULL;
if (optget(opts,"DevLiblog")->enabled)
cl_set_clcb_msg(msg_callback);
if((ret = cl_init(CL_INIT_DEFAULT))) {
logg("!Can't initialize libclamav: %s\n", cl_strerror(ret));
ret = 1;
break;
}
if(optget(opts, "Debug")->enabled) /* enable debug messages in libclamav */ {
cl_debug();
logg_verbose = 2;
}
#if defined(USE_SYSLOG) && !defined(C_AIX)
if(optget(opts, "LogSyslog")->enabled) {
int fac = LOG_LOCAL6;
opt = optget(opts, "LogFacility");
if((fac = logg_facility(opt->strarg)) == -1) {
logg("!LogFacility: %s: No such facility.\n", opt->strarg);
ret = 1;
break;
}
openlog("clamd", LOG_PID, fac);
logg_syslog = 1;
}
#endif
#ifdef C_LINUX
procdev = 0;
if(CLAMSTAT("/proc", &sb) != -1 && !sb.st_size)
procdev = sb.st_dev;
#endif
/* check socket type */
开发者ID:bknowles,项目名称:clamav-devel,代码行数:67,代码来源:clamd.c
示例15: Scan_Initialize
int CLAMAPI Scan_Initialize(const wchar_t *pEnginesFolder, const wchar_t *pTempRoot, const wchar_t *pLicenseKey, BOOL bLoadMinDefs) {
BOOL cant_convert;
int ret;
logg("*in Scan_Initialize(pEnginesFolder = %S, pTempRoot = %S)\n", pEnginesFolder, pTempRoot);
if(!pEnginesFolder)
FAIL(CL_ENULLARG, "pEnginesFolder is NULL");
if(!pTempRoot)
FAIL(CL_ENULLARG, "pTempRoot is NULL");
if(lock_engine())
FAIL(CL_ELOCK, "failed to lock engine");
if(engine) {
unlock_engine();
FAIL(CL_ESTATE, "Already initialized");
}
if(!(engine = cl_engine_new())) {
unlock_engine();
FAIL(CL_EMEM, "Not enough memory for a new engine");
}
cl_engine_set_clcb_pre_cache(engine, filetype_cb);
cl_engine_set_clcb_pre_scan(engine, prescan_cb);
cl_engine_set_clcb_post_scan(engine, postscan_cb);
minimal_definitions = bLoadMinDefs;
if(bLoadMinDefs)
logg("^MINIMAL DEFINITIONS MODE ON!\n");
if(!WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, pTempRoot, -1, tmpdir, sizeof(tmpdir), NULL, &cant_convert) || cant_convert) {
free_engine_and_unlock();
FAIL(CL_EARG, "Can't translate pTempRoot");
}
ret = strlen(tmpdir);
while(ret>0 && tmpdir[--ret] == '\\')
tmpdir[ret] = '\0';
if(!ret || ret + 8 + 1 >= sizeof(tmpdir)) {
free_engine_and_unlock();
FAIL(CL_EARG, "Bad or too long pTempRoot '%s'", tmpdir);
}
memcpy(&tmpdir[ret+1], "\\clamtmp", 9);
cli_rmdirs(tmpdir);
if((ret = SHCreateDirectoryExA(NULL, tmpdir, NULL) != ERROR_SUCCESS) && ret != ERROR_ALREADY_EXISTS) {
free_engine_and_unlock();
FAIL(CL_ETMPDIR, "Cannot create pTempRoot '%s': error %d", tmpdir, ret);
}
if((ret = cl_engine_set_str(engine, CL_ENGINE_TMPDIR, tmpdir))) {
free_engine_and_unlock();
FAIL(ret, "Failed to set engine tempdir to '%s': %s", tmpdir, cl_strerror(ret));
}
if(!WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, pEnginesFolder, -1, dbdir, sizeof(dbdir), NULL, &cant_convert) || cant_convert) {
free_engine_and_unlock();
FAIL(CL_EARG, "Can't translate pEnginesFolder");
}
ret = load_db();
unlock_engine();
if(!ret) {
ResetEvent(monitor_event);
if(!(monitor_hdl = CreateThread(NULL, 0, monitor_thread, NULL, 0, NULL)))
logg("^Failed to start db monitoring thread\n");
}
logg("*Scan_Initialize: returning %d\n", ret);
return ret;
}
开发者ID:Yuyue,项目名称:clamav-devel,代码行数:65,代码来源:interface.c
示例16: scan_callback
//.........这里部分代码省略.........
return CL_EMEM;
} else {
client_conn->engine = scandata->engine;
pthread_mutex_lock(&reload_mutex);
client_conn->engine_timestamp = reloaded_time;
pthread_mutex_unlock(&reload_mutex);
if(!thrmgr_group_dispatch(scandata->thr_pool, scandata->group, client_conn, 1)) {
logg("!thread dispatch failed\n");
cl_engine_free(scandata->engine);
free(filename);
free(client_conn);
return CL_EMEM;
}
}
} else {
logg("!Can't allocate memory for client_conn\n");
scandata->errors++;
free(filename);
return CL_EMEM;
}
return CL_SUCCESS;
}
if (access(filename, R_OK)) {
if (conn_reply(scandata->conn, filename, "Access denied.", "ERROR") == -1) {
free(filename);
return CL_ETIMEOUT;
}
logg("*Access denied: %s\n", filename);
scandata->errors++;
free(filename);
return CL_SUCCESS;
}
thrmgr_setactivetask(filename, NULL);
context.filename = filename;
context.virsize = 0;
context.scandata = scandata;
ret = cl_scanfile_callback(filename, &virname, &scandata->scanned, scandata->engine, scandata->options, &context);
thrmgr_setactivetask(NULL, NULL);
if (thrmgr_group_need_terminate(scandata->conn->group)) {
free(filename);
logg("*Client disconnected while scanjob was active\n");
return ret == CL_ETIMEOUT ? ret : CL_BREAK;
}
if ((ret == CL_VIRUS) && (virname == NULL)) {
logg("*%s: reported CL_VIRUS but no virname returned!\n", filename);
ret = CL_EMEM;
}
if (ret == CL_VIRUS) {
scandata->infected++;
if (scandata->options & CL_SCAN_ALLMATCHES) {
if(optget(scandata->opts, "PreludeEnable")->enabled){
prelude_logging(filename, virname, context.virhash, context.virsize);
}
virusaction(filename, virname, scandata->opts);
} else {
if (conn_reply_virus(scandata->conn, filename, virname) == -1) {
free(filename);
return CL_ETIMEOUT;
}
if(optget(scandata->opts, "PreludeEnable")->enabled){
prelude_logging(filename, virname, context.virhash, context.virsize);
}
if(context.virsize && optget(scandata->opts, "ExtendedDetectionInfo")->enabled)
logg("~%s: %s(%s:%llu) FOUND\n", filename, virname, context.virhash, context.virsize);
else
logg("~%s: %s FOUND\n", filename, virname);
virusaction(filename, virname, scandata->opts);
}
} else if (ret != CL_CLEAN) {
scandata->errors++;
if (conn_reply(scandata->conn, filename, cl_strerror(ret), "ERROR") == -1) {
free(filename);
return CL_ETIMEOUT;
}
logg("~%s: %s ERROR\n", filename, cl_strerror(ret));
} else if (logok) {
logg("~%s: OK\n", filename);
}
free(filename);
if(ret == CL_EMEM) /* stop scanning */
return ret;
if (type == TYPE_SCAN) {
/* virus -> break */
return ret;
}
/* keep scanning always */
return CL_SUCCESS;
}
开发者ID:anh2hn,项目名称:clamav-devel,代码行数:101,代码来源:scanner.c
示例17: scanstdin
static int scanstdin(const struct cl_engine *engine, const struct optstruct *opts, int options)
{
int ret;
unsigned int fsize = 0;
const char *virname, *tmpdir;
char *file, buff[FILEBUFF];
size_t bread;
FILE *fs;
struct clamscan_cb_data data;
if(optget(opts, "tempdir")->enabled) {
tmpdir = optget(opts, "tempdir")->strarg;
} else {
/* check write access */
tmpdir = cli_gettmpdir();
}
if(checkaccess(tmpdir, CLAMAVUSER, W_OK) != 1) {
logg("!Can't write to temporary directory\n");
return 2;
}
if(!(file = cli_gentemp(tmpdir))) {
logg("!Can't generate tempfile name\n");
return 2;
}
if(!(fs = fopen(file, "wb"))) {
logg("!Can't open %s for writing\n", file);
free(file);
return 2;
}
while((bread = fread(buff, 1, FILEBUFF, stdin))) {
fsize += bread;
if(fwrite(buff, 1, bread, fs) < bread) {
logg("!Can't write to %s\n", file);
free(file);
fclose(fs);
return 2;
}
}
fclose(fs);
logg("*Checking %s\n", file);
info.files++;
info.rblocks += fsize / CL_COUNT_PRECISION;
data.filename = "stdin";
data.chain = NULL;
if((ret = cl_scanfile_callback(file, &virname, &info.blocks, engine, options, &data)) == CL_VIRUS) {
info.ifiles++;
if(bell)
fprintf(stderr, "\007");
} else if(ret == CL_CLEAN) {
if(!printinfected)
mprintf("stdin: OK\n");
} else {
if(!printinfected)
logg("stdin: %s ERROR\n", cl_strerror(ret));
info.errors++;
}
unlink(file);
free(file);
return ret;
}
开发者ID:lattera,项目名称:clamav-devel,代码行数:71,代码来源:manager.c
示例18: scanmanager
int scanmanager(const struct optstruct *opts)
{
int ret = 0, i;
unsigned int options = 0, dboptions = 0, dirlnk = 1, filelnk = 1;
struct cl_engine *engine;
STATBUF sb;
char *file, cwd[1024], *pua_cats = NULL;
const char *filename;
const struct optstruct *opt;
#ifndef _WIN32
struct rlimit rlim;
#endif
dirlnk = optget(opts, "follow-dir-symlinks")->numarg;
if(dirlnk > 2) {
logg("!--follow-dir-symlinks: Invalid argument\n");
return 2;
}
filelnk = optget(opts, "follow-file-symlinks")->numarg;
if(filelnk > 2) {
logg("!--follow-file-symlinks: Invalid argument\n");
return 2;
}
if(optget(opts, "yara-rules")->enabled) {
char *p = optget(opts, "yara-rules")->strarg;
if(strcmp(p, "yes")) {
if(!strcmp(p, "only"))
dboptions |= CL_DB_YARA_ONLY;
else if (!strcmp(p, "no"))
dboptions |= CL_DB_YARA_EXCLUDE;
}
}
if(optget(opts, "phishing-sigs")->enabled)
dboptions |= CL_DB_PHISHING;
if(optget(opts, "official-db-only")->enabled)
dboptions |= CL_DB_OFFICIAL_ONLY;
if(optget(opts,"phishing-scan-urls")->enabled)
dboptions |= CL_DB_PHISHING_URLS;
if(optget(opts,"bytecode")->enabled)
dboptions |= CL_DB_BYTECODE;
if((ret = cl_init(CL_INIT_DEFAULT))) {
logg("!Can't initialize libclamav: %s\n", cl_strerror(ret));
return 2;
}
if(!(engine = cl_engine_new())) {
logg("!Can't initialize antivirus engine\n");
return 2;
}
cl_engine_set_clcb_virus_found(engine, clamscan_virus_found_cb);
if (optget(opts, "disable-cache")->enabled)
cl_engine_set_num(engine, CL_ENGINE_DISABLE_CACHE, 1);
if (optget(opts, "disable-pe-stats")->enabled) {
cl_engine_set_num(engine, CL_ENGINE_DISABLE_PE_STATS, 1);
}
if (optget(opts, "enable-stats")->enabled) {
cl_engine_stats_enable(engine);
}
if (optget(opts, "stats-timeout")->enabled) {
cl_engine_set_num(engine, CL_ENGINE_STATS_TIMEOUT, optget(opts, "StatsTimeout")->numarg);
}
if (optget(opts, "stats-host-id")->enabled) {
char *p = optget(opts, "stats-host-id")->strarg;
if (strcmp(p, "default")) {
if (!strcmp(p, "none")) {
cl_engine_set_clcb_stats_get_hostid(engine, NULL);
} else if (!strcmp(p, "anonymous")) {
strcpy(hostid, STATS_ANON_UUID);
} else {
if (strlen(p) > 36) {
logg("!Invalid HostID\n");
cl_engine_set_clcb_stats_submit(engine, NULL);
cl_engine_free(engine);
return 2;
}
strcpy(hostid, p);
}
cl_engine_set_clcb_stats_get_hostid(engine, get_hostid);
}
}
if(optget(opts, "detect-pua")->enabled) {
//.........这里部分代码省略.........
开发者ID:lattera,项目名称:clamav-devel,代码行数:101,代码来源:manager.c
示例19: logg
static struct cl_engine *reload_db(struct cl_engine *engine, unsigned int dboptions, const struct optstruct *opts, int do_check, int *ret)
{
const char *dbdir;
int retval;
unsigned int sigs = 0;
struct cl_settings *settings = NULL;
*ret = 0;
if(do_check) {
if(!dbstat.entries) {
logg("No stats for Database check - forcing reload\n");
return engine;
}
if(cl_statchkdir(&dbstat) == 1) {
logg("SelfCheck: Database modification detected. Forcing reload.\n");
return engine;
} else {
logg("SelfCheck: Database status OK.\n");
return NULL;
}
}
/* release old structure */
if(engine) {
/* copy current settings */
settings = cl_engine_settings_copy(engine);
if(!settings)
logg("^Can't make a copy of the current engine settings\n");
thrmgr_setactiveengine(NULL);
cl_engine_free(engine);
}
dbdir = optget(opts, "DatabaseDirectory")->strarg;
logg("Reading databases from %s\n", dbdir);
if(dbstat.entries)
cl_statfree(&dbstat);
memset(&dbstat, 0, sizeof(struct cl_stat));
if((retval = cl_statinidir(dbdir, &dbstat))) {
logg("!cl_statinidir() failed: %s\n", cl_strerror(retval));
*ret = 1;
if(settings)
cl_engine_settings_free(settings);
return NULL;
}
if(!(engine = cl_engine_new())) {
logg("!Can't initialize antivirus engine\n");
*ret = 1;
if(settings)
cl_engine_settings_free(settings);
return NULL;
}
if(settings) {
retval = cl_engine_settings_apply(engine, settings);
if(retval != CL_SUCCESS) {
logg("^Can't apply previous engine settings: %s\n", cl_strerror(retval));
logg("^Using default engine settings\n");
}
cl_engine_settings_free(settings);
}
if((retval = cl_load(dbdir, engine, &sigs, dboptions))) {
logg("!reload db failed: %s\n", cl_strerror(retval));
cl_engine_free(engine);
*ret = 1;
return NULL;
}
if((retval = cl_engine_compile(engine)) != 0) {
logg("!Database initialization error: can't compile engine: %s\n", cl_strerror(retval));
cl_engine_free(engine);
*ret = 1;
return NULL;
}
logg("Database correctly reloaded (%u signatures)\n", sigs);
thrmgr_setactiveengine(engine);
return engine;
}
开发者ID:jmatthed,项目名称:clamav-devel,代码行数:84,代码来源:server-th.c
|
请发表评论