URL: https://github.com/freeipa/freeipa/pull/595
Author: martbab
 Title: #595: idviews: correctly handle modification of non-existent view
Action: opened

PR body:
"""
the pre-callback in `idview-mod` did not correctly handle non-existent
object during objectclass check. It will now correctly report that the
object was not found instead on generic 'no such entry'.

https://pagure.io/freeipa/issue/6372
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/595/head:pr595
git checkout pr595
From b2984edf27f744fca75c51e804a686d596c505ab Mon Sep 17 00:00:00 2001
From: Martin Babinsky <mbabi...@redhat.com>
Date: Wed, 15 Mar 2017 08:18:39 +0100
Subject: [PATCH] idviews: correctly handle modification of non-existent view

the pre-callback in `idview-mod` did not correctly handle non-existent
object during objectclass check. It will now correctly report that the
object was not found instead on generic 'no such entry'.

https://pagure.io/freeipa/issue/6372
---
 ipaserver/plugins/idviews.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/ipaserver/plugins/idviews.py b/ipaserver/plugins/idviews.py
index 7320432..6d4ac75 100644
--- a/ipaserver/plugins/idviews.py
+++ b/ipaserver/plugins/idviews.py
@@ -145,8 +145,11 @@ class idview(LDAPObject):
         },
     }
 
-    def ensure_possible_objectclasses(self, ldap, dn, entry_attrs):
-        orig_entry_attrs = ldap.get_entry(dn, ['objectclass'])
+    def ensure_possible_objectclasses(self, ldap, dn, entry_attrs, *keys):
+        try:
+            orig_entry_attrs = ldap.get_entry(dn, ['objectclass'])
+        except errors.NotFound:
+            self.handle_not_found(*keys)
 
         orig_objectclasses = {
             o.lower() for o in orig_entry_attrs.get('objectclass', [])}
@@ -193,7 +196,7 @@ def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
                 raise protected_default_trust_view_error
 
         self.api.Object.config.validate_domain_resolution_order(entry_attrs)
-        self.obj.ensure_possible_objectclasses(ldap, dn, entry_attrs)
+        self.obj.ensure_possible_objectclasses(ldap, dn, entry_attrs, *keys)
 
         return dn
 
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to