> >>> Hi.  At http://wiki.dovecot.org/ManageSieve#line-229 , I want to
> >>> download the patch that's supposed to fix two problems in Avelsieve.
> >>> Unfortunately, when I click on the link to the patch, I always get
> >>> an error message:
> >>>
> >>> You are not allowed to do AttachFile on this page.
> >>
> >> Ouch, sorry, I advised Timo to disable AttachFile because somebody
> >> was using the dovecot wiki to distribute some key files for something
> >> that had nothing to do with dovecot.
> >
> > Johannes, thanks.  While we're waiting for that to get sorted out,
> > could someone be so kind as to email me the patch?  Thanks, Andrew.
>
> Ok, that is not practical. I've recovered it from my mail discussion
> with Hanspeter Kunz who provided the definitive version of this patch.
> I've put it online here:
>
> http://www.rename-it.nl/dovecot/client-patches/avelsieve-1.9.7-dovecot.d
>iff

Stephan, thank you.  I applied the patch and it seems to work fine.

For anyone else who wants the patch, I'm attaching it here in diff -urN 
format.

I hope we can get attachment downloads working soon in the wiki.

Thanks,
Andrew.

diff -urNb avelsieve.orig/include/managesieve.lib.php avelsieve/include/managesieve.lib.php
--- avelsieve.orig/include/managesieve.lib.php	2008-05-20 13:13:29.000000000 -0400
+++ avelsieve/include/managesieve.lib.php	2008-07-05 06:46:18.000000000 -0400
@@ -82,6 +82,12 @@
    * a comma seperated list of allowed auth types, in order of preference
    */
   var $auth_types;
+
+  /** 
+   * options
+   */
+  var $broken_tls;
+
   /**
    * type of authentication attempted
    */
@@ -311,6 +317,9 @@
     else
         $this->auth = $auth;
     $this->auth_types=$auth_types;	/* Allowed authentication types */
+
+    $this->broken_tls = false;
+
     $this->fp=0;
     $this->line="";
     $this->retval="";
@@ -484,6 +493,10 @@
         } /* end if */
         elseif(is_string($this->modules))
             $this->capabilites[$this->cap_type][$this->module]=true;
+
+        // set broken_tls. Older cyrus servers do not respond with 
+        // capabilities after STARTTLS
+        $broken_tls = true;
     }
 
     if(sieve::status($this->line) == F_NO){		//here we should do some returning of error codes?
@@ -504,8 +517,13 @@
             return false;
         } else {
             $this->loggedin = true;
-            // RFC says that we need to ask for the capabilities again
+            // RFC says that we get an unsolicited capability response after TLS negotiation. Older Cyrus
+            // did not do this. If the server has old/broken TLS we need to send a CAPABILITY command,
+            // otherwise we just parse the unsolicited capability response. 
+            if ( $this->broken_tls )
             $this->sieve_get_capability();
+            else
+                $this->sieve_read_capability_response();
             $this->loggedin = false;
         }
     }
@@ -817,14 +835,11 @@
   }
 
   /**
-   * Return an array of available capabilities.
+   * Read incoming capability response.
    *
    * @return array
    */
-  function sieve_get_capability() {
-    if($this->loggedin==false)
-        return false;
-    fputs($this->fp, "CAPABILITY\r\n"); 
+  function sieve_read_capability_response() {
     $this->line=fgets($this->fp,1024);
 
     $tmp = array();
@@ -876,8 +891,20 @@
     return $this->capabilities['modules'];
   }
 
-}
+  /**
+   * Return an array of available capabilities.
+   *
+   * @return array
+   */
+  function sieve_get_capability() {
 
+    if($this->loggedin==false)
+        return false;
+    fputs($this->fp, "CAPABILITY\r\n");
+
+    return $this->sieve_read_capability_response();
+  }
+}
 
 /**
  * The following functions are support functions and might be handy to the
diff -urNb avelsieve.orig/table.php avelsieve/table.php
--- avelsieve.orig/table.php	2008-05-20 13:13:29.000000000 -0400
+++ avelsieve/table.php	2008-07-05 06:52:47.000000000 -0400
@@ -162,6 +162,7 @@
 	    if (!$conservative) {
 		    $s->login();
 		    if(sizeof($rules) == 0) {
+		        $s->setactive('');
 				$s->delete('phpscript');
 			}  else {
 		        $newscript = makesieverule($rules);

Reply via email to