pgreco / rpms / ipa

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

Blame SOURCES/0030-idviews-Check-for-the-Default-Trust-View-only-if-app.patch

590d18
From f12e0e81f1cc6af2034c535866c3bfeddce8321d Mon Sep 17 00:00:00 2001
590d18
From: Tomas Babej <tbabej@redhat.com>
590d18
Date: Tue, 21 Jul 2015 12:44:37 +0200
590d18
Subject: [PATCH] idviews: Check for the Default Trust View only if applying
590d18
 the view
590d18
590d18
Currently, the code wrongly validates the idview-unapply command. Move
590d18
check for the forbidden application of the Default Trust View into
590d18
the correct logical branch.
590d18
590d18
https://fedorahosted.org/freeipa/ticket/4969
590d18
590d18
Reviewed-By: Martin Basti <mbasti@redhat.com>
590d18
---
590d18
 ipalib/plugins/idviews.py | 14 ++++++++------
590d18
 1 file changed, 8 insertions(+), 6 deletions(-)
590d18
590d18
diff --git a/ipalib/plugins/idviews.py b/ipalib/plugins/idviews.py
590d18
index 2e6e84510d3caa3636d3f0c08c56403866ff54f9..ceb277020d1325bfd1607bcd4b05f4069ae9508d 100644
590d18
--- a/ipalib/plugins/idviews.py
590d18
+++ b/ipalib/plugins/idviews.py
590d18
@@ -256,17 +256,19 @@ class baseidview_apply(LDAPQuery):
590d18
         if not options.get('clear_view', False):
590d18
             view_dn = self.api.Object['idview'].get_dn_if_exists(view)
590d18
             assert isinstance(view_dn, DN)
590d18
+
590d18
+            # Check that we're not applying the Default Trust View
590d18
+            if view.lower() == DEFAULT_TRUST_VIEW_NAME:
590d18
+                raise errors.ValidationError(
590d18
+                    name=_('ID View'),
590d18
+                    error=_('Default Trust View cannot be applied on hosts')
590d18
+                )
590d18
+
590d18
         else:
590d18
             # In case we are removing assigned view, we modify the host setting
590d18
             # the ipaAssignedIDView to None
590d18
             view_dn = None
590d18
 
590d18
-        if view.lower() == DEFAULT_TRUST_VIEW_NAME:
590d18
-            raise errors.ValidationError(
590d18
-                name=_('ID View'),
590d18
-                error=_('Default Trust View cannot be applied on hosts')
590d18
-            )
590d18
-
590d18
         completed = 0
590d18
         succeeded = {'host': []}
590d18
         failed = {
590d18
-- 
590d18
2.4.3
590d18