Skip to content

Commit

Permalink
console: show the name of the logged in user after login
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Nov 5, 2018
1 parent 58cb11c commit 1aea737
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/src/console/console.cc
Expand Up @@ -1184,6 +1184,21 @@ int main(int argc, char *argv[])
ConsoleOutput(response_args.JoinReadable().c_str());
}

response_args.clear();
if (!UA_sock->ReceiveAndEvaluateResponseMessage(response_id, response_args)) {
Dmsg0(200, "Could not receive the response message\n");
TerminateConsole(0);
return 1;
}

if (response_id != kMessageIdInfoMessage) {
Dmsg0(200, "Could not receive the response message\n");
TerminateConsole(0);
return 1;
}
response_args.PopFront();
ConsoleOutput(response_args.JoinReadable().c_str());

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

ConsoleOutput(_("\nEnter a period to cancel a command.\n"));
Expand Down
3 changes: 3 additions & 0 deletions core/src/dird/authenticate_console.cc
Expand Up @@ -231,6 +231,9 @@ bool AuthenticateUserAgent(UaContext *ua)
}
}
}
std::string message{"You are logged in as: "};
message += ua->cons ? ua->cons->name() : "root";
ua->UA_sock->FormatAndSendResponseMessage(kMessageIdInfoMessage, message);
return true;
}
} /* namespace directordaemon */
1 change: 1 addition & 0 deletions core/src/lib/bnet.h
Expand Up @@ -55,6 +55,7 @@ enum : uint32_t {
kMessageIdReceiveError = 2,
kMessageIdOk = 1000,
kMessageIdPamRequired = 1001,
kMessageIdInfoMessage = 1002,
kMessageIdPamInteractive = 4001,
kMessageIdPamUserCredentials = 4002
};
Expand Down
7 changes: 7 additions & 0 deletions core/src/lib/bstringlist.cc
Expand Up @@ -93,6 +93,13 @@ void BStringList::Append(const char *str)
emplace_back(str);
}

void BStringList::PopFront()
{
if (size() >= 1) {
erase(begin());
}
}

std::string BStringList::Join(char separator) const
{
return Join(&separator);
Expand Down
1 change: 1 addition & 0 deletions core/src/lib/bstringlist.h
Expand Up @@ -41,6 +41,7 @@ class BStringList : public std::vector<std::string>
void Append(const std::vector<std::string> &vec);
void Append(char character);
void Append(const char *str);
void PopFront();

private:
std::string Join(const char *separator) const;
Expand Down

0 comments on commit 1aea737

Please sign in to comment.