Skip to content

Commit

Permalink
Fix a bug which prevented the client from retrieving a credential
Browse files Browse the repository at this point in the history
from the credentials cache.  This now looks for the credential in
the specified keytab file, and then try the credentials cache.
  • Loading branch information
hrs-allbsd committed Jan 15, 2020
1 parent 2dc1a67 commit 74faca7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions plugins/gssapi.c
Expand Up @@ -1777,7 +1777,17 @@ static int gssapi_client_mech_step(void *conn_context,
req_flags = req_flags | GSS_C_DELEG_FLAG;
}

/* If caller didn't provide creds already */
/*
* If caller didn't provide creds already.
*
* In the case of Kerberos, a client typically wants to use
* a credential in either a keytab file or the credentials cache
* of the current process context. This code path will try to
* find a credential in the specified keytab file, then the
* credentials cache. The keytab file can be specified by
* "keytab" option, and it is configured by using
* gsskrb5_register_acceptor_identity() API when available.
*/
if (client_creds == GSS_C_NO_CREDENTIAL) {
GSS_LOCK_MUTEX_CTX(params->utils, text);
maj_stat = gss_acquire_cred(&min_stat,
Expand All @@ -1790,14 +1800,16 @@ static int gssapi_client_mech_step(void *conn_context,
NULL);
GSS_UNLOCK_MUTEX_CTX(params->utils, text);

if (GSS_ERROR(maj_stat)) {
sasl_gss_seterror(text->utils, maj_stat, min_stat);
sasl_gss_free_context_contents(text);
return SASL_FAIL;
/*
* Ignore the error intentionally. The credential was
* not found in the specified keytab file.
*/
if (GSS_ERROR(maj_stat) == 0) {
client_creds = text->client_creds;
}
client_creds = text->client_creds;
}

/* Try the credentials cache. */
GSS_LOCK_MUTEX_CTX(params->utils, text);
maj_stat = gss_init_sec_context(&min_stat,
client_creds, /* GSS_C_NO_CREDENTIAL */
Expand Down

0 comments on commit 74faca7

Please sign in to comment.