ldap/servers
by Noriko Hosoi
ldap/servers/slapd/dn.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
New commits:
commit 0c44a46448595fdb1e079b5f4c91d4d8bfa2e0f2
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Mon Jan 7 17:07:52 2013 -0800
Ticket #547 - Incorrect assumption in ndn cache
Bug Description: In ndn_cache_lookup, to determine the given dn
is already normalized or not, the length is compared with the
normalized dn length. If they match, it considers the given dn
is already normalized. But there are cases even if the lengths
are equal, the given dn may not be normalized yet.
(e.g., 'cn="o=ABC",o=XYZ' vs. 'cn=o\3DABC,o=XYZ')
Fix Description: This patch adds another check: if the dn and
normalized dn length match, call memcmp to compare the 2 dn's.
When memcmp returns 0, ndn_cache_lookup returns the passed dn.
https://fedorahosted.org/389/ticket/547
Reviewed by mreynolds (Thanks, Mark!).
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index d643d33..6081119 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2706,26 +2706,29 @@ ndn_cache_lookup(char *dn, size_t dn_len, char **result, char **udn, int *rc)
slapi_rwlock_rdlock(ndn_cache_lock);
ndn_ht_val = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
if(ndn_ht_val){
- ndn_cache_update_lru(&ndn_ht_val->lru_node);
- slapi_counter_increment(ndn_cache->cache_hits);
- if(ndn_ht_val->len == dn_len ){
- /* the dn was already normalized, just return the dn as the result */
- *result = dn;
- *rc = 0;
- } else {
- *rc = 1; /* free result */
+ ndn_cache_update_lru(&ndn_ht_val->lru_node);
+ slapi_counter_increment(ndn_cache->cache_hits);
+ if ((ndn_ht_val->len != dn_len) ||
+ /* even if the lengths match, dn may not be normalized yet.
+ * (e.g., 'cn="o=ABC",o=XYZ' vs. 'cn=o\3DABC,o=XYZ') */
+ (memcmp(dn, ndn_ht_val->ndn, dn_len))){
+ *rc = 1; /* free result */
ndn = slapi_ch_malloc(ndn_ht_val->len + 1);
memcpy(ndn, ndn_ht_val->ndn, ndn_ht_val->len);
ndn[ndn_ht_val->len] = '\0';
*result = ndn;
+ } else {
+ /* the dn was already normalized, just return the dn as the result */
+ *result = dn;
+ *rc = 0;
}
rv = 1;
} else {
- /* copy/preserve the udn, so we can use it as the key when we add dn's to the hashtable */
- key = slapi_ch_malloc(dn_len + 1);
- memcpy(key, dn, dn_len);
- key[dn_len] = '\0';
- *udn = key;
+ /* copy/preserve the udn, so we can use it as the key when we add dn's to the hashtable */
+ key = slapi_ch_malloc(dn_len + 1);
+ memcpy(key, dn, dn_len);
+ key[dn_len] = '\0';
+ *udn = key;
}
slapi_rwlock_unlock(ndn_cache_lock);
11 years, 2 months
ldap/admin
by Mark Reynolds
ldap/admin/src/logconv.pl | 55 ++++++++++++++++++++--------------------------
1 file changed, 25 insertions(+), 30 deletions(-)
New commits:
commit 8965dda8d4023ab36f0a404a874c657d78631e9d
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jan 8 12:16:14 2013 -0500
Ticket 539 - logconv.pl should handle microsecond timing
Bug Description: logconv.pl can not handle microsecond etimes
Fix Description: Update the regular expressions to handle the decimal point "."
Also did a little code cleanup.
https://fedorahosted.org/389/ticket/539
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index 94ba036..f5342af 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -948,36 +948,31 @@ if ($filter_count > 0){
# #
#########################################
-
-#
-# print most often etimes
-#
-
if ($usage =~ /t/i || $verb eq "yes"){
-print "\n\n----- Top $sizeCount Most Frequent etimes -----\n\n";
-$eloop = 0;
-foreach $et (sort { $etime{$b} <=> $etime{$a} } keys %etime) {
- if ($eloop == $sizeCount) { last; }
- if ($retime ne "2"){
- $first = $et;
- $retime = "2";
+ #
+ # print most often etimes
+ #
+ print "\n\n----- Top $sizeCount Most Frequent etimes -----\n\n";
+ $eloop = 0;
+ foreach $et (sort { $etime{$b} <=> $etime{$a} } keys %etime) {
+ if ($eloop == $sizeCount) { last; }
+ if ($retime ne "2"){
+ $first = $et;
+ $retime = "2";
+ }
+ printf "%-8s %-12s\n", $etime{ $et }, "etime=$et";
+ $eloop++;
}
- printf "%-8s %-12s\n", $etime{ $et }, "etime=$et";
- $eloop++;
-}
-
-#
-# print longest etimes
-#
-
-print "\n\n----- Top $sizeCount Longest etimes -----\n\n";
-$eloop = 0;
-foreach $et (sort { $b <=> $a } (keys %etime)) {
- if ($eloop == $sizeCount) { last; }
- printf "%-12s %-10s\n","etime=$et",$etime{ $et };
- $eloop++;
-}
-
+ #
+ # print longest etimes
+ #
+ print "\n\n----- Top $sizeCount Longest etimes -----\n\n";
+ $eloop = 0;
+ foreach $et (sort { $b <=> $a } (keys %etime)) {
+ if ($eloop == $sizeCount) { last; }
+ printf "%-12s %-10s\n","etime=$et",$etime{ $et };
+ $eloop++;
+ }
}
#######################################
@@ -1651,7 +1646,7 @@ if (m/ notes=U/){
}
if ($usage =~ /u/ || $verb eq "yes"){
if ($v eq "0" ){
- if ($_ =~ /etime= *([0-9]+)/i ) {
+ if ($_ =~ /etime= *([0-9.]+)/i ) {
$notesEtime[$vet]=$1;
$vet++;
}
@@ -1931,7 +1926,7 @@ if ($_ =~ /err= *([0-9]+)/i){
if ($1 ne "0"){ $errorck++;}
else { $errorsucc++;}
}
-if ($_ =~ /etime= *([0-9]+)/i ) { $etime{$1}++;}
+if ($_ =~ /etime= *([0-9.]+)/ ) { $etime{$1}++;}
if ($_ =~ / tag=101 nentries= *([0-9]+)/i ) {$nentries{$1}++}
if ($_ =~ / tag=111 nentries= *([0-9]+)/i ) {$nentries{$1}++}
if ($_ =~ / tag=100 nentries= *([0-9]+)/i ) {$nentries{$1}++}
11 years, 2 months
ldap/schema
by Mark Reynolds
ldap/schema/01core389.ldif | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 6e84e093b3f8b424887ea0ee827527e350840720
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jan 8 10:13:00 2013 -0500
Ticket 534 - SASL Mapping Fallback
Bug Description: wrong oid for nsslapd-sasl-mapping-fallback
Fix Description: Use the correct oid.
https://fedorahosted.org/389/ticket/534
Reported by: Noriko(Thanks!)
diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif
index 8a245de..1c9112f 100644
--- a/ldap/schema/01core389.ldif
+++ b/ldap/schema/01core389.ldif
@@ -140,7 +140,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2136 NAME 'nsds5ReplicaCleanRUVNotified'
attributeTypes: ( 2.16.840.1.113730.3.1.2137 NAME 'nsds5ReplicaAbortCleanRUV' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2111 NAME 'tombstoneNumSubordinates' DESC 'count of immediate subordinates for tombstone entries' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation X-ORIGIN '389 directory server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2138 NAME 'nsslapd-readonly' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2142 NAME 'nsslapd-sasl-mapping-fallback' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2143 NAME 'nsslapd-sasl-mapping-fallback' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
#
# objectclasses
#
11 years, 2 months
ldap/ldif ldap/schema ldap/servers
by Mark Reynolds
ldap/ldif/template-dse.ldif.in | 1 +
ldap/schema/01core389.ldif | 1 +
ldap/servers/slapd/libglobs.c | 31 ++++++++++++++++++++++++++++++-
ldap/servers/slapd/proto-slap.h | 2 ++
ldap/servers/slapd/saslbind.c | 3 ++-
ldap/servers/slapd/slap.h | 2 ++
6 files changed, 38 insertions(+), 2 deletions(-)
New commits:
commit a15416d095e07c333c027965032e08bfc729d422
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Jan 7 16:50:52 2013 -0500
Ticket 534 - Add SASL mappings fallback
Bug Description: IPA team requested that the fallback feature be configurable.
Fix Description: Added new config setting under cn=config to turn feature "on",
the default is "off".
https://fedorahosted.org/389/ticket/534
Reviewed by: richm(Thanks Rich!)
diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in
index e7837a7..b854c47 100644
--- a/ldap/ldif/template-dse.ldif.in
+++ b/ldap/ldif/template-dse.ldif.in
@@ -57,6 +57,7 @@ nsslapd-rootpw: %ds_passwd%
nsslapd-maxdescriptors: 1024
nsslapd-max-filter-nest-level: 40
nsslapd-ndn-cache-enabled: off
+nsslapd-sasl-mapping-fallback: off
dn: cn=features,cn=config
objectclass: top
diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif
index d22edaa..8a245de 100644
--- a/ldap/schema/01core389.ldif
+++ b/ldap/schema/01core389.ldif
@@ -140,6 +140,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2136 NAME 'nsds5ReplicaCleanRUVNotified'
attributeTypes: ( 2.16.840.1.113730.3.1.2137 NAME 'nsds5ReplicaAbortCleanRUV' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2111 NAME 'tombstoneNumSubordinates' DESC 'count of immediate subordinates for tombstone entries' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation X-ORIGIN '389 directory server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2138 NAME 'nsslapd-readonly' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2142 NAME 'nsslapd-sasl-mapping-fallback' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
#
# objectclasses
#
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 3fcd8c9..1a414ed 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -251,6 +251,7 @@ int init_disk_monitoring;
int init_disk_logging_critical;
int init_disk_preserve_logging;
int init_ndn_cache_enabled;
+int init_sasl_mapping_fallback;
#ifdef MEMPOOL_EXPERIMENTAL
int init_mempool_switch;
#endif
@@ -427,6 +428,11 @@ static struct config_get_and_set {
NULL, 0,
(void**)&global_slapdFrontendConfig.readonly,
CONFIG_ON_OFF, NULL, &init_readonly},
+ {CONFIG_SASL_MAPPING_FALLBACK, config_set_sasl_mapping_fallback,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.sasl_mapping_fallback,
+ CONFIG_ON_OFF, (ConfigGetFunc)config_get_sasl_mapping_fallback,
+ &init_sasl_mapping_fallback},
{CONFIG_THREADNUMBER_ATTRIBUTE, config_set_threadnumber,
NULL, 0,
(void**)&global_slapdFrontendConfig.threadnumber,
@@ -1441,6 +1447,8 @@ FrontendConfig_init () {
init_ndn_cache_enabled = cfg->ndn_cache_enabled = LDAP_OFF;
cfg->ndn_cache_max_size = NDN_DEFAULT_SIZE;
cfg->ignore_vattrs = slapi_counter_new();
+ cfg->sasl_mapping_fallback = slapi_counter_new();
+ init_sasl_mapping_fallback = LDAP_OFF;
#ifdef MEMPOOL_EXPERIMENTAL
init_mempool_switch = cfg->mempool_switch = LDAP_ON;
@@ -1581,6 +1589,20 @@ config_set_ignore_vattrs (const char *attrname, char *value, char *errorbuf, int
}
int
+config_set_sasl_mapping_fallback (const char *attrname, char *value, char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal = LDAP_SUCCESS;
+ int val;
+
+ retVal = config_set_onoff ( attrname, value, &val, errorbuf, apply);
+ if(retVal == LDAP_SUCCESS){
+ slapi_counter_set_value(slapdFrontendConfig->sasl_mapping_fallback, val);
+ }
+ return retVal;
+}
+
+int
config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply )
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -3129,7 +3151,6 @@ config_set_readonly( const char *attrname, char *value, char *errorbuf, int appl
return retVal;
}
-
int
config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply ) {
int retVal = LDAP_SUCCESS;
@@ -4155,6 +4176,14 @@ config_get_ignore_vattrs()
}
int
+config_get_sasl_mapping_fallback()
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ return slapi_counter_get_value(slapdFrontendConfig->sasl_mapping_fallback);
+}
+
+int
config_get_disk_monitoring(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
int retVal;
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 778b916..169feb3 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -556,6 +556,8 @@ int config_set_allowed_sasl_mechs(const char *attrname, char *value, char *error
int config_get_schemamod();
int config_set_ignore_vattrs(const char *attrname, char *value, char *errorbuf, int apply);
int config_get_ignore_vattrs();
+int config_set_sasl_mapping_fallback(const char *attrname, char *value, char *errorbuf, int apply);
+int config_get_sasl_mapping_fallback();
PLHashNumber hashNocaseString(const void *key);
PRIntn hashNocaseCompare(const void *v1, const void *v2);
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index 6181474..78031dc 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -377,7 +377,8 @@ static Slapi_Entry *ids_sasl_user_to_entry(
break;
}
}
- if(map == NULL){
+ /* break if the next map is NULL, or we are not checking all the mappings */
+ if(map == NULL || !config_get_sasl_mapping_fallback()){
break;
}
}
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index edb75b7..669c059 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2054,6 +2054,7 @@ typedef struct _slapdEntryPoints {
#define CONFIG_NDN_CACHE_SIZE "nsslapd-ndn-cache-max-size"
#define CONFIG_ALLOWED_SASL_MECHS "nsslapd-allowed-sasl-mechanisms"
#define CONFIG_IGNORE_VATTRS "nsslapd-ignore-virtual-attrs"
+#define CONFIG_SASL_MAPPING_FALLBACK "nsslapd-sasl-mapping-fallback"
#ifdef MEMPOOL_EXPERIMENTAL
#define CONFIG_MEMPOOL_SWITCH_ATTRIBUTE "nsslapd-mempool"
@@ -2279,6 +2280,7 @@ typedef struct _slapdFrontendConfig {
/* atomic settings */
Slapi_Counter *ignore_vattrs;
+ Slapi_Counter *sasl_mapping_fallback;
} slapdFrontendConfig_t;
/* possible values for slapdFrontendConfig_t.schemareplace */
11 years, 2 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/pblock.c | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit d47fd4bc965e597c8d27368aa546d4012ce2546e
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Jan 7 14:55:29 2013 -0500
Ticket 495 - 1.2.11 - plugin dn is missing from pblock
Bug Description: on 1.2.11 when setting the backend in the pblock we do not
set the plugin dn if its missing. This causes inconsistencies
with internalModifiersname and internalcreatorsname.
Fix description: Set the plugin dn of the plugin if it is mising when setting the
backend in the pblock.
https://fedorahosted.org/389/ticket/495
Reviewed by: ?
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index 33559a7..1d1db1e 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -1966,6 +1966,10 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value )
switch ( arg ) {
case SLAPI_BACKEND:
pblock->pb_backend = (Slapi_Backend *) value;
+ if (pblock->pb_backend && (NULL == pblock->pb_plugin)) {
+ /* newly allocated pblock may not have backend plugin set. */
+ pblock->pb_plugin = (struct slapdplugin *)pblock->pb_backend->be_database;
+ }
break;
case SLAPI_BACKEND_COUNT:
pblock->pb_backend_count = *((int *) value);
11 years, 2 months
ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5.h | 4 +
ldap/servers/plugins/replication/repl5_plugins.c | 2
ldap/servers/plugins/replication/repl5_replica.c | 38 +++++++++++-----
ldap/servers/plugins/replication/repl5_replica_config.c | 33 +++++++++++++
ldap/servers/plugins/replication/repl5_ruv.c | 10 ++--
ldap/servers/slapd/csngen.c | 13 +++++
ldap/servers/slapd/slapi-private.h | 2
7 files changed, 83 insertions(+), 19 deletions(-)
New commits:
commit 93b6cefb66a5dea5af0d7753f6d26d8d6046d618
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Dec 21 14:01:55 2012 -0500
Ticket 532 - RUV is not getting updated for both Master and consumer
Bug Description: If you change the replica type, the RUV does not reflect the change. This is
partly due to the nsState attribute not being updated - specifically the csngen.
Fix Description: When we change the replica type, update the csn gen, add the new RUV element,
delete the old RUV element, clean the changelog RUV, update the state, and notify
the agmts. Then you must reinitialize the agmts after changing the replica type.
https://fedorahosted.org/389/ticket/532
Reviewed by: richm(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index f1d6ef4..7b0d6e4 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -61,6 +61,7 @@
#include "repl5_ruv.h"
#include "cl4.h"
+#define START_UPDATE_DELAY 2 /* 2 second */
#define REPLICA_TYPE_WINDOWS 1
#define REPLICA_TYPE_MULTIMASTER 0
#define REPL_DIRSYNC_CONTROL_OID "1.2.840.113556.1.4.841"
@@ -558,6 +559,7 @@ int replica_add_by_name (const char *name, Object *replica);
int replica_delete_by_name (const char *name);
Object* replica_get_by_name (const char *name);
void replica_flush(Replica *r);
+void replica_set_csn_assigned(Replica *r);
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);
@@ -584,6 +586,8 @@ void replica_set_ruv_dirty (Replica *r);
void replica_write_ruv (Replica *r);
char *replica_get_dn(Replica *r);
void replica_check_for_tasks(Replica*r, Slapi_Entry *e);
+void replica_update_state (time_t when, void *arg);
+void replica_reset_csn_pl(Replica *r);
/* The functions below handles the state flag */
/* Current internal state flags */
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index efd7e18..43c1596 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -1213,7 +1213,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
op_params->target_address.uniqueid = slapi_ch_strdup (uniqueid);
}
- if( is_cleaned_rid(csn_get_replicaid(op_params->csn))){
+ if( op_params->csn && is_cleaned_rid(csn_get_replicaid(op_params->csn))){
/* this RID has been cleaned */
object_release (repl_obj);
return 0;
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 3d7677b..82362d6 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -51,7 +51,6 @@
#include "cl5_api.h"
#define RUV_SAVE_INTERVAL (30 * 1000) /* 30 seconds */
-#define START_UPDATE_DELAY 2 /* 2 second */
#define REPLICA_RDN "cn=replica"
#define CHANGELOG_RDN "cn=legacy changelog"
@@ -107,7 +106,6 @@ static int _replica_check_validity (const Replica *r);
static int _replica_init_from_config (Replica *r, Slapi_Entry *e, char *errortext);
static int _replica_update_entry (Replica *r, Slapi_Entry *e, char *errortext);
static int _replica_configure_ruv (Replica *r, PRBool isLocked);
-static void _replica_update_state (time_t when, void *arg);
static char * _replica_get_config_dn (const Slapi_DN *root);
static char * _replica_type_as_string (const Replica *r);
/* DBDB, I think this is probably bogus : */
@@ -248,7 +246,7 @@ replica_new_from_entry (Slapi_Entry *e, char *errortext, PRBool is_add_operation
In that case the updated would fail but nothing bad would happen. The next
scheduled update would save the state */
repl_name = slapi_ch_strdup (r->repl_name);
- r->repl_eqcxt_rs = slapi_eq_repeat(_replica_update_state, repl_name,
+ r->repl_eqcxt_rs = slapi_eq_repeat(replica_update_state, repl_name,
current_time () + START_UPDATE_DELAY, RUV_SAVE_INTERVAL);
if (r->tombstone_reap_interval > 0)
@@ -295,10 +293,17 @@ replica_flush(Replica *r)
PR_Unlock(r->repl_lock);
/* This function take the Lock Inside */
/* And also write the RUV */
- _replica_update_state((time_t)0, r->repl_name);
+ replica_update_state((time_t)0, r->repl_name);
}
}
+void
+replica_set_csn_assigned(Replica *r)
+{
+ PR_Lock(r->repl_lock);
+ r->repl_csn_assigned = PR_TRUE;
+ PR_Unlock(r->repl_lock);
+}
/*
* Deallocate a replica. arg should point to the address of a
@@ -928,6 +933,19 @@ replica_set_updatedn (Replica *r, const Slapi_ValueSet *vs, int mod_op)
PR_Unlock(r->repl_lock);
}
+void
+replica_reset_csn_pl(Replica *r)
+{
+ PR_Lock(r->repl_lock);
+
+ if (NULL != r->min_csn_pl){
+ csnplFree (&r->min_csn_pl);
+ }
+ r->min_csn_pl = csnplNew();
+
+ PR_Unlock(r->repl_lock);
+}
+
/* gets current replica generation for this replica */
char *replica_get_generation (const Replica *r)
{
@@ -1251,8 +1269,8 @@ replica_set_enabled (Replica *r, PRBool enable)
{
if (r->repl_eqcxt_rs == NULL) /* event is not already registered */
{
- repl_name = slapi_ch_strdup (r->repl_name);
- r->repl_eqcxt_rs = slapi_eq_repeat(_replica_update_state, repl_name,
+ repl_name = slapi_ch_strdup (r->repl_name);
+ r->repl_eqcxt_rs = slapi_eq_repeat(replica_update_state, repl_name,
current_time() + START_UPDATE_DELAY, RUV_SAVE_INTERVAL);
}
}
@@ -2349,8 +2367,8 @@ done:
/* NOTE - this is the only non-api function that performs locking because
it is called by the event queue */
-static void
-_replica_update_state (time_t when, void *arg)
+void
+replica_update_state (time_t when, void *arg)
{
int rc;
const char *replica_name = (const char *)arg;
@@ -2420,7 +2438,7 @@ _replica_update_state (time_t when, void *arg)
dn = _replica_get_config_dn (r->repl_root);
if (NULL == dn) {
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "_replica_update_state: failed to get the config dn for %s\n",
+ "replica_update_state: failed to get the config dn for %s\n",
slapi_sdn_get_dn (r->repl_root));
PR_Unlock(r->repl_lock);
goto done;
@@ -2461,7 +2479,7 @@ _replica_update_state (time_t when, void *arg)
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
if (rc != LDAP_SUCCESS)
{
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "_replica_update_state: "
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_update_state: "
"failed to update state of csn generator for replica %s: LDAP "
"error - %d\n", slapi_sdn_get_dn(r->repl_root), rc);
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index aef9c13..dd3e65e 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -500,8 +500,12 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
if (new_repl_id || new_repl_type)
{
*returncode = replica_config_change_type_and_id(r, new_repl_type, new_repl_id, errortext, apply_mods);
+ PR_Unlock (s_configLock);
+ replica_update_state(0, (void *)replica_get_name(r));
+ PR_Lock (s_configLock);
slapi_ch_free_string(&new_repl_id);
slapi_ch_free_string(&new_repl_type);
+ agmtlist_notify_all(pb);
}
}
@@ -808,10 +812,35 @@ replica_config_change_type_and_id (Replica *r, const char *new_type,
if (apply_mods)
{
+ Object *ruv_obj, *gen_obj;
+ RUV *ruv;
+ CSNGen *gen;
+
+ ruv_obj = replica_get_ruv(r);
+ if(ruv_obj){
+ /* we need to rewrite the repl_csngen with the new rid */
+ ruv = object_get_data (ruv_obj);
+ gen_obj = replica_get_csngen (r);
+ if(gen_obj){
+ const char *purl = multimaster_get_local_purl();
+
+ gen = (CSNGen*) object_get_data (gen_obj);
+ csngen_rewrite_rid(gen, rid);
+ if(purl && type == REPLICA_TYPE_UPDATABLE){
+ ruv_add_replica(ruv, rid, purl);
+ replica_reset_csn_pl(r);
+ }
+ ruv_delete_replica(ruv, oldrid);
+ replica_set_ruv_dirty(r);
+ cl5CleanRUV(oldrid);
+ replica_set_csn_assigned(r);
+ }
+ object_release(ruv_obj);
+ }
replica_set_type (r, type);
- replica_set_rid(r, rid);
+ replica_set_rid(r, rid);
- /* Set the mapping tree node, and the list of referrals */
+ /* Set the mapping tree node, and the list of referrals */
/* if this server is a 4.0 consumer the referrals are set by legacy plugin */
if (!replica_is_legacy_consumer(r))
consumer5_set_mapping_tree_state_for_replica(r, NULL);
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index b52dd49..972b812 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -466,7 +466,7 @@ ruv_add_replica (RUV *ruv, ReplicaId rid, const char *replica_purl)
{
replica = ruvAddReplicaNoCSN (ruv, rid, replica_purl);
}
-
+
slapi_rwlock_unlock (ruv->lock);
if (replica)
@@ -514,7 +514,7 @@ ruv_add_index_replica (RUV *ruv, ReplicaId rid, const char *replica_purl, int in
{
replica = ruvAddIndexReplicaNoCSN (ruv, rid, replica_purl, index);
}
-
+
slapi_rwlock_unlock (ruv->lock);
if (replica)
@@ -1983,14 +1983,14 @@ ruv_move_local_supplier_to_first(RUV *ruv, ReplicaId aRid)
PR_ASSERT(ruv);
- slapi_rwlock_wrlock (ruv->lock);
-
+ slapi_rwlock_wrlock (ruv->lock);
+
elem = (RUVElement *)dl_delete(ruv->elements,(const void*)&aRid, ruvReplicaCompare, 0);
if (elem) {
dl_add_index(ruv->elements, elem, 1);
rc = RUV_SUCCESS;
}
-
+
slapi_rwlock_unlock (ruv->lock);
return rc;
diff --git a/ldap/servers/slapd/csngen.c b/ldap/servers/slapd/csngen.c
index 7e0bdb6..464a59e 100644
--- a/ldap/servers/slapd/csngen.c
+++ b/ldap/servers/slapd/csngen.c
@@ -306,11 +306,22 @@ void csngen_abort_csn (CSNGen *gen, const CSN *csn)
_csngen_call_callbacks (gen, csn, 1);
}
+void csngen_rewrite_rid(CSNGen *gen, ReplicaId rid)
+{
+ if (gen == NULL){
+ return;
+ }
+ slapi_rwlock_wrlock (gen->lock);
+ gen->state.rid = rid;
+ slapi_rwlock_unlock (gen->lock);
+
+}
+
/* this function should be called when a remote CSN for the same part of
the dit becomes known to the server (for instance, as part of RUV during
replication session. In response, the generator would adjust its notion
of time so that it does not generate smaller csns */
-int csngen_adjust_time (CSNGen *gen, const CSN* csn)
+int csngen_adjust_time(CSNGen *gen, const CSN* csn)
{
time_t remote_time, remote_offset, cur_time;
PRUint16 remote_seqnum;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index b3888ef..225c7aa 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -264,6 +264,8 @@ void csngen_abort_csn (CSNGen *gen, const CSN *csn);
int csngen_adjust_time (CSNGen *gen, const CSN* csn);
/* returns PR_TRUE if the csn was generated by this generator and
PR_FALSE otherwise. */
+void csngen_rewrite_rid(CSNGen *gen, ReplicaId rid);
+
PRBool csngen_is_local_csn(const CSNGen *gen, const CSN *csn);
/* returns current state of the generator so that it can be saved in the DIT */
11 years, 2 months
ldap/servers
by Mark Reynolds
ldap/servers/slapd/sasl_map.c | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit a0986e6159564073c8cb6c7534c9e0e5dac1274f
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Jan 7 11:20:37 2013 -0500
Ticket 534 - sasl mapping fallback
Fix memory leak
https://fedorahosted.org/389/ticket/534
Thanks richm!
diff --git a/ldap/servers/slapd/sasl_map.c b/ldap/servers/slapd/sasl_map.c
index 96905ec..60bf4a7 100644
--- a/ldap/servers/slapd/sasl_map.c
+++ b/ldap/servers/slapd/sasl_map.c
@@ -417,6 +417,8 @@ sasl_map_config_parse_entry(Slapi_Entry *entry, sasl_map_data **new_dp)
slapi_ch_free_string(&basedntemplate);
slapi_ch_free_string(&filtertemplate);
}
+ slapi_ch_free_string(&priority_str);
+
return ret;
}
11 years, 2 months
ldap/schema ldap/servers
by Mark Reynolds
ldap/schema/01core389.ldif | 3
ldap/servers/slapd/fe.h | 21 ++++
ldap/servers/slapd/fedse.c | 67 ++++++-------
ldap/servers/slapd/sasl_map.c | 208 +++++++++++++++++++++++++++++-------------
ldap/servers/slapd/saslbind.c | 62 +++++++-----
5 files changed, 239 insertions(+), 122 deletions(-)
New commits:
commit 83f292c9b4e3f68482e9773c30ce96d6129fd68f
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Dec 21 17:24:29 2012 -0500
Ticket 534 - RFE: Add SASL mappings fallback
Bug Description: If the mapping fails to find an entry the bind fails without
checking if other mappings would also match.
Fix Description: Added the fallback functionality. Also added the ability to prioritize
the mapping order, and to be able to modify the mappings while
the server is up.
https://fedorahosted.org/389/ticket/534
Reviewed by: noriko & richm (Thanks!)
diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif
index fb707d3..d22edaa 100644
--- a/ldap/schema/01core389.ldif
+++ b/ldap/schema/01core389.ldif
@@ -113,6 +113,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.9999999 NAME 'nsds5debugreplicatimeout'
attributeTypes: ( 2.16.840.1.113730.3.1.2064 NAME 'nsSaslMapRegexString' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2065 NAME 'nsSaslMapBaseDNTemplate' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2066 NAME 'nsSaslMapFilterTemplate' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2142 NAME 'nsSaslMapPriority' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( nsCertfile-oid NAME 'nsCertfile' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape' )
attributeTypes: ( nsKeyfile-oid NAME 'nsKeyfile' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape' )
attributeTypes: ( nsSSL2-oid NAME 'nsSSL2' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape' )
@@ -152,7 +153,7 @@ objectClasses: ( 2.16.840.1.113730.3.2.108 NAME 'nsDS5Replica' DESC 'Netscape de
objectClasses: ( 2.16.840.1.113730.3.2.113 NAME 'nsTombstone' DESC 'Netscape defined objectclass' SUP top MAY ( nsParentUniqueId $ nscpEntryDN ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.103 NAME 'nsDS5ReplicationAgreement' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( nsds5ReplicaCleanRUVNotified $ nsDS5ReplicaHost $ nsDS5ReplicaPort $ nsDS5ReplicaTransportInfo $ nsDS5ReplicaBindDN $ nsDS5ReplicaCredentials $ nsDS5ReplicaBindMethod $ nsDS5ReplicaRoot $ nsDS5ReplicatedAttributeList $ nsDS5ReplicatedAttributeListTotal $ nsDS5ReplicaUpdateSchedule $ nsds5BeginReplicaRefresh $ description $ nsds50ruv $ nsruvReplicaLastModified $ nsds5ReplicaTimeout $ nsds5replicaChangesSentSinceStartup $ nsds5replicaLastUpdateEnd $ nsds5replicaLastUpdateStart $ nsds5replicaLastUpdateStatus $ nsds5replicaUpdateInProgress $ nsds5replicaLastInitEnd $ nsds5ReplicaEnabled $ nsds5replicaLastInitStart $ nsds5replicaLastInitStatus $ nsds5debugreplicatimeout $ nsds5replicaBusyWaitTime $ nsds5ReplicaStripAttrs $ nsds5replicaSessionPauseTime ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.39 NAME 'nsslapdConfig' DESC 'Netscape defined objectclass' SUP top MAY ( cn ) X-ORIGIN 'Netscape Directory Server' )
-objectClasses: ( 2.16.840.1.113730.3.2.317 NAME 'nsSaslMapping' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSaslMapRegexString $ nsSaslMapBaseDNTemplate $ nsSaslMapFilterTemplate ) X-ORIGIN 'Netscape Directory Server' )
+objectClasses: ( 2.16.840.1.113730.3.2.317 NAME 'nsSaslMapping' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSaslMapRegexString $ nsSaslMapBaseDNTemplate $ nsSaslMapFilterTemplate ) MAY ( nsSaslMapPriority ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.43 NAME 'nsSNMP' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSNMPEnabled ) MAY ( nsSNMPOrganization $ nsSNMPLocation $ nsSNMPContact $ nsSNMPDescription $ nsSNMPName $ nsSNMPMasterHost $ nsSNMPMasterPort ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( nsEncryptionConfig-oid NAME 'nsEncryptionConfig' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( nsCertfile $ nsKeyfile $ nsSSL2 $ nsSSL3 $ nsTLS1 $ nsSSLSessionTimeout $ nsSSL3SessionTimeout $ nsSSLClientAuth $ nsSSL2Ciphers $ nsSSL3Ciphers $ nsSSLSupportedCiphers) X-ORIGIN 'Netscape' )
objectClasses: ( nsEncryptionModule-oid NAME 'nsEncryptionModule' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( nsSSLToken $ nsSSLPersonalityssl $ nsSSLActivation ) X-ORIGIN 'Netscape' )
diff --git a/ldap/servers/slapd/fe.h b/ldap/servers/slapd/fe.h
index 3a985cb..d21d108 100644
--- a/ldap/servers/slapd/fe.h
+++ b/ldap/servers/slapd/fe.h
@@ -190,10 +190,29 @@ int sasl_io_cleanup(Connection *c, void *data);
/*
* sasl_map.c
*/
+typedef struct sasl_map_data_ sasl_map_data;
+struct sasl_map_data_ {
+ char *name;
+ char *regular_expression;
+ char *template_base_dn;
+ char *template_search_filter;
+ int priority;
+ sasl_map_data *next; /* For linked list */
+ sasl_map_data *prev;
+};
+
+typedef struct _sasl_map_private {
+ Slapi_RWLock *lock;
+ sasl_map_data *map_data_list;
+} sasl_map_private;
+
int sasl_map_config_add(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg);
int sasl_map_config_delete(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg);
-int sasl_map_domap(char *sasl_user, char *sasl_realm, char **ldap_search_base, char **ldap_search_filter);
+int sasl_map_config_modify(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg);
+int sasl_map_domap(sasl_map_data **map, char *sasl_user, char *sasl_realm, char **ldap_search_base, char **ldap_search_filter);
int sasl_map_init();
int sasl_map_done();
+void sasl_map_read_lock();
+void sasl_map_read_unlock();
#endif
diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c
index dbfba16..5434c75 100644
--- a/ldap/servers/slapd/fedse.c
+++ b/ldap/servers/slapd/fedse.c
@@ -1767,7 +1767,7 @@ search_snmp(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *ret
int
setup_internal_backends(char *configdir)
{
- int rc = init_schema_dse(configdir);
+ int rc = init_schema_dse(configdir);
Slapi_DN config;
slapi_sdn_init_ndn_byref(&config,"cn=config");
@@ -1777,15 +1777,15 @@ setup_internal_backends(char *configdir)
rc= init_dse_file(configdir, &config);
}
- if(rc)
- {
+ if(rc)
+ {
Slapi_DN monitor;
Slapi_DN counters;
Slapi_DN snmp;
Slapi_DN root;
- Slapi_Backend *be;
- Slapi_DN encryption;
- Slapi_DN saslmapping;
+ Slapi_Backend *be;
+ Slapi_DN encryption;
+ Slapi_DN saslmapping;
slapi_sdn_init_ndn_byref(&monitor,"cn=monitor");
slapi_sdn_init_ndn_byref(&counters,"cn=counters,cn=monitor");
@@ -1795,50 +1795,51 @@ setup_internal_backends(char *configdir)
slapi_sdn_init_ndn_byref(&encryption,"cn=encryption,cn=config");
slapi_sdn_init_ndn_byref(&saslmapping,"cn=mapping,cn=sasl,cn=config");
- /* Search */
- dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",read_config_dse,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&monitor,LDAP_SCOPE_BASE,"(objectclass=*)",monitor_info,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&root,LDAP_SCOPE_BASE,"(objectclass=*)",read_root_dse,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&monitor,LDAP_SCOPE_SUBTREE,EGG_FILTER,search_easter_egg,NULL); /* Egg */
- dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&counters,LDAP_SCOPE_BASE,"(objectclass=*)",search_counters,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&snmp,LDAP_SCOPE_BASE,"(objectclass=*)",search_snmp,NULL);
+ /* Search */
+ dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",read_config_dse,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&monitor,LDAP_SCOPE_BASE,"(objectclass=*)",monitor_info,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&root,LDAP_SCOPE_BASE,"(objectclass=*)",read_root_dse,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&monitor,LDAP_SCOPE_SUBTREE,EGG_FILTER,search_easter_egg,NULL); /* Egg */
+ dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&counters,LDAP_SCOPE_BASE,"(objectclass=*)",search_counters,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&snmp,LDAP_SCOPE_BASE,"(objectclass=*)",search_snmp,NULL);
dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&encryption,LDAP_SCOPE_BASE,"(objectclass=*)",search_encryption,NULL);
- /* Modify */
- dse_register_callback(pfedse,SLAPI_OPERATION_MODIFY,DSE_FLAG_PREOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",modify_config_dse,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_MODIFY,DSE_FLAG_POSTOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",postop_modify_config_dse,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_MODIFY,DSE_FLAG_PREOP,&root,LDAP_SCOPE_BASE,"(objectclass=*)",modify_root_dse,NULL);
+ /* Modify */
+ dse_register_callback(pfedse,SLAPI_OPERATION_MODIFY,DSE_FLAG_PREOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",modify_config_dse,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_MODIFY,DSE_FLAG_POSTOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",postop_modify_config_dse,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_MODIFY,DSE_FLAG_PREOP,&root,LDAP_SCOPE_BASE,"(objectclass=*)",modify_root_dse,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_MODIFY,DSE_FLAG_PREOP,&saslmapping,LDAP_SCOPE_SUBTREE,"(objectclass=nsSaslMapping)",sasl_map_config_modify,NULL);
- /* Delete */
- dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&monitor,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&counters,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&snmp,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
- dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&root,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
+ /* Delete */
+ dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&monitor,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&counters,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&snmp,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
+ dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&root,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&encryption,LDAP_SCOPE_BASE,"(objectclass=*)",dont_allow_that,NULL);
-
dse_register_callback(pfedse,SLAPI_OPERATION_DELETE,DSE_FLAG_PREOP,&saslmapping,LDAP_SCOPE_SUBTREE,"(objectclass=nsSaslMapping)",sasl_map_config_delete,NULL);
- /* Write */
- dse_register_callback(pfedse,DSE_OPERATION_WRITE,DSE_FLAG_PREOP,&monitor,LDAP_SCOPE_SUBTREE,EGG_FILTER,dont_allow_that,NULL); /* Egg */
+ /* Write */
+ dse_register_callback(pfedse,DSE_OPERATION_WRITE,DSE_FLAG_PREOP,&monitor,LDAP_SCOPE_SUBTREE,EGG_FILTER,dont_allow_that,NULL); /* Egg */
+ /* Add */
dse_register_callback(pfedse,SLAPI_OPERATION_ADD,DSE_FLAG_PREOP,&saslmapping,LDAP_SCOPE_SUBTREE,"(objectclass=nsSaslMapping)",sasl_map_config_add,NULL);
- be= be_new_internal(pfedse, "DSE", DSE_BACKEND);
- be_addsuffix(be,&root);
- be_addsuffix(be,&monitor);
- be_addsuffix(be,&config);
+ be = be_new_internal(pfedse, "DSE", DSE_BACKEND);
+ be_addsuffix(be,&root);
+ be_addsuffix(be,&monitor);
+ be_addsuffix(be,&config);
add_internal_entries();
- add_easter_egg_entry();
+ add_easter_egg_entry();
slapi_sdn_done(&monitor);
slapi_sdn_done(&counters);
slapi_sdn_done(&snmp);
slapi_sdn_done(&root);
slapi_sdn_done(&saslmapping);
- } else {
+ } else {
slapi_log_error( SLAPI_LOG_FATAL, "dse",
"Please edit the file to correct the reported problems"
" and then restart the server.\n" );
@@ -1846,7 +1847,7 @@ setup_internal_backends(char *configdir)
}
slapi_sdn_done(&config);
- return rc;
+ return rc;
}
int fedse_create_startOK(char *filename, char *startokfilename, const char *configdir)
diff --git a/ldap/servers/slapd/sasl_map.c b/ldap/servers/slapd/sasl_map.c
index 7e7cfb8..96905ec 100644
--- a/ldap/servers/slapd/sasl_map.c
+++ b/ldap/servers/slapd/sasl_map.c
@@ -48,25 +48,9 @@
* Map SASL identities to LDAP searches
*/
-/*
- * We maintain a list of mappings to consult
- */
-
-typedef struct sasl_map_data_ sasl_map_data;
-struct sasl_map_data_ {
- char *name;
- char *regular_expression;
- char *template_base_dn;
- char *template_search_filter;
- sasl_map_data *next; /* For linked list */
-};
-
-typedef struct _sasl_map_private {
- PRLock *lock;
- sasl_map_data *map_data_list;
-} sasl_map_private;
-
static char * configDN = "cn=mapping,cn=sasl,cn=config";
+#define LOW_PRIORITY 100
+#define LOW_PRIORITY_STR "100"
/*
* DBDB: this is ugly, but right now there is _no_ server-wide
@@ -87,7 +71,7 @@ sasl_map_private *sasl_map_get_global_priv()
static
sasl_map_private *sasl_map_new_private()
{
- PRLock *new_lock = PR_NewLock();
+ Slapi_RWLock *new_lock = slapi_new_rwlock();
sasl_map_private *new_priv = NULL;
if (NULL == new_lock) {
return NULL;
@@ -100,20 +84,23 @@ sasl_map_private *sasl_map_new_private()
static void
sasl_map_free_private(sasl_map_private **priv)
{
- PR_DestroyLock((*priv)->lock);
+ slapi_destroy_rwlock((*priv)->lock);
slapi_ch_free((void**)priv);
*priv = NULL;
}
/* This function does a shallow copy on the payload data supplied, so the caller should not free it, and it needs to be allocated using slapi_ch_malloc() */
static
-sasl_map_data *sasl_map_new_data(char *name, char *regex, char *dntemplate, char *filtertemplate)
+sasl_map_data *sasl_map_new_data(char *name, char *regex, char *dntemplate, char *filtertemplate, int priority)
{
sasl_map_data *new_dp = (sasl_map_data *) slapi_ch_calloc(1,sizeof(sasl_map_data));
new_dp->name = name;
new_dp->regular_expression = regex;
new_dp->template_base_dn = dntemplate;
new_dp->template_search_filter = filtertemplate;
+ new_dp->priority = priority;
+ new_dp->next = NULL;
+ new_dp->prev = NULL;
return new_dp;
}
@@ -139,31 +126,39 @@ sasl_map_remove_list_entry(sasl_map_private *priv, char *removeme)
int ret = 0;
int foundit = 0;
sasl_map_data *current = NULL;
- sasl_map_data *previous = NULL;
- PR_Lock(priv->lock);
+ sasl_map_data *prev = NULL;
+ sasl_map_data *next = NULL;
+
+ slapi_rwlock_wrlock(priv->lock);
current = priv->map_data_list;
while (current) {
+ next = current->next;
if (0 == strcmp(current->name,removeme)) {
foundit = 1;
- if (previous) {
+ prev = current->prev;
+ if (prev) {
/* Unlink it */
- previous->next = current->next;
+ if(next){
+ next->prev = prev;
+ }
+ prev->next = next;
} else {
/* That was the first list entry */
priv->map_data_list = current->next;
+ priv->map_data_list->prev = NULL;
}
/* Payload free */
sasl_map_free_data(¤t);
/* And no need to look further */
break;
}
- previous = current;
- current = current->next;
+ current = next;
}
+ slapi_rwlock_unlock(priv->lock);
if (!foundit) {
ret = -1;
}
- PR_Unlock(priv->lock);
+
return ret;
}
@@ -208,15 +203,21 @@ sasl_map_insert_list_entry(sasl_map_private *priv, sasl_map_data *dp)
int ret = 0;
int ishere = 0;
sasl_map_data *current = NULL;
+ sasl_map_data *last = NULL;
+ sasl_map_data *prev = NULL;
+
if (NULL == dp) {
return ret;
}
- PR_Lock(priv->lock);
+
+ slapi_rwlock_wrlock(priv->lock);
+
/* Check to see if it's here already */
current = priv->map_data_list;
while (current) {
if (0 == sasl_map_cmp_data(current, dp)) {
ishere = 1;
+ break;
}
if (current->next) {
current = current->next;
@@ -225,15 +226,39 @@ sasl_map_insert_list_entry(sasl_map_private *priv, sasl_map_data *dp)
}
}
if (ishere) {
+ slapi_rwlock_unlock(priv->lock);
return -1;
}
- /* current now points to the end of the list or NULL */
+
+ /* insert the map in its proper place */
if (NULL == priv->map_data_list) {
priv->map_data_list = dp;
} else {
- current->next = dp;
+ current = priv->map_data_list;
+ while (current) {
+ last = current;
+ if(current->priority > dp->priority){
+ prev = current->prev;
+ if(prev){
+ prev->next = dp;
+ dp->prev = prev;
+ } else {
+ /* this is now the head of the list */
+ priv->map_data_list = dp;
+ }
+ current->prev = dp;
+ dp->next = current;
+ slapi_rwlock_unlock(priv->lock);
+ return ret;
+ }
+ current = current->next;
+ }
+ /* add the map at the end of the list */
+ last->next = dp;
+ dp->prev = last;
}
- PR_Unlock(priv->lock);
+ slapi_rwlock_unlock(priv->lock);
+
return ret;
}
@@ -342,9 +367,11 @@ static int
sasl_map_config_parse_entry(Slapi_Entry *entry, sasl_map_data **new_dp)
{
int ret = 0;
+ int priority;
char *regex = NULL;
char *basedntemplate = NULL;
char *filtertemplate = NULL;
+ char *priority_str = NULL;
char *map_name = NULL;
*new_dp = NULL;
@@ -352,21 +379,43 @@ sasl_map_config_parse_entry(Slapi_Entry *entry, sasl_map_data **new_dp)
basedntemplate = slapi_entry_attr_get_charptr( entry, "nsSaslMapBaseDNTemplate" );
filtertemplate = slapi_entry_attr_get_charptr( entry, "nsSaslMapFilterTemplate" );
map_name = slapi_entry_attr_get_charptr( entry, "cn" );
+ priority_str = slapi_entry_attr_get_charptr( entry, "nsSaslMapPriority" );
+ if(priority_str){
+ priority = atoi(priority_str);
+ } else {
+ priority = LOW_PRIORITY;
+ }
+ if(priority == 0 || priority > LOW_PRIORITY){
+ struct berval desc;
+ struct berval *newval[2] = {0, 0};
+
+ desc.bv_val = LOW_PRIORITY_STR;
+ desc.bv_len = strlen(desc.bv_val);
+ newval[0] = &desc;
+ if (entry_replace_values(entry, "nsSaslMapPriority", newval) != 0){
+ LDAPDebug( LDAP_DEBUG_TRACE, "sasl_map_config_parse_entry: failed to reset priority to (%d)\n",
+ LOW_PRIORITY,0,0);
+ } else {
+ LDAPDebug( LDAP_DEBUG_ANY, "sasl_map_config_parse_entry: resetting nsSaslMapPriority to lowest priority(%d)\n",
+ LOW_PRIORITY,0,0);
+ }
+ priority = LOW_PRIORITY;
+ }
if ( (NULL == map_name) || (NULL == regex) ||
(NULL == basedntemplate) || (NULL == filtertemplate) ) {
/* Invalid entry */
ret = -1;
} else {
/* Make the new dp */
- *new_dp = sasl_map_new_data(map_name, regex, basedntemplate, filtertemplate);
+ *new_dp = sasl_map_new_data(map_name, regex, basedntemplate, filtertemplate, priority);
}
if (ret) {
- slapi_ch_free((void **) &map_name);
- slapi_ch_free((void **) ®ex);
- slapi_ch_free((void **) &basedntemplate);
- slapi_ch_free((void **) &filtertemplate);
+ slapi_ch_free_string(&map_name);
+ slapi_ch_free_string(®ex);
+ slapi_ch_free_string(&basedntemplate);
+ slapi_ch_free_string(&filtertemplate);
}
return ret;
}
@@ -431,6 +480,35 @@ sasl_map_config_add(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e,
}
int
+sasl_map_config_modify(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg)
+{
+ sasl_map_private *priv = sasl_map_get_global_priv();
+ sasl_map_data *dp;
+ char *map_name = NULL;
+ int ret = SLAPI_DSE_CALLBACK_ERROR;
+
+ if((map_name = slapi_entry_attr_get_charptr( entryBefore, "cn" )) == NULL){
+ LDAPDebug( LDAP_DEBUG_TRACE, "sasl_map_config_modify: could not find name of map\n",0,0,0);
+ return ret;
+ }
+ if(sasl_map_remove_list_entry(priv, map_name) == 0){
+ ret = sasl_map_config_parse_entry(e, &dp);
+ if (!ret && dp) {
+ ret = sasl_map_insert_list_entry(priv, dp);
+ if(ret == 0){
+ ret = SLAPI_DSE_CALLBACK_OK;
+ }
+ }
+ }
+ if(ret == SLAPI_DSE_CALLBACK_ERROR){
+ LDAPDebug( LDAP_DEBUG_TRACE, "sasl_map_config_modify: failed to update map(%s)\n",map_name,0,0);
+ }
+ slapi_ch_free_string(&map_name);
+
+ return ret;
+}
+
+int
sasl_map_config_delete(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg)
{
int ret = 0;
@@ -485,30 +563,20 @@ int sasl_map_done()
}
/* Free the map list */
- PR_Lock(priv->lock);
+ slapi_rwlock_wrlock(priv->lock);
dp = priv->map_data_list;
while (dp) {
sasl_map_data *dp_next = dp->next;
sasl_map_free_data(&dp);
dp = dp_next;
}
- PR_Unlock(priv->lock);
+ slapi_rwlock_unlock(priv->lock);
/* Free the private structure */
sasl_map_free_private(&priv);
return ret;
}
-static sasl_map_data*
-sasl_map_first(sasl_map_private *priv)
-{
- sasl_map_data *result = NULL;
- PR_Lock(priv->lock);
- result = priv->map_data_list;
- PR_Unlock(priv->lock);
- return result;
-}
-
static int
sasl_map_check(sasl_map_data *dp, char *sasl_user_and_realm, char **ldap_search_base, char **ldap_search_filter)
{
@@ -610,28 +678,31 @@ sasl_map_str_concat(char *s1, char *s2)
* returns 1 if matched, 0 otherwise
*/
int
-sasl_map_domap(char *sasl_user, char *sasl_realm, char **ldap_search_base, char **ldap_search_filter)
+sasl_map_domap(sasl_map_data **map, char *sasl_user, char *sasl_realm, char **ldap_search_base, char **ldap_search_filter)
{
- int ret = 0;
- sasl_map_data *this_map = NULL;
- char *sasl_user_and_realm = NULL;
sasl_map_private *priv = sasl_map_get_global_priv();
+ char *sasl_user_and_realm = NULL;
+ int ret = 0;
+
+ LDAPDebug( LDAP_DEBUG_TRACE, "-> sasl_map_domap\n", 0, 0, 0 );
+ if(map == NULL){
+ LDAPDebug( LDAP_DEBUG_TRACE, "<- sasl_map_domap: Internal error, mapping is NULL\n",0,0,0);
+ return ret;
+ }
*ldap_search_base = NULL;
*ldap_search_filter = NULL;
- LDAPDebug( LDAP_DEBUG_TRACE, "-> sasl_map_domap\n", 0, 0, 0 );
sasl_user_and_realm = sasl_map_str_concat(sasl_user,sasl_realm);
/* Walk the list of maps */
- this_map = sasl_map_first(priv);
- while (this_map) {
- int matched = 0;
+ if(*map == NULL)
+ *map = priv->map_data_list;
+ while (*map) {
/* If one matches, then make the search params */
- LDAPDebug( LDAP_DEBUG_TRACE, "sasl_map_domap - trying map [%s]\n", this_map->name, 0, 0 );
- matched = sasl_map_check(this_map, sasl_user_and_realm, ldap_search_base, ldap_search_filter);
- if (1 == matched) {
- ret = 1;
+ LDAPDebug( LDAP_DEBUG_TRACE, "sasl_map_domap - trying map [%s]\n", (*map)->name, 0, 0 );
+ if((ret = sasl_map_check(*map, sasl_user_and_realm, ldap_search_base, ldap_search_filter))){
+ *map = sasl_map_next(*map);
break;
}
- this_map = sasl_map_next(this_map);
+ *map = sasl_map_next(*map);
}
if (sasl_user_and_realm) {
slapi_ch_free((void**)&sasl_user_and_realm);
@@ -640,3 +711,16 @@ sasl_map_domap(char *sasl_user, char *sasl_realm, char **ldap_search_base, char
return ret;
}
+void
+sasl_map_read_lock()
+{
+ sasl_map_private *priv = sasl_map_get_global_priv();
+ slapi_rwlock_rdlock(priv->lock);
+}
+
+void
+sasl_map_read_unlock()
+{
+ sasl_map_private *priv = sasl_map_get_global_priv();
+ slapi_rwlock_unlock(priv->lock);
+}
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index f9ddbfc..6181474 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -323,14 +323,15 @@ static Slapi_Entry *ids_sasl_user_to_entry(
const char *user_realm
)
{
- int found = 0;
- int attrsonly = 0, scope = LDAP_SCOPE_SUBTREE;
LDAPControl **ctrls = NULL;
+ sasl_map_data *map = NULL;
Slapi_Entry *entry = NULL;
char **attrs = NULL;
- int regexmatch = 0;
char *base = NULL;
char *filter = NULL;
+ int attrsonly = 0, scope = LDAP_SCOPE_SUBTREE;
+ int regexmatch = 0;
+ int found = 0;
/* Check for wildcards in the authid and realm. If we encounter one,
* just fail the mapping without performing a costly internal search. */
@@ -345,31 +346,42 @@ static Slapi_Entry *ids_sasl_user_to_entry(
}
/* New regex-based identity mapping */
- regexmatch = sasl_map_domap((char*)user, (char*)user_realm, &base, &filter);
- if (regexmatch) {
- ids_sasl_user_search(base, scope, filter,
- ctrls, attrs, attrsonly,
- &entry, &found);
-
- if (found == 1) {
- LDAPDebug(LDAP_DEBUG_TRACE, "sasl user search found this entry: dn:%s, "
- "matching filter=%s\n", entry->e_sdn.dn, filter, 0);
- } else if (found == 0) {
- LDAPDebug(LDAP_DEBUG_TRACE, "sasl user search found no entries matching "
- "filter=%s\n", filter, 0, 0);
- } else {
- LDAPDebug(LDAP_DEBUG_TRACE, "sasl user search found more than one entry "
- "matching filter=%s\n", filter, 0, 0);
- if (entry) {
- slapi_entry_free(entry);
- entry = NULL;
+ sasl_map_read_lock();
+ while(1){
+ regexmatch = sasl_map_domap(&map, (char*)user, (char*)user_realm, &base, &filter);
+ if (regexmatch) {
+ ids_sasl_user_search(base, scope, filter,
+ ctrls, attrs, attrsonly,
+ &entry, &found);
+ if (found == 1) {
+ LDAPDebug(LDAP_DEBUG_TRACE, "sasl user search found this entry: dn:%s, "
+ "matching filter=%s\n", entry->e_sdn.dn, filter, 0);
+ } else if (found == 0) {
+ LDAPDebug(LDAP_DEBUG_TRACE, "sasl user search found no entries matching "
+ "filter=%s\n", filter, 0, 0);
+ } else {
+ LDAPDebug(LDAP_DEBUG_TRACE, "sasl user search found more than one entry "
+ "matching filter=%s\n", filter, 0, 0);
+ if (entry) {
+ slapi_entry_free(entry);
+ entry = NULL;
+ }
}
- }
- /* Free the filter etc */
- slapi_ch_free_string(&base);
- slapi_ch_free_string(&filter);
+ /* Free the filter etc */
+ slapi_ch_free_string(&base);
+ slapi_ch_free_string(&filter);
+
+ /* If we didn't find an entry, look at the other maps */
+ if(found){
+ break;
+ }
+ }
+ if(map == NULL){
+ break;
+ }
}
+ sasl_map_read_unlock();
return entry;
}
11 years, 2 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Nathan Kinder
ldap/servers/plugins/dna/dna.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
New commits:
commit 3b177a768a48857f9dcb891a7dd3c8f8d9a220a4
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Jan 4 11:41:48 2013 -0800
Ticket 549 - DNA plugin no longer reports additional info when range is depleted
When the DNA plug-in was modified to allocate range values at the
bepreop phase, it stopped returning detailed error strings to the
client when the range was depleted.
This patch allows our bepreop functions to fill in the error string
that the caller can return to the client.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 66d4a05..36dd936 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -2759,7 +2759,7 @@ dna_create_valcheck_filter(struct configEntry *config_entry, PRUint64 value, cha
/* This function is called at BEPREOP timing to add uid/gidNumber
* if modtype is missing */
static int
-_dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
+_dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
{
int ret = 0;
PRCList *list = NULL;
@@ -2886,6 +2886,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
if (LDAP_SUCCESS != ret) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: no more values available!!\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -2895,6 +2899,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
if (LDAP_SUCCESS != ret){
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: failed to allocate a new ID\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -2902,6 +2910,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
/* dna_first_free_value() failed for some unknown reason */
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: failed to allocate a new ID!!\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -2943,7 +2955,7 @@ bail:
/* This function is called at BEPREOP timing to add uid/gidNumber
* if modtype is missing */
static int
-_dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
+_dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods, char **errstr)
{
int ret = 0;
PRCList *list = NULL;
@@ -3144,6 +3156,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
if (LDAP_SUCCESS != ret) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: no more values available!!\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -3153,6 +3169,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
if (LDAP_SUCCESS != ret){
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: failed to allocate a new ID\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -3160,6 +3180,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
/* dna_first_free_value() failed for some unknown reason */
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: failed to allocate a new ID!!\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -3287,9 +3311,9 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
}
} else {
if (LDAP_CHANGETYPE_ADD == modtype) {
- ret = _dna_pre_op_add(pb, test_e);
+ ret = _dna_pre_op_add(pb, test_e, &errstr);
} else {
- if((ret = _dna_pre_op_modify(pb, test_e, smods))){
+ if((ret = _dna_pre_op_modify(pb, test_e, smods, &errstr))){
slapi_mods_free(&smods);
}
}
11 years, 2 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Nathan Kinder
ldap/servers/plugins/dna/dna.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
New commits:
commit 090236b6dd97b16258f3bb03631dabfadef34a99
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Jan 4 11:41:48 2013 -0800
Ticket 549 - DNA plugin no longer reports additional info when range is depleted
When the DNA plug-in was modified to allocate range values at the
bepreop phase, it stopped returning detailed error strings to the
client when the range was depleted.
This patch allows our bepreop functions to fill in the error string
that the caller can return to the client.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 66d4a05..36dd936 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -2759,7 +2759,7 @@ dna_create_valcheck_filter(struct configEntry *config_entry, PRUint64 value, cha
/* This function is called at BEPREOP timing to add uid/gidNumber
* if modtype is missing */
static int
-_dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
+_dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
{
int ret = 0;
PRCList *list = NULL;
@@ -2886,6 +2886,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
if (LDAP_SUCCESS != ret) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: no more values available!!\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -2895,6 +2899,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
if (LDAP_SUCCESS != ret){
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: failed to allocate a new ID\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -2902,6 +2910,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
/* dna_first_free_value() failed for some unknown reason */
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: failed to allocate a new ID!!\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -2943,7 +2955,7 @@ bail:
/* This function is called at BEPREOP timing to add uid/gidNumber
* if modtype is missing */
static int
-_dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
+_dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods, char **errstr)
{
int ret = 0;
PRCList *list = NULL;
@@ -3144,6 +3156,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
if (LDAP_SUCCESS != ret) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: no more values available!!\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -3153,6 +3169,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
if (LDAP_SUCCESS != ret){
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: failed to allocate a new ID\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -3160,6 +3180,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
/* dna_first_free_value() failed for some unknown reason */
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_pre_op: failed to allocate a new ID!!\n");
+ /* Set an error string to be returned to the client. */
+ *errstr = slapi_ch_smprintf("Allocation of a new value for range"
+ " %s failed! Unable to proceed.",
+ config_entry->dn);
slapi_unlock_mutex(config_entry->lock);
break;
}
@@ -3287,9 +3311,9 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
}
} else {
if (LDAP_CHANGETYPE_ADD == modtype) {
- ret = _dna_pre_op_add(pb, test_e);
+ ret = _dna_pre_op_add(pb, test_e, &errstr);
} else {
- if((ret = _dna_pre_op_modify(pb, test_e, smods))){
+ if((ret = _dna_pre_op_modify(pb, test_e, smods, &errstr))){
slapi_mods_free(&smods);
}
}
11 years, 2 months