From a1cd3cf8e8b6b33ab21d5338921187a76dd9dcd0 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Fri, 22 May 2020 15:41:45 -0400 Subject: [PATCH 07/12] Issue 51110 - Fix ASAN ODR warnings Description: Fixed ODR issues with glboal attributes which were duplicated from the core server into the replication and retrocl plugins. relates: https://pagure.io/389-ds-base/issue/51110 Reviewed by: firstyear(Thanks!) --- ldap/servers/plugins/replication/repl5.h | 17 +++--- .../plugins/replication/repl_globals.c | 17 +++--- ldap/servers/plugins/replication/replutil.c | 16 +++--- ldap/servers/plugins/retrocl/retrocl.h | 22 ++++---- ldap/servers/plugins/retrocl/retrocl_cn.c | 12 ++--- ldap/servers/plugins/retrocl/retrocl_po.c | 52 +++++++++---------- ldap/servers/plugins/retrocl/retrocl_trim.c | 30 +++++------ 7 files changed, 82 insertions(+), 84 deletions(-) diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h index 873dd8a16..72b7089e3 100644 --- a/ldap/servers/plugins/replication/repl5.h +++ b/ldap/servers/plugins/replication/repl5.h @@ -280,15 +280,14 @@ struct berval *NSDS90StartReplicationRequest_new(const char *protocol_oid, int multimaster_extop_NSDS50ReplicationEntry(Slapi_PBlock *pb); /* From repl_globals.c */ -extern char *attr_changenumber; -extern char *attr_targetdn; -extern char *attr_changetype; -extern char *attr_newrdn; -extern char *attr_deleteoldrdn; -extern char *attr_changes; -extern char *attr_newsuperior; -extern char *attr_changetime; -extern char *attr_dataversion; +extern char *repl_changenumber; +extern char *repl_targetdn; +extern char *repl_changetype; +extern char *repl_newrdn; +extern char *repl_deleteoldrdn; +extern char *repl_changes; +extern char *repl_newsuperior; +extern char *repl_changetime; extern char *attr_csn; extern char *changetype_add; extern char *changetype_delete; diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c index 355a0ffa1..c615c77da 100644 --- a/ldap/servers/plugins/replication/repl_globals.c +++ b/ldap/servers/plugins/replication/repl_globals.c @@ -48,15 +48,14 @@ char *changetype_delete = CHANGETYPE_DELETE; char *changetype_modify = CHANGETYPE_MODIFY; char *changetype_modrdn = CHANGETYPE_MODRDN; char *changetype_moddn = CHANGETYPE_MODDN; -char *attr_changenumber = ATTR_CHANGENUMBER; -char *attr_targetdn = ATTR_TARGETDN; -char *attr_changetype = ATTR_CHANGETYPE; -char *attr_newrdn = ATTR_NEWRDN; -char *attr_deleteoldrdn = ATTR_DELETEOLDRDN; -char *attr_changes = ATTR_CHANGES; -char *attr_newsuperior = ATTR_NEWSUPERIOR; -char *attr_changetime = ATTR_CHANGETIME; -char *attr_dataversion = ATTR_DATAVERSION; +char *repl_changenumber = ATTR_CHANGENUMBER; +char *repl_targetdn = ATTR_TARGETDN; +char *repl_changetype = ATTR_CHANGETYPE; +char *repl_newrdn = ATTR_NEWRDN; +char *repl_deleteoldrdn = ATTR_DELETEOLDRDN; +char *repl_changes = ATTR_CHANGES; +char *repl_newsuperior = ATTR_NEWSUPERIOR; +char *repl_changetime = ATTR_CHANGETIME; char *attr_csn = ATTR_CSN; char *type_copyingFrom = TYPE_COPYINGFROM; char *type_copiedFrom = TYPE_COPIEDFROM; diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c index de1e77880..39f821d12 100644 --- a/ldap/servers/plugins/replication/replutil.c +++ b/ldap/servers/plugins/replication/replutil.c @@ -64,14 +64,14 @@ get_cleattrs() { if (cleattrs[0] == NULL) { cleattrs[0] = type_objectclass; - cleattrs[1] = attr_changenumber; - cleattrs[2] = attr_targetdn; - cleattrs[3] = attr_changetype; - cleattrs[4] = attr_newrdn; - cleattrs[5] = attr_deleteoldrdn; - cleattrs[6] = attr_changes; - cleattrs[7] = attr_newsuperior; - cleattrs[8] = attr_changetime; + cleattrs[1] = repl_changenumber; + cleattrs[2] = repl_targetdn; + cleattrs[3] = repl_changetype; + cleattrs[4] = repl_newrdn; + cleattrs[5] = repl_deleteoldrdn; + cleattrs[6] = repl_changes; + cleattrs[7] = repl_newsuperior; + cleattrs[8] = repl_changetime; cleattrs[9] = NULL; } return cleattrs; diff --git a/ldap/servers/plugins/retrocl/retrocl.h b/ldap/servers/plugins/retrocl/retrocl.h index 06482a14c..2ce76fcec 100644 --- a/ldap/servers/plugins/retrocl/retrocl.h +++ b/ldap/servers/plugins/retrocl/retrocl.h @@ -94,17 +94,17 @@ extern int retrocl_nattributes; extern char **retrocl_attributes; extern char **retrocl_aliases; -extern const char *attr_changenumber; -extern const char *attr_targetdn; -extern const char *attr_changetype; -extern const char *attr_newrdn; -extern const char *attr_newsuperior; -extern const char *attr_deleteoldrdn; -extern const char *attr_changes; -extern const char *attr_changetime; -extern const char *attr_objectclass; -extern const char *attr_nsuniqueid; -extern const char *attr_isreplicated; +extern const char *retrocl_changenumber; +extern const char *retrocl_targetdn; +extern const char *retrocl_changetype; +extern const char *retrocl_newrdn; +extern const char *retrocl_newsuperior; +extern const char *retrocl_deleteoldrdn; +extern const char *retrocl_changes; +extern const char *retrocl_changetime; +extern const char *retrocl_objectclass; +extern const char *retrocl_nsuniqueid; +extern const char *retrocl_isreplicated; extern PRLock *retrocl_internal_lock; extern Slapi_RWLock *retrocl_cn_lock; diff --git a/ldap/servers/plugins/retrocl/retrocl_cn.c b/ldap/servers/plugins/retrocl/retrocl_cn.c index 709d7a857..5fc5f586d 100644 --- a/ldap/servers/plugins/retrocl/retrocl_cn.c +++ b/ldap/servers/plugins/retrocl/retrocl_cn.c @@ -62,7 +62,7 @@ handle_cnum_entry(Slapi_Entry *e, void *callback_data) Slapi_Attr *chattr = NULL; sval = NULL; value = NULL; - if (slapi_entry_attr_find(e, attr_changenumber, &chattr) == 0) { + if (slapi_entry_attr_find(e, retrocl_changenumber, &chattr) == 0) { slapi_attr_first_value(chattr, &sval); if (NULL != sval) { value = slapi_value_get_berval(sval); @@ -79,7 +79,7 @@ handle_cnum_entry(Slapi_Entry *e, void *callback_data) chattr = NULL; sval = NULL; value = NULL; - if (slapi_entry_attr_find(e, attr_changetime, &chattr) == 0) { + if (slapi_entry_attr_find(e, retrocl_changetime, &chattr) == 0) { slapi_attr_first_value(chattr, &sval); if (NULL != sval) { value = slapi_value_get_berval(sval); @@ -134,7 +134,7 @@ retrocl_get_changenumbers(void) cr.cr_time = 0; slapi_seq_callback(RETROCL_CHANGELOG_DN, SLAPI_SEQ_FIRST, - (char *)attr_changenumber, /* cast away const */ + (char *)retrocl_changenumber, /* cast away const */ NULL, NULL, 0, &cr, NULL, handle_cnum_result, handle_cnum_entry, NULL); @@ -144,7 +144,7 @@ retrocl_get_changenumbers(void) slapi_ch_free((void **)&cr.cr_time); slapi_seq_callback(RETROCL_CHANGELOG_DN, SLAPI_SEQ_LAST, - (char *)attr_changenumber, /* cast away const */ + (char *)retrocl_changenumber, /* cast away const */ NULL, NULL, 0, &cr, NULL, handle_cnum_result, handle_cnum_entry, NULL); @@ -185,7 +185,7 @@ retrocl_getchangetime(int type, int *err) return NO_TIME; } slapi_seq_callback(RETROCL_CHANGELOG_DN, type, - (char *)attr_changenumber, /* cast away const */ + (char *)retrocl_changenumber, /* cast away const */ NULL, NULL, 0, &cr, NULL, handle_cnum_result, handle_cnum_entry, NULL); @@ -353,7 +353,7 @@ retrocl_update_lastchangenumber(void) cr.cr_cnum = 0; cr.cr_time = 0; slapi_seq_callback(RETROCL_CHANGELOG_DN, SLAPI_SEQ_LAST, - (char *)attr_changenumber, /* cast away const */ + (char *)retrocl_changenumber, /* cast away const */ NULL, NULL, 0, &cr, NULL, handle_cnum_result, handle_cnum_entry, NULL); diff --git a/ldap/servers/plugins/retrocl/retrocl_po.c b/ldap/servers/plugins/retrocl/retrocl_po.c index d2af79b31..e1488f56b 100644 --- a/ldap/servers/plugins/retrocl/retrocl_po.c +++ b/ldap/servers/plugins/retrocl/retrocl_po.c @@ -25,17 +25,17 @@ modrdn2reple(Slapi_Entry *e, const char *newrdn, int deloldrdn, LDAPMod **ldm, c /******************************/ -const char *attr_changenumber = "changenumber"; -const char *attr_targetdn = "targetdn"; -const char *attr_changetype = "changetype"; -const char *attr_newrdn = "newrdn"; -const char *attr_deleteoldrdn = "deleteoldrdn"; -const char *attr_changes = "changes"; -const char *attr_newsuperior = "newsuperior"; -const char *attr_changetime = "changetime"; -const char *attr_objectclass = "objectclass"; -const char *attr_nsuniqueid = "nsuniqueid"; -const char *attr_isreplicated = "isreplicated"; +const char *retrocl_changenumber = "changenumber"; +const char *retrocl_targetdn = "targetdn"; +const char *retrocl_changetype = "changetype"; +const char *retrocl_newrdn = "newrdn"; +const char *retrocl_deleteoldrdn = "deleteoldrdn"; +const char *retrocl_changes = "changes"; +const char *retrocl_newsuperior = "newsuperior"; +const char *retrocl_changetime = "changetime"; +const char *retrocl_objectclass = "objectclass"; +const char *retrocl_nsuniqueid = "nsuniqueid"; +const char *retrocl_isreplicated = "isreplicated"; /* * Function: make_changes_string @@ -185,7 +185,7 @@ write_replog_db( changenum, dn); /* Construct the dn of this change record */ - edn = slapi_ch_smprintf("%s=%lu,%s", attr_changenumber, changenum, RETROCL_CHANGELOG_DN); + edn = slapi_ch_smprintf("%s=%lu,%s", retrocl_changenumber, changenum, RETROCL_CHANGELOG_DN); /* * Create the entry struct, and fill in fields common to all types @@ -214,7 +214,7 @@ write_replog_db( attributeAlias = attributeName; } - if (strcasecmp(attributeName, attr_nsuniqueid) == 0) { + if (strcasecmp(attributeName, retrocl_nsuniqueid) == 0) { Slapi_Entry *entry = NULL; const char *uniqueId = NULL; @@ -236,7 +236,7 @@ write_replog_db( extensibleObject = 1; - } else if (strcasecmp(attributeName, attr_isreplicated) == 0) { + } else if (strcasecmp(attributeName, retrocl_isreplicated) == 0) { int isReplicated = 0; char *attributeValue = NULL; @@ -298,17 +298,17 @@ write_replog_db( sprintf(chnobuf, "%lu", changenum); val.bv_val = chnobuf; val.bv_len = strlen(chnobuf); - slapi_entry_add_values(e, attr_changenumber, vals); + slapi_entry_add_values(e, retrocl_changenumber, vals); /* Set the targetentrydn attribute */ val.bv_val = dn; val.bv_len = strlen(dn); - slapi_entry_add_values(e, attr_targetdn, vals); + slapi_entry_add_values(e, retrocl_targetdn, vals); /* Set the changeTime attribute */ val.bv_val = format_genTime(curtime); val.bv_len = strlen(val.bv_val); - slapi_entry_add_values(e, attr_changetime, vals); + slapi_entry_add_values(e, retrocl_changetime, vals); slapi_ch_free((void **)&val.bv_val); /* @@ -344,7 +344,7 @@ write_replog_db( /* Set the changetype attribute */ val.bv_val = "delete"; val.bv_len = 6; - slapi_entry_add_values(e, attr_changetype, vals); + slapi_entry_add_values(e, retrocl_changetype, vals); } break; @@ -422,7 +422,7 @@ entry2reple(Slapi_Entry *e, Slapi_Entry *oe, int optype) } else { return (1); } - slapi_entry_add_values(e, attr_changetype, vals); + slapi_entry_add_values(e, retrocl_changetype, vals); estr = slapi_entry2str(oe, &len); p = estr; @@ -435,7 +435,7 @@ entry2reple(Slapi_Entry *e, Slapi_Entry *oe, int optype) } val.bv_val = p; val.bv_len = len - (p - estr); /* length + terminating \0 */ - slapi_entry_add_values(e, attr_changes, vals); + slapi_entry_add_values(e, retrocl_changes, vals); slapi_ch_free_string(&estr); return 0; } @@ -471,7 +471,7 @@ mods2reple(Slapi_Entry *e, LDAPMod **ldm) if (NULL != l) { val.bv_val = l->ls_buf; val.bv_len = l->ls_len + 1; /* string + terminating \0 */ - slapi_entry_add_values(e, attr_changes, vals); + slapi_entry_add_values(e, retrocl_changes, vals); lenstr_free(&l); } } @@ -511,12 +511,12 @@ modrdn2reple( val.bv_val = "modrdn"; val.bv_len = 6; - slapi_entry_add_values(e, attr_changetype, vals); + slapi_entry_add_values(e, retrocl_changetype, vals); if (newrdn) { val.bv_val = (char *)newrdn; /* cast away const */ val.bv_len = strlen(newrdn); - slapi_entry_add_values(e, attr_newrdn, vals); + slapi_entry_add_values(e, retrocl_newrdn, vals); } if (deloldrdn == 0) { @@ -526,12 +526,12 @@ modrdn2reple( val.bv_val = "TRUE"; val.bv_len = 4; } - slapi_entry_add_values(e, attr_deleteoldrdn, vals); + slapi_entry_add_values(e, retrocl_deleteoldrdn, vals); if (newsuperior) { val.bv_val = (char *)newsuperior; /* cast away const */ val.bv_len = strlen(newsuperior); - slapi_entry_add_values(e, attr_newsuperior, vals); + slapi_entry_add_values(e, retrocl_newsuperior, vals); } if (NULL != ldm) { @@ -540,7 +540,7 @@ modrdn2reple( if (l->ls_len) { val.bv_val = l->ls_buf; val.bv_len = l->ls_len; - slapi_entry_add_values(e, attr_changes, vals); + slapi_entry_add_values(e, retrocl_changes, vals); } lenstr_free(&l); } diff --git a/ldap/servers/plugins/retrocl/retrocl_trim.c b/ldap/servers/plugins/retrocl/retrocl_trim.c index 0378eb7f6..d031dc3f8 100644 --- a/ldap/servers/plugins/retrocl/retrocl_trim.c +++ b/ldap/servers/plugins/retrocl/retrocl_trim.c @@ -49,15 +49,15 @@ static const char ** get_cleattrs(void) { if (cleattrs[0] == NULL) { - cleattrs[0] = attr_objectclass; - cleattrs[1] = attr_changenumber; - cleattrs[2] = attr_targetdn; - cleattrs[3] = attr_changetype; - cleattrs[4] = attr_newrdn; - cleattrs[5] = attr_deleteoldrdn; - cleattrs[6] = attr_changes; - cleattrs[7] = attr_newsuperior; - cleattrs[8] = attr_changetime; + cleattrs[0] = retrocl_objectclass; + cleattrs[1] = retrocl_changenumber; + cleattrs[2] = retrocl_targetdn; + cleattrs[3] = retrocl_changetype; + cleattrs[4] = retrocl_newrdn; + cleattrs[5] = retrocl_deleteoldrdn; + cleattrs[6] = retrocl_changes; + cleattrs[7] = retrocl_newsuperior; + cleattrs[8] = retrocl_changetime; cleattrs[9] = NULL; } return cleattrs; @@ -81,7 +81,7 @@ delete_changerecord(changeNumber cnum) char *dnbuf; int delrc; - dnbuf = slapi_ch_smprintf("%s=%ld, %s", attr_changenumber, cnum, + dnbuf = slapi_ch_smprintf("%s=%ld, %s", retrocl_changenumber, cnum, RETROCL_CHANGELOG_DN); pb = slapi_pblock_new(); slapi_delete_internal_set_pb(pb, dnbuf, NULL /*controls*/, NULL /* uniqueid */, @@ -154,7 +154,7 @@ handle_getchangetime_search(Slapi_Entry *e, void *callback_data) if (NULL != e) { Slapi_Value *sval = NULL; const struct berval *val = NULL; - rc = slapi_entry_attr_find(e, attr_changetime, &attr); + rc = slapi_entry_attr_find(e, retrocl_changetime, &attr); /* Bug 624442: Logic checking for lack of timestamp was reversed. */ if (0 != rc || slapi_attr_first_value(attr, &sval) == -1 || @@ -174,14 +174,14 @@ handle_getchangetime_search(Slapi_Entry *e, void *callback_data) /* * Function: get_changetime * Arguments: cnum - number of change record to retrieve - * Returns: Taking the attr_changetime of the 'cnum' entry, + * Returns: Taking the retrocl_changetime of the 'cnum' entry, * it converts it into time_t (parse_localTime) and returns this time value. * It returns 0 in the following cases: - * - changerecord entry has not attr_changetime + * - changerecord entry has not retrocl_changetime * - attr_changetime attribute has no value * - attr_changetime attribute value is empty * - * Description: Retrieve attr_changetime ("changetime") from a changerecord whose number is "cnum". + * Description: Retrieve retrocl_changetime ("changetime") from a changerecord whose number is "cnum". */ static time_t get_changetime(changeNumber cnum, int *err) @@ -198,7 +198,7 @@ get_changetime(changeNumber cnum, int *err) } crtp->crt_nentries = crtp->crt_err = 0; crtp->crt_time = 0; - PR_snprintf(fstr, sizeof(fstr), "%s=%ld", attr_changenumber, cnum); + PR_snprintf(fstr, sizeof(fstr), "%s=%ld", retrocl_changenumber, cnum); pb = slapi_pblock_new(); slapi_search_internal_set_pb(pb, RETROCL_CHANGELOG_DN, -- 2.26.2