clamscan, sigtool: select fresh database directory

git-svn: trunk@550
remotes/push_mirror/metadata
Tomasz Kojm 21 years ago
parent 266f39676b
commit 908db4dfea
  1. 6
      clamav-devel/ChangeLog
  2. 2
      clamav-devel/clamscan/Makefile.am
  3. 35
      clamav-devel/clamscan/Makefile.in
  4. 3
      clamav-devel/clamscan/clamscan.c
  5. 41
      clamav-devel/clamscan/manager.c
  6. 4
      clamav-devel/etc/freshclam.conf
  7. 2
      clamav-devel/sigtool/Makefile.am
  8. 30
      clamav-devel/sigtool/Makefile.in
  9. 2
      clamav-devel/sigtool/options.c
  10. 45
      clamav-devel/sigtool/sigtool.c

@ -1,3 +1,9 @@
Mon May 10 02:43:32 CEST 2004 (tk)
----------------------------------
* clamscan, sigtool: compare clamav.conf's DatabaseDirectory against the
hardcoded directory and select more fresh one (by
checking version numbers of daily.cvd)
Mon May 10 00:05:23 CEST 2004 (tk)
----------------------------------
* clamscan: + allow regular expressions in --[in|ex]clude (patch by

@ -25,6 +25,8 @@ clamscan_SOURCES = \
$(top_srcdir)/shared/getopt.h \
$(top_srcdir)/shared/memory.c \
$(top_srcdir)/shared/memory.h \
$(top_srcdir)/shared/cfgparser.c \
$(top_srcdir)/shared/cfgparser.h \
clamscan.c \
options.c \
options.h \

@ -127,6 +127,8 @@ clamscan_SOURCES = \
$(top_srcdir)/shared/getopt.h \
$(top_srcdir)/shared/memory.c \
$(top_srcdir)/shared/memory.h \
$(top_srcdir)/shared/cfgparser.c \
$(top_srcdir)/shared/cfgparser.h \
clamscan.c \
options.c \
options.h \
@ -151,8 +153,8 @@ bin_PROGRAMS = clamscan$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS)
am_clamscan_OBJECTS = output.$(OBJEXT) getopt.$(OBJEXT) memory.$(OBJEXT) \
clamscan.$(OBJEXT) options.$(OBJEXT) others.$(OBJEXT) \
manager.$(OBJEXT) treewalk.$(OBJEXT)
cfgparser.$(OBJEXT) clamscan.$(OBJEXT) options.$(OBJEXT) \
others.$(OBJEXT) manager.$(OBJEXT) treewalk.$(OBJEXT)
clamscan_OBJECTS = $(am_clamscan_OBJECTS)
clamscan_LDADD = $(LDADD)
clamscan_DEPENDENCIES =
@ -162,10 +164,11 @@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/clamscan.Po ./$(DEPDIR)/getopt.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/manager.Po ./$(DEPDIR)/memory.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/options.Po ./$(DEPDIR)/others.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/output.Po ./$(DEPDIR)/treewalk.Po
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cfgparser.Po ./$(DEPDIR)/clamscan.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/getopt.Po ./$(DEPDIR)/manager.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/memory.Po ./$(DEPDIR)/options.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/others.Po ./$(DEPDIR)/output.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/treewalk.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
@ -217,6 +220,7 @@ clean-binPROGRAMS:
output.$(OBJEXT): $(top_srcdir)/shared/output.c
getopt.$(OBJEXT): $(top_srcdir)/shared/getopt.c
memory.$(OBJEXT): $(top_srcdir)/shared/memory.c
cfgparser.$(OBJEXT): $(top_srcdir)/shared/cfgparser.c
clamscan$(EXEEXT): $(clamscan_OBJECTS) $(clamscan_DEPENDENCIES)
@rm -f clamscan$(EXEEXT)
$(LINK) $(clamscan_LDFLAGS) $(clamscan_OBJECTS) $(clamscan_LDADD) $(LIBS)
@ -227,6 +231,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgparser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamscan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manager.Po@am__quote@
@ -310,6 +315,24 @@ memory.lo: $(top_srcdir)/shared/memory.c
@AMDEP_TRUE@ depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c
cfgparser.o: $(top_srcdir)/shared/cfgparser.c
@AMDEP_TRUE@ source='$(top_srcdir)/shared/cfgparser.c' object='cfgparser.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/cfgparser.Po' tmpdepfile='$(DEPDIR)/cfgparser.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.o `test -f '$(top_srcdir)/shared/cfgparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/cfgparser.c
cfgparser.obj: $(top_srcdir)/shared/cfgparser.c
@AMDEP_TRUE@ source='$(top_srcdir)/shared/cfgparser.c' object='cfgparser.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/cfgparser.Po' tmpdepfile='$(DEPDIR)/cfgparser.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.obj `cygpath -w $(top_srcdir)/shared/cfgparser.c`
cfgparser.lo: $(top_srcdir)/shared/cfgparser.c
@AMDEP_TRUE@ source='$(top_srcdir)/shared/cfgparser.c' object='cfgparser.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/cfgparser.Plo' tmpdepfile='$(DEPDIR)/cfgparser.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.lo `test -f '$(top_srcdir)/shared/cfgparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/cfgparser.c
CCDEPMODE = @CCDEPMODE@
mostlyclean-libtool:

@ -53,7 +53,6 @@ int clamscan(struct optstruct *opt)
struct timezone tz;
time_t starttime;
/* initialize some important variables */
if(optc(opt, 'v')) {
@ -197,7 +196,7 @@ void help(void)
mprintf("\n");
mprintf(" --tempdir=DIRECTORY create temporary files in DIRECTORY\n");
mprintf(" --database=FILE/DIR -d FILE/DIR Load virus database from FILE or load\n");
mprintf(" all .db and .db2 files from DIR\n");
mprintf(" all .cvd and .db[2] files from DIR\n");
mprintf(" --log=FILE -l FILE Save scan report to FILE\n");
mprintf(" --recursive -r Scan directories recursively\n");
mprintf(" --infected -i Print infected files only\n");

@ -53,6 +53,7 @@
#include "strrcpy.h"
#include "memory.h"
#include "output.h"
#include "cfgparser.h"
#ifdef C_LINUX
dev_t procdev;
@ -67,7 +68,9 @@ int scanmanager(const struct optstruct *opt)
struct passwd *user = NULL;
struct stat sb;
char *fullpath = NULL, cwd[200];
struct cfgstruct *copt, *cpt;
struct cl_cvd *d1, *d2;
const char *dbdir;
/* njh@bandsman.co.uk: BeOS */
#if !defined(C_CYGWIN) && !defined(C_BEOS)
@ -79,14 +82,12 @@ int scanmanager(const struct optstruct *opt)
}
#endif
if(optl(opt, "unzip") || optl(opt, "unrar") || optl(opt, "unace") ||
optl(opt, "arj") || optl(opt, "unzoo") || optl(opt, "jar") ||
optl(opt, "lha") || optl(opt, "tar") || optl(opt, "tgz") ||
optl(opt, "deb"))
compression = 1;
/* now initialize the database */
if(optc(opt, 'd')) {
@ -110,10 +111,42 @@ int scanmanager(const struct optstruct *opt)
}
} else {
if((ret = cl_loaddbdir(cl_retdbdir(), &trie, &claminfo.signs))) {
/* try to find fresh directory */
dbdir = cl_retdbdir();
if((copt = parsecfg(CONFDIR"/clamav.conf"))) {
if((cpt = cfgopt(copt, "DatabaseDirectory")) || (cpt = cfgopt(copt, "DataDirectory"))) {
if(strcmp(cl_retdbdir(), cpt->strarg)) {
char *daily = (char *) mmalloc(strlen(cpt->strarg) + strlen(cl_retdbdir()) + 15);
sprintf(daily, "%s/daily.cvd", cpt->strarg);
if((d1 = cl_cvdhead(daily))) {
sprintf(daily, "%s/daily.cvd", cl_retdbdir());
if((d2 = cl_cvdhead(daily))) {
free(daily);
if(d1->version > d2->version)
dbdir = cpt->strarg;
else
dbdir = cl_retdbdir();
cl_cvdfree(d2);
} else {
free(daily);
dbdir = cpt->strarg;
}
cl_cvdfree(d1);
} else {
free(daily);
dbdir = cl_retdbdir();
}
}
}
}
if((ret = cl_loaddbdir(dbdir, &trie, &claminfo.signs))) {
mprintf("@%s\n", cl_strerror(ret));
return 50;
}
if(copt)
freecfg(copt);
}

@ -4,8 +4,8 @@
## This file may be optionally merged with clamav.conf.
##
# You can change the default database directory here.
# It should match clamav.conf's directive ! (in most cases you shouldn't
# change it)
#DatabaseDirectory /var/lib/clamav
# Path to the log file (make sure it has proper permissions)

@ -24,6 +24,8 @@ sigtool_SOURCES = \
$(top_srcdir)/shared/getopt.h \
$(top_srcdir)/shared/memory.c \
$(top_srcdir)/shared/memory.h \
$(top_srcdir)/shared/cfgparser.c \
$(top_srcdir)/shared/cfgparser.h \
options.c \
options.h \
sigtool.c

@ -126,6 +126,8 @@ sigtool_SOURCES = \
$(top_srcdir)/shared/getopt.h \
$(top_srcdir)/shared/memory.c \
$(top_srcdir)/shared/memory.h \
$(top_srcdir)/shared/cfgparser.c \
$(top_srcdir)/shared/cfgparser.h \
options.c \
options.h \
sigtool.c
@ -144,7 +146,7 @@ bin_PROGRAMS = sigtool$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS)
am_sigtool_OBJECTS = output.$(OBJEXT) getopt.$(OBJEXT) memory.$(OBJEXT) \
options.$(OBJEXT) sigtool.$(OBJEXT)
cfgparser.$(OBJEXT) options.$(OBJEXT) sigtool.$(OBJEXT)
sigtool_OBJECTS = $(am_sigtool_OBJECTS)
sigtool_DEPENDENCIES = $(top_builddir)/clamscan/others.o
sigtool_LDFLAGS =
@ -153,9 +155,9 @@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/getopt.Po ./$(DEPDIR)/memory.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/options.Po ./$(DEPDIR)/output.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/sigtool.Po
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cfgparser.Po ./$(DEPDIR)/getopt.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/memory.Po ./$(DEPDIR)/options.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/output.Po ./$(DEPDIR)/sigtool.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
@ -207,6 +209,7 @@ clean-binPROGRAMS:
output.$(OBJEXT): $(top_srcdir)/shared/output.c
getopt.$(OBJEXT): $(top_srcdir)/shared/getopt.c
memory.$(OBJEXT): $(top_srcdir)/shared/memory.c
cfgparser.$(OBJEXT): $(top_srcdir)/shared/cfgparser.c
sigtool$(EXEEXT): $(sigtool_OBJECTS) $(sigtool_DEPENDENCIES)
@rm -f sigtool$(EXEEXT)
$(LINK) $(sigtool_LDFLAGS) $(sigtool_OBJECTS) $(sigtool_LDADD) $(LIBS)
@ -217,6 +220,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgparser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
@ -297,6 +301,24 @@ memory.lo: $(top_srcdir)/shared/memory.c
@AMDEP_TRUE@ depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c
cfgparser.o: $(top_srcdir)/shared/cfgparser.c
@AMDEP_TRUE@ source='$(top_srcdir)/shared/cfgparser.c' object='cfgparser.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/cfgparser.Po' tmpdepfile='$(DEPDIR)/cfgparser.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.o `test -f '$(top_srcdir)/shared/cfgparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/cfgparser.c
cfgparser.obj: $(top_srcdir)/shared/cfgparser.c
@AMDEP_TRUE@ source='$(top_srcdir)/shared/cfgparser.c' object='cfgparser.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/cfgparser.Po' tmpdepfile='$(DEPDIR)/cfgparser.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.obj `cygpath -w $(top_srcdir)/shared/cfgparser.c`
cfgparser.lo: $(top_srcdir)/shared/cfgparser.c
@AMDEP_TRUE@ source='$(top_srcdir)/shared/cfgparser.c' object='cfgparser.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/cfgparser.Plo' tmpdepfile='$(DEPDIR)/cfgparser.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.lo `test -f '$(top_srcdir)/shared/cfgparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/cfgparser.c
CCDEPMODE = @CCDEPMODE@
mostlyclean-libtool:

@ -33,6 +33,8 @@
#include "options.h"
#include "others.h"
#include "output.h"
#include "memory.h"
void sigtool(struct optstruct *opt);

@ -47,6 +47,7 @@
#include "str.h"
#include "memory.h"
#include "output.h"
#include "cfgparser.h"
#define LINE 1024
@ -477,6 +478,44 @@ int countlines(const char *filename)
return lines;
}
const char *getdbdir(void)
{
struct cfgstruct *copt, *cpt;
struct cl_cvd *d1, *d2;
const char *dbdir;
dbdir = cl_retdbdir();
if((copt = parsecfg(CONFDIR"/clamav.conf"))) {
if((cpt = cfgopt(copt, "DatabaseDirectory")) || (cpt = cfgopt(copt, "DataDirectory"))) {
if(strcmp(cl_retdbdir(), cpt->strarg)) {
char *daily = (char *) mmalloc(strlen(cpt->strarg) + strlen(cl_retdbdir()) + 15);
sprintf(daily, "%s/daily.cvd", cpt->strarg);
if((d1 = cl_cvdhead(daily))) {
sprintf(daily, "%s/daily.cvd", cl_retdbdir());
if((d2 = cl_cvdhead(daily))) {
free(daily);
if(d1->version > d2->version)
dbdir = cpt->strarg;
else
dbdir = cl_retdbdir();
cl_cvdfree(d2);
} else {
free(daily);
dbdir = cpt->strarg;
}
cl_cvdfree(d1);
} else {
free(daily);
dbdir = cl_retdbdir();
}
}
}
}
return dbdir;
}
int build(struct optstruct *opt)
{
int ret, no = 0, realno = 0, bytes, itmp;
@ -575,7 +614,7 @@ int build(struct optstruct *opt)
/* try to read cvd header of old database */
sprintf(buffer, "%s/%s", cl_retdbdir(), getargc(opt, 'b'));
sprintf(buffer, "%s/%s", getdbdir(), getargc(opt, 'b'));
if((oldcvd = cl_cvdhead(buffer)) == NULL)
mprintf("WARNING: CAN'T READ CVD HEADER OF CURRENT DATABASE %s\n", buffer);
@ -785,7 +824,7 @@ int unpack(struct optstruct *opt)
if(optl(opt, "unpack-current")) {
name = mcalloc(300, sizeof(char)); /* FIXME */
sprintf(name, "%s/%s", cl_retdbdir(), getargl(opt, "unpack-current"));
sprintf(name, "%s/%s", getdbdir(), getargl(opt, "unpack-current"));
} else
name = getargc(opt, 'u');
@ -979,7 +1018,7 @@ void listsigs(struct optstruct *opt)
if((name = getargc(opt, 'l')))
ret = listdb(name);
else
ret = listdir(cl_retdbdir());
ret = listdir(getdbdir());
ret ? exit(1) : exit(0);
}

Loading…
Cancel
Save