-/*
- * Functions which implement RFC2086 (and maybe RFC4314) (IMAP ACL extension)
- *
- * Copyright (c) 2007-2017 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
+// Functions which implement RFC2086 (and maybe RFC4314) (IMAP ACL extension)
+//
+// Copyright (c) 2007-2023 by the citadel.org team
+//
+// This program is open source software. Use, duplication or disclosure
+// is subject to the terms of the GNU General Public License, version 3.
#include "../../sysdep.h"
#include <stdlib.h>
#include "../../ctdl_module.h"
-/*
- * Implements the SETACL command.
- */
+// Implements the SETACL command.
void imap_setacl(int num_parms, ConstStr *Params) {
-
IReply("BAD not yet implemented FIXME");
return;
}
-/*
- * Implements the DELETEACL command.
- */
+// Implements the DELETEACL command.
void imap_deleteacl(int num_parms, ConstStr *Params) {
-
IReply("BAD not yet implemented FIXME");
return;
}
-/*
- * Given the bits returned by CtdlRoomAccess(), populate a string buffer
- * with IMAP ACL format flags. This code is common to GETACL and MYRIGHTS.
- */
-void imap_acl_flags(StrBuf *rights, int ra)
-{
+// Given the bits returned by CtdlRoomAccess(), populate a string buffer
+// with IMAP ACL format flags. This code is common to GETACL and MYRIGHTS.
+void imap_acl_flags(StrBuf *rights, int ra) {
FlushStrBuf(rights);
- /* l - lookup (mailbox is visible to LIST/LSUB commands)
- * r - read (SELECT the mailbox, perform STATUS et al)
- * s - keep seen/unseen information across sessions (STORE SEEN flag)
- */
- if ( (ra & UA_KNOWN) /* known rooms */
- || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED)) /* zapped rooms */
+ // l - lookup (mailbox is visible to LIST/LSUB commands)
+ // r - read (SELECT the mailbox, perform STATUS et al)
+ // s - keep seen/unseen information across sessions (STORE SEEN flag)
+ if ( (ra & UA_KNOWN) // known rooms
+ || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED)) // zapped rooms
) {
StrBufAppendBufPlain(rights, HKEY("l"), 0);
StrBufAppendBufPlain(rights, HKEY("r"), 0);
StrBufAppendBufPlain(rights, HKEY("s"), 0);
- /* Only output the remaining flags if the room is known */
+ // Only output the remaining flags if the room is known
- /* w - write (set or clear flags other than SEEN or DELETED, not supported in Citadel */
+ // w - write (set or clear flags other than SEEN or DELETED, not supported in Citadel
- /* i - insert (perform APPEND, COPY into mailbox) */
- /* p - post (send mail to submission address for mailbox - not enforced) */
- /* c - create (CREATE new sub-mailboxes) */
+ // i - insert (perform APPEND, COPY into mailbox)
+ // p - post (send mail to submission address for mailbox - not enforced)
+ // c - create (CREATE new sub-mailboxes)
if (ra & UA_POSTALLOWED) {
StrBufAppendBufPlain(rights, HKEY("i"), 0);
StrBufAppendBufPlain(rights, HKEY("p"), 0);
StrBufAppendBufPlain(rights, HKEY("c"), 0);
}
- /* d - delete messages (STORE DELETED flag, perform EXPUNGE) */
+ // d - delete messages (STORE DELETED flag, perform EXPUNGE)
if (ra & UA_DELETEALLOWED) {
StrBufAppendBufPlain(rights, HKEY("d"), 0);
}
- /* a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) */
+ // a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS)
if (ra & UA_ADMINALLOWED) {
- /*
- * 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.
- *
- * StrBufAppendBufPlain(rights, HKEY("a"), 0);
- */
+ // 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.
+ //
+ // StrBufAppendBufPlain(rights, HKEY("a"), 0);
}
}
}
-/*
- * Implements the GETACL command.
- */
+// Implements the GETACL command.
void imap_getacl(int num_parms, ConstStr *Params) {
char roomname[ROOMNAMELEN];
char savedroom[ROOMNAMELEN];
int msgs, new;
int ret;
struct ctdluser temp;
- struct cdbdata *cdbus;
+ struct cdbkeyval cdbus;
int ra;
StrBuf *rights;
return;
}
- /*
- * Search for the specified room or folder
- */
+ // Search for the specified room or folder
ret = imap_grabroom(roomname, Params[2].Key, 1);
if (ret != 0) {
IReply("NO Invalid mailbox name or access denied");
return;
}
- /*
- * CtdlUserGoto() formally takes us to the desired room. (If another
- * folder is selected, save its name so we can return there!!!!!)
- */
+ // CtdlUserGoto() 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);
}
IAPuts("* ACL ");
IPutCParamStr(2);
- /*
- * Traverse the userlist
- */
+ // Traverse the userlist
rights = NewStrBuf();
cdb_rewind(CDB_USERS);
- while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL)
- {
+ while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) { // always read through to the end
memset(&temp, 0, sizeof temp);
- memcpy(&temp, cdbus->ptr, sizeof temp);
- cdb_free(cdbus);
+ memcpy(&temp, cdbus.val.ptr, sizeof temp);
CtdlRoomAccess(&CC->room, &temp, &ra, NULL);
if (!IsEmptyStr(temp.fullname)) {
FreeStrBuf(&rights);
IAPuts("\r\n");
- /*
- * If another folder is selected, go back to that room so we can resume
- * our happy day without violent explosions.
- */
+ // If another folder is selected, go back to that room so we can resume
+ // our happy day without violent explosions.
if (IMAP->selected) {
CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL);
}
}
-/*
- * Implements the LISTRIGHTS command.
- */
+// Implements the LISTRIGHTS command.
void imap_listrights(int num_parms, ConstStr *Params) {
char roomname[ROOMNAMELEN];
char savedroom[ROOMNAMELEN];
return;
}
- /*
- * Search for the specified room/folder
- */
+ // Search for the specified room/folder
ret = imap_grabroom(roomname, Params[2].Key, 1);
if (ret != 0) {
IReply("NO Invalid mailbox name or access denied");
return;
}
- /*
- * Search for the specified user
- */
+ // Search for the specified user
ret = (-1);
valid = validate_recipients(Params[3].Key, NULL, 0);
if (valid != NULL) {
return;
}
- /*
- * CtdlUserGoto() formally takes us to the desired room. (If another
- * folder is selected, save its name so we can return there!!!!!)
- */
+ // CtdlUserGoto() 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);
}
CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL);
- /*
- * Now output the list of rights
- */
+ // Now output the list of rights
IAPuts("* LISTRIGHTS ");
IPutCParamStr(2);
IAPuts(" ");
IPutCParamStr(3);
IAPuts(" ");
- IPutStr(HKEY("")); /* FIXME ... do something here */
+ IPutStr(HKEY("")); // FIXME ... do something here
IAPuts("\r\n");
- /*
- * If another folder is selected, go back to that room so we can resume
- * our happy day without violent explosions.
- */
+ // If another folder is selected, go back to that room so we can resume
+ // our happy day without violent explosions.
if (IMAP->selected) {
CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL);
}
}
-/*
- * Implements the MYRIGHTS command.
- */
+// Implements the MYRIGHTS command.
void imap_myrights(int num_parms, ConstStr *Params) {
char roomname[ROOMNAMELEN];
char savedroom[ROOMNAMELEN];
return;
}
- /*
- * CtdlUserGoto() formally takes us to the desired room. (If another
- * folder is selected, save its name so we can return there!!!!!)
- */
+ // CtdlUserGoto() 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);
}
FreeStrBuf(&rights);
- /*
- * If a different folder was previously selected, return there now.
- */
+ // If a different folder was previously selected, return there now.
if ( (IMAP->selected) && (strcasecmp(roomname, savedroom)) ) {
CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL);
}