--- file.php	2010-05-31 03:35:59.015894106 -0400
+++ file.new.php	2010-05-31 03:25:31.835687028 -0400
@@ -8,6 +8,7 @@
 class fileCache extends Cache {
   var $content = array();
   var $fspath = '/tmp/filecache';
+  var $allow_global_file_write;
   
   function page_fast_cache() {
     return TRUE;
@@ -21,6 +22,19 @@ class fileCache extends Cache {
     elseif (isset($default_options['path'])) {
       $this->fspath = $default_options['path'];
     }
+    
+    // Determine if the CacheRouter should grant global write privileges
+    // when creating new cache files 
+    if (isset($options['allow_global_file_write'])) {
+      $this->allow_global_file_write = $options['allow_global_file_write'] ? TRUE : FALSE;
+    }
+    elseif (isset($default_options['allow_global_file_write'])) {
+      $this->allow_global_file_write = $default_options['allow_global_file_write'] ? TRUE : FALSE;
+    }
+    else {
+      $this->allow_global_file_write = FALSE;
+    }
+	
     if (substr($this->fspath,-1) == '/') {
       $this->fspath = substr($this->fspath, 0, strlen($this->fspath) - 2);
     }
@@ -99,7 +113,12 @@ class fileCache extends Cache {
           flock($fp, LOCK_UN);
         }
         fclose($fp);
-        @chmod(0664, $file); // Necessary for non-webserver users.
+        if ($this->allow_global_file_write) {
+          @chmod($file, 0666); // Necessary for compatibility with drush
+        }
+        else {
+          @chmod($file, 0664); // Necessary for non-webserver users.
+        }
       }
       else {
         // t() may not be loaded
@@ -237,7 +256,12 @@ class fileCache extends Cache {
             }
           }
           else {
-            @chmod($dir, 0775); // Necessary for non-webserver users.
+            if ($this->allow_global_file_write) {
+              @chmod($dir, 0777); // Necessary for compatibility with drush.
+            }
+            else {
+              @chmod($dir, 0775); // Necessary for non-webserver users.
+            }
           }
         }
       }
