commit_id
string | repo
string | commit_message
string | diff
string | label
int64 |
---|---|---|---|---|
05587edaeca03b1c26cb087cc3f0c68856c4bc82
|
389ds/389-ds-base
|
Ticket 49742 - Fine grained password policy can impact search performance
Bug Description:
new_passwdPolicy is called with an entry DN.
In case of fine grain password policy we need to retrieve
the possible password policy (pwdpolicysubentry) that applies to
that entry.
It triggers an internal search to retrieve the entry.
In case of a search operation (add_shadow_ext_password_attrs), the
entry is already in the pblock. So it is useless to do an additional
internal search for it.
Fix Description:
in case of fine grain password policy and a SRCH operation,
if the entry DN matches the entry stored in the pblock (SLAPI_SEARCH_RESULT_ENTRY)
then use that entry instead of doing an internal search
https://pagure.io/389-ds-base/issue/49742
Reviewed by: Mark Reynolds
Platforms tested: F26
Flag Day: no
Doc impact: no
|
commit 05587edaeca03b1c26cb087cc3f0c68856c4bc82
Author: Thierry Bordaz <[email protected]>
Date: Thu Jun 7 18:35:34 2018 +0200
Ticket 49742 - Fine grained password policy can impact search performance
Bug Description:
new_passwdPolicy is called with an entry DN.
In case of fine grain password policy we need to retrieve
the possible password policy (pwdpolicysubentry) that applies to
that entry.
It triggers an internal search to retrieve the entry.
In case of a search operation (add_shadow_ext_password_attrs), the
entry is already in the pblock. So it is useless to do an additional
internal search for it.
Fix Description:
in case of fine grain password policy and a SRCH operation,
if the entry DN matches the entry stored in the pblock (SLAPI_SEARCH_RESULT_ENTRY)
then use that entry instead of doing an internal search
https://pagure.io/389-ds-base/issue/49742
Reviewed by: Mark Reynolds
Platforms tested: F26
Flag Day: no
Doc impact: no
diff --git a/dirsrvtests/tests/tickets/ticket48228_test.py b/dirsrvtests/tests/tickets/ticket48228_test.py
index 4f4494e0b..1ab741b94 100644
--- a/dirsrvtests/tests/tickets/ticket48228_test.py
+++ b/dirsrvtests/tests/tickets/ticket48228_test.py
@@ -7,6 +7,7 @@
# --- END COPYRIGHT BLOCK ---
#
import logging
+import time
import pytest
from lib389.tasks import *
@@ -33,14 +34,14 @@ def set_global_pwpolicy(topology_st, inhistory):
topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
# Enable password policy
try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-pwpolicy-local', 'on')])
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-pwpolicy-local', b'on')])
except ldap.LDAPError as e:
log.error('Failed to set pwpolicy-local: error ' + e.message['desc'])
assert False
log.info(" Set global password history on\n")
try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordHistory', 'on')])
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordHistory', b'on')])
except ldap.LDAPError as e:
log.error('Failed to set passwordHistory: error ' + e.message['desc'])
assert False
@@ -48,7 +49,7 @@ def set_global_pwpolicy(topology_st, inhistory):
log.info(" Set global passwords in history\n")
try:
count = "%d" % inhistory
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordInHistory', count)])
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordInHistory', count.encode())])
except ldap.LDAPError as e:
log.error('Failed to set passwordInHistory: error ' + e.message['desc'])
assert False
@@ -113,9 +114,9 @@ def check_passwd_inhistory(topology_st, user, cpw, passwd):
topology_st.standalone.simple_bind_s(user, cpw)
time.sleep(1)
try:
- topology_st.standalone.modify_s(user, [(ldap.MOD_REPLACE, 'userpassword', passwd)])
+ topology_st.standalone.modify_s(user, [(ldap.MOD_REPLACE, 'userpassword', passwd.encode())])
except ldap.LDAPError as e:
- log.info(' The password ' + passwd + ' of user' + USER1_DN + ' in history: error ' + e.message['desc'])
+ log.info(' The password ' + passwd + ' of user' + USER1_DN + ' in history: error {0}'.format(e))
inhistory = 1
time.sleep(1)
return inhistory
@@ -130,7 +131,7 @@ def update_passwd(topology_st, user, passwd, times):
# Now update the value for this iter.
cpw = 'password%d' % i
try:
- topology_st.standalone.modify_s(user, [(ldap.MOD_REPLACE, 'userpassword', cpw)])
+ topology_st.standalone.modify_s(user, [(ldap.MOD_REPLACE, 'userpassword', cpw.encode())])
except ldap.LDAPError as e:
log.fatal(
'test_ticket48228: Failed to update the password ' + cpw + ' of user ' + user + ': error ' + e.message[
@@ -146,7 +147,6 @@ def test_ticket48228_test_global_policy(topology_st):
"""
Check global password policy
"""
-
log.info(' Set inhistory = 6')
set_global_pwpolicy(topology_st, 6)
@@ -201,7 +201,7 @@ def test_ticket48228_test_global_policy(topology_st):
log.info("Global policy was successfully verified.")
-def test_ticket48228_test_subtree_policy(topology_st):
+def text_ticket48228_text_subtree_policy(topology_st):
"""
Check subtree level password policy
"""
@@ -233,7 +233,7 @@ def test_ticket48228_test_subtree_policy(topology_st):
log.info(' Set inhistory = 4')
topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
try:
- topology_st.standalone.modify_s(SUBTREE_PWP, [(ldap.MOD_REPLACE, 'passwordInHistory', '4')])
+ topology_st.standalone.modify_s(SUBTREE_PWP, [(ldap.MOD_REPLACE, 'passwordInHistory', b'4')])
except ldap.LDAPError as e:
log.error('Failed to set pwpolicy-local: error ' + e.message['desc'])
assert False
diff --git a/dirsrvtests/tests/tickets/ticket548_test.py b/dirsrvtests/tests/tickets/ticket548_test.py
index d354cc802..0d71ab6ca 100644
--- a/dirsrvtests/tests/tickets/ticket548_test.py
+++ b/dirsrvtests/tests/tickets/ticket548_test.py
@@ -42,7 +42,7 @@ def set_global_pwpolicy(topology_st, min_=1, max_=10, warn=3):
log.info(" +++++ Enable global password policy +++++\n")
# Enable password policy
try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-pwpolicy-local', 'on')])
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-pwpolicy-local', b'on')])
except ldap.LDAPError as e:
log.error('Failed to set pwpolicy-local: error ' + e.message['desc'])
assert False
@@ -54,28 +54,28 @@ def set_global_pwpolicy(topology_st, min_=1, max_=10, warn=3):
log.info(" Set global password Min Age -- %s day\n" % min_)
try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordMinAge', '%s' % min_secs)])
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordMinAge', ('%s' % min_secs).encode())])
except ldap.LDAPError as e:
log.error('Failed to set passwordMinAge: error ' + e.message['desc'])
assert False
log.info(" Set global password Expiration -- on\n")
try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordExp', 'on')])
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordExp', b'on')])
except ldap.LDAPError as e:
log.error('Failed to set passwordExp: error ' + e.message['desc'])
assert False
log.info(" Set global password Max Age -- %s days\n" % max_)
try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordMaxAge', '%s' % max_secs)])
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordMaxAge', ('%s' % max_secs).encode())])
except ldap.LDAPError as e:
log.error('Failed to set passwordMaxAge: error ' + e.message['desc'])
assert False
log.info(" Set global password Warning -- %s days\n" % warn)
try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordWarning', '%s' % warn_secs)])
+ topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'passwordWarning', ('%s' % warn_secs).encode())])
except ldap.LDAPError as e:
log.error('Failed to set passwordWarning: error ' + e.message['desc'])
assert False
@@ -93,6 +93,8 @@ def set_subtree_pwpolicy(topology_st, min_=2, max_=20, warn=6):
try:
topology_st.standalone.add_s(Entry((SUBTREE_CONTAINER, {'objectclass': 'top nsContainer'.split(),
'cn': 'nsPwPolicyContainer'})))
+ except ldap.ALREADY_EXISTS:
+ pass
except ldap.LDAPError as e:
log.error('Failed to add subtree container: error ' + e.message['desc'])
# assert False
@@ -128,6 +130,8 @@ def set_subtree_pwpolicy(topology_st, min_=2, max_=20, warn=6):
'cosPriority': '1',
'cn': SUBTREE_COS_TMPLDN,
'pwdpolicysubentry': SUBTREE_PWP})))
+ except ldap.ALREADY_EXISTS:
+ pass
except ldap.LDAPError as e:
log.error('Failed to add COS template: error ' + e.message['desc'])
# assert False
@@ -139,6 +143,8 @@ def set_subtree_pwpolicy(topology_st, min_=2, max_=20, warn=6):
'cn': SUBTREE_PWPDN,
'costemplatedn': SUBTREE_COS_TMPL,
'cosAttribute': 'pwdpolicysubentry default operational-default'})))
+ except ldap.ALREADY_EXISTS:
+ pass
except ldap.LDAPError as e:
log.error('Failed to add COS def: error ' + e.message['desc'])
# assert False
@@ -150,7 +156,7 @@ def update_passwd(topology_st, user, passwd, newpasswd):
log.info(" Bind as {%s,%s}" % (user, passwd))
topology_st.standalone.simple_bind_s(user, passwd)
try:
- topology_st.standalone.modify_s(user, [(ldap.MOD_REPLACE, 'userpassword', newpasswd)])
+ topology_st.standalone.modify_s(user, [(ldap.MOD_REPLACE, 'userpassword', newpasswd.encode())])
except ldap.LDAPError as e:
log.fatal('test_ticket548: Failed to update the password ' + cpw + ' of user ' + user + ': error ' + e.message[
'desc'])
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 6b5684ad5..9b5e03b48 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1644,6 +1644,10 @@ new_passwdPolicy(Slapi_PBlock *pb, const char *dn)
int attr_free_flags = 0;
int rc = 0;
int optype = -1;
+ int free_e = 1; /* reset if e is taken from pb */
+ if (pb) {
+ slapi_pblock_get(pb, SLAPI_OPERATION_TYPE, &optype);
+ }
/* If we already allocated a pw policy, return it */
if (pb != NULL) {
@@ -1707,7 +1711,43 @@ new_passwdPolicy(Slapi_PBlock *pb, const char *dn)
/* If we're not doing an add, we look for the pwdpolicysubentry
attribute in the target entry itself. */
} else {
- if ((e = get_entry(pb, dn)) != NULL) {
+ if (optype == SLAPI_OPERATION_SEARCH) {
+ Slapi_Entry *pb_e;
+
+ /* During a search the entry should be in the pblock
+ * For safety check entry DN is identical to 'dn'
+ */
+ slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY, &pb_e);
+ if (pb_e) {
+ Slapi_DN * sdn;
+ const char *ndn;
+ char *pb_ndn;
+
+ pb_ndn = slapi_entry_get_ndn(pb_e);
+
+ sdn = slapi_sdn_new_dn_byval(dn);
+ ndn = slapi_sdn_get_ndn(sdn);
+
+ if (strcasecmp(pb_ndn, ndn) == 0) {
+ /* We are using the candidate entry that is already loaded in the pblock
+ * Do not trigger an additional internal search
+ * Also we will not need to free the entry that will remain in the pblock
+ */
+ e = pb_e;
+ free_e = 0;
+ } else {
+ e = get_entry(pb, dn);
+ }
+ slapi_sdn_free(&sdn);
+ } else {
+ e = get_entry(pb, dn);
+ }
+ } else {
+ /* For others operations but SEARCH */
+ e = get_entry(pb, dn);
+ }
+
+ if (e) {
Slapi_Attr *attr = NULL;
rc = slapi_entry_attr_find(e, "pwdpolicysubentry", &attr);
if (attr && (0 == rc)) {
@@ -1737,7 +1777,9 @@ new_passwdPolicy(Slapi_PBlock *pb, const char *dn)
}
}
slapi_vattr_values_free(&values, &actual_type_name, attr_free_flags);
- slapi_entry_free(e);
+ if (free_e) {
+ slapi_entry_free(e);
+ }
if (pw_entry == NULL) {
slapi_log_err(SLAPI_LOG_ERR, "new_passwdPolicy",
@@ -1935,7 +1977,7 @@ new_passwdPolicy(Slapi_PBlock *pb, const char *dn)
slapi_pblock_set_pwdpolicy(pb, pwdpolicy);
}
return pwdpolicy;
- } else if (e) {
+ } else if (free_e) {
slapi_entry_free(e);
}
}
| 0 |
d0747eda6a155dbaa85ca667ce11a16dbdab9fba
|
389ds/389-ds-base
|
Issue 6782 - Improve paged result locking
Description:
When cleaning a slot, instead of mem setting everything to Zero and restoring
the mutex, manually reset all the values leaving the mutex pointer
intact.
There is also a deadlock possibility when checking for abandoned PR search
in opshared.c, and we were checking a flag value outside of the per_conn
lock.
Relates: https://github.com/389ds/389-ds-base/issues/6782
Reviewed by: progier & spichugi(Thanks!!)
|
commit d0747eda6a155dbaa85ca667ce11a16dbdab9fba
Author: Mark Reynolds <[email protected]>
Date: Thu May 15 10:35:27 2025 -0400
Issue 6782 - Improve paged result locking
Description:
When cleaning a slot, instead of mem setting everything to Zero and restoring
the mutex, manually reset all the values leaving the mutex pointer
intact.
There is also a deadlock possibility when checking for abandoned PR search
in opshared.c, and we were checking a flag value outside of the per_conn
lock.
Relates: https://github.com/389ds/389-ds-base/issues/6782
Reviewed by: progier & spichugi(Thanks!!)
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 5ea919e2d..545518748 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -619,6 +619,14 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
int32_t tlimit;
slapi_pblock_get(pb, SLAPI_SEARCH_TIMELIMIT, &tlimit);
pagedresults_set_timelimit(pb_conn, operation, (time_t)tlimit, pr_idx);
+ /* When using this mutex in conjunction with the main paged
+ * result lock, you must do so in this order:
+ *
+ * --> pagedresults_lock()
+ * --> pagedresults_mutex
+ * <-- pagedresults_mutex
+ * <-- pagedresults_unlock()
+ */
pagedresults_mutex = pageresult_lock_get_addr(pb_conn);
}
@@ -744,11 +752,11 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
pr_search_result = pagedresults_get_search_result(pb_conn, operation, 1 /*locked*/, pr_idx);
if (pr_search_result) {
if (pagedresults_is_abandoned_or_notavailable(pb_conn, 1 /*locked*/, pr_idx)) {
+ pthread_mutex_unlock(pagedresults_mutex);
pagedresults_unlock(pb_conn, pr_idx);
/* Previous operation was abandoned and the simplepaged object is not in use. */
send_ldap_result(pb, 0, NULL, "Simple Paged Results Search abandoned", 0, NULL);
rc = LDAP_SUCCESS;
- pthread_mutex_unlock(pagedresults_mutex);
goto free_and_return;
} else {
slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET, pr_search_result);
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index 642aefb3d..c3f3aae01 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -48,7 +48,6 @@ pageresult_lock_get_addr(Connection *conn)
static void
_pr_cleanup_one_slot(PagedResults *prp)
{
- PRLock *prmutex = NULL;
if (!prp) {
return;
}
@@ -56,13 +55,17 @@ _pr_cleanup_one_slot(PagedResults *prp)
/* sr is left; release it. */
prp->pr_current_be->be_search_results_release(&(prp->pr_search_result_set));
}
- /* clean up the slot */
- if (prp->pr_mutex) {
- /* pr_mutex is reused; back it up and reset it. */
- prmutex = prp->pr_mutex;
- }
- memset(prp, '\0', sizeof(PagedResults));
- prp->pr_mutex = prmutex;
+
+ /* clean up the slot except the mutex */
+ prp->pr_current_be = NULL;
+ prp->pr_search_result_set = NULL;
+ prp->pr_search_result_count = 0;
+ prp->pr_search_result_set_size_estimate = 0;
+ prp->pr_sort_result_code = 0;
+ prp->pr_timelimit_hr.tv_sec = 0;
+ prp->pr_timelimit_hr.tv_nsec = 0;
+ prp->pr_flags = 0;
+ prp->pr_msgid = 0;
}
/*
@@ -1007,7 +1010,8 @@ op_set_pagedresults(Operation *op)
/*
* pagedresults_lock/unlock -- introduced to protect search results for the
- * asynchronous searches.
+ * asynchronous searches. Do not call these functions while the PR conn lock
+ * is held (e.g. pageresult_lock_get_addr(conn))
*/
void
pagedresults_lock(Connection *conn, int index)
@@ -1045,6 +1049,8 @@ int
pagedresults_is_abandoned_or_notavailable(Connection *conn, int locked, int index)
{
PagedResults *prp;
+ int32_t result;
+
if (!conn || (index < 0) || (index >= conn->c_pagedresults.prl_maxlen)) {
return 1; /* not abandoned, but do not want to proceed paged results op. */
}
@@ -1052,10 +1058,11 @@ pagedresults_is_abandoned_or_notavailable(Connection *conn, int locked, int inde
pthread_mutex_lock(pageresult_lock_get_addr(conn));
}
prp = conn->c_pagedresults.prl_list + index;
+ result = prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED;
if (!locked) {
pthread_mutex_unlock(pageresult_lock_get_addr(conn));
}
- return prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED;
+ return result;
}
int
| 0 |
8eb8e5c74ae8cc64e9116545bb0d4876335e25cd
|
389ds/389-ds-base
|
Ticket 19 - Missing file and improve make
Bug Description: This fixes a missing file in the RPM specfile.
This also makes the local makefile better for docker containers.
Fix Description: Fix the renamed README line in spec, and improve
the topdir in rpmbuild
https://pagure.io/lib389/issue/19
Author: wibrown
Review by: vashirov (Thanks!)
|
commit 8eb8e5c74ae8cc64e9116545bb0d4876335e25cd
Author: William Brown <[email protected]>
Date: Thu Apr 6 15:04:03 2017 +1000
Ticket 19 - Missing file and improve make
Bug Description: This fixes a missing file in the RPM specfile.
This also makes the local makefile better for docker containers.
Fix Description: Fix the renamed README line in spec, and improve
the topdir in rpmbuild
https://pagure.io/lib389/issue/19
Author: wibrown
Review by: vashirov (Thanks!)
diff --git a/src/lib389/Makefile b/src/lib389/Makefile
index e6a577de5..5e4332c1f 100644
--- a/src/lib389/Makefile
+++ b/src/lib389/Makefile
@@ -2,6 +2,7 @@
LIB389_VERS ?= $(shell cat ./VERSION | head -n 1)
PYTHON ?= /usr/bin/python
+RPMBUILD ?= $(shell pwd)/rpmbuild
all: build
@@ -13,17 +14,16 @@ install:
rpmbuild-prep:
mkdir -p ./dist/
- mkdir -p ~/rpmbuild/SOURCES
- mkdir -p ~/rpmbuild/SPECS
+ mkdir -p $(RPMBUILD)/SOURCES
+ mkdir -p $(RPMBUILD)/SPECS
git archive --prefix=python-lib389-$(LIB389_VERS)-1/ HEAD | bzip2 > ./dist/python-lib389-$(LIB389_VERS)-1.tar.bz2
- cp ./dist/python-lib389-$(LIB389_VERS)-1.tar.bz2 ~/rpmbuild/SOURCES/
+ cp ./dist/python-lib389-$(LIB389_VERS)-1.tar.bz2 $(RPMBUILD)/SOURCES/
srpm: rpmbuild-prep
- rpmbuild -bs python-lib389.spec
- cp ~/rpmbuild/SRPMS/python-lib389*.src.rpm ./dist/
+ rpmbuild --define "_topdir $(RPMBUILD)" -bs python-lib389.spec
rpm: rpmbuild-prep
- rpmbuild -bb python-lib389.spec
+ rpmbuild --define "_topdir $(RPMBUILD)" -bb python-lib389.spec
pep8:
pep8 --max-line-length=160 ./lib389
diff --git a/src/lib389/python-lib389.spec b/src/lib389/python-lib389.spec
index 95a300b03..68394ad9a 100644
--- a/src/lib389/python-lib389.spec
+++ b/src/lib389/python-lib389.spec
@@ -93,7 +93,7 @@ and configuring the 389 Directory Server.
%files -n python2-%{srcname}
%license LICENSE
-%doc README
+%doc README.md
%{python2_sitelib}/*
%if 0%{?rhel} >= 8 || 0%{?fedora}
%exclude %{_sbindir}/*
| 0 |
c868a418a171854a4a2fd4c9eed6d45d886bf379
|
389ds/389-ds-base
|
Issue 50545 - remove dbmon "incr" option from arg parser
Description: Forgot to remove the "incr" option for dbmon from the argparse list
Relates: https://pagure.io/389-ds-base/issue/50545
Reviewed by: mreynolds (one line commit rule)
|
commit c868a418a171854a4a2fd4c9eed6d45d886bf379
Author: Mark Reynolds <[email protected]>
Date: Mon Apr 6 09:23:54 2020 -0400
Issue 50545 - remove dbmon "incr" option from arg parser
Description: Forgot to remove the "incr" option for dbmon from the argparse list
Relates: https://pagure.io/389-ds-base/issue/50545
Reviewed by: mreynolds (one line commit rule)
diff --git a/src/lib389/lib389/cli_conf/monitor.py b/src/lib389/lib389/cli_conf/monitor.py
index e136cf90c..de4231d7a 100644
--- a/src/lib389/lib389/cli_conf/monitor.py
+++ b/src/lib389/lib389/cli_conf/monitor.py
@@ -295,7 +295,6 @@ def create_parser(subparsers):
dbmon_parser = subcommands.add_parser('dbmon', help="Monitor the all the database statistics in a single report")
dbmon_parser.set_defaults(func=db_monitor)
- dbmon_parser.add_argument('-i', '--incr', type=int, help="Keep refreshing the report every N seconds")
dbmon_parser.add_argument('-b', '--backends', help="List of space separated backends to monitor. Default is all backends.")
dbmon_parser.add_argument('-x', '--indexes', action='store_true', default=False, help="Show index stats for each backend")
| 0 |
25ed4bfad2045406d34d7516fac49593f91991d7
|
389ds/389-ds-base
|
remove bogus logging fix bug#154261
|
commit 25ed4bfad2045406d34d7516fac49593f91991d7
Author: David Boreham <[email protected]>
Date: Mon Apr 18 18:14:02 2005 +0000
remove bogus logging fix bug#154261
diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c
index 583962409..8fbda9c03 100644
--- a/ldap/servers/plugins/replication/repl5_inc_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c
@@ -450,7 +450,7 @@ repl5_inc_waitfor_async_results(result_data *rd)
/* Lock the structure to force memory barrier */
PR_Lock(rd->lock);
/* Are we caught up ? */
- slapi_log_error(SLAPI_LOG_FATAL, NULL,
+ slapi_log_error(SLAPI_LOG_REPL, NULL,
"repl5_inc_waitfor_async_results: %d %d\n",
rd->last_message_id_received, rd->last_message_id_sent, 0);
if (rd->last_message_id_received >= rd->last_message_id_sent)
diff --git a/ldap/servers/plugins/replication/repl5_tot_protocol.c b/ldap/servers/plugins/replication/repl5_tot_protocol.c
index 91acba1e8..243663ef7 100644
--- a/ldap/servers/plugins/replication/repl5_tot_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_tot_protocol.c
@@ -187,7 +187,7 @@ static void repl5_tot_result_threadmain(void *param)
}
conn_get_error_ex(conn, &operation_code, &connection_error, &ldap_error_string);
- if (connection_error)
+ if (connection_error && connection_error != LDAP_TIMEOUT)
{
repl5_tot_log_operation_failure(connection_error,ldap_error_string,agmt_get_long_name(cb->prp->agmt));
}
@@ -277,8 +277,8 @@ repl5_tot_waitfor_async_results(callback_data *cb_data)
/* Lock the structure to force memory barrier */
PR_Lock(cb_data->lock);
/* Are we caught up ? */
- slapi_log_error(SLAPI_LOG_FATAL, NULL,
- "repl5_inc_waitfor_async_results: %d %d\n",
+ slapi_log_error(SLAPI_LOG_REPL, NULL,
+ "repl5_tot_waitfor_async_results: %d %d\n",
cb_data->last_message_id_received, cb_data->last_message_id_sent, 0);
if (cb_data->last_message_id_received >= cb_data->last_message_id_sent)
{
| 0 |
ac27e7bf17969358d5824ab5ff35f4e0579c4c65
|
389ds/389-ds-base
|
Issue 4731 - Promoting/demoting a replica can crash the server
Bug Description: The server will crash if you demote a
supplier with no changelog.
Fix Description: Check if the changelog pointer is NULL before
dereferencing it
relates: https://github.com/389ds/389-ds-base/issues/4731
Reviewed by: spichugi & firstyear (Thanks!!)
|
commit ac27e7bf17969358d5824ab5ff35f4e0579c4c65
Author: Mark Reynolds <[email protected]>
Date: Wed Oct 27 13:38:35 2021 -0400
Issue 4731 - Promoting/demoting a replica can crash the server
Bug Description: The server will crash if you demote a
supplier with no changelog.
Fix Description: Check if the changelog pointer is NULL before
dereferencing it
relates: https://github.com/389ds/389-ds-base/issues/4731
Reviewed by: spichugi & firstyear (Thanks!!)
diff --git a/dirsrvtests/tests/suites/replication/promote_demote_test.py b/dirsrvtests/tests/suites/replication/promote_demote_test.py
new file mode 100644
index 000000000..040fff3ba
--- /dev/null
+++ b/dirsrvtests/tests/suites/replication/promote_demote_test.py
@@ -0,0 +1,67 @@
+import logging
+import pytest
+import os
+from lib389._constants import DEFAULT_SUFFIX, ReplicaRole
+from lib389.topologies import topology_m1h1c1 as topo
+from lib389.replica import Replicas, ReplicationManager, Agreements
+
+pytestmark = pytest.mark.tier1
+
+log = logging.getLogger(__name__)
+
+def test_promote_demote(topo):
+ """Test promoting and demoting a replica
+
+ :id: 75edff64-f987-4ed5-a03d-9bee73c0fbf0
+ :setup: 2 Supplier Instances
+ :steps:
+ 1. Promote Hub to a Supplier
+ 2. Test replication works
+ 3. Demote the supplier to a consumer
+ 4. Test replication works
+ 5. Promote consumer to supplier
+ 6. Test replication works
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ """
+
+ supplier = topo.ms["supplier1"]
+ supplier_replica = Replicas(supplier).get(DEFAULT_SUFFIX)
+ bind_dn = supplier_replica.get_attr_val_utf8('nsDS5ReplicaBindDN')
+ hub = topo.hs["hub1"]
+ hub_replica = Replicas(hub).get(DEFAULT_SUFFIX)
+ consumer = topo.cs["consumer1"]
+
+ repl = ReplicationManager(DEFAULT_SUFFIX)
+
+ # promote replica
+ hub_replica.promote(ReplicaRole.SUPPLIER, binddn=bind_dn, rid='55')
+ repl.test_replication(supplier, consumer)
+
+ # Demote the replica
+ hub_replica.demote(ReplicaRole.CONSUMER)
+ repl.test_replication(supplier, hub)
+
+ # promote replica and init it
+ hub_replica.promote(ReplicaRole.SUPPLIER, binddn=bind_dn, rid='56')
+ agmt = Agreements(supplier).list()[0]
+ agmt.begin_reinit()
+ agmt.wait_reinit()
+
+ # init consumer
+ agmt = Agreements(hub).list()[0]
+ agmt.begin_reinit()
+ agmt.wait_reinit()
+ repl.test_replication(supplier, consumer)
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main(["-s", CURRENT_FILE])
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index dad946d41..7e87ef3bf 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -799,6 +799,12 @@ cl5WriteOperationTxn(cldb_Handle *cldb, const slapi_operation_parameters *op, vo
return CL5_BAD_DATA;
}
+ if (cldb == NULL) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "cl5WriteOperationTxn - changelog is not initialized\n");
+ return CL5_BAD_DATA;
+ }
+
pthread_mutex_lock(&(cldb->stLock));
if (cldb->dbState != CL5_STATE_OPEN) {
if (cldb->dbState == CL5_STATE_IMPORT) {
@@ -948,6 +954,11 @@ cl5CreateReplayIterator(Private_Repl_Protocol *prp, const RUV *consumerRuv, CL5R
*iterator = NULL;
cldb = replica_get_cl_info(replica);
+ if (cldb == NULL) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "cl5CreateReplayIterator - Changelog is not available (NULL)\n");
+ return CL5_BAD_STATE;
+ }
pthread_mutex_lock(&(cldb->stLock));
if (cldb->dbState != CL5_STATE_OPEN) {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -4403,6 +4414,10 @@ void
cl5CleanRUV(ReplicaId rid, Replica *replica)
{
cldb_Handle *cldb = replica_get_cl_info(replica);
+
+ if (cldb == NULL) {
+ return;
+ }
ruv_delete_replica(cldb->purgeRUV, rid);
ruv_delete_replica(cldb->maxRUV, rid);
}
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index 7b82727d6..fda553178 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -996,6 +996,11 @@ write_changelog_and_ruv(Slapi_PBlock *pb)
/* changelog database information to pass to the write function */
cldb = replica_get_cl_info(r);
+ if (cldb == NULL) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name_cl,
+ "write_changelog_and_ruv - changelog is not initialized\n");
+ return return_value;
+ }
/* for replicated operations, we log the original, non-urp data which is
saved in the operation extension */
diff --git a/src/lib389/lib389/replica.py b/src/lib389/lib389/replica.py
index 41acf7647..505484beb 100644
--- a/src/lib389/lib389/replica.py
+++ b/src/lib389/lib389/replica.py
@@ -1510,7 +1510,7 @@ class Replica(DSLdapObject):
:param *replica_dirsrvs: DirSrv instance, DirSrv instance, ...
:type *replica_dirsrvs: list of DirSrv
- :returns: True - if all servers have recevioed the update by this
+ :returns: True - if all servers have received the update by this
replica, otherwise return False
:raises: LDAPError - when failing to update/search database
"""
| 0 |
71be5faaa478593bb056887410ca8e48e05b2fe4
|
389ds/389-ds-base
|
Ticket #47799 - Any negative LDAP error code number reported as Illegal error by ldclt.
Description: ldclt was implemented with mozldap, which did not expect
negative erorr codes, but openldap does. E.g., LDAP_FILTER_ERROR (-7)
This patch prepares a negativeError array for the negative error codes.
Example:
$ ldclt [...] -e esearch -e random -b "<basedn>" -f "<bad filter>" -v
Filter = "<bad filter>"
...
ldclt[16030]: T000: Cannot ldap_search(), error=-7 (Bad search filter) -- NULL result
...
ldclt[16030]: Global error -7 (Bad search filter) occurs 1001 times
ldclt[16030]: Exit status 3 - Max errors reached.
https://fedorahosted.org/389/ticket/47799
Reviewed by [email protected] (Thank you, Mark!!)
|
commit 71be5faaa478593bb056887410ca8e48e05b2fe4
Author: Noriko Hosoi <[email protected]>
Date: Wed Jul 8 10:19:15 2015 -0700
Ticket #47799 - Any negative LDAP error code number reported as Illegal error by ldclt.
Description: ldclt was implemented with mozldap, which did not expect
negative erorr codes, but openldap does. E.g., LDAP_FILTER_ERROR (-7)
This patch prepares a negativeError array for the negative error codes.
Example:
$ ldclt [...] -e esearch -e random -b "<basedn>" -f "<bad filter>" -v
Filter = "<bad filter>"
...
ldclt[16030]: T000: Cannot ldap_search(), error=-7 (Bad search filter) -- NULL result
...
ldclt[16030]: Global error -7 (Bad search filter) occurs 1001 times
ldclt[16030]: Exit status 3 - Max errors reached.
https://fedorahosted.org/389/ticket/47799
Reviewed by [email protected] (Thank you, Mark!!)
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index f906c5ace..13e66b857 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -1382,6 +1382,10 @@ printErrorFromLdap (
printf ("ldclt[%d]: T%03d: %s, error=%d (%s",
mctx.pid, tttctx->thrdNum, errmsg,
errcode, my_ldap_err2string (errcode));
+ if (!res) {
+ printf (") -- NULL result\n");
+ return -1;
+ }
/*
* See if there is an additional error message...
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c b/ldap/servers/slapd/tools/ldclt/ldclt.c
index edb687fb0..9e573a5d3 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.c
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.c
@@ -716,19 +716,35 @@ printGlobalStatistics (void)
* Note: Maybe implement a way to stop the running threads ?
*/
found = 0;
- for (i=0 ; i<MAX_ERROR_NB ; i++)
- if (mctx.errors[i] > 0)
- {
+ for (i = 0; i < MAX_ERROR_NB; i++) {
+ if (mctx.errors[i] > 0) {
found = 1;
sprintf (buf, "(%s)", my_ldap_err2string (i));
printf ("ldclt[%d]: Global error %2d %s occurs %5d times\n",
mctx.pid, i, buf, mctx.errors[i]);
}
+ }
+#if defined(USE_OPENLDAP)
+ for (i = 0; i < ABS(NEGATIVE_MAX_ERROR_NB); i++) {
+ if (mctx.negativeErrors[i] > 0) {
+ found = 1;
+ sprintf (buf, "(%s)", my_ldap_err2string (-i));
+ printf ("ldclt[%d]: Global error %2d %s occurs %5d times\n",
+ mctx.pid, -i, buf, mctx.negativeErrors[i]);
+ }
+ }
+#endif
if (mctx.errorsBad > 0)
{
found = 1;
- printf ("ldclt[%d]: Global illegal errors (codes not in [0, %d]) occurs %5d times\n",
- mctx.pid, MAX_ERROR_NB-1, mctx.errorsBad);
+ printf("ldclt[%d]: Global illegal errors (codes not in [%d, %d]) occurs %5d times\n",
+ mctx.pid,
+#if defined(USE_OPENLDAP)
+ NEGATIVE_MAX_ERROR_NB,
+#else
+ 0,
+#endif
+ MAX_ERROR_NB-1, mctx.errorsBad);
}
if (!found)
printf ("ldclt[%d]: Global no error occurs during this session.\n", mctx.pid);
@@ -1293,9 +1309,14 @@ basicInit (void)
mctx.totNbOpers = 0;
mctx.totNbSamples = 0;
mctx.errorsBad = 0;
- for (i=0 ; i<MAX_ERROR_NB ; i++)
+ for (i = 0; i < MAX_ERROR_NB; i++) {
mctx.errors[i] = 0;
-
+ }
+#if defined(USE_OPENLDAP)
+ for (i = 0; i < ABS(NEGATIVE_MAX_ERROR_NB); i++) {
+ mctx.negativeErrors[i] = 0;
+ }
+#endif
/*
* Initiate the mutex that protect the errors statistics
*/
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.h b/ldap/servers/slapd/tools/ldclt/ldclt.h
index a48ab7961..4f8f485c9 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.h
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.h
@@ -169,6 +169,9 @@ dd/mm/yy | Author | Comments
#ifndef LDCLT_H
#define LDCLT_H
+#if defined(USE_OPENLDAP)
+#define ABS(x) ((x > 0) ? (x) : (-x))
+#endif
/*
* Misc constant definitions
*/
@@ -183,7 +186,10 @@ dd/mm/yy | Author | Comments
#define DEF_PORT_CHECK 16000 /* Port used for check processing */
#define MAX_ATTRIBS 40 /* Max number of attributes */ /*JLS 28-03-01*/
#define MAX_DN_LENGTH 1024 /* Max length for a DN */
-#define MAX_ERROR_NB 0x62 /* Max ldap err number + 1 */
+#define MAX_ERROR_NB 0x7b /* Max ldap err number + 1 */
+#if defined(USE_OPENLDAP)
+#define NEGATIVE_MAX_ERROR_NB (LDAP_X_CONNECTING - 1) /* Mininum ldap err number */
+#endif
#define MAX_IGN_ERRORS 20 /* Max errors ignored */
#define MAX_FILTER 512 /* Max filters length */
#define MAX_THREADS 1000 /* Max number of threads */ /*JLS 21-11-00*/
@@ -504,6 +510,9 @@ typedef struct main_context {
char *certfile; /* certificate file */ /* BK 11-10-00 */
char *cltcertname; /* client cert name */ /* BK 23 11-00 */
data_list_file *dlf; /* Data list files */ /*JLS 23-03-01*/
+#if defined(USE_OPENLDAP)
+ int negativeErrors[ABS(NEGATIVE_MAX_ERROR_NB)]; /* Err stats */
+#endif
int errors[MAX_ERROR_NB]; /* Err stats */
int errorsBad; /* Bad errors */
ldclt_mutex_t errors_mutex; /* Protect errors */ /*JLS 28-11-00*/
diff --git a/ldap/servers/slapd/tools/ldclt/threadMain.c b/ldap/servers/slapd/tools/ldclt/threadMain.c
index be41186d0..5d915fde4 100644
--- a/ldap/servers/slapd/tools/ldclt/threadMain.c
+++ b/ldap/servers/slapd/tools/ldclt/threadMain.c
@@ -430,14 +430,26 @@ addErrorStat (
/*
* Update the counters
*/
+#if defined(USE_OPENLDAP)
+ if ((err <= NEGATIVE_MAX_ERROR_NB) || (err >= MAX_ERROR_NB))
+#else
if ((err <= 0) || (err >= MAX_ERROR_NB))
+#endif
{
fprintf (stderr, "ldclt[%d]: Illegal error number %d\n", mctx.pid, err);
fflush (stderr);
mctx.errorsBad++;
}
+#if defined(USE_OPENLDAP)
+ else if (err < 0)
+ {
+ mctx.negativeErrors[abs(err)]++;
+ }
+#endif
else
+ {
mctx.errors[err]++;
+ }
/*
* Release the mutex
@@ -460,26 +472,28 @@ addErrorStat (
* Ok, we should not ignore this error...
* Maybe the limit is reached ?
*/
+#if defined(USE_OPENLDAP)
+ if ((err <= NEGATIVE_MAX_ERROR_NB) || (err >= MAX_ERROR_NB))
+#else
if ((err <= 0) || (err >= MAX_ERROR_NB))
- {
- if (mctx.errorsBad > mctx.maxErrors)
- {
- printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
- (void) printGlobalStatistics(); /*JLS 25-08-00*/
- fflush (stdout);
- ldclt_sleep (5);
- ldcltExit (EXIT_MAX_ERRORS); /*JLS 25-08-00*/
+#endif
+ {
+ if (mctx.errorsBad > mctx.maxErrors) {
+ printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
+ (void) printGlobalStatistics(); /*JLS 25-08-00*/
+ fflush (stdout);
+ ldclt_sleep (5);
+ ldcltExit (EXIT_MAX_ERRORS); /*JLS 25-08-00*/
}
- }
- else
- if (mctx.errors[err] > mctx.maxErrors)
- {
- printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
- (void) printGlobalStatistics(); /*JLS 25-08-00*/
- fflush (stdout);
- ldclt_sleep (5);
- ldcltExit (EXIT_MAX_ERRORS); /*JLS 25-08-00*/
+ } else {
+ if (mctx.errors[err] + mctx.negativeErrors[abs(err)] > mctx.maxErrors) {
+ printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
+ (void) printGlobalStatistics(); /*JLS 25-08-00*/
+ fflush (stdout);
+ ldclt_sleep (5);
+ ldcltExit (EXIT_MAX_ERRORS); /*JLS 25-08-00*/
}
+ }
}
/*
| 0 |
088ddec90957ca2ef7a1c072f8fe834eabf46298
|
389ds/389-ds-base
|
Ticket #48295 - Entry cache is not rolled back -- Linked Attributes plug-in - wrong behaviour when adding valid and broken links
Bug Description: When multiple link attribute values are added or deleted
and if some of the op was successfully and one fails, the succeeded operation's
managed type appears in the managed entry although all of the link attribute
operation were rolled back. The managed type indeed does not exist in the
managed entry. That just in the entry cache. Once the server is restarted
the changes disappear.
Fix Description: If the first link attribute value operation fails, it stops
the operation and returns the failure. If the second or the later operation
fails, the succeeded operation up to the previous one are reverted.
https://fedorahosted.org/389/ticket/48295
Reviewed by [email protected] (Thank you, Mark!!)
|
commit 088ddec90957ca2ef7a1c072f8fe834eabf46298
Author: Noriko Hosoi <[email protected]>
Date: Mon Dec 21 16:33:34 2015 -0800
Ticket #48295 - Entry cache is not rolled back -- Linked Attributes plug-in - wrong behaviour when adding valid and broken links
Bug Description: When multiple link attribute values are added or deleted
and if some of the op was successfully and one fails, the succeeded operation's
managed type appears in the managed entry although all of the link attribute
operation were rolled back. The managed type indeed does not exist in the
managed entry. That just in the entry cache. Once the server is restarted
the changes disappear.
Fix Description: If the first link attribute value operation fails, it stops
the operation and returns the failure. If the second or the later operation
fails, the succeeded operation up to the previous one are reverted.
https://fedorahosted.org/389/ticket/48295
Reviewed by [email protected] (Thank you, Mark!!)
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 0d07a1f5d..27af28750 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1474,6 +1474,9 @@ linked_attrs_mod_backpointers(Slapi_PBlock *pb, char *linkdn, char *type,
} else if (rc != LDAP_SUCCESS) {
char *err_msg = NULL;
+ slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
+ "Linked Attrs Plugin: Failed to update link to target entry (%s) error %d",
+ targetdn, rc);
err_msg = PR_smprintf("Linked Attrs Plugin: Failed to update "
"link to target entry (%s) error %d",
targetdn, rc);
@@ -1481,6 +1484,23 @@ linked_attrs_mod_backpointers(Slapi_PBlock *pb, char *linkdn, char *type,
slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, err_msg);
PR_smprintf_free(err_msg);
slapi_sdn_free(&targetsdn);
+ if (i > 0) {
+ int j;
+ Slapi_ValueSet *undoVals = slapi_valueset_new();
+ /* undo 0..i-1 */
+ j = slapi_valueset_first_value(targetvals, &targetval);
+ do {
+ slapi_valueset_add_value(undoVals, targetval);
+ j = slapi_valueset_next_value(targetvals, j, &targetval);
+ } while (j < i);
+ if (LDAP_MOD_DELETE == modop) {
+ modop = LDAP_MOD_ADD;
+ } else {
+ modop = LDAP_MOD_DELETE;
+ }
+ rc = linked_attrs_mod_backpointers(pb, linkdn, type, scope, modop, undoVals);
+ slapi_valueset_free(undoVals);
+ }
rc = LDAP_UNWILLING_TO_PERFORM;
break;
}
| 0 |
d1885bac7558cafb0a2b7a9a67f3f2b6cc2db8f2
|
389ds/389-ds-base
|
Bump version to 1.0.2
|
commit d1885bac7558cafb0a2b7a9a67f3f2b6cc2db8f2
Author: Mark Reynolds <[email protected]>
Date: Mon Aug 1 13:17:22 2016 -0400
Bump version to 1.0.2
diff --git a/src/lib389/VERSION b/src/lib389/VERSION
index 658aed929..663c61a88 100644
--- a/src/lib389/VERSION
+++ b/src/lib389/VERSION
@@ -1,2 +1,2 @@
-1.0.1
+1.0.2
diff --git a/src/lib389/python-lib389.spec b/src/lib389/python-lib389.spec
index 84c126619..3eb124ec8 100644
--- a/src/lib389/python-lib389.spec
+++ b/src/lib389/python-lib389.spec
@@ -1,6 +1,6 @@
Summary: A library for accessing, testing, and configuring the 389 Directory Server
Name: python-lib389
-Version: 1.0.1
+Version: 1.0.2
Release: 1%{?dist}
%global tarver %{version}-1
Source0: http://www.port389.org/binaries/%{name}-%{tarver}.tar.bz2
@@ -17,7 +17,7 @@ Requires: python-ldap
Requires: python-six
Requires: python-pyasn1
Requires: python-pyasn1-modules
-Requires: python-dateutil
+Requires: python2-dateutil
%{?python_provide:%python_provide python2-lib389}
@@ -47,6 +47,66 @@ done
%exclude %{_sbindir}/*
%changelog
+* Mon Aug 1 2016 Mark Reynolds <[email protected]> - 1.0.2-1
+- Bump version to 1.0.2
+- Ticket 48946 - openConnection should not fully popluate DirSrv object
+- Ticket 48832 - Add DirSrvTools.getLocalhost() function
+- Ticket 48382 - Fix serverCmd to get sbin dir properly
+- Bug 1347760 - Information disclosure via repeated use of LDAP ADD operation, etc.
+- Ticket 48937 - Cleanup valgrind wrapper script
+- Ticket 48923 - Fix additional issue with serverCmd
+- Ticket 48923 - serverCmd timeout not working as expected
+- Ticket 48917 - Attribute presence
+- Ticket 48911 - Plugin improvements for lib389
+- Ticket 48911 - Improve plugin support based on new mapped objects
+- Ticket 48910 - Fixes for backend tests and lib389 reliability.
+- Ticket 48860 - Add replication tools
+- Ticket 48888 - Correction to create of dsldapobject
+- Ticket 48886 - Fix NSS SSL library in lib389
+- Ticket 48885 - Fix spec file requires
+- Ticket 48884 - Bugfixes for mapped object and new connections
+- Ticket 48878 - better style for backend in backend_test.py
+- Ticket 48878 - pep8 fixes part 2
+- Ticket 48878 - pep8 fixes and fix rpm to build
+- Ticket 48853 - Prerelease installer
+- Ticket 48820 - Begin to test compatability with py.test3, and the new orm
+- Ticket 48434 - Fix for negative tz offsets
+- Ticket 48857 - Remove python-krbV from lib389
+- Ticket 48820 - Move Encryption and RSA to the new object types
+- Ticket 48431 - lib389 integrate ldclt
+- Ticket 48434 - lib389 logging tools
+- Ticket 48796 - add function to remove logs
+- Ticket 48771 - lib389 - get ns-slapd version
+- Ticket 48830 - Convert lib389 to ip route tools
+- Ticket 48763 - backup should run regardless of existing backups.
+- Ticket 48434 - lib389 logging tools
+- Ticket 48798 - EL6 compat for lib389 tests for DH params
+- Ticket 48798 - lib389 add ability to create nss ca and certificate
+- Ticket 48433 - Aci linting tools
+- Ticket 48791 - format args in server tools
+- Ticket 48399 - Helper makefile is missing mkdir dist
+- Ticket 48399 - Helper makefile is missing mkdir dist
+- Ticket 48794 - lib389 build requires are on a single line
+- Ticket 48660 - Add function to convert binary values in an entry to base64
+- Ticket 48764 - Fix mit krb password to be random.
+- Ticket 48765 - Change default ports for standalone topology
+- Ticket 48750 - Clean up logging to improve command experience
+- Ticket 48751 - Improve lib389 ldapi support
+- Ticket 48399 - Add helper makefile to lib389 to build and install
+- Ticket 48661 - Agreement test suite fails at the test_changes case
+- Ticket 48407 - Add test coverage module for lib389 repo
+- Ticket 48357 - clitools should standarise their args
+- Ticket 48560 - Make verbose handling consistent
+- Ticket 48419 - getadminport() should not a be a static method
+- Ticket 48415 - Add default domain parameter
+- Ticket 48408 - RFE escaped default suffix for tests
+- Ticket 48405 - python-lib389 in rawhide is missing dependencies
+- Ticket 48401 - Revert typecheck
+- Ticket 48401 - lib389 Entry hasAttr returs dict instead of false
+- Ticket 48390 - RFE Improvements to lib389 monitor features for rest389
+- Ticket 48358 - Add new spec file
+- Ticket 48371 - weaker host check on localhost.localdomain
+
* Mon Dec 7 2015 Mark Reynolds <[email protected]> - 1.0.1-1
- Removed downloaded dependencies, and added python_provide macro
- Fixed Source0 URL in spec file
diff --git a/src/lib389/setup.py b/src/lib389/setup.py
index 274cb926d..ae656f3f6 100644
--- a/src/lib389/setup.py
+++ b/src/lib389/setup.py
@@ -71,5 +71,5 @@ setup(
]),
],
- install_requires=['python-ldap', 'python-dateutil'],
+ install_requires=['python-ldap'],
)
| 0 |
4fe22eccb13d93892434ca0eb9300f9ff882dfcd
|
389ds/389-ds-base
|
Issue 6110 - Typo in Account Policy plugin message
Description:
Add additional condition for add and set state
in the config entry success message
Fixes: https://github.com/389ds/389-ds-base/issues/6110
Reviewed by: @progier389, @droideck (Thanks!)
|
commit 4fe22eccb13d93892434ca0eb9300f9ff882dfcd
Author: Barbora Simonova <[email protected]>
Date: Thu Feb 29 16:05:29 2024 +0100
Issue 6110 - Typo in Account Policy plugin message
Description:
Add additional condition for add and set state
in the config entry success message
Fixes: https://github.com/389ds/389-ds-base/issues/6110
Reviewed by: @progier389, @droideck (Thanks!)
diff --git a/src/cockpit/389-console/src/lib/plugins/accountPolicy.jsx b/src/cockpit/389-console/src/lib/plugins/accountPolicy.jsx
index 92776a6ca..f909cf909 100644
--- a/src/cockpit/389-console/src/lib/plugins/accountPolicy.jsx
+++ b/src/cockpit/389-console/src/lib/plugins/accountPolicy.jsx
@@ -490,7 +490,7 @@ class AccountPolicy extends React.Component {
console.info("accountPolicyOperation", "Result", content);
this.props.addNotification(
"success",
- cockpit.format(_("Config entry $0 was successfully $1ed"), configDN, action)
+ cockpit.format(_("Config entry $0 was successfully $1"), configDN, action === "add" ? "added" : "set")
);
this.props.pluginListHandler();
this.handleCloseModal();
| 0 |
2a03eed6f1bb8d70d529b9248603e0449f07ec30
|
389ds/389-ds-base
|
Bug 547503 - replication broken again, with 389 MMR replication and TCP errors
https://bugzilla.redhat.com/show_bug.cgi?id=547503
Resolves: bug 547503
Bug Description: replication broken again, with 389 MMR replication and TCP errors
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: When turbo mode is used for the connection, the server does
not poll for read ready status in the main loop, nor go through the code in
handle_pr_read_ready that updates conn->c_idlesince. So while the conn is in
turbo mode, the c_idlesince is not updated. If the conn gets a timeout while
reading, a flag will be set on the connection that will put it back in the
main loop. When it then hits handle_pr_read_ready, if there is still no
activity on the connection, it will go through idle timeout processing. It
may have been a long time since c_idlesince was updated, so the connection
may be closed wrongly.
The solution is to have c_idlesince updated in connection_threadmain() in
turbo mode if the connection really isn't idle.
In addition, the conn private turbo_mode flag was not being used correctly -
in the timeout case, the local variable was being updated but not the
conn private turbo_flag. Since the conn private turbo_flag is not used
anywhere else, it can be removed, and just use the local variable.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 9d638b3fc25fbc57884a511744943499c7102f40)
|
commit 2a03eed6f1bb8d70d529b9248603e0449f07ec30
Author: Rich Megginson <[email protected]>
Date: Fri Jul 16 14:26:19 2010 -0600
Bug 547503 - replication broken again, with 389 MMR replication and TCP errors
https://bugzilla.redhat.com/show_bug.cgi?id=547503
Resolves: bug 547503
Bug Description: replication broken again, with 389 MMR replication and TCP errors
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: When turbo mode is used for the connection, the server does
not poll for read ready status in the main loop, nor go through the code in
handle_pr_read_ready that updates conn->c_idlesince. So while the conn is in
turbo mode, the c_idlesince is not updated. If the conn gets a timeout while
reading, a flag will be set on the connection that will put it back in the
main loop. When it then hits handle_pr_read_ready, if there is still no
activity on the connection, it will go through idle timeout processing. It
may have been a long time since c_idlesince was updated, so the connection
may be closed wrongly.
The solution is to have c_idlesince updated in connection_threadmain() in
turbo mode if the connection really isn't idle.
In addition, the conn private turbo_mode flag was not being used correctly -
in the timeout case, the local variable was being updated but not the
conn private turbo_flag. Since the conn private turbo_flag is not used
anywhere else, it can be removed, and just use the local variable.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 9d638b3fc25fbc57884a511744943499c7102f40)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 57672afe3..d4af04c6a 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -1527,7 +1527,6 @@ static int counter= 0; /* JCM Dumb Name */
/* The connection private structure for UNIX turbo mode */
struct Conn_private
{
- int turbo_flag; /* set if we are currently in turbo mode */
int previous_op_count; /* the operation counter value last time we sampled it, used to compute operation rate */
int operation_rate; /* rate (ops/sample period) at which this connection has been processing operations */
time_t previous_count_check_time; /* The wall clock time we last sampled the operation count */
@@ -2062,7 +2061,7 @@ void connection_find_our_rank(Connection *conn,int *connection_count, int *our_r
/*
* Evaluate the turbo policy for this connection
*/
-void connection_enter_leave_turbo(Connection *conn, int *new_turbo_flag)
+void connection_enter_leave_turbo(Connection *conn, int current_turbo_flag, int *new_turbo_flag)
{
int current_mode = 0;
int new_mode = 0;
@@ -2071,7 +2070,7 @@ void connection_enter_leave_turbo(Connection *conn, int *new_turbo_flag)
int threshold_rank = 0;
PR_Lock(conn->c_mutex);
/* We can already be in turbo mode, or not */
- current_mode = conn->c_private->turbo_flag;
+ current_mode = current_turbo_flag;
if (conn->c_search_result_set) {
/* PAGED_RESULTS does not need turbo mode */
new_mode = 0;
@@ -2125,7 +2124,6 @@ void connection_enter_leave_turbo(Connection *conn, int *new_turbo_flag)
}
}
}
- conn->c_private->turbo_flag = new_mode;
PR_Unlock(conn->c_mutex);
if (current_mode != new_mode) {
if (current_mode) {
@@ -2158,6 +2156,7 @@ connection_threadmain()
while (1) {
int is_timedout = 0;
+ time_t curtime = 0;
if( op_shutdown ) {
LDAPDebug( LDAP_DEBUG_TRACE,
@@ -2218,15 +2217,16 @@ connection_threadmain()
more_data = 0;
ret = connection_read_operation(conn,op,&tag,&more_data);
+ curtime = current_time();
#define DB_PERF_TURBO 1
#if defined(DB_PERF_TURBO)
/* If it's been a while since we last did it ... */
- if (current_time() - conn->c_private->previous_count_check_time > CONN_TURBO_CHECK_INTERVAL) {
+ 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,&new_turbo_flag);
+ connection_enter_leave_turbo(conn,thread_turbo_flag,&new_turbo_flag);
thread_turbo_flag = new_turbo_flag;
}
@@ -2248,6 +2248,7 @@ connection_threadmain()
* should call connection_make_readable after the op is removed
* connection_make_readable(conn);
*/
+ LDAPDebug(LDAP_DEBUG_CONNS,"conn %" NSPRIu64 " leaving turbo mode due to %d\n",conn->c_connid,ret,0);
goto done;
case CONN_SHUTDOWN:
LDAPDebug( LDAP_DEBUG_TRACE,
@@ -2258,6 +2259,14 @@ connection_threadmain()
break;
}
+ /* if we got here, then we had some read activity */
+ if (thread_turbo_flag) {
+ /* turbo mode avoids handle_pr_read_ready which avoids setting c_idlesince
+ update c_idlesince here since, if we got some read activity, we are
+ not idle */
+ conn->c_idlesince = curtime;
+ }
+
/*
* Do not put the connection back to the read ready poll list
* if the operation is unbind. Unbind will close the socket.
| 0 |
aa2649fa0c7eb412e1714bb56cfdd4bbf812f613
|
389ds/389-ds-base
|
Issue: 48851 - investigate and port TET matching rules filter tests(vfilter simple)
Investigate and port TET matching rules filter tests(vfilter simple)
Relates: https://pagure.io/389-ds-base/issue/48851
Author: aborah
Reviewed by: Simon Pichugin, Viktor Ashirov, Barbora Smejkalová
|
commit aa2649fa0c7eb412e1714bb56cfdd4bbf812f613
Author: Anuj Borah <[email protected]>
Date: Thu May 30 07:47:40 2019 +0530
Issue: 48851 - investigate and port TET matching rules filter tests(vfilter simple)
Investigate and port TET matching rules filter tests(vfilter simple)
Relates: https://pagure.io/389-ds-base/issue/48851
Author: aborah
Reviewed by: Simon Pichugin, Viktor Ashirov, Barbora Smejkalová
diff --git a/dirsrvtests/tests/suites/filter/vfilter_simple_test.py b/dirsrvtests/tests/suites/filter/vfilter_simple_test.py
new file mode 100644
index 000000000..9387adbed
--- /dev/null
+++ b/dirsrvtests/tests/suites/filter/vfilter_simple_test.py
@@ -0,0 +1,410 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2019 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ----
+
+"""
+verify and testing Filter from a search
+"""
+
+import os
+import pytest
+
+from lib389._constants import DEFAULT_SUFFIX, PW_DM
+from lib389.topologies import topology_st as topo
+from lib389.idm.organizationalunit import OrganizationalUnits
+from lib389.idm.account import Accounts
+from lib389.idm.user import UserAccount, UserAccounts
+from lib389.schema import Schema
+from lib389.idm.role import ManagedRoles, FilterRoles
+
+pytestmark = pytest.mark.tier1
+
+FILTER_POSTAL = "(postalCode=99999)"
+FILTER_ADDRESS = "(postalAddress=345 California Av., Mountain View, CA)"
+FILTER_8888 = "(postalCode:2.16.840.1.113730.3.3.2.7.1:=88888)"
+FILTER_6666 = "(postalCode:2.16.840.1.113730.3.3.2.7.1.3:=66666)"
+FILTER_VPE = "(emailclass=vpe*)"
+FILTER_EMAIL = "(emailclass=*emai*)"
+FILTER_EMAILQUATA = "(mailquota=*00)"
+FILTER_QUATA = '(mailquota=*6*0)'
+FILTER_ROLE = '(nsRole=*)'
+FILTER_POST = '(postalAddress=*)'
+FILTER_CLASS = "(emailclass:2.16.840.1.113730.3.3.2.15.1:=>AAA)"
+FILTER_CLASSES = "(emailclass:es:=>AAA)"
+FILTER_AAA = "(emailclass:2.16.840.1.113730.3.3.2.15.1.5:=AAA)"
+FILTER_VE = "(emailclass:2.16.840.1.113730.3.3.2.15.1:=>vpemail)"
+FILTER_VPEM = "(emailclass:es:=>vpemail)"
+FILTER_900 = "(mailquota:2.16.840.1.113730.3.3.2.15.1.1:=900)"
+FILTER_7777 = "(postalCode:de:==77777)"
+FILTER_FRED = '(fred=*)'
+FILTER_ECLASS = "(emailclass:2.16.840.1.113730.3.3.2.15.1.5:=vpemail)"
+FILTER_ECLASS_1 = "(emailclass:2.16.840.1.113730.3.3.2.15.1:=<1)"
+FILTER_ECLASS_2 = "(emailclass:es:=<1)"
+FILTER_ECLASS_3 = "(emailclass:2.16.840.1.113730.3.3.2.15.1.1:=1)"
+FILTER_ECLASS_4 = "(emailclass:2.16.840.1.113730.3.3.2.15.1:=<vpemail)"
+FILTER_VPE_1 = "(emailclass:es:=<vpemail)"
+FILTER_VPE_2 = "(emailclass:2.16.840.1.113730.3.3.2.15.1.1:=vpemail)"
+FILTER_MAILQUATA_1 = "(mailquota:2.16.840.1.113730.3.3.2.15.1:=<900)"
+FILTER_MAILQUATA_2 = "(mailquota:es:=<900)"
+
+
+VALUES = [FILTER_POSTAL,
+ FILTER_ADDRESS,
+ FILTER_8888,
+ FILTER_6666,
+ FILTER_VPE,
+ FILTER_EMAIL,
+ FILTER_EMAILQUATA,
+ FILTER_QUATA,
+ FILTER_ROLE,
+ FILTER_POST,
+ FILTER_CLASS,
+ FILTER_CLASSES,
+ FILTER_AAA,
+ FILTER_VE,
+ FILTER_VPEM,
+ FILTER_900]
+
+VALUES_NEGATIVE = [FILTER_7777,
+ FILTER_FRED,
+ FILTER_ECLASS,
+ FILTER_ECLASS_1,
+ FILTER_ECLASS_2,
+ FILTER_ECLASS_3,
+ FILTER_ECLASS_4,
+ FILTER_VPE_1,
+ FILTER_VPE_2,
+ FILTER_MAILQUATA_1,
+ FILTER_MAILQUATA_2]
+
+
+def non_english_user(people, user, cn_cn, ou_ou, des, tele, facetele, be_be, lang):
+ """
+ Will create users with non english name
+ """
+ people.create(properties={
+ 'uid': user,
+ 'cn': cn_cn,
+ 'sn': cn_cn.split()[1].title(),
+ 'givenname': cn_cn.split()[0],
+ 'ou': ou_ou,
+ 'mail': f'{user}@anujborah.com',
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/' + user,
+ 'telephoneNumber': tele,
+ 'facsimileTelephoneNumber': facetele,
+ f'cn;lang-{be_be}': lang,
+ f'sn;lang-{be_be}': lang.split()[1],
+ f'givenName;lang-{be_be}': lang.split()[0],
+ 'userpassword': PW_DM,
+ 'manager': 'uid=' + user + ',ou=' + ou_ou + ',' + DEFAULT_SUFFIX,
+ 'description': des
+ })
+
+
+def english_named_user(people, user, org, l_l, telephone, facsimile_telephone_number, rn_rn):
+ """
+ Will create users with English name
+ """
+ people.create(properties={
+ 'uid': user,
+ 'cn': user,
+ 'sn': user,
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/' + user,
+ 'givenname': user,
+ 'ou': org,
+ 'mail': f'{user}@example.com',
+ 'roomnumber': rn_rn,
+ 'l': l_l,
+ 'telephonenumber': telephone,
+ 'manager': f'uid={user},ou=People,{DEFAULT_SUFFIX}',
+ 'facsimiletelephonenumber': facsimile_telephone_number,
+ 'userpassword': PW_DM,
+ })
+
+
+def user_with_postal_code(people, user, address, pin):
+ """
+ Will create users with postal Address
+ """
+ people.create(properties={
+ 'uid': user,
+ 'cn': user,
+ 'sn': user,
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/' + user,
+ 'postalAddress': address,
+ 'postalCode': pin,
+ })
+
+
[email protected](scope="module")
+def _create_test_entries(topo):
+ # Changing schema
+ current_schema = Schema(topo.standalone)
+ current_schema.add('attributetypes',
+ "( 9.9.8.4 NAME 'emailclass' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
+ "X-ORIGIN 'RFC 2256' )")
+ current_schema.add('objectclasses',
+ "( 9.9.8.2 NAME 'mailSchemeUser' DESC 'User Defined ObjectClass' "
+ "SUP 'top' MUST ( objectclass ) "
+ "MAY (aci $ emailclass) X-ORIGIN 'RFC 2256' )")
+
+ # Creating ous
+ ous = OrganizationalUnits(topo.standalone, DEFAULT_SUFFIX)
+ for ou_ou in ['Çéliné Ändrè', 'Ännheimè', 'Çlose Crèkä',
+ 'Sàn Fråncêscô', 'Netscape Servers',
+ 'COS', ]:
+ ous.create(properties={'ou': ou_ou})
+
+ ous_mail = OrganizationalUnits(topo.standalone, f'ou=COS,{DEFAULT_SUFFIX}')
+ ous_mail.create(properties={'ou': 'MailSchemeClasses'})
+
+ # Creating users
+ users_people = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ for user, org, l_l, telephone, facetele, rn_rn in [
+ ['scarter', ['Accounting', 'People'], 'Sunnyvale',
+ '+1 408 555 4798', '+1 408 555 9751', '4612'],
+ ['tmorris', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 9187', '+1 408 555 8473', '4117'],
+ ['kvaughan', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 5625', ' +1 408 555 3372', '2871'],
+ ['abergin', ['Product Testing', 'People'], 'Cupertino',
+ '+1 408 555 8585', '+1 408 555 7472', '3472'],
+ ['dmiller', ['Accounting', 'People'], 'Sunnyvale',
+ '+1 408 555 9423', '+1 408 555 0111', '4135'],
+ ['gfarmer', ['Accounting', 'People'], 'Cupertino',
+ '+1 408 555 6201', '+1 408 555 8473', '1269'],
+ ['kwinters', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 9069', '+1 408 555 1992', '4178'],
+ ['trigden', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 9280', '+1 408 555 8473', '3584'],
+ ['cschmith', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 8011', '+1 408 555 4774', '0416'],
+ ['jwallace', ['Accounting', 'People'], 'Sunnyvale',
+ '+1 408 555 0319', '+1 408 555 8473', '1033'],
+ ['jwalker', ['Product Testing', 'People'], 'Cupertino',
+ '+1 408 555 1476', '+1 408 555 1992', '3915'],
+ ['tclow', ['Human Resources', 'People'], 'Santa Clara',
+ '+1 408 555 8825', '+1 408 555 1992', '4376'],
+ ['rdaugherty', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 1296', '+1 408 555 1992', '0194'],
+ ['jreuter', ['Product Testing', 'People'], 'Cupertino',
+ '+1 408 555 1122', '+1 408 555 8721', '2942'],
+ ['tmason', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 1596', '+1 408 555 9751', '1124'],
+ ['bhall', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 4798', '+1 408 555 9751', '4612'],
+ ['btalbot', ['Human Resources', 'People'], 'Cupertino',
+ '+1 408 555 6067', '+1 408 555 9751', '3532'],
+ ['mward', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '1707'],
+ ['bjablons', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 6067', '+1 408 555 9751', '0906'],
+ ['jmcFarla', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '2359'],
+ ['llabonte', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '2854'],
+ ['jcampaig', ['Product Development', 'People'], 'Cupertino',
+ '+1 408 555 6067', '+1 408 555 9751', '4385'],
+ ['bhal2', ['Accounting', 'People'], 'Sunnyvale',
+ '+1 408 555 6067', '+1 408 555 9751', '2758'],
+ ['alutz', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '1327'],
+ ['btalbo2', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '1205'],
+ ['achassin', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '0466'],
+ ['hmiller', ['Human Resources', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '4304'],
+ ['jcampai2', ['Human Resources', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '1377'],
+ ['lulrich', ['Accounting', 'People'], 'Sunnyvale',
+ '+1 408 555 6067', '+1 408 555 9751', '0985'],
+ ['mlangdon', ['Product Development', 'People'], 'Cupertino',
+ '+1 408 555 6067', '+1 408 555 9751', '4471'],
+ ['striplet', ['Human Resources', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '3083'],
+ ['gtriplet', ['Accounting', 'People'], 'Sunnyvale',
+ '+1 408 555 6067', '+1 408 555 9751', '4023'],
+ ['jfalena', ['Human Resources', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '1917'],
+ ['speterso', ['Human Resources', 'People'], 'Cupertino',
+ '+1 408 555 6067', '+1 408 555 9751', '3073'],
+ ['ejohnson', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '3737'],
+ ['prigden', ['Accounting', 'People'], 'Santa',
+ '+1 408 555 6067', '+1 408 555 9751', '1271'],
+ ['bwalker', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 6067', '+1 408 555 9751', '3529'],
+ ['kjensen', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 4798', '+1 408 555 9751', '1944'],
+ ['mlott', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 4798', '+1 408 555 9751', '0498'],
+ ['cwallace', ['Product Development', 'People'], 'Cupertino',
+ '+1 408 555 4798', '+1 408 555 9751', '0349'],
+ ['falbers', ['Accounting', 'People'], 'Sunnyvale',
+ '+1 408 555 4798', '+1 408 555 9751', '1439'],
+ ['calexand', ['Product Development', 'People'], 'Sunnyvale',
+ '+1 408 555 4798', '+1 408 555 9751', '2884'],
+ ['phunt', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 4798', '+1 408 555 9751', '1183'],
+ ['awhite', ['Product Testing', 'People'], 'Sunnyvale',
+ '+1 408 555 4798', '+1 408 555 9751', '0142'],
+ ['sfarmer', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 4798', '+1 408 555 9751', '0019'],
+ ['jrentz', ['Human Resources', 'People'], 'Santa Clara',
+ '+1 408 555 4798', '+1 408 555 9751', '3025'],
+ ['ahall', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 4798', '+1 408 555 9751', '3050'],
+ ['lstockto', ['Product Testing', 'People'], 'Santa Clara',
+ '+1 408 555 0518', '+1 408 555 4774', '0169'],
+ ['ttully', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 2274', '+1 408 555 0111', '3924'],
+ ['polfield', ['Human Resources', 'People'], 'Santa Clara',
+ '+1 408 555 4798', '+1 408 555 9751', '1376'],
+ ['scarte2', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 4798', '+1 408 555 9751', '2013'],
+ ['tkelly', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 4295', '+1 408 555 1992', '3107'],
+ ['mmcinnis', ['Product Development', 'People'], 'Santa Clara',
+ '+1 408 555 9655', '+1 408 555 8721', '4818'],
+ ['brigden', ['Human Resources', 'People'], 'Sunnyvale',
+ '+1 408 555 9655', '+1 408 555 8721', '1643'],
+ ['mtyler', ['Human Resources', 'People'], 'Cupertino',
+ '+1 408 555 9655', '+1 408 555 8721', '2701'],
+ ['rjense2', ['Product Testing', 'People'], 'Sunnyvale',
+ '+1 408 555 9655', '+1 408 555 8721', '1984'],
+ ['rhunt', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 9655', '+1 408 555 8721', '0718'],
+ ['ptyler', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 9655', '+1 408 555 8721', '0327'],
+ ['gtyler', ['Accounting', 'People'], 'Santa Clara',
+ '+1 408 555 9655', '+1 408 555 8721', '0312']]:
+ english_named_user(users_people, user, org, l_l, telephone, facetele, rn_rn)
+
+ # Creating Users
+ users_annahame = UserAccounts(topo.standalone, f'ou=Ännheimè,{DEFAULT_SUFFIX}', rdn=None)
+ users_sanfran = UserAccounts(topo.standalone, f'ou=Sàn Fråncêscô,{DEFAULT_SUFFIX}', rdn=None)
+ users_andre = UserAccounts(topo.standalone, f'ou=Çéliné Ändrè,{DEFAULT_SUFFIX}', rdn=None)
+ users_close = UserAccounts(topo.standalone, f'ou=Çlose Crèkä,{DEFAULT_SUFFIX}', rdn=None)
+ for people, user, cn_cn, ou_ou, des, tele, facetele, be_be, lang in [
+ [users_annahame, 'user0', 'Babette Ryndérs', 'Ännheimè',
+ 'This is Babette Ryndérs description', '+1 415 788-4115',
+ '+1 804 849-2367', 'es', 'Babette Ryndérs'],
+ [users_sanfran, 'user1', 'mÿrty DeCoùrsin', 'Sàn Fråncêscô',
+ 'This is mÿrty DeCoùrsins description', '+1 408 689-8883',
+ '+1 804 849-2367', 'ie', 'mÿrty DeCoùrsin'],
+ [users_sanfran, 'user3', 'Kéñnon Fùndérbùrg', 'Sàn Fråncêscô',
+ "This is Kéñnon Fùndérbùrg's description", '+1 408 689-8883',
+ '+1 804 849-2367', 'it', 'Kéñnon Fùndérbùrg'],
+ [users_sanfran, 'user5', 'Dàsya Cozàrt', 'Sàn Fråncêscô',
+ "This is Dàsya Cozàrt's description", '+1 408 689-8883',
+ '+1 804 849-2367', 'be', 'Dàsya Cozàrt'],
+ [users_andre, 'user2', "Rôw O'Connér", 'Çéliné Ändrè',
+ "This is Rôw O'Connér's description", '+1 408 689-8883',
+ '+1 804 849-2367', 'it', "Rôw O'Connér"],
+ [users_andre, 'user4', 'Theadora Ebérle', 'Çéliné Ändrè',
+ "This is Kéñnon Fùndérbùrg's description", '+1 408 689-8883',
+ '+1 804 849-2367', 'de', 'Theadora Ebérle'],
+ [users_andre, 'user6', 'mÿrv Callânân', 'Çéliné Ändrè',
+ "This is mÿrv Callânân's description", '+1 408 689-8883',
+ '+1 804 849-2367', 'fr', 'mÿrv Callânân'],
+ [users_close, 'user7', 'Ñäthan Ovâns', 'Çlose Crèkä',
+ "This is Ñäthan Ovâns's description", '+1 408 689-8883',
+ '+1 804 849-2367', 'be', 'Ñäthan Ovâns']]:
+ non_english_user(people, user, cn_cn, ou_ou, des, tele, facetele, be_be, lang)
+
+ # Creating User Entry
+ for user, address, pin in [
+ ['Secretary1', '123 Castro St., Mountain View, CA', '99999'],
+ ['Secretary2', '234 Ellis St., Mountain View, CA', '88888'],
+ ['Secretary3', '345 California Av., Mountain View, CA', '77777'],
+ ['Secretary4', '456 Villa St., Mountain View, CA', '66666'],
+ ['Secretary5', '567 University Av., Mountain View, CA', '55555']]:
+ user_with_postal_code(users_people, user, address, pin)
+
+ # Adding properties to mtyler
+ mtyler = UserAccount(topo.standalone, 'uid=mtyler, ou=people, dc=example, dc=com')
+ for value1, value2 in [
+ ('objectclass', ['mailSchemeUser', 'mailRecipient']),
+ ('emailclass', 'vpemail'),
+ ('mailquota', '600'),
+ ('multiLineDescription', 'fromentry This is the special \2a attribute value')]:
+ mtyler.add(value1, value2)
+
+ # Adding properties to rjense2
+ rjense2 = UserAccount(topo.standalone, 'uid=rjense2, ou=people, dc=example, dc=com')
+ for value1, value2 in [
+ ('objectclass', ['mailRecipient', 'mailSchemeUser']),
+ ('emailclass', 'vpemail')]:
+ rjense2.add(value1, value2)
+
+ # Creating managed role
+ ManagedRoles(topo.standalone, DEFAULT_SUFFIX).create(properties={
+ 'description': 'This is the new managed role configuration',
+ 'cn': 'new managed role'})
+
+ # Creating filter role
+ filters = FilterRoles(topo.standalone, DEFAULT_SUFFIX)
+ filters.create(properties={
+ 'nsRoleFilter': '(uid=*wal*)',
+ 'description': 'this is the new filtered role',
+ 'cn': 'new filtered role'})
+ filters.create(properties={
+ 'nsRoleFilter': '(&(postalCode=77777)(uid=*er*))',
+ 'description': 'This is the new vddr filter role config',
+ 'cn': 'new vaddr filtered role'
+ })
+ filters.create(properties={
+ 'nsRoleFilter': '(&(postalCode=66666)(l=Cupertino))',
+ 'description': 'This is the new vddr filter role config',
+ 'cn': 'another vaddr role'
+ })
+
+
[email protected]("real_value", VALUES)
+def test_param_positive(topo, _create_test_entries, real_value):
+ """
+ Will test Filters with positive output.
+ :id:71de14a4-9f22-11e8-b5cc-8c16451d917b
+ :setup: Standalone Server
+ :steps:
+ 1. Create Filter rules.
+ 2. Try to pass filter rules as per the condition .
+ :expected results:
+ 1. It should pass
+ 2. It should pass
+ """
+ assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter(real_value)
+
+
[email protected]("real_value", VALUES_NEGATIVE)
+def test_param_negative(topo, _create_test_entries, real_value):
+ """
+ Will test Filetrs with 0 outputs
+ :id:81054e7a-9f22-11e8-a461-8c16451d917b
+ :setup: Standalone Server
+ :steps:
+ 1. Create Filter rules.
+ 2. Try to pass filter rules as per the condition .
+ 3. All Filters will give 0 output as these are negative test cases.
+ :expected results:
+ 1. It should pass
+ 2. It should pass
+ 3. no output
+ """
+ assert not Accounts(topo.standalone, DEFAULT_SUFFIX).filter(real_value)
+
+
+if __name__ == '__main__':
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
| 0 |
985425be4b33f4ea192d5a69a345fab153b722da
|
389ds/389-ds-base
|
Issue 6623 - UI - Generic updates (#6624)
Bug description:
Missing dot in warning alert when changing suffix backend state.
No success alert upon deleting local password policy.
Tool tips for part of Syntax Settings for local password policies do not show.
Fixes: https://github.com/389ds/389-ds-base/issues/6623
Reviewed by: @mreynolds389 (Thank you)
|
commit 985425be4b33f4ea192d5a69a345fab153b722da
Author: James Chapman <[email protected]>
Date: Wed Feb 19 12:18:59 2025 +0000
Issue 6623 - UI - Generic updates (#6624)
Bug description:
Missing dot in warning alert when changing suffix backend state.
No success alert upon deleting local password policy.
Tool tips for part of Syntax Settings for local password policies do not show.
Fixes: https://github.com/389ds/389-ds-base/issues/6623
Reviewed by: @mreynolds389 (Thank you)
diff --git a/src/cockpit/389-console/src/lib/database/localPwp.jsx b/src/cockpit/389-console/src/lib/database/localPwp.jsx
index 90565ae40..e87f9a183 100644
--- a/src/cockpit/389-console/src/lib/database/localPwp.jsx
+++ b/src/cockpit/389-console/src/lib/database/localPwp.jsx
@@ -542,10 +542,10 @@ class CreatePolicy extends React.Component {
isDisabled={!this.props.passwordchecksyntax}
/>
</GridItem>
- <GridItem className="ds-label" offset={5} span={3} title={_("Reject passwords with fewer than this many alpha characters (passwordMinAlphas).")}>
+ <GridItem className="ds-label" offset={5} span={3}>
{_("Minimum Alpha's")}
</GridItem>
- <GridItem span={1}>
+ <GridItem span={1} title={_("Reject passwords with fewer than this many alpha characters (passwordMinAlphas).")}>
<TextInput
type="number"
id="create_passwordminalphas"
@@ -574,10 +574,10 @@ class CreatePolicy extends React.Component {
isDisabled={!this.props.passwordchecksyntax}
/>
</GridItem>
- <GridItem className="ds-label" offset={5} span={3} title={_("Reject passwords with fewer than this many special non-alphanumeric characters (passwordMinSpecials).")}>
+ <GridItem className="ds-label" offset={5} span={3}>
{_("Minimum Special")}
</GridItem>
- <GridItem span={1}>
+ <GridItem span={1} title={_("Reject passwords with fewer than this many special non-alphanumeric characters (passwordMinSpecials).")}>
<TextInput
type="number"
id="create_passwordminspecials"
@@ -606,10 +606,10 @@ class CreatePolicy extends React.Component {
isDisabled={!this.props.passwordchecksyntax}
/>
</GridItem>
- <GridItem className="ds-label" offset={5} span={3} title={_("Reject passwords with fewer than this many lowercase characters (passwordMinLowers).")}>
+ <GridItem className="ds-label" offset={5} span={3}>
{_("Minimum Lowercase")}
</GridItem>
- <GridItem span={1}>
+ <GridItem span={1} title={_("Reject passwords with fewer than this many lowercase characters (passwordMinLowers).")}>
<TextInput
type="number"
id="create_passwordminlowers"
@@ -638,10 +638,10 @@ class CreatePolicy extends React.Component {
isDisabled={!this.props.passwordchecksyntax}
/>
</GridItem>
- <GridItem className="ds-label" offset={5} span={3} title={_("The minimum number of character categories that a password must contain (categories are upper, lower, digit, special, and 8-bit) (passwordMinCategories).")}>
+ <GridItem className="ds-label" offset={5} span={3}>
{_("Minimum Categories")}
</GridItem>
- <GridItem span={1}>
+ <GridItem span={1} title={_("The minimum number of character categories that a password must contain (categories are upper, lower, digit, special, and 8-bit) (passwordMinCategories).")}>
<TextInput
type="number"
id="create_passwordmincategories"
@@ -670,10 +670,10 @@ class CreatePolicy extends React.Component {
isDisabled={!this.props.passwordchecksyntax}
/>
</GridItem>
- <GridItem className="ds-label" offset={5} span={3} title={_("The maximum number of times the same character can sequentially appear in a password (passwordMaxRepeats).")}>
+ <GridItem className="ds-label" offset={5} span={3}>
{_("Max Repeated Chars")}
</GridItem>
- <GridItem span={1}>
+ <GridItem span={1} title={_("The maximum number of times the same character can sequentially appear in a password (passwordMaxRepeats).")}>
<TextInput
type="number"
id="create_passwordmaxrepeats"
@@ -702,10 +702,10 @@ class CreatePolicy extends React.Component {
isDisabled={!this.props.passwordchecksyntax}
/>
</GridItem>
- <GridItem className="ds-label" offset={5} span={3} title={_("The maximum number of times the same character can sequentially appear in a password (passwordMaxRepeats).")}>
+ <GridItem className="ds-label" offset={5} span={3}>
{_("Max Sequence Sets")}
</GridItem>
- <GridItem span={1}>
+ <GridItem span={1} title={_("The maximum number of times the same character can sequentially appear in a password (passwordMaxRepeats).")}>
<TextInput
type="number"
id="create_passwordmaxseqsets"
@@ -1855,7 +1855,12 @@ export class LocalPwPolicy extends React.Component {
.spawn(cmd, { superuser: true, err: "message" })
.done(content => {
this.handleLoadPolicies();
+ this.props.addNotification(
+ "success",
+ "Successfully deleted password policy"
+ )
})
+
.fail(err => {
const errMsg = JSON.parse(err);
this.handleLoadPolicies();
diff --git a/src/cockpit/389-console/src/lib/database/suffix.jsx b/src/cockpit/389-console/src/lib/database/suffix.jsx
index c6f19e640..bd59653dd 100644
--- a/src/cockpit/389-console/src/lib/database/suffix.jsx
+++ b/src/cockpit/389-console/src/lib/database/suffix.jsx
@@ -812,7 +812,7 @@ export class Suffix extends React.Component {
savingConfig: true
});
log_cmd("saveSuffixConfig", "Save suffix config", cmd);
- const msg = "Successfully updated suffix configuration";
+ const msg = "Successfully updated suffix configuration.";
cockpit
.spawn(cmd, { superuser: true, err: "message" })
.done(content => {
@@ -821,7 +821,7 @@ export class Suffix extends React.Component {
if (requireRestart) {
this.props.addNotification(
"warning",
- msg + _("You must restart the Directory Server for these changes to take effect.")
+ msg + _(" You must restart the Directory Server for these changes to take effect.")
);
}
this.setState({
| 0 |
71465a8d14ba09ebe102a1a9bee1596473488f11
|
389ds/389-ds-base
|
[160003] db2index.pl cannot find libldap50.so if only certain parameters are used
In the perl script db2index.pl, before executing any ldap client command line
tools, should have chdir to the <dsroot>/shared/bin, where the rpath is set
from.
|
commit 71465a8d14ba09ebe102a1a9bee1596473488f11
Author: Noriko Hosoi <[email protected]>
Date: Thu Aug 25 21:17:48 2005 +0000
[160003] db2index.pl cannot find libldap50.so if only certain parameters are used
In the perl script db2index.pl, before executing any ldap client command line
tools, should have chdir to the <dsroot>/shared/bin, where the rpath is set
from.
diff --git a/ldap/admin/src/scripts/template-db2index.pl b/ldap/admin/src/scripts/template-db2index.pl
index d86decc9c..9e7910986 100644
--- a/ldap/admin/src/scripts/template-db2index.pl
+++ b/ldap/admin/src/scripts/template-db2index.pl
@@ -40,21 +40,21 @@
#
sub usage {
- print(STDERR "Usage: $0 [-v] -D rootdn { -w password | -w - | -j filename } \n");
- print(STDERR " -n instance [-t attributeName[:indextypes[:matchingrules]]]\n");
- print(STDERR " Opts: -D rootdn - Directory Manager\n");
- print(STDERR " : -w password - Directory Manager's password\n");
- print(STDERR " : -w - - Prompt for Directory Manager's password\n");
- print(STDERR " : -j filename - Read Directory Manager's password from file\n");
- print(STDERR " : -n instance - instance to be indexed\n");
- print(STDERR " : -t attributeName[:indextypes[:matchingrules]]\n");
- print(STDERR " - attribute: name of the attribute to be indexed\n");
- print(STDERR " If omitted, all the indexes defined \n");
- print(STDERR " for that instance are generated.\n");
- print(STDERR " - indextypes: comma separated index types\n");
- print(STDERR " - matchingrules: comma separated matrules\n");
- print(STDERR " Example: -t foo:eq,pres\n");
- print(STDERR " : -v - version\n");
+ print(STDERR "Usage: $0 [-v] -D rootdn { -w password | -w - | -j filename } \n");
+ print(STDERR " -n instance [-t attributeName[:indextypes[:matchingrules]]]\n");
+ print(STDERR " Opts: -D rootdn - Directory Manager\n");
+ print(STDERR " : -w password - Directory Manager's password\n");
+ print(STDERR " : -w - - Prompt for Directory Manager's password\n");
+ print(STDERR " : -j filename - Read Directory Manager's password from file\n");
+ print(STDERR " : -n instance - instance to be indexed\n");
+ print(STDERR " : -t attributeName[:indextypes[:matchingrules]]\n");
+ print(STDERR " - attribute: name of the attribute to be indexed\n");
+ print(STDERR " If omitted, all the indexes defined \n");
+ print(STDERR " for that instance are generated.\n");
+ print(STDERR " - indextypes: comma separated index types\n");
+ print(STDERR " - matchingrules: comma separated matrules\n");
+ print(STDERR " Example: -t foo:eq,pres\n");
+ print(STDERR " : -v - verbose\n");
}
$instance = "";
@@ -71,81 +71,81 @@ $mydsroot = "{{MY-DS-ROOT}}";
$i = 0;
while ($i <= $#ARGV)
{
- if ("$ARGV[$i]" eq "-n")
- {
- # instance
- $i++; $instance = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-D")
- {
- # Directory Manager
- $i++; $rootdn = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-w")
- {
- # Directory Manager's password
- $i++; $passwd = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-j")
- {
- # Read Directory Manager's password from a file
- $i++; $passwdfile = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-t")
- {
- # Attribute to index
- $i++; $attribute_arg = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-T")
- {
- # Vlvattribute to index
- $i++; $vlvattribute_arg = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-v")
- {
- # verbose
- $verbose = 1;
- }
- else
- {
- &usage; exit(1);
- }
- $i++;
+ if ("$ARGV[$i]" eq "-n")
+ {
+ # instance
+ $i++; $instance = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-D")
+ {
+ # Directory Manager
+ $i++; $rootdn = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-w")
+ {
+ # Directory Manager's password
+ $i++; $passwd = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-j")
+ {
+ # Read Directory Manager's password from a file
+ $i++; $passwdfile = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-t")
+ {
+ # Attribute to index
+ $i++; $attribute_arg = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-T")
+ {
+ # Vlvattribute to index
+ $i++; $vlvattribute_arg = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-v")
+ {
+ # verbose
+ $verbose = 1;
+ }
+ else
+ {
+ &usage; exit(1);
+ }
+ $i++;
}
if ($passwdfile ne ""){
# Open file and get the password
- unless (open (RPASS, $passwdfile)) {
- die "Error, cannot open password file $passwdfile\n";
- }
- $passwd = <RPASS>;
- chomp($passwd);
- close(RPASS);
+ unless (open (RPASS, $passwdfile)) {
+ die "Error, cannot open password file $passwdfile\n";
+ }
+ $passwd = <RPASS>;
+ chomp($passwd);
+ close(RPASS);
} elsif ($passwd eq "-"){
# Read the password from terminal
- die "The '-w -' option requires an extension library (Term::ReadKey) which is not\n",
- "part of the standard perl distribution. If you want to use it, you must\n",
- "download and install the module. You can find it at\n",
- "http://www.perl.com/CPAN/CPAN.html\n";
+ die "The '-w -' option requires an extension library (Term::ReadKey) which is not\n",
+ "part of the standard perl distribution. If you want to use it, you must\n",
+ "download and install the module. You can find it at\n",
+ "http://www.perl.com/CPAN/CPAN.html\n";
# Remove the previous line and uncomment the following 6 lines once you have installed Term::ReadKey module.
# use Term::ReadKey;
-# print "Bind Password: ";
-# ReadMode('noecho');
-# $passwd = ReadLine(0);
-# chomp($passwd);
-# ReadMode('normal');
+# print "Bind Password: ";
+# ReadMode('noecho');
+# $passwd = ReadLine(0);
+# chomp($passwd);
+# ReadMode('normal');
}
if ( $rootdn eq "" || $passwd eq "" )
{
- &usage;
- exit(1);
+ &usage;
+ exit(1);
}
$vstr = "";
if ($verbose != 0)
{
- $vstr = "-v";
+ $vstr = "-v";
}
($s, $m, $h, $dy, $mn, $yr, $wdy, $ydy, $r) = localtime(time);
@@ -154,74 +154,72 @@ $taskname = "db2index_${yr}_${mn}_${dy}_${h}_${m}_${s}";
if ( $instance eq "" )
{
- &usage;
- exit(1);
+ &usage;
+ exit(1);
}
-else
+
+# No attribute name has been specified: let's get them from the configuration
+$attribute="";
+$indexes_list="";
+$vlvattribute="";
+$vlvindexes_list="";
+chdir("$dsroot{{SEP}}shared{{SEP}}bin");
+if ( $attribute_arg eq "" && $vlvattribute_arg eq "" )
{
- # No attribute name has been specified: let's get them from the configuration
- $attribute="";
- $indexes_list="";
- $vlvattribute="";
- $vlvindexes_list="";
- if ( $attribute_arg eq "" && $vlvattribute_arg eq "" )
- {
- # Get the list of indexes from the entry
- $indexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s one " .
- "-b \"cn=index,cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"(&(objectclass=*)(nsSystemIndex=false))\" cn";
-
- # build the values of the attribute nsIndexAttribute
- open(LDAP1, "$indexes_list |");
- while (<LDAP1>) {
- s/\n //g;
- if (/^cn: (.*)\n/) {
- $IndexAttribute="nsIndexAttribute";
- $attribute="$attribute$IndexAttribute: $1\n";
- }
- }
- close(LDAP1);
- if ( $attribute eq "" )
- {
- # No attribute to index, just exit
- exit(0);
- }
+ # Get the list of indexes from the entry
+ $indexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s one " .
+ "-b \"cn=index,cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"(&(objectclass=*)(nsSystemIndex=false))\" cn";
- # Get the list of indexes from the entry
- $vlvindexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s sub -b \"cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"objectclass=vlvIndex\" cn";
-
- # build the values of the attribute nsIndexVlvAttribute
- open(LDAP1, "$vlvindexes_list |");
- while (<LDAP1>) {
- s/\n //g;
- if (/^cn: (.*)\n/) {
- $vlvIndexAttribute="nsIndexVlvAttribute";
- $vlvattribute="$vlvattribute$vlvIndexAttribute: $1\n";
- }
+ # build the values of the attribute nsIndexAttribute
+ open(LDAP1, "$indexes_list |");
+ while (<LDAP1>) {
+ s/\n //g;
+ if (/^cn: (.*)\n/) {
+ $IndexAttribute="nsIndexAttribute";
+ $attribute="$attribute$IndexAttribute: $1\n";
}
- close(LDAP1);
}
- else
+ close(LDAP1);
+ if ( $attribute eq "" )
{
- if ( $attribute_arg ne "" )
- {
- $attribute="nsIndexAttribute: $attribute_arg\n";
- }
- if ( $vlvattribute_arg ne "" )
- {
- $vlvattribute="nsIndexVlvAttribute: $vlvattribute_arg\n";
+ # No attribute to index, just exit
+ exit(0);
+ }
+
+ # Get the list of indexes from the entry
+ $vlvindexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s sub -b \"cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"objectclass=vlvIndex\" cn";
+
+ # build the values of the attribute nsIndexVlvAttribute
+ open(LDAP1, "$vlvindexes_list |");
+ while (<LDAP1>) {
+ s/\n //g;
+ if (/^cn: (.*)\n/) {
+ $vlvIndexAttribute="nsIndexVlvAttribute";
+ $vlvattribute="$vlvattribute$vlvIndexAttribute: $1\n";
}
}
-
- # Build the task entry to add
-
- $dn = "dn: cn=$taskname, cn=index, cn=tasks, cn=config\n";
- $misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
- $cn = "cn: $taskname\n";
- $nsinstance = "nsInstance: ${instance}\n";
-
- $entry = "${dn}${misc}${cn}${nsinstance}${attribute}${vlvattribute}";
+ close(LDAP1);
}
-chdir("$dsroot{{SEP}}shared{{SEP}}bin");
+else
+{
+ if ( $attribute_arg ne "" )
+ {
+ $attribute="nsIndexAttribute: $attribute_arg\n";
+ }
+ if ( $vlvattribute_arg ne "" )
+ {
+ $vlvattribute="nsIndexVlvAttribute: $vlvattribute_arg\n";
+ }
+}
+
+# Build the task entry to add
+
+$dn = "dn: cn=$taskname, cn=index, cn=tasks, cn=config\n";
+$misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
+$cn = "cn: $taskname\n";
+$nsinstance = "nsInstance: ${instance}\n";
+
+$entry = "${dn}${misc}${cn}${nsinstance}${attribute}${vlvattribute}";
open(FOO, "| $dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
print(FOO "$entry");
close(FOO);
| 0 |
3c3e1f30cdb046a1aabb93aacebcf261a76a0892
|
389ds/389-ds-base
|
Issue 4440 - BUG - ldifgen with --start-idx option fails with unsupported operand (#4444)
Bug description:
Got TypeError exception when usign:
dsctl -v slapd-localhost ldifgen users --suffix
dc=example,dc=com --parent ou=people,dc=example,dc=com
--number 100000 --generic --start-idx=50
The reason is that by default python parser provides
value for numeric options:
as an integer if specified by "--option value" or
as a string if specified by "--option=value"
Fix description:
convert the numeric parameters to integer when using it.
options impacted are:
- in users subcommand: --number , --start-idx
- in mod-load subcommand: --num-users, --add-users,
--del-users, --modrdn-users, --mod-users
FYI: An alternative solution would have been to indicate the
parser that these values are an integer. But two reasons
leaded me to implement the first solution:
- first solution fix the problem for all users while the
second one fixes only dsctl command.
- first solution is easier to test:
I just added a new test file generated by a script
that duplicated existing ldifgen test, renamed the
test cases and replaced the numeric arguments by
strings.
Second solution would need to redesign the test framework
to be able to test the parser.
relates: https://github.com/389ds/389-ds-base/issues/4440
Reviewed by:
Platforms tested: F32
|
commit 3c3e1f30cdb046a1aabb93aacebcf261a76a0892
Author: progier389 <[email protected]>
Date: Thu Nov 19 10:21:10 2020 +0100
Issue 4440 - BUG - ldifgen with --start-idx option fails with unsupported operand (#4444)
Bug description:
Got TypeError exception when usign:
dsctl -v slapd-localhost ldifgen users --suffix
dc=example,dc=com --parent ou=people,dc=example,dc=com
--number 100000 --generic --start-idx=50
The reason is that by default python parser provides
value for numeric options:
as an integer if specified by "--option value" or
as a string if specified by "--option=value"
Fix description:
convert the numeric parameters to integer when using it.
options impacted are:
- in users subcommand: --number , --start-idx
- in mod-load subcommand: --num-users, --add-users,
--del-users, --modrdn-users, --mod-users
FYI: An alternative solution would have been to indicate the
parser that these values are an integer. But two reasons
leaded me to implement the first solution:
- first solution fix the problem for all users while the
second one fixes only dsctl command.
- first solution is easier to test:
I just added a new test file generated by a script
that duplicated existing ldifgen test, renamed the
test cases and replaced the numeric arguments by
strings.
Second solution would need to redesign the test framework
to be able to test the parser.
relates: https://github.com/389ds/389-ds-base/issues/4440
Reviewed by:
Platforms tested: F32
diff --git a/dirsrvtests/tests/suites/clu/dbgen_test_usan.py b/dirsrvtests/tests/suites/clu/dbgen_test_usan.py
new file mode 100644
index 000000000..80ff63417
--- /dev/null
+++ b/dirsrvtests/tests/suites/clu/dbgen_test_usan.py
@@ -0,0 +1,806 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2020 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import time
+
+"""
+ This file contains tests similar to dbgen_test.py
+ except that paramaters that are number are expressed as string
+ (to mimic the parameters parser default behavior which returns an
+ int when parsing "option value" and a string when parsing "option=value"
+ This file has been generated by usign:
+sed '
+9r z1
+s/ test_/ test_usan/
+/args.*= [0-9]/s,[0-9]*$,"&",
+/:id:/s/.$/1/
+' dbgen_test.py > dbgen_test_usan.py
+ ( with z1 file containing this comment )
+"""
+
+
+
+import subprocess
+import pytest
+
+from lib389.cli_ctl.dbgen import *
+from lib389.cos import CosClassicDefinitions, CosPointerDefinitions, CosIndirectDefinitions, CosTemplates
+from lib389.idm.account import Accounts
+from lib389.idm.group import Groups
+from lib389.idm.role import ManagedRoles, FilteredRoles, NestedRoles
+from lib389.tasks import *
+from lib389.utils import *
+from lib389.topologies import topology_st
+from lib389.cli_base import FakeArgs
+
+pytestmark = pytest.mark.tier0
+
+LOG_FILE = '/tmp/dbgen.log'
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+
[email protected](scope="function")
+def set_log_file_and_ldif(topology_st, request):
+ global ldif_file
+ ldif_file = get_ldif_dir(topology_st.standalone) + '/created.ldif'
+
+ fh = logging.FileHandler(LOG_FILE)
+ fh.setLevel(logging.DEBUG)
+ log.addHandler(fh)
+
+ def fin():
+ log.info('Delete files')
+ os.remove(LOG_FILE)
+ os.remove(ldif_file)
+
+ request.addfinalizer(fin)
+
+
+def run_offline_import(instance, ldif_file):
+ log.info('Stopping the server and running offline import...')
+ instance.stop()
+ assert instance.ldif2db(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], encrypt=None, excludeSuffixes=None,
+ import_file=ldif_file)
+ instance.start()
+
+
+def run_ldapmodify_from_file(instance, ldif_file, output_to_check=None):
+ LDAP_MOD = '/usr/bin/ldapmodify'
+ log.info('Add entries from ldif file with ldapmodify')
+ result = subprocess.check_output([LDAP_MOD, '-cx', '-D', DN_DM, '-w', PASSWORD,
+ '-h', instance.host, '-p', str(instance.port), '-af', ldif_file])
+ if output_to_check is not None:
+ assert output_to_check in ensure_str(result)
+
+
+def check_value_in_log_and_reset(content_list):
+ with open(LOG_FILE, 'r+') as f:
+ file_content = f.read()
+ log.info('Check if content is present in output')
+ for item in content_list:
+ assert item in file_content
+
+ log.info('Reset log file for next test')
+ f.truncate(0)
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_users(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create ldif with users
+
+ :id: 426b5b94-9923-454d-a736-7e71ca985e91
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with users
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.suffix = DEFAULT_SUFFIX
+ args.parent = 'ou=people,dc=example,dc=com'
+ args.number = "1000"
+ args.rdn_cn = False
+ args.generic = True
+ args.start_idx = "50"
+ args.localize = False
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'suffix={}'.format(args.suffix),
+ 'parent={}'.format(args.parent),
+ 'number={}'.format(args.number),
+ 'rdn-cn={}'.format(args.rdn_cn),
+ 'generic={}'.format(args.generic),
+ 'start-idx={}'.format(args.start_idx),
+ 'localize={}'.format(args.localize),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create users ldif')
+ dbgen_create_users(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ log.info('Get number of accounts before import')
+ accounts = Accounts(standalone, DEFAULT_SUFFIX)
+ count_account = len(accounts.filter('(uid=*)'))
+
+ run_offline_import(standalone, ldif_file)
+
+ log.info('Check that accounts are imported')
+ assert len(accounts.filter('(uid=*)')) > count_account
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_groups(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create ldif with group
+
+ :id: 97207413-9a93-4065-a5ec-63aa93801a31
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with group
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+ LDAP_RESULT = 'adding new entry "cn=myGroup-1,ou=groups,dc=example,dc=com"'
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.NAME = 'myGroup'
+ args.parent = 'ou=groups,dc=example,dc=com'
+ args.suffix = DEFAULT_SUFFIX
+ args.number = "1"
+ args.num_members = "1000"
+ args.create_members = True
+ args.member_attr = 'uniquemember'
+ args.member_parent = 'ou=people,dc=example,dc=com'
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'NAME={}'.format(args.NAME),
+ 'number={}'.format(args.number),
+ 'suffix={}'.format(args.suffix),
+ 'num-members={}'.format(args.num_members),
+ 'create-members={}'.format(args.create_members),
+ 'member-parent={}'.format(args.member_parent),
+ 'member-attr={}'.format(args.member_attr),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create group ldif')
+ dbgen_create_groups(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ log.info('Get number of accounts before import')
+ accounts = Accounts(standalone, DEFAULT_SUFFIX)
+ count_account = len(accounts.filter('(uid=*)'))
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ # ldapmodify will complain about already existing parent which causes subprocess to return exit code != 0
+ with pytest.raises(subprocess.CalledProcessError):
+ run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)
+
+ log.info('Check that accounts are imported')
+ assert len(accounts.filter('(uid=*)')) > count_account
+
+ log.info('Check that group is imported')
+ groups = Groups(standalone, DEFAULT_SUFFIX)
+ assert groups.exists(args.NAME + '-1')
+ new_group = groups.get(args.NAME + '-1')
+ new_group.present('uniquemember', 'uid=group_entry1-0152,ou=people,dc=example,dc=com')
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_cos_classic(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create a COS definition
+
+ :id: 8557f994-8a91-4f8a-86f6-9cb826a0b8f1
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with classic COS definition
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ LDAP_RESULT = 'adding new entry "cn=My_Postal_Def,ou=cos definitions,dc=example,dc=com"'
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.type = 'classic'
+ args.NAME = 'My_Postal_Def'
+ args.parent = 'ou=cos definitions,dc=example,dc=com'
+ args.create_parent = True
+ args.cos_specifier = 'businessCategory'
+ args.cos_attr = ['postalcode', 'telephonenumber']
+ args.cos_template = 'cn=sales,cn=classicCoS,dc=example,dc=com'
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'NAME={}'.format(args.NAME),
+ 'type={}'.format(args.type),
+ 'parent={}'.format(args.parent),
+ 'create-parent={}'.format(args.create_parent),
+ 'cos-specifier={}'.format(args.cos_specifier),
+ 'cos-template={}'.format(args.cos_template),
+ 'cos-attr={}'.format(args.cos_attr),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create COS definition ldif')
+ dbgen_create_cos_def(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)
+
+ log.info('Check that COS definition is imported')
+ cos_def = CosClassicDefinitions(standalone, args.parent)
+ assert cos_def.exists(args.NAME)
+ new_cos = cos_def.get(args.NAME)
+ assert new_cos.present('cosTemplateDN', args.cos_template)
+ assert new_cos.present('cosSpecifier', args.cos_specifier)
+ assert new_cos.present('cosAttribute', args.cos_attr[0])
+ assert new_cos.present('cosAttribute', args.cos_attr[1])
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_cos_pointer(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create a COS definition
+
+ :id: 6b26ca6d-226a-4f93-925e-faf95cc20211
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with pointer COS definition
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ LDAP_RESULT = 'adding new entry "cn=My_Postal_Def_pointer,ou=cos pointer definitions,dc=example,dc=com"'
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.type = 'pointer'
+ args.NAME = 'My_Postal_Def_pointer'
+ args.parent = 'ou=cos pointer definitions,dc=example,dc=com'
+ args.create_parent = True
+ args.cos_specifier = None
+ args.cos_attr = ['postalcode', 'telephonenumber']
+ args.cos_template = 'cn=sales,cn=pointerCoS,dc=example,dc=com'
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'NAME={}'.format(args.NAME),
+ 'type={}'.format(args.type),
+ 'parent={}'.format(args.parent),
+ 'create-parent={}'.format(args.create_parent),
+ 'cos-template={}'.format(args.cos_template),
+ 'cos-attr={}'.format(args.cos_attr),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create COS definition ldif')
+ dbgen_create_cos_def(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)
+
+ log.info('Check that COS definition is imported')
+ cos_def = CosPointerDefinitions(standalone, args.parent)
+ assert cos_def.exists(args.NAME)
+ new_cos = cos_def.get(args.NAME)
+ assert new_cos.present('cosTemplateDN', args.cos_template)
+ assert new_cos.present('cosAttribute', args.cos_attr[0])
+ assert new_cos.present('cosAttribute', args.cos_attr[1])
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_cos_indirect(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create a COS definition
+
+ :id: ab4b799e-e801-432a-a61d-badad2628201
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with indirect COS definition
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ LDAP_RESULT = 'adding new entry "cn=My_Postal_Def_indirect,ou=cos indirect definitions,dc=example,dc=com"'
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.type = 'indirect'
+ args.NAME = 'My_Postal_Def_indirect'
+ args.parent = 'ou=cos indirect definitions,dc=example,dc=com'
+ args.create_parent = True
+ args.cos_specifier = 'businessCategory'
+ args.cos_attr = ['postalcode', 'telephonenumber']
+ args.cos_template = None
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'NAME={}'.format(args.NAME),
+ 'type={}'.format(args.type),
+ 'parent={}'.format(args.parent),
+ 'create-parent={}'.format(args.create_parent),
+ 'cos-specifier={}'.format(args.cos_specifier),
+ 'cos-attr={}'.format(args.cos_attr),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create COS definition ldif')
+ dbgen_create_cos_def(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)
+
+ log.info('Check that COS definition is imported')
+ cos_def = CosIndirectDefinitions(standalone, args.parent)
+ assert cos_def.exists(args.NAME)
+ new_cos = cos_def.get(args.NAME)
+ assert new_cos.present('cosIndirectSpecifier', args.cos_specifier)
+ assert new_cos.present('cosAttribute', args.cos_attr[0])
+ assert new_cos.present('cosAttribute', args.cos_attr[1])
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_cos_template(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create a COS template
+
+ :id: 544017c7-4a82-4e7d-a047-00b68a28e071
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with COS template
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ LDAP_RESULT = 'adding new entry "cn=My_Template,ou=cos templates,dc=example,dc=com"'
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.NAME = 'My_Template'
+ args.parent = 'ou=cos templates,dc=example,dc=com'
+ args.create_parent = True
+ args.cos_priority = "1"
+ args.cos_attr_val = 'postalcode:12345'
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'NAME={}'.format(args.NAME),
+ 'parent={}'.format(args.parent),
+ 'create-parent={}'.format(args.create_parent),
+ 'cos-priority={}'.format(args.cos_priority),
+ 'cos-attr-val={}'.format(args.cos_attr_val),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create COS template ldif')
+ dbgen_create_cos_tmp(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)
+
+ log.info('Check that COS template is imported')
+ cos_temp = CosTemplates(standalone, args.parent)
+ assert cos_temp.exists(args.NAME)
+ new_cos = cos_temp.get(args.NAME)
+ assert new_cos.present('cosPriority', str(args.cos_priority))
+ assert new_cos.present('postalcode', '12345')
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_managed_role(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create a managed role
+
+ :id: 10e77b41-0bc1-4ad5-a144-2c5107455b91
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with managed role
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ LDAP_RESULT = 'adding new entry "cn=My_Managed_Role,ou=managed roles,dc=example,dc=com"'
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+
+ args.NAME = 'My_Managed_Role'
+ args.parent = 'ou=managed roles,dc=example,dc=com'
+ args.create_parent = True
+ args.type = 'managed'
+ args.filter = None
+ args.role_dn = None
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'NAME={}'.format(args.NAME),
+ 'parent={}'.format(args.parent),
+ 'create-parent={}'.format(args.create_parent),
+ 'type={}'.format(args.type),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create managed role ldif')
+ dbgen_create_role(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)
+
+ log.info('Check that managed role is imported')
+ roles = ManagedRoles(standalone, DEFAULT_SUFFIX)
+ assert roles.exists(args.NAME)
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_filtered_role(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create a filtered role
+
+ :id: cb3c8ea8-4234-40e2-8810-fb6a25973921
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with filtered role
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ LDAP_RESULT = 'adding new entry "cn=My_Filtered_Role,ou=filtered roles,dc=example,dc=com"'
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+
+ args.NAME = 'My_Filtered_Role'
+ args.parent = 'ou=filtered roles,dc=example,dc=com'
+ args.create_parent = True
+ args.type = 'filtered'
+ args.filter = '"objectclass=posixAccount"'
+ args.role_dn = None
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'NAME={}'.format(args.NAME),
+ 'parent={}'.format(args.parent),
+ 'create-parent={}'.format(args.create_parent),
+ 'type={}'.format(args.type),
+ 'filter={}'.format(args.filter),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create filtered role ldif')
+ dbgen_create_role(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)
+
+ log.info('Check that filtered role is imported')
+ roles = FilteredRoles(standalone, DEFAULT_SUFFIX)
+ assert roles.exists(args.NAME)
+ new_role = roles.get(args.NAME)
+ assert new_role.present('nsRoleFilter', args.filter)
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_nested_role(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create a nested role
+
+ :id: 97fff0a8-3103-4adb-be04-2799ff58d8f1
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate ldif with nested role
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ LDAP_RESULT = 'adding new entry "cn=My_Nested_Role,ou=nested roles,dc=example,dc=com"'
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.NAME = 'My_Nested_Role'
+ args.parent = 'ou=nested roles,dc=example,dc=com'
+ args.create_parent = True
+ args.type = 'nested'
+ args.filter = None
+ args.role_dn = ['cn=some_role,ou=roles,dc=example,dc=com']
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'NAME={}'.format(args.NAME),
+ 'parent={}'.format(args.parent),
+ 'create-parent={}'.format(args.create_parent),
+ 'type={}'.format(args.type),
+ 'role-dn={}'.format(args.role_dn),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create nested role ldif')
+ dbgen_create_role(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)
+
+ log.info('Check that nested role is imported')
+ roles = NestedRoles(standalone, DEFAULT_SUFFIX)
+ assert roles.exists(args.NAME)
+ new_role = roles.get(args.NAME)
+ assert new_role.present('nsRoleDN', args.role_dn[0])
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_mod_ldif_mixed(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create mixed modification ldif
+
+ :id: 4a2e0901-2b48-452e-a4a0-507735132c81
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate modification ldif
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.parent = DEFAULT_SUFFIX
+ args.create_users = True
+ args.delete_users = True
+ args.create_parent = False
+ args.num_users = "1000"
+ args.add_users = "100"
+ args.del_users = "999"
+ args.modrdn_users = "100"
+ args.mod_users = "10"
+ args.mod_attrs = ['cn', 'uid', 'sn']
+ args.randomize = False
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'create-users={}'.format(args.create_users),
+ 'parent={}'.format(args.parent),
+ 'create-parent={}'.format(args.create_parent),
+ 'delete-users={}'.format(args.delete_users),
+ 'num-users={}'.format(args.num_users),
+ 'add-users={}'.format(args.add_users),
+ 'del-users={}'.format(args.del_users),
+ 'modrdn-users={}'.format(args.modrdn_users),
+ 'mod-users={}'.format(args.mod_users),
+ 'mod-attrs={}'.format(args.mod_attrs),
+ 'randomize={}'.format(args.randomize),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created LDIF file: {}'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create modification ldif')
+ dbgen_create_mods(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ log.info('Get number of accounts before import')
+ accounts = Accounts(standalone, DEFAULT_SUFFIX)
+ count_account = len(accounts.filter('(uid=*)'))
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ # ldapmodify will complain about a lot of changes done which causes subprocess to return exit code != 0
+ with pytest.raises(subprocess.CalledProcessError):
+ run_ldapmodify_from_file(standalone, ldif_file)
+
+ log.info('Check that some accounts are imported')
+ assert len(accounts.filter('(uid=*)')) > count_account
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Not implemented")
+def test_usandsconf_dbgen_nested_ldif(topology_st, set_log_file_and_ldif):
+ """Test ldifgen (formerly dbgen) tool to create nested ldif
+
+ :id: 9c281c28-4169-45e0-8c07-c5502d9a7581
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Run ldifgen to generate nested ldif
+ 3. Import generated ldif to database
+ 4. Check it was properly imported
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ standalone = topology_st.standalone
+
+ args = FakeArgs()
+ args.suffix = DEFAULT_SUFFIX
+ args.node_limit = "100"
+ args.num_users = "600"
+ args.ldif_file = ldif_file
+
+ content_list = ['Generating LDIF with the following options:',
+ 'suffix={}'.format(args.suffix),
+ 'node-limit={}'.format(args.node_limit),
+ 'num-users={}'.format(args.num_users),
+ 'ldif-file={}'.format(args.ldif_file),
+ 'Writing LDIF',
+ 'Successfully created nested LDIF file ({}) containing 6 nodes/subtrees'.format(args.ldif_file)]
+
+ log.info('Run ldifgen to create nested ldif')
+ dbgen_create_nested(standalone, log, args)
+
+ log.info('Check if file exists')
+ assert os.path.exists(ldif_file)
+
+ check_value_in_log_and_reset(content_list)
+
+ log.info('Get number of accounts before import')
+ accounts = Accounts(standalone, DEFAULT_SUFFIX)
+ count_account = len(accounts.filter('(uid=*)'))
+ count_ou = len(accounts.filter('(ou=*)'))
+
+ # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
+ # ldapmodify will complain about already existing suffix which causes subprocess to return exit code != 0
+ with pytest.raises(subprocess.CalledProcessError):
+ run_ldapmodify_from_file(standalone, ldif_file)
+
+ standalone.restart()
+
+ log.info('Check that accounts are imported')
+ assert len(accounts.filter('(uid=*)')) > count_account
+ assert len(accounts.filter('(ou=*)')) > count_ou
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/src/lib389/lib389/cli_ctl/dbgen.py b/src/lib389/lib389/cli_ctl/dbgen.py
index 7bc3892ba..058342fb1 100644
--- a/src/lib389/lib389/cli_ctl/dbgen.py
+++ b/src/lib389/lib389/cli_ctl/dbgen.py
@@ -451,13 +451,13 @@ def dbgen_create_mods(inst, log, args):
props = {
"createUsers": args.create_users,
"deleteUsers": args.delete_users,
- "numUsers": args.num_users,
+ "numUsers": int(args.num_users),
"parent": args.parent,
"createParent": args.create_parent,
- "addUsers": args.add_users,
- "delUsers": args.del_users,
- "modrdnUsers": args.modrdn_users,
- "modUsers": args.mod_users,
+ "addUsers": int(args.add_users),
+ "delUsers": int(args.del_users),
+ "modrdnUsers": int(args.modrdn_users),
+ "modUsers": int(args.mod_users),
"random": args.randomize,
"modAttrs": args.mod_attrs
}
diff --git a/src/lib389/lib389/dbgen.py b/src/lib389/lib389/dbgen.py
index 6273781a2..10fb200f7 100644
--- a/src/lib389/lib389/dbgen.py
+++ b/src/lib389/lib389/dbgen.py
@@ -220,6 +220,9 @@ def dbgen_users(instance, number, ldif_file, suffix, generic=False, entry_name="
"""
Generate an LDIF of randomly named entries
"""
+ # Lets insure that integer parameters are not string
+ number=int(number)
+ startIdx=int(startIdx)
familyname_file = os.path.join(instance.ds_paths.data_dir, 'dirsrv/data/dbgen-FamilyNames')
givename_file = os.path.join(instance.ds_paths.data_dir, 'dirsrv/data/dbgen-GivenNames')
familynames = []
| 0 |
a6c7241c6ce2ce3a03df59fb297fc8cc8514e549
|
389ds/389-ds-base
|
Ticket 48791 - format args in server tools
Bug Description: A crash was found during a test:
# sometimes the server fails to start - try again
> rc = os.system("%s %s" % (fullCmd))
E TypeError: not enough arguments for format string
Fix Description: Fix the parameters.
https://fedorahosted.org/389/ticket/48791
Author: wibrown
Review by: nhosoi (Thanks)
|
commit a6c7241c6ce2ce3a03df59fb297fc8cc8514e549
Author: William Brown <[email protected]>
Date: Tue Apr 12 15:42:35 2016 +1000
Ticket 48791 - format args in server tools
Bug Description: A crash was found during a test:
# sometimes the server fails to start - try again
> rc = os.system("%s %s" % (fullCmd))
E TypeError: not enough arguments for format string
Fix Description: Fix the parameters.
https://fedorahosted.org/389/ticket/48791
Author: wibrown
Review by: nhosoi (Thanks)
diff --git a/src/lib389/lib389/tools.py b/src/lib389/lib389/tools.py
index f044a6559..6068fb6e5 100644
--- a/src/lib389/lib389/tools.py
+++ b/src/lib389/lib389/tools.py
@@ -241,12 +241,12 @@ class DirSrvTools(object):
done = True
elif line.find("Initialization Failed") >= 0:
# sometimes the server fails to start - try again
- rc = os.system("%s %s" % (fullCmd))
+ rc = os.system("%s" % (fullCmd))
pos = logfp.tell()
break
elif line.find("exiting.") >= 0:
# possible transient condition - try again
- rc = os.system("%s %s" % (fullCmd))
+ rc = os.system("%s" % (fullCmd))
pos = logfp.tell()
break
pos = logfp.tell()
| 0 |
2523f487118a8740927e7662dc0a2725671c8b79
|
389ds/389-ds-base
|
Issue 50545 - Port dbmon.sh to dsconf
Description: dbmon.sh has been ported to dsconf with basically the
same feature set. i You can contiusiouly refresh the
report at a specified interval, you can choose to get
stats one multiple/specific backends, and the option
to display individual index stats. There is now a human
friendly report and a JSON version.
There was also other improvements made to lib389 to take
into account the new bdb split configuration under cn=confg.
Design Doc: https://www.port389.org/docs/389ds/design/dbmon-design.html
Relates: https://pagure.io/389-ds-base/issue/50545
Reviewed by: spichugi & firstyear (Thanks!!)
Cleanup comments about the change needed for #50189
Fix adjustment
|
commit 2523f487118a8740927e7662dc0a2725671c8b79
Author: Mark Reynolds <[email protected]>
Date: Thu Apr 2 20:59:08 2020 -0400
Issue 50545 - Port dbmon.sh to dsconf
Description: dbmon.sh has been ported to dsconf with basically the
same feature set. i You can contiusiouly refresh the
report at a specified interval, you can choose to get
stats one multiple/specific backends, and the option
to display individual index stats. There is now a human
friendly report and a JSON version.
There was also other improvements made to lib389 to take
into account the new bdb split configuration under cn=confg.
Design Doc: https://www.port389.org/docs/389ds/design/dbmon-design.html
Relates: https://pagure.io/389-ds-base/issue/50545
Reviewed by: spichugi & firstyear (Thanks!!)
Cleanup comments about the change needed for #50189
Fix adjustment
diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py
index dd44a3a21..e28c602a3 100644
--- a/src/lib389/lib389/_constants.py
+++ b/src/lib389/lib389/_constants.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2015 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -85,6 +85,7 @@ DN_SCHEMA = "cn=schema"
DN_MONITOR = "cn=monitor"
DN_MONITOR_SNMP = "cn=snmp,cn=monitor"
DN_MONITOR_LDBM = "cn=monitor,cn=ldbm database,cn=plugins,cn=config"
+DN_MONITOR_DATABASE = "cn=database,cn=monitor,cn=ldbm database,cn=plugins,cn=config"
DN_PWDSTORAGE_SCHEMES = "cn=Password Storage Schemes,cn=plugins,cn=config"
CMD_PATH_SETUP_DS = "setup-ds.pl"
diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py
index f13586ea9..e472d3de5 100644
--- a/src/lib389/lib389/backend.py
+++ b/src/lib389/lib389/backend.py
@@ -978,6 +978,7 @@ class DatabaseConfig(DSLdapObject):
'nsslapd-db-transaction-wait',
'nsslapd-db-checkpoint-interval',
'nsslapd-db-compactdb-interval',
+ 'nsslapd-db-page-size',
'nsslapd-db-transaction-batch-val',
'nsslapd-db-transaction-batch-min-wait',
'nsslapd-db-transaction-batch-max-wait',
diff --git a/src/lib389/lib389/cli_conf/monitor.py b/src/lib389/lib389/cli_conf/monitor.py
index 38490c6ad..e136cf90c 100644
--- a/src/lib389/lib389/cli_conf/monitor.py
+++ b/src/lib389/lib389/cli_conf/monitor.py
@@ -1,12 +1,13 @@
# --- BEGIN COPYRIGHT BLOCK ---
# Copyright (C) 2019 William Brown <[email protected]>
-# Copyright (C) 2019 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
+import datetime
import json
from lib389.monitor import (Monitor, MonitorLDBM, MonitorSNMP, MonitorDiskSpace)
from lib389.chaining import (ChainingLinks)
@@ -30,8 +31,6 @@ def backend_monitor(inst, basedn, log, args):
for be in bes.list():
be_monitor = be.get_monitor()
_format_status(log, be_monitor, args.json)
- # Inejct a new line for now ... see https://pagure.io/389-ds-base/issue/50189
- log.info("")
def ldbm_monitor(inst, basedn, log, args):
@@ -57,6 +56,7 @@ def chaining_monitor(inst, basedn, log, args):
# Inject a new line for now ... see https://pagure.io/389-ds-base/issue/50189
log.info("")
+
def disk_monitor(inst, basedn, log, args):
disk_space_mon = MonitorDiskSpace(inst)
disks = disk_space_mon.get_disks()
@@ -88,6 +88,204 @@ def disk_monitor(inst, basedn, log, args):
log.info(json.dumps({"type": "list", "items": disk_list}, indent=4))
+def db_monitor(inst, basedn, log, args):
+ """Report on all the database statistics
+ """
+ ldbm_monitor = MonitorLDBM(inst)
+ backends_obj = Backends(inst)
+ backend_objs = []
+ args_backends = None
+
+ # Gather all the backends
+ if args.backends is not None:
+ # This is a space separated list, it could be backend names or suffixes
+ args_backends = args.backends.lower().split()
+
+ for be in backends_obj.list():
+ if args_backends is not None:
+ for arg_be in args_backends:
+ if '=' in arg_be:
+ # We have a suffix
+ if arg_be == be.get_suffix():
+ backend_objs.append(be)
+ break
+ else:
+ # We have a backend name
+ if arg_be == be.rdn.lower():
+ backend_objs.append(be)
+ break
+ else:
+ # Get all the backends
+ backend_objs.append(be)
+
+ if args_backends is not None and len(backend_objs) == 0:
+ raise ValueError("Could not find any backends from the provided list: {}".format(args.backends))
+
+ # Gather the global DB stats
+ report_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ ldbm_mon = ldbm_monitor.get_status()
+ dbcachesize = int(ldbm_mon['nsslapd-db-cache-size-bytes'][0])
+ if 'nsslapd-db-page-size' in ldbm_mon:
+ pagesize = int(ldbm_mon['nsslapd-db-page-size'][0])
+ else:
+ pagesize = 8 * 1024 # Taken from DBLAYER_PAGESIZE
+ dbhitratio = ldbm_mon['dbcachehitratio'][0]
+ dbcachepagein = ldbm_mon['dbcachepagein'][0]
+ dbcachepageout = ldbm_mon['dbcachepageout'][0]
+ dbroevict = ldbm_mon['nsslapd-db-page-ro-evict-rate'][0]
+ dbpages = int(ldbm_mon['nsslapd-db-pages-in-use'][0])
+ dbcachefree = int(dbcachesize - (pagesize * dbpages))
+ dbcachefreeratio = dbcachefree/dbcachesize
+ ndnratio = ldbm_mon['normalizeddncachehitratio'][0]
+ ndncursize = int(ldbm_mon['currentnormalizeddncachesize'][0])
+ ndnmaxsize = int(ldbm_mon['maxnormalizeddncachesize'][0])
+ ndncount = ldbm_mon['currentnormalizeddncachecount'][0]
+ ndnevictions = ldbm_mon['normalizeddncacheevictions'][0]
+ if ndncursize > ndnmaxsize:
+ ndnfree = 0
+ ndnfreeratio = 0
+ else:
+ ndnfree = ndnmaxsize - ndncursize
+ ndnfreeratio = "{:.1f}".format(ndnfree / ndnmaxsize * 100)
+
+ # Build global cache stats
+ result = {
+ 'date': report_time,
+ 'dbcache': {
+ 'hit_ratio': dbhitratio,
+ 'free': convert_bytes(str(dbcachefree)),
+ 'free_percentage': "{:.1f}".format(dbcachefreeratio * 100),
+ 'roevicts': dbroevict,
+ 'pagein': dbcachepagein,
+ 'pageout': dbcachepageout
+ },
+ 'ndncache': {
+ 'hit_ratio': ndnratio,
+ 'free': convert_bytes(str(ndnfree)),
+ 'free_percentage': ndnfreeratio,
+ 'count': ndncount,
+ 'evictions': ndnevictions
+ },
+ 'backends': {},
+ }
+
+ # Build the backend results
+ for be in backend_objs:
+ be_name = be.rdn
+ be_suffix = be.get_suffix()
+ monitor = be.get_monitor()
+ all_attrs = monitor.get_status()
+
+ # Process entry cache stats
+ entcur = int(all_attrs['currententrycachesize'][0])
+ entmax = int(all_attrs['maxentrycachesize'][0])
+ entcnt = int(all_attrs['currententrycachecount'][0])
+ entratio = all_attrs['entrycachehitratio'][0]
+ entfree = entmax - entcur
+ entfreep = "{:.1f}".format(entfree / entmax * 100)
+ if entcnt == 0:
+ entsize = 0
+ else:
+ entsize = int(entcur / entcnt)
+
+ # Process DN cache stats
+ dncur = int(all_attrs['currentdncachesize'][0])
+ dnmax = int(all_attrs['maxdncachesize'][0])
+ dncnt = int(all_attrs['currentdncachecount'][0])
+ dnratio = all_attrs['dncachehitratio'][0]
+ dnfree = dnmax - dncur
+ dnfreep = "{:.1f}".format(dnfree / dnmax * 100)
+ if dncnt == 0:
+ dnsize = 0
+ else:
+ dnsize = int(dncur / dncnt)
+
+ # Build the backend result
+ result['backends'][be_name] = {
+ 'suffix': be_suffix,
+ 'entry_cache_count': all_attrs['currententrycachecount'][0],
+ 'entry_cache_free': convert_bytes(str(entfree)),
+ 'entry_cache_free_percentage': entfreep,
+ 'entry_cache_size': convert_bytes(str(entsize)),
+ 'entry_cache_hit_ratio': entratio,
+ 'dn_cache_count': all_attrs['currentdncachecount'][0],
+ 'dn_cache_free': convert_bytes(str(dnfree)),
+ 'dn_cache_free_percentage': dnfreep,
+ 'dn_cache_size': convert_bytes(str(dnsize)),
+ 'dn_cache_hit_ratio': dnratio,
+ 'indexes': []
+ }
+
+ # Process indexes if requested
+ if args.indexes:
+ index = {}
+ index_name = ''
+ for attr, val in all_attrs.items():
+ if attr.startswith('dbfile'):
+ if attr.startswith("dbfilename-"):
+ if index_name != '':
+ # Update backend index list
+ result['backends'][be_name]['indexes'].append(index)
+ index_name = val[0].split('/')[1]
+ index = {'name': index_name}
+ elif attr.startswith('dbfilecachehit-'):
+ index['cachehit'] = val[0]
+ elif attr.startswith('dbfilecachemiss-'):
+ index['cachemiss'] = val[0]
+ elif attr.startswith('dbfilepagein-'):
+ index['pagein'] = val[0]
+ elif attr.startswith('dbfilepageout-'):
+ index['pageout'] = val[0]
+ if index_name != '':
+ # Update backend index list
+ result['backends'][be_name]['indexes'].append(index)
+
+ # Return the report
+ if args.json:
+ log.info(json.dumps(result, indent=4))
+ else:
+ log.info("DB Monitor Report: " + result['date'])
+ log.info("--------------------------------------------------------")
+ log.info("Database Cache:")
+ log.info(" - Cache Hit Ratio: {}%".format(result['dbcache']['hit_ratio']))
+ log.info(" - Free Space: {}".format(result['dbcache']['free']))
+ log.info(" - Free Percentage: {}%".format(result['dbcache']['free_percentage']))
+ log.info(" - RO Page Drops: {}".format(result['dbcache']['roevicts']))
+ log.info(" - Pages In: {}".format(result['dbcache']['pagein']))
+ log.info(" - Pages Out: {}".format(result['dbcache']['pageout']))
+ log.info("")
+ log.info("Normalized DN Cache:")
+ log.info(" - Cache Hit Ratio: {}%".format(result['ndncache']['hit_ratio']))
+ log.info(" - Free Space: {}".format(result['ndncache']['free']))
+ log.info(" - Free Percentage: {}%".format(result['ndncache']['free_percentage']))
+ log.info(" - DN Count: {}".format(result['ndncache']['count']))
+ log.info(" - Evictions: {}".format(result['ndncache']['evictions']))
+ log.info("")
+ log.info("Backends:")
+ for be_name, attr_dict in result['backends'].items():
+ log.info(f" - {attr_dict['suffix']} ({be_name}):")
+ log.info(" - Entry Cache Hit Ratio: {}%".format(attr_dict['entry_cache_hit_ratio']))
+ log.info(" - Entry Cache Count: {}".format(attr_dict['entry_cache_count']))
+ log.info(" - Entry Cache Free Space: {}".format(attr_dict['entry_cache_free']))
+ log.info(" - Entry Cache Free Percentage: {}%".format(attr_dict['entry_cache_free_percentage']))
+ log.info(" - Entry Cache Average Size: {}".format(attr_dict['entry_cache_size']))
+ log.info(" - DN Cache Hit Ratio: {}%".format(attr_dict['dn_cache_hit_ratio']))
+ log.info(" - DN Cache Count: {}".format(attr_dict['dn_cache_count']))
+ log.info(" - DN Cache Free Space: {}".format(attr_dict['dn_cache_free']))
+ log.info(" - DN Cache Free Percentage: {}%".format(attr_dict['dn_cache_free_percentage']))
+ log.info(" - DN Cache Average Size: {}".format(attr_dict['dn_cache_size']))
+ if len(result['backends'][be_name]['indexes']) > 0:
+ log.info(" - Indexes:")
+ for index in result['backends'][be_name]['indexes']:
+ log.info(" - Index: {}".format(index['name']))
+ log.info(" - Cache Hit: {}".format(index['cachehit']))
+ log.info(" - Cache Miss: {}".format(index['cachemiss']))
+ log.info(" - Page In: {}".format(index['pagein']))
+ log.info(" - Page Out: {}".format(index['pageout']))
+ log.info("")
+ log.info("")
+
+
def create_parser(subparsers):
monitor_parser = subparsers.add_parser('monitor', help="Monitor the state of the instance")
subcommands = monitor_parser.add_subparsers(help='action')
@@ -95,10 +293,16 @@ def create_parser(subparsers):
server_parser = subcommands.add_parser('server', help="Monitor the server statistics, connections and operations")
server_parser.set_defaults(func=monitor)
+ dbmon_parser = subcommands.add_parser('dbmon', help="Monitor the all the database statistics in a single report")
+ dbmon_parser.set_defaults(func=db_monitor)
+ dbmon_parser.add_argument('-i', '--incr', type=int, help="Keep refreshing the report every N seconds")
+ dbmon_parser.add_argument('-b', '--backends', help="List of space separated backends to monitor. Default is all backends.")
+ dbmon_parser.add_argument('-x', '--indexes', action='store_true', default=False, help="Show index stats for each backend")
+
ldbm_parser = subcommands.add_parser('ldbm', help="Monitor the ldbm statistics, such as dbcache")
ldbm_parser.set_defaults(func=ldbm_monitor)
- backend_parser = subcommands.add_parser('backend', help="Monitor the behaviour of a backend database")
+ backend_parser = subcommands.add_parser('backend', help="Monitor the behavior of a backend database")
backend_parser.add_argument('backend', nargs='?', help="Optional name of the backend to monitor")
backend_parser.set_defaults(func=backend_monitor)
diff --git a/src/lib389/lib389/config.py b/src/lib389/lib389/config.py
index becfccb72..a29d0244c 100644
--- a/src/lib389/lib389/config.py
+++ b/src/lib389/lib389/config.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2019 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -504,7 +504,7 @@ class BDB_LDBMConfig(DSLdapObject):
def __init__(self, conn):
super(BDB_LDBMConfig, self).__init__(instance=conn)
self._dn = DN_CONFIG_LDBM_BDB
- config_compare_exclude = []
+ self._config_compare_exclude = []
self._rdn_attribute = 'cn'
self._lint_functions = []
self._protected = True
diff --git a/src/lib389/lib389/monitor.py b/src/lib389/lib389/monitor.py
index cfaacff48..73750c3c2 100644
--- a/src/lib389/lib389/monitor.py
+++ b/src/lib389/lib389/monitor.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2019 Red Hat, Inc.
+# Copyright (C) 2020 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -107,9 +107,15 @@ class Monitor(DSLdapObject):
class MonitorLDBM(DSLdapObject):
+ """An object that helps reading the global database statistics.
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: not used
+ """
def __init__(self, instance, dn=None):
super(MonitorLDBM, self).__init__(instance=instance)
self._dn = DN_MONITOR_LDBM
+ self._db_mon = MonitorDatabase(instance)
self._backend_keys = [
'dbcachehits',
'dbcachetries',
@@ -119,6 +125,42 @@ class MonitorLDBM(DSLdapObject):
'dbcacheroevict',
'dbcacherwevict',
]
+ self._db_mon_keys = [
+ 'nsslapd-db-abort-rate',
+ 'nsslapd-db-active-txns',
+ 'nsslapd-db-cache-hit',
+ 'nsslapd-db-cache-try',
+ 'nsslapd-db-cache-region-wait-rate',
+ 'nsslapd-db-cache-size-bytes',
+ 'nsslapd-db-clean-pages',
+ 'nsslapd-db-commit-rate',
+ 'nsslapd-db-deadlock-rate',
+ 'nsslapd-db-dirty-pages',
+ 'nsslapd-db-hash-buckets',
+ 'nsslapd-db-hash-elements-examine-rate',
+ 'nsslapd-db-hash-search-rate',
+ 'nsslapd-db-lock-conflicts',
+ 'nsslapd-db-lock-region-wait-rate',
+ 'nsslapd-db-lock-request-rate',
+ 'nsslapd-db-lockers',
+ 'nsslapd-db-configured-locks',
+ 'nsslapd-db-current-locks',
+ 'nsslapd-db-max-locks',
+ 'nsslapd-db-current-lock-objects',
+ 'nsslapd-db-max-lock-objects',
+ 'nsslapd-db-log-bytes-since-checkpoint',
+ 'nsslapd-db-log-region-wait-rate',
+ 'nsslapd-db-log-write-rate',
+ 'nsslapd-db-longest-chain-length',
+ 'nsslapd-db-page-create-rate',
+ 'nsslapd-db-page-read-rate',
+ 'nsslapd-db-page-ro-evict-rate',
+ 'nsslapd-db-page-rw-evict-rate',
+ 'nsslapd-db-page-trickle-rate',
+ 'nsslapd-db-page-write-rate',
+ 'nsslapd-db-pages-in-use',
+ 'nsslapd-db-txn-region-wait-rate',
+ ]
if not ds_is_older("1.4.0", instance=instance):
self._backend_keys.extend([
'normalizeddncachetries',
@@ -133,6 +175,58 @@ class MonitorLDBM(DSLdapObject):
'normalizeddncachethreadslots'
])
+ def get_status(self, use_json=False):
+ ldbm_dict = self.get_attrs_vals_utf8(self._backend_keys)
+ db_dict = self._db_mon.get_attrs_vals_utf8(self._db_mon_keys)
+ return {**ldbm_dict, **db_dict}
+
+
+class MonitorDatabase(DSLdapObject):
+ """An object that helps reading the global libdb(bdb) statistics.
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: not used
+ """
+ def __init__(self, instance, dn=None):
+ super(MonitorDatabase, self).__init__(instance=instance)
+ self._dn = DN_MONITOR_DATABASE
+ self._backend_keys = [
+ 'nsslapd-db-abort-rate',
+ 'nsslapd-db-active-txns',
+ 'nsslapd-db-cache-hit',
+ 'nsslapd-db-cache-try',
+ 'nsslapd-db-cache-region-wait-rate',
+ 'nsslapd-db-cache-size-bytes',
+ 'nsslapd-db-clean-pages',
+ 'nsslapd-db-commit-rate',
+ 'nsslapd-db-deadlock-rate',
+ 'nsslapd-db-dirty-pages',
+ 'nsslapd-db-hash-buckets',
+ 'nsslapd-db-hash-elements-examine-rate',
+ 'nsslapd-db-hash-search-rate',
+ 'nsslapd-db-lock-conflicts',
+ 'nsslapd-db-lock-region-wait-rate',
+ 'nsslapd-db-lock-request-rate',
+ 'nsslapd-db-lockers',
+ 'nsslapd-db-configured-locks',
+ 'nsslapd-db-current-locks',
+ 'nsslapd-db-max-locks',
+ 'nsslapd-db-current-lock-objects',
+ 'nsslapd-db-max-lock-objects',
+ 'nsslapd-db-log-bytes-since-checkpoint',
+ 'nsslapd-db-log-region-wait-rate',
+ 'nsslapd-db-log-write-rate',
+ 'nsslapd-db-longest-chain-length',
+ 'nsslapd-db-page-create-rate',
+ 'nsslapd-db-page-read-rate',
+ 'nsslapd-db-page-ro-evict-rate',
+ 'nsslapd-db-page-rw-evict-rate',
+ 'nsslapd-db-page-trickle-rate',
+ 'nsslapd-db-page-write-rate',
+ 'nsslapd-db-pages-in-use',
+ 'nsslapd-db-txn-region-wait-rate',
+ ]
+
def get_status(self, use_json=False):
return self.get_attrs_vals_utf8(self._backend_keys)
@@ -172,10 +266,18 @@ class MonitorBackend(DSLdapObject):
'currentnormalizeddncachecount'
])
- # Issue: get status should return a dict and the called should be
- # formatting it. See: https://pagure.io/389-ds-base/issue/50189
def get_status(self, use_json=False):
- return self.get_attrs_vals_utf8(self._backend_keys)
+ result = {}
+ all_attrs = self.get_all_attrs_utf8()
+ for attr in self._backend_keys:
+ result[attr] = all_attrs[attr]
+
+ # Now gather all the dbfile* attributes
+ for attr, val in all_attrs.items():
+ if attr.startswith('dbfile'):
+ result[attr] = val
+
+ return result
class MonitorChaining(DSLdapObject):
| 0 |
9c41a365e8fbd23cab28eb91f50cdce696a30730
|
389ds/389-ds-base
|
Ticket 47620 - Unable to delete protocol timeout attribute
Bug Description: Attempting to delete nsds5ReplicaProtocolTimeout from a replication
agreement unexpectedly fails with an error 53.
Fix Description: The previous delete operation check was in the wrong location, and the
delete operation was treated as a modify - which then triggered the
error 53. Added the correct check for the delete operation.
Also removed some old code for a CLEANALLRUV attribute that was never
implemented.
https://fedorahosted.org/389/ticket/47620
Reviewed by: nhosoi(Thanks!)
|
commit 9c41a365e8fbd23cab28eb91f50cdce696a30730
Author: Mark Reynolds <[email protected]>
Date: Fri Jan 17 15:13:21 2014 -0500
Ticket 47620 - Unable to delete protocol timeout attribute
Bug Description: Attempting to delete nsds5ReplicaProtocolTimeout from a replication
agreement unexpectedly fails with an error 53.
Fix Description: The previous delete operation check was in the wrong location, and the
delete operation was treated as a modify - which then triggered the
error 53. Added the correct check for the delete operation.
Also removed some old code for a CLEANALLRUV attribute that was never
implemented.
https://fedorahosted.org/389/ticket/47620
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 49d83d53d..716da32b4 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -167,7 +167,6 @@ extern const char *type_nsds5ReplicaBusyWaitTime;
extern const char *type_nsds5ReplicaSessionPauseTime;
extern const char *type_nsds5ReplicaEnabled;
extern const char *type_nsds5ReplicaStripAttrs;
-extern const char *type_nsds5ReplicaCleanRUVnotified;
extern const char *type_replicaProtocolTimeout;
extern const char *type_replicaBackoffMin;
extern const char *type_replicaBackoffMax;
diff --git a/ldap/servers/plugins/replication/repl5_agmtlist.c b/ldap/servers/plugins/replication/repl5_agmtlist.c
index 334f8a1bb..53c12a93a 100644
--- a/ldap/servers/plugins/replication/repl5_agmtlist.c
+++ b/ldap/servers/plugins/replication/repl5_agmtlist.c
@@ -254,15 +254,6 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
the replication plugin - handled above */
if (mods[i]->mod_op & LDAP_MOD_DELETE)
{
- if(strcasecmp (mods[i]->mod_type, type_nsds5ReplicaCleanRUVnotified) == 0 ){
- /* allow the deletion of cleanallruv agmt attr */
- continue;
- }
- if(strcasecmp (mods[i]->mod_type, type_replicaProtocolTimeout) == 0){
- agmt_set_protocol_timeout(agmt, 0);
- continue;
- }
-
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: "
"deletion of %s attribute is not allowed\n", type_nsds5ReplicaInitialize);
*returncode = LDAP_UNWILLING_TO_PERFORM;
@@ -514,23 +505,30 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
}
}
else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_replicaProtocolTimeout)){
- long ptimeout = 0;
-
- if (val){
- ptimeout = atol(val);
+ if (mods[i]->mod_op & LDAP_MOD_DELETE)
+ {
+ agmt_set_protocol_timeout(agmt, 0);
}
- if(ptimeout <= 0){
- *returncode = LDAP_UNWILLING_TO_PERFORM;
- PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
- type_replicaProtocolTimeout, val ? val : "");
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "attribute %s value (%s) is invalid, "
- "must be a number greater than zero.\n",
- type_replicaProtocolTimeout, val ? val : "");
- rc = SLAPI_DSE_CALLBACK_ERROR;
- break;
+ else
+ {
+ long ptimeout = 0;
+
+ if (val){
+ ptimeout = atol(val);
+ }
+ if(ptimeout <= 0){
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
+ type_replicaProtocolTimeout, val ? val : "");
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "attribute %s value (%s) is invalid, "
+ "must be a number greater than zero.\n",
+ type_replicaProtocolTimeout, val ? val : "");
+ rc = SLAPI_DSE_CALLBACK_ERROR;
+ break;
+ }
+ agmt_set_protocol_timeout(agmt, ptimeout);
}
- agmt_set_protocol_timeout(agmt, ptimeout);
}
else if (0 == windows_handle_modify_agreement(agmt, mods[i]->mod_type, e))
{
diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c
index ee09e4982..68891a193 100644
--- a/ldap/servers/plugins/replication/repl_globals.c
+++ b/ldap/servers/plugins/replication/repl_globals.c
@@ -134,7 +134,6 @@ const char *type_nsds5ReplicaBusyWaitTime = "nsds5ReplicaBusyWaitTime";
const char *type_nsds5ReplicaSessionPauseTime = "nsds5ReplicaSessionPauseTime";
const char *type_nsds5ReplicaEnabled = "nsds5ReplicaEnabled";
const char *type_nsds5ReplicaStripAttrs = "nsds5ReplicaStripAttrs";
-const char *type_nsds5ReplicaCleanRUVnotified = "nsds5ReplicaCleanRUVNotified";
/* windows sync specific attributes */
const char *type_nsds7WindowsReplicaArea = "nsds7WindowsReplicaSubtree";
| 0 |
4b8b470f064fb676c7794d6d557b82276754e7cb
|
389ds/389-ds-base
|
Ticket 50122 - Fix incorrect path spec
Bug Description: Due to human error, I missed a path spec in
a change I made
Fix Description: Fix the path
https://pagure.io/389-ds-base/issue/50122
Author: William Brown <[email protected]>
Review by: ???
|
commit 4b8b470f064fb676c7794d6d557b82276754e7cb
Author: William Brown <[email protected]>
Date: Thu Jan 10 11:07:13 2019 +1000
Ticket 50122 - Fix incorrect path spec
Bug Description: Due to human error, I missed a path spec in
a change I made
Fix Description: Fix the path
https://pagure.io/389-ds-base/issue/50122
Author: William Brown <[email protected]>
Review by: ???
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index cb0244cfe..c06b3bced 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -191,9 +191,9 @@ def selinux_restorecon(path):
return
try:
- selinux.restorecon(slapd[path], recursive=True)
+ selinux.restorecon(path, recursive=True)
except:
- log.debug("Failed to run restorecon on: " + slapd[path])
+ log.debug("Failed to run restorecon on: " + path)
def selinux_label_port(port, remove_label=False):
"""
| 0 |
aea218c41961502b1cbdfc4c082ed494db6a49a7
|
389ds/389-ds-base
|
Bug 727511 - ldclt SSL search requests are failing with "illegal error number -1" error
https://bugzilla.redhat.com/show_bug.cgi?id=727511
Resolves: bug 727511
Bug Description: ldclt SSL search requests are failing with "illegal error number -1" error
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: Make all code in ldclt use the same function for creating
and binding to an LDAP*. Add code to initialize TLS/SSL when using openldap.
If using cert client auth, add code to authenticate to the token using the
given password.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit aea218c41961502b1cbdfc4c082ed494db6a49a7
Author: Rich Megginson <[email protected]>
Date: Wed Aug 3 12:04:52 2011 -0600
Bug 727511 - ldclt SSL search requests are failing with "illegal error number -1" error
https://bugzilla.redhat.com/show_bug.cgi?id=727511
Resolves: bug 727511
Bug Description: ldclt SSL search requests are failing with "illegal error number -1" error
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: Make all code in ldclt use the same function for creating
and binding to an LDAP*. Add code to initialize TLS/SSL when using openldap.
If using cert client auth, add code to authenticate to the token using the
given password.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 317628c12..7123a1a84 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -261,6 +261,11 @@ dd/mm/yy | Author | Comments
#endif
#include <prprf.h>
+#include <plstr.h>
+#include <nspr.h>
+#include <nss.h>
+#include <ssl.h>
+#include <pk11pub.h>
#define LDCLT_DEREF_ATTR "secretary"
int ldclt_create_deref_control( LDAP *ld, char *derefAttr, char **attrs, LDAPControl **ctrlp );
@@ -598,211 +603,266 @@ referralSetup (
-
/* ****************************************************************************
- FUNCTION : connectToServer
- PURPOSE : Realise the connection to the server.
- If requested by the user, it also realize the
- disconnection prior to connect.
- INPUT : tttctx = this thread's thread_context
- OUTPUT : None.
- RETURN : -1 if error, 0 else.
- DESCRIPTION :
+ FUNCTION : dirname
+ PURPOSE : given a relative or absolute path name, return
+ the name of the directory containing the path
+ INPUT : path
+ OUTPUT : none
+ RETURN : directory part of path or "."
+ DESCRIPTION : caller must free return value when done
*****************************************************************************/
-int
-connectToServer (
- thread_context *tttctx)
+static char *
+ldclt_dirname(const char *path) {
+ char sep = PR_GetDirectorySeparator();
+ char *ptr = NULL;
+ char *ret = NULL;
+ if (path && ((ptr = strrchr(path, sep))) && *(ptr+1)) {
+ ret = PL_strndup(path, ptr-path);
+ } else {
+ ret = PL_strdup(".");
+ }
+
+ return ret;
+}
+
+static char *
+ldclt_get_sec_pwd(PK11SlotInfo *slot, PRBool retry, void *arg)
{
- int ret; /* Return value */
- LBER_SOCKET fd; /* LDAP cnx's fd */
- int v2v3; /* LDAP version used */
- struct berval cred = {0, NULL};
+ char *pwd = (char *)arg;
+ return PL_strdup(pwd);
+}
- /*
- * Maybe close the connection ?
- * We will do this *here* to keep the cnx the longest time open.
- */
- if ((mctx.mode & BIND_EACH_OPER) && (tttctx->ldapCtx != NULL))
- {
- /*
- * Maybe the user want the connection to be *closed* rather than
- * being kindly unbinded ?
- */
- if (mctx.mode & CLOSE_FD)
- {
- /*
- * Get the corresponding fd
- */
-#ifdef WORKAROUND_4197228
- if (getFdFromLdapSession (tttctx->ldapCtx, &fd) < 0)
- {
- printf ("ldclt[%d]: T%03d: Cannot extract fd from ldap session\n",
- mctx.pid, tttctx->thrdNum);
- fflush (stdout);
- return (-1);
- }
-#else
- ret = ldap_get_option (tttctx->ldapCtx, LDAP_OPT_DESC, &fd);
- if (ret < 0)
- {
- printf ("ldclt[%d]: T%03d: Cannot ldap_get_option(LDAP_OPT_DESC)\n",
- mctx.pid, tttctx->thrdNum);
- fflush (stdout);
- return (-1);
- }
-#endif
-#ifdef TRACE_FD_GET_OPTION_BUG
- printf ("ldclt[%d]: T%03d: fd=%d\n", mctx.pid, tttctx->thrdNum, (int)fd);
-#endif
- if (close ((int)fd) < 0)
- {
- perror ("ldctx");
- printf ("ldclt[%d]: T%03d: cannot close(fd=%d), error=%d (%s)\n",
- mctx.pid, tttctx->thrdNum, (int)fd, errno, strerror (errno));
- return (-1);
- }
- }
+static int
+ldclt_clientauth(thread_context *tttctx, const char *path, const char *certname, const char *pwd)
+{
+ const char *colon = NULL;
+ char *token_name = NULL;
+ PK11SlotInfo *slot = NULL;
+ int rc = 0;
+
+ rc = NSS_Initialize(path, "", "", SECMOD_DB, NSS_INIT_READONLY);
+ if (rc != SECSuccess) {
+ printf ("ldclt[%d]: T%03d: Cannot NSS_Initialize(%s) %d\n",
+ mctx.pid, tttctx->thrdNum, path, PR_GetError());
+ fflush(stdout);
+ goto done;
+ }
- /*
- * Ok, anyway, we must ldap_unbind() to release our contextes
- * at the client side, otherwise this process will rocket through
- * the ceiling.
- * But don't be afraid, the UNBIND operation never reach the
- * server that will only see a suddent socket disconnection.
- */
- ret = ldap_unbind_ext (tttctx->ldapCtx, NULL, NULL);
- if (ret != LDAP_SUCCESS)
- {
- fprintf (stderr, "ldclt[%d]: T%03d: cannot ldap_unbind(), error=%d (%s)\n",
- mctx.pid, tttctx->thrdNum, ret,strerror (ret));
- fflush (stderr);
- if (addErrorStat (ret) < 0)
- return (-1);
- return (-1);
- }
- tttctx->ldapCtx = NULL;
+ if ((colon = PL_strchr(certname, ':' ))) {
+ token_name = PL_strndup(certname, colon-certname);
}
- /*
- * Maybe create the LDAP context ?
- */
- if (tttctx->ldapCtx == NULL)
- {
- const char *mech = LDAP_SASL_SIMPLE;
- const char *binddn = NULL;
- const char *passwd = NULL;
+ if (token_name) {
+ slot = PK11_FindSlotByName(token_name);
+ } else {
+ slot = PK11_GetInternalKeySlot();
+ }
+
+ if (!slot) {
+ printf ("ldclt[%d]: T%03d: Cannot find slot for token %s - %d\n",
+ mctx.pid, tttctx->thrdNum,
+ token_name ? token_name : "internal", PR_GetError());
+ fflush(stdout);
+ goto done;
+ }
+
+ NSS_SetDomesticPolicy();
+
+ PK11_SetPasswordFunc(ldclt_get_sec_pwd);
+
+ rc = PK11_Authenticate(slot, PR_FALSE, (void *)pwd);
+ if (rc != SECSuccess) {
+ printf ("ldclt[%d]: T%03d: Cannot authenticate to token %s - %d\n",
+ mctx.pid, tttctx->thrdNum,
+ token_name ? token_name : "internal", PR_GetError());
+ fflush(stdout);
+ goto done;
+ }
+
+ if ((rc = ldap_set_option(tttctx->ldapCtx, LDAP_OPT_X_TLS_CERTFILE, certname))) {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(ld, LDAP_OPT_X_CERTFILE, %s), errno=%d ldaperror=%d:%s\n",
+ mctx.pid, tttctx->thrdNum, certname, errno, rc, my_ldap_err2string(rc));
+ fflush (stdout);
+ goto done;
+ }
+
+ if ((rc = ldap_set_option(tttctx->ldapCtx, LDAP_OPT_X_TLS_KEYFILE, pwd))) {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(ld, LDAP_OPT_X_KEYFILE, %s), errno=%d ldaperror=%d:%s\n",
+ mctx.pid, tttctx->thrdNum, pwd, errno, rc, my_ldap_err2string(rc));
+ fflush (stdout);
+ goto done;
+ }
+
+done:
+ PL_strfree(token_name);
+ if (slot) {
+ PK11_FreeSlot(slot);
+ }
+
+ return rc;
+}
+
+/* mctx is a global */
+LDAP *
+connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2)
+{
+ LDAP *ld = NULL;
+ const char *mech = LDAP_SASL_SIMPLE;
+ struct berval cred = {0, NULL};
+ int v2v3 = LDAP_VERSION3;
+ const char *binddn = NULL;
+ const char *passwd = NULL;
#if defined(USE_OPENLDAP)
- char *ldapurl = NULL;
+ char *ldapurl = NULL;
#endif
+ int thrdNum = 0;
+ int ret = -1;
+ int binded = 0;
+
+ if (tttctx) {
+ thrdNum = tttctx->thrdNum;
+ }
#if defined(USE_OPENLDAP)
- ldapurl = PR_smprintf("ldap%s://%s:%d/",
- (mctx.mode & SSL) ? "s" : "",
- mctx.hostname, mctx.port);
- if ((ret = ldap_initialize(&tttctx->ldapCtx, ldapurl))) {
- printf ("ldclt[%d]: T%03d: Cannot ldap_initialize (%s), errno=%d ldaperror=%d:%s\n",
- mctx.pid, tttctx->thrdNum, ldapurl, errno, ret, my_ldap_err2string(ret));
- fflush (stdout);
- PR_smprintf_free(ldapurl);
- return (-1);
+ ldapurl = PR_smprintf("ldap%s://%s:%d/",
+ (mode & SSL) ? "s" : "",
+ mctx.hostname, mctx.port);
+ if ((ret = ldap_initialize(&ld, ldapurl))) {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_initialize (%s), errno=%d ldaperror=%d:%s\n",
+ mctx.pid, thrdNum, ldapurl, errno, ret, my_ldap_err2string(ret));
+ fflush (stdout);
+ goto done;
+ }
+ PR_smprintf_free(ldapurl);
+ ldapurl = NULL;
+ if (mode & SSL) {
+ int optval = 0;
+ /* bad, but looks like the tools expect to be able to use an ip address
+ for the hostname, so have to defeat fqdn checking in cn of subject of server cert */
+ int ssl_strength = LDAP_OPT_X_TLS_NEVER;
+ char *certdir = ldclt_dirname(mctx.certfile);
+ if ((ret = ldap_set_option(ld, LDAP_OPT_X_TLS_NEWCTX, &optval))) {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(ld, LDAP_OPT_X_TLS_NEWCTX), errno=%d ldaperror=%d:%s\n",
+ mctx.pid, thrdNum, errno, ret, my_ldap_err2string(ret));
+ fflush (stdout);
+ free(certdir);
+ goto done;
}
- PR_smprintf_free(ldapurl);
- ldapurl = NULL;
+ if ((ret = ldap_set_option(ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &ssl_strength))) {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(ld, LDAP_OPT_X_TLS_REQUIRE_CERT), errno=%d ldaperror=%d:%s\n",
+ mctx.pid, thrdNum, errno, ret, my_ldap_err2string(ret));
+ fflush (stdout);
+ free(certdir);
+ goto done;
+ }
+ /* tell it where our cert db is */
+ if ((ret = ldap_set_option(ld, LDAP_OPT_X_TLS_CACERTDIR, certdir))) {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(ld, LDAP_OPT_X_CACERTDIR, %s), errno=%d ldaperror=%d:%s\n",
+ mctx.pid, thrdNum, certdir, errno, ret, my_ldap_err2string(ret));
+ fflush (stdout);
+ free(certdir);
+ goto done;
+ }
+ if ((mode & CLTAUTH) &&
+ (ret = ldclt_clientauth(tttctx, certdir, mctx.cltcertname, mctx.keydbpin))) {
+ free(certdir);
+ goto done;
+ }
+ free(certdir);
+ }
#else /* !USE_OPENLDAP */
+ /*
+ * SSL is enabled ?
+ */
+ if (mode & SSL) {
/*
- * SSL is enabled ?
+ * LDAP session initialization in SSL mode
+ * added by: B Kolics (11/10/00)
*/
- if (mctx.mode & SSL)
- {
- /*
- * LDAP session initialization in SSL mode
- * added by: B Kolics (11/10/00)
- */
- tttctx->ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n",
- mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
- tttctx->ldapCtx);
- if (tttctx->ldapCtx == NULL)
- {
- printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n",
- mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port, errno);
- fflush (stdout);
- return (-1);
- }
- /*
- * Client authentication is used ?
- */
- if (mctx.mode & CLTAUTH)
- {
- ret = ldapssl_enable_clientauth(tttctx->ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
- if (mctx.mode & VERY_VERBOSE)
- printf
- ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
- mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
- mctx.cltcertname);
- if (ret < 0)
- {
- printf
- ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
- mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
- mctx.cltcertname);
- ldap_perror(tttctx->ldapCtx, "ldapssl_enable_clientauth");
- fflush (stdout);
- return (-1);
- }
- }
- } else {
- /*
- * connection initialization in normal, unencrypted mode
- */
- tttctx->ldapCtx = ldap_init (mctx.hostname, mctx.port);
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: After ldap_init (%s, %d), ldapCtx=0x%p\n",
- mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
- tttctx->ldapCtx);
- if (tttctx->ldapCtx == NULL)
- {
- printf ("ldclt[%d]: T%03d: Cannot ldap_init (%s, %d), errno=%d\n",
- mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port, errno);
+ ld = ldapssl_init(mctx.hostname, mctx.port, 1);
+ if (mode & VERY_VERBOSE)
+ printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n",
+ mctx.pid, thrdNum, mctx.hostname, mctx.port,
+ ld);
+ if (ld == NULL) {
+ printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n",
+ mctx.pid, thrdNum, mctx.hostname, mctx.port, errno);
+ fflush (stdout);
+ ret = -1;
+ goto done;
+ }
+ /*
+ * Client authentication is used ?
+ */
+ if (mode & CLTAUTH) {
+ ret = ldapssl_enable_clientauth(ld, "", mctx.keydbpin, mctx.cltcertname);
+ if (mode & VERY_VERBOSE)
+ printf
+ ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+ mctx.pid, thrdNum, ld, mctx.keydbpin,
+ mctx.cltcertname);
+ if (ret < 0) {
+ printf
+ ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+ mctx.pid, thrdNum, ld, mctx.keydbpin, mctx.cltcertname);
+ ldap_perror(ld, "ldapssl_enable_clientauth");
fflush (stdout);
- return (-1);
+ goto done;
}
}
+ } else {
+ /*
+ * connection initialization in normal, unencrypted mode
+ */
+ ld = ldap_init (mctx.hostname, mctx.port);
+ if (mode & VERY_VERBOSE)
+ printf ("ldclt[%d]: T%03d: After ldap_init (%s, %d), ldapCtx=0x%p\n",
+ mctx.pid, thrdNum, mctx.hostname, mctx.port,
+ ld);
+ if (ld == NULL) {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_init (%s, %d), errno=%d\n",
+ mctx.pid, thrdNum, mctx.hostname, mctx.port, errno);
+ fflush (stdout);
+ ret = -1;
+ goto done;
+ }
+ }
#endif /* !USE_OPENLDAP */
- if (mctx.mode & CLTAUTH) {
- mech = "EXTERNAL";
- binddn = "";
- passwd = NULL;
- } else {
- binddn = tttctx->bufBindDN?tttctx->bufBindDN:mctx.bindDN;
- passwd = tttctx->bufPasswd?tttctx->bufPasswd:mctx.passwd;
- if (passwd) {
- cred.bv_val = (char *)passwd;
- cred.bv_len = strlen(passwd);
- }
+ if (mode & CLTAUTH) {
+ mech = "EXTERNAL";
+ binddn = "";
+ passwd = NULL;
+ } else {
+ binddn = bufBindDN?bufBindDN:mctx.bindDN;
+ passwd = bufPasswd?bufPasswd:mctx.passwd;
+ if (passwd) {
+ cred.bv_val = (char *)passwd;
+ cred.bv_len = strlen(passwd);
}
+ }
- if (mctx.mode & LDAP_V2)
- v2v3 = LDAP_VERSION2;
- else
- v2v3 = LDAP_VERSION3;
+ if (mode & LDAP_V2)
+ v2v3 = LDAP_VERSION2;
+ else
+ v2v3 = LDAP_VERSION3;
- ret = ldap_set_option (tttctx->ldapCtx, LDAP_OPT_PROTOCOL_VERSION, &v2v3);
- if (ret < 0)
- {
- printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(LDAP_OPT_PROTOCOL_VERSION)\n",
- mctx.pid, tttctx->thrdNum);
- fflush (stdout);
- return (-1);
- }
+ ret = ldap_set_option (ld, LDAP_OPT_PROTOCOL_VERSION, &v2v3);
+ if (ret < 0) {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(LDAP_OPT_PROTOCOL_VERSION)\n",
+ mctx.pid, thrdNum);
+ fflush (stdout);
+ ret = -1;
+ goto done;
+ }
- /*
- * Set the referral options...
- */
- if (referralSetup (tttctx) < 0)
- return (-1);
+ /*
+ * Set the referral options...
+ */
+ if (tttctx && (referralSetup (tttctx) < 0)) {
+ ret = -1;
+ goto done;
}
/*
@@ -813,11 +873,13 @@ connectToServer (
* below in this function ?
* 03-05-01 : no cleanup I think, cf M2_RNDBINDFILE
*/
- if ((mctx.bindDN == NULL) && ((!(mctx.mod2 & M2_RNDBINDFILE))
- && (!(mctx.mod2 & M2_SASLAUTH))))
- { /*JLS 05-03-01*/
- tttctx->binded = 1; /*JLS 05-03-01*/
- return (0); /*JLS 05-03-01*/
+ if ((bufBindDN == NULL) && (mctx.bindDN == NULL) &&
+ ((!(mod2 & M2_RNDBINDFILE)) && (!(mod2 & M2_SASLAUTH)))) {/*JLS 05-03-01*/
+ if (tttctx) {
+ tttctx->binded = 1; /*JLS 05-03-01*/
+ }
+ ret = 0;
+ goto done;
} /*JLS 05-03-01*/
/*
@@ -826,181 +888,301 @@ connectToServer (
/*
* for SSL client authentication, SASL BIND is used
*/
- if ((mctx.mode & CLTAUTH) && ((!(tttctx->binded)) ||
- (mctx.mode & BIND_EACH_OPER)))
- {
- if (mctx.mode & VERY_VERBOSE)
+ if (tttctx) {
+ binded = tttctx->binded;
+ }
+ if ((mode & CLTAUTH) && ((!(binded)) ||
+ (mode & BIND_EACH_OPER))) {
+ if (mode & VERY_VERBOSE)
printf ("ldclt[%d]: T%03d: Before ldap_sasl_bind_s\n",
- mctx.pid, tttctx->thrdNum);
- ret = ldap_sasl_bind_s (tttctx->ldapCtx, "", "EXTERNAL", NULL, NULL, NULL,
+ mctx.pid, thrdNum);
+ ret = ldap_sasl_bind_s (ld, "", "EXTERNAL", NULL, NULL, NULL,
NULL);
- if (mctx.mode & VERY_VERBOSE)
+ if (mode & VERY_VERBOSE)
printf ("ldclt[%d]: T%03d: After ldap_sasl_bind_s\n",
- mctx.pid, tttctx->thrdNum);
- if (ret == LDAP_SUCCESS) /*JLS 18-12-00*/
- tttctx->binded = 1; /*JLS 18-12-00*/
- else /*JLS 18-12-00*/
- { /*JLS 18-12-00*/
- tttctx->binded = 0; /*JLS 18-12-00*/
- if (ignoreError (ret)) /*JLS 18-12-00*/
- { /*JLS 18-12-00*/
- if (!(mctx.mode & QUIET)) /*JLS 18-12-00*/
- { /*JLS 18-12-00*/
+ mctx.pid, thrdNum);
+ if (ret == LDAP_SUCCESS) { /*JLS 18-12-00*/
+ if (tttctx) {
+ tttctx->binded = 1; /*JLS 18-12-00*/
+ }
+ } else { /*JLS 18-12-00*/
+ if (tttctx) {
+ tttctx->binded = 0; /*JLS 18-12-00*/
+ }
+ if (ignoreError (ret)) { /*JLS 18-12-00*/
+ if (!(mode & QUIET)) { /*JLS 18-12-00*/
printf ("ldclt[%d]: T%03d: Cannot ldap_sasl_bind_s, error=%d (%s)\n",
- mctx.pid, tttctx->thrdNum, ret, my_ldap_err2string (ret));
+ mctx.pid, thrdNum, ret, my_ldap_err2string (ret));
fflush (stdout); /*JLS 18-12-00*/
} /*JLS 18-12-00*/
if (addErrorStat (ret) < 0) /*JLS 18-12-00*/
- return (-1); /*JLS 18-12-00*/
- return (0); /*JLS 18-12-00*/
- } /*JLS 18-12-00*/
- else /*JLS 18-12-00*/
- { /*JLS 18-12-00*/
+ ret = -1;
+ else
+ ret = 0;
+ goto done;
+ } else { /*JLS 18-12-00*/
printf ("ldclt[%d]: T%03d: Cannot ldap_sasl_bind_s, error=%d (%s)\n",
- mctx.pid, tttctx->thrdNum, ret, my_ldap_err2string (ret));
+ mctx.pid, thrdNum, ret, my_ldap_err2string (ret));
fflush (stdout); /*JLS 18-12-00*/
- tttctx->exitStatus = EXIT_NOBIND; /*JLS 18-12-00*/
- if (addErrorStat (ret) < 0) /*JLS 18-12-00*/
- return (-1); /*JLS 18-12-00*/
- return (-1); /*JLS 18-12-00*/
+ if (tttctx)
+ tttctx->exitStatus = EXIT_NOBIND; /*JLS 18-12-00*/
+ (void)addErrorStat(ret);
+ ret = -1;
+ goto done;
} /*JLS 18-12-00*/
}
- } else if ((mctx.mod2 & M2_SASLAUTH) && ((!(tttctx->binded)) ||
- (mctx.mode & BIND_EACH_OPER))) {
+ } else if ((mod2 & M2_SASLAUTH) && ((!(binded)) ||
+ (mode & BIND_EACH_OPER))) {
void *defaults;
char *my_saslauthid = NULL;
if ( mctx.sasl_mech == NULL) {
fprintf( stderr, "Please specify the SASL mechanism name when "
- "using SASL options\n");
- return (-1);
+ "using SASL options\n");
+ ret = -1;
+ goto done;
}
if ( mctx.sasl_secprops != NULL) {
- ret = ldap_set_option( tttctx->ldapCtx, LDAP_OPT_X_SASL_SECPROPS,
+ ret = ldap_set_option( ld, LDAP_OPT_X_SASL_SECPROPS,
(void *) mctx.sasl_secprops );
if ( ret != LDAP_SUCCESS ) {
fprintf( stderr, "Unable to set LDAP_OPT_X_SASL_SECPROPS: %s\n",
- mctx.sasl_secprops );
- return (-1);
+ mctx.sasl_secprops );
+ goto done;
}
}
- /*
- * Generate the random authid if set up so
- */
- if (mctx.mod2 & M2_RANDOM_SASLAUTHID)
- {
+ /*
+ * Generate the random authid if set up so
+ */
+ if ((mod2 & M2_RANDOM_SASLAUTHID) && tttctx) {
rnd (tttctx->buf2, mctx.sasl_authid_low, mctx.sasl_authid_high,
- mctx.sasl_authid_nbdigit);
+ mctx.sasl_authid_nbdigit);
strncpy (&(tttctx->bufSaslAuthid[tttctx->startSaslAuthid]),
- tttctx->buf2, mctx.sasl_authid_nbdigit);
+ tttctx->buf2, mctx.sasl_authid_nbdigit);
my_saslauthid = tttctx->bufSaslAuthid;
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: Sasl Authid=\"%s\"\n",
- mctx.pid, tttctx->thrdNum, tttctx->bufSaslAuthid);
- }
- else
- {
+ if (mode & VERY_VERBOSE)
+ printf ("ldclt[%d]: T%03d: Sasl Authid=\"%s\"\n",
+ mctx.pid, thrdNum, tttctx->bufSaslAuthid);
+ } else {
my_saslauthid = mctx.sasl_authid;
}
- defaults = ldaptool_set_sasl_defaults( tttctx->ldapCtx, mctx.sasl_flags, mctx.sasl_mech,
- my_saslauthid, mctx.sasl_username, mctx.passwd, mctx.sasl_realm );
+ defaults = ldaptool_set_sasl_defaults( ld, mctx.sasl_flags, mctx.sasl_mech,
+ my_saslauthid, mctx.sasl_username, mctx.passwd, mctx.sasl_realm );
if (defaults == NULL) {
perror ("malloc");
exit (LDAP_NO_MEMORY);
}
#if defined(USE_OPENLDAP)
- ret = ldap_sasl_interactive_bind_s( tttctx->ldapCtx, mctx.bindDN, mctx.sasl_mech,
- NULL, NULL, mctx.sasl_flags,
- ldaptool_sasl_interact, defaults );
+ ret = ldap_sasl_interactive_bind_s( ld, mctx.bindDN, mctx.sasl_mech,
+ NULL, NULL, mctx.sasl_flags,
+ ldaptool_sasl_interact, defaults );
#else
- ret = ldap_sasl_interactive_bind_ext_s( tttctx->ldapCtx, mctx.bindDN, mctx.sasl_mech,
- NULL, NULL, mctx.sasl_flags,
- ldaptool_sasl_interact, defaults, NULL );
+ ret = ldap_sasl_interactive_bind_ext_s( ld, mctx.bindDN, mctx.sasl_mech,
+ NULL, NULL, mctx.sasl_flags,
+ ldaptool_sasl_interact, defaults, NULL );
#endif
if (ret != LDAP_SUCCESS ) {
- tttctx->binded = 0;
- if (!(mctx.mode & QUIET)) {
+ if (tttctx) {
+ tttctx->binded = 0;
+ }
+ if (!(mode & QUIET)) {
fprintf(stderr, "Error: could not bind: %d:%s\n",
ret, my_ldap_err2string(ret));
}
if (addErrorStat (ret) < 0)
- return (-1);
+ goto done;
} else {
+ if (tttctx) {
tttctx->binded = 1;
+ }
}
ldaptool_free_defaults( defaults );
} else {
- if (((mctx.bindDN != NULL) || (mctx.mod2 & M2_RNDBINDFILE)) && /*03-05-01*/
- ((!(tttctx->binded)) || (mctx.mode & BIND_EACH_OPER)))
- {
+ if (((mctx.bindDN != NULL) || (mod2 & M2_RNDBINDFILE)) && /*03-05-01*/
+ ((!(binded)) || (mode & BIND_EACH_OPER))) {
struct berval *servercredp = NULL;
- char *binddn = NULL;
- char *passwd = NULL;
-
- if (buildNewBindDN (tttctx) < 0) /*JLS 05-01-01*/
- return (-1); /*JLS 05-01-01*/
- if (tttctx->bufPasswd) {
- binddn = tttctx->bufBindDN;
- passwd = tttctx->bufPasswd;
+ const char *binddn = NULL;
+ const char *passwd = NULL;
+
+ if (tttctx && (buildNewBindDN (tttctx) < 0)) { /*JLS 05-01-01*/
+ ret = -1;
+ goto done;
+ }
+ if (tttctx && tttctx->bufPasswd) {
+ binddn = tttctx->bufBindDN;
+ passwd = tttctx->bufPasswd;
+ } else if (bufPasswd) {
+ binddn = bufBindDN;
+ passwd = bufPasswd;
} else if (mctx.passwd) {
- binddn = mctx.bindDN;
- passwd = mctx.passwd;
+ binddn = mctx.bindDN;
+ passwd = mctx.passwd;
}
if (passwd) {
- cred.bv_val = passwd;
- cred.bv_len = strlen(passwd);
+ cred.bv_val = (char *)passwd;
+ cred.bv_len = strlen(passwd);
}
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: Before ldap_simple_bind_s (%s, %s)\n",
- mctx.pid, tttctx->thrdNum, binddn,
- passwd?passwd:"NO PASSWORD PROVIDED");
- ret = ldap_sasl_bind_s (tttctx->ldapCtx, binddn,
- LDAP_SASL_SIMPLE, &cred, NULL, NULL, &servercredp); /*JLS 05-01-01*/
+ if (mode & VERY_VERBOSE)
+ printf ("ldclt[%d]: T%03d: Before ldap_simple_bind_s (%s, %s)\n",
+ mctx.pid, thrdNum, binddn,
+ passwd?passwd:"NO PASSWORD PROVIDED");
+ ret = ldap_sasl_bind_s (ld, binddn,
+ LDAP_SASL_SIMPLE, &cred, NULL, NULL, &servercredp); /*JLS 05-01-01*/
ber_bvfree(servercredp);
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: After ldap_simple_bind_s (%s, %s)\n",
- mctx.pid, tttctx->thrdNum, binddn,
- passwd?passwd:"NO PASSWORD PROVIDED");
- if (ret == LDAP_SUCCESS) /*JLS 18-12-00*/
- tttctx->binded = 1; /*JLS 18-12-00*/
- else /*JLS 18-12-00*/
- { /*JLS 18-12-00*/
- tttctx->binded = 0; /*JLS 18-12-00*/
- if (ignoreError (ret)) /*JLS 18-12-00*/
- { /*JLS 18-12-00*/
- if (!(mctx.mode & QUIET)) /*JLS 18-12-00*/
- { /*JLS 18-12-00*/
+ if (mode & VERY_VERBOSE)
+ printf ("ldclt[%d]: T%03d: After ldap_simple_bind_s (%s, %s)\n",
+ mctx.pid, thrdNum, binddn,
+ passwd?passwd:"NO PASSWORD PROVIDED");
+ if (ret == LDAP_SUCCESS) { /*JLS 18-12-00*/
+ if (tttctx) {
+ tttctx->binded = 1; /*JLS 18-12-00*/
+ }
+ } else { /*JLS 18-12-00*/
+ if (tttctx) {
+ tttctx->binded = 0; /*JLS 18-12-00*/
+ }
+ if (ignoreError (ret)) { /*JLS 18-12-00*/
+ if (!(mode & QUIET)) { /*JLS 18-12-00*/
printf("ldclt[%d]: T%03d: Cannot ldap_simple_bind_s (%s, %s), error=%d (%s)\n",
- mctx.pid, tttctx->thrdNum, tttctx->bufBindDN,
- mctx.passwd?tttctx->bufPasswd:"NO PASSWORD PROVIDED",
- ret, my_ldap_err2string (ret));
+ mctx.pid, thrdNum, binddn,
+ passwd?passwd:"NO PASSWORD PROVIDED",
+ ret, my_ldap_err2string (ret));
fflush (stdout); /*JLS 18-12-00*/
} /*JLS 18-12-00*/
- if (addErrorStat (ret) < 0) /*JLS 18-12-00*/
- return (-1); /*JLS 18-12-00*/
- return (0); /*JLS 18-12-00*/
- } /*JLS 18-12-00*/
- else /*JLS 18-12-00*/
- { /*JLS 18-12-00*/
+ if (addErrorStat (ret) < 0) { /*JLS 18-12-00*/
+ ret = -1;
+ } else {
+ ret = 0;
+ }
+ goto done;
+ } else { /*JLS 18-12-00*/
printf ("ldclt[%d]: T%03d: Cannot ldap_simple_bind_s (%s, %s), error=%d (%s)\n",
- mctx.pid, tttctx->thrdNum, tttctx->bufBindDN,
- mctx.passwd?tttctx->bufPasswd:"NO PASSWORD PROVIDED",
- ret, my_ldap_err2string (ret));
+ mctx.pid, thrdNum, binddn,
+ passwd?passwd:"NO PASSWORD PROVIDED",
+ ret, my_ldap_err2string (ret));
fflush (stdout); /*JLS 18-12-00*/
- tttctx->exitStatus = EXIT_NOBIND; /*JLS 18-12-00*/
- if (addErrorStat (ret) < 0) /*JLS 18-12-00*/
- return (-1); /*JLS 18-12-00*/
- return (-1); /*JLS 18-12-00*/
+ if (tttctx)
+ tttctx->exitStatus = EXIT_NOBIND; /*JLS 18-12-00*/
+ (void)addErrorStat(ret);
+ ret = -1;
+ goto done;
} /*JLS 18-12-00*/
}
}
}
+ done:
+ if (ret) {
+ ldap_unbind_ext(ld, NULL, NULL);
+ ld = NULL;
+ }
+ if (ldapurl) {
+ PR_smprintf_free(ldapurl);
+ ldapurl = NULL;
+ }
+
+ return ld;
+}
+
+/* ****************************************************************************
+ FUNCTION : connectToServer
+ PURPOSE : Realise the connection to the server.
+ If requested by the user, it also realize the
+ disconnection prior to connect.
+ INPUT : tttctx = this thread's thread_context
+ OUTPUT : None.
+ RETURN : -1 if error, 0 else.
+ DESCRIPTION :
+ *****************************************************************************/
+int
+connectToServer (
+ thread_context *tttctx)
+{
+ int ret; /* Return value */
+ LBER_SOCKET fd; /* LDAP cnx's fd */
+
+ /*
+ * Maybe close the connection ?
+ * We will do this *here* to keep the cnx the longest time open.
+ */
+ if ((mctx.mode & BIND_EACH_OPER) && (tttctx->ldapCtx != NULL))
+ {
+ /*
+ * Maybe the user want the connection to be *closed* rather than
+ * being kindly unbinded ?
+ */
+ if (mctx.mode & CLOSE_FD)
+ {
+ /*
+ * Get the corresponding fd
+ */
+#ifdef WORKAROUND_4197228
+ if (getFdFromLdapSession (tttctx->ldapCtx, &fd) < 0)
+ {
+ printf ("ldclt[%d]: T%03d: Cannot extract fd from ldap session\n",
+ mctx.pid, tttctx->thrdNum);
+ fflush (stdout);
+ return (-1);
+ }
+#else
+ ret = ldap_get_option (tttctx->ldapCtx, LDAP_OPT_DESC, &fd);
+ if (ret < 0)
+ {
+ printf ("ldclt[%d]: T%03d: Cannot ldap_get_option(LDAP_OPT_DESC)\n",
+ mctx.pid, tttctx->thrdNum);
+ fflush (stdout);
+ return (-1);
+ }
+#endif
+#ifdef TRACE_FD_GET_OPTION_BUG
+ printf ("ldclt[%d]: T%03d: fd=%d\n", mctx.pid, tttctx->thrdNum, (int)fd);
+#endif
+ if (close ((int)fd) < 0)
+ {
+ perror ("ldctx");
+ printf ("ldclt[%d]: T%03d: cannot close(fd=%d), error=%d (%s)\n",
+ mctx.pid, tttctx->thrdNum, (int)fd, errno, strerror (errno));
+ return (-1);
+ }
+ }
+
+ /*
+ * Ok, anyway, we must ldap_unbind() to release our contextes
+ * at the client side, otherwise this process will rocket through
+ * the ceiling.
+ * But don't be afraid, the UNBIND operation never reach the
+ * server that will only see a suddent socket disconnection.
+ */
+ ret = ldap_unbind_ext (tttctx->ldapCtx, NULL, NULL);
+ if (ret != LDAP_SUCCESS)
+ {
+ fprintf (stderr, "ldclt[%d]: T%03d: cannot ldap_unbind(), error=%d (%s)\n",
+ mctx.pid, tttctx->thrdNum, ret,strerror (ret));
+ fflush (stderr);
+ if (addErrorStat (ret) < 0)
+ return (-1);
+ return (-1);
+ }
+ tttctx->ldapCtx = NULL;
+ }
+
+ /*
+ * Maybe create the LDAP context ?
+ */
+ if (tttctx->ldapCtx == NULL)
+ {
+ tttctx->ldapCtx = connectToLDAP(tttctx, tttctx->bufBindDN, tttctx->bufPasswd,
+ mctx.mode, mctx.mod2);
+ if (!tttctx->ldapCtx) {
+ return (-1);
+ }
+ }
+
/*
* Normal end
*/
@@ -1015,8 +1197,6 @@ connectToServer (
-
-
/* ****************************************************************************
FUNCTION : buildVersatileAttribute
PURPOSE : Build a new attribute value using the definitions of
@@ -1915,7 +2095,6 @@ createMissingNodes (
int nbAttribs; /* Nb of attributes */
LDAPMod attribute; /* To build the attributes */
LDAPMod *attrs[4]; /* Attributes of this entry */
- int v2v3; /* LDAP version used */
/*
* Skip the rdn of the given newDN, that was rejected.
@@ -2000,135 +2179,22 @@ createMissingNodes (
*/
if (cnx == NULL)
{
- const char *mech = LDAP_SASL_SIMPLE;
- const char *binddn = NULL;
- const char *passwd = NULL;
- struct berval cred = {0, NULL};
-#if defined(USE_OPENLDAP)
- char *ldapurl = NULL;
-#endif
-
- if (mctx.mode & VERY_VERBOSE) /*JLS 14-12-00*/
+ unsigned int mode = mctx.mode;
+ unsigned int mod2 = mctx.mod2;
+ /* clear bits not applicable to this mode */
+ mod2 &= ~M2_RNDBINDFILE;
+ mod2 &= ~M2_SASLAUTH;
+ mod2 &= ~M2_RANDOM_SASLAUTHID;
+ /* force bind to happen */
+ mode |= BIND_EACH_OPER;
+ if (mode & VERY_VERBOSE) /*JLS 14-12-00*/
printf ("ldclt[%d]: T%03d: must connect to the server.\n",
mctx.pid, tttctx->thrdNum);
-#if defined(USE_OPENLDAP)
- ldapurl = PR_smprintf("ldap%s://%s:%d/",
- (mctx.mode & SSL) ? "s" : "",
- mctx.hostname, mctx.port);
- if ((ret = ldap_initialize(&tttctx->ldapCtx, ldapurl))) {
- printf ("ldclt[%d]: T%03d: Cannot ldap_initialize (%s), errno=%d ldaperror=%d:%s\n",
- mctx.pid, tttctx->thrdNum, ldapurl, errno, ret, my_ldap_err2string(ret));
- fflush (stdout);
- PR_smprintf_free(ldapurl);
- return (-1);
- }
- PR_smprintf_free(ldapurl);
- ldapurl = NULL;
- cnx = tttctx->ldapCtx;
-#else /* !USE_OPENLDAP */
- /*
- * SSL is enabled ?
- */
- if (mctx.mode & SSL)
- {
- /*
- * LDAP session initialization in SSL mode
- * added by: B Kolics (11/10/00)
- */
- tttctx->ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n",
- mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
- tttctx->ldapCtx);
- if (tttctx->ldapCtx == NULL)
- {
- printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n",
- mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port, errno);
- fflush (stdout);
- return (-1);
- }
- /*
- * Client authentication is used ?
- */
- if (mctx.mode & CLTAUTH)
- {
- ret = ldapssl_enable_clientauth(tttctx->ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
- if (mctx.mode & VERY_VERBOSE)
- printf
- ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
- mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
- mctx.cltcertname);
- if (ret < 0)
- {
- printf
- ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
- mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
- mctx.cltcertname);
- fflush (stdout);
- return (-1);
- }
- }
- } else {
- /*
- * connection initialization in normal, unencrypted mode
- */
- cnx = ldap_init (mctx.hostname, mctx.port);
- if (cnx == NULL)
- {
- printf ("ldclt[%d]: T%03d: Cannot ldap_init (%s, %d), errno=%d\n",
- mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port, errno);
- fflush (stdout);
- return (-1);
- }
- }
-#endif /* !USE_OPENLDAP */
-
- if (mctx.mode & CLTAUTH) {
- mech = "EXTERNAL";
- binddn = "";
- passwd = NULL;
- } else {
- binddn = tttctx->bufBindDN?tttctx->bufBindDN:mctx.bindDN;
- passwd = tttctx->bufPasswd?tttctx->bufPasswd:mctx.passwd;
- if (passwd) {
- cred.bv_val = (char *)passwd;
- cred.bv_len = strlen(passwd);
- }
- }
-
- if (mctx.mode & LDAP_V2)
- v2v3 = LDAP_VERSION2;
- else
- v2v3 = LDAP_VERSION3;
-
- ret = ldap_set_option (cnx, LDAP_OPT_PROTOCOL_VERSION, &v2v3);
- if (ret < 0)
- {
- printf ("ldclt[%d]: T%03d: Cannot ldap_set_option(LDAP_OPT_PROTOCOL_VERSION)\n",
- mctx.pid, tttctx->thrdNum);
- fflush (stdout);
- return (-1);
- }
-
- /*
- * Bind to the server
- */
- ret = ldap_sasl_bind_s (tttctx->ldapCtx, binddn, mech, &cred, NULL, NULL,
- NULL);
- if (ret != LDAP_SUCCESS)
- {
- printf ("ldclt[%d]: T%03d: Cannot bind using mech [%s] (%s, %s), error=%d (%s)\n",
- mctx.pid, tttctx->thrdNum,
- mech ? mech : "SIMPLE",
- tttctx->bufBindDN ? tttctx->bufBindDN : "",
- tttctx->bufPasswd ? tttctx->bufPasswd : "",
- ret, my_ldap_err2string (ret));
- fflush (stdout);
- tttctx->exitStatus = EXIT_NOBIND; /*JLS 25-08-00*/
- if (addErrorStat (ret) < 0)
- return (-1);
+ tttctx->ldapCtx = connectToLDAP(tttctx, tttctx->bufBindDN, tttctx->bufPasswd, mode, mod2);
+ if (!tttctx->ldapCtx) {
return (-1);
}
+ cnx = tttctx->ldapCtx;
}
/*
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.h b/ldap/servers/slapd/tools/ldclt/ldclt.h
index 48c398be8..0426a1a2b 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.h
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.h
@@ -736,6 +736,7 @@ extern int setThreadStatus (thread_context *tttctx, /*JLS 17-11-00*/
int status); /*JLS 17-11-00*/
extern void *threadMain (void *);
/* From ldapfct.c */
+extern LDAP* connectToLDAP (thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2);
extern int connectToServer (thread_context *tttctx); /*JLS 14-03-01*/
extern char *dnFromMessage (thread_context *tttctx, LDAPMessage *res);
extern int doAddEntry (thread_context *tttctx);
diff --git a/ldap/servers/slapd/tools/ldclt/scalab01.c b/ldap/servers/slapd/tools/ldclt/scalab01.c
index 39345bd19..049e5f629 100644
--- a/ldap/servers/slapd/tools/ldclt/scalab01.c
+++ b/ldap/servers/slapd/tools/ldclt/scalab01.c
@@ -532,134 +532,23 @@ done:
int
scalab01_connectSuperuser (void)
{
- int ret; /* Return value */
- int v2v3; /* LDAP version used */
char bindDN [MAX_DN_LENGTH] = {0}; /* To bind */
- const char *mech = LDAP_SASL_SIMPLE;
- struct berval cred = {0, NULL};
- struct berval *servercredp = NULL;
-#if defined(USE_OPENLDAP)
- char *ldapurl = NULL;
-#endif
+ unsigned int mode = mctx.mode;
+ unsigned int mod2 = mctx.mod2;
-#if defined(USE_OPENLDAP)
- ldapurl = PR_smprintf("ldap%s://%s:%d/",
- (mctx.mode & SSL) ? "s" : "",
- mctx.hostname, mctx.port);
- if ((ret = ldap_initialize(&s1ctx.ldapCtx, ldapurl))) {
- printf ("ldclt[%d]: ctrl: Cannot ldap_initialize (%s), errno=%d ldaperror=%d:%s\n",
- mctx.pid, ldapurl, errno, ret, my_ldap_err2string(ret));
- fflush (stdout);
- PR_smprintf_free(ldapurl);
- return (-1);
- }
- PR_smprintf_free(ldapurl);
- ldapurl = NULL;
-#else /* !USE_OPENLDAP */
- /*
- * Create the LDAP context
- */
- /*
- * SSL is enabled ?
- */
- if (mctx.mode & SSL)
- {
- /*
- * LDAP session initialization in SSL mode
- */
- s1ctx.ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: ctrl: ldapssl_init (%s, %d), ldapCtx=0x%p\n",
- mctx.pid, mctx.hostname, mctx.port, s1ctx.ldapCtx);
- if (s1ctx.ldapCtx == NULL)
- {
- printf ("ldclt[%d]: ctrl: Cannot ldapssl_init (%s, %d), errno=%d\n",
- mctx.pid, mctx.hostname, mctx.port, errno);
- fflush (stdout);
- return (-1);
- }
- /*
- * Client authentication is used ?
- */
- if (mctx.mode & CLTAUTH)
- {
- ret = ldapssl_enable_clientauth(s1ctx.ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
- if (mctx.mode & VERY_VERBOSE)
- printf
- ("ldclt[%d]: ctrl: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
- mctx.pid, s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
- if (ret < 0)
- {
- printf
- ("ldclt[%d]: ctrl: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
- mctx.pid, s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
- ldap_perror(s1ctx.ldapCtx, "ldapssl_enable_clientauth");
- fflush (stdout);
- return (-1);
- }
- }
- }
- else
- {
- /*
- * Connection initialization in normal, unencrypted mode
- */
- s1ctx.ldapCtx = ldap_init (mctx.hostname, mctx.port);
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: ctrl: After ldap_init (%s, %d), ldapCtx=0x%p\n",
- mctx.pid, mctx.hostname, mctx.port, s1ctx.ldapCtx);
- if (s1ctx.ldapCtx == NULL)
- {
- printf ("ldclt[%d]: ctrl: Cannot ldap_init (%s, %d), errno=%d\n",
- mctx.pid, mctx.hostname, mctx.port, errno);
- fflush (stdout);
- return (-1);
- }
- }
-#endif /* !USE_OPENLDAP */
-
- if (mctx.mode & CLTAUTH) {
- mech = "EXTERNAL";
- } else {
+ if (!(mode & CLTAUTH)) {
strcpy (bindDN, SCALAB01_SUPER_USER_RDN);
strcat (bindDN, ",");
strcat (bindDN, mctx.baseDN);
- cred.bv_val = SCALAB01_SUPER_USER_PASSWORD;
- cred.bv_len = strlen(cred.bv_val);
}
-
- /*
- * Set the LDAP version and other options...
- */
- if (mctx.mode & LDAP_V2)
- v2v3 = LDAP_VERSION2;
- else
- v2v3 = LDAP_VERSION3;
-
- ret = ldap_set_option (s1ctx.ldapCtx, LDAP_OPT_PROTOCOL_VERSION, &v2v3);
- if (ret < 0) /*JLS 14-03-01*/
- { /*JLS 14-03-01*/
- printf ("ldclt[%d]: ctrl: Cannot ldap_set_option(LDAP_OPT_PROTOCOL_VERSION)\n",
- mctx.pid);
- fflush (stdout); /*JLS 14-03-01*/
- return (-1); /*JLS 14-03-01*/
- } /*JLS 14-03-01*/
-
-
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: ctrl: Before bind mech %s (%s , %s)\n",
- mctx.pid, mech ? mech : "SIMPLE", bindDN, SCALAB01_SUPER_USER_PASSWORD);
- ret = ldap_sasl_bind_s (s1ctx.ldapCtx, bindDN, mech, &cred, NULL, NULL, &servercredp);
- ber_bvfree(servercredp);
- if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: ctrl: After bind mech %s (%s, %s)\n",
- mctx.pid, mech ? mech : "SIMPLE", bindDN, SCALAB01_SUPER_USER_PASSWORD);
- if (ret != LDAP_SUCCESS)
- {
- printf("ldclt[%d]: ctrl: Cannot bind mech %s (%s, %s), error=%d (%s)\n",
- mctx.pid, mech ? mech : "SIMPLE", bindDN, SCALAB01_SUPER_USER_PASSWORD,
- ret, my_ldap_err2string (ret));
- fflush (stdout);
+ /* clear bits not applicable to this mode */
+ mod2 &= ~M2_RNDBINDFILE;
+ mod2 &= ~M2_SASLAUTH;
+ mod2 &= ~M2_RANDOM_SASLAUTHID;
+ /* force bind to happen */
+ mode |= BIND_EACH_OPER;
+ s1ctx.ldapCtx = connectToLDAP(NULL, bindDN, SCALAB01_SUPER_USER_PASSWORD, mode, mod2);
+ if (!s1ctx.ldapCtx) {
return (-1);
}
| 0 |
9b6882eed8556871b788f13b50e780fb393d893c
|
389ds/389-ds-base
|
Issue 4775 -plugin entryuuid failing (#5229)
Check CLI dsconf entryuuid fixup
|
commit 9b6882eed8556871b788f13b50e780fb393d893c
Author: Gilbert Kimetto <[email protected]>
Date: Tue Mar 29 20:46:43 2022 -0400
Issue 4775 -plugin entryuuid failing (#5229)
Check CLI dsconf entryuuid fixup
diff --git a/dirsrvtests/tests/suites/entryuuid/basic_test.py b/dirsrvtests/tests/suites/entryuuid/basic_test.py
index d547d313d..e499a2eb7 100644
--- a/dirsrvtests/tests/suites/entryuuid/basic_test.py
+++ b/dirsrvtests/tests/suites/entryuuid/basic_test.py
@@ -11,6 +11,9 @@ import pytest
import time
import shutil
import uuid
+import subprocess
+import pytest
+import logging
from lib389.idm.user import nsUserAccounts, UserAccounts
from lib389.idm.account import Accounts
from lib389.idm.domain import Domain
@@ -24,6 +27,7 @@ from lib389.plugins import EntryUUIDPlugin
default_paths = Paths()
pytestmark = pytest.mark.tier1
+log = logging.getLogger(__name__)
DATADIR1 = os.path.join(os.path.dirname(__file__), '../../data/entryuuid/')
IMPORT_UUID_A = "973e1bbf-ba9c-45d4-b01b-ff7371fd9008"
@@ -32,6 +36,37 @@ IMPORT_UUID_B = "f6df8fe9-6b30-46aa-aa13-f0bf755371e8"
UUID_MIN = "00000000-0000-0000-0000-000000000000"
UUID_MAX = "ffffffff-ffff-ffff-ffff-ffffffffffff"
[email protected](ds_is_older('1.4.3.27'), reason="CLI Entryuuid is not available in prior versions")
+def test_cli_entryuuid_plugin_fixup(topology):
+ """Test that dsconf CLI entryuuid attribute is enabled and can execute.
+ :id: 91b46be2-ac3f-11ec-a38a-98fa9ba19b65
+ :parametrized: yes
+ :customerscenario: True
+ :setup: Standalone Instance
+ :steps:
+ 1. Create DS Instance
+ 2. Create a user "jdoe" with a dn
+ 3. Verify dsconf command is working correctly with plugin entryuuid fixup
+
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+
+ """
+ log.info("Use dsconf tool to configure entryuuid plugin")
+ parent = "ou=People,dc=example,dc=com"
+ name = 'jdoe'
+ dn = 'uid=%s,%s' % (name, parent)
+ log.info('Testing with User created for dn :{} .'.format(dn))
+ cmd=['/usr/sbin/dsconf',topology.standalone.get_ldap_uri(),'-D',DN_DM,'-w','password','plugin','entryuuid','fixup',dn]
+ log.info(f'Dsconf Command used : %{cmd}')
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ msg = proc.communicate()
+ log.info(f'output message : {msg[0]}')
+ assert proc.returncode == 0
+
+
def _entryuuid_import_and_search(topology):
# 1
ldif_dir = topology.standalone.get_ldif_dir()
| 0 |
3dcdb8df3e8678409453782c2c6ce3f9785e204b
|
389ds/389-ds-base
|
190724 - Array initialization needed to be changed to fix a HP-UX PA compilation error
|
commit 3dcdb8df3e8678409453782c2c6ce3f9785e204b
Author: Nathan Kinder <[email protected]>
Date: Fri May 5 18:45:09 2006 +0000
190724 - Array initialization needed to be changed to fix a HP-UX PA compilation error
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index 828eb191a..f6e135c8f 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -907,7 +907,9 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod *mod, char **old
{
/* slapi_acl_check_mods needs an array of LDAPMods, but
* we're really only interested in the one password mod. */
- LDAPMod *mods[2] = { mod, NULL };
+ LDAPMod *mods[2];
+ mods[0] = mod;
+ mods[1] = NULL;
/* Create a bogus entry with just the target dn. This will
* only be used for checking the ACIs. */
| 0 |
3606b78bacce984ab2226755c5921dffac9552c2
|
389ds/389-ds-base
|
Ticket #48755 - moving an entry could make the online init fail
Bug Description: Online init (aka Total update, bulk import) scans the
primary id2entry db in the order of ID. If Entry A is moved under a
new superior Entry B which was generated after Entry A, when Entry A
is sent to a consumer using online init, its parent entry does not
exist on the consumer and the online init fails.
Fix Description:
- Added a command BACK_INFO_IS_ENTRYRDN to slapi_back_get_info, which
returns the status of entryrdn switch maintained in the backend.
- If slapi_backend_get_info(BACK_INFO_IS_ENTRYRDN) returns true for
the replicated backend, repl5_tot_run searches the entry with the
filter:
(|(parentid>=1)(objectclass=ldapsubentry)(objectclass=nstombstone))
instead of:
(|(objectclass=ldapsubentry)(objectclass=nstombstone)(nsuniqueid=*))".
- In addition, idl_new_range_fetch had to be modified so that ...
* A range search for parentid ignores nsslapd-idlistscanlimit by
setting SLAPI_OP_RANGE_NO_ALLIDS as well as it skips sorting the
IDlist by ID by setting SLAPI_OP_RANGE_NO_IDL_SORT.
* In case SLAPI_OP_RANGE_NO_IDL_SORT is set, idl_new_range_fetch
checks whether the key (in this case parentid) is in the IDlist.
If it exists, the ID is appended. If it does not, the ID is in
the leftover list and appended when the parent ID is found in the
IDlist.
- Increased the version of rdn-format-# in DBVERSION to 3.
- Upgrade script 91reindex.pl.in is added which reindex the parentid
index file in the integer order if the version of rdn-format-# in
DBVERSION is less than 3.
https://fedorahosted.org/389/ticket/48755
Reviewed by [email protected] and [email protected] (Thanks, William and Ludwig!)
|
commit 3606b78bacce984ab2226755c5921dffac9552c2
Author: Noriko Hosoi <[email protected]>
Date: Thu May 26 15:14:06 2016 -0700
Ticket #48755 - moving an entry could make the online init fail
Bug Description: Online init (aka Total update, bulk import) scans the
primary id2entry db in the order of ID. If Entry A is moved under a
new superior Entry B which was generated after Entry A, when Entry A
is sent to a consumer using online init, its parent entry does not
exist on the consumer and the online init fails.
Fix Description:
- Added a command BACK_INFO_IS_ENTRYRDN to slapi_back_get_info, which
returns the status of entryrdn switch maintained in the backend.
- If slapi_backend_get_info(BACK_INFO_IS_ENTRYRDN) returns true for
the replicated backend, repl5_tot_run searches the entry with the
filter:
(|(parentid>=1)(objectclass=ldapsubentry)(objectclass=nstombstone))
instead of:
(|(objectclass=ldapsubentry)(objectclass=nstombstone)(nsuniqueid=*))".
- In addition, idl_new_range_fetch had to be modified so that ...
* A range search for parentid ignores nsslapd-idlistscanlimit by
setting SLAPI_OP_RANGE_NO_ALLIDS as well as it skips sorting the
IDlist by ID by setting SLAPI_OP_RANGE_NO_IDL_SORT.
* In case SLAPI_OP_RANGE_NO_IDL_SORT is set, idl_new_range_fetch
checks whether the key (in this case parentid) is in the IDlist.
If it exists, the ID is appended. If it does not, the ID is in
the leftover list and appended when the parent ID is found in the
IDlist.
- Increased the version of rdn-format-# in DBVERSION to 3.
- Upgrade script 91reindex.pl.in is added which reindex the parentid
index file in the integer order if the version of rdn-format-# in
DBVERSION is less than 3.
https://fedorahosted.org/389/ticket/48755
Reviewed by [email protected] and [email protected] (Thanks, William and Ludwig!)
diff --git a/Makefile.am b/Makefile.am
index 824b74515..cad1b618c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -839,7 +839,8 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
ldap/admin/src/scripts/50AES-pbe-plugin.ldif\
ldap/admin/src/scripts/50updateconfig.ldif \
ldap/admin/src/scripts/52updateAESplugin.pl \
- ldap/admin/src/scripts/dnaplugindepends.ldif
+ ldap/admin/src/scripts/dnaplugindepends.ldif \
+ ldap/admin/src/scripts/91reindex.pl
update_SCRIPTS = ldap/admin/src/scripts/exampleupdate.sh
diff --git a/Makefile.in b/Makefile.in
index 0752ff1bb..a45a0d623 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2240,7 +2240,8 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
ldap/admin/src/scripts/50AES-pbe-plugin.ldif\
ldap/admin/src/scripts/50updateconfig.ldif \
ldap/admin/src/scripts/52updateAESplugin.pl \
- ldap/admin/src/scripts/dnaplugindepends.ldif
+ ldap/admin/src/scripts/dnaplugindepends.ldif \
+ ldap/admin/src/scripts/91reindex.pl
update_SCRIPTS = ldap/admin/src/scripts/exampleupdate.sh
diff --git a/ldap/admin/src/scripts/91reindex.pl.in b/ldap/admin/src/scripts/91reindex.pl.in
new file mode 100644
index 000000000..c861f64cf
--- /dev/null
+++ b/ldap/admin/src/scripts/91reindex.pl.in
@@ -0,0 +1,103 @@
+use Mozilla::LDAP::Conn;
+use Mozilla::LDAP::Utils qw(normalizeDN);
+use Mozilla::LDAP::API qw(:constant ldap_url_parse ldap_explode_dn);
+use DSUpdate qw(isOffline);
+
+sub runinst {
+ my ($inf, $inst, $dseldif, $conn) = @_;
+ my $rc, @errs;
+
+ # List of index to be reindexed
+ my @toreindex = qw(parentid);
+ # rdn-format value. See $rdn_format set below.
+ # If equal to or greater than this value, no need to reindex.
+ # If it needs to be unconditionally reindexed, set 0.
+ my @rdnconditions = (4)
+
+ my $config = $conn->search("cn=config", "base", "(objectclass=*)");
+ if (!$config) {
+ push @errs, ['error_finding_config_entry', 'cn=config',
+ $conn->getErrorString()];
+ return @errs;
+ }
+
+ ($rc, @errs) = isOffline($inf, $inst, $conn);
+ if (!$rc) {
+ return @errs;
+ }
+
+ my $reindex = "@sbindir@/db2index -Z $inst";
+ my @errs;
+ my $instconf = $conn->search("cn=ldbm database,cn=plugins,cn=config", "onelevel", "(objectclass=*)");
+ if (!$instconf) {
+ push @errs, ['error_finding_config_entry', 'cn=*,cn=ldbm database,cn=plugins,cn=config', $conn->getErrorString()];
+ return @errs;
+ }
+
+ my $dbconf = $conn->search("cn=config,cn=ldbm database,cn=plugins,cn=config", "base", "(objectclass=*)");
+ if (!$dbconf) {
+ push @errs, ['error_finding_config_entry',
+ 'cn=config,cn=ldbm database,cn=plugins,cn=config',
+ $conn->getErrorString()];
+ return @errs;
+ }
+
+ # Get the value of nsslapd-subtree-rename-switch.
+ my $switch = $dbconf->getValues('nsslapd-subtree-rename-switch');
+ if ("" eq $switch) {
+ return (); # subtree-rename-switch does not exist; do nothing.
+ } elsif ("off" eq $switch || "OFF" eq $switch) {
+ return (); # subtree-rename-switch is OFF; do nothing.
+ }
+
+ my $dbdir = $dbconf->getValues('nsslapd-directory');
+ my $dbversion0 = $dbdir . "/DBVERSION";
+ my $rdn_format = 0;
+ my $dbversionstr = "";
+ if (!open(DBVERSION, "$dbversion0")) {
+ push @errs, ['error_opening_file', $dbversion0, $!];
+ return @errs;
+ } else {
+ while (<DBVERSION>) {
+ if ($_ =~ /rdn-format/) {
+ $rdn_format = 1;
+ $dbversionstr = $_;
+ if ($_ =~ /rdn-format-1/) {
+ $rdn_format = 2;
+ } elsif ($_ =~ /rdn-format-2/) {
+ $rdn_format = 3;
+ } elsif ($_ =~ /rdn-format-3/) {
+ $rdn_format = 4;
+ } elsif ($_ =~ /rdn-format-4/) {
+ $rdn_format = 5;
+ } elsif ($_ =~ /rdn-format-5/) {
+ $rdn_format = 6;
+ } elsif ($_ =~ /rdn-format-/) {
+ # assume greater than -5
+ $rdn_format = 7;
+ }
+ }
+ }
+ close DBVERSION;
+ }
+
+ while ($instconf) {
+ my $backend= $instconf->getValues('cn');
+ if (($backend eq "config") || ($backend eq "monitor")) {
+ goto NEXT;
+ }
+
+ for (my $idx = 0; $ <= $#toreindex; $idx++) {
+ if (0 == $rdnconditions[$idx] || $rdnconditions[$idx] > $rdn_format) {
+ my $rc = system("$reindex -n $backend -t $idx");
+ if ($rc) {
+ push @errs, ["error_reindexng", $idx, $backend, $rc];
+ }
+ }
+ }
+NEXT:
+ $instconf = $conn->nextEntry();
+ }
+
+ return @errs;
+}
diff --git a/ldap/admin/src/scripts/91subtreereindex.pl b/ldap/admin/src/scripts/91subtreereindex.pl
index a031cc1a4..c4b40a3de 100644
--- a/ldap/admin/src/scripts/91subtreereindex.pl
+++ b/ldap/admin/src/scripts/91subtreereindex.pl
@@ -51,14 +51,18 @@ sub runinst {
if ($_ =~ /rdn-format-1/) {
$is_rdn_format = 2;
}
- if ($_ =~ /rdn-format-2/) {
+ elsif ($_ =~ /rdn-format-2/) {
$is_rdn_format = 3;
}
+ elsif ($_ =~ /rdn-format-/) {
+ # assume greater than -2
+ $is_rdn_format = 4;
+ }
}
}
close DBVERSION;
- if (3 == $is_rdn_format) {
+ if (3 <= $is_rdn_format) {
return (); # DB already has the new rdn format.
}
diff --git a/ldap/admin/src/scripts/setup-ds.res.in b/ldap/admin/src/scripts/setup-ds.res.in
index fa3756766..e46b8583d 100644
--- a/ldap/admin/src/scripts/setup-ds.res.in
+++ b/ldap/admin/src/scripts/setup-ds.res.in
@@ -209,3 +209,4 @@ error_opening_file = Opening file '%s' failed. Error: %s\n
error_format_error = '%s' has invalid format.\n
error_update_not_offline = Error: offline mode selected but the server [%s] is still running.\n
error_update_all = Failed to update all the Directory Server instances.\n
+error_reindexing = Failed to reindex '%s' in backend '%s'. Error: %s\n
diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in
index f18c08248..46b416bd1 100644
--- a/ldap/ldif/template-dse.ldif.in
+++ b/ldap/ldif/template-dse.ldif.in
@@ -930,6 +930,7 @@ objectclass: nsIndex
cn: parentid
nssystemindex: true
nsindextype: eq
+nsmatchingrule: integerOrderingMatch
dn: cn=seeAlso,cn=default indexes, cn=config,cn=ldbm database,cn=plugins,cn=config
objectclass: top
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 14020b7b5..3330a629b 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -405,7 +405,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
{
if (apply_mods)
replica_set_precise_purging(r, 0);
- }
+ }
else
{
*returncode = LDAP_UNWILLING_TO_PERFORM;
@@ -567,8 +567,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
{
if (apply_mods)
{
- if (apply_mods && config_attr_value[0])
- {
+ if (config_attr_value[0]) {
PRUint64 on_off = 0;
if (strcasecmp(config_attr_value, "on") == 0){
@@ -587,7 +586,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
break;
}
replica_set_precise_purging(r, on_off);
- } else if (apply_mods) {
+ } else {
replica_set_precise_purging(r, 0);
}
}
diff --git a/ldap/servers/plugins/replication/repl5_tot_protocol.c b/ldap/servers/plugins/replication/repl5_tot_protocol.c
index d0c4402d1..03d0c3e31 100644
--- a/ldap/servers/plugins/replication/repl5_tot_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_tot_protocol.c
@@ -323,6 +323,10 @@ repl5_tot_run(Private_Repl_Protocol *prp)
int init_retry = 0;
Replica *replica;
ReplicaId rid = 0; /* Used to create the replica keep alive subentry */
+ Slapi_Entry *suffix = NULL;
+ char **instances = NULL;
+ Slapi_Backend *be = NULL;
+ int is_entryrdn = 0;
PR_ASSERT(NULL != prp);
@@ -354,21 +358,21 @@ retry:
*/
if (rc != ACQUIRE_SUCCESS)
{
- int optype, ldaprc, wait_retry;
- conn_get_error(prp->conn, &optype, &ldaprc);
- if (rc == ACQUIRE_TRANSIENT_ERROR && INIT_RETRY_MAX > init_retry++) {
- wait_retry = init_retry * INIT_RETRY_INT;
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
- "acquire replica for total update, error: %d,"
+ int optype, ldaprc, wait_retry;
+ conn_get_error(prp->conn, &optype, &ldaprc);
+ if (rc == ACQUIRE_TRANSIENT_ERROR && INIT_RETRY_MAX > init_retry++) {
+ wait_retry = init_retry * INIT_RETRY_INT;
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
+ "acquire replica for total update, error: %d,"
" retrying in %d seconds.\n",
- ldaprc, wait_retry);
- DS_Sleep(PR_SecondsToInterval(wait_retry));
- goto retry;
- } else {
- agmt_set_last_init_status(prp->agmt, ldaprc,
- prp->last_acquire_response_code, 0, NULL);
- goto done;
- }
+ ldaprc, wait_retry);
+ DS_Sleep(PR_SecondsToInterval(wait_retry));
+ goto retry;
+ } else {
+ agmt_set_last_init_status(prp->agmt, ldaprc,
+ prp->last_acquire_response_code, 0, NULL);
+ goto done;
+ }
}
else if (prp->terminate)
{
@@ -405,48 +409,121 @@ retry:
and that the order implies that perent entry is always ahead of the
child entry in the list. Otherwise, the consumer would not be
properly updated because bulk import at the moment skips orphand entries. */
- /* XXXggood above assumption may not be valid if orphaned entry moved???? */
+ /* XXXggood above assumption may not be valid if orphaned entry moved???? */
agmt_set_last_init_status(prp->agmt, 0, 0, 0, "Total update in progress");
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Beginning total update of replica "
- "\"%s\".\n", agmt_get_long_name(prp->agmt));
+ "\"%s\".\n", agmt_get_long_name(prp->agmt));
/* RMREPL - need to send schema here */
pb = slapi_pblock_new ();
- /* we need to provide managedsait control so that referral entries can
- be replicated */
- ctrls = (LDAPControl **)slapi_ch_calloc (3, sizeof (LDAPControl *));
- ctrls[0] = create_managedsait_control ();
- ctrls[1] = create_backend_control(area_sdn);
+ replica = (Replica*) object_get_data(prp->replica_object);
+ /*
+ * Get the info about the entryrdn vs. entrydn from the backend.
+ * If NOT is_entryrdn, its ancestor entries are always found prior to an entry.
+ */
+ rc = slapi_lookup_instance_name_by_suffix((char *)slapi_sdn_get_dn(area_sdn), NULL, &instances, 1);
+ if (rc || !instances) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
+ "get the instance name for the suffix \"%s\".\n", slapi_sdn_get_dn(area_sdn));
+ goto done;
+ }
+ be = slapi_be_select_by_instance_name(instances[0]);
+ if (!be) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
+ "get the instance for the suffix \"%s\".\n", slapi_sdn_get_dn(area_sdn));
+ goto done;
+ }
+ rc = slapi_back_get_info(be, BACK_INFO_IS_ENTRYRDN, (void **)&is_entryrdn);
+ if (is_entryrdn) {
+ /*
+ * Supporting entries out of order -- parent could have a larger id than its children.
+ * Entires are retireved sorted by parentid without the allid threshold.
+ */
+ /* Get suffix */
+ rc = slapi_search_internal_get_entry(area_sdn, NULL, &suffix, repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION));
+ if (rc) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
+ "get the suffix entry \"%s\".\n", slapi_sdn_get_dn(area_sdn));
+ goto done;
+ }
- /* Time to make sure it exists a keep alive subentry for that replica */
- replica = (Replica*) object_get_data(prp->replica_object);
- if (replica)
- {
- rid = replica_get_rid(replica);
- }
- replica_subentry_check(area_sdn, rid);
-
- slapi_search_internal_set_pb (pb, slapi_sdn_get_dn (area_sdn),
- LDAP_SCOPE_SUBTREE, "(|(objectclass=ldapsubentry)(objectclass=nstombstone)(nsuniqueid=*))", NULL, 0, ctrls, NULL,
- repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION), 0);
-
- cb_data.prp = prp;
- cb_data.rc = 0;
- cb_data.num_entries = 0UL;
- cb_data.sleep_on_busy = 0UL;
- cb_data.last_busy = current_time ();
- cb_data.flowcontrol_detection = 0;
- cb_data.lock = PR_NewLock();
-
- /* This allows during perform_operation to check the callback data
- * especially to do flow contol on delta send msgid / recv msgid
- */
- conn_set_tot_update_cb(prp->conn, (void *) &cb_data);
+ cb_data.prp = prp;
+ cb_data.rc = 0;
+ cb_data.num_entries = 1UL;
+ cb_data.sleep_on_busy = 0UL;
+ cb_data.last_busy = current_time ();
+ cb_data.flowcontrol_detection = 0;
+ cb_data.lock = PR_NewLock();
+
+ /* This allows during perform_operation to check the callback data
+ * especially to do flow contol on delta send msgid / recv msgid
+ */
+ conn_set_tot_update_cb(prp->conn, (void *) &cb_data);
+
+ /* Send suffix first. */
+ rc = send_entry(suffix, (void *)&cb_data);
+ if (rc) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
+ "send the suffix entry \"%s\" to the consumer.\n", slapi_sdn_get_dn(area_sdn));
+ goto done;
+ }
+
+ /* we need to provide managedsait control so that referral entries can
+ be replicated */
+ ctrls = (LDAPControl **)slapi_ch_calloc (3, sizeof (LDAPControl *));
+ ctrls[0] = create_managedsait_control ();
+ ctrls[1] = create_backend_control(area_sdn);
+
+ /* Time to make sure it exists a keep alive subentry for that replica */
+ if (replica)
+ {
+ rid = replica_get_rid(replica);
+ }
+ replica_subentry_check(area_sdn, rid);
+ /* Send the subtree of the suffix in the order of parentid index plus ldapsubentry and nstombstone. */
+ slapi_search_internal_set_pb(pb, slapi_sdn_get_dn (area_sdn),
+ LDAP_SCOPE_SUBTREE, "(|(parentid>=1)(objectclass=ldapsubentry)(objectclass=nstombstone))", NULL, 0, ctrls, NULL,
+ repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION), 0);
+ cb_data.num_entries = 0UL;
+ } else {
+ /* Original total update */
+ /* we need to provide managedsait control so that referral entries can
+ be replicated */
+ ctrls = (LDAPControl **)slapi_ch_calloc (3, sizeof (LDAPControl *));
+ ctrls[0] = create_managedsait_control ();
+ ctrls[1] = create_backend_control(area_sdn);
+
+ /* Time to make sure it exists a keep alive subentry for that replica */
+ replica = (Replica*) object_get_data(prp->replica_object);
+ if (replica)
+ {
+ rid = replica_get_rid(replica);
+ }
+ replica_subentry_check(area_sdn, rid);
+
+ slapi_search_internal_set_pb (pb, slapi_sdn_get_dn (area_sdn),
+ LDAP_SCOPE_SUBTREE, "(|(objectclass=ldapsubentry)(objectclass=nstombstone)(nsuniqueid=*))", NULL, 0, ctrls, NULL,
+ repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION), 0);
+
+ cb_data.prp = prp;
+ cb_data.rc = 0;
+ cb_data.num_entries = 0UL;
+ cb_data.sleep_on_busy = 0UL;
+ cb_data.last_busy = current_time ();
+ cb_data.flowcontrol_detection = 0;
+ cb_data.lock = PR_NewLock();
+
+ /* This allows during perform_operation to check the callback data
+ * especially to do flow contol on delta send msgid / recv msgid
+ */
+ conn_set_tot_update_cb(prp->conn, (void *) &cb_data);
+ }
+
/* Before we get started on sending entries to the replica, we need to
* setup things for async propagation:
* 1. Create a thread that will read the LDAP results from the connection.
@@ -470,7 +547,7 @@ retry:
slapi_search_internal_callback_pb (pb, &cb_data /* callback data */,
get_result /* result callback */,
send_entry /* entry callback */,
- NULL /* referral callback*/);
+ NULL /* referral callback*/);
/*
* After completing the sending operation (or optionally failing), we need to clean up
diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h
index 949929205..2d77a8aec 100644
--- a/ldap/servers/slapd/back-ldbm/back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h
@@ -132,7 +132,7 @@ typedef unsigned short u_int16_t;
#define BDB_BACKEND "libback-ldbm" /* This backend plugin */
#define BDB_NEWIDL "newidl" /* new idl format */
#define BDB_RDNFORMAT "rdn-format" /* Subtree rename enabled */
-#define BDB_RDNFORMAT_VERSION "2" /* rdn-format version (by default, 0) */
+#define BDB_RDNFORMAT_VERSION "3" /* rdn-format version (by default, 0) */
#define BDB_DNFORMAT "dn-4514" /* DN format RFC 4514 compliant */
#define BDB_DNFORMAT_VERSION "1" /* DN format version */
@@ -808,11 +808,11 @@ typedef struct _back_search_result_set
/* #define LDBM_ENTRYRDN_OID "2.16.840.1.113730.3.1.2097" */
#define LDBM_ANCESTORID_STR "ancestorid"
-#define LDBM_ENTRYDN_STR "entrydn"
+#define LDBM_ENTRYDN_STR SLAPI_ATTR_ENTRYDN
#define LDBM_ENTRYRDN_STR "entryrdn"
#define LDBM_NUMSUBORDINATES_STR "numsubordinates"
#define LDBM_TOMBSTONE_NUMSUBORDINATES_STR "tombstonenumsubordinates"
-#define LDBM_PARENTID_STR "parentid"
+#define LDBM_PARENTID_STR SLAPI_ATTR_PARENTID
/* Name of psuedo attribute used to track default indexes */
#define LDBM_PSEUDO_ATTR_DEFAULT ".default"
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index bc290cb2e..93d42bed8 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -7315,6 +7315,11 @@ ldbm_back_get_info(Slapi_Backend *be, int cmd, void **info)
}
break;
}
+ case BACK_INFO_IS_ENTRYRDN:
+ {
+ *(int *)info = entryrdn_get_switch();
+ break;
+ }
default:
break;
}
diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c
index 9c14de421..9a7e7bed1 100644
--- a/ldap/servers/slapd/back-ldbm/filterindex.c
+++ b/ldap/servers/slapd/back-ldbm/filterindex.c
@@ -552,6 +552,7 @@ range_candidates(
struct berval *low = NULL, *high = NULL;
struct berval **lows = NULL, **highs = NULL;
back_txn txn = {NULL};
+ int operator = 0;
LDAPDebug(LDAP_DEBUG_TRACE, "=> range_candidates attr=%s\n", type, 0, 0);
@@ -578,18 +579,21 @@ range_candidates(
}
high = attr_value_lowest(highs, slapi_berval_cmp);
}
-
+ if (entryrdn_get_switch() && !strcasecmp(type, LDBM_PARENTID_STR)) {
+ /* parentid is treated specially that is needed for the bulk import. (See #48755) */
+ operator = SLAPI_OP_RANGE_NO_IDL_SORT|SLAPI_OP_RANGE_NO_ALLIDS;
+ }
if (low == NULL) {
- idl = index_range_read_ext(pb, be, type, (char*)indextype_EQUALITY,
- SLAPI_OP_LESS_OR_EQUAL,
+ operator |= SLAPI_OP_LESS_OR_EQUAL;
+ idl = index_range_read_ext(pb, be, type, (char*)indextype_EQUALITY, operator,
high, NULL, 0, &txn, err, allidslimit);
} else if (high == NULL) {
- idl = index_range_read_ext(pb, be, type, (char*)indextype_EQUALITY,
- SLAPI_OP_GREATER_OR_EQUAL,
+ operator |= SLAPI_OP_GREATER_OR_EQUAL;
+ idl = index_range_read_ext(pb, be, type, (char*)indextype_EQUALITY, operator,
low, NULL, 0, &txn, err, allidslimit);
} else {
- idl = index_range_read_ext(pb, be, type, (char*)indextype_EQUALITY,
- SLAPI_OP_LESS_OR_EQUAL,
+ operator |= SLAPI_OP_LESS_OR_EQUAL;
+ idl = index_range_read_ext(pb, be, type, (char*)indextype_EQUALITY, operator,
low, high, 1, &txn, err, allidslimit);
}
diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c
index 25b3bfa2b..6ca6c96fd 100644
--- a/ldap/servers/slapd/back-ldbm/idl_new.c
+++ b/ldap/servers/slapd/back-ldbm/idl_new.c
@@ -350,17 +350,31 @@ error:
return idl;
}
+typedef struct _range_id_pair {
+ ID key;
+ ID id;
+} idl_range_id_pair;
/*
* Perform the range search in the idl layer instead of the index layer
* to improve the performance.
*/
+/*
+ * NOTE:
+ * In the total update (bulk import), an entry requires its ancestors already added.
+ * To guarantee it, the range search with parentid is used with setting the flag
+ * SLAPI_OP_RANGE_NO_IDL_SORT in operator.
+ *
+ * If the flag is set,
+ * 1. the IDList is not sorted by the ID.
+ * 2. holding to add an ID to the IDList unless the key is found in the IDList.
+ */
IDList *
idl_new_range_fetch(
- backend *be,
- DB* db,
- DBT *lowerkey,
+ backend *be,
+ DB* db,
+ DBT *lowerkey,
DBT *upperkey,
- DB_TXN *txn,
+ DB_TXN *txn,
struct attrinfo *ai,
int *flag_err,
int allidslimit,
@@ -380,7 +394,7 @@ idl_new_range_fetch(
size_t count = 0;
#ifdef DB_USE_BULK_FETCH
/* beware that a large buffer on the stack might cause a stack overflow on some platforms */
- char buffer[BULK_FETCH_BUFFER_SIZE];
+ char buffer[BULK_FETCH_BUFFER_SIZE];
void *ptr;
DBT dataret;
#endif
@@ -388,15 +402,21 @@ idl_new_range_fetch(
struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private;
time_t curtime;
void *saved_key = NULL;
+ int coreop = operator & SLAPI_OP_RANGE;
+ ID key;
+ ID suffix;
+ idl_range_id_pair *leftover = NULL;
+ size_t leftoverlen = 32;
+ int leftovercnt = 0;
if (NULL == flag_err) {
return NULL;
}
- *flag_err = 0;
if (NEW_IDL_NOOP == *flag_err) {
return NULL;
}
+
dblayer_txn_init(li, &s_txn);
if (txn) {
dblayer_read_txn_begin(be, txn, &s_txn);
@@ -460,7 +480,7 @@ idl_new_range_fetch(
#ifdef DB_USE_BULK_FETCH
while (cur_key.data &&
(upperkey && upperkey->data ?
- ((operator == SLAPI_OP_LESS) ?
+ ((coreop == SLAPI_OP_LESS) ?
DBTcmp(&cur_key, upperkey, ai->ai_key_cmp_fn) < 0 :
DBTcmp(&cur_key, upperkey, ai->ai_key_cmp_fn) <= 0) :
PR_TRUE /* e.g., (x > a) */)) {
@@ -496,6 +516,9 @@ idl_new_range_fetch(
goto error;
}
}
+ if (operator & SLAPI_OP_RANGE_NO_IDL_SORT) {
+ key = (ID)strtol((char *)cur_key.data+1 , (char **)NULL, 10);
+ }
while (PR_TRUE) {
DB_MULTIPLE_NEXT(ptr, &data, dataret.data, dataret.size);
if (dataret.data == NULL) break;
@@ -524,7 +547,29 @@ idl_new_range_fetch(
/* note the last id read to check for dups */
lastid = id;
/* we got another ID, add it to our IDL */
- idl_rc = idl_append_extend(&idl, id);
+ if (operator & SLAPI_OP_RANGE_NO_IDL_SORT) {
+ if (!idl) {
+ /* First time. Keep the suffix ID. */
+ suffix = key;
+ idl_rc = idl_append_extend(&idl, id);
+ } else if ((key == suffix) || idl_id_is_in_idlist(idl, key)) {
+ /* the parent is the suffix or already in idl. */
+ idl_rc = idl_append_extend(&idl, id);
+ } else {
+ /* Otherwise, keep the {key,id} in leftover array */
+ if (!leftover) {
+ leftover = (idl_range_id_pair *)slapi_ch_calloc(leftoverlen, sizeof(idl_range_id_pair));
+ } else if (leftovercnt == leftoverlen) {
+ leftover = (idl_range_id_pair *)slapi_ch_realloc((char *)leftover, 2 * leftoverlen * sizeof(idl_range_id_pair));
+ memset(leftover + leftovercnt, 0, leftoverlen);
+ leftoverlen *= 2;
+ }
+ leftover[leftovercnt].key = key;
+ leftover[leftovercnt++].id = id;
+ }
+ } else {
+ idl_rc = idl_append_extend(&idl, id);
+ }
if (idl_rc) {
LDAPDebug1Arg(LDAP_DEBUG_ANY,
"unable to extend id list (err=%d)\n", idl_rc);
@@ -581,7 +626,7 @@ idl_new_range_fetch(
}
#else
while (upperkey && upperkey->data ?
- ((operator == SLAPI_OP_LESS) ?
+ ((coreop == SLAPI_OP_LESS) ?
DBTcmp(&cur_key, upperkey, ai->ai_key_cmp_fn) < 0 :
DBTcmp(&cur_key, upperkey, ai->ai_key_cmp_fn) <= 0) :
PR_TRUE /* e.g., (x > a) */) {
@@ -698,9 +743,27 @@ error:
*flag_err = ret;
/* sort idl */
- if (idl && !ALLIDS(idl)) {
- qsort((void *)&idl->b_ids[0], idl->b_nids,
- (size_t)sizeof(ID), idl_sort_cmp);
+ if (idl && !ALLIDS(idl) && !(operator & SLAPI_OP_RANGE_NO_IDL_SORT)) {
+ qsort((void *)&idl->b_ids[0], idl->b_nids, (size_t)sizeof(ID), idl_sort_cmp);
+ }
+ if (operator & SLAPI_OP_RANGE_NO_IDL_SORT) {
+ int i;
+ int left = leftovercnt;
+ while (left) {
+ for (i = 0; i < leftovercnt; i++) {
+ if (leftover[i].key && idl_id_is_in_idlist(idl, leftover[i].key)) {
+ idl_rc = idl_append_extend(&idl, leftover[i].id);
+ if (idl_rc) {
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "unable to extend id list (err=%d)\n", idl_rc);
+ idl_free(&idl);
+ return NULL;
+ }
+ leftover[i].key = 0;
+ left--;
+ }
+ }
+ }
+ slapi_ch_free((void **)&leftover);
}
return idl;
}
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 00e78a7bc..81d662196 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -1232,6 +1232,7 @@ index_range_read_ext(
int timelimit = -1;
back_search_result_set *sr = NULL;
int isroot = 0;
+ int coreop = operator & SLAPI_OP_RANGE;
if (!pb) {
LDAPDebug(LDAP_DEBUG_ANY, "index_range_read: NULL pblock\n",
@@ -1278,7 +1279,7 @@ index_range_read_ext(
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "index_range_read lookthrough_limit=%d\n",
lookthrough_limit);
- switch( operator ) {
+ switch( coreop ) {
case SLAPI_OP_LESS:
case SLAPI_OP_LESS_OR_EQUAL:
case SLAPI_OP_GREATER_OR_EQUAL:
@@ -1287,7 +1288,7 @@ index_range_read_ext(
default:
LDAPDebug( LDAP_DEBUG_ANY,
"<= index_range_read(%s,%s) NULL (operator %i)\n",
- type, prefix, operator );
+ type, prefix, coreop );
index_free_prefix(prefix);
return( NULL );
}
@@ -1343,7 +1344,7 @@ index_range_read_ext(
if (range != 1) { /* open range search */
char *tmpbuf = NULL;
/* this is a search with only one boundary value */
- switch( operator ) {
+ switch( coreop ) {
case SLAPI_OP_LESS:
case SLAPI_OP_LESS_OR_EQUAL:
lowerkey.dptr = slapi_ch_strdup(prefix);
@@ -1451,8 +1452,17 @@ index_range_read_ext(
cur_key.data = lowerkey.data;
cur_key.size = lowerkey.size;
lowerkey.data = NULL; /* Don't need this any more, since the memory will be freed from cur_key */
- if (operator == SLAPI_OP_GREATER) {
- *err = index_range_next_key(db,&cur_key,db_txn);
+ *err = 0;
+ if (coreop == SLAPI_OP_GREATER) {
+ *err = index_range_next_key(db, &cur_key, db_txn);
+ if (*err) {
+ LDAPDebug(LDAP_DEBUG_ANY, "<= index_range_read(%s,%s) op==GREATER, no next key: %i)\n",
+ type, prefix, *err );
+ goto error;
+ }
+ }
+ if (operator & SLAPI_OP_RANGE_NO_ALLIDS) {
+ *err = NEW_IDL_NO_ALLID;
}
if (idl_get_idl_new()) { /* new idl */
idl = idl_new_range_fetch(be, db, &cur_key, &upperkey, db_txn,
@@ -1462,7 +1472,7 @@ index_range_read_ext(
int retry_count = 0;
while (*err == 0 &&
(upperkey.data &&
- (operator == SLAPI_OP_LESS) ?
+ (coreop == SLAPI_OP_LESS) ?
DBTcmp(&cur_key, &upperkey, ai->ai_key_cmp_fn) < 0 :
DBTcmp(&cur_key, &upperkey, ai->ai_key_cmp_fn) <= 0)) {
/* exit the loop when we either run off the end of the table,
diff --git a/ldap/servers/slapd/back-ldbm/init.c b/ldap/servers/slapd/back-ldbm/init.c
index a531abbf8..04cc9368f 100644
--- a/ldap/servers/slapd/back-ldbm/init.c
+++ b/ldap/servers/slapd/back-ldbm/init.c
@@ -36,7 +36,7 @@ ldbm_back_add_schema( Slapi_PBlock *pb )
SLAPI_ATTR_FLAG_NOUSERMOD );
rc |= slapi_add_internal_attr_syntax( LDBM_PARENTID_STR,
- LDBM_PARENTID_OID, DIRSTRING_SYNTAX_OID, CASEIGNOREMATCH_NAME,
+ LDBM_PARENTID_OID, INTEGER_SYNTAX_OID, INTEGERMATCH_NAME,
SLAPI_ATTR_FLAG_SINGLE|SLAPI_ATTR_FLAG_NOUSERMOD );
rc |= slapi_add_internal_attr_syntax( "entryid",
diff --git a/ldap/servers/slapd/back-ldbm/misc.c b/ldap/servers/slapd/back-ldbm/misc.c
index fe3d01bfb..77c1e70fe 100644
--- a/ldap/servers/slapd/back-ldbm/misc.c
+++ b/ldap/servers/slapd/back-ldbm/misc.c
@@ -79,6 +79,7 @@ static const char *systemIndexes[] = {
SLAPI_ATTR_NSCP_ENTRYDN,
ATTR_NSDS5_REPLCONFLICT,
SLAPI_ATTR_ENTRYUSN,
+ SLAPI_ATTR_PARENTID,
NULL
};
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 3124ff6af..d38f9709b 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -3429,8 +3429,8 @@ slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, Slapi_D
/* We remove the parentid and entrydn since the backend will change these.
* We don't want to give the caller an inconsistent entry. */
- slapi_entry_attr_delete(e, "parentid");
- slapi_entry_attr_delete(e, "entrydn");
+ slapi_entry_attr_delete(e, SLAPI_ATTR_PARENTID);
+ slapi_entry_attr_delete(e, SLAPI_ATTR_ENTRYDN);
/* Build new DN. If newsuperior is set, just use "newrdn,newsuperior". If
* newsuperior is not set, need to add newrdn to old superior. */
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index a594a2916..ea834f1f1 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -536,12 +536,16 @@ typedef int (*SyntaxEnumFunc)(char **names, Slapi_PluginDesc *plugindesc,
/* OIDs for some commonly used matching rules */
#define DNMATCH_OID "2.5.13.1" /* distinguishedNameMatch */
#define CASEIGNOREMATCH_OID "2.5.13.2" /* caseIgnoreMatch */
+#define INTEGERMATCH_OID "2.5.13.14" /* integerMatch */
+#define INTEGERORDERINGMATCH_OID "2.5.13.15" /* integerOrderingMatch */
#define INTFIRSTCOMPMATCH_OID "2.5.13.29" /* integerFirstComponentMatch */
#define OIDFIRSTCOMPMATCH_OID "2.5.13.30" /* objectIdentifierFirstComponentMatch */
/* Names for some commonly used matching rules */
#define DNMATCH_NAME "distinguishedNameMatch"
#define CASEIGNOREMATCH_NAME "caseIgnoreMatch"
+#define INTEGERMATCH_NAME "integerMatch"
+#define INTEGERORDERINGMATCH_NAME "integerOrderingMatch"
#define INTFIRSTCOMPMATCH_NAME "integerFirstComponentMatch"
#define OIDFIRSTCOMPMATCH_NAME "objectIdentifierFirstComponentMatch"
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 294f2c34b..856432e54 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -483,6 +483,7 @@ NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
#define SLAPI_ATTR_ENTRYDN "entrydn"
#define SLAPI_ATTR_DN "dn"
#define SLAPI_ATTR_RDN "rdn"
+#define SLAPI_ATTR_PARENTID "parentid"
#define SLAPI_ATTR_UNIQUEID_LENGTH 10
#define SLAPI_ATTR_OBJECTCLASS_LENGTH 11
#define SLAPI_ATTR_VALUE_TOMBSTONE_LENGTH 11
@@ -494,6 +495,7 @@ NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
#define SLAPI_ATTR_ENTRYDN_LENGTH 7
#define SLAPI_ATTR_DN_LENGTH 2
#define SLAPI_ATTR_RDN_LENGTH 3
+#define SLAPI_ATTR_PARENTID_LENGTH 8
/* plugin shared config area */
#define SLAPI_PLUGIN_SHARED_CONFIG_AREA "nsslapd-pluginConfigArea"
@@ -7002,6 +7004,9 @@ typedef struct slapi_plugindesc {
#define SLAPI_OP_GREATER_OR_EQUAL 4
#define SLAPI_OP_GREATER 5
#define SLAPI_OP_SUBSTRING 6
+#define SLAPI_OP_RANGE 0xff
+#define SLAPI_OP_RANGE_NO_IDL_SORT 0x100
+#define SLAPI_OP_RANGE_NO_ALLIDS 0x200
/* Defined values of SLAPI_PLUGIN_MR_USAGE: */
#define SLAPI_PLUGIN_MR_USAGE_INDEX 0
@@ -7585,7 +7590,8 @@ enum
BACK_INFO_CRYPT_ENCRYPT_VALUE, /* Ctrl: clcrypt_encrypt_value */
BACK_INFO_CRYPT_DECRYPT_VALUE, /* Ctrl: clcrypt_decrypt_value */
BACK_INFO_DIRECTORY, /* Get the directory path */
- BACK_INFO_LOG_DIRECTORY /* Get the txn log directory */
+ BACK_INFO_LOG_DIRECTORY, /* Get the txn log directory */
+ BACK_INFO_IS_ENTRYRDN /* Get the flag for entryrdn */
};
struct _back_info_crypt_init {
| 0 |
5d5b9c617e8c73f3771720c1f6906bddae2612db
|
389ds/389-ds-base
|
Ticket 49273 - Fix compiler warning in dbversion_write, missing newline
Bug Description: 49273 was missing a new line, and there was a
nearby (unrelated) compiler warning.
Fix Description: Add the new line, and resolve the compiler warning.
https://pagure.io/389-ds-base/issue/49273
Author: wibrown
Review by: mreynolds (Thanks!)
|
commit 5d5b9c617e8c73f3771720c1f6906bddae2612db
Author: William Brown <[email protected]>
Date: Thu Jun 1 09:34:41 2017 +1000
Ticket 49273 - Fix compiler warning in dbversion_write, missing newline
Bug Description: 49273 was missing a new line, and there was a
nearby (unrelated) compiler warning.
Fix Description: Add the new line, and resolve the compiler warning.
https://pagure.io/389-ds-base/issue/49273
Author: wibrown
Review by: mreynolds (Thanks!)
diff --git a/ldap/servers/slapd/back-ldbm/dbversion.c b/ldap/servers/slapd/back-ldbm/dbversion.c
index 2d7d82e92..33ca329f9 100644
--- a/ldap/servers/slapd/back-ldbm/dbversion.c
+++ b/ldap/servers/slapd/back-ldbm/dbversion.c
@@ -101,8 +101,7 @@ dbversion_write(struct ldbminfo *li, const char *directory,
len = strlen(buf);
if ( slapi_write_buffer( prfd, buf, len ) != (PRInt32)len )
{
- slapi_log_err(SLAPI_LOG_ERR, "dbversion_write",
- "Could not write to file \"%s\"\n", filename, 0, 0 );
+ slapi_log_err(SLAPI_LOG_ERR, "dbversion_write", "Could not write to file \"%s\"\n", filename );
rc= -1;
}
if(rc==0 && dataversion!=NULL)
@@ -111,8 +110,7 @@ dbversion_write(struct ldbminfo *li, const char *directory,
len = strlen( buf );
if ( slapi_write_buffer( prfd, buf, len ) != (PRInt32)len )
{
- slapi_log_err(SLAPI_LOG_ERR, "dbversion_write",
- "Could not write to file \"%s\"\n", filename, 0, 0 );
+ slapi_log_err(SLAPI_LOG_ERR, "dbversion_write", "Could not write to file \"%s\"\n", filename );
rc= -1;
}
}
@@ -185,7 +183,7 @@ dbversion_read(struct ldbminfo *li, const char *directory,
* which seems appropriate for the error here :)
*/
slapi_log_err(SLAPI_LOG_CRIT, "dbversion_read", "Could not parse file \"%s\". It may be corrupted.\n", filename);
- slapi_log_err(SLAPI_LOG_CRIT, "dbversion_read", "It may be possible to recover by replacing with a valid DBVERSION file from another DB instance");
+ slapi_log_err(SLAPI_LOG_CRIT, "dbversion_read", "It may be possible to recover by replacing with a valid DBVERSION file from another DB instance\n");
return EIDRM;
}
| 0 |
a4c4e4ec20c65507c6a4fdd6f7a02734abc1ab73
|
389ds/389-ds-base
|
Issue 5598 - In 2.x, SRCH throughput drops by 10% because of handling of referral (#5604)
Bug description:
A part of the fix #5170 append '(objectclass=referral)' to
the original filter (in subtree scope) in order to conform
smart referral support https://www.ietf.org/rfc/rfc3296.txt
This triggers a drop on SRCH throughput (10%).
#5598 limits the case when '(objectclass=referral)' is added
- Most of the time a server does not contain smart referral.
So most of the time it is useless to add that subfilter
- It should not be added for internal searches
Fix description:
A mechanism periodically (each 30s) checks if there are
smart referral entries (referral_check) under each backends.
Note that if a smart referral is present in a subsuffix,
the parent suffix inherits the referral flag.
When a smart referral is detected or no more smart
referral is detected it logs a information message.
During a direct subtree search, 'objectclass=referral' is
append at the condition it exists at least a referral
under the backend.
relates: #5598
Reviewed by: Mark Reynolds, Pierre Rogier, William Brown (Thanks)
|
commit a4c4e4ec20c65507c6a4fdd6f7a02734abc1ab73
Author: tbordaz <[email protected]>
Date: Wed Feb 22 15:06:52 2023 +0100
Issue 5598 - In 2.x, SRCH throughput drops by 10% because of handling of referral (#5604)
Bug description:
A part of the fix #5170 append '(objectclass=referral)' to
the original filter (in subtree scope) in order to conform
smart referral support https://www.ietf.org/rfc/rfc3296.txt
This triggers a drop on SRCH throughput (10%).
#5598 limits the case when '(objectclass=referral)' is added
- Most of the time a server does not contain smart referral.
So most of the time it is useless to add that subfilter
- It should not be added for internal searches
Fix description:
A mechanism periodically (each 30s) checks if there are
smart referral entries (referral_check) under each backends.
Note that if a smart referral is present in a subsuffix,
the parent suffix inherits the referral flag.
When a smart referral is detected or no more smart
referral is detected it logs a information message.
During a direct subtree search, 'objectclass=referral' is
append at the condition it exists at least a referral
under the backend.
relates: #5598
Reviewed by: Mark Reynolds, Pierre Rogier, William Brown (Thanks)
diff --git a/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py b/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py
index 67605438b..69df047e3 100644
--- a/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py
+++ b/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py
@@ -8,13 +8,18 @@
#
from decimal import *
import os
+import time
import logging
import pytest
import subprocess
+from lib389.backend import Backend
+from lib389.mappingTree import MappingTrees
+from lib389.idm.domain import Domain
+from lib389.configurations.sample import create_base_domain
from lib389._mapped_object import DSLdapObject
from lib389.topologies import topology_st
from lib389.plugins import AutoMembershipPlugin, ReferentialIntegrityPlugin, AutoMembershipDefinitions, MemberOfPlugin
-from lib389.idm.user import UserAccounts
+from lib389.idm.user import UserAccounts, UserAccount
from lib389.idm.group import Groups
from lib389.idm.organizationalunit import OrganizationalUnits
from lib389._constants import DEFAULT_SUFFIX, LOG_ACCESS_LEVEL, PASSWORD
@@ -210,6 +215,32 @@ def disable_access_log_buffering(topology_st, request):
return disable_access_log_buffering
+def create_backend(inst, rdn, suffix):
+ # We only support dc= in this test.
+ assert suffix.startswith('dc=')
+ be1 = Backend(inst)
+ be1.create(properties={
+ 'cn': rdn,
+ 'nsslapd-suffix': suffix,
+ },
+ create_mapping_tree=False
+ )
+
+ # Now we temporarily make the MT for this node so we can add the base entry.
+ mts = MappingTrees(inst)
+ mt = mts.create(properties={
+ 'cn': suffix,
+ 'nsslapd-state': 'backend',
+ 'nsslapd-backend': rdn,
+ })
+
+ # Create the domain entry
+ create_base_domain(inst, suffix)
+ # Now delete the mt
+ mt.delete()
+
+ return be1
+
@pytest.mark.bz1273549
def test_check_default(topology_st):
"""Check the default value of nsslapd-logging-hr-timestamps-enabled,
@@ -1342,6 +1373,310 @@ def test_stat_internal_op(topology_st, request):
request.addfinalizer(fin)
+def test_referral_check(topology_st, request):
+ """Check that referral detection mechanism works
+
+ :id: ff9b4247-d1fd-4edc-ba74-6ad61e65c0a4
+ :setup: Standalone Instance
+ :steps:
+ 1. Set nsslapd-referral-check-period=7 to accelerate test
+ 2. Add a test entry
+ 3. Remove error log file
+ 4. Check that no referral entry exist
+ 5. Create a referral entry
+ 6. Check that the server detects the referral
+ 7. Delete the referral entry
+ 8. Check that the server detects the deletion of the referral
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Success
+ 8. Success
+ """
+
+ inst = topology_st.standalone
+
+ # Step 1 reduce nsslapd-referral-check-period to accelerate test
+ REFERRAL_CHECK=7
+ topology_st.standalone.config.set("nsslapd-referral-check-period", str(REFERRAL_CHECK))
+ topology_st.standalone.restart()
+
+ # Step 2 Add a test entry
+ users = UserAccounts(inst, DEFAULT_SUFFIX, rdn=None)
+ user = users.create(properties={'uid': 'test_1',
+ 'cn': 'test_1',
+ 'sn': 'test_1',
+ 'description': 'member',
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/testuser'})
+
+ # Step 3 Remove error log file
+ topology_st.standalone.stop()
+ lpath = topology_st.standalone.ds_error_log._get_log_path()
+ os.unlink(lpath)
+ topology_st.standalone.start()
+
+ # Step 4 Check that no referral entry is found (on regular deployment)
+ entries = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, "uid=test_1")
+ time.sleep(REFERRAL_CHECK + 1)
+ assert not topology_st.standalone.ds_error_log.match('.*slapd_daemon - New referral entries are detected.*')
+
+ # Step 5 Create a referral entry
+ REFERRAL_DN = "cn=my_ref,%s" % DEFAULT_SUFFIX
+ properties = ({'cn': 'my_ref',
+ 'uid': 'my_ref',
+ 'sn': 'my_ref',
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/testuser',
+ 'description': 'referral entry',
+ 'objectclass': "top referral extensibleObject".split(),
+ 'ref': 'ref: ldap://remote/%s' % REFERRAL_DN})
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.create(properties=properties)
+
+ # Step 6 Check that the server detected the referral
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - New referral entries are detected under %s.*' % DEFAULT_SUFFIX)
+ assert not topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % DEFAULT_SUFFIX)
+
+ # Step 7 Delete the referral entry
+ referral.delete()
+
+ # Step 8 Check that the server detected the deletion of the referral
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % DEFAULT_SUFFIX)
+
+ def fin():
+ log.info('Deleting user/referral')
+ try:
+ user.delete()
+ referral.delete()
+ except:
+ pass
+
+ request.addfinalizer(fin)
+
+def test_referral_subsuffix(topology_st, request):
+ """Test the results of an inverted parent suffix definition in the configuration.
+
+ For more details see:
+ https://www.port389.org/docs/389ds/design/mapping_tree_assembly.html
+
+ :id: 4faf210a-4fde-4e4f-8834-865bdc8f4d37
+ :setup: Standalone instance
+ :steps:
+ 1. First create two Backends, without mapping trees.
+ 2. create the mapping trees for these backends
+ 3. reduce nsslapd-referral-check-period to accelerate test
+ 4. Remove error log file
+ 5. Create a referral entry on parent suffix
+ 6. Check that the server detected the referral
+ 7. Delete the referral entry
+ 8. Check that the server detected the deletion of the referral
+ 9. Remove error log file
+ 10. Create a referral entry on child suffix
+ 11. Check that the server detected the referral on both parent and child suffixes
+ 12. Delete the referral entry
+ 13. Check that the server detected the deletion of the referral on both parent and child suffixes
+ 14. Remove error log file
+ 15. Create a referral entry on parent suffix
+ 16. Check that the server detected the referral on both parent and child suffixes
+ 17. Delete the child referral entry
+ 18. Check that the server detected the deletion of the referral on child suffix but not on parent suffix
+ 19. Delete the parent referral entry
+ 20. Check that the server detected the deletion of the referral parent suffix
+
+ :expectedresults:
+ all steps succeeds
+ """
+ inst = topology_st.standalone
+ # Step 1 First create two Backends, without mapping trees.
+ PARENT_SUFFIX='dc=parent,dc=com'
+ CHILD_SUFFIX='dc=child,%s' % PARENT_SUFFIX
+ be1 = create_backend(inst, 'Parent', PARENT_SUFFIX)
+ be2 = create_backend(inst, 'Child', CHILD_SUFFIX)
+ # Step 2 create the mapping trees for these backends
+ mts = MappingTrees(inst)
+ mt1 = mts.create(properties={
+ 'cn': PARENT_SUFFIX,
+ 'nsslapd-state': 'backend',
+ 'nsslapd-backend': 'Parent',
+ })
+ mt2 = mts.create(properties={
+ 'cn': CHILD_SUFFIX,
+ 'nsslapd-state': 'backend',
+ 'nsslapd-backend': 'Child',
+ 'nsslapd-parent-suffix': PARENT_SUFFIX,
+ })
+
+ dc_ex = Domain(inst, dn=PARENT_SUFFIX)
+ assert dc_ex.exists()
+
+ dc_st = Domain(inst, dn=CHILD_SUFFIX)
+ assert dc_st.exists()
+
+ # Step 3 reduce nsslapd-referral-check-period to accelerate test
+ # requires a restart done on step 4
+ REFERRAL_CHECK=7
+ topology_st.standalone.config.set("nsslapd-referral-check-period", str(REFERRAL_CHECK))
+
+ # Check that if we create a referral at parent level
+ # - referral is detected at parent backend
+ # - referral is not detected at child backend
+
+ # Step 3 Remove error log file
+ topology_st.standalone.stop()
+ lpath = topology_st.standalone.ds_error_log._get_log_path()
+ os.unlink(lpath)
+ topology_st.standalone.start()
+
+ # Step 4 Create a referral entry on parent suffix
+ REFERRAL_DN = "cn=my_ref,%s" % PARENT_SUFFIX
+ properties = ({'cn': 'my_ref',
+ 'uid': 'my_ref',
+ 'sn': 'my_ref',
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/testuser',
+ 'description': 'referral entry',
+ 'objectclass': "top referral extensibleObject".split(),
+ 'ref': 'ref: ldap://remote/%s' % REFERRAL_DN})
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.create(properties=properties)
+
+ # Step 5 Check that the server detected the referral
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - New referral entries are detected under %s.*' % PARENT_SUFFIX)
+ assert not topology_st.standalone.ds_error_log.match('.*slapd_daemon - New referral entries are detected under %s.*' % CHILD_SUFFIX)
+ assert not topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % PARENT_SUFFIX)
+
+ # Step 6 Delete the referral entry
+ referral.delete()
+
+ # Step 7 Check that the server detected the deletion of the referral
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % PARENT_SUFFIX)
+
+ # Check that if we create a referral at child level
+ # - referral is detected at parent backend
+ # - referral is detected at child backend
+
+ # Step 8 Remove error log file
+ topology_st.standalone.stop()
+ lpath = topology_st.standalone.ds_error_log._get_log_path()
+ os.unlink(lpath)
+ topology_st.standalone.start()
+
+ # Step 9 Create a referral entry on child suffix
+ REFERRAL_DN = "cn=my_ref,%s" % CHILD_SUFFIX
+ properties = ({'cn': 'my_ref',
+ 'uid': 'my_ref',
+ 'sn': 'my_ref',
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/testuser',
+ 'description': 'referral entry',
+ 'objectclass': "top referral extensibleObject".split(),
+ 'ref': 'ref: ldap://remote/%s' % REFERRAL_DN})
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.create(properties=properties)
+
+ # Step 10 Check that the server detected the referral on both parent and child suffixes
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - New referral entries are detected under %s.*' % PARENT_SUFFIX)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - New referral entries are detected under %s.*' % CHILD_SUFFIX)
+ assert not topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % CHILD_SUFFIX)
+
+ # Step 11 Delete the referral entry
+ referral.delete()
+
+ # Step 12 Check that the server detected the deletion of the referral on both parent and child suffixes
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % PARENT_SUFFIX)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % CHILD_SUFFIX)
+
+ # Check that if we create a referral at child level and parent level
+ # - referral is detected at parent backend
+ # - referral is detected at child backend
+
+ # Step 13 Remove error log file
+ topology_st.standalone.stop()
+ lpath = topology_st.standalone.ds_error_log._get_log_path()
+ os.unlink(lpath)
+ topology_st.standalone.start()
+
+ # Step 14 Create a referral entry on parent suffix
+ # Create a referral entry on child suffix
+ REFERRAL_DN = "cn=my_ref,%s" % PARENT_SUFFIX
+ properties = ({'cn': 'my_ref',
+ 'uid': 'my_ref',
+ 'sn': 'my_ref',
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/testuser',
+ 'description': 'referral entry',
+ 'objectclass': "top referral extensibleObject".split(),
+ 'ref': 'ref: ldap://remote/%s' % REFERRAL_DN})
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.create(properties=properties)
+ REFERRAL_DN = "cn=my_ref,%s" % CHILD_SUFFIX
+ properties = ({'cn': 'my_ref',
+ 'uid': 'my_ref',
+ 'sn': 'my_ref',
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ 'homeDirectory': '/home/testuser',
+ 'description': 'referral entry',
+ 'objectclass': "top referral extensibleObject".split(),
+ 'ref': 'ref: ldap://remote/%s' % REFERRAL_DN})
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.create(properties=properties)
+
+ # Step 15 Check that the server detected the referral on both parent and child suffixes
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - New referral entries are detected under %s.*' % PARENT_SUFFIX)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - New referral entries are detected under %s.*' % CHILD_SUFFIX)
+ assert not topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % CHILD_SUFFIX)
+
+ # Step 16 Delete the child referral entry
+ REFERRAL_DN = "cn=my_ref,%s" % CHILD_SUFFIX
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.delete()
+
+ # Step 17 Check that the server detected the deletion of the referral on child suffix but not on parent suffix
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % CHILD_SUFFIX)
+ assert not topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % PARENT_SUFFIX)
+
+ # Step 18 Delete the parent referral entry
+ REFERRAL_DN = "cn=my_ref,%s" % PARENT_SUFFIX
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.delete()
+
+ # Step 19 Check that the server detected the deletion of the referral parent suffix
+ time.sleep(REFERRAL_CHECK + 1)
+ assert topology_st.standalone.ds_error_log.match('.*slapd_daemon - No more referral entry under %s' % PARENT_SUFFIX)
+
+ def fin():
+ log.info('Deleting referral')
+ try:
+ REFERRAL_DN = "cn=my_ref,%s" % PARENT_SUFFIX
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.delete()
+ REFERRAL_DN = "cn=my_ref,%s" % CHILD_SUFFIX
+ referral = UserAccount(inst, REFERRAL_DN)
+ referral.delete()
+ except:
+ pass
+
+ request.addfinalizer(fin)
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
diff --git a/ldap/servers/slapd/back-ldbm/instance.c b/ldap/servers/slapd/back-ldbm/instance.c
index 53ffca1ad..70b40fb8b 100644
--- a/ldap/servers/slapd/back-ldbm/instance.c
+++ b/ldap/servers/slapd/back-ldbm/instance.c
@@ -259,6 +259,11 @@ ldbm_instance_start(backend *be)
}
rc = dblayer_instance_start(be, DBLAYER_NORMAL_MODE);
+ if (slapi_exist_referral(be)) {
+ slapi_be_set_flag(be, SLAPI_BE_FLAG_CONTAINS_REFERRAL);
+ } else {
+ slapi_be_unset_flag(be, SLAPI_BE_FLAG_CONTAINS_REFERRAL);
+ }
be->be_state = BE_STATE_STARTED;
PR_Unlock(be->be_state_lock);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index 838deb08b..61e9b11bb 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1002,6 +1002,7 @@ build_candidate_list(Slapi_PBlock *pb, backend *be, struct backentry *e, const c
int err = 0;
int r = 0;
char logbuf[1024] = {0};
+ Slapi_Operation *operation;
slapi_pblock_get(pb, SLAPI_SEARCH_FILTER, &filter);
if (NULL == filter) {
@@ -1036,8 +1037,18 @@ build_candidate_list(Slapi_PBlock *pb, backend *be, struct backentry *e, const c
case LDAP_SCOPE_SUBTREE:
/* Now optimise the filter for use */
slapi_filter_optimise(filter);
- /* make (|(originalfilter)(objectclass=referral)) */
- filter_exec = create_subtree_filter(filter, managedsait);
+
+ slapi_pblock_get(pb, SLAPI_OPERATION, &operation);
+ if (!slapi_be_is_flag_set(be, SLAPI_BE_FLAG_CONTAINS_REFERRAL) || (operation && operation_is_flag_set(operation, OP_FLAG_INTERNAL))) {
+ /* For performance reason, skip adding (objectclass=referral) in case
+ * - there is no referral on the server
+ * - this is an internal SRCH
+ */
+ filter_exec = slapi_filter_dup(filter);
+ } else {
+ /* make (|(originalfilter)(objectclass=referral)) */
+ filter_exec = create_subtree_filter(filter, managedsait);
+ }
slapi_log_err(SLAPI_LOG_FILTER, "ldbm_back_search", "Optimised SUB filter to - %s\n",
slapi_filter_to_string(filter_exec, logbuf, sizeof(logbuf)));
diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c
index 6f1e7a621..e0a498a8c 100644
--- a/ldap/servers/slapd/backend.c
+++ b/ldap/servers/slapd/backend.c
@@ -17,6 +17,7 @@
#include "nspr.h"
static PRMonitor *global_backend_mutex = NULL;
+static Slapi_Eq_Context referral_check_ctx = NULL;
void
be_init(Slapi_Backend *be, const char *type, const char *name, int isprivate, int logchanges, int sizelimit, int timelimit)
@@ -204,6 +205,111 @@ slapi_be_gettype(Slapi_Backend *be)
return r;
}
+int
+slapi_exist_referral(Slapi_Backend *be)
+{
+ Slapi_PBlock *search_pb = NULL;
+ const char *suffix;
+ Slapi_Entry **entries = NULL;
+ char **referrals = NULL;
+ char *filter;
+ int rc = 0; /* assume there is no referral */
+ int exist_referral = 0;
+ LDAPControl **server_ctrls;
+
+ filter = "(objectclass=referral)";
+ if (!slapi_be_is_flag_set(be, SLAPI_BE_FLAG_REMOTE_DATA) && (be->be_state == BE_STATE_STARTED)) {
+ suffix = slapi_sdn_get_dn(slapi_be_getsuffix(be, 0));
+
+ /* ignore special backends */
+ if ((strcmp(suffix, "cn=schema") == 0) ||
+ (strcmp(suffix, "cn=config") == 0)) {
+ return 0; /* it does not mean anything having a referral in those backends */
+ }
+
+ /* search for ("smart") referral entries */
+ search_pb = slapi_pblock_new();
+ server_ctrls = (LDAPControl **) slapi_ch_calloc(2, sizeof (LDAPControl *));
+ server_ctrls[0] = (LDAPControl *) slapi_ch_malloc(sizeof (LDAPControl));
+ server_ctrls[0]->ldctl_oid = slapi_ch_strdup(LDAP_CONTROL_MANAGEDSAIT);
+ server_ctrls[0]->ldctl_value.bv_val = NULL;
+ server_ctrls[0]->ldctl_value.bv_len = 0;
+ server_ctrls[0]->ldctl_iscritical = '\0';
+ slapi_search_internal_set_pb(search_pb, suffix, LDAP_SCOPE_SUBTREE,
+ filter, NULL, 0, server_ctrls, NULL,
+ (void *) plugin_get_default_component_id(), 0);
+ slapi_search_internal_pb(search_pb);
+ slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ if (LDAP_SUCCESS != rc) { /* plugin is not available */
+ exist_referral = 1; /* be safe, assume there is a referral somewhere */
+ }
+
+ slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS, &referrals);
+ if ((entries && entries[0]) || referrals) {
+ exist_referral = 1;
+ }
+ slapi_free_search_results_internal(search_pb);
+ slapi_pblock_destroy(search_pb);
+ }
+ if (exist_referral) {
+ if (!slapi_be_is_flag_set(be, SLAPI_BE_FLAG_CONTAINS_REFERRAL)) {
+ /* it existed no referral on that backend but now it exists at least a new referral entry */
+ slapi_be_set_flag(be, SLAPI_BE_FLAG_CONTAINS_REFERRAL);
+ slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon",
+ "New referral entries are detected under %s (returned to SRCH req)\n",
+ slapi_sdn_get_ndn(be->be_suffix));
+ }
+ } else if (slapi_be_is_flag_set(be, SLAPI_BE_FLAG_CONTAINS_REFERRAL)) {
+ /* now there is no more referral */
+ slapi_be_unset_flag(be, SLAPI_BE_FLAG_CONTAINS_REFERRAL);
+ slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon",
+ "No more referral entry under %s\n",
+ slapi_sdn_get_ndn(be->be_suffix));
+ }
+ return exist_referral;
+}
+
+/*
+ * This function periodically checks if it exists referrals entries
+ * in the server.
+ * This is used to accelerate SRCH request as the lookup for referrals
+ * has a negative impact on SRCH throughput
+ */
+static void
+referral_check(time_t start_time __attribute__((unused)), void *arg __attribute__((unused)))
+{
+ Slapi_Backend *be;
+ char *cookie;
+
+ /* loop over the backends to check if a it exists a "smart" referral */
+ be = slapi_get_first_backend(&cookie);
+ while (be) {
+ slapi_exist_referral(be);
+
+ /* next backend */
+ be = slapi_get_next_backend(cookie);
+ }
+ slapi_ch_free((void **) &cookie);
+}
+
+/* schedule periodic call to referral_check */
+void
+slapi_referral_check_init(void)
+{
+ referral_check_ctx = slapi_eq_repeat_rel(referral_check,
+ NULL, (time_t)0,
+ config_get_referral_check_period() * 1000);
+}
+void
+slapi_referral_check_stop(void)
+{
+ if (referral_check_ctx) {
+ slapi_eq_cancel_rel(referral_check_ctx);
+ referral_check_ctx = NULL;
+ }
+}
+
Slapi_DN *
be_getbasedn(Slapi_Backend *be, Slapi_DN *dn)
{
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 7fef51e39..de73183dc 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1027,6 +1027,7 @@ slapd_daemon(daemon_ports_t *ports)
}
}
}
+ slapi_referral_check_init();
/* We are now ready to accept incoming connections */
if (n_tcps != NULL) {
@@ -1136,6 +1137,7 @@ slapd_daemon(daemon_ports_t *ports)
ct_thread_cleanup();
housekeeping_stop(); /* Run this after op_thread_cleanup() logged sth */
disk_monitoring_stop();
+ slapi_referral_check_stop();
/*
* Now that they are abandonded, we need to mark them as done.
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 4c73367c4..cc5269ffd 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1406,6 +1406,11 @@ static struct config_get_and_set
NULL, 0,
(void **)&global_slapdFrontendConfig.tcp_keepalive_time, CONFIG_INT,
(ConfigGetFunc)config_get_tcp_keepalive_time, SLAPD_DEFAULT_TCP_KEEPALIVE_TIME_STR, NULL},
+ {CONFIG_REFERRAL_CHECK_PERIOD, config_set_referral_check_period,
+ NULL, 0,
+ (void **)&global_slapdFrontendConfig.referral_check_period,
+ CONFIG_INT, (ConfigGetFunc)config_set_referral_check_period,
+ SLAPD_DEFAULT_REFERRAL_CHECK_PERIOD_STR, NULL},
{CONFIG_RETURN_ENTRY_DN, config_set_return_orig_dn,
NULL, 0,
(void **)&global_slapdFrontendConfig.return_orig_dn,
@@ -1955,6 +1960,7 @@ FrontendConfig_init(void)
#endif
#endif
init_extract_pem = cfg->extract_pem = LDAP_ON;
+ cfg->referral_check_period = SLAPD_DEFAULT_REFERRAL_CHECK_PERIOD;
init_return_orig_dn = cfg->return_orig_dn = LDAP_ON;
/*
* Default upgrade hash to on - this is an important security step, meaning that old
@@ -8474,6 +8480,40 @@ config_get_verify_filter_schema()
return FILTER_POLICY_OFF;
}
+int32_t
+config_get_referral_check_period()
+{
+ int32_t retVal;
+
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = slapdFrontendConfig->referral_check_period;
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
+int32_t
+config_set_referral_check_period(const char *attrname, char *value, char *errorbuf, int apply __attribute__((unused)))
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int32_t min = 5;
+ int32_t max = 3600;
+ int32_t referral_check_period;
+ char *endp = NULL;
+
+ errno = 0;
+ referral_check_period = strtol(value, &endp, 10);
+ if ((*endp != '\0') || (errno == ERANGE) || (referral_check_period < min) || (referral_check_period > max)) {
+ slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "limit \"%s\" is invalid, %s must range from %d to %d",
+ value, CONFIG_REFERRAL_CHECK_PERIOD, min, max);
+ return LDAP_OPERATIONS_ERROR;
+ }
+ slapi_atomic_store_32(&(slapdFrontendConfig->referral_check_period), referral_check_period, __ATOMIC_RELEASE);
+
+ return LDAP_SUCCESS;
+}
+
int32_t
config_get_return_orig_dn()
{
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 3077869f8..45f23658e 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -629,6 +629,9 @@ int32_t config_set_ldapssotoken_secret(const char *attrname, char *value, char *
int32_t config_set_ldapssotoken_ttl(const char *attrname, char *value, char *errorbuf, int apply);
int32_t config_get_ldapssotoken_ttl(void);
+int32_t config_get_referral_check_period();
+int32_t config_set_referral_check_period(const char *attrname, char *value, char *errorbuf, int apply);
+
int32_t config_get_return_orig_dn(void);
int32_t config_set_return_orig_dn(const char *attrname, char *value, char *errorbuf, int apply);
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 9bd150fee..2495df0f1 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -431,6 +431,9 @@ typedef void (*VFPV)(); /* takes undefined arguments */
#define SLAPD_DEFAULT_TCP_KEEPALIVE_TIME 300
#define SLAPD_DEFAULT_TCP_KEEPALIVE_TIME_STR "300"
+#define SLAPD_DEFAULT_REFERRAL_CHECK_PERIOD 300
+#define SLAPD_DEFAULT_REFERRAL_CHECK_PERIOD_STR "300"
+
#define MIN_THREADS 16
#define MAX_THREADS 512
@@ -2348,6 +2351,7 @@ typedef struct _slapdEntryPoints
#define CONFIG_LISTEN_BACKLOG_SIZE "nsslapd-listen-backlog-size"
#define CONFIG_DYNAMIC_PLUGINS "nsslapd-dynamic-plugins"
#define CONFIG_RETURN_DEFAULT_OPATTR "nsslapd-return-default-opattr"
+#define CONFIG_REFERRAL_CHECK_PERIOD "nsslapd-referral-check-period"
#define CONFIG_RETURN_ENTRY_DN "nsslapd-return-original-entrydn"
#define CONFIG_CN_USES_DN_SYNTAX_IN_DNS "nsslapd-cn-uses-dn-syntax-in-dns"
@@ -2702,6 +2706,7 @@ typedef struct _slapdFrontendConfig
slapi_int_t tcp_fin_timeout;
slapi_int_t tcp_keepalive_time;
+ int32_t referral_check_period;
slapi_onoff_t return_orig_dn;
char *auditlog_display_attrs;
} slapdFrontendConfig_t;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index b3066909d..e1f7beba5 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -6406,6 +6406,9 @@ Slapi_DN *slapi_get_next_suffix_ext(void **node, int show_private);
int slapi_is_root_suffix(Slapi_DN *dn);
const Slapi_DN *slapi_get_suffix_by_dn(const Slapi_DN *dn);
const char *slapi_be_gettype(Slapi_Backend *be);
+int slapi_exist_referral(Slapi_Backend *be);
+void slapi_referral_check_init(void);
+void slapi_referral_check_stop(void);
/**
* Start database transaction
@@ -6459,6 +6462,7 @@ void slapi_be_unset_flag(Slapi_Backend *be, int flag);
#define SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST 0x10 /* force to call filter_test (search only) */
#define SLAPI_BE_FLAG_POST_IMPORT 0x100 /* backend was imported */
#define SLAPI_BE_FLAG_POST_RESTORE 0x200 /* startup after restore */
+#define SLAPI_BE_FLAG_CONTAINS_REFERRAL 0x400 /* Used to flag that the backend contains a referral entry */
/* These functions allow a plugin to register for callback when
| 0 |
fdd0c5f453fe368f2a8732bb0ae16bd68d6b5b13
|
389ds/389-ds-base
|
Bug 610119 - fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199
https://bugzilla.redhat.com/show_bug.cgi?id=610119
Resolves: bug 610119
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199
Fix description: Catch possible NULL pointer in ldbm_back_modify().
|
commit fdd0c5f453fe368f2a8732bb0ae16bd68d6b5b13
Author: Endi S. Dewata <[email protected]>
Date: Thu Jul 1 23:50:57 2010 -0500
Bug 610119 - fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199
https://bugzilla.redhat.com/show_bug.cgi?id=610119
Resolves: bug 610119
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199
Fix description: Catch possible NULL pointer in ldbm_back_modify().
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index a368f1c7d..30a99b18c 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -221,7 +221,14 @@ ldbm_back_modify( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_TARGET_ADDRESS, &addr );
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
slapi_pblock_get( pb, SLAPI_PARENT_TXN, (void**)&parent_txn );
+
slapi_pblock_get( pb, SLAPI_OPERATION, &operation );
+ if (NULL == operation)
+ {
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ goto error_return;
+ }
+
is_fixup_operation = operation_is_flag_set(operation, OP_FLAG_REPL_FIXUP);
is_ruv = operation_is_flag_set(operation, OP_FLAG_REPL_RUV);
inst = (ldbm_instance *) be->be_instance_info;
@@ -347,9 +354,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
* before we make our last abandon check to avoid race conditions in
* the code that processes abandon operations.
*/
- if (operation) {
- operation->o_status = SLAPI_OP_STATUS_WILL_COMPLETE;
- }
+ operation->o_status = SLAPI_OP_STATUS_WILL_COMPLETE;
if ( slapi_op_abandoned( pb ) ) {
goto error_return;
}
| 0 |
9e4f7a8a73d93066042563031bce72a839cd23c3
|
389ds/389-ds-base
|
was using wrong section
|
commit 9e4f7a8a73d93066042563031bce72a839cd23c3
Author: Rich Megginson <[email protected]>
Date: Fri Mar 18 21:38:48 2005 +0000
was using wrong section
diff --git a/ldap/admin/src/ds_newinst.pl b/ldap/admin/src/ds_newinst.pl
index 32c8e87e3..8df7536ad 100644
--- a/ldap/admin/src/ds_newinst.pl
+++ b/ldap/admin/src/ds_newinst.pl
@@ -173,8 +173,8 @@ if ($cgiargs{cfg_sspt} ||
}
#
-if ($table{slapd}->{UserDirectoryLdapURL}) {
- $cgiargs{user_ldap_url} = $table{slapd}->{UserDirectoryLdapURL};
+if ($table{General}->{UserDirectoryLdapURL}) {
+ $cgiargs{user_ldap_url} = $table{General}->{UserDirectoryLdapURL};
} else {
$cgiargs{user_ldap_url} = $cgiargs{ldap_url};
}
| 0 |
e4a09aa1ce9562799cd8a15ec10b03727c50d651
|
389ds/389-ds-base
|
Issue 4623 - RFE - Monitor the current DB locks ( nsslapd-db-current-locks )
Description:
Added additional tests for DB locks monitoring to check if invalid
values are correctly rejected for nsslapd-db-locks and
nsslapd-db-locks-monitoring-threshold.
Relates: https://github.com/389ds/389-ds-base/issues/4623
Reviewed by: droideck (Thanks!)
|
commit e4a09aa1ce9562799cd8a15ec10b03727c50d651
Author: Barbora Simonova <[email protected]>
Date: Mon Aug 2 10:01:03 2021 +0200
Issue 4623 - RFE - Monitor the current DB locks ( nsslapd-db-current-locks )
Description:
Added additional tests for DB locks monitoring to check if invalid
values are correctly rejected for nsslapd-db-locks and
nsslapd-db-locks-monitoring-threshold.
Relates: https://github.com/389ds/389-ds-base/issues/4623
Reviewed by: droideck (Thanks!)
diff --git a/dirsrvtests/tests/suites/monitor/db_locks_monitor_test.py b/dirsrvtests/tests/suites/monitor/db_locks_monitor_test.py
index 7f9938f30..cf4f89a66 100644
--- a/dirsrvtests/tests/suites/monitor/db_locks_monitor_test.py
+++ b/dirsrvtests/tests/suites/monitor/db_locks_monitor_test.py
@@ -27,6 +27,7 @@ from lib389.plugins import AttributeUniquenessPlugin
from lib389.config import BDB_LDBMConfig
from lib389.monitor import MonitorLDBM
from lib389.topologies import create_topology, _remove_ssca_db
+from lib389.utils import ds_is_older
pytestmark = pytest.mark.tier2
db_locks_monitoring_ack = pytest.mark.skipif(not os.environ.get('DB_LOCKS_MONITORING_ACK', False),
@@ -144,6 +145,8 @@ def test_exhaust_db_locks_basic(topology_st_fn, setup_attruniq_index_be_import,
and database is not corrupted
:id: 299108cc-04d8-4ddc-b58e-99157fccd643
+ :customerscenario: True
+ :parametrized: yes
:setup: Standalone instance with Attr Uniq plugin and user indexes disabled
:steps: 1. Set nsslapd-db-locks to 11000
2. Check that we stop acquiring new locks when the threshold is reached
@@ -209,6 +212,7 @@ def test_exhaust_db_locks_big_pause(topology_st_fn, setup_attruniq_index_be_impo
"""Test that DB lock pause setting increases the wait interval value for the monitoring thread
:id: 7d5bf838-5d4e-4ad5-8c03-5716afb84ea6
+ :customerscenario: True
:setup: Standalone instance with Attr Uniq plugin and user indexes disabled
:steps: 1. Set nsslapd-db-locks to 20000 while using the default threshold value (95%)
2. Set nsslapd-db-locks-monitoring-pause to 10000 (10 seconds)
@@ -249,3 +253,68 @@ def test_exhaust_db_locks_big_pause(topology_st_fn, setup_attruniq_index_be_impo
f"Finished the execution in {time_delta.seconds} seconds")
# In case something has failed - restart for the clean up
inst.restart()
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3.23"), reason="Not implemented")
[email protected]("invalid_value", [("0"), ("1"), ("42"), ("68"), ("69"), ("96"), ("120")])
+def test_invalid_threshold_range(topology_st_fn, invalid_value):
+ """Test that setting nsslapd-db-locks-monitoring-threshold to 60 % is rejected
+
+ :id: e4551de1-8582-4c13-b59d-3d5ec4701457
+ :customerscenario: True
+ :parametrized: yes
+ :setup: Standalone instance
+ :steps: 1. Set nsslapd-db-locks-monitoring-threshold to 60 %
+ 2. Check if exception message contains info about invalid value range
+ :expectedresults:
+ 1. Exception is raised
+ 2. Success
+ """
+
+ inst = topology_st_fn.standalone
+ bdb_config = BDB_LDBMConfig(inst)
+ msg = 'threshold is indicated as a percentage and it must lie in range of 70 and 95'
+
+ try:
+ bdb_config.replace("nsslapd-db-locks-monitoring-threshold", invalid_value)
+ except ldap.OPERATIONS_ERROR as e:
+ log.info('Got expected error: {}'.format(str(e)))
+ assert msg in str(e)
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3.23"), reason="Not implemented")
[email protected]("locks_invalid", [("0"), ("1"), ("9999"), ("10000")])
+def test_invalid_db_locks_value(topology_st_fn, locks_invalid):
+ """Test that setting nsslapd-db-locks to 0 is rejected
+
+ :id: bbb40279-d622-4f36-a129-c54f963f494a
+ :customerscenario: True
+ :parametrized: yes
+ :setup: Standalone instance
+ :steps: 1. Set nsslapd-db-locks to 0
+ 2. Check if exception message contains info about invalid value
+ :expectedresults:
+ 1. Exception is raised
+ 2. Success
+ """
+
+ inst = topology_st_fn.standalone
+ bdb_config = BDB_LDBMConfig(inst)
+ msg = 'Invalid value for nsslapd-db-locks ({}). Must be greater than 10000'.format(locks_invalid)
+
+ try:
+ bdb_config.replace("nsslapd-db-locks", locks_invalid)
+ except ldap.UNWILLING_TO_PERFORM as e:
+ log.info('Got expected error: {}'.format(str(e)))
+ assert msg in str(e)
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main(["-s", CURRENT_FILE])
| 0 |
c75126be1edece121826e336141f9b0b9c0bddfd
|
389ds/389-ds-base
|
Issue 49169 - Fix covscan errors
src/libsds/bpt/map.c - resource leak
ldap/servers/slapd/vattr.c - resource leak
ldap/servers/slapd/task.c: resource leaks
ldap/servers/slapd/str2filter.c - resource leak
ldap/servers/slapd/pw.c - resource leak
ldap/servers/slapd/back-ldbm/import-threads.c - resource leak
ldap/servers/plugins/uiduniq/uid.c:536 - resource leak
ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c:164 - resource leak
ldap/servers/plugins/linkedattrs/linked_attrs.c:1672 - resource leak
ldap/servers/plugins/addn/addn.c:419
ldap/servers/slapd/ssl.c - dead code
ldap/servers/slapd/index_subsystem.c - null dereference
https://pagure.io/389-ds-base/issue/49169
Reviewed by: nkinder & wibrown(Thanks!!)
|
commit c75126be1edece121826e336141f9b0b9c0bddfd
Author: Mark Reynolds <[email protected]>
Date: Tue Mar 14 20:23:07 2017 -0400
Issue 49169 - Fix covscan errors
src/libsds/bpt/map.c - resource leak
ldap/servers/slapd/vattr.c - resource leak
ldap/servers/slapd/task.c: resource leaks
ldap/servers/slapd/str2filter.c - resource leak
ldap/servers/slapd/pw.c - resource leak
ldap/servers/slapd/back-ldbm/import-threads.c - resource leak
ldap/servers/plugins/uiduniq/uid.c:536 - resource leak
ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c:164 - resource leak
ldap/servers/plugins/linkedattrs/linked_attrs.c:1672 - resource leak
ldap/servers/plugins/addn/addn.c:419
ldap/servers/slapd/ssl.c - dead code
ldap/servers/slapd/index_subsystem.c - null dereference
https://pagure.io/389-ds-base/issue/49169
Reviewed by: nkinder & wibrown(Thanks!!)
diff --git a/ldap/servers/plugins/addn/addn.c b/ldap/servers/plugins/addn/addn.c
index 3abc11202..6ba783387 100644
--- a/ldap/servers/plugins/addn/addn.c
+++ b/ldap/servers/plugins/addn/addn.c
@@ -415,7 +415,9 @@ addn_start(Slapi_PBlock *pb)
domain = slapi_entry_attr_get_charptr(plugin_entry, "addn_default_domain");
if (domain == NULL) {
- slapi_log_err(SLAPI_LOG_ERR, plugin_name, "addn_start: CRITICAL: No default domain in configuration, you must set addn_default_domain!\n");
+ slapi_log_err(SLAPI_LOG_ERR, plugin_name,
+ "addn_start: CRITICAL: No default domain in configuration, you must set addn_default_domain!\n");
+ slapi_ch_free((void**)&config);
return SLAPI_PLUGIN_FAILURE;
}
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index b5adb2192..d046542aa 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1669,6 +1669,8 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
/* Bail out if the plug-in close function was just called. */
if (!slapi_plugin_running(pb)) {
linked_attrs_unlock();
+ slapi_mod_free(&next_mod);
+ slapi_mods_free(&smods);
return SLAPI_PLUGIN_SUCCESS;
}
diff --git a/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c b/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c
index 1b3e5556d..b2287009a 100644
--- a/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c
+++ b/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c
@@ -161,6 +161,7 @@ pbkdf2_sha256_pw_enc(const char *pwd)
*/
if ( pbkdf2_sha256_hash(hash + PBKDF2_ITERATIONS_LENGTH + PBKDF2_SALT_LENGTH, PBKDF2_HASH_LENGTH, &passItem, &saltItem, PBKDF2_ITERATIONS) != SECSuccess ) {
slapi_log_err(SLAPI_LOG_ERR, (char *)schemeName, "Could not generate pbkdf2_sha256_hash!\n");
+ slapi_ch_free_string(&enc);
return NULL;
}
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index ae9320e33..46554b266 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -533,7 +533,11 @@ create_filter(const char **attributes, const struct berval *value, const char *r
/* Place value in filter */
if (ldap_quote_filter_value(value->bv_val, value->bv_len,
- fp, max-fp, &valueLen)) { slapi_ch_free((void**)&filter); return 0; }
+ fp, max-fp, &valueLen)) {
+ slapi_ch_free((void**)&filter);
+ slapi_ch_free((void**)&attrLen);
+ return 0;
+ }
fp += valueLen;
strcpy(fp, ")");
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 5b814275d..087103bfa 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -1647,6 +1647,7 @@ upgradedn_producer(void *param)
}
e = slapi_str2entry_ext(normdn, NULL, data.dptr,
SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT);
+ slapi_ch_free_string(&rdn);
}
} else {
e =
diff --git a/ldap/servers/slapd/index_subsystem.c b/ldap/servers/slapd/index_subsystem.c
index 57d4f5855..8f9fe6dbe 100644
--- a/ldap/servers/slapd/index_subsystem.c
+++ b/ldap/servers/slapd/index_subsystem.c
@@ -185,27 +185,28 @@ static int index_subsys_index_matches_filter(indexEntry *index, Slapi_Filter *f)
*/
int index_subsys_assign_filter_decoders(Slapi_PBlock *pb)
{
- int rc;
+ int rc = 0;
Slapi_Filter *f;
char *subsystem = "index_subsys_assign_filter_decoders";
char logbuf[ 1024 ];
/* extract the filter */
slapi_pblock_get(pb, SLAPI_SEARCH_FILTER, &f);
+ if (f) {
+ if ( loglevel_is_set( LDAP_DEBUG_FILTER )) {
+ logbuf[0] = '\0';
+ slapi_log_err(SLAPI_LOG_DEBUG, subsystem, "before: %s\n",
+ slapi_filter_to_string(f, logbuf, sizeof(logbuf)));
+ }
- if ( loglevel_is_set( LDAP_DEBUG_FILTER ) && NULL != f ) {
- logbuf[0] = '\0';
- slapi_log_err(SLAPI_LOG_DEBUG, subsystem, "before: %s\n",
- slapi_filter_to_string(f, logbuf, sizeof(logbuf)));
- }
-
- /* find decoders */
- rc = index_subsys_assign_decoders(f);
+ /* find decoders */
+ rc = index_subsys_assign_decoders(f);
- if ( loglevel_is_set( LDAP_DEBUG_FILTER ) && NULL != f ) {
- logbuf[0] = '\0';
- slapi_log_err(SLAPI_LOG_DEBUG, subsystem, " after: %s\n",
- slapi_filter_to_string(f, logbuf, sizeof(logbuf)));
+ if ( loglevel_is_set( LDAP_DEBUG_FILTER )) {
+ logbuf[0] = '\0';
+ slapi_log_err(SLAPI_LOG_DEBUG, subsystem, " after: %s\n",
+ slapi_filter_to_string(f, logbuf, sizeof(logbuf)));
+ }
}
return rc;
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 215c9ebd2..378d1487b 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1512,6 +1512,7 @@ check_trivial_words (Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Value **vals, char
ep = sp + strlen(sp);
ep = ldap_utf8prevn(sp, ep, toklen);
if (!ep || (sp >= ep)) {
+ slapi_ch_free_string(&sp);
continue;
}
/* See if the password contains the value */
diff --git a/ldap/servers/slapd/pw_verify.c b/ldap/servers/slapd/pw_verify.c
index 529bb83fd..a9fd9ecae 100644
--- a/ldap/servers/slapd/pw_verify.c
+++ b/ldap/servers/slapd/pw_verify.c
@@ -103,7 +103,6 @@ pw_verify_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral)
int
pw_validate_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral)
{
- int rc = 0;
Slapi_Backend *be = NULL;
Slapi_DN *pb_sdn;
struct berval *cred;
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index f35b3f190..050e7b5bd 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -1418,12 +1418,10 @@ slapd_ssl_init()
errorCode = PR_GetError();
slapd_SSL_error("Failed to retrieve SSL "
"configuration information ("
- SLAPI_COMPONENT_NAME_NSPR " error %d - %s): "
+ SLAPI_COMPONENT_NAME_NSPR " error %d - not found): "
"nssslSessionTimeout: %s ",
- errorCode, slapd_pr_strerror(errorCode),
- (val ? "found" : "not found"));
- slapi_ch_free((void **) &val);
- slapi_ch_free((void **) &ciphers);
+ errorCode, slapd_pr_strerror(errorCode));
+ slapi_ch_free((void **)&ciphers);
freeConfigEntry( &entry );
return -1;
}
diff --git a/ldap/servers/slapd/str2filter.c b/ldap/servers/slapd/str2filter.c
index ebd5c5dfd..744c93fc4 100644
--- a/ldap/servers/slapd/str2filter.c
+++ b/ldap/servers/slapd/str2filter.c
@@ -344,6 +344,7 @@ str2simple( char *str , int unescape_filter)
*endp = '\0';
rc = _parse_ext_filter(str, extp, &f->f_mr_type, &f->f_mr_oid, &f->f_mr_dnAttrs);
if (rc) {
+ slapi_filter_free(f, 1);
return NULL; /* error */
} else {
f->f_choice = LDAP_FILTER_EXTENDED;
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index ad52e9d99..eabd51782 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -2389,7 +2389,6 @@ task_fixup_tombstones_add(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eAfter,
slapi_task_finish(task, *returncode);
slapi_ch_array_free(base);
slapi_ch_free((void **)&task_data);
- return SLAPI_DSE_CALLBACK_ERROR;
}
done:
@@ -2507,9 +2506,9 @@ task_des2aes(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eAfter,
error:
if (rc == SLAPI_DSE_CALLBACK_ERROR){
slapi_ch_array_free(bases);
- slapi_ch_array_free(suffix);
slapi_ch_free((void **)&task_data);
}
+ slapi_ch_array_free(suffix);
return rc;
}
diff --git a/ldap/servers/slapd/vattr.c b/ldap/servers/slapd/vattr.c
index 34665deab..599b54efd 100644
--- a/ldap/servers/slapd/vattr.c
+++ b/ldap/servers/slapd/vattr.c
@@ -753,10 +753,10 @@ slapi_vattr_values_get_sp(vattr_context *c,
}
if (use_local_ctx) {
/* slapi_pblock_destroy cleans up pb_vattr_context, as well */
- slapi_pblock_destroy(local_pb);
- } else {
- vattr_context_ungrok(&c);
+ slapi_pblock_destroy(local_pb);
+ ctx->pb = NULL;
}
+ vattr_context_ungrok(&ctx);
return rc;
}
diff --git a/src/libsds/sds/bpt/map.c b/src/libsds/sds/bpt/map.c
index 4ba340eab..e778f6f29 100644
--- a/src/libsds/sds/bpt/map.c
+++ b/src/libsds/sds/bpt/map.c
@@ -19,6 +19,7 @@ sds_bptree_map_nodes(sds_bptree_instance *binst, sds_bptree_node *root, sds_resu
sds_bptree_node_list *tail = cur;
if (binst == NULL) {
+ sds_free(cur);
return SDS_NULL_POINTER;
}
| 0 |
77fdecc3a2bf6d9ce8e545ba0746f619fb14ce84
|
389ds/389-ds-base
|
Ticket #167 - Mixing transaction and non-transaction plugins can cause deadlock
https://fedorahosted.org/389/ticket/167
Resolves: Ticket #167
Bug Description: Mixing transaction and non-transaction plugins can cause deadlock
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Make all code that uses internal database operations be
transaction aware. This excludes code that works exclusively on the
config DSEs such as cn=schema or cn=config. This also excludes code in
a couple of areas, because of difficulty in passing in the txn handle:
1) views_entry_exists Slapi APIB functions
2) acllas.c code that does internal searching
3) cos_cache_follow_pointer()
Also allow dna, linkedattrs, automember, and mep to run as betxn plugins by
configuring the plugin config entry in the dse
Platforms tested: RHEL6 x86_64, Fedora 16
Flag Day: no
Doc impact: no
|
commit 77fdecc3a2bf6d9ce8e545ba0746f619fb14ce84
Author: Rich Megginson <[email protected]>
Date: Wed Jan 11 15:04:05 2012 -0700
Ticket #167 - Mixing transaction and non-transaction plugins can cause deadlock
https://fedorahosted.org/389/ticket/167
Resolves: Ticket #167
Bug Description: Mixing transaction and non-transaction plugins can cause deadlock
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Make all code that uses internal database operations be
transaction aware. This excludes code that works exclusively on the
config DSEs such as cn=schema or cn=config. This also excludes code in
a couple of areas, because of difficulty in passing in the txn handle:
1) views_entry_exists Slapi APIB functions
2) acllas.c code that does internal searching
3) cos_cache_follow_pointer()
Also allow dna, linkedattrs, automember, and mep to run as betxn plugins by
configuring the plugin config entry in the dse
Platforms tested: RHEL6 x86_64, Fedora 16
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/acctpolicy/acct_plugin.c b/ldap/servers/plugins/acctpolicy/acct_plugin.c
index 5969bec99..9c742788f 100644
--- a/ldap/servers/plugins/acctpolicy/acct_plugin.c
+++ b/ldap/servers/plugins/acctpolicy/acct_plugin.c
@@ -90,7 +90,7 @@ done:
with the current time.
*/
static int
-acct_record_login( const char *dn )
+acct_record_login( const char *dn, void *txn )
{
int ldrc;
int rc = 0; /* Optimistic default */
@@ -125,6 +125,7 @@ acct_record_login( const char *dn )
slapi_modify_internal_set_pb( modpb, dn, mods, NULL, NULL,
plugin_id, SLAPI_OP_FLAG_NO_ACCESS_CHECK |
SLAPI_OP_FLAG_BYPASS_REFERRALS );
+ slapi_pblock_set( modpb, SLAPI_TXN, txn );
slapi_modify_internal_pb( modpb );
slapi_pblock_get( modpb, SLAPI_PLUGIN_INTOP_RESULT, &ldrc );
@@ -160,6 +161,7 @@ acct_bind_preop( Slapi_PBlock *pb )
int ldrc;
acctPolicy *policy = NULL;
void *plugin_id;
+ void *txn = NULL;
slapi_log_error( SLAPI_LOG_PLUGIN, PRE_PLUGIN_NAME,
"=> acct_bind_preop\n" );
@@ -180,8 +182,9 @@ acct_bind_preop( Slapi_PBlock *pb )
goto done;
}
- ldrc = slapi_search_internal_get_entry( sdn, NULL, &target_entry,
- plugin_id );
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
+ ldrc = slapi_search_internal_get_entry_ext( sdn, NULL, &target_entry,
+ plugin_id, txn );
/* There was a problem retrieving the entry */
if( ldrc != LDAP_SUCCESS ) {
@@ -194,7 +197,7 @@ acct_bind_preop( Slapi_PBlock *pb )
goto done;
}
- if( get_acctpolicy( pb, target_entry, plugin_id, &policy ) ) {
+ if( get_acctpolicy( pb, target_entry, plugin_id, &policy, txn ) ) {
slapi_log_error( SLAPI_LOG_FATAL, PRE_PLUGIN_NAME,
"Account Policy object for \"%s\" is missing\n", dn );
rc = -1;
@@ -244,6 +247,7 @@ acct_bind_postop( Slapi_PBlock *pb )
Slapi_Entry *target_entry = NULL;
acctPluginCfg *cfg;
void *plugin_id;
+ void *txn = NULL;
slapi_log_error( SLAPI_LOG_PLUGIN, POST_PLUGIN_NAME,
"=> acct_bind_postop\n" );
@@ -263,6 +267,7 @@ acct_bind_postop( Slapi_PBlock *pb )
goto done;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
cfg = get_config();
tracklogin = cfg->always_record_login;
@@ -270,8 +275,8 @@ acct_bind_postop( Slapi_PBlock *pb )
covered by an account policy to decide whether we should track */
if( tracklogin == 0 ) {
sdn = slapi_sdn_new_dn_byref( dn );
- ldrc = slapi_search_internal_get_entry( sdn, NULL, &target_entry,
- plugin_id );
+ ldrc = slapi_search_internal_get_entry_ext( sdn, NULL, &target_entry,
+ plugin_id, txn );
if( ldrc != LDAP_SUCCESS ) {
slapi_log_error( SLAPI_LOG_FATAL, POST_PLUGIN_NAME,
@@ -288,7 +293,7 @@ acct_bind_postop( Slapi_PBlock *pb )
}
if( tracklogin ) {
- rc = acct_record_login( dn );
+ rc = acct_record_login( dn, txn );
}
/* ...Any additional account policy postops go here... */
diff --git a/ldap/servers/plugins/acctpolicy/acct_util.c b/ldap/servers/plugins/acctpolicy/acct_util.c
index 8e220c3b0..c4217465f 100644
--- a/ldap/servers/plugins/acctpolicy/acct_util.c
+++ b/ldap/servers/plugins/acctpolicy/acct_util.c
@@ -78,7 +78,7 @@ get_attr_string_val( Slapi_Entry* target_entry, char* attr_name ) {
*/
int
get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry, void *plugin_id,
- acctPolicy **policy ) {
+ acctPolicy **policy, void *txn ) {
Slapi_DN *sdn = NULL;
Slapi_Entry *policy_entry = NULL;
Slapi_Attr *attr;
@@ -114,8 +114,8 @@ get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry, void *plugin_id,
}
sdn = slapi_sdn_new_dn_byref( policy_dn );
- ldrc = slapi_search_internal_get_entry( sdn, NULL, &policy_entry,
- plugin_id );
+ ldrc = slapi_search_internal_get_entry_ext( sdn, NULL, &policy_entry,
+ plugin_id, txn );
slapi_sdn_free( &sdn );
/* There should be a policy but it can't be retrieved; fatal error */
diff --git a/ldap/servers/plugins/acctpolicy/acctpolicy.h b/ldap/servers/plugins/acctpolicy/acctpolicy.h
index e6f14979c..006400901 100644
--- a/ldap/servers/plugins/acctpolicy/acctpolicy.h
+++ b/ldap/servers/plugins/acctpolicy/acctpolicy.h
@@ -65,7 +65,7 @@ typedef struct accountpolicy {
/* acct_util.c */
int get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry,
- void *plugin_id, acctPolicy **policy );
+ void *plugin_id, acctPolicy **policy, void *txn );
void free_acctpolicy( acctPolicy **policy );
int has_attr( Slapi_Entry* target_entry, char* attr_name,
char** val );
diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index 1195a1584..c5e5667d3 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -84,9 +84,9 @@ static int automember_add_pre_op(Slapi_PBlock *pb);
/*
* Config cache management functions
*/
-static int automember_load_config();
+static int automember_load_config(Slapi_PBlock *pb);
static void automember_delete_config();
-static int automember_parse_config_entry(Slapi_Entry * e, int apply);
+static int automember_parse_config_entry(Slapi_Entry * e, int apply, Slapi_PBlock *pb);
static void automember_free_config_entry(struct configEntry ** entry);
/*
@@ -103,9 +103,9 @@ static struct automemberRegexRule *automember_parse_regex_rule(char *rule_string
static void automember_free_regex_rule(struct automemberRegexRule *rule);
static int automember_parse_grouping_attr(char *value, char **grouping_attr,
char **grouping_value);
-static void automember_update_membership(struct configEntry *config, Slapi_Entry *e);
+static void automember_update_membership(struct configEntry *config, Slapi_Entry *e, void *txn);
static void automember_add_member_value(Slapi_Entry *member_e, const char *group_dn,
- char *grouping_attr, char *grouping_value);
+ char *grouping_attr, char *grouping_value, void *txn);
/*
* Config cache locking functions
@@ -156,6 +156,7 @@ automember_get_plugin_sdn()
return _PluginDN;
}
+static int plugin_is_betxn = 0;
/*
* Plug-in initialization functions
@@ -165,10 +166,25 @@ automember_init(Slapi_PBlock *pb)
{
int status = 0;
char *plugin_identity = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int preadd = SLAPI_PLUGIN_PRE_ADD_FN;
+ int premod = SLAPI_PLUGIN_PRE_MODIFY_FN;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_init\n");
+ /* get args */
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ plugin_is_betxn = 1;
+ preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
+ premod = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
/* Store the plugin identity for later use.
* Used for internal operations. */
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
@@ -184,10 +200,14 @@ automember_init(Slapi_PBlock *pb)
(void *) automember_close) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
- (void *) automember_mod_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
- (void *) automember_add_pre_op) != 0 ||
+ slapi_pblock_set(pb, premod, (void *) automember_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, preadd, (void *) automember_add_pre_op) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
+ "automember_init: failed to register plugin\n");
+ status = -1;
+ }
+
+ if (!plugin_is_betxn && !status &&
slapi_register_plugin("internalpostoperation", /* op type */
1, /* Enabled */
"automember_init", /* this function desc */
@@ -195,19 +215,30 @@ automember_init(Slapi_PBlock *pb)
AUTOMEMBER_INT_POSTOP_DESC, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
- ) ||
- slapi_register_plugin("postoperation", /* op type */
- 1, /* Enabled */
- "automember_init", /* this function desc */
- automember_postop_init, /* init func for post op */
- AUTOMEMBER_POSTOP_DESC, /* plugin desc */
- NULL, /* ? */
- plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
+ "automember_init: failed to register internalpostoperation plugin\n");
+ status = -1;
+ }
+
+ if (!status) {
+ plugin_type = "postoperation";
+ if (plugin_is_betxn) {
+ plugin_type = "betxnpostoperation";
+ }
+ if (slapi_register_plugin(plugin_type, /* op type */
+ 1, /* Enabled */
+ "automember_init", /* this function desc */
+ automember_postop_init, /* init func for post op */
+ AUTOMEMBER_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
)
) {
slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
- "automember_init: failed to register plugin\n");
+ "automember_init: failed to register postop plugin\n");
status = -1;
+ }
}
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
@@ -215,6 +246,7 @@ automember_init(Slapi_PBlock *pb)
return status;
}
+/* not used when using plugin as a betxn plugin - betxn plugins are called for both internal and external ops */
static int
automember_internal_postop_init(Slapi_PBlock *pb)
{
@@ -244,19 +276,26 @@ static int
automember_postop_init(Slapi_PBlock *pb)
{
int status = 0;
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ if (plugin_is_betxn) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- (void *) automember_add_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- (void *) automember_del_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- (void *) automember_mod_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- (void *) automember_modrdn_post_op) != 0) {
+ slapi_pblock_set(pb, addfn, (void *) automember_add_post_op) != 0 ||
+ slapi_pblock_set(pb, delfn, (void *) automember_del_post_op) != 0 ||
+ slapi_pblock_set(pb, modfn, (void *) automember_mod_post_op) != 0 ||
+ slapi_pblock_set(pb, mdnfn, (void *) automember_modrdn_post_op) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"automember_postop_init: failed to register plugin\n");
status = -1;
@@ -319,7 +358,7 @@ automember_start(Slapi_PBlock * pb)
g_automember_config = (PRCList *)slapi_ch_calloc(1, sizeof(struct configEntry));
PR_INIT_CLIST(g_automember_config);
- if (automember_load_config() != 0) {
+ if (automember_load_config(pb) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"automember_start: unable to load plug-in configuration\n");
return -1;
@@ -391,13 +430,14 @@ automember_get_config()
* Parse and load the config entries.
*/
static int
-automember_load_config()
+automember_load_config(Slapi_PBlock *pb)
{
int status = 0;
int result;
int i;
Slapi_PBlock *search_pb;
Slapi_Entry **entries = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_load_config\n");
@@ -406,6 +446,7 @@ automember_load_config()
automember_config_write_lock();
automember_delete_config();
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
search_pb = slapi_pblock_new();
/* If an alternate config area is configured, find
@@ -432,6 +473,7 @@ automember_load_config()
NULL, 0, NULL, NULL, automember_get_plugin_id(), 0);
}
+ slapi_pblock_set(search_pb, SLAPI_TXN, txn);
slapi_search_internal_pb(search_pb);
slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -458,7 +500,7 @@ automember_load_config()
/* We don't care about the status here because we may have
* some invalid config entries, but we just want to continue
* looking for valid ones. */
- automember_parse_config_entry(entries[i], 1);
+ automember_parse_config_entry(entries[i], 1, pb);
}
cleanup:
@@ -482,7 +524,7 @@ automember_load_config()
* Returns 0 if the entry is valid and -1 if it is invalid.
*/
static int
-automember_parse_config_entry(Slapi_Entry * e, int apply)
+automember_parse_config_entry(Slapi_Entry * e, int apply, Slapi_PBlock *pb)
{
char *value = NULL;
char **values = NULL;
@@ -497,6 +539,7 @@ automember_parse_config_entry(Slapi_Entry * e, int apply)
int entry_added = 0;
int i = 0;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_parse_config_entry\n");
@@ -529,6 +572,7 @@ automember_parse_config_entry(Slapi_Entry * e, int apply)
goto bail;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
value = slapi_entry_get_ndn(e);
if (value) {
entry->dn = slapi_ch_strdup(value);
@@ -621,6 +665,7 @@ automember_parse_config_entry(Slapi_Entry * e, int apply)
slapi_search_internal_set_pb(search_pb, entry->dn, LDAP_SCOPE_SUBTREE,
AUTOMEMBER_REGEX_RULE_FILTER, NULL, 0, NULL,
NULL, automember_get_plugin_id(), 0);
+ slapi_pblock_set(search_pb, SLAPI_TXN, txn);
slapi_search_internal_pb(search_pb);
slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1302,7 +1347,7 @@ automember_parse_grouping_attr(char *value, char **grouping_attr, char **groupin
* the rules in config, then performs the updates.
*/
static void
-automember_update_membership(struct configEntry *config, Slapi_Entry *e)
+automember_update_membership(struct configEntry *config, Slapi_Entry *e, void *txn)
{
PRCList *rule = NULL;
struct automemberRegexRule *curr_rule = NULL;
@@ -1456,14 +1501,14 @@ automember_update_membership(struct configEntry *config, Slapi_Entry *e)
/* Add to each default group. */
for (i = 0; config->default_groups && config->default_groups[i]; i++) {
automember_add_member_value(e, config->default_groups[i],
- config->grouping_attr, config->grouping_value);
+ config->grouping_attr, config->grouping_value, txn);
}
} else {
/* Update the target groups. */
dnitem = (struct automemberDNListItem *)PR_LIST_HEAD(&targets);
while ((PRCList *)dnitem != &targets) {
automember_add_member_value(e, slapi_sdn_get_dn(dnitem->dn),
- config->grouping_attr, config->grouping_value);
+ config->grouping_attr, config->grouping_value, txn);
dnitem = (struct automemberDNListItem *)PR_NEXT_LINK((PRCList *)dnitem);
}
}
@@ -1491,7 +1536,7 @@ automember_update_membership(struct configEntry *config, Slapi_Entry *e)
*/
static void
automember_add_member_value(Slapi_Entry *member_e, const char *group_dn,
- char *grouping_attr, char *grouping_value)
+ char *grouping_attr, char *grouping_value, void *txn)
{
Slapi_PBlock *mod_pb = slapi_pblock_new();
int result = LDAP_SUCCESS;
@@ -1527,6 +1572,7 @@ automember_add_member_value(Slapi_Entry *member_e, const char *group_dn,
slapi_modify_internal_set_pb(mod_pb, group_dn,
mods, 0, 0, automember_get_plugin_id(), 0);
+ slapi_pblock_set(mod_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1573,6 +1619,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
int free_entry = 0;
char *errstr = NULL;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_pre_op\n");
@@ -1584,6 +1631,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
if (0 == (sdn = automember_get_sdn(pb)))
goto bail;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (automember_dn_is_config(sdn)) {
/* Validate config changes, but don't apply them.
* This allows us to reject invalid config changes
@@ -1602,7 +1650,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
/* Fetch the entry being modified so we can
* create the resulting entry for validation. */
if (sdn) {
- slapi_search_internal_get_entry(sdn, 0, &e, automember_get_plugin_id());
+ slapi_search_internal_get_entry_ext(sdn, 0, &e, automember_get_plugin_id(), txn);
free_entry = 1;
}
@@ -1630,7 +1678,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
goto bail;
}
- if (automember_parse_config_entry(e, 0) != 0) {
+ if (automember_parse_config_entry(e, 0, pb) != 0) {
/* Refuse the operation if config parsing failed. */
ret = LDAP_UNWILLING_TO_PERFORM;
if (LDAP_CHANGETYPE_ADD == modop) {
@@ -1700,7 +1748,7 @@ automember_mod_post_op(Slapi_PBlock *pb)
if (automember_oktodo(pb) && (sdn = automember_get_sdn(pb))) {
/* Check if the config is being modified and reload if so. */
if (automember_dn_is_config(sdn)) {
- automember_load_config();
+ automember_load_config(pb);
}
}
@@ -1718,6 +1766,7 @@ automember_add_post_op(Slapi_PBlock *pb)
Slapi_DN *sdn = NULL;
struct configEntry *config = NULL;
PRCList *list = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_add_post_op\n");
@@ -1729,7 +1778,7 @@ automember_add_post_op(Slapi_PBlock *pb)
/* Reload config if a config entry was added. */
if ((sdn = automember_get_sdn(pb))) {
if (automember_dn_is_config(sdn)) {
- automember_load_config();
+ automember_load_config(pb);
}
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, AUTOMEMBER_PLUGIN_SUBSYSTEM,
@@ -1743,6 +1792,7 @@ automember_add_post_op(Slapi_PBlock *pb)
return 0;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Get the newly added entry. */
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &e);
@@ -1776,7 +1826,7 @@ automember_add_post_op(Slapi_PBlock *pb)
if (slapi_dn_issuffix(slapi_sdn_get_dn(sdn), config->scope) &&
(slapi_filter_test_simple(e, config->filter) == 0)) {
/* Find out what membership changes are needed and make them. */
- automember_update_membership(config, e);
+ automember_update_membership(config, e, txn);
}
list = PR_NEXT_LINK(list);
@@ -1817,7 +1867,7 @@ automember_del_post_op(Slapi_PBlock *pb)
/* Reload config if a config entry was deleted. */
if ((sdn = automember_get_sdn(pb))) {
if (automember_dn_is_config(sdn))
- automember_load_config();
+ automember_load_config(pb);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"automember_del_post_op: Error "
@@ -1865,7 +1915,7 @@ automember_modrdn_post_op(Slapi_PBlock *pb)
if ((old_sdn = automember_get_sdn(pb))) {
if (automember_dn_is_config(old_sdn) || automember_dn_is_config(new_sdn))
- automember_load_config();
+ automember_load_config(pb);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"automember_modrdn_post_op: Error "
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
index fb6a54a3e..86055b235 100644
--- a/ldap/servers/plugins/deref/deref.c
+++ b/ldap/servers/plugins/deref/deref.c
@@ -594,6 +594,7 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn,
Slapi_PBlock *derefpb = NULL;
Slapi_Entry **entries = NULL;
int rc;
+ void *txn = NULL;
if (deref_check_access(pb, NULL, derefdn, attrs, &retattrs,
(SLAPI_ACL_SEARCH|SLAPI_ACL_READ))) {
@@ -604,10 +605,11 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn,
}
derefpb = slapi_pblock_new();
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_search_internal_set_pb(derefpb, derefdn, LDAP_SCOPE_BASE,
"(objectclass=*)", retattrs, 0,
NULL, NULL, deref_get_plugin_id(), 0);
-
+ slapi_pblock_set(derefpb, SLAPI_TXN, txn);
slapi_search_internal_pb(derefpb);
slapi_pblock_get(derefpb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
if (LDAP_SUCCESS == rc) {
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 858a0d74e..32b6d1132 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -230,15 +230,15 @@ static char *dna_get_dn(Slapi_PBlock * pb);
static Slapi_DN *dna_get_sdn(Slapi_PBlock * pb);
static int dna_dn_is_config(char *dn);
static int dna_get_next_value(struct configEntry * config_entry,
- char **next_value_ret);
+ char **next_value_ret, void *txn);
static int dna_first_free_value(struct configEntry *config_entry,
- PRUint64 *newval);
-static int dna_fix_maxval(struct configEntry *config_entry);
+ PRUint64 *newval, void *txn);
+static int dna_fix_maxval(struct configEntry *config_entry, void *txn);
static void dna_notice_allocation(struct configEntry *config_entry,
- PRUint64 new, PRUint64 last, int fix);
-static int dna_update_shared_config(struct configEntry * config_entry);
+ PRUint64 new, PRUint64 last, int fix, void *txn);
+static int dna_update_shared_config(struct configEntry * config_entry, void *txn);
static void dna_update_config_event(time_t event_time, void *arg);
-static int dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers);
+static int dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers, void *txn);
static void dna_free_shared_server(struct dnaServer **server);
static void dna_delete_shared_servers(PRCList **servers);
static int dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper);
@@ -247,8 +247,8 @@ static int dna_request_range(struct configEntry *config_entry,
PRUint64 *lower, PRUint64 *upper);
static struct berval *dna_create_range_request(char *range_dn);
static int dna_update_next_range(struct configEntry *config_entry,
- PRUint64 lower, PRUint64 upper);
-static int dna_activate_next_range(struct configEntry *config_entry);
+ PRUint64 lower, PRUint64 upper, void *txn);
+static int dna_activate_next_range(struct configEntry *config_entry, void *txn);
static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn);
static int dna_get_replica_bind_creds(char *range_dn, struct dnaServer *server,
char **bind_dn, char **bind_passwd,
@@ -341,6 +341,8 @@ const char *getPluginDN()
return _PluginDN;
}
+static int plugin_is_betxn = 0;
+
/*
dna_init
-------------
@@ -351,11 +353,25 @@ dna_init(Slapi_PBlock *pb)
{
int status = DNA_SUCCESS;
char *plugin_identity = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int preadd = SLAPI_PLUGIN_PRE_ADD_FN;
+ int premod = SLAPI_PLUGIN_PRE_MODIFY_FN;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_init\n");
- /**
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ plugin_is_betxn = 1;
+ preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
+ premod = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
+ /**
* Store the plugin identity for later use.
* Used for internal operations
*/
@@ -372,10 +388,14 @@ dna_init(Slapi_PBlock *pb)
(void *) dna_close) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
- (void *) dna_mod_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
- (void *) dna_add_pre_op) != 0 ||
+ slapi_pblock_set(pb, premod, (void *) dna_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, preadd, (void *) dna_add_pre_op) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_init: failed to register plugin\n");
+ status = DNA_FAILURE;
+ }
+
+ if ((status == DNA_SUCCESS) && !plugin_is_betxn &&
/* internal preoperation */
slapi_register_plugin("internalpreoperation", /* op type */
1, /* Enabled */
@@ -384,16 +404,32 @@ dna_init(Slapi_PBlock *pb)
DNA_INT_PREOP_DESC, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
- ) ||
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_init: failed to register internalpreoperation plugin\n");
+ status = DNA_FAILURE;
+ }
+ if (status == DNA_SUCCESS) {
+ plugin_type = "postoperation";
+ if (plugin_is_betxn) {
+ plugin_type = "betxnpostoperation";
+ }
/* the config change checking post op */
- slapi_register_plugin("postoperation", /* op type */
- 1, /* Enabled */
- "dna_init", /* this function desc */
- dna_postop_init, /* init func for post op */
- DNA_POSTOP_DESC, /* plugin desc */
- NULL, /* ? */
- plugin_identity /* access control */
- ) ||
+ if (slapi_register_plugin(plugin_type, /* op type */
+ 1, /* Enabled */
+ "dna_init", /* this function desc */
+ dna_postop_init, /* init func for post op */
+ DNA_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_init: failed to register postop plugin\n");
+ status = DNA_FAILURE;
+ }
+ }
+
+ if ((status == DNA_SUCCESS) &&
/* the range extension extended operation */
slapi_register_plugin("extendedop", /* op type */
1, /* Enabled */
@@ -414,6 +450,7 @@ dna_init(Slapi_PBlock *pb)
return status;
}
+/* not used when using plugin as a betxn plugin - betxn plugins are called for both internal and external ops */
static int
dna_internal_preop_init(Slapi_PBlock *pb)
{
@@ -437,19 +474,26 @@ static int
dna_postop_init(Slapi_PBlock *pb)
{
int status = DNA_SUCCESS;
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ if (plugin_is_betxn) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- (void *) dna_config_check_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- (void *) dna_config_check_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- (void *) dna_config_check_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- (void *) dna_config_check_post_op) != 0) {
+ slapi_pblock_set(pb, addfn, (void *) dna_config_check_post_op) != 0 ||
+ slapi_pblock_set(pb, mdnfn, (void *) dna_config_check_post_op) != 0 ||
+ slapi_pblock_set(pb, delfn, (void *) dna_config_check_post_op) != 0 ||
+ slapi_pblock_set(pb, modfn, (void *) dna_config_check_post_op) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_postop_init: failed to register plugin\n");
status = DNA_FAILURE;
@@ -1263,7 +1307,7 @@ dna_update_config_event(time_t event_time, void *arg)
slapi_delete_internal_pb(pb);
/* Now force the entry to be recreated */
- dna_update_shared_config(config_entry);
+ dna_update_shared_config(config_entry, NULL);
slapi_unlock_mutex(config_entry->lock);
slapi_pblock_init(pb);
@@ -1291,7 +1335,7 @@ bail:
* The lock for configEntry should be obtained
* before calling this function.
*/
-static int dna_fix_maxval(struct configEntry *config_entry)
+static int dna_fix_maxval(struct configEntry *config_entry, void *txn)
{
PRCList *servers = NULL;
PRCList *server = NULL;
@@ -1306,7 +1350,7 @@ static int dna_fix_maxval(struct configEntry *config_entry)
/* If we already have a next range we only need
* to activate it. */
if (config_entry->next_range_lower != 0) {
- ret = dna_activate_next_range(config_entry);
+ ret = dna_activate_next_range(config_entry, txn);
if (ret != 0) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_fix_maxval: Unable to activate the "
@@ -1315,7 +1359,7 @@ static int dna_fix_maxval(struct configEntry *config_entry)
} else if (config_entry->shared_cfg_base) {
/* Find out if there are any other servers to request
* range from. */
- dna_get_shared_servers(config_entry, &servers);
+ dna_get_shared_servers(config_entry, &servers, txn);
if (servers) {
/* We have other servers we can try to extend
@@ -1330,7 +1374,7 @@ static int dna_fix_maxval(struct configEntry *config_entry)
} else {
/* Someone provided us with a new range. Attempt
* to update the config. */
- if ((ret = dna_update_next_range(config_entry, lower, upper)) == 0) {
+ if ((ret = dna_update_next_range(config_entry, lower, upper, txn)) == 0) {
break;
}
}
@@ -1362,7 +1406,7 @@ bail:
* this function. */
static void
dna_notice_allocation(struct configEntry *config_entry, PRUint64 new,
- PRUint64 last, int fix)
+ PRUint64 last, int fix, void *txn)
{
/* update our cached config entry */
if ((new != 0) && (new <= (config_entry->maxval + config_entry->interval))) {
@@ -1376,7 +1420,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64 new,
* new active range. */
if (config_entry->next_range_lower != 0) {
/* Make the next range active */
- if (dna_activate_next_range(config_entry) != 0) {
+ if (dna_activate_next_range(config_entry, txn) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_notice_allocation: Unable to activate "
"the next range for range %s.\n", config_entry->dn);
@@ -1384,7 +1428,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64 new,
} else {
config_entry->remaining = 0;
/* update the shared configuration */
- dna_update_shared_config(config_entry);
+ dna_update_shared_config(config_entry, txn);
}
} else {
if (config_entry->next_range_lower != 0) {
@@ -1397,7 +1441,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64 new,
}
/* update the shared configuration */
- dna_update_shared_config(config_entry);
+ dna_update_shared_config(config_entry, txn);
}
/* Check if we passed the threshold and try to fix maxval if so. We
@@ -1409,7 +1453,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64 new,
config_entry->threshold, config_entry->dn, config_entry->remaining);
/* Only attempt to fix maxval if the fix flag is set. */
if (fix != 0) {
- dna_fix_maxval(config_entry);
+ dna_fix_maxval(config_entry, txn);
}
}
@@ -1417,7 +1461,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64 new,
}
static int
-dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
+dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers, void *txn)
{
int ret = LDAP_SUCCESS;
Slapi_PBlock *pb = NULL;
@@ -1442,6 +1486,7 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
LDAP_SCOPE_ONELEVEL, "objectclass=*",
attrs, 0, NULL,
NULL, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -1826,7 +1871,7 @@ static LDAPControl *dna_build_sort_control(const char *attr)
* maximum configured value for this range. */
static int
dna_first_free_value(struct configEntry *config_entry,
- PRUint64 *newval)
+ PRUint64 *newval, void *txn)
{
Slapi_Entry **entries = NULL;
Slapi_PBlock *pb = NULL;
@@ -1894,6 +1939,7 @@ dna_first_free_value(struct configEntry *config_entry,
LDAP_SCOPE_SUBTREE, filter,
config_entry->types, 0, ctrls,
NULL, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1933,6 +1979,7 @@ dna_first_free_value(struct configEntry *config_entry,
config_entry->types, 0, 0,
NULL, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2006,7 +2053,7 @@ cleanup:
* Return the next value to be assigned
*/
static int dna_get_next_value(struct configEntry *config_entry,
- char **next_value_ret)
+ char **next_value_ret, void *txn)
{
Slapi_PBlock *pb = NULL;
LDAPMod mod_replace;
@@ -2026,12 +2073,12 @@ static int dna_get_next_value(struct configEntry *config_entry,
slapi_lock_mutex(config_entry->lock);
/* get the first value */
- ret = dna_first_free_value(config_entry, &setval);
+ ret = dna_first_free_value(config_entry, &setval, txn);
if (LDAP_SUCCESS != ret) {
/* check if we overflowed the configured range */
if (setval > config_entry->maxval) {
/* try for a new range or fail */
- ret = dna_fix_maxval(config_entry);
+ ret = dna_fix_maxval(config_entry, txn);
if (LDAP_SUCCESS != ret) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_get_next_value: no more values available!!\n");
@@ -2039,7 +2086,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
}
/* get the first value from our newly extended range */
- ret = dna_first_free_value(config_entry, &setval);
+ ret = dna_first_free_value(config_entry, &setval, txn);
if (LDAP_SUCCESS != ret)
goto done;
} else {
@@ -2076,6 +2123,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
slapi_modify_internal_set_pb(pb, config_entry->dn,
mods, 0, 0, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -2090,7 +2138,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
}
/* update our cached config */
- dna_notice_allocation(config_entry, nextval, setval, 1);
+ dna_notice_allocation(config_entry, nextval, setval, 1, txn);
}
done:
@@ -2116,7 +2164,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
* before calling this function.
* */
static int
-dna_update_shared_config(struct configEntry * config_entry)
+dna_update_shared_config(struct configEntry * config_entry, void *txn)
{
int ret = LDAP_SUCCESS;
@@ -2148,7 +2196,7 @@ dna_update_shared_config(struct configEntry * config_entry)
} else {
slapi_modify_internal_set_pb(pb, config_entry->shared_cfg_dn,
mods, NULL, NULL, getPluginID(), 0);
-
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -2176,6 +2224,7 @@ dna_update_shared_config(struct configEntry * config_entry)
/* e will be consumed by slapi_add_internal() */
slapi_add_entry_internal_set_pb(pb, e, NULL, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
}
@@ -2205,7 +2254,7 @@ dna_update_shared_config(struct configEntry * config_entry)
*/
static int
dna_update_next_range(struct configEntry *config_entry,
- PRUint64 lower, PRUint64 upper)
+ PRUint64 lower, PRUint64 upper, void *txn)
{
Slapi_PBlock *pb = NULL;
LDAPMod mod_replace;
@@ -2236,7 +2285,7 @@ dna_update_next_range(struct configEntry *config_entry,
slapi_modify_internal_set_pb(pb, config_entry->dn,
mods, 0, 0, getPluginID(), 0);
-
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -2252,7 +2301,7 @@ dna_update_next_range(struct configEntry *config_entry,
/* update the cached config and the shared config */
config_entry->next_range_lower = lower;
config_entry->next_range_upper = upper;
- dna_notice_allocation(config_entry, 0, 0, 0);
+ dna_notice_allocation(config_entry, 0, 0, 0, txn);
}
bail:
@@ -2269,7 +2318,7 @@ bail:
* be obtained before calling this function.
*/
static int
-dna_activate_next_range(struct configEntry *config_entry)
+dna_activate_next_range(struct configEntry *config_entry, void *txn)
{
Slapi_PBlock *pb = NULL;
LDAPMod mod_maxval;
@@ -2318,7 +2367,7 @@ dna_activate_next_range(struct configEntry *config_entry)
slapi_modify_internal_set_pb(pb, config_entry->dn,
mods, 0, 0, getPluginID(), 0);
-
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -2339,7 +2388,7 @@ dna_activate_next_range(struct configEntry *config_entry)
config_entry->remaining = ((config_entry->maxval - config_entry->nextval + 1) /
config_entry->interval);
/* update the shared configuration */
- dna_update_shared_config(config_entry);
+ dna_update_shared_config(config_entry, txn);
}
bail:
@@ -2781,6 +2830,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
char *errstr = NULL;
int i = 0;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_pre_op\n");
@@ -2792,6 +2842,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
if (0 == (dn = dna_get_dn(pb)))
goto bail;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (LDAP_CHANGETYPE_ADD == modtype) {
slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
} else {
@@ -2808,7 +2859,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
*/
Slapi_DN *tmp_dn = dna_get_sdn(pb);
if (tmp_dn) {
- slapi_search_internal_get_entry(tmp_dn, 0, &e, getPluginID());
+ slapi_search_internal_get_entry_ext(tmp_dn, 0, &e, getPluginID(), txn);
free_entry = 1;
}
@@ -3047,7 +3098,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
int len;
/* create the value to add */
- ret = dna_get_next_value(config_entry, &value);
+ ret = dna_get_next_value(config_entry, &value, txn);
if (DNA_SUCCESS != ret) {
errstr = slapi_ch_smprintf("Allocation of a new value for range"
" %s failed! Unable to proceed.",
@@ -3420,7 +3471,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
/* Try to set the new next range in the config */
ret = dna_update_next_range(config_entry, config_entry->next_range_lower,
- *lower - 1);
+ *lower - 1, NULL);
} else {
/* We release up to half of our remaining values,
* but we'll only release a range that is a multiple
@@ -3457,7 +3508,6 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
slapi_modify_internal_set_pb(pb, config_entry->dn,
mods, 0, 0, getPluginID(), 0);
-
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -3468,7 +3518,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
if (ret == LDAP_SUCCESS) {
/* Adjust maxval in our cached config and shared config */
config_entry->maxval = *lower - 1;
- dna_notice_allocation(config_entry, config_entry->nextval, 0, 0);
+ dna_notice_allocation(config_entry, config_entry->nextval, 0, 0, NULL);
}
}
diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c b/ldap/servers/plugins/linkedattrs/fixup_task.c
index d5d0b14de..ef2c7e093 100644
--- a/ldap/servers/plugins/linkedattrs/fixup_task.c
+++ b/ldap/servers/plugins/linkedattrs/fixup_task.c
@@ -48,7 +48,7 @@
*/
static void linked_attrs_fixup_task_destructor(Slapi_Task *task);
static void linked_attrs_fixup_task_thread(void *arg);
-static void linked_attrs_fixup_links(struct configEntry *config);
+static void linked_attrs_fixup_links(struct configEntry *config, void *txn);
static int linked_attrs_remove_backlinks_callback(Slapi_Entry *e, void *callback_data);
static int linked_attrs_add_backlinks_callback(Slapi_Entry *e, void *callback_data);
static const char *fetch_attr(Slapi_Entry *e, const char *attrname,
@@ -163,7 +163,7 @@ linked_attrs_fixup_task_thread(void *arg)
"Fixing up linked attribute pair (%s)\n",
config_entry->dn);
- linked_attrs_fixup_links(config_entry);
+ linked_attrs_fixup_links(config_entry, NULL);
break;
}
} else {
@@ -173,7 +173,7 @@ linked_attrs_fixup_task_thread(void *arg)
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
"Fixing up linked attribute pair (%s)\n", config_entry->dn);
- linked_attrs_fixup_links(config_entry);
+ linked_attrs_fixup_links(config_entry, NULL);
}
list = PR_NEXT_LINK(list);
@@ -200,12 +200,19 @@ linked_attrs_fixup_task_thread(void *arg)
slapi_task_finish(task, rc);
}
+struct fixup_cb_data {
+ char *attrtype;
+ void *txn;
+ struct configEntry *config;
+};
+
static void
-linked_attrs_fixup_links(struct configEntry *config)
+linked_attrs_fixup_links(struct configEntry *config, void *txn)
{
Slapi_PBlock *pb = slapi_pblock_new();
char *del_filter = NULL;
char *add_filter = NULL;
+ struct fixup_cb_data cb_data = {NULL, NULL, NULL};
del_filter = slapi_ch_smprintf("%s=*", config->managedtype);
add_filter = slapi_ch_smprintf("%s=*", config->linktype);
@@ -218,8 +225,11 @@ linked_attrs_fixup_links(struct configEntry *config)
* within the scope and remove the managed type. */
slapi_search_internal_set_pb(pb, config->scope, LDAP_SCOPE_SUBTREE,
del_filter, 0, 0, 0, 0, linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
- slapi_search_internal_callback_pb(pb, config->managedtype, 0,
+ cb_data.attrtype = config->managedtype;
+ cb_data.txn = txn;
+ slapi_search_internal_callback_pb(pb, &cb_data, 0,
linked_attrs_remove_backlinks_callback, 0);
/* Clean out pblock for reuse. */
@@ -229,8 +239,12 @@ linked_attrs_fixup_links(struct configEntry *config)
* scope and add backlinks to the entries they point to. */
slapi_search_internal_set_pb(pb, config->scope, LDAP_SCOPE_SUBTREE,
add_filter, 0, 0, 0, 0, linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
- slapi_search_internal_callback_pb(pb, config, 0,
+ cb_data.attrtype = NULL;
+ cb_data.txn = txn;
+ cb_data.config = config;
+ slapi_search_internal_callback_pb(pb, &cb_data, 0,
linked_attrs_add_backlinks_callback, 0);
} else {
/* Loop through all non-private backend suffixes and
@@ -245,7 +259,10 @@ linked_attrs_fixup_links(struct configEntry *config)
LDAP_SCOPE_SUBTREE, del_filter,
0, 0, 0, 0,
linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
+ cb_data.attrtype = config->managedtype;
+ cb_data.txn = txn;
slapi_search_internal_callback_pb(pb, config->managedtype, 0,
linked_attrs_remove_backlinks_callback, 0);
@@ -256,8 +273,11 @@ linked_attrs_fixup_links(struct configEntry *config)
LDAP_SCOPE_SUBTREE, add_filter,
0, 0, 0, 0,
linked_attrs_get_plugin_id(), 0);
-
- slapi_search_internal_callback_pb(pb, config, 0,
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
+ cb_data.attrtype = NULL;
+ cb_data.txn = txn;
+ cb_data.config = config;
+ slapi_search_internal_callback_pb(pb, &cb_data, 0,
linked_attrs_add_backlinks_callback, 0);
/* Clean out pblock for reuse. */
@@ -280,7 +300,8 @@ linked_attrs_remove_backlinks_callback(Slapi_Entry *e, void *callback_data)
{
int rc = 0;
Slapi_DN *sdn = slapi_entry_get_sdn(e);
- char *type = (char *)callback_data;
+ struct fixup_cb_data *cb_data = (struct fixup_cb_data *)callback_data;
+ char *type = cb_data->attrtype;
Slapi_PBlock *pb = slapi_pblock_new();
char *val[1];
LDAPMod mod;
@@ -303,6 +324,7 @@ linked_attrs_remove_backlinks_callback(Slapi_Entry *e, void *callback_data)
/* Perform the operation. */
slapi_modify_internal_set_pb_ext(pb, sdn, mods, 0, 0,
linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, cb_data->txn);
slapi_modify_internal_pb(pb);
slapi_pblock_destroy(pb);
@@ -315,7 +337,8 @@ linked_attrs_add_backlinks_callback(Slapi_Entry *e, void *callback_data)
{
int rc = 0;
char *linkdn = slapi_entry_get_dn(e);
- struct configEntry *config = (struct configEntry *)callback_data;
+ struct fixup_cb_data *cb_data = (struct fixup_cb_data *)callback_data;
+ struct configEntry *config = cb_data->config;
Slapi_PBlock *pb = slapi_pblock_new();
int i = 0;
char **targets = NULL;
@@ -365,6 +388,7 @@ linked_attrs_add_backlinks_callback(Slapi_Entry *e, void *callback_data)
/* Perform the modify operation. */
slapi_modify_internal_set_pb_ext(pb, targetsdn, mods, 0, 0,
linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, cb_data->txn);
slapi_modify_internal_pb(pb);
/* Initialize the pblock so we can reuse it. */
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 5c6d4624c..2b5127d5f 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -107,13 +107,13 @@ static int linked_attrs_oktodo(Slapi_PBlock *pb);
void linked_attrs_load_array(Slapi_Value **array, Slapi_Attr *attr);
int linked_attrs_compare(const void *a, const void *b);
static void linked_attrs_add_backpointers(char *linkdn, struct configEntry *config,
- Slapi_Mod *smod);
+ Slapi_Mod *smod, void *txn);
static void linked_attrs_del_backpointers(Slapi_PBlock *pb, char *linkdn,
struct configEntry *config, Slapi_Mod *smod);
static void linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
struct configEntry *config, Slapi_Mod *smod);
static void linked_attrs_mod_backpointers(char *linkdn, char *type, char *scope,
- int modop, Slapi_ValueSet *targetvals);
+ int modop, Slapi_ValueSet *targetvals, void *txn);
/*
* Config cache locking functions
@@ -164,6 +164,7 @@ linked_attrs_get_plugin_dn()
return _PluginDN;
}
+static int plugin_is_betxn = 0;
/*
* Plug-in initialization functions
@@ -173,10 +174,24 @@ linked_attrs_init(Slapi_PBlock *pb)
{
int status = 0;
char *plugin_identity = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int preadd = SLAPI_PLUGIN_PRE_ADD_FN;
+ int premod = SLAPI_PLUGIN_PRE_MODIFY_FN;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_init\n");
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ plugin_is_betxn = 1;
+ preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
+ premod = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
/* Store the plugin identity for later use.
* Used for internal operations. */
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
@@ -192,10 +207,14 @@ linked_attrs_init(Slapi_PBlock *pb)
(void *) linked_attrs_close) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
- (void *) linked_attrs_mod_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
- (void *) linked_attrs_add_pre_op) != 0 ||
+ slapi_pblock_set(pb, premod, (void *) linked_attrs_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, preadd, (void *) linked_attrs_add_pre_op) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
+ "linked_attrs_init: failed to register plugin\n");
+ status = -1;
+ }
+
+ if (!status && !plugin_is_betxn &&
slapi_register_plugin("internalpostoperation", /* op type */
1, /* Enabled */
"linked_attrs_init", /* this function desc */
@@ -203,26 +222,37 @@ linked_attrs_init(Slapi_PBlock *pb)
LINK_INT_POSTOP_DESC, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
- ) ||
- slapi_register_plugin("postoperation", /* op type */
- 1, /* Enabled */
- "linked_attrs_init", /* this function desc */
- linked_attrs_postop_init, /* init func for post op */
- LINK_POSTOP_DESC, /* plugin desc */
- NULL, /* ? */
- plugin_identity /* access control */
- )
- ) {
+ )) {
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
- "linked_attrs_init: failed to register plugin\n");
+ "linked_attrs_init: failed to register internalpostoperation plugin\n");
status = -1;
}
+ if (!status) {
+ plugin_type = "postoperation";
+ if (plugin_is_betxn) {
+ plugin_type = "betxnpostoperation";
+ }
+ if (slapi_register_plugin(plugin_type, /* op type */
+ 1, /* Enabled */
+ "linked_attrs_init", /* this function desc */
+ linked_attrs_postop_init, /* init func for post op */
+ LINK_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
+ "linked_attrs_init: failed to register postop plugin\n");
+ status = -1;
+ }
+ }
+
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"<-- linked_attrs_init\n");
return status;
}
+/* not used when using plugin as a betxn plugin - betxn plugins are called for both internal and external ops */
static int
linked_attrs_internal_postop_init(Slapi_PBlock *pb)
{
@@ -252,19 +282,26 @@ static int
linked_attrs_postop_init(Slapi_PBlock *pb)
{
int status = 0;
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ if (plugin_is_betxn) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- (void *) linked_attrs_add_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- (void *) linked_attrs_del_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- (void *) linked_attrs_mod_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- (void *) linked_attrs_modrdn_post_op) != 0) {
+ slapi_pblock_set(pb, addfn, (void *) linked_attrs_add_post_op) != 0 ||
+ slapi_pblock_set(pb, delfn, (void *) linked_attrs_del_post_op) != 0 ||
+ slapi_pblock_set(pb, modfn, (void *) linked_attrs_mod_post_op) != 0 ||
+ slapi_pblock_set(pb, mdnfn, (void *) linked_attrs_modrdn_post_op) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
"linked_attrs_postop_init: failed to register plugin\n");
status = -1;
@@ -1218,13 +1255,13 @@ linked_attrs_compare(const void *a, const void *b)
*/
static void
linked_attrs_add_backpointers(char *linkdn, struct configEntry *config,
- Slapi_Mod *smod)
+ Slapi_Mod *smod, void *txn)
{
Slapi_ValueSet *vals = slapi_valueset_new();
slapi_valueset_set_from_smod(vals, smod);
linked_attrs_mod_backpointers(linkdn, config->managedtype, config->scope,
- LDAP_MOD_ADD, vals);
+ LDAP_MOD_ADD, vals, txn);
slapi_valueset_free(vals);
}
@@ -1240,6 +1277,7 @@ linked_attrs_del_backpointers(Slapi_PBlock *pb, char *linkdn,
struct configEntry *config, Slapi_Mod *smod)
{
Slapi_ValueSet *vals = NULL;
+ void *txn = NULL;
/* If no values are listed in the smod, we need to get
* a list of all of the values that were deleted by
@@ -1256,8 +1294,9 @@ linked_attrs_del_backpointers(Slapi_PBlock *pb, char *linkdn,
slapi_valueset_set_from_smod(vals, smod);
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
linked_attrs_mod_backpointers(linkdn, config->managedtype, config->scope,
- LDAP_MOD_DELETE, vals);
+ LDAP_MOD_DELETE, vals, txn);
slapi_valueset_free(vals);
}
@@ -1278,6 +1317,7 @@ linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
Slapi_Entry *post_e = NULL;
Slapi_Attr *pre_attr = 0;
Slapi_Attr *post_attr = 0;
+ void *txn = NULL;
/* Get the pre and post copy of the entry to see
* what values have been added and removed. */
@@ -1288,6 +1328,7 @@ linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
slapi_entry_attr_find(pre_e, config->linktype, &pre_attr);
slapi_entry_attr_find(post_e, config->linktype, &post_attr);
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if(pre_attr || post_attr) {
int pre_total = 0;
@@ -1374,13 +1415,13 @@ linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
/* Perform the actual updates to the target entries. */
if (delvals) {
linked_attrs_mod_backpointers(linkdn, config->managedtype,
- config->scope, LDAP_MOD_DELETE, delvals);
+ config->scope, LDAP_MOD_DELETE, delvals, txn);
slapi_valueset_free(delvals);
}
if (addvals) {
linked_attrs_mod_backpointers(linkdn, config->managedtype,
- config->scope, LDAP_MOD_ADD, addvals);
+ config->scope, LDAP_MOD_ADD, addvals, txn);
slapi_valueset_free(addvals);
}
@@ -1396,7 +1437,7 @@ linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
*/
static void
linked_attrs_mod_backpointers(char *linkdn, char *type,
- char *scope, int modop, Slapi_ValueSet *targetvals)
+ char *scope, int modop, Slapi_ValueSet *targetvals, void *txn)
{
char *val[2];
int i = 0;
@@ -1449,6 +1490,7 @@ linked_attrs_mod_backpointers(char *linkdn, char *type,
/* Perform the modify operation. */
slapi_modify_internal_set_pb_ext(mod_pb, targetsdn, mods, 0, 0,
linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(mod_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mod_pb);
/* Initialize the pblock so we can reuse it. */
@@ -1482,6 +1524,7 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
int free_entry = 0;
char *errstr = NULL;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_pre_op\n");
@@ -1493,6 +1536,7 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
if (0 == (dn = linked_attrs_get_dn(pb)))
goto bail;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (linked_attrs_dn_is_config(dn)) {
/* Validate config changes, but don't apply them.
* This allows us to reject invalid config changes
@@ -1507,7 +1551,7 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
/* int free_sdn = 0; */
Slapi_DN *tmp_dn = linked_attrs_get_sdn(pb);
if (tmp_dn) {
- slapi_search_internal_get_entry(tmp_dn, 0, &e, linked_attrs_get_plugin_id());
+ slapi_search_internal_get_entry_ext(tmp_dn, 0, &e, linked_attrs_get_plugin_id(), txn);
free_entry = 1;
}
@@ -1579,6 +1623,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
char *dn = NULL;
struct configEntry *config = NULL;
void *caller_id = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_mod_post_op\n");
@@ -1596,6 +1641,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
/* Just return without processing */
return 0;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (linked_attrs_oktodo(pb) &&
(dn = linked_attrs_get_dn(pb))) {
@@ -1638,7 +1684,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
case LDAP_MOD_ADD:
/* Find the entries pointed to by the new
* values and add the backpointers. */
- linked_attrs_add_backpointers(dn, config, smod);
+ linked_attrs_add_backpointers(dn, config, smod, txn);
break;
case LDAP_MOD_DELETE:
/* Find the entries pointed to by the deleted
@@ -1682,6 +1728,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
{
Slapi_Entry *e = NULL;
char *dn = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_add_post_op\n");
@@ -1700,6 +1747,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
"retrieving dn\n");
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Get the newly added entry. */
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &e);
@@ -1732,7 +1780,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
slapi_lock_mutex(config->lock);
linked_attrs_mod_backpointers(dn, config->managedtype,
- config->scope, LDAP_MOD_ADD, vals);
+ config->scope, LDAP_MOD_ADD, vals, txn);
slapi_unlock_mutex(config->lock);
@@ -1761,6 +1809,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
{
char *dn = NULL;
Slapi_Entry *e = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_del_post_op\n");
@@ -1769,6 +1818,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
if (!g_plugin_started || !linked_attrs_oktodo(pb))
return 0;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Reload config if a config entry was deleted. */
if ((dn = linked_attrs_get_dn(pb))) {
if (linked_attrs_dn_is_config(dn))
@@ -1811,7 +1861,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
slapi_lock_mutex(config->lock);
linked_attrs_mod_backpointers(dn, config->managedtype,
- config->scope, LDAP_MOD_DELETE, vals);
+ config->scope, LDAP_MOD_DELETE, vals, txn);
slapi_unlock_mutex(config->lock);
@@ -1840,7 +1890,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
/* Delete forward link value. */
linked_attrs_mod_backpointers(dn, config->linktype,
- config->scope, LDAP_MOD_DELETE, vals);
+ config->scope, LDAP_MOD_DELETE, vals, txn);
slapi_unlock_mutex(config->lock);
@@ -1878,6 +1928,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
char *type = NULL;
struct configEntry *config = NULL;
int rc = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_modrdn_post_op\n");
@@ -1887,6 +1938,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
goto done;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Reload config if an existing config entry was renamed,
* or if the new dn brings an entry into the scope of the
* config entries. */
@@ -1939,7 +1991,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* Delete old dn value. */
linked_attrs_mod_backpointers(old_dn, config->managedtype,
- config->scope, LDAP_MOD_DELETE, vals);
+ config->scope, LDAP_MOD_DELETE, vals, txn);
slapi_unlock_mutex(config->lock);
@@ -1962,7 +2014,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* Add new dn value. */
linked_attrs_mod_backpointers(new_dn, config->managedtype,
- config->scope, LDAP_MOD_ADD, vals);
+ config->scope, LDAP_MOD_ADD, vals, txn);
slapi_unlock_mutex(config->lock);
@@ -1991,11 +2043,11 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* Delete old dn value. */
linked_attrs_mod_backpointers(old_dn, config->linktype,
- config->scope, LDAP_MOD_DELETE, vals);
+ config->scope, LDAP_MOD_DELETE, vals, txn);
/* Add new dn value. */
linked_attrs_mod_backpointers(new_dn, config->linktype,
- config->scope, LDAP_MOD_ADD, vals);
+ config->scope, LDAP_MOD_ADD, vals, txn);
slapi_unlock_mutex(config->lock);
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index 237ef91c4..82acdbd21 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -86,9 +86,9 @@ static int mep_modrdn_pre_op(Slapi_PBlock *pb);
/*
* Config cache management functions
*/
-static int mep_load_config();
+static int mep_load_config(Slapi_PBlock *pb);
static void mep_delete_config();
-static int mep_parse_config_entry(Slapi_Entry * e, int apply);
+static int mep_parse_config_entry(Slapi_Entry * e, int apply, Slapi_PBlock *pb);
static void mep_free_config_entry(struct configEntry ** entry);
/*
@@ -107,9 +107,9 @@ static int mep_isrepl(Slapi_PBlock *pb);
static Slapi_Entry *mep_create_managed_entry(struct configEntry *config,
Slapi_Entry *origin);
static void mep_add_managed_entry(struct configEntry *config,
- Slapi_Entry *origin);
+ Slapi_Entry *origin, void *txn);
static void mep_rename_managed_entry(Slapi_Entry *origin,
- Slapi_DN *new_dn, Slapi_DN *old_dn);
+ Slapi_DN *new_dn, Slapi_DN *old_dn, void *txn);
static Slapi_Mods *mep_get_mapped_mods(struct configEntry *config,
Slapi_Entry *origin, char **mapped_dn);
static int mep_parse_mapped_attr(char *mapping, Slapi_Entry *origin,
@@ -168,6 +168,8 @@ mep_get_plugin_sdn()
}
+static int plugin_is_betxn = 0;
+
/*
* Plug-in initialization functions
*/
@@ -176,10 +178,28 @@ mep_init(Slapi_PBlock *pb)
{
int status = 0;
char *plugin_identity = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int preadd = SLAPI_PLUGIN_PRE_ADD_FN;
+ int premod = SLAPI_PLUGIN_PRE_MODIFY_FN;
+ int predel = SLAPI_PLUGIN_PRE_DELETE_FN;
+ int premdn = SLAPI_PLUGIN_PRE_MODRDN_FN;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_init\n");
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ plugin_is_betxn = 1;
+ preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
+ premod = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
+ predel = SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN;
+ premdn = SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
/* Store the plugin identity for later use.
* Used for internal operations. */
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
@@ -195,14 +215,16 @@ mep_init(Slapi_PBlock *pb)
(void *) mep_close) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
- (void *) mep_mod_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
- (void *) mep_add_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_DELETE_FN,
- (void *) mep_del_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODRDN_FN,
- (void *) mep_modrdn_pre_op) != 0 ||
+ slapi_pblock_set(pb, premod, (void *) mep_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, preadd, (void *) mep_add_pre_op) != 0 ||
+ slapi_pblock_set(pb, predel, (void *) mep_del_pre_op) != 0 ||
+ slapi_pblock_set(pb, premdn, (void *) mep_modrdn_pre_op) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
+ "mep_init: failed to register plugin\n");
+ status = -1;
+ }
+
+ if (!status && !plugin_is_betxn &&
slapi_register_plugin("internalpostoperation", /* op type */
1, /* Enabled */
"mep_init", /* this function desc */
@@ -210,26 +232,34 @@ mep_init(Slapi_PBlock *pb)
MEP_INT_POSTOP_DESC, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
- ) ||
- slapi_register_plugin("postoperation", /* op type */
- 1, /* Enabled */
- "mep_init", /* this function desc */
- mep_postop_init, /* init func for post op */
- MEP_POSTOP_DESC, /* plugin desc */
- NULL, /* ? */
- plugin_identity /* access control */
- )
- ) {
+ )) {
slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
- "mep_init: failed to register plugin\n");
+ "mep_init: failed to register internalpostoperation plugin\n");
status = -1;
}
+ if (!status) {
+ plugin_type = plugin_is_betxn ? "betxnpostoperation" : "postoperation";
+ if (slapi_register_plugin(plugin_type, /* op type */
+ 1, /* Enabled */
+ "mep_init", /* this function desc */
+ mep_postop_init, /* init func for post op */
+ MEP_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
+ "mep_init: failed to register plugin\n");
+ status = -1;
+ }
+ }
+
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"<-- mep_init\n");
return status;
}
+/* not used when using plugin as a betxn plugin - betxn plugins are called for both internal and external ops */
static int
mep_internal_postop_init(Slapi_PBlock *pb)
{
@@ -259,19 +289,26 @@ static int
mep_postop_init(Slapi_PBlock *pb)
{
int status = 0;
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ if (plugin_is_betxn) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- (void *) mep_add_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- (void *) mep_del_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- (void *) mep_mod_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- (void *) mep_modrdn_post_op) != 0) {
+ slapi_pblock_set(pb, addfn, (void *) mep_add_post_op) != 0 ||
+ slapi_pblock_set(pb, delfn, (void *) mep_del_post_op) != 0 ||
+ slapi_pblock_set(pb, modfn, (void *) mep_mod_post_op) != 0 ||
+ slapi_pblock_set(pb, mdnfn, (void *) mep_modrdn_post_op) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
"mep_postop_init: failed to register plugin\n");
status = -1;
@@ -333,7 +370,7 @@ mep_start(Slapi_PBlock * pb)
g_mep_config = (PRCList *)slapi_ch_calloc(1, sizeof(struct configEntry));
PR_INIT_CLIST(g_mep_config);
- if (mep_load_config() != 0) {
+ if (mep_load_config(pb) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
"mep_start: unable to load plug-in configuration\n");
return -1;
@@ -401,13 +438,14 @@ mep_get_config()
* --- cn=etc,...
*/
static int
-mep_load_config()
+mep_load_config(Slapi_PBlock *pb)
{
int status = 0;
int result;
int i;
Slapi_PBlock *search_pb;
Slapi_Entry **entries = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_load_config\n");
@@ -442,6 +480,8 @@ mep_load_config()
NULL, 0, NULL, NULL, mep_get_plugin_id(), 0);
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
+ slapi_pblock_set(search_pb, SLAPI_TXN, txn);
slapi_search_internal_pb(search_pb);
slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -465,7 +505,7 @@ mep_load_config()
/* We don't care about the status here because we may have
* some invalid config entries, but we just want to continue
* looking for valid ones. */
- mep_parse_config_entry(entries[i], 1);
+ mep_parse_config_entry(entries[i], 1, pb);
}
cleanup:
@@ -489,7 +529,7 @@ mep_load_config()
* Returns 0 if the entry is valid and -1 if it is invalid.
*/
static int
-mep_parse_config_entry(Slapi_Entry * e, int apply)
+mep_parse_config_entry(Slapi_Entry * e, int apply, Slapi_PBlock *pb)
{
char *value;
struct configEntry *entry = NULL;
@@ -497,6 +537,7 @@ mep_parse_config_entry(Slapi_Entry * e, int apply)
PRCList *list;
int entry_added = 0;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_parse_config_entry\n");
@@ -530,6 +571,7 @@ mep_parse_config_entry(Slapi_Entry * e, int apply)
slapi_log_error(SLAPI_LOG_CONFIG, MEP_PLUGIN_SUBSYSTEM,
"----------> dn [%s]\n", entry->dn);
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Load the origin scope */
value = slapi_entry_attr_get_charptr(e, MEP_SCOPE_TYPE);
if (value) {
@@ -592,8 +634,8 @@ mep_parse_config_entry(Slapi_Entry * e, int apply)
/* Fetch the managed entry template */
template_sdn = slapi_sdn_new_dn_byref(entry->template_dn);
- slapi_search_internal_get_entry(template_sdn, 0,
- &entry->template_entry, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(template_sdn, 0,
+ &entry->template_entry, mep_get_plugin_id(), txn);
slapi_sdn_free(&template_sdn);
if (entry->template_entry == NULL) {
@@ -1178,7 +1220,7 @@ mep_create_managed_entry(struct configEntry *config, Slapi_Entry *origin)
*/
static void
mep_add_managed_entry(struct configEntry *config,
- Slapi_Entry *origin)
+ Slapi_Entry *origin, void *txn)
{
Slapi_Entry *managed_entry = NULL;
char *managed_dn = NULL;
@@ -1208,6 +1250,7 @@ mep_add_managed_entry(struct configEntry *config,
"entry \"%s\"\n.", managed_dn, slapi_entry_get_dn(origin));
slapi_add_entry_internal_set_pb(mod_pb, managed_entry, NULL,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mod_pb, SLAPI_TXN, txn);
slapi_add_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1253,6 +1296,7 @@ mep_add_managed_entry(struct configEntry *config,
slapi_modify_internal_set_pb_ext(mod_pb,
slapi_entry_get_sdn(origin),
mods, 0, 0, mep_get_plugin_id(), 0);
+ slapi_pblock_set(mod_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1277,7 +1321,7 @@ mep_add_managed_entry(struct configEntry *config,
*/
static void
mep_rename_managed_entry(Slapi_Entry *origin,
- Slapi_DN *new_dn, Slapi_DN *old_dn)
+ Slapi_DN *new_dn, Slapi_DN *old_dn, void *txn)
{
Slapi_RDN *srdn = slapi_rdn_new();
Slapi_PBlock *mep_pb = slapi_pblock_new();
@@ -1298,6 +1342,7 @@ mep_rename_managed_entry(Slapi_Entry *origin,
slapi_rename_internal_set_pb_ext(mep_pb, old_dn,
slapi_rdn_get_rdn(srdn),
NULL, 1, NULL, NULL, mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modrdn_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1326,6 +1371,7 @@ mep_rename_managed_entry(Slapi_Entry *origin,
vals[0], slapi_entry_get_dn(origin));
slapi_modify_internal_set_pb_ext(mep_pb, slapi_entry_get_sdn(origin),
mods, 0, 0, mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1744,6 +1790,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
struct configEntry *config = NULL;
void *caller_id = NULL;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_pre_op\n");
@@ -1758,6 +1805,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
if (0 == (sdn = mep_get_sdn(pb)))
goto bail;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (mep_dn_is_config(sdn)) {
/* Validate config changes, but don't apply them.
* This allows us to reject invalid config changes
@@ -1771,7 +1819,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
/* Fetch the entry being modified so we can
* create the resulting entry for validation. */
if (sdn) {
- slapi_search_internal_get_entry(sdn, 0, &e, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(sdn, 0, &e, mep_get_plugin_id(), txn);
free_entry = 1;
}
@@ -1800,7 +1848,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
goto bail;
}
- if (mep_parse_config_entry(e, 0) != 0) {
+ if (mep_parse_config_entry(e, 0, pb) != 0) {
/* Refuse the operation if config parsing failed. */
ret = LDAP_UNWILLING_TO_PERFORM;
if (LDAP_CHANGETYPE_ADD == modop) {
@@ -1852,7 +1900,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
case LDAP_CHANGETYPE_MODIFY:
/* Fetch the existing template entry. */
if (sdn) {
- slapi_search_internal_get_entry(sdn, 0, &e, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(sdn, 0, &e, mep_get_plugin_id(), txn);
free_entry = 1;
}
@@ -1920,7 +1968,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
slapi_entry_free(e);
}
- slapi_search_internal_get_entry(sdn, 0, &e, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(sdn, 0, &e, mep_get_plugin_id(), txn);
free_entry = 1;
}
@@ -1930,8 +1978,8 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
origin_dn = slapi_entry_attr_get_charptr(e, MEP_MANAGED_BY_TYPE);
if (origin_dn) {
origin_sdn = slapi_sdn_new_dn_byref(origin_dn);
- slapi_search_internal_get_entry(origin_sdn, 0,
- &origin_e, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(origin_sdn, 0,
+ &origin_e, mep_get_plugin_id(), txn);
slapi_sdn_free(&origin_sdn);
}
@@ -2062,6 +2110,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
Slapi_DN *mapped_sdn = NULL;
struct configEntry *config = NULL;
int result = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_mod_post_op\n");
@@ -2070,10 +2119,11 @@ mep_mod_post_op(Slapi_PBlock *pb)
if (!g_plugin_started)
return 0;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (mep_oktodo(pb) && (sdn = mep_get_sdn(pb))) {
/* First check if the config or a template is being modified. */
if (mep_dn_is_config(sdn) || mep_dn_is_template(slapi_sdn_get_dn(sdn))) {
- mep_load_config();
+ mep_load_config(pb);
}
/* If replication, just bail. */
@@ -2121,6 +2171,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
slapi_modify_internal_set_pb(mep_pb, managed_dn,
slapi_mods_get_ldapmods_byref(smods), 0, 0,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2142,7 +2193,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
managed_sdn = slapi_sdn_new_dn_byref(managed_dn);
if (slapi_sdn_compare(managed_sdn, mapped_sdn) != 0) {
- mep_rename_managed_entry(e, mapped_sdn, managed_sdn);
+ mep_rename_managed_entry(e, mapped_sdn, managed_sdn, txn);
}
slapi_sdn_free(&mapped_sdn);
@@ -2174,6 +2225,7 @@ mep_add_post_op(Slapi_PBlock *pb)
Slapi_Entry *e = NULL;
Slapi_DN *sdn = NULL;
struct configEntry *config = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_add_post_op\n");
@@ -2182,10 +2234,11 @@ mep_add_post_op(Slapi_PBlock *pb)
if (!g_plugin_started || !mep_oktodo(pb))
return 0;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Reload config if a config entry was added. */
if ((sdn = mep_get_sdn(pb))) {
if (mep_dn_is_config(sdn)) {
- mep_load_config();
+ mep_load_config(pb);
}
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
@@ -2219,7 +2272,7 @@ mep_add_post_op(Slapi_PBlock *pb)
mep_find_config(e, &config);
if (config) {
- mep_add_managed_entry(config, e);
+ mep_add_managed_entry(config, e, txn);
}
mep_config_unlock();
@@ -2240,6 +2293,7 @@ mep_del_post_op(Slapi_PBlock *pb)
{
Slapi_Entry *e = NULL;
Slapi_DN *sdn = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_del_post_op\n");
@@ -2252,7 +2306,7 @@ mep_del_post_op(Slapi_PBlock *pb)
/* Reload config if a config entry was deleted. */
if ((sdn = mep_get_sdn(pb))) {
if (mep_dn_is_config(sdn))
- mep_load_config();
+ mep_load_config(pb);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
"mep_del_post_op: Error "
@@ -2264,6 +2318,7 @@ mep_del_post_op(Slapi_PBlock *pb)
return 0;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Get deleted entry, then go through types to find config. */
slapi_pblock_get( pb, SLAPI_ENTRY_PRE_OP, &e );
@@ -2287,6 +2342,7 @@ mep_del_post_op(Slapi_PBlock *pb)
"\"%s\".\n ", managed_dn, slapi_sdn_get_dn(sdn));
slapi_delete_internal_set_pb(mep_pb, managed_dn, NULL,
NULL, mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_delete_internal_pb(mep_pb);
slapi_ch_free_string(&managed_dn);
@@ -2313,6 +2369,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
Slapi_Entry *post_e = NULL;
char *managed_dn = NULL;
struct configEntry *config = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_modrdn_post_op\n");
@@ -2335,9 +2392,10 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
return 0;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if ((old_sdn = mep_get_sdn(pb))) {
if (mep_dn_is_config(old_sdn) || mep_dn_is_config(new_sdn))
- mep_load_config();
+ mep_load_config(pb);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
"mep_modrdn_post_op: Error "
@@ -2388,6 +2446,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
managed_dn, slapi_sdn_get_dn(old_sdn));
slapi_delete_internal_set_pb (mep_pb, managed_dn, NULL, NULL,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_delete_internal_pb(mep_pb);
/* Clear out the pblock for reuse. */
@@ -2417,6 +2476,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
MEP_MANAGED_ENTRY_TYPE, MEP_ORIGIN_OC, new_dn);
slapi_modify_internal_set_pb_ext(mep_pb, new_sdn, mods, 0, 0,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2454,8 +2514,8 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
* perform our updates. */
managed_sdn = slapi_sdn_new_dn_byref(managed_dn);
- if (slapi_search_internal_get_entry(managed_sdn, 0,
- NULL, mep_get_plugin_id()) == LDAP_NO_SUCH_OBJECT) {
+ if (slapi_search_internal_get_entry_ext(managed_sdn, 0,
+ NULL, mep_get_plugin_id(), txn) == LDAP_NO_SUCH_OBJECT) {
slapi_ch_free_string(&managed_dn);
/* This DN is not a copy, so we don't want to free it later. */
managed_dn = slapi_entry_get_dn(new_managed_entry);
@@ -2469,6 +2529,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
"in entry \"%s\".\n", MEP_MANAGED_BY_TYPE, new_dn, managed_dn);
slapi_modify_internal_set_pb(mep_pb, managed_dn, mods, 0, 0,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2489,7 +2550,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
slapi_sdn_get_dn(old_sdn));
mep_rename_managed_entry(post_e,
slapi_entry_get_sdn(new_managed_entry),
- managed_sdn);
+ managed_sdn, txn);
}
/* Update all of the mapped attributes
@@ -2507,6 +2568,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
slapi_entry_get_sdn(new_managed_entry),
slapi_mods_get_ldapmods_byref(smods), 0, 0,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2549,7 +2611,7 @@ bailmod:
mep_find_config(post_e, &config);
if (config) {
- mep_add_managed_entry(config, post_e);
+ mep_add_managed_entry(config, post_e, txn);
}
mep_config_unlock();
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index 1328996ef..33be252e9 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -53,10 +53,10 @@
extern int slapi_log_urp;
static int urp_add_resolve_parententry (Slapi_PBlock *pb, char *sessionid, Slapi_Entry *entry, Slapi_Entry *parententry, CSN *opcsn);
-static int urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, const char *optype);
+static int urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, const char *optype, void *txn);
static int urp_naming_conflict_removal (Slapi_PBlock *pb, char *sessionid, CSN *opcsn, const char *optype);
-static int mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn, const Slapi_DN *conflictsdn, CSN *opcsn);
-static int del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags);
+static int mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn, const Slapi_DN *conflictsdn, CSN *opcsn, void *txn);
+static int del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags, void *txn);
static char *get_dn_plus_uniqueid(char *sessionid,const char *olddn,const char *uniqueid);
static char *get_rdn_plus_uniqueid(char *sessionid,const char *olddn,const char *uniqueid);
static int is_suffix_entry (Slapi_PBlock *pb, Slapi_Entry *entry, Slapi_DN **parenddn);
@@ -123,12 +123,14 @@ urp_add_operation( Slapi_PBlock *pb )
int op_result= 0;
int rc= 0; /* OK */
Slapi_DN *sdn = NULL;
+ void *txn = NULL;
if ( slapi_op_abandoned(pb) )
{
return rc;
}
+ slapi_pblock_get( pb, SLAPI_TXN, &txn );
slapi_pblock_get( pb, SLAPI_ADD_EXISTING_UNIQUEID_ENTRY, &existing_uniqueid_entry );
if (existing_uniqueid_entry!=NULL)
{
@@ -227,7 +229,7 @@ urp_add_operation( Slapi_PBlock *pb )
else if(r>0)
{
/* Existing entry is a loser */
- if (!urp_annotate_dn(sessionid, existing_dn_entry, opcsn, "ADD"))
+ if (!urp_annotate_dn(sessionid, existing_dn_entry, opcsn, "ADD", txn))
{
op_result= LDAP_OPERATIONS_ERROR;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
@@ -286,12 +288,14 @@ urp_modrdn_operation( Slapi_PBlock *pb )
int op_result= 0;
int rc= 0; /* OK */
int del_old_replconflict_attr = 0;
+ void *txn = NULL;
if ( slapi_op_abandoned(pb) )
{
return rc;
}
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
slapi_pblock_get (pb, SLAPI_MODRDN_TARGET_ENTRY, &target_entry);
if(target_entry==NULL)
{
@@ -417,7 +421,7 @@ urp_modrdn_operation( Slapi_PBlock *pb )
Unique ID already in RDN - Change to Lost and Found entry */
goto bailout;
}
- mod_namingconflict_attr (op_uniqueid, target_sdn, existing_sdn, opcsn);
+ mod_namingconflict_attr (op_uniqueid, target_sdn, existing_sdn, opcsn, txn);
slapi_pblock_set(pb, SLAPI_MODRDN_NEWRDN, newrdn_with_uniqueid);
slapi_log_error(slapi_log_urp, sessionid,
"Naming conflict MODRDN. Rename target entry to %s\n",
@@ -432,7 +436,7 @@ urp_modrdn_operation( Slapi_PBlock *pb )
{
/* The existing entry is a loser */
- int resolve = urp_annotate_dn (sessionid, existing_entry, opcsn, "MODRDN");
+ int resolve = urp_annotate_dn (sessionid, existing_entry, opcsn, "MODRDN", txn);
if(!resolve)
{
op_result= LDAP_OPERATIONS_ERROR;
@@ -543,7 +547,7 @@ urp_modrdn_operation( Slapi_PBlock *pb )
bailout:
if ( del_old_replconflict_attr && rc == 0 )
{
- del_replconflict_attr (target_entry, opcsn, 0);
+ del_replconflict_attr (target_entry, opcsn, 0, txn);
}
if ( parentdn )
slapi_sdn_free(&parentdn);
@@ -561,12 +565,14 @@ urp_delete_operation( Slapi_PBlock *pb )
char sessionid[REPL_SESSION_ID_SIZE];
int op_result= 0;
int rc= 0; /* OK */
+ void *txn = NULL;
if ( slapi_op_abandoned(pb) )
{
return rc;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_pblock_get(pb, SLAPI_DELETE_EXISTING_ENTRY, &deleteentry);
if(deleteentry==NULL) /* uniqueid can't be found */
@@ -592,14 +598,14 @@ urp_delete_operation( Slapi_PBlock *pb )
if(!slapi_entry_has_children(deleteentry))
{
/* Remove possible conflict attributes */
- del_replconflict_attr (deleteentry, opcsn, 0);
+ del_replconflict_attr (deleteentry, opcsn, 0, txn);
rc= 0; /* OK, to delete the entry */
PROFILE_POINT; /* Delete Operation; OK. */
}
else
{
/* Turn this entry into a glue_absent_parent entry */
- entry_to_glue(sessionid, deleteentry, REASON_RESURRECT_ENTRY, opcsn);
+ entry_to_glue(sessionid, deleteentry, REASON_RESURRECT_ENTRY, opcsn, txn);
/* Turn the Delete into a No-Op */
op_result= LDAP_SUCCESS;
@@ -712,7 +718,7 @@ urp_post_delete_operation( Slapi_PBlock *pb )
}
int
-urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char *parentuniqueid, CSN *opcsn, int opflags)
+urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char *parentuniqueid, CSN *opcsn, int opflags, void *txn)
{
Slapi_PBlock *newpb;
Slapi_Operation *op;
@@ -743,6 +749,7 @@ urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char *pa
slapi_pblock_get ( newpb, SLAPI_OPERATION, &op );
operation_set_csn ( op, opcsn );
+ slapi_pblock_set ( newpb, SLAPI_TXN, txn );
slapi_add_internal_pb ( newpb );
slapi_pblock_get ( newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result );
slapi_pblock_destroy ( newpb );
@@ -751,7 +758,7 @@ urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char *pa
}
int
-urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags)
+urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags, void *txn)
{
Slapi_PBlock *newpb;
Slapi_Operation *op;
@@ -780,6 +787,7 @@ urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags)
slapi_pblock_get (newpb, SLAPI_OPERATION, &op);
operation_set_csn (op, opcsn);
+ slapi_pblock_set(newpb, SLAPI_TXN, txn);
slapi_modrdn_internal_pb(newpb);
slapi_pblock_get(newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result);
@@ -788,7 +796,7 @@ urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags)
}
int
-urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int opflags)
+urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int opflags, void *txn)
{
Slapi_PBlock *newpb;
Slapi_Operation *op;
@@ -810,6 +818,7 @@ urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int op
slapi_pblock_get ( newpb, SLAPI_OPERATION, &op );
operation_set_csn ( op, opcsn );
+ slapi_pblock_set ( newpb, SLAPI_TXN, txn );
slapi_delete_internal_pb ( newpb );
slapi_pblock_get ( newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result );
slapi_pblock_destroy ( newpb );
@@ -818,7 +827,7 @@ urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int op
}
int
-urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn, Slapi_Mods *smods, int opflags)
+urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn, Slapi_Mods *smods, int opflags, void *txn)
{
Slapi_PBlock *newpb;
Slapi_Operation *op;
@@ -839,6 +848,7 @@ urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn, S
slapi_pblock_get (newpb, SLAPI_OPERATION, &op);
operation_set_csn (op, opcsn);
+ slapi_pblock_set (newpb, SLAPI_TXN, txn);
/* do modify */
slapi_modify_internal_pb (newpb);
slapi_pblock_get (newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result);
@@ -962,7 +972,7 @@ bailout:
* a new entry (the operation entry) see urp_add_operation.
*/
static int
-urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, const char *optype)
+urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, const char *optype, void *txn)
{
int rc = 0; /* Fail */
int op_result;
@@ -978,8 +988,8 @@ urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, const char *op
newrdn = get_rdn_plus_uniqueid ( sessionid, basedn, uniqueid );
if(newrdn!=NULL)
{
- mod_namingconflict_attr (uniqueid, basesdn, basesdn, opcsn);
- op_result = urp_fixup_rename_entry ( entry, newrdn, 0 );
+ mod_namingconflict_attr (uniqueid, basesdn, basesdn, opcsn, txn);
+ op_result = urp_fixup_rename_entry ( entry, newrdn, 0, txn );
switch(op_result)
{
case LDAP_SUCCESS:
@@ -1041,7 +1051,9 @@ urp_get_min_naming_conflict_entry ( Slapi_PBlock *pb, char *sessionid, CSN *opcs
int i = 0;
int min_i = -1;
int op_result = LDAP_SUCCESS;
+ void *txn = NULL;
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
slapi_pblock_get (pb, SLAPI_URP_NAMING_COLLISION_DN, &basedn);
if (NULL == basedn || strncmp (basedn, SLAPI_ATTR_UNIQUEID, strlen(SLAPI_ATTR_UNIQUEID)) == 0)
return NULL;
@@ -1068,6 +1080,7 @@ urp_get_min_naming_conflict_entry ( Slapi_PBlock *pb, char *sessionid, CSN *opcs
NULL, /* UniqueID */
repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION),
0);
+ slapi_pblock_set(newpb, SLAPI_TXN, txn);
slapi_search_internal_pb(newpb);
slapi_pblock_get(newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result);
slapi_pblock_get(newpb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
@@ -1133,6 +1146,9 @@ urp_naming_conflict_removal ( Slapi_PBlock *pb, char *sessionid, CSN *opcsn, con
Slapi_RDN *oldrdn, *newrdn;
const char *oldrdnstr, *newrdnstr;
int op_result;
+ void *txn = NULL;
+
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
/*
* Backend op has set SLAPI_URP_NAMING_COLLISION_DN to the basedn.
@@ -1158,7 +1174,7 @@ urp_naming_conflict_removal ( Slapi_PBlock *pb, char *sessionid, CSN *opcsn, con
* is done after DB lock was released. The backend modrdn
* will acquire the DB lock if it sees this flag.
*/
- op_result = urp_fixup_rename_entry (min_naming_conflict_entry, newrdnstr, OP_FLAG_ACTION_INVOKE_FOR_REPLOP);
+ op_result = urp_fixup_rename_entry (min_naming_conflict_entry, newrdnstr, OP_FLAG_ACTION_INVOKE_FOR_REPLOP, txn);
if ( op_result != LDAP_SUCCESS )
{
slapi_log_error (slapi_log_urp, sessionid,
@@ -1173,7 +1189,7 @@ urp_naming_conflict_removal ( Slapi_PBlock *pb, char *sessionid, CSN *opcsn, con
* A fixup op will not invoke urp_modrdn_operation(). Even it does,
* urp_modrdn_operation() will do nothing because of the same CSN.
*/
- op_result = del_replconflict_attr (min_naming_conflict_entry, opcsn, OP_FLAG_ACTION_INVOKE_FOR_REPLOP);
+ op_result = del_replconflict_attr (min_naming_conflict_entry, opcsn, OP_FLAG_ACTION_INVOKE_FOR_REPLOP, txn);
if (op_result != LDAP_SUCCESS) {
slapi_log_error(SLAPI_LOG_REPL, sessionid,
"Failed to remove nsds5ReplConflict for %s, err=%d\n",
@@ -1277,7 +1293,7 @@ is_suffix_dn ( Slapi_PBlock *pb, const Slapi_DN *dn, Slapi_DN **parentdn )
static int
mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn,
- const Slapi_DN *conflictsdn, CSN *opcsn)
+ const Slapi_DN *conflictsdn, CSN *opcsn, void *txn)
{
Slapi_Mods smods;
char buf[BUFSIZ];
@@ -1300,13 +1316,13 @@ mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn,
*/
slapi_mods_add (&smods, LDAP_MOD_REPLACE, ATTR_NSDS5_REPLCONFLICT, strlen(buf), buf);
}
- op_result = urp_fixup_modify_entry (uniqueid, entrysdn, opcsn, &smods, 0);
+ op_result = urp_fixup_modify_entry (uniqueid, entrysdn, opcsn, &smods, 0, txn);
slapi_mods_done (&smods);
return op_result;
}
static int
-del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags)
+del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags, void *txn)
{
Slapi_Attr *attr;
int op_result = 0;
@@ -1321,7 +1337,7 @@ del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags)
entrysdn = slapi_entry_get_sdn_const (entry);
slapi_mods_init (&smods, 2);
slapi_mods_add (&smods, LDAP_MOD_DELETE, ATTR_NSDS5_REPLCONFLICT, 0, NULL);
- op_result = urp_fixup_modify_entry (uniqueid, entrysdn, opcsn, &smods, opflags);
+ op_result = urp_fixup_modify_entry (uniqueid, entrysdn, opcsn, &smods, opflags, txn);
slapi_mods_done (&smods);
}
return op_result;
diff --git a/ldap/servers/plugins/replication/urp.h b/ldap/servers/plugins/replication/urp.h
index 2ca7ad2c5..77ac8a4f3 100644
--- a/ldap/servers/plugins/replication/urp.h
+++ b/ldap/servers/plugins/replication/urp.h
@@ -57,10 +57,10 @@ int urp_modrdn_operation( Slapi_PBlock *pb );
int urp_post_modrdn_operation( Slapi_PBlock *pb );
/* urp internal ops */
-int urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char *parentuniqueid, CSN *opcsn, int opflags);
-int urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int opflags);
-int urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags);
-int urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn, Slapi_Mods *smods, int opflags);
+int urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char *parentuniqueid, CSN *opcsn, int opflags, void *txn);
+int urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int opflags, void *txn);
+int urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags, void *txn);
+int urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn, Slapi_Mods *smods, int opflags, void *txn);
int is_suffix_dn (Slapi_PBlock *pb, const Slapi_DN *dn, Slapi_DN **parenddn);
@@ -69,7 +69,7 @@ int is_suffix_dn (Slapi_PBlock *pb, const Slapi_DN *dn, Slapi_DN **parenddn);
*/
int is_glue_entry(const Slapi_Entry* entry);
int create_glue_entry ( Slapi_PBlock *pb, char *sessionid, Slapi_DN *dn, const char *uniqueid, CSN *opcsn );
-int entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN *opcsn);
+int entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN *opcsn, void *txn);
int glue_to_entry (Slapi_PBlock *pb, Slapi_Entry *entry );
PRBool get_glue_csn(const Slapi_Entry *entry, const CSN **gluecsn);
diff --git a/ldap/servers/plugins/replication/urp_glue.c b/ldap/servers/plugins/replication/urp_glue.c
index e51712c78..499cb9790 100644
--- a/ldap/servers/plugins/replication/urp_glue.c
+++ b/ldap/servers/plugins/replication/urp_glue.c
@@ -92,7 +92,7 @@ get_glue_csn(const Slapi_Entry *entry, const CSN **gluecsn)
* Submit a Modify operation to turn the Entry into Glue.
*/
int
-entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN *opcsn)
+entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN *opcsn, void *txn)
{
int op_result = 0;
const char *dn;
@@ -135,7 +135,7 @@ entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN
if (slapi_mods_get_num_mods(&smods) > 0)
{
- op_result = urp_fixup_modify_entry (NULL, sdn, opcsn, &smods, 0);
+ op_result = urp_fixup_modify_entry (NULL, sdn, opcsn, &smods, 0, txn);
if (op_result == LDAP_SUCCESS)
{
slapi_log_error (slapi_log_urp, repl_plugin_name,
@@ -158,7 +158,7 @@ static const char *glue_entry =
"%s: %s\n"; /* Add why it's been created */
static int
-do_create_glue_entry(const Slapi_RDN *rdn, const Slapi_DN *superiordn, const char *uniqueid, const char *reason, CSN *opcsn)
+do_create_glue_entry(const Slapi_RDN *rdn, const Slapi_DN *superiordn, const char *uniqueid, const char *reason, CSN *opcsn, void *txn)
{
int op_result= LDAP_OPERATIONS_ERROR;
int rdnval_index = 0;
@@ -202,7 +202,7 @@ do_create_glue_entry(const Slapi_RDN *rdn, const Slapi_DN *superiordn, const cha
if ( e!=NULL )
{
slapi_entry_set_uniqueid (e, slapi_ch_strdup(uniqueid));
- op_result = urp_fixup_add_entry (e, NULL, NULL, opcsn, 0);
+ op_result = urp_fixup_add_entry (e, NULL, NULL, opcsn, 0, txn);
}
slapi_ch_free_string(&estr);
slapi_sdn_free(&sdn);
@@ -214,12 +214,14 @@ create_glue_entry ( Slapi_PBlock *pb, char *sessionid, Slapi_DN *dn, const char
{
int op_result;
const char *dnstr;
+ void *txn = NULL;
if ( slapi_sdn_get_dn (dn) )
dnstr = slapi_sdn_get_dn (dn);
else
dnstr = "";
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if ( NULL == uniqueid )
{
op_result = LDAP_OPERATIONS_ERROR;
@@ -239,7 +241,7 @@ create_glue_entry ( Slapi_PBlock *pb, char *sessionid, Slapi_DN *dn, const char
while(!done)
{
- op_result= do_create_glue_entry(rdn, superiordn, uniqueid, "missingEntry", opcsn);
+ op_result= do_create_glue_entry(rdn, superiordn, uniqueid, "missingEntry", opcsn, txn);
switch(op_result)
{
case LDAP_SUCCESS:
diff --git a/ldap/servers/plugins/replication/urp_tombstone.c b/ldap/servers/plugins/replication/urp_tombstone.c
index 6dd9a2ace..7c3642186 100644
--- a/ldap/servers/plugins/replication/urp_tombstone.c
+++ b/ldap/servers/plugins/replication/urp_tombstone.c
@@ -94,6 +94,10 @@ tombstone_to_glue_resolve_parent (
{
int op_result;
Slapi_PBlock *newpb= slapi_pblock_new();
+ void *txn = NULL;
+
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
+ slapi_pblock_set(newpb, SLAPI_TXN, txn);
slapi_search_internal_set_pb(
newpb,
slapi_sdn_get_dn(parentdn), /* JCM - This DN just identifies the backend to be searched. */
@@ -156,6 +160,7 @@ tombstone_to_glue (
Slapi_Entry *addingentry;
const char *addingdn;
int op_result;
+ void *txn = NULL;
/* JCMREPL
* Nothing logged to the 5.0 Change Log
@@ -189,7 +194,8 @@ tombstone_to_glue (
slapi_entry_add_string(addingentry, ATTR_NSDS5_REPLCONFLICT, reason);
}
tombstoneuniqueid= slapi_entry_get_uniqueid(tombstoneentry);
- op_result = urp_fixup_add_entry (addingentry, tombstoneuniqueid, parentuniqueid, opcsn, OP_FLAG_RESURECT_ENTRY);
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
+ op_result = urp_fixup_add_entry (addingentry, tombstoneuniqueid, parentuniqueid, opcsn, OP_FLAG_RESURECT_ENTRY, txn);
if (op_result == LDAP_SUCCESS)
{
slapi_log_error (slapi_log_urp, repl_plugin_name,
@@ -213,6 +219,7 @@ entry_to_tombstone ( Slapi_PBlock *pb, Slapi_Entry *entry )
CSN *opcsn;
const char *uniqueid;
int op_result = LDAP_SUCCESS;
+ void *txn = NULL;
slapi_pblock_get ( pb, SLAPI_OPERATION, &op );
opcsn = operation_get_csn ( op );
@@ -227,9 +234,10 @@ entry_to_tombstone ( Slapi_PBlock *pb, Slapi_Entry *entry )
*/
slapi_mods_add ( &smods, LDAP_MOD_DELETE, ATTR_NSDS5_REPLCONFLICT, 0, NULL );
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
op_result = urp_fixup_modify_entry (uniqueid,
slapi_entry_get_sdn_const (entry),
- opcsn, &smods, 0);
+ opcsn, &smods, 0, txn);
slapi_mods_done ( &smods );
/*
@@ -242,7 +250,7 @@ entry_to_tombstone ( Slapi_PBlock *pb, Slapi_Entry *entry )
* through the urp operations and trigger the recursive
* fixup if applicable.
*/
- op_result = urp_fixup_delete_entry (uniqueid, slapi_entry_get_dn_const (entry), opcsn, 0);
+ op_result = urp_fixup_delete_entry (uniqueid, slapi_entry_get_dn_const (entry), opcsn, 0, txn);
}
return op_result;
diff --git a/ldap/servers/plugins/retrocl/retrocl_po.c b/ldap/servers/plugins/retrocl/retrocl_po.c
index 29ce79f15..729ffbb50 100644
--- a/ldap/servers/plugins/retrocl/retrocl_po.c
+++ b/ldap/servers/plugins/retrocl/retrocl_po.c
@@ -178,12 +178,15 @@ write_replog_db(
changeNumber changenum;
int i;
int extensibleObject = 0;
+ void *txn = NULL;
if (!dn) {
slapi_log_error( SLAPI_LOG_PLUGIN, RETROCL_PLUGIN_NAME, "write_replog_db: NULL dn\n");
return;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
+
PR_Lock(retrocl_internal_lock);
changenum = retrocl_assign_changenumber();
@@ -361,6 +364,7 @@ write_replog_db(
slapi_add_entry_internal_set_pb( newPb, e, NULL /* controls */,
g_plg_identity[PLUGIN_RETROCL],
0 /* actions */ );
+ slapi_pblock_set (newPb, SLAPI_TXN, txn);
slapi_add_internal_pb (newPb);
slapi_pblock_get( newPb, SLAPI_PLUGIN_INTOP_RESULT, &rc );
slapi_pblock_destroy(newPb);
diff --git a/ldap/servers/plugins/uiduniq/plugin-utils.h b/ldap/servers/plugins/uiduniq/plugin-utils.h
index 5cdd95b64..9c5eeb16e 100644
--- a/ldap/servers/plugins/uiduniq/plugin-utils.h
+++ b/ldap/servers/plugins/uiduniq/plugin-utils.h
@@ -87,10 +87,10 @@
int op_error(int internal_error);
Slapi_PBlock *readPblockAndEntry( const char *baseDN, const char *filter,
- char *attrs[] );
+ char *attrs[], void *txn, void *pluginid );
int entryHasObjectClass(Slapi_PBlock *pb, Slapi_Entry *e,
const char *objectClass);
-Slapi_PBlock *dnHasObjectClass( const char *baseDN, const char *objectClass );
-Slapi_PBlock *dnHasAttribute( const char *baseDN, const char *attrName );
+Slapi_PBlock *dnHasObjectClass( const char *baseDN, const char *objectClass, void *txn, void *pluginid );
+Slapi_PBlock *dnHasAttribute( const char *baseDN, const char *attrName, void *txn, void *pluginid );
#endif /* _PLUGIN_UTILS_H_ */
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index 8bd5e17b0..e1b855c88 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -70,7 +70,7 @@ int ldap_quote_filter_value(
static int search_one_berval(const char *baseDN, const char *attrName,
- const struct berval *value, const char *requiredObjectClass, const char *target);
+ const struct berval *value, const char *requiredObjectClass, const char *target, void *txn);
/*
* ISSUES:
@@ -226,7 +226,7 @@ create_filter(const char *attribute, const struct berval *value, const char *req
static int
search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
struct berval **values, const char *requiredObjectClass,
- const char *target)
+ const char *target, void *txn)
{
int result;
@@ -260,7 +260,7 @@ search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
{
result = search_one_berval(baseDN, attrName,
slapi_value_get_berval(v),
- requiredObjectClass, target);
+ requiredObjectClass, target, txn);
}
}
else
@@ -268,7 +268,7 @@ search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
for (;*values != NULL && LDAP_SUCCESS == result; values++)
{
result = search_one_berval(baseDN, attrName, *values, requiredObjectClass,
- target);
+ target, txn);
}
}
@@ -284,7 +284,7 @@ search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
static int
search_one_berval(const char *baseDN, const char *attrName,
const struct berval *value, const char *requiredObjectClass,
- const char *target)
+ const char *target, void *txn)
{
int result;
char *filter;
@@ -319,6 +319,7 @@ search_one_berval(const char *baseDN, const char *attrName,
slapi_search_internal_set_pb(spb, baseDN, LDAP_SCOPE_SUBTREE,
filter, attrs, 0 /* attrs only */, NULL, NULL, plugin_identity, 0 /* actions */);
+ slapi_pblock_set(spb, SLAPI_TXN, txn);
slapi_search_internal_pb(spb);
err = slapi_pblock_get(spb, SLAPI_PLUGIN_INTOP_RESULT, &sres);
@@ -394,7 +395,7 @@ search_one_berval(const char *baseDN, const char *attrName,
static int
searchAllSubtrees(int argc, char *argv[], const char *attrName,
Slapi_Attr *attr, struct berval **values, const char *requiredObjectClass,
- const char *dn)
+ const char *dn, void *txn)
{
int result = LDAP_SUCCESS;
@@ -409,7 +410,7 @@ searchAllSubtrees(int argc, char *argv[], const char *attrName,
* worry about that here.
*/
if (slapi_dn_issuffix(dn, *argv)) {
- result = search(*argv, attrName, attr, values, requiredObjectClass, dn);
+ result = search(*argv, attrName, attr, values, requiredObjectClass, dn, txn);
if (result) break;
}
}
@@ -499,14 +500,14 @@ getArguments(Slapi_PBlock *pb, char **attrName, char **markerObjectClass,
static int
findSubtreeAndSearch(char *parentDN, const char *attrName, Slapi_Attr *attr,
struct berval **values, const char *requiredObjectClass, const char *target,
- const char *markerObjectClass)
+ const char *markerObjectClass, void *txn)
{
int result = LDAP_SUCCESS;
Slapi_PBlock *spb = NULL;
while (NULL != (parentDN = slapi_dn_parent(parentDN)))
{
- if ((spb = dnHasObjectClass(parentDN, markerObjectClass)))
+ if ((spb = dnHasObjectClass(parentDN, markerObjectClass, txn, plugin_identity)))
{
freePblock(spb);
/*
@@ -514,7 +515,7 @@ findSubtreeAndSearch(char *parentDN, const char *attrName, Slapi_Attr *attr,
* to have the attribute already.
*/
result = search(parentDN, attrName, attr, values, requiredObjectClass,
- target);
+ target, txn);
break;
}
}
@@ -554,6 +555,7 @@ preop_add(Slapi_PBlock *pb)
Slapi_Attr *attr;
int argc;
char **argv = NULL;
+ void *txn = NULL;
/*
* If this is a replication update, just be a noop.
@@ -565,6 +567,7 @@ preop_add(Slapi_PBlock *pb)
break;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/*
* Get the arguments
*/
@@ -631,12 +634,12 @@ preop_add(Slapi_PBlock *pb)
/* Subtree defined by location of marker object class */
result = findSubtreeAndSearch((char *)dn, attrName, attr, NULL,
requiredObjectClass, dn,
- markerObjectClass);
+ markerObjectClass, txn);
} else
{
/* Subtrees listed on invocation line */
result = searchAllSubtrees(argc, argv, attrName, attr, NULL,
- requiredObjectClass, dn);
+ requiredObjectClass, dn, txn);
}
END
@@ -708,6 +711,7 @@ preop_modify(Slapi_PBlock *pb)
int isupdatedn;
int argc;
char **argv = NULL;
+ void *txn = NULL;
/*
* If this is a replication update, just be a noop.
@@ -719,6 +723,7 @@ preop_modify(Slapi_PBlock *pb)
break;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/*
* Get the arguments
*/
@@ -780,7 +785,7 @@ preop_modify(Slapi_PBlock *pb)
* Check if it has the required object class
*/
if (requiredObjectClass &&
- !(spb = dnHasObjectClass(dn, requiredObjectClass))) {
+ !(spb = dnHasObjectClass(dn, requiredObjectClass, txn, plugin_identity))) {
break;
}
@@ -800,12 +805,12 @@ preop_modify(Slapi_PBlock *pb)
/* Subtree defined by location of marker object class */
result = findSubtreeAndSearch((char *)dn, attrName, NULL,
mod->mod_bvalues, requiredObjectClass,
- dn, markerObjectClass);
+ dn, markerObjectClass, txn);
} else
{
/* Subtrees listed on invocation line */
result = searchAllSubtrees(argc, argv, attrName, NULL,
- mod->mod_bvalues, requiredObjectClass, dn);
+ mod->mod_bvalues, requiredObjectClass, dn, txn);
}
}
END
@@ -866,6 +871,7 @@ preop_modrdn(Slapi_PBlock *pb)
Slapi_Attr *attr;
int argc;
char **argv = NULL;
+ void *txn = NULL;
/*
* If this is a replication update, just be a noop.
@@ -877,6 +883,7 @@ preop_modrdn(Slapi_PBlock *pb)
break;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/*
* Get the arguments
*/
@@ -935,7 +942,7 @@ preop_modrdn(Slapi_PBlock *pb)
/* Get the entry that is being renamed so we can make a dummy copy
* of what it will look like after the rename. */
- err = slapi_search_internal_get_entry(sdn, NULL, &e, plugin_identity);
+ err = slapi_search_internal_get_entry_ext(sdn, NULL, &e, plugin_identity, txn);
if (err != LDAP_SUCCESS) {
result = uid_op_error(35);
/* We want to return a no such object error if the target doesn't exist. */
@@ -971,12 +978,12 @@ preop_modrdn(Slapi_PBlock *pb)
/* Subtree defined by location of marker object class */
result = findSubtreeAndSearch(slapi_entry_get_dn(e), attrName, attr, NULL,
requiredObjectClass, dn,
- markerObjectClass);
+ markerObjectClass, txn);
} else
{
/* Subtrees listed on invocation line */
result = searchAllSubtrees(argc, argv, attrName, attr, NULL,
- requiredObjectClass, dn);
+ requiredObjectClass, dn, txn);
}
END
/* Clean-up */
diff --git a/ldap/servers/plugins/uiduniq/utils.c b/ldap/servers/plugins/uiduniq/utils.c
index 49660897b..567218a3b 100644
--- a/ldap/servers/plugins/uiduniq/utils.c
+++ b/ldap/servers/plugins/uiduniq/utils.c
@@ -82,19 +82,22 @@ op_error(int internal_error) {
*/
Slapi_PBlock *
readPblockAndEntry( const char *baseDN, const char *filter,
- char *attrs[] ) {
+ char *attrs[], void *txn, void *pluginid ) {
Slapi_PBlock *spb = NULL;
BEGIN
int sres;
- /* Perform the search - the new pblock needs to be freed */
- spb = slapi_search_internal((char *)baseDN, LDAP_SCOPE_BASE,
- (char *)filter, NULL, attrs, 0);
- if ( !spb ) {
+ spb = slapi_pblock_new();
+ if (!spb) {
op_error(20);
break;
}
+ slapi_search_internal_set_pb (spb, baseDN, LDAP_SCOPE_BASE, filter,
+ attrs, 0, NULL,
+ NULL, pluginid, 0);
+ slapi_pblock_set(spb, SLAPI_TXN, txn);
+ slapi_search_internal_pb (spb);
if ( slapi_pblock_get( spb, SLAPI_PLUGIN_INTOP_RESULT, &sres ) ) {
op_error(21);
@@ -150,7 +153,7 @@ entryHasObjectClass(Slapi_PBlock *pb, Slapi_Entry *e,
* A pblock containing the entry, or NULL
*/
Slapi_PBlock *
-dnHasObjectClass( const char *baseDN, const char *objectClass ) {
+dnHasObjectClass( const char *baseDN, const char *objectClass, void *txn, void *pluginid ) {
char *filter = NULL;
Slapi_PBlock *spb = NULL;
@@ -162,7 +165,7 @@ dnHasObjectClass( const char *baseDN, const char *objectClass ) {
attrs[0] = "objectclass";
attrs[1] = NULL;
filter = PR_smprintf("objectclass=%s", objectClass );
- if ( !(spb = readPblockAndEntry( baseDN, filter, attrs) ) ) {
+ if ( !(spb = readPblockAndEntry( baseDN, filter, attrs, txn, pluginid ) ) ) {
break;
}
@@ -196,7 +199,7 @@ dnHasObjectClass( const char *baseDN, const char *objectClass ) {
* The entry, or NULL
*/
Slapi_PBlock *
-dnHasAttribute( const char *baseDN, const char *attrName ) {
+dnHasAttribute( const char *baseDN, const char *attrName, void *txn, void *pluginid ) {
Slapi_PBlock *spb = NULL;
char *filter = NULL;
@@ -209,12 +212,16 @@ dnHasAttribute( const char *baseDN, const char *attrName ) {
attrs[0] = (char *)attrName;
attrs[1] = NULL;
filter = PR_smprintf( "%s=*", attrName );
- spb = slapi_search_internal((char *)baseDN, LDAP_SCOPE_BASE,
- filter, NULL, attrs, 0);
- if ( !spb ) {
+ spb = slapi_pblock_new();
+ if (!spb) {
op_error(20);
break;
}
+ slapi_search_internal_set_pb (spb, baseDN, LDAP_SCOPE_BASE, filter,
+ attrs, 0, NULL,
+ NULL, pluginid, 0);
+ slapi_pblock_set(spb, SLAPI_TXN, txn);
+ slapi_search_internal_pb (spb);
if ( slapi_pblock_get( spb, SLAPI_PLUGIN_INTOP_RESULT, &sres ) ) {
op_error(21);
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index a0af0064b..e872f3590 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -1013,6 +1013,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod *mod, char **old
char *proxydn = NULL;
char *proxystr = NULL;
char *errtext = NULL;
+ void *txn = NULL;
slapi_pblock_get (pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op);
if (repl_op) {
@@ -1027,6 +1028,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod *mod, char **old
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
slapi_pblock_get (pb, SLAPI_PWPOLICY, &pwresponse_req);
internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL);
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
slapi_sdn_init_dn_byref (&sdn, dn);
pwpolicy = new_passwdPolicy(pb, (char *)slapi_sdn_get_ndn(&sdn));
@@ -1056,7 +1058,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod *mod, char **old
mods[1] = NULL;
/* We need to actually fetch the target here to use for ACI checking. */
- slapi_search_internal_get_entry(&sdn, NULL, &e, (void *)plugin_get_default_component_id());
+ slapi_search_internal_get_entry_ext(&sdn, NULL, &e, (void *)plugin_get_default_component_id(), txn);
/* Create a bogus entry with just the target dn if we were unable to
* find the actual entry. This will only be used for checking the ACIs. */
diff --git a/ldap/servers/slapd/passwd_extop.c b/ldap/servers/slapd/passwd_extop.c
index c77d3b70e..c05dd81e9 100644
--- a/ldap/servers/slapd/passwd_extop.c
+++ b/ldap/servers/slapd/passwd_extop.c
@@ -153,6 +153,7 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn, Slapi_Mods *mods,
LDAPControl **req_controls_copy = NULL;
LDAPControl **pb_resp_controls = NULL;
int ret=0;
+ void *txn = NULL;
LDAPDebug( LDAP_DEBUG_TRACE, "=> passwd_apply_mods\n", 0, 0, 0 );
@@ -179,6 +180,9 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn, Slapi_Mods *mods,
* that it was done by the root DN. */
pb.pb_conn = pb_orig->pb_conn;
+ slapi_pblock_get(pb_orig, SLAPI_TXN, &txn);
+ slapi_pblock_set(&pb, SLAPI_TXN, txn);
+
ret =slapi_modify_internal_pb (&pb);
/* We now clean up the connection that we copied into the
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index da58f9bee..971487123 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -862,6 +862,7 @@ void pw_add_allowchange_aci(Slapi_Entry *e, int pw_prohibit_change);
*/
int update_pw_retry ( Slapi_PBlock *pb );
void pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods);
+void pw_apply_mods_ext(const Slapi_DN *sdn, Slapi_Mods *mods, void *txn);
void pw_set_componentID(struct slapi_componentid * cid);
struct slapi_componentid * pw_get_componentID();
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index ed8d2c886..58fce2897 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -593,7 +593,9 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) {
passwdPolicy *pwpolicy = NULL;
int internal_op = 0;
Slapi_Operation *operation = NULL;
+ void *txn = NULL;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_pblock_get(pb, SLAPI_OPERATION, &operation);
internal_op = slapi_operation_is_flag_set(operation, SLAPI_OP_FLAG_INTERNAL);
@@ -666,7 +668,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) {
} else if (prev_exp_date == SLAPD_END_TIME) {
/* Special entries' passwords never expire */
slapi_ch_free((void**)&prev_exp_date_str);
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
return 0;
@@ -683,7 +685,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) {
*/
pw_exp_date = NOT_FIRST_TIME;
} else {
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
return 0;
@@ -697,7 +699,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) {
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpWarned", "0");
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
if (pb->pb_conn) { /* no conn for internal op */
/* reset c_needpw to 0 */
@@ -1080,6 +1082,7 @@ update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw )
char *str;
passwdPolicy *pwpolicy = NULL;
const char *dn = slapi_sdn_get_dn(sdn);
+ void *txn = NULL;
pwpolicy = new_passwdPolicy(pb, dn);
@@ -1138,8 +1141,10 @@ update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw )
list_of_mods[1] = NULL;
pblock_init(&mod_pb);
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_modify_internal_set_pb_ext(&mod_pb, sdn, list_of_mods, NULL, NULL,
pw_get_componentID(), 0);
+ slapi_pblock_set(&mod_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(&mod_pb);
slapi_pblock_get(&mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
if (res != LDAP_SUCCESS){
diff --git a/ldap/servers/slapd/pw_mgmt.c b/ldap/servers/slapd/pw_mgmt.c
index 8d9987972..28b0491bc 100644
--- a/ldap/servers/slapd/pw_mgmt.c
+++ b/ldap/servers/slapd/pw_mgmt.c
@@ -67,7 +67,9 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int pwresponse_req )
passwdPolicy *pwpolicy = NULL;
int pwdGraceUserTime = 0;
char graceUserTime[8];
+ void *txn = NULL;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_mods_init (&smods, 0);
sdn = slapi_entry_get_sdn_const( e );
dn = slapi_entry_get_ndn( e );
@@ -102,9 +104,9 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int pwresponse_req )
slapi_ch_free((void **)×tring);
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpWarned", "0");
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
} else if (pwpolicy->pw_lockout == 1) {
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
}
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
@@ -150,7 +152,7 @@ skip:
}
slapi_add_pwd_control ( pb, LDAP_CONTROL_PWEXPIRED, 0);
}
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
return ( 0 );
@@ -173,7 +175,7 @@ skip:
sprintf ( graceUserTime, "%d", pwdGraceUserTime );
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE,
"passwordGraceUserTime", graceUserTime);
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
if (pwresponse_req) {
/* check for "changeafterreset" condition */
@@ -216,7 +218,7 @@ skip:
pb->pb_op->o_opid, SLAPD_DISCONNECT_UNBIND, 0);
}
/* Apply current modifications */
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
return (-1);
@@ -263,7 +265,7 @@ skip:
*t = (long)diff_t; /* jcm: had to cast double to long */
}
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
if (pwresponse_req) {
/* check for "changeafterreset" condition */
@@ -283,7 +285,7 @@ skip:
return (2);
}
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
/* Leftover from "changeafterreset" condition */
if (pb->pb_conn->c_needpw == 1) {
diff --git a/ldap/servers/slapd/pw_retry.c b/ldap/servers/slapd/pw_retry.c
index 524462290..48849fbd3 100644
--- a/ldap/servers/slapd/pw_retry.c
+++ b/ldap/servers/slapd/pw_retry.c
@@ -130,7 +130,9 @@ void set_retry_cnt_and_time ( Slapi_PBlock *pb, int count, time_t cur_time ) {
time_t reset_time;
char *timestr;
passwdPolicy *pwpolicy = NULL;
+ void *txn = NULL;
+ slapi_pblock_get( pb, SLAPI_TXN, &txn );
slapi_pblock_get( pb, SLAPI_TARGET_SDN, &sdn );
dn = slapi_sdn_get_dn(sdn);
pwpolicy = new_passwdPolicy(pb, dn);
@@ -146,7 +148,7 @@ void set_retry_cnt_and_time ( Slapi_PBlock *pb, int count, time_t cur_time ) {
set_retry_cnt_mods(pb, &smods, count);
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
}
@@ -193,11 +195,13 @@ void set_retry_cnt ( Slapi_PBlock *pb, int count)
{
Slapi_DN *sdn = NULL;
Slapi_Mods smods;
-
+ void *txn = NULL;
+
+ slapi_pblock_get( pb, SLAPI_TXN, &txn );
slapi_pblock_get( pb, SLAPI_TARGET_SDN, &sdn );
slapi_mods_init(&smods, 0);
set_retry_cnt_mods(pb, &smods, count);
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
}
@@ -208,6 +212,7 @@ Slapi_Entry *get_entry ( Slapi_PBlock *pb, const char *dn)
Slapi_Entry *retentry = NULL;
Slapi_DN *target_sdn = NULL;
Slapi_DN sdn;
+ void *txn = NULL;
if (NULL == pb) {
LDAPDebug(LDAP_DEBUG_ANY, "get_entry - no pblock specified.\n",
@@ -216,6 +221,7 @@ Slapi_Entry *get_entry ( Slapi_PBlock *pb, const char *dn)
}
slapi_pblock_get( pb, SLAPI_TARGET_SDN, &target_sdn );
+ slapi_pblock_get( pb, SLAPI_TXN, &txn );
if (dn == NULL) {
dn = slapi_sdn_get_dn(target_sdn);
@@ -232,9 +238,9 @@ Slapi_Entry *get_entry ( Slapi_PBlock *pb, const char *dn)
target_sdn = &sdn;
}
- search_result = slapi_search_internal_get_entry(target_sdn, NULL,
- &retentry,
- pw_get_componentID());
+ search_result = slapi_search_internal_get_entry_ext(target_sdn, NULL,
+ &retentry,
+ pw_get_componentID(), txn);
if (search_result != LDAP_SUCCESS) {
LDAPDebug (LDAP_DEBUG_TRACE, "WARNING: 'get_entry' can't find entry '%s', err %d\n", dn, search_result, 0);
}
@@ -244,7 +250,7 @@ bail:
}
void
-pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
+pw_apply_mods_ext(const Slapi_DN *sdn, Slapi_Mods *mods, void *txn)
{
Slapi_PBlock pb;
int res;
@@ -260,6 +266,7 @@ pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
NULL, /* UniqueID */
pw_get_componentID(), /* PluginID */
OP_FLAG_SKIP_MODIFIED_ATTRS); /* Flags */
+ slapi_pblock_set(&pb, SLAPI_TXN, txn);
slapi_modify_internal_pb (&pb);
slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
@@ -275,6 +282,11 @@ pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
return;
}
+void
+pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
+{
+ pw_apply_mods_ext(sdn, mods, NULL);
+}
/* Handle the component ID for the password policy */
static struct slapi_componentid * pw_componentid = NULL;
| 0 |
54b544231036a1ae713ef30b71f9b3cfc63ce7a2
|
389ds/389-ds-base
|
Issue 4360 - password policy max sequence sets is not working as expected
Description: password max sequence sets: "123--123" are not being correctly
detected. This is due to an uninitialized char array
Relates: https://github.com/389ds/389-ds-base/issues/4360
Reviewed by: mreynolds (one line commit rule)
|
commit 54b544231036a1ae713ef30b71f9b3cfc63ce7a2
Author: Mark Reynolds <[email protected]>
Date: Tue Oct 6 10:17:37 2020 -0400
Issue 4360 - password policy max sequence sets is not working as expected
Description: password max sequence sets: "123--123" are not being correctly
detected. This is due to an uninitialized char array
Relates: https://github.com/389ds/389-ds-base/issues/4360
Reviewed by: mreynolds (one line commit rule)
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index b6c2c89a3..d0c86949c 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -873,7 +873,7 @@ pw_sequence_sets(const char *new, int32_t max_seq, int check_sets)
if (check_sets) {
/* remember this seq, can call pw_sequence on remaining password */
char *remaining = slapi_ch_smprintf("%s", new + i);
- char token[11];
+ char token[11] = {0};
memcpy(token, new + (i - max_seq), max_seq);
if (strstr(remaining, token)) {
| 0 |
89081d1f702275c588db62da180b790bcab6b529
|
389ds/389-ds-base
|
Issue: 50446 - NameError: name 'ds_is_older' is not defined
Bug description: ds_is_older module is not imported in account.py
that's why enroll_certificate function is not working.
Fixes: https://pagure.io/389-ds-base/issue/50446
Author: aborah
Reviewed by: Simon Pichugin
|
commit 89081d1f702275c588db62da180b790bcab6b529
Author: Anuj Borah <[email protected]>
Date: Mon Jun 17 14:33:12 2019 +0530
Issue: 50446 - NameError: name 'ds_is_older' is not defined
Bug description: ds_is_older module is not imported in account.py
that's why enroll_certificate function is not working.
Fixes: https://pagure.io/389-ds-base/issue/50446
Author: aborah
Reviewed by: Simon Pichugin
diff --git a/src/lib389/lib389/idm/account.py b/src/lib389/lib389/idm/account.py
index 4bd6f6b8b..4a5c5c459 100644
--- a/src/lib389/lib389/idm/account.py
+++ b/src/lib389/lib389/idm/account.py
@@ -8,6 +8,7 @@
from lib389._mapped_object import DSLdapObject, DSLdapObjects, _gen_or, _gen_filter, _term_gen
from lib389._constants import SER_ROOT_DN, SER_ROOT_PW
+from lib389.utils import ds_is_older
import os
import subprocess
| 0 |
6ea27bfcd0f3c305b4feabc4f5d90df5c355a893
|
389ds/389-ds-base
|
Ticket 48707 - Draft Ldap SSO Token proposal
Description: This is the first revision of the Draft of LDAP SSO Sasl mech
we would like to design and add to DS.
Additionally, this provides the structure and make file to allow easier drafting
and implementation of further rfc topics.
https://fedorahosted.org/389/ticket/48707
Author: wibrown
Review by: mreynolds (Thanks!)
|
commit 6ea27bfcd0f3c305b4feabc4f5d90df5c355a893
Author: William Brown <[email protected]>
Date: Tue Feb 16 15:28:17 2016 +1000
Ticket 48707 - Draft Ldap SSO Token proposal
Description: This is the first revision of the Draft of LDAP SSO Sasl mech
we would like to design and add to DS.
Additionally, this provides the structure and make file to allow easier drafting
and implementation of further rfc topics.
https://fedorahosted.org/389/ticket/48707
Author: wibrown
Review by: mreynolds (Thanks!)
diff --git a/rfcs/Makefile b/rfcs/Makefile
new file mode 100644
index 000000000..e868d38fa
--- /dev/null
+++ b/rfcs/Makefile
@@ -0,0 +1,13 @@
+
+allrfcs: folders examplerfcs draft-wibrown-ldapssotoken-00
+
+folders:
+ mkdir -p txt
+
+examplerfcs:
+ xml2rfc examples/template-bare-06.txt -o txt/template-bare-06.txt --text
+
+draft-wibrown-ldapssotoken-00:
+ xml2rfc src/draft-wibrown-ldapssotoken-00.xml -o txt/draft-wibrown-ldapssotoken-00.txt --text
+ xml2rfc src/draft-wibrown-ldapssotoken-00.xml -o txt/draft-wibrown-ldapssotoken-00.raw --raw
+
diff --git a/rfcs/examples/template-bare-06.txt b/rfcs/examples/template-bare-06.txt
new file mode 100644
index 000000000..49aa691eb
--- /dev/null
+++ b/rfcs/examples/template-bare-06.txt
@@ -0,0 +1,426 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!-- This template is for creating an Internet Draft using xml2rfc,
+ which is available here: http://xml.resource.org. -->
+<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
+<!-- One method to get references from the online citation libraries.
+ There has to be one entity for each item to be referenced.
+ An alternate method (rfc include) is described in the references. -->
+
+<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
+<!ENTITY RFC2629 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2629.xml">
+<!ENTITY RFC3552 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3552.xml">
+<!ENTITY RFC5226 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5226.xml">
+]>
+<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
+<!-- used by XSLT processors -->
+<!-- For a complete list and description of processing instructions (PIs),
+ please see http://xml.resource.org/authoring/README.html. -->
+<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
+ (Here they are set differently than their defaults in xml2rfc v1.32) -->
+<?rfc strict="yes" ?>
+<!-- give errors regarding ID-nits and DTD validation -->
+<!-- control the table of contents (ToC) -->
+<?rfc toc="yes"?>
+<!-- generate a ToC -->
+<?rfc tocdepth="4"?>
+<!-- the number of levels of subsections in ToC. default: 3 -->
+<!-- control references -->
+<?rfc symrefs="yes"?>
+<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
+<?rfc sortrefs="yes" ?>
+<!-- sort the reference entries alphabetically -->
+<!-- control vertical white space
+ (using these PIs as follows is recommended by the RFC Editor) -->
+<?rfc compact="yes" ?>
+<!-- do not start each main section on a new page -->
+<?rfc subcompact="no" ?>
+<!-- keep one blank line between list items -->
+<!-- end of list of popular I-D processing instructions -->
+<rfc category="info" docName="draft-ietf-xml2rfc-template-06" ipr="trust200902">
+ <!-- category values: std, bcp, info, exp, and historic
+ ipr values: trust200902, noModificationTrust200902, noDerivativesTrust200902,
+ or pre5378Trust200902
+ you can add the attributes updates="NNNN" and obsoletes="NNNN"
+ they will automatically be output with "(if approved)" -->
+
+ <!-- ***** FRONT MATTER ***** -->
+
+ <front>
+ <!-- The abbreviated title is used in the page header - it is only necessary if the
+ full title is longer than 39 characters -->
+
+ <title abbrev="Abbreviated Title">Put Your Internet Draft Title
+ Here</title>
+
+ <!-- add 'role="editor"' below for the editors if appropriate -->
+
+ <!-- Another author who claims to be an editor -->
+
+ <author fullname="Elwyn Davies" initials="E.B." role="editor"
+ surname="Davies">
+ <organization>Folly Consulting</organization>
+
+ <address>
+ <postal>
+ <street></street>
+
+ <!-- Reorder these if your country does things differently -->
+
+ <city>Soham</city>
+
+ <region></region>
+
+ <code></code>
+
+ <country>UK</country>
+ </postal>
+
+ <phone>+44 7889 488 335</phone>
+
+ <email>[email protected]</email>
+
+ <!-- uri and facsimile elements may also be added -->
+ </address>
+ </author>
+
+ <date year="2010" />
+
+ <!-- If the month and year are both specified and are the current ones, xml2rfc will fill
+ in the current day for you. If only the current year is specified, xml2rfc will fill
+ in the current day and month for you. If the year is not the current one, it is
+ necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the
+ purpose of calculating the expiry date). With drafts it is normally sufficient to
+ specify just the year. -->
+
+ <!-- Meta-data Declarations -->
+
+ <area>General</area>
+
+ <workgroup>Internet Engineering Task Force</workgroup>
+
+ <!-- WG name at the upperleft corner of the doc,
+ IETF is fine for individual submissions.
+ If this element is not present, the default is "Network Working Group",
+ which is used by the RFC Editor as a nod to the history of the IETF. -->
+
+ <keyword>template</keyword>
+
+ <!-- Keywords will be incorporated into HTML output
+ files in a meta tag but they have no effect on text or nroff
+ output. If you submit your draft to the RFC Editor, the
+ keywords will be used for the search engine. -->
+
+ <abstract>
+ <t>Insert an abstract: MANDATORY. This template is for creating an
+ Internet Draft.</t>
+ </abstract>
+ </front>
+
+ <middle>
+ <section title="Introduction">
+ <t>The original specification of xml2rfc format is in <xref
+ target="RFC2629">RFC 2629</xref>.</t>
+
+ <section title="Requirements Language">
+ <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
+ "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
+ document are to be interpreted as described in <xref
+ target="RFC2119">RFC 2119</xref>.</t>
+ </section>
+ </section>
+
+ <section anchor="simple_list" title="Simple List">
+ <t>List styles: 'empty', 'symbols', 'letters', 'numbers', 'hanging',
+ 'format'.</t>
+
+ <t><list style="symbols">
+ <t>First bullet</t>
+
+ <t>Second bullet</t>
+ </list> You can write text here as well.</t>
+ </section>
+
+ <section title="Figures">
+ <t>Figures should not exceed 69 characters wide to allow for the indent
+ of sections.</t>
+
+ <figure align="center" anchor="xml_happy">
+ <preamble>Preamble text - can be omitted or empty.</preamble>
+
+ <artwork align="left"><![CDATA[
++-----------------------+
+| Use XML, be Happy :-) |
+|_______________________|
+ ]]></artwork>
+
+ <postamble>Cross-references allowed in pre- and postamble. <xref
+ target="min_ref" />.</postamble>
+ </figure>
+
+ <t>The CDATA means you don't need to escape meta-characters (especially
+ < (&lt;) and & (&amp;)) but is not essential.
+ Figures may also have a title attribute but it won't be displayed unless
+ there is also an anchor. White space, both horizontal and vertical, is
+ significant in figures even if you don't use CDATA.</t>
+ </section>
+
+ <!-- This PI places the pagebreak correctly (before the section title) in the text output. -->
+
+ <?rfc needLines="8" ?>
+
+ <section title="Subsections and Tables">
+ <section title="A Subsection">
+ <t>By default 3 levels of nesting show in table of contents but that
+ can be adjusted with the value of the "tocdepth" processing
+ instruction.</t>
+ </section>
+
+ <section title="Tables">
+ <t>.. are very similar to figures:</t>
+
+ <texttable anchor="table_example" title="A Very Simple Table">
+ <preamble>Tables use ttcol to define column headers and widths.
+ Every cell then has a "c" element for its content.</preamble>
+
+ <ttcol align="center">ttcol #1</ttcol>
+
+ <ttcol align="center">ttcol #2</ttcol>
+
+ <c>c #1</c>
+
+ <c>c #2</c>
+
+ <c>c #3</c>
+
+ <c>c #4</c>
+
+ <c>c #5</c>
+
+ <c>c #6</c>
+
+ <postamble>which is a very simple example.</postamble>
+ </texttable>
+ </section>
+ </section>
+
+ <section anchor="nested_lists" title="More about Lists">
+ <t>Lists with 'hanging labels': the list item is indented the amount of
+ the hangIndent: <list hangIndent="8" style="hanging">
+ <t hangText="short">With a label shorter than the hangIndent.</t>
+
+ <t hangText="fantastically long label">With a label longer than the
+ hangIndent.</t>
+
+ <t hangText="vspace_trick"><vspace blankLines="0" />Forces the new
+ item to start on a new line.</t>
+ </list></t>
+
+ <!-- It would be nice to see the next piece (12 lines) all on one page. -->
+
+ <?rfc needLines="12" ?>
+
+ <t>Simulating more than one paragraph in a list item using
+ <vspace>: <list style="letters">
+ <t>First, a short item.</t>
+
+ <t>Second, a longer list item.<vspace blankLines="1" /> And
+ something that looks like a separate pararaph..</t>
+ </list></t>
+
+ <t>Simple indented paragraph using the "empty" style: <list
+ hangIndent="10" style="empty">
+ <t>The quick, brown fox jumped over the lazy dog and lived to fool
+ many another hunter in the great wood in the west.</t>
+ </list></t>
+
+ <section title="Numbering Lists across Lists and Sections">
+ <t>Numbering items continuously although they are in separate
+ <list> elements, maybe in separate sections using the "format"
+ style and a "counter" variable.</t>
+
+ <t>First list: <list counter="reqs" hangIndent="4" style="format R%d">
+ <t>#1</t>
+
+ <t>#2</t>
+
+ <t>#3</t>
+ </list> Specify the indent explicitly so that all the items line up
+ nicely.</t>
+
+ <t>Second list: <list counter="reqs" hangIndent="4" style="format R%d">
+ <t>#4</t>
+
+ <t>#5</t>
+
+ <t>#6</t>
+ </list></t>
+ </section>
+
+ <section title="Where the List Numbering Continues">
+ <t>List continues here.</t>
+
+ <t>Third list: <list counter="reqs" hangIndent="4" style="format R%d">
+ <t>#7</t>
+
+ <t>#8</t>
+
+ <t>#9</t>
+
+ <t>#10</t>
+ </list> The end of the list.</t>
+ </section>
+ </section>
+
+ <section anchor="codeExample"
+ title="Example of Code or MIB Module To Be Extracted">
+ <figure>
+ <preamble>The <artwork> element has a number of extra attributes
+ that can be used to substitute a more aesthetically pleasing rendition
+ into HTML output while continuing to use the ASCII art version in the
+ text and nroff outputs (see the xml2rfc README for details). It also
+ has a "type" attribute. This is currently ignored except in the case
+ 'type="abnf"'. In this case the "artwork" is expected to contain a
+ piece of valid Augmented Backus-Naur Format (ABNF) grammar. This will
+ be syntax checked by xml2rfc and any errors will cause a fatal error
+ if the "strict" processing instruction is set to "yes". The ABNF will
+ also be colorized in HTML output to highlight the syntactic
+ components. Checking of additional "types" may be provided in future
+ versions of xml2rfc.</preamble>
+
+ <artwork><![CDATA[
+
+/**** an example C program */
+
+#include <stdio.h>
+
+void
+main(int argc, char *argv[])
+{
+ int i;
+
+ printf("program arguments are:\n");
+ for (i = 0; i < argc; i++) {
+ printf("%d: \"%s\"\n", i, argv[i]);
+ }
+
+ exit(0);
+} /* main */
+
+/* end of file */
+
+ ]]></artwork>
+ </figure>
+ </section>
+
+ <section anchor="Acknowledgements" title="Acknowledgements">
+ <t>This template was derived from an initial version written by Pekka
+ Savola and contributed by him to the xml2rfc project.</t>
+
+ <t>This document is part of a plan to make xml2rfc indispensable <xref
+ target="DOMINATION"></xref>.</t>
+ </section>
+
+ <!-- Possibly a 'Contributors' section ... -->
+
+ <section anchor="IANA" title="IANA Considerations">
+ <t>This memo includes no request to IANA.</t>
+
+ <t>All drafts are required to have an IANA considerations section (see
+ <xref target="RFC5226">Guidelines for Writing an IANA Considerations Section in RFCs</xref> for a guide). If the draft does not require IANA to do
+ anything, the section contains an explicit statement that this is the
+ case (as above). If there are no requirements for IANA, the section will
+ be removed during conversion into an RFC by the RFC Editor.</t>
+ </section>
+
+ <section anchor="Security" title="Security Considerations">
+ <t>All drafts are required to have a security considerations section.
+ See <xref target="RFC3552">RFC 3552</xref> for a guide.</t>
+ </section>
+ </middle>
+
+ <!-- *****BACK MATTER ***** -->
+
+ <back>
+ <!-- References split into informative and normative -->
+
+ <!-- There are 2 ways to insert reference entries from the citation libraries:
+ 1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
+ 2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
+ (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")
+
+ Both are cited textually in the same manner: by using xref elements.
+ If you use the PI option, xml2rfc will, by default, try to find included files in the same
+ directory as the including file. You can also define the XML_LIBRARY environment variable
+ with a value containing a set of directories to search. These can be either in the local
+ filing system or remote ones accessed by http (http://domain/dir/... ).-->
+
+ <references title="Normative References">
+ <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->
+ &RFC2119;
+
+ <reference anchor="min_ref">
+ <!-- the following is the minimum to make xml2rfc happy -->
+
+ <front>
+ <title>Minimal Reference</title>
+
+ <author initials="authInitials" surname="authSurName">
+ <organization></organization>
+ </author>
+
+ <date year="2006" />
+ </front>
+ </reference>
+ </references>
+
+ <references title="Informative References">
+ <!-- Here we use entities that we defined at the beginning. -->
+
+ &RFC2629;
+
+ &RFC3552;
+
+ &RFC5226;
+
+ <!-- A reference written by by an organization not a person. -->
+
+ <reference anchor="DOMINATION"
+ target="http://www.example.com/dominator.html">
+ <front>
+ <title>Ultimate Plan for Taking Over the World</title>
+
+ <author>
+ <organization>Mad Dominators, Inc.</organization>
+ </author>
+
+ <date year="1984" />
+ </front>
+ </reference>
+ </references>
+
+ <section anchor="app-additional" title="Additional Stuff">
+ <t>This becomes an Appendix.</t>
+ </section>
+
+ <!-- Change Log
+
+v00 2006-03-15 EBD Initial version
+
+v01 2006-04-03 EBD Moved PI location back to position 1 -
+ v3.1 of XMLmind is better with them at this location.
+v02 2007-03-07 AH removed extraneous nested_list attribute,
+ other minor corrections
+v03 2007-03-09 EBD Added comments on null IANA sections and fixed heading capitalization.
+ Modified comments around figure to reflect non-implementation of
+ figure indent control. Put in reference using anchor="DOMINATION".
+ Fixed up the date specification comments to reflect current truth.
+v04 2007-03-09 AH Major changes: shortened discussion of PIs,
+ added discussion of rfc include.
+v05 2007-03-10 EBD Added preamble to C program example to tell about ABNF and alternative
+ images. Removed meta-characters from comments (causes problems).
+
+v06 2010-04-01 TT Changed ipr attribute values to latest ones. Changed date to
+ year only, to be consistent with the comments. Updated the
+ IANA guidelines reference from the I-D to the finished RFC. -->
+ </back>
+</rfc>
diff --git a/rfcs/src/draft-wibrown-ldapssotoken-00.xml b/rfcs/src/draft-wibrown-ldapssotoken-00.xml
new file mode 100644
index 000000000..c503744d1
--- /dev/null
+++ b/rfcs/src/draft-wibrown-ldapssotoken-00.xml
@@ -0,0 +1,441 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
+
+<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
+<!ENTITY RFC2222 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2222.xml">
+<!ENTITY RFC4511 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4511.xml">
+]>
+
+<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
+
+<?rfc strict="yes" ?>
+<?rfc toc="yes"?>
+<?rfc tocdepth="4"?>
+<?rfc symrefs="yes"?>
+<?rfc sortrefs="yes" ?>
+<?rfc compact="yes" ?>
+<?rfc subcompact="no" ?>
+<rfc category="std" docName="draft-wibrown-ldapssotoken-01" ipr="trust200902">
+
+<front>
+
+ <title abbrev="LDAP SSO Token">Draft LDAP Single Sign On Token Processing</title>
+
+
+ <author fullname="William Brown" initials="W.B." surname="Brown">
+ <organization>Red Hat Asia-Pacific Pty Ltd</organization>
+
+ <address>
+ <postal>
+ <street>Level 1, 193 North Quay</street>
+ <city>Brisbane</city>
+ <code>4000</code>
+ <region>Queensland</region>
+ <country>AU</country>
+ </postal>
+
+ <phone></phone>
+
+ <email>[email protected]</email>
+
+ <!-- uri and facsimile elements may also be added -->
+ </address>
+ </author>
+
+ <author fullname="Simo Sorce" initials="S.S." surname="Sorce" role="editor">
+ <organization>Red Hat, Inc.</organization>
+
+ <address>
+ <postal>
+ <street></street>
+
+ <city></city>
+
+ <region></region>
+
+ <code></code>
+
+ <country></country>
+ </postal>
+
+ <phone></phone>
+
+ <email>[email protected]</email>
+
+ <!-- uri and facsimile elements may also be added -->
+ </address>
+ </author>
+
+ <author fullname="Kieran Andrews" initials="K.A." surname="Andrews" role="editor">
+ <organization>The University of Adelaide</organization>
+
+ <address>
+ <postal>
+ <street></street>
+
+ <city>Adelaide</city>
+
+ <region>South Australia</region>
+
+ <code>5005</code>
+
+ <country>AU</country>
+ </postal>
+
+ <phone></phone>
+
+ <email>[email protected]</email>
+
+ <!-- uri and facsimile elements may also be added -->
+ </address>
+ </author>
+
+ <date year="2016"></date>
+
+
+ <area>General</area>
+
+ <workgroup>Internet Engineering Task Force</workgroup>
+
+ <!-- I am not sure of the appropriate keywords here -->
+ <keyword>draft-wibrown-ldapssotoken</keyword>
+
+ <abstract>
+ <t>LDAP Single Sign On Token is a SASL (Simple Authentication and Security Layer
+ <xref target="RFC2222">RFC 2222</xref>) mechanism to allow single sign-on to an LDAP
+ Directory Server environment. Tokens generated by the LDAP server can be transmitted through other
+ protocols and channels, allowing a broad range of clients and middleware to take advantage
+ of single sign-on in environments where Kerberos v5 or other Single Sign On mechanisms may not be avaliable.</t>
+ </abstract>
+
+</front>
+
+
+<middle>
+
+ <section title="Introduction">
+ <t>The need for new, simple single sign-on capable systems has arisen
+ with the development of new technologies and systems. For these systems
+ we should be able to provide a simple, localised and complete single
+ sign-on service. This does not aim to replace Kerberos V5. It is designed for when Kerberos
+ is too invasive for installation in an environment.
+ </t>
+
+
+ <t>Tokens generated by this system should be able to be transmitted over
+ different protocols allowing middleware to relay tokens to clients.
+ Clients can then contact the middleware natively and the middleware can
+ negotiate the client authentication with the LDAP server.</t>
+
+ <!-- Use terms to describe instead -->
+ <t>This implementation will provide an LDAP extended operation to create
+ tokens which a client may cache, or relay to a further client. The token
+ can then be sent in a SASL bind request to the LDAP server. The token
+ remains valid over many binds. Finally, Tokens
+ for a client are always able to be revoked at the LDAP Server using an
+ LDAP extended operation, allowing global
+ logout by the user or administrator.</t>
+
+
+ </section>
+
+ <section title="Requirements Language">
+ <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
+ "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
+ document are to be interpreted as described in <xref
+ target="RFC2119">RFC 2119</xref>.</t>
+ </section>
+
+ <section title="Format">
+ <t>This document has two components. A SASL Mechanism, and LDAP extended operations.</t>
+ <t>There is no strict requirement for the two to coexist: The LDAP Operation
+ is an implementation of the service providing tokens, and the SASL Mechanism to authenticate them.</t>
+ <t>In theory, an alternate protocol and database could generate and authenticate these tokens.</t>
+ </section>
+
+ <section title="SASL Component">
+ <section title="Token formats">
+ <t>Token formats are server implementation specific: As they
+ are the only entity that will decrypt and consume them, they have
+ the option to provide these in any format they wish. </t>
+ <t>This means the client will only see an opaque data structure, and will only
+ need to transmit this opaque structure as part of the authentication request.</t>
+
+ <t>For the token system to operate correctly the server MUST
+ generate tokens that contain at least these three values:</t>
+ <t>
+ <list style="symbols">
+ <t>Date Time Issued</t>
+ <t>Date Time Until</t>
+ <t>User Unique Id</t>
+ </list>
+ </t>
+ <t>As the client does not ever see the contents the User Unique Id can be
+ anything within the database that uniquely identifies the user
+ that is the holder of the token.</t>
+ <t>The User Unique Id MUST be an UTF8 String.</t>
+ <t>The token format MUST be encrypted. The token format can be
+ decrypted with either a asymmetric or symmetric keying system. </t>
+ <t>The token format MUST have a form of data authentication.
+ This can be through authenticated encryption, or validation of a hash.</t>
+ <t>The Date Time Issued MUST be a complete timestamp in UTC, to
+ prevent issues with changing timezones.</t>
+ <t>Without these guarantees, the token system is not secure,
+ and is vulnerable to credential forgery attacks.</t>
+
+ <t>Here is an EXAMPLE ASN.1 format that would be encrypted and
+ sent to the client:</t>
+ <figure align="left" anchor="asn_token_example">
+ <artwork align="left"><![CDATA[
+LDAPSSOToken ::= SEQUENCE {
+ DateTimeIssued GeneralizedTime,
+ DateTimeUntil GeneralizedTime,
+ UserUniqueId UTF8String }
+ ]]></artwork>
+ </figure>
+ <t>This would be encrypted with AES-GCM and transmitted to the
+ client.</t>
+
+ <!-- make this an xref -->
+ <t>Another example would be to use a fernet token
+ <xref target="FERNETSPEC">Fernet Specification</xref>.</t>
+
+ <figure align="left" anchor="fernet_token_example">
+ <artwork align="left"><![CDATA[
+Version || Timestamp || IV || Ciphertext || HMAC
+ ]]></artwork>
+ </figure>
+
+ <t>Timestamp can be considered to be the DateTimeIssued as:</t>
+
+ <t>"This field is a 64-bit unsigned big-endian integer. It records
+ the number of seconds elapsed between January 1, 1970 UTC and the
+ time the token was created."</t>
+
+ <t>We can then create a Cipher text containing:</t>
+
+ <figure align="left" anchor="fernet_tokendata_example">
+ <artwork align="left"><![CDATA[
+Date Time Until || User Unique Id
+ ]]></artwork>
+ </figure>
+
+ <t>The Date Time Until is a 64-bit unsigned big-endian integer. It is,
+ like Date Time Issued, the number of seconds since January 1, 1970
+ UTC, and the token creation time added to the number of seconds of
+ the requested life time. </t>
+
+ <t>This example format satisfies all of our data requirements for the sso token
+ system.</t>
+
+ </section>
+
+ <section title="SASL Client">
+ <t>The client will request a token from the authentication server.
+ The acquisition method for the token is discussed in section XXX.</t>
+ <t>For authentication, the client MUST send the token as it was received.
+ IE changes to formatting are not permitted.</t>
+ <t>The client MAY transform the token if acting in a proxy fashion.
+ However this transformation must be deterministic and able to be
+ reversed to satisfy the previous requirement.</t>
+ <figure align="left" anchor="server_transform_example">
+ <artwork align="left"><![CDATA[
++-------+ +-------------+ +--------+
+| LDAP | | HTTP server | | Client |
+| | | | <- Login -- | |
+| | <-- Bind -- | | | |
+| | - Success -> | | | |
+| | <- Req Token | | | |
+| | -- Token --> | | | |
+| | <- Unbind - | | | |
+| | - Success -> | | | |
+| | | Html Escape | | |
+| | | | -- Safe --> | |
+| | | | Token | |
+| | | | | Store |
+| | | | < Request +- | |
+| | | Reverse esc | Token | |
+| | < Token Bind | | | |
+| | - Success -> | | | |
+| | <- Operation | | | |
+| | <- Unbind - | | | |
+| | - Success -> | | | |
+| | | | - Response > | |
++-------+ +-------------+ +--------+
+ ]]></artwork>
+ </figure>
+ <t>This example shows how a client is issued with a token when
+ communicating with a web server via the HTTP intermediate. The Client
+ does not need to be aware of the SASL/LDAP system in the background,
+ or the token's formatting rules. Provided the HTTP server in
+ proxy, if required to transform the token, is able to undo the
+ transformations, this is a valid scenario. For example, HTML escaping
+ a base64 token.</t>
+ </section>
+
+ <section title="SASL Authentication">
+ <t>The client issues a SASL bind request with the mechanism name
+ LDAPSSOTOKEN.</t>
+ <t>The client provides the encrypted token that was provided in
+ the LDAPSSOTokenResponse Token Field.</t>
+ <t>The token is decrypted and authenticated based on the token
+ format selected by the server. The server MAY attempt multiple
+ token keys and or formats to find the correct issuing format and
+ key.</t>
+ <t>If the token decryption fails, the attempt with this key and
+ format MUST be considered to fail.</t>
+ <t>If the values have been tampered with, IE hash authentication fails, the attempt with the key
+ and format MUST be considered to fail. </t>
+ <t>The token decryption MUST return a valid DateTimeUntil,
+ DateTimeIssued and User Unique Id. If this is not returned, the decryption
+ MUST be considered to fail.</t>
+ <t>If all token formats and keys fail to decrypt, this MUST cause an
+ invalidCredentials error.</t>
+ <t>The DateTimeUntil field is checked against the servers current
+ time. If the current time exceeds or is equal to DateTimeUntil,
+ invalidCredentials MUST be returned.</t>
+ <t>The User Unique Id is validated to exist on the server. If the User Unique Id
+ does not exist, invalidCredentials MUST be returned.</t>
+ <t>The DateTimeIssued field is validated against the User Unique Id object's
+ attribute or related attribute that contains "Valid Not Before". If the value of
+ "Valid Not Before" exceeds or is equal to DateTimeIssued,
+ invalidCredentials MUST be returned.</t>
+ <t>Only if all of these steps have succeeded, then the authentication is considered successful. </t>
+ </section>
+
+ <section title="Valid Not Before Attribute">
+ <t>The management and details of the "Valid Not Before" attribute
+ are left to the implementation to decide how to implement and
+ manage. The implementation should consider how an administrator
+ or responsible party could revoke tokens for users other than their
+ own. The Valid Not Before SHOULD be replicated between LDAP servers
+ to allow correct revocation across many LDAP servers. For example,
+ Valid Not Before MAY be an attribute on the User Unique Id object, or MAY be on another
+ object with a unique relation to the User Unique Id.</t>
+ </section>
+ </section>
+
+ <section title="LDAP Component">
+
+ <section title="Token Generation">
+ <t>An ldap extended operation is issued as per Section 4.12 of
+ <xref target="RFC4511">RFC 4511</xref>.</t>
+ <t>The LDAP OID to be used for the LDAPSSOTokenRequest is 2.16.840.1.113730.3.5.14.</t>
+ <t>The LDAP OID to be used for the LDAPSSOTokenResponse is 2.16.840.1.113730.3.5.15.</t>
+ <t>A User Unique Id is selected. This may be the Bind DN, UUID or other
+ utf8 identifier that uniquely determines an object.</t>
+ <t>The extended operation must fail if the LDAP connection security stregth factors is 0.</t>
+ <t>Tokens must not be generated for Anonymous binds. This means,
+ tokens may only be generated for connections with a valid bind dn set.</t>
+ <t>Token requests MUST contain a requested lifetime in seconds.
+ The server MAY choose to ignore this lifetime and set it's own
+ value.</t>
+ <t>A token request of a negative or zero value SHOULD default to
+ a server definied minimum lifetime.</t>
+ <t>The token is created as per an example token format in 4.1. This value
+ is then encrypted with an encryption algorithm of the servers
+ choosing. The client does not need to be aware of the encryption
+ algorithm.</t>
+ <t>The DateTimeIssued, DateTimeUntil and User Unique Id are collected in
+ the format required by the token format we are choosing to use in
+ the server. The token is then generated by the chosen
+ algorithm.</t>
+ <t>The encrypted token is sent to the client in the
+ LDAPSSOTokenResponse structure, along with the servers chosen valid
+ life time as a guide for the client to approximate the expiry of the
+ token. This valid life time value is in seconds.</t>
+ <t>If the token cannot be generated due to a server error, LDAP_OPERATION_ERROR MUST be returned.</t>
+
+ <section title="Token Generation Extended Operation">
+ <figure align="left" anchor="token_generation_ext_op">
+ <artwork align="left"><![CDATA[
+LDAPSSOTokenRequest ::= SEQUENCE {
+ ValidLifeTime INTEGER }
+
+LDAPSSOTokenResponse ::= SEQUENCE {
+ ValidLifeTime INTEGER,
+ EncryptedToken OCTET STRING
+}
+ ]]></artwork>
+ </figure>
+ </section>
+ </section>
+
+ <section title="Token Revocation">
+ <t>An ldap extended operation is issued as per Section 4.12
+ <xref target="RFC4511">RFC 4511</xref>. </t>
+ <t>The LDAP OID to be used for LDAPSSOTOKENRevokeRequest is 2.16.840.1.113730.3.5.16.</t>
+ <t>The extended operation MUST fail if the connection is
+ anonymous.</t>
+ <t>The extended operation MUST fail if the LDAP connection security strength factors is 0.</t>
+ <t>The extended operation MUST only act upon the "Valid Not Before"
+ attribute related to the bind DN of the connection.</t>
+ <t>Upon recieving the extended operation to revoke tokens, the
+ directory server MUST set the current BindDN's related "Valid Not Before" attribute timestamp to the current datetime. This will
+ have the effect, that all previously issued tokens are invalidated.</t>
+ <t>This revocation option must work regardless of directory server
+ access controls on the attribute containing "Valid Not Before".</t>
+ <section title="Token Revocation Extended Operation">
+ <t>The extended operation requestValue MUST not be set for
+ LDAP SSO Token revocation.</t>
+ <t>The extended operation does not provide a response OID. The result is set in the LDAPResult.</t>
+ </section>
+ </section>
+
+ <section title="Binding">
+ <t>The SASL bind attempt MUST fail if the LDAP connection security strength factors is 0.</t>
+ <t>The SASL Authentication is attempted as per Section 4.3. If this does not succeed, the bind attempt MUST fail.</t>
+ <t>The LDAP Object is retrived from the User Unique Id, and a Bind DN Determined. If no Bind DN can be determined, the bind attempt MUST fail.</t>
+ <t>The current Bind DN MUST be set to the Bind DN of the LDAP object that is determined, and the result ldap success is returned to the LDAP client.</t>
+ </section>
+
+ </section>
+
+ <section title="Security Considerations">
+ <t>Due to the design of this token, it is possible to use it in a replay
+ attack. Notable threats are storage on the client and man in the middle attacks.
+ To minimise the man in the middle attack thread, LDAP security strength factor of greater than 0 is a requirement.
+ Client security is not covered by this document.</t>
+ </section>
+
+ <section title="Requirements">
+ <t>The SASL mechanism, LDAPSSOTOKEN, MUST be registered to IANA as per
+ <xref target="RFC2222">RFC 2222</xref> Section 6.4</t>
+ </section>
+
+
+</middle>
+
+<back>
+
+ <references title="Normative References">
+ &RFC2119;
+
+ </references>
+
+ <references title="Informative References">
+ &RFC2222;
+
+ &RFC4511;
+ <!-- Add the fernet reference -->
+
+ <reference anchor="FERNETSPEC"
+ target="https://github.com/fernet/spec/blob/master/Spec.md">
+ <front>
+ <title>Fernet Specification</title>
+
+ <author fullname="Tom Maher" initials="T.M." surname="Maher">
+ </author>
+
+ <author fullname="Keith Rarick" initials="K.R." surname="Rarick">
+ </author>
+
+ <date year="2013" />
+ </front>
+ </reference>
+
+ </references>
+
+</back>
+
+</rfc>
| 0 |
5287b9ac635a502f3cec9f6ac92f7f847b71d437
|
389ds/389-ds-base
|
Issue 50206 - Refactor lock, unlock and status of dsidm account/role
Description: Port ns-accountstatus.pl, ns-activate.pl and ns-inactivate.pl to lib389 CLI.
Add: dsidm account/role entry-status, dsidm account subtree-status, dsidm role lock/unlock
Refactor: dsidm account lock/unlock
Remove: dsidm account status
Also, refactor role.py and idm/account.py accordingly to the CLI requirements.
https://pagure.io/389-ds-base/issue/50206
Reviewed by: firstyear (Thanks, William!)
|
commit 5287b9ac635a502f3cec9f6ac92f7f847b71d437
Author: Simon Pichugin <[email protected]>
Date: Wed Aug 14 11:38:50 2019 +0200
Issue 50206 - Refactor lock, unlock and status of dsidm account/role
Description: Port ns-accountstatus.pl, ns-activate.pl and ns-inactivate.pl to lib389 CLI.
Add: dsidm account/role entry-status, dsidm account subtree-status, dsidm role lock/unlock
Refactor: dsidm account lock/unlock
Remove: dsidm account status
Also, refactor role.py and idm/account.py accordingly to the CLI requirements.
https://pagure.io/389-ds-base/issue/50206
Reviewed by: firstyear (Thanks, William!)
diff --git a/dirsrvtests/tests/suites/acl/acivattr_test.py b/dirsrvtests/tests/suites/acl/acivattr_test.py
index f9cf09609..e46b8917b 100644
--- a/dirsrvtests/tests/suites/acl/acivattr_test.py
+++ b/dirsrvtests/tests/suites/acl/acivattr_test.py
@@ -15,7 +15,7 @@ from lib389.cos import CosTemplate, CosClassicDefinition
from lib389.topologies import topology_st as topo
from lib389.idm.nscontainer import nsContainer
from lib389.idm.domain import Domain
-from lib389.idm.role import FilterRoles
+from lib389.idm.role import FilteredRoles
pytestmark = pytest.mark.tier1
@@ -55,7 +55,7 @@ def _add_user(request, topo):
ou = OrganizationalUnit(topo.standalone, "ou=sales,o=acivattr,{}".format(DEFAULT_SUFFIX))
ou.create(properties={'ou': 'sales'})
- roles = FilterRoles(topo.standalone, DNBASE)
+ roles = FilteredRoles(topo.standalone, DNBASE)
roles.create(properties={'cn':'FILTERROLEENGROLE', 'nsRoleFilter':'cn=eng*'})
roles.create(properties={'cn': 'FILTERROLESALESROLE', 'nsRoleFilter': 'cn=sales*'})
diff --git a/dirsrvtests/tests/suites/acl/roledn_test.py b/dirsrvtests/tests/suites/acl/roledn_test.py
index f6277539a..361653276 100644
--- a/dirsrvtests/tests/suites/acl/roledn_test.py
+++ b/dirsrvtests/tests/suites/acl/roledn_test.py
@@ -18,7 +18,7 @@ from lib389.idm.user import UserAccounts, UserAccount
from lib389.idm.organizationalunit import OrganizationalUnits
from lib389.topologies import topology_st as topo
from lib389.idm.domain import Domain
-from lib389.idm.role import NestedRoles, ManagedRoles, FilterRoles
+from lib389.idm.role import NestedRoles, ManagedRoles, FilteredRoles
from lib389.idm.account import Anonymous
import ldap
@@ -94,7 +94,7 @@ def _add_user(request, topo):
for i in ['ROLE1', 'ROLE21', 'ROLE31']:
managedroles.create(properties={'cn': i})
- filterroles = FilterRoles(topo.standalone, OU_ROLE)
+ filterroles = FilteredRoles(topo.standalone, OU_ROLE)
filterroles.create(properties={'cn': 'filterRole',
'nsRoleFilter': 'sn=Dr Drake',
'description': 'filter role tester'})
diff --git a/dirsrvtests/tests/suites/cos/cos_test.py b/dirsrvtests/tests/suites/cos/cos_test.py
index a8907d182..6065e8932 100644
--- a/dirsrvtests/tests/suites/cos/cos_test.py
+++ b/dirsrvtests/tests/suites/cos/cos_test.py
@@ -10,7 +10,7 @@ import pytest, os, ldap
from lib389.cos import CosClassicDefinition, CosClassicDefinitions, CosTemplate
from lib389._constants import DEFAULT_SUFFIX
from lib389.topologies import topology_st as topo
-from lib389.idm.role import FilterRoles
+from lib389.idm.role import FilteredRoles
from lib389.idm.nscontainer import nsContainer
from lib389.idm.user import UserAccount
@@ -36,7 +36,7 @@ def test_positive(topo):
6. Operation should success
"""
# Adding ns filter role
- roles = FilterRoles(topo.standalone, DEFAULT_SUFFIX)
+ roles = FilteredRoles(topo.standalone, DEFAULT_SUFFIX)
roles.create(properties={'cn': 'FILTERROLEENGROLE',
'nsRoleFilter': 'cn=eng*'})
# adding ns container
diff --git a/dirsrvtests/tests/suites/filter/vfilter_simple_test.py b/dirsrvtests/tests/suites/filter/vfilter_simple_test.py
index 871fd99a2..1796f8806 100644
--- a/dirsrvtests/tests/suites/filter/vfilter_simple_test.py
+++ b/dirsrvtests/tests/suites/filter/vfilter_simple_test.py
@@ -19,7 +19,7 @@ from lib389.idm.organizationalunit import OrganizationalUnits
from lib389.idm.account import Accounts
from lib389.idm.user import UserAccount, UserAccounts
from lib389.schema import Schema
-from lib389.idm.role import ManagedRoles, FilterRoles
+from lib389.idm.role import ManagedRoles, FilteredRoles
pytestmark = pytest.mark.tier1
@@ -496,7 +496,7 @@ def _create_test_entries(topo):
'cn': 'new managed role'})
# Creating filter role
- filters = FilterRoles(topo.standalone, DEFAULT_SUFFIX)
+ filters = FilteredRoles(topo.standalone, DEFAULT_SUFFIX)
filters.create(properties={
'nsRoleFilter': '(uid=*wal*)',
'description': 'this is the new filtered role',
diff --git a/dirsrvtests/tests/suites/roles/basic_test.py b/dirsrvtests/tests/suites/roles/basic_test.py
index a3e3c5c36..08bc8f2f5 100644
--- a/dirsrvtests/tests/suites/roles/basic_test.py
+++ b/dirsrvtests/tests/suites/roles/basic_test.py
@@ -19,7 +19,7 @@ from lib389.idm.user import UserAccount, UserAccounts
from lib389.idm.organization import Organization
from lib389.idm.organizationalunit import OrganizationalUnit
from lib389.topologies import topology_st as topo
-from lib389.idm.role import FilterRoles, ManagedRoles, NestedRoles
+from lib389.idm.role import FilteredRoles, ManagedRoles, NestedRoles
from lib389.idm.domain import Domain
pytestmark = pytest.mark.tier1
@@ -59,7 +59,7 @@ def test_filterrole(topo):
ou_ou = OrganizationalUnit(topo.standalone, "ou=sales,o=acivattr,{}".format(DEFAULT_SUFFIX))
ou_ou.create(properties=properties)
- roles = FilterRoles(topo.standalone, DNBASE)
+ roles = FilteredRoles(topo.standalone, DNBASE)
roles.create(properties={'cn': 'FILTERROLEENGROLE', 'nsRoleFilter': 'cn=eng*'})
roles.create(properties={'cn': 'FILTERROLESALESROLE', 'nsRoleFilter': 'cn=sales*'})
diff --git a/src/lib389/cli/dsidm b/src/lib389/cli/dsidm
index 9e5b998e7..aab6f6f10 100755
--- a/src/lib389/cli/dsidm
+++ b/src/lib389/cli/dsidm
@@ -11,11 +11,10 @@
# PYTHON_ARGCOMPLETE_OK
import ldap
-import argparse, argcomplete
-import logging
+import argparse
+import argcomplete
import sys
import signal
-from lib389._constants import DN_DM
from lib389.cli_idm import account as cli_account
from lib389.cli_idm import initialise as cli_init
from lib389.cli_idm import organizationalunit as cli_ou
@@ -23,6 +22,7 @@ from lib389.cli_idm import group as cli_group
from lib389.cli_idm import posixgroup as cli_posixgroup
from lib389.cli_idm import user as cli_user
from lib389.cli_idm import client_config as cli_client_config
+from lib389.cli_idm import role as cli_role
from lib389.cli_base import connect_instance, disconnect_instance, setup_script_logger
from lib389.cli_base.dsrc import dsrc_to_ldap, dsrc_arg_concat
@@ -73,6 +73,7 @@ cli_ou.create_parser(subparsers)
cli_posixgroup.create_parser(subparsers)
cli_user.create_parser(subparsers)
cli_client_config.create_parser(subparsers)
+cli_role.create_parser(subparsers)
argcomplete.autocomplete(parser)
diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py
index 3953a67d6..5cfb59eba 100644
--- a/src/lib389/lib389/_mapped_object.py
+++ b/src/lib389/lib389/_mapped_object.py
@@ -1138,14 +1138,19 @@ class DSLdapObjects(DSLogging):
# Now actually commit the creation req
return co.ensure_state(rdn, properties, self._basedn)
- def filter(self, search):
+ def filter(self, search, scope=None):
# This will yield and & filter for objectClass with as many terms as needed.
- search_filter = _gen_and([self._get_objectclass_filter(), search])
- self._log.debug('list filter = %s' % search_filter)
+ if search:
+ search_filter = _gen_and([self._get_objectclass_filter(), search])
+ else:
+ search_filter = self._get_objectclass_filter()
+ if scope is None:
+ scope = self._scope
+ self._log.debug(f'list filter = {search_filter} with scope {scope}')
try:
results = self._instance.search_ext_s(
base=self._basedn,
- scope=self._scope,
+ scope=scope,
filterstr=search_filter,
attrlist=self._list_attrlist,
serverctrls=self._server_controls, clientctrls=self._client_controls
diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py
index 5405e20bb..d2249a494 100644
--- a/src/lib389/lib389/backend.py
+++ b/src/lib389/lib389/backend.py
@@ -874,4 +874,3 @@ class DatabaseConfig(DSLdapObject):
self._create_objectclasses = ['top', 'extensibleObject']
self._protected = True
self._dn = "cn=config,cn=ldbm database,cn=plugins,cn=config"
-
diff --git a/src/lib389/lib389/cli_base/__init__.py b/src/lib389/lib389/cli_base/__init__.py
index d1390402b..932938b0e 100644
--- a/src/lib389/lib389/cli_base/__init__.py
+++ b/src/lib389/lib389/cli_base/__init__.py
@@ -11,11 +11,12 @@ import logging
import sys
import json
import ldap
+from ldap.dn import is_dn
from getpass import getpass
from lib389 import DirSrv
from lib389.utils import assert_c, get_ldapurl_from_serverid
-from lib389.properties import *
+from lib389.properties import SER_ROOT_PW, SER_ROOT_DN
def _get_arg(args, msg=None, hidden=False, confirm=False):
@@ -37,6 +38,13 @@ def _get_arg(args, msg=None, hidden=False, confirm=False):
return input("%s : " % msg)
+def _get_dn_arg(args, msg=None):
+ dn_arg = _get_arg(args, msg)
+ if not is_dn(dn_arg):
+ raise ValueError(f"{dn_arg} is not a valid DN")
+ return dn_arg
+
+
def _get_args(args, kws):
kwargs = {}
while len(kws) > 0:
diff --git a/src/lib389/lib389/cli_idm/__init__.py b/src/lib389/lib389/cli_idm/__init__.py
index fcf017532..28648ad69 100644
--- a/src/lib389/lib389/cli_idm/__init__.py
+++ b/src/lib389/lib389/cli_idm/__init__.py
@@ -7,8 +7,6 @@
# --- END COPYRIGHT BLOCK ---
from getpass import getpass
-from lib389 import DirSrv
-from lib389.properties import *
import json
diff --git a/src/lib389/lib389/cli_idm/account.py b/src/lib389/lib389/cli_idm/account.py
index f95c6c674..025ea1e6c 100644
--- a/src/lib389/lib389/cli_idm/account.py
+++ b/src/lib389/lib389/cli_idm/account.py
@@ -7,9 +7,13 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
+import ldap
+import math
+import time
+from datetime import datetime
import argparse
-from lib389.idm.account import Account, Accounts
+from lib389.idm.account import Account, Accounts, AccountState
from lib389.cli_base import (
_generic_get,
_generic_get_dn,
@@ -17,66 +21,115 @@ from lib389.cli_base import (
_generic_delete,
_generic_modify_dn,
_get_arg,
+ _get_dn_arg,
_warn,
)
+from lib389.utils import gentime_to_posix_time
+
MANY = Accounts
SINGULAR = Account
+
def list(inst, basedn, log, args):
_generic_list(inst, basedn, log.getChild('_generic_list'), MANY, args)
+
def get_dn(inst, basedn, log, args):
- dn = _get_arg( args.dn, msg="Enter dn to retrieve")
+ dn = _get_dn_arg(args.dn, msg="Enter dn to retrieve")
_generic_get_dn(inst, basedn, log.getChild('_generic_get_dn'), MANY, dn, args)
+
def delete(inst, basedn, log, args, warn=True):
- dn = _get_arg( args.dn, msg="Enter dn to delete")
+ dn = _get_dn_arg(args.dn, msg="Enter dn to delete")
if warn:
_warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn))
_generic_delete(inst, basedn, log.getChild('_generic_delete'), SINGULAR, dn, args)
+
def modify(inst, basedn, log, args, warn=True):
- dn = _get_arg( args.dn, msg="Enter dn to modify")
+ dn = _get_dn_arg(args.dn, msg="Enter dn to modify")
_generic_modify_dn(inst, basedn, log.getChild('_generic_modify'), MANY, dn, args)
-def status(inst, basedn, log, args):
- dn = _get_arg( args.dn, msg="Enter dn to check")
+
+def _print_entry_status(status, dn, log):
+ log.info(f'Entry DN: {dn}')
+ for name, value in status["params"].items():
+ if "Time" in name and value is not None:
+ inactivation_date = datetime.fromtimestamp(status["calc_time"] + value)
+ log.info(f"Entry {name}: {int(math.fabs(value))} seconds ({inactivation_date.strftime('%Y-%m-%d %H:%M:%S')})")
+ elif "Date" in name and value is not None:
+ log.info(f"Entry {name}: {value.strftime('%Y%m%d%H%M%SZ')} ({value.strftime('%Y-%m-%d %H:%M:%S')})")
+ log.info(f'Entry State: {status["state"].describe(status["role_dn"])}\n')
+
+
+def entry_status(inst, basedn, log, args):
+ dn = _get_dn_arg(args.dn, msg="Enter dn to check")
accounts = Accounts(inst, basedn)
acct = accounts.get(dn=dn)
- acct_str = "locked: %s" % acct.is_locked()
- log.info('dn: %s' % dn)
- log.info(acct_str)
+ status = acct.status()
+ _print_entry_status(status, dn, log)
+
+
+def subtree_status(inst, basedn, log, args):
+ basedn = _get_dn_arg(args.basedn, msg="Enter basedn to check")
+ filter = ""
+ scope = ldap.SCOPE_SUBTREE
+ epoch_inactive_time = None
+ if args.scope == "one":
+ scope = ldap.SCOPE_ONELEVEL
+ if args.filter:
+ filter = args.filter
+ if args.become_inactive_on:
+ datetime_inactive_time = datetime.strptime(args.become_inactive_on, '%Y-%m-%dT%H:%M:%S')
+ epoch_inactive_time = datetime.timestamp(datetime_inactive_time)
+
+ account_list = Accounts(inst, basedn).filter(filter, scope)
+ if not account_list:
+ raise ValueError(f"No entries were found under {basedn}")
+
+ for entry in account_list:
+ status = entry.status()
+ state = status["state"]
+ params = status["params"]
+ if args.inactive_only and state == AccountState.ACTIVATED:
+ continue
+ if args.become_inactive_on:
+ if epoch_inactive_time is None or params["Time Until Inactive"] is None or \
+ epoch_inactive_time <= (params["Time Until Inactive"] + status["calc_time"]):
+ continue
+ _print_entry_status(status, entry.dn, log)
+
def lock(inst, basedn, log, args):
- dn = _get_arg( args.dn, msg="Enter dn to check")
+ dn = _get_dn_arg(args.dn, msg="Enter dn to check")
accounts = Accounts(inst, basedn)
acct = accounts.get(dn=dn)
acct.lock()
- log.info('locked %s' % dn)
+ log.info(f'Entry {dn} is locked')
+
def unlock(inst, basedn, log, args):
- dn = _get_arg( args.dn, msg="Enter dn to check")
+ dn = _get_dn_arg(args.dn, msg="Enter dn to check")
accounts = Accounts(inst, basedn)
acct = accounts.get(dn=dn)
acct.unlock()
- log.info('unlocked %s' % dn)
+ log.info(f'Entry {dn} is unlocked')
+
def reset_password(inst, basedn, log, args):
- dn = _get_arg(args.dn, msg="Enter dn to reset password")
- new_password = _get_arg(args.new_password, hidden=True, confirm=True,
- msg="Enter new password for %s" % dn)
+ dn = _get_dn_arg(args.dn, msg="Enter dn to reset password")
+ new_password = _get_arg(args.new_password, hidden=True, confirm=True, msg="Enter new password for %s" % dn)
accounts = Accounts(inst, basedn)
acct = accounts.get(dn=dn)
acct.reset_password(new_password)
log.info('reset password for %s' % dn)
+
def change_password(inst, basedn, log, args):
- dn = _get_arg(args.dn, msg="Enter dn to change password")
- cur_password = _get_arg(args.current_password, hidden=True, confirm=False,
- msg="Enter current password for %s" % dn)
- new_password = _get_arg(args.new_password, hidden=True, confirm=True,
- msg="Enter new password for %s" % dn)
+ dn = _get_dn_arg(args.dn, msg="Enter dn to change password")
+ cur_password = _get_arg(args.current_password, hidden=True, confirm=False, msg="Enter current password for %s" % dn)
+ new_password = _get_arg(args.new_password, hidden=True, confirm=True, msg="Enter new password for %s" % dn)
accounts = Accounts(inst, basedn)
acct = accounts.get(dn=dn)
acct.change_password(cur_password, new_password)
@@ -109,14 +162,25 @@ like modify, locking and unlocking. To create an account, see "user" subcommand
lock_parser.set_defaults(func=lock)
lock_parser.add_argument('dn', nargs='?', help='The dn to lock')
- status_parser = subcommands.add_parser('status', help='status')
- status_parser.set_defaults(func=status)
- status_parser.add_argument('dn', nargs='?', help='The dn to check')
-
unlock_parser = subcommands.add_parser('unlock', help='unlock')
unlock_parser.set_defaults(func=unlock)
unlock_parser.add_argument('dn', nargs='?', help='The dn to unlock')
+ status_parser = subcommands.add_parser('entry-status', help='status of a single entry')
+ status_parser.set_defaults(func=entry_status)
+ status_parser.add_argument('dn', nargs='?', help='The single entry dn to check')
+ status_parser.add_argument('-V', '--details', action='store_true', help="Print more account policy details about the entry")
+
+ status_parser = subcommands.add_parser('subtree-status', help='status of a subtree')
+ status_parser.set_defaults(func=subtree_status)
+ status_parser.add_argument('basedn', help="Search base for finding entries")
+ status_parser.add_argument('-V', '--details', action='store_true', help="Print more account policy details about the entries")
+ status_parser.add_argument('-f', '--filter', help="Search filter for finding entries")
+ status_parser.add_argument('-s', '--scope', choices=['one', 'sub'], help="Search scope (one, sub - default is sub")
+ status_parser.add_argument('-i', '--inactive-only', action='store_true', help="Only display inactivated entries")
+ status_parser.add_argument('-o', '--become-inactive-on',
+ help="Only display entries that will become inactive before specified date (in a format 2007-04-25T14:30)")
+
reset_pw_parser = subcommands.add_parser('reset_password', help='Reset the password of an account. This should be performed by a directory admin.')
reset_pw_parser.set_defaults(func=reset_password)
reset_pw_parser.add_argument('dn', nargs='?', help='The dn to reset the password for')
@@ -127,5 +191,3 @@ like modify, locking and unlocking. To create an account, see "user" subcommand
change_pw_parser.add_argument('dn', nargs='?', help='The dn to change the password for')
change_pw_parser.add_argument('new_password', nargs='?', help='The new password to set')
change_pw_parser.add_argument('current_password', nargs='?', help='The accounts current password')
-
-
diff --git a/src/lib389/lib389/cli_idm/role.py b/src/lib389/lib389/cli_idm/role.py
new file mode 100644
index 000000000..922dadcd8
--- /dev/null
+++ b/src/lib389/lib389/cli_idm/role.py
@@ -0,0 +1,126 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2019, Red Hat inc,
+# Copyright (C) 2018, William Brown <[email protected]>
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+import ldap
+import argparse
+
+from lib389.idm.role import Role, Roles, RoleState
+from lib389.cli_base import (
+ _generic_get,
+ _generic_get_dn,
+ _generic_list,
+ _generic_delete,
+ _generic_modify_dn,
+ _get_arg,
+ _get_dn_arg,
+ _warn,
+ )
+
+MANY = Roles
+SINGULAR = Role
+
+
+def list(inst, basedn, log, args):
+ _generic_list(inst, basedn, log.getChild('_generic_list'), MANY, args)
+
+
+def get_dn(inst, basedn, log, args):
+ dn = _get_dn_arg(args.dn, msg="Enter dn to retrieve")
+ _generic_get_dn(inst, basedn, log.getChild('_generic_get_dn'), MANY, dn, args)
+
+
+def delete(inst, basedn, log, args, warn=True):
+ dn = _get_dn_arg(args.dn, msg="Enter dn to delete")
+ if warn:
+ _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn))
+ _generic_delete(inst, basedn, log.getChild('_generic_delete'), SINGULAR, dn, args)
+
+
+def modify(inst, basedn, log, args, warn=True):
+ dn = _get_dn_arg(args.dn, msg="Enter dn to modify")
+ _generic_modify_dn(inst, basedn, log.getChild('_generic_modify'), MANY, dn, args)
+
+
+def entry_status(inst, basedn, log, args):
+ dn = _get_dn_arg(args.dn, msg="Enter dn to check")
+ roles = Roles(inst, basedn)
+ role = roles.get(dn=dn)
+ status = role.status()
+ log.info(f'Entry DN: {dn}')
+ log.info(f'Entry State: {status["state"].describe(status["role_dn"])}\n')
+
+
+def subtree_status(inst, basedn, log, args):
+ basedn = _get_dn_arg(args.basedn, msg="Enter basedn to check")
+ filter = ""
+ scope = ldap.SCOPE_SUBTREE
+
+ role_list = Roles(inst, basedn).filter(filter, scope)
+ if not role_list:
+ raise ValueError(f"No entries were found under {basedn} or the user doesn't have an access")
+
+ for entry in role_list:
+ status = entry.status()
+ log.info(f'Entry DN: {entry.dn}')
+ log.info(f'Entry State: {status["state"].describe(status["role_dn"])}\n')
+
+
+def lock(inst, basedn, log, args):
+ dn = _get_dn_arg(args.dn, msg="Enter dn to check")
+ role = Role(inst, dn=dn)
+ role.lock()
+ log.info(f'Entry {dn} is locked')
+
+
+def unlock(inst, basedn, log, args):
+ dn = _get_dn_arg(args.dn, msg="Enter dn to check")
+ role = Role(inst, dn=dn)
+ role.unlock()
+ log.info(f'Entry {dn} is unlocked')
+
+
+def create_parser(subparsers):
+ role_parser = subparsers.add_parser('role', help='''Manage generic roles, with tasks
+like modify, locking and unlocking.''')
+
+ subcommands = role_parser.add_subparsers(help='action')
+
+ list_parser = subcommands.add_parser('list', help='list roles that could login to the directory')
+ list_parser.set_defaults(func=list)
+
+ get_dn_parser = subcommands.add_parser('get-by-dn', help='get-by-dn <dn>')
+ get_dn_parser.set_defaults(func=get_dn)
+ get_dn_parser.add_argument('dn', nargs='?', help='The dn to get and display')
+
+ modify_dn_parser = subcommands.add_parser('modify-by-dn', help='modify-by-dn <dn> <add|delete|replace>:<attribute>:<value> ...')
+ modify_dn_parser.set_defaults(func=modify)
+ modify_dn_parser.add_argument('dn', nargs=1, help='The dn to get and display')
+ modify_dn_parser.add_argument('changes', nargs='+', help="A list of changes to apply in format: <add|delete|replace>:<attribute>:<value>")
+
+ delete_parser = subcommands.add_parser('delete', help='deletes the role')
+ delete_parser.set_defaults(func=delete)
+ delete_parser.add_argument('dn', nargs='?', help='The dn of the role to delete')
+
+ lock_parser = subcommands.add_parser('lock', help='lock')
+ lock_parser.set_defaults(func=lock)
+ lock_parser.add_argument('dn', nargs='?', help='The dn to lock')
+
+ unlock_parser = subcommands.add_parser('unlock', help='unlock')
+ unlock_parser.set_defaults(func=unlock)
+ unlock_parser.add_argument('dn', nargs='?', help='The dn to unlock')
+
+ status_parser = subcommands.add_parser('entry-status', help='status of a single entry')
+ status_parser.set_defaults(func=entry_status)
+ status_parser.add_argument('dn', nargs='?', help='The single entry dn to check')
+
+ status_parser = subcommands.add_parser('subtree-status', help='status of a subtree')
+ status_parser.set_defaults(func=subtree_status)
+ status_parser.add_argument('basedn', help="Search base for finding entries")
+ status_parser.add_argument('-f', '--filter', help="Search filter for finding entries")
+ status_parser.add_argument('-s', '--scope', choices=['base', 'one', 'sub'], help="Search scope (base, one, sub - default is sub")
diff --git a/src/lib389/lib389/idm/account.py b/src/lib389/lib389/idm/account.py
index 4a5c5c459..c95e7a96f 100644
--- a/src/lib389/lib389/idm/account.py
+++ b/src/lib389/lib389/idm/account.py
@@ -1,4 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2019 Red Hat, Inc.
# Copyright (C) 2017, William Brown <william at blackhats.net.au>
# All rights reserved.
#
@@ -6,12 +7,33 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
+import os
+import time
+import subprocess
+from enum import Enum
+import ldap
+
from lib389._mapped_object import DSLdapObject, DSLdapObjects, _gen_or, _gen_filter, _term_gen
from lib389._constants import SER_ROOT_DN, SER_ROOT_PW
-from lib389.utils import ds_is_older
+from lib389.utils import ds_is_older, gentime_to_posix_time, gentime_to_datetime
+from lib389.plugins import AccountPolicyPlugin, AccountPolicyConfig, AccountPolicyEntry
+from lib389.cos import CosTemplates
+from lib389.mappingTree import MappingTrees
+from lib389.idm.role import Roles
+
+
+class AccountState(Enum):
+ ACTIVATED = "activated"
+ DIRECTLY_LOCKED = "directly locked through nsAccountLock"
+ INDIRECTLY_LOCKED = "indirectly locked through a Role"
+ INACTIVITY_LIMIT_EXCEEDED = "inactivity limit exceeded"
+
+ def describe(self, role_dn=None):
+ if self.name == "INDIRECTLY_LOCKED" and role_dn is not None:
+ return f'{self.value} - {role_dn}'
+ else:
+ return f'{self.value}'
-import os
-import subprocess
class Account(DSLdapObject):
"""A single instance of Account entry
@@ -22,23 +44,152 @@ class Account(DSLdapObject):
:type dn: str
"""
- def is_locked(self):
- """Check if nsAccountLock is set
-
- :returns: True if account is locked
+ def _format_status_message(self, message, create_time, modify_time, last_login_time, limit, role_dn=None):
+ params = {}
+ now = time.time()
+ params["Creation Date"] = gentime_to_datetime(create_time)
+ params["Modification Date"] = gentime_to_datetime(modify_time)
+ params["Last Login Date"] = None
+ params["Time Until Inactive"] = None
+ params["Time Since Inactive"] = None
+ if last_login_time:
+ params["Last Login Date"] = gentime_to_datetime(last_login_time)
+ if limit:
+ remaining_time = float(limit) + gentime_to_posix_time(last_login_time) - now
+ if remaining_time <= 0:
+ if message == AccountState.INACTIVITY_LIMIT_EXCEEDED:
+ params["Time Since Inactive"] = remaining_time
+ else:
+ params["Time Until Inactive"] = remaining_time
+ result = {"state": message, "params": params, "calc_time": now, "role_dn": None}
+ if role_dn is not None:
+ result["role_dn"] = role_dn
+ return result
+
+ def _dict_get_with_ignore_indexerror(self, dict, attr):
+ try:
+ return dict[attr][0]
+ except IndexError:
+ return ""
+
+ def status(self):
+ """Check if account is locked by Account Policy plugin or
+ nsAccountLock (directly or indirectly)
+
+ :returns: a dict in a format -
+ {"status": status, "params": activity_data, "calc_time": epoch_time}
"""
- return self.present('nsAccountLock')
+ inst = self._instance
+
+ # Fetch Account Policy data if its enabled
+ plugin = AccountPolicyPlugin(inst)
+ state_attr = ""
+ alt_state_attr = ""
+ limit = ""
+ spec_attr = ""
+ limit_attr = ""
+ process_account_policy = False
+ try:
+ process_account_policy = plugin.status()
+ except IndexError:
+ self._log.debug("The bound user doesn't have rights to access Account Policy settings. Not checking.")
+
+ if process_account_policy:
+ config_dn = plugin.get_attr_val_utf8("nsslapd-pluginarg0")
+ config = AccountPolicyConfig(inst, config_dn)
+ config_settings = config.get_attrs_vals_utf8(["stateattrname", "altstateattrname",
+ "specattrname", "limitattrname"])
+ state_attr = self._dict_get_with_ignore_indexerror(config_settings, "stateattrname")
+ alt_state_attr = self._dict_get_with_ignore_indexerror(config_settings, "altstateattrname")
+ spec_attr = self._dict_get_with_ignore_indexerror(config_settings, "specattrname")
+ limit_attr = self._dict_get_with_ignore_indexerror(config_settings, "limitattrname")
+
+ cos_entries = CosTemplates(inst, self.dn)
+ accpol_entry_dn = ""
+ for cos in cos_entries.list():
+ if cos.present(spec_attr):
+ accpol_entry_dn = cos.get_attr_val_utf8_l(spec_attr)
+ if accpol_entry_dn:
+ accpol_entry = AccountPolicyEntry(inst, accpol_entry_dn)
+ else:
+ accpol_entry = config
+ limit = accpol_entry.get_attr_val_utf8_l(limit_attr)
+
+ # Fetch account data
+ account_data = self.get_attrs_vals_utf8(["createTimestamp", "modifyTimeStamp",
+ "nsAccountLock", state_attr])
+
+ last_login_time = self._dict_get_with_ignore_indexerror(account_data, state_attr)
+ if not last_login_time:
+ last_login_time = self._dict_get_with_ignore_indexerror(account_data, alt_state_attr)
+
+ create_time = self._dict_get_with_ignore_indexerror(account_data, "createTimestamp")
+ modify_time = self._dict_get_with_ignore_indexerror(account_data, "modifyTimeStamp")
+
+ acct_roles = self.get_attr_vals_utf8_l("nsRole")
+ mapping_trees = MappingTrees(inst)
+ root_suffix = ""
+ try:
+ root_suffix = mapping_trees.get_root_suffix_by_entry(self.dn)
+ except ldap.NO_SUCH_OBJECT:
+ self._log.debug("The bound user doesn't have rights to access disabled roles settings. Not checking.")
+ if root_suffix:
+ roles = Roles(inst, root_suffix)
+ try:
+ disabled_roles = roles.get_disabled_roles()
+
+ # Locked indirectly through a role
+ locked_indirectly_role_dn = ""
+ for role in acct_roles:
+ if str.lower(role) in [str.lower(role.dn) for role in disabled_roles.keys()]:
+ locked_indirectly_role_dn = role
+ if locked_indirectly_role_dn:
+ return self._format_status_message(AccountState.INDIRECTLY_LOCKED, create_time, modify_time,
+ last_login_time, limit, locked_indirectly_role_dn)
+ except ldap.NO_SUCH_OBJECT:
+ pass
+
+ # Locked directly
+ if self._dict_get_with_ignore_indexerror(account_data, "nsAccountLock") == "true":
+ return self._format_status_message(AccountState.DIRECTLY_LOCKED,
+ create_time, modify_time, last_login_time, limit)
+
+ # Locked indirectly through Account Policy plugin
+ if process_account_policy and last_login_time:
+ # Now check the Acount Policy Plugin inactivity limits
+ remaining_time = float(limit) - (time.time() - gentime_to_posix_time(last_login_time))
+ if remaining_time <= 0:
+ return self._format_status_message(AccountState.INACTIVITY_LIMIT_EXCEEDED,
+ create_time, modify_time, last_login_time, limit)
+ # All checks are passed - we are active
+ return self._format_status_message(AccountState.ACTIVATED, create_time, modify_time, last_login_time, limit)
+
+ def ensure_lock(self):
+ """Ensure nsAccountLock is set to 'true'"""
+
+ self.replace('nsAccountLock', 'true')
+
+ def ensure_unlock(self):
+ """Unset nsAccountLock if it's set"""
+
+ self.ensure_removed('nsAccountLock', None)
def lock(self):
"""Set nsAccountLock to 'true'"""
+ current_status = self.status()
+ if current_status["state"] == AccountState.DIRECTLY_LOCKED:
+ raise ValueError("Account is already active")
self.replace('nsAccountLock', 'true')
def unlock(self):
"""Unset nsAccountLock"""
- self.ensure_removed('nsAccountLock', None)
+ current_status = self.status()
+ if current_status["state"] == AccountState.ACTIVATED:
+ raise ValueError("Account is already active")
+ self.remove('nsAccountLock', None)
# If the account can be bound to, this will attempt to do so. We don't check
# for exceptions, just pass them back!
@@ -143,6 +294,7 @@ class Account(DSLdapObject):
self._instance.passwd_s(self._dn, current_password, new_password,
serverctrls=self._server_controls, clientctrls=self._client_controls, escapehatch='i am sure')
+
class Accounts(DSLdapObjects):
"""DSLdapObjects that represents Account entry
diff --git a/src/lib389/lib389/idm/role.py b/src/lib389/lib389/idm/role.py
index b630bff00..fe91aab6f 100644
--- a/src/lib389/lib389/idm/role.py
+++ b/src/lib389/lib389/idm/role.py
@@ -7,157 +7,334 @@
# --- END COPYRIGHT BLOCK ----
+from enum import Enum
+import ldap
from lib389._mapped_object import DSLdapObject, DSLdapObjects
+from lib389.cos import CosTemplates, CosClassicDefinitions
+from lib389.mappingTree import MappingTrees
+from lib389.idm.nscontainer import nsContainers
-class FilterRole(DSLdapObject):
- """A single instance of FilterRole entry to create FilterRole role.
+class RoleState(Enum):
+ ACTIVATED = "activated"
+ DIRECTLY_LOCKED = "directly locked through nsDisabledRole"
+ INDIRECTLY_LOCKED = "indirectly locked through a Role"
+ PROBABLY_ACTIVATED = '''probably activated or nsDisabledRole setup and its CoS entries are not
+in a valid state or there is no access to the settings.'''
- :param instance: An instance
- :type instance: lib389.DirSrv
- :param dn: Entry DN
- :type dn: str
- Usages:
- user1 = 'cn=anuj,ou=people,dc=example,ed=com'
- user2 = 'cn=unknownuser,ou=people,dc=example,ed=com'
- role=FilterRole(topo.standalone,'cn=NameofRole,ou=People,dc=example,dc=com')
- role_props={'cn':'Anuj', 'nsRoleFilter':'cn=anuj*'}
- role.create(properties=role_props, basedn=SUFFIX)
- The user1 entry matches the filter (possesses the cn=anuj* attribute with the value anuj)
- therefore, it is a member of this filtered role automatically.
+ def describe(self, role_dn=None):
+ if self.name == "INDIRECTLY_LOCKED" and role_dn is not None:
+ return f'{self.value} - {role_dn}'
+ else:
+ return f'{self.value}'
+
+
+class Role(DSLdapObject):
+ """A single instance of Role entry
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: Entry DN
+ :type dn: str
"""
+
def __init__(self, instance, dn=None):
- super(FilterRole, self).__init__(instance, dn)
+ super(Role, self).__init__(instance, dn)
self._rdn_attribute = 'cn'
self._create_objectclasses = [
'top',
+ 'LDAPsubentry',
'nsRoleDefinition',
- 'nsComplexRoleDefinition',
- 'nsFilteredRoleDefinition'
]
+ def _format_status_message(self, message, role_dn=None):
+ return {"state": message, "role_dn": role_dn}
+
+ def status(self):
+ """Check if role is locked in nsDisabledRole (directly or indirectly)
-class FilterRoles(DSLdapObjects):
- """DSLdapObjects that represents all filtertrole entries in suffix.
-
- This instance is used mainly for search operation filtred role
-
- :param instance: An instance
- :type instance: lib389.DirSrv
- :param basedn: Suffix DN
- :type basedn: str
- :param rdn: The DN that will be combined wit basedn
- :type rdn: str
- Usages:
- role_props={'cn':'Anuj', 'nsRoleFilter':'cn=*'}
- FilterRoles(topo.standalone, DEFAULT_SUFFIX).create(properties=role_props)
- FilterRoles(topo.standalone, DEFAULT_SUFFIX).list()
- user1 = 'cn=anuj,ou=people,dc=example,ed=com'
- user2 = 'uid=unknownuser,ou=people,dc=example,ed=com'
- The user1 entry matches the filter (possesses the cn=* attribute with the value cn)
- therefore, it is a member of this filtered role automatically.
+ :returns: a dict
"""
+
+ inst = self._instance
+ disabled_roles = {}
+ try:
+ mapping_trees = MappingTrees(inst)
+ root_suffix = mapping_trees.get_root_suffix_by_entry(self.dn)
+ roles = Roles(inst, root_suffix)
+ disabled_roles = roles.get_disabled_roles()
+ nested_roles = NestedRoles(inst, root_suffix)
+ disabled_role = nested_roles.get("nsDisabledRole")
+ inact_containers = nsContainers(inst, basedn=root_suffix)
+ inact_container = inact_containers.get('nsAccountInactivationTmp')
+
+ cos_templates = CosTemplates(inst, inact_container.dn)
+ cos_template = cos_templates.get(f'{disabled_role.dn}')
+ cos_template.present('cosPriority', '1')
+ cos_template.present('nsAccountLock', 'true')
+
+ cos_classic_defs = CosClassicDefinitions(inst, root_suffix)
+ cos_classic_def = cos_classic_defs.get('nsAccountInactivation_cos')
+ cos_classic_def.present('cosAttribute', 'nsAccountLock operational')
+ cos_classic_def.present('cosTemplateDn', inact_container.dn)
+ cos_classic_def.present('cosSpecifier', 'nsRole')
+ except ldap.NO_SUCH_OBJECT:
+ return self._format_status_message(RoleState.PROBABLY_ACTIVATED)
+
+ for role, parent in disabled_roles.items():
+ if str.lower(self.dn) == str.lower(role.dn):
+ if parent is None:
+ return self._format_status_message(RoleState.DIRECTLY_LOCKED)
+ else:
+ return self._format_status_message(RoleState.INDIRECTLY_LOCKED, parent)
+
+ return self._format_status_message(RoleState.ACTIVATED)
+
+ def lock(self):
+ """Set the entry dn to nsDisabledRole and ensure it exists"""
+
+ current_status = self.status()
+ if current_status["state"] == RoleState.DIRECTLY_LOCKED:
+ raise ValueError(f"Role is already {current_status['state'].describe()}")
+
+ inst = self._instance
+
+ mapping_trees = MappingTrees(inst)
+ root_suffix = ""
+ root_suffix = mapping_trees.get_root_suffix_by_entry(self.dn)
+
+ if root_suffix:
+ managed_roles = ManagedRoles(inst, root_suffix)
+ managed_role = managed_roles.ensure_state(properties={"cn": "nsManagedDisabledRole"})
+ nested_roles = NestedRoles(inst, root_suffix)
+ try:
+ disabled_role = nested_roles.get("nsDisabledRole")
+ except ldap.NO_SUCH_OBJECT:
+ # We don't use "ensure_state" because we want to preserve the existing attributes
+ disabled_role = nested_roles.create(properties={"cn": "nsDisabledRole",
+ "nsRoleDN": managed_role.dn})
+ disabled_role.add("nsRoleDN", self.dn)
+
+ inact_containers = nsContainers(inst, basedn=root_suffix)
+ inact_container = inact_containers.ensure_state(properties={'cn': 'nsAccountInactivationTmp'})
+
+ cos_templates = CosTemplates(inst, inact_container.dn)
+ cos_templates.ensure_state(properties={'cosPriority': '1',
+ 'nsAccountLock': 'true',
+ 'cn': f'{disabled_role.dn}'})
+
+ cos_classic_defs = CosClassicDefinitions(inst, root_suffix)
+ cos_classic_defs.ensure_state(properties={'cosAttribute': 'nsAccountLock operational',
+ 'cosSpecifier': 'nsRole',
+ 'cosTemplateDn': inact_container.dn,
+ 'cn': 'nsAccountInactivation_cos'})
+
+ def unlock(self):
+ """Remove the entry dn from nsDisabledRole if it exists"""
+
+ inst = self._instance
+ current_status = self.status()
+ if current_status["state"] == RoleState.ACTIVATED:
+ raise ValueError("Role is already active")
+
+ mapping_trees = MappingTrees(inst)
+ root_suffix = mapping_trees.get_root_suffix_by_entry(self.dn)
+ roles = NestedRoles(inst, root_suffix)
+ try:
+ disabled_role = roles.get("nsDisabledRole")
+ # Still we want to ensure that it is not locked directly too
+ disabled_role.ensure_removed("nsRoleDN", self.dn)
+ except ldap.NO_SUCH_OBJECT:
+ pass
+
+ # Notify if it's locked indirectly
+ if current_status["state"] == RoleState.INDIRECTLY_LOCKED:
+ raise ValueError(f"Role is {current_status['state'].describe(current_status['role_dn'])}. Please, deal with it separately")
+
+
+class Roles(DSLdapObjects):
+ """DSLdapObjects that represents all Roles entries
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param basedn: Suffix DN
+ :type basedn: str
+ """
+
def __init__(self, instance, basedn):
- super(FilterRoles, self).__init__(instance)
+ super(Roles, self).__init__(instance)
self._objectclasses = [
'top',
+ 'LDAPsubentry',
'nsRoleDefinition',
- 'nsComplexRoleDefinition',
- 'nsFilteredRoleDefinition'
]
self._filterattrs = ['cn']
self._basedn = basedn
- self._childobject = FilterRole
-
+ self._childobject = Role
-class ManagedRole(DSLdapObject):
- """A single instance of ManagedRole entry to create ManagedRole role.
+ def get_with_type(self, selector=[], dn=None):
+ """Get the correct role type
- :param instance: An instance
- :type instance: lib389.DirSrv
- :param dn: Entry DN
+ :param dn: DN of wanted entry
:type dn: str
+ :param selector: An additional filter to search for, i.e. 'backend_name'. The attributes
+ selected are based on object type, ie user will search for uid and cn.
+ :type dn: str
+
+ :returns: FilteredRole, ManagedRole or NestedRole
+ """
+
+ ROLE_OBJECTCLASSES = {FilteredRole: ['nscomplexroledefinition',
+ 'nsfilteredroledefinition'],
+ ManagedRole: ['nssimpleroledefinition',
+ 'nsmanagedroledefinition'],
+ NestedRole: ['nscomplexroledefinition',
+ 'nsnestedroledefinition']}
+ entry = self.get(selector=selector, dn=dn, json=False)
+ entry_objectclasses = entry.get_attr_vals_utf8_l("objectClass")
+ role_found = False
+ for role, objectclasses in ROLE_OBJECTCLASSES.items():
+ role_found = all(oc in entry_objectclasses for oc in objectclasses)
+ if role_found:
+ return role(self._instance, entry.dn)
+ if not role_found:
+ raise ldap.NO_SUCH_OBJECT("Role definition was not found")
+
+ def get_disabled_roles(self):
+ """Get disabled roles that are usually defined in the cn=nsDisabledRole,ROOT_SUFFIX
+
+ :returns: A dict {role: its_parent, }
+ """
+
+ disabled_role = self.get("nsDisabledRole")
+ roles_inactive = {}
+ result = {}
+
+ # Do this on 0 level of nestedness
+ for role_dn in disabled_role.get_attr_vals_utf8_l("nsRoleDN"):
+ roles_inactive[role_dn] = None
+
+ # We go through the list and check if the role is Nested and
+ # then add its 'nsrole' attributes to the processing list
+ while roles_inactive.items():
+ processing_role_dn, parent = roles_inactive.popitem()
+ # Check if already seen the role and skip it then
+ if processing_role_dn in result.keys():
+ continue
+
+ processing_role = self.get_with_type(dn=processing_role_dn)
+ if isinstance(processing_role, NestedRole):
+ for role_dn in processing_role.get_attr_vals_utf8_l("nsRoleDN"):
+ # We don't need to process children which are already present in the list
+ if role_dn in result.keys() or role_dn in roles_inactive.keys():
+ continue
+ # We are deeper - return its children to the processing and assign the original parent
+ if parent in [role.dn for role in result.keys()]:
+ roles_inactive[role_dn] = parent
+ else:
+ roles_inactive[role_dn] = processing_role_dn
+ # Set the processed role to list
+ result[processing_role] = parent
+
+ return result
+class FilteredRole(Role):
+ """A single instance of FilteredRole entry to create FilteredRole role
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: Entry DN
+ :type dn: str
"""
+
+ def __init__(self, instance, dn=None):
+ super(FilteredRole, self).__init__(instance, dn)
+ self._rdn_attribute = 'cn'
+ self._create_objectclasses = ['nsComplexRoleDefinition', 'nsFilteredRoleDefinition']
+
+
+
+class FilteredRoles(Roles):
+ """DSLdapObjects that represents all filtered role entries
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param basedn: Suffix DN
+ :type basedn: str
+ """
+
+ def __init__(self, instance, basedn):
+ super(FilteredRoles, self).__init__(instance, basedn)
+ self._objectclasses = ['LDAPsubentry', 'nsComplexRoleDefinition', 'nsFilteredRoleDefinition']
+ self._filterattrs = ['cn']
+ self._basedn = basedn
+ self._childobject = FilteredRole
+
+
+class ManagedRole(Role):
+ """A single instance of Managed Role entry
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: Entry DN
+ :type dn: str
+ """
+
def __init__(self, instance, dn=None):
super(ManagedRole, self).__init__(instance, dn)
self._rdn_attribute = 'cn'
- self._create_objectclasses = [
- 'top',
- 'nsRoleDefinition',
- 'nsSimpleRoleDefinition',
- 'nsManagedRoleDefinition'
- ]
+ self._create_objectclasses = ['nsSimpleRoleDefinition', 'nsManagedRoleDefinition']
-class ManagedRoles(DSLdapObjects):
- """DSLdapObjects that represents all ManagedRoles entries in suffix.
+class ManagedRoles(Roles):
+ """DSLdapObjects that represents all Managed Roles entries
- This instance is used mainly for search operation ManagedRoles role
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param basedn: Suffix DN
+ :type basedn: str
+ :param rdn: The DN that will be combined wit basedn
+ :type rdn: str
+ """
- :param instance: An instance
- :type instance: lib389.DirSrv
- :param basedn: Suffix DN
- :type basedn: str
- :param rdn: The DN that will be combined wit basedn
- :type rdn: str
- """
def __init__(self, instance, basedn):
- super(ManagedRoles, self).__init__(instance)
- self._objectclasses = [
- 'top',
- 'nsRoleDefinition',
- 'nsSimpleRoleDefinition',
- 'nsManagedRoleDefinition'
- ]
+ super(ManagedRoles, self).__init__(instance, basedn)
+ self._objectclasses = ['LDAPsubentry', 'nsSimpleRoleDefinition', 'nsManagedRoleDefinition']
self._filterattrs = ['cn']
self._basedn = basedn
self._childobject = ManagedRole
-class NestedRole(DSLdapObject):
- """A single instance of NestedRole entry to create NestedRole role.
-
- :param instance: An instance
- :type instance: lib389.DirSrv
- :param dn: Entry DN
- :type dn: str
+class NestedRole(Role):
+ """A single instance of Nested Role entry
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: Entry DN
+ :type dn: str
"""
+
def __init__(self, instance, dn=None):
super(NestedRole, self).__init__(instance, dn)
self._must_attributes = ['cn', 'nsRoleDN']
self._rdn_attribute = 'cn'
- self._create_objectclasses = [
- 'top',
- 'nsRoleDefinition',
- 'nsComplexRoleDefinition',
- 'ldapSubEntry',
- 'nsNestedRoleDefinition'
- ]
+ self._create_objectclasses = ['nsComplexRoleDefinition', 'nsNestedRoleDefinition']
-class NestedRoles(DSLdapObjects):
+class NestedRoles(Roles):
"""DSLdapObjects that represents all NestedRoles entries in suffix.
- This instance is used mainly for search operation NestedRoles role
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param basedn: Suffix DN
+ :type basedn: str
+ :param rdn: The DN that will be combined wit basedn
+ :type rdn: str
+ """
- :param instance: An instance
- :type instance: lib389.DirSrv
- :param basedn: Suffix DN
- :type basedn: str
- :param rdn: The DN that will be combined wit basedn
- :type rdn: str
- """
def __init__(self, instance, basedn):
- super(NestedRoles, self).__init__(instance)
- self._objectclasses = [
- 'top',
- 'nsRoleDefinition',
- 'nsComplexRoleDefinition',
- 'ldapSubEntry',
- 'nsNestedRoleDefinition'
- ]
+ super(NestedRoles, self).__init__(instance, basedn)
+ self._objectclasses = ['LDAPsubentry', 'nsComplexRoleDefinition', 'nsNestedRoleDefinition']
self._filterattrs = ['cn']
self._basedn = basedn
self._childobject = NestedRole
diff --git a/src/lib389/lib389/mappingTree.py b/src/lib389/lib389/mappingTree.py
index 7a5902056..45f1a9a40 100644
--- a/src/lib389/lib389/mappingTree.py
+++ b/src/lib389/lib389/mappingTree.py
@@ -7,7 +7,7 @@
# --- END COPYRIGHT BLOCK ---
import ldap
-import ldap.dn
+from ldap.dn import str2dn, dn2str
import six
from lib389._constants import *
@@ -395,7 +395,7 @@ class MappingTree(DSLdapObject):
super(MappingTree, self).__init__(instance, dn)
self._rdn_attribute = 'cn'
self._must_attributes = ['cn']
- self._create_objectclasses = ['top', 'extensibleObject', MT_OBJECTCLASS_VALUE]
+ self._create_objectclasses = ['top', 'extensibleObject', 'nsMappingTree']
self._protected = False
def set_parent(self, parent):
@@ -422,9 +422,31 @@ class MappingTrees(DSLdapObjects):
def __init__(self, instance):
super(MappingTrees, self).__init__(instance=instance)
- self._objectclasses = [MT_OBJECTCLASS_VALUE]
- self._filterattrs = ['cn', 'nsslapd-backend' ]
+ self._objectclasses = ['nsMappingTree']
+ self._filterattrs = ['cn', 'nsslapd-backend']
self._childobject = MappingTree
self._basedn = DN_MAPPING_TREE
+ def get_root_suffix_by_entry(self, entry_dn):
+ """Get the root suffix to which the entry belongs
+ :param entry_dn: An entry DN
+ :type entry_dn: str
+ :returns: str
+ """
+
+ mapping_tree_list = sorted(self.list(), key=lambda b: len(b.dn), reverse=True)
+
+ entry_dn_parts = str2dn(entry_dn)
+ processing = True
+ while processing:
+ compare_dn = dn2str(entry_dn_parts)
+ for mapping_tree in mapping_tree_list:
+ if str.lower(compare_dn) == str.lower(mapping_tree.rdn):
+ processing = False
+ return mapping_tree.rdn
+ if entry_dn_parts:
+ entry_dn_parts.pop(0)
+ else:
+ processing = False
+ raise ldap.NO_SUCH_OBJECT(f"{entry_dn} doesn't belong to any suffix")
diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py
index 8271e03e8..a8b13c778 100644
--- a/src/lib389/lib389/plugins.py
+++ b/src/lib389/lib389/plugins.py
@@ -1820,6 +1820,40 @@ class AccountPolicyConfigs(DSLdapObjects):
self._basedn = basedn
+class AccountPolicyEntry(DSLdapObject):
+ """A single instance of Account Policy Plugin entry which is used for CoS
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: Entry DN
+ :type dn: str
+ """
+
+ def __init__(self, instance, dn=None):
+ super(AccountPolicyConfig, self).__init__(instance, dn)
+ self._rdn_attribute = 'cn'
+ self._must_attributes = ['cn']
+ self._create_objectclasses = ['top', 'accountpolicy']
+ self._protected = False
+
+
+class AccountPolicyEntries(DSLdapObjects):
+ """A DSLdapObjects entity which represents Account Policy Plugin entry which is used for CoS
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param basedn: Base DN for all account entries below
+ :type basedn: str
+ """
+
+ def __init__(self, instance, basedn):
+ super(AccountPolicyConfigs, self).__init__(instance)
+ self._objectclasses = ['top', 'accountpolicy']
+ self._filterattrs = ['cn']
+ self._childobject = AccountPolicyEntry
+ self._basedn = basedn
+
+
class DNAPlugin(Plugin):
"""A single instance of Distributed Numeric Assignment plugin entry
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index 10c8caede..51960eb2a 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -31,6 +31,7 @@ import shutil
import ldap
import socket
import time
+from datetime import datetime
import sys
import filecmp
import pwd
@@ -1085,6 +1086,29 @@ def ds_is_newer(*ver):
return ds_is_related('newer', *ver)
+def gentime_to_datetime(gentime):
+ """Convert Generalized time to datetime object
+
+ :param gentime: Time in the format - YYYYMMDDHHMMSSZ (20170126120000Z)
+ :type password: str
+ :returns: datetime.datetime object
+ """
+
+ return datetime.strptime(gentime, '%Y%m%d%H%M%SZ')
+
+
+def gentime_to_posix_time(gentime):
+ """Convert Generalized time to POSIX time format
+
+ :param gentime: Time in the format - YYYYMMDDHHMMSSZ (20170126120000Z)
+ :type password: str
+ :returns: Epoch time int
+ """
+
+ target_timestamp = gentime_to_datetime(gentime)
+ return datetime.timestamp(target_timestamp)
+
+
def getDateTime():
"""
Return the date and time:
| 0 |
28f69b393fd63221894bb3232b0877919854e9ea
|
389ds/389-ds-base
|
Ticket 49639 - Crash when failing to read from SASL conn
Description: This is a regression from ticket 49618, a return code
integer was reset to a unsigned int, when it needed to
remain signed. This allowed an error condition to go
unchecked, which leads to a crash caused by a large
realloc attempt from the overflowed integer result code.
https://pagure.io/389-ds-base/issue/49639
Reviewed by: mreynolds(one line commit rule)
|
commit 28f69b393fd63221894bb3232b0877919854e9ea
Author: Mark Reynolds <[email protected]>
Date: Thu Apr 19 15:49:58 2018 -0400
Ticket 49639 - Crash when failing to read from SASL conn
Description: This is a regression from ticket 49618, a return code
integer was reset to a unsigned int, when it needed to
remain signed. This allowed an error condition to go
unchecked, which leads to a crash caused by a large
realloc attempt from the overflowed integer result code.
https://pagure.io/389-ds-base/issue/49639
Reviewed by: mreynolds(one line commit rule)
diff --git a/ldap/servers/slapd/sasl_io.c b/ldap/servers/slapd/sasl_io.c
index 751832b12..735114842 100644
--- a/ldap/servers/slapd/sasl_io.c
+++ b/ldap/servers/slapd/sasl_io.c
@@ -189,8 +189,8 @@ sasl_io_start_packet(PRFileDesc *fd, PRIntn flags, PRIntervalTime timeout, PRInt
unsigned char buffer[SASL_IO_BUFFER_START_SIZE];
sasl_io_private *sp = sasl_get_io_private(fd);
Connection *c = sp->conn;
- uint32_t amount = sizeof(buffer);
- uint32_t ret = 0;
+ int32_t amount = sizeof(buffer);
+ int32_t ret = 0;
uint32_t packet_length = 0;
int32_t saslio_limit;
| 0 |
f5730129dfbc4ef3808735051b12cbfda518f4fb
|
389ds/389-ds-base
|
Ticket #47772 empty modify returns LDAP_INVALID_DN_SYNTAX
https://fedorahosted.org/389/ticket/47772
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Do not call normalize_mods2bvals if mods is NULL - just allow
the empty modify op to proceed. Since normalize_mods2bvals only cares about
DN syntax attributes, it is appropriate to return LDAP_INVALID_DN_SYNTAX if
normalize_mods2bvals returns NULL.
Since this fix allows NULL mods to proceed throughout the code, I checked for
all places that SLAPI_MODIFY_MODS was used, to make sure we don't try to
dereference NULL mods, and to make sure the NULL mods were handled correctly
otherwise.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit f5730129dfbc4ef3808735051b12cbfda518f4fb
Author: Rich Megginson <[email protected]>
Date: Wed Apr 9 13:43:37 2014 -0600
Ticket #47772 empty modify returns LDAP_INVALID_DN_SYNTAX
https://fedorahosted.org/389/ticket/47772
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Do not call normalize_mods2bvals if mods is NULL - just allow
the empty modify op to proceed. Since normalize_mods2bvals only cares about
DN syntax attributes, it is appropriate to return LDAP_INVALID_DN_SYNTAX if
normalize_mods2bvals returns NULL.
Since this fix allows NULL mods to proceed throughout the code, I checked for
all places that SLAPI_MODIFY_MODS was used, to make sure we don't try to
dereference NULL mods, and to make sure the NULL mods were handled correctly
otherwise.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/chainingdb/cb_config.c b/ldap/servers/plugins/chainingdb/cb_config.c
index 7cbd7baf3..25f466d88 100644
--- a/ldap/servers/plugins/chainingdb/cb_config.c
+++ b/ldap/servers/plugins/chainingdb/cb_config.c
@@ -380,7 +380,7 @@ cb_config_modify_check_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slap
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
- for (i = 0; mods[i] ; i++) {
+ for (i = 0; mods && mods[i] ; i++) {
attr_name = mods[i]->mod_type;
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_FORWARD_CTRLS )) {
@@ -413,7 +413,7 @@ cb_config_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entr
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
- for (i = 0; mods[i] ; i++) {
+ for (i = 0; mods && mods[i] ; i++) {
attr_name = mods[i]->mod_type;
if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_FORWARD_CTRLS )) {
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index 10958d765..fa9c44154 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -306,7 +306,7 @@ int cb_instance_modify_config_check_callback(Slapi_PBlock *pb, Slapi_Entry* entr
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
/* First pass to validate input */
- for (i = 0; mods[i] && LDAP_SUCCESS == rc; i++) {
+ for (i = 0; mods && mods[i] && LDAP_SUCCESS == rc; i++) {
attr_name = mods[i]->mod_type;
/* specific processing for multi-valued attributes */
@@ -379,7 +379,7 @@ int cb_instance_modify_config_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
/* input checked in the preop modify callback */
- for (i = 0; mods[i] && LDAP_SUCCESS == rc; i++) {
+ for (i = 0; mods && mods[i] && LDAP_SUCCESS == rc; i++) {
attr_name = mods[i]->mod_type;
/* specific processing for multi-valued attributes */
diff --git a/ldap/servers/plugins/chainingdb/cb_modify.c b/ldap/servers/plugins/chainingdb/cb_modify.c
index 06e6b820f..65acb58f1 100644
--- a/ldap/servers/plugins/chainingdb/cb_modify.c
+++ b/ldap/servers/plugins/chainingdb/cb_modify.c
@@ -291,7 +291,7 @@ cb_remove_illegal_mods(cb_backend_instance *inst, LDAPMod **mods)
slapi_rwlock_wrlock(inst->rwl_config_lock);
for (j=0; inst->illegal_attributes[j]; j++) {
- for ( i = 0; mods[i] != NULL; i++ ) {
+ for ( i = 0; mods && mods[i] != NULL; i++ ) {
if (slapi_attr_types_equivalent(inst->illegal_attributes[j],mods[i]->mod_type)) {
tmp = mods[i];
for ( j = i; mods[j] != NULL; j++ ) {
diff --git a/ldap/servers/plugins/replication/cl5_config.c b/ldap/servers/plugins/replication/cl5_config.c
index e168bbd50..55727c214 100644
--- a/ldap/servers/plugins/replication/cl5_config.c
+++ b/ldap/servers/plugins/replication/cl5_config.c
@@ -342,7 +342,7 @@ changelog5_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entr
config.trimInterval = CL5_NUM_IGNORE;
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
- for (i = 0; mods[i] != NULL; i++)
+ for (i = 0; mods && mods[i] != NULL; i++)
{
if (mods[i]->mod_op & LDAP_MOD_DELETE)
{
diff --git a/ldap/servers/plugins/replication/legacy_consumer.c b/ldap/servers/plugins/replication/legacy_consumer.c
index aa5a9b548..8eb928bf6 100644
--- a/ldap/servers/plugins/replication/legacy_consumer.c
+++ b/ldap/servers/plugins/replication/legacy_consumer.c
@@ -321,7 +321,7 @@ legacy_consumer_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
slapi_rwlock_wrlock (legacy_consumer_config_lock);
- for (i = 0; (mods[i] && (!not_allowed)); i++)
+ for (i = 0; mods && (mods[i] && (!not_allowed)); i++)
{
if (mods[i]->mod_op & LDAP_MOD_DELETE)
{
diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c
index 8fb5a0242..139c8a31f 100644
--- a/ldap/servers/plugins/replication/repl5_agmt.c
+++ b/ldap/servers/plugins/replication/repl5_agmt.c
@@ -1920,7 +1920,7 @@ agmt_notify_change(Repl_Agmt *agmt, Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
slapi_rwlock_rdlock(agmt->attr_lock);
- for (i = 0; !affects_non_fractional_attribute && NULL != agmt->frac_attrs[i]; i++)
+ for (i = 0; mods && !affects_non_fractional_attribute && NULL != agmt->frac_attrs[i]; i++)
{
for (j = 0; !affects_non_fractional_attribute && NULL != mods[j]; j++)
{
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index a8c72c1c6..f433fc990 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -351,7 +351,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
if (*returncode != LDAP_SUCCESS)
break;
- for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++)
+ for (i = 0; mods && (mods[i] && (LDAP_SUCCESS == rc)); i++)
{
if (*returncode != LDAP_SUCCESS)
break;
@@ -699,7 +699,7 @@ replica_config_post_modify(Slapi_PBlock *pb,
if (*returncode != LDAP_SUCCESS)
break;
- for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++)
+ for (i = 0; mods && (mods[i] && (LDAP_SUCCESS == rc)); i++)
{
if (*returncode != LDAP_SUCCESS)
break;
diff --git a/ldap/servers/plugins/uiduniq/7bit.c b/ldap/servers/plugins/uiduniq/7bit.c
index 3474bf95a..c84c79cd5 100644
--- a/ldap/servers/plugins/uiduniq/7bit.c
+++ b/ldap/servers/plugins/uiduniq/7bit.c
@@ -472,7 +472,7 @@ preop_modify(Slapi_PBlock *pb)
which are add or replace ops and are bvalue encoded
*/
/* find out how many mods meet this criteria */
- for(mods=firstMods;*mods;mods++)
+ for(mods=firstMods;mods && *mods;mods++)
{
mod = *mods;
if ((slapi_attr_type_cmp(mod->mod_type, attr_name, 1) == 0) && /* mod contains target attr */
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index 984b93eca..d4f0c84e7 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -761,7 +761,7 @@ preop_modify(Slapi_PBlock *pb)
which are add or replace ops and are bvalue encoded
*/
/* find out how many mods meet this criteria */
- for(;*mods;mods++)
+ for(;mods && *mods;mods++)
{
mod = *mods;
if ((slapi_attr_type_cmp(mod->mod_type, attrName, 1) == 0) && /* mod contains target attr */
diff --git a/ldap/servers/slapd/auditlog.c b/ldap/servers/slapd/auditlog.c
index f6afd101c..fabe21e13 100644
--- a/ldap/servers/slapd/auditlog.c
+++ b/ldap/servers/slapd/auditlog.c
@@ -154,7 +154,7 @@ write_audit_file(
addlenstr( l, attr_changetype );
addlenstr( l, ": modify\n" );
mods = change;
- for ( j = 0; mods[j] != NULL; j++ )
+ for ( j = 0; (mods != NULL) && (mods[j] != NULL); j++ )
{
int operationtype= mods[j]->mod_op & ~LDAP_MOD_BVALUES;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt_config.c b/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt_config.c
index 0b7deaa45..86479c90a 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt_config.c
@@ -287,7 +287,7 @@ ldbm_instance_attrcrypt_config_modify_callback(Slapi_PBlock *pb, Slapi_Entry *e,
return SLAPI_DSE_CALLBACK_ERROR;
}
- for (i = 0; mods[i] != NULL; i++) {
+ for (i = 0; (mods != NULL) && (mods[i] != NULL); i++) {
char *config_attr = (char *)mods[i]->mod_type;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index ef5cdce9b..0f8cc765e 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -2124,7 +2124,7 @@ int ldbm_config_modify_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore
* 2nd pass: set apply mods to 1 to apply changes to internal storage
*/
for ( apply_mod = 0; apply_mod <= 1 && LDAP_SUCCESS == rc; apply_mod++ ) {
- for (i = 0; mods[i] && LDAP_SUCCESS == rc; i++) {
+ for (i = 0; mods && mods[i] && LDAP_SUCCESS == rc; i++) {
attr_name = mods[i]->mod_type;
/* There are some attributes that we don't care about, like modifiersname. */
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
index 565e9ad69..9b93f9a27 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -781,7 +781,7 @@ ldbm_instance_modify_config_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryB
* 2nd pass: set apply mods to 1 to apply changes to internal storage
*/
for ( apply_mod = 0; apply_mod <= 1 && LDAP_SUCCESS == rc; apply_mod++ ) {
- for (i = 0; mods[i] && LDAP_SUCCESS == rc; i++) {
+ for (i = 0; mods && mods[i] && LDAP_SUCCESS == rc; i++) {
attr_name = mods[i]->mod_type;
if (strcasecmp(attr_name, CONFIG_INSTANCE_SUFFIX) == 0) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index 92692f0e2..8bbeae023 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -253,7 +253,7 @@ modify_apply_check_expand(
* If the objectClass attribute type was modified in any way, expand
* the objectClass values to reflect the inheritance hierarchy.
*/
- for ( i = 0; mods[i] != NULL && !repl_op; ++i ) {
+ for ( i = 0; (mods != NULL) && (mods[i] != NULL) && !repl_op; ++i ) {
if ( 0 == strcasecmp( SLAPI_ATTR_OBJECTCLASS, mods[i]->mod_type )) {
slapi_schema_expand_objectclasses( ec->ep_entry );
break;
@@ -938,7 +938,7 @@ remove_illegal_mods(LDAPMod **mods)
LDAPMod *tmp;
/* remove any attempts by the user to modify these attrs */
- for ( i = 0; mods[i] != NULL; i++ ) {
+ for ( i = 0; (mods != NULL) && (mods[i] != NULL); i++ ) {
if ( strcasecmp( mods[i]->mod_type, numsubordinates ) == 0
|| strcasecmp( mods[i]->mod_type, hassubordinates ) == 0 )
{
diff --git a/ldap/servers/slapd/back-ldif/modify.c b/ldap/servers/slapd/back-ldif/modify.c
index 7fff06707..9a92b1712 100644
--- a/ldap/servers/slapd/back-ldif/modify.c
+++ b/ldap/servers/slapd/back-ldif/modify.c
@@ -560,7 +560,7 @@ apply_mods( Slapi_Entry *e, LDAPMod **mods )
LDAPDebug( LDAP_DEBUG_TRACE, "=> apply_mods\n", 0, 0, 0 );
err = LDAP_SUCCESS;
- for ( j = 0; mods[j] != NULL; j++ ) {
+ for ( j = 0; (mods != NULL) && (mods[j] != NULL); j++ ) {
switch ( mods[j]->mod_op & ~LDAP_MOD_BVALUES ) {
case LDAP_MOD_ADD:
LDAPDebug( LDAP_DEBUG_ARGS, " add: %s\n",
diff --git a/ldap/servers/slapd/configdse.c b/ldap/servers/slapd/configdse.c
index 2cea73afe..339be42d8 100644
--- a/ldap/servers/slapd/configdse.c
+++ b/ldap/servers/slapd/configdse.c
@@ -394,7 +394,7 @@ modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, in
*/
for ( apply_mods = 0; apply_mods <= 1; apply_mods++ ) {
int i = 0;
- for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++) {
+ for (i = 0; mods && (mods[i] && (LDAP_SUCCESS == rc)); i++) {
/* send all aci modifications to the backend */
config_attr = (char *)mods[i]->mod_type;
if (ignore_attr_type(config_attr))
@@ -497,7 +497,7 @@ postop_modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
returntext[0] = '\0';
- for (i = 0; mods[i]; i++) {
+ for (i = 0; mods && mods[i]; i++) {
if (mods[i]->mod_op & LDAP_MOD_REPLACE ) {
/* Check if the server needs to be restarted */
for (j = 0; j < num_requires_restart; j++)
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index d01b285ff..338fffeaf 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -1096,7 +1096,7 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
return SLAPI_DSE_CALLBACK_ERROR;
}
- for (i = 0; mods[i] != NULL; i++) {
+ for (i = 0; (mods != NULL) && (mods[i] != NULL); i++) {
if ( (strcasecmp(mods[i]->mod_type, "cn") == 0) ||
(strcasecmp(mods[i]->mod_type,
MAPPING_TREE_PARENT_ATTRIBUTE) == 0) )
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index 79e7c7c40..7763700ea 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -402,14 +402,17 @@ do_modify( Slapi_PBlock *pb )
mods = slapi_mods_get_ldapmods_passout (&smods);
/* normalize the mods */
- normalized_mods = normalize_mods2bvals((const LDAPMod**)mods);
- ldap_mods_free (mods, 1 /* Free the Array and the Elements */);
- if (normalized_mods == NULL) {
- op_shared_log_error_access(pb, "MOD", rawdn?rawdn:"",
- "mod includes invalid dn format");
- send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX, NULL,
- "mod includes invalid dn format", 0, NULL);
- goto free_and_return;
+ if (mods) {
+ normalized_mods = normalize_mods2bvals((const LDAPMod**)mods);
+ ldap_mods_free (mods, 1 /* Free the Array and the Elements */);
+ if (normalized_mods == NULL) {
+ /* NOTE: normalize_mods2bvals only handles DN syntax currently */
+ op_shared_log_error_access(pb, "MOD", rawdn?rawdn:"",
+ "mod includes invalid dn format");
+ send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX, NULL,
+ "mod includes invalid dn format", 0, NULL);
+ goto free_and_return;
+ }
}
slapi_pblock_set(pb, SLAPI_MODIFY_MODS, normalized_mods);
@@ -1445,7 +1448,7 @@ hash_rootpw (LDAPMod **mods)
return 0;
}
- for (i=0; mods[i] != NULL; i++) {
+ for (i=0; (mods != NULL) && (mods[i] != NULL); i++) {
LDAPMod *mod = mods[i];
if (strcasecmp (mod->mod_type, CONFIG_ROOTPW_ATTRIBUTE) != 0)
continue;
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 24febadf0..d6aae5800 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -2082,7 +2082,7 @@ modify_schema_dse (Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entr
* True for DS 4.x as well, although it tried to keep going even after
* an error was detected (which was very wrong).
*/
- for (i = 0; rc == SLAPI_DSE_CALLBACK_OK && mods[i]; i++) {
+ for (i = 0; rc == SLAPI_DSE_CALLBACK_OK && mods && mods[i]; i++) {
schema_dse_attr_name = (char *) mods[i]->mod_type;
num_mods++; /* incr the number of mods */
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index 5e03bc255..6340db8cc 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -792,7 +792,7 @@ static int task_modify(Slapi_PBlock *pb, Slapi_Entry *e,
/* ignore eAfter, just scan the mods for anything unacceptable */
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
- for (i = 0; mods[i] != NULL; i++) {
+ for (i = 0; (mods != NULL) && (mods[i] != NULL); i++) {
/* for some reason, "modifiersName" and "modifyTimestamp" are
* stuck in by the server */
if ((strcasecmp(mods[i]->mod_type, "ttl") != 0) &&
diff --git a/ldap/servers/slapd/test-plugins/testpostop.c b/ldap/servers/slapd/test-plugins/testpostop.c
index f18f4ab17..d91ddd473 100644
--- a/ldap/servers/slapd/test-plugins/testpostop.c
+++ b/ldap/servers/slapd/test-plugins/testpostop.c
@@ -355,7 +355,7 @@ write_changelog(
that has been added, replaced, or deleted. */
fprintf( fp, "changetype: modify\n" );
mods = (LDAPMod **)change;
- for ( j = 0; mods[j] != NULL; j++ ) {
+ for ( j = 0; (mods != NULL) && (mods[j] != NULL); j++ ) {
switch ( mods[j]->mod_op & ~LDAP_MOD_BVALUES ) {
case LDAP_MOD_ADD:
fprintf( fp, "add: %s\n", mods[j]->mod_type );
| 0 |
e57cfacec154d8f473291db43c0d429ca519d400
|
389ds/389-ds-base
|
Update packaging for ntds
|
commit e57cfacec154d8f473291db43c0d429ca519d400
Author: David Boreham <[email protected]>
Date: Thu May 12 03:18:24 2005 +0000
Update packaging for ntds
diff --git a/ldap/servers/ntds/wrapper/usersync.conf b/ldap/servers/ntds/wrapper/usersync.conf
index 015a20e2b..0a77bf9c3 100644
--- a/ldap/servers/ntds/wrapper/usersync.conf
+++ b/ldap/servers/ntds/wrapper/usersync.conf
@@ -37,8 +37,13 @@
# All rights reserved.
# END COPYRIGHT BLOCK
#
-server.net.ldap.port=1024
-server.net.ldaps.port=1025
+
+#server.net.ldap.port=389
+#server.net.ldaps.port=636
+#server.net.admin.password=changeit
+#javax.net.ssl.keyStore=c:\\Path\\To\\Fedora Directory Synchronization\\conf\\keystore
+#javax.net.ssl.keyStorePassword=changeit
+#server.net.ldaps.enable=true
server.db.partition.suffix.usersync=dc=example,dc=com
# do not modify beyond this point
diff --git a/ldap/servers/ntds/wrapper/wix/ntds.wxs b/ldap/servers/ntds/wrapper/wix/ntds.wxs
index 6f3e4bf0c..f6938cc6f 100644
--- a/ldap/servers/ntds/wrapper/wix/ntds.wxs
+++ b/ldap/servers/ntds/wrapper/wix/ntds.wxs
@@ -53,7 +53,7 @@
<Directory Id='INSTALLDIR' Name='UserSync' LongName='Fedora Directory Synchronization'>
<Directory Id='bin' Name='bin'>
-<Component Id='bin'>
+<Component Id='bin' Guid='2354cddf-a2e1-4c80-836b-0ed9302d8a2a'>
<File Id='apachejar' Name='apache~1.jar' LongName='apacheds-main.jar' DiskId='1' src='bin\apacheds-main.jar' Vital='yes' />
<File Id='install' Name='instal~1.bat' LongName='installuseresync.bat' DiskId='1' src='bin\installusersync.bat' Vital='yes' />
<File Id='jnetmanjar' Name='jnetman.jar' DiskId='1' src='bin\jnetman.jar' Vital='yes' />
@@ -65,14 +65,14 @@
</Directory>
<Directory Id='conf' Name='conf'>
-<Component Id='conf'>
+<Component Id='conf' Guid='c3de9b1d-d818-4998-aa61-b494f96068be'>
<File Id='usersyncconf' Name='usersy~1.con' LongName='usersync.conf' DiskId='1' src='conf\usersync.conf' Vital='yes' />
<File Id='wrapperconf' Name='wrappe~1.con' LongName='wrapper.conf' DiskId='1' src='conf\wrapper.conf' Vital='yes' />
</Component>
</Directory>
<Directory Id='lib' Name='lib'>
-<Component Id='lib'>
+<Component Id='lib' Guid='abad968e-3799-419f-9ffb-ce5387c563cd'>
<File Id='netmandll' Name='jnetman.dll' DiskId='1' src='lib\jnetman.dll' Vital='yes' />
<File Id='wrapperlib' Name='wrapper.dll' DiskId='1' src='lib\wrapper.dll' Vital='yes' />
<File Id='wrapperjar' Name='wrapper.jar' DiskId='1' src='lib\wrapper.jar' Vital='yes' />
@@ -81,7 +81,7 @@
<Directory Id='logs' Name='logs'>
-<Component Id='logs' SharedDllRefCount='no' KeyPath='no' NeverOverwrite='no' Permanent='no' Transitive='no'
+<Component Id='logs' SharedDllRefCount='no' KeyPath='no' NeverOverwrite='no' Permanent='no' Transitive='no' Guid='2ee0e998-e326-4310-888e-a0470d266112'
Win64='no' Location='either'>
<CreateFolder/>
</Component>
| 0 |
255b3031c2b44888c40f5254a34c7fd741c66533
|
389ds/389-ds-base
|
Fix for 154837 : non-sync'ed group entries get backed out
|
commit 255b3031c2b44888c40f5254a34c7fd741c66533
Author: David Boreham <[email protected]>
Date: Fri Apr 22 15:58:27 2005 +0000
Fix for 154837 : non-sync'ed group entries get backed out
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index 0bf13d54a..b01e3705b 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -66,7 +66,7 @@ static int windows_get_local_entry(const Slapi_DN* local_dn,Slapi_Entry **local_
static int windows_get_local_entry_by_uniqueid(Private_Repl_Protocol *prp,const char* uniqueid,Slapi_Entry **local_entry);
static int map_entry_dn_outbound(Slapi_Entry *e, const Slapi_DN **dn, Private_Repl_Protocol *prp, int *missing_entry, int want_guid);
static char* extract_ntuserdomainid_from_entry(Slapi_Entry *e);
-static int windows_get_remote_entry (Private_Repl_Protocol *prp, Slapi_DN* remote_dn,Slapi_Entry **remote_entry);
+static int windows_get_remote_entry (Private_Repl_Protocol *prp, const Slapi_DN* remote_dn,Slapi_Entry **remote_entry);
static const char* op2string (int op);
static int is_subject_of_agreemeent_remote(Slapi_Entry *e, const Repl_Agmt *ra);
static int map_entry_dn_inbound(Slapi_Entry *e, const Slapi_DN **dn, const Repl_Agmt *ra);
@@ -193,8 +193,8 @@ static windows_attribute_map user_attribute_map[] =
{ "codePage", "ntUserCodePage", bidirectional, always, normal},
{ "logonHours", "ntUserLogonHours", bidirectional, always, normal},
{ "maxStorage", "ntUserMaxStorage", bidirectional, always, normal},
- { "profilePath", "ntUserParms", bidirectional, always, normal},
- { "userParameters", "ntUserProfile", bidirectional, always, normal},
+ { "profilePath", "ntUserProfile", bidirectional, always, normal},
+ { "userParameters", "ntUserParms", bidirectional, always, normal},
{ "userWorkstations", "ntUserWorkstations", bidirectional, always, normal},
{ "sAMAccountName", "ntUserDomainId", bidirectional, createonly, normal},
/* cn is a naming attribute in AD, so we don't want to change it after entry creation */
@@ -260,12 +260,12 @@ windows_dump_entry(const char *string, Slapi_Entry *e)
if (buffer)
{
slapi_ch_free((void**)&buffer);
- }
+ }
}
}
static void
-map_dn_values(Private_Repl_Protocol *prp,Slapi_ValueSet *original_values, Slapi_ValueSet **mapped_values, int to_windows)
+map_dn_values(Private_Repl_Protocol *prp,Slapi_ValueSet *original_values, Slapi_ValueSet **mapped_values, int to_windows, int return_originals)
{
Slapi_ValueSet *new_vs = NULL;
Slapi_Value *original_value = NULL;
@@ -305,7 +305,13 @@ map_dn_values(Private_Repl_Protocol *prp,Slapi_ValueSet *original_values, Slapi_
if (!missing_entry)
{
/* Success */
- new_dn_string = slapi_ch_strdup(slapi_sdn_get_dn(remote_dn));
+ if (return_originals)
+ {
+ new_dn_string = slapi_ch_strdup(slapi_sdn_get_dn(slapi_entry_get_sdn_const(local_entry)));
+ } else
+ {
+ new_dn_string = slapi_ch_strdup(slapi_sdn_get_dn(remote_dn));
+ }
}
slapi_sdn_free(&remote_dn);
}
@@ -324,18 +330,30 @@ map_dn_values(Private_Repl_Protocol *prp,Slapi_ValueSet *original_values, Slapi_
Slapi_DN *local_dn = NULL;
/* Try to get the remote entry */
retval = windows_get_remote_entry(prp,original_dn,&remote_entry);
- is_ours = is_subject_of_agreemeent_remote(remote_entry,prp->agmt);
- if (is_ours)
+ if (remote_entry && 0 == retval)
{
- retval = map_entry_dn_inbound(remote_entry,&local_dn,prp->agmt);
- if (0 == retval && local_dn)
- {
- new_dn_string = slapi_ch_strdup(slapi_sdn_get_dn(local_dn));
- slapi_sdn_free(&local_dn);
- } else
+ is_ours = is_subject_of_agreemeent_remote(remote_entry,prp->agmt);
+ if (is_ours)
{
- slapi_log_error(SLAPI_LOG_REPL, NULL, "map_dn_values: no remote entry found for %s\n", original_dn_string);
+ retval = map_entry_dn_inbound(remote_entry,&local_dn,prp->agmt);
+ if (0 == retval && local_dn)
+ {
+ if (return_originals)
+ {
+ new_dn_string = slapi_ch_strdup(slapi_sdn_get_dn(slapi_entry_get_sdn_const(remote_entry)));
+ } else
+ {
+ new_dn_string = slapi_ch_strdup(slapi_sdn_get_dn(local_dn));
+ }
+ slapi_sdn_free(&local_dn);
+ } else
+ {
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "map_dn_values: no local dn found for %s\n", original_dn_string);
+ }
}
+ } else
+ {
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "map_dn_values: no remote entry found for %s\n", original_dn_string);
}
if (remote_entry)
{
@@ -453,6 +471,10 @@ windows_acquire_replica(Private_Repl_Protocol *prp, RUV **ruv, int check_ruv)
windows_dump_ruvs(supl_ruv_obj,cons_ruv_obj);
is_newer = ruv_is_newer ( supl_ruv_obj, cons_ruv_obj );
+ if (is_newer)
+ {
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "acquire_replica, supplier RUV is newer\n");
+ }
/* Handle the pristine case */
if (cons_ruv_obj == NULL)
@@ -641,32 +663,30 @@ static int
windows_entry_has_attr_and_value(Slapi_Entry *e, const char *attrname, char *value)
{
int retval = 0;
- Slapi_Attr *attr = 0;
- if (!e || !attrname)
+ Slapi_Attr *attr = NULL;
+ if (NULL == e || NULL == attrname)
+ {
return retval;
-
+ }
/* see if the entry has the specified attribute name */
- if (!slapi_entry_attr_find(e, attrname, &attr) && attr)
+ if (0 == slapi_entry_attr_find(e, attrname, &attr) && attr)
{
/* if value is not null, see if the attribute has that
value */
- if (!value)
+ if (value)
{
- retval = 1;
- }
- else
- {
- Slapi_Value *v = 0;
+ Slapi_Value *v = NULL;
int index = 0;
for (index = slapi_attr_first_value(attr, &v);
v && (index != -1);
index = slapi_attr_next_value(attr, index, &v))
{
const char *s = slapi_value_get_string(v);
- if (!s)
+ if (NULL == s)
+ {
continue;
-
- if (!strcasecmp(s, value))
+ }
+ if (0 == strcasecmp(s, value))
{
retval = 1;
break;
@@ -739,12 +759,12 @@ delete_remote_entry_allowed(Slapi_Entry *e)
if (!is_user && !is_group)
{
/* Neither fish nor foul.. */
- return -1;
+ return 0;
}
if (is_user && is_group)
{
/* Now that's just really strange... */
- return -1;
+ return 0;
}
if (is_user)
{
@@ -1141,7 +1161,7 @@ windows_create_remote_entry(Private_Repl_Protocol *prp,Slapi_Entry *original_ent
if (mapdn)
{
Slapi_ValueSet *mapped_values = NULL;
- map_dn_values(prp,vs,&mapped_values, 1 /* to windows */);
+ map_dn_values(prp,vs,&mapped_values, 1 /* to windows */,0);
if (mapped_values)
{
slapi_entry_add_valueset(new_entry,new_type,mapped_values);
@@ -1282,7 +1302,7 @@ windows_map_mods_for_replay(Private_Repl_Protocol *prp,LDAPMod **original_mods,
vs = slapi_valueset_new();
slapi_mod_init_byref(&smod,mod);
slapi_valueset_set_from_smod(vs, &smod);
- map_dn_values(prp,vs,&mapped_values, 1 /* to windows */);
+ map_dn_values(prp,vs,&mapped_values, 1 /* to windows */,0);
if (mapped_values)
{
slapi_mods_add_mod_values(&mapped_smods,mod->mod_op,mapped_type,valueset_get_valuearray(mapped_values));
@@ -1413,7 +1433,7 @@ find_entry_by_attr_value_remote(const char *attribute, const char *value, Slapi_
/* Search for an entry in AD by DN */
static int
-windows_get_remote_entry (Private_Repl_Protocol *prp, Slapi_DN* remote_dn,Slapi_Entry **remote_entry)
+windows_get_remote_entry (Private_Repl_Protocol *prp, const Slapi_DN* remote_dn,Slapi_Entry **remote_entry)
{
int retval = 0;
ConnResult cres = 0;
@@ -2116,7 +2136,7 @@ windows_create_local_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry,
if (mapdn)
{
Slapi_ValueSet *mapped_values = NULL;
- map_dn_values(prp,vs,&mapped_values, 0 /* from windows */);
+ map_dn_values(prp,vs,&mapped_values, 0 /* from windows */,0);
if (mapped_values)
{
slapi_entry_add_valueset(local_entry,new_type,mapped_values);
@@ -2177,6 +2197,48 @@ error:
return retval;
}
+/* Function to generate the correct mods to bring 'local' attribute values into consistency with given 'remote' values */
+/* 'local' and 'remote' in quotes because we actually use this function in both directions */
+/* This function expects the value sets to have been already pruned to exclude values that are not
+ * subject to the agreement and present in the peer. */
+static int
+windows_generate_dn_value_mods(char *local_type, const Slapi_Attr *attr, Slapi_Mods *smods, Slapi_ValueSet *remote_values, Slapi_ValueSet *local_values, int *do_modify)
+{
+ int ret = 0;
+ int i = 0;
+ Slapi_Value *rv = NULL;
+ Slapi_Value *lv = NULL;
+ /* We need to generate an ADD mod for each entry that is in the remote values but not in the local values */
+ /* Iterate over the remote values */
+ i = slapi_valueset_first_value(remote_values,&rv);
+ while (NULL != rv)
+ {
+ const char *remote_dn = slapi_value_get_string(rv);
+ int value_present_in_local_values = (NULL != slapi_valueset_find(attr, local_values, rv));
+ if (!value_present_in_local_values)
+ {
+ slapi_mods_add_string(smods,LDAP_MOD_ADD,local_type,remote_dn);
+ *do_modify = 1;
+ }
+ i = slapi_valueset_next_value(remote_values,i,&rv);
+ }
+ /* We need to generate a DEL mod for each entry that is in the local values but not in the remote values */
+ /* Iterate over the local values */
+ i = slapi_valueset_first_value(local_values,&lv);
+ while (NULL != lv)
+ {
+ const char *local_dn = slapi_value_get_string(lv);
+ int value_present_in_remote_values = (NULL != slapi_valueset_find(attr, remote_values, lv));
+ if (!value_present_in_remote_values)
+ {
+ slapi_mods_add_string(smods,LDAP_MOD_DELETE,local_type,local_dn);
+ *do_modify = 1;
+ }
+ i = slapi_valueset_next_value(local_values,i,&lv);
+ }
+ return ret;
+}
+
static int
windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry,Slapi_Entry *local_entry, int to_windows, Slapi_Mods *smods, int *do_modify)
{
@@ -2244,29 +2306,46 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
/* Is the attribute present on the local entry ? */
if (is_present_local && !is_guid)
{
- int values_equal = attr_compare_equal(attr,local_attr);
- /* If it is then we need to replace the local values with the remote values if they are different */
- if (!values_equal)
+ if (!mapdn)
{
- if (mapdn)
+ int values_equal = attr_compare_equal(attr,local_attr);
+ /* If it is then we need to replace the local values with the remote values if they are different */
+ if (!values_equal)
{
- Slapi_ValueSet *mapped_values = NULL;
- map_dn_values(prp,vs,&mapped_values, to_windows);
- if (mapped_values)
- {
- slapi_mods_add_mod_values(smods,LDAP_MOD_REPLACE,local_type,valueset_get_valuearray(mapped_values));
- slapi_valueset_free(mapped_values);
- mapped_values = NULL;
- }
+ slapi_mods_add_mod_values(smods,LDAP_MOD_REPLACE,local_type,valueset_get_valuearray(vs));
+ *do_modify = 1;
} else
{
- slapi_mods_add_mod_values(smods,LDAP_MOD_REPLACE,local_type,valueset_get_valuearray(vs));
+ slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name,
+ "windows_update_local_entry: %s, %s : values are equal\n", slapi_sdn_get_dn(slapi_entry_get_sdn_const(local_entry)), local_type);
+ }
+ } else {
+ /* A dn-valued attribute : need to take special steps */
+ Slapi_ValueSet *mapped_remote_values = NULL;
+ /* First map all the DNs to that they're in a consistent domain */
+ map_dn_values(prp,vs,&mapped_remote_values, to_windows,0);
+ if (mapped_remote_values)
+ {
+ Slapi_ValueSet *local_values = NULL;
+ Slapi_ValueSet *restricted_local_values = NULL;
+ /* Now do a compare on the values, generating mods to bring them into consistency (if any) */
+ /* We ignore any DNs that are outside the scope of the agreement (on both sides) */
+ slapi_attr_get_valueset(local_attr,&local_values);
+ map_dn_values(prp,local_values,&restricted_local_values,!to_windows,1);
+ if (restricted_local_values)
+ {
+ windows_generate_dn_value_mods(local_type,local_attr,smods,mapped_remote_values,restricted_local_values,do_modify);
+ slapi_valueset_free(restricted_local_values);
+ restricted_local_values = NULL;
+ }
+ slapi_valueset_free(mapped_remote_values);
+ mapped_remote_values = NULL;
+ if (local_values)
+ {
+ slapi_valueset_free(local_values);
+ local_values = NULL;
+ }
}
- *do_modify = 1;
- } else
- {
- slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name,
- "windows_update_local_entry: %s, %s : values are equal\n", slapi_sdn_get_dn(slapi_entry_get_sdn_const(local_entry)), local_type);
}
} else
{
@@ -2288,7 +2367,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
if (mapdn)
{
Slapi_ValueSet *mapped_values = NULL;
- map_dn_values(prp,vs,&mapped_values, to_windows);
+ map_dn_values(prp,vs,&mapped_values, to_windows,0);
if (mapped_values)
{
slapi_mods_add_mod_values(smods,LDAP_MOD_ADD,local_type,valueset_get_valuearray(mapped_values));
@@ -2314,6 +2393,10 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
local_type = NULL;
}
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL) && *do_modify)
+ {
+ slapi_mods_dump(smods,"windows sync");
+ }
LDAPDebug( LDAP_DEBUG_TRACE, "<= windows_update_local_entry: %d\n", retval, 0, 0 );
return retval;
}
@@ -2601,7 +2684,20 @@ windows_process_dirsync_entry(Private_Repl_Protocol *prp,Slapi_Entry *e, int is_
if ((0 == rc) && local_entry)
{
/* Since the entry exists we should now make it match the entry we received from AD */
- rc = windows_update_local_entry(prp, e, local_entry);
+ /* Actually we are better off simply fetching the entire entry from AD and using that
+ * because otherwise we don't get all the attributes we need to make sense of it such as
+ * objectclass */
+ Slapi_Entry *remote_entry = NULL;
+ windows_get_remote_entry(prp,slapi_entry_get_sdn_const(e),&remote_entry);
+ if (remote_entry)
+ {
+ rc = windows_update_local_entry(prp, remote_entry, local_entry);
+ slapi_entry_free(remote_entry);
+ remote_entry = NULL;
+ } else
+ {
+ slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name,"%s: windows_process_dirsync_entry: failed to fetch inbound entry.\n",agmt_get_long_name(prp->agmt));
+ }
slapi_entry_free(local_entry);
if (rc) {
/* Something bad happened */
diff --git a/ldap/servers/plugins/replication/windows_tot_protocol.c b/ldap/servers/plugins/replication/windows_tot_protocol.c
index deea96087..ba34dd937 100644
--- a/ldap/servers/plugins/replication/windows_tot_protocol.c
+++ b/ldap/servers/plugins/replication/windows_tot_protocol.c
@@ -199,6 +199,11 @@ windows_tot_run(Private_Repl_Protocol *prp)
/* Now update our consumer RUV for this agreement.
* This ensures that future incrememental updates work.
*/
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL))
+ {
+ slapi_log_error(SLAPI_LOG_REPL, NULL, "total update setting consumer RUV:\n");
+ ruv_dump (starting_ruv, "consumer", NULL);
+ }
agmt_set_consumer_ruv(prp->agmt, starting_ruv );
}
| 0 |
b23201b34cb68de8b0a8720b51b29fee7d6fa429
|
389ds/389-ds-base
|
Ticket 49295 - Fix CI tests and compiler warnings
Description: Fix CI and compiler warnings
https://pagure.io/389-ds-base/issue/49295
Reviewed by: mreynolds(one line commit rule)
|
commit b23201b34cb68de8b0a8720b51b29fee7d6fa429
Author: Mark Reynolds <[email protected]>
Date: Fri Jul 7 14:59:08 2017 -0400
Ticket 49295 - Fix CI tests and compiler warnings
Description: Fix CI and compiler warnings
https://pagure.io/389-ds-base/issue/49295
Reviewed by: mreynolds(one line commit rule)
diff --git a/dirsrvtests/tests/tickets/ticket48759_test.py b/dirsrvtests/tests/tickets/ticket48759_test.py
index 3406a7881..35bbec9cb 100644
--- a/dirsrvtests/tests/tickets/ticket48759_test.py
+++ b/dirsrvtests/tests/tickets/ticket48759_test.py
@@ -13,7 +13,8 @@ from lib389.tasks import *
from lib389.topologies import topology_st
from lib389._constants import (PLUGIN_MEMBER_OF, DEFAULT_SUFFIX, REPLICAROLE_MASTER, REPLICAID_MASTER_1,
- DN_CONFIG, PLUGIN_RETRO_CHANGELOG, REPLICA_PRECISE_PURGING, REPLICA_PURGE_DELAY)
+ DN_CONFIG, PLUGIN_RETRO_CHANGELOG, REPLICA_PRECISE_PURGING, REPLICA_PURGE_DELAY,
+ REPLICA_PURGE_INTERVAL)
log = logging.getLogger(__name__)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 1592f9dcd..37eb5e71b 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1213,7 +1213,7 @@ void slapd_daemon( daemon_ports_t *ports, ns_thrpool_t *tp )
threads = g_get_active_threadcnt();
if ( threads > 0 ) {
slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon",
- "slapd shutting down - waiting for %d thread%s to terminate\n",
+ "slapd shutting down - waiting for %lu thread%s to terminate\n",
threads, ( threads > 1 ) ? "s" : "");
}
@@ -1252,7 +1252,7 @@ void slapd_daemon( daemon_ports_t *ports, ns_thrpool_t *tp )
DS_Sleep(PR_INTERVAL_NO_WAIT);
if ( threads != g_get_active_threadcnt() ) {
slapi_log_err(SLAPI_LOG_TRACE, "slapd_daemon",
- "slapd shutting down - waiting for %d threads to terminate\n",
+ "slapd shutting down - waiting for %lu threads to terminate\n",
g_get_active_threadcnt());
threads = g_get_active_threadcnt();
}
diff --git a/ldap/servers/slapd/monitor.c b/ldap/servers/slapd/monitor.c
index 8dd27af2b..2271bfa63 100644
--- a/ldap/servers/slapd/monitor.c
+++ b/ldap/servers/slapd/monitor.c
@@ -59,7 +59,7 @@ monitor_info(Slapi_PBlock *pb __attribute__((unused)),
attrlist_replace( &e->e_attrs, "version", vals );
slapi_ch_free( (void **) &val.bv_val );
- val.bv_len = snprintf( buf, sizeof(buf), "%d", g_get_active_threadcnt() );
+ val.bv_len = snprintf( buf, sizeof(buf), "%lu", g_get_active_threadcnt() );
val.bv_val = buf;
attrlist_replace( &e->e_attrs, "threads", vals );
| 0 |
d09a57d4b5268e46477366aa67c2734ed3cd158c
|
389ds/389-ds-base
|
Add Cockpit UI fonts
On F28 these fonts are requested by both Firefox and Chrome so I'm adding them back.
Reviewed by: mreynolds
|
commit d09a57d4b5268e46477366aa67c2734ed3cd158c
Author: Mark Reynolds <[email protected]>
Date: Thu May 31 15:28:25 2018 -0400
Add Cockpit UI fonts
On F28 these fonts are requested by both Firefox and Chrome so I'm adding them back.
Reviewed by: mreynolds
diff --git a/src/cockpit/389-console/fonts/OpenSans-Light-webfont.ttf b/src/cockpit/389-console/fonts/OpenSans-Light-webfont.ttf
new file mode 100644
index 000000000..0d381897d
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Light-webfont.ttf differ
diff --git a/src/cockpit/389-console/fonts/OpenSans-Light-webfont.woff b/src/cockpit/389-console/fonts/OpenSans-Light-webfont.woff
new file mode 100644
index 000000000..fb34cf388
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Light-webfont.woff differ
diff --git a/src/cockpit/389-console/fonts/OpenSans-Light-webfont.woff2 b/src/cockpit/389-console/fonts/OpenSans-Light-webfont.woff2
new file mode 100644
index 000000000..9a71d1c78
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Light-webfont.woff2 differ
diff --git a/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.ttf b/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.ttf
new file mode 100644
index 000000000..db433349b
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.ttf differ
diff --git a/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.woff b/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.woff
new file mode 100644
index 000000000..1251d51a6
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.woff differ
diff --git a/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.woff2 b/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.woff2
new file mode 100644
index 000000000..0964c7c46
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Regular-webfont.woff2 differ
diff --git a/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.ttf b/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.ttf
new file mode 100644
index 000000000..1a7679e39
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.ttf differ
diff --git a/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.woff b/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.woff
new file mode 100644
index 000000000..409c725d0
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.woff differ
diff --git a/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.woff2 b/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.woff2
new file mode 100644
index 000000000..d088697a0
Binary files /dev/null and b/src/cockpit/389-console/fonts/OpenSans-Semibold-webfont.woff2 differ
| 0 |
22107650f6c09c38420976c988cdb94c1cbc6764
|
389ds/389-ds-base
|
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.
|
commit 22107650f6c09c38420976c988cdb94c1cbc6764
Author: Nathan Kinder <[email protected]>
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 a015eaedc..670ae6445 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 fc520c933..a245a8da7 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 b69b2cd8c..1080436ef 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 cc4be8e45..ee7c7c02b 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);
| 0 |
b07e0183072bc11fe48248823b1e9ca18e9105ef
|
389ds/389-ds-base
|
Fix display name to say Fedora...
|
commit b07e0183072bc11fe48248823b1e9ca18e9105ef
Author: David Boreham <[email protected]>
Date: Wed May 4 23:52:03 2005 +0000
Fix display name to say Fedora...
diff --git a/ldap/servers/ntds/wrapper/wix/ntds.wxs b/ldap/servers/ntds/wrapper/wix/ntds.wxs
index 7a728473e..6f3e4bf0c 100644
--- a/ldap/servers/ntds/wrapper/wix/ntds.wxs
+++ b/ldap/servers/ntds/wrapper/wix/ntds.wxs
@@ -36,21 +36,21 @@
All rights reserved.
END COPYRIGHT BLOCK -->
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
- <Product Name='NT User Synchronization' Id='9FABDEC3-CAA0-40D5-871F-A0E1759C38C1'
+ <Product Name='Fedora Directory Synchronization' Id='9FABDEC3-CAA0-40D5-871F-A0E1759C38C1'
Language='1033' Codepage='1252'
- Version='1.0.0' Manufacturer='Brandx'>
+ Version='1.0.0' Manufacturer='Fedora'>
<Package Id='????????-????-????-????-????????????' Keywords='Installer'
- Description="User Synchronization Installer"
- Manufacturer='Brandx'
+ Description="Fedora Directory Synchronization Installer"
+ Manufacturer='Fedora'
InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />
<Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
- <Property Id='DiskPrompt' Value="User Sync Installation [1]" />
+ <Property Id='DiskPrompt' Value="Fedora Directory Synchronization Installation [1]" />
<Directory Id='ProgramFilesFolder' Name='PFiles'>
-<Directory Id='INSTALLDIR' Name='UserSync' LongName='NT User Synchronization'>
+<Directory Id='INSTALLDIR' Name='UserSync' LongName='Fedora Directory Synchronization'>
<Directory Id='bin' Name='bin'>
<Component Id='bin'>
@@ -92,7 +92,7 @@
</Directory>
</Directory>
-<Feature Id='All' Title='NT User Synchronization' Description='The complete package.'
+<Feature Id='All' Title='Fedora Directory Synchronization' Description='The complete package.'
TypicalDefault='install' Display='expand' Level='1'
ConfigurableDirectory='INSTALLDIR'>
<ComponentRef Id='bin'/>
| 0 |
3abcd685cfa4784715e97957b13eaef14ffe47c9
|
389ds/389-ds-base
|
Ticket 49298 - fix missing header
Bug Description: While adding fsync to dirs for 49298 I
missed a compiler warning (there were many other shadow warns).
Fix Description: Add the missing header.
https://pagure.io/389-ds-base/issue/49298
Author: wibrown
Review by: one line rule
|
commit 3abcd685cfa4784715e97957b13eaef14ffe47c9
Author: William Brown <[email protected]>
Date: Thu Jul 6 12:33:41 2017 +1000
Ticket 49298 - fix missing header
Bug Description: While adding fsync to dirs for 49298 I
missed a compiler warning (there were many other shadow warns).
Fix Description: Add the missing header.
https://pagure.io/389-ds-base/issue/49298
Author: wibrown
Review by: one line rule
diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c
index becaacef1..fa1aaccc1 100644
--- a/ldap/servers/slapd/dse.c
+++ b/ldap/servers/slapd/dse.c
@@ -40,6 +40,8 @@
#include "slap.h"
#include <pwd.h>
+#include <unistd.h> /* provides fsync/close */
+
/* #define SLAPI_DSE_DEBUG */ /* define this to force trace log */
/* messages to always be logged */
| 0 |
69df678cfed4d38ab34eed8aedcf34daa47e4455
|
389ds/389-ds-base
|
Issue 6753 - Port ticket tests 48294 & 48295
Description: Porting ticket 48294 and 48295 tests to
dirsrvtests/tests/suites/plugins/linked_attributes_test.py
Relates: #6753
Author: Lenka Doudova
Reviewed by: Simon Pichugin
|
commit 69df678cfed4d38ab34eed8aedcf34daa47e4455
Author: Lenka Doudova <[email protected]>
Date: Mon Jun 30 12:07:59 2025 +0200
Issue 6753 - Port ticket tests 48294 & 48295
Description: Porting ticket 48294 and 48295 tests to
dirsrvtests/tests/suites/plugins/linked_attributes_test.py
Relates: #6753
Author: Lenka Doudova
Reviewed by: Simon Pichugin
diff --git a/dirsrvtests/tests/suites/plugins/linked_attributes_test.py b/dirsrvtests/tests/suites/plugins/linked_attributes_test.py
new file mode 100644
index 000000000..4e4b9d729
--- /dev/null
+++ b/dirsrvtests/tests/suites/plugins/linked_attributes_test.py
@@ -0,0 +1,207 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2025 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import logging
+import pytest
+import ldap
+from lib389.topologies import topology_st
+from lib389._constants import DEFAULT_SUFFIX
+from lib389.plugins import LinkedAttributesPlugin, LinkedAttributesConfigs
+from lib389.idm.user import UserAccounts
+
+pytestmark = pytest.mark.tier1
+
+log = logging.getLogger(__name__)
+
+OU_PEOPLE = f'ou=People,{DEFAULT_SUFFIX}'
+LINKTYPE = 'directReport'
+MANAGEDTYPE = 'manager'
+MANAGER = 'manager1'
+EMPLOYEE = 'employee1'
+INVALID = f'uid=doNotExist,{OU_PEOPLE}'
+
+
[email protected](scope='function')
+def manager(topology_st, request):
+ """Fixture to create a manager entry."""
+ log.info('Creating manager entry')
+
+ users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX)
+ if users.exists(MANAGER):
+ users.get(MANAGER).delete()
+
+ manager = users.create(properties={
+ 'uid': MANAGER,
+ 'cn': MANAGER,
+ 'sn': MANAGER,
+ 'uidNumber': '1',
+ 'gidNumber': '10',
+ 'homeDirectory': f'/home/{MANAGER}'
+ })
+ manager.add('objectclass', 'extensibleObject')
+
+ def fin():
+ log.info('Delete manager entry')
+ if manager.exists():
+ manager.delete()
+
+ request.addfinalizer(fin)
+
+ return manager
+
+
[email protected](scope='function')
+def employee(topology_st, request):
+ """Fixture to create an employee entry."""
+ log.info('Creating employee entry')
+
+ users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX)
+ if users.exists(EMPLOYEE):
+ users.get(EMPLOYEE).delete()
+
+ employee = users.create(properties={
+ 'uid': EMPLOYEE,
+ 'cn': EMPLOYEE,
+ 'sn': EMPLOYEE,
+ 'uidNumber': '2',
+ 'gidNumber': '20',
+ 'homeDirectory': f'/home/{EMPLOYEE}'
+ })
+ employee.add('objectclass', 'extensibleObject')
+
+ def fin():
+ log.info('Delete employee entry')
+ if employee.exists():
+ employee.delete()
+
+ request.addfinalizer(fin)
+
+ return employee
+
+
[email protected](scope='function')
+def setup_linked_attributes(topology_st, request):
+ """Fixture to set up the Linked Attributes plugin."""
+ log.info('Setting up Linked Attributes plugin')
+
+ log.info('Enable Linked Attributes plugin')
+ linkedattr = LinkedAttributesPlugin(topology_st.standalone)
+ linkedattr.enable()
+ topology_st.standalone.restart()
+
+ log.info('Add the plugin config entry')
+ la_configs = LinkedAttributesConfigs(topology_st.standalone)
+ config = la_configs.create(properties={'cn': 'Manager Link',
+ 'linkType': LINKTYPE,
+ 'managedType': MANAGEDTYPE})
+
+ def fin():
+ log.info('Cleaning up Linked Attributes plugin')
+ config.delete()
+ linkedattr.disable()
+ topology_st.standalone.restart()
+
+ request.addfinalizer(fin)
+
+
+def test_linked_attribute_after_modrdn(topology_st, setup_linked_attributes, manager, employee):
+ """ Test that linked attributes are properly updated after a modrdn operation.
+
+ :id: 11577519-6e91-428e-b547-4fe49ba29285
+ :setup:
+ Standalone instance with Linked Attributes plugin enabled and manager and employee entries created.
+ :steps:
+ 1. Add linktype to manager
+ 2. Check managed attribute on employee
+ 3. Rename employee1 to employee2
+ 4. Modify the value of directReport to employee2
+ 5. Verify that the link is properly updated
+ 6. Rename employee2 to employee3
+ 7. Modify the value of directReport to employee3 by deleting and readding the link
+ 8. Verify that the link is properly updated
+ 9. Rename manager1 to manager2
+ 10. Verify that the link is properly updated
+ :expectedresults:
+ 1. Linktype is added to manager
+ 2. Managed attribute is present on employee
+ 3. Employee is renamed to employee2
+ 4. The value of directReport is modified to employee2
+ 5. The link is properly updated to employee2
+ 6. Employee2 is renamed to employee3
+ 7. The value of directReport is modified to employee3 by deleting and readding the link
+ 8. The link is properly updated to employee3
+ 9. Manager is renamed to manager2
+ 10. The link is properly updated to manager2
+ """
+
+ log.info('Add linktype to manager')
+ manager.add(LINKTYPE, employee.dn)
+
+ log.info('Check managed attribute')
+ assert employee.present(MANAGEDTYPE, manager.dn)
+
+ log.info('Rename employee1 to employee2')
+ employee.rename('uid=employee2')
+
+ log.info('Modify the value of directReport to employee2')
+ manager.replace(LINKTYPE, f'uid=employee2,{OU_PEOPLE}')
+
+ log.info('Verify that the link is properly updated')
+ assert manager.present(LINKTYPE, employee.dn)
+ assert employee.present(MANAGEDTYPE, manager.dn)
+
+ log.info('Rename employee2 to employee3')
+ employee.rename('uid=employee3')
+
+ log.info('Modify the value of directReport to employee3 by deleting and readding the link')
+ manager.remove(LINKTYPE, f'uid=employee2,{OU_PEOPLE}')
+ manager.add(LINKTYPE, f'uid=employee3,{OU_PEOPLE}')
+
+ log.info('Verify that the link is properly updated')
+ assert manager.present(LINKTYPE, employee.dn)
+ assert employee.present(MANAGEDTYPE, manager.dn)
+
+ log.info('Rename manager1 to manager2')
+ manager.rename('uid=manager2')
+
+ log.info('Verify that the link is properly updated')
+ assert manager.present(LINKTYPE, employee.dn)
+ assert employee.present(MANAGEDTYPE, manager.dn)
+
+
+def test_rollback_on_failed_operation(topology_st, setup_linked_attributes, manager, employee):
+ """ Test that successful changes are rolled back if made as a part of unsuccessful
+ linked attribute operation.
+
+ :id: 407c03a1-a5b1-4668-8716-ccecc27414f3
+ :setup:
+ Standalone instance with Linked Attributes plugin enabled and manager and employee entries created.
+ :steps:
+ 1. Add linktype to manager with a valid employee DN and an invalid DN.
+ 2. Check that the link was not added to employee due to failed operation.
+ 3. Check that manager does not have any link.
+ :expectedresults:
+ 1. Operation fails with UNWILLING_TO_PERFORM error.
+ 2. No changes are made to employee's managed attribute.
+ 3. Manager has no linked attribute.
+ """
+ log.info('Add linktype to manager')
+ with pytest.raises(ldap.UNWILLING_TO_PERFORM):
+ manager.add_many((LINKTYPE, INVALID), (LINKTYPE, employee.dn))
+
+ log.info('Check that no changes were made since previous operation failed')
+ assert not employee.present(MANAGEDTYPE, manager.dn)
+ assert not manager.present(LINKTYPE, employee.dn)
+ assert not manager.present(LINKTYPE, INVALID)
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main(f"-s {CURRENT_FILE}")
diff --git a/dirsrvtests/tests/tickets/ticket48294_test.py b/dirsrvtests/tests/tickets/ticket48294_test.py
deleted file mode 100644
index 73df89658..000000000
--- a/dirsrvtests/tests/tickets/ticket48294_test.py
+++ /dev/null
@@ -1,220 +0,0 @@
-# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2016 Red Hat, Inc.
-# All rights reserved.
-#
-# License: GPL (version 3 or any later version).
-# See LICENSE for details.
-# --- END COPYRIGHT BLOCK ---
-#
-import logging
-import time
-
-import ldap
-import pytest
-from lib389 import Entry
-from lib389._constants import *
-from lib389.topologies import topology_st
-from lib389.utils import *
-
-pytestmark = pytest.mark.tier2
-
-log = logging.getLogger(__name__)
-
-LINKEDATTR_PLUGIN = 'cn=Linked Attributes,cn=plugins,cn=config'
-MANAGER_LINK = 'cn=Manager Link,' + LINKEDATTR_PLUGIN
-OU_PEOPLE = 'ou=People,' + DEFAULT_SUFFIX
-LINKTYPE = 'directReport'
-MANAGEDTYPE = 'manager'
-
-
-def _header(topology_st, label):
- topology_st.standalone.log.info("###############################################")
- topology_st.standalone.log.info("####### %s" % label)
- topology_st.standalone.log.info("###############################################")
-
-
-def check_attr_val(topology_st, dn, attr, expected):
- try:
- centry = topology_st.standalone.search_s(dn, ldap.SCOPE_BASE, 'uid=*')
- if centry:
- val = centry[0].getValue(attr)
- if val.lower() == expected.lower():
- log.info('Value of %s is %s' % (attr, expected))
- else:
- log.info('Value of %s is not %s, but %s' % (attr, expected, val))
- assert False
- else:
- log.fatal('Failed to get %s' % dn)
- assert False
- except ldap.LDAPError as e:
- log.fatal('Failed to search ' + dn + ': ' + e.args[0]['desc'])
- assert False
-
-
-def _modrdn_entry(topology_st=None, entry_dn=None, new_rdn=None, del_old=0, new_superior=None):
- assert topology_st is not None
- assert entry_dn is not None
- assert new_rdn is not None
-
- topology_st.standalone.log.info("\n\n######################### MODRDN %s ######################\n" % new_rdn)
- try:
- if new_superior:
- topology_st.standalone.rename_s(entry_dn, new_rdn, newsuperior=new_superior, delold=del_old)
- else:
- topology_st.standalone.rename_s(entry_dn, new_rdn, delold=del_old)
- except ldap.NO_SUCH_ATTRIBUTE:
- topology_st.standalone.log.info("accepted failure due to 47833: modrdn reports error.. but succeeds")
- attempt = 0
- if new_superior:
- dn = "%s,%s" % (new_rdn, new_superior)
- base = new_superior
- else:
- base = ','.join(entry_dn.split(",")[1:])
- dn = "%s, %s" % (new_rdn, base)
- myfilter = entry_dn.split(',')[0]
-
- while attempt < 10:
- try:
- ent = topology_st.standalone.getEntry(dn, ldap.SCOPE_BASE, myfilter)
- break
- except ldap.NO_SUCH_OBJECT:
- topology_st.standalone.log.info("Accept failure due to 47833: unable to find (base) a modrdn entry")
- attempt += 1
- time.sleep(1)
- if attempt == 10:
- ent = topology_st.standalone.getEntry(base, ldap.SCOPE_SUBTREE, myfilter)
- ent = topology_st.standalone.getEntry(dn, ldap.SCOPE_BASE, myfilter)
-
-
-def test_48294_init(topology_st):
- """
- Set up Linked Attribute
- """
- _header(topology_st,
- 'Testing Ticket 48294 - Linked Attributes plug-in - won\'t update links after MODRDN operation')
-
- log.info('Enable Dynamic plugins, and the linked Attrs plugin')
- try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'on')])
- except ldap.LDAPError as e:
- log.fatal('Failed to enable dynamic plugin!' + e.args[0]['desc'])
- assert False
-
- try:
- topology_st.standalone.plugins.enable(name=PLUGIN_LINKED_ATTRS)
- except ValueError as e:
- log.fatal('Failed to enable linked attributes plugin!' + e.args[0]['desc'])
- assert False
-
- log.info('Add the plugin config entry')
- try:
- topology_st.standalone.add_s(Entry((MANAGER_LINK, {
- 'objectclass': 'top extensibleObject'.split(),
- 'cn': 'Manager Link',
- 'linkType': LINKTYPE,
- 'managedType': MANAGEDTYPE
- })))
- except ldap.LDAPError as e:
- log.fatal('Failed to add linked attr config entry: error ' + e.args[0]['desc'])
- assert False
-
- log.info('Add 2 entries: manager1 and employee1')
- try:
- topology_st.standalone.add_s(Entry(('uid=manager1,%s' % OU_PEOPLE, {
- 'objectclass': 'top extensibleObject'.split(),
- 'uid': 'manager1'})))
- except ldap.LDAPError as e:
- log.fatal('Add manager1 failed: error ' + e.args[0]['desc'])
- assert False
-
- try:
- topology_st.standalone.add_s(Entry(('uid=employee1,%s' % OU_PEOPLE, {
- 'objectclass': 'top extensibleObject'.split(),
- 'uid': 'employee1'})))
- except ldap.LDAPError as e:
- log.fatal('Add employee1 failed: error ' + e.args[0]['desc'])
- assert False
-
- log.info('Add linktype to manager1')
- topology_st.standalone.modify_s('uid=manager1,%s' % OU_PEOPLE,
- [(ldap.MOD_ADD, LINKTYPE, ensure_bytes('uid=employee1,%s' % OU_PEOPLE))])
-
- log.info('Check managed attribute')
- check_attr_val(topology_st, 'uid=employee1,%s' % OU_PEOPLE, MANAGEDTYPE, ensure_bytes('uid=manager1,%s' % OU_PEOPLE))
-
- log.info('PASSED')
-
-
-def test_48294_run_0(topology_st):
- """
- Rename employee1 to employee2 and adjust the value of directReport by replace
- """
- _header(topology_st, 'Case 0 - Rename employee1 and adjust the link type value by replace')
-
- log.info('Rename employee1 to employee2')
- _modrdn_entry(topology_st, entry_dn='uid=employee1,%s' % OU_PEOPLE, new_rdn='uid=employee2')
-
- log.info('Modify the value of directReport to uid=employee2')
- try:
- topology_st.standalone.modify_s('uid=manager1,%s' % OU_PEOPLE,
- [(ldap.MOD_REPLACE, LINKTYPE, ensure_bytes('uid=employee2,%s' % OU_PEOPLE))])
- except ldap.LDAPError as e:
- log.fatal('Failed to replace uid=employee1 with employee2: ' + e.args[0]['desc'])
- assert False
-
- log.info('Check managed attribute')
- check_attr_val(topology_st, 'uid=employee2,%s' % OU_PEOPLE, MANAGEDTYPE, ensure_bytes('uid=manager1,%s' % OU_PEOPLE))
-
- log.info('PASSED')
-
-
-def test_48294_run_1(topology_st):
- """
- Rename employee2 to employee3 and adjust the value of directReport by delete and add
- """
- _header(topology_st, 'Case 1 - Rename employee2 and adjust the link type value by delete and add')
-
- log.info('Rename employee2 to employee3')
- _modrdn_entry(topology_st, entry_dn='uid=employee2,%s' % OU_PEOPLE, new_rdn='uid=employee3')
-
- log.info('Modify the value of directReport to uid=employee3')
- try:
- topology_st.standalone.modify_s('uid=manager1,%s' % OU_PEOPLE,
- [(ldap.MOD_DELETE, LINKTYPE, ensure_bytes('uid=employee2,%s' % OU_PEOPLE))])
- except ldap.LDAPError as e:
- log.fatal('Failed to delete employee2: ' + e.args[0]['desc'])
- assert False
-
- try:
- topology_st.standalone.modify_s('uid=manager1,%s' % OU_PEOPLE,
- [(ldap.MOD_ADD, LINKTYPE, ensure_bytes('uid=employee3,%s' % OU_PEOPLE))])
- except ldap.LDAPError as e:
- log.fatal('Failed to add employee3: ' + e.args[0]['desc'])
- assert False
-
- log.info('Check managed attribute')
- check_attr_val(topology_st, 'uid=employee3,%s' % OU_PEOPLE, MANAGEDTYPE, ensure_bytes('uid=manager1,%s' % OU_PEOPLE))
-
- log.info('PASSED')
-
-
-def test_48294_run_2(topology_st):
- """
- Rename manager1 to manager2 and make sure the managed attribute value is updated
- """
- _header(topology_st, 'Case 2 - Rename manager1 to manager2 and make sure the managed attribute value is updated')
-
- log.info('Rename manager1 to manager2')
- _modrdn_entry(topology_st, entry_dn='uid=manager1,%s' % OU_PEOPLE, new_rdn='uid=manager2')
-
- log.info('Check managed attribute')
- check_attr_val(topology_st, 'uid=employee3,%s' % OU_PEOPLE, MANAGEDTYPE, ensure_bytes('uid=manager2,%s' % OU_PEOPLE))
-
- log.info('PASSED')
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket48295_test.py b/dirsrvtests/tests/tickets/ticket48295_test.py
deleted file mode 100644
index c175b21d0..000000000
--- a/dirsrvtests/tests/tickets/ticket48295_test.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2016 Red Hat, Inc.
-# All rights reserved.
-#
-# License: GPL (version 3 or any later version).
-# See LICENSE for details.
-# --- END COPYRIGHT BLOCK ---
-#
-import logging
-
-import ldap
-import pytest
-from lib389 import Entry
-from lib389._constants import *
-from lib389.topologies import topology_st
-from lib389.utils import *
-
-pytestmark = pytest.mark.tier2
-
-log = logging.getLogger(__name__)
-
-LINKEDATTR_PLUGIN = 'cn=Linked Attributes,cn=plugins,cn=config'
-MANAGER_LINK = 'cn=Manager Link,' + LINKEDATTR_PLUGIN
-OU_PEOPLE = 'ou=People,' + DEFAULT_SUFFIX
-LINKTYPE = 'directReport'
-MANAGEDTYPE = 'manager'
-
-
-def _header(topology_st, label):
- topology_st.standalone.log.info("###############################################")
- topology_st.standalone.log.info("####### %s" % label)
- topology_st.standalone.log.info("###############################################")
-
-
-def check_attr_val(topology_st, dn, attr, expected, revert):
- try:
- centry = topology_st.standalone.search_s(dn, ldap.SCOPE_BASE, 'uid=*')
- if centry:
- val = centry[0].getValue(attr)
- if val:
- if val.lower() == expected.lower():
- if revert:
- log.info('Value of %s %s exists, which should not.' % (attr, expected))
- assert False
- else:
- log.info('Value of %s is %s' % (attr, expected))
- else:
- if revert:
- log.info('NEEDINFO: Value of %s is not %s, but %s' % (attr, expected, val))
- else:
- log.info('Value of %s is not %s, but %s' % (attr, expected, val))
- assert False
- else:
- if revert:
- log.info('Value of %s does not expectedly exist' % attr)
- else:
- log.info('Value of %s does not exist' % attr)
- assert False
- else:
- log.fatal('Failed to get %s' % dn)
- assert False
- except ldap.LDAPError as e:
- log.fatal('Failed to search ' + dn + ': ' + e.args[0]['desc'])
- assert False
-
-
-def test_48295_init(topology_st):
- """
- Set up Linked Attribute
- """
- _header(topology_st,
- 'Testing Ticket 48295 - Entry cache is not rolled back -- Linked Attributes plug-in - wrong behaviour when adding valid and broken links')
-
- log.info('Enable Dynamic plugins, and the linked Attrs plugin')
- try:
- topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'on')])
- except ldap.LDAPError as e:
- log.fatal('Failed to enable dynamic plugin!' + e.args[0]['desc'])
- assert False
-
- try:
- topology_st.standalone.plugins.enable(name=PLUGIN_LINKED_ATTRS)
- except ValueError as e:
- log.fatal('Failed to enable linked attributes plugin!' + e.args[0]['desc'])
- assert False
-
- log.info('Add the plugin config entry')
- try:
- topology_st.standalone.add_s(Entry((MANAGER_LINK, {
- 'objectclass': 'top extensibleObject'.split(),
- 'cn': 'Manager Link',
- 'linkType': LINKTYPE,
- 'managedType': MANAGEDTYPE
- })))
- except ldap.LDAPError as e:
- log.fatal('Failed to add linked attr config entry: error ' + e.args[0]['desc'])
- assert False
-
- log.info('Add 2 entries: manager1 and employee1')
- try:
- topology_st.standalone.add_s(Entry(('uid=manager1,%s' % OU_PEOPLE, {
- 'objectclass': 'top extensibleObject'.split(),
- 'uid': 'manager1'})))
- except ldap.LDAPError as e:
- log.fatal('Add manager1 failed: error ' + e.args[0]['desc'])
- assert False
-
- try:
- topology_st.standalone.add_s(Entry(('uid=employee1,%s' % OU_PEOPLE, {
- 'objectclass': 'top extensibleObject'.split(),
- 'uid': 'employee1'})))
- except ldap.LDAPError as e:
- log.fatal('Add employee1 failed: error ' + e.args[0]['desc'])
- assert False
-
- log.info('PASSED')
-
-
-def test_48295_run(topology_st):
- """
- Add 2 linktypes - one exists, another does not
- """
-
- _header(topology_st,
- 'Add 2 linktypes to manager1 - one exists, another does not to make sure the managed entry does not have managed type.')
- try:
- topology_st.standalone.modify_s('uid=manager1,%s' % OU_PEOPLE,
- [(ldap.MOD_ADD, LINKTYPE, ensure_bytes('uid=employee1,%s' % OU_PEOPLE)),
- (ldap.MOD_ADD, LINKTYPE, ensure_bytes('uid=doNotExist,%s' % OU_PEOPLE))])
- except ldap.UNWILLING_TO_PERFORM:
- log.info('Add uid=employee1 and uid=doNotExist expectedly failed.')
- pass
-
- log.info('Check managed attribute does not exist.')
- check_attr_val(topology_st, 'uid=employee1,%s' % OU_PEOPLE, MANAGEDTYPE, ensure_bytes('uid=manager1,%s' % OU_PEOPLE), True)
-
- log.info('PASSED')
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
| 0 |
144af5987dad38152e61f2e056ced3aa19eaa532
|
389ds/389-ds-base
|
coverity uninit var and resource leak
12550 Uninitialized pointer read
In dna_update_config_event(): Reads an uninitialized pointer or its target
12549 Resource leak
In referint_thread_func(): Leak of memory or pointers to system resources
Reviewed by: mreynolds (Thanks!)
|
commit 144af5987dad38152e61f2e056ced3aa19eaa532
Author: Rich Megginson <[email protected]>
Date: Thu Feb 16 08:14:43 2012 -0700
coverity uninit var and resource leak
12550 Uninitialized pointer read
In dna_update_config_event(): Reads an uninitialized pointer or its target
12549 Resource leak
In referint_thread_func(): Leak of memory or pointers to system resources
Reviewed by: mreynolds (Thanks!)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index fedfa50be..efb2de4f5 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1271,7 +1271,7 @@ dna_load_host_port()
static void
dna_update_config_event(time_t event_time, void *arg)
{
- Slapi_PBlock *pb;
+ Slapi_PBlock *pb = NULL;
struct configEntry *config_entry = NULL;
PRCList *list = NULL;
char *binddn = (char *)arg;
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index 775da5941..ee7c7819a 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -920,6 +920,7 @@ referint_thread_func(void *arg)
if(plugin_argv == NULL){
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_thread_func not get args \n" );
+ slapi_pblock_destroy(pb);
return;
}
| 0 |
abc6f165bb6150809a2466fcf1760803f2032df0
|
389ds/389-ds-base
|
Issue 50634 - Clean up CLI errors output - Fix wrong exception
Description: The previous commit takes care only about ValueError
evaluation. But it is possible that other exceptions will be raised
which will result in a wrong error output.
Make the exception object more general.
https://pagure.io/389-ds-base/issue/50634
Reviewed by: ?
|
commit abc6f165bb6150809a2466fcf1760803f2032df0
Author: Simon Pichugin <[email protected]>
Date: Mon Oct 21 18:25:20 2019 +0200
Issue 50634 - Clean up CLI errors output - Fix wrong exception
Description: The previous commit takes care only about ValueError
evaluation. But it is possible that other exceptions will be raised
which will result in a wrong error output.
Make the exception object more general.
https://pagure.io/389-ds-base/issue/50634
Reviewed by: ?
diff --git a/src/lib389/lib389/cli_base/__init__.py b/src/lib389/lib389/cli_base/__init__.py
index 23fc312b0..12b1c5115 100644
--- a/src/lib389/lib389/cli_base/__init__.py
+++ b/src/lib389/lib389/cli_base/__init__.py
@@ -423,6 +423,6 @@ def format_error_to_dict(exception):
errmsg = str(exception)
try:
msg = ast.literal_eval(errmsg)
- except ValueError:
+ except Exception:
msg = {'desc': errmsg}
return msg
| 0 |
9caf7aba4dc6ad9a57e3353f6921b07a063ac98d
|
389ds/389-ds-base
|
Issue: 48851 - investigate and port TET matching rules filter tests(cert)
Investigate and port TET matching rules filter tests(cert)
Fixes: https://pagure.io/389-ds-base/issue/48851
Author: aborah
Reviewed by: Matus Honek
|
commit 9caf7aba4dc6ad9a57e3353f6921b07a063ac98d
Author: Anuj Borah <[email protected]>
Date: Tue Nov 26 06:28:20 2019 +0530
Issue: 48851 - investigate and port TET matching rules filter tests(cert)
Investigate and port TET matching rules filter tests(cert)
Fixes: https://pagure.io/389-ds-base/issue/48851
Author: aborah
Reviewed by: Matus Honek
diff --git a/dirsrvtests/tests/suites/filter/filter_cert_test.py b/dirsrvtests/tests/suites/filter/filter_cert_test.py
new file mode 100644
index 000000000..af5376522
--- /dev/null
+++ b/dirsrvtests/tests/suites/filter/filter_cert_test.py
@@ -0,0 +1,69 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2019 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ----
+
+
+"""
+verify and testing Filter from a search
+"""
+
+import os
+import pytest
+
+from lib389._constants import DEFAULT_SUFFIX
+from lib389.topologies import topology_st as topo
+from lib389.idm.user import UserAccounts
+from lib389.idm.account import Accounts
+from lib389.nss_ssl import NssSsl
+from lib389.utils import search_filter_escape_bytes
+
+pytestmark = pytest.mark.tier1
+
+
+def test_positive(topo):
+ """Test User certificate field
+ :id: e984ac40-63d1-4176-ad1e-0cbe71391b5f
+ :setup: Standalone
+ :steps:
+ 1. Create entries with userCertificate field.
+ 2. Try to search/filter them with userCertificate field.
+ :expected results:
+ 1. Pass
+ 2. Pass
+ """
+ # SETUP TLS
+ topo.standalone.stop()
+ NssSsl(topo.standalone).reinit()
+ NssSsl(topo.standalone).create_rsa_ca()
+ NssSsl(topo.standalone).create_rsa_key_and_cert()
+ # Create user
+ NssSsl(topo.standalone).create_rsa_user('testuser1')
+ NssSsl(topo.standalone).create_rsa_user('testuser2')
+ # Creating cert users
+ topo.standalone.start()
+ users_people = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ for count in range(1, 3):
+ user = users_people.create_test_user(uid=count, gid=count)
+ tls_locs = NssSsl(topo.standalone).get_rsa_user(f'testuser{count}')
+ # {'ca': ca_path, 'key': key_path, 'crt': crt_path}
+ user.enroll_certificate(tls_locs['crt_der_path'])
+
+ assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter("(usercertificate=*)")
+ assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter("(userCertificate;binary=*)")
+ user1_cert = users_people.list()[0].get_attr_val("userCertificate;binary")
+ assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter(
+ f'(userCertificate;binary={search_filter_escape_bytes(user1_cert)})')[0].dn == \
+ 'uid=test_user_1,ou=People,dc=example,dc=com'
+ user2_cert = users_people.list()[1].get_attr_val("userCertificate;binary")
+ assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter(
+ f'(userCertificate;binary={search_filter_escape_bytes(user2_cert)})')[0].dn == \
+ 'uid=test_user_2,ou=People,dc=example,dc=com'
+
+
+if __name__ == '__main__':
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
| 0 |
2e5517e279e97b50ae6465e221ea4ae364c168b2
|
389ds/389-ds-base
|
Resolves: #475899
Summary: extensible filter having range operation crashes the server (comment#7)
Description: As Rich suggested, set the pb->pb_op to glob_pb->pb_op to catch
the abandon request in case the underlying operation is interrupted.
|
commit 2e5517e279e97b50ae6465e221ea4ae364c168b2
Author: Noriko Hosoi <[email protected]>
Date: Fri Dec 12 01:21:53 2008 +0000
Resolves: #475899
Summary: extensible filter having range operation crashes the server (comment#7)
Description: As Rich suggested, set the pb->pb_op to glob_pb->pb_op to catch
the abandon request in case the underlying operation is interrupted.
diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c
index ae89d2633..42d416259 100644
--- a/ldap/servers/slapd/back-ldbm/filterindex.c
+++ b/ldap/servers/slapd/back-ldbm/filterindex.c
@@ -335,7 +335,7 @@ presence_candidates(
{
char *type;
IDList *idl;
- int unindexed = 0;
+ int unindexed = 0;
LDAPDebug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 );
@@ -379,6 +379,7 @@ extensible_candidates(
IDList* idl = NULL;
Slapi_PBlock* pb = slapi_pblock_new();
int mrOP = 0;
+ Slapi_Operation *op = NULL;
LDAPDebug (LDAP_DEBUG_TRACE, "=> extensible_candidates\n", 0, 0, 0);
if ( ! slapi_mr_filter_index (f, pb) && !slapi_pblock_get (pb, SLAPI_PLUGIN_MR_QUERY_OPERATOR, &mrOP))
{
@@ -389,13 +390,18 @@ extensible_candidates(
case SLAPI_OP_EQUAL:
case SLAPI_OP_GREATER_OR_EQUAL:
case SLAPI_OP_GREATER:
- {
+ {
IFP mrINDEX = NULL;
void* mrOBJECT = NULL;
struct berval** mrVALUES = NULL;
char* mrOID = NULL;
char* mrTYPE = NULL;
+ /* set the pb->pb_op to glob_pb->pb_op to catch the abandon req.
+ * in case the operation is interrupted. */
+ slapi_pblock_get (glob_pb, SLAPI_OPERATION, &op);
+ slapi_pblock_set (pb, SLAPI_OPERATION, op);
+
slapi_pblock_get (pb, SLAPI_PLUGIN_MR_INDEX_FN, &mrINDEX);
slapi_pblock_get (pb, SLAPI_PLUGIN_OBJECT, &mrOBJECT);
slapi_pblock_get (pb, SLAPI_PLUGIN_MR_VALUES, &mrVALUES);
@@ -493,6 +499,8 @@ extensible_candidates(
idl = idl_allids (be); /* all entries are candidates */
}
return_idl:
+ op = NULL;
+ slapi_pblock_set (pb, SLAPI_OPERATION, op);
slapi_pblock_destroy (pb);
LDAPDebug (LDAP_DEBUG_TRACE, "<= extensible_candidates %lu\n",
(u_long)IDL_NIDS(idl), 0, 0);
@@ -746,7 +754,7 @@ list_candidates(
if ( (ftype == LDAP_FILTER_AND) && ((idl == NULL) ||
(idl_length(idl) <= FILTER_TEST_THRESHOLD))) {
break; /* We can exit the loop now, since the candidate list is small already */
- }
+ }
} else if ( ftype == LDAP_FILTER_AND ) {
if (isnot) {
IDList *new_idl = NULL;
| 0 |
72f3f04e1ec6d3d552f3d0141768329dcc632fe1
|
389ds/389-ds-base
|
Ticket #529 - dn normalization must handle multiple space characters in attributes
Bug Description: Commit 69ff83598d517bed84922b1c7dd67cab023b4d99
had a flaw -- When multiple server instances exist, upgrade dn
format fails due to missing server ID.
Fix Description: The upgrade script always passes server ID.
Reviewed by Rich (Thank you!!)
https://fedorahosted.org/389/ticket/529
|
commit 72f3f04e1ec6d3d552f3d0141768329dcc632fe1
Author: Noriko Hosoi <[email protected]>
Date: Tue Apr 16 17:28:14 2013 -0700
Ticket #529 - dn normalization must handle multiple space characters in attributes
Bug Description: Commit 69ff83598d517bed84922b1c7dd67cab023b4d99
had a flaw -- When multiple server instances exist, upgrade dn
format fails due to missing server ID.
Fix Description: The upgrade script always passes server ID.
Reviewed by Rich (Thank you!!)
https://fedorahosted.org/389/ticket/529
diff --git a/ldap/admin/src/scripts/80upgradednformat.pl.in b/ldap/admin/src/scripts/80upgradednformat.pl.in
index 6d14099b2..aa433e34b 100644
--- a/ldap/admin/src/scripts/80upgradednformat.pl.in
+++ b/ldap/admin/src/scripts/80upgradednformat.pl.in
@@ -87,8 +87,8 @@ sub runinst {
my $ldifdir = $config_entry->{"nsslapd-ldifdir"}[0];
my $instancedir = $config_entry->{"nsslapd-instancedir"}[0];
my ($slapd, $serverID) = split(/-/, $instancedir);
- my $upgradednformat = "@sbindir@/upgradednformat";
- my $reindex = "@sbindir@/db2index";
+ my $upgradednformat = "@sbindir@/upgradednformat -Z $serverID";
+ my $reindex = "@sbindir@/db2index -Z $serverID";
# Scan through all of the backends to see if any of them
# contain escape characters in the DNs. If we find any
@@ -171,7 +171,7 @@ sub runinst {
# ancestorid index is in disorder; need to reindex it.
if ($disorder) {
print "The ancestorid index in $backend is in disorder; Reindexing $ancestorid.\n";
- $cmd = "$reindex -Z $serverID -n $backend -t ancestorid";
+ $cmd = "$reindex -n $backend -t ancestorid";
$rc = system("$cmd");
if ($rc & 127) {
push @errs, [ 'error_running_command', $cmd, $rc, $! ];
@@ -260,7 +260,7 @@ sub runinst {
if ((1 == $escapes) || (2 == $escapes) || (3 == $escapes)) {
# call conversion tool here and get return status.
- $cmd = "$upgradednformat -Z $serverID -n $backend -a $workdir/$instname";
+ $cmd = "$upgradednformat -n $backend -a $workdir/$instname";
$rc = system("$cmd");
if ($rc & 127) {
push @errs, [ 'error_running_command', $cmd, $rc, $! ];
@@ -274,7 +274,7 @@ sub runinst {
move("$dbinstdir.orig/dnupgrade/$instname", "$dbinstdir");
copy("$dbinstdir.orig/dnupgrade/DBVERSION", "$dbdir");
if ((1 == $escapes) || (3 == $escapes)) {
- $cmd = "$reindex -Z $serverID -n $backend -t entryrdn";
+ $cmd = "$reindex -n $backend -t entryrdn";
$rc = system("$cmd");
if ($rc & 127) {
push @errs, [ 'error_running_command', $cmd, $rc, $! ];
| 0 |
0e9fd8bc8205a46a6355555683e3fa0b014b4d03
|
389ds/389-ds-base
|
several spelling errors
https://bugzilla.redhat.com/show_bug.cgi?id=558518
Resolves: bug 558518
Bug Description: several spelling errors
Reviewed by: ???
Branch: HEAD
Fix Description: Fix several spelling errors in error messages and man pages.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
|
commit 0e9fd8bc8205a46a6355555683e3fa0b014b4d03
Author: Rich Megginson <[email protected]>
Date: Mon Jan 25 08:25:36 2010 -0700
several spelling errors
https://bugzilla.redhat.com/show_bug.cgi?id=558518
Resolves: bug 558518
Bug Description: several spelling errors
Reviewed by: ???
Branch: HEAD
Fix Description: Fix several spelling errors in error messages and man pages.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
index 18d869018..a3dfe36b4 100644
--- a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
+++ b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
@@ -412,7 +412,7 @@ int cb_get_connection(cb_conn_pool * pool, LDAP ** lld, cb_outgoing_conn ** cc,s
{
/* Bind is successful but password has expired */
slapi_log_error(SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "Succesfully bound as %s to remote server %s:%d, "
+ "Successfully bound as %s to remote server %s:%d, "
"but password has expired.\n",
binddn, hostname, port);
}
@@ -424,7 +424,7 @@ int cb_get_connection(cb_conn_pool * pool, LDAP ** lld, cb_outgoing_conn ** cc,s
{
int password_expiring = atoi( serverctrls[ i ]->ldctl_value.bv_val );
slapi_log_error(SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
- "Succesfully bound as %s to remote server %s:%d, "
+ "Successfully bound as %s to remote server %s:%d, "
"but password is expiring in %d seconds.\n",
binddn, hostname, port, password_expiring);
}
diff --git a/ldap/servers/plugins/replication/repl5_connection.c b/ldap/servers/plugins/replication/repl5_connection.c
index 47d07be44..927fb2007 100644
--- a/ldap/servers/plugins/replication/repl5_connection.c
+++ b/ldap/servers/plugins/replication/repl5_connection.c
@@ -1696,7 +1696,7 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password)
{
/* Bind is successfull but password has expired */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "%s: Succesfully bound %s to consumer, "
+ "%s: Successfully bound %s to consumer, "
"but password has expired on consumer.\n",
agmt_get_long_name(conn->agmt), binddn);
}
@@ -1708,7 +1708,7 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password)
{
int password_expiring = atoi( ctrls[ i ]->ldctl_value.bv_val );
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "%s: Succesfully bound %s to consumer, "
+ "%s: Successfully bound %s to consumer, "
"but password is expiring on consumer in %d seconds.\n",
agmt_get_long_name(conn->agmt), binddn, password_expiring);
}
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index d0eadee16..a1e74c444 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -1752,7 +1752,7 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password)
{
/* Bind is successfull but password has expired */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "%s: Succesfully bound %s to consumer, "
+ "%s: Successfully bound %s to consumer, "
"but password has expired on consumer.\n",
agmt_get_long_name(conn->agmt), binddn);
}
@@ -1764,7 +1764,7 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password)
{
int password_expiring = atoi( ctrls[ i ]->ldctl_value.bv_val );
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "%s: Succesfully bound %s to consumer, "
+ "%s: Successfully bound %s to consumer, "
"but password is expiring on consumer in %d seconds.\n",
agmt_get_long_name(conn->agmt), binddn, password_expiring);
}
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index a52ba21e0..5c8decbe5 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -631,7 +631,7 @@ int connection_release_nolock (Connection *conn)
if (conn->c_refcnt <= 0)
{
slapi_log_error(SLAPI_LOG_FATAL, "connection",
- "conn=%" NSPRIu64 " fd=%d Attempt to release connection that is not aquired\n",
+ "conn=%" NSPRIu64 " fd=%d Attempt to release connection that is not acquired\n",
conn->c_connid, conn->c_sd);
PR_ASSERT (PR_FALSE);
return -1;
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index db641b637..75b14979a 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -416,7 +416,7 @@ str2entry_fast( const char *dn, char *s, int flags, int read_stateinfo )
{
LDAPDebug( LDAP_DEBUG_ANY,
"str2entry_fast: entry %s exceeded max attribute value cound %ld\n",
- slapi_entry_get_dn_const(e)?slapi_entry_get_dn_const(e):"unkown",
+ slapi_entry_get_dn_const(e)?slapi_entry_get_dn_const(e):"unknown",
attr_val_cnt, 0 );
}
if (read_stateinfo && maxcsn)
diff --git a/ldap/servers/slapd/sslerrstrs.h b/ldap/servers/slapd/sslerrstrs.h
index 3f846c123..e960d1c0c 100644
--- a/ldap/servers/slapd/sslerrstrs.h
+++ b/ldap/servers/slapd/sslerrstrs.h
@@ -256,7 +256,7 @@ ER3(SSL_ERROR_HANDSHAKE_UNEXPECTED_ALERT , (SSL_ERROR_BASE + 59),
"SSL peer was not expecting a handshake message it received.")
ER3(SSL_ERROR_DECOMPRESSION_FAILURE_ALERT , (SSL_ERROR_BASE + 60),
-"SSL peer was unable to succesfully decompress an SSL record it received.")
+"SSL peer was unable to successfully decompress an SSL record it received.")
ER3(SSL_ERROR_HANDSHAKE_FAILURE_ALERT , (SSL_ERROR_BASE + 61),
"SSL peer was unable to negotiate an acceptable set of security parameters.")
diff --git a/ldap/servers/slapd/uniqueidgen.c b/ldap/servers/slapd/uniqueidgen.c
index 15badc35b..dad44df31 100644
--- a/ldap/servers/slapd/uniqueidgen.c
+++ b/ldap/servers/slapd/uniqueidgen.c
@@ -119,7 +119,7 @@ int slapi_uniqueIDGenerate (Slapi_UniqueID *uId){
if (uId == NULL)
{
slapi_log_error (SLAPI_LOG_FATAL, MODULE, "uniqueIDGenerate: "
- "NULL paramter is passed to the function.\n");
+ "NULL parameter is passed to the function.\n");
return UID_BADDATA;
}
@@ -179,7 +179,7 @@ int slapi_uniqueIDGenerateFromName (Slapi_UniqueID *uId, const Slapi_UniqueID *u
if (uId == NULL || uIdBase == NULL || name == NULL || namelen <= 0)
{
slapi_log_error (SLAPI_LOG_FATAL, MODULE, "uniqueIDGenerateMT: "
- "invalid paramter is passed to the function.\n");
+ "invalid parameter is passed to the function.\n");
return UID_BADDATA;
}
diff --git a/man/man1/cl-dump.1 b/man/man1/cl-dump.1
index ff8d30dfe..7a35aa2be 100644
--- a/man/man1/cl-dump.1
+++ b/man/man1/cl-dump.1
@@ -63,7 +63,7 @@ Pathname of binding certificate DB
.TP
.B \-r replica\-roots
Specify replica roots whose changelog you want to dump. The replica
-roots may be seperated by comma. All the replica roots would be
+roots may be separated by comma. All the replica roots would be
dumped if the option is omitted.
.TP
.B \-v
diff --git a/man/man1/logconv.pl.1 b/man/man1/logconv.pl.1
index c7a77953a..ab81c6918 100644
--- a/man/man1/logconv.pl.1
+++ b/man/man1/logconv.pl.1
@@ -45,11 +45,11 @@ E.g. Load balancers
Print version of the tool
.TP
.B \fB\-S\fR <time to begin analyzing logfile from>
-Time to begin analyzing logile from
+Time to begin analyzing logfile from
E.g. [28/Mar/2002:13:14:22 \fB\-0800]\fR
.TP
.B \fB\-E\fR <time to stop analyzing logfile>
-Time to stop analyzing logile from
+Time to stop analyzing logfile from
E.g. [28/Mar/2002:13:24:62 \fB\-0800]\fR
.TP
\fB\-V\fR <enable verbose output \- includes all stats listed below>
| 0 |
0aea89bc6d5828a959b9240d8af786b5ac1cf800
|
389ds/389-ds-base
|
Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
Fix description: Catch possible NULL pointer in write_replog_db().
|
commit 0aea89bc6d5828a959b9240d8af786b5ac1cf800
Author: Endi S. Dewata <[email protected]>
Date: Fri Jul 9 20:20:28 2010 -0500
Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
Fix description: Catch possible NULL pointer in write_replog_db().
diff --git a/ldap/servers/plugins/retrocl/retrocl_po.c b/ldap/servers/plugins/retrocl/retrocl_po.c
index 6b1aa5656..96be617ba 100644
--- a/ldap/servers/plugins/retrocl/retrocl_po.c
+++ b/ldap/servers/plugins/retrocl/retrocl_po.c
@@ -179,13 +179,18 @@ write_replog_db(
int i;
int extensibleObject = 0;
+ if (!dn) {
+ slapi_log_error( SLAPI_LOG_PLUGIN, RETROCL_PLUGIN_NAME, "write_replog_db: NULL dn\n");
+ return;
+ }
+
PR_Lock(retrocl_internal_lock);
changenum = retrocl_assign_changenumber();
PR_ASSERT( changenum > 0UL );
slapi_log_error( SLAPI_LOG_PLUGIN, RETROCL_PLUGIN_NAME,
"write_replog_db: write change record %lu for dn: \"%s\"\n",
- changenum, ( dn == NULL ) ? "NULL" : dn );
+ changenum, dn );
/* Construct the dn of this change record */
edn = slapi_ch_smprintf( "%s=%lu,%s", attr_changenumber, changenum, RETROCL_CHANGELOG_DN);
| 0 |
c5cd4dd3baf47d6f3f11d23c2bf4d1a6300da863
|
389ds/389-ds-base
|
Bug 586973 - Sample update ldif points to non-existent directory
https://bugzilla.redhat.com/show_bug.cgi?id=586973
Description by [email protected]:
There are no files in /usr/share/dirsrv/ldif.
This should be /usr/share/dirsrv/data/template-*.ldif
|
commit c5cd4dd3baf47d6f3f11d23c2bf4d1a6300da863
Author: Noriko Hosoi <[email protected]>
Date: Tue Oct 12 10:34:23 2010 -0700
Bug 586973 - Sample update ldif points to non-existent directory
https://bugzilla.redhat.com/show_bug.cgi?id=586973
Description by [email protected]:
There are no files in /usr/share/dirsrv/ldif.
This should be /usr/share/dirsrv/data/template-*.ldif
diff --git a/ldap/admin/src/scripts/exampleupdate.ldif b/ldap/admin/src/scripts/exampleupdate.ldif
index 00f9a70db..63cd00173 100644
--- a/ldap/admin/src/scripts/exampleupdate.ldif
+++ b/ldap/admin/src/scripts/exampleupdate.ldif
@@ -37,4 +37,4 @@
#
# These files work the same way as the LDIF templates in
-# /usr/share/dirsrv/ldif/template*.ldif
+# /usr/share/dirsrv/data/template-*.ldif
| 0 |
ce44176803aa52ab8001113136bfbb7ff4a50972
|
389ds/389-ds-base
|
Ticket 48935 - Update dirsrv.systemd file
BUg Description: Two issues here. First the default system startup timeout
is set to 1 minute 30 seconds. But in the start-dirsrv script
it attempts to use a 10 minute timeout.
Second, starting in F23 systemd does not work well with valgrind.
systemd does not accept the notification once the DS starts.
So the start command actually fails after it times out.
Fix Description: For the first issue set the system startup timeout to match the
start-dirsrv script by setting:
TimeoutStartSecs=10min
Second, allow valgrind's startup success message to be
recognized/accepted we set:
NotifyAccess=all
https://fedorahosted.org/389/ticket/48935
Reviewed by: nhosoi(Thanks!)
|
commit ce44176803aa52ab8001113136bfbb7ff4a50972
Author: Mark Reynolds <[email protected]>
Date: Tue Jul 26 15:31:32 2016 -0400
Ticket 48935 - Update dirsrv.systemd file
BUg Description: Two issues here. First the default system startup timeout
is set to 1 minute 30 seconds. But in the start-dirsrv script
it attempts to use a 10 minute timeout.
Second, starting in F23 systemd does not work well with valgrind.
systemd does not accept the notification once the DS starts.
So the start command actually fails after it times out.
Fix Description: For the first issue set the system startup timeout to match the
start-dirsrv script by setting:
TimeoutStartSecs=10min
Second, allow valgrind's startup success message to be
recognized/accepted we set:
NotifyAccess=all
https://fedorahosted.org/389/ticket/48935
Reviewed by: nhosoi(Thanks!)
diff --git a/wrappers/systemd.template.sysconfig b/wrappers/systemd.template.sysconfig
index d88bdcdf8..e653c86c4 100644
--- a/wrappers/systemd.template.sysconfig
+++ b/wrappers/systemd.template.sysconfig
@@ -1,3 +1,6 @@
[Service]
+TimeoutStartSec=10m
+NotifyAccess=all
+
# uncomment this line to raise the file descriptor limit
# LimitNOFILE=8192
| 0 |
1d6dd39fb8b0ef8eb42ec9ef8c3d325e27a3d3c1
|
389ds/389-ds-base
|
Ticket 408 - create a normalized dn cache
Description: When we call slapi_dn_normalize_ext, first check if the dn is
in the cache. If it is, return the normalized dn(ndn), otherwise
make a copy of the raw/unnormalized dn so we can use it as the hash
key. We need to copy it because the normalize process consumes/modifys
the string. Then at the end of the slapi_dn_normalize_ext, we add the
ndn to the hash using the rawdn as the key.
This feature is configurable, and the max size can also be set. The
default is 20mb for max size. You can also monitor the cache searching
on the ldbm monitor(cn=monitor,cn=userRoot,cn=ldbm database,cn=plugins,cn=config).
https://fedorahosted.org/389/ticket/408
Reviewed by: richm & noriko (Thanks!)
|
commit 1d6dd39fb8b0ef8eb42ec9ef8c3d325e27a3d3c1
Author: Mark Reynolds <[email protected]>
Date: Thu Sep 13 10:00:56 2012 -0400
Ticket 408 - create a normalized dn cache
Description: When we call slapi_dn_normalize_ext, first check if the dn is
in the cache. If it is, return the normalized dn(ndn), otherwise
make a copy of the raw/unnormalized dn so we can use it as the hash
key. We need to copy it because the normalize process consumes/modifys
the string. Then at the end of the slapi_dn_normalize_ext, we add the
ndn to the hash using the rawdn as the key.
This feature is configurable, and the max size can also be set. The
default is 20mb for max size. You can also monitor the cache searching
on the ldbm monitor(cn=monitor,cn=userRoot,cn=ldbm database,cn=plugins,cn=config).
https://fedorahosted.org/389/ticket/408
Reviewed by: richm & noriko (Thanks!)
diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in
index ddf2b357b..c6267264b 100644
--- a/ldap/ldif/template-dse.ldif.in
+++ b/ldap/ldif/template-dse.ldif.in
@@ -53,9 +53,10 @@ nsslapd-auditlog-maxlogsize: 100
nsslapd-auditlog-logrotationtime: 1
nsslapd-auditlog-logrotationtimeunit: day
nsslapd-rootdn: %rootdn%
+nsslapd-rootpw: %ds_passwd%
nsslapd-maxdescriptors: 1024
nsslapd-max-filter-nest-level: 40
-nsslapd-rootpw: %ds_passwd%
+nsslapd-ndn-cache-enabled: off
dn: cn=features,cn=config
objectclass: top
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
index 62dfea17f..36ed768c4 100644
--- a/ldap/servers/slapd/attrsyntax.c
+++ b/ldap/servers/slapd/attrsyntax.c
@@ -201,29 +201,6 @@ attr_syntax_new()
return (struct asyntaxinfo *)slapi_ch_calloc(1, sizeof(struct asyntaxinfo));
}
-/*
- * hashNocaseString - used for case insensitive hash lookups
- */
-static PLHashNumber
-hashNocaseString(const void *key)
-{
- PLHashNumber h = 0;
- const unsigned char *s;
-
- for (s = key; *s; s++)
- h = (h >> 28) ^ (h << 4) ^ (tolower(*s));
- return h;
-}
-
-/*
- * hashNocaseCompare - used for case insensitive hash key comparisons
- */
-static PRIntn
-hashNocaseCompare(const void *v1, const void *v2)
-{
- return (strcasecmp((char *)v1, (char *)v2) == 0);
-}
-
/*
* Given an OID, return the syntax info. If there is more than one
* attribute syntax with the same OID (i.e. aliases), the first one
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 075a48fc2..ee4f01a48 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -70,8 +70,8 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
struct berval *vals[2];
char buf[BUFSIZ];
PRUint64 hits, tries;
- long nentries,maxentries;
- size_t size,maxsize;
+ long nentries, maxentries, count;
+ size_t size, maxsize;
/* NPCTE fix for bugid 544365, esc 0. <P.R> <04-Jul-2001> */
struct stat astat;
/* end of NPCTE fix for bugid 544365 */
@@ -145,6 +145,28 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
sprintf(buf, "%ld", maxentries);
MSET("maxDnCacheCount");
}
+ /* normalized dn cache stats */
+ if(config_get_ndn_cache_enabled()){
+ ndn_cache_get_stats(&hits, &tries, &size, &maxsize, &count);
+ sprintf(buf, "%" NSPRIu64, tries);
+ MSET("normalizedDnCacheTries");
+ sprintf(buf, "%" NSPRIu64, hits);
+ MSET("normalizedDnCacheHits");
+ sprintf(buf, "%" NSPRIu64, tries - hits);
+ MSET("normalizedDnCacheMisses");
+ sprintf(buf, "%lu", (unsigned long)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
+ MSET("normalizedDnCacheHitRatio");
+ sprintf(buf, "%lu", size);
+ MSET("currentNormalizedDnCacheSize");
+ if(maxsize == 0){
+ sprintf(buf, "%d", -1);
+ } else {
+ sprintf(buf, "%lu", maxsize);
+ }
+ MSET("maxNormalizedDnCacheSize");
+ sprintf(buf, "%ld", count);
+ MSET("currentNormalizedDnCacheCount");
+ }
#ifdef DEBUG
{
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 568871fb3..11e56a9e9 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -51,6 +51,7 @@
#include <sys/socket.h>
#endif
#include "slap.h"
+#include <plhash.h>
#undef SDN_DEBUG
@@ -61,6 +62,52 @@ static void sort_rdn_avs( struct berval *avs, int count, int escape );
static int rdn_av_cmp( struct berval *av1, struct berval *av2 );
static void rdn_av_swap( struct berval *av1, struct berval *av2, int escape );
+/* normalized dn cache related definitions*/
+struct
+ndn_cache_lru
+{
+ struct ndn_cache_lru *prev;
+ struct ndn_cache_lru *next;
+ char *key;
+};
+
+struct
+ndn_cache_ctx
+{
+ struct ndn_cache_lru *head;
+ struct ndn_cache_lru *tail;
+ Slapi_Counter *cache_hits;
+ Slapi_Counter *cache_tries;
+ Slapi_Counter *cache_misses;
+ size_t cache_size;
+ size_t cache_max_size;
+ long cache_count;
+};
+
+struct
+ndn_hash_val
+{
+ char *ndn;
+ size_t len;
+ int size;
+ struct ndn_cache_lru *lru_node; /* used to speed up lru shuffling */
+};
+
+#define NDN_FLUSH_COUNT 10000 /* number of DN's to remove when cache fills up */
+#define NDN_MIN_COUNT 1000 /* the minimum number of DN's to keep in the cache */
+#define NDN_CACHE_BUCKETS 2053 /* prime number */
+
+static PLHashNumber ndn_hash_string(const void *key);
+static int ndn_cache_lookup(char *dn, size_t dn_len, char **result, char **udn, int *rc);
+static void ndn_cache_update_lru(struct ndn_cache_lru **node);
+static void ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len);
+static void ndn_cache_delete(char *dn);
+static void ndn_cache_flush();
+static int ndn_started = 0;
+static PRLock *lru_lock = NULL;
+static Slapi_RWLock *ndn_cache_lock = NULL;
+static struct ndn_cache_ctx *ndn_cache = NULL;
+static PLHashTable *ndn_cache_hashtable = NULL;
#define ISBLANK(c) ((c) == ' ')
#define ISBLANKSTR(s) (((*(s)) == '2') && (*((s)+1) == '0'))
@@ -487,6 +534,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
char *ends = NULL;
char *endd = NULL;
char *lastesc = NULL;
+ char *udn;
/* rdn avs for the main DN */
char *typestart = NULL;
int rdn_av_count = 0;
@@ -511,6 +559,14 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
if (0 == src_len) {
src_len = strlen(src);
}
+ /*
+ * Check the normalized dn cache
+ */
+ if(ndn_cache_lookup(src, src_len, dest, &udn, &rc)){
+ *dest_len = strlen(*dest);
+ return rc;
+ }
+
s = PL_strnchr(src, '\\', src_len);
if (s) {
*dest_len = src_len * 3;
@@ -1072,6 +1128,10 @@ bail:
/* We terminate the str with NULL only when we allocate the str */
*d = '\0';
}
+ /* add this dn to the normalized dn cache */
+ if(*dest)
+ ndn_cache_add(udn, src_len, *dest, *dest_len);
+
return rc;
}
@@ -2567,3 +2627,290 @@ slapi_sdn_get_size(const Slapi_DN *sdn)
sz += strlen(sdn->dn) + 1;
return sz;
}
+
+/*
+ *
+ * Normalized DN Cache
+ *
+ */
+
+/*
+ * Hashing function using Bernstein's method
+ */
+static PLHashNumber
+ndn_hash_string(const void *key)
+{
+ PLHashNumber hash = 5381;
+ unsigned char *x = (unsigned char *)key;
+ int c;
+
+ while ((c = *x++)){
+ hash = ((hash << 5) + hash) ^ c;
+ }
+ return hash;
+}
+
+void
+ndn_cache_init()
+{
+ if(!config_get_ndn_cache_enabled()){
+ return;
+ }
+ ndn_cache_hashtable = PL_NewHashTable( NDN_CACHE_BUCKETS, ndn_hash_string, PL_CompareStrings, PL_CompareValues, 0, 0);
+ ndn_cache = (struct ndn_cache_ctx *)slapi_ch_malloc(sizeof(struct ndn_cache_ctx));
+ ndn_cache->cache_max_size = config_get_ndn_cache_size();
+ ndn_cache->cache_hits = slapi_counter_new();
+ ndn_cache->cache_tries = slapi_counter_new();
+ ndn_cache->cache_misses = slapi_counter_new();
+ ndn_cache->cache_count = 0;
+ ndn_cache->cache_size = sizeof(struct ndn_cache_ctx) + sizeof(PLHashTable) + sizeof(PLHashTable);
+ ndn_cache->head = NULL;
+ ndn_cache->tail = NULL;
+
+ if ( NULL == ( lru_lock = PR_NewLock()) || NULL == ( ndn_cache_lock = slapi_new_rwlock())) {
+ char *errorbuf = NULL;
+ if(ndn_cache_hashtable){
+ PL_HashTableDestroy(ndn_cache_hashtable);
+ }
+ ndn_cache_hashtable = NULL;
+ config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", errorbuf, 1 );
+ slapi_counter_destroy(&ndn_cache->cache_hits);
+ slapi_counter_destroy(&ndn_cache->cache_tries);
+ slapi_counter_destroy(&ndn_cache->cache_misses);
+ slapi_ch_free((void **)&ndn_cache);
+ slapi_log_error( SLAPI_LOG_FATAL, "ndn_cache_init", "Failed to create locks. Disabling cache.\n" );
+ } else {
+ ndn_started = 1;
+ }
+}
+
+/*
+ * Look up this dn in the ndn cache
+ */
+static int
+ndn_cache_lookup(char *dn, size_t dn_len, char **result, char **udn, int *rc)
+{
+ struct ndn_hash_val *ndn_ht_val = NULL;
+ char *ndn, *key;
+ int rv = 0;
+
+ if(ndn_started == 0){
+ return rv;
+ }
+ if(dn_len == 0){
+ *result = dn;
+ *rc = 0;
+ return 1;
+ }
+ slapi_counter_increment(ndn_cache->cache_tries);
+ slapi_rwlock_rdlock(ndn_cache_lock);
+ ndn_ht_val = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
+ if(ndn_ht_val){
+ ndn_cache_update_lru(&ndn_ht_val->lru_node);
+ slapi_counter_increment(ndn_cache->cache_hits);
+ if(ndn_ht_val->len == dn_len ){
+ /* the dn was already normalized, just return the dn as the result */
+ *result = dn;
+ *rc = 0;
+ } else {
+ *rc = 1; /* free result */
+ ndn = slapi_ch_malloc(ndn_ht_val->len + 1);
+ memcpy(ndn, ndn_ht_val->ndn, ndn_ht_val->len);
+ ndn[ndn_ht_val->len] = '\0';
+ *result = ndn;
+ }
+ rv = 1;
+ } else {
+ /* copy/preserve the udn, so we can use it as the key when we add dn's to the hashtable */
+ key = slapi_ch_malloc(dn_len + 1);
+ memcpy(key, dn, dn_len);
+ key[dn_len] = '\0';
+ *udn = key;
+ }
+ slapi_rwlock_unlock(ndn_cache_lock);
+
+ return rv;
+}
+
+/*
+ * Move this lru node to the top of the list
+ */
+static void
+ndn_cache_update_lru(struct ndn_cache_lru **node)
+{
+ struct ndn_cache_lru *prev, *next, *curr_node = *node;
+
+ if(curr_node == NULL){
+ return;
+ }
+ PR_Lock(lru_lock);
+ if(curr_node->prev == NULL){
+ /* already the top node */
+ PR_Unlock(lru_lock);
+ return;
+ }
+ prev = curr_node->prev;
+ next = curr_node->next;
+ if(next){
+ next->prev = prev;
+ prev->next = next;
+ } else {
+ /* this was the tail, so reset the tail */
+ ndn_cache->tail = prev;
+ prev->next = NULL;
+ }
+ curr_node->prev = NULL;
+ curr_node->next = ndn_cache->head;
+ ndn_cache->head->prev = curr_node;
+ ndn_cache->head = curr_node;
+ PR_Unlock(lru_lock);
+}
+
+/*
+ * Add a ndn to the cache. Try and do as much as possible before taking the write lock.
+ */
+static void
+ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len)
+{
+ struct ndn_hash_val *ht_entry;
+ struct ndn_cache_lru *new_node = NULL;
+ PLHashEntry *he;
+ int size;
+
+ if(ndn_started == 0 || dn_len == 0){
+ return;
+ }
+ if(strlen(ndn) > ndn_len){
+ /* we need to null terminate the ndn */
+ *(ndn + ndn_len) = '\0';
+ }
+ /*
+ * Calculate the approximate memory footprint of the hash entry, key, and lru entry.
+ */
+ size = (dn_len * 2) + ndn_len + sizeof(PLHashEntry) + sizeof(struct ndn_hash_val) + sizeof(struct ndn_cache_lru);
+ /*
+ * Create our LRU node
+ */
+ new_node = (struct ndn_cache_lru *)slapi_ch_malloc(sizeof(struct ndn_cache_lru));
+ if(new_node == NULL){
+ slapi_log_error( SLAPI_LOG_FATAL, "ndn_cache_add", "Failed to allocate new lru node.\n");
+ return;
+ }
+ new_node->prev = NULL;
+ new_node->key = dn; /* dn has already been allocated */
+ /*
+ * Its possible this dn was added to the hash by another thread.
+ */
+ slapi_rwlock_wrlock(ndn_cache_lock);
+ ht_entry = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
+ if(ht_entry){
+ /* already exists, free the node and return */
+ slapi_rwlock_unlock(ndn_cache_lock);
+ slapi_ch_free_string(&new_node->key);
+ slapi_ch_free((void **)&new_node);
+ return;
+ }
+ /*
+ * Create the hash entry
+ */
+ ht_entry = (struct ndn_hash_val *)slapi_ch_malloc(sizeof(struct ndn_hash_val));
+ if(ht_entry == NULL){
+ slapi_rwlock_unlock(ndn_cache_lock);
+ slapi_log_error( SLAPI_LOG_FATAL, "ndn_cache_add", "Failed to allocate new hash entry.\n");
+ slapi_ch_free_string(&new_node->key);
+ slapi_ch_free((void **)&new_node);
+ return;
+ }
+ ht_entry->ndn = slapi_ch_malloc(ndn_len + 1);
+ memcpy(ht_entry->ndn, ndn, ndn_len);
+ ht_entry->ndn[ndn_len] = '\0';
+ ht_entry->len = ndn_len;
+ ht_entry->size = size;
+ ht_entry->lru_node = new_node;
+ /*
+ * Check if our cache is full
+ */
+ PR_Lock(lru_lock); /* grab the lru lock now, as ndn_cache_flush needs it */
+ if(ndn_cache->cache_max_size != 0 && ((ndn_cache->cache_size + size) > ndn_cache->cache_max_size)){
+ ndn_cache_flush();
+ }
+ /*
+ * Set the ndn cache lru nodes
+ */
+ if(ndn_cache->head == NULL && ndn_cache->tail == NULL){
+ /* this is the first node */
+ ndn_cache->head = new_node;
+ ndn_cache->tail = new_node;
+ new_node->next = NULL;
+ } else {
+ new_node->next = ndn_cache->head;
+ ndn_cache->head->prev = new_node;
+ }
+ ndn_cache->head = new_node;
+ PR_Unlock(lru_lock);
+ /*
+ * Add the new object to the hashtable, and update our stats
+ */
+ he = PL_HashTableAdd(ndn_cache_hashtable, new_node->key, (void *)ht_entry);
+ if(he == NULL){
+ slapi_log_error( SLAPI_LOG_FATAL, "ndn_cache_add", "Failed to add new entry to hash(%s)\n",dn);
+ } else {
+ ndn_cache->cache_count++;
+ ndn_cache->cache_size += size;
+ }
+ slapi_rwlock_unlock(ndn_cache_lock);
+}
+
+/*
+ * cache is full, remove the least used dn's. lru_lock/ndn_cache write lock are already taken
+ */
+static void
+ndn_cache_flush()
+{
+ struct ndn_cache_lru *node, *next, *flush_node;
+ int i;
+
+ node = ndn_cache->tail;
+ for(i = 0; i < NDN_FLUSH_COUNT && ndn_cache->cache_count > NDN_MIN_COUNT; i++){
+ flush_node = node;
+ /* update the lru */
+ next = node->prev;
+ next->next = NULL;
+ ndn_cache->tail = next;
+ node = next;
+ /* now update the hash */
+ ndn_cache->cache_count--;
+ ndn_cache_delete(flush_node->key);
+ slapi_ch_free_string(&flush_node->key);
+ slapi_ch_free((void **)&flush_node);
+ }
+
+ slapi_log_error( SLAPI_LOG_CACHE, "ndn_cache_flush","Flushed cache.\n");
+}
+
+/* this is already "write" locked from ndn_cache_add */
+static void
+ndn_cache_delete(char *dn)
+{
+ struct ndn_hash_val *ht_val;
+
+ ht_val = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
+ if(ht_val){
+ ndn_cache->cache_size -= ht_val->size;
+ slapi_ch_free_string(&ht_val->ndn);
+ PL_HashTableRemove(ndn_cache_hashtable, dn);
+ }
+}
+/* stats for monitor */
+void
+ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, long *count)
+{
+ slapi_rwlock_rdlock(ndn_cache_lock);
+ *hits = slapi_counter_get_value(ndn_cache->cache_hits);
+ *tries = slapi_counter_get_value(ndn_cache->cache_tries);
+ *size = ndn_cache->cache_size;
+ *max_size = ndn_cache->cache_max_size;
+ *count = ndn_cache->cache_count;
+ slapi_rwlock_unlock(ndn_cache_lock);
+}
+
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 3226ede46..dc8452aa1 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -691,6 +691,14 @@ static struct config_get_and_set {
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_preserve_logging,
CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_preserve_logging},
+ {CONFIG_NDN_CACHE, config_set_ndn_cache_enabled,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.ndn_cache_enabled, CONFIG_INT,
+ (ConfigGetFunc)config_get_ndn_cache_enabled},
+ {CONFIG_NDN_CACHE_SIZE, config_set_ndn_cache_max_size,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.ndn_cache_max_size,
+ CONFIG_INT, (ConfigGetFunc)config_get_ndn_cache_size},
#ifdef MEMPOOL_EXPERIMENTAL
,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
NULL, 0,
@@ -704,7 +712,7 @@ static struct config_get_and_set {
/*
* hashNocaseString - used for case insensitive hash lookups
*/
-static PLHashNumber
+PLHashNumber
hashNocaseString(const void *key)
{
PLHashNumber h = 0;
@@ -718,7 +726,7 @@ hashNocaseString(const void *key)
/*
* hashNocaseCompare - used for case insensitive hash key comparisons
*/
-static PRIntn
+PRIntn
hashNocaseCompare(const void *v1, const void *v2)
{
return (strcasecmp((char *)v1, (char *)v2) == 0);
@@ -1092,6 +1100,8 @@ FrontendConfig_init () {
cfg->disk_grace_period = 60; /* 1 hour */
cfg->disk_preserve_logging = LDAP_OFF;
cfg->disk_logging_critical = LDAP_OFF;
+ cfg->ndn_cache_enabled = LDAP_OFF;
+ cfg->ndn_cache_max_size = NDN_DEFAULT_SIZE;
#ifdef MEMPOOL_EXPERIMENTAL
cfg->mempool_switch = LDAP_ON;
@@ -1310,6 +1320,42 @@ config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf,
return retVal;
}
+int
+config_set_ndn_cache_enabled(const char *attrname, char *value, char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->ndn_cache_enabled), errorbuf, apply);
+
+ return retVal;
+}
+
+int
+config_set_ndn_cache_max_size(const char *attrname, char *value, char *errorbuf, int apply )
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ long size;
+ int retVal = LDAP_SUCCESS;
+
+ size = atol(value);
+ if(size < 0){
+ size = 0; /* same as -1 */
+ }
+ if(size > 0 && size < 1024000){
+ PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "ndn_cache_max_size too low(%d), changing to "
+ "%d bytes.\n",(int)size, NDN_DEFAULT_SIZE);
+ size = NDN_DEFAULT_SIZE;
+ }
+ if(apply){
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapdFrontendConfig->ndn_cache_max_size = size;
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ }
+
+ return retVal;
+}
+
int
config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
long nPort;
@@ -5213,6 +5259,27 @@ config_get_max_filter_nest_level()
return retVal;
}
+size_t
+config_get_ndn_cache_size(){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ size_t retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = slapdFrontendConfig->ndn_cache_max_size;
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+ return retVal;
+}
+
+int
+config_get_ndn_cache_enabled(){
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = slapdFrontendConfig->ndn_cache_enabled;
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+ return retVal;
+}
char *
config_get_basedn() {
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 69314cc7a..03d708630 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -1042,6 +1042,9 @@ main( int argc, char **argv)
}
}
+ /* initialize the normalized DN cache */
+ ndn_cache_init();
+
/*
* Detach ourselves from the terminal (unless running in debug mode).
* We must detach before we start any threads since detach forks() on
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index cdd5eec5f..55c3a7867 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -388,6 +388,8 @@ int config_set_disk_grace_period( const char *attrname, char *value, char *error
int config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply);
+int config_set_ndn_cache_enabled(const char *attrname, char *value, char *errorbuf, int apply);
+int config_set_ndn_cache_max_size(const char *attrname, char *value, char *errorbuf, int apply);
#if !defined(_WIN32) && !defined(AIX)
int config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply );
@@ -543,6 +545,11 @@ long config_get_disk_threshold();
int config_get_disk_grace_period();
int config_get_disk_preserve_logging();
int config_get_disk_logging_critical();
+int config_get_ndn_cache_count();
+size_t config_get_ndn_cache_size();
+int config_get_ndn_cache_enabled();
+PLHashNumber hashNocaseString(const void *key);
+PRIntn hashNocaseCompare(const void *v1, const void *v2);
int is_abspath(const char *);
char* rel2abspath( char * );
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index ba76b65ca..c66c3207b 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -250,22 +250,6 @@ dont_allow_that(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int
return SLAPI_DSE_CALLBACK_ERROR;
}
-#if 0
-/*
- * hashNocaseString - used for case insensitive hash lookups
- */
-static PLHashNumber
-hashNocaseString(const void *key)
-{
- PLHashNumber h = 0;
- const unsigned char *s;
-
- for (s = key; *s; s++)
- h = (h >> 28) ^ (h << 4) ^ (tolower(*s));
- return h;
-}
-#endif
-
static const char *
skipWS(const char *s)
{
@@ -278,7 +262,6 @@ skipWS(const char *s)
return s;
}
-
/*
* like strchr() but strings within single quotes are skipped.
*/
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index ca1cb874c..33607cb34 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2012,6 +2012,8 @@ typedef struct _slapdEntryPoints {
#define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
#define CONFIG_DISK_PRESERVE_LOGGING "nsslapd-disk-monitoring-preserve-logging"
#define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical"
+#define CONFIG_NDN_CACHE "nsslapd-ndn-cache-enabled"
+#define CONFIG_NDN_CACHE_SIZE "nsslapd-ndn-cache-max-size"
#ifdef MEMPOOL_EXPERIMENTAL
#define CONFIG_MEMPOOL_SWITCH_ATTRIBUTE "nsslapd-mempool"
@@ -2247,6 +2249,10 @@ typedef struct _slapdFrontendConfig {
int disk_grace_period;
int disk_preserve_logging;
int disk_logging_critical;
+
+ /* normalized dn cache */
+ int ndn_cache_enabled;
+ size_t ndn_cache_max_size;
} slapdFrontendConfig_t;
/* possible values for slapdFrontendConfig_t.schemareplace */
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index a57b4530d..6c2781c29 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -384,12 +384,14 @@ Slapi_DN *slapi_sdn_init_normdn_ndn_passin(Slapi_DN *sdn, const char *dn);
Slapi_DN *slapi_sdn_init_normdn_passin(Slapi_DN *sdn, const char *dn);
char *slapi_dn_normalize_original( char *dn );
char *slapi_dn_normalize_case_original( char *dn );
+void ndn_cache_init();
+void ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, long *count);
+#define NDN_DEFAULT_SIZE 20971520 /* 20mb - size of normalized dn cache */
/* filter.c */
int filter_flag_is_set(const Slapi_Filter *f,unsigned char flag);
char *slapi_filter_to_string(const Slapi_Filter *f, char *buffer, size_t bufsize);
-char *
-slapi_filter_to_string_internal( const struct slapi_filter *f, char *buf, size_t *bufsize );
+char *slapi_filter_to_string_internal( const struct slapi_filter *f, char *buf, size_t *bufsize );
/* operation.c */
| 0 |
ded0b0bf0b108553c528b6819a418559f4305245
|
389ds/389-ds-base
|
169954 - Moved illegal declaration to the top of code block
|
commit ded0b0bf0b108553c528b6819a418559f4305245
Author: Nathan Kinder <[email protected]>
Date: Thu Oct 6 18:23:10 2005 +0000
169954 - Moved illegal declaration to the top of code block
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index 779ba3745..106972dfe 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -569,6 +569,8 @@ windows_search_entry(Repl_Connection *conn, char* searchbase, char *filter, Slap
&conn->timeout, 0 /* sizelimit */, &res);
if (LDAP_SUCCESS == ldap_rc)
{
+ LDAPMessage *message = ldap_first_entry(conn->ld, res);
+
if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
nummessages = ldap_count_messages(conn->ld, res);
numentries = ldap_count_entries(conn->ld, res);
@@ -576,7 +578,7 @@ windows_search_entry(Repl_Connection *conn, char* searchbase, char *filter, Slap
LDAPDebug( LDAP_DEBUG_REPL, "windows_search_entry: recieved %d messages, %d entries, %d references\n",
nummessages, numentries, numreferences );
}
- LDAPMessage *message = ldap_first_entry(conn->ld, res);
+
if (NULL != entry)
{
*entry = windows_LDAPMessage2Entry(conn->ld,message,0);
| 0 |
4d448d3829d21f22d6363cac96a5e00850ee6942
|
389ds/389-ds-base
|
Ticket 49024 - Fix inst_dir parameter in defaults.inf
Description: The inst_dir parameter has wrong value that differs
from nsslapd-instancedir. Set inst_dir to @serverdir@ value.
Fix tests accordingly.
https://fedorahosted.org/389/ticket/49024
Reviewed by: wibrown (Thanks!)
|
commit 4d448d3829d21f22d6363cac96a5e00850ee6942
Author: Simon Pichugin <[email protected]>
Date: Mon Nov 7 21:01:56 2016 +0100
Ticket 49024 - Fix inst_dir parameter in defaults.inf
Description: The inst_dir parameter has wrong value that differs
from nsslapd-instancedir. Set inst_dir to @serverdir@ value.
Fix tests accordingly.
https://fedorahosted.org/389/ticket/49024
Reviewed by: wibrown (Thanks!)
diff --git a/dirsrvtests/tests/tickets/ticket47669_test.py b/dirsrvtests/tests/tickets/ticket47669_test.py
index fd5299c52..021ec1539 100644
--- a/dirsrvtests/tests/tickets/ticket47669_test.py
+++ b/dirsrvtests/tests/tickets/ticket47669_test.py
@@ -85,7 +85,7 @@ def test_ticket47669_init(topology):
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
try:
- changelogdir = os.path.join(topology.standalone.inst_dir, 'changelog')
+ changelogdir = os.path.join(os.path.dirname(topology.standalone.dbdir), 'changelog')
topology.standalone.add_s(Entry((CHANGELOG,
{'objectclass': 'top extensibleObject'.split(),
'nsslapd-changelogdir': changelogdir})))
diff --git a/ldap/admin/src/defaults.inf.in b/ldap/admin/src/defaults.inf.in
index 7729c06d7..31dbf2f13 100644
--- a/ldap/admin/src/defaults.inf.in
+++ b/ldap/admin/src/defaults.inf.in
@@ -34,6 +34,7 @@ config_dir = @instconfigdir@/slapd-{instance_name}
local_state_dir = @localstatedir@
run_dir = @localstatedir@/run/dirsrv
pid_file = @localstatedir@/run/dirsrv/slapd-{instance_name}.pid
+inst_dir = @serverdir@
plugin_dir = @serverplugindir@
; These values can be altered in an installation of ds
@@ -49,7 +50,6 @@ log_dir = @localstatedir@/log/dirsrv/slapd-{instance_name}
access_log = @localstatedir@/log/dirsrv/slapd-{instance_name}/access
audit_log = @localstatedir@/log/dirsrv/slapd-{instance_name}/audit
error_log = @localstatedir@/log/dirsrv/slapd-{instance_name}/errors
-inst_dir = @localstatedir@/lib/dirsrv/slapd-{instance_name}
db_dir = @localstatedir@/lib/dirsrv/slapd-{instance_name}/db
backup_dir = @localstatedir@/lib/dirsrv/slapd-{instance_name}/bak
ldif_dir = @localstatedir@/lib/dirsrv/slapd-{instance_name}/ldif
| 0 |
e98841c722645d45d59428e1c0da53a924311938
|
389ds/389-ds-base
|
bump version to 1.2.7.4
|
commit e98841c722645d45d59428e1c0da53a924311938
Author: Rich Megginson <[email protected]>
Date: Fri Dec 10 11:26:21 2010 -0700
bump version to 1.2.7.4
diff --git a/VERSION.sh b/VERSION.sh
index fa4dc3885..23e16b785 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -10,7 +10,7 @@ vendor="389 Project"
# PACKAGE_VERSION is constructed from these
VERSION_MAJOR=1
VERSION_MINOR=2
-VERSION_MAINT=7.3
+VERSION_MAINT=7.4
# if this is a PRERELEASE, set VERSION_PREREL
# otherwise, comment it out
# be sure to include the dot prefix in the prerel
| 0 |
b903b039f83556f2bbca1b7cfe12c3fb87e3e509
|
389ds/389-ds-base
|
Issue 49820 - lib389 requires wrong python ldap library
Bug Description:
python3-ldap [1] is not the same as python-ldap [2].
[1] https://pypi.org/project/python3-ldap/
[2] https://pypi.org/project/python-ldap/
Fix Description:
Update setup.py and requirements.txt.
https://pagure.io/389-ds-base/issue/49820
Reviewed by: mreynolds (Thanks!)
|
commit b903b039f83556f2bbca1b7cfe12c3fb87e3e509
Author: Viktor Ashirov <[email protected]>
Date: Mon Jul 2 14:01:42 2018 +0200
Issue 49820 - lib389 requires wrong python ldap library
Bug Description:
python3-ldap [1] is not the same as python-ldap [2].
[1] https://pypi.org/project/python3-ldap/
[2] https://pypi.org/project/python-ldap/
Fix Description:
Update setup.py and requirements.txt.
https://pagure.io/389-ds-base/issue/49820
Reviewed by: mreynolds (Thanks!)
diff --git a/src/lib389/requirements.txt b/src/lib389/requirements.txt
index 842bdc40d..2b2582d64 100644
--- a/src/lib389/requirements.txt
+++ b/src/lib389/requirements.txt
@@ -5,4 +5,4 @@ python-dateutil
six
argcomplete
argparse-manpage
-python3-ldap
+python-ldap
diff --git a/src/lib389/setup.py b/src/lib389/setup.py
index a14e80697..52122b6c6 100644
--- a/src/lib389/setup.py
+++ b/src/lib389/setup.py
@@ -76,7 +76,7 @@ setup(
'six',
'argcomplete',
'argparse-manpage',
- 'python3-ldap',
+ 'python-ldap',
],
cmdclass={
| 0 |
17f3624c19929ffa1d37a567b7a889fd397cca59
|
389ds/389-ds-base
|
Ticket #548 - RFE: Allow AD password sync to update shadowLastChange
Shadow Account Support Design - http://www.port389.org/docs/389ds/design/shadow-account-support.html
https://fedorahosted.org/389/ticket/548
Reviewed by [email protected] (Thank you, Mark!!)
|
commit 17f3624c19929ffa1d37a567b7a889fd397cca59
Author: Noriko Hosoi <[email protected]>
Date: Mon Oct 26 22:11:43 2015 -0700
Ticket #548 - RFE: Allow AD password sync to update shadowLastChange
Shadow Account Support Design - http://www.port389.org/docs/389ds/design/shadow-account-support.html
https://fedorahosted.org/389/ticket/548
Reviewed by [email protected] (Thank you, Mark!!)
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index a3c4243af..fde388516 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1447,7 +1447,7 @@ FrontendConfig_init () {
cfg->pw_policy.pw_mintokenlength = 3;
cfg->pw_policy.pw_maxage = 8640000; /* 100 days */
cfg->pw_policy.pw_minage = 0;
- cfg->pw_policy.pw_warning = 86400; /* 1 day */
+ cfg->pw_policy.pw_warning = _SEC_PER_DAY; /* 1 day */
init_pw_history = cfg->pw_policy.pw_history = LDAP_OFF;
cfg->pw_policy.pw_inhistory = 6;
init_pw_lockout = cfg->pw_policy.pw_lockout = LDAP_OFF;
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 2ec90de6d..78701c4a5 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -200,7 +200,7 @@ void g_log_init(int log_enabled)
loginfo.log_access_rotationsyncclock = -1;
loginfo.log_access_rotationtime = 1; /* default: 1 */
loginfo.log_access_rotationunit = LOG_UNIT_DAYS; /* default: day */
- loginfo.log_access_rotationtime_secs = 86400; /* default: 1 day */
+ loginfo.log_access_rotationtime_secs = _SEC_PER_DAY; /* default: 1 day */
loginfo.log_access_maxdiskspace = -1;
loginfo.log_access_minfreespace = -1;
loginfo.log_access_exptime = -1; /* default: -1 */
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index dcdbb048d..4fe796968 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -1439,6 +1439,8 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
done = 1;
continue;
}
+ /* Adding shadow password attrs. */
+ add_shadow_ext_password_attrs(pb, e);
if (process_entry(pb, e, send_result))
{
/* shouldn't send this entry */
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index b10c1ebad..c49f1d198 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -917,6 +917,7 @@ void add_password_attrs( Slapi_PBlock *pb, Operation *op, Slapi_Entry *e );
void mod_allowchange_aci(char *val);
void pw_mod_allowchange_aci(int pw_prohibit_change);
void pw_add_allowchange_aci(Slapi_Entry *e, int pw_prohibit_change);
+void add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry *e);
/*
* pw_retry.c
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 4e222d75e..3985c2b3a 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -611,6 +611,13 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw)
cur_time = current_time();
slapi_mods_init(&smods, 0);
+ if (slapi_entry_attr_hasvalue(e, SLAPI_ATTR_OBJECTCLASS, "shadowAccount")) {
+ time_t ctime = cur_time / _SEC_PER_DAY;
+ timestr = slapi_ch_smprintf("%ld", ctime);
+ slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "shadowLastChange", timestr);
+ slapi_ch_free_string(×tr);
+ }
+
/* update passwordHistory */
if ( old_pw != NULL && pwpolicy->pw_history == 1 ) {
(void)update_pw_history(pb, sdn, old_pw);
@@ -699,7 +706,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw)
timestr = format_genTime ( pw_exp_date );
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpirationTime", timestr);
- slapi_ch_free((void **)×tr);
+ slapi_ch_free_string(×tr);
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpWarned", "0");
@@ -722,8 +729,7 @@ check_pw_minage ( Slapi_PBlock *pb, const Slapi_DN *sdn, struct berval **vals)
pwpolicy = new_passwdPolicy(pb, dn);
slapi_pblock_get ( pb, SLAPI_PWPOLICY, &pwresponse_req );
- if ( !pb->pb_op->o_isroot &&
- pwpolicy->pw_minage != 0 ) {
+ if (!pb->pb_op->o_isroot && !pwpolicy->pw_minage) {
Slapi_Entry *e;
char *passwordAllowChangeTime;
@@ -753,9 +759,7 @@ check_pw_minage ( Slapi_PBlock *pb, const Slapi_DN *sdn, struct berval **vals)
slapi_pwpolicy_make_response_control ( pb, -1, -1,
LDAP_PWPOLICY_PWDTOOYOUNG );
}
- pw_send_ldap_result ( pb,
- LDAP_CONSTRAINT_VIOLATION, NULL,
- "within password minimum age", 0, NULL );
+ pw_send_ldap_result(pb, LDAP_CONSTRAINT_VIOLATION, NULL, "within password minimum age", 0, NULL);
slapi_entry_free( e );
slapi_ch_free((void **) &cur_time_str );
return ( 1 );
@@ -1379,17 +1383,23 @@ add_password_attrs( Slapi_PBlock *pb, Operation *op, Slapi_Entry *e )
const char *dn = slapi_entry_get_ndn(e);
int has_allowchangetime = 0, has_expirationtime = 0;
time_t existing_exptime = 0;
+ time_t exptime = 0;
+ int isShadowAccount = 0;
+ int has_shadowLastChange = 0;
- LDAPDebug( LDAP_DEBUG_TRACE, "add_password_attrs\n", 0, 0, 0 );
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "add_password_attrs\n");
bvals[0] = &bv;
bvals[1] = NULL;
-
+
+ if (slapi_entry_attr_hasvalue(e, SLAPI_ATTR_OBJECTCLASS, "shadowAccount")) {
+ isShadowAccount = 1;
+ }
+
/* If passwordexpirationtime is specified by the user, don't
try to assign the initial value */
- for ( a = &e->e_attrs; *a != NULL; a = next ) {
- if ( strcasecmp( (*a)->a_type,
- "passwordexpirationtime" ) == 0) {
+ for (a = &e->e_attrs; a && *a; a = next) {
+ if (!strcasecmp((*a)->a_type, "passwordexpirationtime")) {
Slapi_Value *sval;
if (slapi_attr_first_value(*a, &sval) == 0) {
const struct berval *bv = slapi_value_get_berval(sval);
@@ -1397,32 +1407,44 @@ add_password_attrs( Slapi_PBlock *pb, Operation *op, Slapi_Entry *e )
}
has_expirationtime = 1;
- } else if ( strcasecmp( (*a)->a_type,
- "passwordallowchangetime" ) == 0) {
+ } else if (!strcasecmp((*a)->a_type, "passwordallowchangetime")) {
has_allowchangetime = 1;
+ } else if (isShadowAccount && !strcasecmp((*a)->a_type, "shadowlastchange")) {
+ has_shadowLastChange = 1;
}
next = &(*a)->a_next;
}
- if ( has_allowchangetime && has_expirationtime ) {
+ if (has_allowchangetime && has_expirationtime && has_shadowLastChange) {
return;
}
pwpolicy = new_passwdPolicy(pb, dn);
- if ( !has_expirationtime &&
- ( pwpolicy->pw_exp || pwpolicy->pw_must_change ) ) {
- if ( pwpolicy->pw_must_change) {
+ if (!has_expirationtime && (pwpolicy->pw_exp || pwpolicy->pw_must_change)) {
+ if (pwpolicy->pw_must_change) {
/* must change password when first time logon */
bv.bv_val = format_genTime ( NO_TIME );
} else if ( pwpolicy->pw_exp ) {
- bv.bv_val = format_genTime ( time_plus_sec ( current_time (),
- pwpolicy->pw_maxage ) );
+ exptime = time_plus_sec(current_time(), pwpolicy->pw_maxage);
+ bv.bv_val = format_genTime(exptime);
}
bv.bv_len = strlen( bv.bv_val );
slapi_entry_attr_merge( e, "passwordexpirationtime", bvals );
slapi_ch_free_string( &bv.bv_val );
}
+ if (isShadowAccount && !has_shadowLastChange) {
+ if (pwpolicy->pw_must_change) {
+ /* must change password when first time logon */
+ bv.bv_val = slapi_ch_smprintf("0");
+ } else {
+ exptime = current_time() / _SEC_PER_DAY;
+ bv.bv_val = slapi_ch_smprintf("%ld", exptime);
+ }
+ bv.bv_len = strlen(bv.bv_val);
+ slapi_entry_attr_merge(e, "shadowLastChange", bvals);
+ slapi_ch_free_string(&bv.bv_val);
+ }
/*
* If the password minimum age is not 0, calculate when the password
@@ -1434,12 +1456,11 @@ add_password_attrs( Slapi_PBlock *pb, Operation *op, Slapi_Entry *e )
*/
if ( !has_allowchangetime && pwpolicy->pw_minage != 0 &&
(has_expirationtime && existing_exptime > current_time()) ) {
- bv.bv_val = format_genTime ( time_plus_sec ( current_time (),
- pwpolicy->pw_minage ) );
+ bv.bv_val = format_genTime ( time_plus_sec ( current_time (), pwpolicy->pw_minage ) );
bv.bv_len = strlen( bv.bv_val );
-
+
slapi_entry_attr_merge( e, "passwordallowchangetime", bvals );
- slapi_ch_free((void **) &bv.bv_val );
+ slapi_ch_free_string( &bv.bv_val );
}
}
@@ -2800,3 +2821,103 @@ pw_get_ext_size(Slapi_Entry *entry, size_t *size)
}
return LDAP_SUCCESS;
}
+
+void
+add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry *e)
+{
+ const char *dn = NULL;
+ passwdPolicy *pwpolicy = NULL;
+ time_t shadowval = 0;
+ time_t exptime = 0;
+ struct berval bv;
+ struct berval *bvals[2];
+
+ if (!e) {
+ return;
+ }
+ dn = slapi_entry_get_ndn(e);
+ if (!dn) {
+ return;
+ }
+ if (!slapi_entry_attr_hasvalue(e, SLAPI_ATTR_OBJECTCLASS, "shadowAccount")) {
+ /* Not a shadowAccount; nothing to do. */
+ return;
+ }
+ if (operation_is_flag_set(pb->pb_op, OP_FLAG_INTERNAL)) {
+ /* external only */
+ return;
+ }
+ pwpolicy = new_passwdPolicy(pb, dn);
+ if (!pwpolicy) {
+ return;
+ }
+
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> add_shadow_password_attrs\n");
+
+ bvals[0] = &bv;
+ bvals[1] = NULL;
+
+ /* shadowMin - the minimum number of days required between password changes. */
+ if (pwpolicy->pw_minage > 0) {
+ shadowval = pwpolicy->pw_minage / _SEC_PER_DAY;
+ } else {
+ shadowval = 0;
+ }
+ bv.bv_val = slapi_ch_smprintf("%ld", shadowval);
+ bv.bv_len = strlen(bv.bv_val);
+ slapi_entry_attr_replace(e, "shadowMin", bvals);
+ slapi_ch_free_string(&bv.bv_val);
+
+ /* shadowMax - the maximum number of days for which the user password remains valid. */
+ if (pwpolicy->pw_maxage > 0) {
+ shadowval = pwpolicy->pw_maxage / _SEC_PER_DAY;
+ exptime = time_plus_sec(current_time(), pwpolicy->pw_maxage);
+ } else {
+ shadowval = 99999;
+ }
+ bv.bv_val = slapi_ch_smprintf("%ld", shadowval);
+ bv.bv_len = strlen(bv.bv_val);
+ slapi_entry_attr_replace(e, "shadowMax", bvals);
+ slapi_ch_free_string(&bv.bv_val);
+
+ /* shadowWarning - the number of days of advance warning given to the user before the user password expires. */
+ if (pwpolicy->pw_warning > 0) {
+ shadowval = pwpolicy->pw_warning / _SEC_PER_DAY;
+ } else {
+ shadowval = 0;
+ }
+ bv.bv_val = slapi_ch_smprintf("%ld", shadowval);
+ bv.bv_len = strlen(bv.bv_val);
+ slapi_entry_attr_replace(e, "shadowWarning", bvals);
+ slapi_ch_free_string(&bv.bv_val);
+
+ /* shadowExpire - the date on which the user login will be disabled. */
+ if (exptime) {
+ exptime /= _SEC_PER_DAY;
+ bv.bv_val = slapi_ch_smprintf("%ld", exptime);
+ bv.bv_len = strlen(bv.bv_val);
+ slapi_entry_attr_replace(e, "shadowExpire", bvals);
+ slapi_ch_free_string(&bv.bv_val);
+ }
+
+#if 0 /* These 2 attributes are no need (or not able) to auto-fill. */
+ /*
+ * shadowInactive - the number of days of inactivity allowed for the user.
+ * Password Policy does not have the corresponding parameter.
+ */
+ shadowval = 0;
+ bv.bv_val = slapi_ch_smprintf("%ld", shadowval);
+ bv.bv_len = strlen(bv.bv_val);
+ slapi_entry_attr_replace(e, "shadowInactive", bvals);
+ slapi_ch_free_string(&bv.bv_val);
+
+ /* shadowFlag - not currently in use. */
+ bv.bv_val = slapi_ch_smprintf("%d", 0);
+ bv.bv_len = strlen(bv.bv_val);
+ slapi_entry_attr_replace(e, "shadowFlag", bvals);
+ slapi_ch_free_string(&bv.bv_val);
+#endif
+
+ LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- add_shadow_password_attrs\n");
+ return;
+}
diff --git a/ldap/servers/slapd/pw_mgmt.c b/ldap/servers/slapd/pw_mgmt.c
index 8f33751b6..a650b1c6f 100644
--- a/ldap/servers/slapd/pw_mgmt.c
+++ b/ldap/servers/slapd/pw_mgmt.c
@@ -27,11 +27,10 @@ int
need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int pwresponse_req )
{
time_t cur_time, pw_exp_date;
- LDAPMod *mod;
Slapi_Mods smods;
double diff_t = 0;
char *cur_time_str = NULL;
- char *passwordExpirationTime;
+ char *passwordExpirationTime = NULL;
char *timestring;
char *dn;
const Slapi_DN *sdn;
@@ -67,13 +66,12 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int pwresponse_req )
* This is ok for data that has been loaded via ldif2ldbm
* Set expiration time if needed,
* don't do further checking and return 0 */
- if ( pwpolicy->pw_exp == 1) {
- pw_exp_date = time_plus_sec ( cur_time,
- pwpolicy->pw_maxage );
+ if (pwpolicy->pw_exp == 1) {
+ pw_exp_date = time_plus_sec(cur_time, pwpolicy->pw_maxage);
timestring = format_genTime (pw_exp_date);
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpirationTime", timestring);
- slapi_ch_free((void **)×tring);
+ slapi_ch_free_string(×tring);
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpWarned", "0");
pw_apply_mods(sdn, &smods);
@@ -86,7 +84,7 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int pwresponse_req )
pw_exp_date = parse_genTime(passwordExpirationTime);
- slapi_ch_free((void**)&passwordExpirationTime);
+ slapi_ch_free_string(&passwordExpirationTime);
/* Check if password has been reset */
if ( pw_exp_date == NO_TIME ) {
@@ -110,7 +108,7 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int pwresponse_req )
pw_exp_date = NOT_FIRST_TIME;
timestring = format_genTime(pw_exp_date);
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpirationTime", timestring);
- slapi_ch_free((void **)×tring);
+ slapi_ch_free_string(×tring);
}
skip:
@@ -130,11 +128,8 @@ skip:
/* check if password expired. If so, abort bind. */
cur_time_str = format_genTime ( cur_time );
- if ( pw_exp_date != NO_TIME &&
- pw_exp_date != NOT_FIRST_TIME &&
- (diff_t = difftime ( pw_exp_date,
- parse_genTime ( cur_time_str ))) <= 0 ) {
-
+ if ((pw_exp_date != NO_TIME) && (pw_exp_date != NOT_FIRST_TIME) &&
+ (diff_t = difftime(pw_exp_date, parse_genTime(cur_time_str))) <= 0) {
slapi_ch_free_string(&cur_time_str); /* only need this above */
/* password has expired. Check the value of
* passwordGraceUserTime and compare it
@@ -144,7 +139,7 @@ skip:
pwdGraceUserTime++;
sprintf ( graceUserTime, "%d", pwdGraceUserTime );
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE,
- "passwordGraceUserTime", graceUserTime);
+ "passwordGraceUserTime", graceUserTime);
pw_apply_mods(sdn, &smods);
slapi_mods_done(&smods);
if (pwresponse_req) {
@@ -190,40 +185,30 @@ skip:
pw_apply_mods(sdn, &smods);
slapi_mods_done(&smods);
return (-1);
- }
+ }
slapi_ch_free((void **) &cur_time_str );
/* check if password is going to expire within "passwordWarning" */
/* Note that if pw_exp_date is NO_TIME or NOT_FIRST_TIME,
* we must send warning first and this changes the expiration time.
* This is done just below since diff_t is 0
- */
+ */
if ( diff_t <= pwpolicy->pw_warning ) {
int pw_exp_warned = 0;
- pw_exp_warned= slapi_entry_attr_get_int( e, "passwordExpWarned");
+ pw_exp_warned = slapi_entry_attr_get_int( e, "passwordExpWarned");
if ( !pw_exp_warned ){
/* first time send out a warning */
/* reset the expiration time to current + warning time
* and set passwordExpWarned to true
*/
if (pb->pb_conn->c_needpw != 1) {
- pw_exp_date = time_plus_sec ( cur_time,
- pwpolicy->pw_warning );
+ pw_exp_date = time_plus_sec(cur_time, pwpolicy->pw_warning);
}
timestring = format_genTime(pw_exp_date);
- /* At this time passwordExpirationTime may already be
- * in the list of mods: Remove it */
- for (mod = slapi_mods_get_first_mod(&smods); mod != NULL;
- mod = slapi_mods_get_next_mod(&smods))
- {
- if (!strcmp(mod->mod_type, "passwordExpirationTime"))
- slapi_mods_remove(&smods);
- }
-
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpirationTime", timestring);
- slapi_ch_free((void **)×tring);
+ slapi_ch_free_string(×tring);
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpWarned", "1");
@@ -232,7 +217,7 @@ skip:
} else {
*t = (long)diff_t; /* jcm: had to cast double to long */
}
-
+
pw_apply_mods(sdn, &smods);
slapi_mods_done(&smods);
if (pwresponse_req) {
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 823568d59..f78bc4622 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2507,4 +2507,6 @@ extern char *attr_dataversion;
/* copied from replication/repl5.h */
#define RUV_STORAGE_ENTRY_UNIQUEID "ffffffff-ffffffff-ffffffff-ffffffff"
+#define _SEC_PER_DAY 86400
+
#endif /* _slap_h_ */
| 0 |
5d918968b89eb5230bbea4dc76ef36a266898c86
|
389ds/389-ds-base
|
Add comment to 00core.ldif to explain why we changed
the standard definitions of groupOfNames and groupOfUniqueNames
to allow empty groups.
|
commit 5d918968b89eb5230bbea4dc76ef36a266898c86
Author: Rich Megginson <[email protected]>
Date: Wed Sep 30 09:15:18 2009 -0600
Add comment to 00core.ldif to explain why we changed
the standard definitions of groupOfNames and groupOfUniqueNames
to allow empty groups.
diff --git a/ldap/schema/00core.ldif b/ldap/schema/00core.ldif
index b8156d078..18164d4b5 100644
--- a/ldap/schema/00core.ldif
+++ b/ldap/schema/00core.ldif
@@ -8,6 +8,14 @@
#
# The DS specific "aci" attribute is also defined here so we can
# set a default aci # on the schema entry.
+#
+# NOTE: There is one very important deviation from the LDAP standard:
+# there is a bug in the standard definition of groupOfNames and
+# groupOfUniqueNames - the member/uniqueMember attribute is in the MUST
+# list, not the MAY list, which means you cannot have an empty group.
+# Until the LDAP community figures out how to do grouping properly, we
+# have put the member/uniqueMember attribute into the MAY list, to allow
+# empty groups.
################################################################################
#
dn: cn=schema
| 0 |
949e4b126ba6cfacfb3b2d7c4cd91c6115187290
|
389ds/389-ds-base
|
Ticket 1 - Fix missing dn / rdn on config.
Bug Description: During the change on #26 we changed the way
that we assert some vallues from the DB. This has exposed
an issue in the way that we handle RDN on config
Fix Description: Since we always know the RDN and DN of cn=config
we can just provide it.
https://pagure.io/lib389/issue/1
Author: wibrown
Review by: ankity10, ilias95 (verified functionality)
|
commit 949e4b126ba6cfacfb3b2d7c4cd91c6115187290
Author: William Brown <[email protected]>
Date: Tue May 2 15:59:23 2017 +1000
Ticket 1 - Fix missing dn / rdn on config.
Bug Description: During the change on #26 we changed the way
that we assert some vallues from the DB. This has exposed
an issue in the way that we handle RDN on config
Fix Description: Since we always know the RDN and DN of cn=config
we can just provide it.
https://pagure.io/lib389/issue/1
Author: wibrown
Review by: ankity10, ilias95 (verified functionality)
diff --git a/src/lib389/lib389/config.py b/src/lib389/lib389/config.py
index 778c203b9..532ac7313 100644
--- a/src/lib389/lib389/config.py
+++ b/src/lib389/lib389/config.py
@@ -51,6 +51,15 @@ class Config(DSLdapObject):
'nsslapd-certdir'
]
self._compare_exclude = self._compare_exclude + config_compare_exclude
+ self._rdn_attribute = 'cn'
+
+ @property
+ def dn(self):
+ return DN_CONFIG
+
+ @property
+ def rdn(self):
+ return DN_CONFIG
def _alter_log_enabled(self, service, state):
if service not in ('access', 'error', 'audit'):
| 0 |
2444cde84da6bee2b54f3fdb35379fd91e0a95d9
|
389ds/389-ds-base
|
Ticket 15 - Improve instance configuration ability
Bug Description: We should be able to create and configure an instance
from python, rather than template-dse.ldif. This gives us the ability
to *install* and *upgrade* to a specific base version of the DS server.
Fix Description: Implement stubs for our plugins, and prove the operation
works by enabling whoami during a minimal python install.
https://pagure.io/lib389/issue/15
Author: wibrown
Review by: spichugi (Thanks!)
|
commit 2444cde84da6bee2b54f3fdb35379fd91e0a95d9
Author: William Brown <[email protected]>
Date: Thu Mar 30 13:36:52 2017 +1000
Ticket 15 - Improve instance configuration ability
Bug Description: We should be able to create and configure an instance
from python, rather than template-dse.ldif. This gives us the ability
to *install* and *upgrade* to a specific base version of the DS server.
Fix Description: Implement stubs for our plugins, and prove the operation
works by enabling whoami during a minimal python install.
https://pagure.io/lib389/issue/15
Author: wibrown
Review by: spichugi (Thanks!)
diff --git a/src/lib389/lib389/configurations/config_001003006.py b/src/lib389/lib389/configurations/config_001003006.py
index 1765dd174..1089dc76a 100644
--- a/src/lib389/lib389/configurations/config_001003006.py
+++ b/src/lib389/lib389/configurations/config_001003006.py
@@ -15,6 +15,8 @@ from lib389.idm.domain import Domain
from lib389.idm.organisationalunit import OrganisationalUnits
from lib389.idm.group import UniqueGroups, UniqueGroup
+from lib389.plugins import WhoamiPlugin
+
class c001003006_sample_entries(sampleentries):
def __init__(self, instance, basedn):
super(c001003006_sample_entries, self).__init__(instance, basedn)
@@ -92,13 +94,47 @@ class c001003006_sample_entries(sampleentries):
### Operations to be filled in soon!
+class c001003006_whoami_plugin(configoperation):
+ def __init__(self, instance):
+ super(c001003006_whoami_plugin, self).__init__(instance)
+ self.install = True
+ self.upgrade = True
+ self.description = "Enable the Whoami Plugin"
+
+ def _apply(self):
+ # This needs to change from create to "ensure"?
+ whoami_plugin = WhoamiPlugin(self._instance)
+ whoami_plugin.create()
+
class c001003006(baseconfig):
def __init__(self, instance):
super(c001003006, self).__init__(instance)
self._operations = [
+ # Create plugin configs first
+ c001003006_whoami_plugin(self._instance)
# Create our sample entries.
# op001003006_sample_entries(self._instance),
]
+ # We need the following to be created and ENABLED
+ # SyntaxValidationPlugin
+ # SchemaReloadPlugin
+ # StateChangePlugin
+ # RolesPlugin
+ # ACLPlugin
+ # ACLPreoperationPlugin
+ # ClassOfServicePlugin
+ # ViewsPlugin
+ # SevenBitCheckPlugin
+ # AccountUsabilityPlugin
+ # AutoMembershipPlugin
+ # DereferencePlugin
+ # HTTPClientPlugin
+ # LinkedAttributesPlugin
+ # ManagedEntriesPlugin
+ # WhoamiPlugin
+ # LDBMBackendPlugin
+ # ChainingBackendPlugin
+
diff --git a/src/lib389/lib389/index.py b/src/lib389/lib389/index.py
index 6949a80e9..8d4a1810a 100644
--- a/src/lib389/lib389/index.py
+++ b/src/lib389/lib389/index.py
@@ -20,6 +20,8 @@ if MAJOR >= 3 or (MAJOR == 2 and MINOR >= 7):
from ldap.controls.readentry import PostReadControl
+
+
class Index(object):
def __init__(self, conn):
diff --git a/src/lib389/lib389/instance/options.py b/src/lib389/lib389/instance/options.py
index 1acbbe42f..f057fe094 100644
--- a/src/lib389/lib389/instance/options.py
+++ b/src/lib389/lib389/instance/options.py
@@ -134,7 +134,7 @@ class General2Base(Options2):
self._options['defaults'] = INSTALL_LATEST_CONFIG
self._type['defaults'] = str
- self._helptext['defaults'] = "Set the configuration defaults version. If set to %{LATEST}, always use the latest values available for the slapd section. This allows pinning default values in cn=config to specific Directory Server releases. This maps to our versions such as 1.3.5 -> 001003005 -> 1003005".format(LATEST=INSTALL_LATEST_CONFIG)
+ self._helptext['defaults'] = "Set the configuration defaults version. If set to %{LATEST}, always use the latest values available for the slapd section. This allows pinning default values in cn=config to specific Directory Server releases. This maps to our versions such as 1.3.5 -> 001003005. The leading 0's are important.".format(LATEST=INSTALL_LATEST_CONFIG)
self._example_comment['defaults'] = True
#
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
index 50c3cfe71..996c5dff4 100644
--- a/src/lib389/lib389/instance/setup.py
+++ b/src/lib389/lib389/instance/setup.py
@@ -21,6 +21,8 @@ from lib389._constants import *
from lib389.properties import *
from lib389.passwd import password_hash, password_generate
+from lib389.configurations import get_config
+
from lib389.instance.options import General2Base, Slapd2Base
# The poc backend api
@@ -370,7 +372,7 @@ class SetupDs(object):
if self.verbose:
self.log.info("ACTION: Creating dse.ldif")
dse = ""
- with open(os.path.join(slapd['data_dir'], 'dirsrv', 'data', 'template-dse.ldif')) as template_dse:
+ with open(os.path.join(slapd['data_dir'], 'dirsrv', 'data', 'template-dse-minimal.ldif')) as template_dse:
for line in template_dse.readlines():
dse += line.replace('%', '{', 1).replace('%', '}', 1)
@@ -425,6 +427,11 @@ class SetupDs(object):
ds_instance.start(timeout=60)
ds_instance.open()
+ # Create the configs related to this version.
+ base_config = get_config(general['defaults'])
+ base_config_inst = base_config(ds_instance)
+ base_config_inst.apply_config(install=True)
+
# Create the backends as listed
# Load example data if needed.
for backend in backends:
diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py
index f47dcaf4d..0a46d3588 100644
--- a/src/lib389/lib389/plugins.py
+++ b/src/lib389/lib389/plugins.py
@@ -8,7 +8,6 @@
import ldap
import copy
-from lib389 import DirSrv, InvalidArgumentError
from lib389.properties import *
from lib389._constants import *
@@ -126,7 +125,113 @@ class ReferentialIntegrityPlugin(Plugin):
# referint-membership-attr: owner
# referint-membership-attr: seeAlso
+class SyntaxValidationPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Syntax Validation Task,cn=plugins,cn=config", batch=False):
+ super(SyntaxValidationPlugin, self).__init__(instance, dn, batch)
+class SchemaReloadPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Schema Reload,cn=plugins,cn=config", batch=False):
+ super(SchemaReloadPlugin, self).__init__(instance, dn, batch)
+
+class StateChangePlugin(Plugin):
+ def __init__(self, instance, dn="cn=State Change Plugin,cn=plugins,cn=config", batch=False):
+ super(StateChangePlugin, self).__init__(instance, dn, batch)
+
+class ACLPlugin(Plugin):
+ def __init__(self, instance, dn="cn=ACL Plugin,cn=plugins,cn=config", batch=False):
+ super(ACLPlugin, self).__init__(instance, dn, batch)
+
+class ACLPreoperationPlugin(Plugin):
+ def __init__(self, instance, dn="cn=ACL preoperation,cn=plugins,cn=config", batch=False):
+ super(ACLPreoperationPlugin, self).__init__(instance, dn, batch)
+
+class RolesPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Roles Plugin,cn=plugins,cn=config", batch=False):
+ super(RolesPlugin, self).__init__(instance, dn, batch)
+
+class MemberOfPlugin(Plugin):
+ def __init__(self, instance, dn="cn=MemberOf Plugin,cn=plugins,cn=config", batch=False):
+ super(MemberOfPlugin, self).__init__(instance, dn, batch)
+
+class RetroChangelogPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Retro Changelog Plugin,cn=plugins,cn=config", batch=False):
+ super(RetroChangelogPlugin, self).__init__(instance, dn, batch)
+
+class ClassOfServicePlugin(Plugin):
+ def __init__(self, instance, dn="cn=Class of Service,cn=plugins,cn=config", batch=False):
+ super(ClassOfServicePlugin, self).__init__(instance, dn, batch)
+
+class ViewsPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Views,cn=plugins,cn=config", batch=False):
+ super(ViewsPlugin, self).__init__(instance, dn, batch)
+
+class SevenBitCheckPlugin(Plugin):
+ def __init__(self, instance, dn="cn=7-bit check,cn=plugins,cn=config", batch=False):
+ super(SevenBitCheckPlugin, self).__init__(instance, dn, batch)
+
+class AccountUsabilityPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Account Usability Plugin,cn=plugins,cn=config", batch=False):
+ super(AccountUsabilityPlugin, self).__init__(instance, dn, batch)
+
+class AutoMembershipPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Auto Membership Plugin,cn=plugins,cn=config", batch=False):
+ super(AutoMembershipPlugin, self).__init__(instance, dn, batch)
+
+class ContentSynchronizationPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Content Synchronization,cn=plugins,cn=config", batch=False):
+ super(ContentSynchronizationPlugin, self).__init__(instance, dn, batch)
+
+class DereferencePlugin(Plugin):
+ def __init__(self, instance, dn="cn=deref,cn=plugins,cn=config", batch=False):
+ super(DereferencePlugin, self).__init__(instance, dn, batch)
+
+class HTTPClientPlugin(Plugin):
+ def __init__(self, instance, dn="cn=HTTP Client,cn=plugins,cn=config", batch=False):
+ super(HTTPClientPlugin, self).__init__(instance, dn, batch)
+
+class LinkedAttributesPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Linked Attributes,cn=plugins,cn=config", batch=False):
+ super(LinkedAttributesPlugin, self).__init__(instance, dn, batch)
+
+class PassThroughAuthenticationPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Pass Through Authentication,cn=plugins,cn=config", batch=False):
+ super(PassThroughAuthenticationPlugin, self).__init__(instance, dn, batch)
+
+class USNPlugin(Plugin):
+ def __init__(self, instance, dn="cn=USN,cn=plugins,cn=config", batch=False):
+ super(USNPlugin, self).__init__(instance, dn, batch)
+
+class WhoamiPlugin(Plugin):
+ _plugin_properties = {
+ 'cn' : 'whoami',
+ 'nsslapd-pluginEnabled' : 'on',
+ 'nsslapd-pluginPath' : 'libwhoami-plugin',
+ 'nsslapd-pluginInitfunc' : 'whoami_init',
+ 'nsslapd-pluginType' : 'extendedop',
+ 'nsslapd-pluginId' : 'ldapwhoami-plugin',
+ 'nsslapd-pluginVendor' : '389 Project',
+ 'nsslapd-pluginVersion' : '1.3.6',
+ 'nsslapd-pluginDescription' : 'Provides whoami extended operation',
+ }
+
+ def __init__(self, instance, dn="cn=whoami,cn=plugins,cn=config", batch=False):
+ super(WhoamiPlugin, self).__init__(instance, dn, batch)
+
+class RootDNAccessControlPlugin(Plugin):
+ def __init__(self, instance, dn="cn=RootDN Access Control,cn=plugins,cn=config", batch=False):
+ super(RootDNAccessControlPlugin, self).__init__(instance, dn, batch)
+
+class LDBMBackendPlugin(Plugin):
+ def __init__(self, instance, dn="cn=ldbm database,cn=plugins,cn=config", batch=False):
+ super(LDBMBackendPlugin, self).__init__(instance, dn, batch)
+
+class ChainingBackendPlugin(Plugin):
+ def __init__(self, instance, dn="cn=chaining database,cn=plugins,cn=config", batch=False):
+ super(ChainingBackendPlugin, self).__init__(instance, dn, batch)
+
+class AccountPolicyPlugin(Plugin):
+ def __init__(self, instance, dn="cn=Account Policy Plugin,cn=plugins,cn=config", batch=False):
+ super(AccountPolicyPlugin, self).__init__(instance, dn, batch)
class Plugins(DSLdapObjects):
@@ -189,6 +294,7 @@ class PluginsLegacy(object):
def __getattr__(self, name):
if name in Plugins.proxied_methods:
+ from lib389 import DirSrv
return DirSrv.__getattr__(self.conn, name)
def list(self, name=None):
@@ -239,6 +345,7 @@ class PluginsLegacy(object):
filt = "(objectclass=%s)" % PLUGINS_OBJECTCLASS_VALUE
if not dn:
+ from lib389 import InvalidArgumentError
raise InvalidArgumentError("'name' and 'plugin_dn' are missing")
ents = self.conn.search_s(dn, ldap.SCOPE_BASE, filt)
@@ -269,6 +376,7 @@ class PluginsLegacy(object):
filt = "(objectclass=%s)" % PLUGINS_OBJECTCLASS_VALUE
if not dn:
+ from lib389 import InvalidArgumentError
raise InvalidArgumentError("'name' and 'plugin_dn' are missing")
ents = self.conn.search_s(dn, ldap.SCOPE_BASE, filt)
| 0 |
c0688a064ceca5f50ab70c0a3a5a2285dcd47b70
|
389ds/389-ds-base
|
Issue 50791 - Healthcheck to find notes=F
Description:
Created tests, that reproduce notes=A and notes=F in access log
and then check if healthcheck returned proper error code.
Relates: https://pagure.io/389-ds-base/issue/50791
Reviewed by: spichugi (Thanks!)
|
commit c0688a064ceca5f50ab70c0a3a5a2285dcd47b70
Author: Barbora Smejkalova <[email protected]>
Date: Fri Jul 10 16:27:10 2020 +0200
Issue 50791 - Healthcheck to find notes=F
Description:
Created tests, that reproduce notes=A and notes=F in access log
and then check if healthcheck returned proper error code.
Relates: https://pagure.io/389-ds-base/issue/50791
Reviewed by: spichugi (Thanks!)
diff --git a/dirsrvtests/tests/suites/healthcheck/health_config_test.py b/dirsrvtests/tests/suites/healthcheck/health_config_test.py
index 8b8878b20..ff413c8a9 100644
--- a/dirsrvtests/tests/suites/healthcheck/health_config_test.py
+++ b/dirsrvtests/tests/suites/healthcheck/health_config_test.py
@@ -13,6 +13,8 @@ import subprocess
from lib389.backend import Backends
from lib389.cos import CosTemplates, CosPointerDefinitions
+from lib389.dbgen import dbgen_users
+from lib389.idm.account import Accounts
from lib389.index import Index
from lib389.plugins import ReferentialIntegrityPlugin
from lib389.utils import *
@@ -71,6 +73,21 @@ def run_healthcheck_and_flush_log(topology, instance, searched_code, json, searc
topology.logcap.flush()
[email protected](scope="function")
+def setup_ldif(topology_st, request):
+ log.info("Generating LDIF...")
+ ldif_dir = topology_st.standalone.get_ldif_dir()
+ global import_ldif
+ import_ldif = ldif_dir + '/basic_import.ldif'
+ dbgen_users(topology_st.standalone, 5000, import_ldif, DEFAULT_SUFFIX)
+
+ def fin():
+ log.info('Delete file')
+ os.remove(import_ldif)
+
+ request.addfinalizer(fin)
+
+
@pytest.mark.ds50873
@pytest.mark.bz1685160
@pytest.mark.xfail(ds_is_older("1.4.1"), reason="Not implemented")
@@ -320,6 +337,104 @@ def test_healthcheck_low_disk_space(topology_st):
os.remove(file)
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3.8"), reason="Not implemented")
+def test_healthcheck_notes_unindexed_search(topology_st, setup_ldif):
+ """Check if HealthCheck returns DSLOGNOTES0001 code
+
+ :id: b25f7027-d43f-4ec2-ac49-9c9bb285df1d
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Set nsslapd-accesslog-logbuffering to off
+ 3. Import users from created ldif file
+ 4. Use HealthCheck without --json option
+ 5. Use HealthCheck with --json option
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Healthcheck reports DSLOGNOTES0001
+ 5. Healthcheck reports DSLOGNOTES0001
+ """
+
+ RET_CODE = 'DSLOGNOTES0001'
+
+ standalone = topology_st.standalone
+
+ log.info('Delete the previous access logs')
+ topology_st.standalone.deleteAccessLogs()
+
+ log.info('Set nsslapd-accesslog-logbuffering to off')
+ standalone.config.set("nsslapd-accesslog-logbuffering", "off")
+
+ log.info('Stopping the server and running offline import...')
+ standalone.stop()
+ assert standalone.ldif2db(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], encrypt=None, excludeSuffixes=None,
+ import_file=import_ldif)
+ standalone.start()
+
+ log.info('Use filters to reproduce "notes=A" in access log')
+ accounts = Accounts(standalone, DEFAULT_SUFFIX)
+ accounts.filter('(uid=test*)')
+
+ log.info('Check that access log contains "notes=A"')
+ assert standalone.ds_access_log.match(r'.*notes=A.*')
+
+ run_healthcheck_and_flush_log(topology_st, standalone, RET_CODE, json=False)
+ run_healthcheck_and_flush_log(topology_st, standalone, RET_CODE, json=True)
+
+
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3.8"), reason="Not implemented")
+def test_healthcheck_notes_unknown_attribute(topology_st, setup_ldif):
+ """Check if HealthCheck returns DSLOGNOTES0002 code
+
+ :id: 71ccd1d7-3c71-416b-9d2a-27f9f6633101
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Set nsslapd-accesslog-logbuffering to off
+ 3. Import users from created ldif file
+ 4. Use HealthCheck without --json option
+ 5. Use HealthCheck with --json option
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Healthcheck reports DSLOGNOTES0002
+ 5. Healthcheck reports DSLOGNOTES0002
+ """
+
+ RET_CODE = 'DSLOGNOTES0002'
+
+ standalone = topology_st.standalone
+
+ log.info('Delete the previous access logs')
+ topology_st.standalone.deleteAccessLogs()
+
+ log.info('Set nsslapd-accesslog-logbuffering to off')
+ standalone.config.set("nsslapd-accesslog-logbuffering", "off")
+
+ log.info('Stopping the server and running offline import...')
+ standalone.stop()
+ assert standalone.ldif2db(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], encrypt=None, excludeSuffixes=None,
+ import_file=import_ldif)
+ standalone.start()
+
+ log.info('Use filters to reproduce "notes=F" in access log')
+ accounts = Accounts(standalone, DEFAULT_SUFFIX)
+ accounts.filter('(unknown=test)')
+
+ log.info('Check that access log contains "notes=F"')
+ assert standalone.ds_access_log.match(r'.*notes=F.*')
+
+ run_healthcheck_and_flush_log(topology_st, standalone, RET_CODE, json=False)
+ run_healthcheck_and_flush_log(topology_st, standalone, RET_CODE, json=True)
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
| 0 |
fcd6b2e1c5f24ff931ab85448ffa6dffc6ee831f
|
389ds/389-ds-base
|
Issue 50873 - Fix issues with healthcheck tool
Description:
- Wrong error code reported with result for backend check
- Disk Space Monitor check crashes because it is missing "import copy"
- On a non-LDAPI instance "dsctl healthcheck" does not prompt for bind dn, only for password.
relates: https://pagure.io/389-ds-base/issue/50873
Reviewed by: firstyear(Thanks!)
|
commit fcd6b2e1c5f24ff931ab85448ffa6dffc6ee831f
Author: Mark Reynolds <[email protected]>
Date: Fri Jan 31 16:36:28 2020 -0500
Issue 50873 - Fix issues with healthcheck tool
Description:
- Wrong error code reported with result for backend check
- Disk Space Monitor check crashes because it is missing "import copy"
- On a non-LDAPI instance "dsctl healthcheck" does not prompt for bind dn, only for password.
relates: https://pagure.io/389-ds-base/issue/50873
Reviewed by: firstyear(Thanks!)
diff --git a/src/lib389/lib389/cli_base/__init__.py b/src/lib389/lib389/cli_base/__init__.py
index e2e6c902a..7dd45b373 100644
--- a/src/lib389/lib389/cli_base/__init__.py
+++ b/src/lib389/lib389/cli_base/__init__.py
@@ -129,14 +129,18 @@ def connect_instance(dsrc_inst, verbose, args):
# No password or we chose to prompt
dsargs[SER_ROOT_PW] = getpass("Enter password for {} on {}: ".format(dsrc_inst['binddn'], dsrc_inst['uri']))
elif not ds.can_autobind():
- # No LDAPI, prompt for password
+ # No LDAPI, prompt for password, and bind DN if necessary
+ if dsrc_inst['binddn'] is None:
+ dn = ""
+ while dn == "":
+ dn = input("Enter Bind DN: ")
+ dsrc_inst['binddn'] = dn
dsargs[SER_ROOT_PW] = getpass("Enter password for {} on {}: ".format(dsrc_inst['binddn'], dsrc_inst['uri']))
- if 'binddn' in dsrc_inst:
- # Allocate is an awful interface that we should stop using, but for now
- # just directly map the dsrc_inst args in (remember, dsrc_inst DOES
- # overlay cli args into the map ...)
- dsargs[SER_ROOT_DN] = dsrc_inst['binddn']
+ # Allocate is an awful interface that we should stop using, but for now
+ # just directly map the dsrc_inst args in (remember, dsrc_inst DOES
+ # overlay cli args into the map ...)
+ dsargs[SER_ROOT_DN] = dsrc_inst['binddn']
ds = DirSrv(verbose=verbose)
ds.allocate(dsargs)
diff --git a/src/lib389/lib389/lint.py b/src/lib389/lib389/lint.py
index b2bd8cd41..c6f2df381 100644
--- a/src/lib389/lib389/lint.py
+++ b/src/lib389/lib389/lint.py
@@ -47,7 +47,7 @@ DSBLE0002 = {
}
DSBLE0003 = {
- 'dsle': 'DSBLE0002',
+ 'dsle': 'DSBLE0003',
'severity': 'LOW',
'items' : [],
'detail' : """The backend database has not been initialized yet""",
diff --git a/src/lib389/lib389/monitor.py b/src/lib389/lib389/monitor.py
index 283c9fbe8..cfaacff48 100644
--- a/src/lib389/lib389/monitor.py
+++ b/src/lib389/lib389/monitor.py
@@ -6,6 +6,7 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
+import copy
from lib389._constants import *
from lib389._mapped_object import DSLdapObject
from lib389.utils import (ds_is_older)
| 0 |
4dc992d611a1544700cb798ee4385ec6e296830b
|
389ds/389-ds-base
|
Reviewed by Nathan (Thanks!)
Fix: Put the dsml gateway and command line jar files in a package called
extjava.tar.gz so that users can choose to deploy these separately if they
want dsml functionality.
|
commit 4dc992d611a1544700cb798ee4385ec6e296830b
Author: Rich Megginson <[email protected]>
Date: Fri Nov 11 14:34:01 2005 +0000
Reviewed by Nathan (Thanks!)
Fix: Put the dsml gateway and command line jar files in a package called
extjava.tar.gz so that users can choose to deploy these separately if they
want dsml functionality.
diff --git a/ldap/cm/Makefile b/ldap/cm/Makefile
index a2c432661..3e38736f0 100644
--- a/ldap/cm/Makefile
+++ b/ldap/cm/Makefile
@@ -234,6 +234,11 @@ LDAPDIR = $(BUILD_ROOT)/ldap
NSDIST = $(BUILD_ROOT)/../dist
DS_JAR_SRC_PATH = $(NSDIST)/$(BUILD_DEBUG)
+# this is the directory into which we place those java files and associated
+# web services files that are Apache or Java licensed - we cannot put them
+# in the same rpm/tarball as the directory server, so we create a separate
+# package for them, using the below macro as the staging area
+EXT_JAVA_RELDIR = $(BUILD_ROOT)/built/release/extjava
DS_JAR_DEST_PATH = java/jars
XMLTOOLS_JAR_FILE = xmltools.jar
@@ -336,29 +341,33 @@ endif
done
# install the DSMLGW into the client directory
+# the following DSML files must be packaged separately:
+# web-app_2_3.dtd, activation.jar, saaj.jar - due to Sun license
+# jaxrpc-api.jar, jaxrpc.jar, xercesImpl.jar, xml-apis.jar, crimson.jar - due to Apache license
ifeq ($(USE_DSMLGW), 1)
$(MKDIR) $(RELDIR)/clients/dsmlgw
+ $(MKDIR) $(EXT_JAVA_RELDIR)/clients/dsmlgw
if [ -d $(DSMLGWJARS_BUILD_DIR)/$(AXIS_REL_DIR)/webapps/axis ] ; then \
- $(CP) -R $(DSMLGWJARS_BUILD_DIR)/$(AXIS_REL_DIR)/webapps/axis/* $(RELDIR)/clients/dsmlgw/ ; \
+ $(CP) -R $(DSMLGWJARS_BUILD_DIR)/$(AXIS_REL_DIR)/webapps/axis/* $(EXT_JAVA_RELDIR)/clients/dsmlgw/ ; \
fi
$(INSTALL) -m 644 $(NSDIST)/dsmlgw/dsmlgw.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/dsmlgw/misc/server-config.wsdd $(RELDIR)/clients/dsmlgw/WEB-INF
- $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/dsmlgw/misc/web-app_2_3.dtd $(RELDIR)/clients/dsmlgw/
+ $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/dsmlgw/misc/web-app_2_3.dtd $(EXT_JAVA_RELDIR)/clients/dsmlgw/
# now time to move the necessary jars in place
$(INSTALL) -m 644 $(LDAPJARFILE) $(RELDIR)/clients/dsmlgw/WEB-INF/lib
- $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/activation.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
+ $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/activation.jar $(EXT_JAVA_RELDIR)/clients/dsmlgw/WEB-INF/lib
# if you use the jaxrpc.jar from the axis distribution, you don't need the api file
# or perhaps you need the jaxrpc.jar for building, and jaxrpc-api.jar at runtime, or vice versa
# if so, I'm not sure where to get the implementation
if [ -f $(DSMLGWJARS_BUILD_DIR)/jaxrpc-api.jar ] ; then \
- $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/jaxrpc-api.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib ; \
+ $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/jaxrpc-api.jar $(EXT_JAVA_RELDIR)/clients/dsmlgw/WEB-INF/lib ; \
fi
- $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/jaxrpc.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
- $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/saaj.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
- $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/xercesImpl.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
- $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/xml-apis.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
+ $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/jaxrpc.jar $(EXT_JAVA_RELDIR)/clients/dsmlgw/WEB-INF/lib
+ $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/saaj.jar $(EXT_JAVA_RELDIR)/clients/dsmlgw/WEB-INF/lib
+ $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/xercesImpl.jar $(EXT_JAVA_RELDIR)/clients/dsmlgw/WEB-INF/lib
+ $(INSTALL) -m 644 $(DSMLGWJARS_BUILD_DIR)/xml-apis.jar $(EXT_JAVA_RELDIR)/clients/dsmlgw/WEB-INF/lib
endif # USE_DSMLGW
# PACKAGE_UNDER_JAVA is defined in components.mk - these are component .jar files to install
@@ -479,9 +488,9 @@ ifeq ($(USE_CONSOLE), 1)
endif
ifeq ($(USE_JAVATOOLS), 1)
$(INSTALL) -m 644 $(DS_JAR_SRC_PATH)/$(XMLTOOLS_JAR_FILE) $(RELDIR)/$(DS_JAR_DEST_PATH)
- $(INSTALL) -m 644 $(CRIMSONJAR_FILE) $(RELDIR)/$(DS_JAR_DEST_PATH)
+ $(INSTALL) -m 644 $(CRIMSONJAR_FILE) $(EXT_JAVA_RELDIR)/$(DS_JAR_DEST_PATH)
if [ -f $(CRIMSON_BUILD_DIR)/$(CRIMSON_LICENSE) ] ; then \
- $(INSTALL) -m 644 $(CRIMSON_BUILD_DIR)/$(CRIMSON_LICENSE) $(RELDIR)/$(DS_JAR_DEST_PATH) ; \
+ $(INSTALL) -m 644 $(CRIMSON_BUILD_DIR)/$(CRIMSON_LICENSE) $(EXT_JAVA_RELDIR)/$(DS_JAR_DEST_PATH) ; \
fi
endif
@@ -619,6 +628,10 @@ ifdef BUILD_RPM
endif
endif
+ifeq ($(USE_DSMLGW), 1)
+ cd $(EXT_JAVA_RELDIR) ; tar cf - * | gzip > $(ABS_INSTDIR)/extjava.tar.gz
+endif
+
ifeq ($(USE_CONSOLE),1)
# create the slapd-client.zip file, which only has the ds jar file for the console and
# the ldap client utility programs
| 0 |
b83fddfa6cdb73fb97a37c676b4a2a7341f8d8f9
|
389ds/389-ds-base
|
Add broooker function to set access log buffering on or off
|
commit b83fddfa6cdb73fb97a37c676b4a2a7341f8d8f9
Author: Mark Reynolds <[email protected]>
Date: Thu Aug 6 08:37:01 2015 -0400
Add broooker function to set access log buffering on or off
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 059186ddc..c5a23598a 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -1989,6 +1989,10 @@ class DirSrv(SimpleLDAPObject):
"""Set nsslapd-accesslog-level and return its value."""
return self.config.loglevel(vals, service='access')
+ def setAccessLogBuffering(self, state):
+ """Set nsslapd-accesslog-logbuffering - state is True or False"""
+ return self.config.logbuffering(state)
+
def configSSL(self, secport=636, secargs=None):
"""Configure SSL support into cn=encryption,cn=config.
diff --git a/src/lib389/lib389/brooker.py b/src/lib389/lib389/brooker.py
index f7a5fc848..03c62d18e 100644
--- a/src/lib389/lib389/brooker.py
+++ b/src/lib389/lib389/brooker.py
@@ -37,18 +37,18 @@ class Config(object):
"""@param conn - a DirSrv instance """
self.conn = conn
self.log = conn.log
-
+
def set(self, key, value):
"""Set a parameter under cn=config
@param key - the attribute name
@param value - attribute value as string
-
+
eg. set('passwordExp', 'on')
"""
self.log.debug("set(%r, %r)" % (key, value))
return self.conn.modify_s(DN_CONFIG,
[(ldap.MOD_REPLACE, key, value)])
-
+
def get(self, key):
"""Get an attribute under cn=config"""
return self.conn.getEntry(DN_CONFIG).__getattr__(key)
@@ -78,7 +78,7 @@ class Config(object):
def loglevel(self, vals=(LOG_DEFAULT,), service='error', update=False):
"""Set the access or error log level.
- @param vals - a list of log level codes (eg. lib389.LOG_*)
+ @param vals - a list of log level codes (eg. lib389.LOG_*)
defaults to LOG_DEFAULT
@param service - 'access' or 'error'. There is no 'audit' log level. use enable_log or disable_log.
@param update - False for replace (default), True for update
@@ -103,6 +103,14 @@ class Config(object):
self.set(service, str(tot))
return tot
+ def logbuffering(self, state=True):
+ if state:
+ value = 'on'
+ else:
+ value = 'off'
+
+ self.set('nsslapd-accesslog-logbuffering', value)
+
def enable_ssl(self, secport=636, secargs=None):
"""Configure SSL support into cn=encryption,cn=config.
| 0 |
089d549353eb41096c580d998e0a113483d9df23
|
389ds/389-ds-base
|
Ticket 48028 - lib389 - add valgrind functions
Description: Added valgrind functions (enable, test, disable). When
we "enable" we copy in a valgrind ns-slapd wrapper,
and backup the original ns-slapd.
The "test" function just searches the output file for a
string or regex.
The "disable" function restores the original ns-slapd
https://fedorahosted.org/389/ticket/48028
Reviewed by: nhosoi(Thanks!)
|
commit 089d549353eb41096c580d998e0a113483d9df23
Author: Mark Reynolds <[email protected]>
Date: Wed Feb 11 09:13:48 2015 -0500
Ticket 48028 - lib389 - add valgrind functions
Description: Added valgrind functions (enable, test, disable). When
we "enable" we copy in a valgrind ns-slapd wrapper,
and backup the original ns-slapd.
The "test" function just searches the output file for a
string or regex.
The "disable" function restores the original ns-slapd
https://fedorahosted.org/389/ticket/48028
Reviewed by: nhosoi(Thanks!)
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 1eb3040fc..645e5dc47 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -182,6 +182,7 @@ class DirSrv(SimpleLDAPObject):
"""Initialize the DirSrv structure filling various fields, like:
self.errlog -> nsslapd-errorlog
self.accesslog -> nsslapd-accesslog
+ self.auditlog -> nsslapd-auditlog
self.confdir -> nsslapd-certdir
self.inst -> equivalent to self.serverid
self.sroot/self.inst -> nsslapd-instancedir
@@ -202,10 +203,12 @@ class DirSrv(SimpleLDAPObject):
'nsslapd-instancedir',
'nsslapd-errorlog',
'nsslapd-accesslog',
+ 'nsslapd-auditlog',
'nsslapd-certdir',
'nsslapd-schemadir'])
self.errlog = ent.getValue('nsslapd-errorlog')
self.accesslog = ent.getValue('nsslapd-accesslog')
+ self.auditlog = ent.getValue('nsslapd-auditlog')
self.confdir = ent.getValue('nsslapd-certdir')
self.schemadir = ent.getValue('nsslapd-schemadir')
@@ -1002,6 +1005,8 @@ class DirSrv(SimpleLDAPObject):
ldir.append(os.path.dirname(self.errlog))
if hasattr(self, 'accesslog') and os.path.dirname(self.accesslog) not in ldir:
ldir.append(os.path.dirname(self.accesslog))
+ if hasattr(self, 'auditlog') and os.path.dirname(self.auditlog) not in ldir:
+ ldir.append(os.path.dirname(self.auditlog))
# now scan the directory list to find the files to backup
for dirToBackup in ldir:
@@ -1081,6 +1086,10 @@ class DirSrv(SimpleLDAPObject):
for f in glob.glob("%s*" % self.accesslog):
log.debug("restoreFS: before restore remove file %s" % (f))
os.remove(f)
+ log.debug("restoreFS: remove audit logs %s" % self.accesslog)
+ for f in glob.glob("%s*" % self.auditlog):
+ log.debug("restoreFS: before restore remove file %s" % (f))
+ os.remove(f)
# Then restore from the directory where DS was deployed
here = os.getcwd()
diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py
index 8769713ec..5ba7fe755 100644
--- a/src/lib389/lib389/_constants.py
+++ b/src/lib389/lib389/_constants.py
@@ -158,6 +158,7 @@ DEFAULT_USER = "nobody"
DEFAULT_USERHOME = "/tmp/lib389_home"
DATA_DIR = "data"
TMP_DIR = "tmp"
+VALGRIND_WRAPPER = "ns-slapd.valgrind"
#
# LOG: see https://access.redhat.com/site/documentation/en-US/Red_Hat_Directory_Server/9.0/html/Administration_Guide/Configuring_Logs.html
diff --git a/src/lib389/lib389/tasks.py b/src/lib389/lib389/tasks.py
index f8a7c8414..a1ed3685e 100644
--- a/src/lib389/lib389/tasks.py
+++ b/src/lib389/lib389/tasks.py
@@ -186,8 +186,6 @@ class Tasks(object):
# Checking the parameters
if not backup_dir:
raise ValueError("You must specify a backup directory.")
- if not os.path.exists(backup_dir):
- raise ValueError("Backup file (%s) does not exist" % backup_dir)
# build the task entry
cn = "backup_" + time.strftime("%m%d%Y_%H%M%S", time.localtime())
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index 2983776b9..2c49d0a11 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -21,6 +21,8 @@ import re
import os
import socket
import logging
+import shutil
+import time
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
@@ -52,7 +54,7 @@ def static_var(varname, value):
#
searches = {
'NAMINGCONTEXTS': ('', ldap.SCOPE_BASE, '(objectclass=*)', ['namingcontexts']),
- 'ZOMBIE' : ('', ldap.SCOPE_SUBTREE, '(&(objectclass=glue)(objectclass=extensibleobject))', ['dn'])
+ 'ZOMBIE' : ('', ldap.SCOPE_SUBTREE, '(&(objectclass=glue)(objectclass=extensibleobject))', ['dn'])
}
#
@@ -101,23 +103,179 @@ def suffixfilt(suffix):
nsuffix = normalizeDN(suffix)
spacesuffix = normalizeDN(nsuffix, True)
escapesuffix = escapeDNFiltValue(nsuffix)
- filt = '(|(cn=%s)(cn=%s)(cn=%s)(cn="%s")(cn="%s")(cn=%s)(cn="%s"))' % (escapesuffix, nsuffix, spacesuffix, nsuffix, spacesuffix, suffix, suffix)
+ filt = ('(|(cn=%s)(cn=%s)(cn=%s)(cn="%s")(cn="%s")(cn=%s)(cn="%s"))' %
+ (escapesuffix, nsuffix, spacesuffix, nsuffix, spacesuffix, suffix, suffix))
return filt
+
#
# path tools
#
-
-
def get_sbin_dir(sroot=None, prefix=None):
"""Return the sbin directory (default /usr/sbin)."""
if sroot:
return "%s/bin/slapd/admin/bin" % sroot
- elif prefix:
+ elif prefix and prefix != '/':
return "%s/sbin" % prefix
return "/usr/sbin"
+def get_data_dir(prefix=None):
+ """Return the shared data directory (default /usr/share/dirsrv/data)."""
+ if prefix and prefix != '/':
+ return "%s/share/dirsrv/data" % prefix
+ return "/usr/share/dirsrv/data"
+
+
+def get_plugin_dir(prefix=None):
+ """
+ Return the plugin directory (default /usr/lib64/dirsrv/plugins).
+ This should be 64/32bit aware.
+ """
+ if prefix and prefix != '/':
+ # With prefix installations, even 64 bit, it can be under /usr/lib/
+ if os.path.exists("%s/usr/lib/dirsrv/plugins" % prefix):
+ return "%s/usr/lib/dirsrv/plugins" % prefix
+ else:
+ if os.path.exists("%s/usr/lib64/dirsrv/plugins" % prefix):
+ return "%s/usr/lib64/dirsrv/plugins" % prefix
+
+ # Need to check for 32/64 bit installations
+ if not os.path.exists("/usr/lib64/dirsrv/plugins"):
+ if os.path.exists("/usr/lib/dirsrv/plugins"):
+ return "/usr/lib/dirsrv/plugins"
+ return "/usr/lib64/dirsrv/plugins"
+
+
+#
+# valgrind functions
+#
+def valgrind_enable(sbin_dir, wrapper=None):
+ '''
+ Copy the valgrind ns-slapd wrapper into the /sbin directory
+ (making a backup of the original ns-slapd binary). The server instance(s)
+ should be stopped prior to calling this function.
+
+ Then after calling valgrind_enable():
+ - Start the server instance(s) with a timeout of 60 (valgrind takes a while to startup)
+ - Run the tests
+ - Run valgrind_check_leak(instance, "leak test") - this also stops the instance
+ - Run valgrind_disable()
+
+ @param sbin_dir - the location of the ns-slapd binary (e.g. /usr/sbin)
+ @param wrapper - The valgrind wrapper script for ns-slapd (if not set, a default wrapper is used)
+ @raise IOError
+ '''
+
+ if not wrapper:
+ # use the default ns-slapd wrapper
+ wrapper = '%s/%s' % (os.path.dirname(os.path.abspath(__file__)), VALGRIND_WRAPPER)
+
+ nsslapd_orig = '%s/ns-slapd' % sbin_dir
+ nsslapd_backup = '%s/ns-slapd.original' % sbin_dir
+
+ if os.path.isfile(nsslapd_backup):
+ # There is a backup which means we never cleaned up from a previous run(failed test?)
+ # We do not want to copy ns-slapd to ns-slapd.original because ns-slapd is currently
+ # the wrapper. Basically everything is already enabled and ready to go.
+ log.info('Valgrind is already enabled.')
+ return
+
+ # Check both nsslapd's exist
+ if not os.path.isfile(wrapper):
+ raise IOError('The valgrind wrapper (%s) does not exist or is not accessible. file=%s' % (wrapper, __file__))
+
+ if not os.path.isfile(nsslapd_orig):
+ raise IOError('The binary (%s) does not exist or is not accessible.' % nsslapd_orig)
+
+ # Make a backup of the original ns-slapd and copy the wrapper into place
+ try:
+ shutil.copy2(nsslapd_orig, nsslapd_backup)
+ except IOError as e:
+ log.fatal('valgrind_enable(): failed to backup ns-slapd, error: %s' % e.strerror)
+ raise IOError('failed to backup ns-slapd, error: ' % e.strerror)
+
+ # Copy the valgrind wrapper into place
+ try:
+ shutil.copy2(wrapper, nsslapd_orig)
+ except IOError as e:
+ log.fatal('valgrind_enable(): failed to copy valgrind wrapper to ns-slapd, error: %s' % e.strerror)
+ raise IOError('failed to copy valgrind wrapper to ns-slapd, error: ' % e.strerror)
+
+ log.info('Valgrind is now enabled.')
+
+
+def valgrind_disable(sbin_dir):
+ '''
+ Restore the ns-slapd binary to its original state - the server instances are
+ expected to be stopped.
+ @param sbin_dir - the location of the ns-slapd binary (e.g. /usr/sbin)
+ @raise ValueError
+ '''
+
+ nsslapd_orig = '%s/ns-slapd' % sbin_dir
+ nsslapd_backup = '%s/ns-slapd.original' % sbin_dir
+
+ # Restore the original ns-slapd
+ try:
+ shutil.copyfile(nsslapd_backup, nsslapd_orig)
+ except IOError as e:
+ log.fatal('valgrind_disable: failed to restore ns-slapd, error: %s' % e.strerror)
+ raise ValueError('failed to restore ns-slapd, error: ' % e.strerror)
+
+ # Delete the backup now
+ try:
+ os.remove(nsslapd_backup)
+ except OSError as e:
+ log.fatal('valgrind_disable: failed to delete backup ns-slapd, error: %s' % e.strerror)
+ raise ValueError('Failed to delete backup ns-slapd, error: ' % e.strerror)
+
+ log.info('Valgrind is now disabled.')
+
+
+def valgrind_check_leak(dirsrv_inst, pattern):
+ '''
+ Check the valgrind results file for the "leak_str"
+ @param dirsrv_inst - DirSrv object for the instance we want the result file from
+ @param pattern - A plain text or regex pattern string that should be searched for
+ @return True/False - Return true of "leak_str" is in the valgrind output file
+ @raise IOError
+ '''
+
+ cmd = ("ps -ef | grep valgrind | grep 'slapd-" + dirsrv_inst.serverid +
+ " ' | awk '{ print $14 }' | sed -e 's/\-\-log\-file=//'")
+
+ '''
+ The "ps -ef | grep valgrind" looks like:
+
+ nobody 26239 1 10 14:33 ? 00:00:06 valgrind -q --tool=memcheck --leak-check=yes
+ --leak-resolution=high --num-callers=50 --log-file=/var/tmp/slapd.vg.26179
+ /usr/sbin/ns-slapd.orig -D /etc/dirsrv/slapd-localhost
+ -i /var/run/dirsrv/slapd-localhost.pid -w /var/run/dirsrv/slapd-localhost.startpid
+ '''
+
+ # Run the command and grab the output
+ p = os.popen(cmd)
+ result_file = p.readline()
+ p.close()
+
+ # We need to stop the server next
+ dirsrv_inst.stop(timeout=30)
+ time.sleep(1)
+
+ # Check the result file fo the leak text
+ result_file = result_file.replace('\n', '')
+ found = False
+ vlog = open(result_file)
+ for line in vlog:
+ if re.search(pattern, line):
+ found = True
+ break
+ vlog.close()
+
+ return found
+
+
#
# functions using sockets
#
@@ -209,13 +367,13 @@ def getcfgdsuserdn(cfgdn, args):
"""Return a DirSrv object bound anonymously or to the admin user.
If the config ds user ID was given, not the full DN, we need to figure
- out the full DN.
-
+ out the full DN.
+
Try in order to:
1- search the directory anonymously;
2- look in ldap.conf;
3- try the default DN.
-
+
This may raise a file or LDAP exception.
"""
# create a connection to the cfg ds
@@ -292,7 +450,7 @@ def getnewcfgdsinfo(new_instance_arguments):
except AttributeError:
log.error("missing ldapurl attribute in new_instance_arguments: %r" % new_instance_arguments)
raise
-
+
ary = url.hostport.split(":")
if len(ary) < 2:
ary.append(389)
@@ -382,45 +540,45 @@ def formatInfData(args):
args = {
# new instance values
newhost, newuserid, newport, SER_ROOT_DN, newrootpw, newsuffix,
-
+
# The following parameters require to register the new instance
# in the admin server
- have_admin, cfgdshost, cfgdsport, cfgdsuser,cfgdspwd, admin_domain
-
+ have_admin, cfgdshost, cfgdsport, cfgdsuser,cfgdspwd, admin_domain
+
InstallLdifFile, AddOrgEntries, ConfigFile, SchemaFile, ldapifilepath
-
+
# Setup the o=NetscapeRoot namingContext
setup_admin,
}
-
+
@see https://access.redhat.com/site/documentation/en-US/Red_Hat_Directory_Server/8.2/html/Installation_Guide/Installation_Guide-Advanced_Configuration-Silent.html
- [General]
- FullMachineName= dir.example.com
- SuiteSpotUserID= nobody
- SuiteSpotGroup= nobody
- AdminDomain= example.com
- ConfigDirectoryAdminID= admin
- ConfigDirectoryAdminPwd= admin
- ConfigDirectoryLdapURL= ldap://dir.example.com:389/o=NetscapeRoot
-
- [slapd]
- SlapdConfigForMC= Yes
- UseExistingMC= 0
- ServerPort= 389
- ServerIdentifier= dir
- Suffix= dc=example,dc=com
- RootDN= cn=Directory Manager
+ [General]
+ FullMachineName= dir.example.com
+ SuiteSpotUserID= nobody
+ SuiteSpotGroup= nobody
+ AdminDomain= example.com
+ ConfigDirectoryAdminID= admin
+ ConfigDirectoryAdminPwd= admin
+ ConfigDirectoryLdapURL= ldap://dir.example.com:389/o=NetscapeRoot
+
+ [slapd]
+ SlapdConfigForMC= Yes
+ UseExistingMC= 0
+ ServerPort= 389
+ ServerIdentifier= dir
+ Suffix= dc=example,dc=com
+ RootDN= cn=Directory Manager
RootDNPwd= password
- ds_bename=exampleDB
+ ds_bename=exampleDB
AddSampleEntries= No
- [admin]
+ [admin]
Port= 9830
- ServerIpAddress= 111.11.11.11
- ServerAdminID= admin
+ ServerIpAddress= 111.11.11.11
+ ServerAdminID= admin
ServerAdminPwd= admin
-
+
"""
args = args.copy()
args['CFGSUFFIX'] = lib389.CFGSUFFIX
@@ -437,22 +595,22 @@ def formatInfData(args):
"ConfigDirectoryAdminID= %(cfgdsuser)s" "\n"
"ConfigDirectoryAdminPwd= %(cfgdspwd)s" "\n"
) % args
-
+
content += ("\n" "\n" "[slapd]" "\n")
content += ("ServerPort= %s\n" % args[SER_PORT])
content += ("RootDN= %s\n" % args[SER_ROOT_DN])
content += ("RootDNPwd= %s\n" % args[SER_ROOT_PW])
content += ("ServerIdentifier= %s\n" % args[SER_SERVERID_PROP])
content += ("Suffix= %s\n" % args[SER_CREATION_SUFFIX])
-
+
# Create admin?
if args.get('setup_admin'):
content += (
- "SlapdConfigForMC= Yes" "\n"
+ "SlapdConfigForMC= Yes" "\n"
"UseExistingMC= 0 " "\n"
)
-
+
if 'InstallLdifFile' in args:
content += """\nInstallLdifFile= %s\n""" % args['InstallLdifFile']
@@ -468,5 +626,5 @@ def formatInfData(args):
if 'ldapifilepath' in args:
content += "\nldapifilepath=%s\n" % args['ldapifilepath']
-
+
return content
| 0 |
0b12f35b9fd398e08924161beca0544e0cd75052
|
389ds/389-ds-base
|
Issue 27 - Fix get function in tests
Description: Function 'dseldif.get' now returns None,
if we haven't found an attribute. Fix tests accordingly.
https://pagure.io/lib389/issue/27
Reviewed by: wibrown (Thanks!)
|
commit 0b12f35b9fd398e08924161beca0544e0cd75052
Author: Simon Pichugin <[email protected]>
Date: Sun May 28 22:52:57 2017 +0200
Issue 27 - Fix get function in tests
Description: Function 'dseldif.get' now returns None,
if we haven't found an attribute. Fix tests accordingly.
https://pagure.io/lib389/issue/27
Reviewed by: wibrown (Thanks!)
diff --git a/src/lib389/lib389/tests/dseldif_test.py b/src/lib389/lib389/tests/dseldif_test.py
index 25eef778d..44eb4d476 100644
--- a/src/lib389/lib389/tests/dseldif_test.py
+++ b/src/lib389/lib389/tests/dseldif_test.py
@@ -34,6 +34,10 @@ def test_get_singlevalue(topo, entry_dn):
attr_values = dse_ldif.get(entry_dn, "cn")
assert attr_values == ["config"]
+ log.info("Get 'nonexistent' attr from {}".format(entry_dn))
+ attr_values = dse_ldif.get(entry_dn, "nonexistent")
+ assert not attr_values
+
def test_get_multivalue(topo):
"""Check that we can get attribute values"""
@@ -63,8 +67,7 @@ def test_add(topo, fake_attr_value):
log.info("Clean up")
dse_ldif.delete(DN_CONFIG, fake_attr)
- with pytest.raises(ValueError):
- dse_ldif.get(DN_CONFIG, fake_attr)
+ assert not dse_ldif.get(DN_CONFIG, fake_attr)
def test_replace(topo):
@@ -107,8 +110,7 @@ def test_delete_singlevalue(topo):
log.info("Clean up")
dse_ldif.delete(DN_CONFIG, fake_attr)
- with pytest.raises(ValueError):
- dse_ldif.get(DN_CONFIG, fake_attr)
+ assert not dse_ldif.get(DN_CONFIG, fake_attr)
def test_delete_multivalue(topo):
@@ -124,6 +126,5 @@ def test_delete_multivalue(topo):
log.info("Delete all values of {}".format(fake_attr))
dse_ldif.delete(DN_CONFIG, fake_attr)
- with pytest.raises(ValueError):
- dse_ldif.get(DN_CONFIG, fake_attr)
+ assert not dse_ldif.get(DN_CONFIG, fake_attr)
| 0 |
9ae878c2ff6475cabb01a035902addd8816c93fe
|
389ds/389-ds-base
|
Ticket #48048 - Fix coverity issues - 2015/2/24
Coverity defect 13035 - Explicit null dereferenced (FORWARD_NULL)
Description: Added NULL check for op.
modified: usn_preop_delete in usn.c
|
commit 9ae878c2ff6475cabb01a035902addd8816c93fe
Author: Noriko Hosoi <[email protected]>
Date: Wed Feb 25 11:45:25 2015 -0800
Ticket #48048 - Fix coverity issues - 2015/2/24
Coverity defect 13035 - Explicit null dereferenced (FORWARD_NULL)
Description: Added NULL check for op.
modified: usn_preop_delete in usn.c
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 6b34bf481..55ab5f7d2 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -321,6 +321,11 @@ usn_preop_delete(Slapi_PBlock *pb)
"--> usn_preop_delete\n");
slapi_pblock_get(pb, SLAPI_OPERATION, &op);
+ if (NULL == op) {
+ slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
+ "<-- usn_preop_delete failed; no operation.\n");
+ return SLAPI_PLUGIN_FAILURE;
+ }
slapi_operation_set_replica_attr_handler(op, (void *)usn_get_attr);
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
| 0 |
ec1e7cdefc25df63eba72f3744c201271df69c6a
|
389ds/389-ds-base
|
Bug 692991 - rhds82 - windows_tot_run: failed to obtain data to send to the consumer; LDAP error - -1
https://bugzilla.redhat.com/show_bug.cgi?id=692991
Resolves: bug 692991
Bug Description: windows_tot_run: failed to obtain data to send to the consumer; LDAP error - -1
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: I could not reproduce the problem. I could not figure out
a way to get Windows to let me add a user-type entry with child entries.
The GUI does not even have this option. Using ldapmodify results in a
Naming Violation. I suspect Exchange somehow tweaks AD to allow this
sort of dit structure. I'm pretty sure the problem is that we are doing
a scope SUBTREE search to get the user's entry and we are running into a
SIZELIMIT_EXCEEDED. The solution is to just do an LDAP_SCOPE_BASE search
to get the single entry to operate on. I had to extend
windows_search_entry_ext to add a scope parameter. Since the old default
was to do a SUBTREE search, I made windows_search_entry use that.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit ec1e7cdefc25df63eba72f3744c201271df69c6a
Author: Rich Megginson <[email protected]>
Date: Mon Apr 4 17:25:25 2011 -0600
Bug 692991 - rhds82 - windows_tot_run: failed to obtain data to send to the consumer; LDAP error - -1
https://bugzilla.redhat.com/show_bug.cgi?id=692991
Resolves: bug 692991
Bug Description: windows_tot_run: failed to obtain data to send to the consumer; LDAP error - -1
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: I could not reproduce the problem. I could not figure out
a way to get Windows to let me add a user-type entry with child entries.
The GUI does not even have this option. Using ldapmodify results in a
Naming Violation. I suspect Exchange somehow tweaks AD to allow this
sort of dit structure. I'm pretty sure the problem is that we are doing
a scope SUBTREE search to get the user's entry and we are running into a
SIZELIMIT_EXCEEDED. The solution is to just do an LDAP_SCOPE_BASE search
to get the single entry to operate on. I had to extend
windows_search_entry_ext to add a scope parameter. Since the old default
was to do a SUBTREE search, I made windows_search_entry use that.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index 50c2abfdf..e8fe94d68 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -618,12 +618,12 @@ windows_LDAPMessage2Entry(Repl_Connection *conn, LDAPMessage * msg, int attrsonl
ConnResult
windows_search_entry(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry)
{
- return windows_search_entry_ext(conn, searchbase, filter, entry, NULL);
+ return windows_search_entry_ext(conn, searchbase, filter, entry, NULL, LDAP_SCOPE_SUBTREE);
}
/* Perform a simple search against Windows with optional controls */
ConnResult
-windows_search_entry_ext(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry, LDAPControl **serverctrls)
+windows_search_entry_ext(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry, LDAPControl **serverctrls, int scope)
{
ConnResult return_value = 0;
@@ -642,7 +642,6 @@ windows_search_entry_ext(Repl_Connection *conn, char* searchbase, char *filter,
int ldap_rc = 0;
LDAPMessage *res = NULL;
char *searchbase_copy = slapi_ch_strdup(searchbase);
- int scope = LDAP_SCOPE_SUBTREE;
char *filter_copy = slapi_ch_strdup(filter);
char **attrs = NULL;
LDAPControl **serverctrls_copy = NULL;
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index 3290e8d2f..a54fe9e63 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -2773,7 +2773,7 @@ windows_get_remote_entry (Private_Repl_Protocol *prp, const Slapi_DN* remote_dn,
Slapi_Entry *found_entry = NULL;
searchbase = slapi_sdn_get_dn(remote_dn);
- cres = windows_search_entry(prp->conn, (char*)searchbase, filter, &found_entry);
+ cres = windows_search_entry_ext(prp->conn, (char*)searchbase, filter, &found_entry, NULL, LDAP_SCOPE_BASE);
if (cres)
{
retval = -1;
@@ -2806,7 +2806,7 @@ windows_get_remote_tombstone (Private_Repl_Protocol *prp, const Slapi_DN* remote
searchbase = slapi_sdn_get_dn(remote_dn);
cres = windows_search_entry_ext(prp->conn, (char*)searchbase, filter,
- &found_entry, server_controls);
+ &found_entry, server_controls, LDAP_SCOPE_SUBTREE);
if (cres) {
retval = -1;
} else {
@@ -4791,8 +4791,8 @@ retry:
char *filter = "(objectclass=*)";
retried = 1;
- cres = windows_search_entry(prp->conn, (char*)searchbase,
- filter, &found_entry);
+ cres = windows_search_entry_ext(prp->conn, (char*)searchbase,
+ filter, &found_entry, NULL, LDAP_SCOPE_BASE);
if (0 == cres && found_entry) {
/*
* Entry e originally allocated in windows_dirsync_inc_run
diff --git a/ldap/servers/plugins/replication/windowsrepl.h b/ldap/servers/plugins/replication/windowsrepl.h
index 158b0d1e1..52b8dac71 100644
--- a/ldap/servers/plugins/replication/windowsrepl.h
+++ b/ldap/servers/plugins/replication/windowsrepl.h
@@ -51,7 +51,7 @@ const Slapi_DN* windows_private_get_directory_subtree (const Repl_Agmt *ra);
LDAPControl* windows_private_dirsync_control(const Repl_Agmt *ra);
ConnResult send_dirsync_search(Repl_Connection *conn);
ConnResult windows_search_entry(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry);
-ConnResult windows_search_entry_ext(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry, LDAPControl **serverctrls);
+ConnResult windows_search_entry_ext(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry, LDAPControl **serverctrls, int scope);
Slapi_Entry *windows_conn_get_search_result(Repl_Connection *conn );
void windows_private_update_dirsync_control(const Repl_Agmt *ra,LDAPControl **controls );
PRBool windows_private_dirsync_has_more(const Repl_Agmt *ra);
| 0 |
5232b202fc2ddb529312d30304867d3ff470d3a2
|
389ds/389-ds-base
|
Ticket #6 - protocol error from proxied auth operation
Bug Description: Trying to perform a proxied auth operation leads to
a protocol error(err=2).
Fix Description: ber_scanf() was rejecting the authdn value, becuase it
did not start with a octet string/char. The fix was
to check for the octet string, and if it wasn't present
then just use the value as it is.
https://fedorahosted.org/389/ticket/
|
commit 5232b202fc2ddb529312d30304867d3ff470d3a2
Author: Mark Reynolds <[email protected]>
Date: Wed Feb 1 10:35:56 2012 -0500
Ticket #6 - protocol error from proxied auth operation
Bug Description: Trying to perform a proxied auth operation leads to
a protocol error(err=2).
Fix Description: ber_scanf() was rejecting the authdn value, becuase it
did not start with a octet string/char. The fix was
to check for the octet string, and if it wasn't present
then just use the value as it is.
https://fedorahosted.org/389/ticket/
diff --git a/ldap/servers/slapd/proxyauth.c b/ldap/servers/slapd/proxyauth.c
index 2230a3116..fe36cf100 100644
--- a/ldap/servers/slapd/proxyauth.c
+++ b/ldap/servers/slapd/proxyauth.c
@@ -106,21 +106,25 @@ parse_LDAPProxyAuth(struct berval *spec_ber, int version, char **errtextp,
break;
}
- ber = ber_init(spec_ber);
- if (!ber) {
- break;
- }
-
- if ( version == 1 ) {
- tag = ber_scanf(ber, "{a}", &spec->auth_dn);
+ if (version == 2 && (spec_ber->bv_val[0] != CHAR_OCTETSTRING)) {
+ /* This doesn't start with an octet string, so just use the actual value */
+ spec->auth_dn = slapi_ch_strdup(spec_ber->bv_val);
} else {
- tag = ber_scanf(ber, "a", &spec->auth_dn);
- }
- if (tag == LBER_ERROR) {
- lderr = LDAP_PROTOCOL_ERROR;
- break;
- }
+ ber = ber_init(spec_ber);
+ if (!ber) {
+ break;
+ }
+ if ( version == 1 ) {
+ tag = ber_scanf(ber, "{a}", &spec->auth_dn);
+ } else {
+ tag = ber_scanf(ber, "a", &spec->auth_dn);
+ }
+ if (tag == LBER_ERROR) {
+ lderr = LDAP_PROTOCOL_ERROR;
+ break;
+ }
+ }
/*
* In version 2 of the control, the control value is actually an
* authorization ID (see section 9 of RFC 2829). We only support
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 86d954d15..c6d342c97 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2310,6 +2310,8 @@ extern char *attr_dataversion;
#define LDAP_VIRTUAL_LIST_VIEW_ERROR 0x4C /* 76 */
#endif
+#define CHAR_OCTETSTRING (char)0x04
+
/* copied from replication/repl5.h */
#define RUV_STORAGE_ENTRY_UNIQUEID "ffffffff-ffffffff-ffffffff-ffffffff"
| 0 |
caca64e7ee89e1f9ea63150f3dbfb5d1e8ea6b1a
|
389ds/389-ds-base
|
Issue 50806 - Fix minor issues in lib389 health checks
Description: For permissions checks, add a list of permissions
that is acceptable instead of single value.
For RI plugin attribute indexing checks, we now check
if a container scope is specified. If it is set, we
skip all the other backends that are not in the scope.
This prevents false positives.
relates: https://pagure.io/389-ds-base/issue/50806
Reviewed by: mhonek(Thanks!)
|
commit caca64e7ee89e1f9ea63150f3dbfb5d1e8ea6b1a
Author: Mark Reynolds <[email protected]>
Date: Fri Jan 10 10:29:02 2020 -0500
Issue 50806 - Fix minor issues in lib389 health checks
Description: For permissions checks, add a list of permissions
that is acceptable instead of single value.
For RI plugin attribute indexing checks, we now check
if a container scope is specified. If it is set, we
skip all the other backends that are not in the scope.
This prevents false positives.
relates: https://pagure.io/389-ds-base/issue/50806
Reviewed by: mhonek(Thanks!)
diff --git a/src/lib389/lib389/dseldif.py b/src/lib389/lib389/dseldif.py
index 75fc76a46..d1dc242c4 100644
--- a/src/lib389/lib389/dseldif.py
+++ b/src/lib389/lib389/dseldif.py
@@ -329,13 +329,27 @@ class FSChecks(object):
self.dirsrv = dirsrv
self._certdb = self.dirsrv.get_cert_dir()
self.ds_files = [
- ('/etc/resolv.conf', '644', DSPERMLE0001),
- (self._certdb + "/pin.txt", '600', DSPERMLE0002),
- (self._certdb + "/pwdfile.txt", '600', DSPERMLE0002),
+ {
+ 'name': '/etc/resolv.conf',
+ 'perms': [644],
+ 'report': DSPERMLE0001
+ },
+ {
+ 'name': self._certdb + "/pin.txt",
+ 'perms': [400, 600],
+ 'report': DSPERMLE0002
+ },
+ {
+ 'name': self._certdb + "/pwdfile.txt",
+ 'perms': [400, 600],
+ 'report': DSPERMLE0002
+ },
]
self._lint_functions = [self._lint_file_perms]
def lint(self):
+ """Run a lint/healthcheck for this class
+ """
results = []
for fn in self._lint_functions:
for result in fn():
@@ -344,14 +358,16 @@ class FSChecks(object):
return results
def _lint_file_perms(self):
- # Check file permissions are correct
+ """Test file permissions are safe
+ """
for ds_file in self.ds_files:
- perms = str(oct(os.stat(ds_file[0])[ST_MODE])[-3:])
- if perms != ds_file[1]:
- report = copy.deepcopy(ds_file[2])
- report['items'].append(ds_file[0])
- report['detail'] = report['detail'].replace('FILE', ds_file[0])
- report['detail'] = report['detail'].replace('PERMS', ds_file[1])
- report['fix'] = report['fix'].replace('FILE', ds_file[0])
- report['fix'] = report['fix'].replace('PERMS', ds_file[1])
+ perms = int(oct(os.stat(ds_file['name'])[ST_MODE])[-3:])
+ if perms not in ds_file['perms']:
+ perms = str(ds_file['perms'][0])
+ report = copy.deepcopy(ds_file['report'])
+ report['items'].append(ds_file['name'])
+ report['detail'] = report['detail'].replace('FILE', ds_file['name'])
+ report['detail'] = report['detail'].replace('PERMS', perms)
+ report['fix'] = report['fix'].replace('FILE', ds_file['name'])
+ report['fix'] = report['fix'].replace('PERMS', perms)
yield report
diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py
index 8cea8e96f..cb6b24a40 100644
--- a/src/lib389/lib389/plugins.py
+++ b/src/lib389/lib389/plugins.py
@@ -455,10 +455,19 @@ class ReferentialIntegrityPlugin(Plugin):
if self.status():
from lib389.backend import Backends
backends = Backends(self._instance).list()
+ attrs = self.get_attr_vals_utf8_l("referint-membership-attr")
+ container = self.get_attr_val_utf8_l("nsslapd-plugincontainerscope")
for backend in backends:
- indexes = backend.get_indexes()
suffix = backend.get_attr_val_utf8_l('nsslapd-suffix')
- attrs = self.get_attr_vals_utf8_l("referint-membership-attr")
+ if suffix == "cn=changelog":
+ # Always skip retro changelog
+ continue
+ if container is not None:
+ # Check if this backend is in the scope
+ if not container.endswith(suffix):
+ # skip this backend that is not in the scope
+ continue
+ indexes = backend.get_indexes()
for attr in attrs:
report = copy.deepcopy(DSRILE0002)
try:
| 0 |
9bf48714b223b0921c9456d10716fe9727025549
|
389ds/389-ds-base
|
Resolves: #436830
Summary: Memory leak in ns-slapd's Class Of Service
Fix Description: When all the necessary values for the template cache are not
available, the allocated memory should be discarded. One of them pCosPriority
was missed to release.
|
commit 9bf48714b223b0921c9456d10716fe9727025549
Author: Noriko Hosoi <[email protected]>
Date: Thu Jan 8 23:11:43 2009 +0000
Resolves: #436830
Summary: Memory leak in ns-slapd's Class Of Service
Fix Description: When all the necessary values for the template cache are not
available, the allocated memory should be discarded. One of them pCosPriority
was missed to release.
diff --git a/ldap/servers/plugins/cos/cos_cache.c b/ldap/servers/plugins/cos/cos_cache.c
index aa042670c..29a0d0d79 100644
--- a/ldap/servers/plugins/cos/cos_cache.c
+++ b/ldap/servers/plugins/cos/cos_cache.c
@@ -1190,7 +1190,7 @@ static int cos_dn_tmpl_entries_cb (Slapi_Entry* e, void *callback_data) {
{
while(dnVals[valIndex])
{
- if(dnVals[valIndex]->bv_val)
+ if(dnVals[valIndex]->bv_val)
cos_cache_add_attrval(pSneakyVal,
dnVals[valIndex]->bv_val);
@@ -1269,6 +1269,8 @@ static int cos_dn_tmpl_entries_cb (Slapi_Entry* e, void *callback_data) {
cos_cache_del_attrval_list(&pDn);
if(pAttributes)
cos_cache_del_attr_list(&pAttributes);
+ if(pCosPriority)
+ cos_cache_del_attrval_list(&pCosPriority);
}
}
/*
| 0 |
22d975426d60adef172da7601586512accae11f0
|
389ds/389-ds-base
|
Issue 50486 - Update jemalloc to 5.2.0
Description: Update jemalloc from 5.1.0 to 5.2.0
https://github.com/jemalloc/jemalloc/releases/tag/5.2.0
Refers: https://pagure.io/389-ds-base/issue/50486
Reviewed by: mhonek(Thanks!)
|
commit 22d975426d60adef172da7601586512accae11f0
Author: Mark Reynolds <[email protected]>
Date: Mon Jul 8 17:17:18 2019 -0400
Issue 50486 - Update jemalloc to 5.2.0
Description: Update jemalloc from 5.1.0 to 5.2.0
https://github.com/jemalloc/jemalloc/releases/tag/5.2.0
Refers: https://pagure.io/389-ds-base/issue/50486
Reviewed by: mhonek(Thanks!)
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index 596c84328..876adb3b1 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -4,7 +4,7 @@
%global bundle_jemalloc __BUNDLE_JEMALLOC__
%if %{bundle_jemalloc}
%global jemalloc_name jemalloc
-%global jemalloc_ver 5.1.0
+%global jemalloc_ver 5.2.0
%endif
# This is used in certain builds to help us know if it has extra features.
| 0 |
1377cbc840a80c9bc22146645a46c421d3fc4551
|
389ds/389-ds-base
|
Auto-generated by autoheader; needs to be in CVS.
|
commit 1377cbc840a80c9bc22146645a46c421d3fc4551
Author: Noriko Hosoi <[email protected]>
Date: Tue Nov 14 21:23:45 2006 +0000
Auto-generated by autoheader; needs to be in CVS.
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 000000000..70b41765c
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,285 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if the `closedir' function returns void instead of `int'. */
+#undef CLOSEDIR_VOID
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#undef HAVE_ARPA_INET_H
+
+/* Define to 1 if your system has a working `chown' function. */
+#undef HAVE_CHOWN
+
+/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRERROR_R
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+#undef HAVE_DOPRNT
+
+/* Define to 1 if you have the `endpwent' function. */
+#undef HAVE_ENDPWENT
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `fork' function. */
+#undef HAVE_FORK
+
+/* Define to 1 if you have the `ftruncate' function. */
+#undef HAVE_FTRUNCATE
+
+/* Define to 1 if you have the `getcwd' function. */
+#undef HAVE_GETCWD
+
+/* Define to 1 if you have the `gethostbyname' function. */
+#undef HAVE_GETHOSTBYNAME
+
+/* Define to 1 if you have the `getpagesize' function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define to 1 if you have the `inet_ntoa' function. */
+#undef HAVE_INET_NTOA
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `localtime_r' function. */
+#undef HAVE_LOCALTIME_R
+
+/* Define to 1 if `lstat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+#undef HAVE_LSTAT_EMPTY_STRING_BUG
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+#undef HAVE_MALLOC
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `mkdir' function. */
+#undef HAVE_MKDIR
+
+/* Define to 1 if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define to 1 if you have the `munmap' function. */
+#undef HAVE_MUNMAP
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the `putenv' function. */
+#undef HAVE_PUTENV
+
+/* Define to 1 if you have the `rmdir' function. */
+#undef HAVE_RMDIR
+
+/* Define to 1 if you have the `setrlimit' function. */
+#undef HAVE_SETRLIMIT
+
+/* Define to 1 if you have the `socket' function. */
+#undef HAVE_SOCKET
+
+/* Define to 1 if `stat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+#undef HAVE_STAT_EMPTY_STRING_BUG
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#undef HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the `strcspn' function. */
+#undef HAVE_STRCSPN
+
+/* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define to 1 if you have the `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the `strerror_r' function. */
+#undef HAVE_STRERROR_R
+
+/* Define to 1 if you have the `strftime' function. */
+#undef HAVE_STRFTIME
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strpbrk' function. */
+#undef HAVE_STRPBRK
+
+/* Define to 1 if you have the `strrchr' function. */
+#undef HAVE_STRRCHR
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* Define to 1 if you have the `strtol' function. */
+#undef HAVE_STRTOL
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define to 1 if you have the `tzset' function. */
+#undef HAVE_TZSET
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `vfork' function. */
+#undef HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#undef HAVE_VFORK_H
+
+/* Define to 1 if you have the `vprintf' function. */
+#undef HAVE_VPRINTF
+
+/* Define to 1 if `fork' works. */
+#undef HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#undef HAVE_WORKING_VFORK
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Use FHS layout */
+#undef IS_FHS
+
+/* LDAP debug flag */
+#undef LDAP_DEBUG
+
+/* Don't use smartheap */
+#undef LDAP_DONT_USE_SMARTHEAP
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+ slash. */
+#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#undef RETSIGTYPE
+
+/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+#undef STAT_MACROS_BROKEN
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if strerror_r returns char *. */
+#undef STRERROR_R_CHAR_P
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef gid_t
+
+/* Define to rpl_malloc if the replacement function should be used. */
+#undef malloc
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef pid_t
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef uid_t
+
+/* Define as `fork' if `vfork' does not work. */
+#undef vfork
| 0 |
cdf4fb4ea6f26b4198d2d6b146ca51dcd51a31ef
|
389ds/389-ds-base
|
Ticket 48957 - set proper update status to replication
agreement in case of failure
Bug Description: If a replication agreement fails to send updates it always returns
a generic error message even though there are many ways it could be
failing.
Fix Description: Set a proper error message when we fail to update a replica. Also made
all the messages consistent in format, and added new response strings
for known errors.
Also fixed some minor compiler warnings.
https://fedorahosted.org/389/ticket/48957
Reviewed by: nhosoi(Thanks!)
|
commit cdf4fb4ea6f26b4198d2d6b146ca51dcd51a31ef
Author: Mark Reynolds <[email protected]>
Date: Fri Aug 26 15:04:02 2016 -0400
Ticket 48957 - set proper update status to replication
agreement in case of failure
Bug Description: If a replication agreement fails to send updates it always returns
a generic error message even though there are many ways it could be
failing.
Fix Description: Set a proper error message when we fail to update a replica. Also made
all the messages consistent in format, and added new response strings
for known errors.
Also fixed some minor compiler warnings.
https://fedorahosted.org/389/ticket/48957
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 6f6c81a3d..13a38fdec 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -91,11 +91,16 @@
#define NSDS50_REPL_BELOW_PURGEPOINT 0x07 /* Supplier provided a CSN below the consumer's purge point */
#define NSDS50_REPL_INTERNAL_ERROR 0x08 /* Something bad happened on consumer */
#define NSDS50_REPL_REPLICA_RELEASE_SUCCEEDED 0x09 /* Replica released successfully */
-#define NSDS50_REPL_LEGACY_CONSUMER 0x0A /* replica is a legacy consumer */
-#define NSDS50_REPL_REPLICAID_ERROR 0x0B /* replicaID doesn't seem to be unique */
-#define NSDS50_REPL_DISABLED 0x0C /* replica suffix is disabled */
-#define NSDS50_REPL_UPTODATE 0x0D /* replica is uptodate */
-#define NSDS50_REPL_BACKOFF 0x0E /* replica wants master to go into backoff mode */
+#define NSDS50_REPL_LEGACY_CONSUMER 0x0A /* replica is a legacy consumer */
+#define NSDS50_REPL_REPLICAID_ERROR 0x0B /* replicaID doesn't seem to be unique */
+#define NSDS50_REPL_DISABLED 0x0C /* replica suffix is disabled */
+#define NSDS50_REPL_UPTODATE 0x0D /* replica is uptodate */
+#define NSDS50_REPL_BACKOFF 0x0E /* replica wants master to go into backoff mode */
+#define NSDS50_REPL_CL_ERROR 0x0F /* Problem reading changelog */
+#define NSDS50_REPL_CONN_ERROR 0x10 /* Problem with replication connection*/
+#define NSDS50_REPL_CONN_TIMEOUT 0x11 /* Connection timeout */
+#define NSDS50_REPL_TRANSIENT_ERROR 0x12 /* Transient error */
+#define NSDS50_REPL_RUV_ERROR 0x13 /* Problem with the RUV */
#define NSDS50_REPL_REPLICA_NO_RESPONSE 0xff /* No response received */
/* Protocol status */
diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c
index 76d26a1da..52cc8b608 100644
--- a/ldap/servers/plugins/replication/repl5_agmt.c
+++ b/ldap/servers/plugins/replication/repl5_agmt.c
@@ -2460,9 +2460,9 @@ agmt_set_last_update_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *
replmsg = NULL;
}
}
- PR_snprintf(ra->last_update_status, STATUS_LEN, "%d %s%sLDAP error: %s%s%s",
+ PR_snprintf(ra->last_update_status, STATUS_LEN, "Error (%d) %s%s - LDAP error: %s%s%s%s",
ldaprc, message?message:"",message?"":" - ",
- slapi_err2string(ldaprc), replmsg ? " - " : "", replmsg ? replmsg : "");
+ slapi_err2string(ldaprc), replmsg ? " (" : "", replmsg ? replmsg : "", replmsg ? ")" : "");
}
/* ldaprc == LDAP_SUCCESS */
else if (replrc != 0)
@@ -2470,16 +2470,15 @@ agmt_set_last_update_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *
if (replrc == NSDS50_REPL_REPLICA_BUSY)
{
PR_snprintf(ra->last_update_status, STATUS_LEN,
- "%d Can't acquire busy replica", replrc );
+ "Error (%d) Can't acquire busy replica", replrc );
}
else if (replrc == NSDS50_REPL_REPLICA_RELEASE_SUCCEEDED)
{
- PR_snprintf(ra->last_update_status, STATUS_LEN, "%d %s",
- ldaprc, "Replication session successful");
+ PR_snprintf(ra->last_update_status, STATUS_LEN, "Error (0) Replication session successful");
}
else if (replrc == NSDS50_REPL_DISABLED)
{
- PR_snprintf(ra->last_update_status, STATUS_LEN, "%d Incremental update aborted: "
+ PR_snprintf(ra->last_update_status, STATUS_LEN, "Error (%d) Incremental update aborted: "
"Replication agreement for %s\n can not be updated while the replica is disabled.\n"
"(If the suffix is disabled you must enable it then restart the server for replication to take place).",
replrc, ra->long_name ? ra->long_name : "a replica");
@@ -2493,20 +2492,18 @@ agmt_set_last_update_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *
else
{
PR_snprintf(ra->last_update_status, STATUS_LEN,
- "%d Replication error acquiring replica: %s%s%s",
- replrc, protocol_response2string(replrc),
- message?" - ":"",message?message:"");
+ "Error (%d) Replication error acquiring replica: %s%s(%s)",
+ replrc, message?message:"", message?" ":"", protocol_response2string(replrc));
}
}
else if (message != NULL) /* replrc == NSDS50_REPL_REPLICA_READY == 0 */
{
- PR_snprintf(ra->last_update_status, STATUS_LEN,
- "%d Replica acquired successfully: %s",
- ldaprc, message);
+ PR_snprintf(ra->last_update_status, STATUS_LEN,
+ "Error (0) Replica acquired successfully: %s", message);
}
else
{ /* agmt_set_last_update_status(0,0,NULL) to reset agmt */
- PR_snprintf(ra->last_update_status, STATUS_LEN, "%d", ldaprc);
+ ra->last_update_status[0] = '\0';
}
}
}
@@ -2737,7 +2734,8 @@ get_agmt_status(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
slapi_entry_add_string(e, "nsds5replicaChangesSentSinceStartup", changecount_string);
if (ra->last_update_status[0] == '\0')
{
- slapi_entry_add_string(e, "nsds5replicaLastUpdateStatus", "0 No replication sessions started since server startup");
+ slapi_entry_add_string(e, "nsds5replicaLastUpdateStatus",
+ "Error (0) No replication sessions started since server startup");
}
else
{
diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c
index 27bac5d91..d1de6c5b7 100644
--- a/ldap/servers/plugins/replication/repl5_inc_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c
@@ -671,7 +671,6 @@ repl5_inc_run(Private_Repl_Protocol *prp)
int wait_change_timer_set = 0;
int current_state = STATE_START;
int next_state = STATE_START;
- int optype, ldaprc;
int done;
int e1;
@@ -838,14 +837,6 @@ repl5_inc_run(Private_Repl_Protocol *prp)
} else if (rc == ACQUIRE_FATAL_ERROR){
next_state = STATE_STOP_FATAL_ERROR;
}
-
- if (rc != ACQUIRE_SUCCESS){
- int optype, ldaprc;
- conn_get_error(prp->conn, &optype, &ldaprc);
- agmt_set_last_update_status(prp->agmt, ldaprc,
- prp->last_acquire_response_code, "Unable to acquire replica");
- }
-
object_release(prp->replica_object);
break;
@@ -934,10 +925,6 @@ repl5_inc_run(Private_Repl_Protocol *prp)
} else if (rc == ACQUIRE_FATAL_ERROR){
next_state = STATE_STOP_FATAL_ERROR;
}
- if (rc != ACQUIRE_SUCCESS){
- conn_get_error(prp->conn, &optype, &ldaprc);
- agmt_set_last_update_status(prp->agmt, ldaprc, prp->last_acquire_response_code, "Unable to acquire replica");
- }
/*
* We either need to step the backoff timer, or
* destroy it if we don't need it anymore
@@ -1037,7 +1024,8 @@ repl5_inc_run(Private_Repl_Protocol *prp)
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Replica has no update vector. It has never been initialized.\n",
agmt_get_long_name(prp->agmt));
- agmt_set_last_update_status(prp->agmt, 0, rc, "Replica is not initialized");
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_RUV_ERROR,
+ "Replica is not initialized");
next_state = STATE_BACKOFF_START;
break;
case EXAMINE_RUV_GENERATION_MISMATCH:
@@ -1045,8 +1033,9 @@ repl5_inc_run(Private_Repl_Protocol *prp)
"%s: The remote replica has a different database generation ID than "
"the local database. You may have to reinitialize the remote replica, "
"or the local replica.\n", agmt_get_long_name(prp->agmt));
- agmt_set_last_update_status(prp->agmt, 0, rc, "Replica has different database "
- "generation ID, remote replica may need to be initialized");
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_RUV_ERROR,
+ "Replica has different database generation ID, remote "
+ "replica may need to be initialized");
next_state = STATE_BACKOFF_START;
break;
case EXAMINE_RUV_REPLICA_TOO_OLD:
@@ -1054,7 +1043,8 @@ repl5_inc_run(Private_Repl_Protocol *prp)
"%s: Replica update vector is too out of date to bring "
"into sync using the incremental protocol. The replica "
"must be reinitialized.\n", agmt_get_long_name(prp->agmt));
- agmt_set_last_update_status(prp->agmt, 0, rc, "Replica needs to be reinitialized");
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_RUV_ERROR,
+ "Replica needs to be reinitialized");
next_state = STATE_BACKOFF_START;
break;
case EXAMINE_RUV_OK:
@@ -1069,11 +1059,15 @@ repl5_inc_run(Private_Repl_Protocol *prp)
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Incremental protocol: fatal error - too much time skew between replicas!\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_EXCESSIVE_CLOCK_SKEW,
+ "fatal error - too much time skew between replicas");
next_state = STATE_STOP_FATAL_ERROR;
} else if (rc != 0) /* internal error */ {
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Incremental protocol: fatal internal error updating the CSN generator!\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_INTERNAL_ERROR,
+ "fatal internal error updating the CSN generator");
next_state = STATE_STOP_FATAL_ERROR;
} else {
/*
@@ -1097,7 +1091,8 @@ repl5_inc_run(Private_Repl_Protocol *prp)
next_state = STATE_BACKOFF_START;
} else if (rc == UPDATE_TRANSIENT_ERROR){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_TRANSIENT_ERROR -> STATE_BACKOFF_START");
- agmt_set_last_update_status(prp->agmt, 0, rc, "Incremental update transient error. Backing off, will retry update later.");
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_TRANSIENT_ERROR,
+ "Incremental update transient error. Backing off, will retry update later.");
next_state = STATE_BACKOFF_START;
} else if (rc == UPDATE_FATAL_ERROR){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_FATAL_ERROR -> STATE_STOP_FATAL_ERROR");
@@ -1114,11 +1109,13 @@ repl5_inc_run(Private_Repl_Protocol *prp)
conn_disconnect (prp->conn);
} else if (rc == UPDATE_CONNECTION_LOST){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_CONNECTION_LOST -> STATE_BACKOFF_START");
- agmt_set_last_update_status(prp->agmt, 0, rc, "Incremental update connection error. Backing off, will retry update later.");
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CONN_ERROR,
+ "Incremental update connection error. Backing off, will retry update later.");
next_state = STATE_BACKOFF_START;
} else if (rc == UPDATE_TIMEOUT){
dev_debug("repl5_inc_run(STATE_SENDING_UPDATES) -> send_updates = UPDATE_TIMEOUT -> STATE_BACKOFF_START");
- agmt_set_last_update_status(prp->agmt, 0, rc, "Incremental update timeout error. Backing off, will retry update later.");
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CONN_TIMEOUT,
+ "Incremental update timeout error. Backing off, will retry update later.");
next_state = STATE_BACKOFF_START;
}
/* Set the updates times based off the result of send_updates() */
@@ -1173,8 +1170,6 @@ repl5_inc_run(Private_Repl_Protocol *prp)
/*
* We encountered some sort of a fatal error. Suspend.
*/
- /* XXXggood update state in replica */
- agmt_set_last_update_status(prp->agmt, -1, 0, "Incremental update has failed and requires administrator action");
dev_debug("repl5_inc_run(STATE_STOP_FATAL_ERROR)");
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Incremental update failed and requires administrator action\n",
@@ -1630,30 +1625,40 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Invalid parameter passed to cl5CreateReplayIterator\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Invalid parameter passed to cl5CreateReplayIterator");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_BAD_FORMAT: /* db data has unexpected format */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Unexpected format encountered in changelog database\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Unexpected format encountered in changelog database");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_BAD_STATE: /* changelog is in an incorrect state for attempted operation */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Changelog database was in an incorrect state\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Changelog database was in an incorrect state");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_BAD_DBVERSION: /* changelog has invalid dbversion */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Incorrect dbversion found in changelog database\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Incorrect dbversion found in changelog database");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_DB_ERROR: /* database error */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: A changelog database error was encountered\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Changelog database error was encountered");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_NOTFOUND: /* we have no changes to send */
@@ -1666,6 +1671,8 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Memory allocation error occurred\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "changelog memory allocation error occurred");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_SYSTEM_ERROR: /* NSPR error occurred: use PR_GetError for further info */
@@ -1694,15 +1701,20 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
break;
case CL5_PURGED_DATA: /* requested data has been purged */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "%s: Data required to update replica has been purged. "
+ "%s: Data required to update replica has been purged from the changelog. "
"The replica must be reinitialized.\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Data required to update replica has been purged from the changelog. "
+ "The replica must be reinitialized.");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_MISSING_DATA: /* data should be in the changelog, but is missing */
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Missing data encountered\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Changelog data is missing");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_UNKNOWN_ERROR: /* unclassified error */
@@ -1738,8 +1750,9 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
rc = repl5_inc_create_async_result_thread(rd);
if (rc) {
slapi_log_error (SLAPI_LOG_FATAL, repl_plugin_name, "%s: repl5_inc_run: "
- "repl5_tot_create_async_result_thread failed; error - %d\n",
+ "repl5_inc_create_async_result_thread failed; error - %d\n",
agmt_get_long_name(prp->agmt), rc);
+ agmt_set_last_update_status(prp->agmt, 0, rc, "Failed to create result thread");
return_value = UPDATE_FATAL_ERROR;
}
}
@@ -1898,6 +1911,8 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: Invalid parameter passed to cl5GetNextOperationToReplay\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Invalid parameter passed to cl5GetNextOperationToReplay");
return_value = UPDATE_FATAL_ERROR;
finished = 1;
break;
@@ -1912,6 +1927,8 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"%s: A database error occurred (cl5GetNextOperationToReplay)\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Database error occurred while getting the next operation to replay");
return_value = UPDATE_FATAL_ERROR;
finished = 1;
break;
@@ -1922,8 +1939,10 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
break;
case CL5_MEMORY_ERROR:
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "%s: A memory allocation error occurred (cl5GetNextOperationToRepla)\n",
+ "%s: A memory allocation error occurred (cl5GetNextOperationToReplay)\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_CL_ERROR,
+ "Memory allocation error occurred (cl5GetNextOperationToReplay)");
return_value = UPDATE_FATAL_ERROR;
break;
case CL5_IGNORE_OP:
@@ -1985,6 +2004,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
if (!replarea_sdn) {
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"send_updates: Unknown replication area due to agreement not found.");
+ agmt_set_last_update_status(prp->agmt, 0, -1, "Agreement is corrupted: missing suffix");
return_value = UPDATE_FATAL_ERROR;
} else {
replica_subentry_update(replarea_sdn, rid);
diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c
index ce27a8a86..ce6281a56 100644
--- a/ldap/servers/plugins/replication/repl5_protocol_util.c
+++ b/ldap/servers/plugins/replication/repl5_protocol_util.c
@@ -140,10 +140,18 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
crc = conn_connect(conn);
if (CONN_OPERATION_FAILED == crc)
{
+ int operation, error;
+ conn_get_error(conn, &operation, &error);
+ agmt_set_last_update_status(prp->agmt, error, NSDS50_REPL_CONN_ERROR,
+ "Problem connecting to replica");
return_value = ACQUIRE_TRANSIENT_ERROR;
}
else if (CONN_SSL_NOT_ENABLED == crc)
{
+ int operation, error;
+ conn_get_error(conn, &operation, &error);
+ agmt_set_last_update_status(prp->agmt, error, NSDS50_REPL_CONN_ERROR,
+ "Problem connecting to replica (SSL not enabled)");
return_value = ACQUIRE_FATAL_ERROR;
}
else
@@ -295,6 +303,9 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"an internal error occurred on the remote replica. "
"Replication is aborting.\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, extop_result,
+ "Failed to acquire replica: "
+ "Internal error occurred on the remote replica");
return_value = ACQUIRE_FATAL_ERROR;
break;
case NSDS50_REPL_PERMISSION_DENIED:
@@ -307,6 +318,11 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"supply replication updates to the replica. "
"Will retry later.\n",
agmt_get_long_name(prp->agmt), repl_binddn);
+ agmt_set_last_update_status(prp->agmt, 0, extop_result,
+ "Unable to acquire replica: permission denied. "
+ "The bind dn does not have permission to "
+ "supply replication updates to the replica. "
+ "Will retry later.");
slapi_ch_free((void **)&repl_binddn);
return_value = ACQUIRE_TRANSIENT_ERROR;
break;
@@ -321,6 +337,10 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"Replication is aborting.\n",
agmt_get_long_name(prp->agmt),
slapi_sdn_get_dn(repl_root));
+ agmt_set_last_update_status(prp->agmt, 0, extop_result,
+ "Unable to acquire replica: there is no "
+ "replicated area on the consumer server. "
+ "Replication is aborting.");
slapi_sdn_free(&repl_root);
return_value = ACQUIRE_FATAL_ERROR;
break;
@@ -342,6 +362,11 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"startReplicationRequest extended operation sent by the "
"supplier. Replication is aborting.\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, extop_result,
+ "Unable to acquire replica: "
+ "the consumer was unable to decode the "
+ "startReplicationRequest extended operation sent "
+ "by the supplier. Replication is aborting.");
return_value = ACQUIRE_FATAL_ERROR;
break;
case NSDS50_REPL_REPLICA_BUSY:
@@ -365,6 +390,10 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"by another supplier. Will try later\n",
agmt_get_long_name(prp->agmt));
}
+ agmt_set_last_update_status(prp->agmt, 0, extop_result,
+ "Unable to acquire replica: "
+ "the replica is currently being updated by another "
+ "supplier.");
return_value = ACQUIRE_REPLICA_BUSY;
break;
case NSDS50_REPL_LEGACY_CONSUMER:
@@ -373,6 +402,9 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"%s: Unable to acquire replica: the replica "
"is supplied by a legacy supplier. "
"Replication is aborting.\n", agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, extop_result,
+ "Unable to acquire replica: the replica is supplied "
+ "by a legacy supplier. Replication is aborting.");
return_value = ACQUIRE_FATAL_ERROR;
break;
case NSDS50_REPL_REPLICAID_ERROR:
@@ -382,6 +414,9 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"has the same Replica ID as this one. "
"Replication is aborting.\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, 0,
+ "Unable to aquire replica: the replica has the same "
+ "Replica ID as this one. Replication is aborting.");
return_value = ACQUIRE_FATAL_ERROR;
break;
case NSDS50_REPL_BACKOFF:
@@ -392,6 +427,9 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"the replica instructed us to go into "
"backoff mode. Will retry later.\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, extop_result,
+ "Unable to acquire replica: the replica instructed "
+ "us to go into backoff mode. Will retry later.");
return_value = ACQUIRE_TRANSIENT_ERROR;
break;
case NSDS50_REPL_REPLICA_READY:
@@ -450,6 +488,8 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
return_value = ACQUIRE_SUCCESS;
break;
default:
+ agmt_set_last_update_status(prp->agmt, 0, extop_result,
+ "Unable to acquire replica");
return_value = ACQUIRE_FATAL_ERROR;
}
}
@@ -461,6 +501,10 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"startReplication extended operation. "
"Replication is aborting.\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, NSDS50_REPL_DECODING_ERROR,
+ "Unable to parse the response to the "
+ "startReplication extended operation. "
+ "Replication is aborting.");
prp->last_acquire_response_code = NSDS50_REPL_INTERNAL_ERROR;
return_value = ACQUIRE_FATAL_ERROR;
}
@@ -477,6 +521,9 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"extended operation to consumer (%s). Will retry later.\n",
agmt_get_long_name(prp->agmt),
error ? ldap_err2string(error) : "unknown error");
+ agmt_set_last_update_status(prp->agmt, error, NSDS50_REPL_CONN_ERROR,
+ "Unable to receive the response for a startReplication "
+ "extended operation to consumer. Will retry later.");
}
}
else
@@ -486,6 +533,9 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
"%s: Unable to obtain current CSN. "
"Replication is aborting.\n",
agmt_get_long_name(prp->agmt));
+ agmt_set_last_update_status(prp->agmt, 0, 0,
+ "Unable to obtain current CSN. "
+ "Replication is aborting.");
return_value = ACQUIRE_FATAL_ERROR;
}
}
@@ -535,8 +585,8 @@ release_replica(Private_Repl_Protocol *prp)
PR_ASSERT(NULL != prp);
PR_ASSERT(NULL != prp->conn);
- if (!prp->replica_acquired)
- return;
+ if (!prp->replica_acquired)
+ return;
replarea_sdn = agmt_get_replarea(prp->agmt);
payload = NSDS50EndReplicationRequest_new((char *)slapi_sdn_get_dn(replarea_sdn)); /* XXXggood had to cast away const */
@@ -650,9 +700,14 @@ protocol_response2string (int response)
case NSDS50_REPL_BELOW_PURGEPOINT: return "csn below purge point";
case NSDS50_REPL_INTERNAL_ERROR: return "internal error";
case NSDS50_REPL_REPLICA_RELEASE_SUCCEEDED: return "replica released";
- case NSDS50_REPL_LEGACY_CONSUMER: return "replica is a legacy consumer";
- case NSDS50_REPL_REPLICAID_ERROR: return "duplicate replica ID detected";
- case NSDS50_REPL_UPTODATE: return "no change to send";
+ case NSDS50_REPL_LEGACY_CONSUMER: return "replica is a legacy consumer";
+ case NSDS50_REPL_REPLICAID_ERROR: return "duplicate replica ID detected";
+ case NSDS50_REPL_UPTODATE: return "no change to send";
+ case NSDS50_REPL_CL_ERROR: return "changelog error";
+ case NSDS50_REPL_CONN_ERROR: return "connection error";
+ case NSDS50_REPL_CONN_TIMEOUT: return "connection timeout";
+ case NSDS50_REPL_TRANSIENT_ERROR: return "transient error";
+ case NSDS50_REPL_RUV_ERROR: return "RUV error";
default: return "unknown error";
}
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 011e4caab..59e529813 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -639,8 +639,8 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
}
done:
- if (mtnode_ext->replica)
- object_release (mtnode_ext->replica);
+ if (mtnode_ext->replica)
+ object_release (mtnode_ext->replica);
/* slapi_ch_free accepts NULL pointer */
slapi_ch_free_string(&replica_root);
diff --git a/ldap/servers/plugins/replication/repl5_total.c b/ldap/servers/plugins/replication/repl5_total.c
index 0512dfa65..dcb7af548 100644
--- a/ldap/servers/plugins/replication/repl5_total.c
+++ b/ldap/servers/plugins/replication/repl5_total.c
@@ -533,8 +533,9 @@ my_ber_scanf_value(BerElement *ber, Slapi_Value **value, PRBool *deleted)
goto loser;
}
- if (attrval)
- ber_bvfree(attrval);
+ if (attrval)
+ ber_bvfree(attrval);
+
return 0;
loser:
| 0 |
750fa2c4c2b3a570ffbbdb5b3e8aabf95a28c597
|
389ds/389-ds-base
|
Resolves: bug 253047
Bug Description: Does not build on Fedora 8
Fix Description: If using the O_CREAT flag with open(), the file mode must also be given. Also, the bdb calls to use ->open() must use parentheses around the function pointer access e.g. (DB->open)(args...) instead of just DB->open(args).
Platforms tested: RHEL4, Fedora 8
Flag Day: no
Doc impact: no
|
commit 750fa2c4c2b3a570ffbbdb5b3e8aabf95a28c597
Author: Rich Megginson <[email protected]>
Date: Thu Aug 16 19:28:58 2007 +0000
Resolves: bug 253047
Bug Description: Does not build on Fedora 8
Fix Description: If using the O_CREAT flag with open(), the file mode must also be given. Also, the bdb calls to use ->open() must use parentheses around the function pointer access e.g. (DB->open)(args...) instead of just DB->open(args).
Platforms tested: RHEL4, Fedora 8
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/back-ldbm/dbhelp.c b/ldap/servers/slapd/back-ldbm/dbhelp.c
index ca69f1647..0a96df8fc 100644
--- a/ldap/servers/slapd/back-ldbm/dbhelp.c
+++ b/ldap/servers/slapd/back-ldbm/dbhelp.c
@@ -74,7 +74,7 @@ static int dblayer_copy_file_keybykey(DB_ENV *env, char *source_file_name, char
LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_keybykey, Create error %d: %s\n", retval, db_strerror(retval), 0);
goto error;
}
- retval = source_file->open(source_file, NULL, source_file_name, NULL, DB_UNKNOWN, DB_RDONLY, 0);
+ retval = (source_file->open)(source_file, NULL, source_file_name, NULL, DB_UNKNOWN, DB_RDONLY, 0);
if (retval) {
LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_keybykey, Open error %d: %s\n", retval, db_strerror(retval), 0);
goto error;
@@ -113,7 +113,7 @@ static int dblayer_copy_file_keybykey(DB_ENV *env, char *source_file_name, char
LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_keybykey, set_pagesize error %d: %s\n", retval, db_strerror(retval), 0);
goto error;
}
- retval = destination_file->open(destination_file, NULL, destination_file_name, NULL, dbtype, DB_CREATE | DB_EXCL, mode);
+ retval = (destination_file->open)(destination_file, NULL, destination_file_name, NULL, dbtype, DB_CREATE | DB_EXCL, mode);
if (retval) {
LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_keybykey, Open error %d: %s\n", retval, db_strerror(retval), 0);
goto error;
@@ -260,7 +260,7 @@ int dblayer_make_private_recovery_env(char *db_home_dir, dblayer_private *priv,
}
dblayer_set_env_debugging(ret_env, priv);
- retval = ret_env->open(ret_env,db_home_dir, DB_INIT_TXN | DB_RECOVER_FATAL | DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE,0);
+ retval = (ret_env->open)(ret_env,db_home_dir, DB_INIT_TXN | DB_RECOVER_FATAL | DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE,0);
if (0 == retval) {
*env = ret_env;
} else {
@@ -292,7 +292,7 @@ int dblayer_make_private_simple_env(char *db_home_dir, DB_ENV **env)
goto error;
}
- retval = ret_env->open(ret_env,db_home_dir,DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE,0);
+ retval = (ret_env->open)(ret_env,db_home_dir,DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE,0);
if (0 == retval) {
*env = ret_env;
} else {
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index a7320d4e3..f06314685 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -102,11 +102,11 @@
{ \
if (((oflags) & DB_INIT_TXN) && ((oflags) & DB_INIT_LOG)) \
{ \
- (rval) = (db)->open((db), (txnid), (file), (database), (type), (flags)|DB_AUTO_COMMIT, (mode)); \
+ (rval) = ((db)->open)((db), (txnid), (file), (database), (type), (flags)|DB_AUTO_COMMIT, (mode)); \
} \
else \
{ \
- (rval) = (db)->open((db), (txnid), (file), (database), (type), (flags), (mode)); \
+ (rval) = ((db)->open)((db), (txnid), (file), (database), (type), (flags), (mode)); \
} \
}
/* 608145: db4.1 and newer does not require exclusive lock for checkpointing
@@ -1556,7 +1556,7 @@ int dblayer_start(struct ldbminfo *li, int dbmode)
}
}
- return_value = pEnv->dblayer_DB_ENV->open(
+ return_value = (pEnv->dblayer_DB_ENV->open)(
pEnv->dblayer_DB_ENV,
region_dir,
recover_flags,
@@ -1612,7 +1612,7 @@ int dblayer_start(struct ldbminfo *li, int dbmode)
if (!((DBLAYER_IMPORT_MODE|DBLAYER_INDEX_MODE) & dbmode))
{
pEnv->dblayer_openflags = open_flags;
- return_value = pEnv->dblayer_DB_ENV->open(
+ return_value = (pEnv->dblayer_DB_ENV->open)(
pEnv->dblayer_DB_ENV,
region_dir,
open_flags,
@@ -1940,7 +1940,7 @@ int dblayer_instance_start(backend *be, int mode)
mypEnv->dblayer_openflags = oflags;
data_directories[0] = inst->inst_parent_dir_name;
dblayer_set_data_dir(priv, mypEnv, data_directories);
- return_value = mypEnv->dblayer_DB_ENV->open(mypEnv->dblayer_DB_ENV,
+ return_value = (mypEnv->dblayer_DB_ENV->open)(mypEnv->dblayer_DB_ENV,
inst_dirp,
oflags,
priv->dblayer_file_mode);
@@ -2220,7 +2220,7 @@ int dblayer_get_aux_id2entry(backend *be, DB **ppDB, DB_ENV **ppEnv)
mypEnv->dblayer_openflags = envflags;
data_directories[0] = inst->inst_parent_dir_name;
dblayer_set_data_dir(priv, mypEnv, data_directories);
- rval = mypEnv->dblayer_DB_ENV->open(mypEnv->dblayer_DB_ENV,
+ rval = (mypEnv->dblayer_DB_ENV->open)(mypEnv->dblayer_DB_ENV,
priv->dblayer_home_directory, envflags, priv->dblayer_file_mode);
if (rval != 0)
{
diff --git a/ldap/servers/slapd/protect_db.c b/ldap/servers/slapd/protect_db.c
index 85d30be76..e234450a1 100644
--- a/ldap/servers/slapd/protect_db.c
+++ b/ldap/servers/slapd/protect_db.c
@@ -116,7 +116,7 @@ grab_lockfile()
t.tv_sec = 0;
t.tv_usec = WAIT_TIME * 1000;
for(x = 0; x < NUM_TRIES; x++) {
- if ((fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL)) != -1) {
+ if ((fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL, 0664)) != -1) {
/* Got the lock */
write(fd, (void *) &pid, sizeof(pid_t));
close(fd);
| 0 |
5129c27a4ee9263caec5a6643e243bff3619fa88
|
389ds/389-ds-base
|
Issue 5098 - Multiple issues around replication and CI test test_online_reinit_may_hang (#5109)
|
commit 5129c27a4ee9263caec5a6643e243bff3619fa88
Author: progier389 <[email protected]>
Date: Thu Jan 20 12:22:28 2022 +0100
Issue 5098 - Multiple issues around replication and CI test test_online_reinit_may_hang (#5109)
diff --git a/dirsrvtests/tests/suites/replication/regression_m2_test.py b/dirsrvtests/tests/suites/replication/regression_m2_test.py
index 52d2bde50..efc979a8b 100644
--- a/dirsrvtests/tests/suites/replication/regression_m2_test.py
+++ b/dirsrvtests/tests/suites/replication/regression_m2_test.py
@@ -845,12 +845,14 @@ def test_online_reinit_may_hang(topo_with_sigkill):
1. Export the database
2. Move RUV entry to the top in the ldif file
3. Import the ldif file
- 4. Online replica initializaton
+ 4. Check that replication is still working
+ 5. Online replica initializaton
:expectedresults:
1. Ldif file should be created successfully
2. RUV entry should be on top in the ldif file
3. Import should be successful
- 4. Server should not hang and consume 100% CPU
+ 4. Replication should work
+ 5. Server should not hang and consume 100% CPU
"""
M1 = topo_with_sigkill.ms["supplier1"]
M2 = topo_with_sigkill.ms["supplier2"]
@@ -863,6 +865,11 @@ def test_online_reinit_may_hang(topo_with_sigkill):
M1.ldif2db(DEFAULT_BENAME, None, None, None, ldif_file)
M1.start()
# After this server may hang
+ # Exporting idle server with replication data and reimporting
+ # should not break replication (Unless we hit issue 5098)
+ # So let check that replication is still working.
+ repl = ReplicationManager(DEFAULT_SUFFIX)
+ repl.test_replication_topology(topo_with_sigkill)
agmt = Agreements(M1).list()[0]
agmt.begin_reinit()
(done, error) = agmt.wait_reinit()
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 9ea1ce3d9..fc0672c18 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -1714,7 +1714,7 @@ replica_check_for_data_reload(Replica *r, void *arg __attribute__((unused)))
return -1;
}
- if (upper_bound_ruv) {
+ if (upper_bound_ruv && ruv_replica_count(upper_bound_ruv) > 0) {
ruv_obj = replica_get_ruv(r);
r_ruv = object_get_data(ruv_obj);
PR_ASSERT(r_ruv);
diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import_threads.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import_threads.c
index 8ef9752f4..b9145d1c5 100644
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import_threads.c
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import_threads.c
@@ -2576,7 +2576,7 @@ bdb_import_foreman(void *param)
*/
#define RUVRDN SLAPI_ATTR_UNIQUEID "=" RUV_STORAGE_ENTRY_UNIQUEID
if (!slapi_be_issuffix(inst->inst_be, backentry_get_sdn(fi->entry)) &&
- strcasecmp(backentry_get_ndn(fi->entry), RUVRDN) /* NOT nsuniqueid=ffffffff-... */) {
+ strcasecmp(slapi_entry_get_nrdn_const(fi->entry->ep_entry), RUVRDN) /* NOT nsuniqueid=ffffffff-... */) {
import_log_notice(job, SLAPI_LOG_WARNING, "bdb_import_foreman",
"Skipping entry \"%s\" which has no parent, ending at line %d "
"of file \"%s\"",
| 0 |
1ab0a0924dbca3c40ed15ccb95999a9811712aac
|
389ds/389-ds-base
|
Issue 5939 - During an update, if the target entry is reverted in the entry cache, the server should not retry to lock it (#6007)
Bug description:
During an update if an BETXN plugin fails the full TXN is aborted and the DB
returns to the previous state.
However potential internal updates, done by BETXN plugins, are also applied
on the entry cache.
Even if the TXN is aborted some entries in the entry cache are left in a state
that does not reflect the DB state.
The fix https://pagure.io/389-ds-base/issue/50260 "reverts" those
entries, setting their state to INVALID.
A problem is that reverted entries stay in the entry cache, until refcnt is 0.
During that period, an update targeting that entry fails to retrieve the
entry from the entry cache and fails to add it again as it already exist
the entry.
The update iterates 1000 times, trying to read the entry and to fetch it
from DB.
This is a pure waste as the reverted entry stays too long.
The signature of this issue is a message in the error log: "Retry count exceeded"
Fix description:
The fix consiste in the loops (fetch on DN or NSUNIQUEID) to test if the
entry state is INVALID.
In such case it aborts the loop and return a failure.
relates: #5939
Reviewed by: Pierre Rogier, Simon Pichugin (Thanks !!)
|
commit 1ab0a0924dbca3c40ed15ccb95999a9811712aac
Author: tbordaz <[email protected]>
Date: Tue Dec 12 12:57:31 2023 +0100
Issue 5939 - During an update, if the target entry is reverted in the entry cache, the server should not retry to lock it (#6007)
Bug description:
During an update if an BETXN plugin fails the full TXN is aborted and the DB
returns to the previous state.
However potential internal updates, done by BETXN plugins, are also applied
on the entry cache.
Even if the TXN is aborted some entries in the entry cache are left in a state
that does not reflect the DB state.
The fix https://pagure.io/389-ds-base/issue/50260 "reverts" those
entries, setting their state to INVALID.
A problem is that reverted entries stay in the entry cache, until refcnt is 0.
During that period, an update targeting that entry fails to retrieve the
entry from the entry cache and fails to add it again as it already exist
the entry.
The update iterates 1000 times, trying to read the entry and to fetch it
from DB.
This is a pure waste as the reverted entry stays too long.
The signature of this issue is a message in the error log: "Retry count exceeded"
Fix description:
The fix consiste in the loops (fetch on DN or NSUNIQUEID) to test if the
entry state is INVALID.
In such case it aborts the loop and return a failure.
relates: #5939
Reviewed by: Pierre Rogier, Simon Pichugin (Thanks !!)
diff --git a/dirsrvtests/tests/suites/betxns/betxn_test.py b/dirsrvtests/tests/suites/betxns/betxn_test.py
index d40fbafd7..76850a992 100644
--- a/dirsrvtests/tests/suites/betxns/betxn_test.py
+++ b/dirsrvtests/tests/suites/betxns/betxn_test.py
@@ -445,6 +445,92 @@ def test_revert_cache(topology_st, request):
request.addfinalizer(fin)
[email protected](max_runs=2, min_passes=1)
+def test_revert_cache_noloop(topology_st, request):
+ """Tests that when an entry is reverted, if an update
+ hit the reverted entry then the retry loop is aborted
+ and the update gets err=51
+ NOTE: this test requires a dynamic so that the two updates
+ occurs about the same time. If the test becomes fragile it is
+ okay to make it flaky
+
+ :id: 88ef0ba5-8c66-49e6-99c9-9e3f6183917f
+
+ :setup: Standalone instance
+
+ :steps:
+ 1. Create a user account (with a homeDirectory)
+ 2. Remove the error log file
+ 3. Configure memberof to trigger a failure
+ 4. Do in a loop 3 parallel updates (they will fail in
+ memberof plugin) and an updated on the reverted entry
+ 5. Check that error log does contain entry cache reversion
+
+ :expectedresults:
+ 1. Succeeds
+ 2. Success
+ 3. Succeeds
+ 4. Succeeds
+ 5. Succeeds
+ """
+ # Create an test user entry
+ log.info('Create a user without nsMemberOF objectclass')
+ try:
+ users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX, rdn='ou=people')
+ user = users.create_test_user()
+ user.replace('objectclass', ['top', 'account', 'person', 'inetorgperson', 'posixAccount', 'organizationalPerson', 'nsAccount'])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to create test user: error ' + e.args[0]['desc'])
+ assert False
+
+ # Remove the current error log file
+ topology_st.standalone.stop()
+ lpath = topology_st.standalone.ds_error_log._get_log_path()
+ os.unlink(lpath)
+ topology_st.standalone.start()
+
+ # Prepare memberof so that it will fail during a next update
+ # If memberof plugin can not add 'memberof' to the
+ # member entry, it retries after adding
+ # 'memberOfAutoAddOC' objectclass to the member.
+ # If it fails again the plugin fails with 'object
+ # violation'
+ # To trigger this failure, set 'memberOfAutoAddOC'
+ # to a value that does *not* allow 'memberof' attribute
+ memberof = MemberOfPlugin(topology_st.standalone)
+ memberof.enable()
+ memberof.replace('memberOfAutoAddOC', 'account')
+ memberof.replace('memberofentryscope', DEFAULT_SUFFIX)
+ topology_st.standalone.restart()
+
+ for i in range(50):
+ # Try to add the user to demo_group
+ # It should fail because user entry has not 'nsmemberof' objectclass
+ # As this is a BETXN plugin that fails it should revert the entry cache
+ try:
+ GROUP_DN = "cn=demo_group,ou=groups," + DEFAULT_SUFFIX
+ topology_st.standalone.modify(GROUP_DN,
+ [(ldap.MOD_REPLACE, 'member', ensure_bytes(user.dn))])
+ topology_st.standalone.modify(GROUP_DN,
+ [(ldap.MOD_REPLACE, 'member', ensure_bytes(user.dn))])
+ topology_st.standalone.modify(GROUP_DN,
+ [(ldap.MOD_REPLACE, 'member', ensure_bytes(user.dn))])
+ except ldap.OBJECT_CLASS_VIOLATION:
+ pass
+
+ user.replace('cn', ['new_value'])
+
+ # Check that both a betxn failed and a reverted entry was
+ # detected during an update
+ assert topology_st.standalone.ds_error_log.match('.*WARN - flush_hash - Upon BETXN callback failure, entry cache is flushed during.*')
+ assert topology_st.standalone.ds_error_log.match('.*cache_is_reverted_entry - Entry reverted.*')
+
+ def fin():
+ user.delete()
+ memberof = MemberOfPlugin(topology_st.standalone)
+ memberof.replace('memberOfAutoAddOC', 'nsmemberof')
+
+ request.addfinalizer(fin)
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
index 604c0d77d..d036af049 100644
--- a/ldap/servers/slapd/back-ldbm/cache.c
+++ b/ldap/servers/slapd/back-ldbm/cache.c
@@ -1744,6 +1744,25 @@ cache_lock_entry(struct cache *cache, struct backentry *e)
return 0;
}
+int
+cache_is_reverted_entry(struct cache *cache, struct backentry *e)
+{
+ struct backentry *dummy_e;
+
+ cache_lock(cache);
+ if (find_hash(cache->c_idtable, &e->ep_id, sizeof(ID), (void **)&dummy_e)) {
+ if (dummy_e->ep_state & ENTRY_STATE_INVALID) {
+ slapi_log_err(SLAPI_LOG_WARNING, "cache_is_reverted_entry", "Entry reverted = %d (0x%lX) [entry: 0x%lX] refcnt=%d\n",
+ dummy_e->ep_state,
+ pthread_self(),
+ dummy_e, dummy_e->ep_refcnt);
+ cache_unlock(cache);
+ return 1;
+ }
+ }
+ cache_unlock(cache);
+ return 0;
+}
/* the opposite of above */
void
cache_unlock_entry(struct cache *cache __attribute__((unused)), struct backentry *e)
diff --git a/ldap/servers/slapd/back-ldbm/findentry.c b/ldap/servers/slapd/back-ldbm/findentry.c
index 58f484303..7bb56ef2c 100644
--- a/ldap/servers/slapd/back-ldbm/findentry.c
+++ b/ldap/servers/slapd/back-ldbm/findentry.c
@@ -98,6 +98,7 @@ find_entry_internal_dn(
size_t tries = 0;
int isroot = 0;
int op_type;
+ int reverted_entry = 0;
/* get the managedsait ldap message control */
slapi_pblock_get(pb, SLAPI_MANAGEDSAIT, &managedsait);
@@ -141,12 +142,20 @@ find_entry_internal_dn(
*/
slapi_log_err(SLAPI_LOG_ARGS, "find_entry_internal_dn",
" Retrying (%s)\n", slapi_sdn_get_dn(sdn));
+ if (cache_is_reverted_entry(&inst->inst_cache, e)) {
+ reverted_entry = 1;
+ break;
+ }
CACHE_RETURN(&inst->inst_cache, &e);
tries++;
}
if (tries >= LDBM_CACHE_RETRY_COUNT) {
slapi_log_err(SLAPI_LOG_ERR, "find_entry_internal_dn", "Retry count exceeded (%s)\n", slapi_sdn_get_dn(sdn));
}
+ if (reverted_entry) {
+ slapi_send_ldap_result(pb, LDAP_BUSY, NULL, "target entry busy because of a canceled operation", 0, NULL);
+ return (NULL);
+ }
/*
* there is no such entry in this server. see how far we
* can match, and check if that entry contains a referral.
@@ -262,6 +271,7 @@ find_entry_internal_uniqueid(
struct backentry *e;
int err;
size_t tries = 0;
+ int reverted_entry = 0;
while ((tries < LDBM_CACHE_RETRY_COUNT) &&
(e = uniqueid2entry(be, uniqueid, txn, &err)) != NULL) {
@@ -283,6 +293,10 @@ find_entry_internal_uniqueid(
*/
slapi_log_err(SLAPI_LOG_ARGS,
" find_entry_internal_uniqueid", "Retrying; uniqueid = (%s)\n", uniqueid);
+ if (cache_is_reverted_entry(&inst->inst_cache, e)) {
+ reverted_entry = 1;
+ break;
+ }
CACHE_RETURN(&inst->inst_cache, &e);
tries++;
}
@@ -292,9 +306,14 @@ find_entry_internal_uniqueid(
uniqueid);
}
- /* entry not found */
- slapi_send_ldap_result(pb, (0 == err || DBI_RC_NOTFOUND == err) ? LDAP_NO_SUCH_OBJECT : LDAP_OPERATIONS_ERROR, NULL /* matched */, NULL,
- 0, NULL);
+ if (reverted_entry) {
+ slapi_send_ldap_result(pb, LDAP_BUSY, NULL, "target entry busy because of a canceled operation", 0, NULL);
+ return (NULL);
+ } else {
+ /* entry not found */
+ slapi_send_ldap_result(pb, (0 == err || DBI_RC_NOTFOUND == err) ? LDAP_NO_SUCH_OBJECT : LDAP_OPERATIONS_ERROR, NULL /* matched */, NULL,
+ 0, NULL);
+ }
slapi_log_err(SLAPI_LOG_TRACE,
"find_entry_internal_uniqueid", "<= not found; uniqueid = (%s)\n",
uniqueid);
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 581b9b545..c6028e00f 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -61,6 +61,7 @@ int cache_replace(struct cache *cache, void *oldptr, void *newptr);
int cache_has_otherref(struct cache *cache, void *bep);
int cache_is_in_cache(struct cache *cache, void *ptr);
void revert_cache(ldbm_instance *inst, struct timespec *start_time);
+int cache_is_reverted_entry(struct cache *cache, struct backentry *e);
#ifdef CACHE_DEBUG
void check_entry_cache(struct cache *cache, struct backentry *e);
| 0 |
38d4ccbe99fa7bcbb9b41b06453a5fe3d7f3eb3d
|
389ds/389-ds-base
|
Resolves: bug 479253
Bug Description: Configuring Server to Server GSSAPI over SSL - Need better Error Message
Reviewed by: nkinder (Thanks!)
Fix Description: If the user attempts to set the bind mech to GSSAPI, and a secure transport is being used, the server will return LDAP_UNWILLING_TO_PERFORM and provide a useful error message. Same if GSSAPI is being used and the user attempts to use a secure transport.
Platforms tested: RHEL5
Flag Day: no
Doc impact: no
|
commit 38d4ccbe99fa7bcbb9b41b06453a5fe3d7f3eb3d
Author: Rich Megginson <[email protected]>
Date: Tue Jan 27 22:37:18 2009 +0000
Resolves: bug 479253
Bug Description: Configuring Server to Server GSSAPI over SSL - Need better Error Message
Reviewed by: nkinder (Thanks!)
Fix Description: If the user attempts to set the bind mech to GSSAPI, and a secure transport is being used, the server will return LDAP_UNWILLING_TO_PERFORM and provide a useful error message. Same if GSSAPI is being used and the user attempts to use a secure transport.
Platforms tested: RHEL5
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index 0e5dda257..19c05baba 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -722,7 +722,18 @@ static int cb_instance_hosturl_set(void *arg, void *value, char *errorbuf, int p
return(LDAP_INVALID_SYNTAX);
}
- if (apply) {
+ if (ludp && (ludp->lud_options & LDAP_URL_OPT_SECURE) && inst && inst->rwl_config_lock) {
+ int isgss = 0;
+ PR_RWLock_Rlock(inst->rwl_config_lock);
+ isgss = inst->pool->mech && !PL_strcasecmp(inst->pool->mech, "GSSAPI");
+ PR_RWLock_Unlock(inst->rwl_config_lock);
+ if (isgss) {
+ PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Cannot use LDAPS if using GSSAPI - please change the %s to use something other than GSSAPI before changing connection to use LDAPS", CB_CONFIG_BINDMECH);
+ rc = LDAP_UNWILLING_TO_PERFORM;
+ }
+ }
+
+ if ((LDAP_SUCCESS == rc) && apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
@@ -1346,7 +1357,18 @@ static int cb_instance_starttls_set(void *arg, void *value, char *errorbuf, int
cb_backend_instance * inst=(cb_backend_instance *) arg;
int rc = LDAP_SUCCESS;
- if (apply) {
+ if (value && inst && inst->rwl_config_lock) {
+ int isgss = 0;
+ PR_RWLock_Rlock(inst->rwl_config_lock);
+ isgss = inst->pool->mech && !PL_strcasecmp(inst->pool->mech, "GSSAPI");
+ PR_RWLock_Unlock(inst->rwl_config_lock);
+ if (isgss) {
+ PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Cannot use startTLS if using GSSAPI - please change the %s to use something other than GSSAPI before changing connection to use startTLS", CB_CONFIG_BINDMECH);
+ rc = LDAP_UNWILLING_TO_PERFORM;
+ }
+ }
+
+ if ((LDAP_SUCCESS == rc) && apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
inst->pool->starttls=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
@@ -1374,7 +1396,18 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int
cb_backend_instance * inst=(cb_backend_instance *) arg;
int rc=LDAP_SUCCESS;
- if (apply) {
+ if (value && !PL_strcasecmp((char *) value, "GSSAPI") && inst && inst->rwl_config_lock) {
+ int secure = 0;
+ PR_RWLock_Rlock(inst->rwl_config_lock);
+ secure = inst->pool->secure || inst->pool->starttls;
+ PR_RWLock_Unlock(inst->rwl_config_lock);
+ if (secure) {
+ PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Cannot use SASL/GSSAPI if using SSL or TLS - please change the connection to use no security before changing %s to use GSSAPI", CB_CONFIG_BINDMECH);
+ rc = LDAP_UNWILLING_TO_PERFORM;
+ }
+ }
+
+ if ((LDAP_SUCCESS == rc) && apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
if (( phase != CB_CONFIG_PHASE_INITIALIZATION ) &&
( phase != CB_CONFIG_PHASE_STARTUP )) {
diff --git a/ldap/servers/plugins/replication/repl5_agmtlist.c b/ldap/servers/plugins/replication/repl5_agmtlist.c
index 6793903c7..510757b6b 100644
--- a/ldap/servers/plugins/replication/repl5_agmtlist.c
+++ b/ldap/servers/plugins/replication/repl5_agmtlist.c
@@ -48,6 +48,7 @@
*/
#include "repl5.h"
+#include <plstr.h>
#define AGMT_CONFIG_BASE "cn=mapping tree, cn=config"
#define CONFIG_FILTER "(objectclass=nsds5replicationagreement)"
@@ -373,8 +374,22 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
else if (slapi_attr_types_equivalent(mods[i]->mod_type,
type_nsds5TransportInfo))
{
+ /* do not allow GSSAPI if using TLS/SSL */
+ char *tmpstr = slapi_entry_attr_get_charptr(e, type_nsds5TransportInfo);
+ /* if some value was set, and the value was not set to LDAP (i.e. was set to use security),
+ and we're already using gssapi, deny the change */
+ if (tmpstr && PL_strcasecmp(tmpstr, "LDAP") && (BINDMETHOD_SASL_GSSAPI == agmt_get_bindmethod(agmt)))
+ {
+ /* Report the error to the client */
+ PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE, "Cannot use SASL/GSSAPI if using SSL or TLS - please change %s to a value other than SASL/GSSAPI before changing %s to use security", type_nsds5ReplicaBindMethod, type_nsds5TransportInfo);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "agmtlist_modify_callback: "
+ "%s", errortext);
+
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ rc = SLAPI_DSE_CALLBACK_ERROR;
+ }
/* New Transport info */
- if (agmt_set_transportinfo_from_entry(agmt, e) != 0)
+ else if (agmt_set_transportinfo_from_entry(agmt, e) != 0)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: "
"failed to update transport info for agreement %s\n",
@@ -386,8 +401,19 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
else if (slapi_attr_types_equivalent(mods[i]->mod_type,
type_nsds5ReplicaBindMethod))
{
- /* New replica bind method */
- if (agmt_set_bind_method_from_entry(agmt, e) != 0)
+ /* do not allow GSSAPI if using TLS/SSL */
+ char *tmpstr = slapi_entry_attr_get_charptr(e, type_nsds5ReplicaBindMethod);
+ if (tmpstr && !PL_strcasecmp(tmpstr, "SASL/GSSAPI") && agmt_get_transport_flags(agmt))
+ {
+ /* Report the error to the client */
+ PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE, "Cannot use SASL/GSSAPI if using SSL or TLS - please change %s to LDAP before changing %s to use SASL/GSSAPI", type_nsds5TransportInfo, type_nsds5ReplicaBindMethod);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "agmtlist_modify_callback: "
+ "%s", errortext);
+
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ rc = SLAPI_DSE_CALLBACK_ERROR;
+ }
+ else if (agmt_set_bind_method_from_entry(agmt, e) != 0)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: "
"failed to update bind method for agreement %s\n",
@@ -395,6 +421,7 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
*returncode = LDAP_OPERATIONS_ERROR;
rc = SLAPI_DSE_CALLBACK_ERROR;
}
+ slapi_ch_free_string(&tmpstr);
}
else if (slapi_attr_types_equivalent(mods[i]->mod_type,
type_nsds5ReplicatedAttributeList))
| 0 |
441d5abaf56385bf010b66df4caab099b7a6349c
|
389ds/389-ds-base
|
Issue 49324 - idl_new report index name in error conditions
Description: Add the index attribute name to error messages
relates: https://pagure.io/389-ds-base/issue/49324
Reviewed by: firstyear & tbordaz (Thanks!!)
|
commit 441d5abaf56385bf010b66df4caab099b7a6349c
Author: Mark Reynolds <[email protected]>
Date: Fri Aug 23 14:15:05 2019 -0400
Issue 49324 - idl_new report index name in error conditions
Description: Add the index attribute name to error messages
relates: https://pagure.io/389-ds-base/issue/49324
Reviewed by: firstyear & tbordaz (Thanks!!)
diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c
index 50c7ba4c6..dd0d9fcfc 100644
--- a/ldap/servers/slapd/back-ldbm/idl_new.c
+++ b/ldap/servers/slapd/back-ldbm/idl_new.c
@@ -146,6 +146,8 @@ idl_new_fetch(
back_txn s_txn;
struct ldbminfo *li = (struct ldbminfo *)be->be_database->plg_private;
+ PR_ASSERT(a && a->ai_type);
+
if (NEW_IDL_NOOP == *flag_err) {
*flag_err = 0;
return NULL;
@@ -186,10 +188,11 @@ idl_new_fetch(
if (0 != ret) {
if (DB_NOTFOUND != ret) {
if (ret == DB_BUFFER_SMALL) {
- slapi_log_err(SLAPI_LOG_ERR, "idl_new_fetch", "Database index is corrupt; "
- "data item for key %s is too large for our buffer "
- "(need=%d actual=%d)\n",
- (char *)key.data, data.size, data.ulen);
+ slapi_log_err(SLAPI_LOG_ERR, "idl_new_fetch",
+ "Database index is corrupt (attribute: %s); "
+ "data item for key %s is too large for our buffer "
+ "(need=%d actual=%d)\n",
+ a->ai_type, (char *)key.data, data.size, data.ulen);
}
ldbm_nasty("idl_new_fetch", filename, 2, ret);
}
@@ -214,22 +217,23 @@ idl_new_fetch(
if (*(int32_t *)ptr < -1) {
slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch",
- "DB_MULTIPLE buffer is corrupt; next offset [%d] is less than zero\n",
- *(int32_t *)ptr);
+ "DB_MULTIPLE buffer is corrupt; (attribute: %s) next offset [%d] is less than zero\n",
+ a->ai_type, *(int32_t *)ptr);
/* retry the read */
break;
}
if (dataret.size != sizeof(ID)) {
- slapi_log_err(SLAPI_LOG_ERR, "idl_new_fetch", "Database index is corrupt; "
- "key %s has a data item with the wrong size (%d)\n",
- (char *)key.data, dataret.size);
+ slapi_log_err(SLAPI_LOG_ERR, "idl_new_fetch",
+ "Database index is corrupt; "
+ "(attribute: %s) key %s has a data item with the wrong size (%d)\n",
+ a->ai_type, (char *)key.data, dataret.size);
goto error;
}
memcpy(&id, dataret.data, sizeof(ID));
if (id == lastid) { /* dup */
- slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "Detected duplicate id "
- "%d due to DB_MULTIPLE error - skipping\n",
- id);
+ slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch",
+ "Detected duplicate id %d due to DB_MULTIPLE error - skipping (attribute: %s)\n",
+ id, a->ai_type);
continue; /* get next one */
}
/* note the last id read to check for dups */
@@ -237,7 +241,8 @@ idl_new_fetch(
/* we got another ID, add it to our IDL */
idl_rc = idl_append_extend(&idl, id);
if (idl_rc) {
- slapi_log_err(SLAPI_LOG_ERR, "idl_new_fetch", "Unable to extend id list (err=%d)\n", idl_rc);
+ slapi_log_err(SLAPI_LOG_ERR, "idl_new_fetch", "Unable to extend id list for attribute (%s) (err=%d)\n",
+ a->ai_type, idl_rc);
idl_free(&idl);
goto error;
}
@@ -245,7 +250,8 @@ idl_new_fetch(
count++;
}
- slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "bulk fetch buffer nids=%" PRIu64 "\n", count);
+ slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "bulk fetch buffer nids=%" PRIu64 " attribute: %s\n",
+ count, a->ai_type);
#if defined(DB_ALLIDS_ON_READ)
/* enforce the allids read limit */
if ((NEW_IDL_NO_ALLID != *flag_err) && (NULL != a) &&
@@ -277,11 +283,11 @@ idl_new_fetch(
if (idl != NULL && idl->b_nids == 1 && idl->b_ids[0] == ALLID) {
idl_free(&idl);
idl = idl_allids(be);
- slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "%s returns allids\n",
- (char *)key.data);
+ slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "%s returns allids (attribute: %s)\n",
+ (char *)key.data, a->ai_type);
} else {
- slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "%s returns nids=%lu\n",
- (char *)key.data, (u_long)IDL_NIDS(idl));
+ slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "%s returns nids=%lu (attribute: %s)\n",
+ (char *)key.data, (u_long)IDL_NIDS(idl), a->ai_type);
}
error:
| 0 |
fe6f8f219bf1769f4daff8b3b1d31163a70eaa46
|
389ds/389-ds-base
|
Bug 521088 - DNA should check ACLs before getting a value from the range
The DNA plug-in gets a value from the range at the pre-op stage, which
means that the operation can fail at a later point. This results in
a value being used up from the range even though it is never actually
used within an entry.
This patch makes DNA check the ACIs to see if the incoming operation
is allowed before allocating a value from the range. If the ACIs
result in an operation that will be rejected, we skip allocation
which keeps us from wasting a value from the range.
|
commit fe6f8f219bf1769f4daff8b3b1d31163a70eaa46
Author: Nathan Kinder <[email protected]>
Date: Mon Nov 1 12:41:05 2010 -0700
Bug 521088 - DNA should check ACLs before getting a value from the range
The DNA plug-in gets a value from the range at the pre-op stage, which
means that the operation can fail at a later point. This results in
a value being used up from the range even though it is never actually
used within an entry.
This patch makes DNA check the ACIs to see if the incoming operation
is allowed before allocating a value from the range. If the ACIs
result in an operation that will be rejected, we skip allocation
which keeps us from wasting a value from the range.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 5419409bb..a60690dcc 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -2821,6 +2821,18 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
goto bailmod;
}
+ /* See if the operation is going to be rejected by the ACIs. There's no use in
+ * us worrying about the change if it's going to be rejected. */
+ if (LDAP_CHANGETYPE_MODIFY == modtype) {
+ if (slapi_acl_check_mods(pb, e, slapi_mods_get_ldapmods_byref(smods), NULL) != LDAP_SUCCESS) {
+ goto bailmod;
+ }
+ } else {
+ if (slapi_access_allowed(pb, e, NULL, NULL, SLAPI_ACL_ADD) != LDAP_SUCCESS) {
+ goto bailmod;
+ }
+ }
+
dna_read_lock();
if (!PR_CLIST_IS_EMPTY(dna_global_config)) {
| 0 |
861d032e175269972b7430c57e8b8811d0272c38
|
389ds/389-ds-base
|
Issue 5554 - Add more tests to security_basic_test suite (#5555)
Description: Add tests for ANONYMOUS_BIND and TLSCLIENTAUTH
cases (including CERT_MAP_FAILED).
Fix minor test structure issues.
Fixes: https://github.com/389ds/389-ds-base/issues/5554
Reviewed by: @mreynolds389, @Firstyear (Thanks!)
|
commit 861d032e175269972b7430c57e8b8811d0272c38
Author: Simon Pichugin <[email protected]>
Date: Mon Dec 12 16:39:46 2022 -0800
Issue 5554 - Add more tests to security_basic_test suite (#5555)
Description: Add tests for ANONYMOUS_BIND and TLSCLIENTAUTH
cases (including CERT_MAP_FAILED).
Fix minor test structure issues.
Fixes: https://github.com/389ds/389-ds-base/issues/5554
Reviewed by: @mreynolds389, @Firstyear (Thanks!)
diff --git a/dirsrvtests/tests/suites/config/config_delete_attr_test.py b/dirsrvtests/tests/suites/config/config_delete_attr_test.py
index 67291d9b9..a5a25878a 100644
--- a/dirsrvtests/tests/suites/config/config_delete_attr_test.py
+++ b/dirsrvtests/tests/suites/config/config_delete_attr_test.py
@@ -75,6 +75,7 @@ def test_reset_attributes(topology_st):
'nsslapd-defaultnamingcontext',
'nsslapd-accesslog',
'nsslapd-auditlog',
+ 'nsslapd-securitylog',
'nsslapd-errorlog',
'nsslapd-tmpdir',
'nsslapd-rundir',
diff --git a/dirsrvtests/tests/suites/logging/security_basic_test.py b/dirsrvtests/tests/suites/logging/security_basic_test.py
index 6e97a95c9..8c897e0ac 100644
--- a/dirsrvtests/tests/suites/logging/security_basic_test.py
+++ b/dirsrvtests/tests/suites/logging/security_basic_test.py
@@ -21,6 +21,9 @@ from lib389.idm.user import UserAccount, UserAccounts
from lib389.dirsrv_log import DirsrvSecurityLog
from lib389.utils import ensure_str
from lib389.idm.domain import Domain
+from lib389.idm.account import Anonymous
+from lib389.config import CertmapLegacy
+from lib389.nss_ssl import NssSsl
log = logging.getLogger(__name__)
@@ -32,6 +35,8 @@ DN_QUOATED = "uid=\"cn=mark\",ou=people," + DEFAULT_SUFFIX
DN_QUOATED_ESCAPED = "uid=cn\\3dmark,ou=people," + DEFAULT_SUFFIX
DN_LONG = "uid=" + ("z" * 520) + ",ou=people," + DEFAULT_SUFFIX
DN_LONG_TRUNCATED = "uid=" + ("z" * 508) + "..."
+RDN_TEST_USER = 'testuser'
+RDN_TEST_USER_WRONG = 'testuser_wrong'
@pytest.fixture
@@ -56,7 +61,7 @@ def setup_test(topo, request):
pass
-def check_log(inst, event_id, msg, dn=None):
+def check_log(inst, event_id, msg, dn=None, bind_method=None):
"""Check the security log
"""
time.sleep(1) # give a little time to flush to disk
@@ -68,14 +73,21 @@ def check_log(inst, event_id, msg, dn=None):
# Skip log title lines
continue
- event = json.loads(line)
- if dn is not None:
- if event['dn'] == dn.lower() and event['event'] == event_id and event['msg'] == msg:
- # Found it
- return
- elif event['event'] == event_id and event['msg'] == msg:
- # Found it
- return
+ event = json.loads(line)
+ found = False
+ if event['event'] == event_id and event['msg'] == msg:
+ if dn is not None:
+ if event['dn'] == dn.lower():
+ found = True
+ if bind_method is not None:
+ if event['bind_method'] == bind_method:
+ found = True
+
+ if not found and (dn is not None or bind_method is not None):
+ continue
+ else:
+ # Found it
+ return
assert False
@@ -106,6 +118,9 @@ def test_invalid_binds(topo, setup_test):
inst = topo.standalone
user_entry = UserAccount(inst, DN)
+ # Delete the previous securty logs
+ inst.deleteSecurityLogs()
+
# Good bind
user_entry.bind(PASSWORD)
check_log(inst, "BIND_SUCCESS", "", DN)
@@ -153,6 +168,9 @@ def test_authorization(topo, setup_test):
"""
inst = topo.standalone
+ # Delete the previous securty logs
+ inst.deleteSecurityLogs()
+
# Bind as a user
user_entry = UserAccount(inst, DN)
user_conn = user_entry.bind(PASSWORD)
@@ -167,7 +185,7 @@ def test_authorization(topo, setup_test):
def test_account_lockout(topo, setup_test):
- """Specify a test case purpose or name here
+ """Test that accound locked message is displayed correctly
:id: b70494f0-7d8e-4d90-8265-9d009bbb08b4
:setup: Standalone Instance
@@ -182,6 +200,9 @@ def test_account_lockout(topo, setup_test):
"""
inst = topo.standalone
+ # Delete the previous securty logs
+ inst.deleteSecurityLogs()
+
# Configure account lockout
inst.config.set('passwordlockout', 'on')
inst.config.set('passwordMaxFailure', '2')
@@ -219,6 +240,9 @@ def test_tcp_events(topo, setup_test):
inst = topo.standalone
+ # Delete the previous securty logs
+ inst.deleteSecurityLogs()
+
# Start interactive ldapamodfy command
ldap_cmd = ['ldapmodify', '-x', '-D', DN_DM, '-w', PASSWORD,
'-H', f'ldap://{inst.host}:{inst.port}']
@@ -234,6 +258,108 @@ def test_tcp_events(topo, setup_test):
check_log(inst, "TCP_ERROR", "Bad Ber Tag or uncleanly closed connection - B1")
+def test_anonymous_bind(topo, setup_test):
+ """Test that anonymous bind message is displayed correctly
+
+ :id: 0df3c6c1-e93a-4baf-88c6-825c1d4d9b8e
+ :setup: Standalone Instance
+ :steps:
+ 1. Bind anonymously
+ 2. Check for account lockout event
+ :expectedresults:
+ 1. Success
+ 2. Success
+ """
+
+ inst = topo.standalone
+
+ # Delete the previous securty logs
+ inst.deleteSecurityLogs()
+
+ Anonymous(inst).bind()
+ check_log(inst, "BIND_SUCCESS", "ANONYMOUS_BIND")
+
+
+def test_cert_map_failed_event(topo, setup_test):
+ """Trigger a CERT_MAP_FAILED event that should be logged in the security log.
+ Also test that BIND_SUCCESS works with TLSCLIENTAUTH
+
+ :id: eb0c638b-4a30-4108-b38b-e75e55ccb6c8
+ :setup: Standalone Instance
+ :steps:
+ 1. Enable TLS
+ 2. Create a user
+ 3. Create User certificates - one is for the new user, another one is free
+ 4. Turn on the certmap.
+ 5. Check that EXTERNAL is listed in supported mechns.
+ 6. Restart to allow certmaps to be re-read
+ 7. Attempt a bind with TLS external with the correct credentials
+ 8. Now attempt a bind with TLS external with a wrong cert
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Securotylog should display BIND_SUCCESS works with TLSCLIENTAUTH
+ 8. Securotylog should display BIND_FAILED works with CERT_MAP_FAILED
+ """
+
+ inst = topo.standalone
+
+ inst.enable_tls()
+
+ users = UserAccounts(inst, DEFAULT_SUFFIX)
+ user = users.create(properties={
+ 'uid': RDN_TEST_USER,
+ 'cn' : RDN_TEST_USER,
+ 'sn' : RDN_TEST_USER,
+ 'uidNumber' : '1000',
+ 'gidNumber' : '2000',
+ 'homeDirectory' : f'/home/{RDN_TEST_USER}'
+ })
+
+ ssca_dir = inst.get_ssca_dir()
+ ssca = NssSsl(dbpath=ssca_dir)
+ ssca.create_rsa_user(RDN_TEST_USER)
+ ssca.create_rsa_user(RDN_TEST_USER_WRONG)
+
+ # Get the details of where the key and crt are.
+ tls_locs = ssca.get_rsa_user(RDN_TEST_USER)
+ tls_locs_wrong = ssca.get_rsa_user(RDN_TEST_USER_WRONG)
+
+ user.enroll_certificate(tls_locs['crt_der_path'])
+
+ # Turn on the certmap.
+ cm = CertmapLegacy(inst)
+ certmaps = cm.list()
+ certmaps['default']['DNComps'] = ''
+ certmaps['default']['FilterComps'] = ['cn']
+ certmaps['default']['VerifyCert'] = 'off'
+ cm.set(certmaps)
+
+ # Check that EXTERNAL is listed in supported mechns.
+ assert(inst.rootdse.supports_sasl_external())
+
+ # Restart to allow certmaps to be re-read: Note, we CAN NOT use post_open
+ # here, it breaks on auth. see lib389/__init__.py
+ inst.restart(post_open=False)
+
+ # Delete the previous securty logs
+ inst.deleteSecurityLogs()
+
+ # Attempt a bind with TLS external
+ inst.open(saslmethod='EXTERNAL', connOnly=True, certdir=ssca_dir, userkey=tls_locs['key'], usercert=tls_locs['crt'])
+ inst.restart()
+ check_log(inst, "BIND_SUCCESS", "", bind_method="TLSCLIENTAUTH")
+
+ # Now attempt a bind with TLS external with a wrong cert
+ with pytest.raises(ldap.INVALID_CREDENTIALS):
+ inst.open(saslmethod='EXTERNAL', connOnly=True, certdir=ssca_dir, userkey=tls_locs_wrong['key'], usercert=tls_locs_wrong['crt'])
+ check_log(inst, "BIND_FAILED", "CERT_MAP_FAILED")
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
| 0 |
3332a8e8daebb3845b154247ac22f36ad3d831e4
|
389ds/389-ds-base
|
Resolves: 230673
Summary: LDAPI: referral mode needs LDAPI socket? (Comment #3)
Change: LDAPI is disabled in the initial configuration parameter setting.
|
commit 3332a8e8daebb3845b154247ac22f36ad3d831e4
Author: Noriko Hosoi <[email protected]>
Date: Fri Mar 2 22:38:07 2007 +0000
Resolves: 230673
Summary: LDAPI: referral mode needs LDAPI socket? (Comment #3)
Change: LDAPI is disabled in the initial configuration parameter setting.
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 313f3ae9b..101f32832 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -778,7 +778,7 @@ FrontendConfig_init () {
cfg->port = LDAP_PORT;
cfg->secureport = LDAPS_PORT;
cfg->ldapi_filename = slapi_ch_strdup(SLAPD_LDAPI_DEFAULT_FILENAME);
- cfg->ldapi_switch = LDAP_ON;
+ cfg->ldapi_switch = LDAP_OFF;
cfg->ldapi_bind_switch = LDAP_OFF;
cfg->ldapi_root_dn = slapi_ch_strdup("cn=Directory Manager");
cfg->ldapi_map_entries = LDAP_OFF;
| 0 |
231cd7e3a7a4f5221dbdc6dbc8ede559db77d9cd
|
389ds/389-ds-base
|
Ticket #292 - logconv.pl reporting unindexed search with different search base than shown in access logs
Bug Description: Sometimes the search base & scope are incorrect in the notes=U output
Fix Description: Previously we were just grabbing the last search base and scope that was
processed in the logs. We did not associate it with a conn/op number.
So if the unindexed search took a long time, another search would come in,
and then our search base and scope are out of synch. I created a new
search base and scope hash to store the values so we can get the correct
output when printing the report.
Reviewed by: nhosoi (Thanks Noriko!)
https://fedorahosted.org/389/ticket/292
|
commit 231cd7e3a7a4f5221dbdc6dbc8ede559db77d9cd
Author: Mark Reynolds <[email protected]>
Date: Wed Mar 7 13:16:05 2012 -0500
Ticket #292 - logconv.pl reporting unindexed search with different search base than shown in access logs
Bug Description: Sometimes the search base & scope are incorrect in the notes=U output
Fix Description: Previously we were just grabbing the last search base and scope that was
processed in the logs. We did not associate it with a conn/op number.
So if the unindexed search took a long time, another search would come in,
and then our search base and scope are out of synch. I created a new
search base and scope hash to store the values so we can get the correct
output when printing the report.
Reviewed by: nhosoi (Thanks Noriko!)
https://fedorahosted.org/389/ticket/292
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index c6e8708a0..c65e5b69d 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -174,6 +174,8 @@ $nt = "0";
$nb = "0";
$bc = "0";
$fcc = "0";
+$bcc = "0";
+$scc = "0";
$nent = "0";
$allOps = "0";
$allResults = "0";
@@ -519,7 +521,6 @@ $modStat = sprintf "(%.2f/sec) (%.2f/min)\n",$mod / $totalTimeInSecs, $mod/($to
$addStat = sprintf "(%.2f/sec) (%.2f/min)\n",$add/$totalTimeInSecs, $add/($totalTimeInSecs/60);
$deleteStat = sprintf "(%.2f/sec) (%.2f/min)\n",$delete/$totalTimeInSecs, $delete/($totalTimeInSecs/60);
$modrdnStat = sprintf "(%.2f/sec) (%.2f/min)\n",$modrdn/$totalTimeInSecs, $modrdn/($totalTimeInSecs/60);
-$moddnStat = sprintf "(%.2f/sec) (%.2f/min)\n",$moddn/$totalTimeInSecs, $moddn/($totalTimeInSecs/60);
$compareStat = sprintf "(%.2f/sec) (%.2f/min)\n",$compare/$totalTimeInSecs, $compare/($totalTimeInSecs/60);
$bindStat = sprintf "(%.2f/sec) (%.2f/min)\n",$bind/$totalTimeInSecs, $bind/($totalTimeInSecs/60);
@@ -534,8 +535,6 @@ Deletes: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
$delete, $deleteStat
Mod RDNs: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
$modrdn, $modrdnStat
-Mod DNs: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
- $moddn, $moddnStat
Compares: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
$compare, $compareStat
Binds: @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
@@ -571,8 +570,6 @@ if ($notes > 0){
print " - Etime: $notesEtime[$n]\n";
print " - Nentries: $notesNentries[$n]\n";
print " - IP Address: $conn_hash{$notesConn[$n]}\n";
- print " - Search Base: $notesBase[$n]\n";
- print " - Scope: $notesScope[$n]\n";
for ($nn = 0; $nn <= $bc; $nn++){
if ($notesConn[$n] eq $bindInfo[$nn][1]) {
@@ -591,6 +588,16 @@ if ($notes > 0){
}
}
}
+ for ($nnn = 0; $nnn <= $bcc; $nnn++){
+ if ($notesConn[$n] eq $baseInfo[$nnn][1] && $notesOp[$n] eq $baseInfo[$nnn][2]){
+ print " - Search Base: $baseInfo[$nnn][0]\n";
+ }
+ }
+ for ($nnn = 0; $nnn <= $scc; $nnn++){
+ if ($notesConn[$n] eq $scopeInfo[$nnn][1] && $notesOp[$n] eq $scopeInfo[$nnn][2]){
+ print " - Search Scope: $scopeInfo[$nnn][0]\n";
+ }
+ }
for ($nnn = 0; $nnn <= $fcc; $nnn++){
if ($notesConn[$n] eq $filterInfo[$nnn][1] && $notesOp[$n] eq $filterInfo[$nnn][2]){
print " - Search Filter: $filterInfo[$nnn][0]\n";
@@ -1328,15 +1335,6 @@ if (m/ SRCH/){
if ($_ =~ /op= *([0-9]+)/i){ $srchOp[$sconn] = $1;}
$sconn++;
}
-
- ##### This to get the Base and Scope value
- ##### just in case this happens to be an
- ##### unindexed search....
-
- if ($_ =~ /base=\"(.*)\" scope=(\d) filter/) {
- $tmpBase = $1;
- $tmpScope = $2;
- }
}
if (m/ DEL/){
$delete++;
@@ -1492,27 +1490,24 @@ if (m/ notes=U/){
inc_stats('notesu',$s_stats,$m_stats);
}
if ($usage =~ /u/ || $verb eq "yes"){
- if ($v eq "0" ){
- if ($_ =~ /etime= *([0-9]+)/i ) {
- $notesEtime[$vet]=$1;
- $vet++;
- }
- if ($_ =~ /conn= *([0-9]+)/i){
- $notesConn[$nc]=$1;
- $nc++;
- }
- if ($_ =~ /op= *([0-9]+)/i){
- $notesOp[$no]=$1;
- $no++;
- }
- if ($_ =~ / *([0-9a-z:\/]+)/i){
- $notesTime[$nt] = $1;
- $nt++;
- }
- $notesBase[$nb] = $tmpBase;
- $notesScope[$nb] = $tmpScope;
- $nb++;
- }
+ if ($v eq "0" ){
+ if ($_ =~ /etime= *([0-9]+)/i ) {
+ $notesEtime[$vet]=$1;
+ $vet++;
+ }
+ if ($_ =~ /conn= *([0-9]+)/i){
+ $notesConn[$nc]=$1;
+ $nc++;
+ }
+ if ($_ =~ /op= *([0-9]+)/i){
+ $notesOp[$no]=$1;
+ $no++;
+ }
+ if ($_ =~ / *([0-9a-z:\/]+)/i){
+ $notesTime[$nt] = $1;
+ $nt++;
+ }
+ }
if ($_ =~ /nentries= *([0-9]+)/i ){
$notesNentries[$nent] = $1;
$nent++;
@@ -1839,6 +1834,25 @@ if ($usage =~ /a/ || $verb eq "yes"){
}
$tmpp =~ tr/A-Z/a-z/;
$base{$tmpp} = $base{$tmpp} + 1;
+
+ #
+ # grab the search bases & scope for potential unindexed searches
+ #
+ $baseInfo[$bcc][0] = $tmpp;
+ if ($_ =~ /scope= *([0-9]+)/i) {
+ $scopeInfo[$scc][0] = $1;
+ }
+ if ($_ =~ /conn= *([0-9]+)/i) {
+ $baseInfo[$bcc][1] = $1;
+ $scopeInfo[$scc][1] = $1;
+ }
+ if ($_ =~ /op= *([0-9]+)/i) {
+ $baseInfo[$bcc][2] = $1;
+ $scopeInfo[$scc][2] = $1;
+ }
+ $bcc++;
+ $scc++;
+
}
}
| 0 |
774a36c8dce821975ecd014b682a51ae2d9c9537
|
389ds/389-ds-base
|
Resolves: #214728
Summary: Cleaning up obsolete macros in the build
Changes: eliminated macro NET_SSL (Comment #5)
|
commit 774a36c8dce821975ecd014b682a51ae2d9c9537
Author: Noriko Hosoi <[email protected]>
Date: Fri Nov 10 01:10:57 2006 +0000
Resolves: #214728
Summary: Cleaning up obsolete macros in the build
Changes: eliminated macro NET_SSL (Comment #5)
diff --git a/httpd/src/ntnsapi.c b/httpd/src/ntnsapi.c
index 5cab8fda5..b8b11ef25 100644
--- a/httpd/src/ntnsapi.c
+++ b/httpd/src/ntnsapi.c
@@ -94,7 +94,6 @@ VOID InitializeSafFunctions()
/* Functions from ereport.h */
SafTable[EREPORT] = (SafFunction *)ereport ;
-#ifdef NET_SSL
/* Functions from minissl.h */
SafTable[SSL_CLOSE] = (SafFunction *)PR_Close;
SafTable[SSL_SOCKET] = (SafFunction *)PR_NewTCPSocket;
@@ -106,7 +105,6 @@ VOID InitializeSafFunctions()
SafTable[SSL_READ] = (SafFunction *)PR_Read;
SafTable[SSL_WRITE] = (SafFunction *)PR_Write;
SafTable[SSL_GETPEERNAME] = (SafFunction *)PR_GetPeerName;
-#endif /* NET_SSL */
/* Functions from shexp.h */
diff --git a/ldap/admin/lib/dsalib_pw.c b/ldap/admin/lib/dsalib_pw.c
index 038ac922c..3c64ba0f1 100644
--- a/ldap/admin/lib/dsalib_pw.c
+++ b/ldap/admin/lib/dsalib_pw.c
@@ -56,10 +56,8 @@
#include "prlong.h"
#include "prmem.h"
-#if defined(NET_SSL)
#include <pk11func.h>
#include <pk11pqg.h>
-#endif /* NET_SSL */
#define SHA1_SALT_LENGTH 8 /* number of bytes of data in salt */
#define PWD_HASH_PREFIX_START '{'
diff --git a/ldap/clients/dsgw/dsgw.h b/ldap/clients/dsgw/dsgw.h
index cbffeec8b..edfcf1aa0 100644
--- a/ldap/clients/dsgw/dsgw.h
+++ b/ldap/clients/dsgw/dsgw.h
@@ -39,10 +39,6 @@
* dsgw.h -- defines for HTTP gateway
*/
-#if !defined( DSGW_NO_SSL ) && !defined( NET_SSL )
-#define DSGW_NO_SSL
-#endif
-
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/ldap/include/proto-ntutil.h b/ldap/include/proto-ntutil.h
index d74171aa8..88181469b 100644
--- a/ldap/include/proto-ntutil.h
+++ b/ldap/include/proto-ntutil.h
@@ -94,10 +94,8 @@ extern BOOL SlapdGetServerNameFromCmdline(char *szServerName, char *szCmdLine, i
* ntgetpassword.c
*
*/
-#ifdef NET_SSL
extern char *Slapd_GetPassword();
extern void CenterDialog(HWND hwndParent, HWND hwndDialog);
-#endif /* NET_SSL */
#ifdef __cplusplus
}
diff --git a/ldap/libraries/libutil/ntstubs.c b/ldap/libraries/libutil/ntstubs.c
index 00238e5ed..e7adbf2e4 100644
--- a/ldap/libraries/libutil/ntstubs.c
+++ b/ldap/libraries/libutil/ntstubs.c
@@ -45,7 +45,7 @@
*
******************************************************/
-#if defined( _WIN32 ) && defined ( NET_SSL )
+#if defined( _WIN32 )
#include <windows.h>
#include <nspr.h>
@@ -68,5 +68,5 @@ WH_FileName (const char *name, PRFileType type)
{
return NULL;
}
-#endif /* WIN32 && NET_SSL */
+#endif /* WIN32 */
diff --git a/ldap/servers/plugins/pwdstorage/pwdstorage.h b/ldap/servers/plugins/pwdstorage/pwdstorage.h
index 70fe11bac..83e885de7 100644
--- a/ldap/servers/plugins/pwdstorage/pwdstorage.h
+++ b/ldap/servers/plugins/pwdstorage/pwdstorage.h
@@ -103,64 +103,4 @@ int ns_mta_md5_pw_cmp( char *userpwd, char *dbpwd );
int md5_pw_cmp( char *userpwd, char *dbpwd );
char *md5_pw_enc( char *pwd );
-
-#if !defined(NET_SSL)
-/******************************************/
-/*
- * Some of the stuff below depends on a definition for uint32, so
- * we include one here. Other definitions appear in nspr/prtypes.h,
- * at least. All the platforms we support use 32-bit ints.
- */
-typedef unsigned int uint32;
-
-
-/******************************************/
-/*
- * The following is from ds.h, which the libsec sec.h stuff depends on (see
- * comment below).
- */
-/*
-** A status code. Status's are used by procedures that return status
-** values. Again the motivation is so that a compiler can generate
-** warnings when return values are wrong. Correct testing of status codes:
-**
-** DSStatus rv;
-** rv = some_function (some_argument);
-** if (rv != DSSuccess)
-** do_an_error_thing();
-**
-*/
-typedef enum DSStatusEnum {
- DSWouldBlock = -2,
- DSFailure = -1,
- DSSuccess = 0
-} DSStatus;
-
-
-/******************************************/
-/*
- * All of the SHA1-related defines are from libsec's "sec.h" -- including
- * it directly pulls in way too much stuff that we conflict with. Ugh.
- */
-
-/*
- * Number of bytes each hash algorithm produces
- */
-#define SHA1_LENGTH 20
-#define SHA256_LENGTH 32
-#define SHA384_LENGTH 48
-#define SHA512_LENGTH 64
-
-/******************************************/
-/*
-** SHA-1 secure hash function
-*/
-
-/*
-** Hash a null terminated string "src" into "dest" using SHA-1
-*/
-DSStatus SHA1_Hash(unsigned char *dest, char *src);
-
-#endif /* !defined(NET_SSL) */
-
#endif /* _PWDSTORAGE_H */
diff --git a/ldap/servers/plugins/pwdstorage/sha_pwd.c b/ldap/servers/plugins/pwdstorage/sha_pwd.c
index 0f4247cb1..f1389f696 100644
--- a/ldap/servers/plugins/pwdstorage/sha_pwd.c
+++ b/ldap/servers/plugins/pwdstorage/sha_pwd.c
@@ -46,9 +46,7 @@
#include "pwdstorage.h"
-#if defined(NET_SSL)
#include <sechash.h>
-#endif /* NET_SSL */
#define SHA_SALT_LENGTH 8 /* number of bytes of data in salt */
#define NOT_FIRST_TIME (time_t)1 /* not the first logon */
diff --git a/ldap/servers/plugins/pwdstorage/ssha_pwd.c b/ldap/servers/plugins/pwdstorage/ssha_pwd.c
index ac72e46ed..b20e50129 100644
--- a/ldap/servers/plugins/pwdstorage/ssha_pwd.c
+++ b/ldap/servers/plugins/pwdstorage/ssha_pwd.c
@@ -48,10 +48,8 @@
#include "prtime.h"
#include "prlong.h"
-#if defined(NET_SSL)
#include <pk11func.h>
#include <pk11pqg.h>
-#endif /* NET_SSL */
#define SHA_SALT_LENGTH 8 /* number of bytes of data in salt */
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index adefdd4aa..7c895be59 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -83,9 +83,7 @@
#include "snmp_collator.h"
#include <private/pprio.h>
-#if defined( NET_SSL )
#include <ssl.h>
-#endif /* defined(NET_SSL) */
#include "fe.h"
@@ -1895,7 +1893,6 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
*/
}
-#if defined(NET_SSL)
if( secure && config_get_SSLclientAuth() != SLAPD_SSLCLIENTAUTH_OFF ) {
/* Prepare to handle the client's certificate (if any): */
int rv;
@@ -1917,7 +1914,6 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
conn->c_sd, rv, prerr);
}
}
-#endif
connection_reset(conn, ns, &from, sizeof(from), secure);
diff --git a/ldap/servers/slapd/globals.c b/ldap/servers/slapd/globals.c
index a6077f751..6ab34b7b4 100644
--- a/ldap/servers/slapd/globals.c
+++ b/ldap/servers/slapd/globals.c
@@ -42,7 +42,6 @@
* SLAPD globals.c -- SLAPD library global variables
*/
-#if defined(NET_SSL)
#include "ldap.h"
#include <sslproto.h> /* cipher suite names */
#include <ldap_ssl.h>
@@ -50,8 +49,6 @@
#undef OFF
#undef LITTLE_ENDIAN
-#endif
-
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 6af39baae..d6549cf13 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -45,7 +45,6 @@
*/
#define DONT_DECLARE_SLAPD_LDAP_DEBUG /* see ldaplog.h */
-#if defined(NET_SSL)
#include "ldap.h"
#include <sslproto.h>
#include <ldap_ssl.h>
@@ -53,8 +52,6 @@
#undef OFF
#undef LITTLE_ENDIAN
-#endif
-
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
diff --git a/ldap/servers/slapd/localhost.c b/ldap/servers/slapd/localhost.c
index a6c569f02..f95af184a 100644
--- a/ldap/servers/slapd/localhost.c
+++ b/ldap/servers/slapd/localhost.c
@@ -56,10 +56,8 @@
#include <unistd.h>
#endif /* USE_SYSCONF */
-#if defined( NET_SSL )
#include <ssl.h>
#include "fe.h"
-#endif /* defined(NET_SSL) */
#ifndef _PATH_RESCONF /* usually defined in <resolv.h> */
#define _PATH_RESCONF "/etc/resolv.conf"
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 0f41080b3..8ef052e24 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -36,11 +36,9 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
-#if defined(NET_SSL)
#include <ldap.h>
#undef OFF
#undef LITTLE_ENDIAN
-#endif
#include <stdio.h>
#include <string.h>
@@ -108,9 +106,7 @@ static int slapd_exemode_db2ldif(int argc, char **argv);
static int slapd_exemode_db2index();
static int slapd_exemode_archive2db();
static int slapd_exemode_db2archive();
-#if defined(UPGRADEDB)
static int slapd_exemode_upgradedb();
-#endif
static int slapd_exemode_dbtest();
static int slapd_exemode_suffix2instance();
static int slapd_debug_level_string2level( const char *s );
@@ -365,21 +361,15 @@ name2exemode( char *progname, char *s, int exit_if_unknown )
} else if ( strcmp( s, "suffix2instance" ) == 0 ) {
exemode = SLAPD_EXEMODE_SUFFIX2INSTANCE;
}
-#if defined(UPGRADEDB)
else if ( strcmp( s, "upgradedb" ) == 0 )
{
exemode = SLAPD_EXEMODE_UPGRADEDB;
}
-#endif
else if ( exit_if_unknown ) {
fprintf( stderr, "usage: %s -D configdir "
"[ldif2db | db2ldif | archive2db "
"| db2archive | db2index | refer | suffix2instance"
-#if defined(UPGRADEDB)
" | upgradedb] "
-#else
- "] "
-#endif
"[options]\n", progname );
exit( 1 );
} else {
@@ -436,11 +426,9 @@ usage( char *name, char *extraname )
case SLAPD_EXEMODE_SUFFIX2INSTANCE:
usagestr = "usage: %s %s%s -D configdir {-s suffix}*\n";
break;
-#if defined(UPGRADEDB)
case SLAPD_EXEMODE_UPGRADEDB:
usagestr = "usage: %s %s%s-D configdir [-d debuglevel] [-f] -a archivedir\n";
break;
-#endif
default: /* SLAPD_EXEMODE_SLAPD */
usagestr = "usage: %s %s%s-D configdir [-d debuglevel] "
@@ -480,9 +468,7 @@ static int ldif2db_generate_uniqueid = SLAPI_UNIQUEID_GENERATE_TIME_BASED;
static int ldif2db_load_state= 1;
static char *ldif2db_namespaceid = NULL;
int importexport_encrypt = 0;
-#if defined(UPGRADEDB)
static int upgradedb_force = 0;
-#endif
/* taken from idsktune */
#if defined(__sun)
@@ -956,10 +942,8 @@ main( int argc, char **argv)
case SLAPD_EXEMODE_SUFFIX2INSTANCE:
return slapd_exemode_suffix2instance();
-#if defined(UPGRADEDB)
case SLAPD_EXEMODE_UPGRADEDB:
return slapd_exemode_upgradedb();
-#endif
case SLAPD_EXEMODE_PRINTVERSION:
slapd_print_version(1);
@@ -1085,9 +1069,7 @@ main( int argc, char **argv)
normalize_oc();
if (n_port) {
-#if defined(NET_SSL)
} else if ( config_get_security()) {
-#endif
} else {
#ifdef _WIN32
if( SlapdIsAService() )
@@ -1327,7 +1309,6 @@ process_command_line(int argc, char **argv, char *myname,
{"exclude",ArgRequired,'x'},
{0,0,0}};
-#if defined(UPGRADEDB)
char *opts_upgradedb = "vfd:a:D:";
struct opt_ext long_options_upgradedb[] = {
{"version",ArgNone,'v'},
@@ -1336,7 +1317,6 @@ process_command_line(int argc, char **argv, char *myname,
{"archive",ArgRequired,'a'},
{"configDir",ArgRequired,'D'},
{0,0,0}};
-#endif
char *opts_referral = "vd:p:r:SD:";
struct opt_ext long_options_referral[] = {
@@ -1430,12 +1410,10 @@ process_command_line(int argc, char **argv, char *myname,
opts = opts_suffix2instance;
long_opts = long_options_suffix2instance;
break;
-#if defined(UPGRADEDB)
case SLAPD_EXEMODE_UPGRADEDB:
opts = opts_upgradedb;
long_opts = long_options_upgradedb;
break;
-#endif
default: /* SLAPD_EXEMODE_SLAPD */
opts = opts_slapd;
long_opts = long_options_slapd;
@@ -1755,7 +1733,6 @@ process_command_line(int argc, char **argv, char *myname,
}
importexport_encrypt = 1;
break;
-#if defined(UPGRADEDB)
case 'f': /* upgradedb only */
if ( slapd_exemode != SLAPD_EXEMODE_UPGRADEDB ) {
usage( myname, *extraname );
@@ -1763,7 +1740,6 @@ process_command_line(int argc, char **argv, char *myname,
}
upgradedb_force = SLAPI_UPGRADEDB_FORCE;
break;
-#endif
case '1': /* db2ldif only */
if ( slapd_exemode != SLAPD_EXEMODE_DB2LDIF ) {
usage( myname, *extraname );
@@ -2500,7 +2476,6 @@ slapd_exemode_archive2db()
return return_value;
}
-#if defined(UPGRADEDB)
/*
* functions to convert idl from the old format to the new one
* (604921) Support a database uprev process any time post-install
@@ -2575,7 +2550,6 @@ slapd_exemode_upgradedb()
slapi_ch_free((void**)&myname );
return( return_value );
}
-#endif
static int
diff --git a/ldap/servers/slapd/ntuserpin.c b/ldap/servers/slapd/ntuserpin.c
index 4859903a3..b420cad16 100644
--- a/ldap/servers/slapd/ntuserpin.c
+++ b/ldap/servers/slapd/ntuserpin.c
@@ -42,7 +42,7 @@
*
******************************************************/
-#if defined( _WIN32 ) && defined ( NET_SSL )
+#if defined( _WIN32 )
#include <windows.h>
#include "ntwatchdog.h"
@@ -206,4 +206,4 @@ static char *getPin(SVRCOREPinObj *obj, const char *tokenName, PRBool retry)
*/
static const SVRCOREPinMethods vtable =
{ 0, 0, destroyObject, getPin };
-#endif /* defined( _WIN32 ) && defined ( NET_SSL ) */
+#endif /* defined( _WIN32 ) */
diff --git a/ldap/servers/slapd/plugin_internal_op.c b/ldap/servers/slapd/plugin_internal_op.c
index 81513e379..1292881e5 100644
--- a/ldap/servers/slapd/plugin_internal_op.c
+++ b/ldap/servers/slapd/plugin_internal_op.c
@@ -42,9 +42,7 @@
#include "slapi-plugin.h"
#include "slap.h"
-#if defined(NET_SSL)
#include <ssl.h>
-#endif
/* entry list node */
typedef struct Entry_Node{
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index dd312d68d..ae5cfd32f 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -43,7 +43,6 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
-#if defined(NET_SSL)
#include <sechash.h>
#if defined( _WIN32 )
#undef DEBUG
@@ -52,8 +51,6 @@
#undef LDAPDebug
#endif /* _WIN32 */
-#endif /* NET_SSL */
-
#include "slap.h"
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index 03f1b289a..0292c2e2f 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -53,10 +53,7 @@
#include "fe.h"
#include "vattr_spi.h"
-
-#if defined( NET_SSL )
#include <ssl.h>
-#endif
PRUint64 num_entries_sent;
PRUint64 num_bytes_sent;
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index db818884f..a8b51c42e 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -61,9 +61,7 @@ static char ptokDes[34] = "Internal (Software) Token ";
#define SLAPD_EXEMODE_REFERRAL 8
#define SLAPD_EXEMODE_SUFFIX2INSTANCE 9
#define SLAPD_EXEMODE_PRINTVERSION 10
-#if defined(UPGRADEDB)
#define SLAPD_EXEMODE_UPGRADEDB 11
-#endif
#ifdef _WIN32
#ifndef DONT_DECLARE_SLAPD_LDAP_DEBUG
@@ -119,7 +117,6 @@ void *dlsym(void *a, char *b);
#define SLAPD_TYPICAL_ATTRIBUTE_NAME_MAX_LENGTH 256
-#if defined(NET_SSL)
typedef struct symbol_t {
const char* name;
unsigned number;
@@ -129,7 +126,6 @@ typedef struct symbol_t {
#define SLAPD_SSLCLIENTAUTH_ALLOWED 1 /* server asks for cert, but client need not send one */
#define SLAPD_SSLCLIENTAUTH_REQUIRED 2 /* server will refuse SSL session unless client sends cert */
#define SLAPD_SSLCLIENTAUTH_DEFAULT SLAPD_SSLCLIENTAUTH_ALLOWED
-#endif /* NET_SSL */
#define SLAPD_LOGGING 1
#define NUM_SNMP_INT_TBL_ROWS 5
@@ -768,9 +764,7 @@ struct slapdplugin {
IFP plg_un_db_db2index; /* database 2 index */
IFP plg_un_db_archive2db; /* ldif 2 database */
IFP plg_un_db_db2archive; /* database 2 ldif */
-#if defined(UPGRADEDB)
IFP plg_un_db_upgradedb; /* convert old idl to new */
-#endif
IFP plg_un_db_begin; /* dbase txn begin */
IFP plg_un_db_commit; /* dbase txn commit */
IFP plg_un_db_abort; /* dbase txn abort */
@@ -805,9 +799,7 @@ struct slapdplugin {
#define plg_db2index plg_un.plg_un_db.plg_un_db_db2index
#define plg_archive2db plg_un.plg_un_db.plg_un_db_archive2db
#define plg_db2archive plg_un.plg_un_db.plg_un_db_db2archive
-#if defined(UPGRADEDB)
#define plg_upgradedb plg_un.plg_un_db.plg_un_db_upgradedb
-#endif
#define plg_dbsize plg_un.plg_un_db.plg_un_db_dbsize
#define plg_dbtest plg_un.plg_un_db.plg_un_db_dbtest
#define plg_rmdb plg_un.plg_un_db.plg_un_db_rmdb
@@ -1051,9 +1043,7 @@ typedef struct backend {
#define be_poststart be_database->plg_poststart
#define be_seq be_database->plg_seq
#define be_ldif2db be_database->plg_ldif2db
-#if defined(UPGRADEDB)
#define be_upgradedb be_database->plg_upgradedb
-#endif
#define be_db2ldif be_database->plg_db2ldif
#define be_db2index be_database->plg_db2index
#define be_archive2db be_database->plg_archive2db
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index d1552442e..027bb5163 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -37,8 +37,6 @@
* END COPYRIGHT BLOCK **/
/* SSL-related stuff for slapd */
-#if defined(NET_SSL)
-
#if defined( _WINDOWS )
#include <windows.h>
#include <winsock.h>
@@ -102,8 +100,6 @@ static char * configDN = "cn=encryption,cn=config";
/* ----------------------- Multiple cipher support ------------------------ */
-#ifdef NET_SSL
-
static char **cipher_names = NULL;
typedef struct {
char *version;
@@ -182,9 +178,7 @@ _conf_setallciphers(int active)
if(active && !strcmp(_conf_ciphers[x].name, "rsa_null_md5")) {
continue;
}
-#ifdef NET_SSL
SSL_CipherPrefSetDefault(_conf_ciphers[x].num, active ? PR_TRUE : PR_FALSE);
-#endif
}
}
@@ -253,24 +247,12 @@ SSLPLCY_Install(void)
SECStatus s = 0;
-
-#ifdef NS_DOMESTIC
-
- s = NSS_SetDomesticPolicy();
-
-#else
- s = NSS_SetExportPolicy();
-
-#endif
-
+ s = NSS_SetDomesticPolicy();
return s?PR_FAILURE:PR_SUCCESS;
}
-
-#endif /* NET_SSL */
-
static void
slapd_SSL_report(int degree, char *fmt, va_list args)
{
@@ -1144,11 +1126,7 @@ int slapd_ssl_init2(PRFileDesc **fd, int startTLS)
SSL_OptionSetDefault(SSL_ENABLE_SSL2, PR_FALSE);
SSL_OptionSetDefault(SSL_ENABLE_SSLdirs
3, PR_TRUE);
-#ifdef NS_DOMESTIC
s = NSS_SetDomesticPolicy();
-#elif NS_EXPORT
- s = NSS_SetExportPolicy();
-
We already do pr_init, we don't need pr_setconcurrency, we already do nss_init and the rest
*/
@@ -1511,5 +1489,3 @@ char* slapd_get_tmp_dir()
#endif
return ( tmpdir );
}
-
-#endif /* NET_SSL */
diff --git a/lib/base/file.cpp b/lib/base/file.cpp
index 46e9ba162..97e5fe85a 100644
--- a/lib/base/file.cpp
+++ b/lib/base/file.cpp
@@ -528,8 +528,6 @@ extern char *sys_errlist[];
#endif /* SNI */
#endif
-#ifdef NET_SSL
-
#define ERRMSG_SIZE 35
#ifdef THREAD_ANY
static int errmsg_key = -1;
@@ -537,19 +535,16 @@ static int errmsg_key = -1;
/* Removed for ns security integration
#include "xp_error.h"
*/
-#else
+#else /* THREAD_ANY */
static char errmsg[ERRMSG_SIZE];
-#endif
+#endif /* THREAD_ANY */
#include "util.h"
-#endif
-
-
void system_errmsg_init(void)
{
if (errmsg_key == -1) {
-#if defined(THREAD_ANY) && defined(NET_SSL)
+#if defined(THREAD_ANY)
errmsg_key = systhread_newkey();
#endif
#ifdef XP_WIN32
| 0 |
3a4be47f1911d2e103cc915d6a4feefe60d07275
|
389ds/389-ds-base
|
Ticket 48020 - lib389 - need to reset args_instance with
every DirSrv init
Bug Description: When running multiple tests using py.test, the global
dictionary "args_instance" is not reset. So settings
from previous DirSrv instances are applied to the new
instance of DirSrv(if not explicity set in the calling
test).
Fix Description: Reset "args_instance" when a DirSrv object is initialized.
Also used "PW_DM" for all the SER_ROOT_PW values.
https://fedorahosted.org/389/ticket/48020
Reviewed by: nhosoi(Thanks!)
|
commit 3a4be47f1911d2e103cc915d6a4feefe60d07275
Author: Mark Reynolds <[email protected]>
Date: Fri Jan 30 14:28:16 2015 -0500
Ticket 48020 - lib389 - need to reset args_instance with
every DirSrv init
Bug Description: When running multiple tests using py.test, the global
dictionary "args_instance" is not reset. So settings
from previous DirSrv instances are applied to the new
instance of DirSrv(if not explicity set in the calling
test).
Fix Description: Reset "args_instance" when a DirSrv object is initialized.
Also used "PW_DM" for all the SER_ROOT_PW values.
https://fedorahosted.org/389/ticket/48020
Reviewed by: nhosoi(Thanks!)
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index b3c491696..89d83c2f0 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -359,6 +359,19 @@ class DirSrv(SimpleLDAPObject):
self.log = log
self.timeout = timeout
+ # Reset the args (py.test reuses the args_instance for each test case)
+ args_instance[SER_DEPLOYED_DIR] = os.environ.get('PREFIX', None)
+ args_instance[SER_BACKUP_INST_DIR] = os.environ.get('BACKUPDIR', DEFAULT_BACKUPDIR)
+ args_instance[SER_ROOT_DN] = DN_DM
+ args_instance[SER_ROOT_PW] = PW_DM
+ args_instance[SER_HOST] = LOCALHOST
+ args_instance[SER_PORT] = DEFAULT_PORT
+ args_instance[SER_SECURE_PORT] = DEFAULT_SECURE_PORT
+ args_instance[SER_SERVERID_PROP] = "template"
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_instance[SER_USER_ID] = None
+ args_instance[SER_GROUP_ID] = None
+
self.__wrapmethods()
self.__add_brookers__()
diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py
index 1c549f768..9b9632402 100644
--- a/src/lib389/lib389/_constants.py
+++ b/src/lib389/lib389/_constants.py
@@ -85,7 +85,6 @@ CONF_RUN_DIR = 'RUN_DIR'
CONF_DS_ROOT = 'DS_ROOT'
CONF_PRODUCT_NAME = 'PRODUCT_NAME'
-
DN_CONFIG = "cn=config"
DN_PLUGIN = "cn=plugins,%s" % DN_CONFIG
DN_MAPPING_TREE = "cn=mapping tree,%s" % DN_CONFIG
@@ -175,13 +174,14 @@ LOG_PLUGIN,
LOG_MICROSECONDS,
LOG_ACL_SUMMARY) = [1 << x for x in (range(8) + range(11, 19))]
+
#
# Constants for individual tests
#
SUFFIX = 'dc=example,dc=com'
PASSWORD = 'password'
-# Used for standalone topology
+# Standalone topology - 10 instances
HOST_STANDALONE = LOCALHOST
PORT_STANDALONE = 31389
SERVERID_STANDALONE = 'standalone'
@@ -323,7 +323,6 @@ PORT_HUB_10 = 50389
SERVERID_HUB_10 = 'hub_10'
REPLICAID_HUB_10 = 65535
-
HOST_CONSUMER_1 = LOCALHOST
PORT_CONSUMER_1 = 61389
SERVERID_CONSUMER_1 = 'consumer_1'
@@ -332,7 +331,6 @@ HOST_CONSUMER_2 = LOCALHOST
PORT_CONSUMER_2 = 62389
SERVERID_CONSUMER_2 = 'consumer_2'
-
HOST_CONSUMER_3 = LOCALHOST
PORT_CONSUMER_3 = 63389
SERVERID_CONSUMER_3 = 'consumer_3'
@@ -413,7 +411,7 @@ args_instance = {
SER_DEPLOYED_DIR: os.environ.get('PREFIX', None),
SER_BACKUP_INST_DIR: os.environ.get('BACKUPDIR', DEFAULT_BACKUPDIR),
SER_ROOT_DN: DN_DM,
- SER_ROOT_PW: PASSWORD,
+ SER_ROOT_PW: PW_DM,
SER_HOST: LOCALHOST,
SER_PORT: DEFAULT_PORT,
SER_SERVERID_PROP: "template",
| 0 |
cd004c58f921141e6705e10283c3bb25cc85783a
|
389ds/389-ds-base
|
Bump openssl from 0.10.66 to 0.10.70 in /src
Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.66 to 0.10.70.
- [Release notes](https://github.com/sfackler/rust-openssl/releases)
- [Commits](https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.66...openssl-v0.10.70)
---
updated-dependencies:
- dependency-name: openssl
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <[email protected]>
|
commit cd004c58f921141e6705e10283c3bb25cc85783a
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon Feb 3 18:51:29 2025 +0000
Bump openssl from 0.10.66 to 0.10.70 in /src
Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.66 to 0.10.70.
- [Release notes](https://github.com/sfackler/rust-openssl/releases)
- [Commits](https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.66...openssl-v0.10.70)
---
updated-dependencies:
- dependency-name: openssl
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <[email protected]>
diff --git a/src/Cargo.lock b/src/Cargo.lock
index ac51bde43..a819940b0 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -445,9 +445,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "openssl"
-version = "0.10.66"
+version = "0.10.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1"
+checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6"
dependencies = [
"bitflags 2.6.0",
"cfg-if",
@@ -471,9 +471,9 @@ dependencies = [
[[package]]
name = "openssl-sys"
-version = "0.9.103"
+version = "0.9.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6"
+checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc"
dependencies = [
"cc",
"libc",
| 0 |
c1f95889039ace1d4db8c2216275ee20b6e849ed
|
389ds/389-ds-base
|
Issue 5909 - Multi listener hang with 20k connections (#5910)
Bug Description: When the server is configured with multiple listeners,
the connection table is divided into multiple sub tables. These sub tables
are then mapped to a single freelist to enable efficient allocation of new
connections. Each sub table is a double linked list with element 0 used as
the head of the list. During the mapping of sub tables to freelist the
head of each sub table is incorrectly mapped to the freelist, creating a "hole"
in the freelist.
Fix Description: Skip element 0 of each sub table when mapping to the
single freelist.
Fixes: https//github.com/389ds/389-ds-base/issues/5909
Reviewed by: @vashirov (Thank you)
|
commit c1f95889039ace1d4db8c2216275ee20b6e849ed
Author: James Chapman <[email protected]>
Date: Mon Aug 28 15:40:49 2023 +0000
Issue 5909 - Multi listener hang with 20k connections (#5910)
Bug Description: When the server is configured with multiple listeners,
the connection table is divided into multiple sub tables. These sub tables
are then mapped to a single freelist to enable efficient allocation of new
connections. Each sub table is a double linked list with element 0 used as
the head of the list. During the mapping of sub tables to freelist the
head of each sub table is incorrectly mapped to the freelist, creating a "hole"
in the freelist.
Fix Description: Skip element 0 of each sub table when mapping to the
single freelist.
Fixes: https//github.com/389ds/389-ds-base/issues/5909
Reviewed by: @vashirov (Thank you)
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index b1c66cf42..0e5d77e23 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -154,7 +154,7 @@ connection_table_new(int table_size)
/* We rely on the fact that we called calloc, which zeros the block, so we don't
* init any structure element unless a zero value is troublesome later
*/
- for (i = 0; i < ct->list_size; i++) {
+ for (i = 1; i < ct->list_size; i++) {
/*
* Technically this is a no-op due to calloc, but we should always be
* careful with things like this ....
| 0 |
677a502c13bd5733ffb7f0951d71f96dfaeba169
|
389ds/389-ds-base
|
Ticket 49554 - update readme
Bug Description: Our readme needs improving.
Fix Description: Improve it with build steps and links, change
to md format.
https://pagure.io/389-ds-base/issue/49554
Author: wibrown
Review by: mreynolds, vashirov (Thanks!)
|
commit 677a502c13bd5733ffb7f0951d71f96dfaeba169
Author: William Brown <[email protected]>
Date: Tue Jan 30 15:57:17 2018 +1000
Ticket 49554 - update readme
Bug Description: Our readme needs improving.
Fix Description: Improve it with build steps and links, change
to md format.
https://pagure.io/389-ds-base/issue/49554
Author: wibrown
Review by: mreynolds, vashirov (Thanks!)
diff --git a/README b/README
deleted file mode 100644
index 19d2c366c..000000000
--- a/README
+++ /dev/null
@@ -1,12 +0,0 @@
-=======================================================================
- 389 Directory Server
-=======================================================================
-
-The 389 Directory Server is subject to the terms detailed in the
-license agreement file called LICENSE.
-
-Late-breaking news and information on the 389 Directory Server is
-available on our wiki page:
-
- http://www.port389.org/
-
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..0d6de4fa5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,45 @@
+389 Directory Server
+====================
+
+389 Directory Server is a highly usable, fully featured, reliable
+and secure LDAP server implementation. It handles many of the
+largest LDAP deployments in the world.
+
+All our code has been extensively tested with sanitisation tools.
+As well as a rich feature set of fail-over and backup technologies
+gives administrators confidence their accounts are safe.
+
+License
+-------
+
+The 389 Directory Server is subject to the terms detailed in the
+license agreement file called LICENSE.
+
+Late-breaking news and information on the 389 Directory Server is
+available on our wiki page:
+
+ http://www.port389.org/
+
+Building
+--------
+
+ autoreconf -fiv
+ ./configure --enable-debug --with-openldap --enable-cmocka --enable-asan
+ make
+ make lib389
+ make check
+ sudo make install
+ sudo make lib389-install
+
+Testing
+-------
+
+ sudo py.test -s 389-ds-base/dirsrvtests/tests/suites/basic/
+
+More information
+----------------
+
+Please see our contributing guide online:
+
+ http://www.port389.org/docs/389ds/contributing.html
+
| 0 |
10b3110d17b6521c786893ee74a29324552efd5c
|
389ds/389-ds-base
|
Issue 5605 - Adding a slapi_log_backtrace function in libslapd (#5606)
Moving log_stack out of db-mdb code to libslapd and renaming it as slapi_log_backtrace.
|
commit 10b3110d17b6521c786893ee74a29324552efd5c
Author: progier389 <[email protected]>
Date: Mon Jan 16 15:08:54 2023 +0100
Issue 5605 - Adding a slapi_log_backtrace function in libslapd (#5606)
Moving log_stack out of db-mdb code to libslapd and renaming it as slapi_log_backtrace.
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_debug.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_debug.c
index dc7567ea3..7775b4311 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_debug.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_debug.c
@@ -12,7 +12,6 @@
#endif
#include "mdb_layer.h"
-#include <execinfo.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -143,23 +142,10 @@ void dbmdb_format_dbslist_info(char *info, dbmdb_dbi_t *dbi)
}
-void log_stack(int loglvl)
+static inline void log_stack(int loglvl)
{
- /* Log stack (1 error message per frame to avoid log framework buffer overflow) */
- void *frames[100];
- char **symbols;
- int nbframes;
- int i;
-
if (loglvl & dbgmdb_level) {
- nbframes = backtrace(frames, (sizeof frames)/sizeof frames[0]);
- symbols = backtrace_symbols(frames, nbframes);
- if (symbols) {
- for (i=0; i<nbframes; i++) {
- slapi_log_err(SLAPI_LOG_DBGMDB, "log_stack", "\t[%d]\t%s\n", i, symbols[i]);
- }
- free(symbols);
- }
+ slapi_log_backtrace(SLAPI_LOG_DBGMDB);
}
}
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_debug.h b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_debug.h
index 63c3db36b..44079a693 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_debug.h
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_debug.h
@@ -23,7 +23,6 @@ void dbmdb_format_dbslist_info(char *info, dbmdb_dbi_t *dbi);
extern int dbgmdb_level; /* defined in mdb_debug.c */
void dbg_log(const char *file, int lineno, const char *funcname, int loglevel, char *fmt, ...);
void dbgval2str(char *buff, size_t bufsiz, MDB_val *val);
-void log_stack(int loglvl);
void dbmdb_dbg_set_dbi_slots(dbmdb_dbi_t *slots);
/* #define DBMDB_DEBUG 1 */
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
index 526c80f77..c09c3d356 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c
@@ -1190,7 +1190,7 @@ int dbmdb_open_dbi_from_filename(dbmdb_dbi_t **dbi, backend *be, const char *fil
* online import/bulk import/reindex failed and suffix database was cleared)
*/
slapi_log_err(SLAPI_LOG_WARNING, "dbmdb_open_dbi_from_filename", "Attempt to open to open dbi %s/%s while txn is already pending. The only case this message is expected is after a failed import or reindex.\n", be->be_name, filename);
- log_stack(SLAPI_LOG_WARNING);
+ slapi_log_backtrace(SLAPI_LOG_WARNING);
return MDB_NOTFOUND;
}
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c
index 2cd62de70..afc2158e5 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_layer.c
@@ -1545,7 +1545,7 @@ dbi_error_t dbmdb_map_error(const char *funcname, int err)
}
slapi_log_err(SLAPI_LOG_ERR, "dbmdb_map_error",
"%s failed with db error %d : %s\n", funcname, err, msg);
- log_stack(SLAPI_LOG_ERR);
+ slapi_log_backtrace(SLAPI_LOG_ERR);
return DBI_RC_OTHER;
}
}
@@ -2550,11 +2550,11 @@ int dbmdb_public_new_cursor(dbi_db_t *db, dbi_cursor_t *cursor)
rc = MDB_NOTFOUND;
} else if (rc==EINVAL) {
slapi_log_err(SLAPI_LOG_ERR, "dbmdb_public_new_cursor", "Invalid dbi =%d (%s) while opening cursor in txn= %p\n", dbi->dbi, dbi->dbname, TXN(cursor->txn));
- log_stack(SLAPI_LOG_ERR);
+ slapi_log_backtrace(SLAPI_LOG_ERR);
} else {
rc = EINVAL;
slapi_log_err(SLAPI_LOG_ERR, "dbmdb_public_new_cursor", "Failed to open cursor dbi =%d (%s) in txn= %p\n", dbi->dbi, dbi->dbname, TXN(cursor->txn));
- log_stack(SLAPI_LOG_ERR);
+ slapi_log_backtrace(SLAPI_LOG_ERR);
}
}
if (rc && cursor->islocaltxn)
diff --git a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_txn.c b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_txn.c
index 5f41c192a..21c53dd8c 100644
--- a/ldap/servers/slapd/back-ldbm/db-mdb/mdb_txn.c
+++ b/ldap/servers/slapd/back-ldbm/db-mdb/mdb_txn.c
@@ -140,7 +140,7 @@ int dbmdb_start_txn(const char *funcname, dbi_txn_t *parent_txn, int flags, dbi_
*/
slapi_log_error(SLAPI_LOG_CRIT, "dbmdb_start_txn",
"Code issue: Trying to handle a db instance in a thread that is already holding a txn.\n");
- log_stack(SLAPI_LOG_CRIT);
+ slapi_log_backtrace(SLAPI_LOG_CRIT);
abort();
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index f89b24f4f..cef14a2f3 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -33,6 +33,7 @@
#define _PSEP '/'
#include <json-c/json.h>
#include <assert.h>
+#include <execinfo.h>
#ifdef SYSTEMTAP
#include <sys/sdt.h>
@@ -2883,6 +2884,29 @@ slapi_is_loglevel_set(const int loglevel)
return (slapd_ldap_debug & slapi_log_map[loglevel] ? 1 : 0);
}
+/*
+ * Log current thread stack backtrace to the errors log.
+ *
+ * loglevel - The logging level: replication, plugin, etc
+ */
+void
+slapi_log_backtrace(int loglevel)
+{
+ if (slapi_is_loglevel_set(loglevel)) {
+ void *frames[100];
+ int nbframes = backtrace(frames, (sizeof frames)/sizeof frames[0]);
+ char **symbols = backtrace_symbols(frames, nbframes);
+ if (symbols) {
+ /* Logs 1 line per frames to avoid risking log message truncation */
+ for (size_t i=0; i<nbframes; i++) {
+ slapi_log_err(loglevel, "slapi_log_backtrace", "\t[%ld]\t%s\n", i, symbols[i]);
+ }
+ free(symbols);
+ }
+ }
+}
+
+
/******************************************************************************
* write in the access log
******************************************************************************/
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index c5ad49f3d..328bce18d 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1508,6 +1508,8 @@ void slapi_pblock_set_task_warning(Slapi_PBlock *pb, task_warning warning);
int slapi_exists_or_add_internal(Slapi_DN *dn, const char *filter, const char *entry, const char *modifier_name);
+void slapi_log_backtrace(int loglevel);
+
#ifdef __cplusplus
}
#endif
| 0 |
d2f3bc13f8eb834fb1d23f178ad10bc3b3295b48
|
389ds/389-ds-base
|
Resolves: 474945
Summary: Fixed assertion when improperly deleting syntaxinfo.
|
commit d2f3bc13f8eb834fb1d23f178ad10bc3b3295b48
Author: Nathan Kinder <[email protected]>
Date: Mon Jan 19 19:43:47 2009 +0000
Resolves: 474945
Summary: Fixed assertion when improperly deleting syntaxinfo.
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
index a85ec63c7..a65d0a997 100644
--- a/ldap/servers/slapd/attrsyntax.c
+++ b/ldap/servers/slapd/attrsyntax.c
@@ -567,7 +567,6 @@ attr_syntax_add( struct asyntaxinfo *asip )
rc = LDAP_TYPE_OR_VALUE_EXISTS;
goto cleanup_and_return;
}
- attr_syntax_delete(oldas_from_name);
} else if ( NULL != oldas_from_oid ) {
/* failure - OID is in use but name does not exist */
rc = LDAP_TYPE_OR_VALUE_EXISTS;
| 0 |
219bd69fb2ec6ece60f512b97dd525b5287d52b3
|
389ds/389-ds-base
|
Resolves: bug 338991
Bug Description: obsolete values migrated to target instance
Reviewed by: nhosoi (Thanks!)
Fix Description: When fixing the attributes in the old entry, remove any obsolete attributes.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
|
commit 219bd69fb2ec6ece60f512b97dd525b5287d52b3
Author: Rich Megginson <[email protected]>
Date: Fri Oct 19 01:50:15 2007 +0000
Resolves: bug 338991
Bug Description: obsolete values migrated to target instance
Reviewed by: nhosoi (Thanks!)
Fix Description: When fixing the attributes in the old entry, remove any obsolete attributes.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
index a617e8c4d..0de30740d 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -549,7 +549,11 @@ sub fixAttrsInEntry {
my ($ent, $mig, $inst) = @_;
for my $attr (keys %{$ent}) {
my $lcattr = lc $attr;
- if ($transformAttr{$lcattr}) {
+ if ($ignoreOld{$lcattr}) {
+ debug(3, "fixAttrsInEntry: ignoring old invalid or obsolete attr $attr\n");
+ $ent->remove($attr);
+ next;
+ } elsif ($transformAttr{$lcattr}) {
my $newval = &{$transformAttr{$lcattr}}($ent, $attr, $mig, $inst);
if (!$newval) {
debug(2, "Removing attribute $attr from entry ", $ent->getDN(), "\n");
@@ -558,7 +562,7 @@ sub fixAttrsInEntry {
debug(2, "Setting new value $newval for attribute $attr in entry ", $ent->getDN(), "\n");
$ent->setValues($attr, $newval);
}
- }
+ } # else just keep as is
}
}
| 0 |
f2d7a71f1644500aed41439a5916889cc65291ac
|
389ds/389-ds-base
|
Ticket #555 - add fixup-memberuid.pl script
Description: add fixup-memberuid.pl to Makefile.am
https://fedorahosted.org/389/ticket/555
Reviewed by [email protected]
|
commit f2d7a71f1644500aed41439a5916889cc65291ac
Author: Carsten Grzemba <[email protected]>
Date: Fri Jan 11 15:52:43 2013 +0100
Ticket #555 - add fixup-memberuid.pl script
Description: add fixup-memberuid.pl to Makefile.am
https://fedorahosted.org/389/ticket/555
Reviewed by [email protected]
diff --git a/Makefile.am b/Makefile.am
index 04bada83e..a2a1fa1fc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -435,6 +435,7 @@ task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \
ldap/admin/src/scripts/template-db2ldif.pl \
ldap/admin/src/scripts/template-fixup-linkedattrs.pl \
ldap/admin/src/scripts/template-fixup-memberof.pl \
+ ldap/admin/src/scripts/template-fixup-memberuid.pl \
ldap/admin/src/scripts/template-cleanallruv.pl \
ldap/admin/src/scripts/template-ldif2db.pl \
ldap/admin/src/scripts/template-ns-accountstatus.pl \
| 0 |
499758194052323a2b97f15665312aca98f5dcdc
|
389ds/389-ds-base
|
Fix for #157901 : FMR in windows sync agreement code
|
commit 499758194052323a2b97f15665312aca98f5dcdc
Author: David Boreham <[email protected]>
Date: Mon May 16 22:26:25 2005 +0000
Fix for #157901 : FMR in windows sync agreement code
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
index c1a28c937..3ffd3e875 100644
--- a/ldap/servers/plugins/replication/windows_private.c
+++ b/ldap/servers/plugins/replication/windows_private.c
@@ -136,8 +136,9 @@ windows_parse_config_entry(Repl_Agmt *ra, const char *type, Slapi_Entry *e)
{
windows_private_set_windows_domain(ra,tmpstr);
}
+ /* No need to free tmpstr because it was aliased by the call above */
+ tmpstr = NULL;
retval = 1;
- slapi_ch_free((void**)&tmpstr);
}
return retval;
}
| 0 |
acf2c6b2f29de7c03763c278ee7f400b1fac44f7
|
389ds/389-ds-base
|
Fixing a syntax error
ldap/servers/slapd/filterentry.c (line 685) void function cannot return value
|
commit acf2c6b2f29de7c03763c278ee7f400b1fac44f7
Author: Noriko Hosoi <[email protected]>
Date: Mon Apr 19 16:33:09 2010 -0700
Fixing a syntax error
ldap/servers/slapd/filterentry.c (line 685) void function cannot return value
diff --git a/ldap/servers/slapd/filterentry.c b/ldap/servers/slapd/filterentry.c
index fad73624e..d2c977e79 100644
--- a/ldap/servers/slapd/filterentry.c
+++ b/ldap/servers/slapd/filterentry.c
@@ -682,7 +682,7 @@ filter_strcpy_special_ext( char *d, char *s, int flags )
void
filter_strcpy_special( char *d, char *s )
{
- return filter_strcpy_special_ext(d, s, 0);
+ filter_strcpy_special_ext(d, s, 0);
}
int test_substring_filter(
| 0 |
cf11faef091663b2cf52da1e04441d9cb735c42b
|
389ds/389-ds-base
|
Ticket 49024 - Fix the rest of the CI failures
Description: Change errors log paths to the ones from paths.py module.
The rest of the test cases, that failed on CI, passed for me on
the latest version of fedora 389-ds-base package built from master.
https://fedorahosted.org/389/ticket/49024
Reviewed by: mreynolds (Thanks!)
|
commit cf11faef091663b2cf52da1e04441d9cb735c42b
Author: Simon Pichugin <[email protected]>
Date: Wed Nov 9 10:10:51 2016 +0100
Ticket 49024 - Fix the rest of the CI failures
Description: Change errors log paths to the ones from paths.py module.
The rest of the test cases, that failed on CI, passed for me on
the latest version of fedora 389-ds-base package built from master.
https://fedorahosted.org/389/ticket/49024
Reviewed by: mreynolds (Thanks!)
diff --git a/dirsrvtests/tests/tickets/ticket48497_test.py b/dirsrvtests/tests/tickets/ticket48497_test.py
index 3130fc4b3..d8141d5a0 100644
--- a/dirsrvtests/tests/tickets/ticket48497_test.py
+++ b/dirsrvtests/tests/tickets/ticket48497_test.py
@@ -135,8 +135,7 @@ def test_ticket48497_homeDirectory_index_run(topology):
topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args)
log.info("Check indexing succeeded with a specified matching rule")
- file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid)
- file_obj = open(file_path, "r")
+ file_obj = open(topology.standalone.errlog, "r")
# Check if the MR configuration failure occurs
regex = re.compile("unknown or invalid matching rule")
diff --git a/dirsrvtests/tests/tickets/ticket48745_test.py b/dirsrvtests/tests/tickets/ticket48745_test.py
index 4c23d044d..6a0c7f0d3 100644
--- a/dirsrvtests/tests/tickets/ticket48745_test.py
+++ b/dirsrvtests/tests/tickets/ticket48745_test.py
@@ -106,8 +106,7 @@ def test_ticket48745_homeDirectory_indexed_cis(topology):
topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args)
log.info("Check indexing succeeded with a specified matching rule")
- file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid)
- file_obj = open(file_path, "r")
+ file_obj = open(topology.standalone.errlog, "r")
# Check if the MR configuration failure occurs
regex = re.compile("unknown or invalid matching rule")
diff --git a/dirsrvtests/tests/tickets/ticket48746_test.py b/dirsrvtests/tests/tickets/ticket48746_test.py
index 401b30067..0a1399854 100644
--- a/dirsrvtests/tests/tickets/ticket48746_test.py
+++ b/dirsrvtests/tests/tickets/ticket48746_test.py
@@ -104,8 +104,7 @@ def test_ticket48746_homeDirectory_indexed_cis(topology):
topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args)
log.info("Check indexing succeeded with a specified matching rule")
- file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid)
- file_obj = open(file_path, "r")
+ file_obj = open(topology.standalone.errlog, "r")
# Check if the MR configuration failure occurs
regex = re.compile("unknown or invalid matching rule")
@@ -168,8 +167,7 @@ def test_ticket48746_homeDirectory_indexed_ces(topology):
topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args)
log.info("Check indexing succeeded with a specified matching rule")
- file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid)
- file_obj = open(file_path, "r")
+ file_obj = open(topology.standalone.errlog, "r")
# Check if the MR configuration failure occurs
regex = re.compile("unknown or invalid matching rule")
| 0 |
a86ff68e4fe8241a5683f441da5a0eb513e454c1
|
389ds/389-ds-base
|
Issue 49538 - replace cacertdir_rehash with openssl rehash
Bug description: Enable TLS method fails on newer Fedora systems.
It complains that cacertdir_rehash tool is not found.
Fix description: The reason is that authconfig was replaced with
authselect package. Authconfig shipped a tool called cacertdir_rehash
which is no longer available on Fedora. We need to switch to openssl tool:
'c_rehash <directory>' that serves the same purpose and is present on both
RHEL7 and Fedora.
Remove authconfig from 389-ds-base.spec.in because 'cacertdir_rehash'
was the only reason why we had the dependency.
Add openssl-perl dependency to the SPEC file.
Eventially, c_rehash will go away but for now we keep it for RHEL7 compatibility.
Fix a small thing in remove_ds_instance function.
We should ignore FileNotFound errors while removing the instance.
https://pagure.io/389-ds-base/issue/49538
Reviewed by: mreynolds, mhonek (Thanks!)
|
commit a86ff68e4fe8241a5683f441da5a0eb513e454c1
Author: Simon Pichugin <[email protected]>
Date: Mon Apr 23 15:12:06 2018 +0200
Issue 49538 - replace cacertdir_rehash with openssl rehash
Bug description: Enable TLS method fails on newer Fedora systems.
It complains that cacertdir_rehash tool is not found.
Fix description: The reason is that authconfig was replaced with
authselect package. Authconfig shipped a tool called cacertdir_rehash
which is no longer available on Fedora. We need to switch to openssl tool:
'c_rehash <directory>' that serves the same purpose and is present on both
RHEL7 and Fedora.
Remove authconfig from 389-ds-base.spec.in because 'cacertdir_rehash'
was the only reason why we had the dependency.
Add openssl-perl dependency to the SPEC file.
Eventially, c_rehash will go away but for now we keep it for RHEL7 compatibility.
Fix a small thing in remove_ds_instance function.
We should ignore FileNotFound errors while removing the instance.
https://pagure.io/389-ds-base/issue/49538
Reviewed by: mreynolds, mhonek (Thanks!)
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index 28c813698..0e6bbc5e5 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -267,9 +267,9 @@ BuildArch: noarch
Group: Development/Libraries
Requires: krb5-workstation
Requires: openssl
+# This is for /usr/bin/c_rehash tool
+Requires: openssl-perl
Requires: iproute
-# This is for /usr/sbin/cacertdir_rehash
-Requires: authconfig
Requires: python%{python3_pkgversion}
Requires: python%{python3_pkgversion}-pytest
Requires: python%{python3_pkgversion}-pyldap
diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py
index 440ff7ba9..25d56a3ab 100644
--- a/src/lib389/lib389/instance/remove.py
+++ b/src/lib389/lib389/instance/remove.py
@@ -51,7 +51,10 @@ def remove_ds_instance(dirsrv):
shutil.rmtree(config_dir_rm)
_log.debug("Copying %s to %s" % (config_dir, config_dir_rm))
- shutil.copytree(config_dir, config_dir_rm)
+ try:
+ shutil.copytree(config_dir, config_dir_rm)
+ except FileNotFoundError:
+ pass
# Remove these paths:
# for path in ('backup_dir', 'cert_dir', 'config_dir', 'db_dir',
diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py
index f8f2f2f4a..7c78d4911 100644
--- a/src/lib389/lib389/nss_ssl.py
+++ b/src/lib389/lib389/nss_ssl.py
@@ -201,7 +201,7 @@ class NssSsl(object):
certdetails = check_output(cmd, stderr=subprocess.STDOUT)
with open('%s/ca.crt' % self._certdb, 'w') as f:
f.write(ensure_str(certdetails))
- check_output(['/usr/sbin/cacertdir_rehash', self._certdb], stderr=subprocess.STDOUT)
+ check_output(['/usr/bin/c_rehash', self._certdb], stderr=subprocess.STDOUT)
return True
def _rsa_cert_list(self):
@@ -423,7 +423,7 @@ class NssSsl(object):
to our database.
"""
shutil.copyfile(ca, '%s/ca.crt' % self._certdb)
- check_output(['/usr/sbin/cacertdir_rehash', self._certdb], stderr=subprocess.STDOUT)
+ check_output(['/usr/bin/c_rehash', self._certdb], stderr=subprocess.STDOUT)
check_output([
'/usr/bin/certutil',
'-A',
| 0 |
7e49dec0ccabeb7df0c4ab7ca7e94282620fdd17
|
389ds/389-ds-base
|
Ticket 49837 - Add new password policy attributes to UI
Description: Added new password policy features to UI.
Also made change to instance creation to line up
with changes going on in lib389
https://pagure.io/389-ds-base/issue/49837
Reviewed by: spichugi(Thanks!)
|
commit 7e49dec0ccabeb7df0c4ab7ca7e94282620fdd17
Author: Mark Reynolds <[email protected]>
Date: Mon Jul 9 14:32:08 2018 -0400
Ticket 49837 - Add new password policy attributes to UI
Description: Added new password policy features to UI.
Also made change to instance creation to line up
with changes going on in lib389
https://pagure.io/389-ds-base/issue/49837
Reviewed by: spichugi(Thanks!)
diff --git a/src/cockpit/389-console/css/ds.css b/src/cockpit/389-console/css/ds.css
index bf77a6ba5..833dfa3c4 100644
--- a/src/cockpit/389-console/css/ds.css
+++ b/src/cockpit/389-console/css/ds.css
@@ -370,8 +370,25 @@ Zbutton:focus {
}
.ds-input {
+ margin-top: 5px !important;
+ padding-right: 5px !important;
+ padding-left: 5px !important;
+}
+
+.ds-pw-input {
+ margin-top: 5px;
padding-right: 5px;
padding-left: 5px !important;
+ min-width: 65px !important;
+ max-width: 65px !important;
+}
+
+.ds-pw-list-input {
+ margin-top: 5px;
+ padding-right: 5px;
+ padding-left: 5px !important;
+ min-width: 150px !important;
+ max-width: 150px !important;
}
.ds-ro-input {
@@ -885,6 +902,12 @@ Zbutton:focus {
width: 285px !important;
}
+.ds-pw-list-label {
+ margin-top: 7px !important;
+ margin-bottom: 7px !important;
+ width: 200px !important;
+}
+
.ds-passwd-label {
width: 300px !important;
}
@@ -1281,7 +1304,7 @@ option {
}
.ds-checkbox-group {
- margin-top: 10px;
+ margin-top: 10px !important;
}
.ds-alert-header {
diff --git a/src/cockpit/389-console/js/servers.js b/src/cockpit/389-console/js/servers.js
index 358987d9a..824d96ba2 100644
--- a/src/cockpit/389-console/js/servers.js
+++ b/src/cockpit/389-console/js/servers.js
@@ -1384,7 +1384,7 @@ $(document).ready( function() {
// TODO - lookup the entry, and get the current settings
// Set the form header and fields
- $("#local-pwp-form-header").html("<b>Edit Local Password Policy</b>");
+ $("#local-pwp-header").html("<b>Edit Local Password Policy</b>");
$("#local-entry-dn").val(policy_name);
// Set radio button for type of policy - TODO
diff --git a/src/cockpit/389-console/servers.html b/src/cockpit/389-console/servers.html
index 93b6728df..d357a5bbe 100644
--- a/src/cockpit/389-console/servers.html
+++ b/src/cockpit/389-console/servers.html
@@ -354,7 +354,7 @@
<div class="ds-inline">
<h4><br>Password Syntax Settings</h4>
- <hr class="ds-hr-pwp">
+ <hr class="ds-hr">
<input type="checkbox" class="ds-config-checkbox" id="passwordchecksyntax" checked><label
for="passwordchecksyntax" class="ds-label" title="Enable account lockout (passwordCheckSyntax).">Check Password Syntax</label>
<div class="ds-container ds-expired-div" id="syntax-attrs">
@@ -384,10 +384,6 @@
"Reject passwords with fewer than this many lowercase characters (passwordMinLowers).">Minimum Lowercase Characters </label><input
class="ds-input" type="text" id="passwordminlowers" size="5"/>
</div>
- </div>
- <div class="ds-divider"></div>
- <div class="ds-divider"></div>
- <div class="ds-inline">
<div>
<label for="passwordminspecials" class="ds-expire-label" title=
"Reject passwords with fewer than this many special non-alphanumeric characters (passwordMinSpecials).">Minimum Special Characters </label><input
@@ -398,11 +394,6 @@
"Reject passwords with fewer than this many 8-bit or multi-byte characters (passwordMin8Bit).">Minimum 8-bit Characters </label><input
class="ds-input" type="text" id="passwordmin8bit" size="5"/>
</div>
- <div>
- <label for="passwordmaxrepeats" class="ds-expire-label" title=
- "The maximum number of times the same character can sequentially appear in a password (passwordMaxRepeats).">Maximum Number Of Repeated Characters </label><input
- class="ds-input" type="text" id="passwordmaxrepeats" size="5"/>
- </div>
<div>
<label for="passwordmincategories" class="ds-expire-label" title=
"The minimum number of character categories that a password must contain (categories are upper, lower, digit, special, and 8-bit) (passwordMinCategories).">Minimum Required Character Categories </label><input
@@ -414,6 +405,50 @@
class="ds-input" type="text" id="passwordmintokenlength" size="5"/>
</div>
</div>
+ <div class="ds-divider"></div>
+ <div class="ds-divider"></div>
+ <div class="ds-inline">
+ <div>
+ <label for="passwordbadwords" class="ds-expire-label" title=
+ "A space-separated list of words that are not allowed to be contained in the new password (passwordBadWords).">Reject Passwords That Contain These Words </label><input
+ class="ds-input" type="text" id="passwordbadwords" size="20"/>
+ </div>
+ <div>
+ <label for="passworduserattributes" class="ds-expire-label" title=
+ "A space-separated list of entry attributes to compare to the new password (passwordUserAttributes).">Entry Attributes To Compare </label><input
+ class="ds-input" type="text" id="passworduserattributes" size="20"/>
+ </div>
+ <div>
+ <label for="passwordmaxrepeats" class="ds-expire-label" title=
+ "The maximum number of times the same character can sequentially appear in a password (passwordMaxRepeats).">Maximum Number Of Repeated Characters </label><input
+ class="ds-input" type="text" id="passwordmaxrepeats" size="5"/>
+ </div>
+ <div>
+ <label for="passwordmaxsequence" class="ds-expire-label" title=
+ "The maximum number of allowed monotonic characters sequences (passwordMaxSequence).">Maximum Character Sequences </label><input
+ class="ds-input" type="text" id="passwordmaxsequence" size="5"/>
+ </div>
+ <div>
+ <label for="passwordmaxseqsets" class="ds-expire-label" title=
+ "The maximum number of allowed monotonic characters sequences that can appear more than once (passwordMaxSeqSets).">Maximum Character Sequence Sets </label><input
+ class="ds-input" type="text" id="passwordmaxseqsets" size="5"/>
+ </div>
+ <div>
+ <label for="passwordmaxclasschars" class="ds-expire-label" title=
+ "The maximum number of consecutive characters from the same character class/category (passwordMaxClassChars).">Maximum Consecutive Chars Per Char Class </label><input
+ class="ds-input" type="text" id="passwordmaxclasschars" size="5"/>
+ </div>
+ <div>
+ <label for="passwordpalindrome" class="ds-expire-label" title=
+ "Reject a password if it is a palindrome (passwordPalindrome).">Reject Passwords that Are Palindromes </label><input
+ class="ds-checkbox-group" type="checkbox" id="passwordpalindrome"/>
+ </div>
+ <div>
+ <label for="passworddictcheck" class="ds-expire-label" title=
+ "Check the password against the system's CrackLib dictionary (passwordDictCheck).">Check Password Contains Dictionary Word </label><input
+ class="ds-checkbox-group" type="checkbox" id="passworddictcheck"/>
+ </div>
+ </div>
</div>
<div class="ds-footer">
<button class="btn btn-primary save-button">Save</button>
@@ -1057,14 +1092,14 @@
<!-- Create Local Password Policy -->
- <div class="modal fade" id="local-pwp-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="local-pwp-label" aria-hidden="true">
+ <div class="modal fade" id="local-pwp-form" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="local-pwp-header" aria-hidden="true">
<div class="modal-dialog ds-modal-wide">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">
<span class="pficon pficon-close"></span>
</button>
- <h4 class="modal-title" id="local-pwp-label">Create Local Password Policy</h4>
+ <h4 class="modal-title" id="local-pwp-header">Create Local Password Policy</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
@@ -1203,38 +1238,59 @@
<div>
<label for="local-passwordminlength" class="ds-expire-label" title=
"The minimum number of characters in the password (passwordMinLength).">Password Minimum Length </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordminlength" size="5"/>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordminlength" size="5"/>
<label for="local-passwordmindigits" class="ds-expire-label" title=
"Reject passwords with fewer than this many digit characters (0-9) (passwordMinDigits).">Minimum Digit Characters </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordmindigits" size="5"/>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordmindigits" size="5"/>
<label for="local-passwordminalphas" class="ds-expire-label" title=
"Reject passwords with fewer than this many alpha characters (passwordMinAlphas).">Minimum Alpha Characters </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordminalphas" size="5"/>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordminalphas" size="5"/>
<label for="local-passwordminuppers" class="ds-expire-label" title=
"Reject passwords with fewer than this many uppercase characters (passwordMinUppers).">Minimum Uppercase Characters </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordminuppers" size="5"/>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordminuppers" size="5"/>
<label for="local-passwordminlowers" class="ds-expire-label" title=
"Reject passwords with fewer than this many lowercase characters (passwordMinLowers).">Minimum Lowercase Characters </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordminlowers" size="5"/>
- </div>
- <div class="ds-divider"></div>
- <div class="ds-divider"></div>
- <div>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordminlowers" size="5"/>
<label for="local-passwordminspecials" class="ds-expire-label" title=
"Reject passwords with fewer than this many special non-alphanumeric characters (passwordMinSpecials).">Minimum Special Characters </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordminspecials" size="5"/>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordminspecials" size="5"/>
<label for="local-passwordmin8bit" class="ds-expire-label" title=
"Reject passwords with fewer than this many 8-bit or multi-byte characters (passwordMin8Bit).">Minimum 8-bit Characters </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordmin8bit" size="5"/>
- <label for="local-passwordmaxrepeats" class="ds-expire-label" title=
- "The maximum number of times the same character can sequentially appear in a password (passwordMaxRepeats).">Maximum Number Of Repeated Characters </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordmaxrepeats" size="5"/>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordmin8bit" size="5"/>
<label for="local-passwordmincategories" class="ds-expire-label" title=
"The minimum number of character categories that a password must contain (categories are upper, lower, digit, special, and 8-bit) (passwordMinCategories).">Minimum Required Character Categories </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordmincategories" size="5"/>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordmincategories" size="5"/>
<label for="local-passwordmintokenlength" class="ds-expire-label" title=
"The smallest attribute value used when checking if the password contains any of the user's account information (passwordMinTokenLength).">Minimum Token Length </label><input
- class="ds-input ds-pwp-input" type="text" id="local-passwordmintokenlength" size="5"/>
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordmintokenlength" size="5"/>
+ </div>
+ <div class="ds-divider"></div>
+ <div class="ds-divider"></div>
+ <div>
+ <label for="local-passwordbadwords" class="ds-pw-list-label" title=
+ "A space-separated list of words that are not allowed to be contained in the new password (passwordBadWords).">Reject Passwords That Contain These Words </label><input
+ class="ds-pw-list-input ds-pwp-input" type="text" id="local-passwordbadwords"/>
+ <label for="local-passworduserattributes" class="ds-pw-list-label" title=
+ "A space-separated list of entry attributes to compare to the new password (passwordUserAttributes).">Entry Attributes To Compare </label><input
+ class="ds-pw-list-input ds-pwp-input" type="text" id="local-passworduserattributes"/>
+ <label for="local-passwordmaxrepeats" class="ds-expire-label" title=
+ "The maximum number of times the same character can sequentially appear in a password (passwordMaxRepeats).">Maximum Number Of Repeated Characters </label><input
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordmaxrepeats"/>
+ <label for="local-passwordmaxsequence" class="ds-expire-label" title=
+ "The maximum number of allowed monotonic characters sequences (passwordMaxSequence).">Maximum Character Sequences </label><input
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordmaxsequence"/>
+ <label for="local-passwordmaxseqsets" class="ds-expire-label" title=
+ "The maximum number of allowed monotonic characters sequences that can appear more than once (passwordMaxSeqSets).">Maximum Character Sequence Sets </label><input
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordmaxseqsets"/>
+ <label for="local-passwordmaxclasschars" class="ds-expire-label" title=
+ "The maximum number of consecutive characters from the same character class/category (passwordMaxClassChars).">Maximum Consecutive Chars Per Char Class </label><input
+ class="ds-pw-input ds-pwp-input" type="text" id="local-passwordmaxclasschars"/>
+ <label for="local-passwordpalindrome" class="ds-expire-label" title=
+ "Reject a password if it is a palindrome (passwordPalindrome).">Reject Passwords that Are Palindromes </label><input
+ class="ds-checkbox-group ds-pwp-checkbox" type="checkbox" id="local-passwordpalindrome"/>
+ <label for="local-passworddictcheck" class="ds-expire-label" title=
+ "Check the password against the system's CrackLib dictionary (passwordDictCheck).">Check Password Contains Dictionary Word </label><input
+ class="ds-checkbox-group ds-pwp-checkbox" type="checkbox" id="local-passworddictcheck"/>
</div>
</div>
</form>
| 0 |
005d08e5b1e06a1c7461d67122c8695ec7163003
|
389ds/389-ds-base
|
Bump version to 2.4.2
|
commit 005d08e5b1e06a1c7461d67122c8695ec7163003
Author: Mark Reynolds <[email protected]>
Date: Mon Jul 10 11:55:29 2023 -0400
Bump version to 2.4.2
diff --git a/VERSION.sh b/VERSION.sh
index 9ff466074..f765f1139 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -10,7 +10,7 @@ vendor="389 Project"
# PACKAGE_VERSION is constructed from these
VERSION_MAJOR=2
VERSION_MINOR=4
-VERSION_MAINT=1
+VERSION_MAINT=2
# NOTE: VERSION_PREREL is automatically set for builds made out of a git tree
VERSION_PREREL=
VERSION_DATE=$(date -u +%Y%m%d%H%M)
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.