From 686a463a87a1c7e5e3f6f833872dc6365bdac401 Mon Sep 17 00:00:00 2001 From: sjanusz-r7 Date: Thu, 12 Dec 2024 12:57:20 +0000 Subject: [PATCH] Keep track of RPC token per-thread --- lib/msf/core/rpc/v10/service.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/msf/core/rpc/v10/service.rb b/lib/msf/core/rpc/v10/service.rb index 90f8c3b3e6d8..81dfbbb99064 100644 --- a/lib/msf/core/rpc/v10/service.rb +++ b/lib/msf/core/rpc/v10/service.rb @@ -140,11 +140,16 @@ def process(req) end end - ::Timeout.timeout(self.dispatcher_timeout) { self.handlers[group].send(mname, *msg) } + ::Timeout.timeout(self.dispatcher_timeout) do + Thread.current[:rpc_token] = token + self.handlers[group].send(mname, *msg) + end rescue ::Exception => e elog('RPC Exception', error: e) process_exception(e) + ensure + Thread.current[:rpc_token] = nil end end