walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
49b3311
diff --git a/Makefile.am b/Makefile.am
49b3311
index 88ae210..b3a6e91 100644
49b3311
--- a/Makefile.am
49b3311
+++ b/Makefile.am
49b3311
@@ -40,7 +40,12 @@ EXTRA_DIST = \
49b3311
 	aclocal/bsdsignals.m4 \
49b3311
 	aclocal/nfs-utils.m4 \
49b3311
 	aclocal/kerberos5.m4 \
49b3311
-	aclocal/tcp-wrappers.m4
49b3311
+	aclocal/tcp-wrappers.m4 \
49b3311
+	aclocal/libtirpc.m4 \
49b3311
+	aclocal/libevent.m4 \
49b3311
+	aclocal/libnfsidmap.m4 \
49b3311
+	aclocal/rpcsec_vers.m4 \
49b3311
+	aclocal/ipv6.m4
49b3311
 
49b3311
 ACLOCAL_AMFLAGS = -I aclocal
49b3311
 
49b3311
diff --git a/aclocal/ipv6.m4 b/aclocal/ipv6.m4
49b3311
new file mode 100644
49b3311
index 0000000..0564b3e
49b3311
--- /dev/null
49b3311
+++ b/aclocal/ipv6.m4
49b3311
@@ -0,0 +1,29 @@
49b3311
+dnl Checks for IPv6 support
49b3311
+dnl
49b3311
+AC_DEFUN([AC_IPV6], [
49b3311
+
49b3311
+  AC_CHECK_DECL([AI_ADDRCONFIG],
49b3311
+                [AC_DEFINE([HAVE_DECL_AI_ADDRCONFIG], 1,
49b3311
+                           [Define this to 1 if AI_ADDRCONFIG macro is defined])], ,
49b3311
+                [ #include <netdb.h> ])
49b3311
+
49b3311
+  if test "$enable_ipv6" = yes; then
49b3311
+
49b3311
+    dnl TI-RPC required for IPv6
49b3311
+    if test "$enable_tirpc" = no; then
49b3311
+      AC_MSG_ERROR(['--enable-ipv6' requires '--enable-tirpc'.])
49b3311
+    fi
49b3311
+
49b3311
+    dnl IPv6-enabled networking functions required for IPv6
49b3311
+    AC_CHECK_FUNCS([getnameinfo bindresvport_sa], , ,
49b3311
+                   [AC_MSG_ERROR([Missing functions needed for IPv6.])])
49b3311
+
49b3311
+    dnl Need to detect presence of IPv6 networking at run time via
49b3311
+    dnl getaddrinfo(3); old versions of glibc do not support ADDRCONFIG
49b3311
+    AC_CHECK_DECL([AI_ADDRCONFIG], ,
49b3311
+                  [AC_MSG_ERROR([full getaddrinfo(3) implementation needed for IPv6 support])],
49b3311
+                  [ #include <netdb.h> ])
49b3311
+
49b3311
+  fi
49b3311
+
49b3311
+])dnl
49b3311
diff --git a/aclocal/libevent.m4 b/aclocal/libevent.m4
49b3311
new file mode 100644
49b3311
index 0000000..3c962b3
49b3311
--- /dev/null
49b3311
+++ b/aclocal/libevent.m4
49b3311
@@ -0,0 +1,11 @@
49b3311
+dnl Checks for libevent
49b3311
+AC_DEFUN([AC_LIBEVENT], [
49b3311
+
49b3311
+  dnl Check for libevent, but do not add -levent to LIBS
49b3311
+  AC_CHECK_LIB([event], [event_dispatch], [libevent=1],
49b3311
+               [AC_MSG_ERROR([libevent not found.])])
49b3311
+
49b3311
+  AC_CHECK_HEADERS([event.h], ,
49b3311
+                   [AC_MSG_ERROR([libevent headers not found.])])
49b3311
+
49b3311
+])dnl
49b3311
diff --git a/aclocal/libnfsidmap.m4 b/aclocal/libnfsidmap.m4
49b3311
new file mode 100644
49b3311
index 0000000..cfcde2f
49b3311
--- /dev/null
49b3311
+++ b/aclocal/libnfsidmap.m4
49b3311
@@ -0,0 +1,17 @@
49b3311
+dnl Checks for libnfsidmap
49b3311
+dnl
49b3311
+AC_DEFUN([AC_LIBNFSIDMAP], [
49b3311
+
49b3311
+  dnl Check for libnfsidmap, but do not add -lnfsidmap to LIBS
49b3311
+  AC_CHECK_LIB([nfsidmap], [nfs4_init_name_mapping], [libnfsidmap=1],
49b3311
+               [AC_MSG_ERROR([libnfsidmap not found.])])
49b3311
+
49b3311
+  AC_CHECK_HEADERS([nfsidmap.h], ,
49b3311
+                   [AC_MSG_ERROR([libnfsidmap headers not found.])])
49b3311
+
49b3311
+  dnl nfs4_set_debug() doesn't appear in all versions of libnfsidmap
49b3311
+  AC_CHECK_LIB([nfsidmap], [nfs4_set_debug],
49b3311
+               [AC_DEFINE([HAVE_NFS4_SET_DEBUG], 1,
49b3311
+                          [Define to 1 if you have the `nfs4_set_debug' function.])])
49b3311
+
49b3311
+])dnl
49b3311
diff --git a/aclocal/librpcsecgss.m4 b/aclocal/librpcsecgss.m4
49b3311
new file mode 100644
49b3311
index 0000000..d1dd25e
49b3311
--- /dev/null
49b3311
+++ b/aclocal/librpcsecgss.m4
49b3311
@@ -0,0 +1,19 @@
49b3311
+dnl Checks for rpcsecgss library and headers
49b3311
+dnl KRB5LIBS must be set before this function is invoked.
49b3311
+dnl
49b3311
+AC_DEFUN([AC_LIBRPCSECGSS], [
49b3311
+
49b3311
+  dnl libtirpc provides an rpcsecgss API
49b3311
+  if test "$enable_tirpc" = no; then
49b3311
+
49b3311
+    dnl Check for library, but do not add -lrpcsecgss to LIBS
49b3311
+    AC_CHECK_LIB([rpcsecgss], [authgss_create_default], [librpcsecgss=1],
49b3311
+                 [AC_MSG_ERROR([librpcsecgss not found.])])
49b3311
+
49b3311
+    AC_CHECK_LIB([rpcsecgss], [authgss_set_debug_level],
49b3311
+                 [AC_DEFINE([HAVE_AUTHGSS_SET_DEBUG_LEVEL], 1,
49b3311
+                 [Define to 1 if you have the `authgss_set_debug_level' function.])])
49b3311
+
49b3311
+  fi
49b3311
+
49b3311
+])dnl
49b3311
diff --git a/aclocal/libtirpc.m4 b/aclocal/libtirpc.m4
49b3311
new file mode 100644
49b3311
index 0000000..af4c7d3
49b3311
--- /dev/null
49b3311
+++ b/aclocal/libtirpc.m4
49b3311
@@ -0,0 +1,28 @@
49b3311
+dnl Checks for TI-RPC library and headers
49b3311
+dnl
49b3311
+AC_DEFUN([AC_LIBTIRPC], [
49b3311
+
49b3311
+  AC_ARG_WITH([tirpcinclude],
49b3311
+              [AC_HELP_STRING([--with-tirpcinclude=DIR],
49b3311
+                              [use TI-RPC headers in DIR])],
49b3311
+              [tirpc_header_dir=$withval],
49b3311
+              [tirpc_header_dir=/usr/include/tirpc])
49b3311
+
49b3311
+  dnl if --enable-tirpc was specifed, the following components
49b3311
+  dnl must be present, and we set up HAVE_ macros for them.
49b3311
+
49b3311
+  if test "$enable_tirpc" = yes; then
49b3311
+
49b3311
+    dnl look for the library; add to LIBS if found
49b3311
+    AC_CHECK_LIB([tirpc], [clnt_tli_create], ,
49b3311
+                 [AC_MSG_ERROR([libtirpc not found.])])
49b3311
+
49b3311
+    dnl also must have the headers installed where we expect
49b3311
+    dnl look for headers; add -I compiler option if found
49b3311
+    AC_CHECK_HEADERS([${tirpc_header_dir}/netconfig.h], ,
49b3311
+                     [AC_MSG_ERROR([libtirpc headers not found.])])
49b3311
+    AC_SUBST([AM_CPPFLAGS], ["-I${tirpc_header_dir}"])
49b3311
+
49b3311
+  fi
49b3311
+
49b3311
+])dnl
49b3311
diff --git a/aclocal/rpcsec_vers.m4 b/aclocal/rpcsec_vers.m4
49b3311
new file mode 100644
49b3311
index 0000000..e59c0aa
49b3311
--- /dev/null
49b3311
+++ b/aclocal/rpcsec_vers.m4
49b3311
@@ -0,0 +1,12 @@
49b3311
+dnl Checks librpcsec version
49b3311
+AC_DEFUN([AC_RPCSEC_VERSION], [
49b3311
+
49b3311
+  dnl TI-RPC replaces librpcsecgss, but we still need libgssglue
49b3311
+  if test "$enable_tirpc" = no; then
49b3311
+    PKG_CHECK_MODULES([RPCSECGSS], [librpcsecgss >= 0.16], ,
49b3311
+                      [AC_MSG_ERROR([Unable to locate information required to use librpcsecgss.  If you have pkgconfig installed, you might try setting environment variable PKG_CONFIG_PATH to /usr/local/lib/pkgconfig])])
49b3311
+  else
49b3311
+    PKG_CHECK_MODULES([GSSGLUE], [libgssglue >= 0.1])
49b3311
+  fi
49b3311
+
49b3311
+])dnl
49b3311
diff --git a/configure.ac b/configure.ac
49b3311
index 5db4417..e34b7e2 100644
49b3311
--- a/configure.ac
49b3311
+++ b/configure.ac
49b3311
@@ -118,6 +118,11 @@ AC_ARG_ENABLE(mount,
49b3311
 	enable_mount=$enableval,
49b3311
 	enable_mount=yes)
49b3311
 	AM_CONDITIONAL(CONFIG_MOUNT, [test "$enable_mount" = "yes"])
49b3311
+AC_ARG_ENABLE(tirpc,
49b3311
+	[AC_HELP_STRING([--enable-tirpc],
49b3311
+			[enable use of TI-RPC @<:@default=no@:>@])],
49b3311
+	enable_tirpc=$enableval,
49b3311
+	enable_tirpc=no)
49b3311
 AC_ARG_ENABLE(ipv6,
49b3311
 	[AC_HELP_STRING([--enable-ipv6],
49b3311
                         [enable support for IPv6 @<:@default=no@:>@])],
49b3311
@@ -131,13 +136,8 @@ AC_ARG_ENABLE(ipv6,
49b3311
 	AC_SUBST(enable_ipv6)
49b3311
 	AM_CONDITIONAL(CONFIG_IPV6, [test "$enable_ipv6" = "yes"])
49b3311
 
49b3311
-AC_ARG_ENABLE(tirpc,
49b3311
-	[AC_HELP_STRING([--enable-tirpc],
49b3311
-                        [enable use of TI-RPC @<:@default=no@:>@])],
49b3311
-	enable_tirpc=$enableval,
49b3311
-	enable_tirpc=no)
49b3311
-	AC_SUBST(enable_tirpc)
49b3311
-	AM_CONDITIONAL(CONFIG_TIRPC, [test "$enable_tirpc" = "yes"])
49b3311
+dnl Check for TI-RPC library and headers
49b3311
+AC_LIBTIRPC
49b3311
 
49b3311
 # Check whether user wants TCP wrappers support
49b3311
 AC_TCP_WRAPPERS
49b3311
@@ -176,39 +176,40 @@ AC_BSD_SIGNALS
49b3311
 dnl *************************************************************
49b3311
 dnl * Check for required libraries
49b3311
 dnl *************************************************************
49b3311
-AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname, [LIBNSL="-lnsl"])])
49b3311
+
49b3311
+AC_CHECK_FUNC([gethostbyname], ,
49b3311
+              [AC_CHECK_LIB([nsl], [gethostbyname], [LIBNSL="-lnsl"])])
49b3311
 AC_SUBST(LIBNSL)
49b3311
 
49b3311
-AC_CHECK_FUNC(connect, ,
49b3311
-      AC_CHECK_LIB(socket, connect, [LIBSOCKET="-lsocket"],
49b3311
-                AC_MSG_ERROR(Function 'socket' not found.), $LIBNSL))
49b3311
+AC_CHECK_FUNC([connect], ,
49b3311
+              [AC_CHECK_LIB([socket], [connect], [LIBSOCKET="-lsocket"],
49b3311
+                    [AC_MSG_ERROR([Function 'socket' not found.])], [$LIBNSL])])
49b3311
+
49b3311
+AC_CHECK_FUNC([getaddrinfo], , ,
49b3311
+              [AC_MSG_ERROR([Function 'getaddrinfo' not found.])])
49b3311
 
49b3311
-AC_CHECK_FUNC(getaddrinfo, , ,
49b3311
-                AC_MSG_ERROR(Function 'getaddrinfo' not found.))
49b3311
+AC_CHECK_FUNC([getrpcbynumber], , ,
49b3311
+              [AC_MSG_ERROR([Function 'getrpcbynumber' not found.])])
49b3311
 
49b3311
-AC_CHECK_FUNC(getrpcbynumber, , ,
49b3311
-                AC_MSG_ERROR(Function 'getrpcbynumber' not found.))
49b3311
+AC_CHECK_FUNC([getservbyname], , ,
49b3311
+              [AC_MSG_ERROR([Function 'getservbyname' not found.])])
49b3311
 
49b3311
-AC_CHECK_FUNC(getservbyname, , ,
49b3311
-                AC_MSG_ERROR(Function 'getservbyname' not found.))
49b3311
+AC_CHECK_LIB([crypt], [crypt], [LIBCRYPT="-lcrypt"])
49b3311
 
49b3311
-AC_CHECK_LIB(crypt, crypt, [LIBCRYPT="-lcrypt"])
49b3311
 if test "$enable_nfsv4" = yes; then
49b3311
-    AC_CHECK_LIB(event, event_dispatch, [libevent=1], AC_MSG_ERROR([libevent needed for nfsv4 support]))
49b3311
-    AC_CHECK_LIB(nfsidmap, nfs4_init_name_mapping, [libnfsidmap=1], AC_MSG_ERROR([libnfsidmap needed for nfsv4 support]))
49b3311
-    AC_CHECK_HEADERS(event.h, ,AC_MSG_ERROR([libevent needed for nfsv4 support]))
49b3311
-    AC_CHECK_HEADERS(nfsidmap.h, ,AC_MSG_ERROR([libnfsidmap needed for nfsv4 support]))
49b3311
-    dnl librpcsecgss already has a dependency on libgssapi,
49b3311
-    dnl but we need to make sure we get the right version
49b3311
-    if test "$enable_gss" = yes; then
49b3311
-     PKG_CHECK_MODULES(RPCSECGSS, librpcsecgss >= 0.16, ,
49b3311
-      [AC_MSG_ERROR([Unable to locate information required to use librpcsecgss.  If you have pkgconfig installed, you might try setting environment variable PKG_CONFIG_PATH to /usr/local/lib/pkgconfig])
49b3311
-      ]
49b3311
-     )
49b3311
-    PKG_CHECK_MODULES(GSSGLUE, libgssglue >= 0.1)
49b3311
-    fi
49b3311
+  dnl check for libevent libraries and headers
49b3311
+  AC_LIBEVENT
49b3311
+
49b3311
+  dnl check for nfsidmap libraries and headers
49b3311
+  AC_LIBNFSIDMAP
49b3311
 
49b3311
+  dnl librpcsecgss already has a dependency on libgssapi,
49b3311
+  dnl but we need to make sure we get the right version
49b3311
+  if test "$enable_gss" = yes; then
49b3311
+    AC_RPCSEC_VERSION
49b3311
+  fi
49b3311
 fi
49b3311
+
49b3311
 if test "$knfsd_cv_glibc2" = no; then
49b3311
     AC_CHECK_LIB(bsd, daemon, [LIBBSD="-lbsd"])
49b3311
 fi
49b3311
@@ -236,49 +237,21 @@ AC_SUBST(LIBBLKID)
49b3311
 
49b3311
 if test "$enable_gss" = yes; then
49b3311
   dnl 'gss' also depends on nfsidmap.h - at least for svcgssd_proc.c
49b3311
-  AC_CHECK_HEADERS(nfsidmap.h, ,AC_MSG_ERROR([libnfsidmap needed for gss support]))
49b3311
-  AC_CHECK_HEADERS(spkm3.h, ,AC_MSG_WARN([could not locate SPKM3 header; will not have SPKM3 support]))
49b3311
-  dnl the nfs4_set_debug function doesn't appear in all version of the library
49b3311
-  AC_CHECK_LIB(nfsidmap, nfs4_set_debug,
49b3311
-	       AC_DEFINE(HAVE_NFS4_SET_DEBUG,1,
49b3311
-			 [Whether nfs4_set_debug() is present in libnfsidmap]),)
49b3311
+  AC_LIBNFSIDMAP
49b3311
+
49b3311
+  AC_CHECK_HEADERS([spkm3.h], ,
49b3311
+                   [AC_MSG_WARN([Could not locate SPKM3 header; will not have SPKM3 support])])
49b3311
 
49b3311
   dnl Check for Kerberos V5
49b3311
   AC_KERBEROS_V5
49b3311
 
49b3311
-  dnl This is not done until here because we need to have KRBLIBS set
49b3311
-  dnl ("librpcsecgss=1" is so that it doesn't get added to LIBS)
49b3311
-  AC_CHECK_LIB(rpcsecgss, authgss_create_default, [librpcsecgss=1], AC_MSG_ERROR([librpcsecgss needed for nfsv4 support]), -lgssglue -ldl)
49b3311
-  AC_CHECK_LIB(rpcsecgss, authgss_set_debug_level,
49b3311
-  	       AC_DEFINE(HAVE_AUTHGSS_SET_DEBUG_LEVEL, 1, [Define this if the rpcsec_gss library has the function authgss_set_debug_level]),, -lgssglue -ldl)
49b3311
+  dnl Invoked after AC_KERBEROS_V5; AC_LIBRPCSECGSS needs to have KRBLIBS set
49b3311
+  AC_LIBRPCSECGSS
49b3311
 
49b3311
 fi
49b3311
 
49b3311
-AC_CHECK_DECL([AI_ADDRCONFIG],
49b3311
-              AC_DEFINE([HAVE_DECL_AI_ADDRCONFIG], 1,
49b3311
-                         [Define this to 1 if AI_ADDRCONFIG macro is defined]), ,
49b3311
-              [ #include <netdb.h> ] )
49b3311
-
49b3311
-if test "$enable_tirpc" = yes; then
49b3311
-  AC_CHECK_LIB(tirpc, clnt_tli_create, ,
49b3311
-           AC_MSG_ERROR([libtirpc not found.]))
49b3311
-  AC_CHECK_HEADERS(tirpc/netconfig.h, ,
49b3311
-                   AC_MSG_ERROR([libtirpc headers not found.]))
49b3311
-  AC_CHECK_FUNCS([bindresvport_sa getnetconfig \
49b3311
-                  clnt_create clnt_create_timed \
49b3311
-                  clnt_vc_create clnt_dg_create xdr_rpcb])
49b3311
-fi
49b3311
-
49b3311
-if test "$enable_ipv6" = yes; then
49b3311
-  if test "$enable_tirpc" = no; then
49b3311
-    AC_MSG_ERROR('--enable-ipv6' requires '--enable-tirpc'.)
49b3311
-  fi
49b3311
-  AC_CHECK_FUNC(getnameinfo, , ,
49b3311
-               AC_MSG_ERROR(Function 'getnameinfo' not found.))
49b3311
-  AC_CHECK_DECL([AI_ADDRCONFIG], ,
49b3311
-               AC_MSG_ERROR([full getaddrinfo(3) implementation needed for IPv6 support]),
49b3311
-               [ #include <netdb.h> ] )
49b3311
-fi
49b3311
+dnl Check for IPv6 support
49b3311
+AC_IPV6
49b3311
 
49b3311
 dnl *************************************************************
49b3311
 dnl Check for headers
49b3311
diff --git a/support/nfs/getport.c b/support/nfs/getport.c
49b3311
index 5da1749..734d21a 100644
49b3311
--- a/support/nfs/getport.c
49b3311
+++ b/support/nfs/getport.c
49b3311
@@ -40,9 +40,9 @@
49b3311
 #include <rpc/rpc.h>
49b3311
 #include <rpc/pmap_prot.h>
49b3311
 
49b3311
-#ifdef HAVE_TIRPC_NETCONFIG_H
49b3311
-#include <tirpc/netconfig.h>
49b3311
-#include <tirpc/rpc/rpcb_prot.h>
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
+#include <netconfig.h>
49b3311
+#include <rpc/rpcb_prot.h>
49b3311
 #endif
49b3311
 
49b3311
 #include "nfsrpc.h"
49b3311
@@ -53,17 +53,17 @@
49b3311
  * Rpcbind's local socket service does not seem to be working.
49b3311
  * Disable this logic for now.
49b3311
  */
49b3311
-#ifdef HAVE_XDR_RPCB
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 #undef NFS_GP_LOCAL
49b3311
-#else	/* HAVE_XDR_RPCB */
49b3311
+#else	/* !HAVE_LIBTIRPC */
49b3311
 #undef NFS_GP_LOCAL
49b3311
-#endif	/* HAVE_XDR_RPCB */
49b3311
+#endif	/* !HAVE_LIBTIRPC */
49b3311
 
49b3311
-#ifdef HAVE_XDR_RPCB
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 const static rpcvers_t default_rpcb_version = RPCBVERS_4;
49b3311
-#else
49b3311
+#else	/* !HAVE_LIBTIRPC */
49b3311
 const static rpcvers_t default_rpcb_version = PMAPVERS;
49b3311
-#endif
49b3311
+#endif	/* !HAVE_LIBTIRPC */
49b3311
 
49b3311
 #ifdef HAVE_DECL_AI_ADDRCONFIG
49b3311
 /*
49b3311
@@ -242,7 +242,7 @@ static CLIENT *nfs_gp_get_rpcbclient(const struct sockaddr *sap,
49b3311
  * Returns a '\0'-terminated string if successful; otherwise NULL.
49b3311
  * rpc_createerr.cf_stat is set to reflect the error.
49b3311
  */
49b3311
-#ifdef HAVE_XDR_RPCB
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 
49b3311
 static char *nfs_gp_get_netid(const sa_family_t family,
49b3311
 			      const unsigned short protocol)
49b3311
@@ -290,7 +290,7 @@ out:
49b3311
 	return NULL;
49b3311
 }
49b3311
 
49b3311
-#endif	/* HAVE_XDR_RPCB */
49b3311
+#endif	/* HAVE_LIBTIRPC */
49b3311
 
49b3311
 /*
49b3311
  * Extract a port number from a universal address, and terminate the
49b3311
@@ -453,7 +453,7 @@ static int nfs_gp_ping(CLIENT *client, struct timeval timeout)
49b3311
 	return (int)(status == RPC_SUCCESS);
49b3311
 }
49b3311
 
49b3311
-#ifdef HAVE_XDR_RPCB
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 
49b3311
 /*
49b3311
  * Initialize the rpcb argument for a GETADDR request.
49b3311
@@ -565,7 +565,7 @@ static unsigned short nfs_gp_rpcb_getaddr(CLIENT *client,
49b3311
 	return port;
49b3311
 }
49b3311
 
49b3311
-#endif	/* HAVE_XDR_RPCB */
49b3311
+#endif	/* HAVE_LIBTIRPC */
49b3311
 
49b3311
 /*
49b3311
  * Try GETPORT request via rpcbind version 2.
49b3311
@@ -595,7 +595,7 @@ static unsigned long nfs_gp_pmap_getport(CLIENT *client,
49b3311
 	return port;
49b3311
 }
49b3311
 
49b3311
-#ifdef HAVE_XDR_RPCB
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 
49b3311
 static unsigned short nfs_gp_getport_rpcb(CLIENT *client,
49b3311
 					  const struct sockaddr *sap,
49b3311
@@ -617,7 +617,7 @@ static unsigned short nfs_gp_getport_rpcb(CLIENT *client,
49b3311
 	return port;
49b3311
 }
49b3311
 
49b3311
-#endif	/* HAVE_XDR_RPCB */
49b3311
+#endif	/* HAVE_LIBTIRPC */
49b3311
 
49b3311
 static unsigned long nfs_gp_getport_pmap(CLIENT *client,
49b3311
 					 const rpcprog_t program,
49b3311
@@ -652,11 +652,11 @@ static unsigned short nfs_gp_getport(CLIENT *client,
49b3311
 				     struct timeval timeout)
49b3311
 {
49b3311
 	switch (sap->sa_family) {
49b3311
-#ifdef HAVE_XDR_RPCB
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 	case AF_INET6:
49b3311
 		return nfs_gp_getport_rpcb(client, sap, salen, program,
49b3311
 						version, protocol, timeout);
49b3311
-#endif	/* HAVE_XDR_RPCB */
49b3311
+#endif	/* HAVE_LIBTIRPC */
49b3311
 	case AF_INET:
49b3311
 		return nfs_gp_getport_pmap(client, program, version,
49b3311
 							protocol, timeout);
49b3311
@@ -922,7 +922,7 @@ unsigned short nfs_getlocalport(const rpcprot_t program,
49b3311
  * address of the same address family.  In this way an RPC server can
49b3311
  * advertise via rpcbind that it does not support AF_INET6.
49b3311
  */
49b3311
-#ifdef HAVE_XDR_RPCB
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 
49b3311
 unsigned short nfs_rpcb_getaddr(const struct sockaddr *sap,
49b3311
 				const socklen_t salen,
49b3311
@@ -955,7 +955,7 @@ unsigned short nfs_rpcb_getaddr(const struct sockaddr *sap,
49b3311
 	return port;
49b3311
 }
49b3311
 
49b3311
-#else	/* HAVE_XDR_RPCB */
49b3311
+#else	/* !HAVE_LIBTIRPC */
49b3311
 
49b3311
 unsigned short nfs_rpcb_getaddr(const struct sockaddr *sap,
49b3311
 				const socklen_t salen,
49b3311
@@ -971,7 +971,7 @@ unsigned short nfs_rpcb_getaddr(const struct sockaddr *sap,
49b3311
 	return 0;
49b3311
 }
49b3311
 
49b3311
-#endif	/* HAVE_XDR_RPCB */
49b3311
+#endif	/* !HAVE_LIBTIRPC */
49b3311
 
49b3311
 /**
49b3311
  * nfs_pmap_getport - query rpcbind via the portmap protocol (rpcbindv2)
49b3311
diff --git a/support/nfs/rpc_socket.c b/support/nfs/rpc_socket.c
49b3311
index b7420d1..2b11e35 100644
49b3311
--- a/support/nfs/rpc_socket.c
49b3311
+++ b/support/nfs/rpc_socket.c
49b3311
@@ -40,51 +40,10 @@
49b3311
 
49b3311
 #include "nfsrpc.h"
49b3311
 
49b3311
-#ifdef HAVE_TIRPC_NETCONFIG_H
49b3311
-
49b3311
-/*
49b3311
- * Most of the headers under /usr/include/tirpc are currently
49b3311
- * unusable for various reasons.  We statically define the bits
49b3311
- * we need here until the official headers are fixed.
49b3311
- *
49b3311
- * The commonly used RPC calls such as CLNT_CALL and CLNT_DESTROY
49b3311
- * are actually virtual functions in both the legacy and TI-RPC
49b3311
- * implementations.  The proper _CALL or _DESTROY will be invoked
49b3311
- * no matter if we used a legacy clnt_create() or clnt_tli_create()
49b3311
- * from libtirpc.
49b3311
- */
49b3311
-
49b3311
-#include <tirpc/netconfig.h>
49b3311
-#include <tirpc/rpc/rpcb_prot.h>
49b3311
-
49b3311
-/* definitions from tirpc/rpc/types.h */
49b3311
-
49b3311
-/*
49b3311
- * The netbuf structure is used for transport-independent address storage.
49b3311
- */
49b3311
-struct netbuf {
49b3311
-	unsigned int	maxlen;
49b3311
-	unsigned int	len;
49b3311
-	void		*buf;
49b3311
-};
49b3311
-
49b3311
-/* definitions from tirpc/rpc/clnt.h */
49b3311
-
49b3311
-/*
49b3311
- * Low level clnt create routine for connectionless transports, e.g. udp.
49b3311
- */
49b3311
-extern CLIENT *clnt_dg_create(const int, const struct netbuf *,
49b3311
-			      const rpcprog_t, const rpcvers_t,
49b3311
-			      const u_int, const u_int);
49b3311
-
49b3311
-/*
49b3311
- * Low level clnt create routine for connectionful transports, e.g. tcp.
49b3311
- */
49b3311
-extern CLIENT *clnt_vc_create(const int, const struct netbuf *,
49b3311
-			      const rpcprog_t, const rpcvers_t,
49b3311
-			      u_int, u_int);
49b3311
-
49b3311
-#endif	/* HAVE_TIRPC_NETCONFIG_H */
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
+#include <netconfig.h>
49b3311
+#include <rpc/rpcb_prot.h>
49b3311
+#endif	/* HAVE_LIBTIRPC */
49b3311
 
49b3311
 /*
49b3311
  * If "-1" is specified in the tv_sec field, use these defaults instead.
49b3311
@@ -107,14 +66,14 @@ static CLIENT *nfs_get_localclient(const struct sockaddr *sap,
49b3311
 				   const rpcvers_t version,
49b3311
 				   struct timeval *timeout)
49b3311
 {
49b3311
-#ifdef HAVE_CLNT_VC_CREATE
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 	struct sockaddr_storage address;
49b3311
 	const struct netbuf nbuf = {
49b3311
 		.maxlen		= sizeof(struct sockaddr_un),
49b3311
 		.len		= (size_t)salen,
49b3311
 		.buf		= &address,
49b3311
 	};
49b3311
-#endif	/* HAVE_CLNT_VC_CREATE */
49b3311
+#endif	/* HAVE_LIBTIRPC */
49b3311
 	CLIENT *client;
49b3311
 	int sock;
49b3311
 
49b3311
@@ -128,13 +87,13 @@ static CLIENT *nfs_get_localclient(const struct sockaddr *sap,
49b3311
 	if (timeout->tv_sec == -1)
49b3311
 		timeout->tv_sec = NFSRPC_TIMEOUT_TCP;
49b3311
 
49b3311
-#ifdef HAVE_CLNT_VC_CREATE
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 	memcpy(nbuf.buf, sap, (size_t)salen);
49b3311
 	client = clnt_vc_create(sock, &nbuf, program, version, 0, 0);
49b3311
-#else	/* HAVE_CLNT_VC_CREATE */
49b3311
+#else	/* !HAVE_LIBTIRPC */
49b3311
 	client = clntunix_create((struct sockaddr_un *)sap,
49b3311
 					program, version, &sock, 0, 0);
49b3311
-#endif	/* HAVE_CLNT_VC_CREATE */
49b3311
+#endif	/* !HAVE_LIBTIRPC */
49b3311
 	if (client != NULL)
49b3311
 		CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL);
49b3311
 	else
49b3311
@@ -261,23 +220,23 @@ static CLIENT *nfs_get_udpclient(const struct sockaddr *sap,
49b3311
 				 const rpcvers_t version,
49b3311
 				 struct timeval *timeout)
49b3311
 {
49b3311
-#ifdef HAVE_CLNT_DG_CREATE
49b3311
+	CLIENT *client;
49b3311
+	int ret, sock;
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 	struct sockaddr_storage address;
49b3311
 	const struct netbuf nbuf = {
49b3311
 		.maxlen		= salen,
49b3311
 		.len		= salen,
49b3311
 		.buf		= &address,
49b3311
 	};
49b3311
-#endif	/* HAVE_CLNT_DG_CREATE */
49b3311
-	CLIENT *client;
49b3311
-	int ret, sock;
49b3311
 
49b3311
-#ifndef HAVE_CLNT_DG_CREATE
49b3311
+#else	/* !HAVE_LIBTIRPC */
49b3311
+
49b3311
 	if (sap->sa_family != AF_INET) {
49b3311
 		rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
49b3311
 		return NULL;
49b3311
 	}
49b3311
-#endif	/* !HAVE_CLNT_DG_CREATE */
49b3311
+#endif	/* !HAVE_LIBTIRPC */
49b3311
 
49b3311
 	sock = socket((int)sap->sa_family, SOCK_DGRAM, IPPROTO_UDP);
49b3311
 	if (sock == -1) {
49b3311
@@ -305,13 +264,13 @@ static CLIENT *nfs_get_udpclient(const struct sockaddr *sap,
49b3311
 		return NULL;
49b3311
 	}
49b3311
 
49b3311
-#ifdef HAVE_CLNT_DG_CREATE
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 	memcpy(nbuf.buf, sap, (size_t)salen);
49b3311
 	client = clnt_dg_create(sock, &nbuf, program, version, 0, 0);
49b3311
-#else	/* HAVE_CLNT_DG_CREATE */
49b3311
+#else	/* !HAVE_LIBTIRPC */
49b3311
 	client = clntudp_create((struct sockaddr_in *)sap, program,
49b3311
 					version, *timeout, &sock);
49b3311
-#endif	/* HAVE_CLNT_DG_CREATE */
49b3311
+#endif	/* !HAVE_LIBTIRPC */
49b3311
 	if (client != NULL) {
49b3311
 		CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)timeout);
49b3311
 		CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL);
49b3311
@@ -337,23 +296,23 @@ static CLIENT *nfs_get_tcpclient(const struct sockaddr *sap,
49b3311
 				 const rpcvers_t version,
49b3311
 				 struct timeval *timeout)
49b3311
 {
49b3311
-#ifdef HAVE_CLNT_VC_CREATE
49b3311
+	CLIENT *client;
49b3311
+	int ret, sock;
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 	struct sockaddr_storage address;
49b3311
 	const struct netbuf nbuf = {
49b3311
 		.maxlen		= salen,
49b3311
 		.len		= salen,
49b3311
 		.buf		= &address,
49b3311
 	};
49b3311
-#endif	/* HAVE_CLNT_VC_CREATE */
49b3311
-	CLIENT *client;
49b3311
-	int ret, sock;
49b3311
 
49b3311
-#ifndef HAVE_CLNT_VC_CREATE
49b3311
+#else	/* !HAVE_LIBTIRPC */
49b3311
+
49b3311
 	if (sap->sa_family != AF_INET) {
49b3311
 		rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
49b3311
 		return NULL;
49b3311
 	}
49b3311
-#endif	/* !HAVE_CLNT_VC_CREATE */
49b3311
+#endif	/* !HAVE_LIBTIRPC */
49b3311
 
49b3311
 	sock = socket((int)sap->sa_family, SOCK_STREAM, IPPROTO_TCP);
49b3311
 	if (sock == -1) {
49b3311
@@ -381,13 +340,13 @@ static CLIENT *nfs_get_tcpclient(const struct sockaddr *sap,
49b3311
 		return NULL;
49b3311
 	}
49b3311
 
49b3311
-#ifdef HAVE_CLNT_VC_CREATE
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
 	memcpy(nbuf.buf, sap, (size_t)salen);
49b3311
 	client = clnt_vc_create(sock, &nbuf, program, version, 0, 0);
49b3311
-#else	/* HAVE_CLNT_VC_CREATE */
49b3311
+#else	/* !HAVE_LIBTIRPC */
49b3311
 	client = clnttcp_create((struct sockaddr_in *)sap,
49b3311
 					program, version, &sock, 0, 0);
49b3311
-#endif	/* HAVE_CLNT_VC_CREATE */
49b3311
+#endif	/* !HAVE_LIBTIRPC */
49b3311
 	if (client != NULL)
49b3311
 		CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL);
49b3311
 	else
49b3311
diff --git a/utils/gssd/Makefile.am b/utils/gssd/Makefile.am
49b3311
index e42b339..95a2bd0 100644
49b3311
--- a/utils/gssd/Makefile.am
49b3311
+++ b/utils/gssd/Makefile.am
49b3311
@@ -39,11 +39,11 @@ gssd_SOURCES = \
49b3311
 	write_bytes.h
49b3311
 
49b3311
 gssd_LDADD =	../../support/nfs/libnfs.a \
49b3311
-		$(RPCSECGSS_LIBS) $(KRBLIBS)
49b3311
+		$(RPCSECGSS_LIBS) $(GSSGLUE_LIBS) $(KRBLIBS)
49b3311
 gssd_LDFLAGS = $(KRBLDFLAGS)
49b3311
 
49b3311
 gssd_CFLAGS = $(AM_CFLAGS) $(CFLAGS) \
49b3311
-	      $(RPCSECGSS_CFLAGS) $(KRBCFLAGS)
49b3311
+	      $(RPCSECGSS_CFLAGS) $(GSSGLUE_CFLAGS) $(KRBCFLAGS)
49b3311
 
49b3311
 svcgssd_SOURCES = \
49b3311
 	$(COMMON_SRCS) \
49b3311
@@ -56,18 +56,18 @@ svcgssd_SOURCES = \
49b3311
 
49b3311
 svcgssd_LDADD = \
49b3311
 	../../support/nfs/libnfs.a \
49b3311
-	$(RPCSECGSS_LIBS) -lnfsidmap \
49b3311
+	$(RPCSECGSS_LIBS) $(GSSGLUE_LIBS) -lnfsidmap \
49b3311
 	$(KRBLIBS)
49b3311
 
49b3311
 svcgssd_LDFLAGS = $(KRBLDFLAGS)
49b3311
 
49b3311
 svcgssd_CFLAGS = $(AM_CFLAGS) $(CFLAGS) \
49b3311
-		 $(RPCSECGSS_CFLAGS) $(KRBCFLAGS)
49b3311
+		 $(RPCSECGSS_CFLAGS) $(GSSGLUE_CFLAGS) $(KRBCFLAGS)
49b3311
 
49b3311
 gss_clnt_send_err_SOURCES = gss_clnt_send_err.c
49b3311
 
49b3311
 gss_clnt_send_err_CFLAGS = $(AM_CFLAGS) $(CFLAGS) \
49b3311
-		 $(RPCSECGSS_CFLAGS) $(KRBCFLAGS)
49b3311
+		 $(RPCSECGSS_CFLAGS) $(GSSGLUE_CFLAGS) $(KRBCFLAGS)
49b3311
 
49b3311
 MAINTAINERCLEANFILES = Makefile.in
49b3311
 
49b3311
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
49b3311
index d0d3f7f..295c37d 100644
49b3311
--- a/utils/gssd/gssd_proc.c
49b3311
+++ b/utils/gssd/gssd_proc.c
49b3311
@@ -70,7 +70,6 @@
49b3311
 #include "gssd.h"
49b3311
 #include "err_util.h"
49b3311
 #include "gss_util.h"
49b3311
-#include "gss_oids.h"
49b3311
 #include "krb5_util.h"
49b3311
 #include "context.h"
49b3311
 
49b3311
@@ -778,8 +777,10 @@ handle_krb5_upcall(struct clnt_info *clp)
49b3311
 out:
49b3311
 	if (token.value)
49b3311
 		free(token.value);
49b3311
+#ifndef HAVE_LIBTIRPC
49b3311
 	if (pd.pd_ctx_hndl.length != 0)
49b3311
 		authgss_free_private_data(&pd;;
49b3311
+#endif
49b3311
 	if (auth)
49b3311
 		AUTH_DESTROY(auth);
49b3311
 	if (rpc_clnt)
49b3311
diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
49b3311
index 8923b3b..e3c6f5e 100644
49b3311
--- a/utils/gssd/krb5_util.c
49b3311
+++ b/utils/gssd/krb5_util.c
49b3311
@@ -124,7 +124,6 @@
49b3311
 #include "gssd.h"
49b3311
 #include "err_util.h"
49b3311
 #include "gss_util.h"
49b3311
-#include "gss_oids.h"
49b3311
 #include "krb5_util.h"
49b3311
 
49b3311
 /* Global list of principals/cache file names for machine credentials */
49b3311
diff --git a/utils/gssd/krb5_util.h b/utils/gssd/krb5_util.h
49b3311
index 4b2da6b..7d808f5 100644
49b3311
--- a/utils/gssd/krb5_util.h
49b3311
+++ b/utils/gssd/krb5_util.h
49b3311
@@ -3,6 +3,12 @@
49b3311
 
49b3311
 #include <krb5.h>
49b3311
 
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
+#include <rpc/auth_gss.h>
49b3311
+#else
49b3311
+#include "gss_oids.h"
49b3311
+#endif
49b3311
+
49b3311
 /*
49b3311
  * List of principals from our keytab that we
49b3311
  * will try to use to obtain credentials
49b3311
diff --git a/utils/mountd/svc_run.c b/utils/mountd/svc_run.c
49b3311
index 422e839..5ba5af6 100644
49b3311
--- a/utils/mountd/svc_run.c
49b3311
+++ b/utils/mountd/svc_run.c
49b3311
@@ -54,6 +54,10 @@
49b3311
 #include <errno.h>
49b3311
 #include <time.h>
49b3311
 
49b3311
+#ifdef HAVE_LIBTIRPC
49b3311
+#include <rpc/rpc_com.h>
49b3311
+#endif
49b3311
+
49b3311
 void cache_set_fds(fd_set *fdset);
49b3311
 int cache_process_req(fd_set *readfds);
49b3311