lib/libadmin
by Nathan Kinder
lib/libadmin/util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 5a52f43e2ecc5cdad7bf4b2916688ee42095fe88
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Apr 29 11:31:19 2011 -0700
Bug 700890 - (cov#10812) Check return value of open() properly in libadmin
We do not properly check the return value of open() in the run_cmd()
function in libadmin. The open() function will return -1 if the open
failed. The if condition needs to check if the return value is < 0 so
it can bail out properly.
diff --git a/lib/libadmin/util.c b/lib/libadmin/util.c
index 4b8f326..bfb7354 100644
--- a/lib/libadmin/util.c
+++ b/lib/libadmin/util.c
@@ -481,7 +481,7 @@ int run_cmd(char *cmd, FILE *closeme, struct runcmd_s *rm)
return -1;
}
if(exstat) {
- if(!(fd = open(tfn, O_RDONLY))) {
+ if((fd = open(tfn, O_RDONLY)) < 0) {
rm->title = "Can't open error file";
rm->msg = "Can't find error file %s.";
rm->arg = cmd;
12 years, 12 months
lib/libdsa
by Nathan Kinder
lib/libdsa/dsalib_updown.c | 47 ++++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 30 deletions(-)
New commits:
commit cc422c4d21ec4ae262601fe2b294b49bb4ea5d97
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Apr 29 10:23:40 2011 -0700
Bug 700875 - (cov#10778) Cleanup ds_bring_up_server_install() in dsalib
The ds_bring_up_server_install() function looks to have some cut/paste errors
in it that throw off the intended logic.
If XP_WIN32 is not defined, the else at line 256 is a part of the if at line
246. If XP_WIN32 is defined, the else at line 256 is a part of the if at line
227, which seems wrong.
It also seems like the if statement at line 227 should be closed out after line
237. The intent looks to be that we want to print the contents of statfile is
the verbose option is set. The code beginning at line 239 seems unrelated to
the verbose option, as it's setting the status that gets returned.
This could be some sort of copy/paste area wince the if/else block beginning at
line 207 seems the same as the if/else block starting at line 239.
diff --git a/lib/libdsa/dsalib_updown.c b/lib/libdsa/dsalib_updown.c
index 5ea331e..c3b460c 100644
--- a/lib/libdsa/dsalib_updown.c
+++ b/lib/libdsa/dsalib_updown.c
@@ -223,9 +223,24 @@ ds_bring_up_server_install(int verbose, char *instdir, char *errorlog)
if (verbose)
ds_send_error("error in starting server.", 1);
return(retval);
+ } else {
+ int tries;
+ for (tries = 0; tries < secondsToWaitForServer; tries++) {
+ if (ds_get_updown_status() == DS_SERVER_UP) {
+ status = DS_SERVER_UP;
+ break;
+ }
+ PR_Sleep(PR_SecondsToInterval(1));
+ }
+ if (verbose) {
+ char str[100];
+ PR_snprintf(str, sizeof(str), "Had to retry %d times", tries);
+ ds_send_status(str);
+ }
}
- if (verbose) {
+
#if !defined( XP_WIN32 )
+ if (verbose) {
if( !(sf = fopen(statfile, "r")) ) {
ds_send_error("could not read status file.", 1);
return(DS_SERVER_UNKNOWN);
@@ -235,36 +250,8 @@ ds_bring_up_server_install(int verbose, char *instdir, char *errorlog)
ds_send_error(startup_line, 0);
fclose(sf);
unlink(statfile);
-#endif
- status = DS_SERVER_UNKNOWN;
- if (strstr(msgBuf, "semget"))
- status = DS_SERVER_MAX_SEMAPHORES;
- else if (strstr(msgBuf, "Back-End Initialization Failed"))
- status = DS_SERVER_CORRUPTED_DB;
- else if (strstr(msgBuf, "not initialized... exiting"))
- status = DS_SERVER_CORRUPTED_DB;
- else if (strstr(msgBuf, "address is in use"))
- status = DS_SERVER_PORT_IN_USE;
-#if defined( XP_WIN32 )
- /* on NT, if we run out of resources, there will not even be an error
- log
- */
- else if (msgBuf[0] == 0) {
- status = DS_SERVER_NO_RESOURCES;
- }
-#endif
- } else {
- int tries;
- for (tries = 0; tries < secondsToWaitForServer; tries++) {
- if (ds_get_updown_status() == DS_SERVER_UP) break;
- PR_Sleep(PR_SecondsToInterval(1));
- }
- if (verbose) {
- char str[100];
- PR_snprintf(str, sizeof(str), "Had to retry %d times", tries);
- ds_send_status(str);
- }
}
+#endif
if ( (status == DS_SERVER_DOWN) || (status == DS_SERVER_UNKNOWN) )
status = ds_get_updown_status();
13 years
ldap/servers
by Nathan Kinder
ldap/servers/plugins/dna/dna.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
New commits:
commit c74a13d7c46887e45aea48e76424ed2f0155cf72
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Apr 29 08:56:46 2011 -0700
Bug 700557 - Leak at shutdown in DNA plug-in
The previous commit for bug 700557 has a leak in the DNA plug-in
when the plug-in has already had it's close() call called during
shutdown. This frees the leaked Slapi_DN.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index a245a8d..8c744c4 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -3316,8 +3316,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
- dna_unlock();
- return 0;
+ goto bail;
}
/* Go through the config entries to see if we
13 years
Branch '389-ds-base-1.2.8' - ldap/servers
by Nathan Kinder
ldap/servers/plugins/dna/dna.c | 39 +++++++++++++++
ldap/servers/plugins/linkedattrs/linked_attrs.c | 54 +++++++++++++++++++++
ldap/servers/plugins/mep/mep.c | 59 ++++++++++++++++++++++++
3 files changed, 152 insertions(+)
New commits:
commit ef511100fe825dcb7874c3c3549274dbf8644808
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Thu Apr 28 10:40:11 2011 -0700
Bug 700557 - Linked attrs callbacks access free'd pointers after close
The linked attributes plug-in callbacks can still try to access free'd
resources after it's close callback has been called. This can cause
ns-slapd to crash.
This same issue actually applies to the following plug-ins:
- DNA
- Linked Attributes
- Managed Entries
We should address this issue in all of these plug-ins. We need to
unset the started flag in the close() callbacks, which needs to be
done with the write lock on the config held. To prevent problems
with waiting readers, we need to make all readers check if the started
flag is set after they obtain a reader lock. This will deal with the
case where the plug-in was stopped while a thread was waiting on a
reader lock. We also need to be sure to NOT free the lock in the
close() function so that these waiting readers don't crash the
server.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index c457c0f..96e3357 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -568,7 +568,14 @@ dna_close(Slapi_PBlock * pb)
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_close\n");
+ if (!g_plugin_started) {
+ goto done;
+ }
+
+ dna_write_lock();
+ g_plugin_started = 0;
dna_delete_config();
+ dna_unlock();
slapi_ch_free((void **)&dna_global_config);
@@ -576,6 +583,15 @@ dna_close(Slapi_PBlock * pb)
slapi_ch_free_string(&portnum);
slapi_ch_free_string(&secureportnum);
+ /* We explicitly don't destroy the config lock here. If we did,
+ * there is the slight possibility that another thread that just
+ * passed the g_plugin_started check is about to try to obtain
+ * a reader lock. We leave the lock around so these threads
+ * don't crash the process. If we always check the started
+ * flag again after obtaining a reader lock, no free'd resources
+ * will be used. */
+
+done:
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"<-- dna_close\n");
@@ -1204,6 +1220,11 @@ dna_update_config_event(time_t event_time, void *arg)
/* Get read lock to prevent config changes */
dna_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ goto bail;
+ }
+
/* Loop through all config entries and update the shared
* config entries. */
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
@@ -2833,6 +2854,12 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
dna_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ dna_unlock();
+ goto bail;
+ }
+
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
list = PR_LIST_HEAD(dna_global_config);
@@ -3281,6 +3308,12 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
dna_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ dna_unlock();
+ return 0;
+ }
+
/* Go through the config entries to see if we
* have a shared range configured that matches
* the range from the exop request. */
@@ -3461,6 +3494,11 @@ void dna_dump_config()
dna_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ goto bail;
+ }
+
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
list = PR_LIST_HEAD(dna_global_config);
while (list != dna_global_config) {
@@ -3469,6 +3507,7 @@ void dna_dump_config()
}
}
+bail:
dna_unlock();
}
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 5cfef5d..e93f297 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -352,11 +352,27 @@ linked_attrs_close(Slapi_PBlock * pb)
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_close\n");
+ if (!g_plugin_started) {
+ goto done;
+ }
+
+ linked_attrs_write_lock();
+ g_plugin_started = 0;
linked_attrs_delete_config();
+ linked_attrs_unlock();
slapi_ch_free((void **)&g_link_config);
slapi_ch_free((void **)&g_managed_config_index);
+ /* We explicitly don't destroy the config lock here. If we did,
+ * there is the slight possibility that another thread that just
+ * passed the g_plugin_started check is about to try to obtain
+ * a reader lock. We leave the lock around so these threads
+ * don't crash the process. If we always check the started
+ * flag again after obtaining a reader lock, no free'd resources
+ * will be used. */
+
+done:
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"<-- linked_attrs_close\n");
@@ -1596,6 +1612,13 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
/* See if there is an applicable link configured. */
linked_attrs_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ linked_attrs_unlock();
+ return 0;
+ }
+
linked_attrs_find_config(dn, type, &config);
/* If we have a matching config entry, we have
@@ -1687,6 +1710,13 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
/* See if there is an applicable link configured. */
linked_attrs_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ linked_attrs_unlock();
+ return 0;
+ }
+
linked_attrs_find_config(dn, type, &config);
/* If config was found, add the backpointers to this entry. */
@@ -1759,6 +1789,13 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
/* See if there is an applicable link configured. */
linked_attrs_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ linked_attrs_unlock();
+ return 0;
+ }
+
linked_attrs_find_config(dn, type, &config);
/* If config was found, delete the backpointers to this entry. */
@@ -1878,6 +1915,13 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* See if there is an applicable link configured. */
linked_attrs_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ linked_attrs_unlock();
+ return 0;
+ }
+
linked_attrs_find_config(old_dn, type, &config);
/* If config was found for the old dn, delete the backpointers
@@ -1981,6 +2025,10 @@ linked_attrs_dump_config()
linked_attrs_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started)
+ goto bail;
+
if (!PR_CLIST_IS_EMPTY(g_link_config)) {
list = PR_LIST_HEAD(g_link_config);
while (list != g_link_config) {
@@ -1989,6 +2037,7 @@ linked_attrs_dump_config()
}
}
+bail:
linked_attrs_unlock();
}
@@ -1999,6 +2048,10 @@ linked_attrs_dump_config_index()
linked_attrs_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started)
+ goto bail;
+
if (!PR_CLIST_IS_EMPTY(g_managed_config_index)) {
list = PR_LIST_HEAD(g_managed_config_index);
while (list != g_managed_config_index) {
@@ -2007,6 +2060,7 @@ linked_attrs_dump_config_index()
}
}
+bail:
linked_attrs_unlock();
}
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index cc4be8e..ee7c7c0 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -349,10 +349,26 @@ mep_close(Slapi_PBlock * pb)
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_close\n");
+ if (!g_plugin_started) {
+ goto done;
+ }
+
+ mep_config_write_lock();
+ g_plugin_started = 0;
mep_delete_config();
+ mep_config_unlock();
slapi_ch_free((void **)&g_mep_config);
+ /* We explicitly don't destroy the config lock here. If we did,
+ * there is the slight possibility that another thread that just
+ * passed the g_plugin_started check is about to try to obtain
+ * a reader lock. We leave the lock around so these threads
+ * don't crash the process. If we always check the started
+ * flag again after obtaining a reader lock, no free'd resources
+ * will be used. */
+
+done:
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"<-- mep_close\n");
@@ -1739,6 +1755,13 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
} else {
/* Check if an active template entry is being updated. If so, validate it. */
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ goto bail;
+ }
+
mep_find_config_by_template_dn(dn, &config);
if (config) {
Slapi_Entry *test_entry = NULL;
@@ -1863,6 +1886,13 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
if (origin_e) {
/* Fetch the config. */
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ goto bail;
+ }
+
mep_find_config(origin_e, &config);
if (config) {
@@ -2019,6 +2049,13 @@ mep_mod_post_op(Slapi_PBlock *pb)
managed_dn = slapi_entry_attr_get_charptr(e, MEP_MANAGED_ENTRY_TYPE);
if (managed_dn) {
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ goto bail;
+ }
+
mep_find_config(e, &config);
if (config) {
smods = mep_get_mapped_mods(config, e, &mapped_dn);
@@ -2123,6 +2160,13 @@ mep_add_post_op(Slapi_PBlock *pb)
/* Check if a config entry applies
* to the entry being added. */
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ return 0;
+ }
+
mep_find_config(e, &config);
if (config) {
mep_add_managed_entry(config, e);
@@ -2273,6 +2317,14 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
Slapi_Mods *smods = NULL;
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ slapi_pblock_destroy(mep_pb);
+ return 0;
+ }
+
mep_find_config(post_e, &config);
if (!config) {
LDAPMod mod2;
@@ -2410,6 +2462,13 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
* If so, treat like an add and create the new managed
* entry and links. */
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ return 0;
+ }
+
mep_find_config(post_e, &config);
if (config) {
mep_add_managed_entry(config, post_e);
13 years
ldap/servers
by Nathan Kinder
ldap/servers/plugins/automember/automember.c | 19 ++++++-
ldap/servers/plugins/dna/dna.c | 39 +++++++++++++++
ldap/servers/plugins/linkedattrs/linked_attrs.c | 54 +++++++++++++++++++++
ldap/servers/plugins/mep/mep.c | 59 ++++++++++++++++++++++++
4 files changed, 168 insertions(+), 3 deletions(-)
New commits:
commit 22107650f6c09c38420976c988cdb94c1cbc6764
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Thu Apr 28 10:40:11 2011 -0700
Bug 700557 - Linked attrs callbacks access free'd pointers after close
The linked attributes plug-in callbacks can still try to access free'd
resources after it's close callback has been called. This can cause
ns-slapd to crash.
This same issue actually applies to the following plug-ins:
- DNA
- Linked Attributes
- Managed Entries
- Auto Membership
We should address this issue in all of these plug-ins. We need to
unset the started flag in the close() callbacks, which needs to be
done with the write lock on the config held. To prevent problems
with waiting readers, we need to make all readers check if the started
flag is set after they obtain a reader lock. This will deal with the
case where the plug-in was stopped while a thread was waiting on a
reader lock. We also need to be sure to NOT free the lock in the
close() function so that these waiting readers don't crash the
server.
diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index a015eae..670ae64 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -349,15 +349,22 @@ automember_close(Slapi_PBlock * pb)
goto done;
}
+ automember_config_write_lock();
+ g_plugin_started = 0;
automember_delete_config();
+ automember_config_unlock();
slapi_ch_free((void **)&g_automember_config);
slapi_sdn_free(&_PluginDN);
slapi_sdn_free(&_ConfigAreaDN);
- if (g_automember_config_lock) {
- PR_DestroyRWLock(g_automember_config_lock);
- }
+ /* We explicitly don't destroy the config lock here. If we did,
+ * there is the slight possibility that another thread that just
+ * passed the g_plugin_started check is about to try to obtain
+ * a reader lock. We leave the lock around so these threads
+ * don't crash the process. If we always check the started
+ * flag again after obtaining a reader lock, no free'd resources
+ * will be used. */
done:
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
@@ -1737,6 +1744,12 @@ automember_add_post_op(Slapi_PBlock *pb)
* to the entry being added. */
automember_config_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ automember_config_unlock();
+ return 0;
+ }
+
if (!PR_CLIST_IS_EMPTY(g_automember_config)) {
list = PR_LIST_HEAD(g_automember_config);
while (list != g_automember_config) {
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index fc520c9..a245a8d 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -568,7 +568,14 @@ dna_close(Slapi_PBlock * pb)
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_close\n");
+ if (!g_plugin_started) {
+ goto done;
+ }
+
+ dna_write_lock();
+ g_plugin_started = 0;
dna_delete_config();
+ dna_unlock();
slapi_ch_free((void **)&dna_global_config);
@@ -576,6 +583,15 @@ dna_close(Slapi_PBlock * pb)
slapi_ch_free_string(&portnum);
slapi_ch_free_string(&secureportnum);
+ /* We explicitly don't destroy the config lock here. If we did,
+ * there is the slight possibility that another thread that just
+ * passed the g_plugin_started check is about to try to obtain
+ * a reader lock. We leave the lock around so these threads
+ * don't crash the process. If we always check the started
+ * flag again after obtaining a reader lock, no free'd resources
+ * will be used. */
+
+done:
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"<-- dna_close\n");
@@ -1207,6 +1223,11 @@ dna_update_config_event(time_t event_time, void *arg)
/* Get read lock to prevent config changes */
dna_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ goto bail;
+ }
+
/* Loop through all config entries and update the shared
* config entries. */
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
@@ -2836,6 +2857,12 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
dna_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ dna_unlock();
+ goto bail;
+ }
+
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
list = PR_LIST_HEAD(dna_global_config);
@@ -3287,6 +3314,12 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
dna_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ dna_unlock();
+ return 0;
+ }
+
/* Go through the config entries to see if we
* have a shared range configured that matches
* the range from the exop request. */
@@ -3467,6 +3500,11 @@ void dna_dump_config()
dna_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ goto bail;
+ }
+
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
list = PR_LIST_HEAD(dna_global_config);
while (list != dna_global_config) {
@@ -3475,6 +3513,7 @@ void dna_dump_config()
}
}
+bail:
dna_unlock();
}
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index b69b2cd..1080436 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -352,11 +352,27 @@ linked_attrs_close(Slapi_PBlock * pb)
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_close\n");
+ if (!g_plugin_started) {
+ goto done;
+ }
+
+ linked_attrs_write_lock();
+ g_plugin_started = 0;
linked_attrs_delete_config();
+ linked_attrs_unlock();
slapi_ch_free((void **)&g_link_config);
slapi_ch_free((void **)&g_managed_config_index);
+ /* We explicitly don't destroy the config lock here. If we did,
+ * there is the slight possibility that another thread that just
+ * passed the g_plugin_started check is about to try to obtain
+ * a reader lock. We leave the lock around so these threads
+ * don't crash the process. If we always check the started
+ * flag again after obtaining a reader lock, no free'd resources
+ * will be used. */
+
+done:
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"<-- linked_attrs_close\n");
@@ -1584,6 +1600,13 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
/* See if there is an applicable link configured. */
linked_attrs_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ linked_attrs_unlock();
+ return 0;
+ }
+
linked_attrs_find_config(dn, type, &config);
/* If we have a matching config entry, we have
@@ -1675,6 +1698,13 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
/* See if there is an applicable link configured. */
linked_attrs_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ linked_attrs_unlock();
+ return 0;
+ }
+
linked_attrs_find_config(dn, type, &config);
/* If config was found, add the backpointers to this entry. */
@@ -1747,6 +1777,13 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
/* See if there is an applicable link configured. */
linked_attrs_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ linked_attrs_unlock();
+ return 0;
+ }
+
linked_attrs_find_config(dn, type, &config);
/* If config was found, delete the backpointers to this entry. */
@@ -1866,6 +1903,13 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* See if there is an applicable link configured. */
linked_attrs_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ linked_attrs_unlock();
+ return 0;
+ }
+
linked_attrs_find_config(old_dn, type, &config);
/* If config was found for the old dn, delete the backpointers
@@ -1969,6 +2013,10 @@ linked_attrs_dump_config()
linked_attrs_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started)
+ goto bail;
+
if (!PR_CLIST_IS_EMPTY(g_link_config)) {
list = PR_LIST_HEAD(g_link_config);
while (list != g_link_config) {
@@ -1977,6 +2025,7 @@ linked_attrs_dump_config()
}
}
+bail:
linked_attrs_unlock();
}
@@ -1987,6 +2036,10 @@ linked_attrs_dump_config_index()
linked_attrs_read_lock();
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started)
+ goto bail;
+
if (!PR_CLIST_IS_EMPTY(g_managed_config_index)) {
list = PR_LIST_HEAD(g_managed_config_index);
while (list != g_managed_config_index) {
@@ -1995,6 +2048,7 @@ linked_attrs_dump_config_index()
}
}
+bail:
linked_attrs_unlock();
}
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index cc4be8e..ee7c7c0 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -349,10 +349,26 @@ mep_close(Slapi_PBlock * pb)
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_close\n");
+ if (!g_plugin_started) {
+ goto done;
+ }
+
+ mep_config_write_lock();
+ g_plugin_started = 0;
mep_delete_config();
+ mep_config_unlock();
slapi_ch_free((void **)&g_mep_config);
+ /* We explicitly don't destroy the config lock here. If we did,
+ * there is the slight possibility that another thread that just
+ * passed the g_plugin_started check is about to try to obtain
+ * a reader lock. We leave the lock around so these threads
+ * don't crash the process. If we always check the started
+ * flag again after obtaining a reader lock, no free'd resources
+ * will be used. */
+
+done:
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"<-- mep_close\n");
@@ -1739,6 +1755,13 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
} else {
/* Check if an active template entry is being updated. If so, validate it. */
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ goto bail;
+ }
+
mep_find_config_by_template_dn(dn, &config);
if (config) {
Slapi_Entry *test_entry = NULL;
@@ -1863,6 +1886,13 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
if (origin_e) {
/* Fetch the config. */
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ goto bail;
+ }
+
mep_find_config(origin_e, &config);
if (config) {
@@ -2019,6 +2049,13 @@ mep_mod_post_op(Slapi_PBlock *pb)
managed_dn = slapi_entry_attr_get_charptr(e, MEP_MANAGED_ENTRY_TYPE);
if (managed_dn) {
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ goto bail;
+ }
+
mep_find_config(e, &config);
if (config) {
smods = mep_get_mapped_mods(config, e, &mapped_dn);
@@ -2123,6 +2160,13 @@ mep_add_post_op(Slapi_PBlock *pb)
/* Check if a config entry applies
* to the entry being added. */
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ return 0;
+ }
+
mep_find_config(e, &config);
if (config) {
mep_add_managed_entry(config, e);
@@ -2273,6 +2317,14 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
Slapi_Mods *smods = NULL;
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ slapi_pblock_destroy(mep_pb);
+ return 0;
+ }
+
mep_find_config(post_e, &config);
if (!config) {
LDAPMod mod2;
@@ -2410,6 +2462,13 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
* If so, treat like an add and create the new managed
* entry and links. */
mep_config_read_lock();
+
+ /* Bail out if the plug-in close function was just called. */
+ if (!g_plugin_started) {
+ mep_config_unlock();
+ return 0;
+ }
+
mep_find_config(post_e, &config);
if (config) {
mep_add_managed_entry(config, post_e);
13 years
Branch '389-ds-base-1.2.8' - ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/replication/windows_protocol_util.c | 17 +++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
New commits:
commit 3bb70c18739f8f7a04a2382ae7ffcb7d7bc68ec9
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Apr 28 13:29:55 2011 -0600
Bug 694336 - Group sync hangs Windows initial Sync
https://bugzilla.redhat.com/show_bug.cgi?id=694336
Resolves: bug 694336
Bug Description: Group sync hangs Windows initial Sync
Reviewed by: rmeggins (Author: diego(a)woitasen.com.ar)
Branch: 389-ds-base-1.2.8
Fix Description: winsync was getting back an error 65 (object class violation)
attempting to add the userAccountControl attribute to a group entry.
Only do this for user entries. I modified the patch slightly to change the
formatting, and to use "is_user" rather than "!is_group" to test whether
or not to send the userAccountControl attribute.
Platforms tested: RHEL6 x86_64, Windows 2008 r2
Flag Day: no
Doc impact: no
(cherry picked from commit c2c82cb46417f033f5a8e1bb2cef58cfb29e82b6)
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index abcdbc3..dc49827 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -928,8 +928,12 @@ windows_entry_has_attr_and_value(Slapi_Entry *e, const char *attrname, char *val
static void
windows_is_local_entry_user_or_group(Slapi_Entry *e, int *is_user, int *is_group)
{
- *is_user = windows_entry_has_attr_and_value(e,"objectclass","ntuser");
- *is_group = windows_entry_has_attr_and_value(e,"objectclass","ntgroup");
+ if (is_user) {
+ *is_user = windows_entry_has_attr_and_value(e, "objectclass", "ntuser");
+ }
+ if (is_group) {
+ *is_group = windows_entry_has_attr_and_value(e, "objectclass", "ntgroup");
+ }
}
static void
@@ -1621,8 +1625,10 @@ windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op
* userAccountControl: 512
* Or, if we added a new entry, we need to change the useraccountcontrol
* to make the new user enabled by default
+ * it is assumed that is_user is set for user entries and that only user entries need
+ * accountcontrol values
*/
- if ((return_value == CONN_OPERATION_SUCCESS) && remote_dn && (password || missing_entry)) {
+ if ((return_value == CONN_OPERATION_SUCCESS) && remote_dn && (password || missing_entry) && is_user) {
return_value = send_accountcontrol_modify(remote_dn, prp, missing_entry);
}
} else {
@@ -4510,6 +4516,7 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r
int can_add = winsync_plugin_call_can_add_entry_to_ad_cb(prp->agmt, e, remote_dn);
/* First map the entry */
local_dn = slapi_entry_get_sdn_const(e);
+ int is_user;
if (missing_entry) {
if (can_add) {
retval = windows_create_remote_entry(prp, e, remote_dn, &mapped_entry, &password);
@@ -4540,7 +4547,9 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r
ldap_mods_free(entryattrs, 1);
entryattrs = NULL;
- if (retval == 0) { /* set the account control bits */
+ windows_is_local_entry_user_or_group(e, &is_user, NULL);
+ if ((retval == 0) && is_user) {
+ /* set the account control bits only for users */
retval = send_accountcontrol_modify(remote_dn, prp, missing_entry);
}
}
13 years
ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/replication/windows_protocol_util.c | 17 +++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
New commits:
commit c2c82cb46417f033f5a8e1bb2cef58cfb29e82b6
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Apr 28 13:29:55 2011 -0600
Bug 694336 - Group sync hangs Windows initial Sync
https://bugzilla.redhat.com/show_bug.cgi?id=694336
Resolves: bug 694336
Bug Description: Group sync hangs Windows initial Sync
Reviewed by: rmeggins (Author: diego(a)woitasen.com.ar)
Branch: master
Fix Description: winsync was getting back an error 65 (object class violation)
attempting to add the userAccountControl attribute to a group entry.
Only do this for user entries. I modified the patch slightly to change the
formatting, and to use "is_user" rather than "!is_group" to test whether
or not to send the userAccountControl attribute.
Platforms tested: RHEL6 x86_64, Windows 2008 r2
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index ec67612..d5cb524 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -928,8 +928,12 @@ windows_entry_has_attr_and_value(Slapi_Entry *e, const char *attrname, char *val
static void
windows_is_local_entry_user_or_group(Slapi_Entry *e, int *is_user, int *is_group)
{
- *is_user = windows_entry_has_attr_and_value(e,"objectclass","ntuser");
- *is_group = windows_entry_has_attr_and_value(e,"objectclass","ntgroup");
+ if (is_user) {
+ *is_user = windows_entry_has_attr_and_value(e, "objectclass", "ntuser");
+ }
+ if (is_group) {
+ *is_group = windows_entry_has_attr_and_value(e, "objectclass", "ntgroup");
+ }
}
static void
@@ -1621,8 +1625,10 @@ windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op
* userAccountControl: 512
* Or, if we added a new entry, we need to change the useraccountcontrol
* to make the new user enabled by default
+ * it is assumed that is_user is set for user entries and that only user entries need
+ * accountcontrol values
*/
- if ((return_value == CONN_OPERATION_SUCCESS) && remote_dn && (password || missing_entry)) {
+ if ((return_value == CONN_OPERATION_SUCCESS) && remote_dn && (password || missing_entry) && is_user) {
return_value = send_accountcontrol_modify(remote_dn, prp, missing_entry);
}
} else {
@@ -4510,6 +4516,7 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r
int can_add = winsync_plugin_call_can_add_entry_to_ad_cb(prp->agmt, e, remote_dn);
/* First map the entry */
local_dn = slapi_entry_get_sdn_const(e);
+ int is_user;
if (missing_entry) {
if (can_add) {
retval = windows_create_remote_entry(prp, e, remote_dn, &mapped_entry, &password);
@@ -4540,7 +4547,9 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r
ldap_mods_free(entryattrs, 1);
entryattrs = NULL;
- if (retval == 0) { /* set the account control bits */
+ windows_is_local_entry_user_or_group(e, &is_user, NULL);
+ if ((retval == 0) && is_user) {
+ /* set the account control bits only for users */
retval = send_accountcontrol_modify(remote_dn, prp, missing_entry);
}
}
13 years
lib/libdsa
by Nathan Kinder
lib/libdsa/dsalib_util.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
New commits:
commit 9047b26a1633f3ca7b049add8e16a8e44d7ad579
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Thu Apr 28 08:28:32 2011 -0700
Bug 700532 - (cov#10832) Incorrect if condition in dsalib
The dsalib code has an incorrect if condition in ds_get_file_list().
It looks like the condition at line 114/115 should be checking if the
realloc failed so we can avoid filling in ret if we were unable to
allocate memory.
diff --git a/lib/libdsa/dsalib_util.c b/lib/libdsa/dsalib_util.c
index 23f2bac..15eb512 100644
--- a/lib/libdsa/dsalib_util.c
+++ b/lib/libdsa/dsalib_util.c
@@ -112,9 +112,10 @@ ds_get_file_list( char *dir )
if ( strcmp( direntp->d_name, "." ) &&
strcmp( direntp->d_name, ".." )) {
if (( ret = (char **) realloc( ret,
- sizeof( char * ) * ( nfiles + 2 ))) == NULL );
- ret[ nfiles ] = strdup( direntp->d_name );
- nfiles++;
+ sizeof( char * ) * ( nfiles + 2 ))) != NULL ) {
+ ret[ nfiles ] = strdup( direntp->d_name );
+ nfiles++;
+ }
}
}
(void) closedir( dirp );
13 years
Branch '389-ds-base-1.2.8' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/tools/ldclt/ldapfct.c | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 96c7f675e1bcdacf98386ee17a5be5192b7a045d
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Apr 28 09:31:23 2011 -0700
Bug 700215 - ldclt core dumps
https://bugzilla.redhat.com/show_bug.cgi?id=700215
Description: A helper function createMissingNodes is supposed to
set LDAP handle 'cnx' if NULL cnx is passed to the function,
but it was missing. This patch sets it.
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index efd64ed..317628c 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -2024,6 +2024,7 @@ createMissingNodes (
}
PR_smprintf_free(ldapurl);
ldapurl = NULL;
+ cnx = tttctx->ldapCtx;
#else /* !USE_OPENLDAP */
/*
* SSL is enabled ?
13 years
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/tools/ldclt/ldapfct.c | 1 +
1 file changed, 1 insertion(+)
New commits:
commit ff7be176694a715b736eac5855012b8819afd378
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Apr 28 09:31:23 2011 -0700
Bug 700215 - ldclt core dumps
https://bugzilla.redhat.com/show_bug.cgi?id=700215
Description: A helper function createMissingNodes is supposed to
set LDAP handle 'cnx' if NULL cnx is passed to the function,
but it was missing. This patch sets it.
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index efd64ed..317628c 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -2024,6 +2024,7 @@ createMissingNodes (
}
PR_smprintf_free(ldapurl);
ldapurl = NULL;
+ cnx = tttctx->ldapCtx;
#else /* !USE_OPENLDAP */
/*
* SSL is enabled ?
13 years