[Fedora-directory-commits] ldapserver/ldap/servers/slapd entry.c, 1.14, 1.14.2.1 filterentry.c, 1.6.2.1, 1.6.2.2 getfilelist.c, 1.7, 1.7.2.1 plugin_syntax.c, 1.5, 1.5.2.1 proto-slap.h, 1.31, 1.31.2.1 regex.c, 1.5.2.1, 1.5.2.2 sasl_map.c, 1.8, 1.8.2.1 slapi-private.h, 1.20, 1.20.2.1 vattr.c, 1.8, 1.8.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8956/servers/slapd
Modified Files:
Tag: Directory_Server_8_0_Branch
entry.c filterentry.c getfilelist.c plugin_syntax.c
proto-slap.h regex.c sasl_map.c slapi-private.h vattr.c
Log Message:
Resolves: 448831
Summary: Make regex code obey search timelimit.
Index: entry.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/entry.c,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- entry.c 18 Oct 2007 00:08:34 -0000 1.14
+++ entry.c 11 Jul 2008 17:18:43 -0000 1.14.2.1
@@ -1836,7 +1836,7 @@
f->f_choice,
&f->f_ava );
} else if ( filter_type == FILTER_TYPE_SUBSTRING) {
- *rc = plugin_call_syntax_filter_sub( tmp_attr,
+ *rc = plugin_call_syntax_filter_sub( NULL, tmp_attr,
&f->f_sub);
} else if ( filter_type == FILTER_TYPE_PRES ) {
/* type is there, that's all we need to know. */
Index: filterentry.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/filterentry.c,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- filterentry.c 18 Apr 2008 20:18:59 -0000 1.6.2.1
+++ filterentry.c 11 Jul 2008 17:18:43 -0000 1.6.2.2
@@ -693,7 +693,7 @@
rc = -1;
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
if ( slapi_attr_type_cmp( f->f_sub_type, a->a_type, SLAPI_TYPE_CMP_SUBTYPE ) == 0 ) {
- rc = plugin_call_syntax_filter_sub( a, &f->f_sub );
+ rc = plugin_call_syntax_filter_sub( pb, a, &f->f_sub );
if ( rc == 0 ) {
break;
}
@@ -726,8 +726,8 @@
rc = -1;
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
if ( slapi_attr_type_cmp( f->f_sub_type, a->a_type, SLAPI_TYPE_CMP_SUBTYPE ) == 0 ) {
- rc = plugin_call_syntax_filter_sub( a, &f->f_sub );
- if ( rc == 0 ) {
+ rc = plugin_call_syntax_filter_sub( pb, a, &f->f_sub );
+ if ( rc == 0 || rc == LDAP_TIMELIMIT_EXCEEDED ) {
break;
}
}
Index: getfilelist.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/getfilelist.c,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- getfilelist.c 10 Nov 2006 23:45:40 -0000 1.7
+++ getfilelist.c 11 Jul 2008 17:18:43 -0000 1.7.2.1
@@ -130,7 +130,7 @@
slapd_re_lock();
s = slapd_re_comp((char *)pattern);
if (!s)
- match = slapd_re_exec((char *)filename);
+ match = slapd_re_exec((char *)filename, -1 /* no timelimit */);
slapd_re_unlock();
return match;
Index: plugin_syntax.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/plugin_syntax.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- plugin_syntax.c 10 Nov 2006 23:45:40 -0000 1.5
+++ plugin_syntax.c 11 Jul 2008 17:18:43 -0000 1.5.2.1
@@ -211,15 +211,17 @@
int
plugin_call_syntax_filter_sub(
+ Slapi_PBlock *pb,
Slapi_Attr *a,
struct subfilt *fsub
)
{
- return(plugin_call_syntax_filter_sub_sv(a,fsub));
+ return(plugin_call_syntax_filter_sub_sv(pb,a,fsub));
}
int
plugin_call_syntax_filter_sub_sv(
+ Slapi_PBlock *pb,
Slapi_Attr *a,
struct subfilt *fsub
)
@@ -240,6 +242,13 @@
{
Slapi_Value **va= valueset_get_valuearray(&a->a_present_values);
pblock_init( &pipb );
+ if (pb)
+ {
+ Operation *op = NULL;
+ /* to pass SLAPI_SEARCH_TIMELIMIT & SLAPI_OPINITATED_TIME */
+ slapi_pblock_get( pb, SLAPI_OPERATION, &op );
+ slapi_pblock_set( &pipb, SLAPI_OPERATION, op );
+ }
slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
rc = a->a_plugin->plg_syntax_filter_sub( &pipb,
fsub->sf_initial, fsub->sf_any, fsub->sf_final, va);
Index: proto-slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -u -r1.31 -r1.31.2.1
--- proto-slap.h 18 Oct 2007 01:22:29 -0000 1.31
+++ proto-slap.h 11 Jul 2008 17:18:43 -0000 1.31.2.1
@@ -740,8 +740,8 @@
struct slapdplugin *slapi_get_global_syntax_plugins();
int plugin_call_syntax_filter_ava( const Slapi_Attr *a, int ftype, struct ava *ava );
int plugin_call_syntax_filter_ava_sv( const Slapi_Attr *a, int ftype, struct ava *ava, Slapi_Value **retVal, int useDeletedValues );
-int plugin_call_syntax_filter_sub( Slapi_Attr *a, struct subfilt *fsub );
-int plugin_call_syntax_filter_sub_sv( Slapi_Attr *a, struct subfilt *fsub );
+int plugin_call_syntax_filter_sub( Slapi_PBlock *pb, Slapi_Attr *a, struct subfilt *fsub );
+int plugin_call_syntax_filter_sub_sv( Slapi_PBlock *pb, Slapi_Attr *a, struct subfilt *fsub );
int plugin_call_syntax_get_compare_fn(void *vpi, value_compare_fn_type *compare_fn);
struct slapdplugin *plugin_syntax_find( const char *nameoroid );
void plugin_syntax_enumerate( SyntaxEnumFunc sef, void *arg );
Index: regex.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/regex.c,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -r1.5.2.1 -r1.5.2.2
--- regex.c 29 Apr 2008 00:38:00 -0000 1.5.2.1
+++ regex.c 11 Jul 2008 17:18:43 -0000 1.5.2.2
@@ -66,6 +66,10 @@
* Modification history:
*
* $Log$
+ * Revision 1.5.2.2 2008/07/11 17:18:43 nkinder
+ * Resolves: 448831
+ * Summary: Make regex code obey search timelimit.
+ *
* Revision 1.5.2.1 2008/04/29 00:38:00 nhosoi
* Resolves: #182621 (#443955)
* Summary: Allow larger regex buffer to enable long substring filters
@@ -699,7 +703,7 @@
static UCHAR *bopat[MAXTAG];
static UCHAR *eopat[MAXTAG];
#ifdef NEEDPROTOS
-static UCHAR *pmatch( UCHAR *lp, UCHAR *ap );
+static UCHAR *pmatch( UCHAR *lp, UCHAR *ap, time_t time_up, int *err );
#else /* NEEDPROTOS */
static UCHAR *pmatch();
#endif /* NEEDPROTOS */
@@ -724,14 +728,18 @@
* to the beginning and the end of the matched fragment,
* respectively.
*
+ * return values: 0 -- did not match
+ * 1 -- matched
+ * othersise -- ldap error (TIMELIMIT_EXCEEDED only)
*/
int
-slapd_re_exec( char *lp )
+slapd_re_exec( char *lp, time_t time_up )
{
register UCHAR c;
register UCHAR *ep = 0;
register UCHAR *ap = nfa;
+ int ldaperror = 0;
bol = (UCHAR*)lp;
@@ -749,7 +757,7 @@
switch(*ap) {
case BOL: /* anchored: match from BOL only */
- ep = pmatch((UCHAR*)lp,ap);
+ ep = pmatch((UCHAR*)lp,ap,time_up,&ldaperror);
break;
case CHR: /* ordinary char: locate it fast */
c = *(ap+1);
@@ -759,7 +767,7 @@
return 0;
default: /* regular matching all the way. */
do {
- if ((ep = pmatch((UCHAR*)lp,ap)))
+ if ((ep = pmatch((UCHAR*)lp,ap,time_up,&ldaperror)))
break;
lp++;
} while (*lp);
@@ -768,6 +776,8 @@
case END: /* munged automaton. fail always */
return 0;
}
+ if (ldaperror)
+ return ldaperror;
if (!ep)
return 0;
@@ -848,13 +858,19 @@
#define CCLSKIP 18 /* [CLO] CCL 16bytes END ... */
static UCHAR *
-pmatch( UCHAR *lp, UCHAR *ap)
+pmatch( UCHAR *lp, UCHAR *ap, time_t time_up, int *err )
{
register int op, c, n;
register UCHAR *e; /* extra pointer for CLO */
register UCHAR *bp; /* beginning of subpat.. */
register UCHAR *ep; /* ending of subpat.. */
UCHAR *are; /* to save the line ptr. */
+ time_t curtime = current_time();
+
+ if ( time_up != -1 && curtime > time_up ) {
+ *err = LDAP_TIMELIMIT_EXCEEDED;
+ return 0;
+ }
while ((op = *ap++) != END)
switch(op) {
@@ -931,7 +947,7 @@
ap += n;
while (lp >= are) {
- if ((e = pmatch(lp, ap)) != NULL)
+ if ((e = pmatch(lp, ap, time_up, err)) != NULL)
return e;
--lp;
}
Index: sasl_map.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/sasl_map.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- sasl_map.c 10 Nov 2006 23:45:40 -0000 1.8
+++ sasl_map.c 11 Jul 2008 17:18:43 -0000 1.8.2.1
@@ -434,9 +434,10 @@
recomp_result = slapd_re_comp(dp->regular_expression);
if (recomp_result) {
LDAPDebug( LDAP_DEBUG_ANY, "sasl_map_check : re_comp failed for expression (%s)\n", dp->regular_expression, 0, 0 );
+ } else {
+ matched = slapd_re_exec(sasl_user_and_realm, -1 /* no timelimit */);
+ LDAPDebug( LDAP_DEBUG_TRACE, "regex: %s, id: %s, %s\n", dp->regular_expression, sasl_user_and_realm, matched ? "matched" : "didn't match" );
}
- matched = slapd_re_exec(sasl_user_and_realm);
- LDAPDebug( LDAP_DEBUG_TRACE, "regex: %s, id: %s, %s\n", dp->regular_expression, sasl_user_and_realm, matched ? "matched" : "didn't match" );
if (matched) {
if (matched == 1) {
/* Allocate buffers for the returned strings */
Index: slapi-private.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-private.h,v
retrieving revision 1.20
retrieving revision 1.20.2.1
diff -u -r1.20 -r1.20.2.1
--- slapi-private.h 18 Oct 2007 22:40:18 -0000 1.20
+++ slapi-private.h 11 Jul 2008 17:18:43 -0000 1.20.2.1
@@ -1184,7 +1184,7 @@
void bervalarray_add_berval_fast(struct berval ***vals, const struct berval *addval, int nvals, int *maxvals);
-int slapd_re_exec( char *lp );
+int slapd_re_exec( char *lp, time_t time_up );
char *slapd_re_comp( char *pat );
int slapd_re_subs( char *src, char* dst );
void slapd_re_lock( void );
Index: vattr.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/vattr.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- vattr.c 1 Nov 2007 20:24:07 -0000 1.8
+++ vattr.c 11 Jul 2008 17:18:43 -0000 1.8.2.1
@@ -540,7 +540,7 @@
rc = plugin_call_syntax_filter_ava( a,
f->f_choice, &f->f_ava );
} else if ( filter_type == FILTER_TYPE_SUBSTRING) {
- rc = plugin_call_syntax_filter_sub( a,
+ rc = plugin_call_syntax_filter_sub( pb, a,
&f->f_sub);
}
@@ -611,7 +611,7 @@
} else if ( filter_type == FILTER_TYPE_SUBSTRING ) {
- rc = test_substring_filter( NULL, e, f, 0 /* no access check */,
+ rc = test_substring_filter( pb, e, f, 0 /* no access check */,
0 /* do test filter */, &acl_test_done);
} else if ( filter_type == FILTER_TYPE_PRES ) {
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/syntaxes string.c, 1.9.2.1, 1.9.2.2
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8956/servers/plugins/syntaxes
Modified Files:
Tag: Directory_Server_8_0_Branch
string.c
Log Message:
Resolves: 448831
Summary: Make regex code obey search timelimit.
Index: string.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes/string.c,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -u -r1.9.2.1 -r1.9.2.2
--- string.c 29 Apr 2008 00:38:00 -0000 1.9.2.1
+++ string.c 11 Jul 2008 17:18:43 -0000 1.9.2.2
@@ -195,9 +195,20 @@
char pat[BUFSIZ];
char buf[BUFSIZ];
char ebuf[BUFSIZ];
+ time_t curtime = 0;
+ time_t time_up = 0;
+ time_t optime = 0; /* time op was initiated */
+ int timelimit = 0; /* search timelimit */
LDAPDebug( LDAP_DEBUG_FILTER, "=> string_filter_sub\n",
0, 0, 0 );
+ slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &timelimit );
+ slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime );
+ /*
+ * (timelimit==-1) means no time limit
+ */
+ time_up = ( timelimit==-1 ? -1 : optime + timelimit);
+
/*
* construct a regular expression corresponding to the
* filter and let regex do the work for each value
@@ -259,18 +270,21 @@
p = (bigpat) ? bigpat : pat;
slapd_re_lock();
if ( (tmpbuf = slapd_re_comp( p )) != 0 ) {
- LDAPDebug( LDAP_DEBUG_ANY, "re_comp (%s) failed (%s)\n",
- pat, p, 0 );
- slapd_re_unlock();
- if( bigpat != NULL ) {
- slapi_ch_free((void**)&bigpat );
- }
- return( LDAP_OPERATIONS_ERROR );
+ LDAPDebug( LDAP_DEBUG_ANY, "re_comp (%s) failed (%s): %s\n",
+ pat, p, tmpbuf );
+ rc = LDAP_OPERATIONS_ERROR;
+ goto bailout;
} else {
LDAPDebug( LDAP_DEBUG_TRACE, "re_comp (%s)\n",
escape_string( p, ebuf ), 0, 0 );
}
+ curtime = current_time();
+ if ( time_up != -1 && curtime > time_up ) {
+ rc = LDAP_TIMELIMIT_EXCEEDED;
+ goto bailout;
+ }
+
/*
* test the regex against each value
*/
@@ -296,22 +310,22 @@
}
value_normalize( realval, syntax, 1 /* trim leading blanks */ );
- tmprc = slapd_re_exec( realval );
+ tmprc = slapd_re_exec( realval, time_up );
LDAPDebug( LDAP_DEBUG_TRACE, "re_exec (%s) %i\n",
escape_string( realval, ebuf ), tmprc, 0 );
- if ( tmprc != 0 ) {
+ if ( tmprc == 1 ) {
rc = 0;
break;
+ } else if (tmprc != 0) {
+ rc = tmprc;
+ break;
}
}
+bailout:
slapd_re_unlock();
- if ( tmpbuf != NULL ) {
- slapi_ch_free((void**)&tmpbuf );
- }
- if( bigpat != NULL ) {
- slapi_ch_free((void**)&bigpat );
- }
+ slapi_ch_free((void**)&tmpbuf );
+ slapi_ch_free((void**)&bigpat );
LDAPDebug( LDAP_DEBUG_FILTER, "<= string_filter_sub %d\n",
rc, 0, 0 );
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ldbm_search.c, 1.12, 1.12.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8956/servers/slapd/back-ldbm
Modified Files:
Tag: Directory_Server_8_0_Branch
ldbm_search.c
Log Message:
Resolves: 448831
Summary: Make regex code obey search timelimit.
Index: ldbm_search.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_search.c,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- ldbm_search.c 12 Oct 2007 18:03:42 -0000 1.12
+++ ldbm_search.c 11 Jul 2008 17:18:43 -0000 1.12.2.1
@@ -1296,6 +1296,10 @@
"Failed the filter test", 0, NULL );
rc = SLAPI_FAIL_GENERAL;
goto bail;
+ } else if (LDAP_TIMELIMIT_EXCEEDED == filter_test) {
+ slapi_send_ldap_result( pb, LDAP_TIMELIMIT_EXCEEDED, NULL, NULL, nentries, urls );
+ rc = SLAPI_FAIL_GENERAL;
+ goto bail;
}
}
}
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication repl5.h, 1.10, 1.10.2.1 repl5_inc_protocol.c, 1.11.2.1, 1.11.2.2 repl5_replica.c, 1.16, 1.16.2.1 repl_extop.c, 1.12, 1.12.2.1 windows_inc_protocol.c, 1.15, 1.15.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20221/ldap/servers/plugins/replication
Modified Files:
Tag: Directory_Server_8_0_Branch
repl5.h repl5_inc_protocol.c repl5_replica.c repl_extop.c
windows_inc_protocol.c
Log Message:
Resolves: 233642
Summary: MMR breaks with time skew errors
Index: repl5.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5.h,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- repl5.h 12 Sep 2007 23:05:24 -0000 1.10
+++ repl5.h 11 Jul 2008 15:27:02 -0000 1.10.2.1
@@ -486,6 +486,7 @@
void replica_get_referrals(const Replica *r, char ***referrals);
void replica_set_referrals(Replica *r,const Slapi_ValueSet *vs);
int replica_update_csngen_state (Replica *r, const RUV *ruv);
+int replica_update_csngen_state_ext (Replica *r, const RUV *ruv, const CSN *extracsn);
CSN *replica_get_purge_csn(const Replica *r);
int replica_log_ruv_elements (const Replica *r);
void replica_enumerate_replicas (FNEnumReplica fn, void *arg);
Index: repl5_inc_protocol.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_inc_protocol.c,v
retrieving revision 1.11.2.1
retrieving revision 1.11.2.2
diff -u -r1.11.2.1 -r1.11.2.2
--- repl5_inc_protocol.c 10 Jul 2008 23:18:04 -0000 1.11.2.1
+++ repl5_inc_protocol.c 11 Jul 2008 15:27:02 -0000 1.11.2.2
@@ -1100,13 +1100,20 @@
rc = replica_update_csngen_state (replica, ruv);
object_release (prp->replica_object);
replica = NULL;
- if (rc != 0) /* too much skew */
+ if (rc == CSN_LIMIT_EXCEEDED) /* too much skew */
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Incremental protocol: fatal error - too much time skew between replicas!\n",
agmt_get_long_name(prp->agmt));
next_state = STATE_STOP_FATAL_ERROR;
}
+ else if (rc != 0) /* internal error */
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "%s: Incremental protocol: fatal internal error updating the CSN generator!\n",
+ agmt_get_long_name(prp->agmt));
+ next_state = STATE_STOP_FATAL_ERROR;
+ }
else
{
rc = send_updates(prp, ruv, &num_changes_sent);
Index: repl5_replica.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_replica.c,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -r1.16 -r1.16.2.1
--- repl5_replica.c 18 Oct 2007 22:40:17 -0000 1.16
+++ repl5_replica.c 11 Jul 2008 15:27:02 -0000 1.16.2.1
@@ -1043,7 +1043,7 @@
}
int
-replica_update_csngen_state (Replica *r, const RUV *ruv)
+replica_update_csngen_state_ext (Replica *r, const RUV *ruv, const CSN *extracsn)
{
int rc = 0;
CSNGen *gen;
@@ -1057,34 +1057,42 @@
return -1;
}
- if (csn == NULL) /* ruv contains no csn - we are done */
+ if ((csn == NULL) && (extracsn == NULL)) /* ruv contains no csn and no extra - we are done */
{
return 0;
}
+ if (csn_compare(extracsn, csn) > 0) /* extracsn > csn */
+ {
+ csn_free (&csn); /* free */
+ csn = (CSN*)extracsn; /* use this csn to do the update */
+ }
+
PR_Lock(r->repl_lock);
gen = (CSNGen *)object_get_data (r->repl_csngen);
PR_ASSERT (gen);
rc = csngen_adjust_time (gen, csn);
- if (rc != CSN_SUCCESS)
- {
- rc = -1;
- goto done;
- }
-
- rc = 0;
+ /* rc will be either CSN_SUCCESS (0) or clock skew */
done:
PR_Unlock(r->repl_lock);
- if (csn)
+ if (csn != extracsn) /* do not free the given csn */
+ {
csn_free (&csn);
+ }
return rc;
}
+int
+replica_update_csngen_state (Replica *r, const RUV *ruv)
+{
+ return replica_update_csngen_state_ext(r, ruv, NULL);
+}
+
/*
* dumps replica state for debugging purpose
*/
Index: repl_extop.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl_extop.c,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- repl_extop.c 18 Oct 2007 00:08:31 -0000 1.12
+++ repl_extop.c 11 Jul 2008 15:27:02 -0000 1.12.2.1
@@ -550,7 +550,6 @@
Replica *replica = NULL;
void *conn;
consumer_connection_extension *connext = NULL;
- CSN *mycsn = NULL;
char *replicacsnstr = NULL;
CSN *replicacsn = NULL;
int zero = 0;
@@ -703,55 +702,37 @@
gen = object_get_data(gen_obj);
if (NULL != gen)
{
- if (csngen_new_csn(gen, &mycsn, PR_FALSE /* notify */) == CSN_SUCCESS)
+ replicacsn = csn_new_by_string(replicacsnstr);
+ if (NULL != replicacsn)
{
- replicacsn = csn_new_by_string(replicacsnstr);
- if (NULL != replicacsn)
+ /* ONREPL - we used to manage clock skew here. However, csn generator
+ code already does it. The csngen also manages local skew caused by
+ system clock reset, so to keep it consistent, I removed code from here */
+ /* update the state of the csn generator */
+ rc = replica_update_csngen_state_ext (replica, supplier_ruv, replicacsn); /* too much skew */
+ if (rc == CSN_LIMIT_EXCEEDED)
{
- /* ONREPL - we used to manage clock skew here. However, csn generator
- code already does it. The csngen also manages local skew caused by
- system clock reset, so to keep it consistent, I removed code from here */
- time_t diff = 0L;
- diff = csn_time_difference(mycsn, replicacsn);
- if (diff > 0)
- {
- /* update the state of the csn generator */
- rc = csngen_adjust_time (gen, replicacsn);
- if (rc == CSN_LIMIT_EXCEEDED) /* too much skew */
- {
- response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
- goto send_response;
- }
- }
- else if (diff <= 0)
- {
- /* Supplier's clock is behind ours */
- /* XXXggood check if CSN smaller than purge point */
- /* response = NSDS50_REPL_BELOW_PURGEPOINT; */
- /* goto send_response; */
- }
+ response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "conn=%d op=%d repl=\"%s\": "
+ "Excessive clock skew from supplier RUV\n",
+ connid, opid, repl_root);
+ goto send_response;
}
- else
+ else if (rc != 0)
{
- /* Oops, csnstr couldn't be converted */
+ /* Oops, problem csn or ruv format, or memory, or .... */
response = NSDS50_REPL_INTERNAL_ERROR;
goto send_response;
}
+
}
else
{
- /* Oops, csn generator failed */
+ /* Oops, csnstr couldn't be converted */
response = NSDS50_REPL_INTERNAL_ERROR;
goto send_response;
}
-
- /* update csn generator's state from the supplier's ruv */
- rc = replica_update_csngen_state (replica, supplier_ruv); /* too much skew */
- if (rc != 0)
- {
- response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
- goto send_response;
- }
}
else
{
@@ -988,11 +969,6 @@
{
object_release(gen_obj);
}
- /* mycsn */
- if (NULL != mycsn)
- {
- csn_free(&mycsn);
- }
/* replicacsn */
if (NULL != replicacsn)
{
Index: windows_inc_protocol.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/windows_inc_protocol.c,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -u -r1.15 -r1.15.2.1
--- windows_inc_protocol.c 18 Oct 2007 00:08:31 -0000 1.15
+++ windows_inc_protocol.c 11 Jul 2008 15:27:02 -0000 1.15.2.1
@@ -796,13 +796,20 @@
rc = replica_update_csngen_state (replica, ruv);
object_release (prp->replica_object);
replica = NULL;
- if (rc != 0) /* too much skew */
+ if (rc == CSN_LIMIT_EXCEEDED) /* too much skew */
{
- slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name,
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Incremental protocol: fatal error - too much time skew between replicas!\n",
agmt_get_long_name(prp->agmt));
next_state = STATE_STOP_FATAL_ERROR;
}
+ else if (rc != 0) /* internal error */
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "%s: Incremental protocol: fatal internal error updating the CSN generator!\n",
+ agmt_get_long_name(prp->agmt));
+ next_state = STATE_STOP_FATAL_ERROR;
+ }
else
{
rc = send_updates(prp, ruv, &num_changes_sent);
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd csngen.c, 1.7, 1.7.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20221/ldap/servers/slapd
Modified Files:
Tag: Directory_Server_8_0_Branch
csngen.c
Log Message:
Resolves: 233642
Summary: MMR breaks with time skew errors
Index: csngen.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/csngen.c,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- csngen.c 10 Nov 2006 23:45:40 -0000 1.7
+++ csngen.c 11 Jul 2008 15:27:03 -0000 1.7.2.1
@@ -60,6 +60,9 @@
#define STATE_FORMAT "%8x%8x%8x%4hx%4hx"
#define STATE_LENGTH 32
#define MAX_VAL(x,y) ((x)>(y)?(x):(y))
+#define CSN_CALC_TSTAMP(gen) ((gen)->state.sampled_time + \
+ (gen)->state.local_offset + \
+ (gen)->state.remote_offset)
/*
* **************************************************************************
@@ -273,8 +276,7 @@
gen->state.seq_num = 0;
}
- (*csn)->tstamp = gen->state.sampled_time + gen->state.local_offset +
- gen->state.remote_offset;
+ (*csn)->tstamp = CSN_CALC_TSTAMP(gen);
(*csn)->seqnum = gen->state.seq_num ++;
(*csn)->rid = gen->state.rid;
(*csn)->subseqnum = 0;
@@ -308,8 +310,9 @@
of time so that it does not generate smaller csns */
int csngen_adjust_time (CSNGen *gen, const CSN* csn)
{
- time_t remote_time, remote_offset;
+ time_t remote_time, remote_offset, cur_time;
PRUint16 remote_seqnum;
+ int rc;
if (gen == NULL || csn == NULL)
return CSN_INVALID_PARAMETER;
@@ -319,21 +322,38 @@
PR_RWLock_Wlock (gen->lock);
- if (remote_seqnum > gen->state.seq_num )
- {
- if (remote_seqnum < CSN_MAX_SEQNUM)
- {
- gen->state.seq_num = remote_seqnum + 1;
- }
- else
- {
- remote_time++;
- }
- }
+ /* make sure we have the current time */
+ csngen_update_time();
+ cur_time = g_sampled_time;
+
+ /* make sure sampled_time is current */
+ /* must only call adjust_local_time if the current time is greater than
+ the generator state time */
+ if ((cur_time > gen->state.sampled_time) &&
+ (CSN_SUCCESS != (rc = _csngen_adjust_local_time(gen, cur_time))))
+ {
+ /* _csngen_adjust_local_time will log error */
+ PR_RWLock_Unlock (gen->lock);
+ csngen_dump_state(gen);
+ return rc;
+ }
- if (remote_time >= gen->state.sampled_time)
+ cur_time = CSN_CALC_TSTAMP(gen);
+ if (remote_time >= cur_time)
{
- remote_offset = remote_time - gen->state.sampled_time;
+ if (remote_seqnum > gen->state.seq_num )
+ {
+ if (remote_seqnum < CSN_MAX_SEQNUM)
+ {
+ gen->state.seq_num = remote_seqnum + 1;
+ }
+ else
+ {
+ remote_time++;
+ }
+ }
+
+ remote_offset = remote_time - cur_time;
if (remote_offset > gen->state.remote_offset)
{
if (remote_offset <= CSN_MAX_TIME_ADJUST)
@@ -346,10 +366,18 @@
"adjustment limit exceeded; value - %ld, limit - %ld\n",
remote_offset, (long)CSN_MAX_TIME_ADJUST);
PR_RWLock_Unlock (gen->lock);
+ csngen_dump_state(gen);
return CSN_LIMIT_EXCEEDED;
}
}
- }
+ }
+ else if (gen->state.remote_offset > 0)
+ {
+ /* decrease remote offset? */
+ /* how to decrease remote offset but ensure that we don't
+ generate a duplicate CSN, or a CSN smaller than one we've already
+ generated? */
+ }
PR_RWLock_Unlock (gen->lock);
@@ -576,7 +604,14 @@
{
time_t time_diff = cur_time - gen->state.sampled_time;
- if (time_diff > 0)
+ if (time_diff == 0) {
+ /* This is a no op - _csngen_adjust_local_time should never be called
+ in this case, because there is nothing to adjust - but just return
+ here to protect ourselves
+ */
+ return CSN_SUCCESS;
+ }
+ else if (time_diff > 0)
{
gen->state.sampled_time = cur_time;
if (time_diff > gen->state.local_offset)
@@ -588,7 +623,7 @@
return CSN_SUCCESS;
}
- else /* time was turend back */
+ else /* time was turned back */
{
if (abs (time_diff) > CSN_MAX_TIME_ADJUST)
{
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication repl5_inc_protocol.c, 1.11, 1.11.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv4549/ldap/servers/plugins/replication
Modified Files:
Tag: Directory_Server_8_0_Branch
repl5_inc_protocol.c
Log Message:
Resolves: 450973
Summary: Don't immediately exit in repl async thread when the consumer encounters an error.
Index: repl5_inc_protocol.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_inc_protocol.c,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- repl5_inc_protocol.c 18 Oct 2007 00:08:31 -0000 1.11
+++ repl5_inc_protocol.c 10 Jul 2008 23:18:04 -0000 1.11.2.1
@@ -294,6 +294,7 @@
while (!finished)
{
conres = conn_read_result_ex(conn, NULL, NULL, NULL, &message_id, 0);
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "repl5_inc_result_threadmain: read result for message_id %d\n", message_id);
/* Timeout here means that we didn't block, not a real timeout */
if (CONN_TIMEOUT == conres)
{
@@ -328,6 +329,7 @@
}
if (conres != CONN_TIMEOUT)
{
+ int should_finish = 0;
if (message_id)
{
rd->last_message_id_received = message_id;
@@ -344,16 +346,18 @@
}
conn_get_error_ex(conn, &operation_code, &connection_error, &ldap_error_string);
- slapi_log_error(SLAPI_LOG_REPL, NULL, "repl5_inc_result_threadmain: result %d, %d, %d, %s\n", operation_code,connection_error,conres,ldap_error_string);
- rd->result = repl5_inc_update_from_op_result(rd->prp, conres, connection_error, csn_str, uniqueid, replica_id, &finished, &(rd->num_changes_sent));
- if (rd->result)
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "repl5_inc_result_threadmain: result %d, %d, %d, %d, %s\n", operation_code,connection_error,conres,message_id,ldap_error_string);
+ rd->result = repl5_inc_update_from_op_result(rd->prp, conres, connection_error, csn_str, uniqueid, replica_id, &should_finish, &(rd->num_changes_sent));
+ if (rd->result || should_finish)
{
- slapi_log_error(SLAPI_LOG_REPL, NULL, "repl5_inc_result_threadmain: got op result %d\n", rd->result);
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "repl5_inc_result_threadmain: got op result %d should finish %d\n", rd->result, should_finish);
/* If so then we need to take steps to abort the update process */
PR_Lock(rd->lock);
rd->abort = 1;
PR_Unlock(rd->lock);
/* We also need to log the error, including details stored from when the operation was sent */
+ /* we cannot finish yet - we still need to waitfor the pending results, then
+ the main repl code will shut down this thread */
}
}
/* Should we stop ? */
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd sasl_io.c, 1.13, 1.13.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv4204/ldap/servers/slapd
Modified Files:
Tag: Directory_Server_8_0_Branch
sasl_io.c
Log Message:
Resolves: 428163
Summary: Fixes SASL IO set/get argument mismatch.
Index: sasl_io.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/sasl_io.c,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -u -r1.13 -r1.13.2.1
--- sasl_io.c 18 Oct 2007 00:08:34 -0000 1.13
+++ sasl_io.c 10 Jul 2008 23:11:14 -0000 1.13.2.1
@@ -103,15 +103,16 @@
sasl_io_setup(Connection *c)
{
int ret = 0;
- struct lber_x_ext_io_fns *func_pointers = NULL;
+ struct lber_x_ext_io_fns func_pointers = {0};
+ struct lber_x_ext_io_fns *real_iofns = (struct lber_x_ext_io_fns *) slapi_ch_malloc(LBER_X_EXTIO_FNS_SIZE);
sasl_io_private *sp = (sasl_io_private*) slapi_ch_calloc(1, sizeof(sasl_io_private));
LDAPDebug( LDAP_DEBUG_CONNS,
"sasl_io_setup for connection %d\n", c->c_connid, 0, 0 );
/* Get the current functions and store them for later */
- ber_sockbuf_get_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, &func_pointers);
- sp->real_iofns = func_pointers;
- func_pointers = NULL;
+ real_iofns->lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
+ ber_sockbuf_get_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, real_iofns );
+ sp->real_iofns = real_iofns; /* released in sasl_io_cleanup */
/* Set up the private structure */
sp->real_handle = (struct lextiof_socket_private*) c->c_prfd;
@@ -119,13 +120,12 @@
/* Store the private structure in the connection */
c->c_sasl_io_private = sp;
/* Insert the sasl i/o functions into the ber layer */
- func_pointers = (struct lber_x_ext_io_fns *) slapi_ch_malloc(LBER_X_EXTIO_FNS_SIZE);
- func_pointers->lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
- func_pointers->lbextiofn_read = sasl_read_function;
- func_pointers->lbextiofn_write = sasl_write_function;
- func_pointers->lbextiofn_writev = NULL;
- func_pointers->lbextiofn_socket_arg = (struct lextiof_socket_private *) sp;
- ber_sockbuf_set_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, func_pointers);
+ func_pointers.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
+ func_pointers.lbextiofn_read = sasl_read_function;
+ func_pointers.lbextiofn_write = sasl_write_function;
+ func_pointers.lbextiofn_writev = NULL;
+ func_pointers.lbextiofn_socket_arg = (struct lextiof_socket_private *) sp;
+ ret = ber_sockbuf_set_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, &func_pointers);
/* Setup the data buffers for the fast read path */
sasl_io_init_buffers(sp);
/* Reset the enable flag, so we don't process it again */
@@ -139,7 +139,6 @@
sasl_io_cleanup(Connection *c)
{
int ret = 0;
- struct lber_x_ext_io_fns *func_pointers = NULL;
sasl_io_private *sp = c->c_sasl_io_private;
if (sp) {
LDAPDebug( LDAP_DEBUG_CONNS,
@@ -148,9 +147,10 @@
slapi_ch_free((void**)&(sp->encrypted_buffer));
slapi_ch_free((void**)&(sp->decrypted_buffer));
/* Put the I/O functions back how they were */
- ber_sockbuf_get_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, &func_pointers);
- slapi_ch_free((void**)&func_pointers);
- ber_sockbuf_set_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, sp->real_iofns);
+ if (NULL != sp->real_iofns) {
+ ber_sockbuf_set_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, sp->real_iofns);
+ slapi_ch_free((void**)&(sp->real_iofns));
+ }
slapi_ch_free((void**)&sp);
c->c_sasl_io_private = NULL;
c->c_enable_sasl_io = 0;
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication cl5_clcache.c, 1.7, 1.7.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3780/ldap/servers/plugins/replication
Modified Files:
Tag: Directory_Server_8_0_Branch
cl5_clcache.c
Log Message:
Resolves: 442170
Summary: Need to use DB_BUFFER_SMALL instead of ENOMEM with newer BDB versions.
Index: cl5_clcache.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_clcache.c,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- cl5_clcache.c 10 Nov 2006 23:45:17 -0000 1.7
+++ cl5_clcache.c 10 Jul 2008 23:04:09 -0000 1.7.2.1
@@ -45,6 +45,15 @@
#include "cl5.h" /* changelog5Config */
#include "cl5_clcache.h"
+/* newer bdb uses DB_BUFFER_SMALL instead of ENOMEM as the
+ error return if the given buffer in which to load a
+ key or value is too small - if it is not defined, define
+ it here to ENOMEM
+*/
+#ifndef DB_BUFFER_SMALL
+#define DB_BUFFER_SMALL ENOMEM
+#endif
+
/*
* Constants for the buffer pool:
*
@@ -248,7 +257,7 @@
else {
slapi_log_error ( SLAPI_LOG_FATAL, get_thread_private_agmtname(),
"clcache_get_buffer: can't allocate new buffer\n" );
- rc = ENOMEM;
+ rc = CL5_MEMORY_ERROR;
}
return rc;
@@ -379,7 +388,7 @@
* Continue if the error is no-mem since we don't need to
* load in the key record anyway with DB_SET.
*/
- if ( 0 == rc || ENOMEM == rc )
+ if ( 0 == rc || DB_BUFFER_SMALL == rc )
rc = clcache_cursor_get ( cursor, buf, flag );
}
@@ -852,7 +861,7 @@
if ( NULL == bl ) {
if ( NULL == ( bl = clcache_new_busy_list ()) ) {
- rc = ENOMEM;
+ rc = CL5_MEMORY_ERROR;
}
else {
PR_RWLock_Wlock ( _pool->pl_lock );
@@ -898,7 +907,7 @@
& buf->buf_key,
& buf->buf_data,
buf->buf_load_flag | flag );
- if ( ENOMEM == rc ) {
+ if ( DB_BUFFER_SMALL == rc ) {
/*
* The record takes more space than the current size of the
* buffer. Fortunately, buf->buf_data.size has been set by
@@ -923,7 +932,7 @@
"clcache_cursor_get: invalid parameter\n" );
break;
- case ENOMEM:
+ case DB_BUFFER_SMALL:
slapi_log_error ( SLAPI_LOG_FATAL, buf->buf_agmt_name,
"clcache_cursor_get: can't allocate %u bytes\n", buf->buf_data.ulen );
break;
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd log.c, 1.21, 1.21.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29119/ldap/servers/slapd
Modified Files:
Tag: Directory_Server_8_0_Branch
log.c
Log Message:
Resolves: 440333
Summary: Fix valgrind errors about use of uninitialized values.
Index: log.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/log.c,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -r1.21 -r1.21.2.1
--- log.c 3 Dec 2007 18:16:32 -0000 1.21
+++ log.c 10 Jul 2008 22:51:42 -0000 1.21.2.1
@@ -4007,7 +4007,7 @@
static time_t
log_reverse_convert_time(char *tbuf)
{
- struct tm tm;
+ struct tm tm = {0};
if (strchr(tbuf, '-')) { /* short format */
strptime(tbuf, "%Y%m%d-%H%M%S", &tm);
15 years, 10 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/acl acl_ext.c, 1.7, 1.7.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/acl
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29119/ldap/servers/plugins/acl
Modified Files:
Tag: Directory_Server_8_0_Branch
acl_ext.c
Log Message:
Resolves: 440333
Summary: Fix valgrind errors about use of uninitialized values.
Index: acl_ext.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/acl/acl_ext.c,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- acl_ext.c 18 Oct 2007 00:08:27 -0000 1.7
+++ acl_ext.c 10 Jul 2008 22:51:42 -0000 1.7.2.1
@@ -647,7 +647,7 @@
struct acl_cblock *aclcb = NULL;
char *authType;
void *conn;
- unsigned long op_type;
+ int op_type;
if ( NULL == aclpb ) {
15 years, 10 months