1 /* $NetBSD: init.c,v 1.3 2021/08/14 16:15:01 christos 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-2021 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 <sys/cdefs.h> 20 __RCSID("$NetBSD: init.c,v 1.3 2021/08/14 16:15:01 christos Exp $"); 21 22 #include "portable.h" 23 24 #include <stdio.h> 25 26 #include <ac/socket.h> 27 28 #include "slap.h" 29 #include "back-passwd.h" 30 31 ldap_pvt_thread_mutex_t passwd_mutex; 32 33 AttributeDescription *ad_sn; 34 AttributeDescription *ad_desc; 35 36 static BI_db_init passwd_back_db_init; 37 38 int 39 passwd_back_initialize( 40 BackendInfo *bi 41 ) 42 { 43 ldap_pvt_thread_mutex_init( &passwd_mutex ); 44 45 bi->bi_open = passwd_back_open; 46 bi->bi_config = 0; 47 bi->bi_close = 0; 48 bi->bi_destroy = passwd_back_destroy; 49 50 bi->bi_db_init = passwd_back_db_init; 51 bi->bi_db_config = 0; 52 bi->bi_db_open = 0; 53 bi->bi_db_close = 0; 54 bi->bi_db_destroy = 0; 55 56 bi->bi_op_bind = 0; 57 bi->bi_op_unbind = 0; 58 bi->bi_op_search = passwd_back_search; 59 bi->bi_op_compare = 0; 60 bi->bi_op_modify = 0; 61 bi->bi_op_modrdn = 0; 62 bi->bi_op_add = 0; 63 bi->bi_op_delete = 0; 64 bi->bi_op_abandon = 0; 65 66 bi->bi_extended = 0; 67 68 bi->bi_chk_referrals = 0; 69 70 bi->bi_connection_init = 0; 71 bi->bi_connection_destroy = 0; 72 73 return passwd_back_init_cf( bi ); 74 } 75 76 int 77 passwd_back_open( 78 BackendInfo *bi 79 ) 80 { 81 const char *text; 82 int rc; 83 84 rc = slap_str2ad( "sn", &ad_sn, &text ); 85 if ( rc != LDAP_SUCCESS ) { 86 Debug( LDAP_DEBUG_ANY, "passwd_back_open: " 87 "slap_str2ad(\"%s\") returned %d: %s\n", 88 "sn", rc, text ); 89 return -1; 90 } 91 rc = slap_str2ad( "description", &ad_desc, &text ); 92 if ( rc != LDAP_SUCCESS ) { 93 Debug( LDAP_DEBUG_ANY, "passwd_back_open: " 94 "slap_str2ad(\"%s\") returned %d: %s\n", 95 "description", rc, text ); 96 return -1; 97 } 98 99 return 0; 100 } 101 102 int 103 passwd_back_destroy( 104 BackendInfo *bi 105 ) 106 { 107 ldap_pvt_thread_mutex_destroy( &passwd_mutex ); 108 return 0; 109 } 110 111 static int 112 passwd_back_db_init( 113 Backend *be, 114 struct config_reply_s *cr 115 ) 116 { 117 be->be_cf_ocs = be->bd_info->bi_cf_ocs; 118 return 0; 119 } 120 121 #if SLAPD_PASSWD == SLAPD_MOD_DYNAMIC 122 123 /* conditionally define the init_module() function */ 124 SLAP_BACKEND_INIT_MODULE( passwd ) 125 126 #endif /* SLAPD_PASSWD == SLAPD_MOD_DYNAMIC */ 127 128