[PATCH] os: Delete the XDM client when a connection is closed.

Tiago Vignatti tiago.vignatti at nokia.com
Mon Oct 18 12:44:27 PDT 2010


On Mon, Oct 18, 2010 at 06:25:48PM +0200, ext Michał Górny wrote:
> 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);

this is too specific code to be inside dix. I'm not sure about the real
needs of your patch but we may want to enhance struct protocol (os/auth.c)
adding a new function pointer to be triggered whenever a client is
disconnected. 


>  	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*/);

then, given the comments above, inside os/osdep.h embraced by HASXDMAUTH would
be convenient.

> +
>  #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
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
             Tiago


More information about the xorg-devel mailing list