fix compilation when the chaining control is undefined

This commit is contained in:
Pierangelo Masarati 2005-11-20 19:28:03 +00:00
parent 55349537ad
commit 4c92090e87

View File

@ -498,9 +498,9 @@ ldap_chain_response( Operation *op, SlapReply *rs )
BerVarray ref; BerVarray ref;
struct berval ndn = op->o_ndn; struct berval ndn = op->o_ndn;
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
int sr_err = rs->sr_err; int sr_err = rs->sr_err;
slap_reply_t sr_type = rs->sr_type; slap_reply_t sr_type = rs->sr_type;
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
slap_mask_t chain_mask = 0; slap_mask_t chain_mask = 0;
ber_len_t chain_shift = 0; ber_len_t chain_shift = 0;
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */ #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
@ -813,9 +813,7 @@ cannot_chain:;
send_ldap_result( op, rs ); send_ldap_result( op, rs );
} }
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
dont_chain:; dont_chain:;
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
rs->sr_err = sr_err; rs->sr_err = sr_err;
rs->sr_type = sr_type; rs->sr_type = sr_type;
rs->sr_matched = matched; rs->sr_matched = matched;
@ -865,9 +863,7 @@ enum {
CH_LAST CH_LAST
}; };
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
static ConfigDriver chain_cf_gen; static ConfigDriver chain_cf_gen;
#endif
static ConfigCfAdd chain_cfadd; static ConfigCfAdd chain_cfadd;
static ConfigLDAPadd chain_ldadd; static ConfigLDAPadd chain_ldadd;
@ -888,16 +884,17 @@ static ConfigTable chaincfg[] = {
}; };
static ConfigOCs chainocs[] = { static ConfigOCs chainocs[] = {
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
{ "( OLcfgOvOc:3.1 " { "( OLcfgOvOc:3.1 "
"NAME 'olcChainConfig' " "NAME 'olcChainConfig' "
"DESC 'Chain configuration' " "DESC 'Chain configuration' "
"SUP olcOverlayConfig " "SUP olcOverlayConfig "
"MAY ( olcChainingBehavior " "MAY ( "
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
"olcChainingBehavior "
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
"$ olcCacheURIs " "$ olcCacheURIs "
") )", ") )",
Cft_Overlay, chaincfg, NULL, chain_cfadd }, Cft_Overlay, chaincfg, NULL, chain_cfadd },
#endif
{ "( OLcfgOvOc:3.2 " { "( OLcfgOvOc:3.2 "
"NAME 'olcChainDatabase' " "NAME 'olcChainDatabase' "
"DESC 'Chain remote server configuration' " "DESC 'Chain remote server configuration' "
@ -1058,7 +1055,6 @@ chain_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *ca )
} }
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
static slap_verbmasks chaining_mode[] = { static slap_verbmasks chaining_mode[] = {
{ BER_BVC("referralsRequired"), LDAP_REFERRALS_REQUIRED }, { BER_BVC("referralsRequired"), LDAP_REFERRALS_REQUIRED },
{ BER_BVC("referralsPreferred"), LDAP_REFERRALS_PREFERRED }, { BER_BVC("referralsPreferred"), LDAP_REFERRALS_PREFERRED },
@ -1066,6 +1062,7 @@ static slap_verbmasks chaining_mode[] = {
{ BER_BVC("chainingPreferred"), LDAP_CHAINING_PREFERRED }, { BER_BVC("chainingPreferred"), LDAP_CHAINING_PREFERRED },
{ BER_BVNULL, 0 } { BER_BVNULL, 0 }
}; };
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
static int static int
chain_cf_gen( ConfigArgs *c ) chain_cf_gen( ConfigArgs *c )
@ -1135,8 +1132,8 @@ chain_cf_gen( ConfigArgs *c )
} }
switch( c->type ) { switch( c->type ) {
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
case CH_CHAINING: { case CH_CHAINING: {
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
char **argv = c->argv; char **argv = c->argv;
int argc = c->argc; int argc = c->argc;
BerElementBuffer berbuf; BerElementBuffer berbuf;
@ -1153,20 +1150,20 @@ chain_cf_gen( ConfigArgs *c )
if ( strncasecmp( argv[ 0 ], "resolve=", STRLENOF( "resolve=" ) ) == 0 ) { if ( strncasecmp( argv[ 0 ], "resolve=", STRLENOF( "resolve=" ) ) == 0 ) {
resolve = str2chain( argv[ 0 ] + STRLENOF( "resolve=" ) ); resolve = str2chain( argv[ 0 ] + STRLENOF( "resolve=" ) );
if ( resolve == -1 ) { if ( resolve == -1 ) {
fprintf( stderr, "%s line %d: " Debug( LDAP_DEBUG_ANY, "%s: "
"illegal <resolve> value %s " "illegal <resolve> value %s "
"in \"chain-chaining>\"\n", "in \"chain-chaining>\".\n",
c->fname, c->lineno, argv[ 0 ] ); c->log, argv[ 0 ], 0 );
return 1; return 1;
} }
} else if ( strncasecmp( argv[ 0 ], "continuation=", STRLENOF( "continuation=" ) ) == 0 ) { } else if ( strncasecmp( argv[ 0 ], "continuation=", STRLENOF( "continuation=" ) ) == 0 ) {
continuation = str2chain( argv[ 0 ] + STRLENOF( "continuation=" ) ); continuation = str2chain( argv[ 0 ] + STRLENOF( "continuation=" ) );
if ( continuation == -1 ) { if ( continuation == -1 ) {
fprintf( stderr, "%s line %d: " Debug( LDAP_DEBUG_ANY, "%s: "
"illegal <continuation> value %s " "illegal <continuation> value %s "
"in \"chain-chaining\"\n", "in \"chain-chaining\".\n",
c->fname, c->lineno, argv[ 0 ] ); c->log, argv[ 0 ], 0 );
return 1; return 1;
} }
@ -1174,9 +1171,9 @@ chain_cf_gen( ConfigArgs *c )
iscritical = 1; iscritical = 1;
} else { } else {
fprintf( stderr, "%s line %d: " Debug( LDAP_DEBUG_ANY, "%s: "
"unknown option in \"chain-chaining\"\n", "unknown option in \"chain-chaining\".\n",
c->fname, c->lineno ); c->log, 0, 0 );
return 1; return 1;
} }
} }
@ -1194,9 +1191,9 @@ chain_cf_gen( ConfigArgs *c )
err = ber_printf( ber, "{e" /* } */, resolve ); err = ber_printf( ber, "{e" /* } */, resolve );
if ( err == -1 ) { if ( err == -1 ) {
ber_free( ber, 1 ); ber_free( ber, 1 );
fprintf( stderr, "%s line %d: " Debug( LDAP_DEBUG_ANY, "%s: "
"chaining behavior control encoding error!\n", "chaining behavior control encoding error!\n",
c->fname, c->lineno ); c->log, 0, 0 );
return 1; return 1;
} }
@ -1204,9 +1201,9 @@ chain_cf_gen( ConfigArgs *c )
err = ber_printf( ber, "e", continuation ); err = ber_printf( ber, "e", continuation );
if ( err == -1 ) { if ( err == -1 ) {
ber_free( ber, 1 ); ber_free( ber, 1 );
fprintf( stderr, "%s line %d: " Debug( LDAP_DEBUG_ANY, "%s: "
"chaining behavior control encoding error!\n", "chaining behavior control encoding error!\n",
c->fname, c->lineno ); c->log, 0, 0 );
return 1; return 1;
} }
} }
@ -1214,9 +1211,9 @@ chain_cf_gen( ConfigArgs *c )
err = ber_printf( ber, /* { */ "N}" ); err = ber_printf( ber, /* { */ "N}" );
if ( err == -1 ) { if ( err == -1 ) {
ber_free( ber, 1 ); ber_free( ber, 1 );
fprintf( stderr, "%s line %d: " Debug( LDAP_DEBUG_ANY, "%s: "
"chaining behavior control encoding error!\n", "chaining behavior control encoding error!\n",
c->fname, c->lineno ); c->log, 0, 0 );
return 1; return 1;
} }
@ -1233,10 +1230,9 @@ chain_cf_gen( ConfigArgs *c )
if ( ldap_chain_parse_ctrl( &op, &rs, &lc->lc_chaining_ctrl ) != LDAP_SUCCESS ) if ( ldap_chain_parse_ctrl( &op, &rs, &lc->lc_chaining_ctrl ) != LDAP_SUCCESS )
{ {
fprintf( stderr, "%s line %d: " Debug( LDAP_DEBUG_ANY, "%s: "
"unable to parse chaining control%s%s\n", "unable to parse chaining control%s%s.\n",
c->fname, c->lineno, c->log, rs.sr_text ? ": " : "",
rs.sr_text ? ": " : "",
rs.sr_text ? rs.sr_text : "" ); rs.sr_text ? rs.sr_text : "" );
return 1; return 1;
} }
@ -1246,10 +1242,12 @@ chain_cf_gen( ConfigArgs *c )
lc->lc_flags |= LDAP_CHAIN_F_CHAINING; lc->lc_flags |= LDAP_CHAIN_F_CHAINING;
rc = 0; rc = 0;
#else /* ! LDAP_CONTROL_X_CHAINING_BEHAVIOR */
break; Debug( LDAP_DEBUG_ANY, "%s: "
} "\"chaining\" control unsupported (ignored).\n",
c->log, 0, 0 );
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */ #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
} break;
case CH_CACHE_URI: case CH_CACHE_URI:
if ( c->value_int ) { if ( c->value_int ) {
@ -1266,8 +1264,6 @@ chain_cf_gen( ConfigArgs *c )
return rc; return rc;
} }
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
static int static int
ldap_chain_db_init( ldap_chain_db_init(
BackendDB *be ) BackendDB *be )
@ -1324,13 +1320,11 @@ ldap_chain_db_config(
argv[ 0 ] += STRLENOF( "chain-" ); argv[ 0 ] += STRLENOF( "chain-" );
/* TODO: create a new structure and, after parsing the URI,
* put it in the lc->lc_lai tree */
if ( strcasecmp( argv[ 0 ], "uri" ) == 0 ) { if ( strcasecmp( argv[ 0 ], "uri" ) == 0 ) {
rc = ldap_chain_db_init_one( be ); rc = ldap_chain_db_init_one( be );
if ( rc != 0 ) { if ( rc != 0 ) {
Debug( LDAP_DEBUG_ANY, "%s: line %d: " Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"underlying slapd-ldap initialization failed\n.", "underlying slapd-ldap initialization failed.\n.",
fname, lineno, 0 ); fname, lineno, 0 );
return 1; return 1;
} }
@ -1338,6 +1332,13 @@ ldap_chain_db_config(
is_uri = 1; is_uri = 1;
} }
/* TODO: add checks on what other slapd-ldap(5) args
* should be put in the template; this is not quite
* harmful, because attributes that shouldn't don't
* get actually used, but the user should at least
* be warned.
*/
be->bd_info = lback; be->bd_info = lback;
be->be_private = (void *)lc->lc_cfg_li; be->be_private = (void *)lc->lc_cfg_li;
be->be_cf_ocs = lback->bi_cf_ocs; be->be_cf_ocs = lback->bi_cf_ocs;
@ -1467,9 +1468,6 @@ ldap_chain_db_open(
} }
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */ #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
/* FIXME: right now slapd-ldap has no open function;
* in case one is introduced, this needs be fixed */
return ldap_chain_db_func( be, db_open ); return ldap_chain_db_func( be, db_open );
} }
@ -1499,19 +1497,17 @@ ldap_chain_db_destroy(
return rc; return rc;
} }
/*
* inits one instance of the slapd-ldap backend, and stores
* the private info in be_private of the arg
*/
static int static int
ldap_chain_db_init_common( ldap_chain_db_init_common(
BackendDB *be ) BackendDB *be )
{ {
slap_overinst *on = (slap_overinst *)be->bd_info;
ldap_chain_t *lc = (ldap_chain_t *)on->on_bi.bi_private;
BackendInfo *bi = be->bd_info; BackendInfo *bi = be->bd_info;
int t; int t;
assert( lc->lc_common_li == NULL );
be->bd_info = lback; be->bd_info = lback;
be->be_private = NULL; be->be_private = NULL;
t = lback->bi_db_init( be ); t = lback->bi_db_init( be );
@ -1523,6 +1519,14 @@ ldap_chain_db_init_common(
return 0; return 0;
} }
/*
* inits one instance of the slapd-ldap backend, stores
* the private info in be_private of the arg and fills
* selected fields with data from the template.
*
* NOTE: add checks about the other fields of the template,
* which are ignored and SHOULD NOT be configured by the user.
*/
static int static int
ldap_chain_db_init_one( ldap_chain_db_init_one(
BackendDB *be ) BackendDB *be )
@ -1739,7 +1743,7 @@ chain_init( void )
ldap_chain_parse_ctrl, &sc_chainingBehavior ); ldap_chain_parse_ctrl, &sc_chainingBehavior );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "slapd-chain: " Debug( LDAP_DEBUG_ANY, "slapd-chain: "
"unable to register chaining behavior control: %d\n", "unable to register chaining behavior control: %d.\n",
rc, 0, 0 ); rc, 0, 0 );
return rc; return rc;
} }