View | Details | Raw Unified | Return to bug 42507 | Differences between
and this patch

Collapse All | Expand All

(-)a/services/univention-ad-connector/ad-connector.py (-7 / +12 lines)
 Lines 37-42    Link Here 
37
import time
37
import time
38
import os
38
import os
39
import univention.debug
39
import univention.debug
40
import shutil
40
41
41
name = 'ad-connector'
42
name = 'ad-connector'
42
description = 'AD Connector replication'
43
description = 'AD Connector replication'
 Lines 94-121   def _dump_changes_to_file_and_check_file(directory, dn, new, old, old_dn): Link Here 
94
95
95
	ob = (dn, new, old, old_dn)
96
	ob = (dn, new, old, old_dn)
96
97
97
	filename = os.path.join(directory, "%f" % time.time())
98
	tmpdir = os.path.join(directory, 'tmp')
99
	filename = '%f' % (time.time(),)
100
	filepath = os.path.join(tmpdir, filename)
98
101
99
	_dump_object_to_file(filename, ob)
102
	_dump_object_to_file(filepath, ob)
100
103
101
	tmp_array = []
104
	tmp_array = []
102
	f = open(filename, 'r')
105
	f = open(filepath, 'r')
103
	tmp_array = cPickle.load(f)
106
	tmp_array = cPickle.load(f)
104
	f.close()
107
	f.close()
105
108
106
	tmp_array_len = len(tmp_array)
109
	tmp_array_len = len(tmp_array)
107
	if tmp_array_len != 4:
110
	if tmp_array_len != 4:
108
		univention.debug.debug(univention.debug.LDAP, univention.debug.WARN, 'replacing broken cPickle in %s (len=%s) with plain pickle' % (filename, tmp_array_len))
111
		univention.debug.debug(univention.debug.LDAP, univention.debug.WARN, 'replacing broken cPickle in %s (len=%s) with plain pickle' % (filepath, tmp_array_len))
109
		_dump_object_to_file(filename, ob)
112
		_dump_object_to_file(filepath, ob)
110
113
111
		tmp_array = []
114
		tmp_array = []
112
		f = open(filename, 'r')
115
		f = open(filepath, 'r')
113
		tmp_array = cPickle.load(f)
116
		tmp_array = cPickle.load(f)
114
		f.close()
117
		f.close()
115
118
116
		tmp_array_len = len(tmp_array)
119
		tmp_array_len = len(tmp_array)
117
		if tmp_array_len != 4:
120
		if tmp_array_len != 4:
118
			univention.debug.debug(univention.debug.LDAP, univention.debug.ERROR, 'pickle in %s (len=%s) seems to be broken' % (filename, tmp_array_len))
121
			univention.debug.debug(univention.debug.LDAP, univention.debug.ERROR, 'pickle in %s (len=%s) seems to be broken' % (filepath, tmp_array_len))
122
123
	shutil.move(filepath, os.path.join(directory, filename))
119
124
120
125
121
def handler(dn, new, old, command):
126
def handler(dn, new, old, command):

Return to bug 42507