ldap/servers
by Mark Reynolds
ldap/servers/plugins/collation/collate.c | 24 +++----
ldap/servers/plugins/replication/windows_protocol_util.c | 9 +-
ldap/servers/slapd/back-ldbm/index.c | 17 ++---
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 24 +------
ldap/servers/slapd/back-ldbm/ldbm_search.c | 2
ldap/servers/slapd/back-ldbm/seq.c | 2
ldap/servers/slapd/bind.c | 2
ldap/servers/slapd/log.c | 46 +++------------
8 files changed, 40 insertions(+), 86 deletions(-)
New commits:
commit db673270e9a01e48adb22d94e676f25a223f407b
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jun 4 13:25:22 2013 -0400
Coverity Fixes (Part 2)
11674 - logically dead code (collate.c)
11675 - logically dead code (windows_protocol_util.c)
11676 - logically dead code (index.c)
11677 - logically dead code (ldbm_entryrdn.c)
11678 - logically dead code (ldbm_entryrdn.c)
11680 - logically dead code (ldbm_search.c)
11681 - Dead default in switch (seq.c)
11683 - logically dead code (bind.c)
11684 - logically dead code (connection.c)
11686 - Dead default in switch (log.c)
11687 - Dead default in switch (log.c)
11688 - Dead default in switch (log.c)
11689 - Dead default in switch (log.c)
11690 - Dead default in switch (log.c)
11691 - Dead default in switch (log.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/collation/collate.c b/ldap/servers/plugins/collation/collate.c
index 240da70..2a73ee1 100644
--- a/ldap/servers/plugins/collation/collate.c
+++ b/ldap/servers/plugins/collation/collate.c
@@ -437,11 +437,7 @@ collation_indexer_create (const char* oid)
profile->variant == NULL);
UErrorCode err = U_ZERO_ERROR;
if ( ! is_default) {
- if (locale) {
- PR_smprintf_free(locale);
- locale = NULL;
- }
- err = s_newNamedLocaleFromComponents(&locale,
+ err = s_newNamedLocaleFromComponents(&locale,
profile->language,
profile->country,
profile->variant);
@@ -460,27 +456,27 @@ collation_indexer_create (const char* oid)
ucol_setAttribute (coll, UCOL_STRENGTH, profile->strength, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
"set the collator strength for oid %s to %d: err %d\n",
oid, profile->strength, err);
}
ucol_setAttribute (coll, UCOL_DECOMPOSITION_MODE, profile->decomposition, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
"set the collator decomposition mode for oid %s to %d: err %d\n",
oid, profile->decomposition, err);
}
etc->collator = coll;
for (id = collation_id; *id; ++id) {
- if ((*id)->profile == profile) {
- break; /* found the 'official' id */
- }
+ if ((*id)->profile == profile) {
+ break; /* found the 'official' id */
+ }
}
- if (!*id) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
- goto error;
- }
+ if (!*id) {
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
+ goto error;
+ }
ix->ix_etc = etc;
ix->ix_oid = (*id)->oid;
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index 03d6ff3..964566a 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -4249,7 +4249,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
windows_is_remote_entry_user_or_group(remote_entry,&is_user,&is_group);
}
- for (rc = slapi_entry_first_attr(remote_entry, &attr); rc == 0;
+ for (rc = slapi_entry_first_attr(remote_entry, &attr); rc == 0;
rc = slapi_entry_next_attr(remote_entry, attr, &attr))
{
int is_present_local = 0;
@@ -4260,7 +4260,6 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
int is_guid = 0;
int mapdn = 0;
-
slapi_attr_get_type( attr, &type );
slapi_attr_get_valueset(attr,&vs);
@@ -4419,7 +4418,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: no restricted local values found for "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
@@ -4431,7 +4430,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: no local values found for "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
@@ -4443,7 +4442,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: could not map the values in "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index a10c67a..e45aba8 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -649,18 +649,17 @@ index_add_mods(
mods[i]->mod_op |= LDAP_MOD_IGNORE;
}
}
- if (mods_valueArray) {
- rc = index_addordel_values_sv( be,
- mods[i]->mod_type,
- mods_valueArray, NULL,
- id, BE_INDEX_ADD, txn );
- if (rc) {
- ldbm_nasty(errmsg, 1042, rc);
- goto error;
- }
+ if(mods_valueArray[0]){
+ rc = index_addordel_values_sv( be, mods[i]->mod_type,
+ mods_valueArray, NULL,
+ id, BE_INDEX_ADD, txn );
} else {
rc = 0;
}
+ if (rc) {
+ ldbm_nasty(errmsg, 1042, rc);
+ goto error;
+ }
}
}
break;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index a3ea091..57b3a20 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -810,14 +810,8 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)oldsupelem;
}
} else {
- if (mynewsupsdn) {
- renamedata.ulen = renamedata.size = newsupelemlen;
- renamedata.data = (void *)newsupelem;
- } else {
- /* never comes here */
- rc = -1;
- goto bail;
- }
+ renamedata.ulen = renamedata.size = newsupelemlen;
+ renamedata.data = (void *)newsupelem;
}
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_PARENT, db_txn);
if (rc) {
@@ -902,16 +896,10 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)targetelem;
}
} else {
- if (mynewsrdn) {
- memset(&renamedata, 0, sizeof(renamedata));
- renamedata.ulen = renamedata.size = newelemlen;
- renamedata.data = (void *)newelem;
- renamedata.flags = DB_DBT_USERMEM;
- } else {
- /* never comes here */
- rc = -1;
- goto bail;
- }
+ memset(&renamedata, 0, sizeof(renamedata));
+ renamedata.ulen = renamedata.size = newelemlen;
+ renamedata.data = (void *)newelem;
+ renamedata.flags = DB_DBT_USERMEM;
}
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_CHILD, db_txn);
if (rc) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index 00cce2c..7e5a20a 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -620,7 +620,7 @@ ldbm_back_search( Slapi_PBlock *pb )
/* This candidate list is for vlv, no need for sort only. */
switch (vlv_search_build_candidate_list(pb, basesdn, &vlv_rc,
sort_control,
- (vlv ? &vlv_request_control : NULL),
+ &vlv_request_control,
&candidates, &vlv_response_control)) {
case VLV_ACCESS_DENIED:
return ldbm_back_search_cleanup(pb, li, sort_control,
diff --git a/ldap/servers/slapd/back-ldbm/seq.c b/ldap/servers/slapd/back-ldbm/seq.c
index 1435ba2..ab473bd 100644
--- a/ldap/servers/slapd/back-ldbm/seq.c
+++ b/ldap/servers/slapd/back-ldbm/seq.c
@@ -221,8 +221,6 @@ ldbm_back_seq( Slapi_PBlock *pb )
}
}
break;
- default:
- PR_ASSERT(0);
}
dbc->c_close(dbc);
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index e92add5..ec874cc 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -178,7 +178,7 @@ do_bind( Slapi_PBlock *pb )
/* check that the dn is formatted correctly */
rc = slapi_dn_syntax_check(pb, rawdn, 1);
if (rc) { /* syntax check failed */
- op_shared_log_error_access(pb, "BIND", rawdn?rawdn:"",
+ op_shared_log_error_access(pb, "BIND", rawdn,
"strict: invalid bind dn");
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX,
NULL, "invalid bind dn", 0, NULL);
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index f483a57..0cf08f0 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -1002,8 +1002,6 @@ log_set_rotationsynchour(const char *attrname, char *rhour_str, int logtype, cha
fe_cfg->auditlog_rotationsynchour = rhour;
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1056,8 +1054,6 @@ log_set_rotationsyncmin(const char *attrname, char *rmin_str, int logtype, char
loginfo.log_audit_rotationsyncclock = log_get_rotationsyncclock( loginfo.log_audit_rotationsynchour, rmin );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1113,8 +1109,6 @@ log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *r
loginfo.log_audit_rotationtime = rtime;
runit = loginfo.log_audit_rotationunit;
break;
- default:
- rv = 1;
}
/* find out the rotation unit we have se right now */
@@ -1142,19 +1136,17 @@ log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *r
fe_cfg->accesslog_rotationtime = rtime;
loginfo.log_access_rotationtime_secs = value;
LOG_ACCESS_UNLOCK_WRITE();
- break;
+ break;
case SLAPD_ERROR_LOG:
fe_cfg->errorlog_rotationtime = rtime;
- loginfo.log_error_rotationtime_secs = value;
- LOG_ERROR_UNLOCK_WRITE();
- break;
+ loginfo.log_error_rotationtime_secs = value;
+ LOG_ERROR_UNLOCK_WRITE();
+ break;
case SLAPD_AUDIT_LOG:
fe_cfg->auditlog_rotationtime = rtime;
- loginfo.log_audit_rotationtime_secs = value;
- LOG_AUDIT_UNLOCK_WRITE();
- break;
- default:
- rv = 1;
+ loginfo.log_audit_rotationtime_secs = value;
+ LOG_AUDIT_UNLOCK_WRITE();
+ break;
}
return rv;
}
@@ -1210,8 +1202,6 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
LOG_AUDIT_LOCK_WRITE( );
origvalue = loginfo.log_audit_rotationtime;
break;
- default:
- rv = 1;
}
if (strcasecmp(runit, "month") == 0) {
@@ -1261,8 +1251,6 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
fe_cfg->auditlog_rotationunit = slapi_ch_strdup ( runit );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
}
@@ -1312,9 +1300,6 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
LOG_AUDIT_LOCK_WRITE( );
mlogsize = loginfo.log_audit_maxlogsize;
break;
- default:
- rv = 1;
- mlogsize = -1;
}
maxdiskspace = (PRInt64)s_maxdiskspace * LOG_MB_IN_BYTES;
if (maxdiskspace < 0) {
@@ -1348,11 +1333,6 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
}
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid log type (%d) for setting maximum disk space: %d MB\n",
- attrname, logtype, s_maxdiskspace);
- rv = LDAP_OPERATIONS_ERROR;
}
return rv;
@@ -1572,10 +1552,6 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
rsecs = loginfo.log_audit_rotationtime_secs;
exptimeunitp = &(loginfo.log_audit_exptimeunit);
break;
- default:
- rv = 1;
- exptime = -1;
- rsecs = -1;
}
value = -1;
@@ -1625,8 +1601,6 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
fe_cfg->auditlog_exptimeunit = slapi_ch_strdup ( expunit );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1748,8 +1722,8 @@ slapd_log_audit_proc (
char *buffer,
int buf_len)
{
- int err;
if ( (loginfo.log_audit_state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL) ){
+ int err;
LOG_AUDIT_LOCK_WRITE( );
if (log__needrotation(loginfo.log_audit_fdes,
SLAPD_AUDIT_LOG) == LOG_ROTATE) {
@@ -4168,9 +4142,9 @@ static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_
static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int err = 0;
-
+
if (type == SLAPD_ACCESS_LOG) {
+ int err = 0;
/* It is only safe to flush once any other threads which are copying are finished */
while (lbi->refcount > 0) {
10 years, 9 months
ldap/servers
by Ludwig Krispenz
ldap/servers/slapd/back-ldbm/back-ldbm.h | 9 +++++
ldap/servers/slapd/back-ldbm/dblayer.c | 47 +++++++++++++++++++++--------
ldap/servers/slapd/back-ldbm/ldbm_add.c | 2 -
ldap/servers/slapd/back-ldbm/ldbm_config.c | 22 +++++++++++++
ldap/servers/slapd/back-ldbm/ldbm_config.h | 1
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 2 -
ldap/servers/slapd/back-ldbm/ldbm_modify.c | 20 +++++++++---
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 2 -
8 files changed, 85 insertions(+), 20 deletions(-)
New commits:
commit a154ecfc9b144d825e400892c84d6327470d6e64
Author: Ludwig Krispenz <lkrispen(a)redhat.com>
Date: Tue May 14 14:04:28 2013 +0200
Ticket 47358 - implement backend optimazation levels
Bug Description: it is an enhancement to be able to test different
otimizations and have the default bahaviour as fallback.
Fix Description: As described in the ticket, this fix introduces
three optimization switches.
1] bypass ruv update inside transaction, might be replaced by
fix for ticket 564
2] reverse order of txn begin/commit and backen lock/unlock
to benefit from fix #568
3] find and lock entry to modify before taking backend lock
to decrease time backend lock is held
https://fedorahosted.org/389/ticket/47358
Reviewed by: Rich, thanks
diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h
index b0f87e1..4645561 100644
--- a/ldap/servers/slapd/back-ldbm/back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h
@@ -654,8 +654,17 @@ struct ldbminfo {
int li_reslimit_rangelookthrough_handle;
int li_idl_update;
int li_old_idl_maxids;
+#define BACKEND_OPT_NO_RUV_UPDATE 0x01
+#define BACKEND_OPT_DBLOCK_INSIDE_TXN 0x02
+#define BACKEND_OPT_MANAGE_ENTRY_BEFORE_DBLOCK 0x04
+ int li_backend_opt_level;
};
+
+#define NO_RUV_UPDATE(li) (li->li_backend_opt_level & BACKEND_OPT_NO_RUV_UPDATE)
+#define DBLOCK_INSIDE_TXN(li) (li->li_backend_opt_level & BACKEND_OPT_DBLOCK_INSIDE_TXN)
+#define MANAGE_ENTRY_BEFORE_DBLOCK(li) (li->li_backend_opt_level & BACKEND_OPT_MANAGE_ENTRY_BEFORE_DBLOCK)
+
/* li_flags could store these bits defined in ../slapi-plugin.h
* task flag (pb_task_flags) *
* SLAPI_TASK_RUNNING_AS_TASK
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 607f802..2f05668 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -3610,12 +3610,19 @@ dblayer_txn_begin(backend *be, back_txnid parent_txn, back_txn *txn)
{
struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private;
int rc = 0;
- if (SERIALLOCK(li)) {
- dblayer_lock_backend(be);
- }
- rc = dblayer_txn_begin_ext(li,parent_txn,txn,PR_TRUE);
- if (rc && SERIALLOCK(li)) {
- dblayer_unlock_backend(be);
+ if (DBLOCK_INSIDE_TXN(li)) {
+ rc = dblayer_txn_begin_ext(li,parent_txn,txn,PR_TRUE);
+ if (!rc && SERIALLOCK(li)) {
+ dblayer_lock_backend(be);
+ }
+ } else {
+ if (SERIALLOCK(li)) {
+ dblayer_lock_backend(be);
+ }
+ rc = dblayer_txn_begin_ext(li,parent_txn,txn,PR_TRUE);
+ if (rc && SERIALLOCK(li)) {
+ dblayer_unlock_backend(be);
+ }
}
return rc;
}
@@ -3721,9 +3728,17 @@ int
dblayer_txn_commit(backend *be, back_txn *txn)
{
struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private;
- int rc = dblayer_txn_commit_ext(li,txn,PR_TRUE);
- if (SERIALLOCK(li)) {
- dblayer_unlock_backend(be);
+ int rc;
+ if (DBLOCK_INSIDE_TXN(li)) {
+ if (SERIALLOCK(li)) {
+ dblayer_unlock_backend(be);
+ }
+ rc = dblayer_txn_commit_ext(li,txn,PR_TRUE);
+ } else {
+ rc = dblayer_txn_commit_ext(li,txn,PR_TRUE);
+ if (SERIALLOCK(li)) {
+ dblayer_unlock_backend(be);
+ }
}
return rc;
}
@@ -3803,9 +3818,17 @@ int
dblayer_txn_abort(backend *be, back_txn *txn)
{
struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private;
- int rc = dblayer_txn_abort_ext(li, txn, PR_TRUE);
- if (SERIALLOCK(li)) {
- dblayer_unlock_backend(be);
+ int rc;
+ if (DBLOCK_INSIDE_TXN(li)) {
+ if (SERIALLOCK(li)) {
+ dblayer_unlock_backend(be);
+ }
+ rc = dblayer_txn_abort_ext(li, txn, PR_TRUE);
+ } else {
+ rc = dblayer_txn_abort_ext(li, txn, PR_TRUE);
+ if (SERIALLOCK(li)) {
+ dblayer_unlock_backend(be);
+ }
}
return rc;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index eab2ae1..c7d1f62 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -759,7 +759,7 @@ ldbm_back_add( Slapi_PBlock *pb )
parententry = NULL;
}
- if (!is_ruv && !is_fixup_operation) {
+ if (!is_ruv && !is_fixup_operation && !NO_RUV_UPDATE(li)) {
ruv_c_init = ldbm_txn_ruv_modify_context( pb, &ruv_c );
if (-1 == ruv_c_init) {
LDAPDebug( LDAP_DEBUG_ANY,
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index 056c14c..2466861 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -209,6 +209,27 @@ static int ldbm_config_rangelookthroughlimit_set(void *arg, void *value, char *e
return retval;
}
+static void *ldbm_config_backend_opt_level_get(void *arg)
+{
+ struct ldbminfo *li = (struct ldbminfo *) arg;
+
+ return (void *) ((uintptr_t)(li->li_backend_opt_level));
+}
+
+static int ldbm_config_backend_opt_level_set(void *arg, void *value, char *errorbuf, int phase, int apply)
+{
+ struct ldbminfo *li = (struct ldbminfo *) arg;
+ int retval = LDAP_SUCCESS;
+ int val = (int) ((uintptr_t)value);
+
+ /* Do whatever we can to make sure the data is ok. */
+
+ if (apply) {
+ li->li_backend_opt_level = val;
+ }
+
+ return retval;
+}
static void *ldbm_config_mode_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
@@ -1415,6 +1436,7 @@ static config_info ldbm_config[] = {
{CONFIG_PAGEDLOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "0", &ldbm_config_pagedlookthroughlimit_get, &ldbm_config_pagedlookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_PAGEDIDLISTSCANLIMIT, CONFIG_TYPE_INT, "0", &ldbm_config_pagedallidsthreshold_get, &ldbm_config_pagedallidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
{CONFIG_RANGELOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "5000", &ldbm_config_rangelookthroughlimit_get, &ldbm_config_rangelookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
+ {CONFIG_BACKEND_OPT_LEVEL, CONFIG_TYPE_INT, "0", &ldbm_config_backend_opt_level_get, &ldbm_config_backend_opt_level_set, CONFIG_FLAG_ALWAYS_SHOW},
{NULL, 0, NULL, NULL, NULL, 0}
};
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h
index 456d27d..af6b2d0 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.h
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h
@@ -145,6 +145,7 @@ struct config_info {
#define CONFIG_BYPASS_FILTER_TEST "nsslapd-search-bypass-filter-test"
#define CONFIG_USE_VLV_INDEX "nsslapd-search-use-vlv-index"
#define CONFIG_SERIAL_LOCK "nsslapd-serial-lock"
+#define CONFIG_BACKEND_OPT_LEVEL "nsslapd-backend-opt-level"
#define CONFIG_ENTRYRDN_SWITCH "nsslapd-subtree-rename-switch"
/* nsslapd-noancestorid is ignored unless nsslapd-subtree-rename-switch is on */
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index 6efa03e..0478a12 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -551,7 +551,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
}
}
- if (!is_ruv && !is_fixup_operation && !delete_tombstone_entry) {
+ if (!is_ruv && !is_fixup_operation && !delete_tombstone_entry && !NO_RUV_UPDATE(li)) {
ruv_c_init = ldbm_txn_ruv_modify_context( pb, &ruv_c );
if (-1 == ruv_c_init) {
LDAPDebug( LDAP_DEBUG_ANY,
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index 1e728da..17adc87 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -410,6 +410,14 @@ ldbm_back_modify( Slapi_PBlock *pb )
dblock_acquired= 1;
}
*/
+ if ( MANAGE_ENTRY_BEFORE_DBLOCK(li)) {
+ /* find and lock the entry we are about to modify */
+ if ( (e = find_entry2modify( pb, be, addr, &txn )) == NULL ) {
+ ldap_result_code= -1;
+ goto error_return; /* error result sent by find_entry2modify() */
+ }
+ }
+
txn.back_txn_txn = NULL; /* ready to create the child transaction */
for (retry_count = 0; retry_count < RETRY_TIMES; retry_count++) {
int cache_rc = 0;
@@ -467,10 +475,12 @@ ldbm_back_modify( Slapi_PBlock *pb )
slapi_pblock_set(pb, SLAPI_TXN, txn.back_txn_txn);
if (0 == retry_count) { /* just once */
- /* find and lock the entry we are about to modify */
- if ( (e = find_entry2modify( pb, be, addr, &txn )) == NULL ) {
- ldap_result_code= -1;
- goto error_return; /* error result sent by find_entry2modify() */
+ if ( !MANAGE_ENTRY_BEFORE_DBLOCK(li)) {
+ /* find and lock the entry we are about to modify */
+ if ( (e = find_entry2modify( pb, be, addr, &txn )) == NULL ) {
+ ldap_result_code= -1;
+ goto error_return; /* error result sent by find_entry2modify() */
+ }
}
if ( !is_fixup_operation )
@@ -543,7 +553,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
goto error_return;
}
- if (!is_ruv && !is_fixup_operation) {
+ if (!is_ruv && !is_fixup_operation && !NO_RUV_UPDATE(li)) {
ruv_c_init = ldbm_txn_ruv_modify_context( pb, &ruv_c );
if (-1 == ruv_c_init) {
LDAPDebug( LDAP_DEBUG_ANY,
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 80bf2f4..bcc59b3 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -839,7 +839,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
/* JCM - A subtree move could break ACIs, static groups, and dynamic groups. */
}
- if (!is_ruv && !is_fixup_operation) {
+ if (!is_ruv && !is_fixup_operation && !NO_RUV_UPDATE(li)) {
ruv_c_init = ldbm_txn_ruv_modify_context( pb, &ruv_c );
if (-1 == ruv_c_init) {
LDAPDebug( LDAP_DEBUG_ANY,
10 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5_protocol_util.c | 2
ldap/servers/slapd/agtmmap.c | 69 ++++++++---------
ldap/servers/slapd/back-ldbm/dblayer.c | 7 +
ldap/servers/slapd/daemon.c | 29 ++++---
ldap/servers/slapd/log.c | 18 ++++
ldap/servers/slapd/main.c | 5 -
ldap/servers/slapd/ssl.c | 17 +++-
ldap/servers/slapd/tools/ldclt/ldclt.c | 4
ldap/servers/slapd/tools/rsearch/sdattable.c | 2
ldap/servers/slapd/util.c | 2
10 files changed, 98 insertions(+), 57 deletions(-)
New commits:
commit f771f95f3f34442a9c238b687227d1d17a1015e7
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Jun 3 17:17:24 2013 -0400
Coverity Fixes (part 1)
11648 - string length miscalulation (ldclt.c)
11655 - unchecked return value (agtmmap.c)
11656 - unchecked return value (dblayer.c)
11657 - unchecked return value (daemon.c)
11658 - unchecked return value (daemon.c)
11660 - unchecked return value (log.c)
11661 - unchecked return value (main.c)
11662 - unchecked return value (ssl.c)
11668 - Same on both sides (repl5_protocol_util.c)
11669 - Same on both sides (ssl.c)
11670 - Same on both sides (util.c)
11673 - Copy-and-paste error (tools/rsearch/sdattable.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: Noriko(Thanks!)
(cherry picked from commit 2b5aecb77784a9cf68fe29204f15bd4b61159d6d)
diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c
index 30d211a..4449170 100644
--- a/ldap/servers/plugins/replication/repl5_protocol_util.c
+++ b/ldap/servers/plugins/replication/repl5_protocol_util.c
@@ -603,7 +603,7 @@ release_replica(Private_Repl_Protocol *prp)
struct berval *data = NULL;
/* Check the message id's match */
- if (sent_message_id != sent_message_id)
+ if (sent_message_id != ret_message_id)
{
int operation, error;
conn_get_error(prp->conn, &operation, &error);
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index d82da5f..f18138a 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -187,46 +187,49 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
if ( fd < 0 )
{
- err = errno;
+ err = errno;
#if (0)
- fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
+ fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- rc = err;
- goto bail;
- }
+ rc = err;
+ goto bail;
+ }
- fstat (fd, &fileinfo);
-
- sz = sizeof (struct agt_stats_t);
-
- if (fileinfo.st_size < sz)
- {
- /* Without this we will get segv when we try to read/write later */
- buf = calloc (1, sz);
- (void)write (fd, buf, sz);
- free (buf);
- }
-
- fp = mmap (NULL, sz, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
-
- if (fp == (caddr_t) -1)
- {
- err = errno;
- close (fd);
+ if(fstat (fd, &fileinfo) != 0){
+ rc = errno;
+ goto bail;
+ }
+
+ sz = sizeof (struct agt_stats_t);
+
+ if (fileinfo.st_size < sz)
+ {
+ /* Without this we will get segv when we try to read/write later */
+ buf = calloc (1, sz);
+ (void)write (fd, buf, sz);
+ free (buf);
+ }
+
+ fp = mmap (NULL, sz, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
+
+ if (fp == (caddr_t) -1)
+ {
+ err = errno;
+ close (fd);
#if (0)
- fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
+ fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- rc = err;
- goto bail;
- }
+ rc = err;
+ goto bail;
+ }
- mmap_tbl [1].maptype = AGT_MAP_RDWR;
- mmap_tbl [1].fd = fd;
- mmap_tbl [1].fp = fp;
- *hdl = 1;
+ mmap_tbl [1].maptype = AGT_MAP_RDWR;
+ mmap_tbl [1].fd = fd;
+ mmap_tbl [1].fp = fp;
+ *hdl = 1;
- rc = 0;
- break;
+ rc = 0;
+ break;
} /* end switch */
#else
/* _WIN32 */
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 804543b..f22f8e8 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4471,7 +4471,12 @@ static int checkpoint_threadmain(void *param)
"%s.old", *listp);
checkpoint_debug_message(debug_checkpointing,
"Renaming %s -> %s\n",*listp, new_filename, 0);
- rename(*listp, new_filename);
+ if(rename(*listp, new_filename) != 0){
+ LDAPDebug(LDAP_DEBUG_ANY, "checkpoint_threadmain: failed to rename log (%s) to (%s)\n",
+ *listp, new_filename, 0);
+ rval = -1;
+ goto error_return;
+ }
}
}
slapi_ch_free((void**)&list);
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 3f3061c..9293557 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -3385,8 +3385,14 @@ createsignalpipe( void )
}
writesignalpipe = PR_FileDesc2NativeHandle(signalpipe[1]);
readsignalpipe = PR_FileDesc2NativeHandle(signalpipe[0]);
- fcntl(writesignalpipe, F_SETFD, O_NONBLOCK);
- fcntl(readsignalpipe, F_SETFD, O_NONBLOCK);
+ if(fcntl(writesignalpipe, F_SETFD, O_NONBLOCK) == -1){
+ LDAPDebug( LDAP_DEBUG_ANY,"createsignalpipe: failed to set FD for write pipe (%d).\n",
+ errno, 0, 0 );
+ }
+ if(fcntl(readsignalpipe, F_SETFD, O_NONBLOCK) == -1){
+ LDAPDebug( LDAP_DEBUG_ANY,"createsignalpipe: failed to set FD for read pipe (%d).\n",
+ errno, 0, 0);
+ }
#endif
return( 0 );
@@ -3606,7 +3612,7 @@ void configure_ns_socket( int * ns )
{
int enable_nagle = config_get_nagle();
- int on;
+ int on, rc;
#if defined(LINUX)
/* On Linux we use TCP_CORK so we must enable nagle */
@@ -3616,19 +3622,18 @@ void configure_ns_socket( int * ns )
if ( have_send_timeouts ) {
daemon_configure_send_timeout( *ns, config_get_ioblocktimeout() );
}
-
-
+ /* set the nagle */
if ( !enable_nagle ) {
- on = 1;
- setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
+ on = 1;
} else {
- on = 0;
- setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
- } /* else (!enable_nagle) */
-
+ on = 0;
+ }
+ /* check for errors */
+ if((rc = setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) ) != 0)){
+ LDAPDebug( LDAP_DEBUG_ANY,"configure_ns_socket: Failed to configure socket (%d).\n", rc, 0, 0);
+ }
return;
-
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index e65b247..83a445c 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -3781,6 +3781,9 @@ log__open_errorlogfile(int logfile_state, int locked)
struct logfileinfo *logp;
char buffer[BUFSIZ];
struct passwd *pw = NULL;
+#ifndef _WIN32
+ int rc = 0;
+#endif
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -3878,7 +3881,20 @@ log__open_errorlogfile(int logfile_state, int locked)
* alternate ns-slapd modes, such as db2bak, tries to log an error
* at startup, it will create the logfile as root!
*/
- slapd_chown_if_not_owner(loginfo.log_error_file, pw->pw_uid, -1);
+ if((rc = slapd_chown_if_not_owner(loginfo.log_error_file, pw->pw_uid, -1)) != 0){
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to chown log file %s: error %d (%s); Exiting...",
+ loginfo.log_error_file, errno, slapd_system_strerror(errno));
+ log__error_emergency(buffer, 1, locked);
+ if (!locked) LOG_ERROR_UNLOCK_WRITE();
+ /* failed to write to the errors log. should not continue. */
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ /*if I have an old log file -- I should log a message
+ ** that I can't open the new file. Let the caller worry
+ ** about logging message.
+ */
+ return LOG_UNABLE_TO_OPENFILE;
+ }
#endif
loginfo.log_error_fdes = fp;
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 84ce01d..9938c01 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -247,7 +247,10 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn, PRBool both)
while( (entry = PR_ReadDir(dir , PR_SKIP_BOTH )) !=NULL )
{
PR_snprintf(file,MAXPATHLEN+1,"%s/%s",log,entry->name);
- slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 );
+ if((rc = slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )) != 0){
+ LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
+ file, errno, slapd_system_strerror(errno));
+ }
}
PR_CloseDir( dir );
}
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index 0aab53d..f515b8e 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -360,7 +360,7 @@ _conf_setciphers(char *ciphers)
if(t)
ciphers = t;
}
- if (unsuplist && unsuplist) {
+ if (unsuplist && *unsuplist) {
char *strsup = charray2str(suplist, ",");
char *strunsup = charray2str(unsuplist, ",");
slapd_SSL_warn("Security Initialization: FIPS mode is enabled - only the following "
@@ -614,9 +614,18 @@ slapd_nss_init(int init_ssl, int config_available)
certdb_file_name = slapi_ch_smprintf("%s/cert8.db", certdir);
keydb_file_name = slapi_ch_smprintf("%s/key3.db", certdir);
secmoddb_file_name = slapi_ch_smprintf("%s/secmod.db", certdir);
- chmod(certdb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- chmod(keydb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ if(chmod(certdb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ certdb_file_name, errno, slapd_system_strerror(errno));
+ }
+ if(chmod(keydb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ keydb_file_name, errno, slapd_system_strerror(errno));
+ }
+ if(chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ secmoddb_file_name, errno, slapd_system_strerror(errno));
+ }
}
/****** end of NSS Initialization ******/
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c b/ldap/servers/slapd/tools/ldclt/ldclt.c
index 27a2412..2a45c76 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.c
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.c
@@ -1497,7 +1497,7 @@ basicInit (void)
/*
* Parse the deference attribute value
*/
- mctx.attRefDef= (char *)malloc(strlen(mctx.attrpl+i+1) + 1);
+ mctx.attRefDef= (char *)malloc(strlen(mctx.attrpl + i) + 2);
if (mctx.attRefDef== NULL) {
printf ("Error: unable to allocate memory for attRefDef\n");
return (-1);
@@ -1525,7 +1525,7 @@ basicInit (void)
/*
* Parse the attribute value
*/
- mctx.attrplFile = (char *)malloc(strlen(mctx.attrpl+i+1) + 1);
+ mctx.attrplFile = (char *)malloc(strlen(mctx.attrpl+i) + 2);
if (mctx.attrplFile == NULL) {
printf ("Error: unable to allocate memory for attreplfile\n");
return (-1);
diff --git a/ldap/servers/slapd/tools/rsearch/sdattable.c b/ldap/servers/slapd/tools/rsearch/sdattable.c
index df1c152..c0274d0 100644
--- a/ldap/servers/slapd/tools/rsearch/sdattable.c
+++ b/ldap/servers/slapd/tools/rsearch/sdattable.c
@@ -183,7 +183,7 @@ int sdt_save(SDatTable *sdt, const char *filename)
PR_Write(fd, sdt->dns[i], strlen(sdt->dns[i]));
PR_Write(fd, "\n", 1);
}
- if (sdt->dns[i]) {
+ if (sdt->uids[i]) {
PR_Write(fd, "uid: ", 5);
PR_Write(fd, sdt->uids[i], strlen(sdt->uids[i]));
PR_Write(fd, "\n", 1);
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
index 649b3a9..0a9d23d 100644
--- a/ldap/servers/slapd/util.c
+++ b/ldap/servers/slapd/util.c
@@ -417,7 +417,7 @@ normalize_mods2bvals(const LDAPMod **mods)
num_values++;
}
} else {
- for (x = 0; mods[w]->mod_values[x] != NULL &&
+ for (x = 0; mods[w]->mod_values != NULL &&
mods[w]->mod_values[x] != NULL; x++)
{
num_values++;
10 years, 10 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5_protocol_util.c | 2
ldap/servers/slapd/agtmmap.c | 69 ++++++++---------
ldap/servers/slapd/back-ldbm/dblayer.c | 7 +
ldap/servers/slapd/daemon.c | 29 ++++---
ldap/servers/slapd/log.c | 18 ++++
ldap/servers/slapd/main.c | 5 -
ldap/servers/slapd/ssl.c | 17 +++-
ldap/servers/slapd/tools/ldclt/ldclt.c | 4
ldap/servers/slapd/tools/rsearch/sdattable.c | 2
ldap/servers/slapd/util.c | 2
10 files changed, 98 insertions(+), 57 deletions(-)
New commits:
commit 275628c4a9e3ee766fd0abcf8590e63c9abfdd3d
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Jun 3 17:17:24 2013 -0400
Coverity Fixes (part 1)
11648 - string length miscalulation (ldclt.c)
11655 - unchecked return value (agtmmap.c)
11656 - unchecked return value (dblayer.c)
11657 - unchecked return value (daemon.c)
11658 - unchecked return value (daemon.c)
11660 - unchecked return value (log.c)
11661 - unchecked return value (main.c)
11662 - unchecked return value (ssl.c)
11668 - Same on both sides (repl5_protocol_util.c)
11669 - Same on both sides (ssl.c)
11670 - Same on both sides (util.c)
11673 - Copy-and-paste error (tools/rsearch/sdattable.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: Noriko(Thanks!)
(cherry picked from commit 2b5aecb77784a9cf68fe29204f15bd4b61159d6d)
diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c
index 30d211a..4449170 100644
--- a/ldap/servers/plugins/replication/repl5_protocol_util.c
+++ b/ldap/servers/plugins/replication/repl5_protocol_util.c
@@ -603,7 +603,7 @@ release_replica(Private_Repl_Protocol *prp)
struct berval *data = NULL;
/* Check the message id's match */
- if (sent_message_id != sent_message_id)
+ if (sent_message_id != ret_message_id)
{
int operation, error;
conn_get_error(prp->conn, &operation, &error);
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index d82da5f..f18138a 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -187,46 +187,49 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
if ( fd < 0 )
{
- err = errno;
+ err = errno;
#if (0)
- fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
+ fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- rc = err;
- goto bail;
- }
+ rc = err;
+ goto bail;
+ }
- fstat (fd, &fileinfo);
-
- sz = sizeof (struct agt_stats_t);
-
- if (fileinfo.st_size < sz)
- {
- /* Without this we will get segv when we try to read/write later */
- buf = calloc (1, sz);
- (void)write (fd, buf, sz);
- free (buf);
- }
-
- fp = mmap (NULL, sz, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
-
- if (fp == (caddr_t) -1)
- {
- err = errno;
- close (fd);
+ if(fstat (fd, &fileinfo) != 0){
+ rc = errno;
+ goto bail;
+ }
+
+ sz = sizeof (struct agt_stats_t);
+
+ if (fileinfo.st_size < sz)
+ {
+ /* Without this we will get segv when we try to read/write later */
+ buf = calloc (1, sz);
+ (void)write (fd, buf, sz);
+ free (buf);
+ }
+
+ fp = mmap (NULL, sz, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
+
+ if (fp == (caddr_t) -1)
+ {
+ err = errno;
+ close (fd);
#if (0)
- fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
+ fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- rc = err;
- goto bail;
- }
+ rc = err;
+ goto bail;
+ }
- mmap_tbl [1].maptype = AGT_MAP_RDWR;
- mmap_tbl [1].fd = fd;
- mmap_tbl [1].fp = fp;
- *hdl = 1;
+ mmap_tbl [1].maptype = AGT_MAP_RDWR;
+ mmap_tbl [1].fd = fd;
+ mmap_tbl [1].fp = fp;
+ *hdl = 1;
- rc = 0;
- break;
+ rc = 0;
+ break;
} /* end switch */
#else
/* _WIN32 */
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 5e53de9..217b20a 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4529,7 +4529,12 @@ static int checkpoint_threadmain(void *param)
"%s.old", *listp);
checkpoint_debug_message(debug_checkpointing,
"Renaming %s -> %s\n",*listp, new_filename, 0);
- rename(*listp, new_filename);
+ if(rename(*listp, new_filename) != 0){
+ LDAPDebug(LDAP_DEBUG_ANY, "checkpoint_threadmain: failed to rename log (%s) to (%s)\n",
+ *listp, new_filename, 0);
+ rval = -1;
+ goto error_return;
+ }
}
}
slapi_ch_free((void**)&list);
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 18ca091..07fa0dc 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -3390,8 +3390,14 @@ createsignalpipe( void )
}
writesignalpipe = PR_FileDesc2NativeHandle(signalpipe[1]);
readsignalpipe = PR_FileDesc2NativeHandle(signalpipe[0]);
- fcntl(writesignalpipe, F_SETFD, O_NONBLOCK);
- fcntl(readsignalpipe, F_SETFD, O_NONBLOCK);
+ if(fcntl(writesignalpipe, F_SETFD, O_NONBLOCK) == -1){
+ LDAPDebug( LDAP_DEBUG_ANY,"createsignalpipe: failed to set FD for write pipe (%d).\n",
+ errno, 0, 0 );
+ }
+ if(fcntl(readsignalpipe, F_SETFD, O_NONBLOCK) == -1){
+ LDAPDebug( LDAP_DEBUG_ANY,"createsignalpipe: failed to set FD for read pipe (%d).\n",
+ errno, 0, 0);
+ }
#endif
return( 0 );
@@ -3611,7 +3617,7 @@ void configure_ns_socket( int * ns )
{
int enable_nagle = config_get_nagle();
- int on;
+ int on, rc;
#if defined(LINUX)
/* On Linux we use TCP_CORK so we must enable nagle */
@@ -3621,19 +3627,18 @@ void configure_ns_socket( int * ns )
if ( have_send_timeouts ) {
daemon_configure_send_timeout( *ns, config_get_ioblocktimeout() );
}
-
-
+ /* set the nagle */
if ( !enable_nagle ) {
- on = 1;
- setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
+ on = 1;
} else {
- on = 0;
- setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
- } /* else (!enable_nagle) */
-
+ on = 0;
+ }
+ /* check for errors */
+ if((rc = setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) ) != 0)){
+ LDAPDebug( LDAP_DEBUG_ANY,"configure_ns_socket: Failed to configure socket (%d).\n", rc, 0, 0);
+ }
return;
-
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index d1c63bc..f483a57 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -3781,6 +3781,9 @@ log__open_errorlogfile(int logfile_state, int locked)
struct logfileinfo *logp;
char buffer[BUFSIZ];
struct passwd *pw = NULL;
+#ifndef _WIN32
+ int rc = 0;
+#endif
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -3878,7 +3881,20 @@ log__open_errorlogfile(int logfile_state, int locked)
* alternate ns-slapd modes, such as db2bak, tries to log an error
* at startup, it will create the logfile as root!
*/
- slapd_chown_if_not_owner(loginfo.log_error_file, pw->pw_uid, -1);
+ if((rc = slapd_chown_if_not_owner(loginfo.log_error_file, pw->pw_uid, -1)) != 0){
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to chown log file %s: error %d (%s); Exiting...",
+ loginfo.log_error_file, errno, slapd_system_strerror(errno));
+ log__error_emergency(buffer, 1, locked);
+ if (!locked) LOG_ERROR_UNLOCK_WRITE();
+ /* failed to write to the errors log. should not continue. */
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ /*if I have an old log file -- I should log a message
+ ** that I can't open the new file. Let the caller worry
+ ** about logging message.
+ */
+ return LOG_UNABLE_TO_OPENFILE;
+ }
#endif
loginfo.log_error_fdes = fp;
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index f438fce..f68a6ab 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -247,7 +247,10 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn, PRBool both)
while( (entry = PR_ReadDir(dir , PR_SKIP_BOTH )) !=NULL )
{
PR_snprintf(file,MAXPATHLEN+1,"%s/%s",log,entry->name);
- slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 );
+ if((rc = slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )) != 0){
+ LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
+ file, errno, slapd_system_strerror(errno));
+ }
}
PR_CloseDir( dir );
}
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index 0aab53d..f515b8e 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -360,7 +360,7 @@ _conf_setciphers(char *ciphers)
if(t)
ciphers = t;
}
- if (unsuplist && unsuplist) {
+ if (unsuplist && *unsuplist) {
char *strsup = charray2str(suplist, ",");
char *strunsup = charray2str(unsuplist, ",");
slapd_SSL_warn("Security Initialization: FIPS mode is enabled - only the following "
@@ -614,9 +614,18 @@ slapd_nss_init(int init_ssl, int config_available)
certdb_file_name = slapi_ch_smprintf("%s/cert8.db", certdir);
keydb_file_name = slapi_ch_smprintf("%s/key3.db", certdir);
secmoddb_file_name = slapi_ch_smprintf("%s/secmod.db", certdir);
- chmod(certdb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- chmod(keydb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ if(chmod(certdb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ certdb_file_name, errno, slapd_system_strerror(errno));
+ }
+ if(chmod(keydb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ keydb_file_name, errno, slapd_system_strerror(errno));
+ }
+ if(chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ secmoddb_file_name, errno, slapd_system_strerror(errno));
+ }
}
/****** end of NSS Initialization ******/
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c b/ldap/servers/slapd/tools/ldclt/ldclt.c
index 27a2412..2a45c76 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.c
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.c
@@ -1497,7 +1497,7 @@ basicInit (void)
/*
* Parse the deference attribute value
*/
- mctx.attRefDef= (char *)malloc(strlen(mctx.attrpl+i+1) + 1);
+ mctx.attRefDef= (char *)malloc(strlen(mctx.attrpl + i) + 2);
if (mctx.attRefDef== NULL) {
printf ("Error: unable to allocate memory for attRefDef\n");
return (-1);
@@ -1525,7 +1525,7 @@ basicInit (void)
/*
* Parse the attribute value
*/
- mctx.attrplFile = (char *)malloc(strlen(mctx.attrpl+i+1) + 1);
+ mctx.attrplFile = (char *)malloc(strlen(mctx.attrpl+i) + 2);
if (mctx.attrplFile == NULL) {
printf ("Error: unable to allocate memory for attreplfile\n");
return (-1);
diff --git a/ldap/servers/slapd/tools/rsearch/sdattable.c b/ldap/servers/slapd/tools/rsearch/sdattable.c
index df1c152..c0274d0 100644
--- a/ldap/servers/slapd/tools/rsearch/sdattable.c
+++ b/ldap/servers/slapd/tools/rsearch/sdattable.c
@@ -183,7 +183,7 @@ int sdt_save(SDatTable *sdt, const char *filename)
PR_Write(fd, sdt->dns[i], strlen(sdt->dns[i]));
PR_Write(fd, "\n", 1);
}
- if (sdt->dns[i]) {
+ if (sdt->uids[i]) {
PR_Write(fd, "uid: ", 5);
PR_Write(fd, sdt->uids[i], strlen(sdt->uids[i]));
PR_Write(fd, "\n", 1);
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
index bdff366..06a6b98 100644
--- a/ldap/servers/slapd/util.c
+++ b/ldap/servers/slapd/util.c
@@ -719,7 +719,7 @@ normalize_mods2bvals(const LDAPMod **mods)
num_values++;
}
} else {
- for (x = 0; mods[w]->mod_values[x] != NULL &&
+ for (x = 0; mods[w]->mod_values != NULL &&
mods[w]->mod_values[x] != NULL; x++)
{
num_values++;
10 years, 10 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5_protocol_util.c | 2
ldap/servers/slapd/agtmmap.c | 69 ++++++++---------
ldap/servers/slapd/back-ldbm/dblayer.c | 7 +
ldap/servers/slapd/daemon.c | 29 ++++---
ldap/servers/slapd/log.c | 18 ++++
ldap/servers/slapd/main.c | 5 -
ldap/servers/slapd/ssl.c | 17 +++-
ldap/servers/slapd/tools/ldclt/ldclt.c | 4
ldap/servers/slapd/tools/rsearch/sdattable.c | 2
ldap/servers/slapd/util.c | 2
10 files changed, 98 insertions(+), 57 deletions(-)
New commits:
commit bd63aa881eddfd05d78e72980b8482c33a077d61
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Jun 3 17:17:24 2013 -0400
Coverity Fixes (part 1)
11648 - string length miscalulation (ldclt.c)
11655 - unchecked return value (agtmmap.c)
11656 - unchecked return value (dblayer.c)
11657 - unchecked return value (daemon.c)
11658 - unchecked return value (daemon.c)
11660 - unchecked return value (log.c)
11661 - unchecked return value (main.c)
11662 - unchecked return value (ssl.c)
11668 - Same on both sides (repl5_protocol_util.c)
11669 - Same on both sides (ssl.c)
11670 - Same on both sides (util.c)
11673 - Copy-and-paste error (tools/rsearch/sdattable.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: Noriko(Thanks!)
(cherry picked from commit 2b5aecb77784a9cf68fe29204f15bd4b61159d6d)
diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c
index 56f8532..82af970 100644
--- a/ldap/servers/plugins/replication/repl5_protocol_util.c
+++ b/ldap/servers/plugins/replication/repl5_protocol_util.c
@@ -603,7 +603,7 @@ release_replica(Private_Repl_Protocol *prp)
struct berval *data = NULL;
/* Check the message id's match */
- if (sent_message_id != sent_message_id)
+ if (sent_message_id != ret_message_id)
{
int operation, error;
conn_get_error(prp->conn, &operation, &error);
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index d82da5f..f18138a 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -187,46 +187,49 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
if ( fd < 0 )
{
- err = errno;
+ err = errno;
#if (0)
- fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
+ fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- rc = err;
- goto bail;
- }
+ rc = err;
+ goto bail;
+ }
- fstat (fd, &fileinfo);
-
- sz = sizeof (struct agt_stats_t);
-
- if (fileinfo.st_size < sz)
- {
- /* Without this we will get segv when we try to read/write later */
- buf = calloc (1, sz);
- (void)write (fd, buf, sz);
- free (buf);
- }
-
- fp = mmap (NULL, sz, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
-
- if (fp == (caddr_t) -1)
- {
- err = errno;
- close (fd);
+ if(fstat (fd, &fileinfo) != 0){
+ rc = errno;
+ goto bail;
+ }
+
+ sz = sizeof (struct agt_stats_t);
+
+ if (fileinfo.st_size < sz)
+ {
+ /* Without this we will get segv when we try to read/write later */
+ buf = calloc (1, sz);
+ (void)write (fd, buf, sz);
+ free (buf);
+ }
+
+ fp = mmap (NULL, sz, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
+
+ if (fp == (caddr_t) -1)
+ {
+ err = errno;
+ close (fd);
#if (0)
- fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
+ fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- rc = err;
- goto bail;
- }
+ rc = err;
+ goto bail;
+ }
- mmap_tbl [1].maptype = AGT_MAP_RDWR;
- mmap_tbl [1].fd = fd;
- mmap_tbl [1].fp = fp;
- *hdl = 1;
+ mmap_tbl [1].maptype = AGT_MAP_RDWR;
+ mmap_tbl [1].fd = fd;
+ mmap_tbl [1].fp = fp;
+ *hdl = 1;
- rc = 0;
- break;
+ rc = 0;
+ break;
} /* end switch */
#else
/* _WIN32 */
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index e272cfa..5f94a29 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4556,7 +4556,12 @@ static int checkpoint_threadmain(void *param)
"%s.old", *listp);
checkpoint_debug_message(debug_checkpointing,
"Renaming %s -> %s\n",*listp, new_filename, 0);
- rename(*listp, new_filename);
+ if(rename(*listp, new_filename) != 0){
+ LDAPDebug(LDAP_DEBUG_ANY, "checkpoint_threadmain: failed to rename log (%s) to (%s)\n",
+ *listp, new_filename, 0);
+ rval = -1;
+ goto error_return;
+ }
}
}
slapi_ch_free((void**)&list);
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index b0e0ed2..2e315f4 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -3391,8 +3391,14 @@ createsignalpipe( void )
}
writesignalpipe = PR_FileDesc2NativeHandle(signalpipe[1]);
readsignalpipe = PR_FileDesc2NativeHandle(signalpipe[0]);
- fcntl(writesignalpipe, F_SETFD, O_NONBLOCK);
- fcntl(readsignalpipe, F_SETFD, O_NONBLOCK);
+ if(fcntl(writesignalpipe, F_SETFD, O_NONBLOCK) == -1){
+ LDAPDebug( LDAP_DEBUG_ANY,"createsignalpipe: failed to set FD for write pipe (%d).\n",
+ errno, 0, 0 );
+ }
+ if(fcntl(readsignalpipe, F_SETFD, O_NONBLOCK) == -1){
+ LDAPDebug( LDAP_DEBUG_ANY,"createsignalpipe: failed to set FD for read pipe (%d).\n",
+ errno, 0, 0);
+ }
#endif
return( 0 );
@@ -3606,7 +3612,7 @@ void configure_ns_socket( int * ns )
{
int enable_nagle = config_get_nagle();
- int on;
+ int on, rc;
#if defined(LINUX)
/* On Linux we use TCP_CORK so we must enable nagle */
@@ -3616,19 +3622,18 @@ void configure_ns_socket( int * ns )
if ( have_send_timeouts ) {
daemon_configure_send_timeout( *ns, config_get_ioblocktimeout() );
}
-
-
+ /* set the nagle */
if ( !enable_nagle ) {
- on = 1;
- setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
+ on = 1;
} else {
- on = 0;
- setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
- } /* else (!enable_nagle) */
-
+ on = 0;
+ }
+ /* check for errors */
+ if((rc = setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) ) != 0)){
+ LDAPDebug( LDAP_DEBUG_ANY,"configure_ns_socket: Failed to configure socket (%d).\n", rc, 0, 0);
+ }
return;
-
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index d1c63bc..f483a57 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -3781,6 +3781,9 @@ log__open_errorlogfile(int logfile_state, int locked)
struct logfileinfo *logp;
char buffer[BUFSIZ];
struct passwd *pw = NULL;
+#ifndef _WIN32
+ int rc = 0;
+#endif
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -3878,7 +3881,20 @@ log__open_errorlogfile(int logfile_state, int locked)
* alternate ns-slapd modes, such as db2bak, tries to log an error
* at startup, it will create the logfile as root!
*/
- slapd_chown_if_not_owner(loginfo.log_error_file, pw->pw_uid, -1);
+ if((rc = slapd_chown_if_not_owner(loginfo.log_error_file, pw->pw_uid, -1)) != 0){
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to chown log file %s: error %d (%s); Exiting...",
+ loginfo.log_error_file, errno, slapd_system_strerror(errno));
+ log__error_emergency(buffer, 1, locked);
+ if (!locked) LOG_ERROR_UNLOCK_WRITE();
+ /* failed to write to the errors log. should not continue. */
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ /*if I have an old log file -- I should log a message
+ ** that I can't open the new file. Let the caller worry
+ ** about logging message.
+ */
+ return LOG_UNABLE_TO_OPENFILE;
+ }
#endif
loginfo.log_error_fdes = fp;
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index e97e5ef..321511d 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -247,7 +247,10 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn, PRBool both)
while( (entry = PR_ReadDir(dir , PR_SKIP_BOTH )) !=NULL )
{
PR_snprintf(file,MAXPATHLEN+1,"%s/%s",log,entry->name);
- slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 );
+ if((rc = slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )) != 0){
+ LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
+ file, errno, slapd_system_strerror(errno));
+ }
}
PR_CloseDir( dir );
}
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index 0aab53d..f515b8e 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -360,7 +360,7 @@ _conf_setciphers(char *ciphers)
if(t)
ciphers = t;
}
- if (unsuplist && unsuplist) {
+ if (unsuplist && *unsuplist) {
char *strsup = charray2str(suplist, ",");
char *strunsup = charray2str(unsuplist, ",");
slapd_SSL_warn("Security Initialization: FIPS mode is enabled - only the following "
@@ -614,9 +614,18 @@ slapd_nss_init(int init_ssl, int config_available)
certdb_file_name = slapi_ch_smprintf("%s/cert8.db", certdir);
keydb_file_name = slapi_ch_smprintf("%s/key3.db", certdir);
secmoddb_file_name = slapi_ch_smprintf("%s/secmod.db", certdir);
- chmod(certdb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- chmod(keydb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ if(chmod(certdb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ certdb_file_name, errno, slapd_system_strerror(errno));
+ }
+ if(chmod(keydb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ keydb_file_name, errno, slapd_system_strerror(errno));
+ }
+ if(chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ secmoddb_file_name, errno, slapd_system_strerror(errno));
+ }
}
/****** end of NSS Initialization ******/
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c b/ldap/servers/slapd/tools/ldclt/ldclt.c
index ecad6b5..0dbc8a4 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.c
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.c
@@ -1509,7 +1509,7 @@ basicInit (void)
/*
* Parse the deference attribute value
*/
- mctx.attRefDef= (char *)malloc(strlen(mctx.attrpl+i+1) + 1);
+ mctx.attRefDef= (char *)malloc(strlen(mctx.attrpl + i) + 2);
if (mctx.attRefDef== NULL) {
printf ("Error: unable to allocate memory for attRefDef\n");
return (-1);
@@ -1537,7 +1537,7 @@ basicInit (void)
/*
* Parse the attribute value
*/
- mctx.attrplFile = (char *)malloc(strlen(mctx.attrpl+i+1) + 1);
+ mctx.attrplFile = (char *)malloc(strlen(mctx.attrpl+i) + 2);
if (mctx.attrplFile == NULL) {
printf ("Error: unable to allocate memory for attreplfile\n");
return (-1);
diff --git a/ldap/servers/slapd/tools/rsearch/sdattable.c b/ldap/servers/slapd/tools/rsearch/sdattable.c
index df1c152..c0274d0 100644
--- a/ldap/servers/slapd/tools/rsearch/sdattable.c
+++ b/ldap/servers/slapd/tools/rsearch/sdattable.c
@@ -183,7 +183,7 @@ int sdt_save(SDatTable *sdt, const char *filename)
PR_Write(fd, sdt->dns[i], strlen(sdt->dns[i]));
PR_Write(fd, "\n", 1);
}
- if (sdt->dns[i]) {
+ if (sdt->uids[i]) {
PR_Write(fd, "uid: ", 5);
PR_Write(fd, sdt->uids[i], strlen(sdt->uids[i]));
PR_Write(fd, "\n", 1);
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
index 3c715ec..653914b 100644
--- a/ldap/servers/slapd/util.c
+++ b/ldap/servers/slapd/util.c
@@ -723,7 +723,7 @@ normalize_mods2bvals(const LDAPMod **mods)
num_values++;
}
} else {
- for (x = 0; mods[w]->mod_values[x] != NULL &&
+ for (x = 0; mods[w]->mod_values != NULL &&
mods[w]->mod_values[x] != NULL; x++)
{
num_values++;
10 years, 10 months
ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5_protocol_util.c | 2
ldap/servers/slapd/agtmmap.c | 69 ++++++++---------
ldap/servers/slapd/back-ldbm/dblayer.c | 7 +
ldap/servers/slapd/daemon.c | 29 ++++---
ldap/servers/slapd/log.c | 18 ++++
ldap/servers/slapd/main.c | 5 -
ldap/servers/slapd/ssl.c | 17 +++-
ldap/servers/slapd/tools/ldclt/ldclt.c | 4
ldap/servers/slapd/tools/rsearch/sdattable.c | 2
ldap/servers/slapd/util.c | 2
10 files changed, 98 insertions(+), 57 deletions(-)
New commits:
commit 2b5aecb77784a9cf68fe29204f15bd4b61159d6d
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Jun 3 17:17:24 2013 -0400
Coverity Fixes (part 1)
11648 - string length miscalulation (ldclt.c)
11655 - unchecked return value (agtmmap.c)
11656 - unchecked return value (dblayer.c)
11657 - unchecked return value (daemon.c)
11658 - unchecked return value (daemon.c)
11660 - unchecked return value (log.c)
11661 - unchecked return value (main.c)
11662 - unchecked return value (ssl.c)
11668 - Same on both sides (repl5_protocol_util.c)
11669 - Same on both sides (ssl.c)
11670 - Same on both sides (util.c)
11673 - Copy-and-paste error (tools/rsearch/sdattable.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: Noriko(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c
index 56f8532..82af970 100644
--- a/ldap/servers/plugins/replication/repl5_protocol_util.c
+++ b/ldap/servers/plugins/replication/repl5_protocol_util.c
@@ -603,7 +603,7 @@ release_replica(Private_Repl_Protocol *prp)
struct berval *data = NULL;
/* Check the message id's match */
- if (sent_message_id != sent_message_id)
+ if (sent_message_id != ret_message_id)
{
int operation, error;
conn_get_error(prp->conn, &operation, &error);
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index d82da5f..f18138a 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -187,46 +187,49 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
if ( fd < 0 )
{
- err = errno;
+ err = errno;
#if (0)
- fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
+ fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- rc = err;
- goto bail;
- }
+ rc = err;
+ goto bail;
+ }
- fstat (fd, &fileinfo);
-
- sz = sizeof (struct agt_stats_t);
-
- if (fileinfo.st_size < sz)
- {
- /* Without this we will get segv when we try to read/write later */
- buf = calloc (1, sz);
- (void)write (fd, buf, sz);
- free (buf);
- }
-
- fp = mmap (NULL, sz, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
-
- if (fp == (caddr_t) -1)
- {
- err = errno;
- close (fd);
+ if(fstat (fd, &fileinfo) != 0){
+ rc = errno;
+ goto bail;
+ }
+
+ sz = sizeof (struct agt_stats_t);
+
+ if (fileinfo.st_size < sz)
+ {
+ /* Without this we will get segv when we try to read/write later */
+ buf = calloc (1, sz);
+ (void)write (fd, buf, sz);
+ free (buf);
+ }
+
+ fp = mmap (NULL, sz, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
+
+ if (fp == (caddr_t) -1)
+ {
+ err = errno;
+ close (fd);
#if (0)
- fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
+ fprintf (stderr, "returning errno =%d from %s(line: %d)\n", err, __FILE__, __LINE__);
#endif
- rc = err;
- goto bail;
- }
+ rc = err;
+ goto bail;
+ }
- mmap_tbl [1].maptype = AGT_MAP_RDWR;
- mmap_tbl [1].fd = fd;
- mmap_tbl [1].fp = fp;
- *hdl = 1;
+ mmap_tbl [1].maptype = AGT_MAP_RDWR;
+ mmap_tbl [1].fd = fd;
+ mmap_tbl [1].fp = fp;
+ *hdl = 1;
- rc = 0;
- break;
+ rc = 0;
+ break;
} /* end switch */
#else
/* _WIN32 */
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 2b0699c..607f802 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4699,7 +4699,12 @@ static int checkpoint_threadmain(void *param)
"%s.old", *listp);
checkpoint_debug_message(debug_checkpointing,
"Renaming %s -> %s\n",*listp, new_filename, 0);
- rename(*listp, new_filename);
+ if(rename(*listp, new_filename) != 0){
+ LDAPDebug(LDAP_DEBUG_ANY, "checkpoint_threadmain: failed to rename log (%s) to (%s)\n",
+ *listp, new_filename, 0);
+ rval = -1;
+ goto error_return;
+ }
}
}
slapi_ch_free((void**)&list);
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 7791f81..8945c36 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -3391,8 +3391,14 @@ createsignalpipe( void )
}
writesignalpipe = PR_FileDesc2NativeHandle(signalpipe[1]);
readsignalpipe = PR_FileDesc2NativeHandle(signalpipe[0]);
- fcntl(writesignalpipe, F_SETFD, O_NONBLOCK);
- fcntl(readsignalpipe, F_SETFD, O_NONBLOCK);
+ if(fcntl(writesignalpipe, F_SETFD, O_NONBLOCK) == -1){
+ LDAPDebug( LDAP_DEBUG_ANY,"createsignalpipe: failed to set FD for write pipe (%d).\n",
+ errno, 0, 0 );
+ }
+ if(fcntl(readsignalpipe, F_SETFD, O_NONBLOCK) == -1){
+ LDAPDebug( LDAP_DEBUG_ANY,"createsignalpipe: failed to set FD for read pipe (%d).\n",
+ errno, 0, 0);
+ }
#endif
return( 0 );
@@ -3606,7 +3612,7 @@ void configure_ns_socket( int * ns )
{
int enable_nagle = config_get_nagle();
- int on;
+ int on, rc;
#if defined(LINUX)
/* On Linux we use TCP_CORK so we must enable nagle */
@@ -3616,19 +3622,18 @@ void configure_ns_socket( int * ns )
if ( have_send_timeouts ) {
daemon_configure_send_timeout( *ns, config_get_ioblocktimeout() );
}
-
-
+ /* set the nagle */
if ( !enable_nagle ) {
- on = 1;
- setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
+ on = 1;
} else {
- on = 0;
- setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) );
- } /* else (!enable_nagle) */
-
+ on = 0;
+ }
+ /* check for errors */
+ if((rc = setsockopt( *ns, IPPROTO_TCP, TCP_NODELAY, (char * ) &on, sizeof(on) ) != 0)){
+ LDAPDebug( LDAP_DEBUG_ANY,"configure_ns_socket: Failed to configure socket (%d).\n", rc, 0, 0);
+ }
return;
-
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index d1c63bc..f483a57 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -3781,6 +3781,9 @@ log__open_errorlogfile(int logfile_state, int locked)
struct logfileinfo *logp;
char buffer[BUFSIZ];
struct passwd *pw = NULL;
+#ifndef _WIN32
+ int rc = 0;
+#endif
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -3878,7 +3881,20 @@ log__open_errorlogfile(int logfile_state, int locked)
* alternate ns-slapd modes, such as db2bak, tries to log an error
* at startup, it will create the logfile as root!
*/
- slapd_chown_if_not_owner(loginfo.log_error_file, pw->pw_uid, -1);
+ if((rc = slapd_chown_if_not_owner(loginfo.log_error_file, pw->pw_uid, -1)) != 0){
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to chown log file %s: error %d (%s); Exiting...",
+ loginfo.log_error_file, errno, slapd_system_strerror(errno));
+ log__error_emergency(buffer, 1, locked);
+ if (!locked) LOG_ERROR_UNLOCK_WRITE();
+ /* failed to write to the errors log. should not continue. */
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ /*if I have an old log file -- I should log a message
+ ** that I can't open the new file. Let the caller worry
+ ** about logging message.
+ */
+ return LOG_UNABLE_TO_OPENFILE;
+ }
#endif
loginfo.log_error_fdes = fp;
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index e97e5ef..321511d 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -247,7 +247,10 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn, PRBool both)
while( (entry = PR_ReadDir(dir , PR_SKIP_BOTH )) !=NULL )
{
PR_snprintf(file,MAXPATHLEN+1,"%s/%s",log,entry->name);
- slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 );
+ if((rc = slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )) != 0){
+ LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
+ file, errno, slapd_system_strerror(errno));
+ }
}
PR_CloseDir( dir );
}
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index 0aab53d..f515b8e 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -360,7 +360,7 @@ _conf_setciphers(char *ciphers)
if(t)
ciphers = t;
}
- if (unsuplist && unsuplist) {
+ if (unsuplist && *unsuplist) {
char *strsup = charray2str(suplist, ",");
char *strunsup = charray2str(unsuplist, ",");
slapd_SSL_warn("Security Initialization: FIPS mode is enabled - only the following "
@@ -614,9 +614,18 @@ slapd_nss_init(int init_ssl, int config_available)
certdb_file_name = slapi_ch_smprintf("%s/cert8.db", certdir);
keydb_file_name = slapi_ch_smprintf("%s/key3.db", certdir);
secmoddb_file_name = slapi_ch_smprintf("%s/secmod.db", certdir);
- chmod(certdb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- chmod(keydb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ if(chmod(certdb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ certdb_file_name, errno, slapd_system_strerror(errno));
+ }
+ if(chmod(keydb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ keydb_file_name, errno, slapd_system_strerror(errno));
+ }
+ if(chmod(secmoddb_file_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP )){
+ LDAPDebug(LDAP_DEBUG_ANY, "slapd_nss_init: chmod failed for file %s error (%d) %s.\n",
+ secmoddb_file_name, errno, slapd_system_strerror(errno));
+ }
}
/****** end of NSS Initialization ******/
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c b/ldap/servers/slapd/tools/ldclt/ldclt.c
index ecad6b5..0dbc8a4 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.c
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.c
@@ -1509,7 +1509,7 @@ basicInit (void)
/*
* Parse the deference attribute value
*/
- mctx.attRefDef= (char *)malloc(strlen(mctx.attrpl+i+1) + 1);
+ mctx.attRefDef= (char *)malloc(strlen(mctx.attrpl + i) + 2);
if (mctx.attRefDef== NULL) {
printf ("Error: unable to allocate memory for attRefDef\n");
return (-1);
@@ -1537,7 +1537,7 @@ basicInit (void)
/*
* Parse the attribute value
*/
- mctx.attrplFile = (char *)malloc(strlen(mctx.attrpl+i+1) + 1);
+ mctx.attrplFile = (char *)malloc(strlen(mctx.attrpl+i) + 2);
if (mctx.attrplFile == NULL) {
printf ("Error: unable to allocate memory for attreplfile\n");
return (-1);
diff --git a/ldap/servers/slapd/tools/rsearch/sdattable.c b/ldap/servers/slapd/tools/rsearch/sdattable.c
index df1c152..c0274d0 100644
--- a/ldap/servers/slapd/tools/rsearch/sdattable.c
+++ b/ldap/servers/slapd/tools/rsearch/sdattable.c
@@ -183,7 +183,7 @@ int sdt_save(SDatTable *sdt, const char *filename)
PR_Write(fd, sdt->dns[i], strlen(sdt->dns[i]));
PR_Write(fd, "\n", 1);
}
- if (sdt->dns[i]) {
+ if (sdt->uids[i]) {
PR_Write(fd, "uid: ", 5);
PR_Write(fd, sdt->uids[i], strlen(sdt->uids[i]));
PR_Write(fd, "\n", 1);
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
index 3c715ec..653914b 100644
--- a/ldap/servers/slapd/util.c
+++ b/ldap/servers/slapd/util.c
@@ -723,7 +723,7 @@ normalize_mods2bvals(const LDAPMod **mods)
num_values++;
}
} else {
- for (x = 0; mods[w]->mod_values[x] != NULL &&
+ for (x = 0; mods[w]->mod_values != NULL &&
mods[w]->mod_values[x] != NULL; x++)
{
num_values++;
10 years, 10 months
ldap/servers
by Mark Reynolds
ldap/servers/slapd/back-ldbm/back-ldbm.h | 1
ldap/servers/slapd/back-ldbm/idl.c | 24 +++++++++++++----------
ldap/servers/slapd/back-ldbm/ldbm_config.c | 30 ++++++++++++++++++++++++++++-
ldap/servers/slapd/back-ldbm/ldbm_config.h | 1
4 files changed, 45 insertions(+), 11 deletions(-)
New commits:
commit a5d3571aadde4d84d426c2c16ac9aa2b189c9bbb
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri May 31 15:43:32 2013 -0400
Ticket 47372 - make old-idl tunable
Bug Description: With the change from ticket 47326 old-idl is working, but tests
showed that performance heavily depends on the size of the idlists.
So idl_maxids should be made configurable.
Fix Description: Added a new config ldbm config setting, "nsslapd-old-idl-maxids".
If this is not set, which is the default value, then we calulate it
the old way, otherwise the config setting is used.
https://fedorahosted.org/389/ticket/47372
Reviewed by: ?
diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h
index e565360..b0f87e1 100644
--- a/ldap/servers/slapd/back-ldbm/back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h
@@ -653,6 +653,7 @@ struct ldbminfo {
int li_rangelookthroughlimit;
int li_reslimit_rangelookthrough_handle;
int li_idl_update;
+ int li_old_idl_maxids;
};
/* li_flags could store these bits defined in ../slapi-plugin.h
diff --git a/ldap/servers/slapd/back-ldbm/idl.c b/ldap/servers/slapd/back-ldbm/idl.c
index 65fca7c..0a11d88 100644
--- a/ldap/servers/slapd/back-ldbm/idl.c
+++ b/ldap/servers/slapd/back-ldbm/idl.c
@@ -89,17 +89,21 @@ size_t idl_old_get_allidslimit(struct attrinfo *a)
static void idl_init_maxids(struct ldbminfo *li,idl_private *priv)
{
- const size_t blksize = dblayer_get_optimal_block_size(li);
+ const size_t blksize = dblayer_get_optimal_block_size(li);
- if (0 == li->li_allidsthreshold) {
- li->li_allidsthreshold = DEFAULT_ALLIDSTHRESHOLD;
- }
- priv->idl_maxids = (blksize / sizeof(ID)) - 2;
- priv->idl_maxindirect = (li->li_allidsthreshold / priv->idl_maxids) + 1;
- priv->idl_allidslimit = (priv->idl_maxids * priv->idl_maxindirect);
- LDAPDebug (LDAP_DEBUG_ARGS,
- "idl_init_private: blksize %lu, maxids %i, maxindirect %i\n",
- (unsigned long)blksize, priv->idl_maxids, priv->idl_maxindirect);
+ if (0 == li->li_allidsthreshold) {
+ li->li_allidsthreshold = DEFAULT_ALLIDSTHRESHOLD;
+ }
+ if(li->li_old_idl_maxids){
+ priv->idl_maxids = li->li_old_idl_maxids;
+ } else {
+ priv->idl_maxids = (blksize / sizeof(ID)) - 2;
+ }
+ priv->idl_maxindirect = (li->li_allidsthreshold / priv->idl_maxids) + 1;
+ priv->idl_allidslimit = (priv->idl_maxids * priv->idl_maxindirect);
+ LDAPDebug (LDAP_DEBUG_ARGS,
+ "idl_init_private: blksize %lu, maxids %i, maxindirect %i\n",
+ (unsigned long)blksize, priv->idl_maxids, priv->idl_maxindirect);
}
/* routine to initialize the private data used by the IDL code per-attribute */
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index 08fc536..056c14c 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -165,7 +165,7 @@ static int ldbm_config_lookthroughlimit_set(void *arg, void *value, char *errorb
return retval;
}
-static void *ldbm_config_pagedlookthroughlimit_get(void *arg)
+static void *ldbm_config_pagedlookthroughlimit_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
@@ -718,6 +718,33 @@ static int ldbm_config_db_idl_divisor_set(void *arg, void *value, char *errorbuf
return retval;
}
+static void *ldbm_config_db_old_idl_maxids_get(void *arg)
+{
+ struct ldbminfo *li = (struct ldbminfo *) arg;
+
+ return (void *) ((uintptr_t)li->li_old_idl_maxids);
+}
+
+static int ldbm_config_db_old_idl_maxids_set(void *arg, void *value, char *errorbuf, int phase, int apply)
+{
+ struct ldbminfo *li = (struct ldbminfo *) arg;
+ int retval = LDAP_SUCCESS;
+ int val = (int) ((uintptr_t)value);
+
+ if (apply) {
+ if(val >= 0){
+ li->li_old_idl_maxids = val;
+ } else {
+ PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Error: Invalid value for %s (%d). Value must be equal or greater than zero.",
+ CONFIG_DB_OLD_IDL_MAXIDS, val);
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
+ }
+
+ return retval;
+}
+
static void *ldbm_config_db_logfile_size_get(void *arg)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
@@ -1352,6 +1379,7 @@ static config_info ldbm_config[] = {
{CONFIG_DB_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_page_size_get, &ldbm_config_db_page_size_set, 0},
{CONFIG_DB_INDEX_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_index_page_size_get, &ldbm_config_db_index_page_size_set, 0},
{CONFIG_DB_IDL_DIVISOR, CONFIG_TYPE_INT, "0", &ldbm_config_db_idl_divisor_get, &ldbm_config_db_idl_divisor_set, 0},
+ {CONFIG_DB_OLD_IDL_MAXIDS, CONFIG_TYPE_INT, "0", &ldbm_config_db_old_idl_maxids_get, &ldbm_config_db_old_idl_maxids_set, 0},
{CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0},
{CONFIG_DB_TRICKLE_PERCENTAGE, CONFIG_TYPE_INT, "5", &ldbm_config_db_trickle_percentage_get, &ldbm_config_db_trickle_percentage_set, 0},
{CONFIG_DB_SPIN_COUNT, CONFIG_TYPE_INT, "0", &ldbm_config_db_spin_count_get, &ldbm_config_db_spin_count_set, 0},
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h
index 17883cb..456d27d 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.h
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h
@@ -123,6 +123,7 @@ struct config_info {
But 8K is still a good page size for id2entry. So we now allow different
page sizes for the primary and secondary indices. */
#define CONFIG_DB_IDL_DIVISOR "nsslapd-db-idl-divisor"
+#define CONFIG_DB_OLD_IDL_MAXIDS "nsslapd-db-old-idl-maxids"
#define CONFIG_DB_LOGFILE_SIZE "nsslapd-db-logfile-size"
#define CONFIG_DB_TRICKLE_PERCENTAGE "nsslapd-db-trickle-percentage"
#define CONFIG_DB_SPIN_COUNT "nsslapd-db-spin-count"
10 years, 10 months