Re: [Database-devel] Actual CVS doesn't compile

Sandro Poppi <[email protected]>
Newsgroups gmane.comp.security.nessus.devel
Message-ID <[email protected]>
Javier,

Thanks for the update. I had finally success compiling and running it 
but had to do some more changes:

In configure.in I added the test for --with-mysql-library since it 
didn't work without out it (see attached file). This is due to the fact 
that on my redhat 9.0 system the headers are in /usr/include/mysql while 
the library is at /usr/lib/mysql.

If I use e.g. db_host = localhost in nessusd.conf instead of db_host= 
localhost the variable name is set to "db_host " instead of "db_host". 
This is true for db_host, db_user, db_pass. db_database works either 
way! Maybe there is something wrong in preferences.c?

Additionally there is a typo in the dia file which results in a wrong 
table name in nessus_db_schema.mysql: knowservice instead of knownservice.

In nessus-extract.pl line 152 is doubled which fires an error when run.

And finally the version still states 2.0.8 but I suppose it should be 
2.0.10a, right?

Cheers,
Sandro
> 
> Just FYI, the code now autoconfigures and compiles fine, I've also done 
> some testing and it works OK. I would appreciate reports on how it works 
> for other people.
> 
>> BTW: I have managed to adapt nessus_db_schema.mysql, nessus-extract.pl 
>> and create-service-proto.pl to work with mysql on my RedHat 9 box 
>> which I could provide if anyone is interested.
> 
> 
> I have not yet reviewed all the changes you sent (I have just updated 
> the mysql file and the documentation). I will review it soon, though.
> 
> Regards
> 
> Javier
> 
> 

-- 
"Linux is like a wigwam: no windows, no gates ... apache inside!"

http://www.lug-burghausen.org/

_______________________________________________
Nessus-devel mailing list
[email protected]
http://mail.nessus.org/mailman/listinfo/nessus-devel
configure.in (text/plain, 28.6 KB)
dnl
dnl autoconf script for Nessus
dnl

dnl
dnl Supported options :
dnl
dnl --enable-release
dnl --enable-debug
dnl --enable-pthreads 	(experimental dont use dont use dont use!)
dnl --enable-syslog
dnl --enable-gtk
dnl --enable-unix-socket


AC_INIT(.root-dir)
AC_REVISION($Revision: 1.115.2.5 $)dnl

dnl version stuff -- jordan
save_IFS="${IFS}"
IFS=.
read NESSUS_MAJOR NESSUS_MINOR NESSUS_PATCH <VERSION
IFS="${save_IFS}"
NESSUS_DATE=\"`date '+%b %d, %Y'`\"
expr 0 + $NESSUS_MAJOR + $NESSUS_MINOR + $NESSUS_PATCH + 0 >/dev/null ||
AC_MSG_ERROR([ *** Panic: Corrupt version file])

test "x$prefix" != "xNONE" || prefix=/usr/local


dnl Set up the main lines of the config script
AC_CONFIG_HEADER(include/config.h)
AC_PREFIX_DEFAULT("/usr/local")
AC_CANONICAL_HOST
AC_LANG_C

dnl Check for several programs
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_INSTALL
INSTALL_DIR="$INSTALL -d"

uname_output=`uname`
case "$uname_output" in 
 *CYGWIN*)
 	is_cygwin=$uname_output
	AC_DEFINE(_CYGWIN_)
	;;
 *)
 	is_cygwin=""
	;;
esac


test -n "$GCC" && CWALL="-Wall"


test "x$enable_language" = x && enable_language="english"
test "x$enable_syslog" = "x" && enable_syslog="yes";
test "x$enable_syslog" = "xno" && unset enable_syslog
test "x$enable_gtk" = "x" && enable_gtk="yes"
test "x$enable_save_kb" = "x" && enable_save_kb="yes"
test "x$enable_save_sessions" = "x" && enable_save_sessions="yes"


nessus_lib=-lnessus

dnl extending the search path for AC_PATH_PROG when searching for config scripts
XPATH="$DESTDIR$prefix/bin:$PATH"
	

dnl User options

AC_ARG_ENABLE(release,[  --enable-release	  set the compiler flags to -O6],
	CFLAGS="-O6")

AC_ARG_ENABLE(debug,[  --enable-debug	  set the compiler flags to -g],[
	CFLAGS="-g"; debug_flags="-DDEBUG"])
	      
AC_ARG_ENABLE(install,[  --enable-install=user	  for debugging, install as non-root user],
	installuser=$enable_install)
: ${installuser:=root}

test -n "$is_cygwin" && {
  test "$installuser" = "root" && 
  {
   installuser=`whoami`
  }
}

AC_ARG_ENABLE(syslog,[  --enable-syslog	  log messages via syslog()],
	AC_DEFINE(USE_SYSLOG))

AC_ARG_ENABLE(gtk,[  --enable-gtk		  build with GTK],
        test $enable_gtk = yes && gtk_flags="-DUSE_GTK" && AC_DEFINE(USE_GTK))

AC_ARG_ENABLE(tcpwrappers,[  --enable-tcpwrappers	  use the libwrap.a library],
        libwrap="-lwrap")
	
	
AC_ARG_ENABLE(save-sessions, [  --enable-save-sessions  save the tests on the server side],
	AC_DEFINE(ENABLE_SAVE_TESTS))
	
AC_ARG_ENABLE(save-kb, [  --enable-save-kb  	  save the information gathered from the remote 
			  hosts)],
	AC_DEFINE(ENABLE_SAVE_KB), enable_save_kb="no")

default_directory="/usr /usr/local"

AC_DEFUN(FAIL_MESSAGE,[
   echo
   echo
   echo "**********************************************"
   echo "  ERROR: unable to find" $1
   echo "  checked in the following places"
   for i in `echo $2`; do
     echo "        $i"
   done
   echo "**********************************************"
   echo
   exit
])


# Keep the previous state to check later
OLIBS=$LIBS

AC_ARG_WITH(mysql, 
    [  --with-mysql=DIR        support for mysql],
    [ with_mysql="$withval" ],
    [ with_mysql=no ])

if test "$with_mysql" != "no"; then
  if test "$with_mysql" = "yes"; then
    mysql_directory="$default_directory"; 
    mysql_fail="yes"
  elif test -d $withval; then
    mysql_directory="$withval"
    mysql_fail="no"
  elif test "$with_mysql" = ""; then
    mysql_directory="$default_directory"; 
    mysql_fail="no"
  fi

  AC_MSG_CHECKING(for mysql)

  for i in $mysql_directory; do
    if test -r $i/include/mysql/mysql.h; then
      MYSQL_DIR=$i
      MYSQL_INC_DIR=$i/include/mysql
    elif test -r $i/include/mysql.h; then
      MYSQL_DIR=$i
      MYSQL_INC_DIR=$i/include
    elif test -r $i/mysql.h; then
      MYSQL_DIR=$i
      MYSQL_INC_DIR=$i
    fi
  done

  if test -z "$MYSQL_DIR"; then
    if test "$mysql_fail" != "no"; then
      tmp=""
      for i in $mysql_directory; do
        tmp="$tmp $i/include $i/include/mysql $i" 
      done
      FAIL_MESSAGE("mysql headers (mysql.h)", $tmp)
    else
      AC_MSG_RESULT(no)
    fi
  else
    AC_MSG_RESULT(yes)
  fi

  dnl add --with-mysql-library option, needed e.g. on RedHat 9
  AC_MSG_CHECKING(for mysql library libmysqlclient)

  AC_ARG_WITH(mysql_library,
        [  --with-mysql-library=DIR	mysql libs directory],
	[ with_mysql_lib="$withval" ],
	[ with_mysql_lib=no ])

  if test "$with_mysql_lib" != "no"; then
    MYSQL_LIB_DIR="$with_mysql_lib";
  else
    for i in lib lib/mysql; do
      str="$MYSQL_DIR/$i/libmysqlclient.*"
      for j in `echo $str`; do
        if test -r $j; then
          MYSQL_LIB_DIR="$MYSQL_DIR/$i"
          break 2
        fi
      done
    done
  fi

  if test -z "$MYSQL_LIB_DIR"; then
    if test "$mysql_fail" != "no"; then
      FAIL_MESSAGE("mysqlclient library", 
                   "$MYSQL_DIR/lib $MYSQL_DIR/lib/mysql")
    else
      AC_MSG_RESULT(no)
    fi
  else
    AC_MSG_RESULT(yes)
    LDFLAGS="${LDFLAGS} -L${MYSQL_LIB_DIR}"
    CPPFLAGS="${CPPFLAGS} -I${MYSQL_INC_DIR}"
    CFLAGS="${CFLAGS} -DUSE_MYSQL -I${MYSQL_INC_DIR}"
    AC_CHECK_LIB(z, compress)
    LIBS="${LIBS} -lmysqlclient"
  fi
fi

AC_ARG_WITH(odbc, 
    [  --with-odbc=DIR         support for odbc],
    [ with_odbc="$withval" ],
    [ with_odbc=no ])

if test "$with_odbc" != "no"; then
  if test "$with_odbc" = "yes"; then
    odbc_directory="$default_directory"
    odbc_fail="yes"
  elif test -d $withval; then
    odbc_directory="$withval $default_directory";
    odbc_fail="yes"
  elif test "$with_odbc" = ""; then
    odbc_directory="$default_directory"
    odbc_fail="no"
  fi

  AC_MSG_CHECKING("for odbc")

  for i in $odbc_directory; do
    if test -r $i/include/sql.h; then
    if test -r $i/include/sqlext.h; then
    if test -r $i/include/sqltypes.h; then
      ODBC_DIR=$i
      ODBC_INC_DIR=$i/include
    fi fi fi
  done

  if test -z "$ODBC_DIR"; then
    if test "$odbc_fail" != "no"; then
      tmp=""
      for i in $odbc_directory; do
        tmp="$tmp $i/include"
      done
      FAIL_MESSAGE("odbc headers (sql.h sqlext.h sqltypes.h)", $tmp)
    else
      AC_MSG_RESULT(no)
    fi
  else

    str="$ODBC_DIR/lib/libodbc.*"
    for j in `echo $str`; do
      if test -r $j; then 
        ODBC_LIB_DIR="$ODBC_DIR/lib"
        ODBC_LIB="odbc"
      fi
    done

dnl    if test -z "$ODBC_LIB_DIR"; then
dnl      str="$ODBC_DIR/lib/libiodbc.*"
dnl      for j in `echo $str`; do
dnl        if test -r $j; then 
dnl          ODBC_LIB_DIR="$ODBC_DIR/lib"
dnl          ODBC_LIB="iodbc"
dnl        fi
dnl      done
dnl    fi

    if test -z "$ODBC_LIB_DIR"; then
      if test "$odbc_fail" != "no"; then
        FAIL_MESSAGE("odbc library (libodbc)", "$ODBC_DIR/lib")
      else
        AC_MSG_RESULT(no)
      fi
    else
      AC_MSG_RESULT(yes)
      LDFLAGS="${LDFLAGS} -L${ODBC_LIB_DIR}"
      CPPFLAGS="${CPPFLAGS} -I${ODBC_INC_DIR}"
      CFLAGS="${CFLAGS} -DUSE_ODBC"
      LIBS="${LIBS} -l$ODBC_LIB"
    fi
  fi
fi

AC_ARG_WITH(postgresql, 
    [  --with-postgresql=DIR   support for postgresql],
    [ with_postgresql="$withval" ],
    [ with_postgresql=no ])

if test "$with_postgresql" != "no"; then
  if test "$with_postgresql" = "yes"; then
    postgresql_directory="$default_directory /usr/local/pgsql /usr/pgsql /usr/local"
    postgresql_fail="yes"
  elif test -d $withval; then
    postgresql_directory="$withval $default_directory /usr/local/pgsql /usr/pgsql"
    postgresql_fail="yes"
  elif test "$with_postgresql" = ""; then
    postgresql_directory="$default_directory /usr/local/pgsql /usr/pgsql"
    postgresql_fail="no"
  fi

  AC_MSG_CHECKING(for postgresql)

  for i in $postgresql_directory; do
    if test -r $i/include/pgsql/libpq-fe.h; then
      POSTGRESQL_DIR=$i
      POSTGRESQL_INC_DIR=$i/include/pgsql
    elif test -r $i/include/libpq-fe.h; then
      POSTGRESQL_DIR=$i
      POSTGRESQL_INC_DIR=$i/include
    elif test -r $i/include/postgresql/libpq-fe.h; then
      POSTGRESQL_DIR=$i
      POSTGRESQL_INC_DIR=$i/include/postgresql
    fi
  done

  if test -z "$POSTGRESQL_DIR"; then
    if test "$postgresql_fail" != "no"; then
      tmp=""
      for i in $postgesql_directory; do
        tmp="$tmp $i/include $i/include/pgsql"
      done
      FAIL_MESSAGE("postgresql header file (libpq-fe.h)", $tmp)
    else
      AC_MSG_RESULT(no)
    fi
  else

    for i in lib lib/pgsql; do
      str="$POSTGRESQL_DIR/$i/libpq.*"
      for j in `echo $str`; do
        if test -r $j; then
          POSTGRESQL_LIB_DIR="$POSTGRESQL_DIR/$i"
          break 2
        fi
      done
    done

    if test -z "$POSTGRESQL_LIB_DIR"; then
      if test "$postgresql_fail" != "no"; then
        FAIL_MESSAGE("postgresql library libpq",
        "$POSTGRESQL_DIR/lib $POSTGRESQL_DIR/lib/pgsql")
      else
        AC_MSG_RESULT(no);
      fi
    else
      AC_MSG_RESULT(yes)
      LDFLAGS="${LDFLAGS} -L${POSTGRESQL_LIB_DIR}"
      CPPFLAGS="${CPPFLAGS} -I${POSTGRESQL_INC_DIR}"
      CFLAGS="${CFLAGS} -DUSE_POSTGRESQL"
      LIBS="${LIBS} -lpq"
    fi
  fi
fi


AC_ARG_WITH(oracle, 
    [  --with-oracle=DIR       support for oracle],
    [ with_oracle="$withval" ],
    [ with_oracle=no ])

if test "$with_oracle" != "no"; then
  if test "$with_oracle" = "yes"; then
    oracle_directory="$default_directory ${ORACLE_HOME}"
    oracle_fail="yes"
  elif test -d $withval; then
    oracle_directory="$withval $default_directory ${ORACLE_HOME}"
    oracle_fail="yes"
  elif test "$with_oracle" = ""; then
    oracle_directory="$default_directory ${ORACLE_HOME}"
    oracle_fail="no"
  fi

  AC_MSG_CHECKING(for oracle)

  for i in $oracle_directory; do
    if test -r $i/rdbms/demo/oci.h; then
      ORACLE_DIR=$i
    fi
  done

  if test -z "$ORACLE_DIR"; then
    if test "$oracle_fail" != "no"; then
      tmp=""
      for i in $oracle_directory; do
        tmp="$tmp $i/rdbms/demo"
      done
      FAIL_MESSAGE("OCI header file (oci.h)", $tmp)
    else
      AC_MSG_RESULT(no)
    fi
  else
    for i in rdbms/demo rdbms/public network/public; do
      ORACLE_CPP_FLAGS="$ORACLE_CPP_FLAGS -I$ORACLE_DIR/$i"
    done
    ORACLE_LIB_DIR="$ORACLE_DIR/lib"
    AC_MSG_RESULT(yes)

    LDFLAGS="${LDFLAGS} -L${ORACLE_LIB_DIR}"
    CPPFLAGS="${CPPFLAGS} ${ORACLE_CPP_FLAGS} -DUSE_ORACLE"
    CFLAGS="${CFLAGS} -DUSE_ORACLE"

    ORACLE_LIBS="-lclntsh"
    if test -r $ORACLE_LIB_DIR/libwtc9.so; then
      ORACLE_LIBS="${ORACLE_LIBS} -lwtc9"
    elif test -r $ORACLE_LIB_DIR/libwtc8.so; then
      ORACLE_LIBS="${ORACLE_LIBS} -lwtc8"
    fi
    LIBS="${LIBS} ${ORACLE_LIBS}"
  fi
fi

# Check if we have added any library
if test "${OLIBS}" != "${LIBS}" ; then
	CFLAGS="${CFLAGS} -DUSE_DATABASE"
fi



AC_PATH_PROG(NESSUSCONFIG, nessus-config,,$XPATH)

test "x$NESSUSCONFIG" = x && AC_ERROR(""
""
"*** nessus-libraries is not installed ! You need to install it before you"
"compile nessus-core."
"Get it at ftp://ftp.nessus.org/pub/nessus/")

AC_PATH_PROG(NASLCONFIG, nasl-config,,$XPATH)

test "x$NASLCONFIG" = x &&  AC_ERROR(""
""
"*** libnasl is not installed ! You need to install it before you "
"compile nessus-core."
""
"Get it at ftp:/ftp.nessus.org/pub/nessus/")



AC_ARG_ENABLE(unix-socket,[  --enable-unix-socket[=/path]	use a unix socket for client server communication],	  
	AC_DEFINE(USE_AF_UNIX))


test "x$enable_unix_socket" != "x" -a "x$enable_unix_socket" != "xyes" &&
 {
 AC_DEFINE_UNQUOTED(AF_UNIX_PATH, "$enable_unix_socket")
 }



dnl only vanilla sed can handle long substitution lines
NESSCFLAGS="`$NESSUSCONFIG --cflags`"
NASLCFLAGS="`$NASLCONFIG --cflags`"

egdpath="`$NESSUSCONFIG --egd`"
saveCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $NESSCFLAGS $NASLCFLAGS"

dnl Check for several headers
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_HEADER_DIRENT
AC_CHECK_HEADERS(unistd.h getopt.h string.h strings.h sys/sockio.h sys/socketio.h)
AC_CHECK_HEADERS(sys/param.h netinet/tcpip.h netinet/in_systm.h)
AC_CHECK_HEADERS(netinet/ip_udp.h netinet/protocols.h sys/ioctl.h netinet/ip_icmp.h)
AC_CHECK_HEADERS(rpc/rpc.h netinet/udp.h dlfcn.h sys/un.h memory.h ctype.h errno.h)
AC_CHECK_HEADERS(sys/types.h stdlib.h stdio.h sys/filio.h pwd.h)
AC_CHECK_HEADERS(assert.h netdb.h netinet/in.h arpa/inet.h)
AC_CHECK_HEADERS(poll.h sys/poll.h netinet/ip_tcp.h fcntl.h signal.h limits.h)
AC_CHECK_HEADERS(sys/stat.h stat.h net/if.h sys/mman.h sys/resource.h dl.h)
AC_CHECK_HEADERS(pty.h termio.h termios.h sgtty.h libutil.h setjmp.h values.h)

dnl ./configure fails to determine the existence of some 
dnl headers under IRIX

case "$host" in
 *-irix*)
    AC_DEFINE(HAVE_SYS_SOCKET_H)
    AC_DEFINE(HAVE_NETINET_IP_H)
    AC_DEFINE(HAVE_NETINET_TCP_H)
    ;;
 *)
    AC_CHECK_HEADERS(sys/socket.h netinet/ip.h netinet/tcp.h)
    ;;
esac


dnl Check for several functions
AC_FUNC_ALLOCA
AC_FUNC_WAIT3
dnl wait4 is tested below
AC_CHECK_FUNCS(waitpid wait4 mmap atexit)
AC_CHECK_FUNCS(lstat memmove gettimeofday gethrtime getrusage rand)
AC_CHECK_FUNCS(strchr memcpy select poll)
AC_CHECK_FUNC(vsnprintf,AC_DEFINE(HAVE_VSNPRINTF))
AC_CHECK_FUNCS(bzero bcopy setsid rint mkstemp)
AC_CHECK_FUNCS(addr2ascii inet_neta setproctitle _exit)

dnl Check for sevral types and guess our byte ordering
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)
AC_C_BIGENDIAN
AC_CHECK_TYPE(time_t,int)
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T

dnl this routine has been adopted from the GNU emacs20 distrubution
AC_MSG_CHECKING(for struct timeval)
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif], [static struct timeval x; x.tv_sec = x.tv_usec;],
  [AC_MSG_RESULT(yes)
   HAVE_TIMEVAL=yes
   AC_DEFINE(HAVE_TIMEVAL)],
  [AC_MSG_RESULT(no)
   HAVE_TIMEVAL=no])


dnl Check for the number of arguments for gettimeofday (), this routine
dnl has been adopted from the GNU emacs20 distrubution
if test "x$HAVE_TIMEVAL" = xyes; then
AC_MSG_CHECKING(whether gettimeofday can't accept two arguments)
AC_TRY_LINK([
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
  ],
  [
  struct timeval time;
  struct timezone dummy;
  gettimeofday (&time, &dummy);
],
  [AC_MSG_RESULT(no)],
  [AC_MSG_RESULT(yes)
   AC_DEFINE(GETTIMEOFDAY_ONE_ARGUMENT)])
fi


BROKEN_REGEXP=""
#
# RedHat 8.0 ships with a broken regexp library (Nessus bug#90)
#
test -f /etc/redhat-release && 
{
 cat /etc/redhat-release | egrep "(8\.0|9)" >/dev/null && BROKEN_REGEXP=y
 }
 

test -z "$BROKEN_REGEXP" &&
{
AC_MSG_CHECKING([for a working regexp implementation])
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <regex.h>

int main()
{
  char fastmap[1 << 8];
  struct re_pattern_buffer pb;
  struct re_registers regs;
 
  pb.allocated = 8;
  pb.buffer = malloc(8);
  pb.fastmap = fastmap;
  pb.translate = 0;
  re_set_syntax(RE_SYNTAX_POSIX_EGREP);
  re_compile_pattern(".*nessus.*", strlen(".*nessus.*"), &pb);
  re_compile_fastmap(&pb);
  return re_search(&pb, 
  		"i use nessus everyday",
		strlen("i use nessus everyday"),
		0, 
  		strlen("i use nessus everyday"),
		&regs);
}
], [AC_MSG_RESULT([yes]);AC_DEFINE(HAVE_REGEX_SUPPORT)],[AC_MSG_RESULT([no])])
}

dnl Check that the struct ip has member ip_csum
AC_MSG_CHECKING([struct ip contains ip_csum])
AC_TRY_COMPILE([#ifdef __linux__
#define __BSD_SOURCE
#define _BSD_SOURCE
#define __FAVOR_BSD
#endif
#include <sys/types.h> 
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>],
[
struct ip ip;
ip.ip_csum = 0;
],	       
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_IP_CSUM)],
[AC_MSG_RESULT(no);])

dnl Check whether we have to redefine the structs ip and icmp
AC_MSG_CHECKING([struct ip]) 
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>],
                [struct ip ip;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_IP)],
[AC_MSG_RESULT(no)])
 
AC_MSG_CHECKING([struct icmp])
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>],
                [struct icmp icmp;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_ICMP)],
[AC_MSG_RESULT(no)])

AC_MSG_CHECKING([struct udphdr])
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/udp.h>],
                [struct udphdr udp;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_UDPHDR)],
[AC_MSG_RESULT(no)])

AC_MSG_CHECKING([BSD struct udphdr])
AC_TRY_COMPILE([#ifdef __linux__
#define __BSD_SOURCE
#define _BSD_SOURCE
#define __FAVOR_BSD
#endif
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/udp.h>],
                [struct udphdr udp;udp.uh_dport = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_BSD_STRUCT_UDPHDR)],
[AC_MSG_RESULT(no)])


AC_MSG_CHECKING([struct tcphdr])
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>],
                [struct tcphdr tcp;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_TCPHDR)],
[AC_MSG_RESULT(no)])

AC_MSG_CHECKING([struct tcphdr has th_off])
AC_TRY_COMPILE([#include <sys/types.h>
#ifdef __linux__
#define __FAVOR_BSD
#endif
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>],
                [struct tcphdr tcp;tcp.th_off = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TCPHDR_TH_OFF)],
[AC_MSG_RESULT(no)])

AC_MSG_CHECKING([struct tcphdr has th_x2_off])
AC_TRY_COMPILE([#include <sys/types.h>
#ifdef __linux__
#define __FAVOR_BSD
#endif
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>],
                [struct tcphdr tcp;tcp.th_x2_off = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TCPHDR_TH_X2_OFF)],
[AC_MSG_RESULT(no)])

dnl Define several paths


AC_PATH_X
AC_PATH_XTRA
PWDD=`pwd`	
AC_SYS_LONG_FILE_NAMES

dnl need support libs before checking nessuslib_phtreads_enabled
AC_HAVE_LIBRARY(rpcsvc, rpcsvc_lib="-lrpcsvc")   
AC_CHECK_LIB(rpcsvc, xdr_mon, AC_DEFINE(HAVE_XDR_MON))


AC_CHECK_LIB(compat, lfind, compat_lib="-lcompat")



test -n "$resolv_lib" && (AC_CHECK_LIB(resolv, inet_neta, AC_DEFINE(HAVE_INET_NETA)))


test -n "$libwrap" && {
	AC_HAVE_LIBRARY(wrap,, AC_ERROR("The switch --enable-tcpwrappers has been set but your system lacks libwrap !"))
	AC_CHECK_HEADER(tcpd.h,,AC_ERROR("The switch --enable-tcpwrappers has been set but your system lacks tcpd.h !"))
	uselibwrap="-DUSE_LIBWRAP"
	}
AC_CHECK_LIB(c, inet_aton, AC_DEFINE(HAVE_INET_ATON))
AC_CHECK_LIB(resolv, inet_aton, AC_DEFINE(HAVE_INET_ATON))

dnl Check for the libraries we may want to use
AC_CHECK_LIB(dl, dlopen, [dl_lib="-ldl" ; AC_DEFINE(HAVE_DL_LIB)])
AC_CHECK_FUNCS(shl_load)
AC_CHECK_FUNCS(NSCreateObjectFileImageFromFile)

# Libs are defined by nessusconfiguration and previously determined LIBS
NLIBS=`$NESSUSCONFIG --libs` 
LIBS="$NLIBS $LIBS"

AC_CHECK_LIB(nessus, nessuslib_pthreads_enabled, use_pthreads="-DUSE_PTHREADS -DTHREADS -D_REENTRANT")

test "$use_pthreads" && {
	AC_CHECK_HEADERS(pthread.h)
	dnl Check if we have a lame pthread header
	AC_MSG_CHECKING([if we have a broken pthread_cleanup_push])
	AC_TRY_COMPILE([#include <pthread.h>
	],
    		[void main(){pthread_cleanup_push(NULL,NULL);}],
	[AC_MSG_RESULT(no)],
	[AC_MSG_RESULT(yes);AC_DEFINE(BROKEN_PTHREAD_CLEANUP_PUSH)])

	
	AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread")
	AC_CHECK_LIB(c_r, gethostbyname_r, c_r_lib="-lc_r")
	AC_CHECK_LIB(c_r, pthread_create, c_r_lib="-lc_r")
	AC_CHECK_LIB(c, gethostbyname_r, AC_DEFINE(HAVE_GETHOSTBYNAME_R))
	AC_CHECK_LIB(c_r, gethostbyname_r, AC_DEFINE(HAVE_GETHOSTBYNAME_R))
	AC_CHECK_LIB(nsl, gethostbyname_r, AC_DEFINE(HAVE_GETHOSTBYNAME_R))
	AC_CHECK_LIB(pthread, pthread_cancel,AC_DEFINE(HAVE_PTHREAD_CANCEL))
	AC_CHECK_LIB(c_r, pthread_cancel,AC_DEFINE(HAVE_PTHREAD_CANCEL))
	AC_MSG_CHECKING([whether gethostbyname_r takes 5 args])
	AC_TRY_COMPILE([
#define THREADS 1
#define _REENTRANT 1
#include <sys/types.h>
#include <netdb.h>],
[
 const char * name;
 struct hostent * result;
 char * buffer;
 int buflen;
 int h_errnop;
 
 gethostbyname_r(name, result, buffer, buflen, h_errnop);
]
, solaris_gethostbyname_r=yes)

	test "x$solaris_gethostbyname_r" = "x" && AC_MSG_RESULT([no])
	test "x$solaris_gethostbyname_r" = "x" || AC_MSG_RESULT([yes])
	test "x$solaris_gethostbyname_r" = "xyes" && AC_DEFINE(HAVE_SOLARIS_GETHOSTBYNAME_R)

	AC_MSG_CHECKING([whether gethostbyaddr_r takes 5 args])
	AC_TRY_COMPILE([
#define THREADS 1
#define _REENTRANT 1
#include <sys/types.h>
#include <netdb.h>],
[
 const char * addr;
 int length;
 int type;
 struct hostent *result;
 char * buffer;
 int buflen;
 int * h_errnop;
 
 gethostbyaddr_r(addr, length, type, result, buffer, buflen, h_errnop);]
, solaris_gethostbyaddr_r=yes)

	test "x$solaris_gethostbyaddr_r" = "x" && AC_MSG_RESULT([no])
	test "x$solaris_gethostbyaddr_r" = "x" || AC_MSG_RESULT([yes])

	test "x$solaris_gethostbyaddr_r" = "xyes" && AC_DEFINE(HAVE_SOLARIS_GETHOSTBYADDR_R)

dnl end section using pthreads
}

dnl dnl Our defines
dnl AC_DEFINE_UNQUOTED(NESS_COMPILER, "`$CC -v 2>&1 | tail -1`")
dnl AC_DEFINE_UNQUOTED(NESS_OS_NAME, "`uname -s`")
dnl AC_DEFINE_UNQUOTED(NESS_OS_VERSION, "`uname -r`")

dnl version defines have been extracted to a separate file
NESS_COMPILER="`$CC -v 2>&1 | tail -1`"
NESS_OS_NAME="`uname -s`"
NESS_OS_VERSION="`uname -r`"
test "$use_pthreads" = "" && unset pthread_lib


dnl I prefer to compile a C program rather than trusting the env. variables...


dnl This test is from the configure.in of Unix Network Programming second
dnl edition example code by W. Richard Stevens
dnl ##################################################################
dnl Check if sockaddr{} has sa_len member.
dnl
AC_CACHE_CHECK(if sockaddr{} has sa_len member, ac_cv_sockaddr_has_sa_len,
        AC_TRY_COMPILE([
#               include <sys/types.h>
#               include <sys/socket.h>],
                [unsigned int i = sizeof(((struct sockaddr *)0)->sa_len)],
        ac_cv_sockaddr_has_sa_len=yes,
        ac_cv_sockaddr_has_sa_len=no))
if test $ac_cv_sockaddr_has_sa_len = yes ; then
        AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
fi



case "$host" in
    *-freebsd*|*-bsdi*|*-netbsd*)
    AC_DEFINE(BSD_BYTE_ORDERING)
esac



case "$host" in
  *-netbsd*)
    AC_DEFINE(NETBSD)
    ;;
  *-openbsd*)
    AC_DEFINE(OPENBSD)
    ;;
  *-sgi-irix5*)
    AC_DEFINE(IRIX)
    no_libsocket=yes
    no_libnsl=yes
    if test -z "$GCC"; then
      sgi_cc=yes
    fi
    ;;
  *-sgi-irix6*)
    AC_DEFINE(IRIX)
    no_libsocket=yes
    no_libnsl=yes
    if test -z "$GCC"; then
      sgi_cc=yes
    fi
    ;;
  *-solaris2.0*)  
    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
    AC_DEFINE(SOLARIS)
    ;;
  *-solaris2.1*)
    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
    AC_DEFINE(SOLARIS)
    ;;
  *-solaris2.2*)
    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
    AC_DEFINE(SOLARIS)
    ;;
  *-solaris2.3*)
    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
    AC_DEFINE(SOLARIS)
    ;;
  *-solaris2.4*)
    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
    AC_DEFINE(SOLARIS)
    ;;
  *-solaris2.5.1)
    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
    AC_DEFINE(SOLARIS)
    ;;
  *-solaris*)
    AC_DEFINE(SOLARIS)
    ;;
  *-sunos4*)
    AC_DEFINE(SUNOS)
    AC_DEFINE(SPRINTF_RETURNS_STRING)
    no_libnsl=yes
    no_libsocket=yes
    ;;
  *-linux*)
    linux=yes
    AC_DEFINE(LINUX)
    AC_DEFINE(PCAP_TIMEOUT_IGNORED)  # libpcap doesn't even LOOK at
                                     # the timeout you give it under Linux
    ;;
  *-freebsd*)
    AC_DEFINE(FREEBSD)
    ;;
  *-bsdi*)
    AC_DEFINE(BSDI)
    ;;
esac



AC_MSG_CHECKING([whether struct sigaction has sa_restorer])
	AC_TRY_COMPILE([
#include <signal.h>],
[
 struct sigaction sa;
 
 sa.sa_restorer = 0;
]
, signal_sa_restorer=yes)

	test "x$signal_sa_restorer" = "x" && AC_MSG_RESULT([no])
	test "x$signal_sa_restorer" = "x" || AC_MSG_RESULT([yes])
	test "x$signal_sa_restorer" = "xyes" && AC_DEFINE(HAVE_SIGNAL_SA_RESTORER)

	

if test "x$enable_gtk" = "xno"; then
    client=client
    client_install=client-install
else
    unset client
    unset client_install
fi


AC_PATH_PROG(GTKCONFIG, gtk-config,,$XPATH)
test "x$GTKCONFIG" = x && {
	AC_PATH_PROG(GTKCONFIG, gtk12-config,,$XPATH)
	test "x$GTKCONFIG" = x && AC_PATH_PROG(GTKCONFIG, gtk10-config,,$XPATH)
	}
	
	
	
test "$GTKCONFIG" || {
  AC_PATH_PROG(PKGCONFIG, pkg-config,,$XPATH)
  test -z "$PKGCONFIG" &&
	AC_WARN("**** gtk-config not found.")
}


	
test -n "$GTKCONFIG" -o "$PKGCONFIG" &&
{
 client=client
 client_install=client-install
 test -n "$GTKCONFIG" && GTKVERSION=`$GTKCONFIG --version`
 test -z "$GTKCONFIG" && GTKVERSION=`$PKGCONFIG --modversion gtk+-2.0`
 AC_MSG_CHECKING([GTK version])
 AC_MSG_RESULT($GTKVERSION)
 GTK_VERSION=`echo $GTKVERSION | sed 's/\./ /g' | awk {'print $1$2'}`
 test -n "$GTK_VERSION" && AC_DEFINE_UNQUOTED(GTK_VERSION,$GTK_VERSION)
}

test -n "$GTKCONFIG" && 
{
AC_PATH_PROG(GLIBCONFIG, glib-config,,$XPATH)
test "x$GLIBCONFIG" = x && {
       AC_PATH_PROG(GLIBCONFIG, glib12-config,,$XPATH)
       }
}


lang=$enable_language




dnl the -R option that comes with X_LIBS usually overwrites the
dnl LD_RUN_PATH value (eg. on Solaris)


test "x$enable_gtk" = "xno" ||
{
 test -n "$PKGCONFIG" &&
  {
   GTKCONFIG_CFLAGS=`$PKGCONFIG --cflags gtk+-2.0`
   GTKCONFIG_LIBS=`$PKGCONFIG --libs gtk+-2.0`
  }
  
  
  test -n "$GTKCONFIG" && 
  {
 case `${GTKCONFIG} --libs` in
 *-R\ *)	RUN_LIBS='-R ${libdir}' ;;
 *-R*)	RUN_LIBS='-R${libdir}' ;;
 esac
 
 GTKCONFIG_CFLAGS=`$GTKCONFIG --cflags`
 GTKCONFIG_LIBS=`$GTKCONFIG --libs`
 }
 
 test -n "$GLIBCONFIG" && {
 GLIBCONFIG_CFLAGS=`$GLIBCONFIG --cflags`
 GLIBCONFIG_LIBS=`$GLIBCONFIG --libs`
 }

 
 
}


dnl only vanilla sed can handle long substitution lines
CFLAGS="$saveCFLAGS"

dnl
dnl AC_CONFIG_SUBDIRS(src/libpcap) -- not used, anymore
dnl
dnl Final step : substitute what we want to

NESSUSD_CONFDIR='${sysconfdir}'
NESSUSD_STATEDIR='${localstatedir}/nessus'
NESSUSD_SHAREDSTATEDIR='${sharedstatedir}/nessus'
NESSUSD_DATADIR='${sysconfdir}/nessus'
NESSUSD_LIBDIR='${libdir}/nessus'
NESSUSD_LOGDIR='${localstatedir}/nessus/logs'

NESSUSD_PLUGINS='${NESSUSD_LIBDIR}/plugins'
NESSUSD_REPORTS='${NESSUSD_LIBDIR}/reports'

 
# The following directories are now passed into the compile
# by the makefile instead of setting at the time configure is run.
# Thus we only need to set these once and all the quoting and 
# everything works okay.
#
#AC_DEFINE_UNQUOTED(NESSUSD_CONFDIR,   "${sysconfdir}")
#AC_DEFINE(NESSUSD_STATEDIR,  "${localstatedir}/nessus'")
#AC_DEFINE(NESSUSD_DATADIR,   "'${sysconfdir}/nessus")
#AC_DEFINE(NESSUSD_LIBDIR,    "${libdir}/nessus")
#AC_DEFINE(NESSUSD_PLUGINS,   "${libdir}/nessus/plugins")
#AC_DEFINE(NESSUSD_REPORTS,   "${libdir}/nessus/reports")
man_nessus_1=doc/nessus.1
man_nessusd_8=doc/nessusd.8

AC_DEFINE_UNQUOTED(NESSUSD_LANGUAGE,  "${lang}")

AC_PATH_PROG(AR, ar)
AC_SUBST(AR)
AC_SUBST(PWD)
AC_SUBST(PWDD)
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(NESSCFLAGS)
AC_SUBST(NASLCFLAGS)
AC_SUBST(CWALL)
AC_SUBST(GTK_VERSION)
AC_SUBST(NESSUS_MAJOR)
AC_SUBST(NESSUS_MINOR)
AC_SUBST(NESSUS_PATCH)
AC_SUBST(NESSUS_DATE)
AC_SUBST(NESS_COMPILER)
AC_SUBST(NESS_OS_NAME)
AC_SUBST(NESS_OS_VERSION)
AC_SUBST(NESSUSD_CONFDIR)
AC_SUBST(NESSUSD_STATEDIR)
AC_SUBST(NESSUSD_SHAREDSTATEDIR)
AC_SUBST(NESSUSD_DATADIR)
AC_SUBST(NESSUSD_LIBDIR)
AC_SUBST(NESSUSD_PLUGINS)
AC_SUBST(NESSUSD_REPORTS)
AC_SUBST(NESSUSD_LOGDIR)
AC_SUBST(CWALL)
AC_SUBST(INSTALL_DIR)
AC_SUBST(INSTALL)
AC_SUBST(RUN_LIBS)
AC_SUBST(resolv_lib)
AC_SUBST(socket_lib)
AC_SUBST(nsl_lib)
AC_SUBST(ssl_lib)
AC_SUBST(pthread_lib)
AC_SUBST(gtk_flags)
AC_SUBST(debug_flags)
AC_SUBST(nessus_lib)
AC_SUBST(man_nessus_1)
AC_SUBST(man_nessusd_8)
AC_SUBST(dl_lib)
AC_SUBST(libwrap)
AC_SUBST(uselibwrap)
AC_SUBST(client)
AC_SUBST(client_install)
AC_SUBST(use_pthreads)
AC_SUBST(rpcsvc_lib)
AC_SUBST(compat_lib)
AC_SUBST(c_r_lib)
AC_SUBST(datadir)
AC_SUBST(NESSUSCONFIG)
AC_SUBST(NASLCONFIG)
AC_SUBST(GTKCONFIG_CFLAGS)
AC_SUBST(GTKCONFIG_LIBS)
AC_SUBST(GLIBCONFIG_CFLAGS)
AC_SUBST(GLIBCONFIG_LIBS)
AC_SUBST(ac_configure_args)
AC_SUBST(egdpath)
AC_SUBST(is_cygwin)
AC_SUBST(installuser)


dnl And we put everything in the appropriate files
AC_OUTPUT(nessus.tmpl include/corevers.h nessus-adduser nessus-rmuser nessus-mkcert nessus-mkcert-client)


chmod +x nessus-adduser nessus-mkcert nessus-mkcert-client


test "x$enable_gtk" = "xno" ||
{
test -z "$GTKCONFIG" -a -z "$PKGCONFIG" && {
AC_WARN(gtk-config could not be found : the client will not be built. \
If you want to build a command-line only client then type ./configure --disable-gtk)
}

test -n "$PKGCONFIG" && {
AC_WARN(Only gtk+-2.0 was found : the client will be built but will be extremely buggy. \
Install gtk+-1.2 if you want stability. If you do not understand why you would \
want to install version 1.2.x when you have 2.0.x  send a mail to the GTK+ team \
(www.gtk.org) and complain about their inability to handle backward compatibility)
}
}

exit 0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.