rework few members of slap_bindconf; silence few warnings

This commit is contained in:
Pierangelo Masarati 2005-04-02 01:33:48 +00:00
parent a736b1041e
commit f1e2d35bd6
3 changed files with 97 additions and 72 deletions

View file

@ -119,10 +119,9 @@ ConfigTable *config_find_keyword(ConfigTable *Conf, ConfigArgs *c) {
}
int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
int i, rc, arg_user, arg_type, iarg;
int rc, arg_user, arg_type, iarg;
long larg;
ber_len_t barg;
void *ptr;
arg_type = Conf->arg_type;
if(arg_type == ARG_IGNORED) {
@ -233,7 +232,7 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
}
int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
int i, rc, arg_type;
int rc, arg_type;
void *ptr;
arg_type = Conf->arg_type;
@ -291,7 +290,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
}
int config_add_vals(ConfigTable *Conf, ConfigArgs *c) {
int i, rc, arg_type, iarg;
int rc, arg_type;
arg_type = Conf->arg_type;
if(arg_type == ARG_IGNORED) {
@ -308,6 +307,8 @@ int
config_del_vals(ConfigTable *cf, ConfigArgs *c)
{
int rc = 0;
return rc;
}
int
@ -690,8 +691,7 @@ verbs_to_mask(int argc, char *argv[], slap_verbmasks *v, slap_mask_t *m) {
int
mask_to_verbs(slap_verbmasks *v, slap_mask_t m, BerVarray *bva) {
int i, j;
struct berval bv;
int i;
if (!m) return 1;
for (i=0; !BER_BVISNULL(&v[i].word); i++) {
@ -721,79 +721,111 @@ static slap_verbmasks methkey[] = {
typedef struct cf_aux_table {
struct berval key;
int off;
int quote;
char type;
char quote;
slap_verbmasks *aux;
} cf_aux_table;
static cf_aux_table bindkey[] = {
{ BER_BVC("starttls="), offsetof(slap_bindconf, sb_tls), 0, tlskey },
{ BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 0, methkey },
{ BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 1, NULL },
{ BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 1, NULL },
{ BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 0, NULL },
{ BER_BVC("secprops="), offsetof(slap_bindconf, sb_secprops), 0, NULL },
{ BER_BVC("realm="), offsetof(slap_bindconf, sb_realm), 0, NULL },
{ BER_BVC("authcID="), offsetof(slap_bindconf, sb_authcId), 0, NULL },
{ BER_BVC("authzID="), offsetof(slap_bindconf, sb_authzId), 1, NULL },
{ BER_BVNULL, 0, 0, NULL }
{ BER_BVC("starttls="), offsetof(slap_bindconf, sb_tls), 'd', 0, tlskey },
{ BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 'd', 0, methkey },
{ BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 'b', 1, NULL },
{ BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 'b', 1, NULL },
{ BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 's', 0, NULL },
{ BER_BVC("secprops="), offsetof(slap_bindconf, sb_secprops), 's', 0, NULL },
{ BER_BVC("realm="), offsetof(slap_bindconf, sb_realm), 's', 0, NULL },
{ BER_BVC("authcID="), offsetof(slap_bindconf, sb_authcId), 's', 0, NULL },
{ BER_BVC("authzID="), offsetof(slap_bindconf, sb_authzId), 'b', 1, NULL },
{ BER_BVNULL, 0, 0, 0, NULL }
};
int bindconf_parse( const char *word, slap_bindconf *bc ) {
int i, rc = 0;
char **cptr;
int rc = 0;
cf_aux_table *tab;
for (tab = bindkey; !BER_BVISNULL(&tab->key); tab++) {
if ( !strncasecmp( word, tab->key.bv_val, tab->key.bv_len )) {
cptr = (char **)((char *)bc + tab->off);
if ( tab->aux ) {
int j;
char **cptr;
int *iptr, j;
struct berval *bptr;
const char *val = word + tab->key.bv_len;
switch ( tab->type ) {
case 's':
cptr = (char **)((char *)bc + tab->off);
*cptr = ch_strdup( val );
break;
case 'b':
bptr = (struct berval *)((char *)bc + tab->off);
ber_str2bv( val, 0, 1, bptr );
break;
case 'i':
assert( tab->aux );
iptr = (int *)((char *)bc + tab->off);
rc = 1;
for (j=0; !BER_BVISNULL(&tab->aux[j].word); j++) {
if (!strcasecmp(word+tab->key.bv_len, tab->aux[j].word.bv_val)) {
int *ptr = (int *)cptr;
*ptr = tab->aux[j].mask;
for ( j = 0; !BER_BVISNULL( &tab->aux[j].word ); j++ ) {
if ( !strcasecmp( val, tab->aux[j].word.bv_val ) ) {
*iptr = tab->aux[j].mask;
rc = 0;
}
}
if (rc ) {
Debug(LDAP_DEBUG_ANY, "invalid bind config value %s\n",
word, 0, 0 );
}
return rc;
break;
}
*cptr = ch_strdup(word+tab->key.bv_len);
return 0;
if ( rc ) {
Debug( LDAP_DEBUG_ANY, "invalid bind config value %s\n",
word, 0, 0 );
}
return rc;
}
}
return rc;
}
int bindconf_unparse( slap_bindconf *bc, struct berval *bv ) {
char buf[BUFSIZ], *ptr;
cf_aux_table *tab;
char **cptr;
struct berval tmp;
ptr = buf;
for (tab = bindkey; !BER_BVISNULL(&tab->key); tab++) {
char **cptr;
int *iptr, i;
struct berval *bptr;
cptr = (char **)((char *)bc + tab->off);
if ( tab->aux ) {
int *ip = (int *)cptr, i;
for ( i=0; !BER_BVISNULL(&tab->aux[i].word); i++ ) {
if ( *ip == tab->aux[i].mask ) {
switch ( tab->type ) {
case 'b':
bptr = (struct berval *)((char *)bc + tab->off);
cptr = &bptr->bv_val;
case 's':
if ( *cptr ) {
*ptr++ = ' ';
ptr = lutil_strcopy( ptr, tab->key.bv_val );
if ( tab->quote ) *ptr++ = '"';
ptr = lutil_strcopy( ptr, *cptr );
if ( tab->quote ) *ptr++ = '"';
}
break;
case 'i':
assert( tab->aux );
for ( i = 0; !BER_BVISNULL( &tab->aux[i].word ); i++ ) {
if ( *iptr == tab->aux[i].mask ) {
*ptr++ = ' ';
ptr = lutil_strcopy( ptr, tab->key.bv_val );
ptr = lutil_strcopy( ptr, tab->aux[i].word.bv_val );
break;
}
}
} else if ( *cptr ) {
*ptr++ = ' ';
ptr = lutil_strcopy( ptr, tab->key.bv_val );
if ( tab->quote ) *ptr++ = '"';
ptr = lutil_strcopy( ptr, *cptr );
if ( tab->quote ) *ptr++ = '"';
break;
}
}
tmp.bv_val = buf;
@ -803,11 +835,11 @@ int bindconf_unparse( slap_bindconf *bc, struct berval *bv ) {
}
void bindconf_free( slap_bindconf *bc ) {
if ( bc->sb_binddn ) {
ch_free( bc->sb_binddn );
if ( !BER_BVISNULL( &bc->sb_binddn ) ) {
ch_free( bc->sb_binddn.bv_val );
}
if ( bc->sb_cred ) {
ch_free( bc->sb_cred );
if ( !BER_BVISNULL( &bc->sb_cred ) ) {
ch_free( bc->sb_cred.bv_val );
}
if ( bc->sb_saslmech ) {
ch_free( bc->sb_saslmech );
@ -821,8 +853,8 @@ void bindconf_free( slap_bindconf *bc ) {
if ( bc->sb_authcId ) {
ch_free( bc->sb_authcId );
}
if ( bc->sb_authzId ) {
ch_free( bc->sb_authzId );
if ( !BER_BVISNULL( &bc->sb_authzId ) ) {
ch_free( bc->sb_authzId.bv_val );
}
}

View file

@ -1419,13 +1419,13 @@ LDAP_SLAPD_V (int) slapMode;
typedef struct slap_bindconf {
int sb_tls;
int sb_method;
char *sb_binddn;
char *sb_cred;
struct berval sb_binddn;
struct berval sb_cred;
char *sb_saslmech;
char *sb_secprops;
char *sb_realm;
char *sb_authcId;
char *sb_authzId;
struct berval sb_authzId;
} slap_bindconf;
struct slap_replica_info {

View file

@ -244,9 +244,9 @@ ldap_sync_search(
c[0].ldctl_iscritical = si->si_type < 0;
ctrls[0] = &c[0];
if ( si->si_bindconf.sb_authzId ) {
if ( !BER_BVISNULL( &si->si_bindconf.sb_authzId ) ) {
c[1].ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
ber_str2bv( si->si_bindconf.sb_authzId, 0, 0, &c[1].ldctl_value );
c[1].ldctl_value = si->si_bindconf.sb_authzId;
c[1].ldctl_iscritical = 1;
ctrls[1] = &c[1];
ctrls[2] = NULL;
@ -324,10 +324,10 @@ do_syncrep1(
defaults = lutil_sasl_defaults( si->si_ld, si->si_bindconf.sb_saslmech,
si->si_bindconf.sb_realm, si->si_bindconf.sb_authcId,
si->si_bindconf.sb_cred, si->si_bindconf.sb_authzId );
si->si_bindconf.sb_cred.bv_val, si->si_bindconf.sb_authzId.bv_val );
rc = ldap_sasl_interactive_bind_s( si->si_ld,
si->si_bindconf.sb_binddn,
si->si_bindconf.sb_binddn.bv_val,
si->si_bindconf.sb_saslmech,
NULL, NULL,
LDAP_SASL_QUIET,
@ -363,12 +363,13 @@ do_syncrep1(
goto done;
#endif
} else {
rc = ldap_bind_s( si->si_ld, si->si_bindconf.sb_binddn,
si->si_bindconf.sb_cred, si->si_bindconf.sb_method );
} else if ( si->si_bindconf.sb_method == LDAP_AUTH_SIMPLE ) {
rc = ldap_sasl_bind_s( si->si_ld,
si->si_bindconf.sb_binddn.bv_val, LDAP_SASL_SIMPLE,
&si->si_bindconf.sb_cred, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "do_syncrep1: "
"ldap_bind_s failed (%d)\n", rc, 0, 0 );
"ldap_sasl_bind_s failed (%d)\n", rc, 0, 0 );
goto done;
}
}
@ -392,7 +393,6 @@ do_syncrep1(
if ( BER_BVISNULL( &si->si_syncCookie.octet_str )) {
/* get contextCSN shadow replica from database */
BerVarray csn = NULL;
struct berval newcookie;
assert( si->si_rid < 1000 );
op->o_req_ndn = op->o_bd->be_nsuffix[0];
@ -445,7 +445,7 @@ do_syncrep1(
done:
if ( rc ) {
if ( si->si_ld ) {
ldap_unbind( si->si_ld );
ldap_unbind_ext( si->si_ld, NULL, NULL );
si->si_ld = NULL;
}
}
@ -815,7 +815,7 @@ done:
if ( res ) ldap_msgfree( res );
if ( rc && si->si_ld ) {
ldap_unbind( si->si_ld );
ldap_unbind_ext( si->si_ld, NULL, NULL );
si->si_ld = NULL;
}
@ -859,7 +859,7 @@ do_syncrepl(
if ( si->si_ld ) {
ldap_get_option( si->si_ld, LDAP_OPT_DESC, &s );
connection_client_stop( s );
ldap_unbind( si->si_ld );
ldap_unbind_ext( si->si_ld, NULL, NULL );
si->si_ld = NULL;
}
ldap_pvt_thread_mutex_unlock( &si->si_mutex );
@ -1533,8 +1533,6 @@ syncrepl_del_nonpresent(
AttributeName an[2];
struct berval pdn = BER_BVNULL;
struct berval org_req_dn = BER_BVNULL;
struct berval org_req_ndn = BER_BVNULL;
op->o_req_dn = si->si_base;
op->o_req_ndn = si->si_base;
@ -1803,10 +1801,6 @@ syncrepl_updateCookie(
Modifications mod = {0};
struct berval vals[2];
const char *text;
char txtbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof txtbuf;
int rc;
slap_callback cb = { NULL };
@ -1847,7 +1841,6 @@ syncrepl_updateCookie(
"be_modify failed (%d)\n", rs_modify.sr_err, 0, 0 );
}
done :
slap_graduate_commit_csn( op );
return;