diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-10-05 16:18:16 +0200 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2011-10-06 05:30:52 -0400 |
commit | 92dbd68677b3166ebb8897c5fac7d6a142226ac1 (patch) | |
tree | 8e5de7d62526c5ca8a3d57da07b344190b0263ce /ipalib/plugins/hostgroup.py | |
parent | 60bacc23a0989c7f9c060d8c209ba4396546ec89 (diff) | |
download | freeipa-92dbd68677b3166ebb8897c5fac7d6a142226ac1.tar.gz freeipa-92dbd68677b3166ebb8897c5fac7d6a142226ac1.tar.xz freeipa-92dbd68677b3166ebb8897c5fac7d6a142226ac1.zip |
Prevent collisions of hostgroup and netgroup
For every hostgroup a managed netgroup is created (if this is allowed).
Make sure that if a stand-alone netgroup exists, a hostgroup with the
same name cannot be created to prevent collisions.
https://fedorahosted.org/freeipa/ticket/1914
Diffstat (limited to 'ipalib/plugins/hostgroup.py')
-rw-r--r-- | ipalib/plugins/hostgroup.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py index 0d69d093e..0560bd7d2 100644 --- a/ipalib/plugins/hostgroup.py +++ b/ipalib/plugins/hostgroup.py @@ -115,6 +115,17 @@ class hostgroup_add(LDAPCreate): msg_summary = _('Added hostgroup "%(value)s"') + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): + try: + netgroup = api.Command['netgroup_show'](keys[-1]) + raise errors.DuplicateEntry(message=unicode(_(\ + u'netgroup with name "%s" already exists' % keys[-1]\ + ))) + except errors.NotFound: + pass + + return dn + def post_callback(self, ldap, dn, entry_attrs, *keys, **options): # Always wait for the associated netgroup to be created so we can # be sure to ignore it in memberOf |