From: Ulrich Drepper Date: Sun, 19 Dec 1999 00:15:18 +0000 (+0000) Subject: Make sure errno is always set correct. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acf56eaa5ef476b4d52948dea4acc7842504a50f;p=thirdparty%2Fglibc.git Make sure errno is always set correct. --- diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c index ac56f6fbec6..2de46088df9 100644 --- a/nis/nss_compat/compat-grp.c +++ b/nis/nss_compat/compat-grp.c @@ -1,6 +1,6 @@ /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1996. + Contributed by Thorsten Kukuk , 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -730,7 +730,10 @@ _nss_compat_getgrnam_r (const char *name, struct group *grp, enum nss_status status; if (name[0] == '-' || name[0] == '+') - return NSS_STATUS_NOTFOUND; + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } __libc_lock_lock (lock); @@ -915,7 +918,10 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent, status = getgrgid_plusgroup (gid, result, buffer, buflen, errnop); if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ - return NSS_STATUS_NOTFOUND; + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } else return status; } diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c index 47b395ede6c..3f7793d8b70 100644 --- a/nis/nss_compat/compat-initgroups.c +++ b/nis/nss_compat/compat-initgroups.c @@ -126,7 +126,7 @@ _nss_first_init (void) grptable = malloc (sizeof (key) + len_local_dir); if (grptable == NULL) - return NSS_STATUS_TRYAGAIN; + return NSS_STATUS_TRYAGAIN; grptablelen = ((char *) mempcpy (mempcpy (grptable, key, sizeof (key) - 1), @@ -263,6 +263,7 @@ getgrent_next_nis (struct group *result, ent_t *ent, char *buffer, if (yp_get_default_domain (&domain) != YPERR_SUCCESS) { ent->nis = 0; + *errnop = ENOENT; return NSS_STATUS_NOTFOUND; } @@ -445,7 +446,10 @@ getgrnam_plusgroup (const char *name, struct group *result, char *buffer, ++p; parse_res = _nss_files_parse_grent (p, result, data, buflen, errnop); if (parse_res == -1) - return NSS_STATUS_TRYAGAIN; + { + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; + } } if (parse_res) diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c index 12903468814..f254fadf5c8 100644 --- a/nis/nss_compat/compat-spwd.c +++ b/nis/nss_compat/compat-spwd.c @@ -383,6 +383,7 @@ getspent_next_nis_netgr (const char *name, struct spwd *result, ent_t *ent, if (parse_res == -1) { ent->netgrdata.cursor = saved_cursor; + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -1112,7 +1113,10 @@ internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent, && result->sp_namp[1] != '@') { if (strcmp (&result->sp_namp[1], name) == 0) - return NSS_STATUS_NOTFOUND; + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } else continue; } @@ -1128,8 +1132,11 @@ internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent, status = getspnam_plususer (name, result, buffer, buflen, errnop); if (status == NSS_STATUS_RETURN) - /* We couldn't parse the entry */ - return NSS_STATUS_NOTFOUND; + { + /* We couldn't parse the entry */ + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } else return status; } @@ -1142,7 +1149,10 @@ internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent, status = getspnam_plususer (name, result, buffer, buflen, errnop); if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ - return NSS_STATUS_NOTFOUND; + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } else return status; } @@ -1159,7 +1169,10 @@ _nss_compat_getspnam_r (const char *name, struct spwd *pwd, enum nss_status status; if (name[0] == '-' || name[0] == '+') - return NSS_STATUS_NOTFOUND; + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } if (ni == NULL) { diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c index 64d0bf8de53..e6e23865478 100644 --- a/nis/nss_nis/nis-alias.c +++ b/nis/nss_nis/nis-alias.c @@ -278,7 +278,10 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, if (parse_res == -1) return NSS_STATUS_TRYAGAIN; else - return NSS_STATUS_NOTFOUND; + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } } return NSS_STATUS_SUCCESS; diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c index c95f766469e..c1ea32adc5a 100644 --- a/nis/nss_nis/nis-ethers.c +++ b/nis/nss_nis/nis-ethers.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1996. + Contributed by Thorsten Kukuk , 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -241,7 +241,10 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth, if (parse_res == -1) return NSS_STATUS_TRYAGAIN; else - return NSS_STATUS_NOTFOUND; + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } } return NSS_STATUS_SUCCESS; } diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c index 6dca66e4df0..62e6b475b7f 100644 --- a/nis/nss_nis/nis-grp.c +++ b/nis/nss_nis/nis-grp.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1996. + Contributed by Thorsten Kukuk , 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -207,7 +207,7 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, return NSS_STATUS_TRYAGAIN; else { - *errnop = EAGAIN; + *errnop = ENOENT; return NSS_STATUS_NOTFOUND; } } diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c index d791b98b3ed..8521dfbaa8c 100644 --- a/nis/nss_nis/nis-hosts.c +++ b/nis/nss_nis/nis-hosts.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1996. + Contributed by Thorsten Kukuk , 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -314,6 +314,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, else { *h_errnop = HOST_NOT_FOUND; + *errnop = ENOENT; return NSS_STATUS_NOTFOUND; } } @@ -375,7 +376,10 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type, *errnop = errno; } if (retval == NSS_STATUS_NOTFOUND) - *h_errnop = HOST_NOT_FOUND; + { + *h_errnop = HOST_NOT_FOUND; + *errnop = ENOENT; + } return retval; } @@ -404,6 +408,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type, else { *h_errnop = HOST_NOT_FOUND; + *errnop = ENOENT; return NSS_STATUS_NOTFOUND; } } diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c index d170b56f505..0d3ed44d3f6 100644 --- a/nis/nss_nis/nis-netgrp.c +++ b/nis/nss_nis/nis-netgrp.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1996. + Contributed by Thorsten Kukuk , 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -117,7 +117,10 @@ _nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen, enum nss_status status; if (cursor == NULL) - return NSS_STATUS_NOTFOUND; + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } __libc_lock_lock (lock); diff --git a/nis/nss_nis/nis-publickey.c b/nis/nss_nis/nis-publickey.c index 73afd442a9a..821accfbae1 100644 --- a/nis/nss_nis/nis-publickey.c +++ b/nis/nss_nis/nis-publickey.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1996. + Contributed by Thorsten Kukuk , 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -50,8 +50,11 @@ _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop) domain = strchr (netname, '@'); if (!domain) - return NSS_STATUS_UNAVAIL; - domain++; + { + *errnop = EINVAL; + return NSS_STATUS_UNAVAIL; + } + ++domain; retval = yperr2nss (yp_match (domain, "publickey.byname", netname, strlen (netname), &result, &len)); @@ -95,8 +98,11 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd, domain = strchr (netname, '@'); if (!domain) - return NSS_STATUS_UNAVAIL; - domain++; + { + *errnop = EINVAL; + return NSS_STATUS_UNAVAIL; + } + ++domain; retval = yperr2nss (yp_match (domain, "publickey.byname", netname, strlen (netname), &result, &len)); @@ -196,10 +202,13 @@ _nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp, domain = strchr (netname, '@'); if (!domain) - return NSS_STATUS_UNAVAIL; + { + *errnop = EINVAL; + return NSS_STATUS_UNAVAIL; + } /* Point past the '@' character */ - domain++; + ++domain; lookup = NULL; yperr = yp_match (domain, "netid.byname", netname, strlen (netname), &lookup, &len); @@ -209,11 +218,13 @@ _nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp, break; /* the successful case */ case YPERR_DOMAIN: case YPERR_KEY: + *errnop = ENOENT; return NSS_STATUS_NOTFOUND; case YPERR_MAP: default: return NSS_STATUS_UNAVAIL; } + if (lookup) { enum nss_status err; @@ -224,7 +235,9 @@ _nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp, return err; } else - return NSS_STATUS_NOTFOUND; - + { + *errnop = ENOENT; + return NSS_STATUS_NOTFOUND; + } return NSS_STATUS_SUCCESS; }