diff --git a/test/user_mgr_test.cpp b/test/user_mgr_test.cpp index 818a18b1..74ae9307 100644 --- a/test/user_mgr_test.cpp +++ b/test/user_mgr_test.cpp @@ -33,7 +33,9 @@ class TestUserMgr : public testing::Test std::vector groupNames, const std::string& priv, bool enabled) { - std::string userObj = std::string(usersObjPath) + "/" + userName; + sdbusplus::message::object_path tempObjPath(usersObjPath); + tempObjPath /= userName; + std::string userObj(tempObjPath); mockManager.usersList.emplace( userName, std::move(std::make_unique( mockManager.bus, userObj.c_str(), groupNames, priv, diff --git a/user_mgr.cpp b/user_mgr.cpp index 307c8103..8fc899f8 100644 --- a/user_mgr.cpp +++ b/user_mgr.cpp @@ -334,7 +334,9 @@ void UserMgr::createUser(std::string userName, } // Add the users object before sending out the signal - std::string userObj = std::string(usersObjPath) + "/" + userName; + sdbusplus::message::object_path tempObjPath(usersObjPath); + tempObjPath /= userName; + std::string userObj(tempObjPath); std::sort(groupNames.begin(), groupNames.end()); usersList.emplace( userName, std::move(std::make_unique( @@ -392,7 +394,9 @@ void UserMgr::renameUser(std::string userName, std::string newUserName) std::string priv = user.get()->userPrivilege(); std::vector groupNames = user.get()->userGroups(); bool enabled = user.get()->userEnabled(); - std::string newUserObj = std::string(usersObjPath) + "/" + newUserName; + sdbusplus::message::object_path tempObjPath(usersObjPath); + tempObjPath /= newUserName; + std::string newUserObj(tempObjPath); // Special group 'ipmi' needs a way to identify user renamed, in order to // update encrypted password. It can't rely only on InterfacesRemoved & // InterfacesAdded. So first send out userRenamed signal. @@ -1159,7 +1163,9 @@ void UserMgr::initUserObjects(void) } } // Add user objects to the Users path. - auto objPath = std::string(usersObjPath) + "/" + user; + sdbusplus::message::object_path tempObjPath(usersObjPath); + tempObjPath /= user; + std::string objPath(tempObjPath); std::sort(userGroups.begin(), userGroups.end()); usersList.emplace(user, std::move(std::make_unique( diff --git a/users.cpp b/users.cpp index 18b552aa..4efc2b27 100644 --- a/users.cpp +++ b/users.cpp @@ -62,7 +62,7 @@ Users::Users(sdbusplus::bus::bus& bus, const char* path, std::vector groups, std::string priv, bool enabled, UserMgr& parent) : Interfaces(bus, path, true), - userName(std::filesystem::path(path).filename()), manager(parent) + userName(sdbusplus::message::object_path(path).filename()), manager(parent) { UsersIface::userPrivilege(priv, true); UsersIface::userGroups(groups, true);