Bug 24779 - Buffer Size Error in password_sync_s4_to_ucs/calculate_krb5key
Buffer Size Error in password_sync_s4_to_ucs/calculate_krb5key
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: S4 Connector
UCS 3.0
Other Linux
: P5 normal (vote)
: UCS 3.0-1
Assigned To: Arvid Requate
Felix Botner
:
: 24780 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-22 09:58 CET by Kevin Dominik Korte
Modified: 2012-03-04 14:34 CET (History)
3 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
Patch für univention-s4-connector, der die Probleme an diesem Bug addressiert. (6.17 KB, patch)
2012-01-30 17:57 CET, Arvid Requate
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Dominik Korte univentionstaff 2011-11-22 09:58:50 CET
Die Übertragung des Keytabs endet mit folgender Fehlermeldung im S4 connector log

22.11.2011 09:52:42,660 LDAP        (PROCESS): sync to ucs: Resync rejected dn: CN=id,CN=Users,DC=ldapbase
22.11.2011 09:52:42,660 LDAP        (PROCESS): sync to ucs: Resync rejected dn: CN=id,CN=Users,DC=ldapbase
22.11.2011 09:52:42,668 LDAP        (PROCESS): sync to ucs:   [          user] [    modify] uid=id,cn=users,dc=ldapbase
22.11.2011 09:52:42,668 LDAP        (PROCESS): sync to ucs:   [          user] [    modify] uid=id,cn=users,dc=ldapbase
22.11.2011 09:52:45,90 LDAP        (ERROR  ): failed in post_con_modify_functions
22.11.2011 09:52:45,90 LDAP        (ERROR  ): failed in post_con_modify_functions
22.11.2011 09:52:45,159 LDAP        (ERROR  ): Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/univention/s4connector/__init__.py", line 1123, in sync_to_ucs
    f(self, property_type, object)
  File "/usr/lib/pymodules/python2.6/univention/s4connector/s4/password.py", line 554, in password_sync_s4_to_ucs
    krb5Key_new = calculate_krb5key(unicodePwd_attr, supplementalCredentials, int(msDS_KeyVersionNumber))
  File "/usr/lib/pymodules/python2.6/univention/s4connector/s4/password.py", line 67, in calculate_krb5key
    sc = ndr_unpack(drsblobs.supplementalCredentialsBlob, sc_blob)
  File "/usr/lib/python2.6/dist-packages/samba/ndr.py", line 44, in ndr_unpack
    object.__ndr_unpack__(data)
RuntimeError: (11, 'Buffer Size Error')

22.11.2011 09:52:45,159 LDAP        (ERROR  ): Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/univention/s4connector/__init__.py", line 1123, in sync_to_ucs
    f(self, property_type, object)
  File "/usr/lib/pymodules/python2.6/univention/s4connector/s4/password.py", line 554, in password_sync_s4_to_ucs
    krb5Key_new = calculate_krb5key(unicodePwd_attr, supplementalCredentials, int(msDS_KeyVersionNumber))
  File "/usr/lib/pymodules/python2.6/univention/s4connector/s4/password.py", line 67, in calculate_krb5key
    sc = ndr_unpack(drsblobs.supplementalCredentialsBlob, sc_blob)
  File "/usr/lib/python2.6/dist-packages/samba/ndr.py", line 44, in ndr_unpack
    object.__ndr_unpack__(data)
RuntimeError: (11, 'Buffer Size Error')
Comment 1 Kevin Dominik Korte univentionstaff 2011-11-22 10:54:45 CET
ktutil list, krb5 samba4 keys und supplementalCredentials sind an Bug 24780 hinterlegt
Comment 2 Arvid Requate univentionstaff 2012-01-03 17:28:02 CET
*** Bug 24780 has been marked as a duplicate of this bug. ***
Comment 3 Arvid Requate univentionstaff 2012-01-03 17:35:11 CET
Bei den meisten Benutzer-Objekten sind ungültige Daten in supplementalCredentials:

root@master:~# echo "AAAAAAAAAAAAAAAAAA==" | base64 -d | hexdump -ve '/1 "%02X"'
00000000000000000000000000

Hier ist aktuell noch zu klären, ob dies ein von Samba4/AD unterstützter Sonderfall ist, den der S4-Connector unterstützen sollte.
Comment 4 Arvid Requate univentionstaff 2012-01-05 18:56:15 CET
Dieser Bug ist unter sehr spezifischen Umständen aufgetreten, die hier vielleicht klar benannt werden sollten:
Die Benutzerobjekte, die ungültige Daten in supplementalCredentials aufweisen, wurden ursprünglich auf einem UCS 2.4-0 System angelegt und per AD-Connector in ein natives AD 2008R2 synchronisiert. In das native AD ist ein UCS3.0 mit Samba4 gejoined. Dadurch werden die Benutzerobjekte per DRS-Replikation auch in UCS3.0/Samba4 angelegt. Der Traceback tritt anschliessend im S4-Connector auf, der die Daten aus Samba4 ausliest um sie nach OpenLDAP zu schreiben.

Aktuell ist noch unklar, wie die entsprechenden Daten im AD aussahen, d.h. ob AD bei fehlenden krb5Keys die supplementalCredentials mit speziellen Werten setzt, oder ob das ein Artefakt von Samba4 ist.

Im entsprechenden Scope ist eine angepasste Version des S4-Connectors gebaut, die diesen spezifischen Traceback abfängt. Andersartige decoding tracebacks werden dort zusätzlich auch weiterhin protokolliert, der S4-Connector fährt dann aber mit der Replikation des Objekts fort, sodass der Benutzer im UCS3.0 OpenLDAP dann wenigstens genau einen gültigen krb5Key-Wert haben sollte.
Comment 5 Arvid Requate univentionstaff 2012-01-10 18:23:14 CET
Zusätzlich war in diesem Kontext noch ein Patch für samba4 notwendig, da W2k8-DCs in der Kommunikation mit W2k3-DCs in das Attribut supplementalCredentials den NT-Hash als dummy-Wert einträgt. Der Patch 92_allow_missing_des-cbc.patch lockert die Prüffunktion für die übergebenen Passwort-Hashes entsprechend, und behebt damit den folgenden Traceback, der nach UDM-Passwortänderungen im S4-Connector auftrat:

04.01.2012 12:35:22,510 LDAP        (PROCESS): sync from ucs: [          user] 
[    modify] cn=administrator,cn=users,dc=demo2,dc=local
04.01.2012 12:35:22,520 LDAP        (WARNING): sync failed, saved as rejected
04.01.2012 12:35:22,520 LDAP        (WARNING): Traceback (most recent call 
last):
  File "/usr/lib/pymodules/python2.6/univention/s4connector/__init__.py", line 
603, in __sync_file_from_ucs
    or (not old_dn and not self.sync_from_ucs(key, object, premapped_ucs_dn, 
old_dn, old))):
  File "/usr/lib/pymodules/python2.6/univention/s4connector/s4/__init__.py", 
line 1946, in sync_from_ucs
    f(self, property_type, object)
  File "/usr/lib/pymodules/python2.6/univention/s4connector/s4/password.py", 
line 514, in password_sync_ucs_to_s4
    s4connector.lo_s4.lo.modify_ext_s(compatible_modstring(object['dn']), 
modlist, serverctrls=[ ctrl_bypass_password_hash ])
  File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 295, in 
modify_ext_s
    return self.result(msgid,all=1,timeout=self.timeout)
  File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 422, in 
result
    res_type,res_data,res_msgid = self.result2(msgid,all,timeout)
  File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 426, in 
result2
    res_type, res_data, res_msgid, srv_ctrls = self.result3(msgid,all,timeout)
  File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 432, in 
result3
    ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
  File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 96, in 
_ldap_call
    result = func(*args,**kwargs)
CONSTRAINT_VIOLATION: {'info': "0000202F: Constraint violation - 
PrimaryKerberos old_keys type/value_len doesn't match 
at ../source4/dsdb/samdb/ldb_modules/password_hash.c:404", 'desc': 'Constraint 
violation'}

Der Patch ist zur Bewertung upstream geschickt. Ggf. wird dieses Problem ab ucs3.0-1 auch einfach durch den Patch 4.0.0~alpha17~git201110100928-5-ucs3.0-1/91_msDS-Behavior-Version.patch umgangen, der gejointen Samba4-Systeme immer auf Funktionslevel 2008R2 setzt (so wie auch provision macht).
Comment 6 Arvid Requate univentionstaff 2012-01-30 17:57:00 CET
Created attachment 4128 [details]
Patch für univention-s4-connector, der die Probleme an diesem Bug addressiert.

Der Samba4-Patch für Comment 5 ist an Bug 25972.
Comment 7 Arvid Requate univentionstaff 2012-01-31 15:13:26 CET
Dir Änderungen am S4 Connector wurden eingechekt und das Paket ist im Scope ucs3.0-1 neu gebaut. Changelog ist angepasst.
Comment 8 Arvid Requate univentionstaff 2012-02-02 16:43:07 CET
Vermutlcih unkritisch, weil eine python2.5-Fehlermeldung, aber es gibt einen traceback beim Installieren von univention-s4-connector:

Trigger für python-support werden verarbeitet ...
/usr/lib/pymodules/python2.5/univention/s4connector/s4/password.py:114: Warning: 'as' will become a reserved keyword in Python 2.6
Compiling /usr/lib/pymodules/python2.5/univention/s4connector/s4/password.py ...
  File "/usr/lib/pymodules/python2.5/univention/s4connector/s4/password.py", line 114
    except Exception as exc:
                      ^
SyntaxError: invalid syntax
Comment 10 Felix Botner univentionstaff 2012-02-20 12:40:07 CET
OK

Connector gestoppt, über samba-tool einen Benutzer im Samba angelegt (samba5) und dort das Attribut "supplementalCredentials" auf "AAAAAAAAAAAAAAAAAA==" gesetzt. Dann den Connector wieder gestartet. Der Benutzer wurde (bis auf die Kerberos Passwörter) synchronisiert.

Log:
password_sync_s4_to_ucs: sambaPwdLastSet: 1329736083
password_sync_s4_to_ucs: sambaPwdMustChange: 
calculate_krb5key: '(11, 'Buffer Size Error')' while unpacking supplementalCredentials:: AAAAAAAAAAAAAAAAAA== 
calculate_krb5key: the krb5Keys from the PrimaryKerberosBlob could not be parsed. Continuing anyway.
get_ucs_object: object found: uid=samba5,cn=users,dc=as,dc=df
password_sync_s4_to_ucs: sambaPwdLastSet in modlist (replace): 1329736002

-> univention-ldapsearch uid=samba5 dn -LLL
dn: uid=samba5,cn=users,dc=as,dc=df


(In reply to comment #9)
> Gefixed nach
> http://docs.python.org/py3k/howto/pyporting.html#capturing-the-currently-raised-exception

OK

grep "Exception as" /usr/share/pyshared/univention/s4connector/s4/password.py

Changelog Eintrag vorhanden.
Comment 11 Sönke Schwardt-Krummrich univentionstaff 2012-03-04 14:34:09 CET
UCS 3.0-1 wurde veröffentlicht. Sollte der hier beschriebene Bug mit einer
neueren Version von UCS erneut auftreten, so sollte dieser Bug dupliziert
werden: "Clone This Bug"