source: trunk/configure.ac@ 211

Last change on this file since 211 was 210, checked in by katerina, 16 years ago

Fix for ticket #136 (compile error); also enhance testsuite to catch compiler warnings.

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