From 591e58fe1a6c42842d26eff62ab4a3727380abd3 Mon Sep 17 00:00:00 2001
From: Jon Trulson <jon@radscan.com>
Date: Mon, 3 Sep 2012 19:50:10 -0600
Subject: [PATCH] linux.cf: add libtirpc support.  Disabled by default.

Currently on Linux, you must run rpcbind in insecure mode (-i) in
order for ttsession to register with rpcbind (the portmapper).  This
is because, on most systems, libc contains an older sun-based rpc
library embedded within it.  The sun-rpc code does not know how to
authenticate with rpcbind when run as a non-privileged user.

Using libtirpc, ttsession can register with rpcbind without requiring
it to be run in insecure mode.  You must have the libtirpc-dev, or
equivalent package installed to use it.

If you want to try this:

- install libtirpc-dev or equivalent
- if your rpcbind process is already running in insecure mode (-i
  option), remove that option and restart it.
- edit config/host.def, (create if it doesn't exist) and add:

  #define HasTIRPCLib  YES

- rebuild CDE (make World).  It's probably a good idea to remove
  /usr/dt/* beforehand to avoid contamination.

Some linux systems seem to incorporate tirpc directly into libc (as
all of the BSD's do AFAIK) so this may not be needed.

I know that at least on Ubuntu systems defining HasTIRPCLib to YES is
required in order to run rpcbind without -i.
---
 cde/config/cf/linux.cf | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/cde/config/cf/linux.cf b/cde/config/cf/linux.cf
index c277ce98..7b246eb1 100644
--- a/cde/config/cf/linux.cf
+++ b/cde/config/cf/linux.cf
@@ -23,7 +23,7 @@ XCOMM platform:  $TOG: linux.cf /main/47 1998/04/17 11:32:51 mgreess $
 /*
   Add "#define LinuxDistribution Linux<mumble>" to your site.def or host.def.
   Currently only LinuxSuSE will be figured out automatically.
-  Valid values are (from the list at www.linux.org in Oct. '97):
+  Valid values are (from the list at www.linux.org in Oct. 1997):
     LinuxUnknown    (0)
     LinuxSuSE       (1)
     LinuxCaldera    (2)
@@ -117,6 +117,22 @@ XCOMM binutils:  (LinuxBinUtilsMajorVersion)
 
 #define LinuxLocaleDefines	/**/
 
+XCOMM If you have the tirpc library on your system, and you have the
+XCOMM libtirpc-dev installed, then define HasTIRPCLib to YES in either
+XCOMM your host.def or site.def file.  Using the tirpc lib should
+XCOMM allow running rpcbind in secure mode (ie: without the -i option).
+XCOMM The default is NO.
+
+#ifndef HasTIRPCLib
+# define HasTIRPCLib NO
+#endif
+
+#if HasTIRPCLib
+TIRPCLIB = -ltirpc
+#else
+TIRPCLIB = 
+#endif
+
 #if LinuxCLibMajorVersion < 6
 # define LinuxSourceDefines	-D_POSIX_SOURCE \
 				-D_BSD_SOURCE -D_SVID_SOURCE LinuxLocaleDefines
@@ -128,8 +144,8 @@ XCOMM binutils:  (LinuxBinUtilsMajorVersion)
 # define LinuxSourceDefines	-D_POSIX_C_SOURCE=199309L \
 				-D_POSIX_SOURCE \
 				-D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE \
-                                -D__NO_STRING_INLINES -D__NO_MATH_INLINES \
-                                LinuxLocaleDefines
+				-D__NO_STRING_INLINES -D__NO_MATH_INLINES \
+				LinuxLocaleDefines
 # define HasPosixThreads	YES
 # define ThreadedX		YES
 # define HasThreadSafeAPI	YES
@@ -232,7 +248,7 @@ XCOMM This is needed for CDE currently
 
 #define ArchitectureDefines	-DLINUX_ARCHITECTURE
 
-#define TtClientLibs $(TTLIB) $(XTOOLLIB) $(XLIB)
+#define TtClientLibs $(TTLIB) $(TIRPCLIB) $(XTOOLLIB) $(XLIB)
 #define TtClientDepLibs $(DEPTTLIB) $(DEPXTOOLLIB) $(DEPXLIB)
 
 #include <lnxLib.rules>
-- 
2.25.1