Fix duplicate entries in session userGroups
The user's groups were getting re-appended in the session object on
every request, resulting in a small memory leak (that does clear away
when the session is ended). Fix by just overwriting instead of
appending.
Tested: Added debug prints in ~UserSession to check contents of
userGroups, then ran multiple GETs to /redfish/v1 via token auth, then
destroyed session via WebUI and confirmed userGroups contained correct
set of groups.
Change-Id: I7c04a18437f69a97f138ff1f9aeee2731952ae8b
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
diff --git a/include/dbus_privileges.hpp b/include/dbus_privileges.hpp
index fca4a13..7fb545a 100644
--- a/include/dbus_privileges.hpp
+++ b/include/dbus_privileges.hpp
@@ -83,11 +83,11 @@
if (userGroups != nullptr)
{
- // Populate session with user groups.
- for (const auto& userGroup : *userGroups)
- {
- req.session->userGroups.emplace_back(userGroup);
- }
+ req.session->userGroups = *userGroups;
+ }
+ else
+ {
+ req.session->userGroups.clear();
}
return true;