gethostent.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 1993, 1998-2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* In order to avoid duplicating libresolv code here, and since libresolv.so.2
* provides res_-equivalents of the getXbyY and {set,get}Xent, lets call
* re_gethostbyaddr() and so on from this file. Among other things, this
* should help us avoid problems like the one described in bug 1264386,
* where the internal getanswer() acquired new functionality in BIND 4.9.3,
* but the local copy of getanswer() in this file wasn't updated, so that new
* functionality wasn't available to the name service switch.
*/
#define gethostbyaddr res_gethostbyaddr
#define gethostbyname res_gethostbyname
#define gethostbyname2 res_gethostbyname2
#define sethostent res_sethostent
#define endhostent res_endhostent
#include "dns_common.h"
#pragma weak res_gethostbyname
#pragma weak res_gethostbyname2
#pragma weak res_gethostbyaddr
#pragma weak res_sethostent
#pragma weak res_endhostent
typedef union {
long al;
char ac;
} align;
/*
* Internet Name Domain Server (DNS) only implementation.
*/
static struct hostent *
{
*h_errnop = *get_h_errno();
return (hp);
}
struct hostent *
{
*h_errnop = *get_h_errno();
return (hp);
}
struct hostent *
{
*h_errnop = *get_h_errno();
return (hp);
}
static void
int stayopen;
{
int ret;
if (ret == 0)
*errp = NSS_SUCCESS;
else
*errp = NSS_UNAVAIL;
}
static void
{
int ret;
ret = endhostent();
if (ret == 0)
*errp = NSS_SUCCESS;
else
*errp = NSS_UNAVAIL;
}
/*ARGSUSED*/
static nss_status_t
void *a;
{
int ret, mt_disabled;
int old_retry;
if (ret == NSS_STR_PARSE_SUCCESS) {
} else {
if (ret == NSS_STR_PARSE_ERANGE) {
}
}
}
}
/*ARGSUSED*/
static nss_status_t
void *a;
{
return (__nss_dns_getbyaddr(be, a));
}
/*
* Exposing a DNS backend specific interface so that it doesn't conflict
* with other getbyaddr() routines from other switch backends.
*/
void *a;
{
size_t n;
char dst[INET6_ADDRSTRLEN];
void *addrp;
int old_retry;
} else {
}
else {
/* save a copy of the (alleged) hostname */
}
}
if (ret == NSS_STR_PARSE_SUCCESS) {
/*
* check to make sure by doing a forward query
* We use _gethostbyname() to avoid the stack, and
* then we throw the result from argp->h_errno away,
* becase we don't care. And besides you want the
* return code from _gethostbyaddr() anyway.
*/
else
hbuf);
/* until we prove name and addr match */
0) {
break;
}
} else {
/*
* What to do if _gethostbyname() fails ???
* We assume they are doing something stupid
* like registering addresses but not names
* (some people actually think that provides
* some "security", through obscurity). So for
* these poor lost souls, because we can't
* PROVE spoofing and because we did try (and
* we don't want a bug filed on this), we let
* this go. And return the name from byaddr.
*/
}
/* we've been spoofed, make sure to log it. */
else
}
} else {
if (ret == NSS_STR_PARSE_ERANGE) {
}
}
}
}
/*ARGSUSED*/
static nss_status_t
void *args;
{
return (NSS_UNAVAIL);
}
/*ARGSUSED*/
static nss_status_t
void *dummy;
{
int mt_disabled = 1;
/*
* Try to enable MT; if not, we have to single-thread libresolv
* access
*/
(void) sigfillset(&newmask);
}
if (mt_disabled) {
} else {
(void) (*disable_mt)();
}
return (errp);
}
/*ARGSUSED*/
static nss_status_t
void *dummy;
{
int mt_disabled = 1;
/*
* Try to enable MT; if not, we have to single-thread libresolv
* access
*/
(void) sigfillset(&newmask);
}
_endhostent(&errp);
if (mt_disabled) {
} else {
(void) (*disable_mt)();
}
return (errp);
}
/*ARGSUSED*/
static nss_status_t
void *dummy;
{
if (be != 0) {
/* === Should change to invoke ops[ENDENT] ? */
int mt_disabled = 1;
(void) sigfillset(&newmask);
}
_endhostent(&errp);
if (mt_disabled) {
} else {
(void) (*disable_mt)();
}
}
return (NSS_SUCCESS); /* In case anyone is dumb enough to check */
}
static dns_backend_op_t host_ops[] = {
};
/*ARGSUSED*/
{
return (_nss_dns_constr(host_ops,
}