* nis/nss_compat/compat-grp.c (internal_getgrgid_r): Check if NSS

module provides getgrgid_r.
	(getgrnam_plusgroup): Preserve original return value.
	* nis/nss_compat/compat-pwd.c (getpwnam_plususer): Preserve
	original return value.
	* nis/nss_compat/compat-spwd.c (getspnam_plususer): Likewise.
This commit is contained in:
Ulrich Drepper 2005-07-06 21:06:29 +00:00
parent ec73fd87da
commit 016c70ea61
4 changed files with 35 additions and 27 deletions

View File

@ -1,3 +1,12 @@
2005-07-05 Thorsten Kukuk <kukuk@suse.de>
* nis/nss_compat/compat-grp.c (internal_getgrgid_r): Check if NSS
module provides getgrgid_r.
(getgrnam_plusgroup): Preserve original return value.
* nis/nss_compat/compat-pwd.c (getpwnam_plususer): Preserve
original return value.
* nis/nss_compat/compat-spwd.c (getspnam_plususer): Likewise.
2005-07-05 Ulrich Drepper <drepper@redhat.com> 2005-07-05 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (build_wcs_buffer): Use MB_LEN_MAX not * posix/regex_internal.c (build_wcs_buffer): Use MB_LEN_MAX not

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996-1999,2001,2002,2003,2004 Free Software Foundation, Inc. /* Copyright (C) 1996-1999,2001-2004,2005 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@ -229,9 +229,10 @@ getgrnam_plusgroup (const char *name, struct group *result, ent_t *ent,
if (!nss_getgrnam_r) if (!nss_getgrnam_r)
return NSS_STATUS_UNAVAIL; return NSS_STATUS_UNAVAIL;
if (nss_getgrnam_r (name, result, buffer, buflen, errnop) != enum nss_status status = nss_getgrnam_r (name, result, buffer, buflen,
NSS_STATUS_SUCCESS) errnop);
return NSS_STATUS_NOTFOUND; if (status != NSS_STATUS_SUCCESS)
return status;
if (in_blacklist (result->gr_name, strlen (result->gr_name), ent)) if (in_blacklist (result->gr_name, strlen (result->gr_name), ent))
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;
@ -551,7 +552,7 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent,
!(parse_res = _nss_files_parse_grent (p, result, data, buflen, !(parse_res = _nss_files_parse_grent (p, result, data, buflen,
errnop))); errnop)));
if (parse_res == -1) if (__builtin_expect (parse_res == -1, 0))
/* The parser ran out of space. */ /* The parser ran out of space. */
goto erange_reset; goto erange_reset;
@ -589,9 +590,11 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent,
/* +:... */ /* +:... */
if (result->gr_name[0] == '+' && result->gr_name[1] == '\0') if (result->gr_name[0] == '+' && result->gr_name[1] == '\0')
{ {
enum nss_status status; if (!nss_getgrgid_r)
return NSS_STATUS_UNAVAIL;
status = nss_getgrgid_r (gid, result, buffer, buflen, errnop); enum nss_status status = nss_getgrgid_r (gid, result, buffer, buflen,
errnop);
if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;
else else

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996-1999,2001,2002,2003,2004 Free Software Foundation, Inc. /* Copyright (C) 1996-1999,2001-2004,2005 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@ -453,29 +453,27 @@ static enum nss_status
getpwnam_plususer (const char *name, struct passwd *result, ent_t *ent, getpwnam_plususer (const char *name, struct passwd *result, ent_t *ent,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
struct passwd pwd;
char *p;
size_t plen;
if (!nss_getpwnam_r) if (!nss_getpwnam_r)
return NSS_STATUS_UNAVAIL; return NSS_STATUS_UNAVAIL;
struct passwd pwd;
memset (&pwd, '\0', sizeof (struct passwd)); memset (&pwd, '\0', sizeof (struct passwd));
copy_pwd_changes (&pwd, result, NULL, 0); copy_pwd_changes (&pwd, result, NULL, 0);
plen = pwd_need_buflen (&pwd); size_t plen = pwd_need_buflen (&pwd);
if (plen > buflen) if (plen > buflen)
{ {
*errnop = ERANGE; *errnop = ERANGE;
return NSS_STATUS_TRYAGAIN; return NSS_STATUS_TRYAGAIN;
} }
p = buffer + (buflen - plen); char *p = buffer + (buflen - plen);
buflen -= plen; buflen -= plen;
if (nss_getpwnam_r (name, result, buffer, buflen, errnop) != enum nss_status status = nss_getpwnam_r (name, result, buffer, buflen,
NSS_STATUS_SUCCESS) errnop);
return NSS_STATUS_NOTFOUND; if (status != NSS_STATUS_SUCCESS)
return status;
if (in_blacklist (result->pw_name, strlen (result->pw_name), ent)) if (in_blacklist (result->pw_name, strlen (result->pw_name), ent))
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996-1999,2001,2002,2003,2004 Free Software Foundation, Inc. /* Copyright (C) 1996-1999,2001-2004,2005 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@ -401,13 +401,10 @@ static enum nss_status
getspnam_plususer (const char *name, struct spwd *result, ent_t *ent, getspnam_plususer (const char *name, struct spwd *result, ent_t *ent,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
struct spwd pwd;
char *p;
size_t plen;
if (!nss_getspnam_r) if (!nss_getspnam_r)
return NSS_STATUS_UNAVAIL; return NSS_STATUS_UNAVAIL;
struct spwd pwd;
memset (&pwd, '\0', sizeof (struct spwd)); memset (&pwd, '\0', sizeof (struct spwd));
pwd.sp_warn = -1; pwd.sp_warn = -1;
pwd.sp_inact = -1; pwd.sp_inact = -1;
@ -416,18 +413,19 @@ getspnam_plususer (const char *name, struct spwd *result, ent_t *ent,
copy_spwd_changes (&pwd, result, NULL, 0); copy_spwd_changes (&pwd, result, NULL, 0);
plen = spwd_need_buflen (&pwd); size_t plen = spwd_need_buflen (&pwd);
if (plen > buflen) if (plen > buflen)
{ {
*errnop = ERANGE; *errnop = ERANGE;
return NSS_STATUS_TRYAGAIN; return NSS_STATUS_TRYAGAIN;
} }
p = buffer + (buflen - plen); char *p = buffer + (buflen - plen);
buflen -= plen; buflen -= plen;
if (nss_getspnam_r (name, result, buffer, buflen, errnop) != enum nss_status status = nss_getspnam_r (name, result, buffer, buflen,
NSS_STATUS_SUCCESS) errnop);
return NSS_STATUS_NOTFOUND; if (status != NSS_STATUS_SUCCESS)
return status;
if (in_blacklist (result->sp_namp, strlen (result->sp_namp), ent)) if (in_blacklist (result->sp_namp, strlen (result->sp_namp), ent))
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;