|
|
|
@ -99,6 +99,7 @@ int clamdscan(struct optstruct *opt)
|
|
|
|
|
long double mb;
|
|
|
|
|
const char *virname;
|
|
|
|
|
struct cl_engine *engine = NULL;
|
|
|
|
|
struct cl_scan_options options;
|
|
|
|
|
struct stat sb;
|
|
|
|
|
|
|
|
|
|
if(optc(opt, 'V')) {
|
|
|
|
@ -178,40 +179,48 @@ int clamdscan(struct optstruct *opt)
|
|
|
|
|
/* Clamd isn't running, start it so it is available next time. */
|
|
|
|
|
startclamd(opt);
|
|
|
|
|
|
|
|
|
|
if((engine = cl_engine_new()) == NULL) {
|
|
|
|
|
printf("Database initialization error: %s\n", cl_strerror(ret));;
|
|
|
|
|
if ((ret = cl_init(CL_INIT_DEFAULT)) != CL_SUCCESS) {
|
|
|
|
|
printf("Can't initialize libclamav: %s\n", cl_strerror(ret));
|
|
|
|
|
close(fd);
|
|
|
|
|
exit(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!(engine = cl_engine_new())) {
|
|
|
|
|
printf("Cannot create scanner engine: %s\n", cl_strerror(ret));;
|
|
|
|
|
cl_engine_free(engine);
|
|
|
|
|
close(fd);
|
|
|
|
|
exit(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(optc(opt, 'd')) {
|
|
|
|
|
if((ret = cl_load(getargc(opt, 'd'), engine, &no, CL_DB_STDOPT))) {
|
|
|
|
|
if((ret = cl_load(getargc(opt, 'd'), engine, &no, CL_DB_STDOPT)) != CL_SUCCESS) {
|
|
|
|
|
printf("cl_load: %s\n", cl_strerror(ret));
|
|
|
|
|
close(fd);
|
|
|
|
|
return 50;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if((ret = cl_load(cl_retdbdir(), engine, &no, CL_DB_STDOPT))) {
|
|
|
|
|
printf("cl_loaddbdir: %s\n", cl_strerror(ret));
|
|
|
|
|
close(fd);
|
|
|
|
|
exit(2);
|
|
|
|
|
if((ret = cl_load(cl_retdbdir(), engine, &no, CL_DB_STDOPT)) != CL_SUCCESS) {
|
|
|
|
|
printf("cl_loaddbdir: %s\n", cl_strerror(ret));
|
|
|
|
|
close(fd);
|
|
|
|
|
exit(2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* build engine */
|
|
|
|
|
if((ret = cl_engine_compile(engine))) {
|
|
|
|
|
printf("Database initialization error: %s\n", cl_strerror(ret));;
|
|
|
|
|
if((ret = cl_engine_compile(engine)) != CL_SUCCESS ) {
|
|
|
|
|
printf("Database initialization error: %s\n", cl_strerror(ret));
|
|
|
|
|
cl_engine_free(engine);
|
|
|
|
|
close(fd);
|
|
|
|
|
exit(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = cl_scandesc(fd, tmpnm, &virname, &size, engine,
|
|
|
|
|
CL_SCAN_GENERAL_ALLMATCHES | CL_SCAN_GENERAL_HEURISTICS |
|
|
|
|
|
CL_SCAN_PARSE_ARCHIVE | CL_SCAN_PARSE_MAIL | CL_SCAN_PARSE_OLE2 |
|
|
|
|
|
CL_SCAN_PARSE_HTML | CL_SCAN_PARSE_PDF );
|
|
|
|
|
printf("scandesc returned: %i\n", cl_strerror(ret));;
|
|
|
|
|
/* scan file descriptor */
|
|
|
|
|
memset(&options, 0, sizeof(struct cl_scan_options));
|
|
|
|
|
options.parse = ~0; // all parsers
|
|
|
|
|
options.general |= CL_SCAN_GENERAL_HEURISTICS;
|
|
|
|
|
options.mail |= CL_SCAN_MAIL_PARTIAL_MESSAGE;
|
|
|
|
|
ret = cl_scandesc(fd, tmpnm, &virname, &size, engine, &options );
|
|
|
|
|
printf("scandesc returned: %i\n", cl_strerror(ret));
|
|
|
|
|
if( ret == CL_VIRUS )
|
|
|
|
|
printf("virus found\n");
|
|
|
|
|
else
|
|
|
|
|