]> git.lizzy.rs Git - minetest.git/commitdiff
Fix password changing getting stuck if wrong password is entered once
authorsfan5 <sfan5@live.de>
Wed, 27 Apr 2022 17:32:51 +0000 (19:32 +0200)
committersfan5 <sfan5@live.de>
Thu, 28 Apr 2022 17:55:36 +0000 (19:55 +0200)
src/clientiface.cpp
src/clientiface.h
src/network/serverpackethandler.cpp

index a1c3e1187384349de0717b8bef79b2459423c792..a4bfb824259724015a2c2f2c14ad49306409b6d4 100644 (file)
@@ -596,6 +596,15 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
        }
 }
 
+void RemoteClient::resetChosenMech()
+{
+       if (chosen_mech == AUTH_MECHANISM_SRP) {
+               srp_verifier_delete((SRPVerifier *) auth_data);
+               auth_data = nullptr;
+       }
+       chosen_mech = AUTH_MECHANISM_NONE;
+}
+
 u64 RemoteClient::uptime() const
 {
        return porting::getTimeS() - m_connection_time;
index 947952e826a61fdbdf766e6fc8080bb7c28cc1a6..3e7ba4793a77352554cca45c1240f23bee554baa 100644 (file)
@@ -243,6 +243,8 @@ class RemoteClient
        u32 allowed_auth_mechs = 0;
        u32 allowed_sudo_mechs = 0;
 
+       void resetChosenMech();
+
        bool isSudoMechAllowed(AuthMechanism mech)
        { return allowed_sudo_mechs & mech; }
        bool isMechAllowed(AuthMechanism mech)
index 51061f57b33466299c3fb4536da03b4a8ced6ffb..125e85cabc91755f42dd3b39b770848471db2ae8 100644 (file)
@@ -1639,6 +1639,7 @@ void Server::handleCommand_SrpBytesA(NetworkPacket* pkt)
                        << std::endl;
                if (wantSudo) {
                        DenySudoAccess(peer_id);
+                       client->resetChosenMech();
                        return;
                }
 
@@ -1705,6 +1706,7 @@ void Server::handleCommand_SrpBytesM(NetworkPacket* pkt)
                                << " tried to change their password, but supplied wrong"
                                << " (SRP) password for authentication." << std::endl;
                        DenySudoAccess(peer_id);
+                       client->resetChosenMech();
                        return;
                }