提交 ebf78be4 编写于 作者: D Daniel P. Berrange

Set the current client identity during API call dispatch

When dispatching an RPC API call, setup the current identity to
hold the identity of the network client associated with the
RPC message being dispatched. The setting is thread-local, so
only affects the API call in this thread
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 d5e83ad9
......@@ -375,6 +375,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
virNetServerProgramProcPtr dispatcher;
virNetMessageError rerr;
size_t i;
virIdentityPtr identity = NULL;
memset(&rerr, 0, sizeof(rerr));
......@@ -419,6 +420,12 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
if (virNetMessageDecodePayload(msg, dispatcher->arg_filter, arg) < 0)
goto error;
if (!(identity = virNetServerClientGetIdentity(client)))
goto error;
if (virIdentitySetCurrent(identity) < 0)
goto error;
/*
* When the RPC handler is called:
*
......@@ -431,6 +438,9 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
*/
rv = (dispatcher->func)(server, client, msg, &rerr, arg, ret);
if (virIdentitySetCurrent(NULL) < 0)
goto error;
/*
* If rv == 1, this indicates the dispatch func has
* populated 'msg' with a list of FDs to return to
......@@ -481,6 +491,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
VIR_FREE(arg);
VIR_FREE(ret);
virObjectUnref(identity);
/* Put reply on end of tx queue to send out */
return virNetServerClientSendMessage(client, msg);
......@@ -491,6 +502,7 @@ error:
VIR_FREE(arg);
VIR_FREE(ret);
virObjectUnref(identity);
return rv;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册