1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

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:
Jacques Vidrine 2003-04-25 18:25:19 +00:00
parent c40586c87d
commit c14d379de1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114021
2 changed files with 58 additions and 0 deletions

View File

@ -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
}

View File

@ -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
}