|
Lines 57-64
Link Here
|
| 57 |
else: |
57 |
else: |
| 58 |
univention.debug.debug(univention.debug.LISTENER, univention.debug.WARN, "ad-connector: additional config basename %s given, but %s/ad/listener/dir not set; ignore basename." % (configbasename, configbasename)) |
58 |
univention.debug.debug(univention.debug.LISTENER, univention.debug.WARN, "ad-connector: additional config basename %s given, but %s/ad/listener/dir not set; ignore basename." % (configbasename, configbasename)) |
| 59 |
|
59 |
|
|
|
60 |
def _save_old_object(directory, dn, old): |
| 61 |
filename=os.path.join(directory, 'tmp','old_dn') |
| 62 |
|
| 63 |
f=open(filename, 'w+') |
| 64 |
os.chmod(filename, 0600) |
| 65 |
p=cPickle.Pickler(f) |
| 66 |
old_dn=p.dump((dn,old)) |
| 67 |
p.clear_memo() |
| 68 |
f.close() |
| 69 |
|
| 70 |
def _load_old_object(directory): |
| 71 |
f=open(os.path.join(directory, 'tmp','old_dn'),'r') |
| 72 |
p=cPickle.Unpickler(f) |
| 73 |
(old_dn,old_object)=p.load() |
| 74 |
f.close() |
| 75 |
|
| 76 |
return (old_dn,old_object) |
| 60 |
|
77 |
|
|
|
78 |
def _dump_object_to_file(filename, ob): |
| 79 |
f=open(filename, 'w+') |
| 80 |
os.chmod(filename, 0600) |
| 81 |
p=cPickle.Pickler(f) |
| 82 |
p.dump(ob) |
| 83 |
p.clear_memo() |
| 84 |
f.close() |
| 61 |
|
85 |
|
|
|
86 |
def _dump_changes_to_file_and_check_file(directory, dn, new, old, old_dn): |
| 87 |
|
| 88 |
ob=(dn, new, old, old_dn) |
| 89 |
|
| 90 |
filename=os.path.join(directory,"%f"%time.time()) |
| 91 |
|
| 92 |
_dump_object_to_file(filename, ob) |
| 93 |
|
| 94 |
tmp_array = [] |
| 95 |
f=open(filename, 'r') |
| 96 |
tmp_array = cPickle.load(f) |
| 97 |
f.close() |
| 98 |
|
| 99 |
tmp_array_len = len(tmp_array) |
| 100 |
if tmp_array_len != 4: |
| 101 |
univention.debug.debug(univention.debug.LDAP, univention.debug.WARN, 'replacing broken cPickle in %s (len=%s) with plain pickle' % (filename, tmp_array_len)) |
| 102 |
_dump_object_to_file(filename, ob) |
| 103 |
|
| 104 |
tmp_array = [] |
| 105 |
f=open(filename, 'r') |
| 106 |
tmp_array = cPickle.load(f) |
| 107 |
f.close() |
| 108 |
|
| 109 |
tmp_array_len = len(tmp_array) |
| 110 |
if tmp_array_len != 4: |
| 111 |
univention.debug.debug(univention.debug.LDAP, univention.debug.ERROR, 'pickle in %s (len=%s) seems to be broken' % (filename, tmp_array_len)) |
| 112 |
|
| 62 |
def handler(dn, new, old, command): |
113 |
def handler(dn, new, old, command): |
| 63 |
|
114 |
|
| 64 |
global group_objects |
115 |
global group_objects |
|
Lines 70-105
Link Here
|
| 70 |
if not os.path.exists(os.path.join(directory, 'tmp')): |
121 |
if not os.path.exists(os.path.join(directory, 'tmp')): |
| 71 |
os.makedirs(os.path.join(directory, 'tmp')) |
122 |
os.makedirs(os.path.join(directory, 'tmp')) |
| 72 |
|
123 |
|
| 73 |
old_dn=None |
124 |
old_dn = None |
|
|
125 |
old_object = {} |
| 126 |
|
| 74 |
if os.path.exists(os.path.join(directory, 'tmp','old_dn')): |
127 |
if os.path.exists(os.path.join(directory, 'tmp','old_dn')): |
| 75 |
f=open(os.path.join(directory, 'tmp','old_dn'),'r') |
128 |
(old_dn,old_object) = _load_old_object(directory) |
| 76 |
p=cPickle.Unpickler(f) |
|
|
| 77 |
old_dn=p.load() |
| 78 |
f.close() |
| 79 |
if command == 'r': |
129 |
if command == 'r': |
| 80 |
filename=os.path.join(directory, 'tmp','old_dn') |
130 |
_save_old_object(directory, dn, old) |
| 81 |
|
|
|
| 82 |
f=open(filename, 'w+') |
| 83 |
os.chmod(filename, 0600) |
| 84 |
p=cPickle.Pickler(f) |
| 85 |
old_dn=p.dump(dn) |
| 86 |
p.clear_memo() |
| 87 |
f.close() |
| 88 |
else: |
131 |
else: |
| 89 |
ob=(dn, new, old, old_dn) |
132 |
# Normally we see two steps for the modrdn operation. But in case of the selective replication we |
|
|
133 |
# might only see the first step. |
| 134 |
# https://forge.univention.org/bugzilla/show_bug.cgi?id=32542 |
| 135 |
if old_dn and new.get('entryUUID') != old_object.get('entryUUID'): |
| 136 |
univention.debug.debug(univention.debug.LISTENER, univention.debug.PROCESS, "The entryUUID attribute of the saved object (%s) does not match the entryUUID attribute of the current object (%s). This can be normal in a selective replication scenario." % (old_dn, dn)) |
| 137 |
_dump_changes_to_file_and_check_file(directory, old_dn, {}, old_object, None) |
| 138 |
old_dn = None |
| 90 |
|
139 |
|
| 91 |
filename=os.path.join(directory,"%f"%time.time()) |
|
|
| 92 |
|
| 93 |
if init_mode: |
140 |
if init_mode: |
| 94 |
if new and 'univentionGroup' in new.get('objectClass', []): |
141 |
if new and 'univentionGroup' in new.get('objectClass', []): |
| 95 |
group_objects.append(ob) |
142 |
group_objects.append((dn, new, old, old_dn)) |
| 96 |
|
143 |
|
| 97 |
f=open(filename, 'w+') |
144 |
_dump_changes_to_file_and_check_file(directory, dn, new, old, old_dn) |
| 98 |
os.chmod(filename, 0600) |
|
|
| 99 |
p=cPickle.Pickler(f) |
| 100 |
p.dump(ob) |
| 101 |
p.clear_memo() |
| 102 |
f.close() |
| 103 |
|
145 |
|
| 104 |
if os.path.exists(os.path.join(directory, 'tmp','old_dn')): |
146 |
if os.path.exists(os.path.join(directory, 'tmp','old_dn')): |
| 105 |
os.unlink(os.path.join(directory, 'tmp','old_dn')) |
147 |
os.unlink(os.path.join(directory, 'tmp','old_dn')) |