1.1 --- a/core/PlayerManager.cpp Sat Mar 02 13:42:07 2013 -0500
1.2 +++ b/core/PlayerManager.cpp Thu Mar 07 00:58:17 2013 +0000
1.3 @@ -116,7 +116,7 @@
1.4 m_SourceTVUserId = -1;
1.5 m_ReplayUserId = -1;
1.6
1.7 - m_bUseSteamAdminAuth = true; // use steam auth by default
1.8 + m_bAuthstringValidation = true; // use steam auth by default
1.9
1.10 m_UserIdLookUp = new int[USHRT_MAX+1];
1.11 memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
1.12 @@ -234,9 +234,9 @@
1.13 } else if (strcmp( key, "SteamAuthstringValidation" ) == 0) {
1.14 if (strcasecmp(value, "yes") == 0)
1.15 {
1.16 - m_bUseSteamAdminAuth = true;
1.17 + m_bAuthstringValidation = true;
1.18 } else if ( strcasecmp(value, "no") == 0) {
1.19 - m_bUseSteamAdminAuth = false;
1.20 + m_bAuthstringValidation = false;
1.21 } else {
1.22 UTIL_Format(error, maxlength, "Invalid value: must be \"yes\" or \"no\"");
1.23 return ConfigResult_Reject;
1.24 @@ -367,23 +367,18 @@
1.25 {
1.26 pPlayer = &m_Players[m_AuthQueue[i]];
1.27 authstr = engine->GetPlayerNetworkIDString(pPlayer->m_pEdict);
1.28 + pPlayer->SetAuthString(authstr);
1.29
1.30 -#if SOURCE_ENGINE >= SE_ORANGEBOX
1.31 - // we can only easily check if the client is fully authed if we're on a recent engine
1.32 - if (m_bUseSteamAdminAuth && !g_HL2.IsLANServer())
1.33 + if (!pPlayer->IsAuthStringValidated())
1.34 {
1.35 - if (!pPlayer->IsAuthedBySteam())
1.36 - {
1.37 - continue; // we're using steam auth, and steam doesn't know about this player yet so we can't do anything about them for now
1.38 - }
1.39 + continue; // we're using steam auth, and steam doesn't know about this player yet so we can't do anything about them for now
1.40 }
1.41 -#endif
1.42
1.43 if (authstr && authstr[0] != '\0'
1.44 && (strcmp(authstr, "STEAM_ID_PENDING") != 0))
1.45 {
1.46 /* Set authorization */
1.47 - pPlayer->Authorize(authstr);
1.48 + pPlayer->Authorize();
1.49
1.50 /* Mark as removed from queue */
1.51 unsigned int client = m_AuthQueue[i];
1.52 @@ -558,7 +553,8 @@
1.53 /* Run manual connection routines */
1.54 char error[255];
1.55 const char *authid = engine->GetPlayerNetworkIDString(pEntity);
1.56 - pPlayer->Authorize(authid);
1.57 + pPlayer->SetAuthString(authid);
1.58 + pPlayer->Authorize();
1.59 pPlayer->m_bFakeClient = true;
1.60
1.61 /*
1.62 @@ -1272,11 +1268,12 @@
1.63 {
1.64 continue;
1.65 }
1.66 - if (!pTarget->IsConnected() || !pTarget->IsAuthorized())
1.67 + if (!pTarget->IsConnected())
1.68 {
1.69 continue;
1.70 }
1.71 - if (strcmp(pTarget->GetAuthString(), new_pattern) == 0)
1.72 + const char *authstr = pTarget->GetAuthString(false); // We want to make it easy for people to be kicked/banned, so don't require validation for command targets.
1.73 + if (authstr && strcmp(authstr, new_pattern) == 0)
1.74 {
1.75 if ((info->reason = FilterCommandTarget(pAdmin, pTarget, info->flags))
1.76 == COMMAND_TARGET_VALID)
1.77 @@ -1634,15 +1631,20 @@
1.78 }
1.79 }
1.80
1.81 -void CPlayer::Authorize(const char *steamid)
1.82 +void CPlayer::SetAuthString(const char *steamid)
1.83 {
1.84 if (m_IsAuthorized)
1.85 {
1.86 return;
1.87 }
1.88
1.89 + m_AuthID.assign(steamid);
1.90 +}
1.91 +
1.92 +// Ensure a valid AuthString is set before calling.
1.93 +void CPlayer::Authorize()
1.94 +{
1.95 m_IsAuthorized = true;
1.96 - m_AuthID.assign(steamid);
1.97 }
1.98
1.99 void CPlayer::Disconnect()
1.100 @@ -1685,8 +1687,13 @@
1.101 return m_Ip.c_str();
1.102 }
1.103
1.104 -const char *CPlayer::GetAuthString()
1.105 +const char *CPlayer::GetAuthString(bool validated)
1.106 {
1.107 + if (validated && !IsAuthStringValidated())
1.108 + {
1.109 + return NULL;
1.110 + }
1.111 +
1.112 return m_AuthID.c_str();
1.113 }
1.114
1.115 @@ -1715,12 +1722,17 @@
1.116 return m_IsAuthorized;
1.117 }
1.118
1.119 +bool CPlayer::IsAuthStringValidated()
1.120 +{
1.121 #if SOURCE_ENGINE >= SE_ORANGEBOX
1.122 -bool CPlayer::IsAuthedBySteam()
1.123 -{
1.124 - return engine->IsClientFullyAuthenticated( m_pEdict );
1.125 + if (g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer())
1.126 + {
1.127 + return engine->IsClientFullyAuthenticated(m_pEdict);
1.128 + }
1.129 +#endif
1.130 +
1.131 + return true;
1.132 }
1.133 -#endif
1.134
1.135 IPlayerInfo *CPlayer::GetPlayerInfo()
1.136 {