Bugs in LIST/LSUB & bug in using DOTCHAR if altnamespace=1

Alexander Drozdov sorcerer at elbrus.ru
Tue Oct 11 03:57:34 EDT 2005


There are 4 problems:

1. LIST and LSUB commands don't return "INBOX" and subfolders if
   userid have dot (".") in the name and unixhierarchysep config
   variable is not set.

My imapd.conf file is simple:

configdirectory: <somedir>
partition-default: <somedir>
loginrealms: domain.ru

I have some test users on the server.

Let we send some commands to IMAP server.

. login u3 at domain.ru q
. OK User logged in
. list "" *
* LIST (\HasChildren) "." "sf1"
* LIST (\HasNoChildren) "." "sf1.subfolder"
* LIST (\HasChildren) "." "sf2"
* LIST (\HasNoChildren) "." "sf2.subfolder"
* LIST (\HasNoChildren) "." "user.u2 at domain^ru.sssssss"
* LIST (\HasChildren) "." "user.u3 at domain^ru"
* LIST (\HasNoChildren) "." "user.u3 at domain^ru.te^st1"
* LIST (\HasNoChildren) "." "user.u3 at domain^ru.te^st2"
* LIST (\HasNoChildren) "." "user.u3 at domain^ru.te^st3"
. OK Completed (0.010 secs 10 calls)

We can see that server doesn't return INBOX and subfolders. Instead,
user.u3 at domain^ru* is returned.

You can see my patch to this bug in the file named "dottedid_inbox.diff"

2. glob.c: glob_test() function returns wrong matches in some cases.

The same configuration of the server.

. list "" u%e
* LIST (\Noselect \HasChildren) "." "user"
. OK Completed (0.000 secs 6 calls)

This is because glob_test() function increments ptr variable when
pattern <sometext>%<char> doesn't match instead staying at the current
place. The function generates partial match in this and some other
cases. My patch just exchanges 'ptr' and 'phier' roles as it was made in
case if wildcard symbol is '*'. I've also added a special case to this
function - detecting <sometext>%<sep_char><sometext>.

You can see my patch to this bug in the file named "glob_test.diff"

3. Treating "^" as "." in user's input in some cases when
   unixhierarchysep config variable is enabled.

imapd.conf:
configdirectory: <somedir>
partition-default: <somedir>
loginrealms: domain.ru
unixhierarchysep: 1

commands:
. login u3 at domain.ru q
. OK User logged in
. list "" *
* LIST (\HasChildren) "/" "INBOX"
* LIST (\HasNoChildren) "/" "INBOX/te.st1"
* LIST (\HasNoChildren) "/" "INBOX/te.st2"
* LIST (\HasNoChildren) "/" "INBOX/te.st3"
* LIST (\HasChildren) "/" "sf1"
* LIST (\HasNoChildren) "/" "sf1/subfolder"
* LIST (\HasChildren) "/" "sf2"
* LIST (\HasNoChildren) "/" "sf2/subfolder"
* LIST (\HasNoChildren) "/" "user/u2 at domain.ru/sssssss"
. OK Completed (0.010 secs 10 calls)
. select "INBOX/te^st1"
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen \*)]  
* 0 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1128607745]  
* OK [UIDNEXT 1]  
. OK [READ-WRITE] Completed

You can see my patch to this bug in the file named
"fail_dotchar.diff". I just deny user to use "^" in mailboxnames in
functions mboxname.c:mboxname_tointernal*. You may say that there are
some other places in the server code where working with maiboxnames
sended by user take place. You are right, but see the next patch.

4. Wrong result of LIST and LSUB commands in some cases where
   altnamespace config variable is enabled.

imapd.conf:
configdirectory: <somedir>
partition-default: <somedir>
loginrealms: domain.ru
altnamespace: 1

You may also enable unixhierarchysep variable in imapd.conf.

commands:
. login sorcerer q
. OK User logged in
. list "" *
* LIST (\Noinferiors) "." "INBOX"
* LIST (\HasNoChildren) "." "public"
* LIST (\HasNoChildren) "." "test.test"
* LIST (\HasChildren) "." "Other Users.u1"
* LIST (\HasNoChildren) "." "Other Users.u1.u1public"
* LIST (\HasNoChildren) "." "Other Users.u2.sp"
* LIST (\HasChildren) "." "Other Users.u3"
* LIST (\HasChildren) "." "Other Users.u3.supertestdir"
* LIST (\HasNoChildren) "." "Other Users.u3.supertestdir.subdir"
* LIST (\HasChildren) "." "Shared Folders.sf1"
* LIST (\HasNoChildren) "." "Shared Folders.sf1.subfolder"
* LIST (\HasChildren) "." "Shared Folders.sf2"
* LIST (\HasNoChildren) "." "Shared Folders.sf2.subfolder"
. OK Completed (0.010 secs 14 calls)
. list "" O*u*
* LIST (\HasChildren) "." "Other Users.u1"
* LIST (\HasNoChildren) "." "Other Users.u1.u1public"
* LIST (\HasNoChildren) "." "Other Users.u2.sp"
* LIST (\HasChildren) "." "Other Users.u3"
* LIST (\HasChildren) "." "Other Users.u3.supertestdir"
* LIST (\HasNoChildren) "." "Other Users.u3.supertestdir.subdir"
. OK Completed (0.010 secs 7 calls)

You may think that it is OK, but:
. list "" O*U*
. OK Completed (0.000 secs 1 calls)

Why? Because imap server tries to translates any pattern from user's
namespace to the internal one and than compares internal mailboxnames
with it. In my opinion such translation is impossible. In our case the
real pattern is not "O*U*". It is "*U*", and mailbox
"user.u1.u1public" and other are comparing with this pattern. I
believe that there is the only way to fix it: it is not to try to
change nor pattern or mailboxnames. I have made it in the patch
"patterns.diff".

There is another reason why I need to modify the current behaviour. My
primary task is to add such new functionality to the imap server that
the server could hide real userids and show other ones which it may
get from, for example, LDAP. I have to made trivial modifications in
the file imapd/mboxname.c to add this ability to the server. But
nothing works because LIST and LSUB handlers don't call functions from
imapd/mboxname.c when it is needed and compare with internal names
instead of user's namespace mailboxnames.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 7000 bytes
Desc: cyrus-imap-patches.tar.bz2
Url : https://lists.andrew.cmu.edu/mailman/private/cyrus-devel/attachments/20051011/af92e6a9/attachment-0001.obj


More information about the Cyrus-devel mailing list