This document describes modifying the shared C library on SunOS 4.1.x systems to use DNS resolution via /etc/resolv.conf instead of NIS-based hostname lookups.

Prerequisites

  • Superuser access required
  • “SHLIB CUSTOM” package installed via SunInstall or add_services
  • Properly configured /etc/resolv.conf file
  • Ability to verify with /usr/etc/nslookup

Step-by-Step Procedure

1. Create Working Directory

cd /usr/lib/shlib.etc
mkdir tmp
cd tmp

2. Extract Library Objects

Extract position-independent code objects and remove symbol definitions:

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

The resolver library objects are already position-independent and can be merged safely.

3. Remove Obsolete Objects

rm gethostent.o
rm strcasecmp.o

These files either conflict with updated resolver routines or duplicate functionality now in the main C library.

4. Update Linker Configuration

Navigate back:

cd ..

Copy and edit the linker order file:

cp lorder-sparc lorder-sparc.orig

Modify lorder-sparc by replacing the gethostent.o reference with resolver library routines:

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

5. Modify Makefile

Update the OBJSORT variable to reference the local directory:

OBJSORT=./objsort

For SunOS 4.1.3 and later, append -ldl to the ld command in build targets to avoid requiring dynamic linking in all compiled executables.

6. Build New Library

make libc.so

7. Test Before Installation

Verify the new library functions correctly:

setenv LD_LIBRARY_PATH `pwd`
ping hostname
ftp somehost
telnet somehost

8. Install the Library

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

Replace x.y.z with the actual version number of your compiled library.

9. Verify Installation

Confirm the new library is active:

trace date

The output should indicate the newly built library is being used by the system.

Notes

This approach was successfully tested on SunOS 4.1.3 and 4.1.4 systems. The modification allows hostname resolution to work directly through DNS without requiring a running NIS server, which is particularly useful for standalone systems or small networks where NIS overhead is unnecessary.