]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapi/plugin.c
fix ITS#5959 fix
[openldap] / servers / slapd / slapi / plugin.c
index b0306abd9462090e31fa6e5a3b0115be531e0af5..89649726c789d555ea5bca934d3c08198613e319 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2002-2005 The OpenLDAP Foundation.
+ * Copyright 2002-2009 The OpenLDAP Foundation.
  * Portions Copyright 1997,2002-2003 IBM Corporation.
  * All rights reserved.
  *
  */
 
 #include "portable.h"
-#include <ldap_pvt_thread.h>
-#include <slap.h>
-#include <slapi.h>
-#include <lutil.h>
+#include "ldap_pvt_thread.h"
+#include "slap.h"
+#include "config.h"
+#include "slapi.h"
+#include "lutil.h"
 
 /*
  * Note: if ltdl.h is not available, slapi should not be compiled
@@ -598,7 +599,7 @@ slapi_int_call_plugins(
        rc = slapi_int_get_plugins( be, funcType, &tmpPlugin );
        if ( rc != LDAP_SUCCESS || tmpPlugin == NULL ) {
                /* Nothing to do, front-end should ignore. */
-               return 1;
+               return rc;
        }
 
        for ( pGetPlugin = tmpPlugin ; *pGetPlugin != NULL; pGetPlugin++ ) {
@@ -644,9 +645,11 @@ slapi_int_read_config(
        }
 
        /* automatically instantiate overlay if necessary */
-       if ( !overlay_is_inst( be, SLAPI_OVERLAY_NAME ) ) {
-               if ( overlay_config( be, SLAPI_OVERLAY_NAME ) != 0 ) {
-                       fprintf( stderr, "Failed to instantiate SLAPI overlay\n");
+       if ( !slapi_over_is_inst( be ) ) {
+               ConfigReply cr = { 0 };
+               if ( slapi_over_config( be, &cr ) != 0 ) {
+                       fprintf( stderr, "Failed to instantiate SLAPI overlay: "
+                               "err=%d msg=\"%s\"\n", cr.err, cr.msg );
                        return -1;
                }
        }
@@ -722,7 +725,11 @@ slapi_int_plugin_unparse(
                slapi_pblock_get( pp, SLAPI_X_CONFIG_ARGV, &argv );
                if ( argv == NULL ) /* could be dynamic plugin */
                        continue;
-               idx.bv_len = sprintf( idx.bv_val, "{%d}", i );
+               idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), "{%d}", i );
+               if ( idx.bv_len >= sizeof( ibuf ) ) {
+                       /* FIXME: just truncating by now */
+                       idx.bv_len = sizeof( ibuf ) - 1;
+               }
                bv.bv_len = idx.bv_len;
                for (j=1; argv[j]; j++) {
                        bv.bv_len += strlen(argv[j]);
@@ -738,29 +745,3 @@ slapi_int_plugin_unparse(
        }
 }
 
-int
-slapi_int_initialize(void)
-{
-       if ( ldap_pvt_thread_mutex_init( &slapi_hn_mutex ) ) {
-               return -1;
-       }
-       
-       if ( ldap_pvt_thread_mutex_init( &slapi_time_mutex ) ) {
-               return -1;
-       }
-
-       if ( ldap_pvt_thread_mutex_init( &slapi_printmessage_mutex ) ) {
-               return -1;
-       }
-
-       slapi_log_file = slapi_ch_strdup( LDAP_RUNDIR LDAP_DIRSEP "errors" );
-       if ( slapi_log_file == NULL ) {
-               return -1;
-       }
-
-       if ( slapi_int_init_object_extensions() != 0 ) {
-               return -1;
-       }
-
-       return slapi_int_overlay_init();
-}