Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/dna/dna.c | 45 ++++++++++-------------------------------
1 file changed, 11 insertions(+), 34 deletions(-)
New commits:
commit 8bd3a0db0eee06130575bded6938480cc6509dc0
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Mar 20 18:25:41 2013 -0700
Ticket #634 - Deadlock in DNA plug-in
Bug description: Fix for Ticket #576 -
DNA: use event queue for config update only at the start up
(commit 7c11ed17796ba8b17afa5758fcfdf1c937b54ef4)
modified the timing of updating the shared config in the
database. The write operation was no need to be in the DNA
write lock, but it was located in it, which caused the dead-
lock.
Fix description: This patch releases the dna write lock before
updating the shared config in the database.
https://fedorahosted.org/389/ticket/634
Reviewed by Nathan (Thank you!!)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 080e357..d3dfa52 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -666,6 +666,7 @@ dna_load_plugin_config(int use_eventq)
if (LDAP_SUCCESS != result) {
status = DNA_FAILURE;
+ dna_unlock();
goto cleanup;
}
@@ -673,6 +674,7 @@ dna_load_plugin_config(int use_eventq)
&entries);
if (NULL == entries || NULL == entries[0]) {
status = DNA_SUCCESS;
+ dna_unlock();
goto cleanup;
}
@@ -682,6 +684,7 @@ dna_load_plugin_config(int use_eventq)
* looking for valid ones. */
dna_parse_config_entry(entries[i], 1);
}
+ dna_unlock();
if (use_eventq) {
/* Setup an event to update the shared config 30
@@ -692,14 +695,13 @@ dna_load_plugin_config(int use_eventq)
time(&now);
slapi_eq_once(dna_update_config_event, NULL, now + 30);
} else {
- int nolock = 1; /* no need to lock since dna write lock is held. */
- dna_update_config_event(0, &nolock);
+ int arg = 0; /* not used. */
+ dna_update_config_event(0, &arg);
}
cleanup:
slapi_free_search_results_internal(search_pb);
slapi_pblock_destroy(search_pb);
- dna_unlock();
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"<-- dna_load_plugin_config\n");
@@ -1247,15 +1249,8 @@ dna_update_config_event(time_t event_time, void *arg)
Slapi_PBlock *pb = NULL;
struct configEntry *config_entry = NULL;
PRCList *list = NULL;
- int nolock = 0;
- if (arg) {
- nolock = *(int *)arg;
- }
- if (!nolock) {
- /* Get read lock to prevent config changes */
- dna_read_lock();
- }
+ dna_read_lock();
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
@@ -1300,9 +1295,7 @@ dna_update_config_event(time_t event_time, void *arg)
}
bail:
- if (!nolock) {
- dna_unlock();
- }
+ dna_unlock();
slapi_pblock_destroy(pb);
}
@@ -2785,7 +2778,6 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
char **generated_types = NULL;
PRUint64 setval = 0;
int i;
- int issharedconfig = 0;
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
@@ -2803,12 +2795,7 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
* We also check if we need to get the next range of values, and grab them.
* We do this here so we don't have to do it in the be_txn_preop.
*/
- /* Has write lock for config entries. */
- issharedconfig = slapi_entry_attr_hasvalue(e, SLAPI_ATTR_OBJECTCLASS,
- DNA_SHAREDCONFIG);
- if (!issharedconfig) {
- dna_read_lock();
- }
+ dna_read_lock();
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
list = PR_LIST_HEAD(dna_global_config);
@@ -2966,9 +2953,7 @@ next:
}
}
- if (!issharedconfig) {
- dna_unlock();
- }
+ dna_unlock();
slapi_ch_array_free(generated_types);
bail:
@@ -3427,7 +3412,6 @@ static int dna_be_txn_pre_op(Slapi_PBlock *pb, int modtype)
char *type = NULL;
int numvals, e_numvals = 0;
int i, len, ret = 0;
- int issharedconfig = 0;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_be_txn_pre_op\n");
@@ -3463,12 +3447,7 @@ static int dna_be_txn_pre_op(Slapi_PBlock *pb, int modtype)
slapi_mods_init_passin(smods, mods);
}
- /* Has write lock for config entries. */
- issharedconfig = slapi_entry_attr_hasvalue(e, SLAPI_ATTR_OBJECTCLASS,
- DNA_SHAREDCONFIG);
- if (!issharedconfig) {
- dna_read_lock();
- }
+ dna_read_lock();
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
list = PR_LIST_HEAD(dna_global_config);
@@ -3659,9 +3638,7 @@ next:
list = PR_NEXT_LINK(list);
}
}
- if (!issharedconfig) {
- dna_unlock();
- }
+ dna_unlock();
bail:
if (LDAP_CHANGETYPE_MODIFY == modtype) {
11 years, 1 month
Branch '389-ds-base-1.3.0' - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/dna/dna.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
New commits:
commit f865988cf5900a4fc447e94ab05338da6c0329d2
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Mar 20 18:20:44 2013 -0700
Ticket #634 - Deadlock in DNA plug-in
Ticket #576 - DNA: use event queue for config update only at the start up
Bug description: DNA config updates were always put into the
event queue and executed in 30 seconds, which increased a chance
to conflict with the ordinary modify operations and cause db
deadlocks.
Fix description: The 30 seconds delay is necessary at the start-
up time when MMR is configured to guarantee the shared config is
logged in the changelog. This patch leaves the behaviour of the
config update at the start-up as it is; the rest won't be queued
but updated immediately.
Note: This patch combines the fix for #576 and #645 in the master.
https://fedorahosted.org/389/ticket/634
Reviewed by Nathan (Thank you!!)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 9bf5c64..b8e51e8 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -93,6 +93,7 @@
#define DNA_SHARED_CFG_DN "dnaSharedCfgDN"
/* Shared Config */
+#define DNA_SHAREDCONFIG "dnaSharedConfig"
#define DNA_REMAINING "dnaRemainingValues"
#define DNA_THRESHOLD "dnaThreshold"
#define DNA_HOSTNAME "dnaHostname"
@@ -219,7 +220,7 @@ static int dna_be_txn_preop_init(Slapi_PBlock *pb);
* Local operation functions
*
*/
-static int dna_load_plugin_config();
+static int dna_load_plugin_config(int use_eventq);
static int dna_parse_config_entry(Slapi_Entry * e, int apply);
static void dna_delete_config();
static void dna_free_config_entry(struct configEntry ** entry);
@@ -571,7 +572,7 @@ dna_start(Slapi_PBlock * pb)
slapi_ch_calloc(1, sizeof(struct configEntry));
PR_INIT_CLIST(dna_global_config);
- if (dna_load_plugin_config() != DNA_SUCCESS) {
+ if (dna_load_plugin_config(1/* use eventq */) != DNA_SUCCESS) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_start: unable to load plug-in configuration\n");
return DNA_FAILURE;
@@ -639,7 +640,7 @@ done:
* ------ cn=etc etc
*/
static int
-dna_load_plugin_config()
+dna_load_plugin_config(int use_eventq)
{
int status = DNA_SUCCESS;
int result;
@@ -649,7 +650,8 @@ dna_load_plugin_config()
Slapi_Entry **entries = NULL;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
- "--> dna_load_plugin_config\n");
+ "--> dna_load_plugin_config %s\n",
+ use_eventq?"using event queue":"");
dna_write_lock();
dna_delete_config();
@@ -664,6 +666,7 @@ dna_load_plugin_config()
if (LDAP_SUCCESS != result) {
status = DNA_FAILURE;
+ dna_unlock();
goto cleanup;
}
@@ -671,6 +674,7 @@ dna_load_plugin_config()
&entries);
if (NULL == entries || NULL == entries[0]) {
status = DNA_SUCCESS;
+ dna_unlock();
goto cleanup;
}
@@ -680,19 +684,24 @@ dna_load_plugin_config()
* looking for valid ones. */
dna_parse_config_entry(entries[i], 1);
}
+ dna_unlock();
- /* Setup an event to update the shared config 30
- * seconds from now. We need to do this since
- * performing the operation at this point when
- * starting up would cause the change to not
- * get changelogged. */
- time(&now);
- slapi_eq_once(dna_update_config_event, NULL, now + 30);
+ if (use_eventq) {
+ /* Setup an event to update the shared config 30
+ * seconds from now. We need to do this since
+ * performing the operation at this point when
+ * starting up would cause the change to not
+ * get changelogged. */
+ time(&now);
+ slapi_eq_once(dna_update_config_event, NULL, now + 30);
+ } else {
+ int arg = 1; /* not used. */
+ dna_update_config_event(0, &arg);
+ }
cleanup:
slapi_free_search_results_internal(search_pb);
slapi_pblock_destroy(search_pb);
- dna_unlock();
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"<-- dna_load_plugin_config\n");
@@ -3669,7 +3678,7 @@ static int dna_config_check_post_op(Slapi_PBlock * pb)
if (!slapi_op_internal(pb)) { /* If internal, no need to check. */
if ((dn = dna_get_dn(pb))) {
if (dna_dn_is_config(dn)) {
- dna_load_plugin_config();
+ dna_load_plugin_config(0);
}
}
}
11 years, 1 month
2 commits - ldap/servers
by Noriko Hosoi
ldap/servers/plugins/dna/dna.c | 45 +++------------
ldap/servers/slapd/attrsyntax.c | 116 +++++++++++++++++++++++++++++-----------
ldap/servers/slapd/proto-slap.h | 3 +
ldap/servers/slapd/schema.c | 48 +++++++++-------
4 files changed, 128 insertions(+), 84 deletions(-)
New commits:
commit 81b997480956b2b6fa3a5d0e8d6abf5113a06400
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Mar 25 14:37:18 2013 -0700
Ticket #627 - ns-slapd crashes sporadically with segmentation fault in libslapd.so
Bug Description: Schema reload task (schema-reload.pl) was not
thread safe.
Fix Description: Attribute Syntax is stored in the hash and
retrieved based upon the attribute syntax. When Schema reload
task is invoked, the attribute syntax objects were completely
replaced ignoring the lock protection. This patch protects
the attribute syntax replacement (attr_syntax_delete_all_for_
schemareload) with the write lock. Also, attribute syntax
object maintains the reference count. The schema reload
respects the reference count instead of blindly deleting them.
https://fedorahosted.org/389/ticket/627
Reviewed by Rich (Thank you!!)
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
index 227369c..4326f03 100644
--- a/ldap/servers/slapd/attrsyntax.c
+++ b/ldap/servers/slapd/attrsyntax.c
@@ -97,12 +97,27 @@ attr_syntax_read_lock(void)
}
void
+attr_syntax_write_lock(void)
+{
+ if (0 != attr_syntax_init()) return;
+
+ AS_LOCK_WRITE(oid2asi_lock);
+ AS_LOCK_WRITE(name2asi_lock);
+}
+
+void
attr_syntax_unlock_read(void)
{
- if(name2asi_lock) AS_UNLOCK_READ(name2asi_lock);
- if(oid2asi_lock) AS_UNLOCK_READ(oid2asi_lock);
+ AS_UNLOCK_READ(name2asi_lock);
+ AS_UNLOCK_READ(oid2asi_lock);
}
+void
+attr_syntax_unlock_write(void)
+{
+ AS_UNLOCK_WRITE(name2asi_lock);
+ AS_UNLOCK_WRITE(oid2asi_lock);
+}
#if 0
@@ -233,13 +248,17 @@ attr_syntax_get_by_oid_locking_optional( const char *oid, PRBool use_lock )
struct asyntaxinfo *asi = 0;
if (oid2asi)
{
- if ( use_lock ) AS_LOCK_READ(oid2asi_lock);
+ if ( use_lock ) {
+ AS_LOCK_READ(oid2asi_lock);
+ }
asi = (struct asyntaxinfo *)PL_HashTableLookup_const(oid2asi, oid);
if (asi)
{
PR_AtomicIncrement( &asi->asi_refcnt );
}
- if ( use_lock ) AS_UNLOCK_READ(oid2asi_lock);
+ if ( use_lock ) {
+ AS_UNLOCK_READ(oid2asi_lock);
+ }
}
return asi;
@@ -257,13 +276,15 @@ attr_syntax_add_by_oid(const char *oid, struct asyntaxinfo *a, int lock)
{
if (0 != attr_syntax_init()) return;
- if (lock)
+ if (lock) {
AS_LOCK_WRITE(oid2asi_lock);
+ }
PL_HashTableAdd(oid2asi, oid, a);
- if (lock)
+ if (lock) {
AS_UNLOCK_WRITE(oid2asi_lock);
+ }
}
/*
@@ -304,12 +325,16 @@ attr_syntax_get_by_name_locking_optional(const char *name, PRBool use_lock)
struct asyntaxinfo *asi = 0;
if (name2asi)
{
- if ( use_lock ) AS_LOCK_READ(name2asi_lock);
+ if ( use_lock ) {
+ AS_LOCK_READ(name2asi_lock);
+ }
asi = (struct asyntaxinfo *)PL_HashTableLookup_const(name2asi, name);
if ( NULL != asi ) {
PR_AtomicIncrement( &asi->asi_refcnt );
}
- if ( use_lock ) AS_UNLOCK_READ(name2asi_lock);
+ if ( use_lock ) {
+ AS_UNLOCK_READ(name2asi_lock);
+ }
}
if (!asi) /* given name may be an OID */
asi = attr_syntax_get_by_oid_locking_optional(name, use_lock);
@@ -331,30 +356,38 @@ attr_syntax_return( struct asyntaxinfo *asi )
}
void
-attr_syntax_return_locking_optional( struct asyntaxinfo *asi, PRBool use_lock )
+attr_syntax_return_locking_optional(struct asyntaxinfo *asi, PRBool use_lock)
{
+ int locked = 0;
+ if(use_lock) {
+ AS_LOCK_READ(name2asi_lock);
+ locked = 1;
+ }
if ( NULL != asi ) {
- if ( 0 == PR_AtomicDecrement( &asi->asi_refcnt ))
- {
- PRBool delete_it;
-
- if(use_lock) AS_LOCK_READ(name2asi_lock);
+ PRBool delete_it = PR_FALSE;
+ if ( 0 == PR_AtomicDecrement( &asi->asi_refcnt )) {
delete_it = asi->asi_marked_for_delete;
- if(use_lock) AS_UNLOCK_READ(name2asi_lock);
-
- if ( delete_it )
- {
- AS_LOCK_WRITE(name2asi_lock); /* get a write lock */
- if ( asi->asi_marked_for_delete ) /* one final check */
- {
- /* ref count is 0 and it's flagged for
- * deletion, so it's safe to free now */
- attr_syntax_free(asi);
+ }
+
+ if (delete_it) {
+ if ( asi->asi_marked_for_delete ) { /* one final check */
+ if(use_lock) {
+ AS_UNLOCK_READ(name2asi_lock);
+ AS_LOCK_WRITE(name2asi_lock);
+ }
+ /* ref count is 0 and it's flagged for
+ * deletion, so it's safe to free now */
+ attr_syntax_free(asi);
+ if(use_lock) {
+ AS_UNLOCK_WRITE(name2asi_lock);
+ locked = 0;
}
- AS_UNLOCK_WRITE(name2asi_lock);
}
}
}
+ if(locked) {
+ AS_UNLOCK_READ(name2asi_lock);
+ }
}
/*
@@ -371,8 +404,9 @@ attr_syntax_add_by_name(struct asyntaxinfo *a, int lock)
{
if (0 != attr_syntax_init()) return;
- if (lock)
+ if (lock) {
AS_LOCK_WRITE(name2asi_lock);
+ }
PL_HashTableAdd(name2asi, a->asi_name, a);
if ( a->asi_aliases != NULL ) {
@@ -383,8 +417,9 @@ attr_syntax_add_by_name(struct asyntaxinfo *a, int lock)
}
}
- if (lock)
+ if (lock) {
AS_UNLOCK_WRITE(name2asi_lock);
+ }
}
@@ -990,11 +1025,11 @@ attr_syntax_enumerate_attrs(AttrEnumFunc aef, void *arg, PRBool writelock )
attr_syntax_enumerate_attrs_ext(oid2asi, aef, arg);
if ( writelock ) {
- AS_UNLOCK_WRITE(oid2asi_lock);
AS_UNLOCK_WRITE(name2asi_lock);
+ AS_UNLOCK_WRITE(oid2asi_lock);
} else {
- AS_UNLOCK_READ(oid2asi_lock);
AS_UNLOCK_READ(name2asi_lock);
+ AS_UNLOCK_READ(oid2asi_lock);
}
}
@@ -1092,6 +1127,21 @@ attr_syntax_delete_all()
(void *)&fi, PR_TRUE );
}
+/*
+ * Delete all attribute definitions without attr_syntax lock.
+ * The caller is responsible for the lock.
+ */
+void
+attr_syntax_delete_all_for_schemareload(unsigned long flag)
+{
+ struct attr_syntax_enum_flaginfo fi;
+
+ memset(&fi, 0, sizeof(fi));
+ fi.asef_flag = flag;
+ attr_syntax_enumerate_attrs_ext(oid2asi, attr_syntax_delete_if_not_flagged,
+ (void *)&fi);
+}
+
static int
attr_syntax_init(void)
{
@@ -1215,13 +1265,19 @@ static int
attr_syntax_internal_asi_add(struct asyntaxinfo *asip, void *arg)
{
struct asyntaxinfo *asip_copy;
+ int rc = 0;
+
if (!asip) {
return 1;
}
/* Copy is needed since when reloading the schema,
* existing syntax info is cleaned up. */
asip_copy = attr_syntax_dup(asip);
- return attr_syntax_add(asip_copy);
+ rc = attr_syntax_add(asip_copy);
+ if (LDAP_SUCCESS != rc) {
+ attr_syntax_free(asip_copy);
+ }
+ return rc;
}
/* Reload internal attribute syntax stashed in the internalasi hashtable. */
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 4077daa..a34136f 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -114,7 +114,9 @@ int attrlist_replace_with_flags(Slapi_Attr **alist, const char *type, struct ber
* attrsyntax.c
*/
void attr_syntax_read_lock(void);
+void attr_syntax_write_lock(void);
void attr_syntax_unlock_read(void);
+void attr_syntax_unlock_write(void);
int attr_syntax_exists (const char *attr_name);
void attr_syntax_delete ( struct asyntaxinfo *asip );
#define SLAPI_SYNTAXLENGTH_NONE (-1) /* for syntaxlength parameter */
@@ -142,6 +144,7 @@ struct asyntaxinfo *attr_syntax_get_by_name_locking_optional ( const char *name,
void attr_syntax_return( struct asyntaxinfo *asi );
void attr_syntax_return_locking_optional( struct asyntaxinfo *asi, PRBool use_lock );
void attr_syntax_delete_all(void);
+void attr_syntax_delete_all_for_schemareload(unsigned long flag);
/*
* value.c
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 5eb6520..dc56534 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -1393,7 +1393,7 @@ slapi_schema_list_attribute_names(unsigned long flag)
aew.flag=flag;
attr_syntax_enumerate_attrs(schema_list_attributes_callback, &aew,
- PR_FALSE);
+ PR_FALSE);
return aew.attrs;
}
@@ -2405,8 +2405,9 @@ static int
schema_replace_attributes ( Slapi_PBlock *pb, LDAPMod *mod, char *errorbuf,
size_t errorbufsize )
{
- int i, rc = LDAP_SUCCESS;
- struct asyntaxinfo *newasip, *oldasip;
+ int i, rc = LDAP_SUCCESS;
+ struct asyntaxinfo *newasip, *oldasip;
+ PRUint32 schema_flags = 0;
if ( NULL == mod->mod_bvalues ) {
schema_create_errormsg( errorbuf, errorbufsize, schema_errprefix_at,
@@ -2414,8 +2415,11 @@ schema_replace_attributes ( Slapi_PBlock *pb, LDAPMod *mod, char *errorbuf,
return LDAP_UNWILLING_TO_PERFORM;
}
- /* clear all of the "keep" flags */
- attr_syntax_all_clear_flag( SLAPI_ATTR_FLAG_KEEP );
+ slapi_pblock_get(pb, SLAPI_SCHEMA_FLAGS, &schema_flags);
+ if (!(schema_flags & (DSE_SCHEMA_NO_LOAD|DSE_SCHEMA_NO_CHECK))) {
+ /* clear all of the "keep" flags unless it's from schema-reload */
+ attr_syntax_all_clear_flag( SLAPI_ATTR_FLAG_KEEP );
+ }
for ( i = 0; mod->mod_bvalues[i] != NULL; ++i ) {
if ( LDAP_SUCCESS != ( rc = read_at_ldif( mod->mod_bvalues[i]->bv_val,
@@ -2473,12 +2477,14 @@ schema_replace_attributes ( Slapi_PBlock *pb, LDAPMod *mod, char *errorbuf,
* XXXmcs: we should consider reporting an error if any read only types
* remain....
*/
- attr_syntax_delete_all_not_flagged( SLAPI_ATTR_FLAG_KEEP
- | SLAPI_ATTR_FLAG_STD_ATTR );
+ attr_syntax_delete_all_not_flagged( SLAPI_ATTR_FLAG_KEEP |
+ SLAPI_ATTR_FLAG_STD_ATTR );
clean_up_and_return:
- /* clear all of the "keep" flags */
- attr_syntax_all_clear_flag( SLAPI_ATTR_FLAG_KEEP );
+ if (!(schema_flags & (DSE_SCHEMA_NO_LOAD|DSE_SCHEMA_NO_CHECK))) {
+ /* clear all of the "keep" flags unless it's from schema-reload */
+ attr_syntax_all_clear_flag( SLAPI_ATTR_FLAG_KEEP );
+ }
return rc;
}
@@ -3894,14 +3900,12 @@ load_schema_dse(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *ignored,
int primary_file = 0; /* this is the primary (writeable) schema file */
int schema_ds4x_compat = config_get_ds4_compatible_schema();
PRUint32 flags = *(PRUint32 *)arg;
- flags |= DSE_SCHEMA_NO_GLOCK; /* don't lock global resources
- during initialization */
*returncode = 0;
/*
* Note: there is no need to call schema_lock_write() here because this
- * function is only called during server startup.
+ * function is only called during server startup.
*/
slapi_pblock_get( pb, SLAPI_DSE_IS_PRIMARY_FILE, &primary_file );
@@ -3943,6 +3947,8 @@ load_schema_dse(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *ignored,
if (*returncode)
return SLAPI_DSE_CALLBACK_ERROR;
+ flags |= DSE_SCHEMA_NO_GLOCK; /* don't lock global resources
+ during initialization */
if (!slapi_entry_attr_find(e, "objectclasses", &attr) && attr)
{
/* enumerate the values in attr */
@@ -4013,7 +4019,6 @@ load_schema_dse(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *ignored,
* DSE_SCHEMA_NO_CHECK -- schema won't be checked
* DSE_SCHEMA_NO_BACKEND -- don't add as backend
* DSE_SCHEMA_LOCKED -- already locked; no further lock needed
-
*/
static int
init_schema_dse_ext(char *schemadir, Slapi_Backend *be,
@@ -4119,7 +4124,7 @@ init_schema_dse_ext(char *schemadir, Slapi_Backend *be,
"DESC 'Standard schema for LDAP' SYNTAX "
"1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'RFC 2252' )",
NULL, errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- DSE_SCHEMA_NO_GLOCK|schema_flags, 0, 0, 0);
+ schema_flags, 0, 0, 0);
}
if (rc)
{
@@ -4192,7 +4197,7 @@ init_schema_dse(const char *configdir)
{
schemadir = slapi_ch_smprintf("%s/%s", configdir, SCHEMA_SUBDIR_NAME);
}
- rc = init_schema_dse_ext(schemadir, NULL, &pschemadse, 0);
+ rc = init_schema_dse_ext(schemadir, NULL, &pschemadse, DSE_SCHEMA_NO_GLOCK);
slapi_ch_free_string(&schemadir);
return rc;
}
@@ -4856,14 +4861,14 @@ slapi_validate_schema_files(char *schemadir)
{
struct dse *my_pschemadse = NULL;
int rc = init_schema_dse_ext(schemadir, NULL, &my_pschemadse,
- DSE_SCHEMA_NO_LOAD | DSE_SCHEMA_NO_BACKEND);
+ DSE_SCHEMA_NO_LOAD | DSE_SCHEMA_NO_BACKEND);
dse_destroy(my_pschemadse); /* my_pschemadse was created just to
- validate the schema */
+ validate the schema */
if (rc) {
return LDAP_SUCCESS;
} else {
slapi_log_error( SLAPI_LOG_FATAL, "schema_reload",
- "schema file validation failed\n" );
+ "schema file validation failed\n" );
return LDAP_OBJECT_CLASS_VIOLATION;
}
}
@@ -4889,10 +4894,13 @@ slapi_reload_schema_files(char *schemadir)
}
slapi_be_Wlock(be); /* be lock must be outer of schemafile lock */
reload_schemafile_lock();
- attr_syntax_delete_all();
+ /* Exclude attr_syntax not to grab from the hash table while cleaning up */
+ attr_syntax_write_lock();
+ attr_syntax_delete_all_for_schemareload(SLAPI_ATTR_FLAG_KEEP);
oc_delete_all_nolock();
+ attr_syntax_unlock_write();
rc = init_schema_dse_ext(schemadir, be, &my_pschemadse,
- DSE_SCHEMA_NO_CHECK | DSE_SCHEMA_LOCKED);
+ DSE_SCHEMA_NO_CHECK | DSE_SCHEMA_LOCKED);
if (rc) {
dse_destroy(pschemadse);
pschemadse = my_pschemadse;
commit 712c59690a9caf120a631da1fb8c886efd422229
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Mar 21 11:18:07 2013 -0700
Ticket #634 - Deadlock in DNA plug-in
Bug description: Fix for Ticket #576 -
DNA: use event queue for config update only at the start up
(commit 7c11ed17796ba8b17afa5758fcfdf1c937b54ef4)
modified the timing of updating the shared config in the
database. The write operation was no need to be in the DNA
write lock, but it was located in it, which caused the dead-
lock.
Fix description: This patch releases the dna write lock before
updating the shared config in the database.
https://fedorahosted.org/389/ticket/634
Reviewed by Nathan (Thanks!!)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 080e357..affdadf 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -666,6 +666,7 @@ dna_load_plugin_config(int use_eventq)
if (LDAP_SUCCESS != result) {
status = DNA_FAILURE;
+ dna_unlock();
goto cleanup;
}
@@ -673,6 +674,7 @@ dna_load_plugin_config(int use_eventq)
&entries);
if (NULL == entries || NULL == entries[0]) {
status = DNA_SUCCESS;
+ dna_unlock();
goto cleanup;
}
@@ -682,6 +684,7 @@ dna_load_plugin_config(int use_eventq)
* looking for valid ones. */
dna_parse_config_entry(entries[i], 1);
}
+ dna_unlock();
if (use_eventq) {
/* Setup an event to update the shared config 30
@@ -692,14 +695,12 @@ dna_load_plugin_config(int use_eventq)
time(&now);
slapi_eq_once(dna_update_config_event, NULL, now + 30);
} else {
- int nolock = 1; /* no need to lock since dna write lock is held. */
- dna_update_config_event(0, &nolock);
+ dna_update_config_event(0, NULL);
}
cleanup:
slapi_free_search_results_internal(search_pb);
slapi_pblock_destroy(search_pb);
- dna_unlock();
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"<-- dna_load_plugin_config\n");
@@ -1247,15 +1248,9 @@ dna_update_config_event(time_t event_time, void *arg)
Slapi_PBlock *pb = NULL;
struct configEntry *config_entry = NULL;
PRCList *list = NULL;
- int nolock = 0;
- if (arg) {
- nolock = *(int *)arg;
- }
- if (!nolock) {
- /* Get read lock to prevent config changes */
- dna_read_lock();
- }
+ /* 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) {
@@ -1300,9 +1295,7 @@ dna_update_config_event(time_t event_time, void *arg)
}
bail:
- if (!nolock) {
- dna_unlock();
- }
+ dna_unlock();
slapi_pblock_destroy(pb);
}
@@ -2785,7 +2778,6 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
char **generated_types = NULL;
PRUint64 setval = 0;
int i;
- int issharedconfig = 0;
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
@@ -2803,12 +2795,7 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
* We also check if we need to get the next range of values, and grab them.
* We do this here so we don't have to do it in the be_txn_preop.
*/
- /* Has write lock for config entries. */
- issharedconfig = slapi_entry_attr_hasvalue(e, SLAPI_ATTR_OBJECTCLASS,
- DNA_SHAREDCONFIG);
- if (!issharedconfig) {
- dna_read_lock();
- }
+ dna_read_lock();
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
list = PR_LIST_HEAD(dna_global_config);
@@ -2966,9 +2953,7 @@ next:
}
}
- if (!issharedconfig) {
- dna_unlock();
- }
+ dna_unlock();
slapi_ch_array_free(generated_types);
bail:
@@ -3427,7 +3412,6 @@ static int dna_be_txn_pre_op(Slapi_PBlock *pb, int modtype)
char *type = NULL;
int numvals, e_numvals = 0;
int i, len, ret = 0;
- int issharedconfig = 0;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_be_txn_pre_op\n");
@@ -3463,12 +3447,7 @@ static int dna_be_txn_pre_op(Slapi_PBlock *pb, int modtype)
slapi_mods_init_passin(smods, mods);
}
- /* Has write lock for config entries. */
- issharedconfig = slapi_entry_attr_hasvalue(e, SLAPI_ATTR_OBJECTCLASS,
- DNA_SHAREDCONFIG);
- if (!issharedconfig) {
- dna_read_lock();
- }
+ dna_read_lock();
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
list = PR_LIST_HEAD(dna_global_config);
@@ -3659,9 +3638,7 @@ next:
list = PR_NEXT_LINK(list);
}
}
- if (!issharedconfig) {
- dna_unlock();
- }
+ dna_unlock();
bail:
if (LDAP_CHANGETYPE_MODIFY == modtype) {
11 years, 1 month
ldap/servers
by Richard Allen Megginson
ldap/servers/slapd/connection.c | 36 +++++++++++++++++-------------------
ldap/servers/slapd/daemon.c | 6 ------
ldap/servers/slapd/libglobs.c | 5 +++++
3 files changed, 22 insertions(+), 25 deletions(-)
New commits:
commit 37f338cec1e84292cf2e5a0db23f36180ff27ef9
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Mar 19 16:43:44 2013 -0600
Ticket #633 - allow nsslapd-nagle to be disabled, and also tcp cork
https://fedorahosted.org/389/ticket/633
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Instead of hard-coded enable_nagle = 1 in the connection
code, use the server config nsslapd-nagle setting. The default is on
on linux. Also make the tcp cork in connection_dispatch_operation() depend
on the nagle setting - if nagle is enabled, then enable tcp cork, otherwise,
disable tcp cork too.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: Yes - document new config parameter
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 26ac20b..31fc543 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -499,7 +499,10 @@ connection_dispatch_operation(Connection *conn, Operation *op, Slapi_PBlock *pb)
{
int minssf = config_get_minssf();
int minssf_exclude_rootdse = 0;
-
+#ifdef TCP_CORK
+ int enable_nagle = config_get_nagle();
+ int pop_cork = 0;
+#endif
/* Get the effective key length now since the first SSL handshake should be complete */
connection_set_ssl_ssf( conn );
@@ -600,38 +603,33 @@ connection_dispatch_operation(Connection *conn, Operation *op, Slapi_PBlock *pb)
case LDAP_REQ_SEARCH:
operation_set_type(op,SLAPI_OPERATION_SEARCH);
-
- /* On Linux we can use TCP_CORK to get us 5-10% speed benefit when one entry is returned */
- /* Nagle needs to be turned _off_, the default is off on linux, in daemon.c */
-#if defined(LINUX)
- {
- int i = 1;
- int ret = 0;
- /* Set TCP_CORK here but only if this is not LDAPI */
- if(!conn->c_unix_local)
+ /* On Linux we can use TCP_CORK to get us 5-10% speed benefit when one entry is returned */
+ /* Nagle needs to be turned _on_, the default is _on_ on linux, in daemon.c */
+#ifdef TCP_CORK
+ if (enable_nagle && !conn->c_unix_local)
{
- ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
+ int i = 1;
+ int ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
if (ret < 0) {
LDAPDebug(LDAP_DEBUG_ANY, "Failed to set TCP_CORK on connection %" NSPRIu64 "\n",conn->c_connid, 0, 0);
}
+ pop_cork = 1;
}
#endif
-
do_search( pb );
-#if defined(LINUX)
- /* Clear TCP_CORK to flush any unsent data but only if not LDAPI*/
- i = 0;
- if(!conn->c_unix_local)
- {
- ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
+#ifdef TCP_CORK
+ if (pop_cork) {
+ /* Clear TCP_CORK to flush any unsent data but only if not LDAPI*/
+ int i = 0;
+ int ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
if (ret < 0) {
LDAPDebug(LDAP_DEBUG_ANY, "Failed to clear TCP_CORK on connection %" NSPRIu64 "\n",conn->c_connid, 0, 0);
}
}
- }
#endif
+
break;
/* for some strange reason, the console is using this old obsolete
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index abf7611..fa19312 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -3478,11 +3478,6 @@ int configure_pr_socket( PRFileDesc **pr_socket, int secure, int local )
PRSocketOptionData pr_socketoption;
-#if defined(LINUX)
- /* On Linux we use TCP_CORK so we must enable nagle */
- enable_nagle = 1;
-#endif
-
ns = PR_FileDesc2NativeHandle( *pr_socket );
#if !defined(_WIN32)
@@ -3561,7 +3556,6 @@ int configure_pr_socket( PRFileDesc **pr_socket, int secure, int local )
} /* else (secure) */
-
if ( !enable_nagle && !local ) {
pr_socketoption.option = PR_SockOpt_NoDelay;
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index fbbb4f9..9780b2e 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1343,7 +1343,12 @@ FrontendConfig_init () {
#endif /* _WIN32 */
init_accesscontrol = cfg->accesscontrol = LDAP_ON;
+#if defined(LINUX)
+ /* On Linux, by default, we use TCP_CORK so we must enable nagle */
+ init_nagle = cfg->nagle = LDAP_ON;
+#else
init_nagle = cfg->nagle = LDAP_OFF;
+#endif
init_security = cfg->security = LDAP_OFF;
init_ssl_check_hostname = cfg->ssl_check_hostname = LDAP_ON;
init_return_exact_case = cfg->return_exact_case = LDAP_ON;
11 years, 1 month
ldap/servers
by Richard Allen Megginson
ldap/servers/slapd/connection.c | 16 ++++++++++------
ldap/servers/slapd/libglobs.c | 34 +++++++++++++++++++++++++++++++++-
ldap/servers/slapd/proto-slap.h | 2 ++
ldap/servers/slapd/slap.h | 2 ++
4 files changed, 47 insertions(+), 7 deletions(-)
New commits:
commit 1c0c6b135ae8a54ef6d0ccff0eb797b9b32a66fa
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Feb 13 07:18:27 2013 -0700
Ticket #565 - turbo mode and replication - allow disable of turbo mode
https://fedorahosted.org/389/ticket/565
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Add nsslapd-enable-turbo-mode configuration attribute.
This allows the user to disable turbo mode. The default for this setting
is on.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes - document new config parameter
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 7750bfe..26ac20b 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -2253,12 +2253,16 @@ connection_threadmain()
#if defined(DB_PERF_TURBO)
/* If it's been a while since we last did it ... */
if (curtime - conn->c_private->previous_count_check_time > CONN_TURBO_CHECK_INTERVAL) {
- int new_turbo_flag = 0;
- /* Check the connection's activity level */
- connection_check_activity_level(conn);
- /* And if appropriate, change into or out of turbo mode */
- connection_enter_leave_turbo(conn,thread_turbo_flag,&new_turbo_flag);
- thread_turbo_flag = new_turbo_flag;
+ if (config_get_enable_turbo_mode()) {
+ int new_turbo_flag = 0;
+ /* Check the connection's activity level */
+ connection_check_activity_level(conn);
+ /* And if appropriate, change into or out of turbo mode */
+ connection_enter_leave_turbo(conn,thread_turbo_flag,&new_turbo_flag);
+ thread_turbo_flag = new_turbo_flag;
+ } else {
+ thread_turbo_flag = 0;
+ }
}
/* turn off turbo mode immediately if any pb waiting in global queue */
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index b7bc999..fbbb4f9 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -256,6 +256,7 @@ 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;
+slapi_onoff_t init_enable_turbo_mode;
#ifdef MEMPOOL_EXPERIMENTAL
slapi_onoff_t init_mempool_switch;
#endif
@@ -1043,7 +1044,11 @@ static struct config_get_and_set {
{CONFIG_SEARCH_RETURN_ORIGINAL_TYPE, config_set_return_orig_type_switch,
NULL, 0,
(void**)&global_slapdFrontendConfig.return_orig_type,
- CONFIG_ON_OFF, (ConfigGetFunc)config_get_return_orig_type_switch, &init_return_orig_type}
+ CONFIG_ON_OFF, (ConfigGetFunc)config_get_return_orig_type_switch, &init_return_orig_type},
+ {CONFIG_ENABLE_TURBO_MODE, config_set_enable_turbo_mode,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.enable_turbo_mode,
+ CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_turbo_mode, &init_enable_turbo_mode}
#ifdef MEMPOOL_EXPERIMENTAL
,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
NULL, 0,
@@ -1478,6 +1483,7 @@ FrontendConfig_init () {
cfg->sasl_max_bufsize = SLAPD_DEFAULT_SASL_MAXBUFSIZE;
cfg->unhashed_pw_switch = SLAPD_UNHASHED_PW_ON;
init_return_orig_type = cfg->return_orig_type = LDAP_OFF;
+ init_enable_turbo_mode = cfg->enable_turbo_mode = LDAP_ON;
#ifdef MEMPOOL_EXPERIMENTAL
init_mempool_switch = cfg->mempool_switch = LDAP_ON;
@@ -6886,6 +6892,19 @@ config_set_unhashed_pw_switch(const char *attrname, char *value,
}
CFG_UNLOCK_WRITE(slapdFrontendConfig);
+
+ return retVal;
+}
+
+int
+config_get_enable_turbo_mode(void)
+{
+ int retVal;
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
+ retVal = (int)slapdFrontendConfig->enable_turbo_mode;
+ CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
+
return retVal;
}
@@ -6907,6 +6926,19 @@ config_get_unhashed_pw_switch()
return retVal;
}
+int
+config_set_enable_turbo_mode( const char *attrname, char *value,
+ char *errorbuf, int apply )
+{
+ int retVal = LDAP_SUCCESS;
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ retVal = config_set_onoff(attrname, value,
+ &(slapdFrontendConfig->enable_turbo_mode),
+ errorbuf, apply);
+ return retVal;
+}
+
/*
* This function is intended to be used from the dse code modify callback. It
* is "optimized" for that case because it takes a berval** of values, which is
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 53d3569..4077daa 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -567,6 +567,8 @@ int config_set_sasl_mapping_fallback(const char *attrname, char *value, char *er
int config_get_sasl_mapping_fallback();
int config_get_unhashed_pw_switch();
int config_get_sasl_maxbufsize();
+int config_get_enable_turbo_mode();
+int config_set_enable_turbo_mode(const char *attrname, char *value, char *errorbuf, int apply);
PLHashNumber hashNocaseString(const void *key);
PRIntn hashNocaseCompare(const void *v1, const void *v2);
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index a19e192..c8381da 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2075,6 +2075,7 @@ typedef struct _slapdEntryPoints {
#define CONFIG_SASL_MAPPING_FALLBACK "nsslapd-sasl-mapping-fallback"
#define CONFIG_SASL_MAXBUFSIZE "nsslapd-sasl-max-buffer-size"
#define CONFIG_SEARCH_RETURN_ORIGINAL_TYPE "nsslapd-search-return-original-type-switch"
+#define CONFIG_ENABLE_TURBO_MODE "nsslapd-enable-turbo-mode"
#ifdef MEMPOOL_EXPERIMENTAL
#define CONFIG_MEMPOOL_SWITCH_ATTRIBUTE "nsslapd-mempool"
@@ -2317,6 +2318,7 @@ typedef struct _slapdFrontendConfig {
Slapi_Counter *ignore_vattrs;
Slapi_Counter *sasl_mapping_fallback;
slapi_onoff_t unhashed_pw_switch; /* switch to on/off/nolog unhashed pw */
+ slapi_onoff_t enable_turbo_mode;
} slapdFrontendConfig_t;
/* possible values for slapdFrontendConfig_t.schemareplace */
11 years, 1 month
man/man8
by Richard Allen Megginson
man/man8/restart-slapd.8 | 48 -----------------------------------------------
man/man8/start-slapd.8 | 48 -----------------------------------------------
man/man8/stop-slapd.8 | 48 -----------------------------------------------
3 files changed, 144 deletions(-)
New commits:
commit 68a0c3cd9b761276631ecf3b00df52e032a7998b
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Mar 25 09:28:36 2013 -0600
Ticket #47302 - get rid of sbindir start/stop/restart slapd scripts
https://fedorahosted.org/389/ticket/47302
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: get rid of man pages too
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/man/man8/restart-slapd.8 b/man/man8/restart-slapd.8
deleted file mode 100644
index 03e210b..0000000
--- a/man/man8/restart-slapd.8
+++ /dev/null
@@ -1,48 +0,0 @@
-.\" Hey, EMACS: -*- nroff -*-
-.\" First parameter, NAME, should be all caps
-.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
-.\" other parameters are allowed: see man(7), man(1)
-.TH RESTART-SLAPD 8 "Mar 5, 2013"
-.\" Please adjust this date whenever revising the manpage.
-.\"
-.\" Some roff macros, for reference:
-.\" .nh disable hyphenation
-.\" .hy enable hyphenation
-.\" .ad l left justify
-.\" .ad b justify to both left and right margins
-.\" .nf disable filling
-.\" .fi enable filling
-.\" .br insert line break
-.\" .sp <n> insert n+1 empty lines
-.\" for manpage-specific macros, see man(7)
-.SH NAME
-restart-slapd - Directory Server script for restarting a server instance
-.SH SYNOPSIS
-restart-slapd [ -Z serverID ] [-h]
-.SH DESCRIPTION
-Restarts a Directory Server instance.
-.SH OPTIONS
-A summary of options is included below:
-.TP
-.B \fB\-Z\fR \fIServer Identifier\fR
-The server ID of the Directory Server instance. If there is only
-one instance on the system, this option can be skipped.
-.TP
-.B \fB\-h\fR
-.br
-Display the usage.
-.SH EXAMPLE
-.TP
-restart-slapd
-.TP
-restart-slapd -Z instance2
-.SH DIAGNOSTICS
-Exit status is zero if no errors occur. Errors result in a
-non-zero exit status and a diagnostic message being written
-to standard error.
-.SH AUTHOR
-restart-slapd was written by the 389 Project.
-.SH "REPORTING BUGS"
-Report bugs to http://bugzilla.redhat.com.
-.SH COPYRIGHT
-Copyright \(co 2013 Red Hat, Inc.
diff --git a/man/man8/start-slapd.8 b/man/man8/start-slapd.8
deleted file mode 100644
index c780112..0000000
--- a/man/man8/start-slapd.8
+++ /dev/null
@@ -1,48 +0,0 @@
-.\" Hey, EMACS: -*- nroff -*-
-.\" First parameter, NAME, should be all caps
-.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
-.\" other parameters are allowed: see man(7), man(1)
-.TH START-SLAPD 8 "Mar 5, 2013"
-.\" Please adjust this date whenever revising the manpage.
-.\"
-.\" Some roff macros, for reference:
-.\" .nh disable hyphenation
-.\" .hy enable hyphenation
-.\" .ad l left justify
-.\" .ad b justify to both left and right margins
-.\" .nf disable filling
-.\" .fi enable filling
-.\" .br insert line break
-.\" .sp <n> insert n+1 empty lines
-.\" for manpage-specific macros, see man(7)
-.SH NAME
-start-slapd - Directory Server script for starting a server instance
-.SH SYNOPSIS
-start-slapd [ -Z serverID ] [-h]
-.SH DESCRIPTION
-Starts a Directory Server instance.
-.SH OPTIONS
-A summary of options is included below:
-.TP
-.B \fB\-Z\fR \fIServer Identifier\fR
-The server ID of the Directory Server instance. If there is only
-one instance on the system, this option can be skipped.
-.TP
-.B \fB\-h\fR
-.br
-Display the usage.
-.SH EXAMPLE
-.TP
-start-slapd
-.TP
-start-slapd -Z instance2
-.SH DIAGNOSTICS
-Exit status is zero if no errors occur. Errors result in a
-non-zero exit status and a diagnostic message being written
-to standard error.
-.SH AUTHOR
-start-slapd was written by the 389 Project.
-.SH "REPORTING BUGS"
-Report bugs to http://bugzilla.redhat.com.
-.SH COPYRIGHT
-Copyright \(co 2013 Red Hat, Inc.
diff --git a/man/man8/stop-slapd.8 b/man/man8/stop-slapd.8
deleted file mode 100644
index 4eacef5..0000000
--- a/man/man8/stop-slapd.8
+++ /dev/null
@@ -1,48 +0,0 @@
-.\" Hey, EMACS: -*- nroff -*-
-.\" First parameter, NAME, should be all caps
-.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
-.\" other parameters are allowed: see man(7), man(1)
-.TH STOP-SLAPD 8 "Mar 5, 2013"
-.\" Please adjust this date whenever revising the manpage.
-.\"
-.\" Some roff macros, for reference:
-.\" .nh disable hyphenation
-.\" .hy enable hyphenation
-.\" .ad l left justify
-.\" .ad b justify to both left and right margins
-.\" .nf disable filling
-.\" .fi enable filling
-.\" .br insert line break
-.\" .sp <n> insert n+1 empty lines
-.\" for manpage-specific macros, see man(7)
-.SH NAME
-stop-slapd - Directory Server script for stopping a server instance
-.SH SYNOPSIS
-stop-slapd [ -Z serverID ] [-h]
-.SH DESCRIPTION
-Stops a Directory Server instance.
-.SH OPTIONS
-A summary of options is included below:
-.TP
-.B \fB\-Z\fR \fIServer Identifier\fR
-The server ID of the Directory Server instance. If there is only
-one instance on the system, this option can be skipped.
-.TP
-.B \fB\-h\fR
-.br
-Display the usage.
-.SH EXAMPLE
-.TP
-stop-slapd
-.TP
-stop-slapd -Z instance3
-.SH DIAGNOSTICS
-Exit status is zero if no errors occur. Errors result in a
-non-zero exit status and a diagnostic message being written
-to standard error.
-.SH AUTHOR
-stop-slapd was written by the 389 Project.
-.SH "REPORTING BUGS"
-Report bugs to http://bugzilla.redhat.com.
-.SH COPYRIGHT
-Copyright \(co 2013 Red Hat, Inc.
11 years, 1 month
3 commits - ldap/admin Makefile.am Makefile.in
by Richard Allen Megginson
Makefile.am | 9 ----
Makefile.in | 11 +----
ldap/admin/src/scripts/DSSharedLib.in | 39 ++++++++++++++---
ldap/admin/src/scripts/DSUtil.pm.in | 22 ++++++----
ldap/admin/src/scripts/restart-dirsrv.in | 17 ++++++-
ldap/admin/src/scripts/restart-slapd.in | 50 -----------------------
ldap/admin/src/scripts/start-dirsrv.in | 17 ++++++-
ldap/admin/src/scripts/start-slapd.in | 50 -----------------------
ldap/admin/src/scripts/stop-dirsrv.in | 17 ++++++-
ldap/admin/src/scripts/stop-slapd.in | 50 -----------------------
ldap/admin/src/scripts/template-restart-slapd.in | 6 --
ldap/admin/src/scripts/template-start-slapd.in | 7 +--
ldap/admin/src/scripts/template-stop-slapd.in | 6 --
13 files changed, 101 insertions(+), 200 deletions(-)
New commits:
commit a10e433c29a4ce3944efade9bb8d404af1577f85
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Mar 21 13:25:43 2013 -0600
Ticket #47303 - start/stop/restart dirsrv scripts should report and error if no instances
https://fedorahosted.org/389/ticket/47303
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: start/stop/restart dirsrv should report and error if no instances
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
index c5825b9..d782124 100644
--- a/ldap/admin/src/scripts/restart-dirsrv.in
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
@@ -54,6 +54,10 @@ if [ "$#" -eq 0 ]; then
# We're restarting all instances.
ret=0
for i in $initconfig_dir/@package_name@-*; do
+ if [ ! -f "$i" ] ; then
+ echo No instances found in $initconfig_dir
+ exit 1
+ fi
regex=s,$initconfig_dir/@package_name@-,,g
inst=`echo $i | sed -e $regex`
# check for admin server ID used by 389-admin pkg, and ignore it
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
index 7864ad9..2173b67 100755
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -132,6 +132,10 @@ if [ "$#" -eq 0 ]; then
# We're starting all instances.
ret=0
for i in $initconfig_dir/@package_name@-*; do
+ if [ ! -f "$i" ] ; then
+ echo No instances found in $initconfig_dir
+ exit 1
+ fi
regex=s,$initconfig_dir/@package_name@-,,g
inst=`echo $i | sed -e $regex`
# check for admin server ID used by 389-admin pkg, and ignore it
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
index cec65d9..708c277 100755
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -84,6 +84,10 @@ if [ "$#" -eq 0 ]; then
# We're stopping all instances.
ret=0
for i in $initconfig_dir/@package_name@-*; do
+ if [ ! -f "$i" ] ; then
+ echo No instances found in $initconfig_dir
+ exit 1
+ fi
regex=s,$initconfig_dir/@package_name@-,,g
inst=`echo $i | sed -e $regex`
# check for admin server ID used by 389-admin pkg, and ignore it
commit e75704b99a046e71fc0e54fcb0e42540b54058d8
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Mar 21 12:04:45 2013 -0600
Ticket #47302 - get rid of sbindir start/stop/restart slapd scripts
https://fedorahosted.org/389/ticket/47302
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description:
do not need sbindir -slapd scripts since we already had -dirsrv scripts -
start-dirsrv etc. - that already take an instance argument, although not
with -Z
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: Yes, if we have already documented sbindir start-slapd etc.
diff --git a/Makefile.am b/Makefile.am
index f25af58..6bff8e4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -122,9 +122,8 @@ CLEANFILES = dberrstrs.h ns-slapd.properties \
ldap/admin/src/scripts/db2index ldap/admin/src/scripts/db2ldif \
ldap/admin/src/scripts/dn2rdn ldap/admin/src/scripts/ldif2db \
ldap/admin/src/scripts/ldif2ldap ldap/admin/src/scripts/monitor \
- ldap/admin/src/scripts/restart-slapd ldap/admin/src/scripts/restoreconfig \
- ldap/admin/src/scripts/saveconfig ldap/admin/src/scripts/start-slapd \
- ldap/admin/src/scripts/stop-slapd ldap/admin/src/scripts/suffix2instance \
+ ldap/admin/src/scripts/restoreconfig ldap/admin/src/scripts/saveconfig \
+ ldap/admin/src/scripts/suffix2instance \
ldap/admin/src/scripts/upgradednformat ldap/admin/src/scripts/vlvindex \
ldap/admin/src/scripts/bak2db.pl ldap/admin/src/scripts/db2bak.pl \
ldap/admin/src/scripts/db2index.pl ldap/admin/src/scripts/db2ldif.pl \
@@ -345,11 +344,8 @@ sbin_SCRIPTS = ldap/admin/src/scripts/setup-ds.pl \
ldap/admin/src/scripts/ldif2db \
ldap/admin/src/scripts/ldif2ldap \
ldap/admin/src/scripts/monitor \
- ldap/admin/src/scripts/restart-slapd \
ldap/admin/src/scripts/restoreconfig \
ldap/admin/src/scripts/saveconfig \
- ldap/admin/src/scripts/start-slapd \
- ldap/admin/src/scripts/stop-slapd \
ldap/admin/src/scripts/suffix2instance \
ldap/admin/src/scripts/upgradednformat \
ldap/admin/src/scripts/vlvindex \
@@ -510,7 +506,6 @@ dist_man_MANS = man/man1/dbscan.1 \
man/man8/dbverify.8 man/man8/verify-db.pl.8 \
man/man8/dn2rdn.8 man/man8/ldif2ldap.8 \
man/man8/restoreconfig.8 man/man8/saveconfig.8 \
- man/man8/start-slapd.8 man/man8/stop-slapd.8 man/man8/restart-slapd.8 \
man/man8/suffix2instance.8 man/man8/monitor.8 \
man/man8/upgradednformat.8 man/man8/vlvindex.8 \
man/man8/cleanallruv.pl.8 man/man8/schema-reload.pl.8 \
diff --git a/Makefile.in b/Makefile.in
index c53b822..73c337a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1412,9 +1412,8 @@ CLEANFILES = dberrstrs.h ns-slapd.properties \
ldap/admin/src/scripts/db2index ldap/admin/src/scripts/db2ldif \
ldap/admin/src/scripts/dn2rdn ldap/admin/src/scripts/ldif2db \
ldap/admin/src/scripts/ldif2ldap ldap/admin/src/scripts/monitor \
- ldap/admin/src/scripts/restart-slapd ldap/admin/src/scripts/restoreconfig \
- ldap/admin/src/scripts/saveconfig ldap/admin/src/scripts/start-slapd \
- ldap/admin/src/scripts/stop-slapd ldap/admin/src/scripts/suffix2instance \
+ ldap/admin/src/scripts/restoreconfig ldap/admin/src/scripts/saveconfig \
+ ldap/admin/src/scripts/suffix2instance \
ldap/admin/src/scripts/upgradednformat ldap/admin/src/scripts/vlvindex \
ldap/admin/src/scripts/bak2db.pl ldap/admin/src/scripts/db2bak.pl \
ldap/admin/src/scripts/db2index.pl ldap/admin/src/scripts/db2ldif.pl \
@@ -1573,11 +1572,8 @@ sbin_SCRIPTS = ldap/admin/src/scripts/setup-ds.pl \
ldap/admin/src/scripts/ldif2db \
ldap/admin/src/scripts/ldif2ldap \
ldap/admin/src/scripts/monitor \
- ldap/admin/src/scripts/restart-slapd \
ldap/admin/src/scripts/restoreconfig \
ldap/admin/src/scripts/saveconfig \
- ldap/admin/src/scripts/start-slapd \
- ldap/admin/src/scripts/stop-slapd \
ldap/admin/src/scripts/suffix2instance \
ldap/admin/src/scripts/upgradednformat \
ldap/admin/src/scripts/vlvindex \
@@ -1735,7 +1731,6 @@ dist_man_MANS = man/man1/dbscan.1 \
man/man8/dbverify.8 man/man8/verify-db.pl.8 \
man/man8/dn2rdn.8 man/man8/ldif2ldap.8 \
man/man8/restoreconfig.8 man/man8/saveconfig.8 \
- man/man8/start-slapd.8 man/man8/stop-slapd.8 man/man8/restart-slapd.8 \
man/man8/suffix2instance.8 man/man8/monitor.8 \
man/man8/upgradednformat.8 man/man8/vlvindex.8 \
man/man8/cleanallruv.pl.8 man/man8/schema-reload.pl.8 \
@@ -10497,7 +10492,7 @@ distcheck: dist
*.zip*) \
unzip $(distdir).zip ;;\
esac
- chmod -R a-w $(distdir); chmod a+w $(distdir)
+ chmod -R a-w $(distdir); chmod u+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
diff --git a/ldap/admin/src/scripts/restart-slapd.in b/ldap/admin/src/scripts/restart-slapd.in
deleted file mode 100644
index 8a64e59..0000000
--- a/ldap/admin/src/scripts/restart-slapd.in
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-
-source @datadir@/dirsrv/data/DSSharedLib
-
-# Script that restarts the ns-slapd server.
-# Exit status can be:
-# 0: Server restarted successfully
-# 1: Server could not be started
-# 2: Server started successfully (was not running)
-# 3: Server could not be stopped
-
-usage ()
-{
- echo "Usage: restart-slapd [-Z serverID]"
-}
-
-while getopts "Z:SvVhi:d:w:" flag
-do
- case $flag in
- Z) servid=$OPTARG;;
- d) args=$args" -d $OPTARG";;
- v) args=$args" -v";;
- V) args=$args" -V";;
- i) args=$args" -i $OPTARG";;
- w) args=$args" -w $OPTARG";;
- S) args=$args" -S";;
- h) usage
- exit 0;;
- ?) usage
- exit 1;;
- esac
-done
-
-servid=$(get_server_id "@initconfigdir@" $servid)
-if [ $? == 1 ]
-then
- usage
- echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
- echo "Available instances: $servid"
- exit 1
-fi
-
-@sbindir@/restart-dirsrv -d @initconfigdir@ $servid $args
-if [ $? == 0 ]
-then
- echo Sucessfully restarted instance \"$servid\"
-else
- echo Failed to restart instance \"$servid\"
-fi
-exit $?
diff --git a/ldap/admin/src/scripts/start-slapd.in b/ldap/admin/src/scripts/start-slapd.in
deleted file mode 100755
index f24aae7..0000000
--- a/ldap/admin/src/scripts/start-slapd.in
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-
-source @datadir@/dirsrv/data/DSSharedLib
-
-# Script that starts the ns-slapd server.
-# Exit status can be:
-# 0: Server started successfully
-# 1: Server could not be started
-# 2: Server already running
-
-usage ()
-{
- echo "Usage: start-slapd [-Z serverID]"
-}
-
-while getopts "Z:SvVhi:d:w:" flag
-do
- case $flag in
- Z) servid=$OPTARG;;
- d) args=$args" -d $OPTARG";;
- v) args=$args" -v";;
- V) args=$args" -V";;
- i) args=$args" -i $OPTARG";;
- w) args=$args" -w $OPTARG";;
- S) args=$args" -S";;
- h) usage
- exit 0;;
- ?) usage
- exit 1;;
- esac
-done
-
-servid=$(get_server_id "@initconfigdir@" $servid)
-if [ $? == 1 ]
-then
- usage
- echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
- echo "Available instances: $servid"
- exit 1
-fi
-
-@sbindir@/start-dirsrv -d @initconfigdir@ $servid $args
-if [ $? == 0 ]
-then
- echo Sucessfully started instance \"$servid\"
-else
- echo Failed to start instance \"$servid\"
-fi
-
-exit $?
diff --git a/ldap/admin/src/scripts/stop-slapd.in b/ldap/admin/src/scripts/stop-slapd.in
deleted file mode 100755
index 94d9858..0000000
--- a/ldap/admin/src/scripts/stop-slapd.in
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-
-source @datadir@/dirsrv/data/DSSharedLib
-
-# Script that stops the ns-slapd server.
-# Exit status can be:
-# 0: Server stopped successfully
-# 1: Server could not be stopped
-# 2: Server was not running
-
-usage ()
-{
- echo "Usage: stop-slapd [-Z serverID]"
-}
-
-while getopts "Z:SvVhi:d:w:" flag
-do
- case $flag in
- Z) servid=$OPTARG;;
- d) args=$args" -d $OPTARG";;
- v) args=$args" -v";;
- V) args=$args" -V";;
- i) args=$args" -i $OPTARG";;
- w) args=$args" -w $OPTARG";;
- S) args=$args" -S";;
- h) usage
- exit 0;;
- ?) usage
- exit 1;;
- esac
-done
-
-servid=$(get_server_id "@initconfigdir@" $servid)
-if [ $? == 1 ]
-then
- usage
- echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
- echo "Available instances: $servid"
- exit 1
-fi
-
-@sbindir@/stop-dirsrv -d @initconfigdir@ $servid $args
-if [ $? == 0 ]
-then
- echo Sucessfully stopped instance \"$servid\"
-else
- echo Failed to stop instance \"$servid\"
-fi
-
-exit $?
diff --git a/ldap/admin/src/scripts/template-restart-slapd.in b/ldap/admin/src/scripts/template-restart-slapd.in
index d169432..7933806 100644
--- a/ldap/admin/src/scripts/template-restart-slapd.in
+++ b/ldap/admin/src/scripts/template-restart-slapd.in
@@ -1,5 +1,3 @@
#!/bin/sh
-
-cd {{SERVERBIN-DIR}}
-./restart-slapd "$@" -Z {{SERV-ID}}
-exit $?
\ No newline at end of file
+# DEPRECATED - use @sbindir@/restart-dirsrv instead
+exec @sbindir@/restart-dirsrv -d {{INITCONFIG-DIR}} {{SERV-ID}} "$@"
diff --git a/ldap/admin/src/scripts/template-start-slapd.in b/ldap/admin/src/scripts/template-start-slapd.in
index c5a9ca9..be59404 100755
--- a/ldap/admin/src/scripts/template-start-slapd.in
+++ b/ldap/admin/src/scripts/template-start-slapd.in
@@ -1,5 +1,4 @@
#!/bin/sh
-
-cd {{SERVERBIN-DIR}}
-./start-slapd "$@" -Z {{SERV-ID}}
-exit $?
+# DEPRECATED - use @sbindir@/start-dirsrv instead
+INSTANCE={{SERV-ID}}
+exec @sbindir@/start-dirsrv -d {{INITCONFIG-DIR}} $INSTANCE "$@"
diff --git a/ldap/admin/src/scripts/template-stop-slapd.in b/ldap/admin/src/scripts/template-stop-slapd.in
index 7e1820a..3bf358d 100755
--- a/ldap/admin/src/scripts/template-stop-slapd.in
+++ b/ldap/admin/src/scripts/template-stop-slapd.in
@@ -1,5 +1,3 @@
#!/bin/sh
-
-cd {{SERVERBIN-DIR}}
-./stop-slapd "$@" -Z {{SERV-ID}}
-exit $?
+# DEPRECATED - use @sbindir@/stop-dirsrv instead
+exec @sbindir@/stop-dirsrv -d {{INITCONFIG-DIR}} {{SERV-ID}} "$@"
commit 7f7f83cbf68f4ce88c00ad203889272812accd0e
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Mar 21 10:20:19 2013 -0600
Ticket #47299 - allow cmdline scripts to work with non-root user
https://fedorahosted.org/389/ticket/47299
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: If running as non-root, look for the initconfig scripts/files
in ~/.dirsrv. If the INITCONFIGDIR env. var. is set, use that and do not
look anywhere else. Cannot depend on the value of $USER - must use id to
determine the effective user id. Also fixed a problem with return value
handling - the if test changes the value of $?, so have to save the value
just after starting the instance.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/admin/src/scripts/DSSharedLib.in b/ldap/admin/src/scripts/DSSharedLib.in
index 17079d7..1a66e28 100644
--- a/ldap/admin/src/scripts/DSSharedLib.in
+++ b/ldap/admin/src/scripts/DSSharedLib.in
@@ -20,13 +20,38 @@ get_server_id()
inst_count=0
instances="<none>"
rc=0
-
- for i in `ls $dir/dirsrv-* 2>/dev/null`
+
+ # convert
+ # uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),.....
+ # to
+ # 0
+ # this is the only portable, secure way to determine the id number
+ userid=`id | awk -F'[=(]+' '{print $2}'`
+ if [ "$userid" -ne 0 ] ; then
+ # magic - see start-dirsrv, DSCreate.pm::get_initconfigdir, etc.
+ dir=$HOME/.@package_name@
+ fi
+ if [ -n "$INITCONFIGDIR" ] ; then
+ dir=$INITCONFIGDIR
+ fi
+
+ # look first in user provided INITCONFIGDIR, then in the system/build location,
+ # then in the users home dir - cases
+ # 1. system install but running as non-root user
+ # in this case, we want to use the instance from $dir - it will
+ # fallback to $homedir in that case, and if that is a problem, the user will
+ # just have to temporarily move $homedir/dirsrv-sysinstancename out of the way
+ # while working on the system instance
+ # 2. prefix/non-system install
+ # in this case, we want to use $homedir - if for some reason there is a system
+ # instance in $dir with the same name, the user can use INITCONFIGDIR to
+ # override that and force the use of the one from $homedir
+ for i in `ls $dir/@package_name@-* 2>/dev/null`
do
- if [ $i != "$dir/dirsrv-admin" ]
+ if [ $i != "$dir/@package_name@-admin" ]
then
inst_count=`expr $inst_count + 1`
- id=$(expr "$i" : ".*dirsrv-\([^)]*\).*")
+ id=$(expr "$i" : ".*@package_name(a)-\([^)]*\).*")
if [ $first == "yes" ]
then
instances=$id
@@ -52,11 +77,11 @@ get_server_id()
elif [ $servid == slapd-* ]
then
servid=`echo "$servid" | sed -e 's/slapd-//'`
- elif [ $servid == dirsrv-* ]
+ elif [ $servid == @package_name@-* ]
then
- servid=`echo "$servid" | sed -e 's/dirsrv-//'`
+ servid=`echo "$servid" | sed -e 's/@package_name@-//'`
fi
- if ! [ -a "$dir/dirsrv-$servid" ]
+ if ! [ -a "$dir/@package_name@-$servid" ]
then
# invalid instance name, return the "valid" instance names
servid=$instances
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index e587671..b69cbb5 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -1287,13 +1287,21 @@ sub get_server_id {
my $instances = "<none>";
my $name;
my $file;
+
+ if (getLogin ne 'root') {
+ $dir = "$ENV{HOME}/.@package_name@";
+ }
+
+ if (defined $ENV{INITCONFIGDIR}) {
+ $dir = $ENV{INITCONFIGDIR};
+ }
opendir(DIR, "$dir");
my @files = readdir(DIR);
foreach $file (@files){
- if($file =~ /^dirsrv-/ && $file ne "dirsrv-admin"){
+ if($file =~ /^@package_name@-/ && $file ne "@package_name@-admin"){
$instance_count++;
- if($file =~ /dirsrv-(.*)/){
+ if($file =~ /@package_name(a)-(.*)/){
if($first eq "yes"){
$instances=$1;
$first = "no";
@@ -1312,17 +1320,17 @@ sub get_server_id {
print "Available instances: $instances\n";
exit (1);
}
- } elsif ($servid =~ /^dirsrv-/){
- # strip off "dirsrv-"
- $servid =~ s/^dirsrv-//;
+ } elsif ($servid =~ /^@package_name@-/){
+ # strip off "@package_name@-"
+ $servid =~ s/^@package_name@-//;
} elsif ($servid =~ /^slapd-/){
# strip off "slapd-"
$servid =~ s/^slapd-//;
}
- unless ( -e "$dir/dirsrv-$servid" ){
+ unless ( -e "$dir/@package_name@-$servid" ){
print (STDERR "Invalid server identifer: $servid\n");
- print (STDERR "Available instances: $instances\n");
+ print (STDERR "Available instances in $dir: $instances\n");
exit (1);
}
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
index 74dc1cf..c5825b9 100644
--- a/ldap/admin/src/scripts/restart-dirsrv.in
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
@@ -37,7 +37,13 @@ done
shift $(($OPTIND-1))
if [ "$initconfig_dir" = "" ]; then
- if [ $USER = root ] ; then
+ # convert
+ # uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),.....
+ # to
+ # 0
+ # this is the only portable, secure way to determine the id number
+ userid=`id | awk -F'[=(]+' '{print $2}'`
+ if [ "$userid" -eq 0 ] ; then
initconfig_dir=@initconfigdir@
else
initconfig_dir=$HOME/.@package_name@
@@ -56,8 +62,9 @@ if [ "$#" -eq 0 ]; then
fi
echo Restarting instance \"$inst\"
restart_instance $inst
- if [ "$?" -ne 0 ]; then
- ret=$?
+ rv=$?
+ if [ "$rv" -ne 0 ]; then
+ ret=$rv
fi
done
exit $ret
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
index b5f45f9..7864ad9 100755
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -115,7 +115,13 @@ done
shift $(($OPTIND-1))
if [ "$initconfig_dir" = "" ]; then
- if [ $USER = root ] ; then
+ # convert
+ # uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),.....
+ # to
+ # 0
+ # this is the only portable, secure way to determine the id number
+ userid=`id | awk -F'[=(]+' '{print $2}'`
+ if [ "$userid" -eq 0 ] ; then
initconfig_dir=@initconfigdir@
else
initconfig_dir=$HOME/.@package_name@
@@ -134,8 +140,9 @@ if [ "$#" -eq 0 ]; then
fi
echo Starting instance \"$inst\"
start_instance $inst
- if [ "$?" -ne 0 ]; then
- ret=$?
+ rv=$?
+ if [ "$rv" -ne 0 ]; then
+ ret=$rv
fi
done
exit $ret
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
index 220fe92..cec65d9 100755
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -67,7 +67,13 @@ done
shift $(($OPTIND-1))
if [ "$initconfig_dir" = "" ]; then
- if [ $USER = root ] ; then
+ # convert
+ # uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),.....
+ # to
+ # 0
+ # this is the only portable, secure way to determine the id number
+ userid=`id | awk -F'[=(]+' '{print $2}'`
+ if [ "$userid" -eq 0 ] ; then
initconfig_dir=@initconfigdir@
else
initconfig_dir=$HOME/.@package_name@
@@ -86,8 +92,9 @@ if [ "$#" -eq 0 ]; then
fi
echo Stopping instance \"$inst\"
stop_instance $inst
- if [ "$?" -ne 0 ]; then
- ret=$?
+ rv=$?
+ if [ "$rv" -ne 0 ]; then
+ ret=$rv
fi
done
exit $ret
11 years, 1 month
Branch '389-ds-base-1.2.10' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/plugin_acl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit caa580edbe0a77c0e4c93c8a63dfd5b6b3a88bff
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Sep 24 11:26:49 2012 -0400
Coverity issue 13091
Bug Description: Local var array "mychange" can go out of scope
Fix Description: Declare "mychange" at the top of the function so it does not go out of scope.
Reviewed by: nkinder(Thanks!)
(cherry picked from commit d58ae20b75ccae99b2122a4a0d4fcf773a51115a)
diff --git a/ldap/servers/slapd/plugin_acl.c b/ldap/servers/slapd/plugin_acl.c
index 3bc3f21..eebc292 100644
--- a/ldap/servers/slapd/plugin_acl.c
+++ b/ldap/servers/slapd/plugin_acl.c
@@ -136,6 +136,7 @@ plugin_call_acl_mods_update ( Slapi_PBlock *pb, int optype )
struct slapdplugin *p;
int rc = 0;
void *change = NULL;
+ void *mychange[2];
Slapi_Entry *te = NULL;
Slapi_DN *sdn = NULL;
Operation *operation;
@@ -158,7 +159,6 @@ plugin_call_acl_mods_update ( Slapi_PBlock *pb, int optype )
break;
case SLAPI_OPERATION_MODRDN:
{
- void *mychange[2];
char *newrdn = NULL;
Slapi_DN *psdn = NULL;
char *pdn = NULL;
11 years, 1 month
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/plugin_acl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit f6a6514279883afb6a8f645a6c1b5c635049a930
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Sep 24 11:26:49 2012 -0400
Coverity issue 13091
Bug Description: Local var array "mychange" can go out of scope
Fix Description: Declare "mychange" at the top of the function so it does not go out of scope.
Reviewed by: nkinder(Thanks!)
(cherry picked from commit d58ae20b75ccae99b2122a4a0d4fcf773a51115a)
diff --git a/ldap/servers/slapd/plugin_acl.c b/ldap/servers/slapd/plugin_acl.c
index 3bc3f21..eebc292 100644
--- a/ldap/servers/slapd/plugin_acl.c
+++ b/ldap/servers/slapd/plugin_acl.c
@@ -136,6 +136,7 @@ plugin_call_acl_mods_update ( Slapi_PBlock *pb, int optype )
struct slapdplugin *p;
int rc = 0;
void *change = NULL;
+ void *mychange[2];
Slapi_Entry *te = NULL;
Slapi_DN *sdn = NULL;
Operation *operation;
@@ -158,7 +159,6 @@ plugin_call_acl_mods_update ( Slapi_PBlock *pb, int optype )
break;
case SLAPI_OPERATION_MODRDN:
{
- void *mychange[2];
char *newrdn = NULL;
Slapi_DN *psdn = NULL;
char *pdn = NULL;
11 years, 1 month
ldap/servers
by thierry bordaz
ldap/servers/plugins/replication/repl5_protocol.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
New commits:
commit 957bea3e270e3af820b1fe500017acde90e4356d
Author: Thierry bordaz (tbordaz) <tbordaz(a)redhat.com>
Date: Thu Mar 21 11:11:34 2013 +0100
Ticket 618 - Crash at shutdown while stopping replica agreements
Bug Description:
During shutdown, the replica agreement thread can be long to detect the shutdown.
If replica agreements fails to detect shutdown before timeout (default is 120s),
the shutdown continue and deletes replica agreement structure.
Fix Description:
The fix consist to make the main thread wait for the RA thread.
https://fedorahosted.org/389/ticket/618
Reviewed by: Rich Megginson (thanks for the review Rich)
Platforms tested: fedora 18
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/repl5_protocol.c b/ldap/servers/plugins/replication/repl5_protocol.c
index 250ce48..d9744fc 100644
--- a/ldap/servers/plugins/replication/repl5_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_protocol.c
@@ -72,6 +72,7 @@ typedef struct repl_protocol
int state;
int next_state;
PRUint64 protocol_timeout;
+ PRThread *agmt_thread;
PRLock *lock;
} repl_protocol;
@@ -366,12 +367,13 @@ prot_start(Repl_Protocol *rp)
PR_ASSERT(NULL != rp);
if (NULL != rp)
{
- if (PR_CreateThread(PR_USER_THREAD, prot_thread_main, (void *)rp,
+ rp->agmt_thread = PR_CreateThread(PR_USER_THREAD, prot_thread_main, (void *)rp,
#if defined(__hpux) && defined(__ia64)
- PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 524288L ) == NULL)
+ PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 524288L );
#else
- PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE) == NULL)
+ PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
#endif
+ if (rp->agmt_thread == NULL)
{
PRErrorCode prerr = PR_GetError();
@@ -426,6 +428,11 @@ prot_stop(Repl_Protocol *rp)
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Error: prot_stop() "
" called on NULL protocol instance.\n");
}
+
+ if (rp->agmt_thread != NULL) {
+ (void) PR_JoinThread(rp->agmt_thread);
+ rp->agmt_thread = NULL;
+ }
}
/*
11 years, 1 month