source: trunk/configure.ac@ 439

Last change on this file since 439 was 439, checked in by katerina, 11 years ago

Fix for ticket #343 (Static compile with port check fails)

File size: 78.9 KB
Line 
1dnl We want to override the standard _AC_INIT_PARSE_ARGS
2dnl
3AU_ALIAS([_AC_INIT_PARSE_ARGS], [SH_INIT_PARSE_ARGS])
4AU_ALIAS([_AC_INIT_help], [SH_INIT_HELP])
5
6AC_INIT(src/samhain.c)
7
8
9AC_ARG_VAR([LIBS], [libraries to link against, e.g. -lintl])
10
11dnl
12dnl start
13dnl
14AM_INIT_AUTOMAKE(samhain, 3.0.13)
15AC_DEFINE([SAMHAIN], 1, [Application is samhain])
16AC_CANONICAL_HOST
17
18dnl
19dnl checks for programs
20dnl
21
22AC_PROG_CC
23if test "$host" != "$build"; then
24 AC_CHECK_PROGS(BUILD_CC, gcc cc)
25else
26 BUILD_CC=$CC
27fi
28AC_PROG_CPP
29AC_PROG_INSTALL
30AC_PROG_LN_S
31AC_PROG_AWK
32SH_PROG_LD
33AC_PATH_PROG(cmd_hostname,hostname)
34AC_SUBST(cmd_hostname)
35AC_SUBST(BUILD_CC)
36
37AC_HEADER_STDC
38dnl
39dnl first one is a dummy because of an autoconf bug
40dnl (no HAVE_... for first one)
41dnl
42AC_CHECK_HEADERS([sys/ipc.h sys/msg.h sys/uio.h fcntl.h])
43
44
45AC_MSG_CHECKING([for OS specific issues])
46mydebugflag=no
47myneedg3=no
48uid_cast="signed long"
49selectconfig=linux
50mynetbsd=no
51sh_use_lcaps="undef"
52dnmalloc_ok=yes
53sh_use_pie=yes
54
55case "$host_os" in
56
57 *linux*)
58 sh_use_lcaps="yes"
59 AC_DEFINE(HOST_IS_LINUX)
60 AC_DEFINE(HAVE_EXT2_IOCTLS)
61 AC_MSG_RESULT([use ioctl to get e2fs flags])
62 case "$host_cpu" in
63 i*86*)
64 AC_DEFINE(HOST_IS_I86LINUX)
65 ;;
66 x86_64)
67 AC_DEFINE([HOST_IS_64LINUX], 1, [Define if host OS is 64bit Linux])
68 ;;
69 *)
70 ;;
71 esac
72 ;;
73
74 *osf*)
75 AC_DEFINE([HOST_IS_OSF], 1, [Define if host OS is OSF])
76 if test "x$GCC" != "xyes"; then
77 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
78 CFLAGS="$CFLAGS -O2 -assume noaligned_objects"
79 myneedg3=yes
80 AC_MSG_RESULT([compiler needs assume noaligned_objects])
81 else
82 AC_MSG_RESULT([none])
83 fi
84 ;;
85
86 *cygwin*)
87 AC_DEFINE(HOST_IS_CYGWIN)
88 AC_DEFINE([USE_REGISTRY_CHECK], 1, [Define for registry check])
89 dnmalloc_ok=no
90 AC_MSG_RESULT([no trusted paths and no dnmalloc])
91 ;;
92
93 *darwin*|*apple*)
94 AC_DEFINE(HOST_IS_DARWIN)
95 dnmalloc_ok=no
96 AC_MSG_RESULT([check resource forks, no dnmalloc])
97 ;;
98
99 *freebsd8*|*freebsd9*)
100 AC_DEFINE(HOST_IS_FREEBSD)
101 selectconfig=freebsd
102 case "$host_cpu" in
103 amd64|x86_64)
104 dnmalloc_ok=no
105 AC_MSG_RESULT([no dnmalloc])
106 ;;
107 *)
108 AC_MSG_RESULT([none])
109 ;;
110 esac
111 ;;
112
113 *freebsd7*)
114 AC_DEFINE(HOST_IS_FREEBSD)
115 selectconfig=freebsd
116 case "$host_cpu" in
117 amd64|x86_64)
118 sh_use_pie=no
119 dnmalloc_ok=no
120 AC_MSG_RESULT([no dnmalloc and broken compiler toolchain])
121 ;;
122 *)
123 AC_MSG_RESULT([none])
124 ;;
125 esac
126 ;;
127
128 *freebsd*)
129 AC_DEFINE(HOST_IS_FREEBSD)
130 selectconfig=freebsd
131 AC_MSG_RESULT([none])
132 ;;
133
134 *openbsd*)
135 AC_DEFINE([HOST_IS_OPENBSD], 1, [Define if host OS is OPENBSD])
136 selectconfig=freebsd
137 dnmalloc_ok=no
138 AC_MSG_RESULT([dnmalloc does not work with pthreads])
139 ;;
140
141 *netbsd*)
142 mynetbsd=yes
143 selectconfig=netbsd
144 AC_MSG_RESULT([bug with libresolve])
145 ;;
146
147 *solaris*)
148 selectconfig=solaris
149 AC_DEFINE(HOST_IS_SOLARIS)
150 case "$host_cpu" in
151 i*86)
152 AC_DEFINE(HOST_IS_I86SOLARIS)
153 AC_MSG_RESULT([vsnprintf prototype])
154 ;;
155 *)
156 AC_MSG_RESULT([none])
157 ;;
158 esac
159 if test "x$GCC" != "xyes"; then
160 if test ! -z "`echo "$CFLAGS" | grep "\-g" 2> /dev/null`" ; then
161 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
162 fi
163 if test -z "`echo "$CFLAGS" | grep "\-xO2" 2> /dev/null`"; then
164 CFLAGS="$CFLAGS -xO2"
165 fi
166 if test -z "`echo "$CFLAGS" | grep "\-Xa" 2> /dev/null`"; then
167 CFLAGS="$CFLAGS -Xa"
168 fi
169 LIBS="-lc $LIBS"
170 fi
171 ;;
172
173
174 *sun*)
175 selectconfig=solaris
176 AC_DEFINE(HOST_IS_SOLARIS)
177 AC_MSG_RESULT([none])
178 ;;
179
180 *aix*)
181 AC_DEFINE(HOST_IS_AIX)
182 selectconfig=aix5.2.0
183 uid_cast="unsigned long"
184 if test "x$GCC" != "xyes"; then
185 if test ! -z "`echo "$CFLAGS" | grep "\-g" 2> /dev/null`" ; then
186 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
187 fi
188 if test -z "`echo "$CFLAGS" | grep "\-O3" 2> /dev/null`"; then
189 CFLAGS="$CFLAGS -O3"
190 fi
191 if test -z "`echo "$CFLAGS" | grep "\-qstrict" 2> /dev/null`"; then
192 CFLAGS="$CFLAGS -qstrict"
193 fi
194 AC_MSG_RESULT([AIX size_t in the accept call and optimize O3 qstrict])
195 else
196 AC_MSG_RESULT([AIX size_t in the accept call])
197 fi
198 ;;
199
200 *hpux*)
201 AC_MSG_RESULT([HPUX need _XOPEN_SOURCE_EXTENDED for h_errno])
202 AC_DEFINE(HOST_IS_HPUX)
203 if test "x$GCC" != "xyes"; then
204 if test ! -z "`echo "$CFLAGS" | grep "\-g" 2> /dev/null`" ; then
205 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
206 fi
207 if test -z "`echo "$CFLAGS" | grep "\+O2" 2> /dev/null`"; then
208 CFLAGS="$CFLAGS +O2"
209 fi
210 fi
211 ;;
212
213 *ultrix*)
214 AC_MSG_RESULT([ULTRIX getcwd uses popen])
215 AC_DEFINE(HAVE_BROKEN_GETCWD)
216 ;;
217
218 *)
219 AC_MSG_RESULT([none])
220 ;;
221esac
222
223AC_SUBST(selectconfig)
224AC_DEFINE_UNQUOTED(UID_CAST, ${uid_cast})
225
226
227
228dnl *****************************************
229dnl
230dnl checks for header files
231dnl
232dnl *****************************************
233
234AC_HEADER_DIRENT
235AC_HEADER_MAJOR
236AC_HEADER_TIME
237dnl used in minilzo.c
238AC_HEADER_STAT
239AC_DECL_SYS_SIGLIST
240
241AC_CHECK_HEADERS(stddef.h libgen.h sched.h malloc.h sys/uio.h \
242 sys/mman.h sys/param.h sys/inotify.h \
243 sys/vfs.h mntent.h \
244 sys/select.h sys/socket.h netinet/in.h \
245 regex.h glob.h fnmatch.h \
246 linux/ext2_fs.h linux/fs.h ext2fs/ext2_fs.h asm/segment.h \
247 elf.h linux/elf.h auparse.h \
248 paths.h arpa/nameser.h arpa/nameser_compat.h \
249 rpc/rpcent.h rpc/rpc.h sys/statvfs.h,
250 [],
251 [],
252 [#include <sys/types.h>]
253)
254
255
256AC_CHECK_HEADER(utmpx.h, sh_utmpx="yes", sh_utmpx="no")
257if test "x$sh_utmpx" = "xyes"; then
258 AC_DEFINE(HAVE_UTMPX_H)
259 AC_EGREP_HEADER(ut_host, utmpx.h, AC_DEFINE(HAVE_UTHOST) )
260 AC_EGREP_HEADER(ut_addr, utmpx.h, AC_DEFINE(HAVE_UTADDR) )
261 AC_EGREP_HEADER(ut_addr_v6, utmpx.h, AC_DEFINE(HAVE_UTADDR_V6) )
262 AC_EGREP_HEADER(ut_xtime,utmpx.h, AC_DEFINE(HAVE_UTXTIME) )
263 AC_EGREP_HEADER(ut_type, utmpx.h, AC_DEFINE(HAVE_UTTYPE) )
264else
265 AC_EGREP_HEADER(ut_addr, utmp.h, AC_DEFINE(HAVE_UTADDR) )
266 AC_EGREP_HEADER(ut_host, utmp.h, AC_DEFINE(HAVE_UTHOST) )
267 AC_EGREP_HEADER(ut_type, utmp.h, AC_DEFINE(HAVE_UTTYPE) )
268fi
269
270dnl
271dnl figure out where acct.h lives
272dnl and whether fields are int/comp_t
273dnl
274dnl GNU Accounting Utilities
275dnl Copyright (C) 1993, 1996, 1997, 2003, 2005 Free Software Foundation, Inc.
276dnl The GNU Accounting Utilities are free software; you can redistribute
277dnl them and/or modify them under the terms of the GNU General Public
278dnl License as published by the Free Software Foundation; either version
279dnl 2, or (at your option) any later version.
280dnl
281AC_CHECK_HEADER(sys/acct.h,
282 AC_DEFINE(HAVE_SYS_ACCT_H, ,
283 [Define if you have the <sys/acct.h> header file.])
284 AC_HEADER_EGREP(ac_utime, sys/acct.h,
285 AC_DEFINE(HAVE_ACUTIME, ,
286 [Define if <sys/acct.h> has the AC_UTIME field.])
287 AC_HEADER_EGREP(comp_t.*ac_utime, sys/acct.h,
288 AC_DEFINE(ACUTIME_COMPT, ,
289 [Define if <sys/acct.h>'s AC_UTIME field is a COMP_T.]))
290 )
291 AC_HEADER_EGREP(ac_stime, sys/acct.h,
292 AC_DEFINE(HAVE_ACSTIME, ,
293 [Define if <sys/acct.h> has the AC_STIME field.])
294 AC_HEADER_EGREP(comp_t.*ac_stime, sys/acct.h,
295 AC_DEFINE(ACSTIME_COMPT, ,
296 [Define if <sys/acct.h>'s AC_STIME field is a COMP_T.]))
297 )
298 AC_HEADER_EGREP(ac_etime, sys/acct.h,
299 AC_DEFINE(HAVE_ACETIME, ,
300 [Define if <sys/acct.h> has the AC_ETIME field.])
301 AC_HEADER_EGREP(comp_t.*ac_etime, sys/acct.h,
302 AC_DEFINE(ACETIME_COMPT, ,
303 [Define if <sys/acct.h>'s AC_ETIME field is a COMP_T.]))
304 )
305 AC_HEADER_EGREP(ac_io, sys/acct.h,
306 AC_DEFINE(HAVE_ACIO, ,
307 [Define if <sys/acct.h> has the AC_IO field.])
308 AC_HEADER_EGREP(comp_t.*ac_io, sys/acct.h,
309 AC_DEFINE(ACIO_COMPT, ,
310 [Define if <sys/acct.h>'s AC_IO field is a COMP_T.]))
311 )
312 AC_HEADER_EGREP(ac_mem, sys/acct.h,
313 AC_DEFINE(HAVE_ACMEM, ,
314 [Define if <sys/acct.h> has the AC_MEM field.])
315 AC_HEADER_EGREP(comp_t.*ac_mem, sys/acct.h,
316 AC_DEFINE(ACMEM_COMPT, ,
317 [Define if <sys/acct.h>'s AC_MEM field is a COMP_T.]))
318 )
319 AC_HEADER_EGREP(ac_minflt, sys/acct.h,
320 AC_HEADER_EGREP(ac_majflt, sys/acct.h,
321 AC_HEADER_EGREP(ac_swaps, sys/acct.h,
322 AC_DEFINE(HAVE_PAGING, ,
323 [Define if <sys/acct.h> has the AC_MINFLT, AC_MAJFLT and AC_SWAPS fields.])
324 AC_HEADER_EGREP(comp_t.*ac_minflt, sys/acct.h,
325 AC_DEFINE(ACMINFLT_COMPT, ,
326 [Define if <sys/acct.h>'s AC_MINFLT field is a COMP_T.]))
327 AC_HEADER_EGREP(comp_t.*ac_mayflt, sys/acct.h,
328 AC_DEFINE(ACMAJFLT_COMPT, ,
329 [Define if <sys/acct.h>'s AC_MAJFLT field is a COMP_T.]))
330 AC_HEADER_EGREP(comp_t.*ac_swaps, sys/acct.h,
331 AC_DEFINE(ACSWAPS_COMPT, ,
332 [Define if <sys/acct.h>'s AC_SWAPS field is a COMP_T.]))
333 )
334 )
335 )
336 AC_HEADER_EGREP(comp_t, sys/acct.h, AC_DEFINE(HAVE_COMP_T, ,
337 [Define if <sys/acct.h> uses the COMP_T type.]))
338 AC_HEADER_EGREP([struct acct_v3], sys/acct.h, AC_DEFINE(HAVE_ACCT_V3, ,
339 [Define if <sys/acct.h> has struct acct_v3.]))
340 AC_HEADER_EGREP([struct acctv2], sys/acct.h, AC_DEFINE(HAVE_ACCTV2, ,
341 [Define if <sys/acct.h> has struct acctv2.]))
342
343 )
344
345
346dnl need to check because AIX 4.2 does not have it
347dnl
348AC_CHECK_MEMBERS([struct statfs.f_flags],[],[],[
349#ifdef HAVE_SYS_TYPES_H
350#include <sys/types.h>
351#endif
352#ifdef HAVE_SYS_STAT_H
353#include <sys/stat.h>
354#endif
355#ifdef HAVE_SYS_VFS_H
356#include <sys/vfs.h>
357#endif
358#ifdef HAVE_UNISTD_H
359#include <unistd.h>
360#endif
361])
362
363AC_SYS_LARGEFILE
364
365dnl
366dnl check whether _POSIX_SOURCE is required
367dnl
368SAMHAIN_POSIX
369
370
371dnl *****************************************
372dnl
373dnl Checks for library functions.
374dnl
375dnl *****************************************
376AC_FUNC_STRFTIME
377AC_CHECK_FUNCS(memcmp memcpy memmove memset getpwent endpwent \
378 gettimeofday strlcat strlcpy strstr strchr strerror strsignal \
379 seteuid setreuid setresuid lstat getwd getcwd ptrace \
380 usleep setpriority getpeereid nanosleep \
381 strptime basename sched_yield hasmntopt \
382 inet_aton gethostbyname setutent setrlimit gethostname uname \
383 getaddrinfo getnameinfo \
384 initgroups getpagesize \
385 ttyname fchmod writev mmap tzset \
386 getsid getpriority getpgid statvfs \
387 strerror_r getgrgid_r getpwnam_r getpwuid_r \
388 gmtime_r localtime_r rand_r readdir_r strtok_r \
389 mincore posix_fadvise inotify_init1
390)
391AC_CHECK_FUNC(statfs, AC_DEFINE(HAVE_STATFS) statfs="yes", statfs="no")
392SL_CHECK_VA_COPY
393AC_CHECK_FUNCS(vsnprintf, [SL_CHECK_VSNPRINTF])
394AC_CHECK_MLOCK
395SH_STRFTIME_Z
396
397AC_MSG_CHECKING(how to get filesystem type)
398fstype=no
399# The order of these tests is important.
400AC_TRY_CPP([#include <sys/statvfs.h>
401#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4)
402if test $fstype = no; then
403AC_TRY_CPP([#include <sys/statfs.h>
404#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3)
405fi
406if test $fstype = no; then
407AC_TRY_CPP([#include <sys/statfs.h>
408#include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX)
409fi
410if test $fstype = no; then
411AC_TRY_CPP([#include <mntent.h>], AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD)
412fi
413if test $fstype = no; then
414AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF)
415fi
416if test $fstype = no; then
417AC_TRY_CPP([#include <sys/mount.h>
418#include <sys/fs_types.h>], AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix)
419fi
420AC_MSG_RESULT($fstype)
421
422sh_libsocket=
423
424dnl Solaris needs -lsocket and -lnsl. Unisys system includes
425dnl gethostbyname in libsocket but needs libnsl for socket.
426AC_CHECK_LIB(nsl, gethostbyname)
427AC_CHECK_LIB(socket, socket, ac_need_libsocket=1, ac_try_nsl=1)
428if test x$ac_need_libsocket = x1; then
429 LIBS="$LIBS -lsocket"
430 sh_libsocket="-lsocket"
431fi
432if test x$ac_try_nsl = x1; then
433 AC_CHECK_LIB(nsl, gethostbyname, ac_need_libnsl=1)
434 if test x$ac_need_libnsl = x1
435 then
436 LIBS="$LIBS -lnsl"
437 fi
438fi
439AC_SUBST(sh_libsocket)
440
441AC_CHECK_LIB(socket, res_search, [
442 AC_CHECK_LIB(resolv, dn_skipname)
443 AC_CHECK_LIB(resolv, __dn_skipname)
444 if test x$ac_need_libsocket = x1; then
445 :
446 else
447 LIBS="$LIBS -lsocket"
448 fi
449 ], [
450 AC_CHECK_LIB(resolv, res_search, [
451 LIBS="$LIBS -lresolv"
452 ], [
453 AC_CHECK_LIB(resolv, dn_skipname)
454 AC_CHECK_LIB(resolv, __dn_skipname)
455 ])
456 ])
457
458sh_auparse=no
459
460if test "x$ac_cv_header_auparse_h" = "xyes"
461then
462 AC_CHECK_LIB(auparse, auparse_find_field, [
463 LIBS="$LIBS -lauparse"
464 sh_auparse=yes
465 AC_DEFINE(HAVE_AUPARSE_LIB, 1, [Define if you have the auparse lib])
466 ])
467fi
468
469dnl arguments for accept
470
471dnl check for Unix98 socklen_t (found on
472dnl xemacs-patches mailing list, written
473dnl by Martin Buchholz)
474dnl
475dnl On Darwin(MacOSX) socklen_t needs to be
476dnl an int (see accept man page), on all other
477dnl unix systems we need a size_t.
478
479AC_MSG_CHECKING(for socklen_t)
480AC_TRY_COMPILE([
481#ifdef HAVE_SYS_TYPES_H
482#include <sys/types.h>
483#endif
484#ifdef HAVE_SYS_SOCKET_H
485#include <sys/socket.h>
486#endif
487 socklen_t x;
488], [],[
489 AC_MSG_RESULT(yes)
490 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[socklen_t], [type of arg3 of accept])
491 AC_DEFINE([HAVE_SOCKLEN_T], 1, [Define if you have socklen_t])
492],[
493 AC_TRY_COMPILE([
494#ifdef HAVE_SYS_TYPES_H
495#include <sys/types.h>
496#endif
497#ifdef HAVE_SYS_SOCKET_H
498#include <sys/socket.h>
499#endif
500 int accept (int, struct sockaddr *, size_t *);
501 ],[],[
502 AC_MSG_RESULT(size_t)
503 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[size_t], [type of arg3 of accept])
504 ], [
505 AC_MSG_RESULT(int)
506 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[int], [type of arg3 of accept])
507 ]
508 )
509])
510
511dnl *****************************************
512dnl checks for extended attribute or ACL
513dnl support
514dnl *****************************************
515
516sh_CHECK_XATTR
517sh_CHECK_POSIX_ACL
518
519dnl *****************************************
520dnl checks for typedefs
521dnl *****************************************
522
523AC_C_LONG_DOUBLE
524SH_CHECK_TYPEDEF(long long, HAVE_LONG_LONG)
525SH_CHECK_TYPEDEF(uint16_t, HAVE_UINT16_T)
526SH_CHECK_TYPEDEF(uint64_t, HAVE_UINT64_T)
527if test "$sh_HAVE_LONG_LONG" = "yes"; then
528 AC_CHECK_SIZEOF(unsigned long long, 4)
529 sh_sizeof_unsigned_long_long=`echo "$ac_cv_sizeof_unsigned_long_long" | sed 's%[^0-9]%%g'`
530 if test "$sh_sizeof_unsigned_long_long" = "8"; then
531 AC_DEFINE(HAVE_LONG_LONG_64, 1, [Define if you have 64bit long long])
532 fi
533fi
534
535AC_CHECK_TYPE(ptrdiff_t, long)
536AC_TYPE_SIZE_T
537AC_CHECK_SIZEOF(char *, 4)
538AC_CHECK_SIZEOF(size_t, 4)
539
540AC_CHECK_SIZEOF(unsigned long, 4)
541AC_CHECK_SIZEOF(unsigned int, 4)
542AC_CHECK_SIZEOF(unsigned short, 2)
543
544
545sh_sizeof_unsigned_long=`echo "$ac_cv_sizeof_unsigned_long" | sed 's%[^0-9]%%g'`
546if test "$sh_sizeof_unsigned_long" = "4"; then
547 AC_DEFINE(HAVE_LONG_32)
548fi
549if test "$sh_sizeof_unsigned_long" = "8"; then
550 AC_DEFINE(HAVE_LONG_64)
551fi
552sh_sizeof_unsigned_int=`echo "$ac_cv_sizeof_unsigned_int" | sed 's%[^0-9]%%g'`
553if test "$sh_sizeof_unsigned_int" = "4"; then
554 AC_DEFINE(HAVE_INT_32)
555fi
556sh_sizeof_unsigned_short=`echo "$ac_cv_sizeof_unsigned_short" | sed 's%[^0-9]%%g'`
557if test "$sh_sizeof_unsigned_short" = "4"; then
558 AC_DEFINE(HAVE_SHORT_32)
559fi
560
561dnl
562dnl check for 64 bit programming environment
563dnl
564SAMHAIN_64
565
566
567dnl *****************************************
568dnl checks for structures
569dnl *****************************************
570
571AC_STRUCT_TM
572
573dnl
574dnl from e2fsprogs
575dnl
576AC_MSG_CHECKING(whether struct stat has a st_flags field)
577AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
578 AC_TRY_COMPILE([#include <sys/stat.h>],
579 [struct stat stat; stat.st_flags = 0;],
580 [e2fsprogs_cv_struct_st_flags=yes],
581 [e2fsprogs_cv_struct_st_flags=no]))
582AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
583if test "$e2fsprogs_cv_struct_st_flags" = yes; then
584 AC_MSG_CHECKING(whether st_flags field is useful)
585 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
586 AC_TRY_COMPILE([#include <sys/stat.h>],
587 [struct stat stat; stat.st_flags |= UF_IMMUTABLE;],
588 [e2fsprogs_cv_struct_st_flags_immut=yes],
589 [e2fsprogs_cv_struct_st_flags_immut=no]))
590 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
591 if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
592 AC_DEFINE(HAVE_STAT_FLAGS)
593 fi
594fi
595
596dnl
597dnl from dbus
598dnl
599AC_MSG_CHECKING(for struct cmsgcred)
600AC_TRY_COMPILE([
601#include <sys/types.h>
602#include <sys/socket.h>
603],[
604struct cmsgcred cred;
605
606cred.cmcred_pid = 0;
607],sh_have_struct_cmsgcred=yes,sh_have_struct_cmsgcred=no)
608AC_MSG_RESULT($sh_have_struct_cmsgcred)
609
610if test x$sh_have_struct_cmsgcred = xyes; then
611 AC_DEFINE(HAVE_STRUCT_CMSGCRED,1,[Have cmsgcred structure])
612fi
613
614AC_MSG_CHECKING(for struct fcred)
615AC_TRY_COMPILE([
616#include <sys/param.h>
617#include <sys/socket.h>
618#include <sys/ucred.h>
619],[
620struct fcred sockcred;
621],sh_have_struct_fcred=yes,sh_have_struct_fcred=no)
622AC_MSG_RESULT($sh_have_struct_fcred)
623
624if test x$sh_have_struct_fcred = xyes; then
625 AC_DEFINE(HAVE_STRUCT_FCRED,1,[Have fcred structure])
626fi
627
628AC_MSG_CHECKING(for struct sockcred)
629AC_TRY_COMPILE([
630#include <sys/param.h>
631#include <sys/socket.h>
632#include <sys/ucred.h>
633],[
634struct sockcred sockcred;
635],sh_have_struct_sockcred=yes,sh_have_struct_sockcred=no)
636AC_MSG_RESULT($sh_have_struct_sockcred)
637
638if test x$sh_have_struct_sockcred = xyes; then
639 AC_DEFINE(HAVE_STRUCT_SOCKCRED,1,[Have sockcred structure])
640fi
641
642AC_MSG_CHECKING(for SO_PEERCRED)
643AC_TRY_COMPILE([
644#include <sys/types.h>
645#include <sys/socket.h>
646],[
647int test = SO_PEERCRED;
648],sh_have_SO_PEERCRED=yes,sh_have_SO_PEERCRED=no)
649AC_MSG_RESULT($sh_have_SO_PEERCRED)
650
651if test x$sh_have_SO_PEERCRED = xyes; then
652 AC_DEFINE(HAVE_SO_PEERCRED,1,[Have SO_PEERCRED define])
653fi
654
655
656dnl *****************************************
657dnl checks for compiler characteristics
658dnl *****************************************
659AC_C_INLINE
660AC_C_CONST
661AC_C_BIGENDIAN
662AC_C_RESTRICT
663
664AM_SA_SIGACTION_WORKS
665
666AC_ARG_ENABLE(ssp,
667 [ --disable-ssp disable the GCC stack protector],
668 [],
669 [enable_ssp=yes;]
670)
671
672if test "x$GCC" = "xyes"; then
673
674 if test x"${enable_ssp}" = xno; then
675 :
676 else
677 GCC_STACK_PROTECT_LIB
678 GCC_STACK_PROTECT_CC
679dnl GCC_STACK_CHECK_CC
680 GCC_PIE_CC
681 fi
682
683fi
684
685dnl *****************************************
686dnl
687dnl checks for system services
688dnl
689dnl *****************************************
690
691dnl
692dnl check for /proc filesystem
693dnl
694if test -d "/proc/$$"
695then
696 AC_DEFINE([HAVE_PROCFS],[1],[Define if you have a proc fs])
697fi
698
699dnl
700dnl check for GNU gmp
701dnl
702AC_CHECK_LIB(gmp, __gmpz_init, [sh_have_gmp=yes], [sh_have_gmp=no])
703if test "x${sh_have_gmp}" = xno
704then
705 AC_CHECK_LIB(gmp, mpz_init, [sh_have_gmp=yes], [sh_have_gmp=no])
706fi
707if test "x${sh_have_gmp}" = xyes
708then
709 # LIBS="-lgmp $LIBS"
710 AC_DEFINE(HAVE_LIBGMP, 1, [Have GNU gmp library])
711fi
712AC_CHECK_HEADERS(gmp.h)
713
714AC_MSG_CHECKING([for ps])
715PS=
716for ff in /usr/ucb /bin /usr/bin; do
717 if test -x "$ff/ps"; then
718 PS="$ff/ps"
719 AC_MSG_RESULT([$PS])
720 break
721 fi
722done
723if test x$PS = x
724then
725 AC_MSG_RESULT([no])
726 AC_MSG_ERROR([Cannot find ps in any of /usr/ucb /bin /usr/bin])
727fi
728AC_DEFINE_UNQUOTED([PSPATH], _("$PS"), [Path to ps])
729
730AC_MSG_CHECKING([how to use ps])
731$PS ax >/dev/null 2>&1
732if test $? -eq 0; then
733 case "$host_os" in
734 *openbsd*)
735 one=`$PS akx | wc -l`
736 ;;
737 *)
738 one=`$PS ax | wc -l`
739 ;;
740 esac
741else
742 one=0
743fi
744$PS -e >/dev/null 2>&1
745if test $? -eq 0; then
746 two=`$PS -e | wc -l`
747else
748 two=0
749fi
750if test $one -ge $two
751then
752 case "$host_os" in
753 *openbsd*)
754 PSARG="akx"
755 ;;
756 *)
757 PSARG="ax"
758 ;;
759 esac
760else
761 PSARG="-e"
762fi
763AC_DEFINE_UNQUOTED([PSARG], _("$PSARG"), [Argument for ps])
764AC_MSG_RESULT([$PS $PSARG])
765
766dnl *****************************************
767dnl
768dnl enable features
769dnl
770dnl *****************************************
771
772AC_ARG_ENABLE(db-reload,
773 [ --enable-db-reload enable database reload on SIGHUP [[no]]],
774 [
775 if test "x${enable_db_reload}" = xyes; then
776 AC_DEFINE(RELOAD_DATABASE)
777 fi
778 ]
779)
780
781AC_ARG_ENABLE(xml-log,
782 [ --enable-xml-log enable XML logfile format [[no]]],
783 [
784 if test "x${enable_xml_log}" = xyes; then
785 AC_DEFINE(SH_USE_XML)
786 fi
787 ]
788)
789
790
791AC_ARG_ENABLE(mail,
792 [ --disable-mail disable the internal SMTP mailer],
793 [
794 if test "x${enable_mail}" = xno; then
795 :
796 else
797 AC_DEFINE(SH_WITH_MAIL)
798 fi
799 ],
800 [AC_DEFINE(SH_WITH_MAIL)]
801)
802
803AC_ARG_ENABLE(suid,
804 [ --enable-suid allow suid],
805 [
806 if test "x${enable_suid}" = xyes; then
807 AC_DEFINE(SH_ALLOW_SUID, [1], [Define if you want to allow suid execution for samhain])
808 fi
809 ]
810)
811
812AC_ARG_ENABLE(shellexpand,
813 [ --disable-shellexpand disable shell expansion in config file],
814 [
815 if test "x${enable_shellexpand}" = xno; then
816 :
817 else
818 AC_DEFINE(SH_EVAL_SHELL, [1], [Define if you want shell expansion in configuration file])
819 fi
820 ],
821 [AC_DEFINE(SH_EVAL_SHELL, [1], [Define if you want shell expansion in configuration file])]
822)
823
824AC_ARG_ENABLE(external-scripts,
825 [ --disable-external-scripts disable interface to external scripts],
826 [
827 if test "x${enableval}" = xno; then
828 :
829 else
830 AC_DEFINE(WITH_EXTERNAL)
831 fi
832 ],
833 [AC_DEFINE(WITH_EXTERNAL)]
834)
835
836AC_ARG_ENABLE(message-queue,
837 [ --enable-message-queue[[=MODE]] enable SysV message queue [[MODE=0700]]],
838 [
839 if test "x${ac_cv_header_sys_msg_h}" = "xyes"; then
840 if test "x${enable_message_queue}" = xyes; then
841 AC_DEFINE(WITH_MESSAGE_QUEUE)
842 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, 0700)
843 elif test "x${enable_message_queue}" != xno; then
844 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
845 AC_MSG_ERROR([With --enable-message-queue=MODE, MODE must be numeric])
846 echo "${enableval}" | \
847 grep ['0[0123456789][0123456789][0123456789]'] >/dev/null 2>&1 ||
848 AC_MSG_ERROR([With --enable-message-queue=MODE, MODE must be an octal (0nnn) number])
849 AC_DEFINE(WITH_MESSAGE_QUEUE)
850 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, ${enable_message_queue})
851 fi
852 else
853 echo
854 echo "**********************************************"
855 echo
856 AC_MSG_WARN([sys/msg.h missing, --enable-message-queue disabled])
857 echo
858 echo "**********************************************"
859 echo
860 fi
861 ]
862)
863
864AC_ARG_WITH(cflags,
865 [ --with-cflags additional flags to pass to compiler],
866 [
867 if test "x$withval" != "xno" ; then
868 CFLAGS="$CFLAGS $withval"
869 fi
870 ]
871)
872AC_ARG_WITH(libs,
873 [ --with-libs additional libraries to link with],
874 [
875 if test "x$withval" != "xno" ; then
876 LIBS="$LIBS $withval"
877 fi
878 ]
879)
880
881
882#
883# this is from ssh
884#
885AC_MSG_CHECKING(whether to use libwrap)
886LIBWRAP_LIB=""
887LIBWRAP_INC=""
888AC_ARG_WITH(libwrap,
889[ --with-libwrap[=PATH] Compile in libwrap (TCP Wrappers) support],
890[ AC_MSG_RESULT($withval)
891 case "$withval" in
892 no)
893 ;;
894 ""|yes)
895 LIBWRAP_LIB="-lwrap"
896 ;;
897 *)
898 if test -d "$withval"; then
899 LIBWRAP_LIB="-L$withval -lwrap"
900 changequote(<<, >>)dnl
901 sh_libwrap_inc=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
902 LIBWRAP_INC="-I${sh_libwrap_inc}/include"
903 changequote([, ])dnl
904 else
905 LIBWRAP_LIB="-lwrap"
906 changequote(<<, >>)dnl
907 sh_libwrap_inc=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
908 LIBWRAP_INC="-I${sh_libwrap_inc}"
909 changequote([, ])dnl
910 fi
911 ;;
912 esac
913 if test -n "$LIBWRAP_LIB"; then
914 # OLDLIBS="$LIBS"
915 LIBS="$LIBWRAP_LIB $LIBS"
916 # OLDCFLAGS="$CFLAGS"
917 CFLAGS="$CFLAGS $LIBWRAP_INC"
918 AC_CHECK_HEADER(tcpd.h,
919 [],
920 [ AC_MSG_ERROR([Could not find tcpd.h for libwrap. You need to install tcp_wrappers.]) ])
921 AC_TRY_LINK([ #include <tcpd.h>
922 int allow_severity; int deny_severity; ],
923 [ hosts_access((struct request_info *) 0); ],
924 [ AC_DEFINE(SH_USE_LIBWRAP,1,[Build with tcp wrapper support]) ],
925 [ AC_MSG_ERROR([Could not find the libwrap library.]) ])
926 fi ],
927 AC_MSG_RESULT(no)
928)
929
930
931dnl
932dnl NETWORK OPTIONS
933dnl
934AC_ARG_ENABLE(network,
935 [ --enable-network=[[client|server]] compile client or server [[no]]],
936 [
937 if test "x$enable_network" = xclient; then
938 mytclient="-DSH_WITH_CLIENT"
939 yulectl_prg=
940 setpwd_prg="samhain_setpwd"
941 sh_main_prg="samhain"
942 if test "x${sh_have_gmp}" = xyes
943 then
944 LIBS="-lgmp $LIBS"
945 fi
946dnl AC_CHECK_HEADER(sys/capability.h,
947dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
948dnl [sh_use_lcaps="no"])
949 elif test "x$enable_network" = xserver; then
950 mytclient="-DSH_WITH_SERVER"
951 yulectl_prg="yulectl"
952 setpwd_prg="samhain_setpwd"
953 sh_main_prg="yule"
954 if test "x${sh_have_gmp}" = xyes
955 then
956 LIBS="-lgmp $LIBS"
957 fi
958 sh_use_lcaps="undef"
959 elif test "x$enable_network" = xno; then
960 mytclient="-DSH_STANDALONE"
961 yulectl_prg=
962 setpwd_prg=
963 sh_main_prg="samhain"
964dnl AC_CHECK_HEADER(sys/capability.h,
965dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
966dnl [sh_use_lcaps="no"])
967 else
968 AC_MSG_ERROR([With --enable-network=WHAT, WHAT must be client, server, or no])
969 fi
970 ],
971 [
972 mytclient="-DSH_STANDALONE"
973 setpwd_prg=
974 yulectl_prg=
975 sh_main_prg="samhain"
976dnl AC_CHECK_HEADER(sys/capability.h,
977dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
978dnl [sh_use_lcaps="no"])
979 ],
980)
981
982AC_SUBST(setpwd_prg)
983AC_SUBST(yulectl_prg)
984AC_SUBST(sh_main_prg)
985AC_SUBST(mytclient)
986
987# needed for the rpm spec
988clmytclient=`echo ${mytclient} | sed s%\-%%`
989AC_SUBST(clmytclient)
990
991sh_no_gcc_static=no
992
993AC_ARG_ENABLE(static,
994 [ --enable-static enable static linking [[no]]],
995 [
996 if test x$enable_static = xyes; then
997 if test x"$mynetbsd" = xyes
998 then
999 tmp_LIBS=`echo $LIBS | sed 's%\-lresolv%%' `
1000 LIBS="${tmp_LIBS}"
1001 fi
1002 if test x"${sh_auparse}" = xyes
1003 then
1004 tmp_LIBS=`echo $LIBS | sed 's%\-lauparse%%' `
1005 LIBS="${tmp_LIBS}"
1006 fi
1007 AC_DEFINE(SH_COMPILE_STATIC, 1, [Define if compiling static])
1008 if test "x$GCC" = "xyes"; then
1009 sh_no_gcc_static=no
1010 LDFLAGS="$LDFLAGS -static"
1011 else
1012 sh_no_gcc_static=yes
1013 case "$host_os" in
1014
1015 *aix*)
1016 LDFLAGS="$LDFLAGS -bnso -bI:/lib/syscalls.exp"
1017 ;;
1018
1019 *hpux*)
1020 LDFLAGS="$LDFLAGS -Wl,-a,archive"
1021 ;;
1022
1023 *osf*)
1024 LDFLAGS="$LDFLAGS -non_shared"
1025 ;;
1026
1027 *irix*)
1028 LDFLAGS="$LDFLAGS -non_shared"
1029 ;;
1030
1031 *sco*)
1032 LDFLAGS="$LDFLAGS -dn"
1033 ;;
1034
1035 *sun*)
1036 LDFLAGS="$LDFLAGS -Bstatic"
1037 ;;
1038
1039 *solaris*)
1040 LDFLAGS="$LDFLAGS -Bstatic"
1041 ;;
1042
1043 *)
1044 echo "***********************************************"
1045 echo "*"
1046 echo "* Don't know how to enable static linking"
1047 echo "* with your compiler. Please set the environment"
1048 echo "* variable LDFLAGS to:"
1049 echo "* ${LDFLAGS} + the static linking flag"
1050 echo "* and run configure again"
1051 echo "*"
1052 echo "***********************************************"
1053 ;;
1054
1055 esac
1056 fi
1057 fi
1058 ]
1059)
1060
1061if test x"${mytclient}" = x-DSH_STANDALONE -o x"${mytclient}" = x-DSH_WITH_CLIENT;
1062then
1063dnl For threaded modules
1064 ACX_PTHREAD
1065 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1066 LIBS="$PTHREAD_LIBS $LIBS"
1067 LDFLAGS="$PTHREAD_CFLAGS $LDFLAGS"
1068 CC="$PTHREAD_CC"
1069dnl For MODI_TXT
1070 CHECK_ZLIB()
1071fi
1072
1073if test x$enable_static = xyes; then
1074 :
1075else
1076 if test x$sh_use_pie = xyes; then
1077 LDFLAGS="$LDFLAGS $PIE_LDFLAGS"
1078 CFLAGS="$CFLAGS $PIE_CFLAGS"
1079 fi
1080fi
1081AC_CHECK_FUNC(pmap_getmaps,
1082 AC_DEFINE([HAVE_PMAP_GETMAPS], [], [Define if pmap_getmaps available]), [],[])
1083
1084
1085#
1086# this is from the snort configure.in
1087#
1088AC_DEFUN(FAIL_MESSAGE,[
1089 echo
1090 echo
1091 echo "**********************************************"
1092 echo " ERROR: unable to find" $1
1093 echo " checked in the following places"
1094 for i in `echo $2`; do
1095 echo " $i"
1096 done
1097 echo "**********************************************"
1098 echo
1099 exit
1100])
1101
1102AC_ARG_WITH(libprelude-prefix,
1103 [ --with-libprelude-prefix=PFX Prefix where libprelude is installed (optional)],
1104 libprelude_config_prefix="$withval", libprelude_config_prefix="")
1105
1106AC_MSG_CHECKING(whether to use prelude)
1107AC_ARG_WITH(prelude,
1108 [ --with-prelude Prelude IDS support [[no]]],
1109 [
1110 if test "x${withval}" = "xno"; then
1111 AC_MSG_RESULT(no)
1112 else
1113 AC_MSG_RESULT(yes)
1114 if test x$libprelude_config_prefix != x ; then
1115 if test x${LIBPRELUDE_CONFIG+set} != xset ; then
1116 LIBPRELUDE_CONFIG=$libprelude_config_prefix/bin/libprelude-config
1117 fi
1118 fi
1119
1120 AC_PATH_PROG(LIBPRELUDE_CONFIG, libprelude-config, no)
1121 if test x"$LIBPRELUDE_CONFIG" = "xno" ; then
1122 HAVE_PRELUDE_CONFIG=no
1123 else
1124 HAVE_PRELUDE_CONFIG=yes
1125 fi
1126dnl AC_CHECK_PROG(HAVE_PRELUDE_CONFIG, libprelude-config, yes, no)
1127 if test "$HAVE_PRELUDE_CONFIG" = "yes"; then
1128 sh_libprelude_version=`$LIBPRELUDE_CONFIG --version`
1129 case "$sh_libprelude_version" in
1130 0.8*)
1131 AC_MSG_ERROR([You have Libprelude 0.8, which is too old. Version 0.9.6 or higher is required.])
1132 ;;
1133 *)
1134 AM_PATH_LIBPRELUDE([0.9.6],
1135 [
1136 AC_DEFINE(HAVE_LIBPRELUDE,1,[Have libprelude])
1137 CFLAGS="$CFLAGS $LIBPRELUDE_PTHREAD_CFLAGS"
1138 LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS"
1139 LIBS="$LIBS $LIBPRELUDE_LIBS"
1140 ],
1141 [
1142 AC_MSG_ERROR([Could not find libprelude (if you are using --enable-static, the static library libprelude.a might be missing).])
1143 ])
1144 ;;
1145 esac
1146 else
1147 AC_MSG_ERROR([Could not find libprelude-config.])
1148 fi
1149 fi
1150 ],
1151 [
1152 AC_MSG_RESULT(no)
1153 ]
1154)
1155
1156#
1157# partly based on the snort configure.in
1158#
1159AC_ARG_WITH(database,
1160 [ --with-database=[[mysql|postgresql|oracle|odbc]] database support [[no]]],
1161 [
1162 if test x"$enable_xml_log" != xyes; then
1163 AC_MSG_ERROR([With --with-database, --enable-xml-log is required as well.])
1164 fi
1165 if test "x${withval}" = "xmysql"; then
1166 if test "x$zlib_found" = "x"
1167 then
1168 CHECK_ZLIB()
1169 fi
1170 AC_CHECK_PROG(HAVE_MYSQL_CONFIG, mysql_config, yes, no)
1171 if test "$HAVE_MYSQL_CONFIG" = "yes"; then
1172 sh_mysql_libs="`mysql_config --libs`"
1173 sh_mysql_libs="`eval echo ${sh_mysql_libs}`"
1174 LIBS="$LIBS ${sh_mysql_libs}"
1175 sh_mysql_cflags="`mysql_config --cflags`"
1176 sh_mysql_cflags="`eval echo ${sh_mysql_cflags}`"
1177 CPPFLAGS="$CPPFLAGS ${sh_mysql_cflags}"
1178 else
1179 AC_MSG_CHECKING([for MySQL in /usr /usr/local /usr/local/mysql MYSQL_HOME])
1180 mysql_directory="/usr /usr/local /usr/local/mysql ${MYSQL_HOME}"
1181
1182 for i in $mysql_directory; do
1183 if test -r $i/include/mysql/mysql.h; then
1184 MYSQL_DIR=$i
1185 MYSQL_INC_DIR=$i/include
1186 # we use AC_CHECK_HEADERS to check for mysql/mysql.h
1187 fi
1188 done
1189 if test -z "$MYSQL_DIR"; then
1190 for i in $mysql_directory; do
1191 if test -r $i/include/mysql.h; then
1192 MYSQL_DIR=$i
1193 MYSQL_INC_DIR=$i/include
1194 fi
1195 done
1196 fi
1197
1198 if test -z "$MYSQL_DIR"; then
1199 tmp=""
1200 for i in $mysql_directory; do
1201 tmp="$tmp $i/include $i/include/mysql"
1202 done
1203 FAIL_MESSAGE("mysql headers (mysql.h)", $tmp)
1204 fi
1205
1206 for i in lib lib/mysql; do
1207 str="$MYSQL_DIR/$i/libmysqlclient.*"
1208 for j in `echo $str`; do
1209 if test -r $j; then
1210 MYSQL_LIB_DIR="$MYSQL_DIR/$i"
1211 break 2
1212 fi
1213 done
1214 done
1215
1216 if test -z "$MYSQL_LIB_DIR"; then
1217 for ff in $mysql_directory; do
1218 for i in lib lib/mysql; do
1219 str="$ff/$i/libmysqlclient.*"
1220 for j in `echo $str`; do
1221 if test -r $j; then
1222 MYSQL_LIB_DIR="$ff/$i"
1223 break 3
1224 fi
1225 done
1226 done
1227 done
1228 fi
1229
1230 if test -z "$MYSQL_LIB_DIR"; then
1231 tmp=""
1232 for i in $mysql_directory; do
1233 tmp="$i/lib $i/lib/mysql"
1234 done
1235 FAIL_MESSAGE("mysql library libmysqlclient", $tmp)
1236 fi
1237
1238 AC_MSG_RESULT(yes)
1239 LIBS="$LIBS -L${MYSQL_LIB_DIR} -lmysqlclient"
1240 # CFLAGS="$CFLAGS -I${MYSQL_INC_DIR}"
1241 CPPFLAGS="$CPPFLAGS -I${MYSQL_INC_DIR}"
1242 fi
1243 AC_DEFINE(WITH_MYSQL)
1244 AC_DEFINE(WITH_DATABASE)
1245 if test "x$zlib_found" = "xyes"
1246 then
1247 LIBS="$LIBS -lz -lm"
1248 else
1249 echo
1250
1251 echo " Mysql library was not found or not useable."
1252 echo " Possible reasons include:"
1253 echo " - an old, incompatible version compiled from source"
1254 echo " - on Solaris, libmysql is compiled with the Solaris"
1255 echo " compiler, thus the mysql_config script provides"
1256 echo " compiler options unsuitable for gcc (move"
1257 echo " mysql_config out of your PATH)"
1258 echo " For other problems, check config.log for the error"
1259 echo " message from the compiler."
1260 echo
1261 echo " If your mysql libraries are installed in an"
1262 echo " unusual place, use --with-libs=-L/path/to/libdirectory"
1263 echo " where libdirectory is the directory holding libmysql."
1264 if test x"$enable_static" = xyes; then
1265 echo " Note that for compiling a static binary, you need"
1266 echo " the static libraries, rather than the shared ones."
1267 fi
1268 echo
1269 AC_MSG_ERROR([Could not find libmysql, or it is not useable.])
1270 fi
1271 AC_CHECK_HEADERS(mysql/mysql.h)
1272 elif test "x${withval}" = "xpostgresql"; then
1273 AC_DEFINE(WITH_POSTGRES)
1274 AC_DEFINE(WITH_DATABASE)
1275 #
1276 PGCONF="no"
1277 MY_PATH="${PATH}:/usr/local/bin:/usr/local/pgsql/bin"
1278 OLD_IFS="$IFS"
1279 IFS=":"
1280 for ff in ${MY_PATH}
1281 do
1282 if test -f "$ff/pg_config"
1283 then
1284 PGCONF="$ff/pg_config"
1285 fi
1286 done
1287 IFS="${OLD_IFS}"
1288 #
1289 #
1290 if test "x${PGCONF}" = "xno"
1291 then
1292 AC_MSG_CHECKING(for PostgreSQL in /usr/local/pgsql /usr/pgsql /usr/local /usr PGSQL_HOME)
1293 pgsql_directory="/usr/local/pgsql /usr/pgsql /usr/local /usr ${PGSQL_HOME}"
1294 for i in $pgsql_directory; do
1295 if test -r $i/include/pgsql/libpq-fe.h; then
1296 PGSQL_INC_DIR=$i/include
1297 PGSQL_DIR=$i
1298 # use AC_CHECK_HEADERS to check for pgsql/libpq-fe.h
1299 fi
1300 done
1301 if test -z "$PGSQL_DIR"; then
1302 for i in $pgsql_directory; do
1303 if test -r $i/include/postgresql/libpq-fe.h; then
1304 PGSQL_INC_DIR=$i/include
1305 PGSQL_DIR=$i
1306 fi
1307 done
1308 fi
1309 if test -z "$PGSQL_DIR"; then
1310 for i in $pgsql_directory; do
1311 if test -r $i/include/libpq-fe.h; then
1312 PGSQL_INC_DIR=$i/include
1313 PGSQL_DIR=$i
1314 fi
1315 done
1316 fi
1317
1318 if test -z "$PGSQL_DIR"; then
1319 tmp=""
1320 for i in $pgsql_directory; do
1321 tmp="$tmp $i/include $i/include/pgsql $i/include/postgresql"
1322 done
1323 FAIL_MESSAGE("PostgreSQL header file (libpq-fe.h)", $tmp)
1324 fi
1325
1326 for i in lib lib/pgsql lib/postgresql; do
1327 str="$PGSQL_DIR/$i/libpq.*"
1328 for j in `echo $str`; do
1329 if test -r $j; then
1330 PGSQL_LIB_DIR="$PGSQL_DIR/$i"
1331 break 2
1332 fi
1333 done
1334 done
1335
1336 if test -z "$PGSQL_LIB_DIR"; then
1337 for ff in $pgsql_directory; do
1338 for i in lib lib/pgsql lib/postgresql; do
1339 str="$ff/$i/libpq.*"
1340 for j in `echo $str`; do
1341 if test -r $j; then
1342 PGSQL_LIB_DIR="$ff/$i"
1343 break 3
1344 fi
1345 done
1346 done
1347 done
1348 fi
1349
1350 if test -z "$PGSQL_LIB_DIR"; then
1351 tmp=""
1352 for i in $pgsql_directory; do
1353 tmp="$i/lib $i/lib/pgsql $i/lib/postgresql"
1354 done
1355 FAIL_MESSAGE("postgresql library libpq", $tmp)
1356 fi
1357
1358 AC_MSG_RESULT(yes)
1359
1360 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lm"
1361 if test x"$enable_static" = xyes; then
1362 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lcrypt -lm"
1363 else
1364 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lm"
1365 fi
1366 # CFLAGS="$CFLAGS -I${PGSQL_INC_DIR}"
1367 CPPFLAGS="$CPPFLAGS -I${PGSQL_INC_DIR}"
1368 AC_CHECK_HEADERS(pgsql/libpq-fe.h)
1369 AC_CHECK_HEADERS(postgresql/libpq-fe.h)
1370 else
1371 pg_lib_dir=`${PGCONF} --libdir`
1372 if test x"$enable_static" = xyes; then
1373 LIBS="$LIBS -L${pg_lib_dir} -lpq -lcrypt -lm"
1374 else
1375 LIBS="$LIBS -L${pg_lib_dir} -lpq -lm"
1376 fi
1377 pg_inc_dir=`${PGCONF} --includedir`
1378 # CFLAGS="$CFLAGS -I${pg_inc_dir}"
1379 CPPFLAGS="$CPPFLAGS -I${pg_inc_dir}"
1380 fi
1381 elif test "x${withval}" = "xodbc"; then
1382 AC_MSG_CHECKING(for odbc in /usr /usr/local ODBC_HOME)
1383 odbc_directory="/usr /usr/local"
1384
1385 for i in $odbc_directory; do
1386 if test -r $i/include/sql.h; then
1387 if test -r $i/include/sqlext.h; then
1388 if test -r $i/include/sqltypes.h; then
1389 ODBC_DIR=$i
1390 ODBC_INC_DIR=$i/include
1391 fi
1392 fi
1393 fi
1394 done
1395
1396 if test -z "$ODBC_DIR"; then
1397 tmp=""
1398 for i in $odbc_directory; do
1399 tmp="$tmp $i/include"
1400 done
1401 FAIL_MESSAGE("odbc headers (sql.h sqlext.h sqltypes.h)", $tmp)
1402 fi
1403
1404 str="$ODBC_DIR/lib/libodbc.*"
1405 for j in `echo $str`; do
1406 if test -r $j; then
1407 ODBC_LIB_DIR="$ODBC_DIR/lib"
1408 ODBC_LIB="odbc"
1409 fi
1410 done
1411
1412 if test -z "$ODBC_LIB_DIR"; then
1413 FAIL_MESSAGE("odbc library (libodbc)", "$ODBC_DIR/lib")
1414 fi
1415
1416 AC_MSG_RESULT(yes)
1417 CPPFLAGS="${CPPFLAGS} -I${ODBC_INC_DIR}"
1418 LIBS="${LIBS} -L${ODBC_LIB_DIR} -l$ODBC_LIB"
1419 AC_DEFINE(WITH_ODBC)
1420 AC_DEFINE(WITH_DATABASE)
1421
1422 elif test "x${withval}" = "xoracle"; then
1423
1424 AC_MSG_CHECKING(for oracle in ORACLE_HOME /usr/local /usr)
1425
1426 oracle_directory="/usr /usr/local ${ORACLE_HOME}"
1427 for i in $oracle_directory; do
1428
1429 ff=`find $i -name oci.h 2>/dev/null | tail -1`
1430 if test "x$ff" = "x"; then
1431 :
1432 else
1433 ORACLE_INC=`dirname $ff`
1434 fi
1435
1436 fg=`find $i -name libclntsh.so 2>/dev/null | tail -1`
1437 if test "x$fg" = "x"; then
1438 :
1439 else
1440 ORACLE_LIB=`dirname $fg`
1441 fi
1442
1443 done
1444
1445 if test -z "$ORACLE_INC"; then
1446
1447 tmp=""
1448 for i in $oracle_directory; do
1449 tmp="$tmp $i"
1450 done
1451 FAIL_MESSAGE("OCI header file (oci.h) please define ORACLE_INC directory where oci.h resides", $tmp)
1452
1453 elif test -z "$ORACLE_LIB"; then
1454
1455 tmp=""
1456 for i in $oracle_directory; do
1457 tmp="$tmp $i"
1458 done
1459 FAIL_MESSAGE("OCI library file (libclntsh.so) please define ORACLE_LIB directory where libclntsh.so resides", $tmp)
1460
1461 else
1462
1463 ORACLE_CPP_FLAGS="-I$ORACLE_INC"
1464 ORACLE_LIB_DIR="$ORACLE_LIB"
1465
1466 AC_MSG_RESULT([$ORACLE_INC $ORACLE_LIB])
1467
1468 CPPFLAGS="${CPPFLAGS} ${ORACLE_CPP_FLAGS}"
1469
1470 ORACLE_LIBS="-lclntsh"
1471
1472 if test -r $ORACLE_LIB_DIR/libnnz11.so; then
1473 ORACLE_LIBS="${ORACLE_LIBS} -lnnz11"
1474 fi
1475 if test -r $ORACLE_LIB_DIR/libwtc9.so; then
1476 ORACLE_LIBS="${ORACLE_LIBS} -lwtc9"
1477 elif test -r $ORACLE_LIB_DIR/libwtc8.so; then
1478 ORACLE_LIBS="${ORACLE_LIBS} -lwtc8"
1479 fi
1480 LIBS="${LIBS} -L${ORACLE_LIB_DIR} ${ORACLE_LIBS}"
1481 if test "x$GCC" != "xyes"; then
1482 CFLAGS="${CFLAGS} -fno-strict-aliasing"
1483 fi
1484 fi
1485 AC_DEFINE(WITH_ORACLE)
1486 AC_DEFINE(WITH_DATABASE)
1487
1488 else
1489 AC_MSG_ERROR([Option --with-database=database used with unsupported database ${withval}])
1490 fi
1491 ]
1492)
1493
1494AC_ARG_WITH(console,
1495 [ --with-console=PATH set path to console device [[/dev/console]]],
1496 [
1497 if test "x${withval}" != xno; then
1498 mycons="$withval"
1499 AC_DEFINE_UNQUOTED(DEFAULT_CONSOLE, _("${mycons}") )
1500 fi
1501 ])
1502
1503AC_ARG_WITH(altconsole,
1504 [ --with-altconsole=PATH set path to second console device [[none]]],
1505 [
1506 if test "x${withval}" != xno; then
1507 myaltcons="$withval"
1508 else
1509 myaltcons="NULL"
1510 fi
1511 ],
1512 [myaltcons="NULL"])
1513AC_DEFINE_UNQUOTED(ALT_CONSOLE, _("${myaltcons}") )
1514
1515AC_ARG_WITH(timeserver,
1516 [ --with-timeserver=HOST set host address for time server [[none]]],
1517 [
1518 if test "x${withval}" != xno; then
1519 mytimeserv="$withval"
1520 AC_DEFINE(HAVE_NTIME)
1521 else
1522 mytimeserv="NULL"
1523 fi
1524 ],
1525 mytimeserv="NULL")
1526AC_DEFINE_UNQUOTED(DEFAULT_TIMESERVER, _("${mytimeserv}") )
1527
1528AC_ARG_WITH(alttimeserver,
1529 [ --with-alttimeserver=HOST set address for backup time server [[none]]],
1530 [
1531 if test "x${withval}" != xno; then
1532 myalttimeserv="$withval"
1533 AC_DEFINE(HAVE_NTIME)
1534 else
1535 myalttimeserv="NULL"
1536 fi
1537 ],
1538 myalttimeserv="NULL")
1539AC_DEFINE_UNQUOTED(ALT_TIMESERVER, _("${myalttimeserv}") )
1540
1541AC_ARG_ENABLE(login-watch,
1542 [ --enable-login-watch watch for login/logout [[no]]],
1543 [
1544 if test "x${enable_login_watch}" = xyes; then
1545 AC_DEFINE(SH_USE_UTMP)
1546 fi
1547 ]
1548)
1549
1550AC_ARG_ENABLE(mounts-check,
1551 [ --enable-mounts-check check mount options on filesystems [[no]]],
1552 [
1553 if test "x${enable_mounts_check}" = xyes; then
1554 AC_DEFINE(SH_USE_MOUNTS)
1555 fi
1556 ]
1557)
1558
1559AC_ARG_ENABLE(logfile-monitor,
1560 [ --enable-logfile-monitor monitor logfiles [[no]]],
1561 [
1562 if test "x${enable_logfile_monitor}" = xyes; then
1563 AC_CHECK_HEADER(pcre.h,
1564 [
1565 AC_DEFINE(USE_LOGFILE_MONITOR, 1, [Define if you want the logfile monitor module.])
1566 LIBS="-lpcre $LIBS"
1567 ],
1568 [
1569 AC_CHECK_HEADER(pcre/pcre.h,
1570 [
1571 AC_DEFINE(USE_LOGFILE_MONITOR, 1, [Define if you want the logfile monitor module.])
1572 AC_DEFINE(HAVE_PCRE_PCRE_H, 1, [Define if you have pcre/pcre.h.])
1573 LIBS="-lpcre $LIBS"
1574 ],
1575 AC_MSG_ERROR([The --enable-logfile-monitor option requires libpcre. For compiling the pcre development package is needed.])
1576 )
1577 ]
1578 )
1579 AC_CHECK_LIB(pcre, pcre_dfa_exec, [
1580 AC_DEFINE([HAVE_PCRE_DFA_EXEC], 1, [Define if you have pcre_dfa_exec])
1581 ], [
1582 AC_MSG_WARN([pcre_dfa_exec not available])
1583 ])
1584 fi
1585 ]
1586)
1587
1588
1589AC_ARG_ENABLE(process-check,
1590 [ --enable-process-check check processes [[no]]],
1591 [
1592 if test "x${enable_process_check}" = xyes; then
1593 AC_CHECK_LIB([rt], [sched_getparam], sh_lrt=yes, sh_lrt=no)
1594 if test x"$sh_lrt" = xyes; then
1595 LIBRT=-lrt
1596 else
1597 LIBRT=
1598 fi
1599 LIBS="$LIBS $LIBRT"
1600 AC_DEFINE(SH_USE_PROCESSCHECK, [1], [Define if you want to check processes])
1601 fi
1602 ]
1603)
1604
1605AC_ARG_ENABLE(port-check,
1606 [ --enable-port-check check ports [[no]]],
1607 [
1608 if test "x${enable_port_check}" = xyes; then
1609 AC_DEFINE(SH_USE_PORTCHECK, [1], [Define if you want to check ports])
1610 fi
1611 ]
1612)
1613
1614AC_ARG_ENABLE(userfiles,
1615 [ --enable-userfiles check for users' config files [[no]]],
1616 [
1617 if test "x${enableval}" = "xyes"; then
1618 AC_DEFINE(SH_USE_USERFILES)
1619 fi
1620 ]
1621)
1622
1623AC_ARG_ENABLE(debug,
1624 [ --enable-debug enable debug options [[no]]],
1625 [
1626 if test "x${enable_debug}" = "xyes"; then
1627 if test "x${mydebugflag}" != "xyes"; then
1628 AC_DEFINE(MEM_DEBUG)
1629 fi
1630 AC_DEFINE(WITH_TPT)
1631 AC_DEFINE(SL_DEBUG)
1632 AC_DEFINE(DNMALLOC_CHECKS, 1, [Debug dnmalloc])
1633 AC_DEFINE(PARANOIA, 0, [Paranoia level for dnmalloc])
1634 AC_DEFINE(SL_FAIL_ON_ERROR)
1635 if test "x${myneedg3}" = "xyes"; then
1636 mydebugdef="-g3"
1637 else
1638 mydebugdef="-g"
1639 fi
1640 mydebugit="yes"
1641 elif test "x${enable_debug}" = "xgdb"; then
1642 if test "x${myneedg3}" = "xyes"; then
1643 mydebugdef="-g3"
1644 else
1645 mydebugdef="-g"
1646 fi
1647 mydebugit="yes"
1648 fi
1649 ]
1650)
1651AC_SUBST(mydebugdef)
1652
1653
1654AC_ARG_ENABLE(ipv6,
1655 [ --disable-ipv6 disable ipv6 support],
1656 [
1657 if test "x${enable_ipv6}" = xno; then
1658 AC_DEFINE(USE_IPV4,1,[Define if you do not want IPv6])
1659 fi
1660 ]
1661)
1662
1663if test "x${dnmalloc_ok}" = "xyes"; then
1664 sh_dnmalloc_enabled=yes
1665else
1666 sh_dnmalloc_enabled=no
1667fi
1668
1669AC_ARG_ENABLE(dnmalloc,
1670 [ --disable-dnmalloc disable dnmalloc],
1671 [
1672 if test "x${enable_dnmalloc}" = xno; then
1673 sh_dnmalloc_enabled=no
1674 else
1675 sh_dnmalloc_enabled=yes
1676 fi
1677 ]
1678)
1679
1680dnl Handle the problem that static linking against libc.a on Linux
1681dnl produces the error "multiple definitions of malloc"
1682dnl
1683if test "x$sh_dnmalloc_enabled" = "xyes"; then
1684 if test x$enable_static = xyes; then
1685 if test "x$sh_no_gcc_static" = "xyes"; then
1686 sh_dnmalloc_enabled=no
1687 else
1688 if test "x$with_gnu_ld" = "xyes"; then
1689 LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
1690 else
1691 sh_dnmalloc_enabled=no
1692 fi
1693 fi
1694 fi
1695fi
1696
1697if test "x${sh_dnmalloc_enabled}" = xno; then
1698 AC_DEFINE(USE_SYSTEM_MALLOC,1,[Define if you want to use the system malloc])
1699fi
1700
1701AC_ARG_ENABLE(ptrace,
1702 [ --enable-ptrace use anti-debugger options [[no]]],
1703 [
1704 if test "x${enable_ptrace}" = xyes; then
1705 if test "x$mydebugit" != "xyes"; then
1706 AC_DEFINE(SCREW_IT_UP)
1707 fi
1708 fi
1709 ]
1710)
1711
1712dnl
1713if test "x$GCC" = "xyes"; then
1714 if test ! -z "`echo "$CFLAGS" | grep "\-g\ " 2> /dev/null`" ; then
1715 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
1716 fi
1717
1718dnl if test ! -z "`echo "$CFLAGS" | grep "\-O2" 2> /dev/null`" ; then
1719dnl CFLAGS=`echo $CFLAGS | sed 's%\-O2%\-O3%' `
1720dnl fi
1721
1722 if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
1723 CFLAGS="$CFLAGS -Wall -W "
1724 fi
1725
1726 if test -z "`echo "$CFLAGS" | grep "\-fstrength\-reduce" 2> /dev/null`"
1727 then
1728 if test -z "`echo "$CFLAGS" | grep "\-fno\-strength\-reduce" 2> /dev/null`"
1729 then
1730 CFLAGS="$CFLAGS -fno-strength-reduce"
1731 fi
1732 fi
1733
1734 if test -z "`echo "$CFLAGS" | grep "\-fomit\-frame\-pointer" 2> /dev/null`"
1735 then
1736 if test -z "`echo "$CFLAGS" | grep "\-fno\-omit\-frame\-pointer" 2> /dev/null`"
1737 then
1738 CFLAGS="$CFLAGS -fno-omit-frame-pointer"
1739 fi
1740 fi
1741
1742fi
1743
1744dnl Test whether gcc supports -Wno-empty-body
1745dnl Suppresses warnings from glibc pthread_cleanup_pop
1746dnl
1747GCC_WEMPTY_BODY
1748
1749AC_MSG_CHECKING([which random module to use])
1750AC_ARG_WITH(rnd,
1751 [ --with-rnd=[[egd|unix|dev|default]] random number generator [[default]]],
1752[use_static_rnd=$withval], [use_static_rnd=default] )
1753
1754if test "$use_static_rnd" = no; then
1755 use_static_rnd=default
1756fi
1757
1758case "$use_static_rnd" in
1759 egd | dev | unix | default )
1760 AC_MSG_RESULT($use_static_rnd)
1761 ;;
1762 * )
1763 AC_MSG_RESULT([invalid argument])
1764 AC_MSG_ERROR([Option --with-rnd=module used with unsupported module ${use_static_rnd}])
1765 ;;
1766esac
1767
1768AC_ARG_WITH(egd-socket,
1769 [ --with-egd-socket=NAME EGD socket name],
1770 egd_socket_name="$withval", egd_socket_name="" )
1771AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, _("$egd_socket_name") )
1772
1773dnl
1774dnl See whether the user wants to disable checking for /dev/random
1775
1776try_dev_random=yes
1777
1778case "$use_static_rnd" in
1779dev | default )
1780 try_dev_random=yes
1781 ;;
1782egd)
1783 AC_DEFINE(HAVE_EGD_RANDOM)
1784 try_dev_random=no
1785 ;;
1786unix)
1787 AC_DEFINE(HAVE_UNIX_RANDOM)
1788 try_dev_random=no
1789 ;;
1790esac
1791
1792
1793if test "x$try_dev_random" = "xyes"; then
1794 AC_MSG_CHECKING(whether /dev/random exists)
1795 if test -r "/dev/srandom" && test -c "/dev/srandom"; then
1796 AC_DEFINE(HAVE_URANDOM)
1797 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, _("/dev/srandom") )
1798 AC_MSG_RESULT(yes)
1799 if test -r "/dev/urandom" && test -c "/dev/urandom"; then
1800 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, _("/dev/urandom") )
1801 fi
1802 else
1803 if test -r "/dev/random" && test -c "/dev/random"; then
1804 AC_DEFINE(HAVE_URANDOM)
1805 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, _("/dev/random") )
1806 AC_MSG_RESULT(yes)
1807 if test -r "/dev/urandom" && test -c "/dev/urandom"; then
1808 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, _("/dev/urandom") )
1809 fi
1810 else
1811 AC_MSG_RESULT(no)
1812 AC_DEFINE(HAVE_UNIX_RANDOM)
1813 fi
1814 fi
1815fi
1816
1817
1818AC_ARG_ENABLE(udp,
1819 [ --enable-udp server can listen on port 514/udp [[no]]],
1820 [
1821 if test "x${enable_udp}" = xyes; then
1822 AC_DEFINE(INET_SYSLOG)
1823 fi
1824 ]
1825)
1826
1827myencrypt=yes
1828AC_ARG_ENABLE(encrypt,
1829 [ --disable-encrypt disable client/server encryption],
1830 [
1831 if test "x${enable_encrypt}" = xno; then
1832 myencrypt=no
1833 elif test "x${enable_encrypt}" = "x1"; then
1834 myencrypt=1
1835 fi
1836 ]
1837)
1838if test "x${myencrypt}" = "xyes"; then
1839 AC_DEFINE(SH_ENCRYPT)
1840 AC_DEFINE(SH_ENCRYPT_2)
1841elif test "x${myencrypt}" = "x1"; then
1842 AC_DEFINE(SH_ENCRYPT)
1843fi
1844
1845sh_use_srp_proto=yes
1846AC_ARG_ENABLE(srp,
1847 [ --disable-srp disable SRP for authentication],
1848 [
1849 if test "x${enable_srp}" = xno; then
1850 sh_use_srp_proto=no
1851 fi
1852 ]
1853)
1854if test "x${sh_use_srp_proto}" = xyes; then
1855 AC_DEFINE(USE_SRP_PROTOCOL)
1856fi
1857
1858AC_ARG_WITH(port,
1859 [ --with-port=PORT set port to use for TCP/IP connection [[49777]]],
1860 [
1861 echo "${withval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1862 AC_MSG_ERROR([For --with-port=PORT, PORT must be numeric.])
1863 myport=${withval}
1864 ],
1865 [myport="49777"])
1866AC_DEFINE_UNQUOTED(SH_DEFAULT_PORT, ${myport})
1867AC_SUBST(myport)
1868
1869AC_ARG_WITH(logserver,
1870 [ --with-logserver=HOST set host address for log server [[none]]],
1871 [
1872 case "$withval" in
1873 *.* | localhost)
1874 mylogsrv="$withval"
1875 ;;
1876 *)
1877 mylogsrv="$withval"
1878 ;;
1879 esac
1880 ],
1881 [mylogsrv="NULL"])
1882AC_DEFINE_UNQUOTED(DEFAULT_LOGSERVER, _("${mylogsrv}") )
1883AC_SUBST(mylogsrv)
1884
1885AC_ARG_WITH(altlogserver,
1886 [ --with-altlogserver=HOST set address for backup log server [[none]]],
1887 [
1888 case "$withval" in
1889 *.* | localhost)
1890 myaltlogsrv="$withval"
1891 ;;
1892 *)
1893 myaltlogsrv="$withval"
1894 ;;
1895 esac
1896 ],
1897 [myaltlogsrv="NULL"])
1898AC_DEFINE_UNQUOTED(ALT_LOGSERVER, _("${myaltlogsrv}"))
1899
1900
1901
1902dnl
1903dnl STEALTH OPTIONS
1904dnl
1905nocl_code=
1906xor_code=0
1907AC_ARG_ENABLE(nocl,
1908 [ --enable-nocl=PW no CL parsing unless first CL argument is PW],
1909 [
1910 if test "x${enableval}" != "x"; then
1911 AC_DEFINE(SH_STEALTH_NOCL)
1912 fi
1913 if test "x${enableval}" = "xstop" || test "x${enableval}" = "xstart"; then
1914 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1915 fi
1916 if test "x${enableval}" = "xreload" || test "x${enableval}" = "xrestart"; then
1917 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1918 fi
1919 if test "x${enableval}" = "xstatus"; then
1920 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1921 fi
1922 if test "x${enableval}" = "xno"; then
1923 AC_MSG_ERROR([With --enable-nocl=PW, the use of --enable-nocl=no is ambiguous.])
1924 fi
1925 nocl_code="${enable_nocl}"
1926 ]
1927)
1928AC_DEFINE_UNQUOTED(NOCL_CODE, _("${nocl_code}") )
1929AC_SUBST(nocl_code)
1930AC_ARG_ENABLE(stealth,
1931 [ --enable-stealth=XOR_VAL enable stealth mode [[no]]],
1932 [AC_DEFINE(SH_STEALTH)
1933 if test "x${enableval}" != "xyes"; then
1934 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1935 AC_MSG_ERROR([For --enable-stealth=XOR_VAL, XOR_VAL must be numeric.])
1936 if test "${enableval}" -lt 127 || test "${enableval}" -gt 255; then
1937 if test x"${enableval}" = x0
1938 then
1939 :
1940 else
1941 AC_MSG_ERROR([For --enable-stealth=XOR_VAL, XOR_VAL must be in the range 127 to 255.])
1942 fi
1943 fi
1944 xor_code="${enable_stealth}"
1945 else
1946 xor_code=0
1947 fi
1948 stegin_prg="samhain_stealth"
1949 ],
1950 [
1951 stegin_prg=
1952 ]
1953)
1954AC_ARG_ENABLE(micro-stealth,
1955 [ --enable-micro-stealth=XOR_VAL enable micro stealth mode [[no]]],
1956 [
1957 AC_DEFINE(SH_STEALTH)
1958 AC_DEFINE(SH_STEALTH_MICRO)
1959 if test "x${enableval}" != "xyes"; then
1960 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1961 AC_MSG_ERROR([For --enable-micro-stealth=XOR_VAL, XOR_VAL must be numeric.])
1962 if test "${enableval}" -lt 127 || test "${enableval}" -gt 255; then
1963 if test x"${enableval}" = x0
1964 then
1965 :
1966 else
1967 AC_MSG_ERROR([For --enable-micro-stealth=XOR_VAL, XOR_VAL must be in the range 127 to 255.])
1968 fi
1969 fi
1970 xor_code="${enable_micro_stealth}"
1971 else
1972 xor_code=0
1973 fi
1974 ]
1975)
1976install_name="samhain"
1977INSTALL_NAME="SAMHAIN"
1978AC_ARG_ENABLE(install-name,
1979 [ --enable-install-name=NAME name under which to install [[samhain|yule]]],
1980 [
1981 if test "x${enableval}" != "xyes"; then
1982 install_name="${enableval}"
1983 INSTALL_NAME=`echo "${enableval}" | tr [a-z] [A-Z]`
1984 else
1985 install_name="${sh_main_prg}"
1986 INSTALL_NAME=`echo "${sh_main_prg}" | tr [a-z] [A-Z]`
1987 fi
1988 ],
1989 [
1990 install_name="${sh_main_prg}"
1991 INSTALL_NAME=`echo "${sh_main_prg}" | tr [a-z] [A-Z]`
1992 ]
1993)
1994
1995
1996need_user_install=0
1997
1998AC_ARG_ENABLE(identity,
1999 [ --enable-identity=USER user if dropping root [[daemon]]],
2000 [
2001 if test x"$enableval" = xno; then
2002 myident="daemon"
2003 else
2004 myident="$enableval"
2005 fi
2006 echo "${myident}" | grep ['[^0123456789]'] >/dev/null 2>&1 || \
2007 AC_MSG_ERROR([With --enable-identity=USER, please supply a username, not a UID.])
2008 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
2009 grep "^${myident}:" | awk -F: '{ print $3; }'`
2010 if test x"${myident_uid}" = x; then
2011 AC_MSG_WARN([Option --enable-identity used, user ${myident} will be added upon install.])
2012 need_user_install=1
2013 fi
2014 ],
2015 [
2016 for myident in ${install_name} daemon nobody; do
2017 AC_MSG_CHECKING(for user ${myident})
2018 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
2019 grep "^${myident}:" | awk -F: '{ print $3; }'`
2020 if test x"${myident_uid}" != x; then
2021 AC_MSG_RESULT(yes)
2022 break;
2023 else
2024 AC_MSG_RESULT(no)
2025 fi
2026 done
2027 if test x"${myident_uid}" = x; then
2028 myident=${install_name}
2029 AC_MSG_WARN([--enable-identity: user ${myident} will be added upon install])
2030 need_user_install=1
2031 fi
2032 ])
2033AC_DEFINE_UNQUOTED(DEFAULT_IDENT, _("${myident}") )
2034AC_SUBST(myident)
2035AC_SUBST(need_user_install)
2036
2037sh_insmod_cmd=": # no kernel module"
2038sh_insmod_pre=": # no kernel module"
2039sh_lkm=""
2040lkm_inc=""
2041khidemap="/boot/System.map"
2042sh_syscalltable="0x0"
2043AC_ARG_ENABLE(khide,
2044 [ --enable-khide=SYSTEM_MAP use kernel module to hide (Linux only)[[/boot/System.map]]],
2045 [
2046 if test "x${enable_khide}" != xno; then
2047 if test "x${enableval}" != "xyes"; then
2048 khidemap="${enableval}"
2049 fi
2050 sh_syscalltable=`egrep '(D|d|R|r) sys_call_table' ${khidemap} | awk '{print $1}'`
2051 if test x"$sh_syscalltable" = x; then
2052 AC_MSG_ERROR([Option --enable-khide cannot be used since the symbol sys_call_table was not found in ${khidemap}.])
2053 fi
2054 sh_syscalltable="0x${sh_syscalltable}"
2055 install_name_len=`echo ${install_name} | awk '{ print(length()); }'`
2056 if test "${install_name_len}" -gt 15 ; then
2057 AC_MSG_ERROR([If --enable-khide is used, install_name must not exceed a length of 15 chars.])
2058 fi
2059 AC_DEFINE(SH_USE_LKM)
2060 AC_DEFINE_UNQUOTED(SH_MAGIC_HIDE, "${install_name}")
2061
2062 # -- NEW --
2063 kernel_version=`uname -r | sed s,2.6.*,LINUX26,`
2064 kernel_numeric=`uname -r | sed 's%-%.%g' | sed 's%_%.%g' | awk -F. '{ print $1*65536+$2*256+$3 }'`
2065 AC_DEFINE_UNQUOTED(SH_KERNEL_NUMERIC, ${kernel_numeric}, [Kernel number])
2066
2067 if test x"$kernel_version" = xLINUX26
2068 then
2069 AC_MSG_CHECKING([for modlist_lock])
2070 sh_modlist_lock=`egrep ['[bd] modlist_lock$'] ${khidemap} | awk '{print $1}'`
2071 if test x"$sh_modlist_lock" = x; then
2072 AC_MSG_RESULT(no)
2073 else
2074 sh_modlist_lock="0x${sh_modlist_lock}"
2075 AC_MSG_RESULT([${sh_modlist_lock}])
2076 AC_DEFINE_UNQUOTED(SH_MODLIST_LOCK, ${sh_modlist_lock}, [The address of the modules list spinlock])
2077 fi
2078
2079 AC_MSG_CHECKING([for module_mutex])
2080 sh_modlist_mutex=`egrep ['[bd] module_mutex$'] ${khidemap} | awk '{print $1}'`
2081 if test x"$sh_modlist_mutex" = x; then
2082 AC_MSG_RESULT(no)
2083 else
2084 sh_modlist_mutex="0x${sh_modlist_mutex}"
2085 AC_MSG_RESULT([${sh_modlist_mutex}])
2086 AC_DEFINE_UNQUOTED(SH_MODLIST_MUTEX, ${sh_modlist_mutex}, [The address of the modules list mutex])
2087 fi
2088
2089 sh_list_modules=`egrep 'd modules$' ${khidemap} | awk '{print $1}'`
2090 if test x"$sh_list_modules" = x; then
2091 AC_MSG_ERROR([Option --enable-khide cannot be used, since the symbol modules was not found in ${khidemap}.])
2092 fi
2093 sh_list_modules="0x${sh_list_modules}"
2094 AC_DEFINE_UNQUOTED(SH_LIST_MODULES, ${sh_list_modules}, [The address of the modules list])
2095
2096 AC_DEFINE(LINUX26, 1, [Define if kernel is 2.6])
2097 sh_insmod_cmd="modprobe ${install_name}_hide"
2098 sh_lkm="samhain_hide.ko"
2099 else
2100 sh_insmod_cmd="insmod ${install_name}_hide; insmod ${install_name}_erase; rmmod ${install_name}_erase"
2101 sh_lkm="samhain_hide.o samhain_erase.o"
2102 fi
2103 # -- END NEW --
2104
2105 kvers=`uname -r`
2106 if test -f /lib/modules/${kvers}/build/include/linux/kernel.h; then
2107 lkm_inc="-I/lib/modules/${kvers}/build/include"
2108 else
2109 AC_MSG_WARN([--enable-khide: /lib/modules/${kvers}/build/include/linux not found])
2110 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])
2111 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])
2112 fi
2113
2114 AC_MSG_CHECKING([for 2.4 vanilla kernel])
2115 sh_is_vanilla_kernel=yes
2116 if test -f /lib/modules/${kvers}/build/include/linux/sched.h; then
2117 grep 'next_task,' /lib/modules/${kvers}/build/include/linux/sched.h >/dev/null 2>&1 || sh_is_vanilla_kernel=no
2118 fi
2119 if test x"${sh_is_vanilla_kernel}" = xno; then
2120 AC_MSG_RESULT(no)
2121 else
2122 AC_MSG_RESULT(yes)
2123 AC_DEFINE(SH_VANILLA_KERNEL)
2124 fi
2125
2126 fi
2127 ]
2128)
2129
2130AC_SUBST(install_name)
2131AC_SUBST(INSTALL_NAME)
2132AC_SUBST(stegin_prg)
2133AC_SUBST(xor_code)
2134
2135AC_DEFINE_UNQUOTED(XOR_CODE, ${xor_code})
2136AC_DEFINE_UNQUOTED(SH_SYSCALLTABLE, ${sh_syscalltable})
2137
2138
2139exepack_state0=`${srcdir}/c_random.sh 2>/dev/null`
2140exepack_state1=`${srcdir}/c_random.sh 2>/dev/null`
2141exepack_state2=`${srcdir}/c_random.sh 2>/dev/null`
2142
2143AC_DEFINE_UNQUOTED(EXEPACK_STATE_0, ${exepack_state0})
2144AC_DEFINE_UNQUOTED(EXEPACK_STATE_1, ${exepack_state1})
2145AC_DEFINE_UNQUOTED(EXEPACK_STATE_2, ${exepack_state2})
2146
2147
2148AC_ARG_ENABLE(suidcheck,
2149 [ --enable-suidcheck check for suid/sgid files [[no]]],
2150 [
2151 if test "x${enableval}" = "xyes"; then
2152 AC_DEFINE(SH_USE_SUIDCHK)
2153 fi
2154 ]
2155)
2156
2157
2158systemmap="/boot/System.map"
2159sh_libkvm=""
2160AC_ARG_WITH(kcheck,
2161 [ --with-kcheck[[=SYSTEM_MAP]] check Linux/FreeBSD/OpenBSD kernel integrity [[/boot/System.map]]],
2162 [
2163 if test "x${withval}" != "xno"; then
2164 AC_DEFINE(SH_USE_KERN)
2165
2166 kernel_numeric=`uname -r | sed 's%-%.%g' | sed 's%_%.%g' | awk -F. '{ print $1*65536+$2*256+$3 }'`
2167 AC_DEFINE_UNQUOTED(SH_KERNEL_NUMBER, ${kernel_numeric}, [Kernel number])
2168
2169 kernelversion=`uname -r`
2170 AC_DEFINE_UNQUOTED(SH_KERNEL_VERSION, _("${kernelversion}"), [Define the kernel version])
2171
2172 if test "x${withval}" != "xyes"; then
2173 systemmap="${withval}"
2174 fi
2175
2176 if test "x${cross_compiling}" = xyes; then
2177 :
2178 elif test "x$selectconfig" = "xfreebsd"; then
2179 LIBS="$LIBS -lkvm"
2180 sh_libkvm="-lkvm"
2181 elif test -f "${systemmap}"; then
2182
2183 test_kmap_open=no
2184
2185 if test -c /dev/kmem; then
2186 AC_MSG_CHECKING([whether /dev/kmem is useable])
2187 dd bs=4 count=16 if=/dev/kmem of=/dev/null >/dev/null 2>&1
2188 if test $? -eq 0; then
2189 test_kmap_open=yes
2190 fi
2191 AC_MSG_RESULT([${test_kmap_open}])
2192 fi
2193
2194 if test x"${test_kmap_open}" = xno; then
2195 # need kernel module
2196
2197 if test -f /lib/modules/${kernelversion}/build/include/linux/kernel.h; then
2198 lkm_inc="-I/lib/modules/${kernelversion}/build/include"
2199 else
2200 AC_MSG_WARN([--enable-khide: /lib/modules/${kernelversion}/build/include/linux not found])
2201 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])
2202 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])
2203 fi
2204
2205 AC_MSG_CHECKING([for vmlist_lock])
2206 sh_vmlist_lock=`egrep ['[bdBD] vmlist_lock$'] ${systemmap} | awk '{print $1}'`
2207 if test x"$sh_vmlist_lock" = x; then
2208 AC_MSG_RESULT(no)
2209 else
2210 sh_vmlist_lock="0x${sh_vmlist_lock}"
2211 AC_MSG_RESULT([${sh_vmlist_lock}])
2212 AC_DEFINE_UNQUOTED(SH_VMLIST_LOCK, ${sh_vmlist_lock}, [The address of the vmlist spinlock])
2213 fi
2214
2215 AC_MSG_CHECKING([for vmlist])
2216 sh_vmlist=`egrep ['[bdBD] vmlist$'] ${systemmap} | awk '{print $1}'`
2217 if test x"$sh_vmlist" = x; then
2218 AC_MSG_RESULT(no)
2219 else
2220 sh_vmlist="0x${sh_vmlist}"
2221 AC_MSG_RESULT([${sh_vmlist}])
2222 AC_DEFINE_UNQUOTED(SH_VMLIST, ${sh_vmlist}, [The address of the vmlist])
2223 fi
2224
2225 sh_lkm="${sh_lkm} samhain_kmem.ko"
2226 sh_insmod_pre="modprobe ${install_name}_kmem"
2227
2228 fi
2229 else
2230 AC_MSG_ERROR([Option --with-kcheck=systemmap cannot be used, because system map ${systemmap} does not exist.])
2231 fi
2232 fi
2233 ]
2234)
2235
2236AC_SUBST(lkm_inc)
2237AC_SUBST(sh_lkm)
2238AC_SUBST(sh_insmod_cmd)
2239AC_SUBST(sh_insmod_pre)
2240
2241AC_SUBST(systemmap)
2242AC_SUBST(sh_libkvm)
2243
2244AC_ARG_ENABLE(base,
2245 [ --enable-base=B1,B2 base key (0...2147483647)],
2246 [
2247 AC_MSG_CHECKING(base key setting)
2248 my_key_A=`echo ${enableval} | awk 'BEGIN{FS=","}{print $1}'`
2249 my_key_B=`echo ${enableval} | awk 'BEGIN{FS=","}{print $2}'`
2250 AC_MSG_RESULT(${my_key_A} ${my_key_B})
2251 if test "x${my_key_A}" = x; then
2252 AC_MSG_ERROR([Option --enable-base=B1,B2 used with invalid first base key (zero length).])
2253 fi
2254 if test "x${my_key_B}" = x; then
2255 AC_MSG_ERROR([Option --enable-base=B1,B2 used with invalid second base key (zero length).])
2256 fi
2257 echo "${my_key_A}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2258 AC_MSG_ERROR([For --enable-base=B1,B2, B1 and B2 must be numeric in the range 0 to 2147483647.])
2259 echo "${my_key_B}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2260 AC_MSG_ERROR([For --enable-base=B1,B2, B1 and B2 must be numeric in the range 0 to 2147483647.])
2261 ],
2262 [
2263 AC_MSG_CHECKING(base key setting .. collecting entropy)
2264 my_key_1=`${srcdir}/c_random.sh 2>/dev/null`
2265 my_key_2=`${srcdir}/c_random.sh 2>/dev/null`
2266 my_key_3=`${srcdir}/c_random.sh 2>/dev/null`
2267 my_key_4=`${srcdir}/c_random.sh 2>/dev/null`
2268 my_key_A=`expr $my_key_1 \* 32767`
2269 my_key_A=`echo ${my_key_A} | sed 's%^0*%%g' 2>/dev/null`
2270 my_key_A=`expr $my_key_A \+ $my_key_2`
2271 my_key_B=`expr $my_key_3 \* 32767`
2272 my_key_B=`echo ${my_key_B} | sed 's%^0*%%g' 2>/dev/null`
2273 my_key_B=`expr $my_key_B \+ $my_key_4`
2274 AC_MSG_RESULT(${my_key_A} ${my_key_B})
2275 ]
2276 )
2277AC_SUBST(my_key_A)
2278AC_SUBST(my_key_B)
2279
2280dnl low bytes
2281my_key_1=`expr $my_key_A \% 65536`
2282dnl high bytes
2283my_key_2=`expr $my_key_A \/ 65536`
2284dnl low bytes
2285my_key_3=`expr $my_key_B \% 65536`
2286dnl high bytes
2287my_key_4=`expr $my_key_B \/ 65536`
2288
2289dnl echo ${my_key_1} ${my_key_2} ${my_key_3} ${my_key_4}
2290
2291dnl touch ./sh_MK.h
2292dnl echo "#ifndef SH_MK_H" >> ./sh_MK.h
2293dnl echo "#define SH_MK_H" >> ./sh_MK.h
2294dnl ${srcdir}/c_bits.sh ${my_key_1} MKB >> ./sh_MK.h
2295dnl ${srcdir}/c_bits.sh ${my_key_2} MKA >> ./sh_MK.h
2296dnl ${srcdir}/c_bits.sh ${my_key_3} MKC >> ./sh_MK.h
2297dnl ${srcdir}/c_bits.sh ${my_key_4} MKD >> ./sh_MK.h
2298dnl echo "#endif" >> ./sh_MK.h
2299AC_SUBST(my_key_1)
2300AC_SUBST(my_key_2)
2301AC_SUBST(my_key_3)
2302AC_SUBST(my_key_4)
2303
2304AC_MSG_CHECKING(key position)
2305pos_tf_1=`${srcdir}/c_random.sh 2>/dev/null`
2306pos_tf_2=`expr $pos_tf_1 \% 8`
2307pos_tf=`expr $pos_tf_2 + 1`
2308AC_MSG_RESULT(${pos_tf})
2309AC_DEFINE_UNQUOTED(POS_TF, ${pos_tf} )
2310
2311mykeybase=`echo ${my_key_A},${my_key_B}`
2312AC_DEFINE_UNQUOTED(DEFKEY, ${mykeybase} )
2313AC_SUBST(mykeybase)
2314
2315
2316dnl
2317dnl GPG/PGP options
2318dnl
2319
2320AC_ARG_WITH(gpg,
2321 [ --with-gpg=PATH use GnuPG to verify database/config [[no]]],
2322 [
2323 if test "x${withval}" != "xno"; then
2324 if test "x${cross_compiling}" = xyes; then
2325 mygpg="${withval}"
2326 else
2327 if test -f "${withval}"; then
2328 mygpg="${withval}"
2329 mychk0=`${withval} --load-extension tiger --print-md TIGER192 ${withval} 2>/dev/null`
2330 if test "x$?" != "x0"; then
2331 mychktest=no
2332 for sampre in ./samhain ./yule /usr/local/sbin/samhain /usr/local/bin/samhain /usr/bin/samhain /usr/sbin/samhain /usr/local/sbin/yule /usr/local/bin/yule /usr/bin/yule /usr/sbin/yule; do
2333 if test x"${mychktest}" = xyes
2334 then
2335 :
2336 else
2337 if test -f ${sampre}
2338 then
2339 echo "use existing ${sampre} for gpg checksum"
2340 mychk0=`${sampre} -H ${withval} 2>/dev/null`
2341 if test "x$?" != "x0"; then
2342 if test "x${nocl_code}" != "x"; then
2343 mychk0=`echo -H ${withval} | ${sampre} ${nocl_code} 2>/dev/null`
2344 if test "x$?" != "x0"; then
2345 :
2346 else
2347 mychk="${mychk0}"
2348 mychktest=yes
2349 fi
2350 fi
2351 else
2352 mychk="${mychk0}"
2353 mychktest=yes
2354 fi
2355 fi
2356 fi
2357 done
2358 if test x${mychktest} = xno; then
2359 AC_MSG_WARN([--with-gpg: cannot determine TIGER192 checksum of ${withval}])
2360 echo "-------------------------------------------------------------"
2361 echo " Your gpg binary does not support the TIGER192 checksum, "
2362 echo " and I cannot find an existing samhain binary to use instead."
2363 echo " You can:"
2364 echo " (a) run make to compile a samhain binary, then repeat"
2365 echo " ./configure and make"
2366 echo " (b) ignore the failure. The checksum of the gpg binary"
2367 echo " will not get compiled in, thus allowing an attacker"
2368 echo " to replace gpg with a trojan and subverting the gpg"
2369 echo " signature verification of configure and database files."
2370 echo
2371 echo " PLEASE IGNORE THIS MESSAGE IF YOU ALSO USE --with-checksum"
2372 echo "-------------------------------------------------------------"
2373 fi
2374 else
2375 mychk="${mychk0}"
2376 fi
2377 else
2378 AC_MSG_ERROR([--with-gpg: cannot find GnuPG PATH=${withval}])
2379 fi
2380 fi
2381 AC_DEFINE(WITH_GPG)
2382 AC_DEFINE_UNQUOTED(DEFAULT_GPG_PATH, _("${mygpg}") )
2383 AC_SUBST(mygpg)
2384 fi
2385 ]
2386)
2387
2388AC_ARG_WITH(keyid,
2389 [ --with-keyid=KEYID specify KeyID (0x...) for GPG/PGP functions [[none]]],
2390 [
2391 if test "x${withval}" != "x"; then
2392 echo "${withval}" | awk '{if((length($0)==10)||(length($0)==18)){exit 2}else{exit 0}}' &&
2393 AC_MSG_ERROR([--with-keyid:${withval} must be "0x" + 8|16 hex digits])
2394 echo "${withval}" | grep ['[^0][^x][^0123456789ABCDEFabcdef]'] >/dev/null 2>&1 &&
2395 AC_MSG_ERROR([--with-keyid:${withval} must be "0x" + 8|16 hex digits])
2396 mykeyid="$withval"
2397 mykeytag="--default-key"
2398 else
2399 mykeyid=""
2400 mykeytag=""
2401 fi
2402 AC_SUBST(mykeyid)
2403 AC_SUBST(mykeytag)
2404 ]
2405)
2406
2407dnl AC_ARG_WITH(pgp,
2408dnl [ --with-pgp=PATH Use PGP to verify database/config (no).],
2409dnl [myppg="$withval"
2410dnl AC_DEFINE(WITH_PGP)
2411dnl AC_DEFINE_UNQUOTED(DEFAULT_PGP_PATH, _("${myppg}") )
2412dnl ])
2413
2414AC_ARG_WITH(checksum,
2415 [ --with-checksum=CHKSUM compile in gpg/pgp checksum [[yes]]],
2416 [
2417 if test "x${withval}" != "xno"; then
2418 if test "x${withval}" != "xyes"; then
2419 if test "x${mychk}" != "x"; then
2420 if test "x${mychk}" != "x${withval}"; then
2421 AC_MSG_WARN([--with-checksum: possible gpg CHKSUM problem])
2422 AC_MSG_WARN([--with-checksum: CHKSUM=${withval}])
2423 AC_MSG_WARN([--with-checksum: autodetected=${mychk}])
2424 fi
2425 fi
2426 mychk="${withval}"
2427 else
2428 if test "x${mychk}" = "x"; then
2429 AC_MSG_ERROR([Option --with-checksum=CHKSUM: checksum CHKSUM of the gpg binary not specified.])
2430 fi
2431 fi
2432 AC_DEFINE(HAVE_GPG_CHECKSUM)
2433 AC_DEFINE_UNQUOTED(GPG_HASH, _("${mychk}") )
2434 echo "${mychk}" | sed 's,.*:,,g' | sed 's, ,,g' | sed 's,\(.\),\1:,g' | awk '{ split($0, arr, ":"); m = length($1)/2; print "#ifndef CHKSUM_H"; print "#define CHKSUM_H"; print "char gpgchk[50];"; for (i=1; i <= m; i++) printf "gpgchk[%d] = %c%s%c;\n", i-1, 39, arr[i], 39; printf "gpgchk[48] = %c%c0%c;\n", 39, 92, 39; print "#endif"; }' > sh_gpg_chksum.h
2435 fi
2436 ],
2437 [
2438 if test "x${mygpg}" != "x"; then
2439 if test "x${mychk}" != "x"; then
2440 AC_DEFINE(HAVE_GPG_CHECKSUM)
2441 AC_DEFINE_UNQUOTED(GPG_HASH, _("${mychk}") )
2442 echo "${mychk}" | sed 's,.*:,,g' | sed 's, ,,g' | sed 's,\(.\),\1:,g' | awk '{ split($0, arr, ":"); m = length($1)/2; print "#ifndef CHKSUM_H"; print "#define CHKSUM_H"; print "char gpgchk[50];"; for (i=1; i <= m; i++) printf "gpgchk[%d] = %c%s%c;\n", i-1, 39, arr[i], 39; printf "gpgchk[48] = %c%c0%c;\n", 39, 92, 39; print "#endif"; }' > sh_gpg_chksum.h
2443 fi
2444 fi
2445 ]
2446)
2447
2448AC_ARG_WITH(fp,
2449 [ --with-fp=FINGERPRINT compile in public key fingerprint [[no]]],
2450 [
2451 if test "x${withval}" != "xno"; then
2452 if test "x${withval}" != "xyes"; then
2453 withval0=`echo ${withval} | sed 's% %%g'`
2454 echo "${withval0}" | \
2455 grep ['[^0123456789abcdefABCDEF]'] >/dev/null 2>&1 &&
2456 AC_MSG_ERROR([In option --with-fp=FINGERPRINT, there is an invalid character(s) in FINGERPRINT=${withval0}.])
2457 sh_len=`echo ${withval0} | wc -c | sed 's% %%g'`
2458 sh_len0=`expr ${sh_len} \- 1`
2459 if test "x${sh_len0}" = "x40" || test "x${sh_len0}" = "x32"
2460 then
2461 myfp="${withval0}"
2462 AC_DEFINE(USE_FINGERPRINT)
2463 AC_DEFINE_UNQUOTED(SH_GPG_FP, _("${myfp}") )
2464 echo "${myfp}" | sed 's,.*:,,g' | sed 's, ,,g' | sed 's,\(.\),\1:,g' | awk '{ split($0, arr, ":"); m = length($1)/2; print "#ifndef FINGERPRINT_H"; print "#define FINGERPRINT_H"; printf "char gpgfp[%d];\n", m+1; for (i=1; i <= m; i++) printf "gpgfp[%d] = %c%s%c;\n", i-1, 39, arr[i], 39; printf "gpgfp[%d] = %c%c0%c;\n", m, 39, 92, 39; print "#endif"; }' > sh_gpg_fp.h
2465 else
2466 AC_MSG_ERROR([In option --with-fp=FINGERPRINT, the length (${sh_len0}) of FINGERPRINT ${withval0} is incorrect.])
2467 fi
2468 else
2469 AC_MSG_ERROR([For option --with-fp=FINGERPRINT, FINGERPRINT=yes is invalid, please specify a valid key fingerprint.])
2470 fi
2471 fi
2472 ])
2473
2474
2475dnl
2476dnl MAIL OPTIONS
2477dnl
2478
2479AC_ARG_WITH(recipient,
2480 [ --with-recipient=ADDR set recipient(s) for e-mail [[none]]],
2481 [
2482 withval0=`echo ${withval} | sed 's%,% %g'`
2483 for sh_item in ${withval0}
2484 do
2485 case ${sh_item} in
2486 *@localhost)
2487 ;;
2488 *@*.*)
2489 sh_tmp=`echo ${sh_item} | awk '{ if ($1 ~ [/^[a-zA-Z0-9][a-zA-Z0-9\-_\.]*@[a-zA-Z0-9\-\.]+\.([a-zA-Z]+|[0-9]+)$/]) {print 1; } else { print 0}}'`
2490 if test "x${sh_tmp}" != "x1"
2491 then
2492 AC_MSG_ERROR([Option --with-recipient=ADDR used with invalid mail address ${sh_item}.])
2493 fi
2494 ;;
2495 *)
2496 AC_MSG_ERROR([Option --with-recipient=ADDR used with invalid mail address ${sh_item}.])
2497 ;;
2498 esac
2499 done
2500 myrcp="$withval0"
2501 ],
2502 [myrcp="NULL"])
2503AC_DEFINE_UNQUOTED(DEFAULT_MAILADDRESS, _("${myrcp}") )
2504
2505
2506AC_ARG_WITH(sender,
2507 [ --with-sender=SENDER set sender for e-mail [[daemon]]],
2508 [
2509 mysender="${withval}"
2510 ],
2511 [
2512 mysender="daemon"
2513 ])
2514AC_DEFINE_UNQUOTED(DEFAULT_SENDER, _("${mysender}") )
2515
2516
2517dnl
2518dnl PATHS
2519dnl
2520
2521AC_ARG_WITH(trusted,
2522 [ --with-trusted=UID Set uid(s) of trusted users [[0]]],
2523 [
2524 sh_tmp_test=no
2525 sh_tmp=`echo ${withval} | sed 's%,% %g'`
2526 for sh_tmp1 in ${sh_tmp}
2527 do
2528 echo "${sh_tmp1}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2529 AC_MSG_ERROR([Option --with-trusted=UID used with non-numeric UID in ${withval}.])
2530 if test "x${sh_tmp1}" = "x0"
2531 then
2532 sh_tmp_test=yes
2533 fi
2534 done
2535 if test "x${sh_tmp_test}" = "xno"
2536 then
2537 withval="0,${withval}"
2538 fi
2539 mytrust="${withval}"
2540 ],
2541 [mytrust="0"] )
2542AC_DEFINE_UNQUOTED(SL_ALWAYS_TRUSTED, ${mytrust} )
2543AC_SUBST(mytrust)
2544
2545mytmpdir=
2546
2547AC_ARG_WITH(tmp-dir,
2548 [ --with-tmp-dir=PFX set directory for temporary files [[HOME]]],
2549 [
2550 if test "x${cross_compiling}" = xyes; then
2551 mytmpdir="$withval"
2552 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2553 else
2554 if test -d "${withval}"; then
2555 mytmpdir="$withval"
2556 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2557 else
2558 mytmpdir="$withval"
2559 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2560 AC_MSG_WARN([--with-tmp-dir: tmp directory ${withval} does not exist])
2561 fi
2562 fi
2563 ]
2564)
2565
2566AC_SUBST(mytmpdir)
2567
2568
2569dnl
2570dnl PATH DEFAULTS
2571dnl
2572
2573if test "x${ac_prefix_set}" = xyes
2574then
2575 if test "x${exec_prefix}" = xNONE
2576 then
2577 exec_prefix="${prefix}"
2578 fi
2579
2580 if test "x${prefix}" = xOPT
2581 then
2582 tmp_sbindir="/opt/${install_name}/bin"
2583 tmp_sysconfdir="/etc/opt"
2584 tmp_mandir="/opt/${install_name}/man"
2585 tmp_localstatedir="/var/opt/${install_name}"
2586 elif test "x${prefix}" = xUSR
2587 then
2588 tmp_sbindir="/usr/sbin"
2589 tmp_sysconfdir="/etc"
2590 tmp_mandir="/usr/share/man"
2591 tmp_localstatedir="/var"
2592 else
2593 tmp_sbindir=`eval echo ${sbindir}`
2594 tmp_sysconfdir=`eval echo ${sysconfdir}`
2595 tmp_mandir=`eval echo ${mandir}`
2596 tmp_localstatedir=`eval echo ${localstatedir}`
2597 fi
2598else
2599 prefix=""
2600 if test "x${ac_exec_prefix_set}" = xyes
2601 then
2602 tmp_sbindir=`eval echo ${sbindir}`
2603 else
2604 tmp_sbindir="/usr/local/sbin"
2605 fi
2606 tmp_sysconfdir="/etc"
2607 # share/man -> man (FHS) 11.10.2002
2608 tmp_mandir="/usr/local/man"
2609 tmp_localstatedir="/var"
2610fi
2611
2612
2613if test "x${ac_sbindir_set}" = xyes
2614then
2615 :
2616else
2617 sbindir=`eval echo ${tmp_sbindir}`
2618fi
2619
2620
2621if test "x${ac_sysconfdir_set}" = xyes
2622then
2623 :
2624else
2625 sysconfdir=`eval echo ${tmp_sysconfdir}`
2626fi
2627
2628if test "x${ac_mandir_set}" = xyes
2629then
2630 :
2631else
2632 mandir=`eval echo ${tmp_mandir}`
2633fi
2634
2635if test "x${ac_localstatedir_set}" = xyes
2636then
2637 :
2638else
2639 localstatedir=`eval echo ${tmp_localstatedir}`
2640fi
2641
2642
2643
2644AC_ARG_WITH(config-file,
2645 [ --with-config-file=FILE configuration file [[/etc/{install_name}rc]]],
2646 [
2647 myconffile="${withval}"
2648 changequote(<<, >>)dnl
2649 tmp=`echo ${withval} | sed 's%^REQ_FROM_SERVER%%'`
2650 sysconfdir=`echo ${tmp} | sed 's%/[^/][^/]*$%%'`
2651 myrpmconffile="${tmp}"
2652 changequote([, ])dnl
2653 ],
2654 [
2655 myconffile="${sysconfdir}/${install_name}rc"
2656 myrpmconffile="${myconffile}"
2657 ]
2658)
2659AC_DEFINE_UNQUOTED(DEFAULT_CONFIGFILE, _("${myconffile}") )
2660AC_SUBST(myconffile)
2661AC_SUBST(myrpmconffile)
2662
2663AC_ARG_WITH(log-file,
2664 [ --with-log-file=FILE path of log file [[/var/log/{install_name}_log]]],
2665 [
2666 mylogfile="$withval"
2667 changequote(<<, >>)dnl
2668 mylogdir=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
2669 changequote([, ])dnl
2670 ],
2671 [
2672 if test "x${mytclient}" = "x-DSH_WITH_SERVER"; then
2673 mylogfile="${localstatedir}/log/${install_name}/${install_name}_log"
2674 mylogdir="${localstatedir}/log/${install_name}"
2675 else
2676 mylogfile="${localstatedir}/log/${install_name}_log"
2677 mylogdir="${localstatedir}/log"
2678 fi
2679 ]
2680)
2681AC_DEFINE_UNQUOTED(DEFAULT_ERRFILE, _("${mylogfile}") )
2682AC_DEFINE_UNQUOTED(DEFAULT_LOGDIR, _("${mylogdir}") )
2683AC_SUBST(mylogfile)
2684AC_SUBST(mylogdir)
2685
2686AC_ARG_WITH(pid-file,
2687 [ --with-pid-file=FILE set path of pid file [[/var/run/{install_name}.pid]]],
2688 [
2689 mylockfile="$withval"
2690 changequote(<<, >>)dnl
2691 mylockdir=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
2692 changequote([, ])dnl
2693 ],
2694 [
2695 if test -h /var/run && test -d /run; then
2696 mylockfile="/run/${install_name}.pid"
2697 mylockdir="/run"
2698 else
2699 mylockfile="${localstatedir}/run/${install_name}.pid"
2700 mylockdir="${localstatedir}/run"
2701 fi
2702 ]
2703)
2704AC_DEFINE_UNQUOTED(DEFAULT_ERRLOCK, _("${mylockfile}") )
2705AC_DEFINE_UNQUOTED(DEFAULT_PIDDIR, _("${mylockdir}") )
2706AC_SUBST(mylockfile)
2707AC_SUBST(mylockdir)
2708
2709AC_ARG_WITH(state-dir,
2710 [ --with-state-dir=PFX set state data directory [[/var/lib/{install_name}]]],
2711 [
2712 mydataroot="$withval"
2713 ],
2714 [
2715 mydataroot="${localstatedir}/lib/${install_name}"
2716 ]
2717 )
2718AC_ARG_WITH(data-file,
2719 [ --with-data-file=FILE set path of data file],
2720 [
2721 mydatafile="$withval"
2722 changequote(<<, >>)dnl
2723 tmp=`echo ${withval} | sed 's%^REQ_FROM_SERVER%%'`
2724 mydataroot=`echo ${tmp} | sed 's%/[^/][^/]*$%%'`
2725 myrpmdatafile="${tmp}"
2726 changequote([, ])dnl
2727 if test x"${tmp}" = x
2728 then
2729 echo "No local path in data file ${withval}"
2730 echo "This will not work for initializing the database."
2731 if test x"${withval}" = xREQ_FROM_SERVER
2732 then
2733 echo "It should be REQ_FROM_SERVER/some/local/path"
2734 fi
2735 AC_MSG_ERROR([Option --with-data-file=FILE used with invalid path ${withval}.])
2736 fi
2737 ],
2738 [
2739 mydatafile="${mydataroot}/${install_name}_file"
2740 myrpmdatafile="${mydatafile}"
2741 ])
2742AC_DEFINE_UNQUOTED(DEFAULT_DATA_FILE, _("${mydatafile}") )
2743AC_SUBST(mydatafile)
2744AC_SUBST(myrpmdatafile)
2745
2746AC_DEFINE_UNQUOTED(DEFAULT_DATAROOT, _("${mydataroot}") )
2747AC_SUBST(mydataroot)
2748
2749AC_DEFINE_UNQUOTED(DEFAULT_QDIR, _("${mydataroot}/.quarantine") )
2750AC_SUBST(myqdir)
2751
2752
2753AC_ARG_WITH(html-file,
2754 [ --with-html-file=FILE set path of html file,],
2755 [
2756 myhtmlfile="$withval"
2757 ],
2758 [
2759 myhtmlfile="${mylogdir}/${install_name}.html"
2760 ])
2761AC_DEFINE_UNQUOTED(DEFAULT_HTML_FILE, _("${myhtmlfile}") )
2762AC_SUBST(myhtmlfile)
2763
2764
2765mydefargs=$ac_configure_args
2766# if test -z "`echo "$mydefargs" | grep "\-\-enable\-static" 2> /dev/null`"
2767# then
2768# mydefargs="--enable-static $mydefargs"
2769# fi
2770if test -z "`echo "$mydefargs" | grep "\-\-enable\-base" 2> /dev/null`"
2771then
2772 mydefargs="--enable-base=${mykeybase} $mydefargs"
2773fi
2774AC_SUBST(mydefargs)
2775
2776
2777AC_DEFINE_UNQUOTED(SH_INSTALL_DIR, _("${sbindir}"))
2778AC_DEFINE_UNQUOTED(SH_INSTALL_PATH, _("${sbindir}/${install_name}"))
2779AC_DEFINE_UNQUOTED(SH_INSTALL_NAME, _("${install_name}"))
2780
2781AC_CONFIG_HEADER(config.h)
2782
2783AC_OUTPUT(
2784[
2785Makefile
2786samhain-install.sh
2787init/samhain.startLSB
2788init/samhain.startLinux
2789init/samhain.startGentoo
2790init/samhain.startFreeBSD
2791init/samhain.startSolaris
2792init/samhain.startHPUX
2793init/samhain.startIRIX
2794init/samhain.startMACOSX
2795samhain.spec
2796rules.deb
2797rules.deb-light
2798hp_ux.psf
2799scripts/logrotate
2800scripts/samhain.spec
2801scripts/redhat_i386.client.spec
2802scripts/samhain.ebuild
2803scripts/samhain.ebuild-light
2804scripts/samhainadmin.pl
2805scripts/yuleadmin.pl
2806scripts/check_samhain.pl
2807deploy.sh
2808],
2809[
2810echo timestamp > stamp-h
2811chmod +x samhain-install.sh
2812chmod +x scripts/samhainadmin.pl
2813chmod +x scripts/yuleadmin.pl
2814chmod +x scripts/check_samhain.pl
2815]
2816)
2817
2818chmod +x deploy.sh
2819
2820if test "x${cross_compiling}" = xyes
2821then
2822
2823echo "--------------------------------------------------------------"
2824echo
2825echo "You are using a cross-compiler. The following system dependent"
2826echo "values may have been set to default values that may be"
2827echo "incorrect for your target system: "
2828echo
2829echo "ac_cv_c_bigendian bigendian byte order ${ac_cv_c_bigendian}"
2830echo "ac_cv_c_long_double long double exists ${ac_cv_c_long_double}"
2831echo "ac_cv_sizeof_char_p size of pointer to char ${ac_cv_sizeof_char_p}"
2832echo "ac_cv_sizeof_char_p size of size_t ${ac_cv_sizeof_size_t}"
2833echo "ac_cv_sizeof_unsigned_int size of unsigned int ${ac_cv_sizeof_unsigned_int}"
2834echo "ac_cv_sizeof_unsigned_long size of unsigned long ${ac_cv_sizeof_unsigned_long}"
2835echo "ac_cv_sizeof_unsigned_short size of unsigned short ${ac_cv_sizeof_unsigned_short}"
2836echo
2837echo "If these values are incorrect, change them in the file "
2838echo "config.cache and run configure again."
2839echo
2840echo "--------------------------------------------------------------"
2841
2842fi
2843
2844if test x${silent} != xyes
2845then
2846
2847 # A=`eval echo ${sbindir}` ; A=`eval echo ${A}`
2848 # B=`eval echo ${myconffile}` ; B=`eval echo ${B}`
2849 # C=`eval echo ${mandir}` ; C=`eval echo ${C}`
2850 # D=`eval echo ${mylockfile}` ; D=`eval echo ${D}`
2851 # E=`eval echo ${mylogfile}` ; E=`eval echo ${E}`
2852 # F=`eval echo ${mydataroot}` ; F=`eval echo ${F}`
2853
2854 echo
2855 echo " samhain has been configured as follows:"
2856 echo " System binaries: ${sbindir}"
2857 echo " Configuration file: ${myconffile}"
2858 echo " Manual pages: ${mandir}"
2859 echo " Data: ${mydataroot}"
2860 echo " PID file: ${mylockfile}"
2861 echo " Log file: ${mylogfile}"
2862 echo " Base key: ${mykeybase}"
2863 if test x"$mykeyid" != x
2864 then
2865 echo " target GPG/PGP key: ${mykeyid}"
2866 fi
2867 echo
2868 if test x"$mytclient" = x"-DSH_WITH_SERVER"
2869 then
2870 echo " Selected rc file: yulerc"
2871 else
2872 echo " Selected rc file: samhainrc.${selectconfig}"
2873 fi
2874
2875fi
2876
Note: See TracBrowser for help on using the repository browser.