1 /* $NetBSD: init.c,v 1.1.1.4 2014/05/28 09:58:51 tron Exp $ */ 2 3 /* init.c - initialize passwd backend */ 4 /* $OpenLDAP$ */ 5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright 1998-2014 The OpenLDAP Foundation. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted only as authorized by the OpenLDAP 12 * Public License. 13 * 14 * A copy of this license is available in the file LICENSE in the 15 * top-level directory of the distribution or, alternatively, at 16 * <http://www.OpenLDAP.org/license.html>. 17 */ 18 19 #include "portable.h" 20 21 #include <stdio.h> 22 23 #include <ac/socket.h> 24 25 #include "slap.h" 26 #include "back-passwd.h" 27 28 ldap_pvt_thread_mutex_t passwd_mutex; 29 30 AttributeDescription *ad_sn; 31 AttributeDescription *ad_desc; 32 33 static BI_db_init passwd_back_db_init; 34 35 int 36 passwd_back_initialize( 37 BackendInfo *bi 38 ) 39 { 40 ldap_pvt_thread_mutex_init( &passwd_mutex ); 41 42 bi->bi_open = passwd_back_open; 43 bi->bi_config = 0; 44 bi->bi_close = 0; 45 bi->bi_destroy = passwd_back_destroy; 46 47 bi->bi_db_init = passwd_back_db_init; 48 bi->bi_db_config = 0; 49 bi->bi_db_open = 0; 50 bi->bi_db_close = 0; 51 bi->bi_db_destroy = 0; 52 53 bi->bi_op_bind = 0; 54 bi->bi_op_unbind = 0; 55 bi->bi_op_search = passwd_back_search; 56 bi->bi_op_compare = 0; 57 bi->bi_op_modify = 0; 58 bi->bi_op_modrdn = 0; 59 bi->bi_op_add = 0; 60 bi->bi_op_delete = 0; 61 bi->bi_op_abandon = 0; 62 63 bi->bi_extended = 0; 64 65 bi->bi_chk_referrals = 0; 66 67 bi->bi_connection_init = 0; 68 bi->bi_connection_destroy = 0; 69 70 return passwd_back_init_cf( bi ); 71 } 72 73 int 74 passwd_back_open( 75 BackendInfo *bi 76 ) 77 { 78 const char *text; 79 int rc; 80 81 rc = slap_str2ad( "sn", &ad_sn, &text ); 82 if ( rc != LDAP_SUCCESS ) { 83 Debug( LDAP_DEBUG_ANY, "passwd_back_open: " 84 "slap_str2ad(\"%s\") returned %d: %s\n", 85 "sn", rc, text ); 86 return -1; 87 } 88 rc = slap_str2ad( "description", &ad_desc, &text ); 89 if ( rc != LDAP_SUCCESS ) { 90 Debug( LDAP_DEBUG_ANY, "passwd_back_open: " 91 "slap_str2ad(\"%s\") returned %d: %s\n", 92 "description", rc, text ); 93 return -1; 94 } 95 96 return 0; 97 } 98 99 int 100 passwd_back_destroy( 101 BackendInfo *bi 102 ) 103 { 104 ldap_pvt_thread_mutex_destroy( &passwd_mutex ); 105 return 0; 106 } 107 108 static int 109 passwd_back_db_init( 110 Backend *be, 111 struct config_reply_s *cr 112 ) 113 { 114 be->be_cf_ocs = be->bd_info->bi_cf_ocs; 115 return 0; 116 } 117 118 #if SLAPD_PASSWD == SLAPD_MOD_DYNAMIC 119 120 /* conditionally define the init_module() function */ 121 SLAP_BACKEND_INIT_MODULE( passwd ) 122 123 #endif /* SLAPD_PASSWD == SLAPD_MOD_DYNAMIC */ 124 125