diff options
Diffstat (limited to 'nis/nss_nis')
-rw-r--r-- | nis/nss_nis/nis-alias.c | 36 | ||||
-rw-r--r-- | nis/nss_nis/nis-ethers.c | 31 | ||||
-rw-r--r-- | nis/nss_nis/nis-grp.c | 34 | ||||
-rw-r--r-- | nis/nss_nis/nis-hosts.c | 46 | ||||
-rw-r--r-- | nis/nss_nis/nis-netgrp.c | 7 | ||||
-rw-r--r-- | nis/nss_nis/nis-network.c | 32 | ||||
-rw-r--r-- | nis/nss_nis/nis-proto.c | 31 | ||||
-rw-r--r-- | nis/nss_nis/nis-publickey.c | 11 | ||||
-rw-r--r-- | nis/nss_nis/nis-pwd.c | 34 | ||||
-rw-r--r-- | nis/nss_nis/nis-rpc.c | 24 | ||||
-rw-r--r-- | nis/nss_nis/nis-service.c | 38 | ||||
-rw-r--r-- | nis/nss_nis/nis-spwd.c | 27 |
12 files changed, 189 insertions, 162 deletions
diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c index e187716bb0..0d0294082d 100644 --- a/nis/nss_nis/nis-alias.c +++ b/nis/nss_nis/nis-alias.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. @@ -36,7 +36,7 @@ static int oldkeylen = 0; static int _nss_nis_parse_aliasent (const char *key, char *alias, struct aliasent *result, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { char *first_unused = buffer + strlen (alias) + 1; size_t room_left = @@ -53,7 +53,7 @@ _nss_nis_parse_aliasent (const char *key, char *alias, struct aliasent *result, { /* The line is too long for our buffer. */ no_more_room: - __set_errno (ERANGE); + *errnop = ERANGE; return -1; } @@ -138,7 +138,7 @@ _nss_nis_endaliasent (void) static enum nss_status internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, - size_t buflen) + size_t buflen, int *errnop) { char *domain; char *result; @@ -168,14 +168,14 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } p = strncpy (buffer, result, len); @@ -184,11 +184,12 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, ++p; free (result); - if ((parse_res = _nss_nis_parse_aliasent (outkey, p, alias, - buffer, buflen)) == -1) + parse_res = _nss_nis_parse_aliasent (outkey, p, alias, buffer, buflen, + errnop); + if (parse_res == -1) { free (outkey); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -203,13 +204,14 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, } enum nss_status -_nss_nis_getaliasent_r (struct aliasent *alias, char *buffer, size_t buflen) +_nss_nis_getaliasent_r (struct aliasent *alias, char *buffer, size_t buflen, + int *errnop) { enum nss_status status; __libc_lock_lock (lock); - status = internal_nis_getaliasent_r (alias, buffer, buflen); + status = internal_nis_getaliasent_r (alias, buffer, buflen, errnop); __libc_lock_unlock (lock); @@ -218,7 +220,7 @@ _nss_nis_getaliasent_r (struct aliasent *alias, char *buffer, size_t buflen) enum nss_status _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { enum nss_status retval; int parse_res; @@ -241,14 +243,14 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -259,10 +261,10 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, free (result); alias->alias_local = 0; - if ((parse_res = _nss_nis_parse_aliasent (name, p, alias, buffer, - buflen)) == -1) + parse_res = _nss_nis_parse_aliasent (name, p, alias, buffer, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; - + if (parse_res) return NSS_STATUS_SUCCESS; else diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c index e54262409c..365f9c9c1d 100644 --- a/nis/nss_nis/nis-ethers.c +++ b/nis/nss_nis/nis-ethers.c @@ -143,7 +143,8 @@ _nss_nis_endetherent (void) } static enum nss_status -internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen) +internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen, + int *errnop) { struct parser_data *data = (void *) buffer; int parse_res; @@ -163,23 +164,25 @@ internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen) while (isspace (*p)) ++p; - if ((parse_res = _nss_files_parse_etherent (p, eth, data, buflen)) == -1) + parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; next = next->next; } while (!parse_res); - + return NSS_STATUS_SUCCESS; } enum nss_status -_nss_nis_getetherent_r (struct ether *result, char *buffer, size_t buflen) +_nss_nis_getetherent_r (struct ether *result, char *buffer, size_t buflen, + int *errnop) { int status; __libc_lock_lock (lock); - status = internal_nis_getetherent_r (result, buffer, buflen); + status = internal_nis_getetherent_r (result, buffer, buflen, errnop); __libc_lock_unlock (lock); @@ -188,7 +191,7 @@ _nss_nis_getetherent_r (struct ether *result, char *buffer, size_t buflen) enum nss_status _nss_nis_gethostton_r (const char *name, struct ether *eth, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -210,14 +213,14 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -227,7 +230,8 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth, ++p; free (result); - if ((parse_res = _nss_files_parse_etherent (p, eth, data, buflen)) == -1) + parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; if (!parse_res) @@ -238,7 +242,7 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth, enum nss_status _nss_nis_getntohost_r (struct ether_addr *addr, struct ether *eth, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -269,14 +273,14 @@ _nss_nis_getntohost_r (struct ether_addr *addr, struct ether *eth, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -286,7 +290,8 @@ _nss_nis_getntohost_r (struct ether_addr *addr, struct ether *eth, ++p; free (result); - if ((parse_res = _nss_files_parse_etherent (p, eth, data, buflen)) == -1) + parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; if (!parse_res) diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c index 7897e21881..98cc4fd878 100644 --- a/nis/nss_nis/nis-grp.c +++ b/nis/nss_nis/nis-grp.c @@ -78,7 +78,8 @@ _nss_nis_endgrent (void) } static enum nss_status -internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen) +internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen, + int *errnop) { struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; @@ -104,14 +105,14 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen) if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -121,9 +122,11 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen) ++p; free (result); - if ((parse_res = _nss_files_parse_grent (p, grp, data, buflen)) == -1) + parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop); + if (parse_res == -1) { free (outkey); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -138,13 +141,14 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen) } enum nss_status -_nss_nis_getgrent_r (struct group *result, char *buffer, size_t buflen) +_nss_nis_getgrent_r (struct group *result, char *buffer, size_t buflen, + int *errnop) { int status; __libc_lock_lock (lock); - status = internal_nis_getgrent_r (result, buffer, buflen); + status = internal_nis_getgrent_r (result, buffer, buflen, errnop); __libc_lock_unlock (lock); @@ -153,7 +157,7 @@ _nss_nis_getgrent_r (struct group *result, char *buffer, size_t buflen) enum nss_status _nss_nis_getgrnam_r (const char *name, struct group *grp, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -175,14 +179,14 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -192,7 +196,8 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, ++p; free (result); - if ((parse_res = _nss_files_parse_grent (p, grp, data, buflen)) == -1) + parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; if (parse_res) @@ -203,7 +208,7 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, enum nss_status _nss_nis_getgrgid_r (gid_t gid, struct group *grp, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -222,14 +227,14 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -239,7 +244,8 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp, ++p; free (result); - if ((parse_res = _nss_files_parse_grent (p, grp, data, buflen)) == -1) + parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; if (parse_res) diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c index da7cef5ada..f08a624c37 100644 --- a/nis/nss_nis/nis-hosts.c +++ b/nis/nss_nis/nis-hosts.c @@ -133,7 +133,7 @@ _nss_nis_endhostent (void) static enum nss_status internal_nis_gethostent_r (struct hostent *host, char *buffer, - size_t buflen, int *h_errnop) + size_t buflen, int *errnop, int *h_errnop) { char *domain; char *result; @@ -148,7 +148,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, if (buflen < sizeof *data + 1) { - __set_errno (ERANGE); + *errnop = ERANGE; *h_errnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } @@ -172,7 +172,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, switch (retval) { case NSS_STATUS_TRYAGAIN: - __set_errno (EAGAIN); + *errnop = errno; *h_errnop = TRY_AGAIN; break; case NSS_STATUS_NOTFOUND: @@ -189,7 +189,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, { free (result); *h_errnop = NETDB_INTERNAL; - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -199,10 +199,11 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, ++p; free (result); - if ((parse_res = parse_line (p, host, data, buflen)) == -1) + if ((parse_res = parse_line (p, host, data, buflen, errnop)) == -1) { free (outkey); - *h_errnop = NETDB_INTERNAL;; + *h_errnop = NETDB_INTERNAL; + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } free (oldkey); @@ -218,13 +219,13 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, int _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen, - int *h_errnop) + int *errnop, int *h_errnop) { int status; __libc_lock_lock (lock); - status = internal_nis_gethostent_r (host, buffer, buflen, h_errnop); + status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop); __libc_lock_unlock (lock); @@ -233,7 +234,8 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen, enum nss_status _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, - char *buffer, size_t buflen, int *h_errnop) + char *buffer, size_t buflen, int *errnop, + int *h_errnop) { enum nss_status retval; char *domain, *result, *p; @@ -253,7 +255,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, if (buflen < sizeof *data + 1) { *h_errnop = NETDB_INTERNAL; - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } retval = yperr2nss (yp_match (domain, "hosts.byname", name, @@ -264,7 +266,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, if (retval == NSS_STATUS_TRYAGAIN) { *h_errnop = TRY_AGAIN; - __set_errno (EAGAIN); + *errnop = errno; } if (retval == NSS_STATUS_NOTFOUND) *h_errnop = HOST_NOT_FOUND; @@ -275,7 +277,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, { free (result); *h_errnop = NETDB_INTERNAL; - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -285,7 +287,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, ++p; free (result); - parse_res = parse_line (p, host, data, buflen); + parse_res = parse_line (p, host, data, buflen, errnop); if (parse_res < 1 || host->h_addrtype != af) { @@ -306,27 +308,27 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, } enum nss_status -_nss_nis_gethostbyname_r (const char *name, struct hostent *host, - char *buffer, size_t buflen, int *h_errnop) +_nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer, + size_t buflen, int *errnop, 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); + errnop, h_errnop); if (status == NSS_STATUS_SUCCESS) return status; } return _nss_nis_gethostbyname2_r (name, AF_INET, host, buffer, buflen, - h_errnop); + errnop, 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) + int *errnop, int *h_errnop) { enum nss_status retval; char *domain, *result, *p; @@ -340,7 +342,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type, if (buflen < sizeof *data + 1) { - __set_errno (ERANGE); + *errnop = ERANGE; *h_errnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } @@ -355,7 +357,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type, if (retval == NSS_STATUS_TRYAGAIN) { *h_errnop = TRY_AGAIN; - __set_errno (EAGAIN); + *errnop = errno; } if (retval == NSS_STATUS_NOTFOUND) *h_errnop = HOST_NOT_FOUND; @@ -365,7 +367,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type, if ((size_t) (len + 1) > linebuflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; *h_errnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } @@ -376,7 +378,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type, ++p; free (result); - parse_res = parse_line (p, host, data, buflen); + parse_res = parse_line (p, host, data, buflen, errnop); if (parse_res < 1) { if (parse_res == -1) diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c index ce8762a1e5..d170b56f50 100644 --- a/nis/nss_nis/nis-netgrp.c +++ b/nis/nss_nis/nis-netgrp.c @@ -40,7 +40,7 @@ static char *cursor = NULL;; extern enum nss_status _nss_netgroup_parseline (char **cursor, struct __netgrent *result, - char *buffer, size_t buflen); + char *buffer, size_t buflen, int *errnop); enum nss_status _nss_nis_setnetgrent (char *group) @@ -111,7 +111,8 @@ _nss_nis_endnetgrent (void) } enum nss_status -_nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen) +_nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen, + int *errnop) { enum nss_status status; @@ -120,7 +121,7 @@ _nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen) __libc_lock_lock (lock); - status = _nss_netgroup_parseline (&cursor, result, buffer, buflen); + status = _nss_netgroup_parseline (&cursor, result, buffer, buflen, errnop); __libc_lock_unlock (lock); diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c index c17ba81a62..4fcf729b34 100644 --- a/nis/nss_nis/nis-network.c +++ b/nis/nss_nis/nis-network.c @@ -79,7 +79,7 @@ _nss_nis_endnetent (void) static enum nss_status internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, - int *herrnop) + int *errnop, int *herrnop) { struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; @@ -107,7 +107,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, if (retval == NSS_STATUS_TRYAGAIN) { *herrnop = NETDB_INTERNAL; - __set_errno (EAGAIN); + *errnop = errno; } return retval; } @@ -126,10 +126,12 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, ++p; free (result); - if ((parse_res = _nss_files_parse_netent (p, net, data, buflen)) == -1) + parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop); + if (parse_res == -1) { free (outkey); *herrnop = NETDB_INTERNAL; + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -145,13 +147,13 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, enum nss_status _nss_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, - int *herrnop) + int *errnop, int *herrnop) { enum nss_status status; __libc_lock_lock (lock); - status = internal_nis_getnetent_r (net, buffer, buflen, herrnop); + status = internal_nis_getnetent_r (net, buffer, buflen, errnop, herrnop); __libc_lock_unlock (lock); @@ -159,8 +161,8 @@ _nss_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, } enum nss_status -_nss_nis_getnetbyname_r (const char *name, struct netent *net, - char *buffer, size_t buflen, int *herrnop) +_nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer, + size_t buflen, int *errnop, int *herrnop) { enum nss_status retval; struct parser_data *data = (void *) buffer; @@ -184,7 +186,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, { if (retval == NSS_STATUS_TRYAGAIN) { - __set_errno (EAGAIN); + *errnop = errno; *herrnop = NETDB_INTERNAL; } return retval; @@ -193,7 +195,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; *herrnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } @@ -204,7 +206,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, ++p; free (result); - parse_res = _nss_files_parse_netent (p, net, data, buflen); + parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop); if (parse_res < 1) { @@ -220,7 +222,8 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, enum nss_status _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net, - char *buffer, size_t buflen, int *herrnop) + char *buffer, size_t buflen, int *errnop, + int *herrnop) { struct parser_data *data = (void *) buffer; char *domain; @@ -264,7 +267,7 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net, else { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } } @@ -272,7 +275,7 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net, if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; *herrnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } @@ -283,8 +286,7 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net, ++p; free (result); - parse_res = _nss_files_parse_netent (p, net, data, buflen); - + parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop); if (parse_res < 1) { diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c index eb09bb4ec7..e0c976041d 100644 --- a/nis/nss_nis/nis-proto.c +++ b/nis/nss_nis/nis-proto.c @@ -136,7 +136,7 @@ _nss_nis_endprotoent (void) static enum nss_status internal_nis_getprotoent_r (struct protoent *proto, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; int parse_res; @@ -156,24 +156,25 @@ internal_nis_getprotoent_r (struct protoent *proto, while (isspace (*p)) ++p; - if ((parse_res = _nss_files_parse_protoent (p, proto, data, - buflen)) == -1) + parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; next = next->next; } while (!parse_res); - + return NSS_STATUS_SUCCESS; } enum nss_status -_nss_nis_getprotoent_r (struct protoent *proto, char *buffer, size_t buflen) +_nss_nis_getprotoent_r (struct protoent *proto, char *buffer, size_t buflen, + int *errnop) { enum nss_status status; __libc_lock_lock (lock); - status = internal_nis_getprotoent_r (proto, buffer, buflen); + status = internal_nis_getprotoent_r (proto, buffer, buflen, errnop); __libc_lock_unlock (lock); @@ -182,7 +183,7 @@ _nss_nis_getprotoent_r (struct protoent *proto, char *buffer, size_t buflen) enum nss_status _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -204,14 +205,14 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -221,7 +222,8 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, ++p; free (result); - if ((parse_res = _nss_files_parse_protoent (p, proto, data, buflen)) == -1) + parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; if (parse_res) @@ -232,7 +234,7 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, enum nss_status _nss_nis_getprotobynumber_r (int number, struct protoent *proto, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -251,14 +253,14 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -268,7 +270,8 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto, ++p; free (result); - if ((parse_res = _nss_files_parse_protoent (p, proto, data, buflen)) == -1) + parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; if (parse_res) diff --git a/nis/nss_nis/nis-publickey.c b/nis/nss_nis/nis-publickey.c index 4c921f4853..1c485d9d23 100644 --- a/nis/nss_nis/nis-publickey.c +++ b/nis/nss_nis/nis-publickey.c @@ -32,7 +32,7 @@ extern int xdecrypt (char *, char *); /* If we haven't found the entry, we give a SUCCESS and an empty key back. */ enum nss_status -_nss_nis_getpublickey (const char *netname, char *pkey) +_nss_nis_getpublickey (const char *netname, char *pkey, int *errnop) { enum nss_status retval; char *domain, *result; @@ -57,7 +57,7 @@ _nss_nis_getpublickey (const char *netname, char *pkey) if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } @@ -72,7 +72,8 @@ _nss_nis_getpublickey (const char *netname, char *pkey) } enum nss_status -_nss_nis_getsecretkey (const char *netname, char *skey, char *passwd) +_nss_nis_getsecretkey (const char *netname, char *skey, char *passwd, + int *errnop) { enum nss_status retval; char buf[1024]; @@ -98,7 +99,7 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd) if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } @@ -178,7 +179,7 @@ parse_netid_str (const char *s, uid_t *uidp, gid_t *gidp, int *gidlenp, enum nss_status _nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp, - gid_t *gidp, int *gidlenp, gid_t *gidlist) + gid_t *gidp, int *gidlenp, gid_t *gidlist, int *errnop) { char *domain; int yperr; diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c index f693db17ea..8924886e1e 100644 --- a/nis/nss_nis/nis-pwd.c +++ b/nis/nss_nis/nis-pwd.c @@ -78,7 +78,8 @@ _nss_nis_endpwent (void) } static enum nss_status -internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen) +internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen, + int *errnop) { struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; @@ -104,14 +105,14 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen) if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -121,9 +122,11 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen) ++p; free (result); - if ((parse_res = _nss_files_parse_pwent (p, pwd, data, buflen)) == -1) + parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop); + if (parse_res == -1) { free (outkey); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -138,13 +141,14 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen) } enum nss_status -_nss_nis_getpwent_r (struct passwd *result, char *buffer, size_t buflen) +_nss_nis_getpwent_r (struct passwd *result, char *buffer, size_t buflen, + int *errnop) { int status; __libc_lock_lock (lock); - status = internal_nis_getpwent_r (result, buffer, buflen); + status = internal_nis_getpwent_r (result, buffer, buflen, errnop); __libc_lock_unlock (lock); @@ -153,7 +157,7 @@ _nss_nis_getpwent_r (struct passwd *result, char *buffer, size_t buflen) enum nss_status _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -175,14 +179,14 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -192,8 +196,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, ++p; free (result); - parse_res = _nss_files_parse_pwent (p, pwd, data, buflen); - + parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop); if (parse_res < 1) { if (parse_res == -1) @@ -207,7 +210,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, enum nss_status _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -226,14 +229,14 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -243,8 +246,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, ++p; free (result); - parse_res = _nss_files_parse_pwent (p, pwd, data, buflen); - + parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop); if (parse_res < 1) { if (parse_res == -1) diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c index cd1f0db9b5..274ef04b7a 100644 --- a/nis/nss_nis/nis-rpc.c +++ b/nis/nss_nis/nis-rpc.c @@ -154,7 +154,7 @@ _nss_nis_endrpcent (void) static enum nss_status internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, - intern_t *data) + int *errnop, intern_t *data) { struct parser_data *pdata = (void *) buffer; int parse_res; @@ -172,7 +172,8 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, while (isspace (*p)) ++p; - if ((parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen)) == -1) + parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; data->next = data->next->next; } @@ -182,13 +183,14 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, } enum nss_status -_nss_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen) +_nss_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, + int *errnop) { enum nss_status status; __libc_lock_lock (lock); - status = internal_nis_getrpcent_r (rpc, buffer, buflen, &intern); + status = internal_nis_getrpcent_r (rpc, buffer, buflen, errnop, &intern); __libc_lock_unlock (lock); @@ -197,7 +199,7 @@ _nss_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen) enum nss_status _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { intern_t data = {NULL, NULL}; enum nss_status status; @@ -215,8 +217,8 @@ _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc, found = 0; while (!found && - ((status = internal_nis_getrpcent_r (rpc, buffer, buflen, &data)) - == NSS_STATUS_SUCCESS)) + ((status = internal_nis_getrpcent_r (rpc, buffer, buflen, errnop, + &data)) == NSS_STATUS_SUCCESS)) { if (strcmp (rpc->r_name, name) == 0) found = 1; @@ -247,7 +249,7 @@ _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc, enum nss_status _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -266,14 +268,14 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -283,7 +285,7 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, ++p; free (result); - parse_res = _nss_files_parse_rpcent (p, rpc, data, buflen); + parse_res = _nss_files_parse_rpcent (p, rpc, data, buflen, errnop); if (parse_res < 1) { diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c index 5ec89c8677..c55b3e0191 100644 --- a/nis/nss_nis/nis-service.c +++ b/nis/nss_nis/nis-service.c @@ -31,7 +31,7 @@ /* The parser is defined in a different module. */ extern int _nss_files_parse_servent (char *line, struct servent *result, - char *data, size_t datalen); + char *data, size_t datalen, int *errnop); @@ -155,7 +155,7 @@ _nss_nis_endservent (void) static enum nss_status internal_nis_getservent_r (struct servent *serv, char *buffer, - size_t buflen, intern_t *data) + size_t buflen, int *errnop, intern_t *data) { int parse_res; char *p; @@ -172,8 +172,8 @@ internal_nis_getservent_r (struct servent *serv, char *buffer, while (isspace (*p)) ++p; - if ((parse_res = _nss_files_parse_servent (p, serv, buffer, - buflen)) == -1) + parse_res = _nss_files_parse_servent (p, serv, buffer, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; data->next = data->next->next; } @@ -183,13 +183,14 @@ internal_nis_getservent_r (struct servent *serv, char *buffer, } enum nss_status -_nss_nis_getservent_r (struct servent *serv, char *buffer, size_t buflen) +_nss_nis_getservent_r (struct servent *serv, char *buffer, size_t buflen, + int *errnop) { enum nss_status status; __libc_lock_lock (lock); - status = internal_nis_getservent_r (serv, buffer, buflen, &intern); + status = internal_nis_getservent_r (serv, buffer, buflen, errnop, &intern); __libc_lock_unlock (lock); @@ -198,7 +199,8 @@ _nss_nis_getservent_r (struct servent *serv, char *buffer, size_t buflen) enum nss_status _nss_nis_getservbyname_r (const char *name, char *protocol, - struct servent *serv, char *buffer, size_t buflen) + struct servent *serv, char *buffer, size_t buflen, + int *errnop) { intern_t data = { NULL, NULL }; enum nss_status status; @@ -216,8 +218,8 @@ _nss_nis_getservbyname_r (const char *name, char *protocol, found = 0; while (!found && - ((status = internal_nis_getservent_r (serv, buffer, buflen, &data)) - == NSS_STATUS_SUCCESS)) + ((status = internal_nis_getservent_r (serv, buffer, buflen, errnop, + &data)) == NSS_STATUS_SUCCESS)) { if (protocol == NULL || strcmp (serv->s_proto, protocol) == 0) { @@ -242,7 +244,7 @@ _nss_nis_getservbyname_r (const char *name, char *protocol, enum nss_status _nss_nis_getservbyport_r (int port, char *protocol, struct servent *serv, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { intern_t data = { NULL, NULL }; enum nss_status status; @@ -260,17 +262,11 @@ _nss_nis_getservbyport_r (int port, char *protocol, struct servent *serv, found = 0; while (!found && - ((status = internal_nis_getservent_r (serv, buffer, buflen, &data)) - == NSS_STATUS_SUCCESS)) - { - if (htons (serv->s_port) == port) - { - if (strcmp (serv->s_proto, protocol) == 0) - { - found = 1; - } - } - } + ((status = internal_nis_getservent_r (serv, buffer, buflen, errnop, + &data)) == NSS_STATUS_SUCCESS)) + if (htons (serv->s_port) == port + && strcmp (serv->s_proto, protocol) == 0) + found = 1; internal_nis_endservent (&data); diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c index 0263f4e313..5be010d433 100644 --- a/nis/nss_nis/nis-spwd.c +++ b/nis/nss_nis/nis-spwd.c @@ -78,7 +78,8 @@ _nss_nis_endspent (void) } static enum nss_status -internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen) +internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen, + int *errnop) { struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; @@ -104,14 +105,14 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen) if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -121,12 +122,14 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen) ++p; free (result); - if ((parse_res = _nss_files_parse_spent (p, sp, data, buflen)) == -1) + parse_res = _nss_files_parse_spent (p, sp, data, buflen, errnop); + if (parse_res == -1) { free (outkey); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } - + free (oldkey); oldkey = outkey; oldkeylen = keylen; @@ -138,13 +141,14 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen) } enum nss_status -_nss_nis_getspent_r (struct spwd *result, char *buffer, size_t buflen) +_nss_nis_getspent_r (struct spwd *result, char *buffer, size_t buflen, + int *errnop) { int status; __libc_lock_lock (lock); - status = internal_nis_getspent_r (result, buffer, buflen); + status = internal_nis_getspent_r (result, buffer, buflen, errnop); __libc_lock_unlock (lock); @@ -153,7 +157,7 @@ _nss_nis_getspent_r (struct spwd *result, char *buffer, size_t buflen) enum nss_status _nss_nis_getspnam_r (const char *name, struct spwd *sp, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { struct parser_data *data = (void *) buffer; enum nss_status retval; @@ -175,14 +179,14 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp, if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_TRYAGAIN) - __set_errno (EAGAIN); + *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -192,7 +196,8 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp, ++p; free (result); - if ((parse_res = _nss_files_parse_spent (p, sp, data, buflen)) == -1) + parse_res = _nss_files_parse_spent (p, sp, data, buflen, errnop); + if (parse_res == -1) return NSS_STATUS_TRYAGAIN; if (parse_res) |