Skip to content

Commit

Permalink
Fix password changing getting stuck if wrong password is entered once
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Apr 28, 2022
1 parent 3d2bf8f commit 00f71c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/clientiface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/clientiface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/network/serverpackethandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,7 @@ void Server::handleCommand_SrpBytesA(NetworkPacket* pkt)
<< std::endl;
if (wantSudo) {
DenySudoAccess(peer_id);
client->resetChosenMech();
return;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 00f71c3

Please sign in to comment.