source: trunk/configure.ac@ 422

Last change on this file since 422 was 422, checked in by katerina, 12 years ago

Fix for tickets #326, #327.

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