diff options
Diffstat (limited to 'user_mgr.hpp')
-rw-r--r-- | user_mgr.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/user_mgr.hpp b/user_mgr.hpp index c1673f1..c78174d 100644 --- a/user_mgr.hpp +++ b/user_mgr.hpp @@ -19,6 +19,7 @@ #include <xyz/openbmc_project/User/Manager/server.hpp> #include <xyz/openbmc_project/User/AccountPolicy/server.hpp> #include <unordered_map> +#include <variant> #include "users.hpp" namespace phosphor @@ -32,6 +33,27 @@ using UserSSHLists = using AccountPolicyIface = sdbusplus::xyz::openbmc_project::User::server::AccountPolicy; +using Privilege = std::string; +using GroupList = std::vector<std::string>; +using UserEnabled = bool; +using PropertyName = std::string; + +using UserInfo = std::variant<Privilege, GroupList, UserEnabled>; +using UserInfoMap = std::map<PropertyName, UserInfo>; + +using DbusUserObjPath = sdbusplus::message::object_path; + +using DbusUserPropVariant = sdbusplus::message::variant<Privilege>; + +using DbusUserObjProperties = + std::vector<std::pair<PropertyName, DbusUserPropVariant>>; + +using Interface = std::string; + +using DbusUserObjValue = std::map<Interface, DbusUserObjProperties>; + +using DbusUserObj = std::map<DbusUserObjPath, DbusUserObjValue>; + /** @class UserMgr * @brief Responsible for managing user accounts over the D-Bus interface. */ @@ -141,6 +163,17 @@ class UserMgr : public UserMgrIface, AccountPolicyIface bool userLockedForFailedAttempt(const std::string &userName, const bool &value); + /** @brief returns user info + * Checks if user is local user, then returns map of properties of user. + * like user privilege, list of user groups, user enabled state and user + * locked state. If its not local user, then it checks if its a ldap user, + * then it gets the privilege mapping of the LDAP group. + * + * @param[in] - user name + * @return - map of user properties + **/ + UserInfoMap getUserInfo(std::string userName) override; + private: /** @brief sdbusplus handler */ sdbusplus::bus::bus &bus; @@ -275,6 +308,30 @@ class UserMgr : public UserMgrIface, AccountPolicyIface int setPamModuleArgValue(const std::string &moduleName, const std::string &argName, const std::string &argValue); + + /** @brief get service name + * method to get dbus service name + * + * @param[in] path - object path + * @param[in] intf - interface + * @return - service name + */ + std::string getServiceName(std::string &&path, std::string &&intf); + + /** @brief get LDAP group name + * method to get LDAP group name for the given LDAP user + * + * @param[in] - userName + * @return - group name + */ + std::string getLdapGroupName(const std::string &userName); + + /** @brief get privilege mapper object + * method to get dbus privilege mapper object + * + * @return - map of user object + */ + DbusUserObj getPrivilegeMapperObject(void); }; } // namespace user |