git-svn: trunk@3492
Tomasz Kojm authored on 2008/01/10 22:57:05... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Thu Jan 10 14:29:28 CET 2008 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * clamdscan: remove dependendcy on libclamav (bb#750), patch from Edwin |
|
4 |
+ |
|
1 | 5 |
Thu Jan 10 11:23:32 GMT 2008 (njh) |
2 | 6 |
---------------------------------- |
3 | 7 |
* clamav-milter: Use new cli_rndnum API - thanks to TK for spotting |
... | ... |
@@ -38,6 +38,6 @@ clamdscan_SOURCES = \ |
38 | 38 |
|
39 | 39 |
endif |
40 | 40 |
|
41 |
-DEFS = @DEFS@ -DCL_NOTHREADS |
|
41 |
+DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV |
|
42 | 42 |
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav |
43 |
-LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@ |
|
43 |
+LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la @FRESHCLAM_LIBS@ |
... | ... |
@@ -114,7 +114,7 @@ CPP = @CPP@ |
114 | 114 |
CPPFLAGS = @CPPFLAGS@ |
115 | 115 |
CYGPATH_W = @CYGPATH_W@ |
116 | 116 |
DBDIR = @DBDIR@ |
117 |
-DEFS = @DEFS@ -DCL_NOTHREADS |
|
117 |
+DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV |
|
118 | 118 |
DEPDIR = @DEPDIR@ |
119 | 119 |
ECHO = @ECHO@ |
120 | 120 |
ECHO_C = @ECHO_C@ |
... | ... |
@@ -134,7 +134,7 @@ LDFLAGS = @LDFLAGS@ |
134 | 134 |
LIBCLAMAV_LIBS = @LIBCLAMAV_LIBS@ |
135 | 135 |
LIBCLAMAV_VERSION = @LIBCLAMAV_VERSION@ |
136 | 136 |
LIBOBJS = @LIBOBJS@ |
137 |
-LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@ |
|
137 |
+LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la @FRESHCLAM_LIBS@ |
|
138 | 138 |
LIBTOOL = @LIBTOOL@ |
139 | 139 |
LN_S = @LN_S@ |
140 | 140 |
LTLIBOBJS = @LTLIBOBJS@ |
... | ... |
@@ -43,6 +43,20 @@ short printinfected = 0; |
43 | 43 |
|
44 | 44 |
extern int notremoved, notmoved; |
45 | 45 |
|
46 |
+#ifdef CL_EXPERIMENTAL |
|
47 |
+#define VERSION_EXP VERSION"-exp" |
|
48 |
+#else |
|
49 |
+#define VERSION_EXP VERSION |
|
50 |
+#endif |
|
51 |
+ |
|
52 |
+static void print_server_version(const struct optstruct *opt) |
|
53 |
+{ |
|
54 |
+ if(get_clamd_version(opt)) { |
|
55 |
+ /* can't get version from server, fallback */ |
|
56 |
+ printf("ClamAV "VERSION_EXP"\n"); |
|
57 |
+ } |
|
58 |
+} |
|
59 |
+ |
|
46 | 60 |
int main(int argc, char **argv) |
47 | 61 |
{ |
48 | 62 |
int ds, dms, ret, infected; |
... | ... |
@@ -74,7 +88,7 @@ int main(int argc, char **argv) |
74 | 74 |
mprintf_stdout = 1; |
75 | 75 |
|
76 | 76 |
if(opt_check(opt, "version")) { |
77 |
- print_version(); |
|
77 |
+ print_server_version(opt); |
|
78 | 78 |
opt_free(opt); |
79 | 79 |
exit(0); |
80 | 80 |
} |
... | ... |
@@ -390,6 +390,29 @@ static int dconnect(const struct optstruct *opt) |
390 | 390 |
return sockd; |
391 | 391 |
} |
392 | 392 |
|
393 |
+int get_clamd_version(const struct optstruct *opt) |
|
394 |
+{ |
|
395 |
+ char buff[64]; |
|
396 |
+ int bread, sockd; |
|
397 |
+ |
|
398 |
+ |
|
399 |
+ if((sockd = dconnect(opt)) < 0) |
|
400 |
+ return 2; |
|
401 |
+ |
|
402 |
+ if(write(sockd, "VERSION", 7) <= 0) { |
|
403 |
+ logg("^Can't write to the socket.\n"); |
|
404 |
+ return 2; |
|
405 |
+ } |
|
406 |
+ |
|
407 |
+ while((bread = read(sockd, buff, sizeof(buff)-1)) > 0) { |
|
408 |
+ buff[bread] = '\0'; |
|
409 |
+ printf("%s\n", buff); |
|
410 |
+ } |
|
411 |
+ |
|
412 |
+ close(sockd); |
|
413 |
+ return 0; |
|
414 |
+} |
|
415 |
+ |
|
393 | 416 |
int client(const struct optstruct *opt, int *infected) |
394 | 417 |
{ |
395 | 418 |
char cwd[200], *fullpath; |
... | ... |
@@ -54,6 +54,8 @@ |
54 | 54 |
#define VERSION_EXP VERSION |
55 | 55 |
#endif |
56 | 56 |
|
57 |
+/* CL_NOLIBCLAMAV means to omit functions that depends on libclamav */ |
|
58 |
+#ifndef CL_NOLIBCLAMAV |
|
57 | 59 |
char *freshdbdir(void) |
58 | 60 |
{ |
59 | 61 |
struct cl_cvd *d1, *d2; |
... | ... |
@@ -131,7 +133,7 @@ void print_version(void) |
131 | 131 |
|
132 | 132 |
free(path); |
133 | 133 |
} |
134 |
- |
|
134 |
+#endif |
|
135 | 135 |
int filecopy(const char *src, const char *dest) |
136 | 136 |
{ |
137 | 137 |
|
... | ... |
@@ -187,6 +189,7 @@ int filecopy(const char *src, const char *dest) |
187 | 187 |
|
188 | 188 |
} |
189 | 189 |
|
190 |
+#ifndef CL_NOLIBCLAMAV |
|
190 | 191 |
int dircopy(const char *src, const char *dest) |
191 | 192 |
{ |
192 | 193 |
DIR *dd; |
... | ... |
@@ -230,6 +233,7 @@ int dircopy(const char *src, const char *dest) |
230 | 230 |
closedir(dd); |
231 | 231 |
return 0; |
232 | 232 |
} |
233 |
+#endif |
|
233 | 234 |
|
234 | 235 |
int isnumb(const char *str) |
235 | 236 |
{ |
... | ... |
@@ -242,6 +246,7 @@ int isnumb(const char *str) |
242 | 242 |
return 1; |
243 | 243 |
} |
244 | 244 |
|
245 |
+#ifndef CL_NOLIBCLAMAV |
|
245 | 246 |
int cvd_unpack(const char *cvd, const char *destdir) |
246 | 247 |
{ |
247 | 248 |
int fd; |
... | ... |
@@ -263,6 +268,7 @@ int cvd_unpack(const char *cvd, const char *destdir) |
263 | 263 |
|
264 | 264 |
return 0; |
265 | 265 |
} |
266 |
+#endif |
|
266 | 267 |
|
267 | 268 |
void daemonize(void) |
268 | 269 |
{ |