Author: Mike O'Connor <stew@vireo.org>
Subject: fix missing xauth documentation and missing auth token case

--- a/gnuserv.1
+++ b/gnuserv.1
@@ -245,6 +245,11 @@ to "kali,"  the `xauth list' output shou
 KALI.FTM.CS.CMU.EDU:999  MIT-MAGIC-COOKIE-1  1234
 .RE
 .PP
+To create the cookie, you can use a command like 
+.RS 4
+xauth add `hostname`:999 MIT-MAGIC-COOKIE-1 `head -c512 /dev/urandom|md5sum`
+.RE
+.PP
 For more information on authorization files, take a look at the
 xauth(1X11) man page, or invoke xauth interactively (without any
 arguments) and type "help" at the prompt. Remember that case in the
--- a/gnuserv.c
+++ b/gnuserv.c
@@ -622,7 +622,19 @@ setup_table (void)
 				   sizeof(host_addr), (char *)&host_addr,
 				   strlen(MCOOKIE_SCREEN), MCOOKIE_SCREEN,
 				   strlen(MCOOKIE_X_NAME), MCOOKIE_X_NAME);
-  hosts++;
+
+  /* Fix suggested by Roderick Schertler <roderick@argon.org> to
+     handle cases where there's no authorization data. */
+  if (server_xauth)
+    {
+      if (server_xauth->data)
+        hosts++;
+      else
+	{
+	  XauDisposeAuth (server_xauth);
+	  server_xauth = NULL;
+	}
+    }
 
 #endif /* AUTH_MAGIC_COOKIE */
 
