| 3736 | } |
| 3737 | |
| 3738 | void CServer::ConAuthUpdateHashed(IConsole::IResult *pResult, void *pUser) |
| 3739 | { |
| 3740 | CServer *pThis = (CServer *)pUser; |
| 3741 | CAuthManager *pManager = &pThis->m_AuthManager; |
| 3742 | |
| 3743 | const char *pIdent = pResult->GetString(0); |
| 3744 | const char *pLevel = pResult->GetString(1); |
| 3745 | const char *pPw = pResult->GetString(2); |
| 3746 | const char *pSalt = pResult->GetString(3); |
| 3747 | |
| 3748 | int KeySlot = pManager->FindKey(pIdent); |
| 3749 | if(KeySlot == -1) |
| 3750 | { |
| 3751 | pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "ident couldn't be found"); |
| 3752 | return; |
| 3753 | } |
| 3754 | |
| 3755 | int Level = GetAuthLevel(pLevel); |
| 3756 | if(Level == -1) |
| 3757 | { |
| 3758 | pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "level can be one of {\"admin\", \"mod(erator)\", \"helper\"}"); |
| 3759 | return; |
| 3760 | } |
| 3761 | // back compat to change "mod", "modder" and so on as parameters to "moderator" |
| 3762 | pLevel = CAuthManager::AuthLevelToRoleName(Level); |
| 3763 | |
| 3764 | MD5_DIGEST Hash; |
| 3765 | unsigned char aSalt[SALT_BYTES]; |
| 3766 | |
| 3767 | if(md5_from_str(&Hash, pPw)) |
| 3768 | { |
| 3769 | pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "Malformed password hash"); |
| 3770 | return; |
| 3771 | } |
| 3772 | if(str_hex_decode(aSalt, sizeof(aSalt), pSalt)) |
| 3773 | { |
| 3774 | pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "Malformed salt hash"); |
| 3775 | return; |
| 3776 | } |
| 3777 | |
| 3778 | pManager->UpdateKeyHash(KeySlot, Hash, aSalt, pLevel); |
| 3779 | pThis->LogoutKey(KeySlot, "key update"); |
| 3780 | |
| 3781 | pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "key updated"); |
| 3782 | } |
| 3783 | |
| 3784 | void CServer::ConAuthRemove(IConsole::IResult *pResult, void *pUser) |
| 3785 | { |
nothing calls this directly
no test coverage detected