]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Swap if/else branches in remote_password_change
authorVolker Lendecke <vl@samba.org>
Mon, 5 Aug 2024 15:28:02 +0000 (17:28 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 20 Aug 2024 09:34:39 +0000 (09:34 +0000)
bail out with an early return next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/passchange.c

index 0d6a70f32a3c9a50ab11e3789010dea621b64726..c3ab30849ab8634956f553eb378cf61fb456dc6a 100644 (file)
@@ -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;
                }
        }
 }