SetUserName to return success - for same user name
Updated code to return IPMI_CC_OK, if set user name is requested
to update with the same name for the user id.
Unit-Test:
Verified set user name for same user id with same name succeeds twice
Verified negative case too.
ipmitool -I lanplus -H xx.xx.xx.xx -U root -P 0penBmc user set name 2 test
ipmitool -I lanplus -H xx.xx.xx.xx -U root -P 0penBmc user set name 2 test
Change-Id: I31c45a3f02ea5de535a27ddfd159b1b6fa4a4b1a
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/user_channel/user_mgmt.cpp b/user_channel/user_mgmt.cpp
index 8ba4a94..641abf0 100644
--- a/user_channel/user_mgmt.cpp
+++ b/user_channel/user_mgmt.cpp
@@ -769,12 +769,17 @@
boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>
userLock{*userMutex};
- bool validUser = isValidUserName(userNameInChar);
std::string oldUser;
getUserName(userId, oldUser);
- UserInfo* userInfo = getUserInfo(userId);
std::string newUser(userNameInChar, 0, ipmiMaxUserName);
+ if (oldUser == newUser)
+ {
+ // requesting to set the same user name, return success.
+ return IPMI_CC_OK;
+ }
+ bool validUser = isValidUserName(userNameInChar);
+ UserInfo* userInfo = getUserInfo(userId);
if (newUser.empty() && !oldUser.empty())
{
// Delete existing user