4b5b9a
diff -up tigervnc-1.0.90-20091221svn3929/unix/vncserver.cookie tigervnc-1.0.90-20091221svn3929/unix/vncserver
4b5b9a
--- tigervnc-1.0.90-20091221svn3929/unix/vncserver.cookie	2009-11-12 11:39:54.000000000 +0100
4b5b9a
+++ tigervnc-1.0.90-20091221svn3929/unix/vncserver	2009-12-21 16:15:01.907799091 +0100
4b5b9a
@@ -189,27 +189,12 @@ $vncPort = 5900 + $displayNumber;
4b5b9a
 $desktopLog = "$vncUserDir/$host:$displayNumber.log";
4b5b9a
 unlink($desktopLog);
4b5b9a
 
4b5b9a
-# Make an X server cookie - use /dev/urandom on systems that have it,
4b5b9a
-# otherwise use perl's random number generator, seeded with the sum
4b5b9a
-# of the current time, our PID and part of the encrypted form of the password.
4b5b9a
-
4b5b9a
-my $cookie = "";
4b5b9a
-if (open(URANDOM, '<', '/dev/urandom')) {
4b5b9a
-  my $randata;
4b5b9a
-  if (sysread(URANDOM, $randata, 16) == 16) {
4b5b9a
-    $cookie = unpack 'h*', $randata;
4b5b9a
-  }
4b5b9a
-  close(URANDOM);
4b5b9a
-}
4b5b9a
-if ($cookie eq "") {
4b5b9a
-  srand(time+$$+unpack("L",`cat $vncUserDir/passwd`));
4b5b9a
-  for (1..16) {
4b5b9a
-    $cookie .= sprintf("%02x", int(rand(256)) % 256);
4b5b9a
-  }
4b5b9a
-}
4b5b9a
-
4b5b9a
-system("xauth -f $xauthorityFile add $host:$displayNumber . $cookie");
4b5b9a
-system("xauth -f $xauthorityFile add $host/unix:$displayNumber . $cookie"); 
4b5b9a
+# Make an X server cookie - use mcookie
4b5b9a
+$cookie = `/usr/bin/mcookie`;
4b5b9a
+open (XAUTH, "|xauth -f $xauthorityFile source -");
4b5b9a
+print XAUTH "add $host:$displayNumber . $cookie\n";
4b5b9a
+print XAUTH "add $host/unix:$displayNumber . $cookie\n";
4b5b9a
+close XAUTH;
4b5b9a
 
4b5b9a
 if ($opt{'-name'}) {
4b5b9a
     $desktopName = $opt{'-name'};