Commit 349b6dec authored by Pauli Nieminen's avatar Pauli Nieminen Committed by Mike Gabriel

os: always check if client is local when connection is accepted

Backported from X.org: commit 2d67ada3c4079a11c52024a9c3d4138becca5171 Author: Pauli Nieminen <ext-pauli.nieminen@nokia.com> Date: Thu Dec 30 19:19:43 2010 +0200 os: always check if client is local when connection is accepted LocalClient is used for all DRI2 requests that makes it frequently called function. Querying if connection is local or not takes 10-15us (on ARM) depending on malloc speed. Signed-off-by: 's avatarPauli Nieminen <ext-pauli.nieminen@nokia.com> Reviewed-by: 's avatarDaniel Stone <daniel@fooishbar.org> Backported-to-NX-by: 's avatarMike Gabriel <mike.gabriel@das-netzwerkteam.de>
parent 239fe3d0
...@@ -1217,12 +1217,17 @@ ResetHosts (char *display) ...@@ -1217,12 +1217,17 @@ ResetHosts (char *display)
} }
/* Is client on the local host */ /* Is client on the local host */
Bool LocalClient(ClientPtr client) Bool
ComputeLocalClient(ClientPtr client)
{ {
int alen, family, notused; int alen, family, notused;
Xtransaddr *from = NULL; Xtransaddr *from = NULL;
void *addr; void *addr;
register HOST *host; register HOST *host;
OsCommPtr oc = (OsCommPtr) client->osPrivate;
if (!oc->trans_conn)
return FALSE;
#ifdef XCSECURITY #ifdef XCSECURITY
/* untrusted clients can't change host access */ /* untrusted clients can't change host access */
...@@ -1233,8 +1238,7 @@ Bool LocalClient(ClientPtr client) ...@@ -1233,8 +1238,7 @@ Bool LocalClient(ClientPtr client)
return FALSE; return FALSE;
} }
#endif #endif
if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn, if (!_XSERVTransGetPeerAddr (oc->trans_conn, &notused, &alen, &from))
&notused, &alen, &from))
{ {
family = ConvertAddr ((struct sockaddr *) from, family = ConvertAddr ((struct sockaddr *) from,
&alen, (void **)&addr); &alen, (void **)&addr);
...@@ -1260,6 +1264,13 @@ Bool LocalClient(ClientPtr client) ...@@ -1260,6 +1264,13 @@ Bool LocalClient(ClientPtr client)
return FALSE; return FALSE;
} }
Bool LocalClient(ClientPtr client)
{
if (!client->osPrivate)
return FALSE;
return ((OsCommPtr)client->osPrivate)->local_client;
}
/* /*
* Return the uid and gid of a connected local client * Return the uid and gid of a connected local client
* *
......
...@@ -754,6 +754,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) ...@@ -754,6 +754,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
free (oc); free (oc);
return NullClient; return NullClient;
} }
oc->local_client = ComputeLocalClient(client);
{ {
#if !defined(WIN32) #if !defined(WIN32)
ConnectionTranslation[fd] = client->index; ConnectionTranslation[fd] = client->index;
......
...@@ -176,6 +176,7 @@ typedef struct _osComm { ...@@ -176,6 +176,7 @@ typedef struct _osComm {
XID auth_id; /* authorization id */ XID auth_id; /* authorization id */
CARD32 conn_time; /* timestamp if not established, else 0 */ CARD32 conn_time; /* timestamp if not established, else 0 */
struct _XtransConnInfo *trans_conn; /* transport connection object */ struct _XtransConnInfo *trans_conn; /* transport connection object */
Bool local_client;
} OsCommRec, *OsCommPtr; } OsCommRec, *OsCommPtr;
extern int FlushClient( extern int FlushClient(
...@@ -239,6 +240,9 @@ typedef long int fd_mask; ...@@ -239,6 +240,9 @@ typedef long int fd_mask;
#define ffs mffs #define ffs mffs
extern int mffs(fd_mask); extern int mffs(fd_mask);
/* in access.c */
extern Bool ComputeLocalClient(ClientPtr client);
/* in auth.c */ /* in auth.c */
extern void GenerateRandomData (int len, char *buf); extern void GenerateRandomData (int len, char *buf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment