Worked on GETACL a little bit
authorArt Cancro <ajc@citadel.org>
Wed, 10 Jan 2007 04:36:06 +0000 (04:36 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 10 Jan 2007 04:36:06 +0000 (04:36 +0000)
citadel/imap_acl.c
citadel/room_ops.c

index 75a791fa2ce91b99813a25af12c53fef3a97d095..2f8bf24ee152125b9ef3a897dfcdb118aee52ab6 100644 (file)
@@ -73,13 +73,86 @@ void imap_deleteacl(int num_parms, char *parms[]) {
 }
 
 
+
 /*
  * Implements the GETACL command.
  */
 void imap_getacl(int num_parms, char *parms[]) {
-
-       cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
-       return;
+       char roomname[ROOMNAMELEN];
+       char savedroom[ROOMNAMELEN];
+       int msgs, new;
+       int ret;
+       struct ctdluser temp;
+       struct cdbdata *cdbus;
+       int ra;
+       char rights[32];
+
+       if (num_parms != 3) {
+               cprintf("%s BAD usage error\r\n", parms[0]);
+               return;
+       }
+
+       ret = imap_grabroom(roomname, parms[2], 0);
+       if (ret != 0) {
+               cprintf("%s NO Invalid mailbox 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);
+
+       cprintf("* ACL");
+       cprintf(" ");
+       imap_strout(parms[2]);
+
+       /*
+        * Traverse the userlist
+        */
+       cdb_rewind(CDB_USERS);
+       while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
+               memset(&temp, 0, sizeof temp);
+               memcpy(&temp, cdbus->ptr, sizeof temp);
+               cdb_free(cdbus);
+
+               CtdlRoomAccess(&CC->room, &temp, &ra, NULL);
+               if (strlen(temp.fullname) > 0) {
+                       strcpy(rights, "");
+
+                       /* Known, zapped, etc. mailboxes can probably be LIST-ed */
+                       /* FIXME don't give away hidden rooms */
+                       if (ra & UA_GOTOALLOWED)        strcat(rights, "l");
+
+                       /* Known rooms can be LSUB-ed */
+                       if (ra & UA_KNOWN)              strcat(rights, "r");
+
+                       /* FIXME do the rest */
+
+                       if (strlen(rights) > 0) {
+                               cprintf(" ");
+                               imap_strout(temp.fullname);
+                               cprintf(" %s", rights);
+                       }
+               }
+       }
+
+       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 GETACL completed\r\n", parms[0]);
 }
 
 
index 05bced87c7874af7a020343b23294a5c72c3411e..285256807dd7fc05ffa0a46552f902dbac7735d1 100644 (file)
@@ -1045,23 +1045,6 @@ void cmd_whok(void)
        struct cdbdata *cdbus;
        int ra;
 
-       getuser(&CC->user, CC->curr_user);
-
-       /*
-        * This command is only allowed by aides, room aides,
-        * and room namespace owners
-        */
-       if (is_room_aide()
-          || (atol(CC->room.QRname) == CC->user.usernum) ) {
-               /* access granted */
-       }
-       else {
-               /* access denied */
-                cprintf("%d Higher access or room ownership required.\n",
-                        ERROR + HIGHER_ACCESS_REQUIRED);
-                return;
-        }
-
        cprintf("%d Who knows room:\n", LISTING_FOLLOWS);
        cdb_rewind(CDB_USERS);
        while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {