Some misc cleanup

This commit is contained in:
Kurt Zeilenga 2002-01-29 06:06:20 +00:00
parent d3c26b6772
commit 0a31400d63
6 changed files with 64 additions and 60 deletions

View file

@ -1004,16 +1004,17 @@ backend_group(
}
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
for (g = conn->c_groups; g; g=g->next) {
if (g->be != be || g->oc != group_oc || g->at != group_at ||
g->len != gr_ndn->bv_len)
for (g = conn->c_groups; g; g=g->ga_next) {
if (g->ga_be != be || g->ga_oc != group_oc ||
g->ga_at != group_at || g->ga_len != gr_ndn->bv_len)
continue;
if (strcmp( g->ndn, gr_ndn->bv_val ) == 0)
if (strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0)
break;
}
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
if (g)
return g->res;
if (g) {
return g->ga_res;
}
if( be->be_group ) {
int res = be->be_group( be, conn, op,
@ -1022,14 +1023,14 @@ backend_group(
if (op->o_tag != LDAP_REQ_BIND) {
g = ch_malloc(sizeof(GroupAssertion) + gr_ndn->bv_len);
g->be = be;
g->oc = group_oc;
g->at = group_at;
g->res = res;
g->len = gr_ndn->bv_len;
strcpy(g->ndn, gr_ndn->bv_val);
g->ga_be = be;
g->ga_oc = group_oc;
g->ga_at = group_at;
g->ga_res = res;
g->ga_len = gr_ndn->bv_len;
strcpy(g->ga_ndn, gr_ndn->bv_val);
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
g->next = conn->c_groups;
g->ga_next = conn->c_groups;
conn->c_groups = g;
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
}

View file

@ -612,7 +612,7 @@ void connection2anonymous( Connection *c )
GroupAssertion *g, *n;
for (g = c->c_groups; g; g=n)
{
n = g->next;
n = g->ga_next;
free(g);
}
c->c_groups = NULL;

View file

@ -938,7 +938,8 @@ LDAP_SLAPD_F (int) syn_schema_info( Entry *e );
* user.c
*/
#if defined(HAVE_PWD_H) && defined(HAVE_GRP_H)
LDAP_SLAPD_F (void) slap_init_user LDAP_P(( char *username, char *groupname ));
LDAP_SLAPD_F (void) slap_init_user LDAP_P((
const char *username, const char *groupname ));
#endif
/*

View file

@ -150,7 +150,7 @@ int slap_sasl_regexp_config( const char *match, const char *replace )
#endif
return( rc );
}
reg->match = nbv.bv_val;
reg->sr_match = nbv.bv_val;
ber_str2bv( replace, 0, 0, &bv );
rc = dnNormalize2( NULL, &bv, &nbv );
@ -166,28 +166,28 @@ int slap_sasl_regexp_config( const char *match, const char *replace )
#endif
return( rc );
}
reg->replace = nbv.bv_val;
reg->sr_replace = nbv.bv_val;
/* Precompile matching pattern */
rc = regcomp( &reg->workspace, reg->match, REG_EXTENDED|REG_ICASE );
rc = regcomp( &reg->sr_workspace, reg->sr_match, REG_EXTENDED|REG_ICASE );
if ( rc ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "sasl", LDAP_LEVEL_ERR,
"slap_sasl_regexp_config: \"%s\" could not be compiled.\n",
reg->match ));
reg->sr_match ));
#else
Debug( LDAP_DEBUG_ANY,
"SASL match pattern %s could not be compiled by regexp engine\n",
reg->match, 0, 0 );
reg->sr_match, 0, 0 );
#endif
return( LDAP_OPERATIONS_ERROR );
}
/* Precompile replace pattern. Find the $<n> placeholders */
reg->offset[0] = -2;
reg->sr_offset[0] = -2;
n = 1;
for ( c = reg->replace; *c; c++ ) {
for ( c = reg->sr_replace; *c; c++ ) {
if ( *c == '\\' ) {
c++;
continue;
@ -196,25 +196,27 @@ int slap_sasl_regexp_config( const char *match, const char *replace )
if ( n == SASLREGEX_REPLACE ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "sasl", LDAP_LEVEL_ERR,
"slap_sasl_regexp_config: \"%s\" has too many $n placeholders (max %d)\n",
reg->replace, SASLREGEX_REPLACE ));
"slap_sasl_regexp_config: \"%s\" has too many $n "
"placeholders (max %d)\n",
reg->sr_replace, SASLREGEX_REPLACE ));
#else
Debug( LDAP_DEBUG_ANY,
"SASL replace pattern %s has too many $n placeholders (max %d)\n",
reg->replace, SASLREGEX_REPLACE, 0 );
"SASL replace pattern %s has too many $n "
"placeholders (max %d)\n",
reg->sr_replace, SASLREGEX_REPLACE, 0 );
#endif
return( LDAP_OPERATIONS_ERROR );
}
reg->offset[n] = c - reg->replace;
reg->sr_offset[n] = c - reg->sr_replace;
n++;
}
}
/* Final placeholder, after the last $n */
reg->offset[n] = c - reg->replace;
reg->sr_offset[n] = c - reg->sr_replace;
n++;
reg->offset[n] = -1;
reg->sr_offset[n] = -1;
nSaslRegexp++;
#endif
@ -247,8 +249,8 @@ char *slap_sasl_regexp( char *saslname )
/* Match the normalized SASL name to the saslregexp patterns */
for( reg = SaslRegexp,i=0; i<nSaslRegexp; i++,reg++ ) {
if ( regexec( &reg->workspace, saslname, SASLREGEX_REPLACE,
reg->strings, 0) == 0 )
if ( regexec( &reg->sr_workspace, saslname, SASLREGEX_REPLACE,
reg->sr_strings, 0) == 0 )
break;
}
@ -266,15 +268,15 @@ char *slap_sasl_regexp( char *saslname )
n=1;
len = 0;
while( reg->offset[n] >= 0 ) {
while( reg->sr_offset[n] >= 0 ) {
/* Len of next section from replacement string (x,y,z above) */
len += reg->offset[n] - reg->offset[n-1] - 2;
if( reg->offset[n+1] < 0)
len += reg->sr_offset[n] - reg->sr_offset[n-1] - 2;
if( reg->sr_offset[n+1] < 0)
break;
/* Len of string from saslname that matched next $i (b,d above) */
i = reg->replace[ reg->offset[n] + 1 ] - '0';
len += reg->strings[i].rm_eo - reg->strings[i].rm_so;
i = reg->sr_replace[ reg->sr_offset[n] + 1 ] - '0';
len += reg->sr_strings[i].rm_eo - reg->sr_strings[i].rm_so;
n++;
}
uri = ch_malloc( len + 1 );
@ -282,18 +284,18 @@ char *slap_sasl_regexp( char *saslname )
/* Fill in URI with replace string, replacing $i as we go */
n=1;
insert = 0;
while( reg->offset[n] >= 0) {
while( reg->sr_offset[n] >= 0) {
/* Paste in next section from replacement string (x,y,z above) */
len = reg->offset[n] - reg->offset[n-1] - 2;
strncpy( uri+insert, reg->replace + reg->offset[n-1] + 2, len);
len = reg->sr_offset[n] - reg->sr_offset[n-1] - 2;
strncpy( uri+insert, reg->sr_replace + reg->sr_offset[n-1] + 2, len);
insert += len;
if( reg->offset[n+1] < 0)
if( reg->sr_offset[n+1] < 0)
break;
/* Paste in string from saslname that matched next $i (b,d above) */
i = reg->replace[ reg->offset[n] + 1 ] - '0';
len = reg->strings[i].rm_eo - reg->strings[i].rm_so;
strncpy( uri+insert, saslname + reg->strings[i].rm_so, len );
i = reg->sr_replace[ reg->sr_offset[n] + 1 ] - '0';
len = reg->sr_strings[i].rm_eo - reg->sr_strings[i].rm_so;
strncpy( uri+insert, saslname + reg->sr_strings[i].rm_so, len );
insert += len;
n++;

View file

@ -698,7 +698,7 @@ typedef struct slap_filter {
#define f_sub_final f_un.f_un_ssa->sa_final
#define f_mra f_un.f_un_mra
#define f_mr_rule f_un.f_un_mra->ma_rule
#define f_mr_rule_text f_un.f_un_mra->ma_rule_text
#define f_mr_rule_text f_un.f_un_mra->ma_rule_text
#define f_mr_desc f_un.f_un_mra->ma_desc
#define f_mr_value f_un.f_un_mra->ma_value
#define f_mr_dnattrs f_un.f_un_mra->ma_dnattrs
@ -1411,7 +1411,7 @@ typedef struct slap_op {
char o_subentries_visibility;
char o_noop;
int o_abandon; /* abandon flag */
char o_abandon; /* abandon flag */
ldap_pvt_thread_mutex_t o_abandonmutex; /* protects o_abandon */
#ifdef LDAP_CONNECTIONLESS
@ -1436,13 +1436,13 @@ typedef struct slap_op {
* Caches the result of a backend_group check for ACL evaluation
*/
typedef struct slap_gacl {
struct slap_gacl *next;
Backend *be;
ObjectClass *oc;
AttributeDescription *at;
int res;
ber_len_t len;
char ndn[1];
struct slap_gacl *ga_next;
Backend *ga_be;
ObjectClass *ga_oc;
AttributeDescription *ga_at;
int ga_res;
ber_len_t ga_len;
char ga_ndn[1];
} GroupAssertion;
/*
@ -1501,9 +1501,9 @@ typedef struct slap_conn {
void *c_sasl_context; /* SASL session context */
void *c_sasl_extra; /* SASL session extra stuff */
long c_n_ops_received; /* num of ops received (next op_id) */
long c_n_ops_received; /* num of ops received (next op_id) */
long c_n_ops_executing; /* num of ops currently executing */
long c_n_ops_pending; /* num of ops pending execution */
long c_n_ops_pending; /* num of ops pending execution */
long c_n_ops_completed; /* num of ops completed */
long c_n_get; /* num of get calls */
@ -1530,11 +1530,11 @@ typedef struct slap_conn {
#define SASL_AUTHZ_DEST_ATTR "saslAuthzFrom"
typedef struct sasl_regexp {
char *match; /* regexp match pattern */
char *replace; /* regexp replace pattern */
regex_t workspace; /* workspace for regexp engine */
regmatch_t strings[SASLREGEX_REPLACE]; /* strings matching $1,$2 ... */
int offset[SASLREGEX_REPLACE+2]; /* offsets of $1,$2... in *replace */
char *sr_match; /* regexp match pattern */
char *sr_replace; /* regexp replace pattern */
regex_t sr_workspace; /* workspace for regexp engine */
regmatch_t sr_strings[SASLREGEX_REPLACE]; /* strings matching $1,$2 ... */
int sr_offset[SASLREGEX_REPLACE+2]; /* offsets of $1,$2... in *replace */
} SaslRegexp_t;
/*

View file

@ -41,7 +41,7 @@
*/
void
slap_init_user( char *user, char *group )
slap_init_user( const char *user, const char *group )
{
uid_t uid = 0;
gid_t gid = 0;