Improved command block security
This commit is contained in:
parent
a032594bf7
commit
fca5a01145
@ -13,6 +13,7 @@
|
|||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../Server.h" // ExecuteConsoleCommand()
|
#include "../Server.h" // ExecuteConsoleCommand()
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
|
#include "../ChatColor.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -206,15 +207,27 @@ void cCommandBlockEntity::Execute()
|
|||||||
virtual void Out(const AString & a_Text)
|
virtual void Out(const AString & a_Text)
|
||||||
{
|
{
|
||||||
// Overwrite field
|
// Overwrite field
|
||||||
m_CmdBlock->SetLastOutput(a_Text);
|
m_CmdBlock->SetLastOutput(cClientHandle::FormatChatPrefix(m_CmdBlock->GetWorld()->ShouldUseChatPrefixes(), "SUCCESS", cChatColor::Green, cChatColor::White) + a_Text);
|
||||||
}
|
}
|
||||||
} CmdBlockOutCb(this);
|
} CmdBlockOutCb(this);
|
||||||
|
|
||||||
LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str());
|
if ( // Administrator commands are not executable by command blocks
|
||||||
|
(m_Command != "stop") &&
|
||||||
cServer * Server = cRoot::Get()->GetServer();
|
(m_Command != "restart") &&
|
||||||
|
(m_Command != "kick") &&
|
||||||
Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
|
(m_Command != "ban") &&
|
||||||
|
(m_Command != "ipban")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
cServer * Server = cRoot::Get()->GetServer();
|
||||||
|
LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str());
|
||||||
|
Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastOutput(cClientHandle::FormatChatPrefix(GetWorld()->ShouldUseChatPrefixes(), "FAILURE", cChatColor::Rose, cChatColor::White) + "Adminstration commands can not be executed");
|
||||||
|
LOGD("cCommandBlockEntity: Prevented execution of administration command %s", m_Command.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO 2014-01-18 xdot: Update the signal strength.
|
// TODO 2014-01-18 xdot: Update the signal strength.
|
||||||
m_Result = 0;
|
m_Result = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user