Example #1
0
File: dm.c Project: 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
}
Example #2
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 ();
	}
    }
}
Example #3
0
static void
RescanServers (void)
{
    Debug ("rescanning servers\n");
    LogInfo ("Rescanning both config and servers files\n");
    ForEachDisplay (MarkDisplay);
    SetConfigFileTime ();
    ReinitResources ();
    LoadDMResources ();
    ScanServers ();
    StartDisplays ();
}
Example #4
0
File: dm.c Project: 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();
}
Example #5
0
File: dm.c Project: bbidulock/wdm
int main(int argc, char **argv)
{
	int oldpid, oldumask;
	char cmdbuf[1024];
	int debugMode = 0;

	/* make sure at least world write access is disabled */
	if (((oldumask = umask(022)) & 002) == 002)
		(void)umask(oldumask);
#ifndef NOXDMTITLE
	Title = argv[0];
	TitleLen = (argv[argc - 1] + strlen(argv[argc - 1])) - Title;
#endif

	/*
	 * Step 1 - load configuration parameters
	 */
	InitResources(argc, argv);
	SetConfigFileTime();
	LoadDMResources();
	/*
	 * Only allow root to run in non-debug mode to avoid problems
	 */
	debugMode = (debugLevel.i > WDM_LEVEL_WARNING);
	if (!debugMode && getuid() != 0) {
		fprintf(stderr, "Only root wants to run %s\n", argv[0]);
		exit(1);
	}
	if (!debugMode && daemonMode.i) {
		BecomeOrphan();
		BecomeDaemon();
	}
	/* SUPPRESS 560 */
	if ((oldpid = StorePid())) {
		if (oldpid == -1)
			WDMError("Can't create/lock pid file %s\n", pidFile);
		else
			WDMError("Can't lock pid file %s, another wdm is running " "(pid %d)\n", pidFile, oldpid);
		exit(1);
	}
	WDMLogLevel(debugLevel.i);
	if (useSyslog.i) {
		WDMUseSysLog("wdm", WDMStringToFacility(syslogFacility));
	} else if (errorLogFile && *errorLogFile) {
		int f;
		if ((f = open(errorLogFile, O_CREAT | O_WRONLY | O_APPEND, 0600)) == -1)
			WDMError("cannot open errorLogFile %s\n", errorLogFile);
		else
			WDMLogStream(fdopen(f, "w"));
	}
	/* redirect any messages for stderr into standard logging functions. */
	WDMRedirectStderr(WDM_LEVEL_ERROR);

	/* Clean up any old Authorization files */
	sprintf(cmdbuf, "/bin/rm -f %s/authdir/authfiles/A*", authDir);
	system(cmdbuf);

#ifdef XDMCP
	init_session_id();
	CreateWellKnownSockets();
#else
	WDMDebug("wdm: not compiled for XDMCP\n");
#endif
	parent_pid = getpid();
	(void)Signal(SIGTERM, StopAll);
	(void)Signal(SIGINT, StopAll);
	/*
	 * Step 2 - Read /etc/Xservers and set up
	 *      the socket.
	 *
	 *      Keep a sub-daemon running
	 *      for each entry
	 */
	SetAccessFileTime();
#ifdef XDMCP
	ScanAccessDatabase();
#endif
	ScanServers();
	StartDisplays();
	(void)Signal(SIGHUP, RescanNotify);
	(void)Signal(SIGCHLD, ChildNotify);
	while (
#ifdef XDMCP
			  AnyWellKnownSockets() ||
#endif
			  AnyDisplaysLeft()) {
		if (Rescan) {
			RescanServers();
			Rescan = 0;
		}
		WaitForSomething();
	}
	WDMDebug("Nothing left to do, exiting\n");
	exit(0);
 /*NOTREACHED*/}
Example #6
0
int
main (int argc, char **argv)
{
    mode_t oldumask;
    char cmdbuf[1024];

    /* make sure at least world write access is disabled */
    if (((oldumask = umask(022)) & 002) == 002)
	(void) umask (oldumask);

    /*
     * Step 1 - load configuration parameters
     */
    InitResources (argc, argv);
    SetConfigFileTime ();
    LoadDMResources ();
    /*
     * Only allow root to run in non-debug mode to avoid problems
     */
    if (debugLevel == 0 && getuid() != 0)
    {
	fprintf (stderr, "Only root wants to run %s\n", argv[0]);
	exit (1);
    }
    if (debugLevel == 0 && daemonMode) {
      if (daemon (0, 0) < 0) {
	/* error */
	LogError("daemon() failed, %s\n", _SysErrorMsg (errno));
	exit(1);
      }
    }
    if (debugLevel == 0)
	InitErrorLog ();
    if (debugLevel >= 10)
	nofork_session = 1;
    LogInfo ("Starting\n");

    if (nofork_session == 0) {
	/* Clean up any old Authorization files */
	/* AUD: all good? */
	snprintf(cmdbuf, sizeof(cmdbuf), "/bin/rm -f %s/authdir/authfiles/A*", authDir);
	system(cmdbuf);
    }
    parent_pid = getpid ();
    (void) signal (SIGTERM, StopAll);
    (void) signal (SIGINT, StopAll);
    /*
     * Step 2 - Read Xservers and set up
     *	    the socket.
     *
     *	    Keep a sub-daemon running
     *	    for each entry
     */
    ScanServers ();
    StartDisplays ();
    (void) signal (SIGHUP, RescanNotify);
    (void) signal (SIGCHLD, ChildNotify);
    Debug ("startup successful; entering main loop\n");
    while (AnyDisplaysLeft ())
    {
	if (Rescan)
	{
	    RescanServers ();
	    Rescan = 0;
	}
	WaitForChild ();
    }
    Debug ("Nothing left to do, exiting\n");
    LogInfo ("Exiting\n");
    return 0;
}
Example #7
0
int
main (int argc, char **argv)
{
    int	oldpid;
    mode_t oldumask;
    char cmdbuf[1024];

    /* make sure at least world write access is disabled */
    if (((oldumask = umask(022)) & 002) == 002)
	(void) umask (oldumask);
#ifndef NOXDMTITLE
    Title = argv[0];
    TitleLen = (argv[argc - 1] + strlen(argv[argc - 1])) - Title;
#endif

#ifdef USESECUREWARE
    set_auth_parameters (argc, argv);
#endif

    /*
     * Step 1 - load configuration parameters
     */
    InitResources (argc, argv);
    SetConfigFileTime ();
    LoadDMResources ();
    /*
     * Only allow root to run in non-debug mode to avoid problems
     */
    if (debugLevel == 0 && getuid() != 0)
    {
	fprintf (stderr, "Only root wants to run %s\n", argv[0]);
	exit (1);
    }
    if (debugLevel == 0 && daemonMode)
	BecomeDaemon ();
    if (debugLevel == 0)
	InitErrorLog ();
    if (debugLevel >= 10)
	nofork_session = 1;
    /* SUPPRESS 560 */
    if ((oldpid = StorePid ()))
    {
	if (oldpid == -1)
	    LogError ("Can't create/lock pid file %s\n", pidFile);
	else
	    LogError ("Can't lock pid file %s, another xdm is running (pid %d)\n",
		 pidFile, oldpid);
	exit (1);
    }

    LogInfo ("Starting\n");

    if (atexit (RemovePid))
	LogError ("could not register RemovePid() with atexit()\n");

    if (nofork_session == 0) {
	/* Clean up any old Authorization files */
	/* AUD: all good? */
	snprintf(cmdbuf, sizeof(cmdbuf), "/bin/rm -f %s/authdir/authfiles/A*", authDir);
	system(cmdbuf);
    }
#if!defined(HAVE_ARC4RANDOM) && !defined(DEV_RANDOM)
    AddOtherEntropy ();
#endif
#ifdef XDMCP
    init_session_id ();
    CreateWellKnownSockets ();
#else
    Debug ("xdm: not compiled for XDMCP\n");
#endif
    parent_pid = getpid ();
    (void) Signal (SIGTERM, StopAll);
    (void) Signal (SIGINT, StopAll);
    /*
     * Step 2 - Read /etc/Xservers and set up
     *	    the socket.
     *
     *	    Keep a sub-daemon running
     *	    for each entry
     */
    SetAccessFileTime ();
#ifdef XDMCP
    ScanAccessDatabase ();
    UpdateListenSockets ();
#endif
    ScanServers ();
    StartDisplays ();
#if !defined(HAVE_ARC4RANDOM) && !defined(DEV_RANDOM)
    AddOtherEntropy();
#endif
    (void) Signal (SIGHUP, RescanNotify);
#ifndef UNRELIABLE_SIGNALS
    (void) Signal (SIGCHLD, ChildNotify);
#endif
    Debug ("startup successful; entering main loop\n");
    while (
#ifdef XDMCP
	   AnyWellKnownSockets() ||
#endif
	   AnyDisplaysLeft ())
    {
	if (Rescan)
	{
	    RescanServers ();
	    Rescan = 0;
	}
#if defined(UNRELIABLE_SIGNALS) || !defined(XDMCP)
	WaitForChild ();
#else
	WaitForSomething ();
#endif
    }
    Debug ("Nothing left to do, exiting\n");
    LogInfo ("Exiting\n");
    exit(0);
    /*NOTREACHED*/
}