Adam Tkac 5009736
--- vnc-4_1-unixsrc/unix/vncserver.cookie	2005-02-23 12:28:18.000000000 +0000
Adam Tkac 5009736
+++ vnc-4_1-unixsrc/unix/vncserver	2005-03-03 22:04:28.000000000 +0000
Adam Tkac 5009736
@@ -116,18 +116,12 @@
Adam Tkac 5009736
 $desktopLog = "$vncUserDir/$host:$displayNumber.log";
Adam Tkac 5009736
 unlink($desktopLog);
Adam Tkac 5009736
 
Adam Tkac 5009736
-# Make an X server cookie - use as the seed the sum of the current time, our
Adam Tkac 5009736
-# PID and part of the encrypted form of the password.  Ideally we'd use
Adam Tkac 5009736
-# /dev/urandom, but that's only available on Linux.
Adam Tkac 5009736
-
Adam Tkac 5009736
-srand(time+$$+unpack("L",`cat $vncUserDir/passwd`));
Adam Tkac 5009736
-$cookie = "";
Adam Tkac 5009736
-for (1..16) {
Adam Tkac 5009736
-    $cookie .= sprintf("%02x", int(rand(256)) % 256);
Adam Tkac 5009736
-}
Adam Tkac 5009736
-    
Adam Tkac 5009736
-system("xauth -f $xauthorityFile add $host:$displayNumber . $cookie");
Adam Tkac 5009736
-system("xauth -f $xauthorityFile add $host/unix:$displayNumber . $cookie"); 
Adam Tkac 5009736
+# Make an X server cookie - use mcookie
Adam Tkac 5009736
+$cookie = `/usr/bin/mcookie`;
Adam Tkac 5009736
+open (XAUTH, "|xauth -f $xauthorityFile source -");
Adam Tkac 5009736
+print XAUTH "add $host:$displayNumber . $cookie\n";
Adam Tkac 5009736
+print XAUTH "add $host/unix:$displayNumber . $cookie\n";
Adam Tkac 5009736
+close XAUTH;
Adam Tkac 5009736
 
Adam Tkac 5009736
 if ($opt{'-name'}) {
Adam Tkac 5009736
     $desktopName = $opt{'-name'};