Skip to content

Commit

Permalink
Open source companion commit for rstudio/rstudio-pro#1376
Browse files Browse the repository at this point in the history
  • Loading branch information
kfeinauer committed Jan 6, 2020
1 parent 8c7685d commit d402dbb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cpp/shared_core/include/shared_core/system/User.hpp
Expand Up @@ -164,6 +164,13 @@ class User
* @return The ID of this user's primary group.
*/
GidType getGroupId() const;

/**
* @brief Returns the login shell of this user.
*
* @return The login shell of this user.
*/
const std::string& getShell() const;

/**
* @brief Gets the ID of this user.
Expand Down
8 changes: 8 additions & 0 deletions src/cpp/shared_core/system/User.cpp
Expand Up @@ -84,6 +84,7 @@ struct User::Impl
GroupId = pwd.pw_gid;
Name = pwd.pw_name;
HomeDirectory = FilePath(pwd.pw_dir);
Shell = pwd.pw_shell;
}

return Success();
Expand All @@ -93,6 +94,7 @@ struct User::Impl
GidType GroupId;
std::string Name;
FilePath HomeDirectory;
std::string Shell;
};

PRIVATE_IMPL_DELETER_IMPL(User)
Expand Down Expand Up @@ -194,12 +196,18 @@ const std::string& User::getUsername() const
return m_impl->Name;
}

const std::string& User::getShell() const
{
return m_impl->Shell;
}

User& User::operator=(const User& in_other)
{
m_impl->Name = in_other.m_impl->Name;
m_impl->UserId = in_other.m_impl->UserId;
m_impl->GroupId = in_other.m_impl->GroupId;
m_impl->HomeDirectory = in_other.m_impl->HomeDirectory;
m_impl->Shell = in_other.m_impl->Shell;
return *this;
}

Expand Down

0 comments on commit d402dbb

Please sign in to comment.