summaryrefslogtreecommitdiffstats
path: root/user_mgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'user_mgr.cpp')
-rw-r--r--user_mgr.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/user_mgr.cpp b/user_mgr.cpp
index 3987088..ebed493 100644
--- a/user_mgr.cpp
+++ b/user_mgr.cpp
@@ -263,12 +263,14 @@ void UserMgr::createUser(std::string userName,
// treat privilege as a group - This is to avoid using different file to
// store the same.
- if (groups.size() != 0)
+ if (!priv.empty())
{
- groups += ",";
+ if (groups.size() != 0)
+ {
+ groups += ",";
+ }
+ groups += priv;
}
- groups += priv;
-
try
{
executeCmd("/usr/sbin/useradd", userName.c_str(), "-G", groups.c_str(),
@@ -381,11 +383,14 @@ void UserMgr::updateGroupsAndPriv(const std::string &userName,
// treat privilege as a group - This is to avoid using different file to
// store the same.
- if (groups.size() != 0)
+ if (!priv.empty())
{
- groups += ",";
+ if (groups.size() != 0)
+ {
+ groups += ",";
+ }
+ groups += priv;
}
- groups += priv;
try
{
executeCmd("/usr/sbin/usermod", userName.c_str(), "-G", groups.c_str(),
OpenPOWER on IntegriCloud