[PATCH] os: Delete the XDM client when a connection is closed.
Michał Górny
mgorny at gentoo.org
Mon Oct 18 09:25:48 PDT 2010
This patch introduces a concept of ClientPtr tracking in the xdm auth
code. It makes sure that the xdm authentication data for a particular
client is removed immediately when the client disconnects, making the
semi-random client identifier reusable.
This should fix the `XDM authorization key matches an existing client!'
issue whenever an application uses an X11 display and then exec()s
an another application expecting to use the display. Such an issue was
observed with OpenOffice.org and SDL applications, when xdm was used as
the display manager.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=10665
Signed-off-by: Michał Górny <mgorny at gentoo.org>
---
dix/dispatch.c | 1 +
include/os.h | 2 ++
os/xdmauth.c | 24 ++++++++++++++++++++++++
3 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/dix/dispatch.c b/dix/dispatch.c
index b66861f..36e6785 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3403,6 +3403,7 @@ CloseDownClient(ClientPtr client)
DeleteClientFromAnySelections(client);
ReleaseActiveGrabs(client);
DeleteClientFontStuff(client);
+ XdmDeleteClient(client);
if (!really_close_down)
{
/* This frees resources that should never be retained
diff --git a/include/os.h b/include/os.h
index efa202c..15be6b4 100644
--- a/include/os.h
+++ b/include/os.h
@@ -554,4 +554,6 @@ extern _X_EXPORT void LogPrintMarkers(void);
extern _X_EXPORT void xorg_backtrace(void);
+extern _X_EXPORT void XdmDeleteClient(ClientPtr /*client*/);
+
#endif /* OS_H */
diff --git a/os/xdmauth.c b/os/xdmauth.c
index b8cbada..7a9eb28 100644
--- a/os/xdmauth.c
+++ b/os/xdmauth.c
@@ -178,6 +178,7 @@ typedef struct _XdmClientAuth {
XdmAuthKeyRec rho;
char client[6];
long time;
+ ClientPtr xclient;
} XdmClientAuthRec, *XdmClientAuthPtr;
static XdmClientAuthPtr xdmClients;
@@ -392,6 +393,7 @@ XdmCheckCookie (unsigned short cookie_length, const char *cookie,
XdmcpUnwrap ((unsigned char *)cookie, (unsigned char *)&auth->key, plain, cookie_length);
if ((client = XdmAuthorizationValidate (plain, cookie_length, &auth->rho, xclient, reason)) != NULL)
{
+ client->xclient = xclient;
client->next = xdmClients;
xdmClients = client;
free(plain);
@@ -496,4 +498,26 @@ XdmRemoveCookie (unsigned short data_length, const char *data)
return 0;
}
+void
+XdmDeleteClient (ClientPtr xclient)
+{
+ XdmClientAuthPtr client, next, prev;
+
+ prev = 0;
+ for (client = xdmClients; client; client=next)
+ {
+ next = client->next;
+ if (client->xclient == xclient)
+ {
+ if (prev)
+ prev->next = next;
+ else
+ xdmClients = next;
+ free(client);
+ }
+ else
+ prev = client;
+ }
+}
+
#endif
--
1.7.3.1
More information about the xorg-devel
mailing list