URL: https://github.com/freeipa/freeipa/pull/5896 Author: rcritten Title: #5896: [Backport][ipa-4-9] Fall back to krbprincipalname when validating host auth indicators Action: opened
PR body: """ This PR was opened automatically because PR #5889 was pushed to master and backport to ipa-4-9 is required. """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/5896/head:pr5896 git checkout pr5896
From 29cb370646886e1a60d5a7774df1c2b81ebe6327 Mon Sep 17 00:00:00 2001 From: Rob Crittenden <[email protected]> Date: Mon, 12 Jul 2021 11:02:10 -0400 Subject: [PATCH] Fall back to krbprincipalname when validating host auth indicators When adding a new host the principal cannot be determined because it relies on either: a) an entry to already exist b) krbprincipalname be a component of the dn As a result the full dn is being passed into ipapython.Kerberos which can't parse it. Look into the entry in validate_validate_auth_indicator() for krbprincipalname in this case. https://pagure.io/freeipa/issue/8206 Signed-off-by: Rob Crittenden <[email protected]> --- ipaserver/plugins/service.py | 5 +++++ ipatests/test_xmlrpc/test_host_plugin.py | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/ipaserver/plugins/service.py b/ipaserver/plugins/service.py index cfbbff3c69c..498f5e44436 100644 --- a/ipaserver/plugins/service.py +++ b/ipaserver/plugins/service.py @@ -209,6 +209,11 @@ def validate_auth_indicator(entry): # and shouldn't be allowed to have auth indicators. # https://pagure.io/freeipa/issue/8206 pkey = api.Object['service'].get_primary_key_from_dn(entry.dn) + if pkey == str(entry.dn): + # krbcanonicalname may not be set yet if this is a host entry, + # try krbprincipalname + if 'krbprincipalname' in entry: + pkey = entry['krbprincipalname'] principal = kerberos.Principal(pkey) server = api.Command.server_find(principal.hostname)['result'] if server: diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py index 9cfde3565d4..ff50e796cd1 100644 --- a/ipatests/test_xmlrpc/test_host_plugin.py +++ b/ipatests/test_xmlrpc/test_host_plugin.py @@ -615,6 +615,17 @@ def test_try_add_auth_ind_master(self, this_host): )): command() + def test_add_non_master_with_auth_ind(self, host5): + host5.ensure_missing() + command = host5.make_command( + 'host_add', host5.fqdn, krbprincipalauthind=['radius'], + force=True + ) + result = command() + # The fact that the command succeeds exercises the change but + # let's check the indicator as well. + assert result['result']['krbprincipalauthind'] == ('radius',) + @pytest.mark.tier1 class TestValidation(XMLRPC_test):
_______________________________________________ FreeIPA-devel mailing list -- [email protected] To unsubscribe send an email to [email protected] Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/[email protected] Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
