BugFix: user name contains invalid characters
There is an typo in the policy "[a-zA-z_]" configuration.
It it should be "[a-zA-Z_]"
Tested: Create a username contains invalid characters like: ^, [, or ].
Before: invalid character can be added as username
ipmitool user list 1
ID Name Callin
4 ^test true
5 [test true
7 ]test true
8 _test true
After: error will be returned once user name has invalid character.
ipmitool user set name 4 ^test4
Set User Name command failed (user 4, name ^test4): Unspecified error
Change-Id: I28a7f36f10b44b59909536214e6688c1895ac14f
Signed-off-by: nichanghao.nch <nichanghao@linux.alibaba.com>
diff --git a/user_channel/user_mgmt.cpp b/user_channel/user_mgmt.cpp
index 4ec61d5..97e6a8c 100644
--- a/user_channel/user_mgmt.cpp
+++ b/user_channel/user_mgmt.cpp
@@ -565,7 +565,7 @@
return false;
}
if (!std::regex_match(userName.c_str(),
- std::regex("[a-zA-z_][a-zA-Z_0-9]*")))
+ std::regex("[a-zA-Z_][a-zA-Z_0-9]*")))
{
log<level::ERR>("Unsupported characters in user name");
return false;