From f67d6f67b84daa6acd33dd8f4192a72bc46c3a63 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Thu, 16 Dec 2010 21:50:51 +0000 Subject: switch to a common back-end with a common constructor and destructor and put file pointer shared between {set,get,end}ent() calls in there git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd-solaris@1333 ef36b2f9-881f-0410-afb5-c4e39611909c --- nss/group.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'nss/group.c') diff --git a/nss/group.c b/nss/group.c index 7427e2d..b460445 100644 --- a/nss/group.c +++ b/nss/group.c @@ -247,23 +247,20 @@ static nss_status_t group_getgrgid(nss_backend_t UNUSED(*be),void *args) READ_RESULT(fp)); } -/* thread-local file pointer to an ongoing request */ -static __thread TFILE *grentfp; - -static nss_status_t group_setgrent(nss_backend_t UNUSED(*be),void UNUSED(*args)) +static nss_status_t group_setgrent(nss_backend_t *be,void UNUSED(*args)) { - NSS_SETENT(grentfp); + NSS_SETENT(LDAP_BE(be)->fp); } -static nss_status_t group_getgrent(nss_backend_t UNUSED(*be),void *args) +static nss_status_t group_getgrent(nss_backend_t *be,void *args) { - NSS_GETENT(grentfp,NSLCD_ACTION_GROUP_ALL, - READ_RESULT(grentfp)); + NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_GROUP_ALL, + READ_RESULT((LDAP_BE(be)->fp))); } -static nss_status_t group_endgrent(nss_backend_t UNUSED(*be),void UNUSED(*args)) +static nss_status_t group_endgrent(nss_backend_t *be,void UNUSED(*args)) { - NSS_ENDENT(grentfp); + NSS_ENDENT(LDAP_BE(be)->fp); } /* @@ -282,14 +279,8 @@ static nss_status_t group_getgroupsbymember(nss_backend_t UNUSED(*be),void *args argp->numgids=(int)start;); } -static nss_status_t group_destructor(nss_backend_t *be,void UNUSED(*args)) -{ - free(be); - return NSS_STATUS_SUCCESS; -} - static nss_backend_op_t group_ops[]={ - group_destructor, + nss_ldap_destructor, group_endgrent, group_setgrent, group_getgrent, @@ -301,12 +292,7 @@ static nss_backend_op_t group_ops[]={ nss_backend_t *_nss_ldap_group_constr(const char UNUSED(*db_name), const char UNUSED(*src_name),const char UNUSED(*cfg_args)) { - nss_backend_t *be; - if (!(be=(nss_backend_t *)malloc(sizeof(*be)))) - return NULL; - be->ops=group_ops; - be->n_ops=sizeof(group_ops)/sizeof(nss_backend_op_t); - return (nss_backend_t *)be; + return nss_ldap_constructor(group_ops,sizeof(group_ops)); } #endif /* NSS_FLAVOUR_SOLARIS */ -- cgit v1.2.3