From 5f4ac74563266a6bf900c36c01d17a6e4226da94 Mon Sep 17 00:00:00 2001 From: Pavel Zuna Date: Tue, 18 Jan 2011 15:43:07 -0500 Subject: Fix password/random logic in host plugin. Fix #798 --- ipalib/plugins/host.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'ipalib/plugins') diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index 0a407058..6947d907 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -319,16 +319,19 @@ class host_add(LDAPCreate): del entry_attrs['locality'] entry_attrs['cn'] = keys[-1] entry_attrs['serverhostname'] = keys[-1].split('.', 1)[0] - if 'userpassword' not in entry_attrs and \ - options.get('random', False) == False: + if 'userpassword' not in entry_attrs and not options.get('random', False): entry_attrs['krbprincipalname'] = 'host/%s@%s' % ( keys[-1], self.api.env.realm ) - if 'krbprincipalaux' not in entry_attrs['objectclass']: - entry_attrs['objectclass'].append('krbprincipalaux') + if 'krbprincipal' not in entry_attrs: entry_attrs['objectclass'].append('krbprincipal') - elif 'krbprincipalaux' in entry_attrs['objectclass']: - entry_attrs['objectclass'].remove('krbprincipalaux') + if 'krbprincipal' not in entry_attrs: + entry_attrs['objectclass'].append('krbprincipalaux') + else: + if 'krbprincipal' in entry_attrs['objectclass']: + entry_attrs['objectclass'].remove('krbprincipal') + if 'krbprincipalaux' in entry_attrs['objectclass']: + entry_attrs['objectclass'].remove('krbprincipalaux') if 'random' in options: if options.get('random'): entry_attrs['userpassword'] = ipa_generate_password() -- cgit