[SUMMARY] DNS without NIS on SUNOS 4.1.3

From: Bill Wang (wcwang@cs.indiana.edu)
Date: Thu Jul 15 1993 - 11:25:23 CDT


I posted a question about DNS on SUN OS 4.1.3. The procedure in
bindon41 wasn't quite working for me. Here are some of the
responses for getting name server running without NIS. The
procedures are very simular. Thanks to all replied.

From: Jim Davis <jdavis@cs.arizona.edu>
To: Bill Wang <wcwang@cs.indiana.edu>

Here you go:

        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,
        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 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-01 1076977
                        4.1 4.1 4.1.2 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

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

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.

--
Jim Davis               | "Revenge!"
jdavis@cs.arizona.edu   |   -- Pete's brother Pete

From: peter@jrc.nl (Peter Watkins) To: wcwang@cs.indiana.edu

This is certainly possible because I have done it and currently have libc.so.1.8.3 running on my SS2 (SUN-OS 4.1.3 & OW3) without any problems. telnet, ping, ftp etc all work perfectly.

The procedure that you mention (using shlib.etc from the distribution media) was described in some detail by Terry White (tkw@blazer.babss.basg.com) about 1 month ago on Sun-Managers. Although it works, I can vouch for that, it does have a couple of bugs which conflict with the C and FORTRAN compilers. I have produced a modified procedure which sorts these problems out and I have just sent a copy to tkw@... for his comments. See below for the modified version - see if it works for you.

I have not made any attempt to replace routines with BIND 4.8.3 versions, mainly because I have no problems with the existing set up.

<============= Begin Included Message =================>

To: Terry White. ================

About a month ago you posted a message in sun-managers about running DNS without NIS. This was exactly what I wanted since we have recently upgraded to 4.1.3 and 'lost' the libc.so.1.6.1 library with the resolver calls included.

Therefore I seized on your bug fix with great joy and reconstructed my libc.so.1.8.1 library just as you indicated. It worked a treat and I thought that all my problems were over!

Everything worked fine until I started to compile FORTRAN and C code (using the standard SUN versions). Suddenly I started to get unresolved references in the load step. There were 2 groups of unresolved references;

mblen - multibyte character handling dlopen - simple programmatic interface to the dynamic linker

I have spent a considerable time trying to track down the reason why these have appeared now and eventually succeeded. In the process I have learnt more than I ever want to know about shared libraries!!! I thought that you would like to know about the latest findings and maybe a revised summary should be posted.

What I have done below is to include your original solution with my comments/corrections included. If you have time please browse through it and pass on any thoughts.

===============================================================================================

SRDB ID : 2170

SYNOPSIS : Using DNS without NIS

DETAIL DESCRIPTION : Want to use DNS, but not NIS

SOLUTION SUMMARY : MAKING A LIBC.SO for DNS without NIS

This is a procedure that can be used to add name resolver routines into shared libc library in SunOS_4.1.x

First load "SHLIB CUSTOM" either from SunInstall or from add_services.

Be sure to have the file /etc/resolv.conf configured properly. Test this with /usr/etc/nslookup.

1. Become super user:

% su (if necessary)

2. Make a temporary directory:

% cd /usr/lib/shlib.etc % 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 <===== % ar x /usr/lib/libresolv.a

------------------------------------------------------------- | COMMENT: | | | | Yes, there is another object module with a long name which | | needs looking at. This is the reason for the 'mblen' | | unresolved references. | -------------------------------------------------------------

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

4. Remove the old routine to do the hostname/addr resolution:

% rm gethostent.o

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

% rm strcasecmp.o

6. % cd ..

7. Copy lorder-sparc to lorder-sparc.orig. Edit the file lorder-sparc and remove the reference to `gethostent.o' and add the references to the resolver library routines by applying this patch:

remove : gethostent.o

add : gethostnamadr.o sethostent.o res_query.o res_mkquery.o res_send.o res_debug.o res_comp.o res_init.o

% 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

8. % make libc.so

------------------------------------------------------------------------------------ | COMMENT: | | | | At this point you can do a 'make libc.so' and you will obtain a sensible libc.so | | library that does resolve domain names as required. However, you will still get | | the 'dlopen' unresolved names. | | There are several ways to hack around this. | | a) link with the -Bstatic flag. This works sometimes, in that my FORTRAN | | codes would work OK but the C codes fail - they really need the shared | | library routines. | | b) Add the -ldl flag to the link. This is suggested in the SUN documentation| | (Chapter 3 of man). It certainly works but it plays havoc with | | complicated Makefiles which don't have it there by default. Moreover I | | don't understand why it is needed here since it does not seem to be in | | the standard libc.so.1.8. | | | | I spent a very long time using 'ar' and 'nm' on the old libc.so.1.8 library | | (which didn't need f77 or cc to be told about -ldl) trying to find any reference | | to these routines. I found absolutely nothing!! | | | | The 'solution' came when I looked at the Makefile in shlib.etc. There on the | | first line is the ld instruction to make the new shared library from a list of | | object modules, archives or SHARED OBJECTS (read manual carefully!). What happens| | I thought if I add the libdl library to the end of this list. Amazingly this | | works perfectly - all unresolved references vanish!!! Strangely the revised | | libc.so.1.8.3 (I had a few trials!!) is the same size as the libc.so.1.8.1 | | produced by your basic recipe but 'diff' says the two are different. | | | | So, I would add the following amendments to your procedure at this point. | | | | % edit Makefile | | % change | | ld -assert pure-text `${OBJSORT} lorder-sparc tmp` | | to | | ld -assert pure-text `${OBJSORT} lorder-sparc tmp` /usr/lib/libdl.so.1.0 | | | | (or equivalent if you want to use /usr/5lib) | | | | % make libc.so | | | | Then continue as before. | ------------------------------------------------------------------------------------

9. Now some libc.so.x.y.z built in the current directory. It is recommended that you test out this library at this point before installing it. Can do so by setting the environment LD_LIBRARY_PATH to the current directory, for example:

This step did not work.

----------------------------- | COMMENT: | | | | It worked fine for me!!!! | -----------------------------

Proceede with copying libc.so.1.8.1 to usr/lib and do the ldconfig.

% setenv LD_LIBRARY_PATH `pwd` % your_favorite_test_cmd (ie. ping, ftp, telnet)

Once satisfied that the new library worked, proceed to install it with the following commands:

% cp libc.so.x.y.z /usr/lib % ldconfig % unsetenv LD_LIBRARY_PATH

10. Now running with the new library. 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.

SYMPTOMS : Can resolve addresses with nslookup, but can't ping, telnet, or ftp to system by name. KEYWORDS : shared library libc.so resolver nameserver

PRODUCT : DNS

<=============== End Included Message =================>

Veel plezier!!

Peter Watkins

Joint Research Centre, | Tel: +31-2246-5120 European Commission, | Fax: +31-2246-1449 Petten, The Netherlands. | Email: peter@jrc.nl

To: "Bill Wang" <wcwang@cs.indiana.edu> From: strombrg@hydra.acs.uci.edu

In message <199307122015.AA30534@delta.eecs.nwu.edu> you write: > >Site configuration: Sun Sparc IPC running running SunOS 4.1.3 without > NIS. > >Aims: To get DNS fully functioning with 'telnet, ftp, ping ...' without using > 'nslookup' everytime.

I've used this with success. If you modify it to make it work for you, please send my diff's, or at least the modified script, along with a quicky note about the architecture. I'd like to get this working on anything running SunOS-4.1*

#!/bin/sh # run as root! # # has worked on: # sun3 running SunOS-4.1.1_U1 # sun4c running SunOS-4.1.3

set -x cd /usr/lib/shlib.etc rm -rf tmp mkdir tmp cd tmp ar x ../libc_pic.a rm __.SYMDEF mv rpc_dtablesize. rpc_dtablesize.o mv rpc_commondata. rpc_commondata.o # In my source, this was said to be "xccs_multibyte." mv xccs.multibyte. xccs_multibyte.o # In my source, the two rm's followed the ld... but things were multiply defined #ar x ${RESLIB:-/usr/lib/libresolv.a} if [ "$RESLIB" = "" ] then RESLIB=/usr/lib/libresolv.a fi ar x $RESLIB rm gethostent.o rm strcasecmp.o ld -assert pure-text *.o cd .. # This test is pretty simplistic - could fail pretty easily if grep res_mkquery lorder-sparc > /dev/null then echo 'assuming lorder-sparc has already been updated' else patch << 'EOF' % diff -rc2 lorder-sparc.orig lorder-sparc *** /dev/null 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 EOF fi # This test is pretty simplistic - could fail pretty easily if grep ldl Makefile > /dev/null then echo 'assuming Makefile has already been updated' else patch << 'EOF' *** Makefile.dist Mon Apr 5 10:29:32 1993 --- Makefile Mon Apr 5 11:18:26 1993 *************** *** 3,14 **** # ! OBJSORT=objsort AWKFILE=awkfile 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}` echo libc.so.`cat TMP_FILE | awk -f ${AWKFILE}` built. --- 3,14 ---- # ! OBJSORT=./objsort AWKFILE=awkfile libc.so: ! ld -assert pure-text -ldl `${OBJSORT} lorder-sparc tmp` /bin/ls /usr/lib/libc.so.* > TMP_FILE mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}` echo libc.so.`cat TMP_FILE | awk -f ${AWKFILE}` built. EOF fi make libc.so echo 'removing tmp directory in background' rm -rf tmp &

Dan Stromberg - OAC/DCS strombrg@uci.edu

-- Bill Wang US Mail = Psychology Department, Indiana University, Bloomington, IN 47405 Internet = wcwang@cs.indiana.edu



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:08:00 CDT