diff options
author | Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> | 2018-07-16 23:50:51 +0530 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-10-01 20:26:48 -0400 |
commit | f977b1af1ffc20407377ea98fe6586fac11756a1 (patch) | |
tree | 1999ec58da834e9ef64c2e8d315e3b86f1d8cc23 /user_mgr.cpp | |
parent | 2cb2e7208e512de2cc6be5361ec6aed480079eb4 (diff) | |
download | phosphor-user-manager-f977b1af1ffc20407377ea98fe6586fac11756a1.tar.gz phosphor-user-manager-f977b1af1ffc20407377ea98fe6586fac11756a1.zip |
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 <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'user_mgr.cpp')
-rw-r--r-- | user_mgr.cpp | 7 |
1 files 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) { |