Back to index

openldap  2.4.31
Functions | Variables
init.c File Reference
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include "slap.h"
#include "config.h"
#include "back-relay.h"

Go to the source code of this file.

Functions

static int relay_back_cf (ConfigArgs *c)
int relay_back_initialize (BackendInfo *bi)
int relay_back_db_init (Backend *be, ConfigReply *cr)
int relay_back_db_open (Backend *be, ConfigReply *cr)
int relay_back_db_close (Backend *be, ConfigReply *cr)
int relay_back_db_destroy (Backend *be, ConfigReply *cr)

Variables

static ConfigDriver relay_back_cf
static ConfigTable relaycfg []
static ConfigOCs relayocs []

Function Documentation

static int relay_back_cf ( ConfigArgs c) [static]

Definition at line 57 of file init.c.

{
       relay_back_info      *ri = ( relay_back_info * )c->be->be_private;
       int           rc = 0;

       if ( c->op == SLAP_CONFIG_EMIT ) {
              if ( ri != NULL && !BER_BVISNULL( &ri->ri_realsuffix ) ) {
                     value_add_one( &c->rvalue_vals, &ri->ri_realsuffix );
                     return 0;
              }
              return 1;

       } else if ( c->op == LDAP_MOD_DELETE ) {
              if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
                     ch_free( ri->ri_realsuffix.bv_val );
                     BER_BVZERO( &ri->ri_realsuffix );
                     ri->ri_bd = NULL;
                     return 0;
              }
              return 1;

       } else {
              BackendDB *bd;

              assert( ri != NULL );
              assert( BER_BVISNULL( &ri->ri_realsuffix ) );

              if ( c->be->be_nsuffix == NULL ) {
                     snprintf( c->cr_msg, sizeof( c->cr_msg),
                            "\"relay\" directive "
                            "must appear after \"suffix\"" );
                     Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
                            "%s: %s.\n", c->log, c->cr_msg );
                     rc = 1;
                     goto relay_done;
              }

              if ( !BER_BVISNULL( &c->be->be_nsuffix[ 1 ] ) ) {
                     snprintf( c->cr_msg, sizeof( c->cr_msg),
                            "relaying of multiple suffix "
                            "database not supported" );
                     Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
                            "%s: %s.\n", c->log, c->cr_msg );
                     rc = 1;
                     goto relay_done;
              }

              bd = select_backend( &c->value_ndn, 1 );
              if ( bd == NULL ) {
                     snprintf( c->cr_msg, sizeof( c->cr_msg),
                            "cannot find database "
                            "of relay dn \"%s\" "
                            "in \"olcRelay <dn>\"\n",
                            c->value_dn.bv_val );
                     Log2( LDAP_DEBUG_CONFIG, LDAP_LEVEL_ERR,
                            "%s: %s.\n", c->log, c->cr_msg );

              } else if ( bd->be_private == c->be->be_private ) {
                     snprintf( c->cr_msg, sizeof( c->cr_msg),
                            "relay dn \"%s\" would call self "
                            "in \"relay <dn>\" line\n",
                            c->value_dn.bv_val );
                     Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
                            "%s: %s.\n", c->log, c->cr_msg );
                     rc = 1;
                     goto relay_done;
              }

              ri->ri_realsuffix = c->value_ndn;
              BER_BVZERO( &c->value_ndn );

relay_done:;
              ch_free( c->value_dn.bv_val );
              ch_free( c->value_ndn.bv_val );
       }

       return rc;
}

Here is the call graph for this function:

int relay_back_db_close ( Backend be,
ConfigReply *  cr 
)

Definition at line 229 of file init.c.

{
       return 0;
}
int relay_back_db_destroy ( Backend be,
ConfigReply *  cr 
)

Definition at line 235 of file init.c.

{
       relay_back_info             *ri = (relay_back_info *)be->be_private;

       if ( ri ) {
              if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
                     ch_free( ri->ri_realsuffix.bv_val );
              }
              ch_free( ri );
       }

       return 0;
}

Here is the call graph for this function:

int relay_back_db_init ( Backend be,
ConfigReply *  cr 
)

Definition at line 172 of file init.c.

{
       relay_back_info             *ri;

       be->be_private = NULL;

       ri = (relay_back_info *) ch_calloc( 1, RELAY_INFO_SIZE );
       if ( ri == NULL ) {
              return -1;
       }

       ri->ri_bd = NULL;
       BER_BVZERO( &ri->ri_realsuffix );
       ri->ri_massage = 0;

       be->be_cf_ocs = be->bd_info->bi_cf_ocs;

       be->be_private = (void *)ri;

       return 0;
}

Here is the call graph for this function:

int relay_back_db_open ( Backend be,
ConfigReply *  cr 
)

Definition at line 195 of file init.c.

{
       relay_back_info             *ri = (relay_back_info *)be->be_private;

       assert( ri != NULL );

       if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
              ri->ri_bd = select_backend( &ri->ri_realsuffix, 1 );

              /* must be there: it was during config! */
              if ( ri->ri_bd == NULL ) {
                     snprintf( cr->msg, sizeof( cr->msg),
                            "cannot find database "
                            "of relay dn \"%s\" "
                            "in \"olcRelay <dn>\"\n",
                            ri->ri_realsuffix.bv_val );
                     Log1( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
                            "relay_back_db_open: %s.\n", cr->msg );

                     return 1;
              }

              /* inherit controls */
              AC_MEMCPY( be->bd_self->be_ctrls, ri->ri_bd->be_ctrls, sizeof( be->be_ctrls ) );

       } else {
              /* inherit all? */
              AC_MEMCPY( be->bd_self->be_ctrls, frontendDB->be_ctrls, sizeof( be->be_ctrls ) );
       }

       return 0;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 31 of file init.c.

ConfigTable relaycfg[] [static]
Initial value:
 {
       { "relay", "relay", 2, 2, 0,
              ARG_MAGIC|ARG_DN,
              relay_back_cf, "( OLcfgDbAt:5.1 "
                     "NAME 'olcRelay' "
                     "DESC 'Relay DN' "
                     "SYNTAX OMsDN "
                     "SINGLE-VALUE )",
              NULL, NULL },
       { NULL }
}

Definition at line 33 of file init.c.

ConfigOCs relayocs[] [static]
Initial value:
 {
       { "( OLcfgDbOc:5.1 "
              "NAME 'olcRelayConfig' "
              "DESC 'Relay backend configuration' "
              "SUP olcDatabaseConfig "
              "MAY ( olcRelay "
              ") )",
                     Cft_Database, relaycfg},
       { NULL, 0, NULL }
}

Definition at line 45 of file init.c.