Ethereal-dev: [Ethereal-dev] Preliminary heimdal autoconf support

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Sun, 14 Mar 2004 12:04:26 +0100
Ronnie,

the attached patch is somewhat hacked together.
It will define HAVE_KERBEROS and HAVE_HEIMDAL_KERBEROS in the way
your kerberos patches use them.
The default behaviour is to not check (and thus use) kerberos. It
has to be requested explicitly with the --with-krb5 configure option.
Please test and report back (feel free to check it in if it works)

 Ciao
  Jörg

PS: Others are free to test too :-)
PPS: Running this on a Suse 9.0 system did not work out of the box
    because /usr/lib/libkrb5.la and /usr/lib/libroken.la brought
    in -ldb but linking didn't work. Until I find the real cause,
    I've just removed -ldb from the two files.


-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/ethereal/configure.in,v
retrieving revision 1.250
diff -p -u -r1.250 configure.in
--- configure.in	4 Mar 2004 06:28:42 -0000	1.250
+++ configure.in	14 Mar 2004 10:44:53 -0000
@@ -701,6 +701,31 @@ fi
 
 AC_SUBST(SNMP_LIBS)
 
+dnl Just a dummy to make this option visible in toplevel confiugre.
+dnl Used (and implemented) in epan/configure
+AC_ARG_WITH(krb5,
+changequote(<<, >>)dnl
+<<  --with-krb5[=DIR]       use kerberos/heimdal (located in directory DIR, if supplied) to use in kerberos dissection  [default=no, if present]>>,
+changequote([, ])dnl
+[
+	if test $withval = no
+	then
+		want_krb5=no
+	elif test $withval = yes
+	then
+		want_krb5=yes
+	else
+		want_krb5=no
+		krb5_dir=$withval
+	fi
+],[
+	#
+	# Use kerberos/heimdal if it's present, otherwise don't.
+	#
+	want_krb5=ifpresent
+	krb5_dir=
+])
+
 dnl ADNS Check
 ADNS_LIBS=''
 AC_MSG_CHECKING(whether to use the GNU ADNS library if available)
Index: epan/Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/ethereal/epan/Makefile.am,v
retrieving revision 1.40
diff -p -u -r1.40 Makefile.am
--- epan/Makefile.am	13 Mar 2004 10:15:35 -0000	1.40
+++ epan/Makefile.am	14 Mar 2004 10:44:57 -0000
@@ -119,7 +119,7 @@ MAINTAINERCLEANFILES =	\
 #
 # Add the object files for missing routines, if any.
 #
-libethereal_la_LIBADD = @INET_ATON_O@ @INET_PTON_O@ @INET_NTOP_O@ dfilter/libdfilter.la ftypes/libftypes.la
+libethereal_la_LIBADD = @INET_ATON_O@ @INET_PTON_O@ @INET_NTOP_O@ dfilter/libdfilter.la ftypes/libftypes.la @KRB5_LIBS@
 libethereal_la_DEPENDENCIES = @INET_ATON_O@ @INET_PTON_O@ @INET_NTOP_O@ dfilter/libdfilter.la ftypes/libftypes.la
 
 ../packet-ncp2222.c : $(srcdir)/../ncp2222.py
Index: epan/acinclude.m4
===================================================================
RCS file: /usr/local/cvsroot/ethereal/epan/acinclude.m4,v
retrieving revision 1.6
diff -p -u -r1.6 acinclude.m4
--- epan/acinclude.m4	17 Dec 2003 02:41:04 -0000	1.6
+++ epan/acinclude.m4	14 Mar 2004 10:44:57 -0000
@@ -288,3 +288,116 @@ AC_DEFUN(AC_ETHEREAL_LIBPCRE_CHECK,
 		AC_SUBST(PCRE_LIBS)
 	fi
 ])
+
+#
+# AC_ETHEREAL_KRB5_CHECK
+#
+AC_DEFUN(AC_ETHEREAL_KRB5_CHECK,
+[
+	if test "x$krb5_dir" != "x"
+	then
+	  #
+	  # The user specified a directory in which kerberos resides,
+	  # so add the "include" subdirectory of that directory to
+	  # the include file search path and the "lib" subdirectory
+	  # of that directory to the library search path.
+	  #
+	  # XXX - if there's also a kerberos in a directory that's
+	  # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
+	  # make us find the version in the specified directory,
+	  # as the compiler and/or linker will search that other
+	  # directory before it searches the specified directory.
+	  #
+	  ethereal_save_CFLAGS="$CFLAGS"
+	  CFLAGS="$CFLAGS -I$krb5_dir/include"
+	  ethereal_save_CPPFLAGS="$CPPFLAGS"
+	  CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
+	  ethereal_save_LIBS="$LIBS"
+	  LIBS="$LIBS -lkrb5 -lasn1 -lcrypto -lroken -lcrypt -lresolv"
+	  ethereal_save_LDFLAGS="$LDFLAGS"
+	  LDFLAGS="$LDFLAGS -L$krb5_dir/lib"
+	else
+	  AC_PATH_PROG(KRB5_CONFIG, krb5-config) 
+	  if test -x $KRB5_CONFIG
+	  then
+	    KRB5_FLAGS=`$KRB5_CONFIG --cflags`
+	    CFLAGS="$CFLAGS $KRB5_FLAGS"
+            CPPFLAGS="$CPPFLAGS $KRB5_FLAGS"
+	    KRB5_LIBS=`$KRB5_CONFIG --libs`
+	    LIBS="$LIBS $KRB5_LIBS"
+ 	  fi
+	fi
+
+	#
+	# Make sure we have "krb5.h".  If we don't, it means we probably
+	# don't have kerberos, so don't use it.
+	#
+	AC_CHECK_HEADER(krb5.h,,
+	  [
+	    if test "x$krb5_dir" != "x"
+	    then
+	      #
+	      # The user used "--with-krb5=" to specify a directory
+	      # containing kerberos, but we didn't find the header file
+	      # there; that either means they didn't specify the
+	      # right directory or are confused about whether kerberos
+	      # is, in fact, installed.  Report the error and give up.
+	      #
+	      AC_MSG_ERROR([kerberos header not found in directory specified in --with-krb5])
+	    else
+	      if test "x$want_krb5" = "xyes"
+	      then
+		#
+		# The user tried to force us to use the library, but we
+		# couldn't find the header file; report an error.
+		#
+		AC_MSG_ERROR(Header file krb5.h not found.)
+	      else
+		#
+		# We couldn't find the header file; don't use the
+		# library, as it's probably not present.
+		#
+		want_krb5=no
+	      fi
+	    fi
+	  ])
+
+	if test "x$want_krb5" != "xno"
+	then
+		#
+		# Well, we at least have the krb5 header file.
+		#
+		AC_CHECK_LIB(krb5, krb5_kt_resolve,
+		[
+			if test "x$krb5_dir" != "x"
+			then
+				#
+				# Put the "-I" and "-L" flags for pcre at
+				# the beginning of CFLAGS, CPPFLAGS,
+				# LDFLAGS, and LIBS.
+				#
+				KRB5_LIBS="-L$krb5_dir/lib $KRB5_LIBS"
+			fi
+			AC_DEFINE(HAVE_KERBEROS, 1, [Define to use kerberos])
+			AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define to use heimdal kerberos])
+		],[
+			if test "x$krb5_dir" != "x"
+			then
+				#
+				# Restore the versions of CFLAGS, CPPFLAGS,
+				# LDFLAGS, and LIBS before we added the
+				# "--with-krb5=" directory, as we didn't
+				# actually find kerberos there.
+				#
+				CFLAGS="$ethereal_save_CFLAGS"
+				CPPFLAGS="$ethereal_save_CPPFLAGS"
+				LDFLAGS="$ethereal_save_LDFLAGS"
+				LIBS="$ethereal_save_LIBS"
+				KRB5_LIBS=""
+			fi
+			want_krb5=no
+		])
+		AC_SUBST(KRB5_LIBS)
+	fi
+])
+
Index: epan/configure.in
===================================================================
RCS file: /usr/local/cvsroot/ethereal/epan/configure.in,v
retrieving revision 1.66
diff -p -u -r1.66 configure.in
--- epan/configure.in	13 Mar 2004 10:15:35 -0000	1.66
+++ epan/configure.in	14 Mar 2004 10:44:58 -0000
@@ -178,6 +178,43 @@ else
 	AC_ETHEREAL_IPV6_STACK
 fi
 
+
+dnl kerberos/heimdal check
+AC_MSG_CHECKING(whether to use kerberos/heimdal)
+
+AC_ARG_WITH(krb5,
+changequote(<<, >>)dnl
+<<  --with-krb5[=DIR]       use kerberos/heimdal (located in directory DIR, if supplied) to use in kerberos dissection  [default=no]>>,
+changequote([, ])dnl
+[
+	if test $withval = no
+	then
+		want_krb5=no
+	elif test $withval = yes
+	then
+		want_krb5=yes
+	else
+		want_krb5=no
+		krb5_dir=$withval
+	fi
+],[
+	#
+	# Use kerberos/heimdal if it's present, otherwise don't.
+	#
+	want_krb5=no
+	krb5_dir=
+])
+if test "x$want_krb5" = "xno" ; then
+        AC_MSG_RESULT(no)
+else
+        AC_MSG_RESULT(yes)
+        AC_ETHEREAL_KRB5_CHECK
+	if test "x$want_krb5" = "xno" ; then
+		AC_MSG_RESULT(heimdal not found - disabling dissection for some kerberos data in packet decoding)
+	fi
+fi
+
+
 AC_CHECK_FUNC(inet_aton, INET_ATON_O="",
   INET_ATON_O="inet_aton.lo")
 if test "$ac_cv_func_inet_aton" = no ; then