Skip to content

Commit

Permalink
Fix false 'multiple dns' error when DN is set from rawdn
Browse files Browse the repository at this point in the history
Description: This change introduces a dn_set_from_rawdn flag to track if the DN was set from the rawdn parameter. It prevents logging a false "Entry has multiple dns" error when the DN is first set from rawdn and then encountered again in the input. The error will now only be logged if multiple dn attributes are present after the initial DN has been processed.

Fixes: 389ds#2182
  • Loading branch information
droideck committed Sep 24, 2024
1 parent b0fc468 commit c45255e
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions ldap/servers/slapd/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ str2entry_dupcheck(const char *rawdn, const char *s, int flags, int read_statein
char *normdn = NULL;
int strict = 0;
struct berval bval = {0};
int dn_set_from_rawdn = 0;

/* Check if we should be performing strict validation. */
strict = config_get_dn_validate_strict();
Expand Down Expand Up @@ -854,6 +855,7 @@ str2entry_dupcheck(const char *rawdn, const char *s, int flags, int read_statein
}
/* normdn is consumed in e */
slapi_entry_set_normdn(e, normdn);
dn_set_from_rawdn = 1;
}
if (NULL == slapi_entry_get_rdn_const(e)) {
if (normdn) {
Expand Down Expand Up @@ -886,15 +888,21 @@ str2entry_dupcheck(const char *rawdn, const char *s, int flags, int read_statein
}
if (strcasecmp(type, "dn") == 0) {
if (slapi_entry_get_dn_const(e) != NULL) {
char ebuf[BUFSIZ];
slapi_log_err(SLAPI_LOG_TRACE, "str2entry_dupcheck"
"Entry has multiple dns \"%s\" and \"%s\" (second ignored)\n",
(char *)slapi_entry_get_dn_const(e),
escape_string(valuecharptr, ebuf));
/* the memory below was not allocated by the slapi_ch_ functions */
if (freeval)
slapi_ch_free_string(&bvvalue.bv_val);
continue;
if (dn_set_from_rawdn) {
/* We reset it so that we can see the duplicate DN message
* if it'll happen later in the entry */
dn_set_from_rawdn = 0;
} else {
char ebuf[BUFSIZ];
slapi_log_err(SLAPI_LOG_TRACE, "str2entry_dupcheck"
"Entry has multiple dns \"%s\" and \"%s\" (second ignored)\n",
(char *)slapi_entry_get_dn_const(e),
escape_string(valuecharptr, ebuf));
/* the memory below was not allocated by the slapi_ch_ functions */
if (freeval)
slapi_ch_free_string(&bvvalue.bv_val);
continue;
}
}
normdn = slapi_create_dn_string("%s", valuecharptr);
if (NULL == normdn) {
Expand Down

0 comments on commit c45255e

Please sign in to comment.