summaryrefslogtreecommitdiffstats
path: root/ipalib/krb_utils.py
diff options
context:
space:
mode:
authorMichael Simacek <msimacek@redhat.com>2015-08-31 14:04:33 +0200
committerJan Cholasta <jcholast@redhat.com>2015-09-22 13:29:55 +0200
commitbdccebbcdb9eb7da476762743121c1e73f95fa10 (patch)
tree38108d6426dfc4dee960b9dba055dc49a1ae38f1 /ipalib/krb_utils.py
parentcfeea91828ad47e1d321947d04f5f6de0e3d1c8c (diff)
downloadfreeipa-bdccebbcdb9eb7da476762743121c1e73f95fa10.tar.gz
freeipa-bdccebbcdb9eb7da476762743121c1e73f95fa10.tar.xz
freeipa-bdccebbcdb9eb7da476762743121c1e73f95fa10.zip
Rewrap errors in get_principal to CCacheError
Causes nicer error message when kerberos credentials are not available. https://fedorahosted.org/freeipa/ticket/5272 Reviewed-By: David Kupka <dkupka@redhat.com> Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipalib/krb_utils.py')
-rw-r--r--ipalib/krb_utils.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/ipalib/krb_utils.py b/ipalib/krb_utils.py
index a1a96a8c2..0c4340c3f 100644
--- a/ipalib/krb_utils.py
+++ b/ipalib/krb_utils.py
@@ -173,9 +173,15 @@ def get_principal(ccache_name=None):
default
:returns:
Default principal name as string
+ :raises:
+ errors.CCacheError if the principal cannot be retrieved from given
+ ccache
'''
- creds = get_credentials(ccache_name=ccache_name)
- return unicode(creds.name)
+ try:
+ creds = get_credentials(ccache_name=ccache_name)
+ return unicode(creds.name)
+ except gssapi.exceptions.GSSError as e:
+ raise errors.CCacheError(message=unicode(e))
def get_credentials_if_valid(name=None, ccache_name=None):
'''