diff options
Diffstat (limited to 'nis/nss_nis')
-rw-r--r-- | nis/nss_nis/nis-ethers.c | 27 | ||||
-rw-r--r-- | nis/nss_nis/nis-hosts.c | 26 | ||||
-rw-r--r-- | nis/nss_nis/nis-proto.c | 5 | ||||
-rw-r--r-- | nis/nss_nis/nis-rpc.c | 5 | ||||
-rw-r--r-- | nis/nss_nis/nis-service.c | 35 |
5 files changed, 60 insertions, 38 deletions
diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c index c6656ee05f..2d08be7967 100644 --- a/nis/nss_nis/nis-ethers.c +++ b/nis/nss_nis/nis-ethers.c @@ -53,7 +53,7 @@ static struct response *start = NULL; static struct response *next = NULL; static int -saveit (int instatus, char *inkey, int inkeylen, char *inval, +saveit (int instatus, char *inkey, int inkeylen, char *inval, int invallen, char *indata) { if (instatus != YP_TRUE) @@ -76,7 +76,7 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval, strncpy (next->val, inval, invallen); next->val[invallen] = '\0'; } - + return 0; } @@ -85,9 +85,10 @@ internal_nis_setetherent (void) { char *domainname; struct ypall_callback ypcb; - - yp_get_default_domain(&domainname); - + enum nss_status status; + + yp_get_default_domain (&domainname); + while (start != NULL) { if (start->val != NULL) @@ -100,10 +101,10 @@ internal_nis_setetherent (void) ypcb.foreach = saveit; ypcb.data = NULL; - yp_all(domainname, "ethers.byname", &ypcb); + status = yperr2nss (yp_all (domainname, "ethers.byname", &ypcb)); next = start; - return NSS_STATUS_SUCCESS; + return status; } enum nss_status @@ -119,7 +120,7 @@ _nss_nis_setetherent (void) return result; } - + enum nss_status _nss_nis_endetherent (void) { @@ -135,9 +136,9 @@ _nss_nis_endetherent (void) } start = NULL; next = NULL; - + __libc_lock_unlock (lock); - + return NSS_STATUS_SUCCESS; } @@ -154,15 +155,15 @@ internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen) do { char *p; - + if (next == NULL) return NSS_STATUS_NOTFOUND; p = strcpy (buffer, next->val); next = next->next; - + while (isspace (*p)) ++p; - + parse_res = _nss_files_parse_etherent (p, eth, data, buflen); if (!parse_res && errno == ERANGE) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c index bab7f4c5f4..42fc5aeac7 100644 --- a/nis/nss_nis/nis-hosts.c +++ b/nis/nss_nis/nis-hosts.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996. @@ -242,7 +242,7 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen, } enum nss_status -_nss_nis_gethostbyname_r (const char *name, struct hostent *host, +_nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, char *buffer, size_t buflen, int *h_errnop) { enum nss_status retval; @@ -297,9 +297,9 @@ _nss_nis_gethostbyname_r (const char *name, struct hostent *host, parse_res = parse_line (p, host, data, buflen); - if (!parse_res) + if (!parse_res || host->h_addrtype != af) { - if (errno == ERANGE) + if (!parse_res && errno == ERANGE) { *h_errnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; @@ -316,6 +316,24 @@ _nss_nis_gethostbyname_r (const char *name, struct hostent *host, } enum nss_status +_nss_nis_gethostbyname_r (const char *name, struct hostent *host, + char *buffer, size_t buflen, int *h_errnop) +{ + if (_res.options & RES_USE_INET6) + { + enum nss_status status; + + status = _nss_nis_gethostbyname2_r (name, AF_INET6, host, buffer, buflen, + h_errnop); + if (status == NSS_STATUS_SUCCESS) + return status; + } + + return _nss_nis_gethostbyname2_r (name, AF_INET, host, buffer, buflen, + h_errnop); +} + +enum nss_status _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type, struct hostent *host, char *buffer, size_t buflen, int *h_errnop) diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c index 3349fe5b36..92ef1c0010 100644 --- a/nis/nss_nis/nis-proto.c +++ b/nis/nss_nis/nis-proto.c @@ -77,6 +77,7 @@ internal_nis_setprotoent (void) { char *domainname; struct ypall_callback ypcb; + enum nss_status status; yp_get_default_domain (&domainname); @@ -92,10 +93,10 @@ internal_nis_setprotoent (void) ypcb.foreach = saveit; ypcb.data = NULL; - yp_all (domainname, "protocols.bynumber", &ypcb); + status = yperr2nss (yp_all (domainname, "protocols.bynumber", &ypcb)); next = start; - return NSS_STATUS_SUCCESS; + return status; } enum nss_status diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c index c0e21d83da..c4c9135e3f 100644 --- a/nis/nss_nis/nis-rpc.c +++ b/nis/nss_nis/nis-rpc.c @@ -85,6 +85,7 @@ internal_nis_setrpcent (intern_t *intern) { char *domainname; struct ypall_callback ypcb; + enum nss_status status; if (yp_get_default_domain (&domainname)) return NSS_STATUS_UNAVAIL; @@ -101,10 +102,10 @@ internal_nis_setrpcent (intern_t *intern) ypcb.foreach = saveit; ypcb.data = (char *)intern; - yp_all(domainname, "rpc.bynumber", &ypcb); + status = yperr2nss (yp_all(domainname, "rpc.bynumber", &ypcb)); intern->next = intern->start; - return NSS_STATUS_SUCCESS; + return status; } enum nss_status diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c index 46c3364fe3..fe189b161b 100644 --- a/nis/nss_nis/nis-service.c +++ b/nis/nss_nis/nis-service.c @@ -50,13 +50,13 @@ struct intern_t }; typedef struct intern_t intern_t; -static intern_t intern = {NULL, NULL}; +static intern_t intern = { NULL, NULL }; static int -saveit (int instatus, char *inkey, int inkeylen, char *inval, +saveit (int instatus, char *inkey, int inkeylen, char *inval, int invallen, char *indata) { - intern_t *intern = (intern_t *)indata; + intern_t *intern = (intern_t *) indata; if (instatus != YP_TRUE) return instatus; @@ -78,7 +78,7 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval, strncpy (intern->next->val, inval, invallen); intern->next->val[invallen] = '\0'; } - + return 0; } @@ -87,10 +87,11 @@ internal_nis_setservent (intern_t *intern) { char *domainname; struct ypall_callback ypcb; - + enum nss_status status; + if (yp_get_default_domain (&domainname)) return NSS_STATUS_UNAVAIL; - + while (intern->start != NULL) { if (intern->start->val != NULL) @@ -102,11 +103,11 @@ internal_nis_setservent (intern_t *intern) intern->start = NULL; ypcb.foreach = saveit; - ypcb.data = (char *)intern; - yp_all(domainname, "services.byname", &ypcb); + ypcb.data = (char *) intern; + status = yperr2nss (yp_all (domainname, "services.byname", &ypcb)); intern->next = intern->start; - return NSS_STATUS_SUCCESS; + return status; } enum nss_status _nss_nis_setservent (void) @@ -134,7 +135,7 @@ internal_nis_endservent (intern_t * intern) free (intern->next); } intern->start = NULL; - + return NSS_STATUS_SUCCESS; } @@ -161,7 +162,7 @@ internal_nis_getservent_r (struct servent *serv, char *buffer, if (data->start == NULL) internal_nis_setservent (data); - + /* Get the next entry until we found a correct one. */ do { @@ -171,7 +172,7 @@ internal_nis_getservent_r (struct servent *serv, char *buffer, data->next = data->next->next; while (isspace (*p)) ++p; - + parse_res = _nss_files_parse_servent (p, serv, buffer, buflen); if (!parse_res && errno == ERANGE) return NSS_STATUS_TRYAGAIN; @@ -199,7 +200,7 @@ enum nss_status _nss_nis_getservbyname_r (const char *name, char *protocol, struct servent *serv, char *buffer, size_t buflen) { - intern_t data = {NULL, NULL}; + intern_t data = { NULL, NULL }; enum nss_status status; int found; @@ -221,16 +222,16 @@ _nss_nis_getservbyname_r (const char *name, char *protocol, if (strcmp (serv->s_proto, protocol) == 0) { char **cp; - + if (strcmp (serv->s_name, name) == 0) found = 1; else for (cp = serv->s_aliases; *cp; cp++) - if (strcmp(name, *cp) == 0) + if (strcmp (name, *cp) == 0) found = 1; } } - + internal_nis_endservent (&data); if (!found && status == NSS_STATUS_SUCCESS) @@ -243,7 +244,7 @@ enum nss_status _nss_nis_getservbyport_r (int port, char *protocol, struct servent *serv, char *buffer, size_t buflen) { - intern_t data = {NULL, NULL}; + intern_t data = { NULL, NULL }; enum nss_status status; int found; |