Skip to content

Commit

Permalink
console: corrected handshake strings
Browse files Browse the repository at this point in the history
- removed trailing \n in response messages
- changed welcome text "You are logged in as / using .."
  • Loading branch information
franku committed Dec 11, 2018
1 parent 11ffdaa commit bcbf382
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/src/console/console.cc
Expand Up @@ -1135,6 +1135,7 @@ int main(int argc, char *argv[])

if (response_id == kMessageIdOk) {
ConsoleOutput(response_args.JoinReadable().c_str());
ConsoleOutput("\n");
}

response_args.clear();
Expand All @@ -1151,6 +1152,7 @@ int main(int argc, char *argv[])
}
response_args.PopFront();
ConsoleOutput(response_args.JoinReadable().c_str());
ConsoleOutput("\n");

Dmsg0(40, "Opened connection with Director daemon\n");

Expand Down
9 changes: 7 additions & 2 deletions core/src/dird/authenticate_console.cc
Expand Up @@ -233,8 +233,13 @@ bool AuthenticateConsole(UaContext *ua)
}
}
}
std::string message{"You are logged in as: "};
message += ua->cons ? ua->cons->name() : "root";
std::string message{"You are "};
if (ua->cons) {
message += "logged in as: ";
message += ua->cons->name();
} else {
message += "connected using the default console";
}
ua->UA_sock->FormatAndSendResponseMessage(kMessageIdInfoMessage, message);
return true;
}
Expand Down
1 change: 0 additions & 1 deletion core/src/lib/bnet.cc
Expand Up @@ -674,7 +674,6 @@ bool BareosSocket::FormatAndSendResponseMessage(uint32_t id, const std::string &
{
BStringList message;
message << str;
message << "\n";

return FormatAndSendResponseMessage(id, message);
}
2 changes: 1 addition & 1 deletion core/src/tests/bsock_test.cc
Expand Up @@ -469,7 +469,7 @@ TEST(BNet, FormatAndSendResponseMessage)
EXPECT_TRUE(ok) << "ReceiveAndEvaluateResponseMessage errored.";
EXPECT_EQ(id, kMessageIdOk) << "Wrong MessageID received.";

std::string test("1000 Test123 \n");
std::string test("1000 Test123");
EXPECT_STREQ(args.JoinReadable().c_str(), test.c_str());
}

0 comments on commit bcbf382

Please sign in to comment.