From: lkn@s1.gov (Leland K. Neely)
Newsgroups: comp.sys.sun.admin
Subject: Re: resolver and NIS, SunOS 4.1.2
Date: 11 Apr 92 03:06:31 GMT
Organization: LLNL

In article <46397@dime.cs.umass.edu> hgschulz@gaia.cs.umass.edu (Henning Schulzrinne) writes:
>Setup: DECstation as YP master, Sun IPC (SunOS 4.1.2) as YP
>client/slave. We would like to use the domain name server, but 
>can't use the -B option discussed in the manual since the YP master
>is not running SunOS. A similar setup seems to work with a bunch
>of Suns and a DECstation YP master (single server, no slave server),
>but nobody around here seems to know or remember why it works.
>
>What do I need to do?

I am not sure about 4.1.2, BUT under 4.1.1, you needed to rebuild libc.so.
(This assumes that you have the shlib.custom installed. )
The essential fix was to redirect gethostname to use the resolver RATHER
than NIS.  I can email the fix to you, BUT it may fail under 4.1.2.

FYI: the -b option: (thought I'd look it up for the hell of it.)

     -b   Interdomain. Propagate a map to all servers  using  the
          interdomain name server named(8C).

this is an option to makedbm, I checked and it is not implemented in the
mips version.  Interesting no? As makedbm credits Sun as its origin.

Here is the doc I have on doing this:
Background: As you may know, the normal /usr/lib/libc.so.* that ships with
SunOS 4.x contains the library routines gethostbyname(3) and gethostbyaddr(3)
to do host name and address resolution.  These routines normally reference
the `hosts' NIS (nee YP) map first, and then fall back to looking in the
/etc/hosts file.  By changing the NIS Makefile to invoke `makedbm' with the
`-b' option, one can arrange things so that NIS does lookups first to a DNS
(Domain Name Service) name server, via the resolver routines.  This is the
`supported' way of doing things.

Fortunately, 2 things in 4.1 have come to the rescue:
(1) There is a selectable software category in the 4.1 Full Install called
    `Shlib Custom' that enables one to build custom shared libraries.
    This software gets installed in /usr/lib/shlib.etc, with a README file
    containing instructions on how to build your own custom shared C library.
    These instructions are a replacement for that file.
    
(2) The version of /usr/lib/libresolv.a in 4.1 appears to have been compiled
    with cc -pic, producing position-independant code.  I have no evidence to
    prove that this is the case, other than the fact that using the contents of
    that library and assuming that the object modules are position-independant
    has not failed yet (^:
    

        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 8.

-------------------------------------------------------------------------
{0.	cd /usr/lib/shlib.etc}

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 2 (or 3) "mv" commands is because "ar" truncated filenames over
   16 characters.
        # cd tmp
        # ar x ../libc_pic.a
        # rm __.SYMDEF
        # 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

Extra instructions for building a shared libc.so that uses the resolver
for hostname/addr resolution:

3a. Extract the contents of libc_pic.a and /usr/lib/libresolv.a into the
    tmp directory:
        # ar x /usr/lib/libresolv.a

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

    Note that if you have your own copy of the resolver library sources,
    perhaps from a post-4.8 BIND distribution, you can compile each of these
    modules yourself using `cc -pic' and the resulting object modules should
    be usable in this schema as well.  To test that the custom resolver
    modules will be usable, cd to the directory containing the custom resolver
    sources and object modules and perform this test:
        # ld -assert pure-text *.o

    If `ld' issues no complaints, then you can assume that the object modules
    are safe to use.

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

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

3d. As mentioned in step 5 below, 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:

        *** 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
          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

3e. Continue on, from steps 6 to 9 (i.e., skip steps 4 and 5 below).

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

4. 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 .

5. 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

6.      # cd ..

7.      # make libc.so

8. 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

9. 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.

-- 
   _______                                              ______________
   | | | |              Leland K. Neely                 |  ________  |
   | | | |              U.C.L.L.N.L                     | |`       | |
   | | | |_____         P.O. Box 808 L-285              | |________| |
   | | \______/         Livermore CA 94550              |____________|
   | \_______/          Email: lkn@s1.gov               ___|______|___
   \________/           Voice: (510) 422-0140           |____________|
                                                                     \
                                                                     /
                                                                    ||
Newsgroups: comp.sys.sun.admin