Debian Codegraph @

nx-X11/include/extensions/security.h

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