diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2016-11-06 09:17:48 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2020-07-14 15:52:35 +0200 |
commit | 52d8432acbf74bb9353daa68b2e6ba33398cf14c (patch) | |
tree | e21767bf86de6e9edf17005dd4ec81401a25c8de /xenodm | |
parent | a18fe6d27c42a0edd96f0c93cfdff913549d1e36 (diff) |
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
Diffstat (limited to 'xenodm')
-rw-r--r-- | xenodm/auth.c | 11 | ||||
-rw-r--r-- | xenodm/dm.c | 84 | ||||
-rw-r--r-- | xenodm/file.c | 58 | ||||
-rw-r--r-- | xenodm/server.c | 2 |
4 files changed, 54 insertions, 101 deletions
diff --git a/xenodm/auth.c b/xenodm/auth.c index ac9a940..cea148f 100644 --- a/xenodm/auth.c +++ b/xenodm/auth.c @@ -867,8 +867,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify) !strncmp (auths[i]->name, "MIT-MAGIC-COOKIE-1", 18)) { magicCookie = i; - if (d->displayType.location == Local) - writeLocalAuth (new, auths[i], d->name); + writeLocalAuth (new, auths[i], d->name); break; } } @@ -885,8 +884,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify) if (auths[i]->name_length == 14 && !strncmp (auths[i]->name, "MIT-KERBEROS-5", 14)) 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; } } @@ -966,10 +964,7 @@ RemoveUserAuthorization (struct display *d, struct verify_info *verify) initAddrs (); doWrite = 0; for (i = 0; i < d->authNum; i++) - { - if (d->displayType.location == Local) - writeLocalAuth (new, auths[i], d->name); - } + writeLocalAuth (new, auths[i], d->name); doWrite = 1; if (old) { if (fstat (fileno (old), &statb) != -1) diff --git a/xenodm/dm.c b/xenodm/dm.c index d2f3d88..1b3081e 100644 --- a/xenodm/dm.c +++ b/xenodm/dm.c @@ -156,11 +156,6 @@ ScanServers (void) int len; FILE *serversFile; struct stat statb; - static DisplayType acceptableTypes[] = - { { Local, Permanent, FromFile }, - }; - -#define NumTypes (sizeof (acceptableTypes) / sizeof (acceptableTypes[0])) if (servers[0] == '/') { @@ -180,13 +175,13 @@ ScanServers (void) len = strlen (lineBuf); if (lineBuf[len-1] == '\n') lineBuf[len-1] = '\0'; - ParseDisplay (lineBuf, acceptableTypes, NumTypes); + ParseDisplay (lineBuf); } fclose (serversFile); } else { - ParseDisplay (servers, acceptableTypes, NumTypes); + ParseDisplay (servers); } } @@ -331,8 +326,7 @@ WaitForChild (void) d->startTries = 0; d->reservTries = 0; Debug ("Display exited with OBEYSESS_DISPLAY\n"); - if (d->displayType.lifetime != Permanent || - d->status == zombie) + if (d->status == zombie) StopDisplay (d); else RestartDisplay (d, FALSE); @@ -345,8 +339,7 @@ WaitForChild (void) * no display connection was ever made, tell the * terminal that the open attempt failed */ - if (d->displayType.origin == FromXDMCP || - d->status == zombie || + if (d->status == zombie || ++d->startTries >= d->startAttempts) { LogError ("Display %s is being disabled\n", d->name); @@ -360,7 +353,7 @@ WaitForChild (void) case RESERVER_DISPLAY: d->startTries = 0; Debug ("Display exited with RESERVER_DISPLAY\n"); - if (d->displayType.origin == FromXDMCP || d->status == zombie) + if (d->status == zombie) StopDisplay(d); else { Time_t now; @@ -404,8 +397,7 @@ WaitForChild (void) case waitCompose (SIGTERM,0,0): Debug ("Display exited on SIGTERM, try %d of %d\n", d->startTries, d->startAttempts); - if (d->displayType.origin == FromXDMCP || - d->status == zombie || + if (d->status == zombie || ++d->startTries >= d->startAttempts) { /* @@ -428,7 +420,7 @@ WaitForChild (void) * XDMCP will restart the session if the display * requests it */ - if (d->displayType.origin == FromXDMCP || d->status == zombie) + if (d->status == zombie) StopDisplay(d); else RestartDisplay (d, FALSE); @@ -480,19 +472,16 @@ WaitForChild (void) static void CheckDisplayStatus (struct display *d) { - if (d->displayType.origin == FromFile) - { - switch (d->state) { - case MissingEntry: - StopDisplay (d); - break; - case NewEntry: - d->state = OldEntry; - case OldEntry: - if (d->status == notRunning) - StartDisplay (d); - break; - } + switch (d->state) { + case MissingEntry: + StopDisplay (d); + break; + case NewEntry: + d->state = OldEntry; + case OldEntry: + if (d->status == notRunning) + StartDisplay (d); + break; } } @@ -576,28 +565,25 @@ StartDisplay (struct display *d) Debug ("StartDisplay %s\n", d->name); LogInfo ("Starting X server on %s\n", d->name); LoadServerResources (d); - if (d->displayType.location == Local) + if (d->authorize) { - 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; - } + 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; } if (!nofork_session) pid = fork (); diff --git a/xenodm/file.c b/xenodm/file.c index 194e8df..732bc2f 100644 --- a/xenodm/file.c +++ b/xenodm/file.c @@ -38,13 +38,6 @@ from The Open Group. #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 freeFileArgs (char **args) @@ -135,14 +128,24 @@ freeSomeArgs (char **args, int n) free (args); } + +static int +parseDisplayType (char *string) +{ + if (strcmp(string, "local") == 0) + return 0; + else + return 1; +} + void -ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable) +ParseDisplay (char *source) { char **args, **argv, **a; char *name, *class, *type; struct display *d; int usedDefault; - DisplayType displayType; + Boolean local; args = splitIntoWords (source); if (!args) @@ -160,7 +163,7 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable) freeFileArgs (args); return; } - displayType = parseDisplayType (args[1], &usedDefault); + usedDefault = parseDisplayType(args[1]); class = NULL; type = args[1]; argv = args + 2; @@ -172,7 +175,7 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable) */ if (usedDefault && args[2]) { - displayType = parseDisplayType (args[2], &usedDefault); + usedDefault = parseDisplayType (args[2]); if (!usedDefault) { class = args[1]; @@ -180,14 +183,7 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable) argv = args + 3; } } - while (numAcceptable) - { - if (DisplayTypeMatch (*acceptableTypes, displayType)) - break; - --numAcceptable; - ++acceptableTypes; - } - if (!numAcceptable) + if (!local) { LogError ("Unacceptable display type %s for display %s\n", type, name); @@ -216,33 +212,9 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable) Debug ("Found new display: %s %s %s", d->name, d->class ? d->class : "", type); } - d->displayType = displayType; d->argv = copyArgs (argv); for (a = d->argv; a && *a; a++) Debug (" %s", *a); Debug ("\n"); 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; -} diff --git a/xenodm/server.c b/xenodm/server.c index c7bef40..5452401 100644 --- a/xenodm/server.c +++ b/xenodm/server.c @@ -233,7 +233,7 @@ WaitForServer (struct display *d) void ResetServer (struct display *d) { - if (d->dpy && d->displayType.origin != FromXDMCP) + if (d->dpy) pseudoReset (d->dpy); } |