commit_id
string
repo
string
commit_message
string
diff
string
label
int64
0410819d48795fca4faf986cf8658c34c4d929e3
389ds/389-ds-base
Add strict DN syntax enforcement option. The DN syntax has become more restrictive over time, and the current rules are quite strict. Strict adherence to the rules defined in RFC 4514, section 3, would likely cause some pain to client applications. Things such as spaces between the RDN components are not allowed, yet many people use them still since they were allowed in the previous specification outlined in RFC 1779. To deal with the special circumstances around validation of the DN syntax, a configuration attribute is provided named nsslapd-dn-validate-strict. This configuration attribute will ensure that the value strictly adheres to the rules defined in RFC 4514, section 3 if it is set to on. If it is set to off, the server will normalize the value before checking it for syntax violations. Our current normalization function was designed to handle DN values adhering to RFC 1779 or RFC 2253
commit 0410819d48795fca4faf986cf8658c34c4d929e3 Author: Nathan Kinder <[email protected]> Date: Wed May 13 11:12:11 2009 -0700 Add strict DN syntax enforcement option. The DN syntax has become more restrictive over time, and the current rules are quite strict. Strict adherence to the rules defined in RFC 4514, section 3, would likely cause some pain to client applications. Things such as spaces between the RDN components are not allowed, yet many people use them still since they were allowed in the previous specification outlined in RFC 1779. To deal with the special circumstances around validation of the DN syntax, a configuration attribute is provided named nsslapd-dn-validate-strict. This configuration attribute will ensure that the value strictly adheres to the rules defined in RFC 4514, section 3 if it is set to on. If it is set to off, the server will normalize the value before checking it for syntax violations. Our current normalization function was designed to handle DN values adhering to RFC 1779 or RFC 2253 diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in index 232d9f2e7..54a9c4f49 100644 --- a/ldap/ldif/template-dse.ldif.in +++ b/ldap/ldif/template-dse.ldif.in @@ -25,6 +25,7 @@ nsslapd-enquote-sup-oc: off nsslapd-localhost: %fqdn% nsslapd-schemacheck: on nsslapd-syntaxcheck: on +nsslapd-dn-validate-strict: off nsslapd-rewrite-rfc1274: off nsslapd-return-exact-case: on nsslapd-ssl-check-hostname: on diff --git a/ldap/servers/plugins/syntaxes/dn.c b/ldap/servers/plugins/syntaxes/dn.c index a6dcceda6..80a3f8bfa 100644 --- a/ldap/servers/plugins/syntaxes/dn.c +++ b/ldap/servers/plugins/syntaxes/dn.c @@ -141,6 +141,7 @@ dn_assertion2keys_sub( Slapi_PBlock *pb, char *initial, char **any, char *final, static int dn_validate( struct berval *val ) { int rc = 0; /* Assume value is valid */ + char *val_copy = NULL; if (val != NULL) { /* Per RFC 4514: @@ -154,10 +155,22 @@ static int dn_validate( struct berval *val ) * attributeValue = string / hexstring */ if (val->bv_len > 0) { + int strict = 0; char *p = val->bv_val; char *end = &(val->bv_val[val->bv_len - 1]); char *last = NULL; + /* Check if we should be performing strict validation. */ + strict = config_get_dn_validate_strict(); + if (!strict) { + /* Create a normalized copy of the value to use + * for validation. The original value will be + * stored in the backend unmodified. */ + val_copy = PL_strndup(val->bv_val, val->bv_len); + p = val_copy; + end = slapi_dn_normalize_to_end(p, NULL) - 1; + } + /* Validate one RDN at a time in a loop. */ while (p <= end) { if ((rc = rdn_validate(p, end, &last)) != 0) { @@ -186,6 +199,9 @@ static int dn_validate( struct berval *val ) goto exit; } exit: + if (val_copy) { + slapi_ch_free_string(&val_copy); + } return rc; } diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c index 1af1b77b4..627575729 100644 --- a/ldap/servers/slapd/config.c +++ b/ldap/servers/slapd/config.c @@ -241,11 +241,13 @@ slapd_bootstrap_config(const char *configdir) char schemacheck[BUFSIZ]; char syntaxcheck[BUFSIZ]; char syntaxlogging[BUFSIZ]; + char dn_validate_strict[BUFSIZ]; Slapi_DN plug_dn; workpath[0] = loglevel[0] = maxdescriptors[0] = '\0'; val[0] = logenabled[0] = schemacheck[0] = syntaxcheck[0] = '\0'; syntaxlogging[0] = _localuser[0] = '\0'; + dn_validate_strict[0] = '\0'; /* Convert LDIF to entry structures */ slapi_sdn_init_dn_byref(&plug_dn, PLUGIN_BASE_DN); @@ -490,6 +492,20 @@ slapd_bootstrap_config(const char *configdir) } } + /* see if we need to enable strict dn validation */ + if (!dn_validate_strict[0] && + entry_has_attr_and_value(e, CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE, + dn_validate_strict, sizeof(dn_validate_strict))) + { + if (config_set_dn_validate_strict(CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE, + dn_validate_strict, errorbuf, CONFIG_APPLY) + != LDAP_SUCCESS) + { + LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile, + CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE, errorbuf); + } + } + /* see if we need to expect quoted schema values */ if (entry_has_attr_and_value(e, CONFIG_ENQUOTE_SUP_OC_ATTRIBUTE, val, sizeof(val))) diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 30ad5f3a6..8c13a9b6c 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -327,6 +327,9 @@ static struct config_get_and_set { {CONFIG_SYNTAXLOGGING_ATTRIBUTE, config_set_syntaxlogging, NULL, 0, (void**)&global_slapdFrontendConfig.syntaxlogging, CONFIG_ON_OFF, NULL}, + {CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE, config_set_dn_validate_strict, + NULL, 0, + (void**)&global_slapdFrontendConfig.dn_validate_strict, CONFIG_ON_OFF, NULL}, {CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE, config_set_ds4_compatible_schema, NULL, 0, (void**)&global_slapdFrontendConfig.ds4_compatible_schema, @@ -899,6 +902,7 @@ FrontendConfig_init () { cfg->schemacheck = LDAP_ON; cfg->syntaxcheck = LDAP_OFF; cfg->syntaxlogging = LDAP_OFF; + cfg->dn_validate_strict = LDAP_OFF; cfg->ds4_compatible_schema = LDAP_OFF; cfg->enquote_sup_oc = LDAP_OFF; cfg->lastmod = LDAP_ON; @@ -2458,6 +2462,20 @@ config_set_syntaxlogging( const char *attrname, char *value, char *errorbuf, int return retVal; } +int +config_set_dn_validate_strict( const char *attrname, char *value, char *errorbuf, int apply ) { + int retVal = LDAP_SUCCESS; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + + retVal = config_set_onoff ( attrname, + value, + &(slapdFrontendConfig->dn_validate_strict), + errorbuf, + apply); + + return retVal; +} + int config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply ) { int retVal = LDAP_SUCCESS; @@ -4092,6 +4110,18 @@ config_get_syntaxlogging() { return retVal; } +int +config_get_dn_validate_strict() { + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + int retVal; + + CFG_LOCK_READ(slapdFrontendConfig); + retVal = slapdFrontendConfig->dn_validate_strict; + CFG_UNLOCK_READ(slapdFrontendConfig); + + return retVal; +} + int config_get_ds4_compatible_schema() { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index c561196df..2041a9978 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -266,6 +266,7 @@ int config_set_readonly( const char *attrname, char *value, char *errorbuf, int int config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_syntaxcheck( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_syntaxlogging( const char *attrname, char *value, char *errorbuf, int apply ); +int config_set_dn_validate_strict( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_schema_ignore_trailing_spaces( const char *attrname, char *value, char *errorbuf, int apply ); int config_set_rootdn( const char *attrname, char *value, char *errorbuf, int apply ); @@ -410,6 +411,7 @@ int config_get_security(); int config_get_schemacheck(); int config_get_syntaxcheck(); int config_get_syntaxlogging(); +int config_get_dn_validate_strict(); int config_get_ds4_compatible_schema(); int config_get_schema_ignore_trailing_spaces(); char *config_get_rootdn(); diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index cec186f96..724bef93b 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1639,7 +1639,8 @@ typedef struct _slapdEntryPoints { #define CONFIG_SCHEMACHECK_ATTRIBUTE "nsslapd-schemacheck" #define CONFIG_SYNTAXCHECK_ATTRIBUTE "nsslapd-syntaxcheck" #define CONFIG_SYNTAXLOGGING_ATTRIBUTE "nsslapd-syntaxlogging" -#define CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE "nsslapd-ds4-compatible-schema" +#define CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE "nsslapd-dn-validate-strict" +#define CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE "nsslapd-ds4-compatible-schema" #define CONFIG_SCHEMA_IGNORE_TRAILING_SPACES "nsslapd-schema-ignore-trailing-spaces" #define CONFIG_SCHEMAREPLACE_ATTRIBUTE "nsslapd-schemareplace" #define CONFIG_LOGLEVEL_ATTRIBUTE "nsslapd-errorlog-level" @@ -1856,6 +1857,7 @@ typedef struct _slapdFrontendConfig { int schemacheck; int syntaxcheck; int syntaxlogging; + int dn_validate_strict; int ds4_compatible_schema; int schema_ignore_trailing_spaces; int secureport;
0
23bf6060d3088f9a3f5f5fac1b18faa4bc8756c8
389ds/389-ds-base
573060 - DN normalizer: ESC HEX HEX is not normalized ( https://bugzilla.redhat.com/show_bug.cgi?id=573060 Description: there were 2 bugs handling ESC HEX HEXT format. It was ignoring non-ASCII characters. Now, they are covered.
commit 23bf6060d3088f9a3f5f5fac1b18faa4bc8756c8 Author: Noriko Hosoi <[email protected]> Date: Fri Mar 12 17:30:49 2010 -0800 573060 - DN normalizer: ESC HEX HEX is not normalized ( https://bugzilla.redhat.com/show_bug.cgi?id=573060 Description: there were 2 bugs handling ESC HEX HEXT format. It was ignoring non-ASCII characters. Now, they are covered. diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c index 2e5ac001c..f9c22589d 100644 --- a/ldap/servers/slapd/dn.c +++ b/ldap/servers/slapd/dn.c @@ -361,9 +361,7 @@ substr_dn_normalize( char *dn, char *end ) gotesc = 1; if ( s+2 < end ) { int n = hexchar2int( s[1] ); - /* If 8th bit is on, the char is not ASCII (not UTF-8). - * Thus, not UTF-8 */ - if ( n >= 0 && n < 8 ) { + if ( n >= 0 && n < 16 ) { int n2 = hexchar2int( s[2] ); if ( n2 >= 0 ) { n = (n << 4) + n2; diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c index 71a2305b9..d26b0b984 100644 --- a/ldap/servers/slapd/util.c +++ b/ldap/servers/slapd/util.c @@ -217,9 +217,7 @@ strcpy_unescape_value( char *d, const char *s ) gotesc = 1; if ( s+2 < end ) { int n = hexchar2int( s[1] ); - /* If 8th bit is on, the char is not ASCII (not UTF-8). - * Thus, not UTF-8 */ - if ( n >= 0 && n < 8 ) { + if ( n >= 0 && n < 16 ) { int n2 = hexchar2int( s[2] ); if ( n2 >= 0 ) { n = (n << 4) + n2;
0
fef7f178b34feccc920c29aafe765ad52dbd074d
389ds/389-ds-base
Issue 3 - ansible-ds - Prefix handling fix (#5275) Description: When we run 389-ds in Ansible, its processing sets PREFIX to "", so we should check for both - None and "". Related: https://github.com/389ds/ansible-ds/issues/3 Reviewed by: @progier389 (Thanks!)
commit fef7f178b34feccc920c29aafe765ad52dbd074d Author: Simon Pichugin <[email protected]> Date: Tue Apr 26 08:05:51 2022 -0700 Issue 3 - ansible-ds - Prefix handling fix (#5275) Description: When we run 389-ds in Ansible, its processing sets PREFIX to "", so we should check for both - None and "". Related: https://github.com/389ds/ansible-ds/issues/3 Reviewed by: @progier389 (Thanks!) diff --git a/src/lib389/lib389/paths.py b/src/lib389/lib389/paths.py index a1a0bf144..f17e30dd4 100644 --- a/src/lib389/lib389/paths.py +++ b/src/lib389/lib389/paths.py @@ -142,7 +142,8 @@ class Paths(object): def _get_defaults_loc(self, search_paths): ## THIS IS HOW WE HANDLE A PREFIX INSTALL prefix = os.getenv('PREFIX') - if prefix is not None: + # When we run 389-ds in Ansible, its processing sets PREFIX to "", so we should check for both - None and "" + if prefix: spath = os.path.join(prefix, 'share/dirsrv/inf/defaults.inf') if os.path.isfile(spath): return spath
0
debe2781a39dd9be839caefdc4ff1b796df2d320
389ds/389-ds-base
Issue #35 - dsconf automember support Bug Description: Add support for managing automember to dsconf Fix Description: Initial patch which adds AutoMembershipPlugin, AutoMembershipDefinition and AutoMembershipDefinitions classes to plugins.py and adds tests for checking valid scope, valid filter and if user is correctly added to the group. https://pagure.io/lib389/issue/35 Author: Alisha Aneja Review by: ???
commit debe2781a39dd9be839caefdc4ff1b796df2d320 Author: alisha17 <[email protected]> Date: Thu Dec 7 00:17:19 2017 +1100 Issue #35 - dsconf automember support Bug Description: Add support for managing automember to dsconf Fix Description: Initial patch which adds AutoMembershipPlugin, AutoMembershipDefinition and AutoMembershipDefinitions classes to plugins.py and adds tests for checking valid scope, valid filter and if user is correctly added to the group. https://pagure.io/lib389/issue/35 Author: Alisha Aneja Review by: ??? diff --git a/dirsrvtests/tests/suites/automember_plugin/automember_test.py b/dirsrvtests/tests/suites/automember_plugin/automember_test.py new file mode 100644 index 000000000..b13c1b2cc --- /dev/null +++ b/dirsrvtests/tests/suites/automember_plugin/automember_test.py @@ -0,0 +1,139 @@ +import logging +import pytest +import os +import ldap +from lib389.utils import ds_is_older +from lib389._constants import * +from lib389.plugins import AutoMembershipPlugin, AutoMembershipDefinition, AutoMembershipDefinitions +from lib389._mapped_object import DSLdapObjects, DSLdapObject +from lib389 import agreement +from lib389.idm.user import UserAccount, UserAccounts, TEST_USER_PROPERTIES +from lib389.idm.group import Groups, Group +from lib389.topologies import topology_st as topo +from lib389._constants import DEFAULT_SUFFIX + + +# Skip on older versions +pytestmark = pytest.mark.skipif(ds_is_older('1.3.7'), reason="Not implemented") + +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__) + + [email protected](scope="module") +def automember_fixture(topo, request): + + groups = Groups(topo.standalone, DEFAULT_SUFFIX) + group = groups.create(properties={'cn': 'testgroup'}) + + automemberplugin = AutoMembershipPlugin(topo.standalone) + automemberplugin.enable() + + topo.standalone.restart() + + automember_prop = { + 'cn': 'testgroup_definition', + 'autoMemberScope': 'ou=People,' + DEFAULT_SUFFIX, + 'autoMemberFilter': 'objectclass=*', + 'autoMemberDefaultGroup': group.dn, + 'autoMemberGroupingAttr': 'member:dn', + } + + automembers = AutoMembershipDefinitions(topo.standalone, "cn=Auto Membership Plugin,cn=plugins,cn=config") + + automember = automembers.create(properties=automember_prop) + + return (group, automembers, automember) + + +def test_automemberscope(automember_fixture, topo): + """Test if the automember scope is valid + + :id: c3d3f250-e7fd-4441-8387-3d24c156e982 + :setup: Standalone instance, enabled Auto Membership Plugin + :steps: + 1. Create automember with invalid cn that raises + UNWILLING_TO_PERFORM exception + 2. If exception raised, set scope to any cn + 3. If exception is not raised, set scope to with ou=People + :expectedresults: + 1. Should be success + 2. Should be success + 3. Should be success + """ + + (group, automembers, automember) = automember_fixture + + automember_prop = { + 'cn': 'anyrandomcn', + 'autoMemberScope': 'ou=People,' + DEFAULT_SUFFIX, + 'autoMemberFilter': 'objectclass=*', + 'autoMemberDefaultGroup': group.dn, + 'autoMemberGroupingAttr': 'member:dn', + } + + # depends on issue #49465 + + # with pytest.raises(ldap.UNWILLING_TO_PERFORM): + # automember = automembers.create(properties=automember_prop) + # automember.set_scope("cn=No Entry,%s" % DEFAULT_SUFFIX) + + automember.set_scope("ou=People,%s" % DEFAULT_SUFFIX) + + +def test_automemberfilter(automember_fixture, topo): + """Test if the automember filter is valid + + :id: 935c55de-52dc-4f80-b7dd-3aacd30f6df2 + :setup: Standalone instance, enabled Auto Membership Plugin + :steps: + 1. Create automember with invalid filter that raises + UNWILLING_TO_PERFORM exception + 2. If exception raised, set filter to the invalid filter + 3. If exception is not raised, set filter as all objectClasses + :expectedresults: + 1. Should be success + 2. Should be success + 3. Should be success + """ + + (group, automembers, automember) = automember_fixture + + automember_prop = { + 'cn': 'anyrandomcn', + 'autoMemberScope': 'ou=People,' + DEFAULT_SUFFIX, + 'autoMemberFilter': '(ou=People', + 'autoMemberDefaultGroup': group.dn, + 'autoMemberGroupingAttr': 'member:dn', + } + + with pytest.raises(ldap.UNWILLING_TO_PERFORM): + automember = automembers.create(properties=automember_prop) + automember.set_filter("(ou=People") + + automember.set_filter("objectClass=*") + + +def test_adduser(automember_fixture, topo): + """Test if member is automatically added to the group + + :id: 14f1e2f5-2162-41ab-962c-5293516baf2e + :setup: Standalone instance, enabled Auto Membership Plugin + :steps: + 1. Create a user + 2. Assert that the user is member of the group + :expectedresults: + 1. Should be success + 2. Should be success + """ + + (group, automembers, automember) = automember_fixture + + users = UserAccounts(topo.standalone, DEFAULT_SUFFIX) + user = users.create(properties=TEST_USER_PROPERTIES) + + assert group.is_member(user.dn) diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py index 3644193dc..6161500bc 100644 --- a/src/lib389/lib389/_mapped_object.py +++ b/src/lib389/lib389/_mapped_object.py @@ -222,10 +222,10 @@ class DSLdapObject(DSLogging): self._log.debug("%s present(%r) %s" % (self._dn, attr, value)) e = self._instance.search_ext_s(self._dn, ldap.SCOPE_BASE, attrlist=[attr, ], serverctrls=self._server_controls, clientctrls=self._client_controls)[0] - if value is None: - return e.hasAttr(attr) - else: - return e.hasValue(attr, value) + 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] def add(self, key, value): """Add an attribute with a value diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py index 9f86ec938..e0080d61a 100644 --- a/src/lib389/lib389/plugins.py +++ b/src/lib389/lib389/plugins.py @@ -387,9 +387,114 @@ class AccountUsabilityPlugin(Plugin): super(AccountUsabilityPlugin, self).__init__(instance, dn) class AutoMembershipPlugin(Plugin): + _plugin_properties = { + 'cn' : 'Auto Membership Plugin', + 'nsslapd-pluginEnabled' : 'off', + 'nsslapd-pluginPath' : 'libautomember-plugin', + 'nsslapd-pluginInitfunc' : 'automember_init', + 'nsslapd-pluginType' : 'betxnpreoperation', + 'nsslapd-plugin-depends-on-type' : 'database', + 'nsslapd-pluginId' : 'Auto Membership', + 'nsslapd-pluginVendor' : '389 Project', + 'nsslapd-pluginVersion' : '1.3.7.0', + 'nsslapd-pluginDescription' : 'Auto Membership plugin', + } + def __init__(self, instance, dn="cn=Auto Membership Plugin,cn=plugins,cn=config"): super(AutoMembershipPlugin, self).__init__(instance, dn) +class AutoMembershipDefinition(DSLdapObject): + """A single instance of Auto Membership Plugin entry + + :param instance: An instance + :type instance: lib389.DirSrv + :param dn: Entry DN + :type dn: str + """ + + def __init__(self, instance, dn=None): + super(AutoMembershipDefinition, self).__init__(instance, dn) + self._rdn_attribute = 'cn' + self._must_attributes = ['cn'] + self._create_objectclasses = ['top', 'AutoMemberDefinition'] + self._protected = False + + def get_groupattr(self): + """Get grouping attributes + + :returns: autoMemberGroupingAttr values + """ + return self.get_attr_vals_utf8('autoMemberGroupingAttr') + + def set_groupattr(self, attr): + """Set grouping attributes + + :param attr: autoMemberGroupingAttr value + :type attr: str + """ + self.set('autoMemberGroupingAttr', attr) + + def get_defaultgroup(self, attr): + """Get default group + + :returns: autoMemberDefaultGroup value + """ + return self.get_attr_vals_utf8('autoMemberDefaultGroup') + + def set_defaultgroup(self, attr): + """Set default group + + :param attr: autoMemberDefaultGroup value + :type attr: str + """ + self.set('autoMemberDefaultGroup', attr) + + def get_scope(self, attr): + """Get scope + + :returns: autoMemberScope value + """ + return self.get_attr_vals_utf8('autoMemberScope') + + def set_scope(self, attr): + """Set scope + + :param attr: autoMemberScope value + :type attr: str + """ + self.set('autoMemberScope', attr) + + def get_filter(self, attr): + """Get filter + + :returns: autoMemberFilter value + """ + return self.get_attr_vals_utf8('autoMemberFilter') + + def set_filter(self, attr): + """Set filter + + :param attr: autoMemberFilter value + :type attr: str + """ + self.set('autoMemberFilter', attr) + +class AutoMembershipDefinitions(DSLdapObjects): + """DSLdapObjects that represents Auto Membership Plugin entry + + :param instance: An instance + :type instance: lib389.DirSrv + :param basedn: Base DN for all account entries below + :type basedn: str + """ + + def __init__(self, instance, basedn): + super(AutoMembershipDefinitions, self).__init__(instance) + self._objectclasses = ['top','autoMemberDefinition'] + self._filterattrs = ['cn'] + self._childobject = AutoMembershipDefinition + self._basedn = basedn + class ContentSynchronizationPlugin(Plugin): def __init__(self, instance, dn="cn=Content Synchronization,cn=plugins,cn=config"): super(ContentSynchronizationPlugin, self).__init__(instance, dn)
0
2e8ffb5e5f0d4f0c1e6f6bd74d78cf8dc2d22de1
389ds/389-ds-base
Ticket 16 - with systemd should unset have systemd if pkgconfig not found Bug Description: On platforms that don't have systemd, we should check for this and correctly disable the systemd parts of svrcore. Fix Description: Add pkgconfig check to configure that will automatically disable systemd support if the pc file is not found. https://pagure.io/svrcore/issue/16 Author: wibrown Review by: lslebodn
commit 2e8ffb5e5f0d4f0c1e6f6bd74d78cf8dc2d22de1 Author: William Brown <[email protected]> Date: Mon Sep 5 11:48:03 2016 +1000 Ticket 16 - with systemd should unset have systemd if pkgconfig not found Bug Description: On platforms that don't have systemd, we should check for this and correctly disable the systemd parts of svrcore. Fix Description: Add pkgconfig check to configure that will automatically disable systemd support if the pc file is not found. https://pagure.io/svrcore/issue/16 Author: wibrown Review by: lslebodn diff --git a/m4/systemd.m4 b/m4/systemd.m4 index 238751a2c..6052acbda 100644 --- a/m4/systemd.m4 +++ b/m4/systemd.m4 @@ -22,7 +22,19 @@ AC_ARG_WITH(systemd, AS_HELP_STRING([--with-systemd],[Enable Systemd native inte AC_MSG_RESULT(no)) if test "$with_systemd" = yes; then - SYSTEMD_CFLAGS="-DHAVE_SYSTEMD" + AC_MSG_CHECKING(for systemd with pkg-config) + AC_PATH_PROG(PKG_CONFIG, pkg-config) + if test -n "$PKG_CONFIG"; then + if $PKG_CONFIG --exists systemd; then + AC_MSG_CHECKING([systemd found, enabling.]) + SYSTEMD_CFLAGS="-DHAVE_SYSTEMD" + else + AC_MSG_CHECKING([systemd not found, disabling.]) + SYSTEMD_CFLAGS="" + fi + else + AC_MSG_ERROR([pkg-config not found.]) + fi else SYSTEMD_CFLAGS="" fi diff --git a/src/std-systemd.c b/src/std-systemd.c index 4cff38db6..c1f8ba8dc 100644 --- a/src/std-systemd.c +++ b/src/std-systemd.c @@ -49,7 +49,6 @@ SVRCORE_CreateStdSystemdPinObj( PRBool systemdPINs, uint64_t timeout) { #ifdef HAVE_SYSTEMD -#ifndef _WIN32 SVRCOREError err = SVRCORE_Success; SVRCOREStdSystemdPinObj *obj = 0; @@ -147,7 +146,6 @@ SVRCORE_CreateStdSystemdPinObj( } return err; -#endif // win32 #else // systemd return SVRCORE_MissingFeature; #endif // Systemd @@ -158,7 +156,6 @@ SVRCORE_DestroyStdSystemdPinObj( SVRCOREStdSystemdPinObj *obj) { #ifdef HAVE_SYSTEMD -#ifndef _WIN32 if (!obj) return; if (obj->user) SVRCORE_DestroyUserPinObj(obj->user); @@ -169,7 +166,6 @@ SVRCORE_DestroyStdSystemdPinObj( if (obj->systemdalt) SVRCORE_DestroyAltPinObj(obj->systemdalt); free(obj); -#endif // win32 #endif // Systemd } @@ -179,9 +175,7 @@ void SVRCORE_SetStdSystemdPinInteractive(SVRCOREStdSystemdPinObj *obj, PRBool i) { #ifdef HAVE_SYSTEMD -#ifndef _WIN32 SVRCORE_SetUserPinInteractive(obj->user, i); -#endif // win32 #endif // Systemd } @@ -194,7 +188,6 @@ SVRCORE_StdSystemdPinGetPin(char **pin, SVRCOREStdSystemdPinObj *obj, const char *tokenName) { #ifdef HAVE_SYSTEMD -#ifndef _WIN32 #ifdef DEBUG printf("std-systemd:stdsystem-getpin() -> starting \n"); #endif @@ -206,7 +199,6 @@ SVRCORE_StdSystemdPinGetPin(char **pin, SVRCOREStdSystemdPinObj *obj, } return SVRCORE_CachedPinGetPin(pin, obj->cache, tokenName); -#endif // win32 #else // systemd return SVRCORE_MissingFeature; #endif // Systemd diff --git a/src/systemd-ask-pass.c b/src/systemd-ask-pass.c index 11d6e0728..ea598d72a 100644 --- a/src/systemd-ask-pass.c +++ b/src/systemd-ask-pass.c @@ -50,7 +50,6 @@ SVRCOREError SVRCORE_CreateSystemdPinObj(SVRCORESystemdPinObj **out, uint64_t timeout) { #ifdef HAVE_SYSTEMD -#ifndef _WIN32 SVRCOREError err = SVRCORE_Success; SVRCORESystemdPinObj *obj = NULL; @@ -79,12 +78,12 @@ SVRCORE_CreateSystemdPinObj(SVRCORESystemdPinObj **out, uint64_t timeout) *out = obj; return err; -#endif // win32 #else // systemd return SVRCORE_MissingFeature; #endif // Systemd } +#ifdef HAVE_SYSTEMD SVRCOREError _create_socket(char **path, int *sfd) { @@ -158,12 +157,12 @@ _until(uint64_t timeout, uint64_t *until) out: return err; } +#endif // Systemd static char * getPin(SVRCOREPinObj *obj, const char *tokenName, PRBool retry) { #ifdef HAVE_SYSTEMD -#ifndef _WIN32 SVRCORESystemdPinObj *sobj = (SVRCORESystemdPinObj *)obj; SVRCOREError err = SVRCORE_Success; char *tbuf = malloc(PASS_MAX); @@ -443,7 +442,6 @@ out: return token; -#endif // win32 #else // systemd return NULL; #endif // Systemd @@ -453,11 +451,9 @@ void SVRCORE_DestroySystemdPinObj(SVRCORESystemdPinObj *obj) { #ifdef HAVE_SYSTEMD -#ifndef _WIN32 if (obj) { free(obj); } -#endif // win32 #endif // Systemd } diff --git a/svrcore.spec b/svrcore.spec index 93c6f2bd4..7319ca5cb 100644 --- a/svrcore.spec +++ b/svrcore.spec @@ -14,6 +14,7 @@ Requires: nss >= %{nss_version} BuildRequires: nspr-devel >= %{nspr_version} BuildRequires: nss-devel >= %{nss_version} BuildRequires: pkgconfig +BuildRequires: pkgconfig(systemd) Source0: http://www.port389.org/binaries/%{name}-%{version}.tar.bz2
0
7c3c10da285b3e7478c81a6d891381ee62b9aa1f
389ds/389-ds-base
Ticket 50745: ns-slapd hangs during CleanAllRUV tests Bug Description: The hang condition: - is not systematic - occurs in rare case, for example here during the deletion of a replica. - a thread is waiting for a dblock that an other thread "forgot" to release. - have always existed, at least since 1.4.0 but likely since 1.2.x When deleting a replica, the replica is retrieved from mapping tree structure (mtnode). The replica is also retrieved through the mapping tree when writing updates to the changelog. When deleting the replica, mapping tree structure is cleared after the changelog is deleted (that can take some cycles). There is a window where an update can retrieve the replica, from the not yet cleared MT, while the changelog being removed. At the end, the update will update the changelog that is currently removed and keeps an unfree lock in the DB. Fix description: Ideally mapping tree should be protected by a lock but it is not done systematically (e.g. slapi_get_mapping_tree_node). Using a lock looks an overkill and can probably introduce deadlock and performance hit. The idea of the fix is to reduce the window, moving the mapping tree clear before the changelog removal. https://pagure.io/389-ds-base/issue/50745 Reviewed by: Mark Reynolds, Ludwig Krispenz
commit 7c3c10da285b3e7478c81a6d891381ee62b9aa1f Author: Thierry Bordaz <[email protected]> Date: Wed Nov 27 14:04:14 2019 +0100 Ticket 50745: ns-slapd hangs during CleanAllRUV tests Bug Description: The hang condition: - is not systematic - occurs in rare case, for example here during the deletion of a replica. - a thread is waiting for a dblock that an other thread "forgot" to release. - have always existed, at least since 1.4.0 but likely since 1.2.x When deleting a replica, the replica is retrieved from mapping tree structure (mtnode). The replica is also retrieved through the mapping tree when writing updates to the changelog. When deleting the replica, mapping tree structure is cleared after the changelog is deleted (that can take some cycles). There is a window where an update can retrieve the replica, from the not yet cleared MT, while the changelog being removed. At the end, the update will update the changelog that is currently removed and keeps an unfree lock in the DB. Fix description: Ideally mapping tree should be protected by a lock but it is not done systematically (e.g. slapi_get_mapping_tree_node). Using a lock looks an overkill and can probably introduce deadlock and performance hit. The idea of the fix is to reduce the window, moving the mapping tree clear before the changelog removal. https://pagure.io/389-ds-base/issue/50745 Reviewed by: Mark Reynolds, Ludwig Krispenz diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c index 79b257564..02b36f6ad 100644 --- a/ldap/servers/plugins/replication/repl5_replica_config.c +++ b/ldap/servers/plugins/replication/repl5_replica_config.c @@ -757,6 +757,10 @@ replica_config_delete(Slapi_PBlock *pb __attribute__((unused)), if (mtnode_ext->replica) { /* remove object from the hash */ r = (Replica *)object_get_data(mtnode_ext->replica); + mtnode_ext->replica = NULL; /* moving it before deleting the CL because + * deletion can take some time giving the opportunity + * to an operation to start while CL is deleted + */ PR_ASSERT(r); /* The changelog for this replica is no longer valid, so we should remove it. */ slapi_log_err(SLAPI_LOG_WARNING, repl_plugin_name, "replica_config_delete - " @@ -765,7 +769,6 @@ replica_config_delete(Slapi_PBlock *pb __attribute__((unused)), slapi_sdn_get_dn(replica_get_root(r))); cl5DeleteDBSync(r); replica_delete_by_name(replica_get_name(r)); - mtnode_ext->replica = NULL; } PR_Unlock(s_configLock);
0
d46a0f6479417e32db7f91a019f7bcffabe80f82
389ds/389-ds-base
Ticket 48979 - Strict Prototypes Bug Description: Fix strict prototypes for freeipa development. Fix Description: If csn and counters to use (void) rather than () in function definitions. https://fedorahosted.org/389/ticket/48979 Author: wibrown Review by: lslebodn (Thanks!)
commit d46a0f6479417e32db7f91a019f7bcffabe80f82 Author: William Brown <[email protected]> Date: Mon Sep 5 10:01:38 2016 +1000 Ticket 48979 - Strict Prototypes Bug Description: Fix strict prototypes for freeipa development. Fix Description: If csn and counters to use (void) rather than () in function definitions. https://fedorahosted.org/389/ticket/48979 Author: wibrown Review by: lslebodn (Thanks!) diff --git a/ldap/servers/slapd/counters.c b/ldap/servers/slapd/counters.c index 19e656291..1d4ac8999 100644 --- a/ldap/servers/slapd/counters.c +++ b/ldap/servers/slapd/counters.c @@ -29,7 +29,7 @@ static int num_counters= 0; static struct counter *counters= NULL; static int -count_counters() +count_counters(void) { int i= 0; PR_DEFINE_COUNTER(qh); @@ -51,7 +51,7 @@ count_counters() } static int -do_fetch_counters() +do_fetch_counters(void) { int i= 0; PR_DEFINE_COUNTER(qh); @@ -79,7 +79,7 @@ do_fetch_counters() } static void -fetch_counters() +fetch_counters(void) { int i; if(counters==NULL) diff --git a/ldap/servers/slapd/csn.c b/ldap/servers/slapd/csn.c index a3f48150f..203789d28 100644 --- a/ldap/servers/slapd/csn.c +++ b/ldap/servers/slapd/csn.c @@ -44,7 +44,7 @@ static Slapi_Counter *slapi_csn_counter_exist; #ifdef DEBUG static void -csn_create_counters() +csn_create_counters(void) { slapi_csn_counter_created = slapi_counter_new(); slapi_csn_counter_deleted = slapi_counter_new(); @@ -53,7 +53,7 @@ csn_create_counters() } #endif -CSN *csn_new() +CSN *csn_new(void) { #ifdef DEBUG if(!counters_created)
0
febd0dbeab80f12bed1109fcbb0a929f83addb2a
389ds/389-ds-base
Ticket 583 - dirsrv fails to start on reboot due to /var/run/dirsrv permissions Bug Description: On Fedora, after a reboot the ownership/permissions can change for /var/lock/dirsrv & /var/run/dirsrv. This is because we were not removing the old /etc/tmpfiles.d/dirsrv-INSTANCE.conf file. So if an existing tmpfile existed, it would not be updated when creating a new instance. Fix Description: When removing an instance, we were using the wrong tmpfile name - it was missing ".conf" extension. This has been corrected. Also, when creating an instance, we now check for and delete the old tmpfile. https://fedorahosted.org/389/ticket/583 Reviewed by: nkinder(Thanks!)
commit febd0dbeab80f12bed1109fcbb0a929f83addb2a Author: Mark Reynolds <[email protected]> Date: Fri Mar 15 14:40:54 2013 -0400 Ticket 583 - dirsrv fails to start on reboot due to /var/run/dirsrv permissions Bug Description: On Fedora, after a reboot the ownership/permissions can change for /var/lock/dirsrv & /var/run/dirsrv. This is because we were not removing the old /etc/tmpfiles.d/dirsrv-INSTANCE.conf file. So if an existing tmpfile existed, it would not be updated when creating a new instance. Fix Description: When removing an instance, we were using the wrong tmpfile name - it was missing ".conf" extension. This has been corrected. Also, when creating an instance, we now check for and delete the old tmpfile. https://fedorahosted.org/389/ticket/583 Reviewed by: nkinder(Thanks!) diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in index fefb3dc75..be2097a5e 100644 --- a/ldap/admin/src/scripts/DSCreate.pm.in +++ b/ldap/admin/src/scripts/DSCreate.pm.in @@ -1040,48 +1040,50 @@ sub updateTmpfilesDotD { # if tmpfiles.d is not available, do nothing if ($dir and -d $dir) { my $filename = "$dir/@package_name@-$inf->{slapd}->{ServerIdentifier}.conf"; - if (! -f $filename) { - debug(3, "Creating $filename\n"); - my $username = ""; - my $groupname = ""; - my $conffile = "$inf->{slapd}->{config_dir}/dse.ldif"; - # use the owner:group from the dse.ldif for the instance - if (-f $conffile) { - my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, - $atime,$mtime,$ctime,$blksize,$blocks) - = stat(_); - $username = getpwuid($uid); - if (!$username) { - debug(1, "Error: could not get username from uid $uid\n"); - } - $groupname = getgrgid($gid); + if (-f $filename) { + debug(3, "Removing the old tmpfile: $filename\n"); + if (!unlink($filename)){ + debug(1, "Can not delete old tmpfile $filename ($!)\n"); + return(); } - # else, see if we were passed in values to use + } + debug(3, "Creating $filename\n"); + my $username = ""; + my $groupname = ""; + my $conffile = "$inf->{slapd}->{config_dir}/dse.ldif"; + # use the owner:group from the dse.ldif for the instance + if (-f $conffile) { + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) + = stat(_); + $username = getpwuid($uid); if (!$username) { - $username = $inf->{General}->{SuiteSpotUserID}; - } - if (!$groupname) { - if (defined($inf->{General}->{SuiteSpotGroup})) { - $groupname = $inf->{General}->{SuiteSpotGroup}; - } else { # $groupname - $groupname = "-"; # use default - } + debug(1, "Error: could not get username from uid $uid\n"); } - - my $parent = dirname($inf->{slapd}->{lock_dir}); - if (!open(DOTDFILE, ">$filename")) { - return ( [ 'error_creating_file', $filename, $! ] ); + $groupname = getgrgid($gid); + } + # else, see if we were passed in values to use + if (!$username) { + $username = $inf->{General}->{SuiteSpotUserID}; + } + if (!$groupname) { + if (defined($inf->{General}->{SuiteSpotGroup})) { + $groupname = $inf->{General}->{SuiteSpotGroup}; + } else { # $groupname + $groupname = "-"; # use default } - # Type Path Mode UID GID Age - # d /var/run/user 0755 root root 10d - # we don't use age - print DOTDFILE "d $inf->{slapd}->{run_dir} 0770 $username $groupname\n"; - print DOTDFILE "d $parent 0770 $username $groupname\n"; - print DOTDFILE "d $inf->{slapd}->{lock_dir} 0770 $username $groupname\n"; - close DOTDFILE; - } else { - debug(3, "$filename exists - skipping\n"); } + my $parent = dirname($inf->{slapd}->{lock_dir}); + if (!open(DOTDFILE, ">$filename")) { + return ( [ 'error_creating_file', $filename, $! ] ); + } + # Type Path Mode UID GID Age + # d /var/run/user 0755 root root 10d + # we don't use age + print DOTDFILE "d $inf->{slapd}->{run_dir} 0770 $username $groupname\n"; + print DOTDFILE "d $parent 0770 $username $groupname\n"; + print DOTDFILE "d $inf->{slapd}->{lock_dir} 0770 $username $groupname\n"; + close DOTDFILE; } else { debug(3, "no tmpfiles.d - skipping\n"); } @@ -1381,8 +1383,8 @@ sub removeDSInstance { } my $tmpfilesdir = "@with_tmpfiles_d@"; - my $tmpfilesname = "$tmpfilesdir/@package_name@-$inst"; - if ($tmpfilesdir and -d $tmpfilesdir and -f $tmpfilesname) { + my $tmpfilesname = "$tmpfilesdir/@package_name@-$inst.conf"; + if ($tmpfilesdir && -d $tmpfilesdir && -f $tmpfilesname) { my $rc = unlink($tmpfilesname); if ( 0 == $rc ) {
0
f9351cfcb2b9fd9dc6b4c347730207c441215d31
389ds/389-ds-base
Ticket 49141 - Enable tcmalloc Bug Description: tcmallon conflicts with asan. Additionally, tcmalloc needs to use -lpthread, so we should guarantee this with the use of the pkg-config file. Fix Description: Fix the rpm to use asan *or* tcmalloc. Fix configure to explode if you try and use both. Fix m4/tcmalloc to use pkg-config file. Update bundled tcmalloc link to apply to all binaries to ensure proper behaviour of the server. This also limits tcmalloc to supported arches (IE exclude s390) https://pagure.io/389-ds-base/issue/49141 Author: wibrown Review by: vashirov (Thanks!)
commit f9351cfcb2b9fd9dc6b4c347730207c441215d31 Author: William Brown <[email protected]> Date: Wed Feb 22 16:41:07 2017 +1000 Ticket 49141 - Enable tcmalloc Bug Description: tcmallon conflicts with asan. Additionally, tcmalloc needs to use -lpthread, so we should guarantee this with the use of the pkg-config file. Fix Description: Fix the rpm to use asan *or* tcmalloc. Fix configure to explode if you try and use both. Fix m4/tcmalloc to use pkg-config file. Update bundled tcmalloc link to apply to all binaries to ensure proper behaviour of the server. This also limits tcmalloc to supported arches (IE exclude s390) https://pagure.io/389-ds-base/issue/49141 Author: wibrown Review by: vashirov (Thanks!) diff --git a/Makefile.am b/Makefile.am index 19109584b..d712aba39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,8 @@ NSPR_INCLUDES = @nspr_inc@ SVRCORE_INCLUDES = @svrcore_inc@ SASL_INCLUDES = @sasl_inc@ EVENT_INCLUDES = @event_inc@ +# Not used currently +# TCMALLOC_INCLUDES = @tcmalloc_inc@ # We can't add the lfds includes all the time as they have a "bomb" in them that # prevents compilation on unsupported hardware arches. @@ -125,7 +127,7 @@ PCRE_LINK = @pcre_lib@ -lpcre NETSNMP_LINK = @netsnmp_lib@ @netsnmp_link@ PAM_LINK = -lpam KERBEROS_LINK = $(kerberos_lib) -TCMALLOC_LINK = @tcmalloc_link@ +TCMALLOC_LINK = @tcmalloc_lib@ EVENT_LINK = @event_lib@ LIBSOCKET=@LIBSOCKET@ @@ -141,7 +143,8 @@ if HPUX AM_LDFLAGS = -lpthread else #AM_LDFLAGS = -Wl,-z,defs -AM_LDFLAGS = $(ASAN_DEFINES) $(PROFILING_LINKS) +# Provide the tcmalloc links if needed +AM_LDFLAGS = $(ASAN_DEFINES) $(PROFILING_LINKS) $(TCMALLOC_LINK) endif #end hpux # https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info @@ -1224,7 +1227,7 @@ libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) @db_ if SPARC libslapd_la_SOURCES += ldap/servers/slapd/slapi_counter_sunos_sparcv9.S endif -libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LINK) $(THREADLIB) $(SYSTEMD_LINK) $(TCMALLOC_LINK) +libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LINK) $(THREADLIB) $(SYSTEMD_LINK) libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS) @@ -1954,7 +1957,7 @@ ns_slapd_SOURCES = ldap/servers/slapd/abandon.c \ ns_slapd_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) $(SVRCORE_INCLUDES) ns_slapd_LDADD = libnunc-stans.la libslapd.la libldaputil.a $(LDAPSDK_LINK) $(NSS_LINK) $(LIBADD_DL) \ - $(NSPR_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LINK) $(EVENT_LINK) $(TCMALLOC_LINK) + $(NSPR_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LINK) $(EVENT_LINK) ns_slapd_DEPENDENCIES = libslapd.la libnunc-stans.la # We need to link ns-slapd with the C++ compiler on HP-UX since we load # some C++ shared libraries (such as icu). diff --git a/configure.ac b/configure.ac index de7f3cbb7..4e3e9fb7d 100644 --- a/configure.ac +++ b/configure.ac @@ -551,6 +551,7 @@ case $host in platform="linux" initdir='$(sysconfdir)/rc.d/init.d' # do arch specific linux stuff here + # TCMalloc is only on i686, x86_64, ppc64 and arm, so we pick that here. case $host in i*86-*-linux*) AC_DEFINE([CPU_x86], [], [cpu type x86]) @@ -585,9 +586,19 @@ case $host in aarch64-*-linux*) AC_DEFINE([CPU_arm], [], [cpu type arm]) ;; - arm*-linux*) + arm-*-linux*) AC_DEFINE([CPU_arm], [], [cpu type arm]) ;; + ppc64le-*-linux*) + ;; + ppc64-*-linux*) + ;; + ppc-*-linux*) + ;; + s390-*-linux*) + ;; + s390x-*-linux*) + ;; esac AC_MSG_CHECKING([for GCC provided 64-bit atomic bool cas function ...]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], @@ -740,9 +751,9 @@ m4_include(m4/pcre.m4) m4_include(m4/selinux.m4) m4_include(m4/systemd.m4) m4_include(m4/cmocka.m4) -m4_include(m4/tcmalloc.m4) m4_include(m4/doxygen.m4) m4_include(m4/event.m4) +m4_include(m4/tcmalloc.m4) PACKAGE_BASE_VERSION=`echo $PACKAGE_VERSION | awk -F\. '{print $1"."$2}'` AC_SUBST(PACKAGE_BASE_VERSION) @@ -807,7 +818,6 @@ AC_SUBST(localrundir) AC_SUBST(systemd_inc) AC_SUBST(systemd_lib) AC_SUBST(systemd_defs) -AC_SUBST(tcmalloc_link) AC_SUBST(brand) AC_SUBST(capbrand) diff --git a/m4/tcmalloc.m4 b/m4/tcmalloc.m4 index da9a722bd..4da8600b2 100644 --- a/m4/tcmalloc.m4 +++ b/m4/tcmalloc.m4 @@ -6,24 +6,44 @@ # See LICENSE for details. # END COPYRIGHT BLOCK -AC_CHECKING(for tcmalloc) +AC_CHECKING(for --enable-tcmalloc) -# check for --with-tcmalloc -AC_MSG_CHECKING(for --with-tcmalloc) -AC_ARG_WITH(tcmalloc, AS_HELP_STRING([--with-tcmalloc],[Use TCMalloc memory allocator.]), +AC_ARG_ENABLE(tcmalloc, AS_HELP_STRING([--enable-tcmalloc], [Enable tcmalloc based tests (default: no)]), [ - if test "$withval" = yes - then - AC_MSG_RESULT([using tcmalloc memory allocator]) - with_tcmalloc=yes - else - AC_MSG_RESULT(no) + AC_MSG_RESULT(yes) + AC_DEFINE([WITH_TCMALLOC], [1], [With tcmalloc]) + with_tcmalloc="yes" + + if test "$enable_asan" = "yes" ; then + AC_MSG_ERROR([CRITICAL: You may not enable ASAN and TCMALLOC simultaneously]) fi + + case $host in + s390-*-linux*) + AC_MSG_ERROR([tcmalloc not support on s390]) + ;; + s390x-*-linux*) + AC_MSG_ERROR([tcmalloc not support on s390x]) + ;; + *) + AC_MSG_CHECKING(for tcmalloc) + if $PKG_CONFIG --exists libtcmalloc; then + tcmalloc_inc=`$PKG_CONFIG --cflags libtcmalloc` + tcmalloc_lib=`$PKG_CONFIG --libs libtcmalloc` + AC_MSG_RESULT([using system tcmalloc]) + else + AC_MSG_ERROR([pkg-config could not find tcmalloc!]) + fi + esac + ], -AC_MSG_RESULT(no)) +[ + AC_MSG_RESULT(no) + with_tcmalloc="0" +]) -if test "$with_tcmalloc" = yes; then - tcmalloc_link=-ltcmalloc -fi +AM_CONDITIONAL([WITH_TCMALLOC], [test "$with_tcmalloc" = "yes"]) +AC_SUBST(tcmalloc_inc) +AC_SUBST(tcmalloc_lib) diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index ac690900e..a76d00e87 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -11,7 +11,6 @@ # also need the relprefix field for a pre-release e.g. .0 - also comment out for official release #% global relprefix 0. -%global use_tcmalloc 1 %global use_openldap 1 %global use_db4 0 # If perl-Socket-2.000 or newer is available, set 0 to use_Socket6. @@ -23,7 +22,14 @@ # This enables an ASAN build. This should not go to production, so we rename. %global use_asan __ASAN_ON__ %if %{use_asan} +%global use_tcmalloc 0 %global variant base-asan +%else +%if %{_arch} != "s390x" && %{_arch} != "s390" +%global use_tcmalloc 1 +%else +%global use_tcmalloc 0 +%endif %endif # fedora 15 and later uses tmpfiles.d
0
724adba659bc6e9cadbf528fa49d9518ad6c7b3c
389ds/389-ds-base
Ticket 48832 - CI Tests - make tests more portable Description: This patch addresses some portability issues with the CI tests. In some cases the amchine just runs too slow, so we need to increase sleep intervals, and in other cases we need to get the proper host name. https://fedorahosted.org/389/ticket/48832 Reviewed by: spichugi (Thanks!)
commit 724adba659bc6e9cadbf528fa49d9518ad6c7b3c Author: Mark Reynolds <[email protected]> Date: Thu Jul 28 10:52:58 2016 -0400 Ticket 48832 - CI Tests - make tests more portable Description: This patch addresses some portability issues with the CI tests. In some cases the amchine just runs too slow, so we need to increase sleep intervals, and in other cases we need to get the proper host name. https://fedorahosted.org/389/ticket/48832 Reviewed by: spichugi (Thanks!) diff --git a/dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py b/dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py index 7ba20cbf6..7b2c01a6d 100644 --- a/dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py +++ b/dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py @@ -381,6 +381,9 @@ def test_rootdn_access_denied_host(topology): topology.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-deny-host', hostname)]) + topology.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, + 'rootdn-deny-host', + 'localhost')]) except ldap.LDAPError as e: log.fatal('test_rootdn_access_denied_host: Failed to set deny host: error ' + e.message['desc']) @@ -555,8 +558,14 @@ def test_rootdn_access_allowed_host(topology): log.fatal('test_rootdn_access_allowed_host: : failed to bind as user1') assert False + hostname = socket.gethostname() try: - topology.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-allow-host', 'localhost.localdomain')]) + topology.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, + 'rootdn-allow-host', + 'localhost')]) + topology.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, + 'rootdn-allow-host', + hostname)]) except ldap.LDAPError as e: log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error ' + e.message['desc']) diff --git a/dirsrvtests/tests/tickets/ticket47462_test.py b/dirsrvtests/tests/tickets/ticket47462_test.py index 2ac1478e2..50b867efb 100644 --- a/dirsrvtests/tests/tickets/ticket47462_test.py +++ b/dirsrvtests/tests/tickets/ticket47462_test.py @@ -267,8 +267,8 @@ def test_ticket47462(topology): # Run the upgrade... # topology.master1.upgrade('online') - topology.master1.restart(timeout=10) - topology.master2.restart(timeout=10) + topology.master1.restart() + topology.master2.restart() # # Check that the restart converted existing DES credentials diff --git a/dirsrvtests/tests/tickets/ticket47823_test.py b/dirsrvtests/tests/tickets/ticket47823_test.py index 223c13985..d7928f303 100644 --- a/dirsrvtests/tests/tickets/ticket47823_test.py +++ b/dirsrvtests/tests/tickets/ticket47823_test.py @@ -67,8 +67,6 @@ def topology(request): ''' global installation_prefix - - standalone = DirSrv(verbose=False) if installation_prefix: args_instance[SER_DEPLOYED_DIR] = installation_prefix diff --git a/dirsrvtests/tests/tickets/ticket47838_test.py b/dirsrvtests/tests/tickets/ticket47838_test.py index d9f6b36e4..109b48d33 100644 --- a/dirsrvtests/tests/tickets/ticket47838_test.py +++ b/dirsrvtests/tests/tickets/ticket47838_test.py @@ -34,8 +34,12 @@ plus_all_dcount = 0 plus_all_ecount_noweak = 0 plus_all_dcount_noweak = 0 +# Cipher counts tend to change with each new verson of NSS nss_version = '' NSS320 = '3.20.0' +NSS321 = '3.21.0' # RHEL6 +NSS323 = '3.23.0' # F22 +NSS325 = '3.25.0' # F23/F24 class TopologyStandalone(object): @@ -368,7 +372,10 @@ def _47838_run_4(topology): log.info("Disabled ciphers: %d" % dcount) global plus_all_ecount global plus_all_dcount - assert ecount == 23 + if nss_version >= NSS323: + assert ecount == 23 + else: + assert ecount == 20 assert dcount == (plus_all_ecount + plus_all_dcount - ecount) weak = os.popen('egrep "SSL alert:" %s | egrep \": enabled\" | egrep "WEAK CIPHER" | wc -l' % topology.standalone.errlog) wcount = int(weak.readline().rstrip()) diff --git a/dirsrvtests/tests/tickets/ticket48784_test.py b/dirsrvtests/tests/tickets/ticket48784_test.py index e513bfd57..e2337f160 100644 --- a/dirsrvtests/tests/tickets/ticket48784_test.py +++ b/dirsrvtests/tests/tickets/ticket48784_test.py @@ -393,7 +393,7 @@ def test_ticket48784(topology): add_entry(topology.master1, 'master1', 'uid=m1user', 0, 5) add_entry(topology.master2, 'master2', 'uid=m2user', 0, 5) - time.sleep(1) + time.sleep(10) log.info('##### Searching for entries on master1...') entries = topology.master1.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)')
0
c278163aebf1a440cd99b30129bde5c135553118
389ds/389-ds-base
Resolves: 245894 Summary: Check process name in initscript in a more cross-platform manner.
commit c278163aebf1a440cd99b30129bde5c135553118 Author: Nathan Kinder <[email protected]> Date: Fri Feb 20 00:14:34 2009 +0000 Resolves: 245894 Summary: Check process name in initscript in a more cross-platform manner. diff --git a/wrappers/initscript.in b/wrappers/initscript.in index 9f4676fed..9223ebac6 100644 --- a/wrappers/initscript.in +++ b/wrappers/initscript.in @@ -139,9 +139,8 @@ start() { if [ -f $pidfile ]; then pid=`cat $pidfile` instlockfile="@localstatedir@/lock/@package_name@/slapd-$instance/server/$pid" - if kill -0 $pid && \ - [ $(awk '{print $2}' /proc/$pid/stat) = "(ns-slapd)" ] \ - > /dev/null 2>&1 ; then + name=`ps -p $pid | tail -1 | awk '{ print $4 }'` + if kill -0 $pid && [ $name = "ns-slapd" ]; then echo_n " already running" success; echo successes=`expr $successes + 1`
0
f1899ba0ea425639932c373d3171ec8a9441f780
389ds/389-ds-base
Bug 616850 - ldapmodify failed to reject the replace operation if its targeted for an Unknown attribute https://bugzilla.redhat.com/show_bug.cgi?id=616850 Description: Attempting to modify an unknown attribute in the config entry fails with LDAP_UNWILLING_TO_PERFORM, while starting up just ignores unknown attributes and the server successfully starts.
commit f1899ba0ea425639932c373d3171ec8a9441f780 Author: Noriko Hosoi <[email protected]> Date: Wed Jan 19 10:52:24 2011 -0800 Bug 616850 - ldapmodify failed to reject the replace operation if its targeted for an Unknown attribute https://bugzilla.redhat.com/show_bug.cgi?id=616850 Description: Attempting to modify an unknown attribute in the config entry fails with LDAP_UNWILLING_TO_PERFORM, while starting up just ignores unknown attributes and the server successfully starts. diff --git a/ldap/servers/slapd/configdse.c b/ldap/servers/slapd/configdse.c index 479914556..faf15603e 100644 --- a/ldap/servers/slapd/configdse.c +++ b/ldap/servers/slapd/configdse.c @@ -329,9 +329,12 @@ load_config_dse(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* ignored, int *ret retval = LDAP_SUCCESS; } } else { - if ((retval != LDAP_SUCCESS) && - slapi_attr_flag_is_set(attr, SLAPI_ATTR_FLAG_OPATTR)) { - retval = LDAP_SUCCESS; /* ignore attempts to modify operational attrs */ + if (((retval != LDAP_SUCCESS) && + slapi_attr_flag_is_set(attr, SLAPI_ATTR_FLAG_OPATTR)) || + (LDAP_NO_SUCH_ATTRIBUTE == retval)) { + /* ignore attempts to modify operational attrs and */ + /* ignore attempts to modify unknown attributes for load. */ + retval = LDAP_SUCCESS; } } } @@ -425,6 +428,12 @@ modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, in } rc = config_set(config_attr, mods[i]->mod_bvalues, returntext, apply_mods); + if (LDAP_NO_SUCH_ATTRIBUTE == rc) { + /* config_set returns LDAP_NO_SUCH_ATTRIBUTE if the + * attr is not defined for cn=config. + * map it to LDAP_UNWILLING_TO_PERFORM */ + rc = LDAP_UNWILLING_TO_PERFORM; + } } else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) { /* Need to allow deleting some configuration attrs */ if (allowed_to_delete_attrs(config_attr)) { @@ -458,6 +467,12 @@ modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, in rc = config_set(config_attr, mods[i]->mod_bvalues, returntext, apply_mods); + if (LDAP_NO_SUCH_ATTRIBUTE == rc) { + /* config_set returns LDAP_NO_SUCH_ATTRIBUTE if the + * attr is not defined for cn=config. + * map it to LDAP_UNWILLING_TO_PERFORM */ + rc = LDAP_UNWILLING_TO_PERFORM; + } } } } diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 6a7e01414..e547b4799 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -5671,7 +5671,7 @@ config_set(const char *attr, struct berval **values, char *errorbuf, int apply) #endif PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown attribute %s will be ignored", attr); slapi_log_error(SLAPI_LOG_FATAL, "config", "%s\n", errorbuf); - return retval; + return LDAP_NO_SUCH_ATTRIBUTE; } switch (cgas->config_var_type)
0
95f425da43b380163c2ddae66fc77d2b863a00e5
389ds/389-ds-base
Ticket #543 - Sorting with attributes in ldapsearch gives incorrect result Bug description: In the server side sorting compare function compare_entries_sv, if multiple attribute types are specified, the sort spec for each attribute is scanned one by one in the for loop. In the for loop, instead of using the "current" spec, the first spec is kept using. If the attribute types have different syntaxes (e.g., cis, tel), then the first syntax is unexpectedly selected for the second syntax. Fix description: This patch correctly uses the current spec in the for loop. Reviewed by Nathan (Thank you!!)
commit 95f425da43b380163c2ddae66fc77d2b863a00e5 Author: Noriko Hosoi <[email protected]> Date: Thu Jan 31 16:45:28 2013 -0800 Ticket #543 - Sorting with attributes in ldapsearch gives incorrect result Bug description: In the server side sorting compare function compare_entries_sv, if multiple attribute types are specified, the sort spec for each attribute is scanned one by one in the for loop. In the for loop, instead of using the "current" spec, the first spec is kept using. If the attribute types have different syntaxes (e.g., cis, tel), then the first syntax is unexpectedly selected for the second syntax. Fix description: This patch correctly uses the current spec in the for loop. Reviewed by Nathan (Thank you!!) diff --git a/ldap/servers/slapd/back-ldbm/sort.c b/ldap/servers/slapd/back-ldbm/sort.c index 501765c1a..a61f117b4 100644 --- a/ldap/servers/slapd/back-ldbm/sort.c +++ b/ldap/servers/slapd/back-ldbm/sort.c @@ -688,7 +688,7 @@ static int compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier * * doesn't try to free them. We need to note at the right place that * we're on the matchrule path, and accordingly free the keys---this turns out * to be when we free the indexer */ - if (NULL == s->matchrule) { + if (NULL == this_one->matchrule) { /* Non-match rule case */ valuearray_get_bervalarray(valueset_get_valuearray(&attr_a->a_present_values),&value_a); valuearray_get_bervalarray(valueset_get_valuearray(&attr_b->a_present_values),&value_b); @@ -700,22 +700,22 @@ static int compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier * valuearray_get_bervalarray(valueset_get_valuearray(&attr_a->a_present_values),&actual_value_a); valuearray_get_bervalarray(valueset_get_valuearray(&attr_b->a_present_values),&actual_value_b); - matchrule_values_to_keys(s->mr_pb,actual_value_a,&temp_value); + matchrule_values_to_keys(this_one->mr_pb,actual_value_a,&temp_value); /* Now copy it, so the second call doesn't crap on it */ value_a = slapi_ch_bvecdup(temp_value); /* Really, we'd prefer to not call the chXXX variant...*/ - matchrule_values_to_keys(s->mr_pb,actual_value_b,&value_b); + matchrule_values_to_keys(this_one->mr_pb,actual_value_b,&value_b); if (actual_value_a) ber_bvecfree(actual_value_a); if (actual_value_b) ber_bvecfree(actual_value_b); } /* Compare them */ if (!order) { - result = sort_attr_compare(value_a, value_b, s->compare_fn); + result = sort_attr_compare(value_a, value_b, this_one->compare_fn); } else { /* If reverse, invert the sense of the comparison */ - result = sort_attr_compare(value_b, value_a, s->compare_fn); + result = sort_attr_compare(value_b, value_a, this_one->compare_fn); } /* Time to free up the attributes allocated above */ - if (NULL != s->matchrule) { + if (NULL != this_one->matchrule) { ber_bvecfree(value_a); } else { ber_bvecfree(value_a);
0
6b6878b07a434e32065f38328127e1c0e4b6ec0f
389ds/389-ds-base
Ticket 49403 - tidy ns logging Bug Description: nunc-stans logging would swap to a printf mode if DEBUG was defined. Fix Description: NS is in a good state, so we can use slapd log instead. https://pagure.io/389-ds-base/issue/49403 Author: wibrown Review by: mreynolds (Thanks!)
commit 6b6878b07a434e32065f38328127e1c0e4b6ec0f Author: William Brown <[email protected]> Date: Fri Oct 13 22:52:26 2017 +1000 Ticket 49403 - tidy ns logging Bug Description: nunc-stans logging would swap to a printf mode if DEBUG was defined. Fix Description: NS is in a good state, so we can use slapd log instead. https://pagure.io/389-ds-base/issue/49403 Author: wibrown Review by: mreynolds (Thanks!) diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index ddaceffea..f8b591ecf 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -139,13 +139,6 @@ nunc_stans_logging(int severity, const char *format, va_list varg) va_end(varg_copy); } -static void -ns_printf_logger(int priority __attribute__((unused)), const char *fmt, va_list varg) -{ - /* Should we do anything with priority? */ - vprintf(fmt, varg); -} - static void * nunc_stans_malloc(size_t size) { @@ -219,9 +212,6 @@ main_create_ns(ns_thrpool_t **tp_in) tp_config.stacksize = SLAPD_DEFAULT_THREAD_STACKSIZE; /* Highly likely that we need to re-write logging to be controlled by NS here. */ tp_config.log_fct = nunc_stans_logging; -#ifdef DEBUG - tp_config.log_fct = ns_printf_logger; -#endif tp_config.log_start_fct = NULL; tp_config.log_close_fct = NULL; tp_config.malloc_fct = nunc_stans_malloc;
0
8e1345ab9276d1cf9c9ac2cbd858c398235ef5ce
389ds/389-ds-base
Ticket #47874 - Performance degradation with scope ONE after some load Bug Description: Backend has a bit to indicate "should not bypass the filter test". It's set if one of the search results is ALLID in idl_intersection. Once the flag is set, it's never been unset. It makes the following one level searches slow down. Fix Description: Introduced slapi_be_unset_flag and unset the bit at the end of every search. https://fedorahosted.org/389/ticket/47874 Reviewed by [email protected] (Thank you, Rich!!)
commit 8e1345ab9276d1cf9c9ac2cbd858c398235ef5ce Author: Noriko Hosoi <[email protected]> Date: Thu Aug 14 17:54:30 2014 -0700 Ticket #47874 - Performance degradation with scope ONE after some load Bug Description: Backend has a bit to indicate "should not bypass the filter test". It's set if one of the search results is ALLID in idl_intersection. Once the flag is set, it's never been unset. It makes the following one level searches slow down. Fix Description: Introduced slapi_be_unset_flag and unset the bit at the end of every search. https://fedorahosted.org/389/ticket/47874 Reviewed by [email protected] (Thank you, Rich!!) diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c index ec3dd1ed3..e1951a0ed 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_search.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c @@ -183,6 +183,11 @@ ldbm_back_search_cleanup(Slapi_PBlock *pb, slapi_pblock_get( pb, SLAPI_BACKEND, &be ); inst = (ldbm_instance *) be->be_instance_info; + /* + * In case SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST is set, + * clean it up for the following sessions. + */ + slapi_be_unset_flag(be, SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST); CACHE_RETURN(&inst->inst_cache, &e); /* NULL e is handled correctly */ if (inst->inst_ref_count) { slapi_counter_decrement(inst->inst_ref_count); diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c index 8a72b13ce..22f41eef3 100644 --- a/ldap/servers/slapd/backend.c +++ b/ldap/servers/slapd/backend.c @@ -580,13 +580,18 @@ slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr, Slapi } int slapi_be_is_flag_set(Slapi_Backend * be, int flag) -{ +{ return be->be_flags & flag; } void slapi_be_set_flag(Slapi_Backend * be, int flag) -{ - be->be_flags|= flag; +{ + be->be_flags |= flag; +} + +void slapi_be_unset_flag(Slapi_Backend * be, int flag) +{ + be->be_flags &= ~flag; } char * slapi_be_get_name(Slapi_Backend * be) diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index f318bb64d..f1ecfe84b 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -6429,6 +6429,7 @@ int slapi_is_ldapi_conn(Slapi_PBlock *pb); int slapi_be_is_flag_set(Slapi_Backend * be, int flag); void slapi_be_set_flag(Slapi_Backend * be, int flag); +void slapi_be_unset_flag(Slapi_Backend * be, int flag); #define SLAPI_BE_FLAG_REMOTE_DATA 0x1 /* entries held by backend are remote */ #define SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST 0x10 /* force to call filter_test (search only) */
0
ca05dea9335452c7c77a60ad7db5588710e0344e
389ds/389-ds-base
Issue 5271 - Serialization of pam_passthrough causing high etimes (#5272) Bug description: calls to PAM authentication are serialized by DS. libpam is thread-safe and some module may also be thread-safe. Because serialization impacts performance, an administator should be allowed to remove the serialization in case the pam module is thread safe Fix description: If the pam configuration entry contains 'pamModuleIsThreadSafe: TRUE' then futher calls to pam_start/pam_authenticate/pam_end are not serialized relates: #5271 Reviewed by: Mark Reynolds, William Brown (thanks)
commit ca05dea9335452c7c77a60ad7db5588710e0344e Author: tbordaz <[email protected]> Date: Tue Sep 20 20:24:47 2022 +0200 Issue 5271 - Serialization of pam_passthrough causing high etimes (#5272) Bug description: calls to PAM authentication are serialized by DS. libpam is thread-safe and some module may also be thread-safe. Because serialization impacts performance, an administator should be allowed to remove the serialization in case the pam module is thread safe Fix description: If the pam configuration entry contains 'pamModuleIsThreadSafe: TRUE' then futher calls to pam_start/pam_authenticate/pam_end are not serialized relates: #5271 Reviewed by: Mark Reynolds, William Brown (thanks) diff --git a/ldap/servers/plugins/pam_passthru/pam_passthru.h b/ldap/servers/plugins/pam_passthru/pam_passthru.h index 1f6f7179b..950d772a0 100644 --- a/ldap/servers/plugins/pam_passthru/pam_passthru.h +++ b/ldap/servers/plugins/pam_passthru/pam_passthru.h @@ -79,6 +79,8 @@ typedef struct pam_passthruconfig PRBool pamptconfig_fallback; /* if false, failure here fails entire bind */ /* if true, failure here falls through to regular bind */ PRBool pamptconfig_secure; /* if true, plugin only operates on secure connections */ + PRBool pamptconfig_thread_safe; /* if true, the underlying pam module is thread safe */ + /* if false, the module is not thread safe => serialize calls */ char *pamptconfig_pam_ident_attr; /* name of attribute in user entry for ENTRY map method */ int pamptconfig_map_method1; /* how to map the BIND DN to the PAM identity */ int pamptconfig_map_method2; /* how to map the BIND DN to the PAM identity */ @@ -101,6 +103,7 @@ typedef struct pam_passthruconfig #define PAMPT_MAP_METHOD_ATTR "pamIDMapMethod" /* single valued */ #define PAMPT_FALLBACK_ATTR "pamFallback" /* single */ #define PAMPT_SECURE_ATTR "pamSecure" /* single */ +#define PAMPT_THREAD_SAFE_ATTR "pamModuleIsThreadSafe" /* single */ #define PAMPT_SERVICE_ATTR "pamService" /* single */ #define PAMPT_FILTER_ATTR "pamFilter" /* single */ diff --git a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c index cbec2ec40..be94e1d87 100644 --- a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c +++ b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c @@ -579,6 +579,7 @@ pam_passthru_apply_config(Slapi_Entry *e) char *dn = NULL; PRBool fallback; PRBool secure; + PRBool thread_safe; Pam_PassthruConfig *entry = NULL; PRCList *list; Slapi_Attr *a = NULL; @@ -592,6 +593,7 @@ pam_passthru_apply_config(Slapi_Entry *e) includes = slapi_entry_attr_get_charray(e, PAMPT_INCLUDES_ATTR); fallback = slapi_entry_attr_get_bool(e, PAMPT_FALLBACK_ATTR); filter_str = slapi_entry_attr_get_charptr(e, PAMPT_FILTER_ATTR); + thread_safe = slapi_entry_attr_get_bool(e, PAMPT_THREAD_SAFE_ATTR); /* Require SSL/TLS if the secure attr is not specified. We * need to check if the attribute is present to make this * determiniation. */ @@ -622,6 +624,7 @@ pam_passthru_apply_config(Slapi_Entry *e) entry->pamptconfig_fallback = fallback; entry->pamptconfig_secure = secure; + entry->pamptconfig_thread_safe = thread_safe; if (!entry->pamptconfig_service || (new_service && PL_strcmp(entry->pamptconfig_service, new_service))) { diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c index 90f8b6eca..39488e7f4 100644 --- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c +++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c @@ -230,7 +230,8 @@ do_one_pam_auth( char *pam_service, /* name of service for pam_start() */ char *map_ident_attr, /* for ENTRY method, name of attribute holding pam identity */ PRBool fallback, /* if true, failure here should fallback to regular bind */ - int pw_response_requested /* do we need to send pwd policy resp control */ + int pw_response_requested, /* do we need to send pwd policy resp control */ + PRBool module_thread_safe /* if not thread safe, make sure only one thread auth at a time */ ) { MyStrBuf pam_id; @@ -277,7 +278,9 @@ do_one_pam_auth( my_data.pb = pb; my_data.pam_identity = pam_id.str; my_pam_conv.appdata_ptr = &my_data; - slapi_lock_mutex(PAMLock); + if (! module_thread_safe) { + slapi_lock_mutex(PAMLock); + } /* from this point on we are in the critical section */ rc = pam_start(pam_service, pam_id.str, &my_pam_conv, &pam_handle); report_pam_error("during pam_start", rc, pam_handle); @@ -362,7 +365,9 @@ do_one_pam_auth( slapi_log_err(SLAPI_LOG_ERR, PAM_PASSTHRU_PLUGIN_SUBSYSTEM, "do_one_pam_auth - Error during pam_end (%d)\n", rc); } - slapi_unlock_mutex(PAMLock); + if (! module_thread_safe) { + slapi_unlock_mutex(PAMLock); + } /* not in critical section any more */ done: @@ -428,6 +433,7 @@ pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg) PRBool final_method; PRBool fallback = PR_FALSE; int pw_response_requested; + PRBool module_thread_safe = PR_FALSE; LDAPControl **reqctrls = NULL; /* get the methods and other info */ @@ -439,6 +445,8 @@ pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg) init_my_str_buf(&pam_service, cfg->pamptconfig_service); fallback = cfg->pamptconfig_fallback; + + module_thread_safe = cfg->pamptconfig_thread_safe; slapi_pblock_get(pb, SLAPI_REQCONTROLS, &reqctrls); slapi_pblock_get(pb, SLAPI_PWPOLICY, &pw_response_requested); @@ -448,15 +456,15 @@ pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg) final_method = (method2 == PAMPT_MAP_METHOD_NONE); rc = do_one_pam_auth(pb, method1, final_method, pam_service.str, pam_id_attr.str, fallback, - pw_response_requested); + pw_response_requested, module_thread_safe); if ((rc != LDAP_SUCCESS) && !final_method) { final_method = (method3 == PAMPT_MAP_METHOD_NONE); rc = do_one_pam_auth(pb, method2, final_method, pam_service.str, pam_id_attr.str, fallback, - pw_response_requested); + pw_response_requested, module_thread_safe); if ((rc != LDAP_SUCCESS) && !final_method) { final_method = PR_TRUE; rc = do_one_pam_auth(pb, method3, final_method, pam_service.str, pam_id_attr.str, fallback, - pw_response_requested); + pw_response_requested, module_thread_safe); } }
0
3344b43b1842e6153115bde03ad6bf5c0416dfbb
389ds/389-ds-base
Ticket 47578: CI tests: removal of 'sudo' and absolute path in lib389 Bug Description: During the first drop of dsadmin into lib389 I added sudo call and absolute path On platform that do not support SELinux, failure to call 'semanage' is not caught Fix Description: suppress the call to sudo and catch failure of 'semanage' call https://fedorahosted.org/389/ticket/47578 Reviewed by: Rich Megginson (Thanks Rich !) Platforms tested: F17 Flag Day: no Doc impact: no
commit 3344b43b1842e6153115bde03ad6bf5c0416dfbb Author: Thierry bordaz (tbordaz) <[email protected]> Date: Wed Nov 6 16:32:56 2013 +0100 Ticket 47578: CI tests: removal of 'sudo' and absolute path in lib389 Bug Description: During the first drop of dsadmin into lib389 I added sudo call and absolute path On platform that do not support SELinux, failure to call 'semanage' is not caught Fix Description: suppress the call to sudo and catch failure of 'semanage' call https://fedorahosted.org/389/ticket/47578 Reviewed by: Rich Megginson (Thanks Rich !) Platforms tested: F17 Flag Day: no Doc impact: no diff --git a/src/lib389/lib389/tools.py b/src/lib389/lib389/tools.py index 0e5774ce0..087dd8856 100644 --- a/src/lib389/lib389/tools.py +++ b/src/lib389/lib389/tools.py @@ -21,6 +21,7 @@ import operator import select import time import shutil +import subprocess import lib389 from lib389 import InvalidArgumentError @@ -46,6 +47,7 @@ log = logging.getLogger(__name__) # Private constants PATH_SETUP_DS_ADMIN = "/setup-ds-admin.pl" PATH_SETUP_DS = "/setup-ds.pl" +PATH_REMOVE_DS = "/remove-ds.pl" PATH_ADM_CONF = "/etc/dirsrv/admin-serv/adm.conf" class DirSrvTools(object): @@ -272,9 +274,16 @@ class DirSrvTools(object): DirSrvTools.stop(dirsrv) # allow secport for selinux if secport != 636: - log.debug("Configuring SELinux on port:", secport) - cmd = '/usr/bin/sudo semanage port -a -t ldap_port_t -p tcp %s' % secport - os.system(cmd) + try: + log.debug("Configuring SELinux on port: %s", str(secport)) + + subprocess.check_call([ "semanage", "port", "-a", "-t", "ldap_port_t", "-p", "tcp", str(secport) ]) + except OSError: + log.debug("Likely SELinux not supported") + pass + except subprocess.CalledProcessError: + log.debug("SELinux fails to configure") + pass # eventually copy security files from source dir to our cert dir if sourcedir: @@ -299,16 +308,13 @@ class DirSrvTools(object): @staticmethod def runInfProg(prog, content, verbose): """run a program that takes an .inf style file on stdin""" - cmd = [ '/usr/bin/sudo' ] - cmd.append('/usr/bin/perl') - cmd.append( prog ) - #cmd = [prog] + cmd = [prog] if verbose: cmd.append('-ddd') else: cmd.extend(['-l', '/dev/null']) cmd.extend(['-s', '-f', '-']) - print "running: %s " % cmd + log.debug("running: %s " % cmd) if HASPOPEN: pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) child_stdin = pipe.stdin @@ -336,10 +342,16 @@ class DirSrvTools(object): return exitCode @staticmethod - def removeInstance(instance): + def removeInstance(dirsrv): """run the remove instance command""" - cmd = "/usr/bin/sudo /usr/bin/perl /usr/sbin/remove-ds.pl -i slapd-%s" % instance - #print "running: %s " % cmd + if hasattr(dirsrv, 'prefix'): + prefix = dirsrv.prefix + else: + prefix = None + + prog = get_sbin_dir(None, prefix) + PATH_REMOVE_DS + cmd = "%s -i slapd-%s" % (prog, dirsrv.serverId) + log.debug("running: %s " % cmd) try: os.system(cmd) except: @@ -451,6 +463,7 @@ class DirSrvTools(object): try: newconn = lib389.DirSrv(args['newhost'], args['newport'], args['newrootdn'], args['newrootpw'], args['newinstance']) + newconn.prefix = prefix newconn.isLocal = isLocal if args['have_admin'] and not args['setup_admin']: newconn.asport = asport @@ -517,6 +530,7 @@ class DirSrvTools(object): newconn = lib389.DirSrv(args['newhost'], args['newport'], args['newrootdn'], args['newrootpw'], args['newinstance']) + newconn.prefix = prefix newconn.isLocal = isLocal # Now the admin should have been created # but still I should have taken all the required infos
0
ff508d1a4bf09f73804115fd34f52c49a9477a26
389ds/389-ds-base
Issue 4914 - BUG - resolve duplicate stderr with clang (#4915) Bug Description: Due to linking with libgcc stderr had multiple locations available when using asan + clang. Fix Description: Remove gcc_s from ld with rust when using clang, and mark c++ to use staticly linked libgcc to scope the stderr definition to libns-dshttpd. fixes: https://github.com/389ds/389-ds-base/issues/4914 Author: William Brown <[email protected]> Review by: @progier389
commit ff508d1a4bf09f73804115fd34f52c49a9477a26 Author: Firstyear <[email protected]> Date: Fri Sep 10 11:44:27 2021 +1000 Issue 4914 - BUG - resolve duplicate stderr with clang (#4915) Bug Description: Due to linking with libgcc stderr had multiple locations available when using asan + clang. Fix Description: Remove gcc_s from ld with rust when using clang, and mark c++ to use staticly linked libgcc to scope the stderr definition to libns-dshttpd. fixes: https://github.com/389ds/389-ds-base/issues/4914 Author: William Brown <[email protected]> Review by: @progier389 diff --git a/Makefile.am b/Makefile.am index 8e22ef734..3e68d7839 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,11 +64,13 @@ CARGO_FLAGS = @cargo_defs@ if CLANG_ENABLE RUSTC_FLAGS = @asan_rust_defs@ @msan_rust_defs@ @tsan_rust_defs@ @debug_rust_defs@ RUSTC_LINK_FLAGS = -C link-arg=-fuse-ld=lld +RUST_LDFLAGS = -ldl -lpthread -lc -lm -lrt -lutil else RUSTC_FLAGS = @asan_rust_defs@ @msan_rust_defs@ @tsan_rust_defs@ @debug_rust_defs@ RUSTC_LINK_FLAGS = -endif +# This avoids issues with stderr being double provided with clang + asan. RUST_LDFLAGS = -ldl -lpthread -lgcc_s -lc -lm -lrt -lutil +endif RUST_DEFINES = -DRUST_ENABLE if RUST_ENABLE_OFFLINE RUST_OFFLINE = --locked --offline @@ -1078,7 +1080,12 @@ libns_dshttpd_la_SOURCES = lib/libaccess/access_plhash.cpp \ libns_dshttpd_la_CPPFLAGS = -I$(srcdir)/include/base $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) -I$(srcdir)/lib/ldaputil libns_dshttpd_la_LIBADD = libslapd.la libldaputil.la $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) +if CLANG_ENABLE +# This avoids issues with stderr being double provided with clang + asan. +libns_dshttpd_la_LDFLAGS = $(AM_LDFLAGS) -static-libgcc +else libns_dshttpd_la_LDFLAGS = $(AM_LDFLAGS) +endif #------------------------ # libslapd
0
c2650f02e2457e4e2d9ace1e9cf25ba6a6ac30e9
389ds/389-ds-base
Issue 49239 - Add a new CI test case Bug Description: ds-replcheck unreliable, showing false positives, showing missing tombstone entries in the report. Fix Description: Added a test case to check missing tombstone entries is not reported, also fixed py3 issue in ds-replcheck by explicitly adding bytes. Relates: https://pagure.io/389-ds-base/issue/49239 Review by: vashirov, mreynolds (Thanks!)
commit c2650f02e2457e4e2d9ace1e9cf25ba6a6ac30e9 Author: Akshay Adhikari <[email protected]> Date: Wed Jun 26 13:56:05 2019 +0530 Issue 49239 - Add a new CI test case Bug Description: ds-replcheck unreliable, showing false positives, showing missing tombstone entries in the report. Fix Description: Added a test case to check missing tombstone entries is not reported, also fixed py3 issue in ds-replcheck by explicitly adding bytes. Relates: https://pagure.io/389-ds-base/issue/49239 Review by: vashirov, mreynolds (Thanks!) diff --git a/dirsrvtests/tests/suites/ds_tools/replcheck_test.py b/dirsrvtests/tests/suites/ds_tools/replcheck_test.py index 11f713e2b..f23b25ce8 100644 --- a/dirsrvtests/tests/suites/ds_tools/replcheck_test.py +++ b/dirsrvtests/tests/suites/ds_tools/replcheck_test.py @@ -432,6 +432,38 @@ def test_suffix_exists(topo_tls_ldapi): assert "Failed to validate suffix" in result[0] +def test_check_missing_tombstones(topo_tls_ldapi): + """Check missing tombstone entries is not reported. + + :id: 93067a5a-416e-4243-9418-c4dfcf42e093 + :setup: Two master replication + :steps: + 1. Pause replication between master and replica + 2. Add and delete an entry on the master + 3. Run ds-replcheck + 4. Verify there are NO complaints about missing entries/tombstones + :expectedresults: + 1. It should be successful + 2. It should be successful + 3. It should be successful + 4. It should be successful + """ + m1 = topo_tls_ldapi.ms["master1"] + m2 = topo_tls_ldapi.ms["master2"] + + try: + topo_tls_ldapi.pause_all_replicas() + users_m1 = UserAccounts(m1, DEFAULT_SUFFIX) + user0 = users_m1.create_test_user(1000) + user0.delete() + for tool_cmd in replcheck_cmd_list(topo_tls_ldapi): + result = subprocess.check_output(tool_cmd, encoding='utf-8').lower() + assert "entries missing on replica" not in result + + finally: + topo_tls_ldapi.resume_all_replicas() + + if __name__ == '__main__': # Run isolated # -s for DEBUG mode diff --git a/ldap/admin/src/scripts/ds-replcheck b/ldap/admin/src/scripts/ds-replcheck index 4abb417af..30bcfd65d 100755 --- a/ldap/admin/src/scripts/ds-replcheck +++ b/ldap/admin/src/scripts/ds-replcheck @@ -142,7 +142,7 @@ def convert_entries(entries): continue # lowercase all the objectclass values (easier for tombstone checking) - oc_vals = new_entry.data['objectclass'] + oc_vals = ensure_list_str(new_entry.data['objectclass']) new_oc_vals = [] for val in oc_vals: new_oc_vals.append(val.lower())
0
30c4f30853e046bf04bc86112b8bf19bcd7fa60d
389ds/389-ds-base
Ticket 49290 - improve idl handling in complex searches Bug Description: Previously we performed iterative set manipulations during searches. For example, (&(a)(b)(c)(d)) would result in: t1 = intersect(a, b) t2 = intersect(t1, c) t3 = intersect(t2, d) This is similar for or with union. The issue is that if the candidate sets were large (until d), then we would allocate and duplicate a large set of ID's repeatedly, until the set was reduced in the third step. The same is true for unions, but the set would continue to grow. As well due to the sorted nature of the IDList, we would perform an O(m + n) merge of the arrays, potentially many times. This would be amplified the more terms added. Especially in the and case, this could result in significant time differences if you move smaller candidate sets to the start of the query, and for the or case, would result in exponential time increases by adding extra terms. Fix Description: To resolve this, rather than processing each set in an interative fashion, we store each subfilters result in the new idl_set structure. When we have collected each candidate set we can then perform better intersections. This is done through k-way intersection and k-way unions, which prevent intermediate allocations during processing. A benefit of this change, is that future improvements to not/or queries are easier to make because we now have "perfect" knowledge of all the IDLists involved, rather than just pairs at a time. https://pagure.io/389-ds-base/issue/49290 Author: wibrown Review by: tbordaz, lkrispen (Thanks!)
commit 30c4f30853e046bf04bc86112b8bf19bcd7fa60d Author: William Brown <[email protected]> Date: Fri Jun 23 11:06:00 2017 +1000 Ticket 49290 - improve idl handling in complex searches Bug Description: Previously we performed iterative set manipulations during searches. For example, (&(a)(b)(c)(d)) would result in: t1 = intersect(a, b) t2 = intersect(t1, c) t3 = intersect(t2, d) This is similar for or with union. The issue is that if the candidate sets were large (until d), then we would allocate and duplicate a large set of ID's repeatedly, until the set was reduced in the third step. The same is true for unions, but the set would continue to grow. As well due to the sorted nature of the IDList, we would perform an O(m + n) merge of the arrays, potentially many times. This would be amplified the more terms added. Especially in the and case, this could result in significant time differences if you move smaller candidate sets to the start of the query, and for the or case, would result in exponential time increases by adding extra terms. Fix Description: To resolve this, rather than processing each set in an interative fashion, we store each subfilters result in the new idl_set structure. When we have collected each candidate set we can then perform better intersections. This is done through k-way intersection and k-way unions, which prevent intermediate allocations during processing. A benefit of this change, is that future improvements to not/or queries are easier to make because we now have "perfect" knowledge of all the IDLists involved, rather than just pairs at a time. https://pagure.io/389-ds-base/issue/49290 Author: wibrown Review by: tbordaz, lkrispen (Thanks!) diff --git a/Makefile.am b/Makefile.am index b2c736bb1..134206d91 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1260,6 +1260,7 @@ libback_ldbm_la_SOURCES = ldap/servers/slapd/back-ldbm/ancestorid.c \ ldap/servers/slapd/back-ldbm/idl.c \ ldap/servers/slapd/back-ldbm/idl_shim.c \ ldap/servers/slapd/back-ldbm/idl_new.c \ + ldap/servers/slapd/back-ldbm/idl_set.c \ ldap/servers/slapd/back-ldbm/idl_common.c \ ldap/servers/slapd/back-ldbm/import.c \ ldap/servers/slapd/back-ldbm/import-merge.c \ diff --git a/dirsrvtests/tests/suites/filter/filter_logic.py b/dirsrvtests/tests/suites/filter/filter_logic.py new file mode 100644 index 000000000..1cb158df4 --- /dev/null +++ b/dirsrvtests/tests/suites/filter/filter_logic.py @@ -0,0 +1,206 @@ +# --- 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._constants import DEFAULT_SUFFIX + +from lib389.idm.user import UserAccounts + +""" +This test case asserts that various logical filters apply correctly and as expected. +This is to assert that we have correct and working search operations, especially related +to indexed content from filterindex.c and idl_sets. + +important to note, some tests check greater than 10 elements to assert that k-way intersect +works, where as most of these actually hit the filtertest threshold so they early return. +""" + +USER0_DN = 'uid=user0,ou=People,%s' % DEFAULT_SUFFIX +USER1_DN = 'uid=user1,ou=People,%s' % DEFAULT_SUFFIX +USER2_DN = 'uid=user2,ou=People,%s' % DEFAULT_SUFFIX +USER3_DN = 'uid=user3,ou=People,%s' % DEFAULT_SUFFIX +USER4_DN = 'uid=user4,ou=People,%s' % DEFAULT_SUFFIX +USER5_DN = 'uid=user5,ou=People,%s' % DEFAULT_SUFFIX +USER6_DN = 'uid=user6,ou=People,%s' % DEFAULT_SUFFIX +USER7_DN = 'uid=user7,ou=People,%s' % DEFAULT_SUFFIX +USER8_DN = 'uid=user8,ou=People,%s' % DEFAULT_SUFFIX +USER9_DN = 'uid=user9,ou=People,%s' % DEFAULT_SUFFIX +USER10_DN = 'uid=user10,ou=People,%s' % DEFAULT_SUFFIX +USER11_DN = 'uid=user11,ou=People,%s' % DEFAULT_SUFFIX +USER12_DN = 'uid=user12,ou=People,%s' % DEFAULT_SUFFIX +USER13_DN = 'uid=user13,ou=People,%s' % DEFAULT_SUFFIX +USER14_DN = 'uid=user14,ou=People,%s' % DEFAULT_SUFFIX +USER15_DN = 'uid=user15,ou=People,%s' % DEFAULT_SUFFIX +USER16_DN = 'uid=user16,ou=People,%s' % DEFAULT_SUFFIX +USER17_DN = 'uid=user17,ou=People,%s' % DEFAULT_SUFFIX +USER18_DN = 'uid=user18,ou=People,%s' % DEFAULT_SUFFIX +USER19_DN = 'uid=user19,ou=People,%s' % DEFAULT_SUFFIX + [email protected](scope="module") +def topology_st_f(topology_st): + # Add our users to the topology_st + users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX) + for i in range(0, 20): + users.create(properties={ + 'uid': 'user%s' % i, + 'cn': 'user%s' % i, + 'sn': '%s' % i, + 'uidNumber': '%s' % i, + 'gidNumber': '%s' % i, + 'homeDirectory': '/home/user%s' % i + }) + # return it + # print("ATTACH NOW") + # import time + # time.sleep(30) + return topology_st.standalone + +def _check_filter(topology_st_f, filt, expect_len, expect_dns): + # print("checking %s" % filt) + results = topology_st_f.search_s("ou=People,%s" % DEFAULT_SUFFIX, ldap.SCOPE_ONELEVEL, filt, ['uid',]) + assert len(results) == expect_len + result_dns = [result.dn for result in results] + assert set(expect_dns) == set(result_dns) + +def test_filter_logic_eq(topology_st_f): + _check_filter(topology_st_f, '(uid=user0)', 1, [USER0_DN]) + +def test_filter_logic_sub(topology_st_f): + _check_filter(topology_st_f, '(uid=user*)', 20, [ + USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN, + USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + +def test_filter_logic_not_eq(topology_st_f): + _check_filter(topology_st_f, '(!(uid=user0))', 19, [ + USER1_DN, USER2_DN, USER3_DN, USER4_DN, USER5_DN, + USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + +# More not cases? + +def test_filter_logic_range(topology_st_f): + _check_filter(topology_st_f, '(uid>=user5)', 15, [ + USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + _check_filter(topology_st_f, '(uid<=user4)', 5, [ + USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN + ]) + _check_filter(topology_st_f, '(uid>=ZZZZ)', 0, []) + _check_filter(topology_st_f, '(uid<=aaaa)', 0, []) + +def test_filter_logic_and_eq(topology_st_f): + _check_filter(topology_st_f, '(&(uid=user0)(cn=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(&(uid=user0)(cn=user1))', 0, []) + _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(sn=0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(&(uid=user0)(cn=user1)(sn=0))', 0, []) + _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(sn=1))', 0, []) + +def test_filter_logic_and_range(topology_st_f): + _check_filter(topology_st_f, '(&(uid>=user5)(cn<=user7))', 3, [ + USER5_DN, USER6_DN, USER7_DN + ]) + +def test_filter_logic_and_allid_shortcut(topology_st_f): + _check_filter(topology_st_f, '(&(objectClass=*)(uid=user0)(cn=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(objectClass=*))', 1, [USER0_DN]) + +def test_filter_logic_or_eq(topology_st_f): + _check_filter(topology_st_f, '(|(uid=user0)(cn=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(|(uid=user0)(uid=user1))', 2, [USER0_DN, USER1_DN]) + _check_filter(topology_st_f, '(|(uid=user0)(cn=user0)(sn=0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(|(uid=user0)(uid=user1)(sn=0))', 2, [USER0_DN, USER1_DN]) + _check_filter(topology_st_f, '(|(uid=user0)(uid=user1)(uid=user2))', 3, [USER0_DN, USER1_DN, USER2_DN]) + +def test_filter_logic_and_not_eq(topology_st_f): + _check_filter(topology_st_f, '(&(uid=user0)(!(cn=user0)))', 0, []) + _check_filter(topology_st_f, '(&(uid=*)(!(uid=user0)))', 19, [ + USER1_DN, USER2_DN, USER3_DN, USER4_DN, USER5_DN, + USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + +def test_filter_logic_or_not_eq(topology_st_f): + _check_filter(topology_st_f, '(|(!(uid=user0))(!(uid=user1)))', 20, [ + USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN, + USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + +def test_filter_logic_and_range(topology_st_f): + # These all hit shortcut cases. + _check_filter(topology_st_f, '(&(uid>=user5)(uid=user6))', 1, [USER6_DN]) + _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0))', 0, []) + _check_filter(topology_st_f, '(&(uid>=user5)(uid=user6)(sn=6))', 1, [USER6_DN]) + _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0)(sn=0))', 0, []) + _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0)(sn=1))', 0, []) + # These all take 2-way or k-way cases. + _check_filter(topology_st_f, '(&(uid>=user5)(uid>=user6))', 15, [ + USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + _check_filter(topology_st_f, '(&(uid>=user5)(uid>=user6)(uid>=user7))', 15, [ + USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + + +def test_filter_logic_or_range(topology_st_f): + _check_filter(topology_st_f, '(|(uid>=user5)(uid=user6))', 15, [ + USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + _check_filter(topology_st_f, '(|(uid>=user5)(uid=user0))', 16, [ + USER0_DN, + USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, + USER10_DN, USER11_DN, USER12_DN, USER13_DN, USER14_DN, + USER15_DN, USER16_DN, USER17_DN, USER18_DN, USER19_DN + ]) + +def test_filter_logic_and_and_eq(topology_st_f): + _check_filter(topology_st_f, '(&(&(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(&(&(uid=user1)(sn=0))(cn=user0))', 0, []) + _check_filter(topology_st_f, '(&(&(uid=user0)(sn=1))(cn=user0))', 0, []) + _check_filter(topology_st_f, '(&(&(uid=user0)(sn=0))(cn=user1))', 0, []) + +def test_filter_logic_or_or_eq(topology_st_f): + _check_filter(topology_st_f, '(|(|(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(|(|(uid=user1)(sn=0))(cn=user0))', 2, [USER0_DN, USER1_DN]) + _check_filter(topology_st_f, '(|(|(uid=user0)(sn=1))(cn=user0))', 2, [USER0_DN, USER1_DN]) + _check_filter(topology_st_f, '(|(|(uid=user0)(sn=0))(cn=user1))', 2, [USER0_DN, USER1_DN]) + _check_filter(topology_st_f, '(|(|(uid=user0)(sn=1))(cn=user2))', 3, [USER0_DN, USER1_DN, USER2_DN]) + +def test_filter_logic_and_or_eq(topology_st_f): + _check_filter(topology_st_f, '(&(|(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(&(|(uid=user1)(sn=0))(cn=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(&(|(uid=user0)(sn=1))(cn=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(&(|(uid=user0)(sn=0))(cn=user1))', 0, []) + _check_filter(topology_st_f, '(&(|(uid=user0)(sn=1))(cn=*))', 2, [USER0_DN, USER1_DN]) + +def test_filter_logic_or_and_eq(topology_st_f): + _check_filter(topology_st_f, '(|(&(uid=user0)(sn=0))(uid=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(|(&(uid=user1)(sn=2))(uid=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(|(&(uid=user0)(sn=1))(uid=user0))', 1, [USER0_DN]) + _check_filter(topology_st_f, '(|(&(uid=user1)(sn=1))(uid=user0))', 2, [USER0_DN, USER1_DN]) + + diff --git a/dirsrvtests/tests/suites/replication/cleanallruv_test.py b/dirsrvtests/tests/suites/replication/cleanallruv_test.py index cd7aa21d7..a5a367305 100644 --- a/dirsrvtests/tests/suites/replication/cleanallruv_test.py +++ b/dirsrvtests/tests/suites/replication/cleanallruv_test.py @@ -18,7 +18,7 @@ from lib389._constants import (DEFAULT_SUFFIX, REPLICA_RUV_FILTER, REPLICAROLE_M REPLICAID_MASTER_1, REPLICATION_BIND_DN, REPLICATION_BIND_PW, REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, SUFFIX, RA_NAME, RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT, - defaultProperties) + defaultProperties, args_instance) from lib389 import DirSrv diff --git a/dirsrvtests/tests/tickets/ticket48252_test.py b/dirsrvtests/tests/tickets/ticket48252_test.py index ac88d3777..d8d25e8a4 100644 --- a/dirsrvtests/tests/tickets/ticket48252_test.py +++ b/dirsrvtests/tests/tickets/ticket48252_test.py @@ -11,6 +11,7 @@ import logging import pytest from lib389.tasks import * from lib389.topologies import topology_st +from lib389.idm.user import UserAccounts from lib389._constants import DEFAULT_SUFFIX, SUFFIX, DEFAULT_BENAME, PLUGIN_USN @@ -21,6 +22,7 @@ USER_NUM = 10 TEST_USER = "test_user" + def test_ticket48252_setup(topology_st): """ Enable USN plug-in for enabling tombstones @@ -35,12 +37,16 @@ def test_ticket48252_setup(topology_st): assert False log.info("Adding test entries...") - for id in range(USER_NUM): - name = "%s%d" % (TEST_USER, id) - topology_st.standalone.add_s(Entry(("cn=%s,%s" % (name, SUFFIX), { - 'objectclass': "top person".split(), - 'sn': name, - 'cn': name}))) + ua = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX) + for i in range(USER_NUM): + ua.create(properties={ + 'uid': "%s%d" % (TEST_USER, i), + 'cn' : "%s%d" % (TEST_USER, i), + 'sn' : 'user', + 'uidNumber' : '1000', + 'gidNumber' : '2000', + 'homeDirectory' : '/home/testuser' + }) def in_index_file(topology_st, id, index): @@ -64,10 +70,11 @@ def test_ticket48252_run_0(topology_st): Check it is not in the 'cn' index file """ log.info("Case 1 - Check deleted entry is not in the 'cn' index file") + uas = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX) del_rdn = "cn=%s0" % TEST_USER - del_entry = "%s,%s" % (del_rdn, SUFFIX) + del_entry = uas.get('%s0' % TEST_USER) log.info(" Deleting a test entry %s..." % del_entry) - topology_st.standalone.delete_s(del_entry) + del_entry.delete() assert in_index_file(topology_st, 0, 'cn') == False @@ -75,7 +82,7 @@ def test_ticket48252_run_0(topology_st): assert topology_st.standalone.db2index(DEFAULT_BENAME, 'cn') assert in_index_file(topology_st, 0, 'cn') == False - log.info(" entry %s is not in the cn index file after reindexed." % del_entry) + log.info(" entry %s is not in the cn index file after reindexed." % del_rdn) log.info('Case 1 - PASSED') @@ -85,21 +92,35 @@ def test_ticket48252_run_1(topology_st): Check it is in the 'objectclass' index file as a tombstone entry """ log.info("Case 2 - Check deleted entry is in the 'objectclass' index file as a tombstone entry") + uas = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX) del_rdn = "cn=%s1" % TEST_USER - del_entry = "%s,%s" % (del_rdn, SUFFIX) - log.info(" Deleting a test entry %s..." % del_entry) - topology_st.standalone.delete_s(del_entry) + del_entry = uas.get('%s1' % TEST_USER) + log.info(" Deleting a test entry %s..." % del_rdn) - entry = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(&(objectclass=nstombstone)(%s))' % del_rdn) + del_uniqueid = del_entry.get_attr_val_utf8('nsuniqueid') + + del_entry.delete() + + ## Note: you can't search by nstombstone and other indexed types - it won't work! + # need to use the nsuniqueid. + + entry = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(&(objectclass=nstombstone)(nsuniqueid=%s))' % del_uniqueid) assert len(entry) == 1 - log.info(" entry %s is in the objectclass index file." % del_entry) + log.info(" entry %s is in the objectclass index file." % del_rdn) + entry = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(&(objectclass=nstombstone)(%s))' % del_rdn) + assert len(entry) == 0 + log.info(" entry %s is correctly not in the cn index file before reindexing." % del_rdn) log.info(" db2index - reindexing %s ..." % 'objectclass') assert topology_st.standalone.db2index(DEFAULT_BENAME, 'objectclass') - entry = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(&(objectclass=nstombstone)(%s))' % del_rdn) + entry = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(&(objectclass=nstombstone)(nsuniqueid=%s))' % del_uniqueid) assert len(entry) == 1 - log.info(" entry %s is in the objectclass index file after reindexed." % del_entry) + log.info(" entry %s is in the objectclass index file after reindexing." % del_rdn) + entry = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(&(objectclass=nstombstone)(%s))' % del_rdn) + assert len(entry) == 0 + log.info(" entry %s is correctly not in the cn index file after reindexing." % del_rdn) + log.info('Case 2 - PASSED') diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h index 7e3b9450a..f5e27cdfe 100644 --- a/ldap/servers/slapd/back-ldbm/back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h @@ -237,7 +237,7 @@ typedef u_int32_t ID; /* * Use this to count and index into an array of ID. */ -typedef u_int32_t NIDS; +typedef uint32_t NIDS; /* * This structure represents an id block on disk and an id list @@ -245,22 +245,39 @@ typedef u_int32_t NIDS; * * The fields have the following meanings: * - * b_nmax maximum number of ids in this block. if this is == ALLIDSBLOCK, - * then this block represents all ids. - * b_nids current number of ids in use in this block. if this - * is == INDBLOCK, then this block is an indirect block - * containing a list of other blocks containing actual ids. - * the list is terminated by an id of NOID. - * b_ids a list of the actual ids themselves + * b_nmax maximum number of ids in this block. if this is == ALLIDSBLOCK, + * then this block represents all ids. + * b_nids current number of ids in use in this block. if this + * is == INDBLOCK, then this block is an indirect block + * containing a list of other blocks containing actual ids. + * the list is terminated by an id of NOID. + * b_ids a list of the actual ids themselves */ +#define ALLIDSBLOCK 0 /* == 0 => this is an allid block */ +#define INDBLOCK 0 /* == 0 => this is an indirect blk */ + +/* Default to holding 8 ids for idl_fetch_ext */ +#define IDLIST_MIN_BLOCK_SIZE 8 + typedef struct block { - NIDS b_nmax; /* max number of ids in this list */ -#define ALLIDSBLOCK 0 /* == 0 => this is an allid block */ - NIDS b_nids; /* current number of ids used */ -#define INDBLOCK 0 /* == 0 => this is an indirect blk */ - ID b_ids[1]; /* the ids - actually bigger */ + NIDS b_nmax; /* max number of ids in this list */ + NIDS b_nids; /* current number of ids used */ + struct block *next; /* Pointer to the next block in the list + * used by idl_set + */ + size_t itr; /* internal tracker of iteration for set ops */ + ID b_ids[1]; /* the ids - actually bigger */ } Block, IDList; +typedef struct _idlist_set { + int64_t count; + int64_t allids; + size_t total_size; + IDList *minimum; + IDList *head; + IDList *complement_head; +} IDListSet; + #define ALLIDS( idl ) ((idl)->b_nmax == ALLIDSBLOCK) #define INDIRECT_BLOCK( idl ) ((idl)->b_nids == INDBLOCK) #define IDL_NIDS(idl) (idl ? (idl)->b_nids : (NIDS)0) diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c index 6af8e093a..991923ace 100644 --- a/ldap/servers/slapd/back-ldbm/filterindex.c +++ b/ldap/servers/slapd/back-ldbm/filterindex.c @@ -652,7 +652,8 @@ list_candidates( int allidslimit ) { - IDList *idl, *tmp, *tmp2; + IDList *idl; + IDList *tmp; Slapi_Filter *f, *nextf, *f_head; int range = 0; int isnot; @@ -663,6 +664,7 @@ list_candidates( char *tpairs[2] = {NULL, NULL}; struct berval *vpairs[2] = {NULL, NULL}; int is_and = 0; + IDListSet *idl_set = NULL; slapi_log_err(SLAPI_LOG_TRACE, "list_candidates", "=> 0x%x\n", ftype); @@ -766,6 +768,10 @@ list_candidates( goto out; } + if (ftype == LDAP_FILTER_OR || ftype == LDAP_FILTER_AND) { + idl_set = idl_set_create(); + } + idl = NULL; nextf = NULL; isnot = 0; @@ -778,15 +784,21 @@ list_candidates( (LDAP_FILTER_EQUALITY == slapi_filter_get_choice(slapi_filter_list_first(f)))); if (isnot) { - /* if this is the first filter we have an allid search anyway, so bail */ - if(f == f_head) - { + /* + * If this is the first filter, make sure we have something to + * subtract from. + */ + if (f == f_head) { idl = idl_allids( be ); - break; + idl_set_insert_idl(idl_set, idl); } + /* + * Not the first filter - good! Get the indexed type out. + * if this is unindexed, we'll get allids. During the intersection + * in notin, we'll mark this as don't skip filter, because else we might + * get the wrong results. + */ - /* Fetch the IDL for foo */ - /* Later we'll remember to call idl_notin() */ slapi_log_err(SLAPI_LOG_TRACE, "list_candidates" ,"NOT filter\n"); if (filter_is_subtype(slapi_filter_list_first(f))) { /* @@ -832,64 +844,79 @@ list_candidates( } } - tmp2 = idl; - if ( idl == NULL ) { - idl = tmp; - if ( (ftype == LDAP_FILTER_AND) && ((idl == NULL) || - (idl_length(idl) <= FILTER_TEST_THRESHOLD))) { - break; /* We can exit the loop now, since the candidate list is small already */ - } - } else if ( ftype == LDAP_FILTER_AND ) { - if (isnot) { - /* - * If tmp is NULL or ALLID, idl_notin just duplicates idl. - * We don't have to do it. - */ - if (!tmp && !idl_is_allids(tmp)) { - IDList *new_idl = NULL; - int notin_result = 0; - notin_result = idl_notin( be, idl, tmp, &new_idl ); - if (notin_result) { - idl_free(&idl); - idl = new_idl; - } - } - } else { - idl = idl_intersection(be, idl, tmp); - idl_free( &tmp2 ); - } - idl_free( &tmp ); - /* stop if the list has gotten too small */ - if ((idl == NULL) || - (idl_length(idl) <= FILTER_TEST_THRESHOLD)) - break; - } else { - Slapi_Operation *operation; - slapi_pblock_get( pb, SLAPI_OPERATION, &operation ); + /* + * Assert we recieved a valid idl. If it was NULL, it means somewhere we failed + * during the dblayer interactions. + * + * idl_set requires a valid idl structure to generate the linked list of + * idls that we insert. + */ + if (tmp == NULL) { + slapi_log_err(SLAPI_LOG_CRIT, "list_candidates", "NULL idl was recieved from filter_candidates_ext."); + slapi_log_err(SLAPI_LOG_CRIT, "list_candidates", "Falling back to empty IDL set. This may affect your search results."); + PR_ASSERT(tmp); + tmp = idl_alloc(0); + } - idl = idl_union( be, idl, tmp ); - idl_free( &tmp ); - idl_free( &tmp2 ); - /* stop if we're already committed to an exhaustive - * search. :( + /* + * At this point we have the idl set from the subfilter. In idl_set, + * we stash this for later .... + */ + + if (ftype == LDAP_FILTER_OR || + (ftype == LDAP_FILTER_AND && !isnot)) { + idl_set_insert_idl(idl_set, tmp); + } else if (ftype == LDAP_FILTER_AND && isnot) { + idl_set_insert_complement_idl(idl_set, tmp); + } + + if (ftype == LDAP_FILTER_OR && idl_set_union_shortcut(idl_set) != 0) { + /* + * If we encounter an allids idl, this means that union will return + * and allids - we should not process anymore, and fallback to full + * table scan at this point. */ - /* PAGED RESULTS: we strictly limit the idlist size by the allids (aka idlistscan) limit. + goto apply_set_op; + } + + if (ftype == LDAP_FILTER_AND && idl_set_intersection_shortcut(idl_set) != 0) { + /* + * If we encounter a zero length idl, we bail now because this can never + * result in a meaningful result besides zero. */ + goto apply_set_op; + } + + } + + /* + * Do the idl_set operation if required. + * these are far more efficient than the iterative union and + * intersections we previously used. + */ +apply_set_op: + + if (ftype == LDAP_FILTER_OR) { + /* If one of the idl_set is allids, this shortcuts :) */ + idl = idl_set_union(idl_set, be); + size_t nids = IDL_NIDS(idl); + if ( allidslimit > 0 && nids > allidslimit ) { + Slapi_Operation *operation; + slapi_pblock_get( pb, SLAPI_OPERATION, &operation ); + /* PAGED RESULTS: we strictly limit the idlist size by the allids (aka idlistscan) limit. */ if (op_is_pagedresults(operation)) { - int nids = IDL_NIDS(idl); - if ( allidslimit > 0 && nids > allidslimit ) { - idl_free( &idl ); - idl = idl_allids( be ); - } + idl_free( &idl ); + idl = idl_allids( be ); } - if (idl_is_allids(idl)) - break; } + } else if (ftype == LDAP_FILTER_AND) { + idl = idl_set_intersect(idl_set, be); } slapi_log_err(SLAPI_LOG_TRACE, "list_candidates", "<= %lu\n", (u_long)IDL_NIDS(idl)); out: + idl_set_destroy(idl_set); if (is_and) { /* * Sets IS_AND back to 0 only when this function set 1. @@ -989,14 +1016,11 @@ keys2idl( int allidslimit ) { - IDList *idl; - int i; + IDList *idl = NULL; - slapi_log_err(SLAPI_LOG_TRACE, "keys2idl", "=> type %s indextype %s\n", - type, indextype); - idl = NULL; - for ( i = 0; ivals[i] != NULL; i++ ) { - IDList *idl2; + slapi_log_err(SLAPI_LOG_TRACE, "keys2idl", "=> type %s indextype %s\n", type, indextype); + for ( size_t i = 0; ivals[i] != NULL; i++ ) { + IDList *idl2 = NULL; idl2 = index_read_ext_allids( pb, be, type, indextype, slapi_value_get_berval(ivals[i]), txn, err, unindexed, allidslimit ); @@ -1011,23 +1035,25 @@ keys2idl( } #endif if ( idl2 == NULL ) { - idl_free( &idl ); - idl = NULL; - break; + slapi_log_err(SLAPI_LOG_WARNING, "keys2idl", "recieved NULL idl from index_read_ext_allids, treating as empty set\n"); + slapi_log_err(SLAPI_LOG_WARNING, "keys2idl", "this is probably a bug that should be reported\n"); + idl2 = idl_alloc(0); } + /* First iteration of the ivals, stash idl2. */ if (idl == NULL) { idl = idl2; } else { - IDList *tmp; + /* + * second iteration of the ivals - do an intersection and free + * the intermediates. + */ + IDList *tmp = NULL; tmp = idl; idl = idl_intersection(be, idl, idl2); idl_free( &idl2 ); idl_free( &tmp ); - if ( idl == NULL ) { - break; - } } } diff --git a/ldap/servers/slapd/back-ldbm/idl_common.c b/ldap/servers/slapd/back-ldbm/idl_common.c index cd3458e5a..b3a7fcb03 100644 --- a/ldap/servers/slapd/back-ldbm/idl_common.c +++ b/ldap/servers/slapd/back-ldbm/idl_common.c @@ -20,7 +20,7 @@ size_t idl_sizeof(IDList *idl) if (NULL == idl) { return 0; } - return (2 + idl->b_nmax) * sizeof(ID); + return sizeof(IDList) + (idl->b_nmax * sizeof(ID)); } NIDS idl_length(IDList *idl) @@ -44,10 +44,19 @@ idl_alloc( NIDS nids ) { IDList *new; + if (nids == 0) { + /* + * Because we use allids in b_nmax as 0, when we request an + * empty set, this *looks* like an empty set. Instead, we make + * a minimum b_nmax to trick it. + */ + nids = 1; + } + /* nmax + nids + space for the ids */ - new = (IDList *) slapi_ch_calloc( (2 + nids), sizeof(ID) ); + new = (IDList *) slapi_ch_calloc( 1, sizeof(IDList) + (sizeof(ID) * nids) ); new->b_nmax = nids; - new->b_nids = 0; + /* new->b_nids = 0; */ return( new ); } @@ -116,7 +125,7 @@ idl_append_extend(IDList **orig_idl, ID id) IDList *idl = *orig_idl; if (idl == NULL) { - idl = idl_alloc(32); /* used to be 0 */ + idl = idl_alloc(IDLIST_MIN_BLOCK_SIZE); /* used to be 0 */ idl_append(idl, id); *orig_idl = idl; @@ -125,17 +134,11 @@ idl_append_extend(IDList **orig_idl, ID id) if ( idl->b_nids == idl->b_nmax ) { /* No more room, need to extend */ - /* Allocate new IDL with twice the space of this one */ - IDList *idl_new = NULL; - idl_new = idl_alloc(idl->b_nmax * 2); - if (NULL == idl_new) { + idl->b_nmax = idl->b_nmax * 2; + idl = slapi_ch_realloc(idl, sizeof(IDList) + (sizeof(ID) * idl->b_nmax)); + if (idl == NULL) { return ENOMEM; } - /* copy over the existing contents */ - idl_new->b_nids = idl->b_nids; - memcpy(idl_new->b_ids, idl->b_ids, sizeof(ID) * idl->b_nids); - idl_free(&idl); - idl = idl_new; } idl->b_ids[idl->b_nids] = id; @@ -155,8 +158,7 @@ idl_dup( IDList *idl ) } new = idl_alloc( idl->b_nmax ); - SAFEMEMCPY( (char *) new, (char *) idl, (idl->b_nmax + 2) - * sizeof(ID) ); + memcpy(new, idl, idl_sizeof(idl) ); return( new ); } @@ -170,14 +172,14 @@ idl_min( IDList *a, IDList *b ) int idl_id_is_in_idlist(IDList *idl, ID id) { - NIDS i; if (NULL == idl || NOID == id) { return 0; /* not in the list */ } if (ALLIDS(idl)) { return 1; /* in the list */ } - for (i = 0; i < idl->b_nids; i++) { + + for (NIDS i = 0; i < idl->b_nids; i++) { if (id == idl->b_ids[i]) { return 1; /* in the list */ } @@ -185,6 +187,39 @@ idl_id_is_in_idlist(IDList *idl, ID id) return 0; /* not in the list */ } +/* + * idl_compare - compare idl a and b for value equality and ordering. + */ +int64_t +idl_compare(IDList *a, IDList *b) { + /* Assert they are not none. */ + if (a == NULL || b == NULL) { + return 1; + } + /* Are they the same pointer? */ + if (a == b) { + return 0; + } + /* Do they have the same number of IDs? */ + if (a->b_nids != b->b_nids) { + return 1; + } + + /* Are they both allid blocks? */ + if ( ALLIDS( a ) && ALLIDS( b ) ) { + return 0; + } + + /* Same size, and not the same array. Lets check! */ + for (size_t i = 0; i < a->b_nids; i++) { + if (a->b_ids[i] != b->b_ids[i]) { + return 1; + } + } + /* Must be the same! */ + return 0; +} + /* * idl_intersection - return a intersection b */ @@ -198,9 +233,14 @@ idl_intersection( NIDS ai, bi, ni; IDList *n; - if ( a == NULL || b == NULL ) { - return( NULL ); + if ( a == NULL || a->b_nids == 0 ) { + return idl_dup(a); + } + + if ( b == NULL || b->b_nids == 0) { + return idl_dup(b); } + if ( ALLIDS( a ) ) { slapi_be_set_flag(be, SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST); return( idl_dup( b ) ); @@ -225,10 +265,6 @@ idl_intersection( } } - if ( ni == 0 ) { - idl_free( &n ); - return( NULL ); - } n->b_nids = ni; return( n ); @@ -248,10 +284,10 @@ idl_union( NIDS ai, bi, ni; IDList *n; - if ( a == NULL ) { + if ( a == NULL || a->b_nids == 0 ) { return( idl_dup( b ) ); } - if ( b == NULL ) { + if ( b == NULL || b->b_nids == 0 ) { return( idl_dup( a ) ); } if ( ALLIDS( a ) || ALLIDS( b ) ) { @@ -311,12 +347,23 @@ idl_notin( IDList *n; *new_result = NULL; - if ( a == NULL ) { - return( 0 ); + /* Nothing in a, so nothing to subtract from. */ + if ( a == NULL || a->b_nids == 0 ) { + *new_result = idl_alloc(0); + return 1; } - if ( b == NULL || ALLIDS( b ) ) { - *new_result = idl_dup( a ); - return( 1 ); + /* b is empty, so nothing to remove from a. */ + if ( b == NULL || b->b_nids == 0 ) { + return 0; + } + + /* b is allIDS, so a - b, should be the empty set. + * but if the type in unindexed, we don't know. Instead we have to + * return a, and mark that we can't skip the filter test. + */ + if ( ALLIDS(b) ) { + slapi_be_set_flag(be, SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST); + return 0; } if ( ALLIDS( a ) ) { /* Not convinced that this code is really worth it */ @@ -418,7 +465,7 @@ idl_nextid( IDList *idl, ID id ) { NIDS i; - if (NULL == idl) { + if (NULL == idl || idl->b_nids == 0) { return NOID; } if ( ALLIDS( idl ) ) { @@ -463,10 +510,18 @@ idl_iterator idl_iterator_decrement(idl_iterator *i) ID idl_iterator_dereference(idl_iterator i, const IDList *idl) { + /* + * NOID is used to terminate iteration. When we get an allIDS + * idl->b_nids == number of entries in id2entry. That's how we + * know to stop returning ids. + */ if ( (NULL == idl) || (i >= idl->b_nids)) { return NOID; } if (ALLIDS(idl)) { + /* + * entries in id2entry start at 1, not 0, so we have off by one here. + */ return (ID) i + 1; } else { return idl->b_ids[i]; @@ -484,5 +539,5 @@ ID idl_iterator_dereference_decrement(idl_iterator *i, const IDList *idl) { idl_iterator_decrement(i); return idl_iterator_dereference(*i,idl); - } + diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c index 0c680aa75..6a175b787 100644 --- a/ldap/servers/slapd/back-ldbm/idl_new.c +++ b/ldap/servers/slapd/back-ldbm/idl_new.c @@ -191,6 +191,9 @@ idl_new_fetch( goto error; /* Not found is OK, return NULL IDL */ } + /* Allocate an idlist to populate into */ + idl = idl_alloc(IDLIST_MIN_BLOCK_SIZE); + /* Iterate over the duplicates, amassing them into an IDL */ for (;;) { ID lastid = 0; @@ -226,8 +229,7 @@ idl_new_fetch( /* we got another ID, add it to our IDL */ idl_rc = idl_append_extend(&idl, id); if (idl_rc) { - slapi_log_err(SLAPI_LOG_ERR, "idl_new_fetch", "Unable to extend id list (err=%d)\n", - idl_rc); + slapi_log_err(SLAPI_LOG_ERR, "idl_new_fetch", "Unable to extend id list (err=%d)\n", idl_rc); idl_free(&idl); goto error; } @@ -240,13 +242,13 @@ idl_new_fetch( /* enforce the allids read limit */ if ((NEW_IDL_NO_ALLID != *flag_err) && (NULL != a) && (idl != NULL) && idl_new_exceeds_allidslimit(count, a, allidslimit)) { - idl->b_nids = 1; - idl->b_ids[0] = ALLID; - ret = DB_NOTFOUND; /* fool the code below into thinking that we finished the dups */ - slapi_log_err(SLAPI_LOG_BACKLDBM, "idl_new_fetch", "Search for key for attribute index %s " - "exceeded allidslimit %d - count is %lu\n", - a->ai_type, allidslimit, count); - break; + idl->b_nids = 1; + idl->b_ids[0] = ALLID; + ret = DB_NOTFOUND; /* fool the code below into thinking that we finished the dups */ + slapi_log_err(SLAPI_LOG_BACKLDBM, "idl_new_fetch", "Search for key for attribute index %s " + "exceeded allidslimit %d - count is %lu\n", + a->ai_type, allidslimit, count); + break; } #endif ret = cursor->c_get(cursor,&key,&data,DB_NEXT_DUP|DB_MULTIPLE); @@ -405,6 +407,9 @@ idl_new_range_fetch( goto error; /* Not found is OK, return NULL IDL */ } + /* Allocate an idlist to populate into */ + idl = idl_alloc(IDLIST_MIN_BLOCK_SIZE); + /* Iterate over the duplicates, amassing them into an IDL */ while (cur_key.data && (upperkey && upperkey->data ? @@ -600,21 +605,16 @@ error: qsort((void *)&idl->b_ids[0], idl->b_nids, (size_t)sizeof(ID), idl_sort_cmp); } if (operator & SLAPI_OP_RANGE_NO_IDL_SORT) { - int i; - int left = leftovercnt; - while (left) { - for (i = 0; i < leftovercnt; i++) { - if (leftover[i].key && idl_id_is_in_idlist(idl, leftover[i].key)) { - idl_rc = idl_append_extend(&idl, leftover[i].id); - if (idl_rc) { - slapi_log_err(SLAPI_LOG_ERR, "idl_new_range_fetch", - "Unable to extend id list (err=%d)\n", idl_rc); - idl_free(&idl); - return NULL; - } - leftover[i].key = 0; - left--; + for (size_t i = 0; i < leftovercnt; i++) { + if (leftover[i].key && idl_id_is_in_idlist(idl, leftover[i].key) == 0) { + idl_rc = idl_append_extend(&idl, leftover[i].id); + if (idl_rc) { + slapi_log_err(SLAPI_LOG_ERR, "idl_new_range_fetch", + "Unable to extend id list (err=%d)\n", idl_rc); + idl_free(&idl); + return NULL; } + leftover[i].key = 0; } } slapi_ch_free((void **)&leftover); diff --git a/ldap/servers/slapd/back-ldbm/idl_set.c b/ldap/servers/slapd/back-ldbm/idl_set.c new file mode 100644 index 000000000..cc8c2e635 --- /dev/null +++ b/ldap/servers/slapd/back-ldbm/idl_set.c @@ -0,0 +1,536 @@ +/** 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 **/ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "back-ldbm.h" + +/* + * In filterindex, rather than calling idl_union multiple times over + * this idl_set provides better apis to do efficent set manipulations + * for idl results. + * + * previously or results were calculated as: + * |(a)(b)(c)(d) + * + * t1 = union(a, b) + * t2 = union(t1, c) + * t3 = union(t2, d) + * As you can see, this results in n-1 union operations. Depending on + * the size of the IDL, this could signifigantly affect performance. + * It actually let to a situation where re-arranging a query would be + * faster. + * + * This idl_set code allows us to perform a k-way intersection and union. + * this means given some arbitrary number of IDLists (k), we intersect + * or union all k of them at the same time, rather than generating + * intermediates. + * + * k-way union + * ----------- + * + * First, if we have allids, return. + * Imagine we have these sets: + * + * (1,2,3,4) (1,5,6) (1), () + * + * We start with a pointer at the head of each: + * + * (1,2,3,4) (1,5,6) (1), () + * ^ ^ ^ ^ + * + * if the idl is empty, we prune it: + * + * (1,2,3,4) (1,5,6) (1) + * ^ ^ ^ + * + * Now we check the min id for all sets. In this case the + * sets agree it's 1, so we add 1 to the result set. + * + * now we move the pointers along and prune the empty set + * + * (1,2,3,4) (1,5,6) + * ^ ^ + * + * Now the next min is 2 - when we examine the second list + * because 5 > 2, we ignore this for now. Finally we then + * insert 2. We advance the pointer. + * + * (1,2,3,4) (1,5,6) + * ^ ^ + * We continue this until we exhaust the first list, or the + * second. + * + * k-way intersection + * ------------------ + * + * k-way intersection intersects multiple idls at the same time. + * it works by continually iterating over our lists to build a + * quorum, where all idls agree on the current minimal element. + * + * given: + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * + * we start our pointers at the start as in k-way union + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * ^ ^ ^ + * | min=0, q=0 + * + * since min=0, we set this to the min of the first list. Because + * the first list "agrees" that 1 is the min, we set quorum to 1. + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * ^ ^ ^ + * | min=1, q=1 + * + * Now we move to the next list. It also has 1 as the min, so we + * increase the quorum. + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * ^ ^ ^ + * | min=1, q=2 + * + * When we advance to the third list we see 3 is the min. So we reset + * min to 3, and q to 1 (since only this list thinks 3 is min so far) + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * ^ ^ ^ + * | min=3, q=1 + * + * We now go back to the first list. Since 1 < min, we advance our + * pointer til either we exceed min or equal it. In this case we + * equal it and add to quorum. + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * ^ ^ ^ + * | min=3, q=2 + * + * When we get to the next list, we repeat this. We advance to 5. + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * ^ ^ ^ + * | min=5, q=1 + * + * Next when we get to list 3 we have 5, and finall list 1 we have 5 + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * ^ ^ ^ + * | min=5, q=2 + * + * (1,2,3,4,5,6) (1,2,5,6) (3,5,6) + * ^ ^ ^ + * | min=5, q=3 + * + * We finally have quorum! Now we insert 5 to the result_list, and + * advance all our idl by 1. + * + * + */ + +IDListSet * +idl_set_create() { + IDListSet *idl_set = (IDListSet *)slapi_ch_calloc(1, sizeof(IDListSet)); + /* all other fields are 0 thanks to calloc */ + return idl_set; +} + +static void +idl_set_free_idls(IDListSet *idl_set) { + /* Free idlists */ + IDList *idl = idl_set->head; + IDList *next_idl = NULL; + while (idl != NULL) { + next_idl = idl->next; + idl_free(&idl); + idl = next_idl; + } + + /* Free complements if any */ + idl = idl_set->complement_head; + while (idl != NULL) { + next_idl = idl->next; + idl_free(&idl); + idl = next_idl; + } +} + +void +idl_set_destroy(IDListSet *idl_set) { + slapi_ch_free((void **)&(idl_set)); +} + +void +idl_set_insert_idl(IDListSet *idl_set, IDList *idl) { + PR_ASSERT(idl); + + /* + * prune incoming allids - for union, we just return + * allids, for intersection, if we only have + * allids we return, else we just ignore it. + */ + if (idl_is_allids(idl)) { + idl_set->allids = 1; + idl_free(&idl); + return; + } + + /* + * Track the current min set to make intersect alloc small + */ + if (idl_set->minimum == NULL || idl->b_nids < idl_set->minimum->b_nids) { + idl_set->minimum = idl; + } + /* + * Track this for max possible union size of these sets. + */ + idl_set->total_size += idl->b_nids; + + idl->next = idl_set->head; + idl_set->head = idl; + idl_set->count += 1; + + return; +} + +/* + * The difference between this and insert is that complement implies + * a future intersection, and that we plan to use a "not" query. + * + * As a result, the order of operations is to: + * * intersect all sets + * * apply complements. + */ +void +idl_set_insert_complement_idl(IDListSet *idl_set, IDList *idl) { + PR_ASSERT(idl); + /* + * If we complement to ALLIDS, the result is empty set. + * so we can put empty set into the main list. This will cause + * -- no change to union (but this should never be called during OR / union) + * -- shortcut of the AND to trigger immediately + */ + idl->next = idl_set->complement_head; + idl_set->complement_head = idl; +} + +int64_t +idl_set_union_shortcut(IDListSet *idl_set) { + /* Are we able to shortcut the union process? */ + /* This generally indicates the presence of allids */ + return idl_set->allids; +} + +int64_t +idl_set_intersection_shortcut(IDListSet *idl_set) { + /* If we have a 0 length idl, we can never create an intersection. */ + if (idl_set->minimum != NULL && idl_set->minimum->b_nids <= FILTER_TEST_THRESHOLD) { + return 1; + } + return 0; +} + +IDList * +idl_set_union(IDListSet *idl_set, backend *be) { + /* + * Check allids first, because allids = 1, may not + * have set count > 0. + */ + if (idl_set->allids != 0) { + idl_set_free_idls(idl_set); + return idl_allids(be); + } else if (idl_set->count == 0) { + return idl_alloc(0); + } else if (idl_set->count == 1) { + return idl_set->head; + } else if (idl_set->count == 2) { + IDList *result_list = idl_union(be, idl_set->head, idl_set->head->next); + idl_free(&(idl_set->head->next)); + idl_free(&(idl_set->head)); + return result_list; + } + + /* + * Allocate a new set based on the size of our sets. + */ + IDList *result_list = idl_alloc(idl_set->total_size); + IDList *idl = idl_set->head; + IDList *idl_del = NULL; + IDList *prev_idl = NULL; + NIDS last_min = 0; + NIDS next_min = 0; + + /* + * Now we iterate over our sets - if the current itr is + * cur_min and ! in the new set, add it. While we do this + * we are finding the next_min to repeat. + * + * we continue until we exhaust every set we have. + * + * check for idl_set->head->next NULL? + */ + while (idl_set->head != NULL) { + prev_idl = NULL; + idl = idl_set->head; + /* now find the next smallest */ + while (idl) { + /* + * Did our head value get inserted last round? + */ + if (idl->b_ids[idl->itr] == last_min && last_min != 0) { + /* + * Our value was previously inserted - advance itr. + */ + idl->itr += 1; + } + /* + * Nothing left to search in this idl + * itr should never be >, but lets be safe. + */ + if (idl->itr >= idl->b_nids) { + if (prev_idl) { + prev_idl->next = idl->next; + } else { + /* + * This is our base case: when we strike the last + * idl, and prev is null, and next is null, we are done! + */ + PR_ASSERT(idl == idl_set->head); + idl_set->head = idl->next; + } + idl_del = idl; + idl = idl_del->next; + idl_free(&idl_del); + /* No need to touch prev_idl. */ + } else { + /* + * Now check our value and see if it's this iterations + * smallest candidate. + */ + if (idl->b_ids[idl->itr] < next_min || next_min == 0) { + next_min = idl->b_ids[idl->itr]; + } + /* Go to the next idl. */ + prev_idl = idl; + idl = idl->next; + } + } + /* Insert the current smallest value we have */ + /* next_min can be 0 because we freed all idls remaining */ + if (next_min > 0) { + idl_append(result_list, next_min); + } + + last_min = next_min; + next_min = 0; + } + + return result_list; +} + +IDList * +idl_set_intersect(IDListSet *idl_set, backend *be) { + IDList *result_list = NULL; + + if (idl_set->allids != 0 && idl_set->count == 0) { + /* + * We only have allids, so must be allids. + */ + result_list = idl_allids(be); + } else if (idl_set->count == 0) { + /* + * No allids, but we do have ... nothing? + */ + result_list = idl_alloc(0); + } else if (idl_set->count == 1) { + /* + * If allids, when we intersect head, we get head, so just skip that. + */ + result_list = idl_set->head; + } else if (idl_set->minimum->b_nids <= FILTER_TEST_THRESHOLD) { + result_list = idl_set->minimum; + + /* Free the other IDLs which are not the minimum. */ + IDList *next = NULL; + IDList *idl = idl_set->head; + while (idl != NULL) { + next = idl->next; + if (idl != idl_set->minimum) { + idl_free(&idl); + } + idl = next; + } + } else if (idl_set->count == 2) { + /* + * If we have two items only, just intersect them. + */ + result_list = idl_intersection(be, idl_set->head, idl_set->head->next); + idl_free(&(idl_set->head->next)); + idl_free(&(idl_set->head)); + } else { + /* + * Must have at least 2 idls or more, so do a k-way intersection. + * result_list is allocated to size of min, because intersection can not + * exceed the size of the smallest set we have. + * + * we don't care if we have allids here, because we'll ignore it anyway. + */ + result_list = idl_alloc(idl_set->minimum->b_nids); + IDList *idl = idl_set->head; + + /* The previous value we inserted. */ + NIDS last_min = 0; + /* The next minimum we have found */ + NIDS next_min = 0; + + uint64_t finished = 0; + uint64_t quorum = 0; + + while (idl_set->head != NULL) { + idl = idl_set->head; + /* now find the next smallest */ + while (idl && finished == 0) { + /* + * Did our head value get inserted last round? + */ + if (idl->b_ids[idl->itr] == last_min && last_min != 0) { + /* + * Our value was previously inserted - advance itr. + */ + idl->itr += 1; + } + /* + * Nothing left to search in this idl + * itr should never be >, but lets be safe. + */ + if (idl->itr >= idl->b_nids) { + /* + * This is our base case: when we have emptied *one* + * idl, intersections of the remaining values can never be + * valid. + */ + finished = 1; + /* + * ensure we don't insert, we're done. + */ + quorum = 0; + } else { + /* + * Still data in IDLs + */ + if (next_min == 0) { + /* Must be head: so put our value as next_min */ + next_min = idl->b_ids[idl->itr]; + } else if (next_min < idl->b_ids[idl->itr]) { + /* + * Must be a diff id. mark it as skip, nothing can be + * inserted this iteration. + */ + quorum = 1; + /* + * Because this is our minimum value of this IDL, set the next_min + * to it. + */ + next_min = idl->b_ids[idl->itr]; + } else if (next_min > idl->b_ids[idl->itr]) { + /* + * We must be behind the next_min. We need to advance til we are + * eq or greater. + * + * I tried optimising this to lookahead and jump by blocks of 256 + * or 64, and it made it slower. Probably not worth it :( + */ + while (idl->itr < idl->b_nids && next_min > idl->b_ids[idl->itr]) { + idl->itr += 1; + } + /* + * Right, made it here. Are we out of ids? + */ + if (idl->itr >= idl->b_nids) { + finished = 1; + quorum = 0; + } else if (next_min < idl->b_ids[idl->itr]) { + /* okay, we don't have next_min. Update and reset */ + next_min = idl->b_ids[idl->itr]; + quorum = 1; + } else { + /* Great! we match! */ + quorum += 1; + } + } else { + /* + * Must be in agreeance - this head is the next_min + */ + quorum += 1; + } + /* + * check if all the idls agree this is the smallest value + * so we insert it! + */ + if (next_min > 0 && quorum == idl_set->count) { + idl_append(result_list, next_min); + last_min = next_min; + next_min = 0; + quorum = 0; + } + /* Go to the next idl. */ + idl = idl->next; + } + } + + if (finished) { + /* + * We emptied an IDL - drain them all. + */ + IDList *idl_del = NULL; + idl = idl_set->head; + while (idl) { + idl_del = idl; + idl = idl_del->next; + idl_free(&idl_del); + } + idl_set->head = NULL; + } + + } + } + + /* Now, that we have the "smallest" intersection possible, we need to subtract + * elements as required. + * + * NOTE: This is still not optimised yet! + */ + if (idl_set->complement_head != NULL && result_list->b_nids > 0) { + IDList *new_result_list = NULL; + IDList *next_idl = NULL; + IDList *idl = idl_set->complement_head; + while (idl != NULL) { + next_idl = idl->next; + if (idl_notin(be, result_list, idl, &new_result_list)) { + /* + * idl_notin returns 1 on new alloc, so free result_list and idl + */ + idl_free(&idl); + idl_free(&result_list); + result_list = new_result_list; + } else { + /* + * idl_notin returns 0 when it "does nothing", so just free idl. + */ + idl_free(&idl); + } + idl = next_idl; + } + } + + return result_list; +} + diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c index 2ba82d2f8..08cad1154 100644 --- a/ldap/servers/slapd/back-ldbm/index.c +++ b/ldap/servers/slapd/back-ldbm/index.c @@ -362,6 +362,7 @@ index_addordel_entry( { const CSN *tombstone_csn = NULL; char deletion_csn_str[CSN_STRSIZE]; + char *entryusn_str; Slapi_DN parent; Slapi_DN *sdn = slapi_entry_get_sdn(e->ep_entry); @@ -371,6 +372,8 @@ index_addordel_entry( * Just index the "nstombstone" attribute value from the objectclass * attribute, and the nsuniqueid attribute value, and the * nscpEntryDN value of the deleted entry. + * + * 2017 - add entryusn to this to improve entryusn tombstone tasks. */ result = index_addordel_string(be, SLAPI_ATTR_OBJECTCLASS, SLAPI_ATTR_VALUE_TOMBSTONE, e->ep_id, flags, txn); if ( result != 0 ) { @@ -397,6 +400,19 @@ index_addordel_entry( } } + /* + * add the entryusn to the list of indexed attributes, even if it's a tombstone + */ + entryusn_str = slapi_entry_attr_get_charptr(e->ep_entry, SLAPI_ATTR_ENTRYUSN); + if (entryusn_str != NULL) { + result = index_addordel_string(be, SLAPI_ATTR_ENTRYUSN, entryusn_str, e->ep_id, flags, txn); + slapi_ch_free_string(&entryusn_str); + if (result != 0) { + ldbm_nasty("index_addordel_entry",errmsg, 1021, result); + return result; + } + } + slapi_sdn_done(&parent); if (entryrdn_get_switch()) { /* subtree-rename: on */ Slapi_Attr* attr; @@ -1033,6 +1049,12 @@ index_read_ext_allids( interval = PR_MillisecondsToInterval(slapi_rand() % 100); DS_Sleep(interval); continue; + } else if (*err != 0 || idl == NULL) { + /* The database might not exist. We have to assume it means empty set */ + slapi_log_err(SLAPI_LOG_TRACE, "index_read_ext_allids", "Failed to access idl index for %s\n", basetype); + slapi_log_err(SLAPI_LOG_TRACE, "index_read_ext_allids", "Assuming %s has no index values\n", basetype); + idl = idl_alloc(0); + break; } else { break; } @@ -1434,19 +1456,19 @@ index_range_read_ext( if (0 != *err) { /* Free the key we just read above */ DBT_FREE_PAYLOAD(lowerkey); - if (DB_NOTFOUND == *err) { - *err = 0; - idl = NULL; - } else { - idl = idl_allids( be ); + if (DB_NOTFOUND == *err) { + *err = 0; + idl = idl_alloc(0); + } else { + idl = idl_allids( be ); ldbm_nasty("index_range_read_ext", errmsg, 1080, *err); - slapi_log_err(SLAPI_LOG_ERR, - "index_range_read_ext", "(%s,%s) allids (seek to lower key in index file err %i)\n", - type, prefix, *err ); - } - dbc->c_close(dbc); + slapi_log_err(SLAPI_LOG_ERR, + "index_range_read_ext", "(%s,%s) allids (seek to lower key in index file err %i)\n", + type, prefix, *err ); + } + dbc->c_close(dbc); goto error; - } + } /* We now close the cursor, since we're about to iterate over many keys */ *err = dbc->c_close(dbc); diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h index 1fc8c0885..f36d89bc5 100644 --- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -281,6 +281,21 @@ IDList *idl_new_range_fetch(backend *be, DB* db, DBT *lowerkey, DBT *upperkey, int allidslimit, int sizelimit, struct timespec *expire_time, int lookthrough_limit, int operator); + +int64_t idl_compare(IDList *a, IDList *b); + +/* + * idl_set.c + */ +IDListSet * idl_set_create(); +void idl_set_destroy(IDListSet *idl_set); +void idl_set_insert_idl(IDListSet *idl_set, IDList *idl); +void idl_set_insert_complement_idl(IDListSet *idl_set, IDList *idl); +int64_t idl_set_union_shortcut(IDListSet *idl_set); +int64_t idl_set_intersection_shortcut(IDListSet *idl_set); +IDList * idl_set_union(IDListSet *idl_set, backend *be); +IDList * idl_set_intersect(IDListSet *idl_set, backend *be); + /* * index.c */
0
9ffcb159076e61532bebf485a427e03a03246091
389ds/389-ds-base
Ticket 48360 - Refactor the delete agreement function Description: The delete agreement function of agreement.py module doesn't cover all usage varieties and should be rewritten. Now it requires suffix and replica(DirSrv object of the server that the agreement points to). By some reasons, this replica object may be missing, then we couldn't delete the agreement. We don't have test coverage for that function. It should be added to tests/agreement_test.py. Also test_changes fails, fix is required. Fix description: Change arguments of the delete agreement function to: - suffix - consumer_host - of the server that the agreement points to - consumer_port - of the server that the agreement points to or - agmtdn - DN of the replica agreement With that, we can clearly define the required agreement. Add the delete test to tests/agreement_test.py Also fix the changes test by adding time.sleep(2) before change number checking, because there was not enough time for updating change number on master. https://fedorahosted.org/389/ticket/48360 Reviewed by: wibrown (Thanks!)
commit 9ffcb159076e61532bebf485a427e03a03246091 Author: Simon Pichugin <[email protected]> Date: Thu Nov 26 16:55:52 2015 +0100 Ticket 48360 - Refactor the delete agreement function Description: The delete agreement function of agreement.py module doesn't cover all usage varieties and should be rewritten. Now it requires suffix and replica(DirSrv object of the server that the agreement points to). By some reasons, this replica object may be missing, then we couldn't delete the agreement. We don't have test coverage for that function. It should be added to tests/agreement_test.py. Also test_changes fails, fix is required. Fix description: Change arguments of the delete agreement function to: - suffix - consumer_host - of the server that the agreement points to - consumer_port - of the server that the agreement points to or - agmtdn - DN of the replica agreement With that, we can clearly define the required agreement. Add the delete test to tests/agreement_test.py Also fix the changes test by adding time.sleep(2) before change number checking, because there was not enough time for updating change number on master. https://fedorahosted.org/389/ticket/48360 Reviewed by: wibrown (Thanks!) diff --git a/src/lib389/lib389/agreement.py b/src/lib389/lib389/agreement.py index 700f591a0..108f7d4a7 100644 --- a/src/lib389/lib389/agreement.py +++ b/src/lib389/lib389/agreement.py @@ -546,40 +546,42 @@ class Agreement(object): return dn_agreement - def delete(self, suffix, replica): - ''' - Delete a replication agreement + def delete(self, suffix=None, consumer_host=None, consumer_port=None, + agmtdn=None): + """Delete a replication agreement @param suffix - the suffix that the agreement is configured for - @replica - DirSrv object of the server that the agreement points to + @param consumer_host - of the server that the agreement points to + @param consumer_port - of the server that the agreement points to + @param agmtdn - DN of the replica agreement + @raise ldap.LDAPError - for ldap operation failures - ''' + @raise TypeError - if too many agreements were found + @raise NoSuchEntryError - if no agreements were found + """ - if replica.sslport: - # We assume that if you are using SSL, you are using it with - # replication - port = replica.sslport - else: - port = replica.port + if not (suffix and consumer_host and consumer_port) and not agmtdn: + raise InvalidArgumentError("Suffix with consumer_host and consumer_port" + + " or agmtdn are required") + + agmts = self.list(suffix, consumer_host, consumer_port, agmtdn) - agmts = self.list(suffix=suffix, consumer_host=replica.host, - consumer_port=port) if agmts: if len(agmts) > 1: - # Found too many agreements - self.log.error('Too many agreements found') - raise + raise TypeError('Too many agreements were found') else: - # delete the agreement + # Delete the agreement try: - self.conn.delete_s(agmts[0].dn) + agmt_dn = agmts[0].dn + self.conn.delete_s(agmt_dn) + self.log.info('Agreement (%s) was successfully removed' % + agmt_dn) except ldap.LDAPError as e: self.log.error('Failed to delete agreement (%s), ' + - 'error: %s' % (agmts[0].dn, str(e))) + 'error: %s' % (agmt_dn, str(e))) raise else: - # No agreements, error? - self.log.error('No agreements found') + raise NoSuchEntryError('No agreements were found') def init(self, suffix=None, consumer_host=None, consumer_port=None): """Trigger a total update of the consumer replica diff --git a/src/lib389/tests/agreement_test.py b/src/lib389/tests/agreement_test.py index 5b0af1229..2390ea9f6 100644 --- a/src/lib389/tests/agreement_test.py +++ b/src/lib389/tests/agreement_test.py @@ -29,6 +29,7 @@ SERVERID_CONSUMER = 'consumer' SUFFIX = DEFAULT_SUFFIX ENTRY_DN = "cn=test_entry, %s" % SUFFIX +SECOND_AGMT_TEST_PORT = 12345 class TopologyReplication(object): @@ -152,14 +153,15 @@ def test_list(topology): str(topology.consumer.port) # Create a second RA to check .list returns 2 RA - properties = {RA_NAME: r'meTo_%s:%d' % (topology.consumer.host, 12345), + properties = {RA_NAME: r'meTo_%s:%d' % (topology.consumer.host, + SECOND_AGMT_TEST_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]} topology.master.agreement.create(suffix=SUFFIX, host=topology.consumer.host, - port=12345, + port=SECOND_AGMT_TEST_PORT, properties=properties) ents = topology.master.agreement.list(suffix=SUFFIX) assert len(ents) == 2 @@ -175,6 +177,39 @@ def test_list(topology): str(topology.consumer.port) +def test_delete(topology): + """Delete previously created the replica agreement + + PREREQUISITE: it exists a replica for SUFFIX and a replica agreement + with a SECOND_AGMT_TEST_PORT specified + """ + + # TODO: add a few test cases for different sets of arguments + # using fixtures and parameters. + topology.master.log.info("\n\n##############\n### DELETE\n##############\n") + ents = topology.master.agreement.list(suffix=SUFFIX, + consumer_host=topology.consumer.host, + consumer_port=SECOND_AGMT_TEST_PORT) + assert len(ents) == 1 + + # Find DN of the second agreement + replica_entries = topology.master.replica.list(SUFFIX) + replica = replica_entries[0] + agreement_cn = r'meTo_%s:%d' % (topology.consumer.host, + SECOND_AGMT_TEST_PORT) + agreement_dn = ','.join(["cn=%s" % agreement_cn, replica.dn]) + + topology.master.agreement.delete(suffix=SUFFIX, + consumer_host=topology.consumer.host, + consumer_port=SECOND_AGMT_TEST_PORT, + agmtdn=agreement_dn) + + ents = topology.master.agreement.list(suffix=SUFFIX, + consumer_host=topology.consumer.host, + consumer_port=SECOND_AGMT_TEST_PORT) + assert not ents + + def test_status(topology): """Test that status is returned from agreement""" @@ -311,6 +346,9 @@ def test_changes(topology): loop += 1 assert loop <= 10 + # Give a little time to update a change number on master + time.sleep(2) + # Check change number newvalue = topology.master.agreement.changes(agmnt_dn=ents[0].dn) topology.master.log.info("\ntest_changes: %d changes\n" % newvalue)
0
b2f76abe10bfbe621308410a1e7f41287cf2ff9e
389ds/389-ds-base
Issue 49188 - retrocl can crash server at shutdown Description: We do not calloc enough elements when processing nsslapd-attribute from the retrocl plugin configuration. This causes invalid memory to be freed at shutdown(via slapi_ch_array_free). https://pagure.io/389-ds-base/issue/49188 Reviewed by: mreynolds(one line commit rule)
commit b2f76abe10bfbe621308410a1e7f41287cf2ff9e Author: Mark Reynolds <[email protected]> Date: Wed Mar 22 10:18:13 2017 -0400 Issue 49188 - retrocl can crash server at shutdown Description: We do not calloc enough elements when processing nsslapd-attribute from the retrocl plugin configuration. This causes invalid memory to be freed at shutdown(via slapi_ch_array_free). https://pagure.io/389-ds-base/issue/49188 Reviewed by: mreynolds(one line commit rule) diff --git a/ldap/servers/plugins/retrocl/retrocl.c b/ldap/servers/plugins/retrocl/retrocl.c index 32b30c794..6e686675b 100644 --- a/ldap/servers/plugins/retrocl/retrocl.c +++ b/ldap/servers/plugins/retrocl/retrocl.c @@ -470,8 +470,8 @@ static int retrocl_start (Slapi_PBlock *pb) retrocl_nattributes = n; - retrocl_attributes = (char **)slapi_ch_calloc(n, sizeof(char *)); - retrocl_aliases = (char **)slapi_ch_calloc(n, sizeof(char *)); + retrocl_attributes = (char **)slapi_ch_calloc(n + 1, sizeof(char *)); + retrocl_aliases = (char **)slapi_ch_calloc(n + 1, sizeof(char *)); slapi_log_err(SLAPI_LOG_PLUGIN, RETROCL_PLUGIN_NAME, "retrocl_start - Attributes:\n");
0
2e279879e43b9addc06c790bc74b07e9a6263967
389ds/389-ds-base
Add Wix dependency.
commit 2e279879e43b9addc06c790bc74b07e9a6263967 Author: Thomas Lackey <[email protected]> Date: Fri May 13 19:35:07 2005 +0000 Add Wix dependency. diff --git a/Makefile b/Makefile index 828c61696..ff5287db8 100644 --- a/Makefile +++ b/Makefile @@ -135,9 +135,11 @@ ifeq ($(INTERNAL_BUILD), 1) $(AXIS_DEP) $(DSMLJAR_DEP) $(DSDOC_DEP) endif +# Pull WiX MSI toolkit on Windows. +ifeq ($(ARCH), WINNT) +COMPONENT_DEPENDENCIES += $(WIX_DEP) ## Only fetch the necessary components for ApacheDS when requested ifeq ($(BUILD_NTDS),1) -ifeq ($(ARCH), WINNT) COMPONENT_DEPENDENCIES += $(WRAPPER_DEP) $(SWIG_DEP) $(MAVEN_DEP) $(APACHEDS_DEP) endif endif
0
1de8c2f9f008e37634ddd6adde83e95b6a657144
389ds/389-ds-base
need to set correct replica type Reviewed by: tbordaz (Thanks!)
commit 1de8c2f9f008e37634ddd6adde83e95b6a657144 Author: Rich Megginson <[email protected]> Date: Wed Nov 20 19:19:09 2013 -0700 need to set correct replica type Reviewed by: tbordaz (Thanks!) diff --git a/src/lib389/lib389/brooker.py b/src/lib389/lib389/brooker.py index a51a92bdc..e067fba07 100644 --- a/src/lib389/lib389/brooker.py +++ b/src/lib389/lib389/brooker.py @@ -656,6 +656,10 @@ class Replica(object): TODO: this method does not update replica type """ # set default values + if rtype == MASTER_TYPE: + rtype = REPLICA_RDWR_TYPE + else: + rtype = REPLICA_RDONLY_TYPE if legacy: legacy = 'on'
0
3f4f52a72e39a4a24fe8f24199842d0314071000
389ds/389-ds-base
Issue 50680 - Remove branding from upstream spec file Bug Description: Branding logic is triggered in EPEL builds. We should not have it in upstream as it should be applied in the downstream only. Fix Description: Remove branding. Fixes: https://pagure.io/389-ds-base/issue/50680 Reviewed by: mreynolds (Thanks!)
commit 3f4f52a72e39a4a24fe8f24199842d0314071000 Author: Viktor Ashirov <[email protected]> Date: Thu Oct 31 14:45:37 2019 +0100 Issue 50680 - Remove branding from upstream spec file Bug Description: Branding logic is triggered in EPEL builds. We should not have it in upstream as it should be applied in the downstream only. Fix Description: Remove branding. Fixes: https://pagure.io/389-ds-base/issue/50680 Reviewed by: mreynolds (Thanks!) diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index 48ef43d47..22ed298de 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -409,12 +409,6 @@ mkdir -p %{buildroot}%{_datadir}/gdb/auto-load%{_sbindir} mkdir -p %{buildroot}%{_datadir}/cockpit make DESTDIR="$RPM_BUILD_ROOT" install -# Cockpit branding, and directory and file list -%if 0%{?rhel} -sed -i "s/389 Directory Server/Red Hat Directory Server/" %{buildroot}%{_datadir}/cockpit/389-console/banner.html -sed -i "s/389 Directory Server/Red Hat Directory Server/" %{buildroot}%{_datadir}/cockpit/389-console/manifest.json -sed -i "s/389 Directory Server/Red Hat Directory Server/" %{buildroot}%{_datadir}/metainfo/389-console/org.port389.cockpit_console.metainfo.xml -%endif find %{buildroot}%{_datadir}/cockpit/389-console -type d | sed -e "s@%{buildroot}@@" | sed -e 's/^/\%dir /' > cockpit.list find %{buildroot}%{_datadir}/cockpit/389-console -type f | sed -e "s@%{buildroot}@@" >> cockpit.list
0
fd8ac10e935bca1f72bfe0f5735fe8f5c2572229
389ds/389-ds-base
Bug 617630 - fix coverify Defect Type: Resource leaks issues CID 12052 - 12093 https://bugzilla.redhat.com/show_bug.cgi?id=617630 Resolves: bug 617630 Bug description: fix coverify Defect Type: Resource leaks issues CID 12064, 12065. description: string_assertion2keys_sub() has been modified to release resources before returning.
commit fd8ac10e935bca1f72bfe0f5735fe8f5c2572229 Author: Endi S. Dewata <[email protected]> Date: Sat Jul 24 01:15:17 2010 -0500 Bug 617630 - fix coverify Defect Type: Resource leaks issues CID 12052 - 12093 https://bugzilla.redhat.com/show_bug.cgi?id=617630 Resolves: bug 617630 Bug description: fix coverify Defect Type: Resource leaks issues CID 12064, 12065. description: string_assertion2keys_sub() has been modified to release resources before returning. diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c index 18e7a0514..d70ca5b67 100644 --- a/ldap/servers/plugins/syntaxes/string.c +++ b/ldap/servers/plugins/syntaxes/string.c @@ -688,11 +688,15 @@ string_assertion2keys_sub( int localsublens[3] = {SUBBEGIN, SUBMIDDLE, SUBEND};/* default values */ int maxsublen; char *comp_buf = NULL; + /* altinit|any|final: store alt string from value_normalize_ext if any, + * otherwise the original string. And use for the real job */ char *altinit = NULL; - char *oaltinit = NULL; char **altany = NULL; - char **oaltany = NULL; char *altfinal = NULL; + /* oaltinit|any|final: prepared to free altinit|any|final if allocated in + * value_normalize_ext */ + char *oaltinit = NULL; + char **oaltany = NULL; char *oaltfinal = NULL; int anysize = 0; @@ -776,7 +780,7 @@ string_assertion2keys_sub( } } if ( nsubs == 0 ) { /* no keys to return */ - return( 0 ); + goto done; } /* @@ -795,7 +799,6 @@ string_assertion2keys_sub( substring_comp_keys( ivals, &nsubs, altinit, initiallen, '^', syntax, comp_buf, substrlens ); } - slapi_ch_free_string(&oaltinit); for ( i = 0; altany != NULL && altany[i] != NULL; i++ ) { len = strlen( altany[i] ); if ( len < substrlens[INDEX_SUBSTRMIDDLE] ) { @@ -803,18 +806,22 @@ string_assertion2keys_sub( } substring_comp_keys( ivals, &nsubs, altany[i], len, 0, syntax, comp_buf, substrlens ); - slapi_ch_free_string(&oaltany[i]); } - slapi_ch_free((void **)&oaltany); - slapi_ch_free((void **)&altany); if ( altfinal != NULL ) { substring_comp_keys( ivals, &nsubs, altfinal, finallen, '$', syntax, comp_buf, substrlens ); } - slapi_ch_free_string(&oaltfinal); (*ivals)[nsubs] = NULL; - slapi_ch_free_string(&comp_buf); +done: + slapi_ch_free_string(&oaltinit); + for ( i = 0; altany != NULL && altany[i] != NULL; i++ ) { + slapi_ch_free_string(&oaltany[i]); + } + slapi_ch_free((void **)&oaltany); + slapi_ch_free_string(&oaltfinal); + slapi_ch_free((void **)&altany); + slapi_ch_free_string(&comp_buf); return( 0 ); }
0
054d32e7b697513124a37dade54828ec52397c1c
389ds/389-ds-base
Issue 50431 - Fix regression from coverity fix Description: Fix a regression from the initial coverity commit where we did not allow NULL pointers to set into the pblock. They were false positives reported by covscan. https://pagure.io/389-ds-base/issue/50431 Reviewed by: mreynolds (one line commit rule)
commit 054d32e7b697513124a37dade54828ec52397c1c Author: Mark Reynolds <[email protected]> Date: Thu Jun 13 17:55:25 2019 -0400 Issue 50431 - Fix regression from coverity fix Description: Fix a regression from the initial coverity commit where we did not allow NULL pointers to set into the pblock. They were false positives reported by covscan. https://pagure.io/389-ds-base/issue/50431 Reviewed by: mreynolds (one line commit rule) diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c index 5dd46a064..8a34ac5eb 100644 --- a/ldap/servers/plugins/acl/acleffectiverights.c +++ b/ldap/servers/plugins/acl/acleffectiverights.c @@ -1030,9 +1030,7 @@ bailout: * slapi_pblock_set() will free any previous data, and * pblock_done() will free SLAPI_PB_RESULT_TEXT. */ - if (gerstr) { - slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, gerstr); - } + slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, gerstr); if (!iscritical) { /* diff --git a/ldap/servers/plugins/views/views.c b/ldap/servers/plugins/views/views.c index 5d8464761..64e305a3f 100644 --- a/ldap/servers/plugins/views/views.c +++ b/ldap/servers/plugins/views/views.c @@ -1760,9 +1760,7 @@ view_search_rewrite_callback(Slapi_PBlock *pb) #endif /* make it happen */ - if (outFilter) { - slapi_pblock_set(pb, SLAPI_SEARCH_FILTER, outFilter); - } + slapi_pblock_set(pb, SLAPI_SEARCH_FILTER, outFilter); ret = -2; diff --git a/ldap/servers/slapd/back-ldbm/vlv_srch.c b/ldap/servers/slapd/back-ldbm/vlv_srch.c index 1ac3e009e..65b876647 100644 --- a/ldap/servers/slapd/back-ldbm/vlv_srch.c +++ b/ldap/servers/slapd/back-ldbm/vlv_srch.c @@ -168,8 +168,9 @@ vlvSearch_init(struct vlvSearch *p, Slapi_PBlock *pb, const Slapi_Entry *e, ldbm /* switch context back to the DSE backend */ slapi_pblock_set(pb, SLAPI_BACKEND, oldbe); - if (oldbe) + if (oldbe) { slapi_pblock_set(pb, SLAPI_PLUGIN, oldbe->be_database); + } } /* make (&(parentid=idofbase)(|(originalfilter)(objectclass=referral))) */ diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c index 125684329..8f2a14c9a 100644 --- a/ldap/servers/slapd/dse.c +++ b/ldap/servers/slapd/dse.c @@ -2530,8 +2530,7 @@ dse_delete(Slapi_PBlock *pb) /* JCM There should only be one exit point from thi dse_call_callback(pdse, pb, SLAPI_OPERATION_DELETE, DSE_FLAG_POSTOP, ec, NULL, &returncode, returntext); done: slapi_pblock_get(pb, SLAPI_DELETE_BEPOSTOP_ENTRY, &orig_entry); - if (ec) - slapi_pblock_set(pb, SLAPI_DELETE_BEPOSTOP_ENTRY, ec); + slapi_pblock_set(pb, SLAPI_DELETE_BEPOSTOP_ENTRY, ec); /* make sure OPRETURN and RESULT_CODE are set */ slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &rc); if (returncode || rc) { @@ -2572,8 +2571,7 @@ done: rc = LDAP_UNWILLING_TO_PERFORM; } } - if (orig_entry) - slapi_pblock_set(pb, SLAPI_DELETE_BEPOSTOP_ENTRY, orig_entry); + slapi_pblock_set(pb, SLAPI_DELETE_BEPOSTOP_ENTRY, orig_entry); slapi_send_ldap_result(pb, returncode, NULL, returntext, 0, NULL); return dse_delete_return(returncode, ec); } diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c index dac42eb13..dd6917363 100644 --- a/ldap/servers/slapd/opshared.c +++ b/ldap/servers/slapd/opshared.c @@ -998,8 +998,7 @@ free_and_return_nolock: slapi_sdn_free(&sdn); } slapi_sdn_free(&basesdn); - if (orig_sdn) - slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, orig_sdn); + slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, orig_sdn); slapi_ch_free_string(&proxydn); slapi_ch_free_string(&proxystr); diff --git a/ldap/servers/slapd/plugin_internal_op.c b/ldap/servers/slapd/plugin_internal_op.c index 622daffdb..9da266b61 100644 --- a/ldap/servers/slapd/plugin_internal_op.c +++ b/ldap/servers/slapd/plugin_internal_op.c @@ -368,8 +368,7 @@ seq_internal_callback_pb(Slapi_PBlock *pb, void *callback_data, plugin_result_ca slapi_pblock_set(pb, SLAPI_BACKEND, be); slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database); slapi_pblock_set(pb, SLAPI_SEQ_ATTRNAME, attrname); - if (val) - slapi_pblock_set(pb, SLAPI_SEQ_VAL, val); + slapi_pblock_set(pb, SLAPI_SEQ_VAL, val); slapi_pblock_set(pb, SLAPI_REQCONTROLS, controls); /* set actions taken to process the operation */ diff --git a/ldap/servers/slapd/plugin_syntax.c b/ldap/servers/slapd/plugin_syntax.c index dc7106da5..e208442d5 100644 --- a/ldap/servers/slapd/plugin_syntax.c +++ b/ldap/servers/slapd/plugin_syntax.c @@ -247,9 +247,7 @@ plugin_call_syntax_filter_sub_sv( Operation *op = NULL; /* to pass SLAPI_SEARCH_TIMELIMIT & SLAPI_OPINITATED_TIME */ slapi_pblock_get(pb, SLAPI_OPERATION, &op); - if (op) { - slapi_pblock_set(pipb, SLAPI_OPERATION, op); - } + slapi_pblock_set(pipb, SLAPI_OPERATION, op); } rc = (*sub_fn)(pipb, fsub->sf_initial, fsub->sf_any, fsub->sf_final, va); } else {
0
a04eb1f138312cec2e9a014b6bf3e39728edc7d8
389ds/389-ds-base
170558 - Add certutil, pk12util and missing dlls to PassSync.msi
commit a04eb1f138312cec2e9a014b6bf3e39728edc7d8 Author: Nathan Kinder <[email protected]> Date: Wed Oct 12 23:26:52 2005 +0000 170558 - Add certutil, pk12util and missing dlls to PassSync.msi diff --git a/ldap/synctools/passwordsync/build.bat b/ldap/synctools/passwordsync/build.bat index 68ca9d189..d569375e1 100644 --- a/ldap/synctools/passwordsync/build.bat +++ b/ldap/synctools/passwordsync/build.bat @@ -108,6 +108,15 @@ if EXIST ..\%LIBROOT%\nss\lib\ssl3.dll ( if EXIST ..\%LIBROOT%\nss\lib\softokn3.dll ( copy /Y ..\%LIBROOT%\nss\lib\softokn3.dll %OBJDEST%\ ) +if EXIST ..\%LIBROOT%\nss\lib\smime3.dll ( + copy /Y ..\%LIBROOT%\nss\lib\smime3.dll %OBJDEST%\ +) +if EXIST ..\%LIBROOT%\nss\bin\certutil.exe ( + copy /Y ..\%LIBROOT%\nss\bin\certutil.exe %OBJDEST%\ +) +if EXIST ..\%LIBROOT%\nss\bin\pk12util.exe ( + copy /Y ..\%LIBROOT%\nss\bin\pk12util.exe %OBJDEST%\ +) xcopy /E /Y /I %WXSDIR%\Binary %OBJDEST%\Binary
0
a733cd11e91d956242452ba4dd1d37406bec4aa4
389ds/389-ds-base
Bug 630096 - (cov#15446) check return value of ber_scanf() We were not checking the return value of ber_scanf in the DNA plug-in when parsing the range transfer response. This checks the return value and sets the return code to LDAP_PROTOCOL_ERROR if we were unable to parse the range transfer response.
commit a733cd11e91d956242452ba4dd1d37406bec4aa4 Author: Nathan Kinder <[email protected]> Date: Fri Sep 3 14:04:16 2010 -0700 Bug 630096 - (cov#15446) check return value of ber_scanf() We were not checking the return value of ber_scanf in the DNA plug-in when parsing the range transfer response. This checks the return value and sets the return code to LDAP_PROTOCOL_ERROR if we were unable to parse the range transfer response. diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c index 558e61382..837b674c1 100644 --- a/ldap/servers/plugins/dna/dna.c +++ b/ldap/servers/plugins/dna/dna.c @@ -1604,7 +1604,10 @@ static int dna_request_range(struct configEntry *config_entry, /* Parse response */ if (responsedata) { respber = ber_init(responsedata); - ber_scanf(respber, "{aa}", &lower_str, &upper_str); + if (ber_scanf(respber, "{aa}", &lower_str, &upper_str) == LBER_ERROR) { + ret = LDAP_PROTOCOL_ERROR; + goto bail; + } } /* Fill in upper and lower */
0
91dc832411a1bb6e8bf62bb72c36777ddc63770f
389ds/389-ds-base
Ticket 49665 - Upgrade script doesn't enable CRYPT password storage plug-in Description: There is no upgrade script to add the new CRYPT plugins, this fix adds the script. https://pagure.io/389-ds-base/issue/49665 Reviewed by: vashirov(Thanks!)
commit 91dc832411a1bb6e8bf62bb72c36777ddc63770f Author: Mark Reynolds <[email protected]> Date: Wed May 9 16:39:23 2018 -0400 Ticket 49665 - Upgrade script doesn't enable CRYPT password storage plug-in Description: There is no upgrade script to add the new CRYPT plugins, this fix adds the script. https://pagure.io/389-ds-base/issue/49665 Reviewed by: vashirov(Thanks!) diff --git a/Makefile.am b/Makefile.am index dfe8e0a22..dc80beffa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1070,6 +1070,7 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \ ldap/admin/src/scripts/50retroclprecedence.ldif \ ldap/admin/src/scripts/50rootdnaccesscontrolplugin.ldif \ ldap/admin/src/scripts/50pbkdf2pwdstorageplugin.ldif \ + ldap/admin/src/scripts/50cryptpwdstorageplugin.ldif \ ldap/admin/src/scripts/50contentsync.ldif \ ldap/admin/src/scripts/60upgradeschemafiles.pl \ ldap/admin/src/scripts/60upgradeconfigfiles.pl \ diff --git a/ldap/admin/src/scripts/50cryptpwdstorageplugin.ldif b/ldap/admin/src/scripts/50cryptpwdstorageplugin.ldif new file mode 100644 index 000000000..0a4a50776 --- /dev/null +++ b/ldap/admin/src/scripts/50cryptpwdstorageplugin.ldif @@ -0,0 +1,38 @@ +dn: cn=CRYPT-MD5,cn=Password Storage Schemes,cn=plugins,cn=config +objectClass: top +objectClass: nsSlapdPlugin +cn: CRYPT-MD5 +nsslapd-pluginPath: libpwdstorage-plugin +nsslapd-pluginInitfunc: crypt_md5_pwd_storage_scheme_init +nsslapd-pluginType: pwdstoragescheme +nsslapd-pluginEnabled: on +nsslapd-pluginId: ID +nsslapd-pluginVersion: PACKAGE_VERSION +nsslapd-pluginVendor: VENDOR +nsslapd-pluginDescription: DESC + +dn: cn=CRYPT-SHA256,cn=Password Storage Schemes,cn=plugins,cn=config +objectClass: top +objectClass: nsSlapdPlugin +cn: CRYPT-SHA256 +nsslapd-pluginPath: libpwdstorage-plugin +nsslapd-pluginInitfunc: crypt_sha256_pwd_storage_scheme_init +nsslapd-pluginType: pwdstoragescheme +nsslapd-pluginEnabled: on +nsslapd-pluginId: ID +nsslapd-pluginVersion: PACKAGE_VERSION +nsslapd-pluginVendor: VENDOR +nsslapd-pluginDescription: DESC + +dn: cn=CRYPT-SHA512,cn=Password Storage Schemes,cn=plugins,cn=config +objectClass: top +objectClass: nsSlapdPlugin +cn: CRYPT-SHA512 +nsslapd-pluginPath: libpwdstorage-plugin +nsslapd-pluginInitfunc: crypt_sha512_pwd_storage_scheme_init +nsslapd-pluginType: pwdstoragescheme +nsslapd-pluginEnabled: on +nsslapd-pluginId: ID +nsslapd-pluginVersion: PACKAGE_VERSION +nsslapd-pluginVendor: VENDOR +nsslapd-pluginDescription: DESC
0
2801442cd00f11716038fd3ffcecc35f89f29837
389ds/389-ds-base
Bug 658309 - Process escaped characters in managed entry mappings The managed entry mappings are designed to allow one to use a $ character in the mapped value by escaping it with the "$$" sequence. The escape itself was ending up in the mapped value. This patch removes the escape characters when creating the mapped value.
commit 2801442cd00f11716038fd3ffcecc35f89f29837 Author: Nathan Kinder <[email protected]> Date: Thu Dec 2 10:24:51 2010 -0800 Bug 658309 - Process escaped characters in managed entry mappings The managed entry mappings are designed to allow one to use a $ character in the mapped value by escaping it with the "$$" sequence. The escape itself was ending up in the mapped value. This patch removes the escape characters when creating the mapped value. diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c index 943633212..16c2e4126 100644 --- a/ldap/servers/plugins/mep/mep.c +++ b/ldap/servers/plugins/mep/mep.c @@ -1308,7 +1308,9 @@ mep_parse_mapped_attr(char *mapping, Slapi_Entry *origin, } pre_str = p; - end = p + strlen(p); + + /* Make end point to the last character that we want in the value. */ + end = p + strlen(p) - 1; /* Find the variable that we need to substitute. */ for (; p <= end; p++) { @@ -1322,8 +1324,12 @@ mep_parse_mapped_attr(char *mapping, Slapi_Entry *origin, } if (*(p + 1) == '$') { - /* This is an escaped $, so just skip it. */ + /* This is an escaped $. Eliminate the escape character + * to prevent if from being a part of the value. */ p++; + memmove(p, p+1, end-(p+1)+1); + *end = '\0'; + end--; } else { int quoted = 0; @@ -1372,15 +1378,27 @@ mep_parse_mapped_attr(char *mapping, Slapi_Entry *origin, break; } - /* Set the map type. */ - map_type = strndup(var_start, p - var_start); - - /* If we're at the end of the string, we - * don't have a post string. Just set - * it to an empty string. */ if (p == end) { - post_str = ""; + /* Set the map type. In this case, p could be + * pointing at either the last character of the + * map type, or at the first character after the + * map type. If the character is valid for use + * in an attribute description, we consider it + * to be a part of the map type. */ + if (IS_ATTRDESC_CHAR(*p)) { + map_type = strndup(var_start, p - var_start + 1); + /* There is no post string, so + * set it to be empty. */ + post_str = ""; + } else { + map_type = strndup(var_start, p - var_start); + post_str = p; + } } else { + /* Set the map type. In this case, p is pointing + * at the first character after the map type. */ + map_type = strndup(var_start, p - var_start); + /* If the variable is quoted, don't include * the closing brace in the post string. */ if (quoted) { @@ -1390,6 +1408,25 @@ mep_parse_mapped_attr(char *mapping, Slapi_Entry *origin, } } + /* Process the post string to remove any escapes. */ + for (p = post_str; p <= end; p++) { + if (*p == '$') { + if ((p == end) || (*(p+1) != '$')) { + slapi_log_error( SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM, + "mep_parse_mapped_attr: Invalid mapped " + "attribute value for type \"%s\".\n", mapping); + ret = 1; + goto bail; + } else { + /* This is an escaped '$'. Remove the escape char. */ + p++; + memmove(p, p+1, end-(p+1)+1); + *end = '\0'; + end--; + } + } + } + /* We only support a single variable, so we're done. */ break; }
0
7daee18462b9234d8d9c6589330cfad199e2b3c5
389ds/389-ds-base
Issue 6468 - Fix building for older versions of Python Bug Description: Structural Pattern Matching has been added in Python 3.10, older version do not support it. Fix Description: Replace `match` and `case` statements with `if-elif`. Relates: https://github.com/389ds/389-ds-base/issues/6468 Reviewed by: @droideck (Thanks!)
commit 7daee18462b9234d8d9c6589330cfad199e2b3c5 Author: Viktor Ashirov <[email protected]> Date: Tue Jan 28 21:05:49 2025 +0100 Issue 6468 - Fix building for older versions of Python Bug Description: Structural Pattern Matching has been added in Python 3.10, older version do not support it. Fix Description: Replace `match` and `case` statements with `if-elif`. Relates: https://github.com/389ds/389-ds-base/issues/6468 Reviewed by: @droideck (Thanks!) diff --git a/src/lib389/lib389/cli_conf/logging.py b/src/lib389/lib389/cli_conf/logging.py index efa034f93..8b6d02af0 100644 --- a/src/lib389/lib389/cli_conf/logging.py +++ b/src/lib389/lib389/cli_conf/logging.py @@ -236,19 +236,20 @@ def get_log_config(inst, basedn, log, args): attr_map = {} levels = {} - match args.logtype: - case "access": - attr_map = ACCESS_ATTR_MAP - levels = ACCESS_LEVELS - case "error": - attr_map = ERROR_ATTR_MAP - levels = ERROR_LEVELS - case "security": - attr_map = SECURITY_ATTR_MAP - case "audit": - attr_map = AUDIT_ATTR_MAP - case "auditfail": - attr_map = AUDITFAIL_ATTR_MAP + if args.logtype == "access": + attr_map = ACCESS_ATTR_MAP + levels = ACCESS_LEVELS + elif args.logtype == "error": + attr_map = ERROR_ATTR_MAP + levels = ERROR_LEVELS + elif args.logtype == "security": + attr_map = SECURITY_ATTR_MAP + elif args.logtype == "audit": + attr_map = AUDIT_ATTR_MAP + elif args.logtype == "auditfail": + attr_map = AUDITFAIL_ATTR_MAP + else: + raise ValueError(f"Unknown logtype: {args.logtype}") sorted_results = [] for attr, value in attrs.items():
0
66e89b66fdde6a67cf4f0b93475142778437cc9d
389ds/389-ds-base
Issue 5714 - UI - fix typo, db settings, log settings, and LDAP editor paginations Description: - DB settings "Look Through Limit" was misspelled, and the "+" increment button was not working - Configuring logs would not correctly enable/disable the save button - LDAP Browser - Pagination was not working correctly when you search for attributes/objectclasses. We were also missing some "search" inputs for attributes in some of the forms. relates: https://github.com/389ds/389-ds-base/issues/5714 Reviewed by: spichugi(Thanks!)
commit 66e89b66fdde6a67cf4f0b93475142778437cc9d Author: Mark Reynolds <[email protected]> Date: Thu Mar 30 10:49:45 2023 -0400 Issue 5714 - UI - fix typo, db settings, log settings, and LDAP editor paginations Description: - DB settings "Look Through Limit" was misspelled, and the "+" increment button was not working - Configuring logs would not correctly enable/disable the save button - LDAP Browser - Pagination was not working correctly when you search for attributes/objectclasses. We were also missing some "search" inputs for attributes in some of the forms. relates: https://github.com/389ds/389-ds-base/issues/5714 Reviewed by: spichugi(Thanks!) diff --git a/src/cockpit/389-console/src/lib/database/databaseConfig.jsx b/src/cockpit/389-console/src/lib/database/databaseConfig.jsx index 92f260c32..1b7a3c1d2 100644 --- a/src/cockpit/389-console/src/lib/database/databaseConfig.jsx +++ b/src/cockpit/389-console/src/lib/database/databaseConfig.jsx @@ -601,7 +601,7 @@ export class GlobalDatabaseConfig extends React.Component { </TextContent> <div className="ds-margin-top-lg"> - <Tabs activeKey={this.state.activeTabKey} onSelect={this.handleNavSelect}> + <Tabs isFilled activeKey={this.state.activeTabKey} onSelect={this.handleNavSelect}> <Tab eventKey={0} title={<TabTitleText>Limits</TabTitleText>}> <div className="ds-left-indent-md"> <Grid @@ -609,13 +609,13 @@ export class GlobalDatabaseConfig extends React.Component { className="ds-margin-top-xlg" > <GridItem className="ds-label" span={4}> - Database Look Though Limit + Database Look Through Limit </GridItem> <GridItem span={8}> <NumberInput value={this.state.looklimit} min={-1} - max={0} + max={this.maxValue} onMinus={() => { this.onMinusConfig("looklimit") }} onChange={(e) => { this.onConfigChange(e, "looklimit", -1, 0) }} onPlus={() => { this.onPlusConfig("looklimit") }} diff --git a/src/cockpit/389-console/src/lib/database/globalPwp.jsx b/src/cockpit/389-console/src/lib/database/globalPwp.jsx index 6b76c51a6..8814d919f 100644 --- a/src/cockpit/389-console/src/lib/database/globalPwp.jsx +++ b/src/cockpit/389-console/src/lib/database/globalPwp.jsx @@ -1238,7 +1238,7 @@ export class GlobalPwPolicy extends React.Component { } else { pwp_element = <div className={this.state.loading ? 'ds-fadeout ds-margin-bottom-md' : 'ds-fadein ds-left-margin ds-margin-bottom-md'}> - <Tabs className="ds-margin-top-lg" activeKey={this.state.activeTabKey} onSelect={this.handleNavSelect}> + <Tabs isFilled className="ds-margin-top-lg" activeKey={this.state.activeTabKey} onSelect={this.handleNavSelect}> <Tab eventKey={0} title={<TabTitleText>General Settings</TabTitleText>}> <Form className="ds-margin-left-sm" isHorizontal autoComplete="off"> <Grid className="ds-margin-top-xlg" title="Allow subtree/user defined local password policies (nsslapd-pwpolicy-local)."> diff --git a/src/cockpit/389-console/src/lib/database/suffix.jsx b/src/cockpit/389-console/src/lib/database/suffix.jsx index f88a7ab51..2a8ccbe2b 100644 --- a/src/cockpit/389-console/src/lib/database/suffix.jsx +++ b/src/cockpit/389-console/src/lib/database/suffix.jsx @@ -904,7 +904,7 @@ export class Suffix extends React.Component { </Grid> <div className="ds-sub-header"> - <Tabs activeKey={activeTabKey} onSelect={this.handleNavSelect}> + <Tabs isFilled activeKey={activeTabKey} onSelect={this.handleNavSelect}> <Tab eventKey={0} title={<TabTitleText>Settings</TabTitleText>}> <SuffixConfig cachememsize={this.state.cachememsize} diff --git a/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addCosTemplate.jsx b/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addCosTemplate.jsx index be4172139..34aee5578 100644 --- a/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addCosTemplate.jsx +++ b/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addCosTemplate.jsx @@ -95,6 +95,7 @@ class AddCosTemplate extends React.Component { ], rowsOc: [], rowsAttr: [], + rowsAttrOrig: [], rowsValues: [], pagedRowsOc: [], pagedRowsAttr: [], @@ -105,7 +106,9 @@ class AddCosTemplate extends React.Component { goBackToCoSDefinition: false, createdTemplate: "", isConfirmModalOpen: false, - createTemplateEnd: false + createTemplateEnd: false, + searchValue: "", + searchAttrValue: "", }; this.handleConfirmModalToggle = () => { @@ -279,8 +282,36 @@ class AddCosTemplate extends React.Component { this.setState({ rowsOc: ocRows, pagedRowsOc: ocRows.slice(0, this.state.perPageOc), + itemCountOc: ocRows.length, + searchValue: value }) } + + this.onAttrSearchChange = (value, event) => { + let attrRows = []; + let allAttrs = this.state.rowsAttrOrig; + const val = value.toLowerCase(); + + // Process search filter on the entire list + if (val !== "") { + for (const row of allAttrs) { + const name = row.attributeName.toLowerCase(); + if (name.includes(val)) { + attrRows.push(row); + } + } + } else { + // Restore entire row list + attrRows = allAttrs; + } + + this.setState({ + rowsAttr: attrRows, + pagedRowsAttr: attrRows.slice(0, this.state.perPageAttr), + itemCountAttr: attrRows.length, + searchAttrValue: value + }); + } // End constructor(). } @@ -625,6 +656,7 @@ class AddCosTemplate extends React.Component { rowsAttr.sort((a, b) => (a.attributeName > b.attributeName) ? 1 : -1) this.setState({ rowsAttr, + rowsAttrOrig: [...rowsAttr], selectedAttributes: rowsAttr.filter(item => item.isAttributeSelected) .map(attrObj => [attrObj.attributeName, attrObj.cells[1]]), itemCountAttr: rowsAttr.length, @@ -999,6 +1031,30 @@ class AddCosTemplate extends React.Component { </TextContent> {this.buildAttrDropdown()} </div> + <Grid className="ds-margin-top-lg"> + <GridItem span={5}> + <SearchInput + className="ds-font-size-md" + placeholder='Search Attributes' + value={this.state.searchAttrValue} + onChange={this.onAttrSearchChange} + onClear={(evt) => this.onAttrSearchChange('', evt)} + /> + </GridItem> + <GridItem span={7}> + <Pagination + itemCount={itemCountAttr} + page={pageAttr} + perPage={perPageAttr} + onSetPage={this.onSetPageAttr} + widgetId="pagination-step-attributes" + onPerPageSelect={this.onPerPageSelectAttr} + dropDirection="up" + isCompact + /> + </GridItem> + </Grid> + <Table className="ds-margin-top" cells={columnsAttr} @@ -1011,16 +1067,7 @@ class AddCosTemplate extends React.Component { <TableHeader /> <TableBody /> </Table> - <Pagination - itemCount={itemCountAttr} - page={pageAttr} - perPage={perPageAttr} - onSetPage={this.onSetPageAttr} - widgetId="pagination-step-attributes" - onPerPageSelect={this.onPerPageSelectAttr} - dropDirection="up" - isCompact - /> + </> ); diff --git a/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addLdapEntry.jsx b/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addLdapEntry.jsx index 6f1953f3e..493b88bb6 100644 --- a/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addLdapEntry.jsx +++ b/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addLdapEntry.jsx @@ -83,6 +83,7 @@ class AddLdapEntry extends React.Component { ], rowsOc: [], rowsAttr: [], + rowsAttrOrig: [], rowsValues: [], pagedRowsOc: [], pagedRowsAttr: [], @@ -91,6 +92,8 @@ class AddLdapEntry extends React.Component { attrsToRemove: [], namingAttr: "", adding: true, + searchOCValue: "", + searchAttrValue: "", }; this.onNext = ({ id }) => { @@ -203,7 +206,35 @@ class AddLdapEntry extends React.Component { this.setState({ rowsOc: ocRows, pagedRowsOc: ocRows.slice(0, this.state.perPageOc), - }) + searchOCValue: value, + itemCountOc: ocRows.length, + }); + } + + this.onAttrSearchChange = (value, event) => { + let attrRows = []; + let allAttrs = this.state.rowsAttrOrig; + const val = value.toLowerCase(); + + // Process search filter on the entire list + if (val !== "") { + for (const row of allAttrs) { + const name = row.attributeName.toLowerCase(); + if (name.includes(val)) { + attrRows.push(row); + } + } + } else { + // Restore entire row list + attrRows = allAttrs; + } + + this.setState({ + rowsAttr: attrRows, + pagedRowsAttr: attrRows.slice(0, this.state.perPageAttr), + itemCountAttr: attrRows.length, + searchAttrValue: value + }); } // End constructor(). } @@ -387,7 +418,7 @@ class AddLdapEntry extends React.Component { // The property 'isAttributeSelected' is used to build the LDAP entry to add. // The row ID cannot be used since it changes with the pagination. const attrName = this.state.pagedRowsAttr[rowId].cells[0]; - let allItems = [...this.state.rowsAttr]; + let allItems = [...this.state.rowsAttrOrig]; const index = allItems.findIndex(item => item.cells[0] === attrName); allItems[index].isAttributeSelected = isSelected; const selectedAttributes = allItems @@ -522,6 +553,7 @@ class AddLdapEntry extends React.Component { rowsAttr.sort((a, b) => (a.attributeName > b.attributeName) ? 1 : -1) this.setState({ rowsAttr, + rowsAttrOrig: [...rowsAttr], selectedAttributes: rowsAttr.filter(item => item.isAttributeSelected) .map(attrObj => [attrObj.attributeName, attrObj.cells[1]]), itemCountAttr: rowsAttr.length, @@ -724,7 +756,7 @@ class AddLdapEntry extends React.Component { <SearchInput className="ds-font-size-md" placeholder='Search Objectclasses' - value={this.state.searchValue} + value={this.state.searchOCValue} onChange={this.onOCSearchChange} onClear={(evt) => this.onOCSearchChange('', evt)} /> @@ -768,6 +800,28 @@ class AddLdapEntry extends React.Component { </TextContent> {this.buildAttrDropdown()} </div> + <Grid className="ds-margin-top-lg"> + <GridItem span={5}> + <SearchInput + className="ds-font-size-md" + placeholder='Search Attributes' + value={this.state.searchAttrValue} + onChange={this.onAttrSearchChange} + onClear={(evt) => this.onAttrSearchChange('', evt)} + /> + </GridItem> + <GridItem span={7}> + <Pagination + itemCount={itemCountAttr} + page={pageAttr} + perPage={perPageAttr} + onSetPage={this.onSetPageAttr} + widgetId="pagination-step-attributes" + onPerPageSelect={this.onPerPageSelectAttr} + isCompact + /> + </GridItem> + </Grid> <Table className="ds-margin-top" cells={columnsAttr} @@ -780,16 +834,6 @@ class AddLdapEntry extends React.Component { <TableHeader /> <TableBody /> </Table> - <Pagination - itemCount={itemCountAttr} - page={pageAttr} - perPage={perPageAttr} - onSetPage={this.onSetPageAttr} - widgetId="pagination-step-attributes" - onPerPageSelect={this.onPerPageSelectAttr} - dropDirection="up" - isCompact - /> </> ); diff --git a/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addUser.jsx b/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addUser.jsx index 6a90a6a4c..7d9e6f8ba 100644 --- a/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addUser.jsx +++ b/src/cockpit/389-console/src/lib/ldap_editor/wizards/operations/addUser.jsx @@ -274,6 +274,7 @@ class AddUser extends React.Component { rowsUser: attrRows, pagedRowsUser: attrRows.slice(0, this.state.perPageAttr), itemCountAddUser: attrRows.length, + searchValue: value }) } 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 29a134715..614aa63c8 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 @@ -98,6 +98,8 @@ class EditLdapEntry extends React.Component { groupMembers: [], groupGenericEditor: false, localProps: {...this.props}, + searchOCValue: "", + searchValue: "", }; this.onNext = ({ id }) => { @@ -206,6 +208,8 @@ class EditLdapEntry extends React.Component { this.setState({ rowsOc: ocRows, pagedRowsOc: ocRows.slice(0, this.state.perPageOc), + itemCountOc: ocRows.length, + searchOCValue: value }) } @@ -234,6 +238,7 @@ class EditLdapEntry extends React.Component { rowsAttr: attrRows, pagedRowsAttr: attrRows.slice(0, this.state.perPageAttr), itemCountAttr: attrRows.length, + searchValue: value, }) } @@ -1226,7 +1231,7 @@ class EditLdapEntry extends React.Component { <SearchInput className="ds-font-size-md" placeholder='Search Objectclasses' - value={this.state.searchValue} + value={this.state.searchOCValue} onChange={this.onOCSearchChange} onClear={(evt) => this.onOCSearchChange('', evt)} /> diff --git a/src/cockpit/389-console/src/lib/monitor/replMonitor.jsx b/src/cockpit/389-console/src/lib/monitor/replMonitor.jsx index 1ba3deccc..121a6c761 100644 --- a/src/cockpit/389-console/src/lib/monitor/replMonitor.jsx +++ b/src/cockpit/389-console/src/lib/monitor/replMonitor.jsx @@ -1505,7 +1505,7 @@ export class ReplMonitor extends React.Component { return ( <div> <div id="monitor-suffix-page" className="ds-tab-table"> - <Tabs activeKey={this.state.activeTabReplKey} onSelect={this.handleNavReplSelect}> + <Tabs isFilled activeKey={this.state.activeTabReplKey} onSelect={this.handleNavReplSelect}> <Tab eventKey={0} title={<TabTitleText>Synchronization Report</TabTitleText>}> {reportContent} </Tab> diff --git a/src/cockpit/389-console/src/lib/monitor/serverMonitor.jsx b/src/cockpit/389-console/src/lib/monitor/serverMonitor.jsx index 4d97cff60..1b62b3e3f 100644 --- a/src/cockpit/389-console/src/lib/monitor/serverMonitor.jsx +++ b/src/cockpit/389-console/src/lib/monitor/serverMonitor.jsx @@ -333,7 +333,7 @@ export class ServerMonitor extends React.Component { </TextContent> </GridItem> </Grid> - <Tabs className="ds-margin-top-lg" activeKey={this.state.activeKey} onSelect={this.handleNavSelect}> + <Tabs isFilled className="ds-margin-top-lg" activeKey={this.state.activeKey} onSelect={this.handleNavSelect}> <Tab eventKey={0} title={<TabTitleText>Resource Charts</TabTitleText>}> <Card className="ds-margin-top-lg" isSelectable> <CardBody> diff --git a/src/cockpit/389-console/src/lib/replication/replSuffix.jsx b/src/cockpit/389-console/src/lib/replication/replSuffix.jsx index 13b4495a2..3c7c2e5ba 100644 --- a/src/cockpit/389-console/src/lib/replication/replSuffix.jsx +++ b/src/cockpit/389-console/src/lib/replication/replSuffix.jsx @@ -316,7 +316,7 @@ export class ReplSuffix extends React.Component { let enabledContent = <div className={suffixClass}> - <Tabs activeKey={this.state.activeTabKey} onSelect={this.handleNavSelect}> + <Tabs isFilled activeKey={this.state.activeTabKey} onSelect={this.handleNavSelect}> <Tab eventKey={0} title={<TabTitleText>Configuration</TabTitleText>}> <ReplConfig suffix={this.props.suffix} diff --git a/src/cockpit/389-console/src/lib/server/accessLog.jsx b/src/cockpit/389-console/src/lib/server/accessLog.jsx index cdcbac711..4a4553a61 100644 --- a/src/cockpit/389-console/src/lib/server/accessLog.jsx +++ b/src/cockpit/389-console/src/lib/server/accessLog.jsx @@ -179,7 +179,7 @@ export class ServerAccessLog extends React.Component { // Check if a setting was changed, if so enable the save button for (const config_attr of config_attrs) { - if (attr === config_attr && this.state['_' + config_attr] !== value) { + if (attr === config_attr && this.state['_' + config_attr].toString() !== value.toString()) { disableSaveBtn = false; break; } @@ -187,7 +187,7 @@ export class ServerAccessLog extends React.Component { // Now check for differences in values that we did not touch for (const config_attr of config_attrs) { - if (attr !== config_attr && this.state['_' + config_attr] !== this.state[config_attr]) { + if (attr !== config_attr && this.state['_' + config_attr].toString() !== this.state[config_attr].toString()) { disableSaveBtn = false; break; } diff --git a/src/cockpit/389-console/src/lib/server/auditLog.jsx b/src/cockpit/389-console/src/lib/server/auditLog.jsx index a73a25c78..673936aeb 100644 --- a/src/cockpit/389-console/src/lib/server/auditLog.jsx +++ b/src/cockpit/389-console/src/lib/server/auditLog.jsx @@ -197,7 +197,7 @@ export class ServerAuditLog extends React.Component { // Check if a setting was changed, if so enable the save button for (const config_attr of config_attrs) { - if (attr === config_attr && this.state['_' + config_attr] !== value) { + if (attr === config_attr && this.state['_' + config_attr].toString() !== value.toString()) { disableSaveBtn = false; break; } @@ -205,7 +205,7 @@ export class ServerAuditLog extends React.Component { // Now check for differences in values that we did not touch for (const config_attr of config_attrs) { - if (attr !== config_attr && this.state['_' + config_attr] !== this.state[config_attr]) { + if (attr !== config_attr && this.state['_' + config_attr].toString() !== this.state[config_attr].toString()) { disableSaveBtn = false; break; } diff --git a/src/cockpit/389-console/src/lib/server/auditfailLog.jsx b/src/cockpit/389-console/src/lib/server/auditfailLog.jsx index 1ce7b8689..2326a9fe1 100644 --- a/src/cockpit/389-console/src/lib/server/auditfailLog.jsx +++ b/src/cockpit/389-console/src/lib/server/auditfailLog.jsx @@ -138,7 +138,7 @@ export class ServerAuditFailLog extends React.Component { // Check if a setting was changed, if so enable the save button for (const config_attr of config_attrs) { - if (attr === config_attr && this.state['_' + config_attr] !== value) { + if (attr === config_attr && this.state['_' + config_attr].toString() !== value.toString()) { disableSaveBtn = false; break; } @@ -146,7 +146,7 @@ export class ServerAuditFailLog extends React.Component { // Now check for differences in values that we did not touch for (const config_attr of config_attrs) { - if (attr !== config_attr && this.state['_' + config_attr] !== this.state[config_attr]) { + if (attr !== config_attr && this.state['_' + config_attr].toString() !== this.state[config_attr].toString()) { disableSaveBtn = false; break; } diff --git a/src/cockpit/389-console/src/lib/server/errorLog.jsx b/src/cockpit/389-console/src/lib/server/errorLog.jsx index 3f2665040..dd6a82055 100644 --- a/src/cockpit/389-console/src/lib/server/errorLog.jsx +++ b/src/cockpit/389-console/src/lib/server/errorLog.jsx @@ -204,7 +204,7 @@ export class ServerErrorLog extends React.Component { // Check if a setting was changed, if so enable the save button for (const config_attr of config_attrs) { - if (attr === config_attr && this.state['_' + config_attr] !== value) { + if (attr === config_attr && this.state['_' + config_attr].toString() !== value.toString()) { disableSaveBtn = false; break; } @@ -212,7 +212,7 @@ export class ServerErrorLog extends React.Component { // Now check for differences in values that we did not touch for (const config_attr of config_attrs) { - if (attr !== config_attr && this.state['_' + config_attr] !== this.state[config_attr]) { + if (attr !== config_attr && this.state['_' + config_attr].toString() !== this.state[config_attr].toString()) { disableSaveBtn = false; break; } diff --git a/src/cockpit/389-console/src/lib/server/settings.jsx b/src/cockpit/389-console/src/lib/server/settings.jsx index d284c223f..bf39369d5 100644 --- a/src/cockpit/389-console/src/lib/server/settings.jsx +++ b/src/cockpit/389-console/src/lib/server/settings.jsx @@ -939,7 +939,7 @@ export class ServerSettings extends React.Component { </Grid> <div className={this.state.loading ? 'ds-fadeout' : 'ds-fadein ds-left-margin'}> - <Tabs className="ds-margin-top-lg" activeKey={this.state.activeTabKey} onSelect={this.handleNavSelect}> + <Tabs isFilled className="ds-margin-top-lg" activeKey={this.state.activeTabKey} onSelect={this.handleNavSelect}> <Tab eventKey={0} title={<TabTitleText>General Settings</TabTitleText>}> <Form autoComplete="off" className="ds-margin-top-xlg"> <Grid
0
1afc45edb18d22c6bb9c7160a1065f7ec3560622
389ds/389-ds-base
Bug 703990 - cross-platform - Support upgrade from Red Hat Directory Server https://bugzilla.redhat.com/show_bug.cgi?id=703990 Resolves: bug 703990 Bug Description: cross-platform - Support upgrade from Red Hat Directory Server Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: There was bug in handling nsState from big-endian systems. Also, create the instance specific directories if they do not exist, which is useful if doing a cross-platform upgrade from a system that does not use the same paths. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no
commit 1afc45edb18d22c6bb9c7160a1065f7ec3560622 Author: Rich Megginson <[email protected]> Date: Tue Aug 30 17:47:55 2011 -0600 Bug 703990 - cross-platform - Support upgrade from Red Hat Directory Server https://bugzilla.redhat.com/show_bug.cgi?id=703990 Resolves: bug 703990 Bug Description: cross-platform - Support upgrade from Red Hat Directory Server Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: There was bug in handling nsState from big-endian systems. Also, create the instance specific directories if they do not exist, which is useful if doing a cross-platform upgrade from a system that does not use the same paths. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no diff --git a/ldap/admin/src/scripts/50fixNsState.pl b/ldap/admin/src/scripts/50fixNsState.pl index acf65067b..b331e9c3b 100644 --- a/ldap/admin/src/scripts/50fixNsState.pl +++ b/ldap/admin/src/scripts/50fixNsState.pl @@ -72,7 +72,7 @@ sub convert_uniqueid { my $maxdiff = 86400*365*10; # 10 years if (($tsdiff > $maxdiff) || (($last_update != 0) && ($last_update != 1))) { # try big endian - ($tslow, $tshigh, $node, $clockseq, $last_update) = unpack($bigfmt, $val); + ($tshigh, $tslow, $node, $clockseq, $last_update) = unpack($bigfmt, $val); $ts = convert_from_32bit($tshigh, $tslow); $tssecs = ($ts - 0x01B21DD213814000) / 10000000; $tsdiff = abs($curts - $tssecs); @@ -120,7 +120,7 @@ sub convert_replica { $timefmt = 'V'; # timevals are unsigned 64-bit int $fmtstr = "vx" . $pad . $timefmt . "6vx" . $pad; $bigfmtstr = 'nx' . $pad . 'N' . '6nx' . $pad; - ($rid, $st_low, $st_high, $lo_low, $lo_high, $rt_low, $rt_high, $seq_num) = unpack($fmtstr, $val); + ($rid, $st_low, $st_high, $lo_low, $lo_high, $ro_low, $ro_high, $seq_num) = unpack($fmtstr, $val); $sampled_time = convert_from_32bit($st_high, $st_low); $local_offset = convert_from_32bit($lo_high, $lo_low); $remote_offset = convert_from_32bit($ro_high, $ro_low); @@ -134,7 +134,7 @@ sub convert_replica { if ($len <= 20) { ($rid, $sampled_time, $local_offset, $remote_offset, $seq_num) = unpack($bigfmtstr, $val); } else { - ($rid, $st_low, $st_high, $lo_low, $lo_high, $rt_low, $rt_high, $seq_num) = unpack($bigfmtstr, $val); + ($rid, $st_high, $st_low, $lo_high, $lo_low, $ro_high, $ro_low, $seq_num) = unpack($bigfmtstr, $val); $sampled_time = convert_from_32bit($st_high, $st_low); $local_offset = convert_from_32bit($lo_high, $lo_low); $remote_offset = convert_from_32bit($ro_high, $ro_low); @@ -222,13 +222,19 @@ sub testit { #my $testval = "00a43cb4d11db2018b7912fd0000a42e01000000"; #my $testval = "0029B605D21DB201FEB70FFC00007EB301000000"; #my $testval = "00E8FEB72B80E001EC359ED2F4D9F1670100000000000000"; -my $testval = "00123781D21DB201F74C95A90000862201000000"; +#my $testval = "00123781D21DB201F74C95A90000862201000000"; +my $testval = '01E0D2DA53198600A12C2D6BADF15D630100000000000000'; +my $testreplval = "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00N\\\x8b5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00"; my $testdecval = $testval; # base16 decode $testdecval =~ s/(..)/chr(hex($1))/eg; my $ent = new Mozilla::LDAP::Entry; $ent->setDN("cn=uniqueid generator"); my ($rc, $newval) = convert_uniqueid($ent, $testdecval); +$ent->setDN('cn=replica'); +my ($rc, $newval2) = convert_replica($ent, $testreplval); } +testit() unless caller(); + 1; diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in index ed40ae1d8..6af591095 100644 --- a/ldap/admin/src/scripts/DSCreate.pm.in +++ b/ldap/admin/src/scripts/DSCreate.pm.in @@ -64,9 +64,9 @@ use Mozilla::LDAP::LDIF; use Exporter; @ISA = qw(Exporter); -@EXPORT = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts +@EXPORT = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts makeDSDirs makeOtherConfigFiles installSchema updateSelinuxPolicy updateTmpfilesDotD); -@EXPORT_OK = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts +@EXPORT_OK = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts makeDSDirs makeOtherConfigFiles installSchema updateSelinuxPolicy updateTmpfilesDotD); use strict; diff --git a/ldap/admin/src/scripts/DSUpdate.pm.in b/ldap/admin/src/scripts/DSUpdate.pm.in index 3b6ccd547..36aa3c93d 100644 --- a/ldap/admin/src/scripts/DSUpdate.pm.in +++ b/ldap/admin/src/scripts/DSUpdate.pm.in @@ -47,7 +47,8 @@ package DSUpdate; use DSUtil; use Inf; use FileConn; -use DSCreate qw(setDefaults createInstanceScripts makeOtherConfigFiles updateSelinuxPolicy updateTmpfilesDotD); +use DSCreate qw(setDefaults createInstanceScripts makeOtherConfigFiles + makeDSDirs updateSelinuxPolicy updateTmpfilesDotD); use File::Basename qw(basename dirname); @@ -314,6 +315,11 @@ sub updateDSInstance { return @errs; } + # create dirs if missing e.g. cross platform upgrade + if (@errs = makeDSDirs($inf)) { + return @errs; + } + # upgrade instance scripts if (@errs = createInstanceScripts($inf, 0)) { return @errs;
0
b2ece76189f87f75ef16ae9c75fc4348904a6714
389ds/389-ds-base
Ticket 314 - ChaiOnUpdate for root handling Bug Description: If chaining and distribution are configured updates as root are always applied locally This leads to inconsistent data Fix Description: Add a configuration option to control the processing of root updates. Valid options are: - local: apply changes to the local database - reject: do not handle root updates - referral: return the referral to the chaining backend https://fedorahosted.org/389/ticket/314 Reviewed by: ?
commit b2ece76189f87f75ef16ae9c75fc4348904a6714 Author: Ludwig Krispenz <[email protected]> Date: Wed Sep 11 14:42:36 2013 +0200 Ticket 314 - ChaiOnUpdate for root handling Bug Description: If chaining and distribution are configured updates as root are always applied locally This leads to inconsistent data Fix Description: Add a configuration option to control the processing of root updates. Valid options are: - local: apply changes to the local database - reject: do not handle root updates - referral: return the referral to the chaining backend https://fedorahosted.org/389/ticket/314 Reviewed by: ? diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c index d007f6cec..4dee4c145 100644 --- a/ldap/servers/plugins/replication/replutil.c +++ b/ldap/servers/plugins/replication/replutil.c @@ -814,7 +814,8 @@ repl_set_mtn_state_and_referrals( int repl_chain_on_update(Slapi_PBlock *pb, Slapi_DN * target_dn, char **mtn_be_names, int be_count, - Slapi_DN * node_dn, int *mtn_be_states) + Slapi_DN * node_dn, int *mtn_be_states, + int root_mode) { char * requestor_dn; unsigned long op_type; @@ -943,7 +944,12 @@ repl_chain_on_update(Slapi_PBlock *pb, Slapi_DN * target_dn, "is root: using local backend\n", connid, opid); } #endif - return local_backend; + if (root_mode == CHAIN_ROOT_UPDATE_LOCAL) + return local_backend; + else if (root_mode == CHAIN_ROOT_UPDATE_REJECT) + return (-2); + else if (root_mode == CHAIN_ROOT_UPDATE_REFERRAL) + return (-3); } /* if the operation is a replicated operation @@ -981,7 +987,7 @@ repl_chain_on_update(Slapi_PBlock *pb, Slapi_DN * target_dn, } } - /* all other case (update while not directory manager) : + /* all other cases : * or any normal non replicated client operation while local is disabled (import) : * use the chaining backend */ diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c index 9336d7c07..53df04a15 100644 --- a/ldap/servers/slapd/mapping_tree.c +++ b/ldap/servers/slapd/mapping_tree.c @@ -47,7 +47,7 @@ /* distribution plugin prototype */ typedef int (* mtn_distrib_fct) (Slapi_PBlock *pb, Slapi_DN * target_dn, - char **mtn_be_names, int be_count, Slapi_DN * mtn_node_dn, int *mtn_be_states); + char **mtn_be_names, int be_count, Slapi_DN * mtn_node_dn, int *mtn_be_states, int rootmode); struct mt_node { @@ -70,6 +70,7 @@ struct mt_node * cn=config, cn=schema and root node */ char * mtn_dstr_plg_lib; /* distribution plugin library name */ char * mtn_dstr_plg_name; /* distribution plugin function name */ + int mtn_dstr_plg_rootmode; /* determines how to process root updates in distribution */ mtn_distrib_fct mtn_dstr_plg; /* pointer to the actual ditribution function */ void *mtn_extension; /* plugins can extend a mapping tree node */ }; @@ -302,7 +303,7 @@ mapping_tree_node_new(Slapi_DN *dn, Slapi_Backend **be, char **backend_names, in int count, int size, char **referral, mapping_tree_node *parent, int state, int private, char *plg_lib, char *plg_fct, - mtn_distrib_fct plg) + mtn_distrib_fct plg, int plg_rootmode) { Slapi_RDN rdn; mapping_tree_node *node; @@ -326,6 +327,7 @@ mapping_tree_node_new(Slapi_DN *dn, Slapi_Backend **be, char **backend_names, in slapi_rdn_done(&rdn); node->mtn_dstr_plg_lib = plg_lib; node->mtn_dstr_plg_name = plg_fct; + node->mtn_dstr_plg_rootmode = plg_rootmode; node->mtn_dstr_plg = plg; slapi_log_error(SLAPI_LOG_TRACE, "mapping_tree", @@ -621,6 +623,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep ) int * be_states = NULL; char * plugin_funct = NULL; char * plugin_lib = NULL; + int plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; mtn_distrib_fct plugin = NULL; char **referral = NULL; @@ -729,6 +732,24 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep ) continue; } plugin_funct = slapi_ch_strdup(slapi_value_get_string(val)); + } else if (!strcasecmp(type, "nsslapd-distribution-root-update")) { + const char *sval; + slapi_attr_first_value(attr, &val); + if (NULL == val) { + LDAPDebug(LDAP_DEBUG_ANY, "Warning: The nsslapd-distribution-plugin attribute has no value for the mapping tree node %s\n", + slapi_entry_get_dn(entry), 0, 0); + continue; + } + sval = slapi_value_get_string(val); + if (strcmp(sval,"reject") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; + else if (strcmp(sval,"local") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_LOCAL; + else if (strcmp(sval,"referral") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_REFERRAL; + else + LDAPDebug(LDAP_DEBUG_ANY, "Warning: The nsslapd-distribution-root-update attribute has undefined value (%s) for the mapping tree node %s\n", + sval, slapi_entry_get_dn(entry), 0); } else if (!strcasecmp(type, MAPPING_TREE_PARENT_ATTRIBUTE)) { Slapi_DN *parent_node_dn = get_parent_from_entry(entry); parent_node = mtn_get_mapping_tree_node_by_entry( @@ -845,7 +866,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep ) node= mapping_tree_node_new(subtree, be_list, be_names, be_states, be_list_count, be_list_size, referral, parent_node, state, 0 /* Normal node. People can see and change it. */, - plugin_lib, plugin_funct, plugin); + plugin_lib, plugin_funct, plugin, plugin_rootmode); tmp_ndn = slapi_sdn_get_ndn( subtree ); if ( NULL != node && NULL == parent_node && tmp_ndn @@ -1061,6 +1082,7 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor int * be_states = NULL; char * plugin_fct = NULL; char * plugin_lib = NULL; + int plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; int plugin_flag = 0; mtn_distrib_fct plugin = NULL; @@ -1325,6 +1347,38 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor plugin_flag = 1; } + else if (strcasecmp(mods[i]->mod_type, + "nsslapd-distribution-root-update" ) == 0) + { + if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op) + || SLAPI_IS_MOD_ADD(mods[i]->mod_op)) + { + const char *sval; + slapi_entry_attr_find(entryAfter, + "nsslapd-distribution-root-update", &attr); + slapi_attr_first_value(attr, &val); + if (NULL == val) { + LDAPDebug(LDAP_DEBUG_ANY, + "Warning: The nsslapd-distribution-root-update attribute" + " has no value for the mapping tree node %s\n", + slapi_entry_get_dn(entryAfter), 0, 0); + plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; + } else { + sval = slapi_value_get_string(val); + if (strcmp(sval,"reject") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; + else if (strcmp(sval,"local") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_LOCAL; + else if (strcmp(sval,"referral") == 0) + plugin_rootmode = CHAIN_ROOT_UPDATE_REFERRAL; + } + } + else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) + { + plugin_rootmode = CHAIN_ROOT_UPDATE_REJECT; /* default */ + } + plugin_flag = 1; + } } /* if distribution plugin has been configured or modified @@ -1371,6 +1425,7 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor if (node->mtn_dstr_plg_name) slapi_ch_free((void **) &node->mtn_dstr_plg_name); node->mtn_dstr_plg_name = plugin_fct; + node->mtn_dstr_plg_rootmode = plugin_rootmode; node->mtn_dstr_plg = plugin; mtn_unlock(); } @@ -1626,7 +1681,7 @@ add_internal_mapping_tree_node(const char *subtree, Slapi_Backend *be, mapping_t MTN_BACKEND, 1, /* The config node is a private node. * People can't see or change it. */ - NULL, NULL, NULL); + NULL, NULL, NULL, 0); /* no distribution */ return node; } @@ -1994,6 +2049,8 @@ Slapi_Backend *slapi_mapping_tree_find_backend_for_sdn(Slapi_DN *sdn) } operation_set_target_spec(op, sdn); slapi_pblock_set(pb, SLAPI_OPERATION, op); + /* requestor dn is not set in pblock, so the distribution plugin + * will return index >= 0 */ index = mtn_get_be_distributed(pb, target_node, sdn, &flag_stop); slapi_pblock_destroy(pb); /* also frees the operation */ @@ -2504,7 +2561,7 @@ mtn_get_be_distributed(Slapi_PBlock *pb, mapping_tree_node * target_node, { index = (*target_node->mtn_dstr_plg)(pb, target_sdn, target_node->mtn_backend_names, target_node->mtn_be_count, - target_node->mtn_subtree, target_node->mtn_be_states); + target_node->mtn_subtree, target_node->mtn_be_states, target_node->mtn_dstr_plg_rootmode); if (index == SLAPI_BE_ALL_BACKENDS) { @@ -2513,6 +2570,12 @@ mtn_get_be_distributed(Slapi_PBlock *pb, mapping_tree_node * target_node, */ index = 0; } + /* check if distribution plugi returned a special mode for + * updates as root */ + else if (index == -2 || index == -3) + { + /* nothing special to do */ + } /* paranoid check, never trust another programmer */ else if ((index >= target_node->mtn_be_count) || (index < 0)) { @@ -2521,7 +2584,7 @@ mtn_get_be_distributed(Slapi_PBlock *pb, mapping_tree_node * target_node, " : %d for entry %s at node %s\n", index, slapi_sdn_get_ndn(target_sdn), slapi_sdn_get_ndn(target_node->mtn_subtree)); - index = 0; + index = 0; } else { @@ -2600,6 +2663,7 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb, ((SLAPI_OPERATION_SEARCH == op_type)||(SLAPI_OPERATION_BIND == op_type) || (SLAPI_OPERATION_UNBIND == op_type) || (SLAPI_OPERATION_COMPARE == op_type))) || override_referral) { + *referral = NULL; if ((target_node == mapping_tree_root) ){ /* If we got here, then we couldn't find a matching node * for the target. We'll use the default backend. Once @@ -2622,11 +2686,18 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb, } else { *index = mtn_get_be_distributed(pb, target_node, target_sdn, &flag_stop); - } - } - - if ((*index == -2) || (*index >= target_node->mtn_be_count)) { - /* we have already returned all backends -> return NULL */ + if (*index == -2) + result = LDAP_UNWILLING_TO_PERFORM; + } + } + if (*index == -3) { + *be = NULL; + *referral = (target_node->mtn_referral_entry ? + slapi_entry_dup(target_node->mtn_referral_entry) : + NULL); + (*index)++; + }else if ((*index == -2) || (*index >= target_node->mtn_be_count)) { + /* we have already returned all backends -> return NULL */ *be = NULL; *referral = NULL; } else { @@ -2673,7 +2744,6 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb, (*index)++; } } - *referral = NULL; } else { /* otherwise we must return the referral * if ((target_node->mtn_state == MTN_REFERRAL) || diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h index 10d531ebf..900d3e53d 100644 --- a/ldap/servers/slapd/slapi-private.h +++ b/ldap/servers/slapd/slapi-private.h @@ -762,6 +762,9 @@ char * slapi_schema_get_superior_name(const char *ocname_or_oid); CSN *dup_global_schema_csn(); /* misc function for the chaining backend */ +#define CHAIN_ROOT_UPDATE_REJECT 0 +#define CHAIN_ROOT_UPDATE_LOCAL 1 +#define CHAIN_ROOT_UPDATE_REFERRAL 2 char * slapi_get_rootdn(); /* return the directory manager dn in use */ /* plugin interface to bulk import */
0
a7718006a57aa8326d3fafa222a654542ea48742
389ds/389-ds-base
Issue 49225 - Add additional CRYPT password storage schemes Description: Add the crypt md5, sha256, and sha512 hashing algorithms. We only need a special encoding function for each type, as the current crypt compare function works for all formats. https://pagure.io/389-ds-base/issue/49225 Reviewed by: firstyear(Thanks!)
commit a7718006a57aa8326d3fafa222a654542ea48742 Author: Mark Reynolds <[email protected]> Date: Wed Apr 26 10:09:26 2017 -0400 Issue 49225 - Add additional CRYPT password storage schemes Description: Add the crypt md5, sha256, and sha512 hashing algorithms. We only need a special encoding function for each type, as the current crypt compare function works for all formats. https://pagure.io/389-ds-base/issue/49225 Reviewed by: firstyear(Thanks!) diff --git a/dirsrvtests/tests/suites/password/pwd_algo_test.py b/dirsrvtests/tests/suites/password/pwd_algo_test.py index b3f03fec6..d997728bf 100644 --- a/dirsrvtests/tests/suites/password/pwd_algo_test.py +++ b/dirsrvtests/tests/suites/password/pwd_algo_test.py @@ -54,7 +54,7 @@ def _test_algo(inst, algo_name): assert (not _test_bind(inst, 'Alsowrong')) # Bind with a subset password, should fail assert (not _test_bind(inst, 'Secret')) - if algo_name != 'CRYPT': + if not algo_name.startswith('CRYPT'): # Bind with a subset password that is 1 char shorter, to detect off by 1 in clear assert (not _test_bind(inst, 'Secret12')) # Bind with a superset password, should fail @@ -71,6 +71,9 @@ def test_pwd_algo_test(topology_st): for algo in ('CLEAR', 'CRYPT', + 'CRYPT-MD5', + 'CRYPT-SHA256', + 'CRYPT-SHA512', 'MD5', 'SHA', 'SHA256', diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in index c78f3b92c..cf3ed1b88 100644 --- a/ldap/ldif/template-dse.ldif.in +++ b/ldap/ldif/template-dse.ldif.in @@ -131,6 +131,33 @@ nsslapd-plugininitfunc: crypt_pwd_storage_scheme_init nsslapd-plugintype: pwdstoragescheme nsslapd-pluginenabled: on +dn: cn=CRYPT-MD5,cn=Password Storage Schemes,cn=plugins,cn=config +objectclass: top +objectclass: nsSlapdPlugin +cn: CRYPT-MD5 +nsslapd-pluginpath: libpwdstorage-plugin +nsslapd-plugininitfunc: crypt_md5_pwd_storage_scheme_init +nsslapd-plugintype: pwdstoragescheme +nsslapd-pluginenabled: on + +dn: cn=CRYPT-SHA256,cn=Password Storage Schemes,cn=plugins,cn=config +objectclass: top +objectclass: nsSlapdPlugin +cn: CRYPT-SHA256 +nsslapd-pluginpath: libpwdstorage-plugin +nsslapd-plugininitfunc: crypt_sha256_pwd_storage_scheme_init +nsslapd-plugintype: pwdstoragescheme +nsslapd-pluginenabled: on + +dn: cn=CRYPT-SHA512,cn=Password Storage Schemes,cn=plugins,cn=config +objectclass: top +objectclass: nsSlapdPlugin +cn: CRYPT-SHA512 +nsslapd-pluginpath: libpwdstorage-plugin +nsslapd-plugininitfunc: crypt_sha512_pwd_storage_scheme_init +nsslapd-plugintype: pwdstoragescheme +nsslapd-pluginenabled: on + dn: cn=MD5,cn=Password Storage Schemes,cn=plugins,cn=config objectclass: top objectclass: nsSlapdPlugin diff --git a/ldap/servers/plugins/pwdstorage/crypt_pwd.c b/ldap/servers/plugins/pwdstorage/crypt_pwd.c index dfd5af94b..03b442aeb 100644 --- a/ldap/servers/plugins/pwdstorage/crypt_pwd.c +++ b/ldap/servers/plugins/pwdstorage/crypt_pwd.c @@ -31,25 +31,34 @@ #include "pwdstorage.h" -static PRLock *cryptlock; /* Some implementations of crypt are not thread safe. ie. ours & Irix */ +static PRLock *cryptlock = NULL; /* Some implementations of crypt are not thread safe. ie. ours & Irix */ /* characters used in crypt encoding */ static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +#define CRYPT_UNIX 0 +#define CRYPT_MD5 1 +#define CRYPT_SHA256 2 +#define CRYPT_SHA512 3 int crypt_start(Slapi_PBlock *pb __attribute__((unused))) { - cryptlock = PR_NewLock(); + if (!cryptlock) { + cryptlock = PR_NewLock(); + } return 0; } int crypt_close(Slapi_PBlock *pb __attribute__((unused))) { - PR_DestroyLock(cryptlock); + if (cryptlock) { + PR_DestroyLock(cryptlock); + cryptlock = NULL; + } return 0; } @@ -70,11 +79,12 @@ crypt_pw_cmp( const char *userpwd, const char *dbpwd ) return rc; } -char * -crypt_pw_enc( const char *pwd ) -{ - char *cry, salt[3]; - char *enc= NULL; +static char* +crypt_pw_enc_by_hash( const char *pwd, int hash_algo){ + char salt[3]; + char *algo_salt = NULL; + char *cry; + char *enc = NULL; long v; static unsigned int seed = 0; @@ -89,13 +99,48 @@ crypt_pw_enc( const char *pwd ) salt[1] = itoa64[v & 0x3f]; salt[2] = '\0'; + /* Prepare our salt based on the hashing algorithm */ + if (hash_algo == CRYPT_UNIX) { + algo_salt = strdup(salt); + } else if (hash_algo == CRYPT_MD5) { + algo_salt = slapi_ch_smprintf("$1$%s", salt); + } else if (hash_algo == CRYPT_SHA256) { + algo_salt = slapi_ch_smprintf("$5$%s", salt); + } else if (hash_algo == CRYPT_SHA512) { + algo_salt = slapi_ch_smprintf("$6$%s", salt); + } + PR_Lock(cryptlock); - cry = crypt( pwd, salt ); + cry = crypt( pwd, algo_salt ); if ( cry != NULL ) { enc = slapi_ch_smprintf("%c%s%c%s", PWD_HASH_PREFIX_START, CRYPT_SCHEME_NAME, PWD_HASH_PREFIX_END, cry ); - } + } PR_Unlock(cryptlock); + slapi_ch_free_string(&algo_salt); + return( enc ); + +} + +char * +crypt_pw_enc( const char *pwd ) +{ + return crypt_pw_enc_by_hash(pwd, CRYPT_UNIX); } +char * +crypt_pw_md5_enc( const char *pwd ) +{ + return crypt_pw_enc_by_hash(pwd, CRYPT_MD5); +} +char * +crypt_pw_sha256_enc( const char *pwd ) +{ + return crypt_pw_enc_by_hash(pwd, CRYPT_SHA256); +} +char * +crypt_pw_sha512_enc( const char *pwd ) +{ + return crypt_pw_enc_by_hash(pwd, CRYPT_SHA512); +} diff --git a/ldap/servers/plugins/pwdstorage/pwd_init.c b/ldap/servers/plugins/pwdstorage/pwd_init.c index 16d2f32b8..ff839f79b 100644 --- a/ldap/servers/plugins/pwdstorage/pwd_init.c +++ b/ldap/servers/plugins/pwdstorage/pwd_init.c @@ -36,6 +36,12 @@ static Slapi_PluginDesc ssha512_pdesc = { "ssha512-password-storage-scheme", VEN static Slapi_PluginDesc crypt_pdesc = { "crypt-password-storage-scheme", VENDOR, DS_PACKAGE_VERSION, "Unix crypt algorithm (CRYPT)" }; +static Slapi_PluginDesc crypt_md5_pdesc = { "crypt-md5-password-storage-scheme", VENDOR, DS_PACKAGE_VERSION, "Unix crypt algorithm (CRYPT-MD5)" }; + +static Slapi_PluginDesc crypt_sha256_pdesc = { "crypt-sha256-password-storage-scheme", VENDOR, DS_PACKAGE_VERSION, "Unix crypt algorithm (CRYPT-SHA256)" }; + +static Slapi_PluginDesc crypt_sha512_pdesc = { "crypt-sha512-password-storage-scheme", VENDOR, DS_PACKAGE_VERSION, "Unix crypt algorithm (CRYPT-SHA512)" }; + static Slapi_PluginDesc clear_pdesc = { "clear-password-storage-scheme", VENDOR, DS_PACKAGE_VERSION, "No encryption (CLEAR)" }; static Slapi_PluginDesc ns_mta_md5_pdesc = { "NS-MTA-MD5-password-storage-scheme", VENDOR, DS_PACKAGE_VERSION, "Netscape MD5 (NS-MTA-MD5)" }; @@ -252,6 +258,78 @@ crypt_pwd_storage_scheme_init( Slapi_PBlock *pb ) return( rc ); } +int +crypt_md5_pwd_storage_scheme_init( Slapi_PBlock *pb ) +{ + int rc; + + slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "=> crypt_md5_pwd_storage_scheme_init\n" ); + + rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, + (void *) SLAPI_PLUGIN_VERSION_01 ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, + (void *)&crypt_md5_pdesc ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void*)&crypt_start); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void*)&crypt_close); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN, + (void *) crypt_pw_md5_enc ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN, + (void *) crypt_pw_cmp ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME, + "CRYPT-MD5" ); + + slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "<= crypt_md5_pwd_storage_scheme_init %d\n\n", rc ); + return( rc ); +} + +int +crypt_sha256_pwd_storage_scheme_init( Slapi_PBlock *pb ) +{ + int rc; + + slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "=> crypt_sha256_pwd_storage_scheme_init\n" ); + + rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, + (void *) SLAPI_PLUGIN_VERSION_01 ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, + (void *)&crypt_sha256_pdesc ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void*)&crypt_start); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void*)&crypt_close); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN, + (void *) crypt_pw_sha256_enc ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN, + (void *) crypt_pw_cmp ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME, + "CRYPT-SHA256" ); + + slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "<= crypt_sha256_pwd_storage_scheme_init %d\n\n", rc ); + return( rc ); +} + +int +crypt_sha512_pwd_storage_scheme_init( Slapi_PBlock *pb ) +{ + int rc; + + slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "=> crypt_sha512_pwd_storage_scheme_init\n" ); + + rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, + (void *) SLAPI_PLUGIN_VERSION_01 ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, + (void *)&crypt_sha512_pdesc ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void*)&crypt_start); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void*)&crypt_close); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN, + (void *) crypt_pw_sha512_enc ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN, + (void *) crypt_pw_cmp ); + rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME, + "CRYPT-SHA512" ); + + slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "<= crypt_sha512_pwd_storage_scheme_init %d\n\n", rc ); + return( rc ); +} + int clear_pwd_storage_scheme_init( Slapi_PBlock *pb ) { diff --git a/ldap/servers/plugins/pwdstorage/pwdstorage.h b/ldap/servers/plugins/pwdstorage/pwdstorage.h index 2909998f1..b41bb47be 100644 --- a/ldap/servers/plugins/pwdstorage/pwdstorage.h +++ b/ldap/servers/plugins/pwdstorage/pwdstorage.h @@ -78,6 +78,9 @@ int crypt_start(Slapi_PBlock *pb); int crypt_close(Slapi_PBlock *pb); int crypt_pw_cmp( const char *userpwd, const char *dbpwd ); char *crypt_pw_enc( const char *pwd ); +char *crypt_pw_md5_enc( const char *pwd ); +char *crypt_pw_sha256_enc( const char *pwd ); +char *crypt_pw_sha512_enc( const char *pwd ); int ns_mta_md5_pw_cmp( const char *userpwd, const char *dbpwd ); int md5_pw_cmp( const char *userpwd, const char *dbpwd ); char *md5_pw_enc( const char *pwd );
0
ad3e726a0361e1745dc2fc9c9d1fd542211e0c69
389ds/389-ds-base
Issue 27 - Add a module for working with dse.ldif file Description: For some tests we need a way to parse and edit dse.ldif file. For starters, it will be nice to have next operations support: - get - Return attribute values under a given entry; - add - Add an attribute under a given entry; - delete - Delete singlevalued or multivalued attributes under a given entry; - replace - Replace attribute values with a new one under a given entry. Add tests to lib389/tests/dseldif_test.py https://pagure.io/lib389/issue/27 Reviewed by: wibrown (Thanks!)
commit ad3e726a0361e1745dc2fc9c9d1fd542211e0c69 Author: Simon Pichugin <[email protected]> Date: Wed May 3 16:03:38 2017 +0200 Issue 27 - Add a module for working with dse.ldif file Description: For some tests we need a way to parse and edit dse.ldif file. For starters, it will be nice to have next operations support: - get - Return attribute values under a given entry; - add - Add an attribute under a given entry; - delete - Delete singlevalued or multivalued attributes under a given entry; - replace - Replace attribute values with a new one under a given entry. Add tests to lib389/tests/dseldif_test.py https://pagure.io/lib389/issue/27 Reviewed by: wibrown (Thanks!) diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py index 96e551732..1aff17d12 100644 --- a/src/lib389/lib389/_constants.py +++ b/src/lib389/lib389/_constants.py @@ -69,6 +69,8 @@ DN_DM = "cn=Directory Manager" PW_DM = "password" DN_CONFIG = "cn=config" DN_LDBM = "cn=ldbm database,cn=plugins,cn=config" +DN_CONFIG_LDBM = "cn=config,cn=ldbm database,cn=plugins,cn=config" +DN_USERROOT_LDBM = "cn=userRoot,cn=ldbm database,cn=plugins,cn=config" DN_SCHEMA = "cn=schema" DN_MONITOR = "cn=monitor" DN_MONITOR_SNMP = "cn=snmp,cn=monitor" diff --git a/src/lib389/lib389/dseldif.py b/src/lib389/lib389/dseldif.py new file mode 100644 index 000000000..39e35b219 --- /dev/null +++ b/src/lib389/lib389/dseldif.py @@ -0,0 +1,95 @@ +# --- 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 os +from lib389.paths import Paths + + +class DSEldif(object): + """A class for working with dse.ldif file""" + + def __init__(self, instance): + self._instance = instance + + ds_paths = Paths(self._instance.serverid, self._instance) + self.path = os.path.join(ds_paths.config_dir, 'dse.ldif') + + with open(self.path, 'r') as file_dse: + self._contents = file_dse.readlines() + + def _update(self): + """Update the dse.ldif with a new contents""" + + with open(self.path, "w") as file_dse: + file_dse.write("".join(self._contents)) + + def _find_attr(self, entry_dn, attr): + """Find all attribute values and indexes under a given entry + + Returns entry dn index and attribute data dict: + relative attribute indexes and the attribute value + """ + + entry_dn_i = self._contents.index("dn: {}\n".format(entry_dn)) + attr_data = {} + + # Find where the entry ends + try: + dn_end_i = self._contents[entry_dn_i:].index("\n") + except ValueError: + # We are in the end of the list + dn_end_i = len(self._contents) + + entry_slice = self._contents[entry_dn_i:entry_dn_i + dn_end_i] + + # Find the attribute + for line in entry_slice: + if line.startswith(attr): + attr_value = line.split(" ", 1)[1][:-1] + attr_data.update({entry_slice.index(line): attr_value}) + + if not attr_data: + raise ValueError("Attribute {} wasn't found under dn: {}".format(attr, entry_dn)) + + return entry_dn_i, attr_data + + def get(self, entry_dn, attr): + """Return attribute values under a given entry""" + + _, attr_data = self._find_attr(entry_dn, attr) + + return attr_data.values() + + def add(self, entry_dn, attr, value): + """Add an attribute under a given entry""" + + entry_dn_i = self._contents.index("dn: {}\n".format(entry_dn)) + self._contents.insert(entry_dn_i+1, "{}: {}\n".format(attr, value)) + self._update() + + def delete(self, entry_dn, attr, value=None): + """Delete attributes under a given entry""" + + entry_dn_i, attr_data = self._find_attr(entry_dn, attr) + + if value is not None: + for attr_i, attr_value in attr_data.items(): + if attr_value == value: + del self._contents[entry_dn_i + attr_i] + else: + for attr_i in sorted(attr_data.keys(), reverse=True): + del self._contents[entry_dn_i + attr_i] + self._update() + + def replace(self, entry_dn, attr, value): + """Replace attribute values with a new one under a given entry""" + + self.delete(entry_dn, attr) + self.add(entry_dn, attr, value) + self._update() + diff --git a/src/lib389/lib389/tests/dseldif_test.py b/src/lib389/lib389/tests/dseldif_test.py new file mode 100644 index 000000000..25eef778d --- /dev/null +++ b/src/lib389/lib389/tests/dseldif_test.py @@ -0,0 +1,129 @@ +# --- 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._constants import * +from lib389.dseldif import DSEldif +from lib389.topologies import topology_st as topo + +DEBUGGING = os.getenv('DEBUGGING', False) + +if DEBUGGING: + logging.getLogger(__name__).setLevel(logging.DEBUG) +else: + logging.getLogger(__name__).setLevel(logging.INFO) + +log = logging.getLogger(__name__) + + [email protected]("entry_dn", (DN_CONFIG, + DN_CONFIG_LDBM)) +def test_get_singlevalue(topo, entry_dn): + """Check that we can get an attribute value under different suffixes""" + + dse_ldif = DSEldif(topo.standalone) + + log.info("Get 'cn' attr from {}".format(entry_dn)) + attr_values = dse_ldif.get(entry_dn, "cn") + assert attr_values == ["config"] + + +def test_get_multivalue(topo): + """Check that we can get attribute values""" + + dse_ldif = DSEldif(topo.standalone) + + log.info("Get objectClass from {}".format(DN_CONFIG)) + attr_values = dse_ldif.get(DN_CONFIG, "objectClass") + assert len(attr_values) == 3 + assert "top" in attr_values + assert "extensibleObject" in attr_values + assert "nsslapdConfig" in attr_values + + [email protected]("fake_attr_value", ("fake value", + "fakevalue")) +def test_add(topo, fake_attr_value): + """Check that we can add an attribute to a given suffix""" + + dse_ldif = DSEldif(topo.standalone) + fake_attr = "fakeAttr" + + log.info("Add {} to {}".format(fake_attr, DN_CONFIG)) + dse_ldif.add(DN_CONFIG, fake_attr, fake_attr_value) + attr_values = dse_ldif.get(DN_CONFIG, fake_attr) + assert attr_values == [fake_attr_value] + + log.info("Clean up") + dse_ldif.delete(DN_CONFIG, fake_attr) + with pytest.raises(ValueError): + dse_ldif.get(DN_CONFIG, fake_attr) + + +def test_replace(topo): + """Check that we can replace an attribute to a given suffix""" + + dse_ldif = DSEldif(topo.standalone) + port_attr = "nsslapd-port" + port_value = "390" + + log.info("Get default value of {}".format(port_attr)) + default_value = dse_ldif.get(DN_CONFIG, port_attr)[0] + + log.info("Replace {} with {}".format(port_attr, port_value)) + dse_ldif.replace(DN_CONFIG, port_attr, port_value) + attr_values = dse_ldif.get(DN_CONFIG, port_attr) + assert attr_values == [port_value] + + log.info("Restore default value") + dse_ldif.replace(DN_CONFIG, port_attr, default_value) + + +def test_delete_singlevalue(topo): + """Check that we can delete an attribute from a given suffix""" + + dse_ldif = DSEldif(topo.standalone) + fake_attr = "fakeAttr" + fake_attr_values = ["fake1", "fake2", "fake3"] + + log.info("Add multivalued {} to {}".format(fake_attr, DN_CONFIG)) + for value in fake_attr_values: + dse_ldif.add(DN_CONFIG, fake_attr, value) + + log.info("Delete {}".format(fake_attr_values[0])) + dse_ldif.delete(DN_CONFIG, fake_attr, fake_attr_values[0]) + attr_values = dse_ldif.get(DN_CONFIG, fake_attr) + assert len(attr_values) == 2 + assert fake_attr_values[0] not in attr_values + assert fake_attr_values[1] in attr_values + assert fake_attr_values[2] in attr_values + + log.info("Clean up") + dse_ldif.delete(DN_CONFIG, fake_attr) + with pytest.raises(ValueError): + dse_ldif.get(DN_CONFIG, fake_attr) + + +def test_delete_multivalue(topo): + """Check that we can delete attributes from a given suffix""" + + dse_ldif = DSEldif(topo.standalone) + fake_attr = "fakeAttr" + fake_attr_values = ["fake1", "fake2", "fake3"] + + log.info("Add multivalued {} to {}".format(fake_attr, DN_CONFIG)) + for value in fake_attr_values: + dse_ldif.add(DN_CONFIG, fake_attr, value) + + log.info("Delete all values of {}".format(fake_attr)) + dse_ldif.delete(DN_CONFIG, fake_attr) + with pytest.raises(ValueError): + dse_ldif.get(DN_CONFIG, fake_attr) +
0
0610f9a7495b5cc995796e8a0bbaa6bc61449c33
389ds/389-ds-base
Ticket #316 and Ticket #70 - add post add/mod and AD add callback hooks https://fedorahosted.org/389/ticket/316 https://fedorahosted.org/389/ticket/70 Resolves: Ticket #316 and Ticket #70 Bug Description: Add user post callback hook to winsync plugin API Bug Description: Winsync API should have callback functions for new entries sync to AD Reviewed by: nkinder (Thanks!) Branch: master Fix Description: New callbacks for all post-add and post-modify (both to and from AD) operations. All post op callbacks have an int *return parameter. This parameter is the ldap result code from the add/mod op. The plugin will be called upon op success or failure, so should use this parameter to find out what happened. The plugin can also change this value to, for example, make a failed op pass, or to tell winsync to make a successful op fail (it will not roll back the op in this case though, but the plugin can tell winsync to stop on this op). There are also new callbacks for AD user/group add for ticket 70. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: yes - doc the new functions
commit 0610f9a7495b5cc995796e8a0bbaa6bc61449c33 Author: Rich Megginson <[email protected]> Date: Tue Mar 27 14:07:16 2012 -0600 Ticket #316 and Ticket #70 - add post add/mod and AD add callback hooks https://fedorahosted.org/389/ticket/316 https://fedorahosted.org/389/ticket/70 Resolves: Ticket #316 and Ticket #70 Bug Description: Add user post callback hook to winsync plugin API Bug Description: Winsync API should have callback functions for new entries sync to AD Reviewed by: nkinder (Thanks!) Branch: master Fix Description: New callbacks for all post-add and post-modify (both to and from AD) operations. All post op callbacks have an int *return parameter. This parameter is the ldap result code from the add/mod op. The plugin will be called upon op success or failure, so should use this parameter to find out what happened. The plugin can also change this value to, for example, make a failed op pass, or to tell winsync to make a successful op fail (it will not roll back the op in this case though, but the plugin can tell winsync to stop on this op). There are also new callbacks for AD user/group add for ticket 70. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: yes - doc the new functions diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c index 6c19e4ab2..72cb7213f 100644 --- a/ldap/servers/plugins/replication/windows_private.c +++ b/ldap/servers/plugins/replication/windows_private.c @@ -1019,6 +1019,10 @@ windows_private_set_sync_interval(Repl_Agmt *ra, char *str) /* an array of function pointers */ static void **_WinSyncAPI = NULL; +static int maxapiidx = WINSYNC_PLUGIN_VERSION_1_END; +#define DECL_WINSYNC_API_FUNC(idx,thetype,thefunc) \ + thetype thefunc = (_WinSyncAPI && (idx <= maxapiidx) && _WinSyncAPI[idx]) ? \ + (thetype)_WinSyncAPI[idx] : NULL; void windows_plugin_init(Repl_Agmt *ra) @@ -1031,14 +1035,34 @@ windows_plugin_init(Repl_Agmt *ra) /* if the function pointer array is null, get the functions - we will call init once per replication agreement, but will only grab the api once */ - if((NULL == _WinSyncAPI) && - (slapi_apib_get_interface(WINSYNC_v1_0_GUID, &_WinSyncAPI) || - (NULL == _WinSyncAPI))) - { - LDAPDebug1Arg( LDAP_DEBUG_PLUGIN, - "<-- windows_plugin_init_start -- no windows plugin API registered for GUID [%s] -- end\n", - WINSYNC_v1_0_GUID); - return; + if(NULL == _WinSyncAPI) { + if (slapi_apib_get_interface(WINSYNC_v2_0_GUID, &_WinSyncAPI) || + (NULL == _WinSyncAPI)) + { + LDAPDebug1Arg( LDAP_DEBUG_PLUGIN, + "<-- windows_plugin_init_start -- no windows plugin API registered for GUID [%s] -- end\n", + WINSYNC_v2_0_GUID); + } else if (_WinSyncAPI) { + LDAPDebug1Arg( LDAP_DEBUG_PLUGIN, + "<-- windows_plugin_init_start -- found windows plugin API registered for GUID [%s] -- end\n", + WINSYNC_v2_0_GUID); + maxapiidx = WINSYNC_PLUGIN_VERSION_2_END; + } + } + + if (NULL == _WinSyncAPI) { /* no v2 interface - look for v1 */ + if (slapi_apib_get_interface(WINSYNC_v1_0_GUID, &_WinSyncAPI) || + (NULL == _WinSyncAPI)) + { + LDAPDebug1Arg( LDAP_DEBUG_PLUGIN, + "<-- windows_plugin_init_start -- no windows plugin API registered for GUID [%s] -- end\n", + WINSYNC_v1_0_GUID); + return; + } else { + LDAPDebug1Arg( LDAP_DEBUG_PLUGIN, + "<-- windows_plugin_init_start -- found windows plugin API registered for GUID [%s] -- end\n", + WINSYNC_v1_0_GUID); + } } initfunc = (winsync_plugin_init_cb)_WinSyncAPI[WINSYNC_PLUGIN_INIT_CB]; @@ -1057,10 +1081,7 @@ winsync_plugin_call_dirsync_search_params_cb(const Repl_Agmt *ra, const char *ag char **base, int *scope, char **filter, char ***attrs, LDAPControl ***serverctrls) { - winsync_search_params_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_DIRSYNC_SEARCH_CB]) ? - (winsync_search_params_cb)_WinSyncAPI[WINSYNC_PLUGIN_DIRSYNC_SEARCH_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_DIRSYNC_SEARCH_CB,winsync_search_params_cb,thefunc); if (!thefunc) { return; @@ -1077,10 +1098,7 @@ winsync_plugin_call_pre_ad_search_cb(const Repl_Agmt *ra, const char *agmt_dn, char **base, int *scope, char **filter, char ***attrs, LDAPControl ***serverctrls) { - winsync_search_params_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_SEARCH_CB]) ? - (winsync_search_params_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_SEARCH_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_AD_SEARCH_CB,winsync_search_params_cb,thefunc); if (!thefunc) { return; @@ -1097,10 +1115,7 @@ winsync_plugin_call_pre_ds_search_entry_cb(const Repl_Agmt *ra, const char *agmt char **base, int *scope, char **filter, char ***attrs, LDAPControl ***serverctrls) { - winsync_search_params_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_SEARCH_ENTRY_CB]) ? - (winsync_search_params_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_SEARCH_ENTRY_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_DS_SEARCH_ENTRY_CB,winsync_search_params_cb,thefunc); if (!thefunc) { return; @@ -1117,10 +1132,7 @@ winsync_plugin_call_pre_ds_search_all_cb(const Repl_Agmt *ra, const char *agmt_d char **base, int *scope, char **filter, char ***attrs, LDAPControl ***serverctrls) { - winsync_search_params_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_SEARCH_ALL_CB]) ? - (winsync_search_params_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_SEARCH_ALL_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_DS_SEARCH_ALL_CB,winsync_search_params_cb,thefunc); if (!thefunc) { return; @@ -1137,10 +1149,7 @@ winsync_plugin_call_pre_ad_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *r Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *do_modify) { - winsync_pre_mod_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_MOD_USER_CB]) ? - (winsync_pre_mod_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_MOD_USER_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_AD_MOD_USER_CB,winsync_pre_mod_cb,thefunc); if (!thefunc) { return; @@ -1157,10 +1166,7 @@ winsync_plugin_call_pre_ad_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry * Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *do_modify) { - winsync_pre_mod_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_MOD_GROUP_CB]) ? - (winsync_pre_mod_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_MOD_GROUP_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_AD_MOD_GROUP_CB,winsync_pre_mod_cb,thefunc); if (!thefunc) { return; @@ -1177,10 +1183,7 @@ winsync_plugin_call_pre_ds_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *r Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *do_modify) { - winsync_pre_mod_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_MOD_USER_CB]) ? - (winsync_pre_mod_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_MOD_USER_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_DS_MOD_USER_CB,winsync_pre_mod_cb,thefunc); if (!thefunc) { return; @@ -1197,10 +1200,7 @@ winsync_plugin_call_pre_ds_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry * Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *do_modify) { - winsync_pre_mod_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_MOD_GROUP_CB]) ? - (winsync_pre_mod_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_MOD_GROUP_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_DS_MOD_GROUP_CB,winsync_pre_mod_cb,thefunc); if (!thefunc) { return; @@ -1216,10 +1216,7 @@ void winsync_plugin_call_pre_ds_add_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry) { - winsync_pre_add_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_ADD_USER_CB]) ? - (winsync_pre_add_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_ADD_USER_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_DS_ADD_USER_CB,winsync_pre_add_cb,thefunc); if (!thefunc) { return; @@ -1235,10 +1232,7 @@ void winsync_plugin_call_pre_ds_add_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry) { - winsync_pre_add_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_ADD_GROUP_CB]) ? - (winsync_pre_add_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_DS_ADD_GROUP_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_DS_ADD_GROUP_CB,winsync_pre_add_cb,thefunc); if (!thefunc) { return; @@ -1255,10 +1249,7 @@ winsync_plugin_call_get_new_ds_user_dn_cb(const Repl_Agmt *ra, const Slapi_Entry Slapi_Entry *ad_entry, char **new_dn_string, const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix) { - winsync_get_new_dn_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_GET_NEW_DS_USER_DN_CB]) ? - (winsync_get_new_dn_cb)_WinSyncAPI[WINSYNC_PLUGIN_GET_NEW_DS_USER_DN_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_GET_NEW_DS_USER_DN_CB,winsync_get_new_dn_cb,thefunc); if (!thefunc) { return; @@ -1275,10 +1266,7 @@ winsync_plugin_call_get_new_ds_group_dn_cb(const Repl_Agmt *ra, const Slapi_Entr Slapi_Entry *ad_entry, char **new_dn_string, const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix) { - winsync_get_new_dn_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_GET_NEW_DS_GROUP_DN_CB]) ? - (winsync_get_new_dn_cb)_WinSyncAPI[WINSYNC_PLUGIN_GET_NEW_DS_GROUP_DN_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_GET_NEW_DS_GROUP_DN_CB,winsync_get_new_dn_cb,thefunc); if (!thefunc) { return; @@ -1297,10 +1285,7 @@ winsync_plugin_call_pre_ad_mod_user_mods_cb(const Repl_Agmt *ra, const Slapi_Ent LDAPMod * const *origmods, Slapi_DN *remote_dn, LDAPMod ***modstosend) { - winsync_pre_ad_mod_mods_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_MOD_USER_MODS_CB]) ? - (winsync_pre_ad_mod_mods_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_MOD_USER_MODS_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_AD_MOD_USER_MODS_CB,winsync_pre_ad_mod_mods_cb,thefunc); if (!thefunc) { return; @@ -1319,10 +1304,7 @@ winsync_plugin_call_pre_ad_mod_group_mods_cb(const Repl_Agmt *ra, const Slapi_En LDAPMod * const *origmods, Slapi_DN *remote_dn, LDAPMod ***modstosend) { - winsync_pre_ad_mod_mods_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_MOD_GROUP_MODS_CB]) ? - (winsync_pre_ad_mod_mods_cb)_WinSyncAPI[WINSYNC_PLUGIN_PRE_AD_MOD_GROUP_MODS_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_AD_MOD_GROUP_MODS_CB,winsync_pre_ad_mod_mods_cb,thefunc); if (!thefunc) { return; @@ -1338,10 +1320,7 @@ int winsync_plugin_call_can_add_entry_to_ad_cb(const Repl_Agmt *ra, const Slapi_Entry *local_entry, const Slapi_DN *remote_dn) { - winsync_can_add_to_ad_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_CAN_ADD_ENTRY_TO_AD_CB]) ? - (winsync_can_add_to_ad_cb)_WinSyncAPI[WINSYNC_PLUGIN_CAN_ADD_ENTRY_TO_AD_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_CAN_ADD_ENTRY_TO_AD_CB,winsync_can_add_to_ad_cb,thefunc); if (!thefunc) { return 1; /* default is entry can be added to AD */ @@ -1354,10 +1333,7 @@ void winsync_plugin_call_begin_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree, const Slapi_DN *ad_subtree, int is_total) { - winsync_plugin_update_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_BEGIN_UPDATE_CB]) ? - (winsync_plugin_update_cb)_WinSyncAPI[WINSYNC_PLUGIN_BEGIN_UPDATE_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_BEGIN_UPDATE_CB,winsync_plugin_update_cb,thefunc); if (!thefunc) { return; @@ -1372,10 +1348,7 @@ void winsync_plugin_call_end_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree, const Slapi_DN *ad_subtree, int is_total) { - winsync_plugin_update_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_END_UPDATE_CB]) ? - (winsync_plugin_update_cb)_WinSyncAPI[WINSYNC_PLUGIN_END_UPDATE_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_END_UPDATE_CB,winsync_plugin_update_cb,thefunc); if (!thefunc) { return; @@ -1391,10 +1364,7 @@ winsync_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree, const Slapi_DN *ad_subtree) { - winsync_plugin_destroy_agmt_cb thefunc = - (_WinSyncAPI && _WinSyncAPI[WINSYNC_PLUGIN_DESTROY_AGMT_CB]) ? - (winsync_plugin_destroy_agmt_cb)_WinSyncAPI[WINSYNC_PLUGIN_DESTROY_AGMT_CB] : - NULL; + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_DESTROY_AGMT_CB,winsync_plugin_destroy_agmt_cb,thefunc); if (thefunc) { (*thefunc)(windows_private_get_api_cookie(ra), ds_subtree, ad_subtree); @@ -1403,6 +1373,204 @@ winsync_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra, return; } +void +winsync_plugin_call_post_ad_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, + Slapi_Mods *smods, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_AD_MOD_USER_CB,winsync_post_mod_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), rawentry, ad_entry, + ds_entry, smods, result); + + return; +} + +void +winsync_plugin_call_post_ad_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, + Slapi_Mods *smods, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_AD_MOD_GROUP_CB,winsync_post_mod_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), rawentry, ad_entry, + ds_entry, smods, result); + + return; +} + +void +winsync_plugin_call_post_ds_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, + Slapi_Mods *smods, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_DS_MOD_USER_CB,winsync_post_mod_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), rawentry, ad_entry, + ds_entry, smods, result); + + return; +} + +void +winsync_plugin_call_post_ds_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, + Slapi_Mods *smods, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_DS_MOD_GROUP_CB,winsync_post_mod_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), rawentry, ad_entry, + ds_entry, smods, result); + + return; +} + +void +winsync_plugin_call_post_ds_add_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_DS_ADD_USER_CB,winsync_post_add_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), rawentry, ad_entry, + ds_entry, result); + + return; +} + +void +winsync_plugin_call_post_ds_add_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_DS_ADD_GROUP_CB,winsync_post_add_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), rawentry, ad_entry, + ds_entry, result); + + return; +} + +void +winsync_plugin_call_pre_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry, + Slapi_Entry *ds_entry) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_AD_ADD_USER_CB,winsync_pre_ad_add_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), ad_entry, ds_entry); + + return; +} + +void +winsync_plugin_call_pre_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry, + Slapi_Entry *ds_entry) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_PRE_AD_ADD_GROUP_CB,winsync_pre_ad_add_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), ad_entry, ds_entry); + + return; +} + +void +winsync_plugin_call_post_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry, + Slapi_Entry *ds_entry, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_AD_ADD_USER_CB,winsync_post_ad_add_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), ad_entry, ds_entry, result); + + return; +} + +void +winsync_plugin_call_post_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry, + Slapi_Entry *ds_entry, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_AD_ADD_GROUP_CB,winsync_post_ad_add_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), ad_entry, ds_entry, result); + + return; +} + +void +winsync_plugin_call_post_ad_mod_user_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + const Slapi_DN *local_dn, + const Slapi_Entry *ds_entry, + LDAPMod * const *origmods, + Slapi_DN *remote_dn, LDAPMod **modstosend, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_AD_MOD_USER_MODS_CB,winsync_post_ad_mod_mods_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), rawentry, local_dn, + ds_entry, origmods, remote_dn, modstosend, result); + + return; +} + +void +winsync_plugin_call_post_ad_mod_group_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + const Slapi_DN *local_dn, + const Slapi_Entry *ds_entry, + LDAPMod * const *origmods, + Slapi_DN *remote_dn, LDAPMod **modstosend, int *result) +{ + DECL_WINSYNC_API_FUNC(WINSYNC_PLUGIN_POST_AD_MOD_GROUP_MODS_CB,winsync_post_ad_mod_mods_cb,thefunc); + + if (!thefunc) { + return; + } + + (*thefunc)(windows_private_get_api_cookie(ra), rawentry, local_dn, + ds_entry, origmods, remote_dn, modstosend, result); + + return; +} + /* #define WINSYNC_TEST_IPA */ #ifdef WINSYNC_TEST_IPA diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c index a1b012c27..d42cd9689 100644 --- a/ldap/servers/plugins/replication/windows_protocol_util.c +++ b/ldap/servers/plugins/replication/windows_protocol_util.c @@ -80,7 +80,7 @@ static const char* op2string (int op); static int is_subject_of_agreement_remote(Slapi_Entry *e, const Repl_Agmt *ra); static int map_entry_dn_inbound(Slapi_Entry *e, Slapi_DN **dn, const Repl_Agmt *ra); static int map_entry_dn_inbound_ext(Slapi_Entry *e, Slapi_DN **dn, const Repl_Agmt *ra, int use_guid, int user_username); -static int windows_update_remote_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry,Slapi_Entry *local_entry); +static int windows_update_remote_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry,Slapi_Entry *local_entry,int is_user); static int is_guid_dn(Slapi_DN *remote_dn); static int map_windows_tombstone_dn(Slapi_Entry *e, Slapi_DN **dn, Private_Repl_Protocol *prp, int *exists); static int windows_check_mods_for_rdn_change(Private_Repl_Protocol *prp, LDAPMod **original_mods, @@ -1184,6 +1184,13 @@ process_replay_add(Private_Repl_Protocol *prp, Slapi_Entry *add_entry, Slapi_Ent /* Convert entry to mods */ if (0 == rc && mapped_entry) { + if (is_user) { + winsync_plugin_call_pre_ad_add_user_cb(prp->agmt, mapped_entry, add_entry); + } else { + winsync_plugin_call_pre_ad_add_group_cb(prp->agmt, mapped_entry, add_entry); + } + /* plugin may reset DN */ + slapi_sdn_copy(slapi_entry_get_sdn(mapped_entry), remote_dn); (void)slapi_entry2mods (mapped_entry , NULL /* &entrydn : We don't need it */, &entryattrs); slapi_entry_free(mapped_entry); mapped_entry = NULL; @@ -1196,9 +1203,29 @@ process_replay_add(Private_Repl_Protocol *prp, Slapi_Entry *add_entry, Slapi_Ent } else { + int ldap_op = 0; + int ldap_result_code = 0; windows_log_add_entry_remote(local_dn, remote_dn); return_value = windows_conn_send_add(prp->conn, slapi_sdn_get_dn(remote_dn), entryattrs, NULL, NULL); + windows_conn_get_error(prp->conn, &ldap_op, &ldap_result_code); + if ((return_value != CONN_OPERATION_SUCCESS) && !ldap_result_code) { + /* op failed but no ldap error code ??? */ + ldap_result_code = LDAP_OPERATIONS_ERROR; + } + if (is_user) { + winsync_plugin_call_post_ad_add_user_cb(prp->agmt, mapped_entry, add_entry, &ldap_result_code); + } else { + winsync_plugin_call_post_ad_add_group_cb(prp->agmt, mapped_entry, add_entry, &ldap_result_code); + } + /* see if plugin reset success/error condition */ + if ((return_value != CONN_OPERATION_SUCCESS) && !ldap_result_code) { + return_value = CONN_OPERATION_SUCCESS; + windows_conn_set_error(prp->conn, ldap_result_code); + } else if ((return_value == CONN_OPERATION_SUCCESS) && ldap_result_code) { + return_value = CONN_OPERATION_FAILED; + windows_conn_set_error(prp->conn, ldap_result_code); + } /* It's possible that the entry already exists in AD, in which * case we fall back to modify it */ /* NGK - This fallback doesn't seem to happen, at least not at this point @@ -1229,7 +1256,7 @@ modify_fallback: /* Fetch the remote entry */ rc = windows_get_remote_entry(prp, remote_dn,&remote_entry); if (0 == rc && remote_entry) { - return_value = windows_update_remote_entry(prp,remote_entry,local_entry); + return_value = windows_update_remote_entry(prp,remote_entry,local_entry,is_user); } if (remote_entry) { @@ -1546,6 +1573,8 @@ windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op return_value = CONN_OPERATION_SUCCESS; } else { + int ldap_op = 0; + int ldap_result_code = 0; if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { int i = 0; @@ -1556,6 +1585,32 @@ windows_replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op } } return_value = windows_conn_send_modify(prp->conn, slapi_sdn_get_dn(remote_dn), mapped_mods, NULL, NULL /* returned controls */); + windows_conn_get_error(prp->conn, &ldap_op, &ldap_result_code); + if ((return_value != CONN_OPERATION_SUCCESS) && !ldap_result_code) { + /* op failed but no ldap error code ??? */ + ldap_result_code = LDAP_OPERATIONS_ERROR; + } + if (is_user) { + winsync_plugin_call_post_ad_mod_user_mods_cb(prp->agmt, + windows_private_get_raw_entry(prp->agmt), + local_dn, local_entry, + op->p.p_modify.modify_mods, + remote_dn, mapped_mods, &ldap_result_code); + } else if (is_group) { + winsync_plugin_call_post_ad_mod_group_mods_cb(prp->agmt, + windows_private_get_raw_entry(prp->agmt), + local_dn, local_entry, + op->p.p_modify.modify_mods, + remote_dn, mapped_mods, &ldap_result_code); + } + /* see if plugin reset success/error condition */ + if ((return_value != CONN_OPERATION_SUCCESS) && !ldap_result_code) { + return_value = CONN_OPERATION_SUCCESS; + windows_conn_set_error(prp->conn, ldap_result_code); + } else if ((return_value == CONN_OPERATION_SUCCESS) && ldap_result_code) { + return_value = CONN_OPERATION_FAILED; + windows_conn_set_error(prp->conn, ldap_result_code); + } } if (mapped_mods) { @@ -3872,6 +3927,7 @@ windows_create_local_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry, int rc = 0; char *guid_str = NULL; int is_nt4 = windows_private_get_isnt4(prp->agmt); + Slapi_Entry *post_entry = NULL; char *local_user_entry_template = "dn: %s\n" @@ -3996,11 +4052,23 @@ windows_create_local_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry, /* Store it */ windows_dump_entry("Adding new local entry",local_entry); pb = slapi_pblock_new(); - slapi_add_entry_internal_set_pb(pb, local_entry, NULL,repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION),0); + slapi_add_entry_internal_set_pb(pb, local_entry, NULL,repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION),0); + post_entry = slapi_entry_dup(local_entry); slapi_add_internal_pb(pb); local_entry = NULL; /* consumed by add */ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &retval); + if (is_user) { + winsync_plugin_call_post_ds_add_user_cb(prp->agmt, + windows_private_get_raw_entry(prp->agmt), + remote_entry, post_entry, &retval); + } else if (is_group) { + winsync_plugin_call_post_ds_add_group_cb(prp->agmt, + windows_private_get_raw_entry(prp->agmt), + remote_entry, post_entry, &retval); + } + slapi_entry_free(post_entry); + if (retval) { slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name, "add operation of entry %s returned: %d\n", slapi_sdn_get_dn(local_sdn), retval); @@ -4429,11 +4497,13 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr } static int -windows_update_remote_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry,Slapi_Entry *local_entry) +windows_update_remote_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry,Slapi_Entry *local_entry, int is_user) { Slapi_Mods smods = {0}; int retval = 0; int do_modify = 0; + int ldap_op = 0; + int ldap_result_code = 0; slapi_mods_init (&smods, 0); retval = windows_generate_update_mods(prp,local_entry,remote_entry,1,&smods,&do_modify); @@ -4446,6 +4516,33 @@ windows_update_remote_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry "windows_update_remote_entry: modifying entry %s\n", escape_string(dn, dnbuf)); retval = windows_conn_send_modify(prp->conn, slapi_sdn_get_dn(slapi_entry_get_sdn_const(remote_entry)),slapi_mods_get_ldapmods_byref(&smods), NULL,NULL); + + windows_conn_get_error(prp->conn, &ldap_op, &ldap_result_code); + if ((retval != CONN_OPERATION_SUCCESS) && !ldap_result_code) { + /* op failed but no ldap error code ??? */ + ldap_result_code = LDAP_OPERATIONS_ERROR; + } + if (is_user) { + winsync_plugin_call_post_ad_mod_user_cb(prp->agmt, + windows_private_get_raw_entry(prp->agmt), + remote_entry, /* the cooked ad entry */ + local_entry, /* the ds entry */ + &smods, &ldap_result_code); + } else { + winsync_plugin_call_post_ad_mod_group_cb(prp->agmt, + windows_private_get_raw_entry(prp->agmt), + remote_entry, /* the cooked ad entry */ + local_entry, /* the ds entry */ + &smods, &ldap_result_code); + } + /* see if plugin reset success/error condition */ + if ((retval != CONN_OPERATION_SUCCESS) && !ldap_result_code) { + retval = CONN_OPERATION_SUCCESS; + windows_conn_set_error(prp->conn, ldap_result_code); + } else if ((retval == CONN_OPERATION_SUCCESS) && ldap_result_code) { + retval = CONN_OPERATION_FAILED; + windows_conn_set_error(prp->conn, ldap_result_code); + } } else { char dnbuf[BUFSIZ]; @@ -4453,7 +4550,8 @@ windows_update_remote_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name, "no mods generated for remote entry: %s\n", escape_string(dn, dnbuf)); } - slapi_mods_done(&smods); + + slapi_mods_done(&smods); return retval; } @@ -4572,6 +4670,19 @@ windows_update_local_entry(Private_Repl_Protocol *prp,Slapi_Entry *remote_entry, repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION), 0); slapi_modify_internal_pb (pb); slapi_pblock_get (pb, SLAPI_PLUGIN_INTOP_RESULT, &rc); + if (is_user) { + winsync_plugin_call_post_ds_mod_user_cb(prp->agmt, + windows_private_get_raw_entry(prp->agmt), + remote_entry, /* the cooked ad entry */ + local_entry, /* the ds entry */ + &smods, &rc); + } else if (is_group) { + winsync_plugin_call_post_ds_mod_group_cb(prp->agmt, + windows_private_get_raw_entry(prp->agmt), + remote_entry, /* the cooked ad entry */ + local_entry, /* the ds entry */ + &smods, &rc); + } if (rc) { slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name, @@ -4624,11 +4735,17 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r } } /* Convert entry to mods */ + windows_is_local_entry_user_or_group(e, &is_user, NULL); if (0 == retval && mapped_entry) { + if (is_user) { + winsync_plugin_call_pre_ad_add_user_cb(prp->agmt, mapped_entry, e); + } else { + winsync_plugin_call_pre_ad_add_group_cb(prp->agmt, mapped_entry, e); + } + /* plugin may reset DN */ + slapi_sdn_copy(slapi_entry_get_sdn(mapped_entry), remote_dn); (void)slapi_entry2mods (mapped_entry , NULL /* &entrydn : We don't need it */, &entryattrs); - slapi_entry_free(mapped_entry); - mapped_entry = NULL; if (NULL == entryattrs) { slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name,"%s: windows_replay_update: Cannot convert entry to LDAPMods.\n",agmt_get_long_name(prp->agmt)); @@ -4636,8 +4753,28 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r } else { + int ldap_op = 0; + int ldap_result_code = 0; windows_log_add_entry_remote(local_dn, remote_dn); retval = windows_conn_send_add(prp->conn, slapi_sdn_get_dn(remote_dn), entryattrs, NULL, NULL /* returned controls */); + windows_conn_get_error(prp->conn, &ldap_op, &ldap_result_code); + if ((retval != CONN_OPERATION_SUCCESS) && !ldap_result_code) { + /* op failed but no ldap error code ??? */ + ldap_result_code = LDAP_OPERATIONS_ERROR; + } + if (is_user) { + winsync_plugin_call_post_ad_add_user_cb(prp->agmt, mapped_entry, e, &ldap_result_code); + } else { + winsync_plugin_call_post_ad_add_group_cb(prp->agmt, mapped_entry, e, &ldap_result_code); + } + /* see if plugin reset success/error condition */ + if ((retval != CONN_OPERATION_SUCCESS) && !ldap_result_code) { + retval = CONN_OPERATION_SUCCESS; + windows_conn_set_error(prp->conn, ldap_result_code); + } else if ((retval == CONN_OPERATION_SUCCESS) && ldap_result_code) { + retval = CONN_OPERATION_FAILED; + windows_conn_set_error(prp->conn, ldap_result_code); + } /* It's possible that the entry already exists in AD, in which case we fall back to modify it */ if (retval) { @@ -4646,7 +4783,6 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r ldap_mods_free(entryattrs, 1); entryattrs = NULL; - windows_is_local_entry_user_or_group(e, &is_user, NULL); if ((retval == 0) && is_user) { /* set the account control bits only for users */ retval = send_accountcontrol_modify(remote_dn, prp, missing_entry); @@ -4660,7 +4796,7 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r retval = windows_get_remote_entry(prp, remote_dn,&remote_entry); if (0 == retval && remote_entry) { - retval = windows_update_remote_entry(prp,remote_entry,e); + retval = windows_update_remote_entry(prp,remote_entry,e,is_user); /* Detect the case where the error is benign */ if (retval) { @@ -4679,6 +4815,8 @@ windows_process_total_add(Private_Repl_Protocol *prp,Slapi_Entry *e, Slapi_DN* r slapi_entry_free(remote_entry); } } + slapi_entry_free(mapped_entry); + mapped_entry = NULL; slapi_ch_free_string(&password); return retval; } diff --git a/ldap/servers/plugins/replication/windowsrepl.h b/ldap/servers/plugins/replication/windowsrepl.h index 52b8dac71..7da855c0d 100644 --- a/ldap/servers/plugins/replication/windowsrepl.h +++ b/ldap/servers/plugins/replication/windowsrepl.h @@ -179,6 +179,41 @@ void winsync_plugin_call_end_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_s void winsync_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree, const Slapi_DN *ad_subtree); +void winsync_plugin_call_post_ad_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, + Slapi_Mods *smods, int *result); +void winsync_plugin_call_post_ad_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, + Slapi_Mods *smods, int *result); +void winsync_plugin_call_post_ds_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, + Slapi_Mods *smods, int *result); +void winsync_plugin_call_post_ds_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, + Slapi_Mods *smods, int *result); +void winsync_plugin_call_post_ds_add_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result); +void winsync_plugin_call_post_ds_add_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result); +void winsync_plugin_call_pre_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry, + Slapi_Entry *ds_entry); +void winsync_plugin_call_pre_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry, + Slapi_Entry *ds_entry); +void winsync_plugin_call_post_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry, + Slapi_Entry *ds_entry, int *result); +void winsync_plugin_call_post_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry, + Slapi_Entry *ds_entry, int *result); +void winsync_plugin_call_post_ad_mod_user_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + const Slapi_DN *local_dn, + const Slapi_Entry *ds_entry, + LDAPMod * const *origmods, + Slapi_DN *remote_dn, LDAPMod **modstosend, int *result); +void winsync_plugin_call_post_ad_mod_group_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, + const Slapi_DN *local_dn, + const Slapi_Entry *ds_entry, + LDAPMod * const *origmods, + Slapi_DN *remote_dn, LDAPMod **modstosend, int *result); + /* Call stack for all places where windows_LDAPMessage2Entry is called: diff --git a/ldap/servers/plugins/replication/winsync-plugin.h b/ldap/servers/plugins/replication/winsync-plugin.h index e70c4a943..9ac5621ec 100644 --- a/ldap/servers/plugins/replication/winsync-plugin.h +++ b/ldap/servers/plugins/replication/winsync-plugin.h @@ -49,6 +49,7 @@ * WinSync plug-in API */ #define WINSYNC_v1_0_GUID "CDA8F029-A3C6-4EBB-80B8-A2E183DB0481" +#define WINSYNC_v2_0_GUID "706B83AA-FC51-444A-ACC9-53DC73D641D4" /* * This callback is called when a winsync agreement is created. @@ -60,6 +61,8 @@ */ typedef void * (*winsync_plugin_init_cb)(const Slapi_DN *ds_subtree, const Slapi_DN *ad_subtree); #define WINSYNC_PLUGIN_INIT_CB 1 +#define WINSYNC_PLUGIN_VERSION_1_BEGIN WINSYNC_PLUGIN_INIT_CB + /* agmt_dn - const - the original AD base dn from the winsync agreement scope - set directly e.g. *scope = 42; base, filter - malloced - to set, free first e.g. @@ -184,12 +187,99 @@ typedef void (*winsync_plugin_update_cb)(void *cookie, const Slapi_DN *ds_subtre */ typedef void (*winsync_plugin_destroy_agmt_cb)(void *cookie, const Slapi_DN *ds_subtree, const Slapi_DN *ad_subtree); #define WINSYNC_PLUGIN_DESTROY_AGMT_CB 19 +#define WINSYNC_PLUGIN_VERSION_1_END WINSYNC_PLUGIN_DESTROY_AGMT_CB + +/* Functions added for API version 2.0 */ +/* + * These callbacks are called after a modify operation. They are called upon both + * success and failure of the modify operation. The plugin is responsible for + * looking at the result code of the modify to decide what action to take. The + * plugin may change the result code e.g. to force an error for an otherwise + * successful operation, or to ignore certain errors. + * rawentry - the raw AD entry, read directly from AD - this is read only + * ad_entry - the "cooked" AD entry - the entry passed to the pre_mod callback + * ds_entry - the entry from the ds - the DS entry passed to the pre_mod callback + * smods - the mods used in the modify operation + * result - the result code from the modify operation - the plugin can change this + */ +typedef void (*winsync_post_mod_cb)(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result); +#define WINSYNC_PLUGIN_POST_AD_MOD_USER_CB 20 +#define WINSYNC_PLUGIN_POST_AD_MOD_GROUP_CB 21 +#define WINSYNC_PLUGIN_POST_DS_MOD_USER_CB 22 +#define WINSYNC_PLUGIN_POST_DS_MOD_GROUP_CB 23 + +#define WINSYNC_PLUGIN_VERSION_2_BEGIN WINSYNC_PLUGIN_POST_AD_MOD_USER_CB +/* + * These callbacks are called after an attempt to add a new entry to the + * local directory server from AD. They are called upon success or failure + * of the add attempt. The result code tells if the operation succeeded. + * The plugin may change the result code e.g. to force an error for an + * otherwise successful operation, or to ignore certain errors. + * rawentry - the raw AD entry, read directly from AD - this is read only + * ad_entry - the "cooked" AD entry + * ds_entry - the entry attempted to be added to the DS + * result - the result code from the add operation - plugin may change this + */ +typedef void (*winsync_post_add_cb)(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result); +#define WINSYNC_PLUGIN_POST_DS_ADD_USER_CB 24 +#define WINSYNC_PLUGIN_POST_DS_ADD_GROUP_CB 25 +/* + * These callbacks are called when a new entry is being added to AD from + * the local directory server. + * ds_entry - the local DS entry + * ad_entry - the entry to be added to AD - all modifications should + * be made to this entry, including changing the DN if needed, + * since the DN of this entry will be used as the ADD target DN + * This entry will already have had the default schema mapping applied +*/ +typedef void (*winsync_pre_ad_add_cb)(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry); +#define WINSYNC_PLUGIN_PRE_AD_ADD_USER_CB 26 +#define WINSYNC_PLUGIN_PRE_AD_ADD_GROUP_CB 27 + +/* + * These callbacks are called after an attempt to add a new entry to AD from + * the local directory server. They are called upon success or failure + * of the add attempt. The result code tells if the operation succeeded. + * The plugin may change the result code e.g. to force an error for an + * otherwise successful operation, or to ignore certain errors. + * ad_entry - the AD entry + * ds_entry - the DS entry + * result - the result code from the add operation - plugin may change this + */ +typedef void (*winsync_post_ad_add_cb)(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry, int *result); +#define WINSYNC_PLUGIN_POST_AD_ADD_USER_CB 28 +#define WINSYNC_PLUGIN_POST_AD_ADD_GROUP_CB 29 + +/* + * These callbacks are called after a mod operation has been replayed + * to AD. This case is different than the pre add or pre mod callbacks + * above because in this context, we may only have the list of modifications + * and the DN to which the mods were applied. If the plugin wants the modified + * entry, the plugin can search for it from AD. The plugin is called upon + * success or failure of the modify operation. The result parameter gives + * the ldap result code of the operation. The plugin may change the result code + * e.g. to force an error for an otherwise successful operation, or to ignore + * certain errors. + * rawentry - the raw AD entry, read directly from AD - may be NULL + * local_dn - the original local DN used in the modification + * ds_entry - the current DS entry that has the operation nsUniqueID + * origmods - the original mod list + * remote_dn - the DN of the AD entry + * modstosend - the mods sent to AD + * result - the result code of the modify operation + * + */ +typedef void (*winsync_post_ad_mod_mods_cb)(void *cookie, const Slapi_Entry *rawentry, const Slapi_DN *local_dn, const Slapi_Entry *ds_entry, LDAPMod * const *origmods, Slapi_DN *remote_dn, LDAPMod **modstosend, int *result); +#define WINSYNC_PLUGIN_POST_AD_MOD_USER_MODS_CB 30 +#define WINSYNC_PLUGIN_POST_AD_MOD_GROUP_MODS_CB 31 +#define WINSYNC_PLUGIN_VERSION_2_END WINSYNC_PLUGIN_POST_AD_MOD_GROUP_MODS_CB /* The following are sample code stubs to show how to implement a plugin which uses this api */ +/* #define WINSYNC_SAMPLE_CODE */ #ifdef WINSYNC_SAMPLE_CODE #include "slapi-plugin.h" @@ -373,13 +463,13 @@ test_winsync_get_new_ds_user_dn_cb(void *cbdata, const Slapi_Entry *rawentry, rdns = slapi_ldap_explode_dn(*new_dn_string, 0); if (!rdns || !rdns[0]) { - ldap_value_free(rdns); + slapi_ldap_value_free(rdns); return; } slapi_ch_free_string(new_dn_string); *new_dn_string = PR_smprintf("%s,%s", rdns[0], slapi_sdn_get_dn(ds_suffix)); - ldap_value_free(rdns); + slapi_ldap_value_free(rdns); slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, "<-- test_winsync_get_new_ds_user_dn_cb -- new dn [%s] -- end\n", @@ -442,7 +532,8 @@ test_winsync_can_add_entry_to_ad_cb(void *cbdata, const Slapi_Entry *local_entry slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, "<-- test_winsync_can_add_entry_to_ad_cb -- end\n"); - return 0; /* false - do not allow entries to be added to ad */ + /* return 0;*/ /* false - do not allow entries to be added to ad */ + return 1; /* true - allow entries to be added to ad */ } static void @@ -486,6 +577,200 @@ test_winsync_destroy_agmt_cb(void *cbdata, const Slapi_DN *ds_subtree, return; } +static void +test_winsync_post_ad_mod_user_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ad_mod_user_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of modifying AD entry [%s] was [%d:%s]\n", + slapi_entry_get_dn(ad_entry), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ad_mod_user_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ad_mod_group_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ad_mod_group_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of modifying AD entry [%s] was [%d:%s]\n", + slapi_entry_get_dn(ad_entry), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ad_mod_group_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ds_mod_user_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ds_mod_user_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of modifying DS entry [%s] was [%d:%s]\n", + slapi_entry_get_dn(ds_entry), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ds_mod_user_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ds_mod_group_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ds_mod_group_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of modifying DS entry [%s] was [%d:%s]\n", + slapi_entry_get_dn(ds_entry), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ds_mod_group_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ds_add_user_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ds_add_user_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of adding DS entry [%s] was [%d:%s]\n", + slapi_entry_get_dn(ds_entry), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ds_add_user_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ds_add_group_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ds_add_group_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of adding DS entry [%s] was [%d:%s]\n", + slapi_entry_get_dn(ds_entry), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ds_add_group_cb -- end\n"); + + return; +} + +static void +test_winsync_pre_ad_add_user_cb(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_pre_ad_add_user_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Adding AD entry [%s] from add of DS entry [%s]\n", + slapi_entry_get_dn(ad_entry), slapi_entry_get_dn(ds_entry)); + /* make modifications to ad_entry here */ + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_pre_ad_add_user_cb -- end\n"); + + return; +} + +static void +test_winsync_pre_ad_add_group_cb(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_pre_ad_add_group_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Adding AD entry [%s] from add of DS entry [%s]\n", + slapi_entry_get_dn(ad_entry), slapi_entry_get_dn(ds_entry)); + /* make modifications to ad_entry here */ + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_pre_ad_add_group_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ad_add_user_cb(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ad_add_user_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of adding AD entry [%s] was [%d:%s]\n", + slapi_entry_get_dn(ad_entry), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ad_add_user_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ad_add_group_cb(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ad_add_group_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of adding AD entry [%s] was [%d:%s]\n", + slapi_entry_get_dn(ad_entry), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ad_add_group_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ad_mod_user_mods_cb(void *cookie, const Slapi_Entry *rawentry, const Slapi_DN *local_dn, const Slapi_Entry *ds_entry, LDAPMod * const *origmods, Slapi_DN *remote_dn, LDAPMod ***modstosend, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ad_mod_user_mods_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of modifying AD entry [%s] was [%d:%s]\n", + slapi_sdn_get_dn(remote_dn), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ad_mod_user_mods_cb -- end\n"); + + return; +} + +static void +test_winsync_post_ad_mod_group_mods_cb(void *cookie, const Slapi_Entry *rawentry, const Slapi_DN *local_dn, const Slapi_Entry *ds_entry, LDAPMod * const *origmods, Slapi_DN *remote_dn, LDAPMod ***modstosend, int *result) +{ + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "--> test_winsync_post_ad_mod_group_mods_cb -- begin\n"); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "Result of modifying AD entry [%s] was [%d:%s]\n", + slapi_sdn_get_dn(remote_dn), *result, ldap_err2string(*result)); + + slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, + "<-- test_winsync_post_ad_mod_group_mods_cb -- end\n"); + + return; +} + /** * Plugin identifiers */ @@ -498,7 +783,8 @@ static Slapi_PluginDesc test_winsync_pdesc = { static Slapi_ComponentId *test_winsync_plugin_id = NULL; -static void *test_winsync_api[] = { +#ifdef TEST_V1_WINSYNC_API +static void *test_winsync_api_v1[] = { NULL, /* reserved for api broker use, must be zero */ test_winsync_api_init, test_winsync_dirsync_search_params_cb, @@ -520,6 +806,42 @@ static void *test_winsync_api[] = { test_winsync_end_update_cb, test_winsync_destroy_agmt_cb }; +#endif /* TEST_V1_WINSYNC_API */ + +static void *test_winsync_api_v2[] = { + NULL, /* reserved for api broker use, must be zero */ + test_winsync_api_init, + test_winsync_dirsync_search_params_cb, + test_winsync_pre_ad_search_cb, + test_winsync_pre_ds_search_entry_cb, + test_winsync_pre_ds_search_all_cb, + test_winsync_pre_ad_mod_user_cb, + test_winsync_pre_ad_mod_group_cb, + test_winsync_pre_ds_mod_user_cb, + test_winsync_pre_ds_mod_group_cb, + test_winsync_pre_ds_add_user_cb, + test_winsync_pre_ds_add_group_cb, + test_winsync_get_new_ds_user_dn_cb, + test_winsync_get_new_ds_group_dn_cb, + test_winsync_pre_ad_mod_user_mods_cb, + test_winsync_pre_ad_mod_group_mods_cb, + test_winsync_can_add_entry_to_ad_cb, + test_winsync_begin_update_cb, + test_winsync_end_update_cb, + test_winsync_destroy_agmt_cb, + test_winsync_post_ad_mod_user_cb, + test_winsync_post_ad_mod_group_cb, + test_winsync_post_ds_mod_user_cb, + test_winsync_post_ds_mod_group_cb, + test_winsync_post_ds_add_user_cb, + test_winsync_post_ds_add_group_cb, + test_winsync_pre_ad_add_user_cb, + test_winsync_pre_ad_add_group_cb, + test_winsync_post_ad_add_user_cb, + test_winsync_post_ad_add_group_cb, + test_winsync_post_ad_mod_user_mods_cb, + test_winsync_post_ad_mod_group_mods_cb +}; static int test_winsync_plugin_start(Slapi_PBlock *pb) @@ -527,7 +849,7 @@ test_winsync_plugin_start(Slapi_PBlock *pb) slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, "--> test_winsync_plugin_start -- begin\n"); - if( slapi_apib_register(WINSYNC_v1_0_GUID, test_winsync_api) ) { + if( slapi_apib_register(WINSYNC_v2_0_GUID, test_winsync_api_v2) ) { slapi_log_error( SLAPI_LOG_FATAL, test_winsync_plugin_name, "<-- test_winsync_plugin_start -- failed to register winsync api -- end\n"); return -1; @@ -544,7 +866,7 @@ test_winsync_plugin_close(Slapi_PBlock *pb) slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, "--> test_winsync_plugin_close -- begin\n"); - slapi_apib_unregister(WINSYNC_v1_0_GUID); + slapi_apib_unregister(WINSYNC_v2_0_GUID); slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name, "<-- test_winsync_plugin_close -- end\n");
0
13f202fba8962b8b0bc6e3dcd777110e758169fe
389ds/389-ds-base
Ticket 49153 - Remove vacuum lock on transaction cleanup Bug Description: Previously we held a vacuum lock to prevent conflicts during transaction clean up. This created a bottleneck. Fix Description: Remove the vacuum lock in favour of a pacman style reference count, where each parent holds a refcount to the child, and decrements it on free. https://pagure.io/389-ds-base/issue/49153 Author: wibrown Review by: mreynolds (Thanks!)
commit 13f202fba8962b8b0bc6e3dcd777110e758169fe Author: William Brown <[email protected]> Date: Mon Apr 3 15:01:06 2017 +1000 Ticket 49153 - Remove vacuum lock on transaction cleanup Bug Description: Previously we held a vacuum lock to prevent conflicts during transaction clean up. This created a bottleneck. Fix Description: Remove the vacuum lock in favour of a pacman style reference count, where each parent holds a refcount to the child, and decrements it on free. https://pagure.io/389-ds-base/issue/49153 Author: wibrown Review by: mreynolds (Thanks!) diff --git a/src/libsds/include/sds.h b/src/libsds/include/sds.h index 1b0dedefb..d8d51d1dc 100644 --- a/src/libsds/include/sds.h +++ b/src/libsds/include/sds.h @@ -549,7 +549,6 @@ typedef struct _sds_bptree_instance { * - read_lock * - write_lock * - tail_txn - * - vacuum_lock * * ### Read Transaction Begin * @@ -589,6 +588,9 @@ typedef struct _sds_bptree_instance { * previous transaction is the last point where they are valid and needed - The last transaction now must * clean up after itself when it's ready to GC! * + * We set our reference count to 2, to indicate that a following node (the previous active transaction) + * relies on us, and that we are also active. + * * We now take the write variant of the rw read_lock. This waits for all in progress read transactions to * begin, and we take exclusive access of this lock. We then pivot the older transaction out with our * transaction. The read_lock is released, and read transactions may now resume. @@ -607,20 +609,20 @@ typedef struct _sds_bptree_instance { * * If the reference count remains positive, we complete, and continue. * - * If the reference count drops to 0, we take the vacuum lock. If our reference count is 0 *and* - * we are the oldest generation of transaction (ie tail_txn), then we free our transaction, and all - * associated owned nodes, values and keys. We update the tail_txn to be the next oldest transaction - * in the chain and repeat the check. + * If the reference count drops to 0, we take a reference to the next transaction in the series, + * and we free our node. We then decrement the reference counter of the next transaction and check + * the result. + * + * Either, the reference count is > 0 because it is the active transaction *or* there is a current + * read transaction. * - * While the tail transaction reference count is 0, and the oldest transaction, we continue to garbage - * collect until we find a live transaction. At this point, we release the vacuum lock and are complete. + * OR, the reference count reaches 0 because there are no active transactions, so we can free this node. + * in the same operation, we then decrement the reference count to the next node in the series, + * and we repeat this til we reach a node with a positive reference count. * - * NOTE: Due to this design, if a reference count is dropped to 0 of the tail_txn, while someone else - * is vacuuming there are two states. Either, the other thread does not ees the reference count drop, and will - * release the vacuum lock, allowing us to take it and contine the garbage collection. Alternately, the other - * thread *does* see the reference count drop, and garbage collects the transaction. In this case, we are blocked - * on the vacuum lock, but because the ref count is 0, and the tail_txn pointer is now a newer generation than - * our transaction id, we do *not* attempt the double free. + * Due to the design of this system, we are guarantee no thread races, as one and only one thread + * can ever set the reference count to 0: either the closing read, or the closing previous transaction. + * This gives us complete thread safety, but without the need for a mutex to ensure this. * * ### Usage of the memory safe properties. * @@ -696,12 +698,6 @@ typedef struct _sds_bptree_cow_instance { * the duration to allow only a single writer. */ pthread_mutex_t *write_lock; - /** - * The vacuum lock. When a transaction final hits a ref count of 0, we have - * to clean from the tail. To do this we need to update the tail_txn of the - * binst atomically. - */ - pthread_mutex_t *vacuum_lock; } sds_bptree_cow_instance; /** diff --git a/src/libsds/sds/bpt_cow/bpt_cow.c b/src/libsds/sds/bpt_cow/bpt_cow.c index 41e5bf67b..7120efcd5 100644 --- a/src/libsds/sds/bpt_cow/bpt_cow.c +++ b/src/libsds/sds/bpt_cow/bpt_cow.c @@ -39,8 +39,6 @@ sds_result sds_bptree_cow_init(sds_bptree_cow_instance **binst_ptr, uint16_t che pthread_rwlock_init((*binst_ptr)->read_lock, NULL); (*binst_ptr)->write_lock = sds_calloc(sizeof(pthread_mutex_t)); pthread_mutex_init((*binst_ptr)->write_lock, NULL); - (*binst_ptr)->vacuum_lock = sds_calloc(sizeof(pthread_mutex_t)); - pthread_mutex_init((*binst_ptr)->vacuum_lock, NULL); /* Take both to be sure of barriers etc. */ pthread_mutex_lock( (*binst_ptr)->write_lock); @@ -98,8 +96,6 @@ sds_result sds_bptree_cow_destroy(sds_bptree_cow_instance *binst) { sds_free(binst->read_lock); pthread_mutex_destroy(binst->write_lock); sds_free(binst->write_lock); - pthread_mutex_destroy(binst->vacuum_lock); - sds_free(binst->vacuum_lock); sds_free(binst->bi); sds_free(binst); diff --git a/src/libsds/sds/bpt_cow/txn.c b/src/libsds/sds/bpt_cow/txn.c index 6dafa8bfd..11451fedd 100644 --- a/src/libsds/sds/bpt_cow/txn.c +++ b/src/libsds/sds/bpt_cow/txn.c @@ -151,7 +151,6 @@ sds_bptree_txn_decrement(sds_bptree_transaction *btxn) { #endif // If the counter is 0 && we are the tail transaction. if (result == 0) { - pthread_mutex_lock(binst->vacuum_lock); while (result == 0 && btxn != NULL && btxn == binst->tail_txn) { #ifdef DEBUG sds_log("sds_bptree_txn_decrement", " txn_%p has reached 0, and is at the tail, vacuumming!", btxn); @@ -161,15 +160,14 @@ sds_bptree_txn_decrement(sds_bptree_transaction *btxn) { // Now, we need to check to see if the next txn is ready to free also .... // I'm not sure if this is okay, as we may not have barriered properly. btxn = binst->tail_txn; - // This isn't an atomic read, but the way that txns work is that - // this will always be >= 1 if this is the alive read, but never - // 0. So we may only "miss" freeing a now zerod txn in this case, - // but we never free "too much"; + // we decrement this txn by 1 to say "there is no more parents behind this" + // as a result, 1 and ONLY ONE thread can be the one to cause this decrement, because + // * there are more parents left, so we are > 0 + // * there are still active holders left, so we are > 0 if (btxn != NULL) { - __atomic_load(&(btxn->reference_count), &result, __ATOMIC_SEQ_CST); + result = __atomic_sub_fetch(&(btxn->reference_count), 1, __ATOMIC_SEQ_CST); } } - pthread_mutex_unlock(binst->vacuum_lock); } #ifdef DEBUG if (btxn != NULL) { @@ -387,8 +385,10 @@ sds_result sds_bptree_cow_wrtxn_commit(sds_bptree_transaction **btxn) { // Take the read lock now at the last possible moment. pthread_rwlock_wrlock((*btxn)->binst->read_lock); - // Say we are alive and commited. - __atomic_add_fetch(&((*btxn)->reference_count), 1, __ATOMIC_SEQ_CST); + // Say we are alive and commited - 2 means "our former transaction owns us" + // and "we are the active root". + uint32_t default_ref_count = 2; + __atomic_store(&((*btxn)->reference_count), &default_ref_count, __ATOMIC_SEQ_CST); // Set it. (*btxn)->binst->txn = *btxn; // Update our parent to reference us.
0
d05836dd5605baa460586e1adf767c4162b2680a
389ds/389-ds-base
Issue 6256 - nsslapd-numlisteners limit is not enforced Description: Add a test to check if nsslapd-numlisteners value can be set higher than 4 Relates: https://github.com/389ds/389-ds-base/issues/6256 Reviewed by: droideck Signed-off-by: Sumedh Sidhaye <[email protected]>
commit d05836dd5605baa460586e1adf767c4162b2680a Author: Sumedh Sidhaye <[email protected]> Date: Tue Jul 16 19:24:39 2024 +0530 Issue 6256 - nsslapd-numlisteners limit is not enforced Description: Add a test to check if nsslapd-numlisteners value can be set higher than 4 Relates: https://github.com/389ds/389-ds-base/issues/6256 Reviewed by: droideck Signed-off-by: Sumedh Sidhaye <[email protected]> diff --git a/dirsrvtests/tests/suites/config/config_test.py b/dirsrvtests/tests/suites/config/config_test.py index 7c0ae5b2c..b85413ce6 100644 --- a/dirsrvtests/tests/suites/config/config_test.py +++ b/dirsrvtests/tests/suites/config/config_test.py @@ -11,6 +11,7 @@ import logging import pytest import os from lib389 import DirSrv, pid_from_file +from lib389.dseldif import DSEldif from lib389.tasks import * from lib389.topologies import topology_m2, topology_st as topo from lib389.utils import * @@ -741,6 +742,56 @@ def test_lmdb_config(create_lmdb_instance): set_and_check(inst, db_config, 'mdb_max_dbs', 'nsslapd-mdb-max-dbs', 200) +def test_numlisteners_limit(topo): + """Test higher limit of nsslapd-numlisteners than 4 + DS allows a higher value of nsslapd-numlisteners than it's limit of 4 + + :id: 96869ea9-c7b4-4a4f-85f9-ea1d3f4a63aa + :setup: Standalone Instance + :steps: + 1. Check default nsslapd-numlisteners value is 1 + 2. Set nsslapd-numlisteners value to 4 + 3. Check nsslapd-numlisteners value is set to 4 + 4. Check dse.ldif value of nsslapd-numlisteners is set to 4 + 5. systemctl restart dirsrv@localhost + 6. Check nsslapd-numlisteners value is 4, after server restart + 7. Check if nsslapd-numlisteners value is still 4 + :expectedresults: + 1. nsslapd-numlisteners config value should show 1 by default + 2. nsslapd-numlisteners value should be successfully set to 4 + 3. nsslapd-numlisteners is indeed set to 4 + 4. nsslapd-numlisteners value in localhost dse.ldif file is set to 4 + 5. restart DS instance is successful + 6. nsslapd-numlisteners value is still 4 after server restart + 7. nsslapd-numlisteners is still 4 even if we try to set it to 5 + """ + # Check default value for nsslapd-numlisteners is 1 + assert topo.standalone.config.get_attr_val_utf8('nsslapd-numlisteners') == '1' + + # Set nsslapd-numlisteners value to 4 + topo.standalone.config.set('nsslapd-numlisteners', '4') + + # Check nsslapd-numlisteners value is set to 4 + assert topo.standalone.config.get_attr_val_utf8('nsslapd-numlisteners') == '4' + + # Check instance dse.ldif value is set to 4 + inst = topo.standalone + dse_ldif = DSEldif(inst) + numlisteners = dse_ldif.get(DN_CONFIG, 'nsslapd-numlisteners') + assert numlisteners[0] == '4' + + # Restart instance + topo.standalone.restart() + + # Check nsslapd-numlisteners value is set to 4 + assert topo.standalone.config.get_attr_val_utf8('nsslapd-numlisteners') == '4' + + # Check if nsslapd-numlisteners value is not set more than 4 + topo.standalone.config.set('nsslapd-numlisteners', '5') + + assert topo.standalone.config.get_attr_val_utf8('nsslapd-numlisteners') == '4' + + if __name__ == '__main__': # Run isolated # -s for DEBUG mode
0
6f0705102374bcff44c24f0d90e7fb4c70e646df
389ds/389-ds-base
593899 - adding specific ACI causes very large mem allocate request https://bugzilla.redhat.com/show_bug.cgi?id=593899 Fix Description: There was a bug if an invalid syntax acl was given (e.g., the value of userdn was not double quoted), normalize_nextACERule mistakenly continued processing the acl and eventually tried to allocate a huge size of memory (since the end address was less than the start address, end - start became negative) and it made the server quit. Added more error handling code to prevent such failures.
commit 6f0705102374bcff44c24f0d90e7fb4c70e646df Author: Noriko Hosoi <[email protected]> Date: Thu May 20 14:55:36 2010 -0700 593899 - adding specific ACI causes very large mem allocate request https://bugzilla.redhat.com/show_bug.cgi?id=593899 Fix Description: There was a bug if an invalid syntax acl was given (e.g., the value of userdn was not double quoted), normalize_nextACERule mistakenly continued processing the acl and eventually tried to allocate a huge size of memory (since the end address was less than the start address, end - start became negative) and it made the server quit. Added more error handling code to prevent such failures. diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c index 80fcfa056..b128ff89e 100644 --- a/ldap/servers/plugins/acl/aclparse.c +++ b/ldap/servers/plugins/acl/aclparse.c @@ -764,7 +764,7 @@ normalize_nextACERule: * " allow (all) groupdn = "ldap:///cn=Domain Administrators,o=$dn.o,o=ISP" */ s = __aclp__getNextLASRule(aci_item, acestr, &end); - while ( s ) { + while ( s && (s < end) ) { if ( (0 == strncmp(s, DS_LAS_USERDNATTR, 10)) || (0 == strncmp(s, DS_LAS_USERATTR, 8)) ) { /* @@ -778,14 +778,15 @@ normalize_nextACERule: if (rc < 0) { goto error; } - } else if ( 0 == strncmp ( s, DS_LAS_USERDN, 6)) { - p = strstr ( s, "="); + } else if ( 0 == strncmp ( s, DS_LAS_USERDN, 6 )) { + p = PL_strnchr (s, '=', end - s); if (NULL == p) { goto error; } p--; - if ( strncmp (p, "!=", 2) == 0) + if ( strncmp (p, "!=", 2) == 0 ) { aci_item->aci_type |= ACI_CONTAIN_NOT_USERDN; + } /* XXXrbyrne * Here we need to scan for more ldap:/// within @@ -830,7 +831,8 @@ normalize_nextACERule: ** we cannot cache the result. See above for more comments. */ /* Find out if we have a URL type of rule */ - if ((p= strstr (s, "ldap")) != NULL) { + p = PL_strnstr (s, "ldap", end - s); + if (NULL != p) { if ( aci_item->aci_elevel > ACI_ELEVEL_GROUPDNATTR_URL ) aci_item->aci_elevel = ACI_ELEVEL_GROUPDNATTR_URL; } else if ( aci_item->aci_elevel > ACI_ELEVEL_GROUPDNATTR ) { @@ -845,7 +847,7 @@ normalize_nextACERule: } } else if ( 0 == strncmp ( s, DS_LAS_GROUPDN, 7)) { - p = strstr ( s, "="); + p = PL_strnchr (s, '=', end - s); if (NULL == p) { goto error; } @@ -868,7 +870,7 @@ normalize_nextACERule: } else if ( 0 == strncmp ( s, DS_LAS_ROLEDN, 6)) { - p = strstr ( s, "="); + p = PL_strnchr (s, '=', end - s); if (NULL == p) { goto error; } @@ -943,21 +945,20 @@ error: static char * __aclp__getNextLASRule (aci_t *aci_item, char *original_str , char **endOfCurrRule) { - char *newstr, *word, *next, *start, *end; - char *ruleStart = NULL; - int len, ruleLen = 0; - int in_dn_expr = 0; - - *endOfCurrRule = NULL; - end = start = NULL; + char *newstr = NULL, *word = NULL, *next = NULL, *start = NULL, *end = NULL; + char *ruleStart = NULL; + int len, ruleLen = 0; + int in_dn_expr = 0; + if (endOfCurrRule) { + *endOfCurrRule = NULL; + } newstr = slapi_ch_strdup (original_str); if ( (strncasecmp(newstr, "allow", 5) == 0) || - (strncasecmp(newstr, "deny", 4) == 0) ) { - word = ldap_utf8strtok_r(newstr, ")", &next); - } - else { + (strncasecmp(newstr, "deny", 4) == 0) ) { + word = ldap_utf8strtok_r(newstr, ")", &next); + } else { word = ldap_utf8strtok_r(newstr, " ", &next); } @@ -1052,7 +1053,7 @@ __aclp__getNextLASRule (aci_t *aci_item, char *original_str , char **endOfCurrRu (strncmp ( word, ">=",2) ==0) || (strncmp ( word, "=>",2) ==0) || (strncmp ( word, "=<",2) ==0)) - ) ){ + ) ) { aci_item->aci_ruleType |= ruleType; got_rule = 1; } @@ -1088,20 +1089,55 @@ __aclp__getNextLASRule (aci_t *aci_item, char *original_str , char **endOfCurrRu } } /* while */ - if ( end ) { /* Found an end to the rule and it's not the last rule */ len = end - newstr; - end = original_str +len; - while ( (end != original_str) && *end != '\"') end--; - *endOfCurrRule = end; + end = original_str + len; + while ( (end != original_str) && *end != '\"' ) end--; + if (end == original_str) { + char *tmpp = NULL; + /* The rule has a problem! Not double quoted? + It should be like this: + userdn="ldap:///cn=*,ou=testou,o=example.com" + But we got this? + userdn=ldap:///cn=*,ou=testou,o=example.com + */ + tmpp = original_str + len; + /* Just excluding the trailing spaces */ + while ( (tmpp != original_str) && *tmpp == ' ' ) tmpp--; + if (tmpp != original_str) { + tmpp++; + } + end = tmpp; + } + if (endOfCurrRule) { + *endOfCurrRule = end; + } len = start - newstr; ruleStart = original_str + len; } else { /* Walked off the end of the string so it's the last rule */ - end = original_str + strlen(original_str)-1; - while ( (end != original_str) && *end != '\"') end--; - *endOfCurrRule = end; + end = original_str + strlen(original_str) - 1; + while ( (end != original_str) && *end != '\"' ) end--; + if (end == original_str) { + char *tmpp = NULL; + /* The rule has a problem! Not double quoted? + It should be like this: + userdn="ldap:///cn=*,ou=testou,o=example.com" + But we got this? + userdn=ldap:///cn=*,ou=testou,o=example.com + */ + tmpp = original_str + strlen(original_str) - 1; + /* Just excluding the trailing spaces */ + while ( (tmpp != original_str) && *tmpp == ' ' ) tmpp--; + if (tmpp != original_str) { + tmpp++; + } + end = tmpp; + } + if (endOfCurrRule) { + *endOfCurrRule = end; + } } if ( start ) { /* Got a rule, fixup the pointer */
0
b22970e26da3f812c7ff6c177583603005eb3702
389ds/389-ds-base
Ticket #47720 - Normalization from old DN format to New DN format doesnt handel condition properly when there is space in a suffix after the seperator operator. Description: DN normalizer (slapi_dn_normalize_ext) follows RFC 4514 and keeps a white space if the RDN attribute type is not based on the DN syntax. But Directory server's configuration entry sometimes uses "cn" to store a DN value (e.g., dn: cn="dc=A,dc=com",cn=mapping tree, cn=config), which expects the value of cn treated as DN although cn is not a DN syntax type. To solve the problem, this patch introduces a configuration parameter "nsslapd-cn-uses-dn-syntax-in-dns" to "cn= config" which takes "on" or "off". If "on" is set, if the value of cn under "cn=config" is quoted, it's processed as DN. By default, nsslapd-cn-uses-dn-syntax-in-dns: off https://fedorahosted.org/389/ticket/47720 Reviewed by [email protected] (Thank you, Mark!!)
commit b22970e26da3f812c7ff6c177583603005eb3702 Author: Noriko Hosoi <[email protected]> Date: Thu May 22 13:48:43 2014 -0700 Ticket #47720 - Normalization from old DN format to New DN format doesnt handel condition properly when there is space in a suffix after the seperator operator. Description: DN normalizer (slapi_dn_normalize_ext) follows RFC 4514 and keeps a white space if the RDN attribute type is not based on the DN syntax. But Directory server's configuration entry sometimes uses "cn" to store a DN value (e.g., dn: cn="dc=A,dc=com",cn=mapping tree, cn=config), which expects the value of cn treated as DN although cn is not a DN syntax type. To solve the problem, this patch introduces a configuration parameter "nsslapd-cn-uses-dn-syntax-in-dns" to "cn= config" which takes "on" or "off". If "on" is set, if the value of cn under "cn=config" is quoted, it's processed as DN. By default, nsslapd-cn-uses-dn-syntax-in-dns: off https://fedorahosted.org/389/ticket/47720 Reviewed by [email protected] (Thank you, Mark!!) diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c index 76b33dab6..cea593be9 100644 --- a/ldap/servers/slapd/dn.c +++ b/ldap/servers/slapd/dn.c @@ -61,6 +61,7 @@ static void reset_rdn_avs( struct berval **rdn_avsp, int *rdn_av_countp ); static void sort_rdn_avs( struct berval *avs, int count, int escape ); static int rdn_av_cmp( struct berval *av1, struct berval *av2 ); static void rdn_av_swap( struct berval *av1, struct berval *av2, int escape ); +static int does_cn_uses_dn_syntax_in_dns(char *type, char *dn); /* normalized dn cache related definitions*/ struct @@ -621,6 +622,10 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len) /* Reset the character we modified. */ *d = savechar; + if (!is_dn_syntax) { + is_dn_syntax = does_cn_uses_dn_syntax_in_dns(typestart, src); + } + state = B4VALUE; *d++ = *s++; } else if (ISCLOSEBRACKET(*s)) { /* special care for ACL macro */ @@ -639,6 +644,10 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len) /* Reset the character we modified. */ *d = savechar; + if (!is_dn_syntax) { + is_dn_syntax = does_cn_uses_dn_syntax_in_dns(typestart, src); + } + state = INVALUE; /* skip a trailing space */ *d++ = *s++; } else if (ISSPACE(*s)) { @@ -657,6 +666,10 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len) /* Reset the character we modified. */ *d = savechar; + if (!is_dn_syntax) { + is_dn_syntax = does_cn_uses_dn_syntax_in_dns(typestart, src); + } + state = B4EQUAL; /* skip a trailing space */ } else if (ISQUOTE(*s) || SEPARATOR(*s)) { /* type includes quote / separator; not a valid dn */ @@ -1030,6 +1043,18 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len) s++; } } + } else if (ISSPACE(*s)) { + while (ISSPACE(*s)) { + s++; + } + /* + * dn_syntax_attr=ABC, XYZ --> dn_syntax_attr=ABC,XYZ + * non_dn_syntax_attr=ABC, XYZ --> dn_syntax_attr=ABC, XYZ + */ + if (!is_dn_syntax) { + --s; + *d++ = *s++; + } } else { *d++ = *s++; } @@ -3172,3 +3197,23 @@ slapi_sdn_common_ancestor(Slapi_DN *dn1, Slapi_DN *dn2) charray_free(dns2); return slapi_sdn_new_ndn_passin(common); } + +/* + * Return 1 - if nsslapd-cn-uses-dn-syntax-in-dns is true && + * the type is "cn" && dn is under "cn=config" + * Return 0 - otherwise + */ +static int +does_cn_uses_dn_syntax_in_dns(char *type, char *dn) +{ + int rc = 0; /* by default off */ + char *ptr = NULL; + if (type && dn && config_get_cn_uses_dn_syntax_in_dns() && + (PL_strcasecmp(type, "cn") == 0) && (ptr = PL_strrchr(dn, ','))) { + if (PL_strcasecmp(++ptr, "cn=config") == 0) { + rc = 1; + } + } + return rc; +} + diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index d1a3dc05e..040649bf6 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -271,6 +271,7 @@ slapi_int_t init_connection_buffer; slapi_int_t init_listen_backlog_size; slapi_onoff_t init_ignore_time_skew; slapi_onoff_t init_dynamic_plugins; +slapi_onoff_t init_cn_uses_dn_syntax_in_dns; #if defined (LINUX) slapi_int_t init_malloc_mxfast; slapi_int_t init_malloc_trim_threshold; @@ -1092,6 +1093,10 @@ static struct config_get_and_set { NULL, 0, (void**)&global_slapdFrontendConfig.dynamic_plugins, CONFIG_ON_OFF, (ConfigGetFunc)config_get_dynamic_plugins, &init_dynamic_plugins}, + {CONFIG_CN_USES_DN_SYNTAX_IN_DNS, config_set_cn_uses_dn_syntax_in_dns, + NULL, 0, + (void**)&global_slapdFrontendConfig.cn_uses_dn_syntax_in_dns, CONFIG_ON_OFF, + (ConfigGetFunc)config_get_cn_uses_dn_syntax_in_dns, &init_cn_uses_dn_syntax_in_dns}, #if defined(LINUX) {CONFIG_MALLOC_MXFAST, config_set_malloc_mxfast, NULL, 0, @@ -1558,6 +1563,7 @@ FrontendConfig_init () { init_listen_backlog_size = cfg->listen_backlog_size = DAEMON_LISTEN_SIZE; init_ignore_time_skew = cfg->ignore_time_skew = LDAP_OFF; init_dynamic_plugins = cfg->dynamic_plugins = LDAP_OFF; + init_cn_uses_dn_syntax_in_dns = cfg->cn_uses_dn_syntax_in_dns = LDAP_OFF; #if defined(LINUX) init_malloc_mxfast = cfg->malloc_mxfast = DEFAULT_MALLOC_UNSET; init_malloc_trim_threshold = cfg->malloc_trim_threshold = DEFAULT_MALLOC_UNSET; @@ -3289,6 +3295,7 @@ config_set_dynamic_plugins( const char *attrname, char *value, char *errorbuf, i return retVal; } + int config_get_dynamic_plugins() { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); @@ -3301,6 +3308,34 @@ config_get_dynamic_plugins() { return retVal; } +int +config_set_cn_uses_dn_syntax_in_dns(const char *attrname, char *value, char *errorbuf, int apply) +{ + int retVal = LDAP_SUCCESS; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + + retVal = config_set_onoff ( attrname, + value, + &(slapdFrontendConfig->cn_uses_dn_syntax_in_dns), + errorbuf, + apply); + + return retVal; +} + +int +config_get_cn_uses_dn_syntax_in_dns() +{ + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + int retVal; + + CFG_ONOFF_LOCK_READ(slapdFrontendConfig); + retVal = (int)slapdFrontendConfig->cn_uses_dn_syntax_in_dns; + CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); + + return retVal; +} + int config_set_security( const char *attrname, char *value, char *errorbuf, int apply ) { int retVal = LDAP_SUCCESS; diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 4c3e517e9..34c4ac60a 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -586,6 +586,8 @@ int config_set_plugin_logging(const char *attrname, char *value, char *errorbuf, int config_get_listen_backlog_size(void); int config_set_dynamic_plugins(const char *attrname, char *value, char *errorbuf, int apply); int config_get_dynamic_plugins(); +int config_set_cn_uses_dn_syntax_in_dns(const char *attrname, char *value, char *errorbuf, int apply); +int config_get_cn_uses_dn_syntax_in_dns(); PLHashNumber hashNocaseString(const void *key); PRIntn hashNocaseCompare(const void *v1, const void *v2); diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 642f3b247..5401a66e9 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -2152,6 +2152,8 @@ typedef struct _slapdEntryPoints { #define CONFIG_DYNAMIC_PLUGINS "nsslapd-dynamic-plugins" #define CONFIG_RETURN_DEFAULT_OPATTR "nsslapd-return-default-opattr" +#define CONFIG_CN_USES_DN_SYNTAX_IN_DNS "nsslapd-cn-uses-dn-syntax-in-dns" + /* getenv alternative */ #define CONFIG_MALLOC_MXFAST "nsslapd-malloc-mxfast" #define CONFIG_MALLOC_TRIM_THRESHOLD "nsslapd-malloc-trim-threshold" @@ -2415,6 +2417,7 @@ typedef struct _slapdFrontendConfig { slapi_onoff_t plugin_logging; /* log all internal plugin operations */ slapi_onoff_t ignore_time_skew; slapi_onoff_t dynamic_plugins; /* allow plugins to be dynamically enabled/disabled */ + slapi_onoff_t cn_uses_dn_syntax_in_dns; /* indicates the cn value in dns has dn syntax */ #if defined(LINUX) int malloc_mxfast; /* mallopt M_MXFAST */ int malloc_trim_threshold; /* mallopt M_TRIM_THRESHOLD */
0
fc6a0cd3362dfdb73a43d3b52ae42a48678c2a24
389ds/389-ds-base
Ticket #353 - coverity 12625-12629 - leaks, dead code, unchecked return https://fedorahosted.org/389/ticket/353 Resolves: Ticket #353 Bug Description: coverity 12625-12629 - leaks, dead code, unchecked return Reviewed by: mreynolds (Thanks!) Branch: master Fix Description: In addition to the errors fixed, I added the use of slapi_entry_attr_get_bool() so that values of true, yes, etc. could be used in addition to on/off. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no
commit fc6a0cd3362dfdb73a43d3b52ae42a48678c2a24 Author: Rich Megginson <[email protected]> Date: Wed May 2 09:17:52 2012 -0600 Ticket #353 - coverity 12625-12629 - leaks, dead code, unchecked return https://fedorahosted.org/389/ticket/353 Resolves: Ticket #353 Bug Description: coverity 12625-12629 - leaks, dead code, unchecked return Reviewed by: mreynolds (Thanks!) Branch: master Fix Description: In addition to the errors fixed, I added the use of slapi_entry_attr_get_bool() so that values of true, yes, etc. could be used in addition to on/off. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c index 229b962b2..c98d8ad00 100644 --- a/ldap/servers/plugins/memberof/memberof.c +++ b/ldap/servers/plugins/memberof/memberof.c @@ -513,7 +513,7 @@ int memberof_del_dn_type_callback(Slapi_Entry *e, void *callback_data) int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn, char **types, plugin_search_entry_callback callback, void *callback_data) { - Slapi_PBlock *search_pb = slapi_pblock_new(); + Slapi_PBlock *search_pb = NULL; Slapi_DN *base_sdn = NULL; Slapi_Backend *be = NULL; Slapi_DN *sdn = NULL; @@ -565,6 +565,7 @@ int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn, return rc; } + search_pb = slapi_pblock_new(); be = slapi_get_first_backend(&cookie); while(be){ if(!all_backends){ diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c index 4c23af525..2819511af 100644 --- a/ldap/servers/plugins/replication/cl5_api.c +++ b/ldap/servers/plugins/replication/cl5_api.c @@ -6556,9 +6556,6 @@ cl5CleanRUV(ReplicaId rid){ ruv_delete_replica(file->maxRUV, rid); obj = objset_next_obj(s_cl5Desc.dbFiles, obj); } - - if (obj) - object_release (obj); } void trigger_cl_trimming(){ @@ -6585,7 +6582,11 @@ trigger_cl_trimming_thread(){ if(s_cl5Desc.dbState == CL5_STATE_CLOSED || s_cl5Desc.dbState == CL5_STATE_CLOSING){ return; } - _cl5AddThread(); + if (CL5_SUCCESS != _cl5AddThread()) { + slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, + "trigger_cl_trimming: failed to increment thread count " + "NSPR error - %d\n", PR_GetError ()); + } _cl5DoTrimming(); _cl5RemoveThread(); } diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c index cdd074ecf..d194accc7 100644 --- a/ldap/servers/plugins/replication/repl5_agmt.c +++ b/ldap/servers/plugins/replication/repl5_agmt.c @@ -341,11 +341,14 @@ agmt_new_from_entry(Slapi_Entry *e) tmpstr = slapi_entry_attr_get_charptr(e, type_nsds5ReplicaEnabled); if (NULL != tmpstr) { - if(strcasecmp(tmpstr, "on") == 0){ + if(strcasecmp(tmpstr, "off") == 0){ + ra->is_enabled = PR_FALSE; + } else if(strcasecmp(tmpstr, "on") == 0){ ra->is_enabled = PR_TRUE; } else { - ra->is_enabled = PR_FALSE; + ra->is_enabled = slapi_entry_attr_get_bool(e, type_nsds5ReplicaEnabled); } + slapi_ch_free_string(&tmpstr); } else { ra->is_enabled = PR_TRUE; } @@ -2499,14 +2502,22 @@ agmt_set_enabled_from_entry(Repl_Agmt *ra, Slapi_Entry *e){ PR_Lock(ra->lock); attr_val = slapi_entry_attr_get_charptr(e, type_nsds5ReplicaEnabled); if(attr_val){ - if(strcasecmp(attr_val,"on") == 0){ + PRBool is_enabled = PR_TRUE; + if(strcasecmp(attr_val,"off") == 0){ + is_enabled = PR_FALSE; + } else if(strcasecmp(attr_val,"on") == 0){ + is_enabled = PR_TRUE; + } else { + is_enabled = slapi_entry_attr_get_bool(e, type_nsds5ReplicaEnabled); + } + slapi_ch_free_string(&attr_val); + if(is_enabled){ if(!ra->is_enabled){ ra->is_enabled = PR_TRUE; slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmt_set_enabled_from_entry: " "agreement is now enabled (%s)\n",ra->long_name); PR_Unlock(ra->lock); agmt_start(ra); - slapi_ch_free_string(&attr_val); return rc; } } else { @@ -2518,7 +2529,6 @@ agmt_set_enabled_from_entry(Repl_Agmt *ra, Slapi_Entry *e){ agmt_stop(ra); agmt_update_consumer_ruv(ra); agmt_set_last_update_status(ra,0,0,"agreement disabled"); - slapi_ch_free_string(&attr_val); return rc; } }
0
75a32a8829297a5cab303590d049f581740cf87e
389ds/389-ds-base
Ticket 49257 - only register modify callbacks Bug Description: Regression. In the previous fix we called ldbm_instance_config_load_dse_info() to register all the dse preop callbacks. Previously this was only done when creating an instance. It was not designed to be used outside of that context, and it caused error 53's when trying to add a backend after instance creation. Fix Description: Just register the "modify" DSE preop callbacks. https://pagure.io/389-ds-base/issue/49257 Reviewed by: ?
commit 75a32a8829297a5cab303590d049f581740cf87e Author: Mark Reynolds <[email protected]> Date: Wed May 31 11:15:13 2017 -0400 Ticket 49257 - only register modify callbacks Bug Description: Regression. In the previous fix we called ldbm_instance_config_load_dse_info() to register all the dse preop callbacks. Previously this was only done when creating an instance. It was not designed to be used outside of that context, and it caused error 53's when trying to add a backend after instance creation. Fix Description: Just register the "modify" DSE preop callbacks. https://pagure.io/389-ds-base/issue/49257 Reviewed by: ? diff --git a/ldap/servers/slapd/back-ldbm/instance.c b/ldap/servers/slapd/back-ldbm/instance.c index 8b38644ba..f067d22a4 100644 --- a/ldap/servers/slapd/back-ldbm/instance.c +++ b/ldap/servers/slapd/back-ldbm/instance.c @@ -305,15 +305,9 @@ ldbm_instance_startall(struct ldbminfo *li) if (rc1 != 0) { rc = rc1; } else { - if(ldbm_instance_config_load_dse_info(inst) != 0){ - slapi_log_err(SLAPI_LOG_ERR, "ldbm_instance_startall", - "Loading database instance configuration failed for (%s)\n", - inst->inst_name); - rc = -1; - } else { - vlv_init(inst); - slapi_mtn_be_started(inst->inst_be); - } + ldbm_instance_register_modify_callback(inst); + vlv_init(inst); + slapi_mtn_be_started(inst->inst_be); } inst_obj = objset_next_obj(li->li_instance_set, inst_obj); } diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h index ddec3a81f..ea597391a 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.h +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h @@ -157,6 +157,6 @@ int ldbm_instance_index_config_enable_index(ldbm_instance *inst, Slapi_Entry* e); int ldbm_instance_create_default_user_indexes(ldbm_instance *inst); void ldbm_config_destroy(struct ldbminfo *li); - +void ldbm_instance_register_modify_callback(ldbm_instance *inst); #endif /* _LDBM_CONFIG_H_ */ diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c index 955a8ea10..7714a42e1 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c @@ -578,6 +578,19 @@ static int ldbm_instance_deny_config(Slapi_PBlock *pb __attribute__((unused)), return SLAPI_DSE_CALLBACK_ERROR; } +void +ldbm_instance_register_modify_callback(ldbm_instance *inst) +{ + struct ldbminfo *li = inst->inst_li; + char *dn = NULL; + + dn = slapi_create_dn_string("cn=%s,cn=%s,cn=plugins,cn=config", + inst->inst_name, li->li_plugin->plg_name); + slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP, dn, + LDAP_SCOPE_BASE, "(objectclass=*)", + ldbm_instance_modify_config_entry_callback, (void *) inst); + slapi_ch_free_string(&dn); +} /* Reads in any config information held in the dse for the given * entry. Creates dse entries used to configure the given instance * if they don't already exist. Registers dse callback functions to
0
fa9a55ae9cb78480446d1f88d5a435be77ecbf87
389ds/389-ds-base
merge in autotool file fixes for gcc43 with the memberof autotool file additions
commit fa9a55ae9cb78480446d1f88d5a435be77ecbf87 Author: Rich Megginson <[email protected]> Date: Wed Feb 27 17:04:25 2008 +0000 merge in autotool file fixes for gcc43 with the memberof autotool file additions diff --git a/Makefile.in b/Makefile.in index b3986d371..3ab740d2a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -252,6 +252,9 @@ am_libhttp_client_plugin_la_OBJECTS = ldap/servers/plugins/http/libhttp_client_p ldap/servers/plugins/http/libhttp_client_plugin_la-http_impl.lo libhttp_client_plugin_la_OBJECTS = \ $(am_libhttp_client_plugin_la_OBJECTS) +libmemberof_plugin_la_LIBADD = +am_libmemberof_plugin_la_OBJECTS = ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.lo +libmemberof_plugin_la_OBJECTS = $(am_libmemberof_plugin_la_OBJECTS) libns_dshttpd_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) @@ -724,7 +727,7 @@ SOURCES = $(libavl_a_SOURCES) $(libldaputil_a_SOURCES) \ $(libdes_plugin_la_SOURCES) $(libdistrib_plugin_la_SOURCES) \ $(libdna_plugin_la_SOURCES) \ $(libhttp_client_plugin_la_SOURCES) \ - $(libns_dshttpd_la_SOURCES) \ + $(libmemberof_plugin_la_SOURCES) $(libns_dshttpd_la_SOURCES) \ $(libpam_passthru_plugin_la_SOURCES) \ $(libpassthru_plugin_la_SOURCES) \ $(libpresence_plugin_la_SOURCES) \ @@ -749,7 +752,7 @@ DIST_SOURCES = $(libavl_a_SOURCES) $(libldaputil_a_SOURCES) \ $(libdes_plugin_la_SOURCES) $(libdistrib_plugin_la_SOURCES) \ $(libdna_plugin_la_SOURCES) \ $(libhttp_client_plugin_la_SOURCES) \ - $(libns_dshttpd_la_SOURCES) \ + $(libmemberof_plugin_la_SOURCES) $(libns_dshttpd_la_SOURCES) \ $(libpam_passthru_plugin_la_SOURCES) \ $(libpassthru_plugin_la_SOURCES) \ $(libpresence_plugin_la_SOURCES) \ @@ -1033,7 +1036,7 @@ server_LTLIBRARIES = libslapd.la libns-dshttpd.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 libhttp-client-plugin.la libcollation-plugin.la \ - libpassthru-plugin.la libpresence-plugin.la \ + libmemberof-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 $(LIBPAM_PASSTHRU_PLUGIN) $(LIBDNA_PLUGIN) $(LIBBITWISE_PLUGIN) @@ -1549,6 +1552,13 @@ libcollation_plugin_la_LIBADD = $(ICU_LINK) $(LIBCSTD) $(LIBCRUN) libcollation_plugin_la_LDFLAGS = -avoid-version libcollation_plugin_la_LINK = $(CXXLINK) +#------------------------ +# libmemberof-plugin +#------------------------ +libmemberof_plugin_la_SOURCES = ldap/servers/plugins/memberof/memberof.c +libmemberof_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) +libmemberof_plugin_la_LDFLAGS = -avoid-version + #------------------------ # libpam-passthru-plugin #------------------------ @@ -2576,6 +2586,17 @@ ldap/servers/plugins/http/libhttp_client_plugin_la-http_impl.lo: \ ldap/servers/plugins/http/$(DEPDIR)/$(am__dirstamp) libhttp-client-plugin.la: $(libhttp_client_plugin_la_OBJECTS) $(libhttp_client_plugin_la_DEPENDENCIES) $(LINK) -rpath $(serverplugindir) $(libhttp_client_plugin_la_LDFLAGS) $(libhttp_client_plugin_la_OBJECTS) $(libhttp_client_plugin_la_LIBADD) $(LIBS) +ldap/servers/plugins/memberof/$(am__dirstamp): + @$(mkdir_p) ldap/servers/plugins/memberof + @: > ldap/servers/plugins/memberof/$(am__dirstamp) +ldap/servers/plugins/memberof/$(DEPDIR)/$(am__dirstamp): + @$(mkdir_p) ldap/servers/plugins/memberof/$(DEPDIR) + @: > ldap/servers/plugins/memberof/$(DEPDIR)/$(am__dirstamp) +ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.lo: \ + ldap/servers/plugins/memberof/$(am__dirstamp) \ + ldap/servers/plugins/memberof/$(DEPDIR)/$(am__dirstamp) +libmemberof-plugin.la: $(libmemberof_plugin_la_OBJECTS) $(libmemberof_plugin_la_DEPENDENCIES) + $(LINK) -rpath $(serverplugindir) $(libmemberof_plugin_la_LDFLAGS) $(libmemberof_plugin_la_OBJECTS) $(libmemberof_plugin_la_LIBADD) $(LIBS) lib/libaccess/$(am__dirstamp): @$(mkdir_p) lib/libaccess @: > lib/libaccess/$(am__dirstamp) @@ -3934,6 +3955,8 @@ mostlyclean-compile: -rm -f ldap/servers/plugins/http/libhttp_client_plugin_la-http_client.lo -rm -f ldap/servers/plugins/http/libhttp_client_plugin_la-http_impl.$(OBJEXT) -rm -f ldap/servers/plugins/http/libhttp_client_plugin_la-http_impl.lo + -rm -f ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.$(OBJEXT) + -rm -f ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.lo -rm -f ldap/servers/plugins/pam_passthru/libpam_passthru_plugin_la-pam_ptconfig.$(OBJEXT) -rm -f ldap/servers/plugins/pam_passthru/libpam_passthru_plugin_la-pam_ptconfig.lo -rm -f ldap/servers/plugins/pam_passthru/libpam_passthru_plugin_la-pam_ptdebug.$(OBJEXT) @@ -4671,6 +4694,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/dna/$(DEPDIR)/libdna_plugin_la-dna.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/http/$(DEPDIR)/libhttp_client_plugin_la-http_client.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/http/$(DEPDIR)/libhttp_client_plugin_la-http_impl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/memberof/$(DEPDIR)/libmemberof_plugin_la-memberof.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/pam_passthru/$(DEPDIR)/libpam_passthru_plugin_la-pam_ptconfig.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/pam_passthru/$(DEPDIR)/libpam_passthru_plugin_la-pam_ptdebug.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ldap/servers/plugins/pam_passthru/$(DEPDIR)/libpam_passthru_plugin_la-pam_ptimpl.Plo@am__quote@ @@ -5978,6 +6002,13 @@ ldap/servers/plugins/http/libhttp_client_plugin_la-http_impl.lo: ldap/servers/pl @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhttp_client_plugin_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ldap/servers/plugins/http/libhttp_client_plugin_la-http_impl.lo `test -f 'ldap/servers/plugins/http/http_impl.c' || echo '$(srcdir)/'`ldap/servers/plugins/http/http_impl.c +ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.lo: ldap/servers/plugins/memberof/memberof.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmemberof_plugin_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.lo -MD -MP -MF "ldap/servers/plugins/memberof/$(DEPDIR)/libmemberof_plugin_la-memberof.Tpo" -c -o ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.lo `test -f 'ldap/servers/plugins/memberof/memberof.c' || echo '$(srcdir)/'`ldap/servers/plugins/memberof/memberof.c; \ +@am__fastdepCC_TRUE@ then mv -f "ldap/servers/plugins/memberof/$(DEPDIR)/libmemberof_plugin_la-memberof.Tpo" "ldap/servers/plugins/memberof/$(DEPDIR)/libmemberof_plugin_la-memberof.Plo"; else rm -f "ldap/servers/plugins/memberof/$(DEPDIR)/libmemberof_plugin_la-memberof.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ldap/servers/plugins/memberof/memberof.c' object='ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmemberof_plugin_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ldap/servers/plugins/memberof/libmemberof_plugin_la-memberof.lo `test -f 'ldap/servers/plugins/memberof/memberof.c' || echo '$(srcdir)/'`ldap/servers/plugins/memberof/memberof.c + lib/libadmin/libns_dshttpd_la-error.lo: lib/libadmin/error.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libns_dshttpd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib/libadmin/libns_dshttpd_la-error.lo -MD -MP -MF "lib/libadmin/$(DEPDIR)/libns_dshttpd_la-error.Tpo" -c -o lib/libadmin/libns_dshttpd_la-error.lo `test -f 'lib/libadmin/error.c' || echo '$(srcdir)/'`lib/libadmin/error.c; \ @am__fastdepCC_TRUE@ then mv -f "lib/libadmin/$(DEPDIR)/libns_dshttpd_la-error.Tpo" "lib/libadmin/$(DEPDIR)/libns_dshttpd_la-error.Plo"; else rm -f "lib/libadmin/$(DEPDIR)/libns_dshttpd_la-error.Tpo"; exit 1; fi @@ -8592,6 +8623,7 @@ clean-libtool: -rm -rf ldap/servers/plugins/distrib/.libs ldap/servers/plugins/distrib/_libs -rm -rf ldap/servers/plugins/dna/.libs ldap/servers/plugins/dna/_libs -rm -rf ldap/servers/plugins/http/.libs ldap/servers/plugins/http/_libs + -rm -rf ldap/servers/plugins/memberof/.libs ldap/servers/plugins/memberof/_libs -rm -rf ldap/servers/plugins/pam_passthru/.libs ldap/servers/plugins/pam_passthru/_libs -rm -rf ldap/servers/plugins/passthru/.libs ldap/servers/plugins/passthru/_libs -rm -rf ldap/servers/plugins/presence/.libs ldap/servers/plugins/presence/_libs @@ -8961,6 +8993,8 @@ distclean-generic: -rm -f ldap/servers/plugins/dna/$(am__dirstamp) -rm -f ldap/servers/plugins/http/$(DEPDIR)/$(am__dirstamp) -rm -f ldap/servers/plugins/http/$(am__dirstamp) + -rm -f ldap/servers/plugins/memberof/$(DEPDIR)/$(am__dirstamp) + -rm -f ldap/servers/plugins/memberof/$(am__dirstamp) -rm -f ldap/servers/plugins/pam_passthru/$(DEPDIR)/$(am__dirstamp) -rm -f ldap/servers/plugins/pam_passthru/$(am__dirstamp) -rm -f ldap/servers/plugins/passthru/$(DEPDIR)/$(am__dirstamp) @@ -9027,7 +9061,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libtool \ distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ldap/libraries/libavl/$(DEPDIR) ldap/servers/plugins/acl/$(DEPDIR) ldap/servers/plugins/bitwise/$(DEPDIR) ldap/servers/plugins/chainingdb/$(DEPDIR) ldap/servers/plugins/collation/$(DEPDIR) ldap/servers/plugins/cos/$(DEPDIR) ldap/servers/plugins/distrib/$(DEPDIR) ldap/servers/plugins/dna/$(DEPDIR) ldap/servers/plugins/http/$(DEPDIR) ldap/servers/plugins/pam_passthru/$(DEPDIR) ldap/servers/plugins/passthru/$(DEPDIR) ldap/servers/plugins/presence/$(DEPDIR) ldap/servers/plugins/pwdstorage/$(DEPDIR) ldap/servers/plugins/referint/$(DEPDIR) ldap/servers/plugins/replication/$(DEPDIR) ldap/servers/plugins/retrocl/$(DEPDIR) ldap/servers/plugins/rever/$(DEPDIR) ldap/servers/plugins/roles/$(DEPDIR) ldap/servers/plugins/shared/$(DEPDIR) ldap/servers/plugins/statechange/$(DEPDIR) ldap/servers/plugins/syntaxes/$(DEPDIR) ldap/servers/plugins/uiduniq/$(DEPDIR) ldap/servers/plugins/views/$(DEPDIR) ldap/servers/slapd/$(DEPDIR) ldap/servers/slapd/back-ldbm/$(DEPDIR) ldap/servers/slapd/tools/$(DEPDIR) ldap/servers/slapd/tools/ldclt/$(DEPDIR) ldap/servers/slapd/tools/rsearch/$(DEPDIR) ldap/servers/snmp/$(DEPDIR) ldap/systools/$(DEPDIR) lib/base/$(DEPDIR) lib/ldaputil/$(DEPDIR) lib/libaccess/$(DEPDIR) lib/libadmin/$(DEPDIR) lib/libsi18n/$(DEPDIR) + -rm -rf ldap/libraries/libavl/$(DEPDIR) ldap/servers/plugins/acl/$(DEPDIR) ldap/servers/plugins/bitwise/$(DEPDIR) ldap/servers/plugins/chainingdb/$(DEPDIR) ldap/servers/plugins/collation/$(DEPDIR) ldap/servers/plugins/cos/$(DEPDIR) ldap/servers/plugins/distrib/$(DEPDIR) ldap/servers/plugins/dna/$(DEPDIR) ldap/servers/plugins/http/$(DEPDIR) ldap/servers/plugins/memberof/$(DEPDIR) ldap/servers/plugins/pam_passthru/$(DEPDIR) ldap/servers/plugins/passthru/$(DEPDIR) ldap/servers/plugins/presence/$(DEPDIR) ldap/servers/plugins/pwdstorage/$(DEPDIR) ldap/servers/plugins/referint/$(DEPDIR) ldap/servers/plugins/replication/$(DEPDIR) ldap/servers/plugins/retrocl/$(DEPDIR) ldap/servers/plugins/rever/$(DEPDIR) ldap/servers/plugins/roles/$(DEPDIR) ldap/servers/plugins/shared/$(DEPDIR) ldap/servers/plugins/statechange/$(DEPDIR) ldap/servers/plugins/syntaxes/$(DEPDIR) ldap/servers/plugins/uiduniq/$(DEPDIR) ldap/servers/plugins/views/$(DEPDIR) ldap/servers/slapd/$(DEPDIR) ldap/servers/slapd/back-ldbm/$(DEPDIR) ldap/servers/slapd/tools/$(DEPDIR) ldap/servers/slapd/tools/ldclt/$(DEPDIR) ldap/servers/slapd/tools/rsearch/$(DEPDIR) ldap/servers/snmp/$(DEPDIR) ldap/systools/$(DEPDIR) lib/base/$(DEPDIR) lib/ldaputil/$(DEPDIR) lib/libaccess/$(DEPDIR) lib/libadmin/$(DEPDIR) lib/libsi18n/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -9061,7 +9095,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ldap/libraries/libavl/$(DEPDIR) ldap/servers/plugins/acl/$(DEPDIR) ldap/servers/plugins/bitwise/$(DEPDIR) ldap/servers/plugins/chainingdb/$(DEPDIR) ldap/servers/plugins/collation/$(DEPDIR) ldap/servers/plugins/cos/$(DEPDIR) ldap/servers/plugins/distrib/$(DEPDIR) ldap/servers/plugins/dna/$(DEPDIR) ldap/servers/plugins/http/$(DEPDIR) ldap/servers/plugins/pam_passthru/$(DEPDIR) ldap/servers/plugins/passthru/$(DEPDIR) ldap/servers/plugins/presence/$(DEPDIR) ldap/servers/plugins/pwdstorage/$(DEPDIR) ldap/servers/plugins/referint/$(DEPDIR) ldap/servers/plugins/replication/$(DEPDIR) ldap/servers/plugins/retrocl/$(DEPDIR) ldap/servers/plugins/rever/$(DEPDIR) ldap/servers/plugins/roles/$(DEPDIR) ldap/servers/plugins/shared/$(DEPDIR) ldap/servers/plugins/statechange/$(DEPDIR) ldap/servers/plugins/syntaxes/$(DEPDIR) ldap/servers/plugins/uiduniq/$(DEPDIR) ldap/servers/plugins/views/$(DEPDIR) ldap/servers/slapd/$(DEPDIR) ldap/servers/slapd/back-ldbm/$(DEPDIR) ldap/servers/slapd/tools/$(DEPDIR) ldap/servers/slapd/tools/ldclt/$(DEPDIR) ldap/servers/slapd/tools/rsearch/$(DEPDIR) ldap/servers/snmp/$(DEPDIR) ldap/systools/$(DEPDIR) lib/base/$(DEPDIR) lib/ldaputil/$(DEPDIR) lib/libaccess/$(DEPDIR) lib/libadmin/$(DEPDIR) lib/libsi18n/$(DEPDIR) + -rm -rf ldap/libraries/libavl/$(DEPDIR) ldap/servers/plugins/acl/$(DEPDIR) ldap/servers/plugins/bitwise/$(DEPDIR) ldap/servers/plugins/chainingdb/$(DEPDIR) ldap/servers/plugins/collation/$(DEPDIR) ldap/servers/plugins/cos/$(DEPDIR) ldap/servers/plugins/distrib/$(DEPDIR) ldap/servers/plugins/dna/$(DEPDIR) ldap/servers/plugins/http/$(DEPDIR) ldap/servers/plugins/memberof/$(DEPDIR) ldap/servers/plugins/pam_passthru/$(DEPDIR) ldap/servers/plugins/passthru/$(DEPDIR) ldap/servers/plugins/presence/$(DEPDIR) ldap/servers/plugins/pwdstorage/$(DEPDIR) ldap/servers/plugins/referint/$(DEPDIR) ldap/servers/plugins/replication/$(DEPDIR) ldap/servers/plugins/retrocl/$(DEPDIR) ldap/servers/plugins/rever/$(DEPDIR) ldap/servers/plugins/roles/$(DEPDIR) ldap/servers/plugins/shared/$(DEPDIR) ldap/servers/plugins/statechange/$(DEPDIR) ldap/servers/plugins/syntaxes/$(DEPDIR) ldap/servers/plugins/uiduniq/$(DEPDIR) ldap/servers/plugins/views/$(DEPDIR) ldap/servers/slapd/$(DEPDIR) ldap/servers/slapd/back-ldbm/$(DEPDIR) ldap/servers/slapd/tools/$(DEPDIR) ldap/servers/slapd/tools/ldclt/$(DEPDIR) ldap/servers/slapd/tools/rsearch/$(DEPDIR) ldap/servers/snmp/$(DEPDIR) ldap/systools/$(DEPDIR) lib/base/$(DEPDIR) lib/ldaputil/$(DEPDIR) lib/libaccess/$(DEPDIR) lib/libadmin/$(DEPDIR) lib/libsi18n/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic
0
8e71d566bdb5c4c37728ed3be7813fa5053ce398
389ds/389-ds-base
Bug 619122 - fix coverify Defect Type: Resource leaks issues CID 11975 - 12053 https://bugzilla.redhat.com/show_bug.cgi?id=619122 Resolves: bug 619122 Bug description: fix coverify Defect Type: Resource leaks issues CID 12048. description: The repl5_tot_run() has been modified to release remote_schema_csn if it is not equal to the value passed into conn_push_schema().
commit 8e71d566bdb5c4c37728ed3be7813fa5053ce398 Author: Endi S. Dewata <[email protected]> Date: Fri Jul 30 14:45:12 2010 -0500 Bug 619122 - fix coverify Defect Type: Resource leaks issues CID 11975 - 12053 https://bugzilla.redhat.com/show_bug.cgi?id=619122 Resolves: bug 619122 Bug description: fix coverify Defect Type: Resource leaks issues CID 12048. description: The repl5_tot_run() has been modified to release remote_schema_csn if it is not equal to the value passed into conn_push_schema(). diff --git a/ldap/servers/plugins/replication/repl5_tot_protocol.c b/ldap/servers/plugins/replication/repl5_tot_protocol.c index 8e26f471f..28a94e638 100644 --- a/ldap/servers/plugins/replication/repl5_tot_protocol.c +++ b/ldap/servers/plugins/replication/repl5_tot_protocol.c @@ -373,6 +373,11 @@ repl5_tot_run(Private_Repl_Protocol *prp) agmt_set_last_init_status(prp->agmt, 0, 0, "Total schema update in progress"); remote_schema_csn = agmt_get_consumer_schema_csn ( prp->agmt ); rc = conn_push_schema(prp->conn, &remote_schema_csn); + + if (remote_schema_csn != agmt_get_consumer_schema_csn ( prp->agmt )) { + csn_free(&remote_schema_csn); + } + if (CONN_SCHEMA_UPDATED != rc && CONN_SCHEMA_NO_UPDATE_NEEDED != rc) { slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
0
04f8cfd493dd9fb10ed98778543edb5ba69e4476
389ds/389-ds-base
Resolves: #448831 Summary: attacker can tie up CPU in regex code (comment #11) Description: string_filter_sub always expected SLAPI_SEARCH_TIMELIMIT and SLAPI_OPINITIATED_TIME were set in pblock, but it was not true. Fixed to check the container of these values first, and retrieve them only if the container is in the pblock. Otherwise, set -1 to timelimit (no timelimit).
commit 04f8cfd493dd9fb10ed98778543edb5ba69e4476 Author: Noriko Hosoi <[email protected]> Date: Fri Jul 18 22:45:36 2008 +0000 Resolves: #448831 Summary: attacker can tie up CPU in regex code (comment #11) Description: string_filter_sub always expected SLAPI_SEARCH_TIMELIMIT and SLAPI_OPINITIATED_TIME were set in pblock, but it was not true. Fixed to check the container of these values first, and retrieve them only if the container is in the pblock. Otherwise, set -1 to timelimit (no timelimit). diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c index c9477cce9..7f8aefcc8 100644 --- a/ldap/servers/plugins/syntaxes/string.c +++ b/ldap/servers/plugins/syntaxes/string.c @@ -201,11 +201,18 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final, time_t time_up = 0; time_t optime = 0; /* time op was initiated */ int timelimit = 0; /* search timelimit */ + Operation *op = NULL; LDAPDebug( LDAP_DEBUG_FILTER, "=> string_filter_sub\n", 0, 0, 0 ); - slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &timelimit ); - slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime ); + slapi_pblock_get( pb, SLAPI_OPERATION, &op ); + if (NULL != op) { + slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &timelimit ); + slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime ); + } else { + /* timelimit is not passed via pblock */ + timelimit = -1; + } /* * (timelimit==-1) means no time limit */
0
20e0d2665bf861fffa0961f8dc0172b7e01904c0
389ds/389-ds-base
Issue 50499 - Fix audit issues and remove jquery from the whitelist Description: 50 high vulnerabilities were found during audit. Fix them. It updates the Patternfly version to 3.59.3 version. Package jquery is no longer an issue, remove it from the whitelist. https://pagure.io/389-ds-base/issue/50499 Reviewed by: mreynolds (Thanks!)
commit 20e0d2665bf861fffa0961f8dc0172b7e01904c0 Author: Simon Pichugin <[email protected]> Date: Mon Jul 15 23:28:45 2019 +0200 Issue 50499 - Fix audit issues and remove jquery from the whitelist Description: 50 high vulnerabilities were found during audit. Fix them. It updates the Patternfly version to 3.59.3 version. Package jquery is no longer an issue, remove it from the whitelist. https://pagure.io/389-ds-base/issue/50499 Reviewed by: mreynolds (Thanks!) diff --git a/src/cockpit/389-console/audit-ci.json b/src/cockpit/389-console/audit-ci.json index 78b590f85..96915facc 100644 --- a/src/cockpit/389-console/audit-ci.json +++ b/src/cockpit/389-console/audit-ci.json @@ -3,6 +3,5 @@ "package-manager": "auto", "report": true, "advisories": [], - "_comment": "jquery should be removed from the whitelist after https://github.com/patternfly/patternfly/pull/1174 is merged", - "whitelist": ["jquery"] + "whitelist": [] } diff --git a/src/cockpit/389-console/package-lock.json b/src/cockpit/389-console/package-lock.json index a35d85779..67f170c2c 100644 --- a/src/cockpit/389-console/package-lock.json +++ b/src/cockpit/389-console/package-lock.json @@ -935,7 +935,8 @@ "@types/d3-color": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-1.2.2.tgz", - "integrity": "sha512-6pBxzJ8ZP3dYEQ4YjQ+NVbQaOflfgXq/JbDiS99oLobM2o72uAST4q6yPxHv6FOTCRC/n35ktuo8pvw/S4M7sw==" + "integrity": "sha512-6pBxzJ8ZP3dYEQ4YjQ+NVbQaOflfgXq/JbDiS99oLobM2o72uAST4q6yPxHv6FOTCRC/n35ktuo8pvw/S4M7sw==", + "optional": true }, "@types/d3-dispatch": { "version": "1.0.7", @@ -955,7 +956,8 @@ "@types/d3-dsv": { "version": "1.0.36", "resolved": "https://registry.npmjs.org/@types/d3-dsv/-/d3-dsv-1.0.36.tgz", - "integrity": "sha512-jbIWQ27QJcBNMZbQv0NSQMHnBDCmxghAxePxgyiPH1XPCRkOsTBei7jcdi3fDrUCGpCV3lKrSZFSlOkhUQVClA==" + "integrity": "sha512-jbIWQ27QJcBNMZbQv0NSQMHnBDCmxghAxePxgyiPH1XPCRkOsTBei7jcdi3fDrUCGpCV3lKrSZFSlOkhUQVClA==", + "optional": true }, "@types/d3-ease": { "version": "1.0.8", @@ -994,6 +996,7 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-1.3.1.tgz", "integrity": "sha512-z8Zmi08XVwe8e62vP6wcA+CNuRhpuUU5XPEfqpG0hRypDE5BWNthQHB1UNWWDB7ojCbGaN4qBdsWp5kWxhT1IQ==", + "optional": true, "requires": { "@types/d3-color": "*" } @@ -1001,7 +1004,8 @@ "@types/d3-path": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-1.0.8.tgz", - "integrity": "sha512-AZGHWslq/oApTAHu9+yH/Bnk63y9oFOMROtqPAtxl5uB6qm1x2lueWdVEjsjjV3Qc2+QfuzKIwIR5MvVBakfzA==" + "integrity": "sha512-AZGHWslq/oApTAHu9+yH/Bnk63y9oFOMROtqPAtxl5uB6qm1x2lueWdVEjsjjV3Qc2+QfuzKIwIR5MvVBakfzA==", + "optional": true }, "@types/d3-polygon": { "version": "1.0.7", @@ -1048,7 +1052,8 @@ "@types/d3-selection": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-1.4.1.tgz", - "integrity": "sha512-bv8IfFYo/xG6dxri9OwDnK3yCagYPeRIjTlrcdYJSx+FDWlCeBDepIHUpqROmhPtZ53jyna0aUajZRk0I3rXNA==" + "integrity": "sha512-bv8IfFYo/xG6dxri9OwDnK3yCagYPeRIjTlrcdYJSx+FDWlCeBDepIHUpqROmhPtZ53jyna0aUajZRk0I3rXNA==", + "optional": true }, "@types/d3-shape": { "version": "1.3.1", @@ -1062,7 +1067,8 @@ "@types/d3-time": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-1.0.10.tgz", - "integrity": "sha512-aKf62rRQafDQmSiv1NylKhIMmznsjRN+MnXRXTqHoqm0U/UZzVpdrtRnSIfdiLS616OuC1soYeX1dBg2n1u8Xw==" + "integrity": "sha512-aKf62rRQafDQmSiv1NylKhIMmznsjRN+MnXRXTqHoqm0U/UZzVpdrtRnSIfdiLS616OuC1soYeX1dBg2n1u8Xw==", + "optional": true }, "@types/d3-time-format": { "version": "2.1.1", @@ -2003,9 +2009,9 @@ "integrity": "sha512-CB9CrpNVrIytlOoqHtRXhhxFo/jencr1U5cMqPBA0WmMdb13bzjHnXQVNGYde/g5gWW+RWiuT9jTquZuz3VE8A==" }, "bootstrap-switch": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/bootstrap-switch/-/bootstrap-switch-3.3.5.tgz", - "integrity": "sha512-aRwgTPO7QPvTtUxit2ucXgs/P+dp3Y8Qy41XOOqTXZiJvfI6b87+hP+r4B4+3y7bptu0P6KHIyEc4ordEVIVkg==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/bootstrap-switch/-/bootstrap-switch-3.3.4.tgz", + "integrity": "sha1-cOCusqh3wNx2aZHeEI4hcPwpov8=", "optional": true }, "bootstrap-touchspin": { @@ -2787,17 +2793,18 @@ "version": "1.10.19", "resolved": "https://registry.npmjs.org/datatables.net/-/datatables.net-1.10.19.tgz", "integrity": "sha512-+ljXcI6Pj3PTGy5pesp3E5Dr3x3AV45EZe0o1r0gKENN2gafBKXodVnk2ypKwl2tTmivjxbkiqoWnipTefyBTA==", + "optional": true, "requires": { "jquery": ">=1.7" } }, "datatables.net-bs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/datatables.net-bs/-/datatables.net-bs-2.1.1.tgz", - "integrity": "sha1-cEEIlyiRlJ0JS/RPU9BlTZ/ue84=", + "version": "1.10.19", + "resolved": "https://registry.npmjs.org/datatables.net-bs/-/datatables.net-bs-1.10.19.tgz", + "integrity": "sha512-5gxoI2n+duZP06+4xVC2TtH6zcY369/TRKTZ1DdSgDcDUl4OYQsrXCuaLJmbVzna/5Y5lrMmK7CxgvYgIynICA==", "optional": true, "requires": { - "datatables.net": ">=1.10.9", + "datatables.net": "1.10.19", "jquery": ">=1.7" } }, @@ -4107,7 +4114,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -4128,12 +4136,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4148,17 +4158,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4275,7 +4288,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4287,6 +4301,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4301,6 +4316,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4308,12 +4324,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4332,6 +4350,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4419,7 +4438,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4431,6 +4451,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4516,7 +4537,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -4552,6 +4574,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4571,6 +4594,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4614,12 +4638,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -5683,9 +5709,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==" }, "lodash.assign": { "version": "4.2.0", @@ -5703,9 +5729,9 @@ "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=" }, "lodash.mergewith": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz", - "integrity": "sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==" + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz", + "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==" }, "lodash.tail": { "version": "4.1.1", @@ -5928,9 +5954,9 @@ } }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -5984,11 +6010,12 @@ "moment": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", - "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==", + "optional": true }, "moment-timezone": { "version": "0.4.1", - "resolved": "http://registry.npmjs.org/moment-timezone/-/moment-timezone-0.4.1.tgz", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.4.1.tgz", "integrity": "sha1-gfWYw61eIs2teWtn7NjYjQ9bqgY=", "optional": true, "requires": { @@ -6502,17 +6529,17 @@ } }, "patternfly": { - "version": "3.59.1", - "resolved": "https://registry.npmjs.org/patternfly/-/patternfly-3.59.1.tgz", - "integrity": "sha512-0Q/P58yaxcQXwnXo/OssiXaZmuX0g9QvWdpsYHyml4ihqnN2lL/yGdadFarA6UAQb//15XtNjKHZocoJXCkWYg==", + "version": "3.59.3", + "resolved": "https://registry.npmjs.org/patternfly/-/patternfly-3.59.3.tgz", + "integrity": "sha512-gStdjLCS9k6NmI2xCXa1IBK0s8p5l5dqMEh/zLEUwA+qdV6z6qwSxHe8QT3AjLyEy27qMSzmtUXxvkO1c8jENw==", "requires": { "@types/c3": "^0.6.0", - "bootstrap": "~3.4.0", + "bootstrap": "~3.4.1", "bootstrap-datepicker": "^1.7.1", "bootstrap-sass": "^3.4.0", "bootstrap-select": "1.12.2", "bootstrap-slider": "^9.9.0", - "bootstrap-switch": "~3.3.4", + "bootstrap-switch": "3.3.4", "bootstrap-touchspin": "~3.1.1", "c3": "~0.4.11", "d3": "~3.5.17", @@ -6525,7 +6552,7 @@ "font-awesome": "^4.7.0", "font-awesome-sass": "^4.7.0", "google-code-prettify": "~1.0.5", - "jquery": "~3.2.1", + "jquery": "~3.4.1", "jquery-match-height": "^0.7.2", "moment": "^2.19.1", "moment-timezone": "^0.4.1", @@ -6537,11 +6564,6 @@ "version": "3.4.1", "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.4.1.tgz", "integrity": "sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA==" - }, - "jquery": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz", - "integrity": "sha1-XE2d5lKvbNCncBVKYxu6ErAVx4c=" } } }, @@ -7649,9 +7671,9 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -8506,38 +8528,15 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "uniq": { diff --git a/src/cockpit/389-console/package.json b/src/cockpit/389-console/package.json index 5ce97c882..7d6fb4e1d 100644 --- a/src/cockpit/389-console/package.json +++ b/src/cockpit/389-console/package.json @@ -50,7 +50,7 @@ "dependencies": { "bootstrap": "^4.3.1", "node-sass": "4.11.0", - "patternfly": "^3.59.1", + "patternfly": "^3.59.3", "patternfly-react": "^2.34.3", "prop-types": "15.6.2", "react": "16.6.1",
0
19f676aa104fb0f4158ed18dfc04d85aba759924
389ds/389-ds-base
Ticket 49099 - ns workers prep Bug Description: We wish to move to nunc-stans to control our worker threads and async tasks. Fix Description: This first patch moves the NS worker pool creation to main.c, which makes it accesible to both offline and online jobs. As well, we no longer "support" a server without nunc-stans so remove the configure options. We still allow enable disable of the feature however, so this has been fully tested. https://pagure.io/389-ds-base/issue/49099 Author: wibrown Review by: mreynolds (thanks!)
commit 19f676aa104fb0f4158ed18dfc04d85aba759924 Author: William Brown <[email protected]> Date: Tue May 9 10:05:20 2017 +1000 Ticket 49099 - ns workers prep Bug Description: We wish to move to nunc-stans to control our worker threads and async tasks. Fix Description: This first patch moves the NS worker pool creation to main.c, which makes it accesible to both offline and online jobs. As well, we no longer "support" a server without nunc-stans so remove the configure options. We still allow enable disable of the feature however, so this has been fully tested. https://pagure.io/389-ds-base/issue/49099 Author: wibrown Review by: mreynolds (thanks!) diff --git a/configure.ac b/configure.ac index 5fbf6acea..bfccc2c7b 100644 --- a/configure.ac +++ b/configure.ac @@ -266,23 +266,6 @@ else fi AM_CONDITIONAL(enable_posix_winsync,test "$enable_posix_winsync" = "yes") -if test -z "$enable_nunc_stans" ; then - enable_nunc_stans=yes # if not set on cmdline, set default -fi -AC_MSG_CHECKING(for --enable-nunc-stans) -AC_ARG_ENABLE(nunc_stans, - AS_HELP_STRING([--enable-nunc-stans], - [enable support for nunc-stans event framework (default: no)])) -if test "$enable_nunc_stans" = yes ; then - m4_include(m4/event.m4) - AC_MSG_RESULT(yes) - AC_DEFINE([ENABLE_NUNC_STANS], [1], [enable support for nunc-stans event framework]) -else - AC_MSG_RESULT(no) -fi -AM_CONDITIONAL(enable_nunc_stans,test "$enable_nunc_stans" = "yes") - - # the default prefix - override with --prefix or --with-fhs AC_PREFIX_DEFAULT([/opt/$PACKAGE_NAME]) diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index f6242c350..d3b0f7e22 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -241,10 +241,8 @@ connection_cleanup(Connection *conn) /* free the connection socket buffer */ connection_free_private_buffer(conn); -#ifdef ENABLE_NUNC_STANS /* even if !config_get_enable_nunc_stans, it is ok to set to 0 here */ conn->c_ns_close_jobs = 0; -#endif } /* @@ -1509,9 +1507,7 @@ connection_threadmain() Connection *pb_conn = NULL; Operation *pb_op = NULL; -#ifdef ENABLE_NUNC_STANS enable_nunc_stans = config_get_enable_nunc_stans(); -#endif #if defined( hpux ) /* Arrange to ignore SIGPIPE signals. */ SIGNAL( SIGPIPE, SIG_IGN ); diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c index 9e334e2cb..1c6757d40 100644 --- a/ldap/servers/slapd/conntable.c +++ b/ldap/servers/slapd/conntable.c @@ -156,10 +156,8 @@ connection_table_get_connection(Connection_Table *ct, int sd) * far then `c' is not being used by any operation threads, etc. */ connection_cleanup(c); -#ifdef ENABLE_NUNC_STANS /* NOTE - ok to do this here even if enable_nunc_stans is off */ c->c_ct = ct; /* pointer to connection table that owns this connection */ -#endif } else { diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 866eac0b5..e63c26af1 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -87,17 +87,13 @@ static PRLock *diskmon_mutex = NULL; void disk_monitoring_stop(void); typedef struct listener_info { -#ifdef ENABLE_NUNC_STANS PRStackElem stackelem; /* must be first in struct for PRStack to work */ -#endif int idx; /* index of this listener in the ct->fd array */ PRFileDesc *listenfd; /* the listener fd */ int secure; int local; -#ifdef ENABLE_NUNC_STANS Connection_Table *ct; /* for listen job callback */ struct ns_job_t *ns_job; /* the ns accept job */ -#endif } listener_info; static size_t listeners = 0; /* number of listener sockets */ @@ -117,11 +113,6 @@ static PRFileDesc **createprlistensockets(unsigned short port, static const char *netaddr2string(const PRNetAddr *addr, char *addrbuf, size_t addrbuflen); static void set_shutdown (int); -#ifdef ENABLE_NUNC_STANS -struct ns_job_t *ns_signal_job[6]; -static void ns_set_shutdown (struct ns_job_t *job); -static void ns_set_user (struct ns_job_t *job); -#endif static void setup_pr_read_pds(Connection_Table *ct, PRFileDesc **n_tcps, PRFileDesc **s_tcps, PRFileDesc **i_unix, PRIntn *num_to_read); #ifdef HPUX10 @@ -161,9 +152,7 @@ accept_and_configure(int s __attribute__((unused)), PRFileDesc *pr_acceptfd, PRN */ /* GGOODREPL static void handle_timeout( void ); */ static int handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, int secure, int local, Connection **newconn ); -#ifdef ENABLE_NUNC_STANS static void ns_handle_new_connection(struct ns_job_t *job); -#endif static void handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll); static int clear_signal(struct POLL_STRUCT *fds); static void unfurl_banners(Connection_Table *ct,daemon_ports_t *ports, PRFileDesc **n_tcps, PRFileDesc **s_tcps, PRFileDesc **i_unix); @@ -916,58 +905,7 @@ convert_pbe_des_to_aes(void) charray_free(attrs); } -#ifdef ENABLE_NUNC_STANS -/* - * Nunc stans logging function. - */ -static void -nunc_stans_logging(int severity, const char *format, va_list varg) -{ - va_list varg_copy; - int loglevel = SLAPI_LOG_ERR; - - if (severity == LOG_DEBUG){ - loglevel = SLAPI_LOG_NUNCSTANS; - } else if(severity == LOG_INFO){ - loglevel = SLAPI_LOG_CONNS; - } - va_copy(varg_copy, varg); - slapi_log_error_ext(loglevel, "nunc-stans", (char *)format, varg, varg_copy); - va_end(varg_copy); -} - -static void* -nunc_stans_malloc(size_t size) -{ - return (void*)slapi_ch_malloc((unsigned long)size); -} - -static void* -nunc_stans_memalign(size_t size, size_t alignment) -{ - return (void*)slapi_ch_memalign(size, alignment); -} - -static void* -nunc_stans_calloc(size_t count, size_t size) -{ - return (void*)slapi_ch_calloc((unsigned long)count, (unsigned long)size); -} - -static void* -nunc_stans_realloc(void *block, size_t size) -{ - return (void*)slapi_ch_realloc((char *)block, (unsigned long)size); -} - -static void -nunc_stans_free(void *ptr) -{ - slapi_ch_free((void **)&ptr); -} -#endif /* ENABLE_NUNC_STANS */ - -void slapd_daemon( daemon_ports_t *ports ) +void slapd_daemon( daemon_ports_t *ports, ns_thrpool_t *tp ) { /* We are passed some ports---one for regular connections, one * for SSL connections, one for ldapi connections. @@ -986,16 +924,10 @@ void slapd_daemon( daemon_ports_t *ports ) PRThread *time_thread_p; int threads; int in_referral_mode = config_check_referral_mode(); -#ifdef ENABLE_NUNC_STANS - ns_thrpool_t *tp = NULL; - struct ns_thrpool_config tp_config; -#endif int connection_table_size = get_configured_connection_table_size(); the_connection_table= connection_table_new(connection_table_size); -#ifdef ENABLE_NUNC_STANS enable_nunc_stans = config_get_enable_nunc_stans(); -#endif #ifdef RESOLVER_NEEDS_LOW_FILE_DESCRIPTORS /* @@ -1022,38 +954,6 @@ void slapd_daemon( daemon_ports_t *ports ) createsignalpipe(); /* Setup our signal interception. */ init_shutdown_detect(); -#ifdef ENABLE_NUNC_STANS - } else { - PRInt32 maxthreads = (PRInt32)config_get_threadnumber(); - /* Set the nunc-stans thread pool config */ - ns_thrpool_config_init(&tp_config); - - tp_config.max_threads = maxthreads; - tp_config.stacksize = SLAPD_DEFAULT_THREAD_STACKSIZE; -#ifdef LDAP_ERROR_LOGGING - tp_config.log_fct = nunc_stans_logging; -#else - tp_config.log_fct = NULL; -#endif - tp_config.log_start_fct = NULL; - tp_config.log_close_fct = NULL; - tp_config.malloc_fct = nunc_stans_malloc; - tp_config.memalign_fct = nunc_stans_memalign; - tp_config.calloc_fct = nunc_stans_calloc; - tp_config.realloc_fct = nunc_stans_realloc; - tp_config.free_fct = nunc_stans_free; - - tp = ns_thrpool_new(&tp_config); - - /* We mark these as persistent so they keep blocking signals forever. */ - /* These *must* be in the event thread (ie not ns_job_thread) to prevent races */ - ns_add_signal_job(tp, SIGINT, NS_JOB_PERSIST, ns_set_shutdown, NULL, &ns_signal_job[0]); - ns_add_signal_job(tp, SIGTERM, NS_JOB_PERSIST, ns_set_shutdown, NULL, &ns_signal_job[1]); - ns_add_signal_job(tp, SIGTSTP, NS_JOB_PERSIST, ns_set_shutdown, NULL, &ns_signal_job[3]); - ns_add_signal_job(tp, SIGHUP, NS_JOB_PERSIST, ns_set_user, NULL, &ns_signal_job[2]); - ns_add_signal_job(tp, SIGUSR1, NS_JOB_PERSIST, ns_set_user, NULL, &ns_signal_job[4]); - ns_add_signal_job(tp, SIGUSR2, NS_JOB_PERSIST, ns_set_user, NULL, &ns_signal_job[5]); -#endif /* ENABLE_NUNC_STANS */ } if ( @@ -1180,7 +1080,6 @@ void slapd_daemon( daemon_ports_t *ports ) */ convert_pbe_des_to_aes(); -#ifdef ENABLE_NUNC_STANS if (enable_nunc_stans && !g_get_shutdown()) { setup_pr_read_pds(the_connection_table,n_tcps,s_tcps,i_unix,&num_poll); for (size_t ii = 0; ii < listeners; ++ii) { @@ -1190,7 +1089,6 @@ void slapd_daemon( daemon_ports_t *ports ) } } -#endif /* ENABLE_NUNC_STANS */ /* Now we write the pid file, indicating that the server is finally and listening for connections */ write_pid_file(); @@ -1205,42 +1103,55 @@ void slapd_daemon( daemon_ports_t *ports ) ); #endif -#ifdef ENABLE_NUNC_STANS - if (enable_nunc_stans && ns_thrpool_wait(tp)) { - slapi_log_err(SLAPI_LOG_ERR, - "slapd-daemon", "ns_thrpool_wait failed errno %d (%s)\n", errno, - slapd_system_strerror(errno)); - } -#endif - /* The meat of the operation is in a loop on a call to select */ - while(!enable_nunc_stans && !g_get_shutdown()) - { - int select_return = 0; - PRErrorCode prerr; + if (enable_nunc_stans) { + if (ns_thrpool_wait(tp)) { + slapi_log_err(SLAPI_LOG_ERR, + "slapd-daemon", "ns_thrpool_wait failed errno %d (%s)\n", errno, + slapd_system_strerror(errno)); + } - setup_pr_read_pds(the_connection_table,n_tcps,s_tcps,i_unix,&num_poll); - select_return = POLL_FN(the_connection_table->fd, num_poll, pr_timeout); - switch (select_return) { - case 0: /* Timeout */ - /* GGOODREPL handle_timeout(); */ - break; - case -1: /* Error */ - prerr = PR_GetError(); - slapi_log_err(SLAPI_LOG_TRACE, "slapd_daemon", "PR_Poll() failed, " - SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n", - prerr, slapd_system_strerror(prerr)); - break; - default: /* either a new connection or some new data ready */ - /* handle new connections from the listeners */ - handle_listeners(the_connection_table); - /* handle new data ready */ - handle_pr_read_ready(the_connection_table, connection_table_size); - clear_signal(the_connection_table->fd); - break; - } - } - /* We get here when the server is shutting down */ - /* Do what we have to do before death */ + /* we have exited from ns_thrpool_wait. This means we are shutting down! */ + /* Please see https://firstyear.fedorapeople.org/nunc-stans/md_docs_job-safety.html */ + /* tldr is shutdown needs to run first to allow job_done on an ARMED job */ + for (size_t i = 0; i < listeners; i++) { + PRStatus shutdown_status = ns_job_done(listener_idxs[i].ns_job); + if (shutdown_status != PR_SUCCESS) { + slapi_log_err(SLAPI_LOG_CRIT, "ns_set_shutdown", "Failed to shutdown listener idx %"PRIu64" !\n", i); + } + PR_ASSERT(shutdown_status == PR_SUCCESS); + listener_idxs[i].ns_job = NULL; + } + } else { + /* The meat of the operation is in a loop on a call to select */ + while(!g_get_shutdown()) + { + int select_return = 0; + PRErrorCode prerr; + + setup_pr_read_pds(the_connection_table,n_tcps,s_tcps,i_unix,&num_poll); + select_return = POLL_FN(the_connection_table->fd, num_poll, pr_timeout); + switch (select_return) { + case 0: /* Timeout */ + /* GGOODREPL handle_timeout(); */ + break; + case -1: /* Error */ + prerr = PR_GetError(); + slapi_log_err(SLAPI_LOG_TRACE, "slapd_daemon", "PR_Poll() failed, " + SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n", + prerr, slapd_system_strerror(prerr)); + break; + default: /* either a new connection or some new data ready */ + /* handle new connections from the listeners */ + handle_listeners(the_connection_table); + /* handle new data ready */ + handle_pr_read_ready(the_connection_table, connection_table_size); + clear_signal(the_connection_table->fd); + break; + } + } + /* We get here when the server is shutting down */ + /* Do what we have to do before death */ + } #ifdef WITH_SYSTEMD sd_notify(0, "STOPPING=1"); @@ -1374,27 +1285,6 @@ void slapd_daemon( daemon_ports_t *ports ) */ log_access_flush(); -#ifdef ENABLE_NUNC_STANS - - /* - * We need to shutdown the nunc-stans thread pool before we free the - * connection table. - */ - if (enable_nunc_stans) { - /* Now we free the signal jobs. We do it late here to keep intercepting - * them for as long as possible .... Later we need to rethink this to - * have plugins and such destroy while the tp is still active. - */ - ns_job_done(ns_signal_job[0]); - ns_job_done(ns_signal_job[1]); - ns_job_done(ns_signal_job[2]); - ns_job_done(ns_signal_job[3]); - ns_job_done(ns_signal_job[4]); - ns_job_done(ns_signal_job[5]); - - ns_thrpool_destroy(tp); - } -#endif /* * connection_table_free could use callbacks in the backend. * (e.g., be_search_results_release) @@ -1804,7 +1694,6 @@ handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll __attribute__((unused } } -#ifdef ENABLE_NUNC_STANS #define CONN_NEEDS_CLOSING(c) (c->c_flags & CONN_FLAG_CLOSING) || (c->c_sd == SLAPD_INVALID_SOCKET) /* Used internally by ns_handle_closure and ns_handle_pr_read_ready. * Returns 0 if the connection was successfully closed, or 1 otherwise. @@ -1859,7 +1748,6 @@ ns_handle_closure(struct ns_job_t *job) } return; } -#endif /** * Schedule more I/O for this connection, or make sure that it @@ -1868,7 +1756,6 @@ ns_handle_closure(struct ns_job_t *job) void ns_connection_post_io_or_closing(Connection *conn) { -#ifdef ENABLE_NUNC_STANS struct timeval tv; if (!enable_nunc_stans) { @@ -1941,10 +1828,8 @@ ns_connection_post_io_or_closing(Connection *conn) "conn %" PRIu64 " for fd=%d\n", conn->c_connid, conn->c_sd); } } -#endif } -#ifdef ENABLE_NUNC_STANS /* This function must be called without the thread flag, in the * event loop. This function may free the connection. This can * only be done in the event loop thread. @@ -2025,7 +1910,6 @@ ns_handle_pr_read_ready(struct ns_job_t *job) ns_job_done(job); return; } -#endif /* * wrapper functions required so we can implement ioblock_timeout and @@ -2634,7 +2518,6 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i return 0; } -#ifdef ENABLE_NUNC_STANS static void ns_handle_new_connection(struct ns_job_t *job) { @@ -2680,7 +2563,6 @@ ns_handle_new_connection(struct ns_job_t *job) ns_connection_post_io_or_closing(c); return; } -#endif static int init_shutdown_detect(void) { @@ -2856,43 +2738,6 @@ set_shutdown (int sig __attribute__((unused))) (void) SIGNAL( SIGHUP, set_shutdown ); } -#ifdef ENABLE_NUNC_STANS -static void -ns_set_user(struct ns_job_t *job __attribute__((unused))) -{ - /* This literally does nothing. We intercept user signals (USR1, USR2) */ - /* Could be good for a status output, or an easter egg. */ - return; -} - -static void -ns_set_shutdown(struct ns_job_t *job) -{ - /* Is there a way to make this a bit more atomic? */ - /* I think NS protects this by only executing one signal job at a time */ - PRStatus shutdown_status = PR_SUCCESS; - - if (g_get_shutdown() == 0) { - g_set_shutdown(SLAPI_SHUTDOWN_SIGNAL); - - /* Signal all the worker threads to stop */ - ns_thrpool_shutdown(ns_job_get_tp(job)); - - /* Stop all the long running jobs */ - /* Please see https://firstyear.fedorapeople.org/nunc-stans/md_docs_job-safety.html */ - /* tldr is shutdown needs to run first to allow job_done on an ARMED job */ - for (size_t i = 0; i < listeners; i++) { - shutdown_status = ns_job_done(listener_idxs[i].ns_job); - if (shutdown_status != PR_SUCCESS) { - slapi_log_err(SLAPI_LOG_CRIT, "ns_set_shutdown", "Failed to shutdown listener idx %"PRIu64" !\n", i); - } - PR_ASSERT(shutdown_status == PR_SUCCESS); - listener_idxs[i].ns_job = NULL; - } - } -} -#endif - #ifndef LINUX void slapd_do_nothing (int sig) diff --git a/ldap/servers/slapd/fe.h b/ldap/servers/slapd/fe.h index 3d9ac08be..9667997ea 100644 --- a/ldap/servers/slapd/fe.h +++ b/ldap/servers/slapd/fe.h @@ -116,7 +116,7 @@ int connection_table_iterate_active_connections(Connection_Table *ct, void* arg, */ int signal_listner(void); int daemon_pre_setuid_init(daemon_ports_t *ports); -void slapd_daemon( daemon_ports_t *ports ); +void slapd_daemon( daemon_ports_t *ports, ns_thrpool_t *tp ); void daemon_register_connection(void); int slapd_listenhost2addr( const char *listenhost, PRNetAddr ***addr ); int daemon_register_reslimits( void ); diff --git a/ldap/servers/slapd/globals.c b/ldap/servers/slapd/globals.c index 003ffed8c..936c92e4e 100644 --- a/ldap/servers/slapd/globals.c +++ b/ldap/servers/slapd/globals.c @@ -38,10 +38,10 @@ #include "slap.h" #include "fe.h" -int should_detach = 1; -time_t starttime; -PRThread *listener_tid; -Slapi_PBlock *repl_pb = NULL; +int should_detach = 0; +time_t starttime; +PRThread *listener_tid; +Slapi_PBlock *repl_pb = NULL; /* * global variables that need mutex protection diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index e48888527..7b338b335 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -241,9 +241,7 @@ slapi_onoff_t init_ignore_time_skew; slapi_onoff_t init_dynamic_plugins; slapi_onoff_t init_cn_uses_dn_syntax_in_dns; slapi_onoff_t init_global_backend_local; -#ifdef ENABLE_NUNC_STANS slapi_onoff_t init_enable_nunc_stans; -#endif #if defined (LINUX) slapi_int_t init_malloc_mxfast; slapi_int_t init_malloc_trim_threshold; @@ -1099,12 +1097,10 @@ static struct config_get_and_set { NULL, 0, (void**)&global_slapdFrontendConfig.maxsimplepaged_per_conn, CONFIG_INT, (ConfigGetFunc)config_get_maxsimplepaged_per_conn, SLAPD_DEFAULT_MAXSIMPLEPAGED_PER_CONN_STR}, -#ifdef ENABLE_NUNC_STANS {CONFIG_ENABLE_NUNC_STANS, config_set_enable_nunc_stans, NULL, 0, (void**)&global_slapdFrontendConfig.enable_nunc_stans, CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_nunc_stans, &init_enable_nunc_stans}, -#endif #ifdef MEMPOOL_EXPERIMENTAL {CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch, NULL, 0, @@ -1667,9 +1663,7 @@ FrontendConfig_init(void) { cfg->maxbersize = SLAPD_DEFAULT_MAXBERSIZE; cfg->logging_backend = slapi_ch_strdup(SLAPD_INIT_LOGGING_BACKEND_INTERNAL); cfg->rootdn = slapi_ch_strdup(SLAPD_DEFAULT_DIRECTORY_MANAGER); -#ifdef ENABLE_NUNC_STANS init_enable_nunc_stans = cfg->enable_nunc_stans = LDAP_ON; -#endif #if defined(LINUX) init_malloc_mxfast = cfg->malloc_mxfast = DEFAULT_MALLOC_UNSET; init_malloc_trim_threshold = cfg->malloc_trim_threshold = DEFAULT_MALLOC_UNSET; @@ -7488,7 +7482,6 @@ config_get_listen_backlog_size() return retVal; } -#ifdef ENABLE_NUNC_STANS int config_get_enable_nunc_stans() { @@ -7513,7 +7506,6 @@ config_set_enable_nunc_stans( const char *attrname, char *value, errorbuf, apply); return retVal; } -#endif static char * config_initvalue_to_onoff(struct config_get_and_set *cgas, char *initvalbuf, size_t initvalbufsize) diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index 3364a0128..0d79aba3b 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -78,89 +78,162 @@ static int slapd_exemode_suffix2instance(void); static int slapd_debug_level_string2level( const char *s ); static void slapd_debug_level_log( int level ); static void slapd_debug_level_usage( void ); -static void cmd_set_shutdown(int); /* * global variables */ static int slapd_exemode = SLAPD_EXEMODE_UNKNOWN; -static int init_cmd_shutdown_detect(void) + +struct ns_job_t *ns_signal_job[6]; + +/* + * Nunc stans logging function. + */ +static void +nunc_stans_logging(int severity, const char *format, va_list varg) { + va_list varg_copy; + int loglevel = SLAPI_LOG_ERR; - /* First of all, we must reset the signal mask to get rid of any blockages - * the process may have inherited from its parent (such as the console), which - * might result in the process not delivering those blocked signals, and thus, - * misbehaving.... - */ - { - int rc; - sigset_t proc_mask; - - slapi_log_err(SLAPI_LOG_TRACE, "init_cmd_shutdown_detect", "Reseting signal mask...\n"); - (void)sigemptyset( &proc_mask ); - rc = pthread_sigmask( SIG_SETMASK, &proc_mask, NULL ); - slapi_log_err(SLAPI_LOG_TRACE, "init_cmd_shutdown_detect", "%s\n", - rc ? "Failed to reset signal mask":"...Done (signal mask reset)!!"); - } + if (severity == LOG_DEBUG){ + loglevel = SLAPI_LOG_NUNCSTANS; + } else if(severity == LOG_INFO){ + loglevel = SLAPI_LOG_CONNS; + } -#if defined ( HPUX10 ) - PR_CreateThread ( PR_USER_THREAD, - catch_signals, - NULL, - PR_PRIORITY_NORMAL, - PR_GLOBAL_THREAD, - PR_UNJOINABLE_THREAD, - SLAPD_DEFAULT_THREAD_STACKSIZE); -#elif defined ( HPUX11 ) - /* In the optimized builds for HPUX, the signal handler doesn't seem - * to get set correctly unless the primordial thread gets a chance - * to run before we make the call to SIGNAL. (At this point the - * the primordial thread has spawned the daemon thread which called - * this function.) The call to DS_Sleep will give the primordial - * thread a chance to run. */ - DS_Sleep(0); -#endif + va_copy(varg_copy, varg); + slapi_log_error_ext(loglevel, "nunc-stans", (char *)format, varg, varg_copy); + va_end(varg_copy); +} - (void) SIGNAL( SIGPIPE, SIG_IGN ); - (void) SIGNAL( SIGCHLD, slapd_wait4child ); -#ifndef LINUX - /* linux uses USR1/USR2 for thread synchronization, so we aren't - * allowed to mess with those. - */ - (void) SIGNAL( SIGUSR1, slapd_do_nothing ); - (void) SIGNAL( SIGUSR2, cmd_set_shutdown ); -#endif - (void) SIGNAL( SIGTERM, cmd_set_shutdown ); - (void) SIGNAL( SIGHUP, cmd_set_shutdown ); - (void) SIGNAL( SIGINT, cmd_set_shutdown ); +static void +ns_printf_logger(int priority __attribute__((unused)), const char *fmt, va_list varg) +{ + /* Should we do anything with priority? */ + vprintf(fmt, varg); +} - return 0; +static void* +nunc_stans_malloc(size_t size) +{ + return (void*)slapi_ch_malloc((unsigned long)size); +} + +static void* +nunc_stans_memalign(size_t size, size_t alignment) +{ + return (void*)slapi_ch_memalign(size, alignment); +} + +static void* +nunc_stans_calloc(size_t count, size_t size) +{ + return (void*)slapi_ch_calloc((unsigned long)count, (unsigned long)size); +} + +static void* +nunc_stans_realloc(void *block, size_t size) +{ + return (void*)slapi_ch_realloc((char *)block, (unsigned long)size); } static void -cmd_set_shutdown (int sig __attribute__((unused))) +nunc_stans_free(void *ptr) { - /* don't log anything from a signal handler: - * you could be holding a lock when the signal was trapped. more - * specifically, you could be holding the logfile lock (and deadlock - * yourself). - */ + slapi_ch_free((void **)&ptr); +} - c_set_shutdown(); -#ifndef LINUX - /* don't mess with USR1/USR2 on linux, used by libpthread */ - (void) SIGNAL( SIGUSR2, cmd_set_shutdown ); -#endif - (void) SIGNAL( SIGTERM, cmd_set_shutdown ); - (void) SIGNAL( SIGHUP, cmd_set_shutdown ); +static void +ns_set_user(struct ns_job_t *job __attribute__((unused))) +{ + /* This literally does nothing. We intercept user signals (USR1, USR2) */ + /* Could be good for a status output, or an easter egg. */ + return; } -#ifdef HPUX10 -extern void collation_init(); +static void +ns_set_shutdown(struct ns_job_t *job) +{ + /* Is there a way to make this a bit more atomic? */ + /* I think NS protects this by only executing one signal job at a time */ + if (g_get_shutdown() == 0) { + g_set_shutdown(SLAPI_SHUTDOWN_SIGNAL); + + /* Signal all the worker threads to stop */ + } + ns_thrpool_shutdown(ns_job_get_tp(job)); +} + + +/* + * Setup our nunc-stans worker pool from our config. + * we must have read dse.ldif before this point. + */ + +static int_fast32_t +main_create_ns(ns_thrpool_t **tp_in) { + if (!config_get_enable_nunc_stans()) { + return 1; + } + struct ns_thrpool_config tp_config; + + int32_t maxthreads = (int32_t)config_get_threadnumber(); + /* Set the nunc-stans thread pool config */ + ns_thrpool_config_init(&tp_config); + + tp_config.max_threads = maxthreads; + tp_config.stacksize = SLAPD_DEFAULT_THREAD_STACKSIZE; + /* Highly likely that we need to re-write logging to be controlled by NS here. */ + /* tp_config.log_fct = nunc_stans_logging; */ +#ifdef DEBUG + tp_config.log_fct = ns_printf_logger; #endif + tp_config.log_start_fct = NULL; + tp_config.log_close_fct = NULL; + tp_config.malloc_fct = nunc_stans_malloc; + tp_config.memalign_fct = nunc_stans_memalign; + tp_config.calloc_fct = nunc_stans_calloc; + tp_config.realloc_fct = nunc_stans_realloc; + tp_config.free_fct = nunc_stans_free; + + *tp_in = ns_thrpool_new(&tp_config); + + /* We mark these as persistent so they keep blocking signals forever. */ + /* These *must* be in the event thread (ie not ns_job_thread) to prevent races */ + ns_add_signal_job(*tp_in, SIGINT, NS_JOB_PERSIST, ns_set_shutdown, NULL, &ns_signal_job[0]); + ns_add_signal_job(*tp_in, SIGTERM, NS_JOB_PERSIST, ns_set_shutdown, NULL, &ns_signal_job[1]); + ns_add_signal_job(*tp_in, SIGTSTP, NS_JOB_PERSIST, ns_set_shutdown, NULL, &ns_signal_job[3]); + ns_add_signal_job(*tp_in, SIGHUP, NS_JOB_PERSIST, ns_set_user, NULL, &ns_signal_job[2]); + ns_add_signal_job(*tp_in, SIGUSR1, NS_JOB_PERSIST, ns_set_user, NULL, &ns_signal_job[4]); + ns_add_signal_job(*tp_in, SIGUSR2, NS_JOB_PERSIST, ns_set_user, NULL, &ns_signal_job[5]); + return 0; +} -/* +static int_fast32_t +main_stop_ns(ns_thrpool_t *tp) { + if (tp == NULL) { + return 0; + } + ns_thrpool_shutdown(tp); + ns_thrpool_wait(tp); + + /* Now we free the signal jobs. We do it late here to keep intercepting + * them for as long as possible .... Later we need to rethink this to + * have plugins and such destroy while the tp is still active. + */ + ns_job_done(ns_signal_job[0]); + ns_job_done(ns_signal_job[1]); + ns_job_done(ns_signal_job[2]); + ns_job_done(ns_signal_job[3]); + ns_job_done(ns_signal_job[4]); + ns_job_done(ns_signal_job[5]); + ns_thrpool_destroy(tp); + + return 0; +} + +/* Four cases: - change ownership of all files in directory (strip_fn=PR_FALSE) - change ownership of all files in directory; but trailing fn needs to be stripped (strip_fn=PR_TRUE) @@ -579,12 +652,8 @@ main( int argc, char **argv) int return_value = 0; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); daemon_ports_t ports_info = {0}; -#ifndef __LP64__ -#if defined(__hpux) && !defined(__ia64) - /* for static constructors */ - _main(); -#endif -#endif + ns_thrpool_t *tp = NULL; + #ifdef MEMPOOL_EXPERIMENTAL /* to use LDAP C SDK lber functions seemlessly with slapi_ch_malloc funcs, * setting the slapi_ch_malloc funcs to lber option here. */ @@ -775,14 +844,6 @@ main( int argc, char **argv) raise_process_limits(); /* should be done ASAP once config file read */ -#ifdef PUMPKIN_HOUR - if ( time( NULL ) > (PUMPKIN_HOUR - 10) ) { - slapi_log_err(SLAPI_LOG_ERR, "main", - "ERROR: ** This beta software has expired **\n"); - exit( 1 ); - } -#endif - /* Set entry points in libslapd */ set_entry_points(); @@ -855,15 +916,22 @@ main( int argc, char **argv) exit(1); } - /* Do NSS and/or SSL init for those modes other than listening modes */ - if ((slapd_exemode != SLAPD_EXEMODE_REFERRAL) && - (slapd_exemode != SLAPD_EXEMODE_SLAPD)) { - if (slapd_do_all_nss_ssl_init(slapd_exemode, importexport_encrypt, - s_port, &ports_info)) { - return_value = 1; - goto cleanup; - } - } + /* + * Detach ourselves from the terminal (unless running in debug mode). + * We must detach before we start any threads since detach forks() on + * UNIX. + * Have to detach after ssl_init - the user may be prompted for the PIN + * on the terminal, so it must be open. + */ + if (detach(slapd_exemode, importexport_encrypt, s_port, &ports_info)) { + return_value = 1; + goto cleanup; + } + + /* + * Create our thread pool here for tasks to utilise. + */ + main_create_ns(&tp); /* * if we were called upon to do special database stuff, do it and be @@ -955,35 +1023,23 @@ main( int argc, char **argv) ndn_cache_init(); global_backend_lock_init(); - /* - * Detach ourselves from the terminal (unless running in debug mode). - * We must detach before we start any threads since detach forks() on - * UNIX. - * Have to detach after ssl_init - the user may be prompted for the PIN - * on the terminal, so it must be open. - */ - if (detach(slapd_exemode, importexport_encrypt, - s_port, &ports_info)) { - return_value = 1; - goto cleanup; - } - /* - * Now write our PID to the startup PID file. - * This is used by the start up script to determine our PID quickly - * after we fork, without needing to wait for the 'real' pid file to be - * written. That could take minutes. And the start script will wait - * that long looking for it. With this new 'early pid' file, it can avoid - * doing that, by detecting the pid and watching for the process exiting. - * This removes the blank stares all round from start-slapd when the server - * fails to start for some reason - */ - write_start_pid_file(); + /* + * Now write our PID to the startup PID file. + * This is used by the start up script to determine our PID quickly + * after we fork, without needing to wait for the 'real' pid file to be + * written. That could take minutes. And the start script will wait + * that long looking for it. With this new 'early pid' file, it can avoid + * doing that, by detecting the pid and watching for the process exiting. + * This removes the blank stares all round from start-slapd when the server + * fails to start for some reason + */ + write_start_pid_file(); /* Make sure we aren't going to run slapd in * a mode that is going to conflict with other - * slapd processes that are currently running - */ + * slapd processes that are currently running + */ if ((slapd_exemode != SLAPD_EXEMODE_REFERRAL) && ( add_new_slapd_process(slapd_exemode, db2ldif_dump_replica, skip_db_protect_check) == -1 )) @@ -1001,12 +1057,12 @@ main( int argc, char **argv) * stderr and our error log. Yuck. */ if (1) { - char *versionstring = config_get_versionstring(); - char *buildnum = config_get_buildnum(); - slapi_log_err(SLAPI_LOG_INFO, "main", "%s B%s starting up\n", + char *versionstring = config_get_versionstring(); + char *buildnum = config_get_buildnum(); + slapi_log_err(SLAPI_LOG_INFO, "main", "%s B%s starting up\n", versionstring, buildnum); - slapi_ch_free((void **)&buildnum); - slapi_ch_free((void **)&versionstring); + slapi_ch_free((void **)&buildnum); + slapi_ch_free((void **)&versionstring); } /* -sduloutre: compute_init() and entry_computed_attr_init() moved up */ @@ -1142,7 +1198,7 @@ main( int argc, char **argv) { time( &starttime ); - slapd_daemon(&ports_info); + slapd_daemon(&ports_info, tp); } slapi_log_err(SLAPI_LOG_INFO, "main", "slapd stopped.\n"); reslimit_cleanup(); @@ -1154,12 +1210,9 @@ cleanup: SSL_ClearSessionCache(); ndn_cache_destroy(); NSS_Shutdown(); + main_stop_ns(tp); PR_Cleanup(); -#if defined( hpux ) - exit( return_value ); -#else return return_value; -#endif } @@ -1411,7 +1464,6 @@ process_command_line(int argc, char **argv, char **extraname) long_opts = long_options_archive2db; break; case SLAPD_EXEMODE_DB2ARCHIVE: - init_cmd_shutdown_detect(); opts = opts_db2archive; long_opts = long_options_db2archive; break; @@ -1420,6 +1472,8 @@ process_command_line(int argc, char **argv, char **extraname) long_opts = long_options_db2index; break; case SLAPD_EXEMODE_REFERRAL: + /* Default to not detaching, but if REFERRAL, turn it on. */ + should_detach = 1; opts = opts_referral; long_opts = long_options_referral; break; @@ -1440,6 +1494,8 @@ process_command_line(int argc, char **argv, char **extraname) long_opts = long_options_dbverify; break; default: /* SLAPD_EXEMODE_SLAPD */ + /* Default to not detaching, but if SLAPD, turn it on. */ + should_detach = 1; opts = opts_slapd; long_opts = long_options_slapd; } @@ -2105,7 +2161,6 @@ slapd_exemode_ldif2db(void) slapi_pblock_set(pb, SLAPI_LDIF2DB_EXCLUDE, db2ldif_exclude); int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE; slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags); - main_setuid(slapdFrontendConfig->localuser); if ( plugin->plg_ldif2db != NULL ) { return_value = (*plugin->plg_ldif2db)( pb ); } else { @@ -2173,9 +2228,6 @@ slapd_exemode_db2ldif(int argc, char** argv) } } - /* [622984] db2lidf -r changes database file ownership - * should call setuid before "db2ldif_dump_replica" */ - main_setuid(slapdFrontendConfig->localuser); for (instp = cmd_line_instance_names; instp && *instp; instp++) { int release_me = 0; @@ -2421,7 +2473,6 @@ static int slapd_exemode_db2index(void) slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, cmd_line_instance_name); int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE; slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags); - main_setuid(slapdFrontendConfig->localuser); return_value = (*plugin->plg_db2index)( pb ); slapi_pblock_destroy(pb); @@ -2472,7 +2523,6 @@ slapd_exemode_db2archive(void) slapi_pblock_set(pb, SLAPI_SEQ_VAL, archive_name); int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE; slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags); - main_setuid(slapdFrontendConfig->localuser); return_value = (backend_plugin->plg_db2archive)( pb ); slapi_pblock_destroy(pb); return return_value; @@ -2521,7 +2571,6 @@ slapd_exemode_archive2db(void) int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE; slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags); slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, cmd_line_instance_name); - main_setuid(slapdFrontendConfig->localuser); return_value = (backend_plugin->plg_archive2db)( pb ); slapi_pblock_destroy(pb); return return_value; @@ -2582,7 +2631,6 @@ slapd_exemode_upgradedb(void) /* borrowing import code, so need to set up the import variables */ slapi_pblock_set(pb, SLAPI_LDIF2DB_GENERATE_UNIQUEID, &ldif2db_generate_uniqueid); slapi_pblock_set(pb, SLAPI_LDIF2DB_NAMESPACEID, &ldif2db_namespaceid); - main_setuid(slapdFrontendConfig->localuser); if ( backend_plugin->plg_upgradedb != NULL ) { return_value = (*backend_plugin->plg_upgradedb)( pb ); } else { @@ -2657,7 +2705,6 @@ slapd_exemode_upgradednformat(void) /* borrowing import code, so need to set up the import variables */ slapi_pblock_set(pb, SLAPI_LDIF2DB_GENERATE_UNIQUEID, &ldif2db_generate_uniqueid); slapi_pblock_set(pb, SLAPI_LDIF2DB_NAMESPACEID, &ldif2db_namespaceid); - main_setuid(slapdFrontendConfig->localuser); if ( backend_plugin->plg_upgradednformat != NULL ) { rc = (*backend_plugin->plg_upgradednformat)( pb ); } else { diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 9696ead44..0439915f3 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -575,10 +575,8 @@ int config_set_dynamic_plugins(const char *attrname, char *value, char *errorbuf int config_get_dynamic_plugins(void); int config_set_cn_uses_dn_syntax_in_dns(const char *attrname, char *value, char *errorbuf, int apply); int config_get_cn_uses_dn_syntax_in_dns(void); -#ifdef ENABLE_NUNC_STANS int config_get_enable_nunc_stans(void); int config_set_enable_nunc_stans(const char *attrname, char *value, char *errorbuf, int apply); -#endif int config_set_extract_pem(const char *attrname, char *value, char *errorbuf, int apply); PLHashNumber hashNocaseString(const void *key); @@ -1495,9 +1493,7 @@ void slapd_do_nothing(int); #endif void slapd_wait4child (int); -#ifdef ENABLE_NUNC_STANS void ns_handle_pr_read_ready(struct ns_job_t *job); -#endif void ns_connection_post_io_or_closing(Connection *conn); /* diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 2f84d27ae..2064d4a9c 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -118,9 +118,7 @@ typedef struct symbol_t { */ #include <pwd.h> -#ifdef ENABLE_NUNC_STANS #include <nunc-stans.h> -#endif #ifdef WITH_SYSTEMD #ifdef HAVE_JOURNALD @@ -1619,11 +1617,9 @@ typedef struct conn { Conn_IO_Layer_cb c_push_io_layer_cb; /* callback to push an IO layer on the conn->c_prfd */ Conn_IO_Layer_cb c_pop_io_layer_cb; /* callback to pop an IO layer off of the conn->c_prfd */ void *c_io_layer_cb_data; /* callback data */ -#ifdef ENABLE_NUNC_STANS struct connection_table *c_ct; /* connection table that this connection belongs to */ ns_thrpool_t *c_tp; /* thread pool for this connection */ int c_ns_close_jobs; /* number of current close jobs */ -#endif } Connection; #define CONN_FLAG_SSL 1 /* Is this connection an SSL connection or not ? * Used to direct I/O code when SSL is handled differently @@ -2102,9 +2098,7 @@ typedef struct _slapdEntryPoints { #define CONFIG_PLUGIN_BINDDN_TRACKING_ATTRIBUTE "nsslapd-plugin-binddn-tracking" #define CONFIG_MODDN_ACI_ATTRIBUTE "nsslapd-moddn-aci" #define CONFIG_GLOBAL_BACKEND_LOCK "nsslapd-global-backend-lock" -#ifdef ENABLE_NUNC_STANS #define CONFIG_ENABLE_NUNC_STANS "nsslapd-enable-nunc-stans" -#endif #define CONFIG_CONFIG_ATTRIBUTE "nsslapd-config" #define CONFIG_INSTDIR_ATTRIBUTE "nsslapd-instancedir" #define CONFIG_SCHEMADIR_ATTRIBUTE "nsslapd-schemadir" @@ -2445,9 +2439,7 @@ typedef struct _slapdFrontendConfig { slapi_onoff_t cn_uses_dn_syntax_in_dns; /* indicates the cn value in dns has dn syntax */ slapi_onoff_t global_backend_lock; slapi_int_t maxsimplepaged_per_conn;/* max simple paged results reqs handled per connection */ -#ifdef ENABLE_NUNC_STANS slapi_onoff_t enable_nunc_stans; -#endif #if defined(LINUX) int malloc_mxfast; /* mallopt M_MXFAST */ int malloc_trim_threshold; /* mallopt M_TRIM_THRESHOLD */ diff --git a/src/nunc-stans/ns/ns_thrpool.c b/src/nunc-stans/ns/ns_thrpool.c index 41f53429d..435aeb98b 100644 --- a/src/nunc-stans/ns/ns_thrpool.c +++ b/src/nunc-stans/ns/ns_thrpool.c @@ -841,10 +841,12 @@ ns_add_io_job(ns_thrpool_t *tp, PRFileDesc *fd, ns_job_type_t job_type, return PR_FAILURE; } + pthread_mutex_lock(_job->monitor); #ifdef DEBUG ns_log(LOG_DEBUG, "ns_add_io_job state %d moving to NS_JOB_ARMED\n", (_job)->state); #endif _job->state = NS_JOB_NEEDS_ARM; + pthread_mutex_unlock(_job->monitor); internal_ns_job_rearm(_job); /* fill in a pointer to the job for the caller if requested */ @@ -880,10 +882,12 @@ ns_add_timeout_job(ns_thrpool_t *tp, struct timeval *tv, ns_job_type_t job_type, return PR_FAILURE; } + pthread_mutex_lock(_job->monitor); #ifdef DEBUG ns_log(LOG_DEBUG, "ns_add_timeout_job state %d moving to NS_JOB_ARMED\n", (_job)->state); #endif _job->state = NS_JOB_NEEDS_ARM; + pthread_mutex_unlock(_job->monitor); internal_ns_job_rearm(_job); /* fill in a pointer to the job for the caller if requested */ @@ -934,12 +938,14 @@ ns_add_io_timeout_job(ns_thrpool_t *tp, PRFileDesc *fd, struct timeval *tv, if (!_job) { return PR_FAILURE; } + pthread_mutex_lock(_job->monitor); _job->tv = *tv; #ifdef DEBUG ns_log(LOG_DEBUG, "ns_add_io_timeout_job state %d moving to NS_JOB_ARMED\n", (_job)->state); #endif _job->state = NS_JOB_NEEDS_ARM; + pthread_mutex_unlock(_job->monitor); internal_ns_job_rearm(_job); /* fill in a pointer to the job for the caller if requested */ @@ -971,10 +977,12 @@ ns_add_signal_job(ns_thrpool_t *tp, PRInt32 signum, ns_job_type_t job_type, return PR_FAILURE; } + pthread_mutex_lock(_job->monitor); #ifdef DEBUG ns_log(LOG_DEBUG, "ns_add_signal_job state %d moving to NS_JOB_ARMED\n", (_job)->state); #endif _job->state = NS_JOB_NEEDS_ARM; + pthread_mutex_unlock(_job->monitor); internal_ns_job_rearm(_job); /* fill in a pointer to the job for the caller if requested */ @@ -1024,7 +1032,9 @@ ns_add_shutdown_job(ns_thrpool_t *tp) { if (!_job) { return PR_FAILURE; } + pthread_mutex_lock(_job->monitor); _job->state = NS_JOB_NEEDS_ARM; + pthread_mutex_unlock(_job->monitor); internal_ns_job_rearm(_job); return PR_SUCCESS; } @@ -1533,7 +1543,10 @@ ns_thrpool_shutdown(struct ns_thrpool_t *tp) PRStatus result = ns_add_shutdown_job(tp); PR_ASSERT(result == PR_SUCCESS); } - + /* Make sure all threads are woken up to their shutdown jobs. */ + pthread_mutex_lock(&(tp->work_q_lock)); + pthread_cond_broadcast(&(tp->work_q_cv)); + pthread_mutex_unlock(&(tp->work_q_lock)); } PRStatus @@ -1547,12 +1560,6 @@ ns_thrpool_wait(ns_thrpool_t *tp) while (sds_queue_dequeue(tp->thread_stack, (void **)&thr) == SDS_SUCCESS) { - - /* Make sure all threads are woken up to their shutdown jobs. */ - pthread_mutex_lock(&(tp->work_q_lock)); - pthread_cond_broadcast(&(tp->work_q_cv)); - pthread_mutex_unlock(&(tp->work_q_lock)); - /* void *thread_retval = NULL; */ int32_t rc = pthread_join(thr->thr, NULL); #ifdef DEBUG diff --git a/src/nunc-stans/test/test_nuncstans.c b/src/nunc-stans/test/test_nuncstans.c index 2795302bb..74ce57dd5 100644 --- a/src/nunc-stans/test/test_nuncstans.c +++ b/src/nunc-stans/test/test_nuncstans.c @@ -402,6 +402,74 @@ ns_job_neg_timeout_test(void **state) } +/* + * Test that a timeout job fires a within a time window + */ + +static void +ns_timer_job_cb(struct ns_job_t *job) +{ + cb_check += 1; + ns_job_done(job); + PR_Lock(cb_lock); + PR_NotifyCondVar(cb_cond); + /* Disarm ourselves */ + PR_Unlock(cb_lock); +} + +static void +ns_job_timer_test(void **state) +{ + struct ns_thrpool_t *tp = *state; + struct ns_job_t *job = NULL; + struct timeval tv = { 2, 0 }; + + PR_Lock(cb_lock); + assert_true(ns_add_timeout_job(tp, &tv, NS_JOB_THREAD, ns_timer_job_cb, NULL, &job) == PR_SUCCESS); + + PR_WaitCondVar(cb_cond, PR_SecondsToInterval(1)); + assert_int_equal(cb_check, 0); + + PR_WaitCondVar(cb_cond, PR_SecondsToInterval(2)); + PR_Unlock(cb_lock); + assert_int_equal(cb_check, 1); + +} + +/* + * Test that within a window, a looping timeout job has fired greater than X times. + */ + +static void +ns_timer_persist_job_cb(struct ns_job_t *job) +{ + cb_check += 1; + if (cb_check < 10) { + ns_job_rearm(job); + } else { + ns_job_done(job); + } +} + +static void +ns_job_timer_persist_test(void **state) +{ + struct ns_thrpool_t *tp = *state; + struct ns_job_t *job = NULL; + struct timeval tv = { 1, 0 }; + + PR_Lock(cb_lock); + assert_true(ns_add_timeout_job(tp, &tv, NS_JOB_THREAD, ns_timer_persist_job_cb, NULL, &job) == PR_SUCCESS); + + PR_Sleep(PR_SecondsToInterval(5)); + + assert_true(cb_check <= 6); + + PR_Sleep(PR_SecondsToInterval(6)); + + assert_int_equal(cb_check, 10); +} + int main(void) { @@ -430,6 +498,12 @@ main(void) cmocka_unit_test_setup_teardown(ns_job_neg_timeout_test, ns_test_setup, ns_test_teardown), + cmocka_unit_test_setup_teardown(ns_job_timer_test, + ns_test_setup, + ns_test_teardown), + cmocka_unit_test_setup_teardown(ns_job_timer_persist_test, + ns_test_setup, + ns_test_teardown), }; return cmocka_run_group_tests(tests, NULL, NULL); }
0
d09ce0e3ab2ea24496ee44622b050e007bb3cb8a
389ds/389-ds-base
Ticket #336 - [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV) https://fedorahosted.org/389/ticket/336 Resolves: Ticket #336 Bug Description: [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV) Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: 1) Entries can be deleted out from under a search operation. The range read code was not handling this situation correctly. The code should notice that the index query was empty, and continue to the next highest key in the range. 2) DB cursor c_close() functions can return DB_LOCK_DEADLOCK that must be reported to the higher level operation functions. If not, then subsequent operations in the same transaction fail. When a DB_LOCK_DEADLOCK is returned by any DB update operation in the transaction, the transaction must be aborted and a new transaction begun before any other transacted db operations can occur. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no BZ: 808770
commit d09ce0e3ab2ea24496ee44622b050e007bb3cb8a Author: Rich Megginson <[email protected]> Date: Sat Apr 7 09:05:18 2012 -0600 Ticket #336 - [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV) https://fedorahosted.org/389/ticket/336 Resolves: Ticket #336 Bug Description: [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV) Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: 1) Entries can be deleted out from under a search operation. The range read code was not handling this situation correctly. The code should notice that the index query was empty, and continue to the next highest key in the range. 2) DB cursor c_close() functions can return DB_LOCK_DEADLOCK that must be reported to the higher level operation functions. If not, then subsequent operations in the same transaction fail. When a DB_LOCK_DEADLOCK is returned by any DB update operation in the transaction, the transaction must be aborted and a new transaction begun before any other transacted db operations can occur. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no BZ: 808770 diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c index 4667c87e2..d62511c74 100644 --- a/ldap/servers/slapd/back-ldbm/idl_new.c +++ b/ldap/servers/slapd/back-ldbm/idl_new.c @@ -333,8 +333,14 @@ IDList * idl_new_fetch( error: /* Close the cursor */ if (NULL != cursor) { - if (0 != cursor->c_close(cursor)) { - ldbm_nasty(filename,3,ret); + int ret2 = cursor->c_close(cursor); + if (ret2) { + ldbm_nasty(filename,3,ret2); + if (!ret) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + ret = ret2; + } } } *flag_err = ret; @@ -418,8 +424,9 @@ int idl_new_insert_key( error: /* Close the cursor */ if (NULL != cursor) { - if (0 != cursor->c_close(cursor)) { - ldbm_nasty(filename,56,ret); + int ret2 = cursor->c_close(cursor); + if (ret2) { + ldbm_nasty(filename,56,ret2); } } #else @@ -439,7 +446,7 @@ error: /* this is okay */ ret = 0; } else { - ldbm_nasty(filename,50,ret); + ldbm_nasty(filename,60,ret); } } #endif @@ -491,8 +498,14 @@ int idl_new_delete_key( error: /* Close the cursor */ if (NULL != cursor) { - if (0 != cursor->c_close(cursor)) { - ldbm_nasty(filename,24,ret); + int ret2 = cursor->c_close(cursor); + if (ret2) { + ldbm_nasty(filename,24,ret2); + if (!ret) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + ret = ret2; + } } } return ret; @@ -559,14 +572,17 @@ static int idl_new_store_allids(backend *be, DB *db, DBT *key, DB_TXN *txn) error: /* Close the cursor */ if (NULL != cursor) { - if (0 != cursor->c_close(cursor)) { - ldbm_nasty(filename,33,ret); + int ret2 = cursor->c_close(cursor); + if (ret2) { + ldbm_nasty(filename,33,ret2); } } return ret; +#ifdef KRAZY_K0DE /* If this function is called in "no-allids" mode, then it's a bug */ ldbm_nasty(filename,63,0); return -1; +#endif } #endif @@ -662,8 +678,14 @@ int idl_new_store_block( error: /* Close the cursor */ if (NULL != cursor) { - if (0 != cursor->c_close(cursor)) { - ldbm_nasty(filename,49,ret); + int ret2 = cursor->c_close(cursor); + if (ret2) { + ldbm_nasty(filename,49,ret2); + if (!ret) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + ret = ret2; + } } } return ret; diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c index 0ed691876..0ede6dea8 100644 --- a/ldap/servers/slapd/back-ldbm/index.c +++ b/ldap/servers/slapd/back-ldbm/index.c @@ -1496,14 +1496,23 @@ index_range_read_ext( if(retry_count == IDL_FETCH_RETRY_COUNT) { ldbm_nasty("index_range_read retry count exceeded",1095,*err); } - tmp2 = idl_union( be, idl, tmp ); - idl_free( idl ); - idl_free( tmp ); - idl = tmp2; - if (ALLIDS(idl)) { - LDAPDebug(LDAP_DEBUG_TRACE, "index_range_read hit an allids value\n", - 0, 0, 0); - break; + if (!idl) { + if (slapi_is_loglevel_set(LDAP_DEBUG_TRACE)) { + char encbuf[BUFSIZ]; + LDAPDebug2Args(LDAP_DEBUG_TRACE, + "index_range_read_ext: cur_key=%s(%li bytes) was deleted - skipping\n", + encoded(&cur_key, encbuf), (long)cur_key.dsize); + } + } else { + tmp2 = idl_union( be, idl, tmp ); + idl_free( idl ); + idl_free( tmp ); + idl = tmp2; + if (ALLIDS(idl)) { + LDAPDebug(LDAP_DEBUG_TRACE, "index_range_read hit an allids value\n", + 0, 0, 0); + break; + } } if (DBT_EQ (&cur_key, &upperkey)) { /* this is the last key */ break; diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c index d8773f1de..447ab8451 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c @@ -727,6 +727,12 @@ ldbm_back_delete( Slapi_PBlock *pb ) retval = index_addordel_values_sv(be, LDBM_PARENTID_STR, svals, NULL, e->ep_id, BE_INDEX_ADD, &txn); + if (DB_LOCK_DEADLOCK == retval) { + LDAPDebug0Args( LDAP_DEBUG_ARGS, + "delete (updating " LDBM_PARENTID_STR ") DB_LOCK_DEADLOCK\n"); + /* Retry txn */ + continue; + } if ( retval ) { LDAPDebug( LDAP_DEBUG_TRACE, "delete (deleting %s) failed, err=%d %s\n", @@ -738,18 +744,33 @@ ldbm_back_delete( Slapi_PBlock *pb ) goto error_return; } } - entryrdn_index_entry(be, e, BE_INDEX_DEL, &txn); - retval = - entryrdn_index_entry(be, tombstone, BE_INDEX_ADD, &txn); + retval = entryrdn_index_entry(be, e, BE_INDEX_DEL, &txn); + if (DB_LOCK_DEADLOCK == retval) { + LDAPDebug0Args( LDAP_DEBUG_ARGS, + "delete (deleting entryrdn) DB_LOCK_DEADLOCK\n"); + /* Retry txn */ + continue; + } + if (0 != retval) { + LDAPDebug2Args( LDAP_DEBUG_TRACE, + "delete (deleting entryrdn) failed, err=%d %s\n", + retval, + (msg = dblayer_strerror( retval )) ? msg : "" ); + if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); + goto error_return; + } + retval = entryrdn_index_entry(be, tombstone, BE_INDEX_ADD, &txn); if (DB_LOCK_DEADLOCK == retval) { LDAPDebug0Args( LDAP_DEBUG_ARGS, - "delete (adding entryrdn) DB_LOCK_DEADLOCK\n"); + "adding (adding tombstone entryrdn) DB_LOCK_DEADLOCK\n"); /* Retry txn */ continue; } if (0 != retval) { LDAPDebug2Args( LDAP_DEBUG_TRACE, - "delete (adding entryrdn) failed, err=%d %s\n", + "adding (adding tombstone entryrdn) failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c index 2a7b1e406..4eba4ed9a 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c @@ -280,9 +280,15 @@ bail: if (cursor) { int myrc = cursor->c_close(cursor); if (0 != myrc) { - slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG, + int loglevel = (myrc == DB_LOCK_DEADLOCK) ? SLAPI_LOG_TRACE : SLAPI_LOG_FATAL; + slapi_log_error(loglevel, ENTRYRDN_TAG, "entryrdn_index_entry: Failed to close cursor: %s(%d)\n", - dblayer_strerror(rc), rc); + dblayer_strerror(myrc), myrc); + if (!rc) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + rc = myrc; + } } } if (db) { @@ -388,9 +394,15 @@ bail: if (cursor) { int myrc = cursor->c_close(cursor); if (0 != myrc) { - slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG, - "entryrdn_index_read: Failed to close cursor: " - "%s(%d)\n", dblayer_strerror(rc), rc); + int loglevel = (myrc == DB_LOCK_DEADLOCK) ? SLAPI_LOG_TRACE : SLAPI_LOG_FATAL; + slapi_log_error(loglevel, ENTRYRDN_TAG, + "entryrdn_index_read: Failed to close cursor: %s(%d)\n", + dblayer_strerror(myrc), myrc); + if (!rc) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + rc = myrc; + } } } if (db) { @@ -841,9 +853,15 @@ bail: if (cursor) { int myrc = cursor->c_close(cursor); if (0 != myrc) { - slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG, + int loglevel = (myrc == DB_LOCK_DEADLOCK) ? SLAPI_LOG_TRACE : SLAPI_LOG_FATAL; + slapi_log_error(loglevel, ENTRYRDN_TAG, "entryrdn_rename_subtree: Failed to close cursor: %s(%d)\n", - dblayer_strerror(rc), rc); + dblayer_strerror(myrc), myrc); + if (!rc) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + rc = myrc; + } } } if (db) { @@ -983,9 +1001,15 @@ bail: if (cursor) { int myrc = cursor->c_close(cursor); if (0 != myrc) { - slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG, + int loglevel = (myrc == DB_LOCK_DEADLOCK) ? SLAPI_LOG_TRACE : SLAPI_LOG_FATAL; + slapi_log_error(loglevel, ENTRYRDN_TAG, "entryrdn_get_subordinates: Failed to close cursor: %s(%d)\n", - dblayer_strerror(rc), rc); + dblayer_strerror(myrc), myrc); + if (!rc) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + rc = myrc; + } } } if (db) { @@ -1147,9 +1171,15 @@ bail: if (cursor) { int myrc = cursor->c_close(cursor); if (0 != myrc) { - slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG, + int loglevel = (myrc == DB_LOCK_DEADLOCK) ? SLAPI_LOG_TRACE : SLAPI_LOG_FATAL; + slapi_log_error(loglevel, ENTRYRDN_TAG, "entryrdn_lookup_dn: Failed to close cursor: %s(%d)\n", dblayer_strerror(myrc), myrc); + if (!rc) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + rc = myrc; + } } } /* it is guaranteed that db is not NULL. */ @@ -1294,9 +1324,15 @@ bail: if (cursor) { int myrc = cursor->c_close(cursor); if (0 != myrc) { - slapi_log_error(SLAPI_LOG_FATAL, ENTRYRDN_TAG, + int loglevel = (myrc == DB_LOCK_DEADLOCK) ? SLAPI_LOG_TRACE : SLAPI_LOG_FATAL; + slapi_log_error(loglevel, ENTRYRDN_TAG, "entryrdn_get_parent: Failed to close cursor: %s(%d)\n", - dblayer_strerror(rc), rc); + dblayer_strerror(myrc), myrc); + if (!rc) { + /* if cursor close returns DEADLOCK, we must bubble that up + to the higher layers for retries */ + rc = myrc; + } } } /* it is guaranteed that db is not NULL. */
0
24e80bf035353cdd3fe943bb3f742305d696e25d
389ds/389-ds-base
Ticket #603 - A logic error in str2simple Fix description: str2simple sets the strdup'ed type this way: if ( f->f_choice == LDAP_FILTER_PRESENT ) { f->f_type = slapi_ch_strdup( str ); } else if ( unescape_filter ) { f->f_avtype = slapi_ch_strdup( str ); } if ( !unescape_filter ) { f->f_avtype = slapi_ch_strdup( str ); } If f_choice is LDAP_FILTER_PRESENT and !unescape_filter is true, the first strdup'ed string is leaked since f_type and f_avtype share the same memory. But currently, str2simple is not called with (unescape_filter == 0). Thus there is no chance to satisfy the condition. This patch fixes the flaw. https://fedorahosted.org/389/ticket/603 Reviewed by Rich (Thank you!!)
commit 24e80bf035353cdd3fe943bb3f742305d696e25d Author: Noriko Hosoi <[email protected]> Date: Thu Feb 28 12:49:18 2013 -0800 Ticket #603 - A logic error in str2simple Fix description: str2simple sets the strdup'ed type this way: if ( f->f_choice == LDAP_FILTER_PRESENT ) { f->f_type = slapi_ch_strdup( str ); } else if ( unescape_filter ) { f->f_avtype = slapi_ch_strdup( str ); } if ( !unescape_filter ) { f->f_avtype = slapi_ch_strdup( str ); } If f_choice is LDAP_FILTER_PRESENT and !unescape_filter is true, the first strdup'ed string is leaked since f_type and f_avtype share the same memory. But currently, str2simple is not called with (unescape_filter == 0). Thus there is no chance to satisfy the condition. This patch fixes the flaw. https://fedorahosted.org/389/ticket/603 Reviewed by Rich (Thank you!!) diff --git a/ldap/servers/slapd/str2filter.c b/ldap/servers/slapd/str2filter.c index e6a999669..d5bcc1a6b 100644 --- a/ldap/servers/slapd/str2filter.c +++ b/ldap/servers/slapd/str2filter.c @@ -340,7 +340,7 @@ str2simple( char *str , int unescape_filter) f->f_flags |= SLAPI_FILTER_RUV; } - } if ( !unescape_filter ) { + } else if ( !unescape_filter ) { f->f_avtype = slapi_ch_strdup( str ); f->f_avvalue.bv_val = slapi_ch_strdup ( value ); f->f_avvalue.bv_len = strlen ( f->f_avvalue.bv_val );
0
dd183895a0104bd250757415e5e2df9b7eeee3ca
389ds/389-ds-base
Ticket 49854 - ns-slapd should create run_dir and lock_dir directories at startup Description: dscreate was not creating its config file in /etc/tmpfiles.d/ like setup-ds.pl used to do. The absence of this config file prevented the server from being started after a reboot. https://pagure.io/389-ds-base/issue/49854 Reviewed by: vashirov(Thanks!)
commit dd183895a0104bd250757415e5e2df9b7eeee3ca Author: Mark Reynolds <[email protected]> Date: Wed Jul 18 16:42:49 2018 -0400 Ticket 49854 - ns-slapd should create run_dir and lock_dir directories at startup Description: dscreate was not creating its config file in /etc/tmpfiles.d/ like setup-ds.pl used to do. The absence of this config file prevented the server from being started after a reboot. https://pagure.io/389-ds-base/issue/49854 Reviewed by: vashirov(Thanks!) diff --git a/ldap/admin/src/defaults.inf.in b/ldap/admin/src/defaults.inf.in index bdc408191..ae847e940 100644 --- a/ldap/admin/src/defaults.inf.in +++ b/ldap/admin/src/defaults.inf.in @@ -40,6 +40,7 @@ pid_file = @localstatedir@/run/dirsrv/slapd-{instance_name}.pid inst_dir = @serverdir@/slapd-{instance_name} plugin_dir = @serverplugindir@ system_schema_dir = @systemschemadir@ +tmpfiles_d = @with_tmpfiles_d@ ; These values can be altered in an installation of ds user = dirsrv diff --git a/src/lib389/doc/source/paths.rst b/src/lib389/doc/source/paths.rst index 39680c629..16be4d71f 100644 --- a/src/lib389/doc/source/paths.rst +++ b/src/lib389/doc/source/paths.rst @@ -7,7 +7,7 @@ Usage example # You can get any variable from the list bellow. Like this: product = standalone.ds_paths.product - + variables = [ 'product', 'version', @@ -33,6 +33,7 @@ Usage example 'backup_dir', 'ldif_dir', 'initconfig_dir', + 'tmpfiles_d', ] Module documentation diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py index 7fa68c0b0..c628b9e98 100644 --- a/src/lib389/lib389/instance/remove.py +++ b/src/lib389/lib389/instance/remove.py @@ -35,6 +35,7 @@ def remove_ds_instance(dirsrv): 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 + remove_paths['tmpfiles_d'] = dirsrv.ds_paths.tmpfiles_d + "/dirsrv-" + dirsrv.serverid + ".conf" marker_path = "%s/sysconfig/dirsrv-%s" % (dirsrv.ds_paths.sysconf_dir, dirsrv.serverid) diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py index 23c76db7d..9818e1c65 100644 --- a/src/lib389/lib389/instance/setup.py +++ b/src/lib389/lib389/instance/setup.py @@ -636,6 +636,14 @@ class SetupDs(object): "enable", "dirsrv@%s" % slapd['instance_name']]) + # Setup tmpfiles_d + tmpfile_d = ds_paths.tmpfiles_d + "/dirsrv-" + slapd['instance_name'] + ".conf" + with open(tmpfile_d, "w") as TMPFILE_D: + TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['run_dir'], slapd['user'], slapd['group'])) + TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['lock_dir'].replace("slapd-" + slapd['instance_name'], ""), + slapd['user'], slapd['group'])) + TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['lock_dir'], slapd['user'], slapd['group'])) + # Else we need to detect other init scripts? # Bind sockets to our type? diff --git a/src/lib389/lib389/paths.py b/src/lib389/lib389/paths.py index 4f643d764..54798319c 100644 --- a/src/lib389/lib389/paths.py +++ b/src/lib389/lib389/paths.py @@ -60,6 +60,7 @@ MUST = [ 'backup_dir', 'ldif_dir', 'initconfig_dir', + 'tmpfiles_d', ] # will need to add the access, error, audit log later.
0
c881f6ec028d8c6b7efa7c5924e52ea037fac686
389ds/389-ds-base
Bump version to 1.4.2.4
commit c881f6ec028d8c6b7efa7c5924e52ea037fac686 Author: Mark Reynolds <[email protected]> Date: Thu Nov 14 16:05:32 2019 -0500 Bump version to 1.4.2.4 diff --git a/VERSION.sh b/VERSION.sh index 869aa0545..2e56a2ef9 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=4 -VERSION_MAINT=2.3 +VERSION_MAINT=2.4 # NOTE: VERSION_PREREL is automatically set for builds made out of a git tree VERSION_PREREL= VERSION_DATE=$(date -u +%Y%m%d)
0
3b5f3fa1b82cde2bda1104cf758acb64f6484009
389ds/389-ds-base
Ticket 47889 - DS crashed during ipa-server-install on test_ava_filter Bug Description: During a MOD the target entry is duplicated and mods are applied on the duplicated entry that is set in the pblock (SLAPI_MODIFY_EXISTING_ENTRY). In case of transient DB error, ldbm_back_modify retries. But when retrying the duplicated entry will be freed and needs to be duplicated again. The new duplicated entry needs to be set in the pblock. https://fedorahosted.org/389/ticket/47834 erronously skip the setting of SLAPI_MODIFY_EXISTING_ENTRY Fix Description: Set SLAPI_MODIFY_EXISTING_ENTRY during mod/retry https://fedorahosted.org/389/ticket/47889 Reviewed by: ? Platforms tested: F20 Flag Day: no Doc impact: no
commit 3b5f3fa1b82cde2bda1104cf758acb64f6484009 Author: Thierry bordaz (tbordaz) <[email protected]> Date: Thu Sep 11 09:47:29 2014 +0200 Ticket 47889 - DS crashed during ipa-server-install on test_ava_filter Bug Description: During a MOD the target entry is duplicated and mods are applied on the duplicated entry that is set in the pblock (SLAPI_MODIFY_EXISTING_ENTRY). In case of transient DB error, ldbm_back_modify retries. But when retrying the duplicated entry will be freed and needs to be duplicated again. The new duplicated entry needs to be set in the pblock. https://fedorahosted.org/389/ticket/47834 erronously skip the setting of SLAPI_MODIFY_EXISTING_ENTRY Fix Description: Set SLAPI_MODIFY_EXISTING_ENTRY during mod/retry https://fedorahosted.org/389/ticket/47889 Reviewed by: ? Platforms tested: F20 Flag Day: no Doc impact: no diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c index 254ef29ab..529bd327e 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c @@ -529,6 +529,7 @@ ldbm_back_modify( Slapi_PBlock *pb ) CACHE_REMOVE(&inst->inst_cache, ec); } CACHE_RETURN(&inst->inst_cache, &ec); + slapi_pblock_set( pb, SLAPI_MODIFY_EXISTING_ENTRY, original_entry->ep_entry ); ec = original_entry; original_entry = tmpentry; tmpentry = NULL;
0
bede5727775b3a9d470acc5941b2d6eca80bb79c
389ds/389-ds-base
Bug 744945 - nsslapd-counters attribute value cannot be set to "off" https://bugzilla.redhat.com/show_bug.cgi?id=744945 Description: nsslapd-counters (cn=config) is allowed to have the value "off". Once it's set, cache monitor would not be available. . when staring the server, following message is logged. cache_init: slapi counter is not available. . ldapsearch cache statistics under cn=monitor,cn=<BACKEND>,cn=ldbm database, cn=plugins,cn=config shows 0's: entrycachehits: 0 entrycachetries: 0 entrycachehitratio: 0
commit bede5727775b3a9d470acc5941b2d6eca80bb79c Author: Noriko Hosoi <[email protected]> Date: Mon Oct 10 15:19:46 2011 -0700 Bug 744945 - nsslapd-counters attribute value cannot be set to "off" https://bugzilla.redhat.com/show_bug.cgi?id=744945 Description: nsslapd-counters (cn=config) is allowed to have the value "off". Once it's set, cache monitor would not be available. . when staring the server, following message is logged. cache_init: slapi counter is not available. . ldapsearch cache statistics under cn=monitor,cn=<BACKEND>,cn=ldbm database, cn=plugins,cn=config shows 0's: entrycachehits: 0 entrycachetries: 0 entrycachehitratio: 0 diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c index ff9921a01..3d09bb3f6 100644 --- a/ldap/servers/slapd/back-ldbm/cache.c +++ b/ldap/servers/slapd/back-ldbm/cache.c @@ -536,7 +536,9 @@ int cache_init(struct cache *cache, size_t maxsize, long maxentries, int type) } else { LDAPDebug0Args(LDAP_DEBUG_ANY, "cache_init: slapi counter is not available.\n"); - return 0; + cache->c_cursize = NULL; + cache->c_hits = NULL; + cache->c_tries = NULL; } cache->c_lruhead = cache->c_lrutail = NULL; cache_make_hashes(cache, type);
0
9e9b9024db9a306141c44417ce907f2d23440b86
389ds/389-ds-base
Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939 https://bugzilla.redhat.com/show_bug.cgi?id=613056 Resolves: bug 613056 Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939 description: Catch possible NULL pointer in slapi_entry_syntax_check() and slapi_mods_syntax_check(). Note: reverted the previous fix and added a NULL pb check to make coverity happy. The functions slapi_entry_syntax_check and slapi_mods_syntax_check are designed to allow NULL pb. coverity ID: 11900
commit 9e9b9024db9a306141c44417ce907f2d23440b86 Author: Noriko Hosoi <[email protected]> Date: Mon Aug 23 10:34:51 2010 -0700 Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939 https://bugzilla.redhat.com/show_bug.cgi?id=613056 Resolves: bug 613056 Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939 description: Catch possible NULL pointer in slapi_entry_syntax_check() and slapi_mods_syntax_check(). Note: reverted the previous fix and added a NULL pb check to make coverity happy. The functions slapi_entry_syntax_check and slapi_mods_syntax_check are designed to allow NULL pb. coverity ID: 11900 diff --git a/ldap/servers/slapd/plugin_syntax.c b/ldap/servers/slapd/plugin_syntax.c index 163e8d46d..2e357b417 100644 --- a/ldap/servers/slapd/plugin_syntax.c +++ b/ldap/servers/slapd/plugin_syntax.c @@ -351,6 +351,9 @@ exit: * * Returns 1 if there is a syntax violation and sets the error message * appropriately. Returns 0 if everything checks out fine. + * + * Note: this function allows NULL pb. If NULL, is_replicated_operation + * will not checked and error message will not be generated and returned. */ int slapi_entry_syntax_check( @@ -368,14 +371,10 @@ slapi_entry_syntax_check( char *errp = &errtext[0]; size_t err_remaining = sizeof(errtext); - if (!pb) { - LDAPDebug( LDAP_DEBUG_ANY, "slapi_entry_syntax_check: NULL PBlock\n", 0, 0, 0 ); - ret = 1; - goto exit; + if (pb != NULL) { + slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation); } - slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation); - /* If syntax checking and logging are off, or if this is a * replicated operation, just return that the syntax is OK. */ if (((syntaxcheck == 0) && (syntaxlogging == 0) && (override == 0)) || @@ -408,10 +407,12 @@ slapi_entry_syntax_check( } if (syntaxcheck || override) { - /* Append new text to any existing text. */ - errp += PR_snprintf( errp, err_remaining, - "%s: value #%d invalid per syntax\n", a->a_type, hint ); - err_remaining -= errp - &errtext[0]; + if (pb) { + /* Append new text to any existing text. */ + errp += PR_snprintf( errp, err_remaining, + "%s: value #%d invalid per syntax\n", a->a_type, hint ); + err_remaining -= errp - &errtext[0]; + } ret = 1; } } @@ -426,7 +427,7 @@ slapi_entry_syntax_check( } /* See if we need to set the error text in the pblock. */ - if (errp != &errtext[0]) { + if (pb && (errp != &errtext[0])) { /* Check pb for coverity */ /* SLAPI_PB_RESULT_TEXT duplicates the text in slapi_pblock_set */ slapi_pblock_set( pb, SLAPI_PB_RESULT_TEXT, errtext ); } @@ -441,6 +442,9 @@ exit: * value for a modrdn operation will be checked. * Returns 1 if there is a syntax violation and sets the error message * appropriately. Returns 0 if everything checks out fine. + * + * Note: this function allows NULL pb. If NULL, is_replicated_operation + * will not checked and error message will not be generated and returned. */ int slapi_mods_syntax_check( @@ -458,13 +462,15 @@ slapi_mods_syntax_check( char *dn = NULL; LDAPMod *mod = NULL; - if (pb == NULL || mods == NULL) { + if (mods == NULL) { ret = 1; goto exit; } - slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation); - slapi_pblock_get(pb, SLAPI_TARGET_DN, &dn); + if (pb != NULL) { + slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation); + slapi_pblock_get(pb, SLAPI_TARGET_DN, &dn); + } /* If syntax checking and logging are off, or if this is a * replicated operation, just return that the syntax is OK. */ @@ -496,10 +502,12 @@ slapi_mods_syntax_check( } if (syntaxcheck || override) { - /* Append new text to any existing text. */ - errp += PR_snprintf( errp, err_remaining, - "%s: value #%d invalid per syntax\n", mod->mod_type, j ); - err_remaining -= errp - &errtext[0]; + if (pb) { + /* Append new text to any existing text. */ + errp += PR_snprintf( errp, err_remaining, + "%s: value #%d invalid per syntax\n", mod->mod_type, j ); + err_remaining -= errp - &errtext[0]; + } ret = 1; } } @@ -509,7 +517,7 @@ slapi_mods_syntax_check( } /* See if we need to set the error text in the pblock. */ - if (errp != &errtext[0]) { + if (pb && (errp != &errtext[0])) { /* Check pb for coverity */ /* SLAPI_PB_RESULT_TEXT duplicates the text in slapi_pblock_set */ slapi_pblock_set( pb, SLAPI_PB_RESULT_TEXT, errtext ); }
0
6041c77a179936f64598ed1039274aa05eebea1e
389ds/389-ds-base
Ticket #617 - Possible to add invalid ACI value Fix description: The fix enables the syntax check for ACI even when '(' is not present https://fedorahosted.org/389/ticket/617 Reviewed by nhosoi.
commit 6041c77a179936f64598ed1039274aa05eebea1e Author: Anupam Jain <[email protected]> Date: Tue Jul 23 13:20:13 2013 -0700 Ticket #617 - Possible to add invalid ACI value Fix description: The fix enables the syntax check for ACI even when '(' is not present https://fedorahosted.org/389/ticket/617 Reviewed by nhosoi. diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c index bf027645f..a8a38a176 100644 --- a/ldap/servers/plugins/acl/aclparse.c +++ b/ldap/servers/plugins/acl/aclparse.c @@ -97,8 +97,8 @@ acl_parse(char * str, aci_t *aci_item, char **errbuf) { int rv=0; - char *next; - char *save; + char *next=NULL; + char *save=NULL; while(*str) { __acl_strip_leading_space( &str ); @@ -108,9 +108,12 @@ acl_parse(char * str, aci_t *aci_item, char **errbuf) if ((next = slapi_find_matching_paren(str)) == NULL) { return(ACL_SYNTAX_ERR); } - } else { + } else if (!next) { + /* the statement does not start with a parenthesis */ + return(ACL_SYNTAX_ERR); + } else { /* then we have done all the processing */ - return 0; + return 0; } LDAP_UTF8INC(str); /* skip the "(" */ save = next;
0
99a74d7b6c3c003c23205c5d2db246ef61862ffb
389ds/389-ds-base
Issue 5356 - Make Rust non-optional and update default password storage scheme Description: We need a stronger default storage scheme which comes from our Rust plugins, but to do this Rust needs to be non-optional. It will be a requirement moving forward. relates: https://github.com/389ds/389-ds-base/issues/5356 Reviewed by: firstyear, vashirov, and spichugi (Thanks!!!)
commit 99a74d7b6c3c003c23205c5d2db246ef61862ffb Author: Mark Reynolds <[email protected]> Date: Wed Aug 17 07:55:34 2022 -0400 Issue 5356 - Make Rust non-optional and update default password storage scheme Description: We need a stronger default storage scheme which comes from our Rust plugins, but to do this Rust needs to be non-optional. It will be a requirement moving forward. relates: https://github.com/389ds/389-ds-base/issues/5356 Reviewed by: firstyear, vashirov, and spichugi (Thanks!!!) diff --git a/Makefile.am b/Makefile.am index c75ae5e87..e89fdb50e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,9 +56,6 @@ SYSTEMTAP_DEFINES = @systemtap_defs@ NSPR_INCLUDES = $(NSPR_CFLAGS) # Rust inclusions. -if RUST_ENABLE -# Rust enabled -RUST_ON = 1 CARGO_FLAGS = @cargo_defs@ if CLANG_ENABLE @@ -77,14 +74,6 @@ RUST_OFFLINE = --locked --offline else RUST_OFFLINE = endif -else -# Rust disabled -RUST_ON = 0 -CARGO_FLAGS = -RUSTC_FLAGS = -RUST_LDFLAGS = -RUST_DEFINES = -endif if CLANG_ENABLE CLANG_ON = 1 @@ -250,13 +239,9 @@ SLAPD_LDFLAGS = -version-info 1:0:1 #------------------------ # Generated Sources #------------------------ -BUILT_SOURCES = dberrstrs.h \ +BUILT_SOURCES = dberrstrs.h rust-slapi-private.h rust-nsslapd-private.h \ $(POLICY_FC) -if RUST_ENABLE -BUILT_SOURCES += rust-slapi-private.h rust-nsslapd-private.h -endif - if enable_posix_winsync LIBPOSIX_WINSYNC_PLUGIN = libposix-winsync-plugin.la endif @@ -270,20 +255,14 @@ CLEANFILES = dberrstrs.h ns-slapd.properties \ ldap/ldif/template-ldapi.ldif ldap/ldif/template-locality.ldif ldap/ldif/template-org.ldif \ ldap/ldif/template-orgunit.ldif ldap/ldif/template-pampta.ldif ldap/ldif/template-sasl.ldif \ ldap/ldif/template-state.ldif ldap/ldif/template-suffix-db.ldif \ - doxyfile.stamp \ + doxyfile.stamp rust-slapi-private.h\ $(NULL) -if RUST_ENABLE -CLEANFILES += rust-slapi-private.h -endif - clean-local: -rm -rf dist -rm -rf $(abs_top_builddir)/html -rm -rf $(abs_top_builddir)/man/man3 -if RUST_ENABLE -rm -rf $(abs_top_builddir)/rs -endif dberrstrs.h: Makefile $(srcdir)/ldap/servers/slapd/mkDBErrStrs.py $(srcdir)/ldap/servers/slapd/back-ldbm/dbimpl.h $(srcdir)/ldap/servers/slapd/mkDBErrStrs.py -i $(srcdir)/ldap/servers/slapd/back-ldbm -o . @@ -382,13 +361,8 @@ serverplugin_LTLIBRARIES = libacl-plugin.la \ libacctusability-plugin.la librootdn-access-plugin.la \ libwhoami-plugin.la $(LIBACCTPOLICY_PLUGIN) \ $(LIBPAM_PASSTHRU_PLUGIN) $(LIBDNA_PLUGIN) \ - $(LIBBITWISE_PLUGIN) $(LIBPRESENCE_PLUGIN) $(LIBPOSIX_WINSYNC_PLUGIN) - -if RUST_ENABLE -serverplugin_LTLIBRARIES += libentryuuid-plugin.la libentryuuid-syntax-plugin.la \ - libpwdchan-plugin.la -endif - + $(LIBBITWISE_PLUGIN) $(LIBPRESENCE_PLUGIN) $(LIBPOSIX_WINSYNC_PLUGIN) \ + libentryuuid-plugin.la libentryuuid-syntax-plugin.la libpwdchan-plugin.la noinst_LIBRARIES = libavl.a @@ -683,12 +657,9 @@ systemschema_DATA = $(srcdir)/ldap/schema/00core.ldif \ $(srcdir)/ldap/schema/60sudo.ldif \ $(srcdir)/ldap/schema/60trust.ldif \ $(srcdir)/ldap/schema/60nss-ldap.ldif \ + $(srcdir)/ldap/schema/03entryuuid.ldif \ $(LIBACCTPOLICY_SCHEMA) -if RUST_ENABLE -systemschema_DATA += $(srcdir)/ldap/schema/03entryuuid.ldif -endif - schema_DATA = $(srcdir)/ldap/schema/99user.ldif libexec_SCRIPTS = @@ -846,8 +817,6 @@ libsvrcore_la_LDFLAGS = $(AM_LDFLAGS) libsvrcore_la_CPPFLAGS = $(AM_CPPFLAGS) $(SVRCORE_INCLUDES) $(DSPLUGIN_CPPFLAGS) libsvrcore_la_LIBADD = $(NSS_LINK) $(NSPR_LINK) -if RUST_ENABLE - noinst_LTLIBRARIES = librslapd.la librnsslapd.la libentryuuid.la libentryuuid_syntax.la \ libpwdchan.la @@ -1034,9 +1003,6 @@ check-local: endif endif -# End if RUST_ENABLE -endif - #------------------------ # libns-dshttpd #------------------------ @@ -1200,7 +1166,7 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \ $(libavl_a_SOURCES) libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) $(DB_INC) $(KERBEROS_CFLAGS) $(PCRE_CFLAGS) $(SVRCORE_INCLUDES) -libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LIBS) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LIBS) libsvrcore.la +libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LIBS) $(PCRE_LIBS) $(THREADLIB) $(SYSTEMD_LIBS) libsvrcore.la $(RSLAPD_LIB) # If asan is enabled, it creates special libcrypt interceptors. However, they are # detected by the first load of libasan at runtime, and what is in the linked lib # so we need libcrypt to be present as soon as libasan is loaded for the interceptors @@ -1209,14 +1175,7 @@ libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(KER if enable_asan libslapd_la_LIBADD += $(LIBCRYPT) endif -libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS) - -if RUST_ENABLE -libslapd_la_LIBADD += $(RSLAPD_LIB) -libslapd_la_LDFLAGS += -lssl -lcrypto -endif - - +libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS) -lssl -lcrypto #//////////////////////////////////////////////////////////////// # @@ -1481,7 +1440,6 @@ libderef_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) libderef_plugin_la_DEPENDENCIES = libslapd.la libderef_plugin_la_LDFLAGS = -avoid-version -if RUST_ENABLE #------------------------ # libentryuuid-syntax-plugin #----------------------- @@ -1505,7 +1463,6 @@ libpwdchan_plugin_la_SOURCES = src/slapi_r_plugin/src/init.c libpwdchan_plugin_la_LIBADD = libslapd.la $(LDAPSDK_LINK) $(NSPR_LINK) -lpwdchan libpwdchan_plugin_la_DEPENDENCIES = libslapd.la $(PWDCHAN_LIB) libpwdchan_plugin_la_LDFLAGS = -avoid-version -endif #------------------------ # libpbe-plugin @@ -1910,23 +1867,13 @@ ns_slapd_SOURCES = ldap/servers/slapd/abandon.c \ ns_slapd_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_CFLAGS) $(SVRCORE_INCLUDES) $(CFI_CFLAGS) # We need our libraries to come first, then our externals libraries second. -ns_slapd_LDADD = libslapd.la libldaputil.la libsvrcore.la -if RUST_ENABLE -ns_slapd_LDADD += $(RNSSLAPD_LIB) -endif -ns_slapd_LDADD += $(LDAPSDK_LINK) $(NSS_LINK) $(LIBADD_DL) \ +ns_slapd_LDADD = libslapd.la libldaputil.la libsvrcore.la $(RNSSLAPD_LIB) + +ns_slapd_LDADD += $(LDAPSDK_LINK) $(NSS_LINK) $(LIBADD_DL) -lssl -lcrypto \ $(NSPR_LINK) $(SASL_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LIBS) $(EVENT_LINK) -if RUST_ENABLE -ns_slapd_LDADD += -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 -# some C++ shared libraries (such as icu). -if HPUX -ns_slapd_LINK = $(CXXLINK) -else ns_slapd_LINK = $(LINK) -endif #------------------------ @@ -2023,7 +1970,6 @@ fixupcmd = sed \ -e 's,@enable_tsan\@,$(TSAN_ON),g' \ -e 's,@enable_ubsan\@,$(UBSAN_ON),g' \ -e 's,@SANITIZER\@,$(SANITIZER),g' \ - -e 's,@enable_rust\@,@enable_rust@,g' \ -e 's,@ECHO_N\@,$(ECHO_N),g' \ -e 's,@ECHO_C\@,$(ECHO_C),g' \ -e 's,@brand\@,$(brand),g' \ diff --git a/configure.ac b/configure.ac index df4bc84a6..759c45a89 100644 --- a/configure.ac +++ b/configure.ac @@ -95,12 +95,7 @@ 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 ]) -AC_MSG_RESULT($enable_rust) -if test "$enable_rust" = yes -o "$enable_rust_offline" = yes; then +if test "$enable_rust_offline" = yes; then AC_CHECK_PROG(CARGO, [cargo], [yes], [no]) AC_CHECK_PROG(RUSTC, [rustc], [yes], [no]) # Since fernet uses the openssl lib. @@ -110,8 +105,6 @@ if test "$enable_rust" = yes -o "$enable_rust_offline" = yes; then AC_MSG_FAILURE("Rust based plugins cannot be built cargo=$CARGO rustc=$RUSTC") ]) fi -AC_SUBST([enable_rust]) -AM_CONDITIONAL([RUST_ENABLE],[test "$enable_rust" = yes -o "$enable_rust_offline" = yes]) # Optional cockpit support (enabled by default) AC_MSG_CHECKING(for --enable-cockpit) diff --git a/dirsrvtests/tests/suites/healthcheck/health_security_test.py b/dirsrvtests/tests/suites/healthcheck/health_security_test.py index 33b62e3c0..2967d8d2b 100644 --- a/dirsrvtests/tests/suites/healthcheck/health_security_test.py +++ b/dirsrvtests/tests/suites/healthcheck/health_security_test.py @@ -78,7 +78,7 @@ def test_healthcheck_insecure_pwd_hash_configured(topology_st): 2. Configure an insecure passwordStorageScheme (as SHA) for the instance 3. Use HealthCheck without --json option 4. Use HealthCheck with --json option - 5. Set passwordStorageScheme and nsslapd-rootpwstoragescheme to PBKDF2_SHA256 + 5. Set passwordStorageScheme and nsslapd-rootpwstoragescheme to PBKDF2_SHA512 6. Use HealthCheck without --json option 7. Use HealthCheck with --json option :expectedresults: @@ -106,9 +106,9 @@ def test_healthcheck_insecure_pwd_hash_configured(topology_st): standalone.config.set('passwordStorageScheme', 'SSHA512') standalone.config.set('nsslapd-rootpwstoragescheme', 'SSHA512') else: - log.info('Set passwordStorageScheme and nsslapd-rootpwstoragescheme to PBKDF2_SHA256') - standalone.config.set('passwordStorageScheme', 'PBKDF2_SHA256') - standalone.config.set('nsslapd-rootpwstoragescheme', 'PBKDF2_SHA256') + log.info('Set passwordStorageScheme and nsslapd-rootpwstoragescheme to PBKDF2-SHA512') + standalone.config.set('passwordStorageScheme', 'PBKDF2-SHA512') + standalone.config.set('nsslapd-rootpwstoragescheme', 'PBKDF2-SHA512') run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT) run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT) diff --git a/dirsrvtests/tests/suites/password/pwp_test.py b/dirsrvtests/tests/suites/password/pwp_test.py index f331d1950..cb80dc8be 100644 --- a/dirsrvtests/tests/suites/password/pwp_test.py +++ b/dirsrvtests/tests/suites/password/pwp_test.py @@ -27,7 +27,7 @@ else: if is_fips(): DEFAULT_PASSWORD_STORAGE_SCHEME = 'SSHA512' else: - DEFAULT_PASSWORD_STORAGE_SCHEME = 'PBKDF2_SHA256' + DEFAULT_PASSWORD_STORAGE_SCHEME = 'PBKDF2-SHA512' def _create_user(topo, uid, cn, uidNumber, userpassword): diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c index 80e5ec4f4..eb8c9a4fe 100644 --- a/ldap/servers/slapd/config.c +++ b/ldap/servers/slapd/config.c @@ -40,16 +40,15 @@ char *rel2abspath(char *); * see fedse.c instead! */ static char *bootstrap_plugins[] = { - "dn: cn=PBKDF2_SHA256,cn=Password Storage Schemes,cn=plugins,cn=config\n" + "dn: cn=PBKDF2-SHA512,cn=Password Storage Schemes,cn=plugins,cn=config\n" "objectclass: top\n" "objectclass: nsSlapdPlugin\n" - "cn: PBKDF2_SHA256\n" - "nsslapd-pluginpath: libpwdstorage-plugin\n" - "nsslapd-plugininitfunc: pbkdf2_sha256_pwd_storage_scheme_init\n" + "cn: PBKDF2-SHA512\n" + "nsslapd-pluginpath: libpwdchan-plugin\n" + "nsslapd-plugininitfunc: pwdchan_pbkdf2_sha512_plugin_init\n" "nsslapd-plugintype: pwdstoragescheme\n" - "nsslapd-pluginenabled: on", + "nsslapd-pluginenabled: on\n", -#ifdef RUST_ENABLE "dn: cn=entryuuid_syntax,cn=plugins,cn=config\n" "objectclass: top\n" "objectclass: nsSlapdPlugin\n" @@ -62,7 +61,6 @@ static char *bootstrap_plugins[] = { "nsslapd-pluginVersion: none\n" "nsslapd-pluginVendor: 389 Project\n" "nsslapd-pluginDescription: entryuuid_syntax\n", -#endif NULL }; diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c index 5f4432591..2f32fdf96 100644 --- a/ldap/servers/slapd/dn.c +++ b/ldap/servers/slapd/dn.c @@ -21,13 +21,8 @@ #include <sys/socket.h> #include "slap.h" #include <plhash.h> - -#ifdef RUST_ENABLE #include <rust-slapi-private.h> -#else -/* For the ndn cache - this gives up siphash13 */ -uint64_t sds_siphash13(const void *src, size_t src_sz, const char key[16]); -#endif + #undef SDN_DEBUG @@ -50,18 +45,6 @@ struct ndn_cache_stats { uint64_t slots; }; -#ifndef RUST_ENABLE -struct ndn_cache_value { - uint64_t size; - uint64_t slot; - char *dn; - char *ndn; - struct ndn_cache_value *next; - struct ndn_cache_value *prev; - struct ndn_cache_value *child; -}; -#endif - /* * This uses a similar alloc trick to IDList to keep * The amount of derefs small. @@ -70,33 +53,7 @@ struct ndn_cache { /* * We keep per thread stats and flush them occasionally */ -#ifdef RUST_ENABLE ARCacheChar *cache; -#else - /* Need to track this because we need to provide diffs to counter */ - uint64_t last_count; - uint64_t count; - /* Number of ops */ - uint64_t tries; - /* hit vs miss. in theroy miss == tries - hits.*/ - uint64_t hits; - /* How many values we kicked out */ - uint64_t evicts; - /* Need to track this because we need to provide diffs to counter */ - uint64_t last_size; - uint64_t size; - uint64_t slots; - /* The per-thread max size */ - uint64_t max_size; - /* - * This is used by siphash to prevent hash bucket attacks - */ - char key[16]; - - struct ndn_cache_value *head; - struct ndn_cache_value *tail; - struct ndn_cache_value *table[1]; -#endif }; /* @@ -2891,12 +2848,6 @@ slapi_sdn_get_size(const Slapi_DN *sdn) * */ - -#ifndef RUST_ENABLE -static pthread_key_t ndn_cache_key; -static pthread_once_t ndn_cache_key_once = PTHREAD_ONCE_INIT; -static struct ndn_cache_stats t_cache_stats = {0}; -#endif /* * WARNING: For some reason we try to use the NDN cache *before* * we have a chance to configure it. As a result, we need to rely @@ -2908,120 +2859,7 @@ static struct ndn_cache_stats t_cache_stats = {0}; * not bother until we improve libglobs to be COW. */ static int32_t ndn_enabled = 0; -#ifdef RUST_ENABLE static ARCacheChar *cache = NULL; -#endif - - -#ifdef RUST_ENABLE -#else -static void -ndn_thread_cache_commit_status(struct ndn_cache *t_cache) { - /* - * Every so often we commit these atomically. We do this infrequently - * to avoid the costly atomics. - */ - if (t_cache->tries % NDN_STAT_COMMIT_FREQUENCY == 0) { - /* We can just add tries and hits. */ - slapi_counter_add(t_cache_stats.cache_evicts, t_cache->evicts); - slapi_counter_add(t_cache_stats.cache_tries, t_cache->tries); - slapi_counter_add(t_cache_stats.cache_hits, t_cache->hits); - t_cache->hits = 0; - t_cache->tries = 0; - t_cache->evicts = 0; - /* Count and size need diff */ - // Get the size from the main cache. - int64_t diff = (t_cache->size - t_cache->last_size); - if (diff > 0) { - // We have more .... - slapi_counter_add(t_cache_stats.cache_size, (uint64_t)diff); - } else if (diff < 0) { - slapi_counter_subtract(t_cache_stats.cache_size, (uint64_t)llabs(diff)); - } - t_cache->last_size = t_cache->size; - - diff = (t_cache->count - t_cache->last_count); - if (diff > 0) { - // We have more .... - slapi_counter_add(t_cache_stats.cache_count, (uint64_t)diff); - } else if (diff < 0) { - slapi_counter_subtract(t_cache_stats.cache_count, (uint64_t)llabs(diff)); - } - t_cache->last_count = t_cache->count; - - } -} -#endif - -#ifndef RUST_ENABLE -static void -ndn_thread_cache_value_destroy(struct ndn_cache *t_cache, struct ndn_cache_value *v) { - /* Update stats */ - t_cache->size = t_cache->size - v->size; - t_cache->count--; - t_cache->evicts++; - - if (v == t_cache->head) { - t_cache->head = v->prev; - } - if (v == t_cache->tail) { - t_cache->tail = v->next; - } - - /* Cut the node out. */ - if (v->next != NULL) { - v->next->prev = v->prev; - } - if (v->prev != NULL) { - v->prev->next = v->next; - } - /* Set the pointer in the table to NULL */ - /* Now see if we were in a list */ - struct ndn_cache_value *slot_node = t_cache->table[v->slot]; - if (slot_node == v) { - t_cache->table[v->slot] = v->child; - } else { - struct ndn_cache_value *former_slot_node = NULL; - do { - former_slot_node = slot_node; - slot_node = slot_node->child; - } while(slot_node != v); - /* Okay, now slot_node is us, and former is our parent */ - former_slot_node->child = v->child; - } - - slapi_ch_free((void **)&(v->dn)); - slapi_ch_free((void **)&(v->ndn)); - slapi_ch_free((void **)&v); -} -#endif - - -#ifndef RUST_ENABLE -static void -ndn_thread_cache_destroy(void *v_cache) { - struct ndn_cache *t_cache = (struct ndn_cache *)v_cache; - /* - * FREE ALL THE NODES!!! - */ - struct ndn_cache_value *node = t_cache->tail; - struct ndn_cache_value *next_node = NULL; - while (node) { - next_node = node->next; - ndn_thread_cache_value_destroy(t_cache, node); - node = next_node; - } - slapi_ch_free((void **)&t_cache); -} - -static void -ndn_cache_key_init(void) { - if (pthread_key_create(&ndn_cache_key, ndn_thread_cache_destroy) != 0) { - /* Log a scary warning? */ - slapi_log_err(SLAPI_LOG_ERR, "ndn_cache_init", "Failed to create pthread key, aborting.\n"); - } -} -#endif int32_t ndn_cache_init() @@ -3036,7 +2874,6 @@ ndn_cache_init() return 0; } -#ifdef RUST_ENABLE uint64_t max_size = config_get_ndn_cache_size(); if (max_size < NDN_CACHE_MINIMUM_CAPACITY) { max_size = NDN_CACHE_MINIMUM_CAPACITY; @@ -3049,45 +2886,7 @@ ndn_cache_init() uintptr_t max_thread_read = 0; /* Setup the main cache which all other caches will inherit. */ cache = cache_char_create(max_estimate, max_thread_read); -#else - /* Create the pthread key */ - (void)pthread_once(&ndn_cache_key_once, ndn_cache_key_init); - /* Get thread numbers and calc the per thread size */ - int32_t maxthreads = (int32_t)config_get_threadnumber(); - size_t tentative_size = t_cache_stats.max_size / maxthreads; - if (tentative_size < NDN_CACHE_MINIMUM_CAPACITY) { - tentative_size = NDN_CACHE_MINIMUM_CAPACITY; - t_cache_stats.max_size = NDN_CACHE_MINIMUM_CAPACITY * maxthreads; - } - t_cache_stats.thread_max_size = tentative_size; - /* - * Slots *must* be a power of two, even if the number of entries - * we store will be *less* than this. - */ - size_t possible_elements = tentative_size / NDN_ENTRY_AVG_SIZE; - /* - * So this is like 1048576 / 168, so we get 6241. Now we need to - * shift this to get the number of bits. - */ - size_t shifts = 0; - while (possible_elements > 0) { - shifts++; - possible_elements = possible_elements >> 1; - } - /* - * So now we can use this to make the slot count. - */ - t_cache_stats.slots = 1 << shifts; - /* Create the global stats. */ - t_cache_stats.max_size = config_get_ndn_cache_size(); - t_cache_stats.cache_evicts = slapi_counter_new(); - t_cache_stats.cache_tries = slapi_counter_new(); - t_cache_stats.cache_hits = slapi_counter_new(); - t_cache_stats.cache_count = slapi_counter_new(); - t_cache_stats.cache_size = slapi_counter_new(); -#endif - /* Done? */ return 0; } @@ -3097,15 +2896,7 @@ ndn_cache_destroy() if (ndn_enabled == 0) { return; } -#ifdef RUST_ENABLE cache_char_free(cache); -#else - slapi_counter_destroy(&(t_cache_stats.cache_tries)); - slapi_counter_destroy(&(t_cache_stats.cache_hits)); - slapi_counter_destroy(&(t_cache_stats.cache_count)); - slapi_counter_destroy(&(t_cache_stats.cache_size)); - slapi_counter_destroy(&(t_cache_stats.cache_evicts)); -#endif } int @@ -3117,9 +2908,6 @@ ndn_cache_started() /* * Look up this dn in the ndn cache */ -#ifdef RUST_ENABLE -/* This is the rust version of the ndn cache */ - static int32_t ndn_cache_lookup(char *dn, size_t dn_len, char **ndn, char **udn, int32_t *rc) { @@ -3183,211 +2971,10 @@ ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len) slapi_ch_free_string(&dn); } -#else -static struct ndn_cache * -ndn_thread_cache_create(size_t thread_max_size, size_t slots) { - size_t t_cache_size = sizeof(struct ndn_cache) + (slots * sizeof(struct ndn_cache_value *)); - struct ndn_cache *t_cache = (struct ndn_cache *)slapi_ch_calloc(1, t_cache_size); - -#ifdef RUST_ENABLE - t_cache->cache = cache; -#else - t_cache->max_size = thread_max_size; - t_cache->slots = slots; -#endif - - return t_cache; -} - -static int -ndn_cache_lookup(char *dn, size_t dn_len, char **ndn, char **udn, int *rc) -{ - if (ndn_enabled == 0 || NULL == udn) { - return 0; - } - *udn = NULL; - - if (dn_len == 0) { - *ndn = dn; - *rc = 0; - return 1; - } - - struct ndn_cache *t_cache = pthread_getspecific(ndn_cache_key); - if (t_cache == NULL) { - t_cache = ndn_thread_cache_create(t_cache_stats.thread_max_size, t_cache_stats.slots); - pthread_setspecific(ndn_cache_key, t_cache); - /* If we have no cache, we can't look up ... */ - return 0; - } - - t_cache->tries++; - - /* - * Hash our DN ... - */ - uint64_t dn_hash = sds_siphash13(dn, dn_len, t_cache->key); - /* Where should it be? */ - size_t expect_slot = dn_hash % t_cache->slots; - - /* - * Is it there? - */ - if (t_cache->table[expect_slot] != NULL) { - /* - * Check it really matches, could be collision. - */ - struct ndn_cache_value *node = t_cache->table[expect_slot]; - while (node != NULL) { - if (strcmp(dn, node->dn) == 0) { - /* - * Update LRU - * Are we already the tail? If so, we can just skip. - * remember, this means in a set of 1, we will always be tail - */ - if (t_cache->tail != node) { - /* - * Okay, we are *not* the tail. We could be anywhere between - * tail -> ... -> x -> head - * or even, we are the head ourself. - */ - if (t_cache->head == node) { - /* We are the head, update head to our predecessor */ - t_cache->head = node->prev; - /* Remember, the head has no next. */ - t_cache->head->next = NULL; - } else { - /* Right, we aren't the head, so we have a next node. */ - node->next->prev = node->prev; - } - /* Because we must be in the middle somewhere, we can assume next and prev exist. */ - node->prev->next = node->next; - /* - * Tail can't be NULL if we have a value in the cache, so we can - * just deref this. - */ - node->next = t_cache->tail; - t_cache->tail->prev = node; - t_cache->tail = node; - node->prev = NULL; - } - - /* Update that we have a hit.*/ - t_cache->hits++; - /* Cope the NDN to the caller. */ - *ndn = slapi_ch_strdup(node->ndn); - /* Indicate to the caller to free this. */ - *rc = 1; - ndn_thread_cache_commit_status(t_cache); - return 1; - } - node = node->child; - } - } - /* If we miss, we need to duplicate dn to udn here. */ - *udn = slapi_ch_strdup(dn); - *rc = 0; - ndn_thread_cache_commit_status(t_cache); - return 0; -} - -/* - * Add a ndn to the cache. Try and do as much as possible before taking the write lock. - */ -static void -ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len) -{ - if (ndn_enabled == 0) { - return; - } - if (dn_len == 0) { - return; - } - if (strlen(ndn) > ndn_len) { - /* we need to null terminate the ndn */ - *(ndn + ndn_len) = '\0'; - } - /* - * Calculate the approximate memory footprint of the hash entry, key, and lru entry. - */ - struct ndn_cache_value *new_value = (struct ndn_cache_value *)slapi_ch_calloc(1, sizeof(struct ndn_cache_value)); - new_value->size = sizeof(struct ndn_cache_value) + dn_len + ndn_len; - /* DN is alloc for us */ - new_value->dn = dn; - /* But we need to copy ndn */ - new_value->ndn = slapi_ch_strdup(ndn); - - /* - * Get our local cache out. - */ - struct ndn_cache *t_cache = pthread_getspecific(ndn_cache_key); - if (t_cache == NULL) { - t_cache = ndn_thread_cache_create(t_cache_stats.thread_max_size, t_cache_stats.slots); - pthread_setspecific(ndn_cache_key, t_cache); - } - /* - * Hash the DN - */ - uint64_t dn_hash = sds_siphash13(new_value->dn, dn_len, t_cache->key); - /* - * Get the insert slot: This works because the number spaces of dn_hash is - * a 64bit int, and slots is a power of two. As a result, we end up with - * even distribution of the values. - */ - size_t insert_slot = dn_hash % t_cache->slots; - /* Track this for free */ - new_value->slot = insert_slot; - - /* - * Okay, check if we have space, else we need to trim nodes from - * the LRU - */ - while (t_cache->head && (t_cache->size + new_value->size) > t_cache->max_size) { - struct ndn_cache_value *trim_node = t_cache->head; - ndn_thread_cache_value_destroy(t_cache, trim_node); - } - - /* - * Add it! - */ - if (t_cache->table[insert_slot] == NULL) { - t_cache->table[insert_slot] = new_value; - } else { - /* - * Hash collision! We need to replace the bucket then .... - * insert at the head of the slot to make this simpler. - */ - new_value->child = t_cache->table[insert_slot]; - t_cache->table[insert_slot] = new_value; - } - - /* - * Finally, stick this onto the tail because it's the newest. - */ - if (t_cache->head == NULL) { - t_cache->head = new_value; - } - if (t_cache->tail != NULL) { - new_value->next = t_cache->tail; - t_cache->tail->prev = new_value; - } - t_cache->tail = new_value; - - /* - * And update the stats. - */ - t_cache->size = t_cache->size + new_value->size; - t_cache->count++; - -} -#endif -/* end rust_enable */ - /* stats for monitor */ void ndn_cache_get_stats(uint64_t *hits, uint64_t *tries, uint64_t *size, uint64_t *max_size, uint64_t *thread_size, uint64_t *evicts, uint64_t *slots, uint64_t *count) { -#ifdef RUST_ENABLE /* * A pretty big note here - the ARCache stores things by slot, not size, because * getting the real byte size is expensive in some cases (that are beyond this @@ -3425,16 +3012,6 @@ ndn_cache_get_stats(uint64_t *hits, uint64_t *tries, uint64_t *size, uint64_t *m *tries = *hits + reader_includes + write_inc_or_mod; *size = (freq + recent) * NDN_ENTRY_AVG_SIZE; *count = (freq + recent); -#else - *max_size = t_cache_stats.max_size; - *thread_size = t_cache_stats.thread_max_size; - *slots = t_cache_stats.slots; - *evicts = slapi_counter_get_value(t_cache_stats.cache_evicts); - *hits = slapi_counter_get_value(t_cache_stats.cache_hits); - *tries = slapi_counter_get_value(t_cache_stats.cache_tries); - *size = slapi_counter_get_value(t_cache_stats.cache_size); - *count = slapi_counter_get_value(t_cache_stats.cache_count); -#endif } /* Common ancestor sdn is allocated. diff --git a/ldap/servers/slapd/extendop.c b/ldap/servers/slapd/extendop.c index fc713573e..ed7b901f6 100644 --- a/ldap/servers/slapd/extendop.c +++ b/ldap/servers/slapd/extendop.c @@ -15,11 +15,8 @@ #include <stdio.h> #include "slap.h" - -/* If available, expose rust types. */ -#ifdef RUST_ENABLE #include <rust-nsslapd-private.h> -#endif + static const char *extended_op_oid2string(const char *oid); @@ -206,8 +203,6 @@ extop_handle_import_done(Slapi_PBlock *pb, char *extoid __attribute__((unused)), return; } - -#ifdef RUST_ENABLE static void extop_handle_ldapssotoken_request(Slapi_PBlock *pb, char *extoid __attribute__((unused)), struct berval *extval) { BerElement *ber = NULL; @@ -258,8 +253,6 @@ extop_handle_ldapssotoken_request(Slapi_PBlock *pb, char *extoid __attribute__(( ber_bvfree(bvp); return; } -#endif - void do_extended(Slapi_PBlock *pb) @@ -411,7 +404,6 @@ do_extended(Slapi_PBlock *pb) * Auth tokens are generated outside of transactions, and are just part of the * main server, so we do it now before consulting plugins - WB */ -#ifdef RUST_ENABLE if (strcmp(extoid, EXTOP_LDAPSSOTOKEN_REQUEST_OID) == 0 && config_get_enable_ldapssotoken()) { /* * We want to generate an auth token for this user. @@ -433,7 +425,6 @@ do_extended(Slapi_PBlock *pb) goto free_and_return; } } -#endif rc = plugin_determine_exop_plugins(extoid, &p); slapi_log_err(SLAPI_LOG_TRACE, "do_extended", "Plugin_determine_exop_plugins rc %d\n", rc); diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c index 097f24762..00509654c 100644 --- a/ldap/servers/slapd/fedse.c +++ b/ldap/servers/slapd/fedse.c @@ -119,7 +119,6 @@ static const char *internal_entries[] = "cn:SNMP\n" "nsSNMPEnabled: on\n", -#ifdef RUST_ENABLE "dn: cn=entryuuid_syntax,cn=plugins,cn=config\n" "objectclass: top\n" "objectclass: nsSlapdPlugin\n" @@ -145,7 +144,6 @@ static const char *internal_entries[] = "nsslapd-pluginVersion: none\n" "nsslapd-pluginVendor: 389 Project\n" "nsslapd-pluginDescription: entryuuid\n", -#endif "dn: cn=Password Storage Schemes,cn=plugins,cn=config\n" "objectclass: top\n" @@ -217,7 +215,6 @@ static const char *internal_entries[] = "nsslapd-pluginVendor: 389 Project\n" "nsslapd-pluginDescription: GOST_YESCRYPT\n", -#ifdef RUST_ENABLE "dn: cn=PBKDF2,cn=Password Storage Schemes,cn=plugins,cn=config\n" "objectclass: top\n" "objectclass: nsSlapdPlugin\n" @@ -256,20 +253,6 @@ static const char *internal_entries[] = "nsslapd-pluginVersion: none\n" "nsslapd-pluginVendor: 389 Project\n" "nsslapd-pluginDescription: PBKDF2-SHA256\n", - - "dn: cn=PBKDF2-SHA512,cn=Password Storage Schemes,cn=plugins,cn=config\n" - "objectclass: top\n" - "objectclass: nsSlapdPlugin\n" - "cn: PBKDF2-SHA512\n" - "nsslapd-pluginpath: libpwdchan-plugin\n" - "nsslapd-plugininitfunc: pwdchan_pbkdf2_sha512_plugin_init\n" - "nsslapd-plugintype: pwdstoragescheme\n" - "nsslapd-pluginenabled: on\n" - "nsslapd-pluginId: PBKDF2-SHA512\n" - "nsslapd-pluginVersion: none\n" - "nsslapd-pluginVendor: 389 Project\n" - "nsslapd-pluginDescription: PBKDF2-SHA512\n", -#endif }; static int NUM_INTERNAL_ENTRIES = sizeof(internal_entries) / sizeof(internal_entries[0]); diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 8123e5ad7..674e3e3ab 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -133,10 +133,7 @@ #include <malloc.h> #endif #include <sys/resource.h> - -#ifdef RUST_ENABLE #include <rust-slapi-private.h> -#endif #define REMOVE_CHANGELOG_CMD "remove" @@ -1386,7 +1383,6 @@ static struct config_get_and_set NULL, 0, (void **)&global_slapdFrontendConfig.enable_ldapssotoken, CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_ldapssotoken, &init_enable_ldapssotoken, NULL}, -#ifdef RUST_ENABLE {CONFIG_LDAPSSOTOKEN_SECRET, config_set_ldapssotoken_secret, NULL, 0, NULL, @@ -1397,7 +1393,6 @@ static struct config_get_and_set NULL, 0, (void **)&global_slapdFrontendConfig.ldapssotoken_ttl, CONFIG_INT, NULL, SLAPD_DEFAULT_LDAPSSOTOKEN_TTL_STR, NULL}, -#endif {CONFIG_TCP_FIN_TIMEOUT, config_set_tcp_fin_timeout, NULL, 0, (void **)&global_slapdFrontendConfig.tcp_fin_timeout, CONFIG_INT, @@ -1697,10 +1692,9 @@ FrontendConfig_init(void) struct rlimit rlp; int64_t maxdescriptors = SLAPD_DEFAULT_MAXDESCRIPTORS; -#ifdef RUST_ENABLE /* prove rust is working */ PR_ASSERT(do_nothing_rust() == 0); -#endif + #if SLAPI_CFG_USE_RWLOCK == 1 /* initialize the read/write configuration lock */ @@ -1976,13 +1970,10 @@ FrontendConfig_init(void) * Default to enabled ldapssotoken, but if no secret is given we generate one * randomly each startup. */ -#ifdef RUST_ENABLE init_enable_ldapssotoken = cfg->enable_ldapssotoken = LDAP_ON; cfg->ldapssotoken_secret = fernet_generate_new_key(); cfg->ldapssotoken_ttl = SLAPD_DEFAULT_LDAPSSOTOKEN_TTL; -#else - init_enable_ldapssotoken = cfg->enable_ldapssotoken = LDAP_OFF; -#endif + cfg->tcp_fin_timeout = SLAPD_DEFAULT_TCP_FIN_TIMEOUT; cfg->tcp_keepalive_time = SLAPD_DEFAULT_TCP_KEEPALIVE_TIME; @@ -8463,15 +8454,12 @@ int32_t config_get_enable_ldapssotoken() { int32_t retVal; -#ifdef RUST_ENABLE + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); CFG_LOCK_READ(slapdFrontendConfig); retVal = slapdFrontendConfig->enable_ldapssotoken; CFG_UNLOCK_READ(slapdFrontendConfig); -#else - /* Always disabled if rust is not compiled in */ - retVal = 0; -#endif + return retVal; } @@ -8503,7 +8491,6 @@ config_get_ldapssotoken_secret() int32_t config_set_ldapssotoken_secret(const char *attrname, char *value, char *errorbuf, int apply) { -#ifdef RUST_ENABLE if (config_get_enable_ldapssotoken() == 0) { return LDAP_OPERATIONS_ERROR; } @@ -8530,9 +8517,6 @@ config_set_ldapssotoken_secret(const char *attrname, char *value, char *errorbuf CFG_UNLOCK_WRITE(slapdFrontendConfig); return retVal; -#else - return LDAP_OPERATIONS_ERROR; -#endif } int32_t diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index 7f65e0ac0..eb4c88151 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -2952,7 +2952,7 @@ slapd_do_all_nss_ssl_init(int slapd_exemode, int importexport_encrypt, int s_por slapi_log_err(SLAPI_LOG_WARNING, "slapd_do_all_nss_ssl_init", "ERROR: TLS is not enabled, and the machine is in FIPS mode. " "Some functionality won't work correctly (for example, " - "users with PBKDF2_SHA256 password scheme won't be able to log in). " + "users with PBKDF2-SHA256 password scheme won't be able to log in). " "It's highly advisable to enable TLS on this instance.\n"); } diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c index aa2e67703..55427e2b8 100644 --- a/ldap/servers/slapd/pw.c +++ b/ldap/servers/slapd/pw.c @@ -274,18 +274,9 @@ pw_name2scheme(char *name) typedef char *(*ENCFP)(char *); if (name == NULL || strcmp(DEFAULT_PASSWORD_SCHEME_NAME, name) == 0) { - /* - * If the name is DEFAULT, we need to get a scheme based on env and others. - */ - if (slapd_pk11_isFIPS()) { - /* Are we in fips mode? This limits algos we have */ - char *ssha = "SSHA512"; - p = plugin_get_pwd_storage_scheme(ssha, strlen(ssha), PLUGIN_LIST_PWD_STORAGE_SCHEME); - } else { - /* if not, let's setup pbkdf2 */ - char *pbkdf = "PBKDF2_SHA256"; - p = plugin_get_pwd_storage_scheme(pbkdf, strlen(pbkdf), PLUGIN_LIST_PWD_STORAGE_SCHEME); - } + /* default scheme */ + char *pbkdf = "PBKDF2-SHA512"; + p = plugin_get_pwd_storage_scheme(pbkdf, strlen(pbkdf), PLUGIN_LIST_PWD_STORAGE_SCHEME); } else { /* * Else, get the scheme "as named". diff --git a/ldap/servers/slapd/pw_verify.c b/ldap/servers/slapd/pw_verify.c index 93858967e..5c741f8ed 100644 --- a/ldap/servers/slapd/pw_verify.c +++ b/ldap/servers/slapd/pw_verify.c @@ -25,10 +25,8 @@ #endif #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) @@ -100,7 +98,6 @@ pw_verify_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral) int32_t pw_verify_token_dn(Slapi_PBlock *pb) { int rc = SLAPI_BIND_FAIL; -#ifdef RUST_ENABLE struct berval *cred = NULL; Slapi_DN *sdn = NULL; @@ -122,7 +119,7 @@ pw_verify_token_dn(Slapi_PBlock *pb) { rc = SLAPI_BIND_SUCCESS; } slapi_ch_free_string(&key); -#endif + return rc; } diff --git a/ldap/servers/slapd/upgrade.c b/ldap/servers/slapd/upgrade.c index f6e9f41ee..0d1e2abf4 100644 --- a/ldap/servers/slapd/upgrade.c +++ b/ldap/servers/slapd/upgrade.c @@ -22,12 +22,9 @@ * or altered. */ -#ifdef RUST_ENABLE static char *modifier_name = "cn=upgrade internal,cn=config"; -#endif static char *old_repl_plugin_name = NULL; -#ifdef RUST_ENABLE static upgrade_status upgrade_entry_exists_or_create(char *upgrade_id, char *filter, char *dn, char *entry) { @@ -46,7 +43,6 @@ upgrade_entry_exists_or_create(char *upgrade_id, char *filter, char *dn, char *e slapi_sdn_free(&base_sdn); return uresult; } -#endif /* * Add the new replication bootstrap bind DN password attribute to the AES @@ -102,7 +98,6 @@ upgrade_AES_reverpwd_plugin(void) return uresult; } -#ifdef RUST_ENABLE static upgrade_status upgrade_143_entryuuid_exists(void) { @@ -126,7 +121,6 @@ upgrade_143_entryuuid_exists(void) entry ); } -#endif static upgrade_status upgrade_144_remove_http_client_presence(void) @@ -288,11 +282,9 @@ upgrade_205_fixup_repl_dep(void) upgrade_status upgrade_server(void) { -#ifdef RUST_ENABLE if (upgrade_143_entryuuid_exists() != UPGRADE_SUCCESS) { return UPGRADE_FAILURE; } -#endif if (upgrade_AES_reverpwd_plugin() != UPGRADE_SUCCESS) { return UPGRADE_FAILURE; diff --git a/rpm.mk b/rpm.mk index a5fd9f53c..ed72ee567 100644 --- a/rpm.mk +++ b/rpm.mk @@ -25,8 +25,6 @@ TSAN_ON = 0 # Undefined Behaviour Sanitizer UBSAN_ON = 0 -RUST_ON = 1 - COCKPIT_ON = 1 clean: @@ -101,7 +99,6 @@ rpmroot: mkdir -p $(RPMBUILD)/SRPMS sed -e s/__VERSION__/$(RPM_VERSION)/ -e s/__RELEASE__/$(RPM_RELEASE)/ \ -e s/__VERSION_PREREL__/$(VERSION_PREREL)/ \ - -e s/__RUST_ON__/$(RUST_ON)/ \ -e s/__ASAN_ON__/$(ASAN_ON)/ \ -e s/__MSAN_ON__/$(MSAN_ON)/ \ -e s/__TSAN_ON__/$(TSAN_ON)/ \ diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index 21b4eff1c..9f79bdc75 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -25,9 +25,6 @@ %global use_tsan __TSAN_ON__ %global use_ubsan __UBSAN_ON__ -# This enables rust in the build. -%global use_rust __RUST_ON__ - %if %{use_asan} || %{use_msan} || %{use_tsan} || %{use_ubsan} %global variant base-xsan %endif @@ -112,11 +109,8 @@ BuildRequires: openssl-devel BuildRequires: pam-devel BuildRequires: systemd-units BuildRequires: systemd-devel -# If rust is enabled -%if %{use_rust} -BuildRequires: cargo -BuildRequires: rust -%endif +BuildRequires: cargo +BuildRequires: rust BuildRequires: pkgconfig BuildRequires: pkgconfig(systemd) BuildRequires: pkgconfig(krb5) @@ -352,9 +346,7 @@ TSAN_FLAGS="--enable-tsan --enable-debug" UBSAN_FLAGS="--enable-ubsan --enable-debug" %endif -%if %{use_rust} RUST_FLAGS="--enable-rust --enable-rust-offline" -%endif %if !%{use_cockpit} COCKPIT_FLAGS="--disable-cockpit" diff --git a/src/Cargo.lock b/src/Cargo.lock index 444084706..9086499cd 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "crossbeam" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845" +checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" dependencies = [ "cfg-if", "crossbeam-channel", @@ -137,9 +137,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ "cfg-if", "crossbeam-utils", @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" +checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" dependencies = [ "autocfg", "cfg-if", @@ -172,9 +172,9 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" +checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" dependencies = [ "cfg-if", "crossbeam-utils", @@ -182,9 +182,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" dependencies = [ "cfg-if", "once_cell", @@ -214,9 +214,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" dependencies = [ "instant", ] @@ -289,9 +289,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "jobserver" @@ -304,9 +304,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.126" +version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" [[package]] name = "librnsslapd" @@ -366,9 +366,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" [[package]] name = "openssl" @@ -479,9 +479,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" dependencies = [ "unicode-ident", ] @@ -501,9 +501,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -540,9 +540,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] @@ -558,9 +558,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "scopeguard" @@ -570,18 +570,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.139" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6" +checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.139" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb" +checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391" dependencies = [ "proc-macro2", "quote", @@ -590,9 +590,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" +checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" dependencies = [ "itoa", "ryu", @@ -629,9 +629,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" dependencies = [ "proc-macro2", "quote", @@ -675,9 +675,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.20.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57aec3cfa4c296db7255446efb4928a6be304b431a806216105542a67b6ca82e" +checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" dependencies = [ "autocfg", "once_cell", @@ -707,9 +707,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" [[package]] name = "unicode-width" @@ -780,9 +780,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "zeroize" -version = "1.5.6" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20b578acffd8516a6c3f2a1bdefc1ec37e547bb4e0fb8b6b01a4cafc886b4442" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" dependencies = [ "zeroize_derive", ] diff --git a/src/lib389/doc/source/passwd.rst b/src/lib389/doc/source/passwd.rst index 5b60d6051..06645c74d 100644 --- a/src/lib389/doc/source/passwd.rst +++ b/src/lib389/doc/source/passwd.rst @@ -16,6 +16,7 @@ Usage example 'SSHA256', 'SSHA512', 'PBKDF2_SHA256', + 'PBKDF2-SHA256', ] # Generate password diff --git a/src/lib389/lib389/config.py b/src/lib389/lib389/config.py index 45968810b..3028ca9c2 100644 --- a/src/lib389/lib389/config.py +++ b/src/lib389/lib389/config.py @@ -210,7 +210,7 @@ class Config(DSLdapObject): yield report def _lint_passwordscheme(self): - allowed_schemes = ['SSHA512', 'PBKDF2_SHA256', 'GOST_YESCRYPT'] + allowed_schemes = ['SSHA512', 'PBKDF2-SHA512', 'GOST_YESCRYPT'] u_password_scheme = self.get_attr_val_utf8('passwordStorageScheme') u_root_scheme = self.get_attr_val_utf8('nsslapd-rootpwstoragescheme') if u_root_scheme not in allowed_schemes or u_password_scheme not in allowed_schemes: diff --git a/src/lib389/lib389/lint.py b/src/lib389/lib389/lint.py index e8f91e10d..108946c0b 100644 --- a/src/lib389/lib389/lint.py +++ b/src/lib389/lib389/lint.py @@ -94,7 +94,7 @@ designed to be *fast* to validate. This is the opposite of what we desire for pa 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 +In Directory Server, we offer one hash suitable for this (PBKDF2-SHA512) and one hash for "legacy" support (SSHA512). Your configuration does not use these for password storage or the root password storage @@ -110,7 +110,7 @@ is started, they will use the server provided defaults that are secure. You can also use 'dsconf' to replace these values. Here is an example: - # dsconf slapd-YOUR_INSTANCE config replace passwordStorageScheme=PBKDF2_SHA256 nsslapd-rootpwstoragescheme=PBKDF2_SHA256""" + # dsconf slapd-YOUR_INSTANCE config replace passwordStorageScheme=PBKDF2-SHA512 nsslapd-rootpwstoragescheme=PBKDF2-SHA512""" } # Security checks diff --git a/src/lib389/lib389/password_plugins.py b/src/lib389/lib389/password_plugins.py index e78918a98..76ad5d149 100644 --- a/src/lib389/lib389/password_plugins.py +++ b/src/lib389/lib389/password_plugins.py @@ -31,7 +31,7 @@ class PasswordPlugin(Plugin): self._protected = True class PBKDF2Plugin(PasswordPlugin): - def __init__(self, instance, dn="cn=PBKDF2_SHA256,cn=Password Storage Schemes,cn=plugins,cn=config"): + def __init__(self, instance, dn="cn=PBKDF2-SHA256,cn=Password Storage Schemes,cn=plugins,cn=config"): super(PBKDF2Plugin, self).__init__(instance, dn)
0
1c5831c02c3e052c097f4b19c7d3ddf00b6d3add
389ds/389-ds-base
Ticket 49734 - Fix various issues with Disk Monitoring Bug Description: The first issue what the internal represenation of the default error code changed since the feature was added. This caused the disk monitoring thread to loop and never actually attempt to stop the server. The other issue is that with nunc-stans g_set_shutdown() is no longer stops the server. Fix Description: Change the defaulterror logging level to be more robust and accept all the default level values. Also, we needed to free the rotated logs when we delete them. Finally add raise() to g_set_downdow(), and make sure set_shutdown() does not overwrite the slapd_shutdown value. https://pagure.io/389-ds-base/issue/49734 Reviewed by: tbordaz & spichugi(Thanks!)
commit 1c5831c02c3e052c097f4b19c7d3ddf00b6d3add Author: Mark Reynolds <[email protected]> Date: Wed Jun 6 14:49:49 2018 -0400 Ticket 49734 - Fix various issues with Disk Monitoring Bug Description: The first issue what the internal represenation of the default error code changed since the feature was added. This caused the disk monitoring thread to loop and never actually attempt to stop the server. The other issue is that with nunc-stans g_set_shutdown() is no longer stops the server. Fix Description: Change the defaulterror logging level to be more robust and accept all the default level values. Also, we needed to free the rotated logs when we delete them. Finally add raise() to g_set_downdow(), and make sure set_shutdown() does not overwrite the slapd_shutdown value. https://pagure.io/389-ds-base/issue/49734 Reviewed by: tbordaz & spichugi(Thanks!) diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index b230e2251..c77e1f15c 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -572,8 +572,8 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) */ if (passed_threshold) { if (logs_disabled) { - slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", "Disk space is now within acceptable levels. " - "Restoring the log settings.\n"); + slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", + "Disk space is now within acceptable levels. Restoring the log settings.\n"); if (using_accesslog) { config_set_accesslog_enabled(LOGGING_ON); } @@ -599,25 +599,27 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) * Check if we are already critical */ if (disk_space < 4096) { /* 4 k */ - slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is critically low on disk (%s), " - "remaining space: %" PRIu64 " Kb. Signaling slapd for shutdown...\n", - dirstr, (disk_space / 1024)); - g_set_shutdown(SLAPI_SHUTDOWN_EXIT); + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Disk space is critically low on disk (%s), remaining space: %" PRIu64 " Kb. Signaling slapd for shutdown...\n", + dirstr, (disk_space / 1024)); + g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL); return; } /* * If we are low, see if we are using verbose error logging, and turn it off * if logging is not critical */ - if (verbose_logging != 0 && verbose_logging != LDAP_DEBUG_ANY) { - slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is low on disk (%s), remaining space: " - "%" PRIu64 " Kb, temporarily setting error loglevel to the default level(%d).\n", - dirstr, - (disk_space / 1024), SLAPD_DEFAULT_ERRORLOG_LEVEL); + if (verbose_logging != 0 && + verbose_logging != LDAP_DEBUG_ANY && + verbose_logging != SLAPD_DEFAULT_FE_ERRORLOG_LEVEL && + verbose_logging != SLAPD_DEFAULT_ERRORLOG_LEVEL) + { + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Disk space is low on disk (%s), remaining space: %" PRIu64 " Kb, " + "temporarily setting error loglevel to the default level.\n", + dirstr, (disk_space / 1024)); /* Setting the log level back to zero, actually sets the value to LDAP_DEBUG_ANY */ - config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, - STRINGIFYDEFINE(SLAPD_DEFAULT_ERRORLOG_LEVEL), - NULL, CONFIG_APPLY); + config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, "0", NULL, CONFIG_APPLY); continue; } /* @@ -625,9 +627,9 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) * access/audit logs, log another error, and continue. */ if (!logs_disabled && !logging_critical) { - slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is too low on disk (%s), remaining " - "space: %" PRIu64 " Kb, disabling access and audit logging.\n", - dirstr, (disk_space / 1024)); + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Disk space is too low on disk (%s), remaining space: %" PRIu64 " Kb, disabling access and audit logging.\n", + dirstr, (disk_space / 1024)); config_set_accesslog_enabled(LOGGING_OFF); config_set_auditlog_enabled(LOGGING_OFF); config_set_auditfaillog_enabled(LOGGING_OFF); @@ -639,9 +641,9 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) * access/audit logging, then delete the rotated logs, log another error, and continue. */ if (!deleted_rotated_logs && !logging_critical) { - slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is too low on disk (%s), remaining " - "space: %" PRIu64 " Kb, deleting rotated logs.\n", - dirstr, (disk_space / 1024)); + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Disk space is too low on disk (%s), remaining space: %" PRIu64 " Kb, deleting rotated logs.\n", + dirstr, (disk_space / 1024)); log__delete_rotated_logs(); deleted_rotated_logs = 1; continue; @@ -650,22 +652,21 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) * Ok, we've done what we can, log a message if we continue to lose available disk space */ if (disk_space < previous_mark) { - slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is too low on disk (%s), remaining " - "space: %" PRIu64 " Kb\n", - dirstr, (disk_space / 1024)); + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Disk space is too low on disk (%s), remaining space: %" PRIu64 " Kb\n", + dirstr, (disk_space / 1024)); } /* - * * If we are below the halfway mark, and we did everything else, * go into shutdown mode. If the disk space doesn't get critical, * wait for the grace period before shutting down. This gives an * admin the chance to clean things up. - * */ if (disk_space < halfway) { - slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space on (%s) is too far below the threshold(%" PRIu64 " bytes). " - "Waiting %d minutes for disk space to be cleaned up before shutting slapd down...\n", - dirstr, threshold, (grace_period / 60)); + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Disk space on (%s) is too far below the threshold(%" PRIu64 " bytes). " + "Waiting %d minutes for disk space to be cleaned up before shutting slapd down...\n", + dirstr, threshold, (grace_period / 60)); start = slapi_current_utc_time(); now = start; while ((now - start) < grace_period) { @@ -685,9 +686,9 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) /* * Excellent, we are back to acceptable levels, reset everything... */ - slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", "Available disk space is now " - "acceptable (%" PRIu64 " bytes). Aborting shutdown, and restoring the log settings.\n", - disk_space); + slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", + "Available disk space is now acceptable (%" PRIu64 " bytes). Aborting shutdown, and restoring the log settings.\n", + disk_space); if (logs_disabled && using_accesslog) { config_set_accesslog_enabled(LOGGING_ON); } @@ -709,9 +710,9 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) /* * Disk space is critical, log an error, and shut it down now! */ - slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is critically low " - "on disk (%s), remaining space: %" PRIu64 " Kb. Signaling slapd for shutdown...\n", - dirstr, (disk_space / 1024)); + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Disk space is critically low on disk (%s), remaining space: %" PRIu64 " Kb. Signaling slapd for shutdown...\n", + dirstr, (disk_space / 1024)); g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL); return; } @@ -727,9 +728,9 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) /* * If disk space was freed up we would of detected in the above while loop. So shut it down. */ - slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is still too low " - "(%" PRIu64 " Kb). Signaling slapd for shutdown...\n", - (disk_space / 1024)); + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Disk space is still too low (%" PRIu64 " Kb). Signaling slapd for shutdown...\n", + (disk_space / 1024)); g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL); return; @@ -2717,7 +2718,9 @@ set_shutdown(int sig __attribute__((unused))) #if 0 slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon", "slapd got shutdown signal\n"); #endif - g_set_shutdown(SLAPI_SHUTDOWN_SIGNAL); + if (g_get_shutdown() == 0) { + g_set_shutdown(SLAPI_SHUTDOWN_SIGNAL); + } #ifndef LINUX /* don't mess with USR1/USR2 on linux, used by libpthread */ (void)SIGNAL(SIGUSR2, set_shutdown); diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 4ec447bb8..2c1e90513 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -121,6 +121,7 @@ #include <arpa/inet.h> #include <netdb.h> #include <unistd.h> +#include <signal.h> #include <pwd.h> /* pwdnam */ #ifdef USE_SYSCONF #include <unistd.h> @@ -1376,6 +1377,7 @@ void g_set_shutdown(int reason) { slapd_shutdown = reason; + raise(SIGTERM); } int diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index 998efaef3..2e4ee03a8 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -3086,6 +3086,7 @@ void log__delete_rotated_logs() { struct logfileinfo *logp = NULL; + struct logfileinfo *prev_log = NULL; char buffer[BUFSIZ]; char tbuf[TBUFSIZE]; @@ -3097,17 +3098,20 @@ log__delete_rotated_logs() tbuf[0] = buffer[0] = '\0'; log_convert_time(logp->l_ctime, tbuf, 1); PR_snprintf(buffer, sizeof(buffer), "%s.%s", loginfo.log_access_file, tbuf); - - slapi_log_err(SLAPI_LOG_ERR, "log__delete_rotated_logs", - "Deleted Rotated Log: %s\n", buffer); - if (PR_Delete(buffer) != PR_SUCCESS) { + PRErrorCode prerr = PR_GetError(); + slapi_log_err(SLAPI_LOG_ERR, "log__delete_rotated_logs", + "Unable to remove file: %s - error %d (%s)\n", + buffer, prerr, slapd_pr_strerror(prerr)); logp = logp->l_next; continue; } + prev_log = logp; loginfo.log_numof_access_logs--; logp = logp->l_next; + slapi_ch_free((void **)&prev_log); } + /* * Audit Log */ @@ -3117,12 +3121,41 @@ log__delete_rotated_logs() log_convert_time(logp->l_ctime, tbuf, 1); PR_snprintf(buffer, sizeof(buffer), "%s.%s", loginfo.log_audit_file, tbuf); if (PR_Delete(buffer) != PR_SUCCESS) { + PRErrorCode prerr = PR_GetError(); + slapi_log_err(SLAPI_LOG_ERR, "log__delete_rotated_logs", + "Unable to remove file: %s - error %d (%s)\n", + buffer, prerr, slapd_pr_strerror(prerr)); logp = logp->l_next; continue; } + prev_log = logp; loginfo.log_numof_audit_logs--; logp = logp->l_next; + slapi_ch_free((void **)&prev_log); } + + /* + * Audit Fail Log + */ + logp = loginfo.log_auditfail_logchain; + while (logp) { + tbuf[0] = buffer[0] = '\0'; + log_convert_time(logp->l_ctime, tbuf, 1); + PR_snprintf(buffer, sizeof(buffer), "%s.%s", loginfo.log_auditfail_file, tbuf); + if (PR_Delete(buffer) != PR_SUCCESS) { + PRErrorCode prerr = PR_GetError(); + slapi_log_err(SLAPI_LOG_ERR, "log__delete_rotated_logs", + "Unable to remove file: %s - error %d (%s)\n", + buffer, prerr, slapd_pr_strerror(prerr)); + logp = logp->l_next; + continue; + } + prev_log = logp; + loginfo.log_numof_auditfail_logs--; + logp = logp->l_next; + slapi_ch_free((void **)&prev_log); + } + /* * Error log */ @@ -3132,11 +3165,17 @@ log__delete_rotated_logs() log_convert_time(logp->l_ctime, tbuf, 1); PR_snprintf(buffer, sizeof(buffer), "%s.%s", loginfo.log_error_file, tbuf); if (PR_Delete(buffer) != PR_SUCCESS) { + PRErrorCode prerr = PR_GetError(); + slapi_log_err(SLAPI_LOG_ERR, "log__delete_rotated_logs", + "Unable to remove file: %s - error %d (%s)\n", + buffer, prerr, slapd_pr_strerror(prerr)); logp = logp->l_next; continue; } + prev_log = logp; loginfo.log_numof_error_logs--; logp = logp->l_next; + slapi_ch_free((void **)&prev_log); } }
0
b2c65453f9fd2b284c250470b39459f6828c73ca
389ds/389-ds-base
Issue 49044 - Fix script usage and man pages Bug Description: All the perl scripts say that "-v" displays verbose output. This is not an actual option though. Some of the shell script say "-v" if also for verbose output, when in fact it is just for displaying the server version. The man pages for the shell scripts do not advertise the version output option "-v". Fix Description: Fix the usage and man pages for all the scripts. https://pagure.io/389-ds-base/issue/49044 Reviewed by: nhosoi(Thanks!)
commit b2c65453f9fd2b284c250470b39459f6828c73ca Author: Mark Reynolds <[email protected]> Date: Wed Mar 1 11:41:33 2017 -0500 Issue 49044 - Fix script usage and man pages Bug Description: All the perl scripts say that "-v" displays verbose output. This is not an actual option though. Some of the shell script say "-v" if also for verbose output, when in fact it is just for displaying the server version. The man pages for the shell scripts do not advertise the version output option "-v". Fix Description: Fix the usage and man pages for all the scripts. https://pagure.io/389-ds-base/issue/49044 Reviewed by: nhosoi(Thanks!) diff --git a/ldap/admin/src/scripts/bak2db.pl.in b/ldap/admin/src/scripts/bak2db.pl.in index 28f1c9837..bba8b930a 100644 --- a/ldap/admin/src/scripts/bak2db.pl.in +++ b/ldap/admin/src/scripts/bak2db.pl.in @@ -25,7 +25,7 @@ $i = 0; sub usage { print(STDERR "Usage: bak2db.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename } -a dirname [-t dbtype]\n"); - print(STDERR " [-n backendname] [-P protocol] [-v] [-h]\n"); + print(STDERR " [-n backendname] [-P protocol] [-h]\n"); print(STDERR "Options:\n"); print(STDERR " -D rootdn - Directory Manager\n"); print(STDERR " -w password - Directory Manager's password\n"); @@ -36,22 +36,21 @@ sub usage { print(STDERR " -t dbtype - Database type (default: ldbm database)\n"); print(STDERR " -n backend - Backend database name. Example: userRoot\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } while ($i <= $#ARGV) { if ("$ARGV[$i]" eq "-a") { # backup directory $i++; $archivedir = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-D") { # Directory Manager + } elsif ("$ARGV[$i]" eq "-D") { # Directory Manager $i++; $rootdn = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-w") { # Directory Manager's password + } elsif ("$ARGV[$i]" eq "-w") { # Directory Manager's password $i++; $passwd = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-j") { # Read Directory Manager's password from a file $i++; $passwdfile = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-t") { # database type + } elsif ("$ARGV[$i]" eq "-t") { # database type $i++; $dbtype = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-n") { # backend instance name + } elsif ("$ARGV[$i]" eq "-n") { # backend instance name $i++; $instance = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-Z") { # server instance name $i++; $servid = $ARGV[$i]; @@ -59,8 +58,6 @@ while ($i <= $#ARGV) { $i++; $protocol = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-h") { # help &usage; exit(0); - } elsif ("$ARGV[$i]" eq "-v") { # verbose - $verbose = 1; } else { print "ERROR - Unknown option: $ARGV[$i]\n"; &usage; exit(1); @@ -75,11 +72,7 @@ while ($i <= $#ARGV) { %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; if ($archivedir eq ""){ &usage; exit(1); diff --git a/ldap/admin/src/scripts/cleanallruv.pl.in b/ldap/admin/src/scripts/cleanallruv.pl.in index f6e5477f8..812962537 100644 --- a/ldap/admin/src/scripts/cleanallruv.pl.in +++ b/ldap/admin/src/scripts/cleanallruv.pl.in @@ -34,7 +34,6 @@ sub usage { print(STDERR " -r rid - The replica id that you want to clean\n"); print(STDERR " -A - Abort an existing cleanallruv task(must use with -b and -r args\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -64,9 +63,6 @@ while ($i <= $#ARGV) } elsif ("$ARGV[$i]" eq "-P"){ # protocol preference $i++; $protocol = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-v"){ - # verbose - $verbose = 1; } elsif ("$ARGV[$i]" eq "-h"){ # help &usage; exit(0); @@ -84,11 +80,7 @@ while ($i <= $#ARGV) %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; if ($basedn eq "" || $rid eq ""){ &usage; exit(1); diff --git a/ldap/admin/src/scripts/db2bak.pl.in b/ldap/admin/src/scripts/db2bak.pl.in index 2e9538333..c73caa1fb 100644 --- a/ldap/admin/src/scripts/db2bak.pl.in +++ b/ldap/admin/src/scripts/db2bak.pl.in @@ -37,7 +37,6 @@ sub usage { print(STDERR " -a backupdir - Backup directory\n"); print(STDERR " -t dbtype - Database type (default: ldbm database)\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -45,16 +44,16 @@ $nestit = 0; while ($i <= $#ARGV) { if ("$ARGV[$i]" eq "-a") { # backup directory $i++; $archivedir = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-A") { # backup directory + } elsif ("$ARGV[$i]" eq "-A") { # backup directory $nestit = 1; $i++; $archivedir = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-D") { # Directory Manager + } elsif ("$ARGV[$i]" eq "-D") { # Directory Manager $i++; $rootdn = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-w") { # Directory Manager's password + } elsif ("$ARGV[$i]" eq "-w") { # Directory Manager's password $i++; $passwd = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-j") { # Read Directory Manager's password from a file $i++; $passwdfile = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-t") { # database type + } elsif ("$ARGV[$i]" eq "-t") { # database type $i++; $dbtype = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-Z") { # Server identifier $i++; $servid = $ARGV[$i]; @@ -62,8 +61,6 @@ while ($i <= $#ARGV) { $i++; $protocol = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-h") { # help &usage; exit(0); - } elsif ("$ARGV[$i]" eq "-v") { # verbose - $verbose = 1; } else { print "ERROR - Unknown option: $ARGV[$i]\n"; &usage; exit(1); @@ -78,11 +75,7 @@ while ($i <= $#ARGV) { %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; $mybakdir = "@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak"; diff --git a/ldap/admin/src/scripts/db2index.pl.in b/ldap/admin/src/scripts/db2index.pl.in index 847e67e5e..0cfaecaba 100644 --- a/ldap/admin/src/scripts/db2index.pl.in +++ b/ldap/admin/src/scripts/db2index.pl.in @@ -26,7 +26,7 @@ $vlv_count = 0; sub usage { print(STDERR "Usage: db2index.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename } [-P protocol]\n"); - print(STDERR " -n backendname [-t attributeName[:indextypes[:matchingrules]]] [-T vlvTag] [-v] [-h]\n"); + print(STDERR " -n backendname [-t attributeName[:indextypes[:matchingrules]]] [-T vlvTag] [-h]\n"); print(STDERR "Options:\n"); print(STDERR " -D rootdn - Directory Manager\n"); print(STDERR " -w password - Directory Manager's password\n"); @@ -42,7 +42,6 @@ sub usage { print(STDERR " Example: -t foo:eq,pres\n"); print(STDERR " -T vlvTag - VLV index name\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose\n"); print(STDERR " -h - Display usage\n"); } @@ -65,8 +64,6 @@ while ($i <= $#ARGV) { $i++; $protocol = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-h") { # help &usage; exit(0); - } elsif ("$ARGV[$i]" eq "-v") { # verbose - $verbose = 1; } else { print "ERROR - Unknown option: $ARGV[$i]\n"; &usage; exit(1); @@ -81,11 +78,7 @@ while ($i <= $#ARGV) { %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; if ($instance eq ""){ &usage; exit(1); diff --git a/ldap/admin/src/scripts/db2ldif.pl.in b/ldap/admin/src/scripts/db2ldif.pl.in index e8ff2295f..179d23625 100644 --- a/ldap/admin/src/scripts/db2ldif.pl.in +++ b/ldap/admin/src/scripts/db2ldif.pl.in @@ -63,7 +63,6 @@ sub usage { print(STDERR " -E - Decrypt encrypted data when exporting\n"); print(STDERR " -1 - Do not print version line\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -148,8 +147,6 @@ while ($i <= $#ARGV) { &usage; exit(0); } elsif ("$ARGV[$i]" eq "-P") { # protocol preference $i++; $protocol = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-v") { # verbose - $verbose = 1; } elsif ("$ARGV[$i]" eq "-c") { # cwd $i++; $cwd = $ARGV[$i]; } else { @@ -167,11 +164,7 @@ while ($i <= $#ARGV) { $ldifdir = "@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif"; $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; if ($instances[0] eq "" && $included[0] eq ""){ &usage; exit(1); diff --git a/ldap/admin/src/scripts/fixup-linkedattrs.pl.in b/ldap/admin/src/scripts/fixup-linkedattrs.pl.in index b9a455e96..d4ee2004d 100644 --- a/ldap/admin/src/scripts/fixup-linkedattrs.pl.in +++ b/ldap/admin/src/scripts/fixup-linkedattrs.pl.in @@ -23,7 +23,7 @@ $i = 0; sub usage { print(STDERR "Usage: fixed-linkedupattrs.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename }\n"); - print(STDERR " [-l linkDN] [-P protocol] [-v] [-h]\n"); + print(STDERR " [-l linkDN] [-P protocol] [-h]\n"); print(STDERR "Options:\n"); print(STDERR " -D rootdn - Directory Manager\n"); print(STDERR " -w password - Directory Manager's password\n"); @@ -34,7 +34,6 @@ sub usage { print(STDERR " up the links for. If omitted, all configured\n"); print(STDERR " linked attributes will be fixed up.\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -58,9 +57,6 @@ while ($i <= $#ARGV) } elsif ("$ARGV[$i]" eq "-h"){ # help &usage; exit(0); - } elsif ("$ARGV[$i]" eq "-v"){ - # verbose - $verbose = 1; } elsif ("$ARGV[$i]" eq "-P") { # protocol preference $i++; $protocol = $ARGV[$i]; @@ -78,11 +74,7 @@ while ($i <= $#ARGV) %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; # # Construct the task entry diff --git a/ldap/admin/src/scripts/fixup-memberof.pl.in b/ldap/admin/src/scripts/fixup-memberof.pl.in index f3d6447dd..fc00c2fac 100644 --- a/ldap/admin/src/scripts/fixup-memberof.pl.in +++ b/ldap/admin/src/scripts/fixup-memberof.pl.in @@ -23,7 +23,7 @@ $i = 0; sub usage { print(STDERR "Usage: fixup-memberof.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename }\n"); - print(STDERR " [-P protocol] -b baseDN [-f filter] [-v] [-h]\n"); + print(STDERR " [-P protocol] -b baseDN [-f filter] [-h]\n"); print(STDERR "Options:\n"); print(STDERR " -D rootdn - Directory Manager\n"); print(STDERR " -w password - Directory Manager's password\n"); @@ -35,7 +35,6 @@ sub usage { print(STDERR " If omitted, all entries with objectclass inetuser/inetadmin under the\n"); print(STDERR " specified base will have their memberOf attribute regenerated.\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -65,9 +64,6 @@ while ($i <= $#ARGV) } elsif ("$ARGV[$i]" eq "-h"){ # help &usage; exit(0); - } elsif ("$ARGV[$i]" eq "-v"){ - # verbose - $verbose = 1; } else { print "ERROR - Unknown option: $ARGV[$i]\n"; &usage; exit(1); diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in index 03a241b70..f9683039d 100755 --- a/ldap/admin/src/scripts/ldif2db.in +++ b/ldap/admin/src/scripts/ldif2db.in @@ -31,7 +31,7 @@ usage() echo " -O - Do not index the attributes" echo " -E - Encrypt attributes" echo " -q - Quiet mode - suppresses output" - echo " -v - Verbose output" + echo " -v - Display version" echo " -h - Display usage" } diff --git a/ldap/admin/src/scripts/ldif2db.pl.in b/ldap/admin/src/scripts/ldif2db.pl.in index bdb311e27..a5d834f8e 100644 --- a/ldap/admin/src/scripts/ldif2db.pl.in +++ b/ldap/admin/src/scripts/ldif2db.pl.in @@ -31,7 +31,7 @@ $encrypt_on_import = 0; sub usage { print(STDERR "Usage: ldif2db.pl -n backend [-Z serverID] [-D rootdn] { -w password | -w - | -j filename }\n"); - print(STDERR " [-P protocol] {-s include}* [{-x exclude}*] [-O] [-c chunksize] [-v] [-h]\n"); + print(STDERR " [-P protocol] {-s include}* [{-x exclude}*] [-O] [-c chunksize] [-h]\n"); print(STDERR " [-E] [-g [string] [-G namespace_id]] {-i filename}*\n"); print(STDERR "Note: either \"-n backend\", \"-s includesuffix\", and \"-i ldiffile\" are required.\n"); print(STDERR "Options:\n"); @@ -53,7 +53,6 @@ sub usage { print(STDERR " -G name - Namespace id for name based uniqueid (-g deterministic)\n"); print(STDERR " -E - Encrypt data when importing\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -129,8 +128,6 @@ while ($i <= $#ARGV) { $i++; $uniqidname = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-Z") { # server id $i++; $servid = $ARGV[$i]; - } elsif ("$ARGV[$i]" eq "-v") { # verbose - $verbose = 1; } elsif ("$ARGV[$i]" eq "-h") { # help &usage; exit(0); } elsif ("$ARGV[$i]" eq "-E") { # encrypt on import @@ -151,11 +148,7 @@ while ($i <= $#ARGV) { %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; if (($instance eq "" && $included[0] eq "") || $ldiffiles[0] eq "" ){ &usage; exit(1); diff --git a/ldap/admin/src/scripts/schema-reload.pl.in b/ldap/admin/src/scripts/schema-reload.pl.in index d88033739..03bb6101b 100644 --- a/ldap/admin/src/scripts/schema-reload.pl.in +++ b/ldap/admin/src/scripts/schema-reload.pl.in @@ -22,7 +22,7 @@ $ENV{'PATH'} = "@ldaptool_bindir@:/usr/bin:/usr/lib64/mozldap/"; $i = 0; sub usage { - print(STDERR "Usage: schema-reload.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename } [-P protocol] [-d schemadir] [-v] [-h]\n"); + print(STDERR "Usage: schema-reload.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename } [-P protocol] [-d schemadir] [-h]\n"); print(STDERR "Options:\n"); print(STDERR " -D rootdn - Directory Manager\n"); print(STDERR " -w password - Directory Manager's password\n"); @@ -31,7 +31,6 @@ sub usage { print(STDERR " -j filename - Read Directory Manager's password from file\n"); print(STDERR " -d schemadir - Directory where schema files are located\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -56,9 +55,6 @@ while ($i <= $#ARGV) # help &usage; exit(0); - } elsif ("$ARGV[$i]" eq "-v"){ - # verbose - $verbose = 1; } elsif ("$ARGV[$i]" eq "-P") { # protocol preference $i++; $protocol = $ARGV[$i]; @@ -77,11 +73,7 @@ while ($i <= $#ARGV) %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; # # Construct the task entry diff --git a/ldap/admin/src/scripts/syntax-validate.pl.in b/ldap/admin/src/scripts/syntax-validate.pl.in index 5f5247557..717a6ed77 100644 --- a/ldap/admin/src/scripts/syntax-validate.pl.in +++ b/ldap/admin/src/scripts/syntax-validate.pl.in @@ -22,7 +22,7 @@ $ENV{'SHLIB_PATH'} = "$ENV{'LD_LIBRARY_PATH'}"; $i = 0; sub usage { - print(STDERR "Usage: syntax-validate.pl [-v] [-Z serverID] [-D rootdn] { -w password | -w - | -j filename }\n"); + print(STDERR "Usage: syntax-validate.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename }\n"); print(STDERR " [-P protocol] -b baseDN [-f filter] [-h]\n"); print(STDERR "Options:\n"); print(STDERR " -D rootdn - Directory Manager\n"); @@ -35,7 +35,6 @@ sub usage { print(STDERR " If omitted, all entries under the specified\n"); print(STDERR " base will have their attribute values validated.\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -66,9 +65,6 @@ while ($i <= $#ARGV) # help &usage; exit(0); - } elsif ("$ARGV[$i]" eq "-v"){ - # verbose - $verbose = 1; } else { print "ERROR - Unknown option: $ARGV[$i]\n"; &usage; @@ -84,11 +80,7 @@ while ($i <= $#ARGV) %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; if ( $basedn_arg eq "" ){ &usage; exit(1); diff --git a/ldap/admin/src/scripts/usn-tombstone-cleanup.pl.in b/ldap/admin/src/scripts/usn-tombstone-cleanup.pl.in index c14bcd82c..4168433c3 100644 --- a/ldap/admin/src/scripts/usn-tombstone-cleanup.pl.in +++ b/ldap/admin/src/scripts/usn-tombstone-cleanup.pl.in @@ -22,7 +22,7 @@ $i = 0; sub usage { print(STDERR "Usage: usn-tombstone-cleanup.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename }\n"); - print(STDERR " -s suffix -n backend [-m maxusn_to_delete] [-P protocol] [-v] [-h]\n"); + print(STDERR " -s suffix -n backend [-m maxusn_to_delete] [-P protocol] [-h]\n"); print(STDERR "Options:\n"); print(STDERR " -D rootdn - Directory Manager\n"); print(STDERR " -w password - Directory Manager's password\n"); @@ -33,7 +33,6 @@ sub usage { print(STDERR " -n backend - Backend instance in which USN tombstone entries are cleaned up (alternative to suffix)\n"); print(STDERR " -m maxusn_to_delete - USN tombstone entries are deleted up to the entry with maxusn_to_delete\n"); print(STDERR " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)\n"); - print(STDERR " -v - Verbose output\n"); print(STDERR " -h - Display usage\n"); } @@ -67,9 +66,6 @@ while ($i <= $#ARGV) # help &usage; exit(0); - } elsif ("$ARGV[$i]" eq "-v"){ - # verbose - $verbose = 1; } else { print "ERROR - Unknown option: $ARGV[$i]\n"; &usage; @@ -85,11 +81,7 @@ while ($i <= $#ARGV) %info = DSUtil::get_info($confdir, $host, $port, $rootdn); $info{rootdnpw} = DSUtil::get_password_from_file($passwd, $passwdfile); $info{protocol} = $protocol; -if ($verbose == 1){ - $info{args} = "-v -a"; -} else { - $info{args} = "-a"; -} +$info{args} = "-a"; if ( $suffix_arg eq "" && $backend_arg eq "" ){ &usage; exit(1); diff --git a/man/man8/bak2db.8 b/man/man8/bak2db.8 index 0b61f1485..778647288 100644 --- a/man/man8/bak2db.8 +++ b/man/man8/bak2db.8 @@ -18,7 +18,7 @@ .SH NAME bak2db - Directory Server script for restoring a backup .SH SYNOPSIS -bak2db archivedir [\-Z serverID] [\-n backendname] [\-q] | [\-h] +bak2db archivedir [\-Z serverID] [\-n backendname] [\-q] [\-v] [\-h] .SH DESCRIPTION Restores the database from a archived backup. The Directory Server must be stopped prior to running this script. .SH OPTIONS @@ -38,6 +38,10 @@ The name of the LDBM database to restore. Example: userRoot .br Quiet mode. Reduces output of task. .TP +.B \fB\-v\fR +Display version +.br +.TP .B \fB\-h\fR .br Display the usage. diff --git a/man/man8/bak2db.pl.8 b/man/man8/bak2db.pl.8 index a551d3d5e..1bb76c5bb 100644 --- a/man/man8/bak2db.pl.8 +++ b/man/man8/bak2db.pl.8 @@ -18,7 +18,7 @@ .SH NAME bak2db.pl - Directory Server perl script for restoring a backup .SH SYNOPSIS -bak2db.pl \-a archivedir [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-t dbtype] [\-n backendname] [\-P protocol] [\-v] [\-h] +bak2db.pl \-a archivedir [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-t dbtype] [\-n backendname] [\-P protocol] [\-h] .SH DESCRIPTION Restores a database from a backup. The Directory Server must be started prior to running this script. .SH OPTIONS @@ -56,10 +56,6 @@ The connection protocol to connect to the Directory Server. Protocols are START If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/cleanallruv.pl.8 b/man/man8/cleanallruv.pl.8 index 1f2385808..55678ac8d 100644 --- a/man/man8/cleanallruv.pl.8 +++ b/man/man8/cleanallruv.pl.8 @@ -18,7 +18,7 @@ .SH NAME cleanallruv.pl - Directory Server perl script for issuing a cleanAllRUV task .SH SYNOPSIS -cleanallruv.pl [\-v] [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } \-b basedn \-r rid [\-A] [\-P protocol] [\-h] +cleanallruv.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } \-b basedn \-r rid [\-A] [\-P protocol] [\-h] .SH DESCRIPTION Creates and adds a cleanAllRUV task to the Directory Server .SH OPTIONS @@ -59,10 +59,6 @@ available for the root user. .br Abort a cleanAllRUV task that is currently running. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/db2bak.8 b/man/man8/db2bak.8 index 79edb640b..5de017e74 100644 --- a/man/man8/db2bak.8 +++ b/man/man8/db2bak.8 @@ -18,7 +18,7 @@ .SH NAME db2bak - Directory Server script for making a backup of the database .SH SYNOPSIS -db2bak [archivedir] [\-Z serverID] [\-q] [\-h] +db2bak [archivedir] [\-Z serverID] [\-q] [\-v] [\-h] .SH DESCRIPTION Creates a backup of the database. This script can be executed while the server is running or stopped. .SH OPTIONS @@ -31,6 +31,10 @@ The full path to the directory to store the backup. The server ID of the Directory Server instance. If there is only one instance on the system, this option can be skipped. .TP +.B \fB\-v\fR +Display version +.br +.TP .B \fB\-q\fR .br Quiet mode. Reduces output of task. diff --git a/man/man8/db2bak.pl.8 b/man/man8/db2bak.pl.8 index 71beae4e6..9a34d51a6 100644 --- a/man/man8/db2bak.pl.8 +++ b/man/man8/db2bak.pl.8 @@ -18,7 +18,7 @@ .SH NAME db2bak.pl - Directory Server perl script for creating a backup .SH SYNOPSIS -db2bak.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-t dbtype] [\-a backupdir] [\-A backupdir] [\-P protocol] [\-v] [\-h] +db2bak.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-t dbtype] [\-a backupdir] [\-A backupdir] [\-P protocol] [\-h] .SH DESCRIPTION Creates a backup of the Directory Server database. The Directory Server must be started prior to running this script. @@ -57,10 +57,6 @@ The connection protocol to connect to the Directory Server. Protocols are START If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/db2index.8 b/man/man8/db2index.8 index 4b626700c..1e70cc935 100644 --- a/man/man8/db2index.8 +++ b/man/man8/db2index.8 @@ -18,7 +18,7 @@ .SH NAME db2index - Directory Server script for indexing attributes .SH SYNOPSIS -db2index [\-Z serverID] [\-n backend | {\-s includeSuffix}* \-t attribute[:indextypes[:matchingrules]] \-T vlvTag] [\-h] +db2index [\-Z serverID] [\-n backend | {\-s includeSuffix}* \-t attribute[:indextypes[:matchingrules]] \-T vlvTag] [\-v] [\-h] .SH DESCRIPTION Reindexes the database index files. The Directory Server must be stopped prior to running this script. .SH OPTIONS @@ -41,6 +41,10 @@ An optional matching rule OID can also be set. .B \fB\-T\fR \fIvlvTag\fR This is the name of the vlv index entry under cn=config. .TP +.B \fB\-v\fR +Display version +.br +.TP .B \fB\-h\fR .br Display the usage. diff --git a/man/man8/db2index.pl.8 b/man/man8/db2index.pl.8 index df9da7e43..4ff9c7a84 100644 --- a/man/man8/db2index.pl.8 +++ b/man/man8/db2index.pl.8 @@ -18,7 +18,7 @@ .SH NAME db2index.pl - Directory Server perl script for indexing a database .SH SYNOPSIS -db2index.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-n backendname] [\-P protocol] [\-t attributeName[:indextypes[:matchingrules]]] [\-T vlvTag] [\-v] [\-h] +db2index.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-n backendname] [\-P protocol] [\-t attributeName[:indextypes[:matchingrules]]] [\-T vlvTag] [\-h] .SH DESCRIPTION Indexes attributes in the specified database. If no attributes are specified, then all the attribute indexes will be regenerated. The Directory Server must be started prior to running this script. .SH OPTIONS @@ -57,10 +57,6 @@ The connection protocol to connect to the Directory Server. Protocols are START If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/db2ldif.8 b/man/man8/db2ldif.8 index 361b224f2..2a787f2c1 100644 --- a/man/man8/db2ldif.8 +++ b/man/man8/db2ldif.8 @@ -18,7 +18,7 @@ .SH NAME db2ldif - Directory Server script for exporting the database .SH SYNOPSIS -db2ldif [\-Z serverID] {\-n backend_instance}* | {\-s includeSuffix}* [{\-x excludeSuffix}*] [\-a outputFile] [\-m] [\-M] [\-r] [\-u] [\-U] [\-C] [\-N] [\-E] [\-1] [\-q] [\-h] +db2ldif [\-Z serverID] {\-n backend_instance}* | {\-s includeSuffix}* [{\-x excludeSuffix}*] [\-a outputFile] [\-v] [\-m] [\-M] [\-r] [\-u] [\-U] [\-C] [\-N] [\-E] [\-1] [\-q] [\-h] .SH DESCRIPTION Exports the contents of the database to a LDIF file. This script can be executed while the server is still running, except when using the \-r option. .SH OPTIONS @@ -54,6 +54,10 @@ By default, all instances are stored in the filename specified by the \-a option .br Export replication data(information required to initialize a replica when the LDIF is imported). .TP +.B \fB\-v\fR +Display version +.br +.TP .B \fB\-u\fR .br Do not export the unique-id attribute. diff --git a/man/man8/db2ldif.pl.8 b/man/man8/db2ldif.pl.8 index 1ddc1cfc9..f02d3ed39 100644 --- a/man/man8/db2ldif.pl.8 +++ b/man/man8/db2ldif.pl.8 @@ -19,7 +19,7 @@ db2ldif.pl - Directory Server perl script for exporting a database to a LDIF file .SH SYNOPSIS db2ldif.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j pwfilename } [\-P protocol] -{\-n backendname}* | {\-s includeSuffix}* [{\-x excludeSuffix}*] [\-m] [\-M] [\-r] [\-u] [\-C] [\-N] [\-E] [\-1] [\-U] [\-a filename] [\-v] [\-h] +{\-n backendname}* | {\-s includeSuffix}* [{\-x excludeSuffix}*] [\-m] [\-M] [\-r] [\-u] [\-C] [\-N] [\-E] [\-1] [\-U] [\-a filename] [\-h] .SH DESCRIPTION Exports the contents of the database to LDIF. This script creates an entry in the directory that launches this dynamic task. .SH OPTIONS @@ -98,10 +98,6 @@ Decrypts any encrypted data during export. .br Deletes, for reasons of backward compatibility, the first line of the LDIF file that gives the version of the LDIF standard. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/fixup-linkedattrs.pl.8 b/man/man8/fixup-linkedattrs.pl.8 index 7dd2bd7af..ee484c8ab 100644 --- a/man/man8/fixup-linkedattrs.pl.8 +++ b/man/man8/fixup-linkedattrs.pl.8 @@ -18,7 +18,7 @@ .SH NAME fixup-linkedattrs.pl - Directory Server perl script for creating a "fixup" task for linked attributes. .SH SYNOPSIS -fixup-linkedattrs.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-l linkDN] [\-P protocol] [\-v] [\-h] +fixup-linkedattrs.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-l linkDN] [\-P protocol] [\-h] .SH DESCRIPTION Creates the managed attributes in the user entries once the linking plug-in instance is created or updates the managed attributes to keep everything in sync after operations like replication or synchronization. .SH OPTIONS @@ -50,10 +50,6 @@ The connection protocol to connect to the Directory Server. Protocols are START If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/fixup-memberof.pl.8 b/man/man8/fixup-memberof.pl.8 index 43235794a..55b750340 100644 --- a/man/man8/fixup-memberof.pl.8 +++ b/man/man8/fixup-memberof.pl.8 @@ -18,7 +18,7 @@ .SH NAME fixup-memberof.pl - Directory Server perl script for memberOf attributes. .SH SYNOPSIS -fixup-memberof.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } \-b baseDN [\-f filter] [\-P protocol] [\-v] [\-h] +fixup-memberof.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } \-b baseDN [\-f filter] [\-P protocol] [\-h] .SH DESCRIPTION Regenerates and updates memberOf on user entries to coordinate changes in group membership. .SH OPTIONS @@ -54,10 +54,6 @@ The connection protocol to connect to the Directory Server. Protocols are START If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/ldif2db.8 b/man/man8/ldif2db.8 index c8ebac201..a5db3ea05 100644 --- a/man/man8/ldif2db.8 +++ b/man/man8/ldif2db.8 @@ -18,7 +18,7 @@ .SH NAME ldif2db - Directory Server script for importing a LDIF file .SH SYNOPSIS -ldif2db [\-Z serverID] \-n backendname {\-s includesuffix}* [{\-x excludesuffix}*] [\-g [string] [\-G namespace_id]] {\-i ldiffile}* [\-c chunksize] [\-O] [\-E] [\-q] [\-h] +ldif2db [\-Z serverID] \-n backendname {\-s includesuffix}* [{\-x excludesuffix}*] [\-g [string] [\-G namespace_id]] {\-i ldiffile}* [\-c chunksize] [\-v] [\-O] [\-E] [\-q] [\-h] .SH DESCRIPTION Imports a LDIF file. Either the option '\-n' or '\-s' must be used. The server instance must be stopped prior to running this command. .SH OPTIONS @@ -47,6 +47,10 @@ The number of entries to process before starting a fresh pass during the import. .br Requests that only the core database is created without attribute indexes. .TP +.B \fB\-v\fR +Display version +.br +.TP .B \fB\-g\fR \fI[string]\fR Generates a unique ID. Type none for no unique ID to be generated and deterministic for the generated unique ID to be name-based. By default, a time-based unique ID is generated. When using the deterministic generation to have a name-based unique ID, it is also possible to specify the namespace for the server to use, as follows: @@ -63,7 +67,7 @@ Encrypts data during import. This option is used only if database encryption is .TP .B \fB\-v\fR .br -Display verbose output +Display version .TP .B \fB\-h\fR .br diff --git a/man/man8/ldif2db.pl.8 b/man/man8/ldif2db.pl.8 index 198864a95..cc3e31681 100644 --- a/man/man8/ldif2db.pl.8 +++ b/man/man8/ldif2db.pl.8 @@ -18,7 +18,7 @@ .SH NAME ldif2db.pl - Directory Server perl script for importing a LDIF file .SH SYNOPSIS -ldif2db.pl \-n backend [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-P protocol] {\-s includeSuffix}* [{\-x excludeSuffix}*] [\-O] [\-c chunksize] [\-v] [\-h] [\-g [string]] [\-G namespace_id] {\-i filename}* +ldif2db.pl \-n backend [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-P protocol] {\-s includeSuffix}* [{\-x excludeSuffix}*] [\-O] [\-c chunksize] [\-h] [\-g [string]] [\-G namespace_id] {\-i filename}* .SH DESCRIPTION Imports LDIF file(s) into the server. Either the option '\-n' or '\-s' must be used. This script creates an entry in the directory that launches this dynamic task. .SH OPTIONS @@ -76,10 +76,6 @@ Requests that only the core database is created without attribute indexes. .B \fB\-c\fR \fIChunk size\fR The number of entries to process before starting a fresh pass during the import. By default this is handled internally by the server. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/schema-reload.pl.8 b/man/man8/schema-reload.pl.8 index d5988805f..17380cf7e 100644 --- a/man/man8/schema-reload.pl.8 +++ b/man/man8/schema-reload.pl.8 @@ -18,7 +18,7 @@ .SH NAME schema-reload.pl - Directory Server perl script for updating the schema. .SH SYNOPSIS -schema-reload.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-P protocol] [\-d schemadir] [\-v] [\-h] +schema-reload.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } [\-P protocol] [\-d schemadir] [\-h] .SH DESCRIPTION Manually reloads the schema files used by the Directory Server instance, either in the default location, or in user-specified locations. .SH OPTIONS @@ -50,10 +50,6 @@ The connection protocol to connect to the Directory Server. Protocols are START If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/syntax-validate.pl.8 b/man/man8/syntax-validate.pl.8 index 115e3ede9..ece2d5925 100644 --- a/man/man8/syntax-validate.pl.8 +++ b/man/man8/syntax-validate.pl.8 @@ -18,7 +18,7 @@ .SH NAME syntax-validate.pl - Directory Server perl script for validating attribute syntax. .SH SYNOPSIS -syntax-validate.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } \-b baseDN [\-f filter] [\-P protocol] [\-v] [\-h] +syntax-validate.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } \-b baseDN [\-f filter] [\-P protocol] [\-h] .SH DESCRIPTION Syntax validation checks every modification to attributes to make sure that the new value has the required syntax for that attribute type. All attribute syntaxes are validated against the definitions in RFC 4514. .SH OPTIONS @@ -53,10 +53,6 @@ The connection protocol to connect to the Directory Server. Protocols are START If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage diff --git a/man/man8/usn-tombstone-cleanup.pl.8 b/man/man8/usn-tombstone-cleanup.pl.8 index a8df579a1..f78b23033 100644 --- a/man/man8/usn-tombstone-cleanup.pl.8 +++ b/man/man8/usn-tombstone-cleanup.pl.8 @@ -18,7 +18,7 @@ .SH NAME usn-tombstone-cleanup.pl - Directory Server perl script for cleaning up tombstone entries. .SH SYNOPSIS -usn-tombstone-cleanup.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } \-s suffix \-n backend [\-m maxusn_to_delete] [\-P protocol] [\-v] [\-h] +usn-tombstone-cleanup.pl [\-Z serverID] [\-D rootdn] { \-w password | \-w \- | \-j filename } \-s suffix \-n backend [\-m maxusn_to_delete] [\-P protocol] [\-h] .SH DESCRIPTION Deletes the tombstone entries maintained by the instance if the USN Plug-in is enabled. .SH OPTIONS @@ -56,10 +56,6 @@ The connection protocol to connect to the Directory Server. Protocols are START If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. .TP -.B \fB\-v\fR -.br -Display verbose output -.TP .B \fB\-h\fR .br Display usage
0
3630638348d97e5c28fb2d5413b85f7d2949582e
389ds/389-ds-base
Bug 614511 - fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 https://bugzilla.redhat.com/show_bug.cgi?id=614511 Resolves: bug 614511 Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 description: Catch possible NULL pointer in cb_instance_free(), cb_instance_hosturl_set(), and cb_instance_starttls_set(), cb_instance_bindmech_set(), and cb_instance_config_get().
commit 3630638348d97e5c28fb2d5413b85f7d2949582e Author: Endi S. Dewata <[email protected]> Date: Mon Jul 12 23:04:01 2010 -0500 Bug 614511 - fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 https://bugzilla.redhat.com/show_bug.cgi?id=614511 Resolves: bug 614511 Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 description: Catch possible NULL pointer in cb_instance_free(), cb_instance_hosturl_set(), and cb_instance_starttls_set(), cb_instance_bindmech_set(), and cb_instance_config_get(). diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c index 73d5e019d..b1af028fe 100644 --- a/ldap/servers/plugins/chainingdb/cb_instance.c +++ b/ldap/servers/plugins/chainingdb/cb_instance.c @@ -250,16 +250,23 @@ void cb_instance_free(cb_backend_instance * inst) { inst->eq_ctx = NULL; } - if (inst->bind_pool) + if (inst->bind_pool) + { cb_close_conn_pool(inst->bind_pool); + slapi_destroy_condvar(inst->bind_pool->conn.conn_list_cv); + slapi_destroy_mutex(inst->bind_pool->conn.conn_list_mutex); + slapi_ch_free((void **) &inst->bind_pool); + } + if (inst->pool) + { cb_close_conn_pool(inst->pool); + slapi_destroy_condvar(inst->pool->conn.conn_list_cv); + slapi_destroy_mutex(inst->pool->conn.conn_list_mutex); + slapi_ch_free((void **) &inst->pool); + } - slapi_destroy_condvar(inst->bind_pool->conn.conn_list_cv); - slapi_destroy_condvar(inst->pool->conn.conn_list_cv); slapi_destroy_mutex(inst->monitor.mutex); - slapi_destroy_mutex(inst->bind_pool->conn.conn_list_mutex); - slapi_destroy_mutex(inst->pool->conn.conn_list_mutex); slapi_destroy_mutex(inst->monitor_availability.cpt_lock); slapi_destroy_mutex(inst->monitor_availability.lock_timeLimit); slapi_ch_free_string(&inst->configDn); @@ -267,11 +274,7 @@ void cb_instance_free(cb_backend_instance * inst) { slapi_ch_free_string(&inst->inst_name); charray_free(inst->every_attribute); - slapi_ch_free((void **) &inst->bind_pool); - slapi_ch_free((void **) &inst->pool); - PR_RWLock_Unlock(inst->rwl_config_lock); - PR_DestroyRWLock(inst->rwl_config_lock); slapi_ch_free((void **) &inst); @@ -716,14 +719,21 @@ static int cb_instance_hosturl_set(void *arg, void *value, char *errorbuf, int p int rc=LDAP_SUCCESS; int secure = 0; - if (( rc = slapi_ldap_url_parse( url, &ludp, 0, &secure )) != 0 ) { + if (!inst) { + PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "NULL instance"); + rc = LDAP_OPERATIONS_ERROR; + goto done; + } + + if (( rc = slapi_ldap_url_parse( url, &ludp, 0, &secure )) != 0 || !ludp) { PL_strncpyz(errorbuf,slapi_urlparse_err2string( rc ), SLAPI_DSE_RETURNTEXT_SIZE); if (CB_CONFIG_PHASE_INITIALIZATION == phase) inst->pool->url=slapi_ch_strdup(""); - return(LDAP_INVALID_SYNTAX); + rc = LDAP_INVALID_SYNTAX; + goto done; } - if (ludp && secure && inst && inst->rwl_config_lock) { + if (secure && inst->rwl_config_lock) { int isgss = 0; PR_RWLock_Rlock(inst->rwl_config_lock); isgss = inst->pool->mech && !PL_strcasecmp(inst->pool->mech, "GSSAPI"); @@ -812,7 +822,7 @@ static int cb_instance_hosturl_set(void *arg, void *value, char *errorbuf, int p PR_RWLock_Unlock(inst->rwl_config_lock); } - +done: if ( ludp != NULL ) { ldap_free_urldesc( ludp ); } @@ -1358,7 +1368,13 @@ static int cb_instance_starttls_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; int rc = LDAP_SUCCESS; - if (value && inst && inst->rwl_config_lock) { + if (!inst) { + PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "NULL instance"); + rc = LDAP_OPERATIONS_ERROR; + goto done; + } + + if (value && inst->rwl_config_lock) { int isgss = 0; PR_RWLock_Rlock(inst->rwl_config_lock); isgss = inst->pool->mech && !PL_strcasecmp(inst->pool->mech, "GSSAPI"); @@ -1378,6 +1394,7 @@ static int cb_instance_starttls_set(void *arg, void *value, char *errorbuf, int rc=CB_REOPEN_CONN; /* reconnect with the new starttls setting */ } } +done: return rc; } @@ -1397,7 +1414,13 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; int rc=LDAP_SUCCESS; - if (value && !PL_strcasecmp((char *) value, "GSSAPI") && inst && inst->rwl_config_lock) { + if (!inst) { + PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "NULL instance"); + rc = LDAP_OPERATIONS_ERROR; + goto done; + } + + if (value && !PL_strcasecmp((char *) value, "GSSAPI") && inst->rwl_config_lock) { int secure = 0; PR_RWLock_Rlock(inst->rwl_config_lock); secure = inst->pool->secure || inst->pool->starttls; @@ -1427,6 +1450,7 @@ static int cb_instance_bindmech_set(void *arg, void *value, char *errorbuf, int } PR_RWLock_Unlock(inst->rwl_config_lock); } +done: return rc; } @@ -1537,6 +1561,7 @@ void cb_instance_config_get(void *arg, cb_instance_config_info *config, char *bu if (config == NULL) { buf[0] = '\0'; + return; } switch(config->config_type) {
0
58bd25b8ce1ecd09d19aae31f6a989928d0413ed
389ds/389-ds-base
Resolves: bug 428765 Bug Description: leak in bitwise plugin Reviewed by: nhosoi (Thanks!) Branch: HEAD Fix Description: The bitwise plugin should first check to make sure the requested OID is one that it can handle. Platforms tested: RHEL5, Fedora 8, Fedora 9 Flag Day: no Doc impact: no
commit 58bd25b8ce1ecd09d19aae31f6a989928d0413ed Author: Rich Megginson <[email protected]> Date: Mon Jul 14 23:31:33 2008 +0000 Resolves: bug 428765 Bug Description: leak in bitwise plugin Reviewed by: nhosoi (Thanks!) Branch: HEAD Fix Description: The bitwise plugin should first check to make sure the requested OID is one that it can handle. Platforms tested: RHEL5, Fedora 8, Fedora 9 Flag Day: no Doc impact: no diff --git a/ldap/servers/plugins/bitwise/bitwise.c b/ldap/servers/plugins/bitwise/bitwise.c index 8116599c8..fb70fcfaf 100644 --- a/ldap/servers/plugins/bitwise/bitwise.c +++ b/ldap/servers/plugins/bitwise/bitwise.c @@ -167,14 +167,18 @@ bitwise_filter_create (Slapi_PBlock* pb) !slapi_pblock_get (pb, SLAPI_PLUGIN_MR_TYPE, &mrTYPE) && mrTYPE != NULL && !slapi_pblock_get (pb, SLAPI_PLUGIN_MR_VALUE, &mrVALUE) && mrVALUE != NULL) { - struct bitwise_match_cb *bmc = new_bitwise_match_cb(mrTYPE, mrVALUE); - slapi_pblock_set (pb, SLAPI_PLUGIN_OBJECT, bmc); - slapi_pblock_set (pb, SLAPI_PLUGIN_DESTROY_FN, (void*)bitwise_filter_destroy); + struct bitwise_match_cb *bmc = NULL; if (strcmp(mrOID, "1.2.840.113556.1.4.803") == 0) { slapi_pblock_set (pb, SLAPI_PLUGIN_MR_FILTER_MATCH_FN, (void*)bitwise_filter_match_and); } else if (strcmp(mrOID, "1.2.840.113556.1.4.804") == 0) { slapi_pblock_set (pb, SLAPI_PLUGIN_MR_FILTER_MATCH_FN, (void*)bitwise_filter_match_or); + } else { /* this oid not handled by this plugin */ + LDAPDebug (LDAP_DEBUG_FILTER, "=> bitwise_filter_create OID (%s) not handled\n", mrOID, 0, 0); + return rc; } + bmc = new_bitwise_match_cb(mrTYPE, mrVALUE); + slapi_pblock_set (pb, SLAPI_PLUGIN_OBJECT, bmc); + slapi_pblock_set (pb, SLAPI_PLUGIN_DESTROY_FN, (void*)bitwise_filter_destroy); rc = LDAP_SUCCESS; } else { LDAPDebug (LDAP_DEBUG_FILTER, "=> bitwise_filter_create missing parameter(s)\n", 0, 0, 0); @@ -190,9 +194,6 @@ int /* LDAP error code */ bitwise_init (Slapi_PBlock* pb) { int rc; - int argc; - char** argv; - char* cfgpath; rc = slapi_pblock_set (pb, SLAPI_PLUGIN_MR_FILTER_CREATE_FN, (void*)bitwise_filter_create); if ( rc == 0 ) {
0
0eb6f5b9a6f76c507ca8c7febf856713588ee5d0
389ds/389-ds-base
Ticket 48397 - ds make rpms doesn't work in a prefixed build env Bug Description: if you run a prefixed build, make rpms does not work. Additionally, rpmbuild throws invalid %if errors with this .spec Fix Description: This fixes the build paths to work regardless of prefix build or not. This also fixes the rpm if macros to work, and the missing dirsrvtests from the dist component of Makefile.am https://fedorahosted.org/389/ticket/48397 Author: wibrown Review by: mreynolds
commit 0eb6f5b9a6f76c507ca8c7febf856713588ee5d0 Author: William Brown <[email protected]> Date: Sat Jan 2 09:24:24 2016 +1000 Ticket 48397 - ds make rpms doesn't work in a prefixed build env Bug Description: if you run a prefixed build, make rpms does not work. Additionally, rpmbuild throws invalid %if errors with this .spec Fix Description: This fixes the build paths to work regardless of prefix build or not. This also fixes the rpm if macros to work, and the missing dirsrvtests from the dist component of Makefile.am https://fedorahosted.org/389/ticket/48397 Author: wibrown Review by: mreynolds diff --git a/Makefile.am b/Makefile.am index bca6489cc..da0965398 100644 --- a/Makefile.am +++ b/Makefile.am @@ -474,6 +474,7 @@ dist_noinst_DATA = \ $(srcdir)/VERSION.sh \ $(srcdir)/wrappers/*.in \ $(srcdir)/wrappers/systemd.template.sysconfig \ + $(srcdir)/dirsrvtests \ $(NULL) #------------------------ @@ -1960,9 +1961,9 @@ rpmroot: rpmbrprep: dist-bzip2 rpmroot cp $(distdir).tar.bz2 $(RPMBUILD)/SOURCES - cp $(builddir)/rpm/389-ds-base-git.sh $(RPMBUILD)/SOURCES - cp $(builddir)/rpm/389-ds-base-devel.README $(RPMBUILD)/SOURCES - sed -e "s/__VERSION__/$(RPM_VERSION)/" -e "s/__RELEASE__/$(RPM_RELEASE)/" -e "s/__NUNC_STANS_ON__/$(NUNC_STANS_ON)/" < $(builddir)/rpm/389-ds-base.spec > $(RPMBUILD)/SPECS/389-ds-base.spec + cp $(srcdir)/rpm/389-ds-base-git.sh $(RPMBUILD)/SOURCES + cp $(srcdir)/rpm/389-ds-base-devel.README $(RPMBUILD)/SOURCES + sed -e "s/__VERSION__/$(RPM_VERSION)/" -e "s/__RELEASE__/$(RPM_RELEASE)/" -e "s/__NUNC_STANS_ON__/$(NUNC_STANS_ON)/" < $(abs_builddir)/rpm/389-ds-base.spec > $(RPMBUILD)/SPECS/389-ds-base.spec rpms: rpmbrprep diff --git a/Makefile.in b/Makefile.in index c5637ab7e..d80811262 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1886,6 +1886,7 @@ dist_noinst_DATA = \ $(srcdir)/VERSION.sh \ $(srcdir)/wrappers/*.in \ $(srcdir)/wrappers/systemd.template.sysconfig \ + $(srcdir)/dirsrvtests \ $(NULL) @@ -10798,9 +10799,9 @@ rpmroot: rpmbrprep: dist-bzip2 rpmroot cp $(distdir).tar.bz2 $(RPMBUILD)/SOURCES - cp $(builddir)/rpm/389-ds-base-git.sh $(RPMBUILD)/SOURCES - cp $(builddir)/rpm/389-ds-base-devel.README $(RPMBUILD)/SOURCES - sed -e "s/__VERSION__/$(RPM_VERSION)/" -e "s/__RELEASE__/$(RPM_RELEASE)/" -e "s/__NUNC_STANS_ON__/$(NUNC_STANS_ON)/" < $(builddir)/rpm/389-ds-base.spec > $(RPMBUILD)/SPECS/389-ds-base.spec + cp $(srcdir)/rpm/389-ds-base-git.sh $(RPMBUILD)/SOURCES + cp $(srcdir)/rpm/389-ds-base-devel.README $(RPMBUILD)/SOURCES + sed -e "s/__VERSION__/$(RPM_VERSION)/" -e "s/__RELEASE__/$(RPM_RELEASE)/" -e "s/__NUNC_STANS_ON__/$(NUNC_STANS_ON)/" < $(abs_builddir)/rpm/389-ds-base.spec > $(RPMBUILD)/SPECS/389-ds-base.spec rpms: rpmbrprep cd $(RPMBUILD); \ diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index 68d7830ed..7dfa0b507 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -14,13 +14,13 @@ # nunc-stans only builds on x86_64 for now # To build without nunc-stans, set use_nunc_stans to 0. %global use_nunc_stans __NUNC_STANS_ON__ -%if %{use_nunc_stans} +%if 0%{?use_nunc_stans:1} %global nunc_stans_ver 0.1.7 %endif # Are we bundling jemalloc? %global bundle_jemalloc __BUNDLE_JEMALLOC__ -%if %{bundle_jemalloc} +%if 0%{?bundle_jemalloc:1} # The version used in the source tarball %global jemalloc_ver 3.6.0 %endif @@ -128,10 +128,10 @@ Source0: http://port389.org/sources/%{name}-%{version}%{?prerel}.tar.bz Source1: %{name}-git.sh Source2: %{name}-devel.README -%if %{bundle_jemalloc} +%if 0%{?bundle_jemalloc:1} Source3: http://www.port389.org/binaries/jemalloc-%{jemalloc_ver}.tar.bz2 %endif -%if %{use_nunc_stans} +%if 0%{?use_nunc_stans:1} Source4: https://git.fedorahosted.org/cgit/nunc-stans.git/snapshot/nunc-stans-%{nunc_stans_ver}.tar.xz %endif @@ -158,12 +158,12 @@ BuildRequires: libdb-devel BuildRequires: cyrus-sasl-devel BuildRequires: libicu-devel BuildRequires: pcre-devel -%if %{use_nunc_stans} +%if 0%{?use_nunc_stans:1} BuildRequires: libtalloc-devel BuildRequires: libevent-devel BuildRequires: libtevent-devel %endif -%if %{bundle_jemalloc} +%if 0%{?bundle_jemalloc:1} BuildRequires: /usr/bin/xsltproc %ifnarch s390 BuildRequires: valgrind-devel @@ -208,16 +208,16 @@ The lib389 CI tests that can be run against the Directory Server. %prep %setup -q -n %{name}-%{version}%{?prerel} -%if %{bundle_jemalloc} +%if 0%{?bundle_jemalloc:1} %setup -q -n %{name}-%{version}%{?prerel} -T -D -b 3 %endif -%if %{use_nunc_stans} +%if 0%{?use_nunc_stans:1} %setup -q -n %{name}-%{version}%{?prerel} -T -D -b 4 %endif cp %{SOURCE2} README.devel %build -%if %{use_nunc_stans} +%if 0%{?use_nunc_stans:1} pushd ../nunc-stans-%{nunc_stans_ver} %configure --with-fhs --libdir=%{_libdir}/%{pkgname} make %{?_smp_mflags} @@ -228,7 +228,7 @@ cp nunc-stans.h include/nunc-stans/nunc-stans.h popd %endif -%if %{bundle_jemalloc} +%if 0%{?bundle_jemalloc:1} pushd ../jemalloc-%{jemalloc_ver} %configure CFLAGS='%{optflags} -msse2' --libdir=%{_libdir}/%{pkgname} make %{?_smp_mflags} @@ -262,7 +262,7 @@ make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT -%if %{use_nunc_stans} +%if 0%{?use_nunc_stans:1} pushd ../nunc-stans-%{nunc_stans_ver} make DESTDIR="$RPM_BUILD_ROOT" install rm -rf $RPM_BUILD_ROOT%{_includedir} $RPM_BUILD_ROOT%{_datadir} \ @@ -270,7 +270,7 @@ rm -rf $RPM_BUILD_ROOT%{_includedir} $RPM_BUILD_ROOT%{_datadir} \ popd %endif -%if %{bundle_jemalloc} +%if 0%{?bundle_jemalloc:1} pushd ../jemalloc-%{jemalloc_ver} cp --preserve=links lib/libjemalloc.so* $RPM_BUILD_ROOT%{_libdir}/%{pkgname} popd @@ -294,6 +294,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/plugins/*.la # make sure perl scripts have a proper shebang sed -i -e 's|#{{PERL-EXEC}}|#!/usr/bin/perl|' $RPM_BUILD_ROOT%{_datadir}/%{pkgname}/script-templates/template-*.pl +# Why are we not making this a proper python package? pushd ../%{name}-%{version}%{?prerel} cp -r dirsrvtests $RPM_BUILD_ROOT/%{_sysconfdir}/%{pkgname} find $RPM_BUILD_ROOT/%{_sysconfdir}/%{pkgname}/dirsrvtests -type f -name '*.pyc' -delete @@ -434,10 +435,10 @@ fi %doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.devel %{_includedir}/%{pkgname} %{_libdir}/%{pkgname}/libslapd.so -%if %{use_nunc_stans} +%if 0%{?use_nunc_stans:1} %{_libdir}/%{pkgname}/libnunc-stans.so %endif -%if %{bundle_jemalloc} +%if 0%{?bundle_jemalloc:1} %{_libdir}/%{pkgname}/libjemalloc.so %endif %{_libdir}/pkgconfig/* @@ -448,10 +449,10 @@ fi %dir %{_libdir}/%{pkgname} %{_libdir}/%{pkgname}/libslapd.so.* %{_libdir}/%{pkgname}/libns-dshttpd.so* -%if %{use_nunc_stans} +%if 0%{?use_nunc_stans:1} %{_libdir}/%{pkgname}/libnunc-stans.so* %endif -%if %{bundle_jemalloc} +%if 0%{?bundle_jemalloc:1} %{_libdir}/%{pkgname}/libjemalloc.so* %endif
0
ca3ad2b93cfaf1dc427f81230e79fe9862fdd2f9
389ds/389-ds-base
Bug 614511 - fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 https://bugzilla.redhat.com/show_bug.cgi?id=614511 Resolves: bug 614511 Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 description: Catch possible NULL pointer in acl_operation_ext_destructor() and acl_init_aclpb().
commit ca3ad2b93cfaf1dc427f81230e79fe9862fdd2f9 Author: Endi S. Dewata <[email protected]> Date: Mon Jul 12 22:57:47 2010 -0500 Bug 614511 - fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 https://bugzilla.redhat.com/show_bug.cgi?id=614511 Resolves: bug 614511 Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 description: Catch possible NULL pointer in acl_operation_ext_destructor() and acl_init_aclpb(). diff --git a/ldap/servers/plugins/acl/acl_ext.c b/ldap/servers/plugins/acl/acl_ext.c index d9494ec39..fbe469fa0 100644 --- a/ldap/servers/plugins/acl/acl_ext.c +++ b/ldap/servers/plugins/acl/acl_ext.c @@ -275,6 +275,11 @@ acl_operation_ext_destructor ( void *ext, void *object, void *parent ) (!(aclpb->aclpb_state & ACLPB_INITIALIZED))) goto clean_aclpb; + if ( NULL == aclpb->aclpb_authorization_sdn ) { + slapi_log_error (SLAPI_LOG_FATAL, plugin_name, "NULL aclcb_autorization_sdn\n"); + goto clean_aclpb; + } + /* get the connection extension */ aclcb = (struct acl_cblock *) acl_get_ext ( ACL_EXT_CONNECTION, parent ); @@ -316,7 +321,7 @@ acl_operation_ext_destructor ( void *ext, void *object, void *parent ) acl_copyEval_context ( NULL, c_evalContext, &aclcb->aclcb_eval_context, attr_only ); aclcb->aclcb_aclsignature = aclpb->aclpb_signature; - if ( aclcb->aclcb_sdn && aclpb->aclpb_authorization_sdn && + if ( aclcb->aclcb_sdn && (0 != slapi_sdn_compare ( aclcb->aclcb_sdn, aclpb->aclpb_authorization_sdn ) ) ) { slapi_sdn_set_ndn_byval( aclcb->aclcb_sdn,
0
add880accaa28de8304da1c2c2f58fe8af002ebb
389ds/389-ds-base
Trac Ticket #260 - 389 DS does not support multiple paging controls on a single connection https://fedorahosted.org/389/ticket/260 Fix description: 1. "Connection" object holds the paged results related values. Now they are packaged in one PagedResults object. And the array of PagedResults with its length and used count are placed in PagedResultList, which is stashed in Connection (slap.h). 2. The pagedresults APIs are extended to take the index of Paged- Results array. The index is set to the cookie in the Paged- Results control before returning it to the client. When a client sends a paged results request, the cookie field in the first request control is supposed to be empty. The result control is returned with the search results. The result control stores the index in the cookie and the client sets it to the following request control to get the next pages. When the paged search is done, empty cookie is returned. If a passed cookie is less than 0 or greater than the array size and the request control is "critical", the request fails with LDAP_PROTOCOL_ERROR and the error is logged in the error log. If the control is not "critical", the paged results request is disabled. 3. The array grows if multiple simple paged results requests over a single connection come in. The array does not get released every time, but it is when the server is shutdown. 4. Simple paged results connection is timed out when it exeeds the timelimit. If multiple requests are served, it won't be disconnected until all the requests are timed out.
commit add880accaa28de8304da1c2c2f58fe8af002ebb Author: Noriko Hosoi <[email protected]> Date: Wed Feb 29 11:33:50 2012 -0800 Trac Ticket #260 - 389 DS does not support multiple paging controls on a single connection https://fedorahosted.org/389/ticket/260 Fix description: 1. "Connection" object holds the paged results related values. Now they are packaged in one PagedResults object. And the array of PagedResults with its length and used count are placed in PagedResultList, which is stashed in Connection (slap.h). 2. The pagedresults APIs are extended to take the index of Paged- Results array. The index is set to the cookie in the Paged- Results control before returning it to the client. When a client sends a paged results request, the cookie field in the first request control is supposed to be empty. The result control is returned with the search results. The result control stores the index in the cookie and the client sets it to the following request control to get the next pages. When the paged search is done, empty cookie is returned. If a passed cookie is less than 0 or greater than the array size and the request control is "critical", the request fails with LDAP_PROTOCOL_ERROR and the error is logged in the error log. If the control is not "critical", the paged results request is disabled. 3. The array grows if multiple simple paged results requests over a single connection come in. The array does not get released every time, but it is when the server is shutdown. 4. Simple paged results connection is timed out when it exeeds the timelimit. If multiple requests are served, it won't be disconnected until all the requests are timed out. diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c index 8870364c7..4f00da9cd 100644 --- a/ldap/servers/slapd/abandon.c +++ b/ldap/servers/slapd/abandon.c @@ -152,11 +152,12 @@ do_abandon( Slapi_PBlock *pb ) 0 ); } - if (pagedresults_cleanup(pb->pb_conn, 0 /* already locked */)) { - /* Cleaned up paged result connection */ - slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ABANDON" - " targetop=Simple Paged Results\n", - pb->pb_conn->c_connid, pb->pb_op->o_opid ); + if ( op_is_pagedresults(o) ) { + if ( 0 == pagedresults_free_one_msgid(pb->pb_conn, id) ) { + slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 + " op=%d ABANDON targetop=Simple Paged Results\n", + pb->pb_conn->c_connid, pb->pb_op->o_opid ); + } } else if ( NULL == o ) { slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ABANDON" " targetop=NOTFOUND msgid=%d\n", diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c index fbc8ccf77..27b20ec97 100644 --- a/ldap/servers/slapd/back-ldbm/filterindex.c +++ b/ldap/servers/slapd/back-ldbm/filterindex.c @@ -223,6 +223,7 @@ ava_candidates( int unindexed = 0; Slapi_Attr sattr; back_txn txn = {NULL}; + int pr_idx = -1; LDAPDebug( LDAP_DEBUG_TRACE, "=> ava_candidates\n", 0, 0, 0 ); @@ -232,6 +233,7 @@ ava_candidates( return( NULL ); } + slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx); slapi_attr_init(&sattr, type); #ifdef LDAP_DEBUG @@ -315,7 +317,7 @@ ava_candidates( if ( unindexed ) { unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED; slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote ); - pagedresults_set_unindexed( pb->pb_conn ); + pagedresults_set_unindexed( pb->pb_conn, pr_idx ); } /* We don't use valuearray_free here since the valueset, berval @@ -347,7 +349,7 @@ ava_candidates( if ( unindexed ) { unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED; slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote ); - pagedresults_set_unindexed( pb->pb_conn ); + pagedresults_set_unindexed( pb->pb_conn, pr_idx ); } valuearray_free( &ivals ); LDAPDebug( LDAP_DEBUG_TRACE, "<= ava_candidates %lu\n", @@ -384,9 +386,11 @@ presence_candidates( NULL, &txn, err, &unindexed, allidslimit ); if ( unindexed ) { + int pr_idx = -1; unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED; slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote ); - pagedresults_set_unindexed( pb->pb_conn ); + slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx); + pagedresults_set_unindexed( pb->pb_conn, pr_idx ); } if (idl != NULL && ALLIDS(idl) && strcasecmp(type, "nscpentrydn") == 0) { @@ -492,10 +496,15 @@ extensible_candidates( index_range_read_ext(pb, be, mrTYPE, mrOID, mrOP, *key, NULL, 0, &txn, err, allidslimit); if ( unindexed ) { + int pr_idx = -1; unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED; slapi_pblock_set( glob_pb, - SLAPI_OPERATION_NOTES, &opnote ); - pagedresults_set_unindexed( glob_pb->pb_conn ); + SLAPI_OPERATION_NOTES, &opnote ); + slapi_pblock_get( glob_pb, + SLAPI_PAGED_RESULTS_INDEX, + &pr_idx ); + pagedresults_set_unindexed( glob_pb->pb_conn, + pr_idx ); } if (idl2 == NULL) { @@ -839,7 +848,7 @@ list_candidates( */ /* PAGED RESULTS: we strictly limit the idlist size by the allids (aka idlistscan) limit. */ - if (operation->o_flags & OP_FLAG_PAGED_RESULTS) { + if (op_is_pagedresults(operation)) { int nids = IDL_NIDS(idl); if ( allidslimit > 0 && nids > allidslimit ) { idl_free( idl ); @@ -887,6 +896,7 @@ substring_candidates( unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED; Slapi_Attr sattr; back_txn txn = {NULL}; + int pr_idx = -1; LDAPDebug( LDAP_DEBUG_TRACE, "=> sub_candidates\n", 0, 0, 0 ); @@ -903,9 +913,10 @@ substring_candidates( slapi_attr_init(&sattr, type); slapi_attr_assertion2keys_sub_sv( &sattr, initial, any, final, &ivals ); attr_done(&sattr); + slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx); if ( ivals == NULL || *ivals == NULL ) { slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote ); - pagedresults_set_unindexed( pb->pb_conn ); + pagedresults_set_unindexed( pb->pb_conn, pr_idx ); LDAPDebug( LDAP_DEBUG_TRACE, "<= sub_candidates ALLIDS (no keys)\n", 0, 0, 0 ); return( idl_allids( be ) ); @@ -919,7 +930,7 @@ substring_candidates( idl = keys2idl( be, type, indextype_SUB, ivals, err, &unindexed, &txn, allidslimit ); if ( unindexed ) { slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote ); - pagedresults_set_unindexed( pb->pb_conn ); + pagedresults_set_unindexed( pb->pb_conn, pr_idx ); } valuearray_free( &ivals ); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c index 7d897c786..e6967e8fd 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_search.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c @@ -95,7 +95,7 @@ compute_lookthrough_limit( Slapi_PBlock *pb, struct ldbminfo *li ) } } - if (op && (op->o_flags & OP_FLAG_PAGED_RESULTS)) { + if (op_is_pagedresults(op)) { if ( slapi_reslimit_get_integer_limit( conn, li->li_reslimit_pagedlookthrough_handle, &limit ) != SLAPI_RESLIMIT_STATUS_SUCCESS ) { @@ -127,7 +127,7 @@ compute_allids_limit( Slapi_PBlock *pb, struct ldbminfo *li ) limit = li->li_allidsthreshold; PR_Unlock(li->li_config_mutex); } - if (op && (op->o_flags & OP_FLAG_PAGED_RESULTS)) { + if (op_is_pagedresults(op)) { if ( slapi_reslimit_get_integer_limit( conn, li->li_reslimit_pagedallids_handle, &limit ) != SLAPI_RESLIMIT_STATUS_SUCCESS ) { @@ -184,8 +184,10 @@ ldbm_back_search_cleanup(Slapi_PBlock *pb, back_search_result_set *sr = NULL; slapi_pblock_get( pb, SLAPI_SEARCH_RESULT_SET, &sr ); if ( (NULL != sr) && (function_result != 0) ) { + int pr_idx = -1; + slapi_pblock_get( pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx ); /* in case paged results, clean up the conn */ - pagedresults_set_search_result(pb->pb_conn, NULL, 0); + pagedresults_set_search_result( pb->pb_conn, NULL, 0, pr_idx ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate ); delete_search_result_set(&sr); @@ -355,8 +357,8 @@ ldbm_back_search( Slapi_PBlock *pb ) if ( !txn.back_txn_txn ) { dblayer_txn_init( li, &txn ); - slapi_pblock_set( pb, SLAPI_TXN, txn.back_txn_txn ); - } + slapi_pblock_set( pb, SLAPI_TXN, txn.back_txn_txn ); + } inst = (ldbm_instance *) be->be_instance_info; @@ -829,6 +831,7 @@ ldbm_back_search( Slapi_PBlock *pb ) if ( NULL != candidates && ALLIDS( candidates )) { unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED; int ri = 0; + int pr_idx = -1; /* * Return error if nsslapd-require-index is set and @@ -850,7 +853,8 @@ ldbm_back_search( Slapi_PBlock *pb ) } slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote ); - pagedresults_set_unindexed( pb->pb_conn ); + slapi_pblock_get( pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx ); + pagedresults_set_unindexed( pb->pb_conn, pr_idx ); } sr->sr_candidates = candidates; @@ -1338,6 +1342,7 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension ) int rc = 0; int estimate = 0; /* estimated search result count */ back_txn txn = {NULL}; + int pr_idx = -1; slapi_pblock_get( pb, SLAPI_BACKEND, &be ); slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li ); @@ -1354,6 +1359,7 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension ) slapi_pblock_get( pb, SLAPI_TARGET_UNIQUEID, &target_uniqueid ); slapi_pblock_get( pb, SLAPI_SEARCH_RESULT_SET, &sr ); slapi_pblock_get( pb, SLAPI_TXN, &txn.back_txn_txn ); + slapi_pblock_get( pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx ); if ( !txn.back_txn_txn ) { dblayer_txn_init( li, &txn ); @@ -1424,7 +1430,7 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension ) if ( slapi_op_abandoned( pb ) || (NULL == sr) ) { /* in case paged results, clean up the conn */ - pagedresults_set_search_result(pb->pb_conn, NULL, 0); + pagedresults_set_search_result( pb->pb_conn, NULL, 0, pr_idx ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate ); if ( use_extension ) { @@ -1441,7 +1447,7 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension ) if ( tlimit != -1 && curtime > stoptime ) { /* in case paged results, clean up the conn */ - pagedresults_set_search_result(pb->pb_conn, NULL, 0); + pagedresults_set_search_result( pb->pb_conn, NULL, 0, pr_idx ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate ); if ( use_extension ) { @@ -1458,7 +1464,7 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension ) if ( llimit != -1 && sr->sr_lookthroughcount >= llimit ) { /* in case paged results, clean up the conn */ - pagedresults_set_search_result(pb->pb_conn, NULL, 0); + pagedresults_set_search_result( pb->pb_conn, NULL, 0, pr_idx ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate ); if ( use_extension ) { @@ -1478,7 +1484,7 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension ) /* No more entries */ /* destroy back_search_result_set */ /* in case paged results, clean up the conn */ - pagedresults_set_search_result(pb->pb_conn, NULL, 0); + pagedresults_set_search_result( pb->pb_conn, NULL, 0, pr_idx ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate ); if ( use_extension ) { @@ -1621,7 +1627,8 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension ) if ( --slimit < 0 ) { CACHE_RETURN( &inst->inst_cache, &e ); /* in case paged results, clean up the conn */ - pagedresults_set_search_result(pb->pb_conn, NULL, 0); + pagedresults_set_search_result( pb->pb_conn, NULL, + 0, pr_idx); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL ); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate ); delete_search_result_set( &sr ); diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c index a953030dd..cf807ec48 100644 --- a/ldap/servers/slapd/back-ldbm/vlv.c +++ b/ldap/servers/slapd/back-ldbm/vlv.c @@ -1159,9 +1159,11 @@ vlv_search_build_candidate_list(Slapi_PBlock *pb, const Slapi_DN *base, int *vlv slapi_rwlock_rdlock(be->vlvSearchList_lock); if((pi=vlv_find_search(be, base, scope, fstr, sort_control)) == NULL) { unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED; + int pr_idx = -1; + slapi_pblock_get( pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx ); slapi_rwlock_unlock(be->vlvSearchList_lock); slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote ); - pagedresults_set_unindexed( pb->pb_conn ); + pagedresults_set_unindexed( pb->pb_conn, pr_idx ); rc = VLV_FIND_SEARCH_FAILED; } else if((*vlv_rc=vlvIndex_accessallowed(pi, pb)) != LDAP_SUCCESS) { slapi_rwlock_unlock(be->vlvSearchList_lock); diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index 13d56b6a2..9e4310400 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -117,6 +117,8 @@ connection_done(Connection *conn) { PR_DestroyLock(conn->c_pdumutex); } + /* PAGED_RESULTS */ + pagedresults_cleanup_all(conn, 0); } /* @@ -2092,7 +2094,7 @@ void connection_enter_leave_turbo(Connection *conn, int current_turbo_flag, int PR_Lock(conn->c_mutex); /* We can already be in turbo mode, or not */ current_mode = current_turbo_flag; - if (conn->c_search_result_set) { + if (pagedresults_in_use(conn)) { /* PAGED_RESULTS does not need turbo mode */ new_mode = 0; } else if (conn->c_private->operation_rate == 0) { @@ -2776,7 +2778,9 @@ disconnect_server_nomutex( Connection *conn, PRUint64 opconnid, int opid, PRErro conn->c_gettingber = 0; connection_abandon_operations( conn ); - conn->c_timelimit = 0; /* needed here to ensure simple paged results timeout properly and don't impact subsequent ops */ + /* needed here to ensure simple paged results timeout properly and + * don't impact subsequent ops */ + pagedresults_reset_timedout(conn); if (! config_check_referral_mode()) { /* diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 3333e8a8b..922802c7a 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -1211,17 +1211,15 @@ setup_pr_read_pds(Connection_Table *ct, PRFileDesc **n_tcps, PRFileDesc **s_tcps { int add_fd = 1; /* check timeout for PAGED RESULTS */ - if (c->c_current_be && (c->c_timelimit > 0)) + if (pagedresults_is_timedout(c)) { - time_t ctime = current_time(); - if (ctime > c->c_timelimit) - { - /* Exceeded the timelimit; disconnect the client */ - disconnect_server_nomutex(c, c->c_connid, -1, - SLAPD_DISCONNECT_IO_TIMEOUT, 0); - connection_table_move_connection_out_of_active_list(ct,c); - add_fd = 0; /* do not poll on this fd */ - } + /* Exceeded the timelimit; disconnect the client */ + disconnect_server_nomutex(c, c->c_connid, -1, + SLAPD_DISCONNECT_IO_TIMEOUT, + 0); + connection_table_move_connection_out_of_active_list(ct, + c); + add_fd = 0; /* do not poll on this fd */ } if (add_fd) { diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c index 01014692a..8d3e5900f 100644 --- a/ldap/servers/slapd/opshared.c +++ b/ldap/servers/slapd/opshared.c @@ -268,6 +268,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result) Slapi_Backend *pr_be = NULL; void *pr_search_result = NULL; int pr_reset_processing = 0; + int pr_idx = -1; be_list[0] = NULL; referral_list[0] = NULL; @@ -450,28 +451,38 @@ op_shared_search (Slapi_PBlock *pb, int send_result) if ( slapi_control_present (ctrlp, LDAP_CONTROL_PAGEDRESULTS, &ctl_value, &iscritical) ) { - rc = pagedresults_parse_control_value(ctl_value, - &pagesize, &curr_search_count); + rc = pagedresults_parse_control_value(pb, ctl_value, + &pagesize, &pr_idx); + /* Let's set pr_idx even if it fails; in case, pr_idx == -1. */ + slapi_pblock_set(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx); if (LDAP_SUCCESS == rc) { unsigned int opnote = SLAPI_OP_NOTE_SIMPLEPAGED; - if (pagedresults_check_or_set_processing(pb->pb_conn)) { + if (pagedresults_check_or_set_processing(pb->pb_conn, pr_idx)) { send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, - NULL, "Simple Paged Results Search already in progress on this connection", 0, NULL); + NULL, "Simple Paged Results Search " + "already in progress on this connection", + 0, NULL); goto free_and_return_nolock; } - pr_reset_processing = 1; /* need to reset after we are done with this op */ - operation->o_flags |= OP_FLAG_PAGED_RESULTS; - pr_be = pagedresults_get_current_be(pb->pb_conn); - pr_search_result = pagedresults_get_search_result(pb->pb_conn); + /* need to reset after we are done with this op */ + pr_reset_processing = 1; + op_set_pagedresults(operation); + pr_be = pagedresults_get_current_be(pb->pb_conn, pr_idx); + pr_search_result = pagedresults_get_search_result(pb->pb_conn, + pr_idx); estimate = - pagedresults_get_search_result_set_size_estimate(pb->pb_conn); - if (pagedresults_get_unindexed(pb->pb_conn)) { + pagedresults_get_search_result_set_size_estimate(pb->pb_conn, + pr_idx); + if (pagedresults_get_unindexed(pb->pb_conn, pr_idx)) { opnote |= SLAPI_OP_NOTE_UNINDEXED; } slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote ); } else { /* parse paged-results-control failed */ if (iscritical) { /* return an error since it's critical */ + send_ldap_result(pb, rc, NULL, + "Simple Paged Results Search failed", + 0, NULL); goto free_and_return; } } @@ -567,7 +578,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result) } if (slapi_sdn_compare(basesdn, sdn)) { slapi_sdn_free(&basesdn); - basesdn = operation_get_target_spec(pb->pb_op); + basesdn = operation_get_target_spec(pb->pb_op); slapi_sdn_free(&basesdn); basesdn = slapi_sdn_dup(sdn); operation_set_target_spec (pb->pb_op, basesdn); @@ -601,13 +612,13 @@ op_shared_search (Slapi_PBlock *pb, int send_result) } /* set the timelimit to clean up the too-long-lived-paged results requests */ - if (operation->o_flags & OP_FLAG_PAGED_RESULTS) { + if (op_is_pagedresults(operation)) { time_t optime, time_up; int tlimit; slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &tlimit ); slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime ); time_up = (tlimit==-1 ? -1 : optime + tlimit); /* -1: no time limit */ - pagedresults_set_timelimit(pb->pb_conn, time_up); + pagedresults_set_timelimit(pb->pb_conn, time_up, pr_idx); } /* PAR: now filters have been rewritten, we can assign plugins to work on them */ @@ -658,7 +669,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result) next_be = NULL; } - if ((operation->o_flags & OP_FLAG_PAGED_RESULTS) && pr_search_result) { + if (op_is_pagedresults(operation) && pr_search_result) { void *sr = NULL; /* PAGED RESULTS and already have the search results from the prev op */ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, pr_search_result ); @@ -666,7 +677,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result) /* search result could be reset in the backend/dse */ slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr); - pagedresults_set_search_result(pb->pb_conn, sr, 0); + pagedresults_set_search_result(pb->pb_conn, sr, 0, pr_idx); if (PAGEDRESULTS_SEARCH_END == pr_stat) { /* no more entries to send in the backend */ @@ -676,7 +687,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result) } else { curr_search_count = pnentries; /* no more entries, but at least another backend */ - if (pagedresults_set_current_be(pb->pb_conn, next_be) < 0) { + if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) { goto free_and_return; } } @@ -685,14 +696,16 @@ op_shared_search (Slapi_PBlock *pb, int send_result) curr_search_count = pnentries; estimate -= estimate?curr_search_count:0; } - pagedresults_set_response_control(pb, 0, estimate, curr_search_count); - if (pagedresults_get_with_sort(pb->pb_conn)) { + pagedresults_set_response_control(pb, 0, estimate, + curr_search_count, pr_idx); + if (pagedresults_get_with_sort(pb->pb_conn, pr_idx)) { sort_make_sort_response_control(pb, CONN_GET_SORT_RESULT_CODE, NULL); } - pagedresults_set_search_result_set_size_estimate(pb->pb_conn, estimate); + pagedresults_set_search_result_set_size_estimate(pb->pb_conn, + estimate, pr_idx); next_be = NULL; /* to break the loop */ if (curr_search_count == -1) { - pagedresults_cleanup(pb->pb_conn, 1 /* need to lock */); + pagedresults_free_one(pb->pb_conn, pr_idx); } } else { /* be_suffix null means that we are searching the default backend @@ -803,7 +816,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result) rc = send_results_ext (pb, 1, &pnentries, pagesize, &pr_stat); /* PAGED RESULTS */ - if (operation->o_flags & OP_FLAG_PAGED_RESULTS) { + if (op_is_pagedresults(operation)) { void *sr = NULL; int with_sort = operation->o_flags & OP_FLAG_SERVER_SIDE_SORTING; @@ -814,7 +827,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result) curr_search_count = -1; } else { /* no more entries, but at least another backend */ - if (pagedresults_set_current_be(pb->pb_conn, next_be) < 0) { + if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) { goto free_and_return; } } @@ -822,22 +835,22 @@ op_shared_search (Slapi_PBlock *pb, int send_result) curr_search_count = pnentries; slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr); slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate); - if (pagedresults_set_current_be(pb->pb_conn, be) < 0 || - pagedresults_set_search_result(pb->pb_conn, sr, 0) < 0 || + if (pagedresults_set_current_be(pb->pb_conn, be, pr_idx) < 0 || + pagedresults_set_search_result(pb->pb_conn, sr, 0, pr_idx) < 0 || pagedresults_set_search_result_count(pb->pb_conn, - curr_search_count) < 0 || + curr_search_count, pr_idx) < 0 || pagedresults_set_search_result_set_size_estimate(pb->pb_conn, - estimate) < 0 || - pagedresults_set_with_sort(pb->pb_conn, with_sort) < 0) { + estimate, pr_idx) < 0 || + pagedresults_set_with_sort(pb->pb_conn, with_sort, pr_idx) < 0) { goto free_and_return; } } - pagedresults_set_response_control(pb, 0, - estimate, curr_search_count); + pagedresults_set_response_control(pb, 0, estimate, + curr_search_count, pr_idx); slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL ); next_be = NULL; /* to break the loop */ if (curr_search_count == -1) { - pagedresults_cleanup(pb->pb_conn, 1 /* need to lock */); + pagedresults_free_one(pb->pb_conn, pr_idx); } } @@ -965,7 +978,7 @@ free_and_return_nolock: slapi_ch_free_string(&proxydn); slapi_ch_free_string(&proxystr); if (pr_reset_processing) { - pagedresults_reset_processing(pb->pb_conn); + pagedresults_reset_processing(pb->pb_conn, pr_idx); } } @@ -1204,12 +1217,14 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result, Slapi_Entry *e = NULL; char **attrs = NULL; unsigned int pr_stat = 0; + int pr_idx = -1; if ( NULL == pb ) { return rval; } slapi_pblock_get(pb, SLAPI_SEARCH_ATTRS, &attrs); slapi_pblock_get(pb, SLAPI_SEARCH_ATTRSONLY, &attrsonly); + slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx); *pnentries = 0; @@ -1231,7 +1246,7 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result, operation_out_of_disk_space(); } pr_stat = PAGEDRESULTS_SEARCH_END; - pagedresults_set_timelimit(pb->pb_conn, 0); + pagedresults_set_timelimit(pb->pb_conn, 0, pr_idx); rval = -1; done = 1; continue; @@ -1542,7 +1557,7 @@ compute_limits (Slapi_PBlock *pb) } } - if (op && (op->o_flags & OP_FLAG_PAGED_RESULTS)) { + if (op_is_pagedresults(op)) { if ( slapi_reslimit_get_integer_limit( pb->pb_conn, pagedsizelimit_reslimit_handle, &max_sizelimit ) != SLAPI_RESLIMIT_STATUS_SUCCESS ) { @@ -1633,7 +1648,7 @@ send_results_ext(Slapi_PBlock *pb, int send_result, int *nentries, int pagesize, */ break; - case 1: /* everything is ok - don't send the result */ + case 1: /* everything is ok - don't send the result */ rc = 0; } diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c index c77ec27d0..1690e889e 100644 --- a/ldap/servers/slapd/pagedresults.c +++ b/ldap/servers/slapd/pagedresults.c @@ -50,20 +50,29 @@ * -- requested page size from client * -- result set size estimate from server * cookie OCTET STRING + * -- index for the pagedresults array in the connection * } * * Return an LDAP error code (LDAP_SUCCESS if all goes well). */ int -pagedresults_parse_control_value( struct berval *psbvp, - ber_int_t *pagesize, int *curr_search_count ) +pagedresults_parse_control_value( Slapi_PBlock *pb, + struct berval *psbvp, ber_int_t *pagesize, + int *index ) { int rc = LDAP_SUCCESS; struct berval cookie = {0}; + Connection *conn = pb->pb_conn; + Operation *op = pb->pb_op; - if ( NULL == pagesize || NULL == curr_search_count ) { + LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_parse_control_value\n"); + if ( NULL == conn || NULL == op || NULL == pagesize || NULL == index ) { + LDAPDebug1Arg(LDAP_DEBUG_ANY, + "<-- pagedresults_parse_control_value: %d\n", + LDAP_OPERATIONS_ERROR); return LDAP_OPERATIONS_ERROR; } + *index = -1; if ( psbvp->bv_len == 0 || psbvp->bv_val == NULL ) { @@ -85,19 +94,64 @@ pagedresults_parse_control_value( struct berval *psbvp, /* the ber encoding is no longer needed */ ber_free(ber, 1); if ( cookie.bv_len <= 0 ) { - *curr_search_count = 0; + int i; + int maxlen; + /* first time? */ + PR_Lock(conn->c_mutex); + maxlen = conn->c_pagedresults.prl_maxlen; + if (conn->c_pagedresults.prl_count == maxlen) { + if (0 == maxlen) { /* first time */ + conn->c_pagedresults.prl_maxlen = 1; + conn->c_pagedresults.prl_list = + (PagedResults *)slapi_ch_calloc(1, + sizeof(PagedResults)); + } else { + /* new max length */ + conn->c_pagedresults.prl_maxlen *= 2; + conn->c_pagedresults.prl_list = + (PagedResults *)slapi_ch_realloc( + (char *)conn->c_pagedresults.prl_list, + sizeof(PagedResults) * + conn->c_pagedresults.prl_maxlen); + /* initialze newly allocated area */ + memset(conn->c_pagedresults.prl_list + maxlen, '\0', + sizeof(PagedResults) * maxlen); + } + *index = maxlen; /* the first position in the new area */ + } else { + for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) { + if (!conn->c_pagedresults.prl_list[i].pr_current_be) { + *index = i; + break; + } + } + } + conn->c_pagedresults.prl_count++; + PR_Unlock(conn->c_mutex); } else { - /* not an error */ + /* Repeated paged results request. + * PagedResults is already allocated. */ char *ptr = slapi_ch_malloc(cookie.bv_len + 1); memcpy(ptr, cookie.bv_val, cookie.bv_len); *(ptr+cookie.bv_len) = '\0'; - *curr_search_count = strtol(ptr, NULL, 10); + *index = strtol(ptr, NULL, 10); slapi_ch_free_string(&ptr); } slapi_ch_free((void **)&cookie.bv_val); } } + if ((*index > -1) && (*index < conn->c_pagedresults.prl_maxlen)) { + /* Need to keep the latest msgid to prepare for the abandon. */ + conn->c_pagedresults.prl_list[*index].pr_msgid = op->o_msgid; + } else { + rc = LDAP_PROTOCOL_ERROR; + LDAPDebug1Arg(LDAP_DEBUG_ANY, + "pagedresults_parse_control_value: invalid cookie: %d\n", + *index); + } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_parse_control_value: idx %d\n", *index); return rc; } @@ -114,7 +168,8 @@ pagedresults_parse_control_value( struct berval *psbvp, */ void pagedresults_set_response_control( Slapi_PBlock *pb, int iscritical, - ber_int_t estimate, int curr_search_count ) + ber_int_t estimate, int current_search_count, + int index ) { LDAPControl **resultctrls = NULL; LDAPControl pr_respctrl; @@ -124,16 +179,19 @@ pagedresults_set_response_control( Slapi_PBlock *pb, int iscritical, int found = 0; int i; + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_set_response_control: idx=%d\n", index); + if ( (ber = der_alloc()) == NULL ) { goto bailout; } /* begin sequence, payload, end sequence */ - if (curr_search_count < 0) { + if (current_search_count < 0) { cookie_str = slapi_ch_strdup(""); } else { - cookie_str = slapi_ch_smprintf("%d", curr_search_count); + cookie_str = slapi_ch_smprintf("%d", index); } ber_printf ( ber, "{io}", estimate, cookie_str, strlen(cookie_str) ); if ( ber_flatten ( ber, &berval ) != LDAP_SUCCESS ) @@ -169,202 +227,362 @@ pagedresults_set_response_control( Slapi_PBlock *pb, int iscritical, bailout: slapi_ch_free_string(&cookie_str); - ber_free ( ber, 1 ); /* ber_free() checks for NULL param */ + ber_free ( ber, 1 ); /* ber_free() checks for NULL param */ ber_bvfree ( berval ); /* ber_bvfree() checks for NULL param */ + + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_set_response_control: idx=%d\n", index); +} + +int +pagedresults_free_one( Connection *conn, int index ) +{ + int rc = -1; + + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_free_one: idx=%d\n", index); + if (conn && (index > -1)) { + PR_Lock(conn->c_mutex); + if (conn->c_pagedresults.prl_count <= 0) { + LDAPDebug2Args(LDAP_DEBUG_TRACE, "pagedresults_free_one: " + "conn=%d paged requests list count is %d\n", + conn->c_connid, conn->c_pagedresults.prl_count); + } else if (index < conn->c_pagedresults.prl_maxlen) { + memset(&conn->c_pagedresults.prl_list[index], + '\0', sizeof(PagedResults)); + conn->c_pagedresults.prl_count--; + rc = 0; + } + PR_Unlock(conn->c_mutex); + } + + LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_free_one: %d\n", rc); + return rc; +} + +int +pagedresults_free_one_msgid( Connection *conn, ber_int_t msgid ) +{ + int rc = -1; + int i; + + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_free_one: idx=%d\n", index); + if (conn && (index > -1)) { + PR_Lock(conn->c_mutex); + if (conn->c_pagedresults.prl_count <= 0) { + LDAPDebug2Args(LDAP_DEBUG_TRACE, "pagedresults_free_one_msgid: " + "conn=%d paged requests list count is %d\n", + conn->c_connid, conn->c_pagedresults.prl_count); + } else { + for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) { + if (conn->c_pagedresults.prl_list[i].pr_msgid == msgid) { + memset(&conn->c_pagedresults.prl_list[i], + '\0', sizeof(PagedResults)); + conn->c_pagedresults.prl_count--; + rc = 0; + break; + } + } + } + PR_Unlock(conn->c_mutex); + } + + LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_free_one: %d\n", rc); + return rc; } /* setters and getters for the connection */ Slapi_Backend * -pagedresults_get_current_be(Connection *conn) +pagedresults_get_current_be(Connection *conn, int index) { Slapi_Backend *be = NULL; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_get_current_be: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - be = conn->c_current_be; + if (index < conn->c_pagedresults.prl_maxlen) { + be = conn->c_pagedresults.prl_list[index].pr_current_be; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_get_current_be: %p\n", be); return be; } int -pagedresults_set_current_be(Connection *conn, Slapi_Backend *be) +pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index) { int rc = -1; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_set_current_be: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - conn->c_current_be = be; + if (index < conn->c_pagedresults.prl_maxlen) { + conn->c_pagedresults.prl_list[index].pr_current_be = be; + } PR_Unlock(conn->c_mutex); rc = 0; } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_set_current_be: %d\n", rc); return rc; } void * -pagedresults_get_search_result(Connection *conn) +pagedresults_get_search_result(Connection *conn, int index) { void *sr = NULL; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_get_search_result: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - sr = conn->c_search_result_set; + if (index < conn->c_pagedresults.prl_maxlen) { + sr = conn->c_pagedresults.prl_list[index].pr_search_result_set; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_get_search_result: %p\n", sr); return sr; } int -pagedresults_set_search_result(Connection *conn, void *sr, int locked) +pagedresults_set_search_result(Connection *conn, void *sr, + int locked, int index) { int rc = -1; - if (conn) { + LDAPDebug2Args(LDAP_DEBUG_TRACE, + "--> pagedresults_set_search_result: idx=%d, sr=%p\n", + index, sr); + if (conn && (index > -1)) { if (!locked) PR_Lock(conn->c_mutex); - conn->c_search_result_set = sr; + if (index < conn->c_pagedresults.prl_maxlen) { + conn->c_pagedresults.prl_list[index].pr_search_result_set = sr; + } if (!locked) PR_Unlock(conn->c_mutex); rc = 0; } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_set_search_result: %d\n", rc); return rc; } int -pagedresults_get_search_result_count(Connection *conn) +pagedresults_get_search_result_count(Connection *conn, int index) { int count = 0; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_get_search_result_count: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - count = conn->c_search_result_count; + if (index < conn->c_pagedresults.prl_maxlen) { + count = conn->c_pagedresults.prl_list[index].pr_search_result_count; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_get_search_result_count: %d\n", count); return count; } int -pagedresults_set_search_result_count(Connection *conn, int count) +pagedresults_set_search_result_count(Connection *conn, int count, int index) { int rc = -1; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_set_search_result_count: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - conn->c_search_result_count = count; + if (index < conn->c_pagedresults.prl_maxlen) { + conn->c_pagedresults.prl_list[index].pr_search_result_count = count; + } PR_Unlock(conn->c_mutex); rc = 0; } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_set_search_result_count: %d\n", rc); return rc; } int -pagedresults_get_search_result_set_size_estimate(Connection *conn) +pagedresults_get_search_result_set_size_estimate(Connection *conn, int index) { int count = 0; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_get_search_result_set_size_estimate: " + "idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - count = conn->c_search_result_set_size_estimate; + if (index < conn->c_pagedresults.prl_maxlen) { + count = conn->c_pagedresults.prl_list[index].pr_search_result_set_size_estimate; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_get_search_result_set_size_estimate: %d\n", + count); return count; } int -pagedresults_set_search_result_set_size_estimate(Connection *conn, int count) +pagedresults_set_search_result_set_size_estimate(Connection *conn, + int count, int index) { int rc = -1; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_set_search_result_set_size_estimate: " + "idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - conn->c_search_result_set_size_estimate = count; + if (index < conn->c_pagedresults.prl_maxlen) { + conn->c_pagedresults.prl_list[index].pr_search_result_set_size_estimate = count; + } PR_Unlock(conn->c_mutex); rc = 0; } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_set_search_result_set_size_estimate: %d\n", + rc); return rc; } int -pagedresults_get_with_sort(Connection *conn) +pagedresults_get_with_sort(Connection *conn, int index) { int flags = 0; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_get_with_sort: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - flags = conn->c_flags&CONN_FLAG_PAGEDRESULTS_WITH_SORT; + if (index < conn->c_pagedresults.prl_maxlen) { + flags = conn->c_pagedresults.prl_list[index].pr_flags&CONN_FLAG_PAGEDRESULTS_WITH_SORT; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_get_with_sort: %p\n", flags); return flags; } int -pagedresults_set_with_sort(Connection *conn, int flags) +pagedresults_set_with_sort(Connection *conn, int flags, int index) { int rc = -1; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_set_with_sort: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - if (flags & OP_FLAG_SERVER_SIDE_SORTING) - conn->c_flags |= CONN_FLAG_PAGEDRESULTS_WITH_SORT; + if (index < conn->c_pagedresults.prl_maxlen) { + if (flags & OP_FLAG_SERVER_SIDE_SORTING) { + conn->c_pagedresults.prl_list[index].pr_flags |= + CONN_FLAG_PAGEDRESULTS_WITH_SORT; + } + } PR_Unlock(conn->c_mutex); rc = 0; } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_set_with_sort: %d\n", rc); return rc; } int -pagedresults_get_unindexed(Connection *conn) +pagedresults_get_unindexed(Connection *conn, int index) { int flags = 0; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_get_unindexed: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - flags = conn->c_flags&CONN_FLAG_PAGEDRESULTS_UNINDEXED; + if (index < conn->c_pagedresults.prl_maxlen) { + flags = conn->c_pagedresults.prl_list[index].pr_flags&CONN_FLAG_PAGEDRESULTS_UNINDEXED; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_get_unindexed: %p\n", flags); return flags; } int -pagedresults_set_unindexed(Connection *conn) +pagedresults_set_unindexed(Connection *conn, int index) { int rc = -1; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_set_unindexed: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - conn->c_flags |= CONN_FLAG_PAGEDRESULTS_UNINDEXED; + if (index < conn->c_pagedresults.prl_maxlen) { + conn->c_pagedresults.prl_list[index].pr_flags |= + CONN_FLAG_PAGEDRESULTS_UNINDEXED; + } PR_Unlock(conn->c_mutex); rc = 0; } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_set_unindexed: %d\n", rc); return rc; } int -pagedresults_get_sort_result_code(Connection *conn) +pagedresults_get_sort_result_code(Connection *conn, int index) { - int code = 0; - if (conn) { + int code = LDAP_OPERATIONS_ERROR; + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_get_sort_result_code: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - code = conn->c_sort_result_code; + if (index < conn->c_pagedresults.prl_maxlen) { + code = conn->c_pagedresults.prl_list[index].pr_sort_result_code; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_get_sort_result_code: %d\n", code); return code; } int -pagedresults_set_sort_result_code(Connection *conn, int code) +pagedresults_set_sort_result_code(Connection *conn, int code, int index) { int rc = -1; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_set_sort_result_code: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - conn->c_sort_result_code = code; + if (index < conn->c_pagedresults.prl_maxlen) { + conn->c_pagedresults.prl_list[index].pr_sort_result_code = code; + } PR_Unlock(conn->c_mutex); rc = 0; } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_set_sort_result_code: %d\n", rc); return rc; } int -pagedresults_set_timelimit(Connection *conn, time_t timelimit) +pagedresults_set_timelimit(Connection *conn, time_t timelimit, int index) { int rc = -1; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_set_timelimit: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - conn->c_timelimit = timelimit; + if (index < conn->c_pagedresults.prl_maxlen) { + conn->c_pagedresults.prl_list[index].pr_timelimit = timelimit; + } PR_Unlock(conn->c_mutex); rc = 0; } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_set_timelimit: %d\n", rc); return rc; } /* - * must be called with conn->c_mutex held + * pagedresults_cleanup cleans up the pagedresults list; + * it does not free the list. * return values * 0: not a simple paged result connection * 1: simple paged result and successfully abandoned @@ -373,26 +591,76 @@ int pagedresults_cleanup(Connection *conn, int needlock) { int rc = 0; + int i; + PagedResults *prp = NULL; + + LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_cleanup\n"); + + if (NULL == conn) { + LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_cleanup: -\n"); + return 0; + } if (needlock) { PR_Lock(conn->c_mutex); } - if (conn->c_current_be) { - if (conn->c_search_result_set) { - if (conn->c_current_be->be_search_results_release) { - conn->c_current_be->be_search_results_release(&(conn->c_search_result_set)); - } - conn->c_search_result_set = NULL; + for (i = 0; conn->c_pagedresults.prl_list && + i < conn->c_pagedresults.prl_maxlen; i++) { + prp = conn->c_pagedresults.prl_list + i; + if (prp->pr_current_be && prp->pr_search_result_set && + prp->pr_current_be->be_search_results_release) { + prp->pr_current_be->be_search_results_release(&(prp->pr_search_result_set)); + rc = 1; + } + memset(prp, '\0', sizeof(PagedResults)); + } + conn->c_pagedresults.prl_count = 0; + if (needlock) { + PR_Unlock(conn->c_mutex); + } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_cleanup: %d\n", rc); + return rc; +} + +/* + * pagedresults_cleanup_all frees the list. + * return values + * 0: not a simple paged result connection + * 1: simple paged result and successfully abandoned + */ +int +pagedresults_cleanup_all(Connection *conn, int needlock) +{ + int rc = 0; + int i; + PagedResults *prp = NULL; + + LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_cleanup_all\n"); + + if (NULL == conn) { + LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_cleanup_all: -\n"); + return 0; + } + + if (needlock) { + PR_Lock(conn->c_mutex); + } + for (i = 0; conn->c_pagedresults.prl_list && + i < conn->c_pagedresults.prl_maxlen; i++) { + prp = conn->c_pagedresults.prl_list + i; + if (prp->pr_current_be && prp->pr_search_result_set && + prp->pr_current_be->be_search_results_release) { + prp->pr_current_be->be_search_results_release(&(prp->pr_search_result_set)); + rc = 1; } - conn->c_current_be = 0; - rc = 1; } - conn->c_search_result_count = 0; - conn->c_timelimit = 0; - conn->c_flags &= ~CONN_FLAG_PAGEDRESULTS_PROCESSING; + slapi_ch_free((void **)&conn->c_pagedresults.prl_list); + conn->c_pagedresults.prl_maxlen = 0; + conn->c_pagedresults.prl_count = 0; if (needlock) { PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_cleanup_all: %d\n", rc); return rc; } @@ -402,16 +670,24 @@ pagedresults_cleanup(Connection *conn, int needlock) * mark that it is processing, and return False */ int -pagedresults_check_or_set_processing(Connection *conn) +pagedresults_check_or_set_processing(Connection *conn, int index) { int ret = 0; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_check_or_set_processing\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - ret = conn->c_flags&CONN_FLAG_PAGEDRESULTS_PROCESSING; - /* if ret is true, the following doesn't do anything */ - conn->c_flags |= CONN_FLAG_PAGEDRESULTS_PROCESSING; + if (index < conn->c_pagedresults.prl_maxlen) { + ret = (conn->c_pagedresults.prl_list[index].pr_flags & + CONN_FLAG_PAGEDRESULTS_PROCESSING); + /* if ret is true, the following doesn't do anything */ + conn->c_pagedresults.prl_list[index].pr_flags |= + CONN_FLAG_PAGEDRESULTS_PROCESSING; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_check_or_set_processing: %d\n", ret); return ret; } @@ -421,15 +697,109 @@ pagedresults_check_or_set_processing(Connection *conn) * False otherwise */ int -pagedresults_reset_processing(Connection *conn) +pagedresults_reset_processing(Connection *conn, int index) { int ret = 0; - if (conn) { + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "--> pagedresults_reset_processing: idx=%d\n", index); + if (conn && (index > -1)) { PR_Lock(conn->c_mutex); - ret = conn->c_flags&CONN_FLAG_PAGEDRESULTS_PROCESSING; - /* if ret is false, the following doesn't do anything */ - conn->c_flags &= ~CONN_FLAG_PAGEDRESULTS_PROCESSING; + if (index < conn->c_pagedresults.prl_maxlen) { + ret = (conn->c_pagedresults.prl_list[index].pr_flags & + CONN_FLAG_PAGEDRESULTS_PROCESSING); + /* if ret is false, the following doesn't do anything */ + conn->c_pagedresults.prl_list[index].pr_flags &= + ~CONN_FLAG_PAGEDRESULTS_PROCESSING; + } PR_Unlock(conn->c_mutex); } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, + "<-- pagedresults_reset_processing: %d\n", ret); return ret; } + +/* Are all the paged results requests timed out? */ +int +pagedresults_is_timedout(Connection *conn) +{ + int i; + PagedResults *prp = NULL; + time_t ctime; + int rc = 0; + + LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_is_timedout\n"); + + if (NULL == conn || 0 == conn->c_pagedresults.prl_count) { + LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_is_timedout: -\n"); + return rc; + } + + ctime = current_time(); + for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) { + prp = conn->c_pagedresults.prl_list + i; + if (prp->pr_current_be && (prp->pr_timelimit > 0)) { + if (ctime < prp->pr_timelimit) { + LDAPDebug0Args(LDAP_DEBUG_TRACE, + "<-- pagedresults_is_timedout: 0\n"); + return 0; /* at least, one request is not timed out. */ + } else { + rc = 1; /* possibly timed out */ + } + } + } + LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_is_timedout: 1\n"); + return rc; /* all requests are timed out. */ +} + +/* reset all timeout */ +int +pagedresults_reset_timedout(Connection *conn) +{ + int i; + PagedResults *prp = NULL; + + LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_reset_timedout\n"); + if (NULL == conn) { + LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_reset_timedout: -\n"); + return 0; + } + + for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) { + prp = conn->c_pagedresults.prl_list + i; + prp->pr_timelimit = 0; + } + LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_reset_timedout: 0\n"); + return 0; +} + +/* paged results requests are in progress. */ +int +pagedresults_in_use(Connection *conn) +{ + LDAPDebug0Args(LDAP_DEBUG_TRACE, "--> pagedresults_in_use\n"); + if (NULL == conn) { + LDAPDebug0Args(LDAP_DEBUG_TRACE, "<-- pagedresults_in_use: -\n"); + return 0; + } + LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_in_use: %d\n", + conn->c_pagedresults.prl_count); + return conn->c_pagedresults.prl_count; +} + +int +op_is_pagedresults(Operation *op) +{ + if (NULL == op) { + return 0; + } + return op->o_flags & OP_FLAG_PAGED_RESULTS; +} + +void +op_set_pagedresults(Operation *op) +{ + if (NULL == op) { + return; + } + op->o_flags |= OP_FLAG_PAGED_RESULTS; +} diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index 2a1c70643..4b5440397 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -1925,6 +1925,14 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value ) (*(void **)value) = pblock->pb_syntax_filter_data; break; + case SLAPI_PAGED_RESULTS_INDEX: + if (op_is_pagedresults(pblock->pb_op)) { + /* search req is simple paged results */ + (*(int *)value) = pblock->pb_paged_results_index; + } else { + (*(int *)value) = -1; + } + break; default: LDAPDebug( LDAP_DEBUG_ANY, "Unknown parameter block argument %d\n", arg, 0, 0 ); @@ -3459,6 +3467,10 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value ) pblock->pb_syntax_filter_data = (void *)value; break; + case SLAPI_PAGED_RESULTS_INDEX: + pblock->pb_paged_results_index = *(int *)value; + break; + default: LDAPDebug( LDAP_DEBUG_ANY, "Unknown parameter block argument %d\n", arg, 0, 0 ); diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index d7057a1c0..ad665955b 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -1378,26 +1378,40 @@ int slapd_do_all_nss_ssl_init(int slapd_exemode, int importexport_encrypt, /* * pagedresults.c */ -int pagedresults_parse_control_value(struct berval *psbvp, ber_int_t *pagesize, int *curr_search_count); -void pagedresults_set_response_control(Slapi_PBlock *pb, int iscritical, ber_int_t estimate, int curr_search_count); -Slapi_Backend *pagedresults_get_current_be(Connection *conn); -int pagedresults_set_current_be(Connection *conn, Slapi_Backend *be); -void *pagedresults_get_search_result(Connection *conn); -int pagedresults_set_search_result(Connection *conn, void *sr, int locked); -int pagedresults_get_search_result_count(Connection *conn); -int pagedresults_set_search_result_count(Connection *conn, int cnt); -int pagedresults_get_search_result_set_size_estimate(Connection *conn); -int pagedresults_set_search_result_set_size_estimate(Connection *conn, int cnt); -int pagedresults_get_with_sort(Connection *conn); -int pagedresults_set_with_sort(Connection *conn, int flags); -int pagedresults_get_unindexed(Connection *conn); -int pagedresults_set_unindexed(Connection *conn); -int pagedresults_get_sort_result_code(Connection *conn); -int pagedresults_set_sort_result_code(Connection *conn, int code); -int pagedresults_set_timelimit(Connection *conn, time_t timelimit); +int pagedresults_parse_control_value(Slapi_PBlock *pb, struct berval *psbvp, + ber_int_t *pagesize, int *index); +void pagedresults_set_response_control(Slapi_PBlock *pb, int iscritical, + ber_int_t estimate, + int curr_search_count, int index); +Slapi_Backend *pagedresults_get_current_be(Connection *conn, int index); +int pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index); +void *pagedresults_get_search_result(Connection *conn, int index); +int pagedresults_set_search_result(Connection *conn, void *sr, + int locked, int index); +int pagedresults_get_search_result_count(Connection *conn, int index); +int pagedresults_set_search_result_count(Connection *conn, int cnt, int index); +int pagedresults_get_search_result_set_size_estimate(Connection *conn, + int index); +int pagedresults_set_search_result_set_size_estimate(Connection *conn, int cnt, + int index); +int pagedresults_get_with_sort(Connection *conn, int index); +int pagedresults_set_with_sort(Connection *conn, int flags, int index); +int pagedresults_get_unindexed(Connection *conn, int index); +int pagedresults_set_unindexed(Connection *conn, int index); +int pagedresults_get_sort_result_code(Connection *conn, int index); +int pagedresults_set_sort_result_code(Connection *conn, int code, int index); +int pagedresults_set_timelimit(Connection *conn, time_t timelimit, int index); int pagedresults_cleanup(Connection *conn, int needlock); -int pagedresults_check_or_set_processing(Connection *conn); -int pagedresults_reset_processing(Connection *conn); +int pagedresults_check_or_set_processing(Connection *conn, int index); +int pagedresults_reset_processing(Connection *conn, int index); +int pagedresults_is_timedout(Connection *conn); +int pagedresults_reset_timedout(Connection *conn); +int pagedresults_in_use(Connection *conn); +int pagedresults_free_one(Connection *conn, int index); +int op_is_pagedresults(Operation *op); +int pagedresults_cleanup_all(Connection *conn, int needlock); +void op_set_pagedresults(Operation *op); + /* * sort.c diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c index a3fff3814..c84d44ba5 100644 --- a/ldap/servers/slapd/result.c +++ b/ldap/servers/slapd/result.c @@ -1426,8 +1426,7 @@ send_ldap_search_entry_ext( ber = NULL; /* flush_ber will always free the ber */ log_and_return: - if ( logit && operation_is_flag_set(operation, - OP_FLAG_ACTION_LOG_ACCESS)){ + if ( logit && operation_is_flag_set(operation, OP_FLAG_ACTION_LOG_ACCESS)) { log_entry( op, e ); diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 3e63f1187..025f74997 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1351,6 +1351,26 @@ typedef struct op { client (or we tried to do so and failed) */ + +/* simple paged structure */ +typedef struct _paged_results { + Slapi_Backend *pr_current_be; /* backend being used */ + void *pr_search_result_set; /* search result set for paging */ + int pr_search_result_count; /* search result count */ + int pr_search_result_set_size_estimate; /* estimated search result set size */ + int pr_sort_result_code; /* sort result put in response */ + time_t pr_timelimit; /* time limit for this request */ + int pr_flags; + ber_int_t pr_msgid; /* msgid of the request; to abandon */ +} PagedResults; + +/* array of simple paged structure stashed in connection */ +typedef struct _paged_results_list { + int prl_maxlen; /* size of the PagedResults array */ + int prl_count; /* count of the list in use */ + PagedResults *prl_list; /* pointer to pr_maxlen length PageResults array */ +} PagedResultsList; + /* * represents a connection from an ldap client */ @@ -1406,14 +1426,7 @@ typedef struct conn { int c_local_valid; /* flag true if the uid/gid are valid */ uid_t c_local_uid; /* uid of connecting process */ gid_t c_local_gid; /* gid of connecting process */ - /* PAGED_RESULTS */ - Slapi_Backend *c_current_be; /* backend being used */ - void *c_search_result_set; /* search result set for paging */ - int c_search_result_count; /* search result count */ - int c_search_result_set_size_estimate; /* estimated search result set size */ - int c_sort_result_code; /* sort result put in response */ - time_t c_timelimit; /* time limit for this connection */ - /* PAGED_RESULTS ENDS */ + PagedResultsList c_pagedresults; /* PAGED_RESULTS */ /* IO layer push/pop */ Conn_IO_Layer_cb c_push_io_layer_cb; /* callback to push an IO layer on the conn->c_prfd */ Conn_IO_Layer_cb c_pop_io_layer_cb; /* callback to pop an IO layer off of the conn->c_prfd */ @@ -1637,6 +1650,7 @@ typedef struct slapi_pblock { IFP pb_mr_index_sv_fn; /* values and keys are Slapi_Value ** */ int pb_syntax_filter_normalized; /* the syntax filter types/values are already normalized */ void *pb_syntax_filter_data; /* extra data to pass to a syntax plugin function */ + int pb_paged_results_index; /* stash SLAPI_PAGED_RESULTS_INDEX */ } slapi_pblock; /* index if substrlens */ diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index b4eb2a6be..67d7ac9fd 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -6674,6 +6674,9 @@ typedef struct slapi_plugindesc { /* Size of the database, in kilobytes */ #define SLAPI_DBSIZE 199 +/* Simple paged results index */ +#define SLAPI_PAGED_RESULTS_INDEX 1945 + /* convenience macros for checking modify operation types */ #define SLAPI_IS_MOD_ADD(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_ADD) #define SLAPI_IS_MOD_DELETE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_DELETE) diff --git a/ldap/servers/slapd/sort.c b/ldap/servers/slapd/sort.c index b6814b269..903fa6f08 100644 --- a/ldap/servers/slapd/sort.c +++ b/ldap/servers/slapd/sort.c @@ -53,14 +53,17 @@ sort_make_sort_response_control ( Slapi_PBlock *pb, int code, char *error_type) struct berval *bvp = NULL; int rc = -1; ber_int_t control_code; + int pr_idx = -1; + + slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx); if (code == CONN_GET_SORT_RESULT_CODE) { - code = pagedresults_get_sort_result_code(pb->pb_conn); + code = pagedresults_get_sort_result_code(pb->pb_conn, pr_idx); } else { Slapi_Operation *operation; slapi_pblock_get (pb, SLAPI_OPERATION, &operation); - if (operation->o_flags & OP_FLAG_PAGED_RESULTS) { - pagedresults_set_sort_result_code(pb->pb_conn, code); + if (op_is_pagedresults(operation)) { + pagedresults_set_sort_result_code(pb->pb_conn, code, pr_idx); } }
0
9433fc73f04520ce7f309fef6bcc4052146d34fe
389ds/389-ds-base
Bug 630092 - (cov#12068) Resource leak in certmap code The ldapu_propval_list_free() function was freeing the nodes in the list, but not the list itself. We need to free the list itself after all of the nodes have been freed.
commit 9433fc73f04520ce7f309fef6bcc4052146d34fe Author: Nathan Kinder <[email protected]> Date: Fri Sep 17 14:14:53 2010 -0700 Bug 630092 - (cov#12068) Resource leak in certmap code The ldapu_propval_list_free() function was freeing the nodes in the list, but not the list itself. We need to free the list itself after all of the nodes have been freed. diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c index 9c6b2bad2..f3da425ef 100644 --- a/lib/ldaputil/certmap.c +++ b/lib/ldaputil/certmap.c @@ -1472,6 +1472,7 @@ void ldapu_propval_list_free (void *propval_list) { LDAPUPropValList_t *list = (LDAPUPropValList_t *)propval_list; ldapu_list_free(list, ldapu_propval_free); + free(list); } int ldapu_certmap_init (const char *config_file,
0
b43e899454351274065ecf76cdf31ae2a84645bf
389ds/389-ds-base
Ticket 47828: DNA scope: allow to exlude some subtrees Bug Description: DNA plugin generates attributes values to any added entry in the scope of the plugin (and filter). For ULC (http://www.freeipa.org/page/V3/User_Life-Cycle_Management), the provisioning container must be excluded. Fix Description: Add the ability to define multivalued attribute: "dnaExcludeScope" in the config entry. DNA will not generate attributes values for entries added under one of the excluded DIT http://fedorahosted.org/389/ticket/47828ticket URL> Platforms tested: F17/F20 Reviewed by : Noriko (many thanks) Flag Day: no Doc impact: yes (adding a config attribute)
commit b43e899454351274065ecf76cdf31ae2a84645bf Author: Thierry bordaz (tbordaz) <[email protected]> Date: Mon Sep 1 11:30:05 2014 +0200 Ticket 47828: DNA scope: allow to exlude some subtrees Bug Description: DNA plugin generates attributes values to any added entry in the scope of the plugin (and filter). For ULC (http://www.freeipa.org/page/V3/User_Life-Cycle_Management), the provisioning container must be excluded. Fix Description: Add the ability to define multivalued attribute: "dnaExcludeScope" in the config entry. DNA will not generate attributes values for entries added under one of the excluded DIT http://fedorahosted.org/389/ticket/47828ticket URL> Platforms tested: F17/F20 Reviewed by : Noriko (many thanks) Flag Day: no Doc impact: yes (adding a config attribute) diff --git a/dirsrvtests/tickets/ticket47828_test.py b/dirsrvtests/tickets/ticket47828_test.py new file mode 100644 index 000000000..b9fb288e7 --- /dev/null +++ b/dirsrvtests/tickets/ticket47828_test.py @@ -0,0 +1,721 @@ +import os +import sys +import time +import ldap +import logging +import socket +import pytest +import shutil +from lib389 import DirSrv, Entry, tools +from lib389.tools import DirSrvTools +from lib389._constants import * +from lib389.properties import * +from constants import * + +log = logging.getLogger(__name__) + +installation_prefix = None + +ACCT_POLICY_CONFIG_DN = 'cn=config,cn=%s,cn=plugins,cn=config' % PLUGIN_ACCT_POLICY +ACCT_POLICY_DN = 'cn=Account Inactivation Pplicy,%s' % SUFFIX +INACTIVITY_LIMIT = '9' +SEARCHFILTER = '(objectclass=*)' + +DUMMY_CONTAINER = 'cn=dummy container,%s' % SUFFIX +PROVISIONING = 'cn=provisioning,%s' % SUFFIX +ACTIVE_USER1_CN = 'active user1' +ACTIVE_USER1_DN = 'cn=%s,%s' % (ACTIVE_USER1_CN, SUFFIX) +STAGED_USER1_CN = 'staged user1' +STAGED_USER1_DN = 'cn=%s,%s' % (STAGED_USER1_CN, PROVISIONING) +DUMMY_USER1_CN = 'dummy user1' +DUMMY_USER1_DN = 'cn=%s,%s' % (DUMMY_USER1_CN, DUMMY_CONTAINER) + +ALLOCATED_ATTR = 'employeeNumber' + +class TopologyStandalone(object): + def __init__(self, standalone): + standalone.open() + self.standalone = standalone + + [email protected](scope="module") +def topology(request): + ''' + This fixture is used to standalone topology for the 'module'. + At the beginning, It may exists a standalone instance. + It may also exists a backup for the standalone instance. + + Principle: + If standalone instance exists: + restart it + If backup of standalone exists: + create/rebind to standalone + + restore standalone instance from backup + else: + Cleanup everything + remove instance + remove backup + Create instance + Create backup + ''' + global installation_prefix + + if installation_prefix: + args_instance[SER_DEPLOYED_DIR] = installation_prefix + + standalone = DirSrv(verbose=False) + + # Args for the standalone instance + args_instance[SER_HOST] = HOST_STANDALONE + args_instance[SER_PORT] = PORT_STANDALONE + args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE + args_standalone = args_instance.copy() + standalone.allocate(args_standalone) + + # Get the status of the backups + backup_standalone = standalone.checkBackupFS() + + # Get the status of the instance and restart it if it exists + instance_standalone = standalone.exists() + if instance_standalone: + # assuming the instance is already stopped, just wait 5 sec max + standalone.stop(timeout=5) + try: + standalone.start(timeout=10) + except ldap.SERVER_DOWN: + pass + + if backup_standalone: + # The backup exist, assuming it is correct + # we just re-init the instance with it + if not instance_standalone: + standalone.create() + # Used to retrieve configuration information (dbdir, confdir...) + standalone.open() + + # restore standalone instance from backup + standalone.stop(timeout=10) + standalone.restoreFS(backup_standalone) + standalone.start(timeout=10) + + else: + # We should be here only in two conditions + # - This is the first time a test involve standalone instance + # - Something weird happened (instance/backup destroyed) + # so we discard everything and recreate all + + # Remove the backup. So even if we have a specific backup file + # (e.g backup_standalone) we clear backup that an instance may have created + if backup_standalone: + standalone.clearBackupFS() + + # Remove the instance + if instance_standalone: + standalone.delete() + + # Create the instance + standalone.create() + + # Used to retrieve configuration information (dbdir, confdir...) + standalone.open() + + # Time to create the backups + standalone.stop(timeout=10) + standalone.backupfile = standalone.backupFS() + standalone.start(timeout=10) + + # + # Here we have standalone instance up and running + # Either coming from a backup recovery + # or from a fresh (re)init + # Time to return the topology + return TopologyStandalone(standalone) + +def _header(topology, label): + topology.standalone.log.info("\n\n###############################################") + topology.standalone.log.info("#######") + topology.standalone.log.info("####### %s" % label) + topology.standalone.log.info("#######") + topology.standalone.log.info("###############################################") + +def test_ticket47828_init(topology): + """ + Enable DNA + """ + topology.standalone.plugins.enable(name=PLUGIN_DNA) + + topology.standalone.add_s(Entry((PROVISIONING,{'objectclass': "top nscontainer".split(), + 'cn': 'provisioning'}))) + topology.standalone.add_s(Entry((DUMMY_CONTAINER,{'objectclass': "top nscontainer".split(), + 'cn': 'dummy container'}))) + + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) + topology.standalone.add_s(Entry((dn_config, {'objectclass': "top extensibleObject".split(), + 'cn': 'excluded scope', + 'dnaType': ALLOCATED_ATTR, + 'dnaNextValue': str(1000), + 'dnaMaxValue': str(2000), + 'dnaMagicRegen': str(-1), + 'dnaFilter': '(&(objectClass=person)(objectClass=organizationalPerson)(objectClass=inetOrgPerson))', + 'dnaScope': SUFFIX}))) + topology.standalone.restart(timeout=10) + + + +def test_ticket47828_run_0(topology): + """ + NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_1(topology): + """ + NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_2(topology): + """ + NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_3(topology): + """ + NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_4(topology): + ''' + Exclude the provisioning container + ''' + _header(topology, 'Exclude the provisioning container') + + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) + mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', PROVISIONING)] + topology.standalone.modify_s(dn_config, mod) + +def test_ticket47828_run_5(topology): + """ + Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_6(topology): + """ + Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_7(topology): + """ + Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set + """ + _header(topology, 'Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(-1) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_8(topology): + """ + Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_9(topology): + """ + Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': DUMMY_USER1_CN, + 'sn': DUMMY_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(DUMMY_USER1_DN) + +def test_ticket47828_run_10(topology): + """ + Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': DUMMY_USER1_CN, + 'sn': DUMMY_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(DUMMY_USER1_DN) + +def test_ticket47828_run_11(topology): + ''' + Exclude (in addition) the dummy container + ''' + _header(topology, 'Exclude (in addition) the dummy container') + + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) + mod = [(ldap.MOD_ADD, 'dnaExcludeScope', DUMMY_CONTAINER)] + topology.standalone.modify_s(dn_config, mod) + +def test_ticket47828_run_12(topology): + """ + Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_13(topology): + """ + Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_14(topology): + """ + Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set + """ + _header(topology, 'Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(-1) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_15(topology): + """ + Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_16(topology): + """ + Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is not set + """ + _header(topology, 'Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR not is set') + + topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': DUMMY_USER1_CN, + 'sn': DUMMY_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(-1) + topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(DUMMY_USER1_DN) + +def test_ticket47828_run_17(topology): + """ + Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': DUMMY_USER1_CN, + 'sn': DUMMY_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(DUMMY_USER1_DN) + + +def test_ticket47828_run_18(topology): + ''' + Exclude PROVISIONING and a wrong container + ''' + _header(topology, 'Exclude PROVISIONING and a wrong container') + + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) + mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', PROVISIONING)] + topology.standalone.modify_s(dn_config, mod) + try: + mod = [(ldap.MOD_ADD, 'dnaExcludeScope', "invalidDN,%s" % SUFFIX)] + topology.standalone.modify_s(dn_config, mod) + raise ValueError("invalid dnaExcludeScope value (not a DN)") + except ldap.INVALID_SYNTAX: + pass + +def test_ticket47828_run_19(topology): + """ + Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_20(topology): + """ + Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_21(topology): + """ + Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set + """ + _header(topology, 'Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(-1) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_22(topology): + """ + Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_23(topology): + """ + Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': DUMMY_USER1_CN, + 'sn': DUMMY_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(DUMMY_USER1_DN) + +def test_ticket47828_run_24(topology): + """ + Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': DUMMY_USER1_CN, + 'sn': DUMMY_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(DUMMY_USER1_DN) + +def test_ticket47828_run_25(topology): + ''' + Exclude a wrong container + ''' + _header(topology, 'Exclude a wrong container') + + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) + + try: + mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', "invalidDN,%s" % SUFFIX)] + topology.standalone.modify_s(dn_config, mod) + raise ValueError("invalid dnaExcludeScope value (not a DN)") + except ldap.INVALID_SYNTAX: + pass + +def test_ticket47828_run_26(topology): + """ + Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_27(topology): + """ + Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((ACTIVE_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': ACTIVE_USER1_CN, + 'sn': ACTIVE_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(ACTIVE_USER1_DN) + +def test_ticket47828_run_28(topology): + """ + Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set + """ + _header(topology, 'Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(-1) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_29(topology): + """ + Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((STAGED_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': STAGED_USER1_CN, + 'sn': STAGED_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(STAGED_USER1_DN) + +def test_ticket47828_run_30(topology): + """ + Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set + """ + _header(topology, 'Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set') + + topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': DUMMY_USER1_CN, + 'sn': DUMMY_USER1_CN, + ALLOCATED_ATTR: str(-1)}))) + ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) != str(-1) + topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(DUMMY_USER1_DN) + +def test_ticket47828_run_31(topology): + """ + Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic) + """ + _header(topology, 'Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic)') + + topology.standalone.add_s(Entry((DUMMY_USER1_DN, {'objectclass': "top person organizationalPerson inetOrgPerson".split(), + 'cn': DUMMY_USER1_CN, + 'sn': DUMMY_USER1_CN, + ALLOCATED_ATTR: str(20)}))) + ent = topology.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)") + assert ent.hasAttr(ALLOCATED_ATTR) + assert ent.getValue(ALLOCATED_ATTR) == str(20) + topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) + topology.standalone.delete_s(DUMMY_USER1_DN) + +def test_ticket47828_final(topology): + topology.standalone.plugins.disable(name=PLUGIN_DNA) + topology.standalone.stop(timeout=10) + +def run_isolated(): + ''' + run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..) + To run isolated without py.test, you need to + - edit this file and comment '@pytest.fixture' line before 'topology' function. + - set the installation prefix + - run this program + ''' + global installation_prefix + installation_prefix = None + + topo = topology(True) + test_ticket47828_init(topo) + + test_ticket47828_run_0(topo) + test_ticket47828_run_1(topo) + test_ticket47828_run_2(topo) + test_ticket47828_run_3(topo) + test_ticket47828_run_4(topo) + test_ticket47828_run_5(topo) + test_ticket47828_run_6(topo) + test_ticket47828_run_7(topo) + test_ticket47828_run_8(topo) + test_ticket47828_run_9(topo) + test_ticket47828_run_10(topo) + test_ticket47828_run_11(topo) + test_ticket47828_run_12(topo) + test_ticket47828_run_13(topo) + test_ticket47828_run_14(topo) + test_ticket47828_run_15(topo) + test_ticket47828_run_16(topo) + test_ticket47828_run_17(topo) + test_ticket47828_run_18(topo) + test_ticket47828_run_19(topo) + test_ticket47828_run_20(topo) + test_ticket47828_run_21(topo) + test_ticket47828_run_22(topo) + test_ticket47828_run_23(topo) + test_ticket47828_run_24(topo) + test_ticket47828_run_25(topo) + test_ticket47828_run_26(topo) + test_ticket47828_run_27(topo) + test_ticket47828_run_28(topo) + test_ticket47828_run_29(topo) + test_ticket47828_run_30(topo) + test_ticket47828_run_31(topo) + + test_ticket47828_final(topo) + + +if __name__ == '__main__': + run_isolated() diff --git a/ldap/schema/10dna-plugin.ldif b/ldap/schema/10dna-plugin.ldif index 74f5f8b87..314390466 100644 --- a/ldap/schema/10dna-plugin.ldif +++ b/ldap/schema/10dna-plugin.ldif @@ -202,6 +202,13 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2160 NAME 'dnaRemoteBindMethod' # ################################################################################ # +attributeTypes: ( 2.16.840.1.113730.3.1.2312 NAME 'dnaExcludeScope' + DESC 'DN of a subtree excluded from DNA plugin scope' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 + X-ORIGIN '389 Directory Server' ) +# +################################################################################ +# objectClasses: ( 2.16.840.1.113730.3.2.324 NAME 'dnaPluginConfig' DESC 'DNA plugin configuration' SUP top @@ -214,6 +221,7 @@ objectClasses: ( 2.16.840.1.113730.3.2.324 NAME 'dnaPluginConfig' dnaMagicRegen $ dnaFilter $ dnaScope $ + dnaExcludeScope $ dnaSharedCfgDN $ dnaThreshold $ dnaNextRange $ diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c index f4a36f015..25123cbbf 100644 --- a/ldap/servers/plugins/dna/dna.c +++ b/ldap/servers/plugins/dna/dna.c @@ -87,6 +87,7 @@ #define DNA_GENERATE "dnaMagicRegen" #define DNA_FILTER "dnaFilter" #define DNA_SCOPE "dnaScope" +#define DNA_EXCLUDE_SCOPE "dnaExcludeScope" #define DNA_REMOTE_BIND_DN "dnaRemoteBindDN" #define DNA_REMOTE_BIND_PW "dnaRemoteBindCred" @@ -164,6 +165,7 @@ struct configEntry { Slapi_Filter *slapi_filter; char *generate; char *scope; + Slapi_DN **excludescope; PRUint64 interval; PRUint64 threshold; char *shared_cfg_base; @@ -356,6 +358,17 @@ dna_config_copy() new_entry->slapi_filter = slapi_filter_dup(config_entry->slapi_filter); new_entry->generate = slapi_ch_strdup(config_entry->generate); new_entry->scope = slapi_ch_strdup(config_entry->scope); + if (config_entry->excludescope == NULL) { + new_entry->excludescope = NULL; + } else { + int i; + + for (i = 0; config_entry->excludescope[i]; i++); + new_entry->excludescope = (Slapi_DN **) slapi_ch_calloc(sizeof (Slapi_DN *), i + 1); + for (i = 0; new_entry->excludescope[i]; i++) { + new_entry->excludescope[i] = slapi_sdn_dup(config_entry->excludescope[i]); + } + } new_entry->shared_cfg_base = slapi_ch_strdup(config_entry->shared_cfg_base); new_entry->shared_cfg_dn = slapi_ch_strdup(config_entry->shared_cfg_dn); new_entry->remote_binddn = slapi_ch_strdup(config_entry->remote_binddn); @@ -906,6 +919,7 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry * e, int apply) int entry_added = 0; int i = 0; int ret = DNA_SUCCESS; + char **plugin_attr_values; slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM, "--> dna_parse_config_entry\n"); @@ -1056,6 +1070,31 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry * e, int apply) slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM, "----------> %s [%s]\n", DNA_SCOPE, entry->scope); + + plugin_attr_values = slapi_entry_attr_get_charray(e, DNA_EXCLUDE_SCOPE); + if (plugin_attr_values) { + int j = 0; + + /* Allocate the array of excluded scopes */ + for (i = 0; plugin_attr_values[i]; i++); + entry->excludescope = (Slapi_DN **) slapi_ch_calloc(sizeof (Slapi_DN *), i + 1); + + /* Copy them in the config at the condition they are valid DN */ + for (i = 0; plugin_attr_values[i]; i++) { + if (slapi_dn_syntax_check(NULL, plugin_attr_values[i], 1) == 1) { + slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM, + "Error: Ignoring invalid DN used as excluded scope: [%s]\n", plugin_attr_values[i]); + slapi_ch_free_string(&plugin_attr_values[i]); + } else { + entry->excludescope[j++] = slapi_sdn_new_dn_passin(plugin_attr_values[i]); + } + } + slapi_ch_free((void**) &plugin_attr_values); + } + for (i = 0; entry->excludescope && entry->excludescope[i]; i++) { + slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM, + "----------> %s[%d] [%s]\n", DNA_EXCLUDE_SCOPE, i, slapi_sdn_get_dn(entry->excludescope[i])); + } /* optional, if not specified set -1 which is converted to the max unsigned * value */ @@ -1381,6 +1420,14 @@ dna_free_config_entry(struct configEntry ** entry) slapi_filter_free(e->slapi_filter, 1); slapi_ch_free_string(&e->generate); slapi_ch_free_string(&e->scope); + if (e->excludescope) { + int i; + + for (i = 0; e->excludescope[i]; i++) { + slapi_sdn_free(&e->excludescope[i]); + } + slapi_ch_free((void **)&e->excludescope); + } slapi_ch_free_string(&e->shared_cfg_base); slapi_ch_free_string(&e->shared_cfg_dn); slapi_ch_free_string(&e->remote_binddn); @@ -3311,6 +3358,13 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr) goto next; } + /* is this entry in an excluded scope? */ + for (i = 0; config_entry->excludescope && config_entry->excludescope[i]; i++) { + if (slapi_dn_issuffix(dn, slapi_sdn_get_dn(config_entry->excludescope[i]))) { + goto next; + } + } + /* does the entry match the filter? */ if (config_entry->slapi_filter) { ret = slapi_vattr_filter_test(pb, e, config_entry->slapi_filter, 0); @@ -3509,7 +3563,14 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods, char **e !slapi_dn_issuffix(dn, config_entry->scope)) { goto next; } - + + /* is this entry in an excluded scope? */ + for (i = 0; config_entry->excludescope && config_entry->excludescope[i]; i++) { + if (slapi_dn_issuffix(dn, slapi_sdn_get_dn(config_entry->excludescope[i]))) { + goto next; + } + } + /* does the entry match the filter? */ if (config_entry->slapi_filter) { ret = slapi_vattr_filter_test(pb, e, @@ -3955,6 +4016,13 @@ static int dna_be_txn_pre_op(Slapi_PBlock *pb, int modtype) goto next; } + /* is this entry in an excluded scope? */ + for (i = 0; config_entry->excludescope && config_entry->excludescope[i]; i++) { + if (slapi_dn_issuffix(dn, slapi_sdn_get_dn(config_entry->excludescope[i]))) { + goto next; + } + } + /* does the entry match the filter? */ if (config_entry->slapi_filter) { if(LDAP_SUCCESS != slapi_vattr_filter_test(pb,e,config_entry->slapi_filter, 0)) @@ -4562,6 +4630,9 @@ void dna_dump_config_entry(struct configEntry * entry) printf("<---- filter ---------> %s\n", entry->filter); printf("<---- prefix ---------> %s\n", entry->prefix); printf("<---- scope ----------> %s\n", entry->scope); + for (i = 0; entry->excludescope && entry->excludescope[i]; i++) { + printf("<---- excluded scope -> %s\n", slapi_sdn_get_dn(entry->excludescope[i])); + } printf("<---- next value -----> %" PRIu64 "\n", entry->nextval); printf("<---- max value ------> %" PRIu64 "\n", entry->maxval); printf("<---- interval -------> %" PRIu64 "\n", entry->interval);
0
14e5422328d8f116916efb4a9e192b8db4686e44
389ds/389-ds-base
Ticket 47451 - Dynamic plugins - fixed thread synchronization Description: Made various fixes and overall improvements to the dynamic plugin feature,and Tthe CI test suite. dirsrvtests/suites/dynamic-plugins/plugin_tests.py dirsrvtests/suites/dynamic-plugins/stress_tests.py dirsrvtests/suites/dynamic-plugins/test_dynamic_plugins.py - Improved/intensified stress test - Improved task monitoring - Added a replication run to the entire test suite - Added tests for "shared config areas": MO & RI plugins ldap/servers/plugins/acctpolicy/acct_config.c ldap/servers/plugins/acctpolicy/acct_init.c ldap/servers/plugins/acctpolicy/acct_plugin.c ldap/servers/plugins/acctpolicy/acct_util.c ldap/servers/plugins/acctpolicy/acctpolicy.h - Added the necessary postop calls to check for config updates ldap/servers/plugins/linkedattrs/fixup_task.c - Fixed logging issue ldap/servers/plugins/memberof/memberof_config.c - Fixed double free/crash ldap/servers/slapd/dse.c - The ADD entry was incorrectly being set to NULL(memory leak) ldap/servers/slapd/plugin.c - Improved thread sychronization/fixed race condition - Fixed memory leak when deleting plugin for the plugin config area ldap/servers/slapd/slapi-plugin.h ldap/servers/slapd/thread_data.c - Revised plugin lock thread data wrappers https://fedorahosted.org/389/ticket/47451 Jenkins: Passed Valgrind: Passed Reviewed by: nhosoi(Thanks!)
commit 14e5422328d8f116916efb4a9e192b8db4686e44 Author: Mark Reynolds <[email protected]> Date: Tue Dec 23 21:40:00 2014 -0500 Ticket 47451 - Dynamic plugins - fixed thread synchronization Description: Made various fixes and overall improvements to the dynamic plugin feature,and Tthe CI test suite. dirsrvtests/suites/dynamic-plugins/plugin_tests.py dirsrvtests/suites/dynamic-plugins/stress_tests.py dirsrvtests/suites/dynamic-plugins/test_dynamic_plugins.py - Improved/intensified stress test - Improved task monitoring - Added a replication run to the entire test suite - Added tests for "shared config areas": MO & RI plugins ldap/servers/plugins/acctpolicy/acct_config.c ldap/servers/plugins/acctpolicy/acct_init.c ldap/servers/plugins/acctpolicy/acct_plugin.c ldap/servers/plugins/acctpolicy/acct_util.c ldap/servers/plugins/acctpolicy/acctpolicy.h - Added the necessary postop calls to check for config updates ldap/servers/plugins/linkedattrs/fixup_task.c - Fixed logging issue ldap/servers/plugins/memberof/memberof_config.c - Fixed double free/crash ldap/servers/slapd/dse.c - The ADD entry was incorrectly being set to NULL(memory leak) ldap/servers/slapd/plugin.c - Improved thread sychronization/fixed race condition - Fixed memory leak when deleting plugin for the plugin config area ldap/servers/slapd/slapi-plugin.h ldap/servers/slapd/thread_data.c - Revised plugin lock thread data wrappers https://fedorahosted.org/389/ticket/47451 Jenkins: Passed Valgrind: Passed Reviewed by: nhosoi(Thanks!) diff --git a/dirsrvtests/suites/dynamic-plugins/plugin_tests.py b/dirsrvtests/suites/dynamic-plugins/plugin_tests.py index fa881450c..e147be5d7 100644 --- a/dirsrvtests/suites/dynamic-plugins/plugin_tests.py +++ b/dirsrvtests/suites/dynamic-plugins/plugin_tests.py @@ -31,6 +31,7 @@ BRANCH2_DN = 'ou=branch2,' + DEFAULT_SUFFIX GROUP_OU = 'ou=groups,' + DEFAULT_SUFFIX PEOPLE_OU = 'ou=people,' + DEFAULT_SUFFIX GROUP_DN = 'cn=group,' + DEFAULT_SUFFIX +CONFIG_AREA = 'nsslapd-pluginConfigArea' ''' Functional tests for each plugin @@ -83,6 +84,35 @@ def test_dependency(inst, plugin): assert False +################################################################################ +# +# Wait for task to complete +# +################################################################################ +def wait_for_task(conn, task_dn): + finished = False + count = 0 + while count < 60: + try: + task_entry = conn.search_s(task_dn, ldap.SCOPE_BASE, 'objectclass=*') + if not task_entry: + log.fatal('wait_for_task: Search failed to find task: ' + task_dn) + assert False + if task_entry[0].hasAttr('nstaskexitcode'): + # task is done + finished = True + break + except ldap.LDAPError, e: + log.fatal('wait_for_task: Search failed: ' + e.message['desc']) + assert False + + time.sleep(1) + count += 1 + if not finished: + log.error('wait_for_task: Task (%s) did not complete!' % task_dn) + assert False + + ################################################################################ # # Test Account Policy Plugin (0) @@ -97,6 +127,7 @@ def test_acctpolicy(inst, args=None): return True CONFIG_DN = 'cn=config,cn=Account Policy Plugin,cn=plugins,cn=config' + log.info('Testing ' + PLUGIN_ACCT_POLICY + '...') ############################################################################ @@ -123,23 +154,12 @@ def test_acctpolicy(inst, args=None): log.error('test_acctpolicy: Failed to add config entry: error ' + e.message['desc']) assert False - # Now set the config entry in the plugin entry - #try: - # inst.modify_s('cn=' + PLUGIN_ACCT_POLICY + ',cn=plugins,cn=config', - # [(ldap.MOD_REPLACE, 'nsslapd-pluginarg0', CONFIG_DN)]) - #except ldap.LDAPError, e: - # log.error('test_acctpolicy: Failed to set config entry in plugin entry: error ' + e.message['desc']) - # assert False - ############################################################################ # Test plugin ############################################################################ - # !!!! acctpolicy does have have a dse callabck to check for live updates - restart plugin for now !!!! - inst.plugins.disable(name=PLUGIN_ACCT_POLICY) - inst.plugins.enable(name=PLUGIN_ACCT_POLICY) - # Add an entry + time.sleep(1) try: inst.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(), 'sn': '1', @@ -154,10 +174,11 @@ def test_acctpolicy(inst, args=None): try: inst.simple_bind_s(USER1_DN, "password") except ldap.LDAPError, e: - log.error('test_acctpolicy:Failed to bind as user1: ' + e.message['desc']) + log.error('test_acctpolicy: Failed to bind as user1: ' + e.message['desc']) assert False # Bind as Root DN + time.sleep(1) try: inst.simple_bind_s(DN_DM, PASSWORD) except ldap.LDAPError, e: @@ -185,14 +206,11 @@ def test_acctpolicy(inst, args=None): log.error('test_acctpolicy: Failed to modify config entry: error ' + e.message['desc']) assert False - # !!!! must restart for now !!!!! - inst.plugins.disable(name=PLUGIN_ACCT_POLICY) - inst.plugins.enable(name=PLUGIN_ACCT_POLICY) - ############################################################################ # Test plugin ############################################################################ + time.sleep(1) # login as user try: inst.simple_bind_s(USER1_DN, "password") @@ -200,6 +218,7 @@ def test_acctpolicy(inst, args=None): log.error('test_acctpolicy: Failed to bind(2nd) as user1: ' + e.message['desc']) assert False + time.sleep(1) # Bind as Root DN try: inst.simple_bind_s(DN_DM, PASSWORD) @@ -498,7 +517,7 @@ def test_automember(inst, args=None): log.error('test_automember: Failed to user3 to branch2: error ' + e.message['desc']) assert False - # Check the group - uniquemember sahould not exist + # Check the group - uniquemember should not exist try: entries = inst.search_s(GROUP_DN, ldap.SCOPE_BASE, '(uniquemember=' + BUSER3_DN + ')') @@ -512,9 +531,10 @@ def test_automember(inst, args=None): # Enable plugin inst.plugins.enable(name=PLUGIN_AUTOMEMBER) + TASK_DN = 'cn=task-' + str(int(time.time())) + ',cn=automember rebuild membership,cn=tasks,cn=config' # Add the task try: - inst.add_s(Entry(('cn=task-' + str(int(time.time())) + ',cn=automember rebuild membership,cn=tasks,cn=config', { + inst.add_s(Entry((TASK_DN, { 'objectclass': 'top extensibleObject'.split(), 'basedn': 'ou=branch2,' + DEFAULT_SUFFIX, 'filter': 'objectclass=top'}))) @@ -522,7 +542,7 @@ def test_automember(inst, args=None): log.error('test_automember: Failed to add task: error ' + e.message['desc']) assert False - time.sleep(3) # Wait for the task to do its work + wait_for_task(inst, TASK_DN) # Verify the fixup task worked try: @@ -722,7 +742,7 @@ def test_dna(inst, args=None): try: inst.delete_s(USER1_DN) except ldap.LDAPError, e: - log.error('test_automember: Failed to delete test entry1: ' + e.message['desc']) + log.error('test_dna: Failed to delete test entry1: ' + e.message['desc']) assert False inst.plugins.disable(name=PLUGIN_DNA) @@ -914,32 +934,11 @@ def test_linkedattrs(inst, args=None): log.fatal('test_linkedattrs: Search for user1 failed: ' + e.message['desc']) assert False - # Verify that the task does not work yet(not until we enable the plugin) - try: - inst.add_s(Entry(('cn=task-' + str(int(time.time())) + ',cn=fixup linked attributes,cn=tasks,cn=config', { - 'objectclass': 'top extensibleObject'.split(), - 'basedn': DEFAULT_SUFFIX, - 'filter': '(objectclass=top)'}))) - except ldap.LDAPError, e: - log.error('test_linkedattrs: Failed to add task: error ' + e.message['desc']) - assert False - - time.sleep(3) # Wait for the task to do, or not do, its work - - # The entry should still not have a manager attribute - try: - entries = inst.search_s(USER2_DN, ldap.SCOPE_BASE, '(manager=*)') - if entries: - log.fatal('test_linkedattrs: user2 incorrectly has a "manager" attr') - assert False - except ldap.LDAPError, e: - log.fatal('test_linkedattrs: Search for user2 failed: ' + e.message['desc']) - assert False - # Enable the plugin and rerun the task entry inst.plugins.enable(name=PLUGIN_LINKED_ATTRS) # Add the task again + TASK_DN = 'cn=task-' + str(int(time.time())) + ',cn=fixup linked attributes,cn=tasks,cn=config' try: inst.add_s(Entry(('cn=task-' + str(int(time.time())) + ',cn=fixup linked attributes,cn=tasks,cn=config', { 'objectclass': 'top extensibleObject'.split(), @@ -949,7 +948,7 @@ def test_linkedattrs(inst, args=None): log.error('test_linkedattrs: Failed to add task: error ' + e.message['desc']) assert False - time.sleep(3) # Wait for the task to do its work + wait_for_task(inst, TASK_DN) # Check if user2 now has a manager attribute now try: @@ -1011,6 +1010,7 @@ def test_memberof(inst, args=None): return PLUGIN_DN = 'cn=' + PLUGIN_MEMBER_OF + ',cn=plugins,cn=config' + SHARED_CONFIG_DN = 'cn=memberOf Config,' + DEFAULT_SUFFIX log.info('Testing ' + PLUGIN_MEMBER_OF + '...') @@ -1048,6 +1048,16 @@ def test_memberof(inst, args=None): log.error('test_memberof: Failed to add group: error ' + e.message['desc']) assert False + try: + inst.add_s(Entry((SHARED_CONFIG_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'memberofgroupattr': 'member', + 'memberofattr': 'memberof' + }))) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to shared config entry: error ' + e.message['desc']) + assert False + # Check if the user now has a "memberOf" attribute try: entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') @@ -1069,7 +1079,7 @@ def test_memberof(inst, args=None): try: entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') if entries: - log.fatal('test_memberof: user1 incorrect has memberOf attr') + log.fatal('test_memberof: user1 incorrectly has memberOf attr') assert False except ldap.LDAPError, e: log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) @@ -1116,51 +1126,169 @@ def test_memberof(inst, args=None): try: entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') if entries: - log.fatal('test_memberof: user1 incorrect has memberOf attr') + log.fatal('test_memberof: user1 incorrectly has memberOf attr') assert False except ldap.LDAPError, e: log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) assert False ############################################################################ - # Test Fixup Task + # Set the shared config entry and test the plugin ############################################################################ - inst.plugins.disable(name=PLUGIN_MEMBER_OF) + # The shared config entry uses "member" - the above test uses "uniquemember" + try: + inst.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, CONFIG_AREA, SHARED_CONFIG_DN)]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to set plugin area: error ' + e.message['desc']) + assert False + + # Delete the test entries then readd them to start with a clean slate + try: + inst.delete_s(USER1_DN) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to delete test entry1: ' + e.message['desc']) + assert False + + try: + inst.delete_s(GROUP_DN) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to delete test group: ' + e.message['desc']) + assert False + + try: + inst.add_s(Entry((USER1_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'uid': 'user1' + }))) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to add user1: error ' + e.message['desc']) + assert False + + try: + inst.add_s(Entry((GROUP_DN, { + 'objectclass': 'top groupOfNames groupOfUniqueNames extensibleObject'.split(), + 'cn': 'group', + 'member': USER1_DN + }))) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to add group: error ' + e.message['desc']) + assert False + + # Test the shared config + # Check if the user now has a "memberOf" attribute + try: + entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') + if not entries: + log.fatal('test_memberof: user1 missing memberOf') + assert False + except ldap.LDAPError, e: + log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) + assert False + + # Remove "member" should remove "memberOf" from the entry + try: + inst.modify_s(GROUP_DN, [(ldap.MOD_DELETE, 'member', None)]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to delete member: error ' + e.message['desc']) + assert False + + # Check that "memberOf" was removed + try: + entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') + if entries: + log.fatal('test_memberof: user1 incorrectly has memberOf attr') + assert False + except ldap.LDAPError, e: + log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) + assert False + + ############################################################################ + # Change the shared config entry to use 'uniquemember' and test the plugin + ############################################################################ + + try: + inst.modify_s(SHARED_CONFIG_DN, [(ldap.MOD_REPLACE, 'memberofgroupattr', 'uniquemember')]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to set shared plugin entry(uniquemember): error ' + + e.message['desc']) + assert False - # Add uniquemember, should not update USER1 try: inst.modify_s(GROUP_DN, [(ldap.MOD_REPLACE, 'uniquemember', USER1_DN)]) except ldap.LDAPError, e: log.error('test_memberof: Failed to add uniquemember: error ' + e.message['desc']) assert False - # Check for "memberOf" + # Check if the user now has a "memberOf" attribute + try: + entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') + if not entries: + log.fatal('test_memberof: user1 missing memberOf') + assert False + except ldap.LDAPError, e: + log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) + assert False + + # Remove "uniquemember" should remove "memberOf" from the entry + try: + inst.modify_s(GROUP_DN, [(ldap.MOD_DELETE, 'uniquemember', None)]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to delete member: error ' + e.message['desc']) + assert False + + # Check that "memberOf" was removed try: entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') if entries: - log.fatal('test_memberof: user1 incorrect has memberOf attr') + log.fatal('test_memberof: user1 incorrectly has memberOf attr') assert False except ldap.LDAPError, e: log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) assert False - # Run fixup task while plugin disabled - should not add "memberOf - # Verify that the task does not work yet(not until we enable the plugin) + ############################################################################ + # Remove shared config from plugin, and retest + ############################################################################ + + # First change the plugin to use member before we move the shared config that uses uniquemember try: - inst.add_s(Entry(('cn=task-' + str(int(time.time())) + ',' + DN_MBO_TASK, { - 'objectclass': 'top extensibleObject'.split(), - 'basedn': DEFAULT_SUFFIX, - 'filter': 'objectclass=top'}))) - except ldap.NO_SUCH_OBJECT: - pass + inst.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'memberofgroupattr', 'member')]) except ldap.LDAPError, e: - log.error('test_memberof: Failed to add task: error ' + e.message['desc']) + log.error('test_memberof: Failed to update config(uniquemember): error ' + e.message['desc']) assert False - time.sleep(3) # Wait for the task to do, or not do, its work + # Remove shared config from plugin + try: + inst.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, CONFIG_AREA, None)]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to add uniquemember: error ' + e.message['desc']) + assert False - # Check for "memberOf" + try: + inst.modify_s(GROUP_DN, [(ldap.MOD_REPLACE, 'member', USER1_DN)]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to add uniquemember: error ' + e.message['desc']) + assert False + + # Check if the user now has a "memberOf" attribute + try: + entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') + if not entries: + log.fatal('test_memberof: user1 missing memberOf') + assert False + except ldap.LDAPError, e: + log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) + assert False + + # Remove "uniquemember" should remove "memberOf" from the entry + try: + inst.modify_s(GROUP_DN, [(ldap.MOD_DELETE, 'member', None)]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to delete member: error ' + e.message['desc']) + assert False + + # Check that "memberOf" was removed try: entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') if entries: @@ -1170,11 +1298,42 @@ def test_memberof(inst, args=None): log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) assert False + ############################################################################ + # Test Fixup Task + ############################################################################ + + inst.plugins.disable(name=PLUGIN_MEMBER_OF) + + # First change the plugin to use uniquemember + try: + inst.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'memberofgroupattr', 'uniquemember')]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to update config(uniquemember): error ' + e.message['desc']) + assert False + + # Add uniquemember, should not update USER1 + try: + inst.modify_s(GROUP_DN, [(ldap.MOD_REPLACE, 'uniquemember', USER1_DN)]) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to add uniquemember: error ' + e.message['desc']) + assert False + + # Check for "memberOf" + try: + entries = inst.search_s(USER1_DN, ldap.SCOPE_BASE, '(memberOf=*)') + if entries: + log.fatal('test_memberof: user1 incorrect has memberOf attr') + assert False + except ldap.LDAPError, e: + log.fatal('test_memberof: Search for user1 failed: ' + e.message['desc']) + assert False + # Enable the plugin, and run the task inst.plugins.enable(name=PLUGIN_MEMBER_OF) + TASK_DN = 'cn=task-' + str(int(time.time())) + ',' + DN_MBO_TASK try: - inst.add_s(Entry(('cn=task-' + str(int(time.time())) + ',' + DN_MBO_TASK, { + inst.add_s(Entry((TASK_DN, { 'objectclass': 'top extensibleObject'.split(), 'basedn': DEFAULT_SUFFIX, 'filter': 'objectclass=top'}))) @@ -1182,7 +1341,7 @@ def test_memberof(inst, args=None): log.error('test_memberof: Failed to add task: error ' + e.message['desc']) assert False - time.sleep(3) # Wait for the task to do its work + wait_for_task(inst, TASK_DN) # Check for "memberOf" try: @@ -1216,6 +1375,12 @@ def test_memberof(inst, args=None): log.error('test_memberof: Failed to delete test group: ' + e.message['desc']) assert False + try: + inst.delete_s(SHARED_CONFIG_DN) + except ldap.LDAPError, e: + log.error('test_memberof: Failed to delete shared config entry: ' + e.message['desc']) + assert False + ############################################################################ # Test passed ############################################################################ @@ -1286,9 +1451,6 @@ def test_mep(inst, args=None): log.error('test_mep: Failed to add template entry: error ' + e.message['desc']) assert False - # log.info('geb.....') - # time.sleep(30) - # Add the config entry try: inst.add_s(Entry((CONFIG_DN, { @@ -1456,19 +1618,10 @@ def test_passthru(inst, args=None): # Create second instance passthru_inst = DirSrv(verbose=False) - #if installation1_prefix: - # args_instance[SER_DEPLOYED_DIR] = installation1_prefix - - # Args for the master1 instance - """ - args_instance[SER_HOST] = '127.0.0.1' - args_instance[SER_PORT] = '33333' - args_instance[SER_SERVERID_PROP] = 'passthru' - """ - args_instance[SER_HOST] = 'localhost.localdomain' + # Args for the instance + args_instance[SER_HOST] = LOCALHOST args_instance[SER_PORT] = 33333 args_instance[SER_SERVERID_PROP] = 'passthru' - args_instance[SER_CREATION_SUFFIX] = PASS_SUFFIX1 args_passthru_inst = args_instance.copy() passthru_inst.allocate(args_passthru_inst) @@ -1615,6 +1768,7 @@ def test_referint(inst, args=None): log.info('Testing ' + PLUGIN_REFER_INTEGRITY + '...') PLUGIN_DN = 'cn=' + PLUGIN_REFER_INTEGRITY + ',cn=plugins,cn=config' + SHARED_CONFIG_DN = 'cn=RI Config,' + DEFAULT_SUFFIX ############################################################################ # Configure plugin @@ -1660,6 +1814,28 @@ def test_referint(inst, args=None): log.error('test_referint: Failed to add group: error ' + e.message['desc']) assert False + # Grab the referint log file from the plugin + + try: + entries = inst.search_s(PLUGIN_DN, ldap.SCOPE_BASE, '(objectclass=top)') + REFERINT_LOGFILE = entries[0].getValue('referint-logfile') + except ldap.LDAPError, e: + log.fatal('test_referint: Unable to search plugin entry: ' + e.message['desc']) + assert False + + # Add shared config entry + try: + inst.add_s(Entry((SHARED_CONFIG_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'referint-membership-attr': 'member', + 'referint-update-delay': '0', + 'referint-logfile': REFERINT_LOGFILE, + 'referint-logchanges': '0' + }))) + except ldap.LDAPError, e: + log.error('test_referint: Failed to shared config entry: error ' + e.message['desc']) + assert False + # Delete a user try: inst.delete_s(USER1_DN) @@ -1708,6 +1884,150 @@ def test_referint(inst, args=None): log.fatal('test_referint: Unable to search group: ' + e.message['desc']) assert False + ############################################################################ + # Set the shared config entry and test the plugin + ############################################################################ + + # The shared config entry uses "member" - the above test used "uniquemember" + try: + inst.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, CONFIG_AREA, SHARED_CONFIG_DN)]) + except ldap.LDAPError, e: + log.error('test_referint: Failed to set plugin area: error ' + e.message['desc']) + assert False + + # Delete the group, and readd everything + try: + inst.delete_s(GROUP_DN) + except ldap.LDAPError, e: + log.error('test_referint: Failed to delete group: ' + e.message['desc']) + assert False + + try: + inst.add_s(Entry((USER1_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'uid': 'user1' + }))) + except ldap.LDAPError, e: + log.error('test_referint: Failed to add user1: error ' + e.message['desc']) + assert False + + try: + inst.add_s(Entry((USER2_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'uid': 'user2' + }))) + except ldap.LDAPError, e: + log.error('test_referint: Failed to add user2: error ' + e.message['desc']) + assert False + + try: + inst.add_s(Entry((GROUP_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'cn': 'group', + 'member': USER1_DN, + 'uniquemember': USER2_DN + }))) + except ldap.LDAPError, e: + log.error('test_referint: Failed to add group: error ' + e.message['desc']) + assert False + + # Delete a user + try: + inst.delete_s(USER1_DN) + except ldap.LDAPError, e: + log.error('test_referint: Failed to delete user1: ' + e.message['desc']) + assert False + + # Check for integrity + try: + entry = inst.search_s(GROUP_DN, ldap.SCOPE_BASE, '(member=' + USER1_DN + ')') + if entry: + log.error('test_referint: user1 was not removed from group') + assert False + except ldap.LDAPError, e: + log.fatal('test_referint: Unable to search group: ' + e.message['desc']) + assert False + + ############################################################################ + # Change the shared config entry to use 'uniquemember' and test the plugin + ############################################################################ + + try: + inst.modify_s(SHARED_CONFIG_DN, [(ldap.MOD_REPLACE, 'referint-membership-attr', 'uniquemember')]) + except ldap.LDAPError, e: + log.error('test_referint: Failed to set shared plugin entry(uniquemember): error ' + + e.message['desc']) + assert False + + # Delete a user + try: + inst.delete_s(USER2_DN) + except ldap.LDAPError, e: + log.error('test_referint: Failed to delete user1: ' + e.message['desc']) + assert False + + # Check for integrity + try: + entry = inst.search_s(GROUP_DN, ldap.SCOPE_BASE, '(uniquemember=' + USER2_DN + ')') + if entry: + log.error('test_referint: user2 was not removed from group') + assert False + except ldap.LDAPError, e: + log.fatal('test_referint: Unable to search group: ' + e.message['desc']) + assert False + + ############################################################################ + # Remove shared config from plugin, and retest + ############################################################################ + + # First change the plugin to use member before we move the shared config that uses uniquemember + try: + inst.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'referint-membership-attr', 'member')]) + except ldap.LDAPError, e: + log.error('test_referint: Failed to update config(uniquemember): error ' + e.message['desc']) + assert False + + # Remove shared config from plugin + try: + inst.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, CONFIG_AREA, None)]) + except ldap.LDAPError, e: + log.error('test_referint: Failed to add uniquemember: error ' + e.message['desc']) + assert False + + # Add test user + try: + inst.add_s(Entry((USER1_DN, { + 'objectclass': 'top extensibleObject'.split(), + 'uid': 'user1' + }))) + except ldap.LDAPError, e: + log.error('test_referint: Failed to add user1: error ' + e.message['desc']) + assert False + + # Add user to group + try: + inst.modify_s(GROUP_DN, [(ldap.MOD_REPLACE, 'member', USER1_DN)]) + except ldap.LDAPError, e: + log.error('test_referint: Failed to add uniquemember: error ' + e.message['desc']) + assert False + + # Delete a user + try: + inst.delete_s(USER1_DN) + except ldap.LDAPError, e: + log.error('test_referint: Failed to delete user1: ' + e.message['desc']) + assert False + + # Check for integrity + try: + entry = inst.search_s(GROUP_DN, ldap.SCOPE_BASE, '(member=' + USER1_DN + ')') + if entry: + log.error('test_referint: user1 was not removed from group') + assert False + except ldap.LDAPError, e: + log.fatal('test_referint: Unable to search group: ' + e.message['desc']) + assert False + ############################################################################ # Test plugin dependency ############################################################################ @@ -1721,7 +2041,13 @@ def test_referint(inst, args=None): try: inst.delete_s(GROUP_DN) except ldap.LDAPError, e: - log.error('test_referint: Failed to delete user1: ' + e.message['desc']) + log.error('test_referint: Failed to delete group: ' + e.message['desc']) + assert False + + try: + inst.delete_s(SHARED_CONFIG_DN) + except ldap.LDAPError, e: + log.error('test_referint: Failed to delete shared config entry: ' + e.message['desc']) assert False ############################################################################ @@ -1863,7 +2189,7 @@ def test_rootdn(inst, args=None): 'userpassword': 'password' }))) except ldap.LDAPError, e: - log.error('test_retrocl: Failed to add user1: error ' + e.message['desc']) + log.error('test_rootdn: Failed to add user1: error ' + e.message['desc']) assert False # Set an aci so we can modify the plugin after ew deny the root dn diff --git a/dirsrvtests/suites/dynamic-plugins/stress_tests.py b/dirsrvtests/suites/dynamic-plugins/stress_tests.py index a1f666d49..f1a34b458 100644 --- a/dirsrvtests/suites/dynamic-plugins/stress_tests.py +++ b/dirsrvtests/suites/dynamic-plugins/stress_tests.py @@ -21,6 +21,7 @@ from constants import * log = logging.getLogger(__name__) NUM_USERS = 250 +GROUP_DN = 'cn=stress-group,' + DEFAULT_SUFFIX def openConnection(inst): @@ -58,6 +59,14 @@ def configureMO(inst): assert False +def cleanup(conn): + try: + conn.delete_s(GROUP_DN) + except ldap.LDAPError, e: + log.error('cleanup: failed to delete group (' + GROUP_DN + ') error: ' + e.message['desc']) + assert False + + class DelUsers(threading.Thread): def __init__(self, inst, rdnval): threading.Thread.__init__(self) @@ -97,7 +106,6 @@ class AddUsers(threading.Thread): idx = 0 if self.addToGroup: - GROUP_DN = 'cn=stress-group,' + DEFAULT_SUFFIX try: conn.add_s(Entry((GROUP_DN, {'objectclass': 'top groupOfNames groupOfUniqueNames extensibleObject'.split(), diff --git a/dirsrvtests/suites/dynamic-plugins/test_dynamic_plugins.py b/dirsrvtests/suites/dynamic-plugins/test_dynamic_plugins.py index 3677fd55f..288505b7f 100644 --- a/dirsrvtests/suites/dynamic-plugins/test_dynamic_plugins.py +++ b/dirsrvtests/suites/dynamic-plugins/test_dynamic_plugins.py @@ -31,6 +31,12 @@ class TopologyStandalone(object): self.standalone = standalone +def repl_fail(replica): + # remove replica instance, and assert failure + replica.delete() + assert False + + @pytest.fixture(scope="module") def topology(request): ''' @@ -128,7 +134,10 @@ def test_dynamic_plugins(topology): Test Dynamic Plugins - exercise each plugin and its main features, while changing the configuration without restarting the server. - Need to test: functionality, stability, and stress. + Need to test: functionality, stability, and stress. These tests need to run + with replication disabled, and with replication setup with a + second instance. Then test if replication is working, and we have + same entries on each side. Functionality - Make sure that as configuration changes are made they take effect immediately. Cross plugin interaction (e.g. automember/memberOf) @@ -137,17 +146,21 @@ def test_dynamic_plugins(topology): Memory Corruption - Restart the plugins many times, and in different orders and test functionality, and stability. This will excerise the internal - plugin linked lists, dse callabcks, and task handlers. + plugin linked lists, dse callbacks, and task handlers. - Stress - Put the server under some type of load that is using a particular - plugin for each operation, and then make changes to that plugin. - The new changes should take effect, and the server should not crash. + Stress - Put the server under load that will trigger multiple plugins(MO, RI, DNA, etc) + Restart various plugins while these operations are going on. Perform this test + 5 times(stress_max_run). """ - ############################################################################ - # Test plugin functionality - ############################################################################ + REPLICA_PORT = 33334 + RUV_FILTER = '(&(nsuniqueid=ffffffff-ffffffff-ffffffff-ffffffff)(objectclass=nstombstone))' + master_maxcsn = 0 + replica_maxcsn = 0 + msg = ' (no replication)' + replication_run = False + stress_max_runs = 5 # First enable dynamic plugins try: @@ -156,132 +169,337 @@ def test_dynamic_plugins(topology): ldap.error('Failed to enable dynamic plugin!' + e.message['desc']) assert False - log.info('#####################################################') - log.info('Testing Dynamic Plugins Functionality...') - log.info('#####################################################\n') - - plugin_tests.test_all_plugins(topology.standalone) - - log.info('#####################################################') - log.info('Successfully Tested Dynamic Plugins Functionality.') - log.info('#####################################################\n') - - ############################################################################ - # Test the stability by exercising the internal lists, callabcks, and task handlers - ############################################################################ - - log.info('#####################################################') - log.info('Testing Dynamic Plugins for Memory Corruption...') - log.info('#####################################################\n') - prev_plugin_test = None - prev_prev_plugin_test = None - for plugin_test in plugin_tests.func_tests: + while 1: # - # Restart the plugin several times (and prev plugins) - work that linked list + # First run the tests with replication disabled, then rerun them with replication set up # - plugin_test(topology.standalone, "restart") - if prev_prev_plugin_test: - prev_prev_plugin_test(topology.standalone, "restart") + ############################################################################ + # Test plugin functionality + ############################################################################ + + log.info('####################################################################') + log.info('Testing Dynamic Plugins Functionality' + msg + '...') + log.info('####################################################################\n') + + plugin_tests.test_all_plugins(topology.standalone) + + log.info('####################################################################') + log.info('Successfully Tested Dynamic Plugins Functionality' + msg + '.') + log.info('####################################################################\n') + + ############################################################################ + # Test the stability by exercising the internal lists, callabcks, and task handlers + ############################################################################ + + log.info('####################################################################') + log.info('Testing Dynamic Plugins for Memory Corruption' + msg + '...') + log.info('####################################################################\n') + prev_plugin_test = None + prev_prev_plugin_test = None + + for plugin_test in plugin_tests.func_tests: + # + # Restart the plugin several times (and prev plugins) - work that linked list + # + plugin_test(topology.standalone, "restart") + + if prev_prev_plugin_test: + prev_prev_plugin_test(topology.standalone, "restart") + + plugin_test(topology.standalone, "restart") + + if prev_plugin_test: + prev_plugin_test(topology.standalone, "restart") + + plugin_test(topology.standalone, "restart") + + # Now run the functional test + plugin_test(topology.standalone) + + # Set the previous tests + if prev_plugin_test: + prev_prev_plugin_test = prev_plugin_test + prev_plugin_test = plugin_test + + log.info('####################################################################') + log.info('Successfully Tested Dynamic Plugins for Memory Corruption' + msg + '.') + log.info('####################################################################\n') + + ############################################################################ + # Stress two plugins while restarting it, and while restarting other plugins. + # The goal is to not crash, and have the plugins work after stressing them. + ############################################################################ + + log.info('####################################################################') + log.info('Stressing Dynamic Plugins' + msg + '...') + log.info('####################################################################\n') + + stress_tests.configureMO(topology.standalone) + stress_tests.configureRI(topology.standalone) + + stress_count = 0 + while stress_count < stress_max_runs: + log.info('####################################################################') + log.info('Running stress test' + msg + '. Run (%d/%d)...' % (stress_count + 1, stress_max_runs)) + log.info('####################################################################\n') + + try: + # Launch three new threads to add a bunch of users + add_users = stress_tests.AddUsers(topology.standalone, 'employee', True) + add_users.start() + add_users2 = stress_tests.AddUsers(topology.standalone, 'entry', True) + add_users2.start() + add_users3 = stress_tests.AddUsers(topology.standalone, 'person', True) + add_users3.start() + time.sleep(1) + + # While we are adding users restart the MO plugin and an idle plugin + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + time.sleep(1) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + time.sleep(1) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.disable(name=PLUGIN_LINKED_ATTRS) + topology.standalone.plugins.enable(name=PLUGIN_LINKED_ATTRS) + time.sleep(1) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + time.sleep(2) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + time.sleep(1) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.disable(name=PLUGIN_LINKED_ATTRS) + topology.standalone.plugins.enable(name=PLUGIN_LINKED_ATTRS) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + time.sleep(1) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + + # Wait for the 'adding' threads to complete + add_users.join() + add_users2.join() + add_users3.join() + + # Now launch three threads to delete the users + del_users = stress_tests.DelUsers(topology.standalone, 'employee') + del_users.start() + del_users2 = stress_tests.DelUsers(topology.standalone, 'entry') + del_users2.start() + del_users3 = stress_tests.DelUsers(topology.standalone, 'person') + del_users3.start() + time.sleep(1) + + # Restart both the MO, RI plugins during these deletes, and an idle plugin + topology.standalone.plugins.disable(name=PLUGIN_REFER_INTEGRITY) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.enable(name=PLUGIN_REFER_INTEGRITY) + time.sleep(1) + topology.standalone.plugins.disable(name=PLUGIN_REFER_INTEGRITY) + time.sleep(1) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + time.sleep(1) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + time.sleep(1) + topology.standalone.plugins.enable(name=PLUGIN_REFER_INTEGRITY) + topology.standalone.plugins.disable(name=PLUGIN_LINKED_ATTRS) + topology.standalone.plugins.enable(name=PLUGIN_LINKED_ATTRS) + topology.standalone.plugins.disable(name=PLUGIN_REFER_INTEGRITY) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + topology.standalone.plugins.enable(name=PLUGIN_REFER_INTEGRITY) + time.sleep(2) + topology.standalone.plugins.disable(name=PLUGIN_REFER_INTEGRITY) + time.sleep(1) + topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) + time.sleep(1) + topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) + time.sleep(1) + topology.standalone.plugins.enable(name=PLUGIN_REFER_INTEGRITY) + topology.standalone.plugins.disable(name=PLUGIN_LINKED_ATTRS) + topology.standalone.plugins.enable(name=PLUGIN_LINKED_ATTRS) + + # Wait for the 'deleting' threads to complete + del_users.join() + del_users2.join() + del_users3.join() + + # Now make sure both the MO and RI plugins still work correctly + plugin_tests.func_tests[8](topology.standalone) # RI plugin + plugin_tests.func_tests[5](topology.standalone) # MO plugin + + # Cleanup the stress tests + stress_tests.cleanup(topology.standalone) + + except: + log.info('Stress test failed!') + repl_fail(replica_inst) + + stress_count += 1 + log.info('####################################################################') + log.info('Successfully Stressed Dynamic Plugins' + msg + + '. Completed (%d/%d)' % (stress_count, stress_max_runs)) + log.info('####################################################################\n') + + if replication_run: + # We're done. + break + else: + # + # Enable replication and run everything one more time + # + log.info('Setting up replication, and rerunning the tests...\n') + + # Create replica instance + replica_inst = DirSrv(verbose=False) + args_instance[SER_HOST] = LOCALHOST + args_instance[SER_PORT] = REPLICA_PORT + args_instance[SER_SERVERID_PROP] = 'replica' + args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX + + args_replica_inst = args_instance.copy() + replica_inst.allocate(args_replica_inst) + replica_inst.create() + replica_inst.open() + + try: + topology.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, + role=REPLICAROLE_MASTER, + replicaId=1) + replica_inst.replica.enableReplication(suffix=DEFAULT_SUFFIX, + role=REPLICAROLE_CONSUMER, + replicaId=65535) + properties = {RA_NAME: r'to_replica', + RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], + RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], + RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], + RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]} + + repl_agreement = topology.standalone.agreement.create(suffix=DEFAULT_SUFFIX, + host=LOCALHOST, + port=REPLICA_PORT, + properties=properties) + + if not repl_agreement: + log.fatal("Fail to create a replica agreement") + repl_fail(replica_inst) + + topology.standalone.agreement.init(DEFAULT_SUFFIX, LOCALHOST, REPLICA_PORT) + topology.standalone.waitForReplInit(repl_agreement) + except: + log.info('Failed to setup replication!') + repl_fail(replica_inst) + + replication_run = True + msg = ' (replication enabled)' + time.sleep(1) - plugin_test(topology.standalone, "restart") + ############################################################################ + # Check replication, and data are in sync, and remove the instance + ############################################################################ - if prev_plugin_test: - prev_plugin_test(topology.standalone, "restart") + log.info('Checking if replication is in sync...') - plugin_test(topology.standalone, "restart") + try: + # Grab master's max CSN + entry = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, RUV_FILTER) + if not entry: + log.error('Failed to find db tombstone entry from master') + repl_fail(replica_inst) + elements = entry[0].getValues('nsds50ruv') + for ruv in elements: + if 'replica 1' in ruv: + parts = ruv.split() + if len(parts) == 5: + master_maxcsn = parts[4] + break + else: + log.error('RUV is incomplete') + repl_fail(replica_inst) + if master_maxcsn == 0: + log.error('Failed to find maxcsn on master') + repl_fail(replica_inst) - # Now run the functional test - plugin_test(topology.standalone) + except ldap.LDAPError, e: + log.fatal('Unable to search masterfor db tombstone: ' + e.message['desc']) + repl_fail(replica_inst) + + # Loop on the consumer - waiting for it to catch up + count = 0 + insync = False + while count < 10: + try: + # Grab master's max CSN + entry = replica_inst.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, RUV_FILTER) + if not entry: + log.error('Failed to find db tombstone entry on consumer') + repl_fail(replica_inst) + elements = entry[0].getValues('nsds50ruv') + for ruv in elements: + if 'replica 1' in ruv: + parts = ruv.split() + if len(parts) == 5: + replica_maxcsn = parts[4] + break + if replica_maxcsn == 0: + log.error('Failed to find maxcsn on consumer') + repl_fail(replica_inst) + except ldap.LDAPError, e: + log.fatal('Unable to search for db tombstone on consumer: ' + e.message['desc']) + repl_fail(replica_inst) + + if master_maxcsn == replica_maxcsn: + insync = True + log.info('Replication is in sync.\n') + break + count += 1 + time.sleep(1) + + # Report on replication status + if not insync: + log.error('Consumer not in sync with master!') + repl_fail(replica_inst) - # Set the previous tests - if prev_plugin_test: - prev_prev_plugin_test = prev_plugin_test - prev_plugin_test = plugin_test + # + # Verify the databases are identical. There should not be any "user, entry, employee" entries + # + log.info('Checking if the data is the same between the replicas...') - log.info('#####################################################') - log.info('Successfully Tested Dynamic Plugins for Memory Corruption.') - log.info('#####################################################\n') + # Check the master + try: + entries = topology.standalone.search_s(DEFAULT_SUFFIX, + ldap.SCOPE_SUBTREE, + "(|(uid=person*)(uid=entry*)(uid=employee*))") + if len(entries) > 0: + log.error('Master database has incorrect data set!\n') + repl_fail(replica_inst) + except ldap.LDAPError, e: + log.fatal('Unable to search db on master: ' + e.message['desc']) + repl_fail(replica_inst) - ############################################################################ - # Stress two plugins while restarting it, and while restarting other plugins. - # The goal is to not crash, and have the plugins work after stressing it. - ############################################################################ + # Check the consumer + try: + entries = replica_inst.search_s(DEFAULT_SUFFIX, + ldap.SCOPE_SUBTREE, + "(|(uid=person*)(uid=entry*)(uid=employee*))") + if len(entries) > 0: + log.error('Consumer database in not consistent with master database') + repl_fail(replica_inst) + except ldap.LDAPError, e: + log.fatal('Unable to search db on consumer: ' + e.message['desc']) + repl_fail(replica_inst) - log.info('#####################################################') - log.info('Stressing Dynamic Plugins...') - log.info('#####################################################\n') + log.info('Data is consistent across the replicas.\n') - # Configure the plugins - stress_tests.configureMO(topology.standalone) - stress_tests.configureRI(topology.standalone) - - # Launch three new threads to add a bunch of users - add_users = stress_tests.AddUsers(topology.standalone, 'user', True) - add_users.start() - add_users2 = stress_tests.AddUsers(topology.standalone, 'entry', True) - add_users2.start() - add_users3 = stress_tests.AddUsers(topology.standalone, 'person', True) - add_users3.start() - time.sleep(1) - - # While we are adding users restart the MO plugin - topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) - topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) - time.sleep(3) - topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) - time.sleep(1) - topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) - - # Restart idle plugin - topology.standalone.plugins.disable(name=PLUGIN_LINKED_ATTRS) - topology.standalone.plugins.enable(name=PLUGIN_LINKED_ATTRS) - - # Wait for the 'adding' threads to complete - add_users.join() - add_users2.join() - add_users3.join() - - # Now launch three threads to delete the users, and restart both the MO and RI plugins - del_users = stress_tests.DelUsers(topology.standalone, 'user') - del_users.start() - del_users2 = stress_tests.DelUsers(topology.standalone, 'entry') - del_users2.start() - del_users3 = stress_tests.DelUsers(topology.standalone, 'person') - del_users3.start() - time.sleep(1) - - # Restart the both the MO and RI plugins during these deletes - - topology.standalone.plugins.disable(name=PLUGIN_REFER_INTEGRITY) - topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) - topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) - topology.standalone.plugins.enable(name=PLUGIN_REFER_INTEGRITY) - time.sleep(3) - topology.standalone.plugins.disable(name=PLUGIN_REFER_INTEGRITY) - time.sleep(1) - topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) - time.sleep(1) - topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) - time.sleep(1) - topology.standalone.plugins.enable(name=PLUGIN_REFER_INTEGRITY) - - # Restart idle plugin - topology.standalone.plugins.disable(name=PLUGIN_LINKED_ATTRS) - topology.standalone.plugins.enable(name=PLUGIN_LINKED_ATTRS) - - # Wait for the 'deleting' threads to complete - del_users.join() - del_users2.join() - del_users3.join() - - # Now make sure both the MO and RI plugins still work - plugin_tests.func_tests[8](topology.standalone) # RI plugin - plugin_tests.func_tests[5](topology.standalone) # MO plugin + log.info('####################################################################') + log.info('Replication consistency test passed') + log.info('####################################################################\n') - log.info('#####################################################') - log.info('Successfully Stressed Dynamic Plugins.') - log.info('#####################################################\n') + # Remove the replica instance + replica_inst.delete() ############################################################################ # We made it to the end! @@ -291,7 +509,8 @@ def test_dynamic_plugins(topology): log.info('#####################################################') log.info("Dynamic Plugins Testsuite: Completed Successfully!") log.info('#####################################################') - log.info('#####################################################') + log.info('#####################################################\n') + def test_dynamic_plugins_final(topology): topology.standalone.stop(timeout=10) diff --git a/dirsrvtests/tickets/ticket47560_test.py b/dirsrvtests/tickets/ticket47560_test.py index 0b7e43635..af7fdc30c 100644 --- a/dirsrvtests/tickets/ticket47560_test.py +++ b/dirsrvtests/tickets/ticket47560_test.py @@ -146,7 +146,7 @@ def test_ticket47560(topology): Enable or disable mbo plugin depending on 'value' ('on'/'off') """ # enable/disable the mbo plugin - if value != 'on': + if value == 'on': topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) else: topology.standalone.plugins.disable(name=PLUGIN_MEMBER_OF) diff --git a/ldap/servers/plugins/acctpolicy/acct_config.c b/ldap/servers/plugins/acctpolicy/acct_config.c index 25352b18f..d1acf1a7b 100644 --- a/ldap/servers/plugins/acctpolicy/acct_config.c +++ b/ldap/servers/plugins/acctpolicy/acct_config.c @@ -53,9 +53,11 @@ acct_policy_load_config_startup( Slapi_PBlock* pb, void* plugin_id ) { PLUGIN_CONFIG_DN, rc ); return( -1 ); } - + config_wr_lock(); + free_config(); newcfg = get_config(); rc = acct_policy_entry2config( config_entry, newcfg ); + config_unlock(); slapi_entry_free( config_entry ); @@ -85,8 +87,8 @@ acct_policy_entry2config( Slapi_Entry *e, acctPluginCfg *newcfg ) { } else if (!update_is_allowed_attr(newcfg->state_attr_name)) { /* log a warning that this attribute cannot be updated */ slapi_log_error( SLAPI_LOG_FATAL, PLUGIN_NAME, - "The configured state attribute [%s] cannot be updated, accounts will always become inactive.\n", - newcfg->state_attr_name ); + "The configured state attribute [%s] cannot be updated, accounts will always become inactive.\n", + newcfg->state_attr_name ); } newcfg->alt_state_attr_name = get_attr_string_val( e, CFG_ALT_LASTLOGIN_STATE_ATTR ); diff --git a/ldap/servers/plugins/acctpolicy/acct_init.c b/ldap/servers/plugins/acctpolicy/acct_init.c index c4dba2218..0b1af9117 100644 --- a/ldap/servers/plugins/acctpolicy/acct_init.c +++ b/ldap/servers/plugins/acctpolicy/acct_init.c @@ -63,6 +63,47 @@ int acct_postop_init( Slapi_PBlock *pb ); int acct_bind_preop( Slapi_PBlock *pb ); int acct_bind_postop( Slapi_PBlock *pb ); +static void *_PluginID = NULL; +static Slapi_DN *_PluginDN = NULL; +static Slapi_DN *_ConfigAreaDN = NULL; +static Slapi_RWLock *config_rwlock = NULL; + +void +acct_policy_set_plugin_id(void *pluginID) +{ + _PluginID = pluginID; +} + +void * +acct_policy_get_plugin_id() +{ + return _PluginID; +} + +void +acct_policy_set_plugin_sdn(Slapi_DN *pluginDN) +{ + _PluginDN = pluginDN; +} + +Slapi_DN * +acct_policy_get_plugin_sdn() +{ + return _PluginDN; +} + +void +acct_policy_set_config_area(Slapi_DN *sdn) +{ + _ConfigAreaDN = sdn; +} + +Slapi_DN * +acct_policy_get_config_area() +{ + return _ConfigAreaDN; +} + /* Master init function for the account plugin */ @@ -120,14 +161,32 @@ acct_policy_init( Slapi_PBlock *pb ) which is needed to retrieve the plugin configuration */ int -acct_policy_start( Slapi_PBlock *pb ) { +acct_policy_start( Slapi_PBlock *pb ) +{ acctPluginCfg *cfg; void *plugin_id = get_identity(); + Slapi_DN *plugindn = NULL; + char *config_area = NULL; if(slapi_plugin_running(pb)){ return 0; } + slapi_pblock_get(pb, SLAPI_TARGET_SDN, &plugindn); + acct_policy_set_plugin_sdn(slapi_sdn_dup(plugindn)); + + /* Set the alternate config area if one is defined. */ + slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_AREA, &config_area); + if (config_area) { + acct_policy_set_config_area(slapi_sdn_new_normdn_byval(config_area)); + } + + if(config_rwlock == NULL){ + if((config_rwlock = slapi_new_rwlock()) == NULL){ + return( CALLBACK_ERR ); + } + } + /* Load plugin configuration */ if( acct_policy_load_config_startup( pb, plugin_id ) ) { slapi_log_error( SLAPI_LOG_FATAL, PLUGIN_NAME, @@ -151,6 +210,10 @@ acct_policy_close( Slapi_PBlock *pb ) { int rc = 0; + slapi_destroy_rwlock(config_rwlock); + config_rwlock = NULL; + slapi_sdn_free(&_PluginDN); + slapi_sdn_free(&_ConfigAreaDN); free_config(); return rc; @@ -168,8 +231,11 @@ acct_preop_init( Slapi_PBlock *pb ) { return( CALLBACK_ERR ); } - if ( slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_BIND_FN, - (void *) acct_bind_preop ) != 0 ) { + if ( slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_BIND_FN, (void *) acct_bind_preop ) != 0 || + slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN, (void *) acct_add_pre_op) != 0 || + slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN, (void *) acct_mod_pre_op) != 0 || + slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_DELETE_FN, (void *) acct_del_pre_op) != 0) + { slapi_log_error( SLAPI_LOG_FATAL, PRE_PLUGIN_NAME, "Failed to set plugin callback function\n" ); return( CALLBACK_ERR ); @@ -192,8 +258,11 @@ acct_postop_init( Slapi_PBlock *pb ) return( CALLBACK_ERR ); } - if ( slapi_pblock_set( pb, SLAPI_PLUGIN_POST_BIND_FN, - (void *)acct_bind_postop ) != 0 ) { + + if ( slapi_pblock_set( pb, SLAPI_PLUGIN_POST_BIND_FN, (void *)acct_bind_postop ) != 0 || + slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN, (void *) acct_post_op) != 0 || + slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN, (void *) acct_post_op) != 0) + { slapi_log_error( SLAPI_LOG_FATAL, POST_PLUGIN_NAME, "Failed to set plugin callback function\n" ); return( CALLBACK_ERR ); @@ -208,3 +277,23 @@ acct_postop_init( Slapi_PBlock *pb ) return( CALLBACK_OK ); } +/* + * Wrappers for config locking + */ +void +config_rd_lock() +{ + slapi_rwlock_rdlock(config_rwlock); +} + +void +config_wr_lock() +{ + slapi_rwlock_wrlock(config_rwlock); +} + +void +config_unlock() +{ + slapi_rwlock_unlock(config_rwlock); +} diff --git a/ldap/servers/plugins/acctpolicy/acct_plugin.c b/ldap/servers/plugins/acctpolicy/acct_plugin.c index 5719f2734..a61a50c8b 100644 --- a/ldap/servers/plugins/acctpolicy/acct_plugin.c +++ b/ldap/servers/plugins/acctpolicy/acct_plugin.c @@ -27,6 +27,46 @@ Hewlett-Packard Development Company, L.P. #include "slapi-plugin.h" #include "acctpolicy.h" +/* + * acct_policy_dn_is_config() + * + * Checks if dn is a plugin config entry. + */ +static int +acct_policy_dn_is_config(Slapi_DN *sdn) +{ + int ret = 0; + + slapi_log_error(SLAPI_LOG_TRACE, PLUGIN_NAME, + "--> automember_dn_is_config\n"); + + if (sdn == NULL) { + goto bail; + } + + /* If an alternate config area is configured, treat it's child + * entries as config entries. If the alternate config area is + * not configured, treat children of the top-level plug-in + * config entry as our config entries. */ + if (acct_policy_get_config_area()) { + if (slapi_sdn_issuffix(sdn, acct_policy_get_config_area()) && + slapi_sdn_compare(sdn, acct_policy_get_config_area())) { + ret = 1; + } + } else { + if (slapi_sdn_issuffix(sdn, acct_policy_get_plugin_sdn()) && + slapi_sdn_compare(sdn, acct_policy_get_plugin_sdn())) { + ret = 1; + } + } + +bail: + slapi_log_error(SLAPI_LOG_TRACE, PLUGIN_NAME, + "<-- automember_dn_is_config\n"); + + return ret; +} + /* Checks bind entry for last login state and compares current time with last login time plus the limit to decide whether to deny the bind. @@ -39,6 +79,7 @@ acct_inact_limit( Slapi_PBlock *pb, const char *dn, Slapi_Entry *target_entry, a int rc = 0; /* Optimistic default */ acctPluginCfg *cfg; + config_rd_lock(); cfg = get_config(); if( ( lasttimestr = get_attr_string_val( target_entry, cfg->state_attr_name ) ) != NULL ) { @@ -75,6 +116,7 @@ acct_inact_limit( Slapi_PBlock *pb, const char *dn, Slapi_Entry *target_entry, a } done: + config_unlock(); /* Deny bind; the account has exceeded the inactivity limit */ if( rc == 1 ) { slapi_send_ldap_result( pb, LDAP_CONSTRAINT_VIOLATION, NULL, @@ -106,13 +148,14 @@ acct_record_login( const char *dn ) Slapi_PBlock *modpb = NULL; int skip_mod_attrs = 1; /* value doesn't matter as long as not NULL */ + config_rd_lock(); cfg = get_config(); /* if we are not allowed to modify the state attr we're done * this could be intentional, so just return */ if (! update_is_allowed_attr(cfg->always_record_login_attr) ) - return rc; + goto done; plugin_id = get_identity(); @@ -152,6 +195,7 @@ acct_record_login( const char *dn ) } done: + config_unlock(); slapi_pblock_destroy( modpb ); slapi_ch_free_string( &timestr ); @@ -274,6 +318,7 @@ acct_bind_postop( Slapi_PBlock *pb ) goto done; } + config_rd_lock(); cfg = get_config(); tracklogin = cfg->always_record_login; @@ -296,6 +341,7 @@ acct_bind_postop( Slapi_PBlock *pb ) } } } + config_unlock(); if( tracklogin ) { rc = acct_record_login( dn ); @@ -319,3 +365,133 @@ done: return( rc == 0 ? CALLBACK_OK : CALLBACK_ERR ); } + +static int acct_pre_op( Slapi_PBlock *pb, int modop ) +{ + Slapi_DN *sdn = 0; + Slapi_Entry *e = 0; + Slapi_Mods *smods = 0; + LDAPMod **mods; + int free_entry = 0; + char *errstr = NULL; + int ret = SLAPI_PLUGIN_SUCCESS; + + slapi_log_error(SLAPI_LOG_TRACE, PRE_PLUGIN_NAME, "--> acct_pre_op\n"); + + slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn); + + if (acct_policy_dn_is_config(sdn)) { + /* Validate config changes, but don't apply them. + * This allows us to reject invalid config changes + * here at the pre-op stage. Applying the config + * needs to be done at the post-op stage. */ + + if (LDAP_CHANGETYPE_ADD == modop) { + slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e); + + /* If the entry doesn't exist, just bail and + * let the server handle it. */ + if (e == NULL) { + goto bail; + } + } else if (LDAP_CHANGETYPE_MODIFY == modop) { + /* Fetch the entry being modified so we can + * create the resulting entry for validation. */ + if (sdn) { + slapi_search_internal_get_entry(sdn, 0, &e, get_identity()); + free_entry = 1; + } + + /* If the entry doesn't exist, just bail and + * let the server handle it. */ + if (e == NULL) { + goto bail; + } + + /* Grab the mods. */ + slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods); + smods = slapi_mods_new(); + slapi_mods_init_byref(smods, mods); + + /* Apply the mods to create the resulting entry. */ + if (mods && (slapi_entry_apply_mods(e, mods) != LDAP_SUCCESS)) { + /* The mods don't apply cleanly, so we just let this op go + * to let the main server handle it. */ + goto bailmod; + } + } else if (modop == LDAP_CHANGETYPE_DELETE){ + ret = LDAP_UNWILLING_TO_PERFORM; + slapi_log_error(SLAPI_LOG_FATAL, PRE_PLUGIN_NAME, + "acct_pre_op: can not delete plugin config entry [%d]\n", ret); + } else { + errstr = slapi_ch_smprintf("acct_pre_op: invalid op type %d", modop); + ret = LDAP_PARAM_ERROR; + goto bail; + } + } + + bailmod: + /* Clean up smods. */ + if (LDAP_CHANGETYPE_MODIFY == modop) { + slapi_mods_free(&smods); + } + + bail: + if (free_entry && e) + slapi_entry_free(e); + + if (ret) { + slapi_log_error(SLAPI_LOG_PLUGIN, PRE_PLUGIN_NAME, + "acct_pre_op: operation failure [%d]\n", ret); + slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL); + slapi_ch_free((void **)&errstr); + slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret); + ret = SLAPI_PLUGIN_FAILURE; + } + + slapi_log_error(SLAPI_LOG_TRACE, PRE_PLUGIN_NAME, "<-- acct_pre_op\n"); + + return ret; +} + +int +acct_add_pre_op( Slapi_PBlock *pb ) +{ + return acct_pre_op(pb, LDAP_CHANGETYPE_ADD); +} + +int +acct_mod_pre_op( Slapi_PBlock *pb ) +{ + return acct_pre_op(pb, LDAP_CHANGETYPE_MODIFY); +} + +int +acct_del_pre_op( Slapi_PBlock *pb ) +{ + return acct_pre_op(pb, LDAP_CHANGETYPE_DELETE); +} + +int +acct_post_op(Slapi_PBlock *pb) +{ + Slapi_DN *sdn = NULL; + + slapi_log_error(SLAPI_LOG_TRACE, POST_PLUGIN_NAME, + "--> acct_policy_post_op\n"); + + slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn); + if (acct_policy_dn_is_config(sdn)){ + if( acct_policy_load_config_startup( pb, get_identity() ) ) { + slapi_log_error( SLAPI_LOG_FATAL, PLUGIN_NAME, + "acct_policy_start failed to load configuration\n" ); + return( CALLBACK_ERR ); + } + } + + slapi_log_error(SLAPI_LOG_TRACE, POST_PLUGIN_NAME, + "<-- acct_policy_mod_post_op\n"); + + return SLAPI_PLUGIN_SUCCESS; +} + diff --git a/ldap/servers/plugins/acctpolicy/acct_util.c b/ldap/servers/plugins/acctpolicy/acct_util.c index 2e24da2e3..cff017615 100644 --- a/ldap/servers/plugins/acctpolicy/acct_util.c +++ b/ldap/servers/plugins/acctpolicy/acct_util.c @@ -82,7 +82,8 @@ get_attr_string_val( Slapi_Entry* target_entry, char* attr_name ) { */ int get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry, void *plugin_id, - acctPolicy **policy ) { + acctPolicy **policy ) +{ Slapi_DN *sdn = NULL; Slapi_Entry *policy_entry = NULL; Slapi_Attr *attr; @@ -93,8 +94,6 @@ get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry, void *plugin_id, acctPluginCfg *cfg; int rc = 0; - cfg = get_config(); - if( policy == NULL ) { /* Bad parameter */ return( -1 ); @@ -102,19 +101,22 @@ get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry, void *plugin_id, *policy = NULL; + config_rd_lock(); + cfg = get_config(); /* Return success and NULL policy */ policy_dn = get_attr_string_val( target_entry, cfg->spec_attr_name ); if( policy_dn == NULL ) { slapi_log_error( SLAPI_LOG_PLUGIN, PLUGIN_NAME, "\"%s\" is not governed by an account inactivity " "policy subentry\n", slapi_entry_get_ndn( target_entry ) ); - if (cfg->inactivitylimit != ULONG_MAX) { - goto dopolicy; - } + if (cfg->inactivitylimit != ULONG_MAX) { + goto dopolicy; + } slapi_log_error( SLAPI_LOG_PLUGIN, PLUGIN_NAME, "\"%s\" is not governed by an account inactivity " "global policy\n", slapi_entry_get_ndn( target_entry ) ); - return rc; + config_unlock(); + return rc; } sdn = slapi_sdn_new_dn_byref( policy_dn ); @@ -153,7 +155,8 @@ dopolicy: } } done: - slapi_ch_free_string( &policy_dn ); + config_unlock(); + slapi_ch_free_string( &policy_dn ); slapi_entry_free( policy_entry ); return( rc ); } diff --git a/ldap/servers/plugins/acctpolicy/acctpolicy.h b/ldap/servers/plugins/acctpolicy/acctpolicy.h index 2185b95f9..64f37fb7a 100644 --- a/ldap/servers/plugins/acctpolicy/acctpolicy.h +++ b/ldap/servers/plugins/acctpolicy/acctpolicy.h @@ -69,10 +69,9 @@ typedef struct accountpolicy { int get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry, void *plugin_id, acctPolicy **policy ); void free_acctpolicy( acctPolicy **policy ); -int has_attr( Slapi_Entry* target_entry, char* attr_name, - char** val ); +int has_attr( Slapi_Entry* target_entry, char* attr_name, char** val ); char* get_attr_string_val( Slapi_Entry* e, char* attr_name ); -void* get_identity(); +void* get_identity(void); void set_identity(void*); time_t gentimeToEpochtime( char *gentimestr ); char* epochtimeToGentime( time_t epochtime ); @@ -80,6 +79,22 @@ int update_is_allowed_attr (const char *attr); /* acct_config.c */ int acct_policy_load_config_startup( Slapi_PBlock* pb, void* plugin_id ); -acctPluginCfg* get_config(); -void free_config(); +acctPluginCfg* get_config(void); +void free_config(void); + +/* acct_init.c */ +void acct_policy_set_plugin_sdn(Slapi_DN *pluginDN); +Slapi_DN * acct_policy_get_plugin_sdn(void); +void acct_policy_set_config_area(Slapi_DN *sdn); +Slapi_DN * acct_policy_get_config_area(void); +void config_rd_lock(void); +void config_wr_lock(void); +void config_unlock(void); + +/* acc_plugins.c */ +int acct_add_pre_op( Slapi_PBlock *pb ); +int acct_mod_pre_op( Slapi_PBlock *pb ); +int acct_del_pre_op( Slapi_PBlock *pb ); +int acct_post_op( Slapi_PBlock *pb ); + diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c b/ldap/servers/plugins/linkedattrs/fixup_task.c index db3c693f5..f3f5c048a 100644 --- a/ldap/servers/plugins/linkedattrs/fixup_task.c +++ b/ldap/servers/plugins/linkedattrs/fixup_task.c @@ -197,8 +197,8 @@ linked_attrs_fixup_task_thread(void *arg) linked_attrs_unlock(); /* Log finished message. */ - slapi_task_log_notice(task, "Linked attributes fixup task complete.\n"); - slapi_task_log_status(task, "Linked attributes fixup task complete.\n"); + slapi_task_log_notice(task, "Linked attributes fixup task complete."); + slapi_task_log_status(task, "Linked attributes fixup task complete."); slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM, "Linked attributes fixup task complete.\n"); slapi_task_inc_progress(task); diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c index 012e2d055..7fa589744 100644 --- a/ldap/servers/plugins/memberof/memberof_config.c +++ b/ldap/servers/plugins/memberof/memberof_config.c @@ -867,7 +867,6 @@ memberof_shared_config_validate(Slapi_PBlock *pb) } slapi_ch_free_string(&configarea_dn); slapi_sdn_free(&config_sdn); - slapi_entry_free(config_entry); } } } diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c index f0ce255b1..f80178e23 100644 --- a/ldap/servers/slapd/dse.c +++ b/ldap/servers/slapd/dse.c @@ -2426,8 +2426,6 @@ dse_add(Slapi_PBlock *pb) /* JCM There should only be one exit point from this f } } - /* entry has been freed, so make sure no one tries to use it later */ - slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL); slapi_send_ldap_result(pb, returncode, NULL, returntext[0] ? returntext : NULL, 0, NULL ); return dse_add_return(rc, e); } diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c index 5530c7035..b0b18e755 100644 --- a/ldap/servers/slapd/plugin.c +++ b/ldap/servers/slapd/plugin.c @@ -454,10 +454,21 @@ plugin_call_plugins( Slapi_PBlock *pb, int whichfunction ) { /* We stash the pblock plugin pointer to preserve the callers context */ struct slapdplugin *p; + int locked = 0; + + locked = slapi_td_get_plugin_locked(); + if (!locked) { + slapi_rwlock_rdlock(global_rwlock); + } + slapi_pblock_get(pb, SLAPI_PLUGIN, &p); /* Call the operation on the Global Plugins */ rc = plugin_call_list(global_plugin_list[plugin_list_number], whichfunction, pb); slapi_pblock_set(pb, SLAPI_PLUGIN, p); + + if (!locked) { + slapi_rwlock_unlock(global_rwlock); + } } else { @@ -1080,12 +1091,6 @@ plugin_start(Slapi_Entry *entry, char *returntext) int ret = 0; int i = 0; - /* - * Disable registered plugin functions so preops/postops/etc - * dont get called prior to the plugin being started (due to - * plugins performing ops on the DIT) - */ - global_plugin_callbacks_enabled = 0; global_plugins_started = 0; /* Count the plugins so we can allocate memory for the config array */ @@ -1404,6 +1409,7 @@ plugin_free_plugin_dep_config(plugin_dep_config **cfg) } slapi_ch_free_string(&config[index].type); slapi_ch_free_string(&config[index].name); + slapi_ch_free_string(&config[index].config_area); pblock_done(&config[index].pb); index++; } @@ -1909,16 +1915,6 @@ plugin_call_func (struct slapdplugin *list, int operation, Slapi_PBlock *pb, int int rc; int return_value = 0; int count = 0; - int *locked = 0; - - /* - * Take the read lock - */ - slapi_td_get_plugin_locked(&locked); - if(locked == 0){ - slapi_rwlock_rdlock(global_rwlock); - } - for (; list != NULL; list = list->plg_next) { @@ -1998,9 +1994,6 @@ plugin_call_func (struct slapdplugin *list, int operation, Slapi_PBlock *pb, int if(call_one) break; } - if(locked == 0){ - slapi_rwlock_unlock(global_rwlock); - } return( return_value ); } @@ -2323,6 +2316,7 @@ plugin_restart(Slapi_Entry *pentryBefore, Slapi_Entry *pentryAfter) } slapi_rwlock_wrlock(global_rwlock); + slapi_td_set_plugin_locked(); if(plugin_delete(pentryBefore, returntext, 1) == LDAP_SUCCESS){ if(plugin_add(pentryAfter, returntext, 1) == LDAP_SUCCESS){ @@ -2346,6 +2340,7 @@ plugin_restart(Slapi_Entry *pentryBefore, Slapi_Entry *pentryAfter) } slapi_rwlock_unlock(global_rwlock); + slapi_td_set_plugin_unlocked(); return rc; } @@ -2995,12 +2990,11 @@ int plugin_add(Slapi_Entry *entry, char *returntext, int locked) { int rc = LDAP_SUCCESS; - int td_locked = 1; if(!locked){ slapi_rwlock_wrlock(global_rwlock); + slapi_td_set_plugin_locked(); } - slapi_td_set_plugin_locked(&td_locked); if((rc = plugin_setup(entry, 0, 0, 1, returntext)) != LDAP_SUCCESS){ LDAPDebug(LDAP_DEBUG_PLUGIN, "plugin_add: plugin_setup failed for (%s)\n",slapi_entry_get_dn(entry), rc, 0); @@ -3015,9 +3009,8 @@ plugin_add(Slapi_Entry *entry, char *returntext, int locked) done: if(!locked){ slapi_rwlock_unlock(global_rwlock); + slapi_td_set_plugin_unlocked(); } - td_locked = 0; - slapi_td_set_plugin_locked(&td_locked); return rc; } @@ -3372,7 +3365,6 @@ plugin_delete(Slapi_Entry *plugin_entry, char *returntext, int locked) struct slapdplugin *plugin = NULL; const char *plugin_dn = slapi_entry_get_dn_const(plugin_entry); char *value = NULL; - int td_locked = 1; int removed = PLUGIN_BUSY; int type = 0; int rc = LDAP_SUCCESS; @@ -3400,8 +3392,8 @@ plugin_delete(Slapi_Entry *plugin_entry, char *returntext, int locked) removed = PLUGIN_NOT_FOUND; if(!locked){ slapi_rwlock_wrlock(global_rwlock); + slapi_td_set_plugin_locked(); } - slapi_td_set_plugin_locked(&td_locked); rc = plugin_get_type_and_list(value, &type, &plugin_list); if ( rc != 0 ) { @@ -3445,9 +3437,8 @@ plugin_delete(Slapi_Entry *plugin_entry, char *returntext, int locked) unlock: if(!locked){ slapi_rwlock_unlock(global_rwlock); + slapi_td_set_plugin_unlocked(); } - td_locked = 0; - slapi_td_set_plugin_locked(&td_locked); } } diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index cb8aad0ed..a61d954c9 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -5585,8 +5585,10 @@ int slapi_td_dn_init(void); int slapi_td_set_dn(char *dn); void slapi_td_get_dn(char **dn); int slapi_td_plugin_lock_init(void); -int slapi_td_set_plugin_locked(int *value); -void slapi_td_get_plugin_locked(int **value); +int slapi_td_get_plugin_locked(void); +int slapi_td_set_plugin_locked(void); +int slapi_td_set_plugin_unlocked(void); + /* Thread Local Storage Index Types */ #define SLAPI_TD_REQUESTOR_DN 1 diff --git a/ldap/servers/slapd/thread_data.c b/ldap/servers/slapd/thread_data.c index 121e2d84a..4d9bb93b2 100644 --- a/ldap/servers/slapd/thread_data.c +++ b/ldap/servers/slapd/thread_data.c @@ -168,19 +168,38 @@ slapi_td_plugin_lock_init() } int -slapi_td_set_plugin_locked(int *value) +slapi_td_set_plugin_locked() { - if(slapi_td_set_val(SLAPI_TD_PLUGIN_LIST_LOCK, (void *)value) == PR_FAILURE){ + int val = 12345; + + if(slapi_td_set_val(SLAPI_TD_PLUGIN_LIST_LOCK, (void *)&val) == PR_FAILURE){ return PR_FAILURE; } return PR_SUCCESS; } -void -slapi_td_get_plugin_locked(int **value) +int +slapi_td_set_plugin_unlocked() { - slapi_td_get_val(SLAPI_TD_PLUGIN_LIST_LOCK, (void **)value); + if(slapi_td_set_val(SLAPI_TD_PLUGIN_LIST_LOCK, NULL) == PR_FAILURE){ + return PR_FAILURE; + } + + return PR_SUCCESS; +} + +int +slapi_td_get_plugin_locked() +{ + int *value = 0; + + slapi_td_get_val(SLAPI_TD_PLUGIN_LIST_LOCK, (void **)&value); + if(value){ + return 1; + } else{ + return 0; + } } /* requestor dn */
0
88e72423c74848837d01760f53b776d0c6b33064
389ds/389-ds-base
Ticket 48249: sync_repl uuid may be invalid Bug Description: uuid is computed from nsuniqueid of the entry. If the computed uuid contains NULL char, slapi_ch_smprintf("%s") will stop on the it, leaving the rest of the buffer with the value that was on the heap at that time Fix Description: use malloc/memcpy instead of slapi_ch_smprintf https://fedorahosted.org/389/ticket/48249 Reviewed by: Noriko Hosoi (thank you !!) Platforms tested: F22 Flag Day: no Doc impact: no
commit 88e72423c74848837d01760f53b776d0c6b33064 Author: Thierry Bordaz <[email protected]> Date: Fri Aug 14 12:32:31 2015 +0200 Ticket 48249: sync_repl uuid may be invalid Bug Description: uuid is computed from nsuniqueid of the entry. If the computed uuid contains NULL char, slapi_ch_smprintf("%s") will stop on the it, leaving the rest of the buffer with the value that was on the heap at that time Fix Description: use malloc/memcpy instead of slapi_ch_smprintf https://fedorahosted.org/389/ticket/48249 Reviewed by: Noriko Hosoi (thank you !!) Platforms tested: F22 Flag Day: no Doc impact: no diff --git a/ldap/servers/plugins/sync/sync_util.c b/ldap/servers/plugins/sync/sync_util.c index 00dc18262..1dcff91f0 100644 --- a/ldap/servers/plugins/sync/sync_util.c +++ b/ldap/servers/plugins/sync/sync_util.c @@ -107,7 +107,8 @@ sync_nsuniqueid2uuid(const char *nsuniqueid) u[16] = '\0'; - uuid = slapi_ch_smprintf("%s",(char *)u); + uuid = slapi_ch_malloc(sizeof(u)); + memcpy(uuid, u, sizeof(u)); return(uuid); }
0
263e072493ec249ee0176193ee8bcb1b72255720
389ds/389-ds-base
allow empty groups https://bugzilla.redhat.com/show_bug.cgi?id=526141 Resolves: bug 526141 Bug Description: allow empty groups Reviewed by: nhosoi (Thanks!) Fix Description: Change groupOfNames and groupOfUniqueNames to allow empty groups by changing the member/uniqueMember attribute from MUST to MAY. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no
commit 263e072493ec249ee0176193ee8bcb1b72255720 Author: Rich Megginson <[email protected]> Date: Tue Sep 29 20:45:54 2009 -0600 allow empty groups https://bugzilla.redhat.com/show_bug.cgi?id=526141 Resolves: bug 526141 Bug Description: allow empty groups Reviewed by: nhosoi (Thanks!) Fix Description: Change groupOfNames and groupOfUniqueNames to allow empty groups by changing the member/uniqueMember attribute from MUST to MAY. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no diff --git a/ldap/schema/00core.ldif b/ldap/schema/00core.ldif index eb73a8807..b8156d078 100644 --- a/ldap/schema/00core.ldif +++ b/ldap/schema/00core.ldif @@ -644,9 +644,9 @@ objectClasses: ( 2.5.6.14 NAME 'device' objectClasses: ( 2.5.6.9 NAME 'groupOfNames' SUP top STRUCTURAL - MUST ( member $ - cn ) - MAY ( businessCategory $ + MUST ( cn ) + MAY ( member $ + businessCategory $ seeAlso $ owner $ ou $ @@ -659,9 +659,9 @@ objectClasses: ( 2.5.6.9 NAME 'groupOfNames' objectClasses: ( 2.5.6.17 NAME 'groupOfUniqueNames' SUP top STRUCTURAL - MUST ( uniqueMember $ - cn ) - MAY ( businessCategory $ + MUST ( cn ) + MAY ( uniqueMember $ + businessCategory $ seeAlso $ owner $ ou $
0
7a8c70b84807616cfc9814b9fc3768fb2d50cc7a
389ds/389-ds-base
set defaults to build java code, and use java, ant, and perl from PATH for external builds
commit 7a8c70b84807616cfc9814b9fc3768fb2d50cc7a Author: Rich Megginson <[email protected]> Date: Wed Nov 16 03:31:05 2005 +0000 set defaults to build java code, and use java, ant, and perl from PATH for external builds diff --git a/nsconfig.mk b/nsconfig.mk index 301cbab2f..8d0fc22bf 100644 --- a/nsconfig.mk +++ b/nsconfig.mk @@ -75,6 +75,10 @@ else USE_DSGW:=1 USE_JAVATOOLS:=1 USE_SETUPUTIL:=1 + GET_JAVA_FROM_PATH := 1 + GET_ANT_FROM_PATH := 1 + USE_PERL_FROM_PATH := 1 + BUILD_JAVA_CODE := 1 endif include $(BUILD_ROOT)/nsdefs.mk
0
df575d3d65a31237bed4cb89db165ed00c0331a7
389ds/389-ds-base
Bug 644784 - Memory leak in "testbind.c" plugin https://bugzilla.redhat.com/show_bug.cgi?id=644784 Resolves: bug 644784 Bug Description: Memory leak in "testbind.c" plugin Reviewed by: rmeggins (submitted by [email protected]) Branch: master Fix Description: Free the entry Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no
commit df575d3d65a31237bed4cb89db165ed00c0331a7 Author: Rich Megginson <[email protected]> Date: Mon Mar 7 11:24:39 2011 -0700 Bug 644784 - Memory leak in "testbind.c" plugin https://bugzilla.redhat.com/show_bug.cgi?id=644784 Resolves: bug 644784 Bug Description: Memory leak in "testbind.c" plugin Reviewed by: rmeggins (submitted by [email protected]) Branch: master Fix Description: Free the entry Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no diff --git a/ldap/servers/slapd/test-plugins/testbind.c b/ldap/servers/slapd/test-plugins/testbind.c index a065279aa..9e44a3191 100644 --- a/ldap/servers/slapd/test-plugins/testbind.c +++ b/ldap/servers/slapd/test-plugins/testbind.c @@ -216,6 +216,7 @@ test_bind( Slapi_PBlock *pb ) break; } + slapi_entry_free( e ); slapi_send_ldap_result( pb, rc, NULL, NULL, 0, NULL ); return( 1 ); }
0
473436cc27666f88d05a333ad4ca2a82df695295
389ds/389-ds-base
[172824] Link SASL library dynamically i1) For non-RHEL platforms, package cyrus sasl library and the supported plugins. 2) by default, cyrus sasl expects to see the plugins in /usr/lib/sasl2. Instead, tell sasl to search "../../../lib/sasl2" (relative path from ns-slapd) for the plugins.
commit 473436cc27666f88d05a333ad4ca2a82df695295 Author: Noriko Hosoi <[email protected]> Date: Thu Nov 10 22:37:54 2005 +0000 [172824] Link SASL library dynamically i1) For non-RHEL platforms, package cyrus sasl library and the supported plugins. 2) by default, cyrus sasl expects to see the plugins in /usr/lib/sasl2. Instead, tell sasl to search "../../../lib/sasl2" (relative path from ns-slapd) for the plugins. diff --git a/ldap/cm/Makefile b/ldap/cm/Makefile index d752f6a49..a2c432661 100644 --- a/ldap/cm/Makefile +++ b/ldap/cm/Makefile @@ -423,6 +423,14 @@ endif endif endif +# if not Linux, we need package sasl library and supported plugins +ifneq ($(ARCH), Linux) + $(INSTALL) -m 755 $(SASL_LIBPATH)/*.$(DLL_SUFFIX)* $(RELDIR)/lib + -mkdir $(RELDIR)/lib/sasl2 + $(INSTALL) -m 755 $(SASL_LIBPATH)/sasl2/libdigestmd5.$(DLL_SUFFIX)* $(RELDIR)/lib/sasl2 + $(INSTALL) -m 755 $(SASL_LIBPATH)/sasl2/libgssapiv2.$(DLL_SUFFIX)* $(RELDIR)/lib/sasl2 +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_INCDIR)/*.h $(RELDIR)/plugins/slapd/slapi/include diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c index 1267b26cc..640ccbfb1 100644 --- a/ldap/servers/slapd/saslbind.c +++ b/ldap/servers/slapd/saslbind.c @@ -551,7 +551,18 @@ static int ids_sasl_canon_user( return returnvalue; } -static sasl_callback_t ids_sasl_callbacks[5] = +#ifdef CYRUS_SASL +#if !defined(LINUX) +static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path) +{ + static char *pluginpath = "../../../lib/sasl2"; + *path = pluginpath; + return SASL_OK; +} +#endif +#endif + +static sasl_callback_t ids_sasl_callbacks[] = { { SASL_CB_GETOPT, @@ -577,6 +588,19 @@ static sasl_callback_t ids_sasl_callbacks[5] = (IFP) ids_sasl_canon_user, NULL }, +#ifdef CYRUS_SASL + /* On Linux: we use system sasl and plugins are found in the default path + * /usr/lib/sasl2 + * On other platforms: we need to tell cyrus sasl where they are localted. + */ +#if !defined(LINUX) + { + SASL_CB_GETPATH, + (IFP) ids_sasl_getpluginpath, + NULL + }, +#endif +#endif { SASL_CB_LIST_END, (IFP) NULL,
0
ab8ed9a5ebb0d15b55d7525ed1d5dbeebd8c7563
389ds/389-ds-base
Ticket #48339 - Share nsslapd-threadnumber in the case nunc-stans is enabled, as well. Description: When nunc-stans is enabled, instead of getting the thread number from the environment variable MAX_THREADS, use the value of config parameter nsslapd-threadnumber. https://fedorahosted.org/389/ticket/48339 Reviewed by [email protected] (Thank you, Rich!!)
commit ab8ed9a5ebb0d15b55d7525ed1d5dbeebd8c7563 Author: Noriko Hosoi <[email protected]> Date: Thu Nov 5 13:08:56 2015 -0800 Ticket #48339 - Share nsslapd-threadnumber in the case nunc-stans is enabled, as well. Description: When nunc-stans is enabled, instead of getting the thread number from the environment variable MAX_THREADS, use the value of config parameter nsslapd-threadnumber. https://fedorahosted.org/389/ticket/48339 Reviewed by [email protected] (Thank you, Rich!!) diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 82099bc62..90f0523a5 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -1199,10 +1199,7 @@ void slapd_daemon( daemon_ports_t *ports ) #ifdef ENABLE_NUNC_STANS if (enable_nunc_stans && !g_get_shutdown()) { int ii; - PRInt32 maxthreads = 3; - if (getenv("MAX_THREADS")) { - maxthreads = atoi(getenv("MAX_THREADS")); - } + PRInt32 maxthreads = (PRInt32)config_get_threadnumber(); /* Set the nunc-stans thread pool config */ ns_thrpool_config_init(&tp_config);
0
ccc61a3a589a47844a7e6eeb13f87e1351637618
389ds/389-ds-base
Ticket 47752 - Don't add unhashed password mod if we don't have an unhashed value When performing a modify operation to replace the userpassword with a pre-hashed value, the modify code adds a LDAPMod that replaces the "unhashed#user#password" attribute with no values. While this doesn't cause any harm inside DS itself, it is not the correct behavior. We should only add a LDAPMod for the unhashed password if we actually have an unhashed value available. https://fedorahosted.org/389/ticket/47752 Reviewed by [email protected]
commit ccc61a3a589a47844a7e6eeb13f87e1351637618 Author: Nathan Kinder <[email protected]> Date: Mon Mar 17 19:34:45 2014 -0700 Ticket 47752 - Don't add unhashed password mod if we don't have an unhashed value When performing a modify operation to replace the userpassword with a pre-hashed value, the modify code adds a LDAPMod that replaces the "unhashed#user#password" attribute with no values. While this doesn't cause any harm inside DS itself, it is not the correct behavior. We should only add a LDAPMod for the unhashed password if we actually have an unhashed value available. https://fedorahosted.org/389/ticket/47752 Reviewed by [email protected] diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c index 34fc32617..fb0fdde69 100644 --- a/ldap/servers/slapd/modify.c +++ b/ldap/servers/slapd/modify.c @@ -975,10 +975,10 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw) } else { /* add pseudo password attribute */ valuearray_init_bervalarray_unhashed_only(pw_mod->mod_bvalues, &va); - if(va){ + if(va && va[0]){ slapi_mods_add_mod_values(&smods, pw_mod->mod_op, unhashed_pw_attr, va); - valuearray_free(&va); } + valuearray_free(&va); } /* Init new value array for hashed value */
0
2ce7a7334bcb89e47c0f5c544144aec37010a5b9
389ds/389-ds-base
Ticket #47511 - bashisms in 389-ds-base admin scripts Description by mvocu (Thank you): The shell scripts in 389-ds-base/ldap/admin/src/scripts use 'source' to source common scripts; the 'source' keyword is bash-specific (or c-shell, if memory serves). The interpreter is set to /bin/sh, which is not guaranteed to be bash (and at least on Debian 7.1 it is dash). The 'source' keyword can be replaced by '.', which should work. The patch was provided by [email protected] (Thank you, Timo!). https://fedorahosted.org/389/ticket/47511 Reviewed and tested by [email protected].
commit 2ce7a7334bcb89e47c0f5c544144aec37010a5b9 Author: Noriko Hosoi <[email protected]> Date: Mon Aug 10 17:04:25 2015 -0700 Ticket #47511 - bashisms in 389-ds-base admin scripts Description by mvocu (Thank you): The shell scripts in 389-ds-base/ldap/admin/src/scripts use 'source' to source common scripts; the 'source' keyword is bash-specific (or c-shell, if memory serves). The interpreter is set to /bin/sh, which is not guaranteed to be bash (and at least on Debian 7.1 it is dash). The 'source' keyword can be replaced by '.', which should work. The patch was provided by [email protected] (Thank you, Timo!). https://fedorahosted.org/389/ticket/47511 Reviewed and tested by [email protected]. diff --git a/ldap/admin/src/initconfig.in b/ldap/admin/src/initconfig.in index 134e82c9a..7afa31524 100644 --- a/ldap/admin/src/initconfig.in +++ b/ldap/admin/src/initconfig.in @@ -2,11 +2,11 @@ OS=`uname -s` # use the new mt slab memory allocator on Solaris # this requires Solaris 9 update 3 or later -if [ "$OS" = "SunOS" -a -f /usr/lib/libumem.so ] ; then +if [ "$OS" = "SunOS" ] && [ -f /usr/lib/libumem.so ] ; then LD_PRELOAD=/usr/lib/libumem.so export LD_PRELOAD fi -if [ "$OS" = "SunOS" -a -f /usr/lib/64/libumem.so ] ; then +if [ "$OS" = "SunOS" ] && [ -f /usr/lib/64/libumem.so ] ; then LD_PRELOAD_64=/usr/lib/64/libumem.so export LD_PRELOAD_64 fi diff --git a/ldap/admin/src/scripts/DSSharedLib.in b/ldap/admin/src/scripts/DSSharedLib.in index 36836968a..8317c5878 100644 --- a/ldap/admin/src/scripts/DSSharedLib.in +++ b/ldap/admin/src/scripts/DSSharedLib.in @@ -98,13 +98,13 @@ get_init_file() do inst_count=`expr $inst_count + 1` id=`normalize_server_id $configfile` - if [ -n "$servid" -a "$id" = "$servid" ] + if [ -n "$servid" ] && [ "$id" = "$servid" ] then # found it echo $configfile exit 0 fi - if [ $first == "yes" ] + if [ $first = "yes" ] then instances=$id first="no" @@ -114,7 +114,7 @@ get_init_file() done # server id not provided, check if there is only one instance - if [ -z "$servid" -a $inst_count -eq 1 ] + if [ -z "$servid" ] && [ $inst_count -eq 1 ] then # return the file echo $configfile @@ -135,48 +135,44 @@ process_dse () configdir=$1 pid=$2 file="$configdir/dse.ldif" - shopt -s nocasematch - OLD_IFC=$IFC + OLD_IFS=$IFS IFS="" while read -r LINE do - if [[ $LINE != \ * ]] && [ "$output" != "" ] + case $LINE in + ' '*) + ;; + *) + if [ -n "$output" ] + then + echo "$output" >> /tmp/DSSharedLib.$pid + output="" + fi + ;; + esac + if [ -n "$output" ] then - echo "$output" >> /tmp/DSSharedLib.$pid - output="" - fi - if [ "$output" != "" ] && [[ $LINE == \ * ]] - then - # continuation line, strip the space and append it - LINE=`echo "$LINE" | sed -e 's/^ //'` - output=$output$LINE - elif [[ $LINE == nsslapd-port* ]] - then - output=$LINE; - elif [[ $LINE == nsslapd-localhost* ]] - then - output=$LINE; - elif [[ $LINE == nsslapd-securePort* ]] - then - output=$LINE; - elif [[ $LINE == nsslapd-security* ]] - then - output=$LINE; - elif [[ $LINE == nsslapd-ldapilisten* ]] - then - output=$LINE; - elif [[ $LINE == nsslapd-ldapifilepath* ]] - then - output=$LINE; - elif [[ $LINE == nsslapd-rootdn* ]] - then - output=$LINE; - elif [[ $LINE == nsslapd-ldapiautobind* ]] - then - output=$LINE; - elif [[ $LINE == nsslapd-certdir* ]] - then - output=$LINE; + case $LINE in + ' '*) + # continuation line, strip the space and append it + LINE=`echo "$LINE" | sed -e 's/^ //'` + output=$output$LINE + ;; + esac + else + case $LINE in + nsslapd-certdir*|\ + nsslapd-ldapiautobind*|\ + nsslapd-ldapilisten*|\ + nsslapd-ldapifilepath*|\ + nsslapd-localhost*|\ + nsslapd-port*|\ + nsslapd-rootdn*|\ + nsslapd-securePort*|\ + nsslapd-security*) + output=$LINE + ;; + esac fi done < $file @@ -194,19 +190,19 @@ check_protocol () ldapi=$3 openldap=$4 - if [ "$protocol" == "LDAPI" ] && [ "$openldap" != "yes" ]; then + if [ "$protocol" = "LDAPI" ] && [ "$openldap" != "yes" ]; then echo "" exit - elif [ "$protocol" == "LDAPI" ] && [ "$ldapi" == "off" ]; then + elif [ "$protocol" = "LDAPI" ] && [ "$ldapi" = "off" ]; then echo "" exit - elif [ "$protocol" == "STARTTLS" ]; then - if [ "$security" == "" ] || [ "$security" == "off" ]; then + elif [ "$protocol" = "STARTTLS" ]; then + if [ -z "$security" ] || [ "$security" = "off" ]; then echo "" exit fi - elif [ "$protocol" == "LDAPS" ]; then - if [ "$security" == "" ] || [ "$security" == "off" ]; then + elif [ "$protocol" = "LDAPS" ]; then + if [ -z "$security" ] || [ "$security" = "off" ]; then echo "" exit fi @@ -224,4 +220,4 @@ check_protocol () fi echo "$protocol" -} \ No newline at end of file +} diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in index f0cede412..a2e54cc60 100755 --- a/ldap/admin/src/scripts/bak2db.in +++ b/ldap/admin/src/scripts/bak2db.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@nss_libdir@" @@ -26,15 +26,18 @@ if [ $# -lt 1 ] || [ $# -gt 7 ] then usage exit 1 -elif [[ $1 == -* ]] -then - usage - exit 1 -else - archivedir=$1 - shift fi - +case $1 in + -*) + usage + exit 1 + ;; + *) + archivedir=$1 + shift + ;; +esac + while getopts "hn:Z:qd:vi:a:SD:" flag do case $flag in @@ -55,7 +58,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in index dacd7b066..1896c197a 100755 --- a/ldap/admin/src/scripts/db2bak.in +++ b/ldap/admin/src/scripts/db2bak.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@nss_libdir@" @@ -26,7 +26,6 @@ then usage exit 1 fi - if [ "$#" -gt 0 ] then if [[ $1 != -* ]] @@ -56,7 +55,7 @@ done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" @@ -67,7 +66,7 @@ fi servid=`normalize_server_id $initfile` . $initfile -if [ -z $bak_dir ] +if [ -z "$bak_dir" ] then bak_dir=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H_%M_%S` fi diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in index a1321ea6d..2b76cd181 100755 --- a/ldap/admin/src/scripts/db2index.in +++ b/ldap/admin/src/scripts/db2index.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@nss_libdir@" @@ -59,7 +59,7 @@ then fi initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in index d7e0ff091..fcf73a089 100755 --- a/ldap/admin/src/scripts/db2ldif.in +++ b/ldap/admin/src/scripts/db2ldif.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@nss_libdir@" @@ -39,7 +39,7 @@ make_ldiffile() be="" while [ "$1" != "" ] do - if [ "$1" = "-a" ]; then + if [ "x$1" = "x-a" ]; then shift if [ `expr "$1" : "/.*"` -gt 0 ]; then if [ `expr "$1" : "/.*"` -gt 0 ]; then @@ -56,17 +56,17 @@ make_ldiffile() shift return 0 fi - elif [ "$1" = "-n" ]; then + elif [ "x$1" = "x-n" ]; then shift - if [ "$be" = "" ]; then + if [ -z "$be" ]; then be="$1" else tmpbe="$be" be="${tmpbe}-$1" fi - elif [ "$1" = "-s" ]; then + elif [ "x$1" = "x-s" ]; then shift - if [ "$1" != "" ]; then + if [ -n "$1" ]; then rdn=`echo $1 | awk -F, '{print $1}'` rdnval=`echo $rdn | awk -F= '{print $2}'` if [ "$be" = "" ]; then @@ -76,15 +76,15 @@ make_ldiffile() be="${tmpbe}-$rdnval" fi fi - elif [ "$1" = "-M" ]; then + elif [ "x$1" = "x-M" ]; then be="" fi - if [ "$1" != "" ]; then + if [ -n "$1" ]; then shift fi done - if [ "$be" = "" ]; then + if [ -z "$be" ]; then echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-`date +%Y_%m_%d_%H%M%S`.ldif else echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-${be}-`date +%Y_%m_%d_%H%M%S`.ldif @@ -92,7 +92,7 @@ make_ldiffile() return 0 } -if [ "$#" -lt 2 ]; +if [ $# -lt 2 ]; then usage exit 1 @@ -137,7 +137,7 @@ then fi initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in index 461cc16ff..bbacc17f1 100755 --- a/ldap/admin/src/scripts/dbverify.in +++ b/ldap/admin/src/scripts/dbverify.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@nss_libdir@" @@ -47,7 +47,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" @@ -58,7 +58,7 @@ fi . $initfile @sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args -if [ $display_version == "yes" ]; then +if [ $display_version = "yes" ]; then exit 0 fi if [ $? -eq 0 ]; then diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in index 32a70c84c..616969acd 100755 --- a/ldap/admin/src/scripts/dn2rdn.in +++ b/ldap/admin/src/scripts/dn2rdn.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@nss_libdir@" @@ -39,7 +39,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in index ce1534992..a34241afd 100755 --- a/ldap/admin/src/scripts/ldif2db.in +++ b/ldap/admin/src/scripts/ldif2db.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@nss_libdir@" @@ -82,7 +82,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/ldap/admin/src/scripts/ldif2ldap.in b/ldap/admin/src/scripts/ldif2ldap.in index 874b1bbb7..1e871bede 100755 --- a/ldap/admin/src/scripts/ldif2ldap.in +++ b/ldap/admin/src/scripts/ldif2ldap.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@ldapsdk_libdir@" libpath_add "@libdir@" @@ -40,14 +40,14 @@ do esac done -if [ "$input_file" == "" ] +if [ -z "$input_file" ] then usage exit 1 fi initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" @@ -67,13 +67,13 @@ ldapi=$(grep -i 'nsslapd-ldapilisten' $file | awk '{print $2}' ) ldapiURL=$(grep -i 'nsslapd-ldapifilepath' $file | awk '{print $2}' ) certdir=$(grep -i 'nsslapd-certdir' $file | awk '{print $2}' ) autobind=$(grep -i 'nsslapd-ldapiautobind' $file | awk '{print $2}' ) -if [ "$rootdn" == "" ]; then +if [ -z "$rootdn" ]; then value=$(grep -i 'nsslapd-rootdn' $file) rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'` fi rm $file -if [ "$ldapiURL" != "" ]; then +if [ -n "$ldapiURL" ]; then ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'` ldapiURL="ldapi://"$ldapiURL fi @@ -86,7 +86,7 @@ then export LDAPTLS_CACERTDIR=$certdir fi -if [ -z $security ]; then +if [ -z "$security" ]; then security="off" fi revised_protocol=$(check_protocol $protocol $security $ldapi $openldap) @@ -99,12 +99,12 @@ protocol=$revised_protocol # # STARTTLS # -if [ "$security" == "on" ]; then - if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then - if [ "$error" == "yes" ]; then +if [ "$security" = "on" ]; then + if [ "$protocol" = "STARTTLS" ] || [ -z "$protocol" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(STARTTLS)" fi - if [ "$openldap" == "yes" ]; then + if [ "$openldap" = "yes" ]; then ldapmodify -x -ZZ -p $port -h $host -D $rootdn -w $passwd -a -f $input_file else ldapmodify -ZZZ -P $certdir -p $port -h $host -D $rootdn -w $passwd -a -f $input_file @@ -116,12 +116,12 @@ fi # # LDAPS # -if [ "$security" == "on" ]; then - if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then - if [ "$error" == "yes" ]; then +if [ "$security" = "on" ]; then + if [ "$protocol" = "LDAPS" ] || [ -z "$protocol" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(LDAPS)" fi - if [ "$openldap" == "yes" ]; then + if [ "$openldap" = "yes" ]; then ldapmodify -x -H "ldaps://$host:$secure_port" -D $rootdn -w $passwd -a -f $input_file else ldapmodify -Z -P $certdir -p $secure_port -h $host -D $rootdn -w $passwd -a -f $input_file @@ -133,21 +133,21 @@ fi # # LDAPI # -if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then - if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then - if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then - if [ "$error" == "yes" ]; then +if [ "$ldapi" = "on" ] && [ "$openldap" = "yes" ]; then + if [ "$protocol" = "LDAPI" ] || [ -z "$protocol" ]; then + if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(LDAPI/AUTOBIND)" fi ldapmodify -H $ldapiURL -Y EXTERNAL -a -f $input_file 2>/dev/null else - if [ "$error" == "yes" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(LDAPI)" fi ldapmodify -x -H $ldapiURL -D $rootdn -w $passwd -a -f $input_file fi rc=$? - if [ $rc != 0 ] + if [ $rc -ne 0 ] then echo "Operation failed (error $rc)" fi @@ -158,11 +158,11 @@ fi # # LDAP # -if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then - if [ "$error" == "yes" ]; then +if [ "$protocol" = "LDAP" ] || [ -z "$protocol" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(LDAP)" fi - if [ "$openldap" == "yes" ]; then + if [ "$openldap" = "yes" ]; then ldapmodify -x -p $port -h $host -D $rootdn -w $passwd -a -f $input_file else ldapmodify -p $port -h $host -D $rootdn -w $passwd -a -f $input_file diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in index 7b2058b89..36a2fc9b0 100755 --- a/ldap/admin/src/scripts/monitor.in +++ b/ldap/admin/src/scripts/monitor.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@ldapsdk_libdir@" @@ -41,7 +41,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" @@ -66,17 +66,17 @@ ldapi=$(grep -i 'nsslapd-ldapilisten' $file | awk '{print $2}' ) ldapiURL=$(grep -i 'nsslapd-ldapifilepath' $file | awk '{print $2}' ) certdir=$(grep -i 'nsslapd-certdir' $file | awk '{print $2}' ) autobind=$(grep -i 'nsslapd-ldapiautobind' $file | awk '{print $2}' ) -if [ "$rootdn" == "" ]; then +if [ -z "$rootdn" ]; then value=$(grep -i 'nsslapd-rootdn' $file) rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'` fi rm $file -if [ "$passwd" != "" ]; then +if [ -n "$passwd" ]; then dn="-D $rootdn" passwd="-w$passwd" fi -if [ "$ldapiURL" != "" ] +if [ -n "$ldapiURL" ] then ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'` ldapiURL="ldapi://"$ldapiURL @@ -103,12 +103,12 @@ protocol=$revised_protocol # # STARTTLS # -if [ "$security" == "on" ]; then - if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then - if [ "$error" == "yes" ]; then +if [ "$security" = "on" ]; then + if [ "$protocol" = "STARTTLS" ] || [ -z "$protocol" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(STARTTLS)" fi - if [ "$openldap" == "yes" ]; then + if [ "$openldap" = "yes" ]; then ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*" else ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*" @@ -120,12 +120,12 @@ fi # # LDAPS # -if [ "$security" == "on" ]; then - if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then - if [ "$error" == "yes" ]; then +if [ "$security" = "on" ]; then + if [ "$protocol" = "LDAPS" ] || [ -z "$protocol" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(LDAPS)" fi - if [ "$openldap" == "yes" ]; then + if [ "$openldap" = "yes" ]; then ldapsearch -x -LLL -H "ldaps://$host:$secure_port" -b "$MDN" -s base $dn $passwd "objectClass=*" else ldapsearch -Z -P $certdir -p $secure_port -b "$MDN" -s base $dn $passwd "objectClass=*" @@ -137,15 +137,15 @@ fi # # LDAPI # -if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then - if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then - if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then - if [ "$error" == "yes" ]; then +if [ "$ldapi" = "on" ] && [ "$openldap" = "yes" ]; then + if [ "$protocol" = "LDAPI" ] || [ -z "$protocol" ]; then + if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(LDAPI/AUTOBIND)" fi ldapsearch -LLL -H "$ldapiURL" -b "$MDN" -s base -Y EXTERNAL "objectClass=*" 2>/dev/null else - if [ "$error" == "yes" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(LDAPI)" fi ldapsearch -x -LLL -H "$ldapiURL" -b "$MDN" -s base $dn $passwd "objectClass=*" @@ -157,14 +157,14 @@ fi # # LDAP # -if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then - if [ "$error" == "yes" ]; then +if [ "$protocol" = "LDAP" ] || [ "$protocol" = "" ]; then + if [ "$error" = "yes" ]; then echo "Using the next most secure protocol(LDAP)" fi - if [ "$openldap" == "yes" ]; then + if [ "$openldap" = "yes" ]; then ldapsearch -x -LLL -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*" else ldapsearch -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*" - fi + fi exit $? fi diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in index 130e06e42..e86a24c18 100644 --- a/ldap/admin/src/scripts/restart-dirsrv.in +++ b/ldap/admin/src/scripts/restart-dirsrv.in @@ -7,7 +7,7 @@ # 2: Server started successfully (was not running) # 3: Server could not be stopped -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib restart_instance() { SERV_ID=$1 diff --git a/ldap/admin/src/scripts/restoreconfig.in b/ldap/admin/src/scripts/restoreconfig.in index 9bb1acf04..56c9e4339 100755 --- a/ldap/admin/src/scripts/restoreconfig.in +++ b/ldap/admin/src/scripts/restoreconfig.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@nss_libdir@" @@ -31,7 +31,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/ldap/admin/src/scripts/saveconfig.in b/ldap/admin/src/scripts/saveconfig.in index 65d80f30a..16e3efc57 100755 --- a/ldap/admin/src/scripts/saveconfig.in +++ b/ldap/admin/src/scripts/saveconfig.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@libdir@" @@ -31,7 +31,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" @@ -45,7 +45,7 @@ servid=`normalize_server_id $initfile` echo saving configuration... conf_ldif=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H%M%S`.ldif @sbindir@/ns-slapd db2ldif -N -D $CONFIG_DIR -s "o=NetscapeRoot" -a $conf_ldif -n NetscapeRoot 2>&1 -if [ "$?" -ge 1 ] +if [ $? -ge 1 ] then echo Error occurred while saving configuration exit 1 diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in index 481797d3a..458f0e816 100755 --- a/ldap/admin/src/scripts/start-dirsrv.in +++ b/ldap/admin/src/scripts/start-dirsrv.in @@ -6,7 +6,7 @@ # 1: Server could not be started # 2: Server already running -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib # Starts a single instance start_instance() { @@ -44,7 +44,7 @@ start_instance() { STARTPIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.startpid if test -f $STARTPIDFILE ; then PID=`cat $STARTPIDFILE` - if kill -0 $PID > /dev/null 2>&1 ; then + if kill -s 0 $PID > /dev/null 2>&1 ; then echo There is an ns-slapd process already running: $PID return 2; else @@ -53,7 +53,7 @@ start_instance() { fi if test -f $PIDFILE ; then PID=`cat $PIDFILE` - if kill -0 $PID > /dev/null 2>&1 ; then + if kill -s 0 $PID > /dev/null 2>&1 ; then echo There is an ns-slapd running: $PID return 2; else @@ -64,7 +64,7 @@ start_instance() { # Use systemctl if available and running as root, # otherwise start the instance the old way. # - if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then + if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then @bindir@/systemctl start @package_name@@$SERV_ID.service if [ $? -ne 0 ]; then return 1 @@ -96,7 +96,7 @@ start_instance() { 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 + if kill -s 0 $PID > /dev/null 2>&1 ; then sleep 1 else echo Server failed to start !!! Please check errors log for problems @@ -123,12 +123,12 @@ do done shift $(($OPTIND-1)) -if [ "$initconfig_dir" = "" ]; then +if [ -z "$initconfig_dir" ]; then initconfig_dir=@initconfigdir@ fi found=0 -if [ "$#" -eq 0 ]; then +if [ $# -eq 0 ]; then # We're starting all instances. ret=0 initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; } @@ -137,7 +137,7 @@ if [ "$#" -eq 0 ]; then echo Starting instance \"$inst\" start_instance $inst rv=$? - if [ "$rv" -ne 0 ]; then + if [ $rv -ne 0 ]; then ret=$rv fi done diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in index 3f02e78d9..72e2b85d7 100755 --- a/ldap/admin/src/scripts/stop-dirsrv.in +++ b/ldap/admin/src/scripts/stop-dirsrv.in @@ -6,7 +6,7 @@ # 1: Server could not be stopped # 2: Server was not running -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib stop_instance() { SERV_ID=$1 @@ -28,7 +28,7 @@ stop_instance() { fi PID=`cat $PIDFILE` # see if the server is already stopped - kill -0 $PID > /dev/null 2>&1 || { + kill -s 0 $PID > /dev/null 2>&1 || { echo Server not running if test -f $PIDFILE ; then rm -f $PIDFILE @@ -39,7 +39,7 @@ stop_instance() { # # use systemctl if running as root # - if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then + if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then # # Now, check if systemctl is aware of this running instance # @@ -65,7 +65,7 @@ stop_instance() { max_count=600 while test $loop_counter -le $max_count; do loop_counter=`expr $loop_counter + 1` - if kill -0 $PID > /dev/null 2>&1 ; then + if kill -s 0 $PID > /dev/null 2>&1 ; then sleep 1; else if test -f $PIDFILE ; then @@ -88,11 +88,11 @@ do done shift $(($OPTIND-1)) -if [ "$initconfig_dir" = "" ]; then +if [ -z "$initconfig_dir" ]; then initconfig_dir=@initconfigdir@ fi -if [ "$#" -eq 0 ]; then +if [ $# -eq 0 ]; then # We're stopping all instances. ret=0 initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; } @@ -105,7 +105,7 @@ if [ "$#" -eq 0 ]; then echo Stopping instance \"$inst\" stop_instance $inst rv=$? - if [ "$rv" -ne 0 ]; then + if [ $rv -ne 0 ]; then ret=$rv fi done diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in index e2f73c321..7774148e2 100755 --- a/ldap/admin/src/scripts/suffix2instance.in +++ b/ldap/admin/src/scripts/suffix2instance.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@libdir@" @@ -32,14 +32,14 @@ do esac done -if [ "$args" == "" ] +if [ -z "$args" ] then usage exit 1 fi initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in index 211bdce4b..bf600dd63 100755 --- a/ldap/admin/src/scripts/upgradedb.in +++ b/ldap/admin/src/scripts/upgradedb.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@libdir@" @@ -39,7 +39,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then echo "You must supply a valid server instance identifier. Use -Z to specify instance name" echo "Available instances: $initfile" diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in index e9d8cab7a..51585aef8 100755 --- a/ldap/admin/src/scripts/upgradednformat.in +++ b/ldap/admin/src/scripts/upgradednformat.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib # upgradednformat -- upgrade DN format to the new style (RFC 4514) # Usgae: upgradednformat [-N] -n backend_instance -a db_instance_directory @@ -49,13 +49,13 @@ do esac done -if [ "$be" = "" ] || [ "$dir" = "" ]; then +if [ -z "$be" ] || [ -z "$dir" ]; then usage exit 1 fi initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in index 0b46b2729..365e32fc8 100755 --- a/ldap/admin/src/scripts/vlvindex.in +++ b/ldap/admin/src/scripts/vlvindex.in @@ -1,6 +1,6 @@ #!/bin/sh -source @datadir@/@package_name@/data/DSSharedLib +. @datadir@/@package_name@/data/DSSharedLib libpath_add "@libdir@/@package_name@/" libpath_add "@libdir@" @@ -45,7 +45,7 @@ do done initfile=$(get_init_file "@initconfigdir@" $servid) -if [ $? == 1 ] +if [ $? -eq 1 ] then usage echo "You must supply a valid server instance identifier. Use -Z to specify instance name" diff --git a/rpm/389-ds-base-git.sh b/rpm/389-ds-base-git.sh index e5aaa8af5..1a38da17f 100644 --- a/rpm/389-ds-base-git.sh +++ b/rpm/389-ds-base-git.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh DATE=`date +%Y%m%d` # use a real tag name here diff --git a/rpm/add_patches.sh b/rpm/add_patches.sh index 690d0b26f..31823d593 100755 --- a/rpm/add_patches.sh +++ b/rpm/add_patches.sh @@ -1,6 +1,6 @@ #!/bin/sh -function usage() +usage() { echo "Adds patches to a specfile" echo "" @@ -51,5 +51,5 @@ for p in $patches; do sed -i -e "/${prefix}/a Patch${i}: ${p}" -e "/$prepprefix/a %patch${i} -p1" $specfile prefix="Patch${i}:" prepprefix="%patch${i}" - i=$(($i+1)) + i=`expr $i + 1` done diff --git a/rpm/rpmverrel.sh b/rpm/rpmverrel.sh index 86b808e47..06e97c75e 100755 --- a/rpm/rpmverrel.sh +++ b/rpm/rpmverrel.sh @@ -6,7 +6,7 @@ srcdir=`pwd` # Source VERSION.sh to set the version # and release environment variables. -source ./VERSION.sh +. ./VERSION.sh if [ "$1" = "version" ]; then echo $RPM_VERSION diff --git a/wrappers/initscript.in b/wrappers/initscript.in index ad4ea2b7a..fa79dbd55 100644 --- a/wrappers/initscript.in +++ b/wrappers/initscript.in @@ -32,28 +32,20 @@ then fi 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 + printf '%s' "$*" } # failure and success are not defined on some platforms -type failure > /dev/null 2>&1 || { +which failure > /dev/null 2>&1 || { failure() { echo_n " FAILED" } } -type success > /dev/null 2>&1 || { +which success > /dev/null 2>&1 || { success() { echo_n " SUCCESS" @@ -178,7 +170,7 @@ start() { pid=`cat $pidfile` instlockfile="@localstatedir@/lock/@package_name@/slapd-$instance/server/$pid" name=`ps -p $pid | tail -1 | awk '{ print $4 }'` - if kill -0 $pid && [ $name = "ns-slapd" ]; then + if kill -s 0 $pid && [ $name = "ns-slapd" ]; then echo_n " already running" success; echo successes=`expr $successes + 1` @@ -239,7 +231,7 @@ start() { 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 + if kill -s 0 $pid > /dev/null 2>&1 ; then sleep 1 else break @@ -249,7 +241,7 @@ start() { break fi done - if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then + if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then success; echo successes=`expr $successes + 1` else @@ -278,7 +270,7 @@ stop() { if [ -f $pidfile ]; then pid=`cat $pidfile` server_stopped=0 - if kill -0 $pid > /dev/null 2>&1 ; then + if kill -s 0 $pid > /dev/null 2>&1 ; then kill $pid if [ $? -eq 0 ]; then server_stopped=1 @@ -297,7 +289,7 @@ stop() { max_count=600 while test $loop_counter -le $max_count; do loop_counter=`expr $loop_counter + 1` - if kill -0 $pid > /dev/null 2>&1 ; then + if kill -s 0 $pid > /dev/null 2>&1 ; then sleep 1 else if test -f $pidfile ; then @@ -339,7 +331,7 @@ status() { for instance in $INSTANCES; do if [ -f $piddir/slapd-$instance.pid ]; then pid=`cat $piddir/slapd-$instance.pid` - if kill -0 $pid > /dev/null 2>&1 ; then + if kill -s 0 $pid > /dev/null 2>&1 ; then echo "$prog $instance (pid $pid) is running..." else echo "$prog $instance dead but pid file exists" diff --git a/wrappers/ldap-agent-initscript.in b/wrappers/ldap-agent-initscript.in index dd8ee9770..b7aa4fe18 100644 --- a/wrappers/ldap-agent-initscript.in +++ b/wrappers/ldap-agent-initscript.in @@ -31,28 +31,20 @@ then fi 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 + printf '%s' "$*" } # failure and success are not defined on some platforms -type failure > /dev/null 2>&1 || { +which failure > /dev/null 2>&1 || { failure() { echo_n " FAILED" } } -type success > /dev/null 2>&1 || { +which success > /dev/null 2>&1 || { success() { echo_n " SUCCESS" @@ -92,7 +84,7 @@ start() { if [ -f $pidfile ]; then pid=`cat $pidfile` name=`ps -p $pid | tail -1 | awk '{ print $4 }'` - if kill -0 $pid && [ $name = "$processname" ]; then + if kill -s 0 $pid && [ $name = "$processname" ]; then echo_n " already running" success; echo subagent_running=1 @@ -121,7 +113,7 @@ start() { 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 + if kill -s 0 $pid > /dev/null 2>&1 ; then sleep 1 else break @@ -131,7 +123,7 @@ start() { break fi done - if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then + if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then success; echo else failure; echo @@ -147,7 +139,7 @@ stop() { if [ -f $pidfile ]; then pid=`cat $pidfile` subagent_stopped=0 - if kill -0 $pid > /dev/null 2>&1 ; then + if kill -s 0 $pid > /dev/null 2>&1 ; then kill $pid if [ $? -eq 0 ]; then subagent_stopped=1 @@ -164,7 +156,7 @@ stop() { 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 + if kill -s 0 $pid > /dev/null 2>&1 ; then sleep 1 else if test -f $pidfile ; then @@ -200,7 +192,7 @@ condrestart() { if [ -f $pidfile ]; then pid=`cat $pidfile` name=`ps -p $pid | tail -1 | awk '{ print $4 }'` - if kill -0 $pid && [ $name = "$processname" ]; then + if kill -s 0 $pid && [ $name = "$processname" ]; then restart fi fi @@ -210,7 +202,7 @@ status() { ret=0 if [ -f $pidfile ]; then pid=`cat $pidfile` - if kill -0 $pid > /dev/null 2>&1 ; then + if kill -s 0 $pid > /dev/null 2>&1 ; then echo "$prog (pid $pid) is running..." else echo "$prog dead but pid file exists"
0
e0df02c139635a94b53078a0afe6324163ce4fed
389ds/389-ds-base
Resolves: bug 147886 Description: Warn if cert or key file is missing Fix Description: My fix for https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=224672 reopened this bug. I think the correct way to address this problem is this: If using security, the key and cert db files must exist i.e. there must already be a server cert for the server. If not using security, there may not be a key/cert db, but NSS will create them if the directory is writable. Reviewed by: nhosoi (Thanks!)
commit e0df02c139635a94b53078a0afe6324163ce4fed Author: Rich Megginson <[email protected]> Date: Mon Jan 29 23:44:49 2007 +0000 Resolves: bug 147886 Description: Warn if cert or key file is missing Fix Description: My fix for https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=224672 reopened this bug. I think the correct way to address this problem is this: If using security, the key and cert db files must exist i.e. there must already be a server cert for the server. If not using security, there may not be a key/cert db, but NSS will create them if the directory is writable. Reviewed by: nhosoi (Thanks!) diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c index 13fc00b62..dc55aa2cd 100644 --- a/ldap/servers/slapd/ssl.c +++ b/ldap/servers/slapd/ssl.c @@ -359,62 +359,28 @@ freeChildren( char **list ) { } static void -warn_if_no_cert_file(const char *filename) +warn_if_no_cert_file(const char *dir) { + char *filename = slapi_ch_smprintf("%s/cert8.db", dir); PRStatus status = PR_Access(filename, PR_ACCESS_READ_OK); if (PR_SUCCESS != status) { - /* if file ends in -cert7.db and the corresponding -cert8.db exists, just - warn */ - char *cert8 = slapi_ch_strdup(filename); - char *ptr; - if ((ptr = PL_strrstr(cert8, "-cert7.db"))) { - strcpy(ptr, "-cert8.db"); - status = PR_Access(cert8, PR_ACCESS_READ_OK); - if (PR_SUCCESS == status) { - slapi_log_error(SLAPI_LOG_FATAL, "SSL Initialization", - "Notice: certificate DB file %s does not exist but %s does - suggest updating nscertfile\n", - filename, cert8); - } - } - slapi_ch_free_string(&cert8); - - if (PR_SUCCESS != status) { - slapi_log_error(SLAPI_LOG_FATAL, "SSL Initialization", - "Warning: certificate DB file %s does not exist - SSL initialization will likely fail\n", - filename); - } + slapi_log_error(SLAPI_LOG_FATAL, "SSL Initialization", + "Warning: certificate DB file %s does not exist - SSL initialization will likely fail\n", + filename); } + slapi_ch_free_string(&filename); } static void -warn_if_no_key_file(const char *path, const char *name) +warn_if_no_key_file(const char *dir) { - char last = path[strlen(path)-1]; - char *filename = slapi_ch_smprintf("%s%s%s", path, ((last == '/' || last == '\\') ? "" : "/"), name); + char *filename = slapi_ch_smprintf("%s/key3.db", dir); PRStatus status = PR_Access(filename, PR_ACCESS_READ_OK); if (PR_SUCCESS != status) { - /* if file ends in -key3.db and the corresponding -key4.db exists, just - warn */ - char *key4 = slapi_ch_strdup(filename); - char *ptr; - if ((ptr = PL_strrstr(key4, "-key3.db"))) { - strcpy(ptr, "-key4.db"); - status = PR_Access(key4, PR_ACCESS_READ_OK); - if (PR_SUCCESS == status) { - slapi_log_error(SLAPI_LOG_FATAL, "SSL Initialization", - "Notice: key DB file %s does not exist but %s does - suggest updating nskeyfile\n", - filename, key4); - } - } - slapi_ch_free_string(&key4); - - if (PR_SUCCESS != status) { - slapi_log_error(SLAPI_LOG_FATAL, "SSL Initialization", - "Warning: key DB file %s does not exist - SSL initialization will likely fail\n", - filename); - } + slapi_log_error(SLAPI_LOG_FATAL, "SSL Initialization", + "Warning: key DB file %s does not exist - SSL initialization will likely fail\n", + filename); } - slapi_ch_free_string(&filename); } @@ -450,20 +416,26 @@ slapd_nss_init(int init_ssl, int config_available) certdir[len-1] = '\0'; } - /* we open the key/cert db in rw mode, so make sure the directory - is writable */ - if (PR_SUCCESS != (status = PR_Access(certdir, PR_ACCESS_WRITE_OK))) { - char *serveruser = "unknown"; + /* If the server is configured to use SSL, we must have a key and cert db */ + if (config_get_security()) { + warn_if_no_cert_file(certdir); + warn_if_no_key_file(certdir); + } else { /* otherwise, NSS will create empty databases */ + /* we open the key/cert db in rw mode, so make sure the directory + is writable */ + if (PR_SUCCESS != (status = PR_Access(certdir, PR_ACCESS_WRITE_OK))) { + char *serveruser = "unknown"; #ifndef _WIN32 - serveruser = config_get_localuser(); + serveruser = config_get_localuser(); #endif - slapi_log_error(SLAPI_LOG_FATAL, "SSL Initialization", - "Warning: The key/cert database directory [%s] is not writable by " - "the server uid [%s]: initialization likely to fail.\n", - certdir, serveruser); + slapi_log_error(SLAPI_LOG_FATAL, "SSL Initialization", + "Warning: The key/cert database directory [%s] is not writable by " + "the server uid [%s]: initialization likely to fail.\n", + certdir, serveruser); #ifndef _WIN32 - slapi_ch_free_string(&serveruser); + slapi_ch_free_string(&serveruser); #endif + } } /******** Initialise NSS *********/
0
d8e44a8103bbd02010a53e528a0349abcb53e167
389ds/389-ds-base
Resolves: #457156 Summary: GER: allow GER for non-existing entries (phase 2) (comment #3) Description: get the target dn from the pblock and add it to the template entry dn if available. Plus a memory leak was found and fixed at the same time. Following the suggestion from Nathan, the "dummy" attributes are replaced with "(template_attribute)".
commit d8e44a8103bbd02010a53e528a0349abcb53e167 Author: Noriko Hosoi <[email protected]> Date: Thu Jul 31 17:25:37 2008 +0000 Resolves: #457156 Summary: GER: allow GER for non-existing entries (phase 2) (comment #3) Description: get the target dn from the pblock and add it to the template entry dn if available. Plus a memory leak was found and fixed at the same time. Following the suggestion from Nathan, the "dummy" attributes are replaced with "(template_attribute)". diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c index 8353aef7a..18f046819 100644 --- a/ldap/servers/plugins/acl/acleffectiverights.c +++ b/ldap/servers/plugins/acl/acleffectiverights.c @@ -811,6 +811,7 @@ _ger_generate_template_entry ( char *object = NULL; char *superior = NULL; char *p = NULL; + char *dn = NULL; int siz = 0; int len = 0; int i = 0; @@ -826,6 +827,8 @@ _ger_generate_template_entry ( rc = LDAP_SUCCESS; goto bailout; } + /* get the target dn where the template entry is located */ + slapi_pblock_get( pb, SLAPI_TARGET_DN, &dn ); for (i = 0; gerattrs && gerattrs[i]; i++) { object = strchr(gerattrs[i], '@'); @@ -855,14 +858,23 @@ _ger_generate_template_entry ( } else { - /* <*attrp>: dummy\n\0 */ - siz += strlen(attrs[i]) + 4 + 5; + /* <*attrp>: (template_attribute)\n\0 */ + siz += strlen(attrs[i]) + 4 + 20; } } - siz += 32 + strlen(object); /* dn: cn=<template_name>\n\0 */ + if (dn) + { + /* dn: cn=<template_name>,<dn>\n\0 */ + siz += 32 + strlen(object) + strlen(dn); + } + else + { + /* dn: cn=<template_name>\n\0 */ + siz += 32 + strlen(object); + } templateentry = (char *)slapi_ch_malloc(siz); PR_snprintf(templateentry, siz, - "dn: cn=template_%s_objectclass\n", object); + "dn: cn=template_%s_objectclass%s%s\n", object, dn?",":"", dn?dn:""); for (--i; i >= 0; i--) { len = strlen(templateentry); @@ -873,7 +885,7 @@ _ger_generate_template_entry ( } else { - PR_snprintf(p, siz - len, "%s: dummy\n", attrs[i]); + PR_snprintf(p, siz - len, "%s: (template_attribute)\n", attrs[i]); } } charray_free(attrs); @@ -909,6 +921,10 @@ _ger_generate_template_entry ( } charray_free(attrs); } + if (notfirst) + { + slapi_ch_free_string(&object); + } slapi_ch_free_string(&superior); siz += 18; /* objectclass: top\n\0 */ len = strlen(templateentry);
0
1a78810088c5fb59b27773b92e95d2e372735251
389ds/389-ds-base
Issue 5718 - Memory leak in connection table (#5719) Bug description: duplicate multiple mem allocation cause leak Fix description: remove duplicate allocation Fixes: https://github.com/389ds/389-ds-base/issues/5718 Reviewed by: @Firstyear (Thank you)
commit 1a78810088c5fb59b27773b92e95d2e372735251 Author: James Chapman <[email protected]> Date: Tue Apr 11 12:51:01 2023 +0100 Issue 5718 - Memory leak in connection table (#5719) Bug description: duplicate multiple mem allocation cause leak Fix description: remove duplicate allocation Fixes: https://github.com/389ds/389-ds-base/issues/5718 Reviewed by: @Firstyear (Thank you) diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c index 6b8052591..b1c66cf42 100644 --- a/ldap/servers/slapd/conntable.c +++ b/ldap/servers/slapd/conntable.c @@ -133,7 +133,6 @@ connection_table_new(int table_size) ct->num_active = (int *)slapi_ch_calloc(1, ct->list_num * sizeof(int)); ct->size = table_size - (table_size % ct->list_num); ct->list_size = ct->size/ct->list_num; - ct->num_active = (int *)slapi_ch_calloc(1, ct->list_num * sizeof(int)); ct->c = (Connection **)slapi_ch_calloc(1, ct->size * sizeof(Connection *)); ct->fd = (struct POLL_STRUCT **)slapi_ch_calloc(1, ct->list_num * sizeof(struct POLL_STRUCT*)); ct->table_mutex = PR_NewLock();
0
6236d7a7df86141311d731ce737d1c0986d564ee
389ds/389-ds-base
Ticket #47362 - ipa upgrade selinuxusermap data not replicating https://fedorahosted.org/389/ticket/47362 Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: When nsslapd-port is set to 0, this causes the replica purl to be "ldap://hostname:0". At startup, the MMR code looks to see if this replica purl is in the RUV, by doing a string comparison of this purl with the ruv replica purl. If it is not there, the MMR code wipes out this ruv element. Later the code in replica_check_for_data_reload() uses this RUV to see if it needs to reinit the changelog. Since the RUV doesn't match the changelog RUV any more, the changelog is erased, which erases any changes that were made in the meantime. The missing RUV element causes the supplier to attempt to send over changes which may already exist on the consumer. If one of these is an ADD, the urp code will correctly flag this as an attempt to add an entry that already exists, and will turn this into a replConflict entry. A subsequent attempt to replicate the same ADD will cause an error in the urp code which will cause it to return err=53. Replication will then become stuck on this update - it will keep trying to send it over and over again, and will not be able to proceed. The only workaround is a replica reinit of the replica, to get the database RUV and changelog in a consistent state. I've also added some additional RUV debugging when using the REPL log level. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no (cherry picked from commit 614ce4e4b1774526bb8c4ad6c43a1582adcc30ec)
commit 6236d7a7df86141311d731ce737d1c0986d564ee Author: Rich Megginson <[email protected]> Date: Wed May 15 19:39:24 2013 -0600 Ticket #47362 - ipa upgrade selinuxusermap data not replicating https://fedorahosted.org/389/ticket/47362 Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: When nsslapd-port is set to 0, this causes the replica purl to be "ldap://hostname:0". At startup, the MMR code looks to see if this replica purl is in the RUV, by doing a string comparison of this purl with the ruv replica purl. If it is not there, the MMR code wipes out this ruv element. Later the code in replica_check_for_data_reload() uses this RUV to see if it needs to reinit the changelog. Since the RUV doesn't match the changelog RUV any more, the changelog is erased, which erases any changes that were made in the meantime. The missing RUV element causes the supplier to attempt to send over changes which may already exist on the consumer. If one of these is an ADD, the urp code will correctly flag this as an attempt to add an entry that already exists, and will turn this into a replConflict entry. A subsequent attempt to replicate the same ADD will cause an error in the urp code which will cause it to return err=53. Replication will then become stuck on this update - it will keep trying to send it over and over again, and will not be able to proceed. The only workaround is a replica reinit of the replica, to get the database RUV and changelog in a consistent state. I've also added some additional RUV debugging when using the REPL log level. Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: no (cherry picked from commit 614ce4e4b1774526bb8c4ad6c43a1582adcc30ec) diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c index 72d2d6ce7..fa442feff 100644 --- a/ldap/servers/plugins/replication/repl5_inc_protocol.c +++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c @@ -1941,6 +1941,44 @@ repl5_inc_stop(Private_Repl_Protocol *prp) agmt_get_long_name(prp->agmt), PR_IntervalToSeconds(now-start)); } + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + if (NULL == prp->replica_object) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "%s: repl5_inc_stop: protocol replica_object is NULL\n", + agmt_get_long_name(prp->agmt)); + } else { + Replica *replica; + object_acquire(prp->replica_object); + replica = object_get_data(prp->replica_object); + if (NULL == replica) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "%s: repl5_inc_stop: replica is NULL\n", + agmt_get_long_name(prp->agmt)); + } else { + Object *ruv_obj = replica_get_ruv(replica); + if (NULL == ruv_obj) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "%s: repl5_inc_stop: ruv_obj is NULL\n", + agmt_get_long_name(prp->agmt)); + } else { + RUV *ruv; + object_acquire(ruv_obj); + ruv = (RUV*)object_get_data (ruv_obj); + if (NULL == ruv) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "%s: repl5_inc_stop: ruv is NULL\n", + agmt_get_long_name(prp->agmt)); + + } else { + ruv_dump(ruv, "Database RUV", NULL); + } + object_release(ruv_obj); + } + } + object_release(prp->replica_object); + } + + } return return_value; } diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c index 9ce976812..107c4f072 100644 --- a/ldap/servers/plugins/replication/repl5_ruv.c +++ b/ldap/servers/plugins/replication/repl5_ruv.c @@ -208,6 +208,9 @@ ruv_init_from_slapi_attr_and_check_purl(Slapi_Attr *attr, RUV **ruv, ReplicaId * Slapi_Value *value; const struct berval *bval; const char *purl = NULL; + char *localhost = get_localhost_DNS(); + size_t localhostlen = localhost ? strlen(localhost) : 0; + int port = config_get_port(); return_value = RUV_SUCCESS; @@ -236,16 +239,30 @@ ruv_init_from_slapi_attr_and_check_purl(Slapi_Attr *attr, RUV **ruv, ReplicaId * RUVElement *ruve = get_ruvelement_from_berval(bval); if (NULL != ruve) { + char *ptr; /* Is the local purl already in the ruv ? */ if ( (*contain_purl==0) && ruve->replica_purl && purl && (strncmp(ruve->replica_purl, purl, strlen(purl))==0) ) { *contain_purl = ruve->rid; } + /* ticket 47362 - nsslapd-port: 0 causes replication to break */ + else if ((*contain_purl==0) && ruve->replica_purl && (port == 0) && localhost && + (ptr = strstr(ruve->replica_purl, localhost)) && (ptr != ruve->replica_purl) && + (*(ptr - 1) == '/') && (*(ptr+localhostlen) == ':')) + { + /* same hostname, but port number may have been temporarily set to 0 + * just allow it with whatever port number is already in the replica_purl + * do not reset the port number, do not tell the configure_ruv code that there + * is anything wrong + */ + *contain_purl = ruve->rid; + } dl_add ((*ruv)->elements, ruve); } } } } + slapi_ch_free_string(&localhost); } } return return_value; @@ -1291,6 +1308,11 @@ ruv_compare_ruv(const RUV *ruv1, const char *ruv1name, const RUV *ruv2, const ch const char *ruvbnames[] = {ruv2name, ruv1name}; const int nitems = 2; + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + ruv_dump(ruv1, (char *)ruv1name, NULL); + ruv_dump(ruv2, (char *)ruv2name, NULL); + } + /* compare replica generations first */ if (ruv1->replGen == NULL || ruv2->replGen == NULL) { slapi_log_error(loglevel, repl_plugin_name, @@ -1347,7 +1369,17 @@ ruv_compare_ruv(const RUV *ruv1, const char *ruv1name, const RUV *ruv2, const ch "than the max CSN [%s] from RUV [%s] for element [%s]\n", csnstrb, ruvbname, csnstra, ruvaname, ruvelem); rc = RUV_COMP_CSN_DIFFERS; + } else { + csn_as_string(replicaa->csn, PR_FALSE, csnstra); + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "ruv_compare_ruv: the max CSN [%s] from RUV [%s] is less than " + "or equal to the max CSN [%s] from RUV [%s] for element [%s]\n", + csnstrb, ruvbname, csnstra, ruvaname, ruvelem); } + } else { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "ruv_compare_ruv: RUV [%s] has an empty CSN\n", + ruvbname); } } }
0
27da34cf51a8719581cee07cc015ac7ea9472b5a
389ds/389-ds-base
Ticket 48376 - Create a 389-ds-base-tests RPM package Description: Create a sub-package for the lib389 CI tests (requires python-lib389) Also added a stress test that was not committed yet, and some READMEs for the tests. https://fedorahosted.org/389/ticket/48376 Reviewed by: nhosoi(Thanks!)
commit 27da34cf51a8719581cee07cc015ac7ea9472b5a Author: Mark Reynolds <[email protected]> Date: Mon Dec 21 17:23:58 2015 -0500 Ticket 48376 - Create a 389-ds-base-tests RPM package Description: Create a sub-package for the lib389 CI tests (requires python-lib389) Also added a stress test that was not committed yet, and some READMEs for the tests. https://fedorahosted.org/389/ticket/48376 Reviewed by: nhosoi(Thanks!) diff --git a/dirsrvtests/README b/dirsrvtests/README new file mode 100644 index 000000000..48b003f49 --- /dev/null +++ b/dirsrvtests/README @@ -0,0 +1,28 @@ +389-ds-base-tests README +================================================= + +Prerequisites: +------------------------------------------------- +Install the python-lib389 packages, or +download the source(git clone ssh://git.fedorahosted.org/git/389/lib389.git) and set your PYTHONPATH accordingly + + +Description: +------------------------------------------------- +This package includes python-lib389 based python scripts for testing the Directory Server. The following describes the various types of tests available: + +tickets - These scripts test individual bug fixes +suites - These test functinoal areas of the server +stress - These tests perform "stress" tests on the server + +There is also a "create_test.py" script available to construct a template test script for creating new tests. + + +Documentation: +------------------------------------------------- +See http://www.port389.org for the latest information + +http://www.port389.org/docs/389ds/FAQ/upstream-test-framework.html +http://www.port389.org/docs/389ds/howto/howto-write-lib389.html +http://www.port389.org/docs/389ds/howto/howto-run-lib389-jenkins.html + diff --git a/dirsrvtests/stress/README b/dirsrvtests/stress/README new file mode 100644 index 000000000..758cad4bb --- /dev/null +++ b/dirsrvtests/stress/README @@ -0,0 +1,13 @@ +README for "Stress" Tests + +Reliablity Tests +============================== + +A generic high load, long running tests + +reliab7_5_test.py +------------------------------ + +This script is a light-weight version of the legacy TET stress test called "Reliabilty 15". This test consists of two MMR Masters, and a 5000 entry database. The test starts off with two threads doing unindexed searchesi(1 for each master). These do not exit untl the entire test completes. Then while the unindexed searches are going on, the test performs a set of adds, mods, deletes, and modrdns on each master at the same time. It performs this set of operations 1000 times. The main goal of this script is to test stablilty, replication convergence, and memory growth/fragmentation. + +Known issue: the server can deadlock in the libdb4 code while performing modrdns(under investigation via https://fedorahosted.org/389/ticket/48166) diff --git a/dirsrvtests/stress/__init__.py b/dirsrvtests/stress/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/dirsrvtests/stress/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/dirsrvtests/stress/reliabilty/__init__.py b/dirsrvtests/stress/reliabilty/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/dirsrvtests/stress/reliabilty/reliab_7_5_test.py b/dirsrvtests/stress/reliabilty/reliab_7_5_test.py new file mode 100644 index 000000000..b827033be --- /dev/null +++ b/dirsrvtests/stress/reliabilty/reliab_7_5_test.py @@ -0,0 +1,570 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2015 Red Hat, Inc. +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- + +import sys +import time +import ldap +import logging +import pytest +import threading +import random +from lib389 import DirSrv, Entry +from lib389._constants import * +from lib389.properties import * +from lib389.tasks import * +from lib389.utils import * + +logging.getLogger(__name__).setLevel(logging.DEBUG) +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s' + + ' - %(message)s') +handler = logging.StreamHandler() +handler.setFormatter(formatter) +log = logging.getLogger(__name__) +log.addHandler(handler) + +installation1_prefix = None +NUM_USERS = 5000 +MAX_PASSES = 1000 +CHECK_CONVERGENCE = True +ENABLE_VALGRIND = False +RUNNING = True + + +class TopologyReplication(object): + def __init__(self, master1, master2): + master1.open() + self.master1 = master1 + master2.open() + self.master2 = master2 + + [email protected](scope="module") +def topology(request): + global installation1_prefix + if installation1_prefix: + args_instance[SER_DEPLOYED_DIR] = installation1_prefix + + # Creating master 1... + master1 = DirSrv(verbose=True) + 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... + 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) + + # + # Create all the agreements + # + # Creating agreement from master 1 to master 2 + properties = {RA_NAME: r'meTo_$host:$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("%s created" % m1_m2_agmt) + + # Creating agreement from master 2 to master 1 + properties = {RA_NAME: r'meTo_$host:$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("%s created" % m2_m1_agmt) + + # Allow the replicas to get situated with the new agreements... + time.sleep(5) + + # + # Import tests entries into master1 before we initialize master2 + # + tmp_dir = master1.getDir(__file__, TMP_DIR) + + import_ldif = tmp_dir + '/rel7.5-entries.ldif' + + # First generate an ldif + try: + ldif = open(import_ldif, 'w') + except IOError as e: + log.fatal('Failed to create test ldif, error: %s - %s' % + (e.errno, e.strerror)) + assert False + + # Create the root node + ldif.write('dn: ' + DEFAULT_SUFFIX + '\n') + ldif.write('objectclass: top\n') + ldif.write('objectclass: domain\n') + ldif.write('dc: example\n') + ldif.write('\n') + + # Create the entries + idx = 0 + while idx < NUM_USERS: + count = str(idx) + ldif.write('dn: uid=master1_entry' + count + ',' + + DEFAULT_SUFFIX + '\n') + ldif.write('objectclass: top\n') + ldif.write('objectclass: person\n') + ldif.write('objectclass: inetorgperson\n') + ldif.write('objectclass: organizationalperson\n') + ldif.write('uid: master1_entry' + count + '\n') + ldif.write('cn: master1 entry' + count + '\n') + ldif.write('givenname: master1 ' + count + '\n') + ldif.write('sn: entry ' + count + '\n') + ldif.write('userpassword: master1_entry' + count + '\n') + ldif.write('description: ' + 'a' * random.randint(1, 1000) + '\n') + ldif.write('\n') + + ldif.write('dn: uid=master2_entry' + count + ',' + + DEFAULT_SUFFIX + '\n') + ldif.write('objectclass: top\n') + ldif.write('objectclass: person\n') + ldif.write('objectclass: inetorgperson\n') + ldif.write('objectclass: organizationalperson\n') + ldif.write('uid: master2_entry' + count + '\n') + ldif.write('cn: master2 entry' + count + '\n') + ldif.write('givenname: master2 ' + count + '\n') + ldif.write('sn: entry ' + count + '\n') + ldif.write('userpassword: master2_entry' + count + '\n') + ldif.write('description: ' + 'a' * random.randint(1, 1000) + '\n') + ldif.write('\n') + idx += 1 + + ldif.close() + + # Now import it + try: + master1.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, + args={TASK_WAIT: True}) + except ValueError: + log.fatal('test_reliab_7.5: Online import failed') + assert False + + # + # Initialize all the agreements + # + master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2) + master1.waitForReplInit(m1_m2_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__) + + # Delete each instance in the end + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin) + + return TopologyReplication(master1, master2) + + +class AddDelUsers(threading.Thread): + def __init__(self, inst, masterid): + threading.Thread.__init__(self) + self.daemon = True + self.inst = inst + self.id = masterid + + def run(self): + # Add 5000 entries + idx = 0 + RDN = 'uid=add_del_master_' + self.id + '-' + + conn = self.inst.openConnection() + while idx < NUM_USERS: + USER_DN = RDN + str(idx) + ',' + DEFAULT_SUFFIX + try: + conn.add_s(Entry((USER_DN, {'objectclass': + 'top extensibleObject'.split(), + 'uid': 'user' + str(idx), + 'cn': 'g' * random.randint(1, 500) + }))) + except ldap.LDAPError as e: + log.fatal('Add users to master ' + self.id + ' failed (' + + USER_DN + ') error: ' + e.message['desc']) + idx += 1 + conn.close() + + # Delete 5000 entries + conn = self.inst.openConnection() + idx = 0 + while idx < NUM_USERS: + USER_DN = RDN + str(idx) + ',' + DEFAULT_SUFFIX + try: + conn.delete_s(USER_DN) + except ldap.LDAPError as e: + log.fatal('Failed to delete (' + USER_DN + ') on master ' + + self.id + ': error ' + e.message['desc']) + idx += 1 + conn.close() + + +class ModUsers(threading.Thread): + # Do mods and modrdns + def __init__(self, inst, masterid): + threading.Thread.__init__(self) + self.daemon = True + self.inst = inst + self.id = masterid + + def run(self): + # Mod existing entries + conn = self.inst.openConnection() + idx = 0 + while idx < NUM_USERS: + USER_DN = ('uid=master' + self.id + '_entry' + str(idx) + ',' + + DEFAULT_SUFFIX) + try: + conn.modify(USER_DN, [(ldap.MOD_REPLACE, + 'givenname', + 'new givenname master1-' + str(idx))]) + except ldap.LDAPError as e: + log.fatal('Failed to modify (' + USER_DN + ') on master ' + + self.id + ': error ' + e.message['desc']) + idx += 1 + conn.close() + + # Modrdn existing entries + conn = self.inst.openConnection() + idx = 0 + while idx < NUM_USERS: + USER_DN = ('uid=master' + self.id + '_entry' + str(idx) + ',' + + DEFAULT_SUFFIX) + NEW_RDN = 'cn=master' + self.id + '_entry' + str(idx) + try: + conn.rename(USER_DN, NEW_RDN, delold=1) + except ldap.LDAPError as e: + log.error('Failed to modrdn (' + USER_DN + ') on master ' + + self.id + ': error ' + e.message['desc']) + idx += 1 + conn.close() + + # Undo modrdn to we can rerun this test + conn = self.inst.openConnection() + idx = 0 + while idx < NUM_USERS: + USER_DN = ('cn=master' + self.id + '_entry' + str(idx) + ',' + + DEFAULT_SUFFIX) + NEW_RDN = 'uid=master' + self.id + '_entry' + str(idx) + try: + conn.rename(USER_DN, NEW_RDN, delold=1) + except ldap.LDAPError as e: + log.error('Failed to modrdn (' + USER_DN + ') on master ' + + self.id + ': error ' + e.message['desc']) + idx += 1 + conn.close() + + +class DoSearches(threading.Thread): + # Search a master + def __init__(self, inst, masterid): + threading.Thread.__init__(self) + self.daemon = True + self.inst = inst + self.id = masterid + + def run(self): + # Equality + conn = self.inst.openConnection() + idx = 0 + while idx < NUM_USERS: + search_filter = ('(|(uid=master' + self.id + '_entry' + str(idx) + + ')(cn=master' + self.id + '_entry' + str(idx) + + '))') + try: + conn.search(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, search_filter) + except ldap.LDAPError as e: + log.fatal('Search Users: Search failed (%s): %s' % + (search_filter, e.message['desc'])) + conn.close() + return + + idx += 1 + conn.close() + + # Substring + conn = self.inst.openConnection() + idx = 0 + while idx < NUM_USERS: + search_filter = ('(|(uid=master' + self.id + '_entry' + str(idx) + + '*)(cn=master' + self.id + '_entry' + str(idx) + + '*))') + try: + conn.search(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, search_filter) + except ldap.LDAPError as e: + log.fatal('Search Users: Search failed (%s): %s' % + (search_filter, e.message['desc'])) + conn.close() + return + + idx += 1 + conn.close() + + +class DoFullSearches(threading.Thread): + # Search a master + def __init__(self, inst): + threading.Thread.__init__(self) + self.daemon = True + self.inst = inst + + def run(self): + global RUNNING + conn = self.inst.openConnection() + while RUNNING: + time.sleep(2) + try: + conn.search_s(DEFAULT_SUFFIX, + ldap.SCOPE_SUBTREE, + 'objectclass=top') + except ldap.LDAPError as e: + log.fatal('Full Search Users: Search failed (%s): %s' % + ('objectclass=*', e.message['desc'])) + conn.close() + assert False + + conn.close() + + +def test_reliab7_5_init(topology): + ''' + Reduce entry cache - to increase the cache churn + + Then process "reliability 15" type tests + ''' + + BACKEND_DN = 'cn=userroot,cn=ldbm database,cn=plugins,cn=config' + + # Update master 1 + try: + topology.master1.modify_s(BACKEND_DN, [(ldap.MOD_REPLACE, + 'nsslapd-cachememsize', + '512000'), + (ldap.MOD_REPLACE, + 'nsslapd-cachesize', + '500')]) + except ldap.LDAPError as e: + log.fatal('Failed to set cache settings: error ' + e.message['desc']) + assert False + + # Update master 2 + try: + topology.master2.modify_s(BACKEND_DN, [(ldap.MOD_REPLACE, + 'nsslapd-cachememsize', + '512000'), + (ldap.MOD_REPLACE, + 'nsslapd-cachesize', + '500')]) + except ldap.LDAPError as e: + log.fatal('Failed to set cache settings: error ' + e.message['desc']) + assert False + + # Restart the masters to pick up the new cache settings + topology.master1.stop(timeout=10) + topology.master2.stop(timeout=10) + + # This is the time to enable valgrind (if enabled) + if ENABLE_VALGRIND: + sbin_dir = get_sbin_dir(prefix=topology.master1.prefix) + valgrind_enable(sbin_dir) + + topology.master1.start(timeout=30) + topology.master2.start(timeout=30) + + +def test_reliab7_5_run(topology): + ''' + Starting issuing adds, deletes, mods, modrdns, and searches + ''' + global RUNNING + count = 1 + RUNNING = True + + # Start some searches to run through the entire stress test + fullSearch1 = DoFullSearches(topology.master1) + fullSearch1.start() + fullSearch2 = DoFullSearches(topology.master2) + fullSearch2.start() + + while count <= MAX_PASSES: + log.info('################## Reliabilty 7.5 Pass: %d' % count) + + # Master 1 + add_del_users1 = AddDelUsers(topology.master1, '1') + add_del_users1.start() + mod_users1 = ModUsers(topology.master1, '1') + mod_users1.start() + search1 = DoSearches(topology.master1, '1') + search1.start() + + # Master 2 + add_del_users2 = AddDelUsers(topology.master2, '2') + add_del_users2.start() + mod_users2 = ModUsers(topology.master2, '2') + mod_users2.start() + search2 = DoSearches(topology.master2, '2') + search2.start() + + # Search the masters + search3 = DoSearches(topology.master1, '1') + search3.start() + search4 = DoSearches(topology.master2, '2') + search4.start() + + # Wait for threads to finish + log.info('################## Waiting for threads to finish...') + add_del_users1.join() + mod_users1.join() + add_del_users2.join() + mod_users2.join() + log.info('################## Update threads finished.') + search1.join() + search2.join() + search3.join() + search4.join() + log.info('################## All threads finished.') + + # Allow some time for replication to catch up before firing + # off the next round of updates + time.sleep(5) + count += 1 + + # + # Wait for replication to converge + # + if CHECK_CONVERGENCE: + # Add an entry to each master, and wait for it to replicate + MASTER1_DN = 'uid=rel7.5-master1,' + DEFAULT_SUFFIX + MASTER2_DN = 'uid=rel7.5-master2,' + DEFAULT_SUFFIX + + # Master 1 + try: + topology.master1.add_s(Entry((MASTER1_DN, {'objectclass': + ['top', + 'extensibleObject'], + 'sn': '1', + 'cn': 'user 1', + 'uid': 'rel7.5-master1', + 'userpassword': + PASSWORD}))) + except ldap.LDAPError as e: + log.fatal('Failed to add replication test entry ' + MASTER1_DN + + ': error ' + e.message['desc']) + assert False + + log.info('################## Waiting for master 2 to converge...') + + while True: + entry = None + try: + entry = topology.master2.search_s(MASTER1_DN, + ldap.SCOPE_BASE, + 'objectclass=*') + except ldap.NO_SUCH_OBJECT: + pass + except ldap.LDAPError as e: + log.fatal('Search Users: Search failed (%s): %s' % + (MASTER1_DN, e.message['desc'])) + assert False + if entry: + break + time.sleep(5) + + log.info('################## Master 2 converged.') + + # Master 2 + try: + topology.master2.add_s( + Entry((MASTER2_DN, {'objectclass': ['top', + 'extensibleObject'], + 'sn': '1', + 'cn': 'user 1', + 'uid': 'rel7.5-master2', + 'userpassword': PASSWORD}))) + except ldap.LDAPError as e: + log.fatal('Failed to add replication test entry ' + MASTER1_DN + + ': error ' + e.message['desc']) + assert False + + log.info('################## Waiting for master 1 to converge...') + while True: + entry = None + try: + entry = topology.master1.search_s(MASTER2_DN, + ldap.SCOPE_BASE, + 'objectclass=*') + except ldap.NO_SUCH_OBJECT: + pass + except ldap.LDAPError as e: + log.fatal('Search Users: Search failed (%s): %s' % + (MASTER2_DN, e.message['desc'])) + assert False + if entry: + break + time.sleep(5) + + log.info('################## Master 1 converged.') + + # Stop the full searches + RUNNING = False + fullSearch1.join() + fullSearch2.join() + + if ENABLE_VALGRIND: + # We're done, disable valgrind... + sbin_dir = get_sbin_dir(prefix=topology.master1.prefix) + valgrind_disable(sbin_dir) + + +if __name__ == '__main__': + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE) diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index 6e4bc4818..68d7830ed 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -197,6 +197,14 @@ Requires: libtevent %description devel Development Libraries and headers for the 389 Directory Server base package. +%package tests +Summary: The lib389 Continuous Integration Tests +Group: Development/Libraries +Requires: python-lib389 + +%description tests +The lib389 CI tests that can be run against the Directory Server. + %prep %setup -q -n %{name}-%{version}%{?prerel} @@ -286,6 +294,13 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/plugins/*.la # make sure perl scripts have a proper shebang sed -i -e 's|#{{PERL-EXEC}}|#!/usr/bin/perl|' $RPM_BUILD_ROOT%{_datadir}/%{pkgname}/script-templates/template-*.pl +pushd ../%{name}-%{version}%{?prerel} +cp -r dirsrvtests $RPM_BUILD_ROOT/%{_sysconfdir}/%{pkgname} +find $RPM_BUILD_ROOT/%{_sysconfdir}/%{pkgname}/dirsrvtests -type f -name '*.pyc' -delete +find $RPM_BUILD_ROOT/%{_sysconfdir}/%{pkgname}/dirsrvtests -type f -name '*.pyo' -delete +find $RPM_BUILD_ROOT/%{_sysconfdir}/%{pkgname}/dirsrvtests -type d -name '__pycache__' -delete +popd + %clean rm -rf $RPM_BUILD_ROOT @@ -440,7 +455,15 @@ fi %{_libdir}/%{pkgname}/libjemalloc.so* %endif +%files tests +%defattr(-,root,root,-) +%doc LICENSE LICENSE.GPLv3+ +%{_sysconfdir}/%{pkgname}/dirsrvtests + %changelog +* Mon Dec 21 2015 Mark Reynolds <[email protected]> - 1.3.4.1-3 +- Ticket 48376 - Create subpackage for lib389 CI tests + * Mon Dec 14 2015 Mark Reynolds <[email protected]> - 1.3.4.1-2 - Ticket 48377 - Include the jemalloc library
0
6d23c816196b3cdf7af3928f988eb4e6f67c1c19
389ds/389-ds-base
Issue 6848 - AddressSanitizer: leak in do_search Bug Description: When there's a BER decoding error and the function goes to `free_and_return`, the `attrs` variable is not being freed because it's only freed if `!psearch || rc != 0 || err != 0`, but `err` is still 0 at that point. If we reach `free_and_return` from the `ber_scanf` error path, `attrs` was never set in the pblock with `slapi_pblock_set()`, so the `slapi_pblock_get()` call will not retrieve the potentially partially allocated `attrs` from the BER decoding. Fixes: https://github.com/389ds/389-ds-base/issues/6848 Reviewed by: @tbordaz, @droideck (Thanks!)
commit 6d23c816196b3cdf7af3928f988eb4e6f67c1c19 Author: Viktor Ashirov <[email protected]> Date: Mon Jul 7 22:01:09 2025 +0200 Issue 6848 - AddressSanitizer: leak in do_search Bug Description: When there's a BER decoding error and the function goes to `free_and_return`, the `attrs` variable is not being freed because it's only freed if `!psearch || rc != 0 || err != 0`, but `err` is still 0 at that point. If we reach `free_and_return` from the `ber_scanf` error path, `attrs` was never set in the pblock with `slapi_pblock_set()`, so the `slapi_pblock_get()` call will not retrieve the potentially partially allocated `attrs` from the BER decoding. Fixes: https://github.com/389ds/389-ds-base/issues/6848 Reviewed by: @tbordaz, @droideck (Thanks!) diff --git a/ldap/servers/slapd/search.c b/ldap/servers/slapd/search.c index e9b2c3670..f9d03c090 100644 --- a/ldap/servers/slapd/search.c +++ b/ldap/servers/slapd/search.c @@ -235,6 +235,7 @@ do_search(Slapi_PBlock *pb) log_search_access(pb, base, scope, fstr, "decoding error"); send_ldap_result(pb, LDAP_PROTOCOL_ERROR, NULL, NULL, 0, NULL); + err = 1; /* Make sure we free everything */ goto free_and_return; } @@ -420,8 +421,17 @@ free_and_return: if (!psearch || rc != 0 || err != 0) { slapi_ch_free_string(&fstr); slapi_filter_free(filter, 1); - slapi_pblock_get(pb, SLAPI_SEARCH_ATTRS, &attrs); - charray_free(attrs); /* passing NULL is fine */ + + /* Get attrs from pblock if it was set there, otherwise use local attrs */ + char **pblock_attrs = NULL; + slapi_pblock_get(pb, SLAPI_SEARCH_ATTRS, &pblock_attrs); + if (pblock_attrs != NULL) { + charray_free(pblock_attrs); /* Free attrs from pblock */ + slapi_pblock_set(pb, SLAPI_SEARCH_ATTRS, NULL); + } else if (attrs != NULL) { + /* Free attrs that were allocated but never put in pblock */ + charray_free(attrs); + } charray_free(gerattrs); /* passing NULL is fine */ /* * Fix for defect 526719 / 553356 : Persistent search op failed.
0
6054dfada0f2b203f2f25d01abdf43105677aaa4
389ds/389-ds-base
Issue 5842 - Add log buffering to audit log Description: Add log buffering to audit/auditfail logs. Since these logs are intertwined there is only one config setting for both logs: nsslapd-auditlog-logbuffering: on/off relates: https://github.com/389ds/389-ds-base/issues/5842 Reviewed by: spichugi(Thanks!)
commit 6054dfada0f2b203f2f25d01abdf43105677aaa4 Author: Mark Reynolds <[email protected]> Date: Wed Feb 28 13:37:09 2024 -0500 Issue 5842 - Add log buffering to audit log Description: Add log buffering to audit/auditfail logs. Since these logs are intertwined there is only one config setting for both logs: nsslapd-auditlog-logbuffering: on/off relates: https://github.com/389ds/389-ds-base/issues/5842 Reviewed by: spichugi(Thanks!) diff --git a/dirsrvtests/tests/suites/ds_logs/audit_log_test.py b/dirsrvtests/tests/suites/ds_logs/audit_log_test.py index baf2571c0..d7b93b2df 100644 --- a/dirsrvtests/tests/suites/ds_logs/audit_log_test.py +++ b/dirsrvtests/tests/suites/ds_logs/audit_log_test.py @@ -6,6 +6,7 @@ # See LICENSE for details. # --- END COPYRIGHT BLOCK --- +import ldap import logging import pytest import os @@ -113,7 +114,7 @@ def test_auditlog_bof(topo): inst.config.replace('nsslapd-auditlog-display-attrs', 'cn') users = UserAccounts(inst, DEFAULT_SUFFIX) - user = users.ensure_state(properties={ + users.ensure_state(properties={ 'uid': 'test_auditlog_bof', 'cn': 'A'*256, 'sn': 'user', @@ -124,10 +125,61 @@ def test_auditlog_bof(topo): time.sleep(1) assert inst.status() == True +def test_auditlog_buffering(topo, request): + """Test log buffering works as expected when on or off + + :id: 08f1ccf0-c1fb-4427-9300-24585e336ae7 + :setup: Standalone Instance + :steps: + 1. Set buffering on + 2. Make update and immediately check log (update should not be present) + 3. Make invalid update, failed update should not be in log + 4. Disable buffering + 5. Make update and immediately check log (update should be present) + 6. Make invalid update, both failed updates should be in log + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success + """ + + # Configure instance + inst = topo.standalone + inst.config.replace('nsslapd-auditlog-logging-enabled', 'on') + inst.config.replace('nsslapd-auditfaillog-logging-enabled', 'on') + inst.config.replace('nsslapd-auditlog-logbuffering', 'on') + inst.deleteAuditLogs() # Start with fresh set of logs + original_value = inst.config.get_attr_val_utf8('nsslapd-timelimit') + + # Make a good and bad update and check neither are logged + inst.config.replace('nsslapd-timelimit', '999') + with pytest.raises(ldap.UNWILLING_TO_PERFORM): + inst.config.replace('no_such_attr', 'blah') + time.sleep(1) + assert not inst.ds_audit_log.match("nsslapd-timelimit: 999") + assert not inst.ds_audit_log.match("result: 53") + + # Make a good and bad update and check both are logged + inst.config.replace('nsslapd-auditlog-logbuffering', 'off') + inst.config.replace('nsslapd-timelimit', '888') + with pytest.raises(ldap.UNWILLING_TO_PERFORM): + inst.config.replace('no_such_attr', 'nope') + time.sleep(1) + assert inst.ds_audit_log.match("nsslapd-timelimit: 888") + # Both failed updates should be present (easiest way to check log) + assert len(inst.ds_audit_log.match("result: 53")) == 2 + + # Reset timelimit just to be safe + def fin(): + inst.config.replace('nsslapd-timelimit', original_value) + request.addfinalizer(fin) + if __name__ == '__main__': # Run isolated # -s for DEBUG mode CURRENT_FILE = os.path.realpath(__file__) pytest.main(["-s", CURRENT_FILE]) - diff --git a/dirsrvtests/tests/suites/healthcheck/health_config_test.py b/dirsrvtests/tests/suites/healthcheck/health_config_test.py index 3f6406007..324f3c561 100644 --- a/dirsrvtests/tests/suites/healthcheck/health_config_test.py +++ b/dirsrvtests/tests/suites/healthcheck/health_config_test.py @@ -505,7 +505,7 @@ def test_healthcheck_unauth_binds(topology_st): inst.config.set("nsslapd-allow-unauthenticated-binds", "off") def test_healthcheck_accesslog_buffering(topology_st): - """Check if HealthCheck returns DSCLE0004 code when acccess log biffering + """Check if HealthCheck returns DSCLE0004 code when acccess log buffering is disabled :id: 5a6512fd-1c7b-4557-9278-45150423148b @@ -537,7 +537,7 @@ def test_healthcheck_accesslog_buffering(topology_st): inst.config.set("nsslapd-accesslog-logbuffering", "on") def test_healthcheck_securitylog_buffering(topology_st): - """Check if HealthCheck returns DSCLE0005 code when security log biffering + """Check if HealthCheck returns DSCLE0005 code when security log buffering is disabled :id: 9b84287a-e022-4bdc-8c65-2276b37371b5 @@ -568,6 +568,41 @@ def test_healthcheck_securitylog_buffering(topology_st): log.info('Reset nnsslapd-securitylog-logbuffering to on') inst.config.set("nsslapd-securitylog-logbuffering", "on") +def test_healthcheck_auditlog_buffering(topology_st): + """Check if HealthCheck returns DSCLE0006 code when audit log buffering + is disabled + + :id: f030c9f3-0ce7-4156-ba70-81ef3ac82867 + :setup: Standalone instance + :steps: + 1. Create DS instance + 2. Set nsslapd-auditlog-logbuffering to off + 3. Use HealthCheck without --json option + 4. Use HealthCheck with --json option + :expectedresults: + 1. Success + 2. Success + 3. Healthcheck reports DSCLE0006 + 4. Healthcheck reports DSCLE0006 + """ + + RET_CODE = 'DSCLE0006' + + inst = topology_st.standalone + enabled = inst.config.get_attr_val_utf8('nsslapd-auditlog-logging-enabled') + + log.info('nsslapd-auditlog-logbuffering to off') + inst.config.set('nsslapd-auditlog-logging-enabled', 'on') + inst.config.set('nsslapd-auditlog-logbuffering', 'off') + + run_healthcheck_and_flush_log(topology_st, inst, RET_CODE, json=False) + run_healthcheck_and_flush_log(topology_st, inst, RET_CODE, json=True) + + # reset setting + log.info('Reset nnsslapd-auditlog-logbuffering to on') + inst.config.set('nsslapd-auditlog-logbuffering', 'on') + inst.config.set('nsslapd-auditlog-logging-enabled', enabled) + if __name__ == '__main__': # Run isolated diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index a06cad4ba..24f4c972a 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -193,6 +193,7 @@ slapi_onoff_t init_securitylogbuffering; slapi_onoff_t init_external_libs_debug_enabled; slapi_onoff_t init_errorlog_logging_enabled; slapi_onoff_t init_auditlog_logging_enabled; +slapi_onoff_t init_auditlogbuffering; slapi_onoff_t init_auditlog_logging_hide_unhashed_pw; slapi_onoff_t init_auditfaillog_logging_enabled; slapi_onoff_t init_auditfaillog_logging_hide_unhashed_pw; @@ -832,6 +833,10 @@ static struct config_get_and_set NULL, 0, (void **)&global_slapdFrontendConfig.accesslogbuffering, CONFIG_ON_OFF, NULL, &init_accesslogbuffering, NULL}, + {CONFIG_AUDITLOG_BUFFERING_ATTRIBUTE, config_set_auditlogbuffering, + NULL, 0, + (void **)&global_slapdFrontendConfig.auditlogbuffering, + CONFIG_ON_OFF, NULL, &init_auditlogbuffering, NULL}, {CONFIG_SECURITYLOG_BUFFERING_ATTRIBUTE, config_set_securitylogbuffering, NULL, 0, (void **)&global_slapdFrontendConfig.securitylogbuffering, @@ -1922,6 +1927,7 @@ FrontendConfig_init(void) cfg->auditlog_exptimeunit = slapi_ch_strdup(SLAPD_INIT_LOG_EXPTIMEUNIT); init_auditlog_logging_hide_unhashed_pw = cfg->auditlog_logging_hide_unhashed_pw = LDAP_ON; + init_auditlogbuffering = cfg->auditlogbuffering = LDAP_ON; init_auditlog_compress_enabled = cfg->auditlog_compress = LDAP_OFF; init_auditfaillog_logging_enabled = cfg->auditfaillog_logging_enabled = LDAP_OFF; @@ -7786,6 +7792,21 @@ config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, return retVal; } +int32_t +config_set_auditlogbuffering(const char *attrname, char *value, char *errorbuf, int apply) +{ + int32_t retVal = LDAP_SUCCESS; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + + retVal = config_set_onoff(attrname, + value, + &(slapdFrontendConfig->auditlogbuffering), + errorbuf, + apply); + + return retVal; +} + int32_t config_set_securitylogbuffering(const char *attrname, char *value, char *errorbuf, int apply) { diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index 4aa905576..d061a65bc 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -1,6 +1,6 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. + * Copyright (C) 2005-2024 Red Hat, Inc. * Copyright (C) 2010 Hewlett-Packard Development Company, L.P. * All rights reserved. * @@ -117,12 +117,15 @@ static PRInt64 log__getfilesize_with_filename(char *filename); static int log__enough_freespace(char *path); static int vslapd_log_error(LOGFD fp, int sev_level, const char *subsystem, const char *fmt, va_list ap, int locked); static int vslapd_log_access(const char *fmt, va_list ap); +static int vslapd_log_audit(const char *log_data); static int vslapd_log_security(const char *log_data); static void log_convert_time(time_t ctime, char *tbuf, int type); static time_t log_reverse_convert_time(char *tbuf); 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_append_security_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size); +static void log_append_audit_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size); +static void log_append_auditfail_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size); 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); @@ -440,10 +443,17 @@ g_log_init() loginfo.log_numof_audit_logs = 1; loginfo.log_audit_fdes = NULL; loginfo.log_audit_logchain = NULL; + loginfo.log_audit_buffer = log_create_buffer(LOG_BUFFER_MAXSIZE); loginfo.log_audit_compress = cfg->auditlog_compress; if ((loginfo.log_audit_rwlock = slapi_new_rwlock()) == NULL) { exit(-1); } + if (loginfo.log_audit_buffer == NULL) { + exit(-1); + } + if ((loginfo.log_audit_buffer->lock = PR_NewLock()) == NULL) { + exit(-1); + } /* AUDIT FAIL LOG */ loginfo.log_auditfail_state = cfg->auditfaillog_logging_enabled; @@ -468,11 +478,18 @@ g_log_init() loginfo.log_numof_auditfail_logs = 1; loginfo.log_auditfail_fdes = NULL; loginfo.log_auditfail_logchain = NULL; + loginfo.log_auditfail_buffer = log_create_buffer(LOG_BUFFER_MAXSIZE); loginfo.log_backend = LOGGING_BACKEND_INTERNAL; loginfo.log_auditfail_compress = cfg->auditfaillog_compress; if ((loginfo.log_auditfail_rwlock = slapi_new_rwlock()) == NULL) { exit(-1); } + if (loginfo.log_auditfail_buffer == NULL) { + exit(-1); + } + if ((loginfo.log_auditfail_buffer->lock = PR_NewLock()) == NULL) { + exit(-1); + } CFG_UNLOCK_READ(cfg); } @@ -2397,6 +2414,36 @@ auditfail_log_openf(char *pathname, int locked) /****************************************************************************** * write in the audit log ******************************************************************************/ +static int +vslapd_log_audit(const char *log_data) +{ + char buffer[SLAPI_LOG_BUFSIZ]; + time_t tnl; + int32_t blen = TBUFSIZE; + int32_t rc = LDAP_SUCCESS; + +#ifdef SYSTEMTAP + STAP_PROBE(ns-slapd, vslapd_log_audit__entry); +#endif + + /* We do this sooner, because that we can use the message in other calls */ + if ((blen = PR_snprintf(buffer, SLAPI_LOG_BUFSIZ, "%s\n", log_data)) == -1) { + log__error_emergency("vslapd_log_audit, Unable to format message", 1, 0); + return -1; + } + +#ifdef SYSTEMTAP + STAP_PROBE(ns-slapd, vslapd_log_audit__prepared); +#endif + tnl = slapi_current_utc_time(); + log_append_audit_buffer(tnl, loginfo.log_audit_buffer, buffer, blen); + +#ifdef SYSTEMTAP + STAP_PROBE(ns-slapd, vslapd_log_audit__buffer); +#endif + + return (rc); +} int slapd_log_audit( @@ -2408,18 +2455,8 @@ slapd_log_audit( int retval = LDAP_SUCCESS; int lbackend = loginfo.log_backend; /* We copy this to make these next checks atomic */ - int *state; - if (sourcelog == SLAPD_AUDIT_LOG) { - state = &loginfo.log_audit_state; - } else if (sourcelog == SLAPD_AUDITFAIL_LOG) { - state = &loginfo.log_auditfail_state; - } else { - /* How did we even get here! */ - return 1; - } - if (lbackend & LOGGING_BACKEND_INTERNAL) { - retval = slapd_log_audit_internal(buffer, buf_len, state); + retval = vslapd_log_audit(buffer); } if (retval != LDAP_SUCCESS) { @@ -2437,39 +2474,76 @@ slapd_log_audit( return retval; } -int -slapd_log_audit_internal( - char *buffer, - int buf_len, - int *state) +static void +log_append_audit_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size) { - if ((*state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL)) { - LOG_AUDIT_LOCK_WRITE(); - if (log__needrotation(loginfo.log_audit_fdes, - SLAPD_AUDIT_LOG) == LOG_ROTATE) { - if (log__open_auditlogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, "slapd_log_audit_internal", - "Unable to open audit file:%s\n", loginfo.log_audit_file); - LOG_AUDIT_UNLOCK_WRITE(); - return 0; - } - while (loginfo.log_audit_rotationsyncclock <= loginfo.log_audit_ctime) { - loginfo.log_audit_rotationsyncclock += PR_ABS(loginfo.log_audit_rotationtime_secs); - } - } - if (*state & LOGGING_NEED_TITLE) { - log_write_title(loginfo.log_audit_fdes); - *state &= ~LOGGING_NEED_TITLE; - } - LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, buffer, buf_len, 0); - LOG_AUDIT_UNLOCK_WRITE(); - return 0; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + char *insert_point = NULL; + + /* While holding the lock, we determine if there is space in the buffer for our payload, + and if we need to flush. + */ + PR_Lock(lbi->lock); + if (((lbi->current - lbi->top) + size > lbi->maxsize) || + (tnl >= loginfo.log_audit_rotationsyncclock && + loginfo.log_audit_rotationsync_enabled)) + { + log_flush_buffer(lbi, SLAPD_AUDIT_LOG, 0 /* do not sync to disk */); + } + insert_point = lbi->current; + lbi->current += size; + /* Increment the copy refcount */ + slapi_atomic_incr_64(&(lbi->refcount), __ATOMIC_RELEASE); + PR_Unlock(lbi->lock); + + /* Now we can copy without holding the lock */ + memcpy(insert_point, msg, size); + + /* Decrement the copy refcount */ + slapi_atomic_decr_64(&(lbi->refcount), __ATOMIC_RELEASE); + + /* If we are asked to sync to disk immediately, do so */ + if (!slapdFrontendConfig->auditlogbuffering) { + PR_Lock(lbi->lock); + log_flush_buffer(lbi, SLAPD_AUDIT_LOG, 1 /* sync to disk now */); + PR_Unlock(lbi->lock); } - return 0; } + /****************************************************************************** * write in the audit fail log ******************************************************************************/ +static int +vslapd_log_auditfail(const char *log_data) +{ + char buffer[SLAPI_LOG_BUFSIZ]; + time_t tnl; + int32_t blen = TBUFSIZE; + int32_t rc = LDAP_SUCCESS; + +#ifdef SYSTEMTAP + STAP_PROBE(ns-slapd, vslapd_log_auditfail__entry); +#endif + + /* We do this sooner, because that we can use the message in other calls */ + if ((blen = PR_snprintf(buffer, SLAPI_LOG_BUFSIZ, "%s\n", log_data)) == -1) { + log__error_emergency("vslapd_log_auditfail, Unable to format message", 1, 0); + return -1; + } + +#ifdef SYSTEMTAP + STAP_PROBE(ns-slapd, vslapd_log_auditfail__prepared); +#endif + tnl = slapi_current_utc_time(); + log_append_auditfail_buffer(tnl, loginfo.log_auditfail_buffer, buffer, blen); + +#ifdef SYSTEMTAP + STAP_PROBE(ns-slapd, vslapd_log_auditfail__buffer); +#endif + + return (rc); +} + int slapd_log_auditfail( char *buffer, @@ -2479,7 +2553,7 @@ slapd_log_auditfail( int retval = LDAP_SUCCESS; int lbackend = loginfo.log_backend; /* We copy this to make these next checks atomic */ if (lbackend & LOGGING_BACKEND_INTERNAL) { - retval = slapd_log_auditfail_internal(buffer, buf_len); + retval = vslapd_log_auditfail(buffer); } if (retval != LDAP_SUCCESS) { return retval; @@ -2496,35 +2570,42 @@ slapd_log_auditfail( return retval; } -int -slapd_log_auditfail_internal( - char *buffer, - int buf_len) +static void +log_append_auditfail_buffer(time_t tnl, LogBufferInfo *lbi, char *msg, size_t size) { - if ((loginfo.log_auditfail_state & LOGGING_ENABLED) && (loginfo.log_auditfail_file != NULL)) { - LOG_AUDITFAIL_LOCK_WRITE(); - if (log__needrotation(loginfo.log_auditfail_fdes, - SLAPD_AUDITFAIL_LOG) == LOG_ROTATE) { - if (log__open_auditfaillogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) { - slapi_log_err(SLAPI_LOG_ERR, "slapd_log_auditfail_internal", - "Unable to open auditfail file:%s\n", loginfo.log_auditfail_file); - LOG_AUDITFAIL_UNLOCK_WRITE(); - return 0; - } - while (loginfo.log_auditfail_rotationsyncclock <= loginfo.log_auditfail_ctime) { - loginfo.log_auditfail_rotationsyncclock += PR_ABS(loginfo.log_auditfail_rotationtime_secs); - } - } - if (loginfo.log_auditfail_state & LOGGING_NEED_TITLE) { - log_write_title(loginfo.log_auditfail_fdes); - loginfo.log_auditfail_state &= ~LOGGING_NEED_TITLE; - } - LOG_WRITE_NOW_NO_ERR(loginfo.log_auditfail_fdes, buffer, buf_len, 0); - LOG_AUDITFAIL_UNLOCK_WRITE(); - return 0; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + char *insert_point = NULL; + + /* While holding the lock, we determine if there is space in the buffer for our payload, + and if we need to flush. + */ + PR_Lock(lbi->lock); + if (((lbi->current - lbi->top) + size > lbi->maxsize) || + (tnl >= loginfo.log_auditfail_rotationsyncclock && + loginfo.log_auditfail_rotationsync_enabled)) + { + log_flush_buffer(lbi, SLAPD_AUDITFAIL_LOG, 0 /* do not sync to disk */); + } + insert_point = lbi->current; + lbi->current += size; + /* Increment the copy refcount */ + slapi_atomic_incr_64(&(lbi->refcount), __ATOMIC_RELEASE); + PR_Unlock(lbi->lock); + + /* Now we can copy without holding the lock */ + memcpy(insert_point, msg, size); + + /* Decrement the copy refcount */ + slapi_atomic_decr_64(&(lbi->refcount), __ATOMIC_RELEASE); + + /* If we are asked to sync to disk immediately, do so */ + if (!slapdFrontendConfig->auditlogbuffering) { + PR_Lock(lbi->lock); + log_flush_buffer(lbi, SLAPD_AUDITFAIL_LOG, 1 /* sync to disk now */); + PR_Unlock(lbi->lock); } - return 0; } + /****************************************************************************** * write in the error log ******************************************************************************/ @@ -6605,6 +6686,78 @@ log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now) lbi->current - lbi->top, 0); } lbi->current = lbi->top; + } else if (type == SLAPD_AUDIT_LOG) { + /* It is only safe to flush once any other threads which are copying are finished */ + while (slapi_atomic_load_64(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) { + /* It's ok to sleep for a while because we only flush every second or so */ + DS_Sleep(PR_MillisecondsToInterval(1)); + } + + if ((lbi->current - lbi->top) == 0) { + return; + } + + if (log__needrotation(loginfo.log_audit_fdes, SLAPD_AUDIT_LOG) == LOG_ROTATE) { + if (log__open_auditlogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) { + slapi_log_err(SLAPI_LOG_ERR, + "log_flush_buffer", "Unable to open audit file:%s\n", + loginfo.log_audit_file); + lbi->current = lbi->top; /* reset counter to prevent overwriting rest of lbi struct */ + return; + } + while (loginfo.log_audit_rotationsyncclock <= loginfo.log_audit_ctime) { + loginfo.log_audit_rotationsyncclock += PR_ABS(loginfo.log_audit_rotationtime_secs); + } + } + + if (loginfo.log_audit_state & LOGGING_NEED_TITLE) { + log_write_title(loginfo.log_audit_fdes); + loginfo.log_audit_state &= ~LOGGING_NEED_TITLE; + } + + if (!sync_now && slapdFrontendConfig->auditlogbuffering) { + LOG_WRITE(loginfo.log_audit_fdes, lbi->top, lbi->current - lbi->top, 0); + } else { + LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, lbi->top, + lbi->current - lbi->top, 0); + } + lbi->current = lbi->top; + } else if (type == SLAPD_AUDITFAIL_LOG) { + /* It is only safe to flush once any other threads which are copying are finished */ + while (slapi_atomic_load_64(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) { + /* It's ok to sleep for a while because we only flush every second or so */ + DS_Sleep(PR_MillisecondsToInterval(1)); + } + + if ((lbi->current - lbi->top) == 0) { + return; + } + + if (log__needrotation(loginfo.log_auditfail_fdes, SLAPD_AUDITFAIL_LOG) == LOG_ROTATE) { + if (log__open_auditfaillogfile(LOGFILE_NEW, 1) != LOG_SUCCESS) { + slapi_log_err(SLAPI_LOG_ERR, + "log_flush_buffer", "Unable to open auditfail file:%s\n", + loginfo.log_audit_file); + lbi->current = lbi->top; /* reset counter to prevent overwriting rest of lbi struct */ + return; + } + while (loginfo.log_auditfail_rotationsyncclock <= loginfo.log_auditfail_ctime) { + loginfo.log_auditfail_rotationsyncclock += PR_ABS(loginfo.log_auditfail_rotationtime_secs); + } + } + + if (loginfo.log_auditfail_state & LOGGING_NEED_TITLE) { + log_write_title(loginfo.log_auditfail_fdes); + loginfo.log_auditfail_state &= ~LOGGING_NEED_TITLE; + } + + if (!sync_now && slapdFrontendConfig->auditlogbuffering) { + LOG_WRITE(loginfo.log_auditfail_fdes, lbi->top, lbi->current - lbi->top, 0); + } else { + LOG_WRITE_NOW_NO_ERR(loginfo.log_auditfail_fdes, lbi->top, + lbi->current - lbi->top, 0); + } + lbi->current = lbi->top; } } @@ -6619,6 +6772,14 @@ logs_flush() log_flush_buffer(loginfo.log_security_buffer, SLAPD_SECURITY_LOG, 1 /* sync to disk now */); LOG_SECURITY_UNLOCK_WRITE(); + LOG_AUDIT_LOCK_WRITE(); + log_flush_buffer(loginfo.log_audit_buffer, SLAPD_AUDIT_LOG, + 1 /* sync to disk now */); + LOG_AUDIT_UNLOCK_WRITE(); + LOG_AUDITFAIL_LOCK_WRITE(); + log_flush_buffer(loginfo.log_auditfail_buffer, SLAPD_AUDITFAIL_LOG, + 1 /* sync to disk now */); + LOG_AUDITFAIL_UNLOCK_WRITE(); } /* diff --git a/ldap/servers/slapd/log.h b/ldap/servers/slapd/log.h index f06161d50..651a81e13 100644 --- a/ldap/servers/slapd/log.h +++ b/ldap/servers/slapd/log.h @@ -1,6 +1,6 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2022 Red Hat, Inc. + * Copyright (C) 2022-2024 Red Hat, Inc. * All rights reserved. * * License: GPL (version 3 or any later version). @@ -210,6 +210,7 @@ struct logging_opts char *log_auditinfo_file; /* audit log rotation info file */ Slapi_RWLock *log_audit_rwlock; /* lock on audit*/ int log_audit_compress; /* Compress rotated logs */ + LogBufferInfo *log_audit_buffer; /* buffer for access log */ /* These are auditfail log specific */ int log_auditfail_state; @@ -236,6 +237,7 @@ struct logging_opts char *log_auditfailinfo_file; /* auditfail log rotation info file */ Slapi_RWLock *log_auditfail_rwlock; /* lock on auditfail */ int log_auditfail_compress; /* Compress rotated logs */ + LogBufferInfo *log_auditfail_buffer; /* buffer for access log */ int log_backend; }; diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 59d484e33..214f2e609 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -384,6 +384,7 @@ int config_set_minssf(const char *attrname, char *value, char *errorbuf, int app int config_set_minssf_exclude_rootdse(const char *attrname, char *value, char *errorbuf, int apply); int config_set_validate_cert_switch(const char *attrname, char *value, char *errorbuf, int apply); int config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply); +int config_set_auditlogbuffering(const char *attrname, char *value, char *errorbuf, int apply); int config_set_securitylogbuffering(const char *attrname, char *value, char *errorbuf, int apply); int config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply); int config_set_force_sasl_external(const char *attrname, char *value, char *errorbuf, int apply); diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index a2a9af271..b1fe6cb2a 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -2301,6 +2301,7 @@ typedef struct _slapdEntryPoints #define CONFIG_PW_SEND_EXPIRING "passwordSendExpiringTime" #define CONFIG_ACCESSLOG_BUFFERING_ATTRIBUTE "nsslapd-accesslog-logbuffering" #define CONFIG_SECURITYLOG_BUFFERING_ATTRIBUTE "nsslapd-securitylog-logbuffering" +#define CONFIG_AUDITLOG_BUFFERING_ATTRIBUTE "nsslapd-auditlog-logbuffering" #define CONFIG_CSNLOGGING_ATTRIBUTE "nsslapd-csnlogging" #define CONFIG_RETURN_EXACT_CASE_ATTRIBUTE "nsslapd-return-exact-case" #define CONFIG_RESULT_TWEAK_ATTRIBUTE "nsslapd-result-tweak" @@ -2584,6 +2585,7 @@ typedef struct _slapdFrontendConfig int auditlog_exptime; char *auditlog_exptimeunit; slapi_onoff_t auditlog_logging_hide_unhashed_pw; + slapi_onoff_t auditlogbuffering; slapi_onoff_t auditlog_compress; /* AUDIT FAIL LOG */ diff --git a/src/cockpit/389-console/src/lib/server/auditLog.jsx b/src/cockpit/389-console/src/lib/server/auditLog.jsx index 862d8f19b..3fcd6fbaf 100644 --- a/src/cockpit/389-console/src/lib/server/auditLog.jsx +++ b/src/cockpit/389-console/src/lib/server/auditLog.jsx @@ -35,6 +35,7 @@ import PropTypes from "prop-types"; const settings_attrs = [ 'nsslapd-auditlog', 'nsslapd-auditlog-logging-enabled', + 'nsslapd-auditlog-logbuffering', ]; const rotation_attrs = [ @@ -79,7 +80,7 @@ export class ServerAuditLog extends React.Component { attrs: this.props.attrs, displayAttrs: [], isDisplayAttrOpen: false, - attributes: [], + attributes: this.props.displayAttrs, displayAllAttrs: false, }; @@ -152,36 +153,12 @@ export class ServerAuditLog extends React.Component { componentDidMount() { // Loading config if (!this.state.loaded) { - this.getAttributes(); + this.loadConfig(); } else { this.props.enableTree(); } } - getAttributes() { - const attr_cmd = [ - "dsconf", - "-j", - "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket", - "schema", - "attributetypes", - "list" - ]; - log_cmd("getAttributes", "Get attributes for audit log display attributes", attr_cmd); - cockpit - .spawn(attr_cmd, { superuser: true, err: "message" }) - .done(content => { - const attrContent = JSON.parse(content); - const attrs = []; - for (const content of attrContent.items) { - attrs.push(content.name[0]); - } - this.setState({ - attributes: attrs, - }, () => { this.loadConfig() }); - }); - } - validateSaveBtn(nav_tab, attr, value) { let disableSaveBtn = true; let disableBtnName = ""; @@ -365,6 +342,7 @@ export class ServerAuditLog extends React.Component { const attrs = config.attrs; let enabled = false; let compressed = false; + let buffering = false; let display_attrs = []; let displayAllAttrs = this.state.displayAllAttrs; @@ -374,6 +352,9 @@ export class ServerAuditLog extends React.Component { if (attrs['nsslapd-auditlog-compress'][0] === "on") { compressed = true; } + if (attrs['nsslapd-auditlog-logbuffering'][0] === "on") { + buffering = true; + } if ('nsslapd-auditlog-display-attrs' in attrs) { if (attrs['nsslapd-auditlog-display-attrs'][0] === "*") { displayAllAttrs = true; @@ -403,6 +384,7 @@ export class ServerAuditLog extends React.Component { 'nsslapd-auditlog-maxlogsize': attrs['nsslapd-auditlog-maxlogsize'][0], 'nsslapd-auditlog-maxlogsperdir': attrs['nsslapd-auditlog-maxlogsperdir'][0], 'nsslapd-auditlog-compress': compressed, + 'nsslapd-auditlog-logbuffering': buffering, displayAttrs: display_attrs, displayAllAttrs, // Record original values @@ -420,6 +402,7 @@ export class ServerAuditLog extends React.Component { '_nsslapd-auditlog-maxlogsize': attrs['nsslapd-auditlog-maxlogsize'][0], '_nsslapd-auditlog-maxlogsperdir': attrs['nsslapd-auditlog-maxlogsperdir'][0], '_nsslapd-auditlog-compress': compressed, + '_nsslapd-auditlog-logbuffering': buffering, _displayAttrs: display_attrs, _displayAllAttrs: displayAllAttrs, }); @@ -441,6 +424,7 @@ export class ServerAuditLog extends React.Component { const attrs = this.state.attrs; let enabled = false; let compressed = false; + let buffering = false; let display_attrs = []; let displayAllAttrs = this.state.displayAllAttrs; @@ -450,6 +434,9 @@ export class ServerAuditLog extends React.Component { if (attrs['nsslapd-auditlog-compress'][0] === "on") { compressed = true; } + if (attrs['nsslapd-auditlog-logbuffering'][0] === "on") { + buffering = true; + } if ('nsslapd-auditlog-display-attrs' in attrs) { if (attrs['nsslapd-auditlog-display-attrs'][0] === "*") { @@ -479,6 +466,7 @@ export class ServerAuditLog extends React.Component { 'nsslapd-auditlog-maxlogsize': attrs['nsslapd-auditlog-maxlogsize'][0], 'nsslapd-auditlog-maxlogsperdir': attrs['nsslapd-auditlog-maxlogsperdir'][0], 'nsslapd-auditlog-compress': compressed, + 'nsslapd-auditlog-logbuffering': buffering, displayAttrs: display_attrs, displayAllAttrs, // Record original values, @@ -496,6 +484,7 @@ export class ServerAuditLog extends React.Component { '_nsslapd-auditlog-maxlogsize': attrs['nsslapd-auditlog-maxlogsize'][0], '_nsslapd-auditlog-maxlogsperdir': attrs['nsslapd-auditlog-maxlogsperdir'][0], '_nsslapd-auditlog-compress': compressed, + '_nsslapd-auditlog-logbuffering': buffering, _displayAttrs: display_attrs, _displayAllAttrs: displayAllAttrs, }, this.props.enableTree); @@ -540,7 +529,7 @@ export class ServerAuditLog extends React.Component { title={_("Enable audit logging (nsslapd-auditlog-logging-enabled).")} label={_("Enable Audit Logging")} /> - <Form className="ds-margin-top-xlg ds-margin-left" isHorizontal autoComplete="off"> + <Form className="ds-margin-top-lg ds-left-margin-md" isHorizontal autoComplete="off"> <FormGroup label={_("Audit Log Location")} fieldId="nsslapd-auditlog" @@ -558,7 +547,17 @@ export class ServerAuditLog extends React.Component { /> </FormGroup> </Form> - <Form className="ds-margin-top-lg ds-margin-left" isHorizontal autoComplete="off"> + <Checkbox + className="ds-left-margin-md ds-margin-top-lg" + id="nsslapd-auditlog-logbuffering" + isChecked={this.state['nsslapd-auditlog-logbuffering']} + onChange={(checked, e) => { + this.handleChange(e, "settings"); + }} + title={_("This applies to both the audit & auditfail logs. Disable audit log buffering for faster troubleshooting, but this will impact server performance (nsslapd-auditlog-logbuffering).")} + label={_("Audit Log Buffering Enabled")} + /> + <Form className="ds-margin-top-lg ds-left-margin-md" isHorizontal autoComplete="off"> <FormGroup label={_("Display Attributes")} fieldId="nsslapd-auditlog-display-attrs" @@ -886,9 +885,11 @@ ServerAuditLog.propTypes = { addNotification: PropTypes.func, serverId: PropTypes.string, attrs: PropTypes.object, + displayAttrs: PropTypes.array, }; ServerAuditLog.defaultProps = { serverId: "", attrs: {}, + displayAttrs: [], }; diff --git a/src/cockpit/389-console/src/lib/server/auditfailLog.jsx b/src/cockpit/389-console/src/lib/server/auditfailLog.jsx index 4eb40c791..f682e98b1 100644 --- a/src/cockpit/389-console/src/lib/server/auditfailLog.jsx +++ b/src/cockpit/389-console/src/lib/server/auditfailLog.jsx @@ -30,8 +30,6 @@ import PropTypes from "prop-types"; const settings_attrs = [ 'nsslapd-auditfaillog', - 'nsslapd-auditfaillog-level', - 'nsslapd-auditfaillog-logbuffering', 'nsslapd-auditfaillog-logging-enabled', ]; diff --git a/src/cockpit/389-console/src/server.jsx b/src/cockpit/389-console/src/server.jsx index 74777d1c2..f9c9c2586 100644 --- a/src/cockpit/389-console/src/server.jsx +++ b/src/cockpit/389-console/src/server.jsx @@ -43,6 +43,7 @@ export class Server extends React.Component { node_name: "settings-config", node_text: "", attrs: [], + displayAttrs: [], loaded: false, disableTree: false, activeItems: [ @@ -55,6 +56,7 @@ export class Server extends React.Component { }; this.loadTree = this.loadTree.bind(this); + this.getAttributes = this.getAttributes.bind(this); this.reloadConfig = this.reloadConfig.bind(this); this.enableTree = this.enableTree.bind(this); this.handleTreeClick = this.handleTreeClick.bind(this); @@ -74,6 +76,30 @@ export class Server extends React.Component { }); } + getAttributes() { + const attr_cmd = [ + "dsconf", + "-j", + "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket", + "schema", + "attributetypes", + "list" + ]; + log_cmd("getAttributes", "Get attributes for audit log display attributes", attr_cmd); + cockpit + .spawn(attr_cmd, { superuser: true, err: "message" }) + .done(content => { + const attrContent = JSON.parse(content); + const attrs = []; + for (const content of attrContent.items) { + attrs.push(content.name[0]); + } + this.setState({ + displayAttrs: attrs, + }); + }); + } + loadConfig() { this.setState({ loaded: false, @@ -198,7 +224,7 @@ export class Server extends React.Component { this.setState({ nodes: basicData, node_name: this.state.node_name - }); + }, this.getAttributes()); } handleTreeClick(evt, treeViewItem, parentItem) { @@ -290,6 +316,7 @@ export class Server extends React.Component { <ServerAuditLog serverId={this.props.serverId} attrs={this.state.attrs} + displayAttrs={this.state.displayAttrs} enableTree={this.enableTree} addNotification={this.props.addNotification} /> diff --git a/src/lib389/lib389/config.py b/src/lib389/lib389/config.py index 09056cee1..eaa8a94df 100644 --- a/src/lib389/lib389/config.py +++ b/src/lib389/lib389/config.py @@ -23,7 +23,7 @@ from lib389 import Entry from lib389._mapped_object import DSLdapObject from lib389.utils import ensure_bytes, selinux_label_port, selinux_present from lib389.lint import ( - DSCLE0001, DSCLE0002, DSCLE0003, DSCLE0004, DSCLE0005, DSELE0001 + DSCLE0001, DSCLE0002, DSCLE0003, DSCLE0004, DSCLE0005, DSCLE0006, DSELE0001 ) class Config(DSLdapObject): @@ -250,11 +250,21 @@ class Config(DSLdapObject): report['check'] = "config:accesslogbuffering" yield report + def _lint_auditlog_buffering(self): + # audit log buffering + enabled = self.get_attr_val_utf8_l('nsslapd-auditlog-logging-enabled') + buffering = self.get_attr_val_utf8_l('nsslapd-auditlog-logbuffering') + if enabled == "on" and buffering == "off": + report = copy.deepcopy(DSCLE0006) + report['fix'] = report['fix'].replace('YOUR_INSTANCE', self._instance.serverid) + report['check'] = "config:auditlogbuffering" + yield report def _lint_securitylog_buffering(self): # security log buffering + enabled = self.get_attr_val_utf8_l('nsslapd-securitylog-logging-enabled') buffering = self.get_attr_val_utf8_l('nsslapd-securitylog-logbuffering') - if buffering == "off": + if enabled == "on" and buffering == "off": report = copy.deepcopy(DSCLE0005) report['fix'] = report['fix'].replace('YOUR_INSTANCE', self._instance.serverid) report['check'] = "config:securitylogbuffering" diff --git a/src/lib389/lib389/lint.py b/src/lib389/lib389/lint.py index d4e7287e2..293bb3f44 100644 --- a/src/lib389/lib389/lint.py +++ b/src/lib389/lib389/lint.py @@ -155,6 +155,22 @@ You can use 'dsconf' to set this attribute. Here is an example: """ } +DSCLE0006 = { + 'dsle': 'DSCLE0006', + 'severity': 'LOW', + 'description': 'Audit Log buffering disabled', + 'items': ['cn=config', ], + 'detail': """nsslapd-auditlog-logbuffering is set to 'off' this will cause high +disk IO and it will impact server performance. This should only be used +for debug purposes +""", + 'fix': """Set nsslapd-auditlog-logbuffering to 'on'. +You can use 'dsconf' to set this attribute. Here is an example: + + # dsconf slapd-YOUR_INSTANCE config replace nsslapd-auditlog-logbuffering=on +""" +} + # Security checks DSELE0001 = { 'dsle': 'DSELE0001', diff --git a/src/lib389/lib389/topologies.py b/src/lib389/lib389/topologies.py index d6f0dadb3..626b5305b 100644 --- a/src/lib389/lib389/topologies.py +++ b/src/lib389/lib389/topologies.py @@ -124,6 +124,7 @@ def _create_instances(topo_dict, suffix): instance.use_ldap_uri() instance.open() instance.config.set('nsslapd-accesslog-logbuffering','off') + instance.config.set('nsslapd-auditlog-logbuffering','off') if role == ReplicaRole.STANDALONE: ins[instance.serverid] = instance instances.update(ins) @@ -528,7 +529,7 @@ def topology_m1h1c1(request): topo_roles = {ReplicaRole.SUPPLIER: 1, ReplicaRole.HUB: 1, ReplicaRole.CONSUMER: 1} topology = create_topology(topo_roles, request=request) - # Since topology implements timeout, create_topology supports hub + # Since topology implements timeout, create_topology supports hub # but hub and suppliers are fully meshed while historically this topology # did not have hub->master agreement. # ==> we must remove hub->master agmt that breaks some test (like promote_demote)
0
2e8fc55fcc185577d0973eae58f1f8f26cbd442b
389ds/389-ds-base
Bug 595874 - 99user.ldif getting overpopulated https://bugzilla.redhat.com/show_bug.cgi?id=595874 Resolves: bug 595874 Bug Description: 99user.ldif getting overpopulated Reviewed by: self Branch: HEAD Fix Description: The schema code was adding X-ORIGIN 'user defined' to all schema elements that had no X-ORIGIN. It should only add user defined to schema elements from the user defined schema file, not to schema defined in standard (read only) schema files. It looks like the code should work fine if the schema element has no origin, so there is no reason to add an origin for schema other than user defined schema. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no
commit 2e8fc55fcc185577d0973eae58f1f8f26cbd442b Author: Rich Megginson <[email protected]> Date: Wed May 26 12:18:34 2010 -0600 Bug 595874 - 99user.ldif getting overpopulated https://bugzilla.redhat.com/show_bug.cgi?id=595874 Resolves: bug 595874 Bug Description: 99user.ldif getting overpopulated Reviewed by: self Branch: HEAD Fix Description: The schema code was adding X-ORIGIN 'user defined' to all schema elements that had no X-ORIGIN. It should only add user defined to schema elements from the user defined schema file, not to schema defined in standard (read only) schema files. It looks like the code should work fine if the schema element has no origin, so there is no reason to add an origin for schema other than user defined schema. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c index 56c1b54cc..72c4898bf 100644 --- a/ldap/servers/slapd/schema.c +++ b/ldap/servers/slapd/schema.c @@ -2976,8 +2976,14 @@ read_oc_ldif ( const char *input, struct objclass **oc, char *errorbuf, if ( schema_ds4x_compat ) nextinput = input; /* look for X-ORIGIN list */ - oc_origins = parse_origin_list( nextinput, &num_origins, - schema_user_defined_origin ); + if (is_user_defined) { + /* add X-ORIGIN 'user defined' */ + oc_origins = parse_origin_list( nextinput, &num_origins, + schema_user_defined_origin ); + } else { + /* add nothing */ + oc_origins = parse_origin_list( nextinput, &num_origins, NULL ); + } /* set remaining flags */ if ( element_is_user_defined( oc_origins )) { @@ -3377,8 +3383,14 @@ read_at_ldif(const char *input, struct asyntaxinfo **asipp, char *errorbuf, if ( schema_ds4x_compat ) nextinput = input; /* X-ORIGIN list */ - attr_origins = parse_origin_list( nextinput, &num_origins, - schema_user_defined_origin ); + if (is_user_defined) { + /* add X-ORIGIN 'user defined' */ + attr_origins = parse_origin_list( nextinput, &num_origins, + schema_user_defined_origin ); + } else { + /* add nothing */ + attr_origins = parse_origin_list( nextinput, &num_origins, NULL ); + } /* Do some sanity checking to make sure everything was read correctly */ @@ -4561,9 +4573,11 @@ parse_origin_list( const char *schema_value, int *num_originsp, origins[i] = NULL; } +/* for debugging if ( origins == NULL || origins[0] == NULL ) { LDAPDebug( LDAP_DEBUG_ANY, "no origin (%s)\n", schema_value, 0, 0 ); } +*/ return origins; }
0
fed0d5e2dc11e9c25d1749f804fe6fbbd0f1ff13
389ds/389-ds-base
Always use the internal regex functions: checkin list in the AOL/RH move.
commit fed0d5e2dc11e9c25d1749f804fe6fbbd0f1ff13 Author: David Boreham <[email protected]> Date: Fri Jan 28 20:23:02 2005 +0000 Always use the internal regex functions: checkin list in the AOL/RH move. diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h index 506ab38d0..8577c550d 100644 --- a/ldap/servers/slapd/slapi-private.h +++ b/ldap/servers/slapd/slapi-private.h @@ -1141,10 +1141,12 @@ typedef char*(*CFP)(); void bervalarray_add_berval_fast(struct berval ***vals, const struct berval *addval, int nvals, int *maxvals); -int re_exec( char *lp ); -char *re_comp( char *pat ); -void re_lock( void ); -int re_unlock( void ); +int slapd_re_exec( char *lp ); +char *slapd_re_comp( char *pat ); +int slapd_re_subs( char *src, char* dst ); +void slapd_re_lock( void ); +int slapd_re_unlock( void ); +int slapd_re_init( void ); /* this is the root configuration entry beneath which all plugin
0
77e6044ee5e44fa86e44280d46f36d63a30458b0
389ds/389-ds-base
Ticket 48220 - The "repl-monitor" web page does not display "year" in date. Bug Description: The year is not displayed in the header when the day is less than 10. Appears to be an issue with localtime(). Fix Description: Instead of strftime for displaying the date. https://fedorahosted.org/389/ticket/48220 Reviewed by: nhosoi(Thanks!)
commit 77e6044ee5e44fa86e44280d46f36d63a30458b0 Author: Mark Reynolds <[email protected]> Date: Thu May 12 16:10:02 2016 -0400 Ticket 48220 - The "repl-monitor" web page does not display "year" in date. Bug Description: The year is not displayed in the header when the day is less than 10. Appears to be an issue with localtime(). Fix Description: Instead of strftime for displaying the date. https://fedorahosted.org/389/ticket/48220 Reviewed by: nhosoi(Thanks!) diff --git a/ldap/admin/src/scripts/repl-monitor.pl.in b/ldap/admin/src/scripts/repl-monitor.pl.in index a670610f7..0964ae06d 100755 --- a/ldap/admin/src/scripts/repl-monitor.pl.in +++ b/ldap/admin/src/scripts/repl-monitor.pl.in @@ -166,6 +166,7 @@ use Mozilla::LDAP::Conn; # LDAP module for Perl use Mozilla::LDAP::Utils qw(normalizeDN); # LULU, utilities. use Mozilla::LDAP::API qw(:api :ssl :apiv3 :constant); # Direct access to C API use Time::Local; # to convert GMT Z strings to localtime +use POSIX; # # Global variables @@ -206,7 +207,7 @@ my %ld; my ($opt_f, $opt_h, $opt_p, $opt_u, $opt_t, $opt_r, $opt_s); my (@conns, @alias, @color); -my ($section, $interval, $nowraw, $now, $mm, $dd, $tt, $yy, $wday); +my ($section, $interval, $now, $mm, $dd, $tt, $yy, $wday); my ($fn, $rc, $prompt, $last_sidx); my $supplierUrl = ""; my %passwords = (); @@ -242,9 +243,7 @@ $prompt = ""; $interval = 300 if ( !$interval || $interval <= 0 ); # Get current date/time - $nowraw = localtime(); - ($wday, $mm, $dd, $tt, $yy) = split(/ /, $nowraw); - $now = "$wday $mm $dd $yy $tt"; + $now = strftime "%a %b %e %Y %H:%M:%S", localtime; # if no -r (Reenter and skip html header), print html header if (!$opt_r) {
0
b036f9d942340a133cc54f44f037bb17fcf733e1
389ds/389-ds-base
Have to add back softokn3 to the link libs - dependent libs are linked directly against it and expect it to be present at link time.
commit b036f9d942340a133cc54f44f037bb17fcf733e1 Author: Rich Megginson <[email protected]> Date: Fri Feb 24 22:52:10 2006 +0000 Have to add back softokn3 to the link libs - dependent libs are linked directly against it and expect it to be present at link time. diff --git a/components.mk b/components.mk index 3deb3482e..464110cf1 100644 --- a/components.mk +++ b/components.mk @@ -218,13 +218,12 @@ endif SECURITY_INCLUDE = -I$(SECURITY_INCDIR) # add crlutil and ocspclnt when we support CRL and OCSP cert checking in DS SECURITY_BINNAMES = certutil derdump pp pk12util ssltap modutil shlibsign -# as of NSS 3.11, no longer need to link with softokn3 -SECURITY_LIBNAMES = ssl3 nss3 +SECURITY_LIBNAMES = ssl3 nss3 softokn3 # these libs have a corresponding .chk file SECURITY_NEED_CHK = softokn3 # these are the libs we need at runtime -SECURITY_LIBNAMES.pkg = $(SECURITY_LIBNAMES) smime3 softokn3 +SECURITY_LIBNAMES.pkg = $(SECURITY_LIBNAMES) smime3 # freebl for all platforms is new for NSS 3.11 # there are some platform specific versions as well
0
a9bc1d1d17c3e14d752422c77505701b0600b0fe
389ds/389-ds-base
fix build breakage - use PERLDAP_BUILT_DIR as the location to download perl since the full DEP has two directory levels in it
commit a9bc1d1d17c3e14d752422c77505701b0600b0fe Author: Rich Megginson <[email protected]> Date: Sat Sep 16 15:10:53 2006 +0000 fix build breakage - use PERLDAP_BUILT_DIR as the location to download perl since the full DEP has two directory levels in it diff --git a/internal_comp_deps.mk b/internal_comp_deps.mk index 011d1d9ac..c8b0d1174 100644 --- a/internal_comp_deps.mk +++ b/internal_comp_deps.mk @@ -551,7 +551,7 @@ $(PERLDAP_DEP): ifdef INTERNAL_BUILD $(RM) -rf $@ $(FTP_PULL) -method $(PERLDAP_PULL_METHOD) \ - -objdir $(dir $@) \ + -objdir $(PERLDAP_BUILT_DIR) \ -componentdir $(PERLDAP_COMPONENT_DIR) \ -files $(PERLDAP_FILES) @if [ ! -d $@ ] ; \
0
761dd658183106363379326490439e381894615f
389ds/389-ds-base
Issue 50545 - Port repl-monitor.pl to lib389 CLI Description: Add a new command to 'dsconf replication' CLI. 'dsconf replication monitor' generates a report which shows the replication topology to which the instance does belong. Additional arguments: -c or --connections [CONNECTION [CONNECTION ...]] The connection values for monitoring other not connected topologies. The format: 'host:port:binddn:bindpwd'. You can use regex for host and port. You can set bindpwd to * and it will be requested at the runtime or you can include the path to the password file in square brackets - [~/pwd.txt] -a or --aliases [ALIAS [ALIAS ...]] If a host:port is assigned an alias, then the alias instead of host:port will be displayed in the output. The format: alias=host:port Also, ~/.dsrc can be used for specifying the connections and aliases. [repl-monitor-connections] connection1 = server1.example.com:38901:cn=Directory manager:* connection2 = server2.example.com:38902:cn=Directory manager:[~/pwd.txt] connection3 = hub1.example.com:.*:cn=Directory manager:password [repl-monitor-aliases] M1 = server1.example.com:38901 M2 = server2.example.com:38902 https://pagure.io/389-ds-base/issue/50545 Reviewed by: mreynolds (Thanks!)
commit 761dd658183106363379326490439e381894615f Author: Simon Pichugin <[email protected]> Date: Wed Sep 11 20:21:17 2019 +0200 Issue 50545 - Port repl-monitor.pl to lib389 CLI Description: Add a new command to 'dsconf replication' CLI. 'dsconf replication monitor' generates a report which shows the replication topology to which the instance does belong. Additional arguments: -c or --connections [CONNECTION [CONNECTION ...]] The connection values for monitoring other not connected topologies. The format: 'host:port:binddn:bindpwd'. You can use regex for host and port. You can set bindpwd to * and it will be requested at the runtime or you can include the path to the password file in square brackets - [~/pwd.txt] -a or --aliases [ALIAS [ALIAS ...]] If a host:port is assigned an alias, then the alias instead of host:port will be displayed in the output. The format: alias=host:port Also, ~/.dsrc can be used for specifying the connections and aliases. [repl-monitor-connections] connection1 = server1.example.com:38901:cn=Directory manager:* connection2 = server2.example.com:38902:cn=Directory manager:[~/pwd.txt] connection3 = hub1.example.com:.*:cn=Directory manager:password [repl-monitor-aliases] M1 = server1.example.com:38901 M2 = server2.example.com:38902 https://pagure.io/389-ds-base/issue/50545 Reviewed by: mreynolds (Thanks!) diff --git a/src/lib389/cli/dsconf b/src/lib389/cli/dsconf index 22635ca5d..1940b8e6e 100755 --- a/src/lib389/cli/dsconf +++ b/src/lib389/cli/dsconf @@ -16,6 +16,7 @@ import sys import signal import json import ast +from lib389._constants import DSRC_HOME from lib389.cli_conf import config as cli_config from lib389.cli_conf import backend as cli_backend from lib389.cli_conf import directory_manager as cli_directory_manager @@ -109,7 +110,7 @@ if __name__ == '__main__': log.debug("Inspired by works of: ITS, The University of Adelaide") # Now that we have our args, see how they relate with our instance. - dsrc_inst = dsrc_to_ldap("~/.dsrc", args.instance, log.getChild('dsrc')) + dsrc_inst = dsrc_to_ldap(DSRC_HOME, args.instance, log.getChild('dsrc')) # Now combine this with our arguments dsrc_inst = dsrc_arg_concat(args, dsrc_inst) diff --git a/src/lib389/cli/dsidm b/src/lib389/cli/dsidm index aab6f6f10..7fd77b63d 100755 --- a/src/lib389/cli/dsidm +++ b/src/lib389/cli/dsidm @@ -15,6 +15,7 @@ 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 from lib389.cli_idm import organizationalunit as cli_ou @@ -96,7 +97,7 @@ if __name__ == '__main__': log.debug("Inspired by works of: ITS, The University of Adelaide") # Now that we have our args, see how they relate with our instance. - dsrc_inst = dsrc_to_ldap("~/.dsrc", args.instance, log.getChild('dsrc')) + dsrc_inst = dsrc_to_ldap(DSRC_HOME, args.instance, log.getChild('dsrc')) # Now combine this with our arguments diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py index a1fa6eedd..1ad72b5b1 100644 --- a/src/lib389/lib389/_constants.py +++ b/src/lib389/lib389/_constants.py @@ -346,4 +346,5 @@ args_instance = {SER_DEPLOYED_DIR: os.environ.get('PREFIX', None), # Helper for linking dse.ldif values to the parse_config function args_dse_keys = SER_PROPNAME_TO_ATTRNAME +DSRC_HOME = '~/.dsrc' DSRC_CONTAINER = '/data/config/container.inf' diff --git a/src/lib389/lib389/agreement.py b/src/lib389/lib389/agreement.py index 84e2f8c61..a9ee68c56 100644 --- a/src/lib389/lib389/agreement.py +++ b/src/lib389/lib389/agreement.py @@ -366,7 +366,7 @@ class Agreement(DSLdapObject): return (json.dumps(result)) else: retstr = ( - "Status for agreement: \"%(cn)s\" (%(nsDS5ReplicaHost)s:" + "Status For Agreement: \"%(cn)s\" (%(nsDS5ReplicaHost)s:" "%(nsDS5ReplicaPort)s)" "\n" "Replica Enabled: %(nsds5ReplicaEnabled)s" "\n" "Update In Progress: %(nsds5replicaUpdateInProgress)s" "\n" diff --git a/src/lib389/lib389/cli_base/dsrc.py b/src/lib389/lib389/cli_base/dsrc.py index 505651485..bbd160e8e 100644 --- a/src/lib389/lib389/cli_base/dsrc.py +++ b/src/lib389/lib389/cli_base/dsrc.py @@ -8,8 +8,10 @@ import sys import os +import json import ldap -from lib389.properties import * +from lib389.properties import (SER_LDAP_URL, SER_ROOT_DN, SER_LDAPI_ENABLED, + SER_LDAPI_SOCKET, SER_LDAPI_AUTOBIND) from lib389._constants import DSRC_CONTAINER MAJOR, MINOR, _, _, _ = sys.version_info @@ -17,6 +19,7 @@ MAJOR, MINOR, _, _, _ = sys.version_info if MAJOR >= 3: import configparser + def dsrc_arg_concat(args, dsrc_inst): """ Given a set of argparse args containing: @@ -65,6 +68,23 @@ def dsrc_arg_concat(args, dsrc_inst): dsrc_inst['starttls'] = True return dsrc_inst + +def _read_dsrc(path, log, case_sensetive=False): + path = os.path.expanduser(path) + log.debug("dsrc path: %s" % path) + log.debug("dsrc container path: %s" % DSRC_CONTAINER) + config = configparser.ConfigParser() + if case_sensetive: + config.optionxform = str + # First read our container config if it exists + # Then overlap the user config. + config.read([DSRC_CONTAINER, path]) + + log.debug("dsrc instances: %s" % config.sections()) + + return config + + def dsrc_to_ldap(path, instance_name, log): """ Given a path to a file, return the required details for an instance. @@ -84,15 +104,7 @@ def dsrc_to_ldap(path, instance_name, log): tls_reqcert = [never, hard, allow] starttls = [true, false] """ - path = os.path.expanduser(path) - log.debug("dsrc path: %s" % path) - log.debug("dsrc container path: %s" % DSRC_CONTAINER) - config = configparser.ConfigParser() - # First read our container config if it exists - # Then overlap the user config. - config.read([DSRC_CONTAINER, path]) - - log.debug("dsrc instances: %s" % config.sections()) + config = _read_dsrc(path, log) # Does our section exist? if not config.has_section(instance_name): @@ -109,14 +121,15 @@ def dsrc_to_ldap(path, instance_name, log): dsrc_inst['binddn'] = config.get(instance_name, 'binddn', fallback=None) dsrc_inst['saslmech'] = config.get(instance_name, 'saslmech', fallback=None) if dsrc_inst['saslmech'] is not None and dsrc_inst['saslmech'] not in ['EXTERNAL', 'PLAIN']: - raise Exception("~/.dsrc [%s] saslmech must be one of EXTERNAL or PLAIN" % instance_name) + raise Exception("%s [%s] saslmech must be one of EXTERNAL or PLAIN" % (path, instance_name)) dsrc_inst['tls_cacertdir'] = config.get(instance_name, 'tls_cacertdir', fallback=None) dsrc_inst['tls_cert'] = config.get(instance_name, 'tls_cert', fallback=None) dsrc_inst['tls_key'] = config.get(instance_name, 'tls_key', fallback=None) dsrc_inst['tls_reqcert'] = config.get(instance_name, 'tls_reqcert', fallback='hard') if dsrc_inst['tls_reqcert'] not in ['never', 'allow', 'hard']: - raise Exception("dsrc tls_reqcert value invalid. ~/.dsrc [%s] tls_reqcert should be one of never, allow or hard" % instance_name) + raise Exception("dsrc tls_reqcert value invalid. %s [%s] tls_reqcert should be one of never, allow or hard" % (instance_name, + path)) if dsrc_inst['tls_reqcert'] == 'never': dsrc_inst['tls_reqcert'] = ldap.OPT_X_TLS_NEVER elif dsrc_inst['tls_reqcert'] == 'allow': @@ -133,9 +146,45 @@ def dsrc_to_ldap(path, instance_name, log): dsrc_inst['args'][SER_LDAPI_SOCKET] = dsrc_inst['uri'][9:] dsrc_inst['args'][SER_LDAPI_AUTOBIND] = "on" - # Return the dict. log.debug("dsrc completed with %s" % dsrc_inst) return dsrc_inst +def dsrc_to_repl_monitor(path, log): + """ + Given a path to a file, return the required details for an instance. + + The connection values for monitoring other not connected topologies. The format: + 'host:port:binddn:bindpwd'. You can use regex for host and port. You can set bindpwd + to * and it will be requested at the runtime. + + If a host:port is assigned an alias, then the alias instead of host:port will be + displayed in the output. The format: "alias=host:port". + + The file should be an ini file, and instance should identify a section. + + The ini fileshould have the content: + + [repl-monitor-connections] + connection1 = server1.example.com:38901:cn=Directory manager:* + connection2 = server2.example.com:38902:cn=Directory manager:[~/pwd.txt] + connection3 = hub1.example.com:.*:cn=Directory manager:password + + [repl-monitor-aliases] + M1 = server1.example.com:38901 + M2 = server2.example.com:38902 + """ + + config = _read_dsrc(path, log, case_sensetive=True) + dsrc_repl_monitor = {"connections": None, + "aliases": None} + + if config.has_section("repl-monitor-connections"): + dsrc_repl_monitor["connections"] = [conn for _, conn in config.items("repl-monitor-connections")] + + if config.has_section("repl-monitor-aliases"): + dsrc_repl_monitor["aliases"] = {alias: inst for alias, inst in config.items("repl-monitor-aliases")} + + log.debug(f"dsrc completed with {dsrc_repl_monitor}") + return dsrc_repl_monitor diff --git a/src/lib389/lib389/cli_conf/replication.py b/src/lib389/lib389/cli_conf/replication.py index eb8297d42..de2099f4d 100644 --- a/src/lib389/lib389/cli_conf/replication.py +++ b/src/lib389/lib389/cli_conf/replication.py @@ -6,16 +6,16 @@ # See LICENSE for details. # --- END COPYRIGHT BLOCK --- +import re import logging -import time -import base64 import os import json import ldap from getpass import getpass -from lib389._constants import * -from lib389.utils import is_a_dn, ensure_str -from lib389.replica import Replicas, BootstrapReplicationManager, RUV, Changelog5, ChangelogLDIF +from lib389._constants import ReplicaRole, DSRC_HOME +from lib389.cli_base.dsrc import dsrc_to_repl_monitor +from lib389.utils import is_a_dn +from lib389.replica import Replicas, ReplicationMonitor, BootstrapReplicationManager, Changelog5, ChangelogLDIF from lib389.tasks import CleanAllRUVTask, AbortCleanAllRUVTask from lib389._mapped_object import DSLdapObjects @@ -338,6 +338,90 @@ def set_repl_config(inst, basedn, log, args): log.info("Successfully updated replication configuration") +def get_repl_monitor_info(inst, basedn, log, args): + connection_data = dsrc_to_repl_monitor(DSRC_HOME, log) + + # Additional details for the connections to the topology + def get_credentials(host, port): + found = False + if args.connections: + connections = args.connections + elif connection_data["connections"]: + connections = connection_data["connections"] + else: + connections = [] + + if connections: + for connection_str in connections: + if len(connection_str.split(":")) != 4: + raise ValueError(f"Connection string {connection_str} is in wrong format." + "It should be host:port:binddn:bindpw") + host_regex = connection_str.split(":")[0] + port_regex = connection_str.split(":")[1] + if re.match(host_regex, host) and re.match(port_regex, port): + found = True + binddn = connection_str.split(":")[2] + bindpw = connection_str.split(":")[3] + # Search for the password file or ask the user to write it + if bindpw.startswith("[") and bindpw.endswith("]"): + pwd_file_path = os.path.expanduser(bindpw[1:][:-1]) + try: + with open(pwd_file_path) as f: + bindpw = f.readline().strip() + except FileNotFoundError: + bindpw = getpass(f"File '{pwd_file_path}' was not found. Please, enter " + f"a password for {binddn} on {host}:{port}: ").rstrip() + if bindpw == "*": + bindpw = getpass(f"Enter a password for {binddn} on {host}:{port}: ").rstrip() + if not found: + binddn = input(f'\nEnter a bind DN for {host}:{port}: ').rstrip() + bindpw = getpass(f"Enter a password for {binddn} on {host}:{port}: ").rstrip() + + return {"binddn": binddn, + "bindpw": bindpw} + + repl_monitor = ReplicationMonitor(inst) + report_dict = repl_monitor.generate_report(get_credentials) + + if args.json: + log.info(json.dumps({"type": "list", "items": report_dict})) + else: + for instance, report_data in report_dict.items(): + found_alias = False + if args.aliases: + aliases = {al.split("=")[0]: al.split("=")[1] for al in args.aliases} + elif connection_data["aliases"]: + aliases = connection_data["aliases"] + else: + aliases = {} + if aliases: + for alias_name, alias_host_port in aliases.items(): + if alias_host_port.lower() == instance.lower(): + supplier_header = f"Supplier: {alias_name} ({instance})" + found_alias = True + break + if not found_alias: + supplier_header = f"Supplier: {instance}" + log.info(supplier_header) + # Draw a line with the same length as the header + log.info("-".join(["" for _ in range(0, len(supplier_header)+1)])) + if "status" in report_data and report_data["status"] == "Unavailable": + status = report_data["status"] + reason = report_data["reason"] + log.info(f"Status: {status}") + log.info(f"Reason: {reason}\n") + else: + for replica in report_data: + replica_root = replica["replica_root"] + replica_id = replica["replica_id"] + maxcsn = replica["maxcsn"] + log.info(f"Replica Root: {replica_root}") + log.info(f"Replica ID: {replica_id}") + log.info(f"Max CSN: {maxcsn}\n") + for agreement_status in replica["agmts_status"]: + log.info(agreement_status) + + def create_cl(inst, basedn, log, args): cl = Changelog5(inst) try: @@ -1033,6 +1117,17 @@ def create_parser(subparsers): repl_set_parser.add_argument('--repl-release-timeout', help="A timeout in seconds a replication master should send " "updates before it yields its replication session") + repl_monitor_parser = repl_subcommands.add_parser('monitor', help='Get the full replication topology report') + repl_monitor_parser.set_defaults(func=get_repl_monitor_info) + repl_monitor_parser.add_argument('-c', '--connections', nargs="*", + help="The connection values for monitoring other not connected topologies. " + "The format: 'host:port:binddn:bindpwd'. You can use regex for host and port. " + "You can set bindpwd to * and it will be requested at the runtime or " + "you can include the path to the password file in square brackets - [~/pwd.txt]") + repl_monitor_parser.add_argument('-a', '--aliases', nargs="*", + help="If a host:port is assigned an alias, then the alias instead of " + "host:port will be displayed in the output. The format: alias=host:port") +# ############################################ # Replication Agmts ############################################ diff --git a/src/lib389/lib389/replica.py b/src/lib389/lib389/replica.py index 48a14cfcc..7f2fd5e06 100644 --- a/src/lib389/lib389/replica.py +++ b/src/lib389/lib389/replica.py @@ -1381,10 +1381,62 @@ class Replica(DSLdapObject): """Return the set of agreements related to this suffix replica :param: winsync: If True then return winsync replication agreements, otherwise return teh standard replication agreements. - :returns: Agreements object + :returns: A list Replicas objects """ return Agreements(self._instance, self.dn, winsync=winsync) + def get_consumer_replicas(self, get_credentials): + """Return the set of consumer replicas related to this suffix replica through its agreements + + :param get_credentials: A user-defined callback function which returns the binding credentials + using given host and port data - {"binddn": "cn=Directory Manager", + "bindpw": "password"} + :returns: Replicas object + """ + + agmts = self.get_agreements() + result_replicas = [] + connections = [] + + try: + for agmt in agmts: + host = agmt.get_attr_val_utf8("nsDS5ReplicaHost") + port = agmt.get_attr_val_utf8("nsDS5ReplicaPort") + protocol = agmt.get_attr_val_utf8("nsDS5ReplicaTransportInfo").lower() + + # The function should be defined outside and + # it should have all the logic for figuring out the credentials + credentials = get_credentials(host, port) + if not credentials["binddn"]: + report_data[supplier] = {"status": "Unavailable", + "reason": "Bind DN was not specified"} + continue + + # Open a connection to the consumer + consumer = DirSrv(verbose=self._instance.verbose) + args_instance[SER_HOST] = host + if protocol == "ssl" or protocol == "ldaps": + args_instance[SER_SECURE_PORT] = int(port) + else: + args_instance[SER_PORT] = int(port) + args_instance[SER_ROOT_DN] = credentials["binddn"] + args_instance[SER_ROOT_PW] = credentials["bindpw"] + args_standalone = args_instance.copy() + consumer.allocate(args_standalone) + try: + consumer.open() + except ldap.LDAPError as e: + self._log.debug(f"Connection to consumer ({host}:{port}) failed, error: {e}") + raise + connections.append(consumer) + result_replicas.append(Replicas(consumer)) + except: + for conn in connections: + conn.close() + raise + + return result_replicas + def get_rid(self): """Return the current replicas RID for this suffix @@ -1412,6 +1464,15 @@ class Replica(DSLdapObject): return RUV(data) + def get_maxcsn(self): + """Return the current replica's maxcsn for this suffix + + :returns: str + """ + replica_id = self.get_rid() + replica_ruvs = self.get_ruv() + return replica_ruvs._rid_maxcsn.get(replica_id, '00000000000000000000') + def get_ruv_agmt_maxcsns(self): """Return the in memory ruv of this replica suffix. @@ -2232,3 +2293,126 @@ class ReplicationManager(object): replicas = Replicas(instance) replica = replicas.get(self._suffix) return replica.get_rid() + + +class ReplicationMonitor(object): + """The lib389 replication monitor. This is used to check the status + of many instances at once. + It also allows to monitor independent topologies and get them into + the one combined report. + + :param instance: A supplier or hub for replication topology monitoring + :type instance: list of DirSrv objects + :param logger: A logging interface + :type logger: python logging + """ + + def __init__(self, instance, logger=None): + self._instance = instance + if logger is not None: + self._log = logger + else: + self._log = logging.getLogger(__name__) + + def _get_replica_status(self, instance, report_data, use_json): + """Load all of the status data to report + and add new hostname:port pairs for future processing + """ + + replicas_status = [] + replicas = Replicas(instance) + for replica in replicas.list(): + replica_id = replica.get_rid() + replica_root = replica.get_suffix() + replica_maxcsn = replica.get_maxcsn() + agmts_status = [] + agmts = replica.get_agreements() + for agmt in agmts.list(): + host = agmt.get_attr_val_utf8_l("nsds5replicahost") + port = agmt.get_attr_val_utf8_l("nsds5replicaport") + protocol = agmt.get_attr_val_utf8_l('nsds5replicatransportinfo') + # Supply protocol here because we need it only for connection + # and agreement status is already preformatted for the user output + consumer = f"{host}:{port}:{protocol}" + if consumer not in report_data: + report_data[consumer] = None + agmts_status.append(agmt.status(use_json)) + replicas_status.append({"replica_id": replica_id, + "replica_root": replica_root, + "maxcsn": replica_maxcsn, + "agmts_status": agmts_status}) + return replicas_status + + def generate_report(self, get_credentials, use_json=False): + """Generate a replication report for each supplier or hub and the instances + that are connected with it by agreements. + + :param get_credentials: A user-defined callback function with parameters (host, port) which returns + a dictionary with binddn and bindpw keys - + example values "cn=Directory Manager" and "password" + :type get_credentials: function + :returns: dict + """ + report_data = {} + + initial_inst_key = f"{self._instance.host.lower()}:{str(self._instance.port).lower()}" + # Do this on an initial instance to get the agreements to other instances + report_data[initial_inst_key] = self._get_replica_status(self._instance, report_data, use_json) + + # Check if at least some replica report on other instances was generated + repl_exists = False + + # While we have unprocessed instances - continue + while True: + try: + supplier = [host_port for host_port, processed_data in report_data.items() if processed_data is None][0] + except IndexError: + break + + s_splitted = supplier.split(":") + supplier_hostname = s_splitted[0] + supplier_port = s_splitted[1] + supplier_protocol = s_splitted[2] + + # The function should be defined outside and + # it should have all the logic for figuring out the credentials. + # It is done for flexibility purpuses between CLI, WebUI and lib389 API applications + credentials = get_credentials(supplier_hostname, supplier_port) + if not credentials["binddn"]: + report_data[supplier] = {"status": "Unavailable", + "reason": "Bind DN was not specified"} + continue + + # Open a connection to the consumer + supplier_inst = DirSrv(verbose=self._instance.verbose) + args_instance[SER_HOST] = supplier_hostname + if supplier_protocol == "ssl" or supplier_protocol == "ldaps": + args_instance[SER_SECURE_PORT] = int(supplier_port) + else: + args_instance[SER_PORT] = int(supplier_port) + args_instance[SER_ROOT_DN] = credentials["binddn"] + args_instance[SER_ROOT_PW] = credentials["bindpw"] + args_standalone = args_instance.copy() + supplier_inst.allocate(args_standalone) + try: + supplier_inst.open() + except ldap.LDAPError as e: + self._log.debug(f"Connection to consumer ({supplier_hostname}:{supplier_port}) failed, error: {e}") + report_data[supplier] = {"status": "Unavailable", + "reason": e.args[0]['desc']} + continue + + report_data[supplier] = self._get_replica_status(supplier_inst, report_data, use_json) + repl_exists = True + + # Now remove the protocol from the name + report_data_final = {} + for key, value in report_data.items(): + # We take the initial instance only if it is the only existing part of the report + if key != initial_inst_key or not repl_exists: + if not value: + value = {"status": "Unavailable", + "reason": "No replicas were found"} + report_data_final[":".join(key.split(":")[:2])] = value + + return report_data_final
0
99f99743617c1d082e748e7d3e83adf953d2ad05
389ds/389-ds-base
Ticket 47967 - cos_cache_build_definition_list does not stop during server shutdown Bug Description: If the COS cache is being rebuilt (where there are many COS definitions/templates), attempting to stop the server can take take a very long time. Fix Description: In the callback functions check for server shutdown to abort out of the search callback loops. https://fedorahosted.org/389/ticket/47967 Reviewed by: nhosoi(Thanks!)
commit 99f99743617c1d082e748e7d3e83adf953d2ad05 Author: Mark Reynolds <[email protected]> Date: Thu Dec 4 11:11:13 2014 -0500 Ticket 47967 - cos_cache_build_definition_list does not stop during server shutdown Bug Description: If the COS cache is being rebuilt (where there are many COS definitions/templates), attempting to stop the server can take take a very long time. Fix Description: In the callback functions check for server shutdown to abort out of the search callback loops. https://fedorahosted.org/389/ticket/47967 Reviewed by: nhosoi(Thanks!) diff --git a/ldap/servers/plugins/cos/cos_cache.c b/ldap/servers/plugins/cos/cos_cache.c index 3f3841f81..a7993c810 100644 --- a/ldap/servers/plugins/cos/cos_cache.c +++ b/ldap/servers/plugins/cos/cos_cache.c @@ -725,7 +725,7 @@ struct dn_defs_info { /* * Currently, always returns 0 to continue the search for definitions, even * if a particular attempt to add a definition fails: info.ret gets set to - * zero only if we succed to add a def. + * zero only if we succeed to add a def. */ static int cos_dn_defs_cb (Slapi_Entry* e, void *callback_data) @@ -1056,10 +1056,10 @@ bail: /* This particular definition may not have yielded anything * worth caching (eg. no template was found for it) but * that should not cause us to abort the search for other more well behaved - * definitions. + * definitions unless we are shutting down. * return info->ret; - */ - return (0); + */ + return slapi_is_shutting_down(); } @@ -1116,7 +1116,7 @@ struct tmpl_info { /* * Currently, always returns 0 to continue the search for templates, even * if a particular attempt to add a template fails: info.ret gets set to - * zero only if we succed to add at least one tmpl. + * zero only if we succeed to add at least one tmpl. */ static int cos_dn_tmpl_entries_cb (Slapi_Entry* e, void *callback_data) { cosAttrValue *pDn = 0; @@ -1166,7 +1166,7 @@ static int cos_dn_tmpl_entries_cb (Slapi_Entry* e, void *callback_data) { if(pSneakyVal == NULL) { - /* look for the atrribute in the dynamic attributes */ + /* look for the attribute in the dynamic attributes */ if(cos_cache_attrval_exists(info->pAttrs, attrType)) { pSneakyVal = &pCosAttribute; @@ -1269,10 +1269,10 @@ static int cos_dn_tmpl_entries_cb (Slapi_Entry* e, void *callback_data) { } } /* - * Always contine the search even if a particular attempt - * to add a template failed. - */ - return 0; + * Always continue the search even if a particular attempt + * to add a template failed unless we are shutting down + */ + return slapi_is_shutting_down(); } /*
0
381caf52a06ad8cefa9daa99586878249a4aa4f2
389ds/389-ds-base
Ticket #48919 - Compiler warnings while building 389-ds-base on RHEL7 Description: Fixing additional covscan errors. 1. RESOURCE_LEAK ldap/servers/slapd/agtmmap.c agt_mopen_stats - leaked_handle: Handle variable "fd" going out of scope leaks the handle. 2. CHECKED_RETURN ldap/servers/slapd/back-ldbm/cache.c entrycache_return - check_return: Calling "remove_hash" without checking return value 3. NULL_RETURNS ldap/systools/idsktune.c linux_check_cpu_features - dereference: Dereferencing a pointer that might be null "cpuinfo" when calling "fclose". 4. UNINIT ldap/servers/slapd/detach.c detach - uninit_use: Using uninitialized value "rc". https://fedorahosted.org/389/ticket/48919
commit 381caf52a06ad8cefa9daa99586878249a4aa4f2 Author: Noriko Hosoi <[email protected]> Date: Thu Jul 14 19:09:21 2016 -0700 Ticket #48919 - Compiler warnings while building 389-ds-base on RHEL7 Description: Fixing additional covscan errors. 1. RESOURCE_LEAK ldap/servers/slapd/agtmmap.c agt_mopen_stats - leaked_handle: Handle variable "fd" going out of scope leaks the handle. 2. CHECKED_RETURN ldap/servers/slapd/back-ldbm/cache.c entrycache_return - check_return: Calling "remove_hash" without checking return value 3. NULL_RETURNS ldap/systools/idsktune.c linux_check_cpu_features - dereference: Dereferencing a pointer that might be null "cpuinfo" when calling "fclose". 4. UNINIT ldap/servers/slapd/detach.c detach - uninit_use: Using uninitialized value "rc". https://fedorahosted.org/389/ticket/48919 diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c index 629bc1bf4..b9d66d95b 100644 --- a/ldap/servers/slapd/agtmmap.c +++ b/ldap/servers/slapd/agtmmap.c @@ -167,6 +167,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl) #endif rc = err; free (buf); + close(fd); goto bail; } free (buf); diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c index bb4e55ef0..015cd4869 100644 --- a/ldap/servers/slapd/back-ldbm/cache.c +++ b/ldap/servers/slapd/back-ldbm/cache.c @@ -1142,7 +1142,9 @@ entrycache_return(struct cache *cache, struct backentry **bep) * so we need to remove the entry from the DN cache because * we don't/can't always call cache_remove(). */ - remove_hash(cache->c_dntable, (void *)ndn, strlen(ndn)); + if (remove_hash(cache->c_dntable, (void *)ndn, strlen(ndn)) == 0) { + LOG("entrycache_return: failed to remove %s from dn table\n", ndn, 0, 0); + } } backentry_free(bep); } else { @@ -1392,7 +1394,7 @@ entrycache_add_int(struct cache *cache, struct backentry *e, int state, return 0; } if(remove_hash(cache->c_dntable, (void *)ndn, strlen(ndn)) == 0){ - LOG("entrycache_add_int: failed to remove %s from dn table\n", 0, 0, 0); + LOG("entrycache_add_int: failed to remove %s from dn table\n", ndn, 0, 0); } e->ep_state |= ENTRY_STATE_NOTINCACHE; cache_unlock(cache); diff --git a/ldap/servers/slapd/detach.c b/ldap/servers/slapd/detach.c index 54c602864..84a9eef0b 100644 --- a/ldap/servers/slapd/detach.c +++ b/ldap/servers/slapd/detach.c @@ -48,7 +48,8 @@ int detach( int slapd_exemode, int importexport_encrypt, int s_port, daemon_ports_t *ports_info ) { - int i, sd, rc; + int i, sd; + int rc = 0; char *workingdir = 0; char *errorlog = 0; char *ptr = 0; diff --git a/ldap/systools/idsktune.c b/ldap/systools/idsktune.c index 4c9652979..08b7f124c 100644 --- a/ldap/systools/idsktune.c +++ b/ldap/systools/idsktune.c @@ -875,6 +875,10 @@ linux_check_cpu_features(void) char *token = NULL; size_t size = 0; int found = 0; + if (NULL == cpuinfo) { + printf("ERROR: Unable to check cpu features since opening \"/proc/cpuinfo\" failed.\n"); + return; + } while(getline(&arg, &size, cpuinfo) != -1) { if (strncmp("flags", arg, 5) == 0) {
0
8dbfff1ff4152afb018490886a612c448ea2a1b0
389ds/389-ds-base
Ticket 49165 pw_verify did not handle external auth Bug Description: During the change to improve sasl and simple bind, we externalised the backend selection outside of do_bind. In an auto_bind scenario however, this mean the be was null, causing the dn to always be invalidated. Fix Description: Add a pw_validate_be_dn function, that correctly checks if we are anonymous, a real be dn, or rootdn. This then allows the correct authentication of autobinds. https://pagure.io/389-ds-base/issue/49165 Author: wibrown Review by: mreynolds (Thanks!)
commit 8dbfff1ff4152afb018490886a612c448ea2a1b0 Author: William Brown <[email protected]> Date: Tue Mar 14 14:01:33 2017 +1000 Ticket 49165 pw_verify did not handle external auth Bug Description: During the change to improve sasl and simple bind, we externalised the backend selection outside of do_bind. In an auto_bind scenario however, this mean the be was null, causing the dn to always be invalidated. Fix Description: Add a pw_validate_be_dn function, that correctly checks if we are anonymous, a real be dn, or rootdn. This then allows the correct authentication of autobinds. https://pagure.io/389-ds-base/issue/49165 Author: wibrown Review by: mreynolds (Thanks!) diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c index b4bb36340..5c4fada23 100644 --- a/ldap/servers/slapd/bind.c +++ b/ldap/servers/slapd/bind.c @@ -656,7 +656,12 @@ do_bind( Slapi_PBlock *pb ) /* We could be serving multiple database backends. Select the appropriate one */ /* pw_verify_be_dn will select the backend we need for us. */ - rc = pw_verify_be_dn(pb, &referral); + if (auto_bind) { + /* We have no password material. We should just check who we are binding as. */ + rc = pw_validate_be_dn(pb, &referral); + } else { + rc = pw_verify_be_dn(pb, &referral); + } if (rc == SLAPI_BIND_NO_BACKEND) { send_nobackend_ldap_result( pb ); @@ -715,7 +720,7 @@ do_bind( Slapi_PBlock *pb ) * */ slapi_pblock_get(pb, SLAPI_BACKEND, &be); - if (!slapi_be_is_flag_set(be, SLAPI_BE_FLAG_REMOTE_DATA)) { + if (!isroot && !slapi_be_is_flag_set(be, SLAPI_BE_FLAG_REMOTE_DATA)) { bind_target_entry = get_entry(pb, slapi_sdn_get_ndn(sdn)); myrc = slapi_check_account_lock(pb, bind_target_entry, pw_response_requested, 1, 1); if (1 == myrc) { /* account is locked */ diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c index d043f2aaa..fa3909fbb 100644 --- a/ldap/servers/slapd/dn.c +++ b/ldap/servers/slapd/dn.c @@ -1738,6 +1738,11 @@ slapi_dn_isroot( const char *dn ) return( rc ); } +int32_t +slapi_sdn_isroot(const Slapi_DN *sdn) { + return slapi_dn_isroot(slapi_sdn_get_ndn(sdn)); +} + int slapi_is_rootdse( const char *dn ) { diff --git a/ldap/servers/slapd/pw_verify.c b/ldap/servers/slapd/pw_verify.c index 93e5ff357..529bb83fd 100644 --- a/ldap/servers/slapd/pw_verify.c +++ b/ldap/servers/slapd/pw_verify.c @@ -88,8 +88,61 @@ pw_verify_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral) return rc; } +/* + * Resolve the dn we have been requested to bind with and verify it's + * valid, and has a backend. + * + * We are checking: + * * is this anonymous? + * * is this the rootdn? + * * is this a real dn, which associates to a real backend. + * + * This is used in SASL autobinds, so we need to handle this validation. + */ + int -pw_verify_dn() +pw_validate_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral) { - return LDAP_OPERATIONS_ERROR; + int rc = 0; + Slapi_Backend *be = NULL; + Slapi_DN *pb_sdn; + struct berval *cred; + ber_tag_t method; + + + slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &pb_sdn); + slapi_pblock_get(pb, SLAPI_BIND_CREDENTIALS, &cred); + slapi_pblock_get(pb, SLAPI_BIND_METHOD, &method); + + if (pb_sdn != NULL || cred != NULL) { + return LDAP_OPERATIONS_ERROR; + } + + if (*referral) { + return SLAPI_BIND_REFERRAL; + } + + /* We need a slapi_sdn_isanon? */ + if (method == LDAP_AUTH_SIMPLE && cred->bv_len == 0) { + return SLAPI_BIND_ANONYMOUS; + } + + if (slapi_sdn_isroot(pb_sdn)) { + /* This is a real identity */ + return SLAPI_BIND_SUCCESS; + } + + if (slapi_mapping_tree_select(pb, &be, referral, NULL, 0) != LDAP_SUCCESS) { + return SLAPI_BIND_NO_BACKEND; + } + slapi_be_Unlock(be); + + slapi_pblock_set(pb, SLAPI_BACKEND, be); + slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database); + /* Make sure the result handlers are setup */ + set_db_default_result_handlers(pb); + + /* The backend associated with this identity is real. */ + + return SLAPI_BIND_SUCCESS; } diff --git a/ldap/servers/slapd/pw_verify.h b/ldap/servers/slapd/pw_verify.h index fc34fd147..513702726 100644 --- a/ldap/servers/slapd/pw_verify.h +++ b/ldap/servers/slapd/pw_verify.h @@ -11,5 +11,6 @@ int pw_verify_root_dn(const char *dn, const Slapi_Value *cred); int pw_verify_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral); +int pw_validate_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral); #endif /* _SLAPD_PW_VERIFY_H_ */ diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index b223f6504..1bd8fc8e1 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -3799,6 +3799,15 @@ int slapi_dn_isparent( const char *parentdn, const char *childdn ); */ int slapi_dn_isroot( const char *dn ); +/** + * Determines if an SDN is the root DN. + * + * \param sdn The DN to check + * \return \c 1 if the DN is the root DN. + * \return \c 0 if the DN is not the root DN. + */ +int32_t slapi_sdn_isroot( const Slapi_DN *sdn ); + /** * Checks if a DN is the backend suffix. *
0
27fadb75ec1f3b252028ce715cd7fa16da1f6525
389ds/389-ds-base
Ticket 48215 - verify_db.pl doesn't verify DB specified by -a option Bug Description: verify_db.pl -a only uses the db location for checking the transaction logs, because it ends up calling "nsslapd dbverify" which only checks the db files in the server configuration. Fix Description: Allow a new argument to be passed to "nsslapd dbverify" that specifies the db parent directory. https://fedorahosted.org/389/ticket/48215 Reviewed by: nhosoi(Thanks!)
commit 27fadb75ec1f3b252028ce715cd7fa16da1f6525 Author: Mark Reynolds <[email protected]> Date: Wed Aug 5 16:31:49 2015 -0400 Ticket 48215 - verify_db.pl doesn't verify DB specified by -a option Bug Description: verify_db.pl -a only uses the db location for checking the transaction logs, because it ends up calling "nsslapd dbverify" which only checks the db files in the server configuration. Fix Description: Allow a new argument to be passed to "nsslapd dbverify" that specifies the db parent directory. https://fedorahosted.org/389/ticket/48215 Reviewed by: nhosoi(Thanks!) diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in index 6306a0732..778a9ba5b 100755 --- a/ldap/admin/src/scripts/dbverify.in +++ b/ldap/admin/src/scripts/dbverify.in @@ -26,7 +26,7 @@ usage() } display_version="no" -while getopts "Z:n:hVvfd:n:D:" flag +while getopts "Z:n:hVvfd:n:D:a:" flag do case $flag in h) usage @@ -39,6 +39,7 @@ do display_version="yes";; f) args=$args" -f";; D) args=$args" -D $OPTARG";; + a) args=$args" -a $OPTARG";; ?) usage exit 1;; esac diff --git a/ldap/admin/src/scripts/verify-db.pl.in b/ldap/admin/src/scripts/verify-db.pl.in index ae56a16e5..d481ecbef 100644 --- a/ldap/admin/src/scripts/verify-db.pl.in +++ b/ldap/admin/src/scripts/verify-db.pl.in @@ -16,7 +16,7 @@ DSUtil::libpath_add("@db_libdir@"); DSUtil::libpath_add("@libdir@"); $ENV{'PATH'} = "@libdir@/@package_name@/slapd-$servid:@db_bindir@:/usr/bin:/"; $ENV{'SHLIB_PATH'} = "$ENV{'LD_LIBRARY_PATH'}"; - +my $custom_dbdir = 0; my $i = 0; sub usage @@ -118,12 +118,7 @@ sub getLastLogfile return \$logfile; } -$isWin = -d '\\'; -if ($isWin) { - $NULL = "nul"; -} else { - $NULL = "/dev/null"; -} +$NULL = "/dev/null"; while ($i <= $#ARGV) { if ( "$ARGV[$i]" eq "-a" ) { # path to search the db files @@ -149,6 +144,8 @@ print("*****************************************************************\n"); if ( "$startpoint" eq "" ) { $startpoint = "@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/db"; +} else { + $custom_dbdir = 1; } # get dirs having DBVERSION my $dbdirs = getDbDir($startpoint); @@ -192,7 +189,11 @@ for (my $i = 0; "$$dbdirs[$i]" ne ""; $i++) # Check db files by db_verify print "Verify db files ... "; -open(DBVERIFY, "@sbindir@/dbverify -Z $servid 2>&1 1> $NULL |"); +if ($custom_dbdir){ + open(DBVERIFY, "@sbindir@/dbverify -Z $servid -a $startpoint 2>&1 1> $NULL |"); +} else { + open(DBVERIFY, "@sbindir@/dbverify -Z $servid 2>&1 1> $NULL |"); +} sleep 1; my $bad_index = 0; my $bad_id2entry = 0; diff --git a/ldap/servers/slapd/back-ldbm/dbverify.c b/ldap/servers/slapd/back-ldbm/dbverify.c index 85ee7a0bd..315ef9348 100644 --- a/ldap/servers/slapd/back-ldbm/dbverify.c +++ b/ldap/servers/slapd/back-ldbm/dbverify.c @@ -186,13 +186,16 @@ ldbm_back_dbverify( Slapi_PBlock *pb ) int rval = 1; int rval_main = 0; char **instance_names = NULL; + char *dbdir = NULL; slapi_log_error(SLAPI_LOG_TRACE, "verify DB", "Verifying db files...\n"); slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_names); slapi_pblock_get(pb, SLAPI_SEQ_TYPE, &verbose); slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li); + slapi_pblock_get(pb, SLAPI_DBVERIFY_DBDIR, &dbdir); ldbm_config_load_dse_info(li); ldbm_config_internal_set(li, CONFIG_DB_TRANSACTION_LOGGING, "off"); + /* no write needed; choose EXPORT MODE */ if (0 != dblayer_start(li, DBLAYER_EXPORT_MODE)) { @@ -211,6 +214,11 @@ ldbm_back_dbverify( Slapi_PBlock *pb ) inst = ldbm_instance_find_by_name(li, *inp); if (inst) { + if (dbdir){ + /* verifying backup */ + slapi_ch_free_string(&inst->inst_parent_dir_name); + inst->inst_parent_dir_name = slapi_ch_strdup(dbdir); + } rval_main |= dbverify_ext(inst, verbose); } else @@ -235,6 +243,11 @@ ldbm_back_dbverify( Slapi_PBlock *pb ) inst->inst_name); continue; /* skip this instance and go to the next*/ } + if (dbdir){ + /* verifying backup */ + slapi_ch_free_string(&inst->inst_parent_dir_name); + inst->inst_parent_dir_name = slapi_ch_strdup(dbdir); + } rval_main |= dbverify_ext(inst, verbose); } } diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index 9016144b1..922de97b9 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -435,13 +435,15 @@ static int ldif_printkey = EXPORT_PRINTKEY|EXPORT_APPENDMODE; static char *archive_name = NULL; static int db2ldif_dump_replica = 0; static int db2ldif_dump_uniqueid = 1; -static int ldif2db_generate_uniqueid = SLAPI_UNIQUEID_GENERATE_TIME_BASED; -static int dbverify_verbose = 0; +static int ldif2db_generate_uniqueid = SLAPI_UNIQUEID_GENERATE_TIME_BASED; static char *ldif2db_namespaceid = NULL; int importexport_encrypt = 0; static int upgradedb_flags = 0; static int upgradednformat_dryrun = 0; static int is_quiet = 0; +/* dbverify options */ +static int dbverify_verbose = 0; +static char *dbverify_dbdir = NULL; /* taken from idsktune */ #if defined(__sun) @@ -1301,13 +1303,14 @@ process_command_line(int argc, char **argv, char *myname, {"dryrun",ArgNone,'N'}, {0,0,0}}; - char *opts_dbverify = "vVfd:n:D:"; + char *opts_dbverify = "vVfd:n:D:a:"; struct opt_ext long_options_dbverify[] = { {"version",ArgNone,'v'}, {"debug",ArgRequired,'d'}, {"backend",ArgRequired,'n'}, {"configDir",ArgRequired,'D'}, {"verbose",ArgNone,'V'}, + {"dbdir",ArgRequired,'a'}, {0,0,0}}; char *opts_referral = "vd:p:r:SD:"; @@ -1674,7 +1677,11 @@ process_command_line(int argc, char **argv, char *myname, break; case 'a': /* archive pathname for db */ - archive_name = optarg_ext; + if ( slapd_exemode == SLAPD_EXEMODE_DBVERIFY ) { + dbverify_dbdir = optarg_ext; + } else { + archive_name = optarg_ext; + } break; case 'Z': @@ -2688,7 +2695,8 @@ slapd_exemode_dbverify() pb.pb_plugin = backend_plugin; pb.pb_instance_name = (char *)cmd_line_instance_names; pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE; - + pb.pb_dbverify_dbdir = dbverify_dbdir; + if ( backend_plugin->plg_dbverify != NULL ) { return_value = (*backend_plugin->plg_dbverify)( &pb ); } else { diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index c10f788c6..bf57a33d2 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -5,7 +5,7 @@ * All rights reserved. * * License: GPL (version 3 or any later version). - * See LICENSE for details. + * See LICENSE for details. * END COPYRIGHT BLOCK **/ #ifdef HAVE_CONFIG_H @@ -1677,6 +1677,11 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value ) (*(IFP*)value) = pblock->pb_txn_ruv_mods_fn; break; + /* dbverify */ + case SLAPI_DBVERIFY_DBDIR: + (*(char **)value) = pblock->pb_dbverify_dbdir; + break; + /* Search results set */ case SLAPI_SEARCH_RESULT_SET: if(pblock->pb_op!=NULL) @@ -3520,6 +3525,11 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value ) pblock->pb_aci_target_check = *((int *) value); break; + /* dbverify */ + case SLAPI_DBVERIFY_DBDIR: + pblock->pb_dbverify_dbdir = (char *) value; + break; + default: LDAPDebug( LDAP_DEBUG_ANY, "Unknown parameter block argument %d\n", arg, 0, 0 ); diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 6d1ad7b6f..823568d59 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1600,6 +1600,8 @@ typedef struct slapi_pblock { int pb_seq_type; char *pb_seq_attrname; char *pb_seq_val; + /* dbverify argument */ + char *pb_dbverify_dbdir; /* ldif2db arguments */ char *pb_ldif_file; int pb_removedupvals; diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index a8c7a4a87..6b046108e 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -7289,6 +7289,9 @@ typedef struct slapi_plugindesc { /* ACI Target Check */ #define SLAPI_ACI_TARGET_CHECK 1946 +/* dbverify */ +#define SLAPI_DBVERIFY_DBDIR 1947 + /* convenience macros for checking modify operation types */ #define SLAPI_IS_MOD_ADD(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_ADD) #define SLAPI_IS_MOD_DELETE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_DELETE) diff --git a/man/man8/dbverify.8 b/man/man8/dbverify.8 index 30d693393..c74747ad8 100644 --- a/man/man8/dbverify.8 +++ b/man/man8/dbverify.8 @@ -31,6 +31,9 @@ one instance on the system, this option can be skipped. .B \fB\-n\fR \fIBackend Name\fR The name of the LDBM database to reindex. Example: userRoot .TP +.B \fB\-a\fR \fIDatabase Directory\fR +Location of database if it is different than what is in the server configuration(e.g. backup directories) +.TP .B \fB\-d\fR \fIDebug Level\fR Sets the debugging level. .TP
0
c4962651906ef23ad353ad00eddadd44d002158d
389ds/389-ds-base
Bug 617630 - fix coverify Defect Type: Resource leaks issues CID 12052 - 12093 https://bugzilla.redhat.com/show_bug.cgi?id=617630 Resolves: bug 617630 Bug description: fix coverify Defect Type: Resource leaks issues CID 12068, 12069. description: dbinfo_to_certinfo() has been modified to release unused resources when error occurs.
commit c4962651906ef23ad353ad00eddadd44d002158d Author: Endi S. Dewata <[email protected]> Date: Sat Jul 24 01:28:18 2010 -0500 Bug 617630 - fix coverify Defect Type: Resource leaks issues CID 12052 - 12093 https://bugzilla.redhat.com/show_bug.cgi?id=617630 Resolves: bug 617630 Bug description: fix coverify Defect Type: Resource leaks issues CID 12068, 12069. description: dbinfo_to_certinfo() has been modified to release unused resources when error occurs. diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c index cea403b6d..83de904ee 100644 --- a/lib/ldaputil/certmap.c +++ b/lib/ldaputil/certmap.c @@ -487,14 +487,18 @@ static int dbconf_to_certmap_err (int err) static int dbinfo_to_certinfo (DBConfDBInfo_t *db_info, LDAPUCertMapInfo_t **certinfo_out) { - LDAPUCertMapInfo_t *certinfo; - int rv; + LDAPUCertMapInfo_t *certinfo = NULL; + LDAPUPropValList_t *propval_list = NULL; + int rv = LDAPU_SUCCESS; *certinfo_out = 0; certinfo = (LDAPUCertMapInfo_t *)malloc(sizeof(LDAPUCertMapInfo_t)); - if (!certinfo) return LDAPU_ERR_OUT_OF_MEMORY; + if (!certinfo) { + rv = LDAPU_ERR_OUT_OF_MEMORY; + goto error; + } memset((void *)certinfo, 0, sizeof(LDAPUCertMapInfo_t)); @@ -509,7 +513,6 @@ static int dbinfo_to_certinfo (DBConfDBInfo_t *db_info, /* hijack actual prop-vals from dbinfo -- to avoid strdup calls */ if (db_info->firstprop) { - LDAPUPropValList_t *propval_list; LDAPUPropVal_t *propval; DBPropVal_t *dbpropval; @@ -517,14 +520,16 @@ static int dbinfo_to_certinfo (DBConfDBInfo_t *db_info, rv = ldapu_list_alloc(&propval_list); - if (rv != LDAPU_SUCCESS) return rv; + if (rv != LDAPU_SUCCESS) { + goto error; + } while(dbpropval) { propval = (LDAPUPropVal_t *)malloc(sizeof(LDAPUPropVal_t)); if (!propval) { - free(certinfo); - return LDAPU_ERR_OUT_OF_MEMORY; + rv = LDAPU_ERR_OUT_OF_MEMORY; + goto error; } propval->prop = dbpropval->prop; @@ -536,8 +541,7 @@ static int dbinfo_to_certinfo (DBConfDBInfo_t *db_info, rv = ldapu_list_add_info(propval_list, propval); if (rv != LDAPU_SUCCESS) { - free(certinfo); - return rv; + goto error; } dbpropval = dbpropval->next; @@ -547,8 +551,14 @@ static int dbinfo_to_certinfo (DBConfDBInfo_t *db_info, } *certinfo_out = certinfo; + goto done; - return LDAPU_SUCCESS; +error: + if (propval_list) ldapu_propval_list_free(propval_list); + if (certinfo) free(certinfo); + +done: + return rv; } static int ldapu_binary_cmp_certs (void *subject_cert,
0
3a643dc8789b284c7f707e5cc7bb0ca76505ac55
389ds/389-ds-base
Issue 4342 - UI - additional fixes for creation instance modal Description: In the instance creation modal there is an incorrect warning about the port number range. It should state valid port numbers are between 1 and 65535. The root DN character validation allows non ascii as the first characters after the "=". And we are not forewarning about the instance name length if it is greater than 80 characters Fixes: https://github.com/389ds/389-ds-base/issues/4342 Reviewed by: spichugi(Thanks!)
commit 3a643dc8789b284c7f707e5cc7bb0ca76505ac55 Author: Mark Reynolds <[email protected]> Date: Thu Sep 24 10:50:36 2020 -0400 Issue 4342 - UI - additional fixes for creation instance modal Description: In the instance creation modal there is an incorrect warning about the port number range. It should state valid port numbers are between 1 and 65535. The root DN character validation allows non ascii as the first characters after the "=". And we are not forewarning about the instance name length if it is greater than 80 characters Fixes: https://github.com/389ds/389-ds-base/issues/4342 Reviewed by: spichugi(Thanks!) diff --git a/src/cockpit/389-console/src/dsModals.jsx b/src/cockpit/389-console/src/dsModals.jsx index 0113bb139..a1a06bdf4 100644 --- a/src/cockpit/389-console/src/dsModals.jsx +++ b/src/cockpit/389-console/src/dsModals.jsx @@ -89,9 +89,11 @@ export class CreateInstanceModal extends React.Component { if (dn.endsWith(",")) { return false; } - // Check that the attr is only letters [A-Za-z]+ and the value is standard - // ascii [ -~]+ that it does not start with a space \\S - let dn_regex = new RegExp("^([A-Za-z]+=\\S[ -~]+$)"); + // Check that the attr is only letters [A-Za-z]+ and the value does not + // start with a space (?=\\S) AND all the characters are standard + // ascii ([ -~]+) + let dn_regex = new RegExp("^([A-Za-z]+=(?=\\S)([ -~]+)$)"); + let result = dn_regex.test(dn); return result; } @@ -109,7 +111,7 @@ export class CreateInstanceModal extends React.Component { if (value == "") { all_good = false; errObj['createServerId'] = true; - } else if (value > 80) { + } else if (value.length > 80) { all_good = false; errObj['createServerId'] = true; modal_msg = "Instance name must be less than 80 characters"; @@ -133,7 +135,7 @@ export class CreateInstanceModal extends React.Component { } else if (!valid_port(value)) { all_good = false; errObj['createPort'] = true; - modal_msg = "Invalid Port number. The port must be between 1 and 65534"; + modal_msg = "Invalid Port number. The port must be between 1 and 65535"; } } else if (this.state.createPort == "") { all_good = false; @@ -141,7 +143,7 @@ export class CreateInstanceModal extends React.Component { } else if (!valid_port(this.state.createPort)) { all_good = false; errObj['createPort'] = true; - modal_msg = "Invalid Port number. The port must be between 1 and 65534"; + modal_msg = "Invalid Port number. The port must be between 1 and 65535"; } if (target_id == 'createSecurePort') { if (value == "") { @@ -150,7 +152,7 @@ export class CreateInstanceModal extends React.Component { } else if (!valid_port(value)) { all_good = false; errObj['createSecurePort'] = true; - modal_msg = "Invalid Secure Port number. Port must be between 1 and 65534"; + modal_msg = "Invalid Secure Port number. Port must be between 1 and 65535"; } } else if (this.state.createSecurePort == "") { all_good = false; @@ -616,7 +618,7 @@ export class CreateInstanceModal extends React.Component { <Col componentClass={ControlLabel} sm={5} - title="The DN for the unrestricted user" + title="The DN for the unrestricted user" > Directory Manager DN </Col>
0
38926b72871d258d6d4b61ded76e5a17a68f7ebe
389ds/389-ds-base
Cleaned up UI for rebranding - [email protected]
commit 38926b72871d258d6d4b61ded76e5a17a68f7ebe Author: Nathan Kinder <[email protected]> Date: Tue Jan 25 23:02:22 2005 +0000 Cleaned up UI for rebranding - [email protected] diff --git a/ldap/clients/dsgw/pbhtml/phone.html b/ldap/clients/dsgw/pbhtml/phone.html index a9f496127..4a79960e8 100644 --- a/ldap/clients/dsgw/pbhtml/phone.html +++ b/ldap/clients/dsgw/pbhtml/phone.html @@ -41,7 +41,7 @@ window.location.href=i; <tr> <td> -<IMG src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=clear.gif" width="10" height="37" border="0"> +<IMG src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=clear.gif" width="10" height="40" border="0"> </td> <TD ALIGN=LEFT VALIGN=CENTER nowrap> <a href="javascript:alert('Powered by Netscape Directory Server 6.2')" onMouseOver="window.status='Click for more information about Netscape Directory Express.'; return true"><img src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=brandblock.gif" border="0" align="left"></a></td> @@ -76,12 +76,37 @@ window.location.href=i; <TD valign="top" colspan="5" width="100%"><IMG src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=clear.gif" width="1" height="5" border="0"></TD> </TR> -<TR> -<TD width="100%" colspan="5" class="bgColor7"><IMG src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=clear.gif" height="1" border="0"></TD> -</TR> - </table> </form> </body> </html> + +Index: phone.html +=================================================================== +RCS file: /hurricane/cvs/spd/ldapserver/ldap/clients/dsgw/pbhtml/phone.html,v +retrieving revision 1.1.1.1 +diff -c -u -r1.1.1.1 phone.html +cvs server: conflicting specifications of output style +--- phone.html 21 Jan 2005 00:40:49 -0000 1.1.1.1 ++++ phone.html 25 Jan 2005 22:25:40 -0000 +@@ -41,7 +41,7 @@ + + <tr> + <td> +-<IMG src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=clear.gif" width="10" height="37" border="0"> ++<IMG src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=clear.gif" width="10" height="40" border="0"> + </td> + <TD ALIGN=LEFT VALIGN=CENTER nowrap> + <a href="javascript:alert('Powered by Netscape Directory Server 6.2')" onMouseOver="window.status='Click for more information about Netscape Directory Express.'; return true"><img src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=brandblock.gif" border="0" align="left"></a></td> +@@ -74,10 +74,6 @@ + + <TR> + <TD valign="top" colspan="5" width="100%"><IMG src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=clear.gif" width="1" height="5" border="0"></TD> +-</TR> +- +-<TR> +-<TD width="100%" colspan="5" class="bgColor7"><IMG src="/clients/dsgw/bin/lang?<!-- GCONTEXT -->&file=clear.gif" height="1" border="0"></TD> + </TR> + + </table> diff --git a/ldap/clients/dsgw/pbhtml/style.css b/ldap/clients/dsgw/pbhtml/style.css index e4739d6f7..1cb0c3354 100644 --- a/ldap/clients/dsgw/pbhtml/style.css +++ b/ldap/clients/dsgw/pbhtml/style.css @@ -57,7 +57,7 @@ A.searchlinkspec:active {color: #CCFFFF} /* *********Search frame*************/ body.Search { - background-color: #003366; + background-color: #000000; font-family: Verdana, Arial, Helvetica, san-serif; color: #ccffff; font-size: 12px; @@ -65,17 +65,17 @@ body.Search { td.appName { font-family: verdana, Arial, Helvetica, sans-serif; - font-size: 12px; + font-size: 14px; vertical-align : middle; - color: #ccffff; + color: #ffffff; font-weight: bold; } .apptext { font-family: verdana, Arial, Helvetica, sans-serif; - font-size: 12px; + font-size: 14px; vertical-align: middle; - color: #ccffff; + color: #ffffff; } /* Fonts */
0
9f97f7486d36544038eaa52e92b802e033a62025
389ds/389-ds-base
Resolves: 211234 Made build-system support building multiple archs from one source tree.
commit 9f97f7486d36544038eaa52e92b802e033a62025 Author: Nathan Kinder <[email protected]> Date: Wed Oct 18 16:01:50 2006 +0000 Resolves: 211234 Made build-system support building multiple archs from one source tree. diff --git a/Makefile.am b/Makefile.am index 453a96b50..758d31911 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,14 +4,14 @@ ACLOCAL_AMFLAGS = -I m4 #------------------------ # Compiler Flags #------------------------ -BUILDNUM := $(shell perl buildnum.pl) +BUILDNUM := $(shell perl $(srcdir)/buildnum.pl) PLATFORM_DEFINES = @platform_defs@ # NGK - Other defines which may need to be conditionally set DS_DEFINES = -DNS_DS -DNET_SSL -DLDAP_DEBUG -DLDAP_DONT_USE_SMARTHEAP \ -DUPGRADEDB -DNSPR20 -DLDAPDB_THREAD_SAFE -DCLIENT_AUTH \ -DMCC_HTTPD -DNS_DOMESTIC -DSPAPI20 -DSERVER_BUILD \ -DBUILD_NUM=$(BUILDNUM) -DS_INCLUDES = -Ildap/include -Ildap/servers/slapd -Iinclude +DS_INCLUDES = -I$(srcdir)/ldap/include -I$(srcdir)/ldap/servers/slapd -I$(srcdir)/include -I. AM_CPPFLAGS = $(PLATFORM_DEFINES) $(DS_DEFINES) $(DS_INCLUDES) PLUGIN_CPPFLAGS = $(AM_CPPFLAGS) @ldapsdk_inc@ @nss_inc@ @nspr_inc@ @@ -31,17 +31,15 @@ PAM_LINK = -lpam #------------------------ # Generated Sources #------------------------ -BUILT_SOURCES = ldap/include/dirver.h \ - ldap/include/dberrstrs.h +BUILT_SOURCES = dirver.h dberrstrs.h -CLEANFILES = ldap/include/dirver.h \ - ldap/include/dberrstrs.h +CLEANFILES = dirver.h dberrstrs.h ns-slapd.properties -ldap/include/dirver.h: Makefile - perl dirver.pl -v "$(VERSION)" -o ldap/include/dirver.h +dirver.h: Makefile + perl $(srcdir)/dirver.pl -v "$(VERSION)" -o dirver.h -ldap/include/dberrstrs.h: Makefile - perl ldap/servers/slapd/mkDBErrStrs.pl -i @db_incdir@ -o ldap/include +dberrstrs.h: Makefile + perl $(srcdir)/ldap/servers/slapd/mkDBErrStrs.pl -i @db_incdir@ -o . #------------------------ # Build Products @@ -103,7 +101,7 @@ libldaputil_a_SOURCES = lib/ldaputil/cert.c \ lib/ldaputil/ldapdb.c \ lib/ldaputil/vtable.c -libldaputil_a_CPPFLAGS = $(AM_CPPFLAGS) -Ilib/ldaputil @ldapsdk_inc@ @nss_inc@ @nspr_inc@ +libldaputil_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/lib/ldaputil @ldapsdk_inc@ @nss_inc@ @nspr_inc@ #------------------------ # libldif @@ -138,7 +136,7 @@ libds_admin_la_SOURCES = ldap/admin/lib/dsalib_conf.c \ ldap/admin/lib/dsalib_util.c \ $(libldif_a_SOURCES) -libds_admin_la_CPPFLAGS = $(AM_CPPFLAGS) -Ildap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@ +libds_admin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/ldap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@ libds_admin_la_LIBADD = $(NSS_LINK) $(NSPR_LINK) #------------------------ @@ -198,7 +196,7 @@ libns_dshttpd_la_SOURCES = lib/libaccess/access_plhash.cpp \ lib/libsi18n/txtfile.c \ $(libldaputil_a_SOURCES) -libns_dshttpd_la_CPPFLAGS = -Iinclude/base $(AM_CPPFLAGS) -Ilib/ldaputil @ldapsdk_inc@ @nss_inc@ @nspr_inc@ +libns_dshttpd_la_CPPFLAGS = -I$(srcdir)/include/base $(AM_CPPFLAGS) -I$(srcdir)/lib/ldaputil @ldapsdk_inc@ @nss_inc@ @nspr_inc@ #------------------------ # libslapd @@ -389,7 +387,7 @@ libacl_plugin_la_SOURCES = ldap/servers/plugins/acl/acl.c \ ldap/servers/plugins/acl/aclproxy.c \ ldap/servers/plugins/acl/aclutil.c -libacl_plugin_la_CPPFLAGS = -Iinclude/libaccess $(PLUGIN_CPPFLAGS) +libacl_plugin_la_CPPFLAGS = -I$(srcdir)/include/libaccess $(PLUGIN_CPPFLAGS) libacl_plugin_la_LIBADD = libns-dshttpd.la #------------------------ @@ -399,7 +397,7 @@ libattr_unique_plugin_la_SOURCES = ldap/servers/plugins/uiduniq/7bit.c \ ldap/servers/plugins/uiduniq/uid.c \ ldap/servers/plugins/shared/utils.c -libattr_unique_plugin_la_CPPFLAGS = -Ildap/servers/plugins/shared $(PLUGIN_CPPFLAGS) +libattr_unique_plugin_la_CPPFLAGS = -I$(srcdir)/ldap/servers/plugins/shared $(PLUGIN_CPPFLAGS) #------------------------ # libchainingdb-plugin @@ -501,7 +499,7 @@ libpassthru_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) #------------------------ libpresence_plugin_la_SOURCES = ldap/servers/plugins/presence/presence.c -libpresence_plugin_la_CPPFLAGS = -Ildap/servers/plugins/http $(PLUGIN_CPPFLAGS) +libpresence_plugin_la_CPPFLAGS = -I$(srcdir)/ldap/servers/plugins/http $(PLUGIN_CPPFLAGS) #------------------------ # libpwdstorage-plugin @@ -660,7 +658,7 @@ ds_newinst_SOURCES = ldap/admin/src/cfg_sspt.c \ ldap/admin/src/ds_newinst.c \ ldap/admin/src/script-gen.c -ds_newinst_CPPFLAGS = $(AM_CPPFLAGS) -Ildap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@ +ds_newinst_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/ldap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@ ds_newinst_LDADD = libds_admin.la $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) #------------------------ diff --git a/Makefile.in b/Makefile.in index 2bc6da2a8..b3fe2c206 100644 --- a/Makefile.in +++ b/Makefile.in @@ -871,7 +871,7 @@ ACLOCAL_AMFLAGS = -I m4 #------------------------ # Compiler Flags #------------------------ -BUILDNUM := $(shell perl buildnum.pl) +BUILDNUM := $(shell perl $(srcdir)/buildnum.pl) PLATFORM_DEFINES = @platform_defs@ # NGK - Other defines which may need to be conditionally set DS_DEFINES = -DNS_DS -DNET_SSL -DLDAP_DEBUG -DLDAP_DONT_USE_SMARTHEAP \ @@ -879,7 +879,7 @@ DS_DEFINES = -DNS_DS -DNET_SSL -DLDAP_DEBUG -DLDAP_DONT_USE_SMARTHEAP \ -DMCC_HTTPD -DNS_DOMESTIC -DSPAPI20 -DSERVER_BUILD \ -DBUILD_NUM=$(BUILDNUM) -DS_INCLUDES = -Ildap/include -Ildap/servers/slapd -Iinclude +DS_INCLUDES = -I$(srcdir)/ldap/include -I$(srcdir)/ldap/servers/slapd -I$(srcdir)/include -I. AM_CPPFLAGS = $(PLATFORM_DEFINES) $(DS_DEFINES) $(DS_INCLUDES) PLUGIN_CPPFLAGS = $(AM_CPPFLAGS) @ldapsdk_inc@ @nss_inc@ @nspr_inc@ @@ -899,12 +899,8 @@ PAM_LINK = -lpam #------------------------ # Generated Sources #------------------------ -BUILT_SOURCES = ldap/include/dirver.h \ - ldap/include/dberrstrs.h - -CLEANFILES = ldap/include/dirver.h \ - ldap/include/dberrstrs.h - +BUILT_SOURCES = dirver.h dberrstrs.h +CLEANFILES = dirver.h dberrstrs.h ns-slapd.properties lib_LTLIBRARIES = libslapd.la libback-ldbm.la libds_admin.la libns-dshttpd.la \ libacl-plugin.la libattr-unique-plugin.la libchainingdb-plugin.la \ libcos-plugin.la libdes-plugin.la libdistrib-plugin.la \ @@ -951,7 +947,7 @@ libldaputil_a_SOURCES = lib/ldaputil/cert.c \ lib/ldaputil/ldapdb.c \ lib/ldaputil/vtable.c -libldaputil_a_CPPFLAGS = $(AM_CPPFLAGS) -Ilib/ldaputil @ldapsdk_inc@ @nss_inc@ @nspr_inc@ +libldaputil_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/lib/ldaputil @ldapsdk_inc@ @nss_inc@ @nspr_inc@ #------------------------ # libldif @@ -985,7 +981,7 @@ libds_admin_la_SOURCES = ldap/admin/lib/dsalib_conf.c \ ldap/admin/lib/dsalib_util.c \ $(libldif_a_SOURCES) -libds_admin_la_CPPFLAGS = $(AM_CPPFLAGS) -Ildap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@ +libds_admin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/ldap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@ libds_admin_la_LIBADD = $(NSS_LINK) $(NSPR_LINK) #------------------------ @@ -1045,7 +1041,7 @@ libns_dshttpd_la_SOURCES = lib/libaccess/access_plhash.cpp \ lib/libsi18n/txtfile.c \ $(libldaputil_a_SOURCES) -libns_dshttpd_la_CPPFLAGS = -Iinclude/base $(AM_CPPFLAGS) -Ilib/ldaputil @ldapsdk_inc@ @nss_inc@ @nspr_inc@ +libns_dshttpd_la_CPPFLAGS = -I$(srcdir)/include/base $(AM_CPPFLAGS) -I$(srcdir)/lib/ldaputil @ldapsdk_inc@ @nss_inc@ @nspr_inc@ #------------------------ # libslapd @@ -1234,7 +1230,7 @@ libacl_plugin_la_SOURCES = ldap/servers/plugins/acl/acl.c \ ldap/servers/plugins/acl/aclproxy.c \ ldap/servers/plugins/acl/aclutil.c -libacl_plugin_la_CPPFLAGS = -Iinclude/libaccess $(PLUGIN_CPPFLAGS) +libacl_plugin_la_CPPFLAGS = -I$(srcdir)/include/libaccess $(PLUGIN_CPPFLAGS) libacl_plugin_la_LIBADD = libns-dshttpd.la #------------------------ @@ -1244,7 +1240,7 @@ libattr_unique_plugin_la_SOURCES = ldap/servers/plugins/uiduniq/7bit.c \ ldap/servers/plugins/uiduniq/uid.c \ ldap/servers/plugins/shared/utils.c -libattr_unique_plugin_la_CPPFLAGS = -Ildap/servers/plugins/shared $(PLUGIN_CPPFLAGS) +libattr_unique_plugin_la_CPPFLAGS = -I$(srcdir)/ldap/servers/plugins/shared $(PLUGIN_CPPFLAGS) #------------------------ # libchainingdb-plugin @@ -1344,7 +1340,7 @@ libpassthru_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) # libpresence-plugin #------------------------ libpresence_plugin_la_SOURCES = ldap/servers/plugins/presence/presence.c -libpresence_plugin_la_CPPFLAGS = -Ildap/servers/plugins/http $(PLUGIN_CPPFLAGS) +libpresence_plugin_la_CPPFLAGS = -I$(srcdir)/ldap/servers/plugins/http $(PLUGIN_CPPFLAGS) #------------------------ # libpwdstorage-plugin @@ -1498,7 +1494,7 @@ ds_newinst_SOURCES = ldap/admin/src/cfg_sspt.c \ ldap/admin/src/ds_newinst.c \ ldap/admin/src/script-gen.c -ds_newinst_CPPFLAGS = $(AM_CPPFLAGS) -Ildap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@ +ds_newinst_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/ldap/admin/include @ldapsdk_inc@ @nss_inc@ @nspr_inc@ ds_newinst_LDADD = libds_admin.la $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) #------------------------ @@ -8711,11 +8707,11 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am \ uninstall-nodist_dataDATA -ldap/include/dirver.h: Makefile - perl dirver.pl -v "$(VERSION)" -o ldap/include/dirver.h +dirver.h: Makefile + perl $(srcdir)/dirver.pl -v "$(VERSION)" -o dirver.h -ldap/include/dberrstrs.h: Makefile - perl ldap/servers/slapd/mkDBErrStrs.pl -i @db_incdir@ -o ldap/include +dberrstrs.h: Makefile + perl $(srcdir)/ldap/servers/slapd/mkDBErrStrs.pl -i @db_incdir@ -o . #------------------------ # ns-slapd.properties
0
20efeea75cc6d8b4e5864589f28b2208844bc4a7
389ds/389-ds-base
Ticket 49470 - overflow in pblock_get Bug Description: While getting the connection id we used an int not a uint64_t Fix Description: Make the stack size uint64_t instead. https://pagure.io/389-ds-base/issue/49470 Author: wibrown Review by: tbordaz (thanks)
commit 20efeea75cc6d8b4e5864589f28b2208844bc4a7 Author: William Brown <[email protected]> Date: Tue Nov 28 15:31:25 2017 +0100 Ticket 49470 - overflow in pblock_get Bug Description: While getting the connection id we used an int not a uint64_t Fix Description: Make the stack size uint64_t instead. https://pagure.io/389-ds-base/issue/49470 Author: wibrown Review by: tbordaz (thanks) diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c index 6309975ae..0dcac646b 100644 --- a/ldap/servers/slapd/modify.c +++ b/ldap/servers/slapd/modify.c @@ -281,11 +281,12 @@ do_modify(Slapi_PBlock *pb) if (ignored_some_mods && (0 == smods.num_elements)) { if (pb_conn->c_isreplication_session) { - int connid, opid; + uint64_t connid; + int32_t opid; slapi_pblock_get(pb, SLAPI_CONN_ID, &connid); slapi_pblock_get(pb, SLAPI_OPERATION_ID, &opid); slapi_log_err(SLAPI_LOG_ERR, "do_modify", - "Rejecting replicated password policy operation(conn=%d op=%d) for " + "Rejecting replicated password policy operation(conn=%"PRIu64" op=%d) for " "entry %s. To allow these changes to be accepted, set passwordIsGlobalPolicy to 'on' in " "cn=config.\n", connid, opid, rawdn); diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index 8f87de5b5..4514c3ce6 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -412,7 +412,7 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value) "slapi_pblock_get", "Connection is NULL and hence cannot access SLAPI_CONN_ID \n"); return (-1); } - (*(PRUint64 *)value) = pblock->pb_conn->c_connid; + (*(uint64_t *)value) = pblock->pb_conn->c_connid; break; case SLAPI_CONN_DN: /* @@ -2538,7 +2538,7 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value) "slapi_pblock_set", "Connection is NULL and hence cannot access SLAPI_CONN_ID \n"); return (-1); } - pblock->pb_conn->c_connid = *((PRUint64 *)value); + pblock->pb_conn->c_connid = *((uint64_t *)value); break; case SLAPI_CONN_DN: /* diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 782631b7b..3c8bc3564 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -1604,7 +1604,7 @@ typedef struct conn int c_gettingber; /* in the middle of ber_get_next */ BerElement *c_currentber; /* ber we're getting */ time_t c_starttime; /* when the connection was opened */ - PRUint64 c_connid; /* id of this connection for stats*/ + uint64_t c_connid; /* id of this connection for stats*/ PRUint64 c_maxthreadscount; /* # of times a conn hit max threads */ PRUint64 c_maxthreadsblocked; /* # of operations blocked by maxthreads */ int c_opsinitiated; /* # ops initiated/next op id */
0
c439b9205967e99645edf57d188737d0b7820a85
389ds/389-ds-base
Issue 49381 - Refactor the plugin test suite docstrings Description: Remove attr_uniqueness_test.py and dna_test.py because they are present in acceptance_test.py. Refactor the docstrings in the existing suites. https://pagure.io/389-ds-base/issue/49381 Reviewed by: vashirov, mreynolds (Thanks!)
commit c439b9205967e99645edf57d188737d0b7820a85 Author: Simon Pichugin <[email protected]> Date: Mon Jul 16 15:51:44 2018 +0200 Issue 49381 - Refactor the plugin test suite docstrings Description: Remove attr_uniqueness_test.py and dna_test.py because they are present in acceptance_test.py. Refactor the docstrings in the existing suites. https://pagure.io/389-ds-base/issue/49381 Reviewed by: vashirov, mreynolds (Thanks!) diff --git a/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py b/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py deleted file mode 100644 index f9905f959..000000000 --- a/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py +++ /dev/null @@ -1,196 +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 DEFAULT_SUFFIX, PLUGIN_ATTR_UNIQUENESS - -USER1_DN = 'uid=user1,' + DEFAULT_SUFFIX -USER2_DN = 'uid=user2,' + DEFAULT_SUFFIX - -logging.getLogger(__name__).setLevel(logging.DEBUG) -log = logging.getLogger(__name__) - - -def test_attr_uniqueness_init(topology_st): - ''' - Enable dynamic plugins - makes things easier - ''' - 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 - - topology_st.standalone.plugins.enable(name=PLUGIN_ATTR_UNIQUENESS) - - -def test_attr_uniqueness(topology_st): - log.info('Running test_attr_uniqueness...') - - # - # Configure plugin - # - try: - topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config', - [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'uid')]) - - except ldap.LDAPError as e: - log.fatal('test_attr_uniqueness: Failed to configure plugin for "uid": error ' + e.message['desc']) - assert False - - # Add an entry - try: - topology_st.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(), - 'sn': '1', - 'cn': 'user 1', - 'uid': 'user1', - 'mail': '[email protected]', - 'mailAlternateAddress': '[email protected]', - 'userpassword': 'password'}))) - except ldap.LDAPError as e: - log.fatal('test_attr_uniqueness: Failed to add test user' + USER1_DN + ': error ' + e.message['desc']) - assert False - - # Add an entry with a duplicate "uid" - try: - topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(), - 'sn': '2', - 'cn': 'user 2', - 'uid': 'user2', - 'uid': 'user1', - 'userpassword': 'password'}))) - except ldap.CONSTRAINT_VIOLATION: - pass - else: - log.fatal('test_attr_uniqueness: Adding of 2nd entry(uid) incorrectly succeeded') - assert False - - # - # Change config to use "mail" instead of "uid" - # - try: - topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config', - [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'mail')]) - - except ldap.LDAPError as e: - log.fatal('test_attr_uniqueness: Failed to configure plugin for "mail": error ' + e.message['desc']) - assert False - - # - # Test plugin - Add an entry, that has a duplicate "mail" value - # - try: - topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(), - 'sn': '2', - 'cn': 'user 2', - 'uid': 'user2', - 'mail': '[email protected]', - 'userpassword': 'password'}))) - except ldap.CONSTRAINT_VIOLATION: - pass - else: - log.fatal('test_attr_uniqueness: Adding of 2nd entry(mail) incorrectly succeeded') - assert False - - # - # Reconfigure plugin for mail and mailAlternateAddress - # - try: - topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config', - [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'mail'), - (ldap.MOD_ADD, 'uniqueness-attribute-name', - b'mailAlternateAddress')]) - except ldap.LDAPError as e: - log.error('test_attr_uniqueness: Failed to reconfigure plugin for "mail mailAlternateAddress": error ' + - e.message['desc']) - assert False - - # - # Test plugin - Add an entry, that has a duplicate "mail" value - # - try: - topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(), - 'sn': '2', - 'cn': 'user 2', - 'uid': 'user2', - 'mail': '[email protected]', - 'userpassword': 'password'}))) - except ldap.CONSTRAINT_VIOLATION: - pass - else: - log.error('test_attr_uniqueness: Adding of 3rd entry(mail) incorrectly succeeded') - assert False - - # - # Test plugin - Add an entry, that has a duplicate "mailAlternateAddress" value - # - try: - topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(), - 'sn': '2', - 'cn': 'user 2', - 'uid': 'user2', - 'mailAlternateAddress': '[email protected]', - 'userpassword': 'password'}))) - except ldap.CONSTRAINT_VIOLATION: - pass - else: - log.error('test_attr_uniqueness: Adding of 4th entry(mailAlternateAddress) incorrectly succeeded') - assert False - - # - # Test plugin - Add an entry, that has a duplicate "mail" value conflicting mailAlternateAddress - # - try: - topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(), - 'sn': '2', - 'cn': 'user 2', - 'uid': 'user2', - 'mail': '[email protected]', - 'userpassword': 'password'}))) - except ldap.CONSTRAINT_VIOLATION: - pass - else: - log.error('test_attr_uniqueness: Adding of 5th entry(mailAlternateAddress) incorrectly succeeded') - assert False - - # - # Test plugin - Add an entry, that has a duplicate "mailAlternateAddress" conflicting mail - # - try: - topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(), - 'sn': '2', - 'cn': 'user 2', - 'uid': 'user2', - 'mailAlternateAddress': '[email protected]', - 'userpassword': 'password'}))) - except ldap.CONSTRAINT_VIOLATION: - pass - else: - log.error('test_attr_uniqueness: Adding of 6th entry(mail) incorrectly succeeded') - assert False - - # - # Cleanup - # - try: - topology_st.standalone.delete_s(USER1_DN) - except ldap.LDAPError as e: - log.fatal('test_attr_uniqueness: Failed to delete test entry: ' + e.message['desc']) - assert False - - log.info('test_attr_uniqueness: PASS\n') - - -if __name__ == '__main__': - # Run isolated - # -s for DEBUG mode - CURRENT_FILE = os.path.realpath(__file__) - pytest.main("-s %s" % CURRENT_FILE) diff --git a/dirsrvtests/tests/suites/plugins/dna_test.py b/dirsrvtests/tests/suites/plugins/dna_test.py deleted file mode 100644 index 370867e25..000000000 --- a/dirsrvtests/tests/suites/plugins/dna_test.py +++ /dev/null @@ -1,168 +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_DNA, DEFAULT_SUFFIX - -logging.getLogger(__name__).setLevel(logging.DEBUG) -log = logging.getLogger(__name__) - -USER1_DN = 'uid=user1,' + DEFAULT_SUFFIX -USER2_DN = 'uid=user2,' + DEFAULT_SUFFIX -USER3_DN = 'uid=user3,' + DEFAULT_SUFFIX -BUSER1_DN = 'uid=user1,ou=branch1,' + DEFAULT_SUFFIX -BUSER2_DN = 'uid=user2,ou=branch2,' + DEFAULT_SUFFIX -BUSER3_DN = 'uid=user3,ou=branch2,' + DEFAULT_SUFFIX -BRANCH1_DN = 'ou=branch1,' + DEFAULT_SUFFIX -BRANCH2_DN = 'ou=branch2,' + DEFAULT_SUFFIX -GROUP_OU = 'ou=groups,' + DEFAULT_SUFFIX -PEOPLE_OU = 'ou=people,' + DEFAULT_SUFFIX -GROUP_DN = 'cn=group,' + DEFAULT_SUFFIX -CONFIG_AREA = 'nsslapd-pluginConfigArea' - - -def test_basic(topology_st): - """Test basic functionality""" - - # Stop the plugin, and start it - topology_st.standalone.plugins.disable(name=PLUGIN_DNA) - topology_st.standalone.plugins.enable(name=PLUGIN_DNA) - - CONFIG_DN = 'cn=config,cn=' + PLUGIN_DNA + ',cn=plugins,cn=config' - - log.info('Testing ' + PLUGIN_DNA + '...') - - ############################################################################ - # Configure plugin - ############################################################################ - - try: - topology_st.standalone.add_s(Entry((CONFIG_DN, { - 'objectclass': 'top dnaPluginConfig'.split(), - 'cn': 'config', - 'dnatype': 'uidNumber', - 'dnafilter': '(objectclass=top)', - 'dnascope': DEFAULT_SUFFIX, - 'dnaMagicRegen': '-1', - 'dnaMaxValue': '50000', - 'dnaNextValue': '1' - }))) - except ldap.ALREADY_EXISTS: - try: - topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaNextValue', b'1'), - (ldap.MOD_REPLACE, 'dnaMagicRegen', b'-1')]) - except ldap.LDAPError as e: - log.fatal('test_dna: Failed to set the DNA plugin: error ' + e.message['desc']) - assert False - except ldap.LDAPError as e: - log.fatal('test_dna: Failed to add config entry: error ' + e.message['desc']) - assert False - - # Do we need to restart for the plugin? - - topology_st.standalone.restart() - - ############################################################################ - # Test plugin - ############################################################################ - - try: - topology_st.standalone.add_s(Entry((USER1_DN, { - 'objectclass': 'top extensibleObject'.split(), - 'uid': 'user1' - }))) - except ldap.LDAPError as e: - log.fatal('test_dna: Failed to user1: error ' + e.message['desc']) - assert False - - # See if the entry now has the new uidNumber assignment - uidNumber=1 - try: - entries = topology_st.standalone.search_s(USER1_DN, ldap.SCOPE_BASE, '(uidNumber=1)') - if not entries: - log.fatal('test_dna: user1 was not updated - (looking for uidNumber: 1)') - assert False - except ldap.LDAPError as e: - log.fatal('test_dna: Search for user1 failed: ' + e.message['desc']) - assert False - - # Test the magic regen value - try: - topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', b'-1')]) - except ldap.LDAPError as e: - log.fatal('test_dna: Failed to set the magic reg value: error ' + e.message['desc']) - assert False - - # See if the entry now has the new uidNumber assignment - uidNumber=2 - try: - entries = topology_st.standalone.search_s(USER1_DN, ldap.SCOPE_BASE, '(uidNumber=2)') - if not entries: - log.fatal('test_dna: user1 was not updated (looking for uidNumber: 2)') - assert False - except ldap.LDAPError as e: - log.fatal('test_dna: Search for user1 failed: ' + e.message['desc']) - assert False - - ################################################################################ - # Change the config - ################################################################################ - - try: - topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaMagicRegen', b'-2')]) - except ldap.LDAPError as e: - log.fatal('test_dna: Failed to set the magic reg value to -2: error ' + e.message['desc']) - assert False - - ################################################################################ - # Test plugin - ################################################################################ - - # Test the magic regen value - try: - topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', b'-2')]) - except ldap.LDAPError as e: - log.fatal('test_dna: Failed to set the magic reg value: error ' + e.message['desc']) - assert False - - # See if the entry now has the new uidNumber assignment - uidNumber=3 - try: - entries = topology_st.standalone.search_s(USER1_DN, ldap.SCOPE_BASE, '(uidNumber=3)') - if not entries: - log.fatal('test_dna: user1 was not updated (looking for uidNumber: 3)') - assert False - except ldap.LDAPError as e: - log.fatal('test_dna: Search for user1 failed: ' + e.message['desc']) - assert False - - ############################################################################ - # Test plugin dependency - ############################################################################ - - # test_dependency(inst, PLUGIN_AUTOMEMBER) - - ############################################################################ - # Cleanup - ############################################################################ - - try: - topology_st.standalone.delete_s(USER1_DN) - except ldap.LDAPError as e: - log.fatal('test_dna: Failed to delete test entry1: ' + e.message['desc']) - assert False - - topology_st.standalone.plugins.disable(name=PLUGIN_DNA) - - -if __name__ == '__main__': - # Run isolated - # -s for DEBUG mode - CURRENT_FILE = os.path.realpath(__file__) - pytest.main("-s %s" % CURRENT_FILE) diff --git a/dirsrvtests/tests/suites/plugins/memberof_test.py b/dirsrvtests/tests/suites/plugins/memberof_test.py index 882f55710..c0e58097f 100644 --- a/dirsrvtests/tests/suites/plugins/memberof_test.py +++ b/dirsrvtests/tests/suites/plugins/memberof_test.py @@ -43,6 +43,7 @@ def _set_memberofgroupattr_add(topology_st, values): def _get_user_rdn(ext): return ensure_bytes("uid=%s_%s" % (USER_RDN, ext)) + def _get_user_dn(ext): return ensure_bytes("%s,%s" % (ensure_str(_get_user_rdn(ext)), USERS_CONTAINER)) @@ -102,7 +103,6 @@ def _check_memberattr(topology_st, entry, memberattr, value): return found - def _check_memberof(topology_st, member, group): log.info("Lookup memberof from %s" % member) entry = topology_st.standalone.getEntry(ensure_str(member), ldap.SCOPE_BASE, '(objectclass=*)', ['memberof']) @@ -119,24 +119,19 @@ def _check_memberof(topology_st, member, group): return found -def text_memberof_683241_01(topology_st): - """ - Test Modify the memberof plugin to use the new type - """ - topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, - [(ldap.MOD_REPLACE, - PLUGIN_TYPE, - b'betxnpostoperation')]) - topology_st.standalone.restart() - ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_TYPE]) - assert ent.hasAttr(PLUGIN_TYPE) - assert ent.getValue(PLUGIN_TYPE) == 'betxnpostoperation' - +def test_betxnpostoperation_replace(topology_st): + """Test modify the memberof plugin operation to use the new type -def text_memberof_683241_01(topology_st): - """ - Test Modify the memberof plugin to use the new type + :id: d222af17-17a6-48a0-8f22-a38306726a91 + :setup: Standalone instance + :steps: + 1. Set plugin type to betxnpostoperation + 2. Check is was changed + :expectedresults: + 1. Success + 2. Success """ + topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN, [(ldap.MOD_REPLACE, PLUGIN_TYPE, @@ -144,13 +139,22 @@ def text_memberof_683241_01(topology_st): topology_st.standalone.restart() ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_TYPE]) assert ent.hasAttr(PLUGIN_TYPE) - assert ent.getValue(PLUGIN_TYPE) == 'betxnpostoperation' + assert ent.getValue(PLUGIN_TYPE) == b'betxnpostoperation' -def test_memberof_MultiGrpAttr_001(topology_st): - """ - Checking multiple grouping attributes supported +def test_memberofgroupattr_add(topology_st): + """Check multiple grouping attributes supported + + :id: d222af17-17a6-48a0-8f22-a38306726a92 + :setup: Standalone instance + :steps: + 1. Add memberofgroupattr - 'uniqueMember' + 2. Check we have 'uniqueMember' and 'member' values + :expectedresults: + 1. Success + 2. Success """ + _set_memberofgroupattr_add(topology_st, 'uniqueMember') ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_MEMBEROF_GRP_ATTR]) @@ -159,10 +163,19 @@ def test_memberof_MultiGrpAttr_001(topology_st): assert b'uniqueMember'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)] -def test_memberof_MultiGrpAttr_003(topology_st): - """ - Check the plug-in is started +def test_enable(topology_st): + """Check the plug-in is started + + :id: d222af17-17a6-48a0-8f22-a38306726a93 + :setup: Standalone instance + :steps: + 1. Enable the plugin + 2. Restart the instance + :expectedresults: + 1. Success + 2. Server should start and plugin should be on """ + log.info("Enable MemberOf plugin") topology_st.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) topology_st.standalone.restart() @@ -171,10 +184,21 @@ def test_memberof_MultiGrpAttr_003(topology_st): assert ent.getValue(PLUGIN_ENABLED).lower() == b'on' -def test_memberof_MultiGrpAttr_004(topology_st): - """ - MemberOf attribute should be successfully added to both the users +def test_member_add(topology_st): + """MemberOf attribute should be successfully added to both the users + + :id: d222af17-17a6-48a0-8f22-a38306726a94 + :setup: Standalone instance + :steps: + 1. Create user and groups + 2. Add the users as members to the groups + 3. Check the membership + :expectedresults: + 1. Success + 2. Success + 3. Success """ + memofenh1 = _create_user(topology_st, 'memofenh1') memofenh2 = _create_user(topology_st, 'memofenh2') @@ -199,10 +223,19 @@ def test_memberof_MultiGrpAttr_004(topology_st): assert _check_memberof(topology_st, member=memofenh2, group=memofegrp2) -def test_memberof_MultiGrpAttr_005(topology_st): - """ - Partial removal of memberofgroupattr: removing member attribute from Group1 +def test_member_delete_gr1(topology_st): + """Partial removal of memberofgroupattr: removing member attribute from Group1 + + :id: d222af17-17a6-48a0-8f22-a38306726a95 + :setup: Standalone instance + :steps: + 1. Delete a member: enh1 in grp1 + 2. Check the states of the members were changed accordingly + :expectedresults: + 1. Success + 2. Success """ + memofenh1 = _get_user_dn('memofenh1') memofenh2 = _get_user_dn('memofenh2') @@ -221,10 +254,19 @@ def test_memberof_MultiGrpAttr_005(topology_st): assert _check_memberof(topology_st, member=memofenh2, group=memofegrp2) -def test_memberof_MultiGrpAttr_006(topology_st): - """ - Partial removal of memberofgroupattr: removing uniqueMember attribute from Group2 +def test_member_delete_gr2(topology_st): + """Partial removal of memberofgroupattr: removing uniqueMember attribute from Group2 + + :id: d222af17-17a6-48a0-8f22-a38306726a96 + :setup: Standalone instance + :steps: + 1. Delete a uniqueMember: enh2 in grp2 + 2. Check the states of the members were changed accordingly + :expectedresults: + 1. Success + 2. Success """ + memofenh1 = _get_user_dn('memofenh1') memofenh2 = _get_user_dn('memofenh2') @@ -244,10 +286,19 @@ def test_memberof_MultiGrpAttr_006(topology_st): assert not _check_memberof(topology_st, member=memofenh2, group=memofegrp2) -def test_memberof_MultiGrpAttr_007(topology_st): - """ - Complete removal of memberofgroupattr +def test_member_delete_all(topology_st): + """Complete removal of memberofgroupattr + + :id: d222af17-17a6-48a0-8f22-a38306726a97 + :setup: Standalone instance + :steps: + 1. Delete the rest of the members + 2. Check the states of the members were changed accordingly + :expectedresults: + 1. Success + 2. Success """ + memofenh1 = _get_user_dn('memofenh1') memofenh2 = _get_user_dn('memofenh2') @@ -271,10 +322,21 @@ def test_memberof_MultiGrpAttr_007(topology_st): assert not _check_memberof(topology_st, member=memofenh2, group=memofegrp2) -def test_memberof_MultiGrpAttr_008(topology_st): - """ - MemberOf attribute should be present on both the users +def test_member_after_restart(topology_st): + """MemberOf attribute should be present on both the users + + :id: d222af17-17a6-48a0-8f22-a38306726a98 + :setup: Standalone instance + :steps: + 1. Add a couple of members to the groups + 2. Restart the instance + 3. Check the states of the members were changed accordingly + :expectedresults: + 1. Success + 2. Success + 3. Success """ + memofenh1 = _get_user_dn('memofenh1') memofenh2 = _get_user_dn('memofenh2') @@ -317,10 +379,17 @@ def test_memberof_MultiGrpAttr_008(topology_st): topology_st.standalone.restart() -def test_memberof_MultiGrpAttr_009(topology_st): - """ - MemberOf attribute should not be added to the user since memberuid is not a DN syntax attribute +def test_memberofgroupattr_uid(topology_st): + """MemberOf attribute should not be added to the user since memberuid is not a DN syntax attribute + + :id: d222af17-17a6-48a0-8f22-a38306726a99 + :setup: Standalone instance + :steps: + 1. Try to add memberUid to the group + :expectedresults: + 1. It should fail with Unwilling to perform error """ + try: _set_memberofgroupattr_add(topology_st, 'memberUid') log.error("Setting 'memberUid' as memberofgroupattr should be rejected") @@ -330,16 +399,19 @@ def test_memberof_MultiGrpAttr_009(topology_st): assert True -def test_memberof_MultiGrpAttr_010(topology_st): - """ - Duplicate member attribute to groups +def test_member_add_duplicate_usr1(topology_st): + """Duplicate member attribute to groups + + :id: d222af17-17a6-48a0-8f22-a38306726a10 + :setup: Standalone instance + :steps: + 1. Try to add a member: enh1 which already exists + :expectedresults: + 1. It should fail with Type of value exists error """ memofenh1 = _get_user_dn('memofenh1') - memofenh2 = _get_user_dn('memofenh2') - memofegrp1 = _get_group_dn('memofegrp1') - memofegrp2 = _get_group_dn('memofegrp2') # assert enh1 is member of grp1 assert _check_memberof(topology_st, member=memofenh1, group=memofegrp1) @@ -356,17 +428,15 @@ def test_memberof_MultiGrpAttr_010(topology_st): assert True -def test_memberof_MultiGrpAttr_011(topology_st): - """ - Duplicate uniqueMember attributes to groups - - At the beginning: - memofenh1 is memberof memofegrp1 - memofenh2 is memberof memofegrp2 +def test_member_add_duplicate_usr2(topology_st): + """Duplicate uniqueMember attributes to groups - At the end - memofenh1 is memberof memofegrp1 - memofenh2 is memberof memofegrp2 + :id: d222af17-17a6-48a0-8f22-a38306726a11 + :setup: Standalone instance + :steps: + 1. Try to add a uniqueMember: enh2 which already exists + :expectedresults: + 1. It should fail with Type of value exists error """ memofenh1 = _get_user_dn('memofenh1') @@ -405,63 +475,75 @@ def test_memberof_MultiGrpAttr_011(topology_st): assert _check_memberof(topology_st, member=memofenh2, group=memofegrp2) -def test_memberof_MultiGrpAttr_012(topology_st): - """ - MemberURL attritbute should reflect the modrdn changes in the group. - - This test has been covered in MODRDN test suite - - At the beginning: - memofenh1 is memberof memofegrp1 - memofenh2 is memberof memofegrp2 - - At the end - memofenh1 is memberof memofegrp1 - memofenh2 is memberof memofegrp2 - """ - pass - - -def test_memberof_MultiGrpAttr_013(topology_st): - """ - MemberURL attritbute should reflect the modrdn changes in the group. - - This test has been covered in MODRDN test suite - - At the beginning: - memofenh1 is memberof memofegrp1 - memofenh2 is memberof memofegrp2 - - At the end - memofenh1 is memberof memofegrp1 - memofenh2 is memberof memofegrp2 - """ - pass +#def test_memberof_MultiGrpAttr_012(topology_st): +# """ +# MemberURL attritbute should reflect the modrdn changes in the group. +# +# This test has been covered in MODRDN test suite +# +# At the beginning: +# memofenh1 is memberof memofegrp1 +# memofenh2 is memberof memofegrp2 +# +# At the end +# memofenh1 is memberof memofegrp1 +# memofenh2 is memberof memofegrp2 +# """ +# pass -def test_memberof_MultiGrpAttr_014(topology_st): - """ - Both member and uniqueMember pointing to the same user +#def test_memberof_MultiGrpAttr_013(topology_st): +# """ +# MemberURL attritbute should reflect the modrdn changes in the group. +# +# This test has been covered in MODRDN test suite +# +# At the beginning: +# memofenh1 is memberof memofegrp1 +# memofenh2 is memberof memofegrp2 +# +# At the end +# memofenh1 is memberof memofegrp1 +# memofenh2 is memberof memofegrp2 +# """ +# pass - At the beginning: - enh1 is member of - - grp1 (member) - - not grp2 - enh2 is member of - - not grp1 - - grp2 (uniquemember) +def test_member_uniquemember_same_user(topology_st): + """Check the situation when both member and uniqueMember + pointing to the same user - At the end - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a13 + :setup: Standalone instance, grp3, + enh1 is member of - grp1 (member) - not grp2 - - grp3 (uniquemember) - - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - - grp3 (member) + :steps: + 1. Add member: enh1 and uniqueMember: enh1 to grp3 + 2. Assert enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (member uniquemember) + 3. Delete member: enh1 from grp3 + 4. Add member: enh2 to grp3 + 5. Assert enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (uniquemember) + 6. Assert enh2 is member of + - not grp1 + - grp2 (uniquemember) + - grp3 (member) + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success """ memofenh1 = _get_user_dn('memofenh1') @@ -512,7 +594,7 @@ def test_memberof_MultiGrpAttr_014(topology_st): # assert enh2 is member of # - not grp1 - # - not grp2 (uniquemember) + # - grp2 (uniquemember) # - grp3 (member) assert not _check_memberof(topology_st, member=memofenh2, group=memofegrp1) assert _check_memberof(topology_st, member=memofenh2, group=memofegrp2) @@ -544,33 +626,35 @@ def test_memberof_MultiGrpAttr_014(topology_st): assert _check_memberof(topology_st, member=memofenh2, group=memofegrp3) -def test_memberof_MultiGrpAttr_015(topology_st): - """ - Non-existing users to member attribut +def test_member_not_exists(topology_st): + """Check the situation when we add non-existing users to member attribute - At the beginning: - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a14 + :setup: Standalone instance, grp015, + enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) - - enh2 is member of - - not grp1 - - grp2 (uniquemember) - - grp3 (member) - - At the end: - enh1 is member of - - grp1 (member) - - not grp2 - - grp3 (uniquemember) - - not grp015 - - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) - - not grp015 + :steps: + 1. Add member: dummy1 and uniqueMember: dummy2 to grp015 + 2. Assert enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (uniquemember) + - not grp015 + 3. Assert enh2 is member of + - not grp1 + - grp2 (uniquemember) + - grp3 (member) + - not grp015 + :expectedresults: + 1. Success + 2. Success + 3. Success """ memofenh1 = _get_user_dn('memofenh1') @@ -634,37 +718,55 @@ def test_memberof_MultiGrpAttr_015(topology_st): assert not _check_memberof(topology_st, member=memofenh2, group=memofegrp015) -def test_memberof_MultiGrpAttr_016(topology_st): - """ - ldapmodify non-existing users to the member attribute +def test_member_not_exists_complex(topology_st): + """Check the situation when we modify non-existing users member attribute - At the beginning: - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a15 + :setup: Standalone instance, + enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) - not grp015 - - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) - not grp015 - - At the end: - enh1 is member of - - grp1 (member) - - not grp2 - - grp3 (uniquemember) - - not grp015 - - grp016 (member uniquemember) - - enh2 is member of - - not grp1 - - grp2 (uniquemember) - - grp3 (member) - - not grp015 - - not grp016 + :steps: + 1. Add member: enh1 and uniqueMember: enh1 to grp016 + 2. Assert enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (uniquemember) + - not grp15 + - grp16 (member uniquemember) + 3. Assert enh2 is member of + - not grp1 + - grp2 (uniquemember) + - grp3 (member) + - not grp15 + - not grp16 + 4. Add member: dummy1 and uniqueMember: dummy2 to grp016 + 5. Assert enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (uniquemember) + - not grp15 + - grp16 (member uniquemember) + 6. Assert enh2 is member of + - not grp1 + - grp2 (uniquemember) + - grp3 (member) + - not grp15 + - not grp16 + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success """ memofenh1 = _get_user_dn('memofenh1') @@ -772,67 +874,74 @@ def test_memberof_MultiGrpAttr_016(topology_st): assert not _check_memberof(topology_st, member=memofenh2, group=memofegrp016) -def test_memberof_MultiGrpAttr_017(topology_st): - """ - Add user1 and user2 as memberof grp017 +def test_complex_group_scenario_1(topology_st): + """Check the situation when user1 and user2 are memberof grp017 user2 is member of grp017 but not with a memberof attribute (memberUid) - At the beginning: - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a16 + :setup: Standalone instance, grp017, + enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) - not grp015 - grp016 (member uniquemember) - - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) - not grp015 - not grp016 - - At the end: - enh1 is member of - - grp1 (member) - - not grp2 - - grp3 (uniquemember) - - not grp015 - - grp016 (member uniquemember) - - not grp17 - - enh2 is member of - - not grp1 - - grp2 (uniquemember) - - grp3 (member) - - not grp015 - - not grp016 - - not grp017 - - user1 is member of - - not grp1 - - not grp2 - - not grp3 - - not grp015 - - not grp016 - - grp017 (member) - - user2 is member of - - not grp1 - - not grp2 - - not grp3 - - not grp015 - - not grp016 - - grp017 (uniquemember) - - user3 is member of - - not grp1 - - not grp2 - - not grp3 - - not grp015 - - not grp016 - - not grp017 (memberuid) + :steps: + 1. Create user1 as grp17 (member) + 2. Create user2 as grp17 (uniqueMember) + 3. Create user3 as grp17 (memberuid) (not memberof attribute) + 4. Assert enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (uniquemember) + - not grp15 + - grp16 (member uniquemember) + - not grp17 + 5. Assert enh2 is member of + - not grp1 + - grp2 (uniquemember) + - grp3 (member) + - not grp15 + - not grp16 + - not grp17 + 6. Assert user1 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - grp17 (member) + 7. Assert user2 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - grp17 (uniqueMember) + 8. Assert user3 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - NOT grp17 (memberuid) + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success + 7. Success + 8. Success """ + memofenh1 = _get_user_dn('memofenh1') memofenh2 = _get_user_dn('memofenh2') @@ -973,68 +1082,89 @@ def test_memberof_MultiGrpAttr_017(topology_st): assert not _check_memberof(topology_st, member=memofuser3, group=memofegrp017) -def test_memberof_MultiGrpAttr_018(topology_st): - """ - Add user1 and user2 as memberof grp018 +def test_complex_group_scenario_2(topology_st): + """Check the situation when user1 and user2 are memberof grp018 user2 is member of grp018 but not with a memberof attribute (memberUid) - At the beginning: - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a17 + :setup: Standalone instance, grp018, + enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) - not grp015 - grp016 (member uniquemember) - not grp17 - - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) - not grp015 - not grp016 - not grp017 - - user1 is member of + user1 is member of - not grp1 - not grp2 - not grp3 - not grp015 - not grp016 - grp017 (member) - - user2 is member of + user2 is member of - not grp1 - not grp2 - not grp3 - not grp015 - not grp016 - grp017 (uniquemember) - - user3 is member of + user3 is member of - not grp1 - not grp2 - not grp3 - not grp015 - not grp016 - not grp017 (memberuid) - - At the end: - enh1 is member of - - grp1 (member) - - not grp2 - - grp3 (uniquemember) - - not grp015 - - grp016 (member uniquemember) - - not grp018 - - enh2 is member of - - not grp1 - - grp2 (uniquemember) - - grp3 (member) - - not grp015 - - not grp016 - - not grp018 + :steps: + 1. Add user1 as a member of grp18 (member, uniquemember) + 2. Assert user1 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - grp17 (member) + - grp18 (member, uniquemember) + 3. Delete user1 member/uniquemember attributes from grp018 + 4. Assert user1 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - grp17 (member) + - NOT grp18 (memberUid) + 5. Delete user1, user2, user3, grp17 entries + 6. Assert enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (uniquemember) + - not grp15 + - grp16 (member uniquemember) + - not grp018 + 7. Assert enh2 is member of + - not grp1 + - grp2 (uniquemember) + - grp3 (member) + - not grp15 + - not grp16 + - not grp018 + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success + 7. Success """ memofenh1 = _get_user_dn('memofenh1') @@ -1203,46 +1333,112 @@ def test_memberof_MultiGrpAttr_018(topology_st): assert not _check_memberof(topology_st, member=memofenh2, group=memofegrp018) -def test_memberof_MultiGrpAttr_019(topology_st): - """ - Add user2 to grp19_2 - Add user3 to grp19_3 +def test_complex_group_scenario_3(topology_st): + """Test a complex memberOf case: + Add user2 to grp19_2, + Add user3 to grp19_3, Add grp19_2 and grp_19_3 to grp19_1 - At the beginning: - enh1 is member of - - grp1 (member) - - not grp2 - - grp3 (uniquemember) - - not grp015 - - grp016 (member uniquemember) - - not grp018 - - enh2 is member of - - not grp1 - - grp2 (uniquemember) - - grp3 (member) - - not grp015 - - not grp016 - - not grp018 - At the end: - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a18 + :setup: Standalone instance, + enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) - not grp015 - grp016 (member uniquemember) - not grp018 - - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) - not grp015 - not grp016 - not grp018 + :steps: + 1. Create user2 and user3 + 2. Create a group grp019_2 with user2 member + 3. Create a group grp019_3 with user3 member + 4. Create a group grp019_1 with memofegrp019_2, memofegrp019_3 member + 5. Assert memofegrp019_1 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - not grp018 + - not grp19_1 + - not grp019_2 + - not grp019_3 - + 6. Assert memofegrp019_2 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - not grp018 + - grp19_1 + - not grp019_2 + - not grp019_3 + 7. Assert memofegrp019_3 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - not grp018 + - grp19_1 + - not grp019_2 + - not grp019_3 + 8. Assert memofuser2 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - not grp018 + - grp19_1 + - grp019_2 + - not grp019_3 + 9. Assert memofuser3 is member of + - not grp1 + - not grp2 + - not grp3 + - not grp15 + - not grp16 + - not grp018 + - grp19_1 + - not grp019_2 + - grp019_3 + 10. Delete user2, user3, and all grp19* entries + 11. Assert enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (uniquemember) + - not grp15 + - grp16 (member uniquemember) + - not grp018 + 12. Assert enh2 is member of + - not grp1 + - grp2 (uniquemember) + - grp3 (member) + - not grp15 + - not grp16 + - not grp018 + :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 """ memofenh1 = _get_user_dn('memofenh1') @@ -1441,32 +1637,43 @@ def test_memberof_MultiGrpAttr_019(topology_st): assert not _check_memberof(topology_st, member=memofenh2, group=memofegrp018) -def test_memberof_MultiGrpAttr_020(topology_st): - """ +def test_complex_group_scenario_4(topology_st): + """Test a complex memberOf case: Add user1 and grp[1-5] Add user1 member of grp[1-4] Add grp[1-4] member of grp5 Check user1 is member of grp[1-5] - At the beginning: - enh1 is member of + :id: d223af17-17a6-48a0-8f22-a38306726a19 + :setup: Standalone instance, + enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) - not grp015 - grp016 (member uniquemember) - not grp018 - - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) - not grp015 - not grp016 - not grp018 - - At the end: - Idem + :steps: + 1. Create user1 + 2. Create grp[1-5] that can be inetUser (having memberof) + 3. Add user1 to grp[1-4] (uniqueMember) + 4. Create grp5 with grp[1-4] as member + 5. Assert user1 is a member grp[1-5] + 6. Delete user1 and all grp20 entries + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success """ memofenh1 = _get_user_dn('memofenh1') @@ -1543,36 +1750,43 @@ def test_memberof_MultiGrpAttr_020(topology_st): topology_st.standalone.delete_s(ensure_str(grp)) -def test_memberof_MultiGrpAttr_021(topology_st): - """ +def test_complex_group_scenario_5(topology_st): + """Test a complex memberOf case: Add user[1-4] and Grp[1-4] Add userX as uniquemember of GrpX - ADD Grp5 + Add Grp5 Grp[1-4] as members of Grp5 user1 as member of Grp5 Check that user1 is member of Grp1 and Grp5 - check that user* are members of Grp5 + Check that user* are members of Grp5 - At the beginning: - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a20 + :setup: Standalone instance, + enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) - not grp015 - grp016 (member uniquemember) - not grp018 - - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) - not grp015 - not grp016 - not grp018 - - At the end: - - enh1 is member of + :steps: + 1. Create user1-4 + 2. Create grp[1-4] that can be inetUser (having memberof) + 3. Add userX (uniquemember) to grpX + 4. Create grp5 with grp[1-4] as member + user1 + 5. Assert user[1-4] are member of grp20_5 + 6. Assert userX is uniqueMember of grpX + 7. Check that user[1-4] is only 'uniqueMember' of the grp20_[1-4] + 8. Check that grp20_[1-4] are only 'member' of grp20_5 + 9. Check that user1 are only 'member' of grp20_5 + 10. Assert enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) @@ -1580,7 +1794,7 @@ def test_memberof_MultiGrpAttr_021(topology_st): - grp16 (member uniquemember) - not grp018 - not grp20* - enh2 is member of + 11. Assert enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) @@ -1588,11 +1802,18 @@ def test_memberof_MultiGrpAttr_021(topology_st): - not grp16 - not grp018 - not grp20* - - user1 is member of grp20_5 - userX is uniquemember of grp20_X - grp[1-4] are member of grp20_5 - + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success + 7. Success + 8. Success + 9. Success + 10. Success + 11. Success """ memofenh1 = _get_user_dn('memofenh1') @@ -1727,38 +1948,40 @@ def test_memberof_MultiGrpAttr_021(topology_st): assert not _check_memberof(topology_st, member=memofenh2, group=memofegrp020_5) -def test_memberof_MultiGrpAttr_022(topology_st): - """ +def test_complex_group_scenario_6(topology_st): + """Test a complex memberOf case: add userX as member/uniqueMember of GrpX add Grp5 as uniquemember of GrpX (this create a loop) - - At the beginning: - enh1 is member of - - grp1 (member) - - not grp2 - - grp3 (uniquemember) - - not grp15 - - grp16 (member uniquemember) - - not grp018 - - not grp20* - enh2 is member of - - not grp1 - - grp2 (uniquemember) - - grp3 (member) - - not grp15 - - not grp16 - - not grp018 - - not grp20* - - - user1 is member of grp20_5 - userX is uniquemember of grp20_X - grp[1-4] are member of grp20_5 - - At the end: - - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a21 + :setup: Standalone instance + enh1 is member of + - grp1 (member) + - not grp2 + - grp3 (uniquemember) + - not grp15 + - grp16 (member uniquemember) + - not grp018 + - not grp20* + enh2 is member of + - not grp1 + - grp2 (uniquemember) + - grp3 (member) + - not grp15 + - not grp16 + - not grp018 + - not grp20* + user1 is member of grp20_5 + userX is uniquemember of grp20_X + grp[1-4] are member of grp20_5 + :steps: + 1. Add user[1-4] (member) to grp020_[1-4] + 2. Check that user[1-4] are 'member' and 'uniqueMember' of the grp20_[1-4] + 3. Add Grp[1-4] (uniqueMember) to grp5 + 4. Assert user[1-4] are member of grp20_[1-4] + 5. Assert that all groups are members of each others because Grp5 is member of all grp20_[1-4] + 6. Assert user[1-5] is uniqueMember of grp[1-5] + 7. Assert enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) @@ -1766,7 +1989,7 @@ def test_memberof_MultiGrpAttr_022(topology_st): - grp16 (member uniquemember) - not grp018 - not grp20* - enh2 is member of + 8. Assert enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) @@ -1774,11 +1997,15 @@ def test_memberof_MultiGrpAttr_022(topology_st): - not grp16 - not grp018 - not grp20* - - grp[1-4] are member of grp20_5 - user1 is member (member) of group_5 - grp5 is uniqueMember of grp20_[1-4] - user[1-4] is member/uniquemember of grp20_[1-4] + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success + 7. Success + 8. Success """ memofenh1 = _get_user_dn('memofenh1') @@ -2009,13 +2236,12 @@ def verify_post_023(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, assert _check_memberof(topology_st, member=memofuser1, group=grp) -def test_memberof_MultiGrpAttr_023(topology_st): - """ - - +def test_complex_group_scenario_7(topology_st): + """Check the user removal from the complex membership topology - At the beginning: - enh1 is member of + :id: d222af17-17a6-48a0-8f22-a38306726a22 + :setup: Standalone instance, + enh1 is member of - grp1 (member) - not grp2 - grp3 (uniquemember) @@ -2023,7 +2249,7 @@ def test_memberof_MultiGrpAttr_023(topology_st): - grp16 (member uniquemember) - not grp018 - not grp20* - enh2 is member of + enh2 is member of - not grp1 - grp2 (uniquemember) - grp3 (member) @@ -2031,41 +2257,35 @@ def test_memberof_MultiGrpAttr_023(topology_st): - not grp16 - not grp018 - not grp20* - grp[1-4] are member of grp20_5 user1 is member (member) of group_5 grp5 is uniqueMember of grp20_[1-4] user[1-4] is member/uniquemember of grp20_[1-4] - - /----member ---> G1 ---member/uniqueMember -\ - /<--uniquemember- V - G5 ------------------------>member ---------- --->U1 - | - |----member ---> G2 ---member/uniqueMember -> U2 - |<--uniquemember-/ - | - |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ - |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ - - - - - At the end: - /----member ---> G1 ---uniqueMember -------\ - / V - G5 ------------------------>member ---------- --->U1 - | - |----member ---> G2 ---member/uniqueMember -> U2 - |<--uniquemember-/ - | - |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ - |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + :steps: + 1. Delete user1 as 'member' of grp20_1 + 2. Delete grp020_5 as 'uniqueMember' of grp20_1 + 3. Check the result membership + :expectedresults: + 1. Success + 2. Success + 3. The result should be like this + + :: + + /----member ---> G1 ---uniqueMember -------\ + / V + G5 ------------------------>member ---------- --->U1 + | + |----member ---> G2 ---member/uniqueMember -> U2 + |<--uniquemember-/ + | + |----member ---> G3 ---member/uniqueMember -> U3 + |<--uniquemember-/ + |----member ---> G4 ---member/uniqueMember -> U4 + |<--uniquemember-/ """ + memofenh1 = _get_user_dn('memofenh1') memofenh2 = _get_user_dn('memofenh2') @@ -2240,35 +2460,47 @@ def verify_post_024(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, assert _check_memberof(topology_st, member=memofuser1, group=grp) -def test_memberof_MultiGrpAttr_024(topology_st): - """ - At the beginning: +def test_complex_group_scenario_8(topology_st): + """Check the user add operation to the complex membership topology + :id: d222af17-17a6-48a0-8f22-a38306726a23 + :setup: Standalone instance, - /----member ---> G1 ---uniqueMember -------\ - / V - G5 ------------------------>member ---------- --->U1 - | - |----member ---> G2 ---member/uniqueMember -> U2 - |<--uniquemember-/ - | - |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ - |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ + :: + + /----member ---> G1 ---uniqueMember -------\ + / V + G5 ------------------------>member ---------- --->U1 + | + |----member ---> G2 ---member/uniqueMember -> U2 + |<--uniquemember-/ + | + |----member ---> G3 ---member/uniqueMember -> U3 + |<--uniquemember-/ + |----member ---> G4 ---member/uniqueMember -> U4 + |<--uniquemember-/ + + :steps: + 1. Add user1 to grp020_1 + 2. Check the result membership + :expectedresults: + 1. Success + 2. The result should be like this + + :: + + /----member ---> G1 ---member/uniqueMember -\ + / V + G5 ------------------------>member ---------- --->U1 + | + |----member ---> G2 ---member/uniqueMember -> U2 + |<--uniquemember-/ + | + |----member ---> G3 ---member/uniqueMember -> U3 + |<--uniquemember-/ + |----member ---> G4 ---member/uniqueMember -> U4 + |<--uniquemember-/ - At the end: - /----member ---> G1 ---member/uniqueMember -\ - / V - G5 ------------------------>member ---------- --->U1 - | - |----member ---> G2 ---member/uniqueMember -> U2 - |<--uniquemember-/ - | - |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ - |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ """ memofuser1 = _get_user_dn('memofuser1') @@ -2327,30 +2559,42 @@ def verify_post_025(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, assert not _check_memberof(topology_st, member=user, group=grp) -def test_memberof_MultiGrpAttr_025(topology_st): - """ - At the beginning: +def test_complex_group_scenario_9(topology_st): + """Check the massive user deletion from the complex membership topology + :id: d222af17-17a6-48a0-8f22-a38306726a24 + :setup: Standalone instance, - /----member ---> G1 ---member/uniqueMember -\ - / V - G5 ------------------------>member ---------- --->U1 - | - |----member ---> G2 ---member/uniqueMember -> U2 - |<--uniquemember-/ - | - |----member ---> G3 ---member/uniqueMember -> U3 - |<--uniquemember-/ - |----member ---> G4 ---member/uniqueMember -> U4 - |<--uniquemember-/ - At the end: - /----member ---> G1 - / - G5 ------------------------>member ---------- --->U1 - | - |----member ---> G2 - |----member ---> G3 - |----member ---> G4 + :: + + /----member ---> G1 ---member/uniqueMember -\ + / V + G5 ------------------------>member ---------- --->U1 + | + |----member ---> G2 ---member/uniqueMember -> U2 + |<--uniquemember-/ + | + |----member ---> G3 ---member/uniqueMember -> U3 + |<--uniquemember-/ + |----member ---> G4 ---member/uniqueMember -> U4 + |<--uniquemember-/ + + :steps: + 1. Delete user[1-5] as 'member' and 'uniqueMember' from grp20_[1-5] + 2. Check the result membership + :expectedresults: + 1. Success + 2. The result should be like this + + :: + + /----member ---> G1 + / + G5 ------------------------>member ---------- --->U1 + | + |----member ---> G2 + |----member ---> G3 + |----member ---> G4 """ @@ -2411,8 +2655,35 @@ def test_memberof_MultiGrpAttr_025(topology_st): def test_memberof_auto_add_oc(topology_st): - """Test the auto add objectclass feature. The plugin should add a predefined + """Test the auto add objectclass (OC) feature. The plugin should add a predefined objectclass that will allow memberOf to be added to an entry. + + :id: d222af17-17a6-48a0-8f22-a38306726a25 + :setup: Standalone instance + :steps: + 1. Enable dynamic plugins + 2. Enable memberOf plugin + 3. Test that the default add OC works. + 4. Add a group that already includes one user + 5. Assert memberOf on user1 + 6. Delete user1 and the group + 7. Test invalid value (config validation) + 8. Add valid objectclass + 9. Add two users + 10. Add a group that already includes one user + 11. Add a user to the group + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success + 6. Success + 7. Success + 8. Success + 9. Success + 10. Success + 11. Success """ # enable dynamic plugins diff --git a/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py b/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py index 1315fc6bc..25d550330 100644 --- a/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py +++ b/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py @@ -19,7 +19,7 @@ log = logging.getLogger(__name__) @pytest.mark.ds47384 def test_pluginpath_validation(topology_st): - '''Test pluginpath validation: relative and absolute paths + """Test pluginpath validation: relative and absolute paths With the inclusion of ticket 47601 - we do allow plugin paths outside the default location @@ -40,7 +40,7 @@ def test_pluginpath_validation(topology_st): 3. This should pass 4. This should fail 5. This should fail - ''' + """ if os.geteuid() != 0: log.warn('This script must be run as root') diff --git a/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py b/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py index 4892255dc..c7bb15f73 100644 --- a/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py +++ b/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py @@ -24,21 +24,21 @@ PLUGIN_DN = 'cn=' + PLUGIN_ROOTDN_ACCESS + ',cn=plugins,cn=config' USER1_DN = 'uid=user1,' + DEFAULT_SUFFIX -def test_rootdn_init(topology_st): - ''' - Initialize our setup to test the ROot DN Access Control Plugin [email protected](scope="module") +def rootdn_setup(topology_st): + """Initialize our setup to test the Root DN Access Control Plugin - Test the following access control type: + Test the following access control type: - - Allowed IP address * - - Denied IP address * - - Specific time window - - Days allowed access - - Allowed host * - - Denied host * + - Allowed IP address * + - Denied IP address * + - Specific time window + - Days allowed access + - Allowed host * + - Denied host * - * means mulitple valued - ''' + * means mulitple valued + """ log.info('Initializing root DN test suite...') @@ -83,10 +83,24 @@ def test_rootdn_init(topology_st): log.info('test_rootdn_init: Initialized root DN test suite.') -def test_rootdn_access_specific_time(topology_st): - ''' - Test binding inside and outside of a specific time - ''' +def test_rootdn_access_specific_time(topology_st, rootdn_setup): + """Test binding inside and outside of a specific time + + :id: a0ef30e5-538b-46fa-9762-01a4435a15e8 + :setup: Standalone instance, rootdn plugin set up + :steps: + 1. Get the current time, and bump it ahead twohours + 2. Bind as Root DN + 3. Set config to allow the entire day + 4. Bind as Root DN + 5. Cleanup - undo the changes we made so the next test has a clean slate + :expectedresults: + 1. Success + 2. Should fail + 3. Success + 4. Success + 5. Success + """ log.info('Running test_rootdn_access_specific_time...') @@ -165,10 +179,24 @@ def test_rootdn_access_specific_time(topology_st): log.info('test_rootdn_access_specific_time: PASSED') -def test_rootdn_access_day_of_week(topology_st): - ''' - Test the days of week feature - ''' +def test_rootdn_access_day_of_week(topology_st, rootdn_setup): + """Test the days of week feature + + :id: a0ef30e5-538b-46fa-9762-01a4435a15e1 + :setup: Standalone instance, rootdn plugin set up + :steps: + 1. Set the deny days + 2. Bind as Root DN + 3. Set the allow days + 4. Bind as Root DN + 5. Cleanup - undo the changes we made so the next test has a clean slate + :expectedresults: + 1. Success + 2. Should fail + 3. Success + 4. Success + 5. Success + """ log.info('Running test_rootdn_access_day_of_week...') @@ -258,10 +286,24 @@ def test_rootdn_access_day_of_week(topology_st): log.info('test_rootdn_access_day_of_week: PASSED') -def test_rootdn_access_denied_ip(topology_st): - ''' - Test denied IP feature - we can just test denying 127.0.0.1 - ''' +def test_rootdn_access_denied_ip(topology_st, rootdn_setup): + """Test denied IP feature - we can just test denying 127.0.0.1 + + :id: a0ef30e5-538b-46fa-9762-01a4435a15e2 + :setup: Standalone instance, rootdn plugin set up + :steps: + 1. Set rootdn-deny-ip to '127.0.0.1' and '::1' + 2. Bind as Root DN + 3. Change the denied IP so root DN succeeds + 4. Bind as Root DN + 5. Cleanup - undo the changes we made so the next test has a clean slate + :expectedresults: + 1. Success + 2. Should fail + 3. Success + 4. Success + 5. Success + """ log.info('Running test_rootdn_access_denied_ip...') try: @@ -333,10 +375,24 @@ def test_rootdn_access_denied_ip(topology_st): log.info('test_rootdn_access_denied_ip: PASSED') -def test_rootdn_access_denied_host(topology_st): - ''' - Test denied Host feature - we can just test denying localhost - ''' +def test_rootdn_access_denied_host(topology_st, rootdn_setup): + """Test denied Host feature - we can just test denying localhost + + :id: a0ef30e5-538b-46fa-9762-01a4435a15e3 + :setup: Standalone instance, rootdn plugin set up + :steps: + 1. Set rootdn-deny-host to hostname (localhost if not accessable) + 2. Bind as Root DN + 3. Change the denied host so root DN succeeds + 4. Bind as Root DN + 5. Cleanup - undo the changes we made so the next test has a clean slate + :expectedresults: + 1. Success + 2. Should fail + 3. Success + 4. Success + 5. Success + """ log.info('Running test_rootdn_access_denied_host...') hostname = socket.gethostname() @@ -410,15 +466,29 @@ def test_rootdn_access_denied_host(topology_st): log.info('test_rootdn_access_denied_host: PASSED') -def test_rootdn_access_allowed_ip(topology_st): - ''' - Test allowed ip feature - ''' +def test_rootdn_access_allowed_ip(topology_st, rootdn_setup): + """Test allowed ip feature + + :id: a0ef30e5-538b-46fa-9762-01a4435a15e4 + :setup: Standalone instance, rootdn plugin set up + :steps: + 1. Set allowed ip to 255.255.255.255 - blocks the Root DN + 2. Bind as Root DN + 3. Allow localhost + 4. Bind as Root DN + 5. Cleanup - undo the changes we made so the next test has a clean slate + :expectedresults: + 1. Success + 2. Should fail + 3. Success + 4. Success + 5. Success + """ log.info('Running test_rootdn_access_allowed_ip...') # - # Set allowed host to an unknown host - blocks the Root DN + # Set allowed ip to 255.255.255.255 - blocks the Root DN # try: conn = ldap.initialize('ldap://{}:{}'.format(LOCALHOST_IP, topology_st.standalone.port)) @@ -488,10 +558,24 @@ def test_rootdn_access_allowed_ip(topology_st): log.info('test_rootdn_access_allowed_ip: PASSED') -def test_rootdn_access_allowed_host(topology_st): - ''' - Test allowed ip feature - ''' +def test_rootdn_access_allowed_host(topology_st, rootdn_setup): + """Test allowed host feature + + :id: a0ef30e5-538b-46fa-9762-01a4435a15e5 + :setup: Standalone instance, rootdn plugin set up + :steps: + 1. Set allowed host to an unknown host - blocks the Root DN + 2. Bind as Root DN + 3. Allow localhost + 4. Bind as Root DN + 5. Cleanup - undo the changes we made so the next test has a clean slate + :expectedresults: + 1. Success + 2. Should fail + 3. Success + 4. Success + 5. Success + """ log.info('Running test_rootdn_access_allowed_host...') @@ -572,15 +656,52 @@ def test_rootdn_access_allowed_host(topology_st): log.info('test_rootdn_access_allowed_host: PASSED') -def test_rootdn_config_validate(topology_st): - ''' - Test configuration validation - - test single valued attributes: rootdn-open-time, - rootdn-close-time, - rootdn-days-allowed - - ''' +def test_rootdn_config_validate(topology_st, rootdn_setup): + """Test plugin configuration validation + + :id: a0ef30e5-538b-46fa-9762-01a4435a15e6 + :setup: Standalone instance, rootdn plugin set up + :steps: + 1. Replace 'rootdn-open-time' with '0000' + 2. Add 'rootdn-open-time': '0000' and 'rootdn-open-time': '0001' + 3. Replace 'rootdn-open-time' with '-1' and 'rootdn-close-time' with '0000' + 4. Replace 'rootdn-open-time' with '2400' and 'rootdn-close-time' with '0000' + 5. Replace 'rootdn-open-time' with 'aaaaa' and 'rootdn-close-time' with '0000' + 6. Replace 'rootdn-close-time' with '0000' + 7. Add 'rootdn-close-time': '0000' and 'rootdn-close-time': '0001' + 8. Replace 'rootdn-open-time' with '0000' and 'rootdn-close-time' with '-1' + 9. Replace 'rootdn-open-time' with '0000' and 'rootdn-close-time' with '2400' + 10. Replace 'rootdn-open-time' with '0000' and 'rootdn-close-time' with 'aaaaa' + 11. Add 'rootdn-days-allowed': 'Mon' and 'rootdn-days-allowed': 'Tue' + 12. Replace 'rootdn-days-allowed' with 'Mon1' + 13. Replace 'rootdn-days-allowed' with 'Tue, Mon1' + 14. Replace 'rootdn-days-allowed' with 'm111m' + 15. Replace 'rootdn-days-allowed' with 'Gur' + 16. Replace 'rootdn-allow-ip' with '12.12.Z.12' + 17. Replace 'rootdn-deny-ip' with '12.12.Z.12' + 18. Replace 'rootdn-allow-host' with 'host._.com' + 19. Replace 'rootdn-deny-host' with 'host.####.com' + :expectedresults: + 1. Should fail + 2. Should fail + 3. Should fail + 4. Should fail + 5. Should fail + 6. Should fail + 7. Should fail + 8. Should fail + 9. Should fail + 10. Should fail + 11. Should fail + 12. Should fail + 13. Should fail + 14. Should fail + 15. Should fail + 16. Should fail + 17. Should fail + 18. Should fail + 19. Should fail + """ log.info('Running test_rootdn_config_validate...')
0
54a74194f6152a37af730fa5ab1588fddbfc6251
389ds/389-ds-base
Issue 4544 - Compiler warnings on krb5 functions (#4545) Bug description: 6dd37b4fa801b64af0f26293c359a08d744661b2 introduced compiler warnings on unused code. Fix description: Remove the dead code. relates: https://github.com/389ds/389-ds-base/issues/4544 Author: Robbie Harwood <[email protected]> Review by: @Firstyear @mreynolds389
commit 54a74194f6152a37af730fa5ab1588fddbfc6251 Author: Robbie Harwood <[email protected]> Date: Thu Jan 14 17:43:38 2021 -0500 Issue 4544 - Compiler warnings on krb5 functions (#4545) Bug description: 6dd37b4fa801b64af0f26293c359a08d744661b2 introduced compiler warnings on unused code. Fix description: Remove the dead code. relates: https://github.com/389ds/389-ds-base/issues/4544 Author: Robbie Harwood <[email protected]> Review by: @Firstyear @mreynolds389 diff --git a/ldap/servers/slapd/ldaputil.c b/ldap/servers/slapd/ldaputil.c index fe2c45715..1e0aa8b14 100644 --- a/ldap/servers/slapd/ldaputil.c +++ b/ldap/servers/slapd/ldaputil.c @@ -1511,202 +1511,6 @@ slapd_ldap_sasl_interactive_bind( #ifdef HAVE_KRB5 #include <krb5.h> -/* for some reason this is not in the public API? - but it is documented e.g. man kinit */ -#ifndef KRB5_ENV_CCNAME -#define KRB5_ENV_CCNAME "KRB5CCNAME" -#endif - -static void -show_one_credential(int authtracelevel, - krb5_context ctx, - krb5_creds *cred) -{ - char *logname = "show_one_credential"; - krb5_error_code rc; - char *name = NULL, *sname = NULL; - char startts[BUFSIZ], endts[BUFSIZ], renewts[BUFSIZ]; - - if ((rc = krb5_unparse_name(ctx, cred->client, &name))) { - slapi_log_err(SLAPI_LOG_ERR, logname, - "Could not get client name from credential: %d (%s)\n", - rc, error_message(rc)); - goto cleanup; - } - if ((rc = krb5_unparse_name(ctx, cred->server, &sname))) { - slapi_log_err(SLAPI_LOG_ERR, logname, - "Could not get server name from credential: %d (%s)\n", - rc, error_message(rc)); - goto cleanup; - } - if (!cred->times.starttime) { - cred->times.starttime = cred->times.authtime; - } - krb5_timestamp_to_sfstring((krb5_timestamp)cred->times.starttime, - startts, sizeof(startts), NULL); - krb5_timestamp_to_sfstring((krb5_timestamp)cred->times.endtime, - endts, sizeof(endts), NULL); - krb5_timestamp_to_sfstring((krb5_timestamp)cred->times.renew_till, - renewts, sizeof(renewts), NULL); - - slapi_log_err(authtracelevel, logname, - "\tKerberos credential: client [%s] server [%s] " - "start time [%s] end time [%s] renew time [%s] " - "flags [0x%x]\n", - name, sname, startts, endts, - renewts, (uint32_t)cred->ticket_flags); - -cleanup: - krb5_free_unparsed_name(ctx, name); - krb5_free_unparsed_name(ctx, sname); - - return; -} - -/* - * Call this after storing the credentials in the cache - */ -static void -show_cached_credentials(int authtracelevel, - krb5_context ctx, - krb5_ccache cc, - krb5_principal princ) -{ - char *logname = "show_cached_credentials"; - krb5_error_code rc = 0; - krb5_creds creds; - krb5_cc_cursor cur; - char *princ_name = NULL; - - if ((rc = krb5_unparse_name(ctx, princ, &princ_name))) { - slapi_log_err(SLAPI_LOG_ERR, logname, - "Could not get principal name from principal: %d (%s)\n", - rc, error_message(rc)); - goto cleanup; - } - - slapi_log_err(authtracelevel, logname, - "Ticket cache: %s:%s\nDefault principal: %s\n\n", - krb5_cc_get_type(ctx, cc), - krb5_cc_get_name(ctx, cc), princ_name); - - if ((rc = krb5_cc_start_seq_get(ctx, cc, &cur))) { - slapi_log_err(SLAPI_LOG_ERR, logname, - "Could not get cursor to iterate cached credentials: " - "%d (%s)\n", - rc, error_message(rc)); - goto cleanup; - } - - while (!(rc = krb5_cc_next_cred(ctx, cc, &cur, &creds))) { - show_one_credential(authtracelevel, ctx, &creds); - krb5_free_cred_contents(ctx, &creds); - } - if (rc == KRB5_CC_END) { - if ((rc = krb5_cc_end_seq_get(ctx, cc, &cur))) { - slapi_log_err(SLAPI_LOG_ERR, logname, - "Could not close cached credentials cursor: " - "%d (%s)\n", - rc, error_message(rc)); - goto cleanup; - } - } - -cleanup: - krb5_free_unparsed_name(ctx, princ_name); - - return; -} - -static int -looks_like_a_princ_name(const char *name) -{ - /* a valid principal name will be a non-empty string - that doesn't have a = in it (which will likely be - a bind DN) */ - return (name && *name && !strchr(name, '=')); -} - -static int -credentials_are_valid( - krb5_context ctx, - krb5_ccache cc, - krb5_principal princ, - const char *princ_name, - int *rc) -{ - char *logname = "credentials_are_valid"; - int myrc = 0; - krb5_creds mcreds = {0}; /* match these values */ - krb5_creds creds = {0}; /* returned creds */ - char *tgs_princ_name = NULL; - krb5_timestamp currenttime; - int authtracelevel = SLAPI_LOG_SHELL; /* special auth tracing */ - int realm_len; - char *realm_str; - int time_buffer = 30; /* seconds - go ahead and renew if creds are - about to expire */ - - *rc = 0; - if (!cc) { - /* ok - no error */ - goto cleanup; - } - -/* have to construct the tgs server principal in - order to set mcreds.server required in order - to use krb5_cc_retrieve_creds() */ -/* get default realm first */ - realm_len = krb5_princ_realm(ctx, princ)->length; - realm_str = krb5_princ_realm(ctx, princ)->data; - tgs_princ_name = slapi_ch_smprintf("%s/%*s@%*s", KRB5_TGS_NAME, - realm_len, realm_str, - realm_len, realm_str); - - if ((*rc = krb5_parse_name(ctx, tgs_princ_name, &mcreds.server))) { - slapi_log_err(SLAPI_LOG_ERR, logname, - "Could parse principal [%s]: %d (%s)\n", - tgs_princ_name, *rc, error_message(*rc)); - goto cleanup; - } - - mcreds.client = princ; - if ((*rc = krb5_cc_retrieve_cred(ctx, cc, 0, &mcreds, &creds))) { - if (*rc == KRB5_CC_NOTFOUND) { - /* ok - no creds for this princ in the cache */ - *rc = 0; - } - goto cleanup; - } - - /* have the creds - now look at the timestamp */ - if ((*rc = krb5_timeofday(ctx, &currenttime))) { - slapi_log_err(SLAPI_LOG_ERR, logname, - "Could not get current time: %d (%s)\n", - *rc, error_message(*rc)); - goto cleanup; - } - - if (currenttime > (creds.times.endtime + time_buffer)) { - slapi_log_err(authtracelevel, logname, - "Credentials for [%s] have expired or will soon " - "expire - now [%d] endtime [%d]\n", - princ_name, - currenttime, creds.times.endtime); - goto cleanup; - } - - myrc = 1; /* credentials are valid */ -cleanup: - krb5_free_cred_contents(ctx, &creds); - slapi_ch_free_string(&tgs_princ_name); - if (mcreds.server) { - krb5_free_principal(ctx, mcreds.server); - } - - return myrc; -} - static void clear_krb5_ccache(void) {
0