From f977b1af1ffc20407377ea98fe6586fac11756a1 Mon Sep 17 00:00:00 2001 From: Richard Marian Thomaiyar Date: Mon, 16 Jul 2018 23:50:51 +0530 Subject: User home directory fixups. Needed for SSH User home directory fixups, needed for SSH to work properly. With this patch, home directory is created for all users created and deleted, when users are removed. Test: Performed user creation, deletion test case and made sure it is properly reflected in user manager and in ipmi. Change-Id: If7d79c67784191e0cccb3f6c22f4e191fd0bbc84 Signed-off-by: Richard Marian Thomaiyar --- user_mgr.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/user_mgr.cpp b/user_mgr.cpp index ebed493..f407133 100644 --- a/user_mgr.cpp +++ b/user_mgr.cpp @@ -274,7 +274,7 @@ void UserMgr::createUser(std::string userName, try { executeCmd("/usr/sbin/useradd", userName.c_str(), "-G", groups.c_str(), - "-M", "-N", "-s", + "-m", "-N", "-s", (sshRequested ? "/bin/sh" : "/bin/nologin"), "-e", (enabled ? "" : "1970-01-02")); } @@ -303,7 +303,7 @@ void UserMgr::deleteUser(std::string userName) throwForUserDoesNotExist(userName); try { - executeCmd("/usr/sbin/userdel", userName.c_str()); + executeCmd("/usr/sbin/userdel", userName.c_str(), "-r"); } catch (const InternalFailure &e) { @@ -329,8 +329,9 @@ void UserMgr::renameUser(std::string userName, std::string newUserName) usersList[userName].get()->userGroups()); try { + std::string newHomeDir = "/home/" + newUserName; executeCmd("/usr/sbin/usermod", "-l", newUserName.c_str(), - userName.c_str()); + userName.c_str(), "-d", newHomeDir.c_str(), "-m"); } catch (const InternalFailure &e) { -- cgit v1.2.1