From 079fdf41592559de96465080e81aa91252c01a3d Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Tue, 19 Aug 2014 16:24:27 +0300 Subject: [PATCH] ipaserver/dcerpc.py: Make sure trust is established only to forest root domain Part of https://fedorahosted.org/freeipa/ticket/4463 Reviewed-By: Sumit Bose --- ipalib/errors.py | 16 ++++++++++++++++ ipaserver/dcerpc.py | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/ipalib/errors.py b/ipalib/errors.py index 716decb2b41baf5470a1dc23c0cfb5d1c995e5ff..405c5c3bfc25d9b024189be9fcf582052dd10dd3 100644 --- a/ipalib/errors.py +++ b/ipalib/errors.py @@ -810,6 +810,22 @@ class DeprecationError(InvocationError): errno = 3015 format = _("Command '%(name)s' has been deprecated") +class NotAForestRootError(InvocationError): + """ + **3016** Raised when an attempt to establish trust is done against non-root domain + Forest root domain has the same name as the forest itself + + For example: + + >>> raise NotAForestRootError(forest='example.test', domain='jointops.test') + Traceback (most recent call last): + ... + NotAForestRootError: Domain 'jointops.test' is not a root domain for forest 'example.test' + """ + + errno = 3016 + format = _("Domain '%(domain)s' is not a root domain for forest '%(forest)s'") + ############################################################################## # 4000 - 4999: Execution errors diff --git a/ipaserver/dcerpc.py b/ipaserver/dcerpc.py index fcf1e4e775868f17220cac3c0203cc67dba2f839..41f373df3cc4365727200f3ca4667faac2f9e19c 100644 --- a/ipaserver/dcerpc.py +++ b/ipaserver/dcerpc.py @@ -1143,6 +1143,9 @@ class TrustDomainJoins(object): realm_passwd ) + if self.remote_domain.info['dns_domain'] != self.remote_domain.info['dns_forest']: + raise errors.NotAForestRootError(forest=self.remote_domain.info['dns_forest'], domain=self.remote_domain.info['dns_domain']) + if not self.remote_domain.read_only: trustdom_pass = samba.generate_random_password(128, 128) self.get_realmdomains() @@ -1159,5 +1162,8 @@ class TrustDomainJoins(object): if not(isinstance(self.remote_domain, TrustDomainInstance)): self.populate_remote_domain(realm, realm_server, realm_passwd=None) + if self.remote_domain.info['dns_domain'] != self.remote_domain.info['dns_forest']: + raise errors.NotAForestRootError(forest=self.remote_domain.info['dns_forest'], domain=self.remote_domain.info['dns_domain']) + self.local_domain.establish_trust(self.remote_domain, trustdom_passwd) return dict(local=self.local_domain, remote=self.remote_domain, verified=False) -- 1.9.3