Re: Shared folders without defined users

From: Todd Nemanich (no email)
Date: Tue Sep 04 2001 - 13:16:35 EDT


Rob O'Connor wrote:

> Wondering if there's a way of setting up a folder hierarchy (I'm using
> cyrus imap 1.6.24) without relying on users already having personal
> inboxes defined. Basically I want to set up a server dedicated to
> shared folders *only*. I've run some tests and it seems that a user
> needs to have a personal inbox defined before any subscriptions to other
> folders outside of the 'user.' hierarchy can take place.
>
> This is probably a case of me trying to use cyrus outside of the scope
> for which it was designed but I need the facilities to be able to set
> acls on folders, but without the hassle of creating unnecessary inboxes
> for each user -so it's not quite news (need those acls), and not quite
> personal mail - really a bulletin board system with access control.
>
>
> Rob.

I have a patch that will allow users to hold a subs file without having
an INBOX. However, if you apply this patch, you will have to manually
cleanup the subs files when you delete a user's account. You need to add
-DINBOXLESS_SUBSCRIBE when you compile cyrus.
        As a note, there are a couple of issues with this related to mozilla.
Some mozilla clients apparantly will keep trying to select INBOX, even
if it does not exist. Also, some mozilla clients had trouble with using
. as a seperator. My patch has a little bit of translation to deal with
this, but it keeps everything as dots internally.
        If you come across any issues with this patch, please let me know. THX.

diff -Naur ../cyrus-imapd-1.6.24/imap/imapd.c cyrus-imapd-1.6.24/imap/imapd.c
--- ../cyrus-imapd-1.6.24/imap/imapd.c Wed Jul 11 11:21:04 2001
+++ cyrus-imapd-1.6.24/imap/imapd.c Mon Jul 2 21:39:45 2001
@@ -2982,6 +2982,7 @@
     int r;
     char mailboxname[MAX_MAILBOX_NAME+1];
 
+#ifndef INBOXLESS_SUBSCRIBE
     if (namespace) lcase(namespace);
     if (!namespace || !strcmp(namespace, "mailbox")) {
         r = mboxname_tointernal(name, imapd_userid, mailboxname);
@@ -2997,6 +2998,15 @@
                add ? "Subscribe" : "Unsubscribe");
         return;
     }
+#else
+/* syslog(LOG_NOTICE,"INBOXLESS_SUBSCRIBE worked...."); */
+ r = mboxname_tointernal(name, imapd_userid, mailboxname);
+/* syslog(LOG_NOTICE,"mboxname_tointernal(%s,%s,%s) = %d",name,imapd_userid,mailboxname,r); */
+ if (!r) {
+ r = mboxlist_changesub(mailboxname, imapd_userid, imapd_authstate, add);
+/* syslog(LOG_NOTICE,"mboxlist_changesub: %d",r); */
+ }
+#endif
 
     if (r) {
         prot_printf(imapd_out, "%s NO %s: %s\r\n", tag,
diff -Naur ../cyrus-imapd-1.6.24/imap/mboxlist.c cyrus-imapd-1.6.24/imap/mboxlist.c
--- ../cyrus-imapd-1.6.24/imap/mboxlist.c Thu Dec 30 16:07:26 1999
+++ cyrus-imapd-1.6.24/imap/mboxlist.c Mon Jul 9 15:17:28 2001
@@ -116,7 +116,7 @@
 {
     unsigned long offset, len, partitionlen, acllen;
     char optionbuf[MAX_MAILBOX_NAME+1];
- char *partition, *acl;
+ char *partition, *acl, *tmp;
     const char *root;
     static char pathresult[MAX_MAILBOX_PATH];
     static char *aclresult;
@@ -124,9 +124,20 @@
 
     mboxlist_reopen();
 
+#ifdef INBOXLESS_SUBSCRIBE
+ tmp=name;
+ while(*tmp) {
+ if (*tmp == '/') {
+ *tmp='.';
+ }
+ tmp++;
+ }
+#endif
+
     /* Find mailbox */
     offset = bsearch_mem(name, 1, list_base, list_size, 0, &len);
     if (!len) {
+/* syslog(LOG_NOTICE,"bsearch_mem(%s,1,%s,%dl,0,%d)",name,list_base,list_size,len); */
         return IMAP_MAILBOX_NONEXISTENT;
     }
         
@@ -1507,24 +1518,39 @@
     const char *subs_base;
     unsigned long subs_size;
     char *subsfname, *newsubsfname;
+ char *tmp;
     unsigned long offset, len;
     struct iovec iov[10];
     int num_iov;
     int n;
     
+/* Change slashes to dots. fscking mozilla!! */
+#ifdef INBOXLESS_SUBSCRIBE
+ tmp=name;
+ while(*tmp) {
+ if (*tmp == '/') {
+ *tmp='.';
+ }
+ tmp++;
+ }
+#endif
+
     if (r = mboxlist_opensubs(userid, 1, &subsfd, &subs_base, &subs_size,
                               &subsfname, &newsubsfname)) {
+/* syslog(LOG_NOTICE,"mboxlist_opensubs failed: %d",r); */
         return r;
     }
 
     if (add) {
         /* Ensure mailbox exists and can be either seen or read by user */
         if (r = mboxlist_lookup(name, (char **)0, &acl)) {
+/* syslog(LOG_NOTICE,"mboxlist_lookup failed: %d",r); */
             mboxlist_closesubs(subsfd, subs_base, subs_size);
             return r;
         }
         if ((acl_myrights(auth_state, acl) & (ACL_READ|ACL_LOOKUP)) == 0) {
             mboxlist_closesubs(subsfd, subs_base, subs_size);
+/* syslog(LOG_NOTICE,"acl_myrights failed: %d",acl_myrights(auth_state,acl) & (ACL_READ|ACL_LOOKUP)); */
             return IMAP_MAILBOX_NONEXISTENT;
         }
     }
@@ -1900,15 +1926,22 @@
     const char *lockfailaction;
     char inboxname[MAX_MAILBOX_NAME+1];
 
- /* Users without INBOXes may not keep subscriptions */
     if (strchr(userid, '.') || strlen(userid) + 6 > MAX_MAILBOX_NAME) {
         return IMAP_PERMISSION_DENIED;
     }
+
+/*
+ We take this out. This will allow INBOXless users
+ to have a subscription file.
+*/
+#ifndef INBOXLESS_SUBSCRIBE
+ /* Users without INBOXes may not keep subscriptions */
     strcpy(inboxname, "user.");
     strcat(inboxname, userid);
     if (mboxlist_lookup(inboxname, (char **)0, (char **)0) != 0) {
         return IMAP_PERMISSION_DENIED;
     }
+#endif
 
     if (subsfname) {
         free(subsfname);








Hosted Email Solutions

Invaluement Anti-Spam DNSBLs



Powered By FreeBSD   Powered By FreeBSD