pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0077-trust-always-use-oddjobd-helper-for-fetching-trust-i.patch

483b06
From 3353a259bb8ace57efcfd784f2a0c0c6884d9966 Mon Sep 17 00:00:00 2001
483b06
From: Alexander Bokovoy <abokovoy@redhat.com>
483b06
Date: Wed, 5 Apr 2017 12:37:10 +0300
483b06
Subject: [PATCH] trust: always use oddjobd helper for fetching trust
483b06
 information
483b06
483b06
Since introduction of privilege separation in IPA framework none of the
483b06
operations that require direct access to the framework's credentials can
483b06
be done. All authentication has to be performed with GSSAPI.
483b06
483b06
As result, we cannot obtain TGT for HTTP/.. principal with kinit
483b06
anymore, so it is better to re-route all types of trust to oddjobd
483b06
helper and get rid of casing out two-way trust.
483b06
483b06
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1438366
483b06
483b06
Reviewed-By: Martin Basti <mbasti@redhat.com>
483b06
---
483b06
 ipaserver/plugins/trust.py | 43 ++++++++++---------------------------------
483b06
 1 file changed, 10 insertions(+), 33 deletions(-)
483b06
483b06
diff --git a/ipaserver/plugins/trust.py b/ipaserver/plugins/trust.py
483b06
index 3de2458466214044f6b1b5d8560a2a7ac53ede57..0829f8c714f15c4384a89e18ba29e417405c249c 100644
483b06
--- a/ipaserver/plugins/trust.py
483b06
+++ b/ipaserver/plugins/trust.py
483b06
@@ -1742,47 +1742,24 @@ class trust_fetch_domains(LDAPRetrieve):
483b06
         ldap = self.api.Backend.ldap2
483b06
         verify_samba_component_presence(ldap, self.api)
483b06
 
483b06
-        trust = self.api.Command.trust_show(
483b06
-            keys[0], all=True, raw=True)['result']
483b06
+        # Check first that the trust actually exists
483b06
+        result = self.api.Command.trust_show(keys[0], all=True, raw=True)
483b06
+        self.obj.warning_if_ad_trust_dom_have_missing_SID(result, **options)
483b06
 
483b06
         result = dict()
483b06
         result['result'] = []
483b06
         result['count'] = 0
483b06
         result['truncated'] = False
483b06
 
483b06
-        trust_direction = int(trust['ipanttrustdirection'][0])
483b06
-        is_nontransitive = int(trust.get('ipanttrustattributes',
483b06
-                               [0])[0]) & LSA_TRUST_ATTRIBUTE_NON_TRANSITIVE
483b06
         # For one-way trust and external trust fetch over DBus.
483b06
         # We don't get the list in this case.
483b06
-        if trust_direction != TRUST_BIDIRECTIONAL or is_nontransitive:
483b06
-            fetch_trusted_domains_over_dbus(self.api, self.log, keys[0])
483b06
-            result['summary'] = unicode(_('List of trust domains successfully refreshed. Use trustdomain-find command to list them.'))
483b06
-            return result
483b06
-
483b06
-        trustinstance = ipaserver.dcerpc.TrustDomainJoins(self.api)
483b06
-        if not trustinstance.configured:
483b06
-            raise errors.NotFound(
483b06
-                name=_('AD Trust setup'),
483b06
-                reason=_(
483b06
-                    'Cannot perform join operation without own domain '
483b06
-                    'configured. Make sure you have run ipa-adtrust-install '
483b06
-                    'on the IPA server first'
483b06
-                )
483b06
-            )
483b06
-
483b06
-        trustinstance.populate_remote_domain(keys[0])
483b06
-
483b06
-        res = fetch_domains_from_trust(self.api, trustinstance, **options)
483b06
-        domains = add_new_domains_from_trust(self.api, trustinstance, trust, res, **options)
483b06
-
483b06
-        if len(domains) > 0:
483b06
-            result['summary'] = unicode(_('List of trust domains successfully refreshed'))
483b06
-        else:
483b06
-            result['summary'] = unicode(_('No new trust domains were found'))
483b06
-
483b06
-        result['result'] = domains
483b06
-        result['count'] = len(domains)
483b06
+        # With privilege separation we also cannot authenticate as
483b06
+        # HTTP/ principal because we have no access to its key material.
483b06
+        # Thus, we'll use DBus call out to oddjobd helper in all cases
483b06
+        fetch_trusted_domains_over_dbus(self.api, self.log, keys[0])
483b06
+        result['summary'] = unicode(_('List of trust domains successfully '
483b06
+                                      'refreshed. Use trustdomain-find '
483b06
+                                      'command to list them.'))
483b06
         return result
483b06
 
483b06
 
483b06
-- 
483b06
2.9.3
483b06