10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2830Sdjl * Common Development and Distribution License (the "License"). 6*2830Sdjl * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*2830Sdjl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*2830Sdjl * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * gethostent.c 300Sstevel@tonic-gate * 310Sstevel@tonic-gate * In order to avoid duplicating libresolv code here, and since libresolv.so.2 320Sstevel@tonic-gate * provides res_-equivalents of the getXbyY and {set,get}Xent, lets call 330Sstevel@tonic-gate * re_gethostbyaddr() and so on from this file. Among other things, this 340Sstevel@tonic-gate * should help us avoid problems like the one described in bug 1264386, 350Sstevel@tonic-gate * where the internal getanswer() acquired new functionality in BIND 4.9.3, 360Sstevel@tonic-gate * but the local copy of getanswer() in this file wasn't updated, so that new 370Sstevel@tonic-gate * functionality wasn't available to the name service switch. 380Sstevel@tonic-gate */ 390Sstevel@tonic-gate 400Sstevel@tonic-gate #define gethostbyaddr res_gethostbyaddr 410Sstevel@tonic-gate #define gethostbyname res_gethostbyname 420Sstevel@tonic-gate #define gethostbyname2 res_gethostbyname2 430Sstevel@tonic-gate #define sethostent res_sethostent 440Sstevel@tonic-gate #define endhostent res_endhostent 450Sstevel@tonic-gate 460Sstevel@tonic-gate #include "dns_common.h" 470Sstevel@tonic-gate 480Sstevel@tonic-gate extern char *inet_ntoa(struct in_addr in); 490Sstevel@tonic-gate 500Sstevel@tonic-gate struct hostent *_gethostbyname(int *h_errnop, const char *name); 510Sstevel@tonic-gate static struct hostent *_gethostbyaddr(int *h_errnop, const char *addr, 520Sstevel@tonic-gate int len, int type); 530Sstevel@tonic-gate struct hostent *_nss_dns_gethostbyname2(int *h_errnop, const char *name); 540Sstevel@tonic-gate 550Sstevel@tonic-gate #pragma weak res_gethostbyname 560Sstevel@tonic-gate #pragma weak res_gethostbyname2 570Sstevel@tonic-gate #pragma weak res_gethostbyaddr 580Sstevel@tonic-gate #pragma weak res_sethostent 590Sstevel@tonic-gate #pragma weak res_endhostent 600Sstevel@tonic-gate 610Sstevel@tonic-gate nss_backend_t *_nss_dns_constr(dns_backend_op_t ops[], int n_ops); 620Sstevel@tonic-gate nss_status_t __nss_dns_getbyaddr(dns_backend_ptr_t, void *); 630Sstevel@tonic-gate 640Sstevel@tonic-gate typedef union { 650Sstevel@tonic-gate long al; 660Sstevel@tonic-gate char ac; 670Sstevel@tonic-gate } align; 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* 700Sstevel@tonic-gate * Internet Name Domain Server (DNS) only implementation. 710Sstevel@tonic-gate */ 720Sstevel@tonic-gate static struct hostent * 730Sstevel@tonic-gate _gethostbyaddr(int *h_errnop, const char *addr, int len, int type) 740Sstevel@tonic-gate { 750Sstevel@tonic-gate struct hostent *hp; 760Sstevel@tonic-gate 770Sstevel@tonic-gate hp = gethostbyaddr(addr, len, type); 780Sstevel@tonic-gate *h_errnop = *get_h_errno(); 790Sstevel@tonic-gate return (hp); 800Sstevel@tonic-gate } 810Sstevel@tonic-gate 820Sstevel@tonic-gate struct hostent * 830Sstevel@tonic-gate _nss_dns_gethostbyname2(int *h_errnop, const char *name) 840Sstevel@tonic-gate { 850Sstevel@tonic-gate struct hostent *hp; 860Sstevel@tonic-gate 870Sstevel@tonic-gate hp = gethostbyname2(name, AF_INET6); 880Sstevel@tonic-gate *h_errnop = *get_h_errno(); 890Sstevel@tonic-gate return (hp); 900Sstevel@tonic-gate } 910Sstevel@tonic-gate 920Sstevel@tonic-gate struct hostent * 930Sstevel@tonic-gate _gethostbyname(int *h_errnop, const char *name) 940Sstevel@tonic-gate { 950Sstevel@tonic-gate struct hostent *hp; 960Sstevel@tonic-gate 970Sstevel@tonic-gate hp = gethostbyname(name); 980Sstevel@tonic-gate *h_errnop = *get_h_errno(); 990Sstevel@tonic-gate return (hp); 1000Sstevel@tonic-gate } 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate static void 1030Sstevel@tonic-gate _sethostent(errp, stayopen) 1040Sstevel@tonic-gate nss_status_t *errp; 1050Sstevel@tonic-gate int stayopen; 1060Sstevel@tonic-gate { 1070Sstevel@tonic-gate int ret; 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate ret = sethostent(stayopen); 1100Sstevel@tonic-gate if (ret == 0) 1110Sstevel@tonic-gate *errp = NSS_SUCCESS; 1120Sstevel@tonic-gate else 1130Sstevel@tonic-gate *errp = NSS_UNAVAIL; 1140Sstevel@tonic-gate } 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate static void 1170Sstevel@tonic-gate _endhostent(errp) 1180Sstevel@tonic-gate nss_status_t *errp; 1190Sstevel@tonic-gate { 1200Sstevel@tonic-gate int ret; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate ret = endhostent(); 1230Sstevel@tonic-gate if (ret == 0) 1240Sstevel@tonic-gate *errp = NSS_SUCCESS; 1250Sstevel@tonic-gate else 1260Sstevel@tonic-gate *errp = NSS_UNAVAIL; 1270Sstevel@tonic-gate } 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate /*ARGSUSED*/ 1310Sstevel@tonic-gate static nss_status_t 1320Sstevel@tonic-gate getbyname(be, a) 1330Sstevel@tonic-gate dns_backend_ptr_t be; 1340Sstevel@tonic-gate void *a; 1350Sstevel@tonic-gate { 1360Sstevel@tonic-gate struct hostent *he; 1370Sstevel@tonic-gate nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a; 1380Sstevel@tonic-gate int ret, mt_disabled; 1390Sstevel@tonic-gate int old_retry; 1400Sstevel@tonic-gate sigset_t oldmask; 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate switch_resolver_setup(&mt_disabled, &oldmask, &old_retry); 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate he = _gethostbyname(&argp->h_errno, argp->key.name); 1450Sstevel@tonic-gate if (he != NULL) { 146*2830Sdjl if (argp->buf.result == NULL) { 147*2830Sdjl /* 148*2830Sdjl * if asked to return data in string, 149*2830Sdjl * convert the hostent structure into 150*2830Sdjl * string data 151*2830Sdjl */ 152*2830Sdjl ret = ent2str(he, a, AF_INET); 153*2830Sdjl if (ret == NSS_STR_PARSE_SUCCESS) 154*2830Sdjl argp->returnval = argp->buf.buffer; 1550Sstevel@tonic-gate } else { 156*2830Sdjl ret = ent2result(he, a, AF_INET); 157*2830Sdjl if (ret == NSS_STR_PARSE_SUCCESS) 158*2830Sdjl argp->returnval = argp->buf.result; 159*2830Sdjl } 160*2830Sdjl 161*2830Sdjl if (ret != NSS_STR_PARSE_SUCCESS) { 1620Sstevel@tonic-gate argp->h_errno = HOST_NOT_FOUND; 1630Sstevel@tonic-gate if (ret == NSS_STR_PARSE_ERANGE) { 1640Sstevel@tonic-gate argp->erange = 1; 1650Sstevel@tonic-gate } 1660Sstevel@tonic-gate } 1670Sstevel@tonic-gate } 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate switch_resolver_reset(mt_disabled, oldmask, old_retry); 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate return (_herrno2nss(argp->h_errno)); 1720Sstevel@tonic-gate } 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate /*ARGSUSED*/ 1770Sstevel@tonic-gate static nss_status_t 1780Sstevel@tonic-gate getbyaddr(be, a) 1790Sstevel@tonic-gate dns_backend_ptr_t be; 1800Sstevel@tonic-gate void *a; 1810Sstevel@tonic-gate { 1820Sstevel@tonic-gate return (__nss_dns_getbyaddr(be, a)); 1830Sstevel@tonic-gate } 1840Sstevel@tonic-gate 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate /* 1870Sstevel@tonic-gate * Exposing a DNS backend specific interface so that it doesn't conflict 1880Sstevel@tonic-gate * with other getbyaddr() routines from other switch backends. 1890Sstevel@tonic-gate */ 190*2830Sdjl /*ARGSUSED*/ 1910Sstevel@tonic-gate nss_status_t 1920Sstevel@tonic-gate __nss_dns_getbyaddr(be, a) 1930Sstevel@tonic-gate dns_backend_ptr_t be; 1940Sstevel@tonic-gate void *a; 1950Sstevel@tonic-gate { 1960Sstevel@tonic-gate size_t n; 1970Sstevel@tonic-gate struct hostent *he, *he2; 1980Sstevel@tonic-gate nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a; 1990Sstevel@tonic-gate int ret, save_h_errno, mt_disabled; 2000Sstevel@tonic-gate char **ans, hbuf[MAXHOSTNAMELEN]; 2010Sstevel@tonic-gate char dst[INET6_ADDRSTRLEN]; 2020Sstevel@tonic-gate struct in_addr unmapv4; 2030Sstevel@tonic-gate sigset_t oldmask; 2040Sstevel@tonic-gate int af, addrlen; 2050Sstevel@tonic-gate void *addrp; 2060Sstevel@tonic-gate int old_retry; 2070Sstevel@tonic-gate 2080Sstevel@tonic-gate switch_resolver_setup(&mt_disabled, &oldmask, &old_retry); 2090Sstevel@tonic-gate 210*2830Sdjl /* LINTED: E_BAD_PTR_CAST_ALIGN */ 2110Sstevel@tonic-gate if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)argp->key.hostaddr.addr)) { 2120Sstevel@tonic-gate addrp = &unmapv4; 2130Sstevel@tonic-gate addrlen = sizeof (unmapv4); 2140Sstevel@tonic-gate af = AF_INET; 215*2830Sdjl (void) memcpy(addrp, &argp->key.hostaddr.addr[12], addrlen); 2160Sstevel@tonic-gate } else { 2170Sstevel@tonic-gate addrp = (void *)argp->key.hostaddr.addr; 2180Sstevel@tonic-gate addrlen = argp->key.hostaddr.len; 2190Sstevel@tonic-gate af = argp->key.hostaddr.type; 2200Sstevel@tonic-gate } 2210Sstevel@tonic-gate he = _gethostbyaddr(&argp->h_errno, addrp, addrlen, af); 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate if (he != NULL) { 2240Sstevel@tonic-gate if (strlen(he->h_name) >= MAXHOSTNAMELEN) 2250Sstevel@tonic-gate ret = NSS_STR_PARSE_ERANGE; 2260Sstevel@tonic-gate else { 2270Sstevel@tonic-gate /* save a copy of the (alleged) hostname */ 2280Sstevel@tonic-gate (void) strcpy(hbuf, he->h_name); 2290Sstevel@tonic-gate n = strlen(hbuf); 2300Sstevel@tonic-gate if (n < MAXHOSTNAMELEN-1 && hbuf[n-1] != '.') { 2310Sstevel@tonic-gate (void) strcat(hbuf, "."); 2320Sstevel@tonic-gate } 233*2830Sdjl 234*2830Sdjl /* 235*2830Sdjl * if asked to return data in string, 236*2830Sdjl * convert the hostent structure into 237*2830Sdjl * string data 238*2830Sdjl */ 239*2830Sdjl if (argp->buf.result == NULL) 240*2830Sdjl ret = ent2str(he, a, argp->key.hostaddr.type); 241*2830Sdjl else 242*2830Sdjl ret = ent2result(he, a, 243*2830Sdjl argp->key.hostaddr.type); 244*2830Sdjl 2450Sstevel@tonic-gate save_h_errno = argp->h_errno; 2460Sstevel@tonic-gate } 2470Sstevel@tonic-gate if (ret == NSS_STR_PARSE_SUCCESS) { 2480Sstevel@tonic-gate /* 2490Sstevel@tonic-gate * check to make sure by doing a forward query 2500Sstevel@tonic-gate * We use _gethostbyname() to avoid the stack, and 2510Sstevel@tonic-gate * then we throw the result from argp->h_errno away, 2520Sstevel@tonic-gate * becase we don't care. And besides you want the 2530Sstevel@tonic-gate * return code from _gethostbyaddr() anyway. 2540Sstevel@tonic-gate */ 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate if (af == AF_INET) 2570Sstevel@tonic-gate he2 = _gethostbyname(&argp->h_errno, hbuf); 2580Sstevel@tonic-gate else 2590Sstevel@tonic-gate he2 = _nss_dns_gethostbyname2(&argp->h_errno, 2600Sstevel@tonic-gate hbuf); 2610Sstevel@tonic-gate if (he2 != (struct hostent *)NULL) { 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate /* until we prove name and addr match */ 2640Sstevel@tonic-gate argp->h_errno = HOST_NOT_FOUND; 2650Sstevel@tonic-gate for (ans = he2->h_addr_list; *ans; ans++) 2660Sstevel@tonic-gate if (memcmp(*ans, addrp, addrlen) == 2670Sstevel@tonic-gate 0) { 2680Sstevel@tonic-gate argp->h_errno = save_h_errno; 269*2830Sdjl if (argp->buf.result == NULL) 270*2830Sdjl argp->returnval = 271*2830Sdjl argp->buf.buffer; 272*2830Sdjl else 273*2830Sdjl argp->returnval = 274*2830Sdjl argp->buf.result; 2750Sstevel@tonic-gate break; 2760Sstevel@tonic-gate } 2770Sstevel@tonic-gate } else { 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate /* 2800Sstevel@tonic-gate * What to do if _gethostbyname() fails ??? 2810Sstevel@tonic-gate * We assume they are doing something stupid 2820Sstevel@tonic-gate * like registering addresses but not names 2830Sstevel@tonic-gate * (some people actually think that provides 2840Sstevel@tonic-gate * some "security", through obscurity). So for 2850Sstevel@tonic-gate * these poor lost souls, because we can't 2860Sstevel@tonic-gate * PROVE spoofing and because we did try (and 2870Sstevel@tonic-gate * we don't want a bug filed on this), we let 2880Sstevel@tonic-gate * this go. And return the name from byaddr. 2890Sstevel@tonic-gate */ 2900Sstevel@tonic-gate argp->h_errno = save_h_errno; 291*2830Sdjl if (argp->buf.result == NULL) 292*2830Sdjl argp->returnval = argp->buf.buffer; 293*2830Sdjl else 294*2830Sdjl argp->returnval = argp->buf.result; 2950Sstevel@tonic-gate } 2960Sstevel@tonic-gate /* we've been spoofed, make sure to log it. */ 2970Sstevel@tonic-gate if (argp->h_errno == HOST_NOT_FOUND) { 2980Sstevel@tonic-gate if (argp->key.hostaddr.type == AF_INET) 2990Sstevel@tonic-gate syslog(LOG_NOTICE, "gethostbyaddr: %s != %s", 300*2830Sdjl /* LINTED: E_BAD_PTR_CAST_ALIGN */ 3010Sstevel@tonic-gate hbuf, inet_ntoa(*(struct in_addr *)argp->key.hostaddr.addr)); 3020Sstevel@tonic-gate else 3030Sstevel@tonic-gate syslog(LOG_NOTICE, "gethostbyaddr: %s != %s", 3040Sstevel@tonic-gate hbuf, inet_ntop(AF_INET6, (void *) argp->key.hostaddr.addr, 3050Sstevel@tonic-gate dst, sizeof (dst))); 3060Sstevel@tonic-gate } 3070Sstevel@tonic-gate } else { 3080Sstevel@tonic-gate argp->h_errno = HOST_NOT_FOUND; 3090Sstevel@tonic-gate if (ret == NSS_STR_PARSE_ERANGE) { 3100Sstevel@tonic-gate argp->erange = 1; 3110Sstevel@tonic-gate } 3120Sstevel@tonic-gate } 3130Sstevel@tonic-gate } 3140Sstevel@tonic-gate 3150Sstevel@tonic-gate switch_resolver_reset(mt_disabled, oldmask, old_retry); 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate return (_herrno2nss(argp->h_errno)); 3180Sstevel@tonic-gate } 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate /*ARGSUSED*/ 3220Sstevel@tonic-gate static nss_status_t 3230Sstevel@tonic-gate _nss_dns_getent(be, args) 3240Sstevel@tonic-gate dns_backend_ptr_t be; 3250Sstevel@tonic-gate void *args; 3260Sstevel@tonic-gate { 3270Sstevel@tonic-gate return (NSS_UNAVAIL); 3280Sstevel@tonic-gate } 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate 3310Sstevel@tonic-gate /*ARGSUSED*/ 3320Sstevel@tonic-gate static nss_status_t 3330Sstevel@tonic-gate _nss_dns_setent(be, dummy) 3340Sstevel@tonic-gate dns_backend_ptr_t be; 3350Sstevel@tonic-gate void *dummy; 3360Sstevel@tonic-gate { 3370Sstevel@tonic-gate nss_status_t errp; 3380Sstevel@tonic-gate 3390Sstevel@tonic-gate sigset_t oldmask, newmask; 3400Sstevel@tonic-gate int mt_disabled = 1; 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate /* 3430Sstevel@tonic-gate * Try to enable MT; if not, we have to single-thread libresolv 3440Sstevel@tonic-gate * access 3450Sstevel@tonic-gate */ 3460Sstevel@tonic-gate if (enable_mt == 0 || (mt_disabled = (*enable_mt)()) != 0) { 3470Sstevel@tonic-gate (void) sigfillset(&newmask); 3480Sstevel@tonic-gate _thr_sigsetmask(SIG_SETMASK, &newmask, &oldmask); 3490Sstevel@tonic-gate _mutex_lock(&one_lane); 3500Sstevel@tonic-gate } 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate _sethostent(&errp, 1); 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate if (mt_disabled) { 3550Sstevel@tonic-gate _mutex_unlock(&one_lane); 3560Sstevel@tonic-gate _thr_sigsetmask(SIG_SETMASK, &oldmask, NULL); 3570Sstevel@tonic-gate } else { 3580Sstevel@tonic-gate (void) (*disable_mt)(); 3590Sstevel@tonic-gate } 3600Sstevel@tonic-gate 3610Sstevel@tonic-gate return (errp); 3620Sstevel@tonic-gate } 3630Sstevel@tonic-gate 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate /*ARGSUSED*/ 3660Sstevel@tonic-gate static nss_status_t 3670Sstevel@tonic-gate _nss_dns_endent(be, dummy) 3680Sstevel@tonic-gate dns_backend_ptr_t be; 3690Sstevel@tonic-gate void *dummy; 3700Sstevel@tonic-gate { 3710Sstevel@tonic-gate nss_status_t errp; 3720Sstevel@tonic-gate 3730Sstevel@tonic-gate sigset_t oldmask, newmask; 3740Sstevel@tonic-gate int mt_disabled = 1; 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate /* 3770Sstevel@tonic-gate * Try to enable MT; if not, we have to single-thread libresolv 3780Sstevel@tonic-gate * access 3790Sstevel@tonic-gate */ 3800Sstevel@tonic-gate if (enable_mt == 0 || (mt_disabled = (*enable_mt)()) != 0) { 3810Sstevel@tonic-gate (void) sigfillset(&newmask); 3820Sstevel@tonic-gate _thr_sigsetmask(SIG_SETMASK, &newmask, &oldmask); 3830Sstevel@tonic-gate _mutex_lock(&one_lane); 3840Sstevel@tonic-gate } 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate _endhostent(&errp); 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate if (mt_disabled) { 3890Sstevel@tonic-gate _mutex_unlock(&one_lane); 3900Sstevel@tonic-gate _thr_sigsetmask(SIG_SETMASK, &oldmask, NULL); 3910Sstevel@tonic-gate } else { 3920Sstevel@tonic-gate (void) (*disable_mt)(); 3930Sstevel@tonic-gate } 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate return (errp); 3960Sstevel@tonic-gate } 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate /*ARGSUSED*/ 4000Sstevel@tonic-gate static nss_status_t 4010Sstevel@tonic-gate _nss_dns_destr(be, dummy) 4020Sstevel@tonic-gate dns_backend_ptr_t be; 4030Sstevel@tonic-gate void *dummy; 4040Sstevel@tonic-gate { 4050Sstevel@tonic-gate nss_status_t errp; 4060Sstevel@tonic-gate 4070Sstevel@tonic-gate if (be != 0) { 4080Sstevel@tonic-gate /* === Should change to invoke ops[ENDENT] ? */ 4090Sstevel@tonic-gate sigset_t oldmask, newmask; 4100Sstevel@tonic-gate int mt_disabled = 1; 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate if (enable_mt == 0 || (mt_disabled = (*enable_mt)()) != 0) { 4130Sstevel@tonic-gate (void) sigfillset(&newmask); 4140Sstevel@tonic-gate _thr_sigsetmask(SIG_SETMASK, &newmask, &oldmask); 4150Sstevel@tonic-gate _mutex_lock(&one_lane); 4160Sstevel@tonic-gate } 4170Sstevel@tonic-gate 4180Sstevel@tonic-gate _endhostent(&errp); 4190Sstevel@tonic-gate 4200Sstevel@tonic-gate if (mt_disabled) { 4210Sstevel@tonic-gate _mutex_unlock(&one_lane); 4220Sstevel@tonic-gate _thr_sigsetmask(SIG_SETMASK, &oldmask, NULL); 4230Sstevel@tonic-gate } else { 4240Sstevel@tonic-gate (void) (*disable_mt)(); 4250Sstevel@tonic-gate } 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate free(be); 4280Sstevel@tonic-gate } 4290Sstevel@tonic-gate return (NSS_SUCCESS); /* In case anyone is dumb enough to check */ 4300Sstevel@tonic-gate } 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate 4330Sstevel@tonic-gate static dns_backend_op_t host_ops[] = { 4340Sstevel@tonic-gate _nss_dns_destr, 4350Sstevel@tonic-gate _nss_dns_endent, 4360Sstevel@tonic-gate _nss_dns_setent, 4370Sstevel@tonic-gate _nss_dns_getent, 4380Sstevel@tonic-gate getbyname, 4390Sstevel@tonic-gate getbyaddr, 4400Sstevel@tonic-gate }; 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate /*ARGSUSED*/ 4430Sstevel@tonic-gate nss_backend_t * 4440Sstevel@tonic-gate _nss_dns_hosts_constr(dummy1, dummy2, dummy3) 4450Sstevel@tonic-gate const char *dummy1, *dummy2, *dummy3; 4460Sstevel@tonic-gate { 4470Sstevel@tonic-gate return (_nss_dns_constr(host_ops, 4480Sstevel@tonic-gate sizeof (host_ops) / sizeof (host_ops[0]))); 4490Sstevel@tonic-gate } 450*2830Sdjl 451*2830Sdjl /* 452*2830Sdjl * optional NSS2 packed backend gethostsbyname with ttl 453*2830Sdjl * entry point. 454*2830Sdjl * 455*2830Sdjl * Returns: 456*2830Sdjl * NSS_SUCCESS - successful 457*2830Sdjl * NSS_NOTFOUND - successful but nothing found 458*2830Sdjl * NSS_ERROR - fallback to NSS backend lookup mode 459*2830Sdjl * If successful, buffer will be filled with valid data 460*2830Sdjl * 461*2830Sdjl */ 462*2830Sdjl 463*2830Sdjl /*ARGSUSED*/ 464*2830Sdjl nss_status_t 465*2830Sdjl _nss_get_dns_hosts_name(dns_backend_ptr_t *be, void **bufp, size_t *sizep) 466*2830Sdjl { 467*2830Sdjl return (_nss_dns_gethost_withttl(*bufp, *sizep, 0)); 468*2830Sdjl } 469