diff options
author | nectar <nectar@FreeBSD.org> | 2003-04-25 18:25:19 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2003-04-25 18:25:19 +0000 |
commit | 223f8458a8fa7a46a4cef431363b70e3cdfe8bb6 (patch) | |
tree | 16a502b8967eefd6af591d13cc4b3e5e25158acc /lib/libc | |
parent | 94effdc88030026e058b2e0aaaa788a05c9e63f7 (diff) | |
download | FreeBSD-src-223f8458a8fa7a46a4cef431363b70e3cdfe8bb6.zip FreeBSD-src-223f8458a8fa7a46a4cef431363b70e3cdfe8bb6.tar.gz |
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
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getgrent.c | 29 | ||||
-rw-r--r-- | lib/libc/gen/getpwent.c | 29 |
2 files changed, 58 insertions, 0 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index 42cffa0..d834d09 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -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 } diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 32abdc9..427a736 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -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 } |