| 2062 | } |
| 2063 | |
| 2064 | void CServer::OnNetMsgRconAuth(int ClientId, const char *pName, const char *pPw, bool SendRconCmds) |
| 2065 | { |
| 2066 | int AuthLevel = -1; |
| 2067 | int KeySlot = -1; |
| 2068 | |
| 2069 | if(!pName[0]) |
| 2070 | { |
| 2071 | if(m_AuthManager.CheckKey((KeySlot = m_AuthManager.DefaultKey(RoleName::ADMIN)), pPw)) |
| 2072 | AuthLevel = AUTHED_ADMIN; |
| 2073 | else if(m_AuthManager.CheckKey((KeySlot = m_AuthManager.DefaultKey(RoleName::MODERATOR)), pPw)) |
| 2074 | AuthLevel = AUTHED_MOD; |
| 2075 | else if(m_AuthManager.CheckKey((KeySlot = m_AuthManager.DefaultKey(RoleName::HELPER)), pPw)) |
| 2076 | AuthLevel = AUTHED_HELPER; |
| 2077 | } |
| 2078 | else |
| 2079 | { |
| 2080 | KeySlot = m_AuthManager.FindKey(pName); |
| 2081 | if(m_AuthManager.CheckKey(KeySlot, pPw)) |
| 2082 | AuthLevel = m_AuthManager.KeyLevel(KeySlot); |
| 2083 | } |
| 2084 | |
| 2085 | if(AuthLevel != -1) |
| 2086 | { |
| 2087 | if(GetAuthedState(ClientId) != AuthLevel) |
| 2088 | { |
| 2089 | if(!IsSixup(ClientId)) |
| 2090 | { |
| 2091 | CMsgPacker Msgp(NETMSG_RCON_AUTH_STATUS, true); |
| 2092 | Msgp.AddInt(1); //authed |
| 2093 | Msgp.AddInt(1); //cmdlist |
| 2094 | SendMsg(&Msgp, MSGFLAG_VITAL, ClientId); |
| 2095 | } |
| 2096 | else |
| 2097 | { |
| 2098 | CMsgPacker Msgp(protocol7::NETMSG_RCON_AUTH_ON, true, true); |
| 2099 | SendMsg(&Msgp, MSGFLAG_VITAL, ClientId); |
| 2100 | } |
| 2101 | |
| 2102 | m_aClients[ClientId].m_AuthKey = KeySlot; |
| 2103 | if(SendRconCmds) |
| 2104 | { |
| 2105 | m_aClients[ClientId].m_pRconCmdToSend = Console()->FirstCommandInfo(ClientId, CFGFLAG_SERVER); |
| 2106 | SendRconCmdGroupStart(ClientId); |
| 2107 | if(m_aClients[ClientId].m_pRconCmdToSend == nullptr) |
| 2108 | { |
| 2109 | SendRconCmdGroupEnd(ClientId); |
| 2110 | } |
| 2111 | } |
| 2112 | |
| 2113 | const char *pIdent = m_AuthManager.KeyIdent(KeySlot); |
| 2114 | switch(AuthLevel) |
| 2115 | { |
| 2116 | case AUTHED_ADMIN: |
| 2117 | { |
| 2118 | SendRconLine(ClientId, "Admin authentication successful. Full remote console access granted."); |
| 2119 | log_info("server", "ClientId=%d authed with key='%s' (admin)", ClientId, pIdent); |
| 2120 | break; |
| 2121 | } |
nothing calls this directly
no test coverage detected