Bug 450742 - server should pass in config entry to plugin init function
Summary: server should pass in config entry to plugin init function
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: 389
Classification: Retired
Component: Server - Plugins
Version: 1.1.1
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Rich Megginson
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks: 389_1.2.10
TreeView+ depends on / blocked
 
Reported: 2008-06-10 19:11 UTC by Nalin Dahyabhai
Modified: 2015-12-10 18:37 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-12-10 18:37:34 UTC
Embargoed:


Attachments (Terms of Use)

Description Nalin Dahyabhai 2008-06-10 19:11:38 UTC
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.)

Comment 1 Rich Megginson 2008-06-10 20:23:06 UTC
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.

Comment 4 Martin Kosek 2012-01-04 13:44:39 UTC
Upstream ticket:
https://fedorahosted.org/389/ticket/120

Comment 5 Rich Megginson 2012-01-06 16:54:50 UTC
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!)


Note You need to log in before you can comment on or make changes to this bug.