greet.h revision 4901b09e
1/* 2 3Copyright 1994, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included 12in all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall 23not be used in advertising or otherwise to promote the sale, use or 24other dealings in this Software without prior written authorization 25from The Open Group. 26 27*/ 28 29/* 30 * greet.h - interface to xdm's dynamically-loadable modular greeter 31 */ 32#include <pwd.h> 33#include <X11/Xlib.h> 34 35/* 36 * Do this rather than break a build over a const-mismatch 37 */ 38#if defined(__linux__) || defined(CSRG_BASED) || (defined(sun) && defined(SVR4)) 39# define CRYPT_ARGS const char *s1, const char *s2 40# define GETSPNAM_ARGS const char *name 41# define GETPWNAM_ARGS const char *name 42#else 43# define CRYPT_ARGS /*unknown*/ 44# define GETSPNAM_ARGS /*unknown*/ 45# define GETPWNAM_ARGS /*unknown*/ 46#endif 47 48#if defined(__FreeBSD__) || defined(__bsdi__) 49# define SETGRENT_TYPE int 50#else 51# define SETGRENT_TYPE void 52#endif 53 54struct dlfuncs { 55 int (*_PingServer)(struct display *d, Display *alternateDpy); 56 void (*_SessionPingFailed)(struct display *d); 57 void (*_Debug)(const char * fmt, ...); 58 void (*_RegisterCloseOnFork)(int fd); 59 void (*_SecureDisplay)(struct display *d, Display *dpy); 60 void (*_UnsecureDisplay)(struct display *d, Display *dpy); 61 void (*_ClearCloseOnFork)(int fd); 62 void (*_SetupDisplay)(struct display *d); 63 void (*_LogError)(const char * fmt, ...); 64 void (*_SessionExit)(struct display *d, int status, int removeAuth); 65 void (*_DeleteXloginResources)(struct display *d, Display *dpy); 66 int (*_source)(char **environ, char *file); 67 char **(*_defaultEnv)(void); 68 char **(*_setEnv)(char **e, const char *name, const char *value); 69 char **(*_putEnv)(const char *string, char **env); 70 char **(*_parseArgs)(char **argv, const char *string); 71 void (*_printEnv)(char **e); 72 char **(*_systemEnv)(struct display *d, char *user, char *home); 73 void (*_LogOutOfMem)(const char * fmt, ...); 74 SETGRENT_TYPE (*_setgrent)(void); /* no longer used */ 75 struct group *(*_getgrent)(void); /* no longer used */ 76 void (*_endgrent)(void); /* no longer used */ 77#ifdef HAVE_GETSPNAM 78 struct spwd *(*_getspnam)(GETSPNAM_ARGS); 79 void (*_endspent)(void); 80#endif 81 struct passwd *(*_getpwnam)(GETPWNAM_ARGS); 82#if defined(linux) || defined(__GLIBC__) 83 void (*_endpwent)(void); 84#endif 85 char *(*_crypt)(CRYPT_ARGS); 86#ifdef USE_PAM 87 pam_handle_t **(*_thepamhp)(void); 88#endif 89}; 90 91/* 92 * Return values for GreetUser(); 93 * Values must be explicitly defined because the greet library 94 * may come from a different vendor. 95 * Negative values indicate an error. 96 */ 97typedef enum { 98 Greet_Session_Over = 0, /* session managed and over */ 99 Greet_Success = 1, /* greet succeeded, session not managed */ 100 Greet_Failure = -1 /* greet failed */ 101} greet_user_rtn; 102 103/* 104 * GreetUser can either handle the user's session or allow xdm to do it. 105 * The return or exit status of GreetUser indicates to xdm whether it 106 * should start a session. 107 * 108 * GreetUser is passed the xdm struct display pointer, a pointer to a 109 * Display, and pointers to greet and verify structs. If it expects xdm 110 * to run the session, it fills in the Display pointer and the fields 111 * of the greet and verify structs. 112 * 113 * The verify struct includes the uid, gid, arguments to run the session, 114 * environment for the session, and environment for startup/reset. 115 * 116 * The greet struct includes the user's name and password but these are 117 * really only needed if xdm is compiled with a user-based authorization 118 * option such as SECURE_RPC or K5AUTH. 119 */ 120 121extern greet_user_rtn GreetUser(struct display *, Display **, 122 struct verify_info *, struct greet_info *, struct dlfuncs *); 123 124typedef greet_user_rtn (*GreetUserProc)(struct display *, Display **, 125 struct verify_info *, struct greet_info *, struct dlfuncs *dlfcns); 126 127#ifdef GREET_LIB 128/* 129 * The greeter uses some symbols from the main xdm executable. Since some 130 * dynamic linkers are broken, we need to fix things up so that the symbols 131 * are referenced indirectly through function pointers. The definitions 132 * here, are used to hold the pointers to the functions in the main xdm 133 * executable. The pointers are filled in when the GreetUser function is 134 * called, with the pointer values passed as a parameter. 135 */ 136 137extern int (*__xdm_PingServer)(struct display *d, Display *alternateDpy); 138extern void (*__xdm_SessionPingFailed)(struct display *d); 139extern void (*__xdm_Debug)(const char * fmt, ...); 140extern void (*__xdm_RegisterCloseOnFork)(int fd); 141extern void (*__xdm_SecureDisplay)(struct display *d, Display *dpy); 142extern void (*__xdm_UnsecureDisplay)(struct display *d, Display *dpy); 143extern void (*__xdm_ClearCloseOnFork)(int fd); 144extern void (*__xdm_SetupDisplay)(struct display *d); 145extern void (*__xdm_LogError)(const char * fmt, ...); 146extern void (*__xdm_SessionExit)(struct display *d, int status, int removeAuth); 147extern void (*__xdm_DeleteXloginResources)(struct display *d, Display *dpy); 148extern int (*__xdm_source)(char **environ, char *file); 149extern char **(*__xdm_defaultEnv)(void); 150extern char **(*__xdm_setEnv)(char **e, const char *name, const char *value); 151extern char **(*__xdm_putEnv)(const char *string, char **env); 152extern char **(*__xdm_parseArgs)(char **argv, const char *string); 153extern void (*__xdm_printEnv)(char **e); 154extern char **(*__xdm_systemEnv)(struct display *d, char *user, char *home); 155extern void (*__xdm_LogOutOfMem)(const char * fmt, ...); 156extern void (*__xdm_setgrent)(void); 157extern struct group *(*__xdm_getgrent)(void); 158extern void (*__xdm_endgrent)(void); 159# ifdef HAVE_GETSPNAM 160extern struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS); 161extern void (*__xdm_endspent)(void); 162# endif 163extern struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS); 164# if defined(linux) || defined(__GLIBC__) 165extern void (*__xdm_endpwent)(void); 166# endif 167extern char *(*__xdm_crypt)(CRYPT_ARGS); 168# ifdef USE_PAM 169extern pam_handle_t **(*__xdm_thepamhp)(void); 170# endif 171 172/* 173 * Force the shared library to call through the function pointer 174 * initialized during the initial call into the library. 175 */ 176 177# define PingServer (*__xdm_PingServer) 178# define SessionPingFailed (*__xdm_SessionPingFailed) 179# define Debug (*__xdm_Debug) 180# define RegisterCloseOnFork (*__xdm_RegisterCloseOnFork) 181# define SecureDisplay (*__xdm_SecureDisplay) 182# define UnsecureDisplay (*__xdm_UnsecureDisplay) 183# define ClearCloseOnFork (*__xdm_ClearCloseOnFork) 184# define SetupDisplay (*__xdm_SetupDisplay) 185# define LogError (*__xdm_LogError) 186# define SessionExit (*__xdm_SessionExit) 187# define DeleteXloginResources (*__xdm_DeleteXloginResources) 188# define source (*__xdm_source) 189# define defaultEnv (*__xdm_defaultEnv) 190# define setEnv (*__xdm_setEnv) 191# define putEnv (*__xdm_putEnv) 192# define parseArgs (*__xdm_parseArgs) 193# define printEnv (*__xdm_printEnv) 194# define systemEnv (*__xdm_systemEnv) 195# define LogOutOfMem (*__xdm_LogOutOfMem) 196# define setgrent (*__xdm_setgrent) 197# define getgrent (*__xdm_getgrent) 198# define endgrent (*__xdm_endgrent) 199# ifdef HAVE_GETSPNAM 200# define getspnam (*__xdm_getspnam) 201# define endspent (*__xdm_endspent) 202# endif 203# define getpwnam (*__xdm_getpwnam) 204# if defined(linux) || defined(__GLIBC__) 205# define endpwent (*__xdm_endpwent) 206# endif 207# define crypt (*__xdm_crypt) 208# ifdef USE_PAM 209# define thepamhp (*__xdm_thepamhp) 210# endif 211 212#endif /* GREET_LIB */ 213