Browse code

cleanups

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

Tomasz Kojm authored on 2004/03/27 07:16:26
Showing 5 changed files
... ...
@@ -58,6 +58,7 @@ Kamil Andrusz <wizz*mniam.net>
58 58
 Patrick Bihan-Faou <patrick*mindstep.com>
59 59
 Len Budney <lbudney*pobox.com>
60 60
 Andrey Cherezov <andrey*cherezov.koenig.su>
61
+Tom G. Christensen <tgc*statsbiblioteket.dk>
61 62
 Damien Curtain <damien*pagefault.org>
62 63
 Michael Dankov <misha*btrc.ru>
63 64
 Alejandro Dubrovsky <s328940*student.uq.edu.au>
... ...
@@ -106,5 +107,6 @@ Gernot Tenchio <g.tenchio*telco-tech.de>
106 106
 Michael L Torrie <torriem*chem.byu.edu>
107 107
 Laurent Wacrenier <lwa*teaser.fr>
108 108
 David Woakes <david*mitredata.co.uk>
109
+Dale Woolridge <dwoolridge*drh.net>
109 110
 Leonid Zeitlin <lz*europe.com>
110 111
 Andoni Zubimendi <andoni*lpsat.net>
... ...
@@ -1,3 +1,15 @@
1
+Fri Mar 26 23:23:21 CET 2004 (tk)
2
+---------------------------------
3
+  * clamdscan: don't call getcwd() in streaming mode (patch by Dale Woolridge
4
+	       <dwoolridge*drh.net>)
5
+  * configure: improved checking for TCPwrappers (patch by Tom G. Christensen
6
+	       <tgc*statsbiblioteket.dk>)
7
+
8
+Fri Mar 26 22:53:45 CET 2004 (tk)
9
+---------------------------------
10
+  * clamdscan: don't call getcwd() in streaming mode (patch by Dale Woolridge
11
+	       <dwoolridge*drh.net>)
12
+
1 13
 Fri Mar 26 21:32:28 CET 2004 (tk)
2 14
 ---------------------------------
3 15
   * libclamav: scan VPOP3 mail files (thanks to Steve <steveb*webtribe.net>)
... ...
@@ -35,6 +35,12 @@
35 35
 #include "defaults.h"
36 36
 #include "shared.h"
37 37
 
38
+#ifdef PF_INET
39
+# define SOCKET_INET	PF_INET
40
+#else
41
+# define SOCKET_INET	AF_INET
42
+#endif
43
+
38 44
 int client(const struct optstruct *opt)
39 45
 {
40 46
 	char buff[4096], cwd[200], *file, *scancmd, *pt;
... ...
@@ -85,11 +91,7 @@ int client(const struct optstruct *opt)
85 85
 
86 86
     } else if((cpt = cfgopt(copt, "TCPSocket"))) {
87 87
 
88
-#ifdef PF_INET
89
-	if((sockd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
90
-#else
91
-	if((sockd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
92
-#endif
88
+	if((sockd = socket(SOCKET_INET, SOCK_STREAM, 0)) < 0) {
93 89
 	    perror("socket()");
94 90
 	    mprintf("@Can't create the socket.\n");
95 91
 	    return 2;
... ...
@@ -122,15 +124,14 @@ int client(const struct optstruct *opt)
122 122
     }
123 123
 
124 124
 
125
-    /* we need the full path to the file */
126
-    if(!getcwd(cwd, 200)) {
127
-	mprintf("@Can't get the absolute pathname of the current working directory.\n");
128
-	return 2;
129
-    }
130
-
131
-    
132 125
     if(opt->filename == NULL || strlen(opt->filename) == 0) {
126
+	/* we need the full path to the file */
127
+	if(!getcwd(cwd, 200)) {
128
+	    mprintf("@Can't get the absolute pathname of the current working directory.\n");
129
+	    return 2;
130
+	}
133 131
 	file = (char *) strdup(cwd);
132
+
134 133
     } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */
135 134
 	if(write(sockd, "STREAM", 6) <= 0) {
136 135
 	    mprintf("@Can't write to the socket.\n");
... ...
@@ -156,11 +157,7 @@ int client(const struct optstruct *opt)
156 156
 
157 157
 	/* connect to clamd */
158 158
 
159
-#ifdef PF_INET
160
-	if((wsockd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
161
-#else
162
-	if((wsockd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
163
-#endif
159
+	if((wsockd = socket(SOCKET_INET, SOCK_STREAM, 0)) < 0) {
164 160
 	    perror("socket()");
165 161
 	    mprintf("@Can't create the socket.\n");
166 162
 	    return 2;
... ...
@@ -214,6 +211,11 @@ int client(const struct optstruct *opt)
214 214
 #ifdef C_CYGWIN
215 215
 	    sprintf(file, "%s", opt->filename);
216 216
 #else
217
+	    /* we need the full path to the file */
218
+	    if(!getcwd(cwd, 200)) {
219
+		mprintf("@Can't get the absolute pathname of the current working directory.\n");
220
+		return 2;
221
+	    }
217 222
 	    sprintf(file, "%s/%s", cwd, opt->filename);
218 223
 #endif
219 224
 	}
... ...
@@ -222,6 +224,7 @@ int client(const struct optstruct *opt)
222 222
 
223 223
     scancmd = mcalloc(strlen(file) + 20, sizeof(char));
224 224
     sprintf(scancmd, "CONTSCAN %s", file);
225
+    free(file);
225 226
 
226 227
     if(write(sockd, scancmd, strlen(scancmd)) <= 0) {
227 228
 	mprintf("@Can't write to the socket.\n");
... ...
@@ -9364,25 +9364,28 @@ else
9364 9364
    tcpw=auto
9365 9365
 fi;
9366 9366
 
9367
-if test x"$tcpw" != xno; then
9368
-  err=no
9369
-  if test "${ac_cv_header_tcpd_h+set}" = set; then
9370
-  echo "$as_me:$LINENO: checking for tcpd.h" >&5
9371
-echo $ECHO_N "checking for tcpd.h... $ECHO_C" >&6
9372
-if test "${ac_cv_header_tcpd_h+set}" = set; then
9367
+if test $tcpw != no ; then
9368
+
9369
+for ac_header in tcpd.h
9370
+do
9371
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
9372
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
9373
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
9374
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
9375
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
9373 9376
   echo $ECHO_N "(cached) $ECHO_C" >&6
9374 9377
 fi
9375
-echo "$as_me:$LINENO: result: $ac_cv_header_tcpd_h" >&5
9376
-echo "${ECHO_T}$ac_cv_header_tcpd_h" >&6
9378
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
9379
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
9377 9380
 else
9378 9381
   # Is the header compilable?
9379
-echo "$as_me:$LINENO: checking tcpd.h usability" >&5
9380
-echo $ECHO_N "checking tcpd.h usability... $ECHO_C" >&6
9382
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
9383
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
9381 9384
 cat >conftest.$ac_ext <<_ACEOF
9382 9385
 #line $LINENO "configure"
9383 9386
 #include "confdefs.h"
9384 9387
 $ac_includes_default
9385
-#include <tcpd.h>
9388
+#include <$ac_header>
9386 9389
 _ACEOF
9387 9390
 rm -f conftest.$ac_objext
9388 9391
 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
... ...
@@ -9407,12 +9410,12 @@ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
9407 9407
 echo "${ECHO_T}$ac_header_compiler" >&6
9408 9408
 
9409 9409
 # Is the header present?
9410
-echo "$as_me:$LINENO: checking tcpd.h presence" >&5
9411
-echo $ECHO_N "checking tcpd.h presence... $ECHO_C" >&6
9410
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
9411
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
9412 9412
 cat >conftest.$ac_ext <<_ACEOF
9413 9413
 #line $LINENO "configure"
9414 9414
 #include "confdefs.h"
9415
-#include <tcpd.h>
9415
+#include <$ac_header>
9416 9416
 _ACEOF
9417 9417
 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
9418 9418
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
... ...
@@ -9444,54 +9447,95 @@ echo "${ECHO_T}$ac_header_preproc" >&6
9444 9444
 # So?  What about this header?
9445 9445
 case $ac_header_compiler:$ac_header_preproc in
9446 9446
   yes:no )
9447
-    { echo "$as_me:$LINENO: WARNING: tcpd.h: accepted by the compiler, rejected by the preprocessor!" >&5
9448
-echo "$as_me: WARNING: tcpd.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
9449
-    { echo "$as_me:$LINENO: WARNING: tcpd.h: proceeding with the preprocessor's result" >&5
9450
-echo "$as_me: WARNING: tcpd.h: proceeding with the preprocessor's result" >&2;};;
9447
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
9448
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
9449
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
9450
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
9451 9451
   no:yes )
9452
-    { echo "$as_me:$LINENO: WARNING: tcpd.h: present but cannot be compiled" >&5
9453
-echo "$as_me: WARNING: tcpd.h: present but cannot be compiled" >&2;}
9454
-    { echo "$as_me:$LINENO: WARNING: tcpd.h: check for missing prerequisite headers?" >&5
9455
-echo "$as_me: WARNING: tcpd.h: check for missing prerequisite headers?" >&2;}
9456
-    { echo "$as_me:$LINENO: WARNING: tcpd.h: proceeding with the preprocessor's result" >&5
9457
-echo "$as_me: WARNING: tcpd.h: proceeding with the preprocessor's result" >&2;};;
9452
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
9453
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
9454
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
9455
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
9456
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
9457
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
9458 9458
 esac
9459
-echo "$as_me:$LINENO: checking for tcpd.h" >&5
9460
-echo $ECHO_N "checking for tcpd.h... $ECHO_C" >&6
9461
-if test "${ac_cv_header_tcpd_h+set}" = set; then
9459
+echo "$as_me:$LINENO: checking for $ac_header" >&5
9460
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
9461
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
9462 9462
   echo $ECHO_N "(cached) $ECHO_C" >&6
9463 9463
 else
9464
-  ac_cv_header_tcpd_h=$ac_header_preproc
9464
+  eval "$as_ac_Header=$ac_header_preproc"
9465 9465
 fi
9466
-echo "$as_me:$LINENO: result: $ac_cv_header_tcpd_h" >&5
9467
-echo "${ECHO_T}$ac_cv_header_tcpd_h" >&6
9466
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
9467
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
9468 9468
 
9469 9469
 fi
9470
-if test $ac_cv_header_tcpd_h = yes; then
9471
-  :
9472
-else
9473
-  err=yes
9474
-fi
9470
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
9471
+  cat >>confdefs.h <<_ACEOF
9472
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
9473
+_ACEOF
9474
+
9475
+                echo "$as_me:$LINENO: checking for TCP wrappers library" >&5
9476
+echo $ECHO_N "checking for TCP wrappers library... $ECHO_C" >&6
9477
+                save_LIBS="$LIBS"
9478
+                LIBS="$LIBS -lwrap"
9479
+                cat >conftest.$ac_ext <<_ACEOF
9480
+#line $LINENO "configure"
9481
+#include "confdefs.h"
9475 9482
 
9483
+#include <tcpd.h>
9484
+int allow_severity = 0;
9485
+int deny_severity  = 0;
9476 9486
 
9477
-  echo "$as_me:$LINENO: checking for hosts_ctl in -lwrap" >&5
9478
-echo $ECHO_N "checking for hosts_ctl in -lwrap... $ECHO_C" >&6
9479
-if test "${ac_cv_lib_wrap_hosts_ctl+set}" = set; then
9480
-  echo $ECHO_N "(cached) $ECHO_C" >&6
9487
+struct request_info *req;
9488
+
9489
+#ifdef F77_DUMMY_MAIN
9490
+#  ifdef __cplusplus
9491
+     extern "C"
9492
+#  endif
9493
+   int F77_DUMMY_MAIN() { return 1; }
9494
+#endif
9495
+int
9496
+main ()
9497
+{
9498
+
9499
+hosts_access(req)
9500
+
9501
+  ;
9502
+  return 0;
9503
+}
9504
+_ACEOF
9505
+rm -f conftest.$ac_objext conftest$ac_exeext
9506
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
9507
+  (eval $ac_link) 2>&5
9508
+  ac_status=$?
9509
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9510
+  (exit $ac_status); } &&
9511
+         { ac_try='test -s conftest$ac_exeext'
9512
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9513
+  (eval $ac_try) 2>&5
9514
+  ac_status=$?
9515
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9516
+  (exit $ac_status); }; }; then
9517
+  echo "$as_me:$LINENO: result: -lwrap" >&5
9518
+echo "${ECHO_T}-lwrap" >&6
9519
+                have_wrappers=yes
9520
+                CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lwrap"
9481 9521
 else
9482
-  ac_check_lib_save_LIBS=$LIBS
9483
-LIBS="-lwrap  $LIBS"
9484
-cat >conftest.$ac_ext <<_ACEOF
9522
+  echo "$as_me: failed program was:" >&5
9523
+cat conftest.$ac_ext >&5
9524
+
9525
+                                LIBS="$LIBS -lnsl"
9526
+                cat >conftest.$ac_ext <<_ACEOF
9485 9527
 #line $LINENO "configure"
9486 9528
 #include "confdefs.h"
9487 9529
 
9488
-/* Override any gcc2 internal prototype to avoid an error.  */
9489
-#ifdef __cplusplus
9490
-extern "C"
9491
-#endif
9492
-/* We use char because int might match the return type of a gcc2
9493
-   builtin and then its argument prototype would still apply.  */
9494
-char hosts_ctl ();
9530
+#include <tcpd.h>
9531
+int allow_severity = 0;
9532
+int deny_severity  = 0;
9533
+
9534
+struct request_info *req;
9535
+
9495 9536
 #ifdef F77_DUMMY_MAIN
9496 9537
 #  ifdef __cplusplus
9497 9538
      extern "C"
... ...
@@ -9501,7 +9545,9 @@ char hosts_ctl ();
9501 9501
 int
9502 9502
 main ()
9503 9503
 {
9504
-hosts_ctl ();
9504
+
9505
+hosts_access(req)
9506
+
9505 9507
   ;
9506 9508
   return 0;
9507 9509
 }
... ...
@@ -9518,37 +9564,43 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
9518 9518
   ac_status=$?
9519 9519
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
9520 9520
   (exit $ac_status); }; }; then
9521
-  ac_cv_lib_wrap_hosts_ctl=yes
9521
+  echo "$as_me:$LINENO: result: -lwrap -lnsl" >&5
9522
+echo "${ECHO_T}-lwrap -lnsl" >&6
9523
+                have_wrappers=yes
9524
+                CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lwrap"
9522 9525
 else
9523 9526
   echo "$as_me: failed program was:" >&5
9524 9527
 cat conftest.$ac_ext >&5
9525
-ac_cv_lib_wrap_hosts_ctl=no
9528
+
9529
+                echo "$as_me:$LINENO: result: no" >&5
9530
+echo "${ECHO_T}no" >&6
9531
+                have_wrappers=no
9532
+                LIBS=$save_LIBS
9526 9533
 fi
9527 9534
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
9528
-LIBS=$ac_check_lib_save_LIBS
9529 9535
 fi
9530
-echo "$as_me:$LINENO: result: $ac_cv_lib_wrap_hosts_ctl" >&5
9531
-echo "${ECHO_T}$ac_cv_lib_wrap_hosts_ctl" >&6
9532
-if test $ac_cv_lib_wrap_hosts_ctl = yes; then
9533
-  true
9536
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
9534 9537
 else
9535
-  err=yes
9538
+  have_wrappers=no
9536 9539
 fi
9537 9540
 
9538
-  if test x"$err" = xyes; then
9539
-    if test x"$tcpw" = xyes; then
9540
-      { { echo "$as_me:$LINENO: error: tcpwrappers not available" >&5
9541
-echo "$as_me: error: tcpwrappers not available" >&2;}
9542
-   { (exit 1); exit 1; }; }
9543
-    fi
9544
-  else
9541
+done
9542
+
9543
+
9544
+        if test $have_wrappers = yes ; then
9545 9545
 
9546 9546
 cat >>confdefs.h <<\_ACEOF
9547 9547
 #define WITH_TCPWRAP 1
9548 9548
 _ACEOF
9549 9549
 
9550
-    CLAMAV_MILTER_LIBS="-lwrap"
9551
-  fi
9550
+        elif test $tcpw = yes ; then
9551
+                { { echo "$as_me:$LINENO: error: could not find TCP wrappers" >&5
9552
+echo "$as_me: error: could not find TCP wrappers" >&2;}
9553
+   { (exit 1); exit 1; }; }
9554
+        else
9555
+                { echo "$as_me:$LINENO: WARNING: could not find TCP wrappers, support disabled" >&5
9556
+echo "$as_me: WARNING: could not find TCP wrappers, support disabled" >&2;}
9557
+        fi
9552 9558
 fi
9553 9559
 
9554 9560
 # check for in_port_t definition
... ...
@@ -213,18 +213,47 @@ AC_ARG_WITH(tcpwrappers,
213 213
   esac],
214 214
 [ tcpw=auto ])
215 215
 
216
-if test x"$tcpw" != xno; then
217
-  err=no
218
-  AC_CHECK_HEADER(tcpd.h,,err=yes)
219
-  AC_CHECK_LIB(wrap,hosts_ctl,true,err=yes)
220
-  if test x"$err" = xyes; then
221
-    if test x"$tcpw" = xyes; then
222
-      AC_MSG_ERROR([tcpwrappers not available])
223
-    fi
224
-  else
225
-    AC_DEFINE(WITH_TCPWRAP,1,[tcpwrappers support])
226
-    CLAMAV_MILTER_LIBS="-lwrap"
227
-  fi
216
+if test $tcpw != no ; then
217
+        AC_CHECK_HEADERS(tcpd.h,[
218
+                AC_MSG_CHECKING([for TCP wrappers library])
219
+                save_LIBS="$LIBS"
220
+                LIBS="$LIBS -lwrap"
221
+                AC_TRY_LINK([
222
+#include <tcpd.h>
223
+int allow_severity = 0;
224
+int deny_severity  = 0;
225
+
226
+struct request_info *req;
227
+                ],[
228
+hosts_access(req)
229
+                ],[AC_MSG_RESULT([-lwrap])
230
+                have_wrappers=yes
231
+                CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lwrap"],[
232
+                dnl try with -lnsl
233
+                LIBS="$LIBS -lnsl"
234
+                AC_TRY_LINK([
235
+#include <tcpd.h>
236
+int allow_severity = 0;
237
+int deny_severity  = 0;
238
+
239
+struct request_info *req;
240
+                ],[
241
+hosts_access(req)
242
+                ],[AC_MSG_RESULT([-lwrap -lnsl])
243
+                have_wrappers=yes
244
+                CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lwrap"],[
245
+                AC_MSG_RESULT(no)
246
+                have_wrappers=no
247
+                LIBS=$save_LIBS])],[
248
+                have_wrappers=no])],[have_wrappers=no])
249
+
250
+        if test $have_wrappers = yes ; then
251
+                AC_DEFINE(WITH_TCPWRAP,1, [tcpwrappers support])
252
+        elif test $tcpw = yes ; then
253
+                AC_MSG_ERROR([could not find TCP wrappers])
254
+        else
255
+                AC_MSG_WARN([could not find TCP wrappers, support disabled])
256
+        fi
228 257
 fi
229 258
 
230 259
 # check for in_port_t definition