Return-Path: seeger@cis.ufl.edu
Received: by gw.home.vix.com id AA20217; Sun, 6 Feb 94 01:11:05 -0800
Received:  from localhost  by beach.cis.ufl.edu (8.6.4/4.11)
	id EAA21339; Sun, 6 Feb 1994 04:11:03 -0500
Message-Id: <199402060911.EAA21339@beach.cis.ufl.edu>
From: seeger@cis.ufl.edu (F. L. Charles Seeger III)
Date: Sun, 6 Feb 1994 04:11:03 -0500
In-Reply-To: paul@vix.com (Paul A Vixie) <VIXIE.94Feb4001622@office.home.vix.com>
X-Mailer: Mail User's Shell (7.2.5 beta 8/1/92)
To: paul@vix.com (Paul A Vixie)
Subject: Re: BIND 4.9.2

+------ Paul A Vixie wrote (Fri,  4-Feb-94,  0:16 -0800):
| 
| If anyone knows any reason why BIND 4.9.2 shouldn't be promoted to full
| production, please let me know.  Otherwise, the release is...imminent.

Paul,

Not having beta'ed it, obviously I won't have any objections.
Attached is a "better" set of instructions for inserting the resolver
routines into the SunOS 4.1.x shared C library.  If you would like to
include these with the distribution, I would like the opportunity to
both edit them and to test them against 4.9.2 and the latest stuff
delievered by Sun (including 4.1.3_U1).

I'm also working on some nice scripts for maintaining the named files,
but they won't be ready to send out for quite some time (i.e. at least
3 months).

Regards,
Chuck
-- 
  Charles Seeger          375 Patricia Ave      Office: +1 813 738 3000 x2083
  cseeger@nielsen.com     Dunedin, FL 34698     Fax:    +1 813 738 3113
----

UFLnotes:
	This file is derived from Greg Earle's customized-for-DNS
	/usr/lib/shlib.etc/README file, updated for 4.1.3 and Sun
	Patch-IDs 100890-08 and 100891-08.  Further, it contains
	updated instructions for installing the resolver routines
	from the BIND-4.9 distribution.

	We will integrate some of the latest header file changes from
	UCB and BIND-4.9.  This entails installing paths.h in /usr/include,
	bitypes.h and cdefs.h in /usr/include/sys, along with replacements
	for netdb.h, resolv.h, arpa/inet.h and arpa/nameser.h.

	Finally, small patches for res_init.c and res_query.c and the
	introduction of a new file, res_commondata.c, are needed to be
	compatible with Sun's shared library facility, which wants
	exported initialized data to appear in libc.sa (data interface
	description) file.  Also, be sure to compile with the "-pic"
	option, and do not use the "-ld -x -r $*.o" and "mv a.out $*.o"
	commands in the BIND res/Makefile.

	BTW, gatekeeper.dec.com:/pub/BSD/bind/4.9/4.9.930517.tar.Z


-------------------------------------------------------------------------

	This is a procedure you can use to substitute or add 
a module in your shared libc library. 

Note! If you are interested in a System V libc, please substitute
	libcs5_pic.a for libc_pic.a in step 3, and
	libcs5.so.x.y.z for libc.so.x.y.z in step 14.

-------------------------------------------------------------------------

1. Become super user
	% su

2. Make a temporary directory
	% mkdir tmp

3. Change to the "tmp" directory just made, extract the pic .o from 
   libc_pic.a and rm the file __.SYMDEF. The reason you need to do 
   the 3 "mv" commands is because "ar" truncated filenames over 
   16 characters.
	% cd tmp
	% ar x ../libc_pic.a
	% rm __.SYMDEF
	% mv rpc_dtablesize. rpc_dtablesize.o
	% mv rpc_commondata. rpc_commondata.o
	% mv xccs_multibyte. xccs_multibyte.o

UFLnotes:
	That last command should be:
		% mv xccs.multibyte. xccs.multibyte.o

   Note: this last mv command is not present in the original version of the
   README file that comes in /usr/lib/shlib.etc/README.  If this step is
   omitted, you will produce a shared libc.so that does not contain the
   xccs_multibyte.o module.  This module contains versions of the library
   functions "mbtowc", "wctomb", "mbstowcs" and "wcstombs" (see mblen(3) for
   more info on these multi-byte character functions), which operate on the
   Xerox XCCS codeset standard.  Specifically, the missing functions will be

	_mbtowc_xccs(pwc, s, n)
	_wctomb_xccs(s, pwc)
	_mbstowcs_xccs(pwc, s, n)
	_wcstombs_xccs(s, pwc, n)

   These are called by the corresponding "mbtowc", "wctomb", "mbstowcs" and
   "wcstombs" functions if the codeset is XCCS (other codesets include EUC,
   ISO 2022, and a default).  In short, if you use any Internationalization
   features and need to handle multi-byte character sets, do not forget this
   step.

4. If you are doing this to specifically create a libc.so that contains
   the DNS resolver routines for doing hostname/hostaddr lookups via the
   Domain Name Service (and not NIS/YP), do these additional steps.  If not,
   please skip down to step 10.


UFLnotes:
	We use the BIND-4.9 resolver routines, with a few changes to be
	more friendly with shared libs.  Compile these and copy the .o
	files into the tmp subdirectory rather than unpacking Sun's
	libresolv.a, as in Step 5.  These should be compiled with the
	"cc -pic" option and verified with "ld -assert pure-text *.o".
	Note that Sun's libc already has mktemp(), strpbrk(), strcasecmp()
	and strncasecmp() (in stricmp.o).  However, it does not provide
	herror(), strerror() nor strtoul(), so herror.o, strerror.o and
	strtoul.o must be added.  inet_aton() has been added to inet_addr.o,
	so the BIND-4.9 version needs to replace the original.
	Also note that res_commondata.o contains the exported initialized
	structure _res, which will be used in both the libc.so and its
	companion libc.sa.
	Further note that h_errno is declared in rpc_commondata.o, which
	is already included in both libc.so and libc.sa files.

	So, these are the object files that need to be copied into the
	"tmp" directory:
			gethnamaddr.o
			herror.o
			inet_addr.o
			res_commondata.o
			res_comp.o
			res_debug.o
			res_init.o
			res_mkquery.o
			res_query.o
			res_send.o
			sethostent.o
			strerror.o
			strtoul.o
	Skip Steps 5 and 7.


5. Extract the contents of /usr/lib/libresolv.a into the tmp directory:
	% ar x /usr/lib/libresolv.a
	% rm __.SYMDEF

   The libresolv.a contains object modules that are position
   independant, so they can be added to the libc_pic modules without fear.

   NOTE: You may wish to install Sun patch 100465-02 *first* before taking
   this step, as it provides a newer patched version of /usr/lib/libresolv.a.
   This fixes a serious bug that causes DNS nameserver lookups to fail if the
   first name server query yields ECONNREFUSED (Connection refused), even if
   the other nameservers specified in /etc/resolv.conf are both up & working:

	Patch i.d.	Bug i.d's	Description
	----------	---------	-----------
	100465-02	1076977		4.1,4.1.1,4.1.2,4.1.3: DNS res_send()
					fails if first nameserver in
					/etc/resolv.conf returns ECONNREFUSED

6. Remove the old routine to do the hostname/addr resolution:
	% rm gethostent.o

7. Remove the libresolv module that contains `strncasecmp' (which is now
   in the main C library, so it is redundant):
	% rm strcasecmp.o

8. As also mentioned below (in step 11), edit the file `lorder-sparc' in the ..
   directory.  Remove the reference to `gethostent.o' and add the
   references to the resolver library routines by applying this patch:

	% cd ..
	% diff -rc2 lorder-sparc.orig lorder-sparc
	*** lorder-sparc.orig   Thu Feb  8 05:27:46 1990
	--- lorder-sparc	Mon Apr  9 12:58:59 1990
	***************
	*** 150,154 ****
	  getwd.o
	  getnetgrent.o
	! gethostent.o
	  ypxdr.o
	  ttyname.o
	--- 150,161 ----
	  getwd.o
	  getnetgrent.o
	! gethostnamadr.o
	! sethostent.o
	! res_query.o
	! res_mkquery.o
	! res_send.o
	! res_debug.o
	! res_comp.o
	! res_init.o
	  ypxdr.o
	  ttyname.o

UFLnotes:	For our BIND-4.9 resolvers we make this change instead.
		
	*** lorder-sparc.orig   Tue Dec  7 14:33:31 1993
	--- lorder-sparc        Tue Dec 14 23:36:17 1993
	***************
	*** 149,155 ****
	  listen.o
	  getwd.o
	  getnetgrent.o
	! gethostent.o
	  ypxdr.o
	  ttyname.o
	  setbuffer.o
	--- 149,166 ----
	  listen.o
	  getwd.o
	  getnetgrent.o
	! gethnamaddr.o
	! sethostent.o
	! herror.o
	! res_commondata.o
	! res_query.o
	! res_mkquery.o
	! res_send.o
	! res_debug.o
	! res_comp.o
	! res_init.o
	! strerror.o
	! strtoul.o
	  ypxdr.o
	  ttyname.o
	  setbuffer.o
	***************
	*** 455,457 ****
	--- 466,469 ----
	  _psignal.o
	  _ftou.o
	  _crypt.o
	+ mblib.o


UFLnotes:
	Patches 100531-02 and 100532-02 (for 4.1.2) include a fixed Makefile,
	so that the patch in Step 9 has already been applied.  However, it
	did not include "mblib.o" in lorder-sparc.
	The base 4.1.3 Makefile *does* require the Step 9 fix.  However,
	the 4.1.3 libc patches (100890-08 and 100891-08 as of 14-Dec-93)
	have incorporated the "-ldl" Makefile fix, but not the "mblib.o"
	lorder-sparc fix, which is required for the multibyte character
	handling mentioned above (see mblen(3)).

9. If you are running under SunOS 4.1.2, you will want to add the entry
   "mblib.o" to the very end of the "lorder-sparc" file.  If you aren't running
   SunOS 4.1.2, you may now skip down to step 13.

   Also, you will need to patch the Makefile, as follows:

	*** Makefile.orig	Wed Oct 23 10:13:00 1991
	--- Makefile	Mon Feb 24 18:38:08 1992
	***************
	*** 9,13 ****
	  
	  libc.so:
	! 	ld -assert pure-text `${OBJSORT} lorder-sparc tmp`
	  	/bin/ls /usr/lib/libc.so.* > TMP_FILE
	  	mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
	--- 9,13 ----
	  
	  libc.so:
	! 	ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
	  	/bin/ls /usr/lib/libc.so.* > TMP_FILE
	  	mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
	***************
	*** 15,19 ****
	  
	  libcs5.so:
	! 	ld -assert pure-text `${OBJSORT} lorder-sparc tmp`
	  	/bin/ls /usr/5lib/libc.so.* > TMP_FILE
	  	mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
	--- 15,19 ----
	  
	  libcs5.so:
	! 	ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
	  	/bin/ls /usr/5lib/libc.so.* > TMP_FILE
	  	mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`

10. Replace or add the .o that you wanted by doing a copy. Please
    note here that you are advised to create your object with
    the following compiler option, i.e "cc -c -pic yourprogram.c" to make
    it shareable.
	% cp your.o .

11. If you add a new module then you need to do this step.
    You need to edit the file "lorder-sparc" and add the name of the file
    you have copied from step 4 at the end of this file. 
	% vi ../lorder-sparc

12. 	% cd ..

13. 	% make libc.so

UFLnotes:
	May need to add current directory to your path, so that
	objsort can be executed.  Or fix the Makefile by changing
	the definition of OBJSORT to "./objsort".

UFLnotes:
	But, we aren't done just yet.  We need to handle the
		exported intialized data...
	Copy the original libc.sa file (x=1 and y=8 for 4.1.3):
		# cp -p /usr/lib/libc.sa.x.y libc.sa.x.y.z
	For adding the BIND-4.9 resolver:
		# ar rv libc.sa.x.y.z tmp/res_commondata.o
	Now ranlib it:
		# ranlib libc.sa.x.y.z



14. Now you should have some libc.so.x.y.z built in the current directory.
    It is recommended that you tested out this library at this point 
    before installing it. You can do so by setting the environment
    LD_LIBRARY_PATH  to the current directory for example:
   	% setenv LD_LIBRARY_PATH `pwd`
	% your_favorite_test_cmd
    Once you are satisfied that the new library worked, you can proceed
    to install it with the following commands:
	% cp libc.so.x.y.z /usr/lib
	% ldconfig
	% unsetenv LD_LIBRARY_PATH

UFLnotes:
	Note that suid commands, e.g. ping and arp, may not honor the
	LD_LIBRARY_PATH as expected.

	Use this command instead of the one above if both the so and
	sa portions of the shared libc are being installed.
	# cp -p libc.so.x.y.z libc.sa.x.y.z /usr/lib
	# ranlib -t /usr/lib/libc.sa.x.y.z
	# ldconfig
	# unsetenv LD_LIBRARY_PATH

15. You are now running with the new library.  You can verify this by
    doing a trace command of, let's say, "date".
	% trace date
    The output should informed you that the new library is being used.


UFLnotes:
	Now, update the following libraries to remain consistent:
			/usr/lib/libc.a
			/usr/lib/libc_p.a
			/usr/lib/libresolv.a
			/usr/5lib/libc.a
			/usr/5lib/libc_p.a
			/usr/5lib/libc.sa.2.8
			/usr/5lib/libc.so.2.8


