From: Art Cancro Date: Wed, 10 Jan 2007 04:36:06 +0000 (+0000) Subject: Worked on GETACL a little bit X-Git-Tag: v7.86~3683 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=e2e9fb4773896d506336d2064d49ddd5d2420a8d;p=citadel.git Worked on GETACL a little bit --- diff --git a/citadel/imap_acl.c b/citadel/imap_acl.c index 75a791fa2..2f8bf24ee 100644 --- a/citadel/imap_acl.c +++ b/citadel/imap_acl.c @@ -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]); } diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 05bced87c..285256807 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -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) {