1 | /* |
---|
2 | * xdm - display manager daemon |
---|
3 | * |
---|
4 | * $XConsortium: dm.h,v 1.51 91/09/19 16:28:35 keith Exp $ |
---|
5 | * |
---|
6 | * Copyright 1988 Massachusetts Institute of Technology |
---|
7 | * |
---|
8 | * Permission to use, copy, modify, and distribute this software and its |
---|
9 | * documentation for any purpose and without fee is hereby granted, provided |
---|
10 | * that the above copyright notice appear in all copies and that both that |
---|
11 | * copyright notice and this permission notice appear in supporting |
---|
12 | * documentation, and that the name of M.I.T. not be used in advertising or |
---|
13 | * publicity pertaining to distribution of the software without specific, |
---|
14 | * written prior permission. M.I.T. makes no representations about the |
---|
15 | * suitability of this software for any purpose. It is provided "as is" |
---|
16 | * without express or implied warranty. |
---|
17 | * |
---|
18 | * Author: Keith Packard, MIT X Consortium |
---|
19 | */ |
---|
20 | |
---|
21 | /* |
---|
22 | * dm.h |
---|
23 | * |
---|
24 | * public interfaces for greet/verify functionality |
---|
25 | */ |
---|
26 | |
---|
27 | # include <X11/Xos.h> |
---|
28 | /* # include <X11/Xfuncs.h> */ |
---|
29 | # include <X11/Xmd.h> |
---|
30 | # include <X11/Xauth.h> |
---|
31 | |
---|
32 | #if !defined(X_NOT_POSIX) && !defined(_POSIX_SOURCE) |
---|
33 | #define _POSIX_SOURCE |
---|
34 | # include <setjmp.h> |
---|
35 | #undef _POSIX_SOURCE |
---|
36 | #else |
---|
37 | # include <setjmp.h> |
---|
38 | #endif |
---|
39 | |
---|
40 | /* If XDMCP symbol defined, compile to run XDMCP protocol */ |
---|
41 | |
---|
42 | #define XDMCP |
---|
43 | |
---|
44 | #ifdef XDMCP |
---|
45 | # include <X11/Xdmcp.h> |
---|
46 | typedef char *XdmcpNetaddr; |
---|
47 | #endif |
---|
48 | |
---|
49 | #ifndef X_NOT_POSIX |
---|
50 | #ifdef _POSIX_SOURCE |
---|
51 | # include <limits.h> |
---|
52 | #else |
---|
53 | #define _POSIX_SOURCE |
---|
54 | # include <limits.h> |
---|
55 | #undef _POSIX_SOURCE |
---|
56 | #endif |
---|
57 | #endif |
---|
58 | #ifndef NGROUPS_MAX |
---|
59 | # include <sys/param.h> |
---|
60 | #ifdef NGROUPS |
---|
61 | #define NGROUPS_MAX NGROUPS |
---|
62 | #endif |
---|
63 | #endif |
---|
64 | |
---|
65 | #ifdef pegasus |
---|
66 | #undef dirty /* Some bozo put a macro called dirty in sys/param.h */ |
---|
67 | #endif /* pegasus */ |
---|
68 | |
---|
69 | #ifndef X_NOT_POSIX |
---|
70 | #ifdef _POSIX_SOURCE |
---|
71 | #include <sys/wait.h> |
---|
72 | #else |
---|
73 | #define _POSIX_SOURCE |
---|
74 | #include <sys/wait.h> |
---|
75 | #undef _POSIX_SOURCE |
---|
76 | #endif |
---|
77 | # define waitCode(w) (WIFEXITED(w) ? WEXITSTATUS(w) : 0) |
---|
78 | # define waitSig(w) (WIFSIGNALED(w) ? WTERMSIG(w) : 0) |
---|
79 | # define waitCore(w) 0 /* not in POSIX. so what? */ |
---|
80 | typedef int waitType; |
---|
81 | #else /* X_NOT_POSIX */ |
---|
82 | #ifdef SYSV |
---|
83 | # define waitCode(w) (((w) >> 8) & 0x7f) |
---|
84 | # define waitSig(w) ((w) & 0xff) |
---|
85 | # define waitCore(w) (((w) >> 15) & 0x01) |
---|
86 | typedef int waitType; |
---|
87 | #else /* SYSV */ |
---|
88 | # include <sys/wait.h> |
---|
89 | # define waitCode(w) ((w).w_T.w_Retcode) |
---|
90 | # define waitSig(w) ((w).w_T.w_Termsig) |
---|
91 | # define waitCore(w) ((w).w_T.w_Coredump) |
---|
92 | typedef union wait waitType; |
---|
93 | #endif |
---|
94 | #endif /* X_NOT_POSIX */ |
---|
95 | |
---|
96 | # define waitCompose(sig,core,code) ((sig) * 256 + (core) * 128 + (code)) |
---|
97 | # define waitVal(w) waitCompose(waitSig(w), waitCore(w), waitCode(w)) |
---|
98 | |
---|
99 | typedef enum displayStatus { running, notRunning, zombie, phoenix } DisplayStatus; |
---|
100 | |
---|
101 | #ifndef FD_ZERO |
---|
102 | typedef struct my_fd_set { int fds_bits[1]; } my_fd_set; |
---|
103 | # define FD_ZERO(fdp) bzero ((fdp), sizeof (*(fdp))) |
---|
104 | # define FD_SET(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] |= (1 << ((f) % (sizeof (int) * 8)))) |
---|
105 | # define FD_CLR(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] &= ~(1 << ((f) % (sizeof (int) * 8)))) |
---|
106 | # define FD_ISSET(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] & (1 << ((f) % (sizeof (int) * 8)))) |
---|
107 | # define FD_TYPE my_fd_set |
---|
108 | #else |
---|
109 | # define FD_TYPE fd_set |
---|
110 | #endif |
---|
111 | |
---|
112 | /* |
---|
113 | * local - server runs on local host |
---|
114 | * foreign - server runs on remote host |
---|
115 | * permanent - session restarted when it exits |
---|
116 | * transient - session not restarted when it exits |
---|
117 | * fromFile - started via entry in servers file |
---|
118 | * fromXDMCP - started with XDMCP |
---|
119 | */ |
---|
120 | |
---|
121 | typedef struct displayType { |
---|
122 | unsigned int location:1; |
---|
123 | unsigned int lifetime:1; |
---|
124 | unsigned int origin:1; |
---|
125 | } DisplayType; |
---|
126 | |
---|
127 | # define Local 1 |
---|
128 | # define Foreign 0 |
---|
129 | |
---|
130 | # define Permanent 1 |
---|
131 | # define Transient 0 |
---|
132 | |
---|
133 | # define FromFile 1 |
---|
134 | # define FromXDMCP 0 |
---|
135 | |
---|
136 | extern DisplayType parseDisplayType (); |
---|
137 | |
---|
138 | typedef enum fileState { NewEntry, OldEntry, MissingEntry } FileState; |
---|
139 | |
---|
140 | struct display { |
---|
141 | struct display *next; |
---|
142 | /* Xservers file / XDMCP information */ |
---|
143 | char *name; /* DISPLAY name */ |
---|
144 | char *class; /* display class (may be NULL) */ |
---|
145 | DisplayType displayType; /* method to handle with */ |
---|
146 | char **argv; /* program name and arguments */ |
---|
147 | |
---|
148 | /* display state */ |
---|
149 | DisplayStatus status; /* current status */ |
---|
150 | int pid; /* process id of child */ |
---|
151 | int serverPid; /* process id of server (-1 if none) */ |
---|
152 | FileState state; /* state during HUP processing */ |
---|
153 | int startTries; /* current start try */ |
---|
154 | |
---|
155 | #ifdef XDMCP |
---|
156 | /* XDMCP state */ |
---|
157 | CARD32 sessionID; /* ID of active session */ |
---|
158 | XdmcpNetaddr peer; /* display peer address */ |
---|
159 | int peerlen; /* length of peer address */ |
---|
160 | XdmcpNetaddr from; /* XDMCP port of display */ |
---|
161 | int fromlen; |
---|
162 | CARD16 displayNumber; |
---|
163 | int useChooser; /* Run the chooser for this display */ |
---|
164 | ARRAY8 clientAddr; /* for chooser picking */ |
---|
165 | CARD16 connectionType; /* ... */ |
---|
166 | #endif |
---|
167 | /* server management resources */ |
---|
168 | int serverAttempts; /* number of attempts at running X */ |
---|
169 | int openDelay; /* open delay time */ |
---|
170 | int openRepeat; /* open attempts to make */ |
---|
171 | int openTimeout; /* abort open attempt timeout */ |
---|
172 | int startAttempts; /* number of attempts at starting */ |
---|
173 | int pingInterval; /* interval between XSync */ |
---|
174 | int pingTimeout; /* timeout for XSync */ |
---|
175 | int terminateServer;/* restart for each session */ |
---|
176 | int grabServer; /* keep server grabbed for Login */ |
---|
177 | int grabTimeout; /* time to wait for grab */ |
---|
178 | int resetSignal; /* signal to reset server */ |
---|
179 | int termSignal; /* signal to terminate server */ |
---|
180 | int resetForAuth; /* server reads auth file at reset */ |
---|
181 | |
---|
182 | /* session resources */ |
---|
183 | char *resources; /* resource file */ |
---|
184 | char *xrdb; /* xrdb program */ |
---|
185 | char *setup; /* Xsetup program */ |
---|
186 | char *startup; /* Xstartup program */ |
---|
187 | char *reset; /* Xreset program */ |
---|
188 | char *session; /* Xsession program */ |
---|
189 | char *userPath; /* path set for session */ |
---|
190 | char *systemPath; /* path set for startup/reset */ |
---|
191 | char *systemShell; /* interpreter for startup/reset */ |
---|
192 | char *failsafeClient;/* a client to start when the session fails */ |
---|
193 | char *chooser; /* chooser program */ |
---|
194 | |
---|
195 | /* authorization resources */ |
---|
196 | int authorize; /* enable authorization */ |
---|
197 | char **authNames; /* authorization protocol names */ |
---|
198 | unsigned short *authNameLens; /* authorization protocol name lens */ |
---|
199 | char *clientAuthFile;/* client specified auth file */ |
---|
200 | char *userAuthDir; /* backup directory for tickets */ |
---|
201 | int authComplain; /* complain when no auth for XDMCP */ |
---|
202 | |
---|
203 | /* information potentially derived from resources */ |
---|
204 | int authNameNum; /* number of protocol names */ |
---|
205 | Xauth **authorizations;/* authorization data */ |
---|
206 | int authNum; /* number of authorizations */ |
---|
207 | char *authFile; /* file to store authorization in */ |
---|
208 | }; |
---|
209 | |
---|
210 | #ifdef XDMCP |
---|
211 | |
---|
212 | #define PROTO_TIMEOUT (30 * 60) /* 30 minutes should be long enough */ |
---|
213 | |
---|
214 | struct protoDisplay { |
---|
215 | struct protoDisplay *next; |
---|
216 | XdmcpNetaddr address; /* UDP address */ |
---|
217 | int addrlen; /* UDP address length */ |
---|
218 | unsigned long date; /* creation date */ |
---|
219 | CARD16 displayNumber; |
---|
220 | CARD16 connectionType; |
---|
221 | ARRAY8 connectionAddress; |
---|
222 | CARD32 sessionID; |
---|
223 | Xauth *fileAuthorization; |
---|
224 | Xauth *xdmcpAuthorization; |
---|
225 | ARRAY8 authenticationName; |
---|
226 | ARRAY8 authenticationData; |
---|
227 | XdmAuthKeyRec key; |
---|
228 | }; |
---|
229 | #endif /* XDMCP */ |
---|
230 | |
---|
231 | struct greet_info { |
---|
232 | char *name; /* user name */ |
---|
233 | char *password; /* user password */ |
---|
234 | char *string; /* random string */ |
---|
235 | }; |
---|
236 | |
---|
237 | /* setgroups is not covered by POSIX, arg type varies */ |
---|
238 | #if defined(SYSV) || defined(SVR4) |
---|
239 | #define GID_T gid_t |
---|
240 | #else |
---|
241 | #define GID_T int |
---|
242 | #endif |
---|
243 | |
---|
244 | struct verify_info { |
---|
245 | int uid; /* user id */ |
---|
246 | #ifdef NGROUPS_MAX |
---|
247 | GID_T groups[NGROUPS_MAX];/* group list */ |
---|
248 | int ngroups; /* number of elements in groups */ |
---|
249 | #else |
---|
250 | int gid; /* group id */ |
---|
251 | #endif |
---|
252 | char **argv; /* arguments to session */ |
---|
253 | char **userEnviron; /* environment for session */ |
---|
254 | char **systemEnviron;/* environment for startup/reset */ |
---|
255 | }; |
---|
256 | |
---|
257 | /* display manager exit status definitions */ |
---|
258 | |
---|
259 | # define OBEYSESS_DISPLAY 0 /* obey multipleSessions resource */ |
---|
260 | # define REMANAGE_DISPLAY 1 /* force remanage */ |
---|
261 | # define UNMANAGE_DISPLAY 2 /* force deletion */ |
---|
262 | # define RESERVER_DISPLAY 3 /* force server termination */ |
---|
263 | # define OPENFAILED_DISPLAY 4 /* XOpenDisplay failed, retry */ |
---|
264 | |
---|
265 | #ifndef TRUE |
---|
266 | #define TRUE 1 |
---|
267 | #define FALSE 0 |
---|
268 | #endif |
---|
269 | |
---|
270 | extern char *config; |
---|
271 | |
---|
272 | extern char *servers; |
---|
273 | extern int request_port; |
---|
274 | extern int debugLevel; |
---|
275 | extern char *errorLogFile; |
---|
276 | extern int daemonMode; |
---|
277 | extern char *pidFile; |
---|
278 | extern int lockPidFile; |
---|
279 | extern char *authDir; |
---|
280 | extern int autoRescan; |
---|
281 | extern int removeDomainname; |
---|
282 | extern char *keyFile; |
---|
283 | extern char *accessFile; |
---|
284 | extern char **exportList; |
---|
285 | extern char *randomFile; |
---|
286 | |
---|
287 | extern struct display *FindDisplayByName (), |
---|
288 | *FindDisplayBySessionID (), |
---|
289 | *FindDisplayByAddress (), |
---|
290 | *FindDisplayByPid (), |
---|
291 | *FindDisplayByServerPid (), |
---|
292 | *NewDisplay (); |
---|
293 | |
---|
294 | extern struct protoDisplay *FindProtoDisplay (), |
---|
295 | *NewProtoDisplay (); |
---|
296 | |
---|
297 | extern char *localHostname (); |
---|
298 | /* |
---|
299 | * CloseOnFork flags |
---|
300 | */ |
---|
301 | |
---|
302 | # define CLOSE_ALWAYS 0 |
---|
303 | # define LEAVE_FOR_DISPLAY 1 |
---|
304 | |
---|
305 | #ifndef X_NOT_STDC_ENV |
---|
306 | #include <stdlib.h> |
---|
307 | #else |
---|
308 | char *malloc(), *realloc(); |
---|
309 | #endif |
---|
310 | #if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */ |
---|
311 | char *malloc(), *realloc(); |
---|
312 | #endif /* macII */ |
---|
313 | |
---|
314 | #if defined(X_NOT_POSIX) && defined(SIGNALRETURNSINT) |
---|
315 | #define SIGVAL int |
---|
316 | #else |
---|
317 | #define SIGVAL void |
---|
318 | #endif |
---|
319 | |
---|
320 | #ifdef X_NOT_POSIX |
---|
321 | #ifdef SYSV |
---|
322 | #define SIGNALS_RESET_WHEN_CAUGHT |
---|
323 | #define UNRELIABLE_SIGNALS |
---|
324 | #endif |
---|
325 | #define Setjmp(e) setjmp(e) |
---|
326 | #define Longjmp(e,v) longjmp(e,v) |
---|
327 | #define Jmp_buf jmp_buf |
---|
328 | #else |
---|
329 | #define Setjmp(e) sigsetjmp(e,1) |
---|
330 | #define Longjmp(e,v) siglongjmp(e,v) |
---|
331 | #define Jmp_buf sigjmp_buf |
---|
332 | #endif |
---|
333 | |
---|
334 | SIGVAL (*Signal())(); |
---|