void StartDisplay (struct display *d) { pid_t pid; Debug ("StartDisplay %s\n", d->name); LogInfo ("Starting X server on %s\n", d->name); LoadServerResources (d); if (d->authorize) { Debug ("SetLocalAuthorization %s, auth %s\n", d->name, d->authNames[0]); SetLocalAuthorization (d); } if (d->serverPid == -1 && !StartServer (d)) { LogError ("Server for display %s can't be started, session disabled\n", d->name); RemoveDisplay (d); return; } if (!nofork_session) pid = fork (); else pid = 0; switch (pid) { case 0: if (!nofork_session) { CleanUpChild (); (void) signal (SIGPIPE, SIG_IGN); } openlog("xenodm", LOG_PID, LOG_AUTHPRIV); LoadSessionResources (d); SetAuthorization (d); if (!WaitForServer (d)) exit (OPENFAILED_DISPLAY); SetWindowPath(d); if (pledge("stdio rpath cpath wpath fattr flock proc dns inet unix exec prot_exec getpw id", NULL) != 0) exit(OPENFAILED_DISPLAY); ManageSession (d); exit (REMANAGE_DISPLAY); case -1: break; default: Debug ("pid: %d\n", pid); d->pid = pid; d->status = running; break; } }
void StartDisplay(struct display *d) { int pid; WDMDebug("StartDisplay %s\n", d->name); LoadServerResources(d); if (d->displayType.location == Local) { /* don't bother pinging local displays; we'll * certainly notice when they exit */ d->pingInterval = 0; if (d->authorize) { WDMDebug("SetLocalAuthorization %s, auth %s\n", d->name, d->authNames[0]); SetLocalAuthorization(d); /* * reset the server after writing the authorization information * to make it read the file (for compatibility with old * servers which read auth file only on reset instead of * at first connection) */ if (d->serverPid != -1 && d->resetForAuth && d->resetSignal) kill(d->serverPid, d->resetSignal); } if (d->serverPid == -1 && !StartServer(d)) { WDMError("Server for display %s can't be started, session disabled\n", d->name); RemoveDisplay(d); return; } } else { /* this will only happen when using XDMCP */ if (d->authorizations) SaveServerAuthorizations(d, d->authorizations, d->authNum); } pid = fork(); switch (pid) { case 0: CleanUpChild(); LoadSessionResources(d); SetAuthorization(d); (void)Signal(SIGPIPE, SIG_IGN); (void)Signal(SIGHUP, SIG_IGN); if (!WaitForServer(d)) exit(OPENFAILED_DISPLAY); #ifdef XDMCP if (d->useChooser) RunChooser(d); else #endif ManageSession(d); exit(REMANAGE_DISPLAY); case -1: break; default: WDMDebug("pid: %d\n", pid); d->pid = pid; d->status = running; /* checking a predeclared X resource DisplayManager*wdmSequentialXServerLaunch here */ if (wdmSequentialXServerLaunch) WaitForServer(d); break; } }
void StartDisplay (struct display *d) { pid_t pid; Debug ("StartDisplay %s\n", d->name); LogInfo ("Starting X server on %s\n", d->name); LoadServerResources (d); if (d->displayType.location == Local) { /* don't bother pinging local displays; we'll * certainly notice when they exit */ d->pingInterval = 0; if (d->authorize) { Debug ("SetLocalAuthorization %s, auth %s\n", d->name, d->authNames[0]); SetLocalAuthorization (d); /* * reset the server after writing the authorization information * to make it read the file (for compatibility with old * servers which read auth file only on reset instead of * at first connection) */ if (d->serverPid != -1 && d->resetForAuth && d->resetSignal) kill (d->serverPid, d->resetSignal); } if (d->serverPid == -1 && !StartServer (d)) { LogError ("Server for display %s can't be started, session disabled\n", d->name); RemoveDisplay (d); return; } } else { /* this will only happen when using XDMCP */ if (d->authorizations) SaveServerAuthorizations (d, d->authorizations, d->authNum); } if (!nofork_session) pid = fork (); else pid = 0; switch (pid) { case 0: if (!nofork_session) { CleanUpChild (); (void) Signal (SIGPIPE, SIG_IGN); } #ifdef USE_SYSLOG openlog("xdm", LOG_PID, LOG_AUTHPRIV); #endif LoadSessionResources (d); SetAuthorization (d); if (!WaitForServer (d)) exit (OPENFAILED_DISPLAY); SetWindowPath(d); #ifdef XDMCP if (d->useChooser) RunChooser (d); else #endif ManageSession (d); exit (REMANAGE_DISPLAY); case -1: break; default: Debug ("pid: %d\n", pid); d->pid = pid; d->status = running; break; } }
int App::StartServer() { ServerPID = vfork(); static const int MAX_XSERVER_ARGS = 256; static char* server[MAX_XSERVER_ARGS+2] = { NULL }; server[0] = (char *)cfg.getOption("default_xserver").c_str(); string argOption = cfg.getOption("xserver_arguments"); char* args = new char[argOption.length()+2]; // NULL plus vt strcpy(args, argOption.c_str()); int argc = 1; int pos = 0; bool hasVtSet = false; while (args[pos] != '\0') { if (args[pos] == ' ' || args[pos] == '\t') { *(args+pos) = '\0'; server[argc++] = args+pos+1; } else if (pos == 0) { server[argc++] = args+pos; } if (server[argc-1][0] == 'v' && server[argc-1][1] == 't') { bool ok = false; Cfg::string2int(server[argc-1]+2, &ok); if (ok) { hasVtSet = true; } } ++pos; if (argc+1 >= MAX_XSERVER_ARGS) { // ignore _all_ arguments to make sure the server starts at // all argc = 1; break; } } if (!hasVtSet && daemonmode) { server[argc++] = "vt07"; } server[argc] = NULL; switch(ServerPID) { case 0: signal(SIGTTIN, SIG_IGN); signal(SIGTTOU, SIG_IGN); signal(SIGUSR1, SIG_IGN); setpgid(0,getpid()); execvp(server[0], server); cerr << APPNAME << ": X server could not be started" << endl; exit(ERR_EXIT); break; case -1: break; default: errno = 0; if(!ServerTimeout(0, "")) { ServerPID = -1; break; } alarm(15); pause(); alarm(0); // Wait for server to start up if(WaitForServer() == 0) { cerr << APPNAME << ": unable to connect to X server" << endl; StopServer(); ServerPID = -1; exit(ERR_EXIT); } break; } delete args; return ServerPID; }