diff options
author | Petr Viktorin <pviktori@redhat.com> | 2012-05-23 05:44:53 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-06-06 21:57:12 -0400 |
commit | f8e7b516d923142a23058cb23ee817522686cfe3 (patch) | |
tree | 9987a2ea8abd8579c4852ad813d00861351e54bf /ipalib/errors.py | |
parent | cf72738b214d115bb930f4e323512fd57a426a63 (diff) | |
download | freeipa-f8e7b516d923142a23058cb23ee817522686cfe3.tar.gz freeipa-f8e7b516d923142a23058cb23ee817522686cfe3.tar.xz freeipa-f8e7b516d923142a23058cb23ee817522686cfe3.zip |
Prevent deletion of the last admin
Raise an error when trying to delete the last user in the
'admins' group, or remove the last member from the group,
or delete the group itself.
https://fedorahosted.org/freeipa/ticket/2564
Diffstat (limited to 'ipalib/errors.py')
-rw-r--r-- | ipalib/errors.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py index df4ab4167..407d9f7db 100644 --- a/ipalib/errors.py +++ b/ipalib/errors.py @@ -1575,6 +1575,38 @@ class DependentEntry(ExecutionError): format = _('%(key)s cannot be deleted because %(label)s %(dependent)s requires it') +class LastMemberError(ExecutionError): + """ + **4308** Raised when an entry being deleted is last member of a protected group + + For example: + >>> raise LastMemberError(key=u'admin', label=u'group', container=u'admins') + Traceback (most recent call last): + ... + LastMemberError: admin cannot be deleted because it is the last member of group admins + + """ + + errno = 4308 + format = _('%(key)s cannot be deleted because it is the last member of %(label)s %(container)s') + + +class ProtectedEntryError(ExecutionError): + """ + **4309** Raised when an entry being deleted is protected + + For example: + >>> raise ProtectedEntryError(label=u'group', key=u'admins', reason=u'privileged group') + Traceback (most recent call last): + ... + ProtectedEntryError: group admins cannot be deleted: privileged group + + """ + + errno = 4309 + format = _('%(label)s %(key)s cannot be deleted: %(reason)s') + + ############################################################################## # 5000 - 5999: Generic errors |