1 /************************************************************
3 Author: Eamon Walsh <ewalsh@tycho.nsa.gov>
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 this permission notice appear in supporting documentation. This permission
8 notice shall be included in all copies or substantial portions of the
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
15 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 ********************************************************/
25 #define XACE_MAJOR_VERSION 2
26 #define XACE_MINOR_VERSION 0
28 #include "extnsionst.h"
33 #include "selection.h"
35 /* Default window background */
36 #define XaceBackgroundNoneState(w) ((w)->forcedBG ? BackgroundPixel : None)
39 /* Constants used to identify the available security hooks
41 #define XACE_CORE_DISPATCH 0
42 #define XACE_EXT_DISPATCH 1
43 #define XACE_RESOURCE_ACCESS 2
44 #define XACE_DEVICE_ACCESS 3
45 #define XACE_PROPERTY_ACCESS 4
46 #define XACE_SEND_ACCESS 5
47 #define XACE_RECEIVE_ACCESS 6
48 #define XACE_CLIENT_ACCESS 7
49 #define XACE_EXT_ACCESS 8
50 #define XACE_SERVER_ACCESS 9
51 #define XACE_SELECTION_ACCESS 10
52 #define XACE_SCREEN_ACCESS 11
53 #define XACE_SCREENSAVER_ACCESS 12
54 #define XACE_AUTH_AVAIL 13
55 #define XACE_KEY_AVAIL 14
56 #define XACE_NUM_HOOKS 15
58 extern CallbackListPtr XaceHooks
[XACE_NUM_HOOKS
];
60 /* Entry point for hook functions. Called by Xserver.
61 * Required by libdbe and libextmod
63 /* needs to be exported for in-tree modsetting driver, but not part
64 of public API for external modules */
65 _X_EXPORT
int XaceHook(int hook
, ... /* appropriate args for hook */);
67 /* determine whether any callbacks are present for the XACE hook */
68 int XaceHookIsSet(int hook
);
70 /* Special-cased hook functions
72 int XaceHookDispatch0(ClientPtr ptr
, int major
);
73 #define XaceHookDispatch(c, m) \
74 ((XaceHooks[XACE_EXT_DISPATCH] && (m) >= EXTENSION_BASE) ? \
75 XaceHookDispatch0((c), (m)) : \
78 int XaceHookPropertyAccess(ClientPtr ptr
, WindowPtr pWin
, PropertyPtr
*ppProp
,
80 int XaceHookSelectionAccess(ClientPtr ptr
, Selection
** ppSel
, Mask access_mode
);
82 /* needs to be exported for in-tree modsetting, but not part of public API */
83 _X_EXPORT
int XaceHookResourceAccess(ClientPtr client
, XID id
, RESTYPE rtype
, void *res
,
84 RESTYPE ptype
, void *parent
, Mask access_mode
);
86 int XaceHookDeviceAccess(ClientPtr client
, DeviceIntPtr dev
, Mask access_mode
);
88 int XaceHookSendAccess(ClientPtr client
, DeviceIntPtr dev
, WindowPtr win
,
89 xEventPtr ev
, int count
);
90 int XaceHookReceiveAccess(ClientPtr client
, WindowPtr win
, xEventPtr ev
, int count
);
91 int XaceHookClientAccess(ClientPtr client
, ClientPtr target
, Mask access_mode
);
92 int XaceHookExtAccess(ClientPtr client
, ExtensionEntry
*ext
);
93 int XaceHookServerAccess(ClientPtr client
, Mask access_mode
);
94 int XaceHookScreenAccess(ClientPtr client
, ScreenPtr screen
, Mask access_mode
);
95 int XaceHookScreensaverAccess(ClientPtr client
, ScreenPtr screen
, Mask access_mode
);
96 int XaceHookAuthAvail(ClientPtr client
, XID authId
);
97 int XaceHookKeyAvail(xEventPtr ev
, DeviceIntPtr dev
, int count
);
100 /* Register a callback for a given hook.
102 #define XaceRegisterCallback(hook,callback,data) \
103 AddCallback(XaceHooks+(hook), callback, data)
105 /* Unregister an existing callback for a given hook.
107 #define XaceDeleteCallback(hook,callback,data) \
108 DeleteCallback(XaceHooks+(hook), callback, data)
110 /* XTrans wrappers for use by security modules
112 int XaceGetConnectionNumber(ClientPtr ptr
);
113 int XaceIsLocal(ClientPtr ptr
);
115 /* From the original Security extension...
118 void XaceCensorImage(ClientPtr client
,
119 RegionPtr pVisibleRegion
,
122 int x
, int y
, int w
, int h
,
123 unsigned int format
, char *pBuf
);
127 /* Default window background */
128 #define XaceBackgroundNoneState(w) None
130 /* Define calls away when XACE is not being built. */
133 #define XaceHookIsSet(args...) 0
134 #define XaceHookDispatch(args...) Success
135 #define XaceHookPropertyAccess(args...) Success
136 #define XaceHookSelectionAccess(args...) Success
137 #define XaceCensorImage(args...) { ; }
139 #define XaceHookIsSet(...) 0
140 #define XaceHookDispatch(...) Success
141 #define XaceHookPropertyAccess(...) Success
142 #define XaceHookSelectionAccess(...) Success
143 #define XaceCensorImage(...) { ; }