[LOSTWAGES] service.cgi - support arbitrary "cookies"

Brian Vincent vinn at theshell.com
Mon Mar 29 11:36:31 CST 2004


Changelog:
    Rather than require a "mask" file for storing cookies,
    store them all internally as md5 so we always know what
    to expect.

Index: service.cgi
===================================================================
RCS file: /home/wine/tools/winetest/service.cgi,v
retrieving revision 1.6
diff -u -r1.6 service.cgi
--- service.cgi	24 Mar 2004 19:36:40 -0000	1.6
+++ service.cgi	29 Mar 2004 17:31:39 -0000
@@ -38,6 +38,7 @@
 #			clients can download, must be writable
 
 use Date::Calc qw(Delta_DHMS);
+use Digest::MD5;
 
 $hour_we_do_build = "2";     # hour, such as 2 or 17, in localtime, rounded up
 $path_to_test_directories="/home/winehq/opt/winetest/";
@@ -57,7 +58,7 @@
     if ($data_received{"publish"}) {
         $cookie_current = read_cookie($data_received{"publish"});
         $cookie_to_save = &get_new_cookie;
-   
+
         # Cookies should never be the same.  Some day we could return an error 
         if ($cookie_to_save eq $cookie_current) {
             print "OK\n";
@@ -70,7 +71,7 @@
         exit;
     }
 
-    if ($data_received{"winrash"} ne $cookie{"winrash"}) {
+    if (convert_to_md5($data_received{"winrash"}) ne $cookie{"winrash"}) {
         send_upgrade("winrash",$cookie{"winrash"});
         exit;
     }
@@ -115,7 +116,7 @@
 
      my $path_to_mask = $path_to_test_directories . $data_received{"publish"}
                         . "/url.mask";
-     my $cookie_url   = $data_received{"url"} . ".cookie";
+     my $cookie_url   = $data_received{"url"} . ".sig";
      my $url_mask     = "";
      my $this_cookie  = "";
 
@@ -127,8 +128,7 @@
      }
 
      $this_cookie = getoneline("$path_to_lynx -source $cookie_url |"); 
-
-     return $this_cookie;
+     return convert_to_md5($this_cookie);
 }
 
 sub save_new_cookie {
@@ -137,16 +137,6 @@
     my $path_to_cookie = $path_to_test_directories . $data_received{"publish"}
                          . "/cookie";
     
-    if(length($cookie) != 32) {
-	debug("MD5sum is " . length($cookie) . ", not 32 characters long? "); 
-	die;
-    }
-
-    if($cookie =~ /[^0-9^A-Z^a-z]/) {
-	debug("Why do we have non-alpha characters in the MD5sum?");
-	die; 
-    }
-
     open(COOKIE_FH, "> $path_to_cookie") 
 	or ( debug("Can't open $path_to_cookie for writing.") && die );
     print COOKIE_FH "$cookie";
@@ -166,6 +156,13 @@
     close(URL_FH);
 }
 
+sub convert_to_md5 {
+
+    local $md5 = Digest::MD5->new;
+    $md5->add($_[0]);
+    return $md5->hexdigest; 
+}
+
 ##########################################################################
 # 
 # Issue commands understood by winrash.  Try to be somewhat intelligent
@@ -293,7 +290,7 @@
 #
 # Some convenience functions.  User_Data splits our name/value pairs
 # by taking GET or POST for input.  Useful for running on the commandline
-# by setting QUERY_STRING.  Debug gives us output if debug=1. Getoneline 
+# by setting QUERY_STRING.  Debug gives us output if debug=1. getoneline 
 # just opens files and returns one line, with trailing new lines removed.
 #  
 ##########################################################################



More information about the wine-patches mailing list