Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: resolver environment variables

355 views
Skip to first unread message

Greg Chavez

unread,
Mar 15, 2006, 3:15:14 PM3/15/06
to
On 3/14/06, David Carmean <dlc...@halibut.com> 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).

I only have Solaris (8/9/10) servers to play with, but according to
the manpage for resolver(4):

The current domain name
is defined by the hostname if not specified in the configuration file; it
can be overridden by the environment variable LOCALDOMAIN. This environ-
ment variable may contain several blank-separated tokens if you wish to
override the ``search list'' on a per-process basis. This is similar to
the search command in the configuration file. Another environment vari-
able (``RES_OPTIONS'') can be set to override certain internal resolver
options which are otherwise set by changing fields in the statp / _res
structure or are inherited from the configuration file's options command.
The syntax of the ``RES_OPTIONS'' environment variable is explained in
resolver(5). Initialization normally occurs on the first call to one of
the other resolver routines.

I would imagine that only OS resolver routines would be able to use
these variables, as opposed to tools like nslookup and dig. Why the
aversion to using resolv.conf? Just want to use these variables for
the halibut?

--
--Greg Chavez
--


Joseph S D Yao

unread,
Mar 15, 2006, 4:49:22 PM3/15/06
to
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?


--
Joe Yao
-----------------------------------------------------------------------
This message is not an official statement of OSIS Center policies.


David Carmean

unread,
Mar 15, 2006, 7:32:00 PM3/15/06
to
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.


Joseph S D Yao

unread,
Mar 16, 2006, 1:02:48 PM3/16/06
to

???? 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);
}
=======================================================================

0 new messages