From 49c4a40e2f87b3e37f3248464c43118c6c8aaadb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Nov 2007 09:26:42 +0100 Subject: r25868: nss_wrapper: add solaris versions of getpwent_r and getgrent_r metze (This used to be commit 386b28f988e80989f3c0e8acdfb1b66469e0a7a5) --- source4/lib/nss_wrapper/nss_wrapper.c | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'source4/lib/nss_wrapper/nss_wrapper.c') diff --git a/source4/lib/nss_wrapper/nss_wrapper.c b/source4/lib/nss_wrapper/nss_wrapper.c index 1b75aa59e6..72ddd8d5c3 100644 --- a/source4/lib/nss_wrapper/nss_wrapper.c +++ b/source4/lib/nss_wrapper/nss_wrapper.c @@ -892,6 +892,36 @@ _PUBLIC_ struct passwd *nwrap_getpwent(void) return pw; } +#ifdef SOLARIS_GETPWENT_R +_PUBLIC_ struct passwd *nwrap_getpwent_r(struct passwd *pwdst, + char *buf, + int buflen) +{ + struct passwd *pw; + struct passwd *pwdstp = NULL; + int ret; + + if (!nwrap_enabled()) { + return real_getpwent_r(pwdst, buf, buflen); + } + + pw = nwrap_getpwent(); + if (!pw) { + if (errno == 0) { + errno = ENOENT; + } + return NULL; + } + + ret = nwrap_pw_copy_r(pw, pwdst, buf, buflen, &pwdstp); + if (ret != 0) { + errno = ret; + return NULL; + } + + return pwdstp; +} +#else _PUBLIC_ int nwrap_getpwent_r(struct passwd *pwdst, char *buf, size_t buflen, struct passwd **pwdstp) { @@ -911,6 +941,7 @@ _PUBLIC_ int nwrap_getpwent_r(struct passwd *pwdst, char *buf, return nwrap_pw_copy_r(pw, pwdst, buf, buflen, pwdstp); } +#endif _PUBLIC_ void nwrap_endpwent(void) { @@ -1064,6 +1095,36 @@ _PUBLIC_ struct group *nwrap_getgrent(void) return gr; } +#ifdef SOLARIS_GETGRENT_R +_PUBLIC_ struct group *nwrap_getgrent_r(struct group *grdst, + char *buf, + int buflen) +{ + struct group *gr; + struct group *grdstp = NULL; + int ret; + + if (!nwrap_enabled()) { + return real_getgrent_r(grdst, buf, buflen); + } + + gr = nwrap_getgrent(); + if (!gr) { + if (errno == 0) { + errno = ENOENT; + } + return NULL; + } + + ret = nwrap_gr_copy_r(gr, grdst, buf, buflen, &grdstp); + if (ret != 0) { + errno = ret; + return NULL; + } + + return grdstp; +} +#else _PUBLIC_ int nwrap_getgrent_r(struct group *grdst, char *buf, size_t buflen, struct group **grdstp) { @@ -1083,6 +1144,7 @@ _PUBLIC_ int nwrap_getgrent_r(struct group *grdst, char *buf, return nwrap_gr_copy_r(gr, grdst, buf, buflen, grdstp); } +#endif _PUBLIC_ void nwrap_endgrent(void) { -- cgit