From 71e2711791e3ec718f3d47110ccd0b8817bb3f31 Mon Sep 17 00:00:00 2001 From: Viktor Ashirov Date: May 27 2019 15:01:51 +0000 Subject: Issue 50390 - Add Managed Entries Plug-in Config Entry schema Bug Description: On older versions without the MEP config entry schema lib389 fails to configure MEP plugin Fix Description: Check if we have required schema present, otherwise fallback to extensibleObject Relates https://pagure.io/389-ds-base/issue/50390 Reviewed by: spichugi (Thanks!) --- diff --git a/src/lib389/lib389/plugins.py b/src/lib389/lib389/plugins.py index a5f4320..8271e03 100644 --- a/src/lib389/lib389/plugins.py +++ b/src/lib389/lib389/plugins.py @@ -1,5 +1,5 @@ # --- BEGIN COPYRIGHT BLOCK --- -# Copyright (C) 2015 Red Hat, Inc. +# Copyright (C) 2019 Red Hat, Inc. # All rights reserved. # # License: GPL (version 3 or any later version). @@ -15,6 +15,7 @@ from lib389 import tasks from lib389._mapped_object import DSLdapObjects, DSLdapObject from lib389.lint import DSRILE0001 from lib389.utils import ensure_str, ensure_list_bytes +from lib389.schema import Schema from lib389._constants import DN_PLUGIN from lib389.properties import ( PLUGINS_OBJECTCLASS_VALUE, PLUGIN_PROPNAME_TO_ATTRNAME, @@ -294,9 +295,17 @@ class MEPConfig(DSLdapObject): def __init__(self, instance, dn): super(MEPConfig, self).__init__(instance, dn) self._rdn_attribute = 'cn' - self._must_attributes = ['cn', 'originScope', 'originFilter', - 'managedBase', 'managedTemplate'] - self._create_objectclasses = ['top', 'mepConfigEntry'] + schema = Schema(instance) + for oc in schema.get_objectclasses(): + if oc.oid == '2.16.840.1.113730.3.2.336': + self._must_attributes = ['cn', 'originScope', 'originFilter', + 'managedBase', 'managedTemplate'] + self._create_objectclasses = ['top', 'mepConfigEntry'] + break + else: + # Workaround for older versions without MEP schema + self._must_attributes = ['cn'] + self._create_objectclasses = ['top', 'extensibleObject'] self._protected = False @@ -311,7 +320,14 @@ class MEPConfigs(DSLdapObjects): def __init__(self, instance, basedn=None): super(MEPConfigs, self).__init__(instance) - self._objectclasses = ['top', 'mepConfigEntry'] + schema = Schema(instance) + for oc in schema.get_objectclasses(): + if oc.oid == '2.16.840.1.113730.3.2.336': + self._objectclasses = ['top', 'mepConfigEntry'] + break + else: + # Workaround for older versions without MEP schema + self._objectclasses = ['top', 'extensibleObject'] self._filterattrs = ['cn'] self._childobject = MEPConfig # So we can set the configArea easily