resolver environment variables
Joseph S D Yao
jsdy at center.osis.gov
Thu Mar 16 18:02:48 UTC 2006
On Wed, Mar 15, 2006 at 04:32:00PM -0800, David Carmean wrote:
> On Wed, Mar 15, 2006 at 04:49:22PM -0500, Joseph S D Yao wrote:
> > On Tue, Mar 14, 2006 at 01:52:54PM -0800, David Carmean wrote:
> > > Do the environment variables LOCALDOMAIN, RES_OPTIONS, and friends
> > > actually work on any common/modern OS package? I have so far been
> > > unsuccessful in using RES_OPTIONS or LOCALDOMAIN in FreeBSD (4.x and 5.4),
> > > Solaris (2.8, 2.9), and Linux (RedHat 8).
> > >
> > > Thanks.
> >
> > I double-checked the code and our local libc.* files, and I was wrong
> > yesterday. They do appear to be compiled into the running versions of
> > the resolver library, on Red Hat Linux, at least..
> >
> > How had you been trying to make them work?
>
> By setting, for example, $LOCALDOMAIN to a subdomain not in the client's
> search order and using ping to test the client's resolver.
>
> However, on Solaris and (RedHat) Linux it's starting to look like an nscd
> issue.
???? AFAIK, 'nscd' doesn't run on RHL.
!!ps -ef | grep 'nsc[d]'
Nope.
I also tried same here, and despite the strings being in the libc.so
[redirected], nothing changed when doing [e.g.] a 'ping':
bash$ LOCALDOMAIN="somebody.else" ping ns1
[get local "ns1" response]
I would have to trace this down a bit, but I suspect that many programs
don't actually use the BIND resolver routines. This may be a legacy
thing.
I compiled the following program and ran it twice:
bash$ ./gethost_test
[shows local host]
bash$ LOCALDOMAIN="somebody.else" ./gethost_test
[shows "somebody else"'s host]
So it IS in there!
=========================== gethost_test.c ============================
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <netdb.h>
#define NUL '\0'
#define DIRC '/'
#define FLAGC '-'
char *myname = "gethost_test";
static char default_host[] = "ns1";
char *ip2str(unsigned char *addr);
int main(int argc, char **argv, char **envp)
{
char *cp;
extern int h_errno;
struct hostent *gp;
if (argc > 0) {
cp = strrchr(*argv, DIRC);
if (cp == (char *) NULL) {
myname = *argv;
} else {
myname = ++cp;
}
}
gp = gethostbyname(default_host);
if (gp == (struct hostent *) NULL) {
herror(myname);
return(1);
}
if (gp->h_name == (char *) NULL) {
fprintf(stderr, "%s: found no name matching \"%s\".\n",
myname, default_host);
return(1);
}
printf("%s == %s\n", gp->h_name, ip2str(gp->h_addr));
return(0);
}
char *ip2str(unsigned char *addr)
{
static char buffer[16];
sprintf(buffer, "%u.%u.%u.%u",
addr[0], addr[1], addr[2], addr[3]);
return(buffer);
}
=======================================================================
--
Joe Yao
-----------------------------------------------------------------------
This message is not an official statement of OSIS Center policies.
More information about the bind-users
mailing list