|
|
dc8c34 |
From fa889bc385ff09b752769b04acc91df84d44ae4c Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
dc8c34 |
Date: Wed, 14 Nov 2012 15:18:57 -0500
|
|
|
dc8c34 |
Subject: [PATCH 15/16] Ticket 517 - crash in DNA if no dnaMagicRegen is
|
|
|
dc8c34 |
specified
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Bug Description: There are several places where we deference config_entry->generate
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Fix Description: Properly check for NULL, and allow the update of dnaType.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/517
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by: richm(Thanks Rich)
|
|
|
dc8c34 |
(cherry picked from commit d97835969db3e957032c52ac317699354299c07c)
|
|
|
dc8c34 |
(cherry picked from commit 322c4ecc2363c4e7a7107ae2e8aa05aa3a55ddf3)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/plugins/dna/dna.c | 49 +++++++++++++++++++-----------------------
|
|
|
dc8c34 |
1 file changed, 22 insertions(+), 27 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
|
|
|
dc8c34 |
index 34d67ab..ef01735 100644
|
|
|
dc8c34 |
--- a/ldap/servers/plugins/dna/dna.c
|
|
|
dc8c34 |
+++ b/ldap/servers/plugins/dna/dna.c
|
|
|
dc8c34 |
@@ -804,10 +804,9 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
|
|
|
dc8c34 |
value = slapi_entry_attr_get_charptr(e, DNA_GENERATE);
|
|
|
dc8c34 |
if (value) {
|
|
|
dc8c34 |
entry->generate = value;
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
|
|
|
dc8c34 |
+ slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
|
|
|
dc8c34 |
"----------> %s [%s]\n", DNA_GENERATE, entry->generate);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
|
|
|
dc8c34 |
value = slapi_entry_attr_get_charptr(e, DNA_FILTER);
|
|
|
dc8c34 |
if (value) {
|
|
|
dc8c34 |
@@ -2809,8 +2808,7 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* does the entry match the filter? */
|
|
|
dc8c34 |
if (config_entry->slapi_filter) {
|
|
|
dc8c34 |
- ret = slapi_vattr_filter_test(pb, e, config_entry->slapi_filter,
|
|
|
dc8c34 |
- 0);
|
|
|
dc8c34 |
+ ret = slapi_vattr_filter_test(pb, e, config_entry->slapi_filter, 0);
|
|
|
dc8c34 |
if (LDAP_SUCCESS != ret) {
|
|
|
dc8c34 |
goto next;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -2820,28 +2818,23 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
|
|
|
dc8c34 |
/* For a multi-type range, we only generate a value
|
|
|
dc8c34 |
* for types where the magic value is set. We do not
|
|
|
dc8c34 |
* generate a value for missing types. */
|
|
|
dc8c34 |
- for (i = 0; config_entry->types && config_entry->types[i];
|
|
|
dc8c34 |
- i++) {
|
|
|
dc8c34 |
- value = slapi_entry_attr_get_charptr(e,
|
|
|
dc8c34 |
- config_entry->types[i]);
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- if (value &&
|
|
|
dc8c34 |
- !slapi_UTF8CASECMP(config_entry->generate, value)) {
|
|
|
dc8c34 |
- slapi_ch_array_add(&types_to_generate,
|
|
|
dc8c34 |
- slapi_ch_strdup(config_entry->types[i]));
|
|
|
dc8c34 |
+ for (i = 0; config_entry->types && config_entry->types[i]; i++) {
|
|
|
dc8c34 |
+ value = slapi_entry_attr_get_charptr(e, config_entry->types[i]);
|
|
|
dc8c34 |
+ if (value){
|
|
|
dc8c34 |
+ if(config_entry->generate == NULL || !slapi_UTF8CASECMP(config_entry->generate, value)){
|
|
|
dc8c34 |
+ slapi_ch_array_add(&types_to_generate, slapi_ch_strdup(config_entry->types[i]));
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ slapi_ch_free_string(&value);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- slapi_ch_free_string(&value);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
/* For a single type range, we generate the value if
|
|
|
dc8c34 |
* the magic value is set or if the type is missing. */
|
|
|
dc8c34 |
value = slapi_entry_attr_get_charptr(e, config_entry->types[0]);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- if ((value &&
|
|
|
dc8c34 |
- !slapi_UTF8CASECMP(config_entry->generate, value)) ||
|
|
|
dc8c34 |
- (0 == value)) {
|
|
|
dc8c34 |
- slapi_ch_array_add(&types_to_generate,
|
|
|
dc8c34 |
- slapi_ch_strdup(config_entry->types[0]));
|
|
|
dc8c34 |
+ if((config_entry->generate == NULL) || (0 == value) ||
|
|
|
dc8c34 |
+ (value && !slapi_UTF8CASECMP(config_entry->generate, value))){
|
|
|
dc8c34 |
+ slapi_ch_array_add(&types_to_generate, slapi_ch_strdup(config_entry->types[0]));
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
slapi_ch_free_string(&value);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -3060,13 +3053,15 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* If we have a value, see if it's the magic value. */
|
|
|
dc8c34 |
if (bv) {
|
|
|
dc8c34 |
- len = strlen(config_entry->generate);
|
|
|
dc8c34 |
- if (len == bv->bv_len) {
|
|
|
dc8c34 |
- if (!slapi_UTF8NCASECMP(bv->bv_val,
|
|
|
dc8c34 |
- config_entry->generate,
|
|
|
dc8c34 |
- len)) {
|
|
|
dc8c34 |
- slapi_ch_array_add(&types_to_generate,
|
|
|
dc8c34 |
- slapi_ch_strdup(type));
|
|
|
dc8c34 |
+ if(config_entry->generate == NULL){
|
|
|
dc8c34 |
+ /* we don't have a magic number set, so apply the update */
|
|
|
dc8c34 |
+ slapi_ch_array_add(&types_to_generate, slapi_ch_strdup(type));
|
|
|
dc8c34 |
+ } else {
|
|
|
dc8c34 |
+ len = strlen(config_entry->generate);
|
|
|
dc8c34 |
+ if (len == bv->bv_len) {
|
|
|
dc8c34 |
+ if (!slapi_UTF8NCASECMP(bv->bv_val, config_entry->generate,len)){
|
|
|
dc8c34 |
+ slapi_ch_array_add(&types_to_generate, slapi_ch_strdup(type));
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
} else if (!dna_is_multitype_range(config_entry)) {
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.7.11.7
|
|
|
dc8c34 |
|