diff --git a/dix/main.c b/dix/main.c
index 0eaa6aa..f466c25 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -78,6 +78,8 @@ Equipment Corporation.
#include <version-config.h>
#endif
+#include <sys/stat.h>
+#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
@@ -123,6 +125,30 @@ extern void DtloginCloseDown(void);
extern void Dispatch(void);
+#if defined(sun)
+extern const char * GetAuthFilename(void);
+
+#define LOCK_PREFIX "/var/xauth/"
+
+/*
+ * Setup /var/xauth/$DISPLAY, which is a symlink to the
+ * actually auth file.
+ */
+static void
+SetupXauthFile(char *filename)
+{
+ struct stat buf;
+ char sym_authfile[40];
+
+ snprintf(sym_authfile, 40, LOCK_PREFIX "%s", display);
+
+ mkdir(LOCK_PREFIX, S_IRWXU);
+
+ remove(sym_authfile);
+ symlink(filename, sym_authfile);
+}
+#endif
+
#ifdef XQUARTZ
#include <pthread.h>
@@ -141,6 +167,9 @@ main(int argc, char *argv[], char *envp[])
{
int i;
HWEventQueueType alwaysCheckForInput[2];
+#if defined(sun)
+ char *xauthfile = NULL;
+#endif
display = "0";
@@ -154,6 +183,12 @@ main(int argc, char *argv[], char *envp[])
ProcessCommandLine(argc, argv);
+#if defined(sun)
+ xauthfile = GetAuthFilename();
+ if (xauthfile)
+ SetupXauthFile(xauthfile);
+#endif
+
alwaysCheckForInput[0] = 0;
alwaysCheckForInput[1] = 1;
while (1) {
index 4b75a98..3113186 100644
@@ -45,6 +45,9 @@
#define CONSOLE_VTNO 1
#define SOL_CONSOLE_DEV "/dev/console"
+/* For use of VT_SETDISPLOGIN in dtlogin.c */
+extern int xf86ConsoleFd;
+
static Bool KeepTty = FALSE;
static Bool Protect0 = FALSE;
static Bool UseConsole = FALSE;
@@ -240,6 +243,8 @@ xf86OpenConsole(void)
if (ioctl(xf86Info.consoleFd, VT_SETDISPINFO, atoi(display)) < 0)
xf86Msg(X_WARNING, "xf86OpenConsole: VT_SETDISPINFO failed\n");
+
+ xf86ConsoleFd = xf86Info.consoleFd;
}
#endif