change dns_getpw() to skip dodgy entries when doing getpwent(), rather

than returning NS_UNAVAIL. this means that a -ve uid entry in hesiod
doesn't stop getpwent() in its tracks. it also brings it in line with
how nis_getpw() works as well in this situation.
problem tracked down (with much pain & suffereing) by simonb.

XXX: we currently have no support for -ve uids, and this is painful in
XXX: hetrogenous environment... (this -ve check is enforced in __pwscan())
This commit is contained in:
lukem 1999-04-26 04:01:32 +00:00
parent 35a22b65fc
commit df8debb219
1 changed files with 7 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: getpwent.c,v 1.42 1999/04/25 07:54:01 lukem Exp $ */
/* $NetBSD: getpwent.c,v 1.43 1999/04/26 04:01:32 lukem Exp $ */
/*
* Copyright (c) 1988, 1993
@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95";
#else
__RCSID("$NetBSD: getpwent.c,v 1.42 1999/04/25 07:54:01 lukem Exp $");
__RCSID("$NetBSD: getpwent.c,v 1.43 1999/04/26 04:01:32 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -463,6 +463,7 @@ _dns_getpw(rv, cb_data, ap)
int r;
search = va_arg(ap, int);
nextdnsbynum:
switch (search) {
case _PW_KEYBYNUM:
if (_pw_hesnum == -1)
@ -504,9 +505,11 @@ _dns_getpw(rv, cb_data, ap)
strncpy(line, hp[0], sizeof(line)); /* only check first elem */
line[sizeof(line) - 1] = '\0';
hesiod_free_list(context, hp);
if (__pwparse(&_pw_passwd, line))
if (__pwparse(&_pw_passwd, line)) {
if (search == _PW_KEYBYNUM)
goto nextdnsbynum; /* skip dogdy entries */
r = NS_UNAVAIL;
else
} else
r = NS_SUCCESS;
cleanup_dns_getpw:
hesiod_end(context);