Browse code

new option --run-cdiff

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@2027 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2006/06/15 22:57:42
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Jun 15 15:55:08 CEST 2006 (tk)
2
+----------------------------------
3
+  * sigtool/sigtool.c: new option --run-cdiff
4
+
1 5
 Thu Jun 15 15:03:55 CEST 2006 (tk)
2 6
 ----------------------------------
3 7
   * shared/cdiff.[ch]: new files (interpreter for scripted database updates)
... ...
@@ -71,7 +71,8 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
71 71
 PROGRAMS = $(bin_PROGRAMS)
72 72
 am_sigtool_OBJECTS = output.$(OBJEXT) getopt.$(OBJEXT) \
73 73
 	memory.$(OBJEXT) cfgparser.$(OBJEXT) misc.$(OBJEXT) \
74
-	options.$(OBJEXT) vba.$(OBJEXT) sigtool.$(OBJEXT)
74
+	options.$(OBJEXT) cdiff.$(OBJEXT) vba.$(OBJEXT) \
75
+	sigtool.$(OBJEXT)
75 76
 sigtool_OBJECTS = $(am_sigtool_OBJECTS)
76 77
 sigtool_DEPENDENCIES = $(top_builddir)/clamscan/others.o
77 78
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
... ...
@@ -217,6 +218,8 @@ sigtool_SOURCES = \
217 217
     $(top_srcdir)/shared/misc.h \
218 218
     $(top_srcdir)/shared/options.c \
219 219
     $(top_srcdir)/shared/options.h \
220
+    $(top_srcdir)/shared/cdiff.c \
221
+    $(top_srcdir)/shared/cdiff.h \
220 222
     vba.c \
221 223
     vba.h \
222 224
     sigtool.c
... ...
@@ -294,6 +297,7 @@ mostlyclean-compile:
294 294
 distclean-compile:
295 295
 	-rm -f *.tab.c
296 296
 
297
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdiff.Po@am__quote@
297 298
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgparser.Po@am__quote@
298 299
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
299 300
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
... ...
@@ -408,6 +412,20 @@ options.obj: $(top_srcdir)/shared/options.c
408 408
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
409 409
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o options.obj `if test -f '$(top_srcdir)/shared/options.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/options.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/options.c'; fi`
410 410
 
411
+cdiff.o: $(top_srcdir)/shared/cdiff.c
412
+@am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdiff.o -MD -MP -MF "$(DEPDIR)/cdiff.Tpo" -c -o cdiff.o `test -f '$(top_srcdir)/shared/cdiff.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/cdiff.c; \
413
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/cdiff.Tpo" "$(DEPDIR)/cdiff.Po"; else rm -f "$(DEPDIR)/cdiff.Tpo"; exit 1; fi
414
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_srcdir)/shared/cdiff.c' object='cdiff.o' libtool=no @AMDEPBACKSLASH@
415
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
416
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdiff.o `test -f '$(top_srcdir)/shared/cdiff.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/cdiff.c
417
+
418
+cdiff.obj: $(top_srcdir)/shared/cdiff.c
419
+@am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdiff.obj -MD -MP -MF "$(DEPDIR)/cdiff.Tpo" -c -o cdiff.obj `if test -f '$(top_srcdir)/shared/cdiff.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/cdiff.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/cdiff.c'; fi`; \
420
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/cdiff.Tpo" "$(DEPDIR)/cdiff.Po"; else rm -f "$(DEPDIR)/cdiff.Tpo"; exit 1; fi
421
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_srcdir)/shared/cdiff.c' object='cdiff.obj' libtool=no @AMDEPBACKSLASH@
422
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
423
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdiff.obj `if test -f '$(top_srcdir)/shared/cdiff.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/cdiff.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/cdiff.c'; fi`
424
+
411 425
 mostlyclean-libtool:
412 426
 	-rm -f *.lo
413 427
 
... ...
@@ -47,6 +47,7 @@
47 47
 #include "shared/output.h"
48 48
 #include "shared/cfgparser.h"
49 49
 #include "shared/misc.h"
50
+#include "shared/cdiff.h"
50 51
 
51 52
 #include "libclamav/cvd.h"
52 53
 #include "libclamav/others.h"
... ...
@@ -805,6 +806,20 @@ static int vbadump(struct optstruct *opt)
805 805
     return 0;
806 806
 }
807 807
 
808
+static int runcdiff(struct optstruct *opt)
809
+{
810
+	int fd, ret;
811
+
812
+
813
+    if((fd = open(opt_arg(opt, "run-cdiff"), O_RDONLY)) == -1)
814
+	return -1;
815
+
816
+    ret = cdiff_apply(fd);
817
+    close(fd);
818
+
819
+    return ret;
820
+}
821
+
808 822
 void help(void)
809 823
 {
810 824
     mprintf("\n");
... ...
@@ -829,6 +844,8 @@ void help(void)
829 829
     mprintf("    --list-sigs[=FILE]     -l[FILE]        List signature names\n");
830 830
     mprintf("    --vba=FILE                             Extract VBA/Word6 macro code\n");
831 831
     mprintf("    --vba-hex=FILE                         Extract Word6 macro code with hex values\n");
832
+    mprintf("    --vba-hex=FILE                         Extract Word6 macro code with hex values\n");
833
+    mprintf("    --run-cdiff=FILE       -r FILE         Execute update script FILE in cwd\n");
832 834
     mprintf("\n");
833 835
 
834 836
     return;
... ...
@@ -838,7 +855,7 @@ int main(int argc, char **argv)
838 838
 {
839 839
 	int ret = 1;
840 840
         struct optstruct *opt;
841
-	const char *short_options = "hvVb:i:u:l::";
841
+	const char *short_options = "hvVb:i:u:l::r:";
842 842
 	static struct option long_options[] = {
843 843
 	    {"help", 0, 0, 'h'},
844 844
 	    {"quiet", 0, 0, 0},
... ...
@@ -858,6 +875,7 @@ int main(int argc, char **argv)
858 858
 	    {"list-sigs", 2, 0, 'l'},
859 859
 	    {"vba", 1, 0 ,0},
860 860
 	    {"vba-hex", 1, 0, 0},
861
+	    {"run-cdiff", 1, 0, 'r'},
861 862
 	    {0, 0, 0, 0}
862 863
     	};
863 864
 
... ...
@@ -906,6 +924,8 @@ int main(int argc, char **argv)
906 906
 	ret = listsigs(opt);
907 907
     else if(opt_check(opt, "vba") || opt_check(opt, "vba-hex"))
908 908
 	ret = vbadump(opt);
909
+    else if(opt_check(opt, "run-cdiff"))
910
+	ret = runcdiff(opt);
909 911
     else
910 912
 	help();
911 913