source:
trunk/server/common/patches/389-ds-indirect-cos.patch
@
2774
Last change on this file since 2774 was 2761, checked in by achernya, 9 years ago | |
---|---|
File size: 10.1 KB |
-
new file dirsrvtests/tickets/ticket47921_test.py
From a9cd2ffd227c19a458b27415dedaaf4a6b4778ec Mon Sep 17 00:00:00 2001 From: Mark Reynolds <mreynolds@redhat.com> Date: Thu, 11 Jun 2015 12:28:07 -0400 Subject: [PATCH] Ticket 47921 - indirect cos does not reflect changes in the cos attribute Bug Description: Indirect cos results are incorrectly cached, so any changes to entries that are indirect are not returned to the client. Fix Description: Do not cache the vattr result if it came from a indirect cos definition. https://fedorahosted.org/389/ticket/47921 Reviewed by: ? --- dirsrvtests/tickets/ticket47921_test.py | 155 ++++++++++++++++++++++++++++++++ ldap/servers/plugins/cos/cos_cache.c | 26 ++++-- 2 files changed, 174 insertions(+), 7 deletions(-) create mode 100644 dirsrvtests/tickets/ticket47921_test.py diff --git a/dirsrvtests/tickets/ticket47921_test.py b/dirsrvtests/tickets/ticket47921_test.py new file mode 100644 index 0000000..951d33b
- + 1 import os 2 import sys 3 import time 4 import ldap 5 import logging 6 import pytest 7 from lib389 import DirSrv, Entry, tools, tasks 8 from lib389.tools import DirSrvTools 9 from lib389._constants import * 10 from lib389.properties import * 11 from lib389.tasks import * 12 from lib389.utils import * 13 14 logging.getLogger(__name__).setLevel(logging.DEBUG) 15 log = logging.getLogger(__name__) 16 17 installation1_prefix = None 18 19 20 class TopologyStandalone(object): 21 def __init__(self, standalone): 22 standalone.open() 23 self.standalone = standalone 24 25 26 @pytest.fixture(scope="module") 27 def topology(request): 28 global installation1_prefix 29 if installation1_prefix: 30 args_instance[SER_DEPLOYED_DIR] = installation1_prefix 31 32 # Creating standalone instance ... 33 standalone = DirSrv(verbose=False) 34 args_instance[SER_HOST] = HOST_STANDALONE 35 args_instance[SER_PORT] = PORT_STANDALONE 36 args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE 37 args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX 38 args_standalone = args_instance.copy() 39 standalone.allocate(args_standalone) 40 instance_standalone = standalone.exists() 41 if instance_standalone: 42 standalone.delete() 43 standalone.create() 44 standalone.open() 45 46 # Clear out the tmp dir 47 standalone.clearTmpDir(__file__) 48 49 return TopologyStandalone(standalone) 50 51 52 def test_ticket47921(topology): 53 ''' 54 Test that indirect cos reflects the current value of the indirect entry 55 ''' 56 57 INDIRECT_COS_DN = 'cn=cos definition,' + DEFAULT_SUFFIX 58 MANAGER_DN = 'uid=my manager,ou=people,' + DEFAULT_SUFFIX 59 USER_DN = 'uid=user,ou=people,' + DEFAULT_SUFFIX 60 61 # Add COS definition 62 try: 63 topology.standalone.add_s(Entry((INDIRECT_COS_DN, 64 {'objectclass': 'top cosSuperDefinition cosIndirectDefinition ldapSubEntry'.split(), 65 'cosIndirectSpecifier': 'manager', 66 'cosAttribute': 'roomnumber' 67 }))) 68 except ldap.LDAPError, e: 69 log.fatal('Failed to add cos defintion, error: ' + e.message['desc']) 70 assert False 71 72 # Add manager entry 73 try: 74 topology.standalone.add_s(Entry((MANAGER_DN, 75 {'objectclass': 'top extensibleObject'.split(), 76 'uid': 'my manager', 77 'roomnumber': '1' 78 }))) 79 except ldap.LDAPError, e: 80 log.fatal('Failed to add manager entry, error: ' + e.message['desc']) 81 assert False 82 83 # Add user entry 84 try: 85 topology.standalone.add_s(Entry((USER_DN, 86 {'objectclass': 'top person organizationalPerson inetorgperson'.split(), 87 'sn': 'last', 88 'cn': 'full', 89 'givenname': 'mark', 90 'uid': 'user', 91 'manager': MANAGER_DN 92 }))) 93 except ldap.LDAPError, e: 94 log.fatal('Failed to add manager entry, error: ' + e.message['desc']) 95 assert False 96 97 # Test COS is working 98 try: 99 entry = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, 100 "uid=user", 101 ['roomnumber']) 102 if entry: 103 if entry[0].getValue('roomnumber') != '1': 104 log.fatal('COS is not working.') 105 assert False 106 else: 107 log.fatal('Failed to find user entry') 108 assert False 109 except ldap.LDAPError, e: 110 log.error('Failed to search for user entry: ' + e.message['desc']) 111 assert False 112 113 # Modify manager entry 114 try: 115 topology.standalone.modify_s(MANAGER_DN, [(ldap.MOD_REPLACE, 'roomnumber', '2')]) 116 except ldap.LDAPError, e: 117 log.error('Failed to modify manager entry: ' + e.message['desc']) 118 assert False 119 120 # Confirm COS is returning the new value 121 try: 122 entry = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, 123 "uid=user", 124 ['roomnumber']) 125 if entry: 126 if entry[0].getValue('roomnumber') != '2': 127 log.fatal('COS is not working after manager update.') 128 assert False 129 else: 130 log.fatal('Failed to find user entry') 131 assert False 132 except ldap.LDAPError, e: 133 log.error('Failed to search for user entry: ' + e.message['desc']) 134 assert False 135 136 log.info('Test complete') 137 138 139 def test_ticket47921_final(topology): 140 topology.standalone.delete() 141 log.info('Testcase PASSED') 142 143 144 def run_isolated(): 145 global installation1_prefix 146 installation1_prefix = None 147 148 topo = topology(True) 149 test_ticket47921(topo) 150 test_ticket47921_final(topo) 151 152 153 if __name__ == '__main__': 154 run_isolated() 155 -
ldap/servers/plugins/cos/cos_cache.c
diff --git a/ldap/servers/plugins/cos/cos_cache.c b/ldap/servers/plugins/cos/cos_cache.c index 7d8e877..fa2b6b5 100644
a b void cos_cache_backend_state_change(void *handle, char *be_name, 284 284 static int cos_cache_vattr_get(vattr_sp_handle *handle, vattr_context *c, Slapi_Entry *e, char *type, Slapi_ValueSet** results,int *type_name_disposition, char** actual_type_name, int flags, int *free_flags, void *hint); 285 285 static int cos_cache_vattr_compare(vattr_sp_handle *handle, vattr_context *c, Slapi_Entry *e, char *type, Slapi_Value *test_this, int* result, int flags, void *hint); 286 286 static int cos_cache_vattr_types(vattr_sp_handle *handle,Slapi_Entry *e,vattr_type_list_context *type_context,int flags); 287 static int cos_cache_query_attr(cos_cache *ptheCache, vattr_context *context, Slapi_Entry *e, char *type, Slapi_ValueSet **out_attr, Slapi_Value *test_this, int *result, int *ops );287 static int cos_cache_query_attr(cos_cache *ptheCache, vattr_context *context, Slapi_Entry *e, char *type, Slapi_ValueSet **out_attr, Slapi_Value *test_this, int *result, int *ops, int *indirect_cos); 288 288 289 289 /* 290 290 compares s2 to s1 starting from end of string until the beginning of either … … static int cos_cache_attrval_exists(cosAttrValue *pAttrs, const char *val) 2096 2096 2097 2097 static int cos_cache_vattr_get(vattr_sp_handle *handle, vattr_context *c, Slapi_Entry *e, char *type, Slapi_ValueSet** results,int *type_name_disposition, char** actual_type_name, int flags, int *free_flags, void *hint) 2098 2098 { 2099 int ret = -1;2100 2099 cos_cache *pCache = 0; 2100 int indirect_cos = 0; 2101 int ret = -1; 2101 2102 2102 2103 LDAPDebug( LDAP_DEBUG_TRACE, "--> cos_cache_vattr_get\n",0,0,0); 2103 2104 … … static int cos_cache_vattr_get(vattr_sp_handle *handle, vattr_context *c, Slapi_ 2108 2109 goto bail; 2109 2110 } 2110 2111 2111 ret = cos_cache_query_attr(pCache, c, e, type, results, NULL, NULL, NULL );2112 ret = cos_cache_query_attr(pCache, c, e, type, results, NULL, NULL, NULL, &indirect_cos); 2112 2113 if(ret == 0) 2113 2114 { 2114 *free_flags = SLAPI_VIRTUALATTRS_RETURNED_COPIES | SLAPI_VIRTUALATTRS_VALUES_CACHEABLE; 2115 if(indirect_cos){ 2116 /* we can't cache indirect cos */ 2117 *free_flags = SLAPI_VIRTUALATTRS_RETURNED_COPIES; 2118 } else { 2119 *free_flags = SLAPI_VIRTUALATTRS_RETURNED_COPIES | SLAPI_VIRTUALATTRS_VALUES_CACHEABLE; 2120 } 2115 2121 *actual_type_name = slapi_ch_strdup(type); 2116 2122 *type_name_disposition = SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_EXACTLY_OR_ALIAS; 2117 2123 } … … static int cos_cache_vattr_compare(vattr_sp_handle *handle, vattr_context *c, Sl 2138 2144 goto bail; 2139 2145 } 2140 2146 2141 ret = cos_cache_query_attr(pCache, c, e, type, NULL, test_this, result, NULL );2147 ret = cos_cache_query_attr(pCache, c, e, type, NULL, test_this, result, NULL, NULL); 2142 2148 2143 2149 cos_cache_release(pCache); 2144 2150 … … static int cos_cache_vattr_types(vattr_sp_handle *handle,Slapi_Entry *e, 2179 2185 lastattr = pCache->ppAttrIndex[index]->pAttrName; 2180 2186 2181 2187 if(1 == cos_cache_query_attr(pCache, NULL, e, lastattr, NULL, NULL, 2182 NULL, &props ))2188 NULL, &props, NULL)) 2183 2189 { 2184 2190 /* entry contains this attr */ 2185 2191 vattr_type_thang thang = {0}; … … bail: 2223 2229 overriding and allow the DS logic to pick it up by denying knowledge 2224 2230 of attribute 2225 2231 */ 2226 static int cos_cache_query_attr(cos_cache *ptheCache, vattr_context *context, Slapi_Entry *e, char *type, Slapi_ValueSet **out_attr, Slapi_Value *test_this, int *result, int *props) 2232 static int cos_cache_query_attr(cos_cache *ptheCache, vattr_context *context, 2233 Slapi_Entry *e, char *type, Slapi_ValueSet **out_attr, 2234 Slapi_Value *test_this, int *result, int *props, 2235 int *indirect_cos) 2227 2236 { 2228 2237 int ret = -1; 2229 2238 cosCache *pCache = (cosCache*)ptheCache; … … static int cos_cache_query_attr(cos_cache *ptheCache, vattr_context *context, Sl 2420 2429 if (cos_cache_follow_pointer( context, (char*)slapi_value_get_string(indirectdn), 2421 2430 type, &tmp_vals, test_this, result, pointer_flags) == 0) 2422 2431 { 2432 if(indirect_cos){ 2433 *indirect_cos = 1; 2434 } 2423 2435 hit = 1; 2424 2436 /* If the caller requested values, set them. We need 2425 2437 * to append values when we follow multiple pointers DNs. */
Note: See TracBrowser
for help on using the repository browser.