dtlogin.c revision 98
/* Copyright 2007 Sun Microsystems, Inc. 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,
* to whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* 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
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
* INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* of the copyright holder.
*/
#pragma ident "@(#)dtlogin.c 1.17 07/01/31 SMI"
/* Implementation of DTLogin to Xsun communication pipe.
* The Solaris Desktop Login process (dtlogin) will start
* the X window server at system boot time before any user
* has logged into the system. The X server is by default
* started as the root UID "0".
* At login time the Xserver local communication pipe is provided
* by Xsun for user specific configuration data supplied
* by DTLogin. It notifies the Xserver it needs to change
* over to the user's credentials (UID, GID, GID_LIST) and
* also switch CWD (current working directory) of to match
* the user's CWD home.
* ASARC case 1995/390
*/
#include <netdb.h>
#include <stdio.h>
#include <fcntl.h>
#include "misc.h"
#include "osdep.h"
#include "input.h"
#include "dixstruct.h"
#include "dixfont.h"
#include "opaque.h"
#include <pwd.h>
#include <project.h>
#include <ctype.h>
#include "scrnintstr.h"
#ifdef XSUN
#include "sunIo.h"
#endif
#define DTLOGIN_PATH "/var/dt/sdtlogin/"
#define BUFLEN 1024
extern char *display;
extern const char *GetAuthFilename(void);
static int dtloginSocket = -1;
extern Bool noXkbExtension;
extern int *argcGlobalP;
extern char ***argvGlobalP;
static int dtlogin_create_pipe(int);
static void dtlogin_receive_packet(void);
static void dtlogin_close_pipe(void);
#ifndef XSUN
#else
#endif
/*
* initialize DTLOGIN: create pipe; set handlers.
* Called from CreateWellKnownSockets in os/connection.c
*/
void
DtloginInit(void)
{
int displayNumber = 0;
if ( getuid() != 0 ) return;
DtloginWakeupHandler, (pointer) 0);
return;
}
static void
{
if ( dtloginSocket == -1 ) return;
}
static void
int i;
{
if ( dtloginSocket == -1 ) return;
if (i > 0)
{
{
}
}
}
static int
dtlogin_create_pipe( int port )
{
char pipename[128];
return -1;
return -1; /* DTLOGIN_PATH is not a directory */
return -1;
/* To make sure root has rw permissions. */
return -1;
return 1;
}
static void dtlogin_close_pipe(void)
{
dtloginSocket = -1;
}
static void
dtlogin_receive_packet(void)
{
/* contains characters to be processed */
char *buf;
/* temporary vars */
char *tXSERVERFLAGS;
int tokLen = 0;
int testFlagXSERVERFLAGS;
int notEvenOnce = TRUE;
while (1) {
int l;
/* ; exists, get the token */
t = (char *) strdup(s);
/* save stuff for next iteration */
}
else {
t = (char *) NULL;
}
if (t) {
/* look for GID */
testFlagGID = TRUE;
ctr++;
continue;
}
ctr++;
break;
}
ctr++;
}
/* printf("ctr=%d\n", ctr); */
/* update tokLen */
}
else
testFlagGID = FALSE;
/* look for UID */
testFlagUID = TRUE;
ctr++;
continue;
}
ctr++;
break;
}
ctr++;
}
/* printf("ctr=%d\n", ctr); */
/* update tokLen */
}
else
testFlagUID = FALSE;
/* look for HOME */
testFlagHOME = TRUE;
ctr++;
continue;
}
ctr++;
break;
}
ctr++;
}
/* printf("ctr=%d\n", ctr); */
/* update tokLen */
}
else
/* look for G_LIST_ID */
while (tG_LIST_ID[ctr]) {
ctr++;
continue;
}
ctr++;
break;
}
ctr++;
}
/* printf("ctr=%d\n", ctr); */
/* update tokLen */
}
else
/* look for XSERVERFLAGS */
while (tXSERVERFLAGS[ctr]) {
ctr++;
continue;
}
ctr++;
break;
}
spaces++;
}
else {
content++;
}
}
ctr++;
}
#if 0
if (content > 0) {
unsigned char *fpes;
int needToRestart;
for (i = 0; i < argcGlobal; i++) {
newArgv[i] = argvGlobal[i];
}
content = 0;
if (content != 0) {
newArgv[i]
i++;
}
break;
}
content = 0;
} else if (content == 0) {
}
}
/* Check through new arguments to see if we can skip
resetting the server */
for (j = argcGlobal;
(j < i) && (needToRestart == FALSE); j++) {
((j + 1) < i) ) {
/* Don't need to restart if setting default
depth to the current default depth. */
for (k=0; k < screenInfo.numScreens; k++) {
}
}
if (noXkbExtension) {
}
if (!noXkbExtension) {
}
} else {
/* Unrecognized argument, assume restart needed */
}
}
if (needToRestart == TRUE) {
/* Make sure to preserve font path since locale
* specific fonts have already been added and if
* we don't preserve them, they are lost. (4809632)
*/
for (j = 0; j < fpcount ; j++) {
unsigned int fpe_length = (unsigned int) *fpes;
curfp += fpe_length;
*curfp++ = ',';
}
*(curfp - 1) = 0;
{
fpset = 1;
}
}
if (!fpset) {
}
argcGlobal = *argcGlobalP = i;
} else {
for (j = argcGlobal; (j < i); j++) {
}
}
}
#endif
/* printf("ctr=%d\n", ctr); */
/* update tokLen */
}
else
/* look for EOF */
char proj_buf[PROJECT_BUFSZ];
testFlagEOF = TRUE;
if ( !env_str )
DtloginFatal("Not enough memory");
/* Memory error */
auth_file = GetAuthFilename();
if (auth_file)
DtloginError("Error in changing owner");
/* This gid dance is necessary in order to make sure
our "saved-set-gid" is 0 so that we can regain gid
0 when necessary for priocntl & power management.
The first step sets rgid to the user's gid and
makes the egid & saved-gid be 0. The second then
sets the egid to the users gid, but leaves the
saved-gid as 0. */
DtloginError("Error in setting regid");
DtloginError("Error in setting egid");
DtloginError("Error in setting groups");
/*
* BUG: 4462531: Set project ID for Xserver
* Get user name and default project.
* Set before the uid value is set.
*/
DtloginError("Error in getting user name");
(void *)&proj_buf,
PROJECT_BUFSZ) == NULL)
DtloginError("Error in getting project id");
TASK_NORMAL) == -1)
DtloginError("Error in setting project");
DtloginError("Error in setting uid");
DtloginError("Error in setting HOME");
DtloginError("Error in changing working directory");
return;
/* exit from program */
}
else
testFlagEOF = FALSE;
}
}
else {
/* We didn't find ;, so get more data! */
notEvenOnce = TRUE;
/*
* Realloc only if buf has filled up and we don't have a record
* delimiter yet. Keep track of alloced size.
*/
}
}
}
}