From 9b31322972605378d5c597d87cf367c0bb00c20f Mon Sep 17 00:00:00 2001 From: starlet-dx <15929766099@163.com> Date: Mon, 23 Oct 2023 19:17:29 +0800 Subject: [PATCH 1/2] Fix unable to add objectclass/attribute without x-origin --- ...est-4664-from-mreynolds389-issue4663.patch | 106 ++++++++++++++++++ 389-ds-base.spec | 7 +- 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 0001-Merge-pull-request-4664-from-mreynolds389-issue4663.patch diff --git a/0001-Merge-pull-request-4664-from-mreynolds389-issue4663.patch b/0001-Merge-pull-request-4664-from-mreynolds389-issue4663.patch new file mode 100644 index 0000000..8ab154f --- /dev/null +++ b/0001-Merge-pull-request-4664-from-mreynolds389-issue4663.patch @@ -0,0 +1,106 @@ +From c25d385f169e4f4dcb6caec9edf71f3235ced447 Mon Sep 17 00:00:00 2001 +From: Mark Reynolds +Date: Tue, 9 Mar 2021 12:37:20 -0500 +Subject: [PATCH 1/1] Merge pull request #4664 from mreynolds389/issue4663 + +Issue 4663 - CLI - unable to add objectclass/attribute without x-origin +--- + dirsrvtests/tests/suites/clu/schema_test.py | 43 ++++++++++++++++++++- + src/lib389/lib389/schema.py | 10 +++++ + 2 files changed, 52 insertions(+), 1 deletion(-) + +diff --git a/dirsrvtests/tests/suites/clu/schema_test.py b/dirsrvtests/tests/suites/clu/schema_test.py +index 1bae854bf..6ba541548 100644 +--- a/dirsrvtests/tests/suites/clu/schema_test.py ++++ b/dirsrvtests/tests/suites/clu/schema_test.py +@@ -5,7 +5,6 @@ from lib389.topologies import topology_st as topo + from lib389.schema import Schema + + pytestmark = pytest.mark.tier0 +- + log = logging.getLogger(__name__) + + +@@ -55,6 +54,48 @@ def test_origins_with_extra_parenthesis(topo): + assert attr_result['at']['x_origin'][0] == X_ORG_VAL + + ++schema_params = [ ++ ['attr1', '99999.1', None], ++ ['attr2', '99999.2', 'test-str'], ++ ['attr3', '99999.3', ['test-list']], ++ ['attr4', '99999.4', ('test-tuple')], ++] ++@pytest.mark.parametrize("name, oid, xorg", schema_params) ++def test_origins(topo, name, oid, xorg): ++ """Test the various possibilities of x-origin ++ ++ :id: 3229f6f8-67c1-4558-9be5-71434283086a ++ :setup: Standalone Instance ++ :steps: ++ 1. Add an attribute with different x-origin values/types ++ :expectedresults: ++ 1. Success ++ """ ++ ++ schema = Schema(topo.standalone) ++ ++ # Add new attribute ++ parameters = { ++ 'names': [name], ++ 'oid': oid, ++ 'desc': 'Test X-ORIGIN', ++ 'x_origin': xorg, ++ 'syntax': '1.3.6.1.4.1.1466.115.121.1.15', ++ 'syntax_len': None, ++ 'x_ordered': None, ++ 'collective': None, ++ 'obsolete': None, ++ 'single_value': None, ++ 'no_user_mod': None, ++ 'equality': None, ++ 'substr': None, ++ 'ordering': None, ++ 'usage': None, ++ 'sup': None ++ } ++ schema.add_attributetype(parameters) ++ ++ + if __name__ == '__main__': + # Run isolated + # -s for DEBUG mode +diff --git a/src/lib389/lib389/schema.py b/src/lib389/lib389/schema.py +index 10a741cbd..056b33fd2 100755 +--- a/src/lib389/lib389/schema.py ++++ b/src/lib389/lib389/schema.py +@@ -199,9 +199,17 @@ class Schema(DSLdapObject): + # Default structure. We modify it later with the specified arguments + schema_object = object_model() + ++ # x-origin requires special handling to make sure it is a Tuple ++ empty = () ++ setattr(schema_object, "x_origin", empty) ++ + for oc_param, value in parameters.items(): + if oc_param.lower() not in OBJECT_MODEL_PARAMS[object_model].keys(): + raise ValueError('Wrong parameter name was specified: %s' % oc_param) ++ if oc_param == "x_origin" and value is not None and \ ++ (type(value) != list and type(value) != tuple): ++ # x-origin is expected to be a tuple in python-ldap ++ value = (value,) + if value is not None: + value = self._validate_ldap_schema_value(value) + setattr(schema_object, oc_param.lower(), value) +@@ -211,6 +219,8 @@ class Schema(DSLdapObject): + # It is automatically assigned to 'SUP top' + parameters_none = {k.lower(): v for k, v in parameters.items() if v is None} + for k, v in parameters_none.items(): ++ if k == "x_origin" and v is None: ++ continue + setattr(schema_object, k, OBJECT_MODEL_PARAMS[object_model][k]) + return self.add(attr_name, str(schema_object)) + +-- +2.33.0 + diff --git a/389-ds-base.spec b/389-ds-base.spec index ed3ba73..713a673 100644 --- a/389-ds-base.spec +++ b/389-ds-base.spec @@ -6,7 +6,7 @@ ExcludeArch: i686 Name: 389-ds-base Summary: Base 389 Directory Server Version: 1.4.3.20 -Release: 1 +Release: 2 License: GPLv3+ URL: https://www.port389.org Source0: https://releases.pagure.org/389-ds-base/389-ds-base-%{version}.tar.bz2 @@ -18,6 +18,8 @@ Patch0: CVE-2021-3652.patch Patch1: CVE-2021-3514.patch # https://github.com/389ds/389-ds-base/commit/5a18aeb49c357a16c138d37a8251d73d8ed35319 Patch2: Fix-attributeError-type-object-build_manpages.patch +# https://github.com/389ds/389-ds-base/commit/c25d385f169e4f4dcb6caec9edf71f3235ced447 +Patch3: 0001-Merge-pull-request-4664-from-mreynolds389-issue4663.patch BuildRequires: nspr-devel nss-devel >= 3.34 perl-generators openldap-devel libdb-devel cyrus-sasl-devel icu BuildRequires: libicu-devel pcre-devel cracklib-devel gcc-c++ net-snmp-devel lm_sensors-devel bzip2-devel @@ -369,6 +371,9 @@ exit 0 %{_mandir}/*/* %changelog +* Mon Oct 23 2023 yaoxin - 1.4.3.20-2 +- Fix unable to add objectclass/attribute without x-origin + * Tue Mar 15 2022 wangkai - 1.4.3.20-1 - Update to 1.4.3.20 for fix CVE-2020-35518 -- Gitee From fa7a322b1d604a7aa91fbf377da25c01b445faf1 Mon Sep 17 00:00:00 2001 From: starlet-dx <15929766099@163.com> Date: Mon, 23 Oct 2023 20:05:24 +0800 Subject: [PATCH 2/2] Fix unable to add objectclass/attribute without x-origin --- 389-ds-base.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/389-ds-base.spec b/389-ds-base.spec index 713a673..e603425 100644 --- a/389-ds-base.spec +++ b/389-ds-base.spec @@ -183,6 +183,7 @@ cd - mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d echo "%{_bindir}/%{name}" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf echo "%{_libdir}/%{name}" >> $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf +echo "%{_libdir}/dirsrv" >> $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf %check if ! make DESTDIR="$RPM_BUILD_ROOT" check; then -- Gitee