greet.h revision 629baa8c
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__) || defined(__osf__)
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, char *name, char *value);
69    char **(*_putEnv)(const char *string, char **env);
70    char **(*_parseArgs)(char **argv, 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# ifndef QNX4
80    void (*_endspent)(void);
81# endif /* QNX4 doesn't use endspent */
82#endif
83    struct passwd *(*_getpwnam)(GETPWNAM_ARGS);
84#if defined(linux) || defined(__GLIBC__)
85    void (*_endpwent)(void);
86#endif
87    char *(*_crypt)(CRYPT_ARGS);
88#ifdef USE_PAM
89    pam_handle_t **(*_thepamhp)(void);
90#endif
91};
92
93/*
94 * Return values for GreetUser();
95 * Values must be explictly defined because the greet library
96 * may come from a different vendor.
97 * Negative values indicate an error.
98 */
99typedef enum {
100    Greet_Session_Over = 0,	/* session managed and over */
101    Greet_Success = 1,		/* greet succeeded, session not managed */
102    Greet_Failure = -1		/* greet failed */
103} greet_user_rtn;
104
105/*
106 * GreetUser can either handle the user's session or allow xdm to do it.
107 * The return or exit status of GreetUser indicates to xdm whether it
108 * should start a session.
109 *
110 * GreetUser is passed the xdm struct display pointer, a pointer to a
111 * Display, and pointers to greet and verify structs.  If it expectes xdm
112 * to run the session, it fills in the Display pointer and the fields
113 * of the greet and verify structs.
114 *
115 * The verify struct includes the uid, gid, arguments to run the session,
116 * environment for the session, and environment for startup/reset.
117 *
118 * The greet struct includes the user's name and password but these are
119 * really only needed if xdm is compiled with a user-based authorization
120 * option such as SECURE_RPC or K5AUTH.
121 */
122
123extern greet_user_rtn GreetUser(struct display *, Display **,
124    struct verify_info *, struct greet_info *, struct dlfuncs *);
125
126typedef greet_user_rtn (*GreetUserProc)(struct display *, Display **,
127    struct verify_info *, struct greet_info *, struct dlfuncs *dlfcns);
128
129#ifdef GREET_LIB
130/*
131 * The greeter uses some symbols from the main xdm executable.  Since some
132 * dynamic linkers are broken, we need to fix things up so that the symbols
133 * are referenced indirectly through function pointers.  The definitions
134 * here, are used to hold the pointers to the functions in the main xdm
135 * executable.  The pointers are filled in when the GreetUser function is
136 * called, with the pointer values passed as a paramter.
137 */
138
139extern	int     (*__xdm_PingServer)(struct display *d, Display *alternateDpy);
140extern	void    (*__xdm_SessionPingFailed)(struct display *d);
141extern	void    (*__xdm_Debug)(const char * fmt, ...);
142extern	void    (*__xdm_RegisterCloseOnFork)(int fd);
143extern	void    (*__xdm_SecureDisplay)(struct display *d, Display *dpy);
144extern	void    (*__xdm_UnsecureDisplay)(struct display *d, Display *dpy);
145extern	void    (*__xdm_ClearCloseOnFork)(int fd);
146extern	void    (*__xdm_SetupDisplay)(struct display *d);
147extern	void    (*__xdm_LogError)(const char * fmt, ...);
148extern	void    (*__xdm_SessionExit)(struct display *d, int status, int removeAuth);
149extern	void    (*__xdm_DeleteXloginResources)(struct display *d, Display *dpy);
150extern	int     (*__xdm_source)(char **environ, char *file);
151extern	char    **(*__xdm_defaultEnv)(void);
152extern	char    **(*__xdm_setEnv)(char **e, char *name, char *value);
153extern	char    **(*__xdm_putEnv)(const char *string, char **env);
154extern	char    **(*__xdm_parseArgs)(char **argv, char *string);
155extern	void    (*__xdm_printEnv)(char **e);
156extern	char    **(*__xdm_systemEnv)(struct display *d, char *user, char *home);
157extern	void    (*__xdm_LogOutOfMem)(const char * fmt, ...);
158extern	void    (*__xdm_setgrent)(void);
159extern	struct group    *(*__xdm_getgrent)(void);
160extern	void    (*__xdm_endgrent)(void);
161# ifdef HAVE_GETSPNAM
162extern	struct spwd   *(*__xdm_getspnam)(GETSPNAM_ARGS);
163#  ifndef QNX4
164extern	void    (*__xdm_endspent)(void);
165#  endif /* QNX4 doesn't use endspent */
166# endif
167extern	struct passwd   *(*__xdm_getpwnam)(GETPWNAM_ARGS);
168# if defined(linux) || defined(__GLIBC__)
169extern  void    (*__xdm_endpwent)(void);
170# endif
171extern	char    *(*__xdm_crypt)(CRYPT_ARGS);
172# ifdef USE_PAM
173extern  pam_handle_t    **(*__xdm_thepamhp)(void);
174# endif
175
176/*
177 * Force the shared library to call through the function pointer
178 * initialized during the initial call into the library.
179 */
180
181# define	PingServer		(*__xdm_PingServer)
182# define	SessionPingFailed	(*__xdm_SessionPingFailed)
183# define	Debug			(*__xdm_Debug)
184# define	RegisterCloseOnFork	(*__xdm_RegisterCloseOnFork)
185# define	SecureDisplay		(*__xdm_SecureDisplay)
186# define	UnsecureDisplay		(*__xdm_UnsecureDisplay)
187# define	ClearCloseOnFork	(*__xdm_ClearCloseOnFork)
188# define	SetupDisplay		(*__xdm_SetupDisplay)
189# define	LogError		(*__xdm_LogError)
190# define	SessionExit		(*__xdm_SessionExit)
191# define	DeleteXloginResources	(*__xdm_DeleteXloginResources)
192# define	source			(*__xdm_source)
193# define	defaultEnv		(*__xdm_defaultEnv)
194# define	setEnv			(*__xdm_setEnv)
195# define	putEnv			(*__xdm_putEnv)
196# define	parseArgs		(*__xdm_parseArgs)
197# define	printEnv		(*__xdm_printEnv)
198# define	systemEnv		(*__xdm_systemEnv)
199# define	LogOutOfMem		(*__xdm_LogOutOfMem)
200# define	setgrent		(*__xdm_setgrent)
201# define	getgrent		(*__xdm_getgrent)
202# define	endgrent		(*__xdm_endgrent)
203# ifdef HAVE_GETSPNAM
204#  define	getspnam		(*__xdm_getspnam)
205#  ifndef QNX4
206#   define	endspent		(*__xdm_endspent)
207#  endif /* QNX4 doesn't use endspent */
208# endif
209# define	getpwnam		(*__xdm_getpwnam)
210# if defined(linux) || defined(__GLIBC__)
211#  define	endpwent		(*__xdm_endpwent)
212# endif
213# define	crypt			(*__xdm_crypt)
214# ifdef USE_PAM
215#  define	thepamhp		(*__xdm_thepamhp)
216# endif
217
218#endif /* GREET_LIB */
219