Пример #1
0
static void
stoppen( int force )
{
#ifdef XDMCP
	request_port = 0;
	UpdateListenSockets();
#endif
	if (force)
		ForEachDisplay( StopDisplay );
	else
		ForEachDisplay( StopInactiveDisplay );
	Stopping = 1;
}
Пример #2
0
Файл: dm.c Проект: bbidulock/wdm
static void StopAll(int n)
{
	int olderrno = errno;

	if (parent_pid != getpid()) {
		/* 
		 * We are a child wdm process that was killed by the
		 * master wdm before we were able to return from fork()
		 * and remove this signal handler.
		 *
		 * See defect XWSog08655 for more information.
		 */
		WDMDebug("Child wdm caught SIGTERM before it remove that signal.\n");
		(void)Signal(n, SIG_DFL);
		TerminateProcess(getpid(), SIGTERM);
		errno = olderrno;
		return;
	}
	WDMDebug("Shutting down entire manager\n");
#ifdef XDMCP
	DestroyWellKnownSockets();
#endif
	ForEachDisplay(StopDisplay);
	errno = olderrno;
}
Пример #3
0
Файл: dm.c Проект: bbidulock/wdm
static void RescanIfMod(void)
{
	struct stat statb;

	if (config && stat(config, &statb) != -1) {
		if (statb.st_mtime != ConfigModTime) {
			WDMDebug("Config file %s has changed, rereading\n", config);
			WDMInfo("Rereading configuration file %s\n", config);
			ConfigModTime = statb.st_mtime;
			ReinitResources();
			LoadDMResources();
		}
	}
	if (servers[0] == '/' && stat(servers, &statb) != -1) {
		if (statb.st_mtime != ServersModTime) {
			WDMDebug("Servers file %s has changed, rescanning\n", servers);
			WDMInfo("Rereading servers file %s\n", servers);
			ServersModTime = statb.st_mtime;
			ForEachDisplay(MarkDisplay);
			ScanServers();
		}
	}
#ifdef XDMCP
	if (accessFile && accessFile[0] && stat(accessFile, &statb) != -1) {
		if (statb.st_mtime != AccessFileModTime) {
			WDMDebug("Access file %s has changed, rereading\n", accessFile);
			WDMInfo("Rereading access file %s\n", accessFile);
			AccessFileModTime = statb.st_mtime;
			ScanAccessDatabase();
		}
	}
#endif
}
Пример #4
0
/* ARGSUSED */
static void
StopAll (int n)
{
    int olderrno = errno;

    if (parent_pid != getpid())
    {
	/*
	 * We are a child xdm process that was killed by the
	 * master xdm before we were able to return from fork()
	 * and remove this signal handler.
	 *
	 * See defect XWSog08655 for more information.
	 */
	Debug ("Child xenodm caught SIGTERM before it removed that signal.\n");
	(void) signal (n, SIG_DFL);
	kill (getpid(), SIGTERM);
	errno = olderrno;
	return;
    }
    Debug ("Shutting down entire manager\n");
    LogInfo ("Shutting down\n");
    ForEachDisplay (StopDisplay);
    errno = olderrno;
}
Пример #5
0
static void
RescanIfMod (void)
{
    struct stat	statb;

    if (config && stat (config, &statb) != -1)
    {
	if (statb.st_mtime != ConfigModTime)
	{
	    Debug ("Config file %s has changed, rereading\n", config);
	    LogInfo ("Rereading configuration file %s\n", config);
	    ConfigModTime = statb.st_mtime;
	    ReinitResources ();
	    LoadDMResources ();
	}
    }
    if (servers[0] == '/' && stat(servers, &statb) != -1)
    {
	if (statb.st_mtime != ServersModTime)
	{
	    Debug ("Servers file %s has changed, rescanning\n", servers);
	    LogInfo ("Rereading servers file %s\n", servers);
	    ServersModTime = statb.st_mtime;
	    ForEachDisplay (MarkDisplay);
	    ScanServers ();
	}
    }
}
Пример #6
0
/* ARGSUSED */
static SIGVAL
StopAll (int n)
{
    int olderrno = errno;

    if (parent_pid != getpid())
    {
	/*
	 * We are a child xdm process that was killed by the
	 * master xdm before we were able to return from fork()
	 * and remove this signal handler.
	 *
	 * See defect XWSog08655 for more information.
	 */
	Debug ("Child xdm caught SIGTERM before it removed that signal.\n");
	(void) Signal (n, SIG_DFL);
	TerminateProcess (getpid(), SIGTERM);
	errno = olderrno;
	return;
    }
    Debug ("Shutting down entire manager\n");
    LogInfo ("Shutting down\n");
#ifdef XDMCP
    DestroyWellKnownSockets ();
#endif
    ForEachDisplay (StopDisplay);
#ifdef SIGNALS_RESET_WHEN_CAUGHT
    /* to avoid another one from killing us unceremoniously */
    (void) Signal (SIGTERM, StopAll);
    (void) Signal (SIGINT, StopAll);
#endif
    errno = olderrno;
}
Пример #7
0
static void
RescanServers (void)
{
    Debug ("rescanning servers\n");
    LogInfo ("Rescanning both config and servers files\n");
    ForEachDisplay (MarkDisplay);
    SetConfigFileTime ();
    ReinitResources ();
    LoadDMResources ();
    ScanServers ();
    StartDisplays ();
}
Пример #8
0
Файл: dm.c Проект: bbidulock/wdm
static void RescanServers(void)
{
	WDMDebug("rescanning servers\n");
	WDMInfo("Rescanning both config and servers files\n");
	ForEachDisplay(MarkDisplay);
	SetConfigFileTime();
	ReinitResources();
	LoadDMResources();
	ScanServers();
	SetAccessFileTime();
#ifdef XDMCP
	ScanAccessDatabase();
#endif
	StartDisplays();
}
Пример #9
0
static void
bombUtmp( void )
{
	struct utmps *utp;

	while ((utp = utmpList)) {
#ifdef HAVE_VTS
		ForEachDisplay( WakeDisplay );
#else
		utp->d->status = notRunning;
#endif
		utmpList = utp->next;
		free( utp );
	}
}
Пример #10
0
Файл: dm.c Проект: bbidulock/wdm
static void StartDisplays(void)
{
	ForEachDisplay(CheckDisplayStatus);
}
Пример #11
0
static void
CheckUtmp( void )
{
	static time_t modtim;
	time_t nck;
	time_t ends;
	struct utmps *utp, **utpp;
	struct stat st;
#ifdef BSD_UTMP
	int fd;
	struct utmp ut[1];
#else
	STRUCTUTMP *ut;
#endif

	if (!utmpList)
		return;
	if (stat( UTMP_FILE, &st )) {
		LogError( UTMP_FILE " not found - cannot use console mode\n" );
		bombUtmp();
		return;
	}
	if (modtim != st.st_mtime) {
		Debug( "rescanning " UTMP_FILE "\n" );
		for (utp = utmpList; utp; utp = utp->next)
			utp->state = UtDead;
#ifdef BSD_UTMP
		if ((fd = open( UTMP_FILE, O_RDONLY )) < 0) {
			LogError( "Cannot open " UTMP_FILE " - cannot use console mode\n" );
			bombUtmp();
			return;
		}
		while (Reader( fd, ut, sizeof(ut[0]) ) == sizeof(ut[0]))
#else
		SETUTENT();
		while ((ut = GETUTENT()))
#endif
		{
			for (utp = utmpList; utp; utp = utp->next) {
#ifdef HAVE_VTS
				char **line;
				for (line = consoleTTYs; *line; line++)
					if (!strncmp( *line, ut->ut_line, sizeof(ut->ut_line) ))
						goto hitlin;
				continue;
			  hitlin:
#else
				if (strncmp( utp->d->console, ut->ut_line, sizeof(ut->ut_line) ))
					continue;
#endif
#ifdef BSD_UTMP
				if (!*ut->ut_user) {
#else
				if (ut->ut_type != USER_PROCESS) {
#endif
#ifdef HAVE_VTS
					if (utp->state == UtActive)
						break;
#endif
					utp->state = UtWait;
				} else {
					utp->hadSess = 1;
					utp->state = UtActive;
				}
				if (utp->time < ut->ut_time) /* theoretically superfluous */
					utp->time = ut->ut_time;
				break;
			}
		}
#ifdef BSD_UTMP
		close( fd );
#else
		ENDUTENT();
#endif
		modtim = st.st_mtime;
	}
	for (utpp = &utmpList; (utp = *utpp); ) {
		if (utp->state != UtActive) {
			if (utp->state == UtDead) /* shouldn't happen ... */
				utp->time = 0;
			ends = utp->time + (utp->hadSess ? TIME_RELOG : TIME_LOG);
			if (ends <= now) {
#ifdef HAVE_VTS
				ForEachDisplay( WakeDisplay );
				Debug( "console login timed out\n" );
#else
				utp->d->status = notRunning;
				Debug( "console login for %s at %s timed out\n",
				       utp->d->name, utp->d->console );
#endif
				*utpp = utp->next;
				free( utp );
				continue;
			} else
				nck = ends;
		} else
			nck = TIME_RELOG + now;
		if (nck < utmpTimeout)
			utmpTimeout = nck;
		utpp = &(*utpp)->next;
	}
}

static void
#ifdef HAVE_VTS
SwitchToTty( void )
#else
SwitchToTty( struct display *d )
#endif
{
	struct utmps *utp;
#ifdef HAVE_VTS
	int vt;
#endif

	if (!(utp = Malloc( sizeof(*utp) ))) {
#ifdef HAVE_VTS
		ForEachDisplay( WakeDisplay );
#else
		d->status = notRunning;
#endif
		return;
	}
#ifndef HAVE_VTS
	d->status = textMode;
	utp->d = d;
#endif
	utp->time = now;
	utp->hadSess = 0;
	utp->next = utmpList;
	utmpList = utp;
	CheckUtmp();

#ifdef HAVE_VTS
	if ((vt = TTYtoVT( *consoleTTYs )))
		activateVT( vt );
#endif

	/* XXX output something useful here */
}

#ifdef HAVE_VTS
static void
StopToTTY( struct display *d )
{
	if ((d->displayType & d_location) == dLocal)
		switch (d->status) {
		default:
			rStopDisplay( d, DS_TEXTMODE | 0x100 );
		case reserve:
		case textMode:
			break;
		}
}

static void
CheckTTYMode( void )
{
	struct display *d;

	for (d = displays; d; d = d->next)
		if (d->status == zombie)
			return;

	SwitchToTty();
}

#else

void
SwitchToX( struct display *d )
{
	struct utmps *utp, **utpp;

	for (utpp = &utmpList; (utp = *utpp); utpp = &(*utpp)->next)
		if (utp->d == d) {
			*utpp = utp->next;
			free( utp );
			d->status = notRunning;
			return;
		}
}
#endif

#ifdef XDMCP
static void
StartRemoteLogin( struct display *d )
{
	char **argv;
	int pid;

	Debug( "StartRemoteLogin for %s\n", d->name );
	/* HACK: omitting LoadDisplayResources( d ) here! */
	switch (pid = Fork()) {
	case 0:
		argv = PrepServerArgv( d, d->serverArgsRemote );
		if (!(argv = addStrArr( argv, "-once", 5 )) ||
		    !(argv = addStrArr( argv, "-query", 6 )) ||
		    !(argv = addStrArr( argv, d->remoteHost, -1 )))
			exit( 1 );
		Debug( "exec %\"[s\n", argv );
		(void)execv( argv[0], argv );
		LogError( "X server %\"s cannot be executed\n", argv[0] );
		exit( 1 );
	case -1:
		LogError( "Forking X server for remote login failed: %m" );
		d->status = notRunning;
		return;
	default:
		break;
	}
	Debug( "X server forked, pid %d\n", pid );
	d->serverPid = pid;

	d->status = remoteLogin;
}