summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMyung Bae <myungbae@us.ibm.com>2024-02-24 18:50:23 +0300
committerEd Tanous <ed@tanous.net>2024-02-28 19:37:41 +0300
commit41b25aa3a541a0f92dee53b89064f655ac5e11cb (patch)
tree9a1f74aa50dad8ac253b6b86f3657771dd7d8da9 /include
parent490d74d6b4f07b9e818b0c3ba23ee2754eb9e393 (diff)
downloadbmcweb-41b25aa3a541a0f92dee53b89064f655ac5e11cb.tar.xz
Fix coredump on async method during validatePrivilege
PATCH may cause bmcweb to coredump depending on timing of `validatePrivilege` execution. It is because `req' is captured as reference, and it may be cleared-up before async-call method completes. (This problem can be seen more frequently by enabling debug mode). This commit is to keep `req` during to async-method execution. Tested: - Create a ReadOnly user - here, called as `readonly` - Using `redfishtool`, run PATCH on `readonly` user role. ``` $ redfishtool -vvvvv raw -r ${bmc}:18080 -u ${user} -p ${password} -S Always PATCH /redfish/v1/AccountService/Accounts/readonly --data='{"RoleId":"Administrator"}' ... This sometimes fails because bmcweb coredump ``` After: ``` $ redfishtool raw -r ${bmc}:18080 -u ${user} -p ${password} -S Always PATCH /redfish/v1/AccountService/Accounts/readonly --data='{"RoleId":"Administrator"}' { "@odata.id": "/redfish/v1/AccountService/Accounts/readonly", "@odata.type": "#ManagerAccount.v1_7_0.ManagerAccount", ... } ``` Change-Id: I2a28d1743cfc0fbd9239f69dec5584b34c7ebe43 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/dbus_privileges.hpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/dbus_privileges.hpp b/include/dbus_privileges.hpp
index 6602a5c2fa..b2bb1e3b70 100644
--- a/include/dbus_privileges.hpp
+++ b/include/dbus_privileges.hpp
@@ -150,7 +150,8 @@ void validatePrivilege(Request& req,
}
std::string username = req.session->username;
crow::connections::systemBus->async_method_call(
- [&req, asyncResp, &rule, callback(std::forward<CallbackFn>(callback))](
+ [req{std::move(req)}, asyncResp, &rule,
+ callback(std::forward<CallbackFn>(callback))](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& userInfoMap) mutable {
afterGetUserInfo(req, asyncResp, rule,