[PATCH] Small code cleanup in credentials code

Andreas Schneider asn at samba.org
Wed Jan 3 08:07:08 UTC 2018


Hi,

attached is a code cleanup for the credentials code.

Please review and push if OK.


Thanks,


	Andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org
-------------- next part --------------
>From 1a7411a12a482fc3dc6cd99739b131056014f855 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Tue, 13 Dec 2016 11:38:13 +0100
Subject: [PATCH] credentials: Simplify cli_credentials_get_server_gss_creds()

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 auth/credentials/credentials_krb5.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/auth/credentials/credentials_krb5.c b/auth/credentials/credentials_krb5.c
index b88497dcace..95bb77d8490 100644
--- a/auth/credentials/credentials_krb5.c
+++ b/auth/credentials/credentials_krb5.c
@@ -1151,16 +1151,14 @@ _PUBLIC_ int cli_credentials_get_server_gss_creds(struct cli_credentials *cred,
 	}
 
 	if (ktc->password_based || obtained < CRED_SPECIFIED) {
-		/* This creates a GSSAPI cred_id_t for match-by-key with only the keytab set */
-		maj_stat = smb_gss_krb5_import_cred(&min_stat, smb_krb5_context->krb5_context,
-						    NULL, NULL, ktc->keytab,
-						    &gcc->creds);
-	} else {
-		/* This creates a GSSAPI cred_id_t with the principal and keytab set, matching by name */
-		maj_stat = smb_gss_krb5_import_cred(&min_stat, smb_krb5_context->krb5_context,
-						    NULL, princ, ktc->keytab,
-						    &gcc->creds);
+		/*
+		 * This creates a GSSAPI cred_id_t for match-by-key with only
+		 * the keytab set
+		 */
+		princ = NULL;
 	}
+	maj_stat = gss_krb5_import_cred(&min_stat, NULL, princ, ktc->keytab,
+					&gcc->creds);
 	if (maj_stat) {
 		if (min_stat) {
 			ret = min_stat;
-- 
2.15.1



More information about the samba-technical mailing list