SUMMARY (DNS - NIS hostname lookup problem)

From: On-Call Problem Solving <oncall_at_cs.usask.ca>
Date: Wed, 29 Mar 1995 10:10:10 -0600

  This summary provides a solution to the DNS - NIS hostname lookup
problem experienced by SUNs running SunOS 4.X which have a DEC Alpha
AXP OSF/1 machine acting as their NIS server:

        (The resolv+2.1.1.tar.Z file is the key)

  The "-b" switch is not supported by NIS on Digital UNIX. SunOS 4.X libc.so
does not include any support for DNS/bind. DNS support only exists in the
ypserv on the server. This is a SunOS unique thing. Digital, HP, IBM, SGI,
and even SUN Solaris 2.x systems support DNS in libc and do not rely on the
NIS server to do a DNS lookup.

  Check some of the SunOS FAQ's, you'll find there are resolver libraries for
SunOS 4.X that add DNS support for the resolver calls by changing libc.so
on the SunOS client. These would allow the SunOS systems to directly query
a dns server, with a system specified order (normally /etc/hosts, yp, then
dns.) Such changes still function with the SunOS ypserv's.

  Thus the fix involves modifiying libc.so on all your SUNOS 4.X machines
to use a more configurable version of gethostbyname(). The resolv+ package
does this, adding a /etc/hosts.conf file where you can include the following
entry 'order hosts,bind,nis'. This entry specifies the order in which
the SUN machine will perform a hostname lookup. From one of the SUN
FAQ's:"Finally, resolv+ can be obtained from thor.ece.uc.edu. Get the file
/pub/sun-faq/resolv+2.1.1.tar.Z." Other sites have this file as well.
        
  Also the following workaroud helps clarify some of the installation of
the new libc and libresolv.a which is handled by the resolv+ package.
 
 **********************************************************************
 /* workaround */
 Bug Id: 1043729
 Product: sunos
 Category: library
 Subcategory: libc
 Release summary: 4.1.3, 4.1.2, 4.1, 4.1.1
 Bug/Rfe: rfe
 State: closed
 Synopsis: README file for shared-library building lacks DNS info
 Keywords: libresolv, shlib.etc, shlib, custom, readme, shared-lib, building, dns
 Severity: 3
 Priority: 5
 Description:
        Starting with SunOS 4.1, we began shipping a software category called
        `Shlib Custom', which provides copies of the C library (BSD and
        System V versions) in Position-Independant archive format (libc_pic.a).
        This archive can be used to create customized versions of the shared
        C library (/usr/lib/libc.so.*), using the instructions contained in
        the file /usr/lib/shlib.etc/README (which, along with the libc_pic.a
        archive and some adjunct files, is loaded when the Shlib Custom
        software category is selected).

        The main purpose that someone would want to create their own custom
        version of the shared C library for would be to create a libc.so
        that replaces the gethostbyname()/gethostbyaddr() routines (which,
        by default, reference /etc/hosts and/or the `hosts' NIS map) with
        versions that talk to a DNS nameserver. This is especially vital for
        our Internet customers. Unfortunately, the README file that contains
        the instructions on how to build the custom libc.so makes no mention
        at all about the steps needed to solve this particular problem.
 Work around:
        There is not really any "workaround", per se. Either you know how to
        do it or you don't.
 Suggested fix:
        My Request for Enhancement involves replacing the existing README file
        in /usr/lib/shlib.etc with the following upward-compatible version:

-------------------- >8 New /usr/lib/shlib.etc/README 8< --------------------

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

Note! if you are interested system 5 libc, please substitute
        libc_pic.a to libcs5_pic.a in step 3,
        libc.so.x.y.z to libcs5.so.x.y.z in step 8.

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

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

   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.

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-01 *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 SunOS Description
---------- --------- ----- -----------
100465-0x 1076977
                        4.1 4.1 4.1.2 DNS res_send() fails if first nameserver
                        in /etc/resolv.conf returns ECONNREFUSED

   Alternatively, 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 -DDEBUG -DBSD=43 -O -pic -c <module>.c

   and the resulting object modules should be usable in this schema as well.

   If you possess a post-4.8 version of BIND, such as the 4.8.3 release
   (available from ucbarpa.Berkeley.EDU) you may wish to compile the version of
   `res_send.c' from that distribution and use that, which also fixes the
   aforementioned res_send() problem. To compile it, use the compilation line
   mentioned above.

   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 probably safe to use.

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

9. If you are running under SunOS 4.1.2, you will also 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, under 4.1.2 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}`
        B
        ***************
        *** 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

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

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.

------------------ >8 End of /usr/lib/shlib.etc/README 8< -------------------
 State triggers:
         Evaluation:
04/06/93 andrewr: This component is not present in Solaris 2.x.
We do not plan to fix it in the Solaris 1.x source base.
         Closed because: will not fix
 Comments:
        I realize it's a little late, but it would be very helpful if this
        could make it into PIE (4.1.1).
--
lenm_at_aus 23Dec92
This procedure works fine for 4.1.3 as well.
--
  Summary:
	Instructions for building a customized shared C library contained in
	/usr/lib/shlib.etc/README do not contain specific instructions for
	building a libc.so that references the DNS resolver routines for
	hostname/hostaddr lookups, which is perhaps the most commonly-used
	application for this capability.
 Bug End:
----------
X-Sun-Data-Type: readme-file
X-Sun-Data-Description: readme-file
X-Sun-Data-Name: README
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 53
Patch-ID# 101435-01
Keywords: ypserv maps DNS res_send resolv.conf nameserver 
Synopsis: SunOS 4.1.3_U1: ypserv fix
Date: Dec/20/93
Solaris Release: 1.1.1
 
SunOS release: 4.1.3_U1
 
Unbundled Product: 
 
Unbundled Release:
 
Topic: ypserv
BugId's fixed with this patch: 1076977
Changes incorporated in this version: 
Architectures for which this patch is available: sun4(all)
Obsoleted by: 
Problem Description: 
	Bug 1076977
	DNS lookup will fail if the first nameserver in /etc/resolv.conf 
	is up but has no nameserver daemon running. The ECONNREFUSED will 
	be carried on down to the other nameservers listed in resolv.conf 
	even if they are up and their nameserver daemons are running.
Install:
#Login as root.
#save original binaries
  mv /usr/etc/ypserv /usr/etc/ypserv.orig
  chmod 0400 /usr/etc/ypserv.orig
#copy the new version to /usr/etc
  cp ypserv /usr/etc/ypserv
 
  chown root.staff /usr/etc/ypserv
  chmod 755  /usr/etc/ypserv
 
#reboot the system to invoke the new binaries.
**********************************************************************
--
Oncall			oncall_at_cs.usask.ca
University of Saskatchewan
Computational Science Department
Network Administration/Problem Solving
Received on Wed Mar 29 1995 - 11:11:47 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:45 NZDT