diff --git a/dix/main.c b/dix/main.c
index 0fb2a18..68d5263 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,36 @@ extern void DtloginCloseDown(void);
extern void Dispatch(void);
+#if defined(sun)
+extern const char * GetAuthFilename(void);
+static char sym_authfile[40];
+
+#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;
+
+ snprintf(sym_authfile, 40, LOCK_PREFIX "%s", display);
+
+ mkdir(LOCK_PREFIX, S_IRWXU);
+
+ remove(sym_authfile);
+ symlink(filename, sym_authfile);
+}
+
+void
+RemoveXauthSymFile(void)
+{
+ remove(sym_authfile);
+}
+#endif
+
#ifdef XQUARTZ
#include <pthread.h>
@@ -137,6 +169,9 @@ dix_main(int argc, char *argv[], char *envp[])
{
int i;
HWEventQueueType alwaysCheckForInput[2];
+#if defined(sun)
+ char *xauthfile = NULL;
+#endif
display = "0";
@@ -150,6 +185,12 @@ dix_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 15e5645..7c5dc25 100644
@@ -46,6 +46,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 UseConsole = FALSE;
@@ -232,6 +235,8 @@ xf86OpenConsole(void)
if (ioctl(xf86Info.consoleFd, VT_SETDISPINFO, atoi(display)) < 0)
xf86Msg(X_WARNING, "xf86OpenConsole: VT_SETDISPINFO failed\n");
+
+ xf86ConsoleFd = xf86Info.consoleFd;
}
#endif
diff --git a/os/log.c b/os/log.c
index 3db5c53..258c09f 100644
--- a/os/log.c
+++ b/os/log.c
@@ -107,6 +107,10 @@ OR PERFORMANCE OF THIS SOFTWARE.
void (*OsVendorVErrorFProc) (const char *, va_list args) = NULL;
#endif
+#ifdef sun
+extern void RemoveXauthSymFile(void);
+#endif
+
static FILE *logFile = NULL;
static int logFileFd = -1;
static Bool logFlush = FALSE;
@@ -937,6 +941,9 @@ FatalError(const char *f, ...)
VErrorFSigSafe(f, args);
va_end(args);
ErrorFSigSafe("\n");
+#ifdef sun
+ RemoveXauthSymFile();
+#endif
if (!beenhere)
OsVendorFatalError(f, args2);
va_end(args2);