Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try USER variable to retrieve the username. #282

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/NetUtils.cc
Expand Up @@ -379,6 +379,15 @@ inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE
GetUserName(buffer, &usernameLen);
return buffer;
#else
// First, try to get the username through the standard environment variable
// for it.
const auto userVariable = std::getenv("USER");
if (userVariable)
{
return userVariable;
}

// No USER variable, request it from the system.
struct passwd pd;
struct passwd *pdResult;
Uuid uuid;
Expand Down