1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
|
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Copyright 1998 - 2008 Double Precision, Inc. See COPYING for
dnl distribution information.
AC_INIT(couriertcpd, 0.11, [courier-users@lists.sourceforge.net])
>confdefs.h # Kill PACKAGE_ macros
AC_CONFIG_SRCDIR(tcpd.c)
AC_CONFIG_AUX_DIR(../..)
AM_INIT_AUTOMAKE([foreign no-define])
LPATH="$PATH:/usr/local/bin"
AC_CONFIG_HEADERS(config.h)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
SPATH="$LPATH:/usr/kerberos/bin"
AC_PATH_PROG(SED, sed, sed, $SPATH)
if test "$SED" = "sed"
then
AC_MSG_ERROR(sed not found.)
fi
AC_SUBST(SED)
AC_PATH_PROG(SETENV, env, env, $SPATH)
if test "$SETENV" = "env"
then
AC_MSG_ERROR(env not found.)
fi
AC_SUBST(SETENV)
AC_PATH_PROG(PKGCONFIG, pkg-config, [], $SPATH)
if test x$GCC = xyes
then
CFLAGS="-Wall $CFLAGS"
fi
if test x$GXX = xyes
then
CXXFLAGS="-Wall $CXXFLAGS"
fi
CFLAGS="-I$srcdir/.. -I.. -I$srcdir/../.. -I../.. $CFLAGS"
CXXFLAGS="-I$srcdir/.. -I.. -I$srcdir/../.. -I../.. $CXXFLAGS"
AC_PATH_PROG(KRB5CONFIG, krb5-config, krb5-config, $SPATH)
#
#
# We may need libdl for later, not just shared check.
#
saveLIBS="$LIBS"
AC_CHECK_LIB(dl, dlopen, [ LIBDL="-ldl" ])
LIBS="$saveLIBS"
PKG_CHECK_MODULES(LIBIDN, libidn >= 0.0.0, [libidn=yes], [libidn=no])
if test "$libidn" != "yes"
then
AC_MSG_ERROR([libidn not found])
fi
dnl Determine whether transport libraries are created static or shared
AC_SUBST(LIBDL)
. ../../dbobj.config
if test "$dblibrary" != ""
then
dblibrary="../../$dblibrary"
fi
AC_SUBST(dblibrary)
COURIERTCPD=""
if test "$dblibrary" != ""
then
COURIERTCPD=couriertcpd$EXEEXT
fi
AC_SUBST(COURIERTCPD)
LIBS="$saveLIBS"
USENSL=no
saveLIBS="$LIBS"
AC_CHECK_LIB(socket,socket,result=yes,result=no)
if test $result = yes; then
NETLIBS="-lsocket"
else
AC_CHECK_LIB(socket,socket,result=yes,result=no,-lnsl)
if test $result = yes; then
NETLIBS = "-lsocket -lnsl"
USENSL=yes
else
AC_CHECK_LIB(socket,connect,result=yes,result=no)
if test $result = yes; then
NETLIBS="-lsocket"
else
AC_CHECK_LIB(socket,connect,result=yes,result=no,-lnsl)
if test $result = yes; then
NETLIBS="-lsocket -lnsl"
USENSL=yes
fi
fi
fi
fi
if test $USENSL != yes; then
LIBS="$LIBS $NETLIBS"
AC_TRY_LINK_FUNC(inet_addr, [ : ],
[
AC_CHECK_LIB(nsl,inet_addr,result=yes,result=no)
if test $result = yes; then
NETLIBS="$NETLIBS -lnsl"
fi
])
fi
AC_SUBST(NETLIBS)
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_CHECK_HEADERS(sys/types.h sys/time.h sys/stat.h sys/wait.h sys/select.h unistd.h fcntl.h sys/ioctl.h)
AC_HEADER_TIME
dnl Checks for typedefs, structures, and compiler characteristics.
AC_PID_T
AC_TYPE_UID_T
AC_TYPE_SIGNAL
AC_SYS_LARGEFILE
AC_CACHE_CHECK([for socklen_t],
tcpd_cv_hassocklen_t,
AC_COMPILE_IFELSE([
AC_LANG_SOURCE( [
#include <sys/types.h>
#include <sys/socket.h>
socklen_t sl_t;
],[
accept(0, 0, &sl_t);
])],
tcpd_cv_hassocklen_t=yes,
tcpd_cv_hassocklen_t=no)
)
socklen_t="int"
if test $tcpd_cv_hassocklen_t = yes
then
:
else
AC_DEFINE_UNQUOTED(socklen_t, int, [ Default definition for socklen_t ])
fi
dnl Checks for library functions.
AC_CHECK_FUNCS(setpgrp setpgid)
AC_CHECK_FUNC(setpgrp,
[
AC_FUNC_SETPGRP
]
)
AC_ARG_WITH(tcpddns, [ --without-tcpddns Use resolver instead of DNS lookups in couriertcpd ], tcpddns="$withval", tcpddns="Y")
case "$tcpddns" in
n*|N*|0*)
;;
*)
AC_DEFINE_UNQUOTED(TCPDUSERFC1035,1,
[ Whether to use librfc1035.a to resolve via DNS ])
;;
esac
saveLIBS="$LIBS"
LIBS="$LIBS $NETLIBS"
AC_CHECK_FUNC(socketpair, have_socketpair=yes, have_socketpair=no)
AC_ARG_WITH(spipe,
[ --with-spipe=socketpair Create stream pipes as BSD socketpairs
--with-spipe=streams Create stream pipes as SVR3 streams
--with-spipe=pipe Create stream pipes as SVR4 streams],
spipe="$withval", spipe="")
AC_CACHE_CHECK([for SVR3 stream pipes],tcpd_cv_svr3,
AC_TRY_COMPILE( [
#include <sys/types.h>
#include <sys/stream.h>
#include <stropts.h>
#include <fcntl.h>
],[ {
struct strfdinsert ins;
queue_t *pointer;
int i=I_FDINSERT;
}
], tcpd_cv_svr3=yes, tcpd_cv_svr3=no))
AC_CACHE_CHECK( [for SVR4 stream pipes],tcpd_cv_svr4,
AC_TRY_RUN(
[
changequote(<<,>>)
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
int pipefd[2];
char c;
c=0;
if (pipe(pipefd) == 0 && write(pipefd[0], &c, 1) == 1 &&
read(pipefd[1], &c, 1) == 1 &&
write(pipefd[1], &c, 1) == 1 &&
read(pipefd[0], &c, 1) == 1)
{
exit (0);
}
exit (1);
return (1);
}
changequote([,])
]
,
tcpd_cv_svr4=yes,
tcpd_cv_svr4=no,
tcpd_cv_svr4="n/a")
)
LIBS="$saveLIBS"
if test "$spipe" = ""
then
if test "$have_socketpair" = "yes"
then
spipe="socketpair"
fi
fi
if test "$spipe" = ""
then
if test "$tcpd_cv_svr3" = "yes"
then
spipe="streams"
fi
fi
if test "$spipe" = ""
then
if test "$tcpd_cv_svr4" = "yes"
then
spipe="pipe"
fi
fi
case "$spipe" in
socketpair)
AC_DEFINE_UNQUOTED(HAVE_SPIPE_SOCKETPAIR, 1,
[ Whether to use socketpair() to create a bidirectional pipe ])
;;
streams)
AC_DEFINE_UNQUOTED(HAVE_SPIPE_SVR3, 1,
[ Whether to use streams to create a vidirectional pipe ])
;;
pipe)
AC_DEFINE_UNQUOTED(HAVE_SPIPE_SVR4, 1,
[ Whether pipe() is SvR4-style that's a bidirectional pipe ])
;;
*)
AC_MSG_ERROR(Cannot determine stream pipe support. If cross-compiling use --with-spipe=pipe to get SVR4 stream pipes.)
;;
esac
AC_MSG_CHECKING([for stream pipes])
AC_MSG_RESULT($spipe)
AC_CHECK_HEADER(openssl/ssl.h,have_ssl_h=yes,have_ssl_h=no)
AC_CHECK_LIB(ssl, SSL_load_error_strings, have_ssl=yes, have_ssl=no,
-lcrypto)
AC_CHECK_LIB(ssl, SSL_library_init, have_ssl=yes)
AC_CHECK_LIB(ssl, OPENSSL_init_ssl, have_ssl=yes)
if test "$have_ssl" = "yes"
then
if test "$have_ssl_h" = "no"
then
AC_MSG_WARN(OpenSSL runtime libraries installed but the header files are missing)
AC_MSG_WARN(disabling OpenSSL support.)
have_ssl="no"
fi
fi
KRBFLAGS=""
if test "$have_ssl" = "yes"
then
LIBCOURIERTLSOPENSSL=libcouriertlsopenssl.la
if test "$KRB5CONFIG" != "krb5-config"
then
AC_MSG_CHECKING(whether OpenSSL requires Kerberos)
AC_TRY_COMPILE( [
#include <openssl/ssl.h>
], [ int x=1; ], :,
[
KRBFLAGS=`$KRB5CONFIG --cflags`
CFLAGS="$CFLAGS $KRBFLAGS"
AC_TRY_COMPILE( [
#include <openssl/ssl.h>
], [ int x=1; ], [ KRBLIBS="`$KRB5CONFIG --libs`" ],
AC_MSG_ERROR(OpenSSL test build failed) )
]
)
if test "$KRBLIBS" = ""
then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
fi
openssldep="-lssl -lcrypto $KRBLIBS $NETLIBS ../random128/librandom128.la"
fi
# GnuTLS
have_gnutls=no
AC_MSG_CHECKING([for GnuTLS])
if test "$PKGCONFIG" != ""
then
if $PKGCONFIG --modversion gnutls >/dev/null 2>&1
then
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags gnutls`"
AC_TRY_COMPILE( [
#include <gnutls/gnutls.h>
],
[
],
[ have_gnutls=yes
],
[
have_gnutls="no: \#include <gnutls/gnutls.h> failed"
])
CPPFLAGS="$save_CPPFLAGS"
else
have_gnutls="no: pkgconfig --modversion gnutls failed"
fi
else
have_gnutls="no: pkg-config not found"
fi
AC_MSG_RESULT($have_gnutls)
if test "$have_gnutls" = "yes"
then
LIBCOURIERTLSGNUTLS="libcouriertlsgnutls.la"
CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags gnutls`"
have_gnutls3=no
PKG_CHECK_EXISTS([gnutls >= 3.0], [have_gnutls3=yes])
if test "x$have_gnutls3" = "xno"
then
gnutlsdep="`$PKGCONFIG --libs gnutls` -lgnutls-extra"
else
gnutlsdep="`$PKGCONFIG --libs gnutls`"
AC_DEFINE([HAVE_GNUTLS3], [1], [Use GnuTLS3])
fi
fi
AC_CHECK_SIZEOF(gnutls_transport_ptr_t,0, [
AC_INCLUDES_DEFAULT
#include <gnutls/gnutls.h>
])
AC_CHECK_SIZEOF(long,0)
cast_to_ptr_t=""
if test "$gnutls_transport_ptr_t_SIZEOF" = "$long_SIZEOF"
then
if test "$gnutls_transport_ptr_t_SIZEOF" != 0
then
cast_to_ptr_t="(long)"
fi
fi
AC_DEFINE_UNQUOTED(GNUTLS_CAST_PTR_T, $cast_to_ptr_t,[How to cast a file descriptor to gnutls_transport_ptr_t])
echo "cppflags='$KRBFLAGS'" >couriertls.config
AC_SUBST(openssldep)
AC_SUBST(gnutlsdep)
soxdep="`cat ../soxwrap/soxlibs.dep`"
AC_SUBST(soxdep)
# Choose GnuTLS or OpenSSL
AC_ARG_WITH(gnutls, [ --with-gnutls Use GnuTLS even if OpenSSL is available],
[
if test "$withval" = "yes"
then
if test "$have_gnutls" = "yes"
then
have_ssl="no"
else
AC_MSG_ERROR(Cannot find GnuTLS)
fi
else
have_gnutls="no"
fi
],
[
if test "$have_ssl" = "yes"
then
have_gnutls="no"
fi
])
if test "$have_gnutls" = "yes"
then
TLSLIBRARY="$LIBCOURIERTLSGNUTLS"
STARTTLS=couriertls$EXEEXT
BUILDLIBCOURIERTLS=libcouriertls.la
CRYPTLIBS=""
AC_MSG_CHECKING([for libgcrypt])
save_LIBS="$LIBS"
LIBS="$LIBS -lgcrypt"
AC_TRY_LINK( [
#include <gcrypt.h>
], [
gcry_cipher_open(NULL, 0, 0, 0);
], [
AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED(HAVE_GCRYPT, 1,
[ Whether libgcrypt is installed ])
CRYPTLIBS="$CRYPTLIBS -lgcrypt"
], [
AC_MSG_RESULT(no)
have_gcrypt="no"
])
if test "$have_gcrypt" = "no"
then
AC_MSG_ERROR(gcrypt header file is required for GNUTLS)
fi
AC_MSG_CHECKING([for libgpg-error])
LIBS="$LIBS -lgpg-error"
AC_TRY_LINK( [
#include <gcrypt.h>
], [
gpg_err_code_from_errno(0);
], [
AC_MSG_RESULT(yes)
CRYPTLIBS="$CRYPTLIBS -lgpg-error"
], [
AC_MSG_RESULT(no)
])
LIBS="$save_LIBS"
echo "ssllib=gnutls" >>couriertls.config
else
if test "$have_ssl" = "yes"
then
save_LIBS="$LIBS"
LIBS="-lcrypto $KRBLIBS $LIBS"
AC_MSG_CHECKING(for OpenSSL 0.9.7)
AC_TRY_LINK( [
#include <openssl/evp.h>
#include <openssl/rand.h>
],
[
EVP_CIPHER_CTX ctx;
char dummy[1];
unsigned char a[1], b[1];
EVP_CIPHER_CTX_init(&ctx);
EVP_EncryptInit_ex(&ctx, EVP_des_cbc(), NULL, a, b);
RAND_pseudo_bytes(dummy, 1);
], [
CRYPTLIBS="-lcrypto $KRBLIBS"
AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED(HAVE_OPENSSL097, 1,
[ Whether OpenSSL 0.9.7 is installed ])
], [
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for OpenSSL 1.1.0)
AC_TRY_LINK( [
#include <openssl/evp.h>
#include <openssl/rand.h>
],
[
char dummy[1];
unsigned char a[1], b[1];
EVP_CIPHER_CTX *ctx=EVP_CIPHER_CTX_new();
EVP_EncryptInit_ex(ctx, EVP_des_cbc(), NULL, a, b);
RAND_bytes(dummy, 1);
], [
CRYPTLIBS="-lcrypto $KRBLIBS"
AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED(HAVE_OPENSSL110, 1,
[ Whether OpenSSL 1.1.0 is installed ])
], [
AC_MSG_RESULT(no)
])
]
)
LIBS="-lssl $LIBS"
AC_CHECK_FUNCS(TLSv1_1_method TLSv1_2_method)
LIBS="$save_LIBS"
AC_TRY_COMPILE( [
#include <openssl/ssl.h>
],
[
SSL_get_servername((SSL *)0, TLSEXT_NAMETYPE_host_name);
], [
AC_DEFINE_UNQUOTED(HAVE_OPENSSL_SNI,1,[ When OpenSSL supports SNI ])
])
TLSLIBRARY="$LIBCOURIERTLSOPENSSL"
STARTTLS=couriertls$EXEEXT
BUILDLIBCOURIERTLS=libcouriertls.la
echo "ssllib=openssl" >>couriertls.config
fi
fi
echo "couriertls=$STARTTLS" >>couriertls.config
echo "cryptlibs=\"`echo $CRYPTLIBS`\"" >>couriertls.config
# Do not built the other SSL library. ... Except if I'm the maintainer
if test ! -d "$srcdir/CVS"
then
if test "$have_ssl" = "yes"
then
LIBCOURIERTLSGNUTLS=""
fi
if test "$have_gnutls" = "yes"
then
LIBCOURIERTLSOPENSSL=""
fi
fi
AC_SUBST(LIBCOURIERTLSOPENSSL)
AC_SUBST(LIBCOURIERTLSGNUTLS)
AC_SUBST(CRYPTLIBS)
AC_SUBST(STARTTLS)
AC_SUBST(BUILDLIBCOURIERTLS)
AC_SUBST(TLSLIBRARY)
AM_CONDITIONAL(HAVE_SGML, test -d ${srcdir}/../docbook)
AC_OUTPUT(Makefile)
|