From: styri@hal.nta.no (Haakon Styri)
Newsgroups: comp.sys.sun.admin
Subject: DNS-no-NIS.FAQ
Date: 19 Aug 92 08:28:03 GMT
Reply-To: styri@nta.no
Organization: Norwegian Telecom Research

Ok, the thread is appearing again and I figure it's time for a post.
I've got several requests for this recipe. I'll try to post this at
regular intervals.

Last Updated: 19th August 1992
------------------------------------------------------------------
DNS-no-NIS : How to get most SunOS commands to use DNS without NIS
------------------------------------------------------------------

This recipe is based on a version by Greg Earle, dated 25 Apr 90
Thanks to Steinar Haug for pointing out some bugs.

Background blurb:
-----------------
The Sun supported way of using DNS is through NIS. Please refer to the
System & Network Administration manual if you want to use NIS. This FAQ
offers no help in that respect.

However, many people want to use resolver-based lookups without having to
run NIS. A simple way to do this is by using a version of the libc.so
shared C library with the gethostbyname()/gethostbyaddr() routines replaced
by the equivalent functions from the BIND nameserver distribution's resolver
library.

For SunOS 4.0.x Sun created 'libc_resolv.so' versions. These were made
available via anonymous FTP. Try anonymous ftp to 'ftp.uu.net' and look
in directory '/systems/sun/sun-fixes'.

For SunOS 4.1.x you'll have to build custom shared libraries. To be able
to do this you need the Shlib Custom option installed. This software
will be installed in the '/usr/lib/shlib.etc' directory. You'll find a
README file containing instructions in this directory. You may want to
read it...

Fortunately, the /usr/lib/libresolv.a library has been compiled with
the '-pic' option, producing position-independant code. Thus you can
use this library when you create your DNS-version of 'libc.so'.

You'll find more information about position-indipendant code and shared
libraries in the Programming Utilities and Libraries manual. You should,
however, be able to create the 'libc.so' library without reading manuals.

Note that you'll have to substitute a few names if you're making a
system 5 libc.

Note that installing a new shared library will not alter the way
statically linked commands work. Try 'mount' and you'll see what
I mean. Don't ask me for a patch. Look in the Programming Utilities
and Libraries manual for a list of all the statically linked commands.

And, finally, no - I haven't tested this procedure using all combinations
of patches and SunOS 4.1.x versions. It should work on a vanilla 4.1.2.
The patch-minded person would maybe look at the following patches:

	100170-08 : jumbo patch to fix various ld problems
	100257-04 : jumbo patch for ld.so, ldd and ldconfig
	100531-02 : libc jumbo patch - Domestic Version (US)
	100532-02 : libc jumbo patch - International Version


Haakon Styri		(styri@nta.no)		Norwegian Telecom Research
---------------------------------------------------------------------------

0. You must be root to do this.

1. Make a temporary directory if not present, and cd to it
	% mkdir /usr/lib/shlib.etc/tmp
	% cd /usr/lib/shlib.etc/tmp

2. Extract the pic .o from 'libc_pic.a' and '/usr/lib/libresolv.a'.
   Remove the file __.SYMDEF.
   You need to do the 3 'mv' commands bacause 'ar' truncates filenames
   over 16 characters. (Note that the last 'mv' may not be documented in
   your '/usr/lib/shlib.etc/README'. It's a patch.)
	% ar x ../libc_pic.a
	% ar x /usr/lib/libresolv.a
	% rm __.SYMDEF
	% mv rpc_dtablesize. rpc_dtablesize.o
	% mv rpc_commondata. rpc_commondata.o
	% mv xccs.multibyte. xccs.multibyte.o

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

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

5. You've finished the work in the 'tmp' directory...
	% cd ..

6. The file 'lorder-sparc' in the '/usr/lib/shlib.etc' directory must
   be edited to reflect the changes. Remove the reference to `gethostent.o'
   and add the references to the resolver library routines by applying
   this patch:

	% diff -rc2 lorder-sparc.orig lorder-sparc
	*** lorder-sparc.orig   Thu Jul 30 12:38:58 1992
	--- lorder-sparc	Thu Jul 30 12:41:25 1992
	***************
	*** 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

7. You're SunOS may have this patched, but should check the 'Makefile' for
   the following problem:
	There should be a '-ldl' option in the 'ld' command lines.
   
8. Now you can make the new shared libary.
 	% make libc.so

9. 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
	% unsetenv LD_LIBRARY_PATH
	% cd ..
	% ldconfig


10. 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 inform you that the new library is being used.

-------------------------------------------------------------------------
Disclaimer: Neither I nor my employer will take any responsibility if
	    this recipe doesn't work.