Fix #798

Pavel
>From a013e19957b33ca84102efdc0be7448eb3a83423 Mon Sep 17 00:00:00 2001
From: Pavel Zuna <pz...@redhat.com>
Date: Tue, 18 Jan 2011 15:43:07 -0500
Subject: [PATCH 2/2] Fix password/random logic in host plugin.

Fix #798
---
 ipalib/plugins/host.py |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index 0a40705..6947d90 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()
-- 
1.7.1.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to