Skip to content

Commit

Permalink
Merge pull request #1376 from hahnjo/krb5-error-unlock
Browse files Browse the repository at this point in the history
krb5: Release lock if initialization fails
  • Loading branch information
abh3 committed Jan 13, 2021
2 parents 3b49067 + 4eba83f commit 2e6dc36
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/XrdSeckrb5/XrdSecProtocolkrb5.cc
Expand Up @@ -247,7 +247,8 @@ XrdSecCredentials *XrdSecProtocolkrb5::getCredentials(XrdSecParameters *noparm,
// Initialize the context and get the cache default.
//
if ((rc = krb5_init_context(&krb_client_context)))
{Fatal(error, ENOPROTOOPT, "Kerberos initialization failed", Service, rc);
{krbClientContext.UnLock();
Fatal(error, ENOPROTOOPT, "Kerberos initialization failed", Service, rc);
return (XrdSecCredentials *)0;
}

Expand All @@ -256,7 +257,8 @@ XrdSecCredentials *XrdSecProtocolkrb5::getCredentials(XrdSecParameters *noparm,
// Set the name of the default credentials cache for the Kerberos context
//
if ((rc = krb5_cc_set_default_name(krb_client_context, kccn)))
{Fatal(error, ENOPROTOOPT, "Kerberos default credentials cache setting failed", Service, rc);
{krbClientContext.UnLock();
Fatal(error, ENOPROTOOPT, "Kerberos default credentials cache setting failed", Service, rc);
return (XrdSecCredentials *)0;
}

Expand All @@ -265,7 +267,8 @@ XrdSecCredentials *XrdSecProtocolkrb5::getCredentials(XrdSecParameters *noparm,
// Obtain the default cache location
//
if ((rc = krb5_cc_default(krb_client_context, &krb_client_ccache)))
{Fatal(error, ENOPROTOOPT, "Unable to locate cred cache", Service, rc);
{krbClientContext.UnLock();
Fatal(error, ENOPROTOOPT, "Unable to locate cred cache", Service, rc);
return (XrdSecCredentials *)0;
}

Expand Down

0 comments on commit 2e6dc36

Please sign in to comment.