In a plugin which needs to read its configuration before the directory server drops privileges, it would be very helpful to have the name and contents of the plugin's configuration entry provided for the initialization function. (In my case I need to bind to a privileged port, and I want to allow the administrator to specify a port so that I don't have to use bindresvport(), so that a hole can be punched in a firewall). Currently SLAPI_TARGET_DN isn't set, and attempts to locate the entry using slapi_search_internal_set_pb()/slapi_search_internal_callback_pb() cause the server to crash. (Rich suggested using nsslapd-pluginArg0, and I can work with that for now.)
In a plugin start function, the plugin receives the plugin config entry in the pblock parameter SLAPI_ADD_ENTRY e.g. from pam_passthru: static int pam_passthru_bindpreop_start( Slapi_PBlock *pb ) { int rc; Slapi_Entry *config_e = NULL; /* entry containing plugin config */ PAM_PASSTHRU_ASSERT( pb != NULL ); slapi_log_error( SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM, "=> pam_passthru_bindpreop_start\n" ); if ( slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &config_e ) != 0 ) { slapi_log_error( SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM, "missing config entry\n" ); return( -1 ); } /* process config using config_e */ We should do the same for plugin init, for those cases where the plugin must have access to its config during the init phase.
Upstream ticket: https://fedorahosted.org/389/ticket/120
fixed commit b6d3ba77683722ed8b88994a637ba64fa18e57a1 Author: Rich Megginson <rmeggins> Date: Wed Oct 5 16:53:30 2011 -0600 pass the plugin config entry to the plugin init function A plugin init function can get the plugin config entry (that is, its own config entry) by using the pblock parameter SLAPI_PLUGIN_CONFIG_ENTRY int my_plugin_init(Slapi_PBlock *pb) { Slapi_Entry *my_config_entry = NULL; slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &my_config_entry); Reviewed by: nkinder, nhosoi (Thanks!)