From d402dbba2798a6817f0c57fc969523772ca9b006 Mon Sep 17 00:00:00 2001 From: "karl@rstudio.com" Date: Mon, 6 Jan 2020 16:32:28 -0600 Subject: [PATCH] Open source companion commit for https://github.com/rstudio/rstudio-pro/pull/1376 --- src/cpp/shared_core/include/shared_core/system/User.hpp | 7 +++++++ src/cpp/shared_core/system/User.cpp | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/cpp/shared_core/include/shared_core/system/User.hpp b/src/cpp/shared_core/include/shared_core/system/User.hpp index 735140b23b2..24494f3ccc9 100644 --- a/src/cpp/shared_core/include/shared_core/system/User.hpp +++ b/src/cpp/shared_core/include/shared_core/system/User.hpp @@ -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. diff --git a/src/cpp/shared_core/system/User.cpp b/src/cpp/shared_core/system/User.cpp index 7363d1a36e4..1c48036854c 100644 --- a/src/cpp/shared_core/system/User.cpp +++ b/src/cpp/shared_core/system/User.cpp @@ -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(); @@ -93,6 +94,7 @@ struct User::Impl GidType GroupId; std::string Name; FilePath HomeDirectory; + std::string Shell; }; PRIVATE_IMPL_DELETER_IMPL(User) @@ -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; }