/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2015 Gary Mills
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stropts.h>
#include <resolv.h>
#include <netinet/if_ether.h>
/*
* Undocumented external function in libnsl
*/
extern int
getdomainname(char *, int);
/*
* Resolver state default settings
*/
RES_TIMEOUT, /* retransmition time interval */
4, /* number of times to retransmit */
RES_DEFAULT, /* options flags */
1, /* number of name servers */
};
/*
* Set up default settings. If the configuration file exist, the values
* there will have precedence. Otherwise, the server address is set to
* INADDR_LOOPBACK and the default domain name comes from the gethostname().
*
* The configuration file should only be used if you want to redefine your
* domain or run without a server on your machine.
*
* Note the user can always override then domain name with the environment
* variable LOCALDOMAIN which has absolute priority.
*
*
* Return 0 if completes successfully, -1 on error
*/
int
res_init(void)
{
register int n;
int haveenv = 0;
int havesearch = 0;
#ifdef SIOCGIFNUM
unsigned bufsize;
unsigned int flags;
char *buf;
perror("socket");
return (-1);
}
}
perror("out of memory");
(void) close(s);
return (-1);
}
perror("ifconfig: SIOCGIFCONF");
(void) close(s);
return (-1);
}
int_up = 0;
n--, ifrp++) {
perror("SIOCGIFFLAGS");
(void) close(s);
return (-1);
}
/* we are looking for a non-loopback interface */
int_up = 1;
}
(void) close(s);
if (int_up == 0) /* all the non-LOOPBACK interfaces are DOWN */
return (-1);
}
#endif /* SIOCGIFNUM */
/*
* for the benefit of hidden NIS domains, we use the same procedure
* as sendmail: convert leading + to dot, then drop to first dot
*/
if (buf[0] == '+')
buf[0] = '.';
#ifdef SYSV
#else
#endif
else
/* Allow user to override the local domain definition */
haveenv++;
}
/* read the config file */
/* read default domain name */
if (haveenv) /* skip if have from environ */
continue;
cp++;
continue;
#ifdef SYSV
#else
#endif
*cp = '\0';
havesearch = 0;
continue;
}
/* set search list */
if (haveenv) /* skip if have from environ */
continue;
cp++;
continue;
#ifdef SYSV
#else
#endif
*cp = '\0';
/*
* Set search list to be blank-separated strings
* on rest of line.
*/
*cp = 0;
n = 1;
} else if (n) {
n = 0;
}
}
/* null terminate last domain if there are excess */
cp++;
*cp = '\0';
*pp++ = 0;
havesearch = 1;
continue;
}
/* read nameservers to query */
cp++;
continue;
continue;
}
nserv++;
continue;
}
}
if (nserv > 1)
}
#ifdef SYSV
#else
#endif
}
/* find components of local domain that might be searched */
if (havesearch == 0) {
if (*cp == '.')
n++;
#ifdef SYSV
#else
#endif
}
*pp++ = 0;
}
return (0);
}