int oath_preop_init(Slapi_PBlock *pb) { int rc; slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &oath_preop_plugin_id); if (slapi_pblock_get(pb, SLAPI_PLUGIN_ARGC, (void *) &argc) != 0 || slapi_pblock_get(pb, SLAPI_PLUGIN_ARGV, (void *) &argv)) { slapi_log_error(SLAPI_LOG_PLUGIN, "oath", "oath_preop_init: Failed to obtain plugin args, not registering plugin\n"); return -1; } if (argc < 1) { slapi_log_error(SLAPI_LOG_PLUGIN, "oath", "oath_preop_init: No configuration given, not registering plugin\n"); return -1; } if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *) &oath_preop_plugin_desc) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_BIND_FN, (void *) oath_preop_bind) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, (void *) oath_preop_start) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN, (void *) oath_preop_close) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, "oath", "oath_preop_init: Error registering plugin\n"); return -1; } slapi_log_error(SLAPI_LOG_PLUGIN, "oath", "oath_preop_init: Plugin successfully registered\n"); return 0; }
/* this function takes SLAPI_PLUGIN_MR_VALUES as Slapi_Value ** and returns SLAPI_PLUGIN_MR_KEYS as Slapi_Value ** */ static int mr_wrap_mr_index_sv_fn(Slapi_PBlock* pb) { int rc = -1; Slapi_Value **in_vals = NULL; Slapi_Value **out_vals = NULL; struct slapdplugin *pi = NULL; slapi_pblock_set(pb, SLAPI_PLUGIN_MR_KEYS, out_vals); /* make sure output is cleared */ slapi_pblock_get(pb, SLAPI_PLUGIN, &pi); if (!pi) { slapi_log_err(SLAPI_LOG_ERR, "mr_wrap_mr_index_sv_fn", "No plugin specified\n"); } else if (!pi->plg_mr_values2keys) { slapi_log_err(SLAPI_LOG_ERR, "mr_wrap_mr_index_sv_fn", "Plugin has no plg_mr_values2keys function\n"); } else { struct mr_private *mrpriv = NULL; int ftype = plugin_mr_get_type(pi); slapi_pblock_get(pb, SLAPI_PLUGIN_MR_VALUES, &in_vals); (*pi->plg_mr_values2keys)(pb, in_vals, &out_vals, ftype); slapi_pblock_set(pb, SLAPI_PLUGIN_MR_KEYS, out_vals); /* we have to save out_vals to free next time or during destroy */ slapi_pblock_get(pb, SLAPI_PLUGIN_OBJECT, &mrpriv); /* In case SLAPI_PLUGIN_OBJECT is not set * (e.g. custom index/filter create function did not initialize it */ if (mrpriv) { mr_private_indexer_done(mrpriv); /* free old vals, if any */ mrpriv->sva = out_vals; /* save pointer for later */ } rc = 0; } return rc; }
int acct_postop_init( Slapi_PBlock *pb ) { void *plugin_id = get_identity(); if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&post_plugin_desc ) != 0 ) { slapi_log_err(SLAPI_LOG_ERR, POST_PLUGIN_NAME, "acct_postop_init - Failed to set plugin version or name\n" ); return( CALLBACK_ERR ); } if ( slapi_pblock_set( pb, SLAPI_PLUGIN_POST_BIND_FN, (void *)acct_bind_postop ) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN, (void *) acct_post_op) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN, (void *) acct_post_op) != 0) { slapi_log_err(SLAPI_LOG_ERR, POST_PLUGIN_NAME, "acct_postop_init - Failed to set plugin callback function\n" ); return( CALLBACK_ERR ); } if( slapi_pblock_get( pb, SLAPI_PLUGIN_IDENTITY, &plugin_id ) != 0 ) { slapi_log_err(SLAPI_LOG_ERR, POST_PLUGIN_NAME, "acct_postop_init - Failed to get plugin identity\n" ); return( CALLBACK_ERR ); } return( CALLBACK_OK ); }
static int usn_bepostop_init(Slapi_PBlock *pb) { int rc = 0; Slapi_Entry *plugin_entry = NULL; char *plugin_type = NULL; int postadd = SLAPI_PLUGIN_BE_POST_ADD_FN; int postmod = SLAPI_PLUGIN_BE_POST_MODIFY_FN; int postmdn = SLAPI_PLUGIN_BE_POST_MODRDN_FN; int postdel = SLAPI_PLUGIN_BE_POST_DELETE_FN; if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) && plugin_entry && (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) && plugin_type && strstr(plugin_type, "betxn")) { postadd = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN; postmod = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN; postmdn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN; postdel = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN; } slapi_ch_free_string(&plugin_type); if ((slapi_pblock_set(pb, postadd, (void *)usn_bepostop) != 0) || (slapi_pblock_set(pb, postdel, (void *)usn_bepostop_delete) != 0) || (slapi_pblock_set(pb, postmod, (void *)usn_bepostop_modify) != 0) || (slapi_pblock_set(pb, postmdn, (void *)usn_bepostop) != 0)) { slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM, "usn_bepostop_init: failed to register bepostop plugin\n"); rc = -1; } return rc; }
int sidgen_task_init(Slapi_PBlock *pb) { int ret = 0; ret = slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &global_sidgen_plugin_id); if (ret != 0 || global_sidgen_plugin_id == NULL) { LOG_FATAL("Plugin identity not available.\n"); ret = (ret != 0) ? ret : EINVAL; goto done; } ret = slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, (void *) SLAPI_PLUGIN_VERSION_03); ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, (void *) sigden_task_start); done: if (ret != 0) { LOG_FATAL("Failed to initialize plug-in\n" ); } return ret; }
void be_unbindall(Connection *conn, Operation *op) { int i; Slapi_PBlock pb = {0}; for ( i = 0; i < maxbackends; i++ ) { if ( backends[i] && (backends[i]->be_unbind != NULL) ) { /* This is the modern, and faster way to do pb memset(0) * It also doesn't trigger the HORRIBLE stack overflows I found ... */ pblock_init_common( &pb, backends[i], conn, op ); if ( plugin_call_plugins( &pb, SLAPI_PLUGIN_PRE_UNBIND_FN ) == 0 ) { int rc = 0; slapi_pblock_set( &pb, SLAPI_PLUGIN, backends[i]->be_database ); if(backends[i]->be_state != BE_STATE_DELETED && backends[i]->be_unbind!=NULL) { rc = (*backends[i]->be_unbind)( &pb ); } slapi_pblock_set( &pb, SLAPI_PLUGIN_OPRETURN, &rc ); (void) plugin_call_plugins( &pb, SLAPI_PLUGIN_POST_UNBIND_FN ); } } } }
/* Initialize a pblock for a call to slapi_delete_internal_pb() */ void slapi_delete_internal_set_pb (Slapi_PBlock *pb, const char *rawdn, LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags) { Operation *op; PR_ASSERT (pb != NULL); if (pb == NULL || rawdn == NULL) { slapi_log_error(SLAPI_LOG_FATAL, NULL, "slapi_delete_internal_set_pb: NULL parameter\n"); return; } op = internal_operation_new(SLAPI_OPERATION_DELETE,operation_flags); slapi_pblock_set(pb, SLAPI_OPERATION, op); slapi_pblock_set(pb, SLAPI_ORIGINAL_TARGET, (void*)rawdn); slapi_pblock_set(pb, SLAPI_CONTROLS_ARG, controls); if (uniqueid) { slapi_pblock_set(pb, SLAPI_TARGET_UNIQUEID, (void*)uniqueid); } slapi_pblock_set(pb, SLAPI_PLUGIN_IDENTITY, plugin_identity); }
/* * Plugin initialization function (which must be listed in the appropriate * slapd config file). */ int passthruauth_init( Slapi_PBlock *pb ) { PASSTHRU_ASSERT( pb != NULL ); slapi_log_error( SLAPI_LOG_PLUGIN, PASSTHRU_PLUGIN_SUBSYSTEM, "=> passthruauth_init\n" ); if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, (void *)SLAPI_PLUGIN_VERSION_01 ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&pdesc ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *)passthru_bindpreop_start ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_BIND_FN, (void *)passthru_bindpreop ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *)passthru_bindpreop_close ) != 0 ) { slapi_log_error( SLAPI_LOG_FATAL, PASSTHRU_PLUGIN_SUBSYSTEM, "passthruauth_init failed\n" ); return( -1 ); } slapi_log_error( SLAPI_LOG_PLUGIN, PASSTHRU_PLUGIN_SUBSYSTEM, "<= passthruauth_init succeeded\n" ); return( 0 ); }
static int bitwise_filter_create (Slapi_PBlock* pb) { auto int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; /* failed to initialize */ auto char* mrOID = NULL; auto char* mrTYPE = NULL; auto struct berval* mrVALUE = NULL; if (!slapi_pblock_get (pb, SLAPI_PLUGIN_MR_OID, &mrOID) && mrOID != NULL && !slapi_pblock_get (pb, SLAPI_PLUGIN_MR_TYPE, &mrTYPE) && mrTYPE != NULL && !slapi_pblock_get (pb, SLAPI_PLUGIN_MR_VALUE, &mrVALUE) && mrVALUE != NULL) { struct bitwise_match_cb *bmc = NULL; if (strcmp(mrOID, "1.2.840.113556.1.4.803") == 0) { slapi_pblock_set (pb, SLAPI_PLUGIN_MR_FILTER_MATCH_FN, (void*)bitwise_filter_match_and); } else if (strcmp(mrOID, "1.2.840.113556.1.4.804") == 0) { slapi_pblock_set (pb, SLAPI_PLUGIN_MR_FILTER_MATCH_FN, (void*)bitwise_filter_match_or); } else { /* this oid not handled by this plugin */ LDAPDebug (LDAP_DEBUG_FILTER, "=> bitwise_filter_create OID (%s) not handled\n", mrOID, 0, 0); return rc; } bmc = new_bitwise_match_cb(mrTYPE, mrVALUE); slapi_pblock_set (pb, SLAPI_PLUGIN_OBJECT, bmc); slapi_pblock_set (pb, SLAPI_PLUGIN_DESTROY_FN, (void*)bitwise_filter_destroy); rc = LDAP_SUCCESS; } else { LDAPDebug (LDAP_DEBUG_FILTER, "=> bitwise_filter_create missing parameter(s)\n", 0, 0, 0); } LDAPDebug (LDAP_DEBUG_FILTER, "<= bitwise_filter_create %i\n", rc, 0, 0); return LDAP_SUCCESS; }
int ipa_topo_pre_add(Slapi_PBlock *pb) { int result = SLAPI_PLUGIN_SUCCESS; char *errtxt = NULL; slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM, "--> ipa_topo_pre_add\n"); if (0 == ipa_topo_get_plugin_active()) { slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM, "<-- ipa_topo_pre_add - plugin not active\n"); return 0; } if (ipa_topo_pre_ignore_op(pb)) return result; if (ipa_topo_is_entry_managed(pb)) { int rc = LDAP_UNWILLING_TO_PERFORM; errtxt = slapi_ch_smprintf("Entry is managed by topology plugin." " Adding of entry not allowed.\n"); slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, errtxt); slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc); result = SLAPI_PLUGIN_FAILURE; } else if (ipa_topo_check_segment_is_valid(pb, &errtxt)) { int rc = LDAP_UNWILLING_TO_PERFORM; slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, errtxt); slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc); result = SLAPI_PLUGIN_FAILURE; } slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM, "<-- ipa_topo_pre_add\n"); return result; }
/* Initialize the legacy replication plugin */ int replication_legacy_plugin_init(Slapi_PBlock *pb) { static int legacy_initialised= 0; int rc= 0; /* OK */ void *identity = NULL; slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &identity); PR_ASSERT (identity); repl_set_plugin_identity (PLUGIN_LEGACY_REPLICATION, identity); if(rc==0 && !legacy_initialised) { rc= slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ); rc= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacydesc ); rc= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) legacy_start ); rc= slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *) legacy_stop ); rc= slapi_pblock_set( pb, SLAPI_PLUGIN_POSTSTART_FN, (void *) legacy_poststart ); /* Register the plugin interfaces we implement */ rc= slapi_register_plugin("preoperation", 1 /* Enabled */, "legacy_preop_init", legacy_preop_init, "Legacy replication preoperation plugin", NULL, identity); rc= slapi_register_plugin("postoperation", 1 /* Enabled */, "legacy_postop_init", legacy_postop_init, "Legacy replication postoperation plugin", NULL, identity); rc= slapi_register_plugin("internalpreoperation", 1 /* Enabled */, "legacy_internalpreop_init", legacy_internalpreop_init, "Legacy replication internal preoperation plugin", NULL, identity); rc= slapi_register_plugin("internalpostoperation", 1 /* Enabled */, "legacy_internalpostop_init", legacy_internalpostop_init, "Legacy replication internal postoperation plugin", NULL, identity); rc= slapi_register_plugin("entry", 1 /* Enabled */, "legacy_entry_init", legacy_entry_init, "Legacy replication entry plugin", NULL, identity); legacy_initialised= 1; } return rc; }
int ipa_topo_pre_modrdn(Slapi_PBlock *pb) { int result = SLAPI_PLUGIN_SUCCESS; slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM, "--> ipa_topo_pre_modrdn\n"); if (0 == ipa_topo_get_plugin_active()) { slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM, "<-- ipa_topo_pre_modrdn - plugin not active\n"); return 0; } if (ipa_topo_pre_ignore_op(pb)) return result; if (ipa_topo_check_entry_move(pb)){ int rc = LDAP_UNWILLING_TO_PERFORM; char *errtxt; errtxt = slapi_ch_smprintf("Moving of a segment or config entry " "to another subtree is not allowed.\n"); slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, errtxt); slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc); result = SLAPI_PLUGIN_FAILURE; } return result; }
static int rename_internal_pb (Slapi_PBlock *pb) { LDAPControl **controls; Operation *op; int opresult = 0; PR_ASSERT (pb != NULL); slapi_pblock_get(pb, SLAPI_CONTROLS_ARG, &controls); slapi_pblock_get(pb, SLAPI_OPERATION, &op); op->o_handler_data = &opresult; op->o_result_handler = internal_getresult_callback; slapi_pblock_set(pb, SLAPI_REQCONTROLS, controls); /* set parameters common for all internal operations */ set_common_params (pb); /* set actions taken to process the operation */ set_config_params (pb); op_shared_rename (pb, 0 /* not passing ownership of args */ ); slapi_pblock_set(pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); return 0; }
void slapi_rename_internal_set_pb_ext(Slapi_PBlock *pb, const Slapi_DN *olddn, const char *newrdn, /* normalized */ const Slapi_DN *newsuperior, int deloldrdn, LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags) { Operation *op; PR_ASSERT (pb != NULL); if (pb == NULL || olddn == NULL || newrdn == NULL) { slapi_log_error(SLAPI_LOG_FATAL, NULL, "slapi_rename_internal_set_pb: NULL parameter\n"); return; } op = internal_operation_new(SLAPI_OPERATION_MODRDN,operation_flags); slapi_pblock_set(pb, SLAPI_OPERATION, op); slapi_pblock_set(pb, SLAPI_ORIGINAL_TARGET, (void*)slapi_sdn_get_dn(olddn)); slapi_pblock_set(pb, SLAPI_MODRDN_TARGET_SDN, (void*)olddn); slapi_pblock_set(pb, SLAPI_MODRDN_NEWRDN, (void*)newrdn); slapi_pblock_set(pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, (void*)newsuperior); slapi_pblock_set(pb, SLAPI_MODRDN_DELOLDRDN, &deloldrdn); slapi_pblock_set(pb, SLAPI_CONTROLS_ARG, controls); slapi_pblock_set(pb, SLAPI_MODIFY_MODS, NULL); if (uniqueid) { slapi_pblock_set(pb, SLAPI_TARGET_UNIQUEID, (void*)uniqueid); } slapi_pblock_set(pb, SLAPI_PLUGIN_IDENTITY, plugin_identity); }
static int ipa_topo_internal_postop_init(Slapi_PBlock *pb) { int rc; rc = slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN, (void *)ipa_topo_post_add); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN, (void *)ipa_topo_post_del); return(rc); }
int acl_preopInit (Slapi_PBlock *pb) { int rc = 0; /* save plugin identity to later pass to internal operations */ rc = slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &g_acl_preop_plugin_identity); /* Declare plugin version */ rc = slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01); /* Provide descriptive information */ rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void*)&pdesc); /* Register functions */ rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_SEARCH_FN, (void*)aclplugin_preop_search); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_COMPARE_FN, (void*)aclplugin_preop_search); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN, (void*)aclplugin_preop_modify); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN, (void*)aclplugin_preop_modify); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODRDN_FN, (void*)aclplugin_preop_modify); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_DELETE_FN, (void*)aclplugin_preop_modify); #if 0 /* * XXXmcs: In order to support access control checking from * extended operations, we need a SLAPI_PLUGIN_PRE_EXTENDED_FN hook. * But today no such entry point exists. */ rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_EXTENDED_FN, (void*)aclplugin_preop_modify); #endif slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "<= acl_preop_Init %d\n", rc ); return( rc ); }
/* * Init function * Specified in the plugin entry as "nsslapd-pluginInitfunc: sampletask_init" */ int sampletask_init( Slapi_PBlock *pb ) { int rc = 0; rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, (void *) SLAPI_PLUGIN_VERSION_03 ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) task_sampletask_start ); return rc; }
int slapi_search_internal_callback_pb( Slapi_PBlock *pb, void *callback_data, plugin_result_callback prc, plugin_search_entry_callback psec, plugin_referral_entry_callback prec ) { int free_filter = 0; SlapReply *rs; if ( pb == NULL ) { return -1; } PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH ); rs = pb->pb_rs; /* search callback and arguments */ slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc ); slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec ); slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec ); slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data ); if ( BER_BVISEMPTY( &pb->pb_op->ors_filterstr )) { rs->sr_err = LDAP_PARAM_ERROR; goto cleanup; } if ( pb->pb_op->ors_filter == NULL ) { pb->pb_op->ors_filter = slapi_str2filter( pb->pb_op->ors_filterstr.bv_val ); if ( pb->pb_op->ors_filter == NULL ) { rs->sr_err = LDAP_PROTOCOL_ERROR; goto cleanup; } free_filter = 1; } slapi_int_func_internal_pb( pb, op_search ); cleanup: if ( free_filter ) { slapi_filter_free( pb->pb_op->ors_filter, 1 ); pb->pb_op->ors_filter = NULL; } slapi_pblock_delete_param( pb, SLAPI_X_INTOP_RESULT_CALLBACK ); slapi_pblock_delete_param( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK ); slapi_pblock_delete_param( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK ); slapi_pblock_delete_param( pb, SLAPI_X_INTOP_CALLBACK_DATA ); return 0; }
int addrdnvalues_preop_init(Slapi_PBlock *pb) { if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, &pluginDescription) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN, (void *)addrdnvalues_preop_add) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, "addrdnvalues_preop_init", "Error registering %s\n", pluginDescription.spd_description); return -1; } return 0; }
/* consumer connection extension destructor */ void consumer_connection_extension_destructor (void *ext, void *object, void *parent) { PRUint64 connid = 0; if (ext) { /* Check to see if this replication session has acquired * a replica. If so, release it here. */ consumer_connection_extension *connext = (consumer_connection_extension *)ext; if (NULL != connext->replica_acquired) { Replica *r = object_get_data ((Object*)connext->replica_acquired); /* If a total update was in progress, abort it */ if (REPL_PROTOCOL_50_TOTALUPDATE == connext->repl_protocol_version) { Slapi_PBlock *pb = slapi_pblock_new(); const Slapi_DN *repl_root_sdn = replica_get_root(r); PR_ASSERT(NULL != repl_root_sdn); if (NULL != repl_root_sdn) { slapi_pblock_set(pb, SLAPI_CONNECTION, connext->connection); slapi_pblock_set(pb, SLAPI_TARGET_SDN, (void*)repl_root_sdn); slapi_pblock_get(pb, SLAPI_CONN_ID, &connid); slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "Aborting total update in progress for replicated " "area %s connid=%" NSPRIu64 "\n", slapi_sdn_get_dn(repl_root_sdn), connid); slapi_stop_bulk_import(pb); } else { slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "consumer_connection_extension_destructor: can't determine root " "of replicated area.\n"); } slapi_pblock_destroy(pb); /* allow reaping again */ replica_set_tombstone_reap_stop(r, PR_FALSE); } replica_relinquish_exclusive_access(r, connid, -1); object_release ((Object*)connext->replica_acquired); connext->replica_acquired = NULL; } if (connext->supplier_ruv) { ruv_destroy ((RUV **)&connext->supplier_ruv); } connext->connection = NULL; slapi_ch_free((void **)&ext); } }
int /* LDAP error code */ bitwise_init (Slapi_PBlock* pb) { int rc; rc = slapi_pblock_set (pb, SLAPI_PLUGIN_MR_FILTER_CREATE_FN, (void*)bitwise_filter_create); if ( rc == 0 ) { rc = slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&pdesc ); } LDAPDebug (LDAP_DEBUG_FILTER, "bitwise_init %i\n", rc, 0, 0); return rc; }
void slapi_add_entry_internal_set_pb( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **controls, Slapi_ComponentId *plugin_identity, int operation_flags ) { slapi_int_connection_init_pb( pb, LDAP_REQ_ADD ); slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e ); slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls ); slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity ); slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags ); slapi_int_set_operation_dn( pb ); }
/* Initialize the entry plugin point for the legacy replication plugin */ static int legacy_entry_init( Slapi_PBlock *pb ) { int rc= 0; /* OK */ /* Set up the fn pointers for the preop and postop operations we're interested in */ if( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacyentrydesc ) != 0 ) { slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "legacy_entry_init failed\n" ); rc= -1; } return rc; }
static int or_indexer_create (Slapi_PBlock* pb) { auto int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; /* failed to initialize */ auto char* mrOID = NULL; auto void* mrOBJECT = NULL; if (slapi_pblock_get (pb, SLAPI_PLUGIN_MR_OID, &mrOID) || mrOID == NULL) { slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM, "or_indexer_create - No OID parameter\n"); } else { auto indexer_t* ix = indexer_create (mrOID); auto char* mrTYPE = NULL; slapi_pblock_get (pb, SLAPI_PLUGIN_MR_TYPE, &mrTYPE); slapi_log_err(SLAPI_LOG_FILTER, "or_indexer_create", "(oid %s; type %s)\n", mrOID, mrTYPE ? mrTYPE : "<NULL>"); if (ix != NULL) { if (ix->ix_index != NULL && !slapi_pblock_set (pb, SLAPI_PLUGIN_OBJECT, ix) && !slapi_pblock_set (pb, SLAPI_PLUGIN_MR_OID, ix->ix_oid) && !slapi_pblock_set (pb, SLAPI_PLUGIN_MR_INDEX_FN, (void*)op_index_entry) && !slapi_pblock_set (pb, SLAPI_PLUGIN_DESTROY_FN, (void*)op_indexer_destroy)) { mrOBJECT = ix; rc = 0; /* success */ } else { indexer_free (ix); } } else { /* mrOID does not identify an ordering rule. */ /* Is it an ordering rule OID with the substring suffix? */ auto size_t oidlen = strlen (mrOID); if (oidlen > 2 && mrOID[oidlen-2] == '.' && atoi (mrOID + oidlen - 1) == SLAPI_OP_SUBSTRING) { auto char* or_oid = slapi_ch_strdup (mrOID); or_oid [oidlen-2] = '\0'; ix = indexer_create (or_oid); if (ix != NULL) { auto ss_indexer_t* ss = (ss_indexer_t*) slapi_ch_malloc (sizeof (ss_indexer_t)); ss->ss_indexer = ix; oidlen = strlen (ix->ix_oid); ss->ss_oid = slapi_ch_malloc (oidlen + 3); memcpy (ss->ss_oid, ix->ix_oid, oidlen); sprintf (ss->ss_oid + oidlen, ".%1i", SLAPI_OP_SUBSTRING); if (ix->ix_index != NULL && !slapi_pblock_set (pb, SLAPI_PLUGIN_OBJECT, ss) && !slapi_pblock_set (pb, SLAPI_PLUGIN_MR_OID, ss->ss_oid) && !slapi_pblock_set (pb, SLAPI_PLUGIN_MR_INDEX_FN, (void*)ss_index_entry) && !slapi_pblock_set (pb, SLAPI_PLUGIN_DESTROY_FN, (void*)ss_indexer_destroy)) { mrOBJECT = ss; rc = 0; /* success */ } else { ss_indexer_free (ss); } } slapi_ch_free((void**)&or_oid); } } } slapi_log_err(SLAPI_LOG_FILTER, COLLATE_PLUGIN_SUBSYSTEM, "or_indexer_create - (%p) %i\n", mrOBJECT, rc); return rc; }
int acl_init( Slapi_PBlock *pb ) { int rc =0; slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "=> acl_init\n" ); if ( 0 != acl_init_ext() ) { slapi_log_err(SLAPI_LOG_ERR, plugin_name, "acl_init - Unable to initialize the extensions\n"); return 1; } /* save plugin identity to later pass to internal operations */ rc = slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &g_acl_plugin_identity); rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, (void *) SLAPI_PLUGIN_VERSION_01 ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&pdesc ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) aclplugin_init ); rc = slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *) aclplugin_stop ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_ACL_SYNTAX_CHECK, (void *) acl_verify_aci_syntax ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_ACL_ALLOW_ACCESS, (void *) acl_access_allowed_main ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_ACL_MODS_ALLOWED, (void *) acl_check_mods ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_ACL_MODS_UPDATE, (void *) acl_modified ); slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "<= acl_init %d\n", rc); return( rc ); }
static int ipa_topo_preop_init(Slapi_PBlock *pb) { int rc; rc = slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_MODIFY_FN, (void *)ipa_topo_pre_mod); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN, (void *)ipa_topo_pre_add); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_DELETE_FN, (void *)ipa_topo_pre_del); return(rc); }
Slapi_PBlock * slapi_rename_internal(const char *iodn, const char *inewrdn, const char *inewsuperior, int deloldrdn, LDAPControl **controls, int dummy) { Slapi_PBlock pb; Slapi_PBlock *result_pb = NULL; int opresult= 0; Slapi_DN sdn; Slapi_DN newsuperiorsdn; pblock_init (&pb); slapi_sdn_init_dn_byref(&sdn, iodn); slapi_sdn_init_dn_byref(&newsuperiorsdn, inewsuperior); slapi_rename_internal_set_pb_ext(&pb, &sdn, inewrdn, &newsuperiorsdn, deloldrdn, controls, NULL, plugin_get_default_component_id(), 0); rename_internal_pb (&pb); result_pb = slapi_pblock_new(); if (result_pb) { slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); } slapi_sdn_done(&sdn); slapi_sdn_done(&newsuperiorsdn); pblock_done(&pb); return result_pb; }
void slapi_delete_internal_set_pb( Slapi_PBlock *pb, const char *dn, LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags ) { slapi_int_connection_init_pb( pb, LDAP_REQ_DELETE ); slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn ); slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls ); slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid ); slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity ); slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags ); slapi_int_set_operation_dn( pb ); }
static int slapi_int_result( Operation *op, SlapReply *rs ) { Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); plugin_result_callback prc = NULL; void *callback_data = NULL; LDAPControl **ctrls = NULL; assert( pb != NULL ); slapi_pblock_get( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc ); slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data ); /* we need to duplicate controls because they might go out of scope */ ctrls = slapi_int_dup_controls( rs->sr_ctrls ); slapi_pblock_set( pb, SLAPI_RESCONTROLS, ctrls ); if ( prc != NULL ) { (*prc)( rs->sr_err, callback_data ); } return rs->sr_err; }
int destroy_matchrule_indexer(Slapi_PBlock *pb) { Slapi_Value **keys = NULL; IFP mrDESTROY = NULL; if (!slapi_pblock_get (pb, SLAPI_PLUGIN_DESTROY_FN, &mrDESTROY)) { if (mrDESTROY != NULL) { mrDESTROY (pb); } } /* matching rule indexers which handle Slapi_Value** directly will own the keys, free them, and set SLAPI_PLUGIN_MR_KEYS to NULL in the destroy function - the old style matching rule indexers which only deal with struct berval ** will not free the Slapi_Value** wrappers so we have to free them here */ slapi_pblock_get(pb, SLAPI_PLUGIN_MR_KEYS, &keys); if (keys) { valuearray_free(&keys); slapi_pblock_set(pb, SLAPI_PLUGIN_MR_KEYS, NULL); } return 0; }