]> code.citadel.org Git - citadel.git/blobdiff - citadel/imap_acl.c
struct recptypes now uses dynamically allocated
[citadel.git] / citadel / imap_acl.c
index cda6df09d37a13de4b9f332c73618aeb192fafd4..204b5473977ffd381c8104d605359460bbe98a1b 100644 (file)
@@ -111,12 +111,21 @@ void imap_acl_flags(char *rights, int ra)
                /* t - delete messages (set/clear \Deleted flag) */
                if (ra & UA_DELETEALLOWED) {
                        strcat(rights, "t");
+                       strcat(rights, "d");
                }
 
                /* a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) */
                /* x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) */
                if (ra & UA_ADMINALLOWED) {
-                       strcat(rights, "a");
+                       /*
+                        * This is the correct place to put the "a" flag.  We are leaving
+                        * it commented out for now, because it implies that we could
+                        * perform any of SETACL/DELETEACL/GETACL/LISTRIGHTS.  Since these
+                        * commands are not yet implemented, omitting the flag should
+                        * theoretically prevent compliant clients from attempting to
+                        * perform them.
+                        */
+                       /* strcat(rights, "a"); * commented out */
                        strcat(rights, "x");
                }
        }
@@ -141,6 +150,9 @@ void imap_getacl(int num_parms, char *parms[]) {
                return;
        }
 
+       /*
+        * Search for the specified room or folder
+        */
        ret = imap_grabroom(roomname, parms[2], 0);
        if (ret != 0) {
                cprintf("%s NO Invalid mailbox name or access denied\r\n",
@@ -199,8 +211,76 @@ void imap_getacl(int num_parms, char *parms[]) {
  * Implements the LISTRIGHTS command.
  */
 void imap_listrights(int num_parms, char *parms[]) {
+       char roomname[ROOMNAMELEN];
+       char savedroom[ROOMNAMELEN];
+       int msgs, new;
+       int ret;
+       struct recptypes *valid;
+       struct ctdluser temp;
 
-       cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
+       if (num_parms != 4) {
+               cprintf("%s BAD usage error\r\n", parms[0]);
+               return;
+       }
+
+       /*
+        * Search for the specified room/folder
+        */
+       ret = imap_grabroom(roomname, parms[2], 0);
+       if (ret != 0) {
+               cprintf("%s NO Invalid mailbox name or access denied\r\n",
+                       parms[0]);
+               return;
+       }
+
+       /*
+        * Search for the specified user
+        */
+       ret = (-1);
+       valid = validate_recipients(parms[3]);
+       if (valid != NULL) {
+               if (valid->num_local == 1) {
+                       ret = getuser(&temp, valid->recp_local);
+               }
+               free_recipients(valid);
+       }
+       if (ret != 0) {
+               cprintf("%s NO Invalid user name or access denied\r\n",
+                       parms[0]);
+               return;
+       }
+
+       /*
+        * usergoto() formally takes us to the desired room.  (If another
+        * folder is selected, save its name so we can return there!!!!!)
+        */
+       if (IMAP->selected) {
+               strcpy(savedroom, CC->room.QRname);
+       }
+       usergoto(roomname, 0, 0, &msgs, &new);
+
+
+       /*
+        * Now output the list of rights
+        */
+       cprintf("* LISTRIGHTS ");
+       imap_strout(parms[2]);
+       cprintf(" ");
+       imap_strout(parms[3]);
+       cprintf(" ");
+       imap_strout("");                /* FIXME ... do something here */
+       cprintf("\r\n");
+
+
+       /*
+        * If another folder is selected, go back to that room so we can resume
+        * our happy day without violent explosions.
+        */
+       if (IMAP->selected) {
+               usergoto(savedroom, 0, 0, &msgs, &new);
+       }
+
+       cprintf("%s OK LISTRIGHTS completed\r\n", parms[0]);
        return;
 }