diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2010-07-22 12:10:22 -0700 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-07-22 12:10:22 -0700 |
commit | 2f9943f02911e6ee7de2d28860a929345fae629c (patch) | |
tree | 08011764abd45007e485860a8ab143164ae35b15 /ldap/servers/slapd/entry.c | |
parent | 2a03eed6f1bb8d70d529b9248603e0449f07ec30 (diff) | |
download | ds-2f9943f02911e6ee7de2d28860a929345fae629c.tar.gz ds-2f9943f02911e6ee7de2d28860a929345fae629c.tar.xz ds-2f9943f02911e6ee7de2d28860a929345fae629c.zip |
616618 - 389 v1.2.5 accepts 2 identical entries with different DN formats
https://bugzilla.redhat.com/show_bug.cgi?id=616618
Change Description:
. renamed 91upgradednformat.pl to 80upgradednformat.pl to run
upgradednformat before 90subtreerename.pl.
. ported following patches applied to Directory_Server_8_2_Branch
to master and 389-ds-base-1.2.6.
612771 - RHDS 8.1/389 v1.2.5 accepts 2 identical entries with
different DN formats
* commit 50bb2ee6676e10cdda704982dfa831efa4011037
Fix Description:
This patch fixes the upgradednformat utility to eliminate the
duplicated DNs found in the upgrading period. Assuming DN:
attr0=value0,attr1=value1,...,attrn=valuen exists in the DB
and another identical DN is found, the second DN is renamed to
nsuniqueid=<uuid>+attr0=value0,attr1=value1,...,attrn=valuen
, where the <uuid> is the unique id assigned to the entry when
the entry is added to the server. The modification is logged
in the error log.
In addition, there was a bug to handle multi-valued RDNs in
slapi_dn_normalize_ext. In case multi-valued RDN appears with
DN value (e.g., nsuniqueid=<uuid>+cn=uid\=<uid>\,o\=<org>,dc=<dc>),
it was not normalized properly. Introduced second rdn_av_stack
(subinitial_rdn_av_stack) for the nested DN value.
See also:
http://directory.fedoraproject.org/wiki/Upgrade_to_New_DN_Format#Another_Upgrade_Scenario
* commit ebaa18adaf201f75c709e078abd8e32605eddb81
Fix Description:
1) In the previous commit 50bb2ee6676e10cdda704982dfa831efa4011037,
there were 3 places to miss replacing rdn_av_count with subrdn_av_count.
2) A variable subtypestart is used to keep the head of nested
multivalued RDNs. For instance,
seeAlso=cn\=<CN>\+l\=<L>\,o\=<O>,dc=examle,dc=com
^ or ^ or ^
There was a bug to set the first position ("cn" in the above example).
In addition, fixed a warning assigning "const char *" to "char *" in
import_foreman (import-threads.c).
* commit 472a2c0f2f21205390ba87c31c498b4419a932ba
Fix Description:
When newly creating an ancestorid index file, instead of
opening the index file with DB_TRUNCATE option, delete
the file then create it.
616135 - Upgrade failure on Solaris :
tar: db/NetscapeRoot/{DBVERSION,*.db4}:
No such file or directory
* commit e6723421e6dc69408edb2a396eb22da361cff206
Fix Description:
.../'{'DBVERSION,*.db4'}' is not a shell syntax. Process DBVERSION
and *.db4 individually.
Cherry-picked 700d7c1a199db4a690740636b8bd3e612304ce1e and
0b6ddc9b06845bdf385e749f2c5a99497df20d98 from
389-ds-base-1.2.6 branch.
Diffstat (limited to 'ldap/servers/slapd/entry.c')
-rw-r--r-- | ldap/servers/slapd/entry.c | 84 |
1 files changed, 53 insertions, 31 deletions
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c index 87765d50..0cb856eb 100644 --- a/ldap/servers/slapd/entry.c +++ b/ldap/servers/slapd/entry.c @@ -274,14 +274,19 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) if ( rawdn ) { if ( NULL == slapi_entry_get_dn_const( e )) { - normdn = slapi_create_dn_string("%s", rawdn); - if (NULL == normdn) { - LDAPDebug1Arg(LDAP_DEBUG_TRACE, - "str2entry_fast: Invalid DN: %s\n", rawdn); - slapi_entry_free( e ); - if (retmalloc) slapi_ch_free_string(&valuecharptr); - if (freetype) slapi_ch_free_string(&type); - return NULL; + if (flags & SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT) { + normdn = + slapi_ch_strdup(slapi_dn_normalize_original(rawdn)); + } else { + normdn = slapi_create_dn_string("%s", rawdn); + if (NULL == normdn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "str2entry_fast: Invalid DN: %s\n", rawdn); + slapi_entry_free( e ); + if (retmalloc) slapi_ch_free_string(&valuecharptr); + if (freetype) slapi_ch_free_string(&type); + return NULL; + } } /* normdn is consumed in e */ slapi_entry_set_dn(e, normdn); @@ -291,14 +296,19 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) /* normdn is just referred in slapi_entry_set_rdn. */ slapi_entry_set_rdn(e, normdn); } else { - normdn = slapi_create_dn_string("%s", rawdn); - if (NULL == normdn) { - LDAPDebug1Arg(LDAP_DEBUG_TRACE, - "str2entry_fast: Invalid DN: %s\n", rawdn); - slapi_entry_free( e ); - if (retmalloc) slapi_ch_free_string(&valuecharptr); - if (freetype) slapi_ch_free_string(&type); - return NULL; + if (flags & SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT) { + normdn = + slapi_ch_strdup(slapi_dn_normalize_original(rawdn)); + } else { + normdn = slapi_create_dn_string("%s", rawdn); + if (NULL == normdn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "str2entry_fast: Invalid DN: %s\n", rawdn); + slapi_entry_free( e ); + if (retmalloc) slapi_ch_free_string(&valuecharptr); + if (freetype) slapi_ch_free_string(&type); + return NULL; + } } /* normdn is just referred in slapi_entry_set_rdn. */ slapi_entry_set_rdn(e, normdn); @@ -321,7 +331,12 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) if (freetype) slapi_ch_free_string(&type); continue; } - normdn = slapi_create_dn_string("%s", valuecharptr); + if (flags & SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT) { + normdn = + slapi_ch_strdup(slapi_dn_normalize_original(valuecharptr)); + } else { + normdn = slapi_create_dn_string("%s", valuecharptr); + } if (NULL == normdn) { LDAPDebug1Arg(LDAP_DEBUG_TRACE, "str2entry_fast: Invalid DN: %s\n", valuecharptr); @@ -429,21 +444,27 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo ) return NULL; } } - rc = slapi_dn_normalize_ext(valuecharptr, 0, &dn_aval, &dnlen); - if (rc < 0) { - /* Give up normalizing the attribute value */ - LDAPDebug2Args(LDAP_DEBUG_TRACE, + if (flags & SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT) { + dn_aval = slapi_dn_normalize_original(valuecharptr); + slapi_value_set(value, dn_aval, strlen(dn_aval)); + } else { + rc = slapi_dn_normalize_ext(valuecharptr, + 0, &dn_aval, &dnlen); + if (rc < 0) { + /* Give up normalizing the attribute value */ + LDAPDebug2Args(LDAP_DEBUG_TRACE, "str2entry_fast: Invalid DN value: %s: %s\n", type, valuecharptr); - dn_aval = valuecharptr; - dnlen = valuelen; - } - slapi_value_set(value, dn_aval, dnlen); - if (rc > 0) { /* if rc == 0, valuecharptr is passed in */ - slapi_ch_free_string(&dn_aval); - } else if (rc == 0) { /* rc == 0; valuecharptr is passed in; - not null terminated */ - *(dn_aval + dnlen) = '\0'; + dn_aval = valuecharptr; + dnlen = valuelen; + } + slapi_value_set(value, dn_aval, dnlen); + if (rc > 0) { /* if rc == 0, valuecharptr is passed in */ + slapi_ch_free_string(&dn_aval); + } else if (rc == 0) { /* rc == 0; valuecharptr is passed in; + not null terminated */ + *(dn_aval + dnlen) = '\0'; + } } } else { slapi_value_set(value, valuecharptr, valuelen); @@ -1263,6 +1284,7 @@ free_and_return: ( SLAPI_STR2ENTRY_IGNORE_STATE \ | SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES \ | SLAPI_STR2ENTRY_TOMBSTONE_CHECK \ + | SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT \ ) #define SLAPI_STRENTRY_FLAGS_HANDLED_BY_STR2ENTRY_FAST \ @@ -1288,7 +1310,7 @@ slapi_str2entry( char *s, int flags ) * slower but more forgiving str2entry_dupcheck() function. */ if ( 0 != ( flags & SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF ) || - 0 != ( flags & ~SLAPI_STRENTRY_FLAGS_HANDLED_BY_STR2ENTRY_FAST )) + 0 != ( flags & ~SLAPI_STRENTRY_FLAGS_HANDLED_BY_STR2ENTRY_FAST )) { e= str2entry_dupcheck( NULL/*dn*/, s, flags, read_stateinfo ); } |