commit_id
string | repo
string | commit_message
string | diff
string | label
int64 |
---|---|---|---|---|
f646bd326a4494cb1a0e7d2d3ea556677b5197eb
|
389ds/389-ds-base
|
Ticket #47664 - Page control does not work if effective rights control is specified
Bug Description: If an effective rights control and a simple paged
results control were specified in one search request, the simple
paged results control was ignored.
Fix Description: In the search iteration code, handling the simple
paged results was not fully implemented. This patch adds it.
https://fedorahosted.org/389/ticket/47664
Reviewed by [email protected] (Thank you, Mark!!)
|
commit f646bd326a4494cb1a0e7d2d3ea556677b5197eb
Author: Noriko Hosoi <[email protected]>
Date: Tue Jul 15 13:33:11 2014 -0700
Ticket #47664 - Page control does not work if effective rights control is specified
Bug Description: If an effective rights control and a simple paged
results control were specified in one search request, the simple
paged results control was ignored.
Fix Description: In the search iteration code, handling the simple
paged results was not fully implemented. This patch adds it.
https://fedorahosted.org/389/ticket/47664
Reviewed by [email protected] (Thank you, Mark!!)
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index e222b0564..4e06652a3 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -1302,16 +1302,26 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY, &e);
/* Check for possible get_effective_rights control */
- if ( operation->o_flags & OP_FLAG_GET_EFFECTIVE_RIGHTS )
- {
+ if (e) {
+ if (operation->o_flags & OP_FLAG_GET_EFFECTIVE_RIGHTS) {
char *errbuf = NULL;
char **gerattrs = NULL;
char **gerattrsdup = NULL;
char **gap = NULL;
char *gapnext = NULL;
- slapi_pblock_get( pb, SLAPI_SEARCH_GERATTRS, &gerattrs );
+ if (PAGEDRESULTS_PAGE_END == pr_stat)
+ {
+ /*
+ * read ahead -- there is at least more entry.
+ * undo it and return the PAGE_END
+ */
+ be->be_prev_search_results(pb);
+ done = 1;
+ continue;
+ }
+ slapi_pblock_get( pb, SLAPI_SEARCH_GERATTRS, &gerattrs );
gerattrsdup = cool_charray_dup(gerattrs);
gap = gerattrsdup;
do
@@ -1414,15 +1424,15 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
while (gap && ++gap && *gap);
slapi_pblock_set( pb, SLAPI_SEARCH_GERATTRS, gerattrs );
cool_charray_free(gerattrsdup);
- if (NULL == e)
- {
- /* no more entries */
- done = 1;
- pr_stat = PAGEDRESULTS_SEARCH_END;
+ if (pagesize == *pnentries)
+ {
+ /* PAGED RESULTS: reached the pagesize */
+ /* We don't set "done = 1" here.
+ * We read ahead next entry to check whether there is
+ * more entries to return or not. */
+ pr_stat = PAGEDRESULTS_PAGE_END;
}
- }
- else if (e)
- {
+ } else { /* not GET_EFFECTIVE_RIGHTS */
if (PAGEDRESULTS_PAGE_END == pr_stat)
{
/*
@@ -1469,6 +1479,7 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
* more entries to return or not. */
pr_stat = PAGEDRESULTS_PAGE_END;
}
+ }
}
else
{
| 0 |
c712b3dee5cae28cb22d955826ef2b23b91b9456
|
389ds/389-ds-base
|
Pick up new ldapconsole
|
commit c712b3dee5cae28cb22d955826ef2b23b91b9456
Author: Nathan Kinder <[email protected]>
Date: Fri Apr 15 23:34:44 2005 +0000
Pick up new ldapconsole
diff --git a/component_versions.mk b/component_versions.mk
index 8e5daa6b5..7ef36ab7d 100644
--- a/component_versions.mk
+++ b/component_versions.mk
@@ -173,7 +173,7 @@ ifndef LDAPCONSOLE_COMP
LDAPCONSOLE_COMP = ldapconsole$(LDAPCONSOLE_REL)
endif
ifndef LDAPCONSOLE_RELDATE
- LDAPCONSOLE_RELDATE=20050405
+ LDAPCONSOLE_RELDATE=20050415
endif
ifndef PERLDAP_VERSION
| 0 |
14890380c5fbc8e07eb68c3e19d99f0a7e2def1e
|
389ds/389-ds-base
|
Issue: 48064
Bug Description: CI test - disk_monitoring
Fix Description: Scripts are ported
https://pagure.io/389-ds-base/issue/48064
Reviewed by: Simon Pichugin
|
commit 14890380c5fbc8e07eb68c3e19d99f0a7e2def1e
Author: Anuj Borah <[email protected]>
Date: Mon Dec 17 16:04:12 2018 +0530
Issue: 48064
Bug Description: CI test - disk_monitoring
Fix Description: Scripts are ported
https://pagure.io/389-ds-base/issue/48064
Reviewed by: Simon Pichugin
diff --git a/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py b/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py
new file mode 100644
index 000000000..1da221232
--- /dev/null
+++ b/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py
@@ -0,0 +1,569 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2018 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+
+import os
+import subprocess
+import re
+import time
+import pytest
+from lib389.tasks import *
+from lib389._constants import *
+from lib389.utils import ensure_bytes
+from lib389.topologies import topology_st as topo
+from lib389.paths import *
+from lib389.idm.user import UserAccounts
+
+
+THRESHOLD = '30'
+THRESHOLD_BYTES = '30000000'
+
+
+def _withouterrorlog(topo, condition, maxtimesleep):
+ timecount = 0
+ while eval(condition):
+ time.sleep(1)
+ timecount += 1
+ if timecount >= maxtimesleep: break
+ assert not eval(condition)
+
+
+def _witherrorlog(topo, condition, maxtimesleep):
+ timecount = 0
+ with open(topo.standalone.errlog, 'r') as study: study = study.read()
+ while condition not in study:
+ time.sleep(1)
+ with open(topo.standalone.errlog, 'r') as study: study = study.read()
+ if timecount >= maxtimesleep: break
+ assert condition in study
+
+
+def presetup(topo):
+ """
+ This is function is part of fixture function setup , will setup the environment for this test.
+ """
+ topo.standalone.stop()
+ if os.path.exists(topo.standalone.ds_paths.log_dir):
+ subprocess.call(['mount', '-t', 'tmpfs', '-o', 'size=35M', 'tmpfs', topo.standalone.ds_paths.log_dir])
+ else:
+ os.mkdir(topo.standalone.ds_paths.log_dir)
+ subprocess.call(['mount', '-t', 'tmpfs', '-o', 'size=35M', 'tmpfs', topo.standalone.ds_paths.log_dir])
+ subprocess.call('chown {}: -R {}'.format(DEFAULT_USER, topo.standalone.ds_paths.log_dir), shell=True)
+ subprocess.call('chown {}: -R {}/*'.format(DEFAULT_USER, topo.standalone.ds_paths.log_dir), shell=True)
+ subprocess.call('restorecon -FvvR {}'.format(topo.standalone.ds_paths.log_dir), shell=True)
+ topo.standalone.start()
+
+
+def setupthesystem(topo):
+ """
+ This function is part of fixture function setup , will setup the environment for this test.
+ """
+ global TOTAL_SIZE, USED_SIZE, AVAIL_SIZE, HALF_THR_FILL_SIZE, FULL_THR_FILL_SIZE
+ topo.standalone.start()
+ topo.standalone.config.set('nsslapd-disk-monitoring-grace-period', '1')
+ topo.standalone.config.set('nsslapd-accesslog-logbuffering', 'off')
+ topo.standalone.config.set('nsslapd-disk-monitoring-threshold', ensure_bytes(THRESHOLD_BYTES))
+ TOTAL_SIZE = int(re.findall('\d+', str(os.statvfs(topo.standalone.ds_paths.log_dir)))[2])*4096/1024/1024
+ AVAIL_SIZE = round(int(re.findall('\d+', str(os.statvfs(topo.standalone.ds_paths.log_dir)))[3]) * 4096 / 1024 / 1024)
+ USED_SIZE = TOTAL_SIZE - AVAIL_SIZE
+ HALF_THR_FILL_SIZE = TOTAL_SIZE - float(THRESHOLD) + 5 - USED_SIZE
+ FULL_THR_FILL_SIZE = TOTAL_SIZE - 0.5 * float(THRESHOLD) + 5 - USED_SIZE
+ HALF_THR_FILL_SIZE = round(HALF_THR_FILL_SIZE)
+ FULL_THR_FILL_SIZE = round(FULL_THR_FILL_SIZE)
+ topo.standalone.restart()
+
+
[email protected](scope="function")
+def setup(topo):
+ """
+ This is the fixture function , will run before running every test case.
+ """
+ presetup(topo)
+ setupthesystem(topo)
+ # Resetting the error log file before we go for the test.
+ open('{}/errors'.format(topo.standalone.ds_paths.log_dir), 'w').close()
+
+
+def test_verify_operation_when_disk_monitoring_is_off(topo, setup):
+ """
+ Verify operation when Disk monitoring is off
+ :id: 73a97536-fe9e-11e8-ba9f-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Turn off disk monitoring
+ 2. Go below the threshold
+ 3. Check DS is up and not entering shutdown mode
+ :expectedresults:
+ 1. Should Success
+ 2. Should Success
+ 3. Should Success
+ """
+ try:
+ # Turn off disk monitoring
+ topo.standalone.config.set('nsslapd-disk-monitoring', 'off')
+ topo.standalone.restart()
+ # go below the threshold
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE)])
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo1'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE)])
+ # Wait for disk monitoring plugin thread to wake up
+ _withouterrorlog(topo, 'topo.standalone.status() != True', 10)
+ # Check DS is up and not entering shutdown mode
+ assert topo.standalone.status() == True
+ finally:
+ os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir))
+ os.remove('{}/foo1'.format(topo.standalone.ds_paths.log_dir))
+
+
+def test_free_up_the_disk_space_and_change_ds_config(topo, setup):
+ """
+ Free up the disk space and change DS config
+ :id: 7be4d560-fe9e-11e8-a307-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Enabling Disk Monitoring plugin and setting disk monitoring logging to critical
+ 2. Verify no message about loglevel is present in the error log
+ 3. Verify no message about disabling logging is present in the error log
+ 4. Verify no message about removing rotated logs is present in the error log
+ :expectedresults:
+ 1. Should Success
+ 2. Should Success
+ 3. Should Success
+ 4. Should Success
+ """
+ # Enabling Disk Monitoring plugin and setting disk monitoring logging to critical
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'on')
+ assert topo.standalone.config.set('nsslapd-errorlog-level', '8')
+ topo.standalone.restart()
+ # Verify no message about loglevel is present in the error log
+ # Verify no message about disabling logging is present in the error log
+ # Verify no message about removing rotated logs is present in the error log
+ with open(topo.standalone.errlog, 'r') as study: study = study.read()
+ assert 'temporarily setting error loglevel to zero' not in study
+ assert 'disabling access and audit logging' not in study
+ assert 'deleting rotated logs' not in study
+
+
+def test_verify_operation_with_nsslapd_disk_monitoring_logging_critical_off(topo, setup):
+ """
+ Verify operation with "nsslapd-disk-monitoring-logging-critical: off
+ :id: 82363bca-fe9e-11e8-9ae7-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Verify that verbose logging was set to default level
+ 2. Verify that logging is disabled
+ 3. Verify that rotated logs were not removed
+ :expectedresults:
+ 1. Should Success
+ 2. Should Success
+ 3. Should Success
+ """
+ try:
+ # Verify that verbose logging was set to default level
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'off')
+ assert topo.standalone.config.set('nsslapd-errorlog-level', '8')
+ topo.standalone.restart()
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(HALF_THR_FILL_SIZE)])
+ _witherrorlog(topo, 'temporarily setting error loglevel to the default level', 11)
+ assert LOG_DEFAULT == int(re.findall('nsslapd-errorlog-level: \d+', str(
+ topo.standalone.search_s('cn=config', ldap.SCOPE_SUBTREE, '(objectclass=*)', ['nsslapd-errorlog-level'])))[
+ 0].split(' ')[1])
+ # Verify that logging is disabled
+ _withouterrorlog(topo, "topo.standalone.config.get_attr_val_utf8('nsslapd-accesslog-logging-enabled') != 'off'", 10)
+ assert topo.standalone.config.get_attr_val_utf8('nsslapd-accesslog-logging-enabled') == 'off'
+ # Verify that rotated logs were not removed
+ with open(topo.standalone.errlog, 'r') as study: study = study.read()
+ assert 'disabling access and audit logging' in study
+ _witherrorlog(topo, 'deleting rotated logs', 11)
+ study = open(topo.standalone.errlog).read()
+ assert "Unable to remove file: {}".format(topo.standalone.ds_paths.log_dir) not in study
+ assert 'is too far below the threshold' not in study
+ finally:
+ os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir))
+
+
+def test_operation_with_nsslapd_disk_monitoring_logging_critical_on_below_half_of_the_threshold(topo, setup):
+ """
+ Verify operation with \"nsslapd-disk-monitoring-logging-critical: on\" below 1/2 of the threshold
+ Verify recovery
+ :id: 8940c502-fe9e-11e8-bcc0-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Verify that DS goes into shutdown mode
+ 2. Verify that DS exited shutdown mode
+ :expectedresults:
+ 1. Should Success
+ 2. Should Success
+ """
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'on')
+ topo.standalone.restart()
+ # Verify that DS goes into shutdown mode
+ if float(THRESHOLD) > FULL_THR_FILL_SIZE:
+ FULL_THR_FILL_SIZE_new = FULL_THR_FILL_SIZE + round(float(THRESHOLD) - FULL_THR_FILL_SIZE) + 1
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE_new)])
+ else:
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE)])
+ _witherrorlog(topo, 'is too far below the threshold', 20)
+ os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir))
+ # Verify that DS exited shutdown mode
+ _witherrorlog(topo, 'Available disk space is now acceptable', 25)
+
+
+def test_setting_nsslapd_disk_monitoring_logging_critical_to_off(topo, setup):
+ """
+ Setting nsslapd-disk-monitoring-logging-critical to \"off\
+ :id: 93265ec4-fe9e-11e8-af93-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Setting nsslapd-disk-monitoring-logging-critical to \"off\
+ :expectedresults:
+ 1. Should Success
+ """
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'off')
+ assert topo.standalone.config.set('nsslapd-errorlog-level', '8')
+ topo.standalone.restart()
+ assert topo.standalone.status() == True
+
+
+def test_operation_with_nsslapd_disk_monitoring_logging_critical_off(topo, setup):
+ """
+ Verify operation with \"nsslapd-disk-monitoring-logging-critical: off
+ :id: 97985a52-fe9e-11e8-9914-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Verify that logging is disabled
+ 2. Verify that rotated logs were removed
+ 3. Verify that verbose logging was set to default level
+ 4. Verify that logging is disabled
+ 5. Verify that rotated logs were removed
+ :expectedresults:
+ 1. Should Success
+ 2. Should Success
+ 3. Should Success
+ 4. Should Success
+ 5. Should Success
+ """
+ # Verify that logging is disabled
+ try:
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'off')
+ assert topo.standalone.config.set('nsslapd-errorlog-level', '8')
+ assert topo.standalone.config.set('nsslapd-accesslog-maxlogsize', '1')
+ assert topo.standalone.config.set('nsslapd-accesslog-logrotationtimeunit', 'minute')
+ assert topo.standalone.config.set('nsslapd-accesslog-level', '772')
+ topo.standalone.restart()
+ # Verify that rotated logs were removed
+ users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ for i in range(10):
+ user_properties = {
+ 'uid': 'cn=anuj{}'.format(i),
+ 'cn': 'cn=anuj{}'.format(i),
+ 'sn': 'cn=anuj{}'.format(i),
+ 'userPassword': "Itsme123",
+ 'uidNumber': '1{}'.format(i),
+ 'gidNumber': '2{}'.format(i),
+ 'homeDirectory': '/home/{}'.format(i)
+ }
+ users.create(properties=user_properties)
+ for j in range(100):
+ for i in [i for i in users.list()]: i.bind('Itsme123')
+ assert re.findall('access.\d+-\d+',str(os.listdir(topo.standalone.ds_paths.log_dir)))
+ topo.standalone.bind_s(DN_DM, PW_DM)
+ assert topo.standalone.config.set('nsslapd-accesslog-maxlogsize', '100')
+ assert topo.standalone.config.set('nsslapd-accesslog-logrotationtimeunit', 'day')
+ assert topo.standalone.config.set('nsslapd-accesslog-level', '256')
+ topo.standalone.restart()
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo2'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(HALF_THR_FILL_SIZE)])
+ # Verify that verbose logging was set to default level
+ _witherrorlog(topo, 'temporarily setting error loglevel to the default level', 10)
+ assert LOG_DEFAULT == int(re.findall('nsslapd-errorlog-level: \d+', str(
+ topo.standalone.search_s('cn=config', ldap.SCOPE_SUBTREE, '(objectclass=*)', ['nsslapd-errorlog-level'])))[0].split(' ')[1])
+ # Verify that logging is disabled
+ _withouterrorlog(topo, "topo.standalone.config.get_attr_val_utf8('nsslapd-accesslog-logging-enabled') != 'off'", 20)
+ with open(topo.standalone.errlog, 'r') as study: study = study.read()
+ assert 'disabling access and audit logging' in study
+ # Verify that rotated logs were removed
+ _witherrorlog(topo, 'deleting rotated logs', 10)
+ with open(topo.standalone.errlog, 'r') as study:study = study.read()
+ assert 'Unable to remove file:' not in study
+ assert 'is too far below the threshold' not in study
+ for i in [i for i in users.list()]: i.delete()
+ finally:
+ os.remove('{}/foo2'.format(topo.standalone.ds_paths.log_dir))
+
+
+def test_operation_with_nsslapd_disk_monitoring_logging_critical_off_below_half_of_the_threshold(topo, setup):
+ """
+ Verify operation with \"nsslapd-disk-monitoring-logging-critical: off\" below 1/2 of the threshold
+ Verify shutdown
+ Recovery and setup
+ :id: 9d4c7d48-fe9e-11e8-b5d6-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Verify that DS goes into shutdown mode
+ 2. Verifying that DS has been shut down after the grace period
+ 3. Verify logging enabled
+ 4. Create rotated logfile
+ 5. Enable verbose logging
+ :expectedresults:
+ 1. Should Success
+ 2. Should Success
+ 3. Should Success
+ 4. Should Success
+ 5. Should Success
+ """
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'off')
+ topo.standalone.restart()
+ # Verify that DS goes into shutdown mode
+ if float(THRESHOLD) > FULL_THR_FILL_SIZE:
+ FULL_THR_FILL_SIZE_new = FULL_THR_FILL_SIZE + round(float(THRESHOLD) - FULL_THR_FILL_SIZE)
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE_new)])
+ else:
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE)])
+ # Increased sleep to avoid failure
+ _witherrorlog(topo, 'is too far below the threshold', 100)
+ _witherrorlog(topo, 'Signaling slapd for shutdown', 2)
+ # Verifying that DS has been shut down after the grace period
+ assert topo.standalone.status() == False
+ # free_space
+ os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir))
+ open('{}/errors'.format(topo.standalone.ds_paths.log_dir), 'w').close()
+ # StartSlapd
+ topo.standalone.start()
+ # verify logging enabled
+ assert topo.standalone.config.get_attr_val_utf8('nsslapd-accesslog-logging-enabled') == 'on'
+ assert topo.standalone.config.get_attr_val_utf8('nsslapd-errorlog-logging-enabled') == 'on'
+ with open(topo.standalone.errlog, 'r') as study: study = study.read()
+ assert 'disabling access and audit logging' not in study
+ assert topo.standalone.config.set('nsslapd-accesslog-maxlogsize', '1')
+ assert topo.standalone.config.set('nsslapd-accesslog-logrotationtimeunit', 'minute')
+ assert topo.standalone.config.set('nsslapd-accesslog-level', '772')
+ topo.standalone.restart()
+ # create rotated logfile
+ users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ for i in range(10):
+ user_properties = {
+ 'uid': 'cn=anuj{}'.format(i),
+ 'cn': 'cn=anuj{}'.format(i),
+ 'sn': 'cn=anuj{}'.format(i),
+ 'userPassword': "Itsme123",
+ 'uidNumber': '1{}'.format(i),
+ 'gidNumber': '2{}'.format(i),
+ 'homeDirectory': '/home/{}'.format(i)
+ }
+ users.create(properties=user_properties)
+ for j in range(100):
+ for i in [i for i in users.list()]: i.bind('Itsme123')
+ assert re.findall('access.\d+-\d+',str(os.listdir(topo.standalone.ds_paths.log_dir)))
+ topo.standalone.bind_s(DN_DM, PW_DM)
+ # enable verbose logging
+ assert topo.standalone.config.set('nsslapd-accesslog-maxlogsize', '100')
+ assert topo.standalone.config.set('nsslapd-accesslog-logrotationtimeunit', 'day')
+ assert topo.standalone.config.set('nsslapd-accesslog-level', '256')
+ assert topo.standalone.config.set('nsslapd-errorlog-level', '8')
+ topo.standalone.restart()
+ for i in [i for i in users.list()]: i.delete()
+
+
+def test_go_straight_below_half_of_the_threshold(topo, setup):
+ """
+ Go straight below 1/2 of the threshold
+ Recovery and setup
+ :id: a2a0664c-fe9e-11e8-b220-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Go straight below 1/2 of the threshold
+ 2. Verify that verbose logging was set to default level
+ 3. Verify that logging is disabled
+ 4. Verify DS is in shutdown mode
+ 5. Verify DS has recovered from shutdown
+ :expectedresults:
+ 1. Should Success
+ 2. Should Success
+ 3. Should Success
+ 4. Should Success
+ 5. Should Success
+ """
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'off')
+ assert topo.standalone.config.set('nsslapd-errorlog-level', '8')
+ topo.standalone.restart()
+ if float(THRESHOLD) > FULL_THR_FILL_SIZE:
+ FULL_THR_FILL_SIZE_new = FULL_THR_FILL_SIZE + round(float(THRESHOLD) - FULL_THR_FILL_SIZE) + 1
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE_new)])
+ else:
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE)])
+ _witherrorlog(topo, 'temporarily setting error loglevel to the default level', 11)
+ # Verify that verbose logging was set to default level
+ assert LOG_DEFAULT == int(re.findall('nsslapd-errorlog-level: \d+',
+ str(topo.standalone.search_s('cn=config', ldap.SCOPE_SUBTREE,
+ '(objectclass=*)',
+ ['nsslapd-errorlog-level']))
+ )[0].split(' ')[1])
+ # Verify that logging is disabled
+ _withouterrorlog(topo, "topo.standalone.config.get_attr_val_utf8('nsslapd-accesslog-logging-enabled') != 'off'", 11)
+ # Verify that rotated logs were removed
+ _witherrorlog(topo, 'disabling access and audit logging', 2)
+ _witherrorlog(topo, 'deleting rotated logs', 11)
+ with open(topo.standalone.errlog, 'r') as study:study = study.read()
+ assert 'Unable to remove file:' not in study
+ # Verify DS is in shutdown mode
+ _withouterrorlog(topo, 'topo.standalone.status() != False', 90)
+ _witherrorlog(topo, 'is too far below the threshold', 2)
+ # Verify DS has recovered from shutdown
+ os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir))
+ open('{}/errors'.format(topo.standalone.ds_paths.log_dir), 'w').close()
+ topo.standalone.start()
+ _withouterrorlog(topo, "topo.standalone.config.get_attr_val_utf8('nsslapd-accesslog-logging-enabled') != 'on'", 20)
+ with open(topo.standalone.errlog, 'r') as study: study = study.read()
+ assert 'disabling access and audit logging' not in study
+
+
+def test_go_straight_below_4kb(topo, setup):
+ """
+ Go straight below 4KB
+ :id: a855115a-fe9e-11e8-8e91-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Go straight below 4KB
+ 2. Clean space
+ :expectedresults:
+ 1. Should Success
+ 2. Should Success
+ """
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ topo.standalone.restart()
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE)])
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo1'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE)])
+ _withouterrorlog(topo, 'topo.standalone.status() != False', 11)
+ os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir))
+ os.remove('{}/foo1'.format(topo.standalone.ds_paths.log_dir))
+ topo.standalone.start()
+ assert topo.standalone.status() == True
+
+
[email protected]
+def test_threshold_to_overflow_value(topo, setup):
+ """
+ Overflow in nsslapd-disk-monitoring-threshold
+ :id: ad60ab3c-fe9e-11e8-88dc-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Setting nsslapd-disk-monitoring-threshold to overflow_value
+ :expectedresults:
+ 1. Should Success
+ """
+ overflow_value = '3000000000'
+ # Setting nsslapd-disk-monitoring-threshold to overflow_value
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-threshold', ensure_bytes(overflow_value))
+ assert overflow_value == re.findall('nsslapd-disk-monitoring-threshold: \d+', str(
+ topo.standalone.search_s('cn=config', ldap.SCOPE_SUBTREE, '(objectclass=*)',
+ ['nsslapd-disk-monitoring-threshold'])))[0].split(' ')[1]
+
+
[email protected]
+def test_threshold_is_reached_to_half(topo, setup):
+ """
+ RHDS not shutting down when disk monitoring threshold is reached to half.
+ :id: b2d3665e-fe9e-11e8-b9c0-8c16451d917b
+ :setup: Standalone
+ :steps: Standalone
+ 1. Verify that there is not endless loop of error messages
+ :expectedresults:
+ 1. Should Success
+ """
+
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'on')
+ assert topo.standalone.config.set('nsslapd-errorlog-level', '8')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-threshold', ensure_bytes(THRESHOLD_BYTES))
+ topo.standalone.restart()
+ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(HALF_THR_FILL_SIZE)])
+ # Verify that there is not endless loop of error messages
+ _witherrorlog(topo, "temporarily setting error loglevel to the default level", 10)
+ with open(topo.standalone.errlog, 'r') as study:study = study.read()
+ assert len(re.findall("temporarily setting error loglevel to the default level", study)) == 1
+ os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir))
+
+
[email protected]("test_input,expected", [
+ ("nsslapd-disk-monitoring-threshold", '-2'),
+ ("nsslapd-disk-monitoring-threshold", '9223372036854775808'),
+ ("nsslapd-disk-monitoring-threshold", '2047'),
+ ("nsslapd-disk-monitoring-threshold", '0'),
+ ("nsslapd-disk-monitoring-threshold", '-1294967296'),
+ ("nsslapd-disk-monitoring-threshold", 'invalid'),
+ ("nsslapd-disk-monitoring", 'invalid'),
+ ("nsslapd-disk-monitoring", '1'),
+ ("nsslapd-disk-monitoring-grace-period", '0'),
+ ("nsslapd-disk-monitoring-grace-period", '525 948'),
+ ("nsslapd-disk-monitoring-grace-period", '-1'),
+ ("nsslapd-disk-monitoring-logging-critical", 'oninvalid'),
+ ("nsslapd-disk-monitoring-grace-period", '-1'),
+ ("nsslapd-disk-monitoring-grace-period", '0'),
+])
+def test_negagtive_parameterize(topo, setup, test_input, expected):
+ """
+ Verify that invalid operations are not permitted
+ :id: b88efbf8-fe9e-11e8-8499-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Verify that invalid operations are not permitted.
+ :expectedresults:
+ 1. Should not success.
+ """
+ with pytest.raises(Exception):
+ topo.standalone.config.set(test_input, ensure_bytes(expected))
+
+
+def test_valid_operations_are_permitted(topo, setup):
+ """
+ Verify that valid operations are permitted
+ :id: bd4f83f6-fe9e-11e8-88f4-8c16451d917b
+ :setup: Standalone
+ :steps:
+ 1. Verify that valid operations are permitted
+ :expectedresults:
+ 1. Should Success.
+ """
+ assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on')
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'on')
+ assert topo.standalone.config.set('nsslapd-errorlog-level', '8')
+ topo.standalone.restart()
+ # Trying to delete nsslapd-disk-monitoring-threshold
+ assert topo.standalone.modify_s('cn=config', [(ldap.MOD_DELETE, 'nsslapd-disk-monitoring-threshold', '')])
+ # Trying to add another value to nsslapd-disk-monitoring-threshold (check that it is not multivalued)
+ topo.standalone.config.add('nsslapd-disk-monitoring-threshold', '2000001')
+ # Trying to delete nsslapd-disk-monitoring
+ assert topo.standalone.modify_s('cn=config', [(ldap.MOD_DELETE, 'nsslapd-disk-monitoring', ensure_bytes(str(
+ topo.standalone.search_s('cn=config', ldap.SCOPE_SUBTREE, '(objectclass=*)', ['nsslapd-disk-monitoring'])[
+ 0]).split(' ')[2].split('\n\n')[0]))])
+ # Trying to add another value to nsslapd-disk-monitoring
+ topo.standalone.config.add('nsslapd-disk-monitoring', 'off')
+ # Trying to delete nsslapd-disk-monitoring-grace-period
+ assert topo.standalone.modify_s('cn=config', [(ldap.MOD_DELETE, 'nsslapd-disk-monitoring-grace-period', '')])
+ # Trying to add another value to nsslapd-disk-monitoring-grace-period
+ topo.standalone.config.add('nsslapd-disk-monitoring-grace-period', '61')
+ # Trying to delete nsslapd-disk-monitoring-logging-critical
+ assert topo.standalone.modify_s('cn=config', [(ldap.MOD_DELETE, 'nsslapd-disk-monitoring-logging-critical',
+ ensure_bytes(str(
+ topo.standalone.search_s('cn=config', ldap.SCOPE_SUBTREE,
+ '(objectclass=*)', [
+ 'nsslapd-disk-monitoring-logging-critical'])[
+ 0]).split(' ')[2].split('\n\n')[0]))])
+ # Trying to add another value to nsslapd-disk-monitoring-logging-critical
+ assert topo.standalone.config.set('nsslapd-disk-monitoring-logging-critical', 'on')
+
+
+if __name__ == '__main__':
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
| 0 |
d2689280492bfd3045cb14ece02be2e4361570c7
|
389ds/389-ds-base
|
Issue 50952 - SSCA lacks basicConstraint:CA
Description:
Created a test that checks if the certificate generated by instance
has 'category: authority' tag in trust.
Relates: https://pagure.io/389-ds-base/issue/50952
Reviewed by: spichugi (Thanks!)
|
commit d2689280492bfd3045cb14ece02be2e4361570c7
Author: Barbora Simonova <[email protected]>
Date: Tue Aug 4 15:32:45 2020 +0200
Issue 50952 - SSCA lacks basicConstraint:CA
Description:
Created a test that checks if the certificate generated by instance
has 'category: authority' tag in trust.
Relates: https://pagure.io/389-ds-base/issue/50952
Reviewed by: spichugi (Thanks!)
diff --git a/dirsrvtests/tests/suites/tls/tls_cert_namespace_test.py b/dirsrvtests/tests/suites/tls/tls_cert_namespace_test.py
index 04135f707..9a6103e37 100644
--- a/dirsrvtests/tests/suites/tls/tls_cert_namespace_test.py
+++ b/dirsrvtests/tests/suites/tls/tls_cert_namespace_test.py
@@ -76,6 +76,55 @@ def test_pem_cert_in_private_namespace(topology_st):
assert not os.path.exists(cert_path + item)
[email protected]
[email protected]
[email protected](ds_is_older("1.4.3"), reason="Might fail because of bz1809279")
[email protected](ds_is_older("1.4.0"), reason="Not implemented")
+def test_cert_category_authority(topology_st):
+ """Test that certificate generated by instance has category: authority
+
+ :id: b7e816e9-2786-4d76-9c5b-bb111b0870f2
+ :setup: Standalone instance
+ :steps:
+ 1. Create DS instance
+ 2. Enable TLS
+ 3. Check if Self-Signed-CA.pem is present
+ 4. Trust the certificate
+ 5. Search if the certificate has category: authority
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ """
+
+ PEM_FILE = 'Self-Signed-CA.pem'
+
+ standalone = topology_st.standalone
+
+ log.info('Enable TLS')
+ standalone.enable_tls()
+
+ log.info('Get certificate path')
+ if ds_is_older('1.4.3'):
+ cert_path = glob('/etc/dirsrv/slapd-{}/'.format(standalone.serverid))
+ else:
+ cert_path = glob('/tmp/systemd-private-*-dirsrv@{}.service-*/tmp/slapd-{}/'.format(standalone.serverid,
+ standalone.serverid))
+ log.info('Check that {} is present'.format(PEM_FILE))
+ signed_cert = cert_path[0] + PEM_FILE
+ assert os.path.exists(signed_cert)
+
+ log.info('Trust the certificate')
+ subprocess.check_output(['trust', 'anchor', signed_cert])
+
+ log.info('Search if our certificate has category: authority')
+ result = subprocess.check_output(['trust', 'list'])
+ assert re.search(r'^(.*)label: ssca[.]389ds[.]example[.]com\n(.*).*\n.*category: authority$', ensure_str(result),
+ re.MULTILINE)
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
| 0 |
013ea7ddb06e96adc6c1c9c3c498cbcb8f55a0a0
|
389ds/389-ds-base
|
ticket 2058: Add keep alive entry after on-line initialization - second version (#4399)
Bug description:
Keep alive entry is not created on target master after on line initialization,
and its RUVelement stays empty until a direct update is issued on that master
Fix description:
The patch allows a consumer (configured as a master) to create (if it did not
exist before) the consumer's keep alive entry. It creates it at the end of a
replication session at a time we are sure the changelog exists and will not
be reset. It allows a consumer to have RUVelement with csn in the RUV at the
first incoming replication session.
That is basically lkrispen's proposal with an associated pytest testcase
Second version changes:
- moved the testcase to suites/replication/regression_test.py
- set up the topology from a 2 master topology then
reinitialized the replicas from an ldif without replication metadata
rather than using the cli.
- search for keepalive entries using search_s instead of getEntry
- add a comment about keep alive entries purpose
last commit:
- wait that ruv are in sync before checking keep alive entries
Reviewed by: droideck, Firstyear
Platforms tested: F32
relates: #2058
|
commit 013ea7ddb06e96adc6c1c9c3c498cbcb8f55a0a0
Author: progier389 <[email protected]>
Date: Tue Nov 3 12:18:50 2020 +0100
ticket 2058: Add keep alive entry after on-line initialization - second version (#4399)
Bug description:
Keep alive entry is not created on target master after on line initialization,
and its RUVelement stays empty until a direct update is issued on that master
Fix description:
The patch allows a consumer (configured as a master) to create (if it did not
exist before) the consumer's keep alive entry. It creates it at the end of a
replication session at a time we are sure the changelog exists and will not
be reset. It allows a consumer to have RUVelement with csn in the RUV at the
first incoming replication session.
That is basically lkrispen's proposal with an associated pytest testcase
Second version changes:
- moved the testcase to suites/replication/regression_test.py
- set up the topology from a 2 master topology then
reinitialized the replicas from an ldif without replication metadata
rather than using the cli.
- search for keepalive entries using search_s instead of getEntry
- add a comment about keep alive entries purpose
last commit:
- wait that ruv are in sync before checking keep alive entries
Reviewed by: droideck, Firstyear
Platforms tested: F32
relates: #2058
diff --git a/dirsrvtests/tests/suites/replication/regression_test.py b/dirsrvtests/tests/suites/replication/regression_test.py
index d03dffdce..d040d2bcd 100644
--- a/dirsrvtests/tests/suites/replication/regression_test.py
+++ b/dirsrvtests/tests/suites/replication/regression_test.py
@@ -109,6 +109,30 @@ def _move_ruv(ldif_file):
for dn, entry in ldif_list:
ldif_writer.unparse(dn, entry)
+def _remove_replication_data(ldif_file):
+ """ Remove the replication data from ldif file:
+ db2lif without -r includes some of the replica data like
+ - nsUniqueId
+ - keepalive entries
+ This function filters the ldif fil to remove these data
+ """
+
+ with open(ldif_file) as f:
+ parser = ldif.LDIFRecordList(f)
+ parser.parse()
+
+ ldif_list = parser.all_records
+ # Iterate on a copy of the ldif entry list
+ for dn, entry in ldif_list[:]:
+ if dn.startswith('cn=repl keep alive'):
+ ldif_list.remove((dn,entry))
+ else:
+ entry.pop('nsUniqueId')
+ with open(ldif_file, 'w') as f:
+ ldif_writer = ldif.LDIFWriter(f)
+ for dn, entry in ldif_list:
+ ldif_writer.unparse(dn, entry)
+
@pytest.fixture(scope="module")
def topo_with_sigkill(request):
@@ -924,6 +948,112 @@ def test_moving_entry_make_online_init_fail(topology_m2):
assert len(m1entries) == len(m2entries)
+def get_keepalive_entries(instance,replica):
+ # Returns the keep alive entries that exists with the suffix of the server instance
+ try:
+ entries = instance.search_s(replica.get_suffix(), ldap.SCOPE_ONELEVEL,
+ "(&(objectclass=ldapsubentry)(cn=repl keep alive*))",
+ ['cn', 'nsUniqueId', 'modifierTimestamp'])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to retrieve keepalive entry (%s) on instance %s: error %s' % (dn, instance, str(e)))
+ assert False
+ # No error, so lets log the keepalive entries
+ if log.isEnabledFor(logging.DEBUG):
+ for ret in entries:
+ log.debug("Found keepalive entry:\n"+str(ret));
+ return entries
+
+def verify_keepalive_entries(topo, expected):
+ #Check that keep alive entries exists (or not exists) for every masters on every masters
+ #Note: The testing method is quite basic: counting that there is one keepalive entry per master.
+ # that is ok for simple test cases like test_online_init_should_create_keepalive_entries but
+ # not for the general case as keep alive associated with no more existing master may exists
+ # (for example after: db2ldif / demote a master / ldif2db / init other masters)
+ # ==> if the function is somehow pushed in lib389, a check better than simply counting the entries
+ # should be done.
+ for masterId in topo.ms:
+ master=topo.ms[masterId]
+ for replica in Replicas(master).list():
+ if (replica.get_role() != ReplicaRole.MASTER):
+ continue
+ replica_info = f'master: {masterId} RID: {replica.get_rid()} suffix: {replica.get_suffix()}'
+ log.debug(f'Checking keepAliveEntries on {replica_info}')
+ keepaliveEntries = get_keepalive_entries(master, replica);
+ expectedCount = len(topo.ms) if expected else 0
+ foundCount = len(keepaliveEntries)
+ if (foundCount == expectedCount):
+ log.debug(f'Found {foundCount} keepalive entries as expected on {replica_info}.')
+ else:
+ log.error(f'{foundCount} Keepalive entries are found '
+ f'while {expectedCount} were expected on {replica_info}.')
+ assert False
+
+
+def test_online_init_should_create_keepalive_entries(topo_m2):
+ """Check that keep alive entries are created when initializinf a master from another one
+
+ :id: d5940e71-d18a-4b71-aaf7-b9185361fffe
+ :setup: Two masters replication setup
+ :steps:
+ 1. Generate ldif without replication data
+ 2 Init both masters from that ldif
+ 3 Check that keep alive entries does not exists
+ 4 Perform on line init of master2 from master1
+ 5 Check that keep alive entries exists
+ :expectedresults:
+ 1. No error while generating ldif
+ 2. No error while importing the ldif file
+ 3. No keepalive entrie should exists on any masters
+ 4. No error while initializing master2
+ 5. All keepalive entries should exist on every masters
+
+ """
+
+ repl = ReplicationManager(DEFAULT_SUFFIX)
+ m1 = topo_m2.ms["master1"]
+ m2 = topo_m2.ms["master2"]
+ # Step 1: Generate ldif without replication data
+ m1.stop()
+ m2.stop()
+ ldif_file = '%s/norepl.ldif' % m1.get_ldif_dir()
+ m1.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX],
+ excludeSuffixes=None, repl_data=False,
+ outputfile=ldif_file, encrypt=False)
+ # Remove replication metadata that are still in the ldif
+ _remove_replication_data(ldif_file)
+
+ # Step 2: Init both masters from that ldif
+ m1.ldif2db(DEFAULT_BENAME, None, None, None, ldif_file)
+ m2.ldif2db(DEFAULT_BENAME, None, None, None, ldif_file)
+ m1.start()
+ m2.start()
+
+ """ Replica state is now as if CLI setup has been done using:
+ dsconf master1 replication enable --suffix "${SUFFIX}" --role master
+ dsconf master2 replication enable --suffix "${SUFFIX}" --role master
+ dsconf master1 replication create-manager --name "${REPLICATION_MANAGER_NAME}" --passwd "${REPLICATION_MANAGER_PASSWORD}"
+ dsconf master2 replication create-manager --name "${REPLICATION_MANAGER_NAME}" --passwd "${REPLICATION_MANAGER_PASSWORD}"
+ dsconf master1 repl-agmt create --suffix "${SUFFIX}"
+ dsconf master2 repl-agmt create --suffix "${SUFFIX}"
+ """
+
+ # Step 3: No keepalive entrie should exists on any masters
+ verify_keepalive_entries(topo_m2, False)
+
+ # Step 4: Perform on line init of master2 from master1
+ agmt = Agreements(m1).list()[0]
+ agmt.begin_reinit()
+ (done, error) = agmt.wait_reinit()
+ assert done is True
+ assert error is False
+
+ # Step 5: All keepalive entries should exists on every masters
+ # Verify the keep alive entry once replication is in sync
+ # (that is the step that fails when bug is not fixed)
+ repl.wait_for_ruv(m2,m1)
+ verify_keepalive_entries(topo_m2, True);
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 0ccc548a8..a50912161 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -386,6 +386,20 @@ replica_destroy(void **arg)
slapi_ch_free((void **)arg);
}
+/******************************************************************************
+ ******************** REPLICATION KEEP ALIVE ENTRIES **************************
+ ******************************************************************************
+ * They are subentries of the replicated suffix and there is one per master. *
+ * These entries exist only to trigger a change that get replicated over the *
+ * topology. *
+ * Their main purpose is to generate records in the changelog and they are *
+ * updated from time to time by fractional replication to insure that at *
+ * least a change must be replicated by FR after a great number of not *
+ * replicated changes are found in the changelog. The interest is that the *
+ * fractional RUV get then updated so less changes need to be walked in the *
+ * changelog when searching for the first change to send *
+ ******************************************************************************/
+
#define KEEP_ALIVE_ATTR "keepalivetimestamp"
#define KEEP_ALIVE_ENTRY "repl keep alive"
#define KEEP_ALIVE_DN_FORMAT "cn=%s %d,%s"
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index dccae55a6..2f0d31e52 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -1175,6 +1175,10 @@ multimaster_extop_EndNSDS50ReplicationRequest(Slapi_PBlock *pb)
*/
if (replica_is_flag_set(r, REPLICA_LOG_CHANGES) && cldb_is_open(r)) {
replica_log_ruv_elements(r);
+ /* now that the changelog is open and started, we can alos cretae the
+ * keep alive entry without risk that db and cl will not match
+ */
+ replica_subentry_check(replica_get_root(r), replica_get_rid(r));
}
/* ONREPL code that dealt with new RUV, etc was moved into the code
| 0 |
2ad4bda25e7add8792172d4ddf3e1f6b64cff5f4
|
389ds/389-ds-base
|
Resolves: bug 229691
Bug Description: Add enable switches for optional/experimental features
Reviewed by: nkinder, nhosoi, prowley (Thanks!)
Fix Description: Added --enable-pam-passthru, --enable-dna, and --enable-ldapi. They are all on by default and must be explicitly disabled (--disable-pam-passthru). These all cause ENABLE_xxx to be defined for C code so that we can enclose the code in #ifdef ENABLE_PAM_PASSTHRU blocks, for example. For the first two, these also cause the plugins to be built - so that if you specify --disable-pam-passthru, the plugin code will not be built at all. I discovered a nifty autoconf macro called AS_HELP_STRING - this nicely formats the help messages output by configure --help. I don't know if it's worth going through all of our m4 code to use this, but I went ahead and fixed configure.ac. Create instance will now add plugin configuration entries (but disabled) for pam passthru and dna if the corresponding ENABLE_ macros are defined. I also fixed a bug with passthru (not pam passthru) - the plugin configuration entry was not being added.
Platforms tested: RHEL4, FC6
Flag Day: no
Doc impact: no
|
commit 2ad4bda25e7add8792172d4ddf3e1f6b64cff5f4
Author: Rich Megginson <[email protected]>
Date: Thu Feb 22 23:59:13 2007 +0000
Resolves: bug 229691
Bug Description: Add enable switches for optional/experimental features
Reviewed by: nkinder, nhosoi, prowley (Thanks!)
Fix Description: Added --enable-pam-passthru, --enable-dna, and --enable-ldapi. They are all on by default and must be explicitly disabled (--disable-pam-passthru). These all cause ENABLE_xxx to be defined for C code so that we can enclose the code in #ifdef ENABLE_PAM_PASSTHRU blocks, for example. For the first two, these also cause the plugins to be built - so that if you specify --disable-pam-passthru, the plugin code will not be built at all. I discovered a nifty autoconf macro called AS_HELP_STRING - this nicely formats the help messages output by configure --help. I don't know if it's worth going through all of our m4 code to use this, but I went ahead and fixed configure.ac. Create instance will now add plugin configuration entries (but disabled) for pam passthru and dna if the corresponding ENABLE_ macros are defined. I also fixed a bug with passthru (not pam passthru) - the plugin configuration entry was not being added.
Platforms tested: RHEL4, FC6
Flag Day: no
Doc impact: no
diff --git a/Makefile.am b/Makefile.am
index 168d1a422..f7f41ef4a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -85,13 +85,21 @@ bin_PROGRAMS = dbscan-bin ds_newinst-bin dsktune-bin infadd-bin ldap-agent-bin \
server_LTLIBRARIES = libslapd.la libds_admin.la libns-dshttpd.la
+# this is how to add optional plugins
+if enable_pam_passthru
+LIBPAM_PASSTHRU_PLUGIN = libpam-passthru-plugin.la
+endif
+if enable_dna
+LIBDNA_PLUGIN = libdna-plugin.la
+endif
+
serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la \
libback-ldbm.la libchainingdb-plugin.la libcos-plugin.la libdes-plugin.la \
- libdistrib-plugin.la libdna-plugin.la libhttp-client-plugin.la libcollation-plugin.la \
- libpam-passthru-plugin.la libpassthru-plugin.la libpresence-plugin.la \
+ libdistrib-plugin.la libhttp-client-plugin.la libcollation-plugin.la \
+ libpassthru-plugin.la libpresence-plugin.la \
libpwdstorage-plugin.la libreferint-plugin.la libreplication-plugin.la \
libretrocl-plugin.la libroles-plugin.la libstatechange-plugin.la libsyntax-plugin.la \
- libviews-plugin.la
+ libviews-plugin.la $(LIBPAM_PASSTHRU_PLUGIN) $(LIBDNA_PLUGIN)
nodist_property_DATA = ns-slapd.properties
diff --git a/Makefile.in b/Makefile.in
index 41fc3c5ff..90f173f35 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -237,6 +237,7 @@ libdna_plugin_la_LIBADD =
am_libdna_plugin_la_OBJECTS = \
ldap/servers/plugins/dna/libdna_plugin_la-dna.lo
libdna_plugin_la_OBJECTS = $(am_libdna_plugin_la_OBJECTS)
+@enable_dna_TRUE@am_libdna_plugin_la_rpath = -rpath $(serverplugindir)
libds_admin_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
am_libds_admin_la_OBJECTS = \
@@ -330,6 +331,8 @@ am_libpam_passthru_plugin_la_OBJECTS = ldap/servers/plugins/pam_passthru/libpam_
ldap/servers/plugins/pam_passthru/libpam_passthru_plugin_la-pam_ptpreop.lo
libpam_passthru_plugin_la_OBJECTS = \
$(am_libpam_passthru_plugin_la_OBJECTS)
+@enable_pam_passthru_TRUE@am_libpam_passthru_plugin_la_rpath = -rpath \
+@enable_pam_passthru_TRUE@ $(serverplugindir)
libpassthru_plugin_la_LIBADD =
am_libpassthru_plugin_la_OBJECTS = \
ldap/servers/plugins/passthru/libpassthru_plugin_la-ptbind.lo \
@@ -877,6 +880,10 @@ db_lib = @db_lib@
db_libdir = @db_libdir@
db_libver = @db_libver@
debug_defs = @debug_defs@
+enable_dna_FALSE = @enable_dna_FALSE@
+enable_dna_TRUE = @enable_dna_TRUE@
+enable_pam_passthru_FALSE = @enable_pam_passthru_FALSE@
+enable_pam_passthru_TRUE = @enable_pam_passthru_TRUE@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
@@ -979,13 +986,17 @@ BUILT_SOURCES = dirver.h dberrstrs.h
CLEANFILES = dirver.h dberrstrs.h ns-slapd.properties
taskdir = $(datadir)@scripttemplatedir@
server_LTLIBRARIES = libslapd.la libds_admin.la libns-dshttpd.la
+
+# this is how to add optional plugins
+@enable_pam_passthru_TRUE@LIBPAM_PASSTHRU_PLUGIN = libpam-passthru-plugin.la
+@enable_dna_TRUE@LIBDNA_PLUGIN = libdna-plugin.la
serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la \
libback-ldbm.la libchainingdb-plugin.la libcos-plugin.la libdes-plugin.la \
- libdistrib-plugin.la libdna-plugin.la libhttp-client-plugin.la libcollation-plugin.la \
- libpam-passthru-plugin.la libpassthru-plugin.la libpresence-plugin.la \
+ libdistrib-plugin.la libhttp-client-plugin.la libcollation-plugin.la \
+ libpassthru-plugin.la libpresence-plugin.la \
libpwdstorage-plugin.la libreferint-plugin.la libreplication-plugin.la \
libretrocl-plugin.la libroles-plugin.la libstatechange-plugin.la libsyntax-plugin.la \
- libviews-plugin.la
+ libviews-plugin.la $(LIBPAM_PASSTHRU_PLUGIN) $(LIBDNA_PLUGIN)
nodist_property_DATA = ns-slapd.properties
noinst_LIBRARIES = libavl.a libldaputil.a
@@ -2415,7 +2426,7 @@ ldap/servers/plugins/dna/libdna_plugin_la-dna.lo: \
ldap/servers/plugins/dna/$(am__dirstamp) \
ldap/servers/plugins/dna/$(DEPDIR)/$(am__dirstamp)
libdna-plugin.la: $(libdna_plugin_la_OBJECTS) $(libdna_plugin_la_DEPENDENCIES)
- $(LINK) -rpath $(serverplugindir) $(libdna_plugin_la_LDFLAGS) $(libdna_plugin_la_OBJECTS) $(libdna_plugin_la_LIBADD) $(LIBS)
+ $(LINK) $(am_libdna_plugin_la_rpath) $(libdna_plugin_la_LDFLAGS) $(libdna_plugin_la_OBJECTS) $(libdna_plugin_la_LIBADD) $(LIBS)
ldap/admin/lib/$(am__dirstamp):
@$(mkdir_p) ldap/admin/lib
@: > ldap/admin/lib/$(am__dirstamp)
@@ -2678,7 +2689,7 @@ ldap/servers/plugins/pam_passthru/libpam_passthru_plugin_la-pam_ptpreop.lo: \
ldap/servers/plugins/pam_passthru/$(am__dirstamp) \
ldap/servers/plugins/pam_passthru/$(DEPDIR)/$(am__dirstamp)
libpam-passthru-plugin.la: $(libpam_passthru_plugin_la_OBJECTS) $(libpam_passthru_plugin_la_DEPENDENCIES)
- $(LINK) -rpath $(serverplugindir) $(libpam_passthru_plugin_la_LDFLAGS) $(libpam_passthru_plugin_la_OBJECTS) $(libpam_passthru_plugin_la_LIBADD) $(LIBS)
+ $(LINK) $(am_libpam_passthru_plugin_la_rpath) $(libpam_passthru_plugin_la_LDFLAGS) $(libpam_passthru_plugin_la_OBJECTS) $(libpam_passthru_plugin_la_LIBADD) $(LIBS)
ldap/servers/plugins/passthru/$(am__dirstamp):
@$(mkdir_p) ldap/servers/plugins/passthru
@: > ldap/servers/plugins/passthru/$(am__dirstamp)
diff --git a/config.h.in b/config.h.in
index ae48930a5..9409bd781 100644
--- a/config.h.in
+++ b/config.h.in
@@ -12,6 +12,15 @@
/* cpu type sparc */
#undef CPU_sparc
+/* enable the dna plugin */
+#undef ENABLE_DNA
+
+/* enable ldapi support in the server */
+#undef ENABLE_LDAPI
+
+/* enable the pam passthru auth plugin */
+#undef ENABLE_PAM_PASSTHRU
+
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
diff --git a/configure b/configure
index 9a40453ad..8e90fcce3 100755
--- a/configure
+++ b/configure
@@ -465,7 +465,7 @@ ac_includes_default="\
#endif"
ac_default_prefix=/opt/$PACKAGE_NAME
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir instconfigdir WINNT_TRUE WINNT_FALSE LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS debug_defs BUNDLE_TRUE BUNDLE_FALSE enable_pam_passthru_TRUE enable_pam_passthru_FALSE enable_dna_TRUE enable_dna_FALSE configdir sampledatadir propertydir schemadir serverdir serverplugindir scripttemplatedir instconfigdir WINNT_TRUE WINNT_FALSE LIBSOCKET LIBNSL LIBDL LIBCSTD LIBCRUN initdir HPUX_TRUE HPUX_FALSE SOLARIS_TRUE SOLARIS_FALSE PKG_CONFIG ICU_CONFIG NETSNMP_CONFIG nspr_inc nspr_lib nspr_libdir nss_inc nss_lib nss_libdir ldapsdk_inc ldapsdk_lib ldapsdk_libdir ldapsdk_bindir db_inc db_incdir db_lib db_libdir db_bindir db_libver sasl_inc sasl_lib sasl_libdir svrcore_inc svrcore_lib icu_lib icu_inc icu_bin netsnmp_inc netsnmp_lib netsnmp_libdir netsnmp_link LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -1038,8 +1038,14 @@ Optional Features:
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
- --enable-debug Enable debug features
- --enable-bundle Enable bundled dependencies
+ --enable-debug Enable debug features (default: no)
+ --enable-bundle Enable bundled dependencies (default: no)
+ --enable-pam-passthru enable the PAM passthrough auth plugin (default:
+ yes)
+ --enable-dna enable the Distributed Numeric Assignment (DNA)
+ plugin (default: yes)
+ --enable-ldapi enable LDAP over unix domain socket (LDAPI) support
+ (default: yes)
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1050,7 +1056,10 @@ Optional Packages:
--with-tags[=TAGS]
include additional configurations [automatic]
--with-fhs Use FHS layout
- --with-instconfigdir=/path Base directory for instance specific writable configuration directories (default $sysconfdir/$PACKAGE_NAME)
+ --with-instconfigdir=/path
+ Base directory for instance specific writable
+ configuration directories (default
+ $sysconfdir/$PACKAGE_NAME)
--with-nspr=PATH Netscape Portable Runtime (NSPR) directory
--with-nspr-inc=PATH Netscape Portable Runtime (NSPR) include file directory
--with-nspr-lib=PATH Netscape Portable Runtime (NSPR) library directory
@@ -4299,7 +4308,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4302 "configure"' > conftest.$ac_ext
+ echo '#line 4311 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -5434,7 +5443,7 @@ fi
# Provide some information about the compiler.
-echo "$as_me:5437:" \
+echo "$as_me:5446:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -6497,11 +6506,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6500: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6509: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6504: \$? = $ac_status" >&5
+ echo "$as_me:6513: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -6765,11 +6774,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6768: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6777: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6772: \$? = $ac_status" >&5
+ echo "$as_me:6781: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -6869,11 +6878,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6872: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6881: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:6876: \$? = $ac_status" >&5
+ echo "$as_me:6885: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -8338,7 +8347,7 @@ linux*)
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 8341 "configure"' > conftest.$ac_ext
+ echo '#line 8350 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -9235,7 +9244,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9238 "configure"
+#line 9247 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -9335,7 +9344,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9338 "configure"
+#line 9347 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11678,11 +11687,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11681: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11690: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:11685: \$? = $ac_status" >&5
+ echo "$as_me:11694: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -11782,11 +11791,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11785: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11794: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:11789: \$? = $ac_status" >&5
+ echo "$as_me:11798: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -12318,7 +12327,7 @@ linux*)
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 12321 "configure"' > conftest.$ac_ext
+ echo '#line 12330 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -13376,11 +13385,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13379: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13388: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:13383: \$? = $ac_status" >&5
+ echo "$as_me:13392: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -13480,11 +13489,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13483: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13492: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:13487: \$? = $ac_status" >&5
+ echo "$as_me:13496: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -14929,7 +14938,7 @@ linux*)
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 14932 "configure"' > conftest.$ac_ext
+ echo '#line 14941 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -15707,11 +15716,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15710: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15719: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15714: \$? = $ac_status" >&5
+ echo "$as_me:15723: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -15975,11 +15984,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15978: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15987: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15982: \$? = $ac_status" >&5
+ echo "$as_me:15991: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16079,11 +16088,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16082: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16091: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:16086: \$? = $ac_status" >&5
+ echo "$as_me:16095: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -17548,7 +17557,7 @@ linux*)
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 17551 "configure"' > conftest.$ac_ext
+ echo '#line 17560 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -22906,6 +22915,97 @@ else
fi
+# these enables are for optional or experimental features
+if test -z "$enable_pam_passthru" ; then
+ enable_pam_passthru=yes # if not set on cmdline, set default
+fi
+echo "$as_me:$LINENO: checking for --enable-pam-passthru" >&5
+echo $ECHO_N "checking for --enable-pam-passthru... $ECHO_C" >&6
+# Check whether --enable-pam-passthru or --disable-pam-passthru was given.
+if test "${enable_pam_passthru+set}" = set; then
+ enableval="$enable_pam_passthru"
+
+fi;
+if test "$enable_pam_passthru" = yes ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define ENABLE_PAM_PASSTHRU 1
+_ACEOF
+
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+if test "$enable_pam_passthru" = "yes"; then
+ enable_pam_passthru_TRUE=
+ enable_pam_passthru_FALSE='#'
+else
+ enable_pam_passthru_TRUE='#'
+ enable_pam_passthru_FALSE=
+fi
+
+
+if test -z "$enable_dna" ; then
+ enable_dna=yes # if not set on cmdline, set default
+fi
+echo "$as_me:$LINENO: checking for --enable-dna" >&5
+echo $ECHO_N "checking for --enable-dna... $ECHO_C" >&6
+# Check whether --enable-dna or --disable-dna was given.
+if test "${enable_dna+set}" = set; then
+ enableval="$enable_dna"
+
+fi;
+if test "$enable_dna" = yes ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define ENABLE_DNA 1
+_ACEOF
+
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+if test "$enable_dna" = "yes"; then
+ enable_dna_TRUE=
+ enable_dna_FALSE='#'
+else
+ enable_dna_TRUE='#'
+ enable_dna_FALSE=
+fi
+
+
+if test -z "$enable_ldapi" ; then
+ enable_ldapi=yes # if not set on cmdline, set default
+fi
+echo "$as_me:$LINENO: checking for --enable-ldapi" >&5
+echo $ECHO_N "checking for --enable-ldapi... $ECHO_C" >&6
+# Check whether --enable-ldapi or --disable-ldapi was given.
+if test "${enable_ldapi+set}" = set; then
+ enableval="$enable_ldapi"
+
+fi;
+if test "$enable_ldapi" = yes ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define ENABLE_LDAPI 1
+_ACEOF
+
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+# the default prefix - override with --prefix or --with-fhs
# BEGIN COPYRIGHT BLOCK
@@ -22990,9 +23090,6 @@ scripttemplatedir=/$PACKAGE_NAME/script-templates
-{ echo "$as_me:$LINENO: checking for instconfigdir..." >&5
-echo "$as_me: checking for instconfigdir..." >&6;}
-
# check for --with-instconfigdir
echo "$as_me:$LINENO: checking for --with-instconfigdir" >&5
echo $ECHO_N "checking for --with-instconfigdir... $ECHO_C" >&6
@@ -25107,6 +25204,20 @@ echo "$as_me: error: conditional \"BUNDLE\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${enable_pam_passthru_TRUE}" && test -z "${enable_pam_passthru_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"enable_pam_passthru\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"enable_pam_passthru\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${enable_dna_TRUE}" && test -z "${enable_dna_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"enable_dna\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"enable_dna\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
if test -z "${WINNT_TRUE}" && test -z "${WINNT_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"WINNT\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -25733,6 +25844,10 @@ s,@LIBOBJS@,$LIBOBJS,;t t
s,@debug_defs@,$debug_defs,;t t
s,@BUNDLE_TRUE@,$BUNDLE_TRUE,;t t
s,@BUNDLE_FALSE@,$BUNDLE_FALSE,;t t
+s,@enable_pam_passthru_TRUE@,$enable_pam_passthru_TRUE,;t t
+s,@enable_pam_passthru_FALSE@,$enable_pam_passthru_FALSE,;t t
+s,@enable_dna_TRUE@,$enable_dna_TRUE,;t t
+s,@enable_dna_FALSE@,$enable_dna_FALSE,;t t
s,@configdir@,$configdir,;t t
s,@sampledatadir@,$sampledatadir,;t t
s,@propertydir@,$propertydir,;t t
diff --git a/configure.ac b/configure.ac
index 336e757b6..c2e66d6ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,7 +51,7 @@ AC_FUNC_VPRINTF
AC_CHECK_FUNCS([setrlimit endpwent ftruncate getcwd gethostbyname inet_ntoa localtime_r memmove memset mkdir munmap putenv rmdir socket strcasecmp strchr strcspn strdup strerror strncasecmp strpbrk strrchr strstr strtol tzset])
AC_MSG_CHECKING(for --enable-debug)
-AC_ARG_ENABLE(debug, [ --enable-debug Enable debug features],
+AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [Enable debug features (default: no)]),
[
AC_MSG_RESULT(yes)
debug_defs="-DDEBUG -DMCC_DEBUG"
@@ -64,7 +64,7 @@ AC_SUBST([debug_defs])
# Used for legacy style packaging where we bundle all of the dependencies.
AC_MSG_CHECKING(for --enable-bundle)
-AC_ARG_ENABLE(bundle, [ --enable-bundle Enable bundled dependencies],
+AC_ARG_ENABLE(bundle, AS_HELP_STRING([--enable-bundle], [Enable bundled dependencies (default: no)]),
[
AC_MSG_RESULT(yes)
bundle="1";
@@ -75,6 +75,52 @@ AC_ARG_ENABLE(bundle, [ --enable-bundle Enable bundled dependencies],
])
AM_CONDITIONAL(BUNDLE,test "$bundle" = "1")
+# these enables are for optional or experimental features
+if test -z "$enable_pam_passthru" ; then
+ enable_pam_passthru=yes # if not set on cmdline, set default
+fi
+AC_MSG_CHECKING(for --enable-pam-passthru)
+AC_ARG_ENABLE(pam-passthru,
+ AS_HELP_STRING([--enable-pam-passthru],
+ [enable the PAM passthrough auth plugin (default: yes)]))
+if test "$enable_pam_passthru" = yes ; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([ENABLE_PAM_PASSTHRU], [1], [enable the pam passthru auth plugin])
+else
+ AC_MSG_RESULT(no)
+fi
+AM_CONDITIONAL(enable_pam_passthru,test "$enable_pam_passthru" = "yes")
+
+if test -z "$enable_dna" ; then
+ enable_dna=yes # if not set on cmdline, set default
+fi
+AC_MSG_CHECKING(for --enable-dna)
+AC_ARG_ENABLE(dna,
+ AS_HELP_STRING([--enable-dna],
+ [enable the Distributed Numeric Assignment (DNA) plugin (default: yes)]))
+if test "$enable_dna" = yes ; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([ENABLE_DNA], [1], [enable the dna plugin])
+else
+ AC_MSG_RESULT(no)
+fi
+AM_CONDITIONAL(enable_dna,test "$enable_dna" = "yes")
+
+if test -z "$enable_ldapi" ; then
+ enable_ldapi=yes # if not set on cmdline, set default
+fi
+AC_MSG_CHECKING(for --enable-ldapi)
+AC_ARG_ENABLE(ldapi,
+ AS_HELP_STRING([--enable-ldapi],
+ [enable LDAP over unix domain socket (LDAPI) support (default: yes)]))
+if test "$enable_ldapi" = yes ; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([ENABLE_LDAPI], [1], [enable ldapi support in the server])
+else
+ AC_MSG_RESULT(no)
+fi
+
+# the default prefix - override with --prefix or --with-fhs
AC_PREFIX_DEFAULT([/opt/$PACKAGE_NAME])
m4_include(m4/fhs.m4)
@@ -115,11 +161,11 @@ AC_SUBST(serverdir)
AC_SUBST(serverplugindir)
AC_SUBST(scripttemplatedir)
-AC_CHECKING(for instconfigdir)
-
# check for --with-instconfigdir
AC_MSG_CHECKING(for --with-instconfigdir)
-AC_ARG_WITH(instconfigdir, [ --with-instconfigdir=/path Base directory for instance specific writable configuration directories (default $sysconfdir/$PACKAGE_NAME)],
+AC_ARG_WITH(instconfigdir,
+ AS_HELP_STRING([--with-instconfigdir=/path],
+ [Base directory for instance specific writable configuration directories (default $sysconfdir/$PACKAGE_NAME)]),
[
if test $withval = yes ; then
AC_ERROR([Please specify a full path with --with-instconfigdir])
diff --git a/ldap/admin/src/create_instance.c b/ldap/admin/src/create_instance.c
index 8da5696b1..cf5c16b34 100644
--- a/ldap/admin/src/create_instance.c
+++ b/ldap/admin/src/create_instance.c
@@ -3149,7 +3149,8 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
#endif
/* enable pass thru authentication */
- if (cf->use_existing_config_ds || cf->use_existing_user_ds)
+ if ((cf->use_existing_config_ds && cf->config_ldap_url) ||
+ (cf->use_existing_user_ds && cf->user_ldap_url))
{
LDAPURLDesc *desc = 0;
char *url = cf->use_existing_config_ds ? cf->config_ldap_url :
@@ -3195,7 +3196,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "\n");
}
-#ifdef BUILD_PAM_PASSTHRU
+#ifdef ENABLE_PAM_PASSTHRU
#if !defined( XP_WIN32 )
/* PAM Pass Through Auth plugin - off by default */
fprintf(f, "dn: cn=PAM Pass Through Auth,cn=plugins,cn=config\n");
@@ -3215,13 +3216,27 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
fprintf(f, "pamExcludeSuffix: %s\n", cf->netscaperoot);
}
fprintf(f, "pamExcludeSuffix: cn=config\n");
- fprintf(f, "pamMapMethod: RDN\n");
+ fprintf(f, "pamIDMapMethod: RDN\n");
+ fprintf(f, "pamIDAttr: notUsedWithRDNMethod\n");
fprintf(f, "pamFallback: FALSE\n");
fprintf(f, "pamSecure: TRUE\n");
fprintf(f, "pamService: ldapserver\n");
fprintf(f, "\n");
#endif /* NO PAM FOR WINDOWS */
-#endif /* BUILD_PAM_PASSTHRU */
+#endif /* ENABLE_PAM_PASSTHRU */
+
+#ifdef ENABLE_DNA
+ fprintf(f, "dn: cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config\n");
+ fprintf(f, "objectclass: top\n");
+ fprintf(f, "objectclass: nsSlapdPlugin\n");
+ fprintf(f, "objectclass: extensibleObject\n");
+ fprintf(f, "objectclass: nsContainer\n");
+ fprintf(f, "cn: Distributed Numeric Assignment Plugin\n");
+ fprintf(f, "nsslapd-plugininitfunc: dna_init\n");
+ fprintf(f, "nsslapd-plugintype: preoperation\n");
+ fprintf(f, "nsslapd-pluginenabled: off\n");
+ fprintf(f, "nsslapd-pluginPath: %s/libdna-plugin%s\n", cf->plugin_dir, shared_lib);
+#endif /* ENABLE_DNA */
fprintf(f, "dn: cn=ldbm database,cn=plugins,cn=config\n");
fprintf(f, "objectclass: top\n");
| 0 |
eb46e6f1975b19956bb38d5e070e6eb5159200b4
|
389ds/389-ds-base
|
Ticket #48183 - bind on db chained to AD returns err=32
Description by [email protected]: bind is doing a search for the entry
post bind, which fails because we don't enable password policy chaining
by default. I think in this case, we should not look up password policy,
because if the remote is AD or some other non-389 server, we can't use
the password policy information. We should instead rely on the remote
server to evaluate the password policy.
The commit 4fc53e1a63222d0ff67c30a59f2cff4b535f90a8 introduced the bug.
Ticket #47748 - Simultaneous adding a user and binding as the user could
fail in the password policy check
https://fedorahosted.org/389/ticket/48183
Revewed by [email protected].
|
commit eb46e6f1975b19956bb38d5e070e6eb5159200b4
Author: Noriko Hosoi <[email protected]>
Date: Sat May 9 18:55:39 2015 -0700
Ticket #48183 - bind on db chained to AD returns err=32
Description by [email protected]: bind is doing a search for the entry
post bind, which fails because we don't enable password policy chaining
by default. I think in this case, we should not look up password policy,
because if the remote is AD or some other non-389 server, we can't use
the password policy information. We should instead rely on the remote
server to evaluate the password policy.
The commit 4fc53e1a63222d0ff67c30a59f2cff4b535f90a8 introduced the bug.
Ticket #47748 - Simultaneous adding a user and binding as the user could
fail in the password policy check
https://fedorahosted.org/389/ticket/48183
Revewed by [email protected].
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 70d2d199c..acc65cea0 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -777,7 +777,8 @@ do_bind( Slapi_PBlock *pb )
* was in be_bind. Since be_bind returned SLAPI_BIND_SUCCESS,
* the entry is in the DS. So, we need to retrieve it once more.
*/
- if (!bind_target_entry) {
+ if (!slapi_be_is_flag_set(be, SLAPI_BE_FLAG_REMOTE_DATA) &&
+ !bind_target_entry) {
bind_target_entry = get_entry(pb, slapi_sdn_get_ndn(sdn));
if (bind_target_entry) {
myrc = slapi_check_account_lock(pb, bind_target_entry,
| 0 |
7a158c753a8e62dac7464dad15838aa864ea917c
|
389ds/389-ds-base
|
Issue 6041 - dscreate ds-root - accepts relative path (#6042)
Bug Description: When dscreate ds-root is invoked with a relative path to
root_dir, the relative path is written to defaults.inf, causing instance
creation failure.
Fix Description: Use abs path when writing root_dir to defaults.inf
Fixes: https://github.com/389ds/389-ds-base/issues/6041
Reviewed by: @progier389, @droideck (Thank you)
|
commit 7a158c753a8e62dac7464dad15838aa864ea917c
Author: James Chapman <[email protected]>
Date: Mon Jan 22 13:08:37 2024 +0000
Issue 6041 - dscreate ds-root - accepts relative path (#6042)
Bug Description: When dscreate ds-root is invoked with a relative path to
root_dir, the relative path is written to defaults.inf, causing instance
creation failure.
Fix Description: Use abs path when writing root_dir to defaults.inf
Fixes: https://github.com/389ds/389-ds-base/issues/6041
Reviewed by: @progier389, @droideck (Thank you)
diff --git a/src/lib389/lib389/cli_ctl/instance.py b/src/lib389/lib389/cli_ctl/instance.py
index 5fa912422..97322ace8 100644
--- a/src/lib389/lib389/cli_ctl/instance.py
+++ b/src/lib389/lib389/cli_ctl/instance.py
@@ -234,7 +234,7 @@ def prepare_ds_root(inst, log, args):
PO = '{'
PF = '}'
copy_and_substitute('/usr/share/dirsrv/inf/defaults.inf', (
- ('WORD', ' /', f' {args.root_dir}/'),
+ ('WORD', ' /', f' {os.path.abspath(args.root_dir)}/'),
('LINE', 'with_selinux', 'no'),
('LINE', 'with_systemd', '0'),
('LINE', 'user', user),
| 0 |
ed83a783887b0f9c54781bac64c7b26f0402640a
|
389ds/389-ds-base
|
Ticket 47426 - move compute_idletimeout out of handle_pr_read_ready
Description: Instead of calculating the idletimeout everytime new data is received,
set the anonymous reslimit idletimeout and handle in the connection struct when the
connection first comes in. Then update idletimeout after each bind.
I removed compute_idletimeout() because bind_credentials_set_nolock()
basically does the same thing, so it was just extended to update
the idletimeout.
https://fedorahosted.org/389/ticket/47426
Reviewed by: richm(Thanks!)
|
commit ed83a783887b0f9c54781bac64c7b26f0402640a
Author: Mark Reynolds <[email protected]>
Date: Wed Jul 31 19:19:34 2013 -0400
Ticket 47426 - move compute_idletimeout out of handle_pr_read_ready
Description: Instead of calculating the idletimeout everytime new data is received,
set the anonymous reslimit idletimeout and handle in the connection struct when the
connection first comes in. Then update idletimeout after each bind.
I removed compute_idletimeout() because bind_credentials_set_nolock()
basically does the same thing, so it was just extended to update
the idletimeout.
https://fedorahosted.org/389/ticket/47426
Reviewed by: richm(Thanks!)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index d37488358..6431874d2 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -2326,6 +2326,27 @@ connection_threadmain()
in connection_activity when the conn is added to the
work queue, setup_pr_read_pds won't add the connection prfd
to the poll list */
+ if(pb->pb_conn && pb->pb_conn->c_opscompleted == 0){
+ /*
+ * We have a new connection, set the anonymous reslimit idletimeout
+ * if applicable.
+ */
+ char *anon_dn = config_get_anon_limits_dn();
+ int idletimeout;
+ /* If an anonymous limits dn is set, use it to set the limits. */
+ if (anon_dn && (strlen(anon_dn) > 0)) {
+ Slapi_DN *anon_sdn = slapi_sdn_new_normdn_byref( anon_dn );
+ reslimit_update_from_dn( pb->pb_conn, anon_sdn );
+ slapi_sdn_free( &anon_sdn );
+ if (slapi_reslimit_get_integer_limit(pb->pb_conn, pb->pb_conn->c_idletimeout_handle,
+ &idletimeout)
+ == SLAPI_RESLIMIT_STATUS_SUCCESS)
+ {
+ pb->pb_conn->c_idletimeout = idletimeout;
+ }
+ }
+ slapi_ch_free_string( &anon_dn );
+ }
if (connection_call_io_layer_callbacks(pb->pb_conn)) {
LDAPDebug0Args( LDAP_DEBUG_ANY, "Error: could not add/remove IO layers from connection\n" );
}
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index c4b0865c4..ba40f53d9 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1785,59 +1785,6 @@ daemon_register_reslimits( void )
&idletimeout_reslimit_handle ));
}
-
-/*
- * Compute the idle timeout for the connection.
- *
- * Note: this function must always be called with conn->c_mutex locked.
- */
-static int
-compute_idletimeout( slapdFrontendConfig_t *fecfg, Connection *conn )
-{
- int idletimeout = 0;
-
- if ( slapi_reslimit_get_integer_limit( conn, idletimeout_reslimit_handle,
- &idletimeout ) != SLAPI_RESLIMIT_STATUS_SUCCESS ) {
- /*
- * No limit associated with binder/connection or some other error
- * occurred. If the user is anonymous and anonymous limits are
- * set, attempt to set the bind based resource limits. We do this
- * here since a BIND operation is not required prior to other
- * operations. We want to set the anonymous limits early on so
- * that they are put into effect if a BIND is never sent. If
- * this is not an anonymous user and no bind-based limits are set,
- * use the default idle timeout.
- */
-
- if (conn->c_dn == NULL) {
- char *anon_dn = config_get_anon_limits_dn();
- if (anon_dn && (strlen(anon_dn) > 0)) {
- Slapi_DN *anon_sdn = slapi_sdn_new_dn_byref(anon_dn);
-
- reslimit_update_from_dn(conn, anon_sdn);
-
- if (slapi_reslimit_get_integer_limit(conn, idletimeout_reslimit_handle,
- &idletimeout)
- != SLAPI_RESLIMIT_STATUS_SUCCESS) {
- idletimeout = fecfg->idletimeout;
- }
-
- slapi_sdn_free(&anon_sdn);
- } else {
- idletimeout = fecfg->idletimeout;
- }
- slapi_ch_free_string(&anon_dn);
- } else if ( conn->c_isroot ) {
- idletimeout = 0; /* no limit for Directory Manager */
- } else {
- idletimeout = fecfg->idletimeout;
- }
- }
-
- return( idletimeout );
-}
-
-
#ifdef _WIN32
static void
handle_read_ready(Connection_Table *ct, fd_set *readfds)
@@ -1881,9 +1828,8 @@ handle_read_ready(Connection_Table *ct, fd_set *readfds)
/* idle timeout */
}
- else if (( idletimeout = compute_idletimeout(
- slapdFrontendConfig, c )) > 0 &&
- (curtime - c->c_idlesince) >= idletimeout &&
+ else if (( c->c_idletimeout > 0 &&
+ (curtime - c->c_idlesince) >= c->c_idletimeout &&
NULL == c->c_ops )
{
disconnect_server_nomutex( c, c->c_connid, -1,
@@ -1903,8 +1849,6 @@ handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll)
{
Connection *c;
time_t curtime = current_time();
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int idletimeout;
int maxthreads = config_get_maxthreadsperconn();
#if defined( XP_WIN32 )
int i;
@@ -1968,10 +1912,9 @@ handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll)
/* This is where the work happens ! */
connection_activity( c );
}
- else if (( idletimeout = compute_idletimeout( slapdFrontendConfig,
- c )) > 0 &&
+ else if (( c->c_ideltimeout > 0 &&
c->c_prfd == ct->fd[i].fd &&
- (curtime - c->c_idlesince) >= idletimeout &&
+ (curtime - c->c_idlesince) >= c->c_ideltimeout &&
NULL == c->c_ops )
{
/* idle timeout */
@@ -2042,9 +1985,8 @@ handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll)
SLAPD_DISCONNECT_POLL, EPIPE );
}
}
- else if (( idletimeout = compute_idletimeout(
- slapdFrontendConfig, c )) > 0 &&
- (curtime - c->c_idlesince) >= idletimeout &&
+ else if (c->c_idletimeout > 0 &&
+ (curtime - c->c_idlesince) >= c->c_idletimeout &&
NULL == c->c_ops )
{
/* idle timeout */
@@ -2613,6 +2555,7 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
PRNetAddr from;
PRFileDesc *pr_clonefd = NULL;
ber_len_t maxbersize;
+ slapdFrontendConfig_t *fecfg = getFrontendConfig();
memset(&from, 0, sizeof(from)); /* reset to nulls so we can see what was set */
if ( (ns = accept_and_configure( tcps, pr_acceptfd, &from,
@@ -2629,6 +2572,13 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
}
PR_Lock( conn->c_mutex );
+ /*
+ * Set the default idletimeout and the handle. We'll update c_idletimeout
+ * after each bind so we can correctly set the resource limit.
+ */
+ conn->c_idletimeout = fecfg->idletimeout;
+ conn->c_idletimeout_handle = idletimeout_reslimit_handle;
+
#if defined( XP_WIN32 )
if( !secure )
ber_sockbuf_set_option(conn->c_sb,LBER_SOCKBUF_OPT_DESC,&ns);
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index d88d224dc..bf9d71e6d 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -3659,6 +3659,9 @@ void
bind_credentials_set_nolock( Connection *conn, char *authtype, char *normdn,
char *extauthtype, char *externaldn, CERTCertificate *clientcert, Slapi_Entry * bind_target_entry )
{
+ slapdFrontendConfig_t *fecfg = getFrontendConfig();
+ int idletimeout = 0;
+
/* clear credentials */
bind_credentials_clear( conn, PR_FALSE /* conn is already locked */,
( extauthtype != NULL ) /* clear external creds. if requested */ );
@@ -3702,8 +3705,17 @@ bind_credentials_set_nolock( Connection *conn, char *authtype, char *normdn,
slapi_ch_free_string( &anon_dn );
}
+ if (slapi_reslimit_get_integer_limit(conn, conn->c_idletimeout_handle,
+ &idletimeout)
+ != SLAPI_RESLIMIT_STATUS_SUCCESS)
+ {
+ conn->c_idletimeout = fecfg->idletimeout;
+ } else {
+ conn->c_idletimeout = idletimeout;
+ }
} else {
/* For root dn clear about the resource limits */
reslimit_update_from_entry( conn, NULL );
+ conn->c_idletimeout = 0;
}
}
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index b5699be27..c4acb604d 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1441,7 +1441,7 @@ typedef struct conn {
char *c_authtype; /* auth method used to bind c_dn */
char *c_external_dn; /* client DN of this SSL session */
char *c_external_authtype; /* used for c_external_dn */
- PRNetAddr *cin_addr; /* address of client on this conn */
+ PRNetAddr *cin_addr; /* address of client on this conn */
PRNetAddr *cin_destaddr; /* address client connected to */
struct berval **c_domain; /* DNS names of client */
Operation *c_ops; /* list of pending operations */
@@ -1458,6 +1458,8 @@ typedef struct conn {
PRLock *c_mutex; /* protect each conn structure */
PRLock *c_pdumutex; /* only write one pdu at a time */
time_t c_idlesince; /* last time of activity on conn */
+ int c_idletimeout; /* local copy of idletimeout */
+ int c_idletimeout_handle; /* the resource limits handle */
Conn_private *c_private; /* data which is not shared outside*/
/* connection.c */
int c_flags; /* Misc flags used only for SSL */
| 0 |
83949f6d50252b56c594e9fcad3ef6c5330dfb9e
|
389ds/389-ds-base
|
Issue 5534 - Fix a rebase typo (#5537)
Description: Fix a minor typo in config/compact_test.py.
Related: https://github.com/389ds/389-ds-base/issues/5534
Reviewed by: @mreynolds389 (Thanks!)
|
commit 83949f6d50252b56c594e9fcad3ef6c5330dfb9e
Author: Simon Pichugin <[email protected]>
Date: Fri Nov 18 09:21:32 2022 -0800
Issue 5534 - Fix a rebase typo (#5537)
Description: Fix a minor typo in config/compact_test.py.
Related: https://github.com/389ds/389-ds-base/issues/5534
Reviewed by: @mreynolds389 (Thanks!)
diff --git a/dirsrvtests/tests/suites/config/compact_test.py b/dirsrvtests/tests/suites/config/compact_test.py
index 2ddae0fa9..3cc50963e 100644
--- a/dirsrvtests/tests/suites/config/compact_test.py
+++ b/dirsrvtests/tests/suites/config/compact_test.py
@@ -5,11 +5,7 @@
# License: GPL (version 3 or any later version).
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
-<<<<<<< HEAD
-
-=======
#
->>>>>>> 4a5f6a8c2 (Issue 5534 - Add copyright text to the repository files)
import logging
import pytest
import os
| 0 |
604bcdeeea0aa365628a288cbae90b250cd04c09
|
389ds/389-ds-base
|
Ticket 88 - python install and remove for tests
Bug Description: We need to be able to test instances with python
and no perl tools. This will help us to progress and remove perl
from the codebase, helping improve our portability.
Fix Description: Add support to remove instances with python.
Fix some setup python issues. Improve the lib389 test suite
to handle some of the edge cases acound the changes.
In general, this helps to improve our python 3 support across
the board as this allows us to perform pure python 3 installs
and tests.
https://pagure.io/lib389/issue/88
Author: wibrown
Review by: spichugi (Thank you!)
|
commit 604bcdeeea0aa365628a288cbae90b250cd04c09
Author: William Brown <[email protected]>
Date: Mon Aug 7 15:53:13 2017 +1000
Ticket 88 - python install and remove for tests
Bug Description: We need to be able to test instances with python
and no perl tools. This will help us to progress and remove perl
from the codebase, helping improve our portability.
Fix Description: Add support to remove instances with python.
Fix some setup python issues. Improve the lib389 test suite
to handle some of the edge cases acound the changes.
In general, this helps to improve our python 3 support across
the board as this allows us to perform pure python 3 installs
and tests.
https://pagure.io/lib389/issue/88
Author: wibrown
Review by: spichugi (Thank you!)
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 4f6dafb5e..6a9608952 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -916,6 +916,7 @@ class DirSrv(SimpleLDAPObject, object):
instance with the same 'serverid'
"""
# check that DirSrv was in DIRSRV_STATE_ALLOCATED state
+ self.log.debug("Server is in state %s" % self.state)
if self.state != DIRSRV_STATE_ALLOCATED:
raise ValueError("invalid state for calling create: %s" %
self.state)
@@ -927,14 +928,8 @@ class DirSrv(SimpleLDAPObject, object):
if not self.serverid:
raise ValueError("SER_SERVERID_PROP is missing, " +
"it is required to create an instance")
-
- # Check how we want to be installed.
- env_pyinstall = False
- if os.getenv('PYINSTALL', False) is not False:
- env_pyinstall = True
# Time to create the instance and retrieve the effective sroot
-
- if (env_pyinstall or pyinstall):
+ if (not self.ds_paths.perl_enabled or pyinstall):
self._createPythonDirsrv(version)
else:
self._createDirsrv()
@@ -946,7 +941,7 @@ class DirSrv(SimpleLDAPObject, object):
# Now the instance is created but DirSrv is not yet connected to it
self.state = DIRSRV_STATE_OFFLINE
- def delete(self):
+ def _deleteDirsrv(self):
'''
Deletes the instance with the parameters sets in dirsrv
The state changes -> DIRSRV_STATE_ALLOCATED
@@ -997,6 +992,16 @@ class DirSrv(SimpleLDAPObject, object):
self.state = DIRSRV_STATE_ALLOCATED
+ def delete(self, pyinstall=False):
+ # Time to create the instance and retrieve the effective sroot
+ if (not self.ds_paths.perl_enabled or pyinstall):
+ from lib389.instance.remove import remove_ds_instance
+ remove_ds_instance(self)
+ else:
+ self._deleteDirsrv()
+ # Now, we are still an allocated ds object so we can be re-installed
+ self.state = DIRSRV_STATE_ALLOCATED
+
def open(self, saslmethod=None, sasltoken=None, certdir=None, starttls=False, connOnly=False, reqcert=ldap.OPT_X_TLS_HARD,
usercert=None, userkey=None):
'''
@@ -3036,7 +3041,7 @@ class DirSrv(SimpleLDAPObject, object):
self.set_option(ldap.OPT_SERVER_CONTROLS, [])
return resp_data, decoded_resp_ctrls
- def buildLDIF(self, num, ldif_file, suffix='dc=example,dc=com'):
+ def buildLDIF(self, num, ldif_file, suffix='dc=example,dc=com', pyinstall=False):
"""Generate a simple ldif file using the dbgen.pl script, and set the
ownership and permissions to match the user that the server runs as.
@@ -3046,18 +3051,21 @@ class DirSrv(SimpleLDAPObject, object):
@return - nothing
@raise - OSError
"""
- try:
- os.system('%s -s %s -n %d -o %s' % (os.path.join(self.ds_paths.bin_dir, 'dbgen.pl'), suffix, num, ldif_file))
- os.chmod(ldif_file, 0o644)
- if os.getuid() == 0:
- # root user - chown the ldif to the server user
- uid = pwd.getpwnam(self.userid).pw_uid
- gid = grp.getgrnam(self.userid).gr_gid
- os.chown(ldif_file, uid, gid)
- except OSError as e:
- log.exception('Failed to create ldif file (%s): error %d - %s' %
- (ldif_file, e.errno, e.strerror))
- raise e
+ if (not self.ds_paths.perl_enabled or pyinstall):
+ raise Exception("Perl tools disabled on this system. Try dbgen py module.")
+ else:
+ try:
+ os.system('%s -s %s -n %d -o %s' % (os.path.join(self.ds_paths.bin_dir, 'dbgen.pl'), suffix, num, ldif_file))
+ os.chmod(ldif_file, 0o644)
+ if os.getuid() == 0:
+ # root user - chown the ldif to the server user
+ uid = pwd.getpwnam(self.userid).pw_uid
+ gid = grp.getgrnam(self.userid).gr_gid
+ os.chown(ldif_file, uid, gid)
+ except OSError as e:
+ log.exception('Failed to create ldif file (%s): error %d - %s' %
+ (ldif_file, e.errno, e.strerror))
+ raise e
def getConsumerMaxCSN(self, replica_entry):
"""
diff --git a/src/lib389/lib389/_entry.py b/src/lib389/lib389/_entry.py
index cf0481731..b8cb4c451 100644
--- a/src/lib389/lib389/_entry.py
+++ b/src/lib389/lib389/_entry.py
@@ -63,7 +63,6 @@ class Entry(object):
If creating a new empty entry, data is the string DN.
"""
self.ref = None
- self.data = None
if entrydata:
if isinstance(entrydata, tuple):
if entrydata[0] is None:
@@ -74,12 +73,11 @@ class Entry(object):
elif isinstance(entrydata, six.string_types):
if '=' not in entrydata:
raise ValueError('Entry dn must contain "="')
-
self.dn = entrydata
self.data = cidict()
else:
- self.dn = ''
self.data = cidict()
+ self.dn = None
def __bool__(self):
"""
@@ -134,7 +132,7 @@ class Entry(object):
# We can't actually enforce this because cidict doesn't inherit Mapping
# if not isinstance(self.data, collections.Mapping):
# raise Exception('Invalid data type for Entry')
- return name in self.data
+ return ensure_str(name) in self.data
def __getitem__(self, name):
# This should probably return getValues?
@@ -234,15 +232,21 @@ class Entry(object):
"""
# For python3, we have to make sure EVERYTHING is a byte string.
# Else everything EXPLODES
- lt = list(self.data.items())
+ lt = None
if MAJOR >= 3:
- ltnew = []
- for l in lt:
- vals = []
- for v in l[1]:
- vals.append(ensure_bytes(v))
- ltnew.append((l[0], vals))
- lt = ltnew
+ # This converts the dict to a list of tuples,
+ lt = []
+ for k in self.data.keys():
+ # l here is the
+ vals = None
+ if isinstance(self.data[k], list) or isinstance(self.data[k], tuple):
+ vals = ensure_list_bytes(self.data[k])
+ else:
+ vals = ensure_list_bytes([self.data[k]])
+ lt.append((k, vals))
+ # lt is now complete.
+ else:
+ lt = list(self.data.items())
return lt
def getref(self):
diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py
index c98f1bc69..d4bfd0a7c 100644
--- a/src/lib389/lib389/_mapped_object.py
+++ b/src/lib389/lib389/_mapped_object.py
@@ -88,7 +88,7 @@ class DSLdapObject(DSLogging):
# This allows some factor objects to be overriden
self._dn = None
if dn is not None:
- self._dn = dn
+ self._dn = ensure_str(dn)
self._batch = batch
self._protected = True
@@ -440,13 +440,13 @@ class DSLdapObject(DSLogging):
v = properties.get(self._rdn_attribute)
rdn = ensure_str(v[0])
- erdn = ldap.dn.escape_dn_chars(rdn)
+ erdn = ensure_str(ldap.dn.escape_dn_chars(rdn))
self._log.debug("Using first property %s: %s as rdn" % (self._rdn_attribute, erdn))
# Now we compare. If we changed this value, we have to put it back to make the properties complete.
if erdn != rdn:
properties[self._rdn_attribute].append(erdn)
- tdn = '%s=%s,%s' % (self._rdn_attribute, erdn, basedn)
+ tdn = ensure_str('%s=%s,%s' % (self._rdn_attribute, erdn, basedn))
# We may need to map over the data in the properties dict to satisfy python-ldap
str_props = {}
@@ -458,11 +458,12 @@ class DSLdapObject(DSLogging):
def create(self, rdn=None, properties=None, basedn=None):
assert(len(self._create_objectclasses) > 0)
+ basedn = ensure_str(basedn)
self._log.debug('Creating "%s" under %s : %s' % (rdn, basedn, properties))
# Add the objectClasses to the properties
(dn, valid_props) = self._validate(rdn, properties, basedn)
# Check if the entry exists or not? .add_s is going to error anyway ...
- self._log.debug('Validated %s : %s' % (dn, valid_props))
+ self._log.debug('Validated dn %s : valid_props %s' % (dn, valid_props))
e = Entry(dn)
e.update({'objectclass': ensure_list_bytes(self._create_objectclasses)})
diff --git a/src/lib389/lib389/configurations/config_001003006.py b/src/lib389/lib389/configurations/config_001003006.py
index 1089dc76a..8c2895fa0 100644
--- a/src/lib389/lib389/configurations/config_001003006.py
+++ b/src/lib389/lib389/configurations/config_001003006.py
@@ -25,8 +25,7 @@ class c001003006_sample_entries(sampleentries):
# All the checks are done, apply them.
def _apply(self):
# Create the base domain object
- domain = Domain(self._instance)
- domain._dn = self._basedn
+ domain = Domain(self._instance, dn=self._basedn)
# Explode the dn to get the first bit.
avas = dn.str2dn(self._basedn)
dc_ava = avas[0][0][1]
@@ -111,7 +110,7 @@ class c001003006(baseconfig):
super(c001003006, self).__init__(instance)
self._operations = [
# Create plugin configs first
- c001003006_whoami_plugin(self._instance)
+ # c001003006_whoami_plugin(self._instance)
# Create our sample entries.
# op001003006_sample_entries(self._instance),
]
diff --git a/src/lib389/lib389/configurations/sample.py b/src/lib389/lib389/configurations/sample.py
index d0fbd16de..a2292f527 100644
--- a/src/lib389/lib389/configurations/sample.py
+++ b/src/lib389/lib389/configurations/sample.py
@@ -6,10 +6,12 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
+from lib389.utils import ensure_str
+
class sampleentries(object):
def __init__(self, instance, basedn):
self._instance = instance
- self._basedn = basedn
+ self._basedn = ensure_str(basedn)
self.description = None
def apply(self):
diff --git a/src/lib389/lib389/dbgen.py b/src/lib389/lib389/dbgen.py
new file mode 100644
index 000000000..a0cda9430
--- /dev/null
+++ b/src/lib389/lib389/dbgen.py
@@ -0,0 +1,191 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+# Replacement of the dbgen.pl utility
+
+import random
+import os
+import pwd
+import grp
+
+DBGEN_POSITIONS = [
+"Accountant",
+"Admin",
+"Architect",
+"Assistant",
+"Artist",
+"Consultant",
+"Czar",
+"Dictator",
+"Director",
+"Diva",
+"Dreamer",
+"Evangelist",
+"Engineer",
+"Figurehead",
+"Fellow",
+"Grunt",
+"Guru",
+"Janitor",
+"Madonna",
+"Manager",
+"Pinhead",
+"President",
+"Punk",
+"Sales Rep",
+"Stooge",
+"Visionary",
+"Vice President",
+"Writer",
+"Warrior",
+"Yahoo"
+]
+
+DBGEN_TITLE_LEVELS = [
+"Senior",
+"Master",
+"Associate",
+"Junior",
+"Chief",
+"Supreme",
+"Elite"
+]
+
+DBGEN_LOCATIONS = [
+"Mountain View", "Redmond", "Redwood Shores", "Armonk",
+"Cambridge", "Santa Clara", "Sunnyvale", "Alameda",
+"Cupertino", "Menlo Park", "Palo Alto", "Orem",
+"San Jose", "San Francisco", "Milpitas", "Hartford", "Windsor",
+"Boston", "New York", "Detroit", "Dallas", "Denver", "Brisbane",
+]
+
+DBGEN_OUS = [
+"Accounting",
+"Product Development",
+"Product Testing",
+"Human Resources",
+"Payroll",
+]
+
+DBGEN_TEMPLATE = """dn: {DN}
+objectClass: top
+objectClass: person
+objectClass: organizationalPerson
+objectClass: inetOrgPerson
+cn: {FIRST} {LAST}
+sn: {LAST}
+uid: {UID}
+givenName: {FIRST}
+description: 2;7613;CN=Red Hat CS 71GA Demo,O=Red Hat CS 71GA Demo,C=US;CN=RHCS Agent - admin01,UID=admin01,O=redhat,C=US [1] This is {FIRST} {LAST}'s description.
+userPassword: {UID}
+departmentNumber: 1230
+employeeType: Manager
+homePhone: +1 303 937-6482
+initials: {INITIALS}
+telephoneNumber: +1 303 573-9570
+facsimileTelephoneNumber: +1 415 408-8176
+mobile: +1 818 618-1671
+pager: +1 804 339-6298
+roomNumber: 5164
+carLicense: 21SJJAG
+l: {LOCATION}
+ou: {OU}
+mail: {FIRST}.{LAST}@example.com
+postalAddress: 518, Dept #851, Room#{OU}
+title: {TITLE}
+usercertificate;binary:: MIIBvjCCASegAwIBAgIBAjANBgkqhkiG9w0BAQQFADAnMQ8wDQYD
+ VQQDEwZjb25maWcxFDASBgNVBAMTC01NUiBDQSBDZXJ0MB4XDTAxMDQwNTE1NTEwNloXDTExMDcw
+ NTE1NTEwNlowIzELMAkGA1UEChMCZnIxFDASBgNVBAMTC01NUiBTMSBDZXJ0MIGfMA0GCSqGSIb3
+ DQEBAQUAA4GNADCBiQKBgQDNlmsKEaPD+o3mAUwmW4E40MPs7aiui1YhorST3KzVngMqe5PbObUH
+ MeJN7CLbq9SjXvdB3y2AoVl/s5UkgGz8krmJ8ELfUCU95AQls321RwBdLRjioiQ3MGJiFjxwYRIV
+ j1CUTuX1y8dC7BWvZ1/EB0yv0QDtp2oVMUeoK9/9sQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBADev
+ hxY6QyDMK3Mnr7vLGe/HWEZCObF+qEo2zWScGH0Q+dAmhkCCkNeHJoqGN4NWjTdnBcGaAr5Y85k1
+ o/vOAMBsZePbYx4SrywL0b/OkOmQX+mQwieC2IQzvaBRyaNMh309vrF4w5kExReKfjR/gXpHiWQz
+ GSxC5LeQG4k3IP34
+
+"""
+
+DBGEN_HEADER = """dn: {SUFFIX}
+objectClass: top
+objectClass: domain
+dc: example
+aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl1"; allow(write) userdn = "ldap:///self";)
+aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl2"; allow(write) groupdn = "ldap:///cn=Directory Administrators, {SUFFIX}";)
+aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl3"; allow(read, search, compare) userdn = "ldap:///anyone";)
+
+dn: ou=Accounting,{SUFFIX}
+objectClass: top
+objectClass: organizationalUnit
+ou: Accounting
+
+dn: ou=Product Development,{SUFFIX}
+objectClass: top
+objectClass: organizationalUnit
+ou: Product Development
+
+dn: ou=Product Testing,{SUFFIX}
+objectClass: top
+objectClass: organizationalUnit
+ou: Product Testing
+
+dn: ou=Human Resources,{SUFFIX}
+objectClass: top
+objectClass: organizationalUnit
+ou: Human Resources
+
+dn: ou=Payroll,{SUFFIX}
+objectClass: top
+objectClass: organizationalUnit
+ou: Payroll
+
+"""
+
+def dbgen(instance, number, ldif_file, suffix):
+ 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 = []
+ givennames = []
+ with open(familyname_file, 'r') as f:
+ familynames = [n.strip() for n in f]
+ with open(givename_file, 'r') as f:
+ givennames = [n.strip() for n in f]
+
+ with open(ldif_file, 'w') as output:
+ output.write(DBGEN_HEADER.format(SUFFIX=suffix))
+ for i in range(0, number):
+ # Pick a random ou
+ ou = random.choice(DBGEN_OUS)
+ first = random.choice(givennames)
+ last = random.choice(familynames)
+ # How do we subscript from a generator?
+ initials = "%s. %s" % (first[0], last[0])
+ uid = "%s%s%s" % (first[0], last, i)
+ dn = "uid=%s,ou=%s,%s" % (uid, ou, suffix)
+ l = random.choice(DBGEN_LOCATIONS)
+ title = "%s %s" % (random.choice(DBGEN_TITLE_LEVELS), random.choice(DBGEN_POSITIONS))
+ output.write(DBGEN_TEMPLATE.format(
+ DN=dn,
+ UID=uid,
+ FIRST=first,
+ LAST=last,
+ INITIALS=initials,
+ OU=ou,
+ LOCATION=l,
+ TITLE=title,
+ SUFFIX=suffix
+ ))
+
+ # Make the file owned by dirsrv
+ os.chmod(ldif_file, 0o644)
+ if os.getuid() == 0:
+ # root user - chown the ldif to the server user
+ uid = pwd.getpwnam(instance.userid).pw_uid
+ gid = grp.getgrnam(instance.userid).gr_gid
+ os.chown(ldif_file, uid, gid)
+
+
diff --git a/src/lib389/lib389/idm/group.py b/src/lib389/lib389/idm/group.py
index bcb15eda7..5de12945e 100644
--- a/src/lib389/lib389/idm/group.py
+++ b/src/lib389/lib389/idm/group.py
@@ -7,7 +7,7 @@
# --- END COPYRIGHT BLOCK ---
from lib389._mapped_object import DSLdapObject, DSLdapObjects
-from lib389.utils import ds_is_older
+from lib389.utils import ds_is_older, ensure_str
MUST_ATTRIBUTES = [
'cn',
@@ -46,7 +46,7 @@ class Groups(DSLdapObjects):
]
self._filterattrs = [RDN]
self._childobject = Group
- self._basedn = '{},{}'.format(rdn, basedn)
+ self._basedn = '{},{}'.format(ensure_str(rdn), ensure_str(basedn))
class UniqueGroup(DSLdapObject):
# WARNING!!!
diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py
new file mode 100644
index 000000000..689b5bd5d
--- /dev/null
+++ b/src/lib389/lib389/instance/remove.py
@@ -0,0 +1,54 @@
+# --- 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 os
+import shutil
+
+def remove_ds_instance(dirsrv):
+ """
+ This will delete the instance as it is define. This must be a local instance.
+ """
+ _log = dirsrv.log.getChild('remove_ds')
+ _log.debug("Removing instance %s" % dirsrv.serverid)
+ # Stop the instance (if running)
+ _log.debug("Stopping instance %s" % dirsrv.serverid)
+ dirsrv.stop()
+ # Copy all the paths we are about to tamp with
+ remove_paths = {}
+ remove_paths['backup_dir'] = dirsrv.ds_paths.backup_dir
+ remove_paths['cert_dir'] = dirsrv.ds_paths.cert_dir
+ remove_paths['config_dir'] = dirsrv.ds_paths.config_dir
+ remove_paths['db_dir'] = dirsrv.ds_paths.db_dir
+ remove_paths['ldif_dir'] = dirsrv.ds_paths.ldif_dir
+ remove_paths['lock_dir'] = dirsrv.ds_paths.lock_dir
+ remove_paths['log_dir'] = dirsrv.ds_paths.log_dir
+ remove_paths['run_dir'] = dirsrv.ds_paths.run_dir
+
+ marker_path = "%s/sysconfig/dirsrv-%s" % (dirsrv.ds_paths.sysconf_dir, dirsrv.serverid)
+
+ # Check the marker exists. If it *does not* warn about this, and say that to
+ # force removal you should touch this file.
+
+ _log.debug("Checking for instance marker at %s" % marker_path)
+ assert os.path.exists(marker_path)
+
+ # Remove these paths:
+ # for path in ('backup_dir', 'cert_dir', 'config_dir', 'db_dir',
+ # 'ldif_dir', 'lock_dir', 'log_dir', 'run_dir'):
+ for path_k in remove_paths:
+ if os.path.exists(remove_paths[path_k]):
+ _log.debug("Removing %s" % remove_paths[path_k])
+ shutil.rmtree(remove_paths[path_k])
+
+ # Finally remove the sysconfig marker.
+ os.remove(marker_path)
+ _log.debug("Removing %s" % marker_path)
+
+ # Done!
+ _log.debug("Complete")
+
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
index f7468d104..cc94b4887 100644
--- a/src/lib389/lib389/instance/setup.py
+++ b/src/lib389/lib389/instance/setup.py
@@ -376,7 +376,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-minimal.ldif')) as template_dse:
+ with open(os.path.join(slapd['data_dir'], 'dirsrv', 'data', 'template-dse.ldif')) as template_dse:
for line in template_dse.readlines():
dse += line.replace('%', '{', 1).replace('%', '}', 1)
@@ -452,14 +452,3 @@ class SetupDs(object):
if self.containerised:
ds_instance.stop()
- def _remove_ds(self):
- """
- The opposite of install: Removes an instance from the system.
- This takes a backup of all relevant data, and removes the paths.
- """
- # This probably actually would need to be able to read the ldif, to
- # know what to remove ...
- for path in ('backup_dir', 'cert_dir', 'config_dir', 'db_dir',
- 'ldif_dir', 'lock_dir', 'log_dir', 'run_dir'):
- print(path)
-
diff --git a/src/lib389/lib389/passwd.py b/src/lib389/lib389/passwd.py
index 58d6637d8..f36d73eab 100644
--- a/src/lib389/lib389/passwd.py
+++ b/src/lib389/lib389/passwd.py
@@ -35,7 +35,7 @@ PWSCHEMES = [
def password_hash(pw, scheme=BESTSCHEME, bin_dir='/bin'):
# Check that the binary exists
assert(scheme in PWSCHEMES)
- pwdhashbin = os.path.join(bin_dir, 'pwdhash-bin')
+ pwdhashbin = os.path.join(bin_dir, 'pwdhash')
assert(os.path.isfile(pwdhashbin))
h = subprocess.check_output([pwdhashbin, '-s', scheme, pw]).strip()
return h.decode('utf-8')
diff --git a/src/lib389/lib389/paths.py b/src/lib389/lib389/paths.py
index f0a4c1b9c..cc2f6cd14 100644
--- a/src/lib389/lib389/paths.py
+++ b/src/lib389/lib389/paths.py
@@ -139,6 +139,7 @@ class Paths(object):
return True
def __getattr__(self, name):
+ from lib389.utils import ensure_str
if self._defaults_cached is False:
self._read_defaults()
self._validate_defaults()
@@ -147,12 +148,12 @@ class Paths(object):
# Get the online value.
(dn, attr) = CONFIG_MAP[name]
ent = self._instance.getEntry(dn, attrlist=[attr,])
- return ent.getValue(attr)
+ return ensure_str(ent.getValue(attr))
elif self._serverid is not None:
- return self._config.get(SECTION, name).format(instance_name=self._serverid)
+ return ensure_str(self._config.get(SECTION, name).format(instance_name=self._serverid))
else:
- return self._config.get(SECTION, name)
+ return ensure_str(self._config.get(SECTION, name))
@property
def asan_enabled(self):
@@ -173,3 +174,13 @@ class Paths(object):
if self._config.get(SECTION, 'with_systemd') == '1':
return True
return False
+
+ @property
+ def perl_enabled(self):
+ if self._defaults_cached is False:
+ self._read_defaults()
+ self._validate_defaults()
+ if self._config.has_option(SECTION, 'enable_perl'):
+ if self._config.get(SECTION, 'enable_perl') == 'no':
+ return False
+ return True
diff --git a/src/lib389/lib389/tasks.py b/src/lib389/lib389/tasks.py
index 2c62dce34..7deb87b21 100644
--- a/src/lib389/lib389/tasks.py
+++ b/src/lib389/lib389/tasks.py
@@ -18,7 +18,7 @@ from lib389.exceptions import Error
from lib389._constants import (
DEFAULT_SUFFIX, DEFAULT_BENAME, DN_EXPORT_TASK, DN_BACKUP_TASK,
DN_IMPORT_TASK, DN_RESTORE_TASK, DN_INDEX_TASK, DN_MBO_TASK,
- DN_TOMB_FIXUP_TASK, DN_TASKS
+ DN_TOMB_FIXUP_TASK, DN_TASKS, DIRSRV_STATE_ONLINE
)
from lib389.properties import (
TASK_WAIT, EXPORT_REPL_INFO, MT_PROPNAME_TO_ATTRNAME, MT_SUFFIX,
@@ -153,6 +153,8 @@ class Tasks(object):
@raise ValueError
'''
+ if self.conn.state != DIRSRV_STATE_ONLINE:
+ raise ValueError("Invalid Server State %s! Must be online" % self.conn.state)
# Checking the parameters
if not benamebase and not suffix:
@@ -177,11 +179,7 @@ class Tasks(object):
entry.setValues('nsIncludeSuffix', suffix)
# start the task and possibly wait for task completion
- try:
- self.conn.add_s(entry)
- except ldap.ALREADY_EXISTS:
- self.log.error("Fail to add the import task of %s" % input_file)
- return -1
+ self.conn.add_s(entry)
exitCode = 0
if args and args.get(TASK_WAIT, False):
diff --git a/src/lib389/lib389/tests/instance/setup_test.py b/src/lib389/lib389/tests/instance/setup_test.py
index 04ae34fd7..aa2d13b63 100644
--- a/src/lib389/lib389/tests/instance/setup_test.py
+++ b/src/lib389/lib389/tests/instance/setup_test.py
@@ -12,6 +12,7 @@ import pytest
from lib389 import DirSrv
from lib389.cli_base import LogCapture
from lib389.instance.setup import SetupDs
+from lib389.instance.remove import remove_ds_instance
from lib389.instance.options import General2Base, Slapd2Base
from lib389._constants import *
@@ -105,6 +106,8 @@ def test_setup_ds_minimal(topology):
# Make sure we can start stop.
topology.standalone.stop()
topology.standalone.start()
+ # Okay, actually remove the instance
+ remove_ds_instance(topology.standalone)
def test_setup_ds_inf_minimal(topology):
| 0 |
8eb7f7d52765adfe9cd9ff7793f81dfff0bd445b
|
389ds/389-ds-base
|
Resolves #329951
Summary: MMR: Supplier does not respond anymore after many operations (deletes)
Description: introduce OP_FLAG_REPL_RUV. It's set in repl5_replica.c if the
entry is RUV. The operation should not be blocked at the backend SERIAL lock
(this is achieved by having OP_FLAG_REPL_FIXUP set in the operation flag).
But updating RUV has nothing to do with VLV, thus if the flag is set, it skips
the VLV indexing.
|
commit 8eb7f7d52765adfe9cd9ff7793f81dfff0bd445b
Author: Noriko Hosoi <[email protected]>
Date: Thu Oct 18 22:40:18 2007 +0000
Resolves #329951
Summary: MMR: Supplier does not respond anymore after many operations (deletes)
Description: introduce OP_FLAG_REPL_RUV. It's set in repl5_replica.c if the
entry is RUV. The operation should not be blocked at the backend SERIAL lock
(this is achieved by having OP_FLAG_REPL_FIXUP set in the operation flag).
But updating RUV has nothing to do with VLV, thus if the flag is set, it skips
the VLV indexing.
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index 2c64382ab..ad701b671 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -846,39 +846,39 @@ multimaster_postop_modrdn (Slapi_PBlock *pb)
static void
copy_operation_parameters(Slapi_PBlock *pb)
{
- Slapi_Operation *op = NULL;
- struct slapi_operation_parameters *op_params;
- supplier_operation_extension *opext;
+ Slapi_Operation *op = NULL;
+ struct slapi_operation_parameters *op_params;
+ supplier_operation_extension *opext;
Object *repl_obj;
Replica *replica;
-
+
repl_obj = replica_get_replica_for_op (pb);
/* we are only interested in the updates to replicas */
if (repl_obj)
{
/* we only save the original operation parameters for replicated operations
- since client operations don't go through urp engine and pblock data can be logged */
- slapi_pblock_get( pb, SLAPI_OPERATION, &op );
- PR_ASSERT (op);
+ since client operations don't go through urp engine and pblock data can be logged */
+ slapi_pblock_get( pb, SLAPI_OPERATION, &op );
+ PR_ASSERT (op);
replica = (Replica*)object_get_data (repl_obj);
- PR_ASSERT (replica);
+ PR_ASSERT (replica);
opext = (supplier_operation_extension*) repl_sup_get_ext (REPL_SUP_EXT_OP, op);
- if (operation_is_flag_set(op,OP_FLAG_REPLICATED) &&
+ if (operation_is_flag_set(op,OP_FLAG_REPLICATED) &&
!operation_is_flag_set(op, OP_FLAG_REPL_FIXUP))
- {
- slapi_pblock_get (pb, SLAPI_OPERATION_PARAMETERS, &op_params);
- opext->operation_parameters= operation_parameters_dup(op_params);
- }
-
- /* this condition is needed to avoid re-entering lock when
- ruv state is updated */
+ {
+ slapi_pblock_get (pb, SLAPI_OPERATION_PARAMETERS, &op_params);
+ opext->operation_parameters= operation_parameters_dup(op_params);
+ }
+
+ /* this condition is needed to avoid re-entering backend serial lock
+ when ruv state is updated */
if (!operation_is_flag_set(op, OP_FLAG_REPL_FIXUP))
{
- /* save replica generation in case it changes */
- opext->repl_gen = replica_get_generation (replica);
+ /* save replica generation in case it changes */
+ opext->repl_gen = replica_get_generation (replica);
}
object_release (repl_obj);
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 40e84da45..702754e3e 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -2258,7 +2258,8 @@ replica_write_ruv (Replica *r)
RUV_STORAGE_ENTRY_UNIQUEID,
repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION),
/* Add OP_FLAG_TOMBSTONE_ENTRY so that this doesn't get logged in the Retro ChangeLog */
- OP_FLAG_REPLICATED | OP_FLAG_REPL_FIXUP | OP_FLAG_TOMBSTONE_ENTRY);
+ OP_FLAG_REPLICATED | OP_FLAG_REPL_FIXUP | OP_FLAG_TOMBSTONE_ENTRY |
+ OP_FLAG_REPL_RUV );
slapi_modify_internal_pb (pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
@@ -2732,7 +2733,8 @@ replica_create_ruv_tombstone(Replica *r)
e,
NULL /* controls */,
repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION),
- OP_FLAG_TOMBSTONE_ENTRY | OP_FLAG_REPLICATED | OP_FLAG_REPL_FIXUP);
+ OP_FLAG_TOMBSTONE_ENTRY | OP_FLAG_REPLICATED | OP_FLAG_REPL_FIXUP |
+ OP_FLAG_REPL_RUV);
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
if (return_value == LDAP_SUCCESS)
@@ -3064,7 +3066,7 @@ replica_replace_ruv_tombstone(Replica *r)
NULL, /* controls */
RUV_STORAGE_ENTRY_UNIQUEID,
repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION),
- OP_FLAG_REPLICATED | OP_FLAG_REPL_FIXUP);
+ OP_FLAG_REPLICATED | OP_FLAG_REPL_FIXUP | OP_FLAG_REPL_RUV);
slapi_modify_internal_pb (pb);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 2a5a5cd70..764cff995 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -104,6 +104,7 @@ ldbm_back_add( Slapi_PBlock *pb )
int is_resurect_operation= 0;
int is_tombstone_operation= 0;
int is_fixup_operation= 0;
+ int is_ruv = 0; /* True if the current entry is RUV */
CSN *opcsn = NULL;
entry_address addr;
@@ -118,12 +119,13 @@ ldbm_back_add( Slapi_PBlock *pb )
is_resurect_operation= operation_is_flag_set(operation,OP_FLAG_RESURECT_ENTRY);
is_tombstone_operation= operation_is_flag_set(operation,OP_FLAG_TOMBSTONE_ENTRY);
- is_fixup_operation = operation_is_flag_set(operation,OP_FLAG_REPL_FIXUP);
+ 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;
-
- slapi_sdn_init(&sdn);
- slapi_sdn_init(&parentsdn);
+
+ slapi_sdn_init(&sdn);
+ slapi_sdn_init(&parentsdn);
/* Get rid of ldbm backend attributes that you are not allowed to specify yourself */
slapi_entry_delete_values( e, hassubordinates, NULL );
@@ -145,7 +147,7 @@ ldbm_back_add( Slapi_PBlock *pb )
dblock_acquired= 1;
}
- rc= 0;
+ rc= 0;
/*
* We are about to pass the last abandon test, so from now on we are
@@ -166,8 +168,8 @@ ldbm_back_add( Slapi_PBlock *pb )
rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_DN_ENTRY);
}
rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_UNIQUEID_ENTRY);
- rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY);
- while(rc!=0)
+ rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY);
+ while(rc!=0)
{
/* JCM - copying entries can be expensive... should optimize */
/*
@@ -175,20 +177,20 @@ ldbm_back_add( Slapi_PBlock *pb )
* backend pre-op plugin. To ensure a consistent snapshot of this state
* we wrap the reading of the entry with the dblock.
*/
- if(slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_UNIQUEID_ENTRY))
+ if(slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_UNIQUEID_ENTRY))
{
- /* Check if an entry with the intended uniqueid already exists. */
+ /* Check if an entry with the intended uniqueid already exists. */
done_with_pblock_entry(pb,SLAPI_ADD_EXISTING_UNIQUEID_ENTRY); /* Could be through this multiple times */
addr.dn = NULL;
addr.uniqueid = (char*)slapi_entry_get_uniqueid(e); /* jcm - cast away const */
ldap_result_code= get_copy_of_entry(pb, &addr, &txn, SLAPI_ADD_EXISTING_UNIQUEID_ENTRY, !is_replicated_operation);
}
- if(slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_DN_ENTRY))
+ if(slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_DN_ENTRY))
{
slapi_pblock_get( pb, SLAPI_ADD_TARGET, &dn );
- slapi_sdn_set_dn_byref(&sdn, dn);
+ slapi_sdn_set_dn_byref(&sdn, dn);
slapi_sdn_get_backend_parent(&sdn,&parentsdn,pb->pb_backend);
- /* Check if an entry with the intended DN already exists. */
+ /* Check if an entry with the intended DN already exists. */
done_with_pblock_entry(pb,SLAPI_ADD_EXISTING_DN_ENTRY); /* Could be through this multiple times */
addr.dn = dn;
addr.uniqueid = NULL;
@@ -206,24 +208,24 @@ ldbm_back_add( Slapi_PBlock *pb )
/* need to set parentsdn or parentuniqueid if either is not set? */
}
- /* Call the Backend Pre Add plugins */
+ /* Call the Backend Pre Add plugins */
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- rc= plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN);
- if(rc==-1)
- {
+ rc= plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN);
+ if(rc==-1)
+ {
/*
* Plugin indicated some kind of failure,
* or that this Operation became a No-Op.
*/
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- goto error_return;
- }
+ goto error_return;
+ }
/*
* (rc!=-1 && rc!= 0) means that the plugin changed things, so we go around
* the loop once again to get the new present state.
*/
/* JCMREPL - Warning: A Plugin could cause an infinite loop by always returning a result code that requires some action. */
- }
+ }
/*
* Originally (in the U-M LDAP 3.3 code), there was a comment near this
@@ -237,7 +239,7 @@ ldbm_back_add( Slapi_PBlock *pb )
/*
* Fetch the parent entry and acquire the cache lock.
*/
- if(have_parent_address(&parentsdn, operation->o_params.p.p_add.parentuniqueid))
+ if(have_parent_address(&parentsdn, operation->o_params.p.p_add.parentuniqueid))
{
addr.dn = (char*)slapi_sdn_get_dn (&parentsdn);
addr.uniqueid = operation->o_params.p.p_add.parentuniqueid;
@@ -255,13 +257,13 @@ ldbm_back_add( Slapi_PBlock *pb )
modify_init(&parent_modify_c,parententry);
}
- /* Check if the entry we have been asked to add already exists */
+ /* Check if the entry we have been asked to add already exists */
{
Slapi_Entry *entry;
slapi_pblock_get( pb, SLAPI_ADD_EXISTING_DN_ENTRY, &entry);
if ( entry != NULL )
{
- /* The entry already exists */
+ /* The entry already exists */
ldap_result_code= LDAP_ALREADY_EXISTS;
goto error_return;
}
@@ -283,7 +285,7 @@ ldbm_back_add( Slapi_PBlock *pb )
if ( ancestorentry != NULL )
{
int sentreferral= check_entry_for_referral(pb, ancestorentry->ep_entry, backentry_get_ndn(ancestorentry), "ldbm_back_add");
- cache_return( &inst->inst_cache, &ancestorentry );
+ cache_return( &inst->inst_cache, &ancestorentry );
if(sentreferral)
{
ldap_result_code= -1; /* The result was sent by check_entry_for_referral */
@@ -316,7 +318,7 @@ ldbm_back_add( Slapi_PBlock *pb )
tombstoneentry = find_entry2modify( pb, be, &addr, NULL );
if ( tombstoneentry==NULL )
{
- ldap_result_code= -1;
+ ldap_result_code= -1;
goto error_return; /* error result sent by find_entry2modify() */
}
tombstone_in_cache = 1;
@@ -324,7 +326,7 @@ ldbm_back_add( Slapi_PBlock *pb )
addingentry = backentry_dup( tombstoneentry );
if ( addingentry==NULL )
{
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
/*
@@ -405,8 +407,8 @@ ldbm_back_add( Slapi_PBlock *pb )
addingentry = backentry_init( e );
if ( ( addingentry->ep_id = next_id( be ) ) >= MAXID ) {
LDAPDebug( LDAP_DEBUG_ANY,
- "add: maximum ID reached, cannot add entry to "
- "backend '%s'", be->be_name, 0, 0 );
+ "add: maximum ID reached, cannot add entry to "
+ "backend '%s'", be->be_name, 0, 0 );
ldap_result_code = LDAP_OPERATIONS_ERROR;
goto error_return;
}
@@ -436,11 +438,11 @@ ldbm_back_add( Slapi_PBlock *pb )
/* Directly add the entry as a tombstone */
/*
* 1) If the entry has an existing DN, change it to be
- * "nsuniqueid=<uniqueid>, <old dn>"
+ * "nsuniqueid=<uniqueid>, <old dn>"
* 2) Add the objectclass value "tombstone" and arrange for only
- * that value to be indexed.
+ * that value to be indexed.
* 3) If the parent entry was found, set the nsparentuniqueid
- * attribute to be the unique id of that parent.
+ * attribute to be the unique id of that parent.
*/
char *untombstoned_dn = slapi_entry_get_dn(e);
if (NULL == untombstoned_dn)
@@ -476,13 +478,13 @@ ldbm_back_add( Slapi_PBlock *pb )
struct backentry *ancestorentry;
LDAPDebug( LDAP_DEBUG_TRACE,
- "parent does not exist, pdn = %s\n",
- slapi_sdn_get_dn(&parentsdn), 0, 0 );
+ "parent does not exist, pdn = %s\n",
+ slapi_sdn_get_dn(&parentsdn), 0, 0 );
ancestorentry = dn2ancestor(be, &parentsdn, &ancestordn, &txn, &err );
cache_return( &inst->inst_cache, &ancestorentry );
- ldap_result_code= LDAP_NO_SUCH_OBJECT;
+ ldap_result_code= LDAP_NO_SUCH_OBJECT;
ldap_result_matcheddn= slapi_ch_strdup((char *)slapi_sdn_get_dn(&ancestordn)); /* jcm - cast away const. */
slapi_sdn_done(&ancestordn);
goto error_return;
@@ -502,8 +504,8 @@ ldbm_back_add( Slapi_PBlock *pb )
if ( !isroot && !is_replicated_operation)
{
LDAPDebug( LDAP_DEBUG_TRACE, "no parent & not root\n",
- 0, 0, 0 );
- ldap_result_code= LDAP_INSUFFICIENT_ACCESS;
+ 0, 0, 0 );
+ ldap_result_code= LDAP_INSUFFICIENT_ACCESS;
goto error_return;
}
parententry = NULL;
@@ -527,7 +529,7 @@ ldbm_back_add( Slapi_PBlock *pb )
/*
* add the parentid, entryid and entrydn operational attributes
*/
- add_update_entry_operational_attributes(addingentry, pid);
+ add_update_entry_operational_attributes(addingentry, pid);
}
/* Tentatively add the entry to the cache. We do this after adding any
@@ -560,7 +562,7 @@ ldbm_back_add( Slapi_PBlock *pb )
retval = parent_update_on_childchange(&parent_modify_c,1,NULL); /* 1==add */\
/* The modify context now contains info needed later */
if (0 != retval) {
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
parent_found = 1;
@@ -577,10 +579,10 @@ ldbm_back_add( Slapi_PBlock *pb )
/* We're re-trying */
LDAPDebug( LDAP_DEBUG_TRACE, "Add Retrying Transaction\n", 0, 0, 0 );
#ifndef LDBM_NO_BACKOFF_DELAY
- {
- PRIntervalTime interval;
- interval = PR_MillisecondsToInterval(slapi_rand() % 100);
- DS_Sleep(interval);
+ {
+ PRIntervalTime interval;
+ interval = PR_MillisecondsToInterval(slapi_rand() % 100);
+ DS_Sleep(interval);
}
#endif
}
@@ -682,7 +684,7 @@ ldbm_back_add( Slapi_PBlock *pb )
}
if (retval != 0) {
LDAPDebug( LDAP_DEBUG_ANY, "add: attempt to index %lu failed\n",
- (u_long)addingentry->ep_id, 0, 0 );
+ (u_long)addingentry->ep_id, 0, 0 );
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
disk_full = 1;
ldap_result_code= LDAP_OPERATIONS_ERROR;
@@ -705,38 +707,41 @@ ldbm_back_add( Slapi_PBlock *pb )
retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
disk_full = 1;
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
goto diskfull_return;
}
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
}
- /*
- * Update the Virtual List View indexes
- */
- retval= vlv_update_all_indexes(&txn, be, pb, NULL, addingentry);
- if (DB_LOCK_DEADLOCK == retval)
+ /*
+ * Update the Virtual List View indexes
+ */
+ if (!is_ruv)
{
- LDAPDebug( LDAP_DEBUG_ARGS, "add DEADLOCK vlv_update_index\n", 0, 0, 0 );
- /* Retry txn */
- continue;
- }
- if (0 != retval) {
- LDAPDebug( LDAP_DEBUG_TRACE, "vlv_update_index failed, err=%d %s\n",
- retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
- if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
- disk_full = 1;
+ retval= vlv_update_all_indexes(&txn, be, pb, NULL, addingentry);
+ if (DB_LOCK_DEADLOCK == retval) {
+ LDAPDebug( LDAP_DEBUG_ARGS,
+ "add DEADLOCK vlv_update_index\n", 0, 0, 0 );
+ /* Retry txn */
+ continue;
+ }
+ if (0 != retval) {
+ LDAPDebug( LDAP_DEBUG_TRACE,
+ "vlv_update_index failed, err=%d %s\n",
+ retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
+ if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
+ disk_full = 1;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
+ goto diskfull_return;
+ }
ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto diskfull_return;
+ goto error_return;
}
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
}
- if (retval == 0 ) {
+ if (retval == 0) {
break;
}
-
}
if (retry_count == RETRY_TIMES) {
/* Failed */
@@ -760,9 +765,9 @@ ldbm_back_add( Slapi_PBlock *pb )
if (cache_replace( &inst->inst_cache, tombstoneentry, addingentry ) != 0 )
{
/* This happens if the dn of addingentry already exists */
- ldap_result_code= LDAP_ALREADY_EXISTS;
+ ldap_result_code= LDAP_ALREADY_EXISTS;
cache_unlock_entry( &inst->inst_cache, tombstoneentry );
- goto error_return;
+ goto error_return;
}
/*
* The tombstone was locked down in the cache... we can
@@ -844,9 +849,9 @@ common_return:
{
dblayer_unlock_backend(be);
}
- if(ldap_result_code!=-1)
+ if(ldap_result_code!=-1)
{
- slapi_send_ldap_result( pb, ldap_result_code, ldap_result_matcheddn, ldap_result_message, 0, NULL );
+ slapi_send_ldap_result( pb, ldap_result_code, ldap_result_matcheddn, ldap_result_message, 0, NULL );
}
slapi_sdn_done(&sdn);
slapi_sdn_done(&parentsdn);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index f9e2520e9..6e6ecea28 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -73,6 +73,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
Slapi_Operation *operation;
CSN *opcsn = NULL;
int is_fixup_operation = 0;
+ int is_ruv = 0; /* True if the current entry is RUV */
int is_replicated_operation= 0;
int is_tombstone_entry = 0; /* True if the current entry is alreday a tombstone */
int delete_tombstone_entry = 0; /* We must remove the given tombstone entry from the DB */
@@ -95,7 +96,8 @@ ldbm_back_delete( Slapi_PBlock *pb )
slapi_log_error (SLAPI_LOG_TRACE, "ldbm_back_delete", "enter conn=%d op=%d\n", pb->pb_conn->c_connid, operation->o_opid);
}
- is_fixup_operation = operation_is_flag_set(operation,OP_FLAG_REPL_FIXUP);
+ is_fixup_operation = operation_is_flag_set(operation, OP_FLAG_REPL_FIXUP);
+ is_ruv = operation_is_flag_set(operation, OP_FLAG_REPL_RUV);
delete_tombstone_entry = operation_is_flag_set(operation, OP_FLAG_TOMBSTONE_ENTRY);
inst = (ldbm_instance *) be->be_instance_info;
@@ -469,7 +471,8 @@ ldbm_back_delete( Slapi_PBlock *pb )
ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
- } else if (delete_tombstone_entry)
+ } /* create_tombstone_entry */
+ else if (delete_tombstone_entry)
{
/*
* We need to remove the Tombstone entry from the remaining indexes:
@@ -521,7 +524,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
goto error_return;
}
}
- }
+ } /* delete_tombstone_entry */
if (parent_found) {
/* Push out the db modifications from the parent entry */
@@ -536,32 +539,31 @@ ldbm_back_delete( Slapi_PBlock *pb )
LDAPDebug( LDAP_DEBUG_TRACE, "delete 3 BAD, err=%d %s\n",
retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1;
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
}
/*
* first check if searchentry needs to be removed
* Remove the entry from the Virtual List View indexes.
- *
*/
- if(!delete_tombstone_entry &&
- !vlv_delete_search_entry(pb,e->ep_entry,inst)) {
+ if (!delete_tombstone_entry && !is_ruv &&
+ !vlv_delete_search_entry(pb,e->ep_entry,inst)) {
retval = vlv_update_all_indexes(&txn, be, pb, e, NULL);
+
+ if (DB_LOCK_DEADLOCK == retval)
+ {
+ LDAPDebug( LDAP_DEBUG_ARGS, "delete DEADLOCK vlv_update_index\n", 0, 0, 0 );
+ /* Retry txn */
+ continue;
+ }
+ if (retval != 0 ) {
+ if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
+ goto error_return;
+ }
}
-
- if (DB_LOCK_DEADLOCK == retval)
- {
- LDAPDebug( LDAP_DEBUG_ARGS, "delete DEADLOCK vlv_update_index\n", 0, 0, 0 );
- /* Retry txn */
- continue;
- }
- if (retval != 0 ) {
- if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1;
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
- }
- if (retval == 0 ) {
+ if (retval == 0 ) {
break;
}
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index 470c40d5b..36e842306 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -131,12 +131,18 @@ int modify_update_all(backend *be, Slapi_PBlock *pb,
back_txn *txn)
{
static char *function_name = "modify_update_all";
+ Slapi_Operation *operation;
+ int is_ruv = 0; /* True if the current entry is RUV */
int retval = 0;
- /*
- * Update the ID to Entry index.
- * Note that id2entry_add replaces the entry, so the Entry ID stays the same.
- */
+ if (pb) { /* pb could be NULL if it's called from import */
+ slapi_pblock_get( pb, SLAPI_OPERATION, &operation );
+ is_ruv = operation_is_flag_set(operation, OP_FLAG_REPL_RUV);
+ }
+ /*
+ * Update the ID to Entry index.
+ * Note that id2entry_add replaces the entry, so the Entry ID stays the same.
+ */
retval = id2entry_add( be, mc->new_entry, txn );
if ( 0 != retval ) {
if (DB_LOCK_DEADLOCK != retval)
@@ -153,13 +159,13 @@ int modify_update_all(backend *be, Slapi_PBlock *pb,
}
goto error;
}
- /*
- * Remove the old entry from the Virtual List View indexes.
- * Add the new entry to the Virtual List View indexes.
+ /*
+ * Remove the old entry from the Virtual List View indexes.
+ * Add the new entry to the Virtual List View indexes.
* Because the VLV code calls slapi_filter_test(), which requires a pb (why?),
* we allow the caller sans pb to get everything except vlv indexing.
- */
- if (NULL != pb) {
+ */
+ if (NULL != pb && !is_ruv) {
retval= vlv_update_all_indexes(txn, be, pb, mc->old_entry, mc->new_entry);
if ( 0 != retval ) {
if (DB_LOCK_DEADLOCK != retval)
@@ -189,7 +195,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
char *errbuf = NULL;
int retry_count = 0;
int disk_full = 0;
- int ldap_result_code= LDAP_SUCCESS;
+ int ldap_result_code= LDAP_SUCCESS;
char *ldap_result_message= NULL;
int rc = 0;
Slapi_Operation *operation;
@@ -198,6 +204,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
int change_entry = 0;
int ec_in_cache = 0;
int is_fixup_operation= 0;
+ int is_ruv = 0; /* True if the current entry is RUV */
CSN *opcsn = NULL;
int repl_op;
@@ -208,7 +215,8 @@ ldbm_back_modify( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_PARENT_TXN, (void**)&parent_txn );
slapi_pblock_get( pb, SLAPI_OPERATION, &operation );
slapi_pblock_get (pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op);
- is_fixup_operation = operation_is_flag_set(operation,OP_FLAG_REPL_FIXUP);
+ 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;
dblayer_txn_init(li,&txn);
@@ -221,15 +229,14 @@ ldbm_back_modify( Slapi_PBlock *pb )
* operations that the URP code in the Replication
* plugin generates.
*/
- if(SERIALLOCK(li) && !operation_is_flag_set(operation,OP_FLAG_REPL_FIXUP))
- {
+ if(SERIALLOCK(li) && !operation_is_flag_set(operation,OP_FLAG_REPL_FIXUP)) {
dblayer_lock_backend(be);
dblock_acquired= 1;
}
/* find and lock the entry we are about to modify */
if ( (e = find_entry2modify( pb, be, addr, NULL )) == NULL ) {
- ldap_result_code= -1;
+ ldap_result_code= -1;
goto error_return; /* error result sent by find_entry2modify() */
}
@@ -260,7 +267,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
/* create a copy of the entry and apply the changes to it */
if ( (ec = backentry_dup( e )) == NULL ) {
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
@@ -276,10 +283,10 @@ ldbm_back_modify( Slapi_PBlock *pb )
{
Slapi_Mods smods;
- CSN *csn = operation_get_csn(operation);
+ CSN *csn = operation_get_csn(operation);
slapi_mods_init_byref(&smods,mods);
if ( (change_entry = mods_have_effect (ec->ep_entry, &smods)) ) {
- ldap_result_code = entry_apply_mods_wsi(ec->ep_entry, &smods, csn, operation_is_flag_set(operation,OP_FLAG_REPLICATED));
+ ldap_result_code = entry_apply_mods_wsi(ec->ep_entry, &smods, csn, operation_is_flag_set(operation,OP_FLAG_REPLICATED));
/*
* XXXmcs: it would be nice to get back an error message from
* the above call so we could pass it along to the client, e.g.,
@@ -356,8 +363,8 @@ ldbm_back_modify( Slapi_PBlock *pb )
dblayer_txn_abort(li,&txn);
LDAPDebug( LDAP_DEBUG_TRACE, "Modify Retrying Transaction\n", 0, 0, 0 );
#ifndef LDBM_NO_BACKOFF_DELAY
- {
- PRIntervalTime interval;
+ {
+ PRIntervalTime interval;
interval = PR_MillisecondsToInterval(slapi_rand() % 100);
DS_Sleep(interval);
}
@@ -373,10 +380,10 @@ ldbm_back_modify( Slapi_PBlock *pb )
goto error_return;
}
- /*
- * Update the ID to Entry index.
- * Note that id2entry_add replaces the entry, so the Entry ID stays the same.
- */
+ /*
+ * Update the ID to Entry index.
+ * Note that id2entry_add replaces the entry, so the Entry ID stays the same.
+ */
retval = id2entry_add( be, ec, &txn );
if (DB_LOCK_DEADLOCK == retval)
{
@@ -404,37 +411,41 @@ ldbm_back_modify( Slapi_PBlock *pb )
ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
- /*
- * Remove the old entry from the Virtual List View indexes.
- * Add the new entry to the Virtual List View indexes.
- */
- retval= vlv_update_all_indexes(&txn, be, pb, e, ec);
- if (DB_LOCK_DEADLOCK == retval)
- {
- /* Abort and re-try */
- continue;
- }
- if (0 != retval) {
- LDAPDebug( LDAP_DEBUG_ANY, "vlv_update_index failed, err=%d %s\n",
- retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
- if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1;
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
- }
+ /*
+ * Remove the old entry from the Virtual List View indexes.
+ * Add the new entry to the Virtual List View indexes.
+ * If the entry is ruv, no need to update vlv.
+ */
+ if (!is_ruv) {
+ retval= vlv_update_all_indexes(&txn, be, pb, e, ec);
+ if (DB_LOCK_DEADLOCK == retval)
+ {
+ /* Abort and re-try */
+ continue;
+ }
+ if (0 != retval) {
+ LDAPDebug( LDAP_DEBUG_ANY,
+ "vlv_update_index failed, err=%d %s\n",
+ retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
+ if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
+ goto error_return;
+ }
+ }
if (0 == retval) {
break;
}
}
if (retry_count == RETRY_TIMES) {
LDAPDebug( LDAP_DEBUG_ANY, "Retry count exceeded in modify\n", 0, 0, 0 );
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
if (cache_replace( &inst->inst_cache, e, ec ) != 0 ) {
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
+ goto error_return;
}
postentry = slapi_entry_dup( ec->ep_entry );
@@ -473,7 +484,7 @@ error_return:
}
else
{
- backentry_free(&ec);
+ backentry_free(&ec);
}
if ( postentry != NULL )
{
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 099f25726..cc5e78bb2 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -113,7 +113,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_REQUESTOR_ISROOT, &isroot );
slapi_pblock_get( pb, SLAPI_OPERATION, &operation );
slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation );
- is_fixup_operation = operation_is_flag_set(operation,OP_FLAG_REPL_FIXUP);
+ is_fixup_operation = operation_is_flag_set(operation, OP_FLAG_REPL_FIXUP);
if (pb->pb_conn)
{
@@ -1127,8 +1127,12 @@ modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbm
ldbm_instance *inst;
int retval= 0;
char *msg;
+ Slapi_Operation *operation;
+ int is_ruv = 0; /* True if the current entry is RUV */
- slapi_pblock_get( pb, SLAPI_BACKEND, &be);
+ slapi_pblock_get( pb, SLAPI_BACKEND, &be );
+ slapi_pblock_get( pb, SLAPI_OPERATION, &operation );
+ is_ruv = operation_is_flag_set(operation, OP_FLAG_REPL_RUV);
inst = (ldbm_instance *) be->be_instance_info;
/*
@@ -1206,17 +1210,21 @@ modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbm
/*
* Remove the old entry from the Virtual List View indexes.
* Add the new entry to the Virtual List View indexes.
+ * If ruv, we don't have to update vlv.
*/
- retval= vlv_update_all_indexes(ptxn, be, pb, e, ec);
- if (DB_LOCK_DEADLOCK == retval)
+ if (!is_ruv)
{
- /* Abort and re-try */
- goto error_return;
- }
- if (retval != 0)
- {
- LDAPDebug( LDAP_DEBUG_TRACE, "vlv_update_all_indexes failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
- goto error_return;
+ retval= vlv_update_all_indexes(ptxn, be, pb, e, ec);
+ if (DB_LOCK_DEADLOCK == retval)
+ {
+ /* Abort and re-try */
+ goto error_return;
+ }
+ if (retval != 0)
+ {
+ LDAPDebug( LDAP_DEBUG_TRACE, "vlv_update_all_indexes failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
+ goto error_return;
+ }
}
if (cache_replace( &inst->inst_cache, e, ec ) != 0 ) {
retval= -1;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 320f392e6..834ce46db 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -382,27 +382,43 @@ slapi_filter_to_string_internal( const struct slapi_filter *f, char *buf, size_t
/* operation.c */
-#define OP_FLAG_PS 0x00001
-#define OP_FLAG_PS_CHANGESONLY 0x00002
-#define OP_FLAG_GET_EFFECTIVE_RIGHTS 0x00004
-#define OP_FLAG_REPLICATED 0x00008 /* A Replicated Operation */
-#define OP_FLAG_REPL_FIXUP 0x00010 /* A Fixup Operation, generated as a
- * consequence of a Replicated Operation. */
-#define OP_FLAG_INTERNAL 0x00020 /* An operation generated by the core
- * server or a plugin. */
-#define OP_FLAG_ACTION_LOG_ACCESS 0x00040
-#define OP_FLAG_ACTION_LOG_AUDIT 0x00080
-#define OP_FLAG_ACTION_SCHEMA_CHECK 0x00100
-#define OP_FLAG_ACTION_LOG_CHANGES 0x00200
-#define OP_FLAG_ACTION_INVOKE_FOR_REPLOP 0x00400
-#define OP_FLAG_NEVER_CHAIN SLAPI_OP_FLAG_NEVER_CHAIN /* 0x0800 */
-#define OP_FLAG_TOMBSTONE_ENTRY 0x01000
-#define OP_FLAG_RESURECT_ENTRY 0x02000
-#define OP_FLAG_LEGACY_REPLICATION_DN 0x04000 /* Operation done by legacy replication DN */
-#define OP_FLAG_ACTION_NOLOG 0x08000 /* Do not log the entry in audit log or
- * change log */
-#define OP_FLAG_SKIP_MODIFIED_ATTRS 0x10000 /* Do not update the modifiersname,
- * modifiedtimestamp, etc. attributes */
+#define OP_FLAG_PS 0x00001
+#define OP_FLAG_PS_CHANGESONLY 0x00002
+#define OP_FLAG_GET_EFFECTIVE_RIGHTS 0x00004
+#define OP_FLAG_REPLICATED 0x00008 /* A Replicated Operation */
+#define OP_FLAG_REPL_FIXUP 0x00010 /* A Fixup Operation,
+ * generated as a consequence
+ * of a Replicated Operation.
+ */
+#define OP_FLAG_INTERNAL 0x00020 /* An operation generated by
+ * the core server or a plugin.
+ */
+#define OP_FLAG_ACTION_LOG_ACCESS 0x00040
+#define OP_FLAG_ACTION_LOG_AUDIT 0x00080
+#define OP_FLAG_ACTION_SCHEMA_CHECK 0x00100
+#define OP_FLAG_ACTION_LOG_CHANGES 0x00200
+#define OP_FLAG_ACTION_INVOKE_FOR_REPLOP 0x00400
+#define OP_FLAG_NEVER_CHAIN SLAPI_OP_FLAG_NEVER_CHAIN /* 0x0800 */
+#define OP_FLAG_TOMBSTONE_ENTRY 0x01000
+#define OP_FLAG_RESURECT_ENTRY 0x02000
+#define OP_FLAG_LEGACY_REPLICATION_DN 0x04000 /* Operation done by legacy
+ * replication DN
+ */
+#define OP_FLAG_ACTION_NOLOG 0x08000 /* Do not log the entry in
+ * audit log or change log
+ */
+#define OP_FLAG_SKIP_MODIFIED_ATTRS 0x10000 /* Do not update the
+ * modifiersname,
+ * modifiedtimestamp, etc.
+ * attributes
+ */
+#define OP_FLAG_REPL_RUV 0x20000 /* Flag to tell to the backend
+ * that the entry to be added/
+ * modified is RUV. This info
+ * is used to skip VLV op.
+ * (see #329951)
+ */
+
CSN *operation_get_csn(Slapi_Operation *op);
void operation_set_csn(Slapi_Operation *op,CSN *csn);
| 0 |
e171a63679cce7b811cbf9232043b5ab32df5bc0
|
389ds/389-ds-base
|
Bump version to 3.1.2
|
commit e171a63679cce7b811cbf9232043b5ab32df5bc0
Author: Viktor Ashirov <[email protected]>
Date: Thu Jan 23 21:31:56 2025 +0100
Bump version to 3.1.2
diff --git a/VERSION.sh b/VERSION.sh
index 6f5924e34..d8a93e4c8 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -10,7 +10,7 @@ vendor="389 Project"
# PACKAGE_VERSION is constructed from these
VERSION_MAJOR=3
VERSION_MINOR=1
-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 |
acc1de0bd86da8a13974638f07735b54f80717e0
|
389ds/389-ds-base
|
Resolves: bug 282741
Bug Description: Show-Stopper - Migration from DS 6.21 to DS80
Reviewed by: nhosoi (Thanks!)
Fix Description: Added a new function migrateNetscapeRoot which will create a temporary LDIF file from the given NetscapeRoot.ldif file. The function will look for all \bNetscape\b occurances and convert them to @capbrand@ where that is defined as the capitalized brand name in configure. It will then import this temporary LDIF file and delete it.
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 acc1de0bd86da8a13974638f07735b54f80717e0
Author: Rich Megginson <[email protected]>
Date: Sat Sep 8 02:16:27 2007 +0000
Resolves: bug 282741
Bug Description: Show-Stopper - Migration from DS 6.21 to DS80
Reviewed by: nhosoi (Thanks!)
Fix Description: Added a new function migrateNetscapeRoot which will create a temporary LDIF file from the given NetscapeRoot.ldif file. The function will look for all \bNetscape\b occurances and convert them to @capbrand@ where that is defined as the capitalized brand name in configure. It will then import this temporary LDIF file and delete it.
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 cc0f9b3cd..d7a6336e1 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -62,6 +62,8 @@ use Mozilla::LDAP::Utils qw(normalizeDN);
use Mozilla::LDAP::API qw(ldap_explode_dn);
use Mozilla::LDAP::LDIF;
+use Carp;
+
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(migrateDS);
@@ -253,6 +255,35 @@ sub copyDatabaseDirs {
return ();
}
+# older versions may use the old Netscape names e.g. Netscape Administration Server
+# we have to convert these to the new names e.g. @capbrand@ Administration Server
+sub migrateNetscapeRoot {
+ my $ldiffile = shift;
+ my ($fh, $tmpldiffile);
+ # create a temp inf file for writing for other processes
+ # never overwrite the user supplied inf file
+ ($fh, $tmpldiffile) = tempfile("nsrootXXXXXX", UNLINK => 0,
+ SUFFIX => ".ldif", OPEN => 1,
+ DIR => File::Spec->tmpdir);
+ open( MYLDIF, "$ldiffile" ) || confess "Can't open $ldiffile: $!";
+ my $in = new Mozilla::LDAP::LDIF(*MYLDIF);
+ while (my $ent = readOneEntry $in) {
+ my $dn = $ent->getDN();
+ $dn =~ s/\bNetscape\b/@capbrand@/g;
+ $ent->setDN($dn);
+ foreach my $attr (keys %{$ent}) {
+ my @vals = $ent->getValues($attr);
+ map { s/\bNetscape\b/@capbrand@/g } @vals;
+ $ent->setValues($attr, @vals);
+ }
+ Mozilla::LDAP::LDIF::put_LDIF($fh, 78, $ent);
+ }
+ close( MYLDIF );
+ close( $fh );
+
+ return $tmpldiffile;
+}
+
# migrate all of the databases in an instance
sub migrateDatabases {
my $mig = shift; # the Migration object
@@ -269,13 +300,22 @@ sub migrateDatabases {
# database
my $foundldif;
for (glob("$mig->{oldsroot}/$inst/db/*.ldif")) {
- my $dbname = basename($_, '.ldif');
- my $cmd = "$inst_dir/ldif2db -n \"$dbname\" -i \"$_\"";
+ my $fname = $_;
+ my $dbname = basename($fname, '.ldif');
+ my $deleteflag = 0;
+ if ($fname =~ /NetscapeRoot.ldif$/) {
+ $fname = migrateNetscapeRoot($fname);
+ $deleteflag = 1;
+ }
+ my $cmd = "$inst_dir/ldif2db -n \"$dbname\" -i \"$fname\"";
debug(1, "migrateDatabases: executing command $cmd\n");
$? = 0; # clear error condition
my $output = `$cmd 2>&1`;
+ if ($deleteflag) {
+ unlink($fname);
+ }
if ($?) {
- return ('error_importing_migrated_db', $_, $?, $output);
+ return ('error_importing_migrated_db', $fname, $?, $output);
}
debug(1, $output);
$foundldif = 1;
| 0 |
fc10c8b392affc7a125dedcefdd7fdda482079c6
|
389ds/389-ds-base
|
Ticket 49050 - make objectclass ldapsubentry effective immediately
Entries containing objectclass ldapsubentry are not returned in normal searches,
but if the objectclass is added via ldapmodify the flag is not set in the cache entry and it is not effective until reloaded to the cache
FIx: when modiifying an entry check for oc ldapsubentry and set flag in entry cache
Reviewed by: Mark, William - thanks
|
commit fc10c8b392affc7a125dedcefdd7fdda482079c6
Author: Ludwig Krispenz <[email protected]>
Date: Tue Nov 22 15:16:21 2016 +0100
Ticket 49050 - make objectclass ldapsubentry effective immediately
Entries containing objectclass ldapsubentry are not returned in normal searches,
but if the objectclass is added via ldapmodify the flag is not set in the cache entry and it is not effective until reloaded to the cache
FIx: when modiifying an entry check for oc ldapsubentry and set flag in entry cache
Reviewed by: Mark, William - thanks
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index e86b391e6..aee39e667 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -275,7 +275,26 @@ modify_apply_check_expand(
*/
for (i = 0; mods && mods[i]; ++i) {
if (0 == strcasecmp(SLAPI_ATTR_OBJECTCLASS, mods[i]->mod_type)) {
- slapi_schema_expand_objectclasses(ec->ep_entry);
+ slapi_schema_expand_objectclasses( ec->ep_entry );
+ /* if the objectclass ldapsubentry is added or removed, the flag in the entry
+ * has to be updated. Otherwise it would only be effective after a reload
+ * of the entry.
+ */
+ for (size_t j = 0; mods[i]->mod_bvalues != NULL && mods[i]->mod_bvalues[j] != NULL; j++ ) {
+ if (strncasecmp((const char *)mods[i]->mod_bvalues[j]->bv_val,
+ "ldapsubentry", mods[i]->mod_bvalues[j]->bv_len) == 0) {
+ switch ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ) {
+ case LDAP_MOD_ADD:
+ case LDAP_MOD_REPLACE:
+ ec->ep_entry->e_flags |= SLAPI_ENTRY_LDAPSUBENTRY;
+ break;
+ case LDAP_MOD_DELETE:
+ ec->ep_entry->e_flags &= ~SLAPI_ENTRY_LDAPSUBENTRY;
+ break;
+ }
+ break;
+ }
+ }
break;
}
}
| 0 |
b7865bf1f2618eee0a909ecaf0758a620f0231b5
|
389ds/389-ds-base
|
Issue 49487 - Restore function that incorrectly removed by last patch
Bug Description: Turns out we still need ldbm_back_entry_release() as
it's used in opshared.c, and its not trival to try and
move it into the backend code.
Fix Description: Restore ldbm_back_entry_release() and still set the
function pointer in the pblock. Also remove the unused
chaining release function. Also did code cleanup with
comments in opshared.c
relates: https://pagure.io/389-ds-base/issue/49487
Reviewed by: elkris(Thanks!)
|
commit b7865bf1f2618eee0a909ecaf0758a620f0231b5
Author: Mark Reynolds <[email protected]>
Date: Tue Jul 28 14:37:31 2020 -0400
Issue 49487 - Restore function that incorrectly removed by last patch
Bug Description: Turns out we still need ldbm_back_entry_release() as
it's used in opshared.c, and its not trival to try and
move it into the backend code.
Fix Description: Restore ldbm_back_entry_release() and still set the
function pointer in the pblock. Also remove the unused
chaining release function. Also did code cleanup with
comments in opshared.c
relates: https://pagure.io/389-ds-base/issue/49487
Reviewed by: elkris(Thanks!)
diff --git a/ldap/servers/plugins/chainingdb/cb.h b/ldap/servers/plugins/chainingdb/cb.h
index fc4c3ee9c..3d13bb4e3 100644
--- a/ldap/servers/plugins/chainingdb/cb.h
+++ b/ldap/servers/plugins/chainingdb/cb.h
@@ -443,7 +443,6 @@ int chaining_back_compare(Slapi_PBlock *pb);
int chaining_back_modify(Slapi_PBlock *pb);
int chaining_back_modrdn(Slapi_PBlock *pb);
int chaining_back_abandon(Slapi_PBlock *pb);
-int chaining_back_entry_release(Slapi_PBlock *pb);
int chainingdb_next_search_entry(Slapi_PBlock *pb);
int chainingdb_build_candidate_list(Slapi_PBlock *pb);
int chainingdb_start(Slapi_PBlock *pb);
diff --git a/ldap/servers/plugins/chainingdb/cb_init.c b/ldap/servers/plugins/chainingdb/cb_init.c
index cd0e84e87..0086bad05 100644
--- a/ldap/servers/plugins/chainingdb/cb_init.c
+++ b/ldap/servers/plugins/chainingdb/cb_init.c
@@ -93,24 +93,22 @@ chaining_back_init(Slapi_PBlock *pb)
(void *)cb_back_cleanup);
/****
- rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN,
- (void *) chaining_back_entry_release );
rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_TEST_FN,
(void *) cb_back_test );
-****/
+ ****/
/*
** The following callbacks are not implemented
** by the chaining backend
** - SLAPI_PLUGIN_DB_SEQ_FN
- ** - SLAPI_PLUGIN_DB_RMDB_FN
+ ** - SLAPI_PLUGIN_DB_RMDB_FN
** - SLAPI_PLUGIN_DB_DB2INDEX_FN
** - SLAPI_PLUGIN_DB_LDIF2DB_FN
** - SLAPI_PLUGIN_DB_DB2LDIF_FN
** - SLAPI_PLUGIN_DB_ARCHIVE2DB_FN
- ** - SLAPI_PLUGIN_DB_DB2ARCHIVE_FN
+ ** - SLAPI_PLUGIN_DB_DB2ARCHIVE_FN
** - SLAPI_PLUGIN_DB_BEGIN_FN
- ** - SLAPI_PLUGIN_DB_COMMIT_FN
+ ** - SLAPI_PLUGIN_DB_COMMIT_FN
** - SLAPI_PLUGIN_DB_ABORT_FN
** - SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN
*/
diff --git a/ldap/servers/plugins/chainingdb/cb_search.c b/ldap/servers/plugins/chainingdb/cb_search.c
index 69d23a6b5..8b494e227 100644
--- a/ldap/servers/plugins/chainingdb/cb_search.c
+++ b/ldap/servers/plugins/chainingdb/cb_search.c
@@ -726,13 +726,6 @@ chainingdb_next_search_entry(Slapi_PBlock *pb)
/* return 0; */
}
-int
-chaining_back_entry_release(Slapi_PBlock *pb __attribute__((unused)))
-{
- slapi_log_err(SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM, "chaining_back_entry_release\n");
- return 0;
-}
-
void
chaining_back_search_results_release(void **sr)
{
diff --git a/ldap/servers/slapd/back-ldbm/init.c b/ldap/servers/slapd/back-ldbm/init.c
index 3faa8ae19..590aa2e78 100644
--- a/ldap/servers/slapd/back-ldbm/init.c
+++ b/ldap/servers/slapd/back-ldbm/init.c
@@ -37,6 +37,9 @@ ldbm_back_init(Slapi_PBlock *pb)
* identity is used during internal ops. */
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &(li->li_identity));
+ /* Set the entry release function */
+ p->plg_entry_release = (void *)ldbm_back_entry_release;
+
/* keep a pointer back to the plugin */
li->li_plugin = p;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index 9119ed5c5..3e88bbc84 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1881,3 +1881,28 @@ ldbm_back_search_results_release(void **sr)
/* passing NULL pb forces to delete the search result set */
delete_search_result_set(NULL, (back_search_result_set **)sr);
}
+
+int
+ldbm_back_entry_release(Slapi_PBlock *pb, void *backend_info_ptr)
+{
+ backend *be;
+ ldbm_instance *inst;
+
+ if (backend_info_ptr == NULL) {
+ return 1;
+ }
+
+ slapi_pblock_get(pb, SLAPI_BACKEND, &be);
+ inst = (ldbm_instance *)be->be_instance_info;
+
+ if (((struct backentry *)backend_info_ptr)->ep_vlventry != NULL) {
+ /* This entry was created during a vlv search whose acl check failed.
+ * It needs to be freed here */
+ slapi_entry_free(((struct backentry *)backend_info_ptr)->ep_vlventry);
+ ((struct backentry *)backend_info_ptr)->ep_vlventry = NULL;
+ }
+
+ CACHE_RETURN(&inst->inst_cache, (struct backentry **)&backend_info_ptr);
+
+ return 0;
+}
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index f461b5df3..8f842d920 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -126,7 +126,7 @@ void *bdb_get_batch_transactions(void *arg);
void *bdb_get_batch_txn_min_sleep(void *arg);
void *bdb_get_batch_txn_max_sleep(void *arg);
int dblayer_in_import(ldbm_instance *inst);
-
+int ldbm_back_entry_release(Slapi_PBlock *pb, void *backend_info_ptr);
int dblayer_update_db_ext(ldbm_instance *inst, char *oldext, char *newext);
char *dblayer_get_full_inst_dir(struct ldbminfo *li, ldbm_instance *inst, char *buf, int buflen);
diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c
index 10ad1622f..3e9edc89a 100644
--- a/ldap/servers/slapd/backend.c
+++ b/ldap/servers/slapd/backend.c
@@ -416,9 +416,6 @@ slapi_be_getentrypoint(Slapi_Backend *be, int entrypoint, void **ret_fnptr, Slap
case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN:
*ret_fnptr = (void *)be->be_next_search_entry_ext;
break;
- case SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN:
- *ret_fnptr = (void *)be->be_entry_release;
- break;
case SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN:
*ret_fnptr = (void *)be->be_search_results_release;
break;
@@ -519,9 +516,6 @@ slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr, Slapi
case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN:
be->be_next_search_entry_ext = (IFP)ret_fnptr;
break;
- case SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN:
- be->be_entry_release = (IFP)ret_fnptr;
- break;
case SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN:
be->be_search_results_release = (VFPP)ret_fnptr;
break;
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 778b99457..c8b45bfdb 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -402,8 +402,8 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
}
/* If we encountered an error parsing the proxy control, return an error
- * to the client. We do this here to ensure that we log the operation first.
- */
+ * to the client. We do this here to ensure that we log the operation first.
+ */
if (proxy_err != LDAP_SUCCESS) {
rc = -1;
send_ldap_result(pb, proxy_err, NULL, errtext, 0, NULL);
@@ -411,23 +411,24 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
}
/* target spec is used to decide which plugins are applicable for
- * the operation. basesdn is duplicated and set to target spec.
- */
+ * the operation. basesdn is duplicated and set to target spec.
+ */
operation_set_target_spec(operation, basesdn);
/*
- * this is time to check if mapping tree specific control was used to
- * specify that we want to parse only one backend.
- */
+ * this is time to check if mapping tree specific control was used to
+ * specify that we want to parse only one backend.
+ */
slapi_pblock_get(pb, SLAPI_REQCONTROLS, &ctrlp);
if (ctrlp) {
if (slapi_control_present(ctrlp, MTN_CONTROL_USE_ONE_BACKEND_EXT_OID,
- &ctl_value, &iscritical)) {
+ &ctl_value, &iscritical))
+ {
/* this control is the smart version of MTN_CONTROL_USE_ONE_BACKEND_OID,
- * it works out for itself what back end is required (thereby relieving
- * the client of working out which backend it needs) by looking at the
- * base of the search if no value is supplied
- */
+ * it works out for itself what back end is required (thereby relieving
+ * the client of working out which backend it needs) by looking at the
+ * base of the search if no value is supplied
+ */
if ((ctl_value->bv_len != 0) && ctl_value->bv_val) {
be_name = ctl_value->bv_val;
@@ -466,8 +467,7 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
if (be_name == NULL) {
char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
- /* no specific backend was requested, use the mapping tree
- */
+ /* no specific backend was requested, use the mapping tree */
errorbuf[0] = '\0';
err_code = slapi_mapping_tree_select_all(pb, be_list, referral_list, errorbuf, sizeof(errorbuf));
if (((err_code != LDAP_SUCCESS) && (err_code != LDAP_OPERATIONS_ERROR) && (err_code != LDAP_REFERRAL)) || ((err_code == LDAP_OPERATIONS_ERROR) && (be_list[0] == NULL))) {
@@ -485,8 +485,7 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
be = NULL;
}
} else {
- /* specific backend be_name was requested, use slapi_be_select_by_instance_name
- */
+ /* specific backend be_name was requested, use slapi_be_select_by_instance_name */
be_single = be = slapi_be_select_by_instance_name(be_name);
if (be_single) {
slapi_be_Rlock(be_single);
@@ -582,9 +581,9 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
}
/*
- * call the pre-search plugins. if they succeed, call the backend
- * search function. then call the post-search plugins.
- */
+ * call the pre-search plugins. if they succeed, call the backend
+ * search function. then call the post-search plugins.
+ */
/* ONREPL - should regular plugin be called for internal searches ? */
if (plugin_call_plugins(pb, SLAPI_PLUGIN_PRE_SEARCH_FN) == 0) {
slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database);
@@ -594,10 +593,10 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
rc = compute_rewrite_search_filter(pb);
switch (rc) {
case 1: /* A rewriter says that we should refuse to perform this search.
- The potential exists that we will refuse to perform a search
- which we were going to refer, perhaps to a server which would
- be willing to perform the search. That's bad. The rewriter
- could be clever enough to spot this and do the right thing though. */
+ The potential exists that we will refuse to perform a search
+ which we were going to refer, perhaps to a server which would
+ be willing to perform the search. That's bad. The rewriter
+ could be clever enough to spot this and do the right thing though. */
send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL, "Search not supported", 0, NULL);
rc = -1;
goto free_and_return;
@@ -633,15 +632,15 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
} else {
/*
- * A pre-operation plugin handled this search. Grab the return code
- * (it may have been set by a plugin) and return.
- *
- * In DS 5.x, the following two lines of code did not exist, which
- * means a pre-search function might return a non-zero value (which
- * indicates that a result was returned to the client) but the code
- * below would execute the search anyway. This was a regression from
- * the documented plugin API behavior (and from DS 3.x and 4.x).
- */
+ * A pre-operation plugin handled this search. Grab the return code
+ * (it may have been set by a plugin) and return.
+ *
+ * In DS 5.x, the following two lines of code did not exist, which
+ * means a pre-search function might return a non-zero value (which
+ * indicates that a result was returned to the client) but the code
+ * below would execute the search anyway. This was a regression from
+ * the documented plugin API behavior (and from DS 3.x and 4.x).
+ */
slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &rc);
goto free_and_return;
}
@@ -667,16 +666,16 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
pnentries = 0;
/* the backends returns no such object when a
- * search is attempted in a node above their nsslapd-suffix
- * this is correct but a bit annoying when a backends
- * is below another backend because in that case the
- * such searches should sometimes succeed
- * To allow this we therefore have to change the
- * SLAPI_SEARCH_TARGET_SDN parameter in the pblock
- *
- * Also when we climb down the mapping tree we have to
- * change ONE-LEVEL searches to BASE
- */
+ * search is attempted in a node above their nsslapd-suffix
+ * this is correct but a bit annoying when a backends
+ * is below another backend because in that case the
+ * such searches should sometimes succeed
+ * To allow this we therefore have to change the
+ * SLAPI_SEARCH_TARGET_SDN parameter in the pblock
+ *
+ * Also when we climb down the mapping tree we have to
+ * change ONE-LEVEL searches to BASE
+ */
/* that means we only support one suffix per backend */
be_suffix = slapi_be_getsuffix(be, 0);
@@ -696,9 +695,9 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
/* PAGED RESULTS and already have the search results from the prev op */
pagedresults_lock(pb_conn, pr_idx);
/*
- * In async paged result case, the search result might be released
- * by other theads. We need to double check it in the locked region.
- */
+ * In async paged result case, the search result might be released
+ * by other theads. We need to double check it in the locked region.
+ */
pthread_mutex_lock(&(pb_conn->c_mutex));
pr_search_result = pagedresults_get_search_result(pb_conn, operation, 1 /*locked*/, pr_idx);
if (pr_search_result) {
@@ -765,15 +764,14 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
}
} else {
/* be_suffix null means that we are searching the default backend
- * -> don't change the search parameters in pblock
- */
- if (be_suffix != NULL) {
+ * -> don't change the search parameters in pblock */
+ if (be_suffix != NULL) {
if ((be_name == NULL) && (scope == LDAP_SCOPE_ONELEVEL)) {
/* one level searches
- * - depending on the suffix of the backend we might have to
- * do a one level search or a base search
- * - we might also have to change the search target
- */
+ * - depending on the suffix of the backend we might have to
+ * do a one level search or a base search
+ * - we might also have to change the search target
+ */
if (slapi_sdn_isparent(basesdn, be_suffix) ||
(slapi_sdn_get_ndn_len(basesdn) == 0)) {
int tmp_scope = LDAP_SCOPE_BASE;
@@ -794,11 +792,11 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
}
/* subtree searches :
- * if the search was started above the backend suffix
- * - temporarily set the SLAPI_SEARCH_TARGET_SDN to the
- * base of the node so that we don't get a NO SUCH OBJECT error
- * - do not change the scope
- */
+ * if the search was started above the backend suffix
+ * - temporarily set the SLAPI_SEARCH_TARGET_SDN to the
+ * base of the node so that we don't get a NO SUCH OBJECT error
+ * - do not change the scope
+ */
if (scope == LDAP_SCOPE_SUBTREE) {
if (slapi_sdn_issuffix(be_suffix, basesdn)) {
if (free_sdn) {
@@ -821,22 +819,22 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
switch (rc) {
case 1:
/* if the backend returned LDAP_NO_SUCH_OBJECT for a SEARCH request,
- * it will not have sent back a result - otherwise, it will have
- * sent a result */
+ * it will not have sent back a result - otherwise, it will have
+ * sent a result */
rc = SLAPI_FAIL_GENERAL;
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &err);
if (err == LDAP_NO_SUCH_OBJECT) {
/* may be the object exist somewhere else
- * wait the end of the loop to send back this error
- */
+ * wait the end of the loop to send back this error
+ */
flag_no_such_object = 1;
} else {
/* err something other than LDAP_NO_SUCH_OBJECT, so the backend will
- * have sent the result -
- * Set a flag here so we don't return another result. */
+ * have sent the result -
+ * Set a flag here so we don't return another result. */
sent_result = 1;
}
- /* fall through */
+ /* fall through */
case -1: /* an error occurred */
/* PAGED RESULTS */
@@ -853,15 +851,15 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &err);
if (err == LDAP_NO_SUCH_OBJECT) {
/* may be the object exist somewhere else
- * wait the end of the loop to send back this error
- */
+ * wait the end of the loop to send back this error
+ */
flag_no_such_object = 1;
break;
} else {
/* for error other than LDAP_NO_SUCH_OBJECT
- * the error has already been sent
- * stop the search here
- */
+ * the error has already been sent
+ * stop the search here
+ */
cache_return_target_entry(pb, be, operation);
goto free_and_return;
}
@@ -935,10 +933,10 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
}
/* if rc != 0 an error occurred while sending back the entries
- * to the LDAP client
- * LDAP error should already have been sent to the client
- * stop the search, free and return
- */
+ * to the LDAP client
+ * LDAP error should already have been sent to the client
+ * stop the search, free and return
+ */
if (rc != 0) {
cache_return_target_entry(pb, be, operation);
goto free_and_return;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 83f856bb5..e00f55924 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -912,7 +912,6 @@ int proxyauth_get_dn(Slapi_PBlock *pb, char **proxydnp, char **errtextp);
#define SLAPI_PLUGIN_DB_TEST_FN 227
#define SLAPI_PLUGIN_DB_DB2INDEX_FN 228
#define SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN 229
-#define SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN 230
#define SLAPI_PLUGIN_DB_WIRE_IMPORT_FN 234
#define SLAPI_PLUGIN_DB_UPGRADEDB_FN 235
#define SLAPI_PLUGIN_DB_DBVERIFY_FN 236
| 0 |
9529cfc0de18f2f77024a3ab7889be6b2539f3e6
|
389ds/389-ds-base
|
Ticket 50493 - connection_is_free to trylock
Bug Description: Due to the nature of the connection table
being single threaded, in connection_is_free, we would iterate
over the CT attempting to lock and check connection free states.
However, because this required the lock, if the connection was
currently in io, or other operations, the ct would delay behind
the c_mutex until it was released, then we would check the free
state.
Fix Description: Change the connection_is_free to use trylock
instead of lock - this means if the connection is locked it's
probably inuse and we can skip over it directly. We also change the
fn to iterate over the ct twice to check for possible connections
incase something frees up.
https://pagure.io/389-ds-base/pull-request/50493
Author: William Brown <[email protected]>
Review by: tbordaz (Thanks!)
|
commit 9529cfc0de18f2f77024a3ab7889be6b2539f3e6
Author: William Brown <[email protected]>
Date: Fri Jul 12 14:39:53 2019 +1000
Ticket 50493 - connection_is_free to trylock
Bug Description: Due to the nature of the connection table
being single threaded, in connection_is_free, we would iterate
over the CT attempting to lock and check connection free states.
However, because this required the lock, if the connection was
currently in io, or other operations, the ct would delay behind
the c_mutex until it was released, then we would check the free
state.
Fix Description: Change the connection_is_free to use trylock
instead of lock - this means if the connection is locked it's
probably inuse and we can skip over it directly. We also change the
fn to iterate over the ct twice to check for possible connections
incase something frees up.
https://pagure.io/389-ds-base/pull-request/50493
Author: William Brown <[email protected]>
Review by: tbordaz (Thanks!)
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 6136d729f..e6ce0f012 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -749,10 +749,13 @@ connection_acquire_nolock(Connection *conn)
int
connection_is_free(Connection *conn, int use_lock)
{
- int rc;
+ int rc = 0;
if (use_lock) {
- pthread_mutex_lock(&(conn->c_mutex));
+ /* If the lock is held, someone owns this! */
+ if (pthread_mutex_trylock(&(conn->c_mutex)) != 0) {
+ return 0;
+ }
}
rc = conn->c_sd == SLAPD_INVALID_SOCKET && conn->c_refcnt == 0 &&
!(conn->c_flags & CONN_FLAG_CLOSING);
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index a5134867b..cadcfa952 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -115,12 +115,24 @@ Connection *
connection_table_get_connection(Connection_Table *ct, int sd)
{
Connection *c = NULL;
- int index, count;
+ size_t index = 0;
+ size_t count = 0;
PR_Lock(ct->table_mutex);
+ /*
+ * We attempt to loop over the ct twice, because connection_is_free uses trylock
+ * and some resources *might* free in the time needed to loop around.
+ */
+ size_t ct_max_loops = ct->size * 2;
+
+ /*
+ * This uses sd as entropy to randomly start inside the ct rather than
+ * always head-loading the list. Not my idea, but it's probably okay ...
+ */
index = sd % ct->size;
- for (count = 0; count < ct->size; count++, index = (index + 1) % ct->size) {
+
+ for (count = 0; count < ct_max_loops; count++, index = (index + 1) % ct->size) {
/* Do not use slot 0, slot 0 is head of the list of active connections */
if (index == 0) {
continue;
@@ -132,7 +144,8 @@ connection_table_get_connection(Connection_Table *ct, int sd)
}
}
- if (count < ct->size) {
+ /* If count exceeds max loops, we didn't find something into index. */
+ if (count < ct_max_loops) {
/* Found an available Connection */
c = &(ct->c[index]);
PR_ASSERT(c->c_next == NULL);
| 0 |
0b08e6f35b000d1383580be59f902ac813e940f2
|
389ds/389-ds-base
|
Issue #4504 - Fix pytest test_dsconf_replication_monitor (#4505)
|
commit 0b08e6f35b000d1383580be59f902ac813e940f2
Author: progier389 <[email protected]>
Date: Wed Dec 16 16:21:35 2020 +0100
Issue #4504 - Fix pytest test_dsconf_replication_monitor (#4505)
diff --git a/dirsrvtests/tests/suites/clu/repl_monitor_test.py b/dirsrvtests/tests/suites/clu/repl_monitor_test.py
index b03d170c8..eb18d2da2 100644
--- a/dirsrvtests/tests/suites/clu/repl_monitor_test.py
+++ b/dirsrvtests/tests/suites/clu/repl_monitor_test.py
@@ -9,6 +9,7 @@
import time
import subprocess
import pytest
+import re
from lib389.cli_conf.replication import get_repl_monitor_info
from lib389.tasks import *
@@ -67,6 +68,25 @@ def check_value_in_log_and_reset(content_list, second_list=None, single_value=No
log.info('Reset log file')
f.truncate(0)
+def get_hostnames_from_log(port1, port2):
+ # Get the supplier host names as displayed in replication monitor output
+ with open(LOG_FILE, 'r') as logfile:
+ logtext = logfile.read()
+ # search for Supplier :hostname:port
+ # and use \D to insure there is no more number is after
+ # the matched port (i.e that 10 is not matching 101)
+ regexp = '(Supplier: )([^:]*)(:' + str(port1) + '\D)'
+ match=re.search(regexp, logtext)
+ host_m1 = 'localhost.localdomain'
+ if (match is not None):
+ host_m1 = match.group(2)
+ # Same for master 2
+ regexp = '(Supplier: )([^:]*)(:' + str(port2) + '\D)'
+ match=re.search(regexp, logtext)
+ host_m2 = 'localhost.localdomain'
+ if (match is not None):
+ host_m2 = match.group(2)
+ return (host_m1, host_m2)
@pytest.mark.ds50545
@pytest.mark.bz1739718
@@ -95,9 +115,6 @@ def test_dsconf_replication_monitor(topology_m2, set_log_file):
m1 = topology_m2.ms["master1"]
m2 = topology_m2.ms["master2"]
- alias_content = ['Supplier: M1 (' + m1.host + ':' + str(m1.port) + ')',
- 'Supplier: M2 (' + m2.host + ':' + str(m2.port) + ')']
-
connection_content = 'Supplier: '+ m1.host + ':' + str(m1.port)
content_list = ['Replica Root: dc=example,dc=com',
'Replica ID: 1',
@@ -160,20 +177,9 @@ def test_dsconf_replication_monitor(topology_m2, set_log_file):
'001',
m1.host + ':' + str(m1.port)]
- dsrc_content = '[repl-monitor-connections]\n' \
- 'connection1 = ' + m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM + '\n' \
- 'connection2 = ' + m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM + '\n' \
- '\n' \
- '[repl-monitor-aliases]\n' \
- 'M1 = ' + m1.host + ':' + str(m1.port) + '\n' \
- 'M2 = ' + m2.host + ':' + str(m2.port)
-
connections = [m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM,
m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM]
- aliases = ['M1=' + m1.host + ':' + str(m1.port),
- 'M2=' + m2.host + ':' + str(m2.port)]
-
args = FakeArgs()
args.connections = connections
args.aliases = None
@@ -181,8 +187,24 @@ def test_dsconf_replication_monitor(topology_m2, set_log_file):
log.info('Run replication monitor with connections option')
get_repl_monitor_info(m1, DEFAULT_SUFFIX, log, args)
+ (host_m1, host_m2) = get_hostnames_from_log(m1.port, m2.port)
check_value_in_log_and_reset(content_list, connection_content, error_list=error_list)
+ # Prepare the data for next tests
+ aliases = ['M1=' + host_m1 + ':' + str(m1.port),
+ 'M2=' + host_m2 + ':' + str(m2.port)]
+
+ alias_content = ['Supplier: M1 (' + host_m1 + ':' + str(m1.port) + ')',
+ 'Supplier: M2 (' + host_m2 + ':' + str(m2.port) + ')']
+
+ dsrc_content = '[repl-monitor-connections]\n' \
+ 'connection1 = ' + m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM + '\n' \
+ 'connection2 = ' + m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM + '\n' \
+ '\n' \
+ '[repl-monitor-aliases]\n' \
+ 'M1 = ' + host_m1 + ':' + str(m1.port) + '\n' \
+ 'M2 = ' + host_m2 + ':' + str(m2.port)
+
log.info('Run replication monitor with aliases option')
args.aliases = aliases
get_repl_monitor_info(m1, DEFAULT_SUFFIX, log, args)
| 0 |
899056900648423b9d6144a2a848bd0b8998e66f
|
389ds/389-ds-base
|
[167982] Service Pack framework
Reporting the patch generation code to the trunk.
|
commit 899056900648423b9d6144a2a848bd0b8998e66f
Author: Noriko Hosoi <[email protected]>
Date: Tue Oct 25 16:55:49 2005 +0000
[167982] Service Pack framework
Reporting the patch generation code to the trunk.
diff --git a/ldap/cm/Makefile b/ldap/cm/Makefile
index 6764e876c..bc55e0129 100644
--- a/ldap/cm/Makefile
+++ b/ldap/cm/Makefile
@@ -208,8 +208,8 @@ ABSBUILD_ROOT = $(shell cd $(BUILD_ROOT); pwd)
ABSRELDIR = $(ABSBUILD_ROOT)/built/release
GENRPMPATCH = $(ABSBUILD_ROOT)/ldap/cm/genRpmPatch.pl
PATCHINF = $(ABSBUILD_ROOT)/ldap/cm/fedora-patch.inf
-DATETIME = $(shell date +%Y%m%d-%H%M%S)
-SPEXT = .SP.$(DATETIME)
+DATETIME := $(shell date +%Y%m%d-%H%M%S)
+SPEXT := .SP.$(DATETIME)
# This is the directory where we put what we're making: the files which go on the CD.
ifndef INSTDIR
@@ -220,6 +220,8 @@ INSTDIR = $(BUILD_DRIVE)$(BUILD_ROOT)/../$(MMDD)/$(NS_BUILD_FLAVOR)
endif
endif
ABS_INSTDIR = $(shell cd $(INSTDIR); pwd)
+ABS_DISTDIR = $(ABSBUILD_ROOT)/../dist
+ESCAPED_ABS_DISTDIR = $(shell echo $(ABS_DISTDIR) | sed -e 's/\//\\\//g')
ifdef BUILD_PATCH
PATCHINSTDIR = $(ABS_INSTDIR)-SP
@@ -581,15 +583,6 @@ packageDirectory: $(INSTDIR)/slapd \
$(INSTDIR)/perldap/$(PERLDAP_ZIP_FILE) \
$(ADMSERV_DEP)
-ifdef BUILD_PATCH
-ifdef BUILD_RPM
-# create a patch
- $(GENRPMPATCH) -i $(RPM_BASE_NAME) -o $(NS_BUILD_FLAVOR) -r $(ABSRELDIR) -e $(SPEXT) -f $(PATCHINF) -v
- mv $(ABSRELDIR)/slapd/$(NS_BUILD_FLAVOR) $(ABSRELDIR)/slapd/$(NS_BUILD_FLAVOR).original
- ln -s $(ABSRELDIR)/slapd/$(NS_BUILD_FLAVOR)$(SPEXT)/opt/$(RPM_BASE_NAME)-ds $(ABSRELDIR)/slapd/$(NS_BUILD_FLAVOR)
-endif
-endif
-
# this gets setup, setup.inf, silent.inf, the zip wrapper, and svrcore, among others
ifeq ($(USE_SETUPUTIL),1)
cp -R $(SETUPUTIL_BINPATH)/* $(INSTDIR)
@@ -616,6 +609,22 @@ endif
endif
endif
endif
+
+ifdef BUILD_PATCH
+# take care of files in components (e.g., a file in nsadmin.zip)
+ -@for pair in `grep "^compfile:" $(PATCHINF) | awk '{print $$3}'`; do \
+ zipfile=`echo $$pair | awk -F: '{print $$1}' | sed -e "s/%DISTDIR%/$(ESCAPED_ABS_DISTDIR)\/$(NSOBJDIR_NAME)/"` ; \
+ afile=`echo $$pair | awk -F: '{print $$2}'` ; \
+ cd $(ABSRELDIR)/$(NS_BUILD_FLAVOR); $(UNZIP) -o $$zipfile $$afile ; \
+ done
+ifdef BUILD_RPM
+# create a patch
+ $(GENRPMPATCH) -i $(RPM_BASE_NAME) -o $(NS_BUILD_FLAVOR) -r $(ABSRELDIR) -e $(SPEXT) -f $(PATCHINF) -v
+ mv $(ABSRELDIR)/$(NS_BUILD_FLAVOR) $(ABSRELDIR)/$(NS_BUILD_FLAVOR).original
+ ln -s $(ABSRELDIR)/$(NS_BUILD_FLAVOR)$(SPEXT)/opt/$(RPM_BASE_NAME)-ds $(ABSRELDIR)/$(NS_BUILD_FLAVOR)
+endif
+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
@@ -740,7 +749,8 @@ ifdef BUILD_PATCH
echo "[$(SLAPDSP)]" >> $(PATCHINSTDIR)/setup.inf
echo "ComponentInfoFile = $(SLAPDSP)/$(SLAPDSP).inf" >> $(PATCHINSTDIR)/setup.inf
# create a zip file based upon the $(PATCHINF) file
- cd $(ABSRELDIR)/slapd/$(NS_BUILD_FLAVOR); zip -r $(PATCHINSTDIR)/$(SLAPDSP)/ns$(SLAPDSP).zip `egrep "^file:" $(PATCHINF) | awk -F: '{print $$3}'`
+ cd $(ABSRELDIR)/$(NS_BUILD_FLAVOR); zip -r $(PATCHINSTDIR)/$(SLAPDSP)/ns$(SLAPDSP).zip `grep "^file:" $(PATCHINF) | awk -F: '{print $$3}'`
+ cd $(ABSRELDIR)/$(NS_BUILD_FLAVOR); zip -r $(PATCHINSTDIR)/$(SLAPDSP)/ns$(SLAPDSP).zip -u `grep "^compfile:" $(PATCHINF) | awk -F: '{print $$4}'`
# put ns-config and needed libs in the $(PATCHINSTDIR)/$(SLAPDSP) directory
$(INSTALL) -m 755 $(RELDIR_32)/bin/slapd/admin/bin/ns-config $(PATCHINSTDIR)/$(SLAPDSP)
-@for file in $(PACKAGE_SETUP_LIBS_32) ; \
@@ -750,7 +760,8 @@ ifdef BUILD_PATCH
done
# create patch inf file: $(SLAPD).inf
cp $(OBJDIR)/slapd-patch.inf $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf
- cd $(ABSRELDIR)/slapd/$(NS_BUILD_FLAVOR); ls `egrep "^file:" $(PATCHINF) | egrep -v "setup/setup" | awk -F: '{print $$3}'` > $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf.tmp
+ cd $(ABSRELDIR)/$(NS_BUILD_FLAVOR); ls `grep "^file:" $(PATCHINF) | egrep -v "setup/setup" | awk -F: '{print $$3}'` > $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf.tmp
+ cd $(ABSRELDIR)/$(NS_BUILD_FLAVOR); ls `grep "^compfile:" $(PATCHINF) | awk -F: '{print $$4}'` >> $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf.tmp
echo `cat $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf.tmp` | sed -e "s/ /,/g" > $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf.tmp2
echo "BackupFiles="`cat $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf.tmp2`>> $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf
rm -f $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf.tmp $(PATCHINSTDIR)/$(SLAPDSP)/$(SLAPDSP).inf.tmp2
@@ -840,7 +851,7 @@ endif # BUILD_SHIP
cleanDirectory:
cd $(LDAPDIR); $(MAKE) clean
- rm -rf $(BUILD_ROOT)/../dist/$(NC_BUILD_FLAVOR)
+ rm -rf $(BUILD_ROOT)/../dist/$(NSOBJDIR_NAME)
rm -rf $(BUILD_ROOT)/built/$(NS_BUILD_FLAVOR)
diff --git a/ldap/cm/fedora-patch.inf b/ldap/cm/fedora-patch.inf
index 9cc6e2d80..2f823f14b 100644
--- a/ldap/cm/fedora-patch.inf
+++ b/ldap/cm/fedora-patch.inf
@@ -39,9 +39,12 @@
# Sample Info file to generate service pack
# base: <builddir> containing the base package -- e.g., DS7.1
# file: <bugzilla number>: <patchfile>
+# compfile: bug#: <patch_zipfile>:<patchfile>
+# %DISTDIR% points <buildroot>/dist/<platform>
#
base: /share/dev4/fedora-ds/fds71/ships/20050526.1
file: 000001: README.txt
file: 000002: lib/libback-ldbm.*
+compfile: 000003: %DISTDIR%/adminserver/admin/nsadmin.zip:manual/help/help
diff --git a/ldap/cm/genRpmPatch.pl b/ldap/cm/genRpmPatch.pl
index d8750a96f..2ea240905 100755
--- a/ldap/cm/genRpmPatch.pl
+++ b/ldap/cm/genRpmPatch.pl
@@ -129,7 +129,13 @@ while ($l = <INFFILE>) {
$pos = rindex($l, ":", $pos);
$pos++;
$file = substr($l, $pos);
- $file =~ s/[ ]//g;
+ $file =~ s/[ ]//g;
+ push(@newfiles, ($file));
+ } elsif ($l =~ /^compfile: /) {
+ $pos = rindex($l, ":", $pos);
+ $pos++;
+ $file = substr($l, $pos);
+ $file =~ s/[ ]//g;
push(@newfiles, ($file));
}
}
@@ -161,9 +167,9 @@ if ($builtdirname =~ /RHEL3/) {
}
$optordbg = "";
-if ($builtdirname =~ /full/) {
+if ($builtdirname =~ /_DBG/) {
$optordbg = "dbg";
-} elsif ($builtdirname =~ /optimize/) {
+} elsif ($builtdirname =~ /_OPT/) {
$optordbg = "opt";
} else {
print(STDERR "ERROR: $builtdirname has no opt/debug info\n");
@@ -205,7 +211,7 @@ if (1 == $verbose) {
}
# Expand the RPM file to the $releasedir
-$workdir = $releasedir . "/slapd/" . $builtdirname . $extension;
+$workdir = $releasedir . "/" . $builtdirname . $extension;
mkdir($workdir, 0700);
chdir($workdir);
if (1 == $verbose) {
@@ -216,7 +222,7 @@ close(RPM2CPIO);
# Copy new files onto the expanded files
foreach $afile (@newfiles) {
- $srcfile = $releasedir . "/slapd/" . $builtdirname . "/" . $afile;
+ $srcfile = $releasedir . "/" . $builtdirname . "/" . $afile;
$destfile = $workdir . "/opt/" . $iddir . "/" . $afile;
$destdir = substr($destfile, 0, rindex($destfile, "/", length($destfile)));
if (!(-d $destdir)) {
diff --git a/ldap/cm/newinst/setup b/ldap/cm/newinst/setup
index f71a6fdb8..c3a13ad5a 100755
--- a/ldap/cm/newinst/setup
+++ b/ldap/cm/newinst/setup
@@ -195,8 +195,161 @@ if ! [ $silent ]; then
askYN "Continue?"
fi
+isadminsslon=0
+sslparams=""
+
+adminSSLOff() {
+ conffile=$1
+ confparam=$2
+ tmpfile=$3
+ if [ -f $conffile ]; then
+ security=`grep -i "^$confparam" $conffile | awk '{print $1}'`
+ issecure=`grep -i "^$confparam" $conffile | awk '{print $2}'`
+ if [ "$issecure" = "on" -o "$issecure" = "ON" -o "$issecure" = "On" -o "$issecure" = "oN" ]
+ then
+ if [ $isadminsslon -eq 0 ]; then
+ $sroot/stop-admin
+ isadminsslon=1
+ fi
+ echo $conffile=$security >> $tmpfile
+ cat $conffile | sed -e "s/^\($security\) .*/\1 off/g" > $conffile.01
+ mv $conffile.01 $conffile
+ echo "$conffile: SSL off ..."
+ fi
+ fi
+}
+
+adminXmlSSLOff() {
+ conffile=$1
+ confparam=$2
+ tmpfile=$3
+ if [ -f $conffile ]; then
+ grep -i "\<security=\"on\"" $conffile > /dev/null 2>&1
+ rval=$?
+ if [ $rval -eq 0 ]
+ then
+ if [ $isadminsslon -eq 0 ]; then
+ $sroot/stop-admin
+ isadminsslon=1
+ fi
+ echo $conffile=$confparam >> $tmpfile
+ cat $conffile | sed -e "s/\([Ss][Ee][Cc][Uu][Rr][Ii][Tt][Yy]=\)\"[A-Za-z]*\"/\1\"off\"/g" > $conffile.0
+ mv $conffile.0 $conffile
+ echo "$conffile: SSL off ..."
+ fi
+ sslparams0=`grep -i "<.*SSLPARAMS " $conffile`
+ rval=$?
+ if [ $rval -eq 0 ]
+ then
+ if [ $isadminsslon -eq 0 ]; then
+ $sroot/stop-admin
+ isadminsslon=1
+ fi
+echo adminXmlSSLOff: SSLPARAMS off
+ sslparams1=`echo $sslparams0 | sed -e 's/\//\\\\\//g'`
+ sslparams=`echo $sslparams1 | sed -e 's/\"/\\\\\"/g'`
+ cat $conffile | sed -e "s/\($sslparams\)/\<\!-- \1 --\>/g" > $conffile.1
+ mv $conffile.1 $conffile
+ fi
+ fi
+}
+
+SSLOff() {
+ rm -f dssecure.txt assecure.txt > /dev/null 2>&1
+ touch dssecure.txt
+ touch assecure.txt
+
+ for dir in $sroot/slapd-* ; do
+ if [ -f $dir/config/dse.ldif ]; then
+ security=`grep -i "^nsslapd-security:" $dir/config/dse.ldif | awk '{print $1}'`
+ issecure=`grep -i "^nsslapd-security:" $dir/config/dse.ldif | awk '{print $2}'`
+ if [ "$issecure" = "on" -o "$issecure" = "ON" -o "$issecure" = "On" -o "$issecure" = "oN" ]
+ then
+ echo $dir >> dssecure.txt
+ $dir/stop-slapd
+ cat $dir/config/dse.ldif | sed -e "s/\($security\) .*/\1 off/g" > $dir/config/dse.ldif.0
+ mv $dir/config/dse.ldif.0 $dir/config/dse.ldif
+ echo "$dir/config/dse.ldif: SSL off ..."
+ fi
+ fi
+ done
+ if [ -d $sroot/admin-serv/config ]; then
+ adminSSLOff $sroot/admin-serv/config/adm.conf security: assecure.txt
+ adminSSLOff $sroot/admin-serv/config/local.conf configuration.nsServerSecurity: assecure.txt
+ adminSSLOff $sroot/admin-serv/config/magnus.conf Security assecure.txt
+ adminXmlSSLOff $sroot/admin-serv/config/server.xml security assecure.txt
+
+ if [ $isadminsslon -ne 0 ]; then
+ $sroot/start-admin
+ fi
+ fi
+}
+
+adminSSLOn() {
+ conffile=$1
+ confparam=$2
+ if [ -f $conffile ]; then
+ cat $conffile | sed -e "s/^\($confparam\) .*/\1 on/g" > $conffile.00
+ mv $conffile.00 $conffile
+ echo "$conffile $confparam: SSL on ..."
+ fi
+}
+
+adminXmlSSLOn() {
+ conffile=$1
+ if [ -f $conffile ]; then
+ cat $conffile | sed -e "s/\([Ss][Ee][Cc][Uu][Rr][Ii][Tt][Yy]=\)\"[A-Za-z]*\"/\1\"on\"/g" > $conffile.2
+ mv $conffile.2 $conffile
+ fi
+ grep -i "<.*SSLPARAMS " $conffile > /dev/null 2>&1
+ rval=$?
+ if [ $rval -eq 0 ]
+ then
+ cat $conffile | sed -e "s/<\!-- *$sslparams *-->/$sslparams/g" > $conffile.3
+ mv $conffile.3 $conffile
+ fi
+ echo "$conffile: SSL on ..."
+}
+
+SSLOn() {
+ for dir in `cat dssecure.txt` ; do
+ if [ -f $dir/config/dse.ldif ]; then
+ security=`grep -i "^nsslapd-security:" $dir/config/dse.ldif | awk '{print $1}'`
+ $dir/stop-slapd
+ cat $dir/config/dse.ldif | sed -e "s/\($security\) .*/\1 on/g" > $dir/config/dse.ldif.0
+ mv $dir/config/dse.ldif.0 $dir/config/dse.ldif
+ echo "$dir/config/dse.ldif: SSL on ..."
+ echo "Restarting Directory Server: $dir/start-slapd"
+ $dir/start-slapd
+ fi
+ done
+
+ if [ $isadminsslon -ne 0 ]; then
+ $sroot/stop-admin
+ fi
+ for confline in `cat assecure.txt` ; do
+ conffile=`echo $confline | awk -F= '{print $1}'`
+ confparam=`echo $confline | awk -F= '{print $2}'`
+ echo $conffile | grep "\.xml$" > /dev/null 2>&1
+ rval=$?
+ if [ $rval -eq 0 ]; then
+ adminXmlSSLOn $conffile $confparam
+ else
+ adminSSLOn $conffile $confparam
+ fi
+ done
+ if [ $isadminsslon -ne 0 ]; then
+ echo "Restarting Administration Server: $sroot/start-admin"
+ $sroot/start-admin
+ fi
+
+ rm -f dssecure.txt assecure.txt > /dev/null 2>&1
+}
+
# check whether it is an in-place installation
if [ -f $sroot/admin-serv/config/adm.conf ]; then
+ SSLOff
+
dsinst=`getValFromAdminConf "ldapStart:" "adm.conf" | awk -F/ '{print $1}'`
if [ -f $sroot/$dsinst/config/dse.ldif ]; then
# it is an in=place installation
@@ -339,6 +492,8 @@ fi
`pwd`/bin/admin/ns-update $doreconfig $silentarg $myargs -f $inffile | tee -a $logfile || doExit
+SSLOn
+
echo "INFO Finished with setup, logfile is setup/setup.log" | tee -a $logfile
if [ -f setup/setup.log ] ; then
cat $logfile >> setup/setup.log
diff --git a/ldap/cm/newinst/setup.patch b/ldap/cm/newinst/setup.patch
new file mode 100755
index 000000000..45004736b
--- /dev/null
+++ b/ldap/cm/newinst/setup.patch
@@ -0,0 +1,307 @@
+#!/bin/sh
+#
+# BEGIN COPYRIGHT BLOCK
+# This Program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 2 of the License.
+#
+# This Program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# In addition, as a special exception, Red Hat, Inc. gives You the additional
+# right to link the code of this Program with code not covered under the GNU
+# General Public License ("Non-GPL Code") and to distribute linked combinations
+# including the two, subject to the limitations in this paragraph. Non-GPL Code
+# permitted under this exception must only link to the code of this Program
+# through those well defined interfaces identified in the file named EXCEPTION
+# found in the source code files (the "Approved Interfaces"). The files of
+# Non-GPL Code may instantiate templates or use macros or inline functions from
+# the Approved Interfaces without causing the resulting work to be covered by
+# the GNU General Public License. Only Red Hat, Inc. may make changes or
+# additions to the list of Approved Interfaces. You must obey the GNU General
+# Public License in all respects for all of the Program code and other code used
+# in conjunction with the Program except the Non-GPL Code covered by this
+# exception. If you modify this file, you may extend this exception to your
+# version of the file, but you are not obligated to do so. If you do not wish to
+# provide this exception without modification, you must delete this exception
+# statement from your version and license this file solely under the GPL without
+# exception.
+#
+#
+# Copyright (C) 2005 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+#
+# This script is a wrapper for dssetup used for inplace upgrade / patch
+# installation.
+#
+clear
+
+echo " Fedora Project"
+echo " Fedora Server Products Installation/Uninstallation"
+echo "-------------------------------------------------------------------------------"
+echo ""
+echo ""
+echo "BY INSTALLING THIS SOFTWARE YOU ARE CONSENTING TO BE BOUND BY"
+echo "AND ARE BECOMING A PARTY TO THE AGREEMENT FOUND IN THE"
+echo "LICENSE.TXT FILE. IF YOU DO NOT AGREE TO ALL OF THE TERMS"
+echo "OF THIS AGREEMENT, PLEASE DO NOT INSTALL OR USE THIS SOFTWARE."
+echo ""
+printf "Do you agree to the license terms? [No]: "
+read ans
+
+if [ "$ans" != "Y" -a "$ans" != "YES" -a "$ans" != "Yes" -a "$ans" != "y" -a "$ans" != "yes" ]; then
+ exit 1;
+fi
+
+clear
+
+echo " Fedora Project"
+echo " Fedora Server Products Installation/Uninstallation"
+echo "-------------------------------------------------------------------------------"
+echo ""
+echo ""
+echo "This program will extract the patch files and install them"
+echo "into a directory where the Directory Server is already installed."
+echo ""
+echo "To accept the default shown in brackets, press the Enter key."
+echo ""
+printf "Install location [/opt/fedora/servers]: "
+read serverroot
+
+if [ ! -d $serverroot ]; then
+ echo ""
+ echo "Directory $serverroot does not exist."
+ exit 1
+fi
+
+if [ ! -f $serverroot/admin-serv/config/adm.conf ]; then
+ echo ""
+ echo "Administration Server's configuration file $serverroot/admin-serv/config/adm.conf does not exist."
+ exit 1
+fi
+
+getValFromAdminConf() {
+ cattr=$1
+ cfile=$2
+ rval=`grep -i $cattr $serverroot/admin-serv/config/$cfile | awk '{print $2}'`
+ echo $rval
+}
+
+dsinst=`getValFromAdminConf "ldapStart:" "adm.conf" | awk -F/ '{print $1}'`
+dsconffile=$serverroot/$dsinst/config/dse.ldif
+if [ ! -f $dsconffile ]; then
+ echo ""
+ echo "Directory Server's configuration file $dsconffile does not exist."
+ exit 1
+fi
+
+clear
+
+isadminsslon=0
+sslparams=""
+
+adminSSLOff() {
+ conffile=$1
+ confparam=$2
+ tmpfile=$3
+ if [ -f $conffile ]; then
+ security=`grep -i "^$confparam" $conffile | awk '{print $1}'`
+ issecure=`grep -i "^$confparam" $conffile | awk '{print $2}'`
+ if [ "$issecure" = "on" -o "$issecure" = "ON" -o "$issecure" = "On" -o "$issecure" = "oN" ]
+ then
+ if [ $isadminsslon -eq 0 ]; then
+ $serverroot/stop-admin
+ isadminsslon=1
+ fi
+ echo $conffile=$security >> $tmpfile
+ cat $conffile | sed -e "s/^\($security\) .*/\1 off/g" > $conffile.0
+ mv $conffile.0 $conffile
+ echo "$conffile: SSL off ..."
+ fi
+ fi
+}
+
+adminXmlSSLOff() {
+ conffile=$1
+ confparam=$2
+ tmpfile=$3
+ if [ -f $conffile ]; then
+ grep -i "\<security=\"on\"" $conffile > /dev/null 2>&1
+ rval=$?
+ if [ $rval -eq 0 ]
+ then
+ if [ $isadminsslon -eq 0 ]; then
+ $serverroot/stop-admin
+ isadminsslon=1
+ fi
+ echo $conffile=$confparam >> $tmpfile
+ cat $conffile | sed -e "s/\([Ss][Ee][Cc][Uu][Rr][Ii][Tt][Yy]=\)\"[A-Za-z]*\"/\1\"off\"/g" > $conffile.0
+ mv $conffile.0 $conffile
+ echo "$conffile: SSL off ..."
+ fi
+ sslparams0=`grep -i "<.*SSLPARAMS " $conffile`
+ rval=$?
+ if [ $rval -eq 0 ]
+ then
+ if [ $isadminsslon -eq 0 ]; then
+ $serverroot/stop-admin
+ isadminsslon=1
+ fi
+ sslparams1=`echo $sslparams0 | sed -e 's/\//\\\\\//g'`
+ sslparams=`echo $sslparams1 | sed -e 's/\"/\\\\\"/g'`
+ cat $conffile | sed -e "s/\($sslparams\)/\<\!-- \1 --\>/g" > $conffile.0
+ mv $conffile.0 $conffile
+ echo "$conffile: SSL off ..."
+ fi
+ fi
+}
+
+rm -f dssecure.txt assecure.txt > /dev/null 2>&1
+touch dssecure.txt
+touch assecure.txt
+
+for dir in $serverroot/slapd-* ; do
+ if [ -f $dir/config/dse.ldif ]; then
+ security=`grep -i "^nsslapd-security:" $dir/config/dse.ldif | awk '{print $1}'`
+ issecure=`grep -i "^nsslapd-security:" $dir/config/dse.ldif | awk '{print $2}'`
+ if [ "$issecure" = "on" -o "$issecure" = "ON" -o "$issecure" = "On" -o "$issecure" = "oN" ]
+ then
+ echo $dir >> dssecure.txt
+ $dir/stop-slapd
+ cat $dir/config/dse.ldif | sed -e "s/\($security\) .*/\1 off/g" > $dir/config/dse.ldif.0
+ mv $dir/config/dse.ldif.0 $dir/config/dse.ldif
+ echo "$dir/config/dse.ldif: SSL off ..."
+ $dir/start-slapd
+ fi
+ fi
+done
+
+if [ -d $serverroot/admin-serv/config ]; then
+ adminSSLOff $serverroot/admin-serv/config/adm.conf security: assecure.txt
+ adminSSLOff $serverroot/admin-serv/config/local.conf configuration.nsServerSecurity: assecure.txt
+ adminSSLOff $serverroot/admin-serv/config/magnus.conf Security assecure.txt
+ adminXmlSSLOff $serverroot/admin-serv/config/server.xml security assecure.txt
+
+ if [ $isadminsslon -ne 0 ]; then
+ $serverroot/start-admin
+ fi
+fi
+
+ldaphost=`getValFromAdminConf "ldapHost:" "adm.conf"`
+ldapport=`getValFromAdminConf "ldapPort:" "adm.conf"`
+siepid=`getValFromAdminConf "siepid:" "adm.conf"`
+suitespotuser=`ls -l $dsconffile | awk '{print $3}'`
+suitespotgroup=`ls -l $dsconffile | awk '{print $4}'`
+admindomain=`echo $ldaphost | awk -F. '{if ($5) {print $2 "." $3 "." $4 "." $5} else if ($4) {print $2 "." $3 "." $4} else if ($3) {print $2 "." $3} else if ($2) {print $2} else {print ""}}'`
+if [ "$admindomain" = "" ]; then
+ admindomain=`domainname`
+fi
+
+clear
+
+echo " Fedora Project"
+echo " Directory Installation/Uninstallation"
+echo "-------------------------------------------------------------------------------"
+echo ""
+echo "In order to reconfigure your installation, the Configuration Directory"
+echo "Administrator password is required. Here is your current information:"
+echo ""
+echo "Configuration Directory: ldap://$ldaphost:$ldapport/o=NetscapeRoot"
+echo "Configuration Administrator ID: $siepid"
+echo ""
+echo "At the prompt, please enter the password for the Configuration Administrator."
+echo ""
+echo "administrator ID: $siepid"
+siepasswd=""
+while [ "$siepasswd" = "" ]; do
+ printf "Password: "
+ read siepasswd
+done
+
+inffile=./myinstall.inf
+
+echo "[General]" > $inffile
+echo "FullMachineName= $ldaphost" >> $inffile
+echo "SuiteSpotUserID= $suitespotuser" >> $inffile
+echo "SuitespotGroup= $suitespotgroup" >> $inffile
+echo "ServerRoot= $serverroot" >> $inffile
+echo "ConfigDirectoryLdapURL= ldap://$ldaphost:$ldapport/" >> $inffile
+echo "ConfigDirectoryAdminID= $siepid" >> $inffile
+echo "AdminDomain= $admindomain" >> $inffile
+echo "ConfigDirectoryAdminPwd= $siepasswd" >> $inffile
+echo "Components= slapd-71sp1" >> $inffile
+echo "" >> $inffile
+echo "[slapd-71sp1]" >> $inffile
+echo "Components= slapd-71sp1" >> $inffile
+
+clear
+
+./dssetup -s -f $inffile
+
+adminSSLOn() {
+ conffile=$1
+ confparam=$2
+ if [ -f $conffile ]; then
+ cat $conffile | sed -e "s/^\($confparam\) .*/\1 on/g" > $conffile.0
+ mv $conffile.0 $conffile
+ echo "$conffile $confparam: SSL on ..."
+ fi
+}
+
+adminXmlSSLOn() {
+ conffile=$1
+ if [ -f $conffile ]; then
+ cat $conffile | sed -e "s/\([Ss][Ee][Cc][Uu][Rr][Ii][Tt][Yy]=\)\"[A-Za-z]*\"/\1\"on\"/g" > $conffile.0
+ mv $conffile.0 $conffile
+ fi
+ grep -i "<.*SSLPARAMS " $conffile > /dev/null 2>&1
+ rval=$?
+ if [ $rval -eq 0 ]
+ then
+ cat $conffile | sed -e "s/<\!-- *$sslparams *-->/$sslparams/g" > $conffile.0
+ mv $conffile.0 $conffile
+ fi
+ echo "$conffile: SSL on ..."
+}
+
+for dir in `cat dssecure.txt` ; do
+ clear
+ if [ -f $dir/config/dse.ldif ]; then
+ security=`grep -i "^nsslapd-security:" $dir/config/dse.ldif | awk '{print $1}'`
+ $dir/stop-slapd
+ cat $dir/config/dse.ldif | sed -e "s/\($security\) .*/\1 on/g" > $dir/config/dse.ldif.0
+ mv $dir/config/dse.ldif.0 $dir/config/dse.ldif
+ echo "$dir/config/dse.ldif: SSL on ..."
+ echo "Restarting Directory Server: $dir/start-slapd"
+ $dir/start-slapd
+ fi
+done
+
+if [ $isadminsslon -ne 0 ]; then
+ $serverroot/stop-admin
+fi
+for confline in `cat assecure.txt` ; do
+ conffile=`echo $confline | awk -F= '{print $1}'`
+ confparam=`echo $confline | awk -F= '{print $2}'`
+ echo $conffile | grep "\.xml$" > /dev/null 2>&1
+ rval=$?
+ if [ $rval -eq 0 ]; then
+ adminXmlSSLOn $conffile $confparam
+ else
+ adminSSLOn $conffile $confparam
+ fi
+done
+if [ $isadminsslon -ne 0 ]; then
+ echo "Restarting Administration Server: $serverroot/start-admin"
+ $serverroot/start-admin
+fi
+
+rm -f dssecure.txt assecuire.txt
diff --git a/ldap/cm/redhat-patch.inf b/ldap/cm/redhat-patch.inf
index 5c48aa098..27a613eec 100644
--- a/ldap/cm/redhat-patch.inf
+++ b/ldap/cm/redhat-patch.inf
@@ -39,8 +39,11 @@
# Sample Info file to generate service pack
# base: <builddir> containing the base package -- e.g., DS7.1
# file: <bugzilla number>: <patchfile>
+# compfile: bug#: <patch_zipfile>:<patchfile>
+# %DISTDIR% points <buildroot>/dist/<platform>
#
base: /share/dev4/fedora-ds/fds71/ships/20050526.1
file: 000001: README.txt
file: 000002: lib/libback-ldbm.*
+compfile: 000003: %DISTDIR%/adminserver/admin/nsadmin.zip:manual/help/help
| 0 |
d04ffbe70416df4b1b63e7d4e21dbcbb428afe49
|
389ds/389-ds-base
|
fix typos in Makefile.am, acctpolicy schema
Fixed some typos and copy/paste errors in Makefile.am and acctpolicy schema
|
commit d04ffbe70416df4b1b63e7d4e21dbcbb428afe49
Author: Rich Megginson <[email protected]>
Date: Wed Sep 29 14:19:04 2010 -0600
fix typos in Makefile.am, acctpolicy schema
Fixed some typos and copy/paste errors in Makefile.am and acctpolicy schema
diff --git a/Makefile.am b/Makefile.am
index 6371f83bb..ccf42d852 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,7 +179,7 @@ endif
if enable_acctpolicy
LIBACCTPOLICY_PLUGIN = libacctpolicy-plugin.la
LIBACCTPOLICY_SCHEMA = $(srcdir)/ldap/schema/60acctpolicy.ldif
-enable_bitwise = 1
+enable_acctpolicy = 1
endif
serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la \
diff --git a/Makefile.in b/Makefile.in
index a4c8f9e02..9c94ff1a2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1268,7 +1268,6 @@ server_LTLIBRARIES = libslapd.la libns-dshttpd.la
@enable_dna_TRUE@LIBDNA_PLUGIN = libdna-plugin.la
@enable_dna_TRUE@enable_dna = 1
@enable_bitwise_TRUE@LIBBITWISE_PLUGIN = libbitwise-plugin.la
-@enable_acctpolicy_TRUE@enable_bitwise = 1
@enable_bitwise_TRUE@enable_bitwise = 1
@enable_presence_TRUE@LIBPRESENCE_PLUGIN = libpresence-plugin.la
@enable_presence_TRUE@LIBPRESENCE_SCHEMA = $(srcdir)/ldap/schema/10presence.ldif
@@ -1277,6 +1276,7 @@ server_LTLIBRARIES = libslapd.la libns-dshttpd.la
@SELINUX_TRUE@POLICY_FC = selinux-built/dirsrv.fc
@enable_acctpolicy_TRUE@LIBACCTPOLICY_PLUGIN = libacctpolicy-plugin.la
@enable_acctpolicy_TRUE@LIBACCTPOLICY_SCHEMA = $(srcdir)/ldap/schema/60acctpolicy.ldif
+@enable_acctpolicy_TRUE@enable_acctpolicy = 1
serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la \
libback-ldbm.la libchainingdb-plugin.la libcollation-plugin.la \
libcos-plugin.la libderef-plugin.la libdes-plugin.la libdistrib-plugin.la \
diff --git a/ldap/schema/60acctpolicy.ldif b/ldap/schema/60acctpolicy.ldif
index 40c092ec8..2eff427c3 100644
--- a/ldap/schema/60acctpolicy.ldif
+++ b/ldap/schema/60acctpolicy.ldif
@@ -26,7 +26,7 @@ attributeTypes: ( 2.16.840.1.113719.1.1.4.1.35 NAME 'lastLoginTime'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE USAGE directoryOperation
X-ORIGIN 'Account Policy Plugin' )
##
-## acctPolicySubentry is an an account policy pointer (DN syntax)
+## acctPolicySubentry is an account policy pointer (DN syntax)
attributeTypes: ( 1.3.6.1.4.1.11.1.3.2.1.2 NAME 'acctPolicySubentry'
DESC 'Account policy pointer'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE USAGE directoryOperation
| 0 |
2ab2ba7aa99be22a8d8c871786704a6149b9e7ce
|
389ds/389-ds-base
|
New RPM packaging options
|
commit 2ab2ba7aa99be22a8d8c871786704a6149b9e7ce
Author: svrbld <svrbld>
Date: Tue Apr 5 23:08:06 2005 +0000
New RPM packaging options
diff --git a/Makefile b/Makefile
index 302ebc95b..e49b2b208 100644
--- a/Makefile
+++ b/Makefile
@@ -299,7 +299,9 @@ endif
redhat-ds.spec: ldapserver.spec.tmpl branding/rhds/brandver.dat $(RELTOOLSPATH)/brandver.pl
sed -e s/@PLATFORM@/$(BUILD_ARCH)/g ldapserver.spec.tmpl > $@
$(RELTOOLSPATH)/brandver.pl -i branding/rhds/brandver.dat $@
+ mv $@ $(OBJDIR)
fedora-ds.spec: ldapserver.spec.tmpl branding/fedora/brandver.dat $(RELTOOLSPATH)/brandver.pl
sed -e s/@PLATFORM@/$(BUILD_ARCH)/g ldapserver.spec.tmpl > $@
$(RELTOOLSPATH)/brandver.pl -i branding/fedora/brandver.dat $@
+ mv $@ $(OBJDIR)
diff --git a/ldap/cm/Makefile b/ldap/cm/Makefile
index bdd73d89d..acbcaa08b 100644
--- a/ldap/cm/Makefile
+++ b/ldap/cm/Makefile
@@ -118,7 +118,6 @@ endif
FTPNAME = $(shell $(RELTOOLS) -name directory $(VERSION) $(INTL) $(SEC) $(DBG) $(SUF))
FTPNAMEGZ = $(shell $(RELTOOLS) -name directory $(VERSION) $(INTL) $(SEC) $(DBG) $(SUFEXE) )
-
# regular NT
ifeq ($(ARCH), WINNT)
@@ -222,6 +221,25 @@ endif
PACKAGE_SETUP_LIBS_32=$(subst $(NS64TAG),,$(PACKAGE_SETUP_LIBS))
+# set the values of the macros used by rpmbuild
+ifdef BUILD_RPM
+# name and version of RPM - must correspond to the spec file - these get branded
+ RPM_BASE_NAME=fedora
+ RPM_VERSION=7.1
+ RPM_FILE_BASE=$(RPM_BASE_NAME)-ds-$(RPM_VERSION)
+# root dir for RPM built and temp files
+ ABS_TOPDIR = $(shell cd $(INSTDIR)/.. ; pwd)
+ RPM_TOPDIR = --define "_topdir $(ABS_TOPDIR)"
+# location of source tarball
+ RPM_SOURCEDIR = --define "_sourcedir $(ABS_TOPDIR)"
+# location of staging area built into RPM
+ RPM_BUILDDIR = --define "_builddir $(ABS_INSTDIR)"
+# location of final RPM file
+ RPM_RPMDIR = --define "_rpmdir $(ABS_TOPDIR)"
+# location of source RPM
+ RPM_SRPMDIR = --define "_srcrpmdir $(ABS_TOPDIR)"
+endif
+
# Borland libraries are build on NT only
dummy:
@@ -482,6 +500,11 @@ endif
$(INSTALL) -m 444 $(LDAPDIR)/cm/v4confs/411/*.* $(RELDIR)/bin/slapd/install/version4/411
$(INSTALL) -m 444 $(LDAPDIR)/cm/v4confs/412/*.* $(RELDIR)/bin/slapd/install/version4/412
+# for RPM, include the post install setup program
+ifdef BUILD_RPM
+ $(INSTALL) -m 755 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/cm/newinst/setup $(RELDIR)/setup/setup
+endif # BUILD_RPM
+
find $(RELDIR) -exec chmod go-w {} \;
# $(RELDIR)/bin/slapd/server may host a core file.
# For security reason, it's readable only by the owner
@@ -703,6 +726,22 @@ endif
#cp $(INSTDIR)/all$(NS_BUILD_FLAVOR).tar.gz $(BUILD_SHIP)
# $(INSTDIR) is used to build international products.
endif
+ifdef BUILD_RPM
+# make the .spec file - actually lives in OBJDIR
+ $(MAKE) $(MFLAGS) -C $(BUILD_ROOT) $(RPM_BASE_NAME)-ds.spec
+# create the source tarball - the name must correspond to the Source: in the spec file
+# they should correspond because the values come from the same source - branding
+ startdir=`pwd` ; cd $(BUILD_ROOT) ; builddir=`pwd` ; \
+ cd $$startdir ; cd $(INSTDIR)/.. ; \
+ if [ ! -f $(RPM_FILE_BASE).tar.gz ] ; then \
+ if [ ! -f $(RPM_FILE_BASE) ] ; then \
+ ln -s $$builddir $(RPM_FILE_BASE) ; \
+ fi ; tar cfh - --exclude \*/built/\* $(RPM_FILE_BASE) | gzip > $(RPM_FILE_BASE).tar.gz ; \
+ rm $(RPM_FILE_BASE) ; \
+ fi
+# execute the RPM build
+ rpmbuild $(RPM_TOPDIR) $(RPM_SOURCEDIR) $(RPM_BUILDDIR) $(RPM_RPMDIR) $(RPM_SRPMDIR) --clean --nodeps -ba $(OBJDIR)/$(RPM_BASE_NAME)-ds.spec
+endif # BUILD_RPM
else
diff --git a/ldapserver.spec.tmpl b/ldapserver.spec.tmpl
index a4d7c42c5..bdddee93f 100644
--- a/ldapserver.spec.tmpl
+++ b/ldapserver.spec.tmpl
@@ -2,6 +2,9 @@
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
+%define _unpackaged_files_terminate_build 0
+# override the default build name format - we do not want the arch subdir
+%define _build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
Summary: @COMPANY-PRODUCT-NAME@
Name: @LCASE-COMPANY-NAME-NOSP@-ds
Version: @GEN-VERSION@
@@ -9,8 +12,8 @@ Release: 1.@PLATFORM@
License: GPL plus extensions
Group: System Environment/Daemons
URL: @COMPANY-URL@
-Source0: %{name}-%{version}.tar.gz
-BuildRoot: %{_builddir}/%{name}-root
+Source: %{name}-%{version}.tar.gz
+BuildRoot: %{_builddir}
BuildPreReq: perl, fileutils, make
# Without Autoreq: 0, rpmbuild finds all sorts of crazy
# dependencies that we don't care about, and refuses to install
@@ -22,47 +25,25 @@ Prefix: /opt/%{name}
%description
@COMPANY-PRODUCT-NAME@ is an LDAPv3 compliant server.
-# prep and setup expect there to be a Source0 file
-# in the SOURCES directory - it will be unpacked
-# in the _builddir (not BuildRoot)
-%prep
-%setup -q
-
-%build
-# This will do a regular make build and make pkg
-# including grabbing the admin server, setup, etc.
-# The resultant zip files and setup program will
-# be in ldapserver/pkg
-# INSTDIR is relative to ldap/cm
-# build the file structure to package under ldapserver/pkg
-# instead of MM.DD/platform
-# remove BUILD_DEBUG=optimize to build the debug version
-# INTERNAL_BUILD=1 uses the internal, proprietary packages
-# like setupsdk, adminsdk, admin server
-# BUILD_MODE=int builds the Redhat branded product
-BUILDMODE=@BUILD-MODE@
-PLATFORM=@PLATFORM@
-if [ $BUILDMODE = int ]; then
-# brandDirectory makes the product use Redhat branded text and graphics
- make brandDirectory
-fi
-make INTERNAL_BUILD=1 BUILD_MODE=$BUILDMODE BUILD_JAVA_CODE=1 BUILD_DEBUG=optimize NO_INSTALLER_TAR_FILES=1 INSTDIR=../../pkg/$PLATFORM
+# wait! what's going on here? where are the prep and build sections?
+# what kind of a .spec file is this anyway?
+# A: one that works well with the current DS build system
+# As we move towards a completely open source build
+# process, will begin doing things in the more RPM way
+# but for now, in order to make our tight deadlines and
+# support RHN distribution, this is the way we do it
%install
# all we do here is run setup -b to unpack the binaries
# into the BuildRoot
-PLATFORM=@PLATFORM@
-rm -rf $RPM_BUILD_ROOT
-cd pkg/$PLATFORM
# the echo yes is for dsktune to continue
echo yes | ./setup -b $RPM_BUILD_ROOT/%{prefix}
-# this is our setup script that sets up the initial
-# server instances after installation
-cd ../..
-cp ldap/cm/newinst/setup $RPM_BUILD_ROOT/%{prefix}/setup
%clean
-rm -rf $RPM_BUILD_ROOT
+if [ -z "$RPM_INSTALL_PREFIX" ]; then
+ RPM_INSTALL_PREFIX=%{prefix}
+fi
+rm -rf $RPM_BUILD_ROOT/$RPM_INSTALL_PREFIX
%files
# rather than listing individual files, we just package (and own)
@@ -74,18 +55,21 @@ rm -rf $RPM_BUILD_ROOT
%post
echo ""
if [ -z "$RPM_INSTALL_PREFIX" ]; then
- RPM_INSTALL_PREFIX=${prefix}
+ RPM_INSTALL_PREFIX=%{prefix}
fi
-echo "Please go to $RPM_INSTALL_PREFIX and run ./setup/setup"
+echo "Install finished. Please run $RPM_INSTALL_PREFIX/setup/setup to set up the servers."
%preun
if [ -z "$RPM_INSTALL_PREFIX" ]; then
- RPM_INSTALL_PREFIX=${prefix}
+ RPM_INSTALL_PREFIX=%{prefix}
fi
cd $RPM_INSTALL_PREFIX
./uninstall -s -force
%changelog
+* Tue Apr 5 2005 Rich Megginson <[email protected]> 7.1-1
+- Removed all of the setup and build stuff - just use the regular DS build process for that
+
* Tue Apr 5 2005 Rich Megginson <[email protected]> 7.1-1
- use platform specific packaging directory; add preun to do uninstall
| 0 |
2ff621022feae3acdd0449d3eb97a3a873d2c444
|
389ds/389-ds-base
|
Update dsktune version date
|
commit 2ff621022feae3acdd0449d3eb97a3a873d2c444
Author: Nathan Kinder <[email protected]>
Date: Mon Apr 4 22:33:32 2005 +0000
Update dsktune version date
diff --git a/ldap/systools/idsktune.c b/ldap/systools/idsktune.c
index 00ecae46b..2b5da78a0 100644
--- a/ldap/systools/idsktune.c
+++ b/ldap/systools/idsktune.c
@@ -7,7 +7,7 @@
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Don't forget to update build_date when the patch sets are updated.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-static char *build_date = "19-MARCH-2004";
+static char *build_date = "04-APRIL-2005";
#if defined(__FreeBSD__) || defined(__bsdi)
#define IDDS_BSD_INCLUDE 1
| 0 |
234cb2ec9807862ec0af8ba4369d338536cc96ac
|
389ds/389-ds-base
|
Bump version to 2.4.1
|
commit 234cb2ec9807862ec0af8ba4369d338536cc96ac
Author: Mark Reynolds <[email protected]>
Date: Thu May 18 09:36:28 2023 -0400
Bump version to 2.4.1
diff --git a/VERSION.sh b/VERSION.sh
index 174f9e5bf..9ff466074 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=0
+VERSION_MAINT=1
# 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 |
7db4fa90caa543b59352046138f453236c0fd652
|
389ds/389-ds-base
|
Ticket #47834 - Tombstone_to_glue: if parents are also converted to glue, the target entry's DN must be adjusted.
Description: Previous fix for the ticket #47834 broke the CI test case
47815.
The fix for 47815 removed the addingentry from the entry cache if
SLAPI_PLUGIN_BE_TXN_POST_ADD_FN failed. The #47834 patch accidentally
deleted the code.
Instead of adding it back, this patch moves the deletion of the entry
from the entry cache to cover both cases SLAPI_PLUGIN_BE_TXN_POST_ADD
_FN successes or fails.
https://fedorahosted.org/389/ticket/47834
Reviewed by [email protected] (Thank you, Mark!!)
|
commit 7db4fa90caa543b59352046138f453236c0fd652
Author: Noriko Hosoi <[email protected]>
Date: Mon Sep 8 14:29:29 2014 -0700
Ticket #47834 - Tombstone_to_glue: if parents are also converted to glue, the target entry's DN must be adjusted.
Description: Previous fix for the ticket #47834 broke the CI test case
47815.
The fix for 47815 removed the addingentry from the entry cache if
SLAPI_PLUGIN_BE_TXN_POST_ADD_FN failed. The #47834 patch accidentally
deleted the code.
Instead of adding it back, this patch moves the deletion of the entry
from the entry cache to cover both cases SLAPI_PLUGIN_BE_TXN_POST_ADD
_FN successes or fails.
https://fedorahosted.org/389/ticket/47834
Reviewed by [email protected] (Thank you, Mark!!)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 2f1b3986e..b74154af3 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -1209,21 +1209,6 @@ error_return:
{
next_id_return( be, addingentry->ep_id );
}
- if ( addingentry )
- {
- if (inst && cache_is_in_cache(&inst->inst_cache, addingentry)) {
- CACHE_REMOVE(&inst->inst_cache, addingentry);
- /* tell frontend not to free this entry */
- slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
- }
- else if (!cache_has_otherref(&inst->inst_cache, addingentry))
- {
- if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
- backentry_clear_entry(addingentry); /* e is released in the frontend */
- }
- }
- CACHE_RETURN( &inst->inst_cache, &addingentry );
- }
if (rc == DB_RUNRECOVERY) {
dblayer_remember_disk_filled(li);
ldbm_nasty("Add",80,rc);
@@ -1244,6 +1229,20 @@ error_return:
}
diskfull_return:
if (disk_full) {
+ if ( addingentry ) {
+ if (inst && cache_is_in_cache(&inst->inst_cache, addingentry)) {
+ CACHE_REMOVE(&inst->inst_cache, addingentry);
+ /* tell frontend not to free this entry */
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+ }
+ else if (!cache_has_otherref(&inst->inst_cache, addingentry))
+ {
+ if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
+ backentry_clear_entry(addingentry); /* e is released in the frontend */
+ }
+ }
+ CACHE_RETURN( &inst->inst_cache, &addingentry );
+ }
rc = return_on_disk_full(li);
} else {
/* It is safer not to abort when the transaction is not started. */
@@ -1277,13 +1276,41 @@ diskfull_return:
}
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
}
-
+ if ( addingentry ) {
+ if (inst && cache_is_in_cache(&inst->inst_cache, addingentry)) {
+ CACHE_REMOVE(&inst->inst_cache, addingentry);
+ /* tell frontend not to free this entry */
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+ }
+ else if (!cache_has_otherref(&inst->inst_cache, addingentry))
+ {
+ if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
+ backentry_clear_entry(addingentry); /* e is released in the frontend */
+ }
+ }
+ CACHE_RETURN( &inst->inst_cache, &addingentry );
+ }
/* Release SERIAL LOCK */
if (!noabort) {
dblayer_txn_abort(be, &txn); /* abort crashes in case disk full */
}
/* txn is no longer valid - reset the txn pointer to the parent */
slapi_pblock_set(pb, SLAPI_TXN, parent_txn);
+ } else {
+ if ( addingentry ) {
+ if (inst && cache_is_in_cache(&inst->inst_cache, addingentry)) {
+ CACHE_REMOVE(&inst->inst_cache, addingentry);
+ /* tell frontend not to free this entry */
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+ }
+ else if (!cache_has_otherref(&inst->inst_cache, addingentry))
+ {
+ if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
+ backentry_clear_entry(addingentry); /* e is released in the frontend */
+ }
+ }
+ CACHE_RETURN( &inst->inst_cache, &addingentry );
+ }
}
if (!not_an_error) {
rc = SLAPI_FAIL_GENERAL;
| 0 |
cbe9198cfb21543464e34a838e2fea355df84de5
|
389ds/389-ds-base
|
Bump verison to 1.3.7.2
|
commit cbe9198cfb21543464e34a838e2fea355df84de5
Author: Mark Reynolds <[email protected]>
Date: Tue Aug 22 09:46:23 2017 -0400
Bump verison to 1.3.7.2
diff --git a/VERSION.sh b/VERSION.sh
index 7e9c27450..8b8f71f0c 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=3
-VERSION_MAINT=7.1
+VERSION_MAINT=7.2
# NOTE: VERSION_PREREL is automatically set for builds made out of a git tree
VERSION_PREREL=
VERSION_DATE=$(date -u +%Y%m%d)
| 0 |
9523a33e2f4c54eda2a171b1a17a668e5e32a83b
|
389ds/389-ds-base
|
Issue 5329 - Improve replication extended op logging
Description:
We need logging around parsing extended op payload, right now when it
fails we have no idea why.
relates: https://github.com/389ds/389-ds-base/issues/5329
Reviewed by: progier, firstyear, and spichugi(Thanks!!!)
|
commit 9523a33e2f4c54eda2a171b1a17a668e5e32a83b
Author: Mark Reynolds <[email protected]>
Date: Thu Jun 2 16:57:07 2022 -0400
Issue 5329 - Improve replication extended op logging
Description:
We need logging around parsing extended op payload, right now when it
fails we have no idea why.
relates: https://github.com/389ds/389-ds-base/issues/5329
Reviewed by: progier, firstyear, and spichugi(Thanks!!!)
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index 47cba16a0..9996f3487 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -73,6 +73,18 @@ done:
return rc;
}
+static void
+ruv_dump_to_log(const RUV *ruv, char *log_name)
+{
+ if (!ruv) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "%s: RUV: None\n", log_name);
+ } else {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "%s: RUV:\n", log_name);
+ ruv_dump(ruv, log_name, NULL);
+ }
+}
+
+
/* The data_guid and data parameters should only be set if we
* are talking with a 9.0 replica. */
static struct berval *
@@ -95,33 +107,60 @@ create_ReplicationExtopPayload(const char *protocol_oid,
PR_ASSERT(protocol_oid != NULL || send_end);
PR_ASSERT(repl_root != NULL);
- /* Create the request data */
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "create_ReplicationExtopPayload - "
+ "encoding '%s' payload...\n",
+ send_end ? "End Replication" : "Start Replication");
+ }
+ /* Create the request data */
if ((tmp_bere = der_alloc()) == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: der_alloc failed\n");
rc = LDAP_ENCODING_ERROR;
goto loser;
}
if (!send_end) {
if (ber_printf(tmp_bere, "{ss", protocol_oid, repl_root) == -1) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: ber_printf failed - protocol_oid (%s) repl_root (%s)\n",
+ protocol_oid, repl_root);
rc = LDAP_ENCODING_ERROR;
goto loser;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "create_ReplicationExtopPayload - "
+ "encoding protocol_oid: %s\n", protocol_oid);
+ }
} else {
if (ber_printf(tmp_bere, "{s", repl_root) == -1) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: ber_printf failed - repl_root (%s)\n",
+ repl_root);
rc = LDAP_ENCODING_ERROR;
goto loser;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "create_ReplicationExtopPayload - "
+ "encoding repl_root: %s\n", repl_root);
+ }
}
sdn = slapi_sdn_new_dn_byref(repl_root);
repl = replica_get_replica_from_dn(sdn);
if (repl == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: failed to get replica from dn (%s)\n",
+ slapi_sdn_get_dn(sdn));
rc = LDAP_OPERATIONS_ERROR;
goto loser;
}
ruv_obj = replica_get_ruv(repl);
if (ruv_obj == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: failed to get ruv from replica suffix (%s)\n",
+ slapi_sdn_get_dn(sdn));
rc = LDAP_OPERATIONS_ERROR;
goto loser;
}
@@ -134,8 +173,14 @@ create_ReplicationExtopPayload(const char *protocol_oid,
/* We need to encode and send each time the local ruv in case we have changed it */
rc = encode_ruv(tmp_bere, ruv);
if (rc != 0) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: encode_ruv failed for replica suffix (%s)\n",
+ slapi_sdn_get_dn(sdn));
goto loser;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ ruv_dump_to_log(ruv, "create_ReplicationExtopPayload");
+ }
if (!send_end) {
char s[CSN_STRSIZE];
@@ -157,36 +202,67 @@ create_ReplicationExtopPayload(const char *protocol_oid,
charray_merge(&referrals_to_send, local_replica_referral, 0);
if (NULL != referrals_to_send) {
if (ber_printf(tmp_bere, "[v]", referrals_to_send) == -1) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: ber_printf (referrals_to_send)\n");
rc = LDAP_ENCODING_ERROR;
goto loser;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ for (size_t i = 0; referrals_to_send[i]; i++) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "create_ReplicationExtopPayload - "
+ "encoding ref: %s\n", referrals_to_send[i]);
+ }
+ }
slapi_ch_free((void **)&referrals_to_send);
}
/* Add the CSN */
PR_ASSERT(NULL != csn);
if (ber_printf(tmp_bere, "s", csn_as_string(csn, PR_FALSE, s)) == -1) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: ber_printf (csnstr)\n");
rc = LDAP_ENCODING_ERROR;
goto loser;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "create_ReplicationExtopPayload - "
+ "encoding csn: %s\n", csn_as_string(csn, PR_FALSE, s));
+ }
}
/* If we have data to send to a 9.0 style replica, set it here. */
if (data_guid && data) {
if (ber_printf(tmp_bere, "sO", data_guid, data) == -1) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: ber_printf (data_guid, data)\n");
rc = LDAP_ENCODING_ERROR;
goto loser;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "create_ReplicationExtopPayload - "
+ "encoding data_guid (%s) data (%s:%ld)\n",
+ data_guid, data->bv_val, data->bv_len);
+ }
}
+
if (ber_printf(tmp_bere, "}") == -1) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: ber_printf\n");
rc = LDAP_ENCODING_ERROR;
goto loser;
}
if (ber_flatten(tmp_bere, &req_data) == -1) {
+ slapi_log_err(SLAPI_LOG_ERR, "create_ReplicationExtopPayload",
+ "encoding failed: ber_flatten failed\n");
rc = LDAP_LOCAL_ERROR;
goto loser;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "create_ReplicationExtopPayload - "
+ "Encoding finished\n");
+ }
+
/* Success */
goto done;
@@ -293,8 +369,14 @@ decode_startrepl_extop(Slapi_PBlock *pb, char **protocol_oid, char **repl_root,
if ((NULL == extop_oid) ||
((strcmp(extop_oid, REPL_START_NSDS50_REPLICATION_REQUEST_OID) != 0) &&
(strcmp(extop_oid, REPL_START_NSDS90_REPLICATION_REQUEST_OID) != 0)) ||
- !BV_HAS_DATA(extop_value)) {
+ !BV_HAS_DATA(extop_value))
+ {
/* bogus */
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: extop_oid (%s) (%s) extop_value (%s)\n",
+ NULL == extop_oid ? "NULL" : "Ok",
+ extop_oid ? extop_oid : "",
+ extop_value ? !BV_HAS_DATA(extop_value) ? "No data" : "Ok" : "No data");
rc = -1;
goto free_and_return;
}
@@ -307,25 +389,36 @@ decode_startrepl_extop(Slapi_PBlock *pb, char **protocol_oid, char **repl_root,
}
if ((tmp_bere = ber_init(extop_value)) == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_init for extop_value (%s:%lu)\n",
+ extop_value->bv_val, extop_value->bv_len);
rc = -1;
goto free_and_return;
}
if (ber_scanf(tmp_bere, "{") == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_scanf 1\n");
rc = -1;
goto free_and_return;
}
/* Get the required protocol OID and root of replicated subtree */
if (ber_get_stringa(tmp_bere, protocol_oid) == LBER_DEFAULT) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_get_stringa (protocol_oid)\n");
rc = -1;
goto free_and_return;
}
if (ber_get_stringa(tmp_bere, repl_root) == LBER_DEFAULT) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_get_stringa (repl_root)\n");
rc = -1;
goto free_and_return;
}
/* get supplier's ruv */
if (decode_ruv(tmp_bere, supplier_ruv) == -1) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: decode_ruv (supplier_ruv)\n");
rc = -1;
goto free_and_return;
}
@@ -333,33 +426,45 @@ decode_startrepl_extop(Slapi_PBlock *pb, char **protocol_oid, char **repl_root,
/* Get the optional set of referral URLs */
if (ber_peek_tag(tmp_bere, &len) == LBER_SET) {
if (ber_scanf(tmp_bere, "[v]", extra_referrals) == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_scanf (extra_referrals)\n");
rc = -1;
goto free_and_return;
}
}
/* Get the CSN */
if (ber_get_stringa(tmp_bere, csnstr) == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_get_stringa (csnstr)\n");
rc = -1;
goto free_and_return;
}
/* Get the optional replication session callback data. */
if (ber_peek_tag(tmp_bere, &len) == LBER_OCTETSTRING) {
if (ber_get_stringa(tmp_bere, data_guid) == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_get_stringa (data_guid)\n");
rc = -1;
goto free_and_return;
}
/* If a data_guid was specified, data must be specified as well. */
if (ber_peek_tag(tmp_bere, &len) == LBER_OCTETSTRING) {
if (ber_get_stringal(tmp_bere, data) == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_get_stringal (data)\n");
rc = -1;
goto free_and_return;
}
} else {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_peek_tag\n");
rc = -1;
goto free_and_return;
}
}
if (ber_scanf(tmp_bere, "}") == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_startrepl_extop",
+ "decoding failed: ber_scanf 2\n");
rc = -1;
goto free_and_return;
}
@@ -378,6 +483,22 @@ free_and_return:
if (*supplier_ruv) {
ruv_destroy(supplier_ruv);
}
+ } else if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "decode_startrepl_extop - decoding payload...\n");
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "decode_startrepl_extop - decoded protocol_oid: %s\n", *protocol_oid);
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "decode_startrepl_extop - decoded repl_root: %s\n", *repl_root);
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "decode_startrepl_extop - decoded csn: %s\n", *csnstr);
+ ruv_dump_to_log(*supplier_ruv, "decode_startrepl_extop");
+ for (size_t i = 0; *extra_referrals && *extra_referrals[i]; i++) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "decode_startrepl_extop - "
+ "decoded referral: %s\n", *extra_referrals[i]);
+ }
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "decode_startrepl_extop - Finshed decoding payload.\n");
}
if (NULL != tmp_bere) {
ber_free(tmp_bere, 1);
@@ -406,30 +527,54 @@ decode_endrepl_extop(Slapi_PBlock *pb, char **repl_root)
if ((NULL == extop_oid) ||
(strcmp(extop_oid, REPL_END_NSDS50_REPLICATION_REQUEST_OID) != 0) ||
- !BV_HAS_DATA(extop_value)) {
+ !BV_HAS_DATA(extop_value))
+ {
/* bogus */
+ slapi_log_err(SLAPI_LOG_ERR, "decode_endrepl_extop",
+ "decoding failed: extop_oid (%s) correct oid (%s) extop_value data (%s)\n",
+ extop_oid ? extop_oid : "NULL",
+ extop_oid ? strcmp(extop_oid, REPL_END_NSDS50_REPLICATION_REQUEST_OID) != 0 ? "wrong oid" : "correct oid" : "NULL",
+ !BV_HAS_DATA(extop_value) ? "No data" : "Has data");
rc = -1;
goto free_and_return;
}
if ((tmp_bere = ber_init(extop_value)) == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_endrepl_extop",
+ "decoding failed: ber_init failed: extop_value (%s:%lu)\n",
+ extop_value->bv_val, extop_value->bv_len);
rc = -1;
goto free_and_return;
}
if (ber_scanf(tmp_bere, "{") == LBER_DEFAULT) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_endrepl_extop",
+ "decoding failed: ber_scanf failed1\n");
rc = -1;
goto free_and_return;
}
/* Get the required root of replicated subtree */
if (ber_get_stringa(tmp_bere, repl_root) == LBER_DEFAULT) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_endrepl_extop",
+ "decoding failed: ber_get_stringa failed\n");
rc = -1;
goto free_and_return;
}
if (ber_scanf(tmp_bere, "}") == LBER_DEFAULT) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_endrepl_extop",
+ "decoding failed: ber_scanf2 failed\n");
rc = -1;
goto free_and_return;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, "decode_endrepl_extop",
+ "Decoding payload...\n");
+ slapi_log_err(SLAPI_LOG_REPL, "decode_endrepl_extop",
+ "Decoded repl_root: %s\n", *repl_root);
+ slapi_log_err(SLAPI_LOG_REPL, "decode_endrepl_extop",
+ "Finished decoding payload.\n");
+ }
+
free_and_return:
if (NULL != tmp_bere) {
ber_free(tmp_bere, 1);
@@ -461,27 +606,46 @@ decode_repl_ext_response(struct berval *bvdata, int *response_code, struct berva
PR_ASSERT(NULL != ruv_bervals);
if ((NULL == response_code) || (NULL == ruv_bervals) ||
- (NULL == data_guid) || (NULL == data) || !BV_HAS_DATA(bvdata)) {
+ (NULL == data_guid) || (NULL == data) || !BV_HAS_DATA(bvdata))
+ {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_repl_ext_response",
+ "decoding failed: response_code (%s) ruv_bervals (%s) data_guid (%s) data (%s) bvdata (%s)\n",
+ NULL == response_code ? "NULL" : "Ok",
+ NULL == ruv_bervals ? "NULL" : "Ok",
+ NULL == data_guid ? "NULL" : "Ok",
+ NULL == data ? "NULL" : "Ok",
+ !BV_HAS_DATA(bvdata) ? "No data" : "Ok");
return_value = -1;
} else {
ber_len_t len;
ber_int_t temp_response_code = 0;
*ruv_bervals = NULL;
if ((tmp_bere = ber_init(bvdata)) == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_repl_ext_response",
+ "decoding failed: ber_init failed from bvdata (%s:%lu)\n",
+ bvdata->bv_val, bvdata->bv_len);
return_value = -1;
} else if (ber_scanf(tmp_bere, "{e", &temp_response_code) == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_repl_ext_response",
+ "decoding failed: ber_scanf failed\n");
return_value = -1;
} else if (ber_peek_tag(tmp_bere, &len) == LBER_SEQUENCE) {
if (ber_scanf(tmp_bere, "{V}", ruv_bervals) == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_repl_ext_response",
+ "decoding failed: ber_scanf2 failed from ruv_bervals\n");
return_value = -1;
}
}
/* Check for optional data from replication session callback */
if (ber_peek_tag(tmp_bere, &len) == LBER_OCTETSTRING) {
if (ber_scanf(tmp_bere, "aO}", data_guid, data) == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_repl_ext_response",
+ "decoding failed: ber_scanf3 failed from data_guid & data\n");
return_value = -1;
}
} else if (ber_scanf(tmp_bere, "}") == LBER_ERROR) {
+ slapi_log_err(SLAPI_LOG_ERR, "decode_repl_ext_response",
+ "decoding failed: ber_scanf4 failed\n");
return_value = -1;
}
@@ -934,17 +1098,36 @@ send_response:
/* ONREPL - not sure what we suppose to do here */
}
ber_printf(resp_bere, "{e", response);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "multisupplier_extop_StartNSDS50ReplicationRequest - encoded response: %d\n",
+ response);
+ }
if (NULL != ruv_bervals) {
ber_printf(resp_bere, "{V}", ruv_bervals);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ ruv_dump_to_log(ruv, "multisupplier_extop_StartNSDS50ReplicationRequest");
+ }
}
+
/* Add extra data from replication session callback if necessary */
if (is90 && data_guid && data) {
ber_printf(resp_bere, "sO", data_guid, data);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "multisupplier_extop_StartNSDS50ReplicationRequest - encoded data_guid (%s) data (%s:%ld)\n",
+ data_guid, data->bv_val, data->bv_len);
+ }
}
ber_printf(resp_bere, "}");
ber_flatten(resp_bere, &resp_bval);
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
+ "multisupplier_extop_StartNSDS50ReplicationRequest - Finished encoding payload\n");
+ }
+
if (is90) {
slapi_pblock_set(pb, SLAPI_EXT_OP_RET_OID, REPL_NSDS90_REPLICATION_RESPONSE_OID);
} else {
@@ -1006,7 +1189,7 @@ send_response:
* The situation is confused
*/
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "multisupplier_extop_StartNSDS50ReplicationRequest - "
- "already acquired replica: replica not ready (%d) (replica=%s)\n",
+ "already acquired replica: replica not ready (%d) (replica=%s)\n",
response, replica_get_name(r) ? replica_get_name(r) : "no name");
/*
@@ -1017,7 +1200,7 @@ send_response:
r_locking_conn = replica_get_locking_conn(r);
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "multisupplier_extop_StartNSDS50ReplicationRequest - "
- "already acquired replica: locking_conn=%" PRIu64 ", current connid=%" PRIu64 "\n",
+ "already acquired replica: locking_conn=%" PRIu64 ", current connid=%" PRIu64 "\n",
r_locking_conn, connid);
if ((r_locking_conn != ULONG_MAX) && (r_locking_conn == connid)) {
@@ -1033,7 +1216,7 @@ send_response:
* that the RA will restart a new session in a clear state
*/
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "multisupplier_extop_StartNSDS50ReplicationRequest - "
- "already acquired replica: disconnect conn=%" PRIu64 "\n",
+ "already acquired replica: disconnect conn=%" PRIu64 "\n",
connid);
slapi_disconnect_server(conn);
}
@@ -1212,6 +1395,10 @@ send_response:
if ((resp_bere = der_alloc()) == NULL) {
goto free_and_return;
}
+ if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
+ slapi_log_err(SLAPI_LOG_REPL, "multisupplier_extop_EndNSDS50ReplicationRequest",
+ "encoded response: %d\n", response);
+ }
ber_printf(resp_bere, "{e}", response);
ber_flatten(resp_bere, &resp_bval);
slapi_pblock_set(pb, SLAPI_EXT_OP_RET_OID, REPL_NSDS50_REPLICATION_RESPONSE_OID);
diff --git a/ldap/servers/slapd/slapi2runtime.c b/ldap/servers/slapd/slapi2runtime.c
index c957440dd..0ac6d7afd 100644
--- a/ldap/servers/slapd/slapi2runtime.c
+++ b/ldap/servers/slapd/slapi2runtime.c
@@ -88,7 +88,6 @@ slapi_lock_mutex(Slapi_Mutex *mutex)
inline int __attribute__((always_inline))
slapi_unlock_mutex(Slapi_Mutex *mutex)
{
- PR_ASSERT(mutex != NULL);
if (mutex == NULL || pthread_mutex_unlock((pthread_mutex_t *)mutex) != 0) {
return (0);
} else {
| 0 |
fe614b6a15395ecbd97d4c8b58fb38a476d526f2
|
389ds/389-ds-base
|
Ticket 48358 - Add new spec file
Description: Add the new properly named python-lib389.spec file
https://fedorahosted.org/389/ticket/48358
|
commit fe614b6a15395ecbd97d4c8b58fb38a476d526f2
Author: Mark Reynolds <[email protected]>
Date: Mon Dec 7 20:52:43 2015 -0500
Ticket 48358 - Add new spec file
Description: Add the new properly named python-lib389.spec file
https://fedorahosted.org/389/ticket/48358
diff --git a/src/lib389/python-lib389.spec b/src/lib389/python-lib389.spec
new file mode 100644
index 000000000..41af220f0
--- /dev/null
+++ b/src/lib389/python-lib389.spec
@@ -0,0 +1,50 @@
+Summary: A library for accessing, testing, and configuring the 389 Directory Server
+Name: python-lib389
+Version: 1.0.1
+Release: 1%{?dist}
+%global tarver %{version}-1
+Source0: http://www.port389.org/binaries/%{name}-%{tarver}.tar.bz2
+License: GPLv3+
+Group: Development/Libraries
+BuildArch: noarch
+Url: http://port389.org/docs/389ds/FAQ/upstream-test-framework.html
+BuildRequires: python2-devel, python-ldap, krb5-devel, python-setuptools
+Requires: pytest
+
+%{?python_provide:%python_provide python2-lib389}
+
+%description
+This module contains tools and libraries for accessing, testing,
+and configuring the 389 Directory Server.
+
+%prep
+%setup -q -n %{name}-%{tarver}
+
+%build
+CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build
+
+%install
+%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
+for file in $RPM_BUILD_ROOT%{python2_sitelib}/lib389/clitools/*.py; do
+ chmod a+x $file
+done
+
+%check
+%{__python2} setup.py test
+
+%files
+%license LICENSE
+%doc README
+%{python2_sitelib}/*
+
+%changelog
+* 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
+
+* Fri Dec 4 2015 Mark Reynolds <[email protected]> - 1.0.1-1
+- Renamed package to python-lib389, and simplified the spec file
+
+* Tue Dec 1 2015 Mark Reynolds <[email protected]> - 1.0.1-1
+- Bugzilla 1287846 - Submit lib389 python module to access the 389 DS
+
diff --git a/src/lib389/setup.cfg b/src/lib389/setup.cfg
index 62bdb21c5..b4982056c 100644
--- a/src/lib389/setup.cfg
+++ b/src/lib389/setup.cfg
@@ -1,3 +1,3 @@
[bdist_rpm]
-requires=python-ldap pytest python-krbV
+requires=python-ldap
diff --git a/src/lib389/setup.py b/src/lib389/setup.py
index ebae599e7..1c8a3129b 100644
--- a/src/lib389/setup.py
+++ b/src/lib389/setup.py
@@ -48,5 +48,5 @@ setup(
keywords='389 directory server test configure',
packages=find_packages(exclude=['tests*']),
- install_requires=['python-ldap', 'pytest', 'python-krbV'],
+ install_requires=['python-ldap'],
)
| 0 |
38d1b0a097c373ecb5d7f974a5d48b66b8fad72d
|
389ds/389-ds-base
|
Issue 50586 - lib389 - Fix DSEldif long line processing
Description: When dse.ldif has a very long line inthe attribute value,
it puts it to the next line and adds ' '.
We should process it correctly in lib389.
https://pagure.io/389-ds-base/issue/50586
Reviewed by: mreynolds, mhonek (Thanks!)
|
commit 38d1b0a097c373ecb5d7f974a5d48b66b8fad72d
Author: Simon Pichugin <[email protected]>
Date: Thu Sep 5 20:16:08 2019 +0200
Issue 50586 - lib389 - Fix DSEldif long line processing
Description: When dse.ldif has a very long line inthe attribute value,
it puts it to the next line and adds ' '.
We should process it correctly in lib389.
https://pagure.io/389-ds-base/issue/50586
Reviewed by: mreynolds, mhonek (Thanks!)
diff --git a/src/lib389/lib389/dseldif.py b/src/lib389/lib389/dseldif.py
index 719ba6be7..dfe3b91e2 100644
--- a/src/lib389/lib389/dseldif.py
+++ b/src/lib389/lib389/dseldif.py
@@ -31,11 +31,18 @@ class DSEldif(object):
self.path = os.path.join(ds_paths.config_dir, 'dse.ldif')
with open(self.path, 'r') as file_dse:
+ processed_line = ""
for line in file_dse.readlines():
- if line.startswith('dn'):
- self._contents.append(line.lower())
+ if not line.startswith(' '):
+ if processed_line:
+ self._contents.append(processed_line)
+
+ if line.startswith('dn:'):
+ processed_line = line.lower()
+ else:
+ processed_line = line
else:
- self._contents.append(line)
+ processed_line = processed_line[:-1] + line[1:]
def _update(self):
"""Update the dse.ldif with a new contents"""
@@ -148,4 +155,3 @@ class DSEldif(object):
self._instance.log.debug("During replace operation: {}".format(e))
self.add(entry_dn, attr, value)
self._update()
-
| 0 |
e8be545fb58f9f1d197eb4c0f27e1694a0232b83
|
389ds/389-ds-base
|
Issue 6368 - UI - fix regression with onChange parameters for new
settings on the access log page
Description:
The event and string parameters were switched for time format and log
format settings on the access log page
Relates: https://github.com/389ds/389-ds-base/issues/6368
Reviewed by: spichugi(Thanks!)
|
commit e8be545fb58f9f1d197eb4c0f27e1694a0232b83
Author: Mark Reynolds <[email protected]>
Date: Wed Dec 4 16:04:14 2024 -0500
Issue 6368 - UI - fix regression with onChange parameters for new
settings on the access log page
Description:
The event and string parameters were switched for time format and log
format settings on the access log page
Relates: https://github.com/389ds/389-ds-base/issues/6368
Reviewed by: spichugi(Thanks!)
diff --git a/src/cockpit/389-console/src/lib/server/accessLog.jsx b/src/cockpit/389-console/src/lib/server/accessLog.jsx
index b18b8e920..827029509 100644
--- a/src/cockpit/389-console/src/lib/server/accessLog.jsx
+++ b/src/cockpit/389-console/src/lib/server/accessLog.jsx
@@ -598,7 +598,7 @@ export class ServerAccessLog extends React.Component {
id="nsslapd-accesslog-time-format"
aria-describedby="horizontal-form-name-helper"
name="nsslapd-accesslog-time-format"
- onChange={(str, e) => {
+ onChange={(e, str) => {
this.handleChange(e, "settings");
}}
/>
@@ -611,7 +611,7 @@ export class ServerAccessLog extends React.Component {
<FormSelect
id="nsslapd-accesslog-log-format"
value={this.state['nsslapd-accesslog-log-format']}
- onChange={(str, e) => {
+ onChange={(e, str) => {
this.handleChange(e, "settings");
}}
aria-label="FormSelect Input"
@@ -652,7 +652,7 @@ export class ServerAccessLog extends React.Component {
<Td
select={{
rowIndex,
- onSelect: (_event, isSelecting) =>
+ onSelect: (_event, isSelecting) =>
this.handleOnSelect(_event, isSelecting, rowIndex),
isSelected: row.selected
}}
@@ -930,7 +930,7 @@ export class ServerAccessLog extends React.Component {
<TextContent>
<Text component={TextVariants.h3}>
{_("Access Log Settings")}
- <Button
+ <Button
variant="plain"
aria-label={_("Refresh log settings")}
onClick={() => {
| 0 |
04864e04feb254422d8c34f2d6f7238408bd82f3
|
389ds/389-ds-base
|
Issue 6753 - Port ticket 47640 test
Porting ticket 47640 test to dirsrvtests/tests/suites/betxns/betxn_test.py::test_linked_attributes_plugin.
Relates: #6753
Author: Lenka Doudova
Reviewer: Simon Pichugin
|
commit 04864e04feb254422d8c34f2d6f7238408bd82f3
Author: Lenka Doudova <[email protected]>
Date: Fri Jun 6 10:12:43 2025 +0200
Issue 6753 - Port ticket 47640 test
Porting ticket 47640 test to dirsrvtests/tests/suites/betxns/betxn_test.py::test_linked_attributes_plugin.
Relates: #6753
Author: Lenka Doudova
Reviewer: Simon Pichugin
diff --git a/dirsrvtests/tests/suites/betxns/betxn_test.py b/dirsrvtests/tests/suites/betxns/betxn_test.py
index 500c007c2..6a06aba1f 100644
--- a/dirsrvtests/tests/suites/betxns/betxn_test.py
+++ b/dirsrvtests/tests/suites/betxns/betxn_test.py
@@ -15,7 +15,8 @@ from lib389.topologies import topology_st
from lib389.plugins import (SevenBitCheckPlugin, AttributeUniquenessPlugin,
MemberOfPlugin, ManagedEntriesPlugin,
ReferentialIntegrityPlugin, MEPTemplates,
- MEPConfigs)
+ MEPConfigs, LinkedAttributesPlugin,
+ LinkedAttributesConfigs)
from lib389.plugins import MemberOfPlugin
from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES
from lib389.idm.organizationalunit import OrganizationalUnits
@@ -559,6 +560,50 @@ def test_revert_cache_noloop(topology_st, request):
memberof.replace('memberOfAutoAddOC', 'nsmemberof')
request.addfinalizer(fin)
+
+
+def test_linked_attributes_plugin(topology_st):
+ ''' Test that Linked Attributes Plugin does not allow to add a link entry
+ that does not exist
+
+ :id: 8ec17a8f-d331-4aff-ab80-1afbdf8d4404
+ :setup: Standalone instance
+ :steps:
+ 1. Enable Linked Attributes plugin
+ 2. Create a config entry for linked attributes plugin
+ 3. Create a user with extensibleObject objectClass
+ 4. Add a link entry to the user, but the linked entry does not exist
+ 5. Cleanup the entry, disable the plugin
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Raises UNWILLING_TO_PERFORM error
+ 5. Success
+ '''
+
+ # Enable Linked Attributes plugin
+ linkedattr = LinkedAttributesPlugin(topology_st.standalone)
+ linkedattr.enable()
+
+ # Add the linked attrs config entry
+ la_configs = LinkedAttributesConfigs(topology_st.standalone)
+ la_configs.create(properties={'cn': 'Manager Link',
+ 'linkType': 'seeAlso',
+ 'managedType': 'seeAlso'})
+
+ # Add an entry that has a link to an entry that does not exist
+ users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX)
+ manager = users.create_test_user(uid=999)
+ with pytest.raises(ldap.UNWILLING_TO_PERFORM):
+ manager.add('seeAlso', 'uid=user,dc=example,dc=com')
+
+ # Cleanup
+ manager.delete()
+ linkedattr.disable()
+ linkedattr.delete()
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
diff --git a/dirsrvtests/tests/tickets/ticket47640_test.py b/dirsrvtests/tests/tickets/ticket47640_test.py
deleted file mode 100644
index 996735f93..000000000
--- a/dirsrvtests/tests/tickets/ticket47640_test.py
+++ /dev/null
@@ -1,82 +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 pytest
-from lib389.tasks import *
-from lib389.utils import *
-from lib389.topologies import topology_st
-
-from lib389._constants import PLUGIN_LINKED_ATTRS, DEFAULT_SUFFIX
-
-# Skip on older versions
-pytestmark = [pytest.mark.tier2,
- pytest.mark.skipif(ds_is_older('1.3.4'), reason="Not implemented")]
-
-logging.getLogger(__name__).setLevel(logging.DEBUG)
-log = logging.getLogger(__name__)
-
-
-def test_ticket47640(topology_st):
- '''
- Linked Attrs Plugins - verify that if the plugin fails to update the link entry
- that the entire operation is aborted
- '''
-
- # 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.message['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.message['desc'])
- assert False
-
- # Add the plugin config entry
- try:
- topology_st.standalone.add_s(Entry(('cn=manager link,cn=Linked Attributes,cn=plugins,cn=config', {
- 'objectclass': 'top extensibleObject'.split(),
- 'cn': 'Manager Link',
- 'linkType': 'seeAlso',
- 'managedType': 'seeAlso'
- })))
- except ldap.LDAPError as e:
- log.fatal('Failed to add linked attr config entry: error ' + e.message['desc'])
- assert False
-
- # Add an entry who has a link to an entry that does not exist
- OP_REJECTED = False
- try:
- topology_st.standalone.add_s(Entry(('uid=manager,' + DEFAULT_SUFFIX, {
- 'objectclass': 'top extensibleObject'.split(),
- 'uid': 'manager',
- 'seeAlso': 'uid=user,dc=example,dc=com'
- })))
- except ldap.UNWILLING_TO_PERFORM:
- # Success
- log.info('Add operation correctly rejected.')
- OP_REJECTED = True
- except ldap.LDAPError as e:
- log.fatal('Add operation incorrectly rejected: error %s - ' +
- 'expected "unwilling to perform"' % e.message['desc'])
- assert False
- if not OP_REJECTED:
- log.fatal('Add operation incorrectly allowed')
- assert False
-
- log.info('Test complete')
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
| 0 |
ad35586f318300cd8027971a6e6bde72f3d716ca
|
389ds/389-ds-base
|
Ticket 66 - expand healthcheck for Directory Server
Bug Description: In order to aid admins, we should be able to offer
advice about the status of their servers.
Fix Description: This expands the healthcheck command to include
encryption and password options. It changes the command name (from
lint to healthcheck), and add's generic wrappers to run these
more easily.
https://pagure.io/lib389/issue/66
Author: wibrown
Review by: ilias95, spichugi (Thanks!)
|
commit ad35586f318300cd8027971a6e6bde72f3d716ca
Author: William Brown <[email protected]>
Date: Wed Jun 7 17:38:06 2017 +1000
Ticket 66 - expand healthcheck for Directory Server
Bug Description: In order to aid admins, we should be able to offer
advice about the status of their servers.
Fix Description: This expands the healthcheck command to include
encryption and password options. It changes the command name (from
lint to healthcheck), and add's generic wrappers to run these
more easily.
https://pagure.io/lib389/issue/66
Author: wibrown
Review by: ilias95, spichugi (Thanks!)
diff --git a/src/lib389/cli/dsconf b/src/lib389/cli/dsconf
index a114afbdd..168ecdfee 100755
--- a/src/lib389/cli/dsconf
+++ b/src/lib389/cli/dsconf
@@ -21,7 +21,7 @@ from lib389._constants import DN_CONFIG, DN_DM
from lib389.cli_conf import backend as cli_backend
from lib389.cli_conf import plugin as cli_plugin
from lib389.cli_conf import schema as cli_schema
-from lib389.cli_conf import lint as cli_lint
+from lib389.cli_conf import health as cli_health
from lib389.cli_conf.plugins import memberof as cli_memberof
from lib389.cli_base import disconnect_instance, connect_instance
@@ -62,7 +62,7 @@ if __name__ == '__main__':
cli_backend.create_parser(subparsers)
cli_schema.create_parser(subparsers)
- cli_lint.create_parser(subparsers)
+ cli_health.create_parser(subparsers)
cli_plugin.create_parser(subparsers)
cli_memberof.create_parser(subparsers)
diff --git a/src/lib389/cli/dsctl b/src/lib389/cli/dsctl
index bfaba4a13..fed1a9634 100755
--- a/src/lib389/cli/dsctl
+++ b/src/lib389/cli/dsctl
@@ -21,7 +21,7 @@ from lib389.cli_ctl import instance as cli_instance
from lib389.cli_ctl import dbtasks as cli_dbtasks
from lib389.cli_base import disconnect_instance
-log = logging.getLogger("dsadm")
+log = logging.getLogger("dsctl")
if __name__ == '__main__':
diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py
index c307cf2c4..361b479f6 100644
--- a/src/lib389/lib389/_mapped_object.py
+++ b/src/lib389/lib389/_mapped_object.py
@@ -96,6 +96,7 @@ class DSLdapObject(DSLogging):
self._must_attributes = None
# attributes, we don't want to compare
self._compare_exclude = ['entryid']
+ self._lint_functions = None
def __unicode__(self):
val = self._dn
@@ -463,8 +464,14 @@ class DSLdapObject(DSLogging):
You should return an array of these dicts, on None if there are no errors.
"""
- return None
-
+ if not self._lint_functions:
+ return None
+ results = []
+ for fn in self._lint_functions:
+ result = fn()
+ if result:
+ results.append(result)
+ return results
# A challenge of this, is how do we manage indexes? They have two naming attribunes....
diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py
index aa540e56b..1affe1353 100644
--- a/src/lib389/lib389/backend.py
+++ b/src/lib389/lib389/backend.py
@@ -24,6 +24,8 @@ from lib389.monitor import MonitorBackend
# This is for sample entry creation.
from lib389.configurations import get_sample_entries
+from lib389.lint import DSBLE0001
+
class BackendLegacy(object):
proxied_methods = 'search_s getEntry'.split()
@@ -391,6 +393,7 @@ class Backend(DSLdapObject):
self._must_attributes = ['nsslapd-suffix', 'cn']
self._create_objectclasses = ['top', 'extensibleObject', BACKEND_OBJECTCLASS_VALUE]
self._protected = False
+ self._lint_functions = [self._lint_mappingtree]
# Check if a mapping tree for this suffix exists.
self._mts = MappingTrees(self._instance)
@@ -480,7 +483,7 @@ class Backend(DSLdapObject):
# The super will actually delete ourselves.
super(Backend, self).delete()
- def lint(self):
+ def _lint_mappingtree(self):
"""
Backend lint
@@ -488,48 +491,18 @@ class Backend(DSLdapObject):
* missing mapping tree entries for the backend
* missing indcies if we are local and have log access?
"""
- results = []
- # return ["Hello!",]
# Check for the missing mapping tree.
suffix = ensure_str(self.get_attr_val('nsslapd-suffix'))
bename = self.get_attr_val('cn')
- # This should change to the mapping tree objects later ....
try:
mt = self._mts.get(suffix)
if mt.get_attr_val('nsslapd-backend') != ensure_bytes(bename) and mt.get_attr_val('nsslapd-state') != ensure_bytes('backend') :
raise ldap.NO_SUCH_OBJECT("We have a matching suffix, but not a backend or correct database name.")
except ldap.NO_SUCH_OBJECT:
- results.append({
- 'dsle': 'DSBLE0001',
- 'severity': 'MEDIUM',
- 'items' : [bename, ],
- 'detail' : """
-This backend may be missing the correct mapping tree references. Mapping Trees allow
-the directory server to determine which backend an operation is routed to in the
-abscence of other information. This is extremely important for correct functioning
-of LDAP ADD for example.
-
-A correct Mapping tree for this backend must contain the suffix name, the database name
-and be a backend type. IE:
-
-cn=o3Dexample,cn=mapping tree,cn=config
-cn: o=example
-nsslapd-backend: userRoot
-nsslapd-state: backend
-objectClass: top
-objectClass: extensibleObject
-objectClass: nsMappingTree
-
- """,
- 'fix' : """
-Either you need to create the mapping tree, or you need to repair the related
-mapping tree. You will need to do this by hand by editing cn=config, or stopping
-the instance and editing dse.ldif.
- """
- })
- if len(results) == 0:
- return None
- return results
+ result = DSBLE0001
+ result['items'] = [bename, ]
+ return result
+ return None
def get_monitor(self):
monitor = MonitorBackend(instance=self._instance, dn= "cn=monitor,%s" % self._dn, batch=self._batch)
diff --git a/src/lib389/lib389/cli_conf/lint.py b/src/lib389/lib389/cli_conf/health.py
similarity index 52%
rename from src/lib389/lib389/cli_conf/lint.py
rename to src/lib389/lib389/cli_conf/health.py
index 31c5cf0b9..02aef146b 100644
--- a/src/lib389/lib389/cli_conf/lint.py
+++ b/src/lib389/lib389/cli_conf/health.py
@@ -9,12 +9,20 @@
import argparse
from lib389.backend import Backend, Backends
+from lib389.config import Encryption, Config
-LINT_OBJECTS = [
- Backends
+# These get all instances, then check them all.
+CHECK_MANY_OBJECTS = [
+ Backends,
]
-def _format_lint_output(log, result):
+# These get single instances and check them.
+CHECK_OBJECTS = [
+ Config,
+ Encryption,
+]
+
+def _format_check_output(log, result):
log.info("==== DS Lint Error: %s ====" % result['dsle'])
log.info(" Severity: %s " % result['severity'])
log.info(" Affects:")
@@ -25,25 +33,27 @@ def _format_lint_output(log, result):
log.info(" Resolution:")
log.info(result['fix'])
-def lint_run(inst, basedn, log, args):
+def health_check_run(inst, basedn, log, args):
log.info("Beginning lint report, this could take a while ...")
report = []
- for lo in LINT_OBJECTS:
+ for lo in CHECK_MANY_OBJECTS:
log.info("Checking %s ..." % lo.__name__)
lo_inst = lo(inst)
for clo in lo_inst.list():
result = clo.lint()
if result is not None:
report += result
- log.info("Lint complete!")
+ for lo in CHECK_OBJECTS:
+ log.info("Checking %s ..." % lo.__name__)
+ lo_inst = lo(inst)
+ result = lo_inst.lint()
+ if result is not None:
+ report += result
+ log.info("Healthcheck complete!")
for item in report:
- _format_lint_output(log, item)
+ _format_check_output(log, item)
def create_parser(subparsers):
- lint_parser = subparsers.add_parser('lint', help="Check for configuration issues in your Directory Server instance.")
-
- subcommands = lint_parser.add_subparsers(help="action")
-
- run_lint_parser = subcommands.add_parser('run', help="Run a lint report on your Directory Server instance. This is a safe, Read Only operation.")
- run_lint_parser.set_defaults(func=lint_run)
+ run_healthcheck_parser = subparsers.add_parser('healthcheck', help="Run a healthcheck report on your Directory Server instance. This is a safe, read only operation.")
+ run_healthcheck_parser.set_defaults(func=health_check_run)
diff --git a/src/lib389/lib389/config.py b/src/lib389/lib389/config.py
index 01b731ead..07232141e 100644
--- a/src/lib389/lib389/config.py
+++ b/src/lib389/lib389/config.py
@@ -20,7 +20,9 @@ import ldap
from lib389._constants import *
from lib389 import Entry
from lib389._mapped_object import DSLdapObject
+from lib389.utils import ensure_bytes, ensure_str
+from lib389.lint import DSCLE0001, DSCLE0002, DSELE0001
class Config(DSLdapObject):
"""
@@ -52,6 +54,7 @@ class Config(DSLdapObject):
]
self._compare_exclude = self._compare_exclude + config_compare_exclude
self._rdn_attribute = 'cn'
+ self._lint_functions = [self._lint_hr_timestamp, self._lint_passwordscheme]
@property
def dn(self):
@@ -180,6 +183,21 @@ class Config(DSLdapObject):
fields = 'nsslapd-security nsslapd-ssl-check-hostname'.split()
return self._instance.getEntry(DN_CONFIG, attrlist=fields)
+ def _lint_hr_timestamp(self):
+ hr_timestamp = self.get_attr_val('nsslapd-logging-hr-timestamps-enabled')
+ if ensure_bytes('on') != hr_timestamp:
+ return DSCLE0001
+ pass # nsslapd-logging-hr-timestamps-enabled
+
+ def _lint_passwordscheme(self):
+ allowed_schemes = ['SSHA512', 'PBKDF2_SHA256']
+ password_scheme = self.get_attr_val('passwordStorageScheme')
+ root_scheme = self.get_attr_val('nsslapd-rootpwstoragescheme')
+ u_password_scheme = ensure_str(password_scheme)
+ u_root_scheme = ensure_str(root_scheme)
+ if u_root_scheme not in allowed_schemes or u_password_scheme not in allowed_schemes:
+ return DSCLE0002
+ return None
class Encryption(DSLdapObject):
"""
@@ -196,12 +214,19 @@ class Encryption(DSLdapObject):
self._rdn_attribute = 'cn'
self._must_attributes = ['cn']
self._protected = True
+ self._lint_functions = [self._lint_check_tls_version]
def create(self, rdn=None, properties={'cn': 'encryption', 'nsSSLClientAuth': 'allowed'}):
if rdn is not None:
self._log.debug("dn on cn=encryption is not None. This is a mistake.")
super(Encryption, self).create(properties=properties)
+ def _lint_check_tls_version(self):
+ tls_min = self.get_attr_val('sslVersionMin');
+ if tls_min < ensure_bytes('TLS1.1'):
+ return DSELE0001
+ return None
+
class RSA(DSLdapObject):
"""
Manage the "cn=RSA,cn=encryption,cn=config" object
diff --git a/src/lib389/lib389/lint.py b/src/lib389/lib389/lint.py
new file mode 100644
index 000000000..404cff8a7
--- /dev/null
+++ b/src/lib389/lib389/lint.py
@@ -0,0 +1,111 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+# A set of constants defining the lint errors we can return to a caller.
+# as well as some functions to help process them.
+
+
+DSBLE0001 = {
+ 'dsle': 'DSBLE0001',
+ 'severity': 'MEDIUM',
+ 'items' : [],
+ 'detail' : """
+This backend may be missing the correct mapping tree references. Mapping Trees allow
+the directory server to determine which backend an operation is routed to in the
+abscence of other information. This is extremely important for correct functioning
+of LDAP ADD for example.
+
+A correct Mapping tree for this backend must contain the suffix name, the database name
+and be a backend type. IE:
+
+cn=o3Dexample,cn=mapping tree,cn=config
+cn: o=example
+nsslapd-backend: userRoot
+nsslapd-state: backend
+objectClass: top
+objectClass: extensibleObject
+objectClass: nsMappingTree
+
+ """,
+ 'fix' : """
+Either you need to create the mapping tree, or you need to repair the related
+mapping tree. You will need to do this by hand by editing cn=config, or stopping
+the instance and editing dse.ldif.
+ """
+}
+
+DSCLE0001 = {
+ 'dsle' : 'DSCLE0001',
+ 'severity' : 'LOW',
+ 'items': ['cn=config', ],
+ 'detail' : """
+nsslapd-logging-hr-timestamps-enabled changes the log format in directory server from
+
+[07/Jun/2017:17:15:58 +1000]
+
+to
+
+[07/Jun/2017:17:15:58.716117312 +1000]
+
+This actually provides a performance improvement. Additionally, this setting will be
+removed in a future release.
+ """,
+ 'fix' : """
+Set nsslapd-logging-hr-timestamps-enabled to on.
+ """
+}
+
+DSCLE0002 = {
+ 'dsle': 'DSCLE0002',
+ 'severity': 'HIGH',
+ 'items' : ['cn=config', ],
+ 'detail' : """
+Password storage schemes in Directory Server define how passwords are hashed via a
+one-way mathematical function for storage. Knowing the hash it is difficult to gain
+the input, but knowing the input you can easily compare the hash.
+
+Many hashes are well known for cryptograhpic verification properties, but are
+designed to be *fast* to validate. This is the opposite of what we desire for password
+storage. In the unlikely event of a disclosure, you want hashes to be *difficult* to
+verify, as this adds a cost of work to an attacker.
+
+In Directory Server, we offer one hash suitable for this (PBKDF2_SHA256) and one hash
+for "legacy" support (SSHA512).
+
+Your configuration does not use these for password storage or the root password storage
+scheme.
+ """,
+ 'fix': """
+Perform a configuration reset of the values:
+
+passwordStorageScheme
+nsslapd-rootpwstoragescheme
+
+IE, stop Directory Server, and in dse.ldif delete these two lines. When Directory Server
+is started, they will use the server provided defaults that are secure.
+ """
+}
+
+DSELE0001 = {
+ 'dsle': 'DSELE0001',
+ 'severity': 'MEDIUM',
+ 'items' : ['cn=encryption,cn=config', ],
+ 'detail': """
+This Directory Server may not be using strong TLS protocol versions. TLS1.0 is known to
+have a number of issues with the protocol. Please see:
+
+https://tools.ietf.org/html/rfc7457
+
+It is advised you set this value to the maximum possible.
+ """,
+ 'fix' : """
+set cn=encryption,cn=config sslVersionMin to a version greater than TLS1.0
+ """
+}
+
+
diff --git a/src/lib389/lib389/tests/healthcheck_test.py b/src/lib389/lib389/tests/healthcheck_test.py
new file mode 100644
index 000000000..94711eb30
--- /dev/null
+++ b/src/lib389/lib389/tests/healthcheck_test.py
@@ -0,0 +1,42 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+
+import pytest
+import ldap
+
+from lib389.topologies import topology_st
+
+from lib389.lint import *
+
+def test_hc_backend_mt(topology_st):
+ mt = topology_st.standalone.mappingtrees.get('userRoot')
+ # We have to remove the MT from a backend.
+ mt.delete()
+ be = topology_st.standalone.backends.get('userRoot')
+ result = be._lint_mappingtree()
+ # We have to check this by name, not object, as the result changes
+ # the affected dn in the result.
+ assert result['dsle'] == 'DSBLE0001'
+
+def test_hc_encryption(topology_st):
+ topology_st.standalone.encryption.set('sslVersionMin', 'TLS1.0')
+ result = topology_st.standalone.encryption._lint_check_tls_version()
+ assert result == DSELE0001
+
+def test_hc_config(topology_st):
+ # Check the HR timestamp
+ topology_st.standalone.config.set('nsslapd-logging-hr-timestamps-enabled', 'off')
+ result = topology_st.standalone.config._lint_hr_timestamp()
+ assert result == DSCLE0001
+
+ # Check the password scheme check.
+ topology_st.standalone.config.set('passwordStorageScheme', 'SSHA')
+ result = topology_st.standalone.config._lint_passwordscheme()
+ assert result == DSCLE0002
+
| 0 |
e00e3e7dd31bb247eade539e21064541153e43db
|
389ds/389-ds-base
|
bump version to 1.3.2.pre.a1
|
commit e00e3e7dd31bb247eade539e21064541153e43db
Author: Noriko Hosoi <[email protected]>
Date: Thu Apr 11 10:28:33 2013 -0700
bump version to 1.3.2.pre.a1
diff --git a/VERSION.sh b/VERSION.sh
index d9ddd3257..7b914db38 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=3
-VERSION_MAINT=1
+VERSION_MAINT=2
# if this is a PRERELEASE, set VERSION_PREREL
# otherwise, comment it out
# be sure to include the dot prefix in the prerel
| 0 |
fc29aef3cd18c9eb68dbb9a45474e0fea9f6b4d1
|
389ds/389-ds-base
|
Resolves: #468248
Summary: LDAPI: when nsslapd-ldapiautodnsuffix doesn't exist - Bind is incorrect
Description:
- introducing --enable-auto-dn-suffix option to configure (disabled by default)
- building the auto-dn-suffix code only when the option is set
|
commit fc29aef3cd18c9eb68dbb9a45474e0fea9f6b4d1
Author: Noriko Hosoi <[email protected]>
Date: Fri Oct 24 00:21:18 2008 +0000
Resolves: #468248
Summary: LDAPI: when nsslapd-ldapiautodnsuffix doesn't exist - Bind is incorrect
Description:
- introducing --enable-auto-dn-suffix option to configure (disabled by default)
- building the auto-dn-suffix code only when the option is set
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 528ebadd3..74e382b79 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -252,7 +252,9 @@ int config_set_ldapi_map_entries( const char *attrname, char *value, char *error
int config_set_ldapi_uidnumber_type( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_gidnumber_type( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_search_base_dn( const char *attrname, char *value, char *errorbuf, int apply );
+#if defined(ENABLE_AUTO_DN_SUFFIX)
int config_set_ldapi_auto_dn_suffix( const char *attrname, char *value, char *errorbuf, int apply );
+#endif
int config_set_srvtab( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply );
@@ -365,7 +367,9 @@ int config_get_ldapi_map_entries();
char *config_get_ldapi_uidnumber_type();
char *config_get_ldapi_gidnumber_type();
char *config_get_ldapi_search_base_dn();
+#if defined(ENABLE_AUTO_DN_SUFFIX)
char *config_get_ldapi_auto_dn_suffix();
+#endif
char *config_get_srvtab();
int config_get_sizelimit();
char *config_get_pw_storagescheme();
| 0 |
ef3595d09bd96ac2fb9c2e1135abc6d91d824eb5
|
389ds/389-ds-base
|
Ticket 49160 - Fix sds benchmark and copyright
Bug Description: THe sds code had the incorrect copyright, and
the benchmark did not work with the new i686 fixes
Fix Description: Fix the copyright to redhat and fix the test
to use uint64_t pointers.
https://pagure.io/389-ds-base/issue/49160
Author: wibrown
Review by: mreynolds (Thanks)
|
commit ef3595d09bd96ac2fb9c2e1135abc6d91d824eb5
Author: William Brown <[email protected]>
Date: Sat Mar 4 09:30:35 2017 +1000
Ticket 49160 - Fix sds benchmark and copyright
Bug Description: THe sds code had the incorrect copyright, and
the benchmark did not work with the new i686 fixes
Fix Description: Fix the copyright to redhat and fix the test
to use uint64_t pointers.
https://pagure.io/389-ds-base/issue/49160
Author: wibrown
Review by: mreynolds (Thanks)
diff --git a/src/libsds/include/sds.h b/src/libsds/include/sds.h
index 31507a73c..1b0dedefb 100644
--- a/src/libsds/include/sds.h
+++ b/src/libsds/include/sds.h
@@ -1,8 +1,9 @@
/* BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -394,39 +395,58 @@ typedef struct _sds_bptree_transaction {
* in the B+Tree and COW B+Tree. A signifigant amount of testing went into the
* tuning of this value for best performance.
*/
-#define SDS_BPTREE_DEFAULT_CAPACITY 5
+#define SDS_BPTREE_DEFAULT_CAPACITY 3
/**
* SDS_BPTREE_HALF_CAPACITY 3 is pre-calculated as "ceiling(default capacity / 2)".
* This is used to assert when node splits and merges should be taken.
*/
-#define SDS_BPTREE_HALF_CAPACITY 3
+#define SDS_BPTREE_HALF_CAPACITY 2
/**
* SDS_BPTREE_BRANCH 6 indicates that each node may potentially have up to 6 child
* nodes. This yields a broad tree, that requires fewer cache misses to travese
* (despite the higher number of comparisons to search).
*/
-#define SDS_BPTREE_BRANCH 6
+#define SDS_BPTREE_BRANCH 4
/**
* This is the core of the B+Tree structures. This node represents the branches
- * and leaves of the structure. It is 128 bytes, which fits on two cachelines.
- * Thanks to modern prediction strategies, this is faster than a 64 byte struct
- *, and yields the best performance in real tests.
+ * and leaves of the structure.
*/
typedef struct _sds_bptree_node {
+#ifdef DEBUG
/**
- * checksum of the structure data to detect errors.
+ * checksum of the structure data to detect errors. Must be the first element
+ * in the struct.
*/
uint32_t checksum;
+#endif
+ /**
+ * Statically sized array of pointers to the keys of this structure.
+ */
+ void *keys[SDS_BPTREE_DEFAULT_CAPACITY];
+ /**
+ * Statically sized array of pointers to values. This is tagged by the level
+ * flag. If level is 0, this is a set of values that have been inserted
+ * by the consumer. If the level is > 0, this is the pointers to further
+ * node structs.
+ *
+ * In a leaf, this is [value, value, value, value, value, link -> ]
+ *
+ * In a non-leaf, this is [link, link, link, link, link, link]
+ */
+ void *values[SDS_BPTREE_BRANCH];
/**
* The number of values currently stored in this structure.
*/
- uint16_t item_count;
+ uint32_t item_count;
/**
* This number of "rows" above the leaves this node is. 0 represents a true
* leaf node, anything greater is a branch.
*/
- uint64_t level;
+ uint32_t level;
+ /* Put these last because they are only used in the insert / delete path, not the search.
+ * This way the keys and values are always in the cache associated with the ptr.
+ */
/**
* The id of the transaction that created this node. This is used so that
* within a transaction, we don't double copy values if we already copied
@@ -438,21 +458,6 @@ typedef struct _sds_bptree_node {
* list during each insertion (by a large factor).
*/
struct _sds_bptree_node *parent;
- /**
- * Statically sized array of pointers to the keys of this structure.
- */
- void *keys[SDS_BPTREE_DEFAULT_CAPACITY];
- /**
- * Statically sized array of pointers to values. This is tagged by the level
- * flag. If level is 0, this is a set of values that have been inserted
- * by the consumer. If the level is > 0, this is the pointers to further
- * node structs.
- *
- * In a leaf, this is [value, value, value, value, value, link -> ]
- *
- * In a non-leaf, this is [link, link, link, link, link, link]
- */
- void *values[SDS_BPTREE_BRANCH];
} sds_bptree_node;
/**
diff --git a/src/libsds/sds/bpt/bpt.c b/src/libsds/sds/bpt/bpt.c
index e20d0c58e..6756ef01b 100644
--- a/src/libsds/sds/bpt/bpt.c
+++ b/src/libsds/sds/bpt/bpt.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt/bpt.h b/src/libsds/sds/bpt/bpt.h
index 6c429f789..712213b2a 100644
--- a/src/libsds/sds/bpt/bpt.h
+++ b/src/libsds/sds/bpt/bpt.h
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt/common.c b/src/libsds/sds/bpt/common.c
index 05b748eba..dcfecae2c 100644
--- a/src/libsds/sds/bpt/common.c
+++ b/src/libsds/sds/bpt/common.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -20,7 +21,7 @@ sds_bptree_node_create() {
node->txn_id = 0;
#ifdef DEBUG
- printf("sds_bptree_node_create: Creating node_%p item_count=%d\n", node, node->item_count);
+ sds_log("sds_bptree_node_create", "Creating node_%p item_count=%d\n", node, node->item_count);
#endif
return node;
@@ -97,7 +98,7 @@ sds_bptree_node_node_index(sds_bptree_node *parent, sds_bptree_node *child) {
void
sds_bptree_node_node_replace(sds_bptree_node *target_node, sds_bptree_node *origin_node, sds_bptree_node *replace_node) {
#ifdef DEBUG
- printf("sds_bptree_node_node_replace: Replace node_%p to overwrite node_%p in node_%p\n", origin_node, replace_node, target_node);
+ sds_log("sds_bptree_node_node_replace", "Replace node_%p to overwrite node_%p in node_%p\n", origin_node, replace_node, target_node);
#endif
size_t index = sds_bptree_node_node_index(target_node, origin_node);
target_node->values[index] = replace_node;
@@ -468,7 +469,12 @@ sds_bptree_root_insert(sds_bptree_instance *binst, sds_bptree_node *left_node, s
sds_log("sds_bptree_root_insert", "left_node %p, key %d, right_node %p", left_node, key, right_node);
#endif
sds_bptree_node *root_node = sds_bptree_node_create();
- root_node->level = left_node->level + 1;
+ /* On non debug, we only need to know if this is a leaf or not. */
+ if (left_node->level == 0) {
+ root_node->level = 1;
+ } else {
+ root_node->level = left_node->level;
+ }
/* Is already duplicated */
root_node->keys[0] = key;
diff --git a/src/libsds/sds/bpt/list.c b/src/libsds/sds/bpt/list.c
index de7c9b388..b89aed6fa 100644
--- a/src/libsds/sds/bpt/list.c
+++ b/src/libsds/sds/bpt/list.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt/map.c b/src/libsds/sds/bpt/map.c
index 4205aa565..4ba340eab 100644
--- a/src/libsds/sds/bpt/map.c
+++ b/src/libsds/sds/bpt/map.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -90,7 +91,7 @@ sds_bptree_verify_node(sds_bptree_instance *binst, sds_bptree_node *node) {
for (size_t i = 0; i < node->item_count; i++) {
if (node->keys[i] == NULL)
{
- printf("%d \n", node->item_count);
+ sds_log("sds_bptree_verify_node", "%d \n", node->item_count);
return SDS_INVALID_KEY;
}
@@ -286,7 +287,7 @@ sds_node_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bptree_n
return SDS_INVALID_NODE;
}
// Given the node write it out as:
- fprintf(fp, "subgraph c%"PRIu64" { \n rank=\"same\";\n", node->level);
+ fprintf(fp, "subgraph c%"PRIu32" { \n rank=\"same\";\n", node->level);
fprintf(fp, " node_%p [label =\" { node=%p items=%d txn=%"PRIu64" parent=%p | { <f0> ", node, node, node->item_count, node->txn_id, node->parent );
for (size_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) {
fprintf(fp, "| %" PRIu64 " | <f%"PRIu64"> ", (uint64_t)node->keys[i], i + 1 );
diff --git a/src/libsds/sds/bpt/search.c b/src/libsds/sds/bpt/search.c
index f406bcc4e..e60f25905 100644
--- a/src/libsds/sds/bpt/search.c
+++ b/src/libsds/sds/bpt/search.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt/set.c b/src/libsds/sds/bpt/set.c
index 50f442629..2319ac4e6 100644
--- a/src/libsds/sds/bpt/set.c
+++ b/src/libsds/sds/bpt/set.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt/verify.c b/src/libsds/sds/bpt/verify.c
index b9ddc12ee..085083a0d 100644
--- a/src/libsds/sds/bpt/verify.c
+++ b/src/libsds/sds/bpt/verify.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt_cow/atomic.c b/src/libsds/sds/bpt_cow/atomic.c
index 63bb645e6..e4dbe4fc2 100644
--- a/src/libsds/sds/bpt_cow/atomic.c
+++ b/src/libsds/sds/bpt_cow/atomic.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt_cow/bpt_cow.c b/src/libsds/sds/bpt_cow/bpt_cow.c
index 148923985..7bcf03001 100644
--- a/src/libsds/sds/bpt_cow/bpt_cow.c
+++ b/src/libsds/sds/bpt_cow/bpt_cow.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -511,7 +512,7 @@ sds_node_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bptree_n
return SDS_INVALID_NODE;
}
// Given the node write it out as:
- fprintf(fp, "subgraph c%"PRIu64" { \n rank=\"same\";\n", node->level);
+ fprintf(fp, "subgraph c%"PRIu32" { \n rank=\"same\";\n", node->level);
fprintf(fp, " node_%p [label =\" { node=%p items=%d txn=%"PRIu64" parent=%p | { <f0> ", node, node, node->item_count, node->txn_id, node->parent );
for (size_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) {
fprintf(fp, "| %" PRIu64 " | <f%"PRIu64"> ", (uint64_t)node->keys[i], i + 1 );
diff --git a/src/libsds/sds/bpt_cow/bpt_cow.h b/src/libsds/sds/bpt_cow/bpt_cow.h
index 4c0adc02f..00c8f7727 100644
--- a/src/libsds/sds/bpt_cow/bpt_cow.h
+++ b/src/libsds/sds/bpt_cow/bpt_cow.h
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt_cow/delete.c b/src/libsds/sds/bpt_cow/delete.c
index d39a836e3..32307f8dd 100644
--- a/src/libsds/sds/bpt_cow/delete.c
+++ b/src/libsds/sds/bpt_cow/delete.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt_cow/insert.c b/src/libsds/sds/bpt_cow/insert.c
index 912ab0a6d..4fe9effbb 100644
--- a/src/libsds/sds/bpt_cow/insert.c
+++ b/src/libsds/sds/bpt_cow/insert.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -16,10 +17,11 @@ sds_bptree_cow_root_insert(sds_bptree_transaction *btxn, sds_bptree_node *left_n
#endif
// Just make the new root, add the nodes, and update the root in the txn.
sds_bptree_node *root_node = sds_bptree_cow_node_create(btxn);
- root_node->level = left_node->level + 1;
-#ifdef DEBUG
- sds_log("sds_bptree_cow_root_insert", "New root level %d", root_node->level);
-#endif
+ if (left_node->level == 0) {
+ root_node->level = 1;
+ } else {
+ root_node->level = left_node->level;
+ }
root_node->keys[0] = key;
root_node->values[0] = (void *)left_node;
root_node->values[1] = (void *)right_node;
diff --git a/src/libsds/sds/bpt_cow/node.c b/src/libsds/sds/bpt_cow/node.c
index 3fec40bdb..648f6ea0c 100644
--- a/src/libsds/sds/bpt_cow/node.c
+++ b/src/libsds/sds/bpt_cow/node.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -10,17 +11,10 @@
#ifdef DEBUG
static sds_result
-sds_bptree_cow_node_path_verify(sds_bptree_transaction *btxn, sds_bptree_node *old_node, sds_bptree_node *node) {
+sds_bptree_cow_node_path_verify(sds_bptree_transaction *btxn, sds_bptree_node *node) {
// Verify that the node has a valid parent path back to the root!
- sds_bptree_node *boom = NULL;
- uint64_t level = old_node->level;
sds_bptree_node *target_node = node;
while (target_node->parent != NULL) {
- if (target_node->level != level) {
- sds_log("sds_bptree_cow_node_path_verify", "node_%p should be level %d, is %d", target_node, level, target_node->level);
- boom->level = 0xffffffff;
- }
- level = level + 1;
target_node = target_node->parent;
}
if (btxn->root != target_node) {
@@ -84,8 +78,8 @@ sds_bptree_cow_node_clone(sds_bptree_transaction *btxn, sds_bptree_node *node) {
sds_bptree_node_list_push(&(btxn->created), clone_node);
#ifdef DEBUG
- printf("sds_bptree_cow_node_clone: Cloning node_%p item_count=%d --> clone node_%p\n", node, node->item_count, clone_node);
- printf("sds_bptree_cow_node_clone: txn_%p tentatively owns node_%p for cleaning\n", btxn->parent_txn, node);
+ sds_log("sds_bptree_cow_node_clone", "Cloning node_%p item_count=%d --> clone node_%p\n", node, node->item_count, clone_node);
+ sds_log("sds_bptree_cow_node_clone", "txn_%p tentatively owns node_%p for cleaning\n", btxn->parent_txn, node);
#endif
return clone_node;
@@ -109,7 +103,7 @@ static void
sds_bptree_cow_branch_clone(sds_bptree_transaction *btxn, sds_bptree_node *origin_node, sds_bptree_node *clone_node) {
#ifdef DEBUG
- printf("sds_bptree_cow_branch_clone: Cloning branch from node_%p\n", clone_node);
+ sds_log("sds_bptree_cow_branch_clone", "Cloning branch from node_%p\n", clone_node);
#endif
// Right, we have now cloned the node. We need to walk up the tree and clone
// all the branches that path to us.
@@ -129,7 +123,7 @@ sds_bptree_cow_branch_clone(sds_bptree_transaction *btxn, sds_bptree_node *origi
// TODO: This probably needs to update csums of the nodes along the branch.
#ifdef DEBUG
- printf("sds_bptree_cow_branch_clone: Branch parent node_%p already within txn, finishing...\n", parent_node);
+ sds_log("sds_bptree_cow_branch_clone", "Branch parent node_%p already within txn, finishing...\n", parent_node);
if (btxn->bi->offline_checksumming) {
// Update this becuase we are updating the owned node lists.
sds_bptree_crc32c_update_node(parent_node);
@@ -141,7 +135,7 @@ sds_bptree_cow_branch_clone(sds_bptree_transaction *btxn, sds_bptree_node *origi
// Is the parent node NOT in this txn?
// We need to clone the parent, and then replace ourselves in it ....
#ifdef DEBUG
- printf("sds_bptree_cow_branch_clone: Branch parent node_%p NOT within txn, cloning...\n", parent_node);
+ sds_log("sds_bptree_cow_branch_clone", "Branch parent node_%p NOT within txn, cloning...\n", parent_node);
#endif
// This is actually the important part!
parent_clone_node = sds_bptree_cow_node_clone(btxn, parent_node);
@@ -167,7 +161,7 @@ sds_bptree_cow_branch_clone(sds_bptree_transaction *btxn, sds_bptree_node *origi
// We have hit the root, update the root.
// Origin is root, update the txn root.
#ifdef DEBUG
- printf("sds_bptree_cow_branch_clone: Updating txn_%p root from node_%p to node_%p\n", btxn, btxn->root, former_clone_node);
+ sds_log("sds_bptree_cow_branch_clone", "Updating txn_%p root from node_%p to node_%p\n", btxn, btxn->root, former_clone_node);
#endif
btxn->root = former_clone_node;
}
@@ -201,7 +195,7 @@ sds_bptree_cow_node_prepare(sds_bptree_transaction *btxn, sds_bptree_node *node)
result_node = clone_node;
}
#ifdef DEBUG
- if (sds_bptree_cow_node_path_verify(btxn, node, result_node)!= SDS_SUCCESS) {
+ if (sds_bptree_cow_node_path_verify(btxn, result_node)!= SDS_SUCCESS) {
sds_log("sds_bptree_cow_node_prepare", "!!! Invalid path from cow_node to root!");
return NULL;
}
@@ -216,7 +210,8 @@ sds_bptree_cow_node_create(sds_bptree_transaction *btxn) {
sds_bptree_node *node = sds_memalign(sizeof(sds_bptree_node), SDS_CACHE_ALIGNMENT);
// Without memset, we need to null the max link in a value
node->values[SDS_BPTREE_DEFAULT_CAPACITY] = NULL;
- node->level = 0xFFFFFFFF;
+ /* On cow, this value is over-written */
+ node->level = 0xFFFF;
node->item_count = 0;
node->parent = NULL;
node->txn_id = btxn->txn_id;
@@ -228,7 +223,7 @@ sds_bptree_cow_node_create(sds_bptree_transaction *btxn) {
// Update this becuase we are updating the created node lists.
sds_bptree_crc32c_update_btxn(btxn);
}
- printf("sds_bptree_cow_node_create: Creating node_%p item_count=%d\n", node, node->item_count);
+ sds_log("sds_bptree_cow_node_create", "Creating node_%p item_count=%d\n", node, node->item_count);
#endif
return node;
diff --git a/src/libsds/sds/bpt_cow/search.c b/src/libsds/sds/bpt_cow/search.c
index 1dc312be4..0b315fba5 100644
--- a/src/libsds/sds/bpt_cow/search.c
+++ b/src/libsds/sds/bpt_cow/search.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt_cow/txn.c b/src/libsds/sds/bpt_cow/txn.c
index 676a41fb3..6dafa8bfd 100644
--- a/src/libsds/sds/bpt_cow/txn.c
+++ b/src/libsds/sds/bpt_cow/txn.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/bpt_cow/verify.c b/src/libsds/sds/bpt_cow/verify.c
index b6eba517c..b12cb77d9 100644
--- a/src/libsds/sds/bpt_cow/verify.c
+++ b/src/libsds/sds/bpt_cow/verify.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -77,7 +78,7 @@ sds_bptree_cow_verify_node(sds_bptree_instance *binst, sds_bptree_node *node) {
for (size_t i = 0; i < node->item_count; i++) {
if (node->keys[i] == NULL)
{
- printf("%d \n", node->item_count);
+ sds_log("sds_bptree_cow_verify_node", "%d \n", node->item_count);
return SDS_INVALID_KEY;
}
@@ -172,9 +173,6 @@ sds_bptree_cow_verify_node(sds_bptree_instance *binst, sds_bptree_node *node) {
return SDS_INVALID_POINTER;
}
- if (lnode->level != node->level - 1 || rnode->level != node->level - 1) {
- return SDS_INVALID_NODE;
- }
// Check that all left keys are LESS.
sds_bptree_node_list *path = NULL;
size_t j = 0;
diff --git a/src/libsds/sds/core/crc32c.c b/src/libsds/sds/core/crc32c.c
index cf5189f50..a64a3f94d 100644
--- a/src/libsds/sds/core/crc32c.c
+++ b/src/libsds/sds/core/crc32c.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/core/utils.c b/src/libsds/sds/core/utils.c
index 85ad9bca0..80368d845 100644
--- a/src/libsds/sds/core/utils.c
+++ b/src/libsds/sds/core/utils.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/queue/lqueue.c b/src/libsds/sds/queue/lqueue.c
index 1b0253c52..94c35480e 100644
--- a/src/libsds/sds/queue/lqueue.c
+++ b/src/libsds/sds/queue/lqueue.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/queue/queue.c b/src/libsds/sds/queue/queue.c
index 5cd280ee6..3aba01274 100644
--- a/src/libsds/sds/queue/queue.c
+++ b/src/libsds/sds/queue/queue.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/queue/queue.h b/src/libsds/sds/queue/queue.h
index 87d31cea2..c86248a16 100644
--- a/src/libsds/sds/queue/queue.h
+++ b/src/libsds/sds/queue/queue.h
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/queue/tqueue.c b/src/libsds/sds/queue/tqueue.c
index ee6ee5517..0e75d2255 100644
--- a/src/libsds/sds/queue/tqueue.c
+++ b/src/libsds/sds/queue/tqueue.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/sds/sds_internal.h b/src/libsds/sds/sds_internal.h
index 8773d0750..aee25d29f 100644
--- a/src/libsds/sds/sds_internal.h
+++ b/src/libsds/sds/sds_internal.h
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/test/benchmark.c b/src/libsds/test/benchmark.c
index 621501f02..1c351f6aa 100644
--- a/src/libsds/test/benchmark.c
+++ b/src/libsds/test/benchmark.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -27,9 +28,9 @@ avl_intcmp(uint64_t *a, uint64_t *b) {
}
uint64_t *
-avl_intdup(uint64_t a) {
+avl_intdup(uint64_t *a) {
uint64_t *b = malloc(sizeof(uint64_t));
- *b = a;
+ *b = *a;
return b;
}
@@ -41,24 +42,15 @@ avl_init_wrapper(void **inst) {
}
int64_t
-avl_add_wrapper(void **inst, void *key, void *value __attribute__((unused))) {
+avl_add_wrapper(void **inst, uint64_t *key, void *value __attribute__((unused))) {
Avlnode **tree = (Avlnode **)inst;
- uint64_t ukey = (uint64_t)key;
- if (ukey == 0) {
- return 1;
- }
- return avl_insert(tree, avl_intdup(ukey), avl_intcmp, avl_dup_error);
+ return avl_insert(tree, avl_intdup(key), avl_intcmp, avl_dup_error);
}
int64_t
-avl_search_wrapper(void **inst, void *key, void **value_out) {
+avl_search_wrapper(void **inst, uint64_t *key, void **value_out) {
Avlnode **tree = (Avlnode **)inst;
- uint64_t *ukey = avl_intdup((uint64_t)key);
- if (ukey == 0) {
- return 1;
- }
- *value_out = avl_find(*tree, ukey, avl_intcmp);
- free(ukey);
+ *value_out = avl_find(*tree, key, avl_intcmp);
if (*value_out == NULL) {
return 1;
}
@@ -66,16 +58,11 @@ avl_search_wrapper(void **inst, void *key, void **value_out) {
}
int64_t
-avl_delete_wrapper(void **inst, void *key) {
+avl_delete_wrapper(void **inst, uint64_t *key) {
void *value_out = NULL;
Avlnode **tree = (Avlnode **)inst;
- uint64_t *ukey = avl_intdup((uint64_t)key);
- if (ukey == 0) {
- return 1;
- }
/* delete is broken :( */
- value_out = avl_find(*tree, ukey, avl_intcmp);
- free(ukey);
+ value_out = avl_find(*tree, key, avl_intcmp);
if (value_out == NULL) {
return 1;
}
@@ -110,26 +97,26 @@ avl_destroy_wrapper(void **inst) {
PLHashNumber
hash_func_large(const void *key) {
- uint64_t ik = (uint64_t)key;
+ uint64_t ik = *(uint64_t *)key;
return ik % HASH_BUCKETS_LARGE;
}
PLHashNumber
hash_func_med(const void *key) {
- uint64_t ik = (uint64_t)key;
+ uint64_t ik = *(uint64_t *)key;
return ik % HASH_BUCKETS_MED;
}
PLHashNumber
hash_func_small(const void *key) {
- uint64_t ik = (uint64_t)key;
+ uint64_t ik = *(uint64_t *)key;
return ik % HASH_BUCKETS_SMALL;
}
PRIntn
hash_key_compare (const void *a, const void *b) {
- uint64_t ia = (uint64_t)a;
- uint64_t ib = (uint64_t)b;
+ uint64_t ia = *(uint64_t *)a;
+ uint64_t ib = *(uint64_t* )b;
return ia == ib;
}
@@ -164,17 +151,18 @@ hash_large_init_wrapper(void **inst) {
}
int64_t
-hash_add_wrapper(void **inst, void *key, void *value __attribute__((unused))) {
+hash_add_wrapper(void **inst, uint64_t *key, void *value __attribute__((unused))) {
PLHashTable **table = (PLHashTable **)inst;
// WARNING: We have to add key as value too else hashmap won't add it!!!
- PL_HashTableAdd(*table, key, key);
+ uint64_t *i = avl_intdup(key);
+ PL_HashTableAdd(*table, (void *)i, (void *)i);
return 0;
}
int64_t
-hash_search_wrapper(void **inst, void *key, void **value_out) {
+hash_search_wrapper(void **inst, uint64_t *key, void **value_out) {
PLHashTable **table = (PLHashTable **)inst;
- *value_out = PL_HashTableLookup(*table, key);
+ *value_out = PL_HashTableLookup(*table, (void *)key);
if (*value_out == NULL) {
return 1;
}
@@ -182,9 +170,9 @@ hash_search_wrapper(void **inst, void *key, void **value_out) {
}
int64_t
-hash_delete_wrapper(void **inst, void *key) {
+hash_delete_wrapper(void **inst, uint64_t *key) {
PLHashTable **table = (PLHashTable **)inst;
- PL_HashTableRemove(*table, key);
+ PL_HashTableRemove(*table, (void *)key);
return 0;
}
@@ -209,16 +197,16 @@ int64_t bptree_init_wrapper(void **inst) {
return 0;
}
-int64_t bptree_add_wrapper(void **inst, void *key, void *value) {
+int64_t bptree_add_wrapper(void **inst, uint64_t *key, void *value) {
// THIS WILL BREAK SOMETIME!
sds_bptree_instance **binst = (sds_bptree_instance **)inst;
- sds_bptree_insert(*binst, key, value);
+ sds_bptree_insert(*binst, (void *)key, value);
return 0;
}
-int64_t bptree_search_wrapper(void **inst, void *key, void **value_out __attribute__((unused))) {
+int64_t bptree_search_wrapper(void **inst, uint64_t *key, void **value_out __attribute__((unused))) {
sds_bptree_instance **binst = (sds_bptree_instance **)inst;
- sds_result result = sds_bptree_search(*binst, key);
+ sds_result result = sds_bptree_search(*binst, (void *)key);
if (result != SDS_KEY_PRESENT) {
// printf("search result is %d\n", result);
return 1;
@@ -226,9 +214,9 @@ int64_t bptree_search_wrapper(void **inst, void *key, void **value_out __attribu
return 0;
}
-int64_t bptree_delete_wrapper(void **inst, void *key) {
+int64_t bptree_delete_wrapper(void **inst, uint64_t *key) {
sds_bptree_instance **binst = (sds_bptree_instance **)inst;
- sds_result result = sds_bptree_delete(*binst, key);
+ sds_result result = sds_bptree_delete(*binst, (void *)key);
if (result != SDS_KEY_PRESENT) {
// printf("delete result is %d\n", result);
@@ -252,16 +240,16 @@ int64_t bptree_cow_init_wrapper(void **inst) {
return 0;
}
-int64_t bptree_cow_add_wrapper(void **inst, void *key, void *value) {
+int64_t bptree_cow_add_wrapper(void **inst, uint64_t *key, void *value) {
// THIS WILL BREAK SOMETIME!
sds_bptree_cow_instance **binst = (sds_bptree_cow_instance **)inst;
- sds_bptree_cow_insert_atomic(*binst, key, value);
+ sds_bptree_cow_insert_atomic(*binst, (void *)key, value);
return 0;
}
-int64_t bptree_cow_search_wrapper(void **inst, void *key, void **value_out __attribute__((unused))) {
+int64_t bptree_cow_search_wrapper(void **inst, uint64_t *key, void **value_out __attribute__((unused))) {
sds_bptree_cow_instance **binst = (sds_bptree_cow_instance **)inst;
- sds_result result = sds_bptree_cow_search_atomic(*binst, key);
+ sds_result result = sds_bptree_cow_search_atomic(*binst, (void *)key);
if (result != SDS_KEY_PRESENT) {
// printf("search result is %d\n", result);
return 1;
@@ -269,9 +257,9 @@ int64_t bptree_cow_search_wrapper(void **inst, void *key, void **value_out __att
return 0;
}
-int64_t bptree_cow_delete_wrapper(void **inst, void *key) {
+int64_t bptree_cow_delete_wrapper(void **inst, uint64_t *key) {
sds_bptree_cow_instance **binst = (sds_bptree_cow_instance **)inst;
- sds_result result = sds_bptree_cow_delete_atomic(*binst, key);
+ sds_result result = sds_bptree_cow_delete_atomic(*binst, (void *)key);
if (result != SDS_KEY_PRESENT) {
// printf("delete result is %d\n", result);
return 1;
@@ -301,7 +289,7 @@ bench_1_insert_seq(struct b_tree_cb *ds, uint64_t iter) {
clock_gettime(CLOCK_MONOTONIC, &start_time);
for (uint64_t i = 1; i < iter ; i++) {
- if (ds->add(&(ds->inst), (void *)(i + 1), NULL) != 0) {
+ if (ds->add(&(ds->inst), &i, NULL) != 0) {
printf("FAIL: Error inserting %" PRIu64 " to %s\n", i, ds->name);
break;
}
@@ -340,7 +328,7 @@ bench_2_search_seq(struct b_tree_cb *ds, uint64_t iter) {
printf("BENCH: Start ...\n");
for (uint64_t i = 1; i < iter ; i++) {
- if (ds->add(&(ds->inst), (void *)(i + 1), NULL) != 0) {
+ if (ds->add(&(ds->inst), &i, NULL) != 0) {
printf("FAIL: Error inserting %" PRIu64 " to %s\n", i, ds->name);
break;
}
@@ -351,7 +339,7 @@ bench_2_search_seq(struct b_tree_cb *ds, uint64_t iter) {
void *output;
for (uint64_t j = 0; j < 100; j++) {
for (uint64_t i = 1; i < iter ; i++) {
- if (ds->search(&(ds->inst), (void *)(i + 1), &output) != 0) {
+ if (ds->search(&(ds->inst), &i, &output) != 0) {
printf("FAIL: Error finding %" PRIu64 " in %s\n", i, ds->name);
break;
}
@@ -390,7 +378,7 @@ bench_3_delete_seq(struct b_tree_cb *ds, uint64_t iter) {
for (uint64_t i = 1; i < iter ; i++) {
- if (ds->add(&(ds->inst), (void *)(i + 1), NULL) != 0) {
+ if (ds->add(&(ds->inst), &i, NULL) != 0) {
printf("FAIL: Error inserting %" PRIu64 " to %s\n", i, ds->name);
break;
}
@@ -400,7 +388,7 @@ bench_3_delete_seq(struct b_tree_cb *ds, uint64_t iter) {
clock_gettime(CLOCK_MONOTONIC, &start_time);
for (uint64_t i = 1; i < iter ; i++) {
- if (ds->delete(&(ds->inst), (void *)(i + 1)) != 0) {
+ if (ds->delete(&(ds->inst), &i) != 0) {
printf("FAIL: Error deleting %" PRIu64 " from %s\n", i, ds->name);
break;
}
@@ -448,7 +436,8 @@ bench_4_insert_search_delete_random(struct b_tree_cb *ds, uint64_t iter) {
for (size_t j = 0; j < max_factors; j++) {
for (size_t i = 0; i < 2048 ; i++) {
- ds->add(&(ds->inst), (void *)(fill_pattern[i] + (2048 << j)), NULL);
+ uint64_t x = fill_pattern[i] + (2048 << j);
+ ds->add(&(ds->inst), &x, NULL);
}
}
@@ -458,12 +447,13 @@ bench_4_insert_search_delete_random(struct b_tree_cb *ds, uint64_t iter) {
int mod = current_step % 10;
cf = step % max_factors;
+ uint64_t x = fill_pattern[step % 2048] + (2048 << cf);
if (mod >= 8) {
- ds->delete(&(ds->inst), (void *)(fill_pattern[step % 2048] + (2048 << cf) ));
+ ds->delete(&(ds->inst), &x);
} else if (mod >= 6) {
- ds->add(&(ds->inst), (void *)(fill_pattern[step % 2048] + (2048 << cf)), NULL);
+ ds->add(&(ds->inst), &x, NULL);
} else {
- ds->search(&(ds->inst), (void *)(fill_pattern[step % 2048] + (2048 << cf)), &output);
+ ds->search(&(ds->inst), &x, &output);
}
}
@@ -548,7 +538,7 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
uint64_t test_arrays[] = {5000, 10000, 100000, 500000, 1000000, 2500000, 5000000, 10000000};
- for (size_t i = 0; i < 2; i++) {
+ for (size_t i = 0; i < 3; i++) {
bench_1_insert_seq(&avl_test, test_arrays[i]);
bench_1_insert_seq(&hash_small_test, test_arrays[i]);
bench_1_insert_seq(&hash_med_test, test_arrays[i]);
diff --git a/src/libsds/test/benchmark.h b/src/libsds/test/benchmark.h
index f40dbc7d2..b0c8a4d39 100644
--- a/src/libsds/test/benchmark.h
+++ b/src/libsds/test/benchmark.h
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -13,9 +14,9 @@ struct b_tree_cb {
char *name;
void *inst;
int64_t (*init)(void **inst);
- int64_t (*add)(void **inst, void *key, void *value);
- int64_t (*search)(void **inst, void *key, void **value_out);
- int64_t (*delete)(void **inst, void *key);
+ int64_t (*add)(void **inst, uint64_t *key, void *value);
+ int64_t (*search)(void **inst, uint64_t *key, void **value_out);
+ int64_t (*delete)(void **inst, uint64_t *key);
int64_t (*destroy)(void **inst);
};
diff --git a/src/libsds/test/benchmark_par.c b/src/libsds/test/benchmark_par.c
index 8fa4ff70a..2a4331728 100644
--- a/src/libsds/test/benchmark_par.c
+++ b/src/libsds/test/benchmark_par.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -111,25 +112,25 @@ batch_random(struct thread_info *info) {
current_step = step + fill_pattern[step % 2048];
size_t mod = current_step % 10;
cf = step % max_factors;
- void *target = (void *)(fill_pattern[step % 2048] + (2048 << cf) + baseid);
+ uint64_t target = fill_pattern[step % 2048] + (2048 << cf) + baseid;
if (mod >= 8) {
info->ds->write_begin(&(info->ds->inst), &write_txn);
- info->ds->delete(&(info->ds->inst), write_txn, target);
+ info->ds->delete(&(info->ds->inst), write_txn, &target);
if (info->write_delay != 0) {
usleep(info->write_delay);
}
info->ds->write_commit(&(info->ds->inst), write_txn);
} else if (mod >= 6) {
info->ds->write_begin(&(info->ds->inst), &write_txn);
- info->ds->add(&(info->ds->inst), write_txn, target, NULL);
+ info->ds->add(&(info->ds->inst), write_txn, &target, NULL);
if (info->write_delay != 0) {
usleep(info->write_delay);
}
info->ds->write_commit(&(info->ds->inst), write_txn);
} else {
info->ds->read_begin(&(info->ds->inst), &read_txn);
- info->ds->search(&(info->ds->inst), read_txn, target, &output);
+ info->ds->search(&(info->ds->inst), read_txn, &target, &output);
if (info->read_delay != 0) {
usleep(info->read_delay);
}
@@ -152,9 +153,9 @@ batch_search(struct thread_info *info) {
info->ds->read_begin(&(info->ds->inst), &read_txn);
for (size_t j = 0; j < info->batchsize; j++) {
cf = (step * info->tid) % 2048;
- void *target = (void *)(fill_pattern[cf] + j);
+ uint64_t target = fill_pattern[cf] + j;
- info->ds->search(&(info->ds->inst), read_txn, target, &output);
+ info->ds->search(&(info->ds->inst), read_txn, &target, &output);
}
if (info->read_delay != 0) {
usleep(info->read_delay);
@@ -180,8 +181,8 @@ batch_insert(struct thread_info *info) {
info->ds->write_begin(&(info->ds->inst), &write_txn);
for (size_t j = 0; j < 10; j++) {
cf = step % max_factors;
- void *target = (void *)(fill_pattern[step % 2048] + (2048 << cf) + baseid);
- info->ds->add(&(info->ds->inst), write_txn, target, NULL);
+ uint64_t target = fill_pattern[step % 2048] + (2048 << cf) + baseid;
+ info->ds->add(&(info->ds->inst), write_txn, &target, NULL);
}
if (info->write_delay != 0) {
@@ -208,8 +209,8 @@ batch_delete(struct thread_info *info) {
info->ds->write_begin(&(info->ds->inst), &write_txn);
for (size_t j = 0; j < 10; j++) {
cf = step % max_factors;
- void *target = (void *)(fill_pattern[step % 2048] + (2048 << cf) + baseid);
- info->ds->delete(&(info->ds->inst), write_txn, target);
+ uint64_t target = fill_pattern[step % 2048] + (2048 << cf) + baseid;
+ info->ds->delete(&(info->ds->inst), write_txn, &target);
}
if (info->write_delay != 0) {
@@ -287,7 +288,8 @@ populate_ds(struct b_tree_cow_cb *ds, uint64_t iter) {
ds->write_begin(&(ds->inst), &write_txn);
for (size_t j = 0; j < max_factors; j++) {
for (size_t i = 0; i < 2048 ; i++) {
- ds->add(&(ds->inst), write_txn, (void *)(fill_pattern[i] + (2048 * j)), NULL);
+ uint64_t target = fill_pattern[i] + (2048 * j);
+ ds->add(&(ds->inst), write_txn, &target, NULL);
count++;
}
}
@@ -313,7 +315,7 @@ bench_insert_search_delete_batch(struct b_tree_cow_cb *ds, uint64_t iter) {
info[i].op = batch_insert;
info[i].batchsize = 10;
}
- for (; i < 2; i++) {
+ for (; i < 5; i++) {
info[i].iter = iter;
info[i].tid = i;
info[i].ds = ds;
@@ -567,11 +569,11 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
uint64_t test_arrays[] = {5000, 10000, 100000, 500000, 1000000, 2500000, 5000000, 10000000};
- for (size_t i = 0; i < 3; i++) {
+ for (size_t i = 0; i < 1; i++) {
/*
bench_insert_search_delete_batch(&hash_small_cb_test, test_arrays[i]);
- */
bench_insert_search_delete_batch(&hash_med_cb_test, test_arrays[i]);
+ */
bench_insert_search_delete_batch(&hash_large_cb_test, test_arrays[i]);
bench_insert_search_delete_batch(&bptree_test, test_arrays[i]);
bench_insert_search_delete_batch(&bptree_cow_test, test_arrays[i]);
@@ -579,8 +581,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
/*
bench_isd_write_delay(&hash_small_cb_test, test_arrays[i]);
- */
bench_isd_write_delay(&hash_med_cb_test, test_arrays[i]);
+ */
bench_isd_write_delay(&hash_large_cb_test, test_arrays[i]);
bench_isd_write_delay(&bptree_test, test_arrays[i]);
bench_isd_write_delay(&bptree_cow_test, test_arrays[i]);
@@ -588,8 +590,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
/*
bench_isd_read_delay(&hash_small_cb_test, test_arrays[i]);
- */
bench_isd_read_delay(&hash_med_cb_test, test_arrays[i]);
+ */
bench_isd_read_delay(&hash_large_cb_test, test_arrays[i]);
bench_isd_read_delay(&bptree_test, test_arrays[i]);
bench_isd_read_delay(&bptree_cow_test, test_arrays[i]);
@@ -597,8 +599,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
/*
bench_high_thread_small_batch_read(&hash_small_cb_test, test_arrays[i]);
- */
bench_high_thread_small_batch_read(&hash_med_cb_test, test_arrays[i]);
+ */
bench_high_thread_small_batch_read(&hash_large_cb_test, test_arrays[i]);
bench_high_thread_small_batch_read(&bptree_test, test_arrays[i]);
bench_high_thread_small_batch_read(&bptree_cow_test, test_arrays[i]);
@@ -606,8 +608,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
/*
bench_high_thread_large_batch_read(&hash_small_cb_test, test_arrays[i]);
- */
bench_high_thread_large_batch_read(&hash_med_cb_test, test_arrays[i]);
+ */
bench_high_thread_large_batch_read(&hash_large_cb_test, test_arrays[i]);
bench_high_thread_large_batch_read(&bptree_test, test_arrays[i]);
bench_high_thread_large_batch_read(&bptree_cow_test, test_arrays[i]);
@@ -615,8 +617,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
/*
bench_high_thread_small_batch_write(&hash_small_cb_test, test_arrays[i]);
- */
bench_high_thread_small_batch_write(&hash_med_cb_test, test_arrays[i]);
+ */
bench_high_thread_small_batch_write(&hash_large_cb_test, test_arrays[i]);
bench_high_thread_small_batch_write(&bptree_test, test_arrays[i]);
bench_high_thread_small_batch_write(&bptree_cow_test, test_arrays[i]);
@@ -624,8 +626,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
/*
bench_high_thread_large_batch_write(&hash_small_cb_test, test_arrays[i]);
- */
bench_high_thread_large_batch_write(&hash_med_cb_test, test_arrays[i]);
+ */
bench_high_thread_large_batch_write(&hash_large_cb_test, test_arrays[i]);
bench_high_thread_large_batch_write(&bptree_test, test_arrays[i]);
bench_high_thread_large_batch_write(&bptree_cow_test, test_arrays[i]);
@@ -633,8 +635,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) {
/*
bench_insert_search_delete_random(&hash_small_cb_test, test_arrays[i]);
- */
bench_insert_search_delete_random(&hash_med_cb_test, test_arrays[i]);
+ */
bench_insert_search_delete_random(&hash_large_cb_test, test_arrays[i]);
bench_insert_search_delete_random(&bptree_test, test_arrays[i]);
bench_insert_search_delete_random(&bptree_cow_test, test_arrays[i]);
diff --git a/src/libsds/test/benchmark_par.h b/src/libsds/test/benchmark_par.h
index 418cfb37b..2507c3bce 100644
--- a/src/libsds/test/benchmark_par.h
+++ b/src/libsds/test/benchmark_par.h
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -17,9 +18,9 @@ struct b_tree_cow_cb {
int64_t (*read_complete)(void **inst, void *read_txn);
int64_t (*write_begin)(void **inst, void **write_txn);
int64_t (*write_commit)(void **inst, void *write_txn);
- int64_t (*add)(void **inst, void *write_txn, void *key, void *value);
- int64_t (*search)(void **inst, void *read_txn, void *key, void **value_out);
- int64_t (*delete)(void **inst, void *write_txn, void *key);
+ int64_t (*add)(void **inst, void *write_txn, uint64_t *key, void *value);
+ int64_t (*search)(void **inst, void *read_txn, uint64_t *key, void **value_out);
+ int64_t (*delete)(void **inst, void *write_txn, uint64_t *key);
int64_t (*destroy)(void **inst);
};
@@ -48,9 +49,9 @@ int64_t bptree_read_begin(void **inst, void **txn);
int64_t bptree_read_complete(void **inst, void *txn);
int64_t bptree_write_begin(void **inst, void **txn);
int64_t bptree_write_commit(void **inst, void *txn);
-int64_t bptree_add_wrapper(void **inst, void *txn, void *key, void *value);
-int64_t bptree_search_wrapper(void **inst, void *txn, void *key, void **value_out);
-int64_t bptree_delete_wrapper(void **inst, void *txn, void *key);
+int64_t bptree_add_wrapper(void **inst, void *txn, uint64_t *key, void *value);
+int64_t bptree_search_wrapper(void **inst, void *txn, uint64_t *key, void **value_out);
+int64_t bptree_delete_wrapper(void **inst, void *txn, uint64_t *key);
int64_t bptree_destroy_wrapper(void **inst);
int64_t bptree_cow_init_wrapper(void **inst);
@@ -58,16 +59,16 @@ int64_t bptree_cow_read_begin(void **inst, void **read_txn);
int64_t bptree_cow_read_complete(void **inst, void *read_txn);
int64_t bptree_cow_write_begin(void **inst, void **write_txn);
int64_t bptree_cow_write_commit(void **inst, void *write_txn);
-int64_t bptree_cow_add_wrapper(void **inst, void *write_txn, void *key, void *value);
-int64_t bptree_cow_search_wrapper(void **inst, void *read_txn, void *key, void **value_out);
-int64_t bptree_cow_delete_wrapper(void **inst, void *write_txn, void *key);
+int64_t bptree_cow_add_wrapper(void **inst, void *write_txn, uint64_t *key, void *value);
+int64_t bptree_cow_search_wrapper(void **inst, void *read_txn, uint64_t *key, void **value_out);
+int64_t bptree_cow_delete_wrapper(void **inst, void *write_txn, uint64_t *key);
int64_t bptree_cow_destroy_wrapper(void **inst);
/* Hash map structures */
int64_t hash_small_init_wrapper(void **inst);
int64_t hash_med_init_wrapper(void **inst);
int64_t hash_large_init_wrapper(void **inst);
-int64_t hash_add_wrapper(void **inst, void *write_txn, void *key, void *value);
-int64_t hash_search_wrapper(void **inst, void *read_txn, void *key, void **value_out);
-int64_t hash_delete_wrapper(void **inst, void *write_txn, void *key);
+int64_t hash_add_wrapper(void **inst, void *write_txn, uint64_t *key, void *value);
+int64_t hash_search_wrapper(void **inst, void *read_txn, uint64_t *key, void **value_out);
+int64_t hash_delete_wrapper(void **inst, void *write_txn, uint64_t *key);
int64_t hash_destroy_wrapper(void **inst);
diff --git a/src/libsds/test/benchmark_parwrap.c b/src/libsds/test/benchmark_parwrap.c
index 36fe9db83..747bc1c83 100644
--- a/src/libsds/test/benchmark_parwrap.c
+++ b/src/libsds/test/benchmark_parwrap.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -69,16 +70,16 @@ int64_t bptree_init_wrapper(void **inst) {
return 0;
}
-int64_t bptree_add_wrapper(void **inst, void *txn __attribute__((unused)), void *key, void *value) {
+int64_t bptree_add_wrapper(void **inst, void *txn __attribute__((unused)), uint64_t *key, void *value) {
// THIS WILL BREAK SOMETIME!
sds_bptree_instance **binst = (sds_bptree_instance **)inst;
- sds_bptree_insert(*binst, key, value);
+ sds_bptree_insert(*binst, (void*)key, value);
return 0;
}
-int64_t bptree_search_wrapper(void **inst, void *txn __attribute__((unused)), void *key, void **value_out __attribute__((unused))) {
+int64_t bptree_search_wrapper(void **inst, void *txn __attribute__((unused)), uint64_t *key, void **value_out __attribute__((unused))) {
sds_bptree_instance **binst = (sds_bptree_instance **)inst;
- sds_result result = sds_bptree_search(*binst, key);
+ sds_result result = sds_bptree_search(*binst, (void *)key);
if (result != SDS_KEY_PRESENT) {
// printf("search result is %d\n", result);
return 1;
@@ -86,9 +87,9 @@ int64_t bptree_search_wrapper(void **inst, void *txn __attribute__((unused)), vo
return 0;
}
-int64_t bptree_delete_wrapper(void **inst, void *txn __attribute__((unused)), void *key) {
+int64_t bptree_delete_wrapper(void **inst, void *txn __attribute__((unused)), uint64_t *key) {
sds_bptree_instance **binst = (sds_bptree_instance **)inst;
- sds_result result = sds_bptree_delete(*binst, key);
+ sds_result result = sds_bptree_delete(*binst, (void *)key);
if (result != SDS_KEY_PRESENT) {
// printf("delete result is %d\n", result);
@@ -148,26 +149,26 @@ int64_t bptree_cow_write_commit(void **inst __attribute__((unused)), void *write
return 0;
}
-int64_t bptree_cow_add_wrapper(void **inst __attribute__((unused)), void *write_txn, void *key, void *value) {
+int64_t bptree_cow_add_wrapper(void **inst __attribute__((unused)), void *write_txn, uint64_t *key, void *value) {
// THIS WILL BREAK SOMETIME!
sds_bptree_transaction *txn = (sds_bptree_transaction *)write_txn;
- sds_bptree_cow_insert(txn, key, value);
+ sds_bptree_cow_insert(txn, (void *)key, value);
return 0;
}
-int64_t bptree_cow_search_wrapper(void **inst __attribute__((unused)), void *read_txn, void *key, void **value_out __attribute__((unused))) {
+int64_t bptree_cow_search_wrapper(void **inst __attribute__((unused)), void *read_txn, uint64_t *key, void **value_out __attribute__((unused))) {
sds_bptree_transaction *txn = (sds_bptree_transaction *)read_txn;
- sds_result result = sds_bptree_cow_search(txn, key);
+ sds_result result = sds_bptree_cow_search(txn, (void *)key);
if (result != SDS_KEY_PRESENT) {
return 1;
}
return 0;
}
-int64_t bptree_cow_delete_wrapper(void **inst __attribute__((unused)), void *write_txn, void *key) {
+int64_t bptree_cow_delete_wrapper(void **inst __attribute__((unused)), void *write_txn, uint64_t *key) {
// sds_bptree_cow_instance **binst = (sds_bptree_cow_instance **)inst;
sds_bptree_transaction *txn = (sds_bptree_transaction *)write_txn;
- sds_result result = sds_bptree_cow_delete(txn, key);
+ sds_result result = sds_bptree_cow_delete(txn, (void *)key);
if (result != SDS_KEY_PRESENT) {
return 1;
}
@@ -204,26 +205,26 @@ int64_t bptree_cow_destroy_wrapper(void **inst) {
PLHashNumber
hash_func_large(const void *key) {
- uint64_t ik = (uint64_t)key;
+ uint64_t ik = *(uint64_t *)key;
return ik % HASH_BUCKETS_LARGE;
}
PLHashNumber
hash_func_med(const void *key) {
- uint64_t ik = (uint64_t)key;
+ uint64_t ik = *(uint64_t *)key;
return ik % HASH_BUCKETS_MED;
}
PLHashNumber
hash_func_small(const void *key) {
- uint64_t ik = (uint64_t)key;
+ uint64_t ik = *(uint64_t *)key;
return ik % HASH_BUCKETS_SMALL;
}
PRIntn
hash_key_compare (const void *a, const void *b) {
- uint64_t ia = (uint64_t)a;
- uint64_t ib = (uint64_t)b;
+ uint64_t ia = *(uint64_t *)a;
+ uint64_t ib = *(uint64_t *)b;
return ia == ib;
}
@@ -273,15 +274,16 @@ hash_large_init_wrapper(void **inst) {
}
int64_t
-hash_add_wrapper(void **inst, void *write_txn __attribute__((unused)), void *key, void *value __attribute__((unused))) {
+hash_add_wrapper(void **inst, void *write_txn __attribute__((unused)), uint64_t *key, void *value __attribute__((unused))) {
PLHashTable **table = (PLHashTable **)inst;
// WARNING: We have to add key as value too else hashmap won't add it!!!
- PL_HashTableAdd(*table, key, key);
+ uint64_t *i = sds_uint64_t_dup(key);
+ PL_HashTableAdd(*table, i, i);
return 0;
}
int64_t
-hash_search_wrapper(void **inst, void *read_txn __attribute__((unused)), void *key, void **value_out) {
+hash_search_wrapper(void **inst, void *read_txn __attribute__((unused)), uint64_t *key, void **value_out) {
PLHashTable **table = (PLHashTable **)inst;
*value_out = PL_HashTableLookup(*table, key);
if (*value_out == NULL) {
@@ -291,7 +293,7 @@ hash_search_wrapper(void **inst, void *read_txn __attribute__((unused)), void *k
}
int64_t
-hash_delete_wrapper(void **inst, void *write_txn __attribute__((unused)), void *key) {
+hash_delete_wrapper(void **inst, void *write_txn __attribute__((unused)), uint64_t *key) {
PLHashTable **table = (PLHashTable **)inst;
PL_HashTableRemove(*table, key);
return 0;
diff --git a/src/libsds/test/test_fixtures.c b/src/libsds/test/test_fixtures.c
index a530c0230..49bce57c5 100644
--- a/src/libsds/test/test_fixtures.c
+++ b/src/libsds/test/test_fixtures.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/test/test_sds.c b/src/libsds/test/test_sds.c
index 276d3d5e3..dff5b8bd2 100644
--- a/src/libsds/test/test_sds.c
+++ b/src/libsds/test/test_sds.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/test/test_sds.h b/src/libsds/test/test_sds.h
index 994611a16..4755d5e35 100644
--- a/src/libsds/test/test_sds.h
+++ b/src/libsds/test/test_sds.h
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/test/test_sds_bpt.c b/src/libsds/test/test_sds_bpt.c
index 32430260f..13f8177cf 100644
--- a/src/libsds/test/test_sds_bpt.c
+++ b/src/libsds/test/test_sds_bpt.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -189,8 +190,10 @@ test_11_tamper_with_node(void **state __attribute__((unused))) {
binst->root->keys[0] = (void *)1;
+#ifdef DEBUG
result = sds_bptree_verify(binst);
assert_int_equal(result, SDS_CHECKSUM_FAILURE);
+#endif
result = sds_bptree_destroy(binst);
assert_int_equal(result, SDS_SUCCESS);
@@ -444,17 +447,10 @@ test_21_delete_redist_left_leaf(void **state)
// I is increment 1 extra, so decrement it ....
i--;
-
-#ifdef DEBUG
- printf("Deleting %" PRIu64 "\n", i);
-#endif
result = sds_bptree_delete(binst, (void *)&i);
assert_int_equal(result, SDS_KEY_PRESENT);
i--;
-#ifdef DEBUG
- printf("Deleting %" PRIu64 "\n", i);
-#endif
result = sds_bptree_delete(binst, (void *)&i);
assert_int_equal(result, SDS_KEY_PRESENT);
@@ -539,9 +535,6 @@ test_22_5_redist_left_borrow(void **state)
assert_int_equal(result, SDS_SUCCESS);
for (uint64_t i = SDS_BPTREE_DEFAULT_CAPACITY; i > 2 ; i--) {
-#ifdef DEBUG
- printf("Deleting %" PRIu64 "\n ", i);
-#endif
key = i + 1;
result = sds_bptree_delete(binst, (void *)&key);
assert_int_equal(result, SDS_KEY_PRESENT);
@@ -625,9 +618,6 @@ test_24_delete_left_merge(void **state)
for (i = SDS_BPTREE_DEFAULT_CAPACITY; i <= (SDS_BPTREE_DEFAULT_CAPACITY * 2) ; i++) {
// Add two to guarantee we don't conflict
-#ifdef DEBUG
- printf("Deleting %" PRIu64 "\n ", i);
-#endif
result = sds_bptree_delete(binst, (void *)&i);
assert_int_equal(result, SDS_KEY_PRESENT);
}
@@ -651,9 +641,6 @@ test_25_delete_all_compress_root(void **state)
for (i = 1; i <= (SDS_BPTREE_DEFAULT_CAPACITY * 3); i++) {
// Add two to guarantee we don't conflict
-#ifdef DEBUG
- printf("Deleting %" PRIu64 "\n ", i);
-#endif
result = sds_bptree_delete(binst, (void *)&i);
assert_int_equal(result, SDS_KEY_PRESENT);
}
@@ -741,9 +728,6 @@ test_27_delete_left_branch_merge(void **state)
// And A should be removed too.
for (i = SDS_BPTREE_DEFAULT_CAPACITY * 2; i <= (SDS_BPTREE_DEFAULT_CAPACITY * 6) ; i++) {
// Add two to guarantee we don't conflict
-#ifdef DEBUG
- printf("Deleting %" PRIu64 "\n ", i);
-#endif
result = sds_bptree_delete(binst, (void *)&i);
assert_int_equal(result, SDS_KEY_PRESENT);
result = sds_bptree_verify(binst);
diff --git a/src/libsds/test/test_sds_cow.c b/src/libsds/test/test_sds_cow.c
index 4ad537586..d4fcfdab9 100644
--- a/src/libsds/test/test_sds_cow.c
+++ b/src/libsds/test/test_sds_cow.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/test/test_sds_lqueue.c b/src/libsds/test/test_sds_lqueue.c
index db91a8d18..fb515ea13 100644
--- a/src/libsds/test/test_sds_lqueue.c
+++ b/src/libsds/test/test_sds_lqueue.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/test/test_sds_queue.c b/src/libsds/test/test_sds_queue.c
index 45d14d91a..03da7a1ab 100644
--- a/src/libsds/test/test_sds_queue.c
+++ b/src/libsds/test/test_sds_queue.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
diff --git a/src/libsds/test/test_sds_set.c b/src/libsds/test/test_sds_set.c
index 3b2787375..159b69c16 100644
--- a/src/libsds/test/test_sds_set.c
+++ b/src/libsds/test/test_sds_set.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
@@ -16,9 +17,6 @@ static int32_t cb_count = 0;
static void
test_31_map_cb(void *k, void *v) {
-#ifdef DEBUG
- printf("mapping %" PRIu64 ":%s\n", (uint64_t)k, (char *)v);
-#endif
cb_count++;
}
@@ -273,9 +271,6 @@ test_38_set_compliment_2(void **state) {
static int64_t
test_39_filter_cb(void *k, void *v) {
-#ifdef DEBUG
- printf("filtering %" PRIu64 ":%s\n", *(uint64_t *)k, (char *)v);
-#endif
if (*(uint64_t *)k % 2 == 0) {
return 1;
}
diff --git a/src/libsds/test/test_sds_tqueue.c b/src/libsds/test/test_sds_tqueue.c
index c150c57ac..f5596bdf6 100644
--- a/src/libsds/test/test_sds_tqueue.c
+++ b/src/libsds/test/test_sds_tqueue.c
@@ -1,8 +1,9 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (c) 2016, William Brown <william at blackhats dot net dot au>
+ * Copyright (c) 2017, Red Hat, Inc
* All rights reserved.
*
- * License: License: GPL (version 3 or any later version).
+ * License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
| 0 |
f0ef03f6fda310b6ff68dde6dcd80c446629e4d4
|
389ds/389-ds-base
|
Issue 4632 - dscontainer: SyntaxWarning: "is" with a literal.
Bug Description:
`dscontainer -H` always returns 1 because of incorrect comparison
(object instead of value).
Fix Description:
Use the euality operator `==` instead of identity operator `is`.
Relates: https://github.com/389ds/389-ds-base/issues/4300
Fixes: https://github.com/389ds/389-ds-base/issues/4632
Reviewed by: @mreynolds389 (Thanks!)
|
commit f0ef03f6fda310b6ff68dde6dcd80c446629e4d4
Author: Viktor Ashirov <[email protected]>
Date: Mon Apr 19 16:38:17 2021 +0200
Issue 4632 - dscontainer: SyntaxWarning: "is" with a literal.
Bug Description:
`dscontainer -H` always returns 1 because of incorrect comparison
(object instead of value).
Fix Description:
Use the euality operator `==` instead of identity operator `is`.
Relates: https://github.com/389ds/389-ds-base/issues/4300
Fixes: https://github.com/389ds/389-ds-base/issues/4632
Reviewed by: @mreynolds389 (Thanks!)
diff --git a/src/lib389/cli/dscontainer b/src/lib389/cli/dscontainer
index 741f110a9..30fd2ee07 100755
--- a/src/lib389/cli/dscontainer
+++ b/src/lib389/cli/dscontainer
@@ -432,7 +432,7 @@ container host.
if args.runit:
begin_magic()
elif args.healthcheck:
- if begin_healthcheck(None) is (False, True):
+ if begin_healthcheck(None) == (False, True):
sys.exit(0)
else:
sys.exit(1)
| 0 |
8216af284bf01728074d474131ae781e6033055c
|
389ds/389-ds-base
|
also checkin fix for 170350 onto trunk
|
commit 8216af284bf01728074d474131ae781e6033055c
Author: Rich Megginson <[email protected]>
Date: Fri Oct 21 17:55:22 2005 +0000
also checkin fix for 170350 onto trunk
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index 106972dfe..efed42638 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -385,6 +385,7 @@ windows_perform_operation(Repl_Connection *conn, int optype, const char *dn,
char *errmsg = NULL;
char **referrals = NULL;
char *matched = NULL;
+ char *ptr;
rc = ldap_parse_result(conn->ld, res, &err, &matched,
&errmsg, &referrals, &loc_returned_controls,
@@ -433,13 +434,34 @@ windows_perform_operation(Repl_Connection *conn, int optype, const char *dn,
}
return_value = LDAP_SUCCESS == conn->last_ldap_error ? CONN_OPERATION_SUCCESS : CONN_OPERATION_FAILED;
}
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "%s: Received result code %d for %s operation %s%s\n",
- agmt_get_long_name(conn->agmt),
- conn->last_ldap_error,
- op_string == NULL ? "" : op_string,
- extra_op_string == NULL ? "" : extra_op_string,
- extra_op_string == NULL ? "" : " ");
+ /* remove extra newlines from AD error message */
+ for (ptr = errmsg; ptr && *ptr; ++ptr) {
+ if ((*ptr == '\n') || (*ptr == '\r')) {
+ *ptr = ' ';
+ }
+ }
+ /* handle special case of constraint violation - give admin
+ enough information to allow them to fix the problem
+ and retry - bug 170350 */
+ if (conn->last_ldap_error == LDAP_CONSTRAINT_VIOLATION) {
+ char ebuf[BUFSIZ];
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "%s: Received error [%s] when attempting to %s"
+ " entry [%s]: Please correct the attribute specified "
+ "in the error message. Refer to the Windows Active "
+ "Directory docs for more information.\n",
+ agmt_get_long_name(conn->agmt),
+ errmsg, op_string == NULL ? "" : op_string,
+ escape_string(dn, ebuf));
+ } else {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "%s: Received result code %d (%s) for %s operation %s%s\n",
+ agmt_get_long_name(conn->agmt),
+ conn->last_ldap_error, errmsg,
+ op_string == NULL ? "" : op_string,
+ extra_op_string == NULL ? "" : extra_op_string,
+ extra_op_string == NULL ? "" : " ");
+ }
/*
* XXXggood do I need to free matched, referrals,
* anything else? Or can I pass NULL for the args
| 0 |
36203f4d76b669667bc79ed330ef1048d106b353
|
389ds/389-ds-base
|
Bug(s) fixed: 154235
Bug Description: HP wants automounter schema removed
Reviewed by: Nathan (Thanks!)
Fix Description: We must have picked up an old version of the rfc2307 schema that had the automount stuff in it which has been removed. This fix just removes the automount stuff.
Platforms tested: RHEL3
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
|
commit 36203f4d76b669667bc79ed330ef1048d106b353
Author: Rich Megginson <[email protected]>
Date: Fri Apr 8 17:47:55 2005 +0000
Bug(s) fixed: 154235
Bug Description: HP wants automounter schema removed
Reviewed by: Nathan (Thanks!)
Fix Description: We must have picked up an old version of the rfc2307 schema that had the automount stuff in it which has been removed. This fix just removes the automount stuff.
Platforms tested: RHEL3
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/schema/10rfc2307.ldif b/ldap/schema/10rfc2307.ldif
index 4afc3ab89..1679e6988 100644
--- a/ldap/schema/10rfc2307.ldif
+++ b/ldap/schema/10rfc2307.ldif
@@ -35,7 +35,6 @@ attributeTypes: ( 1.3.6.1.1.1.1.21 NAME 'ipNetmaskNumber' DESC 'Standard LDAP at
attributeTypes: ( 1.3.6.1.1.1.1.22 NAME 'macAddress' DESC 'Standard LDAP attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'RFC 2307' )
attributeTypes: ( 1.3.6.1.1.1.1.23 NAME 'bootParameter' DESC 'Standard LDAP attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'RFC 2307' )
attributeTypes: ( 1.3.6.1.1.1.1.24 NAME 'bootFile' DESC 'Standard LDAP attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'RFC 2307' )
-attributeTypes: ( 1.3.6.1.1.1.1.25 NAME 'automountInformation' DESC 'Standard LDAP attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'RFC 2307' )
attributeTypes: ( 1.3.6.1.1.1.1.26 NAME 'nisMapName' DESC 'Standard LDAP attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'RFC 2307' )
attributeTypes: ( 1.3.6.1.1.1.1.27 NAME 'nisMapEntry' DESC 'Standard LDAP attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'RFC 2307' )
objectClasses: ( 1.3.6.1.1.1.2.0 NAME 'posixAccount' DESC 'Standard LDAP objectclass' SUP top AUXILIARY MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory ) MAY ( userPassword $ loginShell $ gecos $ description ) X-ORIGIN 'RFC 2307' )
@@ -47,7 +46,6 @@ objectClasses: ( 1.3.6.1.1.1.2.5 NAME 'oncRpc' DESC 'Standard LDAP objectclass'
objectClasses: ( 1.3.6.1.1.1.2.6 NAME 'ipHost' DESC 'Standard LDAP objectclass' SUP top AUXILIARY MUST ( ipHostNumber $ cn ) MAY ( manager $ description $ l $ o $ ou $ owner $ seeAlso $ serialNumber ) X-ORIGIN 'RFC 2307' )
objectClasses: ( 1.3.6.1.1.1.2.7 NAME 'ipNetwork' DESC 'Standard LDAP objectclass' SUP top STRUCTURAL MUST ( ipNetworkNumber $ cn ) MAY ( ipNetmaskNumber $ manager $ l $ description ) X-ORIGIN 'RFC 2307' )
objectClasses: ( 1.3.6.1.1.1.2.8 NAME 'nisNetgroup' DESC 'Standard LDAP objectclass' SUP top STRUCTURAL MUST cn MAY ( nisNetgroupTriple $ memberNisNetgroup $ description ) X-ORIGIN 'RFC 2307' )
-objectClasses: ( 1.3.6.1.1.1.2.9 NAME 'automount' DESC 'Standard LDAP objectclass' SUP top MUST ( cn $ automountInformation ) MAY ( description ) X-ORIGIN 'RFC 2307' )
objectClasses: ( 1.3.6.1.1.1.2.10 NAME 'nisObject' DESC 'Standard LDAP objectclass' SUP top STRUCTURAL MUST ( cn $ nisMapEntry $ nisMapName ) MAY ( description ) X-ORIGIN 'RFC 2307' )
objectClasses: ( 1.3.6.1.1.1.2.11 NAME 'ieee802Device' DESC 'Standard LDAP objectclass' SUP top AUXILIARY MUST cn MAY ( macAddress $ description $ l $ o $ ou $ owner $ seeAlso $ serialNumber ) X-ORIGIN 'RFC 2307' )
objectClasses: ( 1.3.6.1.1.1.2.12 NAME 'bootableDevice' DESC 'Standard LDAP objectclass' SUP top AUXILIARY MUST cn MAY ( bootFile $ bootParameter $ description $ l $ o $ ou $ owner $ seeAlso $ serialNumber ) X-ORIGIN 'RFC 2307' )
| 0 |
9c29bdbfa149529e561a0bcd114cf2b064b6a008
|
389ds/389-ds-base
|
609255 - fix coverity Defect Type: Memory - illegal accesses issues
https://bugzilla.redhat.com/show_bug.cgi?id=609255
12224 UNINIT Triaged Unassigned Bug Minor Fix Required
windows_private_update_dirsync_control() ds/ldap/servers/plugins/replication/windows_private.c
Comment:
If DIRSYNC control is not found, uninitialized ber is passed to
ber_free. We should init ber to NULL.
|
commit 9c29bdbfa149529e561a0bcd114cf2b064b6a008
Author: Noriko Hosoi <[email protected]>
Date: Wed Jun 30 09:55:53 2010 -0700
609255 - fix coverity Defect Type: Memory - illegal accesses issues
https://bugzilla.redhat.com/show_bug.cgi?id=609255
12224 UNINIT Triaged Unassigned Bug Minor Fix Required
windows_private_update_dirsync_control() ds/ldap/servers/plugins/replication/windows_private.c
Comment:
If DIRSYNC control is not found, uninitialized ber is passed to
ber_free. We should init ber to NULL.
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
index 8ba8b5c3e..b5bcabff8 100644
--- a/ldap/servers/plugins/replication/windows_private.c
+++ b/ldap/servers/plugins/replication/windows_private.c
@@ -582,7 +582,7 @@ void windows_private_update_dirsync_control(const Repl_Agmt *ra,LDAPControl **co
int foundDirsyncControl;
int i;
LDAPControl *dirsync = NULL;
- BerElement *ber;
+ BerElement *ber = NULL;
ber_int_t hasMoreData;
ber_int_t maxAttributeCount;
BerValue *serverCookie;
| 0 |
cef82090cc3ece1a72c2ec1b62205b1f68b1074f
|
389ds/389-ds-base
|
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit f25c7f1f988783d620171f7b648f946dc6704c81.
|
commit cef82090cc3ece1a72c2ec1b62205b1f68b1074f
Author: Noriko Hosoi <[email protected]>
Date: Wed Jul 9 16:07:34 2014 -0700
Revert "Ticket #47835 - Coverity: 12687..12692"
This reverts commit f25c7f1f988783d620171f7b648f946dc6704c81.
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index fd06dd42c..03738777c 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -75,7 +75,6 @@ main (int argc, char *argv[]) {
struct stat logdir_s;
pid_t child_pid;
FILE *pid_fp;
- long arg_max = 0;
/* Load options */
while ((--argc > 0) && ((*++argv)[0] == '-')) {
@@ -91,13 +90,11 @@ main (int argc, char *argv[]) {
}
}
- if ((argc != 1) || (NULL == *argv)) {
+ if (argc != 1)
exit_usage();
- }
/* load config file */
- arg_max = sysconf(_SC_ARG_MAX);
- if ((config_file = strndup(*argv, arg_max)) == NULL) {
+ if ((config_file = strdup(*argv)) == NULL) {
printf("ldap-agent: Memory error loading config file\n");
exit(1);
}
| 0 |
8fedec0f4f180b5e0ab6129f7a2bfe149dd014a1
|
389ds/389-ds-base
|
Issue 5495 - RFE - skip dds during migration. (#5496)
Bug Description: We don't directly support dynamic directory services
per openldap, so we need to skip these values in migration. The admin
must review these changes.
Fix Description: Skip the values.
fixes: https://github.com/389ds/389-ds-base/issues/5495
Author: William Brown <[email protected]>
Review by: @droideck @mreynolds389
|
commit 8fedec0f4f180b5e0ab6129f7a2bfe149dd014a1
Author: Firstyear <[email protected]>
Date: Fri Oct 21 11:57:25 2022 +1000
Issue 5495 - RFE - skip dds during migration. (#5496)
Bug Description: We don't directly support dynamic directory services
per openldap, so we need to skip these values in migration. The admin
must review these changes.
Fix Description: Skip the values.
fixes: https://github.com/389ds/389-ds-base/issues/5495
Author: William Brown <[email protected]>
Review by: @droideck @mreynolds389
diff --git a/src/lib389/lib389/migrate/plan.py b/src/lib389/lib389/migrate/plan.py
index 11cc84845..d31a10dea 100644
--- a/src/lib389/lib389/migrate/plan.py
+++ b/src/lib389/lib389/migrate/plan.py
@@ -101,6 +101,7 @@ class ImportTransformer(LDIFParser):
def __init__(self, f_import, f_outport, exclude_attributes_set, exclude_objectclass_set):
self.exclude_attributes_set = exclude_attributes_set
# Already all lowered by the db ldif import
+
self.exclude_objectclass_set = exclude_objectclass_set
self.f_outport = f_outport
self.writer = LDIFWriter(self.f_outport)
@@ -540,6 +541,14 @@ class Migration(object):
'1.3.6.1.4.1.42.2.27.8.1.13', # pwdMustChange
'1.3.6.1.4.1.42.2.27.8.1.14', # pwdAllowUserChange
'1.3.6.1.4.1.42.2.27.8.2.1', # pwdPolicy objectClass
+ # Openldap supplies some schema which conflicts to ours, skip them
+ 'NetscapeLDAPattributeType:198', # memberUrl
+ 'NetscapeLDAPobjectClass:33', # groupOfURLs
+
+ # Dynamic Directory Services can't be supported due to missing syntax oid below, so we
+ # exclude the "otherwise" supported attrs / ocs
+ 'DynGroupAttr:1', # dgIdentity
+ 'DynGroupOC:1', # dgIdentityAux
] + skip_schema_oids)
self._schema_oid_unsupported = set([
# RFC4517 othermailbox syntax is not supported on 389.
@@ -561,6 +570,9 @@ class Migration(object):
'1.3.6.1.4.1.42.2.27.8.1.15', # pwdSafeModify
'1.3.6.1.4.1.4754.1.99.1', # pwdCheckModule
'1.3.6.1.4.1.42.2.27.8.1.30', # pwdMaxRecordedFailure
+ # OpenLDAP dynamic directory services defines an internal
+ # oid ( 1.3.6.1.4.1.4203.666.2.7 )for dynamic group authz, but has very little docs about this.
+ 'DynGroupAttr:2', # dgAuthz
])
self._skip_entry_attributes = set(
@@ -574,12 +586,17 @@ class Migration(object):
'pwdsafemodify',
'pwdcheckmodule',
'pwdmaxrecordedfailure',
+ # dds attributes we don't support
+ 'dgidentity',
+ 'dgauthz'
] +
[x.lower() for x in skip_entry_attributes]
)
- self._skip_entry_objectclasses = set(
+ # These tend to be be from overlays we don't support
+ self._skip_entry_objectclasses = set([
'pwdpolicy',
- )
+ 'dgidentityaux'
+ ])
self._gen_migration_plan()
| 0 |
d3ba228724f4be5039256f5ec9290d6357ff6b7f
|
389ds/389-ds-base
|
Ticket 49527 - Improve ds* cli tool testing
Bug Description: As we get closer to release it's important
our tests work correctly and are comprehensive.
Fix Description: Improve the directory manager test, backend test
user test and correct some incompatability with memberof test.
https://pagure.io/389-ds-base/issue/49527
Author: wibrown
Review by: mreynolds, spichugi (Thanks!)
|
commit d3ba228724f4be5039256f5ec9290d6357ff6b7f
Author: William Brown <[email protected]>
Date: Wed Jan 10 09:59:23 2018 +1000
Ticket 49527 - Improve ds* cli tool testing
Bug Description: As we get closer to release it's important
our tests work correctly and are comprehensive.
Fix Description: Improve the directory manager test, backend test
user test and correct some incompatability with memberof test.
https://pagure.io/389-ds-base/issue/49527
Author: wibrown
Review by: mreynolds, spichugi (Thanks!)
diff --git a/src/lib389/cli/dsconf b/src/lib389/cli/dsconf
index ea1d056a8..b13183c67 100755
--- a/src/lib389/cli/dsconf
+++ b/src/lib389/cli/dsconf
@@ -19,6 +19,7 @@ logging.basicConfig(format='%(message)s')
from lib389 import DirSrv
from lib389._constants import DN_CONFIG, DN_DM
from lib389.cli_conf import backend as cli_backend
+from lib389.cli_conf import directory_manager as cli_directory_manager
from lib389.cli_conf import plugin as cli_plugin
from lib389.cli_conf import schema as cli_schema
from lib389.cli_conf import health as cli_health
@@ -65,6 +66,7 @@ if __name__ == '__main__':
subparsers = parser.add_subparsers(help="resources to act upon")
cli_backend.create_parser(subparsers)
+ cli_directory_manager.create_parsers(subparsers)
cli_schema.create_parser(subparsers)
cli_health.create_parser(subparsers)
cli_plugin.create_parser(subparsers)
@@ -109,10 +111,12 @@ if __name__ == '__main__':
if args.verbose:
inst = connect_instance(dsrc_inst=dsrc_inst, verbose=args.verbose)
args.func(inst, None, log, args)
+ log.info("Command successful.")
else:
try:
inst = connect_instance(dsrc_inst=dsrc_inst, verbose=args.verbose)
args.func(inst, None, log, args)
+ log.info("Command successful.")
except Exception as e:
log.debug(e, exc_info=True)
log.error("Error: %s" % e)
diff --git a/src/lib389/cli/dsctl b/src/lib389/cli/dsctl
index 36ecf99ee..02a1cffa1 100755
--- a/src/lib389/cli/dsctl
+++ b/src/lib389/cli/dsctl
@@ -80,9 +80,11 @@ if __name__ == '__main__':
if args.verbose:
result = args.func(inst, log, args)
+ log.info("Command successful.")
else:
try:
result = args.func(inst, log, args)
+ log.info("Command successful.")
except Exception as e:
log.debug(e, exc_info=True)
log.error("Error: %s" % str(e))
diff --git a/src/lib389/cli/dsidm b/src/lib389/cli/dsidm
index 1cfc415c3..d6a43ab0f 100755
--- a/src/lib389/cli/dsidm
+++ b/src/lib389/cli/dsidm
@@ -101,10 +101,12 @@ if __name__ == '__main__':
if args.verbose:
inst = connect_instance(dsrc_inst=dsrc_inst, verbose=args.verbose)
args.func(inst, dsrc_inst['basedn'], log, args)
+ log.info("Command successful.")
else:
try:
inst = connect_instance(dsrc_inst=dsrc_inst, verbose=args.verbose)
args.func(inst, dsrc_inst['basedn'], log, args)
+ log.info("Command successful.")
except Exception as e:
log.debug(e, exc_info=True)
log.error("Error: %s" % str(e))
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index fab1ed10f..b636ebbd5 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -3323,6 +3323,7 @@ class DirSrv(SimpleLDAPObject, object):
# This could be made to delete by filter ....
def delete_branch_s(self, basedn, scope):
ents = self.search_s(basedn, scope)
- for ent in ents:
+
+ for ent in sorted(ents, key=lambda e: len(e.dn), reverse=True):
self.log.debug("Delete entry children %s" % (ent.dn))
self.delete_s(ent.dn)
diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py
index 6161500bc..64ccd5642 100644
--- a/src/lib389/lib389/_mapped_object.py
+++ b/src/lib389/lib389/_mapped_object.py
@@ -225,7 +225,12 @@ class DSLdapObject(DSLogging):
values = self.get_attr_vals_bytes(attr)
self._log.debug("%s contains %s" % (self._dn, values))
- return ensure_bytes(value).lower() in [x.lower() for x in values]
+ if value is None:
+ # We are just checking if SOMETHING is present ....
+ return len(values) > 0
+ else:
+ # Check if a value really does exist.
+ return ensure_bytes(value).lower() in [x.lower() for x in values]
def add(self, key, value):
"""Add an attribute with a value
@@ -287,7 +292,10 @@ class DSLdapObject(DSLogging):
:type key: str
"""
- self.set(key, None, action=ldap.MOD_DELETE)
+ try:
+ self.set(key, None, action=ldap.MOD_DELETE)
+ except ldap.NO_SUCH_ATTRIBUTE:
+ pass
# maybe this could be renamed?
def set(self, key, value, action=ldap.MOD_REPLACE):
@@ -491,6 +499,21 @@ class DSLdapObject(DSLogging):
return ensure_str(self.get_attr_val(key))
+ def get_attr_val_utf8_l(self, key):
+ """Get a single attribute value from the entry in utf8 type
+
+ :param key: An attribute name
+ :type key: str
+ :returns: A single bytes value
+ :raises: ValueError - if instance is offline
+ """
+
+ x = self.get_attr_val(key)
+ if x is not None:
+ return ensure_str(x).lower()
+ else:
+ return None
+
def get_attr_vals_utf8(self, key):
"""Get attribute values from the entry in utf8 type
@@ -502,6 +525,17 @@ class DSLdapObject(DSLogging):
return ensure_list_str(self.get_attr_vals(key))
+ def get_attr_vals_utf8_l(self, key):
+ """Get attribute values from the entry in utf8 type and lowercase
+
+ :param key: An attribute name
+ :type key: str
+ :returns: A single bytes value
+ :raises: ValueError - if instance is offline
+ """
+
+ return [x.lower() for x in ensure_list_str(self.get_attr_vals(key))]
+
def get_attr_val_int(self, key):
"""Get a single attribute value from the entry in int type
diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py
index 25a244c89..3fcaf07d1 100644
--- a/src/lib389/lib389/backend.py
+++ b/src/lib389/lib389/backend.py
@@ -516,7 +516,10 @@ class Backend(DSLdapObject):
self._instance.index.delete_all(bename)
# Now remove our children, this is all ldbm config
- self._instance.delete_branch_s(self._dn, ldap.SCOPE_ONELEVEL)
+
+ configs = self._instance.search_s(self._dn, ldap.SCOPE_ONELEVEL)
+ for c in configs:
+ self._instance.delete_branch_s(c.dn, ldap.SCOPE_SUBTREE)
# The super will actually delete ourselves.
super(Backend, self).delete()
diff --git a/src/lib389/lib389/cli_base/__init__.py b/src/lib389/lib389/cli_base/__init__.py
index 21bf3ccfe..4f5e7adb5 100644
--- a/src/lib389/lib389/cli_base/__init__.py
+++ b/src/lib389/lib389/cli_base/__init__.py
@@ -23,14 +23,17 @@ def _input(msg):
return raw_input(msg)
-def _get_arg(args, msg=None):
+def _get_arg(args, msg=None, hidden=False):
if args is not None and len(args) > 0:
if type(args) is list:
return args[0]
else:
return args
else:
- return _input("%s : " % msg)
+ if hidden:
+ return getpass("%s : " % msg)
+ else:
+ return _input("%s : " % msg)
def _get_args(args, kws):
kwargs = {}
@@ -50,8 +53,11 @@ def _get_args(args, kws):
def _get_attributes(args, attrs):
kwargs = {}
for attr in attrs:
- if args is not None and hasattr(args, attr) and getattr(args, attr) is not None:
- kwargs[attr] = getattr(args, attr)
+ # Python can't represent a -, so it replaces it to _
+ # in many places, so we have to normalise this.
+ attr_normal = attr.replace('-', '_')
+ if args is not None and hasattr(args, attr_normal) and getattr(args, attr_normal) is not None:
+ kwargs[attr] = getattr(args, attr_normal)
else:
if attr.lower() == 'userpassword':
kwargs[attr] = getpass("Enter value for %s : " % attr)
@@ -168,3 +174,6 @@ class FakeArgs(object):
def __init__(self):
pass
+ def __len__(self):
+ return len(self.__dict__.keys())
+
diff --git a/src/lib389/lib389/cli_conf/backend.py b/src/lib389/lib389/cli_conf/backend.py
index e99cc82c0..4437725ca 100644
--- a/src/lib389/lib389/cli_conf/backend.py
+++ b/src/lib389/lib389/cli_conf/backend.py
@@ -10,6 +10,7 @@ from lib389.backend import Backend, Backends
import argparse
from lib389.cli_base import (
+ populate_attr_arguments,
_generic_list,
_generic_get,
_generic_get_dn,
@@ -37,7 +38,7 @@ def backend_get_dn(inst, basedn, log, args):
_generic_get_dn(inst, basedn, log.getChild('backend_get_dn'), MANY, dn)
def backend_create(inst, basedn, log, args):
- kwargs = _get_attributes(args.extra, SINGULAR._must_attributes)
+ kwargs = _get_attributes(args, Backend._must_attributes)
_generic_create(inst, basedn, log.getChild('backend_create'), MANY, kwargs)
def backend_delete(inst, basedn, log, args, warn=True):
@@ -65,9 +66,7 @@ def create_parser(subparsers):
create_parser = subcommands.add_parser('create', help='create')
create_parser.set_defaults(func=backend_create)
- create_parser.add_argument('extra', nargs=argparse.REMAINDER,
- help='A create may take one or more extra arguments. This parameter provides them'
- )
+ populate_attr_arguments(create_parser, Backend._must_attributes)
delete_parser = subcommands.add_parser('delete', help='deletes the object')
delete_parser.set_defaults(func=backend_delete)
diff --git a/src/lib389/lib389/cli_conf/directory_manager.py b/src/lib389/lib389/cli_conf/directory_manager.py
new file mode 100644
index 000000000..56c3e73e0
--- /dev/null
+++ b/src/lib389/lib389/cli_conf/directory_manager.py
@@ -0,0 +1,35 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+from lib389.idm.directorymanager import DirectoryManager
+
+from lib389.cli_base import _get_arg
+
+import argparse
+
+def password_change(inst, basedn, log, args):
+ # Due to an issue, we can't use extended op, so we have to
+ # submit the password directly to the field.
+
+ password = _get_arg(args.password, msg="Enter new directory manager password", hidden=True)
+ dm = DirectoryManager(inst)
+ dm.change_password(password)
+
+def create_parsers(subparsers):
+ directory_manager_parser = subparsers.add_parser('directory_manager', help="Manage the directory manager account")
+
+ subcommands = directory_manager_parser.add_subparsers(help='action')
+
+ password_change_parser = subcommands.add_parser('password_change', help="Change the directory manager password")
+ password_change_parser.set_defaults(func=password_change)
+ # This is to put in a dummy attr that args can work with. We do this
+ # because the actual test case will over-ride it, but it prevents
+ # a user putting the pw on the cli.
+ password_change_parser.set_defaults(password=None)
+
+
diff --git a/src/lib389/lib389/cli_idm/user.py b/src/lib389/lib389/cli_idm/user.py
index 5b5786273..70e7148f4 100644
--- a/src/lib389/lib389/cli_idm/user.py
+++ b/src/lib389/lib389/cli_idm/user.py
@@ -43,11 +43,34 @@ def create(inst, basedn, log, args):
kwargs = _get_attributes(args, MUST_ATTRIBUTES)
_generic_create(inst, basedn, log.getChild('_generic_create'), MANY, kwargs)
-def delete(inst, basedn, log, args):
- dn = _get_arg( args, msg="Enter dn to delete")
- _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn))
+def delete(inst, basedn, log, args, warn=True):
+ dn = _get_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)
+def status(inst, basedn, log, args):
+ uid = _get_arg( args.uid, msg="Enter %s to check" % RDN)
+ uas = UserAccounts(inst, basedn)
+ acct = uas.get(uid)
+ acct_str = "locked: %s" % acct.is_locked()
+ log.info('uid: %s' % uid)
+ log.info(acct_str)
+
+def lock(inst, basedn, log, args):
+ uid = _get_arg( args.uid, msg="Enter %s to check" % RDN)
+ accounts = UserAccounts(inst, basedn)
+ acct = accounts.get(uid)
+ acct.lock()
+ log.info('locked %s' % uid)
+
+def unlock(inst, basedn, log, args):
+ uid = _get_arg( args.uid, msg="Enter %s to check" % RDN)
+ accounts = UserAccounts(inst, basedn)
+ acct = accounts.get(uid)
+ acct.unlock()
+ log.info('unlocked %s' % uid)
+
def create_parser(subparsers):
user_parser = subparsers.add_parser('user', help='Manage posix users')
@@ -72,5 +95,17 @@ def create_parser(subparsers):
delete_parser.set_defaults(func=delete)
delete_parser.add_argument('dn', nargs='?', help='The dn to delete')
+ lock_parser = subcommands.add_parser('lock', help='lock')
+ lock_parser.set_defaults(func=lock)
+ lock_parser.add_argument('uid', nargs='?', help='The uid to lock')
+
+ status_parser = subcommands.add_parser('status', help='status')
+ status_parser.set_defaults(func=status)
+ status_parser.add_argument('uid', nargs='?', help='The uid to check')
+
+ unlock_parser = subcommands.add_parser('unlock', help='unlock')
+ unlock_parser.set_defaults(func=unlock)
+ unlock_parser.add_argument('uid', nargs='?', help='The uid to unlock')
+
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/src/lib389/lib389/idm/directorymanager.py b/src/lib389/lib389/idm/directorymanager.py
index 4028fc64b..150a549bd 100644
--- a/src/lib389/lib389/idm/directorymanager.py
+++ b/src/lib389/lib389/idm/directorymanager.py
@@ -30,6 +30,9 @@ class DirectoryManager(Account):
self._create_objectclasses = None
self._protected = True
+ def change_password(self, new_password):
+ self._instance.config.set('nsslapd-rootpw', new_password)
+
def bind(self, password=PW_DM, *args, **kwargs):
"""Bind as the Directory Manager. We have a default test password
that can be overriden.
diff --git a/src/lib389/lib389/idm/nscontainer.py b/src/lib389/lib389/idm/nscontainer.py
new file mode 100644
index 000000000..5ea2aff41
--- /dev/null
+++ b/src/lib389/lib389/idm/nscontainer.py
@@ -0,0 +1,90 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017, Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+from lib389._mapped_object import DSLdapObject, DSLdapObjects
+
+class nsContainer(DSLdapObject):
+ """A single instance of a nsContainer. This is similar to OU
+ for organisation of a directory tree.
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: Entry DN
+ :type dn: str
+ """
+
+ def __init__(self, instance, dn=None):
+ super(nsContainer, self).__init__(instance, dn)
+ self._rdn_attribute = 'cn'
+ self._must_attributes = ['cn']
+ self._create_objectclasses = [
+ 'top',
+ 'nscontainer',
+ ]
+ self._protected = False
+
+class nsContainers(DSLdapObjects):
+ """The set of nsContainers on the server.
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param basedn: Base DN for all group entries below
+ :type basedn: str
+ """
+
+ def __init__(self, instance, basedn):
+ super(nsContainers, self).__init__(instance)
+ self._objectclasses = [
+ 'nscontainer',
+ ]
+ self._filterattrs = ['cn']
+ self._childobject = nsContainer
+ self._basedn = basedn
+
+class nsHiddenContainer(DSLdapObject):
+ """A single instance of a hidden container. This is a combination
+ of nsContainer and ldapsubentry.
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param dn: Entry DN
+ :type dn: str
+ """
+
+ def __init__(self, instance, dn=None):
+ super(nsHiddenContainer, self).__init__(instance, dn)
+ self._rdn_attribute = 'cn'
+ self._must_attributes = ['cn']
+ self._create_objectclasses = [
+ 'top',
+ 'nscontainer',
+ 'ldapsubentry',
+ ]
+ self._protected = False
+
+class nsHiddenContainers(DSLdapObjects):
+ """The set of nsHiddenContainers on the server.
+
+ :param instance: An instance
+ :type instance: lib389.DirSrv
+ :param basedn: Base DN for all group entries below
+ :type basedn: str
+ """
+
+ def __init__(self, instance, basedn):
+ super(nsHiddenContainers, self).__init__(instance)
+ self._objectclasses = [
+ 'nscontainer',
+ 'ldapsubentry',
+ ]
+ self._filterattrs = ['cn']
+ self._childobject = nsHiddenContainer
+ self._basedn = basedn
+
+
+
diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py
index e0080d61a..8180e7876 100644
--- a/src/lib389/lib389/plugins.py
+++ b/src/lib389/lib389/plugins.py
@@ -271,7 +271,7 @@ class MemberOfPlugin(Plugin):
self._must_attributes.extend(['memberOfGroupAttr', 'memberOfAttr'])
def get_attr(self):
- return self.get_attr_val('memberofattr')
+ return self.get_attr_val_utf8_l('memberofattr')
def get_attr_formatted(self):
return self.display_attr('memberofattr')
@@ -280,7 +280,7 @@ class MemberOfPlugin(Plugin):
self.set('memberofattr', attr)
def get_groupattr(self):
- return self.get_attr_vals('memberofgroupattr')
+ return self.get_attr_vals_utf8_l('memberofgroupattr')
def get_groupattr_formatted(self):
return self.display_attr('memberofgroupattr')
@@ -292,7 +292,7 @@ class MemberOfPlugin(Plugin):
self.remove('memberofgroupattr', attr)
def get_allbackends(self):
- return self.get_attr_val('memberofallbackends')
+ return self.get_attr_val_utf8_l('memberofallbackends')
def get_allbackends_formatted(self):
return self.display_attr('memberofallbackends')
@@ -304,7 +304,7 @@ class MemberOfPlugin(Plugin):
self.set('memberofallbackends', 'off')
def get_skipnested(self):
- return self.get_attr_val('memberofskipnested')
+ return self.get_attr_val_utf8_l('memberofskipnested')
def get_skipnested_formatted(self):
return self.display_attr('memberofskipnested')
@@ -316,7 +316,7 @@ class MemberOfPlugin(Plugin):
self.set('memberofskipnested', 'off')
def get_autoaddoc(self):
- return self.get_attr_val('memberofautoaddoc')
+ return self.get_attr_val_utf8_l('memberofautoaddoc')
def get_autoaddoc_formatted(self):
return self.display_attr('memberofautoaddoc')
@@ -328,7 +328,7 @@ class MemberOfPlugin(Plugin):
self.remove_all('memberofautoaddoc')
def get_entryscope(self, formatted=False):
- return self.get_attr_vals('memberofentryscope')
+ return self.get_attr_vals_utf8_l('memberofentryscope')
def get_entryscope_formatted(self):
return self.display_attr('memberofentryscope')
@@ -343,7 +343,7 @@ class MemberOfPlugin(Plugin):
self.remove_all('memberofentryscope')
def get_excludescope(self):
- return self.get_attr_vals('memberofentryscopeexcludesubtree')
+ return self.get_attr_vals_utf8_l('memberofentryscopeexcludesubtree')
def get_excludescope_formatted(self):
return self.display_attr('memberofentryscopeexcludesubtree')
@@ -768,7 +768,7 @@ class Plugins(DSLdapObjects):
# This is a map of plugin to type, so when we
# do a get / list / create etc, we can map to the correct
# instance.
- def __init__(self, instance):
+ def __init__(self, instance, basedn=None):
super(Plugins, self).__init__(instance=instance)
self._objectclasses = ['top', 'nsslapdplugin']
self._filterattrs = ['cn', 'nsslapd-pluginPath']
diff --git a/src/lib389/lib389/tests/cli/adm_instance_test.py b/src/lib389/lib389/tests/cli/adm_instance_test.py
index 1c3d829e4..d8d2f4140 100644
--- a/src/lib389/lib389/tests/cli/adm_instance_test.py
+++ b/src/lib389/lib389/tests/cli/adm_instance_test.py
@@ -14,7 +14,6 @@ from lib389 import DirSrv
from lib389.cli_base import LogCapture
-
def test_instance_list():
lc = LogCapture()
inst = DirSrv()
diff --git a/src/lib389/lib389/tests/cli/conf_backend_test.py b/src/lib389/lib389/tests/cli/conf_backend_test.py
index da8ec7370..3ed55aa9c 100644
--- a/src/lib389/lib389/tests/cli/conf_backend_test.py
+++ b/src/lib389/lib389/tests/cli/conf_backend_test.py
@@ -13,6 +13,9 @@ from lib389.cli_conf.backend import backend_list, backend_get, backend_get_dn, b
from lib389.cli_base import LogCapture, FakeArgs
from lib389.tests.cli import topology
+from lib389.utils import ds_is_older
+pytestmark = pytest.mark.skipif(ds_is_older('1.4.0'), reason="Not implemented")
+
# Topology is pulled from __init__.py
def test_backend_cli(topology):
#
@@ -23,7 +26,8 @@ def test_backend_cli(topology):
topology.logcap.flush()
# Add a backend
# We need to fake the args
- args.extra = ['dc=example,dc=com', 'userRoot']
+ args.cn = 'userRoot'
+ args.nsslapd_suffix = 'dc=example,dc=com'
backend_create(topology.standalone, None, topology.logcap.log, args)
# Assert one.
backend_list(topology.standalone, None, topology.logcap.log, None)
diff --git a/src/lib389/lib389/tests/cli/conf_directory_manager_test.py b/src/lib389/lib389/tests/cli/conf_directory_manager_test.py
new file mode 100644
index 000000000..96b0b1729
--- /dev/null
+++ b/src/lib389/lib389/tests/cli/conf_directory_manager_test.py
@@ -0,0 +1,22 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+import pytest
+
+from lib389.cli_conf.directory_manager import password_change
+
+from lib389.cli_base import LogCapture, FakeArgs
+from lib389.tests.cli import topology
+
+# Topology is pulled from __init__.py
+def test_directory_manager(topology):
+ #
+ args = FakeArgs()
+ args.password = 'password'
+ password_change(topology.standalone, None, topology.logcap.log, args)
+
diff --git a/src/lib389/lib389/tests/cli/conf_plugins/memberof_test.py b/src/lib389/lib389/tests/cli/conf_plugins/memberof_test.py
index 339138f38..903956d34 100644
--- a/src/lib389/lib389/tests/cli/conf_plugins/memberof_test.py
+++ b/src/lib389/lib389/tests/cli/conf_plugins/memberof_test.py
@@ -56,24 +56,24 @@ def test_set_attr_with_illegal_value(topology):
def test_set_groupattr_with_legal_value(topology):
args = FakeArgs()
- args.value = "uniqueMember"
+ args.value = "uniquemember"
memberof_cli.add_groupattr(topology.standalone, None, topology.logcap.log, args)
assert topology.logcap.contains("successfully added memberOfGroupAttr value")
topology.logcap.flush()
memberof_cli.display_groupattr(topology.standalone, None, topology.logcap.log, args)
- assert topology.logcap.contains(": uniqueMember")
+ assert topology.logcap.contains(": uniquemember")
topology.logcap.flush()
def test_set_groupattr_with_value_that_already_exists(topology):
plugin = MemberOfPlugin(topology.standalone)
# setup test
- if not "uniqueMember" in plugin.get_groupattr():
- plugin.add_groupattr("uniqueMember")
+ if not "uniquemember" in plugin.get_groupattr():
+ plugin.add_groupattr("uniquemember")
args = FakeArgs()
- args.value = "uniqueMember"
+ args.value = "uniquemember"
memberof_cli.add_groupattr(topology.standalone, None, topology.logcap.log, args)
assert topology.logcap.contains("already exists")
topology.logcap.flush()
@@ -89,18 +89,18 @@ def test_set_groupattr_with_illegal_value(topology):
def test_remove_groupattr_with_value_that_exists(topology):
plugin = MemberOfPlugin(topology.standalone)
# setup test
- if not "uniqueMember" in plugin.get_groupattr():
- plugin.add_groupattr("uniqueMember")
+ if not "uniquemember" in plugin.get_groupattr():
+ plugin.add_groupattr("uniquemember")
args = FakeArgs()
- args.value = "uniqueMember"
+ args.value = "uniquemember"
memberof_cli.remove_groupattr(topology.standalone, None, topology.logcap.log, args)
assert topology.logcap.contains("successfully removed memberOfGroupAttr value")
topology.logcap.flush()
memberof_cli.display_groupattr(topology.standalone, None, topology.logcap.log, args)
- assert not topology.logcap.contains(": uniqueMember")
+ assert not topology.logcap.contains(": uniquemember")
topology.logcap.flush()
def test_remove_groupattr_with_value_that_doesnt_exist(topology):
@@ -361,14 +361,14 @@ def test_get_excludescope_when_not_set(topology):
def test_add_excludescope_with_legal_value(topology):
args = FakeArgs()
- args.value = "ou=People,dc=example,dc=com"
+ args.value = "ou=people,dc=example,dc=com"
memberof_cli.add_excludescope(topology.standalone, None, topology.logcap.log, args)
assert topology.logcap.contains("successfully added memberOfEntryScopeExcludeSubtree value")
topology.logcap.flush()
args.value = None
memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args)
- assert topology.logcap.contains(": ou=People,dc=example,dc=com")
+ assert topology.logcap.contains(": ou=people,dc=example,dc=com")
topology.logcap.flush()
args.value = "a=b"
@@ -378,7 +378,7 @@ def test_add_excludescope_with_legal_value(topology):
args.value = None
memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args)
- assert topology.logcap.contains(": ou=People,dc=example,dc=com")
+ assert topology.logcap.contains(": ou=people,dc=example,dc=com")
assert topology.logcap.contains(": a=b")
topology.logcap.flush()
@@ -393,12 +393,12 @@ def test_add_excludescope_with_illegal_value(topology):
def test_add_excludescope_with_existing_value(topology):
plugin = MemberOfPlugin(topology.standalone)
# setup test
- if not "ou=People,dc=example,dc=com" in plugin.get_excludescope():
- plugin.add_excludescope("ou=People,dc=example,dc=com")
+ if not "ou=people,dc=example,dc=com" in plugin.get_excludescope():
+ plugin.add_excludescope("ou=people,dc=example,dc=com")
args = FakeArgs()
- args.value = "ou=People,dc=example,dc=com"
+ args.value = "ou=people,dc=example,dc=com"
memberof_cli.add_excludescope(topology.standalone, None, topology.logcap.log, args)
assert topology.logcap.contains('Value "{}" already exists'.format(args.value))
topology.logcap.flush()
@@ -408,8 +408,8 @@ def test_remove_excludescope_with_existing_value(topology):
# setup test
if not "a=b" in plugin.get_excludescope():
plugin.add_excludescope("a=b")
- if not "ou=People,dc=example,dc=com" in plugin.get_excludescope():
- plugin.add_excludescope("ou=People,dc=example,dc=com")
+ if not "ou=people,dc=example,dc=com" in plugin.get_excludescope():
+ plugin.add_excludescope("ou=people,dc=example,dc=com")
args = FakeArgs()
@@ -420,7 +420,7 @@ def test_remove_excludescope_with_existing_value(topology):
args.value = None
memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args)
- assert topology.logcap.contains(": ou=People,dc=example,dc=com")
+ assert topology.logcap.contains(": ou=people,dc=example,dc=com")
assert not topology.logcap.contains(": a=b")
topology.logcap.flush()
@@ -437,15 +437,15 @@ def test_remove_all_excludescope(topology):
# setup test
if not "a=b" in plugin.get_excludescope():
plugin.add_excludescope("a=b")
- if not "ou=People,dc=example,dc=com" in plugin.get_excludescope():
- plugin.add_excludescope("ou=People,dc=example,dc=com")
+ if not "ou=people,dc=example,dc=com" in plugin.get_excludescope():
+ plugin.add_excludescope("ou=people,dc=example,dc=com")
args = FakeArgs()
args.value = None
memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args)
assert topology.logcap.contains(": a=b")
- assert topology.logcap.contains(": ou=People,dc=example,dc=com")
+ assert topology.logcap.contains(": ou=people,dc=example,dc=com")
topology.logcap.flush()
args.value = None
@@ -456,7 +456,7 @@ def test_remove_all_excludescope(topology):
args.value = None
memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args)
assert not topology.logcap.contains(": a=b")
- assert not topology.logcap.contains(": ou=People,dc=example,dc=com")
+ assert not topology.logcap.contains(": ou=people,dc=example,dc=com")
topology.logcap.flush()
def test_add_entryscope_with_value_that_exists_in_excludescope(topology):
@@ -464,12 +464,12 @@ def test_add_entryscope_with_value_that_exists_in_excludescope(topology):
# setup test
if not "dc=example,dc=com" in plugin.get_entryscope():
plugin.add_entryscope("dc=example,dc=com")
- if not "ou=People,dc=example,dc=com" in plugin.get_excludescope():
- plugin.add_excludescope("ou=People,dc=example,dc=com")
+ if not "ou=people,dc=example,dc=com" in plugin.get_excludescope():
+ plugin.add_excludescope("ou=people,dc=example,dc=com")
args = FakeArgs()
- args.value = "ou=People,dc=example,dc=com"
+ args.value = "ou=people,dc=example,dc=com"
memberof_cli.add_scope(topology.standalone, None, topology.logcap.log, args)
assert topology.logcap.contains("is also listed as an exclude suffix")
topology.logcap.flush()
@@ -479,12 +479,12 @@ def test_add_excludescope_with_value_that_exists_in_entryscope(topology):
# setup test
if not "dc=example,dc=com" in plugin.get_entryscope():
plugin.add_entryscope("dc=example,dc=com")
- if not "ou=People,dc=example,dc=com" in plugin.get_excludescope():
- plugin.add_excludescope("ou=People,dc=example,dc=com")
+ if not "ou=people,dc=example,dc=com" in plugin.get_excludescope():
+ plugin.add_excludescope("ou=people,dc=example,dc=com")
args = FakeArgs()
- args.value = "ou=People,dc=example,dc=com"
+ args.value = "ou=people,dc=example,dc=com"
memberof_cli.add_scope(topology.standalone, None, topology.logcap.log, args)
assert topology.logcap.contains("is also listed as an exclude suffix")
topology.logcap.flush()
diff --git a/src/lib389/lib389/tests/cli/ctl_dbtasks_test.py b/src/lib389/lib389/tests/cli/ctl_dbtasks_test.py
index f2c31e51b..d77b72ea1 100644
--- a/src/lib389/lib389/tests/cli/ctl_dbtasks_test.py
+++ b/src/lib389/lib389/tests/cli/ctl_dbtasks_test.py
@@ -15,6 +15,9 @@ from lib389.cli_ctl.dbtasks import dbtasks_db2index, dbtasks_db2bak, dbtasks_db2
from lib389.cli_base import LogCapture, FakeArgs
from lib389.tests.cli import topology, topology_be_latest
+from lib389.utils import ds_is_older
+pytestmark = pytest.mark.skipif(ds_is_older('1.4.0'), reason="Not implemented")
+
def test_db2index(topology):
pass
diff --git a/src/lib389/lib389/tests/cli/idm_user_test.py b/src/lib389/lib389/tests/cli/idm_user_test.py
new file mode 100644
index 000000000..da579b4d0
--- /dev/null
+++ b/src/lib389/lib389/tests/cli/idm_user_test.py
@@ -0,0 +1,90 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+
+import pytest
+import ldap
+
+from lib389._constants import DEFAULT_SUFFIX, INSTALL_LATEST_CONFIG
+
+from lib389.cli_conf.backend import backend_create
+from lib389.cli_idm.initialise import initialise
+from lib389.cli_idm.user import get, create, delete, status, lock, unlock
+
+from lib389.cli_base import LogCapture, FakeArgs
+from lib389.tests.cli import topology
+
+from lib389.utils import ds_is_older
+pytestmark = pytest.mark.skipif(ds_is_older('1.4.0'), reason="Not implemented")
+
+# Topology is pulled from __init__.py
+def test_user_tasks(topology):
+ #
+ be_args = FakeArgs()
+
+ be_args.cn = 'userRoot'
+ be_args.nsslapd_suffix = DEFAULT_SUFFIX
+ backend_create(topology.standalone, None, topology.logcap.log, be_args)
+
+ # And add the skeleton objects.
+ init_args = FakeArgs()
+ init_args.version = INSTALL_LATEST_CONFIG
+ initialise(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, init_args)
+
+ # First check that our test user isn't there:
+ topology.logcap.flush()
+ u_args = FakeArgs()
+ u_args.selector = 'testuser'
+ with pytest.raises(ldap.NO_SUCH_OBJECT):
+ get(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args)
+
+ # Create the user
+ topology.logcap.flush()
+ u_args.cn = 'testuser'
+ u_args.uid = 'testuser'
+ u_args.sn = 'testuser'
+ u_args.homeDirectory = '/home/testuser'
+ u_args.uidNumber = '5000'
+ u_args.gidNumber = '5000'
+ create(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args)
+
+ assert(topology.logcap.contains("Sucessfully created testuser"))
+ # Assert they exist
+ topology.logcap.flush()
+ get(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args)
+ assert(topology.logcap.contains('dn: uid=testuser,ou=people,dc=example,dc=com'))
+
+ # Reset the password
+
+ # Lock the account, check status
+ topology.logcap.flush()
+ lock(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args)
+ assert(topology.logcap.contains('locked'))
+
+ topology.logcap.flush()
+ status(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args)
+ assert(topology.logcap.contains('locked: True'))
+
+ # Unlock check status
+ topology.logcap.flush()
+ unlock(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args)
+ assert(topology.logcap.contains('unlocked'))
+
+ topology.logcap.flush()
+ status(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args)
+ assert(topology.logcap.contains('locked: False'))
+
+ # Enroll a dummy cert
+
+ # Enroll a dummy sshkey
+
+ # Delete it
+ topology.logcap.flush()
+ u_args.dn = 'uid=testuser,ou=people,dc=example,dc=com'
+ delete(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args, warn=False)
+ assert(topology.logcap.contains('Sucessfully deleted uid=testuser,ou=people,dc=example,dc=com'))
+
diff --git a/src/lib389/lib389/tests/configurations/config_001003006_test.py b/src/lib389/lib389/tests/configurations/config_001003006_test.py
index 300122a9a..dfc8e8139 100644
--- a/src/lib389/lib389/tests/configurations/config_001003006_test.py
+++ b/src/lib389/lib389/tests/configurations/config_001003006_test.py
@@ -18,15 +18,10 @@ from lib389 import DirSrv
from lib389._constants import *
from lib389.properties import *
-DEBUGGING = os.getenv('DEBUGGING', default=False)
-if DEBUGGING:
- logging.getLogger(__name__).setLevel(logging.DEBUG)
-else:
- logging.getLogger(__name__).setLevel(logging.INFO)
-log = logging.getLogger(__name__)
+from lib389.topologies import topology_st
-### WARNING:
-# We can't use topology here, as we need to force python install!
+from lib389.utils import ds_is_older
+pytestmark = pytest.mark.skipif(ds_is_older('1.4.0'), reason="Not implemented")
REQUIRED_DNS = [
'dc=example,dc=com',
@@ -40,52 +35,6 @@ REQUIRED_DNS = [
'cn=Directory Administrators,dc=example,dc=com',
]
-class TopologyMain(object):
- def __init__(self, standalones=None, masters=None,
- consumers=None, hubs=None):
- if standalones:
- if isinstance(standalones, dict):
- self.ins = standalones
- else:
- self.standalone = standalones
- if masters:
- self.ms = masters
- if consumers:
- self.cs = consumers
- if hubs:
- self.hs = hubs
-
[email protected](scope="module")
-def topology_st(request):
- """Create DS standalone instance"""
-
- if DEBUGGING:
- standalone = DirSrv(verbose=True)
- else:
- standalone = DirSrv(verbose=False)
- args_instance[SER_HOST] = HOST_STANDALONE1
- args_instance[SER_PORT] = PORT_STANDALONE1
- # args_instance[SER_SECURE_PORT] = SECUREPORT_STANDALONE1
- args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE1
- args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
- args_standalone = args_instance.copy()
- standalone.allocate(args_standalone)
- instance_standalone = standalone.exists()
- if instance_standalone:
- standalone.delete()
- standalone.create(pyinstall=True, version='001003006')
- standalone.open()
-
- def fin():
- if DEBUGGING:
- standalone.stop()
- else:
- standalone.delete()
-
- request.addfinalizer(fin)
-
- return TopologyMain(standalones=standalone)
-
def test_install_sample_entries(topology_st):
# Assert that our entries match.
| 0 |
a5419366ada4b10b245306e809f5805ba9adacd7
|
389ds/389-ds-base
|
Ticket #47359 - new ldap connections can block ldaps and ldapi connections
https://fedorahosted.org/389/ticket/47359
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Fix more build breakage in previous commit
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit a5419366ada4b10b245306e809f5805ba9adacd7
Author: Rich Megginson <[email protected]>
Date: Tue May 21 17:30:50 2013 -0600
Ticket #47359 - new ldap connections can block ldaps and ldapi connections
https://fedorahosted.org/389/ticket/47359
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Fix more build breakage in previous commit
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 56069d0d0..7791f819f 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -140,7 +140,7 @@ void disk_monitoring_stop();
typedef struct listener_info {
int idx; /* index of this listener in the ct->fd array */
- PRFileDesc *listenpr; /* the listener fd */
+ PRFileDesc *listenfd; /* the listener fd */
int secure;
int local;
} listener_info;
@@ -966,7 +966,6 @@ void slapd_daemon( daemon_ports_t *ports )
int s_tcps_native = 0;
PRFileDesc *s_tcps = NULL;
#else
- PRFileDesc *tcps = 0;
PRFileDesc **n_tcps = NULL;
PRFileDesc **s_tcps = NULL;
PRFileDesc **i_unix = NULL;
@@ -1169,9 +1168,6 @@ void slapd_daemon( daemon_ports_t *ports )
int oserr;
#endif
int select_return = 0;
- int secure = 0; /* is a new connection an SSL one ? */
- int local = 0; /* is new connection an ldapi one? */
- int i;
#ifndef _WIN32
PRErrorCode prerr;
| 0 |
74e81521ccc3913e8672cdd5713f832a2c6a09c3
|
389ds/389-ds-base
|
Bug 700145 - userpasswd not replicating
https://bugzilla.redhat.com/show_bug.cgi?id=700145
Resolves: bug 700145
Bug Description: userpasswd not replicating
Reviewed by: nkinder, nhosoi (Thanks!)
Branch: master
Fix Description: The problem is happening because we are replicating
the unhashed#user#password attribute. The consumer gets this sequence:
delete: unhashed#user#password
-
add: unhashed#user#password
unhashed#user#password: value
The code in entry_wsi_apply_mod attempts to apply the delete, but since the
attribute does not exist, it returns LDAP_NO_SUCH_ATTRIBUTE and the entire
modify operation is rejected. The server removes unhashed#user#password before
doing database operations in the non-replicated case, but in the replicated
case it is assumed we can just apply the operations as they are given by the
supplier. pw_change is never set in the replicated case, so the consumer
never removes unhashed#user#password. The solution is to just remove
unhashed#user#password even if pw_change is not set. If the attribute is
not in the mods list, remove_mod is a no-op.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit 74e81521ccc3913e8672cdd5713f832a2c6a09c3
Author: Rich Megginson <[email protected]>
Date: Fri Apr 29 15:44:04 2011 -0600
Bug 700145 - userpasswd not replicating
https://bugzilla.redhat.com/show_bug.cgi?id=700145
Resolves: bug 700145
Bug Description: userpasswd not replicating
Reviewed by: nkinder, nhosoi (Thanks!)
Branch: master
Fix Description: The problem is happening because we are replicating
the unhashed#user#password attribute. The consumer gets this sequence:
delete: unhashed#user#password
-
add: unhashed#user#password
unhashed#user#password: value
The code in entry_wsi_apply_mod attempts to apply the delete, but since the
attribute does not exist, it returns LDAP_NO_SUCH_ATTRIBUTE and the entire
modify operation is rejected. The server removes unhashed#user#password before
doing database operations in the non-replicated case, but in the replicated
case it is assumed we can just apply the operations as they are given by the
supplier. pw_change is never set in the replicated case, so the consumer
never removes unhashed#user#password. The solution is to just remove
unhashed#user#password even if pw_change is not set. If the attribute is
not in the mods list, remove_mod is a no-op.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index 2eafcf617..219ac7214 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -873,9 +873,11 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
/* Remove the unhashed password pseudo-attribute prior */
/* to db access */
- if (pw_change)
- {
- slapi_mods_init_passin (&smods, mods);
+ slapi_mods_init_passin (&smods, mods);
+ if (!unhashed_pw_attr) {
+ unhashed_pw_attr = slapi_attr_syntax_normalize(PSEUDO_ATTR_UNHASHEDUSERPASSWORD);
+ }
+ if (slapi_mods_get_num_mods(&smods)) {
remove_mod (&smods, unhashed_pw_attr, &unhashed_pw_smod);
slapi_pblock_set (pb, SLAPI_MODIFY_MODS,
(void*)slapi_mods_get_ldapmods_passout (&smods));
@@ -936,8 +938,9 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
}
slapi_pblock_set (pb, SLAPI_MODIFY_MODS,
(void*)slapi_mods_get_ldapmods_passout (&smods));
- slapi_mods_done(&unhashed_pw_smod); /* can finalize now */
}
+ slapi_mods_done(&unhashed_pw_smod); /* can finalize now */
+
slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, &rc);
plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN :
| 0 |
4f410d762b008da8e2e43e29100c2c04ff332fbb
|
389ds/389-ds-base
|
openldap ber_init will assert if the bv->bv_val is NULL
Have to ensure that all usage of ber_init in the server checks to see if
the bv->bv_val is non-NULL before using ber_init, and return the appropriate
error if it is NULL
Also fixed a problem in dna_extend_exop - would not send the ldap result to
the client in certain error conditions
Reviewed by: nhosoi (Thanks!)
Tested on: RHEL5 x86_64
|
commit 4f410d762b008da8e2e43e29100c2c04ff332fbb
Author: Rich Megginson <[email protected]>
Date: Fri Oct 1 16:38:04 2010 -0600
openldap ber_init will assert if the bv->bv_val is NULL
Have to ensure that all usage of ber_init in the server checks to see if
the bv->bv_val is non-NULL before using ber_init, and return the appropriate
error if it is NULL
Also fixed a problem in dna_extend_exop - would not send the ldap result to
the client in certain error conditions
Reviewed by: nhosoi (Thanks!)
Tested on: RHEL5 x86_64
diff --git a/ldap/servers/plugins/acl/aclproxy.c b/ldap/servers/plugins/acl/aclproxy.c
index 9b28489ac..46eb437a6 100644
--- a/ldap/servers/plugins/acl/aclproxy.c
+++ b/ldap/servers/plugins/acl/aclproxy.c
@@ -98,6 +98,10 @@ parse_LDAPProxyAuth(struct berval *spec_ber, int version, char **errtextp,
break;
}
+ if ( !spec_ber || !spec_ber->bv_val ) {
+ break;
+ }
+
/* create_LDAPProxyAuth */
spec = (LDAPProxyAuth*)slapi_ch_calloc(1,sizeof (LDAPProxyAuth));
if (!spec) {
diff --git a/ldap/servers/plugins/chainingdb/cb_controls.c b/ldap/servers/plugins/chainingdb/cb_controls.c
index f6b0653ac..8416c0a56 100644
--- a/ldap/servers/plugins/chainingdb/cb_controls.c
+++ b/ldap/servers/plugins/chainingdb/cb_controls.c
@@ -221,7 +221,8 @@ int cb_update_controls( Slapi_PBlock * pb,
dCount++;
} else
- if (!strcmp(reqControls[cCount]->ldctl_oid,CB_LDAP_CONTROL_CHAIN_SERVER)) {
+ if (!strcmp(reqControls[cCount]->ldctl_oid,CB_LDAP_CONTROL_CHAIN_SERVER) &&
+ reqControls[cCount]->ldctl_value.bv_val) {
/* Max hop count reached ? */
/* Checked earlier by a call to cb_forward_operation() */
diff --git a/ldap/servers/plugins/chainingdb/cb_utils.c b/ldap/servers/plugins/chainingdb/cb_utils.c
index 4878e1a81..cfa19a16f 100644
--- a/ldap/servers/plugins/chainingdb/cb_utils.c
+++ b/ldap/servers/plugins/chainingdb/cb_utils.c
@@ -147,7 +147,8 @@ int cb_forward_operation(Slapi_PBlock * pb ) {
struct berval *ctl_value=NULL;
int iscritical=0;
- if (slapi_control_present(ctrls,CB_LDAP_CONTROL_CHAIN_SERVER,&ctl_value,&iscritical)) {
+ if (slapi_control_present(ctrls,CB_LDAP_CONTROL_CHAIN_SERVER,&ctl_value,&iscritical) &&
+ ctl_value && ctl_value->bv_val) {
/* Decode control data */
/* hop INTEGER (0 .. maxInt) */
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
index e7fdaa5cb..fb6a54a3e 100644
--- a/ldap/servers/plugins/deref/deref.c
+++ b/ldap/servers/plugins/deref/deref.c
@@ -380,6 +380,12 @@ deref_parse_ctrl_value(DerefSpecList *speclist, const struct berval *ctrlbv, int
PR_ASSERT(ctrlbv && ctrlbv->bv_val && ctrlbv->bv_len && ldapcode && ldaperrtext);
+ if (!ctrlbv || !ctrlbv->bv_val) {
+ *ldapcode = LDAP_PROTOCOL_ERROR;
+ *ldaperrtext = "Empty deref control value";
+ return;
+ }
+
ber = ber_init((struct berval *)ctrlbv);
for (tag = ber_first_element(ber, &len, &last);
(tag != LBER_ERROR) && (tag != LBER_END_OF_SEQORSET);
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index e60f3714a..5419409bb 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1602,7 +1602,7 @@ static int dna_request_range(struct configEntry *config_entry,
}
/* Parse response */
- if (responsedata) {
+ if (responsedata && responsedata->bv_val) {
respber = ber_init(responsedata);
if (ber_scanf(respber, "{aa}", &lower_str, &upper_str) == LBER_ERROR) {
ret = LDAP_PROTOCOL_ERROR;
@@ -3123,7 +3123,7 @@ static int dna_config_check_post_op(Slapi_PBlock * pb)
***************************************************/
static int dna_extend_exop(Slapi_PBlock *pb)
{
- int ret = -1;
+ int ret = SLAPI_PLUGIN_EXTENDED_NOT_HANDLED;
struct berval *reqdata = NULL;
BerElement *tmp_bere = NULL;
char *shared_dn = NULL;
@@ -3152,20 +3152,19 @@ static int dna_extend_exop(Slapi_PBlock *pb)
/* Fetch the request data */
slapi_pblock_get(pb, SLAPI_EXT_OP_REQ_VALUE, &reqdata);
- if (!reqdata) {
+ if (!reqdata || !reqdata->bv_val) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_extend_exop: No request data received.\n");
goto free_and_return;
}
/* decode the exop */
- if ((tmp_bere = ber_init(reqdata)) == NULL) {
- ret = -1;
+ if ((reqdata->bv_val == NULL) || (tmp_bere = ber_init(reqdata)) == NULL) {
goto free_and_return;
}
if (ber_scanf(tmp_bere, "{a}", &shared_dn) == LBER_ERROR) {
- ret = -1;
+ ret = LDAP_PROTOCOL_ERROR;
goto free_and_return;
}
diff --git a/ldap/servers/plugins/replication/repl5_total.c b/ldap/servers/plugins/replication/repl5_total.c
index d2987cdb9..99ba838a5 100644
--- a/ldap/servers/plugins/replication/repl5_total.c
+++ b/ldap/servers/plugins/replication/repl5_total.c
@@ -729,7 +729,7 @@ decode_total_update_extop(Slapi_PBlock *pb, Slapi_Entry **ep)
if (NULL == extop_oid ||
((strcmp(extop_oid, REPL_NSDS50_REPLICATION_ENTRY_REQUEST_OID) != 0) &&
(strcmp(extop_oid, REPL_NSDS71_REPLICATION_ENTRY_REQUEST_OID) != 0)) ||
- NULL == extop_value)
+ NULL == extop_value || NULL == extop_value->bv_val)
{
/* Bogus */
goto loser;
diff --git a/ldap/servers/plugins/replication/repl_controls.c b/ldap/servers/plugins/replication/repl_controls.c
index cfd980fdc..980bdd898 100644
--- a/ldap/servers/plugins/replication/repl_controls.c
+++ b/ldap/servers/plugins/replication/repl_controls.c
@@ -216,7 +216,7 @@ decode_NSDS50ReplUpdateInfoControl(LDAPControl **controlsp,
if (slapi_control_present(controlsp, REPL_NSDS50_UPDATE_INFO_CONTROL_OID,
&ctl_value, &iscritical))
{
- if ((tmp_bere = ber_init(ctl_value)) == NULL)
+ if ((ctl_value->bv_val == NULL) || (tmp_bere = ber_init(ctl_value)) == NULL)
{
rc = -1;
goto loser;
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index 527c964e8..38af8ab8f 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -342,7 +342,7 @@ decode_startrepl_extop(Slapi_PBlock *pb, char **protocol_oid, char **repl_root,
if (NULL == extop_oid ||
((strcmp(extop_oid, REPL_START_NSDS50_REPLICATION_REQUEST_OID) != 0) &&
(strcmp(extop_oid, REPL_START_NSDS90_REPLICATION_REQUEST_OID) != 0)) ||
- NULL == extop_value)
+ NULL == extop_value || NULL == extop_value->bv_val)
{
/* bogus */
rc = -1;
@@ -478,7 +478,7 @@ decode_endrepl_extop(Slapi_PBlock *pb, char **repl_root)
if (NULL == extop_oid ||
strcmp(extop_oid, REPL_END_NSDS50_REPLICATION_REQUEST_OID) != 0 ||
- NULL == extop_value)
+ NULL == extop_value || NULL == extop_value->bv_val)
{
/* bogus */
rc = -1;
@@ -542,7 +542,7 @@ decode_repl_ext_response(struct berval *bvdata, int *response_code,
PR_ASSERT(NULL != ruv_bervals);
if (NULL == bvdata || NULL == response_code || NULL == ruv_bervals ||
- NULL == data_guid || NULL == data)
+ NULL == data_guid || NULL == data || NULL == bvdata->bv_val)
{
return_value = -1;
}
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
index f2bf031e9..9ad7681ae 100644
--- a/ldap/servers/plugins/replication/windows_private.c
+++ b/ldap/servers/plugins/replication/windows_private.c
@@ -609,6 +609,12 @@ void windows_private_update_dirsync_control(const Repl_Agmt *ra,LDAPControl **co
{
#ifdef FOR_DEBUGGING
return_value = LDAP_CONTROL_NOT_FOUND;
+#endif
+ goto choke;
+ }
+ else if (!controls[i-1]->ldctl_value.bv_val) {
+#ifdef FOR_DEBUGGING
+ return_value = LDAP_CONTROL_NOT_FOUND;
#endif
goto choke;
}
diff --git a/ldap/servers/slapd/back-ldbm/sort.c b/ldap/servers/slapd/back-ldbm/sort.c
index 10d441703..7a2a9c972 100644
--- a/ldap/servers/slapd/back-ldbm/sort.c
+++ b/ldap/servers/slapd/back-ldbm/sort.c
@@ -299,6 +299,10 @@ int parse_sort_spec(struct berval *sort_spec_ber, sort_spec **ps)
char *matchrule = NULL;
int rc = LDAP_SUCCESS;
+ if (NULL == sort_spec_ber->bv_val) {
+ return LDAP_PROTOCOL_ERROR;
+ }
+
ber = ber_init(sort_spec_ber);
if(ber==NULL)
{
diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
index 163d8a649..c68ce6429 100644
--- a/ldap/servers/slapd/back-ldbm/vlv.c
+++ b/ldap/servers/slapd/back-ldbm/vlv.c
@@ -1846,6 +1846,12 @@ vlv_parse_request_control( backend *be, struct berval *vlv_spec_ber,struct vlv_r
vlvp->value.bv_len = 0;
vlvp->value.bv_val = NULL;
+ if (NULL == vlv_spec_ber->bv_val)
+ {
+ return_value= LDAP_OPERATIONS_ERROR;
+ return return_value;
+ }
+
ber = ber_init(vlv_spec_ber);
if (ber_scanf(ber, "{ii", &vlvp->beforeCount, &vlvp->afterCount) == LBER_ERROR)
{
diff --git a/ldap/servers/slapd/passwd_extop.c b/ldap/servers/slapd/passwd_extop.c
index ff2e19f30..e22a52d41 100644
--- a/ldap/servers/slapd/passwd_extop.c
+++ b/ldap/servers/slapd/passwd_extop.c
@@ -527,6 +527,16 @@ passwd_modify_extop( Slapi_PBlock *pb )
/* Get the ber value of the extended operation */
slapi_pblock_get(pb, SLAPI_EXT_OP_REQ_VALUE, &extop_value);
+
+ if (extop_value->bv_val == NULL)
+ {
+ /* The request field wasn't provided. We'll
+ * now try to determine the userid and verify
+ * knowledge of the old password via other
+ * means.
+ */
+ goto parse_req_done;
+ }
if ((ber = ber_init(extop_value)) == NULL)
{
| 0 |
dde5b629534c87b4e49f39df32190c05ba941a87
|
389ds/389-ds-base
|
Ticket 48746: Crash when indexing an attribute with a matching rule
Bug Description:
When creating a mr_indexer, we first look at the registered MR (global_mr_oids).
If the indexer is not registered or have no indexer create function, we try
- to find a plugin (possibly a custom one) that could provide such indexer create.
- use a default indexer
The problem is that going through the matching rule plugins, we pick the first one with
an indexer even if it applies to a different syntax.
For example, searching for an caseExactIA5Match MR plugin we select caseIgnoreIA5Match because
it appears first in the plugins list.
The consequence is that we may index with the wrong index function (and trigger
https://fedorahosted.org/389/ticket/48745) and picking a wrong indexer_create (or filter_create)
function the MR private in the pblock (SLAPI_PLUGIN_OBJECT) can be NULL
(https://fedorahosted.org/389/ticket/48746).
Also we can imagine an incorrect custom MR plugin that forgets to set this MR private object
and could trigger a crash. So use of MR private object should check if it was set.
Fix Description:
The fix is:
slapi_mr_indexer_create:
plugin_mr_filter_create:
If there is no register MR for a specific oid, we search a plugin
that can handle that oid (plugin_mr_find).
mr_wrap_mr_index_sv_fn:
mr_wrap_mr_index_fn:
default_mr_filter_match:
default_mr_filter_index:
hardening if a custom plugin index_create function did not set SLAPI_PLUGIN_OBJECT
https://fedorahosted.org/389/ticket/48746
Reviewed by: Rich Megginson (thanks Rich for all help/feedback and the review)
Platforms tested: F17
Flag Day: no
Doc impact: no
|
commit dde5b629534c87b4e49f39df32190c05ba941a87
Author: Thierry Bordaz <[email protected]>
Date: Wed Mar 2 18:13:41 2016 +0100
Ticket 48746: Crash when indexing an attribute with a matching rule
Bug Description:
When creating a mr_indexer, we first look at the registered MR (global_mr_oids).
If the indexer is not registered or have no indexer create function, we try
- to find a plugin (possibly a custom one) that could provide such indexer create.
- use a default indexer
The problem is that going through the matching rule plugins, we pick the first one with
an indexer even if it applies to a different syntax.
For example, searching for an caseExactIA5Match MR plugin we select caseIgnoreIA5Match because
it appears first in the plugins list.
The consequence is that we may index with the wrong index function (and trigger
https://fedorahosted.org/389/ticket/48745) and picking a wrong indexer_create (or filter_create)
function the MR private in the pblock (SLAPI_PLUGIN_OBJECT) can be NULL
(https://fedorahosted.org/389/ticket/48746).
Also we can imagine an incorrect custom MR plugin that forgets to set this MR private object
and could trigger a crash. So use of MR private object should check if it was set.
Fix Description:
The fix is:
slapi_mr_indexer_create:
plugin_mr_filter_create:
If there is no register MR for a specific oid, we search a plugin
that can handle that oid (plugin_mr_find).
mr_wrap_mr_index_sv_fn:
mr_wrap_mr_index_fn:
default_mr_filter_match:
default_mr_filter_index:
hardening if a custom plugin index_create function did not set SLAPI_PLUGIN_OBJECT
https://fedorahosted.org/389/ticket/48746
Reviewed by: Rich Megginson (thanks Rich for all help/feedback and the review)
Platforms tested: F17
Flag Day: no
Doc impact: no
diff --git a/dirsrvtests/tests/tickets/ticket48745_test.py b/dirsrvtests/tests/tickets/ticket48745_test.py
new file mode 100644
index 000000000..bfbaf03f1
--- /dev/null
+++ b/dirsrvtests/tests/tickets/ticket48745_test.py
@@ -0,0 +1,185 @@
+import os
+import sys
+import time
+import ldap
+import logging
+#import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+NEW_ACCOUNT = "new_account"
+MAX_ACCOUNTS = 20
+
+MIXED_VALUE="/home/mYhOmEdIrEcToRy"
+LOWER_VALUE="/home/myhomedirectory"
+HOMEDIRECTORY_INDEX = 'cn=homeDirectory,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config'
+HOMEDIRECTORY_CN="homedirectory"
+MATCHINGRULE = 'nsMatchingRule'
+UIDNUMBER_INDEX = 'cn=uidnumber,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config'
+UIDNUMBER_CN="uidnumber"
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
[email protected](scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ #request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+def test_ticket48745_init(topology):
+ log.info("Initialization: add dummy entries for the tests")
+ for cpt in range(MAX_ACCOUNTS):
+ name = "%s%d" % (NEW_ACCOUNT, cpt)
+ topology.standalone.add_s(Entry(("uid=%s,%s" % (name, SUFFIX), {
+ 'objectclass': "top posixAccount".split(),
+ 'uid': name,
+ 'cn': name,
+ 'uidnumber': str(111),
+ 'gidnumber': str(222),
+ 'homedirectory': "/home/tbordaz_%d" % cpt})))
+
+def test_ticket48745_homeDirectory_indexed_cis(topology):
+ log.info("\n\nindex homeDirectory in caseIgnoreIA5Match and caseExactIA5Match")
+ try:
+ ent = topology.standalone.getEntry(HOMEDIRECTORY_INDEX, ldap.SCOPE_BASE)
+ except ldap.NO_SUCH_OBJECT:
+ topology.standalone.add_s(Entry((HOMEDIRECTORY_INDEX, {
+ 'objectclass': "top nsIndex".split(),
+ 'cn': HOMEDIRECTORY_CN,
+ 'nsSystemIndex': 'false',
+ 'nsIndexType': 'eq'})))
+ #log.info("attach debugger")
+ #time.sleep(60)
+
+ IGNORE_MR_NAME='caseIgnoreIA5Match'
+ EXACT_MR_NAME='caseExactIA5Match'
+ mod = [(ldap.MOD_REPLACE, MATCHINGRULE, (IGNORE_MR_NAME, EXACT_MR_NAME))]
+ topology.standalone.modify_s(HOMEDIRECTORY_INDEX, mod)
+
+ #topology.standalone.stop(timeout=10)
+ log.info("successfully checked that filter with exact mr , a filter with lowercase eq is failing")
+ #assert topology.standalone.db2index(bename=DEFAULT_BENAME, suffixes=None, attrs=['homeDirectory'])
+ #topology.standalone.start(timeout=10)
+ args = {TASK_WAIT: True}
+ 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")
+
+ # Check if the MR configuration failure occurs
+ regex = re.compile("unknown or invalid matching rule")
+ while True:
+ line = file_obj.readline()
+ found = regex.search(line)
+ if ((line == '') or (found)):
+ break
+
+ if (found):
+ log.info("The configuration of a specific MR fails")
+ log.info(line)
+ assert 0
+
+def test_ticket48745_homeDirectory_mixed_value(topology):
+ # Set a homedirectory value with mixed case
+ name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX)
+ mod = [(ldap.MOD_REPLACE, 'homeDirectory', MIXED_VALUE)]
+ topology.standalone.modify_s(name, mod)
+
+def test_ticket48745_extensible_search_after_index(topology):
+ name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX)
+
+ # check with the exact stored value
+ log.info("Default: can retrieve an entry filter syntax with exact stored value")
+ ent = topology.standalone.getEntry(SUFFIX, ldap.SCOPE_SUBTREE, "(homeDirectory=%s)" % MIXED_VALUE)
+# log.info("attach debugger")
+# time.sleep(60)
+
+ # This search will fail because a
+ # subtree search with caseExactIA5Match will find a key
+ # where the value has been lowercase
+ log.info("Default: can retrieve an entry filter caseExactIA5Match with exact stored value")
+ ent = topology.standalone.getEntry(SUFFIX, ldap.SCOPE_SUBTREE, "(homeDirectory:caseExactIA5Match:=%s)" % MIXED_VALUE)
+ assert ent
+
+ # But do additional searches.. just for more tests
+ # check with a lower case value that is different from the stored value
+ log.info("Default: can not retrieve an entry filter syntax match with lowered stored value")
+ try:
+ ent = topology.standalone.getEntry(SUFFIX, ldap.SCOPE_SUBTREE, "(homeDirectory=%s)" % LOWER_VALUE)
+ assert ent is None
+ except ldap.NO_SUCH_OBJECT:
+ pass
+ log.info("Default: can not retrieve an entry filter caseExactIA5Match with lowered stored value")
+ try:
+ ent = topology.standalone.getEntry(SUFFIX, ldap.SCOPE_SUBTREE, "(homeDirectory:caseExactIA5Match:=%s)" % LOWER_VALUE)
+ assert ent is None
+ except ldap.NO_SUCH_OBJECT:
+ pass
+ log.info("Default: can retrieve an entry filter caseIgnoreIA5Match with lowered stored value")
+ ent = topology.standalone.getEntry(SUFFIX, ldap.SCOPE_SUBTREE, "(homeDirectory:caseIgnoreIA5Match:=%s)" % LOWER_VALUE)
+
+def test_ticket48745(topology):
+ """Write your testcase here...
+
+ Also, if you need any testcase initialization,
+ please, write additional fixture for that(include finalizer).
+ """
+
+ log.info('Test complete')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+# global installation1_prefix
+# installation1_prefix = None
+# topo = topology(True)
+# test_ticket48745_init(topo)
+#
+# test_ticket48745_homeDirectory_indexed_cis(topo)
+# test_ticket48745_homeDirectory_mixed_value(topo)
+# test_ticket48745_extensible_search_after_index(topo)
+
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket48746_test.py b/dirsrvtests/tests/tickets/ticket48746_test.py
new file mode 100644
index 000000000..5ee0b9e09
--- /dev/null
+++ b/dirsrvtests/tests/tickets/ticket48746_test.py
@@ -0,0 +1,213 @@
+import os
+import sys
+import time
+import ldap
+import logging
+#import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+NEW_ACCOUNT = "new_account"
+MAX_ACCOUNTS = 20
+
+MIXED_VALUE="/home/mYhOmEdIrEcToRy"
+LOWER_VALUE="/home/myhomedirectory"
+HOMEDIRECTORY_INDEX = 'cn=homeDirectory,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config'
+HOMEDIRECTORY_CN="homedirectory"
+MATCHINGRULE = 'nsMatchingRule'
+UIDNUMBER_INDEX = 'cn=uidnumber,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config'
+UIDNUMBER_CN="uidnumber"
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
[email protected](scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ #request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+def test_ticket48746_init(topology):
+ log.info("Initialization: add dummy entries for the tests")
+ for cpt in range(MAX_ACCOUNTS):
+ name = "%s%d" % (NEW_ACCOUNT, cpt)
+ topology.standalone.add_s(Entry(("uid=%s,%s" % (name, SUFFIX), {
+ 'objectclass': "top posixAccount".split(),
+ 'uid': name,
+ 'cn': name,
+ 'uidnumber': str(111),
+ 'gidnumber': str(222),
+ 'homedirectory': "/home/tbordaz_%d" % cpt})))
+
+def test_ticket48746_homeDirectory_indexed_cis(topology):
+ log.info("\n\nindex homeDirectory in caseIgnoreIA5Match and caseExactIA5Match")
+ try:
+ ent = topology.standalone.getEntry(HOMEDIRECTORY_INDEX, ldap.SCOPE_BASE)
+ except ldap.NO_SUCH_OBJECT:
+ topology.standalone.add_s(Entry((HOMEDIRECTORY_INDEX, {
+ 'objectclass': "top nsIndex".split(),
+ 'cn': HOMEDIRECTORY_CN,
+ 'nsSystemIndex': 'false',
+ 'nsIndexType': 'eq'})))
+ #log.info("attach debugger")
+ #time.sleep(60)
+
+ IGNORE_MR_NAME='caseIgnoreIA5Match'
+ EXACT_MR_NAME='caseExactIA5Match'
+ mod = [(ldap.MOD_REPLACE, MATCHINGRULE, (IGNORE_MR_NAME, EXACT_MR_NAME))]
+ topology.standalone.modify_s(HOMEDIRECTORY_INDEX, mod)
+
+ #topology.standalone.stop(timeout=10)
+ log.info("successfully checked that filter with exact mr , a filter with lowercase eq is failing")
+ #assert topology.standalone.db2index(bename=DEFAULT_BENAME, suffixes=None, attrs=['homeDirectory'])
+ #topology.standalone.start(timeout=10)
+ args = {TASK_WAIT: True}
+ 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")
+
+ # Check if the MR configuration failure occurs
+ regex = re.compile("unknown or invalid matching rule")
+ while True:
+ line = file_obj.readline()
+ found = regex.search(line)
+ if ((line == '') or (found)):
+ break
+
+ if (found):
+ log.info("The configuration of a specific MR fails")
+ log.info(line)
+ assert not found
+
+def test_ticket48746_homeDirectory_mixed_value(topology):
+ # Set a homedirectory value with mixed case
+ name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX)
+ mod = [(ldap.MOD_REPLACE, 'homeDirectory', MIXED_VALUE)]
+ topology.standalone.modify_s(name, mod)
+
+def test_ticket48746_extensible_search_after_index(topology):
+ name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX)
+
+ # check with the exact stored value
+# log.info("Default: can retrieve an entry filter syntax with exact stored value")
+# ent = topology.standalone.getEntry(name, ldap.SCOPE_BASE, "(homeDirectory=%s)" % MIXED_VALUE)
+# log.info("attach debugger")
+# time.sleep(60)
+
+ # This search is enought to trigger the crash
+ # because it loads a registered filter MR plugin that has no indexer create function
+ # following index will trigger the crash
+ log.info("Default: can retrieve an entry filter caseExactIA5Match with exact stored value")
+ ent = topology.standalone.getEntry(name, ldap.SCOPE_BASE, "(homeDirectory:caseExactIA5Match:=%s)" % MIXED_VALUE)
+
+
+
+def test_ticket48746_homeDirectory_indexed_ces(topology):
+ log.info("\n\nindex homeDirectory in caseExactIA5Match, this would trigger the crash")
+ try:
+ ent = topology.standalone.getEntry(HOMEDIRECTORY_INDEX, ldap.SCOPE_BASE)
+ except ldap.NO_SUCH_OBJECT:
+ topology.standalone.add_s(Entry((HOMEDIRECTORY_INDEX, {
+ 'objectclass': "top nsIndex".split(),
+ 'cn': HOMEDIRECTORY_CN,
+ 'nsSystemIndex': 'false',
+ 'nsIndexType': 'eq'})))
+# log.info("attach debugger")
+# time.sleep(60)
+
+ EXACT_MR_NAME='caseExactIA5Match'
+ mod = [(ldap.MOD_REPLACE, MATCHINGRULE, (EXACT_MR_NAME))]
+ topology.standalone.modify_s(HOMEDIRECTORY_INDEX, mod)
+
+ #topology.standalone.stop(timeout=10)
+ log.info("successfully checked that filter with exact mr , a filter with lowercase eq is failing")
+ #assert topology.standalone.db2index(bename=DEFAULT_BENAME, suffixes=None, attrs=['homeDirectory'])
+ #topology.standalone.start(timeout=10)
+ args = {TASK_WAIT: True}
+ 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")
+
+ # Check if the MR configuration failure occurs
+ regex = re.compile("unknown or invalid matching rule")
+ while True:
+ line = file_obj.readline()
+ found = regex.search(line)
+ if ((line == '') or (found)):
+ break
+
+ if (found):
+ log.info("The configuration of a specific MR fails")
+ log.info(line)
+ assert not found
+
+def test_ticket48746(topology):
+ """Write your testcase here...
+
+ Also, if you need any testcase initialization,
+ please, write additional fixture for that(include finalizer).
+ """
+
+ log.info('Test complete')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+# global installation1_prefix
+# installation1_prefix = None
+# topo = topology(True)
+# test_ticket48746_init(topo)
+#
+#
+# test_ticket48746_homeDirectory_indexed_cis(topo)
+# test_ticket48746_homeDirectory_mixed_value(topo)
+# test_ticket48746_extensible_search_after_index(topo)
+# # crash should occur here
+# test_ticket48746_homeDirectory_indexed_ces(topo)
+
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/ldap/servers/slapd/plugin_mr.c b/ldap/servers/slapd/plugin_mr.c
index 2ff63a685..0ff4b7827 100644
--- a/ldap/servers/slapd/plugin_mr.c
+++ b/ldap/servers/slapd/plugin_mr.c
@@ -165,44 +165,43 @@ slapi_mr_indexer_create (Slapi_PBlock* opb)
}
else
{
- /* call each plugin, until one is able to handle this request. */
- rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
- for (mrp = get_plugin_list(PLUGIN_LIST_MATCHINGRULE); mrp != NULL; mrp = mrp->plg_next)
- {
+ /* look for a new syntax-style mr plugin */
+ struct slapdplugin* pi = plugin_mr_find(oid);
+ rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
+
+ /* register that plugin at the condition it has a createFn/index/indexSvFn */
+ if (pi) {
IFP indexFn = NULL;
IFP indexSvFn = NULL;
Slapi_PBlock pb;
- memcpy (&pb, opb, sizeof(Slapi_PBlock));
- slapi_pblock_set(&pb, SLAPI_PLUGIN, mrp);
- if (slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEXER_CREATE_FN, &createFn)) {
- /* plugin not a matchingrule type */
- continue;
- }
+ memcpy(&pb, opb, sizeof (Slapi_PBlock));
+ slapi_pblock_set(&pb, SLAPI_PLUGIN, pi);
+ slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEXER_CREATE_FN, &createFn);
if (createFn && !createFn(&pb)) {
+ /* we need to call the createFn before testing the indexFn/indexSvFn
+ * because it sets the index callbacks
+ */
slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEX_FN, &indexFn);
slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEX_SV_FN, &indexSvFn);
if (indexFn || indexSvFn) {
- /* Success: this plugin can handle it. */
+ /* Use the defined indexer_create function if it exists */
memcpy(opb, &pb, sizeof (Slapi_PBlock));
- plugin_mr_bind(oid, mrp); /* for future reference */
+ plugin_mr_bind(oid, pi); /* for future reference */
rc = 0; /* success */
- break;
}
-
}
- }
- if (rc != 0) {
- /* look for a new syntax-style mr plugin */
- struct slapdplugin *pi = plugin_mr_find(oid);
- if (pi) {
- Slapi_PBlock pb;
- memcpy (&pb, opb, sizeof(Slapi_PBlock));
- slapi_pblock_set(&pb, SLAPI_PLUGIN, pi);
- rc = default_mr_indexer_create(&pb);
- if (!rc) {
- memcpy (opb, &pb, sizeof(Slapi_PBlock));
- plugin_mr_bind (oid, pi); /* for future reference */
- }
+ }
+ if (pi && (rc != 0)) {
+ /* No defined indexer_create or it fails
+ * Let's use the default one
+ */
+ Slapi_PBlock pb;
+ memcpy(&pb, opb, sizeof (Slapi_PBlock));
+ slapi_pblock_set(&pb, SLAPI_PLUGIN, pi);
+ rc = default_mr_indexer_create(&pb);
+ if (!rc) {
+ memcpy(opb, &pb, sizeof (Slapi_PBlock));
+ plugin_mr_bind(oid, pi); /* for future reference */
}
}
}
@@ -292,8 +291,14 @@ mr_wrap_mr_index_sv_fn(Slapi_PBlock* pb)
slapi_pblock_set(pb, SLAPI_PLUGIN_MR_KEYS, out_vals);
/* we have to save out_vals to free next time or during destroy */
slapi_pblock_get(pb, SLAPI_PLUGIN_OBJECT, &mrpriv);
- mr_private_indexer_done(mrpriv); /* free old vals, if any */
- mrpriv->sva = out_vals; /* save pointer for later */
+
+ /* In case SLAPI_PLUGIN_OBJECT is not set
+ * (e.g. custom index/filter create function did not initialize it
+ */
+ if (mrpriv) {
+ mr_private_indexer_done(mrpriv); /* free old vals, if any */
+ mrpriv->sva = out_vals; /* save pointer for later */
+ }
rc = 0;
}
return rc;
@@ -329,8 +334,14 @@ mr_wrap_mr_index_fn(Slapi_PBlock* pb)
get freed by mr_private_indexer_done() */
/* we have to save out_vals to free next time or during destroy */
slapi_pblock_get(pb, SLAPI_PLUGIN_OBJECT, &mrpriv);
- mr_private_indexer_done(mrpriv); /* free old vals, if any */
- mrpriv->bva = out_vals; /* save pointer for later */
+
+ /* In case SLAPI_PLUGIN_OBJECT is not set
+ * (e.g. custom index/filter create function did not initialize it
+ */
+ if (mrpriv) {
+ mr_private_indexer_done(mrpriv); /* free old vals, if any */
+ mrpriv->bva = out_vals; /* save pointer for later */
+ }
/* set return value berval array for caller */
slapi_pblock_set(pb, SLAPI_PLUGIN_MR_KEYS, out_vals);
@@ -359,6 +370,11 @@ default_mr_filter_match(void *obj, Slapi_Entry *e, Slapi_Attr *attr)
*/
int rc = -1;
struct mr_private* mrpriv = (struct mr_private*)obj;
+
+ /* In case SLAPI_PLUGIN_OBJECT is not set, mrpriv may be NULL */
+ if (mrpriv == NULL)
+ return rc;
+
for (; (rc == -1) && (attr != NULL); slapi_entry_next_attr(e, attr, &attr)) {
char* type = NULL;
if (!slapi_attr_get_type (attr, &type) && type != NULL &&
@@ -385,6 +401,22 @@ default_mr_filter_index(Slapi_PBlock *pb)
struct mr_private* mrpriv = NULL;
slapi_pblock_get(pb, SLAPI_PLUGIN_OBJECT, &mrpriv);
+
+ /* In case SLAPI_PLUGIN_OBJECT is not set
+ * (e.g. custom index/filter create function did not initialize it
+ */
+ if (mrpriv == NULL) {
+ char* mrOID = NULL;
+ char* mrTYPE = NULL;
+ slapi_pblock_get(pb, SLAPI_PLUGIN_MR_OID, &mrOID);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_MR_TYPE, &mrTYPE);
+
+ slapi_log_error(SLAPI_LOG_FATAL, "default_mr_filter_index",
+ "Failure because mrpriv is NULL : %s %s\n",
+ mrOID ? "" : " oid",
+ mrTYPE ? "" : " attribute type");
+ return -1;
+ }
slapi_pblock_set(pb, SLAPI_PLUGIN, (void *)mrpriv->pi);
slapi_pblock_set(pb, SLAPI_PLUGIN_MR_TYPE, (void *)mrpriv->type);
@@ -547,19 +579,7 @@ plugin_mr_filter_create (mr_filter_t* f)
{
rc = attempt_mr_filter_create (f, mrp, &pb);
}
- else
- {
- /* call each plugin, until one is able to handle this request. */
- for (mrp = get_plugin_list(PLUGIN_LIST_MATCHINGRULE); mrp != NULL; mrp = mrp->plg_next)
- {
- if (!(rc = attempt_mr_filter_create (f, mrp, &pb)))
- {
- plugin_mr_bind (f->mrf_oid, mrp); /* for future reference */
- break;
- }
- }
- }
- if (rc)
+ if (!mrp || rc)
{
/* look for a new syntax-style mr plugin */
mrp = plugin_mr_find(f->mrf_oid);
| 0 |
dc952e22aba6354bf18e261c5d40a14cb2a8c978
|
389ds/389-ds-base
|
Issue 6307 - Wrong set of entries returned for some search filters (#6308)
Bug description:
When the server returns an entry to a search it
checks both access and matching of the filter.
When evaluating a '!' (NOT) logical expression the server,
in a first phase evaluates ONLY the right to access the
related component (and its subcomponents).
Then in a second phase verifies the matching.
If the related component is a OR, in the first phase it
evaluates access AND matching, this even if the call was
to evaluate only access.
This result in incoherent results.
Fix description:
Make sure that when the function vattr_test_filter_list_or
is called to only check access, it does not evaluate the matching.
fixes: #6307
Reviewed by: Pierre Rogier (Thanks !!)
|
commit dc952e22aba6354bf18e261c5d40a14cb2a8c978
Author: tbordaz <[email protected]>
Date: Thu Sep 5 10:19:59 2024 +0200
Issue 6307 - Wrong set of entries returned for some search filters (#6308)
Bug description:
When the server returns an entry to a search it
checks both access and matching of the filter.
When evaluating a '!' (NOT) logical expression the server,
in a first phase evaluates ONLY the right to access the
related component (and its subcomponents).
Then in a second phase verifies the matching.
If the related component is a OR, in the first phase it
evaluates access AND matching, this even if the call was
to evaluate only access.
This result in incoherent results.
Fix description:
Make sure that when the function vattr_test_filter_list_or
is called to only check access, it does not evaluate the matching.
fixes: #6307
Reviewed by: Pierre Rogier (Thanks !!)
diff --git a/dirsrvtests/tests/suites/filter/filter_test.py b/dirsrvtests/tests/suites/filter/filter_test.py
index 01dd6c7ca..471b59594 100644
--- a/dirsrvtests/tests/suites/filter/filter_test.py
+++ b/dirsrvtests/tests/suites/filter/filter_test.py
@@ -10,12 +10,14 @@ import logging
import pytest
import time
+from ldap import SCOPE_SUBTREE
from lib389.dirsrv_log import DirsrvAccessLog
from lib389.tasks import *
from lib389.backend import Backends, Backend
from lib389.dbgen import dbgen_users, dbgen_groups
from lib389.topologies import topology_st
from lib389._constants import PASSWORD, DEFAULT_SUFFIX, DN_DM, SUFFIX, DN_CONFIG_LDBM
+from lib389.idm.user import UserAccount, UserAccounts
from lib389.utils import *
pytestmark = pytest.mark.tier1
@@ -427,6 +429,120 @@ def test_match_large_valueset(topology_st):
assert len(entries) == groups_number
assert (etime < 5)
+def test_filter_not_operator(topology_st, request):
+ """Test ldapsearch with scope one gives only single entry
+
+ :id: b3711e02-7e76-444d-82f3-495c6dadd97f
+ :setup: Standalone instance
+ :steps:
+ 1. Creating user1..user9
+ 2. Adding specific 'telephonenumber' to the users
+ 3. Check returned set (5 users) with the first filter
+ 4. Check returned set (4 users) with the second filter
+ :expectedresults:
+ 1. This should pass
+ 2. This should pass
+ 3. This should pass
+ 4. This should pass
+ """
+
+ topology_st.standalone.start()
+ # Creating Users
+ log.info('Create users from user1 to user9')
+ users = UserAccounts(topology_st.standalone, "ou=people,%s" % DEFAULT_SUFFIX, rdn=None)
+
+ for user in ['user1',
+ 'user2',
+ 'user3',
+ 'user4',
+ 'user5',
+ 'user6',
+ 'user7',
+ 'user8',
+ 'user9']:
+ users.create(properties={
+ 'mail': f'{user}@redhat.com',
+ 'uid': user,
+ 'givenName': user.title(),
+ 'cn': f'bit {user}',
+ 'sn': user.title(),
+ 'manager': f'uid={user},{SUFFIX}',
+ 'userpassword': PW_DM,
+ 'homeDirectory': '/home/' + user,
+ 'uidNumber': '1000',
+ 'gidNumber': '2000',
+ })
+ # Adding specific values to the users
+ log.info('Adding telephonenumber values')
+ user = UserAccount(topology_st.standalone, 'uid=user1, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['1234', '2345'])
+
+ user = UserAccount(topology_st.standalone, 'uid=user2, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['1234', '4567'])
+
+ user = UserAccount(topology_st.standalone, 'uid=user3, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['1234', '4567'])
+
+ user = UserAccount(topology_st.standalone, 'uid=user4, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['1234'])
+
+ user = UserAccount(topology_st.standalone, 'uid=user5, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['2345'])
+
+ user = UserAccount(topology_st.standalone, 'uid=user6, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['3456'])
+
+ user = UserAccount(topology_st.standalone, 'uid=user7, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['4567'])
+
+ user = UserAccount(topology_st.standalone, 'uid=user8, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['1234'])
+
+ user = UserAccount(topology_st.standalone, 'uid=user9, ou=people, %s' % DEFAULT_SUFFIX)
+ user.add('telephonenumber', ['1234', '4567'])
+
+ # Do a first test of filter containing a NOT
+ # and check the expected values are retrieved
+ log.info('Search with filter containing NOT')
+ log.info('expect user2, user3, user6, user8 and user9')
+ filter1 = "(|(telephoneNumber=3456)(&(telephoneNumber=1234)(!(|(uid=user1)(uid=user4)))))"
+ entries = topology_st.standalone.search_s(DEFAULT_SUFFIX, SCOPE_SUBTREE, filter1)
+ uids = []
+ for entry in entries:
+ assert entry.hasAttr('uid')
+ uids.append(entry.getValue('uid'))
+
+ assert len(uids) == 5
+ for uid in [b'user2', b'user3', b'user6', b'user8', b'user9']:
+ assert uid in uids
+
+ # Do a second test of filter containing a NOT
+ # and check the expected values are retrieved
+ log.info('Search with a second filter containing NOT')
+ log.info('expect user2, user3, user8 and user9')
+ filter1 = "(|(&(telephoneNumber=1234)(!(|(uid=user1)(uid=user4)))))"
+ entries = topology_st.standalone.search_s(DEFAULT_SUFFIX, SCOPE_SUBTREE, filter1)
+ uids = []
+ for entry in entries:
+ assert entry.hasAttr('uid')
+ uids.append(entry.getValue('uid'))
+
+ assert len(uids) == 4
+ for uid in [b'user2', b'user3', b'user8', b'user9']:
+ assert uid in uids
+
+ def fin():
+ """
+ Deletes entries after the test.
+ """
+ for user in users.list():
+ pass
+ user.delete()
+
+
+ request.addfinalizer(fin)
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
diff --git a/ldap/servers/slapd/filterentry.c b/ldap/servers/slapd/filterentry.c
index d2c7e3082..f5604161d 100644
--- a/ldap/servers/slapd/filterentry.c
+++ b/ldap/servers/slapd/filterentry.c
@@ -948,14 +948,17 @@ slapi_vattr_filter_test_ext_internal(
break;
case LDAP_FILTER_NOT:
+ slapi_log_err(SLAPI_LOG_FILTER, "vattr_test_filter_list_NOT", "=>\n");
rc = slapi_vattr_filter_test_ext_internal(pb, e, f->f_not, verify_access, only_check_access, access_check_done);
if (verify_access && only_check_access) {
/* dont play with access control return codes
* do not negate return code */
+ slapi_log_err(SLAPI_LOG_FILTER, "vattr_test_filter_list_NOT only check access", "<= %d\n", rc);
break;
}
if (rc > 0) {
/* an error occurred or access denied, don't negate */
+ slapi_log_err(SLAPI_LOG_FILTER, "vattr_test_filter_list_NOT slapi_vattr_filter_test_ext_internal fails", "<= %d\n", rc);
break;
}
if (verify_access) {
@@ -980,6 +983,7 @@ slapi_vattr_filter_test_ext_internal(
/* filter verification only, no error */
rc = (rc == 0) ? -1 : 0;
}
+ slapi_log_err(SLAPI_LOG_FILTER, "vattr_test_filter_list_NOT", "<= %d\n", rc);
break;
default:
@@ -1084,6 +1088,13 @@ vattr_test_filter_list_or(
continue;
}
}
+ /* we are not evaluating if the entry matches
+ * but only that we have access to ALL components
+ * so check the next one
+ */
+ if (only_check_access) {
+ continue;
+ }
/* now check if filter matches */
/*
* We can NOT skip this because we need to know if the item we matched on
| 0 |
722b08519570426287f753bc31c4d69da72081ed
|
389ds/389-ds-base
|
Ticket 48917 - Attribute presence
Bug Description: Need a way to check for attribute presence. Add default equal
for entry aci
Fix Description:
* Add the def present to dsldapobject
* add the .get(,True) for equal in format_term
https://fedorahosted.org/389/ticket/48917
Author: wibrown
Review by: spichugi (Thanks!)
|
commit 722b08519570426287f753bc31c4d69da72081ed
Author: William Brown <[email protected]>
Date: Sat Jul 9 21:23:26 2016 +1000
Ticket 48917 - Attribute presence
Bug Description: Need a way to check for attribute presence. Add default equal
for entry aci
Fix Description:
* Add the def present to dsldapobject
* add the .get(,True) for equal in format_term
https://fedorahosted.org/389/ticket/48917
Author: wibrown
Review by: spichugi (Thanks!)
diff --git a/src/lib389/lib389/_entry.py b/src/lib389/lib389/_entry.py
index ade0a2256..06717eb39 100644
--- a/src/lib389/lib389/_entry.py
+++ b/src/lib389/lib389/_entry.py
@@ -445,7 +445,7 @@ class EntryAci(object):
def _format_term(self, key, value_dict):
rawaci = ''
- if value_dict['equal']:
+ if value_dict.get('equal', True):
rawaci += '="'
else:
rawaci += '!="'
diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py
index d595fe42e..9f1bfc6de 100644
--- a/src/lib389/lib389/_mapped_object.py
+++ b/src/lib389/lib389/_mapped_object.py
@@ -106,6 +106,20 @@ class DSLdapObject(DSLogging):
def dn(self):
return self._dn
+ def present(self, attr, value=None):
+ """
+ Assert that some attr, or some attr / value exist on the entry.
+ """
+ if self._instance.state != DIRSRV_STATE_ONLINE:
+ raise ValueError("Invalid state. Cannot get presence on instance that is not ONLINE")
+ self._log.debug("%s present(%r) %s" % (self._dn, attr, value))
+
+ e = self._instance.getEntry(self._dn)
+ if value is None:
+ return e.hasAttr(attr)
+ else:
+ return e.hasValue(attr, value)
+
def add(self, key, value):
self.set(key, value, action=ldap.MOD_ADD)
@@ -116,12 +130,8 @@ class DSLdapObject(DSLogging):
# This needs to work on key + val, and key
def remove(self, key, value):
"""Remove a value defined by key"""
- self._log.debug("%s get(%r, %r)" % (self._dn, key, value))
- if self._instance.state != DIRSRV_STATE_ONLINE:
- raise ValueError("Invalid state. Cannot remove properties on instance that is not ONLINE")
- else:
- # Do a mod_delete on the value.
- self.set(key, value, action=ldap.MOD_DELETE)
+ # Do a mod_delete on the value.
+ self.set(key, value, action=ldap.MOD_DELETE)
# maybe this could be renamed?
def set(self, key, value, action=ldap.MOD_REPLACE):
| 0 |
406084847f29aa44ffd81de746770aeff6b67c61
|
389ds/389-ds-base
|
Ticket 49320 - Activating already active role returns error 16
Bug Description: ns-activate.pl returns error 16 when trying to activate an
already active role.
Fix Description: Check for error 16 (no such attr), and return error 100.
Also added a "redirect"otion to the ldapmod function to
hide any errors printed to STDERR, so that the script can
display its own error message.
https://pagure.io/389-ds-base/issue/49320
Reviewed by: firstyear(Thanks!)
|
commit 406084847f29aa44ffd81de746770aeff6b67c61
Author: Mark Reynolds <[email protected]>
Date: Tue Oct 3 09:51:53 2017 -0400
Ticket 49320 - Activating already active role returns error 16
Bug Description: ns-activate.pl returns error 16 when trying to activate an
already active role.
Fix Description: Check for error 16 (no such attr), and return error 100.
Also added a "redirect"otion to the ldapmod function to
hide any errors printed to STDERR, so that the script can
display its own error message.
https://pagure.io/389-ds-base/issue/49320
Reviewed by: firstyear(Thanks!)
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index 805a9b91d..791464d0a 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -1447,6 +1447,10 @@ sub ldapmod {
close (FILE);
}
+ if ($info{redirect} eq ""){
+ $info{redirect} = "> /dev/null";
+ }
+
#
# Check the protocol, and reset it if it's invalid
#
@@ -1470,9 +1474,9 @@ sub ldapmod {
print "STARTTLS)\n";
}
if($info{openldap} eq "yes"){
- system "ldapmodify -x -ZZ -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
+ system "ldapmodify -x -ZZ -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
} else {
- system "ldapmodify -ZZZ -P \"$info{certdir}\" -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
+ system "ldapmodify -ZZZ -P \"$info{certdir}\" -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
}
} elsif (($info{security} eq "on" && $info{protocol} eq "") || ($info{security} eq "on" && $info{protocol} =~ m/LDAPS/i) ){
#
@@ -1482,9 +1486,9 @@ sub ldapmod {
print "LDAPS)\n";
}
if($info{openldap} eq "yes"){
- system "ldapmodify -x -H \"ldaps://$info{host}:$info{secure_port}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
+ system "ldapmodify -x -H \"ldaps://$info{host}:$info{secure_port}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
} else {
- system "ldapmodify -Z -P \"$info{certdir}\" -p $info{secure_port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
+ system "ldapmodify -Z -P \"$info{certdir}\" -p $info{secure_port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
}
} elsif (($info{openldap} eq "yes") && (($info{ldapi} eq "on" && $info{protocol} eq "") || ($info{ldapi} eq "on" && $info{protocol} =~ m/LDAPI/i)) ){
#
@@ -1499,7 +1503,7 @@ sub ldapmod {
if($protocol_error eq "yes"){
print "LDAPI)\n";
}
- system "ldapmodify -x -H \"$info{ldapiURL}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
+ system "ldapmodify -x -H \"$info{ldapiURL}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
}
} else {
#
@@ -1509,9 +1513,9 @@ sub ldapmod {
print "LDAP)\n";
}
if($info{openldap} eq "yes"){
- system "ldapmodify -x -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
+ system "ldapmodify -x -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
} else {
- system "ldapmodify -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
+ system "ldapmodify -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
}
}
unlink ($file);
diff --git a/ldap/admin/src/scripts/ns-activate.pl.in b/ldap/admin/src/scripts/ns-activate.pl.in
index 5922c9aab..bec19c8e7 100644
--- a/ldap/admin/src/scripts/ns-activate.pl.in
+++ b/ldap/admin/src/scripts/ns-activate.pl.in
@@ -731,11 +731,18 @@ if ( $single == 1 ){
}
$info{args} = "-c";
+$info{redirect} = "> /dev/null 2>&1";
DSUtil::ldapmod($record, %info);
if( $? != 0 ){
debug("delete, $entry\n");
$retCode=$?>>8;
- exit $retCode;
+ if ($retCode == "16") { # Error 16 (no such attr) - already activated
+ out("$entry already $state.\n");
+ exit 100;
+ } else {
+ out("Failed to activate $entry, error $retCode\n");
+ exit $retCode;
+ }
}
out("$entry $state.\n");
| 0 |
af11fb883739c6b421cb0a24d310b0ea4e99b393
|
389ds/389-ds-base
|
Issue 49374 - Add CI test case
Description: Add a test case to suites/config/regression_test.py.
Test that we can start the server after editing dse.ldif file
where we set nsslapd-errorlog-maxlogsize and nsslapd-errorlog-logmaxdiskspace
in a different order.
https://pagure.io/389-ds-base/issue/49374
Reviewed by: wibrown (Thanks!)
|
commit af11fb883739c6b421cb0a24d310b0ea4e99b393
Author: Simon Pichugin <[email protected]>
Date: Tue Nov 28 15:57:46 2017 +0100
Issue 49374 - Add CI test case
Description: Add a test case to suites/config/regression_test.py.
Test that we can start the server after editing dse.ldif file
where we set nsslapd-errorlog-maxlogsize and nsslapd-errorlog-logmaxdiskspace
in a different order.
https://pagure.io/389-ds-base/issue/49374
Reviewed by: wibrown (Thanks!)
diff --git a/dirsrvtests/tests/suites/config/regression_test.py b/dirsrvtests/tests/suites/config/regression_test.py
new file mode 100644
index 000000000..30824c926
--- /dev/null
+++ b/dirsrvtests/tests/suites/config/regression_test.py
@@ -0,0 +1,54 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 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
+from lib389.dseldif import DSEldif
+from lib389.topologies import topology_st as topo
+
+logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+
+def test_maxbersize_repl(topo):
+ """Check that instance starts when nsslapd-errorlog-maxlogsize
+ nsslapd-errorlog-logmaxdiskspace are set in certain order
+
+ :id: 743e912c-2be4-4f5f-9c2a-93dcb18f51a0
+ :setup: MMR with two masters
+ :steps:
+ 1. Stop the instance
+ 2. Set nsslapd-errorlog-maxlogsize before/after
+ nsslapd-errorlog-logmaxdiskspace
+ 3. Start the instance
+ 4. Check the error log for errors
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. The error log should contain no errors
+ """
+
+ inst = topo.standalone
+ dse_ldif = DSEldif(inst)
+
+ inst.stop()
+ log.info("Set nsslapd-errorlog-maxlogsize before nsslapd-errorlog-logmaxdiskspace")
+ dse_ldif.replace('cn=config', 'nsslapd-errorlog-maxlogsize', '300')
+ dse_ldif.replace('cn=config', 'nsslapd-errorlog-logmaxdiskspace', '500')
+ inst.start()
+ log.info("Assert no init_dse_file errors in the error log")
+ assert not inst.ds_error_log.match('.*ERR - init_dse_file.*')
+
+ inst.stop()
+ log.info("Set nsslapd-errorlog-maxlogsize after nsslapd-errorlog-logmaxdiskspace")
+ dse_ldif.replace('cn=config', 'nsslapd-errorlog-logmaxdiskspace', '500')
+ dse_ldif.replace('cn=config', 'nsslapd-errorlog-maxlogsize', '300')
+ inst.start()
+ log.info("Assert no init_dse_file errors in the error log")
+ assert not inst.ds_error_log.match('.*ERR - init_dse_file.*')
| 0 |
1671dc03bbee34c0948619387917aebbf0cc2756
|
389ds/389-ds-base
|
Ticket 50900 - Fix cargo offline build
Bug Description: The cargo offline build was broken due to a missing
+ on the CPP flags to nsslapd, and because of a "space" between a
variable and the value in configure.ac.
Fix Description: Add the plus, remove the space.
https://pagure.io/389-ds-base/pull-request/50900
Author: William Brown <[email protected]>
Review by: mhonek (Thanks!)
|
commit 1671dc03bbee34c0948619387917aebbf0cc2756
Author: William Brown <[email protected]>
Date: Mon Feb 17 13:59:27 2020 +1000
Ticket 50900 - Fix cargo offline build
Bug Description: The cargo offline build was broken due to a missing
+ on the CPP flags to nsslapd, and because of a "space" between a
variable and the value in configure.ac.
Fix Description: Add the plus, remove the space.
https://pagure.io/389-ds-base/pull-request/50900
Author: William Brown <[email protected]>
Review by: mhonek (Thanks!)
diff --git a/Makefile.am b/Makefile.am
index df986bfee..9180d170c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2180,7 +2180,7 @@ ns_slapd_LDADD = libslapd.la libldaputil.la libsvrcore.la $(LDAPSDK_LINK) $(NSS_
$(NSPR_LINK) $(SASL_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LIBS) $(EVENT_LINK)
if RUST_ENABLE
ns_slapd_LDADD += $(RNSSLAPD_LIB)
-ns_slapd_CPPFLAGS = -lssl -lcrypto
+ns_slapd_CPPFLAGS += -lssl -lcrypto
endif
ns_slapd_DEPENDENCIES = libslapd.la libldaputil.la
# We need to link ns-slapd with the C++ compiler on HP-UX since we load
diff --git a/configure.ac b/configure.ac
index 78803cc9b..bfb94360a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,11 @@ AC_ARG_ENABLE(rust_offline, AS_HELP_STRING([--enable-rust-offline], [Enable rust
AC_MSG_RESULT($enable_rust_offline)
AM_CONDITIONAL([RUST_ENABLE_OFFLINE],[test "$enable_rust_offline" = yes])
+AS_IF([test "$enable_rust_offline" = yes],
+ [rust_vendor_sources="replace-with = \"vendored-sources\""],
+ [rust_vendor_sources=""])
+AC_SUBST([rust_vendor_sources])
+
AC_MSG_CHECKING(for --enable-rust)
AC_ARG_ENABLE(rust, AS_HELP_STRING([--enable-rust], [Enable rust language features (default: no)]),
[], [ enable_rust=no ])
@@ -104,14 +109,6 @@ if test "$enable_rust" = yes -o "$enable_rust_offline" = yes; then
AS_IF([test "$CARGO" != "yes" -o "$RUSTC" != "yes"], [
AC_MSG_FAILURE("Rust based plugins cannot be built cargo=$CARGO rustc=$RUSTC")
])
-
- if test "$enable_rust_offline" = yes; then
- rust_vendor_sources = "replace-with = \"vendored-sources\""
- else
- rust_vendor_sources = ""
- fi
- AC_SUBST([rust_vendor_sources])
- AC_CONFIG_FILES([.cargo/config])
fi
AC_SUBST([enable_rust])
AM_CONDITIONAL([RUST_ENABLE],[test "$enable_rust" = yes -o "$enable_rust_offline" = yes])
@@ -925,5 +922,7 @@ AC_CONFIG_FILES([src/pkgconfig/dirsrv.pc src/pkgconfig/libsds.pc src/pkgconfig/s
AC_CONFIG_FILES([Makefile rpm/389-ds-base.spec ])
+AC_CONFIG_FILES([.cargo/config])
+
AC_OUTPUT
| 0 |
d80ddd54286c83d00a89aac11d844cd75bbde752
|
389ds/389-ds-base
|
Resolves: 452169
Summary: Indexing code needs to use new entry copy to search for subtypes when deleting an attribute value.
|
commit d80ddd54286c83d00a89aac11d844cd75bbde752
Author: Nathan Kinder <[email protected]>
Date: Fri Jun 20 15:10:00 2008 +0000
Resolves: 452169
Summary: Indexing code needs to use new entry copy to search for subtypes when deleting an attribute value.
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 344f33f1c..92e973ceb 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -652,13 +652,21 @@ index_add_mods(
* BE_INDEX_EQUALITY flag so the equality index is
* removed.
*/
- slapi_entry_attr_find( olde->ep_entry, mods[i]->mod_type, &curr_attr);
- for (j = 0; mods_valueArray[j] != NULL; j++ ) {
- if ( valuearray_find(curr_attr, evals, mods_valueArray[j]) == -1 ) {
- if (!(flags & BE_INDEX_EQUALITY)) {
- flags |= BE_INDEX_EQUALITY;
+ slapi_entry_attr_find( newe->ep_entry, mods[i]->mod_type, &curr_attr);
+ if (curr_attr) {
+ for (j = 0; mods_valueArray[j] != NULL; j++ ) {
+ if ( valuearray_find(curr_attr, evals, mods_valueArray[j]) == -1 ) {
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
}
}
+ } else {
+ /* If we didn't find the attribute in the new
+ * entry, we should remove the equality index. */
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
}
rc = index_addordel_values_sv( be, basetype,
| 0 |
fc8def62bb569197a27d083ee113b90606fb1fb8
|
389ds/389-ds-base
|
Ticket 47805 - syncrepl doesn't send notification when attribute in search filter changes
Bug Description: if an entry is modified so that it no longer matches
the search filter specified in teh sync repl
request a delete info should be sent
Fix Description: check pre and post entry for mods to determine if an entry
moves in or out of scope. Same logic as modrdn
https://fedorahosted.org/389/ticket/47805
Reviewed by: Mark, thanks
|
commit fc8def62bb569197a27d083ee113b90606fb1fb8
Author: Ludwig Krispenz <[email protected]>
Date: Tue May 27 15:27:17 2014 +0200
Ticket 47805 - syncrepl doesn't send notification when attribute in search filter changes
Bug Description: if an entry is modified so that it no longer matches
the search filter specified in teh sync repl
request a delete info should be sent
Fix Description: check pre and post entry for mods to determine if an entry
moves in or out of scope. Same logic as modrdn
https://fedorahosted.org/389/ticket/47805
Reviewed by: Mark, thanks
diff --git a/ldap/servers/plugins/sync/sync_persist.c b/ldap/servers/plugins/sync/sync_persist.c
index 4216a8702..4fb457485 100644
--- a/ldap/servers/plugins/sync/sync_persist.c
+++ b/ldap/servers/plugins/sync/sync_persist.c
@@ -97,14 +97,15 @@ int sync_del_persist_post_op(Slapi_PBlock *pb)
int sync_mod_persist_post_op(Slapi_PBlock *pb)
{
- Slapi_Entry *e;
+ Slapi_Entry *e, *e_prev;
if ( !SYNC_IS_INITIALIZED()) {
return(0);
}
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &e);
- sync_queue_change(e, NULL, LDAP_REQ_MODIFY);
+ slapi_pblock_get(pb, SLAPI_ENTRY_PRE_OP, &e_prev);
+ sync_queue_change(e, e_prev, LDAP_REQ_MODIFY);
return( 0 );
}
@@ -180,7 +181,7 @@ sync_queue_change( Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype )
/* if the change is a modrdn then we need to check if the entry was
* moved into scope, out of scope, or stays in scope
*/
- if (chgtype == LDAP_REQ_MODRDN)
+ if (chgtype == LDAP_REQ_MODRDN || chgtype == LDAP_REQ_MODIFY)
prev_match = slapi_sdn_scope_test( slapi_entry_get_sdn_const(eprev), base, scope ) &&
( 0 == slapi_vattr_filter_test( req->req_pblock, eprev, req->req_filter, 0 /* verify_access */ ));
@@ -194,9 +195,8 @@ sync_queue_change( Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype )
matched++;
node = (SyncQueueNode *)slapi_ch_calloc( 1, sizeof( SyncQueueNode ));
- node->sync_entry = slapi_entry_dup( e );
- if ( chgtype == LDAP_REQ_MODRDN) {
+ if ( chgtype == LDAP_REQ_MODRDN || chgtype == LDAP_REQ_MODIFY) {
if (prev_match && cur_match)
node->sync_chgtype = LDAP_REQ_MODIFY;
else if (prev_match)
@@ -206,6 +206,12 @@ sync_queue_change( Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype )
} else {
node->sync_chgtype = chgtype;
}
+ if (node->sync_chgtype == LDAP_REQ_DELETE && chgtype == LDAP_REQ_MODIFY ) {
+ /* use previous entry to pass the filter test in sync_send_results */
+ node->sync_entry = slapi_entry_dup( eprev );
+ } else {
+ node->sync_entry = slapi_entry_dup( e );
+ }
/* Put it on the end of the list for this sync search */
PR_Lock( req->req_lock );
pOldtail = req->ps_eq_tail;
| 0 |
95653e7461ce877b21384b65efe2d3918fa8765e
|
389ds/389-ds-base
|
Issue 4295 - Fix a closing quote issue (#4386)
Description: The "details" keyword in the access log does not have
a closing quote.
The issue happens because the quote was set in the wrong place.
Fixes: #4295
Reviewed by: @mreynolds389
|
commit 95653e7461ce877b21384b65efe2d3918fa8765e
Author: Simon Pichugin <[email protected]>
Date: Tue Oct 20 18:49:37 2020 +0200
Issue 4295 - Fix a closing quote issue (#4386)
Description: The "details" keyword in the access log does not have
a closing quote.
The issue happens because the quote was set in the wrong place.
Fixes: #4295
Reviewed by: @mreynolds389
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index 61efb6f8d..9daf3b151 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -1958,7 +1958,7 @@ notes2str(unsigned int notes, char *buf, size_t buflen)
* Put in the end quote. If another snp_detail is append a comma
* will overwrite the quote.
*/
- *(p + 1) = '"';
+ *p = '"';
}
}
| 0 |
49b7b668953f576040f308081e1920a325f49971
|
389ds/389-ds-base
|
Fix for ticket 510
Avoid creating an attribute just to determine the syntax for a type, look up the syntax directly by type
|
commit 49b7b668953f576040f308081e1920a325f49971
Author: Ludwig Krispenz <[email protected]>
Date: Fri Nov 16 14:13:27 2012 +0100
Fix for ticket 510
Avoid creating an attribute just to determine the syntax for a type, look up the syntax directly by type
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
index f134fa4d1..59506a02f 100644
--- a/ldap/servers/slapd/attrsyntax.c
+++ b/ldap/servers/slapd/attrsyntax.c
@@ -812,6 +812,24 @@ slapi_attr_is_dn_syntax_attr(Slapi_Attr *attr)
return dn_syntax;
}
+int
+slapi_attr_is_dn_syntax_type(char *type)
+{
+ const char *syntaxoid = NULL;
+ int dn_syntax = 0; /* not DN, by default */
+ struct asyntaxinfo * asi;
+
+ asi = attr_syntax_get_by_name(type);
+
+ if (asi && asi->asi_plugin) { /* If not set, there is no way to get the info */
+ if (syntaxoid = asi->asi_plugin->plg_syntax_oid) {
+ dn_syntax = ((0 == strcmp(syntaxoid, NAMEANDOPTIONALUID_SYNTAX_OID))
+ || (0 == strcmp(syntaxoid, DN_SYNTAX_OID)));
+ }
+ }
+ return dn_syntax;
+}
+
#ifdef ATTR_LDAP_DEBUG
PRIntn
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 0ca44e730..d643d3302 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -608,7 +608,6 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
/* See if the type is defined to use
* the Distinguished Name syntax. */
char savechar;
- Slapi_Attr test_attr;
/* We need typestart to be a string containing only
* the type. We terminate the type and then reset
@@ -616,9 +615,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
savechar = *d;
*d = '\0';
- slapi_attr_init(&test_attr, typestart);
- is_dn_syntax = slapi_attr_is_dn_syntax_attr(&test_attr);
- attr_done(&test_attr);
+ is_dn_syntax = slapi_attr_is_dn_syntax_type(typestart);
/* Reset the character we modified. */
*d = savechar;
@@ -629,7 +626,6 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
/* See if the type is defined to use
* the Distinguished Name syntax. */
char savechar;
- Slapi_Attr test_attr;
/* We need typestart to be a string containing only
* the type. We terminate the type and then reset
@@ -637,9 +633,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
savechar = *d;
*d = '\0';
- slapi_attr_init(&test_attr, typestart);
- is_dn_syntax = slapi_attr_is_dn_syntax_attr(&test_attr);
- attr_done(&test_attr);
+ is_dn_syntax = slapi_attr_is_dn_syntax_type(typestart);
/* Reset the character we modified. */
*d = savechar;
@@ -650,7 +644,6 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
/* See if the type is defined to use
* the Distinguished Name syntax. */
char savechar;
- Slapi_Attr test_attr;
/* We need typestart to be a string containing only
* the type. We terminate the type and then reset
@@ -658,9 +651,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
savechar = *d;
*d = '\0';
- slapi_attr_init(&test_attr, typestart);
- is_dn_syntax = slapi_attr_is_dn_syntax_attr(&test_attr);
- attr_done(&test_attr);
+ is_dn_syntax = slapi_attr_is_dn_syntax_type(typestart);
/* Reset the character we modified. */
*d = savechar;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 4883ad54d..978b02ce6 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -3738,6 +3738,7 @@ int slapi_attr_get_syntax_oid_copy( const Slapi_Attr *a, char **oidp );
* \return \c 0 if the attribute does not use a DN syntax.
*/
int slapi_attr_is_dn_syntax_attr(Slapi_Attr *attr);
+int slapi_attr_is_dn_syntax_type(char *type);
/**
* Get the flags associated with a particular attribute.
| 0 |
71151cf26d1f8e851078e01f875a0da0bbbad600
|
389ds/389-ds-base
|
Ticket 47490 - Schema replication between DS versions may overwrite newer base schema
Bug Description:
At the beginning of a replication session, the supplier checks if the schema (that the supplier owns) needs to be pushed
to the consumer. This is based on the comparison of a CSN (nsSchemaCSN).
The problem is that the CSN specifies which is the most recent update but does not garantee that the most recent
update is a superset of a previous update.
In an upgrade scenario a consumer schema can be overwriten by a supplier schema although the consumer schema is a superset
of the supplier schema
Fix Description:
The fix contains two parts:
- one to prevent a supplier to push its schema if it is not a superset of the consumer one
- one to prevent a consumer to accept a schema push, if the supplier schema is not a superset of its schema
To determine that a schema is a superset of an other, this fix only deals objectclasses.
For all objectclasses (of the consumer schema), it checks that
- all required attributes are also required in the supplier objectclasses
- all allowed attributes are also allowed in the supplier objectclasses
https://fedorahosted.org/389/ticket/47490
Reviewed by: Rich Megginson (thanks Rich !)
Platforms tested: unit tests, acceptance mmr, new TC in tet accept/mmr
Flag Day: no
Doc impact: possibly for troubleshooting guide, in case of warning messages
|
commit 71151cf26d1f8e851078e01f875a0da0bbbad600
Author: Thierry bordaz (tbordaz) <[email protected]>
Date: Wed Sep 18 15:25:41 2013 +0200
Ticket 47490 - Schema replication between DS versions may overwrite newer base schema
Bug Description:
At the beginning of a replication session, the supplier checks if the schema (that the supplier owns) needs to be pushed
to the consumer. This is based on the comparison of a CSN (nsSchemaCSN).
The problem is that the CSN specifies which is the most recent update but does not garantee that the most recent
update is a superset of a previous update.
In an upgrade scenario a consumer schema can be overwriten by a supplier schema although the consumer schema is a superset
of the supplier schema
Fix Description:
The fix contains two parts:
- one to prevent a supplier to push its schema if it is not a superset of the consumer one
- one to prevent a consumer to accept a schema push, if the supplier schema is not a superset of its schema
To determine that a schema is a superset of an other, this fix only deals objectclasses.
For all objectclasses (of the consumer schema), it checks that
- all required attributes are also required in the supplier objectclasses
- all allowed attributes are also allowed in the supplier objectclasses
https://fedorahosted.org/389/ticket/47490
Reviewed by: Rich Megginson (thanks Rich !)
Platforms tested: unit tests, acceptance mmr, new TC in tet accept/mmr
Flag Day: no
Doc impact: possibly for troubleshooting guide, in case of warning messages
diff --git a/ldap/servers/plugins/replication/repl5_connection.c b/ldap/servers/plugins/replication/repl5_connection.c
index 668abdaf3..4bd14a8c3 100644
--- a/ldap/servers/plugins/replication/repl5_connection.c
+++ b/ldap/servers/plugins/replication/repl5_connection.c
@@ -52,6 +52,7 @@ replica locked. Seems like right thing to do.
*/
#include "repl5.h"
+#include "slapi-private.h"
#if defined(USE_OPENLDAP)
#include "ldap.h"
#else
@@ -95,6 +96,9 @@ typedef struct repl_connection
/* #define DEFAULT_LINGER_TIME (5 * 60) */ /* 5 minutes */
#define DEFAULT_LINGER_TIME (60)
+/*** from proto-slap.h ***/
+int schema_objectclasses_superset_check(struct berval **remote_schema, char *type);
+
/* Controls we add on every outbound operation */
static LDAPControl manageDSAITControl = {LDAP_CONTROL_MANAGEDSAIT, {0, ""}, '\0'};
@@ -1575,6 +1579,33 @@ conn_push_schema(Repl_Connection *conn, CSN **remotecsn)
/* Need to free the remote_schema_csn_bervals */
ber_bvecfree(remote_schema_csn_bervals);
}
+ if (return_value != CONN_SCHEMA_NO_UPDATE_NEEDED) {
+ struct berval **remote_schema_objectclasses_bervals;
+ /* before pushing the schema do some checking */
+
+ /* First objectclasses */
+ return_value = conn_read_entry_attribute(conn, "cn=schema", "objectclasses", &remote_schema_objectclasses_bervals);
+ if (return_value == CONN_OPERATION_SUCCESS) {
+ /* Check if the consumer objectclasses are a superset of the local supplier schema */
+ if (schema_objectclasses_superset_check(remote_schema_objectclasses_bervals, OC_SUPPLIER)) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "Schema %s must not be overwritten (set replication log for additional info)\n",
+ agmt_get_long_name(conn->agmt));
+ return_value = CONN_OPERATION_FAILED;
+ }
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "%s: Fail to retrieve the remote schema objectclasses\n",
+ agmt_get_long_name(conn->agmt));
+ }
+
+ /* In case of success, possibly log a message */
+ if (return_value == CONN_OPERATION_SUCCESS) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "Schema checking successful: ok to push the schema (%s)\n", agmt_get_long_name(conn->agmt));
+ }
+ }
+
}
}
}
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index e2567288d..6539f9582 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -1001,6 +1001,8 @@ int slapi_validate_schema_files(char *schemadir);
int slapi_reload_schema_files(char *schemadir);
void schema_free_extensions(schemaext *extensions);
schemaext *schema_copy_extensions(schemaext *extensions);
+int schema_objectclasses_superset_check(struct berval **remote_schema, char *type);
+
/*
* schemaparse.c
*/
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 290e754e0..6fdb99fa2 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -128,7 +128,7 @@ static int strcpy_count( char *dst, const char *src );
static int refresh_user_defined_schema(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg);
static int schema_check_oc_attrs ( struct objclass *poc, char *errorbuf,
size_t errorbufsize, int stripOptions );
-static struct objclass *oc_find_nolock( const char *ocname_or_oid );
+static struct objclass *oc_find_nolock( const char *ocname_or_oid, struct objclass *oc_private, PRBool use_private );
static struct objclass *oc_find_oid_nolock( const char *ocoid );
static void oc_free( struct objclass **ocp );
static PRBool oc_equal( struct objclass *oc1, struct objclass *oc2 );
@@ -156,7 +156,7 @@ static size_t strcat_qdlist( char *buf, char *prefix, char **qdlist );
static int parse_attr_str(const char *input, struct asyntaxinfo **asipp, char *errorbuf, size_t errorbufsize,
PRUint32 schema_flags, int is_user_defined, int schema_ds4x_compat, int is_remote);
static int parse_objclass_str(const char *input, struct objclass **oc, char *errorbuf, size_t errorbufsize,
- PRUint32 schema_flags, int is_user_defined, int schema_ds4x_compat );
+ PRUint32 schema_flags, int is_user_defined, int schema_ds4x_compat, struct objclass* private_schema );
#else
/*
@@ -228,10 +228,10 @@ static int parse_at_str(const char *input, struct asyntaxinfo **asipp, char *err
static int parse_oc_str(const char *input, struct objclass **oc, char *errorbuf,
size_t errorbufsize, PRUint32 schema_flags, int is_user_defined,
- int schema_ds4x_compat )
+ int schema_ds4x_compat, struct objclass* private_schema )
{
#ifdef USE_OPENLDAP
- return parse_objclass_str (input, oc, errorbuf, errorbufsize, schema_flags, is_user_defined, schema_ds4x_compat );
+ return parse_objclass_str (input, oc, errorbuf, errorbufsize, schema_flags, is_user_defined, schema_ds4x_compat, private_schema );
#else
return read_oc_ldif (input, oc, errorbuf, errorbufsize, schema_flags, is_user_defined, schema_ds4x_compat );
#endif
@@ -560,7 +560,7 @@ slapi_entry_schema_check_ext( Slapi_PBlock *pb, Slapi_Entry *e, int repl_check )
continue;
}
- if ((oc = oc_find_nolock( ocname )) != NULL ) {
+ if ((oc = oc_find_nolock( ocname, NULL, PR_FALSE )) != NULL ) {
oclist[oc_count++] = oc;
} else {
/* we don't know about the oc; return an appropriate error message */
@@ -795,7 +795,7 @@ oc_find_name( const char *name_or_oid )
char *ocname = NULL;
oc_lock_read();
- if ( NULL != ( oc = oc_find_nolock( name_or_oid ))) {
+ if ( NULL != ( oc = oc_find_nolock( name_or_oid, NULL, PR_FALSE ))) {
ocname = slapi_ch_strdup( oc->oc_name );
}
oc_unlock();
@@ -810,13 +810,18 @@ oc_find_name( const char *name_or_oid )
* NULL is returned if no match is found or `name_or_oid' is NULL.
*/
static struct objclass *
-oc_find_nolock( const char *ocname_or_oid )
+oc_find_nolock( const char *ocname_or_oid, struct objclass *oc_private, PRBool use_private)
{
struct objclass *oc;
if ( NULL != ocname_or_oid ) {
if ( !schema_ignore_trailing_spaces ) {
- for ( oc = g_get_global_oc_nolock(); oc != NULL; oc = oc->oc_next ) {
+ if (use_private) {
+ oc = oc_private;
+ } else {
+ oc = g_get_global_oc_nolock();
+ }
+ for ( ; oc != NULL; oc = oc->oc_next ) {
if ( ( strcasecmp( oc->oc_name, ocname_or_oid ) == 0 )
|| ( oc->oc_oid &&
strcasecmp( oc->oc_oid, ocname_or_oid ) == 0 )) {
@@ -834,8 +839,13 @@ oc_find_nolock( const char *ocname_or_oid )
p++, len++ ) {
; /* NULL */
}
-
- for ( oc = g_get_global_oc_nolock(); oc != NULL; oc = oc->oc_next ) {
+
+ if (use_private) {
+ oc = oc_private;
+ } else {
+ oc = g_get_global_oc_nolock();
+ }
+ for ( ; oc != NULL; oc = oc->oc_next ) {
if ( ( (strncasecmp( oc->oc_name, ocname_or_oid, len ) == 0)
&& (len == strlen(oc->oc_name)) )
||
@@ -1885,11 +1895,34 @@ modify_schema_dse (Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entr
*returncode = schema_replace_attributes( pb, mods[i], returntext,
SLAPI_DSE_RETURNTEXT_SIZE );
} else if (strcasecmp (mods[i]->mod_type, "objectclasses") == 0) {
- /*
- * Replace all objectclasses
- */
- *returncode = schema_replace_objectclasses( pb, mods[i],
- returntext, SLAPI_DSE_RETURNTEXT_SIZE );
+
+ if (is_replicated_operation) {
+ /* before accepting the schema checks if the local consumer schema is not
+ * a superset of the supplier schema
+ */
+ if (schema_objectclasses_superset_check(mods[i]->mod_bvalues, OC_CONSUMER)) {
+
+ schema_create_errormsg( returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ schema_errprefix_generic, mods[i]->mod_type,
+ "Replace is not possible, local consumer schema is a superset of the supplier" );
+ slapi_log_error(SLAPI_LOG_FATAL, "schema",
+ "Local %s must not be overwritten (set replication log for additional info)\n",
+ mods[i]->mod_type);
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ } else {
+ /*
+ * Replace all objectclasses
+ */
+ *returncode = schema_replace_objectclasses(pb, mods[i],
+ returntext, SLAPI_DSE_RETURNTEXT_SIZE);
+ }
+ } else {
+ /*
+ * Replace all objectclasses
+ */
+ *returncode = schema_replace_objectclasses(pb, mods[i],
+ returntext, SLAPI_DSE_RETURNTEXT_SIZE);
+ }
} else if (strcasecmp (mods[i]->mod_type, "nsschemacsn") == 0) {
if (is_replicated_operation) {
/* Update the schema CSN */
@@ -2155,13 +2188,13 @@ schema_delete_objectclasses( Slapi_Entry *entryBefore, LDAPMod *mod,
for (i = 0; mod->mod_bvalues[i]; i++) {
if ( LDAP_SUCCESS != ( rc = parse_oc_str (
(const char *)mod->mod_bvalues[i]->bv_val, &delete_oc,
- errorbuf, errorbufsize, 0, 0, schema_ds4x_compat))) {
+ errorbuf, errorbufsize, 0, 0, schema_ds4x_compat, NULL))) {
return rc;
}
oc_lock_write();
- if ((poc = oc_find_nolock(delete_oc->oc_name)) != NULL) {
+ if ((poc = oc_find_nolock(delete_oc->oc_name, NULL, PR_FALSE)) != NULL) {
/* check to see if any objectclasses inherit from this oc */
for (poc2 = g_get_global_oc_nolock(); poc2 != NULL; poc2 = poc2->oc_next) {
@@ -2382,8 +2415,8 @@ add_oc_internal(struct objclass *pnew_oc, char *errorbuf, size_t errorbufsize,
if (!(flags & DSE_SCHEMA_LOCKED))
oc_lock_write();
- oldoc_by_name = oc_find_nolock (pnew_oc->oc_name);
- oldoc_by_oid = oc_find_nolock (pnew_oc->oc_oid);
+ oldoc_by_name = oc_find_nolock (pnew_oc->oc_name, NULL, PR_FALSE);
+ oldoc_by_oid = oc_find_nolock (pnew_oc->oc_oid, NULL, PR_FALSE);
/* Check to see if the objectclass name and the objectclass oid are already
* in use by an existing objectclass. If an existing objectclass is already
@@ -2421,7 +2454,7 @@ add_oc_internal(struct objclass *pnew_oc, char *errorbuf, size_t errorbufsize,
/* check to see if the superior oc exists */
if (!rc && pnew_oc->oc_superior &&
- ((psup_oc = oc_find_nolock (pnew_oc->oc_superior)) == NULL)) {
+ ((psup_oc = oc_find_nolock (pnew_oc->oc_superior, NULL, PR_FALSE)) == NULL)) {
schema_create_errormsg( errorbuf, errorbufsize, schema_errprefix_oc,
pnew_oc->oc_name, "Superior object class \"%s\" does not exist",
pnew_oc->oc_superior);
@@ -2628,7 +2661,7 @@ schema_add_objectclass ( Slapi_PBlock *pb, LDAPMod *mod, char *errorbuf,
newoc_ldif = (char *) mod->mod_bvalues[j]->bv_val;
if ( LDAP_SUCCESS != (rc = parse_oc_str ( newoc_ldif, &pnew_oc,
errorbuf, errorbufsize, 0, 1 /* user defined */,
- schema_ds4x_compat))) {
+ schema_ds4x_compat, NULL))) {
oc_free( &pnew_oc );
return rc;
}
@@ -2706,7 +2739,7 @@ schema_replace_objectclasses ( Slapi_PBlock *pb, LDAPMod *mod, char *errorbuf,
if ( LDAP_SUCCESS != ( rc = parse_oc_str( mod->mod_bvalues[i]->bv_val,
&newocp, errorbuf, errorbufsize, DSE_SCHEMA_NO_GLOCK,
- 1 /* user defined */, 0 /* no DS 4.x compat issues */ ))) {
+ 1 /* user defined */, 0 /* no DS 4.x compat issues */ , NULL))) {
rc = LDAP_INVALID_SYNTAX;
goto clean_up_and_return;
}
@@ -3090,7 +3123,7 @@ read_oc_ldif ( const char *input, struct objclass **oc, char *errorbuf,
keyword_strstr_fn ))) {
pOcSup = get_tagged_oid( " SUP ", &nextinput, keyword_strstr_fn );
}
- psup_oc = oc_find_nolock ( pOcSup );
+ psup_oc = oc_find_nolock ( pOcSup, NULL, PR_FALSE);
if ( schema_ds4x_compat ) nextinput = input;
@@ -4085,7 +4118,7 @@ parse_attr_str(const char *input, struct asyntaxinfo **asipp, char *errorbuf,
static int
parse_objclass_str ( const char *input, struct objclass **oc, char *errorbuf,
size_t errorbufsize, PRUint32 schema_flags, int is_user_defined,
- int schema_ds4x_compat )
+ int schema_ds4x_compat, struct objclass *private_schema )
{
LDAPObjectClass *objClass;
struct objclass *pnew_oc = NULL, *psup_oc = NULL;
@@ -4194,8 +4227,15 @@ parse_objclass_str ( const char *input, struct objclass **oc, char *errorbuf,
/* needed because we access the superior oc */
oc_lock_read();
}
- if(objClass->oc_sup_oids && objClass->oc_sup_oids[0]){
- psup_oc = oc_find_nolock ( objClass->oc_sup_oids[0] );
+ if(objClass->oc_sup_oids && objClass->oc_sup_oids[0]) {
+ if (schema_flags & DSE_SCHEMA_USE_PRIV_SCHEMA) {
+ /* We have built an objectclass list on a private variable
+ * This is used to check the schema of a remote consumer
+ */
+ psup_oc = oc_find_nolock(objClass->oc_sup_oids[0], private_schema, PR_TRUE);
+ } else {
+ psup_oc = oc_find_nolock(objClass->oc_sup_oids[0], NULL, PR_FALSE);
+ }
}
/*
* Walk the "oc_extensions" and set the schema extensions
@@ -4760,7 +4800,7 @@ load_schema_dse(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *ignored,
if ( LDAP_SUCCESS != (*returncode = parse_oc_str(s, &oc, returntext,
SLAPI_DSE_RETURNTEXT_SIZE, flags,
primary_file /* force user defined? */,
- schema_ds4x_compat)))
+ schema_ds4x_compat, NULL)))
{
oc_free( &oc );
break;
@@ -5584,7 +5624,7 @@ va_expand_one_oc( const char *dn, const Slapi_Attr *a, Slapi_ValueSet *vs, const
Slapi_Value **va = vs->va;
- this_oc = oc_find_nolock( ocs );
+ this_oc = oc_find_nolock( ocs, NULL, PR_FALSE );
if ( this_oc == NULL ) {
return; /* skip unknown object classes */
@@ -5594,7 +5634,7 @@ va_expand_one_oc( const char *dn, const Slapi_Attr *a, Slapi_ValueSet *vs, const
return; /* no superior */
}
- sup_oc = oc_find_nolock( this_oc->oc_superior );
+ sup_oc = oc_find_nolock( this_oc->oc_superior, NULL, PR_FALSE );
if ( sup_oc == NULL ) {
return; /* superior is unknown -- ignore */
}
@@ -5770,7 +5810,7 @@ slapi_schema_list_objectclass_attributes(const char *ocname_or_oid,
}
oc_lock_read();
- oc = oc_find_nolock(ocname_or_oid);
+ oc = oc_find_nolock(ocname_or_oid, NULL, PR_FALSE);
if (oc) {
switch (flags & mask) {
case SLAPI_OC_FLAG_REQUIRED:
@@ -5806,7 +5846,7 @@ slapi_schema_get_superior_name(const char *ocname_or_oid)
char *superior = NULL;
oc_lock_read();
- oc = oc_find_nolock(ocname_or_oid);
+ oc = oc_find_nolock(ocname_or_oid, NULL, PR_FALSE);
if (oc) {
superior = slapi_ch_strdup(oc->oc_superior);
}
@@ -5814,3 +5854,221 @@ slapi_schema_get_superior_name(const char *ocname_or_oid)
return superior;
}
+
+
+/* Check if the oc_list1 is a superset of oc_list2.
+ * oc_list1 is a superset if it exists objectclass in oc_list1 that
+ * do not exist in oc_list2. Or if a OC in oc_list1 required more attributes
+ * that the OC in oc_list2. Or if a OC in oc_list1 allowed more attributes
+ * that the OC in oc_list2.
+ *
+ * It returns 1 if oc_list1 is a superset of oc_list2, else it returns 0
+ *
+ * If oc_list1 or oc_list2 is global_oc, the caller must hold the oc_lock
+ */
+static int
+schema_oc_superset_check(struct objclass *oc_list1, struct objclass *oc_list2, char *message) {
+ struct objclass *oc_1, *oc_2;
+ char *description;
+ int rc, i, j;
+ int found;
+
+ if (message == NULL) {
+ description = "";
+ } else {
+ description = message;
+ }
+
+ /* by default assum oc_list1 == oc_list2 */
+ rc = 0;
+
+ /* Check if all objectclass in oc_list1
+ * - exists in oc_list2
+ * - required attributes are also required in oc_2
+ * - allowed attributes are also allowed in oc_2
+ */
+ for (oc_1 = oc_list1; oc_1 != NULL; oc_1 = oc_1->oc_next) {
+
+ /* Retrieve the remote objectclass in our local schema */
+ oc_2 = oc_find_nolock(oc_1->oc_oid, oc_list2, PR_TRUE);
+ if (oc_2 == NULL) {
+ /* try to retrieve it with the name*/
+ oc_2 = oc_find_nolock(oc_1->oc_name, oc_list2, PR_TRUE);
+ }
+ if (oc_2 == NULL) {
+ slapi_log_error(SLAPI_LOG_REPL, "schema", "Fail to retrieve in the %s schema [%s or %s]\n",
+ description,
+ oc_1->oc_name,
+ oc_1->oc_oid);
+
+ /* The oc_1 objectclasses is supperset */
+ rc = 1;
+
+ continue; /* we continue to check all the objectclass */
+ }
+
+ /* First check the MUST */
+ if (oc_1->oc_orig_required) {
+ for (i = 0; oc_1->oc_orig_required[i] != NULL; i++) {
+ /* For each required attribute from the remote schema check that
+ * it is also required in the local schema
+ */
+ found = 0;
+ if (oc_2->oc_orig_required) {
+ for (j = 0; oc_2->oc_orig_required[j] != NULL; j++) {
+ if (strcasecmp(oc_2->oc_orig_required[j], oc_1->oc_orig_required[i]) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (!found) {
+ /* The required attribute in the remote protocol (remote_oc->oc_orig_required[i])
+ * is not required in the local protocol
+ */
+ slapi_log_error(SLAPI_LOG_REPL, "schema", "Attribute %s is not required in '%s' of the %s schema\n",
+ oc_1->oc_orig_required[i],
+ oc_1->oc_name,
+ description);
+
+ /* The oc_1 objectclasses is supperset */
+ rc = 1;
+
+ continue; /* we continue to check all attributes */
+ }
+ }
+ }
+
+ /* Second check the MAY */
+ if (oc_1->oc_orig_allowed) {
+ for (i = 0; oc_1->oc_orig_allowed[i] != NULL; i++) {
+ /* For each required attribute from the remote schema check that
+ * it is also required in the local schema
+ */
+ found = 0;
+ if (oc_2->oc_orig_allowed) {
+ for (j = 0; oc_2->oc_orig_allowed[j] != NULL; j++) {
+ if (strcasecmp(oc_2->oc_orig_allowed[j], oc_1->oc_orig_allowed[i]) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (!found) {
+ /* The required attribute in the remote protocol (remote_oc->oc_orig_allowed[i])
+ * is not required in the local protocol
+ */
+ slapi_log_error(SLAPI_LOG_REPL, "schema", "Attribute %s is not allowed in '%s' of the %s schema\n",
+ oc_1->oc_orig_allowed[i],
+ oc_1->oc_name,
+ description);
+
+ /* The oc_1 objectclasses is supperset */
+ rc = 1;
+
+ continue; /* we continue to check all attributes */
+ }
+ }
+ }
+ }
+
+ return rc;
+}
+
+static void
+schema_oclist_free(struct objclass *oc_list)
+{
+ struct objclass *oc, *oc_next;
+
+ for (oc = oc_list; oc != NULL; oc = oc_next) {
+ oc_next = oc->oc_next;
+ oc_free(&oc);
+ }
+}
+
+static
+struct objclass *schema_berval_to_oclist(struct berval **oc_berval) {
+ struct objclass *oc, *oc_list, *oc_tail;
+ char errorbuf[BUFSIZ];
+ int schema_ds4x_compat, rc;
+ int i;
+
+ schema_ds4x_compat = config_get_ds4_compatible_schema();
+ rc = 0;
+
+ oc_list = NULL;
+ oc_tail = NULL;
+ if (oc_berval != NULL) {
+ for (i = 0; oc_berval[i] != NULL; i++) {
+ /* parse the objectclass value */
+ if (LDAP_SUCCESS != (rc = parse_oc_str(oc_berval[i]->bv_val, &oc,
+ errorbuf, sizeof (errorbuf), DSE_SCHEMA_NO_CHECK | DSE_SCHEMA_USE_PRIV_SCHEMA, 0,
+ schema_ds4x_compat, oc_list))) {
+ oc_free(&oc);
+ rc = 1;
+ break;
+ }
+
+ /* Add oc at the end of the oc_list */
+ oc->oc_next = NULL;
+ if (oc_list == NULL) {
+ oc_list = oc;
+ oc_tail = oc;
+ } else {
+ oc_tail->oc_next = oc;
+ oc_tail = oc;
+ }
+ }
+ }
+ if (rc) {
+ schema_oclist_free(oc_list);
+ oc_list = NULL;
+ }
+ return oc_list;
+}
+
+int
+schema_objectclasses_superset_check(struct berval **remote_schema, char *type) {
+ int rc;
+ struct objclass *remote_oc_list;
+
+ rc = 0;
+
+ /* head is the future list of the objectclass of the remote schema */
+ remote_oc_list = NULL;
+
+ if (remote_schema != NULL) {
+ /* First build an objectclass list from the remote schema */
+ if ((remote_oc_list = schema_berval_to_oclist(remote_schema)) == NULL) {
+ rc = 1;
+ return rc;
+ }
+
+
+ /* Check that for each object from the remote schema
+ * - MUST attributes are also MUST in local schema
+ * - ALLOWED attributes are also ALLOWED in local schema
+ */
+
+ if (remote_oc_list) {
+ oc_lock_read();
+ if (strcmp(type, OC_SUPPLIER) == 0) {
+ /* Check if the remote_oc_list from a consumer are or not
+ * a superset of the objectclasses of the local supplier schema
+ */
+ rc = schema_oc_superset_check(remote_oc_list, g_get_global_oc_nolock(), "local supplier" );
+ } else {
+ /* Check if the objectclasses of the local consumer schema are or not
+ * a superset of the remote_oc_list from a supplier
+ */
+ rc = schema_oc_superset_check(g_get_global_oc_nolock(), remote_oc_list, "remote supplier");
+ }
+
+ oc_unlock();
+ }
+
+ /* Free the remote schema list*/
+ schema_oclist_free(remote_oc_list);
+ }
+ return rc;
+}
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 900d3e53d..f459e9d43 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1129,6 +1129,11 @@ void schema_expand_objectclasses_nolock( Slapi_Entry *e );
* reload_schemafile_lock;
* no further lock needed */
#define DSE_SCHEMA_USER_DEFINED_ONLY 0x0100 /* refresh user defined schema */
+#define DSE_SCHEMA_USE_PRIV_SCHEMA 0x0200 /* Use a provided private schema */
+
+/* */
+#define OC_CONSUMER "consumer"
+#define OC_SUPPLIER "supplier"
#define SLAPI_RTN_BIT_FETCH_EXISTING_DN_ENTRY 0
#define SLAPI_RTN_BIT_FETCH_PARENT_ENTRY 1
| 0 |
3e9fa7ada315098b9e18b4ed30e777170314c2cb
|
389ds/389-ds-base
|
Bug 690882 - (cov#10703) Incorrect sizeof use in vattr code
We are using sizeof() incorrectly when allocating memory for an
array of integers. We are currently getting the sizeof a pointer
to an int instead of the size of an int itself.
|
commit 3e9fa7ada315098b9e18b4ed30e777170314c2cb
Author: Nathan Kinder <[email protected]>
Date: Fri Mar 25 10:11:17 2011 -0700
Bug 690882 - (cov#10703) Incorrect sizeof use in vattr code
We are using sizeof() incorrectly when allocating memory for an
array of integers. We are currently getting the sizeof a pointer
to an int instead of the size of an int itself.
diff --git a/ldap/servers/slapd/vattr.c b/ldap/servers/slapd/vattr.c
index e22109622..2961ea430 100644
--- a/ldap/servers/slapd/vattr.c
+++ b/ldap/servers/slapd/vattr.c
@@ -1705,7 +1705,7 @@ int vattr_call_sp_get_batch_values(vattr_sp_handle *handle, vattr_context *c, Sl
{
/* make our args look like the simple non-batched case */
*results = (Slapi_ValueSet**)slapi_ch_calloc(2, sizeof(**results)); /* 2 for null terminated list */
- *type_name_disposition = (int *)slapi_ch_calloc(2, sizeof(*type_name_disposition));
+ *type_name_disposition = (int *)slapi_ch_calloc(2, sizeof(**type_name_disposition));
*actual_type_name = (char**)slapi_ch_calloc(2, sizeof(**actual_type_name));
ret =((handle->sp->sp_get_fn)(handle,c,e,*type,*results,*type_name_disposition,*actual_type_name,flags,buffer_flags, hint));
| 0 |
13c5b2e238efc8a76e78a24ed38b39fc78e8656c
|
389ds/389-ds-base
|
Resolves: #173873
Summary: Directory Server should shutdown if it fails to write logs (comment #7)
Change Description:
1. introduced a new static function log__error_emergency, which is called at
emergency to log to the syslog and at least try to log into the errors log one
more time.
2. added an error parameter to the macro LOG_WRITE_NOW to return if the writing
to the log was successful or not.
3. if opening an errors log or writing to an errors log failed, call
g_set_shutdown to shutdown the server gracefully.
4. log__error_emergency calls writing log function (LDAPDebug --> slapd_log_error_proc_internal) with ERROR_LOCK_WRITE unlocked, if locked.
|
commit 13c5b2e238efc8a76e78a24ed38b39fc78e8656c
Author: Noriko Hosoi <[email protected]>
Date: Fri Oct 5 17:00:04 2007 +0000
Resolves: #173873
Summary: Directory Server should shutdown if it fails to write logs (comment #7)
Change Description:
1. introduced a new static function log__error_emergency, which is called at
emergency to log to the syslog and at least try to log into the errors log one
more time.
2. added an error parameter to the macro LOG_WRITE_NOW to return if the writing
to the log was successful or not.
3. if opening an errors log or writing to an errors log failed, call
g_set_shutdown to shutdown the server gracefully.
4. log__error_emergency calls writing log function (LDAPDebug --> slapd_log_error_proc_internal) with ERROR_LOCK_WRITE unlocked, if locked.
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index c54b03024..27075140e 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -3034,22 +3034,26 @@ config_set_errorlog( const char *attrname, char *value, char *errorbuf, int appl
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
+ return LDAP_OPERATIONS_ERROR;
}
retVal = log_update_errorlogdir ( value, apply );
if ( retVal != LDAP_SUCCESS ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Cannot open errorlog directory \"%s\", errors will "
- "not be logged.", value );
+ PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
+ "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
+ value );
+ syslog(LOG_ERR,
+ "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
+ value );
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
}
if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->errorlog) );
- slapdFrontendConfig->errorlog = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapi_ch_free ( (void **) &(slapdFrontendConfig->errorlog) );
+ slapdFrontendConfig->errorlog = slapi_ch_strdup ( value );
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
}
return retVal;
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index bb5e9eca6..a1189c95d 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -126,7 +126,7 @@ static int log__check_prevlogs (FILE *fp, char *filename);
static int log__getfilesize(LOGFD fp);
static int log__enough_freespace(char *path);
-static int vslapd_log_error(LOGFD fp, char *subsystem, char *fmt, va_list ap );
+static int vslapd_log_error(LOGFD fp, char *subsystem, char *fmt, va_list ap, int locked );
static int vslapd_log_access(char *fmt, va_list ap );
static void log_convert_time (time_t ctime, char *tbuf, int type);
static time_t log_reverse_convert_time (char *tbuf);
@@ -134,7 +134,7 @@ static LogBufferInfo *log_create_buffer(size_t sz);
static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, char *msg2, size_t size2);
static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now);
static void log_write_title(LOGFD fp);
-
+static void log__error_emergency(const char *errstr, int reopen, int locked);
static int
slapd_log_error_proc_internal(
@@ -154,8 +154,8 @@ slapd_log_error_proc_internal(
* LOG_OPEN_WRITE(fd, filename, mode) is the same but truncates the file and
* starts writing at the beginning of the file.
* LOG_WRITE(fd, buffer, size, headersize) writes into a LOGFD
- * LOG_WRITE_NOW(fd, buffer, size, headersize) writes into a LOGFD and flushes the
- * buffer if necessary
+ * LOG_WRITE_NOW(fd, buffer, size, headersize, err) writes into a LOGFD and
+ * flushes the buffer if necessary
* LOG_CLOSE(fd) closes the logfile
*/
#ifdef XP_WIN32
@@ -168,10 +168,12 @@ slapd_log_error_proc_internal(
{\
ReportSlapdEvent(EVENTLOG_INFORMATION_TYPE, MSG_SERVER_FAILED_TO_WRITE_LOG, 1, (buffer)); \
}
-#define LOG_WRITE_NOW(fd, buffer, size, headersize) do {\
+#define LOG_WRITE_NOW(fd, buffer, size, headersize, err) do {\
+ (err) = 0; \
if ( fwrite((buffer), (size), 1, (fd)) != 1 ) \
{ \
ReportSlapdEvent(EVENTLOG_INFORMATION_TYPE, MSG_SERVER_FAILED_TO_WRITE_LOG, 1, (buffer)); \
+ (err) = 1; \
}; \
fflush((fd)); \
} while (0)
@@ -190,11 +192,13 @@ slapd_log_error_proc_internal(
PRErrorCode prerr = PR_GetError(); \
syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer)+(headersize) ); \
}
-#define LOG_WRITE_NOW(fd, buffer, size, headersize) do {\
+#define LOG_WRITE_NOW(fd, buffer, size, headersize, err) do {\
+ (err) = 0; \
if ( slapi_write_buffer((fd), (buffer), (size)) != (size) ) \
{ \
PRErrorCode prerr = PR_GetError(); \
syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer)+(headersize) ); \
+ (err) = prerr; \
} \
/* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
PR_Sync(fd); \
@@ -528,10 +532,13 @@ log_update_errorlogdir(char *pathname, int apply)
/* try to open the file, we may have a incorrect path */
if (! LOG_OPEN_APPEND(fp, pathname, loginfo.log_error_mode)) {
- LDAPDebug(LDAP_DEBUG_ANY, "WARNING: can't open file %s. "
- "errno %d (%s)\n",
- pathname, errno, slapd_system_strerror(errno));
+ char buffer[SLAPI_LOG_BUFSIZ];
+ PRErrorCode prerr = PR_GetError();
/* stay with the current log file */
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to open file %s. error %d (%s). Exiting...",
+ pathname, prerr, slapd_pr_strerror(prerr));
+ log__error_emergency(buffer, 0, 0);
return LDAP_UNWILLING_TO_PERFORM;
}
@@ -1589,11 +1596,12 @@ log_write_title (LOGFD fp)
char *buildnum = config_get_buildnum();
char buff[512];
int bufflen = sizeof(buff);
+ int err = 0;
PR_snprintf(buff, bufflen, "\t%s B%s\n",
fe_cfg->versionstring ? fe_cfg->versionstring : "Fedora-Directory",
buildnum ? buildnum : "");
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0);
+ LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
if (fe_cfg->localhost) {
PR_snprintf(buff, bufflen, "\t%s:%d (%s)\n\n",
@@ -1608,7 +1616,7 @@ log_write_title (LOGFD fp)
PR_snprintf(buff, bufflen, "\t<host>:<port> (%s)\n\n",
fe_cfg->configdir ? fe_cfg->configdir : "");
}
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0);
+ LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
slapi_ch_free((void **)&buildnum);
}
@@ -1696,6 +1704,7 @@ slapd_log_audit_proc (
char *buffer,
int buf_len)
{
+ int err;
if ( (loginfo.log_audit_state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL) ){
LOG_AUDIT_LOCK_WRITE( );
if (log__needrotation(loginfo.log_audit_fdes,
@@ -1715,7 +1724,7 @@ slapd_log_audit_proc (
log_write_title( loginfo.log_audit_fdes);
loginfo.log_audit_state &= ~LOGGING_NEED_TITLE;
}
- LOG_WRITE_NOW(loginfo.log_audit_fdes, buffer, buf_len, 0);
+ LOG_WRITE_NOW(loginfo.log_audit_fdes, buffer, buf_len, 0, err);
LOG_AUDIT_UNLOCK_WRITE();
return 0;
}
@@ -1755,6 +1764,8 @@ slapd_log_error_proc_internal(
SLAPD_ERROR_LOG) == LOG_ROTATE) {
if (log__open_errorlogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) {
LOG_ERROR_UNLOCK_WRITE();
+ /* shouldn't continue. error is syslog'ed in open_errorlogfile */
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
return 0;
}
while (loginfo.log_error_rotationsyncclock <= loginfo.log_error_ctime) {
@@ -1763,19 +1774,19 @@ slapd_log_error_proc_internal(
}
if (!(detached)) {
- rc = vslapd_log_error( NULL, subsystem, fmt, ap_err );
+ rc = vslapd_log_error( NULL, subsystem, fmt, ap_err, 1 );
}
if ( loginfo.log_error_fdes != NULL ) {
if (loginfo.log_error_state & LOGGING_NEED_TITLE) {
log_write_title(loginfo.log_error_fdes);
loginfo.log_error_state &= ~LOGGING_NEED_TITLE;
}
- rc = vslapd_log_error( loginfo.log_error_fdes, subsystem, fmt, ap_file );
+ rc = vslapd_log_error( loginfo.log_error_fdes, subsystem, fmt, ap_file, 1 );
}
LOG_ERROR_UNLOCK_WRITE();
} else {
/* log the problem in the stderr */
- rc = vslapd_log_error( NULL, subsystem, fmt, ap_err );
+ rc = vslapd_log_error( NULL, subsystem, fmt, ap_err, 0 );
}
return( rc );
}
@@ -1785,17 +1796,19 @@ vslapd_log_error(
LOGFD fp,
char *subsystem, /* omitted if NULL */
char *fmt,
- va_list ap )
+ va_list ap,
+ int locked )
{
- time_t tnl;
- long tz;
- struct tm *tmsp, tms;
- char tbuf[ TBUFSIZE ];
- char sign;
- char buffer[SLAPI_LOG_BUFSIZ];
- int blen;
- char *vbuf;
- int header_len = 0;
+ time_t tnl;
+ long tz;
+ struct tm *tmsp, tms;
+ char tbuf[ TBUFSIZE ];
+ char sign;
+ char buffer[SLAPI_LOG_BUFSIZ];
+ int blen;
+ char *vbuf;
+ int header_len = 0;
+ int err = 0;
tnl = current_time();
#ifdef _WIN32
@@ -1813,50 +1826,67 @@ vslapd_log_error(
#else /* BSD_TIME */
tz = - timezone;
if ( tmsp->tm_isdst ) {
- tz += 3600;
+ tz += 3600;
}
#endif /* BSD_TIME */
sign = ( tz >= 0 ? '+' : '-' );
if ( tz < 0 ) {
- tz = -tz;
+ tz = -tz;
}
(void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
sprintf( buffer, "[%s %c%02d%02d]%s%s - ", tbuf, sign,
- (int)( tz / 3600 ), (int)( tz % 3600 ),
- subsystem ? " " : "",
- subsystem ? subsystem : "");
-
- /* Bug 561525: to be able to remove timestamp to not over pollute syslog, we may need
- to skip the timestamp part of the message.
- The size of the header is:
- the size of the time string
- + size of space
- + size of one char (sign)
- + size of 2 char
- + size of 2 char
- + size of [
- + size of ]
- */
+ (int)( tz / 3600 ), (int)( tz % 3600 ),
+ subsystem ? " " : "",
+ subsystem ? subsystem : "");
+
+ /* Bug 561525: to be able to remove timestamp to not over pollute syslog, we may need
+ to skip the timestamp part of the message.
+ The size of the header is:
+ the size of the time string
+ + size of space
+ + size of one char (sign)
+ + size of 2 char
+ + size of 2 char
+ + size of [
+ + size of ]
+ */
- header_len = strlen(tbuf) + 8;
+ header_len = strlen(tbuf) + 8;
if ((vbuf = PR_vsmprintf(fmt, ap)) == NULL) {
- return -1;
+ return -1;
}
blen = strlen(buffer);
- if ((unsigned int)(SLAPI_LOG_BUFSIZ - blen ) < strlen(vbuf)) {
- free (vbuf);
- return -1;
- }
-
- sprintf (buffer+blen, "%s", vbuf);
+ PR_snprintf (buffer+blen, sizeof(buffer)-blen, "%s", vbuf);
+ buffer[sizeof(buffer)-1] = '\0';
if (fp)
- LOG_WRITE_NOW(fp, buffer, strlen(buffer), header_len);
-
-
+#if 0
+ LOG_WRITE_NOW(fp, buffer, strlen(buffer), header_len, err);
+#else
+ do {
+ int size = strlen(buffer);
+ (err) = 0;
+ if ( slapi_write_buffer((fp), (buffer), (size)) != (size) )
+ {
+ PRErrorCode prerr = PR_GetError();
+ syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer)+(header_len) );
+ (err) = prerr;
+ }
+ /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */
+ PR_Sync(fp);
+ } while (0);
+#endif
else /* stderr is always unbuffered */
- fprintf(stderr, "%s", buffer);
+ fprintf(stderr, "%s", buffer);
+
+ if (err) {
+ PR_snprintf(buffer, sizeof(buffer),
+ "Writing to the errors log failed. Exiting...");
+ log__error_emergency(buffer, 1, locked);
+ /* failed to write to the errors log. should not continue. */
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ }
PR_smprintf_free (vbuf);
return( 0 );
@@ -1865,31 +1895,31 @@ vslapd_log_error(
int
slapi_log_error( int severity, char *subsystem, char *fmt, ... )
{
- va_list ap1;
- va_list ap2;
- int rc;
+ va_list ap1;
+ va_list ap2;
+ int rc;
if ( severity < SLAPI_LOG_MIN || severity > SLAPI_LOG_MAX ) {
- (void)slapd_log_error_proc( subsystem,
- "slapi_log_error: invalid severity %d (message %s)\n",
- severity, fmt );
- return( -1 );
+ (void)slapd_log_error_proc( subsystem,
+ "slapi_log_error: invalid severity %d (message %s)\n",
+ severity, fmt );
+ return( -1 );
}
-
+ if (
#ifdef _WIN32
- if ( *module_ldap_debug
+ *module_ldap_debug
#else
- if ( slapd_ldap_debug
+ slapd_ldap_debug
#endif
- & slapi_log_map[ severity ] ) {
- va_start( ap1, fmt );
- va_start( ap2, fmt );
- rc = slapd_log_error_proc_internal( subsystem, fmt, ap1, ap2 );
- va_end( ap1 );
- va_end( ap2 );
+ & slapi_log_map[ severity ] ) {
+ va_start( ap1, fmt );
+ va_start( ap2, fmt );
+ rc = slapd_log_error_proc_internal( subsystem, fmt, ap1, ap2 );
+ va_end( ap1 );
+ va_end( ap2 );
} else {
- rc = 0; /* nothing to be logged --> always return success */
+ rc = 0; /* nothing to be logged --> always return success */
}
return( rc );
@@ -1899,13 +1929,13 @@ int
slapi_is_loglevel_set ( const int loglevel )
{
- return (
+ return (
#ifdef _WIN32
*module_ldap_debug
#else
slapd_ldap_debug
#endif
- & slapi_log_map[ loglevel ] ? 1 : 0);
+ & slapi_log_map[ loglevel ] ? 1 : 0);
}
@@ -3474,6 +3504,31 @@ log__audit_rotationinfof( char *pathname)
return logfile_type;
}
+static void
+log__error_emergency(const char *errstr, int reopen, int locked)
+{
+ syslog(LOG_ERR, "%s\n", errstr);
+
+ /* emergency open */
+ if (!reopen) {
+ return;
+ }
+ if (NULL != loginfo.log_error_fdes) {
+ LOG_CLOSE(loginfo.log_error_fdes);
+ }
+ if (! LOG_OPEN_APPEND(loginfo.log_error_fdes,
+ loginfo.log_error_file, loginfo.log_error_mode)) {
+ PRErrorCode prerr = PR_GetError();
+ syslog(LOG_ERR, "Failed to reopen errors log file, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n", prerr, slapd_pr_strerror(prerr));
+ } else {
+ /* LDAPDebug locks ERROR_LOCK_WRITE internally */
+ if (locked) LOG_ERROR_UNLOCK_WRITE();
+ LDAPDebug(LDAP_DEBUG_ANY, "%s\n", errstr, 0, 0);
+ if (locked) LOG_ERROR_LOCK_WRITE( );
+ }
+ return;
+}
+
/******************************************************************************
* log__open_errorlogfile
*
@@ -3485,7 +3540,7 @@ log__open_errorlogfile(int logfile_state, int locked)
{
time_t now;
- LOGFD fp;
+ LOGFD fp = NULL;
LOGFD fpinfo = NULL;
char tbuf[TBUFSIZE];
struct logfileinfo *logp;
@@ -3500,6 +3555,9 @@ log__open_errorlogfile(int logfile_state, int locked)
pw = slapdFrontendConfig->localuserinfo;
}
else {
+ PR_snprintf(buffer, sizeof(buffer),
+ "Invalid nsslapd-localuser. Cannot open the errors log. Exiting...");
+ log__error_emergency(buffer, 0, locked);
return LOG_UNABLE_TO_OPENFILE;
}
#endif
@@ -3541,6 +3599,14 @@ log__open_errorlogfile(int logfile_state, int locked)
log_convert_time (log->l_ctime, tbuf, 1/*short */);
PR_snprintf(newfile, sizeof(newfile), "%s.%s", loginfo.log_error_file, tbuf);
if (PR_Rename (loginfo.log_error_file, newfile) != PR_SUCCESS) {
+ PRErrorCode prerr = PR_GetError();
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to rename errors log file, "
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s). Exiting...",
+ prerr, slapd_pr_strerror(prerr));
+ log__error_emergency(buffer, 1, 1);
+ slapi_ch_free((void **)&log);
+ if (!locked) LOG_ERROR_UNLOCK_WRITE();
return LOG_UNABLE_TO_OPENFILE;
}
@@ -3551,15 +3617,17 @@ log__open_errorlogfile(int logfile_state, int locked)
}
}
-
/* open a new log file */
if (! LOG_OPEN_APPEND(fp, loginfo.log_error_file, loginfo.log_error_mode)) {
- LDAPDebug(LDAP_DEBUG_ANY, "WARNING: can't open file %s. "
- "errno %d (%s)\n",
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to open errors log file %s: error %d (%s); Exiting...",
loginfo.log_error_file, errno, slapd_system_strerror(errno));
+ log__error_emergency(buffer, 1, locked);
if (!locked) LOG_ERROR_UNLOCK_WRITE();
+ /* failed to write to the errors log. should not continue. */
+ g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
/*if I have an old log file -- I should log a message
- ** that I can't open the new file. Let the caller worry
+ ** that I can't open the new file. Let the caller worry
** about logging message.
*/
return LOG_UNABLE_TO_OPENFILE;
@@ -3583,9 +3651,10 @@ log__open_errorlogfile(int logfile_state, int locked)
loginfo.log_error_state |= LOGGING_NEED_TITLE;
if (! LOG_OPEN_WRITE(fpinfo, loginfo.log_errorinfo_file, loginfo.log_error_mode)) {
- LDAPDebug(LDAP_DEBUG_ANY, "WARNING: can't open file %s. "
- "errno %d (%s)\n",
- loginfo.log_errorinfo_file, errno, slapd_system_strerror(errno));
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to open/write to errors log file %s: error %d (%s). Exiting...",
+ loginfo.log_error_file, errno, slapd_system_strerror(errno));
+ log__error_emergency(buffer, 1, locked);
if (!locked) LOG_ERROR_UNLOCK_WRITE();
return LOG_UNABLE_TO_OPENFILE;
}
@@ -3597,7 +3666,7 @@ log__open_errorlogfile(int logfile_state, int locked)
LOG_WRITE(fpinfo, buffer, strlen(buffer), 0);
logp = loginfo.log_error_logchain;
- while ( logp) {
+ while (logp) {
log_convert_time (logp->l_ctime, tbuf, 1 /*short */);
PR_snprintf(buffer, sizeof(buffer), "LOGINFO:%s%s.%s (%lu) (%u)\n",
PREVLOGFILE, loginfo.log_error_file, tbuf, logp->l_ctime, logp->l_size);
@@ -3607,7 +3676,7 @@ log__open_errorlogfile(int logfile_state, int locked)
/* Close the info file. We need only when we need to rotate to the
** next log file.
*/
- if (fpinfo) LOG_CLOSE(fpinfo);
+ if (fpinfo) LOG_CLOSE(fpinfo);
/* This is now the current error log */
loginfo.log_error_ctime = now;
@@ -3836,6 +3905,7 @@ static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_
static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ int err = 0;
if (type == SLAPD_ACCESS_LOG) {
@@ -3868,7 +3938,8 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
if (!sync_now && slapdFrontendConfig->accesslogbuffering) {
LOG_WRITE(loginfo.log_access_fdes, lbi->top, lbi->current - lbi->top, 0);
} else {
- LOG_WRITE_NOW(loginfo.log_access_fdes, lbi->top, lbi->current - lbi->top, 0);
+ LOG_WRITE_NOW(loginfo.log_access_fdes, lbi->top,
+ lbi->current - lbi->top, 0, err);
}
lbi->current = lbi->top;
| 0 |
daaae1c5ee00c43506543bb1ac469545bb2c6004
|
389ds/389-ds-base
|
Trac Ticket #18 - Data inconsitency during replication
https://fedorahosted.org/389/ticket/18
Bug description: If promote a hub server to a new master and
assign the same replica ID as the original master server had,
some new adds/modifies to the new server may dropped and not
be replicated to the consumers.
Fix description: If a hub is promoted to a master, consumer's
RUV is updated. It only updated the master's URL, but not the
CSN and min CSN. This patch resets the CSNs if the URL needs
to be updated.
|
commit daaae1c5ee00c43506543bb1ac469545bb2c6004
Author: Noriko Hosoi <[email protected]>
Date: Thu Jan 19 11:19:53 2012 -0800
Trac Ticket #18 - Data inconsitency during replication
https://fedorahosted.org/389/ticket/18
Bug description: If promote a hub server to a new master and
assign the same replica ID as the original master server had,
some new adds/modifies to the new server may dropped and not
be replicated to the consumers.
Fix description: If a hub is promoted to a master, consumer's
RUV is updated. It only updated the master's URL, but not the
CSN and min CSN. This patch resets the CSNs if the URL needs
to be updated.
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index e5ddb3900..e0b10aecc 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -479,21 +479,26 @@ int
ruv_replace_replica_purl (RUV *ruv, ReplicaId rid, const char *replica_purl)
{
RUVElement* replica;
- int rc = RUV_NOTFOUND;
-
+ int rc = RUV_NOTFOUND;
+
PR_ASSERT (ruv && replica_purl);
slapi_rwlock_wrlock (ruv->lock);
replica = ruvGetReplica (ruv, rid);
if (replica != NULL)
{
- slapi_ch_free((void **)&(replica->replica_purl));
- replica->replica_purl = slapi_ch_strdup(replica_purl);
+ if (strcmp(replica->replica_purl, replica_purl)) { /* purl updated */
+ /* Replace replica_purl in RUV since supplier has been updated. */
+ slapi_ch_free((void **)&(replica->replica_purl));
+ replica->replica_purl = slapi_ch_strdup(replica_purl);
+ /* Also, reset csn and min_csn. */
+ replica->csn = replica->min_csn = NULL;
+ }
rc = RUV_SUCCESS;
- }
+ }
- slapi_rwlock_unlock (ruv->lock);
- return rc;
+ slapi_rwlock_unlock (ruv->lock);
+ return rc;
}
int
| 0 |
391921702407acd9792b415e96d40935dad918a4
|
389ds/389-ds-base
|
Ticket 83 - Fix create_test.py imports
Description: The import for "os" was removed, but it is needed in every test script
https://pagure.io/lib389/issue/83
Reviewed by: mreynolds(one line commit rule)
|
commit 391921702407acd9792b415e96d40935dad918a4
Author: Mark Reynolds <[email protected]>
Date: Thu Sep 14 12:05:47 2017 -0400
Ticket 83 - Fix create_test.py imports
Description: The import for "os" was removed, but it is needed in every test script
https://pagure.io/lib389/issue/83
Reviewed by: mreynolds(one line commit rule)
diff --git a/dirsrvtests/create_test.py b/dirsrvtests/create_test.py
index 25f48476d..da336fd45 100755
--- a/dirsrvtests/create_test.py
+++ b/dirsrvtests/create_test.py
@@ -212,7 +212,7 @@ if len(sys.argv) > 0:
else:
topology_import = ''
- TEST.write('import logging\nimport pytest\n')
+ TEST.write('import logging\nimport pytest\nimport os\n')
TEST.write('{}\n'.format(topology_import))
TEST.write('DEBUGGING = os.getenv("DEBUGGING", default=False)\n')
| 0 |
20284e6539f557efc0679d974d5156cdcd55c407
|
389ds/389-ds-base
|
Ticket 48215 - update dbverify usage
Description: Need to add the "-a" argument usage
https://fedorahosted.org/389/ticket/48215
|
commit 20284e6539f557efc0679d974d5156cdcd55c407
Author: Mark Reynolds <[email protected]>
Date: Thu Aug 6 10:13:40 2015 -0400
Ticket 48215 - update dbverify usage
Description: Need to add the "-a" argument usage
https://fedorahosted.org/389/ticket/48215
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index 778a9ba5b..461cc16ff 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -14,15 +14,16 @@ PATH=$PATH:/bin
usage()
{
- echo "Usage: dbverify [-Z serverID] [-n backend_instance] [-V] [-v] [-d debuglevel] [-h]"
+ echo "Usage: dbverify [-Z serverID] [-n backend_instance] [-a db_directory ] [-V] [-v] [-d debuglevel] [-h]"
echo "Note if \"-n backend\" is not passed, verify all DBs."
echo "Options:"
- echo " -Z - Server instance identifier"
- echo " -n backend - Backend database name. Example: userRoot"
- echo " -V - Verbose output"
- echo " -d debuglevel - Debugging level"
- echo " -v - Display version"
- echo " -h - Display usage"
+ echo " -Z - Server instance identifier"
+ echo " -n backend - Backend database name. Example: userRoot"
+ echo " -a db_directory - Database directory"
+ echo " -V - Verbose output"
+ echo " -d debuglevel - Debugging level"
+ echo " -v - Display version"
+ echo " -h - Display usage"
}
display_version="no"
| 0 |
bdcbf5bfdb45bf51a3ea306394ca1e3649be38a9
|
389ds/389-ds-base
|
Ticket 48118 - fix compiler warning for incorrect return type
|
commit bdcbf5bfdb45bf51a3ea306394ca1e3649be38a9
Author: Ludwig Krispenz <[email protected]>
Date: Wed Nov 15 13:17:00 2017 +0100
Ticket 48118 - fix compiler warning for incorrect return type
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 55032dfb0..721013abf 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -250,8 +250,8 @@ static void _cl5ReadBerval(struct berval *bv, char **buff);
static void _cl5WriteBerval(struct berval *bv, char **buff);
static int _cl5ReadBervals(struct berval ***bv, char **buff, unsigned int size);
static int _cl5WriteBervals(struct berval **bv, char **buff, u_int32_t *size);
-static int64_t _cl5CheckMaxRUV(CL5DBFile *file, RUV *maxruv);
-static int64_t _cl5CheckCSNinCL(const ruv_enum_data *element, void *arg);
+static int32_t _cl5CheckMaxRUV(CL5DBFile *file, RUV *maxruv);
+static int32_t _cl5CheckCSNinCL(const ruv_enum_data *element, void *arg);
/* replay iteration */
#ifdef FOR_DEBUGGING
@@ -2718,7 +2718,7 @@ _cl5WriteBervals(struct berval **bv, char **buff, u_int32_t *size)
return CL5_SUCCESS;
}
-static int64_t
+static int32_t
_cl5CheckCSNinCL(const ruv_enum_data *element, void *arg)
{
CL5DBFile *file = (CL5DBFile *)arg;
@@ -2739,7 +2739,7 @@ _cl5CheckCSNinCL(const ruv_enum_data *element, void *arg)
return rc;
}
-static int64_t
+static int32_t
_cl5CheckMaxRUV(CL5DBFile *file, RUV *maxruv)
{
int rc = 0;
| 0 |
8a4bbc7c74a6847d75e4d6e9e0b16859a5da8ec0
|
389ds/389-ds-base
|
Ticket 47620 - Config value validation improvement
Bug Description: When setting the replication protocol timeout, it is possible
to set a negative number(it should be rejected), and when
setting the timeout for an agreement using letters, we get an
invalid syntax error, but it should really be an error 53 to
be consistent with how the invalid timeout error that is given
when updating the replica entry.
Fix Description: In the agmt modify code, we did not have the actual modify value
during the validation. This allowed the value to be added, which
was later caught for the invalid syntax. Then improved the overall
logic to the validation to also catch the negative numbers.
https://fedorahosted.org/389/ticket/47620
Reviewed by: rmeggins(Thanks!)
|
commit 8a4bbc7c74a6847d75e4d6e9e0b16859a5da8ec0
Author: Mark Reynolds <[email protected]>
Date: Fri Dec 13 11:43:47 2013 -0500
Ticket 47620 - Config value validation improvement
Bug Description: When setting the replication protocol timeout, it is possible
to set a negative number(it should be rejected), and when
setting the timeout for an agreement using letters, we get an
invalid syntax error, but it should really be an error 53 to
be consistent with how the invalid timeout error that is given
when updating the replica entry.
Fix Description: In the agmt modify code, we did not have the actual modify value
during the validation. This allowed the value to be added, which
was later caught for the invalid syntax. Then improved the overall
logic to the validation to also catch the negative numbers.
https://fedorahosted.org/389/ticket/47620
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5_agmtlist.c b/ldap/servers/plugins/replication/repl5_agmtlist.c
index f9b844b2b..7d1c6518c 100644
--- a/ldap/servers/plugins/replication/repl5_agmtlist.c
+++ b/ldap/servers/plugins/replication/repl5_agmtlist.c
@@ -245,6 +245,7 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
for (i = 0; NULL != mods && NULL != mods[i]; i++)
{
slapi_ch_free_string(&val);
+ val = slapi_berval_get_string_copy (mods[i]->mod_bvalues[0]);
if (slapi_attr_types_equivalent(mods[i]->mod_type, type_nsds5ReplicaInitialize))
{
/* we don't allow delete attribute operations unless it was issued by
@@ -268,10 +269,7 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
}
else
{
- if (mods[i]->mod_bvalues && mods[i]->mod_bvalues[0])
- val = slapi_berval_get_string_copy (mods[i]->mod_bvalues[0]);
- else
- {
+ if(val == NULL){
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: "
"no value provided for %s attribute\n", type_nsds5ReplicaInitialize);
*returncode = LDAP_UNWILLING_TO_PERFORM;
@@ -524,19 +522,23 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
}
}
else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_replicaProtocolTimeout)){
- if (val){
- long ptimeout = atol(val);
+ long ptimeout = 0;
- if(ptimeout <= 0){
- *returncode = LDAP_UNWILLING_TO_PERFORM;
- 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);
- rc = SLAPI_DSE_CALLBACK_ERROR;
- break;
- }
- agmt_set_protocol_timeout(agmt, ptimeout);
+ 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);
}
else if (0 == windows_handle_modify_agreement(agmt, mods[i]->mod_type, e))
{
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 4a3f29ff9..9abbbac77 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -498,17 +498,21 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
else if (strcasecmp (config_attr, type_replicaProtocolTimeout) == 0 ){
if (apply_mods && config_attr_value && config_attr_value[0])
{
- long ptimeout = atol(config_attr_value);
+ long ptimeout = 0;
+
+ if(config_attr_value){
+ ptimeout = atol(config_attr_value);
+ }
if(ptimeout <= 0){
*returncode = LDAP_UNWILLING_TO_PERFORM;
PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
"attribute %s value (%s) is invalid, must be a number greater than zero.\n",
- config_attr, config_attr_value);
+ config_attr, config_attr_value ? config_attr_value : "");
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n", errortext);
- } else {
- replica_set_protocol_timeout(r, ptimeout);
+ break;
}
+ replica_set_protocol_timeout(r, ptimeout);
}
}
else
| 0 |
a24d9cca5f0618af8393f8659d559ec355beae12
|
389ds/389-ds-base
|
Bug 691313 - Need TLS/SSL error messages in repl status and errors log
When an error is encnountered during the bind operation in the
beginning of a replication session, the error is only logged
at the fatal level the first time it is encountered. If replication
level logging is turned on, it can be easy to miss the error the
first time, so the subsequent debug logging is not very useful.
This patch makes us log repeated bind errors at the replication log
level only. The first time an error is encountered, it will still
be logged at the fatal level.
|
commit a24d9cca5f0618af8393f8659d559ec355beae12
Author: Nathan Kinder <[email protected]>
Date: Fri Jul 8 12:59:09 2011 -0700
Bug 691313 - Need TLS/SSL error messages in repl status and errors log
When an error is encnountered during the bind operation in the
beginning of a replication session, the error is only logged
at the fatal level the first time it is encountered. If replication
level logging is turned on, it can be easy to miss the error the
first time, so the subsequent debug logging is not very useful.
This patch makes us log repeated bind errors at the replication log
level only. The first time an error is encountered, it will still
be logged at the fatal level.
diff --git a/ldap/servers/plugins/replication/repl5_connection.c b/ldap/servers/plugins/replication/repl5_connection.c
index c77819a40..4cf69d1d9 100644
--- a/ldap/servers/plugins/replication/repl5_connection.c
+++ b/ldap/servers/plugins/replication/repl5_connection.c
@@ -1799,7 +1799,8 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password)
else
{
ldap_controls_free( ctrls );
- /* Do not report the same error over and over again */
+ /* Do not report the same error over and over again
+ * unless replication level logging is enabled. */
if (conn->last_ldap_error != rc)
{
char *errmsg = NULL;
@@ -1811,6 +1812,15 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password)
agmt_get_long_name(conn->agmt),
mech ? mech : "SIMPLE", rc,
ldap_err2string(rc), errmsg);
+ } else {
+ char *errmsg = NULL;
+ /* errmsg is a pointer directly into the ld structure - do not free */
+ rc = slapi_ldap_get_lderrno( ld, NULL, &errmsg );
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "%s: Replication bind with %s auth failed: LDAP error %d (%s) (%s)\n",
+ agmt_get_long_name(conn->agmt),
+ mech ? mech : "SIMPLE", rc,
+ ldap_err2string(rc), errmsg);
}
return (CONN_OPERATION_FAILED);
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index 52a24243b..f76e749c1 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -1802,7 +1802,8 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password)
else
{
ldap_controls_free( ctrls );
- /* Do not report the same error over and over again */
+ /* Do not report the same error over and over again
+ * unless replication level logging is enabled. */
if (conn->last_ldap_error != rc)
{
char *errmsg = NULL;
@@ -1814,6 +1815,15 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password)
agmt_get_long_name(conn->agmt),
mech ? mech : "SIMPLE", rc,
ldap_err2string(rc), errmsg);
+ } else {
+ char *errmsg = NULL;
+ /* errmsg is a pointer directly into the ld structure - do not free */
+ rc = slapi_ldap_get_lderrno( ld, NULL, &errmsg );
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "%s: Replication bind with %s auth failed: LDAP error %d (%s) (%s)\n",
+ agmt_get_long_name(conn->agmt),
+ mech ? mech : "SIMPLE", rc,
+ ldap_err2string(rc), errmsg);
}
LDAPDebug( LDAP_DEBUG_TRACE, "<= bind_and_check_pwp - CONN_OPERATION_FAILED\n", 0, 0, 0 );
| 0 |
741e7a72a2d13db8ece6d2d23c304184154e9770
|
389ds/389-ds-base
|
Issue 4127 - With Accounts/Account module delete fuction is not working (#4697)
Description: Added a test to verify delete function is working with Accounts/Account
Relates: https://github.com/389ds/389-ds-base/issues/4127
Reviewed by: @droideck
|
commit 741e7a72a2d13db8ece6d2d23c304184154e9770
Author: Akshay Adhikari <[email protected]>
Date: Wed Mar 24 20:52:23 2021 +0530
Issue 4127 - With Accounts/Account module delete fuction is not working (#4697)
Description: Added a test to verify delete function is working with Accounts/Account
Relates: https://github.com/389ds/389-ds-base/issues/4127
Reviewed by: @droideck
diff --git a/dirsrvtests/tests/suites/lib389/idm/account_test.py b/dirsrvtests/tests/suites/lib389/idm/account_test.py
new file mode 100644
index 000000000..32cbdafc7
--- /dev/null
+++ b/dirsrvtests/tests/suites/lib389/idm/account_test.py
@@ -0,0 +1,42 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2021 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import os
+import pytest
+from lib389.idm.user import UserAccounts, Account
+from lib389.topologies import topology_st as topo
+from lib389._constants import DEFAULT_SUFFIX
+
+
+def test_account_delete(topo):
+ """
+ Test that delete function is working with Accounts/Account
+
+ :id: 9b036f14-5144-4862-b18c-a6d91b7a1620
+
+ :setup: Standalone instance
+
+ :steps:
+ 1. Create a test user.
+ 2. Delete the test user using Account class object.
+
+ :expectedresults:
+ 1. Operation should be successful
+ 2. Operation should be successful
+ """
+ users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
+ users.create_test_user(uid=1001)
+ account = Account(topo.standalone, f'uid=test_user_1001,ou=People,{DEFAULT_SUFFIX}')
+ account.delete()
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
| 0 |
e8a685f2c4f0227cf96e246799ed14ec6d71b30f
|
389ds/389-ds-base
|
Bug 750625 - Fix Coverity (11057) Dereference null return value
https://bugzilla.redhat.com/show_bug.cgi?id=750625
plugins/acl/aclutil.c (aclutil_expand_paramString)
Bug Description: Dereferencing a null pointer "a_dns".
Missing a check of the NULL possibilities for slapi_entry_get_ndn(e),
str and their exploded results.
Fix Description: check if slapi_entry_get_ndn(e), str and their
exploded values are NULL or not. If any of the values are NULL,
it does not go further, but returns.
|
commit e8a685f2c4f0227cf96e246799ed14ec6d71b30f
Author: Noriko Hosoi <[email protected]>
Date: Tue Nov 1 17:45:35 2011 -0700
Bug 750625 - Fix Coverity (11057) Dereference null return value
https://bugzilla.redhat.com/show_bug.cgi?id=750625
plugins/acl/aclutil.c (aclutil_expand_paramString)
Bug Description: Dereferencing a null pointer "a_dns".
Missing a check of the NULL possibilities for slapi_entry_get_ndn(e),
str and their exploded results.
Fix Description: check if slapi_entry_get_ndn(e), str and their
exploded values are NULL or not. If any of the values are NULL,
it does not go further, but returns.
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index d57291100..2f24da3b2 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -555,9 +555,14 @@ aclutil_expand_paramString ( char *str, Slapi_Entry *e )
int rc = -1;
char *buf = NULL;
-
+ if ((NULL == slapi_entry_get_ndn ( e )) || (NULL == str)) {
+ return NULL;
+ }
e_dns = slapi_ldap_explode_dn ( slapi_entry_get_ndn ( e ), 0 );
a_dns = slapi_ldap_explode_dn ( str, 0 );
+ if ((NULL == e_dns) || (NULL == a_dns)) {
+ goto cleanup;
+ }
i = 0;
ncomponents = 0;
| 0 |
dadcd7890ff5e44b7b9e30ac36290559287b9ed2
|
389ds/389-ds-base
|
Ticket #360 - ldapmodify returns Operations error
https://fedorahosted.org/389/ticket/360
Resolves: Ticket #360
Bug Description: ldapmodify returns Operations error
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description:
1) Fix handling of DB_LOCK_DEADLOCK conditions. When a database operation
returns DB_LOCK_DEADLOCK, all cursors must be closed, and the transaction
aborted and retried. If not in a transaction, the operation may be retried
immediately. This fix adds this logic to many places in the db code where
it was lacking.
2) Fix resetting of the data when an operation has to be retried. When
a transaction has to be retried, we must reset the data to the same state
it was before any of the operations in the transaction were attempted. This
includes the entry cache state, which was lacking in a number of ways. One
major problem with resetting the cache is that cache_add_tentative adds an
entry to the dncache, but not the idcache, in order to reserve a space in
the cache, and to prevent other entries with the same DN from being added
while the operation is in progress. There was no good way to remove this
entry. In the case of modrdn, removing the tentative entry would also
remove the real entry since they share the same entryid. This fix also
makes sure that in error conditions, temporary entries are removed from
the cache and properly freed, and real entries are "rolled back" into the
cache.
3) Added a transaction stress thread. This thread can simulate various types
of read and write locking that can cause conflicts and trigger regular
database operations to return DB_LOCK_DEADLOCK. The usual culprit is read
locks which are held on pages that are searched outside of a transaction.
The stress thread can lock, via read cursors, all of the pages in all of
the indexes in the database, and hold these pages for some set period of
time, then loop and do it again.
4) It is quite easy to get the database in a deadlock situation, where a
update operation is waiting for a read lock to be released in order to
write to a page, while a search operation is waiting for a write lock to
be released in order to read lock the page. If we are going to allow
concurrent searches during update operations, without making search requests
transacted, we need to have some way to detect these deadlocks. The fastest
way to do it is to use the DB_TXN_NOWAIT flag when starting transactions.
This tells bdb to return immediately with a DB_LOCK_DEADLOCK if the
transaction cannot proceed due to a locked page (e.g. a search request
has read locked a page). Alternately, we could have transactions wait
for some specified period of time, but if we think that this type of thread
contention is going to be rare, it makes sense to return immediately, if
our deadlock handling is fast and robust.
5) Fixed some memory leaks
6) The txn_test thread needs to know when the backend databases are
available - had to add a backend flag BE_STATE_STOPPING so that
the txn_thread knows when the databases are available
7) If the op was retried RETRY_TIMES times, return LDAP_BUSY instead of
OPERATIONS_ERROR - the problem really is that the server is busy with
other transactions, and the operation could go through if the client
were to retry.
8) Renaming an entry without changing the dn e.g. changing the case does
not cache the entry, so handle that
9) Added a delay when a deadlock is encountered in modrdn - same as the
other add/mod/del cases
Platforms tested: RHEL6 x86_64, Fedora 17
Flag Day: yes
Doc impact: yes
(cherry picked from commit 48b8ace54583662306c75f22f2f243fc274251af)
|
commit dadcd7890ff5e44b7b9e30ac36290559287b9ed2
Author: Rich Megginson <[email protected]>
Date: Mon May 14 15:14:28 2012 -0600
Ticket #360 - ldapmodify returns Operations error
https://fedorahosted.org/389/ticket/360
Resolves: Ticket #360
Bug Description: ldapmodify returns Operations error
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description:
1) Fix handling of DB_LOCK_DEADLOCK conditions. When a database operation
returns DB_LOCK_DEADLOCK, all cursors must be closed, and the transaction
aborted and retried. If not in a transaction, the operation may be retried
immediately. This fix adds this logic to many places in the db code where
it was lacking.
2) Fix resetting of the data when an operation has to be retried. When
a transaction has to be retried, we must reset the data to the same state
it was before any of the operations in the transaction were attempted. This
includes the entry cache state, which was lacking in a number of ways. One
major problem with resetting the cache is that cache_add_tentative adds an
entry to the dncache, but not the idcache, in order to reserve a space in
the cache, and to prevent other entries with the same DN from being added
while the operation is in progress. There was no good way to remove this
entry. In the case of modrdn, removing the tentative entry would also
remove the real entry since they share the same entryid. This fix also
makes sure that in error conditions, temporary entries are removed from
the cache and properly freed, and real entries are "rolled back" into the
cache.
3) Added a transaction stress thread. This thread can simulate various types
of read and write locking that can cause conflicts and trigger regular
database operations to return DB_LOCK_DEADLOCK. The usual culprit is read
locks which are held on pages that are searched outside of a transaction.
The stress thread can lock, via read cursors, all of the pages in all of
the indexes in the database, and hold these pages for some set period of
time, then loop and do it again.
4) It is quite easy to get the database in a deadlock situation, where a
update operation is waiting for a read lock to be released in order to
write to a page, while a search operation is waiting for a write lock to
be released in order to read lock the page. If we are going to allow
concurrent searches during update operations, without making search requests
transacted, we need to have some way to detect these deadlocks. The fastest
way to do it is to use the DB_TXN_NOWAIT flag when starting transactions.
This tells bdb to return immediately with a DB_LOCK_DEADLOCK if the
transaction cannot proceed due to a locked page (e.g. a search request
has read locked a page). Alternately, we could have transactions wait
for some specified period of time, but if we think that this type of thread
contention is going to be rare, it makes sense to return immediately, if
our deadlock handling is fast and robust.
5) Fixed some memory leaks
6) The txn_test thread needs to know when the backend databases are
available - had to add a backend flag BE_STATE_STOPPING so that
the txn_thread knows when the databases are available
7) If the op was retried RETRY_TIMES times, return LDAP_BUSY instead of
OPERATIONS_ERROR - the problem really is that the server is busy with
other transactions, and the operation could go through if the client
were to retry.
8) Renaming an entry without changing the dn e.g. changing the case does
not cache the entry, so handle that
9) Added a delay when a deadlock is encountered in modrdn - same as the
other add/mod/del cases
Platforms tested: RHEL6 x86_64, Fedora 17
Flag Day: yes
Doc impact: yes
(cherry picked from commit 48b8ace54583662306c75f22f2f243fc274251af)
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index a768edb34..2b4d0c951 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -1007,6 +1007,11 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
return 0;
}
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
+ if (rc) { /* op failed - just return */
+ return 0;
+ }
+
/* we only log changes for operations applied to a replica */
repl_obj = replica_get_replica_for_op (pb);
if (repl_obj == NULL)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 9966a27d8..55deeee3a 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -665,6 +665,7 @@ static void op_shared_add (Slapi_PBlock *pb)
int rc;
Slapi_Entry *ec;
Slapi_DN *add_target_sdn = NULL;
+ Slapi_Entry *save_e = NULL;
slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database);
set_db_default_result_handlers(pb);
@@ -678,6 +679,8 @@ static void op_shared_add (Slapi_PBlock *pb)
if (be->be_add != NULL)
{
rc = (*be->be_add)(pb);
+ /* backend may change this if errors and not consumed */
+ slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &save_e);
slapi_pblock_set(pb, SLAPI_ADD_ENTRY, ec);
if (rc == 0)
{
@@ -703,6 +706,10 @@ static void op_shared_add (Slapi_PBlock *pb)
}
else
{
+ /* restore e so we can free it below */
+ if (save_e) {
+ e = save_e;
+ }
if (rc == SLAPI_FAIL_DISKFULL)
{
operation_out_of_disk_space();
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
index 2ef0f287b..045b1eba4 100644
--- a/ldap/servers/slapd/back-ldbm/cache.c
+++ b/ldap/servers/slapd/back-ldbm/cache.c
@@ -294,7 +294,7 @@ dump_hash(Hashtable *ht)
continue;
}
do {
- PR_snprintf(ep_id, 16, "%u", ((struct backcommon *)e)->ep_id);
+ PR_snprintf(ep_id, 16, "%u-%u", ((struct backcommon *)e)->ep_id, ((struct backcommon *)e)->ep_refcnt);
len = strlen(ep_id);
if (ids_size < len + 1) {
LDAPDebug1Arg(LDAP_DEBUG_ANY, "%s\n", ep_ids);
@@ -857,7 +857,7 @@ entrycache_remove_int(struct cache *cache, struct backentry *e)
const char *uuid;
#endif
- LOG("=> entrycache_remove_int (%s)\n", backentry_get_ndn(e), 0, 0);
+ LOG("=> entrycache_remove_int (%s) (%u) (%u)\n", backentry_get_ndn(e), e->ep_id, e->ep_refcnt);
if (e->ep_state & ENTRY_STATE_NOTINCACHE)
{
return ret;
@@ -876,13 +876,22 @@ entrycache_remove_int(struct cache *cache, struct backentry *e)
{
LOG("remove %s from dn hash failed\n", ndn, 0, 0);
}
- if (remove_hash(cache->c_idtable, &(e->ep_id), sizeof(ID)))
+ /* if entry was added tentatively, it will be in the dntable
+ but not in the idtable - we cannot just remove it from
+ the idtable - in the case of modrdn, this will remove
+ the _real_ entry from the idtable, leading to a cache
+ imbalance
+ */
+ if (!(e->ep_state & ENTRY_STATE_CREATING))
{
- ret = 0;
- }
- else
- {
- LOG("remove %d from id hash failed\n", e->ep_id, 0, 0);
+ if (remove_hash(cache->c_idtable, &(e->ep_id), sizeof(ID)))
+ {
+ ret = 0;
+ }
+ else
+ {
+ LOG("remove %d from id hash failed\n", e->ep_id, 0, 0);
+ }
}
#ifdef UUIDCACHE_ON
uuid = slapi_entry_get_uniqueid(e->ep_entry);
@@ -907,6 +916,11 @@ entrycache_remove_int(struct cache *cache, struct backentry *e)
/* mark for deletion (will be erased when refcount drops to zero) */
e->ep_state |= ENTRY_STATE_DELETED;
+#if 0
+ if (slapi_is_loglevel_set(SLAPI_LOG_CACHE)) {
+ dump_hash(cache->c_idtable);
+ }
+#endif
LOG("<= entrycache_remove_int: %d\n", ret, 0, 0);
return ret;
}
@@ -999,14 +1013,23 @@ static int entrycache_replace(struct cache *cache, struct backentry *olde,
* cache tables, operation error
*/
if ( (olde->ep_state & ENTRY_STATE_NOTINCACHE) == 0 ) {
-
- found = remove_hash(cache->c_dntable, (void *)oldndn, strlen(oldndn));
- found &= remove_hash(cache->c_idtable, &(olde->ep_id), sizeof(ID));
+ int found_in_dn = remove_hash(cache->c_dntable, (void *)oldndn, strlen(oldndn));
+ int found_in_id = remove_hash(cache->c_idtable, &(olde->ep_id), sizeof(ID));
+#ifdef UUIDCACHE_ON
+ int found_in_uuid = remove_hash(cache->c_uuidtable, (void *)olduuid, strlen(olduuid));
+#endif
+ found = found_in_dn && found_in_id;
#ifdef UUIDCACHE_ON
- found &= remove_hash(cache->c_uuidtable, (void *)olduuid, strlen(olduuid));
+ found = found && found_in_uuid;
#endif
if (!found) {
- LOG("entry cache replace: cache index tables out of sync\n", 0, 0, 0);
+#ifdef UUIDCACHE_ON
+ LOG("entry cache replace: cache index tables out of sync - found dn [%d] id [%d] uuid [%d]\n",
+ found_in_dn, found_in_id, found_in_uuid);
+#else
+ LOG("entry cache replace: cache index tables out of sync - found dn [%d] id [%d]\n",
+ found_in_dn, found_in_id, 0);
+#endif
PR_Unlock(cache->c_mutex);
return 1;
}
@@ -1472,7 +1495,9 @@ int cache_lock_entry(struct cache *cache, struct backentry *e)
void cache_unlock_entry(struct cache *cache, struct backentry *e)
{
LOG("=> cache_unlock_entry\n", 0, 0, 0);
- PR_ExitMonitor(e->ep_mutexp);
+ if (PR_ExitMonitor(e->ep_mutexp)) {
+ LOG("=> cache_unlock_entry - monitor was not entered!!!\n", 0, 0, 0);
+ }
}
/* DN cache */
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 132b2b901..09d10a0e9 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -214,6 +214,7 @@ static int dblayer_start_deadlock_thread(struct ldbminfo *li);
static int dblayer_start_checkpoint_thread(struct ldbminfo *li);
static int dblayer_start_trickle_thread(struct ldbminfo *li);
static int dblayer_start_perf_thread(struct ldbminfo *li);
+static int dblayer_start_txn_test_thread(struct ldbminfo *li);
static int trans_batch_count=1;
static int trans_batch_limit=0;
static PRBool log_flush_thread=PR_FALSE;
@@ -226,6 +227,14 @@ static void dblayer_pop_pvt_txn();
#define MEGABYTE (1024 * 1024)
#define GIGABYTE (1024 * MEGABYTE)
+/* env. vars. you can set to stress txn handling */
+#define TXN_TESTING "TXN_TESTING" /* enables the txn test thread */
+#define TXN_TEST_HOLD_MSEC "TXN_TEST_HOLD_MSEC" /* time to hold open the db cursors */
+#define TXN_TEST_LOOP_MSEC "TXN_TEST_LOOP_MSEC" /* time to wait before looping again */
+#define TXN_TEST_USE_TXN "TXN_TEST_USE_TXN" /* use transactions or not */
+#define TXN_TEST_USE_RMW "TXN_TEST_USE_RMW" /* use DB_RMW for c_get flags or not */
+#define TXN_TEST_INDEXES "TXN_TEST_INDEXES" /* list of indexes to use - comma delimited - id2entry,entryrdn,etc. */
+#define TXN_TEST_VERBOSE "TXN_TEST_VERBOSE" /* be wordy */
/* This function compares two index keys. It is assumed
that the values are already normalized, since they should have
@@ -1755,6 +1764,9 @@ dblayer_start(struct ldbminfo *li, int dbmode)
/* Now open the performance counters stuff */
perfctrs_init(li,&(priv->perf_private));
+ if (getenv(TXN_TESTING)) {
+ dblayer_start_txn_test_thread(li);
+ }
}
if (return_value != 0) {
if (return_value == ENOMEM) {
@@ -2597,7 +2609,10 @@ int dblayer_instance_close(backend *be)
if (NULL == inst)
return -1;
- if (getenv("USE_VALGRIND")) {
+ if (!inst->import_env) {
+ be->be_state = BE_STATE_STOPPING;
+ }
+ if (getenv("USE_VALGRIND") || slapi_is_loglevel_set(SLAPI_LOG_CACHE)) {
/*
* if any string is set to an environment variable USE_VALGRIND,
* when running a memory leak checking tool (e.g., valgrind),
@@ -3422,7 +3437,7 @@ int dblayer_txn_begin_ext(struct ldbminfo *li, back_txnid parent_txn, back_txn *
return_value = TXN_BEGIN(pEnv->dblayer_DB_ENV,
(DB_TXN*)parent_txn,
&new_txn.back_txn_txn,
- 0);
+ DB_TXN_NOWAIT);
if (0 != return_value)
{
if(use_lock) slapi_rwlock_unlock(priv->dblayer_env->dblayer_env_lock);
@@ -3725,6 +3740,407 @@ dblayer_start_deadlock_thread(struct ldbminfo *li)
return return_value;
}
+static const u_int32_t default_flags = DB_NEXT;
+
+/* this is the loop delay - how long after we release the db pages
+ until we acquire them again */
+#define TXN_TEST_LOOP_WAIT(msecs) do { \
+ if (msecs) { \
+ DS_Sleep(PR_MillisecondsToInterval(slapi_rand() % msecs)); \
+ } \
+} while (0)
+
+/* this is how long we hold the pages open until we close the cursors */
+#define TXN_TEST_PAGE_HOLD(msecs) do { \
+ if (msecs) { \
+ DS_Sleep(PR_MillisecondsToInterval(slapi_rand() % msecs)); \
+ } \
+} while (0)
+
+typedef struct txn_test_iter {
+ DB *db;
+ DBC *cur;
+ size_t cnt;
+ const char *attr;
+ u_int32_t flags;
+ backend *be;
+} txn_test_iter;
+
+typedef struct txn_test_cfg {
+ PRUint32 hold_msec;
+ PRUint32 loop_msec;
+ u_int32_t flags;
+ int use_txn;
+ char **indexes;
+ int verbose;
+} txn_test_cfg;
+
+static txn_test_iter *
+new_txn_test_iter(DB *db, const char *attr, backend *be, u_int32_t flags)
+{
+ txn_test_iter *tti = (txn_test_iter *)slapi_ch_malloc(sizeof(txn_test_iter));
+ tti->db = db;
+ tti->cur = NULL;
+ tti->cnt = 0;
+ tti->attr = attr;
+ tti->flags = default_flags|flags;
+ tti->be = be;
+ return tti;
+}
+
+static void
+init_txn_test_iter(txn_test_iter *tti)
+{
+ if (tti->cur) {
+ if (tti->cur->dbp && (tti->cur->dbp->open_flags == 0x58585858)) {
+ /* already closed? */
+ } else if (tti->be && (tti->be->be_state != BE_STATE_STARTED)) {
+ /* already closed? */
+ } else {
+ tti->cur->c_close(tti->cur);
+ }
+ tti->cur = NULL;
+ }
+ tti->cnt = 0;
+ tti->flags = default_flags;
+}
+
+static void
+free_txn_test_iter(txn_test_iter *tti)
+{
+ init_txn_test_iter(tti);
+ slapi_ch_free((void **)&tti);
+}
+
+static void
+free_ttilist(txn_test_iter ***ttilist, size_t *tticnt)
+{
+ if (!ttilist || !*ttilist || !**ttilist) {
+ return;
+ }
+ while (*tticnt > 0) {
+ (*tticnt)--;
+ free_txn_test_iter((*ttilist)[*tticnt]);
+ }
+ slapi_ch_free((void *)ttilist);
+}
+
+static void
+init_ttilist(txn_test_iter **ttilist, size_t tticnt)
+{
+ if (!ttilist || !*ttilist) {
+ return;
+ }
+ while (tticnt > 0) {
+ tticnt--;
+ init_txn_test_iter(ttilist[tticnt]);
+ }
+}
+
+static void
+print_ttilist(txn_test_iter **ttilist, size_t tticnt)
+{
+ while (tticnt > 0) {
+ tticnt--;
+ LDAPDebug2Args(LDAP_DEBUG_ANY,
+ "txn_test_threadmain: attr [%s] cnt [%lu]\n",
+ ttilist[tticnt]->attr, ttilist[tticnt]->cnt);
+ }
+}
+
+#define TXN_TEST_IDX_OK_IF_NULL "nscpEntryDN"
+
+static void
+txn_test_init_cfg(txn_test_cfg *cfg)
+{
+ static char *indexlist = "aci,entryrdn,numsubordinates,uid,ancestorid,objectclass,uniquemember,cn,parentid,nsuniqueid,sn,id2entry," TXN_TEST_IDX_OK_IF_NULL;
+ char *indexlist_copy = NULL;
+
+ cfg->hold_msec = getenv(TXN_TEST_HOLD_MSEC) ? atoi(getenv(TXN_TEST_HOLD_MSEC)) : 200;
+ cfg->loop_msec = getenv(TXN_TEST_LOOP_MSEC) ? atoi(getenv(TXN_TEST_LOOP_MSEC)) : 10;
+ cfg->flags = getenv(TXN_TEST_USE_RMW) ? DB_RMW : 0;
+ cfg->use_txn = getenv(TXN_TEST_USE_TXN) ? 1 : 0;
+ if (getenv(TXN_TEST_INDEXES)) {
+ indexlist_copy = slapi_ch_strdup(getenv(TXN_TEST_INDEXES));
+ } else {
+ indexlist_copy = slapi_ch_strdup(indexlist);
+ }
+ cfg->indexes = slapi_str2charray(indexlist_copy, ",");
+ slapi_ch_free_string(&indexlist_copy);
+ cfg->verbose = getenv(TXN_TEST_VERBOSE) ? 1 : 0;
+
+ slapi_log_error(SLAPI_LOG_FATAL, "txn_test_threadmain",
+ "Config hold_msec [%d] loop_msec [%d] rmw [%d] txn [%d] indexes [%s]\n",
+ cfg->hold_msec, cfg->loop_msec, cfg->flags, cfg->use_txn,
+ getenv(TXN_TEST_INDEXES) ? getenv(TXN_TEST_INDEXES) : indexlist);
+}
+
+static int txn_test_threadmain(void *param)
+{
+ dblayer_private *priv = NULL;
+ struct ldbminfo *li = NULL;
+ Object *inst_obj;
+ int rc = 0;
+ txn_test_iter **ttilist = NULL;
+ size_t tticnt = 0;
+ DB_TXN *txn = NULL;
+ txn_test_cfg cfg;
+ size_t counter = 0;
+ char keybuf[8192];
+ char databuf[8192];
+
+ PR_ASSERT(NULL != param);
+ li = (struct ldbminfo*)param;
+
+ priv = (dblayer_private*)li->li_dblayer_private;
+ PR_ASSERT(NULL != priv);
+
+ INCR_THREAD_COUNT(priv);
+
+ if (!priv->dblayer_enable_transactions) {
+ goto end;
+ }
+
+ txn_test_init_cfg(&cfg);
+
+wait_for_init:
+ free_ttilist(&ttilist, &tticnt);
+ DS_Sleep(PR_MillisecondsToInterval(1000));
+ if (priv->dblayer_stop_threads) {
+ goto end;
+ }
+
+ for (inst_obj = objset_first_obj(li->li_instance_set); inst_obj;
+ inst_obj = objset_next_obj(li->li_instance_set, inst_obj)) {
+ char **idx = NULL;
+ ldbm_instance *inst = (ldbm_instance *)object_get_data(inst_obj);
+ backend *be = inst->inst_be;
+
+ if (be->be_state != BE_STATE_STARTED) {
+ object_release(inst_obj);
+ goto wait_for_init;
+ }
+
+ for (idx = cfg.indexes; idx && *idx; ++idx) {
+ DB *db = NULL;
+ if (be->be_state != BE_STATE_STARTED) {
+ object_release(inst_obj);
+ goto wait_for_init;
+ }
+
+ if (!strcmp(*idx, "id2entry")) {
+ dblayer_get_id2entry(be, &db);
+ if (db == NULL) {
+ object_release(inst_obj);
+ goto wait_for_init;
+ }
+ } else {
+ struct attrinfo *ai = NULL;
+ ainfo_get(be, *idx, &ai);
+ if (NULL == ai) {
+ object_release(inst_obj);
+ goto wait_for_init;
+ }
+ dblayer_get_index_file(be, ai, &db, 0);
+ if (NULL == db) {
+ if (strcasecmp(*idx, TXN_TEST_IDX_OK_IF_NULL)) {
+ object_release(inst_obj);
+ goto wait_for_init;
+ }
+ }
+ }
+ if (db) {
+ ttilist = (txn_test_iter **)slapi_ch_realloc((char *)ttilist, sizeof(txn_test_iter *) * (tticnt + 1));
+ ttilist[tticnt++] = new_txn_test_iter(db, *idx, be, cfg.flags);
+ }
+ }
+ }
+
+ while (!priv->dblayer_stop_threads) {
+retry_txn:
+ init_ttilist(ttilist, tticnt);
+ if (txn) {
+ TXN_ABORT(txn);
+ txn = NULL;
+ }
+ if (cfg.use_txn) {
+ rc = TXN_BEGIN(priv->dblayer_env->dblayer_DB_ENV, NULL, &txn, 0);
+ if (rc || !txn) {
+ LDAPDebug2Args(LDAP_DEBUG_ANY,
+ "txn_test_threadmain failed to create a new transaction, err=%d (%s)\n",
+ rc, dblayer_strerror(rc));
+ }
+ } else {
+ rc = 0;
+ }
+ if (!rc) {
+ DBT key;
+ DBT data;
+ size_t ii;
+ size_t donecnt = 0;
+ size_t cnt = 0;
+
+ /* phase 1 - open a cursor to each db */
+ if (cfg.verbose) {
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,
+ "txn_test_threadmain: starting [%lu] indexes\n", tticnt);
+ }
+ for (ii = 0; ii < tticnt; ++ii) {
+ txn_test_iter *tti = ttilist[ii];
+
+retry_cursor:
+ if (priv->dblayer_stop_threads) {
+ goto end;
+ }
+ if (tti->be->be_state != BE_STATE_STARTED) {
+ if (txn) {
+ TXN_ABORT(txn);
+ txn = NULL;
+ }
+ goto wait_for_init;
+ }
+ if (tti->db->open_flags == 0xdbdbdbdb) {
+ if (txn) {
+ TXN_ABORT(txn);
+ txn = NULL;
+ }
+ goto wait_for_init;
+ }
+ rc = tti->db->cursor(tti->db, txn, &tti->cur, 0);
+ if (DB_LOCK_DEADLOCK == rc) {
+ if (cfg.verbose) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY,
+ "txn_test_threadmain cursor create deadlock - retry\n");
+ }
+ if (cfg.use_txn) {
+ goto retry_txn;
+ } else {
+ goto retry_cursor;
+ }
+ } else if (rc) {
+ LDAPDebug2Args(LDAP_DEBUG_ANY,
+ "txn_test_threadmain failed to create a new cursor, err=%d (%s)\n",
+ rc, dblayer_strerror(rc));
+ }
+ }
+
+ memset(&key, 0, sizeof(key));
+ key.flags = DB_DBT_USERMEM;
+ key.data = keybuf;
+ key.ulen = sizeof(keybuf);
+ memset(&data, 0, sizeof(data));
+ data.flags = DB_DBT_USERMEM;
+ data.data = databuf;
+ data.ulen = sizeof(databuf);
+ /* phase 2 - iterate over each cursor at the same time until
+ 1) get error
+ 2) get deadlock
+ 3) all cursors are exhausted
+ */
+ while (donecnt < tticnt) {
+ for (ii = 0; ii < tticnt; ++ii) {
+ txn_test_iter *tti = ttilist[ii];
+ if (tti->cur) {
+retry_get:
+ if (priv->dblayer_stop_threads) {
+ goto end;
+ }
+ if (tti->be->be_state != BE_STATE_STARTED) {
+ if (txn) {
+ TXN_ABORT(txn);
+ txn = NULL;
+ }
+ goto wait_for_init;
+ }
+ if (tti->db->open_flags == 0xdbdbdbdb) {
+ if (txn) {
+ TXN_ABORT(txn);
+ txn = NULL;
+ }
+ goto wait_for_init;
+ }
+ rc = tti->cur->c_get(tti->cur, &key, &data, tti->flags);
+ if (DB_LOCK_DEADLOCK == rc) {
+ if (cfg.verbose) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY,
+ "txn_test_threadmain cursor get deadlock - retry\n");
+ }
+ if (cfg.use_txn) {
+ goto retry_txn;
+ } else {
+ goto retry_get;
+ }
+ } else if (DB_NOTFOUND == rc) {
+ donecnt++; /* ran out of this one */
+ tti->flags = DB_FIRST|cfg.flags; /* start over until all indexes are done */
+ } else if (rc) {
+ if ((DB_BUFFER_SMALL != rc) || cfg.verbose) {
+ LDAPDebug2Args(LDAP_DEBUG_ANY,
+ "txn_test_threadmain failed to read a cursor, err=%d (%s)\n",
+ rc, dblayer_strerror(rc));
+ }
+ tti->cur->c_close(tti->cur);
+ tti->cur = NULL;
+ donecnt++;
+ } else {
+ tti->cnt++;
+ tti->flags = default_flags|cfg.flags;
+ cnt++;
+ }
+ }
+ }
+ }
+ TXN_TEST_PAGE_HOLD(cfg.hold_msec);
+ /*print_ttilist(ttilist, tticnt);*/
+ init_ttilist(ttilist, tticnt);
+ if (cfg.verbose) {
+ LDAPDebug2Args(LDAP_DEBUG_ANY,
+ "txn_test_threadmain: finished [%lu] indexes [%lu] records\n", tticnt, cnt);
+ }
+ TXN_TEST_LOOP_WAIT(cfg.loop_msec);
+ } else {
+ TXN_TEST_LOOP_WAIT(cfg.loop_msec);
+ }
+ counter++;
+ if (!(counter % 40)) {
+ /* some operations get completely stuck - so every once in a while,
+ pause to allow those ops to go through */
+ DS_Sleep(PR_SecondsToInterval(1));
+ }
+ }
+
+end:
+ slapi_ch_array_free(cfg.indexes);
+ free_ttilist(&ttilist, &tticnt);
+ if (txn) {
+ TXN_ABORT(txn);
+ }
+ DECR_THREAD_COUNT(priv);
+ return 0;
+}
+
+/*
+ * create a thread for transaction deadlock testing
+ */
+static int
+dblayer_start_txn_test_thread(struct ldbminfo *li)
+{
+ int return_value = 0;
+ if (NULL == PR_CreateThread (PR_USER_THREAD,
+ (VFP) (void *) txn_test_threadmain, li,
+ PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
+ PR_UNJOINABLE_THREAD,
+ SLAPD_DEFAULT_THREAD_STACKSIZE) )
+ {
+ PRErrorCode prerr = PR_GetError();
+ LDAPDebug(LDAP_DEBUG_ANY, "failed to create txn test thread, "
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
+ prerr, slapd_pr_strerror(prerr), 0);
+ return_value = -1;
+ }
+ return return_value;
+}
+
/* deadlock thread main function */
static int deadlock_threadmain(void *param)
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 7e8aa1239..cfcd51f59 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -412,7 +412,7 @@ index_addordel_entry(
}
result = index_addordel_string(be, SLAPI_ATTR_NSCP_ENTRYDN, slapi_sdn_get_ndn(&parent), e->ep_id, flags, txn);
if ( result != 0 ) {
- ldbm_nasty(errmsg, 1020, result);
+ ldbm_nasty(errmsg, 1021, result);
return( result );
}
slapi_sdn_done(&parent);
@@ -423,6 +423,7 @@ index_addordel_entry(
*/
result = entryrdn_index_entry(be, e, flags, txn);
if ( result != 0 ) {
+ ldbm_nasty(errmsg, 1023, result);
return( result );
}
/* To maintain tombstonenumsubordinates,
@@ -433,7 +434,7 @@ index_addordel_entry(
result = index_addordel_values_sv(be, LDBM_PARENTID_STR, svals, NULL,
e->ep_id, flags, txn);
if ( result != 0 ) {
- ldbm_nasty(errmsg, 1020, result);
+ ldbm_nasty(errmsg, 1022, result);
return( result );
}
}
@@ -481,6 +482,7 @@ index_addordel_entry(
if (entryrdn_get_switch()) { /* subtree-rename: on */
result = entryrdn_index_entry(be, e, flags, txn);
if ( result != 0 ) {
+ ldbm_nasty(errmsg, 1031, result);
return( result );
}
}
@@ -608,13 +610,18 @@ index_add_mods(
/* We need to first remove the old values from the
* index, if any. */
if (deleted_valueArray) {
- index_addordel_values_sv( be, mods[i]->mod_type,
- deleted_valueArray, evals, id,
- flags, txn );
+ rc = index_addordel_values_sv( be, mods[i]->mod_type,
+ deleted_valueArray, evals, id,
+ flags, txn );
+ if (rc) {
+ ldbm_nasty(errmsg, 1041, rc);
+ goto error;
+ }
}
/* Free valuearray */
slapi_valueset_free(mod_vals);
+ mod_vals = NULL;
case LDAP_MOD_ADD:
if ( mods_valueArray == NULL ) {
rc = 0;
@@ -643,9 +650,13 @@ index_add_mods(
}
if (mods_valueArray) {
rc = index_addordel_values_sv( be,
- mods[i]->mod_type,
- mods_valueArray, NULL,
- id, BE_INDEX_ADD, txn );
+ mods[i]->mod_type,
+ mods_valueArray, NULL,
+ id, BE_INDEX_ADD, txn );
+ if (rc) {
+ ldbm_nasty(errmsg, 1042, rc);
+ goto error;
+ }
} else {
rc = 0;
}
@@ -702,12 +713,17 @@ index_add_mods(
/* Update the index, if necessary */
if (deleted_valueArray) {
- index_addordel_values_sv( be, mods[i]->mod_type,
- deleted_valueArray, evals, id,
- flags, txn );
+ rc = index_addordel_values_sv( be, mods[i]->mod_type,
+ deleted_valueArray, evals, id,
+ flags, txn );
+ if (rc) {
+ ldbm_nasty(errmsg, 1043, rc);
+ goto error;
+ }
}
slapi_valueset_free(mod_vals);
+ mod_vals = NULL;
} else {
/* determine if the presence key should be
@@ -753,15 +769,25 @@ index_add_mods(
rc = index_addordel_values_sv( be, basetype,
mods_valueArray,
evals, id, flags, txn );
+ if (rc) {
+ ldbm_nasty(errmsg, 1044, rc);
+ goto error;
+ }
}
rc = 0;
break;
} /* switch ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ) */
+error:
/* free memory */
slapi_ch_free((void **)&tmp);
+ tmp = NULL;
valuearray_free(&mods_valueArray);
+ mods_valueArray = NULL;
slapi_valueset_free(all_vals);
+ all_vals = NULL;
+ slapi_valueset_free(mod_vals);
+ mod_vals = NULL;
if ( rc != 0 ) {
ldbm_nasty(errmsg, 1040, rc);
@@ -996,6 +1022,9 @@ index_read_ext_allids(
idl = idl_fetch_ext( be, db, &key, db_txn, ai, err, allidslimit );
if(*err == DB_LOCK_DEADLOCK) {
ldbm_nasty("index read retrying transaction", 1045, *err);
+#ifdef FIX_TXN_DEADLOCKS
+#error can only retry here if txn == NULL - otherwise, have to abort and retry txn
+#endif
continue;
} else {
break;
@@ -1124,6 +1153,9 @@ retry:
cursor->c_close(cursor);
cursor = NULL;
key->data = saved_key;
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to abort and retry the transaction, not just the cursor
+#endif
goto retry;
} else
{
@@ -1146,6 +1178,9 @@ retry:
cursor->c_close(cursor);
cursor = NULL;
key->data = saved_key;
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to abort and retry the transaction, not just the cursor
+#endif
goto retry;
}
error:
@@ -1493,6 +1528,9 @@ index_range_read_ext(
tmp = idl_fetch_ext( be, db, &cur_key, NULL, ai, err, allidslimit );
if(*err == DB_LOCK_DEADLOCK) {
ldbm_nasty("index_range_read retrying transaction", 1090, *err);
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to abort and retry the transaction, not just the fetch
+#endif
continue;
} else {
break;
@@ -1641,7 +1679,7 @@ addordel_values(
if ( rc != 0)
{
- ldbm_nasty(errmsg, 1090, rc);
+ ldbm_nasty(errmsg, 1096, rc);
}
index_free_prefix (prefix);
if (NULL != key.dptr && prefix != key.dptr)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 1539c7c3d..18390c246 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -934,7 +934,7 @@ ldbm_back_add( Slapi_PBlock *pb )
if (retry_count == RETRY_TIMES) {
/* Failed */
LDAPDebug( LDAP_DEBUG_ANY, "Retry count exceeded in add\n", 0, 0, 0 );
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_BUSY;
goto error_return;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index 57a460517..237085c9f 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -60,7 +60,8 @@ ldbm_back_delete( Slapi_PBlock *pb )
struct ldbminfo *li = NULL;
struct backentry *e = NULL;
struct backentry *tombstone = NULL;
- struct backentry *original_entry = NULL;
+ Slapi_Entry *original_entry = NULL;
+ struct backentry *original_tombstone = NULL;
char *dn = NULL;
back_txn txn;
back_txnid parent_txn;
@@ -90,7 +91,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
int delete_tombstone_entry = 0; /* We must remove the given tombstone entry from the DB */
int create_tombstone_entry = 0; /* We perform a "regular" LDAP delete but since we use */
/* replication, we must create a new tombstone entry */
- int e_in_cache = 0;
int tombstone_in_cache = 0;
entry_address *addr;
int addordel_flags = 0; /* passed to index_addordel */
@@ -98,6 +98,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
Slapi_Entry *orig_entry = NULL;
Slapi_DN parentsdn;
int opreturn = 0;
+ int free_delete_existing_entry = 0;
slapi_pblock_get( pb, SLAPI_BACKEND, &be);
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
@@ -186,7 +187,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
/* retval is -1 */
goto error_return; /* error result sent by find_entry2modify() */
}
- e_in_cache = 1;
if ( slapi_entry_has_children( e->ep_entry ) )
{
@@ -206,6 +206,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
*/
ldap_result_code= get_copy_of_entry(pb, addr, &txn,
SLAPI_DELETE_EXISTING_ENTRY, !is_replicated_operation);
+ free_delete_existing_entry = 1;
if(ldap_result_code==LDAP_OPERATIONS_ERROR ||
ldap_result_code==LDAP_INVALID_DN_SYNTAX)
{
@@ -428,6 +429,11 @@ ldbm_back_delete( Slapi_PBlock *pb )
slapi_value_free(&tomb_value);
/* XXXggood above used to be: slapi_entry_add_string(tombstone->ep_entry, SLAPI_ATTR_OBJECTCLASS, SLAPI_ATTR_VALUE_TOMBSTONE); */
/* JCMREPL - Add a description of what's going on? */
+
+ if ( (original_tombstone = backentry_dup( tombstone )) == NULL ) {
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
+ goto error_return;
+ }
}
if (!is_ruv && !is_fixup_operation && !delete_tombstone_entry) {
@@ -443,7 +449,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
}
}
- if ( (original_entry = backentry_dup( e )) == NULL ) {
+ if ( (original_entry = slapi_entry_dup( e->ep_entry )) == NULL ) {
ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
@@ -456,26 +462,45 @@ ldbm_back_delete( Slapi_PBlock *pb )
txn.back_txn_txn = NULL; /* ready to create the child transaction */
for (retry_count = 0; retry_count < RETRY_TIMES; retry_count++) {
if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
+ Slapi_Entry *ent = NULL;
+
dblayer_txn_abort(li,&txn);
slapi_pblock_set(pb, SLAPI_TXN, parent_txn);
- if (e_in_cache) {
- /* entry 'e' is in the entry cache. Since we reset 'e' to
- * the original_entry, remove it from the cache. */
- CACHE_REMOVE(&inst->inst_cache, e);
- cache_unlock_entry(&inst->inst_cache, e);
- CACHE_RETURN(&inst->inst_cache, &e);
- /* As we are about to delete it,
- * we don't put the entry back to cache */
- e_in_cache = 0;
- } else {
- backentry_free(&e);
+
+ /* reset original entry */
+ slapi_pblock_get( pb, SLAPI_DELETE_EXISTING_ENTRY, &ent );
+ if (ent && (ent != original_entry) && free_delete_existing_entry) {
+ slapi_entry_free(ent);
+ slapi_pblock_set( pb, SLAPI_DELETE_EXISTING_ENTRY, NULL );
}
- slapi_pblock_set( pb, SLAPI_DELETE_EXISTING_ENTRY, original_entry->ep_entry );
- e = original_entry;
- if ( (original_entry = backentry_dup( e )) == NULL ) {
+ slapi_entry_free(e->ep_entry);
+ e->ep_entry = original_entry;
+ if ( (original_entry = slapi_entry_dup( e->ep_entry )) == NULL ) {
ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
+ slapi_pblock_set( pb, SLAPI_DELETE_EXISTING_ENTRY, original_entry );
+ free_delete_existing_entry = 0; /* owned by original_entry now */
+ if (nscpEntrySDN) {
+ nscpEntrySDN = slapi_entry_get_sdn(original_entry);
+ }
+
+ /* reset tombstone entry */
+ if (original_tombstone) {
+ if (tombstone_in_cache) {
+ CACHE_REMOVE(&inst->inst_cache, tombstone);
+ CACHE_RETURN(&inst->inst_cache, &tombstone);
+ tombstone_in_cache = 0;
+ } else {
+ backentry_free(&tombstone);
+ }
+ tombstone = original_tombstone;
+ if ( (original_tombstone = backentry_dup( tombstone )) == NULL ) {
+ ldap_result_code= LDAP_OPERATIONS_ERROR;
+ goto error_return;
+ }
+ }
+
/* We're re-trying */
LDAPDebug0Args(LDAP_DEBUG_BACKLDBM,
"Delete Retrying Transaction\n");
@@ -562,6 +587,14 @@ ldbm_back_delete( Slapi_PBlock *pb )
* tentatively for now, then cache_add again when the original
* entry is removed from the cache.
*/
+ if (cache_add_tentative( &inst->inst_cache, tombstone, NULL) == 0) {
+ tombstone_in_cache = 1;
+ } else if (!(tombstone->ep_state & ENTRY_STATE_NOTINCACHE)) {
+ LDAPDebug1Arg(LDAP_DEBUG_CACHE,
+ "id2entry_add tombstone (%s) is in cache\n",
+ slapi_entry_get_dn(tombstone->ep_entry));
+ tombstone_in_cache = 1;
+ }
retval = id2entry_add( be, tombstone, &txn );
if (DB_LOCK_DEADLOCK == retval) {
LDAPDebug( LDAP_DEBUG_ARGS, "delete 1 DB_LOCK_DEADLOCK\n", 0, 0, 0 );
@@ -576,14 +609,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
LDAP_OPERATIONS_ERROR, retry_count);
goto error_return;
}
- if (cache_add_tentative( &inst->inst_cache, tombstone, NULL) == 0) {
- tombstone_in_cache = 1;
- } else if (!(tombstone->ep_state & ENTRY_STATE_NOTINCACHE)) {
- LDAPDebug1Arg(LDAP_DEBUG_CACHE,
- "id2entry_add tombstone (%s) is in cache\n",
- slapi_entry_get_dn(tombstone->ep_entry));
- tombstone_in_cache = 1;
- }
}
else
{
@@ -966,7 +991,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
if (retry_count == RETRY_TIMES) {
/* Failed */
LDAPDebug( LDAP_DEBUG_ANY, "Retry count exceeded in delete\n", 0, 0, 0 );
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_BUSY;
retval = -1;
goto error_return;
}
@@ -1007,18 +1032,13 @@ ldbm_back_delete( Slapi_PBlock *pb )
}
/* delete from cache and clean up */
- if (e_in_cache) {
+ if (e) {
CACHE_REMOVE(&inst->inst_cache, e);
cache_unlock_entry(&inst->inst_cache, e);
CACHE_RETURN(&inst->inst_cache, &e);
+ e = NULL;
}
- if (tombstone_in_cache) {
- if (CACHE_ADD( &inst->inst_cache, tombstone, NULL ) == 0) {
- tombstone_in_cache = 1;
- } else {
- tombstone_in_cache = 0;
- }
- }
+
if (parent_found)
{
/* Replace the old parent entry with the newly modified one */
@@ -1042,6 +1062,9 @@ error_return:
if (tombstone_in_cache)
{
CACHE_REMOVE( &inst->inst_cache, tombstone );
+ CACHE_RETURN( &inst->inst_cache, &tombstone );
+ tombstone = NULL;
+ tombstone_in_cache = 0;
}
else
{
@@ -1108,6 +1131,8 @@ common_return:
if (tombstone_in_cache)
{
CACHE_RETURN( &inst->inst_cache, &tombstone );
+ tombstone = NULL;
+ tombstone_in_cache = 0;
}
else
{
@@ -1126,7 +1151,7 @@ common_return:
/* Need to return to cache after post op plugins are called */
if (retval) { /* error case */
- if (e && e_in_cache) {
+ if (e) {
cache_unlock_entry( &inst->inst_cache, e );
CACHE_RETURN( &inst->inst_cache, &e );
}
@@ -1156,8 +1181,13 @@ diskfull_return:
*/
slapi_pblock_set(pb, SLAPI_URP_NAMING_COLLISION_DN, slapi_ch_strdup (dn));
}
- done_with_pblock_entry(pb, SLAPI_DELETE_EXISTING_ENTRY);
- backentry_free(&original_entry);
+ if (free_delete_existing_entry) {
+ done_with_pblock_entry(pb, SLAPI_DELETE_EXISTING_ENTRY);
+ } else { /* owned by original_entry */
+ slapi_pblock_set(pb, SLAPI_DELETE_EXISTING_ENTRY, NULL);
+ }
+ slapi_entry_free(original_entry);
+ backentry_free(&original_tombstone);
slapi_ch_free((void**)&errbuf);
slapi_sdn_done(&sdn);
slapi_ch_free_string(&e_uniqueid);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index b548b29b0..449e02a82 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -115,8 +115,8 @@ static char *_entryrdn_decrypt_key(backend *be, const char *key, struct attrinfo
#endif
static int _entryrdn_get_elem(DBC *cursor, DBT *key, DBT *data, const char *comp_key, rdn_elem **elem);
static int _entryrdn_get_tombstone_elem(DBC *cursor, Slapi_RDN *srdn, DBT *key, const char *comp_key, rdn_elem **elem);
-static int _entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type);
-static int _entryrdn_del_data(DBC *cursor, DBT *key, DBT *data);
+static int _entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type, DB_TXN *db_txn);
+static int _entryrdn_del_data(DBC *cursor, DBT *key, DBT *data, DB_TXN *db_txn);
static int _entryrdn_insert_key(backend *be, DBC *cursor, Slapi_RDN *srdn, ID id, DB_TXN *db_txn);
static int _entryrdn_insert_key_elems(backend *be, DBC *cursor, Slapi_RDN *srdn, DBT *key, rdn_elem *elem, rdn_elem *childelem, size_t childelemlen, DB_TXN *db_txn);
static int _entryrdn_delete_key(backend *be, DBC *cursor, Slapi_RDN *srdn, ID id, DB_TXN *db_txn);
@@ -274,7 +274,7 @@ entryrdn_index_entry(backend *be,
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"entryrdn_index_entry: Failed to make a cursor: %s(%d)\n",
dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -284,6 +284,12 @@ entryrdn_index_entry(backend *be,
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "entryrdn_index_entry: cursor open failed after [%d] retries\n", db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
if (flags & BE_INDEX_ADD) {
rc = _entryrdn_insert_key(be, cursor, srdn, e->ep_id, db_txn);
@@ -303,7 +309,7 @@ bail:
slapi_log_error(ENTRYRDN_LOGLEVEL(myrc), ENTRYRDN_TAG,
"entryrdn_index_entry: Failed to close cursor: %s(%d)\n",
dblayer_strerror(myrc), myrc);
- if (DB_LOCK_DEADLOCK == myrc) {
+ if ((DB_LOCK_DEADLOCK == myrc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -317,6 +323,11 @@ bail:
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "entryrdn_index_entry: cursor close failed after [%d] retries\n", db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ }
}
if (db) {
dblayer_release_index_file(be, ai, db);
@@ -407,7 +418,7 @@ entryrdn_index_read_ext(backend *be,
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"entryrdn_index_read: Failed to make a cursor: %s(%d)\n",
dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -417,6 +428,13 @@ entryrdn_index_read_ext(backend *be,
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "entryrdn_index_read: Failed to make a cursor after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
rc = _entryrdn_index_read(be, cursor, &srdn, &elem, NULL, NULL,
flags, db_txn);
@@ -434,7 +452,7 @@ bail:
slapi_log_error(ENTRYRDN_LOGLEVEL(myrc), ENTRYRDN_TAG,
"entryrdn_index_read: Failed to close cursor: %s(%d)\n",
dblayer_strerror(myrc), myrc);
- if (DB_LOCK_DEADLOCK == myrc) {
+ if ((DB_LOCK_DEADLOCK == myrc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -448,6 +466,12 @@ bail:
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "entryrdn_index_read: Failed to close cursor after [%d] retries\n",
+ db_retry);
+ rc = rc ? rc : DB_LOCK_DEADLOCK;
+ }
}
if (db) {
dblayer_release_index_file(be, ai, db);
@@ -594,7 +618,7 @@ entryrdn_rename_subtree(backend *be,
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"entryrdn_rename_subtree: Failed to make a cursor: %s(%d)\n",
dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -604,6 +628,13 @@ entryrdn_rename_subtree(backend *be,
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "entryrdn_rename_subtree: create cursor failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
/* prepare the element for the newly renamed rdn, if any. */
if (mynewsrdn) {
@@ -680,7 +711,7 @@ entryrdn_rename_subtree(backend *be,
renamedata.ulen = renamedata.size = targetelemlen;
renamedata.data = (void *)targetelem;
renamedata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_del_data(cursor, &key, &renamedata);
+ rc = _entryrdn_del_data(cursor, &key, &renamedata, db_txn);
if (rc) {
goto bail;
}
@@ -697,7 +728,7 @@ entryrdn_rename_subtree(backend *be,
_entryrdn_rdn_elem_size(*cep);
renamedata.data = (void *)(*cep);
renamedata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_del_data(cursor, &key, &renamedata);
+ rc = _entryrdn_del_data(cursor, &key, &renamedata, db_txn);
if (rc) {
goto bail;
}
@@ -715,7 +746,7 @@ entryrdn_rename_subtree(backend *be,
renamedata.ulen = renamedata.size = newelemlen;
renamedata.data = (void *)newelem;
renamedata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_SELF);
+ rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_SELF, db_txn);
if (rc) {
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"entryrdn_rename_subtree: Adding %s failed; "
@@ -736,7 +767,7 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)(*cep);
renamedata.flags = DB_DBT_USERMEM;
rc = _entryrdn_put_data(cursor, &key,
- &renamedata, RDN_INDEX_CHILD);
+ &renamedata, RDN_INDEX_CHILD, db_txn);
if (rc) {
goto bail;
}
@@ -755,7 +786,7 @@ entryrdn_rename_subtree(backend *be,
renamedata.ulen = renamedata.size = oldsupelemlen;
renamedata.data = (void *)oldsupelem;
renamedata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_del_data(cursor, &key, &renamedata);
+ rc = _entryrdn_del_data(cursor, &key, &renamedata, db_txn);
if (rc) {
goto bail;
}
@@ -787,7 +818,7 @@ entryrdn_rename_subtree(backend *be,
goto bail;
}
}
- rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_PARENT);
+ rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_PARENT, db_txn);
if (rc) {
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"entryrdn_rename_subtree: Adding "
@@ -812,7 +843,7 @@ entryrdn_rename_subtree(backend *be,
renamedata.ulen = renamedata.size = targetelemlen;
renamedata.data = (void *)targetelem;
renamedata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_del_data(cursor, &key, &renamedata);
+ rc = _entryrdn_del_data(cursor, &key, &renamedata, db_txn);
if (rc) {
goto bail;
}
@@ -822,7 +853,7 @@ entryrdn_rename_subtree(backend *be,
renamedata.ulen = renamedata.size = newelemlen;
renamedata.data = (void *)newelem;
renamedata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_SELF);
+ rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_SELF, db_txn);
if (rc) {
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"entryrdn_rename_subtree: Adding %s failed; "
@@ -846,7 +877,7 @@ entryrdn_rename_subtree(backend *be,
renamedata.ulen = renamedata.size = targetelemlen;
renamedata.data = (void *)targetelem;
renamedata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_del_data(cursor, &key, &renamedata);
+ rc = _entryrdn_del_data(cursor, &key, &renamedata, db_txn);
if (rc) {
goto bail;
}
@@ -881,7 +912,7 @@ entryrdn_rename_subtree(backend *be,
goto bail;
}
}
- rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_CHILD);
+ rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_CHILD, db_txn);
if (rc) {
goto bail;
}
@@ -911,7 +942,7 @@ bail:
slapi_log_error(ENTRYRDN_LOGLEVEL(myrc), ENTRYRDN_TAG,
"entryrdn_rename_subtree: Failed to close cursor: %s(%d)\n",
dblayer_strerror(myrc), myrc);
- if (DB_LOCK_DEADLOCK == myrc) {
+ if ((DB_LOCK_DEADLOCK == myrc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -925,6 +956,12 @@ bail:
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "entryrdn_rename_subtree: Failed to close cursor after [%d] retries.\n",
+ db_retry);
+ rc = rc ? rc : DB_LOCK_DEADLOCK;
+ }
}
if (db) {
dblayer_release_index_file(be, ai, db);
@@ -1017,7 +1054,7 @@ entryrdn_get_subordinates(backend *be,
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"entryrdn_get_subordinates: Failed to make a cursor: %s(%d)\n",
dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -1027,6 +1064,13 @@ entryrdn_get_subordinates(backend *be,
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "entryrdn_get_subordinates: Failed to make a cursor after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
rc = _entryrdn_index_read(be, cursor, &srdn, &elem,
NULL, &childelems, 0/*flags*/, db_txn);
@@ -1076,7 +1120,7 @@ bail:
slapi_log_error(ENTRYRDN_LOGLEVEL(myrc), ENTRYRDN_TAG,
"entryrdn_get_subordinates: Failed to close cursor: %s(%d)\n",
dblayer_strerror(myrc), myrc);
- if (DB_LOCK_DEADLOCK == myrc) {
+ if ((DB_LOCK_DEADLOCK == myrc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -1090,6 +1134,14 @@ bail:
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "entryrdn_get_subordinates: Failed to close cursor after [%d] retries\n",
+ db_retry);
+ rc = rc ? rc : DB_LOCK_DEADLOCK;
+ goto bail;
+ }
+
}
if (db) {
dblayer_release_index_file(be, ai, db);
@@ -1159,6 +1211,9 @@ entryrdn_lookup_dn(backend *be,
"entryrdn_lookup_dn: Failed to make a cursor: %s(%d)\n",
dblayer_strerror(rc), rc);
if (DB_LOCK_DEADLOCK == rc) {
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
ENTRYRDN_DELAY;
continue;
}
@@ -1199,6 +1254,11 @@ retry_get0:
if (rc) {
if (DB_LOCK_DEADLOCK == rc) {
/* try again */
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "entryrdn_get_parent: cursor get deadlock\n");
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
goto retry_get0;
} else if (DB_NOTFOUND == rc) { /* could be a suffix or
note: no parent for suffix */
@@ -1212,6 +1272,11 @@ retry_get1:
if (rc) {
if (DB_LOCK_DEADLOCK == rc) {
/* try again */
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "entryrdn_get_parent: retry cursor get deadlock\n");
goto retry_get1;
} else if (DB_NOTFOUND != rc) {
_entryrdn_cursor_print_error("entryrdn_lookup_dn",
@@ -1264,6 +1329,9 @@ bail:
"entryrdn_lookup_dn: Failed to close cursor: %s(%d)\n",
dblayer_strerror(myrc), myrc);
if (DB_LOCK_DEADLOCK == myrc) {
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
ENTRYRDN_DELAY;
continue;
}
@@ -1352,6 +1420,9 @@ entryrdn_get_parent(backend *be,
"entryrdn_get_parent: Failed to make a cursor: %s(%d)\n",
dblayer_strerror(rc), rc);
if (DB_LOCK_DEADLOCK == rc) {
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
ENTRYRDN_DELAY;
continue;
}
@@ -1388,6 +1459,11 @@ retry_get0:
rc = cursor->c_get(cursor, &key, &data, DB_SET);
if (rc) {
if (DB_LOCK_DEADLOCK == rc) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "entryrdn_get_parent: cursor get deadlock\n");
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
/* try again */
goto retry_get0;
} else if (DB_NOTFOUND == rc) { /* could be a suffix
@@ -1402,6 +1478,11 @@ retry_get1:
if (rc) {
if (DB_LOCK_DEADLOCK == rc) {
/* try again */
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "entryrdn_get_parent: retry cursor get deadlock\n");
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
goto retry_get1;
} else if (DB_NOTFOUND != rc) {
_entryrdn_cursor_print_error("entryrdn_get_parent",
@@ -1434,6 +1515,9 @@ bail:
"entryrdn_get_parent: Failed to close cursor: %s(%d)\n",
dblayer_strerror(myrc), myrc);
if (DB_LOCK_DEADLOCK == myrc) {
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
ENTRYRDN_DELAY;
continue;
}
@@ -1705,7 +1789,12 @@ retry_get:
*elem = (rdn_elem *)data->data;
if (rc) {
if (DB_LOCK_DEADLOCK == rc) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_get_elem: cursor get deadlock\n");
/* try again */
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
goto retry_get;
} else if (DB_BUFFER_SMALL == rc) {
/* try again */
@@ -1774,6 +1863,11 @@ retry_get0:
rc = cursor->c_get(cursor, key, &data, DB_SET|DB_MULTIPLE);
if (DB_LOCK_DEADLOCK == rc) {
/* try again */
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_get_tombstone_elem: cursor get deadlock\n");
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
goto retry_get0;
} else if (DB_NOTFOUND == rc) {
rc = 0; /* Child not found is ok */
@@ -1824,6 +1918,11 @@ retry_get1:
rc = cursor->c_get(cursor, key, &data, DB_NEXT_DUP|DB_MULTIPLE);
if (DB_LOCK_DEADLOCK == rc) {
/* try again */
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_get_tombstone_elem: retry cursor get deadlock\n");
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
goto retry_get1;
} else if (DB_NOTFOUND == rc) {
rc = 0;
@@ -1842,7 +1941,7 @@ bail:
}
static int
-_entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type)
+_entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type, DB_TXN *db_txn)
{
int rc = -1;
int db_retry = 0;
@@ -1866,6 +1965,8 @@ _entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type)
"_entryrdn_put_data: The same key (%s) and the "
"data exists in index\n",
(char *)key->data);
+ rc = 0;
+ break;
} else {
char *keyword = NULL;
if (type == RDN_INDEX_CHILD) {
@@ -1879,7 +1980,7 @@ _entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type)
"_entryrdn_put_data: Adding the %s link (%s) "
"failed: %s (%d)\n", keyword, (char *)key->data,
dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -1889,13 +1990,19 @@ _entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type)
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_put_data: cursor put operation failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ }
bail:
slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG, "<-- _entryrdn_put_data\n");
return rc;
}
static int
-_entryrdn_del_data(DBC *cursor, DBT *key, DBT *data)
+_entryrdn_del_data(DBC *cursor, DBT *key, DBT *data, DB_TXN *db_txn)
{
int rc = -1;
int db_retry = 0;
@@ -1909,37 +2016,57 @@ _entryrdn_del_data(DBC *cursor, DBT *key, DBT *data)
NULL==data?"data":"unknown");
goto bail;
}
-retry_get:
- rc = cursor->c_get(cursor, key, data, DB_GET_BOTH);
- if (rc) {
- if (DB_LOCK_DEADLOCK == rc) {
- /* try again */
- goto retry_get;
- } else if (DB_NOTFOUND == rc) {
- rc = 0; /* not found is ok */
- } else {
- _entryrdn_cursor_print_error("_entryrdn_del_data",
- key->data, data->size, data->ulen, rc);
- }
- } else {
- /* We found it, so delete it */
- for (db_retry = 0; db_retry < RETRY_TIMES; db_retry++) {
- rc = cursor->c_del(cursor, 0);
- if (rc) {
+
+ for (db_retry = 0; db_retry < RETRY_TIMES; db_retry++) {
+ rc = cursor->c_get(cursor, key, data, DB_GET_BOTH);
+ if (rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
- "_entryrdn_del_data: Deleting %s failed; "
- "%s(%d)\n", (char *)key->data,
- dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
- ENTRYRDN_DELAY;
- continue;
- }
+ "_entryrdn_del_data: cursor get deadlock\n");
+ /* try again */
+ } else if (DB_NOTFOUND == rc) {
+ rc = 0; /* not found is ok */
goto bail;
} else {
- break; /* success */
+ _entryrdn_cursor_print_error("_entryrdn_del_data",
+ key->data, data->size, data->ulen, rc);
+ goto bail;
+ }
+ } else {
+ break; /* found it */
+ }
+ }
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_del_data: cursor get failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
+
+ /* We found it, so delete it */
+ for (db_retry = 0; db_retry < RETRY_TIMES; db_retry++) {
+ rc = cursor->c_del(cursor, 0);
+ if (rc) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_del_data: Deleting %s failed; "
+ "%s(%d)\n", (char *)key->data,
+ dblayer_strerror(rc), rc);
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
+ ENTRYRDN_DELAY;
+ continue;
}
+ goto bail;
+ } else {
+ break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_del_data: cursor del failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ }
bail:
slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
"<-- _entryrdn_del_data\n");
@@ -1985,7 +2112,7 @@ _entryrdn_insert_key_elems(backend *be,
adddata.flags = DB_DBT_USERMEM;
/* adding RDN to the child key */
- rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_CHILD);
+ rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_CHILD, db_txn);
keybuf = key->data;
if (rc) { /* failed */
goto bail;
@@ -2002,7 +2129,7 @@ _entryrdn_insert_key_elems(backend *be,
key->size = key->ulen = strlen(keybuf) + 1;
key->flags = DB_DBT_USERMEM;
- rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_SELF);
+ rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_SELF, db_txn);
if (rc) { /* failed */
goto bail;
}
@@ -2022,7 +2149,7 @@ _entryrdn_insert_key_elems(backend *be,
adddata.data = (void *)parentelem;
adddata.flags = DB_DBT_USERMEM;
/* adding RDN to the self key */
- rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_PARENT);
+ rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_PARENT, db_txn);
/* Succeeded or failed, it's done. */
bail:
slapi_ch_free_string(&keybuf);
@@ -2036,7 +2163,7 @@ bail:
*/
static int
_entryrdn_replace_suffix_id(DBC *cursor, DBT *key, DBT *adddata,
- ID id, const char *normsuffix)
+ ID id, const char *normsuffix, DB_TXN *db_txn)
{
int rc = 0;
char *keybuf = NULL;
@@ -2061,7 +2188,7 @@ _entryrdn_replace_suffix_id(DBC *cursor, DBT *key, DBT *adddata,
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"_entryrdn_replace_suffix_id: Adding suffix %s failed: "
"%s (%d)\n", normsuffix, dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -2070,6 +2197,13 @@ _entryrdn_replace_suffix_id(DBC *cursor, DBT *key, DBT *adddata,
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_replace_suffix_id: cursor put failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
/*
* Fixing Child link:
@@ -2095,18 +2229,27 @@ _entryrdn_replace_suffix_id(DBC *cursor, DBT *key, DBT *adddata,
memset(&moddata, 0, sizeof(moddata));
moddata.flags = DB_DBT_USERMEM;
-retry_get0:
- rc = cursor->c_get(cursor, key, &data, DB_SET|DB_MULTIPLE);
- if (DB_LOCK_DEADLOCK == rc) {
- /* try again */
- goto retry_get0;
- } else if (DB_NOTFOUND == rc) {
- _entryrdn_cursor_print_error("_entryrdn_replace_suffix_id",
- key->data, data.size, data.ulen, rc);
- goto bail;
- } else if (rc) {
- _entryrdn_cursor_print_error("_entryrdn_replace_suffix_id",
- key->data, data.size, data.ulen, rc);
+
+ for (db_retry = 0; db_retry < RETRY_TIMES; db_retry++) {
+ rc = cursor->c_get(cursor, key, &data, DB_SET|DB_MULTIPLE);
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_replace_suffix_id: cursor get deadlock\n");
+ /* try again */
+ ENTRYRDN_DELAY;
+ } else if (rc) {
+ _entryrdn_cursor_print_error("_entryrdn_replace_suffix_id",
+ key->data, data.size, data.ulen, rc);
+ goto bail;
+ } else {
+ break; /* found */
+ }
+ }
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_replace_suffix_id: cursor get1 failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
goto bail;
}
childelems = (rdn_elem **)slapi_ch_calloc(childnum, sizeof(rdn_elem *));
@@ -2124,13 +2267,16 @@ retry_get0:
moddata.data = childelem;
moddata.ulen = moddata.size = _entryrdn_rdn_elem_size(childelem);
/* Delete it first */
- rc = _entryrdn_del_data(cursor, key, &moddata);
+ rc = _entryrdn_del_data(cursor, key, &moddata, db_txn);
if (rc) {
goto bail0;
}
/* Add it back */
rc = _entryrdn_put_data(cursor, &realkey, &moddata,
- RDN_INDEX_CHILD);
+ RDN_INDEX_CHILD, db_txn);
+ if (rc) {
+ goto bail0;
+ }
if (curr_childnum + 1 == childnum) {
childnum *= 2;
childelems = (rdn_elem **)slapi_ch_realloc((char *)childelems,
@@ -2142,19 +2288,33 @@ retry_get0:
/* We don't access the address with this variable any more */
childelem = NULL;
} while (NULL != dataret.data && NULL != ptr);
-retry_get1:
- rc = cursor->c_get(cursor, key, &data, DB_NEXT_DUP|DB_MULTIPLE);
- if (DB_LOCK_DEADLOCK == rc) {
- /* try again */
- goto retry_get1;
- } else if (DB_NOTFOUND == rc) {
- rc = 0;
- break; /* done */
- } else if (rc) {
- _entryrdn_cursor_print_error("_entryrdn_replace_suffix_id",
- key->data, data.size, data.ulen, rc);
+
+ for (db_retry = 0; db_retry < RETRY_TIMES; db_retry++) {
+ rc = cursor->c_get(cursor, key, &data, DB_NEXT_DUP|DB_MULTIPLE);
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_replace_suffix_id: retry cursor get deadlock\n");
+ /* try again */
+ ENTRYRDN_DELAY;
+ } else if (!rc || (DB_NOTFOUND == rc)) {
+ break; /* done */
+ } else {
+ _entryrdn_cursor_print_error("_entryrdn_replace_suffix_id",
+ key->data, data.size, data.ulen, rc);
+ goto bail0;
+ }
+ }
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_replace_suffix_id: cursor get2 failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
goto bail0;
}
+ if (DB_NOTFOUND == rc) {
+ rc = 0; /* ok */
+ break; /* we're done */
+ }
} while (0 == rc);
/*
@@ -2176,18 +2336,29 @@ retry_get1:
moddata.flags = DB_DBT_MALLOC;
/* Position cursor at the matching key */
-retry_get2:
- rc = cursor->c_get(cursor, key, &moddata, DB_SET);
- if (rc) {
- if (DB_LOCK_DEADLOCK == rc) {
- /* try again */
- goto retry_get2;
- } else if (rc) {
- _entryrdn_cursor_print_error("_entryrdn_replace_suffix_id",
- key->data, data.size, data.ulen, rc);
- goto bail0;
+ for (db_retry = 0; db_retry < RETRY_TIMES; db_retry++) {
+ rc = cursor->c_get(cursor, key, &moddata, DB_SET);
+ if (rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_replace_suffix_id: retry2 cursor get deadlock\n");
+ ENTRYRDN_DELAY;
+ } else {
+ _entryrdn_cursor_print_error("_entryrdn_replace_suffix_id",
+ key->data, data.size, data.ulen, rc);
+ goto bail0;
+ }
+ } else {
+ break;
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_replace_suffix_id: cursor get3 failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail0;
+ }
pelem = (rdn_elem *)moddata.data;
if (TMPID == id_stored_to_internal(pelem->rdn_elem_id)) {
/* the parent id is TMPID;
@@ -2200,7 +2371,7 @@ retry_get2:
"_entryrdn_replace_suffix_id: "
"Fixing the parent link (%s) failed: %s (%d)\n",
keybuf, dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -2209,6 +2380,13 @@ retry_get2:
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_replace_suffix_id: cursor put failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail0;
+ }
}
slapi_ch_free((void **)&moddata.data);
} /* for (cep = childelems; cep && *cep; cep++) */
@@ -2220,6 +2398,9 @@ bail0:
bail:
slapi_ch_free_string(&keybuf);
slapi_ch_free_string(&realkeybuf);
+ if (moddata.data && (moddata.flags == DB_DBT_MALLOC)) {
+ slapi_ch_free((void **)&moddata.data);
+ }
return rc;
}
@@ -2294,7 +2475,7 @@ _entryrdn_insert_key(backend *be,
adddata.data = (void *)elem;
adddata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_put_data(cursor, &key, &adddata, RDN_INDEX_SELF);
+ rc = _entryrdn_put_data(cursor, &key, &adddata, RDN_INDEX_SELF, db_txn);
if (DB_KEYEXIST == rc) {
DBT existdata;
rdn_elem *existelem = NULL;
@@ -2308,7 +2489,7 @@ _entryrdn_insert_key(backend *be,
"_entryrdn_insert_key: Get existing suffix %s "
"failed: %s (%d)\n",
nrdn, dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
@@ -2317,12 +2498,19 @@ _entryrdn_insert_key(backend *be,
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_insert_key: cursor get failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
existelem = (rdn_elem *)existdata.data;
tmpid = id_stored_to_internal(existelem->rdn_elem_id);
slapi_ch_free((void **)&existelem);
if (TMPID == tmpid) {
rc = _entryrdn_replace_suffix_id(cursor, &key, &adddata,
- id, nrdn);
+ id, nrdn, db_txn);
if (rc) {
goto bail;
}
@@ -2401,10 +2589,13 @@ _entryrdn_insert_key(backend *be,
adddata.data = (void *)elem;
adddata.flags = DB_DBT_USERMEM;
- rc = _entryrdn_put_data(cursor, &key, &adddata, RDN_INDEX_SELF);
+ rc = _entryrdn_put_data(cursor, &key, &adddata, RDN_INDEX_SELF, db_txn);
slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
"_entryrdn_insert_key: Suffix %s added: %d\n",
slapi_rdn_get_rdn(tmpsrdn), rc);
+#ifdef FIX_TXN_DEADLOCKS
+#error no checking for rc here? - what if rc is deadlock? should bail?
+#endif
} else {
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
"_entryrdn_insert_key: Suffix \"%s\" not found: "
@@ -2651,25 +2842,41 @@ _entryrdn_delete_key(backend *be,
memset(&data, 0, sizeof(data));
data.flags = DB_DBT_MALLOC;
-retry_get0:
- rc = cursor->c_get(cursor, &key, &data, DB_SET);
- if (rc) {
- if (DB_LOCK_DEADLOCK == rc) {
- /* try again */
- goto retry_get0;
- } else if (DB_NOTFOUND != rc) {
- _entryrdn_cursor_print_error("_entryrdn_delete_key",
- key.data, data.size, data.ulen, rc);
+ for (db_retry = 0; db_retry < RETRY_TIMES; db_retry++) {
+ rc = cursor->c_get(cursor, &key, &data, DB_SET);
+ if (rc) {
+ if (DB_LOCK_DEADLOCK == rc) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_delete_key: cursor get deadlock\n");
+ /* try again */
+ if (db_txn) {
+ goto bail; /* have to abort/retry the entire transaction */
+ } else {
+ ENTRYRDN_DELAY; /* sleep for a bit then retry immediately */
+ }
+ } else if (DB_NOTFOUND != rc) {
+ _entryrdn_cursor_print_error("_entryrdn_delete_key",
+ key.data, data.size, data.ulen, rc);
+ goto bail;
+ } else {
+ break; /* DB_NOTFOUND - ok */
+ }
+ } else {
+ slapi_ch_free(&data.data);
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_delete_key: Failed to remove %s; "
+ "has children\n", nrdn);
+ rc = -1;
goto bail;
}
- } else {
- slapi_ch_free(&data.data);
+ }
+ if (RETRY_TIMES == db_retry) {
slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
- "_entryrdn_delete_key: Failed to remove %s; "
- "has children\n", nrdn);
- rc = -1;
+ "_entryrdn_delete_key: failed after [%d] iterations\n", db_retry);
+ rc = DB_LOCK_DEADLOCK;
goto bail;
}
+
workid = id;
do {
@@ -2777,15 +2984,22 @@ retry_get0:
"_entryrdn_delete_key: Deleting %s failed; "
"%s(%d)\n", (char *)key.data,
dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
- ENTRYRDN_DELAY;
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
+ ENTRYRDN_DELAY; /* sleep for a bit then retry immediately */
continue;
}
- goto bail;
+ goto bail; /* if deadlock and txn, have to abort entire txn */
} else {
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_delete_key: delete parent link failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
} else if (parentnrdn) {
#ifdef LDAP_DEBUG_ENTRYRDN
_entryrdn_dump_rdn_elem(elem);
@@ -2800,15 +3014,22 @@ retry_get0:
"_entryrdn_delete_key: Deleting %s failed; "
"%s(%d)\n", (char *)key.data,
dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
- goto bail;
+ goto bail; /* if deadlock and txn, have to abort entire txn */
} else {
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_delete_key: delete parent's child link failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ goto bail;
+ }
selfnrdn = nrdn;
workid = id;
} else if (selfnrdn) {
@@ -2824,20 +3045,27 @@ retry_get0:
"_entryrdn_delete_key: Deleting %s failed; "
"%s(%d)\n", (char *)key.data,
dblayer_strerror(rc), rc);
- if (DB_LOCK_DEADLOCK == rc) {
+ if ((DB_LOCK_DEADLOCK == rc) && !db_txn) {
ENTRYRDN_DELAY;
continue;
}
- goto bail;
+ goto bail; /* if deadlock and txn, have to abort entire txn */
} else {
break; /* success */
}
}
+ if (RETRY_TIMES == db_retry) {
+ slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG,
+ "_entryrdn_delete_key: delete self link failed after [%d] retries\n",
+ db_retry);
+ rc = DB_LOCK_DEADLOCK;
+ }
goto bail; /* done */
}
} while (workid);
bail:
+ slapi_ch_free_string(&parentnrdn);
slapi_ch_free_string(&keybuf);
slapi_ch_free((void **)&elem);
slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
@@ -3107,6 +3335,11 @@ _entryrdn_index_read(backend *be,
retry_get0:
rc = cursor->c_get(cursor, &key, &data, DB_SET|DB_MULTIPLE);
if (DB_LOCK_DEADLOCK == rc) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_index_read: cursor get deadlock\n");
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
/* try again */
goto retry_get0;
} else if (DB_NOTFOUND == rc) {
@@ -3146,6 +3379,11 @@ retry_get0:
retry_get1:
rc = cursor->c_get(cursor, &key, &data, DB_NEXT_DUP|DB_MULTIPLE);
if (DB_LOCK_DEADLOCK == rc) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_index_read: retry cursor get deadlock\n");
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
/* try again */
goto retry_get1;
} else if (DB_NOTFOUND == rc) {
@@ -3197,7 +3435,12 @@ retry_get0:
rc = cursor->c_get(cursor, &key, &data, DB_SET|DB_MULTIPLE);
if (rc) {
if (DB_LOCK_DEADLOCK == rc) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_append_childidl: cursor get deadlock\n");
/* try again */
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
goto retry_get0;
} else if (DB_NOTFOUND == rc) {
rc = 0; /* okay not to have children */
@@ -3242,7 +3485,12 @@ retry_get1:
rc = cursor->c_get(cursor, &key, &data, DB_NEXT_DUP|DB_MULTIPLE);
if (rc) {
if (DB_LOCK_DEADLOCK == rc) {
+ slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
+ "_entryrdn_append_childidl: retry cursor get deadlock\n");
/* try again */
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
goto retry_get1;
} else if (DB_NOTFOUND == rc) {
rc = 0; /* okay not to have children */
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index bdc29673a..f7520c61d 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -460,25 +460,17 @@ ldbm_back_modify( Slapi_PBlock *pb )
/* New entry 'ec' is in the entry cache.
* Remove it from the cache once. */
CACHE_REMOVE(&inst->inst_cache, ec);
- cache_unlock_entry(&inst->inst_cache, e);
- CACHE_RETURN(&inst->inst_cache, ec);
+ CACHE_RETURN(&inst->inst_cache, &ec);
} else {
backentry_free(&ec);
}
+ ec_in_cache = 0; /* added to cache by id2entry - have to remove to try again */
slapi_pblock_set( pb, SLAPI_MODIFY_EXISTING_ENTRY, original_entry->ep_entry );
ec = original_entry;
if ( (original_entry = backentry_dup( e )) == NULL ) {
ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
- /* Put new entry 'ec' into the entry cache. */
- if (ec_in_cache && CACHE_ADD(&inst->inst_cache, ec, NULL) < 0) {
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "ldbm_back_modify: adding %s to cache failed\n",
- slapi_entry_get_dn_const(ec->ep_entry));
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- goto error_return;
- }
LDAPDebug0Args(LDAP_DEBUG_BACKLDBM,
"Modify Retrying Transaction\n");
#ifndef LDBM_NO_BACKOFF_DELAY
@@ -603,7 +595,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
}
if (retry_count == RETRY_TIMES) {
LDAPDebug( LDAP_DEBUG_ANY, "Retry count exceeded in modify\n", 0, 0, 0 );
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_BUSY;
goto error_return;
}
@@ -629,6 +621,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
ec->ep_entry->e_virtual_watermark = 0;
/* we must return both e (which has been deleted) and new entry ec */
+ /* cache_replace removes e from the caches */
cache_unlock_entry( &inst->inst_cache, e );
CACHE_RETURN( &inst->inst_cache, &e );
/*
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index b3d811156..c7d821ae4 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -46,11 +46,11 @@
#include "back-ldbm.h"
static const char *moddn_get_newdn(Slapi_PBlock *pb, Slapi_DN *dn_olddn, Slapi_DN *dn_newrdn, Slapi_DN *dn_newsuperiordn);
-static void moddn_unlock_and_return_entries(backend *be,struct backentry **targetentry, struct backentry **existingentry);
+static void moddn_unlock_and_return_entry(backend *be,struct backentry **targetentry);
static int moddn_newrdn_mods(Slapi_PBlock *pb, const char *olddn, struct backentry *ec, Slapi_Mods *smods_wsi, int is_repl_op);
static IDList *moddn_get_children(back_txn *ptxn, Slapi_PBlock *pb, backend *be, struct backentry *parententry, Slapi_DN *parentdn, struct backentry ***child_entries, struct backdn ***child_dns);
static int moddn_rename_children(back_txn *ptxn, Slapi_PBlock *pb, backend *be, IDList *children, Slapi_DN *dn_parentdn, Slapi_DN *dn_newsuperiordn, struct backentry *child_entries[]);
-static int modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li, struct backentry *e, struct backentry *ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3);
+static int modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li, struct backentry *e, struct backentry **ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3, int *e_in_cache, int *ec_in_cache);
static void mods_remove_nsuniqueid(Slapi_Mods *smods);
#define MOD_SET_ERROR(rc, error, count) \
@@ -68,6 +68,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
struct backentry *e= NULL;
struct backentry *ec= NULL;
int ec_in_cache= 0;
+ int e_in_cache= 0;
back_txn txn;
back_txnid parent_txn;
int retval = -1;
@@ -81,7 +82,6 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
char *ldap_result_matcheddn= NULL;
struct backentry *parententry= NULL;
struct backentry *newparententry= NULL;
- struct backentry *existingentry= NULL;
struct backentry *original_entry = NULL;
struct backentry *original_parent = NULL;
struct backentry *original_newparent = NULL;
@@ -120,6 +120,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
const char *newdn = NULL;
char *newrdn = NULL;
int opreturn = 0;
+ int free_modrdn_existing_entry = 0;
/* sdn & parentsdn need to be initialized before "goto *_return" */
slapi_sdn_init(&dn_newdn);
@@ -254,6 +255,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
{
goto error_return;
}
+ free_modrdn_existing_entry = 1; /* need to free it */
}
/* <old superior> */
@@ -349,6 +351,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
ldap_result_code= -1;
goto error_return; /* error result sent by find_entry2modify() */
}
+ e_in_cache = 1; /* e is in the cache and locked */
/* Check that an entry with the same DN doesn't already exist. */
{
Slapi_Entry *entry;
@@ -518,17 +521,21 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
}
/* create it in the cache - prevents others from creating it */
- if (( cache_add_tentative( &inst->inst_cache, ec, NULL ) != 0 ) &&
+ if (( cache_add_tentative( &inst->inst_cache, ec, NULL ) != 0 ) ) {
+ ec_in_cache = 0; /* not in cache */
/* allow modrdn even if the src dn and dest dn are identical */
- ( 0 != slapi_sdn_compare((const Slapi_DN *)&dn_newdn,
- (const Slapi_DN *)sdn)) )
- {
- /* somebody must've created it between dn2entry() and here */
- /* JCMREPL - Hmm... we can't permit this to happen...? */
- ldap_result_code= LDAP_ALREADY_EXISTS;
- goto error_return;
+ if ( 0 != slapi_sdn_compare((const Slapi_DN *)&dn_newdn,
+ (const Slapi_DN *)sdn) ) {
+ /* somebody must've created it between dn2entry() and here */
+ /* JCMREPL - Hmm... we can't permit this to happen...? */
+ ldap_result_code= LDAP_ALREADY_EXISTS;
+ goto error_return;
+ }
+ /* so if the old dn is the same as the new dn, the entry will not be cached
+ until it is replaced with cache_replace */
+ } else {
+ ec_in_cache = 1;
}
- ec_in_cache= 1;
/* Build the list of modifications required to the existing entry */
{
@@ -725,15 +732,6 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
- if ( (original_parent = backentry_dup( parententry )) == NULL ) {
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
- }
- if ( newparententry &&
- ((original_newparent = backentry_dup( newparententry )) == NULL) ) {
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
- }
slapi_pblock_get(pb, SLAPI_MODRDN_TARGET_ENTRY, &target_entry);
if ( (original_targetentry = slapi_entry_dup(target_entry)) == NULL ) {
ldap_result_code= LDAP_OPERATIONS_ERROR;
@@ -754,6 +752,8 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
{
if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn))
{
+ Slapi_Entry *ent = NULL;
+
dblayer_txn_abort(li,&txn);
/* txn is no longer valid - reset slapi_txn to the parent */
slapi_pblock_set(pb, SLAPI_TXN, parent_txn);
@@ -761,6 +761,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &newrdn);
slapi_ch_free_string(&newrdn);
slapi_pblock_set(pb, SLAPI_MODRDN_NEWRDN, original_newrdn);
+ slapi_sdn_set_normdn_byref(&dn_newrdn, original_newrdn);
original_newrdn = slapi_ch_strdup(original_newrdn);
slapi_pblock_get(pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &dn_newsuperiordn);
@@ -769,27 +770,51 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
orig_dn_newsuperiordn = slapi_sdn_dup(orig_dn_newsuperiordn);
if (ec_in_cache) {
/* New entry 'ec' is in the entry cache.
- * Remove it from teh cache once. */
+ * Remove it from the cache . */
CACHE_REMOVE(&inst->inst_cache, ec);
- cache_unlock_entry(&inst->inst_cache, e);
- CACHE_RETURN(&inst->inst_cache, ec);
+ CACHE_RETURN(&inst->inst_cache, &ec);
+#ifdef DEBUG_CACHE
+ PR_ASSERT(ec == NULL);
+#endif
+ ec_in_cache = 0;
} else {
backentry_free(&ec);
}
- slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, original_entry->ep_entry );
+ /* make sure the original entry is back in the cache if it was removed */
+ if (!e_in_cache) {
+ CACHE_ADD(&inst->inst_cache, e, NULL);
+ e_in_cache = 1;
+ }
+ slapi_pblock_get( pb, SLAPI_MODRDN_EXISTING_ENTRY, &ent );
+ if (ent && (ent != original_entry->ep_entry)) {
+ slapi_entry_free(ent);
+ slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, NULL );
+ }
ec = original_entry;
if ( (original_entry = backentry_dup( ec )) == NULL ) {
ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
- if (ec_in_cache &&
+ slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, original_entry->ep_entry );
+ free_modrdn_existing_entry = 0; /* owned by original_entry now */
+ if (!ec_in_cache) {
/* Put the resetted entry 'ec' into the cache again. */
- (cache_add_tentative( &inst->inst_cache, ec, NULL ) != 0)) {
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "ldbm_back_modrdn: adding %s to cache failed\n",
- slapi_entry_get_dn_const(ec->ep_entry));
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- goto error_return;
+ if (cache_add_tentative( &inst->inst_cache, ec, NULL ) != 0) {
+ ec_in_cache = 0; /* not in cache */
+ /* allow modrdn even if the src dn and dest dn are identical */
+ if ( 0 != slapi_sdn_compare((const Slapi_DN *)&dn_newdn,
+ (const Slapi_DN *)sdn) ) {
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,
+ "ldbm_back_modrdn: adding %s to cache failed\n",
+ slapi_entry_get_dn_const(ec->ep_entry));
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ goto error_return;
+ }
+ /* so if the old dn is the same as the new dn, the entry will not be cached
+ until it is replaced with cache_replace */
+ } else {
+ ec_in_cache = 1;
+ }
}
slapi_pblock_get(pb, SLAPI_MODRDN_TARGET_ENTRY, &target_entry );
@@ -800,28 +825,16 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
goto error_return;
}
- backentry_free(&parententry);
- slapi_pblock_set( pb, SLAPI_MODRDN_PARENT_ENTRY, original_parent->ep_entry );
- parententry = original_parent;
- if ( (original_entry = backentry_dup( parententry )) == NULL ) {
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
- }
-
- backentry_free(&newparententry);
- if (original_newparent) {
- slapi_pblock_set( pb, SLAPI_MODRDN_NEWPARENT_ENTRY,
- original_newparent->ep_entry );
- }
- newparententry = original_entry;
- if ( newparententry &&
- ((original_entry = backentry_dup(newparententry)) == NULL) ) {
- ldap_result_code= LDAP_OPERATIONS_ERROR;
- goto error_return;
- }
/* We're re-trying */
LDAPDebug0Args(LDAP_DEBUG_BACKLDBM,
"Modrdn Retrying Transaction\n");
+#ifndef LDBM_NO_BACKOFF_DELAY
+ {
+ PRIntervalTime interval;
+ interval = PR_MillisecondsToInterval(slapi_rand() % 100);
+ DS_Sleep(interval);
+ }
+#endif
}
retval = dblayer_txn_begin(li,parent_txn,&txn);
if (0 != retval) {
@@ -852,7 +865,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
/*
* Update the indexes for the entry.
*/
- retval = modrdn_rename_entry_update_indexes(&txn, pb, li, e, ec, &smods_generated, &smods_generated_wsi, &smods_operation_wsi);
+ retval = modrdn_rename_entry_update_indexes(&txn, pb, li, e, &ec, &smods_generated, &smods_generated_wsi, &smods_operation_wsi, &e_in_cache, &ec_in_cache);
if (DB_LOCK_DEADLOCK == retval)
{
/* Retry txn */
@@ -979,11 +992,14 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
{
Slapi_RDN newsrdn;
slapi_rdn_init_sdn(&newsrdn, (const Slapi_DN *)&dn_newdn);
- rc = entryrdn_rename_subtree(be, (const Slapi_DN *)sdn, &newsrdn,
- (const Slapi_DN *)dn_newsuperiordn,
- e->ep_id, &txn);
+ retval = entryrdn_rename_subtree(be, (const Slapi_DN *)sdn, &newsrdn,
+ (const Slapi_DN *)dn_newsuperiordn,
+ e->ep_id, &txn);
slapi_rdn_done(&newsrdn);
- if (rc) {
+ if (retval != 0) {
+ if (retval == DB_LOCK_DEADLOCK) continue;
+ if (retval == DB_RUNRECOVERY || LDBM_OS_ERR_IS_DISKFULL(retval))
+ disk_full = 1;
MOD_SET_ERROR(ldap_result_code,
LDAP_OPERATIONS_ERROR, retry_count);
goto error_return;
@@ -1035,7 +1051,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
{
/* Failed */
LDAPDebug( LDAP_DEBUG_ANY, "Retry count exceeded in modrdn\n", 0, 0, 0 );
- ldap_result_code= LDAP_OPERATIONS_ERROR;
+ ldap_result_code= LDAP_BUSY;
goto error_return;
}
@@ -1128,12 +1144,6 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
}
retval= 0;
-#if 0 /* this new entry in the cache can be used for future; don't remove it */
- /* remove from cache so that memory can be freed by cache_return */
- if (ec_in_cache) {
- CACHE_REMOVE(&inst->inst_cache, ec);
- }
-#endif
goto common_return;
error_return:
@@ -1151,13 +1161,6 @@ error_return:
CACHE_REMOVE(&inst->inst_dncache, bdn);
CACHE_RETURN(&inst->inst_dncache, &bdn);
}
- if( ec!=NULL ) {
- if (ec_in_cache) {
- CACHE_REMOVE(&inst->inst_cache, ec);
- } else {
- backentry_free( &ec );
- }
- }
if(children)
{
int i = 0;
@@ -1245,13 +1248,6 @@ error_return:
common_return:
- /* Free up the resource we don't need any more */
- if(ec_in_cache) {
- CACHE_RETURN( &inst->inst_cache, &ec );
- }
-
- moddn_unlock_and_return_entries(be,&e,&existingentry);
-
/* result code could be used in the bepost plugin functions. */
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
/*
@@ -1259,6 +1255,32 @@ common_return:
*/
plugin_call_plugins (pb, SLAPI_PLUGIN_BE_POST_MODRDN_FN);
+ /* Free up the resource we don't need any more */
+ if (ec) {
+ /* remove the new entry from the cache if the op failed -
+ otherwise, leave it in */
+ if (ec_in_cache && retval) {
+ CACHE_REMOVE( &inst->inst_cache, ec );
+ }
+ if (ec_in_cache) {
+ CACHE_RETURN( &inst->inst_cache, &ec );
+ } else {
+ backentry_free( &ec );
+ }
+ ec = NULL;
+ ec_in_cache = 0;
+ }
+
+ /* put e back in the cache if the modrdn failed */
+ if (e) {
+ if (!e_in_cache && retval) {
+ CACHE_ADD(&inst->inst_cache, e, NULL);
+ e_in_cache = 1;
+ }
+ }
+
+ moddn_unlock_and_return_entry(be,&e);
+
if (ruv_c_init) {
modify_term(&ruv_c, be);
}
@@ -1281,7 +1303,11 @@ common_return:
slapi_sdn_done(&dn_parentdn);
modify_term(&parent_modify_context,be);
modify_term(&newparent_modify_context,be);
- done_with_pblock_entry(pb,SLAPI_MODRDN_EXISTING_ENTRY);
+ if (free_modrdn_existing_entry) {
+ done_with_pblock_entry(pb,SLAPI_MODRDN_EXISTING_ENTRY);
+ } else { /* owned by original_entry */
+ slapi_pblock_set(pb, SLAPI_MODRDN_EXISTING_ENTRY, NULL);
+ }
done_with_pblock_entry(pb,SLAPI_MODRDN_PARENT_ENTRY);
done_with_pblock_entry(pb,SLAPI_MODRDN_NEWPARENT_ENTRY);
done_with_pblock_entry(pb,SLAPI_MODRDN_TARGET_ENTRY);
@@ -1354,10 +1380,9 @@ moddn_get_newdn(Slapi_PBlock *pb, Slapi_DN *dn_olddn, Slapi_DN *dn_newrdn, Slapi
* Return the entries to the cache.
*/
static void
-moddn_unlock_and_return_entries(
+moddn_unlock_and_return_entry(
backend *be,
- struct backentry **targetentry,
- struct backentry **existingentry)
+ struct backentry **targetentry)
{
ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
@@ -1367,10 +1392,6 @@ moddn_unlock_and_return_entries(
CACHE_RETURN( &inst->inst_cache, targetentry );
*targetentry= NULL;
}
- if ( *existingentry!=NULL ) {
- CACHE_RETURN( &inst->inst_cache, existingentry );
- *existingentry= NULL;
- }
}
@@ -1540,8 +1561,8 @@ moddn_newrdn_mods(Slapi_PBlock *pb, const char *olddn, struct backentry *ec, Sla
}
else
{
- LDAPDebug( LDAP_DEBUG_TRACE, "moddn_newrdn_mods failed: could not parse new rdn %s\n",
- newrdn, 0, 0);
+ LDAPDebug( LDAP_DEBUG_TRACE, "moddn_newrdn_mods failed: could not parse new rdn %s\n",
+ newrdn, 0, 0);
return LDAP_OPERATIONS_ERROR;
}
@@ -1568,7 +1589,7 @@ mods_remove_nsuniqueid(Slapi_Mods *smods)
* mods contains the list of attribute change made.
*/
static int
-modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li, struct backentry *e, struct backentry *ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3)
+modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li, struct backentry *e, struct backentry **ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3, int *e_in_cache, int *ec_in_cache)
{
backend *be;
ldbm_instance *inst;
@@ -1576,36 +1597,41 @@ modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbm
char *msg;
Slapi_Operation *operation;
int is_ruv = 0; /* True if the current entry is RUV */
+ int orig_ec_in_cache = 0;
slapi_pblock_get( pb, SLAPI_BACKEND, &be );
slapi_pblock_get( pb, SLAPI_OPERATION, &operation );
is_ruv = operation_is_flag_set(operation, OP_FLAG_REPL_RUV);
inst = (ldbm_instance *) be->be_instance_info;
+ orig_ec_in_cache = *ec_in_cache;
/*
* Update the ID to Entry index.
* Note that id2entry_add replaces the entry, so the Entry ID stays the same.
*/
- retval = id2entry_add( be, ec, ptxn );
+ retval = id2entry_add( be, *ec, ptxn );
if (DB_LOCK_DEADLOCK == retval)
{
/* Retry txn */
+ LDAPDebug0Args( LDAP_DEBUG_BACKLDBM, "modrdn_rename_entry_update_indexes: id2entry_add deadlock\n" );
goto error_return;
}
if (retval != 0)
{
- LDAPDebug( LDAP_DEBUG_ANY, "id2entry_add failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
+ LDAPDebug( LDAP_DEBUG_ANY, "modrdn_rename_entry_update_indexes: id2entry_add failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
goto error_return;
}
+ *ec_in_cache = 1; /* id2entry_add adds to cache if not already in */
if(smods1!=NULL && slapi_mods_get_num_mods(smods1)>0)
{
/*
* update the indexes: lastmod, rdn, etc.
*/
- retval = index_add_mods( be, slapi_mods_get_ldapmods_byref(smods1), e, ec, ptxn );
+ retval = index_add_mods( be, slapi_mods_get_ldapmods_byref(smods1), e, *ec, ptxn );
if (DB_LOCK_DEADLOCK == retval)
{
/* Retry txn */
+ LDAPDebug0Args( LDAP_DEBUG_BACKLDBM, "modrdn_rename_entry_update_indexes: index_add_mods1 deadlock\n" );
goto error_return;
}
if (retval != 0)
@@ -1625,10 +1651,11 @@ modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbm
/*
* update the indexes: lastmod, rdn, etc.
*/
- retval = index_add_mods( be, slapi_mods_get_ldapmods_byref(smods2), e, ec, ptxn );
+ retval = index_add_mods( be, slapi_mods_get_ldapmods_byref(smods2), e, *ec, ptxn );
if (DB_LOCK_DEADLOCK == retval)
{
/* Retry txn */
+ LDAPDebug0Args( LDAP_DEBUG_BACKLDBM, "modrdn_rename_entry_update_indexes: index_add_mods2 deadlock\n" );
goto error_return;
}
if (retval != 0)
@@ -1642,10 +1669,11 @@ modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbm
/*
* update the indexes: lastmod, rdn, etc.
*/
- retval = index_add_mods( be, slapi_mods_get_ldapmods_byref(smods3), e, ec, ptxn );
+ retval = index_add_mods( be, slapi_mods_get_ldapmods_byref(smods3), e, *ec, ptxn );
if (DB_LOCK_DEADLOCK == retval)
{
/* Retry txn */
+ LDAPDebug0Args( LDAP_DEBUG_BACKLDBM, "modrdn_rename_entry_update_indexes: index_add_mods3 deadlock\n" );
goto error_return;
}
if (retval != 0)
@@ -1661,10 +1689,11 @@ modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbm
*/
if (!is_ruv)
{
- retval= vlv_update_all_indexes(ptxn, be, pb, e, ec);
+ retval= vlv_update_all_indexes(ptxn, be, pb, e, *ec);
if (DB_LOCK_DEADLOCK == retval)
{
/* Abort and re-try */
+ LDAPDebug0Args( LDAP_DEBUG_BACKLDBM, "modrdn_rename_entry_update_indexes: vlv_update_all_indexes deadlock\n" );
goto error_return;
}
if (retval != 0)
@@ -1673,9 +1702,18 @@ modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbm
goto error_return;
}
}
- if (cache_replace( &inst->inst_cache, e, ec ) != 0 ) {
+ if (cache_replace( &inst->inst_cache, e, *ec ) != 0 ) {
+ LDAPDebug0Args( LDAP_DEBUG_BACKLDBM, "modrdn_rename_entry_update_indexes cache_replace failed\n");
retval= -1;
goto error_return;
+ } else {
+ *e_in_cache = 0; /* e un-cached */
+ }
+ if (orig_ec_in_cache) {
+ /* ec was already added to the cache via cache_add_tentative (to reserve its spot in the cache)
+ and/or id2entry_add - so it already had one refcount - cache_replace adds another refcount -
+ drop the extra ref added by cache_replace */
+ CACHE_RETURN( &inst->inst_cache, ec );
}
error_return:
return retval;
@@ -1687,7 +1725,7 @@ moddn_rename_child_entry(
Slapi_PBlock *pb,
struct ldbminfo *li,
struct backentry *e,
- struct backentry *ec,
+ struct backentry **ec,
int parentdncomps,
char **newsuperiordns,
int newsuperiordncomps,
@@ -1711,8 +1749,10 @@ moddn_rename_child_entry(
int olddncomps= 0;
int need= 1; /* For the '\0' */
int i;
+ int e_in_cache = 1;
+ int ec_in_cache = 0;
- olddn = slapi_entry_get_dn(ec->ep_entry);
+ olddn = slapi_entry_get_dn((*ec)->ep_entry);
if (NULL == olddn) {
return retval;
}
@@ -1747,9 +1787,9 @@ moddn_rename_child_entry(
}
}
slapi_ldap_value_free( olddns );
- slapi_entry_set_dn( ec->ep_entry, newdn );
+ slapi_entry_set_dn( (*ec)->ep_entry, newdn );
/* add the entrydn operational attributes */
- add_update_entrydn_operational_attributes (ec);
+ add_update_entrydn_operational_attributes (*ec);
/*
* Update the DN CSN of the entry.
@@ -1767,13 +1807,14 @@ moddn_rename_child_entry(
slapi_mods_add( &smods, LDAP_MOD_DELETE, LDBM_ENTRYDN_STR,
strlen( backentry_get_ndn(e) ), backentry_get_ndn(e) );
slapi_mods_add( &smods, LDAP_MOD_REPLACE, LDBM_ENTRYDN_STR,
- strlen( backentry_get_ndn(ec) ), backentry_get_ndn(ec) );
+ strlen( backentry_get_ndn(*ec) ), backentry_get_ndn(*ec) );
smodsp = &smods;
/*
* Update all the indexes.
*/
retval = modrdn_rename_entry_update_indexes(ptxn, pb, li, e, ec,
- smodsp, NULL, NULL);
+ smodsp, NULL, NULL,
+ &e_in_cache, &ec_in_cache);
/* JCMREPL - Should the children get updated modifiersname and lastmodifiedtime? */
slapi_mods_done(&smods);
}
@@ -1850,7 +1891,7 @@ moddn_rename_children(
opcsn = operation_get_csn (operation);
for (i=0,retval=0; retval == 0 && child_entries[i] && child_entry_copies[i]; i++) {
retval = moddn_rename_child_entry(ptxn, pb, li, child_entries[i],
- child_entry_copies[i], parentdncomps,
+ &child_entry_copies[i], parentdncomps,
newsuperiordns, newsuperiordncomps,
opcsn );
}
diff --git a/ldap/servers/slapd/back-ldbm/misc.c b/ldap/servers/slapd/back-ldbm/misc.c
index 814081845..a56069bfc 100644
--- a/ldap/servers/slapd/back-ldbm/misc.c
+++ b/ldap/servers/slapd/back-ldbm/misc.c
@@ -53,7 +53,7 @@ void ldbm_nasty(const char* str, int c, int err)
char buffer[200];
if (err == DB_LOCK_DEADLOCK) {
PR_snprintf(buffer,200,"%s WARNING %d",str,c);
- LDAPDebug(LDAP_DEBUG_TRACE,"%s, err=%d %s\n",
+ LDAPDebug(LDAP_DEBUG_BACKLDBM,"%s, err=%d %s\n",
buffer,err,(msg = dblayer_strerror( err )) ? msg : "");
} else if (err == DB_RUNRECOVERY) {
LDAPDebug2Args(LDAP_DEBUG_ANY, "FATAL ERROR at %s (%d); "
diff --git a/ldap/servers/slapd/back-ldbm/seq.c b/ldap/servers/slapd/back-ldbm/seq.c
index ac958ad58..1435ba2b3 100644
--- a/ldap/servers/slapd/back-ldbm/seq.c
+++ b/ldap/servers/slapd/back-ldbm/seq.c
@@ -240,6 +240,9 @@ ldbm_back_seq( Slapi_PBlock *pb )
idl = idl_fetch( be, db, &key, NULL, ai, &err );
if(err == DB_LOCK_DEADLOCK) {
ldbm_nasty("ldbm_back_seq deadlock retry", 1600, err);
+#ifdef FIX_TXN_DEADLOCKS
+#error if txn != NULL, have to retry the entire transaction
+#endif
continue;
} else {
break;
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 22237ce5c..3138ed37b 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1242,7 +1242,8 @@ enum
BE_STATE_STOPPED = 1, /* backend is initialized but not started */
BE_STATE_STARTED, /* backend is started */
BE_STATE_CLEANED, /* backend was cleaned up */
- BE_STATE_DELETED /* backend is removed */
+ BE_STATE_DELETED, /* backend is removed */
+ BE_STATE_STOPPING /* told to stop but not yet stopped */
};
struct conn;
| 0 |
5538bac519c5363bb456e98d615c9366dedd57d8
|
389ds/389-ds-base
|
Ticket 48266 - Online init crashes consumer
Bug Description: When trying to create the 'replica keep alive' entry
on a consumer during an online init, the entry gets freed
in op_shared_add(), and then freed again in
replica_subentry_create() which leads to a crash.
Fix Description: Do not free the "keep alive" entry if a referral is
returned when trying to create the keep-alive entry.
https://fedorahosted.org/389/ticket/48266
Reviewed by: tbordaz(Thanks!)
|
commit 5538bac519c5363bb456e98d615c9366dedd57d8
Author: Mark Reynolds <[email protected]>
Date: Tue Sep 22 09:49:12 2015 -0400
Ticket 48266 - Online init crashes consumer
Bug Description: When trying to create the 'replica keep alive' entry
on a consumer during an online init, the entry gets freed
in op_shared_add(), and then freed again in
replica_subentry_create() which leads to a crash.
Fix Description: Do not free the "keep alive" entry if a referral is
returned when trying to create the keep-alive entry.
https://fedorahosted.org/389/ticket/48266
Reviewed by: tbordaz(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 6ac28c13c..708008c18 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -448,7 +448,9 @@ replica_subentry_create(Slapi_DN *repl_root, ReplicaId rid)
repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */);
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
- if (return_value != LDAP_SUCCESS && return_value != LDAP_ALREADY_EXISTS)
+ if (return_value != LDAP_SUCCESS &&
+ return_value != LDAP_ALREADY_EXISTS &&
+ return_value != LDAP_REFERRAL /* CONSUMER */)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
"create replication keep alive entry %s: %s\n", slapi_entry_get_dn_const(e),
| 0 |
2237cbb7f9bdadfee9913f32a71eccd73d57d27b
|
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 ids_sasl_check_bind().
|
commit 2237cbb7f9bdadfee9913f32a71eccd73d57d27b
Author: Endi S. Dewata <[email protected]>
Date: Fri Jul 2 00:16:08 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 ids_sasl_check_bind().
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index 58703657e..ecc935c2b 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -966,11 +966,10 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
bind_target_entry = get_entry(pb, dn);
if ( bind_target_entry == NULL )
{
- break;
+ goto out;
}
if ( slapi_check_account_lock(pb, bind_target_entry, pwresponse_requested, 1, 1) == 1) {
- slapi_entry_free(bind_target_entry);
- break;
+ goto out;
}
}
@@ -1003,10 +1002,6 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
int pwrc;
pwrc = need_new_pw(pb, &t, bind_target_entry, pwresponse_requested);
- if ( bind_target_entry != NULL ) {
- slapi_entry_free(bind_target_entry);
- bind_target_entry = NULL;
- }
switch (pwrc) {
case 1:
@@ -1081,6 +1076,8 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
slapi_entry_free(referral);
if (be)
slapi_be_Unlock(be);
+ if (bind_target_entry)
+ slapi_entry_free(bind_target_entry);
LDAPDebug( LDAP_DEBUG_TRACE, "=> ids_sasl_check_bind\n", 0, 0, 0 );
| 0 |
31f4f341b8f1d2ae04ae1606f0822169201d2737
|
389ds/389-ds-base
|
fix jenkins warning
|
commit 31f4f341b8f1d2ae04ae1606f0822169201d2737
Author: Ludwig Krispenz <[email protected]>
Date: Wed Dec 17 19:54:33 2014 +0100
fix jenkins warning
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index cc42c6c03..b8e23867b 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -921,7 +921,7 @@ int memberof_postop_modrdn(Slapi_PBlock *pb)
}
if(ret == LDAP_SUCCESS) {
memberof_del_dn_data del_data = {0, configCopy.memberof_attr};
- if(ret = memberof_del_dn_type_callback(post_e, &del_data)){
+ if((ret = memberof_del_dn_type_callback(post_e, &del_data))){
slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
"memberof_postop_modrdn - delete dn callback failed for (%s), error (%d)\n",
slapi_entry_get_dn(post_e), ret);
| 0 |
6816e1155b28fb65fe294099336c4acbbac8ad77
|
389ds/389-ds-base
|
Ticket 47793 - Server crashes if uniqueMember is invalid syntax and memberOf
plugin is enabled.
Bug Description: MemberOf assumes the DN value has the correct syntax, and
does not check the normalized value of that DN. This
leads to dereferencing a NULL pointer and crash.
Fix Description: Check the normalized value, and log a proper error.
https://fedorahosted.org/389/ticket/47793
Reviewed by: nhosoi(Thanks!)
|
commit 6816e1155b28fb65fe294099336c4acbbac8ad77
Author: Mark Reynolds <[email protected]>
Date: Thu May 8 15:10:52 2014 -0400
Ticket 47793 - Server crashes if uniqueMember is invalid syntax and memberOf
plugin is enabled.
Bug Description: MemberOf assumes the DN value has the correct syntax, and
does not check the normalized value of that DN. This
leads to dereferencing a NULL pointer and crash.
Fix Description: Check the normalized value, and log a proper error.
https://fedorahosted.org/389/ticket/47793
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index f3771054b..1073b8e37 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -1309,20 +1309,31 @@ memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config,
char *op_str = 0;
const char *op_to;
const char *op_this;
- Slapi_Value *to_dn_val;
- Slapi_Value *this_dn_val;
+ Slapi_Value *to_dn_val = NULL;
+ Slapi_Value *this_dn_val = NULL;
op_to = slapi_sdn_get_ndn(op_to_sdn);
op_this = slapi_sdn_get_ndn(op_this_sdn);
- to_dn_val = slapi_value_new_string(op_to);
- this_dn_val = slapi_value_new_string(op_this);
- if(this_dn_val == NULL || to_dn_val == NULL){
+ /* Make sure we have valid DN's for the group(op_this) and the new member(op_to) */
+ if(op_to && op_this){
+ to_dn_val = slapi_value_new_string(op_to);
+ this_dn_val = slapi_value_new_string(op_this);
+ }
+ if(to_dn_val == NULL){
+ const char *udn = op_to_sdn ? slapi_sdn_get_udn(op_to_sdn) : "";
slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
- "memberof_modop_one_replace_r: failed to get DN values (NULL)\n");
+ "memberof_modop_one_replace_r: failed to get DN value from "
+ "member value (%s)\n", udn);
+ goto bail;
+ }
+ if(this_dn_val == NULL){
+ const char *udn = op_this_sdn ? slapi_sdn_get_udn(op_this_sdn) : "";
+ slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
+ "memberof_modop_one_replace_r: failed to get DN value from"
+ "group (%s)\n", udn);
goto bail;
}
-
/* op_this and op_to are both case-normalized */
slapi_value_set_flags(this_dn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS);
slapi_value_set_flags(to_dn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS);
| 0 |
1315287109f4054b42819c11604d4620a723eb36
|
389ds/389-ds-base
|
Issue 5755 - Massive memory leaking on update operations (#5824)
Description: Correction of idl memory leak fix
Fix description: Initial mem leak fix (#5803) causing a SEGV during
basic search.
The inital memory leak occurs during idl_set manipulation when a filter
type LDAP_FILTER_AND, filter choice LDAP_FILTER_NOT and an empty set is
used. The complelement idl is stashed for a later intersection, but is
never freed when an empty set is used during set intersection.
The previous fix has been removed and the inital leak corrected.
relates: https://github.com/389ds/389-ds-base/pull/5803
Reviewed by: @tbordaz @progier389 (Thank you)
|
commit 1315287109f4054b42819c11604d4620a723eb36
Author: James Chapman <[email protected]>
Date: Wed Jul 5 13:20:00 2023 +0000
Issue 5755 - Massive memory leaking on update operations (#5824)
Description: Correction of idl memory leak fix
Fix description: Initial mem leak fix (#5803) causing a SEGV during
basic search.
The inital memory leak occurs during idl_set manipulation when a filter
type LDAP_FILTER_AND, filter choice LDAP_FILTER_NOT and an empty set is
used. The complelement idl is stashed for a later intersection, but is
never freed when an empty set is used during set intersection.
The previous fix has been removed and the inital leak corrected.
relates: https://github.com/389ds/389-ds-base/pull/5803
Reviewed by: @tbordaz @progier389 (Thank you)
diff --git a/ldap/servers/slapd/back-ldbm/idl_set.c b/ldap/servers/slapd/back-ldbm/idl_set.c
index 8766354ea..e2d7b7eb2 100644
--- a/ldap/servers/slapd/back-ldbm/idl_set.c
+++ b/ldap/servers/slapd/back-ldbm/idl_set.c
@@ -168,7 +168,6 @@ idl_set_free_idls(IDListSet *idl_set)
void
idl_set_destroy(IDListSet *idl_set)
{
- idl_free(&idl_set->complement_head);
slapi_ch_free((void **)&(idl_set));
}
@@ -523,7 +522,7 @@ idl_set_intersect(IDListSet *idl_set, backend *be)
*
* NOTE: This is still not optimised yet!
*/
- if (idl_set->complement_head != NULL && result_list->b_nids > 0) {
+ if (idl_set->complement_head != NULL) {
IDList *new_result_list = NULL;
IDList *next_idl = NULL;
IDList *idl = idl_set->complement_head;
| 0 |
4ae764558fba2b175d71f319e39ddc83dcd20ea1
|
389ds/389-ds-base
|
Ticket #605 - support TLS 1.1 - Fixing "Coverity 12415 - Logically dead code"
Description: The return value from SSL_VersionRangeSet was not assigned
to "sslStatus" which was used to evaluate the API worked correctly or not.
https://fedorahosted.org/389/ticket/605
|
commit 4ae764558fba2b175d71f319e39ddc83dcd20ea1
Author: Noriko Hosoi <[email protected]>
Date: Mon Dec 9 09:38:48 2013 -0800
Ticket #605 - support TLS 1.1 - Fixing "Coverity 12415 - Logically dead code"
Description: The return value from SSL_VersionRangeSet was not assigned
to "sslStatus" which was used to evaluate the API worked correctly or not.
https://fedorahosted.org/389/ticket/605
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index addf6b110..48c3fe97f 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -1590,7 +1590,7 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
myNSSVersions.min = NSSVersionMin;
myNSSVersions.max = NSSVersionMax;
restrict_SSLVersionRange(&myNSSVersions, enableSSL3, enableTLS1);
- SSL_VersionRangeSet(pr_sock, &myNSSVersions);
+ sslStatus = SSL_VersionRangeSet(pr_sock, &myNSSVersions);
if (sslStatus == SECSuccess) {
/* Set the restricted value to the cn=encryption entry */
} else {
| 0 |
fb22b387e4376caae35121a645a5879dbac7b4fb
|
389ds/389-ds-base
|
Ticket 47722 - Using the filter file does not work
Bug Description: Using a filter file does not work correctly. rsearch fails to
to use the filters from the file.
Fix Description: There was a bug where we incorrectly freed each filter right after
we added it to the local list. This left the list empty.
https://fedorahosted.org/389/ticket/47722
Reviewed by: nhosoi(Thanks!)
|
commit fb22b387e4376caae35121a645a5879dbac7b4fb
Author: Mark Reynolds <[email protected]>
Date: Tue Dec 9 15:29:07 2014 -0500
Ticket 47722 - Using the filter file does not work
Bug Description: Using a filter file does not work correctly. rsearch fails to
to use the filters from the file.
Fix Description: There was a bug where we incorrectly freed each filter right after
we added it to the local list. This left the list empty.
https://fedorahosted.org/389/ticket/47722
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/slapd/tools/rsearch/nametable.c b/ldap/servers/slapd/tools/rsearch/nametable.c
index 9d56a3474..03a6ae1a0 100644
--- a/ldap/servers/slapd/tools/rsearch/nametable.c
+++ b/ldap/servers/slapd/tools/rsearch/nametable.c
@@ -160,7 +160,6 @@ int nt_load(NameTable *nt, const char *filename)
free(s);
break;
}
- free(s);
}
PR_Close(fd);
return nt->size;
| 0 |
2bbf4e5d30873ecf9c7d75dd7f17652ac27db9ef
|
389ds/389-ds-base
|
Resolves: #232050
Summary: Change format of DBVERSION and guardian files (comment #10)
|
commit 2bbf4e5d30873ecf9c7d75dd7f17652ac27db9ef
Author: Noriko Hosoi <[email protected]>
Date: Mon Mar 26 23:04:17 2007 +0000
Resolves: #232050
Summary: Change format of DBVERSION and guardian files (comment #10)
diff --git a/ldap/servers/slapd/back-ldbm/archive.c b/ldap/servers/slapd/back-ldbm/archive.c
index 06e2d16b9..3d9ec999f 100644
--- a/ldap/servers/slapd/back-ldbm/archive.c
+++ b/ldap/servers/slapd/back-ldbm/archive.c
@@ -71,11 +71,11 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb )
/* check the current idl format vs backup DB version */
if (idl_get_idl_new())
{
- char dbversion[LDBM_VERSION_MAXBUF];
- char dataversion[LDBM_VERSION_MAXBUF];
+ char *dbversion = NULL;
+ char *dataversion = NULL;
int value = 0;
- if (dbversion_read(li, directory, dbversion, dataversion) != 0)
+ if (dbversion_read(li, directory, &dbversion, &dataversion) != 0)
{
LDAPDebug(LDAP_DEBUG_ANY, "Warning: Unable to read dbversion "
"file in %s\n", directory, 0, 0);
@@ -85,6 +85,8 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb )
{
is_old_to_new = 1;
}
+ slapi_ch_free_string(&dbversion);
+ slapi_ch_free_string(&dataversion);
}
/* No ldbm be's exist until we process the config information. */
| 0 |
435fae3831ed2efa3ca6b55f5f985243c543877c
|
389ds/389-ds-base
|
Issue 6599 - Access JSON logging - lib389/CI/minor fixes
Description:
Update lib389 for the JSON format, added a CI test, and fixed some minor
bugs
Relates: https://github.com/389ds/389-ds-base/issues/6599
Reviewed by: jchapman, progier (Thanks!!)
|
commit 435fae3831ed2efa3ca6b55f5f985243c543877c
Author: Mark Reynolds <[email protected]>
Date: Wed Feb 12 10:26:35 2025 -0500
Issue 6599 - Access JSON logging - lib389/CI/minor fixes
Description:
Update lib389 for the JSON format, added a CI test, and fixed some minor
bugs
Relates: https://github.com/389ds/389-ds-base/issues/6599
Reviewed by: jchapman, progier (Thanks!!)
diff --git a/dirsrvtests/tests/suites/logging/access_json_logging_test.py b/dirsrvtests/tests/suites/logging/access_json_logging_test.py
new file mode 100644
index 000000000..9fd1e5bb4
--- /dev/null
+++ b/dirsrvtests/tests/suites/logging/access_json_logging_test.py
@@ -0,0 +1,569 @@
+# --- 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 os
+import time
+import ldap
+import pytest
+from lib389._constants import DEFAULT_SUFFIX, PASSWORD, LOG_ACCESS_LEVEL
+from lib389.properties import TASK_WAIT
+from lib389.topologies import topology_m2 as topo_m2
+from lib389.idm.group import Groups
+from lib389.idm.user import UserAccounts
+from lib389.dirsrv_log import DirsrvAccessJSONLog
+from lib389.index import VLVSearch, VLVIndex
+from lib389.tasks import Tasks
+from ldap.controls.vlv import VLVRequestControl
+from ldap.controls.sss import SSSRequestControl
+from ldap.controls import SimplePagedResultsControl
+from ldap.controls.sessiontrack import SessionTrackingControl, SESSION_TRACKING_CONTROL_OID
+from ldap.controls.psearch import PersistentSearchControl,EntryChangeNotificationControl
+
+
+log = logging.getLogger(__name__)
+
+MAIN_KEYS = [
+ "local_time",
+ "key",
+ "conn_id",
+ "operation",
+]
+CONN = 'conn_id'
+OP = 'op_id'
+
+
[email protected]
+def setup_test(topo_m2, request):
+ """Configure log settings"""
+ inst = topo_m2.ms["supplier1"]
+ inst.config.replace('nsslapd-accesslog-logbuffering', 'off')
+ inst.config.replace('nsslapd-accesslog-log-format', 'json')
+
+
+def get_log_event(inst, op, key=None, val=None, key2=None, val2=None):
+ """Get a specific access log event by operation and key/value
+ """
+ time.sleep(1) # give a little time to flush to disk
+
+ access_log = DirsrvAccessJSONLog(inst)
+ log_lines = access_log.readlines()
+ for line in log_lines:
+ event = access_log.parse_line(line)
+ if event is None or 'header' in event:
+ # Skip non-json or header lines
+ continue
+
+ if event['operation'] == op:
+ if key is not None and key2 is not None:
+ if key in event and key2 in event:
+ val = str(val).lower()
+ val2 = str(val2).lower()
+ if val == str(event[key]).lower() and \
+ val2 == str(event[key2]).lower():
+ return event
+
+ elif key is not None and key in event:
+ val = str(val).lower()
+ if val == str(event[key]).lower():
+ return event
+ else:
+ return event
+
+ return None
+
+
+def create_vlv_search_and_index(inst):
+ """
+ Create VlvIndex
+ """
+
+ vlv_search = VLVSearch(inst)
+ vlv_search_properties = {
+ "objectclass": ["top", "vlvSearch"],
+ "cn": "vlvSrch",
+ "vlvbase": DEFAULT_SUFFIX,
+ "vlvfilter": "(uid=*)",
+ "vlvscope": str(ldap.SCOPE_SUBTREE),
+ }
+ vlv_search.create(
+ basedn="cn=userroot,cn=ldbm database,cn=plugins,cn=config",
+ properties=vlv_search_properties
+ )
+
+ vlv_index = VLVIndex(inst)
+ vlv_index_properties = {
+ "objectclass": ["top", "vlvIndex"],
+ "cn": "vlvIdx",
+ "vlvsort": "cn",
+ }
+ vlv_index.create(
+ basedn="cn=vlvSrch,cn=userroot,cn=ldbm database,cn=plugins,cn=config",
+ properties=vlv_index_properties
+ )
+ reindex_task = Tasks(inst)
+ assert reindex_task.reindex(
+ suffix=DEFAULT_SUFFIX,
+ attrname=vlv_index.rdn,
+ args={TASK_WAIT: True},
+ ) == 0
+
+ return vlv_search, vlv_index
+
+
+def check_for_control(ctrl_list, oid, name):
+ """
+ Check if the oid and name of a control is present
+ """
+ for ctrl in ctrl_list:
+ if ctrl['oid'] == oid and ctrl['oid_name'] == name:
+ return True
+ return False
+
+
+def _run_psearch(inst, msg_id):
+ """
+ Run a search with EntryChangeNotificationControl
+ """
+ while True:
+ try:
+ _, data, _, _, _, _ = inst.result4(msgid=msg_id, all=0,
+ timeout=1.0, add_ctrls=1,
+ add_intermediates=1,
+ resp_ctrl_classes={EntryChangeNotificationControl.controlType:EntryChangeNotificationControl})
+ except ldap.TIMEOUT:
+ # There are no more results, so we timeout.
+ return
+
+
+def test_access_json_format(topo_m2, setup_test):
+ """Specify a test case purpose or name here
+
+ :id: 30ca307b-e0e0-4aa1-ae07-31a349e87a69
+ :setup: Two suppliers replication setup
+ :steps:
+ 1. Test ADD is logged correctly
+ 2. Test SEARCH is logged correctly
+ 3. Test STAT is logged correctly
+ 4. Test MODIFY is logged correctly
+ 5. Test MODRDN is logged correctly
+ 6. Test CONNECTION is logged correctly
+ 7. Test BIND is logged correctly
+ 8. Test DISCONNECT is logged correctly
+ 9. Test SESSION TRACKING is logged correctly
+ 10. Test ENTRY is logged correctly
+ 11. Test VLV is logged correctly
+ 12. Test UNINDEXED is logged correctly
+ 13. Test DELETE is logged correctly
+ 14. Test PAGED SEARCH is logged correctly
+ 15. Test PERSISTENT SEARCH is logged correctly
+ 16. Test EXTENDED OP
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ 7. Success
+ 8. Success
+ 9. Success
+ 10. Success
+ 11. Success
+ 12. Success
+ 13. Success
+ 14. Success
+ 15. Success
+ 16. Success
+ """
+
+ inst = topo_m2.ms["supplier1"]
+
+ # Need to make sure internal logging is off or the test will fail
+ inst.config.set("nsslapd-accesslog-level", "256")
+
+ #
+ # Add entry
+ #
+ log.info("Test ADD")
+ DN = "uid=test_access_log,ou=people," + DEFAULT_SUFFIX
+ users = UserAccounts(inst, DEFAULT_SUFFIX)
+ user = users.create(properties={
+ 'uid': 'test_access_log',
+ 'cn': 'test',
+ 'sn': 'user',
+ 'uidNumber': '1000',
+ 'gidNumber': '1000',
+ 'homeDirectory': '/home/test',
+ 'userPassword': PASSWORD
+ })
+
+ # Check all the expected keys are present
+ event = get_log_event(inst, "ADD", "target_dn", user.dn)
+ for key in MAIN_KEYS:
+ assert key in event and event[key] != ""
+ assert event['target_dn'].lower() == DN
+
+ # Check result
+ event = get_log_event(inst, "RESULT",
+ CONN, event['conn_id'],
+ OP, event['op_id'])
+ assert event['err'] == 0
+
+ #
+ # Compare
+ #
+ log.info("Test COMPARE")
+ inst.compare_ext_s(DN, 'sn', b'test_compare')
+ event = get_log_event(inst, "COMPARE")
+ assert event is not None
+
+ #
+ # Search entry
+ #
+ log.info("Test SEARCH")
+ user.get_attr_val("cn")
+ event = get_log_event(inst, "SEARCH", 'base_dn', user.dn)
+ for key in MAIN_KEYS:
+ assert key in event and event[key] != ""
+ assert event['base_dn'] == user.dn
+ assert event['scope'] == 0
+ assert event['filter'] == "(objectClass=*)"
+
+ # Check result
+ event = get_log_event(inst, "RESULT", CONN, event['conn_id'],
+ OP, event['op_id'])
+ assert event['err'] == 0
+
+ #
+ # Stat
+ #
+ log.info("Test STAT")
+ users = UserAccounts(inst, DEFAULT_SUFFIX)
+ users_set = []
+ for i in range(20):
+ name = 'user_%d' % i
+ last_user = users.create(properties={
+ 'uid': name,
+ 'sn': name,
+ 'cn': name,
+ 'uidNumber': '1000',
+ 'gidNumber': '1000',
+ 'homeDirectory': '/home/%s' % name,
+ 'mail': '%[email protected]' % name,
+ 'userpassword': 'pass%s' % name,
+ })
+ users_set.append(last_user)
+ inst.config.set("nsslapd-statlog-level", "1")
+ inst.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, "cn=user_*")
+ event = get_log_event(inst, "STAT")
+ if 'stat_attr' in event:
+ assert event['stat_attr'] == 'ancestorid'
+ assert event['stat_key'] == 'eq'
+ assert event['stat_key_value'] == '1'
+ assert event['stat_count'] == 39
+ inst.config.set("nsslapd-statlog-level", "0")
+
+ #
+ # Modify entry
+ #
+ log.info("Test MODIFY")
+ user.replace('sn', 'new sn')
+ event = get_log_event(inst, "ADD")
+ for key in MAIN_KEYS:
+ assert key in event and event[key] != ""
+ assert event['target_dn'].lower() == DN
+
+ # Check result
+ event = get_log_event(inst, "RESULT", CONN, event['conn_id'],
+ OP, event['op_id'])
+ assert event['err'] == 0
+
+ #
+ # ModRDN entry
+ #
+ log.info("Test MODRDN")
+ NEW_SUP = "ou=groups," + DEFAULT_SUFFIX
+ user.rename('uid=test_modrdn', newsuperior=NEW_SUP, deloldrdn=True)
+ event = get_log_event(inst, "MODRDN")
+ for key in MAIN_KEYS:
+ assert key in event and event[key] != ""
+ assert event['target_dn'].lower() == DN
+ assert event['newrdn'] == "uid=test_modrdn"
+ assert event['newsup'] == NEW_SUP
+ assert event['deleteoldrdn']
+
+ # Check result
+ event = get_log_event(inst, "RESULT", CONN, event['conn_id'],
+ OP, event['op_id'])
+ assert event['err'] == 0
+
+ #
+ # Test CONNECTION
+ #
+ log.info("Test CONNECTION")
+ user_conn = user.bind(PASSWORD)
+ event = get_log_event(inst, "CONNECTION")
+ for key in MAIN_KEYS:
+ assert key in event and event[key] != ""
+ assert event['fd']
+ assert event['slot']
+
+ #
+ # Test BIND
+ #
+ log.info("Test BIND")
+ event = get_log_event(inst, "BIND")
+ for key in MAIN_KEYS:
+ assert key in event and event[key] != ""
+ assert event['bind_dn'] == user.dn
+
+ # Check result
+ event = get_log_event(inst, "RESULT", CONN, event['conn_id'],
+ OP, event['op_id'])
+ assert event['err'] == 0
+ assert event['bind_dn'] == user.dn
+
+ #
+ # Test UNBIND and DISCONNECT
+ #
+ log.info("Test UNBIND & DISCONNECT")
+ user_conn.close()
+ event = get_log_event(inst, "UNBIND", CONN, event['conn_id'])
+ assert event
+ event = get_log_event(inst, "DISCONNECT", CONN, event['conn_id'])
+ for key in MAIN_KEYS:
+ assert key in event and event[key] != ""
+ assert event['close_reason']
+
+ #
+ # Session tracking
+ #
+ log.info("Test SESSION TRACKING")
+ SESSION_TRACKING_IDENTIFIER = "SRCH short"
+ SESSION_SOURCE_IP = '10.0.0.10'
+ SESSION_SOURCE_NAME = 'host.example.com'
+ SESSION_TRACKING_FORMAT_OID = SESSION_TRACKING_CONTROL_OID + ".1234"
+ st_ctrl = SessionTrackingControl(
+ SESSION_SOURCE_IP,
+ SESSION_SOURCE_NAME,
+ SESSION_TRACKING_FORMAT_OID,
+ SESSION_TRACKING_IDENTIFIER
+ )
+ inst.search_ext_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)',
+ serverctrls=[st_ctrl])
+ event = get_log_event(inst, "RESULT", "sid", SESSION_TRACKING_IDENTIFIER)
+ assert event is not None
+
+ #
+ # ENTRY
+ #
+ log.info("Test ENTRY")
+ inst.config.set(LOG_ACCESS_LEVEL, str(512 + 4))
+ inst.search_ext_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)')
+ event = get_log_event(inst, "ENTRY")
+ inst.config.set(LOG_ACCESS_LEVEL, "256")
+ assert event is not None
+
+ #
+ # VLV & SORT
+ #
+ log.info("Test VLV")
+ vlv_control = VLVRequestControl(criticality=True,
+ before_count="1",
+ after_count="3",
+ offset="5",
+ content_count=0,
+ greater_than_or_equal=None,
+ context_id=None)
+
+ sss_control = SSSRequestControl(criticality=True, ordering_rules=['cn'])
+ inst.search_ext_s(base=DEFAULT_SUFFIX,
+ scope=ldap.SCOPE_SUBTREE,
+ filterstr='(uid=*)',
+ serverctrls=[vlv_control, sss_control])
+ event = get_log_event(inst, "VLV")
+ assert event is not None
+
+ # VLV Request
+ assert check_for_control(event['request_controls'],
+ "2.16.840.1.113730.3.4.9",
+ "LDAP_CONTROL_VLVREQUEST")
+ assert check_for_control(event['request_controls'],
+ "1.2.840.113556.1.4.473",
+ "LDAP_CONTROL_SORTREQUEST")
+ assert check_for_control(event['response_controls'],
+ "1.2.840.113556.1.4.474",
+ "LDAP_CONTROL_SORTRESPONSE")
+ assert check_for_control(event['response_controls'],
+ "2.16.840.1.113730.3.4.10",
+ "LDAP_CONTROL_VLVRESPONSE")
+ vlvRequest = event['vlv_request']
+ assert vlvRequest['request_before_count'] == 1
+ assert vlvRequest['request_after_count'] == 3
+ assert vlvRequest['request_index'] == 4
+ assert vlvRequest['request_content_count'] == 0
+ assert vlvRequest['request_value_len'] == 0
+ assert "SORT cn" in vlvRequest['request_sort']
+
+ vlvResponse = event['vlv_response']
+ assert vlvResponse['response_target_position'] == 5
+ assert vlvResponse['response_content_count'] == 23
+ assert vlvResponse['response_result'] == 0
+
+ # VLV Result
+ event = get_log_event(inst, "RESULT", CONN, event['conn_id'],
+ OP, event['op_id'])
+ assert check_for_control(event['request_controls'],
+ "2.16.840.1.113730.3.4.9",
+ "LDAP_CONTROL_VLVREQUEST")
+ assert check_for_control(event['request_controls'],
+ "1.2.840.113556.1.4.473",
+ "LDAP_CONTROL_SORTREQUEST")
+ assert check_for_control(event['response_controls'],
+ "1.2.840.113556.1.4.474",
+ "LDAP_CONTROL_SORTRESPONSE")
+ assert check_for_control(event['response_controls'],
+ "2.16.840.1.113730.3.4.10",
+ "LDAP_CONTROL_VLVRESPONSE")
+
+ #
+ # Test unindexed search detauils (using previous vlv search)
+ #
+ log.info("Test UNINDEXED")
+ assert event['client_ip'] is not None
+ note = event['notes'][0]
+ assert note['note'] == 'U'
+ assert note['description'] == 'Partially Unindexed Filter'
+ assert note['base_dn'] == 'dc=example,dc=com'
+ assert note['filter'] == '(uid=*)'
+
+ #
+ # Delete entry
+ #
+ log.info("Test DELETE")
+ DN = "uid=test_modrdn," + NEW_SUP
+ user.delete()
+ event = get_log_event(inst, "DELETE")
+ assert event['target_dn'] == DN
+
+ # Check result
+ event = get_log_event(inst, "RESULT", CONN, event['conn_id'],
+ OP, event['op_id'])
+ assert event['err'] == 0
+
+ #
+ # Paged search
+ #
+ log.info("Test PAGED SEARCH")
+ req_ctrl = SimplePagedResultsControl(True, size=3, cookie='')
+ pages = 0
+ pctrls = []
+ search_filter = "sn=user_*"
+
+ msgid = inst.search_ext(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, search_filter,
+ ['cn'], serverctrls=[req_ctrl])
+ while True:
+ try:
+ rtype, rdata, rmsgid, rctrls = inst.result3(msgid, timeout=0.001)
+ except ldap.TIMEOUT:
+ if pages > 1:
+ inst.abandon(msgid)
+ break
+ continue
+ pages += 1
+ pctrls = [
+ c
+ for c in rctrls
+ if c.controlType == SimplePagedResultsControl.controlType
+ ]
+
+ if pctrls:
+ if pctrls[0].cookie:
+ # Copy cookie from response control to request control
+ req_ctrl.cookie = pctrls[0].cookie
+ msgid = inst.search_ext(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
+ search_filter, ['cn'],
+ serverctrls=[req_ctrl])
+ else:
+ break # No more pages available
+ else:
+ break
+
+ # Check log
+ event = get_log_event(inst, "SEARCH", "filter", "(sn=user_*)")
+ assert event is not None
+ assert check_for_control(event['request_controls'],
+ "1.2.840.113556.1.4.319",
+ "LDAP_CONTROL_PAGEDRESULTS")
+
+ event = get_log_event(inst, "RESULT", CONN, event['conn_id'],
+ OP, event['op_id'])
+ assert event is not None
+ assert 'pr_idx' in event
+ assert 'pr_cookie' in event
+ assert check_for_control(event['response_controls'],
+ "1.2.840.113556.1.4.319",
+ "LDAP_CONTROL_PAGEDRESULTS")
+ note = event['notes'][0]
+ assert note['note'] == 'P'
+ assert note['description'] == 'Paged Search'
+
+ event = get_log_event(inst, "ABANDON", CONN, "1")
+ assert event is not None
+ assert 'target_op' in event
+
+ #
+ # Persistent search
+ #
+ log.info("Test PERSISTENT SEARCH")
+ # Create the search control
+ psc = PersistentSearchControl()
+ # do a search extended with the control
+ msg_id = inst.search_ext(base=DEFAULT_SUFFIX, scope=ldap.SCOPE_SUBTREE,
+ attrlist=['*'], serverctrls=[psc])
+ # Get the result for the message id with result4
+ _run_psearch(inst, msg_id)
+ # Change an entry / add one
+ groups = Groups(inst, DEFAULT_SUFFIX)
+ groups.create(properties={'cn': 'group1',
+ 'description': 'testgroup'})
+ time.sleep(.5)
+ # Now run the result again and see what's there.
+ _run_psearch(inst, msg_id)
+
+ # Check the log
+ event = get_log_event(inst, "SEARCH", CONN, "1",
+ "psearch", "true")
+ assert event is not None
+ assert check_for_control(event['request_controls'],
+ "2.16.840.1.113730.3.4.3",
+ "LDAP_CONTROL_PERSISTENTSEARCH")
+
+ #
+ # Extended op
+ #
+ log.info("Test EXTENDED_OP")
+ event = get_log_event(inst, "EXTENDED_OP", "oid",
+ "2.16.840.1.113730.3.5.12")
+ assert event is not None
+ assert event['oid_name'] == "REPL_START_NSDS90_REPLICATION_REQUEST_OID"
+ assert event['name'] == "replication-multisupplier-extop"
+
+ event = get_log_event(inst, "EXTENDED_OP", "oid",
+ "2.16.840.1.113730.3.5.5")
+ assert event is not None
+ assert event['oid_name'] == "REPL_END_NSDS50_REPLICATION_REQUEST_OID"
+ assert event['name'] == "replication-multisupplier-extop"
+
+
+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/slapd/accesslog.c b/ldap/servers/slapd/accesslog.c
index 2de14e3cf..68022fe38 100644
--- a/ldap/servers/slapd/accesslog.c
+++ b/ldap/servers/slapd/accesslog.c
@@ -602,7 +602,7 @@ slapd_log_access_modrdn(slapd_log_pblock *logpb)
if (logpb->newsup) {
json_object_object_add(json_obj, "newsup", json_obj_add_str(logpb->newsup));
}
- json_object_object_add(json_obj, "deletoldrdn", json_object_new_boolean(logpb->deletoldrdn));
+ json_object_object_add(json_obj, "deleteoldrdn", json_object_new_boolean(logpb->deleteoldrdn));
/* Convert json object to string and log it */
msg = (char *)json_object_to_json_string_ext(json_obj, logpb->log_format);
@@ -643,6 +643,7 @@ slapd_log_access_modrdn(slapd_log_pblock *logpb)
int32_t
slapd_log_access_result(slapd_log_pblock *logpb)
{
+ Connection *conn = NULL;
int32_t rc = 0;
char *msg = NULL;
json_object *json_obj = NULL;
@@ -651,23 +652,28 @@ slapd_log_access_result(slapd_log_pblock *logpb)
return rc;
}
+ slapi_pblock_get(logpb->pb, SLAPI_CONNECTION, &conn); /* For IP addr */
+
json_object_object_add(json_obj, "tag", json_object_new_int(logpb->tag));
json_object_object_add(json_obj, "err", json_object_new_int(logpb->err));
json_object_object_add(json_obj, "nentries", json_object_new_int(logpb->nentries));
json_object_object_add(json_obj, "wtime", json_obj_add_str(logpb->wtime));
json_object_object_add(json_obj, "optime", json_obj_add_str(logpb->optime));
json_object_object_add(json_obj, "etime", json_obj_add_str(logpb->etime));
+ if (conn) {
+ json_object_object_add(json_obj, "client_ip", json_obj_add_str(conn->c_ipaddr));
+ } else {
+ json_object_object_add(json_obj, "client_ip", json_obj_add_str("Internal"));
+ }
if (logpb->csn) {
char csn_str[CSN_STRSIZE] = {0};
csn_as_string(logpb->csn, PR_FALSE, csn_str);
json_object_object_add(json_obj, "csn",
json_obj_add_str(csn_str));
}
- if (logpb->pr_idx > 0) {
+ if (logpb->pr_idx >= 0) {
json_object_object_add(json_obj, "pr_idx",
json_object_new_int(logpb->pr_idx));
- }
- if (logpb->pr_cookie != 0) {
json_object_object_add(json_obj, "pr_cookie",
json_object_new_int(logpb->pr_cookie));
}
@@ -678,17 +684,15 @@ slapd_log_access_result(slapd_log_pblock *logpb)
get_notes_info(logpb->notes, notes, details);
for (size_t i = 0; notes[i]; i++) {
+ char *filter_str = NULL;
json_object *note = json_object_new_object();
json_object_object_add(note, "note", json_obj_add_str(notes[i]));
json_object_object_add(note, "description", json_obj_add_str(details[i]));
if ((strcmp("A", notes[i]) == 0 || strcmp("U", notes[i]) == 0) && logpb->pb) {
/* Full/partial unindexed search - log more info */
- Connection *conn = NULL;
- char *filter_str;
char *base_dn;
int32_t scope = 0;
- slapi_pblock_get(logpb->pb, SLAPI_CONNECTION, &conn);
slapi_pblock_get(logpb->pb, SLAPI_TARGET_DN, &base_dn);
slapi_pblock_get(logpb->pb, SLAPI_SEARCH_STRFILTER, &filter_str);
slapi_pblock_get(logpb->pb, SLAPI_SEARCH_SCOPE, &scope);
@@ -696,9 +700,7 @@ slapd_log_access_result(slapd_log_pblock *logpb)
json_object_object_add(note, "base_dn", json_obj_add_str(base_dn));
json_object_object_add(note, "filter", json_obj_add_str(filter_str));
json_object_object_add(note, "scope", json_object_new_int(scope));
- json_object_object_add(note, "client_ip", json_obj_add_str(conn->c_ipaddr));
} else if (strcmp("F", notes[i]) == 0 && logpb->pb) {
- char *filter_str;
slapi_pblock_get(logpb->pb, SLAPI_SEARCH_STRFILTER, &filter_str);
json_object_object_add(note, "filter", json_obj_add_str(filter_str));
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index b58e593f3..f4bd62ed1 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -7238,6 +7238,8 @@ slapd_log_pblock_init(slapd_log_pblock *logpb, int32_t log_format, Slapi_PBlock
logpb->op_id = -1;
logpb->op_internal_id = -1;
logpb->op_nested_count = -1;
+ logpb->pr_cookie = -1;
+ logpb->pr_idx = -1;
logpb->curr_time = slapi_current_utc_time_hr();
if (conn) {
diff --git a/ldap/servers/slapd/modrdn.c b/ldap/servers/slapd/modrdn.c
index d8bd4f502..e9f2047a6 100644
--- a/ldap/servers/slapd/modrdn.c
+++ b/ldap/servers/slapd/modrdn.c
@@ -472,7 +472,7 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
logpb.target_dn = dn;
logpb.newrdn = newrdn;
logpb.newsup = newsuperior;
- logpb.deletoldrdn = deloldrdn ? PR_TRUE : PR_FALSE;
+ logpb.deleteoldrdn = deloldrdn ? PR_TRUE : PR_FALSE;
logpb.authzid = proxydn;
if (proxydn) {
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index bb93957c1..02afac751 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -2288,8 +2288,6 @@ log_result(Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag, int nentries
logpb.etime = etime;
logpb.notes = operation_notes;
logpb.csn = operationcsn;
- logpb.pr_idx = 0;
- logpb.pr_cookie = 0;
logpb.msg = NULL;
logpb.sid = sessionTrackingId;
logpb.tag = tag;
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index ccca06702..c3632b809 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1571,7 +1571,7 @@ typedef struct slapd_log_pblock {
/* Modrdn */
const char *newrdn;
const char *newsup;
- PRBool deletoldrdn;
+ PRBool deleteoldrdn;
/* Search */
const char *base_dn;
int32_t scope;
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index b8fd86b68..6034cb872 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -322,8 +322,8 @@ class DirSrv(SimpleLDAPObject, object):
from lib389.config import RSA
from lib389.config import Encryption
from lib389.dirsrv_log import (
- DirsrvAccessLog, DirsrvErrorLog, DirsrvAuditLog,
- DirsrvAuditJSONLog, DirsrvSecurityLog
+ DirsrvAccessLog, DirsrvAccessJSONLog, DirsrvErrorLog,
+ DirsrvAuditLog, DirsrvAuditJSONLog, DirsrvSecurityLog
)
from lib389.ldclt import Ldclt
from lib389.mappingTree import MappingTrees
@@ -368,6 +368,7 @@ class DirSrv(SimpleLDAPObject, object):
self.rsa = RSA(self)
self.encryption = Encryption(self)
self.ds_access_log = DirsrvAccessLog(self)
+ self.ds_access_json_log = DirsrvAccessJSONLog(self)
self.ds_error_log = DirsrvErrorLog(self)
self.ds_audit_log = DirsrvAuditLog(self)
self.ds_audit_json_log = DirsrvAuditJSONLog(self)
diff --git a/src/lib389/lib389/dirsrv_log.py b/src/lib389/lib389/dirsrv_log.py
index bbd2f22e9..9572a65ef 100644
--- a/src/lib389/lib389/dirsrv_log.py
+++ b/src/lib389/lib389/dirsrv_log.py
@@ -51,6 +51,8 @@ class DirsrvLog(DSLint):
self.dirsrv = dirsrv
self.log = self.dirsrv.log
self.prog_timestamp = re.compile(r'\[(?P<day>\d*)\/(?P<month>\w*)\/(?P<year>\d*):(?P<hour>\d*):(?P<minute>\d*):(?P<second>\d*)(.(?P<nanosecond>\d*))+\s(?P<tz>[\+\-]\d*)') # noqa
+ # JSON timestamp uses strftime %FT%T --> 2025-02-12T17:00:47.663123181 -0500
+ self.prog_json_timestamp = re.compile(r'(?P<year>\d*)-(?P<month>\w*)-(?P<day>\d*)T(?P<hour>\d*):(?P<minute>\d*):(?P<second>\d*)(.(?P<nanosecond>\d*))+\s(?P<tz>[\+\-]\d*)') # noqa
self.prog_datetime = re.compile(r'^(?P<timestamp>\[.*\])')
self.jsonFormat = False
@@ -145,17 +147,20 @@ class DirsrvLog(DSLint):
results.append(line)
return results
- def parse_timestamp(self, ts):
+ def parse_timestamp(self, ts, json_format=False):
"""Parse a logs timestamps and break it down into its individual parts
@param ts - The timestamp string from a log
@return - a "datetime" object
"""
- timedata = self.prog_timestamp.match(ts).groupdict()
+ if json_format:
+ timedata = self.prog_json_timestamp.match(ts).groupdict()
+ else:
+ timedata = self.prog_timestamp.match(ts).groupdict()
# Now, have to convert month to an int.
dt_str = '{YEAR}-{MONTH}-{DAY} {HOUR}-{MINUTE}-{SECOND} {TZ}'.format(
YEAR=timedata['year'],
- MONTH=MONTH_LOOKUP[timedata['month']],
+ MONTH=timedata['month'],
DAY=timedata['day'],
HOUR=timedata['hour'],
MINUTE=timedata['minute'],
@@ -168,19 +173,35 @@ class DirsrvLog(DSLint):
return dt
def get_time_in_secs(self, log_line):
- """Take the timestamp (not the date) from a DS log and convert it
- to seconds:
+ """Take the timestamp (not the date) from a DS access log and convert
+ it to seconds:
[25/May/2016:15:24:27.289341875 -0400]...
+ JSON format
+
+ 2025-02-12T17:00:47.699153015 -0500
+
@param log_line - A line of txt from a DS error/access log
@return - time in seconds
"""
total = 0
- index = log_line.index(':') + 1
- hms = log_line[index: index + 8]
- parts = hms.split(':')
+
+ try:
+ log_obj = json.loads(log_line)
+ # JSON format
+ date_str = log_obj["local_time"]
+ time_str = date_str.split('T')[1:] # splice off the date
+ hms = time_str[:8]
+ parts = hms.split(':')
+
+ except ValueError:
+ # Old format
+ index = log_line.index(':') + 1
+ hms = log_line[index: index + 8]
+ parts = hms.split(':')
+
if int(parts[0]):
total += int(parts[0]) * 3600
if int(parts[1]):
@@ -190,6 +211,118 @@ class DirsrvLog(DSLint):
return total
+class DirsrvAccessJSONLog(DirsrvLog):
+ """Class for process access logs in JSON format"""
+ def __init__(self, dirsrv):
+ """Init the class
+ @param dirsrv - A DirSrv object
+ """
+ super(DirsrvAccessJSONLog, self).__init__(dirsrv)
+ self.lpath = None
+
+ @classmethod
+ def lint_uid(cls):
+ return 'logs'
+
+ def _log_get_search_stats(self, conn, op):
+ self.lpath = self._get_log_path()
+ if self.lpath is not None:
+ with open(self.lpath, 'r') as lf:
+ for line in lf:
+ line = line.strip()
+ action = json.loads(line)
+ if 'header' in action:
+ # This is the log title, skip it
+ continue
+ if action['operation'] == "SEARCH" and \
+ action['conn_id'] == op and \
+ action['op_id'] == op:
+ return action
+ return None
+
+ def _lint_notes(self):
+ """
+ Check for notes=A (fully unindexed searches), and
+ notes=F (unknown attribute in filter)
+ """
+ for pattern, lint_report in [(".* notes=A", DSLOGNOTES0001), (".* notes=F", DSLOGNOTES0002)]:
+ lines = self.match(pattern)
+ if len(lines) > 0:
+ count = 0
+ searches = []
+ for line in lines:
+ line = line.strip()
+ action = json.loads(line)
+ if action['operation'] == 'RESULT':
+ # Looks like a valid notes=A/F
+ conn = action['conn_id']
+ op = action['op_id']
+ etime = action['etime']
+ stats = self._log_get_search_stats(conn, op)
+ if stats is not None:
+ timestamp = stats['local_time']
+ base = stats['base_dn']
+ scope = stats['scope']
+ srch_filter = stats['filter']
+ count += 1
+ if lint_report == DSLOGNOTES0001:
+ searches.append(f'\n [{count}] Unindexed Search\n'
+ f' - date: {timestamp}\n'
+ f' - conn/op: {conn}/{op}\n'
+ f' - base: {base}\n'
+ f' - scope: {scope}\n'
+ f' - filter: {srch_filter}\n'
+ f' - etime: {etime}\n')
+ else:
+ searches.append(f'\n [{count}] Invalid Attribute in Filter\n'
+ f' - date: {timestamp}\n'
+ f' - conn/op: {conn}/{op}\n'
+ f' - filter: {srch_filter}\n')
+ if len(searches) > 0:
+ report = copy.deepcopy(lint_report)
+ report['items'].append(self._get_log_path())
+ report['detail'] = report['detail'].replace('NUMBER', str(count))
+ for srch in searches:
+ report['detail'] += srch
+ report['check'] = 'logs:notes'
+ yield report
+
+ def _get_log_path(self):
+ """Return the current log file location"""
+ return self.dirsrv.ds_paths.access_log
+
+ def parse_line(self, line):
+ """
+ This knows how to break up an access log line into the specific fields.
+ @param line - A text line from an access log
+ @return - A dictionary of the log parts
+ """
+ line = line.strip()
+ try:
+ action = json.loads(line)
+ except ValueError:
+ # Old format, skip this line
+ return None
+
+ # First, pull some well known info out.
+ if self.dirsrv.verbose:
+ self.log.info("parse_line --> %s ", line)
+
+ action['datetime'] = self.parse_timestamp(action['local_time'],
+ json_format=True)
+
+ if self.dirsrv.verbose:
+ self.log.info(action)
+ return action
+
+ def parse_lines(self, lines):
+ """Parse multiple log lines
+ @param lines - a list of log lines
+ @return - A dictionary of the log parts for each line
+ """
+ return map(self.parse_line, lines)
+
+
class DirsrvAccessLog(DirsrvLog):
"""Class for process access logs"""
def __init__(self, dirsrv):
@@ -371,6 +504,9 @@ class DirsrvSecurityLog(DirsrvLog):
"""
line = line.strip()
action = json.loads(line)
+ if 'header' in action:
+ # This is the log title, return it as is
+ return action
action['datetime'] = action['date']
return action
| 0 |
52e57deb427ed84f226f0cf6ce2bcc63d8782c02
|
389ds/389-ds-base
|
Ticket 47787: Make the test case more robust
Description
Sometime the MOD (description) M2->M1 takes some time and we need to be sure it is
replicated before checking that the target entry is identical M1 vs. M2
https://fedorahosted.org/389/ticket/47787
reviewed by: Mark Reynolds (Thanks Mark !)
Platforms tested: F20
Flag Day: no
Doc impact: no
|
commit 52e57deb427ed84f226f0cf6ce2bcc63d8782c02
Author: Thierry bordaz (tbordaz) <[email protected]>
Date: Fri Sep 12 19:07:11 2014 +0200
Ticket 47787: Make the test case more robust
Description
Sometime the MOD (description) M2->M1 takes some time and we need to be sure it is
replicated before checking that the target entry is identical M1 vs. M2
https://fedorahosted.org/389/ticket/47787
reviewed by: Mark Reynolds (Thanks Mark !)
Platforms tested: F20
Flag Day: no
Doc impact: no
diff --git a/dirsrvtests/tickets/ticket47787_test.py b/dirsrvtests/tickets/ticket47787_test.py
index 81d53240a..e9fa87625 100644
--- a/dirsrvtests/tickets/ticket47787_test.py
+++ b/dirsrvtests/tickets/ticket47787_test.py
@@ -269,7 +269,16 @@ def _status_entry_both_server(topology, name=None, desc=None, debug=True):
if not name:
return
topology.master1.log.info("\n\n######################### Tombstone on M1 ######################\n")
- ent_m1 = _find_tombstone(topology.master1, SUFFIX, 'sn', name)
+ attr = 'description'
+ found = False
+ attempt = 0
+ while not found and attempt < 10:
+ ent_m1 = _find_tombstone(topology.master1, SUFFIX, 'sn', name)
+ if attr in ent_m1.getAttrs():
+ found = True
+ else:
+ time.sleep(1)
+ attempt = attempt + 1
assert ent_m1
topology.master1.log.info("\n\n######################### Tombstone on M2 ######################\n")
| 0 |
5565862a9642ffb6c4a00846e3ec7522fc4acb72
|
389ds/389-ds-base
|
Issue 5241 - UI - Add account locking missing functionality (#5251)
Description: Add a missing ability to lock and unlock Roles/Accounts to LDAP Editor.
Add Lock/Unlock button to Dropdown when choose entry in Tree and Table Views tab;
Add 'Locked' indicator with 'lock' icon beside entry DN;
Add the same functionality to Search tab. But also add Show Locking button
which enables this functionality (disabled by default). We need it because
it vastly impacts performance.
Fixes: https://github.com/389ds/389-ds-base/issues/5241
Reviewed by: @mreynolds389 (Thanks!!)
|
commit 5565862a9642ffb6c4a00846e3ec7522fc4acb72
Author: Simon Pichugin <[email protected]>
Date: Fri Apr 15 10:45:44 2022 -0700
Issue 5241 - UI - Add account locking missing functionality (#5251)
Description: Add a missing ability to lock and unlock Roles/Accounts to LDAP Editor.
Add Lock/Unlock button to Dropdown when choose entry in Tree and Table Views tab;
Add 'Locked' indicator with 'lock' icon beside entry DN;
Add the same functionality to Search tab. But also add Show Locking button
which enables this functionality (disabled by default). We need it because
it vastly impacts performance.
Fixes: https://github.com/389ds/389-ds-base/issues/5241
Reviewed by: @mreynolds389 (Thanks!!)
diff --git a/dirsrvtests/tests/suites/clu/dsidm_account_test.py b/dirsrvtests/tests/suites/clu/dsidm_account_test.py
index b1dfa9117..01711f492 100644
--- a/dirsrvtests/tests/suites/clu/dsidm_account_test.py
+++ b/dirsrvtests/tests/suites/clu/dsidm_account_test.py
@@ -81,6 +81,7 @@ def test_dsidm_account_entry_status_with_lock(topology_st, create_test_user):
args = FakeArgs()
args.dn = test_user.dn
+ args.json = False
log.info('Test dsidm account entry-status')
entry_status(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
diff --git a/src/cockpit/389-console/src/LDAPEditor.jsx b/src/cockpit/389-console/src/LDAPEditor.jsx
index 4299a00e6..4e2d62b13 100644
--- a/src/cockpit/389-console/src/LDAPEditor.jsx
+++ b/src/cockpit/389-console/src/LDAPEditor.jsx
@@ -4,22 +4,30 @@ import {
expandable
} from '@patternfly/react-table';
import {
+ AngleRightIcon,
CatalogIcon,
+ ExclamationCircleIcon,
ExclamationTriangleIcon,
- ResourcesEmptyIcon,
- AngleRightIcon,
InfoCircleIcon,
+ LockIcon,
+ ResourcesEmptyIcon,
} from '@patternfly/react-icons';
import {
Breadcrumb,
BreadcrumbItem,
+ Button,
+ Modal,
+ ModalVariant,
Spinner,
Tab,
Tabs,
TabTitleText,
Text,
TextContent,
+ TextList,
+ TextListItem,
TextVariants,
+ Tooltip,
} from "@patternfly/react-core";
import {
generateUniqueId,
@@ -97,6 +105,15 @@ export class LDAPEditor extends React.Component {
pagedRows: [],
refreshing: false,
allObjectclasses: [],
+ isConfirmModalOpen: false,
+ isTreeViewAction: false,
+ currentRowKey: -1
+ };
+
+ this.handleConfirmModalToggle = () => {
+ this.setState(({ isConfirmModalOpen }) => ({
+ isConfirmModalOpen: !isConfirmModalOpen,
+ }));
};
// Toggle currently active tab
@@ -132,6 +149,42 @@ export class LDAPEditor extends React.Component {
});
return;
}
+ if (aTarget.name === ENTRY_MENU.lockRole) {
+ this.setState({
+ entryDn: aTarget.value,
+ entryType: "role",
+ operationType: "lock",
+ isTreeViewAction: true
+ }, () => { this.handleConfirmModalToggle() });
+ return;
+ }
+ if (aTarget.name === ENTRY_MENU.lockAccount) {
+ this.setState({
+ entryDn: aTarget.value,
+ entryType: "account",
+ operationType: "lock",
+ isTreeViewAction: true
+ }, () => { this.handleConfirmModalToggle() });
+ return;
+ }
+ if (aTarget.name === ENTRY_MENU.unlockRole) {
+ this.setState({
+ entryDn: aTarget.value,
+ entryType: "role",
+ operationType: "unlock",
+ isTreeViewAction: true
+ }, () => { this.handleConfirmModalToggle() });
+ return;
+ }
+ if (aTarget.name === ENTRY_MENU.unlockAccount) {
+ this.setState({
+ entryDn: aTarget.value,
+ entryType: "account",
+ operationType: "unlock",
+ isTreeViewAction: true
+ }, () => { this.handleConfirmModalToggle() });
+ return;
+ }
const keyIndex = this.state.keyIndex + 1;
this.setState({
@@ -187,6 +240,7 @@ export class LDAPEditor extends React.Component {
this.onNavItemClick = this.onNavItemClick.bind(this);
this.handleReload = this.handleReload.bind(this);
this.getAttributes = this.getAttributes.bind(this);
+ this.handleLockUnlockEntry = this.handleLockUnlockEntry.bind(this);
}
handleReload(refresh) {
@@ -221,6 +275,61 @@ export class LDAPEditor extends React.Component {
}
}
+ handleLockUnlockEntry() {
+ const {
+ entryDn,
+ entryType,
+ operationType,
+ isTreeViewAction
+ } = this.state;
+
+ const cmd = ["dsidm", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",
+ "-b", entryDn, entryType, operationType, entryDn];
+ log_cmd("handleLockUnlockEntry", `${operationType} entry`, cmd);
+ cockpit
+ .spawn(cmd, { superuser: true, err: 'message' })
+ .done(_ => {
+ this.setState({
+ entryMenuIsOpen: !this.state.entryMenuIsOpen,
+ }, () => {
+ this.handleConfirmModalToggle();
+ if (isTreeViewAction) {
+ this.setState({
+ refreshEntryTime: Date.now(),
+ isTreeViewAction: false
+ });
+ } else {
+ this.handleReload(true);
+ }
+ });
+ })
+ .fail(err => {
+ const errMsg = JSON.parse(err);
+ console.error(
+ "handleLockUnlockEntry",
+ `${entryType} ${operationType} operation failed -`,
+ errMsg.desc
+ );
+ this.props.addNotification(
+ `${errMsg.desc.includes(`is already ${operationType === "unlock" ? "active" : "locked"}`) ? 'warning' : 'error'}`,
+ `${errMsg.desc}`
+ );
+ this.setState({
+ entryMenuIsOpen: !this.state.entryMenuIsOpen,
+ }, () => {
+ this.handleConfirmModalToggle();
+ if (isTreeViewAction) {
+ this.setState({
+ refreshEntryTime: Date.now(),
+ isTreeViewAction: false
+ });
+ } else {
+ this.handleReload(true);
+ }
+ });
+ });
+ }
+
getAttributes(callbackFunc) {
const attr_cmd = [
"dsconf",
@@ -395,6 +504,8 @@ export class LDAPEditor extends React.Component {
// TODO Test for a JPEG photo!!!
// if ( info.fullEntry.contains)
+
+ // TODO Add isActive func
let dn = info.dn;
if (info.ldapsubentry) {
dn =
@@ -411,7 +522,11 @@ export class LDAPEditor extends React.Component {
numSubCellInfo,
info.modifyTimestamp,
],
- rawdn: info.dn
+ rawdn: info.dn,
+ entryState: "",
+ isRole: info.isRole,
+ isLockable: info.isLockable,
+ ldapsubentry: info.ldapsubentry
},
{
// customRowId: info.parentId + 1,
@@ -433,6 +548,10 @@ export class LDAPEditor extends React.Component {
pagedRows: childrenRows.slice(0, 2 * this.state.perPage),
total: childrenRows.length / 2,
page: 1
+ }, () => {
+ if (this.state.currentRowKey >= 0) {
+ this.handleCollapse(null, this.state.currentRowKey, true, null);
+ }
});
}
@@ -452,24 +571,102 @@ export class LDAPEditor extends React.Component {
const firstTime = (pagedRows[rowKey + 1].cells[0].title) === this.initialChildText;
if (firstTime) {
- const baseDn = pagedRows[rowKey].rawdn; // The DN is the first element in the array.
- getBaseLevelEntryAttributes(this.props.serverId, baseDn, (entryArray) => {
- pagedRows[rowKey + 1].cells = [{
- title: (
- <>
- {entryArray.map((line) => (
- <div key={line.attribute + line.value}>
- <strong>{line.attribute}</strong>
- {line.value.toLowerCase() === ": ldapsubentry" ? <span className="ds-info-color">{line.value}</span> : line.attribute.toLowerCase() === "userpassword" ? ": ********" : line.value}
- </div>
- ))}
- </>
- )
- }];
- // Update the row.
- this.setState({
- pagedRows
+ const entryRows = [];
+ let entryStateIcon = "";
+ let isRole = false;
+ const entryDn = pagedRows[rowKey].rawdn; // The DN is the first element in the array.
+ getBaseLevelEntryAttributes(this.props.serverId, entryDn, (entryArray) => {
+ entryArray.map(line => {
+ const attr = line.attribute;
+ const val = line.value.toLowerCase() === ": ldapsubentry" ? <span className="ds-info-color">{line.value}</span> : line.attribute.toLowerCase() === "userpassword" ? ": ********" : line.value;
+
+ // <div key={line.attribute + line.value}></div>
+ entryRows.push({ attr: attr, value: val });
+
+ const myVal = line.value.substring(1).trim()
+ .toLowerCase();
+ const accountObjectclasses = ['nsaccount', 'nsperson', 'simplesecurityobject',
+ 'organization', 'person', 'account', 'organizationalunit',
+ 'netscapeserver', 'domain', 'posixaccount', 'shadowaccount',
+ 'posixgroup', 'mailrecipient', 'nsroledefinition'];
+ if (accountObjectclasses.includes(myVal)) {
+ entryStateIcon = <LockIcon className="ds-pf-blue-color" />;
+ }
+ if (myVal === 'nsroledefinition') {
+ isRole = true;
+ }
});
+ let entryState = "";
+ const cmd = ["dsidm", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",
+ "-b", entryDn, isRole ? "role" : "account", "entry-status", entryDn];
+ log_cmd("handleCollapse", "Checking if entry is activated", cmd);
+ cockpit
+ .spawn(cmd, { superuser: true, err: 'message' })
+ .done(content => {
+ if ((entryDn !== 'Root DSE') && (entryStateIcon !== "")) {
+ const status = JSON.parse(content);
+ entryState = status.info.state;
+ if (entryState === 'inactivity limit exceeded' || entryState.startsWith("probably activated or")) {
+ entryStateIcon = <ExclamationTriangleIcon className="ds-pf-yellow-color ct-icon-exclamation-triangle" />;
+ }
+ }
+ })
+ .fail(err => {
+ const errMsg = JSON.parse(err);
+ if ((entryDn !== 'Root DSE') && (entryStateIcon !== "") && !(errMsg.desc.includes("Root suffix can't be locked or unlocked"))) {
+ console.error(
+ "handleCollapse",
+ `${isRole ? "role" : "account"} account entry-status operation failed`,
+ errMsg.desc
+ );
+ entryState = "error: please, check browser logs";
+ entryStateIcon = <ExclamationCircleIcon className="ds-pf-red-color ct-exclamation-circle" />;
+ }
+ })
+ .finally(() => {
+ let entryStateIconFinal = "";
+ if ((entryState !== "") && (entryStateIcon !== "") && (entryState !== "activated")) {
+ entryStateIconFinal =
+ <Tooltip
+ position="bottom"
+ content={
+ <div className="ds-info-icon">
+ {entryState}
+ </div>
+ }
+ >
+ <a className="ds-font-size-md">{entryStateIcon}</a>
+ </Tooltip>;
+ }
+ pagedRows[rowKey].entryState = entryState;
+ pagedRows[rowKey + 1].cells = [{
+ title: (
+ <>
+ {entryRows.map((line) => {
+ let attrLine = "";
+ if (line.attr === "dn") {
+ attrLine =
+ <div key={line.attr + line.value}>
+ <strong>{line.attr}</strong>{line.value} {entryStateIconFinal}
+ </div>;
+ } else {
+ attrLine =
+ <div key={line.attr + line.value}>
+ <strong>{line.attr}</strong>{line.value}
+ </div>;
+ }
+ return attrLine;
+ }
+ )}
+ </>
+ )
+ }];
+ // Update the rows.
+ this.setState({
+ pagedRows,
+ currentRowKey: -1
+ });
+ });
});
}
}
@@ -521,7 +718,8 @@ export class LDAPEditor extends React.Component {
],
rawdn: info.dn,
customRowId: info.parentId,
- isEmptySuffix: isEmptySuffix
+ isEmptySuffix: isEmptySuffix,
+ entryState: ""
},
{
customRowId: info.parentId + 1,
@@ -708,6 +906,55 @@ export class LDAPEditor extends React.Component {
}
}];
}
+
+ let lockingDropdown = [];
+ if (rowData.isLockable) {
+ if (rowData.entryState !== "" && rowData.entryState !== "activated") {
+ if (rowData.entryState.includes("probably activated") || rowData.entryState.includes("indirectly locked")) {
+ lockingDropdown = [{
+ title: 'Lock ...',
+ onClick:
+ () => {
+ const entryType = rowData.isRole ? "role" : "account";
+ this.setState({
+ entryDn: rowData.rawdn,
+ entryType: entryType,
+ operationType: "lock",
+ currentRowKey: rowData.secretTableRowKeyId
+ }, () => { this.handleConfirmModalToggle() });
+ }
+ }];
+ } else {
+ lockingDropdown = [{
+ title: 'Unlock ...',
+ onClick:
+ () => {
+ const entryType = rowData.isRole ? "role" : "account";
+ this.setState({
+ entryDn: rowData.rawdn,
+ entryType: entryType,
+ operationType: "unlock",
+ currentRowKey: rowData.secretTableRowKeyId
+ }, () => { this.handleConfirmModalToggle() });
+ }
+ }];
+ }
+ } else if (rowData.entryState === "activated") {
+ lockingDropdown = [{
+ title: 'Lock ...',
+ onClick:
+ () => {
+ const entryType = rowData.isRole ? "role" : "account";
+ this.setState({
+ entryDn: rowData.rawdn,
+ entryType: entryType,
+ operationType: "lock",
+ currentRowKey: rowData.secretTableRowKeyId
+ }, () => { this.handleConfirmModalToggle() });
+ }
+ }];
+ }
+ }
const keyIndex = this.state.keyIndex + 1;
const updateActions =
[{
@@ -760,6 +1007,7 @@ export class LDAPEditor extends React.Component {
});
}
},
+ ...lockingDropdown,
{
title: 'ACIs ...',
onClick:
@@ -786,21 +1034,6 @@ export class LDAPEditor extends React.Component {
});
}
},
- /*
- {
- title: 'Roles ...',
- isDisabled: true,
- onClick: (event, rowId, rowData, extra) => {
- // TODO
- console.log(`clicked on Third action, on row ${rowId}`);
- console.log('extra = ' + extra);
- }
- },
- {
- title: 'Smart Referrals ...',
- isDisabled: true
- },
- */
{
isSeparator: true
},
@@ -960,13 +1193,59 @@ export class LDAPEditor extends React.Component {
/>
</Tab>
</Tabs>
- { this.state.showEmptySuffixModal &&
+ {this.state.showEmptySuffixModal &&
<CreateRootSuffix
showEmptySuffixModal={this.state.showEmptySuffixModal}
handleEmptySuffixToggle={this.onHandleEmptySuffixToggle}
suffixDn={this.state.emptyDN}
editorLdapServer={this.props.serverId}
/>}
+ <Modal
+ // TODO: Fix confirmation modal formatting and size; add operation to the tables
+ variant={ModalVariant.medium}
+ title={
+ `Are you sure you want to ${this.state.operationType} the ${this.state.entryType}?`
+ }
+ isOpen={this.state.isConfirmModalOpen}
+ onClose={this.handleConfirmModalToggle}
+ actions={[
+ <Button key="confirm" variant="primary" onClick={this.handleLockUnlockEntry}>
+ Confirm
+ </Button>,
+ <Button key="cancel" variant="link" onClick={this.handleConfirmModalToggle}>
+ Cancel
+ </Button>
+ ]}
+ >
+ <TextContent className="ds-margin-top ds-hide-vertical-scrollbar">
+ <Text>
+ {this.state.entryType === "account"
+ ? `It will ${this.state.operationType === "lock" ? "add" : "remove"} nsAccountLock attribute
+ ${this.state.operationType === "lock" ? "to" : "from"} the entry - ${this.state.entryDn}.`
+ : `This operation will make sure that these five entries are created at the entry's root suffix (if not, they will be created):`}
+ </Text>
+ {this.state.entryType === "role" &&
+ <>
+ <TextList>
+ <TextListItem>
+ cn=nsManagedDisabledRole
+ </TextListItem>
+ <TextListItem>
+ cn=nsDisabledRole
+ </TextListItem>
+ <TextListItem>
+ cn=nsAccountInactivationTmp (with a child)
+ </TextListItem>
+ <TextListItem>
+ cn=nsAccountInactivation_cos
+ </TextListItem>
+ </TextList>
+ <Text>
+ {`The entry - ${this.state.entryDn} - will be ${this.state.operationType === "lock" ? "added to" : "removed from"} nsRoleDN attribute in cn=nsDisabledRole entry in the root suffix.`}
+ </Text>
+ </>}
+ </TextContent>
+ </Modal>
</>
);
}
diff --git a/src/cockpit/389-console/src/css/ds.css b/src/cockpit/389-console/src/css/ds.css
index bf1913a10..004b64484 100644
--- a/src/cockpit/389-console/src/css/ds.css
+++ b/src/cockpit/389-console/src/css/ds.css
@@ -76,6 +76,18 @@ td {
margin-top: 20px;
}
+.ds-pf-red-color {
+ color: #f54f42 !important;
+}
+
+.ds-pf-blue-color {
+ color: #39a5dc !important;
+}
+
+.ds-pf-yellow-color {
+ color: #f0ab00 !important;
+}
+
.ds-editor-tree {
max-height: 70vh;
overflow: auto;
@@ -270,6 +282,10 @@ textarea {
overflow-y:auto;
}
+.ds-hide-vertical-scrollbar {
+ overflow-y: hidden !important;
+}
+
.ds-indent {
margin-left: 15px !important;
margin-right: 15px !important;
diff --git a/src/cockpit/389-console/src/lib/ldap_editor/lib/constants.jsx b/src/cockpit/389-console/src/lib/ldap_editor/lib/constants.jsx
index d320bc3b5..6739dff86 100644
--- a/src/cockpit/389-console/src/lib/ldap_editor/lib/constants.jsx
+++ b/src/cockpit/389-console/src/lib/ldap_editor/lib/constants.jsx
@@ -6,6 +6,10 @@ export const ENTRY_MENU = {
edit: 'edit',
new: 'new',
rename: 'rename',
+ lockRole: 'lockRole',
+ lockAccount: 'lockAccount',
+ unlockRole: 'unlockRole',
+ unlockAccount: 'unlockAccount',
acis: 'acis',
cos: 'cos',
delete: 'delete',
diff --git a/src/cockpit/389-console/src/lib/ldap_editor/lib/utils.jsx b/src/cockpit/389-console/src/lib/ldap_editor/lib/utils.jsx
index b9c08b9c0..e96eef36b 100644
--- a/src/cockpit/389-console/src/lib/ldap_editor/lib/utils.jsx
+++ b/src/cockpit/389-console/src/lib/ldap_editor/lib/utils.jsx
@@ -275,7 +275,13 @@ export function getSearchEntries (params, resultCallback) {
}
const lines = searchResult.split('\n');
let ldapsubentry = false;
+ let isRole = false;
+ let isLockable = false;
lines.map(currentLine => {
+ const accountObjectclasses = ['nsaccount', 'nsperson', 'simplesecurityobject',
+ 'organization', 'person', 'account', 'organizationalunit',
+ 'netscapeserver', 'domain', 'posixaccount', 'shadowaccount',
+ 'posixgroup', 'mailrecipient', 'nsroledefinition'];
if (isAttributeLine(currentLine, 'dn:')) {
// Convert base64-encoded DNs
const pos = currentLine.indexOf(':');
@@ -285,20 +291,32 @@ export function getSearchEntries (params, resultCallback) {
dn = currentLine.substring(pos + 1).trim();
}
ldapsubentry = false;
+ isRole = false;
+ isLockable = false;
} else if (isAttributeLine(currentLine, 'numSubordinates:')) {
numSubordinates = (currentLine.split(':')[1]).trim()
} else if (isAttributeLine(currentLine, 'modifyTimestamp:')) {
modifyTimestamp = (currentLine.split(':')[1]).trim()
} else if (isAttributeLine(currentLine, 'objectclass: ldapsubentry')) {
ldapsubentry = true;
+ } else if (isAttributeLine(currentLine, 'objectclass: nsroledefinition')) {
+ isRole = true;
}
+ for (const accountOC of accountObjectclasses) {
+ if (isAttributeLine(currentLine, `objectclass: ${accountOC}`)) {
+ isLockable = true;
+ }
+ }
+
if (currentLine === '' && dn !== '') {
const result = JSON.stringify(
{
dn: dn,
numSubordinates: numSubordinates,
modifyTimestamp: getModDateUTC(modifyTimestamp),
- ldapsubentry: ldapsubentry
+ ldapsubentry: ldapsubentry,
+ isRole: isRole,
+ isLockable: isLockable,
});
allEntries.push(result);
@@ -341,7 +359,7 @@ export function getBaseLevelEntryAttributes (serverId, baseDn, entryAttributesCa
`ldapsearch -LLL -o ldif-wrap=no -Y EXTERNAL -b "${baseDn}"` +
` -H ldapi://%2fvar%2frun%2fslapd-${serverId}.socket` +
` ${optionTimeLimit}` +
- ' -s base "(|(objectClass=*)(objectClass=ldapSubEntry))" nsRoleDN \\*' // +
+ ' -s base "(|(objectClass=*)(objectClass=ldapSubEntry))" nsRoleDN nsAccountLock \\*' // +
// ' | /usr/bin/head -c 150001' // Taking 1 additional character to check if the
// the entry was indeed bigger than 150K.
];
@@ -542,7 +560,13 @@ export function getOneLevelEntries (params, oneLevelCallback) {
}
const lines = searchResult.split('\n');
let ldapsubentry = false;
+ let isRole = false;
+ let isLockable = false;
lines.map(currentLine => {
+ const accountObjectclasses = ['nsaccount', 'nsperson', 'simplesecurityobject',
+ 'organization', 'person', 'account', 'organizationalunit',
+ 'netscapeserver', 'domain', 'posixaccount', 'shadowaccount',
+ 'posixgroup', 'mailrecipient', 'nsroledefinition'];
if (isAttributeLine(currentLine, 'dn:')) {
// Convert base64-encoded DNs
const pos = currentLine.indexOf(':');
@@ -552,26 +576,38 @@ export function getOneLevelEntries (params, oneLevelCallback) {
dn = currentLine.substring(pos + 1).trim();
}
ldapsubentry = false;
+ isRole = false;
+ isLockable = false;
} else if (isAttributeLine(currentLine, 'numSubordinates:')) {
numSubordinates = (currentLine.split(':')[1]).trim()
} else if (isAttributeLine(currentLine, 'modifyTimestamp:')) {
modifyTimestamp = (currentLine.split(':')[1]).trim()
} else if (isAttributeLine(currentLine, 'objectclass: ldapsubentry')) {
ldapsubentry = true;
+ } else if (isAttributeLine(currentLine, 'objectclass: nsroledefinition')) {
+ isRole = true;
}
+ for (const accountOC of accountObjectclasses) {
+ if (isAttributeLine(currentLine, `objectclass: ${accountOC}`)) {
+ isLockable = true;
+ }
+ }
+
if (currentLine === '' && dn !== '') {
const result = JSON.stringify(
{
dn: dn,
numSubordinates: numSubordinates,
modifyTimestamp: getModDateUTC(modifyTimestamp),
- ldapsubentry: ldapsubentry
+ ldapsubentry: ldapsubentry,
+ isRole: isRole,
+ isLockable: isLockable,
});
allEntries.push(result);
// Reset the variables:
dn = '';
- numSubordinates = '';
+ numSubordinates = '0';
modifyTimestamp = '';
}
});
diff --git a/src/cockpit/389-console/src/lib/ldap_editor/search.jsx b/src/cockpit/389-console/src/lib/ldap_editor/search.jsx
index fabef187e..355e1fdbb 100644
--- a/src/cockpit/389-console/src/lib/ldap_editor/search.jsx
+++ b/src/cockpit/389-console/src/lib/ldap_editor/search.jsx
@@ -1,5 +1,6 @@
import React from "react";
import {
+ Button,
Checkbox,
Grid,
GridItem,
@@ -9,31 +10,34 @@ import {
FormSelect,
FormSelectOption,
Label,
+ Modal,
+ ModalVariant,
NumberInput,
SearchInput,
Select,
SelectOption,
SelectVariant,
Spinner,
+ Switch,
Text,
TextContent,
TextInput,
+ TextList,
+ TextListItem,
TextVariants,
ToggleGroup,
ToggleGroupItem,
+ Tooltip,
ValidatedOptions
} from "@patternfly/react-core";
import {
- Table,
- TableHeader,
- TableBody,
- TableVariant,
- EditableTextCell,
expandable
} from '@patternfly/react-table';
import {
- AngleRightIcon,
- InfoCircleIcon
+ ExclamationCircleIcon,
+ ExclamationTriangleIcon,
+ InfoCircleIcon,
+ LockIcon,
} from '@patternfly/react-icons';
import PropTypes from "prop-types";
import {
@@ -41,7 +45,7 @@ import {
} from './lib/utils.jsx';
import { ENTRY_MENU } from './lib/constants.jsx';
import EditorTableView from './tableView.jsx';
-import { valid_dn } from '../tools.jsx';
+import { log_cmd, valid_dn } from '../tools.jsx';
import GenericWizard from './wizards/genericWizard.jsx';
@@ -77,6 +81,8 @@ export class SearchDatabase extends React.Component {
uniqueMember: false,
customSearchAttrs: [],
isCustomAttrOpen: false,
+ isConfirmModalOpen: false,
+ checkIfLocked: false,
// Table
columns: [
{
@@ -103,6 +109,12 @@ export class SearchDatabase extends React.Component {
this.initialResultText = 'Loading...';
+ this.handleChangeSwitch = checkIfLocked => {
+ this.setState({
+ checkIfLocked
+ });
+ };
+
this.onToggle = isExpanded => {
this.setState({
isExpanded
@@ -191,20 +203,21 @@ export class SearchDatabase extends React.Component {
}
// Do search
this.setState({
+ rows: [],
isExpanded: false,
searching: true,
+ }, () => {
+ let params = {
+ serverId: this.props.serverId,
+ searchBase: this.state.searchBase,
+ searchFilter: this.state.searchFilter,
+ searchScope: this.state.searchScope,
+ sizeLimit: this.state.sizeLimit,
+ timeLimit: this.state.timeLimit,
+ addNotification: this.props.addNotification,
+ };
+ getSearchEntries(params, this.processResults);
});
-
- let params = {
- serverId: this.props.serverId,
- searchBase: this.state.searchBase,
- searchFilter: this.state.searchFilter,
- searchScope: this.state.searchScope,
- sizeLimit: this.state.sizeLimit,
- timeLimit: this.state.timeLimit,
- addNotification: this.props.addNotification,
- };
- getSearchEntries(params, this.processResults);
};
this.handleSearchTypeClick = (isSelected, event) => {
@@ -245,6 +258,12 @@ export class SearchDatabase extends React.Component {
});
}
+ this.handleConfirmModalToggle = () => {
+ this.setState(({ isConfirmModalOpen }) => ({
+ isConfirmModalOpen: !isConfirmModalOpen,
+ }));
+ };
+
this.handleChange = this.handleChange.bind(this);
this.handleSearchChange = this.handleSearchChange.bind(this);
this.handleSuffixChange = this.handleSuffixChange.bind(this);
@@ -253,6 +272,7 @@ export class SearchDatabase extends React.Component {
this.processResults = this.processResults.bind(this);
this.handleCollapse = this.handleCollapse.bind(this);
this.actionResolver = this.actionResolver.bind(this);
+ this.handleLockUnlockEntry = this.handleLockUnlockEntry.bind(this);
}
componentDidMount() {
@@ -305,43 +325,148 @@ export class SearchDatabase extends React.Component {
// Process the entries that are direct children.
processResults = (searchResults, resObj) => {
- const resultRows = [];
+ let resultRows = [];
let rowNumber = 0;
if (searchResults) {
- searchResults.map(aChild => {
- const info = JSON.parse(aChild);
+ if (this.state.checkIfLocked) {
+ searchResults.map(aChild => {
+ const info = JSON.parse(aChild);
+ resultRows = [...this.state.rows];
+ let entryState = "";
+ let entryStateIcon = "";
- // TODO Test for a JPEG photo!!!
+ entryStateIcon = <LockIcon className="ds-pf-blue-color"/>
+ const cmd = ["dsidm", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",
+ "-b", info.dn, info.isRole ? "role" : "account", "entry-status", info.dn];
+ log_cmd("processResults", "Checking if entry is activated", cmd);
+ cockpit
+ .spawn(cmd, { superuser: true, err: 'message' })
+ .done(content => {
+ if (info.isLockable) {
+ const status = JSON.parse(content);
+ entryState = status.info.state;
+ if (entryState === 'inactivity limit exceeded' || entryState.startsWith("probably activated or")) {
+ entryStateIcon = <ExclamationTriangleIcon className="ds-pf-yellow-color ct-icon-exclamation-triangle"/>
+ }
+ }
+ })
+ .fail(err => {
+ const errMsg = JSON.parse(err);
+ if ((info.isLockable) && !(errMsg.desc.includes("Root suffix can't be locked or unlocked"))) {
+ console.error(
+ "processResults",
+ `${info.isRole ? "role" : "account"} account entry-status operation failed`,
+ errMsg.desc
+ );
+ entryState = "error: please, check browser logs";
+ entryStateIcon = <ExclamationCircleIcon className="ds-pf-red-color ct-exclamation-circle"/>
+ }
+ })
+ .finally(() => {
+ // TODO Test for a JPEG photo!!!
+ if (!info.isLockable) {
+ console.info("processResults:", `${info.dn} entry is not lockable`);
+ }
- let dn = info.dn;
- if (info.ldapsubentry) {
- dn =
- <div className="ds-info-icon">
- {info.dn} <InfoCircleIcon title="This is a hidden LDAP subentry" className="ds-info-icon" />
- </div>;
- }
+ let ldapsubentryIcon = "";
+ let entryStateIconFinal = "";
+ if (info.ldapsubentry) {
+ ldapsubentryIcon = <InfoCircleIcon title="This is a hidden LDAP subentry" className="ds-pf-blue-color ds-info-icon" />;
+ }
+ if ((entryState !== "") && (entryStateIcon !== "") && (entryState !== "activated")) {
+ entryStateIconFinal = <Tooltip
+ position="bottom"
+ content={
+ <div className="ds-info-icon">
+ {entryState}
+ </div>
+ }
+ >
+ <a className="ds-font-size-md">{entryStateIcon}</a>
+ </Tooltip>;
+ }
- resultRows.push(
- {
- isOpen: false,
- cells: [
- { title: dn },
- info.numSubordinates,
- info.modifyTimestamp,
- ],
- rawdn: info.dn
- },
- {
- parent: rowNumber,
- cells: [
- { title: this.initialResultText }
- ]
- });
+ let dn = <>
+ {info.dn} {ldapsubentryIcon} {entryStateIconFinal}
+ </>
- // Increment by 2 the row number.
- rowNumber += 2;
- });
+ resultRows.push(
+ {
+ isOpen: false,
+ cells: [
+ { title: dn },
+ info.numSubordinates,
+ info.modifyTimestamp,
+ ],
+ rawdn: info.dn,
+ isLockable: info.isLockable,
+ isRole: info.isRole,
+ entryState: entryState
+ },
+ {
+ parent: rowNumber,
+ cells: [
+ { title: this.initialResultText }
+ ]
+ });
+
+ // Increment by 2 the row number.
+ rowNumber += 2;
+ this.setState({
+ searching: false,
+ rows: resultRows,
+ // Each row is composed of a parent and its single child.
+ pagedRows: resultRows.slice(0, 2 * this.state.perPage),
+ total: resultRows.length / 2,
+ page: 1
+ });
+ });
+ });
+ } else {
+ searchResults.map(aChild => {
+ const info = JSON.parse(aChild);
+ // TODO Test for a JPEG photo!!!
+
+ // TODO Add isActive func
+ let dn = info.dn;
+ if (info.ldapsubentry) {
+ dn =
+ <div className="ds-info-icon">
+ {info.dn} <InfoCircleIcon title="This is a hidden LDAP subentry" className="ds-info-icon" />
+ </div>;
+ }
+
+ resultRows.push(
+ {
+ isOpen: false,
+ cells: [
+ { title: dn },
+ info.numSubordinates,
+ info.modifyTimestamp,
+ ],
+ rawdn: info.dn,
+ entryState: ""
+ },
+ {
+ parent: rowNumber,
+ cells: [
+ { title: this.initialResultText }
+ ]
+ });
+
+ // Increment by 2 the row number.
+ rowNumber += 2;
+ });
+ this.setState({
+ searching: false,
+ rows: resultRows,
+ // Each row is composed of a parent and its single child.
+ pagedRows: resultRows.slice(0, 2 * this.state.perPage),
+ total: resultRows.length / 2,
+ page: 1
+ });
+ }
} else {
if (resObj.status !== 0) {
this.props.addNotification(
@@ -349,16 +474,16 @@ export class SearchDatabase extends React.Component {
`Error searching the database: ${resObj.msg}`
);
}
+ this.setState({
+ searching: false,
+ rows: resultRows,
+ // Each row is composed of a parent and its single child.
+ pagedRows: resultRows.slice(0, 2 * this.state.perPage),
+ total: resultRows.length / 2,
+ page: 1
+ });
}
- this.setState({
- searching: false,
- rows: resultRows,
- // Each row is composed of a parent and its single child.
- pagedRows: resultRows.slice(0, 2 * this.state.perPage),
- total: resultRows.length / 2,
- page: 1
- });
}
handleCustomAttrChange (value) {
@@ -412,12 +537,100 @@ export class SearchDatabase extends React.Component {
}
}
+ handleLockUnlockEntry() {
+ const {
+ entryDn,
+ entryType,
+ operationType
+ } = this.state;
+
+ const cmd = ["dsidm", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",
+ "-b", entryDn, entryType, operationType, entryDn];
+ log_cmd("handleLockUnlockEntry", `${operationType} entry`, cmd);
+ cockpit
+ .spawn(cmd, { superuser: true, err: 'message' })
+ .done(_ => {
+ this.setState({
+ entryMenuIsOpen: !this.state.entryMenuIsOpen,
+ refreshEntryTime: Date.now()
+ }, () => {
+ this.onSearch();
+ this.handleConfirmModalToggle();
+ });
+
+ })
+ .fail(err => {
+ const errMsg = JSON.parse(err);
+ console.error(
+ "handleLockUnlockEntry",
+ `${entryType} ${operationType} operation failed -`,
+ errMsg.desc
+ );
+ this.props.addNotification(
+ `${errMsg.desc.includes(`is already ${operationType === "unlock" ? "active" : "locked"}`) ? 'warning' : 'error'}`,
+ `${errMsg.desc}`
+ );
+ this.setState({
+ entryMenuIsOpen: !this.state.entryMenuIsOpen,
+ refreshEntryTime: Date.now()
+ }, () => {
+ this.onSearch();
+ this.handleConfirmModalToggle();
+ });
+ });
+ }
+
actionResolver = (rowData, { rowIndex }) => {
// No action on the children.
if ((rowIndex % 2) === 1) {
return null;
}
+ let lockingDropdown = [];
+ if (rowData.entryState !== "" && !rowData.entryState.startsWith("error:")) {
+ if (rowData.entryState !== "activated") {
+ if (rowData.entryState.includes("probably activated") || rowData.entryState.includes("indirectly locked")) {
+ lockingDropdown = [{
+ title: 'Lock ...',
+ onClick:
+ () => {
+ const entryType = rowData.isRole ? "role" : "account";
+ this.setState({
+ entryDn: rowData.rawdn,
+ entryType: entryType,
+ operationType: "lock"
+ }, () => { this.handleConfirmModalToggle() });
+ }
+ }];
+ } else {
+ lockingDropdown = [{
+ title: 'Unlock ...',
+ onClick:
+ () => {
+ const entryType = rowData.isRole ? "role" : "account";
+ this.setState({
+ entryDn: rowData.rawdn,
+ entryType: entryType,
+ operationType: "unlock"
+ }, () => { this.handleConfirmModalToggle() });
+ }
+ }];
+ }
+ } else {
+ lockingDropdown = [{
+ title: 'Lock ...',
+ onClick:
+ () => {
+ const entryType = rowData.isRole ? "role" : "account";
+ this.setState({
+ entryDn: rowData.rawdn,
+ entryType: entryType,
+ operationType: "lock"
+ }, () => { this.handleConfirmModalToggle() });
+ }
+ }];
+ }
+ }
const updateActions =
[{
title: 'Search ...',
@@ -451,6 +664,7 @@ export class SearchDatabase extends React.Component {
});
}
},
+ ...lockingDropdown,
{
isSeparator: true
},
@@ -466,18 +680,18 @@ export class SearchDatabase extends React.Component {
}
},
{
- title: 'Roles ...',
- isDisabled: true,
- onClick: (event, rowId, rowData, extra) => {
- // TODO
- console.log(`clicked on Third action, on row ${rowId}`);
- console.log('extra = ' + extra);
+ title: 'Class of Service ...',
+ onClick:
+ () => {
+ this.setState({
+ wizardName: ENTRY_MENU.cos,
+ wizardEntryDn: rowData.rawdn,
+ isWizardOpen: true,
+ isTreeWizardOpen: false,
+ keyIndex,
+ });
}
},
- {
- title: 'Smart Referrals ...',
- isDisabled: true
- },
{
isSeparator: true
},
@@ -500,9 +714,6 @@ export class SearchDatabase extends React.Component {
render() {
const {
- showModal,
- closeHandler,
- logData,
suffixList
} = this.props;
@@ -712,6 +923,14 @@ export class SearchDatabase extends React.Component {
/>
</GridItem>
</Grid>
+ <Grid className="ds-margin-left ds-margin-top" title="Check if the search result entries are locked, and add Lock/Unlock options to the dropdown. This setting vastly impacts the search's performance. Use only when needed.">
+ <GridItem span={2} className="ds-label">
+ Show Locking
+ </GridItem>
+ <GridItem span={10}>
+ <Switch id="no-label-switch-on" aria-label="Message when on" isChecked={this.state.checkIfLocked} onChange={this.handleChangeSwitch} />
+ </GridItem>
+ </Grid>
<div hidden={this.state.searchType == "Search Filter"}>
<Grid
className="ds-margin-left ds-margin-top"
@@ -899,6 +1118,52 @@ export class SearchDatabase extends React.Component {
/>
</div>
</div>
+ <Modal
+ // TODO: Fix confirmation modal formatting and size; add operation to the tables
+ variant={ModalVariant.medium}
+ title={
+ `Are you sure you want to ${this.state.operationType} the ${this.state.entryType}?`
+ }
+ isOpen={this.state.isConfirmModalOpen}
+ onClose={this.handleConfirmModalToggle}
+ actions={[
+ <Button key="confirm" variant="primary" onClick={this.handleLockUnlockEntry}>
+ Confirm
+ </Button>,
+ <Button key="cancel" variant="link" onClick={this.handleConfirmModalToggle}>
+ Cancel
+ </Button>
+ ]}
+ >
+ <TextContent className="ds-margin-top">
+ <Text>
+ {this.state.entryType === "account"
+ ? `It will ${this.state.operationType === "lock" ? "add" : "remove"} nsAccountLock attribute
+ ${this.state.operationType === "lock" ? "to" : "from"} the entry - ${this.state.entryDn}.`
+ : `This operation will make sure that these five entries are created at the entry's root suffix (if not, they will be created):`}
+ </Text>
+ {this.state.entryType === "role" &&
+ <>
+ <TextList>
+ <TextListItem>
+ cn=nsManagedDisabledRole
+ </TextListItem>
+ <TextListItem>
+ cn=nsDisabledRole
+ </TextListItem>
+ <TextListItem>
+ cn=nsAccountInactivationTmp (with a child)
+ </TextListItem>
+ <TextListItem>
+ cn=nsAccountInactivation_cos
+ </TextListItem>
+ </TextList>
+ <Text>
+ {`The entry - ${this.state.entryDn} - will be ${this.state.operationType === "lock" ? "added to" : "removed from"} nsRoleDN attribute in cn=nsDisabledRole entry in the root suffix.`}
+ </Text>
+ </>}
+ </TextContent>
+ </Modal>
</div>
);
}
diff --git a/src/cockpit/389-console/src/lib/ldap_editor/tableView.jsx b/src/cockpit/389-console/src/lib/ldap_editor/tableView.jsx
index 79cd2b117..3d74cc6ed 100644
--- a/src/cockpit/389-console/src/lib/ldap_editor/tableView.jsx
+++ b/src/cockpit/389-console/src/lib/ldap_editor/tableView.jsx
@@ -19,7 +19,6 @@ class EditorTableView extends React.Component {
render () {
const {
- instanceList,
loading
} = this.props;
diff --git a/src/cockpit/389-console/src/lib/ldap_editor/treeView.jsx b/src/cockpit/389-console/src/lib/ldap_editor/treeView.jsx
index 3858ba25f..cd28a45ff 100644
--- a/src/cockpit/389-console/src/lib/ldap_editor/treeView.jsx
+++ b/src/cockpit/389-console/src/lib/ldap_editor/treeView.jsx
@@ -11,7 +11,6 @@ import {
Grid, GridItem,
KebabToggle,
Label,
- List, ListItem, ListVariant,
Spinner,
Title,
TextContent, Text, TextVariants, TextList,
@@ -22,9 +21,11 @@ import {
ArrowRightIcon,
CatalogIcon,
CubeIcon,
- DatabaseIcon,
DomainIcon,
+ ExclamationCircleIcon,
+ ExclamationTriangleIcon,
InfoCircleIcon,
+ LockIcon,
ResourcesEmptyIcon,
SyncAltIcon,
UserIcon,
@@ -35,6 +36,7 @@ import GenericPagination from './lib/genericPagination.jsx';
import LdapNavigator from './lib/ldapNavigator.jsx';
import CreateRootSuffix from './lib/rootSuffix.jsx';
import { ENTRY_MENU } from './lib/constants.jsx';
+import { log_cmd } from "../tools.jsx";
import {
showCertificate,
b64DecodeUnicode
@@ -84,6 +86,8 @@ class EditorTreeView extends React.Component {
entryIsLoading: true,
entryIcon: null,
entryDn: '',
+ entryState: '',
+ entryStateIcon: null,
isSuffixEntry: false,
entryModTime: '',
isEmptySuffix: false,
@@ -98,6 +102,7 @@ class EditorTreeView extends React.Component {
refreshButtonTriggerTime: 0,
latestEntryRefreshTime: 0,
searching: false,
+ isRole: false
};
this.addAlert = (title, variant, key) => {
@@ -195,11 +200,13 @@ class EditorTreeView extends React.Component {
const entryRows = [];
const isEmptySuffix = treeViewItem.isEmptySuffix;
let entryIcon = treeViewItem.icon; // Only already set for special suffixes.
+ let entryStateIcon = "";
const entryDn = treeViewItem.dn === '' ? 'Root DSE' : treeViewItem.dn;
const isSuffixEntry = treeViewItem.id === "0";
const entryModTime = treeViewItem.modTime;
const fullEntry = treeViewItem.fullEntry;
const encodedValues = [];
+ let isRole = false;
fullEntry
.filter(data => (data.attribute + data.value !== '') && // Filter out empty lines
(data.attribute !== '???: ')) // and data for empty suffix(es) and in case of failure.
@@ -229,11 +236,21 @@ class EditorTreeView extends React.Component {
}
entryRows.push([{ title: <strong>{attr}</strong> }, val]);
+ const myVal = val.trim().toLowerCase();
+ const accountObjectclasses = ['nsaccount', 'nsperson', 'simplesecurityobject',
+ 'organization', 'person', 'account', 'organizationalunit',
+ 'netscapeserver', 'domain', 'posixaccount', 'shadowaccount',
+ 'posixgroup', 'mailrecipient', 'nsroledefinition'];
+ if (accountObjectclasses.includes(myVal)) {
+ entryStateIcon = <LockIcon className="ds-pf-blue-color"/>
+ }
+ if (myVal === 'nsroledefinition') {
+ isRole = true;
+ }
// TODO: Use a better logic to assign icons!
// console.log(`!entryIcon = ${!entryIcon}`);
if (!entryIcon && attrLowerCase === 'objectclass') {
// console.log(`val.trim().toLowerCase() = ${val.trim().toLowerCase()}`);
- const myVal = val.trim().toLowerCase();
if (myVal === 'inetorgperson' || myVal === 'posixaccount' || myVal === 'person') {
entryIcon = <UserIcon/>
} else if (myVal === 'organizationalunit' || myVal === 'groupofuniquenames' || myVal === 'groupofnames') {
@@ -260,151 +277,216 @@ class EditorTreeView extends React.Component {
// Update the rows of the selected entry.
const entryIsLoading = false;
+ let entryState = "";
+
+ const cmd = ["dsidm", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.editorLdapServer + ".socket",
+ "-b", entryDn, isRole ? "role" : "account", "entry-status", entryDn];
+ log_cmd("updateEntryRows", "Checking if entry is activated", cmd);
+ cockpit
+ .spawn(cmd, { superuser: true, err: 'message' })
+ .done(content => {
+ if ((entryDn !== 'Root DSE') && (entryStateIcon !== "")) {
+ const status = JSON.parse(content);
+ entryState = status.info.state;
+ if (entryState === 'inactivity limit exceeded' || entryState.startsWith("probably activated or")) {
+ entryStateIcon = <ExclamationTriangleIcon className="ds-pf-yellow-color ct-icon-exclamation-triangle"/>
+ }
+ }
+ })
+ .fail(err => {
+ const errMsg = JSON.parse(err);
+ if ((entryDn !== 'Root DSE') && (entryStateIcon !== "") && !(errMsg.desc.includes("Root suffix can't be locked or unlocked"))) {
+ console.error(
+ "updateEntryRow",
+ `${isRole ? "role" : "account"} account entry-status operation failed`,
+ errMsg.desc
+ );
+ entryState = "error: please, check browser logs";
+ entryStateIcon = <ExclamationCircleIcon className="ds-pf-red-color ct-exclamation-circle"/>
+ }
+ })
+ .finally(() => {
+ const tableModificationTime = Date.now();
+ this.setState({
+ entryRows,
+ entryDn,
+ entryState,
+ isSuffixEntry,
+ entryModTime,
+ isEmptySuffix,
+ entryIsLoading,
+ isEntryTooLarge,
+ tableModificationTime,
+ entryIcon,
+ entryStateIcon,
+ isRole
+ },
+ () => {
+ // Now decode the encoded values.
+ // A sample object stored in the variable encodedValues looks like { index: entryRows.length, line: line }
+ const finalRows = [...this.state.entryRows];
+ let numberDecoded = 0;
+ // console.log(`encodedValues.length = ${encodedValues.length}`);
+
+ encodedValues.map(myObj => {
+ const attr = myObj.line.attribute;
+ // console.log('Processing attribute = ' + attr);
+ const attrLowerCase = attr.trim().toLowerCase();
+ const encVal = myObj.line.value.substring(3); // eg ==> "jpegPhoto:: <VALUE>". Removing 2 colons and 1 space character.
+ let decodedValue = encVal; // Show the encoded value in case the decoding fails.
+
+ // See list of attribute types:
+ // https://pagure.io/389-ds-console/blob/master/f/src/com/netscape/admin/dirserv/propedit/DSPropertyModel.java
+ switch (attrLowerCase) {
+ case 'jpegphoto':
+ {
+ decodedValue =
+ <React.Fragment>
+ <img
+ src={`data:image/png;base64,${encVal}`}
+ alt={attr}
+ />
+ </React.Fragment>;
- const tableModificationTime = Date.now();
- this.setState({
- entryRows,
- entryDn,
- isSuffixEntry,
- entryModTime,
- isEmptySuffix,
- entryIsLoading,
- isEntryTooLarge,
- tableModificationTime,
- entryIcon
- },
- () => {
- // Now decode the encoded values.
- // A sample object stored in the variable encodedValues looks like { index: entryRows.length, line: line }
- const finalRows = [...this.state.entryRows];
- let numberDecoded = 0;
- // console.log(`encodedValues.length = ${encodedValues.length}`);
-
- encodedValues.map(myObj => {
- const attr = myObj.line.attribute;
- // console.log('Processing attribute = ' + attr);
- const attrLowerCase = attr.trim().toLowerCase();
- const encVal = myObj.line.value.substring(3); // eg ==> "jpegPhoto:: <VALUE>". Removing 2 colons and 1 space character.
- let decodedValue = encVal; // Show the encoded value in case the decoding fails.
-
- // See list of attribute types:
- // https://pagure.io/389-ds-console/blob/master/f/src/com/netscape/admin/dirserv/propedit/DSPropertyModel.java
- switch (attrLowerCase) {
- case 'jpegphoto':
- {
- decodedValue =
- <React.Fragment>
- <img
+ // Use the picture as an icon:
+ const myPhoto = <img
src={`data:image/png;base64,${encVal}`}
- alt={attr}
+ alt=""
+ // style={{ width: '24px', height: '24px' }}
+ style={{ width: '48px' }} // height will adjust automatically.
/>
- </React.Fragment>;
-
- // Use the picture as an icon:
- const myPhoto = <img
- src={`data:image/png;base64,${encVal}`}
- alt=""
- // style={{ width: '24px', height: '24px' }}
- style={{ width: '48px' }} // height will adjust automatically.
- />
- const newRow = [{ title: <strong>{attr}</strong> }, decodedValue];
- finalRows.splice(myObj.index, 1, newRow);
- numberDecoded++;
+ const newRow = [{ title: <strong>{attr}</strong> }, decodedValue];
+ finalRows.splice(myObj.index, 1, newRow);
+ numberDecoded++;
- this.setState({ entryIcon: myPhoto });
- break;
- }
+ this.setState({ entryIcon: myPhoto });
+ break;
+ }
- case 'usercertificate':
- case 'usercertificate;binary':
- case 'cacertificate':
- case 'cacertificate;binary':
- showCertificate(encVal,
- (result) => {
- // const dataArray = [];
- if (result.code === 'OK') {
- const timeDiff = result.timeDifference;
- const certDays = Math.ceil(Math.abs(timeDiff) / (1000 * 3600 * 24));
- const dayMsg = certDays > 1
- ? `${certDays} days`
- : `${certDays} day`;
- const diffMessage = timeDiff > 0
- ? `Certificate is valid for ${dayMsg}`
- : `Certificate is expired since ${dayMsg}`;
- const type = timeDiff < 0
- ? 'danger'
- : timeDiff < (1000 * 3600 * 24 * 30) // 30 days.
- ? 'warning'
- : 'info';
- const certItems = result.data
- .map(datum => {
- return (
- <React.Fragment key={datum.param} >
- <TextListItem component={TextListItemVariants.dt}>{datum.param}</TextListItem>
- <TextListItem component={TextListItemVariants.dd}>{datum.paramVal}</TextListItem>
- </React.Fragment>);
+ case 'usercertificate':
+ case 'usercertificate;binary':
+ case 'cacertificate':
+ case 'cacertificate;binary':
+ showCertificate(encVal,
+ (result) => {
+ // const dataArray = [];
+ if (result.code === 'OK') {
+ const timeDiff = result.timeDifference;
+ const certDays = Math.ceil(Math.abs(timeDiff) / (1000 * 3600 * 24));
+ const dayMsg = certDays > 1
+ ? `${certDays} days`
+ : `${certDays} day`;
+ const diffMessage = timeDiff > 0
+ ? `Certificate is valid for ${dayMsg}`
+ : `Certificate is expired since ${dayMsg}`;
+ const type = timeDiff < 0
+ ? 'danger'
+ : timeDiff < (1000 * 3600 * 24 * 30) // 30 days.
+ ? 'warning'
+ : 'info';
+ const certItems = result.data
+ .map(datum => {
+ return (
+ <React.Fragment key={datum.param} >
+ <TextListItem component={TextListItemVariants.dt}>{datum.param}</TextListItem>
+ <TextListItem component={TextListItemVariants.dd}>{datum.paramVal}</TextListItem>
+ </React.Fragment>);
+ });
+
+ decodedValue =
+ (<React.Fragment>
+ <div>
+ <Alert variant={type} isInline title={diffMessage} />
+ <TextContent>
+ <TextList component={TextListVariants.dl}>
+ {certItems}
+ </TextList>
+ </TextContent>
+ </div>
+ </React.Fragment>);
+
+ const newRow = [{ title: <strong>{attr}</strong> }, decodedValue];
+ finalRows.splice(myObj.index, 1, newRow);
+ numberDecoded++;
+
+ if (encodedValues.length === numberDecoded) {
+ // Caution: We need to update the entryRows here
+ // ( AFTER the decoding of the certificate is completed ).
+ // The decoding is done asynchronously in showCertificate()!
+ this.setState({
+ entryRows: finalRows,
+ tableModificationTime: Date.now()
+ });
+ }
+ }
});
- decodedValue =
- (<React.Fragment>
- <div>
- <Alert variant={type} isInline title={diffMessage} />
- <TextContent>
- <TextList component={TextListVariants.dl}>
- {certItems}
- </TextList>
- </TextContent>
- </div>
- </React.Fragment>);
-
- const newRow = [{ title: <strong>{attr}</strong> }, decodedValue];
- finalRows.splice(myObj.index, 1, newRow);
- numberDecoded++;
-
- if (encodedValues.length === numberDecoded) {
- // Caution: We need to update the entryRows here
- // ( AFTER the decoding of the certificate is completed ).
- // The decoding is done asynchronously in showCertificate()!
- this.setState({
- entryRows: finalRows,
- tableModificationTime: Date.now()
- });
- }
- }
+ break;
+ default:
+ console.log(`Got an unexpected line ==> ${myObj.line}`);
+ console.log(`Got an unexpected line attr ==> ${myObj.line.attribute}`);
+ console.log(`Got an unexpected line value ==> ${myObj.line.value}`);
+ }
+ // Update the entry table once all encoded attributes have been processed:
+ if (encodedValues.length === numberDecoded) {
+ this.setState({
+ entryRows: finalRows,
+ tableModificationTime: Date.now(),
});
+ }
+ });
- break;
- default:
- console.log(`Got an unexpected line ==> ${myObj.line}`);
- console.log(`Got an unexpected line attr ==> ${myObj.line.attribute}`);
- console.log(`Got an unexpected line value ==> ${myObj.line.value}`);
- }
- // Update the entry table once all encoded attributes have been processed:
- if (encodedValues.length === numberDecoded) {
+ // Update the refresh time.
this.setState({
- entryRows: finalRows,
- tableModificationTime: Date.now(),
+ latestEntryRefreshTime: Date.now(),
});
- }
- });
-
- // Update the refresh time.
- this.setState({
- latestEntryRefreshTime: Date.now(),
+ this.showEntryLoading(false);
+ });
});
- this.showEntryLoading(false);
- });
};
render () {
const {
- alerts, searching, isSuffixEntry,
+ alerts, searching, isSuffixEntry, isRole,
firstClickOnTree, entryColumns, entryRows, entryIcon, entryDn, entryModTime, isEmptySuffix,
- entryIsLoading, isEntryTooLarge, tableModificationTime, showEmptySuffixModal,
- newSuffixData, isTreeLoading, refreshButtonTriggerTime, latestEntryRefreshTime
+ entryIsLoading, isEntryTooLarge, tableModificationTime, showEmptySuffixModal, entryState,
+ newSuffixData, isTreeLoading, refreshButtonTriggerTime, latestEntryRefreshTime, entryStateIcon
} = this.state;
const { loading } = this.props;
+ let lockingDropdown = [];
+ if (entryState !== "" && !entryState.startsWith("error:")) {
+ if (entryState !== "activated") {
+ if (entryState.includes("probably activated") || entryState.includes("indirectly locked")) {
+ lockingDropdown = [<DropdownItem
+ key="tree-view-lock"
+ component="button"
+ name={isRole ? ENTRY_MENU.lockRole : ENTRY_MENU.lockAccount}
+ value={entryDn}
+ >
+ Lock ...
+ </DropdownItem>];
+ } else {
+ lockingDropdown = [<DropdownItem
+ key="tree-view-unlock"
+ component="button"
+ name={isRole ? ENTRY_MENU.unlockRole : ENTRY_MENU.unlockAccount}
+ value={entryDn}
+ >
+ Unlock ...
+ </DropdownItem>];
+ }
+ } else {
+ lockingDropdown = [<DropdownItem
+ key="tree-view-lock"
+ component="button"
+ name={isRole ? ENTRY_MENU.lockRole : ENTRY_MENU.lockAccount}
+ value={entryDn}
+ >
+ Lock ...
+ </DropdownItem>];
+ }
+ }
const dropdownItems = [
<DropdownItem
@@ -444,6 +526,8 @@ class EditorTreeView extends React.Component {
>
Rename ...
</DropdownItem>,
+ // Lock and Unlock buttons
+ ...lockingDropdown,
<DropdownItem
key="tree-view-acis"
component="button"
@@ -461,15 +545,6 @@ class EditorTreeView extends React.Component {
Class of Service ...
</DropdownItem>,
/*
- <DropdownItem
- isDisabled
- key="tree-view-roles"
- component="button"
- name="roles"
- value={entryDn}
- >
- Roles ...
- </DropdownItem>,
<DropdownItem
isDisabled
key="tree-view-refs"
@@ -643,7 +718,19 @@ class EditorTreeView extends React.Component {
{entryIcon}
</CardHeaderMain>
<Title headingLevel="h6" size="md">
- <span> {entryDn}</span>
+ <span> {entryDn} </span>
+ {(entryState !== "") && (entryStateIcon !== "") && (entryState !== "activated")?
+ <Tooltip
+ position="bottom"
+ content={
+ <div>
+ {entryState}
+ </div>
+ }
+ >
+ <a className="ds-font-size-md">{entryStateIcon}</a>
+ </Tooltip>
+ : ""}
</Title>
</CardHeader>
{ isEntryTooLarge &&
diff --git a/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/editLdapEntry.jsx b/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/editLdapEntry.jsx
index d38cde080..9eafb78c4 100644
--- a/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/editLdapEntry.jsx
+++ b/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/editLdapEntry.jsx
@@ -587,7 +587,7 @@ class EditLdapEntry extends React.Component {
}
}
- // If we're editing a user then add nsRoleDN attribute to the possible list
+ // If we're editing a user then add nsRoleDN and nsAccountLock attributes to the possible list
let personOC = false;
for (const existingOC of this.state.selectedObjectClasses) {
if (existingOC.cells[0].toLowerCase() === 'person' ||
@@ -596,23 +596,25 @@ class EditLdapEntry extends React.Component {
break;
}
}
- let roleDNAttr = 'nsRoleDN'
- if ((personOC && !attrList.includes(roleDNAttr))) {
- let selected = false;
- for (const existingRow of this.state.editableTableData) {
- if (existingRow.attr.toLowerCase() === roleDNAttr.toLowerCase()) {
- selected = true;
- break;
+ const additionalAttrs = ['nsRoleDN', 'nsAccountLock'];
+ for (const addAttr of additionalAttrs) {
+ if ((personOC && !attrList.includes(addAttr))) {
+ let selected = false;
+ for (const existingRow of this.state.editableTableData) {
+ if (existingRow.attr.toLowerCase() === addAttr.toLowerCase()) {
+ selected = true;
+ break;
+ }
}
- }
- attrList.push(roleDNAttr);
- rowsAttr.push({
- attributeName: roleDNAttr,
- isAttributeSelected: selected,
- selected: selected,
- cells: [roleDNAttr, '']
- });
+ attrList.push(addAttr);
+ rowsAttr.push({
+ attributeName: addAttr,
+ isAttributeSelected: selected,
+ selected: selected,
+ cells: [addAttr, '']
+ });
+ }
}
});
diff --git a/src/lib389/cli/dsidm b/src/lib389/cli/dsidm
index 3d9e2141a..0e8a42758 100755
--- a/src/lib389/cli/dsidm
+++ b/src/lib389/cli/dsidm
@@ -10,11 +10,12 @@
#
# PYTHON_ARGCOMPLETE_OK
+import json
+import sys
+import signal
import ldap
import argparse
import argcomplete
-import sys
-import signal
from lib389._constants import DSRC_HOME
from lib389.cli_idm import account as cli_account
from lib389.cli_idm import initialise as cli_init
diff --git a/src/lib389/lib389/cli_idm/account.py b/src/lib389/lib389/cli_idm/account.py
index 1dec2b5d0..ed376ac66 100644
--- a/src/lib389/lib389/cli_idm/account.py
+++ b/src/lib389/lib389/cli_idm/account.py
@@ -7,6 +7,7 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
+import json
import ldap
import math
from datetime import datetime
@@ -52,23 +53,39 @@ def rename(inst, basedn, log, args, warn=True):
_generic_rename_dn(inst, basedn, log.getChild('_generic_rename_dn'), MANY, dn, args)
-def _print_entry_status(status, dn, log):
- log.info(f'Entry DN: {dn}')
+def _print_entry_status(status, dn, log, args):
+ info_dict = {}
+ if args.json:
+ info_dict["dn"] = dn
+ else:
+ 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')})")
+ if args.json:
+ info_dict[name] = f"{int(math.fabs(value))} seconds ({inactivation_date.strftime('%Y-%m-%d %H:%M:%S')})"
+ else:
+ 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')
-
+ if args.json:
+ info_dict[name] = f"{value.strftime('%Y%m%d%H%M%SZ')} ({value.strftime('%Y-%m-%d %H:%M:%S')})"
+ else:
+ log.info(f"Entry {name}: {value.strftime('%Y%m%d%H%M%SZ')} ({value.strftime('%Y-%m-%d %H:%M:%S')})")
+ else:
+ if args.json:
+ info_dict["state"] = f'{status["state"].describe(status["role_dn"])}'
+ else:
+ log.info(f'Entry State: {status["state"].describe(status["role_dn"])}\n')
+
+ if args.json:
+ log.info(json.dumps({"type": "status", "info": info_dict}, indent=4))
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)
status = acct.status()
- _print_entry_status(status, dn, log)
+ _print_entry_status(status, dn, log, args)
def subtree_status(inst, basedn, log, args):
diff --git a/src/lib389/lib389/cli_idm/role.py b/src/lib389/lib389/cli_idm/role.py
index 0ad8267a1..ebaa8b72b 100644
--- a/src/lib389/lib389/cli_idm/role.py
+++ b/src/lib389/lib389/cli_idm/role.py
@@ -7,6 +7,7 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
+import json
import ldap
from lib389.idm.role import (
Role,
@@ -86,10 +87,20 @@ def rename(inst, basedn, log, args, warn=True):
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)
+ try:
+ role = roles.get(dn=dn)
+ except ldap.NO_SUCH_OBJECT:
+ raise ValueError("Role \"{}\" is not found or the entry is not a role.".format(dn))
+
status = role.status()
- log.info(f'Entry DN: {dn}')
- log.info(f'Entry State: {status["state"].describe(status["role_dn"])}\n')
+ info_dict = {}
+ if args.json:
+ info_dict["dn"] = dn
+ info_dict["state"] = f'{status["state"].describe(status["role_dn"])}'
+ log.info(json.dumps({"type": "status", "info": info_dict}, indent=4))
+ else:
+ 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):
diff --git a/src/lib389/lib389/cos.py b/src/lib389/lib389/cos.py
index 3f7908729..598445b25 100644
--- a/src/lib389/lib389/cos.py
+++ b/src/lib389/lib389/cos.py
@@ -78,6 +78,7 @@ class CosIndirectDefinition(DSLdapObject):
self._must_attributes = ['cn', 'cosIndirectSpecifier', 'cosattribute']
self._create_objectclasses = [
'top',
+ 'ldapsubentry',
'cosSuperDefinition',
'cosIndirectDefinition',
]
@@ -98,6 +99,8 @@ class CosIndirectDefinitions(DSLdapObjects):
def __init__(self, instance, basedn, rdn=None):
super(CosIndirectDefinitions, self).__init__(instance)
self._objectclasses = [
+ 'top',
+ 'ldapsubentry',
'cosSuperDefinition',
'cosIndirectDefinition',
]
@@ -145,6 +148,7 @@ class CosPointerDefinitions(DSLdapObjects):
def __init__(self, instance, basedn, rdn=None):
super(CosPointerDefinitions, self).__init__(instance)
self._objectclasses = [
+ 'top',
'ldapsubentry',
'cosSuperDefinition',
'cosPointerDefinition',
@@ -171,6 +175,7 @@ class CosClassicDefinition(DSLdapObject):
self._must_attributes = ['cn']
self._create_objectclasses = [
'top',
+ 'ldapsubentry',
'cossuperdefinition',
'cosClassicDefinition',
]
@@ -191,6 +196,7 @@ class CosClassicDefinitions(DSLdapObjects):
super(CosClassicDefinitions, self).__init__(instance)
self._objectclasses = [
'top',
+ 'ldapsubentry',
'cossuperdefinition',
'cosClassicDefinition',
]
diff --git a/src/lib389/lib389/idm/account.py b/src/lib389/lib389/idm/account.py
index 11477876b..4b823b662 100644
--- a/src/lib389/lib389/idm/account.py
+++ b/src/lib389/lib389/idm/account.py
@@ -25,6 +25,7 @@ from lib389.extended_operations import LdapSSOTokenRequest, LdapSSOTokenResponse
class AccountState(Enum):
ACTIVATED = "activated"
DIRECTLY_LOCKED = "directly locked through nsAccountLock"
+ # TODO: Indirectly locked - revise the UI check
INDIRECTLY_LOCKED = "indirectly locked through a Role"
INACTIVITY_LIMIT_EXCEEDED = "inactivity limit exceeded"
@@ -51,8 +52,10 @@ class Account(DSLdapObject):
def _format_status_message(self, message, create_time, modify_time, last_login_time, limit, role_dn=None):
params = {}
now = time.mktime(time.gmtime())
- params["Creation Date"] = gentime_to_datetime(create_time)
- params["Modification Date"] = gentime_to_datetime(modify_time)
+ if create_time:
+ params["Creation Date"] = gentime_to_datetime(create_time)
+ if modify_time:
+ params["Modification Date"] = gentime_to_datetime(modify_time)
params["Last Login Date"] = None
params["Time Until Inactive"] = None
params["Time Since Inactive"] = None
@@ -88,17 +91,27 @@ class Account(DSLdapObject):
# Fetch Account Policy data if its enabled
plugin = AccountPolicyPlugin(inst)
- config_dn = plugin.get_attr_val_utf8("nsslapd-pluginarg0")
+ try:
+ config_dn = plugin.get_attr_val_utf8("nsslapd-pluginarg0")
+ except IndexError:
+ self._log.debug("The bound user doesn't have rights to access Account Policy settings. Not checking.")
state_attr = ""
alt_state_attr = ""
limit = ""
spec_attr = ""
limit_attr = ""
process_account_policy = False
+ mapping_trees = MappingTrees(inst)
+ try:
+ root_suffix = mapping_trees.get_root_suffix_by_entry(self.dn)
+ if str.lower(root_suffix) == str.lower(self.dn):
+ raise ValueError("Root suffix can't be locked or unlocked via dsidm functionality.")
+ except ldap.NO_SUCH_OBJECT:
+ self._log.debug("Can't acquire root suffix from user DN. Probably - insufficient rights. Skipping this step.")
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.")
+ pass
if process_account_policy and config_dn is not None:
config = AccountPolicyConfig(inst, config_dn)
@@ -186,7 +199,7 @@ class Account(DSLdapObject):
current_status = self.status()
if current_status["state"] == AccountState.DIRECTLY_LOCKED:
- raise ValueError("Account is already active")
+ raise ValueError("Account is already locked")
self.replace('nsAccountLock', 'true')
def unlock(self):
| 0 |
d19a4f9955aa0cdf3daf1c8a5ac0f6d83bfd9a7b
|
389ds/389-ds-base
|
Issue 6715 - dsconf backend replication monitor fails if replica id starts with 0 (#6716)
* Issue 6715 - dsconf backend replication monitor fails if replica id starts with 0
lib389 fails to retrioeve the csn if the replicaid is not exactly the normalized form of a number
Typically because 010 does not match with the RUV value.
Solution: Ensure that rid get normalized before comparing them or using them in a dict
Issue: #6715
Reviewed by: @droideck, @tbordaz (Thanks!)
|
commit d19a4f9955aa0cdf3daf1c8a5ac0f6d83bfd9a7b
Author: progier389 <[email protected]>
Date: Fri Apr 4 14:44:11 2025 +0200
Issue 6715 - dsconf backend replication monitor fails if replica id starts with 0 (#6716)
* Issue 6715 - dsconf backend replication monitor fails if replica id starts with 0
lib389 fails to retrioeve the csn if the replicaid is not exactly the normalized form of a number
Typically because 010 does not match with the RUV value.
Solution: Ensure that rid get normalized before comparing them or using them in a dict
Issue: #6715
Reviewed by: @droideck, @tbordaz (Thanks!)
diff --git a/dirsrvtests/tests/suites/replication/regression_m2_test.py b/dirsrvtests/tests/suites/replication/regression_m2_test.py
index ed138013d..1a2f80522 100644
--- a/dirsrvtests/tests/suites/replication/regression_m2_test.py
+++ b/dirsrvtests/tests/suites/replication/regression_m2_test.py
@@ -12,6 +12,7 @@ import time
import logging
import ldif
import ldap
+import pprint
import pytest
import subprocess
import time
@@ -29,7 +30,10 @@ from lib389.idm.group import Groups, Group
from lib389.idm.domain import Domain
from lib389.idm.directorymanager import DirectoryManager
from lib389.idm.services import ServiceAccounts, ServiceAccount
-from lib389.replica import Replicas, ReplicationManager, ReplicaRole, BootstrapReplicationManager
+from lib389.replica import (
+ Replicas, ReplicationManager, ReplicationMonitor, ReplicaRole,
+ BootstrapReplicationManager, NormalizedRidDict
+)
from lib389.agreement import Agreements
from lib389 import pid_from_file
from lib389.dseldif import *
@@ -1144,6 +1148,129 @@ def test_bulk_import(preserve_topo_m2):
assert len(users_s1) == len(users_s2)
+def check_monitoring_status(inst):
+ creds = { 'binddn': DN_DM, 'bindpw': PW_DM }
+ repl_monitor = ReplicationMonitor(inst)
+ report_dict = repl_monitor.generate_report(lambda h,p: creds, use_json=True)
+ log.debug(f'(Monitoring status: {pprint.pformat(report_dict)}')
+
+ agmts_status = {}
+ for inst_status in report_dict.values():
+ for replica_status in inst_status:
+ suffix = replica_status['replica_root']
+ rid = replica_status['replica_id']
+ for agmt_status in replica_status['agmts_status']:
+ rag_status = agmt_status['replication-status'][0]
+ if 'Unavailable' in rag_status:
+ aname = agmt_status['agmt-name'][0]
+ url = f'{agmt_status["replica"][0]}/{suffix}'
+ assert False, f"'Unavailable' found in agreement {aname} of replica {url} : {rag_status}"
+
+ assert 'Unavailable' not in str(report_dict)
+
+
+def reinit_replica(S1, S2):
+ # Reinit replication
+ agmt = Agreements(S1).list()[0]
+ agmt.begin_reinit()
+ (done, error) = agmt.wait_reinit()
+ assert done is True
+ assert error is False
+
+ repl = ReplicationManager(DEFAULT_SUFFIX)
+ repl.wait_for_replication(S1, S2)
+ repl.wait_for_replication(S2, S1)
+
+
+def test_rid_starting_with_0(topo_m2, request):
+ """Check that replication monitoring works if replica
+ id starts with 0
+
+ :id: ed0176e6-0bf7-11f0-9846-482ae39447e5
+ :setup: 2 Supplier Instances
+ :steps:
+ 1. Initialize replication to ensure that init status is set
+ 2. Check that monitoring status does not contains 'Unavailable'
+ 3. Change replica ids to 001 and 002
+ 4. Initialize replication to ensure that init status is set
+ 5. Check that monitoring status does not contains 'Unavailable'
+ 6. Restore the replica ids to 1 and 2
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ 5. Success
+ 6. Success
+ """
+ S1 = topo_m2.ms["supplier1"]
+ S2 = topo_m2.ms["supplier2"]
+ replicas = [ Replicas(inst).get(DEFAULT_SUFFIX) for inst in topo_m2 ]
+
+ # Reinit replication (to ensure that init status is set)
+ reinit_replica(S1, S2)
+
+ # Get replication monitoring results
+ check_monitoring_status(S1)
+
+ # Change replica id
+ for replica,rid in zip(replicas, ['010', '020']):
+ replica.replace('nsDS5ReplicaId', rid)
+
+ # Restore replica id in finalizer
+ def fin():
+ for replica,rid in zip(replicas, ['1', '2']):
+ replica.replace('nsDS5ReplicaId', rid)
+ reinit_replica(S1, S2)
+
+ request.addfinalizer(fin)
+ # Reinit replication
+ reinit_replica(S1, S2)
+
+ # Get replication monitoring results
+ check_monitoring_status(S1)
+
+
+def test_normalized_rid_dict():
+ """Check that lib389.replica NormalizedRidDict class behaves as expected
+
+ :id: 0f88a29c-0fcd-11f0-b5df-482ae39447e5
+ :setup: None
+ :steps:
+ 1. Initialize a NormalizedRidDict
+ 2. Check that normalization do something
+ 3. Check that key stored in NormalizedRidDict are normalized
+ 4. Check that normalized and non normalized keys have the same value
+ :expectedresults:
+ 1. Success
+ 2. Success
+ 3. Success
+ 4. Success
+ """
+
+ sd = { '1': 'v1', '020': 'v2' }
+ nsd = { NormalizedRidDict.normalize_rid(key): val for key,val in sd.items() }
+ nkeys = list(nsd.keys())
+
+ # Initialize a NormalizedRidDict
+ nrd = NormalizedRidDict()
+ for key,val in sd.items():
+ nrd[key] = val
+
+ # Check that normalization do something
+ assert nkeys != list(sd.keys())
+
+ # Check that key stored in NormalizedRidDict are normalized
+ for key in nrd.keys():
+ assert key in nkeys
+
+ # Check that normalized and non normalized keys have the same value
+ for key,val in sd.items():
+ nkey = NormalizedRidDict.normalize_rid(key)
+ assert nrd[key] == val
+ assert nrd[nkey] == val
+
+
def test_online_reinit_may_hang(topo_with_sigkill):
"""Online reinitialization may hang when the first
entry of the DB is RUV entry instead of the suffix
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 9d12c8289..a68ecd19f 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -60,6 +60,7 @@ from lib389.utils import (
normalizeDN,
escapeDNValue,
ensure_bytes,
+ ensure_int,
ensure_str,
ensure_list_str,
format_cmd_list,
@@ -3424,7 +3425,7 @@ class DirSrv(SimpleLDAPObject, object):
# Error
consumer.close()
return None
- rid = ensure_str(replica_entries[0].getValue(REPL_ID))
+ rid = ensure_int(replica_entries[0].getValue(REPL_ID))
except:
# Error
consumer.close()
@@ -3441,7 +3442,7 @@ class DirSrv(SimpleLDAPObject, object):
return error_msg
elements = ensure_list_str(entry[0].getValues('nsds50ruv'))
for ruv in elements:
- if ('replica %s ' % rid) in ruv:
+ if ('replica %d ' % rid) in ruv:
ruv_parts = ruv.split()
if len(ruv_parts) == 5:
return ruv_parts[4]
diff --git a/src/lib389/lib389/agreement.py b/src/lib389/lib389/agreement.py
index 82421ed4b..2aa023942 100644
--- a/src/lib389/lib389/agreement.py
+++ b/src/lib389/lib389/agreement.py
@@ -161,7 +161,7 @@ class Agreement(DSLdapObject):
from lib389.replica import Replicas
replicas = Replicas(self._instance)
replica = replicas.get(suffix)
- rid = replica.get_attr_val_utf8(REPL_ID)
+ rid = int(replica.get_attr_val_utf8(REPL_ID))
# Open a connection to the consumer
consumer = DirSrv(verbose=self._instance.verbose)
@@ -191,12 +191,15 @@ class Agreement(DSLdapObject):
else:
elements = ensure_list_str(entry[0].getValues('nsds50ruv'))
for ruv in elements:
- if ('replica %s ' % rid) in ruv:
+ if ('replica %d ' % rid) in ruv:
ruv_parts = ruv.split()
if len(ruv_parts) == 5:
result_msg = ruv_parts[4]
break
except ldap.INVALID_CREDENTIALS as e:
+ self._log.debug('Failed to search for the suffix ' +
+ '({}) consumer ({}:{}) failed, error: {}'.format(
+ suffix, host, port, e))
raise(e)
except ldap.LDAPError as e:
self._log.debug('Failed to search for the suffix ' +
diff --git a/src/lib389/lib389/replica.py b/src/lib389/lib389/replica.py
index 7fd210591..42b84bff3 100644
--- a/src/lib389/lib389/replica.py
+++ b/src/lib389/lib389/replica.py
@@ -822,6 +822,26 @@ class ReplicaLegacy(object):
raise ValueError('Failed to update replica: ' + str(e))
+class NormalizedRidDict(dict):
+ """A dict whose key is a Normalized Replica ID
+ """
+
+ @staticmethod
+ def normalize_rid(rid):
+ return int(rid)
+
+ def __init__(self):
+ super().__init__()
+
+ def __getitem__(self, key):
+ nkey = NormalizedRidDict.normalize_rid(key)
+ return super().__getitem__(nkey)
+
+ def __setitem__(self, key, value):
+ nkey = NormalizedRidDict.normalize_rid(key)
+ super().__setitem__(nkey, value)
+
+
class RUV(object):
"""Represents the server in memory RUV object. The RUV contains each
update vector the server knows of, along with knowledge of CSN state of the
@@ -839,11 +859,11 @@ class RUV(object):
else:
self._log = logging.getLogger(__name__)
self._rids = []
- self._rid_url = {}
- self._rid_rawruv = {}
- self._rid_csn = {}
- self._rid_maxcsn = {}
- self._rid_modts = {}
+ self._rid_url = NormalizedRidDict()
+ self._rid_rawruv = NormalizedRidDict()
+ self._rid_csn = NormalizedRidDict()
+ self._rid_maxcsn = NormalizedRidDict()
+ self._rid_modts = NormalizedRidDict()
self._data_generation = None
self._data_generation_csn = None
# Process the array of data
@@ -935,9 +955,10 @@ class RUV(object):
:returns: str
"""
self._log.debug("Allocated rids: %s" % self._rids)
+ rids = [ int(rid) for rid in self._rids ]
for i in range(1, 65534):
self._log.debug("Testing ... %s" % i)
- if str(i) not in self._rids:
+ if i not in rids:
return str(i)
raise Exception("Unable to alloc rid!")
| 0 |
ef2424ebf0cfb52e16c47f747cd7ef456d6fdc67
|
389ds/389-ds-base
|
Ticket 47747 - Add more topology fixtures
Description: Add topology fixtures to topologies.py:
- topology_m1c1
- topology_m1h1c1
- topology_m3
https://fedorahosted.org/389/ticket/47747
Reviewed by: wibrown (Thanks!)
|
commit ef2424ebf0cfb52e16c47f747cd7ef456d6fdc67
Author: Simon Pichugin <[email protected]>
Date: Mon Dec 12 09:47:21 2016 +0100
Ticket 47747 - Add more topology fixtures
Description: Add topology fixtures to topologies.py:
- topology_m1c1
- topology_m1h1c1
- topology_m3
https://fedorahosted.org/389/ticket/47747
Reviewed by: wibrown (Thanks!)
diff --git a/src/lib389/lib389/topologies.py b/src/lib389/lib389/topologies.py
index 39cb861ef..6cd3d79eb 100644
--- a/src/lib389/lib389/topologies.py
+++ b/src/lib389/lib389/topologies.py
@@ -66,6 +66,217 @@ def topology_st(request):
return TopologyMain(standalone=standalone)
[email protected](scope="module")
+def topology_m1c1(request):
+ """Create Replication Deployment with one master and one consumer"""
+
+ # Creating master 1...
+ if DEBUGGING:
+ master1 = DirSrv(verbose=True)
+ else:
+ master1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_MASTER_1
+ args_instance[SER_PORT] = PORT_MASTER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master1.allocate(args_master)
+ instance_master1 = master1.exists()
+ if instance_master1:
+ master1.delete()
+ master1.create()
+ master1.open()
+ master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+ replicaId=REPLICAID_MASTER_1)
+
+ # Creating consumer 1...
+ if DEBUGGING:
+ consumer1 = DirSrv(verbose=True)
+ else:
+ consumer1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_CONSUMER_1
+ args_instance[SER_PORT] = PORT_CONSUMER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_CONSUMER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_consumer = args_instance.copy()
+ consumer1.allocate(args_consumer)
+ instance_consumer1 = consumer1.exists()
+ if instance_consumer1:
+ consumer1.delete()
+ consumer1.create()
+ consumer1.open()
+ consumer1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_CONSUMER,
+ replicaId=CONSUMER_REPLICAID)
+
+ def fin():
+ if DEBUGGING:
+ master1.stop()
+ consumer1.stop()
+ else:
+ master1.delete()
+ consumer1.delete()
+
+ request.addfinalizer(fin)
+
+ # Create all the agreements
+ # Creating agreement from master 1 to consumer 1
+ properties = {RA_NAME: 'meTo_{}:{}'.format(consumer1.host, str(consumer1.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m1_c1_agmt = master1.agreement.create(suffix=SUFFIX, host=consumer1.host,
+ port=consumer1.port, properties=properties)
+ if not m1_c1_agmt:
+ log.fatal("Fail to create a hub -> consumer replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(m1_c1_agmt))
+
+ # Allow the replicas to get situated with the new agreements...
+ time.sleep(5)
+
+ # Initialize all the agreements
+ master1.agreement.init(SUFFIX, HOST_CONSUMER_1, PORT_CONSUMER_1)
+ master1.waitForReplInit(m1_c1_agmt)
+
+ # Check replication is working...
+ if master1.testReplication(DEFAULT_SUFFIX, consumer1):
+ log.info('Replication is working.')
+ else:
+ log.fatal('Replication is not working.')
+ assert False
+
+ # Clear out the tmp dir
+ master1.clearTmpDir(__file__)
+
+ return TopologyMain(masters={"master1": master1, "master1_agmts": {"m1_c1": m1_c1_agmt}},
+ consumers={"consumer1": consumer1})
+
+
[email protected](scope="module")
+def topology_m1h1c1(request):
+ """Create Replication Deployment with one master, one consumer and one hub"""
+
+ # Creating master 1...
+ if DEBUGGING:
+ master1 = DirSrv(verbose=True)
+ else:
+ master1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_MASTER_1
+ args_instance[SER_PORT] = PORT_MASTER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master1.allocate(args_master)
+ instance_master1 = master1.exists()
+ if instance_master1:
+ master1.delete()
+ master1.create()
+ master1.open()
+ master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+ replicaId=REPLICAID_MASTER_1)
+
+ # Creating hub 1...
+ if DEBUGGING:
+ hub1 = DirSrv(verbose=True)
+ else:
+ hub1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_HUB_1
+ args_instance[SER_PORT] = PORT_HUB_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_HUB_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_hub = args_instance.copy()
+ hub1.allocate(args_hub)
+ instance_hub1 = hub1.exists()
+ if instance_hub1:
+ hub1.delete()
+ hub1.create()
+ hub1.open()
+ hub1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_HUB,
+ replicaId=REPLICAID_HUB_1)
+
+ # Creating consumer 1...
+ if DEBUGGING:
+ consumer1 = DirSrv(verbose=True)
+ else:
+ consumer1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_CONSUMER_1
+ args_instance[SER_PORT] = PORT_CONSUMER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_CONSUMER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_consumer = args_instance.copy()
+ consumer1.allocate(args_consumer)
+ instance_consumer1 = consumer1.exists()
+ if instance_consumer1:
+ consumer1.delete()
+ consumer1.create()
+ consumer1.open()
+ consumer1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_CONSUMER,
+ replicaId=CONSUMER_REPLICAID)
+
+ def fin():
+ if DEBUGGING:
+ master1.stop()
+ hub1.stop()
+ consumer1.stop()
+ else:
+ master1.delete()
+ hub1.delete()
+ consumer1.delete()
+
+ request.addfinalizer(fin)
+
+ # Create all the agreements
+ # Creating agreement from master 1 to hub 1
+ properties = {RA_NAME: 'meTo_{}:{}'.format(hub1.host, str(hub1.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m1_h1_agmt = master1.agreement.create(suffix=SUFFIX, host=hub1.host,
+ port=hub1.port, properties=properties)
+ if not m1_h1_agmt:
+ log.fatal("Fail to create a master -> hub replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(m1_h1_agmt))
+
+ # Creating agreement from hub 1 to consumer 1
+ properties = {RA_NAME: 'meTo_{}:{}'.format(consumer1.host, str(consumer1.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ h1_c1_agmt = hub1.agreement.create(suffix=SUFFIX, host=consumer1.host,
+ port=consumer1.port, properties=properties)
+ if not h1_c1_agmt:
+ log.fatal("Fail to create a hub -> consumer replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(h1_c1_agmt))
+
+ # Allow the replicas to get situated with the new agreements...
+ time.sleep(5)
+
+ # Initialize all the agreements
+ master1.agreement.init(SUFFIX, HOST_HUB_1, PORT_HUB_1)
+ master1.waitForReplInit(m1_h1_agmt)
+ hub1.agreement.init(SUFFIX, HOST_CONSUMER_1, PORT_CONSUMER_1)
+ hub1.waitForReplInit(h1_c1_agmt)
+
+ # Check replication is working...
+ if master1.testReplication(DEFAULT_SUFFIX, consumer1):
+ log.info('Replication is working.')
+ else:
+ log.fatal('Replication is not working.')
+ assert False
+
+ # Clear out the tmp dir
+ master1.clearTmpDir(__file__)
+
+ return TopologyMain(masters={"master1": master1, "master1_agmts": {"m1_h1": m1_h1_agmt}},
+ hubs={"hub1": hub1, "hub1_agmts": {"h1_c1": h1_c1_agmt}},
+ consumers={"consumer1": consumer1})
+
+
@pytest.fixture(scope="module")
def topology_m2(request):
"""Create Replication Deployment with two masters"""
@@ -133,7 +344,7 @@ def topology_m2(request):
log.debug("{} created".format(m1_m2_agmt))
# Creating agreement from master 2 to master 1
- properties = {RA_NAME: 'meTo_' + master1.host + ':' + str(master1.port),
+ properties = {RA_NAME: 'meTo_{}:{}'.format(master1.host, str(master1.port)),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
@@ -166,6 +377,185 @@ def topology_m2(request):
"master2": master2, "master2_agmts": {"m2_m1": m2_m1_agmt}})
[email protected](scope="module")
+def topology_m3(request):
+ """Create Replication Deployment with three masters"""
+
+ # Creating master 1...
+ if DEBUGGING:
+ master1 = DirSrv(verbose=True)
+ else:
+ master1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_MASTER_1
+ args_instance[SER_PORT] = PORT_MASTER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master1.allocate(args_master)
+ instance_master1 = master1.exists()
+ if instance_master1:
+ master1.delete()
+ master1.create()
+ master1.open()
+ master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+ replicaId=REPLICAID_MASTER_1)
+
+ # Creating master 2...
+ if DEBUGGING:
+ master2 = DirSrv(verbose=True)
+ else:
+ master2 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_MASTER_2
+ args_instance[SER_PORT] = PORT_MASTER_2
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master2.allocate(args_master)
+ instance_master2 = master2.exists()
+ if instance_master2:
+ master2.delete()
+ master2.create()
+ master2.open()
+ master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+ replicaId=REPLICAID_MASTER_2)
+
+ # Creating master 3...
+ if DEBUGGING:
+ master3 = DirSrv(verbose=True)
+ else:
+ master3 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_MASTER_3
+ args_instance[SER_PORT] = PORT_MASTER_3
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_3
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master3.allocate(args_master)
+ instance_master3 = master3.exists()
+ if instance_master3:
+ master3.delete()
+ master3.create()
+ master3.open()
+ master3.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+ replicaId=REPLICAID_MASTER_3)
+
+ def fin():
+ if DEBUGGING:
+ master1.stop()
+ master2.stop()
+ master3.stop()
+ else:
+ master1.delete()
+ master2.delete()
+ master3.delete()
+
+ request.addfinalizer(fin)
+
+ # Create all the agreements
+ # Creating agreement from master 1 to master 2
+ properties = {RA_NAME: 'meTo_{}:{}'.format(master2.host, str(master2.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m1_m2_agmt = master1.agreement.create(suffix=SUFFIX, host=master2.host,
+ port=master2.port, properties=properties)
+ if not m1_m2_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(m1_m2_agmt))
+
+ # Creating agreement from master 1 to master 3
+ properties = {RA_NAME: 'meTo_{}:{}'.format(master3.host, str(master3.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m1_m3_agmt = master1.agreement.create(suffix=SUFFIX, host=master3.host,
+ port=master3.port, properties=properties)
+ if not m1_m3_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(m1_m3_agmt))
+
+ # Creating agreement from master 2 to master 1
+ properties = {RA_NAME: 'meTo_{}:{}'.format(master1.host, str(master1.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m2_m1_agmt = master2.agreement.create(suffix=SUFFIX, host=master1.host,
+ port=master1.port, properties=properties)
+ if not m2_m1_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(m2_m1_agmt))
+
+ # Creating agreement from master 2 to master 3
+ properties = {RA_NAME: 'meTo_{}:{}'.format(master3.host, str(master3.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m2_m3_agmt = master2.agreement.create(suffix=SUFFIX, host=master3.host,
+ port=master3.port, properties=properties)
+ if not m2_m3_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(m2_m3_agmt))
+
+ # Creating agreement from master 3 to master 1
+ properties = {RA_NAME: 'meTo_{}:{}'.format(master1.host, str(master1.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m3_m1_agmt = master3.agreement.create(suffix=SUFFIX, host=master1.host,
+ port=master1.port, properties=properties)
+ if not m3_m1_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(m3_m1_agmt))
+
+ # Creating agreement from master 3 to master 2
+ properties = {RA_NAME: 'meTo_{}:{}'.format(master2.host, str(master2.port)),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m3_m2_agmt = master3.agreement.create(suffix=SUFFIX, host=master2.host,
+ port=master2.port, properties=properties)
+ if not m3_m2_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("{} created".format(m3_m2_agmt))
+
+ # Allow the replicas to get situated with the new agreements...
+ time.sleep(5)
+
+ # Initialize all the agreements
+ master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
+ master1.waitForReplInit(m1_m2_agmt)
+ master1.agreement.init(SUFFIX, HOST_MASTER_3, PORT_MASTER_3)
+ master1.waitForReplInit(m1_m3_agmt)
+
+ # Check replication is working...
+ if master1.testReplication(DEFAULT_SUFFIX, master2):
+ log.info('Replication is working.')
+ else:
+ log.fatal('Replication is not working.')
+ assert False
+
+ # Clear out the tmp dir
+ master1.clearTmpDir(__file__)
+
+ return TopologyMain(masters={"master1": master1, "master1_agmts": {"m1_m2": m1_m2_agmt,
+ "m1_m3": m1_m3_agmt},
+ "master2": master2, "master2_agmts": {"m2_m1": m2_m1_agmt,
+ "m2_m3": m2_m3_agmt},
+ "master3": master3, "master3_agmts": {"m3_m1": m3_m1_agmt,
+ "m3_m2": m3_m2_agmt}})
+
+
@pytest.fixture(scope="module")
def topology_m4(request):
"""Create Replication Deployment with four masters"""
@@ -272,7 +662,7 @@ def topology_m4(request):
if not m1_m2_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m1_m2_agmt)
+ log.debug("{} created".format(m1_m2_agmt))
# Creating agreement from master 1 to master 3
properties = {RA_NAME: 'meTo_' + master3.host + ':' + str(master3.port),
@@ -285,7 +675,7 @@ def topology_m4(request):
if not m1_m3_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m1_m3_agmt)
+ log.debug("{} created".format(m1_m3_agmt))
# Creating agreement from master 1 to master 4
properties = {RA_NAME: 'meTo_' + master4.host + ':' + str(master4.port),
@@ -298,7 +688,7 @@ def topology_m4(request):
if not m1_m4_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m1_m4_agmt)
+ log.debug("{} created".format(m1_m4_agmt))
# Creating agreement from master 2 to master 1
properties = {RA_NAME: 'meTo_' + master1.host + ':' + str(master1.port),
@@ -311,7 +701,7 @@ def topology_m4(request):
if not m2_m1_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m2_m1_agmt)
+ log.debug("{} created".format(m2_m1_agmt))
# Creating agreement from master 2 to master 3
properties = {RA_NAME: 'meTo_' + master3.host + ':' + str(master3.port),
@@ -324,7 +714,7 @@ def topology_m4(request):
if not m2_m3_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m2_m3_agmt)
+ log.debug("{} created".format(m2_m3_agmt))
# Creating agreement from master 2 to master 4
properties = {RA_NAME: 'meTo_' + master4.host + ':' + str(master4.port),
@@ -337,7 +727,7 @@ def topology_m4(request):
if not m2_m4_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m2_m4_agmt)
+ log.debug("{} created".format(m2_m4_agmt))
# Creating agreement from master 3 to master 1
properties = {RA_NAME: 'meTo_' + master1.host + ':' + str(master1.port),
@@ -350,7 +740,7 @@ def topology_m4(request):
if not m3_m1_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m3_m1_agmt)
+ log.debug("{} created".format(m3_m1_agmt))
# Creating agreement from master 3 to master 2
properties = {RA_NAME: 'meTo_' + master2.host + ':' + str(master2.port),
@@ -363,7 +753,7 @@ def topology_m4(request):
if not m3_m2_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m3_m2_agmt)
+ log.debug("{} created".format(m3_m2_agmt))
# Creating agreement from master 3 to master 4
properties = {RA_NAME: 'meTo_' + master4.host + ':' + str(master4.port),
@@ -376,7 +766,7 @@ def topology_m4(request):
if not m3_m4_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m3_m4_agmt)
+ log.debug("{} created".format(m3_m4_agmt))
# Creating agreement from master 4 to master 1
properties = {RA_NAME: 'meTo_' + master1.host + ':' + str(master1.port),
@@ -389,7 +779,7 @@ def topology_m4(request):
if not m4_m1_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m4_m1_agmt)
+ log.debug("{} created".format(m4_m1_agmt))
# Creating agreement from master 4 to master 2
properties = {RA_NAME: 'meTo_' + master2.host + ':' + str(master2.port),
@@ -402,7 +792,7 @@ def topology_m4(request):
if not m4_m2_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m4_m2_agmt)
+ log.debug("{} created".format(m4_m2_agmt))
# Creating agreement from master 4 to master 3
properties = {RA_NAME: 'meTo_' + master3.host + ':' + str(master3.port),
@@ -415,7 +805,7 @@ def topology_m4(request):
if not m4_m3_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
- log.debug("%s created" % m4_m3_agmt)
+ log.debug("{} created".format(m4_m3_agmt))
# Allow the replicas to get situated with the new agreements...
time.sleep(5)
@@ -450,4 +840,3 @@ def topology_m4(request):
"master4": master4, "master4_agmts": {"m4_m1": m4_m1_agmt,
"m4_m2": m4_m2_agmt,
"m4_m3": m4_m3_agmt}})
-
| 0 |
7466be331dd773c663971dd24443e2248a90a021
|
389ds/389-ds-base
|
Issue 50425 - Add jemalloc LD_PRELOAD to systemd drop-in file
Description: Add the jemalloc back to the systemd dropin file which
was accidentally removed from a previous change regarding
systemd
Relates: https://pagure.io/389-ds-base/issue/50425
Reviewed by: mhonek(Thanks!)
|
commit 7466be331dd773c663971dd24443e2248a90a021
Author: Mark Reynolds <[email protected]>
Date: Mon Jul 15 17:47:42 2019 -0400
Issue 50425 - Add jemalloc LD_PRELOAD to systemd drop-in file
Description: Add the jemalloc back to the systemd dropin file which
was accidentally removed from a previous change regarding
systemd
Relates: https://pagure.io/389-ds-base/issue/50425
Reviewed by: mhonek(Thanks!)
diff --git a/Makefile.am b/Makefile.am
index 7279f3800..6c948a338 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -654,8 +654,10 @@ endif
#------------------------
config_DATA = $(srcdir)/lib/ldaputil/certmap.conf \
$(srcdir)/ldap/schema/slapd-collations.conf \
- ldap/admin/src/template-initconfig \
ldap/servers/snmp/ldap-agent.conf
+if !SYSTEMD
+config_DATA += ldap/admin/src/template-initconfig
+endif
# the schema files in this list are either not
# standard schema, not tested, or not compatible
@@ -882,10 +884,12 @@ systemdsystemunit_DATA = wrappers/$(PACKAGE_NAME)@.service \
wrappers/$(systemdgroupname) \
wrappers/$(PACKAGE_NAME)-snmp.service
-systemdsystemunitdropin_DATA = wrappers/$(PACKAGE_NAME)@.service.d/custom.conf
if with_sanitizer
-systemdsystemunitdropin_DATA += wrappers/$(PACKAGE_NAME)@.service.d/xsan.conf
+systemdsystemunitdropin_DATA = wrappers/$(PACKAGE_NAME)@.service.d/xsan.conf
+else
+systemdsystemunitdropin_DATA = wrappers/$(PACKAGE_NAME)@.service.d/custom.conf
endif
+
else
if INITDDIR
init_SCRIPTS = wrappers/$(PACKAGE_NAME) \
@@ -983,12 +987,14 @@ dist_man_MANS = man/man1/dbscan.1 \
man/man5/slapd-collations.conf.5 \
man/man8/suffix2instance.8 \
man/man8/syntax-validate.pl.8 \
- man/man5/template-initconfig.5 \
man/man8/upgradednformat.8 \
man/man8/upgradedb.8 \
man/man8/usn-tombstone-cleanup.pl.8 \
man/man8/vlvindex.8 \
man/man8/verify-db.pl.8
+if !SYSTEMD
+dist_man_MANS += man/man5/template-initconfig.5
+endif
#------------------------
# updates
@@ -2292,20 +2298,14 @@ fixupcmd = sed \
if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
$(fixupcmd) $^ > $@
+if !SYSTEMD
%/$(PACKAGE_NAME): %/base-initconfig.in
if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
-if SYSTEMD
- $(fixupcmd) $^ | sed -e 's/@preamble@/# This file is in systemd EnvironmentFile format - see man systemd.exec/' > $@
-else
$(fixupcmd) $^ | sed -n -e 's/@preamble@//' -e '/^#/{p;d;}' -e '/^$$/{p;d;}' -e 's/^\([^=]*\)\(=.*\)$$/\1\2 ; export \1/ ; p' > $@
$(fixupcmd) $(srcdir)/ldap/admin/src/initconfig.in >> $@
-endif
%/template-initconfig: %/template-initconfig.in
if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
-if SYSTEMD
- $(fixupcmd) $^ | sed -e 's/@preamble@/# This file is in systemd EnvironmentFile format - see man systemd.exec/' > $@
-else
$(fixupcmd) $^ | sed -n -e 's/@preamble@//' -e '/^#/{p;d;}' -e '/^$$/{p;d;}' -e 's/^\([^=]*\)\(=.*\)$$/\1\2 ; export \1/ ; p' > $@
endif
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index 876adb3b1..16406d795 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -601,7 +601,6 @@ exit 0
%dir %{_sysconfdir}/systemd/system/%{groupname}.wants
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/slapd-collations.conf
%config(noreplace)%{_sysconfdir}/%{pkgname}/config/certmap.conf
-%config(noreplace)%{_sysconfdir}/%{pkgname}/config/template-initconfig
%{_datadir}/%{pkgname}
%exclude %{_datadir}/%{pkgname}/script-templates
%exclude %{_datadir}/%{pkgname}/updates
@@ -655,7 +654,6 @@ exit 0
%{_mandir}/man8/vlvindex.8.gz
%{_mandir}/man5/99user.ldif.5.gz
%{_mandir}/man5/certmap.conf.5.gz
-%{_mandir}/man5/template-initconfig.5.gz
%{_mandir}/man5/slapd-collations.conf.5.gz
%{_mandir}/man5/dirsrv.5.gz
%{_mandir}/man5/dirsrv.systemd.5.gz
diff --git a/wrappers/systemd.template.service.custom.conf.in b/wrappers/systemd.template.service.custom.conf.in
index 0dce62826..fd10fe167 100644
--- a/wrappers/systemd.template.service.custom.conf.in
+++ b/wrappers/systemd.template.service.custom.conf.in
@@ -49,4 +49,5 @@ TimeoutStopSec=600
#ProtectHome=yes
#PrivateTmp=yes
-
+# Preload jemalloc
+Environment=LD_PRELOAD=@libdir@/@package_name@/lib/libjemalloc.so.2
| 0 |
64b1ebffe5af118965bcdf3a84d62c0fc3efd196
|
389ds/389-ds-base
|
Ticket 49071 - Import with duplicate DNs throws unexpected errors
Bug Description: When an import fails there are unable to flush error
messages.
Fix Description: When an import fails close the database files before
deleting them.
Also fixed a small issue in DSUtil where we did not properly
check if an entry was valid.
https://fedorahosted.org/389/ticket/49071
Reviewed by: mreynolds(one line commit rule)
|
commit 64b1ebffe5af118965bcdf3a84d62c0fc3efd196
Author: Mark Reynolds <[email protected]>
Date: Mon Dec 19 12:26:59 2016 -0500
Ticket 49071 - Import with duplicate DNs throws unexpected errors
Bug Description: When an import fails there are unable to flush error
messages.
Fix Description: When an import fails close the database files before
deleting them.
Also fixed a small issue in DSUtil where we did not properly
check if an entry was valid.
https://fedorahosted.org/389/ticket/49071
Reviewed by: mreynolds(one line commit rule)
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index eac59a337..c97280562 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -1262,7 +1262,7 @@ sub get_info {
last;
}
}
- if($foundcfg eq "yes"){
+ if($foundcfg eq "yes" && $entry){
$info{cacertfile} = $entry->getValues("CACertExtractFile");
if ($info{cacertfile}) {
$ENV{LDAPTLS_CACERT}=$info{cacertfile};
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index 0512194ec..d0cef1a49 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -1485,12 +1485,12 @@ error:
}
}
if (0 != ret) {
+ dblayer_instance_close(job->inst->inst_be);
if (!(job->flags & (FLAG_DRYRUN|FLAG_UPGRADEDNFORMAT_V1))) {
/* If not dryrun NOR upgradedn space */
/* if running in the dry run mode, don't touch the db */
dblayer_delete_instance_dir(be);
}
- dblayer_instance_close(job->inst->inst_be);
} else {
if (0 != (ret = dblayer_instance_close(job->inst->inst_be)) ) {
import_log_notice(job, SLAPI_LOG_WARNING, "import_main_offline", "Failed to close database");
| 0 |
4daa0a6cd4d0db8df34e7466fb3877549d69e7d1
|
389ds/389-ds-base
|
Ticket #50 - server should not call a plugin after the plugin close function is calle
Bug Description: Its possible that a plugin's pre/post op function can be called as
the plugin is shutting down. It is also possible that a queued plugin
task can be run after the plugin is shut down.
Fix description: Added a new flag to plugin struct to mark when the plugin is closed.
This flag is checked when we attempt to call a plugin function. We also
now check if the plugin is closed before issuing a plugin task. The
plugin task change only affected 3 plugins: usn, likedatttrs, & memberOf
https://fedorahosted.org/389/ticket/50
|
commit 4daa0a6cd4d0db8df34e7466fb3877549d69e7d1
Author: Mark Reynolds <[email protected]>
Date: Thu Jan 19 13:53:01 2012 -0500
Ticket #50 - server should not call a plugin after the plugin close function is calle
Bug Description: Its possible that a plugin's pre/post op function can be called as
the plugin is shutting down. It is also possible that a queued plugin
task can be run after the plugin is shut down.
Fix description: Added a new flag to plugin struct to mark when the plugin is closed.
This flag is checked when we attempt to call a plugin function. We also
now check if the plugin is closed before issuing a plugin task. The
plugin task change only affected 3 plugins: usn, likedatttrs, & memberOf
https://fedorahosted.org/389/ticket/50
diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c b/ldap/servers/plugins/linkedattrs/fixup_task.c
index ee64d7137..a698a6c2a 100644
--- a/ldap/servers/plugins/linkedattrs/fixup_task.c
+++ b/ldap/servers/plugins/linkedattrs/fixup_task.c
@@ -69,6 +69,14 @@ linked_attrs_fixup_task_add(Slapi_PBlock *pb, Slapi_Entry *e,
const char *linkdn = NULL;
*returncode = LDAP_SUCCESS;
+
+ /* make sure the plugin is not closed */
+ if(!linked_attrs_is_started()){
+ *returncode = LDAP_OPERATIONS_ERROR;
+ rv = SLAPI_DSE_CALLBACK_ERROR;
+ goto out;
+ }
+
/* get arg(s) */
linkdn = fetch_attr(e, "linkdn", 0);
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 2b5127d5f..1a647bcc5 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -2135,3 +2135,8 @@ linked_attrs_dump_config_entry(struct configEntry * entry)
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
"<---- scope ---------------> %s\n", entry->scope);
}
+
+int
+linked_attrs_is_started(){
+ return g_plugin_started;
+}
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.h b/ldap/servers/plugins/linkedattrs/linked_attrs.h
index 879513dcc..137e31723 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.h
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.h
@@ -138,3 +138,8 @@ int linked_attrs_fixup_task_add(Slapi_PBlock *pb, Slapi_Entry *e,
char *returntext, void *arg);
int g_get_shutdown(); /* declared in proto-slap.h */
+
+/*
+ * misc
+ */
+int linked_attrs_is_started();
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index e7fcf22e2..19c308574 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -2295,6 +2295,15 @@ int memberof_task_add(Slapi_PBlock *pb, Slapi_Entry *e,
const char *dn = 0;
*returncode = LDAP_SUCCESS;
+
+ /* make sure the plugin was not stopped from a shutdown */
+ if (!g_plugin_started)
+ {
+ *returncode = LDAP_OPERATIONS_ERROR;
+ rv = SLAPI_DSE_CALLBACK_ERROR;
+ goto out;
+ }
+
/* get arg(s) */
if ((dn = fetch_attr(e, "basedn", 0)) == NULL)
{
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index f5579c999..dbae1d55b 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -68,6 +68,7 @@ static int usn_get_attr(Slapi_PBlock *pb, const char* type, void *value);
static int usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e,
Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
+int g_plugin_started = 0;
/*
* Register USN plugin
* Note: USN counter initialization is done in the backend (ldbm_usn_init).
@@ -237,6 +238,7 @@ usn_start(Slapi_PBlock *pb)
value = slapi_value_new_string("(objectclass=*) $ EXCLUDE entryusn");
rc = slapi_set_plugin_default_config("nsds5ReplicatedAttributeList", value);
slapi_value_free(&value);
+ g_plugin_started = 1;
bail:
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- usn_start (rc: %d)\n", rc);
@@ -252,6 +254,7 @@ usn_close(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "--> usn_close\n");
csngen_free(&_usn_csngen);
+ g_plugin_started = 0;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "<-- usn_close\n");
@@ -708,3 +711,9 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
"<-- usn_rootdse_search\n");
return SLAPI_DSE_CALLBACK_OK;
}
+
+int
+usn_is_started()
+{
+ return g_plugin_started;
+}
diff --git a/ldap/servers/plugins/usn/usn.h b/ldap/servers/plugins/usn/usn.h
index 8e6c5c8e0..46bcd1654 100644
--- a/ldap/servers/plugins/usn/usn.h
+++ b/ldap/servers/plugins/usn/usn.h
@@ -51,6 +51,7 @@
/* usn.c */
void usn_set_identity(void *identity);
void *usn_get_identity();
+int usn_is_started();
/* usn_cleanup.c */
int usn_cleanup_start(Slapi_PBlock *pb);
diff --git a/ldap/servers/plugins/usn/usn_cleanup.c b/ldap/servers/plugins/usn/usn_cleanup.c
index 16e6a9529..12a48e346 100644
--- a/ldap/servers/plugins/usn/usn_cleanup.c
+++ b/ldap/servers/plugins/usn/usn_cleanup.c
@@ -252,6 +252,14 @@ usn_cleanup_add(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eAfter,
"--> usn_cleanup_add\n");
*returncode = LDAP_SUCCESS;
+
+ /* make sure plugin is not closed*/
+ if(!usn_is_started()){
+ *returncode = LDAP_OPERATIONS_ERROR;
+ rv = SLAPI_DSE_CALLBACK_ERROR;
+ goto bail;
+ }
+
cn = slapi_entry_attr_get_charptr(e, "cn");
if (NULL == cn) {
*returncode = LDAP_OBJECT_CLASS_VIOLATION;
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 8179352db..50df50268 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1360,6 +1360,8 @@ plugin_dependency_closeall()
{
pblock_init(&pb);
plugin_call_one( global_plugin_shutdown_order[index].plugin, SLAPI_PLUGIN_CLOSE_FN, &pb );
+ /* set plg_closed to 1 to prevent any further plugin pre/post op function calls */
+ global_plugin_shutdown_order[index].plugin->plg_closed = 1;
plugins_closed++;
}
@@ -1440,7 +1442,7 @@ plugin_call_func (struct slapdplugin *list, int operation, Slapi_PBlock *pb, int
slapi_pblock_set (pb, SLAPI_PLUGIN, list);
set_db_default_result_handlers (pb); /* JCM: What's this do? Is it needed here? */
if (slapi_pblock_get (pb, operation, &func) == 0 && func != NULL &&
- plugin_invoke_plugin_pb (list, operation, pb))
+ plugin_invoke_plugin_pb (list, operation, pb) && list->plg_closed == 0)
{
char *n= list->plg_name;
LDAPDebug( LDAP_DEBUG_TRACE, "Calling plugin '%s' #%d type %d\n", (n==NULL?"noname":n), count, operation );
@@ -2102,6 +2104,7 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group,
plugin = (struct slapdplugin *)slapi_ch_calloc(1, sizeof(struct slapdplugin));
plugin->plg_dn = slapi_ch_strdup(slapi_entry_get_dn_const(plugin_entry));
+ plugin->plg_closed = 0;
if (!(value = slapi_entry_attr_get_charptr(plugin_entry,
ATTR_PLUGIN_TYPE)))
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index c5d658dc9..86d954d15 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -799,7 +799,8 @@ struct slapdplugin {
struct pluginconfig plg_conf; /* plugin configuration parameters */
IFP plg_cleanup; /* cleanup function */
IFP plg_start; /* start function */
- IFP plg_poststart; /* poststart function */
+ IFP plg_poststart; /* poststart function */
+ int plg_closed; /* mark plugin as closed */
/* NOTE: These LDIF2DB and DB2LDIF fn pointers are internal only for now.
I don't believe you can get these functions from a plug-in and
| 0 |
8af8dffe2416290b8777dcda3450d1e76ca8657c
|
389ds/389-ds-base
|
Add SELinux policy for ldap-agent.
This adds SELinux policy to confine the SNMP subagent (ldap-agent).
There were some changes required around the aubagent to make it
work in a more standard fashion.
I moved the ldap-agent binary and wrapper to sbindir. It was
previously in bindir, yet it is not a user command. The location
really should be sbindir per FHS.
I added init scripts for the subagent, so it can now be managed
using "service dirsrv-snmp [start|stop|restart|condrestart|status]".
While doing this, I found that the parent process was exiting with
1 on success instead of 0, so I fixed that.
I added a default config file for the subagent as well. When using
the init script, the config file is hardcoded into this standard
location. Having this config template should also hopefully cut
down on configuration errors since it's self documenting.
The pid file location was also changed to go into /var/run per FHS.
Previously, it was written to the same directory as the log file.
There are a few notes in the policy .te file about some bugs that
we are working around for now. These bugs are mainly minor issues
in the snmp policy that is a part of the selinux-policy pacakge.
Once those bugs are fixed, we can clean our policy .te file up.
|
commit 8af8dffe2416290b8777dcda3450d1e76ca8657c
Author: Nathan Kinder <[email protected]>
Date: Thu Sep 17 08:13:59 2009 -0700
Add SELinux policy for ldap-agent.
This adds SELinux policy to confine the SNMP subagent (ldap-agent).
There were some changes required around the aubagent to make it
work in a more standard fashion.
I moved the ldap-agent binary and wrapper to sbindir. It was
previously in bindir, yet it is not a user command. The location
really should be sbindir per FHS.
I added init scripts for the subagent, so it can now be managed
using "service dirsrv-snmp [start|stop|restart|condrestart|status]".
While doing this, I found that the parent process was exiting with
1 on success instead of 0, so I fixed that.
I added a default config file for the subagent as well. When using
the init script, the config file is hardcoded into this standard
location. Having this config template should also hopefully cut
down on configuration errors since it's self documenting.
The pid file location was also changed to go into /var/run per FHS.
Previously, it was written to the same directory as the log file.
There are a few notes in the policy .te file about some bugs that
we are working around for now. These bugs are mainly minor issues
in the snmp policy that is a part of the selinux-policy pacakge.
Once those bugs are fixed, we can clean our policy .te file up.
diff --git a/Makefile.am b/Makefile.am
index 665b1f4ff..7f35c6a21 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -135,10 +135,10 @@ defaultgroup=@defaultgroup@
#------------------------
# Build Products
#------------------------
-sbin_PROGRAMS = ns-slapd
+sbin_PROGRAMS = ns-slapd ldap-agent-bin
-bin_PROGRAMS = dbscan-bin dsktune-bin infadd-bin ldap-agent-bin \
- ldclt-bin ldif-bin migratecred-bin mmldif-bin pwdhash-bin rsearch-bin
+bin_PROGRAMS = dbscan-bin dsktune-bin infadd-bin ldclt-bin \
+ ldif-bin migratecred-bin mmldif-bin pwdhash-bin rsearch-bin
server_LTLIBRARIES = libslapd.la libns-dshttpd.la
@@ -193,7 +193,8 @@ policy_DATA = $(POLICY_MODULE)
config_DATA = $(srcdir)/lib/ldaputil/certmap.conf \
$(srcdir)/ldap/schema/slapd-collations.conf \
- ldap/admin/src/template-initconfig
+ ldap/admin/src/template-initconfig \
+ ldap/servers/snmp/ldap-agent.conf
# the schema files in this list are either not
# standard schema, not tested, or not compatible
@@ -274,13 +275,13 @@ sbin_SCRIPTS = ldap/admin/src/scripts/setup-ds.pl \
ldap/admin/src/scripts/remove-ds.pl \
ldap/admin/src/scripts/start-dirsrv \
ldap/admin/src/scripts/stop-dirsrv \
- ldap/admin/src/scripts/restart-dirsrv
+ ldap/admin/src/scripts/restart-dirsrv \
+ wrappers/ldap-agent
bin_SCRIPTS = ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl \
wrappers/dbscan \
wrappers/dsktune \
wrappers/infadd \
- wrappers/ldap-agent \
wrappers/ldclt \
wrappers/ldif \
$(srcdir)/ldap/admin/src/logconv.pl \
@@ -343,7 +344,8 @@ task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \
ldap/admin/src/scripts/template-verify-db.pl \
ldap/admin/src/scripts/template-dbverify
-init_SCRIPTS = wrappers/$(PACKAGE_NAME)
+init_SCRIPTS = wrappers/$(PACKAGE_NAME) \
+ wrappers/$(PACKAGE_NAME)-snmp
initconfig_DATA = ldap/admin/src/$(PACKAGE_NAME)
@@ -1315,3 +1317,8 @@ endif
%/$(PACKAGE_NAME): %/initconfig.in
if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
$(fixupcmd) $^ > $@
+
+%/$(PACKAGE_NAME)-snmp: %/ldap-agent-initscript.in
+ if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+ $(fixupcmd) $^ > $@
+
diff --git a/Makefile.in b/Makefile.in
index a09bdd48e..f064dede3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -40,10 +40,10 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-sbin_PROGRAMS = ns-slapd$(EXEEXT)
+sbin_PROGRAMS = ns-slapd$(EXEEXT) ldap-agent-bin$(EXEEXT)
bin_PROGRAMS = dbscan-bin$(EXEEXT) dsktune-bin$(EXEEXT) \
- infadd-bin$(EXEEXT) ldap-agent-bin$(EXEEXT) ldclt-bin$(EXEEXT) \
- ldif-bin$(EXEEXT) migratecred-bin$(EXEEXT) mmldif-bin$(EXEEXT) \
+ infadd-bin$(EXEEXT) ldclt-bin$(EXEEXT) ldif-bin$(EXEEXT) \
+ migratecred-bin$(EXEEXT) mmldif-bin$(EXEEXT) \
pwdhash-bin$(EXEEXT) rsearch-bin$(EXEEXT)
noinst_PROGRAMS = makstrdb$(EXEEXT)
@SOLARIS_TRUE@am__append_1 = ldap/servers/slapd/slapi_counter_sunos_sparcv9.S
@@ -1230,7 +1230,8 @@ noinst_LIBRARIES = libavl.a libldaputil.a
policy_DATA = $(POLICY_MODULE)
config_DATA = $(srcdir)/lib/ldaputil/certmap.conf \
$(srcdir)/ldap/schema/slapd-collations.conf \
- ldap/admin/src/template-initconfig
+ ldap/admin/src/template-initconfig \
+ ldap/servers/snmp/ldap-agent.conf
# the schema files in this list are either not
@@ -1312,13 +1313,13 @@ sbin_SCRIPTS = ldap/admin/src/scripts/setup-ds.pl \
ldap/admin/src/scripts/remove-ds.pl \
ldap/admin/src/scripts/start-dirsrv \
ldap/admin/src/scripts/stop-dirsrv \
- ldap/admin/src/scripts/restart-dirsrv
+ ldap/admin/src/scripts/restart-dirsrv \
+ wrappers/ldap-agent
bin_SCRIPTS = ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl \
wrappers/dbscan \
wrappers/dsktune \
wrappers/infadd \
- wrappers/ldap-agent \
wrappers/ldclt \
wrappers/ldif \
$(srcdir)/ldap/admin/src/logconv.pl \
@@ -1382,7 +1383,9 @@ task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \
ldap/admin/src/scripts/template-verify-db.pl \
ldap/admin/src/scripts/template-dbverify
-init_SCRIPTS = wrappers/$(PACKAGE_NAME)
+init_SCRIPTS = wrappers/$(PACKAGE_NAME) \
+ wrappers/$(PACKAGE_NAME)-snmp
+
initconfig_DATA = ldap/admin/src/$(PACKAGE_NAME)
inf_DATA = ldap/admin/src/slapd.inf \
ldap/admin/src/scripts/dscreate.map \
@@ -9847,6 +9850,10 @@ ns-slapd.properties: makstrdb
%/$(PACKAGE_NAME): %/initconfig.in
if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
$(fixupcmd) $^ > $@
+
+%/$(PACKAGE_NAME)-snmp: %/ldap-agent-initscript.in
+ if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+ $(fixupcmd) $^ > $@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/ldap/servers/snmp/ldap-agent.conf.in b/ldap/servers/snmp/ldap-agent.conf.in
new file mode 100644
index 000000000..6593685b1
--- /dev/null
+++ b/ldap/servers/snmp/ldap-agent.conf.in
@@ -0,0 +1,30 @@
+# The agentx-master setting defines how to communicate
+# with the SNMP master agent using the AgentX protocol.
+# The default is to use a UNIX domain socket. If your
+# master agent is listening on a tcp port for AgentX
+# subagents, use a line like the following:
+#
+# agentx-master localhost:705
+agentx-master /var/agentx/master
+
+# The agent-logdir settings defines where the subagent
+# will write it's logfile.
+agent-logdir @localstatedir@/log/@package_name@
+
+# The server setting specifies a Directory Server
+# instance that you want to monitor. You must use one
+# server setting for each Directory Server instance. The
+# subagent requires at least one server setting to be
+# specified. The server setting
+# should be set to the name of the Directory Server
+# instance you would like to monitor. For example:
+#
+# server slapd-phonebook
+#
+# To monitor multiple Directory Server instances, add
+# an additional server parameter for each instance:
+#
+# server slapd-phonebook
+# server slapd-example
+# server slapd-directory
+
diff --git a/ldap/servers/snmp/ldap-agent.h b/ldap/servers/snmp/ldap-agent.h
index 30253d1c0..664d7e221 100644
--- a/ldap/servers/snmp/ldap-agent.h
+++ b/ldap/servers/snmp/ldap-agent.h
@@ -90,7 +90,7 @@ extern "C" {
#define CACHE_REFRESH_INTERVAL 15
#define UPDATE_THRESHOLD 20
#define SNMP_NUM_SEM_WAITS 10
-#define LDAP_AGENT_PIDFILE ".ldap-agent.pid"
+#define LDAP_AGENT_PIDFILE "ldap-agent.pid"
#define LDAP_AGENT_LOGFILE "ldap-agent.log"
/*************************************************************
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 5b2ad68a3..04c4ee3f7 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -191,7 +191,7 @@ main (int argc, char *argv[]) {
fscanf(pid_fp, "%d", &child_pid);
fclose(pid_fp);
printf("ldap-agent: Started as pid %d\n", child_pid);
- exit(1);
+ exit(0);
}
/* initialize the agent */
@@ -205,7 +205,7 @@ main (int argc, char *argv[]) {
signal(SIGTERM, stop_server);
signal(SIGINT, stop_server);
- /* create pidfile in config file dir */
+ /* create pidfile */
child_pid = getpid();
if ((pid_fp = fopen(pidfile, "w")) == NULL) {
snmp_log(LOG_ERR, "Error creating pid file: %s\n", pidfile);
@@ -272,25 +272,24 @@ load_config(char *conf_path)
}
/* set pidfile path */
+ if ((pidfile = malloc(strlen(LOCALSTATEDIR) + strlen("/run/") +
+ strlen(LDAP_AGENT_PIDFILE) + 1)) != NULL) {
+ strncpy(pidfile, LOCALSTATEDIR, strlen(LOCALSTATEDIR));
+ /* The above will likely not be NULL terminated, but we need to
+ * be sure that we're properly NULL terminated for the below
+ * strcat() to work properly. */
+ pidfile[strlen(LOCALSTATEDIR)] = (char)0;
+ strcat(pidfile, "/run/");
+ strcat(pidfile, LDAP_AGENT_PIDFILE);
+ } else {
+ printf("ldap-agent: malloc error processing config file\n");
+ error = 1;
+ goto close_and_exit;
+ }
+
+ /* set default logdir to location of config file */
for (p = (conf_path + strlen(conf_path) - 1); p >= conf_path; p--) {
if (*p == '/') {
- /* set pidfile path */
- if ((pidfile = malloc((p - conf_path) +
- strlen(LDAP_AGENT_PIDFILE) + 2)) != NULL) {
- strncpy(pidfile, conf_path, (p - conf_path + 1));
- /* The above will likely not be NULL terminated, but we need to
- * be sure that we're properly NULL terminated for the below
- * strcat() to work properly. */
- pidfile[(p - conf_path + 2)] = (char)0;
- strcat(pidfile, LDAP_AGENT_PIDFILE);
- pidfile[((p - conf_path) + strlen(LDAP_AGENT_PIDFILE) + 1)] = (char)0;
- } else {
- printf("ldap-agent: malloc error processing config file\n");
- error = 1;
- goto close_and_exit;
- }
-
- /* set default logdir to location of config file */
if ((agent_logdir = malloc((p - conf_path) + 1)) != NULL) {
strncpy(agent_logdir, conf_path, (p - conf_path));
agent_logdir[(p - conf_path)] = (char)0;
diff --git a/selinux/dirsrv.fc.in b/selinux/dirsrv.fc.in
index ae768b1bb..f61a87101 100644
--- a/selinux/dirsrv.fc.in
+++ b/selinux/dirsrv.fc.in
@@ -4,14 +4,18 @@
# MCS categories: <none>
@sbindir@/ns-slapd -- gen_context(system_u:object_r:dirsrv_exec_t,s0)
+@sbindir@/ldap-agent -- gen_context(system_u:object_r:initrc_exec_t,s0)
+@sbindir@/ldap-agent-bin -- gen_context(system_u:object_r:dirsrv_snmp_exec_t,s0)
@sbindir@/start-dirsrv -- gen_context(system_u:object_r:initrc_exec_t,s0)
@sbindir@/restart-dirsrv -- gen_context(system_u:object_r:initrc_exec_t,s0)
@serverdir@ gen_context(system_u:object_r:dirsrv_lib_t,s0)
@serverdir@(/.*) gen_context(system_u:object_r:dirsrv_lib_t,s0)
@localstatedir@/run/@package_name@ gen_context(system_u:object_r:dirsrv_var_run_t,s0)
@localstatedir@/run/@package_name@(/.*) gen_context(system_u:object_r:dirsrv_var_run_t,s0)
+@localstatedir@/run/ldap-agent.pid gen_context(system_u:object_r:dirsrv_snmp_var_run_t,s0)
@localstatedir@/log/@package_name@ gen_context(system_u:object_r:dirsrv_var_log_t,s0)
@localstatedir@/log/@package_name@(/.*) gen_context(system_u:object_r:dirsrv_var_log_t,s0)
+@localstatedir@/log/@package_name@/ldap-agent.log gen_context(system_u:object_r:dirsrv_snmp_var_log_t,s0)
@localstatedir@/lock/@package_name@ gen_context(system_u:object_r:dirsrv_var_lock_t,s0)
@localstatedir@/lock/@package_name@(/.*) gen_context(system_u:object_r:dirsrv_var_lock_t,s0)
@localstatedir@/lib/@package_name@ gen_context(system_u:object_r:dirsrv_var_lib_t,s0)
diff --git a/selinux/dirsrv.te b/selinux/dirsrv.te
index 872e42fe7..b505c89a4 100644
--- a/selinux/dirsrv.te
+++ b/selinux/dirsrv.te
@@ -5,12 +5,26 @@ policy_module(dirsrv,1.0.0)
# Declarations
#
+# NGK - this can go away when bz 478629, bz 523548,
+# and bz 523771 are addressed. See the notes below
+# where we work around those issues.
+require {
+ type snmpd_var_lib_t;
+ type snmpd_t;
+}
+
# main daemon
type dirsrv_t;
type dirsrv_exec_t;
domain_type(dirsrv_t)
init_daemon_domain(dirsrv_t, dirsrv_exec_t)
+# snmp subagent daemon
+type dirsrv_snmp_t;
+type dirsrv_snmp_exec_t;
+domain_type(dirsrv_snmp_t)
+init_daemon_domain(dirsrv_snmp_t, dirsrv_snmp_exec_t)
+
# dynamic libraries
type dirsrv_lib_t;
files_type(dirsrv_lib_t)
@@ -23,10 +37,18 @@ files_type(dirsrv_var_lib_t)
type dirsrv_var_log_t;
logging_log_file(dirsrv_var_log_t)
+# snmp log file
+type dirsrv_snmp_var_log_t;
+logging_log_file(dirsrv_snmp_var_log_t)
+
# pid files
type dirsrv_var_run_t;
files_pid_file(dirsrv_var_run_t)
+# snmp pid file
+type dirsrv_snmp_var_run_t;
+files_pid_file(dirsrv_snmp_var_run_t)
+
# lock files
type dirsrv_var_lock_t;
files_lock_file(dirsrv_var_lock_t)
@@ -93,7 +115,7 @@ files_pid_filetrans(dirsrv_t, dirsrv_var_run_t, { file sock_file })
# ldapi socket
manage_sock_files_pattern(dirsrv_t, dirsrv_var_run_t, dirsrv_var_run_t)
-#lock files
+# lock files
manage_files_pattern(dirsrv_t, dirsrv_var_lock_t, dirsrv_var_lock_t)
manage_dirs_pattern(dirsrv_t, dirsrv_var_lock_t, dirsrv_var_lock_t)
files_lock_filetrans(dirsrv_t, dirsrv_var_lock_t, { file })
@@ -128,3 +150,64 @@ allow dirsrv_t self:tcp_socket { create_stream_socket_perms };
init_use_fds(dirsrv_t)
init_use_script_ptys(dirsrv_t)
domain_use_interactive_fds(dirsrv_t)
+
+
+########################################
+#
+# dirsrv-snmp local policy
+#
+
+# Some common macros
+files_read_etc_files(dirsrv_snmp_t)
+miscfiles_read_localization(dirsrv_snmp_t)
+libs_use_ld_so(dirsrv_snmp_t)
+libs_use_shared_libs(dirsrv_snmp_t)
+dev_read_rand(dirsrv_snmp_t)
+dev_read_urand(dirsrv_snmp_t)
+files_read_usr_files(dirsrv_snmp_t)
+fs_getattr_tmpfs(dirsrv_snmp_t)
+fs_search_tmpfs(dirsrv_snmp_t)
+allow dirsrv_snmp_t self:fifo_file { read write };
+sysnet_read_config(dirsrv_snmp_t)
+sysnet_dns_name_resolve(dirsrv_snmp_t)
+
+# Net-SNMP /var/lib files (includes agentx unix domain socket)
+snmp_dontaudit_read_snmp_var_lib_files(dirsrv_snmp_t)
+snmp_dontaudit_write_snmp_var_lib_files(dirsrv_snmp_t)
+# NGK - there really should be a macro for this. (see bz 523771)
+allow dirsrv_snmp_t snmpd_var_lib_t:file append;
+# NGK - use snmp_stream_connect(dirsrv_snmp_t) when it is made
+# available on all platforms we build on (see bz 478629 and bz 523548)
+stream_connect_pattern(dirsrv_snmp_t, snmpd_var_lib_t, snmpd_var_lib_t, snmpd_t)
+
+# Net-SNMP agentx tcp socket
+corenet_tcp_connect_agentx_port(dirsrv_snmp_t)
+
+# Net-SNMP persistent data file
+files_manage_var_files(dirsrv_snmp_t)
+
+# stats file semaphore
+rw_files_pattern(dirsrv_snmp_t, dirsrv_tmpfs_t, dirsrv_tmpfs_t)
+
+# stats file
+read_files_pattern(dirsrv_snmp_t, dirsrv_var_run_t, dirsrv_var_run_t)
+
+# process stuff
+allow dirsrv_snmp_t self:capability { dac_override dac_read_search };
+
+# config file
+read_files_pattern(dirsrv_snmp_t, dirsrv_config_t, dirsrv_config_t)
+
+# pid file
+admin_pattern(dirsrv_snmp_t, dirsrv_snmp_var_run_t)
+files_pid_filetrans(dirsrv_snmp_t, dirsrv_snmp_var_run_t, { file sock_file })
+search_dirs_pattern(dirsrv_snmp_t, dirsrv_var_run_t, dirsrv_var_run_t)
+
+# log file
+manage_files_pattern(dirsrv_snmp_t, dirsrv_var_log_t, dirsrv_snmp_var_log_t);
+filetrans_pattern(dirsrv_snmp_t, dirsrv_var_log_t, dirsrv_snmp_var_log_t, file)
+
+# Init script handling
+init_use_fds(dirsrv_snmp_t)
+init_use_script_ptys(dirsrv_snmp_t)
+domain_use_interactive_fds(dirsrv_snmp_t)
diff --git a/wrappers/ldap-agent-initscript.in b/wrappers/ldap-agent-initscript.in
new file mode 100644
index 000000000..d4e791f70
--- /dev/null
+++ b/wrappers/ldap-agent-initscript.in
@@ -0,0 +1,221 @@
+#!/bin/sh
+#
+# @package_name@-snmp This starts and stops @package_name@-snmp
+#
+# chkconfig: - 22 78
+# description: @capbrand@ Directory Server SNMP Subagent
+# processname: ldap-agent-bin
+# config: @sysconfdir@/@package_name@/config/ldap-agent.conf
+# pidfile: @localstatedir@/run/ldap-agent.pid
+#
+
+# Source function library.
+if [ -f /etc/rc.d/init.d/functions ] ; then
+. /etc/rc.d/init.d/functions
+fi
+# Source networking configuration.
+if [ -f /etc/sysconfig/network ] ; then
+. /etc/sysconfig/network
+fi
+
+# Check that networking is up.
+if [ "${NETWORKING}" = "no" ]
+then
+ echo "Networking is down"
+ exit 0
+fi
+
+# figure out which echo we're using
+ECHO_N=`echo -n`
+
+# some shells echo cannot use -n - linux echo by default cannot use \c
+echo_n()
+{
+ if [ "$ECHO_N" = '-n' ] ; then
+ echo "$*\c"
+ else
+ echo -n "$*"
+ fi
+}
+
+# failure and success are not defined on some platforms
+type failure > /dev/null 2>&1 || {
+failure()
+{
+ echo_n " FAILED"
+}
+}
+
+type success > /dev/null 2>&1 || {
+success()
+{
+ echo_n " SUCCESS"
+}
+}
+
+baseexec="ldap-agent"
+exec="@sbindir@/$baseexec"
+processname="ldap-agent-bin"
+prog="@package_name@-snmp"
+pidfile="@localstatedir@/run/ldap-agent.pid"
+configfile="@sysconfdir@/@package_name@/config/ldap-agent.conf"
+
+
+
+[ -f $exec ] || exit 0
+
+
+umask 077
+
+start() {
+ echo_n "Starting $prog: "
+ ret=0
+ subagent_running=0
+ subagent_started=0
+
+ # the subagent creates a pidfile and writes
+ # the pid to it when it is fully started.
+ if [ -f $pidfile ]; then
+ pid=`cat $pidfile`
+ name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
+ if kill -0 $pid && [ $name = "$processname" ]; then
+ echo_n " already running"
+ success; echo
+ subagent_running=1
+ else
+ echo " not running, but pid file exists"
+ echo_n " ... attempting to start anyway"
+ fi
+ fi
+
+ if [ $subagent_running -eq 0 ] ; then
+ rm -f $pidfile
+ $exec $configfile > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ subagent_started=1 # well, perhaps not running, but started ok
+ else
+ failure; echo
+ ret=1
+ fi
+ fi
+ # ok, if we started the subagent successfully, let's see
+ # if it is really running and ready to serve requests.
+ if [ $subagent_started -eq 1 ] ; then
+ loop_counter=1
+ # wait for 10 seconds
+ max_count=10
+ while test $loop_counter -le $max_count ; do
+ loop_counter=`expr $loop_counter + 1`
+ if test ! -f $pidfile ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
+ sleep 1
+ else
+ break
+ fi
+ else
+ pid=`cat $pidfile`
+ break
+ fi
+ done
+ if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ success; echo
+ else
+ failure; echo
+ ret=1
+ fi
+ fi
+
+ exit $ret
+}
+
+stop() {
+ echo_n "Shutting down $prog: "
+ if [ -f $pidfile ]; then
+ pid=`cat $pidfile`
+ subagent_stopped=0
+ if kill -0 $pid > /dev/null 2>&1 ; then
+ kill $pid
+ if [ $? -eq 0 ]; then
+ subagent_stopped=1
+ else
+ failure; echo
+ fi
+ else
+ echo_n " subagent not running"
+ failure; echo
+ fi
+ if [ $subagent_stopped -eq 1 ] ; then
+ loop_counter=1
+ # wait for 10 seconds
+ max_count=10
+ while test $loop_counter -le $max_count; do
+ loop_counter=`expr $loop_counter + 1`
+ if kill -0 $pid > /dev/null 2>&1 ; then
+ sleep 1
+ else
+ if test -f $pidfile ; then
+ rm -f $pidfile
+ fi
+ break
+ fi
+ done
+ if test -f $pidfile ; then
+ failure; echo
+ else
+ success; echo
+ rm -f $pidfile
+ fi
+ fi
+ else
+ echo_n " subagent already stopped"
+ failure; echo
+ fi
+}
+
+reload() {
+ stop
+ start
+}
+
+restart() {
+ stop
+ start
+}
+
+condrestart() {
+ if [ -f $pidfile ]; then
+ pid=`cat $pidfile`
+ name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
+ if kill -0 $pid && [ $name = "$processname" ]; then
+ restart
+ fi
+ fi
+}
+
+status() {
+ ret=0
+ if [ -f $pidfile ]; then
+ pid=`cat $pidfile`
+ if kill -0 $pid > /dev/null 2>&1 ; then
+ echo "$prog (pid $pid) is running..."
+ else
+ echo "$prog dead but pid file exists"
+ ret=1
+ fi
+ else
+ echo "$prog is stopped"
+ ret=3
+ fi
+ exit $ret
+}
+
+
+case "$1" in
+ start|stop|restart|reload|condrestart|status)
+ $1
+ ;;
+ *)
+ echo Unknown command $1
+ echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
+ exit 2
+esac
diff --git a/wrappers/ldap-agent.in b/wrappers/ldap-agent.in
index 0b19d8e03..266507aa1 100755
--- a/wrappers/ldap-agent.in
+++ b/wrappers/ldap-agent.in
@@ -5,7 +5,7 @@
###############################################################################
LIB_DIR=@nss_libdir@:@nspr_libdir@:@ldapsdk_libdir@:@netsnmp_libdir@
-BIN_DIR=@bindir@
+BIN_DIR=@sbindir@
COMMAND=ldap-agent-bin
# We don't need to load any mibs, so set MIBS to nothing.
| 0 |
3e814cfba6b74a74bb91fe5dfe62486f27613e57
|
389ds/389-ds-base
|
Issue 5541 - Fix typo in `lib389.cli_conf.backend._get_backend` (#5542)
Fix Description:
Replace `name` with `be_name`.
relates: https://github.com/389ds/389-ds-base/issues/5541
Reviewed by: progier (Thanks)
|
commit 3e814cfba6b74a74bb91fe5dfe62486f27613e57
Author: Stanislav Levin <[email protected]>
Date: Tue Nov 22 17:21:11 2022 +0300
Issue 5541 - Fix typo in `lib389.cli_conf.backend._get_backend` (#5542)
Fix Description:
Replace `name` with `be_name`.
relates: https://github.com/389ds/389-ds-base/issues/5541
Reviewed by: progier (Thanks)
diff --git a/src/lib389/lib389/cli_conf/backend.py b/src/lib389/lib389/cli_conf/backend.py
index f2b6c0866..d32e3327c 100644
--- a/src/lib389/lib389/cli_conf/backend.py
+++ b/src/lib389/lib389/cli_conf/backend.py
@@ -107,7 +107,7 @@ def _get_backend(inst, be_name):
if (is_a_dn(be_name) and str2dn(be_suffix) == str2dn(be_name)) or (not is_a_dn(be_name) and cn == be_name):
return be
- raise ValueError('Could not find backend suffix: {}'.format(name))
+ raise ValueError('Could not find backend suffix: {}'.format(be_name))
def _get_index(inst, be_name, attr):
| 0 |
df5293373d49c3a875d6fba3fec44babfff7b4f6
|
389ds/389-ds-base
|
audit log does not log unhashed password: enabled, by default.
|
commit df5293373d49c3a875d6fba3fec44babfff7b4f6
Author: Noriko Hosoi <[email protected]>
Date: Thu Jun 14 14:40:27 2012 -0700
audit log does not log unhashed password: enabled, by default.
diff --git a/ldap/servers/slapd/auditlog.c b/ldap/servers/slapd/auditlog.c
index 81afe3e45..f6afd101c 100644
--- a/ldap/servers/slapd/auditlog.c
+++ b/ldap/servers/slapd/auditlog.c
@@ -55,7 +55,7 @@ char *attr_changetype = ATTR_CHANGETYPE;
char *attr_newrdn = ATTR_NEWRDN;
char *attr_deleteoldrdn = ATTR_DELETEOLDRDN;
char *attr_modifiersname = ATTR_MODIFIERSNAME;
-static int hide_unhashed_pw = 0;
+static int hide_unhashed_pw = 1;
/* Forward Declarations */
static void write_audit_file( int optype, const char *dn, void *change, int flag, time_t curtime );
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 282fc0de5..3226ede46 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1080,7 +1080,7 @@ FrontendConfig_init () {
cfg->auditlog_minfreespace = 5;
cfg->auditlog_exptime = 1;
cfg->auditlog_exptimeunit = slapi_ch_strdup("month");
- cfg->auditlog_logging_hide_unhashed_pw = LDAP_OFF;
+ cfg->auditlog_logging_hide_unhashed_pw = LDAP_ON;
cfg->entryusn_global = LDAP_OFF;
cfg->entryusn_import_init = slapi_ch_strdup("0");
| 0 |
76847e82a4f70af90b88f2bf5023e8e70be178b4
|
389ds/389-ds-base
|
Ticket 50099 - In FIPS mode, the server can select an unsupported password storage scheme
Bug Description:
When running in FIPS mode, DS selects SSHA512 as password storage schema else it selects PBKDF2_SHA256.
The problem is that in FIPS mode it selects PBKDF2_SHA256 that is currently not supported by NSS.
So DS fails to hash password
The scheme selection is done in the early phase of DS startup (slapd_bootstrap_config).
To determine it is in FIPS mode, DS calls PK11_IsFIPS that requires that NSS has been initialized.
The problem is that during slapd_bootstrap_config, NSS is not yet initialized and PK11_IsFIPS returns
PR_FALSE even in FIPS mode
Fix Description:
The fix consists to check if NSS is initialized. If it is initialize, then rely on PK11_IsFIPS.
If it is not initialized then retrieve the FIPS mode from the system, assuming that if system
is in FIPS mode, then NSS will be in FIPS mode as well
https://pagure.io/389-ds-base/issue/50099
Reviewed by: Mark Reynolds (thanks Mark !)
Platforms tested: F27
Flag Day: no
Doc impact: no
|
commit 76847e82a4f70af90b88f2bf5023e8e70be178b4
Author: Thierry Bordaz <[email protected]>
Date: Fri Dec 14 11:43:30 2018 +0100
Ticket 50099 - In FIPS mode, the server can select an unsupported password storage scheme
Bug Description:
When running in FIPS mode, DS selects SSHA512 as password storage schema else it selects PBKDF2_SHA256.
The problem is that in FIPS mode it selects PBKDF2_SHA256 that is currently not supported by NSS.
So DS fails to hash password
The scheme selection is done in the early phase of DS startup (slapd_bootstrap_config).
To determine it is in FIPS mode, DS calls PK11_IsFIPS that requires that NSS has been initialized.
The problem is that during slapd_bootstrap_config, NSS is not yet initialized and PK11_IsFIPS returns
PR_FALSE even in FIPS mode
Fix Description:
The fix consists to check if NSS is initialized. If it is initialize, then rely on PK11_IsFIPS.
If it is not initialized then retrieve the FIPS mode from the system, assuming that if system
is in FIPS mode, then NSS will be in FIPS mode as well
https://pagure.io/389-ds-base/issue/50099
Reviewed by: Mark Reynolds (thanks Mark !)
Platforms tested: F27
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/security_wrappers.c b/ldap/servers/slapd/security_wrappers.c
index d05588925..49b19684f 100644
--- a/ldap/servers/slapd/security_wrappers.c
+++ b/ldap/servers/slapd/security_wrappers.c
@@ -226,11 +226,60 @@ slapd_pk11_setSlotPWValues(PK11SlotInfo *slot, int askpw, int timeout)
return;
}
+/* The system FIPS mode can be tested on FIPS_ENABLED
+ * system FIPS mode is ON => NSS is always ON
+ * One can imagine to set NSS ON when system FIPS is OFF but it makes no real sense
+ */
+#define FIPS_ENABLED "/proc/sys/crypto/fips_enabled"
+PRBool
+slapd_system_isFIPS()
+{
+ PRBool rc = PR_FALSE;
+ PRFileDesc *prfd;
+ char buf[sizeof (PRIu64)];
+ int val;
+ if (PR_SUCCESS != PR_Access(FIPS_ENABLED, PR_ACCESS_READ_OK)) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_system_isFIPS", "Can not read %s\n", FIPS_ENABLED);
+ goto done;
+ }
+ if ((prfd = PR_Open(FIPS_ENABLED, PR_RDONLY, SLAPD_DEFAULT_FILE_MODE)) == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_system_isFIPS", "Can not open %s\n", FIPS_ENABLED);
+ goto done;
+ }
+ if (PR_Read(prfd, buf, sizeof (buf)) < 0) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_system_isFIPS", "Can not read %s\n", FIPS_ENABLED);
+ PR_Close(prfd);
+ goto done;
+ }
+ PR_Close(prfd);
+ val = atoi(buf);
+ if (val) {
+ slapi_log_err(SLAPI_LOG_INFO, "slapd_system_isFIPS", "system in FIPS mode\n");
+ rc = PR_TRUE;
+ }
+done:
+ return rc;
+}
PRBool
slapd_pk11_isFIPS()
{
- return PK11_IsFIPS();
+ PRBool rc = PR_FALSE;
+
+ if (slapd_nss_is_initialized()) {
+ /* It requires that NSS is initialized before calling PK11_IsFIPS.
+ * Note that it can exist a false positive if NSS in was FIPS mode
+ * although the system is not in FIPS. Such configuration makes no sense
+ */
+ rc = PK11_IsFIPS();
+ } else {
+ /* NSS being not initialized, we are considering the
+ * system FIPS mode.
+ */
+ rc = slapd_system_isFIPS();
+ }
+
+ return rc;
}
| 0 |
ca4d38dff3bd820af2bf60c9bcc82fd64aac2556
|
389ds/389-ds-base
|
Ticket #48252 - db2index creates index entry from deleted records
Bug Description: When an entry is deleted, its indexed attribute values
are also removed from each index file. But if the entry is turned to be
a tombstone entry, reindexing adds the removed attribute value back to
the index file.
Fix Description: In the reindexing function ldbm_back_ldbm2index, if the
entry is a tombstone entry, it skips reindexing operation unless the target
attribute is entryrdn or objectclass. If it is reindexing the objectclass,
it indexes just for the key "=nstombstone".
https://fedorahosted.org/389/ticket/48252
Reviewed by [email protected] (Thank you, Mark!!)
|
commit ca4d38dff3bd820af2bf60c9bcc82fd64aac2556
Author: Noriko Hosoi <[email protected]>
Date: Fri Aug 21 12:10:27 2015 -0700
Ticket #48252 - db2index creates index entry from deleted records
Bug Description: When an entry is deleted, its indexed attribute values
are also removed from each index file. But if the entry is turned to be
a tombstone entry, reindexing adds the removed attribute value back to
the index file.
Fix Description: In the reindexing function ldbm_back_ldbm2index, if the
entry is a tombstone entry, it skips reindexing operation unless the target
attribute is entryrdn or objectclass. If it is reindexing the objectclass,
it indexes just for the key "=nstombstone".
https://fedorahosted.org/389/ticket/48252
Reviewed by [email protected] (Thank you, Mark!!)
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index a1b4a9f5f..3d07b2eca 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -25,9 +25,12 @@
static char *sourcefile = "ldif2ldbm.c";
-#define DB2INDEX_ANCESTORID 0x1 /* index ancestorid */
-#define DB2INDEX_ENTRYRDN 0x2 /* index entryrdn */
-#define DB2LDIF_ENTRYRDN 0x4 /* export entryrdn */
+#define DB2INDEX_ANCESTORID 0x1 /* index ancestorid */
+#define DB2INDEX_ENTRYRDN 0x2 /* index entryrdn */
+#define DB2LDIF_ENTRYRDN 0x4 /* export entryrdn */
+#define DB2INDEX_OBJECTCLASS 0x10 /* for reindexing "objectclass: nstombstone" */
+
+#define LDIF2LDBM_EXTBITS(x) ((x) & 0xf)
typedef struct _export_args {
struct backentry *ep;
@@ -1675,6 +1678,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
struct vlvIndex *vlvip = NULL;
back_txn txn;
ID suffixid = NOID; /* holds the id of the suffix entry */
+ Slapi_Value **nstombstone_vals = NULL;
LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2index\n", 0, 0, 0 );
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -1795,7 +1799,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
if (strcasecmp(attrs[i]+1, LDBM_ANCESTORID_STR) == 0) {
if (task) {
slapi_task_log_notice(task, "%s: Indexing %s",
- inst->inst_name, LDBM_ENTRYRDN_STR);
+ inst->inst_name, LDBM_ANCESTORID_STR);
}
LDAPDebug2Args(LDAP_DEBUG_ANY, "%s: Indexing %s\n",
inst->inst_name, LDBM_ANCESTORID_STR);
@@ -1848,6 +1852,9 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
inst->inst_name, attrs[i] + 1);
}
} else {
+ if (strcasecmp(attrs[i]+1, SLAPI_ATTR_OBJECTCLASS) == 0) {
+ index_ext |= DB2INDEX_OBJECTCLASS;
+ }
charray_add(&indexAttrs, attrs[i]+1);
ai->ai_indexmask |= INDEX_OFFLINE;
if (task) {
@@ -1893,7 +1900,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
* idl composed from the ancestorid list, instead of traversing the
* entire database.
*/
- if (!indexAttrs && !index_ext && pvlv) {
+ if (!indexAttrs && !LDIF2LDBM_EXTBITS(index_ext) && pvlv) {
int err;
char **suffix_list = NULL;
@@ -2152,11 +2159,13 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* If this entry is a tombstone, update the 'nstombstonecsn' index
*/
- if(ep->ep_entry->e_flags & SLAPI_ENTRY_FLAG_TOMBSTONE){
- const CSN *tombstone_csn = NULL;
+ if (ep->ep_entry->e_flags & SLAPI_ENTRY_FLAG_TOMBSTONE) {
+ const CSN *tombstone_csn = entry_get_deletion_csn(ep->ep_entry);
char deletion_csn_str[CSN_STRSIZE];
- if((tombstone_csn = entry_get_deletion_csn(ep->ep_entry))){
+ nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
+ *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ if (tombstone_csn) {
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
if (0 != rc) {
@@ -2215,18 +2224,31 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* Update the attribute indexes
*/
- if (indexAttrs != NULL) {
+ if (indexAttrs) {
+ if (nstombstone_vals && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
+ /* if it is a tombstone entry, just entryrdn or "objectclass: nstombstone"
+ * need to be reindexed. the to-be-indexed list does not contain them. */
+ continue;
+ }
for (i = slapi_entry_first_attr(ep->ep_entry, &attr); i == 0;
i = slapi_entry_next_attr(ep->ep_entry, attr, &attr)) {
Slapi_Value **svals;
slapi_attr_get_type( attr, &type );
for ( j = 0; indexAttrs[j] != NULL; j++ ) {
+ int is_tombstone_obj = 0;
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
- if (slapi_attr_type_cmp(indexAttrs[j], type,
- SLAPI_TYPE_CMP_SUBTYPE) == 0 ) {
+ if (slapi_attr_type_cmp(indexAttrs[j], type, SLAPI_TYPE_CMP_SUBTYPE) == 0) {
+ if (nstombstone_vals) {
+ if (!slapi_attr_type_cmp(indexAttrs[j], SLAPI_ATTR_OBJECTCLASS, SLAPI_TYPE_CMP_SUBTYPE)) {
+ is_tombstone_obj = 1; /* is tombstone && is objectclass. need to index "nstombstone"*/
+ } else if (slapi_attr_type_cmp(indexAttrs[j], LDBM_ENTRYRDN_STR, SLAPI_TYPE_CMP_SUBTYPE)) {
+ /* Entry is a tombstone && this index is not an entryrdn. */
+ continue;
+ }
+ }
svals = attr_get_present_values(attr);
if (!run_from_cmdline) {
@@ -2250,10 +2272,12 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
goto err_out;
}
}
- rc = index_addordel_values_sv(
- be, indexAttrs[j], svals,
- NULL, ep->ep_id, BE_INDEX_ADD, &txn);
- if (rc != 0) {
+ if (is_tombstone_obj) {
+ rc = index_addordel_values_sv(be, indexAttrs[j], nstombstone_vals, NULL, ep->ep_id, BE_INDEX_ADD, &txn);
+ } else {
+ rc = index_addordel_values_sv(be, indexAttrs[j], svals, NULL, ep->ep_id, BE_INDEX_ADD, &txn);
+ }
+ if (rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to update index '%s'\n",
inst->inst_name, indexAttrs[j], 0);
@@ -2299,18 +2323,16 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
}
/*
- * Update the Virtual List View indexes
+ * If it is NOT a tombstone entry, update the Virtual List View indexes.
*/
- for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+ for (vlvidx = 0; !nstombstone_vals && (vlvidx < numvlv); vlvidx++) {
char *ai = "Unknown index";
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
- if(indexAttrs){
- if(indexAttrs[vlvidx]){
- ai = indexAttrs[vlvidx];
- }
+ if (indexAttrs && indexAttrs[vlvidx]) {
+ ai = indexAttrs[vlvidx];
}
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
@@ -2364,7 +2386,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* Update the ancestorid and entryrdn index
*/
- if (!entryrdn_get_noancestorid() && index_ext & DB2INDEX_ANCESTORID) {
+ if (!entryrdn_get_noancestorid() && (index_ext & DB2INDEX_ANCESTORID)) {
rc = ldbm_ancestorid_index_entry(be, ep, BE_INDEX_ADD, NULL);
if (rc != 0) {
LDAPDebug(LDAP_DEBUG_ANY,
| 0 |
7bb6a9a856600a99d9865b3aea02fb59ac975c66
|
389ds/389-ds-base
|
Ticket #48317: SELinux port labeling retry attempts are excessive
https://fedorahosted.org/389/ticket/48317
Bug Description: In dscreate.pm we attempt to label the ldap_port_t type 60
times in the case of a failure. This is excessive, and it means the setup-ds.pl
appears to hang in certain cases.
Fix Description:
Reduce this number to 5 attempts, and when debug is enabled, display the amount
of attempts remaining.
Author: [email protected]
Review by: [email protected] (Thank you Noriko!)
|
commit 7bb6a9a856600a99d9865b3aea02fb59ac975c66
Author: William Brown <[email protected]>
Date: Tue Nov 3 09:19:54 2015 +1000
Ticket #48317: SELinux port labeling retry attempts are excessive
https://fedorahosted.org/389/ticket/48317
Bug Description: In dscreate.pm we attempt to label the ldap_port_t type 60
times in the case of a failure. This is excessive, and it means the setup-ds.pl
appears to hang in certain cases.
Fix Description:
Reduce this number to 5 attempts, and when debug is enabled, display the amount
of attempts remaining.
Author: [email protected]
Review by: [email protected] (Thank you Noriko!)
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index 3ce5a7311..7f272f6ba 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -1011,10 +1011,11 @@ sub updateSelinuxPolicy {
if ($need_label == 1) {
my $semanage_err;
my $rc;
- my $retry = 60;
+ # 60 is a bit excessive, we should fail faster.
+ my $retry = 5;
$ENV{LANG} = "C";
while (($retry > 0) && ($semanage_err = `semanage port -a -t ldap_port_t -p tcp $inf->{slapd}->{ServerPort} 2>&1`) && ($rc = $?)) {
- debug(1, "Adding port $inf->{slapd}->{ServerPort} to selinux policy failed - $semanage_err (return code: $rc).\n");
+ debug(1, "Adding port $inf->{slapd}->{ServerPort} to selinux policy failed - $semanage_err (return code: $rc, $retry attempts remain).\n");
debug(1, "Retrying in 5 seconds\n");
sleep(5);
$retry--;
@@ -1413,13 +1414,13 @@ sub removeDSInstance {
{
my $semanage_err;
my $rc;
- my $retry = 60;
+ my $retry = 5;
$ENV{LANG} = "C";
while (($retry > 0) && ($semanage_err = `semanage port -d -t ldap_port_t -p tcp $port 2>&1`) && ($rc = $?)) {
if (($semanage_err =~ /defined in policy, cannot be deleted/) || ($semanage_err =~ /is not defined/)) {
$retry = -1;
} else {
- debug(1, "Warning: Port $port not removed from selinux policy correctly. Error: $semanage_err\n");
+ debug(1, "Warning: Port $port not removed from selinux policy correctly, $retry attempts remain. Error: $semanage_err\n");
debug(1, "Retrying in 5 seconds\n");
sleep(5);
$retry--;
| 0 |
d213146b92c90e4cc86843f6978c9badb4877eb6
|
389ds/389-ds-base
|
do not terminate unwrapped LDIF line with another newline
The function ldif_sput already terminates the line with a newline character -
we do not need to add another one when unwrapping a wrapped line.
|
commit d213146b92c90e4cc86843f6978c9badb4877eb6
Author: Rich Megginson <[email protected]>
Date: Fri Aug 20 12:33:01 2010 -0600
do not terminate unwrapped LDIF line with another newline
The function ldif_sput already terminates the line with a newline character -
we do not need to add another one when unwrapping a wrapped line.
diff --git a/ldap/servers/slapd/ldaputil.c b/ldap/servers/slapd/ldaputil.c
index 8b8cf94c3..2a9c965aa 100644
--- a/ldap/servers/slapd/ldaputil.c
+++ b/ldap/servers/slapd/ldaputil.c
@@ -228,7 +228,6 @@ slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const cha
}
*dest++ = *src;
}
- *dest = '\n';
}
#else
ldif_put_type_and_value_with_options( out, (char *)t, (char *)val, vlen, options );
| 0 |
6db4b30d1d7b3962764380bee9b8c563209407ff
|
389ds/389-ds-base
|
Resolves: bug 262021
Bug Description: Migration script does not migrate nsDS5ReplicaCredentials correctly.
Reviewed by: nkinder (Thanks!)
Fix Description: 7.1 and earlier chaining and replication credentials were stored incorrectly on little endian machines (x86 and itanium). They were "accidentally" stored correctly on big endian machines (sparc, pa-risc) because val == ntohl(val) on those platforms. When migrating from a little endian machine, we need to decode the password using the broken algorithm and re-encode it using the good method. We determine if the password is encode incorrectly by the following method: we use migratecred to decode and encode using the old path. If the values are equal, this means the password was already encoded correctly and we don't need to fix it. Otherwise, we set the flag that tells migratecred to fix it. In order to decode the broken password correctly on big endian machines, we have to swap the byte order to convert the values to little endian.
Platforms tested: RHEL5 x86_64, RHEL5 i386, Solaris 9
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
|
commit 6db4b30d1d7b3962764380bee9b8c563209407ff
Author: Rich Megginson <[email protected]>
Date: Mon Sep 24 22:54:55 2007 +0000
Resolves: bug 262021
Bug Description: Migration script does not migrate nsDS5ReplicaCredentials correctly.
Reviewed by: nkinder (Thanks!)
Fix Description: 7.1 and earlier chaining and replication credentials were stored incorrectly on little endian machines (x86 and itanium). They were "accidentally" stored correctly on big endian machines (sparc, pa-risc) because val == ntohl(val) on those platforms. When migrating from a little endian machine, we need to decode the password using the broken algorithm and re-encode it using the good method. We determine if the password is encode incorrectly by the following method: we use migratecred to decode and encode using the old path. If the values are equal, this means the password was already encoded correctly and we don't need to fix it. Otherwise, we set the flag that tells migratecred to fix it. In order to decode the broken password correctly on big endian machines, we have to swap the byte order to convert the values to little endian.
Platforms tested: RHEL5 x86_64, RHEL5 i386, Solaris 9
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 b6d5a7f5d..2be458602 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -179,10 +179,20 @@ sub getNewDbDir {
sub migrateCredentials {
my ($ent, $attr, $mig, $inst) = @_;
my $oldval = $ent->getValues($attr);
+
+ # Older versions of the server on x86 systems and other systems that do not use network byte order
+ # stored the credentials incorrectly. The first step is to determine if this is the case. We
+ # migrate using the same server root to see if we get the same output as we input.
+ debug(3, "In migrateCredentials - see how old credentials were encoded.\n");
+ my $testval = `@bindir@/migratecred -o $mig->{actualsroot}/$inst -n $mig->{actualsroot}/$inst -c \'$oldval\'`;
+ if ($testval ne $oldval) { # need to turn on the special flag
+ debug(3, "Credentials not encoded correctly. oldval $oldval not equal to testval $testval. The value will be re-encoded correctly.\n");
+ $ENV{MIGRATE_BROKEN_PWD} = "1"; # decode and re-encode correctly
+ }
+
debug(3, "Executing @bindir@/migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c \'$oldval\' . . .\n");
- $ENV{MIGRATE_BROKEN_PWD} = "1"; # passwords prior to 8.0 were encrypted incorrectly
my $newval = `@bindir@/migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c \'$oldval\'`;
- delete $ENV{MIGRATE_BROKEN_PWD}; # clear the flag
+ delete $ENV{MIGRATE_BROKEN_PWD}; # clear the flag, if set
debug(3, "Converted old value [$oldval] to new value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
return $newval;
}
diff --git a/ldap/admin/src/scripts/Migration.pm.in b/ldap/admin/src/scripts/Migration.pm.in
index 0192b97c6..aa26a8432 100644
--- a/ldap/admin/src/scripts/Migration.pm.in
+++ b/ldap/admin/src/scripts/Migration.pm.in
@@ -128,17 +128,7 @@ e.g.
or
"slapd.Suffix=dc=example, dc=com"
Values passed in this manner will override values in an .inf file
-given with the -f argument. If you need to specify the cleartext
-directory manager password (e.g. in order to do remote migration),
-you must specify the password for each instance in a section whose
-name is the instance name e.g.
- [slapd-ldap1]
- RootDNPwd=ldap1password
- [slapd-ldap2]
- RootDNPwd=ldap2password
-or on the command line like this:
- command ... slapd-ldap1.RootDNPwd=ldap1password \
- slapd-ldap2.RootDNPwd=ldap2password ...
+given with the -f argument.
actualsroot:
This is used when you must migrate from one machine to another. The
@@ -373,3 +363,10 @@ sub migrateSecurityFiles {
# Mandatory TRUE return value.
#
1;
+
+# emacs settings
+# Local Variables:
+# mode:perl
+# indent-tabs-mode: nil
+# tab-width: 4
+# End:
diff --git a/ldap/servers/plugins/rever/des.c b/ldap/servers/plugins/rever/des.c
index 0db0c4ab6..0966951bc 100644
--- a/ldap/servers/plugins/rever/des.c
+++ b/ldap/servers/plugins/rever/des.c
@@ -492,7 +492,7 @@ char *
migrateCredentials(char *oldpath, char *newpath, char *oldcred)
{
static char *useBrokenUUID = "USE_BROKEN_UUID=1";
- static char *disableBrokenUUID = "USE_BROKEN_UUID";
+ static char *disableBrokenUUID = "USE_BROKEN_UUID=0";
char *plain = NULL;
char *cipher = NULL;
diff --git a/ldap/servers/slapd/uuid.c b/ldap/servers/slapd/uuid.c
index 626b03303..3089de094 100644
--- a/ldap/servers/slapd/uuid.c
+++ b/ldap/servers/slapd/uuid.c
@@ -847,10 +847,16 @@ static void format_uuid_v1(guid_t * uuid, uuid_time_t timestamp, unsigned16 cloc
memcpy(&uuid->node, &_state.genstate.node, sizeof (uuid->node));
}
+/* when converting broken values, we may need to swap the bytes */
+#define BSWAP16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+#define BSWAP32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
/* format_uuid_v3 -- make a UUID from a (pseudo)random 128 bit number
*/
static void format_uuid_v3(guid_t * uuid, unsigned char hash[16])
{
+ char *use_broken_uuid = getenv("USE_BROKEN_UUID");
/* Construct a version 3 uuid with the (pseudo-)random number
* plus a few constants. */
@@ -858,11 +864,18 @@ static void format_uuid_v3(guid_t * uuid, unsigned char hash[16])
/* when migrating, we skip the ntohl in order to read in old,
incorrectly formatted uuids */
- if (!getenv("USE_BROKEN_UUID")) {
+ if (!use_broken_uuid || (*use_broken_uuid == '0')) {
/* convert UUID to local byte order */
uuid->time_low = PR_ntohl(uuid->time_low);
uuid->time_mid = PR_ntohs(uuid->time_mid);
uuid->time_hi_and_version = PR_ntohs(uuid->time_hi_and_version);
+ } else {
+#if defined(IS_BIG_ENDIAN)
+ /* convert UUID to b0rken byte order */
+ uuid->time_low = BSWAP32(uuid->time_low);
+ uuid->time_mid = BSWAP16(uuid->time_mid);
+ uuid->time_hi_and_version = BSWAP16(uuid->time_hi_and_version);
+#endif
}
/* put in the variant and version bits */
| 0 |
b68be619ceb59d9ad242841be4ebe2abb993d6d8
|
389ds/389-ds-base
|
Resolves: 430321
Summary: Fixed memory leak in collator plug-in.
|
commit b68be619ceb59d9ad242841be4ebe2abb993d6d8
Author: Nathan Kinder <[email protected]>
Date: Tue Nov 25 16:15:09 2008 +0000
Resolves: 430321
Summary: Fixed memory leak in collator plug-in.
diff --git a/ldap/servers/plugins/collation/collate.c b/ldap/servers/plugins/collation/collate.c
index e7e8195d8..06bb556a2 100644
--- a/ldap/servers/plugins/collation/collate.c
+++ b/ldap/servers/plugins/collation/collate.c
@@ -230,7 +230,6 @@ typedef struct collation_indexer_t
UCollator* collator;
UConverter* converter;
struct berval** ix_keys;
- int is_default_collator;
} collation_indexer_t;
/*
@@ -386,8 +385,8 @@ collation_indexer_destroy (indexer_t* ix)
ucnv_close(etc->converter);
etc->converter = NULL;
}
- if (!etc->is_default_collator) {
- /* Don't delete the default collation - it seems to cause problems */
+
+ if (etc->collator) {
ucol_close(etc->collator);
etc->collator = NULL;
}
@@ -469,7 +468,6 @@ collation_indexer_create (const char* oid)
oid, profile->decomposition, err);
}
etc->collator = coll;
- etc->is_default_collator = is_default;
for (id = collation_id; *id; ++id) {
if ((*id)->profile == profile) {
break; /* found the 'official' id */
| 0 |
0712904f21d8c33daa55e35b3ea6f65a4fc59de6
|
389ds/389-ds-base
|
Bug 611790 - fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
https://bugzilla.redhat.com/show_bug.cgi?id=611790
Resolves: bug 611790
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
Fix description: Catch possible NULL pointer in ruv_get_replica_generation().
Note: committing the fix on behalf of Endi ([email protected]).
|
commit 0712904f21d8c33daa55e35b3ea6f65a4fc59de6
Author: Noriko Hosoi <[email protected]>
Date: Mon Aug 23 17:23:32 2010 -0700
Bug 611790 - fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
https://bugzilla.redhat.com/show_bug.cgi?id=611790
Resolves: bug 611790
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
Fix description: Catch possible NULL pointer in ruv_get_replica_generation().
Note: committing the fix on behalf of Endi ([email protected]).
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
index 9f0d99a5c..78f7a53b3 100644
--- a/ldap/servers/plugins/replication/repl5_ruv.c
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
@@ -825,14 +825,18 @@ ruv_get_replica_generation(const RUV *ruv)
{
char *return_str = NULL;
- PR_RWLock_Rlock (ruv->lock);
+ if (!ruv) {
+ return return_str;
+ }
+
+ PR_RWLock_Rlock (ruv->lock);
if (ruv != NULL && ruv->replGen != NULL)
{
return_str = slapi_ch_strdup(ruv->replGen);
}
- PR_RWLock_Unlock (ruv->lock);
+ PR_RWLock_Unlock (ruv->lock);
return return_str;
}
| 0 |
f4d86bb9d65c5c69e497c0110cfb54cf684c182a
|
389ds/389-ds-base
|
Issue 49434 - RPM build errors
Bug Description:
When rpm is built on epel-7 (using mock), build fails because
python libraries and tests are installed, but not packaged.
Fix Description:
Don't install files if we don't plan to package them.
https://pagure.io/389-ds-base/issue/49434
Reviewed by: mreynolds (Thanks!)
|
commit f4d86bb9d65c5c69e497c0110cfb54cf684c182a
Author: Viktor Ashirov <[email protected]>
Date: Mon Oct 30 19:06:45 2017 +0100
Issue 49434 - RPM build errors
Bug Description:
When rpm is built on epel-7 (using mock), build fails because
python libraries and tests are installed, but not packaged.
Fix Description:
Don't install files if we don't plan to package them.
https://pagure.io/389-ds-base/issue/49434
Reviewed by: mreynolds (Thanks!)
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index 52e109504..2fac56032 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -282,6 +282,7 @@ autoreconf -fiv
$NSSARGS $TCMALLOC_FLAGS $ASAN_FLAGS \
--enable-cmocka
+%if 0%{?rhel} >= 8 || 0%{?fedora}
make setup.py
# lib389
@@ -291,7 +292,7 @@ popd
# tests
%py3_build
-
+%endif
# Generate symbolic info for debuggers
export XCFLAGS=$RPM_OPT_FLAGS
@@ -307,6 +308,7 @@ make DESTDIR="$RPM_BUILD_ROOT" install
# Copy in our docs from doxygen.
cp -r %{_builddir}/%{name}-%{version}%{?prerel}/man/man3 $RPM_BUILD_ROOT/%{_mandir}/man3
+%if 0%{?rhel} >= 8 || 0%{?fedora}
# lib389
pushd src/lib389
%py3_install
@@ -314,6 +316,7 @@ popd
# tests
%py3_install
+%endif
mkdir -p $RPM_BUILD_ROOT/var/log/%{pkgname}
mkdir -p $RPM_BUILD_ROOT/var/lib/%{pkgname}
| 0 |
68e08801b9e00ece45600fc81cf971786deaa36c
|
389ds/389-ds-base
|
Ticket 50165 - Fix dscreate issues
Description: There were some recent regressions about selinux in dscreate.
- When skipping labelling of default port an error message was incorrectly logged
- restorecon was not using the correct path
https://pagure.io/389-ds-base/issue/50165
Reviewed by: firstyear & mhonek (Thanks!!)
|
commit 68e08801b9e00ece45600fc81cf971786deaa36c
Author: Mark Reynolds <[email protected]>
Date: Tue Jan 15 15:40:59 2019 -0500
Ticket 50165 - Fix dscreate issues
Description: There were some recent regressions about selinux in dscreate.
- When skipping labelling of default port an error message was incorrectly logged
- restorecon was not using the correct path
https://pagure.io/389-ds-base/issue/50165
Reviewed by: firstyear & mhonek (Thanks!!)
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
index 931ed0506..d8c513ecd 100644
--- a/src/lib389/lib389/instance/setup.py
+++ b/src/lib389/lib389/instance/setup.py
@@ -828,7 +828,7 @@ class SetupDs(object):
selinux_paths = ('backup_dir', 'cert_dir', 'config_dir', 'db_dir', 'ldif_dir',
'lock_dir', 'log_dir', 'run_dir', 'schema_dir', 'tmp_dir')
for path in selinux_paths:
- selinux_restorecon(path)
+ selinux_restorecon(slapd[path])
selinux_label_port(slapd['port'])
diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index c06b3bced..0b90da26e 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -172,6 +172,7 @@ _chars = {
# Utilities
#
+
def selinux_restorecon(path):
"""
Relabel a filesystem rooted at path.
@@ -195,6 +196,7 @@ def selinux_restorecon(path):
except:
log.debug("Failed to run restorecon on: " + path)
+
def selinux_label_port(port, remove_label=False):
"""
Either set or remove an SELinux label(ldap_port_t) for a TCP port
@@ -225,7 +227,7 @@ def selinux_label_port(port, remove_label=False):
# a RH based system.
selinux_default_ports = [389, 636, 3268, 3269, 7389]
if port in selinux_default_ports:
- log.error('port %s already in %s, skipping port relabel' % (port, selinux_default_ports))
+ log.debug('port %s already in %s, skipping port relabel' % (port, selinux_default_ports))
return
label_set = False
| 0 |
cee5f058e10b6379d12b643e03eed81ee22a937d
|
389ds/389-ds-base
|
Bug 675113 - ns-slapd core dump in windows_tot_run if oneway sync is used
https://bugzilla.redhat.com/show_bug.cgi?id=675113
Resolves: bug 675113
Bug Description: ns-slapd core dump in windows_tot_run if oneway sync is used
Author: Carsten Grzemba <[email protected]>
Reviewed by: rmeggins
Branch: master
Fix Description: Init pb and dn to NULL to avoid free of uninit memory.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
|
commit cee5f058e10b6379d12b643e03eed81ee22a937d
Author: Rich Megginson <[email protected]>
Date: Mon Feb 14 12:21:19 2011 -0700
Bug 675113 - ns-slapd core dump in windows_tot_run if oneway sync is used
https://bugzilla.redhat.com/show_bug.cgi?id=675113
Resolves: bug 675113
Bug Description: ns-slapd core dump in windows_tot_run if oneway sync is used
Author: Carsten Grzemba <[email protected]>
Reviewed by: rmeggins
Branch: master
Fix Description: Init pb and dn to NULL to avoid free of uninit memory.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/windows_tot_protocol.c b/ldap/servers/plugins/replication/windows_tot_protocol.c
index 482d49d38..24d167576 100644
--- a/ldap/servers/plugins/replication/windows_tot_protocol.c
+++ b/ldap/servers/plugins/replication/windows_tot_protocol.c
@@ -98,8 +98,8 @@ windows_tot_run(Private_Repl_Protocol *prp)
{
int rc;
callback_data cb_data;
- Slapi_PBlock *pb;
- char* dn;
+ Slapi_PBlock *pb = NULL;
+ char* dn = NULL;
RUV *ruv = NULL;
RUV *starting_ruv = NULL;
Replica *replica = NULL;
| 0 |
115327c9e4163ef87c144cd19a82d1ee05a0c070
|
389ds/389-ds-base
|
Fix snprintf into sizeof(char *) instead of actual buffer size
|
commit 115327c9e4163ef87c144cd19a82d1ee05a0c070
Author: Rich Megginson <[email protected]>
Date: Fri Mar 18 20:28:29 2005 +0000
Fix snprintf into sizeof(char *) instead of actual buffer size
diff --git a/ldap/cm/newinstnt/dsinst.c b/ldap/cm/newinstnt/dsinst.c
index 5b1163820..5674604c8 100644
--- a/ldap/cm/newinstnt/dsinst.c
+++ b/ldap/cm/newinstnt/dsinst.c
@@ -908,7 +908,7 @@ int set_default_ldap_settings()
mi.m_nMCCPort=DEFAULT_SERVER_PORT;
mi.m_szMCCBindAs = malloc(MAX_STR_SIZE);
- my_snprintf(mi.m_szMCCBindAs, sizeof(mi.m_szMCCBindAs), "%s", DEFAULT_SSPT_USER);
+ my_snprintf(mi.m_szMCCBindAs, MAX_STR_SIZE, "%s", DEFAULT_SSPT_USER);
my_strncpy(mi.m_szUGSuffix, mi.m_szInstanceSuffix, sizeof(mi.m_szUGSuffix));
mi.m_nUGPort=DEFAULT_SERVER_PORT;
@@ -971,7 +971,7 @@ void set_ldap_settings()
my_strncpy(mi.m_szMCCHost, mi.m_szInstanceHostName, sizeof(mi.m_szMCCHost));
mi.m_nMCCPort = mi.m_nInstanceServerPort;
my_strncpy(mi.m_szMCCSuffix, NS_DOMAIN_ROOT, sizeof(mi.m_szMCCSuffix));
- my_snprintf(mi.m_szMCCBindAs, sizeof(mi.m_szMCCBindAs), "%s", mi.m_szSsptUid);
+ my_snprintf(mi.m_szMCCBindAs, MAX_STR_SIZE, "%s", mi.m_szSsptUid);
my_strncpy(mi.m_szMCCPw, mi.m_szSsptUidPw, sizeof(mi.m_szMCCPw));
}
| 0 |
3d0ae27c29cc3a0fb9c152b012903c63a94c5dd6
|
389ds/389-ds-base
|
Ticket 48204 - update lib389 test scripts for python 3
Description: Added support for python3, and also addressed certain failing
test scripts.
https://fedorahosted.org/389/ticket/48204
Reviewed by: rmeggins(Thanks!)
|
commit 3d0ae27c29cc3a0fb9c152b012903c63a94c5dd6
Author: Mark Reynolds <[email protected]>
Date: Fri Sep 25 20:17:21 2015 -0400
Ticket 48204 - update lib389 test scripts for python 3
Description: Added support for python3, and also addressed certain failing
test scripts.
https://fedorahosted.org/389/ticket/48204
Reviewed by: rmeggins(Thanks!)
diff --git a/dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py b/dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py
index c26a0a26c..06e742588 100644
--- a/dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py
+++ b/dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py
@@ -21,7 +21,8 @@ from lib389.utils import *
logging.getLogger(__name__).setLevel(logging.DEBUG)
log = logging.getLogger(__name__)
-
+USER1_DN = 'uid=user1,' + DEFAULT_SUFFIX
+USER2_DN = 'uid=user2,' + DEFAULT_SUFFIX
installation1_prefix = None
@@ -67,6 +68,8 @@ def test_attr_uniqueness_init(topology):
ldap.fatal('Failed to enable dynamic plugin!' + e.message['desc'])
assert False
+ topology.standalone.plugins.enable(name=PLUGIN_ATTR_UNIQUENESS)
+
def test_attr_uniqueness(topology):
log.info('Running test_attr_uniqueness...')
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index 9aec8ef10..d2f81ffbf 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -661,15 +661,16 @@ def test_basic_systemctl(topology, import_example_ldif):
log.fatal('test_basic_systemctl: The server incorrectly started')
assert False
log.info('Server failed to start as expected')
+ time.sleep(5)
#
# Fix the dse.ldif, and make sure the server starts up,
# and systemctl correctly identifies the successful start
#
shutil.copy(tmp_dir + 'dse.ldif', config_dir)
- log.info('Starting the server...')
+ log.info('Starting the server with good dse.ldif...')
rc = os.system(start_ds)
- time.sleep(10)
+ time.sleep(5)
log.info('Check the status...')
if rc != 0 or os.system(is_running) != 0:
log.fatal('test_basic_systemctl: Failed to start the server')
diff --git a/dirsrvtests/tickets/ticket47653MMR_test.py b/dirsrvtests/tickets/ticket47653MMR_test.py
index 0c6da0207..f951e5508 100644
--- a/dirsrvtests/tickets/ticket47653MMR_test.py
+++ b/dirsrvtests/tickets/ticket47653MMR_test.py
@@ -104,10 +104,9 @@ def topology(request):
master2.allocate(args_master)
# Get the status of the instance and restart it if it exists
- instance_master1 = master1.exists()
+ instance_master1 = master1.exists()
instance_master2 = master2.exists()
-
# Remove all the instances
if instance_master1:
master1.delete()
diff --git a/dirsrvtests/tickets/ticket47669_test.py b/dirsrvtests/tickets/ticket47669_test.py
index 5458fba86..2ef1f3e94 100644
--- a/dirsrvtests/tickets/ticket47669_test.py
+++ b/dirsrvtests/tickets/ticket47669_test.py
@@ -79,7 +79,7 @@ def topology(request):
return TopologyStandalone(standalone)
-def test_ticket47669_init(topo):
+def test_ticket47669_init(topology):
"""
Add cn=changelog5,cn=config
Enable cn=Retro Changelog Plugin,cn=plugins,cn=config
@@ -87,12 +87,12 @@ def test_ticket47669_init(topo):
log.info('Testing Ticket 47669 - Test duration syntax in the changelogs')
# bind as directory manager
- topo.standalone.log.info("Bind as %s" % DN_DM)
- topo.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.log.info("Bind as %s" % DN_DM)
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
try:
- changelogdir = "%s/changelog" % topo.standalone.dbdir
- topo.standalone.add_s(Entry((CHANGELOG,
+ changelogdir = "%s/changelog" % topology.standalone.dbdir
+ topology.standalone.add_s(Entry((CHANGELOG,
{'objectclass': 'top extensibleObject'.split(),
'nsslapd-changelogdir': changelogdir})))
except ldap.LDAPError as e:
@@ -100,23 +100,23 @@ def test_ticket47669_init(topo):
assert False
try:
- topo.standalone.modify_s(RETROCHANGELOG, [(ldap.MOD_REPLACE, 'nsslapd-pluginEnabled', 'on')])
+ topology.standalone.modify_s(RETROCHANGELOG, [(ldap.MOD_REPLACE, 'nsslapd-pluginEnabled', 'on')])
except ldap.LDAPError as e:
log.error('Failed to enable ' + RETROCHANGELOG + ': error ' + e.message['desc'])
assert False
# restart the server
- topo.standalone.restart(timeout=10)
+ topology.standalone.restart(timeout=10)
-def add_and_check(topo, plugin, attr, val, isvalid):
+def add_and_check(topology, plugin, attr, val, isvalid):
"""
Helper function to add/replace attr: val and check the added value
"""
if isvalid:
log.info('Test %s: %s -- valid' % (attr, val))
try:
- topo.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)])
+ topology.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)])
except ldap.LDAPError as e:
log.error('Failed to add ' + attr + ': ' + val + ' to ' + plugin + ': error ' + e.message['desc'])
assert False
@@ -124,17 +124,18 @@ def add_and_check(topo, plugin, attr, val, isvalid):
log.info('Test %s: %s -- invalid' % (attr, val))
if plugin == CHANGELOG:
try:
- topo.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)])
+ topology.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)])
except ldap.LDAPError as e:
- log.error('Expectedly failed to add ' + attr + ': ' + val + ' to ' + plugin + ': error ' + e.message['desc'])
+ log.error('Expectedly failed to add ' + attr + ': ' + val +
+ ' to ' + plugin + ': error ' + e.message['desc'])
else:
try:
- topo.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)])
+ topology.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)])
except ldap.LDAPError as e:
log.error('Failed to add ' + attr + ': ' + val + ' to ' + plugin + ': error ' + e.message['desc'])
try:
- entries = topo.standalone.search_s(plugin, ldap.SCOPE_BASE, FILTER, [attr])
+ entries = topology.standalone.search_s(plugin, ldap.SCOPE_BASE, FILTER, [attr])
if isvalid:
if not entries[0].hasValue(attr, val):
log.fatal('%s does not have expected (%s: %s)' % (plugin, attr, val))
@@ -153,86 +154,86 @@ def add_and_check(topo, plugin, attr, val, isvalid):
assert False
-def test_ticket47669_changelog_maxage(topo):
+def test_ticket47669_changelog_maxage(topology):
"""
Test nsslapd-changelogmaxage in cn=changelog5,cn=config
"""
log.info('1. Test nsslapd-changelogmaxage in cn=changelog5,cn=config')
# bind as directory manager
- topo.standalone.log.info("Bind as %s" % DN_DM)
- topo.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.log.info("Bind as %s" % DN_DM)
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
- add_and_check(topo, CHANGELOG, MAXAGE, '12345', True)
- add_and_check(topo, CHANGELOG, MAXAGE, '10s', True)
- add_and_check(topo, CHANGELOG, MAXAGE, '30M', True)
- add_and_check(topo, CHANGELOG, MAXAGE, '12h', True)
- add_and_check(topo, CHANGELOG, MAXAGE, '2D', True)
- add_and_check(topo, CHANGELOG, MAXAGE, '4w', True)
- add_and_check(topo, CHANGELOG, MAXAGE, '-123', False)
- add_and_check(topo, CHANGELOG, MAXAGE, 'xyz', False)
+ add_and_check(topology, CHANGELOG, MAXAGE, '12345', True)
+ add_and_check(topology, CHANGELOG, MAXAGE, '10s', True)
+ add_and_check(topology, CHANGELOG, MAXAGE, '30M', True)
+ add_and_check(topology, CHANGELOG, MAXAGE, '12h', True)
+ add_and_check(topology, CHANGELOG, MAXAGE, '2D', True)
+ add_and_check(topology, CHANGELOG, MAXAGE, '4w', True)
+ add_and_check(topology, CHANGELOG, MAXAGE, '-123', False)
+ add_and_check(topology, CHANGELOG, MAXAGE, 'xyz', False)
-def test_ticket47669_changelog_triminterval(topo):
+def test_ticket47669_changelog_triminterval(topology):
"""
Test nsslapd-changelogtrim-interval in cn=changelog5,cn=config
"""
log.info('2. Test nsslapd-changelogtrim-interval in cn=changelog5,cn=config')
# bind as directory manager
- topo.standalone.log.info("Bind as %s" % DN_DM)
- topo.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.log.info("Bind as %s" % DN_DM)
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, '12345', True)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, '10s', True)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, '30M', True)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, '12h', True)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, '2D', True)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, '4w', True)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, '-123', False)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, 'xyz', False)
+ add_and_check(topology, CHANGELOG, TRIMINTERVAL, '12345', True)
+ add_and_check(topology, CHANGELOG, TRIMINTERVAL, '10s', True)
+ add_and_check(topology, CHANGELOG, TRIMINTERVAL, '30M', True)
+ add_and_check(topology, CHANGELOG, TRIMINTERVAL, '12h', True)
+ add_and_check(topology, CHANGELOG, TRIMINTERVAL, '2D', True)
+ add_and_check(topology, CHANGELOG, TRIMINTERVAL, '4w', True)
+ add_and_check(topology, CHANGELOG, TRIMINTERVAL, '-123', False)
+ add_and_check(topology, CHANGELOG, TRIMINTERVAL, 'xyz', False)
-def test_ticket47669_changelog_compactdbinterval(topo):
+def test_ticket47669_changelog_compactdbinterval(topology):
"""
Test nsslapd-changelogcompactdb-interval in cn=changelog5,cn=config
"""
log.info('3. Test nsslapd-changelogcompactdb-interval in cn=changelog5,cn=config')
# bind as directory manager
- topo.standalone.log.info("Bind as %s" % DN_DM)
- topo.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology.standalone.log.info("Bind as %s" % DN_DM)
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '12345', True)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '10s', True)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '30M', True)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '12h', True)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '2D', True)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '4w', True)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '-123', False)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, 'xyz', False)
+ add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '12345', True)
+ add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '10s', True)
+ add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '30M', True)
+ add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '12h', True)
+ add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '2D', True)
+ add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '4w', True)
+ add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '-123', False)
+ add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, 'xyz', False)
-def test_ticket47669_retrochangelog_maxage(topo):
+def test_ticket47669_retrochangelog_maxage(topology):
"""
Test nsslapd-changelogmaxage in cn=Retro Changelog Plugin,cn=plugins,cn=config
"""
log.info('4. Test nsslapd-changelogmaxage in cn=Retro Changelog Plugin,cn=plugins,cn=config')
# bind as directory manager
- topo.standalone.log.info("Bind as %s" % DN_DM)
- topo.standalone.simple_bind_s(DN_DM, PASSWORD)
-
- add_and_check(topo, RETROCHANGELOG, MAXAGE, '12345', True)
- add_and_check(topo, RETROCHANGELOG, MAXAGE, '10s', True)
- add_and_check(topo, RETROCHANGELOG, MAXAGE, '30M', True)
- add_and_check(topo, RETROCHANGELOG, MAXAGE, '12h', True)
- add_and_check(topo, RETROCHANGELOG, MAXAGE, '2D', True)
- add_and_check(topo, RETROCHANGELOG, MAXAGE, '4w', True)
- add_and_check(topo, RETROCHANGELOG, MAXAGE, '-123', False)
- add_and_check(topo, RETROCHANGELOG, MAXAGE, 'xyz', False)
-
- topo.standalone.log.info("ticket47669 was successfully verified.")
+ topology.standalone.log.info("Bind as %s" % DN_DM)
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+
+ add_and_check(topology, RETROCHANGELOG, MAXAGE, '12345', True)
+ add_and_check(topology, RETROCHANGELOG, MAXAGE, '10s', True)
+ add_and_check(topology, RETROCHANGELOG, MAXAGE, '30M', True)
+ add_and_check(topology, RETROCHANGELOG, MAXAGE, '12h', True)
+ add_and_check(topology, RETROCHANGELOG, MAXAGE, '2D', True)
+ add_and_check(topology, RETROCHANGELOG, MAXAGE, '4w', True)
+ add_and_check(topology, RETROCHANGELOG, MAXAGE, '-123', False)
+ add_and_check(topology, RETROCHANGELOG, MAXAGE, 'xyz', False)
+
+ topology.standalone.log.info("ticket47669 was successfully verified.")
def test_ticket47669_final(topology):
diff --git a/dirsrvtests/tickets/ticket47714_test.py b/dirsrvtests/tickets/ticket47714_test.py
index 400c24367..268ddef58 100644
--- a/dirsrvtests/tickets/ticket47714_test.py
+++ b/dirsrvtests/tickets/ticket47714_test.py
@@ -209,22 +209,22 @@ def test_ticket47714_run_1(topology):
except ldap.CONSTRAINT_VIOLATION as e:
log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+ time.sleep(1)
+
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
entry = topology.standalone.search_s(TEST_USER_DN, ldap.SCOPE_BASE, SEARCHFILTER, ['lastLoginTime'])
-
lastLoginTime0 = entry[0].lastLoginTime
- time.sleep(2)
-
log.info("\n######################### Bind as %s again ######################\n" % TEST_USER_DN)
try:
topology.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW)
except ldap.CONSTRAINT_VIOLATION as e:
log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+ time.sleep(1)
+
topology.standalone.simple_bind_s(DN_DM, PASSWORD)
entry = topology.standalone.search_s(TEST_USER_DN, ldap.SCOPE_BASE, SEARCHFILTER, ['lastLoginTime'])
-
lastLoginTime1 = entry[0].lastLoginTime
log.info("First lastLoginTime: %s, Second lastLoginTime: %s" % (lastLoginTime0, lastLoginTime1))
| 0 |
64408bd7f22d4e85c01eaf638b643ef4900d3a1e
|
389ds/389-ds-base
|
add ability to build from open source components
|
commit 64408bd7f22d4e85c01eaf638b643ef4900d3a1e
Author: Rich Megginson <[email protected]>
Date: Fri Mar 18 21:38:53 2005 +0000
add ability to build from open source components
diff --git a/Makefile b/Makefile
index 4c7d2cb1a..3f9453489 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,6 @@ COMPONENT_DEPS := 1
include nsdefs.mk
include nsconfig.mk
-include ns_usedb.mk
# first (default) rule: build and create a DS package
all: buildAndPkgDirectory
@@ -35,6 +34,20 @@ help:
@echo " gmake pkgDirectory"
@echo " gmake pkgDirectoryl10n"
@echo " gmake pkgDirectoryPseudoL10n"
+ @echo " gmake with no arguments will do buildAndPkgDirectory, which "
+ @echo " is usually what you want to do"
+ @echo ""
+ @echo " The following are optional build flags which build or pull in"
+ @echo " optional components which are only available internally for"
+ @echo " now. In the future these components may be made available"
+ @echo " externally or in an open source version."
+ @echo " USE_ADMINSERVER=1 - bundle the Admin Server (required to run Console/webapps)"
+ @echo " USE_CONSOLE=1 - bundle the Administration Console (requires Java)"
+ @echo " USE_DSMLGW=1 - build/bundle the DSMLv2 Gateway (requires Java)"
+ @echo " USE_ORGCHART=1 - build/bundle the Org Chart webapp"
+ @echo " USE_DSGW=1 - build/bundle the Phonebook/DS Gateway webapp"
+ @echo " USE_JAVATOOLS=1 - build/bundle the Java command line tools"
+ @echo " USE_SETUPSDK=1 - build/bundle programs that use Setup SDK"
###### Implementation notes:
#
@@ -84,9 +97,13 @@ help:
#
###### End of implementation notes.
-components: $(ADMINUTIL_DEP) $(NSPR_DEP) $(ARLIB_DEP) $(DBM_DEP) $(SECURITY_DEP) $(SVRCORE_DEP) \
+ifeq ($(INTERNAL_BUILD), 1)
+ COMPONENT_DEPENDENCIES = $(ADMINUTIL_DEP) $(NSPR_DEP) $(ARLIB_DEP) $(DBM_DEP) $(SECURITY_DEP) $(SVRCORE_DEP) \
$(ICU_DEP) $(SETUPSDK_DEP) $(LDAPSDK_DEP) $(DB_LIB_DEP) $(SASL_DEP) $(PEER_DEP) \
$(AXIS_DEP) $(DSMLJAR_DEP)
+endif
+
+components: $(COMPONENT_DEPENDENCIES)
-@echo "The components are up to date"
ifeq ($(BUILD_JAVA_CODE),1)
@@ -202,14 +219,20 @@ cleanDirectory:
buildDirectoryConsole: consoleComponents java_platform_check
ifeq ($(BUILD_JAVA_CODE),1)
# cd ldap/admin/src/java/com/netscape/admin/dirserv; $(MAKE) $(MFLAGS) package
- cd ldap/admin/src/java/com/netscape/xmltools; $(MAKE) $(MFLAGS) package
+ ifeq ($(USE_JAVATOOLS), 1)
+ cd ldap/admin/src/java/com/netscape/xmltools; $(MAKE) $(MFLAGS) package
+ endif
endif
buildDirectoryClients: $(ANT_DEP) java_platform_check
ifeq ($(BUILD_JAVA_CODE),1)
- cd ldap/clients; $(MAKE) _dsmlgw
+ ifeq ($(USE_DSMLGW), 1)
+ cd ldap/clients; $(MAKE) _dsmlgw
+ endif
endif
+ifeq ($(USE_DSGW), 1)
cd ldap/clients; $(MAKE) _dsgw
+endif
$(OBJDIR):
if test ! -d $(OBJDIR); then mkdir -p $(OBJDIR); fi;
@@ -248,7 +271,9 @@ Longduration:
setupDirectory:
cd ldap/cm; $(MAKE) $(MFLAGS) releaseDirectory;
+ifeq ($(USE_SETUPSDK), 1)
cd ldap/cm; $(MAKE) $(MFLAGS) packageDirectory;
+endif
pkgDirectoryJars:
cd ldap/cm; $(MAKE) $(MFLAGS) packageJars
diff --git a/buildpaths.mk b/buildpaths.mk
new file mode 100644
index 000000000..c600d8d0c
--- /dev/null
+++ b/buildpaths.mk
@@ -0,0 +1,82 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright (C) 2005 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# This file is where you tell the build process where to find the
+# various components used during the build process.
+
+# You can either use components built locally from source or
+# pre-built components. The reason for the different macros
+# for SOURCE and BUILD is that the locations for the libs, includes,
+# etc. are usually different for packages built from source vs.
+# pre-built packages. As an example, when building NSPR from
+# source, the includes are in mozilla/dist/$(OBJDIR_NAME)/include
+# where OBJDIR_NAME includes the OS, arch, compiler, thread model, etc.
+# When using the pre-built NSPR from Mozilla FTP, the include files
+# are just in nsprdir/include. This is why we have to make the
+# distinction between a SOURCE component and a BUILD (pre-built)
+# component. See components.mk for the gory details.
+
+# For each component, specify the source root OR the pre-built
+# component directory. If both a SOURCE_ROOT and a BUILD_DIR are
+# defined for a component, the SOURCE_ROOT will be used - don't do
+# this, it's confusing.
+
+# For the Mozilla components, if using source for all of them,
+# you can just define MOZILLA_SOURCE_ROOT - the build will
+# assume all of them have been built in that same directory
+# (as per the recommended build instructions)
+
+# For all components, the recommended way is to put each
+# component in a subdirectory of the parent directory of
+# BUILD_ROOT, both with pre-built and source components
+
+MOZILLA_SOURCE_ROOT = $(BUILD_ROOT)/../mozilla
+ifdef MOZILLA_SOURCE_ROOT
+ # some of the mozilla components are put in a platform/buildtype specific
+ # subdir of mozilla/dist, and their naming convention is different than
+ # ours - we need to map ours to theirs
+ ifneq (,$(findstring RHEL3,$(NSOBJDIR_NAME)))
+ MOZ_OBJDIR_NAME = $(subst _gcc3_,_glibc_PTH_,$(subst RHEL3,Linux2.4,$(NSOBJDIR_NAME)))
+ else
+ ifneq (,$(findstring RHEL4,$(NSOBJDIR_NAME)))
+ MOZ_OBJDIR_NAME = $(subst _gcc3_,_glibc_PTH_,$(subst RHEL4,Linux2.6,$(NSOBJDIR_NAME)))
+ else
+ MOZ_OBJDIR_NAME = $(NSOBJDIR_NAME)
+ endif
+ endif
+endif
+
+NSPR_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+#NSPR_BUILD_DIR = $(BUILD_ROOT)/../nspr-4.4.1
+# NSPR also needs a build dir with a full, absolute path for some reason
+#NSPR_ABS_BUILD_DIR = $(shell cd $(NSPR_BUILD_DIR) && pwd)
+
+DBM_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+#DBM_BUILD_DIR = $(BUILD_ROOT)/../nss-3.9.3
+
+SECURITY_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+#SECURITY_BUILD_DIR = $(BUILD_ROOT)/../nss-3.9.3
+
+SVRCORE_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+#SVRCORE_BUILD_DIR = $(BUILD_ROOT)/../svrcore-4.0
+
+LDAPSDK_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+#LDAP_ROOT = $(BUILD_ROOT)/../ldapsdk-5.15
+
+SASL_SOURCE_ROOT = $(BUILD_ROOT)/../cyrus-sasl-2.1.20
+#SASL_BUILD_DIR = $(BUILD_ROOT)/../sasl
+
+ICU_SOURCE_ROOT = $(BUILD_ROOT)/../icu
+#ICU_BUILD_DIR = $(BUILD_ROOT)/../icu-2.4
+
+DB_SOURCE_ROOT = $(BUILD_ROOT)/../db-4.2.52.NC
+# DB_MAJOR_MINOR is the root name for the db shared library
+# source builds use db-4.2 - lib is prepended later
+DB_MAJOR_MINOR := db-4.2
+# internal builds rename this to be db42
+#DB_MAJOR_MINOR := db42
+#component_name:=$(DB_MAJOR_MINOR)
+#db_path_config:=$(BUILD_ROOT)/../$(component_name)
diff --git a/components.mk b/components.mk
index f4c4a93e3..8b7c090b6 100644
--- a/components.mk
+++ b/components.mk
@@ -78,10 +78,12 @@ PACKAGE_UNDER_JAVA =
# nls locale files are in libnls31/locale, but for packaging they need to
# go into lib/nls, not just lib; the destination should be a directory name;
# separate the src from the dest with a single space
+PACKAGE_SRC_DEST =
+
+# these defs are useful for doing pattern search/replace
COMMA := ,
NULLSTRING :=
SPACE := $(NULLSTRING) # the space is between the ) and the #
-PACKAGE_SRC_DEST =
ifeq ($(ARCH), WINNT)
EXE_SUFFIX = .exe
@@ -89,90 +91,11 @@ else # unix - windows has no lib name prefix, except for nspr
LIB_PREFIX = lib
endif
-# work around vsftpd -L problem
-ifeq ($(COMPONENT_PULL_METHOD), FTP)
-ifdef USING_VSFTPD
-VSFTPD_HACK=1
-endif
-endif
-
-# ADMINUTIL library #######################################
-ADMINUTIL_VERSION=$(ADMINUTIL_RELDATE)$(SEC_SUFFIX)
-ADMINUTIL_BASE=$(ADMINUTIL_VERSDIR)/${ADMINUTIL_VERSION}
-ADMSDKOBJDIR = $(FULL_RTL_OBJDIR)
-ADMINUTIL_IMPORT=$(COMPONENTS_DIR)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
-# this is the base directory under which the component's files will be found
-# during the build process
-ADMINUTIL_BUILD_DIR=$(NSCP_DISTDIR_FULL_RTL)/adminutil
-ADMINUTIL_LIBPATH=$(ADMINUTIL_BUILD_DIR)/lib
-ADMINUTIL_INCPATH=$(ADMINUTIL_BUILD_DIR)/include
-
-PACKAGE_SRC_DEST += $(ADMINUTIL_LIBPATH)/property bin/slapd/lib
-LIBS_TO_PKG += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
-LIBS_TO_PKG_CLIENTS += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
-
-#
-# Libadminutil
-#
-ADMINUTIL_DEP = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(LIB_SUFFIX)
-ifeq ($(ARCH), WINNT)
-ADMINUTIL_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil$(ADMINUTIL_VER).$(LIB_SUFFIX)
-ADMINUTIL_S_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil_s$(ADMINUTIL_VER).$(LIB_SUFFIX)
-LIBADMINUTILDLL_NAMES = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(DLL_SUFFIX)
+ifeq ($(INTERNAL_BUILD), 1)
+include $(BUILD_ROOT)/internal_buildpaths.mk
else
-ADMINUTIL_LINK=-L$(ADMINUTIL_LIBPATH) -ladminutil$(ADMINUTIL_VER)
+include $(BUILD_ROOT)/buildpaths.mk
endif
-ADMINUTIL_INCLUDE=-I$(ADMINUTIL_INCPATH) \
- -I$(ADMINUTIL_INCPATH)/libadminutil \
- -I$(ADMINUTIL_INCPATH)/libadmsslutil
-
-ifndef ADMINUTIL_PULL_METHOD
-ADMINUTIL_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(ADMINUTIL_DEP): ${NSCP_DISTDIR_FULL_RTL}
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(ADMINUTIL_PULL_METHOD) \
- -objdir $(ADMINUTIL_BUILD_DIR) \
- -componentdir $(ADMINUTIL_IMPORT) \
- -files include,lib
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component adminutil file $@" ; \
- fi
-###########################################################
-# Peer
-
-PEER_BUILD_DIR = $(NSCP_DISTDIR)/peer
-ifeq ($(ARCH), WINNT)
-# PEER_RELEASE = $(COMPONENTS_DIR)/peer/$(PEER_RELDATE)
-# PEER_FILES = include
-else
-PEER_RELEASE = $(COMPONENTS_DIR)/peer/$(PEER_RELDATE)/$(NSOBJDIR_NAME)
-PEER_FILES = obj
-PEER_DEP = $(PEER_OBJPATH)/ns-ldapagt
-endif
-# PEER_MGMTPATH = $(PEER_BUILD_DIR)/dev
-# PEER_INCDIR = $(PEER_BUILD_DIR)/include
-# PEER_BINPATH = $(PEER_BUILD_DIR)/dev
-PEER_OBJPATH = $(PEER_BUILD_DIR)/obj
-# PEER_INCLUDE = -I$(PEER_INCDIR)
-
-ifndef PEER_PULL_METHOD
-PEER_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(PEER_DEP): $(NSCP_DISTDIR)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(PEER_PULL_METHOD) \
- -objdir $(PEER_BUILD_DIR) -componentdir $(PEER_RELEASE) \
- -files $(PEER_FILES)
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component PEER file $@" ; \
- fi
-endif
-
-###########################################################
# NSPR20 Library
NSPR_LIBNAMES = plc4 plds4
@@ -185,19 +108,25 @@ LIBS_TO_PKG += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(NSPR_LIBPATH)/lib,ultras
endif
endif
NSPR_LIBNAMES += nspr4
-NSPR_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/nspr
-NSPR_ABS_BUILD_DIR = $(NSCP_ABS_DISTDIR_FULL_RTL)/nspr
-NSPR_LIBPATH = $(NSPR_BUILD_DIR)/lib
-NSPR_INCLUDE = -I$(NSPR_BUILD_DIR)/include
-NSPR_IMPORT = $(COMPONENTS_DIR)/nspr20/$(NSPR_RELDATE)/$(FULL_RTL_OBJDIR)
+ifdef NSPR_SOURCE_ROOT
+ NSPR_LIBPATH = $(NSPR_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/lib
+ NSPR_INCDIR = $(NSPR_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/include
+else
+ NSPR_LIBPATH = $(NSPR_BUILD_DIR)/lib
+ NSPR_INCDIR = $(NSPR_BUILD_DIR)/include
+endif
+NSPR_INCLUDE = -I$(NSPR_INCDIR)
NSPR_LIBS_TO_PKG = $(addsuffix .$(DLL_SUFFIX),$(addprefix $(NSPR_LIBPATH)/lib,$(NSPR_LIBNAMES)))
LIBS_TO_PKG += $(NSPR_LIBS_TO_PKG)
LIBS_TO_PKG_SHARED += $(NSPR_LIBS_TO_PKG) # needed for cmd line tools
-PACKAGE_SETUP_LIBS += $(NSPR_LIBS_TO_PKG)
-LIBS_TO_PKG_CLIENTS += $(NSPR_LIBS_TO_PKG) # for dsgw
+ifeq ($(USE_SETUPSDK), 1)
+ PACKAGE_SETUP_LIBS += $(NSPR_LIBS_TO_PKG)
+endif
+ifeq ($(USE_DSGW), 1)
+ LIBS_TO_PKG_CLIENTS += $(NSPR_LIBS_TO_PKG) # for dsgw
+endif
-NSPR_DEP = $(NSPR_LIBPATH)/libnspr4.$(LIB_SUFFIX)
ifeq ($(ARCH), WINNT)
NSPRDLL_NAME = $(addprefix lib, $(NSPR_LIBNAMES))
NSPROBJNAME = $(addsuffix .lib, $(NSPRDLL_NAME))
@@ -211,27 +140,15 @@ else
NSPRLINK = -L$(NSPR_LIBPATH) $(addprefix -l, $(NSPR_LIBNAMES))
endif
-ifndef NSPR_PULL_METHOD
-NSPR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(NSPR_DEP): $(NSCP_DISTDIR_FULL_RTL)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(NSPR_PULL_METHOD) \
- -objdir $(NSPR_BUILD_DIR) -componentdir $(NSPR_IMPORT) \
- -files lib,include
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component NSPR file $@" ; \
- fi
-
### DBM #############################
-DBM_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/dbm
-DBM_LIBPATH = $(DBM_BUILD_DIR)/lib
-DBM_INCDIR = $(DBM_BUILD_DIR)/include
-DBM_DEP = $(DBM_LIBPATH)/libdbm.$(LIB_SUFFIX)
-DBM_IMPORT = $(COMPONENTS_DIR)/dbm/$(DBM_RELDATE)/$(NSOBJDIR_NAME)
+ifdef DBM_SOURCE_ROOT
+ DBM_LIBPATH = $(DBM_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/lib
+ DBM_INCDIR = $(DBM_SOURCE_ROOT)/dist/public/dbm
+else
+ DBM_LIBPATH = $(DBM_BUILD_DIR)/lib
+ DBM_INCDIR = $(DBM_BUILD_DIR)/include
+endif
DBM_INCLUDE = -I$(DBM_INCDIR)
DBM_LIBNAMES = dbm
@@ -239,39 +156,25 @@ ifeq ($(ARCH), WINNT)
DBMOBJNAME = $(addsuffix .lib, $(DBM_LIBNAMES))
LIBDBM = $(addprefix $(DBM_LIBPATH)/, $(DBMOBJNAME))
DBMLINK = /LIBPATH:$(DBM_LIBPATH) $(DBMOBJNAME)
- DBM_DEP = $(DBM_LIBPATH)/dbm.$(LIB_SUFFIX)
else
DBM_SOLIBS = $(addsuffix .$(DLL_SUFFIX), $(addprefix $(LIB_PREFIX), $(DBM_LIBNAMES)))
DBMROBJNAME = $(addsuffix .a, $(addprefix $(LIB_PREFIX), $(DBM_LIBNAMES)))
LIBDBM = $(addprefix $(DBM_LIBPATH)/, $(DBMROBJNAME))
DBMLINK = -L$(DBM_LIBPATH) $(addprefix -l, $(DBM_LIBNAMES))
- DBM_DEP = $(DBM_LIBPATH)/libdbm.$(LIB_SUFFIX)
endif
-ifndef DBM_PULL_METHOD
-DBM_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(DBM_DEP): $(NSCP_DISTDIR_FULL_RTL)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(DBM_PULL_METHOD) \
- -objdir $(DBM_BUILD_DIR) -componentdir $(DBM_IMPORT)/.. \
- -files xpheader.jar -unzip $(DBM_INCDIR)
- $(FTP_PULL) -method $(DBM_PULL_METHOD) \
- -objdir $(DBM_BUILD_DIR) -componentdir $(DBM_IMPORT) \
- -files mdbinary.jar -unzip $(DBM_BUILD_DIR)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component DBM file $@" ; \
- fi
-
### DBM END #############################
### SECURITY #############################
-SECURITY_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/nss
-SECURITY_LIBPATH = $(SECURITY_BUILD_DIR)/lib
-SECURITY_BINPATH = $(SECURITY_BUILD_DIR)/bin
-SECURITY_INCDIR = $(SECURITY_BUILD_DIR)/include
+ifdef SECURITY_SOURCE_ROOT
+ SECURITY_LIBPATH = $(SECURITY_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/lib
+ SECURITY_BINPATH = $(SECURITY_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/bin
+ SECURITY_INCDIR = $(SECURITY_SOURCE_ROOT)/dist/public/nss
+else
+ SECURITY_LIBPATH = $(SECURITY_BUILD_DIR)/lib
+ SECURITY_BINPATH = $(SECURITY_BUILD_DIR)/bin
+ SECURITY_INCDIR = $(SECURITY_BUILD_DIR)/include
+endif
SECURITY_INCLUDE = -I$(SECURITY_INCDIR)
# add crlutil and ocspclnt when we support CRL and OCSP cert checking in DS
ifeq ($(SECURITY_RELDATE), NSS_3_7_9_RTM)
@@ -280,7 +183,6 @@ else
SECURITY_BINNAMES = certutil derdump pp pk12util ssltap modutil shlibsign
endif
SECURITY_LIBNAMES = ssl3 nss3 softokn3
-SECURITY_IMPORT = $(COMPONENTS_DIR)/nss/$(SECURITY_RELDATE)/$(FULL_RTL_OBJDIR)
SECURITY_LIBNAMES.pkg = $(SECURITY_LIBNAMES)
SECURITY_LIBNAMES.pkg += smime3
@@ -309,19 +211,21 @@ SECURITY_LIBS_TO_PKG += $(addsuffix .chk,$(addprefix $(SECURITY_LIBPATH)/$(LIB_P
endif
LIBS_TO_PKG += $(SECURITY_LIBS_TO_PKG)
LIBS_TO_PKG_SHARED += $(SECURITY_LIBS_TO_PKG) # for cmd line tools
-PACKAGE_SETUP_LIBS += $(SECURITY_LIBS_TO_PKG)
-LIBS_TO_PKG_CLIENTS += $(SECURITY_LIBS_TO_PKG) # for dsgw
+ifeq ($(USE_SETUPSDK), 1)
+ PACKAGE_SETUP_LIBS += $(SECURITY_LIBS_TO_PKG)
+endif
+ifeq ($(USE_DSGW), 1)
+ LIBS_TO_PKG_CLIENTS += $(SECURITY_LIBS_TO_PKG) # for dsgw
+endif
ifeq ($(ARCH), WINNT)
SECURITYOBJNAME = $(addsuffix .$(LIB_SUFFIX), $(SECURITY_LIBNAMES))
LIBSECURITY = $(addprefix $(SECURITY_LIBPATH)/, $(SECURITYOBJNAME))
SECURITYLINK = /LIBPATH:$(SECURITY_LIBPATH) $(SECURITYOBJNAME)
- SECURITY_DEP = $(SECURITY_LIBPATH)/ssl3.$(DLL_SUFFIX)
else
SECURITYOBJNAME = $(addsuffix .$(DLL_SUFFIX), $(addprefix $(LIB_PREFIX), $(SECURITY_LIBNAMES)))
LIBSECURITY = $(addprefix $(SECURITY_LIBPATH)/, $(SECURITYOBJNAME))
SECURITYLINK = -L$(SECURITY_LIBPATH) $(addprefix -l, $(SECURITY_LIBNAMES))
- SECURITY_DEP = $(SECURITY_LIBPATH)/libssl3.$(DLL_SUFFIX)
endif
# we need to package the root cert file in the alias directory
@@ -330,187 +234,71 @@ PACKAGE_SRC_DEST += $(SECURITY_LIBPATH)/$(LIB_PREFIX)nssckbi.$(DLL_SUFFIX) alias
# need to package the sec tools in shared/bin
BINS_TO_PKG_SHARED += $(SECURITY_TOOLS_FULLPATH)
-#ifeq ($(ARCH), OSF1)
-#OSF1SECURITYHACKOBJ = $(OBJDIR)/osf1securityhack.o
-
-#$(OSF1SECURITYHACKOBJ): $(BUILD_ROOT)/osf1securityhack.c
-# $(CC) -c $(CFLAGS) $(MCC_INCLUDE) $< -o $@
-
-# SECURITYLINK += $(OSF1SECURITYHACKOBJ)
-#endif
-
-ifdef VSFTPD_HACK
-SECURITY_FILES=lib,bin/$(subst $(SPACE),$(COMMA)bin/,$(SECURITY_TOOLS))
-else
-SECURITY_FILES=lib,include,bin/$(subst $(SPACE),$(COMMA)bin/,$(SECURITY_TOOLS))
-endif
-
-ifndef SECURITY_PULL_METHOD
-SECURITY_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(SECURITY_DEP): $(NSCP_DISTDIR_FULL_RTL) $(OSF1SECURITYHACKOBJ)
-ifdef COMPONENT_DEPS
- mkdir -p $(SECURITY_BINPATH)
- $(FTP_PULL) -method $(SECURITY_PULL_METHOD) \
- -objdir $(SECURITY_BUILD_DIR) -componentdir $(SECURITY_IMPORT) \
- -files $(SECURITY_FILES)
-ifdef VSFTPD_HACK
-# work around vsftpd -L problem
- $(FTP_PULL) -method $(SECURITY_PULL_METHOD) \
- -objdir $(SECURITY_BUILD_DIR) -componentdir $(COMPONENTS_DIR)/nss/$(SECURITY_RELDATE) \
- -files include
-endif
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component NSS file $@" ; \
- fi
-
### SECURITY END #############################
### SVRCORE #############################
-SVRCORE_BUILD_DIR = $(NSCP_DISTDIR)/svrcore
-SVRCORE_LIBPATH = $(SVRCORE_BUILD_DIR)/lib
-SVRCORE_INCDIR = $(SVRCORE_BUILD_DIR)/include
+ifdef SVRCORE_SOURCE_ROOT
+ SVRCORE_LIBPATH = $(SVRCORE_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/lib
+ SVRCORE_INCDIR = $(SVRCORE_SOURCE_ROOT)/dist/public/svrcore
+else
+ SVRCORE_LIBPATH = $(SVRCORE_BUILD_DIR)/lib
+ SVRCORE_INCDIR = $(SVRCORE_BUILD_DIR)/include
+endif
SVRCORE_INCLUDE = -I$(SVRCORE_INCDIR)
-#SVRCORE_LIBNAMES = svrplcy svrcore
SVRCORE_LIBNAMES = svrcore
-SVRCORE_IMPORT = $(COMPONENTS_DIR)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
-#SVRCORE_IMPORT = $(COMPONENTS_DIR_DEV)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
ifeq ($(ARCH), WINNT)
SVRCOREOBJNAME = $(addsuffix .lib, $(SVRCORE_LIBNAMES))
LIBSVRCORE = $(addprefix $(SVRCORE_LIBPATH)/, $(SVRCOREOBJNAME))
SVRCORELINK = /LIBPATH:$(SVRCORE_LIBPATH) $(SVRCOREOBJNAME)
- SVRCORE_DEP = $(SVRCORE_LIBPATH)/svrcore.$(LIB_SUFFIX)
else
SVRCOREOBJNAME = $(addsuffix .a, $(addprefix $(LIB_PREFIX), $(SVRCORE_LIBNAMES)))
LIBSVRCORE = $(addprefix $(SVRCORE_LIBPATH)/, $(SVRCOREOBJNAME))
-ifeq ($(ARCH), OSF1)
-# the -all flag is used by default. This flag causes _all_ objects in lib.a files to
-# be processed and linked. This causes problems with svrcore because there are
-# several undefined symbols (notably, the JSS_xxx functions)
- SVRCORELINK = -L$(SVRCORE_LIBPATH) -none $(addprefix -l, $(SVRCORE_LIBNAMES)) -all
-else
SVRCORELINK = -L$(SVRCORE_LIBPATH) $(addprefix -l, $(SVRCORE_LIBNAMES))
endif
- SVRCORE_DEP = $(SVRCORE_LIBPATH)/libsvrcore.$(LIB_SUFFIX)
-endif
-
-ifndef SVRCORE_PULL_METHOD
-SVRCORE_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(SVRCORE_DEP): $(NSCP_DISTDIR)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(SVRCORE_PULL_METHOD) \
- -objdir $(SVRCORE_BUILD_DIR) -componentdir $(SVRCORE_IMPORT)/.. \
- -files xpheader.jar -unzip $(SVRCORE_INCDIR)
- $(FTP_PULL) -method $(SVRCORE_PULL_METHOD) \
- -objdir $(SVRCORE_BUILD_DIR) -componentdir $(SVRCORE_IMPORT) \
- -files mdbinary.jar -unzip $(SVRCORE_BUILD_DIR)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component SVRCORE file $@" ; \
- fi
### SVRCORE END #############################
-### SETUPSDK #############################
-# this is where the build looks for setupsdk components
-SETUP_SDK_BUILD_DIR = $(NSCP_DISTDIR)/setupsdk
-SETUPSDK_VERSION = $(SETUP_SDK_RELDATE)$(SEC_SUFFIX)
-SETUPSDK_RELEASE = $(COMPONENTS_DIR)/setupsdk/$(SETUPSDK_VERSDIR)/$(SETUPSDK_VERSION)/$(NSOBJDIR_NAME)
-SETUPSDK_LIBPATH = $(SETUP_SDK_BUILD_DIR)/lib
-SETUPSDK_INCDIR = $(SETUP_SDK_BUILD_DIR)/include
-SETUPSDK_BINPATH = $(SETUP_SDK_BUILD_DIR)/bin
-SETUPSDK_INCLUDE = -I$(SETUPSDK_INCDIR)
-
-ifeq ($(ARCH), WINNT)
-SETUP_SDK_FILES = setupsdk.tar.gz -unzip $(NSCP_DISTDIR)/setupsdk
-SETUPSDK_DEP = $(SETUPSDK_LIBPATH)/nssetup32.$(LIB_SUFFIX)
-SETUPSDKLINK = /LIBPATH:$(SETUPSDK_LIBPATH) nssetup32.$(LIB_SUFFIX)
-SETUPSDK_S_LINK = /LIBPATH:$(SETUPSDK_LIBPATH) nssetup32_s.$(LIB_SUFFIX)
-else
-SETUP_SDK_FILES = bin,lib,include
-SETUPSDK_DEP = $(SETUPSDK_LIBPATH)/libinstall.$(LIB_SUFFIX)
-SETUPSDKLINK = -L$(SETUPSDK_LIBPATH) -linstall
-SETUPSDK_S_LINK = $(SETUPSDKLINK)
-endif
-
-ifndef SETUPSDK_PULL_METHOD
-SETUPSDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(SETUPSDK_DEP): $(NSCP_DISTDIR)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(SETUPSDK_PULL_METHOD) \
- -objdir $(SETUP_SDK_BUILD_DIR) -componentdir $(SETUPSDK_RELEASE) \
- -files $(SETUP_SDK_FILES)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component SETUPSDK file $@" ; \
- fi
-
####################################################
# LDAP SDK
###################################################
-ifndef LDAP_VERSION
- LDAP_VERSION = $(LDAP_RELDATE)$(SEC_SUFFIX)
-endif
-LDAP_ROOT = $(NSCP_DISTDIR_FULL_RTL)/ldapsdk
-LDAPSDK_LIBPATH = $(LDAP_ROOT)/lib
-LDAPSDK_INCDIR = $(LDAP_ROOT)/include
-LDAPSDK_INCLUDE = -I$(LDAPSDK_INCDIR)
-ifndef LDAP_SBC
-# LDAP_SBC = $(COMPONENTS_DIR_DEV)
-LDAP_SBC = $(COMPONENTS_DIR)
+ifdef LDAPSDK_SOURCE_ROOT
+ LDAPSDK_LIBPATH = $(LDAPSDK_SOURCE_ROOT)/dist/lib
+ LDAPSDK_INCDIR = $(LDAPSDK_SOURCE_ROOT)/dist/public/ldap
+ LDAPSDK_BINPATH = $(LDAPSDK_SOURCE_ROOT)/dist/bin
+else
+ LDAPSDK_LIBPATH = $(LDAP_ROOT)/lib
+ LDAPSDK_INCDIR = $(LDAP_ROOT)/include
+ LDAPSDK_BINPATH = $(LDAP_ROOT)/tools
endif
+LDAPSDK_INCLUDE = -I$(LDAPSDK_INCDIR)
# package the command line programs
-LDAPSDK_TOOLS = $(wildcard $(LDAP_ROOT)/tools/*$(EXE_SUFFIX))
+LDAPSDK_TOOLS = $(wildcard $(LDAPSDK_BINPATH)/ldap*$(EXE_SUFFIX))
BINS_TO_PKG_SHARED += $(LDAPSDK_TOOLS)
# package the include files - needed for the plugin API
LDAPSDK_INCLUDE_FILES = $(wildcard $(LDAPSDK_INCDIR)/*.h)
PACKAGE_SRC_DEST += $(subst $(SPACE),$(SPACE)plugins/slapd/slapi/include$(SPACE),$(LDAPSDK_INCLUDE_FILES))
PACKAGE_SRC_DEST += plugins/slapd/slapi/include
-LDAPOBJDIR = $(FULL_RTL_OBJDIR)
ifeq ($(ARCH), WINNT)
- ifeq ($(PROCESSOR), ALPHA)
- ifeq ($(DEBUG), full)
- LDAPOBJDIR = WINNTALPHA3.51_DBG.OBJ
- else
- LDAPOBJDIR = WINNTALPHA3.51_OPT.OBJ
- endif
- endif
-
- LDAP_RELEASE = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(LDAPOBJDIR)
LDAP_LIBNAMES = ldapssl32v$(LDAP_SUF) ldap32v$(LDAP_SUF) ldappr32v$(LDAP_SUF)
LDAPDLL_NAME = $(addprefix ns, $(LDAP_LIBNAMES))
LDAPOBJNAME = $(addsuffix .$(LIB_SUFFIX), $(LDAPDLL_NAME))
LDAPLINK = /LIBPATH:$(LDAPSDK_LIBPATH) $(LDAPOBJNAME)
LDAP_NOSSL_LINK = /LIBPATH:$(LDAPSDK_LIBPATH) nsldap32v$(LDAP_SUF).$(LIB_SUFFIX)
LIBLDAPDLL_NAMES = $(addsuffix .dll, $(addprefix $(LDAP_LIBPATH)/, $(LDAPDLL_NAME)))
- LDAPSDK_DEP = $(LDAPSDK_LIBPATH)/nsldap32v$(LDAP_SUF).$(DLL_SUFFIX)
- LDAPSDK_PULL_LIBS = lib/nsldapssl32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldapssl32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX),lib/nsldap32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldap32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX),lib/nsldappr32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldappr32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX)
LIBS_TO_PKG += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
- PACKAGE_SETUP_LIBS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
LIBS_TO_PKG_SHARED += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
- LIBS_TO_PKG_CLIENTS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
-endif
-
-# override LDAP version in OS specific section
-ifneq ($(ARCH), WINNT)
-# LDAP Does not has PTH version, so here is the hack which treat non PTH
-# version as PTH version
- ifeq ($(USE_PTHREADS), 1)
- LDAP_RELEASE = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(NSOBJDIR_NAME1)
- else
- LDAP_RELEASE = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(LDAPOBJDIR)
+ ifeq ($(USE_SETUPSDK), 1)
+ PACKAGE_SETUP_LIBS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
+ endif
+ ifeq ($(USE_DSGW), 1)
+ LIBS_TO_PKG_CLIENTS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
endif
+else # not WINNT
LDAP_SOLIB_NAMES = ssldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) ldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) prldap$(LDAP_SUF)$(LDAP_DLL_PRESUF)
ifndef LDAP_NO_LIBLCACHE
LDAP_SOLIB_NAMES += lcache30$(LDAP_DLL_PRESUF)
@@ -520,489 +308,128 @@ ifneq ($(ARCH), WINNT)
LDAP_SOLIBS = $(addsuffix .$(LDAP_DLL_SUFFIX), $(addprefix $(LIB_PREFIX), $(LDAP_SOLIB_NAMES)))
LDAPOBJNAME = $(addsuffix .$(LIB_SUFFIX), $(addprefix $(LIB_PREFIX), $(LDAP_DOTALIB_NAMES))) \
$(LDAP_SOLIBS)
- LDAPSDK_DEP = $(LDAPSDK_LIBPATH)/libldap$(LDAP_SUF).$(DLL_SUFFIX)
LDAPLINK = -L$(LDAPSDK_LIBPATH) $(addprefix -l,$(LDAP_SOLIB_NAMES))
LDAP_NOSSL_LINK = -L$(LDAPSDK_LIBPATH) -lldap$(LDAP_SUF)$(LDAP_DLL_PRESUF)
- LDAPSDK_PULL_LIBS = lib/libssldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX),lib/libldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX),lib/libprldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX)
LIBS_TO_PKG += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
- PACKAGE_SETUP_LIBS += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
LIBS_TO_PKG_SHARED += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
- LIBS_TO_PKG_CLIENTS += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
+ ifeq ($(USE_SETUPSDK), 1)
+ PACKAGE_SETUP_LIBS += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
+ endif
+ ifeq ($(USE_DSGW), 1)
+ LIBS_TO_PKG_CLIENTS += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
+ endif
endif
-LDAP_LIBPATH = $(LDAP_ROOT)/lib
-LDAP_INCLUDE = $(LDAP_ROOT)/include
-LDAP_TOOLDIR = $(LDAP_ROOT)/tools
+LDAP_LIBPATH = $(LDAPSDK_LIBPATH)
+LDAP_INCLUDE = $(LDAPSDK_INCDIR)
+LDAP_TOOLDIR = $(LDAPSDK_BINPATH)
LIBLDAP = $(addprefix $(LDAP_LIBPATH)/, $(LDAPOBJNAME))
-LDAPSDK_FILES = include,$(LDAPSDK_PULL_LIBS),tools
-
-ifndef LDAPSDK_PULL_METHOD
-LDAPSDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(LDAPSDK_DEP): $(NSCP_DISTDIR_FULL_RTL)
-ifdef COMPONENT_DEPS
- mkdir -p $(LDAP_LIBPATH)
- $(FTP_PULL) -method $(LDAPSDK_PULL_METHOD) \
- -objdir $(LDAP_ROOT) -componentdir $(LDAP_RELEASE) \
- -files $(LDAPSDK_FILES)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component LDAPSDK file $@" ; \
- fi
-
-# apache-axis java classes #######################################
-AXIS = axis-bin-$(AXIS_VERSION).zip
-AXIS_FILES = $(AXIS)
-AXIS_RELEASE = $(COMPONENTS_DIR)/axis
-#AXISJAR_DIR = $(AXISJAR_RELEASE)/$(AXISJAR_COMP)/$(AXISJAR_VERSION)
-AXIS_DIR = $(AXIS_RELEASE)/$(AXIS_VERSION)
-AXIS_FILE = $(CLASS_DEST)/$(AXIS)
-AXIS_DEP = $(AXIS_FILE)
-AXIS_REL_DIR=$(subst -bin,,$(subst .zip,,$(AXIS)))
-
-
-# This is java, so there is only one real platform subdirectory
-
-#PACKAGE_UNDER_JAVA += $(AXIS_FILE)
-
-ifndef AXIS_PULL_METHOD
-AXIS_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(AXIS_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- echo "Inside ftppull"
- $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(AXIS_DIR) \
- -files $(AXIS_FILES) -unzip $(CLASS_DEST)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component AXIS files $@" ; \
- fi
-
-###########################################################
-
-
-# other dsml java classes #######################################
-DSMLJAR = activation.jar,jaxrpc-api.jar,jaxrpc.jar,saaj.jar,xercesImpl.jar,xml-apis.jar
-DSMLJAR_FILES = $(DSMLJAR)
-DSMLJAR_RELEASE = $(COMPONENTS_DIR)
-#DSMLJARJAR_DIR = $(DSMLJARJAR_RELEASE)/$(DSMLJARJAR_COMP)/$(DSMLJARJAR_VERSION)
-DSMLJAR_DIR = $(DSMLJAR_RELEASE)/dsmljars
-DSMLJAR_FILE = $(CLASS_DEST)
-DSMLJAR_DEP = $(CLASS_DEST)/activation.jar $(CLASS_DEST)/jaxrpc-api.jar $(CLASS_DEST)/jaxrpc.jar $(CLASS_DEST)/saaj.jar $(CLASS_DEST)/xercesImpl.jar $(CLASS_DEST)/xml-apis.jar
-ifndef DSMLJAR_PULL_METHOD
-DSMLJAR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(DSMLJAR_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- echo "Inside ftppull"
- $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(DSMLJAR_DIR) \
- -files $(DSMLJAR_FILES)
-
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component DSMLJAR files $@" ; \
- fi
-
-###########################################################
-
-# XMLTOOLS java classes #######################################
-CRIMSONJAR = crimson.jar
-CRIMSON_LICENSE = LICENSE.crimson
-CRIMSONJAR_FILES = $(CRIMSONJAR),$(CRIMSON_LICENSE)
-CRIMSONJAR_RELEASE = $(COMPONENTS_DIR)
-CRIMSONJAR_DIR = $(CRIMSONJAR_RELEASE)/$(CRIMSONJAR_COMP)/$(CRIMSONJAR_VERSION)
-CRIMSONJAR_FILE = $(CLASS_DEST)/$(CRIMSONJAR)
-CRIMSONJAR_DEP = $(CRIMSONJAR_FILE) $(CLASS_DEST)/$(CRIMSON_LICENSE)
-
-
-# This is java, so there is only one real platform subdirectory
-
-PACKAGE_UNDER_JAVA += $(CRIMSONJAR_FILE)
-
-ifndef CRIMSONJAR_PULL_METHOD
-CRIMSONJAR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(CRIMSONJAR_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- echo "Inside ftppull"
- $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(CRIMSONJAR_DIR) \
- -files $(CRIMSONJAR_FILES)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component CRIMSONJAR files $@" ; \
- fi
-
-###########################################################
-
-# ANT java classes #######################################
-ifeq ($(BUILD_JAVA_CODE),1)
-# (we use ant for building some Java code)
-ANTJAR = ant.jar
-JAXPJAR = jaxp.jar
-ANT_FILES = $(ANTJAR) $(JAXPJAR)
-ANT_RELEASE = $(COMPONENTS_DIR)
-ANT_HOME = $(ANT_RELEASE)/$(ANT_COMP)/$(ANT_VERSION)
-ANT_DIR = $(ANT_HOME)/lib
-ANT_DEP = $(addprefix $(CLASS_DEST)/, $(ANT_FILES))
-ANT_CP = $(subst $(SPACE),$(PATH_SEP),$(ANT_DEP))
-ANT_PULL = $(subst $(SPACE),$(COMMA),$(ANT_FILES))
-
-ifndef ANT_PULL_METHOD
-ANT_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(ANT_DEP): $(CLASS_DEST) $(CRIMSONJAR_DEP)
-ifdef COMPONENT_DEPS
- echo "Inside ftppull"
- $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(ANT_DIR) \
- -files $(ANT_PULL)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component ant files $@" ; \
- fi
-endif
-###########################################################
-
-# Servlet SDK classes #######################################
-SERVLETJAR = servlet.jar
-SERVLET_FILES = $(SERVLETJAR)
-SERVLET_RELEASE = $(COMPONENTS_DIR)
-SERVLET_DIR = $(SERVLET_RELEASE)/$(SERVLET_COMP)/$(SERVLET_VERSION)
-SERVLET_DEP = $(addprefix $(CLASS_DEST)/, $(SERVLET_FILES))
-SERVLET_CP = $(subst $(SPACE),$(PATH_SEP),$(SERVLET_DEP))
-SERVLET_PULL = $(subst $(SPACE),$(COMMA),$(SERVLET_FILES))
-
-ifndef SERVLET_PULL_METHOD
-SERVLET_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(SERVLET_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- echo "Inside ftppull"
- $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(SERVLET_DIR) \
- -files $(SERVLET_PULL)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component servlet SDK files $@" ; \
- fi
-
-###########################################################
-
-# LDAP java classes #######################################
-LDAPJDK = ldapjdk.jar
-LDAPJDK_VERSION = $(LDAPJDK_RELDATE)
-LDAPJDK_RELEASE = $(COMPONENTS_DIR)
-LDAPJDK_DIR = $(LDAPJDK_RELEASE)
-LDAPJDK_IMPORT = $(LDAPJDK_RELEASE)/$(LDAPJDK_COMP)/$(LDAPJDK_VERSION)/$(NSOBJDIR_NAME)
-# This is java, so there is only one real platform subdirectory
-LDAPJARFILE=$(CLASS_DEST)/ldapjdk.jar
-LDAPJDK_DEP=$(LDAPJARFILE)
-
-#PACKAGE_UNDER_JAVA += $(LDAPJARFILE)
-
-ifndef LDAPJDK_PULL_METHOD
-LDAPJDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(LDAPJDK_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(LDAPJDK_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(LDAPJDK_IMPORT) \
- -files $(LDAPJDK)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component LDAPJDK file $@" ; \
- fi
-
-###########################################################
-
-# MCC java classes - the Mission Control Console #########
-MCC_VERSION=$(MCC_RELDATE)$(SEC_SUFFIX)
-#
-MCCJAR = mcc$(MCC_REL).jar
-MCCJAR_EN = mcc$(MCC_REL)_en.jar
-NMCLFJAR = nmclf$(MCC_REL).jar
-NMCLFJAR_EN = nmclf$(MCC_REL)_en.jar
-BASEJAR = base.jar
-#MCC_RELEASE=$(COMPONENTS_DIR_DEV)
-MCC_RELEASE=$(COMPONENTS_DIR)
-MCC_JARDIR = $(MCC_RELEASE)/$(MCC_COMP)/$(MCC_VERSION)/jars
-MCCJARFILE=$(CLASS_DEST)/$(MCCJAR)
-NMCLFJARFILE=$(CLASS_DEST)/$(NMCLFJAR)
-BASEJARFILE=$(CLASS_DEST)/$(BASEJAR)
-
-MCC_DEP = $(BASEJARFILE)
-MCC_FILES=$(MCCJAR),$(MCCJAR_EN),$(NMCLFJAR),$(NMCLFJAR_EN),$(BASEJAR)
-
-#PACKAGE_UNDER_JAVA += $(addprefix $(CLASS_DEST)/,$(subst $(COMMA),$(SPACE),$(MCC_FILES)))
-
-ifndef MCC_PULL_METHOD
-MCC_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(MCC_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(MCC_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(MCC_JARDIR) \
- -files $(MCC_FILES)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component MCC file $@" ; \
- fi
-
-###########################################################
-# LDAP Console java classes
-###########################################################
-LDAPCONSOLEJAR = ds$(LDAPCONSOLE_REL).jar
-LDAPCONSOLEJAR_EN = ds$(LDAPCONSOLE_REL)_en.jar
-
-LDAPCONSOLE_RELEASE=$(COMPONENTS_DIR_DEV)
-LDAPCONSOLE_JARDIR = $(LDAPCONSOLE_RELEASE)/$(LDAPCONSOLE_COMP)ext/$(LDAPCONSOLE_RELDATE)/jars
-LDAPCONSOLE_DEP = $(CLASS_DEST)/$(LDAPCONSOLEJAR)
-LDAPCONSOLE_FILES=$(LDAPCONSOLEJAR),$(LDAPCONSOLEJAR_EN)
-
-ifndef LDAPCONSOLE_PULL_METHOD
-LDAPCONSOLE_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(LDAPCONSOLE_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(LDAPCONSOLE_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(LDAPCONSOLE_JARDIR) \
- -files $(LDAPCONSOLE_FILES)
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component LDAPCONSOLE file $@" ; \
- fi
-
-###########################################################
-### Perldap package #######################################
-
-PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32)
-PERLDAP_ZIP_FILE = perldap14.zip
-
-###########################################################
-
-# JSS classes - for the Mission Control Console ######
-JSSJAR = jss$(JSS_JAR_VERSION).jar
-JSSJARFILE = $(CLASS_DEST)/$(JSSJAR)
-JSS_RELEASE = $(COMPONENTS_DIR)/$(JSS_COMP)/$(JSS_VERSION)
-JSS_DEP = $(JSSJARFILE)
-
-#PACKAGE_UNDER_JAVA += $(JSSJARFILE)
-
-ifndef JSS_PULL_METHOD
-JSS_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(JSS_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
-ifdef VSFTPD_HACK
-# work around vsftpd -L problem
- $(FTP_PULL) -method $(JSS_PULL_METHOD) \
- -objdir $(CLASS_DEST)/jss -componentdir $(JSS_RELEASE) \
- -files xpclass.jar
- mv $(CLASS_DEST)/jss/xpclass.jar $(CLASS_DEST)/$(JSSJAR)
- rm -rf $(CLASS_DEST)/jss
-else
- $(FTP_PULL) -method $(JSS_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(JSS_RELEASE) \
- -files $(JSSJAR)
-endif
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component JSS file $@" ; \
- fi
-
-###########################################################
+### SASL package ##########################################
-###########################################################
-### Admin Server package ##################################
-
-ADMIN_REL = $(ADM_VERSDIR)
-ADMIN_REL_DATE = $(ADM_VERSION)
-ADMIN_FILE = admserv.tar.gz
-ADMIN_FILE_TAR = admserv.tar
-ADMSDKOBJDIR = $(NSCONFIG)$(NSOBJDIR_TAG).OBJ
-IMPORTADMINSRV_BASE=$(COMPONENTS_DIR)/$(ADMIN_REL)/$(ADMIN_REL_DATE)
-IMPORTADMINSRV = $(IMPORTADMINSRV_BASE)/$(NSOBJDIR_NAME_32)
-ADMSERV_DIR=$(ABS_ROOT_PARENT)/dist/$(NSOBJDIR_NAME)/admserv
-ADMSERV_DEP = $(ADMSERV_DIR)/setup$(EXE_SUFFIX)
-
-ifdef FORTEZZA
- ADM_VERSION = $(ADM_RELDATE)F
+ifdef SASL_SOURCE_ROOT
+ SASL_LIBPATH = $(SASL_SOURCE_ROOT)/lib
+ SASL_BINPATH = $(SASL_SOURCE_ROOT)/bin
+ SASL_INCDIR = $(SASL_SOURCE_ROOT)/include
else
- ifeq ($(SECURITY), domestic)
- ADM_VERSION = $(ADM_RELDATE)D
- else
- ifneq ($(ARCH), IRIX)
- ADM_VERSION = $(ADM_RELDATE)E
- else
- ADM_VERSION = $(ADM_RELDATE)D
- endif
- endif
+ SASL_LIBPATH = $(SASL_BUILD_DIR)/lib
+ SASL_BINPATH = $(SASL_BUILD_DIR)/bin
+ SASL_INCDIR = $(SASL_BUILD_DIR)/include
endif
+SASL_INCLUDE = $(SASL_INCDIR)
+SASL_LIB_ROOT_NAME = sasl
+# for cyrus it's sasl2
+#SASL_LIB_ROOT_NAME = sasl2
-ADM_VERSION = $(ADM_RELDATE)$(SEC_SUFFIX)
-ADM_RELEASE = $(COMPONENTS_DIR)/$(ADM_VERSDIR)/$(ADM_VERSION)/$(NSOBJDIR_NAME)
-
-ifndef ADMSERV_PULL_METHOD
-ADMSERV_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-ifndef ADMSERV_DEPS
-ADMSERV_DEPS = $(COMPONENT_DEPS)
-endif
-#IMPORTADMINSRV = /share/builds/sbsrel1/admsvr/admsvr62/ships/20030702.2/spd04_Solaris8/SunOS5.8-domestic-optimize-normal
-#ADM_RELEASE = /share/builds/sbsrel1/admsvr/admsvr62/ships/20030702.2/spd04_Solaris8/SunOS5.8-domestic-optimize-normal
-$(ADMSERV_DEP): $(ABS_ROOT_PARENT)/dist/$(NSOBJDIR_NAME)
-ifdef ADMSERV_DEPS
- $(FTP_PULL) -method $(ADMSERV_PULL_METHOD) \
- -objdir $(ADMSERV_DIR) -componentdir $(IMPORTADMINSRV) \
- -files $(ADMIN_FILE) -unzip $(ADMSERV_DIR)
-endif
- @if [ ! -f $@ ] ; \
- then echo "Error: could not get component ADMINSERV file $@" ; \
- exit 1 ; \
- fi
-### Admin Server END ######################################
-
-
-
-### SASL package ##########################################
-
-SASL_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/sasl
-SASL_RELEASE = $(COMPONENTS_DIR)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME)
-SASL_LIBPATH = $(SASL_BUILD_DIR)/lib
-SASL_BINPATH = $(SASL_BUILD_DIR)/bin
-SASL_INCLUDE = $(SASL_BUILD_DIR)/include
-SASL_DEP = $(SASL_INCLUDE)/sasl.h
ifeq ($(ARCH), WINNT)
-SASL_LINK = /LIBPATH:$(SASL_LIBPATH) sasl.lib
+ SASL_LINK = /LIBPATH:$(SASL_LIBPATH) $(SASL_LIB_ROOT_NAME).lib
else
-ifeq ($(ARCH), SOLARIS)
-GSSAPI_LIBS=-lgss
-endif
+ ifeq ($(ARCH), SOLARIS)
+ GSSAPI_LIBS=-lgss
+ endif
#ifeq ($(ARCH), HPUX)
-GSSAPI_LIBS=-lgss
+ GSSAPI_LIBS=-lgss
#endif
-ifeq ($(ARCH), Linux)
-GSSAPI_LIBS=-L/usr/kerberos/lib -lgssapi_krb5
-endif
-SASL_LINK = -L$(SASL_LIBPATH) -lsasl $(GSSAPI_LIBS)
-#SASL_LINK = -L$(SASL_LIBPATH) -lsasl
-endif
-
-ifndef SASL_PULL_METHOD
-SASL_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(SASL_DEP): $(NSCP_DISTDIR_FULL_RTL)
-ifdef COMPONENT_DEPS
-ifdef VSFTPD_HACK
- $(FTP_PULL) -method $(SASL_PULL_METHOD) \
- -objdir $(SASL_BUILD_DIR) -componentdir $(SASL_RELEASE) \
- -files lib
- $(FTP_PULL) -method $(SASL_PULL_METHOD) \
- -objdir $(SASL_INCLUDE) -componentdir $(SASL_RELEASE)/../public \
- -files .\*.h
-else
- $(FTP_PULL) -method $(SASL_PULL_METHOD) \
- -objdir $(SASL_BUILD_DIR) -componentdir $(SASL_RELEASE) \
- -files lib,include
-
-endif
-endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component SASL file $@" ; \
- fi
-
-###########################################################
-
-### JSP compiler package ##################################
-
-JSPC_REL = $(JSPC_VERSDIR)
-JSPC_REL_DATE = $(JSPC_VERSION)
-JSPC_FILES = jasper-compiler.jar jasper-runtime.jar
-JSPC_RELEASE = $(COMPONENTS_DIR)
-JSPC_DIR = $(JSPC_RELEASE)/$(JSPC_COMP)/$(JSPC_VERSION)
-JSPC_DEP = $(addprefix $(CLASS_DEST)/, $(JSPC_FILES))
-JSPC_CP = $(subst $(SPACE),$(PATH_SEP),$(JSPC_DEP))
-JSPC_PULL = $(subst $(SPACE),$(COMMA),$(JSPC_FILES))
-
-ifndef JSPC_PULL_METHOD
-JSPC_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
-
-$(JSPC_DEP): $(CLASS_DEST)
-ifdef COMPONENT_DEPS
- echo "Inside ftppull"
- $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
- -objdir $(CLASS_DEST) -componentdir $(JSPC_DIR) \
- -files $(JSPC_PULL)
+ ifeq ($(ARCH), Linux)
+ GSSAPI_LIBS=-L/usr/kerberos/lib -lgssapi_krb5
+ endif
+ SASL_LINK = -L$(SASL_LIBPATH) -l$(SASL_LIB_ROOT_NAME) $(GSSAPI_LIBS)
+#SASL_LINK = -L$(SASL_LIBPATH) -l$(SASL_LIB_ROOT_NAME)
endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component jspc files $@" ; \
- fi
###########################################################
### ICU package ##########################################
ICU_LIB_VERSION = 24
-ICU_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/libicu
-ICU_RELEASE = $(COMPONENTS_DIR)/libicu/$(ICU_VERSDIR)/$(ICU_RELDATE)/$(NSOBJDIR_NAME)
-ICU_LIBPATH = $(ICU_BUILD_DIR)/lib
-ICU_BINPATH = $(ICU_BUILD_DIR)/bin
-ICU_INCPATH = $(ICU_BUILD_DIR)/include
-ICU_DEP = $(ICU_INCPATH)/unicode/unicode.h
-ICU_INCLUDE = -I$(ICU_INCPATH)
-ifeq ($(ARCH), WINNT)
-ifeq ($(BUILD_DEBUG), optimize)
-ICU_LIB_SUF=
+ifdef ICU_SOURCE_ROOT
+ ICU_LIBPATH = $(ICU_SOURCE_ROOT)/built/lib
+ ICU_BINPATH = $(ICU_SOURCE_ROOT)/built/bin
+ ICU_INCPATH = $(ICU_SOURCE_ROOT)/built/include
else
-ICU_LIB_SUF=d
+ ICU_LIBPATH = $(ICU_BUILD_DIR)/lib
+ ICU_BINPATH = $(ICU_BUILD_DIR)/bin
+ ICU_INCPATH = $(ICU_BUILD_DIR)/include
endif
-ICU_LIBNAMES = icuin$(ICU_LIB_SUF) icuuc$(ICU_LIB_SUF) icudata
-ICU_DLLNAMES = icuin$(ICU_LIB_VERSION)$(ICU_LIB_SUF) icuuc$(ICU_LIB_VERSION)$(ICU_LIB_SUF) icudt$(ICU_LIB_VERSION)l
-ICULINK = /LIBPATH:$(ICU_LIBPATH) $(addsuffix .$(LIB_SUFFIX),$(ICU_LIBNAMES))
-LIBS_TO_PKG += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
-LIBS_TO_PKG_SHARED += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
-LIBS_TO_PKG_CLIENTS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
+ICU_INCLUDE = -I$(ICU_INCPATH)
+ifeq ($(ARCH), WINNT)
+ ifeq ($(BUILD_DEBUG), optimize)
+ ICU_LIB_SUF=
+ else
+ ICU_LIB_SUF=d
+ endif
+ ICU_LIBNAMES = icuin$(ICU_LIB_SUF) icuuc$(ICU_LIB_SUF) icudata
+ ICU_DLLNAMES = icuin$(ICU_LIB_VERSION)$(ICU_LIB_SUF) icuuc$(ICU_LIB_VERSION)$(ICU_LIB_SUF) icudt$(ICU_LIB_VERSION)l
+ ICULINK = /LIBPATH:$(ICU_LIBPATH) $(addsuffix .$(LIB_SUFFIX),$(ICU_LIBNAMES))
+ LIBS_TO_PKG += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
+ LIBS_TO_PKG_SHARED += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
+ ifeq ($(USE_DSGW), 1)
+ LIBS_TO_PKG_CLIENTS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
+ endif
else
-ICU_LIBNAMES = icui18n icuuc icudata
-ICULINK = -L$(ICU_LIBPATH) $(addprefix -l, $(ICU_LIBNAMES))
-LIBS_TO_PKG += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
-LIBS_TO_PKG_SHARED += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
-LIBS_TO_PKG_CLIENTS += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
+ ICU_LIBNAMES = icui18n icuuc icudata
+ ICULINK = -L$(ICU_LIBPATH) $(addprefix -l, $(ICU_LIBNAMES))
+ LIBS_TO_PKG += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
+ LIBS_TO_PKG_SHARED += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
+ ifeq ($(USE_DSGW), 1)
+ LIBS_TO_PKG_CLIENTS += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
+ endif
#LIBS_TO_PKG = $(addsuffix $(addprefix lib,$(ICU_LIBNAMES))
endif
BINS_TO_PKG_SHARED += $(ICU_BINPATH)/uconv$(EXE_SUFFIX)
-ifndef ICU_PULL_METHOD
-ICU_PULL_METHOD = $(COMPONENT_PULL_METHOD)
-endif
+###########################################################
-$(ICU_DEP): $(NSCP_DISTDIR_FULL_RTL)
-ifdef COMPONENT_DEPS
- $(FTP_PULL) -method $(ICU_PULL_METHOD) \
- -objdir $(ICU_BUILD_DIR) -componentdir $(ICU_RELEASE) \
- -files lib,include,bin
+### DB component (Berkeley DB) ############################
+DB_LIBNAME=lib$(DB_MAJOR_MINOR)
+ifdef DB_SOURCE_ROOT
+ DB_INCLUDE =$(DB_SOURCE_ROOT)/built
+ DB_LIBPATH =$(DB_SOURCE_ROOT)/built/.libs
+ DB_BINPATH =$(DB_SOURCE_ROOT)/built
+else
+ DB_INCLUDE =$(db_path_config)/include
+ DB_LIBPATH =$(db_path_config)/lib
+ DB_BINPATH =$(db_path_config)/bin
endif
- -@if [ ! -f $@ ] ; \
- then echo "Error: could not get component ICU file $@" ; \
- fi
+ifeq ($(ARCH), WINNT)
+ db_import_lib_suffix =$(LIB_SUFFIX)
+ DB_LIB =$(DB_LIBPATH)/$(DB_LIBNAME).$(db_import_lib_suffix)
+ DB_STATIC_LIB =$(DB_LIBPATH)/$(DB_LIBNAME).$(LIB_SUFFIX)
+else # not WINNT
+ db_import_lib_suffix =$(DLL_SUFFIX)
+ DB_LIB =-L$(DB_LIBPATH) -l$(DB_MAJOR_MINOR)
+# XXXsspitzer: we need the spinlock symbols staticly linked in to libdb
+ DB_STATIC_LIB =-L$(DB_LIBPATH) -ldbs
+endif # not WINNT
-###########################################################
+# libdb only needs to be in the server directory since only the server uses it
+PACKAGE_SRC_DEST += $(wildcard $(DB_LIBPATH)/*.$(DLL_SUFFIX)) bin/slapd/server
+
+### DB component (Berkeley DB) ############################
+
+# must define dependencies last because they depend on the definitions above
+ifeq ($(INTERNAL_BUILD), 1)
+include $(BUILD_ROOT)/internal_comp_deps.mk
+endif
diff --git a/internal_buildpaths.mk b/internal_buildpaths.mk
new file mode 100644
index 000000000..e1ad4052e
--- /dev/null
+++ b/internal_buildpaths.mk
@@ -0,0 +1,90 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright (C) 2005 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# This file is where you tell the build process where to find the
+# various components used during the build process.
+
+# You can either use components built locally from source or
+# pre-built components. The reason for the different macros
+# for SOURCE and BUILD is that the locations for the libs, includes,
+# etc. are usually different for packages built from source vs.
+# pre-built packages. As an example, when building NSPR from
+# source, the includes are in mozilla/dist/$(OBJDIR_NAME)/include
+# where OBJDIR_NAME includes the OS, arch, compiler, thread model, etc.
+# When using the pre-built NSPR from Mozilla FTP, the include files
+# are just in nsprdir/include. This is why we have to make the
+# distinction between a SOURCE component and a BUILD (pre-built)
+# component. See components.mk for the gory details.
+
+# For each component, specify the source root OR the pre-built
+# component directory. If both a SOURCE_ROOT and a BUILD_DIR are
+# defined for a component, the SOURCE_ROOT will be used - don't do
+# this, it's confusing.
+
+# For the Mozilla components, if using source for all of them,
+# you can just define MOZILLA_SOURCE_ROOT - the build will
+# assume all of them have been built in that same directory
+# (as per the recommended build instructions)
+
+# For all components, the recommended way is to put each
+# component in a subdirectory of the parent directory of
+# BUILD_ROOT, both with pre-built and source components
+
+# work around vsftpd -L problem
+ifeq ($(COMPONENT_PULL_METHOD), FTP)
+ifdef USING_VSFTPD
+VSFTPD_HACK=1
+endif
+endif
+
+#MOZILLA_SOURCE_ROOT = $(BUILD_ROOT)/../mozilla
+
+#NSPR_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+ifndef NSPR_SOURCE_ROOT
+NSPR_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/nspr
+# NSPR also needs a build dir with a full, absolute path for some reason
+NSPR_ABS_BUILD_DIR = $(NSCP_ABS_DISTDIR_FULL_RTL)/nspr
+endif # NSPR_SOURCE_ROOT
+
+#DBM_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+ifndef DBM_SOURCE_ROOT
+DBM_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/dbm
+endif # DBM_SOURCE_ROOT
+
+#SECURITY_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+ifndef SECURITY_SOURCE_ROOT
+SECURITY_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/nss
+endif # SECURITY_SOURCE_ROOT
+
+#SVRCORE_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+ifndef SVRCORE_SOURCE_ROOT
+SVRCORE_BUILD_DIR = $(NSCP_DISTDIR)/svrcore
+endif # SVRCORE_SOURCE_ROOT
+
+#LDAPSDK_SOURCE_ROOT = $(MOZILLA_SOURCE_ROOT)
+ifndef LDAPSDK_SOURCE_ROOT
+LDAP_ROOT = $(NSCP_DISTDIR_FULL_RTL)/ldapsdk
+endif # LDAPSDK_SOURCE_ROOT
+
+#SASL_SOURCE_ROOT = $(BUILD_ROOT)/../cyrus-sasl-2.1.20
+ifndef SASL_SOURCE_ROOT
+SASL_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/sasl
+endif # SASL_SOURCE_ROOT
+
+#ICU_SOURCE_ROOT = $(BUILD_ROOT)/../icu
+ifndef ICU_SOURCE_ROOT
+ICU_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/libicu
+endif # ICU_SOURCE_ROOT
+
+#DB_SOURCE_ROOT = $(BUILD_ROOT)/../db-4.2.52.NC
+# DB_MAJOR_MINOR is the root name for the db shared library
+# source builds use db-4.2 - uncomment this if using source
+#DB_MAJOR_MINOR := db-4.2
+ifndef DB_SOURCE_ROOT
+DB_MAJOR_MINOR := db42
+component_name:=$(DB_MAJOR_MINOR)
+db_path_config =$(NSCP_DISTDIR)/$(component_name)
+endif # DB_SOURCE_ROOT
diff --git a/internal_comp_deps.mk b/internal_comp_deps.mk
new file mode 100644
index 000000000..cdf647b78
--- /dev/null
+++ b/internal_comp_deps.mk
@@ -0,0 +1,703 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright (C) 2005 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# This file defines dependencies for components and
+# tells how to satisfy thoes dependencies
+
+# For internal components, we use ftp_puller_new.pl
+# We should consider using wget or something like that
+# in the future.
+
+ifndef NSPR_SOURCE_ROOT
+NSPR_IMPORT = $(COMPONENTS_DIR)/nspr20/$(NSPR_RELDATE)/$(FULL_RTL_OBJDIR)
+NSPR_DEP = $(NSPR_LIBPATH)/libnspr4.$(LIB_SUFFIX)
+
+ifndef NSPR_PULL_METHOD
+NSPR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(NSPR_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(NSPR_PULL_METHOD) \
+ -objdir $(NSPR_BUILD_DIR) -componentdir $(NSPR_IMPORT) \
+ -files lib,include
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component NSPR file $@" ; \
+ fi
+endif # NSPR_SOURCE_ROOT
+
+ifndef DBM_SOURCE_ROOT
+DBM_IMPORT = $(COMPONENTS_DIR)/dbm/$(DBM_RELDATE)/$(NSOBJDIR_NAME)
+ifeq ($(ARCH), WINNT)
+ DBM_DEP = $(DBM_LIBPATH)/dbm.$(LIB_SUFFIX)
+else
+ DBM_DEP = $(DBM_LIBPATH)/libdbm.$(LIB_SUFFIX)
+endif
+
+ifndef DBM_PULL_METHOD
+DBM_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(DBM_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(DBM_PULL_METHOD) \
+ -objdir $(DBM_BUILD_DIR) -componentdir $(DBM_IMPORT)/.. \
+ -files xpheader.jar -unzip $(DBM_INCDIR)
+ $(FTP_PULL) -method $(DBM_PULL_METHOD) \
+ -objdir $(DBM_BUILD_DIR) -componentdir $(DBM_IMPORT) \
+ -files mdbinary.jar -unzip $(DBM_BUILD_DIR)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component DBM file $@" ; \
+ fi
+endif # DBM_SOURCE_ROOT
+
+ifndef SECURITY_SOURCE_ROOT
+SECURITY_IMPORT = $(COMPONENTS_DIR)/nss/$(SECURITY_RELDATE)/$(FULL_RTL_OBJDIR)
+ifeq ($(ARCH), WINNT)
+ SECURITY_DEP = $(SECURITY_LIBPATH)/ssl3.$(DLL_SUFFIX)
+else
+ SECURITY_DEP = $(SECURITY_LIBPATH)/libssl3.$(DLL_SUFFIX)
+endif
+
+ifdef VSFTPD_HACK
+SECURITY_FILES=lib,bin/$(subst $(SPACE),$(COMMA)bin/,$(SECURITY_TOOLS))
+else
+SECURITY_FILES=lib,include,bin/$(subst $(SPACE),$(COMMA)bin/,$(SECURITY_TOOLS))
+endif
+
+ifndef SECURITY_PULL_METHOD
+SECURITY_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SECURITY_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+ mkdir -p $(SECURITY_BINPATH)
+ $(FTP_PULL) -method $(SECURITY_PULL_METHOD) \
+ -objdir $(SECURITY_BUILD_DIR) -componentdir $(SECURITY_IMPORT) \
+ -files $(SECURITY_FILES)
+ifdef VSFTPD_HACK
+# work around vsftpd -L problem
+ $(FTP_PULL) -method $(SECURITY_PULL_METHOD) \
+ -objdir $(SECURITY_BUILD_DIR) -componentdir $(COMPONENTS_DIR)/nss/$(SECURITY_RELDATE) \
+ -files include
+endif
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component NSS file $@" ; \
+ fi
+endif # SECURITY_SOURCE_ROOT
+
+ifndef SVRCORE_SOURCE_ROOT
+SVRCORE_IMPORT = $(COMPONENTS_DIR)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
+#SVRCORE_IMPORT = $(COMPONENTS_DIR_DEV)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
+ifeq ($(ARCH), WINNT)
+ SVRCORE_DEP = $(SVRCORE_LIBPATH)/svrcore.$(LIB_SUFFIX)
+else
+ SVRCORE_DEP = $(SVRCORE_LIBPATH)/libsvrcore.$(LIB_SUFFIX)
+endif
+
+ifndef SVRCORE_PULL_METHOD
+SVRCORE_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SVRCORE_DEP): $(NSCP_DISTDIR)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(SVRCORE_PULL_METHOD) \
+ -objdir $(SVRCORE_BUILD_DIR) -componentdir $(SVRCORE_IMPORT)/.. \
+ -files xpheader.jar -unzip $(SVRCORE_INCDIR)
+ $(FTP_PULL) -method $(SVRCORE_PULL_METHOD) \
+ -objdir $(SVRCORE_BUILD_DIR) -componentdir $(SVRCORE_IMPORT) \
+ -files mdbinary.jar -unzip $(SVRCORE_BUILD_DIR)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component SVRCORE file $@" ; \
+ fi
+endif # SVRCORE_SOURCE_ROOT
+
+ifndef LDAPSDK_SOURCE_ROOT
+ifndef LDAP_VERSION
+ LDAP_VERSION = $(LDAP_RELDATE)$(SEC_SUFFIX)
+endif
+ifndef LDAP_SBC
+# LDAP_SBC = $(COMPONENTS_DIR_DEV)
+LDAP_SBC = $(COMPONENTS_DIR)
+endif
+LDAPOBJDIR = $(FULL_RTL_OBJDIR)
+# LDAP does not have PTH version, so here is the hack which treat non PTH
+# version as PTH version
+ifeq ($(USE_PTHREADS), 1)
+ LDAP_RELEASE = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(NSOBJDIR_NAME1)
+else
+ LDAP_RELEASE = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(LDAPOBJDIR)
+endif
+ifeq ($(ARCH), WINNT)
+ LDAPSDK_DEP = $(LDAPSDK_LIBPATH)/nsldap32v$(LDAP_SUF).$(DLL_SUFFIX)
+ LDAPSDK_PULL_LIBS = lib/nsldapssl32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldapssl32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX),lib/nsldap32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldap32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX),lib/nsldappr32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldappr32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX)
+else
+ LDAPSDK_DEP = $(LDAPSDK_LIBPATH)/libldap$(LDAP_SUF).$(DLL_SUFFIX)
+ LDAPSDK_PULL_LIBS = lib/libssldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX),lib/libldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX),lib/libprldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX)
+endif
+
+ifndef LDAPSDK_PULL_METHOD
+LDAPSDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(LDAPSDK_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+ mkdir -p $(LDAP_LIBPATH)
+ $(FTP_PULL) -method $(LDAPSDK_PULL_METHOD) \
+ -objdir $(LDAP_ROOT) -componentdir $(LDAP_RELEASE) \
+ -files include,$(LDAPSDK_PULL_LIBS),tools
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component LDAPSDK file $@" ; \
+ fi
+endif # LDAPSDK_SOURCE_ROOT
+
+ifndef SASL_SOURCE_ROOT
+#SASL_RELEASE = $(COMPONENTS_DIR_DEV)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME)
+SASL_RELEASE = $(COMPONENTS_DIR)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME)
+SASL_DEP = $(SASL_INCLUDE)/sasl.h
+ifndef SASL_PULL_METHOD
+SASL_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SASL_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(SASL_PULL_METHOD) \
+ -objdir $(SASL_BUILD_DIR) -componentdir $(SASL_RELEASE) \
+ -files lib,include
+
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component SASL file $@" ; \
+ fi
+endif # SASL_SOURCE_ROOT
+
+ifndef ICU_SOURCE_ROOT
+ICU_RELEASE = $(COMPONENTS_DIR)/libicu/$(ICU_VERSDIR)/$(ICU_RELDATE)/$(NSOBJDIR_NAME)
+ICU_DEP = $(ICU_INCPATH)/unicode/ucol.h
+ifndef ICU_PULL_METHOD
+ICU_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(ICU_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(ICU_PULL_METHOD) \
+ -objdir $(ICU_BUILD_DIR) -componentdir $(ICU_RELEASE) \
+ -files lib,include,bin
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component ICU file $@" ; \
+ fi
+endif # ICU_SOURCE_ROOT
+
+ifndef DB_SOURCE_ROOT
+#if no version specified, we'll use the latest one
+ifndef DB_VERSION
+ DB_VERSION=20040130
+endif
+# define the paths to the component parts
+db_components_share=$(COMPONENTS_DIR)/$(component_name)
+MY_NSOBJDIR_TAG=$(NSOBJDIR_TAG).OBJ
+db_release_config =$(db_components_share)/$(DB_VERSION)/$(NSCONFIG_NOTAG)$(NS64TAG)$(MY_NSOBJDIR_TAG)
+# add ",bin" to DB_FILES if you want the programs like db_verify, db_recover, etc.
+DB_FILES=include,lib,bin
+
+ifeq ($(ARCH), WINNT)
+ DB_LIB_DEP =$(DB_STATIC_LIB)
+else # not WINNT
+ DB_LIB_DEP =$(DB_LIBPATH)/$(DB_LIBNAME).$(DLL_SUFFIX)
+endif # not WINNT
+
+ifndef DB_PULL_METHOD
+DB_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(DB_LIB_DEP): $(NSCP_DISTDIR)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(DB_PULL_METHOD) \
+ -objdir $(db_path_config) -componentdir $(db_release_config) \
+ -files $(DB_FILES)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component $(component_name) file $@" ; \
+ fi
+endif # DB_SOURCE_ROOT
+
+######## END OF OPEN SOURCE COMPONENTS ######################
+
+######## The rest of these components are internal only (for now)
+
+# ADMINUTIL library #######################################
+ADMINUTIL_VERSION=$(ADMINUTIL_RELDATE)$(SEC_SUFFIX)
+ADMINUTIL_BASE=$(ADMINUTIL_VERSDIR)/${ADMINUTIL_VERSION}
+ADMSDKOBJDIR = $(FULL_RTL_OBJDIR)
+ADMINUTIL_IMPORT=$(COMPONENTS_DIR)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
+# this is the base directory under which the component's files will be found
+# during the build process
+ADMINUTIL_BUILD_DIR=$(NSCP_DISTDIR_FULL_RTL)/adminutil
+ADMINUTIL_LIBPATH=$(ADMINUTIL_BUILD_DIR)/lib
+ADMINUTIL_INCPATH=$(ADMINUTIL_BUILD_DIR)/include
+
+PACKAGE_SRC_DEST += $(ADMINUTIL_LIBPATH)/property bin/slapd/lib
+LIBS_TO_PKG += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
+LIBS_TO_PKG_CLIENTS += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
+
+#
+# Libadminutil
+#
+ADMINUTIL_DEP = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(LIB_SUFFIX)
+ifeq ($(ARCH), WINNT)
+ADMINUTIL_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil$(ADMINUTIL_VER).$(LIB_SUFFIX)
+ADMINUTIL_S_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil_s$(ADMINUTIL_VER).$(LIB_SUFFIX)
+LIBADMINUTILDLL_NAMES = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(DLL_SUFFIX)
+else
+ADMINUTIL_LINK=-L$(ADMINUTIL_LIBPATH) -ladminutil$(ADMINUTIL_VER)
+endif
+ADMINUTIL_INCLUDE=-I$(ADMINUTIL_INCPATH) \
+ -I$(ADMINUTIL_INCPATH)/libadminutil \
+ -I$(ADMINUTIL_INCPATH)/libadmsslutil
+
+ifndef ADMINUTIL_PULL_METHOD
+ADMINUTIL_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(ADMINUTIL_DEP): ${NSCP_DISTDIR_FULL_RTL}
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(ADMINUTIL_PULL_METHOD) \
+ -objdir $(ADMINUTIL_BUILD_DIR) \
+ -componentdir $(ADMINUTIL_IMPORT) \
+ -files include,lib
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component adminutil file $@" ; \
+ fi
+
+###########################################################
+# Peer
+
+PEER_BUILD_DIR = $(NSCP_DISTDIR)/peer
+ifeq ($(ARCH), WINNT)
+# PEER_RELEASE = $(COMPONENTS_DIR)/peer/$(PEER_RELDATE)
+# PEER_FILES = include
+else
+PEER_RELEASE = $(COMPONENTS_DIR)/peer/$(PEER_RELDATE)/$(NSOBJDIR_NAME)
+PEER_FILES = obj
+PEER_DEP = $(PEER_OBJPATH)/ns-ldapagt
+endif
+# PEER_MGMTPATH = $(PEER_BUILD_DIR)/dev
+# PEER_INCDIR = $(PEER_BUILD_DIR)/include
+# PEER_BINPATH = $(PEER_BUILD_DIR)/dev
+PEER_OBJPATH = $(PEER_BUILD_DIR)/obj
+# PEER_INCLUDE = -I$(PEER_INCDIR)
+
+ifndef PEER_PULL_METHOD
+PEER_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(PEER_DEP): $(NSCP_DISTDIR)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(PEER_PULL_METHOD) \
+ -objdir $(PEER_BUILD_DIR) -componentdir $(PEER_RELEASE) \
+ -files $(PEER_FILES)
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component PEER file $@" ; \
+ fi
+endif
+
+###########################################################
+
+### SETUPSDK #############################
+# this is where the build looks for setupsdk components
+SETUP_SDK_BUILD_DIR = $(NSCP_DISTDIR)/setupsdk
+SETUPSDK_VERSION = $(SETUP_SDK_RELDATE)$(SEC_SUFFIX)
+SETUPSDK_RELEASE = $(COMPONENTS_DIR)/setupsdk/$(SETUPSDK_VERSDIR)/$(SETUPSDK_VERSION)/$(NSOBJDIR_NAME)
+SETUPSDK_LIBPATH = $(SETUP_SDK_BUILD_DIR)/lib
+SETUPSDK_INCDIR = $(SETUP_SDK_BUILD_DIR)/include
+SETUPSDK_BINPATH = $(SETUP_SDK_BUILD_DIR)/bin
+SETUPSDK_INCLUDE = -I$(SETUPSDK_INCDIR)
+
+ifeq ($(ARCH), WINNT)
+SETUP_SDK_FILES = setupsdk.tar.gz -unzip $(NSCP_DISTDIR)/setupsdk
+SETUPSDK_DEP = $(SETUPSDK_LIBPATH)/nssetup32.$(LIB_SUFFIX)
+SETUPSDKLINK = /LIBPATH:$(SETUPSDK_LIBPATH) nssetup32.$(LIB_SUFFIX)
+SETUPSDK_S_LINK = /LIBPATH:$(SETUPSDK_LIBPATH) nssetup32_s.$(LIB_SUFFIX)
+else
+SETUP_SDK_FILES = bin,lib,include
+SETUPSDK_DEP = $(SETUPSDK_LIBPATH)/libinstall.$(LIB_SUFFIX)
+SETUPSDKLINK = -L$(SETUPSDK_LIBPATH) -linstall
+SETUPSDK_S_LINK = $(SETUPSDKLINK)
+endif
+
+ifndef SETUPSDK_PULL_METHOD
+SETUPSDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SETUPSDK_DEP): $(NSCP_DISTDIR)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(SETUPSDK_PULL_METHOD) \
+ -objdir $(SETUP_SDK_BUILD_DIR) -componentdir $(SETUPSDK_RELEASE) \
+ -files $(SETUP_SDK_FILES)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component SETUPSDK file $@" ; \
+ fi
+# apache-axis java classes #######################################
+AXIS = axis-bin-$(AXIS_VERSION).zip
+AXIS_FILES = $(AXIS)
+AXIS_RELEASE = $(COMPONENTS_DIR)/axis
+#AXISJAR_DIR = $(AXISJAR_RELEASE)/$(AXISJAR_COMP)/$(AXISJAR_VERSION)
+AXIS_DIR = $(AXIS_RELEASE)/$(AXIS_VERSION)
+AXIS_FILE = $(CLASS_DEST)/$(AXIS)
+AXIS_DEP = $(AXIS_FILE)
+AXIS_REL_DIR=$(subst -bin,,$(subst .zip,,$(AXIS)))
+
+
+# This is java, so there is only one real platform subdirectory
+
+#PACKAGE_UNDER_JAVA += $(AXIS_FILE)
+
+ifndef AXIS_PULL_METHOD
+AXIS_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(AXIS_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ echo "Inside ftppull"
+ $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(AXIS_DIR) \
+ -files $(AXIS_FILES) -unzip $(CLASS_DEST)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component AXIS files $@" ; \
+ fi
+
+###########################################################
+
+
+# other dsml java classes #######################################
+DSMLJAR = activation.jar,jaxrpc-api.jar,jaxrpc.jar,saaj.jar,xercesImpl.jar,xml-apis.jar
+DSMLJAR_FILES = $(DSMLJAR)
+DSMLJAR_RELEASE = $(COMPONENTS_DIR)
+#DSMLJARJAR_DIR = $(DSMLJARJAR_RELEASE)/$(DSMLJARJAR_COMP)/$(DSMLJARJAR_VERSION)
+DSMLJAR_DIR = $(DSMLJAR_RELEASE)/dsmljars
+DSMLJAR_FILE = $(CLASS_DEST)
+DSMLJAR_DEP = $(CLASS_DEST)/activation.jar $(CLASS_DEST)/jaxrpc-api.jar $(CLASS_DEST)/jaxrpc.jar $(CLASS_DEST)/saaj.jar $(CLASS_DEST)/xercesImpl.jar $(CLASS_DEST)/xml-apis.jar
+
+ifndef DSMLJAR_PULL_METHOD
+DSMLJAR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(DSMLJAR_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ echo "Inside ftppull"
+ $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(DSMLJAR_DIR) \
+ -files $(DSMLJAR_FILES)
+
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component DSMLJAR files $@" ; \
+ fi
+
+###########################################################
+
+# XMLTOOLS java classes #######################################
+CRIMSONJAR = crimson.jar
+CRIMSON_LICENSE = LICENSE.crimson
+CRIMSONJAR_FILES = $(CRIMSONJAR),$(CRIMSON_LICENSE)
+CRIMSONJAR_RELEASE = $(COMPONENTS_DIR)
+CRIMSONJAR_DIR = $(CRIMSONJAR_RELEASE)/$(CRIMSONJAR_COMP)/$(CRIMSONJAR_VERSION)
+CRIMSONJAR_FILE = $(CLASS_DEST)/$(CRIMSONJAR)
+CRIMSONJAR_DEP = $(CRIMSONJAR_FILE) $(CLASS_DEST)/$(CRIMSON_LICENSE)
+
+
+# This is java, so there is only one real platform subdirectory
+
+PACKAGE_UNDER_JAVA += $(CRIMSONJAR_FILE)
+
+ifndef CRIMSONJAR_PULL_METHOD
+CRIMSONJAR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(CRIMSONJAR_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ echo "Inside ftppull"
+ $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(CRIMSONJAR_DIR) \
+ -files $(CRIMSONJAR_FILES)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component CRIMSONJAR files $@" ; \
+ fi
+
+###########################################################
+
+# ANT java classes #######################################
+ifeq ($(BUILD_JAVA_CODE),1)
+# (we use ant for building some Java code)
+ANTJAR = ant.jar
+JAXPJAR = jaxp.jar
+ANT_FILES = $(ANTJAR) $(JAXPJAR)
+ANT_RELEASE = $(COMPONENTS_DIR)
+ANT_HOME = $(ANT_RELEASE)/$(ANT_COMP)/$(ANT_VERSION)
+ANT_DIR = $(ANT_HOME)/lib
+ANT_DEP = $(addprefix $(CLASS_DEST)/, $(ANT_FILES))
+ANT_CP = $(subst $(SPACE),$(PATH_SEP),$(ANT_DEP))
+ANT_PULL = $(subst $(SPACE),$(COMMA),$(ANT_FILES))
+
+ifndef ANT_PULL_METHOD
+ANT_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(ANT_DEP): $(CLASS_DEST) $(CRIMSONJAR_DEP)
+ifdef COMPONENT_DEPS
+ echo "Inside ftppull"
+ $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(ANT_DIR) \
+ -files $(ANT_PULL)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component ant files $@" ; \
+ fi
+endif
+###########################################################
+
+# Servlet SDK classes #######################################
+SERVLETJAR = servlet.jar
+SERVLET_FILES = $(SERVLETJAR)
+SERVLET_RELEASE = $(COMPONENTS_DIR)
+SERVLET_DIR = $(SERVLET_RELEASE)/$(SERVLET_COMP)/$(SERVLET_VERSION)
+SERVLET_DEP = $(addprefix $(CLASS_DEST)/, $(SERVLET_FILES))
+SERVLET_CP = $(subst $(SPACE),$(PATH_SEP),$(SERVLET_DEP))
+SERVLET_PULL = $(subst $(SPACE),$(COMMA),$(SERVLET_FILES))
+
+ifndef SERVLET_PULL_METHOD
+SERVLET_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SERVLET_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ echo "Inside ftppull"
+ $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(SERVLET_DIR) \
+ -files $(SERVLET_PULL)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component servlet SDK files $@" ; \
+ fi
+
+###########################################################
+
+# LDAP java classes #######################################
+LDAPJDK = ldapjdk.jar
+LDAPJDK_VERSION = $(LDAPJDK_RELDATE)
+LDAPJDK_RELEASE = $(COMPONENTS_DIR)
+LDAPJDK_DIR = $(LDAPJDK_RELEASE)
+LDAPJDK_IMPORT = $(LDAPJDK_RELEASE)/$(LDAPJDK_COMP)/$(LDAPJDK_VERSION)/$(NSOBJDIR_NAME)
+# This is java, so there is only one real platform subdirectory
+LDAPJARFILE=$(CLASS_DEST)/ldapjdk.jar
+LDAPJDK_DEP=$(LDAPJARFILE)
+
+#PACKAGE_UNDER_JAVA += $(LDAPJARFILE)
+
+ifndef LDAPJDK_PULL_METHOD
+LDAPJDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(LDAPJDK_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(LDAPJDK_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(LDAPJDK_IMPORT) \
+ -files $(LDAPJDK)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component LDAPJDK file $@" ; \
+ fi
+
+###########################################################
+
+# MCC java classes - the Mission Control Console #########
+MCC_VERSION=$(MCC_RELDATE)$(SEC_SUFFIX)
+#
+MCCJAR = mcc$(MCC_REL).jar
+MCCJAR_EN = mcc$(MCC_REL)_en.jar
+NMCLFJAR = nmclf$(MCC_REL).jar
+NMCLFJAR_EN = nmclf$(MCC_REL)_en.jar
+BASEJAR = base.jar
+#MCC_RELEASE=$(COMPONENTS_DIR_DEV)
+MCC_RELEASE=$(COMPONENTS_DIR)
+MCC_JARDIR = $(MCC_RELEASE)/$(MCC_COMP)/$(MCC_VERSION)/jars
+MCCJARFILE=$(CLASS_DEST)/$(MCCJAR)
+NMCLFJARFILE=$(CLASS_DEST)/$(NMCLFJAR)
+BASEJARFILE=$(CLASS_DEST)/$(BASEJAR)
+
+MCC_DEP = $(BASEJARFILE)
+MCC_FILES=$(MCCJAR),$(MCCJAR_EN),$(NMCLFJAR),$(NMCLFJAR_EN),$(BASEJAR)
+
+#PACKAGE_UNDER_JAVA += $(addprefix $(CLASS_DEST)/,$(subst $(COMMA),$(SPACE),$(MCC_FILES)))
+
+ifndef MCC_PULL_METHOD
+MCC_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(MCC_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(MCC_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(MCC_JARDIR) \
+ -files $(MCC_FILES)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component MCC file $@" ; \
+ fi
+
+###########################################################
+# LDAP Console java classes
+###########################################################
+LDAPCONSOLEJAR = ds$(LDAPCONSOLE_REL).jar
+LDAPCONSOLEJAR_EN = ds$(LDAPCONSOLE_REL)_en.jar
+
+LDAPCONSOLE_RELEASE=$(COMPONENTS_DIR_DEV)
+LDAPCONSOLE_JARDIR = $(LDAPCONSOLE_RELEASE)/$(LDAPCONSOLE_COMP)ext/$(LDAPCONSOLE_RELDATE)/jars
+LDAPCONSOLE_DEP = $(CLASS_DEST)/$(LDAPCONSOLEJAR)
+LDAPCONSOLE_FILES=$(LDAPCONSOLEJAR),$(LDAPCONSOLEJAR_EN)
+
+ifndef LDAPCONSOLE_PULL_METHOD
+LDAPCONSOLE_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(LDAPCONSOLE_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ $(FTP_PULL) -method $(LDAPCONSOLE_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(LDAPCONSOLE_JARDIR) \
+ -files $(LDAPCONSOLE_FILES)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component LDAPCONSOLE file $@" ; \
+ fi
+
+###########################################################
+### Perldap package #######################################
+
+PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32)
+PERLDAP_ZIP_FILE = perldap14.zip
+
+###########################################################
+
+# JSS classes - for the Mission Control Console ######
+JSSJAR = jss$(JSS_JAR_VERSION).jar
+JSSJARFILE = $(CLASS_DEST)/$(JSSJAR)
+JSS_RELEASE = $(COMPONENTS_DIR)/$(JSS_COMP)/$(JSS_VERSION)
+JSS_DEP = $(JSSJARFILE)
+
+#PACKAGE_UNDER_JAVA += $(JSSJARFILE)
+
+ifndef JSS_PULL_METHOD
+JSS_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(JSS_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ifdef VSFTPD_HACK
+# work around vsftpd -L problem
+ $(FTP_PULL) -method $(JSS_PULL_METHOD) \
+ -objdir $(CLASS_DEST)/jss -componentdir $(JSS_RELEASE) \
+ -files xpclass.jar
+ mv $(CLASS_DEST)/jss/xpclass.jar $(CLASS_DEST)/$(JSSJAR)
+ rm -rf $(CLASS_DEST)/jss
+else
+ $(FTP_PULL) -method $(JSS_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(JSS_RELEASE) \
+ -files $(JSSJAR)
+endif
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component JSS file $@" ; \
+ fi
+
+###########################################################
+
+### JSP compiler package ##################################
+
+JSPC_REL = $(JSPC_VERSDIR)
+JSPC_REL_DATE = $(JSPC_VERSION)
+JSPC_FILES = jasper-compiler.jar jasper-runtime.jar
+JSPC_RELEASE = $(COMPONENTS_DIR)
+JSPC_DIR = $(JSPC_RELEASE)/$(JSPC_COMP)/$(JSPC_VERSION)
+JSPC_DEP = $(addprefix $(CLASS_DEST)/, $(JSPC_FILES))
+JSPC_CP = $(subst $(SPACE),$(PATH_SEP),$(JSPC_DEP))
+JSPC_PULL = $(subst $(SPACE),$(COMMA),$(JSPC_FILES))
+
+ifndef JSPC_PULL_METHOD
+JSPC_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(JSPC_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+ echo "Inside ftppull"
+ $(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+ -objdir $(CLASS_DEST) -componentdir $(JSPC_DIR) \
+ -files $(JSPC_PULL)
+endif
+ -@if [ ! -f $@ ] ; \
+ then echo "Error: could not get component jspc files $@" ; \
+ fi
+
+###########################################################
+
+###########################################################
+### Admin Server package ##################################
+
+ADMIN_REL = $(ADM_VERSDIR)
+ADMIN_REL_DATE = $(ADM_VERSION)
+ADMIN_FILE = admserv.tar.gz
+ADMIN_FILE_TAR = admserv.tar
+ADMSDKOBJDIR = $(NSCONFIG)$(NSOBJDIR_TAG).OBJ
+IMPORTADMINSRV_BASE=$(COMPONENTS_DIR)/$(ADMIN_REL)/$(ADMIN_REL_DATE)
+IMPORTADMINSRV = $(IMPORTADMINSRV_BASE)/$(NSOBJDIR_NAME_32)
+ADMSERV_DIR=$(ABS_ROOT_PARENT)/dist/$(NSOBJDIR_NAME)/admserv
+ADMSERV_DEP = $(ADMSERV_DIR)/setup$(EXE_SUFFIX)
+
+ifdef FORTEZZA
+ ADM_VERSION = $(ADM_RELDATE)F
+else
+ ifeq ($(SECURITY), domestic)
+ ADM_VERSION = $(ADM_RELDATE)D
+ else
+ ifneq ($(ARCH), IRIX)
+ ADM_VERSION = $(ADM_RELDATE)E
+ else
+ ADM_VERSION = $(ADM_RELDATE)D
+ endif
+ endif
+endif
+
+ADM_VERSION = $(ADM_RELDATE)$(SEC_SUFFIX)
+ADM_RELEASE = $(COMPONENTS_DIR)/$(ADM_VERSDIR)/$(ADM_VERSION)/$(NSOBJDIR_NAME)
+
+ifndef ADMSERV_PULL_METHOD
+ADMSERV_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+ifndef ADMSERV_DEPS
+ADMSERV_DEPS = $(COMPONENT_DEPS)
+endif
+#IMPORTADMINSRV = /share/builds/sbsrel1/admsvr/admsvr62/ships/20030702.2/spd04_Solaris8/SunOS5.8-domestic-optimize-normal
+#ADM_RELEASE = /share/builds/sbsrel1/admsvr/admsvr62/ships/20030702.2/spd04_Solaris8/SunOS5.8-domestic-optimize-normal
+$(ADMSERV_DEP): $(ABS_ROOT_PARENT)/dist/$(NSOBJDIR_NAME)
+ifdef ADMSERV_DEPS
+ $(FTP_PULL) -method $(ADMSERV_PULL_METHOD) \
+ -objdir $(ADMSERV_DIR) -componentdir $(IMPORTADMINSRV) \
+ -files $(ADMIN_FILE) -unzip $(ADMSERV_DIR)
+endif
+ @if [ ! -f $@ ] ; \
+ then echo "Error: could not get component ADMINSERV file $@" ; \
+ exit 1 ; \
+ fi
+### Admin Server END ######################################
diff --git a/ldap/Makefile b/ldap/Makefile
index 9328b6324..a81c44813 100644
--- a/ldap/Makefile
+++ b/ldap/Makefile
@@ -29,6 +29,7 @@ ldapprogs:
ifneq ($(ARCH), WINNT)
cd systools; $(MAKE) $(MFLAGS) all
# new unix installer
+ifeq ($(USE_SETUPSDK), 1)
cd cm/newinst; $(MAKE) $(MFLAGS) all
ifeq ($(USE_64),1)
# In 64-bit builds, we build the installer 32-bit, which has the side-effect that the uninstaller and ns-update scripts
@@ -36,10 +37,13 @@ ifeq ($(USE_64),1)
# to see them in the 64-bit output directory. So, here we copy them over.
$(CP) $(RELDIR_32)/bin/slapd/admin/bin/ns-update $(LDAP_ADMIN_BIN_RELDIR)
$(CP) $(RELDIR_32)/bin/slapd/admin/bin/uninstall $(LDAP_ADMIN_BIN_RELDIR)
-endif
-else
+endif # USE_64
+endif # USE_SETUPSDK
+else # not WINNT
+ifeq ($(USE_SETUPSDK), 1)
cd cm/newinstnt; $(MAKE) $(MFLAGS) all
-endif
+endif # USE_SETUPSDK
+endif # WINNT
cd admin; $(MAKE) $(MFLAGS) all
ldapdocs:
diff --git a/ldap/admin/src/Makefile b/ldap/admin/src/Makefile
index b78bd1f26..0bde63e7e 100644
--- a/ldap/admin/src/Makefile
+++ b/ldap/admin/src/Makefile
@@ -21,11 +21,10 @@ SCRIPTSDIR=$(LDAP_BASE_RELDIR)/admin/scripts
include $(BUILD_ROOT)/nsconfig.mk
include $(LDAP_SRC)/nsldap.mk
-ifndef LDAP_USE_OLD_DB
-include $(BUILD_ROOT)/ns_usedb.mk
-endif
+ifeq ($(USE_ADMINSERVER), 1)
MCC_INCLUDE += $(ADMINUTIL_INCLUDE)
+endif
INCLUDES += -I$(LDAP_SRC)/admin/include
@@ -36,15 +35,21 @@ EXTRALDFLAGS += $(SSLLIBFLAG)
endif
ifeq ($(BUILD_DLL), yes)
-DYNAMIC_DEPLIBS=$(LDAP_ADMLIB) $(LDAP_COMMON_LIBS_DEP) $(ADMINUTIL)
+DYNAMIC_DEPLIBS=$(LDAP_ADMLIB) $(LDAP_COMMON_LIBS_DEP)
+ifeq ($(USE_ADMINSERVER), 1)
+ DYNAMIC_DEPLIBS += $(ADMINUTIL)
+endif
DYNAMIC_DEPLINK=$(DYNAMIC_DEPLIBS)
else
DYNAMIC_DEPLIBS=$(LDAP_COMMON_LIBS_DEP)
DYNAMIC_DEPLINK=$(LDAP_ADMLIB) $(LDAP_COMMON_LIBS)
endif
-EXTRA_LIBS_DEP += $(NSPR_DEP) $(LDAPSDK_DEP) $(ADMINUTIL_DEP) $(ICU_DEP)
-
+EXTRA_LIBS_DEP += $(NSPR_DEP) $(LDAPSDK_DEP)
+ifeq ($(USE_ADMINSERVER), 1)
+ EXTRA_LIBS_DEP += $(ADMINUTIL_DEP)
+endif
+EXTRA_LIBS_DEP += $(ICU_DEP)
# we don't want to build with warnings-as-errors for the admin/ stuff, because
# it's got crappy C++ code which is LITTERED with warnings, most of which we
# can't fix because it comes from files in dist/, etc.
@@ -53,8 +58,15 @@ CFLAGS := $(subst -Werror,,$(CFLAGS))
endif
OLD_EXTRA_LIBS := $(EXTRA_LIBS)
-EXTRA_LIBS = $(DYNAMIC_DEPLINK) $(ADMINUTIL_LINK) $(LDAP_NOSSL_LINK) \
- $(SECURITYLINK) $(NSPRLINK) $(SETUPSDK_S_LINK) $(ICULINK) $(OLD_EXTRA_LIBS)
+EXTRA_LIBS = $(DYNAMIC_DEPLINK) $(LDAP_NOSSL_LINK)
+ifeq ($(USE_ADMINSERVER), 1)
+ EXTRA_LIBS += $(ADMINUTIL_LINK)
+endif
+EXTRA_LIBS += $(SECURITYLINK) $(NSPRLINK)
+ifeq ($(USE_SETUPSDK), 1)
+ EXTRA_LIBS += $(SETUPSDK_S_LINK)
+endif
+EXTRA_LIBS += $(ICULINK) $(OLD_EXTRA_LIBS)
# these are the libraries to use when building the installer for the open source version
OPENSOURCE_LIBS = $(LDAP_ADMLIB) $(LDAP_NOSSL_LINK) $(SECURITYLINK) $(NSPRLINK)
@@ -146,7 +158,9 @@ SECURE_BINS=
SECLIB=$(LIBSECURITY)
endif
-ADMIN_DLLGLUEOBJ=$(BUILD_ROOT)/built/$(ARCH)-$(SECURITY)-$(DEBUG)-admin/admin-lib/dllglue.o
+ifeq ($(USE_ADMINSERVER), 1)
+ ADMIN_DLLGLUEOBJ=$(BUILD_ROOT)/built/$(ARCH)-$(SECURITY)-$(DEBUG)-admin/admin-lib/dllglue.o
+endif
ifeq ($(ARCH),AIX)
DLLGLUEOBJ=
@@ -156,29 +170,27 @@ endif
$(OBJDEST)/key.res: key.rc
$(RC) $(OFFLAG)$(OBJDEST)/key.res ey.rc
-OLD_PROGS = ds_pcontrol ds_impldif \
- ds_backldif ds_backdb ds_restdb \
- ds_monitor ds_conf ds_rmldif \
- commit index ds_acccon ds_perf ds_dbconf ds_conf_check \
- ds_net ds_ldap ds_pwconf ds_inconf ds_grplst ds_grpcrt \
- ds_version ds_client ds_secpref ds_secact instindex \
- ds_reploc ds_repinit ldif2replica ds_addldif ds_ldif2ldap clpstat \
- ds_sscfg ds_attr_manage ds_oc_view ds_oc_create ds_schema_update \
- ds_replov ds_pw ds_snmpconf
-
-PROGS = start restart shutdown ds_ldif2db \
+PROGS = ds_newinst
+ifeq ($(USE_ADMINSERVER), 1)
+PROGS += start restart shutdown ds_ldif2db \
ds_db2ldif ds_db2bak ds_listdb \
- ds_bak2db ds_rmdb ds_create ds_newinst \
+ ds_bak2db ds_rmdb ds_create \
ds_remove ds_snmpctrl vlvindex addindex
+endif
ifeq ($(ARCH), WINNT)
SERVER_PROGS = namegen latest_file
endif
+ifeq ($(USE_ADMINSERVER), 1)
OBJECTS= init_ds_env.o
+endif
ifeq ($(ARCH), WINNT)
-OBJECTS += namegen.o latest_file.o ds_remove_uninst.o
+OBJECTS += namegen.o latest_file.o
+ifeq ($(USE_SETUPSDK), 1)
+ OBJECTS += ds_remove_uninst.o
+endif
endif
ifeq ($(ARCH), WINNT)
@@ -212,9 +224,6 @@ $(SCRIPTSDIR):
.PHONY: installPerlFiles
-#NSSetupSDK:
-# $(MAKE) -f NSSetupSDK_Base.mk $(MFLAGS) all
-
clean:
-@echo $(BINS)
-$(RM) $(BINS)
@@ -236,13 +245,13 @@ $(BINDIR)/ds_newinst: $(OBJDEST)/ds_newinst.o $(OBJDEST)/cfg_sspt.o \
$(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o
$(LINK_EXE_NOLIBSOBJS) $(SHARED) $(EXTRALDFLAGS) \
$(OBJDEST)/ds_newinst.o $(OBJDEST)/cfg_sspt.o \
- $(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o $(OPENSOURCE_LIBS)
+ $(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o $(EXTRA_LIBS)
$(BINDIR)/ds_newinst.exe: $(OBJDEST)/ds_newinst.o $(OBJDEST)/cfg_sspt.o \
$(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o
$(LINK_EXE) $(NT_NOLIBS) $(OBJDEST)/ds_newinst.o $(OBJDEST)/cfg_sspt.o \
$(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o \
- $(LIBNT) $(OPENSOURCE_LIBS)
+ $(LIBNT) $(NSPRLINK) $(EXTRA_LIBS) $(DB_LIB)
# linking this file causes a .exp and a .lib file to be generated which don't seem
# to be required while running, so I get rid of them
$(RM) $(subst .exe,.exp,$@) $(subst .exe,.lib,$@)
diff --git a/ldap/cm/Makefile b/ldap/cm/Makefile
index 9c4fdc7f9..288e7cf38 100644
--- a/ldap/cm/Makefile
+++ b/ldap/cm/Makefile
@@ -27,7 +27,6 @@ ADMSERV_DEPS = 1
include $(BUILD_ROOT)/nsconfig.mk
include $(BUILD_ROOT)/ldap/nsldap.mk
include $(BUILD_ROOT)/ldap/javarules.mk
-include $(BUILD_ROOT)/ns_usedb.mk
include $(BUILD_ROOT)/ns_usesh.mk
NSDISTMODE = copy
@@ -279,6 +278,7 @@ endif
done
# install the DSMLGW into the client directory
+ifeq ($(USE_DSMLGW), 1)
$(MKDIR) $(RELDIR)/clients/dsmlgw
$(CP) -R $(NSDIST)/classes/$(AXIS_REL_DIR)/webapps/axis/* $(RELDIR)/clients/dsmlgw/
@@ -295,7 +295,7 @@ endif
$(INSTALL) -m 644 $(NSDIST)/classes/saaj.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
$(INSTALL) -m 644 $(NSDIST)/classes/xercesImpl.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
$(INSTALL) -m 644 $(NSDIST)/classes/xml-apis.jar $(RELDIR)/clients/dsmlgw/WEB-INF/lib
-
+endif # USE_DSMLGW
# PACKAGE_UNDER_JAVA is defined in components.mk - these are component .jar files to install
# with the other component files that we don't necessarily pick up from the admin server build
@@ -320,6 +320,7 @@ endif
# fi
### Package up the orgchart ###
+ifeq ($(USE_ORGCHART), 1)
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/orgchart/*.gif $(RELDIR)/clients/orgchart/html
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/orgchart/*.html $(RELDIR)/clients/orgchart/html
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/clients/orgchart/*.css $(RELDIR)/clients/orgchart/html
@@ -335,6 +336,7 @@ else
chmod 755 $(RELDIR)/clients/orgchart/bin/org
chmod 755 $(RELDIR)/clients/orgchart/bin/myorg
endif
+endif # USE_ORGCHART
### end orgchart package ###
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/schema/*.ldif $(RELDIR)/bin/slapd/install/schema
@@ -366,8 +368,8 @@ endif
# the plugin API
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/servers/slapd/slapi-plugin.h $(RELDIR)/plugins/slapd/slapi/include
- $(INSTALL) -m 644 $(NSPR_BUILD_DIR)/include/*.h $(RELDIR)/plugins/slapd/slapi/include
- $(INSTALL) -m 644 $(NSPR_BUILD_DIR)/include/obsolete/*.h $(RELDIR)/plugins/slapd/slapi/include/obsolete
+ $(INSTALL) -m 644 $(NSPR_INCDIR)/*.h $(RELDIR)/plugins/slapd/slapi/include
+ $(INSTALL) -m 644 $(NSPR_INCDIR)/obsolete/*.h $(RELDIR)/plugins/slapd/slapi/include/obsolete
$(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/servers/slapd/slapi-plugin-compat4.h $(RELDIR)/plugins/slapd/slapi/include
# if [ -f $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/docs/plugin/README ] ; \
# then $(INSTALL) -m 644 $(BUILD_DRIVE)$(BUILD_ROOT)/ldap/docs/plugin/README $(RELDIR)/plugins/slapd ; \
@@ -406,11 +408,15 @@ endif
# install the ds jar file in the <server root>/$(DS_JAR_DEST_PATH) directory
# also install the other jar files we use
+ifeq ($(USE_CONSOLE), 1)
$(INSTALL) -m 644 $(NSDIST)/classes/$(LDAPCONSOLEJAR) $(RELDIR)/$(DS_JAR_DEST_PATH)
$(INSTALL) -m 644 $(NSDIST)/classes/$(LDAPCONSOLEJAR_EN) $(RELDIR)/$(DS_JAR_DEST_PATH)
+endif
+ifeq ($(USE_JAVATOOLS), 1)
$(INSTALL) -m 644 $(DS_JAR_SRC_PATH)/$(XMLTOOLS_JAR_FILE) $(RELDIR)/$(DS_JAR_DEST_PATH)
$(INSTALL) -m 644 $(NSDIST)/classes/$(CRIMSONJAR) $(RELDIR)/$(DS_JAR_DEST_PATH)
$(INSTALL) -m 644 $(NSDIST)/classes/$(CRIMSON_LICENSE) $(RELDIR)/$(DS_JAR_DEST_PATH)
+endif
# Images for IM Presence plugin
ifdef BUILD_PRESENCE
diff --git a/ldap/servers/Makefile b/ldap/servers/Makefile
index 01b2797c3..a06668595 100644
--- a/ldap/servers/Makefile
+++ b/ldap/servers/Makefile
@@ -48,7 +48,9 @@ _plugins:
cd plugins; $(MAKE) $(MFLAGS) all
_snmp:
+ifdef still_waiting_for_net_snmp
cd snmp; $(MAKE) $(MFLAGS) all
+endif
_slapdtools:
cd slapd/tools; $(MAKE) $(MFLAGS) all
diff --git a/nsconfig.mk b/nsconfig.mk
index 2afe1cb96..48239cc21 100644
--- a/nsconfig.mk
+++ b/nsconfig.mk
@@ -26,6 +26,17 @@ MAKE=gmake $(BUILDOPT)
# 7/12/96 Adrian - allow MAKEFLAGS to propagate
# override MAKEFLAGS :=
+# all of these things are on by default for internal builds
+ifdef INTERNAL_BUILD
+ USE_ADMINSERVER:=1
+ USE_CONSOLE:=1
+ USE_DSMLGW:=1
+ USE_ORGCHART:=1
+ USE_DSGW:=1
+ USE_JAVATOOLS:=1
+ USE_SETUPSDK:=1
+endif
+
include $(BUILD_ROOT)/nsdefs.mk
include $(BUILD_ROOT)/component_versions.mk
| 0 |
84a845c490cf0cc3470975f2976f644552d010d2
|
389ds/389-ds-base
|
Issue 5980 - Improve instance startup failure handling (#5991)
* Issue 5980 - Improve instance startup failure handling - PR 5991
Displays the important error log messages (those that are not: INFO/DEBUG/WARNING) when the server fails to start
to provide the root cause of the failure and help to diagnose some CI tests failures.
Issue: #5990
Reviewed by: @tbordaz Thanks!
|
commit 84a845c490cf0cc3470975f2976f644552d010d2
Author: progier389 <[email protected]>
Date: Wed Nov 22 15:26:54 2023 +0100
Issue 5980 - Improve instance startup failure handling (#5991)
* Issue 5980 - Improve instance startup failure handling - PR 5991
Displays the important error log messages (those that are not: INFO/DEBUG/WARNING) when the server fails to start
to provide the root cause of the failure and help to diagnose some CI tests failures.
Issue: #5990
Reviewed by: @tbordaz Thanks!
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 7590ec442..b6cdb5307 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -1048,6 +1048,38 @@ class DirSrv(SimpleLDAPObject, object):
self.state = DIRSRV_STATE_OFFLINE
+ def dump_errorlog(self):
+ '''
+ Its logs all errors messages within the error log that occured
+ after the last startup.
+ '''
+ errlog = self.ds_paths.error_log
+ if os.path.isfile(errlog):
+ lines = []
+ nbskipped = 0
+ with open(errlog, 'r') as file:
+ for line in file:
+ keepit = True
+ if "starting up" in line:
+ nbskipped += len(lines)
+ lines = []
+ for key in ( 'DEBUG', 'INFO', 'NOTICE', 'WARN' ):
+ if key in line:
+ keepit = False
+ nbskipped += 1
+ break
+ if keepit:
+ lines.append(line)
+ for line in lines:
+ # using logger.info because for some reason:
+ # - self.log may not be initialized
+ # - logger.error() does not log anything
+ logger.info(line.strip())
+ if not lines:
+ logger.info('No significant errors found in %s. (%d lines ignored)' % (errlog, nbskipped))
+ else:
+ logger.info('Cannot find the error log file %s.' % errlog)
+
def start(self, timeout=120, post_open=True):
'''
It starts an instance and rebind it. Its final state after rebind
@@ -1058,7 +1090,8 @@ class DirSrv(SimpleLDAPObject, object):
@return None
- @raise ValueError
+ @raise ValueError (if error and systemd is not used)
+ @raise subprocess.CalledProcessError (if error and systemd is used)
'''
if not self.isLocal:
self.log.error("This is a remote instance!")
@@ -1071,7 +1104,13 @@ class DirSrv(SimpleLDAPObject, object):
if self.with_systemd():
self.log.debug("systemd status -> True")
# Do systemd things here ...
- subprocess.check_output(["systemctl", "start", "dirsrv@%s" % self.serverid], stderr=subprocess.STDOUT)
+ try:
+ subprocess.check_output(["systemctl", "start", "dirsrv@%s" % self.serverid], stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ self.dump_errorlog()
+ logger.info('Failed to start dirsrv@%s: "%s"' % (self.serverid, e.output.decode()))
+ logger.info(e)
+ raise e from None
else:
self.log.debug("systemd status -> False")
# Start the process.
@@ -1095,6 +1134,7 @@ class DirSrv(SimpleLDAPObject, object):
self.log.debug("DEBUG: starting with %s" % cmd)
output = subprocess.check_output(*cmd, env=env, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
+ self.dump_errorlog()
self.log.error('Failed to start ns-slapd: "%s"' % e.output.decode())
self.log.error(e)
raise ValueError('Failed to start DS')
@@ -1116,6 +1156,7 @@ class DirSrv(SimpleLDAPObject, object):
time.sleep(1)
count -= 1
if not pid_exists(pid):
+ self.dump_errorlog()
self.log.error("pid (%s) of ns-slapd process does not exist" % pid)
raise ValueError("Failed to start DS")
if post_open:
| 0 |
b8e9773e9316bf09401c1c3296659e7dead1baf4
|
389ds/389-ds-base
|
Ticket 51177 - on upgrade configuration handlers
Bug Description: 389 to function in docker and other environments
such as restore-from-backup, needs to be able to upgrade it's configuration
on startup. This lets us ship-and-enable new features, upgrade plugins
and more (similar to libglobs upgrades)
Previously we had only basic machinery for this (IE make sure this
entry exists like this) which would always write the content. This
caused problems where plugins would re-enable on restart, or couldn't
be removed.
Fix Description: This adds an upgrade processor and an exists_or_add
so that we can do stateful creates of entries, but without trampling
user modifications IE disabling plugins.
https://pagure.io/389-ds-base/issue/51177
fixes: #51177
Author: William Brown <[email protected]>
Review by: tbordaz, mreynolds (Thanks!)
|
commit b8e9773e9316bf09401c1c3296659e7dead1baf4
Author: William Brown <[email protected]>
Date: Thu Aug 20 14:00:20 2020 +1000
Ticket 51177 - on upgrade configuration handlers
Bug Description: 389 to function in docker and other environments
such as restore-from-backup, needs to be able to upgrade it's configuration
on startup. This lets us ship-and-enable new features, upgrade plugins
and more (similar to libglobs upgrades)
Previously we had only basic machinery for this (IE make sure this
entry exists like this) which would always write the content. This
caused problems where plugins would re-enable on restart, or couldn't
be removed.
Fix Description: This adds an upgrade processor and an exists_or_add
so that we can do stateful creates of entries, but without trampling
user modifications IE disabling plugins.
https://pagure.io/389-ds-base/issue/51177
fixes: #51177
Author: William Brown <[email protected]>
Review by: tbordaz, mreynolds (Thanks!)
diff --git a/Makefile.am b/Makefile.am
index 0c15072cd..2ccee1727 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1544,6 +1544,7 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \
ldap/servers/slapd/thread_data.c \
ldap/servers/slapd/uniqueid.c \
ldap/servers/slapd/uniqueidgen.c \
+ ldap/servers/slapd/upgrade.c \
ldap/servers/slapd/utf8.c \
ldap/servers/slapd/utf8compare.c \
ldap/servers/slapd/util.c \
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 52c64fa3c..0839d0564 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -369,6 +369,72 @@ slapi_add_entry_internal_set_pb(Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **
slapi_pblock_set(pb, SLAPI_PLUGIN_IDENTITY, plugin_identity);
}
+int
+slapi_exists_or_add_internal(
+ Slapi_DN *dn, const char *filter, const char *entry, const char *modifier_name
+) {
+ /* Search */
+ Slapi_PBlock *search_pb = slapi_pblock_new();
+ int search_result = 0;
+ int search_nentries = 0;
+
+ slapi_search_internal_set_pb_ext(search_pb,
+ dn,
+ LDAP_SCOPE_BASE,
+ filter,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ 0);
+
+ slapi_search_internal_pb(search_pb);
+
+ slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &search_result);
+ if (search_result == LDAP_SUCCESS) {
+ slapi_pblock_get(search_pb, SLAPI_NENTRIES, &search_nentries);
+ }
+ slapi_pblock_destroy(search_pb);
+
+ slapi_log_error(SLAPI_LOG_DEBUG, "slapi_exists_or_add_internal", "search_internal result -> %d, %d\n", search_result, search_nentries);
+
+ if (search_result != LDAP_SUCCESS) {
+ return search_result;
+ }
+
+ /* Did it exist? */
+ if (search_nentries == 0) {
+ int create_result = 0;
+ /* begin the create */
+ slapi_log_error(SLAPI_LOG_DEBUG, "slapi_exists_or_add_internal", "creating entry:\n%s\n", entry);
+ Slapi_Entry *s_entry = slapi_str2entry((char *)entry, 0);
+
+ if (s_entry == NULL) {
+ slapi_log_error(SLAPI_LOG_ERR, "slapi_exists_or_add_internal", "failed to parse entry\n");
+ return -1;
+ }
+
+ /* Set modifiers name */
+ slapi_entry_attr_set_charptr(s_entry, "internalModifiersname", modifier_name);
+
+ /* do the add */
+ Slapi_PBlock *add_pb = slapi_pblock_new();
+
+ slapi_add_entry_internal_set_pb(add_pb, s_entry, NULL, NULL, 0);
+ slapi_add_internal_pb(add_pb);
+
+ slapi_pblock_get(add_pb, SLAPI_PLUGIN_INTOP_RESULT, &create_result);
+ slapi_pblock_destroy(add_pb);
+
+ slapi_log_error(SLAPI_LOG_DEBUG, "slapi_exists_or_add_internal", "add_internal result -> %d\n", create_result);
+
+ return create_result;
+ }
+ /* No action was taken */
+ return LDAP_SUCCESS;
+}
+
/* Helper functions */
static int
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 2af3f38fc..e3e97f3f8 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2009,6 +2009,10 @@ slapi_sdn_new_dn_byval(const char *dn)
return sdn;
}
+/* This is a much clearer name for what we want to achieve. */
+Slapi_DN *
+slapi_sdn_new_from_char_dn(const char *dn) __attribute__((weak, alias("slapi_sdn_new_dn_byval")));
+
Slapi_DN *
slapi_sdn_new_ndn_byval(const char *ndn)
{
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index ec4d86360..ddefbad6c 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -60,6 +60,8 @@ union semun
#include "fe.h"
#include <nss.h>
+#include <slapi-private.h>
+
#ifdef LINUX
/* For mallopt. Should be removed soon. */
#include <malloc.h>
@@ -1021,6 +1023,20 @@ main(int argc, char **argv)
*/
task_cleanup();
+ /*
+ * This step checks for any updates and changes on upgrade
+ * specifically, it manages assumptions about what plugins should exist, and their
+ * configurations, and potentially even the state of configurations on the server
+ * and their removal and deprecation.
+ *
+ * Has to be after uuid + dse to change config, but before password and plugins
+ * so we can adjust these configurations.
+ */
+ if (upgrade_server() != UPGRADE_SUCCESS) {
+ return_value = 1;
+ goto cleanup;
+ }
+
/*
* Initialize password storage in entry extension.
* Need to be initialized before plugin_startall in case stucked
diff --git a/ldap/servers/slapd/pw_verify.c b/ldap/servers/slapd/pw_verify.c
index 4ff1fa2fd..2615aa11f 100644
--- a/ldap/servers/slapd/pw_verify.c
+++ b/ldap/servers/slapd/pw_verify.c
@@ -26,6 +26,10 @@
#include "slap.h"
#include "fe.h"
+#ifdef RUST_ENABLE
+#include <rust-nsslapd-private.h>
+#endif
+
int
pw_verify_root_dn(const char *dn, const Slapi_Value *cred)
{
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 7e5dfb93b..1b2b65cb1 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -12,6 +12,8 @@
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
+#pragma once
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -2729,5 +2731,14 @@ extern char *attr_dataversion;
#define _SEC_PER_DAY 86400
#define _MAX_SHADOW 99999
+/*
+ * SERVER UPGRADE INTERNALS
+ */
+typedef enum _upgrade_status {
+ UPGRADE_SUCCESS = 0,
+ UPGRADE_FAILURE = 1,
+} upgrade_status;
+
+upgrade_status upgrade_server(void);
#endif /* _slap_h_ */
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 713aaee01..fa79a4951 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -2380,6 +2380,8 @@ Slapi_DN *slapi_sdn_new(void);
*/
Slapi_DN *slapi_sdn_new_dn_byval(const char *dn);
+Slapi_DN *slapi_sdn_new_from_char_dn(const char *dn);
+
/**
* Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
*
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index e00f55924..f35685772 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1,12 +1,15 @@
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
* Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2020 William Brown <[email protected]>
* All rights reserved.
*
* License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
+#pragma once
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
diff --git a/ldap/servers/slapd/upgrade.c b/ldap/servers/slapd/upgrade.c
new file mode 100644
index 000000000..47d608eb7
--- /dev/null
+++ b/ldap/servers/slapd/upgrade.c
@@ -0,0 +1,81 @@
+/* BEGIN COPYRIGHT BLOCK
+ * Copyright (C) 2017 Red Hat, Inc.
+ * Copyright (C) 2020 William Brown <[email protected]>
+ * All rights reserved.
+ *
+ * License: GPL (version 3 or any later version).
+ * See LICENSE for details.
+ * END COPYRIGHT BLOCK */
+
+#include <slap.h>
+#include <slapi-private.h>
+
+/*
+ * This is called on server startup *before* plugins start
+ * but after config dse is read for operations. This allows
+ * us to make internal assertions about the state of the configuration
+ * at start up, enable plugins, and more.
+ *
+ * The functions in this file are named as:
+ * upgrade_xxx_yyy, where xxx is the minimum version of the project
+ * and yyy is the feature that is having it's configuration upgrade
+ * or altered.
+ */
+
+static char *modifier_name = "cn=upgrade internal,cn=config";
+
+static upgrade_status
+upgrade_entry_exists_or_create(char *upgrade_id, char *filter, char *dn, char *entry) {
+ upgrade_status uresult = UPGRADE_SUCCESS;
+ char *dupentry = strdup(entry);
+
+ Slapi_DN *base_sdn = slapi_sdn_new_from_char_dn(dn);
+ /* If not, create it. */
+ int result = slapi_exists_or_add_internal(base_sdn, filter, dupentry, modifier_name);
+
+ if (result != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, upgrade_id, "Failed to create entry: %"PRId32": %s\n", result);
+ uresult = UPGRADE_FAILURE;
+ }
+ slapi_ch_free_string(&dupentry);
+ slapi_sdn_free(&base_sdn);
+ return uresult;
+}
+
+#ifdef RUST_ENABLE
+static upgrade_status
+upgrade_143_entryuuid_exists(void) {
+ char *entry = "dn: cn=entryuuid,cn=plugins,cn=config\n"
+ "objectclass: top\n"
+ "objectclass: nsSlapdPlugin\n"
+ "cn: entryuuid\n"
+ "nsslapd-pluginpath: libentryuuid-plugin\n"
+ "nsslapd-plugininitfunc: entryuuid_plugin_init\n"
+ "nsslapd-plugintype: betxnpreoperation\n"
+ "nsslapd-pluginenabled: on\n"
+ "nsslapd-pluginId: entryuuid\n"
+ "nsslapd-pluginVersion: none\n"
+ "nsslapd-pluginVendor: 389 Project\n"
+ "nsslapd-pluginDescription: entryuuid\n";
+
+ return upgrade_entry_exists_or_create(
+ "upgrade_143_entryuuid_exists",
+ "(cn=entryuuid)",
+ "cn=entryuuid,cn=plugins,cn=config",
+ entry
+ );
+}
+#endif
+
+upgrade_status
+upgrade_server(void) {
+#ifdef RUST_ENABLE
+ if (upgrade_143_entryuuid_exists() != UPGRADE_SUCCESS) {
+ return UPGRADE_FAILURE;
+ }
+#endif
+
+ return UPGRADE_SUCCESS;
+}
+
+
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.