Index: modules/univention/s4connector/__init__.py =================================================================== --- modules/univention/s4connector/__init__.py (Revision 51983) +++ modules/univention/s4connector/__init__.py (Arbeitskopie) @@ -31,7 +31,7 @@ # /usr/share/common-licenses/AGPL-3; if not, see # . -import sys, codecs, base64, string, os, cPickle, types, random, traceback, copy, time +import sys, codecs, string, os, cPickle, types, random, traceback, copy, time import ldap import pdb import univention_baseconfig @@ -41,6 +41,8 @@ import univention.admin.objects import univention.debug2 as ud import base64 +from samba.ndr import ndr_unpack +from samba.dcerpc import misc from signal import * term_signal_caught = False @@ -623,7 +625,6 @@ print traceback with ud.debug, level is i.e. ud.INFO ''' _d=ud.function('ldap._debug_traceback') - exc_info = sys.exc_info() ud.debug(ud.LDAP, level, text) ud.debug(ud.LDAP, level, traceback.format_exc()) @@ -1329,7 +1330,9 @@ pass try: - guid = original_object.get('attributes').get('objectGUID')[0] + guid_unicode = original_object.get('attributes').get('objectGUID')[0] + guid_blob = guid_unicode.encode('ISO-8859-1') ## to compensate for __object_from_element + guid = str(ndr_unpack(misc.GUID, guid_blob)) object['changed_attributes'] = [] if object['modtype'] == 'modify' and original_object: Index: modules/univention/s4connector/s4/__init__.py =================================================================== --- modules/univention/s4connector/s4/__init__.py (Revision 51983) +++ modules/univention/s4connector/s4/__init__.py (Arbeitskopie) @@ -32,7 +32,7 @@ # . -import string, ldap, sys, traceback, base64, time, pdb, os, copy, types +import string, ldap, sys, base64, time, pdb, os, copy, types import array import univention.uldap import univention.s4connector Index: modules/univention/s4connector/s4cache.py =================================================================== --- modules/univention/s4connector/s4cache.py (Revision 51983) +++ modules/univention/s4connector/s4cache.py (Arbeitskopie) @@ -41,22 +41,6 @@ def func_name(): return inspect.currentframe().f_back.f_code.co_name -def _is_base64(val): - try: - # It is not sufficient to run base64.decodestring to detect a base64 string. - # When the ascii decode is not possible, it is not a base4 string. - val.decode('ascii') - except UnicodeDecodeError: - return False - try: - # The string must be casted as str otherwise we saw something like this: - # 11.02.2014 03:53:44,141 LDAP (INFO): _is_base64 returns True for: Í8^Ml%'A²ôâ/! ^RÃ - # 11.02.2014 03:53:44,142 LDAP (WARNING): S4Cache: sqlite: near "A²ôâ": syntax error. SQL command was: [u"SELECT id FROM GUIDS WHERE guid='\xcd8\rl%'\x97A\xb2\xf4\xe2/! \x12\xc3';" - base64.decodestring(str(val)) - return True - except binascii.Error: - return False - def _decode_base64(val): return base64.decodestring(val) @@ -63,24 +47,6 @@ def _encode_base64(val): return base64.encodestring(val) -def _encode_guid(guid): - # guid may be unicode - - if _is_base64(guid): - return guid - - if type(guid) == type(u''): - return guid.encode('ISO-8859-1').encode('base64') - else: - return unicode(guid,'latin').encode('ISO-8859-1').encode('base64') - -def _decode_guid(guid): - try: - return base64.decodestring(guid) - except binascii.Error: - return guid - - class EntryDiff(object): def __init__(self, old, new): self.old = old @@ -121,8 +87,6 @@ def add_entry(self, guid, entry): _d = ud.function('S4Cache.%s' % func_name()) - guid = _encode_guid(guid).strip() - if not self._guid_exists(guid): self._add_entry(guid, entry) else: @@ -148,8 +112,6 @@ entry = {} - guid = _encode_guid(guid) - guid_id = self._get_guid_id(guid) if not guid_id: @@ -157,7 +119,7 @@ sql_commands = [ "SELECT ATTRIBUTES.attribute,data.value from data \ - inner join ATTRIBUTES ON data.attribute_id=attributes.id where guid_id = %s;" % (guid_id) + inner join ATTRIBUTES ON data.attribute_id=attributes.id where guid_id = %s;" % (guid_id,) ] rows = self.__execute_sql_commands(sql_commands, fetch_result=True) @@ -175,8 +137,6 @@ def remove_entry(self, guid): _d = ud.function('S4Cache.%s' % func_name()) - guid = _encode_guid(guid) - guid_id = self._get_guid_id(guid) if not guid_id: @@ -183,8 +143,8 @@ return None sql_commands = [ - "DELETE FROM data WHERE guid_id = '%(guid_id)s';" % ({'guid_id': guid_id}), - "DELETE FROM guids WHERE id = '%(guid_id)s';" % ({'guid_id': guid_id}) + "DELETE FROM data WHERE guid_id = '%(guid_id)s';" % {'guid_id': guid_id}, + "DELETE FROM guids WHERE id = '%(guid_id)s';" % {'guid_id': guid_id} ] self.__execute_sql_commands(sql_commands, fetch_result=False) @@ -237,7 +197,7 @@ _d = ud.function('S4Cache.%s' % func_name()) sql_commands = [ - "SELECT id FROM GUIDS WHERE guid='%s';" % (_encode_guid(guid).strip()) + "SELECT id FROM GUIDS WHERE guid='%s';" % (guid,) ] rows = self.__execute_sql_commands(sql_commands, fetch_result=True) @@ -252,7 +212,7 @@ _d = ud.function('S4Cache.%s' % func_name()) sql_commands = [ - "INSERT INTO GUIDS(guid) VALUES('%s');" % (_encode_guid(guid).strip()) + "INSERT INTO GUIDS(guid) VALUES('%s');" % (guid,) ] rows = self.__execute_sql_commands(sql_commands, fetch_result=False) @@ -262,7 +222,7 @@ _d = ud.function('S4Cache.%s' % func_name()) sql_commands = [ - "SELECT id FROM ATTRIBUTES WHERE attribute='%s';" % (attr) + "SELECT id FROM ATTRIBUTES WHERE attribute='%s';" % (attr,) ] rows = self.__execute_sql_commands(sql_commands, fetch_result=True) @@ -282,7 +242,7 @@ _d = ud.function('S4Cache.%s' % func_name()) sql_commands = [ - "INSERT INTO ATTRIBUTES(attribute) VALUES('%s');" % (attr) + "INSERT INTO ATTRIBUTES(attribute) VALUES('%s');" % (attr,) ] self.__execute_sql_commands(sql_commands, fetch_result=False)