Remove the displayType member of struct display.
xenodm only manages Local Permanent FromFile X servers. No need to keep the checks for that. For now the Xservers file keeps the location field, but ignores its
This commit is contained in:
parent
1d7833af8c
commit
1a2fd595f2
@ -54,7 +54,6 @@ from The Open Group.
|
|||||||
# include <time.h>
|
# include <time.h>
|
||||||
# define Time_t time_t
|
# define Time_t time_t
|
||||||
|
|
||||||
|
|
||||||
# include <X11/Xdmcp.h>
|
# include <X11/Xdmcp.h>
|
||||||
|
|
||||||
|
|
||||||
@ -80,33 +79,6 @@ typedef int waitType;
|
|||||||
|
|
||||||
typedef enum displayStatus { running, notRunning, zombie, phoenix } DisplayStatus;
|
typedef enum displayStatus { running, notRunning, zombie, phoenix } DisplayStatus;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* local - server runs on local host
|
|
||||||
* foreign - server runs on remote host -- unsupported in xenodm
|
|
||||||
* permanent - session restarted when it exits
|
|
||||||
* transient - session not restarted when it exits
|
|
||||||
* fromFile - started via entry in servers file
|
|
||||||
* fromXDMCP - started with XDMCP
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct displayType {
|
|
||||||
unsigned int location:1;
|
|
||||||
unsigned int lifetime:1;
|
|
||||||
unsigned int origin:1;
|
|
||||||
} DisplayType;
|
|
||||||
|
|
||||||
# define Local 1
|
|
||||||
# define Foreign 0
|
|
||||||
|
|
||||||
# define Permanent 1
|
|
||||||
# define Transient 0
|
|
||||||
|
|
||||||
# define FromFile 1
|
|
||||||
# define FromXDMCP 0 /* unsupported in xenodm */
|
|
||||||
|
|
||||||
extern DisplayType parseDisplayType (char *string, int *usedDefault);
|
|
||||||
|
|
||||||
typedef enum fileState { NewEntry, OldEntry, MissingEntry } FileState;
|
typedef enum fileState { NewEntry, OldEntry, MissingEntry } FileState;
|
||||||
|
|
||||||
struct display {
|
struct display {
|
||||||
@ -114,7 +86,6 @@ struct display {
|
|||||||
/* Xservers file / XDMCP information */
|
/* Xservers file / XDMCP information */
|
||||||
char *name; /* DISPLAY name */
|
char *name; /* DISPLAY name */
|
||||||
char *class; /* display class (may be NULL) */
|
char *class; /* display class (may be NULL) */
|
||||||
DisplayType displayType; /* method to handle with */
|
|
||||||
char **argv; /* program name and arguments */
|
char **argv; /* program name and arguments */
|
||||||
|
|
||||||
/* display state */
|
/* display state */
|
||||||
@ -274,7 +245,7 @@ extern void ForEachDisplay (void (*f)(struct display *));
|
|||||||
extern void RemoveDisplay (struct display *old);
|
extern void RemoveDisplay (struct display *old);
|
||||||
|
|
||||||
/* in file.c */
|
/* in file.c */
|
||||||
extern void ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable);
|
extern void ParseDisplay (char *source);
|
||||||
|
|
||||||
/* in netaddr.c */
|
/* in netaddr.c */
|
||||||
extern char *NetaddrAddress(XdmcpNetaddr netaddrp, int *lenp);
|
extern char *NetaddrAddress(XdmcpNetaddr netaddrp, int *lenp);
|
||||||
|
@ -867,8 +867,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify)
|
|||||||
!strncmp (auths[i]->name, "MIT-MAGIC-COOKIE-1", 18))
|
!strncmp (auths[i]->name, "MIT-MAGIC-COOKIE-1", 18))
|
||||||
{
|
{
|
||||||
magicCookie = i;
|
magicCookie = i;
|
||||||
if (d->displayType.location == Local)
|
writeLocalAuth (new, auths[i], d->name);
|
||||||
writeLocalAuth (new, auths[i], d->name);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -885,8 +884,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify)
|
|||||||
if (auths[i]->name_length == 14 &&
|
if (auths[i]->name_length == 14 &&
|
||||||
!strncmp (auths[i]->name, "MIT-KERBEROS-5", 14))
|
!strncmp (auths[i]->name, "MIT-KERBEROS-5", 14))
|
||||||
auths[i]->data_length = 0;
|
auths[i]->data_length = 0;
|
||||||
if (d->displayType.location == Local)
|
writeLocalAuth (new, auths[i], d->name);
|
||||||
writeLocalAuth (new, auths[i], d->name);
|
|
||||||
auths[i]->data_length = data_len;
|
auths[i]->data_length = data_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -966,10 +964,7 @@ RemoveUserAuthorization (struct display *d, struct verify_info *verify)
|
|||||||
initAddrs ();
|
initAddrs ();
|
||||||
doWrite = 0;
|
doWrite = 0;
|
||||||
for (i = 0; i < d->authNum; i++)
|
for (i = 0; i < d->authNum; i++)
|
||||||
{
|
writeLocalAuth (new, auths[i], d->name);
|
||||||
if (d->displayType.location == Local)
|
|
||||||
writeLocalAuth (new, auths[i], d->name);
|
|
||||||
}
|
|
||||||
doWrite = 1;
|
doWrite = 1;
|
||||||
if (old) {
|
if (old) {
|
||||||
if (fstat (fileno (old), &statb) != -1)
|
if (fstat (fileno (old), &statb) != -1)
|
||||||
|
@ -156,11 +156,6 @@ ScanServers (void)
|
|||||||
int len;
|
int len;
|
||||||
FILE *serversFile;
|
FILE *serversFile;
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
static DisplayType acceptableTypes[] =
|
|
||||||
{ { Local, Permanent, FromFile },
|
|
||||||
};
|
|
||||||
|
|
||||||
#define NumTypes (sizeof (acceptableTypes) / sizeof (acceptableTypes[0]))
|
|
||||||
|
|
||||||
if (servers[0] == '/')
|
if (servers[0] == '/')
|
||||||
{
|
{
|
||||||
@ -180,13 +175,13 @@ ScanServers (void)
|
|||||||
len = strlen (lineBuf);
|
len = strlen (lineBuf);
|
||||||
if (lineBuf[len-1] == '\n')
|
if (lineBuf[len-1] == '\n')
|
||||||
lineBuf[len-1] = '\0';
|
lineBuf[len-1] = '\0';
|
||||||
ParseDisplay (lineBuf, acceptableTypes, NumTypes);
|
ParseDisplay (lineBuf);
|
||||||
}
|
}
|
||||||
fclose (serversFile);
|
fclose (serversFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ParseDisplay (servers, acceptableTypes, NumTypes);
|
ParseDisplay (servers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,8 +326,7 @@ WaitForChild (void)
|
|||||||
d->startTries = 0;
|
d->startTries = 0;
|
||||||
d->reservTries = 0;
|
d->reservTries = 0;
|
||||||
Debug ("Display exited with OBEYSESS_DISPLAY\n");
|
Debug ("Display exited with OBEYSESS_DISPLAY\n");
|
||||||
if (d->displayType.lifetime != Permanent ||
|
if (d->status == zombie)
|
||||||
d->status == zombie)
|
|
||||||
StopDisplay (d);
|
StopDisplay (d);
|
||||||
else
|
else
|
||||||
RestartDisplay (d, FALSE);
|
RestartDisplay (d, FALSE);
|
||||||
@ -345,8 +339,7 @@ WaitForChild (void)
|
|||||||
* no display connection was ever made, tell the
|
* no display connection was ever made, tell the
|
||||||
* terminal that the open attempt failed
|
* terminal that the open attempt failed
|
||||||
*/
|
*/
|
||||||
if (d->displayType.origin == FromXDMCP ||
|
if (d->status == zombie ||
|
||||||
d->status == zombie ||
|
|
||||||
++d->startTries >= d->startAttempts)
|
++d->startTries >= d->startAttempts)
|
||||||
{
|
{
|
||||||
LogError ("Display %s is being disabled\n", d->name);
|
LogError ("Display %s is being disabled\n", d->name);
|
||||||
@ -360,7 +353,7 @@ WaitForChild (void)
|
|||||||
case RESERVER_DISPLAY:
|
case RESERVER_DISPLAY:
|
||||||
d->startTries = 0;
|
d->startTries = 0;
|
||||||
Debug ("Display exited with RESERVER_DISPLAY\n");
|
Debug ("Display exited with RESERVER_DISPLAY\n");
|
||||||
if (d->displayType.origin == FromXDMCP || d->status == zombie)
|
if (d->status == zombie)
|
||||||
StopDisplay(d);
|
StopDisplay(d);
|
||||||
else {
|
else {
|
||||||
Time_t now;
|
Time_t now;
|
||||||
@ -404,8 +397,7 @@ WaitForChild (void)
|
|||||||
case waitCompose (SIGTERM,0,0):
|
case waitCompose (SIGTERM,0,0):
|
||||||
Debug ("Display exited on SIGTERM, try %d of %d\n",
|
Debug ("Display exited on SIGTERM, try %d of %d\n",
|
||||||
d->startTries, d->startAttempts);
|
d->startTries, d->startAttempts);
|
||||||
if (d->displayType.origin == FromXDMCP ||
|
if (d->status == zombie ||
|
||||||
d->status == zombie ||
|
|
||||||
++d->startTries >= d->startAttempts)
|
++d->startTries >= d->startAttempts)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -428,7 +420,7 @@ WaitForChild (void)
|
|||||||
* XDMCP will restart the session if the display
|
* XDMCP will restart the session if the display
|
||||||
* requests it
|
* requests it
|
||||||
*/
|
*/
|
||||||
if (d->displayType.origin == FromXDMCP || d->status == zombie)
|
if (d->status == zombie)
|
||||||
StopDisplay(d);
|
StopDisplay(d);
|
||||||
else
|
else
|
||||||
RestartDisplay (d, FALSE);
|
RestartDisplay (d, FALSE);
|
||||||
@ -480,19 +472,16 @@ WaitForChild (void)
|
|||||||
static void
|
static void
|
||||||
CheckDisplayStatus (struct display *d)
|
CheckDisplayStatus (struct display *d)
|
||||||
{
|
{
|
||||||
if (d->displayType.origin == FromFile)
|
switch (d->state) {
|
||||||
{
|
case MissingEntry:
|
||||||
switch (d->state) {
|
StopDisplay (d);
|
||||||
case MissingEntry:
|
break;
|
||||||
StopDisplay (d);
|
case NewEntry:
|
||||||
break;
|
d->state = OldEntry;
|
||||||
case NewEntry:
|
case OldEntry:
|
||||||
d->state = OldEntry;
|
if (d->status == notRunning)
|
||||||
case OldEntry:
|
StartDisplay (d);
|
||||||
if (d->status == notRunning)
|
break;
|
||||||
StartDisplay (d);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,28 +565,25 @@ StartDisplay (struct display *d)
|
|||||||
Debug ("StartDisplay %s\n", d->name);
|
Debug ("StartDisplay %s\n", d->name);
|
||||||
LogInfo ("Starting X server on %s\n", d->name);
|
LogInfo ("Starting X server on %s\n", d->name);
|
||||||
LoadServerResources (d);
|
LoadServerResources (d);
|
||||||
if (d->displayType.location == Local)
|
if (d->authorize)
|
||||||
{
|
{
|
||||||
if (d->authorize)
|
Debug ("SetLocalAuthorization %s, auth %s\n",
|
||||||
{
|
d->name, d->authNames[0]);
|
||||||
Debug ("SetLocalAuthorization %s, auth %s\n",
|
SetLocalAuthorization (d);
|
||||||
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
|
||||||
* reset the server after writing the authorization information
|
* servers which read auth file only on reset instead of
|
||||||
* to make it read the file (for compatibility with old
|
* at first connection)
|
||||||
* 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 && d->resetForAuth && d->resetSignal)
|
}
|
||||||
kill (d->serverPid, d->resetSignal);
|
if (d->serverPid == -1 && !StartServer (d))
|
||||||
}
|
{
|
||||||
if (d->serverPid == -1 && !StartServer (d))
|
LogError ("Server for display %s can't be started, session disabled\n", d->name);
|
||||||
{
|
RemoveDisplay (d);
|
||||||
LogError ("Server for display %s can't be started, session disabled\n", d->name);
|
return;
|
||||||
RemoveDisplay (d);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!nofork_session)
|
if (!nofork_session)
|
||||||
pid = fork ();
|
pid = fork ();
|
||||||
|
@ -38,13 +38,6 @@ from The Open Group.
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static int
|
|
||||||
DisplayTypeMatch (DisplayType d1, DisplayType d2)
|
|
||||||
{
|
|
||||||
return d1.location == d2.location &&
|
|
||||||
d1.lifetime == d2.lifetime &&
|
|
||||||
d1.origin == d2.origin;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
freeFileArgs (char **args)
|
freeFileArgs (char **args)
|
||||||
@ -135,14 +128,24 @@ freeSomeArgs (char **args, int n)
|
|||||||
free (args);
|
free (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
parseDisplayType (char *string)
|
||||||
|
{
|
||||||
|
if (strcmp(string, "local") == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable)
|
ParseDisplay (char *source)
|
||||||
{
|
{
|
||||||
char **args, **argv, **a;
|
char **args, **argv, **a;
|
||||||
char *name, *class, *type;
|
char *name, *class, *type;
|
||||||
struct display *d;
|
struct display *d;
|
||||||
int usedDefault;
|
int usedDefault;
|
||||||
DisplayType displayType;
|
Boolean local;
|
||||||
|
|
||||||
args = splitIntoWords (source);
|
args = splitIntoWords (source);
|
||||||
if (!args)
|
if (!args)
|
||||||
@ -160,7 +163,7 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable)
|
|||||||
freeFileArgs (args);
|
freeFileArgs (args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
displayType = parseDisplayType (args[1], &usedDefault);
|
usedDefault = parseDisplayType(args[1]);
|
||||||
class = NULL;
|
class = NULL;
|
||||||
type = args[1];
|
type = args[1];
|
||||||
argv = args + 2;
|
argv = args + 2;
|
||||||
@ -172,7 +175,7 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable)
|
|||||||
*/
|
*/
|
||||||
if (usedDefault && args[2])
|
if (usedDefault && args[2])
|
||||||
{
|
{
|
||||||
displayType = parseDisplayType (args[2], &usedDefault);
|
usedDefault = parseDisplayType (args[2]);
|
||||||
if (!usedDefault)
|
if (!usedDefault)
|
||||||
{
|
{
|
||||||
class = args[1];
|
class = args[1];
|
||||||
@ -180,14 +183,7 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable)
|
|||||||
argv = args + 3;
|
argv = args + 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (numAcceptable)
|
if (!local)
|
||||||
{
|
|
||||||
if (DisplayTypeMatch (*acceptableTypes, displayType))
|
|
||||||
break;
|
|
||||||
--numAcceptable;
|
|
||||||
++acceptableTypes;
|
|
||||||
}
|
|
||||||
if (!numAcceptable)
|
|
||||||
{
|
{
|
||||||
LogError ("Unacceptable display type %s for display %s\n",
|
LogError ("Unacceptable display type %s for display %s\n",
|
||||||
type, name);
|
type, name);
|
||||||
@ -216,33 +212,9 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable)
|
|||||||
Debug ("Found new display: %s %s %s",
|
Debug ("Found new display: %s %s %s",
|
||||||
d->name, d->class ? d->class : "", type);
|
d->name, d->class ? d->class : "", type);
|
||||||
}
|
}
|
||||||
d->displayType = displayType;
|
|
||||||
d->argv = copyArgs (argv);
|
d->argv = copyArgs (argv);
|
||||||
for (a = d->argv; a && *a; a++)
|
for (a = d->argv; a && *a; a++)
|
||||||
Debug (" %s", *a);
|
Debug (" %s", *a);
|
||||||
Debug ("\n");
|
Debug ("\n");
|
||||||
freeSomeArgs (args, argv - args);
|
freeSomeArgs (args, argv - args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct displayMatch {
|
|
||||||
const char *name;
|
|
||||||
DisplayType type;
|
|
||||||
} displayTypes[] = {
|
|
||||||
{ "local", { Local, Permanent, FromFile } },
|
|
||||||
{ NULL, { Local, Permanent, FromFile } },
|
|
||||||
};
|
|
||||||
|
|
||||||
DisplayType
|
|
||||||
parseDisplayType (char *string, int *usedDefault)
|
|
||||||
{
|
|
||||||
struct displayMatch *d;
|
|
||||||
|
|
||||||
for (d = displayTypes; d->name; d++)
|
|
||||||
if (!strcmp (d->name, string))
|
|
||||||
{
|
|
||||||
*usedDefault = 0;
|
|
||||||
return d->type;
|
|
||||||
}
|
|
||||||
*usedDefault = 1;
|
|
||||||
return d->type;
|
|
||||||
}
|
|
||||||
|
@ -233,7 +233,7 @@ WaitForServer (struct display *d)
|
|||||||
void
|
void
|
||||||
ResetServer (struct display *d)
|
ResetServer (struct display *d)
|
||||||
{
|
{
|
||||||
if (d->dpy && d->displayType.origin != FromXDMCP)
|
if (d->dpy)
|
||||||
pseudoReset (d->dpy);
|
pseudoReset (d->dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user