~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kdm/backend/dm.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright 1988, 1998  The Open Group
 
4
Copyright 2000-2005 Oswald Buddenhagen <ossi@kde.org>
 
5
 
 
6
Permission to use, copy, modify, distribute, and sell this software and its
 
7
documentation for any purpose is hereby granted without fee, provided that
 
8
the above copyright notice appear in all copies and that both that
 
9
copyright notice and this permission notice appear in supporting
 
10
documentation.
 
11
 
 
12
The above copyright notice and this permission notice shall be included
 
13
in all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
18
IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
21
OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of a copyright holder shall
 
24
not be used in advertising or otherwise to promote the sale, use or
 
25
other dealings in this Software without prior written authorization
 
26
from the copyright holder.
 
27
 
 
28
*/
 
29
 
 
30
/*
 
31
 * xdm - display manager daemon
 
32
 * Author: Keith Packard, MIT X Consortium
 
33
 *
 
34
 * global xdm core declarations
 
35
 */
 
36
 
 
37
#ifndef _DM_H_
 
38
#define _DM_H_ 1
 
39
 
 
40
#include "greet.h"
 
41
 
 
42
#define WANT_CORE_DECLS
 
43
#include <config.ci>
 
44
 
 
45
#include <X11/X.h> /* FamilyInternet6 */
 
46
#include <X11/Xos.h>
 
47
#include <X11/Xfuncs.h>
 
48
#include <X11/Xmd.h>
 
49
#include <X11/Xauth.h>
 
50
 
 
51
#include <sys/param.h>
 
52
#ifdef HAVE_LIMITS_H
 
53
# include <limits.h>
 
54
#endif
 
55
 
 
56
#include <time.h>
 
57
#include <sys/time.h>
 
58
#include <stdlib.h>
 
59
#include <errno.h>
 
60
 
 
61
extern char **environ;
 
62
 
 
63
#ifdef XDMCP
 
64
# if defined(__osf__)
 
65
/* someone somewhere defines QUERY under Tru64 which confuses Xdmcp.h */
 
66
#  undef QUERY
 
67
# endif
 
68
# include <X11/Xdmcp.h>
 
69
#endif
 
70
 
 
71
#ifndef PATH_MAX
 
72
# ifdef MAXPATHLEN
 
73
#  define PATH_MAX MAXPATHLEN
 
74
# else
 
75
#  define PATH_MAX 1024
 
76
# endif
 
77
#endif
 
78
 
 
79
#include <sys/wait.h>
 
80
#define waitCode(w) (WIFEXITED(w) ? WEXITSTATUS(w) : 0)
 
81
#define waitSig(w) (WIFSIGNALED(w) ? WTERMSIG(w) : 0)
 
82
#ifdef WCOREDUMP
 
83
# define waitCore(w) (WCOREDUMP(w))
 
84
#else
 
85
# define waitCore(w) 0 /* not in POSIX.  so what? */
 
86
#endif
 
87
 
 
88
#define wcCompose(sig,core,code) ((sig) * 256 + (core) * 128 + (code))
 
89
#define wcFromWait(w) wcCompose(waitSig(w), waitCore(w), waitCode(w))
 
90
#define wcCode(w) ((w) & 0x7f)
 
91
#define wcCore(w) (((w) >> 7) & 1)
 
92
#define wcSig(w) (((w) >> 8) & 0xff)
 
93
 
 
94
#include <setjmp.h>
 
95
#if defined(__EMX__) || (defined(__NetBSD__) && defined(__sparc__)) /* XXX netbsd? */
 
96
# define Setjmp(e) setjmp(e)
 
97
# define Longjmp(e,v) longjmp(e,v)
 
98
# define Jmp_buf jmp_buf
 
99
#else
 
100
# define Setjmp(e) sigsetjmp(e,1)
 
101
# define Longjmp(e,v) siglongjmp(e,v)
 
102
# define Jmp_buf sigjmp_buf
 
103
#endif
 
104
 
 
105
#ifdef HAVE_UTMPX
 
106
# include <utmpx.h>
 
107
# define STRUCTUTMP struct utmpx
 
108
# define UTMPNAME utmpxname
 
109
# define SETUTENT setutxent
 
110
# define GETUTENT getutxent
 
111
# define PUTUTLINE pututxline
 
112
# define ENDUTENT endutxent
 
113
# define ut_time ut_tv.tv_sec
 
114
#else
 
115
# include <utmp.h>
 
116
# define STRUCTUTMP struct utmp
 
117
# define UTMPNAME utmpname
 
118
# define SETUTENT setutent
 
119
# define GETUTENT getutent
 
120
# define PUTUTLINE pututline
 
121
# define ENDUTENT endutent
 
122
# ifndef HAVE_STRUCT_UTMP_UT_USER
 
123
#  define ut_user ut_name
 
124
# endif
 
125
#endif
 
126
#ifndef WTMP_FILE
 
127
# ifdef _PATH_WTMPX
 
128
#  define WTMP_FILE _PATH_WTMPX
 
129
# elif defined(_PATH_WTMP)
 
130
#  define WTMP_FILE _PATH_WTMP
 
131
# else
 
132
#  define WTMP_FILE "/usr/adm/wtmp"
 
133
# endif
 
134
#endif
 
135
#ifndef UTMP_FILE
 
136
# ifdef _PATH_UTMPX
 
137
#  define UTMP_FILE _PATH_UTMPX
 
138
# elif defined(_PATH_UTMP)
 
139
#  define UTMP_FILE _PATH_UTMP
 
140
# else
 
141
#  define UTMP_FILE "/etc/utmp"
 
142
# endif
 
143
#endif
 
144
 
 
145
#ifdef HAVE_NETCONFIG_H
 
146
# define STREAMSCONN
 
147
#else
 
148
# define UNIXCONN
 
149
# define TCPCONN
 
150
# ifdef FamilyInternet6
 
151
#  define IPv6
 
152
# endif
 
153
# ifdef HAVE_NETDNET_DN_H
 
154
#  define DNETCONN
 
155
# endif
 
156
#endif
 
157
 
 
158
#if !defined(HAVE_ARC4RANDOM) && !defined(DEV_RANDOM)
 
159
# define NEED_ENTROPY
 
160
#endif
 
161
 
 
162
typedef struct GPipe {
 
163
#if defined(__FreeBSD__) || defined(UNIXCONN)
 
164
# define SINGLE_PIPE
 
165
    union
 
166
#else
 
167
    struct
 
168
#endif
 
169
    {
 
170
        int w, r;
 
171
    } fd;
 
172
    char *who;
 
173
} GPipe;
 
174
 
 
175
typedef struct GTalk {
 
176
    GPipe *pipe;
 
177
    Jmp_buf errjmp;
 
178
} GTalk;
 
179
 
 
180
typedef struct GProc {
 
181
    GPipe pipe;
 
182
    int pid;
 
183
} GProc;
 
184
 
 
185
typedef enum displayStatus {
 
186
    notRunning = 0, /* waiting for being started */
 
187
    running,        /* was started */
 
188
    zombie,         /* manager and server killed, remove/suspend when both are gone */
 
189
    phoenix,        /* server killed, restart when it dies */
 
190
    raiser,         /* manager killed, restart when it dies */
 
191
    textMode,       /* suspended, console mode */
 
192
    reserve,        /* suspended, reserve display */
 
193
    remoteLogin     /* running X -query */
 
194
} DisplayStatus;
 
195
 
 
196
typedef enum serverStatus {
 
197
    ignore = 0,     /* error in this state is no error */
 
198
    awaiting,       /* waking for being started */
 
199
    starting,       /* process launched, wait max serverTimeout secs */
 
200
    terminated,     /* process SIGTERMed, wait max serverTimeout secs */
 
201
    killed,         /* process SIGKILLed, wait max 10 secs */
 
202
    pausing         /* startup failed, wait openDelay secs */
 
203
} ServerStatus;
 
204
 
 
205
typedef struct {
 
206
    unsigned how:2,    /* 0=none 1=reboot 2=halt (SHUT_*) */
 
207
             force:2;
 
208
    int uid;
 
209
    int start;
 
210
    int timeout;
 
211
    char *osname;
 
212
    time_t bmstamp;
 
213
    int osindex;
 
214
} SdRec;
 
215
 
 
216
typedef struct RcStr {
 
217
    struct RcStr *next;
 
218
    char *str;
 
219
    int cnt;
 
220
} RcStr;
 
221
 
 
222
typedef struct CfgDep {
 
223
    RcStr *name;
 
224
    long time;
 
225
} CfgDep;
 
226
 
 
227
typedef struct CfgArr {
 
228
    void *data;     /* config value array; allocated */
 
229
    int *idx;      /* config index array; alias */
 
230
    CfgDep dep;     /* filestamp */
 
231
    int numCfgEnt;  /* number of config entries */
 
232
} CfgArr;
 
233
 
 
234
struct bsock {
 
235
    int fd;
 
236
    int buflen;
 
237
    char *buffer;
 
238
};
 
239
 
 
240
struct cmdsock {
 
241
    struct cmdsock *next;
 
242
    struct bsock sock;    /* buffered fd of the socket */
 
243
};
 
244
 
 
245
typedef struct {
 
246
    struct cmdsock *css;  /* open connections */
 
247
 
 
248
    char *path;           /* filename of the socket */
 
249
#ifndef HONORS_SOCKET_PERMS
 
250
    char *realdir;        /* real dirname of the socket */
 
251
#endif
 
252
    int fd;               /* fd of the socket */
 
253
    int gid;              /* owner group of the socket */
 
254
} CtrlRec;
 
255
 
 
256
struct display {
 
257
    struct display *next;
 
258
    struct disphist *hstent;    /* display history entry */
 
259
 
 
260
    /* basic display information */
 
261
    char *name;                 /* DISPLAY name -- also referenced in hstent */
 
262
    char *class2;               /* display class (may be 0) */
 
263
    int displayType;            /* location/origin/lifetime */
 
264
    CfgArr cfg;                 /* config data array */
 
265
 
 
266
    /* display state */
 
267
    DisplayStatus status;       /* current status */
 
268
    int zstatus;                /* substatus while zombie */
 
269
    int pid;                    /* process id of child */
 
270
    int serverPid;              /* process id of server (-1 if none) */
 
271
#ifdef HAVE_VTS
 
272
    int serverVT;               /* server VT (0 = none, -1 = pending) */
 
273
    struct display *follower;   /* on exit, hand VT to this display */
 
274
#endif
 
275
    ServerStatus serverStatus;  /* X server startup state */
 
276
    time_t lastStart;           /* time of last display start */
 
277
    int startTries;             /* current start try */
 
278
    int stillThere;             /* state during HUP processing */
 
279
    int userSess;               /* -1=nobody, otherwise uid */
 
280
    char *userName;
 
281
    char *sessName;
 
282
    SdRec sdRec;                /* user session requested shutdown */
 
283
    CtrlRec ctrl;               /* command socket */
 
284
    GPipe pipe;                 /* comm master <-> slave */
 
285
    GPipe gpipe;                /* comm master <-> greeter */
 
286
#ifdef XDMCP
 
287
    char *remoteHost;           /* for X -query type remote login */
 
288
    /* XDMCP state */
 
289
    unsigned sessionID;         /* ID of active session */
 
290
    ARRAY8 peer;                /* display peer address (sockaddr) */
 
291
    ARRAY8 from;                /* XDMCP peer address (sockaddr) */
 
292
    unsigned displayNumber;     /* numerical part of name */
 
293
    int useChooser;             /* Run the chooser for this display */
 
294
    ARRAY8 clientAddr;          /* for chooser picking */
 
295
    ARRAY8 clientPort;          /* ... */
 
296
    unsigned connectionType;    /* ... */
 
297
    int xdmcpFd;
 
298
#endif
 
299
 
 
300
    CONF_CORE_LOCAL_DEFS
 
301
 
 
302
    /* information potentially derived from resources */
 
303
    Xauth **authorizations;     /* authorization data */
 
304
    int authNum;                /* number of authorizations */
 
305
    char *authFile;             /* file to store authorization in */
 
306
    char *greeterAuthFile;      /* file to store authorization for greeter in */
 
307
};
 
308
 
 
309
#define d_location   1
 
310
#define dLocal          1       /* server runs on local host */
 
311
#define dForeign        0       /* server runs on remote host */
 
312
 
 
313
#define d_lifetime   6
 
314
#define dPermanent      4       /* display restarted when session exits */
 
315
#define dReserve        2       /* display not restarted when session exits */
 
316
#define dTransient      0       /* display removed when session exits */
 
317
 
 
318
#ifdef XDMCP
 
319
#define d_origin     24
 
320
#else
 
321
#define d_origin     16 /* clever, huh? :) */
 
322
#endif
 
323
#define dFromCommand   16       /* started via command socket */
 
324
#define dFromXDMCP      8       /* started with XDMCP */
 
325
#define dFromFile       0       /* started via entry in servers file */
 
326
 
 
327
struct disphist {
 
328
    struct disphist *next;
 
329
    char *name;
 
330
    time_t lastExit;      /* time of last display exit */
 
331
    unsigned rLogin:2,    /* 0=nothing 1=relogin 2=login */
 
332
             lock:1,      /* screen locker running */
 
333
             goodExit:1;  /* was the last exit "peaceful"? */
 
334
    char *nuser, *npass, *nargs;
 
335
};
 
336
 
 
337
#ifdef XDMCP
 
338
 
 
339
#define PROTO_TIMEOUT (30 * 60)  /* 30 minutes should be long enough */
 
340
 
 
341
struct protoDisplay {
 
342
    struct protoDisplay *next;
 
343
    XdmcpNetaddr address;       /* UDP address */
 
344
    int addrlen;                /* UDP address length */
 
345
    unsigned long date;         /* creation date */
 
346
    CARD16 displayNumber;
 
347
    CARD16 connectionType;
 
348
    ARRAY8 connectionAddress;
 
349
    CARD32 sessionID;
 
350
    Xauth *fileAuthorization;
 
351
    Xauth *xdmcpAuthorization;
 
352
    ARRAY8 authenticationName;
 
353
    ARRAY8 authenticationData;
 
354
    XdmAuthKeyRec key;
 
355
};
 
356
#endif /* XDMCP */
 
357
 
 
358
/* status code for rStopDisplay */
 
359
#define DS_MASK      255
 
360
# define DS_RESTART  0
 
361
# define DS_TEXTMODE 1
 
362
# define DS_RESERVE  2
 
363
# define DS_REMOTE   3
 
364
# define DS_REMOVE   4
 
365
#define DS_SCHEDULE  256 /* flag for DS_TEXTMODE */
 
366
 
 
367
/* command codes dpy process -> master process */
 
368
#define D_User       1
 
369
#define D_ReLogin    2
 
370
#define D_ChooseHost 4
 
371
#define D_RemoteHost 5
 
372
#define D_XConnOk    6
 
373
#define D_UnUser     7
 
374
 
 
375
extern int debugLevel;
 
376
 
 
377
CONF_CORE_GLOBAL_DECLS
 
378
 
 
379
/* in daemon.c */
 
380
void becomeDaemon(void);
 
381
 
 
382
/* in dm.c */
 
383
#if KDM_LIBEXEC_STRIP != -1
 
384
extern char *progpath;
 
385
#endif
 
386
#if KDM_LIBEXEC_STRIP
 
387
extern char *progname;
 
388
#endif
 
389
extern char *prog;
 
390
extern time_t now;
 
391
extern SdRec sdRec;
 
392
void startDisplayP2(struct display *d);
 
393
void stopDisplay(struct display *d);
 
394
#if !defined(HAVE_SETPROCTITLE) && !defined(NOXDMTITLE)
 
395
void setproctitle(const char *fmt, ...);
 
396
#endif
 
397
void wakeDisplays(void);
 
398
void switchToX(struct display *d);
 
399
void setNLogin(struct display *d,
 
400
               const char *nuser, const char *npass, const char *nargs,
 
401
               int rl);
 
402
void cancelShutdown(void);
 
403
int TTYtoVT(const char *tty);
 
404
int activateVT(int vt);
 
405
 
 
406
#ifndef _POSIX_MONOTONIC_CLOCK
 
407
# define _POSIX_MONOTONIC_CLOCK -1
 
408
#endif
 
409
#if (_POSIX_MONOTONIC_CLOCK > 0)
 
410
# define nowMonotonic 1
 
411
#elif (_POSIX_MONOTONIC_CLOCK < 0)
 
412
# define nowMonotonic 0
 
413
#else
 
414
extern int nowMonotonic;
 
415
#endif
 
416
void updateNow(void);
 
417
 
 
418
/* in ctrl.c */
 
419
void openCtrl(struct display *d);
 
420
void closeCtrl(struct display *d);
 
421
int handleCtrl(fd_set *reads, struct display *d);
 
422
void chownCtrl(CtrlRec *cr, int uid);
 
423
void updateCtrl(void);
 
424
 
 
425
/* in dpylist.c */
 
426
extern struct display *displays; /* that's ugly ... */
 
427
int anyDisplaysLeft(void);
 
428
void forEachDisplay(void (*f)(struct display *));
 
429
#ifdef HAVE_VTS
 
430
void forEachDisplayRev(void (*f)(struct display *));
 
431
#endif
 
432
void removeDisplay(struct display *old);
 
433
struct display
 
434
    *findDisplayByName(const char *name),
 
435
#ifdef XDMCP
 
436
    *findDisplayBySessionID(CARD32 sessionID),
 
437
    *findDisplayByAddress(XdmcpNetaddr addr, int addrlen, CARD16 displayNumber),
 
438
#endif /* XDMCP */
 
439
    *findDisplayByPid(int pid),
 
440
    *findDisplayByServerPid(int serverPid),
 
441
    *newDisplay(const char *name);
 
442
int anyRunningDisplays(void);
 
443
int anyReserveDisplays(void);
 
444
int idleReserveDisplays(void);
 
445
int startReserveDisplay(void);
 
446
const char *displayName(struct display *);
 
447
 
 
448
/* in reset.c */
 
449
void pseudoReset(void);
 
450
 
 
451
/* in resource.c */
 
452
void **findCfgEnt(struct display *d, int id);
 
453
int initResources(char **argv);
 
454
int loadDMResources(int force);
 
455
int loadDisplayResources(struct display *d);
 
456
void scanServers(void);
 
457
void closeGetter(void);
 
458
int startConfig(int what, CfgDep *dep, int force);
 
459
RcStr *newStr(char *str);
 
460
void delStr(RcStr *str);
 
461
extern GTalk cnftalk;
 
462
 
 
463
/* in session.c */
 
464
extern struct display *td;
 
465
extern const char *td_setup;
 
466
char **baseEnv(char **env, const char *user);
 
467
char **inheritEnv(char **env, const char **what);
 
468
char **systemEnv(char **env, const char *user);
 
469
int source(char **env, const char *file, const char *arg);
 
470
void manageSession(void);
 
471
 
 
472
extern GTalk mstrtalk, grttalk;
 
473
extern GProc grtproc;
 
474
void openGreeter(void);
 
475
int closeGreeter(int force);
 
476
int ctrlGreeterWait(int wreply);
 
477
void prepareErrorGreet(void);
 
478
void finishGreet(void);
 
479
char *conv_interact(int what, const char *prompt);
 
480
 
 
481
/* process.c */
 
482
typedef void (*SIGFUNC)(int);
 
483
SIGFUNC Signal(int, SIGFUNC handler);
 
484
 
 
485
void registerInput(int fd);
 
486
void unregisterInput(int fd);
 
487
void registerCloseOnFork(int fd);
 
488
void clearCloseOnFork(int fd);
 
489
void closeNclearCloseOnFork(int fd);
 
490
int Fork(volatile int *pid);
 
491
int Wait4(volatile int *pid);
 
492
void execute(char **argv, char **env);
 
493
int runAndWait(char **args, char **env);
 
494
FILE *pOpen(char **what, char m, volatile int *pid);
 
495
int pClose(FILE *f, volatile int *pid);
 
496
char *locate(const char *exe);
 
497
void terminateProcess(int pid, int sig);
 
498
void blockTerm(void);
 
499
void unblockTerm(void);
 
500
 
 
501
void gSet(GTalk *talk); /* call before gOpen! */
 
502
void gCloseOnExec(GPipe *pajp);
 
503
int gFork(GPipe *pajp, const char *pname, char *cname,
 
504
          GPipe *ogp, char *cgname, GPipe *igp, volatile int *pid);
 
505
void gClosen(GPipe *pajp);
 
506
int gOpen(GProc *proc,
 
507
          char **argv, const char *what, char **env, char *cname,
 
508
          const char *user, const char *authfile, GPipe *igp);
 
509
int gClose(GProc *proc, GPipe *gp, int force);
 
510
 
 
511
void gSendInt(int val);
 
512
int gRecvInt(void);
 
513
int gRecvCmd(int *cmd);
 
514
void gSendArr(int len, const char *data);
 
515
char *gRecvArr(int *len);
 
516
int gRecvStrBuf(char *buf);
 
517
int gRecvArrBuf(char *buf);
 
518
void gSendStr(const char *buf);
 
519
void gSendNStr(const char *buf, int len); /* exact len, buf != 0 */
 
520
void gSendStrN(const char *buf, int len); /* maximal len */
 
521
char *gRecvStr(void);
 
522
void gSendArgv(char **argv);
 
523
void gSendStrArr(int len, char **data);
 
524
char **gRecvStrArr(int *len);
 
525
char **gRecvArgv(void);
 
526
 
 
527
/* client.c */
 
528
#define GCONV_NORMAL  0
 
529
#define GCONV_HIDDEN  1
 
530
#define GCONV_USER    2
 
531
#define GCONV_PASS    3
 
532
#define GCONV_PASS_ND 4
 
533
#define GCONV_BINARY  5
 
534
typedef char *(*GConvFunc)(int what, const char *prompt);
 
535
int verify(GConvFunc gconv, int rootok);
 
536
int startClient(volatile int *pid);
 
537
void clientExited(void);
 
538
void sessionExit(int status) ATTR_NORETURN;
 
539
int readDmrc(void);
 
540
int changeUser(const char *user, const char *authfile);
 
541
extern char **userEnviron, **systemEnviron;
 
542
extern char *curuser, *curpass, *curtype, *newpass,
 
543
            *dmrcuser, *curdmrc, *newdmrc;
 
544
extern int cursource;
 
545
#define PWSRC_MANUAL 0
 
546
#define PWSRC_AUTOLOGIN 1
 
547
#define PWSRC_RELOGIN 2
 
548
 
 
549
/* server.c */
 
550
char **prepareServerArgv(struct display *d, const char *args);
 
551
void startServer(struct display *d);
 
552
void abortStartServer(struct display *d);
 
553
void startServerSuccess(void);
 
554
void startServerFailed(void);
 
555
void startServerTimeout(void);
 
556
extern struct display *startingServer;
 
557
extern time_t serverTimeout;
 
558
 
 
559
void waitForServer(struct display *d);
 
560
void resetServer(struct display *d);
 
561
int pingServer(struct display *d);
 
562
extern struct _XDisplay *dpy;
 
563
 
 
564
/* in util.c */
 
565
void *Calloc(size_t nmemb, size_t size);
 
566
void *Malloc(size_t size);
 
567
void *Realloc(void *ptr, size_t size);
 
568
void wipeStr(char *str);
 
569
int strCmp(const char *s1, const char *s2);
 
570
#ifndef HAVE_STRNLEN
 
571
int strnlen(const char *s, int max);
 
572
#endif
 
573
int strNDup(char **dst, const char *src, int len);
 
574
int strDup(char **dst, const char *src);
 
575
int arrLen(char **arr);
 
576
void freeStrArr(char **arr);
 
577
char **initStrArr(char **arr);
 
578
char **xCopyStrArr(int rn, char **arr);
 
579
/* Note: the following functions free the old data even in case of failure */
 
580
int reStrN(char **dst, const char *src, int len);
 
581
int reStr(char **dst, const char *src);
 
582
int strApp(char **dst, ...);
 
583
char **addStrArr(char **arr, const char *str, int len);
 
584
char **parseArgs(char **argv, const char *string);
 
585
/* End note */
 
586
char **setEnv(char **e, const char *name, const char *value);
 
587
char **putEnv(const char *string, char **env);
 
588
const char *getEnv(char **e, const char *name);
 
589
const char *localHostname(void);
 
590
int reader(int fd, void *buf, int len);
 
591
int writer(int fd, const void *buf, int len);
 
592
int fGets(char *buf, int max, FILE *f);
 
593
time_t mTime(const char *fn);
 
594
void randomStr(char *s);
 
595
int hexToBinary(char *out, const char *in);
 
596
void listSessions(int flags, struct display *d, void *ctx,
 
597
                  void (*emitXSess)(struct display *, struct display *, void *),
 
598
                  void (*emitTTYSess)(STRUCTUTMP *, struct display *, void *));
 
599
int anyUserLogins(int exclude_uid);
 
600
 
 
601
struct expando {
 
602
    char key;
 
603
    int uses;
 
604
    const char *val;
 
605
};
 
606
char *expandMacros(const char *str, struct expando *expandos);
 
607
 
 
608
/* in inifile.c */
 
609
char *iniLoad(const char *fname);
 
610
int iniSave(const char *data, const char *fname);
 
611
char *iniEntry(char *data, const char *section, const char *key, const char *value);
 
612
char *iniMerge(char *data, const char *newdata);
 
613
 
 
614
/* in bootman.c */
 
615
int getBootOptions(char ***opts, int *def, int *cur);
 
616
int setBootOption(const char *opt, SdRec *sdr);
 
617
void commitBootOption(void);
 
618
 
 
619
/* in netaddr.c */
 
620
CARD8 *netaddrAddress(char *netaddrp, int *lenp);
 
621
CARD8 *netaddrPort(char *netaddrp, int *lenp);
 
622
int convertAddr(char *saddr, int *len, CARD8 **addr);
 
623
int netaddrFamily(char *netaddrp);
 
624
int addressEqual(char *a1, int len1, char *a2, int len2);
 
625
 
 
626
#ifdef XDMCP
 
627
 
 
628
/* in xdmcp.c */
 
629
char *networkAddressToHostname(CARD16 connectionType, ARRAY8Ptr connectionAddress);
 
630
void sendFailed(struct display *d, const char *reason);
 
631
void initXdmcp(void);
 
632
 
 
633
/* in policy.c */
 
634
struct sockaddr;
 
635
ARRAY8Ptr isAccepting(struct sockaddr *from, int fromlen, CARD16 displayNumber);
 
636
ARRAY8Ptr chooseAuthentication(ARRAYofARRAY8Ptr authenticationNames);
 
637
int checkAuthentication(struct protoDisplay *pdpy, ARRAY8Ptr displayID, ARRAY8Ptr name, ARRAY8Ptr data);
 
638
int selectAuthorizationTypeIndex(ARRAY8Ptr authenticationName, ARRAYofARRAY8Ptr authorizationNames);
 
639
int selectConnectionTypeIndex(ARRAY16Ptr connectionTypes, ARRAYofARRAY8Ptr connectionAddresses);
 
640
int isWilling(ARRAY8Ptr addr, CARD16 connectionType, ARRAY8Ptr authenticationName, ARRAY8Ptr status, xdmOpCode type);
 
641
 
 
642
/* in protodpy.c */
 
643
void disposeProtoDisplay(struct protoDisplay *pdpy);
 
644
 
 
645
struct protoDisplay *findProtoDisplay(XdmcpNetaddr address, int addrlen,
 
646
                                      CARD16 displayNumber);
 
647
struct protoDisplay *newProtoDisplay(XdmcpNetaddr address, int addrlen,
 
648
                                     CARD16 displayNumber,
 
649
                                     CARD16 connectionType,
 
650
                                     ARRAY8Ptr connectionAddress,
 
651
                                     CARD32 sessionID);
 
652
 
 
653
#define FamilyBroadcast 0xffff
 
654
typedef void (*ChooserFunc)(CARD16 connectionType, ARRAY8Ptr addr, char *closure);
 
655
typedef void (*ListenFunc)(ARRAY8Ptr addr, void **closure);
 
656
 
 
657
/* in access.c */
 
658
ARRAY8Ptr getLocalAddress(void);
 
659
int acceptableDisplayAddress(ARRAY8Ptr clientAddress, CARD16 connectionType, xdmOpCode type);
 
660
int forEachMatchingIndirectHost(ARRAY8Ptr clientAddress, ARRAY8Ptr clientPort, CARD16 connectionType,
 
661
                                ChooserFunc function, char *closure);
 
662
void scanAccessDatabase(int force);
 
663
int useChooser(ARRAY8Ptr clientAddress, CARD16 connectionType);
 
664
void forEachChooserHost(ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure);
 
665
void forEachListenAddr(ListenFunc listenfunction, ListenFunc mcastfcuntion, void **closure);
 
666
 
 
667
/* in choose.c */
 
668
time_t disposeIndirectHosts(void);
 
669
ARRAY8Ptr indirectChoice(ARRAY8Ptr clientAddress, ARRAY8Ptr clientPort, CARD16 connectionType);
 
670
int checkIndirectChoice(ARRAY8Ptr clientAddress, ARRAY8Ptr clientPort, CARD16 connectionType);
 
671
void registerIndirectChoice(ARRAY8Ptr clientAddress, ARRAY8Ptr clientPort, CARD16 connectionType,
 
672
                            ARRAY8Ptr choice);
 
673
int doChoose(void);
 
674
 
 
675
/* socket.c or streams.c */
 
676
void updateListenSockets(void);
 
677
int anyListenSockets(void);
 
678
int processListenSockets(fd_set *reads);
 
679
 
 
680
/* in xdmcp.c */
 
681
void processRequestSocket(int fd);
 
682
 
 
683
#endif /* XDMCP */
 
684
 
 
685
/* in sessreg.c */
 
686
void sessreg(struct display *d, int pid, const char *user, int uid);
 
687
 
 
688
#endif /* _DM_H_ */