1 | /* $Xorg: security.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $ */
|
---|
2 | /*
|
---|
3 | Copyright 1996, 1998 The Open Group
|
---|
4 |
|
---|
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 | the above copyright notice appear in all copies and that both that
|
---|
8 | copyright notice and this permission notice appear in supporting
|
---|
9 | documentation.
|
---|
10 |
|
---|
11 | The above copyright notice and this permission notice shall be included
|
---|
12 | in all copies or substantial portions of the Software.
|
---|
13 |
|
---|
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
15 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
---|
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
---|
17 | IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
18 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
19 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
20 | OTHER DEALINGS IN THE SOFTWARE.
|
---|
21 |
|
---|
22 | Except as contained in this notice, the name of The Open Group shall
|
---|
23 | not be used in advertising or otherwise to promote the sale, use or
|
---|
24 | other dealings in this Software without prior written authorization
|
---|
25 | from The Open Group.
|
---|
26 | */
|
---|
27 | /* $XFree86: xc/include/extensions/security.h,v 1.3 2001/12/14 19:53:29 dawes Exp $ */
|
---|
28 |
|
---|
29 | #ifndef _SECURITY_H
|
---|
30 | #define _SECURITY_H
|
---|
31 |
|
---|
32 | #define _XAUTH_STRUCT_ONLY
|
---|
33 | #include <X11/Xauth.h>
|
---|
34 |
|
---|
35 | /* constants that server, library, and application all need */
|
---|
36 |
|
---|
37 | #define XSecurityNumberEvents 1
|
---|
38 | #define XSecurityNumberErrors 2
|
---|
39 | #define XSecurityBadAuthorization 0
|
---|
40 | #define XSecurityBadAuthorizationProtocol 1
|
---|
41 |
|
---|
42 | /* trust levels */
|
---|
43 | #define XSecurityClientTrusted 0
|
---|
44 | #define XSecurityClientUntrusted 1
|
---|
45 |
|
---|
46 | /* authorization attribute masks */
|
---|
47 | #define XSecurityTimeout (1<<0)
|
---|
48 | #define XSecurityTrustLevel (1<<1)
|
---|
49 | #define XSecurityGroup (1<<2)
|
---|
50 | #define XSecurityEventMask (1<<3)
|
---|
51 | #define XSecurityAllAuthorizationAttributes \
|
---|
52 | (XSecurityTimeout | XSecurityTrustLevel | XSecurityGroup | XSecurityEventMask)
|
---|
53 |
|
---|
54 | /* event masks */
|
---|
55 | #define XSecurityAuthorizationRevokedMask (1<<0)
|
---|
56 | #define XSecurityAllEventMasks XSecurityAuthorizationRevokedMask
|
---|
57 |
|
---|
58 | /* event offsets */
|
---|
59 | #define XSecurityAuthorizationRevoked 0
|
---|
60 |
|
---|
61 | #define XSecurityAuthorizationName "XC-QUERY-SECURITY-1"
|
---|
62 | #define XSecurityAuthorizationNameLen 19
|
---|
63 |
|
---|
64 |
|
---|
65 | #ifndef _SECURITY_SERVER
|
---|
66 |
|
---|
67 | _XFUNCPROTOBEGIN
|
---|
68 |
|
---|
69 | Status XSecurityQueryExtension (
|
---|
70 | Display *dpy,
|
---|
71 | int *major_version_return,
|
---|
72 | int *minor_version_return);
|
---|
73 |
|
---|
74 | Xauth *XSecurityAllocXauth(void);
|
---|
75 |
|
---|
76 | void XSecurityFreeXauth(Xauth *auth);
|
---|
77 |
|
---|
78 | /* type for returned auth ids */
|
---|
79 | typedef unsigned long XSecurityAuthorization;
|
---|
80 |
|
---|
81 | typedef struct {
|
---|
82 | unsigned int timeout;
|
---|
83 | unsigned int trust_level;
|
---|
84 | XID group;
|
---|
85 | long event_mask;
|
---|
86 | } XSecurityAuthorizationAttributes;
|
---|
87 |
|
---|
88 | Xauth *XSecurityGenerateAuthorization(
|
---|
89 | Display *dpy,
|
---|
90 | Xauth *auth_in,
|
---|
91 | unsigned long valuemask,
|
---|
92 | XSecurityAuthorizationAttributes *attributes,
|
---|
93 | XSecurityAuthorization *auth_id_return);
|
---|
94 |
|
---|
95 | Status XSecurityRevokeAuthorization(
|
---|
96 | Display *dpy,
|
---|
97 | XSecurityAuthorization auth_id);
|
---|
98 |
|
---|
99 | _XFUNCPROTOEND
|
---|
100 |
|
---|
101 | typedef struct {
|
---|
102 | int type; /* event base + XSecurityAuthorizationRevoked */
|
---|
103 | unsigned long serial; /* # of last request processed by server */
|
---|
104 | Bool send_event; /* true if this came from a SendEvent request */
|
---|
105 | Display *display; /* Display the event was read from */
|
---|
106 | XSecurityAuthorization auth_id; /* revoked authorization id */
|
---|
107 | } XSecurityAuthorizationRevokedEvent;
|
---|
108 |
|
---|
109 | #else /* _SECURITY_SERVER */
|
---|
110 |
|
---|
111 | #include "input.h" /* for DeviceIntPtr */
|
---|
112 | #include "property.h" /* for PropertyPtr */
|
---|
113 | #include "pixmap.h" /* for DrawablePtr */
|
---|
114 | #include "resource.h" /* for RESTYPE */
|
---|
115 |
|
---|
116 | /* resource type to pass in LookupIDByType for authorizations */
|
---|
117 | extern RESTYPE SecurityAuthorizationResType;
|
---|
118 |
|
---|
119 | /* this is what we store for an authorization */
|
---|
120 | typedef struct {
|
---|
121 | XID id; /* resource ID */
|
---|
122 | CARD32 timeout; /* how long to live in seconds after refcnt == 0 */
|
---|
123 | unsigned int trustLevel; /* trusted/untrusted */
|
---|
124 | XID group; /* see embedding extension */
|
---|
125 | unsigned int refcnt; /* how many clients connected with this auth */
|
---|
126 | unsigned int secondsRemaining; /* overflow time amount for >49 days */
|
---|
127 | OsTimerPtr timer; /* timer for this auth */
|
---|
128 | struct _OtherClients *eventClients; /* clients wanting events */
|
---|
129 | } SecurityAuthorizationRec, *SecurityAuthorizationPtr;
|
---|
130 |
|
---|
131 | /* The following callback is called when a GenerateAuthorization request
|
---|
132 | * is processed to sanity check the group argument. The call data will
|
---|
133 | * be a pointer to a SecurityValidateGroupInfoRec (below).
|
---|
134 | * Functions registered on this callback are expected to examine the
|
---|
135 | * group and set the valid field to TRUE if they recognize the group as a
|
---|
136 | * legitimate group. If they don't recognize it, they should not change the
|
---|
137 | * valid field.
|
---|
138 | */
|
---|
139 | extern CallbackListPtr SecurityValidateGroupCallback;
|
---|
140 | typedef struct {
|
---|
141 | XID group; /* the group that was sent in GenerateAuthorization */
|
---|
142 | Bool valid; /* did anyone recognize it? if so, set to TRUE */
|
---|
143 | } SecurityValidateGroupInfoRec;
|
---|
144 |
|
---|
145 | /* Proc vectors for untrusted clients, swapped and unswapped versions.
|
---|
146 | * These are the same as the normal proc vectors except that extensions
|
---|
147 | * that haven't declared themselves secure will have ProcBadRequest plugged
|
---|
148 | * in for their major opcode dispatcher. This prevents untrusted clients
|
---|
149 | * from guessing extension major opcodes and using the extension even though
|
---|
150 | * the extension can't be listed or queried.
|
---|
151 | */
|
---|
152 | extern int (*UntrustedProcVector[256])(ClientPtr client);
|
---|
153 | extern int (*SwappedUntrustedProcVector[256])(ClientPtr client);
|
---|
154 |
|
---|
155 | extern Bool SecurityCheckDeviceAccess(ClientPtr client, DeviceIntPtr dev,
|
---|
156 | Bool fromRequest);
|
---|
157 |
|
---|
158 | extern void SecurityAudit(char *format, ...);
|
---|
159 |
|
---|
160 | #ifdef LBX
|
---|
161 | extern Bool SecuritySameLevel(ClientPtr client, XID authId);
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | extern int XSecurityOptions(int argc, char **argv, int i);
|
---|
165 |
|
---|
166 | /* Give this value or higher to the -audit option to get security messages */
|
---|
167 | #define SECURITY_AUDIT_LEVEL 4
|
---|
168 |
|
---|
169 | extern void SecurityCensorImage(
|
---|
170 | ClientPtr client,
|
---|
171 | RegionPtr pVisibleRegion,
|
---|
172 | long widthBytesLine,
|
---|
173 | DrawablePtr pDraw,
|
---|
174 | int x, int y, int w, int h,
|
---|
175 | unsigned int format,
|
---|
176 | char * pBuf);
|
---|
177 |
|
---|
178 | #define SecurityAllowOperation 0
|
---|
179 | #define SecurityIgnoreOperation 1
|
---|
180 | #define SecurityErrorOperation 2
|
---|
181 |
|
---|
182 | char
|
---|
183 | SecurityCheckPropertyAccess(
|
---|
184 | ClientPtr client,
|
---|
185 | WindowPtr pWin,
|
---|
186 | ATOM propertyName,
|
---|
187 | Mask access_mode);
|
---|
188 |
|
---|
189 | #define SECURITY_POLICY_FILE_VERSION "version-1"
|
---|
190 |
|
---|
191 | char **SecurityGetSitePolicyStrings(int *n);
|
---|
192 |
|
---|
193 | #endif /* _SECURITY_SERVER */
|
---|
194 |
|
---|
195 | #endif /* _SECURITY_H */
|
---|