1/************************************************************ 2 3Author: Eamon Walsh <ewalsh@tycho.nsa.gov> 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7this permission notice appear in supporting documentation. This permission 8notice shall be included in all copies or substantial portions of the 9Software. 10 11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 15AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 16CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 18********************************************************/ 19 20#ifndef _XACE_H 21#define _XACE_H 22 23#ifdef XACE 24 25#define XACE_MAJOR_VERSION 2 26#define XACE_MINOR_VERSION 0 27 28#include "pixmap.h" 29#include "region.h" 30#include "window.h" 31#include "property.h" 32#include "selection.h" 33 34/* Default window background */ 35#define XaceBackgroundNoneState(w) ((w)->forcedBG ? BackgroundPixel : None) 36 37/* security hooks */ 38/* Constants used to identify the available security hooks 39 */ 40#define XACE_CORE_DISPATCH 0 41#define XACE_EXT_DISPATCH 1 42#define XACE_RESOURCE_ACCESS 2 43#define XACE_DEVICE_ACCESS 3 44#define XACE_PROPERTY_ACCESS 4 45#define XACE_SEND_ACCESS 5 46#define XACE_RECEIVE_ACCESS 6 47#define XACE_CLIENT_ACCESS 7 48#define XACE_EXT_ACCESS 8 49#define XACE_SERVER_ACCESS 9 50#define XACE_SELECTION_ACCESS 10 51#define XACE_SCREEN_ACCESS 11 52#define XACE_SCREENSAVER_ACCESS 12 53#define XACE_AUTH_AVAIL 13 54#define XACE_KEY_AVAIL 14 55#define XACE_AUDIT_BEGIN 15 56#define XACE_AUDIT_END 16 57#define XACE_NUM_HOOKS 17 58 59extern _X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS]; 60 61/* Entry point for hook functions. Called by Xserver. 62 * Required by libdbe and libextmod 63 */ 64extern _X_EXPORT int XaceHook( 65 int /*hook*/, 66 ... /*appropriate args for hook*/ 67 ); 68 69/* Special-cased hook functions 70 */ 71extern _X_EXPORT int XaceHookDispatch(ClientPtr ptr, int major); 72extern _X_EXPORT int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin, 73 PropertyPtr *ppProp, Mask access_mode); 74extern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr, 75 Selection **ppSel, Mask access_mode); 76extern _X_EXPORT void XaceHookAuditEnd(ClientPtr ptr, int result); 77 78/* Register a callback for a given hook. 79 */ 80#define XaceRegisterCallback(hook,callback,data) \ 81 AddCallback(XaceHooks+(hook), callback, data) 82 83/* Unregister an existing callback for a given hook. 84 */ 85#define XaceDeleteCallback(hook,callback,data) \ 86 DeleteCallback(XaceHooks+(hook), callback, data) 87 88/* XTrans wrappers for use by security modules 89 */ 90extern _X_EXPORT int XaceGetConnectionNumber(ClientPtr ptr); 91extern _X_EXPORT int XaceIsLocal(ClientPtr ptr); 92 93/* From the original Security extension... 94 */ 95 96extern _X_EXPORT void XaceCensorImage( 97 ClientPtr client, 98 RegionPtr pVisibleRegion, 99 long widthBytesLine, 100 DrawablePtr pDraw, 101 int x, int y, int w, int h, 102 unsigned int format, 103 char * pBuf 104 ); 105 106#else /* XACE */ 107 108/* Default window background */ 109#define XaceBackgroundNoneState(w) None 110 111/* Define calls away when XACE is not being built. */ 112 113#ifdef __GNUC__ 114#define XaceHook(args...) Success 115#define XaceHookDispatch(args...) Success 116#define XaceHookPropertyAccess(args...) Success 117#define XaceHookSelectionAccess(args...) Success 118#define XaceHookAuditEnd(args...) { ; } 119#define XaceCensorImage(args...) { ; } 120#else 121#define XaceHook(...) Success 122#define XaceHookDispatch(...) Success 123#define XaceHookPropertyAccess(...) Success 124#define XaceHookSelectionAccess(...) Success 125#define XaceHookAuditEnd(...) { ; } 126#define XaceCensorImage(...) { ; } 127#endif 128 129#endif /* XACE */ 130 131#endif /* _XACE_H */ 132