diff options
Diffstat (limited to 'nss/hosts.c')
-rw-r--r-- | nss/hosts.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/nss/hosts.c b/nss/hosts.c index 019e2b5..eda7dc5 100644 --- a/nss/hosts.c +++ b/nss/hosts.c @@ -242,6 +242,13 @@ nss_status_t _nss_ldap_endhostent(void) #ifdef NSS_FLAVOUR_SOLARIS +struct nss_ldap_hosts_backend +{ + nss_backend_op_t *ops; + int n_ops; + TFILE *fp; +}; + #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN static nss_status_t read_hoststring(TFILE *fp,nss_XbyY_args_t *args,int erronempty) @@ -341,33 +348,24 @@ static nss_status_t hosts_gethostbyaddr(nss_backend_t UNUSED(*be),void *args) READ_RESULT_ERRONEMPTY(fp)); } -/* thread-local file pointer to an ongoing request */ -static __thread TFILE *hostentfp; - -static nss_status_t hosts_sethostent(nss_backend_t UNUSED(*be),void UNUSED(*args)) +static nss_status_t hosts_sethostent(nss_backend_t *be,void UNUSED(*args)) { - NSS_SETENT(hostentfp); + NSS_SETENT(LDAP_BE(be)->fp); } -static nss_status_t hosts_gethostent(nss_backend_t UNUSED(*be),void *args) +static nss_status_t hosts_gethostent(nss_backend_t *be,void *args) { - NSS_GETENT(hostentfp,NSLCD_ACTION_HOST_ALL, - READ_RESULT_NEXTONEMPTY(hostentfp)); -} - -static nss_status_t hosts_endhostent(nss_backend_t UNUSED(*be),void UNUSED(*args)) -{ - NSS_ENDENT(hostentfp); + NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_HOST_ALL, + READ_RESULT_NEXTONEMPTY(LDAP_BE(be)->fp)); } -static nss_status_t hosts_destructor(nss_backend_t *be,void UNUSED(*args)) +static nss_status_t hosts_endhostent(nss_backend_t *be,void UNUSED(*args)) { - free(be); - return NSS_STATUS_SUCCESS; + NSS_ENDENT(LDAP_BE(be)->fp); } -static nss_backend_op_t host_ops[]={ - hosts_destructor, +static nss_backend_op_t hosts_ops[]={ + nss_ldap_destructor, hosts_endhostent, hosts_sethostent, hosts_gethostent, @@ -378,12 +376,7 @@ static nss_backend_op_t host_ops[]={ nss_backend_t *_nss_ldap_hosts_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=host_ops; - be->n_ops=sizeof(host_ops)/sizeof(nss_backend_op_t); - return (nss_backend_t *)be; + return nss_ldap_constructor(hosts_ops,sizeof(hosts_ops)); } #endif /* NSS_FLAVOUR_SOLARIS */ |