summaryrefslogtreecommitdiff
path: root/nss/common.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2010-12-16 21:50:51 +0000
committerArthur de Jong <arthur@arthurdejong.org>2010-12-16 21:50:51 +0000
commitf67d6f67b84daa6acd33dd8f4192a72bc46c3a63 (patch)
tree5a2a84e90cbf80cd3f2ca1616a2d27b694c51d91 /nss/common.c
parent08f01639626bb2ec2537df7d9f8c5459867c0afb (diff)
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
Diffstat (limited to 'nss/common.c')
-rw-r--r--nss/common.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/nss/common.c b/nss/common.c
index 20a3136..7a0f8e7 100644
--- a/nss/common.c
+++ b/nss/common.c
@@ -19,4 +19,38 @@
02110-1301 USA
*/
+#include "config.h"
+
+#include <errno.h>
+
+#include "prototypes.h"
+#include "common.h"
+#include "compat/attrs.h"
+
+/* global symbol to prevent NSS name lookups using this module */
int _nss_ldap_enablelookups=1;
+
+#ifdef NSS_FLAVOUR_SOLARIS
+
+nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops,size_t sizeofops)
+{
+ struct nss_ldap_backend *ldapbe;
+ ldapbe=(struct nss_ldap_backend *)malloc(sizeof(struct nss_ldap_backend));
+ if (ldapbe==NULL)
+ return NULL;
+ ldapbe->ops=ops;
+ ldapbe->n_ops=sizeofops/sizeof(nss_backend_op_t);
+ ldapbe->fp=NULL;
+ return (nss_backend_t *)ldapbe;
+}
+
+nss_status_t nss_ldap_destructor(nss_backend_t *be,void UNUSED(*args))
+{
+ struct nss_ldap_backend *ldapbe=(struct nss_ldap_backend *)be;
+ if (ldapbe->fp!=NULL)
+ (void)tio_close(ldapbe->fp);
+ free(ldapbe);
+ return NSS_STATUS_SUCCESS;
+}
+
+#endif /* NSS_FLAVOUR_SOLARIS */