Skip to content

Commit

Permalink
Merge pull request #833 from Expensify/master
Browse files Browse the repository at this point in the history
Update expensify_prod branch
  • Loading branch information
cead22 authored Aug 4, 2020
2 parents aecccd4 + 9a0d24c commit 85e9f83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions BedrockServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,9 @@ bool BedrockServer::_handleIfStatusOrControlCommand(unique_ptr<BedrockCommand>&
_reply(command);
return true;
} else if (_isControlCommand(command)) {
// Control commands can only come from localhost (and thus have an empty `_source`).
if (command->request["_source"].empty()) {
// Control commands can only come from localhost (and thus have an empty `_source`)
// with the exception of non-secure control commands
if (command->request["_source"].empty() || _isNonSecureControlCommand(command)) {
_control(command);
} else {
SWARN("Got control command " << command->request.methodLine << " on non-localhost socket ("
Expand Down Expand Up @@ -2065,6 +2066,11 @@ bool BedrockServer::_isControlCommand(const unique_ptr<BedrockCommand>& command)
return false;
}

bool BedrockServer::_isNonSecureControlCommand(const unique_ptr<BedrockCommand>& command) {
// A list of non-secure control commands that can be run from another host
return SIEquals(command->request.methodLine, "SuppressCommandPort") || SIEquals(command->request.methodLine, "ClearCommandPort");
}

void BedrockServer::_control(unique_ptr<BedrockCommand>& command) {
SData& response = command->response;
response.methodLine = "200 OK";
Expand Down
1 change: 1 addition & 0 deletions BedrockServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class BedrockServer : public SQLiteServer {
bool _isStatusCommand(const unique_ptr<BedrockCommand>& command);
void _status(unique_ptr<BedrockCommand>& command);
bool _isControlCommand(const unique_ptr<BedrockCommand>& command);
bool _isNonSecureControlCommand(const unique_ptr<BedrockCommand>& command);
void _control(unique_ptr<BedrockCommand>& command);

// Accepts any sockets pending on our listening ports. We do this both after `poll()`, and before shutting down
Expand Down

0 comments on commit 85e9f83

Please sign in to comment.