source: trunk/configure.ac@ 383

Last change on this file since 383 was 383, checked in by katerina, 13 years ago

Fix for ticket #281 (warnings from clang static analyzer).

File size: 77.6 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.1)
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 *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 fnmatch.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(shellexpand,
793 [ --disable-shellexpand disable shell expansion in config file],
794 [
795 if test "x${enable_shellexpand}" = xno; then
796 :
797 else
798 AC_DEFINE(SH_EVAL_SHELL, [1], [Define if you want shell expansion in configuration file])
799 fi
800 ],
801 [AC_DEFINE(SH_EVAL_SHELL, [1], [Define if you want shell expansion in configuration file])]
802)
803
804AC_ARG_ENABLE(external-scripts,
805 [ --disable-external-scripts disable interface to external scripts],
806 [
807 if test "x${enableval}" = xno; then
808 :
809 else
810 AC_DEFINE(WITH_EXTERNAL)
811 fi
812 ],
813 [AC_DEFINE(WITH_EXTERNAL)]
814)
815
816AC_ARG_ENABLE(message-queue,
817 [ --enable-message-queue[[=MODE]] enable SysV message queue [[MODE=0700]]],
818 [
819 if test "x${ac_cv_header_sys_msg_h}" = "xyes"; then
820 if test "x${enable_message_queue}" = xyes; then
821 AC_DEFINE(WITH_MESSAGE_QUEUE)
822 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, 0700)
823 elif test "x${enable_message_queue}" != xno; then
824 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
825 AC_MSG_ERROR([With --enable-message-queue=MODE, MODE must be numeric])
826 echo "${enableval}" | \
827 grep ['0[0123456789][0123456789][0123456789]'] >/dev/null 2>&1 ||
828 AC_MSG_ERROR([With --enable-message-queue=MODE, MODE must be an octal (0nnn) number])
829 AC_DEFINE(WITH_MESSAGE_QUEUE)
830 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, ${enable_message_queue})
831 fi
832 else
833 echo
834 echo "**********************************************"
835 echo
836 AC_MSG_WARN([sys/msg.h missing, --enable-message-queue disabled])
837 echo
838 echo "**********************************************"
839 echo
840 fi
841 ]
842)
843
844AC_ARG_WITH(cflags,
845 [ --with-cflags additional flags to pass to compiler],
846 [
847 if test "x$withval" != "xno" ; then
848 CFLAGS="$CFLAGS $withval"
849 fi
850 ]
851)
852AC_ARG_WITH(libs,
853 [ --with-libs additional libraries to link with],
854 [
855 if test "x$withval" != "xno" ; then
856 LIBS="$LIBS $withval"
857 fi
858 ]
859)
860
861
862#
863# this is from ssh
864#
865AC_MSG_CHECKING(whether to use libwrap)
866LIBWRAP_LIB=""
867LIBWRAP_INC=""
868AC_ARG_WITH(libwrap,
869[ --with-libwrap[=PATH] Compile in libwrap (TCP Wrappers) support],
870[ AC_MSG_RESULT($withval)
871 case "$withval" in
872 no)
873 ;;
874 ""|yes)
875 LIBWRAP_LIB="-lwrap"
876 ;;
877 *)
878 if test -d "$withval"; then
879 LIBWRAP_LIB="-L$withval -lwrap"
880 changequote(<<, >>)dnl
881 sh_libwrap_inc=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
882 LIBWRAP_INC="-I${sh_libwrap_inc}/include"
883 changequote([, ])dnl
884 else
885 LIBWRAP_LIB="-lwrap"
886 changequote(<<, >>)dnl
887 sh_libwrap_inc=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
888 LIBWRAP_INC="-I${sh_libwrap_inc}"
889 changequote([, ])dnl
890 fi
891 ;;
892 esac
893 if test -n "$LIBWRAP_LIB"; then
894 # OLDLIBS="$LIBS"
895 LIBS="$LIBWRAP_LIB $LIBS"
896 # OLDCFLAGS="$CFLAGS"
897 CFLAGS="$CFLAGS $LIBWRAP_INC"
898 AC_CHECK_HEADER(tcpd.h,
899 [],
900 [ AC_MSG_ERROR([Could not find tcpd.h for libwrap. You need to install tcp_wrappers.]) ])
901 AC_TRY_LINK([ #include <tcpd.h>
902 int allow_severity; int deny_severity; ],
903 [ hosts_access((struct request_info *) 0); ],
904 [ AC_DEFINE(SH_USE_LIBWRAP,1,[Build with tcp wrapper support]) ],
905 [ AC_MSG_ERROR([Could not find the libwrap library.]) ])
906 fi ],
907 AC_MSG_RESULT(no)
908)
909
910
911dnl
912dnl NETWORK OPTIONS
913dnl
914AC_ARG_ENABLE(network,
915 [ --enable-network=[[client|server]] compile client or server [[no]]],
916 [
917 if test "x$enable_network" = xclient; then
918 mytclient="-DSH_WITH_CLIENT"
919 yulectl_prg=
920 setpwd_prg="samhain_setpwd"
921 sh_main_prg="samhain"
922 if test "x${sh_have_gmp}" = xyes
923 then
924 LIBS="-lgmp $LIBS"
925 fi
926dnl AC_CHECK_HEADER(sys/capability.h,
927dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
928dnl [sh_use_lcaps="no"])
929 elif test "x$enable_network" = xserver; then
930 mytclient="-DSH_WITH_SERVER"
931 yulectl_prg="yulectl"
932 setpwd_prg="samhain_setpwd"
933 sh_main_prg="yule"
934 if test "x${sh_have_gmp}" = xyes
935 then
936 LIBS="-lgmp $LIBS"
937 fi
938 sh_use_lcaps="undef"
939 elif test "x$enable_network" = xno; then
940 mytclient="-DSH_STANDALONE"
941 yulectl_prg=
942 setpwd_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 else
948 AC_MSG_ERROR([With --enable-network=WHAT, WHAT must be client, server, or no])
949 fi
950 ],
951 [
952 mytclient="-DSH_STANDALONE"
953 setpwd_prg=
954 yulectl_prg=
955 sh_main_prg="samhain"
956dnl AC_CHECK_HEADER(sys/capability.h,
957dnl [AC_CHECK_LIB(cap, cap_get_proc,,sh_use_lcaps="no")],
958dnl [sh_use_lcaps="no"])
959 ],
960)
961
962AC_SUBST(setpwd_prg)
963AC_SUBST(yulectl_prg)
964AC_SUBST(sh_main_prg)
965AC_SUBST(mytclient)
966
967# needed for the rpm spec
968clmytclient=`echo ${mytclient} | sed s%\-%%`
969AC_SUBST(clmytclient)
970
971sh_no_gcc_static=no
972
973AC_ARG_ENABLE(static,
974 [ --enable-static enable static linking [[no]]],
975 [
976 if test x$enable_static = xyes; then
977 if test x"$mynetbsd" = xyes
978 then
979 tmp_LIBS=`echo $LIBS | sed 's%\-lresolv%%' `
980 LIBS="${tmp_LIBS}"
981 fi
982 if test x"${sh_auparse}" = xyes
983 then
984 tmp_LIBS=`echo $LIBS | sed 's%\-lauparse%%' `
985 LIBS="${tmp_LIBS}"
986 fi
987 AC_DEFINE(SH_COMPILE_STATIC, 1, [Define if compiling static])
988 if test "x$GCC" = "xyes"; then
989 sh_no_gcc_static=no
990 LDFLAGS="$LDFLAGS -static"
991 else
992 sh_no_gcc_static=yes
993 case "$host_os" in
994
995 *aix*)
996 LDFLAGS="$LDFLAGS -bnso -bI:/lib/syscalls.exp"
997 ;;
998
999 *hpux*)
1000 LDFLAGS="$LDFLAGS -Wl,-a,archive"
1001 ;;
1002
1003 *osf*)
1004 LDFLAGS="$LDFLAGS -non_shared"
1005 ;;
1006
1007 *irix*)
1008 LDFLAGS="$LDFLAGS -non_shared"
1009 ;;
1010
1011 *sco*)
1012 LDFLAGS="$LDFLAGS -dn"
1013 ;;
1014
1015 *sun*)
1016 LDFLAGS="$LDFLAGS -Bstatic"
1017 ;;
1018
1019 *solaris*)
1020 LDFLAGS="$LDFLAGS -Bstatic"
1021 ;;
1022
1023 *)
1024 echo "***********************************************"
1025 echo "*"
1026 echo "* Don't know how to enable static linking"
1027 echo "* with your compiler. Please set the environment"
1028 echo "* variable LDFLAGS to:"
1029 echo "* ${LDFLAGS} + the static linking flag"
1030 echo "* and run configure again"
1031 echo "*"
1032 echo "***********************************************"
1033 ;;
1034
1035 esac
1036 fi
1037 fi
1038 ]
1039)
1040
1041if test x"${mytclient}" = x-DSH_STANDALONE -o x"${mytclient}" = x-DSH_WITH_CLIENT;
1042then
1043dnl For threaded modules
1044 ACX_PTHREAD
1045 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1046 LIBS="$PTHREAD_LIBS $LIBS"
1047 LDFLAGS="$PTHREAD_CFLAGS $LDFLAGS"
1048 CC="$PTHREAD_CC"
1049dnl For MODI_TXT
1050 CHECK_ZLIB()
1051fi
1052
1053if test x$enable_static = xyes; then
1054 :
1055else
1056 if test x$sh_use_pie = xyes; then
1057 LDFLAGS="$LDFLAGS $PIE_LDFLAGS"
1058 CFLAGS="$CFLAGS $PIE_CFLAGS"
1059 fi
1060fi
1061
1062
1063#
1064# this is from the snort configure.in
1065#
1066AC_DEFUN(FAIL_MESSAGE,[
1067 echo
1068 echo
1069 echo "**********************************************"
1070 echo " ERROR: unable to find" $1
1071 echo " checked in the following places"
1072 for i in `echo $2`; do
1073 echo " $i"
1074 done
1075 echo "**********************************************"
1076 echo
1077 exit
1078])
1079
1080AC_ARG_WITH(libprelude-prefix,
1081 [ --with-libprelude-prefix=PFX Prefix where libprelude is installed (optional)],
1082 libprelude_config_prefix="$withval", libprelude_config_prefix="")
1083
1084AC_MSG_CHECKING(whether to use prelude)
1085AC_ARG_WITH(prelude,
1086 [ --with-prelude Prelude IDS support [[no]]],
1087 [
1088 if test "x${withval}" = "xno"; then
1089 AC_MSG_RESULT(no)
1090 else
1091 AC_MSG_RESULT(yes)
1092 if test x$libprelude_config_prefix != x ; then
1093 if test x${LIBPRELUDE_CONFIG+set} != xset ; then
1094 LIBPRELUDE_CONFIG=$libprelude_config_prefix/bin/libprelude-config
1095 fi
1096 fi
1097
1098 AC_PATH_PROG(LIBPRELUDE_CONFIG, libprelude-config, no)
1099 if test x"$LIBPRELUDE_CONFIG" = "xno" ; then
1100 HAVE_PRELUDE_CONFIG=no
1101 else
1102 HAVE_PRELUDE_CONFIG=yes
1103 fi
1104dnl AC_CHECK_PROG(HAVE_PRELUDE_CONFIG, libprelude-config, yes, no)
1105 if test "$HAVE_PRELUDE_CONFIG" = "yes"; then
1106 sh_libprelude_version=`$LIBPRELUDE_CONFIG --version`
1107 case "$sh_libprelude_version" in
1108 0.8*)
1109 AC_MSG_ERROR([You have Libprelude 0.8, which is too old. Version 0.9.6 or higher is required.])
1110 ;;
1111 *)
1112 AM_PATH_LIBPRELUDE([0.9.6],
1113 [
1114 AC_DEFINE(HAVE_LIBPRELUDE,1,[Have libprelude])
1115 CFLAGS="$CFLAGS $LIBPRELUDE_PTHREAD_CFLAGS"
1116 LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS"
1117 LIBS="$LIBS $LIBPRELUDE_LIBS"
1118 ],
1119 [
1120 AC_MSG_ERROR([Could not find libprelude (if you are using --enable-static, the static library libprelude.a might be missing).])
1121 ])
1122 ;;
1123 esac
1124 else
1125 AC_MSG_ERROR([Could not find libprelude-config.])
1126 fi
1127 fi
1128 ],
1129 [
1130 AC_MSG_RESULT(no)
1131 ]
1132)
1133
1134#
1135# partly based on the snort configure.in
1136#
1137AC_ARG_WITH(database,
1138 [ --with-database=[[mysql|postgresql|oracle|odbc]] database support [[no]]],
1139 [
1140 if test x"$enable_xml_log" != xyes; then
1141 AC_MSG_ERROR([With --with-database, --enable-xml-log is required as well.])
1142 fi
1143 if test "x${withval}" = "xmysql"; then
1144 if test "x$zlib_found" = "x"
1145 then
1146 CHECK_ZLIB()
1147 fi
1148 AC_CHECK_PROG(HAVE_MYSQL_CONFIG, mysql_config, yes, no)
1149 if test "$HAVE_MYSQL_CONFIG" = "yes"; then
1150 sh_mysql_libs="`mysql_config --libs`"
1151 sh_mysql_libs="`eval echo ${sh_mysql_libs}`"
1152 LIBS="$LIBS ${sh_mysql_libs}"
1153 sh_mysql_cflags="`mysql_config --cflags`"
1154 sh_mysql_cflags="`eval echo ${sh_mysql_cflags}`"
1155 CPPFLAGS="$CPPFLAGS ${sh_mysql_cflags}"
1156 else
1157 AC_MSG_CHECKING([for MySQL in /usr /usr/local /usr/local/mysql MYSQL_HOME])
1158 mysql_directory="/usr /usr/local /usr/local/mysql ${MYSQL_HOME}"
1159
1160 for i in $mysql_directory; do
1161 if test -r $i/include/mysql/mysql.h; then
1162 MYSQL_DIR=$i
1163 MYSQL_INC_DIR=$i/include
1164 # we use AC_CHECK_HEADERS to check for mysql/mysql.h
1165 fi
1166 done
1167 if test -z "$MYSQL_DIR"; then
1168 for i in $mysql_directory; do
1169 if test -r $i/include/mysql.h; then
1170 MYSQL_DIR=$i
1171 MYSQL_INC_DIR=$i/include
1172 fi
1173 done
1174 fi
1175
1176 if test -z "$MYSQL_DIR"; then
1177 tmp=""
1178 for i in $mysql_directory; do
1179 tmp="$tmp $i/include $i/include/mysql"
1180 done
1181 FAIL_MESSAGE("mysql headers (mysql.h)", $tmp)
1182 fi
1183
1184 for i in lib lib/mysql; do
1185 str="$MYSQL_DIR/$i/libmysqlclient.*"
1186 for j in `echo $str`; do
1187 if test -r $j; then
1188 MYSQL_LIB_DIR="$MYSQL_DIR/$i"
1189 break 2
1190 fi
1191 done
1192 done
1193
1194 if test -z "$MYSQL_LIB_DIR"; then
1195 for ff in $mysql_directory; do
1196 for i in lib lib/mysql; do
1197 str="$ff/$i/libmysqlclient.*"
1198 for j in `echo $str`; do
1199 if test -r $j; then
1200 MYSQL_LIB_DIR="$ff/$i"
1201 break 3
1202 fi
1203 done
1204 done
1205 done
1206 fi
1207
1208 if test -z "$MYSQL_LIB_DIR"; then
1209 tmp=""
1210 for i in $mysql_directory; do
1211 tmp="$i/lib $i/lib/mysql"
1212 done
1213 FAIL_MESSAGE("mysql library libmysqlclient", $tmp)
1214 fi
1215
1216 AC_MSG_RESULT(yes)
1217 LIBS="$LIBS -L${MYSQL_LIB_DIR} -lmysqlclient"
1218 # CFLAGS="$CFLAGS -I${MYSQL_INC_DIR}"
1219 CPPFLAGS="$CPPFLAGS -I${MYSQL_INC_DIR}"
1220 fi
1221 AC_DEFINE(WITH_MYSQL)
1222 AC_DEFINE(WITH_DATABASE)
1223 if test "x$zlib_found" = "xyes"
1224 then
1225 LIBS="$LIBS -lz -lm"
1226 else
1227 echo
1228
1229 echo " Mysql library was not found or not useable."
1230 echo " Possible reasons include:"
1231 echo " - an old, incompatible version compiled from source"
1232 echo " - on Solaris, libmysql is compiled with the Solaris"
1233 echo " compiler, thus the mysql_config script provides"
1234 echo " compiler options unsuitable for gcc (move"
1235 echo " mysql_config out of your PATH)"
1236 echo " For other problems, check config.log for the error"
1237 echo " message from the compiler."
1238 echo
1239 echo " If your mysql libraries are installed in an"
1240 echo " unusual place, use --with-libs=-L/path/to/libdirectory"
1241 echo " where libdirectory is the directory holding libmysql."
1242 if test x"$enable_static" = xyes; then
1243 echo " Note that for compiling a static binary, you need"
1244 echo " the static libraries, rather than the shared ones."
1245 fi
1246 echo
1247 AC_MSG_ERROR([Could not find libmysql, or it is not useable.])
1248 fi
1249 AC_CHECK_HEADERS(mysql/mysql.h)
1250 elif test "x${withval}" = "xpostgresql"; then
1251 AC_DEFINE(WITH_POSTGRES)
1252 AC_DEFINE(WITH_DATABASE)
1253 #
1254 PGCONF="no"
1255 MY_PATH="${PATH}:/usr/local/bin:/usr/local/pgsql/bin"
1256 OLD_IFS="$IFS"
1257 IFS=":"
1258 for ff in ${MY_PATH}
1259 do
1260 if test -f "$ff/pg_config"
1261 then
1262 PGCONF="$ff/pg_config"
1263 fi
1264 done
1265 IFS="${OLD_IFS}"
1266 #
1267 #
1268 if test "x${PGCONF}" = "xno"
1269 then
1270 AC_MSG_CHECKING(for PostgreSQL in /usr/local/pgsql /usr/pgsql /usr/local /usr PGSQL_HOME)
1271 pgsql_directory="/usr/local/pgsql /usr/pgsql /usr/local /usr ${PGSQL_HOME}"
1272 for i in $pgsql_directory; do
1273 if test -r $i/include/pgsql/libpq-fe.h; then
1274 PGSQL_INC_DIR=$i/include
1275 PGSQL_DIR=$i
1276 # use AC_CHECK_HEADERS to check for pgsql/libpq-fe.h
1277 fi
1278 done
1279 if test -z "$PGSQL_DIR"; then
1280 for i in $pgsql_directory; do
1281 if test -r $i/include/postgresql/libpq-fe.h; then
1282 PGSQL_INC_DIR=$i/include
1283 PGSQL_DIR=$i
1284 fi
1285 done
1286 fi
1287 if test -z "$PGSQL_DIR"; then
1288 for i in $pgsql_directory; do
1289 if test -r $i/include/libpq-fe.h; then
1290 PGSQL_INC_DIR=$i/include
1291 PGSQL_DIR=$i
1292 fi
1293 done
1294 fi
1295
1296 if test -z "$PGSQL_DIR"; then
1297 tmp=""
1298 for i in $pgsql_directory; do
1299 tmp="$tmp $i/include $i/include/pgsql $i/include/postgresql"
1300 done
1301 FAIL_MESSAGE("PostgreSQL header file (libpq-fe.h)", $tmp)
1302 fi
1303
1304 for i in lib lib/pgsql lib/postgresql; do
1305 str="$PGSQL_DIR/$i/libpq.*"
1306 for j in `echo $str`; do
1307 if test -r $j; then
1308 PGSQL_LIB_DIR="$PGSQL_DIR/$i"
1309 break 2
1310 fi
1311 done
1312 done
1313
1314 if test -z "$PGSQL_LIB_DIR"; then
1315 for ff in $pgsql_directory; do
1316 for i in lib lib/pgsql lib/postgresql; do
1317 str="$ff/$i/libpq.*"
1318 for j in `echo $str`; do
1319 if test -r $j; then
1320 PGSQL_LIB_DIR="$ff/$i"
1321 break 3
1322 fi
1323 done
1324 done
1325 done
1326 fi
1327
1328 if test -z "$PGSQL_LIB_DIR"; then
1329 tmp=""
1330 for i in $pgsql_directory; do
1331 tmp="$i/lib $i/lib/pgsql $i/lib/postgresql"
1332 done
1333 FAIL_MESSAGE("postgresql library libpq", $tmp)
1334 fi
1335
1336 AC_MSG_RESULT(yes)
1337
1338 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lm"
1339 if test x"$enable_static" = xyes; then
1340 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lcrypt -lm"
1341 else
1342 LIBS="$LIBS -L${PGSQL_LIB_DIR} -lpq -lm"
1343 fi
1344 # CFLAGS="$CFLAGS -I${PGSQL_INC_DIR}"
1345 CPPFLAGS="$CPPFLAGS -I${PGSQL_INC_DIR}"
1346 AC_CHECK_HEADERS(pgsql/libpq-fe.h)
1347 AC_CHECK_HEADERS(postgresql/libpq-fe.h)
1348 else
1349 pg_lib_dir=`${PGCONF} --libdir`
1350 if test x"$enable_static" = xyes; then
1351 LIBS="$LIBS -L${pg_lib_dir} -lpq -lcrypt -lm"
1352 else
1353 LIBS="$LIBS -L${pg_lib_dir} -lpq -lm"
1354 fi
1355 pg_inc_dir=`${PGCONF} --includedir`
1356 # CFLAGS="$CFLAGS -I${pg_inc_dir}"
1357 CPPFLAGS="$CPPFLAGS -I${pg_inc_dir}"
1358 fi
1359 elif test "x${withval}" = "xodbc"; then
1360 AC_MSG_CHECKING(for odbc in /usr /usr/local ODBC_HOME)
1361 odbc_directory="/usr /usr/local"
1362
1363 for i in $odbc_directory; do
1364 if test -r $i/include/sql.h; then
1365 if test -r $i/include/sqlext.h; then
1366 if test -r $i/include/sqltypes.h; then
1367 ODBC_DIR=$i
1368 ODBC_INC_DIR=$i/include
1369 fi
1370 fi
1371 fi
1372 done
1373
1374 if test -z "$ODBC_DIR"; then
1375 tmp=""
1376 for i in $odbc_directory; do
1377 tmp="$tmp $i/include"
1378 done
1379 FAIL_MESSAGE("odbc headers (sql.h sqlext.h sqltypes.h)", $tmp)
1380 fi
1381
1382 str="$ODBC_DIR/lib/libodbc.*"
1383 for j in `echo $str`; do
1384 if test -r $j; then
1385 ODBC_LIB_DIR="$ODBC_DIR/lib"
1386 ODBC_LIB="odbc"
1387 fi
1388 done
1389
1390 if test -z "$ODBC_LIB_DIR"; then
1391 FAIL_MESSAGE("odbc library (libodbc)", "$ODBC_DIR/lib")
1392 fi
1393
1394 AC_MSG_RESULT(yes)
1395 CPPFLAGS="${CPPFLAGS} -I${ODBC_INC_DIR}"
1396 LIBS="${LIBS} -L${ODBC_LIB_DIR} -l$ODBC_LIB"
1397 AC_DEFINE(WITH_ODBC)
1398 AC_DEFINE(WITH_DATABASE)
1399
1400 elif test "x${withval}" = "xoracle"; then
1401 AC_MSG_CHECKING(for oracle in /usr /usr/local ORACLE_HOME)
1402 oracle_directory="/usr /usr/local ${ORACLE_HOME}"
1403 for i in $oracle_directory; do
1404 if test -r $i/rdbms/demo/oci.h; then
1405 ORACLE_DIR=$i
1406 fi
1407 done
1408
1409 if test -z "$ORACLE_DIR"; then
1410 tmp=""
1411 for i in $oracle_directory; do
1412 tmp="$tmp $i/rdbms/demo"
1413 done
1414 FAIL_MESSAGE("OCI header file (oci.h)", $tmp)
1415 else
1416 for i in rdbms/demo rdbms/public network/public; do
1417 ORACLE_CPP_FLAGS="$ORACLE_CPP_FLAGS -I$ORACLE_DIR/$i"
1418 done
1419 ORACLE_LIB_DIR="$ORACLE_DIR/lib"
1420 AC_MSG_RESULT(yes)
1421
1422 CPPFLAGS="${CPPFLAGS} ${ORACLE_CPP_FLAGS}"
1423
1424 ORACLE_LIBS="-lclntsh"
1425 if test -r $ORACLE_LIB_DIR/libwtc9.so; then
1426 ORACLE_LIBS="${ORACLE_LIBS} -lwtc9"
1427 elif test -r $ORACLE_LIB_DIR/libwtc8.so; then
1428 ORACLE_LIBS="${ORACLE_LIBS} -lwtc8"
1429 fi
1430 LIBS="${LIBS} -L${ORACLE_LIB_DIR} ${ORACLE_LIBS}"
1431 if test "x$GCC" != "xyes"; then
1432 CFLAGS="${CFLAGS} -fno-strict-aliasing"
1433 fi
1434 fi
1435 AC_DEFINE(WITH_ORACLE)
1436 AC_DEFINE(WITH_DATABASE)
1437
1438 else
1439 AC_MSG_ERROR([Option --with-database=database used with unsupported database ${withval}])
1440 fi
1441 ]
1442)
1443
1444AC_ARG_WITH(console,
1445 [ --with-console=PATH set path to console device [[/dev/console]]],
1446 [
1447 if test "x${withval}" != xno; then
1448 mycons="$withval"
1449 AC_DEFINE_UNQUOTED(DEFAULT_CONSOLE, _("${mycons}") )
1450 fi
1451 ])
1452
1453AC_ARG_WITH(altconsole,
1454 [ --with-altconsole=PATH set path to second console device [[none]]],
1455 [
1456 if test "x${withval}" != xno; then
1457 myaltcons="$withval"
1458 else
1459 myaltcons="NULL"
1460 fi
1461 ],
1462 [myaltcons="NULL"])
1463AC_DEFINE_UNQUOTED(ALT_CONSOLE, _("${myaltcons}") )
1464
1465AC_ARG_WITH(timeserver,
1466 [ --with-timeserver=HOST set host address for time server [[none]]],
1467 [
1468 if test "x${withval}" != xno; then
1469 mytimeserv="$withval"
1470 AC_DEFINE(HAVE_NTIME)
1471 else
1472 mytimeserv="NULL"
1473 fi
1474 ],
1475 mytimeserv="NULL")
1476AC_DEFINE_UNQUOTED(DEFAULT_TIMESERVER, _("${mytimeserv}") )
1477
1478AC_ARG_WITH(alttimeserver,
1479 [ --with-alttimeserver=HOST set address for backup time server [[none]]],
1480 [
1481 if test "x${withval}" != xno; then
1482 myalttimeserv="$withval"
1483 AC_DEFINE(HAVE_NTIME)
1484 else
1485 myalttimeserv="NULL"
1486 fi
1487 ],
1488 myalttimeserv="NULL")
1489AC_DEFINE_UNQUOTED(ALT_TIMESERVER, _("${myalttimeserv}") )
1490
1491AC_ARG_ENABLE(login-watch,
1492 [ --enable-login-watch watch for login/logout [[no]]],
1493 [
1494 if test "x${enable_login_watch}" = xyes; then
1495 AC_DEFINE(SH_USE_UTMP)
1496 fi
1497 ]
1498)
1499
1500AC_ARG_ENABLE(mounts-check,
1501 [ --enable-mounts-check check mount options on filesystems [[no]]],
1502 [
1503 if test "x${enable_mounts_check}" = xyes; then
1504 AC_DEFINE(SH_USE_MOUNTS)
1505 fi
1506 ]
1507)
1508
1509AC_ARG_ENABLE(logfile-monitor,
1510 [ --enable-logfile-monitor monitor logfiles [[no]]],
1511 [
1512 if test "x${enable_logfile_monitor}" = xyes; then
1513 AC_CHECK_HEADER(pcre.h,
1514 [
1515 AC_DEFINE(USE_LOGFILE_MONITOR, 1, [Define if you want the logfile monitor module.])
1516 LIBS="-lpcre $LIBS"
1517 ],
1518 [
1519 AC_CHECK_HEADER(pcre/pcre.h,
1520 [
1521 AC_DEFINE(USE_LOGFILE_MONITOR, 1, [Define if you want the logfile monitor module.])
1522 AC_DEFINE(HAVE_PCRE_PCRE_H, 1, [Define if you have pcre/pcre.h.])
1523 LIBS="-lpcre $LIBS"
1524 ],
1525 AC_MSG_ERROR([The --enable-logfile-monitor option requires libpcre. For compiling the pcre development package is needed.])
1526 )
1527 ]
1528 )
1529 AC_CHECK_LIB(pcre, pcre_dfa_exec, [
1530 AC_DEFINE([HAVE_PCRE_DFA_EXEC], 1, [Define if you have pcre_dfa_exec])
1531 ], [
1532 AC_MSG_WARN([pcre_dfa_exec not available])
1533 ])
1534 fi
1535 ]
1536)
1537
1538
1539AC_ARG_ENABLE(process-check,
1540 [ --enable-process-check check processes [[no]]],
1541 [
1542 if test "x${enable_process_check}" = xyes; then
1543 AC_CHECK_LIB([rt], [sched_getparam], sh_lrt=yes, sh_lrt=no)
1544 if test x"$sh_lrt" = xyes; then
1545 LIBRT=-lrt
1546 else
1547 LIBRT=
1548 fi
1549 LIBS="$LIBS $LIBRT"
1550 AC_DEFINE(SH_USE_PROCESSCHECK, [1], [Define if you want to check processes])
1551 fi
1552 ]
1553)
1554
1555AC_ARG_ENABLE(port-check,
1556 [ --enable-port-check check ports [[no]]],
1557 [
1558 if test "x${enable_port_check}" = xyes; then
1559 AC_DEFINE(SH_USE_PORTCHECK, [1], [Define if you want to check ports])
1560 fi
1561 ]
1562)
1563
1564AC_ARG_ENABLE(userfiles,
1565 [ --enable-userfiles check for users' config files [[no]]],
1566 [
1567 if test "x${enableval}" = "xyes"; then
1568 AC_DEFINE(SH_USE_USERFILES)
1569 fi
1570 ]
1571)
1572
1573AC_ARG_ENABLE(debug,
1574 [ --enable-debug enable debug options [[no]]],
1575 [
1576 if test "x${enable_debug}" = "xyes"; then
1577 if test "x${mydebugflag}" != "xyes"; then
1578 AC_DEFINE(MEM_DEBUG)
1579 fi
1580 AC_DEFINE(WITH_TPT)
1581 AC_DEFINE(SL_DEBUG)
1582 AC_DEFINE(DNMALLOC_CHECKS, 1, [Debug dnmalloc])
1583 AC_DEFINE(PARANOIA, 0, [Paranoia level for dnmalloc])
1584 AC_DEFINE(SL_FAIL_ON_ERROR)
1585 if test "x${myneedg3}" = "xyes"; then
1586 mydebugdef="-g3"
1587 else
1588 mydebugdef="-g"
1589 fi
1590 mydebugit="yes"
1591 elif test "x${enable_debug}" = "xgdb"; then
1592 if test "x${myneedg3}" = "xyes"; then
1593 mydebugdef="-g3"
1594 else
1595 mydebugdef="-g"
1596 fi
1597 mydebugit="yes"
1598 fi
1599 ]
1600)
1601AC_SUBST(mydebugdef)
1602
1603
1604AC_ARG_ENABLE(ipv6,
1605 [ --disable-ipv6 disable ipv6 support],
1606 [
1607 if test "x${enable_ipv6}" = xno; then
1608 AC_DEFINE(USE_IPV4,1,[Define if you do not want IPv6])
1609 fi
1610 ]
1611)
1612
1613if test "x${dnmalloc_ok}" = "xyes"; then
1614 sh_dnmalloc_enabled=yes
1615else
1616 sh_dnmalloc_enabled=no
1617fi
1618
1619AC_ARG_ENABLE(dnmalloc,
1620 [ --disable-dnmalloc disable dnmalloc],
1621 [
1622 if test "x${enable_dnmalloc}" = xno; then
1623 sh_dnmalloc_enabled=no
1624 else
1625 sh_dnmalloc_enabled=yes
1626 fi
1627 ]
1628)
1629
1630dnl Handle the problem that static linking against libc.a on Linux
1631dnl produces the error "multiple definitions of malloc"
1632dnl
1633if test "x$sh_dnmalloc_enabled" = "xyes"; then
1634 if test x$enable_static = xyes; then
1635 if test "x$sh_no_gcc_static" = "xyes"; then
1636 sh_dnmalloc_enabled=no
1637 else
1638 if test "x$with_gnu_ld" = "xyes"; then
1639 LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
1640 else
1641 sh_dnmalloc_enabled=no
1642 fi
1643 fi
1644 fi
1645fi
1646
1647if test "x${sh_dnmalloc_enabled}" = xno; then
1648 AC_DEFINE(USE_SYSTEM_MALLOC,1,[Define if you want to use the system malloc])
1649fi
1650
1651AC_ARG_ENABLE(ptrace,
1652 [ --enable-ptrace use anti-debugger options [[no]]],
1653 [
1654 if test "x${enable_ptrace}" = xyes; then
1655 if test "x$mydebugit" != "xyes"; then
1656 AC_DEFINE(SCREW_IT_UP)
1657 fi
1658 fi
1659 ]
1660)
1661
1662dnl
1663if test "x$GCC" = "xyes"; then
1664 if test ! -z "`echo "$CFLAGS" | grep "\-g\ " 2> /dev/null`" ; then
1665 CFLAGS=`echo $CFLAGS | sed 's%\-g%%' `
1666 fi
1667
1668dnl if test ! -z "`echo "$CFLAGS" | grep "\-O2" 2> /dev/null`" ; then
1669dnl CFLAGS=`echo $CFLAGS | sed 's%\-O2%\-O3%' `
1670dnl fi
1671
1672 if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
1673 CFLAGS="$CFLAGS -Wall -W "
1674 fi
1675
1676 if test -z "`echo "$CFLAGS" | grep "\-fstrength\-reduce" 2> /dev/null`"
1677 then
1678 if test -z "`echo "$CFLAGS" | grep "\-fno\-strength\-reduce" 2> /dev/null`"
1679 then
1680 CFLAGS="$CFLAGS -fno-strength-reduce"
1681 fi
1682 fi
1683
1684 if test -z "`echo "$CFLAGS" | grep "\-fomit\-frame\-pointer" 2> /dev/null`"
1685 then
1686 if test -z "`echo "$CFLAGS" | grep "\-fno\-omit\-frame\-pointer" 2> /dev/null`"
1687 then
1688 CFLAGS="$CFLAGS -fno-omit-frame-pointer"
1689 fi
1690 fi
1691
1692fi
1693
1694dnl Test whether gcc supports -Wno-empty-body
1695dnl Suppresses warnings from glibc pthread_cleanup_pop
1696dnl
1697GCC_WEMPTY_BODY
1698
1699AC_MSG_CHECKING([which random module to use])
1700AC_ARG_WITH(rnd,
1701 [ --with-rnd=[[egd|unix|dev|default]] random number generator [[default]]],
1702[use_static_rnd=$withval], [use_static_rnd=default] )
1703
1704if test "$use_static_rnd" = no; then
1705 use_static_rnd=default
1706fi
1707
1708case "$use_static_rnd" in
1709 egd | dev | unix | default )
1710 AC_MSG_RESULT($use_static_rnd)
1711 ;;
1712 * )
1713 AC_MSG_RESULT([invalid argument])
1714 AC_MSG_ERROR([Option --with-rnd=module used with unsupported module ${use_static_rnd}])
1715 ;;
1716esac
1717
1718AC_ARG_WITH(egd-socket,
1719 [ --with-egd-socket=NAME EGD socket name],
1720 egd_socket_name="$withval", egd_socket_name="" )
1721AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, _("$egd_socket_name") )
1722
1723dnl
1724dnl See whether the user wants to disable checking for /dev/random
1725
1726try_dev_random=yes
1727
1728case "$use_static_rnd" in
1729dev | default )
1730 try_dev_random=yes
1731 ;;
1732egd)
1733 AC_DEFINE(HAVE_EGD_RANDOM)
1734 try_dev_random=no
1735 ;;
1736unix)
1737 AC_DEFINE(HAVE_UNIX_RANDOM)
1738 try_dev_random=no
1739 ;;
1740esac
1741
1742
1743if test "x$try_dev_random" = "xyes"; then
1744 AC_MSG_CHECKING(whether /dev/random exists)
1745 if test -r "/dev/srandom" && test -c "/dev/srandom"; then
1746 AC_DEFINE(HAVE_URANDOM)
1747 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, _("/dev/srandom") )
1748 AC_MSG_RESULT(yes)
1749 if test -r "/dev/urandom" && test -c "/dev/urandom"; then
1750 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, _("/dev/urandom") )
1751 fi
1752 else
1753 if test -r "/dev/random" && test -c "/dev/random"; then
1754 AC_DEFINE(HAVE_URANDOM)
1755 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, _("/dev/random") )
1756 AC_MSG_RESULT(yes)
1757 if test -r "/dev/urandom" && test -c "/dev/urandom"; then
1758 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, _("/dev/urandom") )
1759 fi
1760 else
1761 AC_MSG_RESULT(no)
1762 AC_DEFINE(HAVE_UNIX_RANDOM)
1763 fi
1764 fi
1765fi
1766
1767
1768AC_ARG_ENABLE(udp,
1769 [ --enable-udp server can listen on port 514/udp [[no]]],
1770 [
1771 if test "x${enable_udp}" = xyes; then
1772 AC_DEFINE(INET_SYSLOG)
1773 fi
1774 ]
1775)
1776
1777myencrypt=yes
1778AC_ARG_ENABLE(encrypt,
1779 [ --disable-encrypt disable client/server encryption],
1780 [
1781 if test "x${enable_encrypt}" = xno; then
1782 myencrypt=no
1783 elif test "x${enable_encrypt}" = "x1"; then
1784 myencrypt=1
1785 fi
1786 ]
1787)
1788if test "x${myencrypt}" = "xyes"; then
1789 AC_DEFINE(SH_ENCRYPT)
1790 AC_DEFINE(SH_ENCRYPT_2)
1791elif test "x${myencrypt}" = "x1"; then
1792 AC_DEFINE(SH_ENCRYPT)
1793fi
1794
1795sh_use_srp_proto=yes
1796AC_ARG_ENABLE(srp,
1797 [ --disable-srp disable SRP for authentication],
1798 [
1799 if test "x${enable_srp}" = xno; then
1800 sh_use_srp_proto=no
1801 fi
1802 ]
1803)
1804if test "x${sh_use_srp_proto}" = xyes; then
1805 AC_DEFINE(USE_SRP_PROTOCOL)
1806fi
1807
1808AC_ARG_WITH(port,
1809 [ --with-port=PORT set port to use for TCP/IP connection [[49777]]],
1810 [
1811 echo "${withval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1812 AC_MSG_ERROR([For --with-port=PORT, PORT must be numeric.])
1813 myport=${withval}
1814 ],
1815 [myport="49777"])
1816AC_DEFINE_UNQUOTED(SH_DEFAULT_PORT, ${myport})
1817AC_SUBST(myport)
1818
1819AC_ARG_WITH(logserver,
1820 [ --with-logserver=HOST set host address for log server [[none]]],
1821 [
1822 case "$withval" in
1823 *.* | localhost)
1824 mylogsrv="$withval"
1825 ;;
1826 *)
1827 mylogsrv="$withval"
1828 ;;
1829 esac
1830 ],
1831 [mylogsrv="NULL"])
1832AC_DEFINE_UNQUOTED(DEFAULT_LOGSERVER, _("${mylogsrv}") )
1833AC_SUBST(mylogsrv)
1834
1835AC_ARG_WITH(altlogserver,
1836 [ --with-altlogserver=HOST set address for backup log server [[none]]],
1837 [
1838 case "$withval" in
1839 *.* | localhost)
1840 myaltlogsrv="$withval"
1841 ;;
1842 *)
1843 myaltlogsrv="$withval"
1844 ;;
1845 esac
1846 ],
1847 [myaltlogsrv="NULL"])
1848AC_DEFINE_UNQUOTED(ALT_LOGSERVER, _("${myaltlogsrv}"))
1849
1850
1851
1852dnl
1853dnl STEALTH OPTIONS
1854dnl
1855nocl_code=
1856xor_code=0
1857AC_ARG_ENABLE(nocl,
1858 [ --enable-nocl=PW no CL parsing unless first CL argument is PW],
1859 [
1860 if test "x${enableval}" != "x"; then
1861 AC_DEFINE(SH_STEALTH_NOCL)
1862 fi
1863 if test "x${enableval}" = "xstop" || test "x${enableval}" = "xstart"; then
1864 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1865 fi
1866 if test "x${enableval}" = "xreload" || test "x${enableval}" = "xrestart"; then
1867 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1868 fi
1869 if test "x${enableval}" = "xstatus"; then
1870 AC_MSG_ERROR([For --enable-nocl=PW start/stop/reload/restart/status are reserved words.])
1871 fi
1872 if test "x${enableval}" = "xno"; then
1873 AC_MSG_ERROR([With --enable-nocl=PW, the use of --enable-nocl=no is ambiguous.])
1874 fi
1875 nocl_code="${enable_nocl}"
1876 ]
1877)
1878AC_DEFINE_UNQUOTED(NOCL_CODE, _("${nocl_code}") )
1879AC_SUBST(nocl_code)
1880AC_ARG_ENABLE(stealth,
1881 [ --enable-stealth=XOR_VAL enable stealth mode [[no]]],
1882 [AC_DEFINE(SH_STEALTH)
1883 if test "x${enableval}" != "xyes"; then
1884 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1885 AC_MSG_ERROR([For --enable-stealth=XOR_VAL, XOR_VAL must be numeric.])
1886 if test "${enableval}" -lt 127 || test "${enableval}" -gt 255; then
1887 if test x"${enableval}" = x0
1888 then
1889 :
1890 else
1891 AC_MSG_ERROR([For --enable-stealth=XOR_VAL, XOR_VAL must be in the range 127 to 255.])
1892 fi
1893 fi
1894 xor_code="${enable_stealth}"
1895 else
1896 xor_code=0
1897 fi
1898 stegin_prg="samhain_stealth"
1899 ],
1900 [
1901 stegin_prg=
1902 ]
1903)
1904AC_ARG_ENABLE(micro-stealth,
1905 [ --enable-micro-stealth=XOR_VAL enable micro stealth mode [[no]]],
1906 [
1907 AC_DEFINE(SH_STEALTH)
1908 AC_DEFINE(SH_STEALTH_MICRO)
1909 if test "x${enableval}" != "xyes"; then
1910 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
1911 AC_MSG_ERROR([For --enable-micro-stealth=XOR_VAL, XOR_VAL must be numeric.])
1912 if test "${enableval}" -lt 127 || test "${enableval}" -gt 255; then
1913 if test x"${enableval}" = x0
1914 then
1915 :
1916 else
1917 AC_MSG_ERROR([For --enable-micro-stealth=XOR_VAL, XOR_VAL must be in the range 127 to 255.])
1918 fi
1919 fi
1920 xor_code="${enable_micro_stealth}"
1921 else
1922 xor_code=0
1923 fi
1924 ]
1925)
1926install_name="samhain"
1927INSTALL_NAME="SAMHAIN"
1928AC_ARG_ENABLE(install-name,
1929 [ --enable-install-name=NAME name under which to install [[samhain|yule]]],
1930 [
1931 if test "x${enableval}" != "xyes"; then
1932 install_name="${enableval}"
1933 INSTALL_NAME=`echo "${enableval}" | tr [a-z] [A-Z]`
1934 else
1935 install_name="${sh_main_prg}"
1936 INSTALL_NAME=`echo "${sh_main_prg}" | tr [a-z] [A-Z]`
1937 fi
1938 ],
1939 [
1940 install_name="${sh_main_prg}"
1941 INSTALL_NAME=`echo "${sh_main_prg}" | tr [a-z] [A-Z]`
1942 ]
1943)
1944
1945
1946need_user_install=0
1947
1948AC_ARG_ENABLE(identity,
1949 [ --enable-identity=USER user if dropping root [[daemon]]],
1950 [
1951 if test x"$enableval" = xno; then
1952 myident="daemon"
1953 else
1954 myident="$enableval"
1955 fi
1956 echo "${myident}" | grep ['[^0123456789]'] >/dev/null 2>&1 || \
1957 AC_MSG_ERROR([With --enable-identity=USER, please supply a username, not a UID.])
1958 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1959 grep "^${myident}:" | awk -F: '{ print $3; }'`
1960 if test x"${myident_uid}" = x; then
1961 AC_MSG_WARN([Option --enable-identity used, user ${myident} will be added upon install.])
1962 need_user_install=1
1963 fi
1964 ],
1965 [
1966 for myident in ${install_name} daemon nobody; do
1967 AC_MSG_CHECKING(for user ${myident})
1968 myident_uid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
1969 grep "^${myident}:" | awk -F: '{ print $3; }'`
1970 if test x"${myident_uid}" != x; then
1971 AC_MSG_RESULT(yes)
1972 break;
1973 else
1974 AC_MSG_RESULT(no)
1975 fi
1976 done
1977 if test x"${myident_uid}" = x; then
1978 myident=${install_name}
1979 AC_MSG_WARN([--enable-identity: user ${myident} will be added upon install])
1980 need_user_install=1
1981 fi
1982 ])
1983AC_DEFINE_UNQUOTED(DEFAULT_IDENT, _("${myident}") )
1984AC_SUBST(myident)
1985AC_SUBST(need_user_install)
1986
1987sh_insmod_cmd=": # no kernel module"
1988sh_insmod_pre=": # no kernel module"
1989sh_lkm=""
1990lkm_inc=""
1991khidemap="/boot/System.map"
1992sh_syscalltable="0x0"
1993AC_ARG_ENABLE(khide,
1994 [ --enable-khide=SYSTEM_MAP use kernel module to hide (Linux only)[[/boot/System.map]]],
1995 [
1996 if test "x${enable_khide}" != xno; then
1997 if test "x${enableval}" != "xyes"; then
1998 khidemap="${enableval}"
1999 fi
2000 sh_syscalltable=`egrep '(D|d|R|r) sys_call_table' ${khidemap} | awk '{print $1}'`
2001 if test x"$sh_syscalltable" = x; then
2002 AC_MSG_ERROR([Option --enable-khide cannot be used since the symbol sys_call_table was not found in ${khidemap}.])
2003 fi
2004 sh_syscalltable="0x${sh_syscalltable}"
2005 install_name_len=`echo ${install_name} | awk '{ print(length()); }'`
2006 if test "${install_name_len}" -gt 15 ; then
2007 AC_MSG_ERROR([If --enable-khide is used, install_name must not exceed a length of 15 chars.])
2008 fi
2009 AC_DEFINE(SH_USE_LKM)
2010 AC_DEFINE_UNQUOTED(SH_MAGIC_HIDE, "${install_name}")
2011
2012 # -- NEW --
2013 kernel_version=`uname -r | sed s,2.6.*,LINUX26,`
2014 kernel_numeric=`uname -r | sed 's%-%.%g' | sed 's%_%.%g' | awk -F. '{ print $1*65536+$2*256+$3 }'`
2015 AC_DEFINE_UNQUOTED(SH_KERNEL_NUMERIC, ${kernel_numeric}, [Kernel number])
2016
2017 if test x"$kernel_version" = xLINUX26
2018 then
2019 AC_MSG_CHECKING([for modlist_lock])
2020 sh_modlist_lock=`egrep ['[bd] modlist_lock$'] ${khidemap} | awk '{print $1}'`
2021 if test x"$sh_modlist_lock" = x; then
2022 AC_MSG_RESULT(no)
2023 else
2024 sh_modlist_lock="0x${sh_modlist_lock}"
2025 AC_MSG_RESULT([${sh_modlist_lock}])
2026 AC_DEFINE_UNQUOTED(SH_MODLIST_LOCK, ${sh_modlist_lock}, [The address of the modules list spinlock])
2027 fi
2028
2029 AC_MSG_CHECKING([for module_mutex])
2030 sh_modlist_mutex=`egrep ['[bd] module_mutex$'] ${khidemap} | awk '{print $1}'`
2031 if test x"$sh_modlist_mutex" = x; then
2032 AC_MSG_RESULT(no)
2033 else
2034 sh_modlist_mutex="0x${sh_modlist_mutex}"
2035 AC_MSG_RESULT([${sh_modlist_mutex}])
2036 AC_DEFINE_UNQUOTED(SH_MODLIST_MUTEX, ${sh_modlist_mutex}, [The address of the modules list mutex])
2037 fi
2038
2039 sh_list_modules=`egrep 'd modules$' ${khidemap} | awk '{print $1}'`
2040 if test x"$sh_list_modules" = x; then
2041 AC_MSG_ERROR([Option --enable-khide cannot be used, since the symbol modules was not found in ${khidemap}.])
2042 fi
2043 sh_list_modules="0x${sh_list_modules}"
2044 AC_DEFINE_UNQUOTED(SH_LIST_MODULES, ${sh_list_modules}, [The address of the modules list])
2045
2046 AC_DEFINE(LINUX26, 1, [Define if kernel is 2.6])
2047 sh_insmod_cmd="modprobe ${install_name}_hide"
2048 sh_lkm="samhain_hide.ko"
2049 else
2050 sh_insmod_cmd="insmod ${install_name}_hide; insmod ${install_name}_erase; rmmod ${install_name}_erase"
2051 sh_lkm="samhain_hide.o samhain_erase.o"
2052 fi
2053 # -- END NEW --
2054
2055 kvers=`uname -r`
2056 if test -f /lib/modules/${kvers}/build/include/linux/kernel.h; then
2057 lkm_inc="-I/lib/modules/${kvers}/build/include"
2058 else
2059 AC_MSG_WARN([--enable-khide: /lib/modules/${kvers}/build/include/linux not found])
2060 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])
2061 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])
2062 fi
2063
2064 AC_MSG_CHECKING([for 2.4 vanilla kernel])
2065 sh_is_vanilla_kernel=yes
2066 if test -f /lib/modules/${kvers}/build/include/linux/sched.h; then
2067 grep 'next_task,' /lib/modules/${kvers}/build/include/linux/sched.h >/dev/null 2>&1 || sh_is_vanilla_kernel=no
2068 fi
2069 if test x"${sh_is_vanilla_kernel}" = xno; then
2070 AC_MSG_RESULT(no)
2071 else
2072 AC_MSG_RESULT(yes)
2073 AC_DEFINE(SH_VANILLA_KERNEL)
2074 fi
2075
2076 fi
2077 ]
2078)
2079
2080AC_SUBST(install_name)
2081AC_SUBST(INSTALL_NAME)
2082AC_SUBST(stegin_prg)
2083AC_SUBST(xor_code)
2084
2085AC_DEFINE_UNQUOTED(XOR_CODE, ${xor_code})
2086AC_DEFINE_UNQUOTED(SH_SYSCALLTABLE, ${sh_syscalltable})
2087
2088
2089exepack_state0=`${srcdir}/c_random.sh 2>/dev/null`
2090exepack_state1=`${srcdir}/c_random.sh 2>/dev/null`
2091exepack_state2=`${srcdir}/c_random.sh 2>/dev/null`
2092
2093AC_DEFINE_UNQUOTED(EXEPACK_STATE_0, ${exepack_state0})
2094AC_DEFINE_UNQUOTED(EXEPACK_STATE_1, ${exepack_state1})
2095AC_DEFINE_UNQUOTED(EXEPACK_STATE_2, ${exepack_state2})
2096
2097
2098AC_ARG_ENABLE(suidcheck,
2099 [ --enable-suidcheck check for suid/sgid files [[no]]],
2100 [
2101 if test "x${enableval}" = "xyes"; then
2102 AC_DEFINE(SH_USE_SUIDCHK)
2103 fi
2104 ]
2105)
2106
2107
2108systemmap="/boot/System.map"
2109sh_libkvm=""
2110AC_ARG_WITH(kcheck,
2111 [ --with-kcheck[[=SYSTEM_MAP]] check Linux/FreeBSD/OpenBSD kernel integrity [[/boot/System.map]]],
2112 [
2113 if test "x${withval}" != "xno"; then
2114 AC_DEFINE(SH_USE_KERN)
2115
2116 kernel_numeric=`uname -r | sed 's%-%.%g' | sed 's%_%.%g' | awk -F. '{ print $1*65536+$2*256+$3 }'`
2117 AC_DEFINE_UNQUOTED(SH_KERNEL_NUMBER, ${kernel_numeric}, [Kernel number])
2118
2119 kernelversion=`uname -r`
2120 AC_DEFINE_UNQUOTED(SH_KERNEL_VERSION, _("${kernelversion}"), [Define the kernel version])
2121
2122 if test "x${withval}" != "xyes"; then
2123 systemmap="${withval}"
2124 fi
2125
2126 if test "x${cross_compiling}" = xyes; then
2127 :
2128 elif test "x$selectconfig" = "xfreebsd"; then
2129 LIBS="$LIBS -lkvm"
2130 sh_libkvm="-lkvm"
2131 elif test -f "${systemmap}"; then
2132
2133 test_kmap_open=no
2134
2135 if test -c /dev/kmem; then
2136 AC_MSG_CHECKING([whether /dev/kmem is useable])
2137 dd bs=4 if=/dev/kmem of=/dev/null 2>&1 | grep opening >/dev/null
2138 if test $? -ne 0; then
2139 test_kmap_open=yes
2140 fi
2141 AC_MSG_RESULT([${test_kmap_open}])
2142 fi
2143
2144 if test x"${test_kmap_open}" = xno; then
2145 # need kernel module
2146
2147 if test -f /lib/modules/${kernelversion}/build/include/linux/kernel.h; then
2148 lkm_inc="-I/lib/modules/${kernelversion}/build/include"
2149 else
2150 AC_MSG_WARN([--enable-khide: /lib/modules/${kernelversion}/build/include/linux not found])
2151 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])
2152 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])
2153 fi
2154
2155 AC_MSG_CHECKING([for vmlist_lock])
2156 sh_vmlist_lock=`egrep ['[bdBD] vmlist_lock$'] ${systemmap} | awk '{print $1}'`
2157 if test x"$sh_vmlist_lock" = x; then
2158 AC_MSG_RESULT(no)
2159 else
2160 sh_vmlist_lock="0x${sh_vmlist_lock}"
2161 AC_MSG_RESULT([${sh_vmlist_lock}])
2162 AC_DEFINE_UNQUOTED(SH_VMLIST_LOCK, ${sh_vmlist_lock}, [The address of the vmlist spinlock])
2163 fi
2164
2165 AC_MSG_CHECKING([for vmlist])
2166 sh_vmlist=`egrep ['[bdBD] vmlist$'] ${systemmap} | awk '{print $1}'`
2167 if test x"$sh_vmlist" = x; then
2168 AC_MSG_RESULT(no)
2169 else
2170 sh_vmlist="0x${sh_vmlist}"
2171 AC_MSG_RESULT([${sh_vmlist}])
2172 AC_DEFINE_UNQUOTED(SH_VMLIST, ${sh_vmlist}, [The address of the vmlist])
2173 fi
2174
2175 sh_lkm="${sh_lkm} samhain_kmem.ko"
2176 sh_insmod_pre="modprobe ${install_name}_kmem"
2177
2178 fi
2179 else
2180 AC_MSG_ERROR([Option --with-kcheck=systemmap cannot be used, because system map ${systemmap} does not exist.])
2181 fi
2182 fi
2183 ]
2184)
2185
2186AC_SUBST(lkm_inc)
2187AC_SUBST(sh_lkm)
2188AC_SUBST(sh_insmod_cmd)
2189AC_SUBST(sh_insmod_pre)
2190
2191AC_SUBST(systemmap)
2192AC_SUBST(sh_libkvm)
2193
2194AC_ARG_ENABLE(base,
2195 [ --enable-base=B1,B2 base key (0...2147483647)],
2196 [
2197 AC_MSG_CHECKING(base key setting)
2198 my_key_A=`echo ${enableval} | awk 'BEGIN{FS=","}{print $1}'`
2199 my_key_B=`echo ${enableval} | awk 'BEGIN{FS=","}{print $2}'`
2200 AC_MSG_RESULT(${my_key_A} ${my_key_B})
2201 if test "x${my_key_A}" = x; then
2202 AC_MSG_ERROR([Option --enable-base=B1,B2 used with invalid first base key (zero length).])
2203 fi
2204 if test "x${my_key_B}" = x; then
2205 AC_MSG_ERROR([Option --enable-base=B1,B2 used with invalid second base key (zero length).])
2206 fi
2207 echo "${my_key_A}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2208 AC_MSG_ERROR([For --enable-base=B1,B2, B1 and B2 must be numeric in the range 0 to 2147483647.])
2209 echo "${my_key_B}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2210 AC_MSG_ERROR([For --enable-base=B1,B2, B1 and B2 must be numeric in the range 0 to 2147483647.])
2211 ],
2212 [
2213 AC_MSG_CHECKING(base key setting .. collecting entropy)
2214 my_key_1=`${srcdir}/c_random.sh 2>/dev/null`
2215 my_key_2=`${srcdir}/c_random.sh 2>/dev/null`
2216 my_key_3=`${srcdir}/c_random.sh 2>/dev/null`
2217 my_key_4=`${srcdir}/c_random.sh 2>/dev/null`
2218 my_key_A=`expr $my_key_1 \* 32767`
2219 my_key_A=`echo ${my_key_A} | sed 's%^0*%%g' 2>/dev/null`
2220 my_key_A=`expr $my_key_A \+ $my_key_2`
2221 my_key_B=`expr $my_key_3 \* 32767`
2222 my_key_B=`echo ${my_key_B} | sed 's%^0*%%g' 2>/dev/null`
2223 my_key_B=`expr $my_key_B \+ $my_key_4`
2224 AC_MSG_RESULT(${my_key_A} ${my_key_B})
2225 ]
2226 )
2227AC_SUBST(my_key_A)
2228AC_SUBST(my_key_B)
2229
2230dnl low bytes
2231my_key_1=`expr $my_key_A \% 65536`
2232dnl high bytes
2233my_key_2=`expr $my_key_A \/ 65536`
2234dnl low bytes
2235my_key_3=`expr $my_key_B \% 65536`
2236dnl high bytes
2237my_key_4=`expr $my_key_B \/ 65536`
2238
2239dnl echo ${my_key_1} ${my_key_2} ${my_key_3} ${my_key_4}
2240
2241dnl touch ./sh_MK.h
2242dnl echo "#ifndef SH_MK_H" >> ./sh_MK.h
2243dnl echo "#define SH_MK_H" >> ./sh_MK.h
2244dnl ${srcdir}/c_bits.sh ${my_key_1} MKB >> ./sh_MK.h
2245dnl ${srcdir}/c_bits.sh ${my_key_2} MKA >> ./sh_MK.h
2246dnl ${srcdir}/c_bits.sh ${my_key_3} MKC >> ./sh_MK.h
2247dnl ${srcdir}/c_bits.sh ${my_key_4} MKD >> ./sh_MK.h
2248dnl echo "#endif" >> ./sh_MK.h
2249AC_SUBST(my_key_1)
2250AC_SUBST(my_key_2)
2251AC_SUBST(my_key_3)
2252AC_SUBST(my_key_4)
2253
2254AC_MSG_CHECKING(key position)
2255pos_tf_1=`${srcdir}/c_random.sh 2>/dev/null`
2256pos_tf_2=`expr $pos_tf_1 \% 8`
2257pos_tf=`expr $pos_tf_2 + 1`
2258AC_MSG_RESULT(${pos_tf})
2259AC_DEFINE_UNQUOTED(POS_TF, ${pos_tf} )
2260
2261mykeybase=`echo ${my_key_A},${my_key_B}`
2262AC_DEFINE_UNQUOTED(DEFKEY, ${mykeybase} )
2263AC_SUBST(mykeybase)
2264
2265
2266dnl
2267dnl GPG/PGP options
2268dnl
2269
2270AC_ARG_WITH(gpg,
2271 [ --with-gpg=PATH use GnuPG to verify database/config [[no]]],
2272 [
2273 if test "x${withval}" != "xno"; then
2274 if test "x${cross_compiling}" = xyes; then
2275 mygpg="${withval}"
2276 else
2277 if test -f "${withval}"; then
2278 mygpg="${withval}"
2279 mychk0=`${withval} --load-extension tiger --print-md TIGER192 ${withval} 2>/dev/null`
2280 if test "x$?" != "x0"; then
2281 mychktest=no
2282 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
2283 if test x"${mychktest}" = xyes
2284 then
2285 :
2286 else
2287 if test -f ${sampre}
2288 then
2289 echo "use existing ${sampre} for gpg checksum"
2290 mychk0=`${sampre} -H ${withval} 2>/dev/null`
2291 if test "x$?" != "x0"; then
2292 :
2293 else
2294 mychk="${mychk0}"
2295 mychktest=yes
2296 fi
2297 fi
2298 fi
2299 done
2300 if test x${mychktest} = xno; then
2301 AC_MSG_WARN([--with-gpg: cannot determine TIGER192 checksum of ${withval}])
2302 echo "-------------------------------------------------------------"
2303 echo " Your gpg binary does not support the TIGER192 checksum, "
2304 echo " and I cannot find an existing samhain binary to use instead."
2305 echo " You can:"
2306 echo " (a) run make to compile a samhain binary, then repeat"
2307 echo " ./configure and make"
2308 echo " (b) ignore the failure. The checksum of the gpg binary"
2309 echo " will not get compiled in, thus allowing an attacker"
2310 echo " to replace gpg with a trojan and subverting the gpg"
2311 echo " signature verification of configure and database files."
2312 echo
2313 echo " PLEASE IGNORE THIS MESSAGE IF YOU ALSO USE --with-checksum"
2314 echo "-------------------------------------------------------------"
2315 fi
2316 else
2317 mychk="${mychk0}"
2318 fi
2319 else
2320 AC_MSG_ERROR([--with-gpg: cannot find GnuPG PATH=${withval}])
2321 fi
2322 fi
2323 AC_DEFINE(WITH_GPG)
2324 AC_DEFINE_UNQUOTED(DEFAULT_GPG_PATH, _("${mygpg}") )
2325 AC_SUBST(mygpg)
2326 fi
2327 ]
2328)
2329
2330AC_ARG_WITH(keyid,
2331 [ --with-keyid=KEYID specify KeyID (0x...) for GPG/PGP functions [[none]]],
2332 [
2333 if test "x${withval}" != "x"; then
2334 echo "${withval}" | awk '{if((length($0)==10)||(length($0)==18)){exit 2}else{exit 0}}' &&
2335 AC_MSG_ERROR([--with-keyid:${withval} must be "0x" + 8|16 hex digits])
2336 echo "${withval}" | grep ['[^0][^x][^0123456789ABCDEFabcdef]'] >/dev/null 2>&1 &&
2337 AC_MSG_ERROR([--with-keyid:${withval} must be "0x" + 8|16 hex digits])
2338 mykeyid="$withval"
2339 mykeytag="--default-key"
2340 else
2341 mykeyid=""
2342 mykeytag=""
2343 fi
2344 AC_SUBST(mykeyid)
2345 AC_SUBST(mykeytag)
2346 ]
2347)
2348
2349dnl AC_ARG_WITH(pgp,
2350dnl [ --with-pgp=PATH Use PGP to verify database/config (no).],
2351dnl [myppg="$withval"
2352dnl AC_DEFINE(WITH_PGP)
2353dnl AC_DEFINE_UNQUOTED(DEFAULT_PGP_PATH, _("${myppg}") )
2354dnl ])
2355
2356AC_ARG_WITH(checksum,
2357 [ --with-checksum=CHKSUM compile in gpg/pgp checksum [[yes]]],
2358 [
2359 if test "x${withval}" != "xno"; then
2360 if test "x${withval}" != "xyes"; then
2361 if test "x${mychk}" != "x"; then
2362 if test "x${mychk}" != "x${withval}"; then
2363 AC_MSG_WARN([--with-checksum: possible gpg CHKSUM problem])
2364 AC_MSG_WARN([--with-checksum: CHKSUM=${withval}])
2365 AC_MSG_WARN([--with-checksum: autodetected=${mychk}])
2366 fi
2367 fi
2368 mychk="${withval}"
2369 else
2370 if test "x${mychk}" = "x"; then
2371 AC_MSG_ERROR([Option --with-checksum=CHKSUM: checksum CHKSUM of the gpg binary not specified.])
2372 fi
2373 fi
2374 AC_DEFINE(HAVE_GPG_CHECKSUM)
2375 AC_DEFINE_UNQUOTED(GPG_HASH, _("${mychk}") )
2376 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
2377 fi
2378 ],
2379 [
2380 if test "x${mygpg}" != "x"; then
2381 if test "x${mychk}" != "x"; then
2382 AC_DEFINE(HAVE_GPG_CHECKSUM)
2383 AC_DEFINE_UNQUOTED(GPG_HASH, _("${mychk}") )
2384 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
2385 fi
2386 fi
2387 ]
2388)
2389
2390AC_ARG_WITH(fp,
2391 [ --with-fp=FINGERPRINT compile in public key fingerprint [[no]]],
2392 [
2393 if test "x${withval}" != "xno"; then
2394 if test "x${withval}" != "xyes"; then
2395 withval0=`echo ${withval} | sed 's% %%g'`
2396 echo "${withval0}" | \
2397 grep ['[^0123456789abcdefABCDEF]'] >/dev/null 2>&1 &&
2398 AC_MSG_ERROR([In option --with-fp=FINGERPRINT, there is an invalid character(s) in FINGERPRINT=${withval0}.])
2399 sh_len=`echo ${withval0} | wc -c | sed 's% %%g'`
2400 sh_len0=`expr ${sh_len} \- 1`
2401 if test "x${sh_len0}" = "x40" || test "x${sh_len0}" = "x32"
2402 then
2403 myfp="${withval0}"
2404 AC_DEFINE(USE_FINGERPRINT)
2405 AC_DEFINE_UNQUOTED(SH_GPG_FP, _("${myfp}") )
2406 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
2407 else
2408 AC_MSG_ERROR([In option --with-fp=FINGERPRINT, the length (${sh_len0}) of FINGERPRINT ${withval0} is incorrect.])
2409 fi
2410 else
2411 AC_MSG_ERROR([For option --with-fp=FINGERPRINT, FINGERPRINT=yes is invalid, please specify a valid key fingerprint.])
2412 fi
2413 fi
2414 ])
2415
2416
2417dnl
2418dnl MAIL OPTIONS
2419dnl
2420
2421AC_ARG_WITH(recipient,
2422 [ --with-recipient=ADDR set recipient(s) for e-mail [[none]]],
2423 [
2424 withval0=`echo ${withval} | sed 's%,% %g'`
2425 for sh_item in ${withval0}
2426 do
2427 case ${sh_item} in
2428 *@localhost)
2429 ;;
2430 *@*.*)
2431 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}}'`
2432 if test "x${sh_tmp}" != "x1"
2433 then
2434 AC_MSG_ERROR([Option --with-recipient=ADDR used with invalid mail address ${sh_item}.])
2435 fi
2436 ;;
2437 *)
2438 AC_MSG_ERROR([Option --with-recipient=ADDR used with invalid mail address ${sh_item}.])
2439 ;;
2440 esac
2441 done
2442 myrcp="$withval0"
2443 ],
2444 [myrcp="NULL"])
2445AC_DEFINE_UNQUOTED(DEFAULT_MAILADDRESS, _("${myrcp}") )
2446
2447
2448AC_ARG_WITH(sender,
2449 [ --with-sender=SENDER set sender for e-mail [[daemon]]],
2450 [
2451 mysender="${withval}"
2452 ],
2453 [
2454 mysender="daemon"
2455 ])
2456AC_DEFINE_UNQUOTED(DEFAULT_SENDER, _("${mysender}") )
2457
2458
2459dnl
2460dnl PATHS
2461dnl
2462
2463AC_ARG_WITH(trusted,
2464 [ --with-trusted=UID Set uid(s) of trusted users [[0]]],
2465 [
2466 sh_tmp_test=no
2467 sh_tmp=`echo ${withval} | sed 's%,% %g'`
2468 for sh_tmp1 in ${sh_tmp}
2469 do
2470 echo "${sh_tmp1}" | grep ['[^0123456789]'] >/dev/null 2>&1 &&
2471 AC_MSG_ERROR([Option --with-trusted=UID used with non-numeric UID in ${withval}.])
2472 if test "x${sh_tmp1}" = "x0"
2473 then
2474 sh_tmp_test=yes
2475 fi
2476 done
2477 if test "x${sh_tmp_test}" = "xno"
2478 then
2479 withval="0,${withval}"
2480 fi
2481 mytrust="${withval}"
2482 ],
2483 [mytrust="0"] )
2484AC_DEFINE_UNQUOTED(SL_ALWAYS_TRUSTED, ${mytrust} )
2485AC_SUBST(mytrust)
2486
2487mytmpdir=
2488
2489AC_ARG_WITH(tmp-dir,
2490 [ --with-tmp-dir=PFX set directory for temporary files [[HOME]]],
2491 [
2492 if test "x${cross_compiling}" = xyes; then
2493 mytmpdir="$withval"
2494 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2495 else
2496 if test -d "${withval}"; then
2497 mytmpdir="$withval"
2498 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2499 else
2500 mytmpdir="$withval"
2501 AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${mytmpdir}") )
2502 AC_MSG_WARN([--with-tmp-dir: tmp directory ${withval} does not exist])
2503 fi
2504 fi
2505 ]
2506)
2507
2508AC_SUBST(mytmpdir)
2509
2510
2511dnl
2512dnl PATH DEFAULTS
2513dnl
2514
2515if test "x${ac_prefix_set}" = xyes
2516then
2517 if test "x${exec_prefix}" = xNONE
2518 then
2519 exec_prefix="${prefix}"
2520 fi
2521
2522 if test "x${prefix}" = xOPT
2523 then
2524 tmp_sbindir="/opt/${install_name}/bin"
2525 tmp_sysconfdir="/etc/opt"
2526 tmp_mandir="/opt/${install_name}/man"
2527 tmp_localstatedir="/var/opt/${install_name}"
2528 elif test "x${prefix}" = xUSR
2529 then
2530 tmp_sbindir="/usr/sbin"
2531 tmp_sysconfdir="/etc"
2532 tmp_mandir="/usr/share/man"
2533 tmp_localstatedir="/var"
2534 else
2535 tmp_sbindir=`eval echo ${sbindir}`
2536 tmp_sysconfdir=`eval echo ${sysconfdir}`
2537 tmp_mandir=`eval echo ${mandir}`
2538 tmp_localstatedir=`eval echo ${localstatedir}`
2539 fi
2540else
2541 prefix=""
2542 if test "x${ac_exec_prefix_set}" = xyes
2543 then
2544 tmp_sbindir=`eval echo ${sbindir}`
2545 else
2546 tmp_sbindir="/usr/local/sbin"
2547 fi
2548 tmp_sysconfdir="/etc"
2549 # share/man -> man (FHS) 11.10.2002
2550 tmp_mandir="/usr/local/man"
2551 tmp_localstatedir="/var"
2552fi
2553
2554
2555if test "x${ac_sbindir_set}" = xyes
2556then
2557 :
2558else
2559 sbindir=`eval echo ${tmp_sbindir}`
2560fi
2561
2562
2563if test "x${ac_sysconfdir_set}" = xyes
2564then
2565 :
2566else
2567 sysconfdir=`eval echo ${tmp_sysconfdir}`
2568fi
2569
2570if test "x${ac_mandir_set}" = xyes
2571then
2572 :
2573else
2574 mandir=`eval echo ${tmp_mandir}`
2575fi
2576
2577if test "x${ac_localstatedir_set}" = xyes
2578then
2579 :
2580else
2581 localstatedir=`eval echo ${tmp_localstatedir}`
2582fi
2583
2584
2585
2586AC_ARG_WITH(config-file,
2587 [ --with-config-file=FILE configuration file [[/etc/{install_name}rc]]],
2588 [
2589 myconffile="${withval}"
2590 changequote(<<, >>)dnl
2591 tmp=`echo ${withval} | sed 's%^REQ_FROM_SERVER%%'`
2592 sysconfdir=`echo ${tmp} | sed 's%/[^/][^/]*$%%'`
2593 myrpmconffile="${tmp}"
2594 changequote([, ])dnl
2595 ],
2596 [
2597 myconffile="${sysconfdir}/${install_name}rc"
2598 myrpmconffile="${myconffile}"
2599 ]
2600)
2601AC_DEFINE_UNQUOTED(DEFAULT_CONFIGFILE, _("${myconffile}") )
2602AC_SUBST(myconffile)
2603AC_SUBST(myrpmconffile)
2604
2605AC_ARG_WITH(log-file,
2606 [ --with-log-file=FILE path of log file [[/var/log/{install_name}_log]]],
2607 [
2608 mylogfile="$withval"
2609 changequote(<<, >>)dnl
2610 mylogdir=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
2611 changequote([, ])dnl
2612 ],
2613 [
2614 if test "x${mytclient}" = "x-DSH_WITH_SERVER"; then
2615 mylogfile="${localstatedir}/log/${install_name}/${install_name}_log"
2616 mylogdir="${localstatedir}/log/${install_name}"
2617 else
2618 mylogfile="${localstatedir}/log/${install_name}_log"
2619 mylogdir="${localstatedir}/log"
2620 fi
2621 ]
2622)
2623AC_DEFINE_UNQUOTED(DEFAULT_ERRFILE, _("${mylogfile}") )
2624AC_DEFINE_UNQUOTED(DEFAULT_LOGDIR, _("${mylogdir}") )
2625AC_SUBST(mylogfile)
2626AC_SUBST(mylogdir)
2627
2628AC_ARG_WITH(pid-file,
2629 [ --with-pid-file=FILE set path of pid file [[/var/run/{install_name}.pid]]],
2630 [
2631 mylockfile="$withval"
2632 changequote(<<, >>)dnl
2633 mylockdir=`echo ${withval} | sed 's%/[^/][^/]*$%%'`
2634 changequote([, ])dnl
2635 ],
2636 [
2637 mylockfile="${localstatedir}/run/${install_name}.pid"
2638 mylockdir="${localstatedir}/run"
2639 ]
2640)
2641AC_DEFINE_UNQUOTED(DEFAULT_ERRLOCK, _("${mylockfile}") )
2642AC_DEFINE_UNQUOTED(DEFAULT_PIDDIR, _("${mylockdir}") )
2643AC_SUBST(mylockfile)
2644AC_SUBST(mylockdir)
2645
2646AC_ARG_WITH(state-dir,
2647 [ --with-state-dir=PFX set state data directory [[/var/lib/{install_name}]]],
2648 [
2649 mydataroot="$withval"
2650 ],
2651 [
2652 mydataroot="${localstatedir}/lib/${install_name}"
2653 ]
2654 )
2655AC_ARG_WITH(data-file,
2656 [ --with-data-file=FILE set path of data file],
2657 [
2658 mydatafile="$withval"
2659 changequote(<<, >>)dnl
2660 tmp=`echo ${withval} | sed 's%^REQ_FROM_SERVER%%'`
2661 mydataroot=`echo ${tmp} | sed 's%/[^/][^/]*$%%'`
2662 myrpmdatafile="${tmp}"
2663 changequote([, ])dnl
2664 if test x"${tmp}" = x
2665 then
2666 echo "No local path in data file ${withval}"
2667 echo "This will not work for initializing the database."
2668 if test x"${withval}" = xREQ_FROM_SERVER
2669 then
2670 echo "It should be REQ_FROM_SERVER/some/local/path"
2671 fi
2672 AC_MSG_ERROR([Option --with-data-file=FILE used with invalid path ${withval}.])
2673 fi
2674 ],
2675 [
2676 mydatafile="${mydataroot}/${install_name}_file"
2677 myrpmdatafile="${mydatafile}"
2678 ])
2679AC_DEFINE_UNQUOTED(DEFAULT_DATA_FILE, _("${mydatafile}") )
2680AC_SUBST(mydatafile)
2681AC_SUBST(myrpmdatafile)
2682
2683AC_DEFINE_UNQUOTED(DEFAULT_DATAROOT, _("${mydataroot}") )
2684AC_SUBST(mydataroot)
2685
2686AC_DEFINE_UNQUOTED(DEFAULT_QDIR, _("${mydataroot}/.quarantine") )
2687AC_SUBST(myqdir)
2688
2689
2690AC_ARG_WITH(html-file,
2691 [ --with-html-file=FILE set path of html file,],
2692 [
2693 myhtmlfile="$withval"
2694 ],
2695 [
2696 myhtmlfile="${mylogdir}/${install_name}.html"
2697 ])
2698AC_DEFINE_UNQUOTED(DEFAULT_HTML_FILE, _("${myhtmlfile}") )
2699AC_SUBST(myhtmlfile)
2700
2701
2702mydefargs=$ac_configure_args
2703# if test -z "`echo "$mydefargs" | grep "\-\-enable\-static" 2> /dev/null`"
2704# then
2705# mydefargs="--enable-static $mydefargs"
2706# fi
2707if test -z "`echo "$mydefargs" | grep "\-\-enable\-base" 2> /dev/null`"
2708then
2709 mydefargs="--enable-base=${mykeybase} $mydefargs"
2710fi
2711AC_SUBST(mydefargs)
2712
2713
2714AC_DEFINE_UNQUOTED(SH_INSTALL_DIR, _("${sbindir}"))
2715AC_DEFINE_UNQUOTED(SH_INSTALL_PATH, _("${sbindir}/${install_name}"))
2716AC_DEFINE_UNQUOTED(SH_INSTALL_NAME, _("${install_name}"))
2717
2718AC_CONFIG_HEADER(config.h)
2719
2720AC_OUTPUT(
2721[
2722Makefile
2723samhain-install.sh
2724init/samhain.startLSB
2725init/samhain.startLinux
2726init/samhain.startGentoo
2727init/samhain.startFreeBSD
2728init/samhain.startSolaris
2729init/samhain.startHPUX
2730init/samhain.startIRIX
2731init/samhain.startMACOSX
2732samhain.spec
2733rules.deb
2734rules.deb-light
2735hp_ux.psf
2736scripts/samhain.spec
2737scripts/redhat_i386.client.spec
2738scripts/samhain.ebuild
2739scripts/samhain.ebuild-light
2740scripts/samhainadmin.pl
2741scripts/yuleadmin.pl
2742scripts/check_samhain.pl
2743deploy.sh
2744],
2745[
2746echo timestamp > stamp-h
2747chmod +x samhain-install.sh
2748chmod +x scripts/samhainadmin.pl
2749chmod +x scripts/yuleadmin.pl
2750chmod +x scripts/check_samhain.pl
2751]
2752)
2753
2754chmod +x deploy.sh
2755
2756if test "x${cross_compiling}" = xyes
2757then
2758
2759echo "--------------------------------------------------------------"
2760echo
2761echo "You are using a cross-compiler. The following system dependent"
2762echo "values may have been set to default values that may be"
2763echo "incorrect for your target system: "
2764echo
2765echo "ac_cv_c_bigendian bigendian byte order ${ac_cv_c_bigendian}"
2766echo "ac_cv_c_long_double long double exists ${ac_cv_c_long_double}"
2767echo "ac_cv_sizeof_char_p size of pointer to char ${ac_cv_sizeof_char_p}"
2768echo "ac_cv_sizeof_char_p size of size_t ${ac_cv_sizeof_size_t}"
2769echo "ac_cv_sizeof_unsigned_int size of unsigned int ${ac_cv_sizeof_unsigned_int}"
2770echo "ac_cv_sizeof_unsigned_long size of unsigned long ${ac_cv_sizeof_unsigned_long}"
2771echo "ac_cv_sizeof_unsigned_short size of unsigned short ${ac_cv_sizeof_unsigned_short}"
2772echo
2773echo "If these values are incorrect, change them in the file "
2774echo "config.cache and run configure again."
2775echo
2776echo "--------------------------------------------------------------"
2777
2778fi
2779
2780if test x${silent} != xyes
2781then
2782
2783 # A=`eval echo ${sbindir}` ; A=`eval echo ${A}`
2784 # B=`eval echo ${myconffile}` ; B=`eval echo ${B}`
2785 # C=`eval echo ${mandir}` ; C=`eval echo ${C}`
2786 # D=`eval echo ${mylockfile}` ; D=`eval echo ${D}`
2787 # E=`eval echo ${mylogfile}` ; E=`eval echo ${E}`
2788 # F=`eval echo ${mydataroot}` ; F=`eval echo ${F}`
2789
2790 echo
2791 echo " samhain has been configured as follows:"
2792 echo " System binaries: ${sbindir}"
2793 echo " Configuration file: ${myconffile}"
2794 echo " Manual pages: ${mandir}"
2795 echo " Data: ${mydataroot}"
2796 echo " PID file: ${mylockfile}"
2797 echo " Log file: ${mylogfile}"
2798 echo " Base key: ${mykeybase}"
2799 if test x"$mykeyid" != x
2800 then
2801 echo " target GPG/PGP key: ${mykeyid}"
2802 fi
2803 echo
2804 if test x"$mytclient" = x"-DSH_WITH_SERVER"
2805 then
2806 echo " Selected rc file: yulerc"
2807 else
2808 echo " Selected rc file: samhainrc.${selectconfig}"
2809 fi
2810
2811fi
2812
Note: See TracBrowser for help on using the repository browser.