On Wed, 9 Aug 95 21:31:26 EDT, richard@fiu.edu said:
richard> I was able to get scotty linked on a SunOS 4.1.3
richard> machine but am having problems resolving names in
richard> /etc/hosts (yp) that are not in DNS. Apparently,
richard> linking with -lresolv does this. I wrote up a small
richard> program that simply does a gethostbyname() and it
richard> worked fine. When linked with -lresolv, it doesn't
richard> find the host (just like what is happening with
richard> scotty). Anyone have a fix?
The ole story about Sun's (mis-)behavior, when looking up names/addrs
via gethostbyname/byaddr; they are both in libc and libresolv, but
behave very different:
libc only, no NIS: /etc/hosts are used only.
libc only, with NIS: NIS is used only. if the NIS-master has B=-b
in /var/yp/Makefile set (the Sun only (mis-)
feature), the NIS server resolves the query
with DNS, if not in NIS database.
libresolv (with or without NIS):
DNS is used only.
a possible fix would be:
patch your libc to include resolver-code and a selection via a
/etc/hosts.conf selection mechanism (eg. to use /etc/hosts, then
bind and then nis to lookup names/addrs).
This is provided by a package named resolv+-2.0.tar.gz
and maybe others.
(eg. avail at ftp.ibr.cs.tu-bs.de:/pub/networking/DNS/resolv+-2.0.tar.gz)
The README.SUNOS from this package is appended below; this is only for
patching the shared library, but i would suggest to patch libc.a as
well, to avoid confusion when creating static binaries.
Then libresolv should not be linked; scotty checks this when
configuring and links with libresolv only, if res_mkquery() is not
avail without (and this is the default with orig libc; with the
patched libc, this function is present and libresolv is not linked to
scotty).
However, i hope this helps a little bit to increase the confusion ;-)
Erik
---To build a resolver library suitable for insertion into a SunOS shared C library, build libresolv.a with Makefile.shlib.
% make -f Makefile.shlib
This will cause PIC code suitable for use in shared libraries to be generated.
Once libresolv.a has been built, copy it into /usr/lib/libresolv.a. Then follow these directions to insert the routines into your system's shared C library.
(Note that I have been unable to test this procedure on a 4.1.2 system. If you encounter problems, please let me know.)
These instructions assume that you've installed the resolv+ library in /usr/lib/libresolv.a. If you haven't, replace any instance of /usr/lib/libresolv.a in these instructions with the location of your resolv+ library.
1. Become super user and go to the shared library build directory % su % cd /usr/lib/shlib.etc
2. Make a temporary directory % mkdir tmp
3. Change to the "tmp" directory just made then extract the contents of libc_pic.a and libresolv.a. Then remove the file __.SYMDEF and rename the two files that had their names truncated by "ar". % cd tmp % 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
If you're running SunOS 4.1.2, you'll also need to do this: % mv xccs.multibyte. xccs.multibyte.o
4. Remove the old gethostent module, as the routines it contains are now in gethostnamadr.o. Also remove the strcasecmp and mktemp modules to avoid duplicating routines already present in Sun's C library. % rm gethostent.o strcasecmp.o mktemp.o
5. Now put the SunOS version of mktemp (which got wiped out when you unpacked libresolv.a) back into place. % ar x ../libc_pic.a mktemp.o
6. Edit the file "lorder-sparc" to reflect the changes that have been made. % vi ../lorder-sparc
Use the following "diff" to guide your editing:
% 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
7. % cd ..
8. If you're running SunOS 4.1.2, you'll need to edit the Makefile and add -ldl to the end of the ld commands. Change the lines that read ld -assert pure-text `${OBJSORT} lorder-sparc tmp` to ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
9. % make libc.so
10. 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
11. 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.
Thanks to Sun's Greg Earle for posting the original version of these instructions.