aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winauth.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xwin/winauth.c')
-rw-r--r--xorg-server/hw/xwin/winauth.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/xorg-server/hw/xwin/winauth.c b/xorg-server/hw/xwin/winauth.c
index 7d4372549..b603f70f5 100644
--- a/xorg-server/hw/xwin/winauth.c
+++ b/xorg-server/hw/xwin/winauth.c
@@ -32,12 +32,15 @@
#include <xwin-config.h>
#endif
+#define GC X11_GC /* To avoid compilation errors later when including win.h (which also defines the GC type) */
+#include <X11/Xlib.h>
+#undef GC
+
#include "win.h"
/* Includes for authorization */
#include "securitysrv.h"
-
/*
* Constants
*/
@@ -57,16 +60,29 @@ static char *g_pAuthData = NULL;
* Code to generate a MIT-MAGIC-COOKIE-1, copied from under XCSECURITY
*/
+
+
#ifndef XCSECURITY
static
void
GenerateRandomData (int len, char *buf)
{
int fd;
+#ifdef _MSC_VER
+ static HANDLE hAdvApi32;
+ static BOOLEAN (_stdcall * RtlGenRandom)(void *,unsigned long);
+ if (!hAdvApi32)
+ {
+ hAdvApi32=LoadLibrary("advapi32.dll");
+ RtlGenRandom=(BOOLEAN (_stdcall *)(void*,unsigned long))GetProcAddress(hAdvApi32,"SystemFunction036");
+ }
+ RtlGenRandom(buf, len);
+#else
fd = open("/dev/urandom", O_RDONLY);
read(fd, buf, len);
close(fd);
+#endif
}
@@ -124,7 +140,6 @@ GenerateAuthorization(
Bool
winGenerateAuthorization (void)
{
- Bool fFreeAuth = FALSE;
SecurityAuthorizationPtr pAuth = NULL;
/* Call OS layer to generate authorization key */
@@ -139,13 +154,14 @@ winGenerateAuthorization (void)
ErrorF ("winGenerateAuthorization - GenerateAuthorization failed\n");
goto auth_bailout;
}
-
+#ifdef WINDBG
else
{
winDebug("winGenerateAuthorization - GenerateAuthorization success!\n"
"AuthDataLen: %d AuthData: %s\n",
g_uiAuthDataLen, g_pAuthData);
}
+#endif
#ifdef XCSECURITY
/* Allocate structure for additional auth information */
@@ -174,19 +190,16 @@ winGenerateAuthorization (void)
pAuth))
{
ErrorF ("winGenerateAuthorization - AddResource failed for auth.\n");
- fFreeAuth = TRUE;
goto auth_bailout;
}
/* Don't free the auth data, since it is still used internally */
- pAuth = NULL;
#endif
return TRUE;
auth_bailout:
- if (fFreeAuth)
- free(pAuth);
+ free(pAuth);
return FALSE;
}
@@ -195,6 +208,7 @@ winGenerateAuthorization (void)
void
winSetAuthorization(void)
{
+ if (g_pAuthData)
XSetAuthorization (AUTH_NAME,
strlen (AUTH_NAME),
g_pAuthData,