source: trunk/configure.ac@ 43

Last change on this file since 43 was 43, checked in by rainer, 18 years ago

Fix for ticket #19 (autoconf problem)

File size: 63.8 KB
Line 
1
2dnl We want to override the standard _AC_INIT_PARSE_ARGS
3dnl
4AU_ALIAS([_AC_INIT_PARSE_ARGS], [SH_INIT_PARSE_ARGS])
5AU_ALIAS([_AC_INIT_help], [SH_INIT_HELP])
6
7AC_INIT(src/samhain.c)
8
9
10AC_ARG_VAR([LIBS],
11 [libraries to link against, e.g. -lintl])
12
13dnl
14dnl start
15dnl
16AM_INIT_AUTOMAKE(samhain, 2.2.1)
17AC_CANONICAL_HOST
18
19dnl
20dnl checks for programs
21dnl
22
23AC_PROG_CC
24AC_PROG_CPP
25AC_PROG_INSTALL
26AC_PROG_LN_S
27AC_PROG_AWK
28AC_PATH_PROG(cmd_hostname,hostname)
29AC_SUBST(cmd_hostname)
30
31GCC_STACK_PROTECT_CC
32
33AC_HEADER_STDC
34dnl
35dnl first one is a dummy because of an autoconf bug
36dnl (no HAVE_... for first one)
37dnl
38AC_CHECK_HEADERS([sys/ipc.h sys/msg.h sys/uio.h fcntl.h])
39
40
41AC_MSG_CHECKING([for host-specific issues])
42mydebugflag=no
43myneedg3=no
44uid_cast="signed long"
45selectconfig=linux
46mynetbsd=no
47sh_use_lcaps="undef"
48
49case "$host_os" in
50
51 *linux*)
52 sh_use_lcaps="yes"
53 AC_DEFINE(HOST_IS_LINUX)
54 AC_DEFINE(HAVE_EXT2_IOCTLS)
55 AC_MSG_RESULT(LINUX use ioctl to get e2fs flags)
56 case "$host_cpu" in
57 i*86*)
58 AC_DEFINE(HOST_IS_I86LINUX)
59 ;;
60 *)
61 ;;
62 esac
63 ;;
64
65 *osf*)
66 AC_DEFINE([HOST_IS_OSF], 1, [Define if host OS is OSF])
67 if test "x$GCC" != "xyes"; then
68 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
69 CFLAGS="$CFLAGS -O2 -assume noaligned_objects"
70 myneedg3=yes
71 AC_MSG_RESULT(OSF1 compiler needs assume noaligned_objects)
72 else
73 AC_MSG_RESULT(none)
74 fi
75 ;;
76
77 *cygwin*)
78 AC_DEFINE(HOST_IS_CYGWIN)
79 AC_MSG_RESULT(CYGWIN do not check for trusted paths)
80 ;;
81
82 *darwin*)
83 AC_DEFINE(HOST_IS_DARWIN)
84 AC_MSG_RESULT(DARWIN check resource forks)
85 ;;
86
87 *freebsd*)
88 AC_DEFINE(HOST_IS_FREEBSD)
89 selectconfig=freebsd
90 AC_MSG_RESULT(none)
91 ;;
92
93 *openbsd*)
94 selectconfig=freebsd
95 AC_MSG_RESULT(none)
96 ;;
97
98 *netbsd*)
99 mynetbsd=yes
100 AC_MSG_RESULT(NETBSD bug with libresolve)
101 ;;
102
103 *solaris*)
104 selectconfig=solaris
105 AC_DEFINE(HOST_IS_SOLARIS)
106 case "$host_cpu" in
107 i*86)
108 AC_DEFINE(HOST_IS_I86SOLARIS)
109 AC_MSG_RESULT(SOLARIS I86 vsnprintf prototype)
110 ;;
111 *)
112 AC_MSG_RESULT(none)
113 ;;
114 esac
115 if test "x$GCC" != "xyes"; then
116 if test ! -z "`echo "$CFLAGS" | grep "\-g" 2> /dev/null`" ; then
117 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
118 fi
119 if test -z "`echo "$CFLAGS" | grep "\-xO2" 2> /dev/null`"; then
120 CFLAGS="$CFLAGS -xO2"
121 fi
122 if test -z "`echo "$CFLAGS" | grep "\-Xa" 2> /dev/null`"; then
123 CFLAGS="$CFLAGS -Xa"
124 fi
125 LIBS="-lc $LIBS"
126 fi
127 ;;
128
129
130 *sun*)
131 selectconfig=solaris
132 AC_DEFINE(HOST_IS_SOLARIS)
133 AC_MSG_RESULT(none)
134 ;;
135
136 *aix*)
137 AC_DEFINE(HOST_IS_AIX)
138 selectconfig=aix5.2.0
139 uid_cast="unsigned long"
140 if test "x$GCC" != "xyes"; then
141 if test ! -z "`echo "$CFLAGS" | grep "\-g" 2> /dev/null`" ; then
142 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
143 fi
144 if test -z "`echo "$CFLAGS" | grep "\-O3" 2> /dev/null`"; then
145 CFLAGS="$CFLAGS -O3"
146 fi
147 if test -z "`echo "$CFLAGS" | grep "\-qstrict" 2> /dev/null`"; then
148 CFLAGS="$CFLAGS -qstrict"
149 fi
150 AC_MSG_RESULT(AIX size_t in the accept call and optimize O3 qstrict)
151 else
152 AC_MSG_RESULT(AIX size_t in the accept call)
153 fi
154 ;;
155
156 *hpux*)
157 AC_MSG_RESULT(HPUX has not always h_errno defined)
158 AC_DEFINE(HOST_IS_HPUX)
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 "\-fast" 2> /dev/null`"; then
164 CFLAGS="$CFLAGS -fast"
165 fi
166 fi
167 ;;
168
169 *ultrix*)
170 AC_MSG_RESULT(ULTRIX getcwd uses popen)
171 AC_DEFINE(HAVE_BROKEN_GETCWD)
172 ;;
173
174 *)
175 AC_MSG_RESULT(none)
176 ;;
177esac
178
179AC_SUBST(selectconfig)
180AC_DEFINE_UNQUOTED(UID_CAST, ${uid_cast})
181
182
183dnl *****************************************
184dnl
185dnl checks for header files
186dnl
187dnl *****************************************
188
189AC_HEADER_DIRENT
190AC_HEADER_MAJOR
191AC_HEADER_TIME
192dnl used in minilzo.c
193AC_HEADER_STAT
194AC_DECL_SYS_SIGLIST
195
196AC_CHECK_HEADERS(stddef.h libgen.h sched.h \
197 sys/vfs.h \
198 sys/select.h sys/socket.h netinet/in.h \
199 regex.h glob.h \
200 linux/ext2_fs.h ext2fs/ext2_fs.h \
201 paths.h arpa/nameser.h arpa/nameser_compat.h,
202 [],
203 [],
204 [#include <sys/types.h>]
205)
206
207
208AC_CHECK_HEADER(utmpx.h, sh_utmpx="yes", sh_utmpx="no")
209if test "x$sh_utmpx" = "xyes"; then
210 if cat "/usr/include/utmpx.h" 2>&5 |
211 egrep "WTMPX_FILE" >/dev/null 2>&1; then
212 AC_DEFINE(HAVE_UTMPX_H)
213 AC_EGREP_HEADER(ut_host, utmpx.h, AC_DEFINE(HAVE_UTHOST) )
214 AC_EGREP_HEADER(ut_addr, utmpx.h, AC_DEFINE(HAVE_UTADDR) )
215 AC_EGREP_HEADER(ut_xtime,utmpx.h, AC_DEFINE(HAVE_UTXTIME) )
216 AC_EGREP_HEADER(ut_type, utmpx.h, AC_DEFINE(HAVE_UTTYPE) )
217 else
218 AC_EGREP_HEADER(ut_addr, utmp.h, AC_DEFINE(HAVE_UTADDR) )
219 AC_EGREP_HEADER(ut_host, utmp.h, AC_DEFINE(HAVE_UTHOST) )
220 AC_EGREP_HEADER(ut_type, utmp.h, AC_DEFINE(HAVE_UTTYPE) )
221 fi
222else
223 AC_EGREP_HEADER(ut_host, utmp.h, AC_DEFINE(HAVE_UTHOST) )
224 AC_EGREP_HEADER(ut_type, utmp.h, AC_DEFINE(HAVE_UTTYPE) )
225fi
226
227dnl need to check because AIX 4.2 does not have it
228dnl
229AC_CHECK_MEMBERS([struct statfs.f_flags],[],[],[
230#ifdef HAVE_SYS_TYPES_H
231#include <sys/types.h>
232#endif
233#ifdef HAVE_SYS_STAT_H
234#include <sys/stat.h>
235#endif
236#ifdef HAVE_SYS_VFS_H
237#include <sys/vfs.h>
238#endif
239#ifdef HAVE_UNISTD_H
240#include <unistd.h>
241#endif
242])
243
244AC_SYS_LARGEFILE
245
246dnl
247dnl check whether _POSIX_SOURCE is required
248dnl
249SAMHAIN_POSIX
250
251
252dnl *****************************************
253dnl
254dnl Checks for library functions.
255dnl
256dnl *****************************************
257AC_FUNC_STRFTIME
258AC_CHECK_FUNCS(memcmp memcpy memmove memset getpwent endpwent \
259 gettimeofday strlcat strlcpy strstr strchr strerror strsignal \
260 seteuid setreuid setresuid lstat getwd getcwd ptrace \
261 usleep setpriority getpeereid nanosleep \
262 strptime basename sched_yield \
263 inet_aton gethostbyname setutent setrlimit gethostname uname \
264 initgroups getpagesize \
265 ttyname fchmod
266)
267AC_CHECK_FUNC(statfs, AC_DEFINE(HAVE_STATFS) statfs="yes", statfs="no")
268SL_CHECK_VA_COPY
269AC_CHECK_FUNCS(vsnprintf, [SL_CHECK_VSNPRINTF])
270AC_CHECK_MLOCK
271
272AC_MSG_CHECKING(how to get filesystem type)
273fstype=no
274# The order of these tests is important.
275AC_TRY_CPP([#include <sys/statvfs.h>
276#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4)
277if test $fstype = no; then
278AC_TRY_CPP([#include <sys/statfs.h>
279#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3)
280fi
281if test $fstype = no; then
282AC_TRY_CPP([#include <sys/statfs.h>
283#include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX)
284fi
285if test $fstype = no; then
286AC_TRY_CPP([#include <mntent.h>], AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD)
287fi
288if test $fstype = no; then
289AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF)
290fi
291if test $fstype = no; then
292AC_TRY_CPP([#include <sys/mount.h>
293#include <sys/fs_types.h>], AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix)
294fi
295AC_MSG_RESULT($fstype)
296
297sh_libsocket=
298
299dnl Solaris needs -lsocket and -lnsl. Unisys system includes
300dnl gethostbyname in libsocket but needs libnsl for socket.
301AC_CHECK_LIB(nsl, gethostbyname)
302AC_CHECK_LIB(socket, socket, ac_need_libsocket=1, ac_try_nsl=1)
303if test x$ac_need_libsocket = x1; then
304 LIBS="$LIBS -lsocket"
305 sh_libsocket="-lsocket"
306fi
307if test x$ac_try_nsl = x1; then
308 AC_CHECK_LIB(nsl, gethostbyname, ac_need_libnsl=1)
309 if test x$ac_need_libnsl = x1
310 then
311 LIBS="$LIBS -lnsl"
312 fi
313fi
314AC_SUBST(sh_libsocket)
315
316AC_CHECK_LIB(socket, res_search, [
317 AC_CHECK_LIB(resolv, dn_skipname)
318 AC_CHECK_LIB(resolv, __dn_skipname)
319 if test x$ac_need_libsocket = x1; then
320 :
321 else
322 LIBS="$LIBS -lsocket"
323 fi
324 ], [
325 AC_CHECK_LIB(resolv, res_search, [
326 LIBS="$LIBS -lresolv"
327 ], [
328 AC_CHECK_LIB(resolv, dn_skipname)
329 AC_CHECK_LIB(resolv, __dn_skipname)
330 ])
331 ])
332
333dnl arguments for accept
334
335dnl check for Unix98 socklen_t (found on
336dnl xemacs-patches mailing list, written
337dnl by Martin Buchholz)
338dnl
339dnl On Darwin(MacOSX) socklen_t needs to be
340dnl an int (see accept man page), on all other
341dnl unix systems we need a size_t.
342
343AC_MSG_CHECKING(for socklen_t)
344AC_TRY_COMPILE([
345#ifdef HAVE_SYS_TYPES_H
346#include <sys/types.h>
347#endif
348#ifdef HAVE_SYS_SOCKET_H
349#include <sys/socket.h>
350#endif
351 socklen_t x;
352], [],[
353 AC_MSG_RESULT(yes)
354 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[socklen_t], [type of arg3 of accept])
355],[
356 AC_TRY_COMPILE([
357#ifdef HAVE_SYS_TYPES_H
358#include <sys/types.h>
359#endif
360#ifdef HAVE_SYS_SOCKET_H
361#include <sys/socket.h>
362#endif
363 int accept (int, struct sockaddr *, size_t *);
364 ],[],[
365 AC_MSG_RESULT(size_t)
366 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[size_t], [type of arg3 of accept])
367 ], [
368 AC_MSG_RESULT(int)
369 AC_DEFINE_UNQUOTED([ACCEPT_TYPE_ARG3],[int], [type of arg3 of accept])
370 ]
371 )
372])
373
374
375dnl *****************************************
376dnl checks for typedefs
377dnl *****************************************
378
379AC_C_LONG_DOUBLE
380SH_CHECK_TYPEDEF(long long, HAVE_LONG_LONG)
381if test "$sh_HAVE_LONG_LONG" = "yes"; then
382 AC_CHECK_SIZEOF(unsigned long long, 4)
383 if test "$ac_cv_sizeof_unsigned_long_long" = "8"; then
384 AC_DEFINE(HAVE_LONG_LONG_64, 1, [Define if you have 64bit long long])
385 fi
386fi
387
388AC_CHECK_TYPE(ptrdiff_t, long)
389AC_TYPE_SIZE_T
390AC_CHECK_SIZEOF(char *, 4)
391AC_CHECK_SIZEOF(size_t, 4)
392
393AC_CHECK_SIZEOF(unsigned long, 4)
394AC_CHECK_SIZEOF(unsigned int , 4)
395AC_CHECK_SIZEOF(unsigned short, 2)
396
397
398if test "$ac_cv_sizeof_unsigned_long" = "4"; then
399 AC_DEFINE(HAVE_LONG_32)
400fi
401if test "$ac_cv_sizeof_unsigned_long" = "8"; then
402 AC_DEFINE(HAVE_LONG_64)
403fi
404if test "$ac_cv_sizeof_unsigned_int" = "4"; then
405 AC_DEFINE(HAVE_INT_32)
406fi
407
408dnl
409dnl For Alpha
410dnl
411if test "$ac_cv_sizeof_unsigned_int_" = "4"; then
412 AC_DEFINE(HAVE_INT_32)
413fi
414if test "$ac_cv_sizeof_unsigned_short" = "4"; then
415 AC_DEFINE(HAVE_SHORT_32)
416fi
417
418dnl
419dnl check for 64 bit programming environment
420dnl
421SAMHAIN_64
422
423
424dnl *****************************************
425dnl checks for structures
426dnl *****************************************
427
428AC_STRUCT_TM
429
430dnl
431dnl from e2fsprogs
432dnl
433AC_MSG_CHECKING(whether struct stat has a st_flags field)
434AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
435 AC_TRY_COMPILE([#include <sys/stat.h>],
436 [struct stat stat; stat.st_flags = 0;],
437 [e2fsprogs_cv_struct_st_flags=yes],
438 [e2fsprogs_cv_struct_st_flags=no]))
439AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
440if test "$e2fsprogs_cv_struct_st_flags" = yes; then
441 AC_MSG_CHECKING(whether st_flags field is useful)
442 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
443 AC_TRY_COMPILE([#include <sys/stat.h>],
444 [struct stat stat; stat.st_flags |= UF_IMMUTABLE;],
445 [e2fsprogs_cv_struct_st_flags_immut=yes],
446 [e2fsprogs_cv_struct_st_flags_immut=no]))
447 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
448 if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
449 AC_DEFINE(HAVE_STAT_FLAGS)
450 fi
451fi
452
453dnl
454dnl from dbus
455dnl
456AC_MSG_CHECKING(for struct cmsgcred)
457AC_TRY_COMPILE([
458#include <sys/types.h>
459#include <sys/socket.h>
460],[
461struct cmsgcred cred;
462
463cred.cmcred_pid = 0;
464],sh_have_struct_cmsgcred=yes,sh_have_struct_cmsgcred=no)
465AC_MSG_RESULT($sh_have_struct_cmsgcred)
466
467if test x$sh_have_struct_cmsgcred = xyes; then
468 AC_DEFINE(HAVE_STRUCT_CMSGCRED,1,[Have cmsgcred structure])
469fi
470
471AC_MSG_CHECKING(for struct fcred)
472AC_TRY_COMPILE([
473#include <sys/param.h>
474#include <sys/socket.h>
475#include <sys/ucred.h>
476],[
477struct fcred sockcred;
478],sh_have_struct_fcred=yes,sh_have_struct_fcred=no)
479AC_MSG_RESULT($sh_have_struct_fcred)
480
481if test x$sh_have_struct_fcred = xyes; then
482 AC_DEFINE(HAVE_STRUCT_FCRED,1,[Have fcred structure])
483fi
484
485AC_MSG_CHECKING(for struct sockcred)
486AC_TRY_COMPILE([
487#include <sys/param.h>
488#include <sys/socket.h>
489#include <sys/ucred.h>
490],[
491struct sockcred sockcred;
492],sh_have_struct_sockcred=yes,sh_have_struct_sockcred=no)
493AC_MSG_RESULT($sh_have_struct_sockcred)
494
495if test x$sh_have_struct_sockcred = xyes; then
496 AC_DEFINE(HAVE_STRUCT_SOCKCRED,1,[Have sockcred structure])
497fi
498
499AC_MSG_CHECKING(for SO_PEERCRED)
500AC_TRY_COMPILE([
501#include <sys/types.h>
502#include <sys/socket.h>
503],[
504int test = SO_PEERCRED;
505],sh_have_SO_PEERCRED=yes,sh_have_SO_PEERCRED=no)
506AC_MSG_RESULT($sh_have_SO_PEERCRED)
507
508if test x$sh_have_SO_PEERCRED = xyes; then
509 AC_DEFINE(HAVE_SO_PEERCRED,1,[Have SO_PEERCRED define])
510fi
511
512
513dnl *****************************************
514dnl checks for compiler characteristics
515dnl *****************************************
516AC_C_INLINE
517AC_C_CONST
518AC_C_BIGENDIAN
519
520AM_SA_SIGACTION_WORKS
521
522dnl *****************************************
523dnl
524dnl checks for system services
525dnl
526dnl *****************************************
527
528dnl
529dnl check for GNU gmp
530dnl
531AC_CHECK_LIB(gmp, __gmpz_init, [sh_have_gmp=yes], [sh_have_gmp=no])
532if test "x${sh_have_gmp}" = xno
533then
534 AC_CHECK_LIB(gmp, mpz_init, [sh_have_gmp=yes], [sh_have_gmp=no])
535fi
536if test "x${sh_have_gmp}" = xyes
537then
538 # LIBS="-lgmp $LIBS"
539 AC_DEFINE(HAVE_LIBGMP, 1, [Have GNU gmp library])
540fi
541AC_CHECK_HEADERS(gmp.h)
542
543
544dnl *****************************************
545dnl
546dnl enable features
547dnl
548dnl *****************************************
549
550AC_ARG_ENABLE(db-reload,
551 [ --enable-db-reload enable database reload on SIGHUP [no]],
552 [
553 if test "x${enable_db_reload}" = xyes; then
554 AC_DEFINE(RELOAD_DATABASE)
555 fi
556 ]
557)
558
559AC_ARG_ENABLE(xml-log,
560 [ --enable-xml-log enable XML logfile format [[no]]],
561 [
562 if test "x${enable_xml_log}" = xyes; then
563 AC_DEFINE(SH_USE_XML)
564 fi
565 ]
566)
567
568
569AC_ARG_ENABLE(mail,
570 [ --disable-mail disable the internal SMTP mailer],
571 [
572 if test "x${enable_mail}" = xno; then
573 :
574 else
575 AC_DEFINE(SH_WITH_MAIL)
576 fi
577 ],
578 [AC_DEFINE(SH_WITH_MAIL)]
579)
580
581AC_ARG_ENABLE(external-scripts,
582 [ --disable-external-scripts disable interface to external scripts],
583 [
584 if test "x${enableval}" = xno; then
585 :
586 else
587 AC_DEFINE(WITH_EXTERNAL)
588 fi
589 ],
590 [AC_DEFINE(WITH_EXTERNAL)]
591)
592
593AC_ARG_ENABLE(message-queue,
594 [ --enable-message-queue[[=MODE]] enable SysV message queue [[MODE=0700]]],
595 [
596 if test "x${ac_cv_header_sys_msg_h}" = "xyes"; then
597 if test "x${enable_message_queue}" = xyes; then
598 AC_DEFINE(WITH_MESSAGE_QUEUE)
599 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, 0700)
600 elif test "x${enable_message_queue}" != xno; then
601 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
602 AC_MSG_ERROR([--enable-message-queue: MODE must be numeric])
603 echo "${enableval}" | \
604 grep ['0[0123456789][0123456789][0123456789]'] >/dev/null 2>&1 ||
605 AC_MSG_ERROR([--enable-message-queue: MODE must be an octal (0nnn) number])
606 AC_DEFINE(WITH_MESSAGE_QUEUE)
607 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, ${enable_message_queue})
608 fi
609 else
610 echo
611 echo "**********************************************"
612 echo
613 AC_MSG_WARN([sys/msg.h missing, --enable-message-queue disabled])
614 echo
615 echo "**********************************************"
616 echo
617 fi
618 ]
619)
620
621AC_ARG_WITH(cflags,
622 [ --with-cflags additional flags to pass to compiler],
623 [
624 if test "x$withval" != "xno" ; then
625 CFLAGS="$CFLAGS $withval"
626 fi
627 ]
628)
629AC_ARG_WITH(libs,
630 [ --with-libs additional libraries to link with],
631 [
632 if test "x$withval" != "xno" ; then
633 LIBS="$LIBS $withval"
634 fi
635 ]
636)
637
638
639#
640# this is from ssh
641#
642AC_MSG_CHECKING(whether to use libwrap)
643LIBWRAP_LIB=""
644LIBWRAP_INC=""
645AC_ARG_WITH(libwrap,
646[ --with-libwrap[=PATH] Compile in libwrap (TCP Wrappers) support],
647[ AC_MSG_RESULT($withval)
648 case "$withval" in
649 no)
650 ;;
651 ""|yes)
652 LIBWRAP_LIB="-lwrap"
653 ;;
654 *)
655 if test -d "$withval"; then
656 LIBWRAP_LIB="-L$withval -lwrap"
657 changequote(<<, >>)dnl
658 sh_libwrap_inc=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
659 LIBWRAP_INC="-I${sh_libwrap_inc}/include"
660 changequote([, ])dnl
661 else
662 LIBWRAP_LIB="-lwrap"
663 changequote(<<, >>)dnl
664 sh_libwrap_inc=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
665 LIBWRAP_INC="-I${sh_libwrap_inc}"
666 changequote([, ])dnl
667 fi
668 ;;
669 esac
670 if test -n "$LIBWRAP_LIB"; then
671 # OLDLIBS="$LIBS"
672 LIBS="$LIBWRAP_LIB $LIBS"
673 # OLDCFLAGS="$CFLAGS"
674 CFLAGS="$CFLAGS $LIBWRAP_INC"
675 AC_CHECK_HEADER(tcpd.h,
676 [],
677 [ AC_MSG_ERROR([Could not find tcpd.h for libwrap. You must first install tcp_wrappers]) ])
678 AC_TRY_LINK([ #include <tcpd.h>
679 int allow_severity; int deny_severity; ],
680 [ hosts_access((struct request_info *) 0); ],
681 [ AC_DEFINE(SH_USE_LIBWRAP,1,[Build with tcp wrapper support]) ],
682 [ AC_MSG_ERROR([Could not find the libwrap library.]) ])
683 fi ],
684 AC_MSG_RESULT(no)
685)
686
687
688#
689# this is from the snort configure.in
690#
691AC_DEFUN(FAIL_MESSAGE,[
692 echo
693 echo
694 echo "**********************************************"
695 echo " ERROR: unable to find" $1
696 echo " checked in the following places"
697 for i in `echo $2`; do
698 echo " $i"
699 done
700 echo "**********************************************"
701 echo
702 exit
703])
704
705AC_ARG_WITH(libprelude-prefix,
706 [ --with-libprelude-prefix=PFX Prefix where libprelude is installed (optional)],
707 libprelude_config_prefix="$withval", libprelude_config_prefix="")
708
709AC_MSG_CHECKING(whether to use prelude)
710AC_ARG_WITH(prelude,
711 [ --with-prelude Prelude IDS support [[no]]],
712 [
713 if test "x${withval}" = "xno"; then
714 AC_MSG_RESULT(no)
715 else
716 AC_MSG_RESULT(yes)
717 if test x$libprelude_config_prefix != x ; then
718 if test x${LIBPRELUDE_CONFIG+set} != xset ; then
719 LIBPRELUDE_CONFIG=$libprelude_config_prefix/bin/libprelude-config
720 fi
721 fi
722
723 AC_PATH_PROG(LIBPRELUDE_CONFIG, libprelude-config, no)
724 if test x"$LIBPRELUDE_CONFIG" = "xno" ; then
725 HAVE_PRELUDE_CONFIG=no
726 else
727 HAVE_PRELUDE_CONFIG=yes
728 fi
729dnl AC_CHECK_PROG(HAVE_PRELUDE_CONFIG, libprelude-config, yes, no)
730 if test "$HAVE_PRELUDE_CONFIG" = "yes"; then
731 sh_libprelude_version=`$LIBPRELUDE_CONFIG --version`
732 case "$sh_libprelude_version" in
733 0.8*)
734 sh_prelude_libs=`$LIBPRELUDE_CONFIG --libs | sed 's,\(.*\)\( -L.* -lprelude$\),\2 \1,'`
735 sh_prelude_cflags=`$LIBPRELUDE_CONFIG --cflags`
736 LIBS="$LIBS ${sh_prelude_libs}"
737 CFLAGS="$CFLAGS ${sh_prelude_cflags}"
738 AC_DEFINE(HAVE_LIBPRELUDE,1,[Have libprelude])
739 AC_DEFINE(HAVE_LIBPRELUDE_8,1,[Have libprelude 0.8])
740 ;;
741 *)
742 AM_PATH_LIBPRELUDE([0.9.6],
743 [
744 AC_DEFINE(HAVE_LIBPRELUDE,1,[Have libprelude])
745 AC_DEFINE(HAVE_LIBPRELUDE_9,1,[Have libprelude 0.9])
746 CFLAGS="$CFLAGS $LIBPRELUDE_PTHREAD_CFLAGS"
747 LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS"
748 LIBS="$LIBS $LIBPRELUDE_LIBS"
749 ],
750 [
751 AC_MSG_ERROR([Could not find libprelude.])
752 ])
753 ;;
754 esac
755 else
756 AC_MSG_ERROR([Could not find libprelude.])
757 fi
758 fi
759 ],
760 [
761 AC_MSG_RESULT(no)
762 ]
763)
764
765dnl AC_MSG_CHECKING(whether to use prelude)
766dnl AC_ARG_WITH(prelude,
767dnl [ --with-prelude Prelude IDS support [[no]]],
768dnl [
769dnl if test "x${withval}" = "xno"; then
770dnl AC_MSG_RESULT(no)
771dnl else
772dnl AC_CHECK_PROG(HAVE_PRELUDE_CONFIG, libprelude-config, yes, no)
773dnl if test "$HAVE_PRELUDE_CONFIG" = "yes"; then
774dnl sh_prelude_libs=`libprelude-config --libs | sed 's,\(.*\)\( -L.* -lprelude$\),\2 \1,'`
775dnl sh_prelude_cflags=`libprelude-config --cflags`
776dnl LIBS="$LIBS ${sh_prelude_libs}"
777dnl CFLAGS="$CFLAGS ${sh_prelude_cflags}"
778dnl AC_DEFINE(HAVE_LIBPRELUDE,1,[Have libprelude])
779dnl else
780dnl AC_MSG_ERROR([Could not find libprelude-config. Did you specify a valid path?])
781dnl fi
782dnl fi
783dnl ],
784dnl AC_MSG_RESULT(no)
785dnl )
786
787AC_ARG_ENABLE(static,
788 [ --enable-static enable static linking (recommended) [[no]]],
789 [
790 if test x$enable_static = xyes; then
791 if test x"$mynetbsd" = xyes
792 then
793 tmp_LIBS=`echo $LIBS | sed 's%\-lresolv%%' `
794 LIBS="${tmp_LIBS}"
795 fi
796 AC_DEFINE(SH_COMPILE_STATIC, 1, [Define if compiling static])
797 if test "x$GCC" = "xyes"; then
798 LDFLAGS="$LDFLAGS -static"
799 else
800 case "$host_os" in
801
802 *aix*)
803 LDFLAGS="$LDFLAGS -bnso -bI:/lib/syscalls.exp"
804 ;;
805
806 *hpux*)
807 LDFLAGS="$LDFLAGS -Wl,-a,archive"
808 ;;
809
810 *osf*)
811 LDFLAGS="$LDFLAGS -non_shared"
812 ;;
813
814 *irix*)
815 LDFLAGS="$LDFLAGS -non_shared"
816 ;;
817
818 *sco*)
819 LDFLAGS="$LDFLAGS -dn"
820 ;;
821
822 *sun*)
823 LDFLAGS="$LDFLAGS -Bstatic"
824 ;;
825
826 *solaris*)
827 LDFLAGS="$LDFLAGS -Bstatic"
828 ;;
829
830 *)
831 echo "***********************************************"
832 echo "*"
833 echo "* Don't know how to enable static linking"
834 echo "* with your compiler. Please set the environment"
835 echo "* variable LDFLAGS to:"
836 echo "* ${LDFLAGS} + the static linking flag"
837 echo "* and run configure again"
838 echo "*"
839 echo "***********************************************"
840 ;;
841
842 esac
843 fi
844 fi
845 ]
846)
847
848#
849# partly based on the snort configure.in
850#
851AC_ARG_WITH(database,
852 [ --with-database=[[mysql|postgresql|oracle|odbc]] database support [[no]]],
853 [
854 if test x"$enable_xml_log" != xyes; then
855 AC_MSG_ERROR([--with-database: --enable-xml-log required])
856 fi
857 if test "x${withval}" = "xmysql"; then
858 AC_CHECK_PROG(HAVE_MYSQL_CONFIG, mysql_config, yes, no)
859 if test "$HAVE_MYSQL_CONFIG" = "yes"; then
860 # echo "mysql_config found"
861 sh_mysql_libs="`mysql_config --libs`"
862 # echo ${sh_mysql_libs}
863 sh_mysql_libs="`eval echo ${sh_mysql_libs}`"
864 # echo $mysql_libs
865 # save_libs="$LIBS"
866 # LIBS="$LIBS `mysql_config --libs`"
867 # echo $LIBS
868 LIBS="$LIBS ${sh_mysql_libs}"
869 # echo $LIBS
870 sh_mysql_cflags="`mysql_config --cflags`"
871 sh_mysql_cflags="`eval echo ${sh_mysql_cflags}`"
872 # CFLAGS="$CFLAGS `mysql_config --cflags`"
873 # CFLAGS="$CFLAGS ${sh_mysql_cflags}"
874 CPPFLAGS="$CPPFLAGS ${sh_mysql_cflags}"
875 else
876 AC_MSG_CHECKING(for MySQL in /usr /usr/local /usr/local/mysql MYSQL_HOME)
877 mysql_directory="/usr /usr/local /usr/local/mysql ${MYSQL_HOME}"
878
879 for i in $mysql_directory; do
880 if test -r $i/include/mysql/mysql.h; then
881 MYSQL_DIR=$i
882 MYSQL_INC_DIR=$i/include
883 # we use AC_CHECK_HEADERS to check for mysql/mysql.h
884 fi
885 done
886 if test -z "$MYSQL_DIR"; then
887 for i in $mysql_directory; do
888 if test -r $i/include/mysql.h; then
889 MYSQL_DIR=$i
890 MYSQL_INC_DIR=$i/include
891 fi
892 done
893 fi
894
895 if test -z "$MYSQL_DIR"; then
896 tmp=""
897 for i in $mysql_directory; do
898 tmp="$tmp $i/include $i/include/mysql"
899 done
900 FAIL_MESSAGE("mysql headers (mysql.h)", $tmp)
901 fi
902
903 for i in lib lib/mysql; do
904 str="$MYSQL_DIR/$i/libmysqlclient.*"
905 for j in `echo $str`; do
906 if test -r $j; then
907 MYSQL_LIB_DIR="$MYSQL_DIR/$i"
908 break 2
909 fi
910 done
911 done
912
913 if test -z "$MYSQL_LIB_DIR"; then
914 for ff in $mysql_directory; do
915 for i in lib lib/mysql; do
916 str="$ff/$i/libmysqlclient.*"
917 for j in `echo $str`; do
918 if test -r $j; then
919 MYSQL_LIB_DIR="$ff/$i"
920 break 3
921 fi
922 done
923 done
924 done
925 fi
926
927 if test -z "$MYSQL_LIB_DIR"; then
928 tmp=""
929 for i in $mysql_directory; do
930 tmp="$i/lib $i/lib/mysql"
931 done
932 FAIL_MESSAGE("mysql library libmysqlclient", $tmp)
933 fi
934
935 AC_MSG_RESULT(yes)
936 LIBS="$LIBS -L${MYSQL_LIB_DIR} -lmysqlclient"
937 # CFLAGS="$CFLAGS -I${MYSQL_INC_DIR}"
938 CPPFLAGS="$CPPFLAGS -I${MYSQL_INC_DIR}"
939 fi
940 AC_DEFINE(WITH_MYSQL)
941 AC_DEFINE(WITH_DATABASE)
942 AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no])
943 AC_MSG_CHECKING(for zlib)
944 if test "$zlib_cv_libz" = "yes"
945 then
946 LIBS="$LIBS -lz -lm"
947 AC_MSG_RESULT(ok)
948 else
949 AC_MSG_RESULT(failed)
950 echo
951 echo " Either the mysql or the zlib library was not found"
952 echo " or was unusable, maybe because an old, incompatible"
953 echo " version is installed on your system, eg compiled from"
954 echo " source long time ago. See config.log for the error"
955 echo " message from the compiler."
956 echo " Please review your installed mysql and zlib libraries"
957 echo " and/or use --with-libs=-L/path/to/libdirectory"
958 echo " where libdirectory is the directory holding libmysql"
959 echo " or libz."
960 if test x"$enable_static" = xyes; then
961 echo " Note that for compiling a static binary, you need"
962 echo " the static libraries, rather than the shared ones."
963 fi
964 echo
965 AC_MSG_ERROR([libmysql or zlib not found or unuseable])
966 fi
967 AC_CHECK_HEADERS(mysql/mysql.h)
968 elif test "x${withval}" = "xpostgresql"; then
969 AC_DEFINE(WITH_POSTGRES)
970 AC_DEFINE(WITH_DATABASE)
971 #
972 PGCONF="no"
973 MY_PATH="${PATH}:/usr/local/bin:/usr/local/pgsql/bin"
974 OLD_IFS="$IFS"
975 IFS=":"
976 for ff in ${MY_PATH}
977 do
978 if test -f "$ff/pg_config"
979 then
980 PGCONF="$ff/pg_config"
981 fi
982 done
983 IFS="${OLD_IFS}"
984 #
985 #
986 if test "x${PGCONF}" = "xno"
987 then
988 AC_MSG_CHECKING(for PostgreSQL in /usr/local/pgsql /usr/pgsql /usr/local /usr PGSQL_HOME)
989 pgsql_directory="/usr/local/pgsql /usr/pgsql /usr/local /usr ${PGSQL_HOME}"
990 for i in $pgsql_directory; do
991 if test -r $i/include/pgsql/libpq-fe.h; then
992 PGSQL_INC_DIR=$i/include
993 PGSQL_DIR=$i
994 # use AC_CHECK_HEADERS to check for pgsql/libpq-fe.h
995 fi
996 done
997 if test -z "$PGSQL_DIR"; then
998 for i in $pgsql_directory; do
999 if test -r $i/include/libpq-fe.h; then
1000 PGSQL_INC_DIR=$i/include
1001 PGSQL_DIR=$i
1002 fi
1003 done
1004 fi
1005
1006 if test -z "$PGSQL_DIR"; then
1007 tmp=""
1008 for i in $pgsql_directory; do
1009 tmp="$tmp $i/include $i/include/pgsql"
1010 done
1011 FAIL_MESSAGE("PostgreSQL header file (libpq-fe.h)", $tmp)
1012 fi
1013
1014 for i in lib lib/pgsql; do
1015 str="$PGSQL_DIR/$i/libpq.*"
1016 for j in `echo $str`; do
1017 if test -r $j; then
1018 PGSQL_LIB_DIR="$PGSQL_DIR/$i"
1019 break 2
1020 fi
1021 done
1022 done
1023
1024 if test -z "$PGSQL_LIB_DIR"; then
1025 for ff in $pgsql_directory; do
1026 for i in lib lib/pgsql; do
1027 str="$ff/$i/libpq.*"
1028 for j in `echo $str`; do
1029 if test -r $j; then
1030 PGSQL_LIB_DIR="$ff/$i"
1031 break 3
1032 fi
1033 done
1034 done
1035 done
1036 fi
1037
1038 if test -z "$PGSQL_LIB_DIR"; then
1039 tmp=""
1040 for i in $pgsql_directory; do
1041 tmp="$i/lib $i/lib/pgsql"
1042 done
1043 FAIL_MESSAGE("postgresql library libpq", $tmp)
1044 fi
1045
1046 AC_MSG_RESULT(yes)
1047
1048 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lm"
1049 if test x"$enable_static" = xyes; then
1050 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lcrypt -lm"
1051 else
1052 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lm"
1053 fi
1054 # CFLAGS="$CFLAGS -I${PGSQL_INC_DIR}"
1055 CPPFLAGS="$CPPFLAGS -I${PGSQL_INC_DIR}"
1056 AC_CHECK_HEADERS(pgsql/libpq-fe.h)
1057 else
1058 pg_lib_dir=`${PGCONF} --libdir`
1059 if test x"$enable_static" = xyes; then
1060 LIBS="$LIBS -L${pg_lib_dir} -lpq -lcrypt -lm"
1061 else
1062 LIBS="$LIBS -L${pg_lib_dir} -lpq -lm"
1063 fi
1064 pg_inc_dir=`${PGCONF} --includedir`
1065 # CFLAGS="$CFLAGS -I${pg_inc_dir}"
1066 CPPFLAGS="$CPPFLAGS -I${pg_inc_dir}"
1067 fi
1068 elif test "x${withval}" = "xodbc"; then
1069 AC_MSG_CHECKING(for odbc in /usr /usr/local ODBC_HOME)
1070 odbc_directory="/usr /usr/local"
1071
1072 for i in $odbc_directory; do
1073 if test -r $i/include/sql.h; then
1074 if test -r $i/include/sqlext.h; then
1075 if test -r $i/include/sqltypes.h; then
1076 ODBC_DIR=$i
1077 ODBC_INC_DIR=$i/include
1078 fi
1079 fi
1080 fi
1081 done
1082
1083 if test -z "$ODBC_DIR"; then
1084 tmp=""
1085 for i in $odbc_directory; do
1086 tmp="$tmp $i/include"
1087 done
1088 FAIL_MESSAGE("odbc headers (sql.h sqlext.h sqltypes.h)", $tmp)
1089 fi
1090
1091 str="$ODBC_DIR/lib/libodbc.*"
1092 for j in `echo $str`; do
1093 if test -r $j; then
1094 ODBC_LIB_DIR="$ODBC_DIR/lib"
1095 ODBC_LIB="odbc"
1096 fi
1097 done
1098
1099 if test -z "$ODBC_LIB_DIR"; then
1100 FAIL_MESSAGE("odbc library (libodbc)", "$ODBC_DIR/lib")
1101 fi
1102
1103 AC_MSG_RESULT(yes)
1104 CPPFLAGS="${CPPFLAGS} -I${ODBC_INC_DIR}"
1105 LIBS="${LIBS} -L${ODBC_LIB_DIR} -l$ODBC_LIB"
1106 AC_DEFINE(WITH_ODBC)
1107 AC_DEFINE(WITH_DATABASE)
1108
1109 elif test "x${withval}" = "xoracle"; then
1110 AC_MSG_CHECKING(for oracle in /usr /usr/local ORACLE_HOME)
1111 oracle_directory="/usr /usr/local ${ORACLE_HOME}"
1112 for i in $oracle_directory; do
1113 if test -r $i/rdbms/demo/oci.h; then
1114 ORACLE_DIR=$i
1115 fi
1116 done
1117
1118 if test -z "$ORACLE_DIR"; then
1119 tmp=""
1120 for i in $oracle_directory; do
1121 tmp="$tmp $i/rdbms/demo"
1122 done
1123 FAIL_MESSAGE("OCI header file (oci.h)", $tmp)
1124 else
1125 for i in rdbms/demo rdbms/public network/public; do
1126 ORACLE_CPP_FLAGS="$ORACLE_CPP_FLAGS -I$ORACLE_DIR/$i"
1127 done
1128 ORACLE_LIB_DIR="$ORACLE_DIR/lib"
1129 AC_MSG_RESULT(yes)
1130
1131 CPPFLAGS="${CPPFLAGS} ${ORACLE_CPP_FLAGS}"
1132
1133 ORACLE_LIBS="-lclntsh"
1134 if test -r $ORACLE_LIB_DIR/libwtc9.so; then
1135 ORACLE_LIBS="${ORACLE_LIBS} -lwtc9"
1136 elif test -r $ORACLE_LIB_DIR/libwtc8.so; then
1137 ORACLE_LIBS="${ORACLE_LIBS} -lwtc8"
1138 fi
1139 LIBS="${LIBS} -L${ORACLE_LIB_DIR} ${ORACLE_LIBS}"
1140 fi
1141 AC_DEFINE(WITH_ORACLE)
1142 AC_DEFINE(WITH_DATABASE)
1143
1144 else
1145 AC_MSG_ERROR([--with-database: unsupported database ${withval}])
1146 fi
1147 ]
1148)
1149
1150AC_ARG_WITH(console,
1151 [ --with-console=PATH set path to console device [[/dev/console]]],
1152 [
1153 if test "x${withval}" != xno; then
1154 mycons="$withval"
1155 AC_DEFINE_UNQUOTED(DEFAULT_CONSOLE, _("${mycons}") )
1156 fi
1157 ])
1158
1159AC_ARG_WITH(altconsole,
1160 [ --with-altconsole=PATH set path to second console device [[none]]],
1161 [
1162 if test "x${withval}" != xno; then
1163 myaltcons="$withval"
1164 else
1165 myaltcons="NULL"
1166 fi
1167 ],
1168 [myaltcons="NULL"])
1169AC_DEFINE_UNQUOTED(ALT_CONSOLE, _("${myaltcons}") )
1170
1171AC_ARG_WITH(timeserver,
1172 [ --with-timeserver=HOST set host address for time server [[none]]],
1173 [
1174 if test "x${withval}" != xno; then
1175 mytimeserv="$withval"
1176 AC_DEFINE(HAVE_NTIME)
1177 else
1178 mytimeserv="NULL"
1179 fi
1180 ],
1181 mytimeserv="NULL")
1182AC_DEFINE_UNQUOTED(DEFAULT_TIMESERVER, _("${mytimeserv}") )
1183
1184AC_ARG_WITH(alttimeserver,
1185 [ --with-alttimeserver=HOST set address for backup time server [[none]]],
1186 [
1187 if test "x${withval}" != xno; then
1188 myalttimeserv="$withval"
1189 AC_DEFINE(HAVE_NTIME)
1190 else
1191 myalttimeserv="NULL"
1192 fi
1193 ],
1194 myalttimeserv="NULL")
1195AC_DEFINE_UNQUOTED(ALT_TIMESERVER, _("${myalttimeserv}") )
1196
1197AC_ARG_ENABLE(login-watch,
1198 [ --enable-login-watch watch for login/logout [[no]]],
1199 [
1200 if test "x${enable_login_watch}" = xyes; then
1201 AC_DEFINE(SH_USE_UTMP)
1202 fi
1203 ]
1204)
1205
1206AC_ARG_ENABLE(mounts-check,
1207 [ --enable-mounts-check check mount options on filesystems [[no]]],
1208 [
1209 if test "x${enable_mounts_check}" = xyes; then
1210 AC_DEFINE(SH_USE_MOUNTS)
1211 fi
1212 ]
1213)
1214
1215AC_ARG_ENABLE(userfiles,
1216 [ --enable-userfiles check for users' config files [[no]]],
1217 [
1218 if test "x${enableval}" = "xyes"; then
1219 AC_DEFINE(SH_USE_USERFILES)
1220 fi
1221 ]
1222)
1223
1224AC_ARG_ENABLE(debug,
1225 [ --enable-debug enable debug options [[no]]],
1226 [
1227 if test "x${enable_debug}" = "xyes"; then
1228 if test "x${mydebugflag}" != "xyes"; then
1229 AC_DEFINE(MEM_DEBUG)
1230 fi
1231 AC_DEFINE(WITH_TPT)
1232 AC_DEFINE(SL_DEBUG)
1233 AC_DEFINE(SL_FAIL_ON_ERROR)
1234 if test "x${myneedg3}" = "xyes"; then
1235 mydebugdef="-g3"
1236 else
1237 mydebugdef="-g"
1238 fi
1239 mydebugit="yes"
1240 fi
1241 ]
1242)
1243AC_SUBST(mydebugdef)
1244
1245AC_ARG_ENABLE(ptrace,
1246 [ --enable-ptrace use anti-debugger options [[no]]],
1247 [
1248 if test "x${enable_ptrace}" = xyes; then
1249 if test "x$mydebugit" != "xyes"; then
1250 AC_DEFINE(SCREW_IT_UP)
1251 fi
1252 fi
1253 ]
1254)
1255
1256dnl
1257if test "x$GCC" = "xyes"; then
1258 if test ! -z "`echo "$CFLAGS" | grep "\-g\ " 2> /dev/null`" ; then
1259 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
1260 fi
1261
1262dnl if test ! -z "`echo "$CFLAGS" | grep "\-O2" 2> /dev/null`" ; then
1263dnl CFLAGS=`echo $CFLAGS | sed 's%\-O2%\-O3%' `
1264dnl fi
1265
1266 if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
1267 CFLAGS="$CFLAGS -Wall -W "
1268 fi
1269
1270 if test -z "`echo "$CFLAGS" | grep "\-fstrength\-reduce" 2> /dev/null`"
1271 then
1272 if test -z "`echo "$CFLAGS" | grep "\-fno\-strength\-reduce" 2> /dev/null`"
1273 then
1274 CFLAGS="$CFLAGS -fno-strength-reduce"
1275 fi
1276 fi
1277
1278 if test -z "`echo "$CFLAGS" | grep "\-fomit\-frame\-pointer" 2> /dev/null`"
1279 then
1280 if test -z "`echo "$CFLAGS" | grep "\-fno\-omit\-frame\-pointer" 2> /dev/null`"
1281 then
1282 CFLAGS="$CFLAGS -fno-omit-frame-pointer"
1283 fi
1284 fi
1285
1286fi
1287
1288AC_MSG_CHECKING([which random module to use])
1289AC_ARG_WITH(rnd,
1290 [ --with-rnd=[[egd|unix|dev|default]] random number generator [[default]]],
1291[use_static_rnd=$withval], [use_static_rnd=default] )
1292
1293if test "$use_static_rnd" = no; then
1294 use_static_rnd=default
1295fi
1296
1297case "$use_static_rnd" in
1298 egd | dev | unix | default )
1299 AC_MSG_RESULT($use_static_rnd)
1300 ;;
1301 * )
1302 AC_MSG_RESULT([invalid argument])
1303 AC_MSG_ERROR([--with-rnd: there is no random module ${use_static_rnd}])
1304 ;;
1305esac
1306
1307AC_ARG_WITH(egd-socket,
1308 [ --with-egd-socket=NAME EGD socket name],
1309 egd_socket_name="$withval", egd_socket_name="" )
1310AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, _("$egd_socket_name") )
1311
1312dnl
1313dnl See whether the user wants to disable checking for /dev/random
1314
1315try_dev_random=yes
1316
1317case "$use_static_rnd" in
1318dev | default )
1319 try_dev_random=yes
1320 ;;
1321egd)
1322 AC_DEFINE(HAVE_EGD_RANDOM)
1323 try_dev_random=no
1324 ;;
1325unix)
1326 AC_DEFINE(HAVE_UNIX_RANDOM)
1327 try_dev_random=no
1328 ;;
1329esac
1330
1331
1332if test "x$try_dev_random" = "xyes"; then
1333 AC_MSG_CHECKING(whether /dev/random exists)
1334 if test -r "/dev/srandom" && test -c "/dev/srandom"; then
1335 AC_DEFINE(HAVE_URANDOM)
1336 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, _("/dev/srandom") )
1337 AC_MSG_RESULT(yes)
1338 if test -r "/dev/urandom" && test -c "/dev/urandom"; then
1339 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, _("/dev/urandom") )
1340 fi
1341 else
1342 if test -r "/dev/random" && test -c "/dev/random"; then
1343 AC_DEFINE(HAVE_URANDOM)
1344 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, _("/dev/random") )
1345 AC_MSG_RESULT(yes)
1346 if test -r "/dev/urandom" && test -c "/dev/urandom"; then
1347 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, _("/dev/urandom") )
1348 fi
1349 else
1350 AC_MSG_RESULT(no)
1351 AC_DEFINE(HAVE_UNIX_RANDOM)
1352 fi
1353 fi
1354fi
1355
1356
1357dnl
1358dnl NETWORK OPTIONS
1359dnl
1360
1361
1362AC_ARG_ENABLE(network,
1363 [ --enable-network=[[client|server]] compile client or server [[no]]],
1364 [
1365 if test "x$enable_network" = xclient; then
1366 mytclient="-DSH_WITH_CLIENT"
1367 yulectl_prg=
1368 setpwd_prg="samhain_setpwd"
1369 sh_main_prg="samhain"
1370 if test "x${sh_have_gmp}" = xyes
1371 then
1372 LIBS="-lgmp $LIBS"
1373 fi
1374dnl AC_CHECK_HEADER(sys/capability.h,
1375dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
1376dnl [sh_use_lcaps="no"])
1377 elif test "x$enable_network" = xserver; then
1378 mytclient="-DSH_WITH_SERVER"
1379 yulectl_prg="yulectl"
1380 setpwd_prg="samhain_setpwd"
1381 sh_main_prg="yule"
1382 if test "x${sh_have_gmp}" = xyes
1383 then
1384 LIBS="-lgmp $LIBS"
1385 fi
1386 sh_use_lcaps="undef"
1387 elif test "x$enable_network" = xno; then
1388 mytclient="-DSH_STANDALONE"
1389 yulectl_prg=
1390 setpwd_prg=
1391 sh_main_prg="samhain"
1392dnl AC_CHECK_HEADER(sys/capability.h,
1393dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
1394dnl [sh_use_lcaps="no"])
1395 else
1396 AC_MSG_ERROR([--enable-network=WHAT: WHAT must be client, server, or no])
1397 fi
1398 ],
1399 [
1400 mytclient="-DSH_STANDALONE"
1401 setpwd_prg=
1402 yulectl_prg=
1403 sh_main_prg="samhain"
1404dnl AC_CHECK_HEADER(sys/capability.h,
1405dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
1406dnl [sh_use_lcaps="no"])
1407 ],
1408)
1409AC_SUBST(setpwd_prg)
1410AC_SUBST(yulectl_prg)
1411AC_SUBST(sh_main_prg)
1412AC_SUBST(mytclient)
1413
1414# needed for the rpm spec
1415clmytclient=`echo ${mytclient} | sed s%\-%%`
1416AC_SUBST(clmytclient)
1417
1418AC_ARG_ENABLE(udp,
1419 [ --enable-udp server can listen on port 514/udp [[no]]],
1420 [
1421 if test "x${enable_udp}" = xyes; then
1422 AC_DEFINE(INET_SYSLOG)
1423 fi
1424 ]
1425)
1426
1427myencrypt=yes
1428AC_ARG_ENABLE(encrypt,
1429 [ --disable-encrypt disable client/server encryption],
1430 [
1431 if test "x${enable_encrypt}" = xno; then
1432 myencrypt=no
1433 elif test "x${enable_encrypt}" = "x1"; then
1434 myencrypt=1
1435 fi
1436 ]
1437)
1438if test "x${myencrypt}" = "xyes"; then
1439 AC_DEFINE(SH_ENCRYPT)
1440 AC_DEFINE(SH_ENCRYPT_2)
1441elif test "x${myencrypt}" = "x1"; then
1442 AC_DEFINE(SH_ENCRYPT)
1443fi
1444
1445sh_use_srp_proto=yes
1446AC_ARG_ENABLE(srp,
1447 [ --disable-srp disable SRP for authentication],
1448 [
1449 if test "x${enable_srp}" = xno; then
1450 sh_use_srp_proto=no
1451 fi
1452 ]
1453)
1454if test "x${sh_use_srp_proto}" = xyes; then
1455 AC_DEFINE(USE_SRP_PROTOCOL)
1456fi
1457
1458AC_ARG_WITH(port,
1459 [ --with-port=PORT set port to use for TCP/IP connection [[49777]]],
1460 [
1461 echo "${withval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1462 AC_MSG_ERROR([--with-port: PORT must be numeric])
1463 myport=${withval}
1464 ],
1465 [myport="49777"])
1466AC_DEFINE_UNQUOTED(SH_DEFAULT_PORT, ${myport})
1467AC_SUBST(myport)
1468
1469AC_ARG_WITH(logserver,
1470 [ --with-logserver=HOST set host address for log server [[none]]],
1471 [
1472 case "$withval" in
1473 *.* | localhost)
1474 mylogsrv="$withval"
1475 ;;
1476 *)
1477 mylogsrv="$withval"
1478 ;;
1479 esac
1480 ],
1481 [mylogsrv="NULL"])
1482AC_DEFINE_UNQUOTED(DEFAULT_LOGSERVER, _("${mylogsrv}") )
1483AC_SUBST(mylogsrv)
1484
1485AC_ARG_WITH(altlogserver,
1486 [ --with-altlogserver=HOST set address for backup log server [[none]]],
1487 [
1488 case "$withval" in
1489 *.* | localhost)
1490 myaltlogsrv="$withval"
1491 ;;
1492 *)
1493 myaltlogsrv="$withval"
1494 ;;
1495 esac
1496 ],
1497 [myaltlogsrv="NULL"])
1498AC_DEFINE_UNQUOTED(ALT_LOGSERVER, _("${myaltlogsrv}"))
1499
1500
1501
1502dnl
1503dnl STEALTH OPTIONS
1504dnl
1505nocl_code=
1506xor_code=0
1507AC_ARG_ENABLE(nocl,
1508 [ --enable-nocl=PW no CL parsing unless first CL argument is PW],
1509 [
1510 if test "x${enableval}" != "x"; then
1511 AC_DEFINE(SH_STEALTH_NOCL)
1512 fi
1513 if test "x${enableval}" = "xstop" || test "x${enableval}" = "xstart"; then
1514 AC_MSG_ERROR([--enable-nocl: start/stop/reload/restart/status are reserved words])
1515 fi
1516 if test "x${enableval}" = "xreload" || test "x${enableval}" = "xrestart"; then
1517 AC_MSG_ERROR([--enable-nocl: start/stop/reload/restart/status are reserved words])
1518 fi
1519 if test "x${enableval}" = "xstatus"; then
1520 AC_MSG_ERROR([--enable-nocl: start/stop/reload/restart/status are reserved words])
1521 fi
1522 if test "x${enableval}" = "xno"; then
1523 AC_MSG_ERROR([--enable-nocl: use of --enable-nocl=no is ambiguous])
1524 fi
1525 nocl_code="${enable_nocl}"
1526 ]
1527)
1528AC_DEFINE_UNQUOTED(NOCL_CODE, _("${nocl_code}") )
1529AC_SUBST(nocl_code)
1530AC_ARG_ENABLE(stealth,
1531 [ --enable-stealth=XOR_VAL enable stealth mode [[no]]],
1532 [AC_DEFINE(SH_STEALTH)
1533 if test "x${enableval}" != "xyes"; then
1534 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1535 AC_MSG_ERROR([--enable-stealth: XOR_VAL must be numeric])
1536 if test "${enableval}" -lt 127 || test "${enableval}" -gt 255; then
1537 if test x"${enableval}" = x0
1538 then
1539 :
1540 else
1541 AC_MSG_ERROR([--enable-stealth: XOR_VAL must be in the range 127 to 255])
1542 fi
1543 fi
1544 xor_code="${enable_stealth}"
1545 else
1546 xor_code=0
1547 fi
1548 stegin_prg="samhain_stealth"
1549 ],
1550 [
1551 stegin_prg=
1552 ]
1553)
1554AC_ARG_ENABLE(micro-stealth,
1555 [ --enable-micro-stealth=XOR_VAL enable micro stealth mode [[no]]],
1556 [
1557 AC_DEFINE(SH_STEALTH)
1558 AC_DEFINE(SH_STEALTH_MICRO)
1559 if test "x${enableval}" != "xyes"; then
1560 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1561 AC_MSG_ERROR([--enable-micro-stealth: XOR_VAL must be numeric])
1562 if test "${enableval}" -lt 127 || test "${enableval}" -gt 255; then
1563 if test x"${enableval}" = x0
1564 then
1565 :
1566 else
1567 AC_MSG_ERROR([--enable-micro-stealth: XOR_VAL must be in the range 127 to 255])
1568 fi
1569 fi
1570 xor_code="${enable_micro_stealth}"
1571 else
1572 xor_code=0
1573 fi
1574 ]
1575)
1576install_name="samhain"
1577INSTALL_NAME="SAMHAIN"
1578AC_ARG_ENABLE(install-name,
1579 [ --enable-install-name=NAME name under which to install [[samhain|yule]]],
1580 [
1581 if test "x${enableval}" != "xyes"; then
1582 install_name="${enableval}"
1583 INSTALL_NAME=`echo "${enableval}" | tr [a-z] [A-Z]`
1584 else
1585 install_name="${sh_main_prg}"
1586 INSTALL_NAME=`echo "${sh_main_prg}" | tr [a-z] [A-Z]`
1587 fi
1588 ],
1589 [
1590 install_name="${sh_main_prg}"
1591 INSTALL_NAME=`echo "${sh_main_prg}" | tr [a-z] [A-Z]`
1592 ]
1593)
1594
1595
1596need_user_install=0
1597
1598AC_ARG_ENABLE(identity,
1599 [ --enable-identity=USER user if dropping root [[daemon]]],
1600 [
1601 if test x"$enableval" = xno; then
1602 myident="daemon"
1603 else
1604 myident="$enableval"
1605 fi
1606 echo "${myident}" | grep ['[^0123456789]'] >/dev/null 2>&1 || \
1607 AC_MSG_ERROR([--enable-identity: need username, not UID])
1608 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1609 grep "^${myident}:" | awk -F: '{ print $3; }'`
1610 if test x"${myident_uid}" = x; then
1611 AC_MSG_WARN([--enable-identity: user ${myident} will be added upon install])
1612 need_user_install=1
1613 fi
1614 ],
1615 [
1616 for myident in ${install_name} daemon nobody; do
1617 AC_MSG_CHECKING(for user ${myident})
1618 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1619 grep "^${myident}:" | awk -F: '{ print $3; }'`
1620 if test x"${myident_uid}" != x; then
1621 AC_MSG_RESULT(yes)
1622 break;
1623 else
1624 AC_MSG_RESULT(no)
1625 fi
1626 done
1627 if test x"${myident_uid}" = x; then
1628 myident=${install_name}
1629 AC_MSG_WARN([--enable-identity: user ${myident} will be added upon install])
1630 need_user_install=1
1631 fi
1632 ])
1633AC_DEFINE_UNQUOTED(DEFAULT_IDENT, _("${myident}") )
1634AC_SUBST(myident)
1635AC_SUBST(need_user_install)
1636
1637sh_insmod_cmd=": # no kernel module"
1638sh_lkm=""
1639lkm_inc=""
1640khidemap="/boot/System.map"
1641sh_syscalltable="0x0"
1642AC_ARG_ENABLE(khide,
1643 [ --enable-khide=SYSTEM_MAP use kernel module to hide (Linux only)[[/boot/System.map]]],
1644 [
1645 if test "x${enable_khide}" != xno; then
1646 if test "x${enableval}" != "xyes"; then
1647 khidemap="${enableval}"
1648 fi
1649 sh_syscalltable=`egrep '(D|d|R|r) sys_call_table' ${khidemap} | awk '{print $1}'`
1650 if test x"$sh_syscalltable" = x; then
1651 AC_MSG_ERROR([--enable-khide: symbol sys_call_table not found in ${khidemap}])
1652 fi
1653 sh_syscalltable="0x${sh_syscalltable}"
1654 install_name_len=`echo ${install_name} | awk '{ print(length()); }'`
1655 if test "${install_name_len}" -gt 15 ; then
1656 AC_MSG_ERROR([--enable-khide: install_name exceeds 15 char length limit])
1657 fi
1658 AC_DEFINE(SH_USE_LKM)
1659 AC_DEFINE_UNQUOTED(SH_MAGIC_HIDE, "${install_name}")
1660
1661 # -- NEW --
1662 kernel_version=`uname -r | sed s,2.6.*,LINUX26,`
1663 if test x"$kernel_version" = xLINUX26
1664 then
1665 sh_modlist_lock=`egrep ['[bd] modlist_lock$'] ${khidemap} | awk '{print $1}'`
1666 if test x"$sh_modlist_lock" = x; then
1667 AC_MSG_ERROR([--enable-khide: symbol modlist_lock not found in ${khidemap}])
1668 fi
1669 sh_modlist_lock="0x${sh_modlist_lock}"
1670 AC_DEFINE_UNQUOTED(SH_MODLIST_LOCK, ${sh_modlist_lock}, [The address of the modules list spinlock])
1671
1672 sh_list_modules=`egrep 'd modules$' ${khidemap} | awk '{print $1}'`
1673 if test x"$sh_list_modules" = x; then
1674 AC_MSG_ERROR([--enable-khide: symbol modules not found in ${khidemap}])
1675 fi
1676 sh_list_modules="0x${sh_list_modules}"
1677 AC_DEFINE_UNQUOTED(SH_LIST_MODULES, ${sh_list_modules}, [The address of the modules list])
1678
1679 AC_DEFINE(LINUX26, 1, [Define if kernel is 2.6])
1680 sh_insmod_cmd="modprobe ${install_name}_hide"
1681 sh_lkm="samhain_hide.ko"
1682 else
1683 sh_insmod_cmd="insmod ${install_name}_hide; insmod ${install_name}_erase; rmmod ${install_name}_erase"
1684 sh_lkm="samhain_hide.o samhain_erase.o"
1685 fi
1686 # -- END NEW --
1687
1688 kvers=`uname -r`
1689 if test -f /lib/modules/${kvers}/build/include/linux/kernel.h; then
1690 lkm_inc="-I/lib/modules/${kvers}/build/include"
1691 else
1692 AC_MSG_WARN([--enable-khide: /lib/modules/${kvers}/build/include/linux not found])
1693 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])
1694 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])
1695 fi
1696 sh_is_vanilla_kernel=yes
1697 if test -f /lib/modules/${kvers}/build/include/linux/sched.h; then
1698 grep 'next_task,' /lib/modules/${kvers}/build/include/linux/sched.h >/dev/null 2>&1 || sh_is_vanilla_kernel=no
1699 fi
1700 if test x"${sh_is_vanilla_kernel}" = xno; then
1701 echo "This is not a 2.4 vanilla kernel"
1702 else
1703 AC_DEFINE(SH_VANILLA_KERNEL)
1704 fi
1705 fi
1706 ]
1707)
1708AC_SUBST(lkm_inc)
1709AC_SUBST(sh_lkm)
1710AC_SUBST(sh_insmod_cmd)
1711AC_SUBST(install_name)
1712AC_SUBST(INSTALL_NAME)
1713AC_SUBST(stegin_prg)
1714AC_SUBST(xor_code)
1715
1716AC_DEFINE_UNQUOTED(XOR_CODE, ${xor_code})
1717AC_DEFINE_UNQUOTED(SH_SYSCALLTABLE, ${sh_syscalltable})
1718
1719
1720exepack_state0=`${srcdir}/c_random.sh 2>/dev/null`
1721exepack_state1=`${srcdir}/c_random.sh 2>/dev/null`
1722exepack_state2=`${srcdir}/c_random.sh 2>/dev/null`
1723
1724AC_DEFINE_UNQUOTED(EXEPACK_STATE_0, ${exepack_state0})
1725AC_DEFINE_UNQUOTED(EXEPACK_STATE_1, ${exepack_state1})
1726AC_DEFINE_UNQUOTED(EXEPACK_STATE_2, ${exepack_state2})
1727
1728
1729AC_ARG_ENABLE(suidcheck,
1730 [ --enable-suidcheck check for suid/sgid files [[no]]],
1731 [
1732 if test "x${enableval}" = "xyes"; then
1733 AC_DEFINE(SH_USE_SUIDCHK)
1734 fi
1735 ]
1736)
1737
1738
1739systemmap="/boot/System.map"
1740sh_libkvm=""
1741AC_ARG_WITH(kcheck,
1742 [ --with-kcheck[[=SYSTEM_MAP]] check Linux/FreeBSD/OpenBSD kernel integrity [[/boot/System.map]]],
1743 [
1744 if test "x${withval}" != "xno"; then
1745 AC_DEFINE(SH_USE_KERN)
1746 kernelversion=`uname -r`
1747 AC_DEFINE_UNQUOTED(SH_KERNEL_VERSION, _("${kernelversion}"), [Define the kernel version])
1748 if test "x${withval}" != "xyes"; then
1749 systemmap="${withval}"
1750 fi
1751 if test "x${cross_compiling}" = xyes; then
1752 :
1753 elif test "x$selectconfig" = "xfreebsd"; then
1754 LIBS="$LIBS -lkvm"
1755 sh_libkvm="-lkvm"
1756 elif test -f "${systemmap}"; then
1757 :
1758 else
1759 AC_MSG_ERROR([--with-kcheck: cannot find system map ${systemmap}])
1760 fi
1761 fi
1762 ]
1763)
1764AC_SUBST(systemmap)
1765AC_SUBST(sh_libkvm)
1766
1767AC_ARG_ENABLE(base,
1768 [ --enable-base=B1,B2 base key (0...2147483647)],
1769 [
1770 AC_MSG_CHECKING(base key setting)
1771 my_key_A=`echo ${enableval} | awk 'BEGIN{FS=","}{print $1}'`
1772 my_key_B=`echo ${enableval} | awk 'BEGIN{FS=","}{print $2}'`
1773 AC_MSG_RESULT(${my_key_A} ${my_key_B})
1774 if test "x${my_key_A}" = x; then
1775 AC_MSG_ERROR([--enable-base: first base key has zero length])
1776 fi
1777 if test "x${my_key_B}" = x; then
1778 AC_MSG_ERROR([--enable-base: second base key has zero length])
1779 fi
1780 echo "${my_key_A}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1781 AC_MSG_ERROR([--enable-base: base key must be numeric in the range 0 to 2147483647])
1782 echo "${my_key_B}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1783 AC_MSG_ERROR([--enable-base: base key must be numeric in the range 0 to 2147483647])
1784 ],
1785 [
1786 AC_MSG_CHECKING(base key setting .. collecting entropy)
1787 my_key_1=`${srcdir}/c_random.sh 2>/dev/null`
1788 my_key_2=`${srcdir}/c_random.sh 2>/dev/null`
1789 my_key_3=`${srcdir}/c_random.sh 2>/dev/null`
1790 my_key_4=`${srcdir}/c_random.sh 2>/dev/null`
1791 my_key_A=`expr $my_key_1 \* 32767`
1792 my_key_A=`echo ${my_key_A} | sed 's%^0*%%g' 2>/dev/null`
1793 my_key_A=`expr $my_key_A \+ $my_key_2`
1794 my_key_B=`expr $my_key_3 \* 32767`
1795 my_key_B=`echo ${my_key_B} | sed 's%^0*%%g' 2>/dev/null`
1796 my_key_B=`expr $my_key_B \+ $my_key_4`
1797 AC_MSG_RESULT(${my_key_A} ${my_key_B})
1798 ]
1799 )
1800AC_SUBST(my_key_A)
1801AC_SUBST(my_key_B)
1802
1803dnl low bytes
1804my_key_1=`expr $my_key_A \% 65536`
1805dnl high bytes
1806my_key_2=`expr $my_key_A \/ 65536`
1807dnl low bytes
1808my_key_3=`expr $my_key_B \% 65536`
1809dnl high bytes
1810my_key_4=`expr $my_key_B \/ 65536`
1811
1812dnl echo ${my_key_1} ${my_key_2} ${my_key_3} ${my_key_4}
1813
1814dnl touch ./sh_MK.h
1815dnl echo "#ifndef SH_MK_H" >> ./sh_MK.h
1816dnl echo "#define SH_MK_H" >> ./sh_MK.h
1817dnl ${srcdir}/c_bits.sh ${my_key_1} MKB >> ./sh_MK.h
1818dnl ${srcdir}/c_bits.sh ${my_key_2} MKA >> ./sh_MK.h
1819dnl ${srcdir}/c_bits.sh ${my_key_3} MKC >> ./sh_MK.h
1820dnl ${srcdir}/c_bits.sh ${my_key_4} MKD >> ./sh_MK.h
1821dnl echo "#endif" >> ./sh_MK.h
1822AC_SUBST(my_key_1)
1823AC_SUBST(my_key_2)
1824AC_SUBST(my_key_3)
1825AC_SUBST(my_key_4)
1826
1827AC_MSG_CHECKING(key position)
1828pos_tf_1=`${srcdir}/c_random.sh 2>/dev/null`
1829pos_tf_2=`expr $pos_tf_1 \% 8`
1830pos_tf=`expr $pos_tf_2 + 1`
1831AC_MSG_RESULT(${pos_tf})
1832AC_DEFINE_UNQUOTED(POS_TF, ${pos_tf} )
1833
1834mykeybase=`echo ${my_key_A},${my_key_B}`
1835AC_DEFINE_UNQUOTED(DEFKEY, ${mykeybase} )
1836AC_SUBST(mykeybase)
1837
1838
1839dnl
1840dnl GPG/PGP options
1841dnl
1842
1843AC_ARG_WITH(gpg,
1844 [ --with-gpg=PATH use GnuPG to verify database/config [[no]]],
1845 [
1846 if test "x${withval}" != "xno"; then
1847 if test "x${cross_compiling}" = xyes; then
1848 mygpg="${withval}"
1849 else
1850 if test -f "${withval}"; then
1851 mygpg="${withval}"
1852 mychk0=`${withval} --load-extension tiger --print-md TIGER192 ${withval} 2>/dev/null`
1853 if test "x$?" != "x0"; then
1854 mychktest=no
1855 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
1856 if test x"${mychktest}" = xyes
1857 then
1858 :
1859 else
1860 if test -f ${sampre}
1861 then
1862 echo "use existing ${sampre} for gpg checksum"
1863 mychk0=`${sampre} -H ${withval} 2>/dev/null`
1864 if test "x$?" != "x0"; then
1865 :
1866 else
1867 mychk="${mychk0}"
1868 mychktest=yes
1869 fi
1870 fi
1871 fi
1872 done
1873 if test x${mychktest} = xno; then
1874 AC_MSG_WARN([--with-gpg: cannot determine TIGER192 checksum of ${withval}])
1875 echo "-------------------------------------------------------------"
1876 echo " Your gpg binary does not support the TIGER192 checksum, "
1877 echo " and I cannot find an existing samhain binary to use instead."
1878 echo " You can:"
1879 echo " (a) run make to compile a samhain binary, then repeat"
1880 echo " ./configure and make"
1881 echo " (b) ignore the failure. The checksum of the gpg binary"
1882 echo " will not get compiled in, thus allowing an attacker"
1883 echo " to replace gpg with a trojan and subverting the gpg"
1884 echo " signature verification of configure and database files."
1885 echo "-------------------------------------------------------------"
1886 fi
1887 else
1888 mychk="${mychk0}"
1889 fi
1890 else
1891 AC_MSG_WARN([--with-gpg: cannot find GnuPG PATH=${withval}])
1892 fi
1893 fi
1894 AC_DEFINE(WITH_GPG)
1895 AC_DEFINE_UNQUOTED(DEFAULT_GPG_PATH, _("${mygpg}") )
1896 AC_SUBST(mygpg)
1897 fi
1898 ]
1899)
1900
1901dnl AC_ARG_WITH(pgp,
1902dnl [ --with-pgp=PATH Use PGP to verify database/config (no).],
1903dnl [myppg="$withval"
1904dnl AC_DEFINE(WITH_PGP)
1905dnl AC_DEFINE_UNQUOTED(DEFAULT_PGP_PATH, _("${myppg}") )
1906dnl ])
1907
1908AC_ARG_WITH(checksum,
1909 [ --with-checksum=CHKSUM compile in gpg/pgp checksum [[yes]]],
1910 [
1911 if test "x${withval}" != "xno"; then
1912 if test "x${withval}" != "xyes"; then
1913 if test "x${mychk}" != "x"; then
1914 if test "x${mychk}" != "x${withval}"; then
1915 AC_MSG_WARN([--with-checksum: possible gpg CHKSUM problem])
1916 AC_MSG_WARN([--with-checksum: CHKSUM=${withval}])
1917 AC_MSG_WARN([--with-checksum: autodetected=${mychk}])
1918 fi
1919 fi
1920 mychk="${withval}"
1921 else
1922 if test "x${mychk}" = "x"; then
1923 AC_MSG_ERROR([--with-checksum: gpg CHKSUM not specified])
1924 fi
1925 fi
1926 AC_DEFINE(HAVE_GPG_CHECKSUM)
1927 AC_DEFINE_UNQUOTED(GPG_HASH, _("${mychk}") )
1928 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
1929 fi
1930 ],
1931 [
1932 if test "x${mygpg}" != "x"; then
1933 if test "x${mychk}" != "x"; then
1934 AC_DEFINE(HAVE_GPG_CHECKSUM)
1935 AC_DEFINE_UNQUOTED(GPG_HASH, _("${mychk}") )
1936 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
1937 fi
1938 fi
1939 ]
1940)
1941
1942AC_ARG_WITH(fp,
1943 [ --with-fp=FINGERPRINT compile in public key fingerprint [[no]]],
1944 [
1945 if test "x${withval}" != "xno"; then
1946 if test "x${withval}" != "xyes"; then
1947 withval0=`echo ${withval} | sed 's% %%g'`
1948 echo "${withval0}" | \
1949 grep ['[^0123456789abcdefABCDEF]'] >/dev/null 2>&1 &&
1950 AC_MSG_ERROR([--with-fp: invalid character(s) in FINGERPRINT=${withval0}])
1951 sh_len=`echo ${withval0} | wc -c | sed 's% %%g'`
1952 sh_len0=`expr ${sh_len} \- 1`
1953 if test "x${sh_len0}" = "x40" || test "x${sh_len0}" = "x32"
1954 then
1955 myfp="${withval0}"
1956 AC_DEFINE(USE_FINGERPRINT)
1957 AC_DEFINE_UNQUOTED(SH_GPG_FP, _("${myfp}") )
1958 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
1959 else
1960 AC_MSG_ERROR([--with-fp: length (${sh_len0}) of FINGERPRINT ${withval0} incorrect])
1961 fi
1962 else
1963 AC_MSG_ERROR([--with-fp: usage error ... FINGERPRINT=yes])
1964 fi
1965 fi
1966 ])
1967
1968
1969dnl
1970dnl MAIL OPTIONS
1971dnl
1972
1973AC_ARG_WITH(recipient,
1974 [ --with-recipient=ADDR set recipient(s) for e-mail [[none]]],
1975 [
1976 withval0=`echo ${withval} | sed 's%,% %g'`
1977 for sh_item in ${withval0}
1978 do
1979 case ${sh_item} in
1980 *@localhost)
1981 ;;
1982 *@*.*)
1983 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}}'`
1984 if test "x${sh_tmp}" != "x1"
1985 then
1986 AC_MSG_ERROR([--with-recipient: invalid mail address ${sh_item}])
1987 fi
1988 ;;
1989 *)
1990 AC_MSG_ERROR([--with-recipient: invalid mail address ${sh_item}])
1991 ;;
1992 esac
1993 done
1994 myrcp="$withval0"
1995 ],
1996 [myrcp="NULL"])
1997AC_DEFINE_UNQUOTED(DEFAULT_MAILADDRESS, _("${myrcp}") )
1998
1999
2000AC_ARG_WITH(sender,
2001 [ --with-sender=SENDER set sender for e-mail [[daemon]]],
2002 [
2003 mysender="${withval}"
2004 ],
2005 [
2006 mysender="daemon"
2007 ])
2008AC_DEFINE_UNQUOTED(DEFAULT_SENDER, _("${mysender}") )
2009
2010
2011dnl
2012dnl PATHS
2013dnl
2014
2015AC_ARG_WITH(trusted,
2016 [ --with-trusted=UID Set uid(s) of trusted users [[0]]],
2017 [
2018 sh_tmp_test=no
2019 sh_tmp=`echo ${withval} | sed 's%,% %g'`
2020 for sh_tmp1 in ${sh_tmp}
2021 do
2022 echo "${sh_tmp1}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2023 AC_MSG_ERROR([--with-trusted: non-numeric UID in ${withval}])
2024 if test "x${sh_tmp1}" = "x0"
2025 then
2026 sh_tmp_test=yes
2027 fi
2028 done
2029 if test "x${sh_tmp_test}" = "xno"
2030 then
2031 withval="0,${withval}"
2032 fi
2033 mytrust="${withval}"
2034 ],
2035 [mytrust="0"] )
2036AC_DEFINE_UNQUOTED(SL_ALWAYS_TRUSTED, ${mytrust} )
2037AC_SUBST(mytrust)
2038
2039AC_ARG_WITH(tmp-dir,
2040 [ --with-tmp-dir=PFX set directory for temporary files [[HOME]]],
2041 [
2042 if test "x${cross_compiling}" = xyes; then
2043 :
2044 else
2045 if test -d "${withval}"; then
2046 my_tmp_dir="$withval"
2047 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${my_tmp_dir}") )
2048 else
2049 AC_MSG_ERROR([--with-tmp-dir: tmp directory ${withval} does not exist])
2050 fi
2051 fi
2052 ]
2053)
2054
2055dnl
2056dnl PATH DEFAULTS
2057dnl
2058
2059if test "x${ac_prefix_set}" = xyes
2060then
2061 if test "x${exec_prefix}" = xNONE
2062 then
2063 exec_prefix="${prefix}"
2064 fi
2065
2066 if test "x${prefix}" = xOPT
2067 then
2068 tmp_sbindir="/opt/${install_name}/bin"
2069 tmp_sysconfdir="/etc/opt"
2070 tmp_mandir="/opt/${install_name}/man"
2071 tmp_localstatedir="/var/opt/${install_name}"
2072 elif test "x${prefix}" = xUSR
2073 then
2074 tmp_sbindir="/usr/sbin"
2075 tmp_sysconfdir="/etc"
2076 tmp_mandir="/usr/share/man"
2077 tmp_localstatedir="/var"
2078 else
2079 tmp_sbindir=`eval echo ${sbindir}`
2080 tmp_sysconfdir=`eval echo ${sysconfdir}`
2081 tmp_mandir=`eval echo ${mandir}`
2082 tmp_localstatedir=`eval echo ${localstatedir}`
2083 fi
2084else
2085 prefix=""
2086 if test "x${ac_exec_prefix_set}" = xyes
2087 then
2088 tmp_sbindir=`eval echo ${sbindir}`
2089 else
2090 tmp_sbindir="/usr/local/sbin"
2091 fi
2092 tmp_sysconfdir="/etc"
2093 # share/man -> man (FHS) 11.10.2002
2094 tmp_mandir="/usr/local/man"
2095 tmp_localstatedir="/var"
2096fi
2097
2098
2099if test "x${ac_sbindir_set}" = xyes
2100then
2101 :
2102else
2103 sbindir=`eval echo ${tmp_sbindir}`
2104fi
2105
2106
2107if test "x${ac_sysconfdir_set}" = xyes
2108then
2109 :
2110else
2111 sysconfdir=`eval echo ${tmp_sysconfdir}`
2112fi
2113
2114if test "x${ac_mandir_set}" = xyes
2115then
2116 :
2117else
2118 mandir=`eval echo ${tmp_mandir}`
2119fi
2120
2121if test "x${ac_localstatedir_set}" = xyes
2122then
2123 :
2124else
2125 localstatedir=`eval echo ${tmp_localstatedir}`
2126fi
2127
2128
2129
2130AC_ARG_WITH(config-file,
2131 [ --with-config-file=FILE configuration file [[/etc/{install_name}rc]]],
2132 [
2133 myconffile="${withval}"
2134 changequote(<<, >>)dnl
2135 tmp=`echo ${withval} | sed 's%^REQ_FROM_SERVER%%'`
2136 sysconfdir=`echo ${tmp} | sed 's%/[^/][^/]*$%%'`
2137 myrpmconffile="${tmp}"
2138 changequote([, ])dnl
2139 ],
2140 [
2141 myconffile="${sysconfdir}/${install_name}rc"
2142 myrpmconffile="${myconffile}"
2143 ]
2144)
2145AC_DEFINE_UNQUOTED(DEFAULT_CONFIGFILE, _("${myconffile}") )
2146AC_SUBST(myconffile)
2147AC_SUBST(myrpmconffile)
2148
2149AC_ARG_WITH(log-file,
2150 [ --with-log-file=FILE path of log file [[/var/log/{install_name}_log]]],
2151 [
2152 mylogfile="$withval"
2153 changequote(<<, >>)dnl
2154 mylogdir=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
2155 changequote([, ])dnl
2156 ],
2157 [
2158 if test "x${mytclient}" = "x-DSH_WITH_SERVER"; then
2159 mylogfile="${localstatedir}/log/${install_name}/${install_name}_log"
2160 mylogdir="${localstatedir}/log/${install_name}"
2161 else
2162 mylogfile="${localstatedir}/log/${install_name}_log"
2163 mylogdir="${localstatedir}/log"
2164 fi
2165 ]
2166)
2167AC_DEFINE_UNQUOTED(DEFAULT_ERRFILE, _("${mylogfile}") )
2168AC_DEFINE_UNQUOTED(DEFAULT_LOGDIR, _("${mylogdir}") )
2169AC_SUBST(mylogfile)
2170AC_SUBST(mylogdir)
2171
2172AC_ARG_WITH(pid-file,
2173 [ --with-pid-file=FILE set path of pid file [[/var/run/{install_name}.pid]]],
2174 [
2175 mylockfile="$withval"
2176 changequote(<<, >>)dnl
2177 mylockdir=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
2178 changequote([, ])dnl
2179 ],
2180 [
2181 mylockfile="${localstatedir}/run/${install_name}.pid"
2182 mylockdir="${localstatedir}/run"
2183 ]
2184)
2185AC_DEFINE_UNQUOTED(DEFAULT_ERRLOCK, _("${mylockfile}") )
2186AC_DEFINE_UNQUOTED(DEFAULT_PIDDIR, _("${mylockdir}") )
2187AC_SUBST(mylockfile)
2188AC_SUBST(mylockdir)
2189
2190AC_ARG_WITH(state-dir,
2191 [ --with-state-dir=PFX set state data directory [[/var/lib/{install_name}]]],
2192 [
2193 mydataroot="$withval"
2194 ],
2195 [
2196 mydataroot="${localstatedir}/lib/${install_name}"
2197 ]
2198 )
2199AC_ARG_WITH(data-file,
2200 [ --with-data-file=FILE set path of data file],
2201 [
2202 mydatafile="$withval"
2203 changequote(<<, >>)dnl
2204 tmp=`echo ${withval} | sed 's%^REQ_FROM_SERVER%%'`
2205 mydataroot=`echo ${tmp} | sed 's%/[^/][^/]*$%%'`
2206 myrpmdatafile="${tmp}"
2207 changequote([, ])dnl
2208 if test x"${tmp}" = x
2209 then
2210 echo "No local path in data file ${withval}"
2211 echo "This will not work for initializing the database."
2212 if test x"${withval}" = xREQ_FROM_SERVER
2213 then
2214 echo "It should be REQ_FROM_SERVER/some/local/path"
2215 fi
2216 AC_MSG_ERROR([--with-data-file: invalid path ${withval}])
2217 fi
2218 ],
2219 [
2220 mydatafile="${mydataroot}/${install_name}_file"
2221 myrpmdatafile="${mydatafile}"
2222 ])
2223AC_DEFINE_UNQUOTED(DEFAULT_DATA_FILE, _("${mydatafile}") )
2224AC_SUBST(mydatafile)
2225AC_SUBST(myrpmdatafile)
2226
2227AC_DEFINE_UNQUOTED(DEFAULT_DATAROOT, _("${mydataroot}") )
2228AC_SUBST(mydataroot)
2229
2230AC_DEFINE_UNQUOTED(DEFAULT_QDIR, _("${mydataroot}/.quarantine") )
2231AC_SUBST(myqdir)
2232
2233
2234AC_ARG_WITH(html-file,
2235 [ --with-html-file=FILE set path of html file,],
2236 [
2237 myhtmlfile="$withval"
2238 ],
2239 [
2240 myhtmlfile="${mylogdir}/${install_name}.html"
2241 ])
2242AC_DEFINE_UNQUOTED(DEFAULT_HTML_FILE, _("${myhtmlfile}") )
2243AC_SUBST(myhtmlfile)
2244
2245
2246mydefargs=$ac_configure_args
2247# if test -z "`echo "$mydefargs" | grep "\-\-enable\-static" 2> /dev/null`"
2248# then
2249# mydefargs="--enable-static $mydefargs"
2250# fi
2251if test -z "`echo "$mydefargs" | grep "\-\-enable\-base" 2> /dev/null`"
2252then
2253 mydefargs="--enable-base=${mykeybase} $mydefargs"
2254fi
2255AC_SUBST(mydefargs)
2256
2257
2258AC_DEFINE_UNQUOTED(SH_INSTALL_DIR, _("${sbindir}"))
2259AC_DEFINE_UNQUOTED(SH_INSTALL_PATH, _("${sbindir}/${install_name}"))
2260AC_DEFINE_UNQUOTED(SH_INSTALL_NAME, _("${install_name}"))
2261
2262AC_CONFIG_HEADER(config.h)
2263
2264AC_OUTPUT(
2265[
2266Makefile
2267samhain-install.sh
2268init/samhain.startLSB
2269init/samhain.startLinux
2270init/samhain.startGentoo
2271init/samhain.startFreeBSD
2272init/samhain.startSolaris
2273init/samhain.startHPUX
2274init/samhain.startIRIX
2275samhain.spec
2276rules.deb
2277rules.deb-light
2278hp_ux.psf
2279scripts/samhain.spec
2280scripts/redhat_i386.client.spec
2281scripts/samhain.ebuild
2282scripts/samhain.ebuild-light
2283scripts/samhainadmin.pl
2284scripts/check_samhain.pl
2285deploy.sh
2286],
2287[
2288echo timestamp > stamp-h
2289chmod +x samhain-install.sh
2290chmod +x scripts/samhainadmin.pl
2291chmod +x scripts/check_samhain.pl
2292]
2293)
2294
2295chmod +x deploy.sh
2296
2297if test "x${cross_compiling}" = xyes
2298then
2299
2300echo "--------------------------------------------------------------"
2301echo
2302echo "You are using a cross-compiler. The following system dependent"
2303echo "values may have been set to default values that may be"
2304echo "incorrect for your target system: "
2305echo
2306echo "ac_cv_c_bigendian bigendian byte order ${ac_cv_c_bigendian}"
2307echo "ac_cv_c_long_double long double exists ${ac_cv_c_long_double}"
2308echo "ac_cv_sizeof_char_p size of pointer to char ${ac_cv_sizeof_char_p}"
2309echo "ac_cv_sizeof_char_p size of size_t ${ac_cv_sizeof_size_t}"
2310echo "ac_cv_sizeof_unsigned_int_ size of unsigned int ${ac_cv_sizeof_unsigned_int_}"
2311echo "ac_cv_sizeof_unsigned_long size of unsigned long ${ac_cv_sizeof_unsigned_long}"
2312echo "ac_cv_sizeof_unsigned_short size of unsigned short ${ac_cv_sizeof_unsigned_short}"
2313echo
2314echo "If these values are incorrect, change them in the file "
2315echo "config.cache and run configure again."
2316echo
2317echo "--------------------------------------------------------------"
2318
2319fi
2320
2321if test x${silent} != xyes
2322then
2323
2324 # A=`eval echo ${sbindir}` ; A=`eval echo ${A}`
2325 # B=`eval echo ${myconffile}` ; B=`eval echo ${B}`
2326 # C=`eval echo ${mandir}` ; C=`eval echo ${C}`
2327 # D=`eval echo ${mylockfile}` ; D=`eval echo ${D}`
2328 # E=`eval echo ${mylogfile}` ; E=`eval echo ${E}`
2329 # F=`eval echo ${mydataroot}` ; F=`eval echo ${F}`
2330
2331 echo
2332 echo " samhain has been configured as follows:"
2333 echo " System binaries: ${sbindir}"
2334 echo " Configuration file: ${myconffile}"
2335 echo " Manual pages: ${mandir}"
2336 echo " Data: ${mydataroot}"
2337 echo " PID file: ${mylockfile}"
2338 echo " Log file: ${mylogfile}"
2339 echo " Base key: ${mykeybase}"
2340 echo
2341 if test x"$mytclient" = x"-DSH_WITH_SERVER"
2342 then
2343 echo " Selected rc file: yulerc"
2344 else
2345 echo " Selected rc file: samhainrc.${selectconfig}"
2346 fi
2347
2348fi
2349
Note: See TracBrowser for help on using the repository browser.