From 94d6f95887941de38eb7e43086f8e95c0c9b19b3 Mon Sep 17 00:00:00 2001 From: div0 Date: Sat, 30 Aug 2008 11:53:20 +0000 Subject: [PATCH] get rid of ServerConsoleEcho workaround; fix a remote DP-console command execution hole in the process :P git-svn-id: svn://svn.icculus.org/nexuiz/trunk@4256 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/campaign.qc | 2 +- data/qcsrc/server/cl_client.qc | 8 ++--- data/qcsrc/server/clientcommands.qc | 7 ++--- data/qcsrc/server/ctf.qc | 2 +- data/qcsrc/server/domination.qc | 2 +- data/qcsrc/server/g_damage.qc | 2 +- data/qcsrc/server/g_world.qc | 47 ++++++++++++++--------------- data/qcsrc/server/ipban.qc | 4 +-- data/qcsrc/server/keyhunt.qc | 2 +- data/qcsrc/server/miscfunctions.qc | 30 ++---------------- data/qcsrc/server/teamplay.qc | 4 +-- data/qcsrc/server/vote.qc | 16 +++++----- 12 files changed, 49 insertions(+), 77 deletions(-) diff --git a/data/qcsrc/server/campaign.qc b/data/qcsrc/server/campaign.qc index 536472150..87bd31393 100644 --- a/data/qcsrc/server/campaign.qc +++ b/data/qcsrc/server/campaign.qc @@ -12,7 +12,7 @@ float checkrules_equality; void CampaignBailout(string s) { cvar_set("g_campaign", "0"); - ServerConsoleEcho(strcat("campaign initialization failed: ", s), TRUE); + print("campaign initialization failed: ", s, "\n"); return; } diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index b9912e7fd..7430e1da8 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -1083,10 +1083,10 @@ void ClientConnect (void) s = "player"; else s = "bot"; - GameLogEcho(strcat(":join:", ftos(self.playerid), ":", s, ":", self.netname), TRUE); + GameLogEcho(strcat(":join:", ftos(self.playerid), ":", s, ":", self.netname)); s = strcat(":team:", ftos(self.playerid), ":"); s = strcat(s, ftos(self.team)); - GameLogEcho(s, FALSE); + GameLogEcho(s); } self.netname_previous = strzone(self.netname); @@ -1233,7 +1233,7 @@ void ClientDisconnect (void) detach_entcs(); if(cvar("sv_eventlog")) - GameLogEcho(strcat(":part:", ftos(self.playerid)), FALSE); + GameLogEcho(strcat(":part:", ftos(self.playerid))); bprint ("^4",self.netname); bprint ("^4 disconnected\n"); @@ -1949,7 +1949,7 @@ void PlayerPreThink (void) if(self.netname_previous != self.netname) { if(cvar("sv_eventlog")) - GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname), TRUE); + GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname)); if(self.netname_previous) strunzone(self.netname_previous); self.netname_previous = strzone(self.netname); diff --git a/data/qcsrc/server/clientcommands.qc b/data/qcsrc/server/clientcommands.qc index 0c4f71697..9bcc70710 100644 --- a/data/qcsrc/server/clientcommands.qc +++ b/data/qcsrc/server/clientcommands.qc @@ -96,7 +96,7 @@ void Say(entity source, float teamsay, string msgin) } else sprint(self, msgstr); - ServerConsoleEcho(strcat("NOTE: ", playername(self), "^7 is flooding."), TRUE); + print("NOTE: ", playername(self), "^7 is flooding.\n"); } else if(teamsay) { @@ -131,7 +131,6 @@ void Say(entity source, float teamsay, string msgin) } else bprint(msgstr); - //ServerConsoleEcho(substring(msgstr, 1, strlen(msgstr) - 2), TRUE); } strunzone(msgstr); @@ -370,7 +369,7 @@ void SV_ParseClientCommand(string s) { if(cmd != "playerskin") if(cmd != "god") if(cmd != "notarget") if(cmd != "fly") if(cmd != "give") if(cmd != "noclip") { - ServerConsoleEcho(strcat("WARNING: Invalid clientcommand by ", self.netname, ": ", s), TRUE); + print("WARNING: Invalid clientcommand by ", self.netname, ": ", s, "\n"); return; } */ @@ -452,7 +451,7 @@ void ReadyRestart() reset_map(); if(cvar("sv_eventlog")) - GameLogEcho(":restart", FALSE); + GameLogEcho(":restart"); } /** diff --git a/data/qcsrc/server/ctf.qc b/data/qcsrc/server/ctf.qc index 471baa2ee..060564553 100644 --- a/data/qcsrc/server/ctf.qc +++ b/data/qcsrc/server/ctf.qc @@ -74,7 +74,7 @@ void LogCTF(string mode, float flagteam, entity actor) s = strcat(s, ":", ftos(flagteam)); if(actor != world) s = strcat(s, ":", ftos(actor.playerid)); - GameLogEcho(s, FALSE); + GameLogEcho(s); } void RegenFlag(entity e) diff --git a/data/qcsrc/server/domination.qc b/data/qcsrc/server/domination.qc index 1a27b039b..62caf58c6 100644 --- a/data/qcsrc/server/domination.qc +++ b/data/qcsrc/server/domination.qc @@ -29,7 +29,7 @@ void LogDom(string mode, float team_before, entity actor) s = strcat(":dom:", mode); s = strcat(s, ":", ftos(team_before)); s = strcat(s, ":", ftos(actor.playerid)); - GameLogEcho(s, FALSE); + GameLogEcho(s); } void() dom_spawnteams; diff --git a/data/qcsrc/server/g_damage.qc b/data/qcsrc/server/g_damage.qc index a5a9f4b12..7c21927b9 100644 --- a/data/qcsrc/server/g_damage.qc +++ b/data/qcsrc/server/g_damage.qc @@ -137,7 +137,7 @@ void LogDeath(string mode, float deathtype, entity killer, entity killed) s = strcat(s, ":victimitems="); s = AppendItemcodes(s, killed); } - GameLogEcho(s, FALSE); + GameLogEcho(s); } void Obituary (entity attacker, entity targ, float deathtype) diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 815ce1af5..fec1be30f 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -265,7 +265,7 @@ void spawnfunc_worldspawn (void) { s = strcat(cvar_string("sv_eventlog_files_counter"), "."); s = strcat(s, ftos(random())); - GameLogEcho(strcat(":gamestart:", GetGametype(), "_", GetMapname(), ":", s), FALSE); + GameLogEcho(strcat(":gamestart:", GetGametype(), "_", GetMapname(), ":", s)); s = ":gameinfo:mutators:LIST"; if(cvar("g_grappling_hook")) s = strcat(s, ":grappling_hook"); @@ -289,8 +289,8 @@ void spawnfunc_worldspawn (void) s = strcat(s, ":midair"); if(cvar("g_minstagib")) s = strcat(s, ":minstagib"); - GameLogEcho(s, FALSE); - GameLogEcho(":gameinfo:end", FALSE); + GameLogEcho(s); + GameLogEcho(":gameinfo:end"); } cvar_set("nextmap", ""); @@ -886,9 +886,9 @@ void DumpStats(float final) s = strcat(s, GetGametype(), "_", GetMapname(), ":", ftos(rint(time))); if(to_console) - ServerConsoleEcho(s, FALSE); + print(s, "\n"); if(to_eventlog) - GameLogEcho(s, FALSE); + GameLogEcho(s); if(to_file) { file = fopen(cvar_string("sv_logscores_filename"), FILE_APPEND); @@ -899,10 +899,9 @@ void DumpStats(float final) } s = strcat(":labels:player:", GetPlayerScoreString(world, 0)); - if(to_console) - ServerConsoleEcho(s, TRUE); + print(s, "\n"); if(to_eventlog) - GameLogEcho(s, TRUE); + GameLogEcho(s); if(to_file) fputs(file, strcat(s, "\n")); @@ -918,9 +917,9 @@ void DumpStats(float final) s = strcat(s, "spectator:"); if(to_console) - ServerConsoleEcho(strcat(s, other.netname), TRUE); + print(s, other.netname, "\n"); if(to_eventlog) - GameLogEcho(strcat(s, ftos(other.playerid), ":", other.netname), TRUE); + GameLogEcho(strcat(s, ftos(other.playerid), ":", other.netname)); if(to_file) fputs(file, strcat(s, other.netname, "\n")); } @@ -930,9 +929,9 @@ void DumpStats(float final) { s = strcat(":labels:teamscores:", GetTeamScoreString(0, 0)); if(to_console) - ServerConsoleEcho(s, TRUE); + print(s, "\n"); if(to_eventlog) - GameLogEcho(s, TRUE); + GameLogEcho(s); if(to_file) fputs(file, strcat(s, "\n")); @@ -941,18 +940,18 @@ void DumpStats(float final) s = strcat(":teamscores:see-labels:", GetTeamScoreString(i, 0)); s = strcat(s, ":", ftos(i)); if(to_console) - ServerConsoleEcho(s, TRUE); + print(s, "\n"); if(to_eventlog) - GameLogEcho(s, TRUE); + GameLogEcho(s); if(to_file) fputs(file, strcat(s, "\n")); } } if(to_console) - ServerConsoleEcho(":end", FALSE); + print(":end\n"); if(to_eventlog) - GameLogEcho(":end", FALSE); + GameLogEcho(":end"); if(to_file) { fputs(file, ":end\n"); @@ -1028,7 +1027,7 @@ void NextLevel() DumpStats(TRUE); if(cvar("sv_eventlog")) - GameLogEcho(":gameover", FALSE); + GameLogEcho(":gameover"); GameLogClose(); @@ -1342,7 +1341,7 @@ void print_to(entity e, string s) if(e) sprint(e, strcat(s, "\n")); else - ServerConsoleEcho(s, TRUE); + print(s, "\n"); } void ShuffleMaplist() @@ -1712,7 +1711,7 @@ string MapVote_Suggest(string m) strunzone(mapvote_suggestions[i]); mapvote_suggestions[i] = strzone(m); if(cvar("sv_eventlog")) - GameLogEcho(strcat(":vote:suggested:", m, ":", ftos(self.playerid)), TRUE); + GameLogEcho(strcat(":vote:suggested:", m, ":", ftos(self.playerid))); return strcat("Suggestion of ", m, " accepted."); } @@ -1907,9 +1906,9 @@ float MapVote_Finished(float mappos) } result = strcat(result, ":didn't vote:", ftos(didntvote)); - GameLogEcho(result, FALSE); + GameLogEcho(result); if(mapvote_maps_suggested[mappos]) - GameLogEcho(strcat(":vote:suggestion_accepted:", mapvote_maps[mappos]), FALSE); + GameLogEcho(strcat(":vote:suggestion_accepted:", mapvote_maps[mappos])); } FOR_EACH_REALCLIENT(other) @@ -2008,7 +2007,7 @@ float MapVote_CheckRules_2() } result = strcat(result, ":didn't vote:", ftos(didntvote)); if(cvar("sv_eventlog")) - GameLogEcho(result, FALSE); + GameLogEcho(result); } return FALSE; @@ -2236,7 +2235,7 @@ float RedirectionThink() clients_found = 0; FOR_EACH_REALCLIENT(self) { - ServerConsoleEcho(strcat("Redirecting: sending connect command to ", self.netname), FALSE); + print("Redirecting: sending connect command to ", self.netname, "\n"); if(redirection_target == "self") stuffcmd(self, "\ndisconnect; reconnect\n"); else @@ -2244,7 +2243,7 @@ float RedirectionThink() ++clients_found; } - ServerConsoleEcho(strcat("Redirecting: ", ftos(clients_found), " clients left."), FALSE); + print("Redirecting: ", ftos(clients_found), " clients left.\n"); if(time > redirection_timeout || clients_found == 0) localcmd("\nwait; wait; wait; quit\n"); diff --git a/data/qcsrc/server/ipban.qc b/data/qcsrc/server/ipban.qc index 9d68f00b0..bc944edb5 100644 --- a/data/qcsrc/server/ipban.qc +++ b/data/qcsrc/server/ipban.qc @@ -78,7 +78,7 @@ void Ban_View() msg = strcat("#", ftos(i), ": "); msg = strcat(msg, ban_ip[i], " is still banned for "); msg = strcat(msg, ftos(ban_expire[i] - time), " seconds"); - ServerConsoleEcho(msg, FALSE); + print(msg, "\n"); } } @@ -149,7 +149,7 @@ float Ban_Insert(string ip, float bantime) return FALSE; // okay, insert our new victim as i Ban_Delete(i); - ServerConsoleEcho(strcat(ip, " has been banned for ", ftos(bantime), " seconds"), FALSE); + print(ip, " has been banned for ", ftos(bantime), " seconds\n"); ban_expire[i] = time + bantime; ban_ip[i] = strzone(ip); ban_count = max(ban_count, i + 1); diff --git a/data/qcsrc/server/keyhunt.qc b/data/qcsrc/server/keyhunt.qc index e5f014b90..71053691b 100644 --- a/data/qcsrc/server/keyhunt.qc +++ b/data/qcsrc/server/keyhunt.qc @@ -143,7 +143,7 @@ void kh_Scores_Event(entity player, entity key, string what, float frags_player, s = strcat(s, ":", ftos(frags_owner), ":"); if(key) s = strcat(s, key.netname); - GameLogEcho(s, FALSE); + GameLogEcho(s); } vector kh_AttachedOrigin(entity e) // runs when a team captures the flag, it can run 2 or 3 times. diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index b1cb4b41d..06ff9003f 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -141,33 +141,7 @@ void bcenterprint(string s) centerprint(head, s); } -void ServerConsoleEcho(string s, float check_dangerous) -{ - local string ch; - if (checkextension("DP_SV_PRINT")) - print(s, "\n"); - else - { - localcmd("echo \""); - if(check_dangerous) - { - while(strlen(s)) - { - ch = substring(s, 0, 1); - if(ch != "\"" && ch != "\r" && ch != "\n") - localcmd(ch); - s = substring(s, 1, strlen(s) - 1); - } - } - else - { - localcmd(s); - } - localcmd("\"\n"); - } -} - -void GameLogEcho(string s, float check_dangerous) +void GameLogEcho(string s) { string fn; float matches; @@ -196,7 +170,7 @@ void GameLogEcho(string s, float check_dangerous) } if(cvar("sv_eventlog_console")) { - ServerConsoleEcho(s, check_dangerous); + print(s, "\n"); } } diff --git a/data/qcsrc/server/teamplay.qc b/data/qcsrc/server/teamplay.qc index b8269836f..7f10b134b 100644 --- a/data/qcsrc/server/teamplay.qc +++ b/data/qcsrc/server/teamplay.qc @@ -82,7 +82,7 @@ void LogTeamchange(entity pl) return; str = strcat(":team:", ftos(pl.playerid), ":"); str = strcat(str, ftos(pl.team)); - GameLogEcho(str, FALSE); + GameLogEcho(str); } void WriteGameCvars() @@ -1201,7 +1201,7 @@ void CauseRebalance(float source_team, float howmany_toomany) steam = COLOR_TEAM3; else if(source_team == 4) steam = COLOR_TEAM4; - ServerConsoleEcho(strcat("Team ", ftos(source_team), " too large, complaining."), TRUE); + print("Team ", ftos(source_team), " too large, complaining.\n"); FOR_EACH_REALPLAYER(head) { if(head.team == steam) diff --git a/data/qcsrc/server/vote.qc b/data/qcsrc/server/vote.qc index 36ddafc30..de56cb3c8 100644 --- a/data/qcsrc/server/vote.qc +++ b/data/qcsrc/server/vote.qc @@ -137,7 +137,7 @@ float GameCommand_Vote(string s, entity e) { } bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2 calls a vote for ", votecalledvote_display, "\n"); if(cvar("sv_eventlog")) - GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display), TRUE); + GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display)); VoteCount(); // needed if you are the only one } else { print_to(e, "^1This vote is not ok. See help for more info."); @@ -175,7 +175,7 @@ float GameCommand_Vote(string s, entity e) { } bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2 calls a vote to become ^3master^2.\n"); if(cvar("sv_eventlog")) - GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display), FALSE); + GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display)); VoteCount(); // needed if you are the only one } } else { @@ -216,7 +216,7 @@ float GameCommand_Vote(string s, entity e) { } bprint("\{1}^2* ^3", VoteNetname(e), "^2 used his ^3master^2 status to do \"^2", dovote_display, "^2\".\n"); if(cvar("sv_eventlog")) - GameLogEcho(strcat(":vote:vdo:", ftos(e.playerid), ":", dovote_display), FALSE); + GameLogEcho(strcat(":vote:vdo:", ftos(e.playerid), ":", dovote_display)); localcmd(strcat(dovote, "\n")); } else { print_to(e, "^1This command is not ok. See help for more info."); @@ -233,13 +233,13 @@ float GameCommand_Vote(string s, entity e) { if (e) e.vote_master = granted; if(granted) { - ServerConsoleEcho(strcat("Accepted master login from ", VoteNetname(e)), TRUE); + print("Accepted master login from ", VoteNetname(e), "\n"); bprint("\{1}^2* ^3", VoteNetname(e), "^2 logged in as ^3master^2\n"); if(cvar("sv_eventlog")) - GameLogEcho(strcat(":vote:vlogin:", ftos(e.playerid)), FALSE); + GameLogEcho(strcat(":vote:vlogin:", ftos(e.playerid))); } else - ServerConsoleEcho(strcat("REJECTED master login from ", VoteNetname(e)), TRUE); + print("REJECTED master login from ", VoteNetname(e), "\n"); } else print_to(e, "^1Login to become master is NOT allowed."); @@ -465,7 +465,7 @@ void VoteTimeout() { void VoteStop(entity stopper) { bprint("\{1}^2* ^3", VoteNetname(stopper), "^2 stopped ^3", VoteNetname(votecaller), "^2's vote\n"); if(cvar("sv_eventlog")) - GameLogEcho(strcat(":vote:vstop:", ftos(stopper.playerid)), FALSE); + GameLogEcho(strcat(":vote:vstop:", ftos(stopper.playerid))); if(stopper == votecaller) { // no wait for next vote so you can correct your vote if(votecaller) { @@ -507,7 +507,7 @@ void VoteSpam(float yescount, float nocount, float abstaincount, float notvoters s = strcat(s, ":", ftos(abstaincount)); s = strcat(s, ":", ftos(notvoters)); s = strcat(s, ":", ftos(mincount)); - GameLogEcho(s, FALSE); + GameLogEcho(s); } } -- 2.39.2