From eae8df718fec43a839aab6be0ad3131692b72eca Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Tue, 24 Mar 2020 12:14:57 +0100 Subject: [PATCH] check krb_principal before it is rewritten --- hub/kojihub.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hub/kojihub.py b/hub/kojihub.py index 6bf98e93..fa13a4a0 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -12175,10 +12175,6 @@ class RootExports(object): raise koji.GenericError('host already exists: %s' % hostname) q = """SELECT id FROM channels WHERE name = 'default'""" default_channel = _singleValue(q) - if krb_principal is None: - fmt = context.opts.get('HostPrincipalFormat') - if fmt: - krb_principal = fmt % hostname # builder user can already exist, if host tried to log in before adding into db userinfo = {'name': hostname} if krb_principal: @@ -12198,6 +12194,10 @@ class RootExports(object): 'user %s already exists and it is not a host' % hostname) userID = user['id'] else: + if krb_principal is None: + fmt = context.opts.get('HostPrincipalFormat') + if fmt: + krb_principal = fmt % hostname userID = context.session.createUser(hostname, usertype=koji.USERTYPES['HOST'], krb_principal=krb_principal) # host entry