View | Details | Raw Unified | Return to bug 9780 | Differences between
and this patch

Collapse All | Expand All

(-)a/hw/xwin/InitOutput.c (-2 lines)
Lines 1013-1023 InitOutput (ScreenInfo *screenInfo, int argc, char *argv[]) Link Here
1013
1013
1014
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
1014
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
1015
1015
1016
#if defined(XCSECURITY)
1017
  /* Generate a cookie used by internal clients for authorization */
1016
  /* Generate a cookie used by internal clients for authorization */
1018
  if (g_fXdmcpEnabled || g_fAuthEnabled)
1017
  if (g_fXdmcpEnabled || g_fAuthEnabled)
1019
    winGenerateAuthorization ();
1018
    winGenerateAuthorization ();
1020
#endif
1021
1019
1022
  /* Perform some one time initialization */
1020
  /* Perform some one time initialization */
1023
  if (1 == serverGeneration)
1021
  if (1 == serverGeneration)
(-)a/hw/xwin/win.h (-2 / +1 lines)
Lines 768-777 winAllocateCmapPrivates (ColormapPtr pCmap); Link Here
768
 */
768
 */
769
769
770
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
770
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
771
# if defined(XCSECURITY)  
772
Bool
771
Bool
773
winGenerateAuthorization (void);
772
winGenerateAuthorization (void);
774
# endif
773
void winSetAuthorization(void);
775
#endif
774
#endif
776
775
777
776
(-)a/hw/xwin/winauth.c (-16 / +87 lines)
Lines 1-7 Link Here
1
#ifdef HAVE_XWIN_CONFIG_H
2
#include <xwin-config.h>
3
#endif
4
#if defined(XCSECURITY)
5
/*
1
/*
6
 *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
2
 *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
7
 *
3
 *
Lines 32-43 Link Here
32
 * Authors:	Harold L Hunt II
28
 * Authors:	Harold L Hunt II
33
 */
29
 */
34
30
31
#ifdef HAVE_XWIN_CONFIG_H
32
#include <xwin-config.h>
33
#endif
34
35
#include "win.h"
35
#include "win.h"
36
36
37
/* Includes for authorization */
37
/* Includes for authorization */
38
#include <X11/Xauth.h>
39
#include "securitysrv.h"
38
#include "securitysrv.h"
40
#include <X11/extensions/securstr.h>
41
39
42
40
43
/*
41
/*
Lines 48-60 Link Here
48
46
49
47
50
/*
48
/*
51
 * Globals
49
 * Locals
50
 */
51
52
static XID g_authId = 0;
53
static unsigned int g_uiAuthDataLen = 0;
54
static char *g_pAuthData = NULL;
55
56
/*
57
 * Code to generate a MIT-MAGIC-COOKIE-1, copied from under XCSECURITY
52
 */
58
 */
53
59
54
XID		g_authId = 0;
60
#ifndef XCSECURITY
55
unsigned int	g_uiAuthDataLen = 0;
61
static
56
char		*g_pAuthData = NULL;
62
void
63
GenerateRandomData (int len, char *buf)
64
{
65
    int fd;
66
67
    fd = open("/dev/urandom", O_RDONLY);
68
    read(fd, buf, len);
69
    close(fd);
70
}
71
72
73
static char cookie[16]; /* 128 bits */
74
75
XID
76
static MitGenerateCookie (
77
    unsigned	data_length,
78
    char	*data,
79
    XID		id,
80
    unsigned	*data_length_return,
81
    char	**data_return)
82
{
83
    int i = 0;
84
    int status;
85
86
    while (data_length--)
87
    {
88
	cookie[i++] += *data++;
89
	if (i >= sizeof (cookie)) i = 0;
90
    }
91
    GenerateRandomData(sizeof (cookie), cookie);
92
    status = MitAddCookie(sizeof (cookie), cookie, id);
93
    if (!status)
94
    {
95
	id = -1;
96
    }
97
    else
98
    {
99
	*data_return = cookie;
100
	*data_length_return = sizeof (cookie);
101
    }
102
    return id;
103
}
57
104
105
static
106
XID
107
GenerateAuthorization(
108
	unsigned name_length,
109
	char	*name,
110
	unsigned data_length,
111
	char	*data,
112
	unsigned *data_length_return,
113
	char	**data_return)
114
{
115
    return MitGenerateCookie(data_length, data,
116
                             FakeClientID(0), data_length_return, data_return);
117
}
118
#endif
58
119
59
/*
120
/*
60
 * Generate authorization cookie for internal server clients
121
 * Generate authorization cookie for internal server clients
Lines 78-92 winGenerateAuthorization () Link Here
78
      ErrorF ("winGenerateAuthorization - GenerateAuthorization failed\n");
139
      ErrorF ("winGenerateAuthorization - GenerateAuthorization failed\n");
79
      goto auth_bailout;
140
      goto auth_bailout;
80
    }
141
    }
81
#if 0
142
82
  else
143
  else
83
    {
144
    {
84
      ErrorF ("winGenerateAuthorization - GenerateAuthorization success!\n"
145
      winDebug("winGenerateAuthorization - GenerateAuthorization success!\n"
85
	      "AuthDataLen: %d AuthData: %s\n",
146
	      "AuthDataLen: %d AuthData: %s\n",
86
	      g_uiAuthDataLen, g_pAuthData);
147
	      g_uiAuthDataLen, g_pAuthData);
87
    }
148
    }
88
#endif
149
89
  
150
#ifdef XCSECURITY
90
  /* Allocate structure for additional auth information */
151
  /* Allocate structure for additional auth information */
91
  pAuth = (SecurityAuthorizationPtr) 
152
  pAuth = (SecurityAuthorizationPtr) 
92
    xalloc (sizeof (SecurityAuthorizationRec));
153
    xalloc (sizeof (SecurityAuthorizationRec));
Lines 119-125 winGenerateAuthorization () Link Here
119
  
180
  
120
  /* Don't free the auth data, since it is still used internally */
181
  /* Don't free the auth data, since it is still used internally */
121
  pAuth = NULL;
182
  pAuth = NULL;
122
  
183
#endif
184
123
  return TRUE;
185
  return TRUE;
124
186
125
 auth_bailout:
187
 auth_bailout:
Lines 128-131 winGenerateAuthorization () Link Here
128
  
190
  
129
  return FALSE;
191
  return FALSE;
130
}
192
}
131
#endif
193
194
/* Use our generated cookie for authentication */
195
void
196
winSetAuthorization(void)
197
{
198
  XSetAuthorization (AUTH_NAME,
199
		     strlen (AUTH_NAME),
200
		     g_pAuthData,
201
		     g_uiAuthDataLen);
202
}
(-)a/hw/xwin/winclipboardthread.c (-18 / +1 lines)
Lines 38-64 Link Here
38
#ifdef __CYGWIN__
38
#ifdef __CYGWIN__
39
#include <errno.h>
39
#include <errno.h>
40
#endif
40
#endif
41
#include "X11/Xauth.h"
42
#include <X11/Xlibint.h>
41
#include <X11/Xlibint.h>
43
42
44
43
45
/*
44
/*
46
 * Constants
47
 */
48
49
#define AUTH_NAME	"MIT-MAGIC-COOKIE-1"
50
51
52
/*
53
 * References to external symbols
45
 * References to external symbols
54
 */
46
 */
55
47
56
extern Bool		g_fUnicodeClipboard;
48
extern Bool		g_fUnicodeClipboard;
57
extern unsigned long	serverGeneration;
49
extern unsigned long	serverGeneration;
58
#if defined(XCSECURITY)
59
extern unsigned int	g_uiAuthDataLen;
60
extern char		*g_pAuthData;
61
#endif
62
extern Bool		g_fClipboardStarted;
50
extern Bool		g_fClipboardStarted;
63
extern HWND		g_hwndClipboard;
51
extern HWND		g_hwndClipboard;
64
extern void		*g_pClipboardDisplay;
52
extern void		*g_pClipboardDisplay;
Lines 154-166 winClipboardProc (void *pvNotUsed) Link Here
154
      pthread_exit (NULL);
142
      pthread_exit (NULL);
155
    }
143
    }
156
144
157
#if defined(XCSECURITY)
158
  /* Use our generated cookie for authentication */
145
  /* Use our generated cookie for authentication */
159
  XSetAuthorization (AUTH_NAME,
146
  winSetAuthorization();
160
		     strlen (AUTH_NAME),
161
		     g_pAuthData,
162
		     g_uiAuthDataLen);
163
#endif
164
147
165
  /* Set error handler */
148
  /* Set error handler */
166
  XSetErrorHandler (winClipboardErrorHandler);
149
  XSetErrorHandler (winClipboardErrorHandler);
(-)a/hw/xwin/winmultiwindowwm.c (-14 / +5 lines)
Lines 86-93 extern void winUpdateRgnMultiWindow(WindowPtr pWin); Link Here
86
#endif
86
#endif
87
#define WIN_JMP_OKAY		0
87
#define WIN_JMP_OKAY		0
88
#define WIN_JMP_ERROR_IO	2
88
#define WIN_JMP_ERROR_IO	2
89
#define AUTH_NAME		"MIT-MAGIC-COOKIE-1"
90
91
89
92
/*
90
/*
93
 * Local structures
91
 * Local structures
Lines 136-146 typedef struct _XMsgProcArgRec { Link Here
136
134
137
extern char *display;
135
extern char *display;
138
extern void ErrorF (const char* /*f*/, ...);
136
extern void ErrorF (const char* /*f*/, ...);
139
#if defined(XCSECURITY)
140
extern unsigned int	g_uiAuthDataLen;
141
extern char		*g_pAuthData;
142
#endif
143
144
137
145
/*
138
/*
146
 * Prototypes for local functions
139
 * Prototypes for local functions
Lines 930-935 winMultiWindowXMsgProc (void *pArg) Link Here
930
923
931
  /* Print the display connection string */
924
  /* Print the display connection string */
932
  ErrorF ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
925
  ErrorF ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
926
927
  /* Use our generated cookie for authentication */
928
  winSetAuthorization();
933
  
929
  
934
  /* Initialize retry count */
930
  /* Initialize retry count */
935
  iRetries = 0;
931
  iRetries = 0;
Lines 1284-1297 winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) Link Here
1284
  /* Print the display connection string */
1280
  /* Print the display connection string */
1285
  ErrorF ("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay);
1281
  ErrorF ("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay);
1286
1282
1287
#if defined(XCSECURITY)
1288
  /* Use our generated cookie for authentication */
1283
  /* Use our generated cookie for authentication */
1289
  XSetAuthorization (AUTH_NAME,
1284
  winSetAuthorization();
1290
		     strlen (AUTH_NAME),
1285
1291
		     g_pAuthData,
1292
		     g_uiAuthDataLen);
1293
#endif
1294
  
1295
  /* Open the X display */
1286
  /* Open the X display */
1296
  do
1287
  do
1297
    {
1288
    {
(-)a/include/os.h (-1 / +2 lines)
Lines 388-393 extern int AddAuthorization( Link Here
388
    unsigned int	/*data_length*/,
388
    unsigned int	/*data_length*/,
389
    char *		/*data*/);
389
    char *		/*data*/);
390
390
391
#ifdef XCSECURITY
391
extern XID GenerateAuthorization(
392
extern XID GenerateAuthorization(
392
    unsigned int   /* name_length */,
393
    unsigned int   /* name_length */,
393
    char	*  /* name */,
394
    char	*  /* name */,
Lines 395-400 extern XID GenerateAuthorization( Link Here
395
    char	*  /* data */,
396
    char	*  /* data */,
396
    unsigned int * /* data_length_return */,
397
    unsigned int * /* data_length_return */,
397
    char	** /* data_return */);
398
    char	** /* data_return */);
399
#endif
398
400
399
extern int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/);
401
extern int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/);
400
402
401
- 

Return to bug 9780