dtlogin.c revision 781
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White/* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * Permission is hereby granted, free of charge, to any person obtaining a
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * copy of this software and associated documentation files (the
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * "Software"), to deal in the Software without restriction, including
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * without limitation the rights to use, copy, modify, merge, publish,
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * distribute, and/or sell copies of the Software, and to permit persons
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * to whom the Software is furnished to do so, provided that the above
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * copyright notice(s) and this permission notice appear in all copies of
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * the Software and that both the above copyright notice(s) and this
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * permission notice appear in supporting documentation.
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * Except as contained in this notice, the name of a copyright holder
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * shall not be used in advertising or otherwise to promote the sale, use
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * or other dealings in this Software without prior written authorization
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * of the copyright holder.
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White#pragma ident "@(#)dtlogin.c 1.20 09/09/11 SMI"
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White/* Implementation of Display Manager (dtlogin/gdm/xdm/etc.) to X server
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * communication pipe. The Display Manager process will start
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * the X window server at system boot time before any user
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * has logged into the system. The X server is by default
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * started as the root UID "0".
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * At login time the Xserver local communication pipe is provided
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * by the Xserver for user specific configuration data supplied
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * by the display manager. It notifies the Xserver it needs to change
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * over to the user's credentials (UID, GID, GID_LIST) and
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * also switch CWD (current working directory) of to match
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński * the user's CWD home.
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński * When shutting down, the Xserver restores it's original uid/gid as
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński * needed by the cleanup/teardown actions in several drivers.
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White * For the original definition, see Sun ASARC case 1995/390
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whiteextern const char *GetAuthFilename(void);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White/* Data about the user we need to switch to */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White gid_t groupids[NGROUPS_UMAX]; /* Supplementary groups */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White/* Data passed to block/wakeup handlers */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White char * buf; /* contains characters to be processed */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White struct dmuser user; /* target user, to switch to on login */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White/* Data stored in screen privates */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitestatic DevPrivateKey dmScreenKey = &dmScreenKeyIndex;
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitestatic struct dmuser originalUser; /* user to switch back to in CloseDown */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitestatic Bool DtloginCloseScreen(int i, ScreenPtr pScreen);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitestatic void DtloginBlockHandler(pointer, struct timeval **, pointer);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitestatic void DtloginWakeupHandler(pointer, int, pointer);
_X_HIDDEN void
DtloginInit(void)
int displayNumber = 0;
if (getuid() != 0) return;
sizeof(struct dmdata));
_X_HIDDEN void
DtloginCloseDown(void)
if (seteuid(0) < 0) {
static Bool
return pipeFD;
int done = 0;
while (!done) {
if (done) {
if (p == NULL) {
if (p == NULL) {
int val;
errno = 0;
if (auth_file) {