source: trunk/configure.ac@ 418

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

Fixes for tickets #314, #315, #316, #317, #318, #319, #320, and #321.

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