diff options
Diffstat (limited to 'lib')
-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 } |