changeset 606 | 068c11b419c9 |
parent 470 | 77e77d76a7c9 |
child 614 | 5ef3ebaba4c3 |
605:e5259db5befc | 606:068c11b419c9 |
---|---|
1 /* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
1 /* Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
2 * |
2 * |
3 * Permission is hereby granted, free of charge, to any person obtaining a |
3 * Permission is hereby granted, free of charge, to any person obtaining a |
4 * copy of this software and associated documentation files (the |
4 * copy of this software and associated documentation files (the |
5 * "Software"), to deal in the Software without restriction, including |
5 * "Software"), to deal in the Software without restriction, including |
6 * without limitation the rights to use, copy, modify, merge, publish, |
6 * without limitation the rights to use, copy, modify, merge, publish, |
22 * |
22 * |
23 * Except as contained in this notice, the name of a copyright holder |
23 * Except as contained in this notice, the name of a copyright holder |
24 * shall not be used in advertising or otherwise to promote the sale, use |
24 * shall not be used in advertising or otherwise to promote the sale, use |
25 * or other dealings in this Software without prior written authorization |
25 * or other dealings in this Software without prior written authorization |
26 * of the copyright holder. |
26 * of the copyright holder. |
27 */ |
27 */ |
28 |
28 |
29 #pragma ident "@(#)tsolprotocol.c 1.24 08/07/21 SMI" |
29 #pragma ident "@(#)tsolprotocol.c 1.25 09/01/14 SMI" |
30 |
30 |
31 #ifdef HAVE_DIX_CONFIG_H |
31 #ifdef HAVE_DIX_CONFIG_H |
32 #include <dix-config.h> |
32 #include <dix-config.h> |
33 #endif |
33 #endif |
34 |
34 |
35 #include <sys/param.h> |
35 #include <sys/param.h> |
36 #include <fcntl.h> |
36 #include <fcntl.h> |
37 #include <sys/types.h> |
37 #include <sys/types.h> |
38 #include <sys/stat.h> |
38 #include <sys/stat.h> |
58 #include "servermd.h" |
58 #include "servermd.h" |
59 #ifdef PANORAMIX |
59 #ifdef PANORAMIX |
60 #include "../Xext/panoramiXsrv.h" |
60 #include "../Xext/panoramiXsrv.h" |
61 #endif |
61 #endif |
62 #ifdef XCSECURITY |
62 #ifdef XCSECURITY |
63 #define _SECURITY_SERVER |
63 #include "../Xext/securitysrv.h" |
64 #include "security.h" |
|
65 #endif |
64 #endif |
65 #include "xace.h" |
|
66 #include "xacestr.h" |
|
67 |
|
68 #define CALLBACK(name) void \ |
|
69 name(CallbackListPtr *pcbl, pointer nulldata, pointer calldata) |
|
66 |
70 |
67 /* |
71 /* |
68 * The event # here match those in /usr/include/bsm/audit_uevents.h. |
72 * The event # here match those in /usr/include/bsm/audit_uevents.h. |
69 * Changes in one should go with corresponding changes in another. |
73 * Changes in one should go with corresponding changes in another. |
70 */ |
74 */ |
71 |
75 |
72 #define MAX_AUDIT_EVENTS 100 |
76 #define MAX_AUDIT_EVENTS 100 |
73 |
77 |
74 int audit_eventsid[100][2] = { |
78 int audit_eventsid[100][2] = { |
75 X_CreateWindow, AUE_CreateWindow, |
79 { X_CreateWindow, AUE_CreateWindow }, |
76 X_ChangeWindowAttributes, AUE_ChangeWindowAttributes, |
80 { X_ChangeWindowAttributes, AUE_ChangeWindowAttributes }, |
77 X_GetWindowAttributes, AUE_GetWindowAttributes, |
81 { X_GetWindowAttributes, AUE_GetWindowAttributes }, |
78 X_DestroyWindow, AUE_DestroyWindow, |
82 { X_DestroyWindow, AUE_DestroyWindow }, |
79 X_DestroySubwindows, AUE_DestroySubwindows, |
83 { X_DestroySubwindows, AUE_DestroySubwindows }, |
80 X_ChangeSaveSet, AUE_ChangeSaveSet, |
84 { X_ChangeSaveSet, AUE_ChangeSaveSet }, |
81 X_ReparentWindow, AUE_ReparentWindow, |
85 { X_ReparentWindow, AUE_ReparentWindow }, |
82 X_MapWindow, AUE_MapWindow, |
86 { X_MapWindow, AUE_MapWindow }, |
83 X_MapSubwindows, AUE_MapSubwindows, |
87 { X_MapSubwindows, AUE_MapSubwindows }, |
84 X_UnmapWindow, AUE_UnmapWindow, |
88 { X_UnmapWindow, AUE_UnmapWindow }, |
85 X_UnmapSubwindows, AUE_UnmapSubwindows, |
89 { X_UnmapSubwindows, AUE_UnmapSubwindows }, |
86 X_ConfigureWindow, AUE_ConfigureWindow, |
90 { X_ConfigureWindow, AUE_ConfigureWindow }, |
87 X_CirculateWindow, AUE_CirculateWindow, |
91 { X_CirculateWindow, AUE_CirculateWindow }, |
88 X_GetGeometry, AUE_GetGeometry, |
92 { X_GetGeometry, AUE_GetGeometry }, |
89 X_QueryTree, AUE_QueryTree, |
93 { X_QueryTree, AUE_QueryTree }, |
90 X_InternAtom, AUE_InternAtom, |
94 { X_InternAtom, AUE_InternAtom }, |
91 X_GetAtomName, AUE_GetAtomName, |
95 { X_GetAtomName, AUE_GetAtomName }, |
92 X_ChangeProperty, AUE_ChangeProperty, |
96 { X_ChangeProperty, AUE_ChangeProperty }, |
93 X_DeleteProperty, AUE_DeleteProperty, |
97 { X_DeleteProperty, AUE_DeleteProperty }, |
94 X_GetProperty, AUE_GetProperty, |
98 { X_GetProperty, AUE_GetProperty }, |
95 X_ListProperties, AUE_ListProperties, |
99 { X_ListProperties, AUE_ListProperties }, |
96 X_SetSelectionOwner, AUE_SetSelectionOwner, |
100 { X_SetSelectionOwner, AUE_SetSelectionOwner }, |
97 X_GetSelectionOwner, AUE_GetSelectionOwner, |
101 { X_GetSelectionOwner, AUE_GetSelectionOwner }, |
98 X_ConvertSelection, AUE_ConvertSelection, |
102 { X_ConvertSelection, AUE_ConvertSelection }, |
99 X_SendEvent, AUE_SendEvent, |
103 { X_SendEvent, AUE_SendEvent }, |
100 X_GrabPointer, AUE_GrabPointer, |
104 { X_GrabPointer, AUE_GrabPointer }, |
101 X_UngrabPointer, AUE_UngrabPointer, |
105 { X_UngrabPointer, AUE_UngrabPointer }, |
102 X_GrabButton, AUE_GrabButton, |
106 { X_GrabButton, AUE_GrabButton }, |
103 X_UngrabButton, AUE_UngrabButton, |
107 { X_UngrabButton, AUE_UngrabButton }, |
104 X_ChangeActivePointerGrab, AUE_ChangeActivePointerGrab, |
108 { X_ChangeActivePointerGrab, AUE_ChangeActivePointerGrab }, |
105 X_GrabKeyboard, AUE_GrabKeyboard, |
109 { X_GrabKeyboard, AUE_GrabKeyboard }, |
106 X_UngrabKeyboard, AUE_UngrabKeyboard, |
110 { X_UngrabKeyboard, AUE_UngrabKeyboard }, |
107 X_GrabKey, AUE_GrabKey, |
111 { X_GrabKey, AUE_GrabKey }, |
108 X_UngrabKey, AUE_UngrabKey, |
112 { X_UngrabKey, AUE_UngrabKey }, |
109 X_GrabServer, AUE_GrabServer, |
113 { X_GrabServer, AUE_GrabServer }, |
110 X_UngrabServer, AUE_UngrabServer, |
114 { X_UngrabServer, AUE_UngrabServer }, |
111 X_QueryPointer, AUE_QueryPointer, |
115 { X_QueryPointer, AUE_QueryPointer }, |
112 X_GetMotionEvents, AUE_GetMotionEvents, |
116 { X_GetMotionEvents, AUE_GetMotionEvents }, |
113 X_TranslateCoords, AUE_TranslateCoords, |
117 { X_TranslateCoords, AUE_TranslateCoords }, |
114 X_WarpPointer, AUE_WarpPointer, |
118 { X_WarpPointer, AUE_WarpPointer }, |
115 X_SetInputFocus, AUE_SetInputFocus, |
119 { X_SetInputFocus, AUE_SetInputFocus }, |
116 X_GetInputFocus, AUE_GetInputFocus, |
120 { X_GetInputFocus, AUE_GetInputFocus }, |
117 X_QueryKeymap, AUE_QueryKeymap, |
121 { X_QueryKeymap, AUE_QueryKeymap }, |
118 X_SetFontPath, AUE_SetFontPath, |
122 { X_SetFontPath, AUE_SetFontPath }, |
119 X_FreePixmap, AUE_FreePixmap, |
123 { X_FreePixmap, AUE_FreePixmap }, |
120 X_ChangeGC, AUE_ChangeGC, |
124 { X_ChangeGC, AUE_ChangeGC }, |
121 X_CopyGC, AUE_CopyGC, |
125 { X_CopyGC, AUE_CopyGC }, |
122 X_SetDashes, AUE_SetDashes, |
126 { X_SetDashes, AUE_SetDashes }, |
123 X_SetClipRectangles, AUE_SetClipRectangles, |
127 { X_SetClipRectangles, AUE_SetClipRectangles }, |
124 X_FreeGC, AUE_FreeGC, |
128 { X_FreeGC, AUE_FreeGC }, |
125 X_ClearArea, AUE_ClearArea, |
129 { X_ClearArea, AUE_ClearArea }, |
126 X_CopyArea, AUE_CopyArea, |
130 { X_CopyArea, AUE_CopyArea }, |
127 X_CopyPlane, AUE_CopyPlane, |
131 { X_CopyPlane, AUE_CopyPlane }, |
128 X_PolyPoint, AUE_PolyPoint, |
132 { X_PolyPoint, AUE_PolyPoint }, |
129 X_PolyLine, AUE_PolyLine, |
133 { X_PolyLine, AUE_PolyLine }, |
130 X_PolySegment, AUE_PolySegment, |
134 { X_PolySegment, AUE_PolySegment }, |
131 X_PolyRectangle, AUE_PolyRectangle, |
135 { X_PolyRectangle, AUE_PolyRectangle }, |
132 X_PolyArc, AUE_PolyArc, |
136 { X_PolyArc, AUE_PolyArc }, |
133 X_FillPoly, AUE_FillPolygon, |
137 { X_FillPoly, AUE_FillPolygon }, |
134 X_PolyFillRectangle, AUE_PolyFillRectangle, |
138 { X_PolyFillRectangle, AUE_PolyFillRectangle }, |
135 X_PolyFillArc, AUE_PolyFillArc, |
139 { X_PolyFillArc, AUE_PolyFillArc }, |
136 X_PutImage, AUE_PutImage, |
140 { X_PutImage, AUE_PutImage }, |
137 X_GetImage, AUE_GetImage, |
141 { X_GetImage, AUE_GetImage }, |
138 X_PolyText8, AUE_PolyText8, |
142 { X_PolyText8, AUE_PolyText8 }, |
139 X_PolyText16, AUE_PolyText16, |
143 { X_PolyText16, AUE_PolyText16 }, |
140 X_ImageText8, AUE_ImageText8, |
144 { X_ImageText8, AUE_ImageText8 }, |
141 X_ImageText16, AUE_ImageText16, |
145 { X_ImageText16, AUE_ImageText16 }, |
142 X_CreateColormap, AUE_CreateColormap, |
146 { X_CreateColormap, AUE_CreateColormap }, |
143 X_FreeColormap, AUE_FreeColormap, |
147 { X_FreeColormap, AUE_FreeColormap }, |
144 X_CopyColormapAndFree, AUE_CopyColormapAndFree, |
148 { X_CopyColormapAndFree, AUE_CopyColormapAndFree }, |
145 X_InstallColormap, AUE_InstallColormap, |
149 { X_InstallColormap, AUE_InstallColormap }, |
146 X_UninstallColormap, AUE_UninstallColormap, |
150 { X_UninstallColormap, AUE_UninstallColormap }, |
147 X_ListInstalledColormaps, AUE_ListInstalledColormaps, |
151 { X_ListInstalledColormaps, AUE_ListInstalledColormaps }, |
148 X_AllocColor, AUE_AllocColor, |
152 { X_AllocColor, AUE_AllocColor }, |
149 X_AllocNamedColor, AUE_AllocNamedColor, |
153 { X_AllocNamedColor, AUE_AllocNamedColor }, |
150 X_AllocColorCells, AUE_AllocColorCells, |
154 { X_AllocColorCells, AUE_AllocColorCells }, |
151 X_AllocColorPlanes, AUE_AllocColorPlanes, |
155 { X_AllocColorPlanes, AUE_AllocColorPlanes }, |
152 X_FreeColors, AUE_FreeColors, |
156 { X_FreeColors, AUE_FreeColors }, |
153 X_StoreColors, AUE_StoreColors, |
157 { X_StoreColors, AUE_StoreColors }, |
154 X_StoreNamedColor, AUE_StoreNamedColor, |
158 { X_StoreNamedColor, AUE_StoreNamedColor }, |
155 X_QueryColors, AUE_QueryColors, |
159 { X_QueryColors, AUE_QueryColors }, |
156 X_LookupColor, AUE_LookupColor, |
160 { X_LookupColor, AUE_LookupColor }, |
157 X_CreateCursor, AUE_CreateCursor, |
161 { X_CreateCursor, AUE_CreateCursor }, |
158 X_CreateGlyphCursor, AUE_CreateGlyphCursor, |
162 { X_CreateGlyphCursor, AUE_CreateGlyphCursor }, |
159 X_FreeCursor, AUE_FreeCursor, |
163 { X_FreeCursor, AUE_FreeCursor }, |
160 X_RecolorCursor, AUE_RecolorCursor, |
164 { X_RecolorCursor, AUE_RecolorCursor }, |
161 X_ChangeKeyboardMapping, AUE_ChangeKeyboardMapping, |
165 { X_ChangeKeyboardMapping, AUE_ChangeKeyboardMapping }, |
162 X_ChangeKeyboardControl, AUE_ChangeKeyboardControl, |
166 { X_ChangeKeyboardControl, AUE_ChangeKeyboardControl }, |
163 X_Bell, AUE_Bell, |
167 { X_Bell, AUE_Bell }, |
164 X_ChangePointerControl, AUE_ChangePointerControl, |
168 { X_ChangePointerControl, AUE_ChangePointerControl }, |
165 X_SetScreenSaver, AUE_SetScreenSaver, |
169 { X_SetScreenSaver, AUE_SetScreenSaver }, |
166 X_ChangeHosts, AUE_ChangeHosts, |
170 { X_ChangeHosts, AUE_ChangeHosts }, |
167 X_SetAccessControl, AUE_SetAccessControl, |
171 { X_SetAccessControl, AUE_SetAccessControl }, |
168 X_SetCloseDownMode, AUE_SetCloseDownMode, |
172 { X_SetCloseDownMode, AUE_SetCloseDownMode }, |
169 X_KillClient, AUE_KillClient, |
173 { X_KillClient, AUE_KillClient }, |
170 X_RotateProperties, AUE_RotateProperties, |
174 { X_RotateProperties, AUE_RotateProperties }, |
171 X_ForceScreenSaver, AUE_ForceScreenSaver, |
175 { X_ForceScreenSaver, AUE_ForceScreenSaver }, |
172 X_SetPointerMapping, AUE_SetPointerMapping, |
176 { X_SetPointerMapping, AUE_SetPointerMapping }, |
173 X_SetModifierMapping, AUE_SetModifierMapping, |
177 { X_SetModifierMapping, AUE_SetModifierMapping }, |
174 X_NoOperation, AUE_XExtensions |
178 { X_NoOperation, AUE_XExtensions } |
175 }; |
179 }; |
176 extern void Swap32Write(); |
|
177 extern int (*TsolSavedProcVector[PROCVECTORSIZE])(ClientPtr /*client*/); |
180 extern int (*TsolSavedProcVector[PROCVECTORSIZE])(ClientPtr /*client*/); |
178 extern int (*TsolSavedSwappedProcVector[PROCVECTORSIZE])(ClientPtr /*client*/); |
181 extern int (*TsolSavedSwappedProcVector[PROCVECTORSIZE])(ClientPtr /*client*/); |
179 |
182 |
183 extern int GetGeometry(ClientPtr client, xGetGeometryReply *rep); |
|
180 |
184 |
181 Atom MakeTSOLAtom(ClientPtr client, char *string, unsigned int len, Bool makeit); |
185 Atom MakeTSOLAtom(ClientPtr client, char *string, unsigned int len, Bool makeit); |
182 |
186 |
183 #define INITIAL_TSOL_NODELENGTH 1500 |
187 #define INITIAL_TSOL_NODELENGTH 1500 |
184 |
188 |
185 extern WindowPtr XYToWindow(int x, int y); |
189 extern WindowPtr XYToWindow(int x, int y); |
186 extern WindowPtr AnyWindowOverlapsJustMe(WindowPtr pWin, |
190 extern WindowPtr AnyWindowOverlapsJustMe(WindowPtr pWin, |
187 WindowPtr pHead, BoxPtr box); |
191 WindowPtr pHead, BoxPtr box); |
188 |
192 |
189 extern Atom tsol_lastAtom; |
193 extern Atom tsol_lastAtom; |
190 extern int tsol_nodelength; |
194 extern int tsol_nodelength; |
191 extern TsolNodePtr tsol_node; |
195 extern TsolNodePtr tsol_node; |
192 extern int NumCurrentSelections; |
|
193 extern Selection *CurrentSelections; |
|
194 extern WindowPtr tpwin; |
196 extern WindowPtr tpwin; |
195 extern int tsolMultiLevel; |
197 extern int tsolMultiLevel; |
196 |
198 |
197 extern char *ConnectionInfo; |
199 extern char *ConnectionInfo; |
198 extern int connBlockScreenStart; |
200 extern int connBlockScreenStart; |
201 |
203 |
202 /* |
204 /* |
203 * Get number of atoms defined in the system |
205 * Get number of atoms defined in the system |
204 */ |
206 */ |
205 static Atom |
207 static Atom |
206 GetLastAtom() |
208 GetLastAtom(void) |
207 { |
209 { |
208 Atom a = (Atom) 1; /* atoms start at 1 */ |
210 Atom a = (Atom) 1; /* atoms start at 1 */ |
209 |
211 |
210 while (ValidAtom(a)) { |
212 while (ValidAtom(a)) { |
211 a++; |
213 a++; |
218 * Update Tsol info for atoms. This function gets |
220 * Update Tsol info for atoms. This function gets |
219 * called typically during initialization. But, it could also get |
221 * called typically during initialization. But, it could also get |
220 * called if some atoms are created internally by server. |
222 * called if some atoms are created internally by server. |
221 */ |
223 */ |
222 void |
224 void |
223 UpdateTsolNode() |
225 UpdateTsolNode(void) |
224 { |
226 { |
225 Atom lastAtom = GetLastAtom(); |
227 Atom lastAtom = GetLastAtom(); |
226 Atom ia; |
228 Atom ia; |
227 |
229 |
228 /* Update may not be needed */ |
230 /* Update may not be needed */ |
229 if (lastAtom == None || lastAtom == tsol_lastAtom) |
231 if (lastAtom == None || lastAtom == tsol_lastAtom) |
230 return; |
232 return; |
231 |
233 |
232 if (tsol_node == NULL) { |
234 if (tsol_node == NULL) { |
233 int newsize = (lastAtom > INITIAL_TSOL_NODELENGTH ? lastAtom : INITIAL_TSOL_NODELENGTH); |
235 int newsize = (lastAtom > INITIAL_TSOL_NODELENGTH ? lastAtom : INITIAL_TSOL_NODELENGTH); |
234 |
236 |
235 /* Initialize */ |
237 /* Initialize */ |
236 tsol_node = (TsolNodePtr )xalloc((newsize + 1) * sizeof(TsolNodeRec)); |
238 tsol_node = (TsolNodePtr )xalloc((newsize + 1) * sizeof(TsolNodeRec)); |
255 if (tsol_node == NULL) { |
257 if (tsol_node == NULL) { |
256 ErrorF("Cannot allocate memory for Tsol node\n"); |
258 ErrorF("Cannot allocate memory for Tsol node\n"); |
257 return; |
259 return; |
258 } |
260 } |
259 |
261 |
260 /* |
262 /* |
261 * Initialize the tsol node for each atom |
263 * Initialize the tsol node for each atom |
262 */ |
264 */ |
263 for (ia = tsol_lastAtom + 1; ia <= lastAtom; ia++) { |
265 for (ia = tsol_lastAtom + 1; ia <= lastAtom; ia++) { |
264 char *atomname = NameForAtom(ia); |
266 char *atomname = NameForAtom(ia); |
265 |
267 |
272 } |
274 } |
273 tsol_lastAtom = lastAtom; |
275 tsol_lastAtom = lastAtom; |
274 } |
276 } |
275 |
277 |
276 int |
278 int |
277 ProcTsolInternAtom(client) |
279 ProcTsolInternAtom(ClientPtr client) |
278 register ClientPtr client; |
|
279 { |
280 { |
280 Atom atom; |
281 Atom atom; |
281 char *tchar; |
282 char *tchar; |
282 REQUEST(xInternAtomReq); |
283 REQUEST(xInternAtomReq); |
283 |
284 |
302 else |
303 else |
303 return (BadAlloc); |
304 return (BadAlloc); |
304 } |
305 } |
305 |
306 |
306 int |
307 int |
307 ProcTsolGetAtomName(client) |
308 ProcTsolGetAtomName(ClientPtr client) |
308 register ClientPtr client; |
|
309 { |
309 { |
310 char *str; |
310 char *str; |
311 xGetAtomNameReply reply; |
311 xGetAtomNameReply reply; |
312 int len; |
312 int len; |
313 REQUEST(xResourceReq); |
313 REQUEST(xResourceReq); |
323 reply.nameLength = len; |
323 reply.nameLength = len; |
324 WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply); |
324 WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply); |
325 (void)WriteToClient(client, len, str); |
325 (void)WriteToClient(client, len, str); |
326 return(client->noClientException); |
326 return(client->noClientException); |
327 } |
327 } |
328 else |
328 else |
329 { |
329 { |
330 client->errorValue = stuff->id; |
330 client->errorValue = stuff->id; |
331 return (BadAtom); |
331 return (BadAtom); |
332 } |
332 } |
333 } |
333 } |
334 |
334 |
335 Atom |
335 Atom |
336 MakeTSOLAtom(ClientPtr client, char *string, unsigned int len, Bool makeit) |
336 MakeTSOLAtom(ClientPtr client, char *string, unsigned int len, Bool makeit) |
337 { |
337 { |
338 TsolNodePtr tndp; |
338 TsolNodePtr tndp; |
339 int count; |
|
340 int k; |
339 int k; |
341 int newsize; |
340 int newsize; |
342 Atom lastAtom; |
|
343 Atom newAtom; |
341 Atom newAtom; |
344 bslabel_t **newsl; |
|
345 |
342 |
346 TsolInfoPtr tsolinfo; |
343 TsolInfoPtr tsolinfo; |
347 bslabel_t *sl; |
|
348 |
|
349 |
344 |
350 /* Make the atom as usual */ |
345 /* Make the atom as usual */ |
351 newAtom = MakeAtom(string, len, makeit); |
346 newAtom = MakeAtom(string, len, makeit); |
352 if (newAtom == None || newAtom == BAD_RESOURCE) { |
347 if (newAtom == None || newAtom == BAD_RESOURCE) { |
353 return (newAtom); |
348 return (newAtom); |
404 return newAtom; |
399 return newAtom; |
405 } |
400 } |
406 |
401 |
407 |
402 |
408 int |
403 int |
409 ProcTsolSetSelectionOwner(client) |
404 ProcTsolSetSelectionOwner(ClientPtr client) |
410 register ClientPtr client; |
405 { |
411 { |
406 WindowPtr pWin = NULL; |
412 WindowPtr pWin; |
|
413 TimeStamp time; |
407 TimeStamp time; |
414 REQUEST(xSetSelectionOwnerReq); |
408 Selection *pSel; |
409 int rc; |
|
415 |
410 |
416 #ifdef TSOL |
411 #ifdef TSOL |
417 TsolSelnPtr tsolseln = NULL; |
412 TsolSelnPtr tsolseln = NULL; |
418 TsolSelnPtr prevtsolseln = NULL; |
413 TsolSelnPtr prevtsolseln = NULL; |
419 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
414 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
420 #endif /* TSOL */ |
415 #endif /* TSOL */ |
421 |
416 |
417 REQUEST(xSetSelectionOwnerReq); |
|
422 REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); |
418 REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); |
419 |
|
423 UpdateCurrentTime(); |
420 UpdateCurrentTime(); |
424 time = ClientTimeToServerTime(stuff->time); |
421 time = ClientTimeToServerTime(stuff->time); |
425 |
422 |
426 /* If the client's time stamp is in the future relative to the server's |
423 /* If the client's time stamp is in the future relative to the server's |
427 time stamp, do not set the selection, just return success. */ |
424 time stamp, do not set the selection, just return success. */ |
428 if (CompareTimeStamps(time, currentTime) == LATER) |
425 if (CompareTimeStamps(time, currentTime) == LATER) |
429 return Success; |
426 return Success; |
427 |
|
430 if (stuff->window != None) |
428 if (stuff->window != None) |
431 { |
429 { |
432 pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, |
430 rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess); |
433 SecurityReadAccess); |
431 if (rc != Success) |
434 if (!pWin) |
432 return rc; |
435 return(BadWindow); |
433 } |
436 } |
434 if (!ValidAtom(stuff->selection)) { |
437 else |
435 client->errorValue = stuff->selection; |
438 pWin = (WindowPtr)None; |
436 return BadAtom; |
439 if (ValidAtom(stuff->selection)) |
437 } |
440 { |
438 |
439 /* |
|
440 * First, see if the selection is already set... |
|
441 */ |
|
442 rc = dixLookupSelection(&pSel, stuff->selection, client, DixSetAttrAccess); |
|
443 |
|
444 if (rc == Success) { |
|
445 xEvent event; |
|
446 |
|
447 #ifdef TSOL |
|
441 int i = 0; |
448 int i = 0; |
442 |
449 |
450 for (pSel = CurrentSelections; |
|
451 (pSel != NULL) && pSel->selection != stuff->selection; |
|
452 pSel = pSel->next) { |
|
453 i++; |
|
454 } |
|
455 |
|
443 /* |
456 /* |
444 * First, see if the selection is already set... |
|
445 */ |
|
446 while ((i < NumCurrentSelections) && |
|
447 CurrentSelections[i].selection != stuff->selection) |
|
448 i++; |
|
449 |
|
450 #ifdef TSOL |
|
451 /* |
|
452 * special processing for selection agent. Just note |
457 * special processing for selection agent. Just note |
453 * the owner of this special selection |
458 * the owner of this special selection |
454 */ |
459 */ |
455 if (stuff->selection == MakeAtom("_TSOL_SEL_AGNT", 14, 1)) |
460 if (stuff->selection == MakeAtom("_TSOL_SEL_AGNT", 14, 1)) |
456 { |
461 { |
457 if (HasWinSelection(tsolinfo)) |
462 if (HasWinSelection(tsolinfo)) |
458 { |
463 { |
459 if (tsolinfo->flags & TSOL_AUDITEVENT) |
464 if (tsolinfo->flags & TSOL_AUDITEVENT) |
460 auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION, |
465 auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION, |
461 AW_APPEND, AW_END); |
466 AW_APPEND, AW_END); |
462 tsol_sel_agnt = i; /* owner of this seln */ |
467 tsol_sel_agnt = i; /* owner of this seln */ |
463 } |
468 } |
464 else |
469 else |
465 { |
470 { |
466 if (tsolinfo->flags & TSOL_AUDITEVENT) |
471 if (tsolinfo->flags & TSOL_AUDITEVENT) |
467 auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION, |
472 auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION, |
468 AW_APPEND, AW_END); |
473 AW_APPEND, AW_END); |
469 client->errorValue = stuff->selection; |
474 client->errorValue = stuff->selection; |
470 return(BadAtom); |
475 return(BadAtom); |
471 } |
476 } |
472 } |
477 } |
473 #endif /* TSOL */ |
478 |
474 |
479 /* for poly-selections, search further to see if sl,uid match */ |
475 if (i < NumCurrentSelections) |
480 tsolseln = *(TsolSelectionPriv(pSel)); |
476 { |
481 if (PolySelection(pSel->selection)) |
477 xEvent event; |
482 { |
478 |
483 prevtsolseln = tsolseln; |
479 #ifdef TSOL |
484 while (tsolseln) |
480 /* for poly-selections, search further to see if sl,uid match */ |
|
481 tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate; |
|
482 if (PolySelection(CurrentSelections[i].selection)) |
|
483 { |
485 { |
484 prevtsolseln = tsolseln; |
486 if (tsolseln->uid == tsolinfo->uid && |
485 while (tsolseln) |
487 tsolseln->sl == tsolinfo->sl) |
486 { |
488 break; /* match found */ |
487 if (tsolseln->uid == tsolinfo->uid && |
489 prevtsolseln = tsolseln; |
488 tsolseln->sl == tsolinfo->sl) |
490 tsolseln = tsolseln->next; |
489 break; /* match found */ |
|
490 prevtsolseln = tsolseln; |
|
491 tsolseln = tsolseln->next; |
|
492 } |
|
493 } |
|
494 if (PolySelection(CurrentSelections[i].selection) && tsolseln) |
|
495 { |
|
496 if (CompareTimeStamps(time, tsolseln->lastTimeChanged) == EARLIER) |
|
497 return Success; |
|
498 if (tsolseln->client && (!pWin || (tsolseln->client != client))) |
|
499 { |
|
500 event.u.u.type = SelectionClear; |
|
501 event.u.selectionClear.time = time.milliseconds; |
|
502 event.u.selectionClear.window = tsolseln->window; |
|
503 event.u.selectionClear.atom = CurrentSelections[i].selection; |
|
504 (void)TryClientEvents (tsolseln->client, |
|
505 &event, |
|
506 1, |
|
507 NoEventMask, |
|
508 NoEventMask /* CantBeFiltered */, |
|
509 NullGrab); |
|
510 } |
|
511 } |
491 } |
512 else if (tsolseln) |
492 } |
513 { |
493 if (PolySelection(pSel->selection) && tsolseln) |
514 /* we use the existing code. So we left it unindented */ |
494 { |
515 #endif /* TSOL */ |
495 if (CompareTimeStamps(time, tsolseln->lastTimeChanged) |
516 |
|
517 /* If the timestamp in client's request is in the past relative |
|
518 to the time stamp indicating the last time the owner of the |
|
519 selection was set, do not set the selection, just return |
|
520 success. */ |
|
521 if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged) |
|
522 == EARLIER) |
496 == EARLIER) |
523 return Success; |
497 return Success; |
524 if (CurrentSelections[i].client && |
498 if (tsolseln->client && |
525 (!pWin || (CurrentSelections[i].client != client))) |
499 (!pWin || (tsolseln->client != client))) |
526 { |
500 { |
527 event.u.u.type = SelectionClear; |
501 event.u.u.type = SelectionClear; |
528 event.u.selectionClear.time = time.milliseconds; |
502 event.u.selectionClear.time = time.milliseconds; |
529 event.u.selectionClear.window = CurrentSelections[i].window; |
503 event.u.selectionClear.window = tsolseln->window; |
530 event.u.selectionClear.atom = CurrentSelections[i].selection; |
504 event.u.selectionClear.atom = pSel->selection; |
531 (void) TryClientEvents (CurrentSelections[i].client, &event, 1, |
505 (void)TryClientEvents (tsolseln->client, |
532 NoEventMask, NoEventMask /* CantBeFiltered */, |
506 &event, |
533 NullGrab); |
507 1, |
508 NoEventMask, |
|
509 NoEventMask /* CantBeFiltered */, |
|
510 NullGrab); |
|
534 } |
511 } |
512 } |
|
513 else if (tsolseln) |
|
514 { |
|
515 /* we use the existing code. So we left it unindented */ |
|
516 #endif /* TSOL */ |
|
517 |
|
518 /* If the timestamp in client's request is in the past relative |
|
519 to the time stamp indicating the last time the owner of the |
|
520 selection was set, do not set the selection, just return |
|
521 success. */ |
|
522 if (CompareTimeStamps(time, pSel->lastTimeChanged) == EARLIER) |
|
523 return Success; |
|
524 if (pSel->client && (!pWin || (pSel->client != client))) |
|
525 { |
|
526 event.u.u.type = SelectionClear; |
|
527 event.u.selectionClear.time = time.milliseconds; |
|
528 event.u.selectionClear.window = pSel->window; |
|
529 event.u.selectionClear.atom = pSel->selection; |
|
530 TryClientEvents(pSel->client, &event, 1, NoEventMask, |
|
531 NoEventMask /* CantBeFiltered */, NullGrab); |
|
532 } |
|
535 #ifdef TSOL |
533 #ifdef TSOL |
536 } |
534 } |
537 #endif /* TSOL */ |
535 #endif /* TSOL */ |
538 } |
536 } |
537 else if (rc == BadMatch) |
|
538 { |
|
539 /* |
|
540 * It doesn't exist, so add it... |
|
541 */ |
|
542 pSel = xalloc(sizeof(Selection)); |
|
543 if (!pSel) |
|
544 return BadAlloc; |
|
545 |
|
546 pSel->selection = stuff->selection; |
|
547 pSel->devPrivates = NULL; |
|
548 |
|
549 /* security creation/labeling check */ |
|
550 rc = XaceHookSelectionAccess(client, &pSel, |
|
551 DixCreateAccess|DixSetAttrAccess); |
|
552 if (rc != Success) { |
|
553 xfree(pSel); |
|
554 return rc; |
|
555 } |
|
556 |
|
557 pSel->next = CurrentSelections; |
|
558 CurrentSelections = pSel; |
|
559 } |
|
560 else |
|
561 return rc; |
|
562 |
|
563 #ifdef TSOL |
|
564 /* |
|
565 * tsolseln == NULL, either seln does not exist, |
|
566 * or there is no sl,uid match |
|
567 */ |
|
568 if (!tsolseln) |
|
569 { |
|
570 /* create one & put it in place */ |
|
571 tsolseln = (TsolSelnPtr)xalloc(sizeof(TsolSelnRec)); |
|
572 if (!tsolseln) |
|
573 return BadAlloc; |
|
574 tsolseln->next = (TsolSelnPtr)NULL; |
|
575 |
|
576 /* if necessary put at the end of the list */ |
|
577 if (prevtsolseln) |
|
578 prevtsolseln->next = tsolseln; |
|
539 else |
579 else |
540 { |
580 *(TsolSelectionPriv(pSel)) = tsolseln; |
541 /* |
581 } |
542 * It doesn't exist, so add it... |
582 /* fill it in */ |
543 */ |
|
544 Selection *newsels; |
|
545 |
|
546 if (i == 0) |
|
547 newsels = (Selection *)xalloc(sizeof(Selection)); |
|
548 else |
|
549 newsels = (Selection *)xrealloc(CurrentSelections, |
|
550 (NumCurrentSelections + 1) * sizeof(Selection)); |
|
551 if (!newsels) |
|
552 return BadAlloc; |
|
553 NumCurrentSelections++; |
|
554 CurrentSelections = newsels; |
|
555 CurrentSelections[i].selection = stuff->selection; |
|
556 } |
|
557 #ifdef TSOL |
|
558 /* |
|
559 * tsolseln == NULL, either seln does not exist, |
|
560 * or there is no sl,uid match |
|
561 */ |
|
562 if (!tsolseln) |
|
563 { |
|
564 /* create one & put it in place */ |
|
565 tsolseln = (TsolSelnPtr)xalloc(sizeof(TsolSelnRec)); |
|
566 if (!tsolseln) |
|
567 return BadAlloc; |
|
568 tsolseln->next = (TsolSelnPtr)NULL; |
|
569 |
|
570 /* if necessary put at the end of the list */ |
|
571 if (prevtsolseln) |
|
572 prevtsolseln->next = tsolseln; |
|
573 else |
|
574 CurrentSelections[i].secPrivate = (pointer)tsolseln; |
|
575 } |
|
576 /* fill it in */ |
|
577 tsolseln->sl = tsolinfo->sl; |
583 tsolseln->sl = tsolinfo->sl; |
578 tsolseln->uid = tsolinfo->uid; |
584 tsolseln->uid = tsolinfo->uid; |
579 tsolseln->lastTimeChanged = time; |
585 tsolseln->lastTimeChanged = time; |
580 tsolseln->window = stuff->window; |
586 tsolseln->window = stuff->window; |
581 tsolseln->pWin = pWin; |
587 tsolseln->pWin = pWin; |
582 tsolseln->client = (pWin ? client : NullClient); |
588 tsolseln->client = (pWin ? client : NullClient); |
583 if (!PolySelection(CurrentSelections[i].selection)) |
589 if (!PolySelection(pSel->selection)) |
584 { |
590 { |
585 /* no change to existing code. left as it is */ |
591 /* no change to existing code. left as it is */ |
586 #endif /* TSOL */ |
592 #endif /* TSOL */ |
587 |
593 |
588 CurrentSelections[i].lastTimeChanged = time; |
594 pSel->lastTimeChanged = time; |
589 CurrentSelections[i].window = stuff->window; |
595 pSel->window = stuff->window; |
590 CurrentSelections[i].pWin = pWin; |
596 pSel->pWin = pWin; |
591 CurrentSelections[i].client = (pWin ? client : NullClient); |
597 pSel->client = (pWin ? client : NullClient); |
592 if (SelectionCallback) |
598 |
593 { |
599 if (SelectionCallback != NULL) { |
594 SelectionInfoRec info; |
600 SelectionInfoRec info = { pSel, client, SelectionSetOwner }; |
595 |
601 CallCallbacks(&SelectionCallback, &info); |
596 info.selection = &CurrentSelections[i]; |
602 } |
597 info.kind= SelectionSetOwner; |
603 #ifdef TSOL |
598 CallCallbacks(&SelectionCallback, &info); |
604 } |
599 } |
|
600 #ifdef TSOL |
|
601 } |
|
602 #endif /* TSOL */ |
605 #endif /* TSOL */ |
603 |
606 |
604 return (client->noClientException); |
607 return (client->noClientException); |
605 } |
608 } |
606 else |
609 |
607 { |
610 int |
608 client->errorValue = stuff->selection; |
611 ProcTsolGetSelectionOwner(ClientPtr client) |
609 return (BadAtom); |
612 { |
610 } |
613 int rc; |
611 } |
614 Selection *pSel; |
612 |
615 xGetSelectionOwnerReply reply; |
613 int |
616 |
614 ProcTsolGetSelectionOwner(client) |
|
615 register ClientPtr client; |
|
616 { |
|
617 REQUEST(xResourceReq); |
617 REQUEST(xResourceReq); |
618 |
|
619 REQUEST_SIZE_MATCH(xResourceReq); |
618 REQUEST_SIZE_MATCH(xResourceReq); |
620 if (ValidAtom(stuff->id)) |
619 |
621 { |
620 if (!ValidAtom(stuff->id)) { |
622 int i; |
621 client->errorValue = stuff->id; |
623 xGetSelectionOwnerReply reply; |
622 return BadAtom; |
624 |
623 } |
625 i = 0; |
624 |
626 while ((i < NumCurrentSelections) && |
625 reply.type = X_Reply; |
627 CurrentSelections[i].selection != stuff->id) i++; |
626 reply.length = 0; |
628 reply.type = X_Reply; |
627 reply.sequenceNumber = client->sequence; |
629 reply.length = 0; |
628 |
630 reply.sequenceNumber = client->sequence; |
629 rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess); |
631 if (i < NumCurrentSelections) |
630 if (rc == Success) |
632 #ifdef TSOL |
631 #ifdef TSOL |
633 { |
632 { |
634 TsolSelnPtr tsolseln; |
633 TsolSelnPtr tsolseln; |
635 TsolInfoPtr tsolinfo; /* tsol client info */ |
634 TsolInfoPtr tsolinfo; /* tsol client info */ |
636 tsolinfo = GetClientTsolInfo(client); |
635 tsolinfo = GetClientTsolInfo(client); |
637 |
636 |
638 /* find matching sl,uid in case of poly selns */ |
637 /* find matching sl,uid in case of poly selns */ |
639 tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate; |
638 tsolseln = *(TsolSelectionPriv(pSel)); |
640 if (PolySelection(CurrentSelections[i].selection)) |
639 if (PolySelection(pSel->selection)) |
641 { |
640 { |
642 while (tsolseln) |
641 while (tsolseln) |
643 { |
642 { |
644 if (tsolseln->uid == tsolinfo->uid && |
643 if (tsolseln->uid == tsolinfo->uid && |
645 tsolseln->sl == tsolinfo->sl) |
644 tsolseln->sl == tsolinfo->sl) |
646 break; /* match found */ |
645 break; /* match found */ |
647 tsolseln = tsolseln->next; |
646 tsolseln = tsolseln->next; |
648 } |
647 } |
649 if (tsolseln) |
648 if (tsolseln) |
650 reply.owner = tsolseln->window; |
649 reply.owner = tsolseln->window; |
651 else |
650 else |
652 reply.owner = None; |
651 reply.owner = None; |
653 } |
652 } |
654 else |
653 else |
655 { |
654 { |
656 reply.owner = CurrentSelections[i].window; |
655 reply.owner = pSel->window; |
657 } |
656 } |
658 /* |
657 /* |
659 * Selection Agent processing. Override the owner |
658 * Selection Agent processing. Override the owner |
660 */ |
659 */ |
661 if (!HasWinSelection(tsolinfo) && |
660 if (!HasWinSelection(tsolinfo) && |
662 client->index != CLIENT_ID(reply.owner) && |
661 client->index != CLIENT_ID(reply.owner) && |
663 reply.owner != None && |
662 reply.owner != None && |
664 tsol_sel_agnt != -1 && |
663 tsol_sel_agnt != -1 && |
665 CurrentSelections[tsol_sel_agnt].client) |
664 CurrentSelections[tsol_sel_agnt].client) |
666 { |
665 { |
667 WindowPtr pWin; |
666 WindowPtr pWin; |
668 pWin = (WindowPtr)LookupWindow(reply.owner, client); |
667 pWin = (WindowPtr)LookupWindow(reply.owner, client); |
669 if (tsolinfo->flags & TSOL_AUDITEVENT) |
668 if (tsolinfo->flags & TSOL_AUDITEVENT) |
670 auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION, |
669 auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION, |
671 AW_APPEND, AW_END); |
670 AW_APPEND, AW_END); |
672 } |
671 } |
673 else if (HasWinSelection(tsolinfo) && |
672 else if (HasWinSelection(tsolinfo) && |
674 tsolinfo->flags & TSOL_AUDITEVENT) |
673 tsolinfo->flags & TSOL_AUDITEVENT) |
675 { |
674 { |
676 auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION, |
675 auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION, |
677 AW_APPEND, AW_END); |
676 AW_APPEND, AW_END); |
678 } |
677 } |
679 /* end seln agent processing */ |
678 /* end seln agent processing */ |
680 } |
679 } |
681 #else /* TSOL */ |
680 #else /* TSOL */ |
682 reply.owner = CurrentSelections[i].window; |
681 reply.owner = pSel->window; |
683 #endif /* TSOL */ |
682 #endif /* TSOL */ |
684 else |
683 else if (rc == BadMatch) |
685 reply.owner = None; |
684 reply.owner = None; |
686 WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply); |
685 else |
687 return(client->noClientException); |
686 return rc; |
688 } |
687 |
689 else |
688 WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply); |
690 { |
689 return client->noClientException; |
691 client->errorValue = stuff->id; |
690 } |
692 return (BadAtom); |
691 |
693 } |
692 int |
694 } |
693 ProcTsolConvertSelection(ClientPtr client) |
695 |
|
696 int |
|
697 ProcTsolConvertSelection(client) |
|
698 register ClientPtr client; |
|
699 { |
694 { |
700 Bool paramsOkay; |
695 Bool paramsOkay; |
701 xEvent event; |
696 xEvent event; |
702 WindowPtr pWin; |
697 WindowPtr pWin; |
698 Selection *pSel; |
|
699 int rc; |
|
700 |
|
703 REQUEST(xConvertSelectionReq); |
701 REQUEST(xConvertSelectionReq); |
704 |
|
705 REQUEST_SIZE_MATCH(xConvertSelectionReq); |
702 REQUEST_SIZE_MATCH(xConvertSelectionReq); |
706 pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client, |
703 |
707 SecurityReadAccess); |
704 rc = dixLookupWindow(&pWin, stuff->requestor, client, DixSetAttrAccess); |
708 if (!pWin) |
705 if (rc != Success) |
709 return(BadWindow); |
706 return rc; |
710 |
707 |
711 paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target)); |
708 paramsOkay = ValidAtom(stuff->selection) && ValidAtom(stuff->target); |
712 if (stuff->property != None) |
709 paramsOkay &= (stuff->property == None) || ValidAtom(stuff->property); |
713 paramsOkay &= ValidAtom(stuff->property); |
710 if (!paramsOkay) { |
714 if (paramsOkay) |
711 client->errorValue = stuff->property; |
715 { |
712 return BadAtom; |
716 int i; |
713 } |
717 |
714 |
718 i = 0; |
715 rc = dixLookupSelection(&pSel, stuff->selection, client, DixReadAccess); |
719 while ((i < NumCurrentSelections) && |
716 |
720 CurrentSelections[i].selection != stuff->selection) i++; |
717 if (rc != Success && rc != BadMatch) |
721 #ifdef TSOL |
718 return rc; |
722 if (i < NumCurrentSelections) |
719 #ifdef TSOL |
723 { |
720 else if (rc == Success) { |
724 TsolSelnPtr tsolseln; |
721 TsolSelnPtr tsolseln; |
725 TsolInfoPtr tsolinfo; /* tsol client info */ |
722 TsolInfoPtr tsolinfo; /* tsol client info */ |
726 Window twin; /* temporary win */ |
723 Window twin; /* temporary win */ |
727 ClientPtr tclient; /* temporary client */ |
724 ClientPtr tclient; /* temporary client */ |
728 |
725 |
729 tsolinfo = GetClientTsolInfo(client); |
726 tsolinfo = GetClientTsolInfo(client); |
730 |
727 |
731 /* find matching sl,uid in case of poly selns */ |
728 /* find matching sl,uid in case of poly selns */ |
732 tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate; |
729 tsolseln = *(TsolSelectionPriv(pSel)); |
733 if (PolySelection(CurrentSelections[i].selection)) |
730 if (PolySelection(pSel->selection)) |
734 { |
731 { |
735 while (tsolseln) |
732 while (tsolseln) |
736 { |
733 { |
737 if (tsolseln->uid == tsolinfo->uid && |
734 if (tsolseln->uid == tsolinfo->uid && |
738 tsolseln->sl == tsolinfo->sl) |
735 tsolseln->sl == tsolinfo->sl) |
739 break; /* match found */ |
736 break; /* match found */ |
740 tsolseln = tsolseln->next; |
737 tsolseln = tsolseln->next; |
741 } |
738 } |
742 if (!tsolseln) |
739 if (!tsolseln) |
743 { |
740 { |
744 client->errorValue = stuff->property; |
741 client->errorValue = stuff->property; |
745 return (BadAtom); |
742 return (BadAtom); |
746 } |
743 } |
747 twin = tsolseln->window; |
744 twin = tsolseln->window; |
748 tclient = tsolseln->client; |
745 tclient = tsolseln->client; |
749 } |
746 } |
750 else |
747 else |
751 { |
748 { |
752 twin = CurrentSelections[i].window; |
749 twin = pSel->window; |
753 tclient = CurrentSelections[i].client; |
750 tclient = pSel->client; |
754 } |
751 } |
755 /* |
752 /* |
756 * Special case for seln agent. |
753 * Special case for seln agent. |
757 * SelectionRequest event is redirected to selection |
754 * SelectionRequest event is redirected to selection |
758 * agent for unpirvileged clients and who do not own |
755 * agent for unpirvileged clients and who do not own |
759 * the selection |
756 * the selection |
760 */ |
757 */ |
761 if (tsol_sel_agnt != -1 && CurrentSelections[tsol_sel_agnt].client) |
758 if (tsol_sel_agnt != -1 && CurrentSelections[tsol_sel_agnt].client) |
762 { |
759 { |
763 /* Redirect only if client other than owner & does not have priv */ |
760 /* Redirect only if client other than owner & does not have priv */ |
764 if (!HasWinSelection(tsolinfo) && (client != tclient)) |
761 if (!HasWinSelection(tsolinfo) && (client != tclient)) |
765 { |
762 { |
766 tclient = CurrentSelections[tsol_sel_agnt].client; |
763 tclient = CurrentSelections[tsol_sel_agnt].client; |
767 twin = CurrentSelections[tsol_sel_agnt].window; |
764 twin = CurrentSelections[tsol_sel_agnt].window; |
768 if (tsolinfo->flags & TSOL_AUDITEVENT) |
765 if (tsolinfo->flags & TSOL_AUDITEVENT) |
769 auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION, |
766 auditwrite(AW_USEOFPRIV, 1, PRIV_WIN_SELECTION, |
770 AW_APPEND, AW_END); |
767 AW_APPEND, AW_END); |
771 } |
768 } |
772 else if (HasWinSelection(tsolinfo) && |
769 else if (HasWinSelection(tsolinfo) && |
773 tsolinfo->flags & TSOL_AUDITEVENT) |
770 tsolinfo->flags & TSOL_AUDITEVENT) |
774 { |
771 { |
775 auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION, |
772 auditwrite(AW_USEOFPRIV, 0, PRIV_WIN_SELECTION, |
776 AW_APPEND, AW_END); |
773 AW_APPEND, AW_END); |
777 } |
774 } |
778 } |
775 } |
779 /* end of special case seln handling */ |
776 /* end of special case seln handling */ |
780 |
777 |
781 if (twin != None) |
778 if (twin != None) |
782 { |
779 { |
783 event.u.u.type = SelectionRequest; |
780 event.u.u.type = SelectionRequest; |
784 event.u.selectionRequest.time = stuff->time; |
781 event.u.selectionRequest.time = stuff->time; |
785 event.u.selectionRequest.owner = twin; |
782 event.u.selectionRequest.owner = twin; |
786 event.u.selectionRequest.requestor = stuff->requestor; |
783 event.u.selectionRequest.requestor = stuff->requestor; |
787 event.u.selectionRequest.selection = stuff->selection; |
784 event.u.selectionRequest.selection = stuff->selection; |
788 event.u.selectionRequest.target = stuff->target; |
785 event.u.selectionRequest.target = stuff->target; |
789 event.u.selectionRequest.property = stuff->property; |
786 event.u.selectionRequest.property = stuff->property; |
790 if (TryClientEvents(tclient, &event, 1, |
787 if (TryClientEvents(tclient, &event, 1, |
791 NoEventMask, NoEventMask /* CantBeFiltered */, |
788 NoEventMask, |
792 NullGrab)) |
789 NoEventMask /* CantBeFiltered */, |
793 return (client->noClientException); |
790 NullGrab)) |
791 return (client->noClientException); |
|
794 } |
792 } |
795 } |
793 } |
796 #else /* TSOL */ |
794 #else /* TSOL */ |
797 if ((i < NumCurrentSelections) && |
795 else if (rc == Success && pSel->window != None) { |
798 (CurrentSelections[i].window != None) |
796 event.u.u.type = SelectionRequest; |
799 #ifdef XCSECURITY |
797 event.u.selectionRequest.owner = pSel->window; |
800 && (!client->CheckAccess || |
798 event.u.selectionRequest.time = stuff->time; |
801 (* client->CheckAccess)(client, CurrentSelections[i].window, |
799 event.u.selectionRequest.requestor = stuff->requestor; |
802 RT_WINDOW, SecurityReadAccess, |
800 event.u.selectionRequest.selection = stuff->selection; |
803 CurrentSelections[i].pWin)) |
801 event.u.selectionRequest.target = stuff->target; |
804 #endif |
802 event.u.selectionRequest.property = stuff->property; |
805 ) |
803 if (TryClientEvents(pSel->client, &event, 1, NoEventMask, |
806 { |
804 NoEventMask /* CantBeFiltered */, NullGrab)) |
807 event.u.u.type = SelectionRequest; |
805 return client->noClientException; |
808 event.u.selectionRequest.time = stuff->time; |
806 } |
809 event.u.selectionRequest.owner = |
|
810 CurrentSelections[i].window; |
|
811 event.u.selectionRequest.requestor = stuff->requestor; |
|
812 event.u.selectionRequest.selection = stuff->selection; |
|
813 event.u.selectionRequest.target = stuff->target; |
|
814 event.u.selectionRequest.property = stuff->property; |
|
815 if (TryClientEvents( |
|
816 CurrentSelections[i].client, &event, 1, NoEventMask, |
|
817 NoEventMask /* CantBeFiltered */, NullGrab)) |
|
818 return (client->noClientException); |
|
819 } |
|
820 #endif /* TSOL */ |
807 #endif /* TSOL */ |
821 |
808 |
822 event.u.u.type = SelectionNotify; |
809 event.u.u.type = SelectionNotify; |
823 event.u.selectionNotify.time = stuff->time; |
810 event.u.selectionNotify.time = stuff->time; |
824 event.u.selectionNotify.requestor = stuff->requestor; |
811 event.u.selectionNotify.requestor = stuff->requestor; |
825 event.u.selectionNotify.selection = stuff->selection; |
812 event.u.selectionNotify.selection = stuff->selection; |
826 event.u.selectionNotify.target = stuff->target; |
813 event.u.selectionNotify.target = stuff->target; |
827 event.u.selectionNotify.property = None; |
814 event.u.selectionNotify.property = None; |
828 (void) TryClientEvents(client, &event, 1, NoEventMask, |
815 TryClientEvents(client, &event, 1, NoEventMask, |
829 NoEventMask /* CantBeFiltered */, NullGrab); |
816 NoEventMask /* CantBeFiltered */, NullGrab); |
830 return (client->noClientException); |
817 return client->noClientException; |
831 } |
|
832 else |
|
833 { |
|
834 client->errorValue = stuff->property; |
|
835 return (BadAtom); |
|
836 } |
|
837 } |
818 } |
838 |
819 |
839 /* Allocate and initialize a tsolprop */ |
820 /* Allocate and initialize a tsolprop */ |
840 |
821 |
841 TsolPropPtr |
822 TsolPropPtr |
842 AllocTsolProp() |
823 AllocTsolProp(void) |
843 { |
824 { |
844 TsolPropPtr tsolprop; |
825 TsolPropPtr tsolprop; |
845 |
826 |
846 tsolprop = (TsolPropPtr)Xcalloc(sizeof(TsolPropRec)); |
827 tsolprop = (TsolPropPtr)Xcalloc(sizeof(TsolPropRec)); |
847 |
828 |
854 } |
835 } |
855 |
836 |
856 return tsolprop; |
837 return tsolprop; |
857 } |
838 } |
858 |
839 |
859 /* |
840 /* |
860 * Allocate and initialize tsolprop created |
841 * Allocate and initialize tsolprop created |
861 * internally by the X server |
842 * internally by the X server |
862 */ |
843 */ |
863 |
844 |
864 TsolPropPtr |
845 TsolPropPtr |
865 AllocServerTsolProp() |
846 AllocServerTsolProp(void) |
866 { |
847 { |
867 TsolPropPtr tsolprop; |
848 TsolPropPtr tsolprop; |
868 |
849 |
869 tsolprop = (TsolPropPtr)Xcalloc(sizeof(TsolPropRec)); |
850 tsolprop = (TsolPropPtr)Xcalloc(sizeof(TsolPropRec)); |
870 |
851 |
888 * instantiated properties. Polyinstanticated property |
869 * instantiated properties. Polyinstanticated property |
889 * data/len stored in the tsolprop structure |
870 * data/len stored in the tsolprop structure |
890 */ |
871 */ |
891 |
872 |
892 int |
873 int |
893 TsolChangeWindowProperty(client, pWin, property, type, |
874 TsolChangeWindowProperty( |
894 format, mode, len, value, sendevent) |
875 ClientPtr client, |
895 ClientPtr client; |
876 WindowPtr pWin, |
896 WindowPtr pWin; |
877 Atom property, |
897 Atom property, type; |
878 Atom type, |
898 int format, mode; |
879 int format, |
899 unsigned long len; |
880 int mode, |
900 pointer value; |
881 unsigned long len, |
901 Bool sendevent; |
882 pointer value, |
883 Bool sendevent) |
|
902 { |
884 { |
903 PropertyPtr pProp; |
885 PropertyPtr pProp; |
904 xEvent event; |
886 xEvent event; |
905 int sizeInBytes; |
887 int sizeInBytes; |
906 int totalSize; |
888 int totalSize; |
907 pointer data; |
889 pointer data; |
908 TsolPropPtr tsolprop; |
890 TsolPropPtr tsolprop; |
891 TsolPropPtr *tsolpropP; |
|
909 TsolInfoPtr tsolinfo; |
892 TsolInfoPtr tsolinfo; |
910 TsolResPtr tsolres; |
893 TsolResPtr tsolres; |
911 int result; |
894 int result; |
912 int polyprop = PolyProperty(property, pWin); |
895 int polyprop = PolyProperty(property, pWin); |
913 |
896 |
914 |
897 |
915 if (!polyprop) |
898 if (!polyprop) |
916 { |
899 { |
917 result = ChangeWindowProperty(pWin, property, type, |
900 result = dixChangeWindowProperty(client, pWin, property, type, |
918 format, mode, len, value, sendevent); |
901 format, mode, len, value, sendevent); |
919 if (result != Success) |
902 if (result != Success) |
920 return (result); |
903 return (result); |
921 } |
904 } |
922 |
905 |
923 sizeInBytes = format>>3; |
906 sizeInBytes = format>>3; |
932 break; |
915 break; |
933 pProp = pProp->next; |
916 pProp = pProp->next; |
934 } |
917 } |
935 |
918 |
936 tsolinfo = GetClientTsolInfo(client); |
919 tsolinfo = GetClientTsolInfo(client); |
937 tsolres = (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr); |
920 tsolres = TsolWindowPriv(pWin); |
938 |
921 |
939 /* Initialize secPrviate if property is not polyinstantiated */ |
922 /* Initialize secPrviate if property is not polyinstantiated */ |
940 if (!polyprop && pProp) |
923 if (!polyprop && pProp) |
941 { |
924 { |
942 /* Initialize for internally created properties */ |
925 /* Initialize for internally created properties */ |
943 if (!pProp->secPrivate) |
926 tsolpropP = TsolPropertyPriv(pProp); |
944 pProp->secPrivate = (pointer)AllocTsolProp(); |
927 if (*tsolpropP == NULL) |
945 |
928 { |
946 if (!pProp->secPrivate) |
929 *tsolpropP = (pointer)AllocTsolProp(); |
947 return(BadAlloc); |
930 if (*tsolpropP == NULL) |
948 |
931 return(BadAlloc); |
949 tsolprop = (TsolPropPtr)(pProp->secPrivate); |
932 } |
933 tsolprop = *tsolpropP; |
|
934 |
|
950 if (WindowIsRoot(pWin)) |
935 if (WindowIsRoot(pWin)) |
951 { |
936 { |
952 tsolprop->sl = tsolinfo->sl; /* use client's sl/uid */ |
937 tsolprop->sl = tsolinfo->sl; /* use client's sl/uid */ |
953 tsolprop->uid = tsolinfo->uid; |
938 tsolprop->uid = tsolinfo->uid; |
954 tsolprop->pid = tsolinfo->pid; |
939 tsolprop->pid = tsolinfo->pid; |
969 if (!pWin->optional && !MakeWindowOptional (pWin)) |
954 if (!pWin->optional && !MakeWindowOptional (pWin)) |
970 return(BadAlloc); |
955 return(BadAlloc); |
971 pProp = (PropertyPtr)xalloc(sizeof(PropertyRec)); |
956 pProp = (PropertyPtr)xalloc(sizeof(PropertyRec)); |
972 if (!pProp) |
957 if (!pProp) |
973 return(BadAlloc); |
958 return(BadAlloc); |
974 pProp->secPrivate = (pointer)Xcalloc(sizeof(TsolPropRec)); |
959 tsolpropP = TsolPropertyPriv(pProp); |
975 if (!pProp->secPrivate) |
960 *tsolpropP = (pointer)Xcalloc(sizeof(TsolPropRec)); |
961 if (!(*tsolpropP)) |
|
976 return(BadAlloc); |
962 return(BadAlloc); |
977 data = (pointer)xalloc(totalSize); |
963 data = (pointer)xalloc(totalSize); |
978 if (!data && len) |
964 if (!data && len) |
979 { |
965 { |
980 xfree(pProp->secPrivate); |
966 xfree(*tsolpropP); |
981 xfree(pProp); |
967 xfree(pProp); |
982 return(BadAlloc); |
968 return(BadAlloc); |
983 } |
969 } |
984 pProp->propertyName = property; |
970 pProp->propertyName = property; |
985 pProp->type = type; |
971 pProp->type = type; |
986 pProp->format = format; |
972 pProp->format = format; |
987 pProp->data = data; |
973 pProp->data = data; |
988 if (len) |
974 if (len) |
989 bcopy((char *)value, (char *)data, totalSize); |
975 bcopy((char *)value, (char *)data, totalSize); |
990 pProp->size = len; |
976 pProp->size = len; |
991 tsolprop = (TsolPropPtr)(pProp->secPrivate); |
977 tsolprop = *tsolpropP; |
992 if (WindowIsRoot(pWin)) |
978 if (WindowIsRoot(pWin)) |
993 { |
979 { |
994 tsolprop->sl = tsolinfo->sl; |
980 tsolprop->sl = tsolinfo->sl; |
995 tsolprop->uid = tsolinfo->uid; |
981 tsolprop->uid = tsolinfo->uid; |
996 } |
982 } |
1015 if ((format != pProp->format) && (mode != PropModeReplace)) |
1001 if ((format != pProp->format) && (mode != PropModeReplace)) |
1016 return(BadMatch); |
1002 return(BadMatch); |
1017 if ((pProp->type != type) && (mode != PropModeReplace)) |
1003 if ((pProp->type != type) && (mode != PropModeReplace)) |
1018 return(BadMatch); |
1004 return(BadMatch); |
1019 |
1005 |
1020 tsolprop = (TsolPropPtr)(pProp->secPrivate); |
1006 tsolpropP = TsolPropertyPriv(pProp); |
1007 tsolprop = *tsolpropP; |
|
1021 /* search for a matching (sl, uid) pair */ |
1008 /* search for a matching (sl, uid) pair */ |
1022 while (tsolprop) |
1009 while (tsolprop) |
1023 { |
1010 { |
1024 if (tsolprop->uid == tsolinfo->uid && tsolprop->sl == tsolinfo->sl) |
1011 if (tsolprop->uid == tsolinfo->uid && tsolprop->sl == tsolinfo->sl) |
1025 break; /* match found */ |
1012 break; /* match found */ |
1038 xfree(newtsol); |
1025 xfree(newtsol); |
1039 return(BadAlloc); |
1026 return(BadAlloc); |
1040 } |
1027 } |
1041 if (len) |
1028 if (len) |
1042 memcpy((char *)data, (char *)value, totalSize); |
1029 memcpy((char *)data, (char *)value, totalSize); |
1043 |
1030 |
1044 newtsol->sl = tsolinfo->sl; |
1031 newtsol->sl = tsolinfo->sl; |
1045 newtsol->uid = tsolinfo->uid; |
1032 newtsol->uid = tsolinfo->uid; |
1046 newtsol->data = data; |
1033 newtsol->data = data; |
1047 newtsol->size = len; |
1034 newtsol->size = len; |
1048 newtsol->next = (TsolPropPtr)(pProp->secPrivate); |
1035 tsolpropP = TsolPropertyPriv(pProp); |
1049 pProp->secPrivate = (pointer)newtsol; |
1036 newtsol->next = *tsolpropP; |
1037 *tsolpropP = newtsol; |
|
1050 } |
1038 } |
1051 else |
1039 else |
1052 { |
1040 { |
1053 switch (mode) |
1041 switch (mode) |
1054 { |
1042 { |
1055 case PropModeReplace: |
1043 case PropModeReplace: |
1056 if (totalSize != tsolprop->size * (pProp->format >> 3)) |
1044 if (totalSize != tsolprop->size * (pProp->format >> 3)) |
1057 { |
1045 { |
1058 data = (pointer)xrealloc(tsolprop->data, totalSize); |
1046 data = (pointer)xrealloc(tsolprop->data, totalSize); |
1059 if (!data && len) |
1047 if (!data && len) |
1060 return(BadAlloc); |
1048 return(BadAlloc); |
1064 bcopy((char *)value, (char *)tsolprop->data, totalSize); |
1052 bcopy((char *)value, (char *)tsolprop->data, totalSize); |
1065 tsolprop->size = len; |
1053 tsolprop->size = len; |
1066 pProp->type = type; |
1054 pProp->type = type; |
1067 pProp->format = format; |
1055 pProp->format = format; |
1068 break; |
1056 break; |
1069 |
1057 |
1070 case PropModeAppend: |
1058 case PropModeAppend: |
1071 if (len) |
1059 if (len) |
1072 { |
1060 { |
1073 data = |
1061 data = |
1074 (pointer)xrealloc(tsolprop->data, |
1062 (pointer)xrealloc(tsolprop->data, |
1080 &((char *)data)[tsolprop->size * sizeInBytes], |
1068 &((char *)data)[tsolprop->size * sizeInBytes], |
1081 totalSize); |
1069 totalSize); |
1082 tsolprop->size += len; |
1070 tsolprop->size += len; |
1083 } |
1071 } |
1084 break; |
1072 break; |
1085 |
1073 |
1086 case PropModePrepend: |
1074 case PropModePrepend: |
1087 if (len) |
1075 if (len) |
1088 { |
1076 { |
1089 data = |
1077 data = |
1090 (pointer)xalloc(sizeInBytes*(len + tsolprop->size)); |
1078 (pointer)xalloc(sizeInBytes*(len + tsolprop->size)); |
1112 |
1100 |
1113 return(Success); |
1101 return(Success); |
1114 } |
1102 } |
1115 |
1103 |
1116 int |
1104 int |
1117 TsolInitWindow(client, pWin) |
1105 TsolInitWindow( |
1118 ClientPtr client; |
1106 ClientPtr client, |
1119 WindowPtr pWin; |
1107 WindowPtr pWin) |
1120 { |
1108 { |
1121 TsolInfoPtr tsolinfo; |
1109 TsolInfoPtr tsolinfo; |
1122 TsolResPtr tsolres = (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr); |
1110 TsolResPtr tsolres = TsolWindowPriv(pWin); |
1123 |
1111 |
1124 if (client == serverClient) |
1112 if (client == serverClient) |
1125 { |
1113 { |
1126 tsolres->uid = 0; |
1114 tsolres->uid = 0; |
1127 tsolres->sl = (bslabel_t *)lookupSL_low(); |
1115 tsolres->sl = (bslabel_t *)lookupSL_low(); |
1135 |
1123 |
1136 return (Success); |
1124 return (Success); |
1137 } |
1125 } |
1138 |
1126 |
1139 int |
1127 int |
1140 TsolDeleteProperty(client, pWin, propName) |
1128 TsolDeleteProperty( |
1141 ClientPtr client; |
1129 ClientPtr client, |
1142 WindowPtr pWin; |
1130 WindowPtr pWin, |
1143 Atom propName; |
1131 Atom propName) |
1144 { |
1132 { |
1145 PropertyPtr pProp, prevProp; |
1133 PropertyPtr pProp, prevProp; |
1146 xEvent event; |
1134 xEvent event; |
1147 TsolPropPtr tsolprop, tail_prop, prevtsolprop; |
1135 TsolPropPtr tsolprop, tail_prop, prevtsolprop; |
1136 TsolPropPtr *tsolpropP; |
|
1148 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
1137 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
1149 |
1138 |
1150 if (!(pProp = wUserProps (pWin))) |
1139 if (!(pProp = wUserProps (pWin))) |
1151 return(Success); |
1140 return(Success); |
1152 |
1141 |
1153 if (!PolyProperty(propName, pWin)) |
1142 if (!PolyProperty(propName, pWin)) |
1154 return (DeleteProperty(pWin, propName)); |
1143 return (DeleteProperty(client, pWin, propName)); |
1155 |
1144 |
1156 prevProp = (PropertyPtr)NULL; |
1145 prevProp = (PropertyPtr)NULL; |
1157 while (pProp) |
1146 while (pProp) |
1158 { |
1147 { |
1159 if (pProp->propertyName == propName) |
1148 if (pProp->propertyName == propName) |
1160 { |
1149 { |
1161 tsolprop = (TsolPropPtr)(pProp->secPrivate); |
1150 tsolpropP = TsolPropertyPriv(pProp); |
1151 tsolprop = *tsolpropP; |
|
1162 /* Found a matching name. Further match for SL,UID */ |
1152 /* Found a matching name. Further match for SL,UID */ |
1163 prevtsolprop = (TsolPropPtr)NULL; |
1153 prevtsolprop = (TsolPropPtr)NULL; |
1164 tail_prop = tsolprop; |
1154 tail_prop = tsolprop; |
1165 while (tsolprop) |
1155 while (tsolprop) |
1166 { |
1156 { |
1187 } |
1177 } |
1188 prevProp = pProp; |
1178 prevProp = pProp; |
1189 pProp = pProp->next; |
1179 pProp = pProp->next; |
1190 } |
1180 } |
1191 |
1181 |
1192 if (pProp) |
1182 if (pProp) |
1193 { |
1183 { |
1194 event.u.u.type = PropertyNotify; |
1184 event.u.u.type = PropertyNotify; |
1195 event.u.property.window = pWin->drawable.id; |
1185 event.u.property.window = pWin->drawable.id; |
1196 event.u.property.state = PropertyDelete; |
1186 event.u.property.state = PropertyDelete; |
1197 event.u.property.atom = pProp->propertyName; |
1187 event.u.property.atom = pProp->propertyName; |
1198 event.u.property.time = currentTime.milliseconds; |
1188 event.u.property.time = currentTime.milliseconds; |
1199 DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); |
1189 DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); |
1200 |
1190 |
1201 if (tsolprop) |
1191 if (tsolprop) |
1202 { |
1192 { |
1203 if ((TsolPropPtr)(pProp->secPrivate) == tsolprop) |
1193 tsolpropP = TsolPropertyPriv(pProp); |
1204 pProp->secPrivate = (pointer)(tsolprop->next); |
1194 if (*tsolpropP == tsolprop) |
1195 *tsolpropP = tsolprop->next; |
|
1205 |
1196 |
1206 if (prevtsolprop) |
1197 if (prevtsolprop) |
1207 { |
1198 { |
1208 prevtsolprop->next = tsolprop->next; |
1199 prevtsolprop->next = tsolprop->next; |
1209 } |
1200 } |
1214 } |
1205 } |
1215 return(Success); |
1206 return(Success); |
1216 } |
1207 } |
1217 |
1208 |
1218 int |
1209 int |
1219 ProcTsolListProperties(client) |
1210 ProcTsolListProperties(ClientPtr client) |
1220 ClientPtr client; |
|
1221 { |
1211 { |
1222 Atom *pAtoms, *temppAtoms; |
1212 Atom *pAtoms, *temppAtoms; |
1223 xListPropertiesReply xlpr; |
1213 xListPropertiesReply xlpr; |
1224 int numProps = 0; |
1214 int rc, numProps = 0; |
1225 WindowPtr pWin; |
1215 WindowPtr pWin; |
1226 PropertyPtr pProp; |
1216 PropertyPtr pProp; |
1227 REQUEST(xResourceReq); |
1217 REQUEST(xResourceReq); |
1228 int err_code; |
|
1229 |
1218 |
1230 REQUEST_SIZE_MATCH(xResourceReq); |
1219 REQUEST_SIZE_MATCH(xResourceReq); |
1231 pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, |
1220 rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess); |
1232 SecurityReadAccess); |
1221 if (rc != Success) |
1233 if (!pWin) |
1222 return rc; |
1234 return(BadWindow); |
|
1235 |
1223 |
1236 /* policy check for window */ |
1224 /* policy check for window */ |
1237 if (err_code = xtsol_policy(TSOL_RES_PROPWIN, TSOL_READ, pWin, |
1225 if (rc = xtsol_policy(TSOL_RES_PROPWIN, TSOL_READ, pWin, |
1238 client, TSOL_ALL, (void *)MAJOROP)) |
1226 client, TSOL_ALL, (void *)MAJOROP)) |
1239 { |
1227 { |
1240 client->errorValue = stuff->id; |
1228 client->errorValue = stuff->id; |
1241 return (err_code); |
1229 return (rc); |
1242 } |
1230 } |
1243 |
1231 |
1244 pProp = wUserProps (pWin); |
1232 for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) |
1245 while (pProp) |
1233 numProps++; |
1246 { |
1234 |
1235 if (numProps && !(pAtoms = (Atom *)xalloc(numProps * sizeof(Atom)))) |
|
1236 return BadAlloc; |
|
1237 |
|
1238 numProps = 0; |
|
1239 temppAtoms = pAtoms; |
|
1240 for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) |
|
1241 { |
|
1247 if (PolyProperty(pProp->propertyName, pWin)) |
1242 if (PolyProperty(pProp->propertyName, pWin)) |
1248 { |
1243 { |
1249 if (PolyPropReadable(pProp, client)) |
1244 if (PolyPropReadable(pProp, client)) { |
1250 numProps++; |
1245 *temppAtoms++ = pProp->propertyName; |
1246 numProps++; |
|
1247 } |
|
1251 } |
1248 } |
1252 else |
1249 else |
1253 { |
1250 { |
1254 /* error ignored */ |
1251 /* error ignored */ |
1255 if (!xtsol_policy(TSOL_RES_PROPERTY, TSOL_READ, pProp, |
1252 if (!xtsol_policy(TSOL_RES_PROPERTY, TSOL_READ, pProp, |
1256 client, TSOL_ALL, (void *)MAJOROP)) |
1253 client, TSOL_ALL, (void *)MAJOROP)) { |
1257 numProps++; |
1254 *temppAtoms++ = pProp->propertyName; |
1255 numProps++; |
|
1256 } |
|
1258 } |
1257 } |
1259 pProp = pProp->next; |
1258 } |
1260 } |
|
1261 |
|
1262 if (numProps) |
|
1263 if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom)))) |
|
1264 return(BadAlloc); |
|
1265 |
1259 |
1266 xlpr.type = X_Reply; |
1260 xlpr.type = X_Reply; |
1267 xlpr.nProperties = numProps; |
1261 xlpr.nProperties = numProps; |
1268 xlpr.length = (numProps * sizeof(Atom)) >> 2; |
1262 xlpr.length = (numProps * sizeof(Atom)) >> 2; |
1269 xlpr.sequenceNumber = client->sequence; |
1263 xlpr.sequenceNumber = client->sequence; |
1270 pProp = wUserProps (pWin); |
|
1271 temppAtoms = pAtoms; |
|
1272 while (pProp) |
|
1273 { |
|
1274 if (PolyProperty(pProp->propertyName, pWin)) |
|
1275 { |
|
1276 if (PolyPropReadable(pProp, client)) |
|
1277 *temppAtoms++ = pProp->propertyName; |
|
1278 } |
|
1279 else |
|
1280 { |
|
1281 /* error ignored */ |
|
1282 if (!xtsol_policy(TSOL_RES_PROPERTY, TSOL_READ, pProp, |
|
1283 client, TSOL_ALL, (void *)MAJOROP)) |
|
1284 *temppAtoms++ = pProp->propertyName; |
|
1285 } |
|
1286 pProp = pProp->next; |
|
1287 } |
|
1288 WriteReplyToClient(client, sizeof(xGenericReply), &xlpr); |
1264 WriteReplyToClient(client, sizeof(xGenericReply), &xlpr); |
1289 if (numProps) |
1265 if (numProps) |
1290 { |
1266 { |
1291 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; |
1267 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; |
1292 WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); |
1268 WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); |
1293 DEALLOCATE_LOCAL(pAtoms); |
1269 } |
1294 } |
1270 xfree(pAtoms); |
1295 return(client->noClientException); |
1271 return(client->noClientException); |
1296 } |
1272 } |
1297 |
1273 |
1298 int |
1274 int |
1299 ProcTsolGetProperty(client) |
1275 ProcTsolGetProperty(ClientPtr client) |
1300 ClientPtr client; |
|
1301 { |
1276 { |
1302 PropertyPtr pProp, prevProp; |
1277 PropertyPtr pProp, prevProp; |
1303 unsigned long n, len, ind; |
1278 unsigned long n, len, ind; |
1279 int rc; |
|
1304 WindowPtr pWin; |
1280 WindowPtr pWin; |
1305 xGetPropertyReply reply; |
1281 xGetPropertyReply reply; |
1282 Mask win_mode = DixGetPropAccess, prop_mode = DixReadAccess; |
|
1283 |
|
1306 TsolPropPtr tsolprop; |
1284 TsolPropPtr tsolprop; |
1307 TsolPropPtr prevtsolprop; |
1285 TsolPropPtr prevtsolprop; |
1308 int err_code; |
|
1309 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
1286 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
1287 |
|
1310 REQUEST(xGetPropertyReq); |
1288 REQUEST(xGetPropertyReq); |
1311 |
1289 |
1312 REQUEST_SIZE_MATCH(xGetPropertyReq); |
1290 REQUEST_SIZE_MATCH(xGetPropertyReq); |
1313 if (stuff->delete) |
1291 if (stuff->delete) { |
1314 UpdateCurrentTime(); |
1292 UpdateCurrentTime(); |
1315 pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, |
1293 win_mode |= DixSetPropAccess; |
1316 SecurityReadAccess); |
1294 prop_mode |= DixDestroyAccess; |
1317 if (!pWin) |
1295 } |
1318 return BadWindow; |
1296 rc = dixLookupWindow(&pWin, stuff->window, client, win_mode); |
1297 if (rc != Success) |
|
1298 return rc; |
|
1319 |
1299 |
1320 if (!ValidAtom(stuff->property)) |
1300 if (!ValidAtom(stuff->property)) |
1321 { |
1301 { |
1322 client->errorValue = stuff->property; |
1302 client->errorValue = stuff->property; |
1323 return(BadAtom); |
1303 return(BadAtom); |
1334 return(BadAtom); |
1314 return(BadAtom); |
1335 } |
1315 } |
1336 |
1316 |
1337 |
1317 |
1338 /* policy check for window */ |
1318 /* policy check for window */ |
1339 if (err_code = xtsol_policy(TSOL_RES_PROPWIN, TSOL_READ, pWin, |
1319 if (rc = xtsol_policy(TSOL_RES_PROPWIN, TSOL_READ, pWin, |
1340 client, TSOL_ALL, (void *)MAJOROP)) |
1320 client, TSOL_ALL, (void *)MAJOROP)) |
1341 { |
1321 { |
1342 client->errorValue = stuff->window; |
1322 client->errorValue = stuff->window; |
1343 return (err_code); |
1323 return (rc); |
1344 } |
1324 } |
1345 |
1325 |
1346 if (!PolyProperty(stuff->property, pWin)) |
1326 if (!PolyProperty(stuff->property, pWin)) |
1347 { |
1327 { |
1348 return (*TsolSavedProcVector[X_GetProperty])(client); |
1328 return (*TsolSavedProcVector[X_GetProperty])(client); |
1353 |
1333 |
1354 while (pProp) |
1334 while (pProp) |
1355 { |
1335 { |
1356 if (pProp->propertyName == stuff->property) |
1336 if (pProp->propertyName == stuff->property) |
1357 { |
1337 { |
1358 tsolprop = (TsolPropPtr)(pProp->secPrivate); |
1338 tsolprop = *(TsolPropertyPriv(pProp)); |
1359 prevtsolprop = tsolprop; |
1339 prevtsolprop = tsolprop; |
1360 while (tsolprop) |
1340 while (tsolprop) |
1361 { |
1341 { |
1362 if (tsolpolyinstinfo.enabled) |
1342 if (tsolpolyinstinfo.enabled) |
1363 { |
1343 { |
1381 } |
1361 } |
1382 |
1362 |
1383 reply.type = X_Reply; |
1363 reply.type = X_Reply; |
1384 reply.sequenceNumber = client->sequence; |
1364 reply.sequenceNumber = client->sequence; |
1385 |
1365 |
1386 if ( (!pProp) || (!tsolprop) || err_code) |
1366 if ( (!pProp) || (!tsolprop) || rc) |
1387 { |
1367 { |
1388 reply.nItems = 0; |
1368 reply.nItems = 0; |
1389 reply.length = 0; |
1369 reply.length = 0; |
1390 reply.bytesAfter = 0; |
1370 reply.bytesAfter = 0; |
1391 reply.propertyType = None; |
1371 reply.propertyType = None; |
1410 } |
1390 } |
1411 |
1391 |
1412 /* |
1392 /* |
1413 * Return type, format, value to client |
1393 * Return type, format, value to client |
1414 */ |
1394 */ |
1415 n = (pProp->format/8) * tsolprop->size; |
1395 n = (pProp->format/8) * tsolprop->size; |
1416 |
1396 |
1417 ind = stuff->longOffset << 2; |
1397 ind = stuff->longOffset << 2; |
1418 |
1398 |
1419 /* If longOffset is invalid such that it causes "len" to |
1399 /* If longOffset is invalid such that it causes "len" to |
1420 be negative, it's a value error. */ |
1400 be negative, it's a value error. */ |
1421 |
1401 |
1422 if (n < ind) |
1402 if (n < ind) |
1437 if (stuff->delete && (reply.bytesAfter == 0) && |
1417 if (stuff->delete && (reply.bytesAfter == 0) && |
1438 (!xtsol_policy(TSOL_RES_PROPERTY, TSOL_DESTROY, pProp, |
1418 (!xtsol_policy(TSOL_RES_PROPERTY, TSOL_DESTROY, pProp, |
1439 client, TSOL_ALL, (void *)MAJOROP))) |
1419 client, TSOL_ALL, (void *)MAJOROP))) |
1440 { /* send the event */ |
1420 { /* send the event */ |
1441 xEvent event; |
1421 xEvent event; |
1442 |
1422 |
1443 event.u.u.type = PropertyNotify; |
1423 event.u.u.type = PropertyNotify; |
1444 event.u.property.window = pWin->drawable.id; |
1424 event.u.property.window = pWin->drawable.id; |
1445 event.u.property.state = PropertyDelete; |
1425 event.u.property.state = PropertyDelete; |
1446 event.u.property.atom = pProp->propertyName; |
1426 event.u.property.atom = pProp->propertyName; |
1447 event.u.property.time = currentTime.milliseconds; |
1427 event.u.property.time = currentTime.milliseconds; |
1479 } |
1459 } |
1480 } |
1460 } |
1481 return (client->noClientException); |
1461 return (client->noClientException); |
1482 } |
1462 } |
1483 |
1463 |
1484 int |
1464 /* Generic ProcVector wrapper for functions which just need to set the |
1485 ProcTsolChangeKeyboardMapping(client) |
1465 client's TrustLevel to Trusted before executing. */ |
1486 ClientPtr client; |
1466 static inline int |
1467 ProcTsolUnwrapWithTrust(ClientPtr client, int majorop) |
|
1468 { |
|
1469 int result, savedtrust; |
|
1470 |
|
1471 savedtrust = setClientTrustLevel(client, XSecurityClientTrusted); |
|
1472 result = (*TsolSavedProcVector[majorop])(client); |
|
1473 setClientTrustLevel(client, savedtrust); |
|
1474 |
|
1475 return result; |
|
1476 } |
|
1477 |
|
1478 /* Generic ProcVector wrapper for functions which need to check |
|
1479 a policy before executing. If policy check fails, and reportErrors |
|
1480 is False, ignores error and returns success to client even though it's |
|
1481 not actually doing anything. If policy check succeeds, and makeTrusted |
|
1482 is True, set the clients TrustLevel before calling the wrapped function. |
|
1483 */ |
|
1484 #define IGNORE_ERRORS FALSE |
|
1485 #define REPORT_ERRORS TRUE |
|
1486 #define KEEP_TRUSTLEVEL FALSE |
|
1487 #define RAISE_TRUSTLEVEL TRUE |
|
1488 |
|
1489 static inline int |
|
1490 ProcTsolUnwrapResourceAccess(ClientPtr client, xresource_t res_type, |
|
1491 xmethod_t method, XID resource, |
|
1492 Bool reportErrors, Bool makeTrusted) |
|
1487 { |
1493 { |
1488 int status; |
1494 int status; |
1489 int savedtrust = client->trustLevel; |
1495 |
1490 |
1496 status = xtsol_policy(res_type, method, (void *) resource, client, |
1491 client->trustLevel = XSecurityClientTrusted; |
1497 TSOL_ALL, (void *)MAJOROP); |
1492 |
1498 |
1493 if (xtsol_policy(TSOL_RES_KEYMAP, TSOL_MODIFY, |
1499 if (status != PASSED) |
1494 NULL, client, TSOL_ALL, (void *)MAJOROP)) |
1500 { |
1495 { |
1501 if (!reportErrors) { |
1496 status = client->noClientException; /* ignore error */ |
1502 status = client->noClientException; /* ignore error */ |
1503 } else if (resource != NULL) { |
|
1504 client->errorValue = resource; |
|
1505 } |
|
1506 } |
|
1507 else if (makeTrusted) |
|
1508 { |
|
1509 status = ProcTsolUnwrapWithTrust(client, MAJOROP); |
|
1497 } |
1510 } |
1498 else |
1511 else |
1499 { |
1512 { |
1500 status = (*TsolSavedProcVector[X_ChangeKeyboardMapping])(client); |
1513 status = (*TsolSavedProcVector[MAJOROP])(client); |
1501 } |
1514 } |
1502 |
1515 |
1503 client->trustLevel = savedtrust; |
|
1504 return (status); |
1516 return (status); |
1505 } |
1517 } |
1506 |
1518 |
1507 int |
1519 int |
1508 ProcTsolSetPointerMapping(client) |
1520 ProcTsolChangeKeyboardMapping(ClientPtr client) |
1509 ClientPtr client; |
1521 { |
1510 { |
1522 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_KEYMAP, TSOL_MODIFY, |
1511 int status; |
1523 NULL, IGNORE_ERRORS, RAISE_TRUSTLEVEL); |
1512 int savedtrust = client->trustLevel; |
1524 } |
1513 |
1525 |
1514 client->trustLevel = XSecurityClientTrusted; |
1526 int |
1515 |
1527 ProcTsolSetPointerMapping(ClientPtr client) |
1516 if (xtsol_policy(TSOL_RES_PTRMAP, TSOL_MODIFY, |
1528 { |
1517 NULL, client, TSOL_ALL, (void *)MAJOROP)) |
1529 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_PTRMAP, TSOL_MODIFY, |
1518 { |
1530 NULL, IGNORE_ERRORS, RAISE_TRUSTLEVEL); |
1519 status = Success; /* ignore error */ |
1531 } |
1520 } |
1532 |
1521 else |
1533 int |
1522 { |
1534 ProcTsolChangeKeyboardControl(ClientPtr client) |
1523 status = (*TsolSavedProcVector[X_SetPointerMapping])(client); |
1535 { |
1524 } |
1536 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_KBDCTL, TSOL_MODIFY, |
1525 |
1537 NULL, IGNORE_ERRORS, RAISE_TRUSTLEVEL); |
1526 client->trustLevel = savedtrust; |
1538 } |
1527 return (status); |
1539 |
1528 } |
1540 int |
1529 |
1541 ProcTsolBell(ClientPtr client) |
1530 int |
1542 { |
1531 ProcTsolChangeKeyboardControl(client) |
1543 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_BELL, TSOL_MODIFY, |
1532 ClientPtr client; |
1544 NULL, IGNORE_ERRORS, RAISE_TRUSTLEVEL); |
1533 { |
1545 } |
1534 int status; |
1546 |
1535 int savedtrust = client->trustLevel; |
1547 int |
1536 |
1548 ProcTsolChangePointerControl(ClientPtr client) |
1537 client->trustLevel = XSecurityClientTrusted; |
1549 { |
1538 |
1550 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_PTRCTL, TSOL_MODIFY, |
1539 if (xtsol_policy(TSOL_RES_KBDCTL, TSOL_MODIFY, |
1551 NULL, IGNORE_ERRORS, RAISE_TRUSTLEVEL); |
1540 NULL, client, TSOL_ALL, (void *)MAJOROP)) |
1552 } |
1541 { |
1553 |
1542 status = Success; /* ignore error */ |
1554 int |
1543 } |
1555 ProcTsolSetModifierMapping(ClientPtr client) |
1544 else |
|
1545 { |
|
1546 status = (*TsolSavedProcVector[X_ChangeKeyboardControl])(client); |
|
1547 } |
|
1548 |
|
1549 client->trustLevel = savedtrust; |
|
1550 return (status); |
|
1551 } |
|
1552 |
|
1553 int |
|
1554 ProcTsolBell(client) |
|
1555 ClientPtr client; |
|
1556 { |
|
1557 int status; |
|
1558 int savedtrust = client->trustLevel; |
|
1559 |
|
1560 client->trustLevel = XSecurityClientTrusted; |
|
1561 |
|
1562 if (xtsol_policy(TSOL_RES_BELL, TSOL_MODIFY, |
|
1563 NULL, client, TSOL_ALL, (void *)MAJOROP)) |
|
1564 { |
|
1565 status = Success; /* ignore error */ |
|
1566 } |
|
1567 else |
|
1568 { |
|
1569 status = (*TsolSavedProcVector[X_Bell])(client); |
|
1570 } |
|
1571 |
|
1572 client->trustLevel = savedtrust; |
|
1573 return (status); |
|
1574 } |
|
1575 |
|
1576 int |
|
1577 ProcTsolChangePointerControl(client) |
|
1578 ClientPtr client; |
|
1579 { |
|
1580 int status; |
|
1581 int savedtrust = client->trustLevel; |
|
1582 |
|
1583 client->trustLevel = XSecurityClientTrusted; |
|
1584 |
|
1585 if (xtsol_policy(TSOL_RES_PTRCTL, TSOL_MODIFY, |
|
1586 NULL, client, TSOL_ALL, (void *)MAJOROP)) |
|
1587 { |
|
1588 status = Success; /* ignore error */ |
|
1589 } |
|
1590 else |
|
1591 { |
|
1592 status = (*TsolSavedProcVector[X_ChangePointerControl])(client); |
|
1593 } |
|
1594 |
|
1595 client->trustLevel = savedtrust; |
|
1596 return (status); |
|
1597 } |
|
1598 |
|
1599 int |
|
1600 ProcTsolSetModifierMapping(client) |
|
1601 ClientPtr client; |
|
1602 { |
1556 { |
1603 |
1557 |
1604 xSetModifierMappingReply rep; |
1558 xSetModifierMappingReply rep; |
1605 REQUEST(xSetModifierMappingReq); |
1559 REQUEST(xSetModifierMappingReq); |
1606 KeyCode *inputMap; |
1560 KeyCode *inputMap; |
1607 int inputMapLen; |
1561 int inputMapLen; |
1608 register int i; |
1562 register int i; |
1609 int status; |
1563 int status; |
1610 DeviceIntPtr keybd = inputInfo.keyboard; |
1564 DeviceIntPtr pDev = NULL; |
1611 register KeyClassPtr keyc = keybd->key; |
1565 int savedtrust; |
1612 int savedtrust = client->trustLevel; |
1566 |
1613 |
|
1614 REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); |
1567 REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); |
1615 |
1568 |
1616 if (client->req_len != ((stuff->numKeyPerModifier<<1) + |
1569 if (client->req_len != ((stuff->numKeyPerModifier<<1) + |
1617 (sizeof (xSetModifierMappingReq)>>2))) |
1570 (sizeof (xSetModifierMappingReq)>>2))) |
1618 return BadLength; |
1571 return BadLength; |
1619 |
1572 |
1620 inputMapLen = 8*stuff->numKeyPerModifier; |
1573 inputMapLen = 8 * stuff->numKeyPerModifier; |
1621 inputMap = (KeyCode *)&stuff[1]; |
1574 inputMap = (KeyCode *)&stuff[1]; |
1622 |
1575 |
1623 /* |
1576 /* |
1624 * Now enforce the restriction that "all of the non-zero keycodes must be |
1577 * Now enforce the restriction that "all of the non-zero keycodes must be |
1625 * in the range specified by min-keycode and max-keycode in the |
1578 * in the range specified by min-keycode and max-keycode in the |
1626 * connection setup (else a Value error)" |
1579 * connection setup (else a Value error)" |
1627 */ |
1580 */ |
1628 i = inputMapLen; |
1581 for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { |
1629 while (i--) |
1582 if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) { |
1630 { |
1583 for (i = 0; i < inputMapLen; i++) { |
1631 if (inputMap[i] |
1584 /* Check that all the new modifiers fall within the advertised |
1632 && (inputMap[i] < keyc->curKeySyms.minKeyCode |
1585 * keycode range, and are okay with the DDX. */ |
1633 || inputMap[i] > keyc->curKeySyms.maxKeyCode)) |
1586 if (inputMap[i] && ((inputMap[i] < pDev->key->curKeySyms.minKeyCode || |
1634 { |
1587 inputMap[i] > pDev->key->curKeySyms.maxKeyCode) || |
1635 client->errorValue = inputMap[i]; |
1588 !LegalModifier(inputMap[i], pDev))) { |
1636 return BadValue; |
1589 client->errorValue = inputMap[i]; |
1590 return BadValue; |
|
1591 } |
|
1592 } |
|
1637 } |
1593 } |
1638 } |
1594 } |
1639 |
1595 |
1640 rep.type = X_Reply; |
1596 rep.type = X_Reply; |
1641 rep.length = 0; |
1597 rep.length = 0; |
1642 rep.sequenceNumber = client->sequence; |
1598 rep.sequenceNumber = client->sequence; |
1643 rep.success = MappingSuccess; |
1599 rep.success = MappingSuccess; |
1644 |
1600 |
1645 client->trustLevel = XSecurityClientTrusted; |
1601 savedtrust = setClientTrustLevel(client, XSecurityClientTrusted); |
1646 |
1602 |
1647 if (xtsol_policy(TSOL_RES_MODMAP, TSOL_MODIFY, |
1603 |
1604 if (xtsol_policy(TSOL_RES_MODMAP, TSOL_MODIFY, |
|
1648 NULL, client, TSOL_ALL, (void *)MAJOROP)) |
1605 NULL, client, TSOL_ALL, (void *)MAJOROP)) |
1649 { |
1606 { |
1650 /* |
1607 /* |
1651 * silently ignore the request. xview apps |
1608 * silently ignore the request. xview apps |
1652 * complain if we return error code. If we don't |
1609 * complain if we return error code. If we don't |
1653 * send the map notify event application hangs |
1610 * send the map notify event application hangs |
1654 */ |
1611 */ |
1655 SendMappingNotify(MappingModifier, 0, 0,client); |
1612 SendMappingNotify(MappingModifier, 0, 0, client); |
1656 WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep); |
1613 WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep); |
1657 status = client->noClientException; |
1614 status = client->noClientException; |
1658 } |
1615 } |
1659 else |
1616 else |
1660 { |
1617 { |
1661 status = (*TsolSavedProcVector[X_SetModifierMapping])(client); |
1618 status = (*TsolSavedProcVector[X_SetModifierMapping])(client); |
1662 } |
1619 } |
1663 |
1620 |
1664 client->trustLevel = savedtrust; |
1621 setClientTrustLevel(client, savedtrust); |
1665 return (status); |
1622 return (status); |
1666 } |
1623 } |
1667 |
1624 |
1668 static void |
1625 static void |
1669 ResetStripeWindow(ClientPtr client) |
1626 ResetStripeWindow(ClientPtr client) |
1670 { |
1627 { |
1671 WindowPtr pParent; |
1628 WindowPtr pParent; |
1672 WindowPtr pWin = NULL; |
1629 WindowPtr pWin = NULL; |
1673 |
1630 |
1674 #if defined(PANORAMIX) |
1631 #if defined(PANORAMIX) |
1675 if (!noPanoramiXExtension) |
1632 if (!noPanoramiXExtension) |
1676 { |
1633 { |
1677 #if defined(IN_MODULE) |
|
1678 PanoramiXRes *panres = NULL; |
1634 PanoramiXRes *panres = NULL; |
1679 int j; |
1635 int j; |
1680 |
1636 |
1681 if (tpwin) { |
1637 if (tpwin) { |
1682 if ((panres = (PanoramiXRes *)LookupIDByType(tpwin->drawable.id, |
1638 if ((panres = (PanoramiXRes *)LookupIDByType(tpwin->drawable.id, |
1698 if (!pParent || pParent->firstChild == pWin) |
1654 if (!pParent || pParent->firstChild == pWin) |
1699 return; |
1655 return; |
1700 |
1656 |
1701 ReflectStackChange(pWin, pParent->firstChild, VTStack); |
1657 ReflectStackChange(pWin, pParent->firstChild, VTStack); |
1702 } |
1658 } |
1703 #else |
|
1704 PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; |
|
1705 int j; |
|
1706 |
|
1707 if (tpwin) { |
|
1708 PANORAMIXFIND_ID(pPanoramiXWin, tpwin->drawable.id); |
|
1709 if (pPanoramiXWin == NULL) |
|
1710 return; |
|
1711 } |
|
1712 |
|
1713 FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) |
|
1714 { |
|
1715 if (pPanoramiXWin == NULL) |
|
1716 return; |
|
1717 /* Validate trusted stripe window */ |
|
1718 pWin = LookupWindow(pPanoramiXWin->info[j].id, client); |
|
1719 |
|
1720 if (tpwin == NullWindow || pWin == NullWindow) |
|
1721 return; |
|
1722 |
|
1723 pParent = pWin->parent; |
|
1724 if (!pParent || pParent->firstChild == pWin) |
|
1725 return; |
|
1726 |
|
1727 ReflectStackChange(pWin, pParent->firstChild, VTStack); |
|
1728 } |
|
1729 #endif |
|
1730 } else |
1659 } else |
1731 #endif |
1660 #endif |
1732 { |
1661 { |
1733 /* Validate trusted stripe window */ |
1662 /* Validate trusted stripe window */ |
1734 if (tpwin) |
1663 if (tpwin) |
1745 ReflectStackChange(tpwin, pParent->firstChild, VTStack); |
1674 ReflectStackChange(tpwin, pParent->firstChild, VTStack); |
1746 } |
1675 } |
1747 } |
1676 } |
1748 |
1677 |
1749 int |
1678 int |
1750 ProcTsolCreateWindow(client) |
1679 ProcTsolCreateWindow(ClientPtr client) |
1751 ClientPtr client; |
1680 { |
1752 { |
1681 int rc; |
1753 int result; |
|
1754 WindowPtr pParent; |
1682 WindowPtr pParent; |
1755 WindowPtr pWin; |
1683 WindowPtr pWin; |
1756 bslabel_t admin_low; |
1684 bslabel_t admin_low; |
1757 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
1685 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
1758 TsolResPtr tsolres; |
1686 TsolResPtr tsolres; |
1759 |
1687 |
1760 REQUEST(xCreateWindowReq); |
1688 REQUEST(xCreateWindowReq); |
1761 |
1689 |
1762 REQUEST_AT_LEAST_SIZE(xCreateWindowReq); |
1690 REQUEST_AT_LEAST_SIZE(xCreateWindowReq); |
1763 |
1691 |
1764 LEGAL_NEW_RESOURCE(stuff->wid, client); |
1692 LEGAL_NEW_RESOURCE(stuff->wid, client); |
1765 if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, |
1693 rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess); |
1766 SecurityWriteAccess))) |
1694 if (rc != Success) |
1767 return BadWindow; |
1695 return rc; |
1768 |
1696 |
1769 |
1697 if (rc = xtsol_policy(TSOL_RES_WINDOW, TSOL_CREATE, pParent, |
1770 if (result = xtsol_policy(TSOL_RES_WINDOW, TSOL_CREATE, pParent, |
1698 client, TSOL_ALL, (void *)MAJOROP)) |
1771 client, TSOL_ALL, (void *)MAJOROP)) |
1699 return rc; |
1772 return (result); |
|
1773 |
1700 |
1774 /* Initialize tsol security attributes */ |
1701 /* Initialize tsol security attributes */ |
1775 result = (*TsolSavedProcVector[X_CreateWindow])(client); |
1702 rc = (*TsolSavedProcVector[X_CreateWindow])(client); |
1776 pWin = pParent->firstChild; |
1703 pWin = pParent->firstChild; |
1777 tsolres = (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr); |
1704 tsolres = TsolWindowPriv(pWin); |
1778 |
1705 |
1779 /* stuff tsol info into window from client */ |
1706 /* stuff tsol info into window from client */ |
1780 if (tsolinfo == NULL || client == serverClient) { |
1707 if (tsolinfo == NULL || client == serverClient) { |
1781 /* Client is Server itself */ |
1708 /* Client is Server itself */ |
1782 tsolres->uid = 0; |
1709 tsolres->uid = 0; |
1794 else |
1721 else |
1795 tsolres->flags = 0; |
1722 tsolres->flags = 0; |
1796 |
1723 |
1797 ResetStripeWindow(client); |
1724 ResetStripeWindow(client); |
1798 |
1725 |
1726 return rc; |
|
1727 } |
|
1728 |
|
1729 int |
|
1730 ProcTsolChangeWindowAttributes(ClientPtr client) |
|
1731 { |
|
1732 WindowPtr pWin; |
|
1733 REQUEST(xChangeWindowAttributesReq); |
|
1734 int rc; |
|
1735 Mask access_mode = 0; |
|
1736 |
|
1737 REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); |
|
1738 access_mode |= (stuff->valueMask & CWEventMask) ? DixReceiveAccess : 0; |
|
1739 access_mode |= (stuff->valueMask & ~CWEventMask) ? DixSetAttrAccess : 0; |
|
1740 rc = dixLookupWindow(&pWin, stuff->window, client, access_mode); |
|
1741 if (rc != Success) |
|
1742 return rc; |
|
1743 |
|
1744 if (rc = xtsol_policy(TSOL_RES_WINDOW, TSOL_MODIFY, pWin, |
|
1745 client, TSOL_ALL, (void *)MAJOROP)) |
|
1746 { |
|
1747 if (!WindowIsRoot(pWin)) |
|
1748 return (rc); |
|
1749 } |
|
1750 |
|
1751 rc = (*TsolSavedProcVector[X_ChangeWindowAttributes])(client); |
|
1752 ResetStripeWindow(client); |
|
1753 |
|
1754 return rc; |
|
1755 } |
|
1756 |
|
1757 /* Generic ProcVector wrapper for functions which just need to have |
|
1758 ResetStripeWindow called after executing. */ |
|
1759 static inline int |
|
1760 ProcTsolUnwrapAndResetStripe(ClientPtr client, int majorop) |
|
1761 { |
|
1762 int result; |
|
1763 |
|
1764 result = (*TsolSavedProcVector[majorop])(client); |
|
1765 ResetStripeWindow(client); |
|
1766 |
|
1799 return result; |
1767 return result; |
1800 } |
1768 } |
1801 |
1769 |
1802 int |
1770 int |
1803 ProcTsolChangeWindowAttributes(client) |
1771 ProcTsolConfigureWindow(ClientPtr client) |
1804 register ClientPtr client; |
1772 { |
1805 { |
1773 return ProcTsolUnwrapAndResetStripe(client, X_ConfigureWindow); |
1806 register WindowPtr pWin; |
1774 } |
1807 REQUEST(xChangeWindowAttributesReq); |
1775 |
1808 int result; |
1776 int |
1809 |
1777 ProcTsolCirculateWindow(ClientPtr client) |
1810 REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); |
1778 { |
1811 pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, |
1779 return ProcTsolUnwrapAndResetStripe(client, X_CirculateWindow); |
1812 SecurityWriteAccess); |
1780 } |
1813 if (!pWin) |
1781 |
1814 return(BadWindow); |
1782 int |
1815 |
1783 ProcTsolReparentWindow(ClientPtr client) |
1816 if (result = xtsol_policy(TSOL_RES_WINDOW, TSOL_MODIFY, pWin, |
1784 { |
1817 client, TSOL_ALL, (void *)MAJOROP)) |
1785 return ProcTsolUnwrapAndResetStripe(client, X_ReparentWindow); |
1818 { |
1786 } |
1819 if (!WindowIsRoot(pWin)) |
1787 |
1820 return (result); |
1788 int |
1821 } |
1789 ProcTsolSendEvent(ClientPtr client) |
1822 |
|
1823 result = (*TsolSavedProcVector[X_ChangeWindowAttributes])(client); |
|
1824 ResetStripeWindow(client); |
|
1825 |
|
1826 return result; |
|
1827 } |
|
1828 |
|
1829 int |
|
1830 ProcTsolConfigureWindow(client) |
|
1831 register ClientPtr client; |
|
1832 { |
|
1833 int result; |
|
1834 |
|
1835 result = (*TsolSavedProcVector[X_ConfigureWindow])(client); |
|
1836 ResetStripeWindow(client); |
|
1837 |
|
1838 return result; |
|
1839 } |
|
1840 |
|
1841 int |
|
1842 ProcTsolCirculateWindow(client) |
|
1843 register ClientPtr client; |
|
1844 { |
|
1845 int result; |
|
1846 |
|
1847 result = (*TsolSavedProcVector[X_CirculateWindow])(client); |
|
1848 ResetStripeWindow(client); |
|
1849 |
|
1850 return result; |
|
1851 } |
|
1852 |
|
1853 int |
|
1854 ProcTsolReparentWindow(client) |
|
1855 register ClientPtr client; |
|
1856 { |
|
1857 int result; |
|
1858 |
|
1859 result = (*TsolSavedProcVector[X_ReparentWindow])(client); |
|
1860 ResetStripeWindow(client); |
|
1861 |
|
1862 return result; |
|
1863 } |
|
1864 |
|
1865 int |
|
1866 ProcTsolSendEvent(client) |
|
1867 register ClientPtr client; |
|
1868 { |
1790 { |
1869 WindowPtr pWin; |
1791 WindowPtr pWin; |
1870 REQUEST(xSendEventReq); |
1792 REQUEST(xSendEventReq); |
1871 |
1793 |
1872 REQUEST_SIZE_MATCH(xSendEventReq); |
1794 REQUEST_SIZE_MATCH(xSendEventReq); |
1873 |
1795 |
1874 pWin = LookupWindow(stuff->destination, client); |
1796 dixLookupWindow(&pWin, stuff->destination, client, DixSendAccess); |
1875 |
1797 |
1876 if (!pWin) |
1798 if (!pWin) |
1877 return BadWindow; |
1799 return BadWindow; |
1878 |
1800 |
1879 if (xtsol_policy(TSOL_RES_EVENTWIN, TSOL_MODIFY, |
1801 if (xtsol_policy(TSOL_RES_EVENTWIN, TSOL_MODIFY, |
1880 pWin, client, TSOL_ALL, (void *)MAJOROP)) |
1802 pWin, client, TSOL_ALL, (void *)MAJOROP)) |
1881 return Success; /* ignore error */ |
1803 return Success; /* ignore error */ |
1882 |
1804 |
1883 return (*TsolSavedProcVector[X_SendEvent])(client); |
1805 return (*TsolSavedProcVector[X_SendEvent])(client); |
1884 } |
1806 } |
1885 |
1807 |
1886 |
1808 |
1887 /* |
1809 /* |
1888 * HandleHotKey - |
1810 * HandleHotKey - |
1889 * HotKey is Meta(Diamond)+ Stop Key |
1811 * HotKey is Meta(Diamond)+ Stop Key |
1890 * Breaks untusted Ptr and Kbd grabs. |
1812 * Breaks untusted Ptr and Kbd grabs. |
1891 * Trusted Grabs are NOT broken |
1813 * Trusted Grabs are NOT broken |
1892 * Warps pointer to the Trusted Stripe if not Trusted grabs in force. |
1814 * Warps pointer to the Trusted Stripe if not Trusted grabs in force. |
1893 */ |
1815 */ |
1894 void |
1816 void |
1895 HandleHotKey() |
1817 HandleHotKey(void) |
1896 { |
1818 { |
1897 extern unsigned int StripeHeight; |
1819 extern unsigned int StripeHeight; |
1898 int x, y; |
1820 int x, y; |
1899 Bool trusted_grab = FALSE; |
1821 Bool trusted_grab = FALSE; |
1900 ClientPtr client; |
1822 ClientPtr client; |
1901 DeviceIntPtr mouse = inputInfo.pointer; |
1823 DeviceIntPtr mouse = inputInfo.pointer; |
1902 DeviceIntPtr keybd = inputInfo.keyboard; |
1824 DeviceIntPtr keybd = inputInfo.keyboard; |
1903 TsolInfoPtr tsolinfo; |
1825 TsolInfoPtr tsolinfo; |
1904 GrabPtr ptrgrab = mouse->grab; |
1826 GrabPtr ptrgrab = mouse->grab; |
1905 GrabPtr kbdgrab = keybd->grab; |
1827 GrabPtr kbdgrab = keybd->grab; |
1906 ScreenPtr pScreen; |
1828 ScreenPtr pScreen; |
1907 |
1829 |
1908 if (kbdgrab) |
1830 if (kbdgrab) |
1944 (*pScreen->SetCursorPosition)(pScreen, x, y, TRUE); |
1866 (*pScreen->SetCursorPosition)(pScreen, x, y, TRUE); |
1945 } |
1867 } |
1946 } |
1868 } |
1947 |
1869 |
1948 int |
1870 int |
1949 ProcTsolSetInputFocus(client) |
1871 ProcTsolSetInputFocus(ClientPtr client) |
1950 ClientPtr client; |
1872 { |
1951 { |
1873 int rc; |
1952 |
1874 |
1953 REQUEST(xSetInputFocusReq); |
1875 REQUEST(xSetInputFocusReq); |
1954 |
1876 |
1955 REQUEST_SIZE_MATCH(xSetInputFocusReq); |
1877 REQUEST_SIZE_MATCH(xSetInputFocusReq); |
1956 |
1878 |
1957 if (stuff->focus != None) |
1879 if (stuff->focus != None) |
1958 { |
1880 { |
1959 WindowPtr focuswin; |
1881 WindowPtr focusWin; |
1960 |
1882 |
1961 focuswin = LookupWindow(stuff->focus, client); |
1883 rc = dixLookupWindow(&focusWin, stuff->focus, |
1962 if ((focuswin != NullWindow) && |
1884 client, DixSetAttrAccess); |
1963 xtsol_policy(TSOL_RES_FOCUSWIN, TSOL_MODIFY, focuswin, |
1885 if ((rc == Success) && (focusWin != NullWindow) && |
1886 xtsol_policy(TSOL_RES_FOCUSWIN, TSOL_MODIFY, focusWin, |
|
1964 client, TSOL_ALL, (void *)MAJOROP)) |
1887 client, TSOL_ALL, (void *)MAJOROP)) |
1965 { |
1888 { |
1966 return (client->noClientException); |
1889 return (client->noClientException); |
1967 } |
1890 } |
1968 } |
1891 } |
1969 return (*TsolSavedProcVector[X_SetInputFocus])(client); |
1892 return (*TsolSavedProcVector[X_SetInputFocus])(client); |
1970 } |
1893 } |
1971 |
1894 |
1972 int |
1895 int |
1973 ProcTsolGetInputFocus(client) |
1896 ProcTsolGetInputFocus(ClientPtr client) |
1974 ClientPtr client; |
|
1975 { |
1897 { |
1976 xGetInputFocusReply rep; |
1898 xGetInputFocusReply rep; |
1977 REQUEST(xReq); |
1899 REQUEST(xReq); |
1978 FocusClassPtr focus = inputInfo.keyboard->focus; |
1900 FocusClassPtr focus = inputInfo.keyboard->focus; |
1901 int rc; |
|
1979 |
1902 |
1980 REQUEST_SIZE_MATCH(xReq); |
1903 REQUEST_SIZE_MATCH(xReq); |
1904 |
|
1905 rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, |
|
1906 DixGetFocusAccess); |
|
1907 if (rc != Success) |
|
1908 return rc; |
|
1981 |
1909 |
1982 rep.type = X_Reply; |
1910 rep.type = X_Reply; |
1983 rep.length = 0; |
1911 rep.length = 0; |
1984 rep.sequenceNumber = client->sequence; |
1912 rep.sequenceNumber = client->sequence; |
1985 if (focus->win == NoneWin) |
1913 if (focus->win == NoneWin) |
1994 WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep); |
1922 WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep); |
1995 return Success; |
1923 return Success; |
1996 } |
1924 } |
1997 |
1925 |
1998 void |
1926 void |
1999 PrintSiblings(p1) |
1927 PrintSiblings(WindowPtr p1) |
2000 WindowPtr p1; |
|
2001 { |
1928 { |
2002 WindowPtr p2; |
1929 WindowPtr p2; |
2003 |
1930 |
2004 if (p1 == NULL || p1->parent == NULL) return; |
1931 if (p1 == NULL || p1->parent == NULL) return; |
2005 |
1932 |
2006 p2 = p1->parent->firstChild; |
1933 p2 = p1->parent->firstChild; |
2007 while (p2) |
1934 while (p2) |
2008 { |
1935 { |
2009 ErrorF( "(%x, %d, %d, %x)\n", p2, p2->drawable.width, |
1936 ErrorF( "(%x, %d, %d, %x)\n", p2, p2->drawable.width, |
2010 p2->drawable.height, p2->prevSib); |
1937 p2->drawable.height, p2->prevSib); |
2011 p2 = p2->nextSib; |
1938 p2 = p2->nextSib; |
2012 } |
1939 } |
2013 } |
1940 } |
2014 |
1941 |
2016 * Checks that tpwin & its siblings have same |
1943 * Checks that tpwin & its siblings have same |
2017 * parents. Returns 0 if OK, a # indicating which |
1944 * parents. Returns 0 if OK, a # indicating which |
2018 * Sibling has a bad parent |
1945 * Sibling has a bad parent |
2019 */ |
1946 */ |
2020 int |
1947 int |
2021 CheckTPWin() |
1948 CheckTPWin(void) |
2022 { |
1949 { |
2023 WindowPtr pWin; |
1950 WindowPtr pWin; |
2024 int count = 1; |
1951 int count = 1; |
2025 |
1952 |
2026 pWin = tpwin->nextSib; |
1953 pWin = tpwin->nextSib; |
2035 } |
1962 } |
2036 |
1963 |
2037 /* NEW */ |
1964 /* NEW */ |
2038 |
1965 |
2039 int |
1966 int |
2040 ProcTsolGetGeometry(client) |
1967 ProcTsolGetGeometry(ClientPtr client) |
2041 register ClientPtr client; |
|
2042 { |
1968 { |
2043 xGetGeometryReply rep; |
1969 xGetGeometryReply rep; |
2044 int status; |
1970 int status; |
2045 |
1971 |
2046 REQUEST(xResourceReq); |
1972 REQUEST(xResourceReq); |
2058 } |
1984 } |
2059 |
1985 |
2060 WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); |
1986 WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); |
2061 return(client->noClientException); |
1987 return(client->noClientException); |
2062 |
1988 |
2063 } else |
1989 } else |
2064 { |
1990 { |
2065 status = (*TsolSavedProcVector[X_GetGeometry])(client); |
1991 status = (*TsolSavedProcVector[X_GetGeometry])(client); |
2066 return (status); |
1992 return (status); |
2067 } |
1993 } |
2068 } |
1994 } |
2069 |
1995 |
2070 int |
1996 int |
2071 ProcTsolGrabServer(client) |
1997 ProcTsolGrabServer(ClientPtr client) |
2072 register ClientPtr client; |
|
2073 { |
1998 { |
2074 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
1999 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2075 |
2000 |
2076 REQUEST(xResourceReq); |
2001 REQUEST(xResourceReq); |
2077 REQUEST_SIZE_MATCH(xReq); |
2002 REQUEST_SIZE_MATCH(xReq); |
2088 |
2013 |
2089 return (*TsolSavedProcVector[X_GrabServer])(client); |
2014 return (*TsolSavedProcVector[X_GrabServer])(client); |
2090 } |
2015 } |
2091 |
2016 |
2092 int |
2017 int |
2093 ProcTsolUngrabServer(client) |
2018 ProcTsolUngrabServer(ClientPtr client) |
2094 register ClientPtr client; |
|
2095 { |
2019 { |
2096 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2020 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2097 |
2021 |
2098 REQUEST(xResourceReq); |
2022 REQUEST(xResourceReq); |
2099 REQUEST_SIZE_MATCH(xReq); |
2023 REQUEST_SIZE_MATCH(xReq); |
2110 |
2034 |
2111 return (*TsolSavedProcVector[X_UngrabServer])(client); |
2035 return (*TsolSavedProcVector[X_UngrabServer])(client); |
2112 } |
2036 } |
2113 |
2037 |
2114 int |
2038 int |
2115 ProcTsolCreatePixmap(client) |
2039 ProcTsolCreatePixmap(ClientPtr client) |
2116 register ClientPtr client; |
|
2117 { |
2040 { |
2118 PixmapPtr pMap; |
2041 PixmapPtr pMap; |
2119 int result; |
2042 int result; |
2120 |
2043 |
2121 REQUEST(xCreatePixmapReq); |
2044 REQUEST(xCreatePixmapReq); |
2123 REQUEST_SIZE_MATCH(xCreatePixmapReq); |
2046 REQUEST_SIZE_MATCH(xCreatePixmapReq); |
2124 |
2047 |
2125 result = (*TsolSavedProcVector[X_CreatePixmap])(client); |
2048 result = (*TsolSavedProcVector[X_CreatePixmap])(client); |
2126 |
2049 |
2127 pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->pid, RT_PIXMAP, |
2050 pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->pid, RT_PIXMAP, |
2128 SecurityDestroyAccess); |
2051 DixDestroyAccess); |
2129 if (pMap) |
2052 if (pMap) |
2130 { |
2053 { |
2131 /* Initialize security info */ |
2054 /* Initialize security info */ |
2132 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2055 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2133 TsolResPtr tsolres = |
2056 TsolResPtr tsolres = TsolPixmapPriv(pMap); |
2134 (TsolResPtr)(pMap->devPrivates[tsolPixmapPrivateIndex].ptr); |
|
2135 |
2057 |
2136 if (tsolinfo == NULL || client == serverClient) |
2058 if (tsolinfo == NULL || client == serverClient) |
2137 { |
2059 { |
2138 /* Client is Server itself */ |
2060 /* Client is Server itself */ |
2139 tsolres->uid = 0; |
2061 tsolres->uid = 0; |
2147 tsolres->flags = 0; |
2069 tsolres->flags = 0; |
2148 } |
2070 } |
2149 |
2071 |
2150 return result; |
2072 return result; |
2151 } |
2073 } |
2152 int |
2074 |
2153 ProcTsolSetScreenSaver(client) |
2075 int |
2154 register ClientPtr client; |
2076 ProcTsolSetScreenSaver(ClientPtr client) |
2155 { |
2077 { |
2156 int result; |
2078 int result; |
2157 |
2079 |
2158 REQUEST(xSetScreenSaverReq); |
2080 REQUEST(xSetScreenSaverReq); |
2159 |
|
2160 REQUEST_SIZE_MATCH(xSetScreenSaverReq); |
2081 REQUEST_SIZE_MATCH(xSetScreenSaverReq); |
2161 |
2082 |
2162 if (result = xtsol_policy(TSOL_RES_SCRSAVER, TSOL_MODIFY, NULL, |
2083 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_SCRSAVER, TSOL_MODIFY, |
2163 client, TSOL_ALL, (void *)MAJOROP)) |
2084 NULL, REPORT_ERRORS, KEEP_TRUSTLEVEL); |
2164 return (result); |
2085 } |
2165 |
2086 |
2166 return (*TsolSavedProcVector[X_SetScreenSaver])(client); |
2087 int |
2167 } |
2088 ProcTsolChangeHosts(ClientPtr client) |
2168 |
2089 { |
2169 int |
2090 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_ACL, TSOL_MODIFY, |
2170 ProcTsolChangeHosts(client) |
2091 NULL, REPORT_ERRORS, RAISE_TRUSTLEVEL); |
2171 register ClientPtr client; |
2092 } |
2172 { |
2093 |
2173 int result; |
2094 int |
2174 int savedtrust = client->trustLevel; |
2095 ProcTsolChangeAccessControl(ClientPtr client) |
2175 |
2096 { |
2176 REQUEST(xChangeHostsReq); |
|
2177 |
|
2178 REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength); |
|
2179 |
|
2180 if (result = xtsol_policy(TSOL_RES_ACL, TSOL_MODIFY, NULL, |
|
2181 client, TSOL_ALL, (void *)MAJOROP)) |
|
2182 return (result); |
|
2183 |
|
2184 client->trustLevel = XSecurityClientTrusted; |
|
2185 result = (*TsolSavedProcVector[X_ChangeHosts])(client); |
|
2186 client->trustLevel = savedtrust; |
|
2187 |
|
2188 return (result); |
|
2189 } |
|
2190 |
|
2191 int |
|
2192 ProcTsolChangeAccessControl(client) |
|
2193 register ClientPtr client; |
|
2194 { |
|
2195 int result; |
|
2196 int savedtrust = client->trustLevel; |
|
2197 |
|
2198 REQUEST(xSetAccessControlReq); |
2097 REQUEST(xSetAccessControlReq); |
2199 |
|
2200 REQUEST_SIZE_MATCH(xSetAccessControlReq); |
2098 REQUEST_SIZE_MATCH(xSetAccessControlReq); |
2201 |
2099 |
2202 if (result = xtsol_policy(TSOL_RES_ACL, TSOL_MODIFY, |
2100 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_ACL, TSOL_MODIFY, |
2203 (void *)stuff->mode, client, TSOL_ALL, (void *)MAJOROP)) |
2101 stuff->mode, REPORT_ERRORS, RAISE_TRUSTLEVEL); |
2204 { |
2102 } |
2205 client->errorValue = stuff->mode; |
2103 |
2206 return (result); |
2104 int |
2207 } |
2105 ProcTsolKillClient(ClientPtr client) |
2208 |
2106 { |
2209 client->trustLevel = XSecurityClientTrusted; |
|
2210 result = (*TsolSavedProcVector[X_SetAccessControl])(client); |
|
2211 client->trustLevel = savedtrust; |
|
2212 |
|
2213 return (result); |
|
2214 } |
|
2215 |
|
2216 int |
|
2217 ProcTsolKillClient(client) |
|
2218 register ClientPtr client; |
|
2219 { |
|
2220 int result; |
|
2221 |
|
2222 REQUEST(xResourceReq); |
2107 REQUEST(xResourceReq); |
2223 |
|
2224 REQUEST_SIZE_MATCH(xResourceReq); |
2108 REQUEST_SIZE_MATCH(xResourceReq); |
2225 |
2109 |
2226 if (result = xtsol_policy(TSOL_RES_CLIENT, TSOL_DESTROY, |
2110 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_CLIENT, TSOL_DESTROY, |
2227 (void *)stuff->id, client, TSOL_ALL, (void *)MAJOROP)) |
2111 stuff->id, REPORT_ERRORS, KEEP_TRUSTLEVEL); |
2228 { |
2112 } |
2229 client->errorValue = stuff->id; |
2113 |
2230 return (result); |
2114 int |
2231 } |
2115 ProcTsolSetFontPath(ClientPtr client) |
2232 |
|
2233 return (*TsolSavedProcVector[X_KillClient])(client); |
|
2234 } |
|
2235 |
|
2236 int |
|
2237 ProcTsolSetFontPath(client) |
|
2238 register ClientPtr client; |
|
2239 { |
2116 { |
2240 REQUEST(xSetFontPathReq); |
2117 REQUEST(xSetFontPathReq); |
2241 |
2118 |
2242 REQUEST_AT_LEAST_SIZE(xSetFontPathReq); |
2119 REQUEST_AT_LEAST_SIZE(xSetFontPathReq); |
2243 |
2120 |
2244 if (xtsol_policy(TSOL_RES_FONTPATH, TSOL_MODIFY, NULL, |
2121 if (xtsol_policy(TSOL_RES_FONTPATH, TSOL_MODIFY, NULL, |
2245 client, TSOL_ALL, (void *)MAJOROP)) |
2122 client, TSOL_ALL, (void *)MAJOROP)) |
2246 { |
2123 { |
2247 return (BadValue); |
2124 return (BadValue); |
2248 } |
2125 } |
2249 |
2126 |
2250 return (*TsolSavedProcVector[X_SetFontPath])(client); |
2127 return (*TsolSavedProcVector[X_SetFontPath])(client); |
2251 } |
2128 } |
2252 |
2129 |
2253 int |
2130 int |
2254 ProcTsolChangeCloseDownMode(client) |
2131 ProcTsolChangeCloseDownMode(ClientPtr client) |
2255 register ClientPtr client; |
|
2256 { |
2132 { |
2257 REQUEST(xSetCloseDownModeReq); |
2133 REQUEST(xSetCloseDownModeReq); |
2258 |
|
2259 REQUEST_SIZE_MATCH(xSetCloseDownModeReq); |
2134 REQUEST_SIZE_MATCH(xSetCloseDownModeReq); |
2260 |
2135 |
2261 if (xtsol_policy(TSOL_RES_CLIENT, TSOL_MODIFY, NULL, |
2136 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_CLIENT, TSOL_MODIFY, |
2262 client, TSOL_ALL, (void *)MAJOROP)) |
2137 NULL, IGNORE_ERRORS, KEEP_TRUSTLEVEL); |
2263 return (client->noClientException); /* Ignore error */ |
2138 } |
2264 |
2139 |
2265 return (*TsolSavedProcVector[X_SetCloseDownMode])(client); |
2140 int |
2266 } |
2141 ProcTsolForceScreenSaver(ClientPtr client) |
2267 |
2142 { |
2268 int ProcTsolForceScreenSaver(client) |
|
2269 register ClientPtr client; |
|
2270 { |
|
2271 int result; |
|
2272 |
|
2273 REQUEST(xForceScreenSaverReq); |
2143 REQUEST(xForceScreenSaverReq); |
2274 |
|
2275 REQUEST_SIZE_MATCH(xForceScreenSaverReq); |
2144 REQUEST_SIZE_MATCH(xForceScreenSaverReq); |
2276 |
2145 |
2277 |
2146 return ProcTsolUnwrapResourceAccess(client, TSOL_RES_SCRSAVER, TSOL_MODIFY, |
2278 if (result = xtsol_policy(TSOL_RES_SCRSAVER, TSOL_MODIFY, NULL, |
2147 NULL, REPORT_ERRORS, KEEP_TRUSTLEVEL); |
2279 client, TSOL_ALL, (void *)MAJOROP)) |
|
2280 return (result); |
|
2281 |
|
2282 return (*TsolSavedProcVector[X_ForceScreenSaver])(client); |
|
2283 } |
2148 } |
2284 |
2149 |
2285 void |
2150 void |
2286 TsolDeleteWindowFromAnySelections(pWin) |
2151 TsolDeleteWindowFromAnySelections(WindowPtr pWin) |
2287 WindowPtr pWin; |
2152 { |
2288 { |
2153 Selection *pSel; |
2289 register int i; |
|
2290 TsolSelnPtr tsolseln = NULL; |
2154 TsolSelnPtr tsolseln = NULL; |
2291 TsolSelnPtr prevtsolseln = NULL; |
2155 TsolSelnPtr prevtsolseln = NULL; |
2292 |
2156 |
2293 for (i = 0; i< NumCurrentSelections; i++) |
2157 for (pSel = CurrentSelections; pSel; pSel = pSel->next) |
2294 { |
2158 { |
2295 if (PolySelection(CurrentSelections[i].selection)) |
2159 if (PolySelection(pSel->selection)) |
2296 { |
2160 { |
2297 tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate; |
2161 tsolseln = *(TsolSelectionPriv(pSel)); |
2298 prevtsolseln = tsolseln; |
2162 prevtsolseln = tsolseln; |
2299 while (tsolseln) |
2163 while (tsolseln) |
2300 { |
2164 { |
2301 if (tsolseln->pWin == pWin) |
2165 if (tsolseln->pWin == pWin) |
2302 break; /* match found */ |
2166 break; /* match found */ |
2308 { |
2172 { |
2309 if (SelectionCallback) |
2173 if (SelectionCallback) |
2310 { |
2174 { |
2311 SelectionInfoRec info; |
2175 SelectionInfoRec info; |
2312 |
2176 |
2313 info.selection = &CurrentSelections[i]; |
2177 info.selection = pSel; |
2314 info.kind = SelectionClientClose; |
2178 info.kind = SelectionClientClose; |
2315 CallCallbacks(&SelectionCallback, &info); |
2179 CallCallbacks(&SelectionCallback, &info); |
2316 } |
2180 } |
2317 |
2181 |
2318 /* first on the list */ |
2182 /* first on the list */ |
2319 if (prevtsolseln == tsolseln) |
2183 if (prevtsolseln == tsolseln) |
2320 CurrentSelections[i].secPrivate = (pointer)tsolseln->next; |
2184 *(TsolSelectionPriv(pSel)) |
2185 = tsolseln->next; |
|
2321 else |
2186 else |
2322 prevtsolseln->next = tsolseln->next; |
2187 prevtsolseln->next = tsolseln->next; |
2323 xfree(tsolseln); |
2188 xfree(tsolseln); |
2324 |
2189 |
2325 /* handle the last reference */ |
2190 /* handle the last reference */ |
2326 if (CurrentSelections[i].secPrivate == NULL) |
2191 if (*(TsolSelectionPriv(pSel)) == NULL) |
2327 { |
2192 { |
2328 CurrentSelections[i].pWin = (WindowPtr)NULL; |
2193 pSel->pWin = (WindowPtr)NULL; |
2329 CurrentSelections[i].window = None; |
2194 pSel->window = None; |
2330 CurrentSelections[i].client = NullClient; |
2195 pSel->client = NullClient; |
2331 } |
2196 } |
2332 } |
2197 } |
2333 } |
2198 } |
2334 else |
2199 else |
2335 { |
2200 { |
2336 if (CurrentSelections[i].pWin == pWin) |
2201 if (pSel->pWin == pWin) |
2337 { |
2202 { |
2338 CurrentSelections[i].pWin = (WindowPtr)NULL; |
2203 SelectionInfoRec info = { pSel, NULL, SelectionWindowDestroy }; |
2339 CurrentSelections[i].window = None; |
2204 CallCallbacks(&SelectionCallback, &info); |
2340 CurrentSelections[i].client = NullClient; |
2205 |
2206 pSel->pWin = (WindowPtr)NULL; |
|
2207 pSel->window = None; |
|
2208 pSel->client = NullClient; |
|
2341 } |
2209 } |
2342 } |
2210 } |
2343 } |
2211 } |
2344 } |
2212 } |
2345 |
2213 |
2346 void |
2214 void |
2347 TsolDeleteClientFromAnySelections(client) |
2215 TsolDeleteClientFromAnySelections(ClientPtr client) |
2348 ClientPtr client; |
2216 { |
2349 { |
2217 Selection *pSel; |
2350 register int i; |
|
2351 TsolSelnPtr tsolseln = NULL; |
2218 TsolSelnPtr tsolseln = NULL; |
2352 TsolSelnPtr prevtsolseln = NULL; |
2219 TsolSelnPtr prevtsolseln = NULL; |
2353 |
2220 |
2354 for (i = 0; i< NumCurrentSelections; i++) |
2221 for (pSel = CurrentSelections; pSel; pSel = pSel->next) |
2355 { |
2222 { |
2356 if (PolySelection(CurrentSelections[i].selection)) |
2223 if (PolySelection(pSel->selection)) |
2357 { |
2224 { |
2358 tsolseln = (TsolSelnPtr)CurrentSelections[i].secPrivate; |
2225 tsolseln = *(TsolSelectionPriv(pSel)); |
2359 prevtsolseln = tsolseln; |
2226 prevtsolseln = tsolseln; |
2360 while (tsolseln) |
2227 while (tsolseln) |
2361 { |
2228 { |
2362 if (tsolseln->client == client) |
2229 if (tsolseln->client == client) |
2363 break; /* match found */ |
2230 break; /* match found */ |
2369 { |
2236 { |
2370 if (SelectionCallback) |
2237 if (SelectionCallback) |
2371 { |
2238 { |
2372 SelectionInfoRec info; |
2239 SelectionInfoRec info; |
2373 |
2240 |
2374 info.selection = &CurrentSelections[i]; |
2241 info.selection = pSel; |
2375 info.kind = SelectionClientClose; |
2242 info.kind = SelectionClientClose; |
2376 CallCallbacks(&SelectionCallback, &info); |
2243 CallCallbacks(&SelectionCallback, &info); |
2377 } |
2244 } |
2378 |
2245 |
2379 /* first on the list */ |
2246 /* first on the list */ |
2380 if (prevtsolseln == tsolseln) |
2247 if (prevtsolseln == tsolseln) |
2381 CurrentSelections[i].secPrivate = (pointer)tsolseln->next; |
2248 *(TsolSelectionPriv(pSel)) |
2249 = tsolseln->next; |
|
2382 else |
2250 else |
2383 prevtsolseln->next = tsolseln->next; |
2251 prevtsolseln->next = tsolseln->next; |
2384 xfree(tsolseln); |
2252 xfree(tsolseln); |
2385 |
2253 |
2386 /* handle the last reference */ |
2254 /* handle the last reference */ |
2387 if (CurrentSelections[i].secPrivate == NULL) |
2255 if (*(TsolSelectionPriv(pSel)) == NULL) |
2388 { |
2256 { |
2389 CurrentSelections[i].pWin = (WindowPtr)NULL; |
2257 pSel->pWin = (WindowPtr)NULL; |
2390 CurrentSelections[i].window = None; |
2258 pSel->window = None; |
2391 CurrentSelections[i].client = NullClient; |
2259 pSel->client = NullClient; |
2392 } |
2260 } |
2393 } |
2261 } |
2394 } |
2262 } |
2395 else |
2263 else |
2396 { |
2264 { |
2397 if (CurrentSelections[i].client == client) |
2265 if (pSel->client == client) |
2398 { |
2266 { |
2399 CurrentSelections[i].pWin = (WindowPtr)NULL; |
2267 SelectionInfoRec info = { pSel, NULL, SelectionClientClose }; |
2400 CurrentSelections[i].window = None; |
2268 CallCallbacks(&SelectionCallback, &info); |
2401 CurrentSelections[i].client = NullClient; |
2269 |
2270 pSel->pWin = (WindowPtr)NULL; |
|
2271 pSel->window = None; |
|
2272 pSel->client = NullClient; |
|
2402 } |
2273 } |
2403 } |
2274 } |
2404 } |
2275 } |
2405 } |
2276 } |
2406 |
2277 |
2407 int |
2278 int |
2408 ProcTsolListInstalledColormaps(client) |
2279 ProcTsolListInstalledColormaps(ClientPtr client) |
2409 register ClientPtr client; |
2280 { |
2410 { |
2281 xListInstalledColormapsReply *preply; |
2411 xListInstalledColormapsReply *preply; |
2282 int nummaps, rc; |
2412 int nummaps; |
|
2413 WindowPtr pWin; |
2283 WindowPtr pWin; |
2414 REQUEST(xResourceReq); |
2284 REQUEST(xResourceReq); |
2415 |
|
2416 REQUEST_SIZE_MATCH(xResourceReq); |
2285 REQUEST_SIZE_MATCH(xResourceReq); |
2417 pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, |
2286 |
2418 SecurityReadAccess); |
2287 rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess); |
2419 |
2288 if (rc != Success) |
2420 if (!pWin) |
2289 return rc; |
2421 return(BadWindow); |
2290 |
2422 |
2291 rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, |
2423 preply = (xListInstalledColormapsReply *) |
2292 DixGetAttrAccess); |
2424 ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) + |
2293 if (rc != Success) |
2294 return rc; |
|
2295 |
|
2296 preply = (xListInstalledColormapsReply *) |
|
2297 xalloc(sizeof(xListInstalledColormapsReply) + |
|
2425 pWin->drawable.pScreen->maxInstalledCmaps * |
2298 pWin->drawable.pScreen->maxInstalledCmaps * |
2426 sizeof(Colormap)); |
2299 sizeof(Colormap)); |
2427 if(!preply) |
2300 if(!preply) |
2428 return(BadAlloc); |
2301 return(BadAlloc); |
2429 |
2302 |
2438 int err_code, i; |
2311 int err_code, i; |
2439 Colormap *pcmap = (Colormap *)&preply[1]; |
2312 Colormap *pcmap = (Colormap *)&preply[1]; |
2440 ColormapPtr pcmp; |
2313 ColormapPtr pcmp; |
2441 |
2314 |
2442 /* |
2315 /* |
2443 * check every colormap id for access. return default colormap |
2316 * check every colormap id for access. return default colormap |
2444 * id in case of failure |
2317 * id in case of failure |
2445 */ |
2318 */ |
2446 for (i = 0; i < nummaps; i++, pcmap++) |
2319 for (i = 0; i < nummaps; i++, pcmap++) |
2447 { |
2320 { |
2448 pcmp = (ColormapPtr )LookupIDByType(*pcmap, RT_COLORMAP); |
2321 pcmp = (ColormapPtr )LookupIDByType(*pcmap, RT_COLORMAP); |
2455 } |
2328 } |
2456 #endif /* TSOL */ |
2329 #endif /* TSOL */ |
2457 WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply); |
2330 WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply); |
2458 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; |
2331 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; |
2459 WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]); |
2332 WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]); |
2460 DEALLOCATE_LOCAL(preply); |
2333 xfree(preply); |
2461 return(client->noClientException); |
2334 return(client->noClientException); |
2462 } |
2335 } |
2463 |
2336 |
2464 |
2337 |
2465 int |
2338 int |
2466 ProcTsolQueryTree(client) |
2339 ProcTsolQueryTree(ClientPtr client) |
2467 register ClientPtr client; |
|
2468 { |
2340 { |
2469 xQueryTreeReply reply; |
2341 xQueryTreeReply reply; |
2470 int numChildren = 0; |
2342 int rc, numChildren = 0; |
2471 register WindowPtr pChild, pWin, pHead; |
2343 WindowPtr pChild, pWin, pHead; |
2472 Window *childIDs = (Window *)NULL; |
2344 Window *childIDs = (Window *)NULL; |
2473 #if defined(PANORAMIX) && !defined(IN_MODULE) |
|
2474 PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; |
|
2475 int j, thisScreen; |
|
2476 #endif |
|
2477 |
2345 |
2478 #ifdef TSOL |
2346 #ifdef TSOL |
2479 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2347 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2480 #endif /* TSOL */ |
2348 #endif /* TSOL */ |
2481 |
2349 |
2482 REQUEST(xResourceReq); |
2350 REQUEST(xResourceReq); |
2483 |
2351 |
2484 REQUEST_SIZE_MATCH(xResourceReq); |
2352 REQUEST_SIZE_MATCH(xResourceReq); |
2485 pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, |
2353 rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess); |
2486 SecurityReadAccess); |
2354 if (rc != Success) |
2487 if (!pWin) |
2355 return rc; |
2488 return(BadWindow); |
|
2489 |
2356 |
2490 #ifdef TSOL |
2357 #ifdef TSOL |
2491 if (xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pWin, |
2358 if (xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pWin, |
2492 client, TSOL_ALL, (void *)MAJOROP)) |
2359 client, TSOL_ALL, (void *)MAJOROP)) |
2493 { |
2360 { |
2508 reply.sequenceNumber = client->sequence; |
2375 reply.sequenceNumber = client->sequence; |
2509 if (pWin->parent) |
2376 if (pWin->parent) |
2510 reply.parent = pWin->parent->drawable.id; |
2377 reply.parent = pWin->parent->drawable.id; |
2511 else |
2378 else |
2512 reply.parent = (Window)None; |
2379 reply.parent = (Window)None; |
2513 #if defined(SUNSOFT) && defined(PANORAMIX) && !defined(IN_MODULE) |
|
2514 if ( !noPanoramiXExtension ) { |
|
2515 thisScreen = 0; |
|
2516 for (j = 0; j <= PanoramiXNumScreens - 1; j++) { |
|
2517 if ( pWin->winSize.extents.x1 < (panoramiXdataPtr[j].x + |
|
2518 panoramiXdataPtr[j].width)) { |
|
2519 thisScreen = j; |
|
2520 break; |
|
2521 } |
|
2522 } |
|
2523 } |
|
2524 if ( !noPanoramiXExtension && thisScreen ) { |
|
2525 PANORAMIXFIND_ID(pPanoramiXWin, pWin->drawable.id); |
|
2526 IF_RETURN(!pPanoramiXWin, BadWindow); |
|
2527 pWin = |
|
2528 (WindowPtr)SecurityLookupWindow(pPanoramiXWin->info[thisScreen].id, |
|
2529 client, |
|
2530 SecurityReadAccess); |
|
2531 if (!pWin) |
|
2532 return(BadWindow); |
|
2533 pHead = RealChildHead(pWin); |
|
2534 for(pChild = pWin->lastChild;pChild != pHead; pChild = pChild->prevSib) |
|
2535 numChildren++; |
|
2536 if (numChildren) |
|
2537 { |
|
2538 int curChild = 0; |
|
2539 childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window)); |
|
2540 if (!childIDs) |
|
2541 return BadAlloc; |
|
2542 for (pChild = pWin->lastChild; pChild != pHead; |
|
2543 pChild = pChild->prevSib) { |
|
2544 pPanoramiXWin = PanoramiXWinRoot; |
|
2545 PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, pChild->drawable.id, |
|
2546 thisScreen); |
|
2547 IF_RETURN(!pPanoramiXWin, BadWindow); |
|
2548 childIDs[curChild++] = pPanoramiXWin->info[0].id; |
|
2549 } |
|
2550 } /* numChildren */ |
|
2551 }else { /* otherwise its screen 0, and nothing changes */ |
|
2552 pHead = RealChildHead(pWin); |
|
2553 for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) |
|
2554 #ifdef TSOL |
|
2555 { |
|
2556 /* error ignored */ |
|
2557 if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild, |
|
2558 client, TSOL_ALL, (void *)MAJOROP)) |
|
2559 { |
|
2560 numChildren++; |
|
2561 } |
|
2562 } |
|
2563 #else /* !TSOL */ |
|
2564 numChildren++; |
|
2565 #endif /* TSOL */ |
|
2566 if (numChildren) |
|
2567 { |
|
2568 int curChild = 0; |
|
2569 |
|
2570 childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window)); |
|
2571 if (!childIDs) |
|
2572 return BadAlloc; |
|
2573 for (pChild = pWin->lastChild; pChild != pHead; |
|
2574 pChild = pChild->prevSib) |
|
2575 #ifdef TSOL |
|
2576 { |
|
2577 |
|
2578 /* error ignored */ |
|
2579 if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild, |
|
2580 client, TSOL_ALL, (void *)MAJOROP)) |
|
2581 { |
|
2582 childIDs[curChild++] = pChild->drawable.id; |
|
2583 } |
|
2584 } |
|
2585 #else /* !TSOL */ |
|
2586 childIDs[curChild++] = pChild->drawable.id; |
|
2587 #endif /* TSOL */ |
|
2588 } |
|
2589 } |
|
2590 #else |
|
2591 pHead = RealChildHead(pWin); |
2380 pHead = RealChildHead(pWin); |
2592 for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) |
2381 for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) |
2593 #ifdef TSOL |
2382 #ifdef TSOL |
2594 { |
2383 { |
2595 /* error ignored */ |
2384 /* error ignored */ |
2596 if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild, |
2385 if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild, |
2597 client, TSOL_ALL, (void *)MAJOROP)) |
2386 client, TSOL_ALL, (void *)MAJOROP)) |
2598 { |
2387 { |
2599 numChildren++; |
2388 numChildren++; |
2600 } |
2389 } |
2601 } |
2390 } |
2602 #else /* !TSOL */ |
2391 #else /* !TSOL */ |
2604 #endif /* TSOL */ |
2393 #endif /* TSOL */ |
2605 if (numChildren) |
2394 if (numChildren) |
2606 { |
2395 { |
2607 int curChild = 0; |
2396 int curChild = 0; |
2608 |
2397 |
2609 childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window)); |
2398 childIDs = (Window *) xalloc(numChildren * sizeof(Window)); |
2610 if (!childIDs) |
2399 if (!childIDs) |
2611 return BadAlloc; |
2400 return BadAlloc; |
2612 for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) |
2401 for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) |
2613 #ifdef TSOL |
2402 #ifdef TSOL |
2614 { |
2403 { |
2615 |
2404 |
2616 /* error ignored */ |
2405 /* error ignored */ |
2617 if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild, |
2406 if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, pChild, |
2618 client, TSOL_ALL, (void *)MAJOROP)) |
2407 client, TSOL_ALL, (void *)MAJOROP)) |
2619 { |
2408 { |
2620 childIDs[curChild++] = pChild->drawable.id; |
2409 childIDs[curChild++] = pChild->drawable.id; |
2621 } |
2410 } |
2622 } |
2411 } |
2623 #else /* !TSOL */ |
2412 #else /* !TSOL */ |
2624 childIDs[curChild++] = pChild->drawable.id; |
2413 childIDs[curChild++] = pChild->drawable.id; |
2625 #endif /* TSOL */ |
2414 #endif /* TSOL */ |
2626 } |
2415 } |
2627 #endif |
2416 |
2628 |
|
2629 reply.nChildren = numChildren; |
2417 reply.nChildren = numChildren; |
2630 reply.length = (numChildren * sizeof(Window)) >> 2; |
2418 reply.length = (numChildren * sizeof(Window)) >> 2; |
2631 |
2419 |
2632 WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); |
2420 WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); |
2633 if (numChildren) |
2421 if (numChildren) |
2634 { |
2422 { |
2635 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; |
2423 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; |
2636 WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); |
2424 WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); |
2637 DEALLOCATE_LOCAL(childIDs); |
2425 xfree(childIDs); |
2638 } |
2426 } |
2639 |
2427 |
2640 return(client->noClientException); |
2428 return(client->noClientException); |
2641 } |
2429 } |
2642 |
2430 |
2643 void |
2431 CALLBACK( |
2644 TsolAuditStart(ClientPtr client) |
2432 TsolAuditStart) |
2645 { |
2433 { |
2434 XaceAuditRec *rec = (XaceAuditRec *) calldata; |
|
2435 ClientPtr client = rec->client; |
|
2436 |
|
2646 extern Bool system_audit_on; |
2437 extern Bool system_audit_on; |
2647 unsigned int protocol; |
2438 unsigned int protocol; |
2648 int xevent_num; |
2439 int xevent_num; |
2649 int count = 0; |
2440 int count = 0; |
2650 int status = 0; |
2441 int status = 0; |
2651 Bool do_x_audit = FALSE; |
2442 Bool do_x_audit = FALSE; |
2652 Bool audit_event = FALSE; |
2443 Bool audit_event = FALSE; |
2653 char audit_ret = (char)NULL; |
|
2654 TsolInfoPtr tsolinfo = (TsolInfoPtr)NULL; |
2444 TsolInfoPtr tsolinfo = (TsolInfoPtr)NULL; |
2655 tsolinfo = GetClientTsolInfo(client); |
2445 tsolinfo = GetClientTsolInfo(client); |
2656 if (system_audit_on && |
2446 if (system_audit_on && |
2657 (tsolinfo->amask.am_success || tsolinfo->amask.am_failure)) { |
2447 (tsolinfo->amask.am_success || tsolinfo->amask.am_failure)) { |
2658 |
2448 |
2659 do_x_audit = TRUE; |
2449 do_x_audit = TRUE; |
2660 auditwrite(AW_PRESELECT, &(tsolinfo->amask), AW_END); |
2450 auditwrite(AW_PRESELECT, &(tsolinfo->amask), AW_END); |
2661 |
2451 |
2662 /* |
2452 /* |
2663 * X audit events start from 9101 in audit_uevents.h. The first two |
2453 * X audit events start from 9101 in audit_uevents.h. The first two |
2664 * events are non-protocol ones viz. ClientConnect, mapped to 9101 |
2454 * events are non-protocol ones viz. ClientConnect, mapped to 9101 |
2665 * and ClientDisconnect, mapped to 9102. |
2455 * and ClientDisconnect, mapped to 9102. |
2666 * The protocol events are mapped from 9103 onwards in the serial |
2456 * The protocol events are mapped from 9103 onwards in the serial |
2700 tsolinfo->flags &= ~TSOL_DOXAUDIT; |
2490 tsolinfo->flags &= ~TSOL_DOXAUDIT; |
2701 } |
2491 } |
2702 } |
2492 } |
2703 } |
2493 } |
2704 |
2494 |
2705 void |
2495 CALLBACK( |
2706 TsolAuditEnd(ClientPtr client, int result) |
2496 TsolAuditEnd) |
2707 { |
2497 { |
2708 extern Bool system_audit_on; |
2498 XaceAuditRec *rec = (XaceAuditRec *) calldata; |
2709 unsigned int protocol; |
2499 ClientPtr client = rec->client; |
2710 int xevent_num; |
2500 int result = rec->requestResult; |
2711 int count = 0; |
2501 |
2712 int status = 0; |
|
2713 Bool do_x_audit = FALSE; |
|
2714 Bool audit_event = FALSE; |
|
2715 char audit_ret = (char)NULL; |
2502 char audit_ret = (char)NULL; |
2716 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2503 TsolInfoPtr tsolinfo = GetClientTsolInfo(client); |
2717 |
2504 |
2718 if (tsolinfo->flags & TSOL_DOXAUDIT) |
2505 if (tsolinfo->flags & TSOL_DOXAUDIT) |
2719 { |
2506 { |
2733 auditwrite(AW_DISCARDRD, -1, AW_END); |
2520 auditwrite(AW_DISCARDRD, -1, AW_END); |
2734 } |
2521 } |
2735 } |
2522 } |
2736 |
2523 |
2737 int |
2524 int |
2738 ProcTsolQueryPointer(client) |
2525 ProcTsolQueryPointer(ClientPtr client) |
2739 ClientPtr client; |
|
2740 { |
2526 { |
2741 xQueryPointerReply rep; |
2527 xQueryPointerReply rep; |
2742 WindowPtr pWin, t, ptrWin; |
2528 WindowPtr pWin, ptrWin; |
2529 DeviceIntPtr mouse = inputInfo.pointer; |
|
2530 int rc; |
|
2743 REQUEST(xResourceReq); |
2531 REQUEST(xResourceReq); |
2744 DeviceIntPtr mouse = inputInfo.pointer; |
|
2745 |
|
2746 REQUEST_SIZE_MATCH(xResourceReq); |
2532 REQUEST_SIZE_MATCH(xResourceReq); |
2747 pWin = SecurityLookupWindow(stuff->id, client, SecurityReadAccess); |
2533 |
2748 if (!pWin) |
2534 rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess); |
2749 return BadWindow; |
2535 if (rc != Success) |
2536 return rc; |
|
2537 rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess); |
|
2538 if (rc != Success) |
|
2539 return rc; |
|
2750 |
2540 |
2751 ptrWin = TsolPointerWindow(); |
2541 ptrWin = TsolPointerWindow(); |
2752 if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, ptrWin, |
2542 if (!xtsol_policy(TSOL_RES_WINDOW, TSOL_READ, ptrWin, |
2753 client, TSOL_ALL, (void *)MAJOROP)) |
2543 client, TSOL_ALL, (void *)MAJOROP)) |
2754 return (*TsolSavedProcVector[X_QueryPointer])(client); |
2544 return (*TsolSavedProcVector[X_QueryPointer])(client); |
2767 rep.winX = 0; |
2557 rep.winX = 0; |
2768 rep.winY = 0; |
2558 rep.winY = 0; |
2769 |
2559 |
2770 WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep); |
2560 WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep); |
2771 |
2561 |
2772 return(Success); |
2562 return(Success); |
2773 } |
2563 } |
2774 |
2564 |
2775 int |
2565 |
2776 ProcTsolQueryExtension(client) |
2566 int |
2777 ClientPtr client; |
2567 ProcTsolQueryExtension(ClientPtr client) |
2778 { |
2568 { |
2779 xQueryExtensionReply reply; |
|
2780 int savedtrust; |
|
2781 int status = client->noClientException; |
|
2782 |
|
2783 REQUEST(xQueryExtensionReq); |
|
2784 |
|
2785 REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes); |
|
2786 |
|
2787 reply.type = X_Reply; |
|
2788 reply.length = 0; |
|
2789 reply.major_opcode = 0; |
|
2790 reply.sequenceNumber = client->sequence; |
|
2791 |
|
2792 /* Allow extensions in the labeled zones */ |
2569 /* Allow extensions in the labeled zones */ |
2793 savedtrust = client->trustLevel; |
2570 return ProcTsolUnwrapWithTrust(client, X_QueryExtension); |
2794 client->trustLevel = XSecurityClientTrusted; |
2571 } |
2795 |
2572 |
2796 if (!TsolDisabledExtension((char *)&stuff[1], stuff->nbytes)) { |
2573 int |
2797 status = (*TsolSavedProcVector[X_QueryExtension])(client); |
2574 ProcTsolListExtensions(ClientPtr client) |
2798 } else { |
2575 { |
2799 /* Hide this extension */ |
|
2800 reply.present = xFalse; |
|
2801 WriteReplyToClient(client, sizeof(xQueryExtensionReply), &reply); |
|
2802 status = client->noClientException; |
|
2803 } |
|
2804 |
|
2805 client->trustLevel = savedtrust; |
|
2806 |
|
2807 return (status); |
|
2808 } |
|
2809 |
|
2810 int |
|
2811 ProcTsolListExtensions(client) |
|
2812 ClientPtr client; |
|
2813 { |
|
2814 int savedtrust; |
|
2815 int status; |
|
2816 |
|
2817 REQUEST(xReq); |
|
2818 REQUEST_SIZE_MATCH(xReq); |
|
2819 |
|
2820 /* Allow extensions in the labeled zones */ |
2576 /* Allow extensions in the labeled zones */ |
2821 savedtrust = client->trustLevel; |
2577 return ProcTsolUnwrapWithTrust(client, X_ListExtensions); |
2822 client->trustLevel = XSecurityClientTrusted; |
2578 } |
2823 status = (*TsolSavedProcVector[X_ListExtensions])(client); |
2579 |
2824 client->trustLevel = savedtrust; |
2580 int |
2825 |
2581 ProcTsolMapWindow(ClientPtr client) |
2826 return (status); |
2582 { |
2827 } |
2583 return ProcTsolUnwrapWithTrust(client, X_MapWindow); |
2828 |
2584 } |
2829 int |
2585 |
2830 ProcTsolMapWindow(register ClientPtr client) |
2586 int |
2831 { |
2587 ProcTsolMapSubwindows(ClientPtr client) |
2832 int savedtrust; |
2588 { |
2833 int status; |
2589 return ProcTsolUnwrapWithTrust(client, X_MapSubwindows); |
2834 |
|
2835 WindowPtr pWin; |
|
2836 REQUEST(xResourceReq); |
|
2837 |
|
2838 REQUEST_SIZE_MATCH(xResourceReq); |
|
2839 pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, |
|
2840 SecurityReadAccess); |
|
2841 if (!pWin) |
|
2842 return(BadWindow); |
|
2843 savedtrust = client->trustLevel; |
|
2844 client->trustLevel = XSecurityClientTrusted; |
|
2845 status = (*TsolSavedProcVector[X_MapWindow])(client); |
|
2846 client->trustLevel = savedtrust; |
|
2847 |
|
2848 return(status); |
|
2849 } |
|
2850 |
|
2851 int |
|
2852 ProcTsolMapSubwindows(register ClientPtr client) |
|
2853 { |
|
2854 int savedtrust; |
|
2855 int status; |
|
2856 |
|
2857 WindowPtr pWin; |
|
2858 REQUEST(xResourceReq); |
|
2859 |
|
2860 REQUEST_SIZE_MATCH(xResourceReq); |
|
2861 pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, |
|
2862 SecurityReadAccess); |
|
2863 if (!pWin) |
|
2864 return(BadWindow); |
|
2865 savedtrust = client->trustLevel; |
|
2866 client->trustLevel = XSecurityClientTrusted; |
|
2867 status = (*TsolSavedProcVector[X_MapSubwindows])(client); |
|
2868 client->trustLevel = savedtrust; |
|
2869 |
|
2870 return(status); |
|
2871 } |
2590 } |
2872 |
2591 |
2873 static int |
2592 static int |
2874 TsolDoGetImage(client, format, drawable, x, y, width, height, planemask, im_return) |
2593 TsolDoGetImage( |
2875 register ClientPtr client; |
2594 register ClientPtr client, |
2876 Drawable drawable; |
2595 Drawable drawable, |
2877 int format; |
2596 int format, |
2878 int x, y, width, height; |
2597 int x, int y, int width, int height, |
2879 Mask planemask; |
2598 Mask planemask, |
2880 xGetImageReply **im_return; |
2599 xGetImageReply **im_return) |
2881 { |
2600 { |
2882 register DrawablePtr pDraw; |
2601 DrawablePtr pDraw; |
2883 int nlines, linesPerBuf; |
2602 int nlines, linesPerBuf, rc; |
2884 register int linesDone; |
2603 register int linesDone; |
2885 long widthBytesLine, length; |
2604 long widthBytesLine, length; |
2886 Mask plane = 0; |
2605 Mask plane = 0; |
2887 char *pBuf; |
2606 char *pBuf; |
2888 xGetImageReply xgi; |
2607 xGetImageReply xgi; |
2902 if ((format != XYPixmap) && (format != ZPixmap)) |
2621 if ((format != XYPixmap) && (format != ZPixmap)) |
2903 { |
2622 { |
2904 client->errorValue = format; |
2623 client->errorValue = format; |
2905 return(BadValue); |
2624 return(BadValue); |
2906 } |
2625 } |
2907 SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess); |
2626 rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixReadAccess); |
2627 if (rc != Success) |
|
2628 return rc; |
|
2629 |
|
2908 |
2630 |
2909 #ifdef TSOL |
2631 #ifdef TSOL |
2910 if (!xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, |
2632 if (!xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, |
2911 pDraw, client, TSOL_ALL, (void *)MAJOROP) && |
2633 pDraw, client, TSOL_ALL, (void *)MAJOROP) && |
2912 (DrawableIsRoot(pDraw) || !tsolMultiLevel)) |
2634 (DrawableIsRoot(pDraw) || !tsolMultiLevel)) |
2913 { |
2635 { |
2914 return DoGetImage(client, format, drawable, x, y, |
2636 return DoGetImage(client, format, drawable, x, y, |
2915 width, height, planemask, im_return); |
2637 width, height, planemask, im_return); |
2916 } |
2638 } |
2917 |
2639 |
2918 if (pDraw->type == DRAWABLE_WINDOW) |
2640 if (pDraw->type == DRAWABLE_WINDOW) |
2919 { |
2641 { |
2967 pwinbox = WindowExtents(pWin, &winbox); |
2689 pwinbox = WindowExtents(pWin, &winbox); |
2968 box.x1 = pwinbox->x1; |
2690 box.x1 = pwinbox->x1; |
2969 box.y1 = pwinbox->y1; |
2691 box.y1 = pwinbox->y1; |
2970 box.x2 = pwinbox->x2; |
2692 box.x2 = pwinbox->x2; |
2971 box.y2 = box.y1; |
2693 box.y2 = box.y1; |
2972 tsolres_win = |
2694 tsolres_win = TsolWindowPriv(pWin); |
2973 (TsolResPtr)(pWin->devPrivates[tsolWindowPrivateIndex].ptr); |
|
2974 root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; |
2695 root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; |
2975 pRoot = (WindowPtr)LookupIDByType(root, RT_WINDOW); |
2696 pRoot = (WindowPtr)LookupIDByType(root, RT_WINDOW); |
2976 pHead = pRoot->firstChild; |
2697 pHead = pRoot->firstChild; |
2977 } |
2698 } |
2978 |
2699 |
3012 ) |
2733 ) |
3013 return(BadMatch); |
2734 return(BadMatch); |
3014 xgi.visual = None; |
2735 xgi.visual = None; |
3015 } |
2736 } |
3016 |
2737 |
3017 SET_DBE_SRCBUF(pDraw, drawable); |
|
3018 |
|
3019 xgi.type = X_Reply; |
2738 xgi.type = X_Reply; |
3020 xgi.sequenceNumber = client->sequence; |
2739 xgi.sequenceNumber = client->sequence; |
3021 xgi.depth = pDraw->depth; |
2740 xgi.depth = pDraw->depth; |
3022 if(format == ZPixmap) |
2741 if(format == ZPixmap) |
3023 { |
2742 { |
3024 widthBytesLine = PixmapBytePad(width, pDraw->depth); |
2743 widthBytesLine = PixmapBytePad(width, pDraw->depth); |
3025 length = widthBytesLine * height; |
2744 length = widthBytesLine * height; |
3026 |
2745 |
3027 } |
2746 } |
3028 else |
2747 else |
3029 { |
2748 { |
3030 widthBytesLine = BitmapBytePad(width); |
2749 widthBytesLine = BitmapBytePad(width); |
3031 plane = ((Mask)1) << (pDraw->depth - 1); |
2750 plane = ((Mask)1) << (pDraw->depth - 1); |
3032 /* only planes asked for */ |
2751 /* only planes asked for */ |
3033 length = widthBytesLine * height * |
2752 length = widthBytesLine * height * |
3074 { |
2793 { |
3075 linesPerBuf++; |
2794 linesPerBuf++; |
3076 length += widthBytesLine; |
2795 length += widthBytesLine; |
3077 } |
2796 } |
3078 } |
2797 } |
3079 if(!(pBuf = (char *) ALLOCATE_LOCAL(length))) |
2798 if(!(pBuf = (char *) xalloc(length))) |
3080 return (BadAlloc); |
2799 return (BadAlloc); |
3081 WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); |
2800 WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); |
3082 } |
2801 } |
3083 |
2802 |
3084 if (linesPerBuf == 0) |
2803 if (linesPerBuf == 0) |
3092 { |
2811 { |
3093 nlines = min(linesPerBuf, height - linesDone); |
2812 nlines = min(linesPerBuf, height - linesDone); |
3094 (*pDraw->pScreen->GetImage) (pDraw, |
2813 (*pDraw->pScreen->GetImage) (pDraw, |
3095 x, |
2814 x, |
3096 y + linesDone, |
2815 y + linesDone, |
3097 width, |
2816 width, |
3098 nlines, |
2817 nlines, |
3099 format, |
2818 format, |
3100 planemask, |
2819 planemask, |
3101 (pointer) pBuf); |
2820 (pointer) pBuf); |
3102 #ifdef TSOL |
2821 #ifdef TSOL |
3150 { |
2869 { |
3151 nlines = min(linesPerBuf, height - linesDone); |
2870 nlines = min(linesPerBuf, height - linesDone); |
3152 (*pDraw->pScreen->GetImage) (pDraw, |
2871 (*pDraw->pScreen->GetImage) (pDraw, |
3153 x, |
2872 x, |
3154 y + linesDone, |
2873 y + linesDone, |
3155 width, |
2874 width, |
3156 nlines, |
2875 nlines, |
3157 format, |
2876 format, |
3158 plane, |
2877 plane, |
3159 (pointer)pBuf); |
2878 (pointer)pBuf); |
3160 #ifdef TSOL |
2879 #ifdef TSOL |
3199 } |
2918 } |
3200 } |
2919 } |
3201 } |
2920 } |
3202 |
2921 |
3203 if (!im_return) |
2922 if (!im_return) |
3204 DEALLOCATE_LOCAL(pBuf); |
2923 xfree(pBuf); |
3205 return (client->noClientException); |
2924 return (client->noClientException); |
3206 } |
2925 } |
3207 |
2926 |
3208 int |
2927 int |
3209 ProcTsolGetImage(client) |
2928 ProcTsolGetImage(ClientPtr client) |
3210 register ClientPtr client; |
|
3211 { |
2929 { |
3212 int status; |
2930 int status; |
3213 int savedtrust = client->trustLevel; |
2931 int savedtrust = setClientTrustLevel(client, XSecurityClientTrusted); |
3214 |
|
3215 client->trustLevel = XSecurityClientTrusted; |
|
3216 |
2932 |
3217 REQUEST(xGetImageReq); |
2933 REQUEST(xGetImageReq); |
3218 |
2934 |
3219 REQUEST_SIZE_MATCH(xGetImageReq); |
2935 REQUEST_SIZE_MATCH(xGetImageReq); |
3220 |
2936 |
3221 status = TsolDoGetImage(client, stuff->format, stuff->drawable, |
2937 status = TsolDoGetImage(client, stuff->format, stuff->drawable, |
3222 stuff->x, stuff->y, |
2938 stuff->x, stuff->y, |
3223 (int)stuff->width, (int)stuff->height, |
2939 (int)stuff->width, (int)stuff->height, |
3224 stuff->planeMask, (xGetImageReply **)NULL); |
2940 stuff->planeMask, (xGetImageReply **)NULL); |
3225 |
2941 |
3226 client->trustLevel = savedtrust; |
2942 setClientTrustLevel(client, savedtrust); |
3227 return (status); |
2943 return (status); |
3228 } |
2944 } |
3229 |
2945 |
3230 int |
2946 int |
3231 ProcTsolPolySegment(client) |
2947 ProcTsolPolySegment(ClientPtr client) |
3232 register ClientPtr client; |
|
3233 { |
2948 { |
3234 int savedtrust; |
2949 int savedtrust; |
3235 int status; |
2950 int status; |
3236 GC *pGC; |
2951 GC *pGC; |
3237 DrawablePtr pDraw; |
2952 DrawablePtr pDraw; |
3238 REQUEST(xPolySegmentReq); |
2953 REQUEST(xPolySegmentReq); |
3239 |
2954 |
3240 REQUEST_AT_LEAST_SIZE(xPolySegmentReq); |
2955 REQUEST_AT_LEAST_SIZE(xPolySegmentReq); |
3241 |
2956 |
3242 savedtrust = client->trustLevel; |
2957 savedtrust = setClientTrustLevel(client, XSecurityClientTrusted); |
3243 client->trustLevel = XSecurityClientTrusted; |
2958 |
3244 |
2959 VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); |
3245 VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); |
|
3246 |
2960 |
3247 if (xtsol_policy(TSOL_RES_PIXEL, TSOL_MODIFY, pDraw, |
2961 if (xtsol_policy(TSOL_RES_PIXEL, TSOL_MODIFY, pDraw, |
3248 client, TSOL_ALL, (void *)MAJOROP)) |
2962 client, TSOL_ALL, (void *)MAJOROP)) |
3249 { |
2963 { |
3250 /* ignore the error message for DnD zap effect */ |
2964 /* ignore the error message for DnD zap effect */ |
3256 client->errorValue = stuff->gc; |
2970 client->errorValue = stuff->gc; |
3257 return (BadGC); |
2971 return (BadGC); |
3258 } |
2972 } |
3259 |
2973 |
3260 status = (*TsolSavedProcVector[X_PolySegment])(client); |
2974 status = (*TsolSavedProcVector[X_PolySegment])(client); |
3261 client->trustLevel = savedtrust; |
2975 setClientTrustLevel(client, savedtrust); |
3262 |
2976 |
3263 return (status); |
2977 return (status); |
3264 } |
2978 } |
3265 |
2979 |
3266 int |
2980 int |
3267 ProcTsolPolyRectangle (client) |
2981 ProcTsolPolyRectangle (ClientPtr client) |
3268 register ClientPtr client; |
|
3269 { |
2982 { |
3270 int savedtrust; |
2983 int savedtrust; |
3271 int status; |
2984 int status; |
3272 GC *pGC; |
2985 GC *pGC; |
3273 DrawablePtr pDraw; |
2986 DrawablePtr pDraw; |
3274 |
2987 |
3275 REQUEST(xPolyRectangleReq); |
2988 REQUEST(xPolyRectangleReq); |
3276 REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); |
2989 REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); |
3277 |
2990 |
3278 savedtrust = client->trustLevel; |
2991 savedtrust = setClientTrustLevel(client, XSecurityClientTrusted); |
3279 client->trustLevel = XSecurityClientTrusted; |
2992 |
3280 |
2993 VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); |
3281 VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); |
|
3282 |
2994 |
3283 if (xtsol_policy(TSOL_RES_PIXEL, TSOL_MODIFY, pDraw, |
2995 if (xtsol_policy(TSOL_RES_PIXEL, TSOL_MODIFY, pDraw, |
3284 client, TSOL_ALL, (void *)MAJOROP)) |
2996 client, TSOL_ALL, (void *)MAJOROP)) |
3285 { |
2997 { |
3286 /* ignore the error message */ |
2998 /* ignore the error message */ |
3292 client->errorValue = stuff->gc; |
3004 client->errorValue = stuff->gc; |
3293 return (BadGC); |
3005 return (BadGC); |
3294 } |
3006 } |
3295 |
3007 |
3296 status = (*TsolSavedProcVector[X_PolyRectangle])(client); |
3008 status = (*TsolSavedProcVector[X_PolyRectangle])(client); |
3297 client->trustLevel = savedtrust; |
3009 setClientTrustLevel(client, savedtrust); |
3298 |
3010 |
3299 return (status); |
3011 return (status); |
3300 } |
3012 } |
3301 |
3013 |
3302 int |
3014 int |
3303 ProcTsolCopyArea (client) |
3015 ProcTsolCopyArea (ClientPtr client) |
3304 register ClientPtr client; |
|
3305 { |
3016 { |
3306 int savedtrust; |
3017 int savedtrust; |
3307 int status; |
3018 int status; |
3308 register DrawablePtr pDst; |
3019 DrawablePtr pDst; |
3309 register DrawablePtr pSrc; |
3020 DrawablePtr pSrc; |
3310 register GC *pGC; |
3021 GC *pGC; |
3022 int rc; |
|
3023 |
|
3311 REQUEST(xCopyAreaReq); |
3024 REQUEST(xCopyAreaReq); |
3312 |
3025 |
3313 REQUEST_SIZE_MATCH(xCopyAreaReq); |
3026 REQUEST_SIZE_MATCH(xCopyAreaReq); |
3314 |
3027 |
3315 savedtrust = client->trustLevel; |
3028 savedtrust = setClientTrustLevel(client, XSecurityClientTrusted); |
3316 client->trustLevel = XSecurityClientTrusted; |
3029 |
3317 |
3030 VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess); |
3318 VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); |
|
3319 |
3031 |
3320 if (stuff->dstDrawable != stuff->srcDrawable) |
3032 if (stuff->dstDrawable != stuff->srcDrawable) |
3321 { |
3033 { |
3322 SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client, |
3034 rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, |
3323 SecurityReadAccess); |
3035 DixReadAccess); |
3036 if (rc != Success) |
|
3037 return rc; |
|
3324 if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) |
3038 if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) |
3325 { |
3039 { |
3326 client->errorValue = stuff->dstDrawable; |
3040 client->errorValue = stuff->dstDrawable; |
3327 return (BadMatch); |
3041 return (BadMatch); |
3328 } |
3042 } |
3329 } |
3043 } |
3330 else |
3044 else |
3331 pSrc = pDst; |
3045 pSrc = pDst; |
3332 |
3046 |
3333 SET_DBE_SRCBUF(pSrc, stuff->srcDrawable); |
|
3334 |
|
3335 if (xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, pSrc, |
3047 if (xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, pSrc, |
3336 client, TSOL_ALL, (void *)MAJOROP)) |
3048 client, TSOL_ALL, (void *)MAJOROP)) |
3337 { |
3049 { |
3338 /* ignore the error message for DnD zap effect */ |
3050 /* ignore the error message for DnD zap effect */ |
3339 return(client->noClientException); |
3051 return(client->noClientException); |
3350 client->errorValue = stuff->gc; |
3062 client->errorValue = stuff->gc; |
3351 return (BadGC); |
3063 return (BadGC); |
3352 } |
3064 } |
3353 |
3065 |
3354 status = (*TsolSavedProcVector[X_CopyArea])(client); |
3066 status = (*TsolSavedProcVector[X_CopyArea])(client); |
3355 client->trustLevel = savedtrust; |
3067 setClientTrustLevel(client, savedtrust); |
3356 |
3068 |
3357 return (status); |
3069 return (status); |
3358 } |
3070 } |
3359 |
3071 |
3360 int |
3072 int |
3361 ProcTsolCopyPlane(client) |
3073 ProcTsolCopyPlane(ClientPtr client) |
3362 register ClientPtr client; |
|
3363 { |
3074 { |
3364 int savedtrust; |
3075 int savedtrust; |
3365 int status; |
3076 int status; |
3366 register DrawablePtr psrcDraw, pdstDraw; |
3077 DrawablePtr psrcDraw, pdstDraw; |
3367 register GC *pGC; |
3078 GC *pGC; |
3368 REQUEST(xCopyPlaneReq); |
3079 REQUEST(xCopyPlaneReq); |
3369 RegionPtr pRgn; |
3080 int rc; |
3370 |
3081 |
3371 REQUEST_SIZE_MATCH(xCopyPlaneReq); |
3082 REQUEST_SIZE_MATCH(xCopyPlaneReq); |
3372 |
3083 |
3373 savedtrust = client->trustLevel; |
3084 savedtrust = setClientTrustLevel(client, XSecurityClientTrusted); |
3374 client->trustLevel = XSecurityClientTrusted; |
3085 |
3375 |
3086 VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess); |
3376 VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client); |
|
3377 |
3087 |
3378 if (stuff->dstDrawable != stuff->srcDrawable) |
3088 if (stuff->dstDrawable != stuff->srcDrawable) |
3379 { |
3089 { |
3380 SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client, |
3090 rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0, |
3381 SecurityReadAccess); |
3091 DixReadAccess); |
3092 if (rc != Success) |
|
3093 return rc; |
|
3094 |
|
3382 if (pdstDraw->pScreen != psrcDraw->pScreen) |
3095 if (pdstDraw->pScreen != psrcDraw->pScreen) |
3383 { |
3096 { |
3384 client->errorValue = stuff->dstDrawable; |
3097 client->errorValue = stuff->dstDrawable; |
3385 return (BadMatch); |
3098 return (BadMatch); |
3386 } |
3099 } |
3387 } |
3100 } |
3388 else |
3101 else |
3389 psrcDraw = pdstDraw; |
3102 psrcDraw = pdstDraw; |
3390 |
3103 |
3391 SET_DBE_SRCBUF(psrcDraw, stuff->srcDrawable); |
|
3392 |
|
3393 if (xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, psrcDraw, |
3104 if (xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, psrcDraw, |
3394 client, TSOL_ALL, (void *)MAJOROP)) |
3105 client, TSOL_ALL, (void *)MAJOROP)) |
3395 { |
3106 { |
3396 /* ignore the error message for DnD zap effect */ |
3107 /* ignore the error message for DnD zap effect */ |
3397 return(client->noClientException); |
3108 return(client->noClientException); |
3408 client->errorValue = stuff->gc; |
3119 client->errorValue = stuff->gc; |
3409 return (BadGC); |
3120 return (BadGC); |
3410 } |
3121 } |
3411 |
3122 |
3412 status = (*TsolSavedProcVector[X_CopyPlane])(client); |
3123 status = (*TsolSavedProcVector[X_CopyPlane])(client); |
3413 client->trustLevel = savedtrust; |
3124 setClientTrustLevel(client, savedtrust); |
3414 |
3125 |
3415 return (status); |
3126 return (status); |
3416 } |
3127 } |