Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
spice-vdagent.17026
vdagentd-Limit-number-of-agents-per-session-to-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File vdagentd-Limit-number-of-agents-per-session-to-1.patch of Package spice-vdagent.17026
From 18515ccb7bb1a06dc493cdcc9d9914f780601d3e Mon Sep 17 00:00:00 2001 From: Frediano Ziglio <freddy77@gmail.com> Date: Thu, 24 Sep 2020 12:13:44 +0100 Subject: [PATCH 18/20] vdagentd: Limit number of agents per session to 1 Git-commit: 6276162c48c0968763bf98a96e0c572a6c92bb99 References: bsc#1173749 Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Acked-by: Uri Lublin <uril@redhat.com> Signed-off-by: Bruce Rogers <brogers@suse.com> --- src/vdagentd/vdagentd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c index 68cf63f..90eacbe 100644 --- a/src/vdagentd/vdagentd.c +++ b/src/vdagentd/vdagentd.c @@ -916,6 +916,20 @@ static gboolean remove_active_xfers(gpointer key, gpointer value, gpointer conn) return 0; } +/* Check if this connection matches the passed session */ +static int connection_matches_session(UdscsConnection *conn, void *priv) +{ + const char *session = priv; + const struct agent_data *agent_data = g_object_get_data(G_OBJECT(conn), "agent_data"); + + if (!agent_data || !agent_data->session || + strcmp(agent_data->session, session) != 0) { + return 0; + } + + return 1; +} + /* Check a given process has a given UID */ static bool check_uid_of_pid(pid_t pid, uid_t uid) { @@ -970,6 +984,16 @@ static void agent_connect(struct udscs_connection *conn) udscs_server_destroy_connection(server, conn); return; } + + // Check there are no other connection for this session + // Note that "conn" is not counted as "agent_data" is still not attached to it + if (udscs_server_for_all_clients(server, connection_matches_session, + agent_data->session) > 0) { + syslog(LOG_ERR, "An agent is already connected for this session"); + agent_data_destroy(agent_data); + udscs_server_destroy_connection(server, conn); + return; + } } g_object_set_data_full(G_OBJECT(conn), "agent_data", agent_data, -- 2.29.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor