Add option to enable / disable root user mgmt.
Provided option to enable / disable managing root user
under phosphor-user-manager. Default root user is managed
by phosphor-user-manager, but can be disbaled if needed.
Tested:
1. Verified that root user is listed as an object,
in default build
2. Verified that root user is not listed as an object with
EXTRA_OECONF += "--disable-root_user_mgmt"
Change-Id: I5efdf99746739e8ae77e78056893ee5f635364ea
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/configure.ac b/configure.ac
index 7f487ca..5c6a6fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,13 @@
AC_DEFINE_UNQUOTED([LDAP_CONF_PERSIST_PATH], ["$LDAP_CONF_PERSIST_PATH"], \
[path of directory having persisted LDAP configuration enabled property.])
+AS_IF([test "x$enable_root_user_mgmt" != "xno"],
+ AC_MSG_NOTICE([Enable managing root user])
+ [cpp_flags="-DENABLE_ROOT_USER_MGMT"]
+ AC_SUBST([CPPFLAGS], [$cpp_flags]),
+ AC_MSG_WARN([Disable managing root user])
+)
+
AC_DEFINE(SYSTEMD_BUSNAME, "org.freedesktop.systemd1", [systemd busname.])
AC_DEFINE(SYSTEMD_PATH, "/org/freedesktop/systemd1", [systemd path.])
AC_DEFINE(SYSTEMD_INTERFACE, "org.freedesktop.systemd1.Manager", [systemd interface.])
diff --git a/user_mgr.cpp b/user_mgr.cpp
index 17146e6..2f22323 100644
--- a/user_mgr.cpp
+++ b/user_mgr.cpp
@@ -752,10 +752,15 @@
// Any error, break the loop.
break;
}
+#ifdef ENABLE_ROOT_USER_MGMT
// 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)))
+#else
+ // Add all users whose UID >=1000 and < 65534
+ if ((pwp->pw_uid >= 1000) && (pwp->pw_uid < 65534))
+#endif
{
std::string userName(pwp->pw_name);
userList.emplace_back(userName);