Files
OpenBMC/meta-luxshare/recipes-phosphor/user/phosphor-user-manager/0001-Move-user-home-to-tmp-instead.patch
T
2026-04-23 17:07:55 +08:00

65 lines
3.0 KiB
Diff
Executable File

From b814451f0d9301d3ad9210154512cbee4eaaac9b Mon Sep 17 00:00:00 2001
From: "Chen.Zhao" <zhao.chen@luxshare-ict.com>
Date: Tue, 10 Dec 2024 15:30:10 +0800
Subject: [PATCH] Move user home to tmp instead
When creat new user or modify user name, because the user HOME is default in /home, BMC can't move
/home/xxx to another folder. So move user HOME to /tmp to fix this issue.
Tested:
D:\Software\ipmitool_win_18>ipmitool -I lanplus -H 10.67.13.44 -U test -P Admin@9000 user set name 2 testtest
D:\Software\ipmitool_win_18>ipmitool -I lanplus -H 10.67.13.44 -U test -P Admin@9000 user list 1
ID Name Callin Link Auth IPMI Msg Channel Priv Limit
1 root false true true ADMINISTRATOR
2 testtest false true true ADMINISTRATOR
3 test false true true ADMINISTRATOR
4 true false false NO ACCESS
5 true false false NO ACCESS
6 true false false NO ACCESS
7 true false false NO ACCESS
8 true false false NO ACCESS
9 true false false NO ACCESS
10 true false false NO ACCESS
11 true false false NO ACCESS
12 true false false NO ACCESS
13 true false false NO ACCESS
14 true false false NO ACCESS
15 true false false NO ACCESS
---
user_mgr.cpp | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/user_mgr.cpp b/user_mgr.cpp
index 5bb1509..873ee1d 100644
--- a/user_mgr.cpp
+++ b/user_mgr.cpp
@@ -1609,9 +1609,10 @@ void UserMgr::executeUserAdd(const char* userName, const char* groups,
{
// set EXPIRE_DATE to 0 to disable user, PAM takes 0 as expire on
// 1970-01-01, that's an implementation-defined behavior
- executeCmd("/usr/sbin/useradd", userName, "-G", groups, "-m", "-N", "-s",
- (sshRequested ? "/bin/sh" : "/sbin/nologin"), "-e",
- (enabled ? "" : "1970-01-01"));
+ executeCmd("/usr/sbin/useradd", userName, "-G", groups, "-M", "-d", "/tmp",
+ "-N", "-s", (sshRequested ? "/bin/sh" : "/sbin/nologin"), "-e",
+ (enabled ? "" : "1970-01-01"));
+
}
void UserMgr::executeUserDelete(const char* userName)
@@ -1628,8 +1629,9 @@ void UserMgr::executeUserRename(const char* userName, const char* newUserName)
{
std::string newHomeDir = "/home/";
newHomeDir += newUserName;
- executeCmd("/usr/sbin/usermod", "-l", newUserName, userName, "-d",
- newHomeDir.c_str(), "-m");
+ // Do not create new home, and re-use /tmp as home for the user
+ executeCmd("/usr/sbin/usermod", "-l", newUserName, userName, "-d", "/tmp");
+
}
void UserMgr::executeUserModify(const char* userName, const char* newGroups,
--
2.25.1