1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
/*
Copyright 1988, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* xdm - display manager daemon
* Author: Keith Packard, MIT X Consortium
*
* dm.h
*
* public interfaces for greet/verify functionality
*/
#ifndef _DM_H_
# define _DM_H_ 1
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include <X11/Xos.h>
# include <X11/Xfuncs.h>
# include <X11/Xfuncproto.h>
# include <X11/Xmd.h>
# include <X11/Xauth.h>
# include <X11/Intrinsic.h>
# include <setjmp.h>
# include <limits.h>
# include <time.h>
# define Time_t time_t
# include <X11/Xdmcp.h>
# ifdef _POSIX_SOURCE
# include <sys/wait.h>
# else
# define _POSIX_SOURCE
# include <sys/wait.h>
# undef _POSIX_SOURCE
# endif
# define waitCode(w) (WIFEXITED(w) ? WEXITSTATUS(w) : 0)
# define waitSig(w) (WIFSIGNALED(w) ? WTERMSIG(w) : 0)
# define waitCore(w) 0 /* not in POSIX. so what? */
typedef int waitType;
# include <sys/param.h>
# include <login_cap.h>
# include <pwd.h>
# include <bsd_auth.h>
# define waitCompose(sig,core,code) ((sig) * 256 + (core) * 128 + (code))
# define waitVal(w) waitCompose(waitSig(w), waitCore(w), waitCode(w))
typedef enum displayStatus { running, notRunning, zombie, phoenix } DisplayStatus;
/*
* local - server runs on local host
* foreign - server runs on remote host
* permanent - session restarted when it exits
* transient - session not restarted when it exits
* fromFile - started via entry in servers file
* fromXDMCP - started with XDMCP
*/
typedef struct displayType {
unsigned int location:1;
unsigned int lifetime:1;
unsigned int origin:1;
} DisplayType;
# define Local 1
# define Foreign 0
# define Permanent 1
# define Transient 0
# define FromFile 1
# define FromXDMCP 0
extern DisplayType parseDisplayType (char *string, int *usedDefault);
typedef enum fileState { NewEntry, OldEntry, MissingEntry } FileState;
struct display {
struct display *next;
/* Xservers file / XDMCP information */
char *name; /* DISPLAY name */
char *class; /* display class (may be NULL) */
DisplayType displayType; /* method to handle with */
char **argv; /* program name and arguments */
/* display state */
DisplayStatus status; /* current status */
pid_t pid; /* process id of child */
pid_t serverPid; /* process id of server (-1 if none) */
FileState state; /* state during HUP processing */
int startTries; /* current start try */
Time_t lastReserv; /* time of last reserver crash */
int reservTries; /* current reserver try */
/* server management resources */
int serverAttempts; /* number of attempts at running X */
int openDelay; /* open delay time */
int openRepeat; /* open attempts to make */
int openTimeout; /* abort open attempt timeout */
int startAttempts; /* number of attempts at starting */
int reservAttempts; /* allowed start-IO error sequences */
int terminateServer;/* restart for each session */
int grabServer; /* keep server grabbed for Login */
int grabTimeout; /* time to wait for grab */
int resetSignal; /* signal to reset server */
int termSignal; /* signal to terminate server */
int resetForAuth; /* server reads auth file at reset */
char *keymaps; /* binary compat with DEC */
char *greeterLib; /* greeter shared library name */
/* session resources */
char *resources; /* resource file */
char *xrdb; /* xrdb program */
char *setup; /* Xsetup program */
char *startup; /* Xstartup program */
char *reset; /* Xreset program */
char *session; /* Xsession program */
char *userPath; /* path set for session */
char *systemPath; /* path set for startup/reset */
char *systemShell; /* interpreter for startup/reset */
char *failsafeClient;/* a client to start when the session fails */
char *chooser; /* chooser program */
/* authorization resources */
int authorize; /* enable authorization */
char **authNames; /* authorization protocol names */
unsigned short *authNameLens; /* authorization protocol name lens */
char *clientAuthFile;/* client specified auth file */
char *userAuthDir; /* backup directory for tickets */
int authComplain; /* complain when no auth for XDMCP */
/* information potentially derived from resources */
int authNameNum; /* number of protocol names */
Xauth **authorizations;/* authorization data */
int authNum; /* number of authorizations */
char *authFile; /* file to store authorization in */
int version; /* to keep dynamic greeter clued in */
/* add new fields only after here. And preferably at the end. */
/* Hack for making "Willing to manage" configurable */
char *willing; /* "Willing to manage" program */
Display *dpy; /* Display */
char *windowPath; /* path to server "window" */
};
# define PROTO_TIMEOUT (30 * 60) /* 30 minutes should be long enough */
# define XDM_BROKEN_INTERVAL (120) /* server crashing more than once within */
/* two minutes is assumed to be broken! */
struct protoDisplay {
struct protoDisplay *next;
XdmcpNetaddr address; /* UDP address */
int addrlen; /* UDP address length */
unsigned long date; /* creation date */
CARD16 displayNumber;
CARD16 connectionType;
ARRAY8 connectionAddress;
CARD32 sessionID;
Xauth *fileAuthorization;
Xauth *xdmcpAuthorization;
ARRAY8 authenticationName;
ARRAY8 authenticationData;
XdmAuthKeyRec key;
};
struct greet_info {
char *name; /* user name */
char *password; /* user password */
char *string; /* random string */
char *passwd; /* binary compat with DEC */
int version; /* for dynamic greeter to see */
/* add new fields below this line, and preferably at the end */
Boolean allow_null_passwd; /* allow null password on login */
Boolean allow_root_login; /* allow direct root login */
};
typedef void (*ChooserFunc)(CARD16 connectionType, ARRAY8Ptr addr, char *closure);
typedef void (*ListenFunc)(ARRAY8Ptr addr, void **closure);
struct verify_info {
int uid; /* user id */
int gid; /* group id */
char **argv; /* arguments to session */
char **userEnviron; /* environment for session */
char **systemEnviron;/* environment for startup/reset */
int version; /* for dynamic greeter to see */
/* add new fields below this line, and preferably at the end */
};
/* display manager exit status definitions */
# define OBEYSESS_DISPLAY 0 /* obey multipleSessions resource */
# define REMANAGE_DISPLAY 1 /* force remanage */
# define UNMANAGE_DISPLAY 2 /* force deletion */
# define RESERVER_DISPLAY 3 /* force server termination */
# define OPENFAILED_DISPLAY 4 /* XOpenDisplay failed, retry */
# ifndef TRUE
# define TRUE 1
# define FALSE 0
# endif
extern char *config;
extern char *servers;
extern int request_port;
extern int debugLevel;
extern char *errorLogFile;
extern int daemonMode;
extern char *pidFile;
extern int lockPidFile;
extern char *authDir;
extern int autoRescan;
extern int removeDomainname;
extern char *keyFile;
extern char *accessFile;
extern char **exportList;
# if !defined(HAVE_ARC4RANDOM)
extern char *randomFile;
extern char *prngdSocket;
extern int prngdPort;
# endif
extern char *greeterLib;
extern char *willing;
extern int choiceTimeout; /* chooser choice timeout */
extern struct display *FindDisplayByName (char *name),
*FindDisplayBySessionID (CARD32 sessionID),
*FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, CARD16 displayNumber),
*FindDisplayByPid (pid_t pid),
*FindDisplayByServerPid (pid_t serverPid),
*NewDisplay (char *name, char *class);
extern struct protoDisplay *FindProtoDisplay (
XdmcpNetaddr address,
int addrlen,
CARD16 displayNumber);
extern struct protoDisplay *NewProtoDisplay (
XdmcpNetaddr address,
int addrlen,
CARD16 displayNumber,
CARD16 connectionType,
ARRAY8Ptr connectionAddress,
CARD32 sessionID);
/* in Login.c */
extern void DrawFail (Widget ctx);
/* in chooser.c */
extern void RunChooser (struct display *d);
/* in dm.c */
extern void CloseOnFork (void);
extern void RegisterCloseOnFork (int fd);
extern void StartDisplay (struct display *d);
# ifndef HAVE_SETPROCTITLE
extern void SetTitle (char *name, ...);
# endif
/* in dpylist.c */
extern int AnyDisplaysLeft (void);
extern void ForEachDisplay (void (*f)(struct display *));
extern void RemoveDisplay (struct display *old);
/* in file.c */
extern void ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable);
/* in netaddr.c */
extern char *NetaddrAddress(XdmcpNetaddr netaddrp, int *lenp);
extern char *NetaddrPort(XdmcpNetaddr netaddrp, int *lenp);
extern int ConvertAddr (XdmcpNetaddr saddr, int *len, char **addr);
extern int NetaddrFamily (XdmcpNetaddr netaddrp);
extern int addressEqual (XdmcpNetaddr a1, int len1, XdmcpNetaddr a2, int len2);
/* in protodpy.c */
extern void DisposeProtoDisplay(struct protoDisplay *pdpy);
/* in reset.c */
extern void pseudoReset (Display *dpy);
/* in resource.c */
extern void InitResources (int argc, char **argv);
extern void LoadDMResources (void);
extern void LoadServerResources (struct display *d);
extern void LoadSessionResources (struct display *d);
extern void ReinitResources (void);
/* in session.c */
extern char **defaultEnv (void);
extern char **systemEnv (struct display *d, char *user, char *home);
extern int source (char **environ, char *file);
extern void ClearCloseOnFork (int fd);
extern void DeleteXloginResources (struct display *d, Display *dpy);
extern void LoadXloginResources (struct display *d);
extern void ManageSession (struct display *d);
extern void SecureDisplay (struct display *d, Display *dpy);
extern void SessionExit (struct display *d, int status, int removeAuth);
extern void SessionPingFailed (struct display *d);
extern void SetupDisplay (struct display *d);
extern void UnsecureDisplay (struct display *d, Display *dpy);
extern void execute(char **argv, char **environ);
/* server.c */
extern const char *_SysErrorMsg (int n);
extern int StartServer (struct display *d);
extern int WaitForServer (struct display *d);
extern void ResetServer (struct display *d);
/* in util.c */
extern char *localHostname (void);
extern char **parseArgs (char **argv, const char *string);
extern char **setEnv (char **e, const char *name, const char *value);
extern char **putEnv(const char *string, char **env);
extern char *getEnv (char **e, const char *name);
extern void CleanUpChild (void);
extern void freeArgs (char **argv);
extern void freeEnv (char **env);
extern void printEnv (char **e);
/* in verify.c */
extern int Verify (struct display *d, struct greet_info *greet, struct verify_info *verify);
/* in dm.c */
extern void StopDisplay (struct display *d);
extern void WaitForChild (void);
/*
* CloseOnFork flags
*/
# define CLOSE_ALWAYS 0
# define LEAVE_FOR_DISPLAY 1
# include <stdlib.h>
# define SIGVAL RETSIGTYPE
# define Setjmp(e) sigsetjmp(e,1)
# define Longjmp(e,v) siglongjmp(e,v)
# define Jmp_buf sigjmp_buf
typedef SIGVAL (*SIGFUNC)(int);
#endif /* _DM_H_ */
|