source: trunk/configure.ac@ 472

Last change on this file since 472 was 471, checked in by katerina, 10 years ago

Fix for ticket #369 (configure detect IPv6 on Solaris).

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