source: trunk/configure.ac@ 414

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

Enhancements for ticket #312 (logrotate) and #313 (--enable-suid).

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