X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbackend.c;h=c8d30afd066efce744304c112c6d58a149fb9c74;hb=48b63d4f165269f29c35f89cceddd880c3966ef5;hp=eb0e3a31942b9e06296647f33b20e7f0958c0154;hpb=e2b5b211558ee778f07954d3843b914f19f6c6b5;p=openldap diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index eb0e3a3194..c8d30afd06 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -13,6 +13,8 @@ #include "slap.h" #include "lutil.h" +#include "ldap_defaults.h" + #ifdef SLAPD_LDAP #include "back-ldap/external.h" #endif @@ -36,25 +38,25 @@ #endif static BackendInfo binfo[] = { -#ifdef SLAPD_LDAP +#if defined(SLAPD_LDAP) && !defined(SLAPD_LDAP_DYNAMIC) {"ldap", ldap_back_initialize}, #endif -#ifdef SLAPD_LDBM +#if defined(SLAPD_LDBM) && !defined(SLAPD_LDBM_DYNAMIC) {"ldbm", ldbm_back_initialize}, #endif -#ifdef SLAPD_BDB2 +#if defined(SLAPD_BDB2) && !defined(SLAPD_BDB2_DYNAMIC) {"bdb2", bdb2_back_initialize}, #endif -#ifdef SLAPD_PASSWD +#if defined(SLAPD_PASSWD) && !defined(SLAPD_PASSWD_DYNAMIC) {"passwd", passwd_back_initialize}, #endif -#ifdef SLAPD_PERL +#if defined(SLAPD_PERL) && !defined(SLAPD_PERL_DYNAMIC) {"perl", perl_back_initialize}, #endif -#ifdef SLAPD_SHELL +#if defined(SLAPD_SHELL) && !defined(SLAPD_SHELL_DYNAMIC) {"shell", shell_back_initialize}, #endif -#ifdef SLAPD_TCL +#if defined(SLAPD_TCL) && !defined(SLAPD_LDAP_TCL) {"tcl", tcl_back_initialize}, #endif {NULL} @@ -108,11 +110,48 @@ int backend_init(void) return 0; } +#ifdef SLAPD_MODULES + return 0; +#else Debug( LDAP_DEBUG_ANY, "backend_init: failed\n", 0, 0, 0 ); return rc; +#endif /* SLAPD_MODULES */ +} + +int backend_add(BackendInfo *aBackendInfo) +{ + int rc = 0; + + if ((rc = aBackendInfo->bi_init(aBackendInfo)) != 0) { + Debug( LDAP_DEBUG_ANY, + "backend_add: initialization for type \"%s\" failed\n", + aBackendInfo->bi_type, 0, 0 ); + return rc; + } + + /* now add the backend type to the Backend Info List */ + { + BackendInfo *newBackendInfo = 0; + + /* if backendInfo == binfo no deallocation of old backendInfo */ + if (backendInfo == binfo) { + newBackendInfo = ch_calloc(nBackendInfo + 1, sizeof(BackendInfo)); + memcpy(newBackendInfo, backendInfo, sizeof(BackendInfo) * + nBackendInfo); + } else { + newBackendInfo = ch_realloc(backendInfo, sizeof(BackendInfo) * + (nBackendInfo + 1)); + } + memcpy(&newBackendInfo[nBackendInfo], aBackendInfo, + sizeof(BackendInfo)); + backendInfo = newBackendInfo; + nBackendInfo++; + + return 0; + } } int backend_startup(int n) @@ -295,6 +334,15 @@ int backend_destroy(void) } } +#ifdef SLAPD_MODULES + if (backendInfo != binfo) { + free(backendInfo); + } +#endif /* SLAPD_MODULES */ + + nBackendInfo = 0; + backendInfo = NULL; + return 0; } @@ -339,6 +387,9 @@ backend_db_init( be->be_sizelimit = defsize; be->be_timelimit = deftime; + be->be_realm = global_realm != NULL + ? ch_strdup( global_realm ) : NULL; + if(bi->bi_db_init) { rc = bi->bi_db_init( be ); } @@ -388,26 +439,6 @@ select_backend( char * dn ) } } - /* if no proper suffix could be found then check for aliases */ - for ( i = 0; i < nbackends; i++ ) { - for ( j = 0; - backends[i].be_suffixAlias != NULL && - backends[i].be_suffixAlias[j] != NULL; - j += 2 ) - { - len = strlen( backends[i].be_suffixAlias[j] ); - - if ( len > dnlen ) { - continue; - } - - if ( strcmp( backends[i].be_suffixAlias[j], - dn + (dnlen - len) ) == 0 ) { - return( &backends[i] ); - } - } - } - #ifdef LDAP_ALLOW_NULL_SEARCH_BASE /* Add greg@greg.rim.or.jp * It's quick hack for cheap client @@ -479,7 +510,7 @@ be_isroot_pw( Backend *be, char *ndn, struct berval *cred ) ldap_pvt_thread_mutex_lock( &crypt_mutex ); #endif - result = lutil_passwd( cred->bv_val, be->be_root_pw ); + result = lutil_passwd( cred->bv_val, be->be_root_pw, NULL ); #ifdef SLAPD_CRYPT ldap_pvt_thread_mutex_unlock( &crypt_mutex ); @@ -550,7 +581,6 @@ backend_connection_destroy( return 0; } -#ifdef SLAPD_ACLGROUPS int backend_group( Backend *be, @@ -567,4 +597,22 @@ backend_group( else return(1); } + +#ifdef SLAPD_SCHEMA_DN +Attribute *backend_subschemasubentry( Backend *be ) +{ + /* should be backend specific */ + static struct berval ss_val = { + sizeof(SLAPD_SCHEMA_DN)-1, + SLAPD_SCHEMA_DN }; + static struct berval *ss_vals[2] = { &ss_val, NULL }; + static Attribute ss_attr = { + "subschemasubentry", + ss_vals, + SYNTAX_DN | SYNTAX_CIS, + NULL + }; + + return &ss_attr; +} #endif