From: Volker Lendecke Date: Mon, 5 Aug 2024 15:28:02 +0000 (+0200) Subject: libsmb: Swap if/else branches in remote_password_change X-Git-Tag: tdb-1.4.13~1373 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d33f9935fd33a0e0691876b5d939f1aba0c22db;p=thirdparty%2Fsamba.git libsmb: Swap if/else branches in remote_password_change bail out with an early return next Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c index 0d6a70f32a3..c3ab30849ab 100644 --- a/source3/libsmb/passchange.c +++ b/source3/libsmb/passchange.c @@ -301,7 +301,16 @@ NTSTATUS remote_password_change(const char *remote_machine, /* We have failed to change the user's password, and we think the server just might not support SAMR password changes, so fall back */ - if (lp_client_lanman_auth()) { + if (!lp_client_lanman_auth()) { + if (asprintf(err_str, "SAMR connection to machine %s " + "failed. Error was %s, but LANMAN password " + "changes are disabled\n", + remote_machine, nt_errstr(result)) == -1) { + *err_str = NULL; + } + cli_shutdown(cli); + return NT_STATUS_UNSUCCESSFUL; + } else { /* Use the old RAP method. */ if (cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) { /* SAMR failed, but the old LanMan protocol worked! */ @@ -318,15 +327,6 @@ NTSTATUS remote_password_change(const char *remote_machine, } cli_shutdown(cli); return result; - } else { - if (asprintf(err_str, "SAMR connection to machine %s " - "failed. Error was %s, but LANMAN password " - "changes are disabled\n", - remote_machine, nt_errstr(result)) == -1) { - *err_str = NULL; - } - cli_shutdown(cli); - return NT_STATUS_UNSUCCESSFUL; } } }