Fix to include user id 0 in users list.
Fix to include user id 0 in users list of user manager service.
This enables to list out the user present in /etc/passwd file
even if it is root user with user id 0.
Unit test:
1. Made sure phosphor-user-manager service loads successfully
2. It listed root user / any user already present in /etc/passwd file.
Change-Id: I060d9581b7f433411e313b745d9d1b32e8680b7d
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/user_mgr.cpp b/user_mgr.cpp
index f407133..cba9366 100644
--- a/user_mgr.cpp
+++ b/user_mgr.cpp
@@ -456,8 +456,10 @@
// Any error, break the loop.
break;
}
- // All users whose UID >= 1000 and < 65534
- if ((pwp->pw_uid >= 1000) && (pwp->pw_uid < 65534))
+ // Add all users whose UID >= 1000 and < 65534
+ // and special UID 0.
+ if ((pwp->pw_uid == 0) ||
+ ((pwp->pw_uid >= 1000) && (pwp->pw_uid < 65534)))
{
std::string userName(pwp->pw_name);
userList.emplace_back(userName);