diff options
author | drochner <drochner@pkgsrc.org> | 2005-08-30 16:12:02 +0000 |
---|---|---|
committer | drochner <drochner@pkgsrc.org> | 2005-08-30 16:12:02 +0000 |
commit | b43512d6ffe28382c606d327757ef71280d28bd5 (patch) | |
tree | 99112bed834df73776e4df98845bbefea2b20f92 /databases/nss_ldap | |
parent | 4228a37254b32e4cef8f06e2c5ab5a6cb189b94b (diff) | |
download | pkgsrc-b43512d6ffe28382c606d327757ef71280d28bd5.tar.gz |
use the "dynamic" version of nss_ldap_initgroups(), to get the
total number of groups
doesn't make much of a difference for standard systems with
NGROUPS==_SC_NGROUPS_MAX, but someone might change this
Diffstat (limited to 'databases/nss_ldap')
-rw-r--r-- | databases/nss_ldap/files/netbsd.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/databases/nss_ldap/files/netbsd.c b/databases/nss_ldap/files/netbsd.c index 2e3de3f9f01..06792f312e3 100644 --- a/databases/nss_ldap/files/netbsd.c +++ b/databases/nss_ldap/files/netbsd.c @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd.c,v 1.2 2005/08/30 12:47:52 drochner Exp $ */ +/* $NetBSD: netbsd.c,v 1.3 2005/08/30 16:12:02 drochner Exp $ */ #include <sys/param.h> #include <pwd.h> @@ -45,8 +45,8 @@ extern NSS_STATUS _nss_ldap_getgrgid_r(gid_t, struct group *, char *, size_t, int *); static int netbsd_getgrgid(void *, void *, va_list); static int netbsd_getgrgid_r(void *, void *, va_list); -extern NSS_STATUS _nss_ldap_initgroups(const char *, gid_t, long int *, - long int *, gid_t *, long int, int *); +extern NSS_STATUS _nss_ldap_initgroups_dyn(const char *, gid_t, long int *, + long int *, gid_t **, long int, int *); static int netbsd_getgroupmembership(void *, void *, va_list); static int nss2netbsderr[] = { @@ -451,27 +451,34 @@ netbsd_getgroupmembership(void *rv, void *cb_data, va_list ap) gid_t *groups = va_arg(ap, gid_t *); int limit = va_arg(ap, int); int *size = va_arg(ap, int*); + gid_t *tmpgroups; long int lstart, lsize; + tmpgroups = malloc(limit * sizeof(gid_t)); + if (!tmpgroups) + return NS_TRYAGAIN; /* insert primary membership */ if (*size < limit) { - groups[0] = group; + tmpgroups[0] = group; (*size)++; } lstart = *size; lsize = limit; - s = _nss_ldap_initgroups(user, group, &lstart, &lsize, - groups, limit, &err); - *size = lstart; - if (s == NSS_STATUS_TRYAGAIN) { - /* array too short */ - *retval = -1; - } else { - if (s == NSS_STATUS_SUCCESS) - s = NSS_STATUS_NOTFOUND; - *retval = 0; + s = _nss_ldap_initgroups_dyn(user, group, &lstart, &lsize, + &tmpgroups, 0, &err); + if (s == NSS_STATUS_SUCCESS) { + if (lstart > limit) { + memcpy(groups, tmpgroups, limit * sizeof(gid_t)); + *retval = -1; + } else { + memcpy(groups, tmpgroups, lstart * sizeof(gid_t)); + *retval = 0; + } + *size = lstart; + s = NSS_STATUS_NOTFOUND; } - + free(tmpgroups); + return nss2netbsderr[s]; } |