From ad7628b2cb254d9b25ee70f86edfeb725e809b01 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 21 Apr 2021 11:30:20 +0200 Subject: [PATCH] gensec: Slightly simplify gensec_generate_session_info_pac() Reduce indentation by an early error return and by introducing a helper variable. Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- auth/gensec/gensec_util.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/auth/gensec/gensec_util.c b/auth/gensec/gensec_util.c index e185acc0c20..e411751c3af 100644 --- a/auth/gensec/gensec_util.c +++ b/auth/gensec/gensec_util.c @@ -38,6 +38,8 @@ NTSTATUS gensec_generate_session_info_pac(TALLOC_CTX *mem_ctx, struct auth_session_info **session_info) { uint32_t session_info_flags = 0; + struct auth4_context *auth_context = NULL; + NTSTATUS status; if (gensec_security->want_features & GENSEC_FEATURE_UNIX_TOKEN) { session_info_flags |= AUTH_SESSION_INFO_UNIX_TOKEN; @@ -55,19 +57,25 @@ NTSTATUS gensec_generate_session_info_pac(TALLOC_CTX *mem_ctx, "user lookup\n", principal_string); } - if (gensec_security->auth_context && gensec_security->auth_context->generate_session_info_pac) { - return gensec_security->auth_context->generate_session_info_pac(gensec_security->auth_context, - mem_ctx, - smb_krb5_context, - pac_blob, - principal_string, - remote_address, - session_info_flags, - session_info); - } else { - DEBUG(0, ("Cannot generate a session_info without the auth_context\n")); + auth_context = gensec_security->auth_context; + + if ((auth_context == NULL) || + (auth_context->generate_session_info_pac == NULL)) { + DBG_ERR("Cannot generate a session_info without " + "the auth_context\n"); return NT_STATUS_INTERNAL_ERROR; } + + status = auth_context->generate_session_info_pac( + auth_context, + mem_ctx, + smb_krb5_context, + pac_blob, + principal_string, + remote_address, + session_info_flags, + session_info); + return status; } /*