summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2007-02-01 17:16:41 -0800
committerAlan Coopersmith <alan.coopersmith@sun.com>2007-02-01 17:16:41 -0800
commit5f0f8c00f47e778c59ae22bf685c97756456b2cd (patch)
tree515a38e86fa94e3da36b3635d867025ae6ca5722
parent450e9eb2725be6ead1c6d3e5477b737ded04070b (diff)
Bug 8014: xdm should set the WINDOWPATH environment variable
X.Org Bug #8014: <https://bugs.freedesktop.org/show_bug.cgi?id=8014> Patch #6702: <https://bugs.freedesktop.org/attachment.cgi?id=6702>
-rw-r--r--dm.c75
-rw-r--r--dm.h2
-rw-r--r--server.c18
-rw-r--r--session.c6
-rw-r--r--xdm.man.cpp2
5 files changed, 93 insertions, 10 deletions
diff --git a/dm.c b/dm.c
index 80a295a..52b49eb 100644
--- a/dm.c
+++ b/dm.c
@@ -68,7 +68,9 @@ from The Open Group.
# include <sys/stat.h>
# include <errno.h>
# include <X11/Xfuncproto.h>
+# include <X11/Xatom.h>
# include <stdarg.h>
+# include <stdint.h>
#ifndef F_TLOCK
#ifndef X_NOT_POSIX
@@ -622,6 +624,78 @@ StartDisplays (void)
ForEachDisplay (CheckDisplayStatus);
}
+static void
+SetWindowPath(struct display *d)
+{
+ /* setting WINDOWPATH for clients */
+ Atom prop;
+ Atom actualtype;
+ int actualformat;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *buf;
+ const char *windowpath;
+ char *newwindowpath;
+ unsigned long num;
+ char nums[10];
+ int numn;
+
+ prop = XInternAtom(d->dpy, "XFree86_VT", False);
+ if (prop == None) {
+ fprintf(stderr, "no XFree86_VT atom\n");
+ return;
+ }
+ if (XGetWindowProperty(d->dpy, DefaultRootWindow(d->dpy), prop, 0, 1,
+ False, AnyPropertyType, &actualtype, &actualformat,
+ &nitems, &bytes_after, &buf)) {
+ fprintf(stderr, "no XFree86_VT property\n");
+ return;
+ }
+ if (nitems != 1) {
+ fprintf(stderr, "%lu items in XFree86_VT property!\n", nitems);
+ XFree(buf);
+ return;
+ }
+ switch (actualtype) {
+ case XA_CARDINAL:
+ case XA_INTEGER:
+ case XA_WINDOW:
+ switch (actualformat) {
+ case 8:
+ num = (*(uint8_t *)(void *)buf);
+ break;
+ case 16:
+ num = (*(uint16_t *)(void *)buf);
+ break;
+ case 32:
+ num = (*(uint32_t *)(void *)buf);
+ break;
+ default:
+ fprintf(stderr, "format %d in XFree86_VT property!\n", actualformat);
+ XFree(buf);
+ return;
+ }
+ break;
+ default:
+ fprintf(stderr, "type %lx in XFree86_VT property!\n", actualtype);
+ XFree(buf);
+ return;
+ }
+ XFree(buf);
+ windowpath = getenv("WINDOWPATH");
+ numn = snprintf(nums, sizeof(nums), "%lu", num);
+ if (!windowpath) {
+ newwindowpath = malloc(numn + 1);
+ sprintf(newwindowpath, "%s", nums);
+ } else {
+ newwindowpath = malloc(strlen(windowpath) + 1 + numn + 1);
+ sprintf(newwindowpath, "%s:%s", windowpath, nums);
+ }
+ if (d->windowPath)
+ free(d->windowPath);
+ d->windowPath = newwindowpath;
+}
+
void
StartDisplay (struct display *d)
{
@@ -677,6 +751,7 @@ StartDisplay (struct display *d)
SetAuthorization (d);
if (!WaitForServer (d))
exit (OPENFAILED_DISPLAY);
+ SetWindowPath(d);
#ifdef XDMCP
if (d->useChooser)
RunChooser (d);
diff --git a/dm.h b/dm.h
index e8b8df8..5fa13e4 100644
--- a/dm.h
+++ b/dm.h
@@ -242,6 +242,8 @@ struct display {
/* Hack for making "Willing to manage" configurable */
char *willing; /* "Willing to manage" program */
+ Display *dpy; /* Display */
+ char *windowPath; /* path to server "window" */
};
#ifdef XDMCP
diff --git a/server.c b/server.c
index 2f991ae..aa6fdb1 100644
--- a/server.c
+++ b/server.c
@@ -51,8 +51,6 @@ static int receivedUsr1;
static int serverPause (unsigned t, pid_t serverPid);
-static Display *dpy;
-
/* ARGSUSED */
static SIGVAL
CatchUsr1 (int n)
@@ -304,7 +302,7 @@ WaitForServer (struct display *d)
Debug ("Before XOpenDisplay(%s)\n", d->name);
errno = 0;
(void) XSetIOErrorHandler (openErrorHandler);
- dpy = XOpenDisplay (d->name);
+ d->dpy = XOpenDisplay (d->name);
#ifdef STREAMSCONN
{
/* For some reason, the next XOpenDisplay we do is
@@ -320,13 +318,13 @@ WaitForServer (struct display *d)
(void) Signal (SIGALRM, SIG_DFL);
(void) XSetIOErrorHandler ((int (*)(Display *)) 0);
Debug ("After XOpenDisplay(%s)\n", d->name);
- if (dpy) {
+ if (d->dpy) {
#ifdef XDMCP
if (d->displayType.location == Foreign)
- GetRemoteAddress (d, ConnectionNumber (dpy));
+ GetRemoteAddress (d, ConnectionNumber (d->dpy));
#endif
- RegisterCloseOnFork (ConnectionNumber (dpy));
- (void) fcntl (ConnectionNumber (dpy), F_SETFD, 0);
+ RegisterCloseOnFork (ConnectionNumber (d->dpy));
+ (void) fcntl (ConnectionNumber (d->dpy), F_SETFD, 0);
return 1;
} else {
Debug ("OpenDisplay failed %d (%s) on \"%s\"\n",
@@ -349,8 +347,8 @@ WaitForServer (struct display *d)
void
ResetServer (struct display *d)
{
- if (dpy && d->displayType.origin != FromXDMCP)
- pseudoReset (dpy);
+ if (d->dpy && d->displayType.origin != FromXDMCP)
+ pseudoReset (d->dpy);
}
static Jmp_buf pingTime;
@@ -384,7 +382,7 @@ PingServer (struct display *d, Display *alternateDpy)
int oldAlarm;
static Display *aDpy;
- aDpy = (alternateDpy != NULL ? alternateDpy : dpy);
+ aDpy = (alternateDpy != NULL ? alternateDpy : d->dpy);
oldError = XSetIOErrorHandler (PingLostIOErr);
oldAlarm = alarm (0);
oldSig = Signal (SIGALRM, PingLostSig);
diff --git a/session.c b/session.c
index 7aaeeaa..384fd78 100644
--- a/session.c
+++ b/session.c
@@ -769,6 +769,10 @@ StartClient (
}
#endif /* K5AUTH */
#endif /* !USE_PAM */
+
+ if (d->windowPath)
+ verify->userEnviron = setEnv(verify->userEnviron, "WINDOWPATH", d->windowPath);
+
if (passwd != NULL)
bzero(passwd, strlen(passwd));
@@ -961,6 +965,8 @@ systemEnv (struct display *d, char *user, char *home)
env = setEnv (env, "SHELL", d->systemShell);
if (d->authFile)
env = setEnv (env, "XAUTHORITY", d->authFile);
+ if (d->windowPath)
+ env = setEnv (env, "WINDOWPATH", d->windowPath);
return env;
}
diff --git a/xdm.man.cpp b/xdm.man.cpp
index c42e253..2e51cbf 100644
--- a/xdm.man.cpp
+++ b/xdm.man.cpp
@@ -1092,6 +1092,7 @@ the following environment variables are passed:
PATH the value of \fBDisplayManager.\fP\fIDISPLAY\fP\fB.systemPath\fP
SHELL the value of \fBDisplayManager.\fP\fIDISPLAY\fP\fB.systemShell\fP
XAUTHORITY may be set to an authority file
+ WINDOWPATH may be set to the "window path" leading to the X server
.fi
.PP
@@ -1146,6 +1147,7 @@ the following environment variables are passed:
SHELL the user's default shell (from \fIgetpwnam\fP)
XAUTHORITY may be set to a non-standard authority file
KRB5CCNAME may be set to a Kerberos credentials cache name
+ WINDOWPATH may be set to the "window path" leading to the X server
.fi
.PP