Very important sanity checks: today I clobbered all four NIS servers on
my network because setnetgrent() was trying to do a lookup on group "". It seems that an attempt to do a yp_match() (and possible yp_next()) on a null or empty key causes Sun's ypserv in SunOS 4.1.3 to exit suddenly (and without warning). Our ypserv behaves badly in this situation too, thoush it doesn't appear to crash. In any event, getpwent, getnetgrent and yp_match() and yp_next() are now extra careful not to accidentally pass on null or empty arguments. Also made a small change to getpwent.c to allow +::::::::: wildcarding, which I had disabled previously.
This commit is contained in:
parent
c534dadbfe
commit
353fefe325
@ -334,7 +334,8 @@ _createcaches()
|
||||
key.size = (sizeof(i)) + 1;
|
||||
if (__hashpw(&key)) {
|
||||
p = (struct _pw_cache *)malloc(sizeof (struct _pw_cache));
|
||||
setnetgrent(_pw_passwd.pw_name+2);
|
||||
if (_pw_passwd.pw_name[1])
|
||||
setnetgrent(_pw_passwd.pw_name+2);
|
||||
namehead = NULL;
|
||||
while(getnetgrent(&host, &user, &domain)) {
|
||||
n = (struct _namelist *)malloc(sizeof (struct _namelist));
|
||||
@ -382,7 +383,8 @@ _createcaches()
|
||||
key.size = (sizeof(i)) + 1;
|
||||
if (__hashpw(&key)) {
|
||||
m = (struct _pw_cache *)malloc(sizeof (struct _pw_cache));
|
||||
setnetgrent(_pw_passwd.pw_name+2);
|
||||
if (_pw_passwd.pw_name[1])
|
||||
setnetgrent(_pw_passwd.pw_name+2);
|
||||
namehead = NULL;
|
||||
while(getnetgrent(&host, &user, &domain)) {
|
||||
n = (struct _namelist *)malloc(sizeof (struct _namelist));
|
||||
@ -564,7 +566,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map)
|
||||
while (m) {
|
||||
n = m->namelist;
|
||||
while (n) {
|
||||
if (!strcmp(n->name, s)) {
|
||||
if (!strcmp(n->name, s) || *n->name == '\0') {
|
||||
free(result);
|
||||
return (0);
|
||||
}
|
||||
@ -578,7 +580,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map)
|
||||
while (p) {
|
||||
n = p->namelist;
|
||||
while (n) {
|
||||
if (!strcmp(n->name, s))
|
||||
if (!strcmp(n->name, s) || *n->name == '\0')
|
||||
bcopy((char *)&p->pw_entry,
|
||||
(char *)&_pw_passwd, sizeof(p->pw_entry));
|
||||
n = n->next;
|
||||
@ -653,7 +655,7 @@ _nextyppass(struct passwd *pw)
|
||||
while (m) {
|
||||
n = m->namelist;
|
||||
while (n) {
|
||||
if (!strcmp(n->name, s)) {
|
||||
if (!strcmp(n->name, s) || *n->name == '\0') {
|
||||
free(result);
|
||||
goto tryagain;
|
||||
}
|
||||
@ -667,7 +669,7 @@ _nextyppass(struct passwd *pw)
|
||||
while (p) {
|
||||
n = p->namelist;
|
||||
while (n) {
|
||||
if (!strcmp(n->name, s))
|
||||
if (!strcmp(n->name, s) || *n->name == '\0')
|
||||
bcopy((char *)&p->pw_entry,
|
||||
(char*)&_pw_passwd, sizeof(p->pw_entry));
|
||||
n = n->next;
|
||||
|
Loading…
Reference in New Issue
Block a user