source: trunk/configure.ac@ 323

Last change on this file since 323 was 323, checked in by katerina, 14 years ago

Fix for ticket #242 (Compile error on FreeBSD) and #241 (deploy.sh documentation)

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