ldap/servers
by Mark Reynolds
ldap/servers/slapd/connection.c | 131 ++++++++++++++++++++--------------------
1 file changed, 66 insertions(+), 65 deletions(-)
New commits:
commit 202c9831194558a7439da815f6627993ce1a17db
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 7 11:41:38 2013 -0400
Ticket 47383 - connections attribute in cn=snmp,cn=monitor is counted twice
Bug Description: In disconnect_server_nomutex() we increment, instead of decrement
the connection counter.
Fix Description: Decrement the counter. Also did some code cleanup.
https://fedorahosted.org/389/ticket/47383
Reviewed by: Richm(Thanks!)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 359dabe..687bf42 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -2891,77 +2891,78 @@ void
disconnect_server_nomutex( Connection *conn, PRUint64 opconnid, int opid, PRErrorCode reason, PRInt32 error )
{
if ( ( conn->c_sd != SLAPD_INVALID_SOCKET &&
- conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) ) {
-
- /*
- * PR_Close must be called before anything else is done because
- * of NSPR problem on NT which requires that the socket on which
- * I/O timed out is closed before any other I/O operation is
- * attempted by the thread.
- * WARNING : As of today the current code does not fulfill the
- * requirements above.
- */
-
- /* Mark that the socket should be closed on this connection.
- * We don't want to actually close the socket here, because
- * the listener thread could be PR_Polling over it right now.
- * The last thread to stop using the connection will do the closing.
- */
- conn->c_flags |= CONN_FLAG_CLOSING;
- g_decrement_current_conn_count();
+ conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) )
+ {
+ /*
+ * PR_Close must be called before anything else is done because
+ * of NSPR problem on NT which requires that the socket on which
+ * I/O timed out is closed before any other I/O operation is
+ * attempted by the thread.
+ * WARNING : As of today the current code does not fulfill the
+ * requirements above.
+ */
- /*
- * Print the error captured above.
- */
- if (error && (EPIPE != error) ) {
- slapi_log_access( LDAP_DEBUG_STATS,
- "conn=%" NSPRIu64 " op=%d fd=%d closed error %d (%s) - %s\n",
- conn->c_connid, opid, conn->c_sd, error,
- slapd_system_strerror(error),
- slapd_pr_strerror(reason));
- } else {
- slapi_log_access( LDAP_DEBUG_STATS,
- "conn=%" NSPRIu64 " op=%d fd=%d closed - %s\n",
- conn->c_connid, opid, conn->c_sd,
- slapd_pr_strerror(reason));
- }
+ /* Mark that the socket should be closed on this connection.
+ * We don't want to actually close the socket here, because
+ * the listener thread could be PR_Polling over it right now.
+ * The last thread to stop using the connection will do the closing.
+ */
+ conn->c_flags |= CONN_FLAG_CLOSING;
+ g_decrement_current_conn_count();
- if (! config_check_referral_mode()) {
- slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsConnections);
- }
+ /*
+ * Print the error captured above.
+ */
+ if (error && (EPIPE != error) ) {
+ slapi_log_access( LDAP_DEBUG_STATS,
+ "conn=%" NSPRIu64 " op=%d fd=%d closed error %d (%s) - %s\n",
+ conn->c_connid, opid, conn->c_sd, error,
+ slapd_system_strerror(error),
+ slapd_pr_strerror(reason));
+ } else {
+ slapi_log_access( LDAP_DEBUG_STATS,
+ "conn=%" NSPRIu64 " op=%d fd=%d closed - %s\n",
+ conn->c_connid, opid, conn->c_sd,
+ slapd_pr_strerror(reason));
+ }
- conn->c_gettingber = 0;
- connection_abandon_operations( conn );
- /* needed here to ensure simple paged results timeout properly and
- * don't impact subsequent ops */
- pagedresults_reset_timedout_nolock(conn);
+ if (! config_check_referral_mode()) {
+ slapi_counter_decrement(g_get_global_snmp_vars()->ops_tbl.dsConnections);
+ }
- if (! config_check_referral_mode()) {
- /*
- * If any of the outstanding operations on this
- * connection were persistent searches, then
- * ding all the persistent searches to get them
- * to notice that their operations have been abandoned.
- */
- int found_ps = 0;
- Operation *o;
+ conn->c_gettingber = 0;
+ connection_abandon_operations( conn );
+ /* needed here to ensure simple paged results timeout properly and
+ * don't impact subsequent ops */
+ pagedresults_reset_timedout_nolock(conn);
- for ( o = conn->c_ops; !found_ps && o != NULL; o = o->o_next ) {
- if ( o->o_flags & OP_FLAG_PS ) {
- found_ps = 1;
- }
- }
- if ( found_ps ) {
- if ( NULL == ps_wakeup_all_fn ) {
- if ( get_entry_point( ENTRY_POINT_PS_WAKEUP_ALL,
- (caddr_t *)(&ps_wakeup_all_fn )) == 0 ) {
- (ps_wakeup_all_fn)();
- }
- } else {
- (ps_wakeup_all_fn)();
+ if (! config_check_referral_mode()) {
+ /*
+ * If any of the outstanding operations on this
+ * connection were persistent searches, then
+ * ding all the persistent searches to get them
+ * to notice that their operations have been abandoned.
+ */
+ int found_ps = 0;
+ Operation *o;
+
+ for ( o = conn->c_ops; !found_ps && o != NULL; o = o->o_next ) {
+ if ( o->o_flags & OP_FLAG_PS ) {
+ found_ps = 1;
+ }
+ }
+ if ( found_ps ) {
+ if ( NULL == ps_wakeup_all_fn ) {
+ if ( get_entry_point( ENTRY_POINT_PS_WAKEUP_ALL,
+ (caddr_t *)(&ps_wakeup_all_fn )) == 0 )
+ {
+ (ps_wakeup_all_fn)();
+ }
+ } else {
+ (ps_wakeup_all_fn)();
+ }
+ }
}
- }
- }
}
}
10 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/chainingdb/cb_instance.c | 2 -
ldap/servers/plugins/replication/cl5_clcache.c | 4 ---
ldap/servers/plugins/replication/repl5_replica_config.c | 3 +-
ldap/servers/slapd/back-ldbm/dblayer.c | 10 ++++-----
ldap/servers/slapd/main.c | 7 ++++--
ldap/servers/slapd/tools/ldclt/data.c | 17 +++++++++-------
ldap/servers/slapd/tools/mmldif.c | 2 -
7 files changed, 25 insertions(+), 20 deletions(-)
New commits:
commit 8212d48b57adf223c7022dba4fbdb70e7aa2080e
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 7 11:15:27 2013 -0400
Fri Jun 7 10:41:00 2013 -0400
Coverity Fixes (Part 6)
11611 - Unchecked value (main.c)
11671 - Copy-paste error (cb_instance.c)
11704 - Dereference after null check (repl5_replica_config.c)
11766 - Resource leak (dblayer.c)
11873 - Argument can not be negative (ldclt/data.c)
Jenkins error: mmldif.c
11876 - Deference before null check (cl5_clcache.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: Rich(Thanks!)
(cherry picked from commit 4a0199b3c3a73b094a7bff64404a632c3bfe7072)
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index 8fb694a..95781b5 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -1437,7 +1437,7 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int
charray_add(&inst->pool->waste_basket,inst->pool->mech);
}
if (inst->bind_pool->mech) {
- charray_add(&inst->pool->waste_basket,inst->bind_pool->mech);
+ charray_add(&inst->bind_pool->waste_basket,inst->bind_pool->mech);
}
rc=CB_REOPEN_CONN;
}
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 738e4cb..1c20b92 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -734,9 +734,7 @@ clcache_skip_change ( CLC_Buffer *buf )
(csn_get_seqnum(buf->buf_current_csn) ==
csn_get_seqnum(cscb->local_maxcsn) + 1) )
{
- if(cscb->local_maxcsn){
- csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
- }
+ csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
if(cscb->consumer_maxcsn){
csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index fbaa35a..1eb3d96 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -2350,7 +2350,7 @@ delete_aborted_rid(Replica *r, ReplicaId rid, char *repl_root, int skip){
static void
delete_cleaned_rid_config(cleanruv_data *clean_data)
{
- Slapi_PBlock *pb = slapi_pblock_new();
+ Slapi_PBlock *pb;
Slapi_Entry **entries = NULL;
LDAPMod *mods[2];
LDAPMod mod;
@@ -2379,6 +2379,7 @@ delete_cleaned_rid_config(cleanruv_data *clean_data)
/*
* Search the config for the exact attribute value to delete
*/
+ pb = slapi_pblock_new();
dn = replica_get_dn(clean_data->replica);
slapi_search_internal_set_pb(pb, dn, LDAP_SCOPE_SUBTREE, "nsds5ReplicaCleanRUV=*", NULL, 0, NULL, NULL,
(void *)plugin_get_default_component_id(), 0);
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index bd28d17..e90022f 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -2996,6 +2996,8 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
int return_value = 0;
DB *dbp = NULL;
char *subname = NULL;
+ char inst_dir[MAXPATHLEN];
+ char *inst_dirp = NULL;
PR_ASSERT(NULL != li);
priv = (dblayer_private*)li->li_dblayer_private;
@@ -3059,8 +3061,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
inst->inst_parent_dir_name) > 0) &&
!dblayer_inst_exists(inst, file_name))
{
- char inst_dir[MAXPATHLEN];
- char *inst_dirp = NULL;
char *abs_file_name = NULL;
/* create a file with abs path, then try again */
@@ -3072,9 +3072,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
}
abs_file_name = slapi_ch_smprintf("%s%c%s",
inst_dirp, get_sep(inst_dirp), file_name);
- if (inst_dirp != inst_dir){
- slapi_ch_free_string(&inst_dirp);
- }
DB_OPEN(pENV->dblayer_openflags,
dbp, NULL/* txnid */, abs_file_name, subname, DB_BTREE,
open_flags, priv->dblayer_file_mode, return_value);
@@ -3107,6 +3104,9 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
out:
slapi_ch_free((void**)&file_name);
slapi_ch_free((void**)&rel_path);
+ if (inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
/* close the database handle to avoid handle leak */
if (dbp && (return_value != 0)) {
dblayer_close_file(dbp);
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 9938c01..53cb5c8 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -232,7 +232,10 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn, PRBool both)
if((ptr=strrchr(log,'/'))==NULL)
{
LDAPDebug(LDAP_DEBUG_ANY, "Caution changing ownership of ./%s \n",name,0,0);
- slapd_chown_if_not_owner(log, pw->pw_uid, -1 );
+ if(slapd_chown_if_not_owner(log, pw->pw_uid, -1 )){
+ LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
+ log, errno, slapd_system_strerror(errno));
+ }
rc=1;
} else if(log==ptr) {
LDAPDebug(LDAP_DEBUG_ANY, "Caution changing ownership of / directory and its contents to %s\n",pw->pw_name,0,0);
@@ -247,7 +250,7 @@ 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);
- if((rc = slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )) != 0){
+ if(slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )){
LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
file, errno, slapd_system_strerror(errno));
}
diff --git a/ldap/servers/slapd/tools/ldclt/data.c b/ldap/servers/slapd/tools/ldclt/data.c
index f6dd4ef..45016d8 100644
--- a/ldap/servers/slapd/tools/ldclt/data.c
+++ b/ldap/servers/slapd/tools/ldclt/data.c
@@ -143,7 +143,7 @@ int loadImages (
char *fileName; /* As read from the system */
char name [1024]; /* To build the full path */
struct stat stat_buf; /* To read the image size */
- int fd; /* To open the image */
+ int fd = -1; /* To open the image */
int ret; /* Return value */
int rc = 0;
@@ -303,11 +303,13 @@ int loadImages (
*/
if (close (fd) < 0)
{
- perror (name);
- fprintf (stderr, "Cannot close(%s)\n", name);
- fflush (stderr);
- rc = -1;
- goto exit;
+ perror (name);
+ fprintf (stderr, "Cannot close(%s)\n", name);
+ fflush (stderr);
+ rc = -1;
+ goto exit;
+ } else {
+ fd = -1;
}
}
#ifdef _WIN32
@@ -335,7 +337,8 @@ exit:
#ifdef _WIN32
if (findPath) free (findPath);
#endif
- close(fd);
+ if(fd != -1)
+ close(fd);
return rc;
}
diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c
index fb97129..1f01976 100644
--- a/ldap/servers/slapd/tools/mmldif.c
+++ b/ldap/servers/slapd/tools/mmldif.c
@@ -729,7 +729,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
int toolong = FALSE;
int rc;
int cmp;
- attrib1_t * att;
+ attrib1_t * att = NULL;
attrib1_t ** prev;
attrib1_t * freelist = *attrib;
attrib1_t * newlist = NULL;
10 years, 10 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/chainingdb/cb_instance.c | 2 -
ldap/servers/plugins/replication/cl5_clcache.c | 4 ---
ldap/servers/plugins/replication/repl5_replica_config.c | 3 +-
ldap/servers/slapd/back-ldbm/dblayer.c | 10 ++++-----
ldap/servers/slapd/main.c | 7 ++++--
ldap/servers/slapd/tools/ldclt/data.c | 17 +++++++++-------
ldap/servers/slapd/tools/mmldif.c | 2 -
7 files changed, 25 insertions(+), 20 deletions(-)
New commits:
commit 136761cb6f35cbb839e0262253797b310bca0c7e
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 7 11:15:27 2013 -0400
Fri Jun 7 10:41:00 2013 -0400
Coverity Fixes (Part 6)
11611 - Unchecked value (main.c)
11671 - Copy-paste error (cb_instance.c)
11704 - Dereference after null check (repl5_replica_config.c)
11766 - Resource leak (dblayer.c)
11873 - Argument can not be negative (ldclt/data.c)
Jenkins error: mmldif.c
11876 - Deference before null check (cl5_clcache.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: Rich(Thanks!)
(cherry picked from commit 4a0199b3c3a73b094a7bff64404a632c3bfe7072)
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index 8fb694a..95781b5 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -1437,7 +1437,7 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int
charray_add(&inst->pool->waste_basket,inst->pool->mech);
}
if (inst->bind_pool->mech) {
- charray_add(&inst->pool->waste_basket,inst->bind_pool->mech);
+ charray_add(&inst->bind_pool->waste_basket,inst->bind_pool->mech);
}
rc=CB_REOPEN_CONN;
}
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 738e4cb..1c20b92 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -734,9 +734,7 @@ clcache_skip_change ( CLC_Buffer *buf )
(csn_get_seqnum(buf->buf_current_csn) ==
csn_get_seqnum(cscb->local_maxcsn) + 1) )
{
- if(cscb->local_maxcsn){
- csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
- }
+ csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
if(cscb->consumer_maxcsn){
csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index e7c7420..b0b3ba5 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -2350,7 +2350,7 @@ delete_aborted_rid(Replica *r, ReplicaId rid, char *repl_root, int skip){
static void
delete_cleaned_rid_config(cleanruv_data *clean_data)
{
- Slapi_PBlock *pb = slapi_pblock_new();
+ Slapi_PBlock *pb;
Slapi_Entry **entries = NULL;
LDAPMod *mods[2];
LDAPMod mod;
@@ -2379,6 +2379,7 @@ delete_cleaned_rid_config(cleanruv_data *clean_data)
/*
* Search the config for the exact attribute value to delete
*/
+ pb = slapi_pblock_new();
dn = replica_get_dn(clean_data->replica);
slapi_search_internal_set_pb(pb, dn, LDAP_SCOPE_SUBTREE, "nsds5ReplicaCleanRUV=*", NULL, 0, NULL, NULL,
(void *)plugin_get_default_component_id(), 0);
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 0a4e640..1e67a5d 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -2994,6 +2994,8 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
int return_value = 0;
DB *dbp = NULL;
char *subname = NULL;
+ char inst_dir[MAXPATHLEN];
+ char *inst_dirp = NULL;
PR_ASSERT(NULL != li);
priv = (dblayer_private*)li->li_dblayer_private;
@@ -3057,8 +3059,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
inst->inst_parent_dir_name) > 0) &&
!dblayer_inst_exists(inst, file_name))
{
- char inst_dir[MAXPATHLEN];
- char *inst_dirp = NULL;
char *abs_file_name = NULL;
/* create a file with abs path, then try again */
@@ -3070,9 +3070,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
}
abs_file_name = slapi_ch_smprintf("%s%c%s",
inst_dirp, get_sep(inst_dirp), file_name);
- if (inst_dirp != inst_dir){
- slapi_ch_free_string(&inst_dirp);
- }
DB_OPEN(pENV->dblayer_openflags,
dbp, NULL/* txnid */, abs_file_name, subname, DB_BTREE,
open_flags, priv->dblayer_file_mode, return_value);
@@ -3105,6 +3102,9 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
out:
slapi_ch_free((void**)&file_name);
slapi_ch_free((void**)&rel_path);
+ if (inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
/* close the database handle to avoid handle leak */
if (dbp && (return_value != 0)) {
dblayer_close_file(&dbp);
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index f68a6ab..fdee5d2 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -232,7 +232,10 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn, PRBool both)
if((ptr=strrchr(log,'/'))==NULL)
{
LDAPDebug(LDAP_DEBUG_ANY, "Caution changing ownership of ./%s \n",name,0,0);
- slapd_chown_if_not_owner(log, pw->pw_uid, -1 );
+ if(slapd_chown_if_not_owner(log, pw->pw_uid, -1 )){
+ LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
+ log, errno, slapd_system_strerror(errno));
+ }
rc=1;
} else if(log==ptr) {
LDAPDebug(LDAP_DEBUG_ANY, "Caution changing ownership of / directory and its contents to %s\n",pw->pw_name,0,0);
@@ -247,7 +250,7 @@ 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);
- if((rc = slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )) != 0){
+ if(slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )){
LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
file, errno, slapd_system_strerror(errno));
}
diff --git a/ldap/servers/slapd/tools/ldclt/data.c b/ldap/servers/slapd/tools/ldclt/data.c
index f6dd4ef..45016d8 100644
--- a/ldap/servers/slapd/tools/ldclt/data.c
+++ b/ldap/servers/slapd/tools/ldclt/data.c
@@ -143,7 +143,7 @@ int loadImages (
char *fileName; /* As read from the system */
char name [1024]; /* To build the full path */
struct stat stat_buf; /* To read the image size */
- int fd; /* To open the image */
+ int fd = -1; /* To open the image */
int ret; /* Return value */
int rc = 0;
@@ -303,11 +303,13 @@ int loadImages (
*/
if (close (fd) < 0)
{
- perror (name);
- fprintf (stderr, "Cannot close(%s)\n", name);
- fflush (stderr);
- rc = -1;
- goto exit;
+ perror (name);
+ fprintf (stderr, "Cannot close(%s)\n", name);
+ fflush (stderr);
+ rc = -1;
+ goto exit;
+ } else {
+ fd = -1;
}
}
#ifdef _WIN32
@@ -335,7 +337,8 @@ exit:
#ifdef _WIN32
if (findPath) free (findPath);
#endif
- close(fd);
+ if(fd != -1)
+ close(fd);
return rc;
}
diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c
index fb97129..1f01976 100644
--- a/ldap/servers/slapd/tools/mmldif.c
+++ b/ldap/servers/slapd/tools/mmldif.c
@@ -729,7 +729,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
int toolong = FALSE;
int rc;
int cmp;
- attrib1_t * att;
+ attrib1_t * att = NULL;
attrib1_t ** prev;
attrib1_t * freelist = *attrib;
attrib1_t * newlist = NULL;
10 years, 10 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/chainingdb/cb_instance.c | 2 -
ldap/servers/plugins/replication/cl5_clcache.c | 4 ---
ldap/servers/plugins/replication/repl5_replica_config.c | 3 +-
ldap/servers/slapd/back-ldbm/dblayer.c | 10 ++++-----
ldap/servers/slapd/main.c | 7 ++++--
ldap/servers/slapd/tools/ldclt/data.c | 17 +++++++++-------
ldap/servers/slapd/tools/mmldif.c | 2 -
7 files changed, 25 insertions(+), 20 deletions(-)
New commits:
commit ae60af1cbcec11ac6fe74b0dc113154bf2b54d34
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 7 11:15:27 2013 -0400
Fri Jun 7 10:41:00 2013 -0400
Coverity Fixes (Part 6)
11611 - Unchecked value (main.c)
11671 - Copy-paste error (cb_instance.c)
11704 - Dereference after null check (repl5_replica_config.c)
11766 - Resource leak (dblayer.c)
11873 - Argument can not be negative (ldclt/data.c)
Jenkins error: mmldif.c
11876 - Deference before null check (cl5_clcache.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: Rich(Thanks!)
(cherry picked from commit 4a0199b3c3a73b094a7bff64404a632c3bfe7072)
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index 8fb694a..95781b5 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -1437,7 +1437,7 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int
charray_add(&inst->pool->waste_basket,inst->pool->mech);
}
if (inst->bind_pool->mech) {
- charray_add(&inst->pool->waste_basket,inst->bind_pool->mech);
+ charray_add(&inst->bind_pool->waste_basket,inst->bind_pool->mech);
}
rc=CB_REOPEN_CONN;
}
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 738e4cb..1c20b92 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -734,9 +734,7 @@ clcache_skip_change ( CLC_Buffer *buf )
(csn_get_seqnum(buf->buf_current_csn) ==
csn_get_seqnum(cscb->local_maxcsn) + 1) )
{
- if(cscb->local_maxcsn){
- csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
- }
+ csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
if(cscb->consumer_maxcsn){
csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index d4ff5c1..c11a47d 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -2379,7 +2379,7 @@ delete_aborted_rid(Replica *r, ReplicaId rid, char *repl_root, int skip){
static void
delete_cleaned_rid_config(cleanruv_data *clean_data)
{
- Slapi_PBlock *pb = slapi_pblock_new();
+ Slapi_PBlock *pb;
Slapi_Entry **entries = NULL;
LDAPMod *mods[2];
LDAPMod mod;
@@ -2408,6 +2408,7 @@ delete_cleaned_rid_config(cleanruv_data *clean_data)
/*
* Search the config for the exact attribute value to delete
*/
+ pb = slapi_pblock_new();
dn = replica_get_dn(clean_data->replica);
slapi_search_internal_set_pb(pb, dn, LDAP_SCOPE_SUBTREE, "nsds5ReplicaCleanRUV=*", NULL, 0, NULL, NULL,
(void *)plugin_get_default_component_id(), 0);
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 302a07e..82454b8 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -3021,6 +3021,8 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
int return_value = 0;
DB *dbp = NULL;
char *subname = NULL;
+ char inst_dir[MAXPATHLEN];
+ char *inst_dirp = NULL;
PR_ASSERT(NULL != li);
priv = (dblayer_private*)li->li_dblayer_private;
@@ -3084,8 +3086,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
inst->inst_parent_dir_name) > 0) &&
!dblayer_inst_exists(inst, file_name))
{
- char inst_dir[MAXPATHLEN];
- char *inst_dirp = NULL;
char *abs_file_name = NULL;
/* create a file with abs path, then try again */
@@ -3097,9 +3097,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
}
abs_file_name = slapi_ch_smprintf("%s%c%s",
inst_dirp, get_sep(inst_dirp), file_name);
- if (inst_dirp != inst_dir){
- slapi_ch_free_string(&inst_dirp);
- }
DB_OPEN(pENV->dblayer_openflags,
dbp, NULL/* txnid */, abs_file_name, subname, DB_BTREE,
open_flags, priv->dblayer_file_mode, return_value);
@@ -3132,6 +3129,9 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
out:
slapi_ch_free((void**)&file_name);
slapi_ch_free((void**)&rel_path);
+ if (inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
/* close the database handle to avoid handle leak */
if (dbp && (return_value != 0)) {
dblayer_close_file(&dbp);
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 321511d..a17a2c5 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -232,7 +232,10 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn, PRBool both)
if((ptr=strrchr(log,'/'))==NULL)
{
LDAPDebug(LDAP_DEBUG_ANY, "Caution changing ownership of ./%s \n",name,0,0);
- slapd_chown_if_not_owner(log, pw->pw_uid, -1 );
+ if(slapd_chown_if_not_owner(log, pw->pw_uid, -1 )){
+ LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
+ log, errno, slapd_system_strerror(errno));
+ }
rc=1;
} else if(log==ptr) {
LDAPDebug(LDAP_DEBUG_ANY, "Caution changing ownership of / directory and its contents to %s\n",pw->pw_name,0,0);
@@ -247,7 +250,7 @@ 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);
- if((rc = slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )) != 0){
+ if(slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )){
LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
file, errno, slapd_system_strerror(errno));
}
diff --git a/ldap/servers/slapd/tools/ldclt/data.c b/ldap/servers/slapd/tools/ldclt/data.c
index f6dd4ef..45016d8 100644
--- a/ldap/servers/slapd/tools/ldclt/data.c
+++ b/ldap/servers/slapd/tools/ldclt/data.c
@@ -143,7 +143,7 @@ int loadImages (
char *fileName; /* As read from the system */
char name [1024]; /* To build the full path */
struct stat stat_buf; /* To read the image size */
- int fd; /* To open the image */
+ int fd = -1; /* To open the image */
int ret; /* Return value */
int rc = 0;
@@ -303,11 +303,13 @@ int loadImages (
*/
if (close (fd) < 0)
{
- perror (name);
- fprintf (stderr, "Cannot close(%s)\n", name);
- fflush (stderr);
- rc = -1;
- goto exit;
+ perror (name);
+ fprintf (stderr, "Cannot close(%s)\n", name);
+ fflush (stderr);
+ rc = -1;
+ goto exit;
+ } else {
+ fd = -1;
}
}
#ifdef _WIN32
@@ -335,7 +337,8 @@ exit:
#ifdef _WIN32
if (findPath) free (findPath);
#endif
- close(fd);
+ if(fd != -1)
+ close(fd);
return rc;
}
diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c
index fb97129..1f01976 100644
--- a/ldap/servers/slapd/tools/mmldif.c
+++ b/ldap/servers/slapd/tools/mmldif.c
@@ -729,7 +729,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
int toolong = FALSE;
int rc;
int cmp;
- attrib1_t * att;
+ attrib1_t * att = NULL;
attrib1_t ** prev;
attrib1_t * freelist = *attrib;
attrib1_t * newlist = NULL;
10 years, 10 months
ldap/servers
by Mark Reynolds
ldap/servers/plugins/chainingdb/cb_instance.c | 2 -
ldap/servers/plugins/replication/cl5_clcache.c | 4 ---
ldap/servers/plugins/replication/repl5_replica_config.c | 3 +-
ldap/servers/slapd/back-ldbm/dblayer.c | 10 ++++-----
ldap/servers/slapd/main.c | 7 ++++--
ldap/servers/slapd/tools/ldclt/data.c | 17 +++++++++-------
ldap/servers/slapd/tools/mmldif.c | 2 -
7 files changed, 25 insertions(+), 20 deletions(-)
New commits:
commit 4a0199b3c3a73b094a7bff64404a632c3bfe7072
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 7 11:15:27 2013 -0400
Fri Jun 7 10:41:00 2013 -0400
Coverity Fixes (Part 6)
11611 - Unchecked value (main.c)
11671 - Copy-paste error (cb_instance.c)
11704 - Dereference after null check (repl5_replica_config.c)
11766 - Resource leak (dblayer.c)
11873 - Argument can not be negative (ldclt/data.c)
Jenkins error: mmldif.c
11876 - Deference before null check (cl5_clcache.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: Rich(Thanks!)
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index 8fb694a..95781b5 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -1437,7 +1437,7 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int
charray_add(&inst->pool->waste_basket,inst->pool->mech);
}
if (inst->bind_pool->mech) {
- charray_add(&inst->pool->waste_basket,inst->bind_pool->mech);
+ charray_add(&inst->bind_pool->waste_basket,inst->bind_pool->mech);
}
rc=CB_REOPEN_CONN;
}
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 738e4cb..1c20b92 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -734,9 +734,7 @@ clcache_skip_change ( CLC_Buffer *buf )
(csn_get_seqnum(buf->buf_current_csn) ==
csn_get_seqnum(cscb->local_maxcsn) + 1) )
{
- if(cscb->local_maxcsn){
- csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
- }
+ csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
if(cscb->consumer_maxcsn){
csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 7d83c99..592faeb 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -2454,7 +2454,7 @@ delete_aborted_rid(Replica *r, ReplicaId rid, char *repl_root, int skip){
static void
delete_cleaned_rid_config(cleanruv_data *clean_data)
{
- Slapi_PBlock *pb = slapi_pblock_new();
+ Slapi_PBlock *pb;
Slapi_Entry **entries = NULL;
LDAPMod *mods[2];
LDAPMod mod;
@@ -2483,6 +2483,7 @@ delete_cleaned_rid_config(cleanruv_data *clean_data)
/*
* Search the config for the exact attribute value to delete
*/
+ pb = slapi_pblock_new();
dn = replica_get_dn(clean_data->replica);
slapi_search_internal_set_pb(pb, dn, LDAP_SCOPE_SUBTREE, "nsds5ReplicaCleanRUV=*", NULL, 0, NULL, NULL,
(void *)plugin_get_default_component_id(), 0);
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index abb64e2..20af828 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -3087,6 +3087,8 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
int return_value = 0;
DB *dbp = NULL;
char *subname = NULL;
+ char inst_dir[MAXPATHLEN];
+ char *inst_dirp = NULL;
PR_ASSERT(NULL != li);
priv = (dblayer_private*)li->li_dblayer_private;
@@ -3150,8 +3152,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
inst->inst_parent_dir_name) > 0) &&
!dblayer_inst_exists(inst, file_name))
{
- char inst_dir[MAXPATHLEN];
- char *inst_dirp = NULL;
char *abs_file_name = NULL;
/* create a file with abs path, then try again */
@@ -3163,9 +3163,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
}
abs_file_name = slapi_ch_smprintf("%s%c%s",
inst_dirp, get_sep(inst_dirp), file_name);
- if (inst_dirp != inst_dir){
- slapi_ch_free_string(&inst_dirp);
- }
DB_OPEN(pENV->dblayer_openflags,
dbp, NULL/* txnid */, abs_file_name, subname, DB_BTREE,
open_flags, priv->dblayer_file_mode, return_value);
@@ -3198,6 +3195,9 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
out:
slapi_ch_free((void**)&file_name);
slapi_ch_free((void**)&rel_path);
+ if (inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
/* close the database handle to avoid handle leak */
if (dbp && (return_value != 0)) {
dblayer_close_file(&dbp);
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 321511d..a17a2c5 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -232,7 +232,10 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn, PRBool both)
if((ptr=strrchr(log,'/'))==NULL)
{
LDAPDebug(LDAP_DEBUG_ANY, "Caution changing ownership of ./%s \n",name,0,0);
- slapd_chown_if_not_owner(log, pw->pw_uid, -1 );
+ if(slapd_chown_if_not_owner(log, pw->pw_uid, -1 )){
+ LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
+ log, errno, slapd_system_strerror(errno));
+ }
rc=1;
} else if(log==ptr) {
LDAPDebug(LDAP_DEBUG_ANY, "Caution changing ownership of / directory and its contents to %s\n",pw->pw_name,0,0);
@@ -247,7 +250,7 @@ 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);
- if((rc = slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )) != 0){
+ if(slapd_chown_if_not_owner( file, pw->pw_uid, both?pw->pw_gid:-1 )){
LDAPDebug(LDAP_DEBUG_ANY, "chown_dir_files: file (%s) chown failed (%d) %s.\n",
file, errno, slapd_system_strerror(errno));
}
diff --git a/ldap/servers/slapd/tools/ldclt/data.c b/ldap/servers/slapd/tools/ldclt/data.c
index f6dd4ef..45016d8 100644
--- a/ldap/servers/slapd/tools/ldclt/data.c
+++ b/ldap/servers/slapd/tools/ldclt/data.c
@@ -143,7 +143,7 @@ int loadImages (
char *fileName; /* As read from the system */
char name [1024]; /* To build the full path */
struct stat stat_buf; /* To read the image size */
- int fd; /* To open the image */
+ int fd = -1; /* To open the image */
int ret; /* Return value */
int rc = 0;
@@ -303,11 +303,13 @@ int loadImages (
*/
if (close (fd) < 0)
{
- perror (name);
- fprintf (stderr, "Cannot close(%s)\n", name);
- fflush (stderr);
- rc = -1;
- goto exit;
+ perror (name);
+ fprintf (stderr, "Cannot close(%s)\n", name);
+ fflush (stderr);
+ rc = -1;
+ goto exit;
+ } else {
+ fd = -1;
}
}
#ifdef _WIN32
@@ -335,7 +337,8 @@ exit:
#ifdef _WIN32
if (findPath) free (findPath);
#endif
- close(fd);
+ if(fd != -1)
+ close(fd);
return rc;
}
diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c
index fb97129..1f01976 100644
--- a/ldap/servers/slapd/tools/mmldif.c
+++ b/ldap/servers/slapd/tools/mmldif.c
@@ -729,7 +729,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
int toolong = FALSE;
int rc;
int cmp;
- attrib1_t * att;
+ attrib1_t * att = NULL;
attrib1_t ** prev;
attrib1_t * freelist = *attrib;
attrib1_t * newlist = NULL;
10 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 31 ++++++++++++++++++++-----------
ldap/servers/slapd/libglobs.c | 28 ----------------------------
ldap/servers/slapd/proto-slap.h | 2 --
ldap/servers/slapd/slap.h | 2 --
4 files changed, 20 insertions(+), 43 deletions(-)
New commits:
commit 70c5bc1a4ff2131fc05bf5e32ba751e6090531ea
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 15:30:41 2013 -0400
Ticket 47385 - DS not shutting down when disk monitoring threshold is reached
Bug Description: If verbose logging is enabled, it fails to correctly
identify that the logging was disabled, and it gets
stuck in an endless loop - never shutting the server down.
Also, whe the server does shutdown due to a disk full, the
pid file is not removed.
Fix Description: Check for the two possible error log levels that indicate
verbose logging is disabled. There were also logic errors
when determining if it was ok to disable access/audit logging,
and if to delete rotated logs.
Also removed the "nsslapd-disk-monitoring-preserve-logging"
setting, as it really didn't served a purpose because it was
basically the same as "nsslapd-disk-monitoring-logging-critical".
Lastly, if the server is being shutdown from a "disk full"
condition, then we need to manually remove the pidfile.
https://fedorahosted.org/389/ticket/47385
Reviewed by: Noriko(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 9293557..5bc5fc0 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -720,7 +720,6 @@ disk_monitoring_thread(void *nothing)
time_t now = 0;
int deleted_rotated_logs = 0;
int logging_critical = 0;
- int preserve_logging = 0;
int passed_threshold = 0;
int verbose_logging = 0;
int using_accesslog = 0;
@@ -750,7 +749,6 @@ disk_monitoring_thread(void *nothing)
* Get the config settings, as they could have changed
*/
logging_critical = config_get_disk_logging_critical();
- preserve_logging = config_get_disk_preserve_logging();
grace_period = 60 * config_get_disk_grace_period(); /* convert it to seconds */
verbose_logging = config_get_errorlog_level();
threshold = config_get_disk_threshold();
@@ -807,18 +805,21 @@ disk_monitoring_thread(void *nothing)
}
/*
* If we are low, see if we are using verbose error logging, and turn it off
+ * if logging is not critical
*/
- if(verbose_logging){
+ if(verbose_logging != 0 && verbose_logging != LDAP_DEBUG_ANY){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is low on disk (%s), remaining space: %d Kb, "
- "setting error loglevel to zero.\n", dirstr, (disk_space / 1024), 0);
- config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, 0, errorbuf, CONFIG_APPLY);
+ "temporarily setting error loglevel to zero.\n", dirstr,
+ (disk_space / 1024), 0);
+ /* Setting the log level back to zero, actually sets the value to LDAP_DEBUG_ANY */
+ config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, "0", errorbuf, CONFIG_APPLY);
continue;
}
/*
* If we are low, there's no verbose logging, logs are not critical, then disable the
* access/audit logs, log another error, and continue.
*/
- if(!logs_disabled && (!preserve_logging || !logging_critical)){
+ if(!logs_disabled && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
"disabling access and audit logging.\n", dirstr, (disk_space / 1024), 0);
@@ -832,7 +833,7 @@ disk_monitoring_thread(void *nothing)
* If we are low, we turned off verbose logging, logs are not critical, and we disabled
* access/audit logging, then delete the rotated logs, log another error, and continue.
*/
- if(!deleted_rotated_logs && (!preserve_logging || !logging_critical)){
+ if(!deleted_rotated_logs && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
"deleting rotated logs.\n", dirstr, (disk_space / 1024), 0);
@@ -881,10 +882,10 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Available disk space is now acceptable (%d bytes). Aborting"
" shutdown, and restoring the log settings.\n",disk_space,0,0);
- if(!preserve_logging && using_accesslog){
+ if(logs_disabled && using_accesslog){
config_set_accesslog_enabled(LOGGING_ON);
}
- if(!preserve_logging && using_auditlog){
+ if(logs_disabled && using_auditlog){
config_set_auditlog_enabled(LOGGING_ON);
}
deleted_rotated_logs = 0;
@@ -901,7 +902,7 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is critically low on disk (%s), remaining space: %d Kb."
" Signaling slapd for shutdown...\n", dirstr, (disk_space / 1024), 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
return;
}
time(&now);
@@ -918,7 +919,8 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is still too low (%d Kb). Signaling slapd for shutdown...\n",
(disk_space / 1024), 0, 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
+
return;
}
}
@@ -1376,6 +1378,13 @@ void slapd_daemon( daemon_ports_t *ports )
#ifdef _WIN32
WSACleanup();
+#else
+ if ( g_get_shutdown() == SLAPI_SHUTDOWN_DISKFULL ){
+ /* This is a server-induced shutdown, we need to manually remove the pid file */
+ if( unlink(get_pid_file()) ){
+ LDAPDebug( LDAP_DEBUG_ANY, "Failed to remove pid file %s\n", get_pid_file(), 0, 0 );
+ }
+ }
#endif
}
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 2e141c7..c8e16fb 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -689,10 +689,6 @@ static struct config_get_and_set {
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_logging_critical,
CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_logging_critical},
- {CONFIG_DISK_PRESERVE_LOGGING, config_set_disk_preserve_logging,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.disk_preserve_logging,
- CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_preserve_logging},
{CONFIG_SASL_MAXBUFSIZE, config_set_sasl_maxbufsize,
NULL, 0,
(void**)&global_slapdFrontendConfig.sasl_max_bufsize,
@@ -1096,7 +1092,6 @@ FrontendConfig_init () {
cfg->disk_monitoring = LDAP_OFF;
cfg->disk_threshold = 2097152; /* 2 mb */
cfg->disk_grace_period = 60; /* 1 hour */
- cfg->disk_preserve_logging = LDAP_OFF;
cfg->disk_logging_critical = LDAP_OFF;
cfg->sasl_max_bufsize = SLAPD_DEFAULT_SASL_MAXBUFSIZE;
@@ -1266,17 +1261,6 @@ config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, in
}
int
-config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply )
-{
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal = LDAP_SUCCESS;
-
- retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_preserve_logging),
- errorbuf, apply);
- return retVal;
-}
-
-int
config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply )
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -3785,18 +3769,6 @@ config_get_disk_monitoring(){
}
int
-config_get_disk_preserve_logging(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->disk_preserve_logging;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
-}
-
-int
config_get_disk_logging_critical(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
int retVal;
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 63d3e55..6a9dd3b 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -389,7 +389,6 @@ int config_set_default_naming_context( const char *attrname, char *value, char *
int config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply );
-int config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, int apply );
@@ -546,7 +545,6 @@ int config_get_accesslog_logging_enabled();
int config_get_disk_monitoring();
long config_get_disk_threshold();
int config_get_disk_grace_period();
-int config_get_disk_preserve_logging();
int config_get_disk_logging_critical();
int config_get_sasl_maxbufsize();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 8fd8f51..9197011 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2003,7 +2003,6 @@ typedef struct _slapdEntryPoints {
#define CONFIG_DISK_MONITORING "nsslapd-disk-monitoring"
#define CONFIG_DISK_THRESHOLD "nsslapd-disk-monitoring-threshold"
#define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
-#define CONFIG_DISK_PRESERVE_LOGGING "nsslapd-disk-monitoring-preserve-logging"
#define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical"
#define CONFIG_SASL_MAXBUFSIZE "nsslapd-sasl-max-buffer-size"
@@ -2240,7 +2239,6 @@ typedef struct _slapdFrontendConfig {
int disk_monitoring;
int disk_threshold;
int disk_grace_period;
- int disk_preserve_logging;
int disk_logging_critical;
} slapdFrontendConfig_t;
10 years, 10 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 31 ++++++++++++++++++++-----------
ldap/servers/slapd/libglobs.c | 31 +------------------------------
ldap/servers/slapd/proto-slap.h | 2 --
ldap/servers/slapd/slap.h | 2 --
4 files changed, 21 insertions(+), 45 deletions(-)
New commits:
commit f315d67449463359301ef9cb2d714e9f264f293f
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 15:30:41 2013 -0400
Ticket 47385 - DS not shutting down when disk monitoring threshold is reached
Bug Description: If verbose logging is enabled, it fails to correctly
identify that the logging was disabled, and it gets
stuck in an endless loop - never shutting the server down.
Also, whe the server does shutdown due to a disk full, the
pid file is not removed.
Fix Description: Check for the two possible error log levels that indicate
verbose logging is disabled. There were also logic errors
when determining if it was ok to disable access/audit logging,
and if to delete rotated logs.
Also removed the "nsslapd-disk-monitoring-preserve-logging"
setting, as it really didn't served a purpose because it was
basically the same as "nsslapd-disk-monitoring-logging-critical".
Lastly, if the server is being shutdown from a "disk full"
condition, then we need to manually remove the pidfile.
https://fedorahosted.org/389/ticket/47385
Reviewed by: Noriko(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 07fa0dc..101cd75 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -722,7 +722,6 @@ disk_monitoring_thread(void *nothing)
time_t now = 0;
int deleted_rotated_logs = 0;
int logging_critical = 0;
- int preserve_logging = 0;
int passed_threshold = 0;
int verbose_logging = 0;
int using_accesslog = 0;
@@ -752,7 +751,6 @@ disk_monitoring_thread(void *nothing)
* Get the config settings, as they could have changed
*/
logging_critical = config_get_disk_logging_critical();
- preserve_logging = config_get_disk_preserve_logging();
grace_period = 60 * config_get_disk_grace_period(); /* convert it to seconds */
verbose_logging = config_get_errorlog_level();
threshold = config_get_disk_threshold();
@@ -809,18 +807,21 @@ disk_monitoring_thread(void *nothing)
}
/*
* If we are low, see if we are using verbose error logging, and turn it off
+ * if logging is not critical
*/
- if(verbose_logging){
+ if(verbose_logging != 0 && verbose_logging != LDAP_DEBUG_ANY){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is low on disk (%s), remaining space: %d Kb, "
- "setting error loglevel to zero.\n", dirstr, (disk_space / 1024), 0);
- config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, 0, errorbuf, CONFIG_APPLY);
+ "temporarily setting error loglevel to zero.\n", dirstr,
+ (disk_space / 1024), 0);
+ /* Setting the log level back to zero, actually sets the value to LDAP_DEBUG_ANY */
+ config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, "0", errorbuf, CONFIG_APPLY);
continue;
}
/*
* If we are low, there's no verbose logging, logs are not critical, then disable the
* access/audit logs, log another error, and continue.
*/
- if(!logs_disabled && (!preserve_logging || !logging_critical)){
+ if(!logs_disabled && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
"disabling access and audit logging.\n", dirstr, (disk_space / 1024), 0);
@@ -834,7 +835,7 @@ disk_monitoring_thread(void *nothing)
* If we are low, we turned off verbose logging, logs are not critical, and we disabled
* access/audit logging, then delete the rotated logs, log another error, and continue.
*/
- if(!deleted_rotated_logs && (!preserve_logging || !logging_critical)){
+ if(!deleted_rotated_logs && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
"deleting rotated logs.\n", dirstr, (disk_space / 1024), 0);
@@ -883,10 +884,10 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Available disk space is now acceptable (%d bytes). Aborting"
" shutdown, and restoring the log settings.\n",disk_space,0,0);
- if(!preserve_logging && using_accesslog){
+ if(logs_disabled && using_accesslog){
config_set_accesslog_enabled(LOGGING_ON);
}
- if(!preserve_logging && using_auditlog){
+ if(logs_disabled && using_auditlog){
config_set_auditlog_enabled(LOGGING_ON);
}
deleted_rotated_logs = 0;
@@ -903,7 +904,7 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is critically low on disk (%s), remaining space: %d Kb."
" Signaling slapd for shutdown...\n", dirstr, (disk_space / 1024), 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
return;
}
time(&now);
@@ -920,7 +921,8 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is still too low (%d Kb). Signaling slapd for shutdown...\n",
(disk_space / 1024), 0, 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
+
return;
}
}
@@ -1378,6 +1380,13 @@ void slapd_daemon( daemon_ports_t *ports )
#ifdef _WIN32
WSACleanup();
+#else
+ if ( g_get_shutdown() == SLAPI_SHUTDOWN_DISKFULL ){
+ /* This is a server-induced shutdown, we need to manually remove the pid file */
+ if( unlink(get_pid_file()) ){
+ LDAPDebug( LDAP_DEBUG_ANY, "Failed to remove pid file %s\n", get_pid_file(), 0, 0 );
+ }
+ }
#endif
}
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index a5c1067..ac664a4 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -251,8 +251,8 @@ int init_slapi_counters;
int init_entryusn_global;
int init_disk_monitoring;
int init_disk_logging_critical;
-int init_disk_preserve_logging;
int init_ndn_cache_enabled;
+
#ifdef MEMPOOL_EXPERIMENTAL
int init_mempool_switch;
#endif
@@ -994,11 +994,6 @@ static struct config_get_and_set {
(void**)&global_slapdFrontendConfig.disk_logging_critical,
CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_logging_critical,
&init_disk_logging_critical},
- {CONFIG_DISK_PRESERVE_LOGGING, config_set_disk_preserve_logging,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.disk_preserve_logging,
- CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_preserve_logging,
- &init_disk_preserve_logging},
{CONFIG_NDN_CACHE, config_set_ndn_cache_enabled,
NULL, 0,
(void**)&global_slapdFrontendConfig.ndn_cache_enabled,
@@ -1439,7 +1434,6 @@ FrontendConfig_init () {
init_disk_monitoring = cfg->disk_monitoring = LDAP_OFF;
cfg->disk_threshold = 2097152; /* 2 mb */
cfg->disk_grace_period = 60; /* 1 hour */
- init_disk_preserve_logging = cfg->disk_preserve_logging = LDAP_OFF;
init_disk_logging_critical = cfg->disk_logging_critical = LDAP_OFF;
init_ndn_cache_enabled = cfg->ndn_cache_enabled = LDAP_OFF;
cfg->ndn_cache_max_size = NDN_DEFAULT_SIZE;
@@ -1611,17 +1605,6 @@ config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, in
}
int
-config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply )
-{
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal = LDAP_SUCCESS;
-
- retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_preserve_logging),
- errorbuf, apply);
- return retVal;
-}
-
-int
config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply )
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4184,18 +4167,6 @@ config_get_disk_monitoring(){
}
int
-config_get_disk_preserve_logging(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->disk_preserve_logging;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
-}
-
-int
config_get_disk_logging_critical(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
int retVal;
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 901b380..0a90e92 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -390,7 +390,6 @@ int config_set_default_naming_context( const char *attrname, char *value, char *
int config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply );
-int config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_ndn_cache_enabled(const char *attrname, char *value, char *errorbuf, int apply);
@@ -549,7 +548,6 @@ int config_get_accesslog_logging_enabled();
int config_get_disk_monitoring();
long config_get_disk_threshold();
int config_get_disk_grace_period();
-int config_get_disk_preserve_logging();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
size_t config_get_ndn_cache_size();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 43a213e..4026c37 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2049,7 +2049,6 @@ typedef struct _slapdEntryPoints {
#define CONFIG_DISK_MONITORING "nsslapd-disk-monitoring"
#define CONFIG_DISK_THRESHOLD "nsslapd-disk-monitoring-threshold"
#define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
-#define CONFIG_DISK_PRESERVE_LOGGING "nsslapd-disk-monitoring-preserve-logging"
#define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical"
#define CONFIG_NDN_CACHE "nsslapd-ndn-cache-enabled"
#define CONFIG_NDN_CACHE_SIZE "nsslapd-ndn-cache-max-size"
@@ -2272,7 +2271,6 @@ typedef struct _slapdFrontendConfig {
int disk_monitoring;
int disk_threshold;
int disk_grace_period;
- int disk_preserve_logging;
int disk_logging_critical;
/* normalized dn cache */
10 years, 10 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 31 ++++++++++++++++++++-----------
ldap/servers/slapd/libglobs.c | 30 ------------------------------
ldap/servers/slapd/proto-slap.h | 2 --
ldap/servers/slapd/slap.h | 2 --
4 files changed, 20 insertions(+), 45 deletions(-)
New commits:
commit 2f83f1c82702535e70092c7424a6d586821fbebd
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 15:30:41 2013 -0400
Ticket 47385 - DS not shutting down when disk monitoring threshold is reached
Bug Description: If verbose logging is enabled, it fails to correctly
identify that the logging was disabled, and it gets
stuck in an endless loop - never shutting the server down.
Also, whe the server does shutdown due to a disk full, the
pid file is not removed.
Fix Description: Check for the two possible error log levels that indicate
verbose logging is disabled. There were also logic errors
when determining if it was ok to disable access/audit logging,
and if to delete rotated logs.
Also removed the "nsslapd-disk-monitoring-preserve-logging"
setting, as it really didn't served a purpose because it was
basically the same as "nsslapd-disk-monitoring-logging-critical".
Lastly, if the server is being shutdown from a "disk full"
condition, then we need to manually remove the pidfile.
https://fedorahosted.org/389/ticket/47385
Reviewed by: Noriko(Thanks!)
(cherry picked from commit fcd2cebe7672f7d746762e9355815ebfb8f56eae)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 2e315f4..eadb4b5 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -722,7 +722,6 @@ disk_monitoring_thread(void *nothing)
time_t now = 0;
int deleted_rotated_logs = 0;
int logging_critical = 0;
- int preserve_logging = 0;
int passed_threshold = 0;
int verbose_logging = 0;
int using_accesslog = 0;
@@ -752,7 +751,6 @@ disk_monitoring_thread(void *nothing)
* Get the config settings, as they could have changed
*/
logging_critical = config_get_disk_logging_critical();
- preserve_logging = config_get_disk_preserve_logging();
grace_period = 60 * config_get_disk_grace_period(); /* convert it to seconds */
verbose_logging = config_get_errorlog_level();
threshold = config_get_disk_threshold();
@@ -809,18 +807,21 @@ disk_monitoring_thread(void *nothing)
}
/*
* If we are low, see if we are using verbose error logging, and turn it off
+ * if logging is not critical
*/
- if(verbose_logging){
+ if(verbose_logging != 0 && verbose_logging != LDAP_DEBUG_ANY){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is low on disk (%s), remaining space: %d Kb, "
- "setting error loglevel to zero.\n", dirstr, (disk_space / 1024), 0);
- config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, 0, errorbuf, CONFIG_APPLY);
+ "temporarily setting error loglevel to zero.\n", dirstr,
+ (disk_space / 1024), 0);
+ /* Setting the log level back to zero, actually sets the value to LDAP_DEBUG_ANY */
+ config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, "0", errorbuf, CONFIG_APPLY);
continue;
}
/*
* If we are low, there's no verbose logging, logs are not critical, then disable the
* access/audit logs, log another error, and continue.
*/
- if(!logs_disabled && (!preserve_logging || !logging_critical)){
+ if(!logs_disabled && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
"disabling access and audit logging.\n", dirstr, (disk_space / 1024), 0);
@@ -834,7 +835,7 @@ disk_monitoring_thread(void *nothing)
* If we are low, we turned off verbose logging, logs are not critical, and we disabled
* access/audit logging, then delete the rotated logs, log another error, and continue.
*/
- if(!deleted_rotated_logs && (!preserve_logging || !logging_critical)){
+ if(!deleted_rotated_logs && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
"deleting rotated logs.\n", dirstr, (disk_space / 1024), 0);
@@ -883,10 +884,10 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Available disk space is now acceptable (%d bytes). Aborting"
" shutdown, and restoring the log settings.\n",disk_space,0,0);
- if(!preserve_logging && using_accesslog){
+ if(logs_disabled && using_accesslog){
config_set_accesslog_enabled(LOGGING_ON);
}
- if(!preserve_logging && using_auditlog){
+ if(logs_disabled && using_auditlog){
config_set_auditlog_enabled(LOGGING_ON);
}
deleted_rotated_logs = 0;
@@ -903,7 +904,7 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is critically low on disk (%s), remaining space: %d Kb."
" Signaling slapd for shutdown...\n", dirstr, (disk_space / 1024), 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
return;
}
time(&now);
@@ -920,7 +921,8 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is still too low (%d Kb). Signaling slapd for shutdown...\n",
(disk_space / 1024), 0, 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
+
return;
}
}
@@ -1378,6 +1380,13 @@ void slapd_daemon( daemon_ports_t *ports )
#ifdef _WIN32
WSACleanup();
+#else
+ if ( g_get_shutdown() == SLAPI_SHUTDOWN_DISKFULL ){
+ /* This is a server-induced shutdown, we need to manually remove the pid file */
+ if( unlink(get_pid_file()) ){
+ LDAPDebug( LDAP_DEBUG_ANY, "Failed to remove pid file %s\n", get_pid_file(), 0, 0 );
+ }
+ }
#endif
}
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 8b234f6..67f0b3a 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -252,7 +252,6 @@ slapi_onoff_t init_slapi_counters;
slapi_onoff_t init_entryusn_global;
slapi_onoff_t init_disk_monitoring;
slapi_onoff_t init_disk_logging_critical;
-slapi_onoff_t init_disk_preserve_logging;
slapi_onoff_t init_ndn_cache_enabled;
slapi_onoff_t init_sasl_mapping_fallback;
slapi_onoff_t init_return_orig_type;
@@ -1008,11 +1007,6 @@ static struct config_get_and_set {
(void**)&global_slapdFrontendConfig.disk_logging_critical,
CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_logging_critical,
&init_disk_logging_critical},
- {CONFIG_DISK_PRESERVE_LOGGING, config_set_disk_preserve_logging,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.disk_preserve_logging,
- CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_preserve_logging,
- &init_disk_preserve_logging},
{CONFIG_NDN_CACHE, config_set_ndn_cache_enabled,
NULL, 0,
(void**)&global_slapdFrontendConfig.ndn_cache_enabled,
@@ -1478,7 +1472,6 @@ FrontendConfig_init () {
init_disk_monitoring = cfg->disk_monitoring = LDAP_OFF;
cfg->disk_threshold = 2097152; /* 2 mb */
cfg->disk_grace_period = 60; /* 1 hour */
- init_disk_preserve_logging = cfg->disk_preserve_logging = LDAP_OFF;
init_disk_logging_critical = cfg->disk_logging_critical = LDAP_OFF;
init_ndn_cache_enabled = cfg->ndn_cache_enabled = LDAP_OFF;
cfg->ndn_cache_max_size = NDN_DEFAULT_SIZE;
@@ -1677,17 +1670,6 @@ config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, in
}
int
-config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply )
-{
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal = LDAP_SUCCESS;
-
- retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_preserve_logging),
- errorbuf, apply);
- return retVal;
-}
-
-int
config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply )
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4309,18 +4291,6 @@ config_get_disk_monitoring(){
}
int
-config_get_disk_preserve_logging(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
- retVal = (int)slapdFrontendConfig->disk_preserve_logging;
- CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
-}
-
-int
config_get_disk_logging_critical(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
int retVal;
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 2508d70..fff3e7c 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -394,7 +394,6 @@ int config_set_default_naming_context( const char *attrname, char *value, char *
int config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply );
-int config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_ndn_cache_enabled(const char *attrname, char *value, char *errorbuf, int apply);
@@ -555,7 +554,6 @@ int config_get_accesslog_logging_enabled();
int config_get_disk_monitoring();
long config_get_disk_threshold();
int config_get_disk_grace_period();
-int config_get_disk_preserve_logging();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
size_t config_get_ndn_cache_size();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index a4258bb..2d4b108 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2068,7 +2068,6 @@ typedef struct _slapdEntryPoints {
#define CONFIG_DISK_MONITORING "nsslapd-disk-monitoring"
#define CONFIG_DISK_THRESHOLD "nsslapd-disk-monitoring-threshold"
#define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
-#define CONFIG_DISK_PRESERVE_LOGGING "nsslapd-disk-monitoring-preserve-logging"
#define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical"
#define CONFIG_NDN_CACHE "nsslapd-ndn-cache-enabled"
#define CONFIG_NDN_CACHE_SIZE "nsslapd-ndn-cache-max-size"
@@ -2307,7 +2306,6 @@ typedef struct _slapdFrontendConfig {
slapi_onoff_t disk_monitoring;
int disk_threshold;
int disk_grace_period;
- slapi_onoff_t disk_preserve_logging;
slapi_onoff_t disk_logging_critical;
/* normalized dn cache */
10 years, 10 months
ldap/servers
by Mark Reynolds
ldap/servers/slapd/daemon.c | 31 ++++++++++++++++++++-----------
ldap/servers/slapd/libglobs.c | 30 ------------------------------
ldap/servers/slapd/proto-slap.h | 2 --
ldap/servers/slapd/slap.h | 2 --
4 files changed, 20 insertions(+), 45 deletions(-)
New commits:
commit fcd2cebe7672f7d746762e9355815ebfb8f56eae
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 15:30:41 2013 -0400
Ticket 47385 - DS not shutting down when disk monitoring threshold is reached
Bug Description: If verbose logging is enabled, it fails to correctly
identify that the logging was disabled, and it gets
stuck in an endless loop - never shutting the server down.
Also, whe the server does shutdown due to a disk full, the
pid file is not removed.
Fix Description: Check for the two possible error log levels that indicate
verbose logging is disabled. There were also logic errors
when determining if it was ok to disable access/audit logging,
and if to delete rotated logs.
Also removed the "nsslapd-disk-monitoring-preserve-logging"
setting, as it really didn't served a purpose because it was
basically the same as "nsslapd-disk-monitoring-logging-critical".
Lastly, if the server is being shutdown from a "disk full"
condition, then we need to manually remove the pidfile.
https://fedorahosted.org/389/ticket/47385
Reviewed by: Noriko(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 8945c36..0120aaa 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -722,7 +722,6 @@ disk_monitoring_thread(void *nothing)
time_t now = 0;
int deleted_rotated_logs = 0;
int logging_critical = 0;
- int preserve_logging = 0;
int passed_threshold = 0;
int verbose_logging = 0;
int using_accesslog = 0;
@@ -752,7 +751,6 @@ disk_monitoring_thread(void *nothing)
* Get the config settings, as they could have changed
*/
logging_critical = config_get_disk_logging_critical();
- preserve_logging = config_get_disk_preserve_logging();
grace_period = 60 * config_get_disk_grace_period(); /* convert it to seconds */
verbose_logging = config_get_errorlog_level();
threshold = config_get_disk_threshold();
@@ -809,18 +807,21 @@ disk_monitoring_thread(void *nothing)
}
/*
* If we are low, see if we are using verbose error logging, and turn it off
+ * if logging is not critical
*/
- if(verbose_logging){
+ if(verbose_logging != 0 && verbose_logging != LDAP_DEBUG_ANY){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is low on disk (%s), remaining space: %d Kb, "
- "setting error loglevel to zero.\n", dirstr, (disk_space / 1024), 0);
- config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, 0, errorbuf, CONFIG_APPLY);
+ "temporarily setting error loglevel to zero.\n", dirstr,
+ (disk_space / 1024), 0);
+ /* Setting the log level back to zero, actually sets the value to LDAP_DEBUG_ANY */
+ config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, "0", errorbuf, CONFIG_APPLY);
continue;
}
/*
* If we are low, there's no verbose logging, logs are not critical, then disable the
* access/audit logs, log another error, and continue.
*/
- if(!logs_disabled && (!preserve_logging || !logging_critical)){
+ if(!logs_disabled && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
"disabling access and audit logging.\n", dirstr, (disk_space / 1024), 0);
@@ -834,7 +835,7 @@ disk_monitoring_thread(void *nothing)
* If we are low, we turned off verbose logging, logs are not critical, and we disabled
* access/audit logging, then delete the rotated logs, log another error, and continue.
*/
- if(!deleted_rotated_logs && (!preserve_logging || !logging_critical)){
+ if(!deleted_rotated_logs && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s), remaining space: %d Kb, "
"deleting rotated logs.\n", dirstr, (disk_space / 1024), 0);
@@ -883,10 +884,10 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Available disk space is now acceptable (%d bytes). Aborting"
" shutdown, and restoring the log settings.\n",disk_space,0,0);
- if(!preserve_logging && using_accesslog){
+ if(logs_disabled && using_accesslog){
config_set_accesslog_enabled(LOGGING_ON);
}
- if(!preserve_logging && using_auditlog){
+ if(logs_disabled && using_auditlog){
config_set_auditlog_enabled(LOGGING_ON);
}
deleted_rotated_logs = 0;
@@ -903,7 +904,7 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is critically low on disk (%s), remaining space: %d Kb."
" Signaling slapd for shutdown...\n", dirstr, (disk_space / 1024), 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
return;
}
time(&now);
@@ -920,7 +921,8 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is still too low (%d Kb). Signaling slapd for shutdown...\n",
(disk_space / 1024), 0, 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
+
return;
}
}
@@ -1378,6 +1380,13 @@ void slapd_daemon( daemon_ports_t *ports )
#ifdef _WIN32
WSACleanup();
+#else
+ if ( g_get_shutdown() == SLAPI_SHUTDOWN_DISKFULL ){
+ /* This is a server-induced shutdown, we need to manually remove the pid file */
+ if( unlink(get_pid_file()) ){
+ LDAPDebug( LDAP_DEBUG_ANY, "Failed to remove pid file %s\n", get_pid_file(), 0, 0 );
+ }
+ }
#endif
}
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index cfb8856..b8fe9ba 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -253,7 +253,6 @@ slapi_onoff_t init_slapi_counters;
slapi_onoff_t init_entryusn_global;
slapi_onoff_t init_disk_monitoring;
slapi_onoff_t init_disk_logging_critical;
-slapi_onoff_t init_disk_preserve_logging;
slapi_onoff_t init_ndn_cache_enabled;
slapi_onoff_t init_sasl_mapping_fallback;
slapi_onoff_t init_return_orig_type;
@@ -1015,11 +1014,6 @@ static struct config_get_and_set {
(void**)&global_slapdFrontendConfig.disk_logging_critical,
CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_logging_critical,
&init_disk_logging_critical},
- {CONFIG_DISK_PRESERVE_LOGGING, config_set_disk_preserve_logging,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.disk_preserve_logging,
- CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_preserve_logging,
- &init_disk_preserve_logging},
{CONFIG_NDN_CACHE, config_set_ndn_cache_enabled,
NULL, 0,
(void**)&global_slapdFrontendConfig.ndn_cache_enabled,
@@ -1493,7 +1487,6 @@ FrontendConfig_init () {
init_disk_monitoring = cfg->disk_monitoring = LDAP_OFF;
cfg->disk_threshold = 2097152; /* 2 mb */
cfg->disk_grace_period = 60; /* 1 hour */
- init_disk_preserve_logging = cfg->disk_preserve_logging = LDAP_OFF;
init_disk_logging_critical = cfg->disk_logging_critical = LDAP_OFF;
init_ndn_cache_enabled = cfg->ndn_cache_enabled = LDAP_OFF;
cfg->ndn_cache_max_size = NDN_DEFAULT_SIZE;
@@ -1694,17 +1687,6 @@ config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, in
}
int
-config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply )
-{
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal = LDAP_SUCCESS;
-
- retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_preserve_logging),
- errorbuf, apply);
- return retVal;
-}
-
-int
config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply )
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4359,18 +4341,6 @@ config_get_disk_monitoring(){
}
int
-config_get_disk_preserve_logging(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
- retVal = (int)slapdFrontendConfig->disk_preserve_logging;
- CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
-}
-
-int
config_get_disk_logging_critical(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
int retVal;
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 9fe26ff..86284fc 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -395,7 +395,6 @@ int config_set_default_naming_context( const char *attrname, char *value, char *
int config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply );
-int config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_ndn_cache_enabled(const char *attrname, char *value, char *errorbuf, int apply);
@@ -556,7 +555,6 @@ int config_get_accesslog_logging_enabled();
int config_get_disk_monitoring();
long config_get_disk_threshold();
int config_get_disk_grace_period();
-int config_get_disk_preserve_logging();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
size_t config_get_ndn_cache_size();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 1039b0a..e1af7b9 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2078,7 +2078,6 @@ typedef struct _slapdEntryPoints {
#define CONFIG_DISK_MONITORING "nsslapd-disk-monitoring"
#define CONFIG_DISK_THRESHOLD "nsslapd-disk-monitoring-threshold"
#define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
-#define CONFIG_DISK_PRESERVE_LOGGING "nsslapd-disk-monitoring-preserve-logging"
#define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical"
#define CONFIG_NDN_CACHE "nsslapd-ndn-cache-enabled"
#define CONFIG_NDN_CACHE_SIZE "nsslapd-ndn-cache-max-size"
@@ -2320,7 +2319,6 @@ typedef struct _slapdFrontendConfig {
slapi_onoff_t disk_monitoring;
int disk_threshold;
int disk_grace_period;
- slapi_onoff_t disk_preserve_logging;
slapi_onoff_t disk_logging_critical;
/* normalized dn cache */
10 years, 10 months
ldap/servers
by thierry bordaz
ldap/servers/plugins/replication/repl5_plugins.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
New commits:
commit 383cc74f8bd2556ad95b5701d9aa7fecb8749fe3
Author: Thierry bordaz (tbordaz) <tbordaz(a)redhat.com>
Date: Thu Jun 6 14:59:24 2013 +0200
Ticket 47350 - (Cont.) Allow search to look up 'in memory RUV'
Bug Description:
Returning the in memory RUV in place of the DB RUV is not
systematically the right thing to do.
For administrative operations (like total update), the server
wants to access the real DB RUV and not the in memory RUV.
Fix Description:
The fix checks if the search is an internal search.
if it is it returns the DB RUV (tombstone)
https://fedorahosted.org/389/ticket/47350
Reviewed by: Rich and Noriko (thanks for your review and help :) )
Platforms tested: Fedora 18
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index cb5fe5c..5981d0c 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -645,13 +645,15 @@ multimaster_ruv_search(Slapi_PBlock *pb)
{
Slapi_Entry *e, *e_alt;
Slapi_DN *suffix_sdn;
+ Slapi_Operation *operation;
slapi_pblock_get(pb, SLAPI_SEARCH_ENTRY_ORIG, &e);
+ slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
- if (e == NULL)
+ if ((e == NULL) || (operation == NULL))
return 0;
- if (is_ruv_tombstone_entry(e)) {
+ if (!operation_is_flag_set(operation, OP_FLAG_INTERNAL) && is_ruv_tombstone_entry(e)) {
/* We are about to send back the database RUV, we need to return
* in memory RUV instead
*/
10 years, 10 months