Index: debian/changelog =================================================================== --- debian/changelog (Revision 78614) +++ debian/changelog (Arbeitskopie) @@ -1,3 +1,10 @@ +univention-ad-connector (11.0.6-8) UNRELEASED; urgency=medium + + * Bug #44518: Generate a strong password which fulfill the password + complexity settings (Backport of Bug #34478) + + -- Arvid Requate Thu, 04 May 2017 14:10:53 +0200 + univention-ad-connector (11.0.6-7) unstable; urgency=low * Bug #43470: Handle UCRV */autostart through systemd Index: modules/univention/connector/__init__.py =================================================================== --- modules/univention/connector/__init__.py (Revision 78614) +++ modules/univention/connector/__init__.py (Arbeitskopie) @@ -75,11 +75,28 @@ return mlValue +password_charsets = [ + 'abcdefghijklmnopqrstuvwxyz', + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + '0123456789', + '^!\$%&/()=?{[]}+~#-_.:,;<>|\\', +] + + +def generate_strong_password(length=24): + pwd = [] + charset = random.choice(password_charsets) + while len(pwd) < length: + pwd.append(random.choice(charset)) + charset = random.choice(list(set(password_charsets) - set([charset]))) + return "".join(pwd) + + def set_ucs_passwd_user(connector, key, ucs_object): ''' set random password to fulfill required values ''' - ucs_object['password'] = str(int(random.random() * 100000000)) * 20 # at least 20 characters + ucs_object['password'] = generate_strong_password() def check_ucs_lastname_user(connector, key, ucs_object):