1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

auth3: Simplify auth_check_ntlm_password logic with a "goto fail"

No intended code change, just reformatting and a goto fail with
inverted logic

Best viewed with "git show -b" :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke
2017-02-11 11:38:56 +01:00
committed by Jeremy Allison
parent 56b0303a61
commit 66f94e557e

View File

@ -257,7 +257,10 @@ NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx,
/* successful authentication */ /* successful authentication */
if (NT_STATUS_IS_OK(nt_status)) { if (!NT_STATUS_IS_OK(nt_status)) {
goto fail;
}
unix_username = server_info->unix_name; unix_username = server_info->unix_name;
/* We skip doing this step if the caller asked us not to */ /* We skip doing this step if the caller asked us not to */
@ -266,8 +269,8 @@ NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx,
const char *rhost; const char *rhost;
if (tsocket_address_is_inet(user_info->remote_host, "ip")) { if (tsocket_address_is_inet(user_info->remote_host, "ip")) {
rhost = tsocket_address_inet_addr_string(user_info->remote_host, rhost = tsocket_address_inet_addr_string(
talloc_tos()); user_info->remote_host, talloc_tos());
if (rhost == NULL) { if (rhost == NULL) {
nt_status = NT_STATUS_NO_MEMORY; nt_status = NT_STATUS_NO_MEMORY;
goto fail; goto fail;
@ -278,22 +281,23 @@ NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx,
/* We might not be root if we are an RPC call */ /* We might not be root if we are an RPC call */
become_root(); become_root();
nt_status = smb_pam_accountcheck(unix_username, nt_status = smb_pam_accountcheck(unix_username, rhost);
rhost);
unbecome_root(); unbecome_root();
if (NT_STATUS_IS_OK(nt_status)) { if (NT_STATUS_IS_OK(nt_status)) {
DEBUG(5, ("check_ntlm_password: PAM Account for user [%s] succeeded\n", DEBUG(5, ("check_ntlm_password: PAM Account for user [%s] "
unix_username)); "succeeded\n", unix_username));
} else { } else {
DEBUG(3, ("check_ntlm_password: PAM Account for user [%s] FAILED with error %s\n", DEBUG(3, ("check_ntlm_password: PAM Account for user [%s] "
"FAILED with error %s\n",
unix_username, nt_errstr(nt_status))); unix_username, nt_errstr(nt_status)));
} }
} }
if (NT_STATUS_IS_OK(nt_status)) { if (NT_STATUS_IS_OK(nt_status)) {
DEBUG(server_info->guest ? 5 : 2, DEBUG(server_info->guest ? 5 : 2,
("check_ntlm_password: %sauthentication for user [%s] -> [%s] -> [%s] succeeded\n", ("check_ntlm_password: %sauthentication for user "
"[%s] -> [%s] -> [%s] succeeded\n",
server_info->guest ? "guest " : "", server_info->guest ? "guest " : "",
user_info->client.account_name, user_info->client.account_name,
user_info->mapped.account_name, user_info->mapped.account_name,
@ -304,7 +308,6 @@ NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx,
TALLOC_FREE(frame); TALLOC_FREE(frame);
return nt_status; return nt_status;
}
fail: fail: