|
|
c9e5da |
From a8b10d7a4f1cad499fa1ba245dd73ca7beac4589 Mon Sep 17 00:00:00 2001
|
|
|
c9e5da |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
c9e5da |
Date: Mon, 27 Feb 2017 07:59:30 -0500
|
|
|
c9e5da |
Subject: [PATCH 71/71] Issue 49122 - Filtered nsrole that uses nsrole crashes
|
|
|
c9e5da |
the server
|
|
|
c9e5da |
|
|
|
c9e5da |
Bug Description: When evaluating a filter role that uses "nsrole" in the filter
|
|
|
c9e5da |
crashes the server due infinite loop that leads to a stack
|
|
|
c9e5da |
overflow.
|
|
|
c9e5da |
|
|
|
c9e5da |
Fix Description: Virtual attributes are not allowed to be used in role filters.
|
|
|
c9e5da |
We were already checking for COS attributes, but not nsrole.
|
|
|
c9e5da |
|
|
|
c9e5da |
Also did some minor code cleanup
|
|
|
c9e5da |
|
|
|
c9e5da |
https://pagure.io/389-ds-base/issue/49122
|
|
|
c9e5da |
|
|
|
c9e5da |
Reviewed by: nhosoi(Thanks!)
|
|
|
c9e5da |
|
|
|
c9e5da |
(cherry picked from commit a95889def41d3869692d7259a9213b1f9238f3c8)
|
|
|
c9e5da |
(cherry picked from commit d589950cdd8ac9a0756b67cfe4ae3a33da094065)
|
|
|
c9e5da |
---
|
|
|
c9e5da |
dirsrvtests/tests/tickets/ticket49122_test.py | 73 ++++++++
|
|
|
c9e5da |
ldap/servers/plugins/roles/roles_cache.c | 235 +++++++++++++++-----------
|
|
|
c9e5da |
2 files changed, 205 insertions(+), 103 deletions(-)
|
|
|
c9e5da |
create mode 100644 dirsrvtests/tests/tickets/ticket49122_test.py
|
|
|
c9e5da |
|
|
|
c9e5da |
diff --git a/dirsrvtests/tests/tickets/ticket49122_test.py b/dirsrvtests/tests/tickets/ticket49122_test.py
|
|
|
c9e5da |
new file mode 100644
|
|
|
c9e5da |
index 0000000..bd553f2
|
|
|
c9e5da |
--- /dev/null
|
|
|
c9e5da |
+++ b/dirsrvtests/tests/tickets/ticket49122_test.py
|
|
|
c9e5da |
@@ -0,0 +1,73 @@
|
|
|
c9e5da |
+import time
|
|
|
c9e5da |
+import ldap
|
|
|
c9e5da |
+import logging
|
|
|
c9e5da |
+import pytest
|
|
|
c9e5da |
+from lib389 import DirSrv, Entry, tools, tasks
|
|
|
c9e5da |
+from lib389.tools import DirSrvTools
|
|
|
c9e5da |
+from lib389._constants import *
|
|
|
c9e5da |
+from lib389.properties import *
|
|
|
c9e5da |
+from lib389.tasks import *
|
|
|
c9e5da |
+from lib389.utils import *
|
|
|
c9e5da |
+from lib389.topologies import topology_st as topo
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+DEBUGGING = os.getenv("DEBUGGING", default=False)
|
|
|
c9e5da |
+if DEBUGGING:
|
|
|
c9e5da |
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
|
|
|
c9e5da |
+else:
|
|
|
c9e5da |
+ logging.getLogger(__name__).setLevel(logging.INFO)
|
|
|
c9e5da |
+log = logging.getLogger(__name__)
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+USER_DN = 'uid=user,' + DEFAULT_SUFFIX
|
|
|
c9e5da |
+ROLE_DN = 'cn=Filtered_Role_That_Includes_Empty_Role,' + DEFAULT_SUFFIX
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+def test_ticket49122(topo):
|
|
|
c9e5da |
+ """Search for non-existant role and make sure the server does not crash
|
|
|
c9e5da |
+ """
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ # Enable roles plugin
|
|
|
c9e5da |
+ topo.standalone.plugins.enable(name=PLUGIN_ROLES)
|
|
|
c9e5da |
+ topo.standalone.restart()
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ # Add invalid role
|
|
|
c9e5da |
+ try:
|
|
|
c9e5da |
+ topo.standalone.add_s(Entry((
|
|
|
c9e5da |
+ ROLE_DN, {'objectclass': ['top', 'ldapsubentry', 'nsroledefinition',
|
|
|
c9e5da |
+ 'nscomplexroledefinition', 'nsfilteredroledefinition'],
|
|
|
c9e5da |
+ 'cn': 'Filtered_Role_That_Includes_Empty_Role',
|
|
|
c9e5da |
+ 'nsRoleFilter': '(!(nsrole=cn=This_Is_An_Empty_Managed_NsRoleDefinition,dc=example,dc=com))',
|
|
|
c9e5da |
+ 'description': 'A filtered role with filter that will crash the server'})))
|
|
|
c9e5da |
+ except ldap.LDAPError as e:
|
|
|
c9e5da |
+ topo.standalone.log.fatal('Failed to add filtered role: error ' + e.message['desc'])
|
|
|
c9e5da |
+ assert False
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ # Add test user
|
|
|
c9e5da |
+ try:
|
|
|
c9e5da |
+ topo.standalone.add_s(Entry((
|
|
|
c9e5da |
+ USER_DN, {'objectclass': "top extensibleObject".split(),
|
|
|
c9e5da |
+ 'uid': 'user'})))
|
|
|
c9e5da |
+ except ldap.LDAPError as e:
|
|
|
c9e5da |
+ topo.standalone.log.fatal('Failed to add test user: error ' + str(e))
|
|
|
c9e5da |
+ assert False
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ if DEBUGGING:
|
|
|
c9e5da |
+ # Add debugging steps(if any)...
|
|
|
c9e5da |
+ print "Attach gdb"
|
|
|
c9e5da |
+ time.sleep(20)
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ # Search for the role
|
|
|
c9e5da |
+ try:
|
|
|
c9e5da |
+ topo.standalone.search_s(USER_DN, ldap.SCOPE_SUBTREE, 'objectclass=*', ['nsrole'])
|
|
|
c9e5da |
+ except ldap.LDAPError as e:
|
|
|
c9e5da |
+ topo.standalone.log.fatal('Search failed: error ' + str(e))
|
|
|
c9e5da |
+ assert False
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ topo.standalone.log.info('Test Passed')
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+if __name__ == '__main__':
|
|
|
c9e5da |
+ # Run isolated
|
|
|
c9e5da |
+ # -s for DEBUG mode
|
|
|
c9e5da |
+ CURRENT_FILE = os.path.realpath(__file__)
|
|
|
c9e5da |
+ pytest.main("-s %s" % CURRENT_FILE)
|
|
|
c9e5da |
+
|
|
|
c9e5da |
diff --git a/ldap/servers/plugins/roles/roles_cache.c b/ldap/servers/plugins/roles/roles_cache.c
|
|
|
c9e5da |
index 147d113..66c8553 100644
|
|
|
c9e5da |
--- a/ldap/servers/plugins/roles/roles_cache.c
|
|
|
c9e5da |
+++ b/ldap/servers/plugins/roles/roles_cache.c
|
|
|
c9e5da |
@@ -1073,6 +1073,26 @@ static int roles_cache_create_role_under(roles_cache_def** roles_cache_suffix, S
|
|
|
c9e5da |
return(rc);
|
|
|
c9e5da |
}
|
|
|
c9e5da |
|
|
|
c9e5da |
+/*
|
|
|
c9e5da |
+ * Check that we are not using nsrole in the filter
|
|
|
c9e5da |
+ */
|
|
|
c9e5da |
+static int roles_check_filter(Slapi_Filter *filter_list)
|
|
|
c9e5da |
+{
|
|
|
c9e5da |
+ Slapi_Filter *f;
|
|
|
c9e5da |
+ char *type = NULL;
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ for ( f = slapi_filter_list_first( filter_list );
|
|
|
c9e5da |
+ f != NULL;
|
|
|
c9e5da |
+ f = slapi_filter_list_next( filter_list, f ) )
|
|
|
c9e5da |
+ {
|
|
|
c9e5da |
+ slapi_filter_get_attribute_type(f, &type);
|
|
|
c9e5da |
+ if (strcasecmp(type, NSROLEATTR) == 0){
|
|
|
c9e5da |
+ return -1;
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ return 0;
|
|
|
c9e5da |
+}
|
|
|
c9e5da |
|
|
|
c9e5da |
/* roles_cache_create_object_from_entry
|
|
|
c9e5da |
------------------------------------
|
|
|
c9e5da |
@@ -1088,17 +1108,17 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
|
|
|
c9e5da |
int rc = 0;
|
|
|
c9e5da |
int type = 0;
|
|
|
c9e5da |
role_object *this_role = NULL;
|
|
|
c9e5da |
- char *rolescopeDN = NULL;
|
|
|
c9e5da |
+ char *rolescopeDN = NULL;
|
|
|
c9e5da |
|
|
|
c9e5da |
slapi_log_error(SLAPI_LOG_PLUGIN, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
"--> roles_cache_create_object_from_entry\n");
|
|
|
c9e5da |
|
|
|
c9e5da |
- *result = NULL;
|
|
|
c9e5da |
+ *result = NULL;
|
|
|
c9e5da |
|
|
|
c9e5da |
- /* Do not allow circular dependencies */
|
|
|
c9e5da |
- if ( hint > MAX_NESTED_ROLES )
|
|
|
c9e5da |
+ /* Do not allow circular dependencies */
|
|
|
c9e5da |
+ if ( hint > MAX_NESTED_ROLES )
|
|
|
c9e5da |
{
|
|
|
c9e5da |
- char *ndn = NULL;
|
|
|
c9e5da |
+ char *ndn = NULL;
|
|
|
c9e5da |
|
|
|
c9e5da |
ndn = slapi_entry_get_ndn( role_entry );
|
|
|
c9e5da |
slapi_log_error(
|
|
|
c9e5da |
@@ -1111,85 +1131,83 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
|
|
|
c9e5da |
return (0);
|
|
|
c9e5da |
}
|
|
|
c9e5da |
|
|
|
c9e5da |
- /* Create the role cache definition */
|
|
|
c9e5da |
- this_role = (role_object*)slapi_ch_calloc(1, sizeof(role_object));
|
|
|
c9e5da |
- if (this_role == NULL )
|
|
|
c9e5da |
+ /* Create the role cache definition */
|
|
|
c9e5da |
+ this_role = (role_object*)slapi_ch_calloc(1, sizeof(role_object));
|
|
|
c9e5da |
+ if (this_role == NULL )
|
|
|
c9e5da |
{
|
|
|
c9e5da |
- return ENOMEM;
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
+ return ENOMEM;
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
|
|
|
c9e5da |
- /* Check the entry is OK */
|
|
|
c9e5da |
- /* Determine role type and assign to structure */
|
|
|
c9e5da |
- /* We determine the role type by reading the objectclass */
|
|
|
c9e5da |
+ /* Check the entry is OK */
|
|
|
c9e5da |
+ /* Determine role type and assign to structure */
|
|
|
c9e5da |
+ /* We determine the role type by reading the objectclass */
|
|
|
c9e5da |
if ( roles_cache_is_role_entry(role_entry) == 0 )
|
|
|
c9e5da |
{
|
|
|
c9e5da |
- /* Bad type */
|
|
|
c9e5da |
- slapi_ch_free((void**)&this_role);
|
|
|
c9e5da |
- return SLAPI_ROLE_DEFINITION_ERROR;
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
+ /* Bad type */
|
|
|
c9e5da |
+ slapi_ch_free((void**)&this_role);
|
|
|
c9e5da |
+ return SLAPI_ROLE_DEFINITION_ERROR;
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
|
|
|
c9e5da |
- type = roles_cache_determine_class(role_entry);
|
|
|
c9e5da |
+ type = roles_cache_determine_class(role_entry);
|
|
|
c9e5da |
|
|
|
c9e5da |
- if (type != 0)
|
|
|
c9e5da |
+ if (type != 0)
|
|
|
c9e5da |
{
|
|
|
c9e5da |
- this_role->type = type;
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
+ this_role->type = type;
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
else
|
|
|
c9e5da |
{
|
|
|
c9e5da |
- /* Bad type */
|
|
|
c9e5da |
- slapi_ch_free((void**)&this_role);
|
|
|
c9e5da |
- return SLAPI_ROLE_DEFINITION_ERROR;
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
+ /* Bad type */
|
|
|
c9e5da |
+ slapi_ch_free((void**)&this_role);
|
|
|
c9e5da |
+ return SLAPI_ROLE_DEFINITION_ERROR;
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
|
|
|
c9e5da |
this_role->dn = slapi_sdn_new();
|
|
|
c9e5da |
slapi_sdn_copy(slapi_entry_get_sdn(role_entry),this_role->dn);
|
|
|
c9e5da |
-
|
|
|
c9e5da |
- rolescopeDN = slapi_entry_attr_get_charptr(role_entry, ROLE_SCOPE_DN);
|
|
|
c9e5da |
- if (rolescopeDN) {
|
|
|
c9e5da |
- Slapi_DN *rolescopeSDN;
|
|
|
c9e5da |
- Slapi_DN *top_rolescopeSDN, *top_this_roleSDN;
|
|
|
c9e5da |
-
|
|
|
c9e5da |
- /* Before accepting to use this scope, first check if it belongs to the same suffix */
|
|
|
c9e5da |
- rolescopeSDN = slapi_sdn_new_dn_byref(rolescopeDN);
|
|
|
c9e5da |
- if ((strlen((char *) slapi_sdn_get_ndn(rolescopeSDN)) > 0) &&
|
|
|
c9e5da |
- (slapi_dn_syntax_check(NULL, (char *) slapi_sdn_get_ndn(rolescopeSDN), 1) == 0)) {
|
|
|
c9e5da |
- top_rolescopeSDN = roles_cache_get_top_suffix(rolescopeSDN);
|
|
|
c9e5da |
- top_this_roleSDN = roles_cache_get_top_suffix(this_role->dn);
|
|
|
c9e5da |
- if (slapi_sdn_compare(top_rolescopeSDN, top_this_roleSDN) == 0) {
|
|
|
c9e5da |
- /* rolescopeDN belongs to the same suffix as the role, we can use this scope */
|
|
|
c9e5da |
- this_role->rolescopedn = rolescopeSDN;
|
|
|
c9e5da |
- } else {
|
|
|
c9e5da |
- slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
- "%s: invalid %s - %s not in the same suffix. Scope skipped.\n",
|
|
|
c9e5da |
- (char*) slapi_sdn_get_dn(this_role->dn),
|
|
|
c9e5da |
- ROLE_SCOPE_DN,
|
|
|
c9e5da |
- rolescopeDN);
|
|
|
c9e5da |
- slapi_sdn_free(&rolescopeSDN);
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
- slapi_sdn_free(&top_rolescopeSDN);
|
|
|
c9e5da |
- slapi_sdn_free(&top_this_roleSDN);
|
|
|
c9e5da |
- } else {
|
|
|
c9e5da |
- /* this is an invalid DN, just ignore this parameter*/
|
|
|
c9e5da |
- slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
- "%s: invalid %s - %s not a valid DN. Scope skipped.\n",
|
|
|
c9e5da |
- (char*) slapi_sdn_get_dn(this_role->dn),
|
|
|
c9e5da |
- ROLE_SCOPE_DN,
|
|
|
c9e5da |
- rolescopeDN);
|
|
|
c9e5da |
- slapi_sdn_free(&rolescopeSDN);
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ rolescopeDN = slapi_entry_attr_get_charptr(role_entry, ROLE_SCOPE_DN);
|
|
|
c9e5da |
+ if (rolescopeDN) {
|
|
|
c9e5da |
+ Slapi_DN *rolescopeSDN;
|
|
|
c9e5da |
+ Slapi_DN *top_rolescopeSDN, *top_this_roleSDN;
|
|
|
c9e5da |
+
|
|
|
c9e5da |
+ /* Before accepting to use this scope, first check if it belongs to the same suffix */
|
|
|
c9e5da |
+ rolescopeSDN = slapi_sdn_new_dn_byref(rolescopeDN);
|
|
|
c9e5da |
+ if ((strlen((char *) slapi_sdn_get_ndn(rolescopeSDN)) > 0) &&
|
|
|
c9e5da |
+ (slapi_dn_syntax_check(NULL, (char *) slapi_sdn_get_ndn(rolescopeSDN), 1) == 0)) {
|
|
|
c9e5da |
+ top_rolescopeSDN = roles_cache_get_top_suffix(rolescopeSDN);
|
|
|
c9e5da |
+ top_this_roleSDN = roles_cache_get_top_suffix(this_role->dn);
|
|
|
c9e5da |
+ if (slapi_sdn_compare(top_rolescopeSDN, top_this_roleSDN) == 0) {
|
|
|
c9e5da |
+ /* rolescopeDN belongs to the same suffix as the role, we can use this scope */
|
|
|
c9e5da |
+ this_role->rolescopedn = rolescopeSDN;
|
|
|
c9e5da |
+ } else {
|
|
|
c9e5da |
+ slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
+ "roles_cache_create_object_from_entry - %s: invalid %s - %s not in the same suffix. Scope skipped.\n",
|
|
|
c9e5da |
+ (char*) slapi_sdn_get_dn(this_role->dn),
|
|
|
c9e5da |
+ ROLE_SCOPE_DN,
|
|
|
c9e5da |
+ rolescopeDN);
|
|
|
c9e5da |
+ slapi_sdn_free(&rolescopeSDN);
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
+ slapi_sdn_free(&top_rolescopeSDN);
|
|
|
c9e5da |
+ slapi_sdn_free(&top_this_roleSDN);
|
|
|
c9e5da |
+ } else {
|
|
|
c9e5da |
+ /* this is an invalid DN, just ignore this parameter*/
|
|
|
c9e5da |
+ slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
+ "roles_cache_create_object_from_entry - %s: invalid %s - %s not a valid DN. Scope skipped.\n",
|
|
|
c9e5da |
+ (char*) slapi_sdn_get_dn(this_role->dn),
|
|
|
c9e5da |
+ ROLE_SCOPE_DN,
|
|
|
c9e5da |
+ rolescopeDN);
|
|
|
c9e5da |
+ slapi_sdn_free(&rolescopeSDN);
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
|
|
|
c9e5da |
- /* Depending upon role type, pull out the remaining information we need */
|
|
|
c9e5da |
+ /* Depending upon role type, pull out the remaining information we need */
|
|
|
c9e5da |
switch (this_role->type)
|
|
|
c9e5da |
{
|
|
|
c9e5da |
case ROLE_TYPE_MANAGED:
|
|
|
c9e5da |
-
|
|
|
c9e5da |
/* Nothing further needed */
|
|
|
c9e5da |
break;
|
|
|
c9e5da |
|
|
|
c9e5da |
case ROLE_TYPE_FILTERED:
|
|
|
c9e5da |
{
|
|
|
c9e5da |
-
|
|
|
c9e5da |
Slapi_Filter *filter = NULL;
|
|
|
c9e5da |
char *filter_attr_value = NULL;
|
|
|
c9e5da |
Slapi_PBlock *pb = NULL;
|
|
|
c9e5da |
@@ -1203,6 +1221,7 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
|
|
|
c9e5da |
slapi_ch_free((void**)&this_role);
|
|
|
c9e5da |
return SLAPI_ROLE_ERROR_NO_FILTER_SPECIFIED;
|
|
|
c9e5da |
}
|
|
|
c9e5da |
+
|
|
|
c9e5da |
/* search (&(objectclass=costemplate)(filter_attr_value))*/
|
|
|
c9e5da |
/* if found, reject it (returning SLAPI_ROLE_ERROR_FILTER_BAD) */
|
|
|
c9e5da |
pb = slapi_pblock_new();
|
|
|
c9e5da |
@@ -1211,33 +1230,33 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
|
|
|
c9e5da |
Slapi_Entry **cosentries = NULL;
|
|
|
c9e5da |
char *costmpl_filter = NULL;
|
|
|
c9e5da |
if ((*filter_attr_value == '(') &&
|
|
|
c9e5da |
- (*(filter_attr_value+strlen(filter_attr_value)-1) == ')')) {
|
|
|
c9e5da |
+ (*(filter_attr_value+strlen(filter_attr_value)-1) == ')')) {
|
|
|
c9e5da |
costmpl_filter =
|
|
|
c9e5da |
- slapi_ch_smprintf("(&(objectclass=costemplate)%s)",
|
|
|
c9e5da |
- filter_attr_value);
|
|
|
c9e5da |
+ slapi_ch_smprintf("(&(objectclass=costemplate)%s)",
|
|
|
c9e5da |
+ filter_attr_value);
|
|
|
c9e5da |
} else {
|
|
|
c9e5da |
costmpl_filter =
|
|
|
c9e5da |
- slapi_ch_smprintf("(&(objectclass=costemplate)(%s))",
|
|
|
c9e5da |
- filter_attr_value);
|
|
|
c9e5da |
+ slapi_ch_smprintf("(&(objectclass=costemplate)(%s))",
|
|
|
c9e5da |
+ filter_attr_value);
|
|
|
c9e5da |
}
|
|
|
c9e5da |
slapi_search_internal_set_pb(pb, parent, LDAP_SCOPE_SUBTREE,
|
|
|
c9e5da |
- costmpl_filter, NULL, 0, NULL,
|
|
|
c9e5da |
- NULL, roles_get_plugin_identity(),
|
|
|
c9e5da |
- 0);
|
|
|
c9e5da |
+ costmpl_filter, NULL, 0, NULL,
|
|
|
c9e5da |
+ NULL, roles_get_plugin_identity(),
|
|
|
c9e5da |
+ 0);
|
|
|
c9e5da |
slapi_search_internal_pb(pb);
|
|
|
c9e5da |
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
|
|
|
c9e5da |
- &cosentries);
|
|
|
c9e5da |
+ &cosentries);
|
|
|
c9e5da |
slapi_ch_free_string(&costmpl_filter);
|
|
|
c9e5da |
slapi_ch_free_string(&parent);
|
|
|
c9e5da |
if (cosentries && *cosentries) {
|
|
|
c9e5da |
slapi_free_search_results_internal(pb);
|
|
|
c9e5da |
slapi_pblock_destroy(pb);
|
|
|
c9e5da |
slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
- "%s: not allowed to refer virtual attribute "
|
|
|
c9e5da |
- "in the value of %s %s. The %s is disabled.\n",
|
|
|
c9e5da |
- (char*)slapi_sdn_get_ndn(this_role->dn),
|
|
|
c9e5da |
- ROLE_FILTER_ATTR_NAME, filter_attr_value,
|
|
|
c9e5da |
- ROLE_FILTER_ATTR_NAME);
|
|
|
c9e5da |
+ "roles_cache_create_object_from_entry - %s: not allowed to refer virtual attribute "
|
|
|
c9e5da |
+ "in the value of %s %s. The %s is disabled.\n",
|
|
|
c9e5da |
+ (char*)slapi_sdn_get_ndn(this_role->dn),
|
|
|
c9e5da |
+ ROLE_FILTER_ATTR_NAME, filter_attr_value,
|
|
|
c9e5da |
+ ROLE_FILTER_ATTR_NAME);
|
|
|
c9e5da |
slapi_ch_free_string(&filter_attr_value);
|
|
|
c9e5da |
slapi_ch_free((void**)&this_role);
|
|
|
c9e5da |
return SLAPI_ROLE_ERROR_FILTER_BAD;
|
|
|
c9e5da |
@@ -1248,16 +1267,27 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
|
|
|
c9e5da |
|
|
|
c9e5da |
/* Turn it into a slapi filter object */
|
|
|
c9e5da |
filter = slapi_str2filter(filter_attr_value);
|
|
|
c9e5da |
- slapi_ch_free_string(&filter_attr_value);
|
|
|
c9e5da |
-
|
|
|
c9e5da |
- if ( filter == NULL )
|
|
|
c9e5da |
+ if ( filter == NULL )
|
|
|
c9e5da |
{
|
|
|
c9e5da |
/* An error has occured */
|
|
|
c9e5da |
slapi_ch_free((void**)&this_role);
|
|
|
c9e5da |
+ slapi_ch_free_string(&filter_attr_value);
|
|
|
c9e5da |
+ return SLAPI_ROLE_ERROR_FILTER_BAD;
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
+ if (roles_check_filter(filter)) {
|
|
|
c9e5da |
+ slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
+ "roles_cache_create_object_from_entry - \"%s\": not allowed to use \"nsrole\" "
|
|
|
c9e5da |
+ "in the role filter \"%s\". %s is disabled.\n",
|
|
|
c9e5da |
+ (char*)slapi_sdn_get_ndn(this_role->dn),
|
|
|
c9e5da |
+ filter_attr_value,
|
|
|
c9e5da |
+ ROLE_FILTER_ATTR_NAME);
|
|
|
c9e5da |
+ slapi_ch_free((void**)&this_role);
|
|
|
c9e5da |
+ slapi_ch_free_string(&filter_attr_value);
|
|
|
c9e5da |
return SLAPI_ROLE_ERROR_FILTER_BAD;
|
|
|
c9e5da |
}
|
|
|
c9e5da |
/* Store on the object */
|
|
|
c9e5da |
this_role->filter = filter;
|
|
|
c9e5da |
+ slapi_ch_free_string(&filter_attr_value);
|
|
|
c9e5da |
|
|
|
c9e5da |
break;
|
|
|
c9e5da |
}
|
|
|
c9e5da |
@@ -1276,50 +1306,49 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
|
|
|
c9e5da |
int i = 0;
|
|
|
c9e5da |
char *string = NULL;
|
|
|
c9e5da |
Slapi_DN nested_role_dn;
|
|
|
c9e5da |
- role_object_nested *nested_role_object = NULL;
|
|
|
c9e5da |
+ role_object_nested *nested_role_object = NULL;
|
|
|
c9e5da |
|
|
|
c9e5da |
- for ( i = 0; va[i] != NULL; i++ )
|
|
|
c9e5da |
+ for ( i = 0; va[i] != NULL; i++ )
|
|
|
c9e5da |
{
|
|
|
c9e5da |
- string = (char*)slapi_value_get_string(va[i]);
|
|
|
c9e5da |
+ string = (char*)slapi_value_get_string(va[i]);
|
|
|
c9e5da |
|
|
|
c9e5da |
- /* Make a DN from the string */
|
|
|
c9e5da |
- slapi_sdn_init_dn_byref(&nested_role_dn,string);
|
|
|
c9e5da |
+ /* Make a DN from the string */
|
|
|
c9e5da |
+ slapi_sdn_init_dn_byref(&nested_role_dn,string);
|
|
|
c9e5da |
|
|
|
c9e5da |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
|
|
c9e5da |
ROLES_PLUGIN_SUBSYSTEM, "roles_cache_create_object_from_entry: dn %s, nested %s\n",
|
|
|
c9e5da |
(char*)slapi_sdn_get_ndn(this_role->dn),string);
|
|
|
c9e5da |
|
|
|
c9e5da |
- /* Make a role object nested from the DN */
|
|
|
c9e5da |
- rc = roles_cache_object_nested_from_dn(&nested_role_dn,&nested_role_object);
|
|
|
c9e5da |
+ /* Make a role object nested from the DN */
|
|
|
c9e5da |
+ rc = roles_cache_object_nested_from_dn(&nested_role_dn,&nested_role_object);
|
|
|
c9e5da |
|
|
|
c9e5da |
- /* Insert it into the nested list */
|
|
|
c9e5da |
- if ( (rc == 0) && nested_role_object)
|
|
|
c9e5da |
+ /* Insert it into the nested list */
|
|
|
c9e5da |
+ if ( (rc == 0) && nested_role_object)
|
|
|
c9e5da |
{
|
|
|
c9e5da |
/* Add to the tree where avl_data is a role_object_nested struct */
|
|
|
c9e5da |
- rc = roles_cache_insert_object_nested(&(this_role->avl_tree),nested_role_object);
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
- slapi_sdn_done(&nested_role_dn);
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
-
|
|
|
c9e5da |
+ rc = roles_cache_insert_object_nested(&(this_role->avl_tree),nested_role_object);
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
+ slapi_sdn_done(&nested_role_dn);
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
+
|
|
|
c9e5da |
break;
|
|
|
c9e5da |
}
|
|
|
c9e5da |
|
|
|
c9e5da |
default:
|
|
|
c9e5da |
- slapi_log_error(SLAPI_LOG_FATAL,
|
|
|
c9e5da |
- ROLES_PLUGIN_SUBSYSTEM, "wrong role type\n");
|
|
|
c9e5da |
+ slapi_log_error(SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
+ "roles_cache_create_object_from_entry - wrong role type\n");
|
|
|
c9e5da |
}
|
|
|
c9e5da |
|
|
|
c9e5da |
- if ( rc == 0 )
|
|
|
c9e5da |
+ if ( rc == 0 )
|
|
|
c9e5da |
{
|
|
|
c9e5da |
- *result = this_role;
|
|
|
c9e5da |
- }
|
|
|
c9e5da |
+ *result = this_role;
|
|
|
c9e5da |
+ }
|
|
|
c9e5da |
|
|
|
c9e5da |
slapi_log_error(SLAPI_LOG_PLUGIN, ROLES_PLUGIN_SUBSYSTEM,
|
|
|
c9e5da |
- "<-- roles_cache_create_object_from_entry\n");
|
|
|
c9e5da |
-
|
|
|
c9e5da |
+ "<-- roles_cache_create_object_from_entry\n");
|
|
|
c9e5da |
|
|
|
c9e5da |
- return rc;
|
|
|
c9e5da |
+ return rc;
|
|
|
c9e5da |
}
|
|
|
c9e5da |
|
|
|
c9e5da |
/* roles_cache_determine_class:
|
|
|
c9e5da |
--
|
|
|
c9e5da |
2.7.4
|
|
|
c9e5da |
|