diff --git a/dix/main.c b/dix/main.c
index 9c3951a..86afa8c 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -79,6 +79,8 @@ Equipment Corporation.
#include <version-config.h>
#endif
+#include <sys/stat.h>
+#include <stdio.h>
#include <X11/X.h>
#include <X11/Xos.h> /* for unistd.h */
#include <X11/Xproto.h>
@@ -122,6 +124,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>
@@ -138,6 +164,9 @@ int main(int argc, char *argv[], char *envp[])
{
int i;
HWEventQueueType alwaysCheckForInput[2];
+#if defined(sun)
+ char *xauthfile = NULL;
+#endif
display = "0";
@@ -153,6 +182,12 @@ int 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)
diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index 281a6df..42e20ac 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -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;
@@ -234,6 +237,8 @@ OPENCONSOLE:
if (ioctl(xf86Info.consoleFd, VT_SETDISPINFO, atoi(display)) < 0)
xf86Msg(X_WARNING, "xf86OpenConsole: VT_SETDISPINFO failed\n");
+
+ xf86ConsoleFd = xf86Info.consoleFd;
}
#endif