diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2015-12-24 17:25:15 +0100 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2015-12-24 17:25:15 +0100 |
commit | cec06325ba15fc490a5df2d215fc80030534cf07 (patch) | |
tree | 5bf538bf45d040f3a614bc4dcadfc89411974302 /include |
Start of a new reduced version of xdm.
Removed support for non BSD systems and for XDMCP.
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 6 | ||||
-rw-r--r-- | include/dm.h | 403 | ||||
-rw-r--r-- | include/dm_auth.h | 99 | ||||
-rw-r--r-- | include/dm_error.h | 46 | ||||
-rw-r--r-- | include/dm_socket.h | 45 | ||||
-rw-r--r-- | include/greet.h | 207 |
6 files changed, 806 insertions, 0 deletions
diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..88ed7b6 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,6 @@ +noinst_HEADERS = \ + dm.h \ + dm_auth.h \ + dm_error.h \ + dm_socket.h \ + greet.h diff --git a/include/dm.h b/include/dm.h new file mode 100644 index 0000000..e038e08 --- /dev/null +++ b/include/dm.h @@ -0,0 +1,403 @@ +/* + +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> + +# if defined(X_POSIX_C_SOURCE) +# define _POSIX_C_SOURCE X_POSIX_C_SOURCE +# include <setjmp.h> +# include <limits.h> +# undef _POSIX_C_SOURCE +# else +# include <setjmp.h> +# include <limits.h> +# endif +# 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 pingInterval; /* interval between XSync */ + int pingTimeout; /* timeout for XSync */ + 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 PingServer(struct display *d, Display *alternateDpy); +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 xdmcp.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 + +# if defined(X_NOT_POSIX) || defined(__UNIXOS2__) || defined(__NetBSD__) && defined(__sparc__) +# if defined(SYSV) || defined(__UNIXOS2__) +# define SIGNALS_RESET_WHEN_CAUGHT +# define UNRELIABLE_SIGNALS +# endif +# define Setjmp(e) setjmp(e) +# define Longjmp(e,v) longjmp(e,v) +# define Jmp_buf jmp_buf +# else +# define Setjmp(e) sigsetjmp(e,1) +# define Longjmp(e,v) siglongjmp(e,v) +# define Jmp_buf sigjmp_buf +# endif + +typedef SIGVAL (*SIGFUNC)(int); + +SIGVAL (*Signal(int, SIGFUNC Handler))(int); + +#endif /* _DM_H_ */ diff --git a/include/dm_auth.h b/include/dm_auth.h new file mode 100644 index 0000000..d475f77 --- /dev/null +++ b/include/dm_auth.h @@ -0,0 +1,99 @@ +/************************************************************ + +Copyright 1998 by Thomas E. Dickey <dickey@clark.net> + + All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright +holders shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization. + +********************************************************/ + +#ifndef _DM_AUTH_H_ +# define _DM_AUTH_H_ 1 + +# include "dm.h" /* for struct display */ + +extern void MitInitAuth (unsigned short name_len, char *name); +extern Xauth *MitGetAuth (unsigned short namelen, char *name); + +# ifdef HASXDMAUTH +extern void XdmInitAuth (unsigned short name_len, char *name); +extern Xauth *XdmGetAuth (unsigned short namelen, char *name); +# ifdef XDMCP +extern void XdmGetXdmcpAuth ( + struct protoDisplay *pdpy, + unsigned short authorizationNameLen, + char *authorizationName); +extern int XdmCheckAuthentication (struct protoDisplay *pdpy, + ARRAY8Ptr displayID, ARRAY8Ptr authenticationName, + ARRAY8Ptr authenticationData); +# else +# define XdmGetXdmcpAuth NULL +# endif +# endif + +# ifdef SECURE_RPC +extern void SecureRPCInitAuth (unsigned short name_len, char *name); +extern Xauth *SecureRPCGetAuth (unsigned short namelen, char *name); +# endif + +# ifdef K5AUTH +extern void Krb5InitAuth (unsigned short name_len, char *name); +extern Xauth *Krb5GetAuth (unsigned short namelen, char *name); +# endif + +/* auth.c */ +extern int ValidAuthorization (unsigned short name_length, char *name); + + +# ifdef XDMCP + +extern void +SetProtoDisplayAuthorization ( + struct protoDisplay *pdpy, + unsigned short authorizationNameLen, + char *authorizationName); + +# endif /* XDMCP */ + +extern int SaveServerAuthorizations (struct display *d, Xauth **auths, int count); +extern void CleanUpFileName (char *src, char *dst, int len); +extern void RemoveUserAuthorization (struct display *d, struct verify_info *verify); +extern void SetAuthorization (struct display *d); +extern void SetLocalAuthorization (struct display *d); +extern void SetUserAuthorization (struct display *d, struct verify_info *verify); + +/* genauth.c */ +extern int GenerateAuthData (char *auth, int len); +# if !defined(HAVE_ARC4RANDOM) +extern void AddPreGetEntropy (void); +extern void AddOtherEntropy (void); +extern void AddTimerEntropy (void); +# endif + +/* prngc.c */ +extern int get_prngd_bytes(char *, int, unsigned short, char *); + +#endif /* _DM_AUTH_H_ */ diff --git a/include/dm_error.h b/include/dm_error.h new file mode 100644 index 0000000..e8a92ef --- /dev/null +++ b/include/dm_error.h @@ -0,0 +1,46 @@ +/************************************************************ + +Copyright 1998 by Thomas E. Dickey <dickey@clark.net> + + All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright +holders shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization. + +********************************************************/ + + +#ifndef _DM_ERROR_H_ +# define _DM_ERROR_H_ 1 + +extern void Debug (const char * fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); +extern void InitErrorLog (void); +extern void LogAppend (const char * fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); +extern void LogError (const char * fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); +extern void LogInfo (const char * fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); +extern void LogOutOfMem (const char * fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); +extern void LogPanic (const char * fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); + + +#endif /* _DM_ERROR_H_ */ diff --git a/include/dm_socket.h b/include/dm_socket.h new file mode 100644 index 0000000..f04517a --- /dev/null +++ b/include/dm_socket.h @@ -0,0 +1,45 @@ +/************************************************************ + +Copyright 1998 by Thomas E. Dickey <dickey@clark.net> + + All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright +holders shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization. + +********************************************************/ + +#ifndef _DM_SOCKET_H_ +# define _DM_SOCKET_H_ 1 + +# include <X11/Xmd.h> +# include <X11/Xdmcp.h> + +# include <sys/socket.h> +# include <netinet/in.h> + +/* ugly, but we need this after socket.h */ +extern ARRAY8Ptr Accept (struct sockaddr *from, int fromlen, CARD16 displayNumber); + +#endif /* _DM_SOCKET_H_ */ diff --git a/include/greet.h b/include/greet.h new file mode 100644 index 0000000..81f4537 --- /dev/null +++ b/include/greet.h @@ -0,0 +1,207 @@ +/* + +Copyright 1994, 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. + +*/ + +/* + * greet.h - interface to xdm's dynamically-loadable modular greeter + */ +#include <pwd.h> +#include <X11/Xlib.h> + +/* + * Do this rather than break a build over a const-mismatch + */ +#if defined(__linux__) || defined(CSRG_BASED) || (defined(sun) && defined(SVR4)) +# define CRYPT_ARGS const char *s1, const char *s2 +# define GETSPNAM_ARGS const char *name +# define GETPWNAM_ARGS const char *name +#else +# define CRYPT_ARGS /*unknown*/ +# define GETSPNAM_ARGS /*unknown*/ +# define GETPWNAM_ARGS /*unknown*/ +#endif + +#if defined(__FreeBSD__) || defined(__bsdi__) || defined(__osf__) +# define SETGRENT_TYPE int +#else +# define SETGRENT_TYPE void +#endif + +struct dlfuncs { + int (*_PingServer)(struct display *d, Display *alternateDpy); + void (*_SessionPingFailed)(struct display *d); + void (*_Debug)(const char * fmt, ...); + void (*_RegisterCloseOnFork)(int fd); + void (*_SecureDisplay)(struct display *d, Display *dpy); + void (*_UnsecureDisplay)(struct display *d, Display *dpy); + void (*_ClearCloseOnFork)(int fd); + void (*_SetupDisplay)(struct display *d); + void (*_LogError)(const char * fmt, ...); + void (*_SessionExit)(struct display *d, int status, int removeAuth); + void (*_DeleteXloginResources)(struct display *d, Display *dpy); + int (*_source)(char **environ, char *file); + char **(*_defaultEnv)(void); + char **(*_setEnv)(char **e, const char *name, const char *value); + char **(*_putEnv)(const char *string, char **env); + char **(*_parseArgs)(char **argv, const char *string); + void (*_printEnv)(char **e); + char **(*_systemEnv)(struct display *d, char *user, char *home); + void (*_LogOutOfMem)(const char * fmt, ...); + SETGRENT_TYPE (*_setgrent)(void); /* no longer used */ + struct group *(*_getgrent)(void); /* no longer used */ + void (*_endgrent)(void); /* no longer used */ + struct passwd *(*_getpwnam)(GETPWNAM_ARGS); + void (*_endpwent)(void); + char *(*_crypt)(CRYPT_ARGS); +}; + +/* + * Return values for GreetUser(); + * Values must be explictly defined because the greet library + * may come from a different vendor. + * Negative values indicate an error. + */ +typedef enum { + Greet_Session_Over = 0, /* session managed and over */ + Greet_Success = 1, /* greet succeeded, session not managed */ + Greet_Failure = -1 /* greet failed */ +} greet_user_rtn; + +/* + * GreetUser can either handle the user's session or allow xdm to do it. + * The return or exit status of GreetUser indicates to xdm whether it + * should start a session. + * + * GreetUser is passed the xdm struct display pointer, a pointer to a + * Display, and pointers to greet and verify structs. If it expectes xdm + * to run the session, it fills in the Display pointer and the fields + * of the greet and verify structs. + * + * The verify struct includes the uid, gid, arguments to run the session, + * environment for the session, and environment for startup/reset. + * + * The greet struct includes the user's name and password but these are + * really only needed if xdm is compiled with a user-based authorization + * option such as SECURE_RPC or K5AUTH. + */ + +extern greet_user_rtn GreetUser(struct display *, Display **, + struct verify_info *, struct greet_info *, struct dlfuncs *); + +typedef greet_user_rtn (*GreetUserProc)(struct display *, Display **, + struct verify_info *, struct greet_info *, struct dlfuncs *dlfcns); + +#ifdef GREET_LIB +/* + * The greeter uses some symbols from the main xdm executable. Since some + * dynamic linkers are broken, we need to fix things up so that the symbols + * are referenced indirectly through function pointers. The definitions + * here, are used to hold the pointers to the functions in the main xdm + * executable. The pointers are filled in when the GreetUser function is + * called, with the pointer values passed as a paramter. + */ + +extern int (*__xdm_PingServer)(struct display *d, Display *alternateDpy); +extern void (*__xdm_SessionPingFailed)(struct display *d); +extern void (*__xdm_Debug)(const char * fmt, ...); +extern void (*__xdm_RegisterCloseOnFork)(int fd); +extern void (*__xdm_SecureDisplay)(struct display *d, Display *dpy); +extern void (*__xdm_UnsecureDisplay)(struct display *d, Display *dpy); +extern void (*__xdm_ClearCloseOnFork)(int fd); +extern void (*__xdm_SetupDisplay)(struct display *d); +extern void (*__xdm_LogError)(const char * fmt, ...); +extern void (*__xdm_SessionExit)(struct display *d, int status, int removeAuth); +extern void (*__xdm_DeleteXloginResources)(struct display *d, Display *dpy); +extern int (*__xdm_source)(char **environ, char *file); +extern char **(*__xdm_defaultEnv)(void); +extern char **(*__xdm_setEnv)(char **e, const char *name, const char *value); +extern char **(*__xdm_putEnv)(const char *string, char **env); +extern char **(*__xdm_parseArgs)(char **argv, const char *string); +extern void (*__xdm_printEnv)(char **e); +extern char **(*__xdm_systemEnv)(struct display *d, char *user, char *home); +extern void (*__xdm_LogOutOfMem)(const char * fmt, ...); +extern void (*__xdm_setgrent)(void); +extern struct group *(*__xdm_getgrent)(void); +extern void (*__xdm_endgrent)(void); +# ifdef HAVE_GETSPNAM +extern struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS); +# ifndef QNX4 +extern void (*__xdm_endspent)(void); +# endif /* QNX4 doesn't use endspent */ +# endif +extern struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS); +# if defined(linux) || defined(__GLIBC__) +extern void (*__xdm_endpwent)(void); +# endif +extern char *(*__xdm_crypt)(CRYPT_ARGS); +# ifdef USE_PAM +extern pam_handle_t **(*__xdm_thepamhp)(void); +# endif + +/* + * Force the shared library to call through the function pointer + * initialized during the initial call into the library. + */ + +# define PingServer (*__xdm_PingServer) +# define SessionPingFailed (*__xdm_SessionPingFailed) +# define Debug (*__xdm_Debug) +# define RegisterCloseOnFork (*__xdm_RegisterCloseOnFork) +# define SecureDisplay (*__xdm_SecureDisplay) +# define UnsecureDisplay (*__xdm_UnsecureDisplay) +# define ClearCloseOnFork (*__xdm_ClearCloseOnFork) +# define SetupDisplay (*__xdm_SetupDisplay) +# define LogError (*__xdm_LogError) +# define SessionExit (*__xdm_SessionExit) +# define DeleteXloginResources (*__xdm_DeleteXloginResources) +# define source (*__xdm_source) +# define defaultEnv (*__xdm_defaultEnv) +# define setEnv (*__xdm_setEnv) +# define putEnv (*__xdm_putEnv) +# define parseArgs (*__xdm_parseArgs) +# define printEnv (*__xdm_printEnv) +# define systemEnv (*__xdm_systemEnv) +# define LogOutOfMem (*__xdm_LogOutOfMem) +# define setgrent (*__xdm_setgrent) +# define getgrent (*__xdm_getgrent) +# define endgrent (*__xdm_endgrent) +# ifdef HAVE_GETSPNAM +# define getspnam (*__xdm_getspnam) +# ifndef QNX4 +# define endspent (*__xdm_endspent) +# endif /* QNX4 doesn't use endspent */ +# endif +# define getpwnam (*__xdm_getpwnam) +# if defined(linux) || defined(__GLIBC__) +# define endpwent (*__xdm_endpwent) +# endif +# define crypt (*__xdm_crypt) +# ifdef USE_PAM +# define thepamhp (*__xdm_thepamhp) +# endif + +#endif /* GREET_LIB */ |