TCP Wrappers has a rather unique (and some might say broken) API.  It
requests that the caller define two global variables, and sometimes the
compile-time linker will insist on seeing these definitions even if the
calling code never invokes anything from the libwrap library -- its
presence on the linker command-line is sufficient.  This causes no end
of problems with builds on some implementations of shared libraries
derived from SunOS-4.x (eg. with the *BSDs).  (This is of course a bug
in the *BSD implementations, since the original SunOS-4.x implementation
never suffered from such utter stupidity, but we live with what we have.)

Furthermore the configure.in tests in SSH-2.4.0 will never ever (well,
at least rarely) find the correct tcpd.h header file for TCP Wrappers.

The following patch fixes these bugs, yet again, for SSH-2.4.0:

Index: configure.in
===================================================================
RCS file: /cvs/misc/ssh2/configure.in,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 configure.in
*** configure.in        2001/02/20 22:39:02     1.1.1.2
--- configure.in        2001/02/21 02:06:33
***************
*** 911,951 ****
  )
  
  AC_MSG_CHECKING(whether to use libwrap)
  AC_ARG_WITH(libwrap,
  [  --with-libwrap[=PATH]   Compile in libwrap (tcp_wrappers) support.],
! [ case "$withval" in
    no)
-     AC_MSG_RESULT(no)
      ;;
!   yes)
!     AC_MSG_RESULT(yes)
!     AC_CHECK_LIB(wrap, request_init, 
!                  [ AC_DEFINE(LIBWRAP)
!                    LIBS="-lwrap $LIBS"
!                    AC_DEFINE(HAVE_LIBWRAP)],
!                  [ AC_MSG_ERROR(Could not find libwrap library. You have to install 
tcp-wrappers before using --with-libwrap option to configure.) ])
      ;;
    *)
      if test -d "$withval"; then
!         LIBS="-L$withval -lwrap $LIBS"
!         CFLAGS="-I$withval $CFLAGS"
      else
!         LIBS="$withval $LIBS"
!       changequote(<<, >>)dnl
!       tcpd_path="`echo $withval | sed -e 's@\(.*\)/[^/]*@\1@'`"
!       changequote([, ])dnl
!         CFLAGS="-I$tcpd_path $CFLAGS"
      fi
-     AC_TRY_LINK([ int allow_severity; int deny_severity; ],
-                 [ hosts_access(); ],
-               [ AC_MSG_RESULT($withval) 
-                   AC_DEFINE(LIBWRAP)
-                   AC_DEFINE(HAVE_LIBWRAP) ],
-               [ AC_MSG_ERROR(Could not find the $withval library. Did you specify a 
valid path?) ])
      ;;
!   esac ],
    AC_MSG_RESULT(no)
  )
  
  # This allows group writeability in userfile_check_owner_permissions()
  AC_MSG_CHECKING(whether to allow group writeability)
--- 911,958 ----
  )
  
  AC_MSG_CHECKING(whether to use libwrap)
+ LIBWRAP_LIB=""
+ LIBWRAP_INC=""
  AC_ARG_WITH(libwrap,
  [  --with-libwrap[=PATH]   Compile in libwrap (tcp_wrappers) support.],
! [ AC_MSG_RESULT($withval)
!   case "$withval" in
    no)
      ;;
!   ""|yes)
!     LIBWRAP_LIB="-lwrap"
      ;;
    *)
      if test -d "$withval"; then
!       LIBWRAP_LIB="-L$withval -lwrap"
!       LIBWRAP_INC="-I`dirname $withval`/include"
      else
!       LIBWRAP_LIB="$withval"
!       LIBWRAP_INC="-I`dirname $withval`"
      fi
      ;;
!   esac
!   if test -n "$LIBWRAP_LIB"; then
!     OLDLIBS="$LIBS"
!     LIBS="$LIBWRAP_LIB $LIBS"
!     OLDCFLAGS="$CFLAGS"
!     CFLAGS="$CFLAGS $LIBWRAP_INC"
!     AC_CHECK_HEADER(tcpd.h,
!                   [],
!                   [ AC_MSG_ERROR(Could not find tcpd.h for libwrap.  You must first 
install tcp_wrappers.) ])
!     AC_TRY_LINK([ #include <tcpd.h>
!                 int allow_severity; int deny_severity; ],
!                 [ hosts_access((struct request_info *) 0); ],
!               [ AC_DEFINE(LIBWRAP)
!                   AC_DEFINE(HAVE_LIBWRAP) ],
!               [ AC_MSG_ERROR(Could not find the libwrap library.  Did you specify a 
valid path?) ])
!     LIBS="$OLDLIBS"
!     CFLAGS="$OLDCFLAGS"
!   fi ],
    AC_MSG_RESULT(no)
  )
+ AC_SUBST(LIBWRAP_LIB)
+ AC_SUBST(LIBWRAP_INC)
  
  # This allows group writeability in userfile_check_owner_permissions()
  AC_MSG_CHECKING(whether to allow group writeability)
Index: apps/ssh/Makefile.am
===================================================================
RCS file: /cvs/misc/ssh2/apps/ssh/Makefile.am,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 Makefile.am
*** apps/ssh/Makefile.am        2001/02/20 22:39:23     1.1.1.2
--- apps/ssh/Makefile.am        2001/02/21 01:50:00
***************
*** 330,341 ****
  #
  #
  ssh2_DEPENDENCIES = $(DEPENDENCIES)
! ssh2_LDADD = @PAM_CLIENT_LIBS@ $(LDADD)
  ssh2_LDFLAGS = -o $@
  
  sshd2_SOURCES = sshd2.c
  sshd2_DEPENDENCIES = $(DEPENDENCIES)
! sshd2_LDADD = @PAM_DAEMON_LIBS@ $(LDADD)
  sshd2_LDFLAGS = -o $@
  
  ssh_agent2_SOURCES = ssh-agent2.c
--- 330,341 ----
  #
  #
  ssh2_DEPENDENCIES = $(DEPENDENCIES)
! ssh2_LDADD = @PAM_CLIENT_LIBS@ $(LDADD) @LIBWRAP_LIB@
  ssh2_LDFLAGS = -o $@
  
  sshd2_SOURCES = sshd2.c
  sshd2_DEPENDENCIES = $(DEPENDENCIES)
! sshd2_LDADD = @PAM_DAEMON_LIBS@ $(LDADD) @LIBWRAP_LIB@
  sshd2_LDFLAGS = -o $@
  
  ssh_agent2_SOURCES = ssh-agent2.c
***************
*** 409,415 ****
  
  # defines
  
! SSH_DEFS = -DETCDIR=\"$(etcdir)\" -DSSH_BINDIR=\"$(bindir)\"
  
  COMPILE = $(CC) $(KERBEROS_INCS) $(INCLUDES) $(SSH_DEFS) $(DEFS) $(CPPFLAGS) 
$(CFLAGS) $(X_CFLAGS)
  LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS)
--- 409,415 ----
  
  # defines
  
! SSH_DEFS = -DETCDIR=\"$(etcdir)\" -DSSH_BINDIR=\"$(bindir)\" @LIBWRAP_INC@
  
  COMPILE = $(CC) $(KERBEROS_INCS) $(INCLUDES) $(SSH_DEFS) $(DEFS) $(CPPFLAGS) 
$(CFLAGS) $(X_CFLAGS)
  LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS)

-- 
                                                        Greg A. Woods

+1 416 218-0098      VE3TCP      <[EMAIL PROTECTED]>      <robohack!woods>
Planix, Inc. <[EMAIL PROTECTED]>; Secrets of the Weird <[EMAIL PROTECTED]>

Reply via email to