noselect_fix_enable incomplete?

Dave McMurtrie <[email protected]> Sun, 04 Dec 2011 10:23:48 -0500
Newsgroups gmane.mail.squirrelmail.devel
Message-ID <[email protected]>
Dear SquirrelMail Developers,

I discovered that Squirrelmail 1.4.22 with $noselect_fix_enable set does 
not seem to be a complete fix, at least in a Cyrus 2.4.x environment. 
I'm not asserting that it would be a complete solution for earlier Cyrus 
versions (or for other IMAP servers, for that matter) but I've only 
tested it in a Cyrus 2.4.x environment.

What I observed is that even with $noselect_fix_enable set to true, I 
had hierarchy levels (not mailboxes) being rendered in left_main.php as 
clickable links.  If a user clicks on one of these links, SquirrelMail 
issues a SELECT to the IMAP server, and the server returns an error 
because NoSelect is set for that hierarchy level.  I also discovered a 
similar issue when selecting "All Folders" from the search page. 
SquirrelMail would eventually attempt to SELECT a hierarchy level to 
search it and an error would be returned.

The code at line 610 in functions/imap_mailbox.php that conditionally 
constructs the LSUB does the correct thing:

         if ($noselect_fix_enable) {
             $lsub_args = "LSUB \"$folder_prefix\" \"*%\"";
         } else {
             $lsub_args = "LSUB \"$folder_prefix\" \"*\"";
         }

However, even if the NoSelect flag is returned in the LSUB response, 
it's thrown away when find_mailbox_name() is called at line 633.  No 
later code expects to be able to glean NoSelect status from this LSUB 
response, so this isn't a problem.  Instead, SquirrelMail calls LIST for 
each subscribed mailbox at line 662 to get all the mailbox flags.  The 
problem I'm seeing is that the LIST isn't constructed similarly to the 
above LSUB and no data is returned at all for things like hierarchy 
levels that aren't mailboxes.  Here's a protocol example using imtest 
against the cmu.misc level of hierarchy on our IMAP server:

1 LIST "" "cmu.misc"
1 OK Completed (0.000 secs 30 calls)
2 LIST "" "cmu.misc%"
* LIST (\Noselect \NonExistent \HasChildren) "." cmu.misc
2 OK Completed (0.000 secs 30 calls)

Attached is a patch that completes the $noselect_fix_enable fix in our 
environment.  Can anyone else confirm whether or not 
$noselect_fix_enable works in different environments than ours?

Let me know if you require any additional information.

Thanks!

Dave
--
Dave McMurtrie, SPE
Email Systems Technical Lead
Carnegie Mellon University,
Computing Services

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d

-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: [email protected]
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel
noselect_fix.patch (text/plain, 655 B)
--- imap_mailbox.php.orig	2011-12-04 10:10:41.000000000 -0500
+++ imap_mailbox.php	2011-12-04 10:13:01.000000000 -0500
@@ -659,7 +659,13 @@
                 $mbx = $sorted_lsub_ary[$i];
             }
 
-            $read = sqimap_run_command ($imap_stream, "LIST \"\" \"$mbx\"",
+            if ($noselect_fix_enable) {
+                $list_args = "LIST \"\" \"$mbx%\"";
+            } else {
+                $list_args = "LIST \"\" \"$mbx\"";
+            }
+
+            $read = sqimap_run_command ($imap_stream, $list_args,
                                         true, $response, $message);
 
             /* Another workaround for literals */