When using `compat' mode, be sure to re-dispatch setpwent, endpwent,
setgrent, and endgrent also. (The previous NSS implementation used to simply twiddle the internal data of the various modules directly.) A symptom (group list set incorrectly in sshd) was Reported by: Glenn Johnson <gjohnson@srrc.ars.usda.gov> Sponsored by: DARPA, Network Associates Laboratories
This commit is contained in:
parent
321397d2ac
commit
3871fd24ca
@ -819,9 +819,31 @@ compat_endstate(void *p)
|
||||
static int
|
||||
compat_setgrent(void *retval, void *mdata, va_list ap)
|
||||
{
|
||||
static const ns_src compatsrc[] = {
|
||||
#ifdef YP
|
||||
{ NSSRC_NIS, NS_SUCCESS },
|
||||
#endif
|
||||
{ NULL, 0 }
|
||||
};
|
||||
ns_dtab dtab[] = {
|
||||
#ifdef HESIOD
|
||||
{ NSSRC_DNS, dns_setgrent, NULL },
|
||||
#endif
|
||||
#ifdef YP
|
||||
{ NSSRC_NIS, nis_setgrent, NULL },
|
||||
#endif
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
struct compat_state *st;
|
||||
int rv, stayopen;
|
||||
|
||||
#define set_setent(x, y) do { \
|
||||
int i; \
|
||||
\
|
||||
for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \
|
||||
x[i].mdata = (void *)y; \
|
||||
} while (0)
|
||||
|
||||
rv = compat_getstate(&st);
|
||||
if (rv != 0)
|
||||
return (NS_UNAVAIL);
|
||||
@ -832,12 +854,18 @@ compat_setgrent(void *retval, void *mdata, va_list ap)
|
||||
rewind(st->fp);
|
||||
else if (stayopen)
|
||||
st->fp = fopen(_PATH_GROUP, "r");
|
||||
set_setent(dtab, mdata);
|
||||
(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
|
||||
compatsrc, 0);
|
||||
break;
|
||||
case ENDGRENT:
|
||||
if (st->fp != NULL) {
|
||||
fclose(st->fp);
|
||||
st->fp = NULL;
|
||||
}
|
||||
set_setent(dtab, mdata);
|
||||
(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "endgrent",
|
||||
compatsrc, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -846,6 +874,7 @@ compat_setgrent(void *retval, void *mdata, va_list ap)
|
||||
free(st->name);
|
||||
st->name = NULL;
|
||||
return (NS_UNAVAIL);
|
||||
#undef set_setent
|
||||
}
|
||||
|
||||
|
||||
|
@ -1392,9 +1392,31 @@ compat_endstate(void *p)
|
||||
static int
|
||||
compat_setpwent(void *retval, void *mdata, va_list ap)
|
||||
{
|
||||
static const ns_src compatsrc[] = {
|
||||
#ifdef YP
|
||||
{ NSSRC_NIS, NS_SUCCESS },
|
||||
#endif
|
||||
{ NULL, 0 }
|
||||
};
|
||||
ns_dtab dtab[] = {
|
||||
#ifdef YP
|
||||
{ NSSRC_NIS, nis_setpwent, NULL },
|
||||
#endif
|
||||
#ifdef HESIOD
|
||||
{ NSSRC_DNS, dns_setpwent, NULL },
|
||||
#endif
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
struct compat_state *st;
|
||||
int rv, stayopen;
|
||||
|
||||
#define set_setent(x, y) do { \
|
||||
int i; \
|
||||
\
|
||||
for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \
|
||||
x[i].mdata = (void *)y; \
|
||||
} while (0)
|
||||
|
||||
rv = compat_getstate(&st);
|
||||
if (rv != 0)
|
||||
return (NS_UNAVAIL);
|
||||
@ -1405,17 +1427,24 @@ compat_setpwent(void *retval, void *mdata, va_list ap)
|
||||
if (stayopen)
|
||||
st->db = pwdbopen(&st->version);
|
||||
st->stayopen = stayopen;
|
||||
set_setent(dtab, mdata);
|
||||
(void)_nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "setpwent",
|
||||
compatsrc, 0);
|
||||
break;
|
||||
case ENDPWENT:
|
||||
if (st->db != NULL) {
|
||||
(void)st->db->close(st->db);
|
||||
st->db = NULL;
|
||||
}
|
||||
set_setent(dtab, mdata);
|
||||
(void)_nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "endpwent",
|
||||
compatsrc, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (NS_UNAVAIL);
|
||||
#undef set_setent
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user