]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
* Renamed "dynloader" to "serv_extensions" globally. We don't want people
[citadel.git] / citadel / room_ops.c
index 613c4dfada08e1cfd249f0a0f4d934f8df2621b9..a2ef5da7bea1c9b81d0bd6ef6191706e8196c9eb 100644 (file)
@@ -31,7 +31,7 @@
 #include <errno.h>
 #include "citadel.h"
 #include "server.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
 #include "database.h"
 #include "config.h"
 #include "room_ops.h"
@@ -62,7 +62,7 @@ int CtdlRoomAccess(struct quickroom *roombuf, struct usersupp *userbuf)
        CtdlGetRelationship(&vbuf, userbuf, roombuf);
 
        /* Force the properties of the Aide room */
-       if (!strcasecmp(roombuf->QRname, AIDEROOM)) {
+       if (!strcasecmp(roombuf->QRname, config.c_aideroom)) {
                if (userbuf->axlevel >= 6) {
                        retval = UA_KNOWN | UA_GOTOALLOWED;
                } else {
@@ -169,7 +169,10 @@ void room_sanity_check(struct quickroom *qrbuf)
        }
        /* Listing order of 0 is illegal except for base rooms */
        if (qrbuf->QRorder == 0)
-               if (!is_noneditable(qrbuf))
+               if (!(qrbuf->QRflags & QR_MAILBOX) &&
+                   strncasecmp(qrbuf->QRname, config.c_baseroom, ROOMNAMELEN)
+                   &&
+                   strncasecmp(qrbuf->QRname, config.c_aideroom, ROOMNAMELEN))
                        qrbuf->QRorder = 64;
 }
 
@@ -463,20 +466,13 @@ int sort_msglist(long listptrs[], int oldcount)
 int is_noneditable(struct quickroom *qrbuf)
 {
 
-       /* Lobby> and Aide> are non-editable */
-       if (!strcasecmp(qrbuf->QRname, BASEROOM))
-               return (1);
-       else if (!strcasecmp(qrbuf->QRname, AIDEROOM))
-               return (1);
-
-       /* Mail> rooms are also non-editable */
-       else if ( (qrbuf->QRflags & QR_MAILBOX)
+       /* Mail> rooms are non-editable */
+       if ( (qrbuf->QRflags & QR_MAILBOX)
             && (!strcasecmp(&qrbuf->QRname[11], MAILROOM)) )
                return (1);
 
        /* Everything else is editable */
-       else
-               return (0);
+       return (0);
 }
 
 
@@ -501,10 +497,12 @@ void list_roomname(struct quickroom *qrbuf)
        }
 
        /* ...and now the other parameters */
-       cprintf("|%u|%d|%d\n",
+       cprintf("|%u|%d|%d|%d\n",
                qrbuf->QRflags,
                (int) qrbuf->QRfloor,
-               (int) qrbuf->QRorder);
+               (int) qrbuf->QRorder,
+               (int) qrbuf->QRflags2
+       );
 }
 
 
@@ -578,6 +576,32 @@ void cmd_lkra(char *argbuf)
 
 
 
+void cmd_lprm_backend(struct quickroom *qrbuf, void *data)
+{
+       int FloorBeingSearched = (-1);
+       FloorBeingSearched = *(int *)data;
+
+       if (   ((qrbuf->QRflags & QR_PRIVATE) == 0)
+               && ((qrbuf->QRflags & QR_MAILBOX) == 0)
+           && ((qrbuf->QRfloor == (FloorBeingSearched))
+               || ((FloorBeingSearched) < 0)))
+               list_roomname(qrbuf);
+}
+
+void cmd_lprm(char *argbuf)
+{
+       int FloorBeingSearched = (-1);
+       if (strlen(argbuf) > 0)
+               FloorBeingSearched = extract_int(argbuf, 0);
+
+       cprintf("%d Publiic rooms:\n", LISTING_FOLLOWS);
+
+       ForEachRoom(cmd_lprm_backend, &FloorBeingSearched);
+       cprintf("000\n");
+}
+
+
+
 /* 
  * cmd_lkrn()   -  List all known rooms with new messages
  */
@@ -688,8 +712,13 @@ void cmd_lzrm(char *argbuf)
 }
 
 
-
-void usergoto(char *where, int display_result, int *retmsgs, int *retnew)
+/*
+ * Make the specified room the current room for this session.  No validation
+ * or access control is done here -- the caller should make sure that the
+ * specified room exists and is ok to access.
+ */
+void usergoto(char *where, int display_result, int transiently,
+               int *retmsgs, int *retnew)
 {
        int a;
        int new_messages = 0;
@@ -704,26 +733,38 @@ void usergoto(char *where, int display_result, int *retmsgs, int *retnew)
        long *msglist = NULL;
        int num_msgs = 0;
 
-       strcpy(CC->quickroom.QRname, where);
-       getroom(&CC->quickroom, where);
+       /* If the supplied room name is NULL, the caller wants us to know that
+        * it has already copied the quickroom record into CC->quickroom, so
+        * we can skip the extra database fetch.
+        */
+       if (where != NULL) {
+               strcpy(CC->quickroom.QRname, where);
+               getroom(&CC->quickroom, where);
+       }
+
+       /* Take care of all the formalities. */
 
-       lgetuser(&CC->usersupp, CC->curr_user);
+       begin_critical_section(S_USERSUPP);
        CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
 
-       /* Know the room ... but not if it's the page log room */
-       if (strcasecmp(where, config.c_logpages)) {
+       /* Know the room ... but not if it's the page log room, or if the
+        * caller specified that we're only entering this room transiently.
+        */
+       if ((strcasecmp(CC->quickroom.QRname, config.c_logpages))
+          && (transiently == 0) ) {
                vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
                vbuf.v_flags = vbuf.v_flags | V_ACCESS;
        }
        CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
-       lputuser(&CC->usersupp);
+       end_critical_section(S_USERSUPP);
 
-       /* check for new mail */
+       /* Check for new mail */
        newmailcount = NewMailCount();
 
        /* set info to 1 if the user needs to read the room's info file */
-       if (CC->quickroom.QRinfo > vbuf.v_lastseen)
+       if (CC->quickroom.QRinfo > vbuf.v_lastseen) {
                info = 1;
+       }
 
        get_mm();
         cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->quickroom.QRnumber, sizeof(long));
@@ -765,19 +806,28 @@ void usergoto(char *where, int display_result, int *retmsgs, int *retnew)
        if (retmsgs != NULL) *retmsgs = total_messages;
        if (retnew != NULL) *retnew = new_messages;
        lprintf(9, "<%s> %d new of %d total messages\n",
-               CC->quickroom.QRname, new_messages, total_messages);
+               CC->quickroom.QRname,
+               new_messages, total_messages
+       );
 
-       if (display_result)
-               cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d\n",
+       if (display_result) {
+               cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d|%d|%d|\n",
                        CIT_OK, CtdlCheckExpress(),
                        truncated_roomname,
-                       new_messages, total_messages,
-                       info, CC->quickroom.QRflags,
-                       CC->quickroom.QRhighest,
-                       vbuf.v_lastseen,
-                       rmailflag, raideflag, newmailcount,
-                       CC->quickroom.QRfloor);
-
+                       (int)new_messages,
+                       (int)total_messages,
+                       (int)info,
+                       (int)CC->quickroom.QRflags,
+                       (long)CC->quickroom.QRhighest,
+                       (long)vbuf.v_lastseen,
+                       (int)rmailflag,
+                       (int)raideflag,
+                       (int)newmailcount,
+                       (int)CC->quickroom.QRfloor,
+                       (int)vbuf.v_view,
+                       (int)CC->quickroom.QRdefaultview
+               );
+       }
 }
 
 
@@ -793,16 +843,18 @@ void cmd_goto(char *gargs)
        char augmented_roomname[SIZ];
        char towhere[SIZ];
        char password[SIZ];
+       int transiently = 0;
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
        extract(towhere, gargs, 0);
        extract(password, gargs, 1);
+       transiently = extract_int(gargs, 2);
 
        getuser(&CC->usersupp, CC->curr_user);
 
        if (!strcasecmp(towhere, "_BASEROOM_"))
-               strcpy(towhere, BASEROOM);
+               strcpy(towhere, config.c_baseroom);
 
        if (!strcasecmp(towhere, "_MAIL_"))
                strcpy(towhere, MAILROOM);
@@ -826,9 +878,11 @@ void cmd_goto(char *gargs)
        /* And if the room was found... */
        if (c == 0) {
 
-               /* let internal programs go directly to any room */
+               /* Let internal programs go directly to any room. */
                if (CC->internal_pgm) {
-                       usergoto(towhere, 1, NULL, NULL);
+                       memcpy(&CC->quickroom, &QRscratch,
+                               sizeof(struct quickroom));
+                       usergoto(NULL, 1, transiently, NULL, NULL);
                        return;
                }
 
@@ -843,7 +897,9 @@ void cmd_goto(char *gargs)
                if (ok == 1) {
                        if ((QRscratch.QRflags & QR_MAILBOX) &&
                            ((ra & UA_GOTOALLOWED))) {
-                               usergoto(towhere, 1, NULL, NULL);
+                               memcpy(&CC->quickroom, &QRscratch,
+                                       sizeof(struct quickroom));
+                               usergoto(NULL, 1, transiently, NULL, NULL);
                                return;
                        } else if ((QRscratch.QRflags & QR_PASSWORDED) &&
                            ((ra & UA_KNOWN) == 0) &&
@@ -862,7 +918,9 @@ void cmd_goto(char *gargs)
                                lprintf(9, "Failed to acquire private room\n");
                                goto NOPE;
                        } else {
-                               usergoto(towhere, 1, NULL, NULL);
+                               memcpy(&CC->quickroom, &QRscratch,
+                                       sizeof(struct quickroom));
+                               usergoto(NULL, 1, transiently, NULL, NULL);
                                return;
                        }
                }
@@ -983,22 +1041,146 @@ void cmd_getr(void)
 {
        if (CtdlAccessCheck(ac_room_aide)) return;
 
-       /********
-       if (is_noneditable(&CC->quickroom)) {
-               cprintf("%d Can't edit this room.\n", ERROR + NOT_HERE);
-               return;
-       }
-       ************/
-
        getroom(&CC->quickroom, CC->quickroom.QRname);
-       cprintf("%d%c%s|%s|%s|%d|%d|%d\n",
-               CIT_OK, CtdlCheckExpress(),
-               CC->quickroom.QRname,
-               ((CC->quickroom.QRflags & QR_PASSWORDED) ? CC->quickroom.QRpasswd : ""),
-               ((CC->quickroom.QRflags & QR_DIRECTORY) ? CC->quickroom.QRdirname : ""),
+       cprintf("%d%c%s|%s|%s|%d|%d|%d|%d|%d|\n",
+               CIT_OK,
+               CtdlCheckExpress(),
+
+               ((CC->quickroom.QRflags & QR_MAILBOX) ?
+                       &CC->quickroom.QRname[11] : CC->quickroom.QRname),
+
+               ((CC->quickroom.QRflags & QR_PASSWORDED) ?
+                       CC->quickroom.QRpasswd : ""),
+
+               ((CC->quickroom.QRflags & QR_DIRECTORY) ?
+                       CC->quickroom.QRdirname : ""),
+
                CC->quickroom.QRflags,
                (int) CC->quickroom.QRfloor,
-               (int) CC->quickroom.QRorder);
+               (int) CC->quickroom.QRorder,
+
+               CC->quickroom.QRdefaultview,
+               CC->quickroom.QRflags2
+               );
+}
+
+
+/*
+ * Back end function to rename a room.
+ * You can also specify which floor to move the room to, or specify -1 to
+ * keep the room on the same floor it was on.
+ *
+ * If you are renaming a mailbox room, you must supply the namespace prefix
+ * in *at least* the old name!
+ */
+int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
+       int old_floor = 0;
+       struct quickroom qrbuf;
+       struct quickroom qrtmp;
+       int ret = 0;
+       struct floor *fl;
+       struct floor flbuf;
+       long owner = 0L;
+       char actual_old_name[SIZ];
+
+       lprintf(9, "CtdlRenameRoom(%s, %s, %d)\n",
+               old_name, new_name, new_floor);
+
+       if (new_floor >= 0) {
+               fl = cgetfloor(new_floor);
+               if ((fl->f_flags & F_INUSE) == 0) {
+                       return(crr_invalid_floor);
+               }
+       }
+
+       begin_critical_section(S_QUICKROOM);
+
+       if ( (getroom(&qrtmp, new_name) == 0) 
+          && (strcasecmp(new_name, old_name)) ) {
+               ret = crr_already_exists;
+       }
+
+       else if (getroom(&qrbuf, old_name) != 0) {
+               ret = crr_room_not_found;
+       }
+
+       else if ( (CC->usersupp.axlevel < 6)
+                 && (CC->usersupp.usernum != qrbuf.QRroomaide)
+                 && ( (((qrbuf.QRflags & QR_MAILBOX) == 0) || (atol(qrbuf.QRname) != CC->usersupp.usernum))) )  {
+               ret = crr_access_denied;
+       }
+
+       else if (is_noneditable(&qrbuf)) {
+               ret = crr_noneditable;
+       }
+
+       else {
+               /* Rename it */
+               strcpy(actual_old_name, qrbuf.QRname);
+               if (qrbuf.QRflags & QR_MAILBOX) {
+                       owner = atol(qrbuf.QRname);
+               }
+               if ( (owner > 0L) && (atol(new_name) == 0L) ) {
+                       snprintf(qrbuf.QRname, sizeof(qrbuf.QRname),
+                                       "%010ld.%s", owner, new_name);
+               }
+               else {
+                       safestrncpy(qrbuf.QRname, new_name,
+                                               sizeof(qrbuf.QRname));
+               }
+
+               /* Reject change of floor for baseroom/aideroom */
+               if (!strncasecmp(old_name, config.c_baseroom, ROOMNAMELEN) ||
+                   !strncasecmp(old_name, config.c_aideroom, ROOMNAMELEN)) {
+                       new_floor = 0;
+               }
+
+               /* Take care of floor stuff */
+               old_floor = qrbuf.QRfloor;
+               if (new_floor < 0) {
+                       new_floor = old_floor;
+               }
+               qrbuf.QRfloor = new_floor;
+               putroom(&qrbuf);
+
+               begin_critical_section(S_CONFIG);
+       
+               /* If baseroom/aideroom name changes, update config */
+               if (!strncasecmp(old_name, config.c_baseroom, ROOMNAMELEN)) {
+                       safestrncpy(config.c_baseroom, new_name, ROOMNAMELEN);
+                       put_config();
+               }
+               if (!strncasecmp(old_name, config.c_aideroom, ROOMNAMELEN)) {
+                       safestrncpy(config.c_aideroom, new_name, ROOMNAMELEN);
+                       put_config();
+               }
+       
+               end_critical_section(S_CONFIG);
+       
+               /* If the room name changed, then there are now two room
+                * records, so we have to delete the old one.
+                */
+               if (strcasecmp(new_name, old_name)) {
+                       b_deleteroom(actual_old_name);
+               }
+
+               ret = crr_ok;
+       }
+
+       end_critical_section(S_QUICKROOM);
+
+       /* Adjust the floor reference counts if necessary */
+       if (new_floor != old_floor) {
+               lgetfloor(&flbuf, old_floor);
+               --flbuf.f_ref_count;
+               lputfloor(&flbuf, old_floor);
+               lgetfloor(&flbuf, CC->quickroom.QRfloor);
+               ++flbuf.f_ref_count;
+               lputfloor(&flbuf, CC->quickroom.QRfloor);
+       }
+
+       /* ...and everybody say "YATTA!" */     
+       return(ret);
 }
 
 
@@ -1008,34 +1190,58 @@ void cmd_getr(void)
 void cmd_setr(char *args)
 {
        char buf[SIZ];
-       struct floor *fl;
-       struct floor flbuf;
-       char old_name[ROOMNAMELEN];
-       int old_floor;
        int new_order = 0;
-       int ne = 0;
+       int r;
+       int new_floor;
+       char new_name[ROOMNAMELEN];
 
-       if (CtdlAccessCheck(ac_room_aide)) return;
+       if (CtdlAccessCheck(ac_logged_in)) return;
 
-       if (is_noneditable(&CC->quickroom)) {
-               ne = 1;
+       if (num_parms(args) >= 6) {
+               new_floor = extract_int(args, 5);
+       } else {
+               new_floor = (-1);       /* don't change the floor */
        }
 
-       /***
-               cprintf("%d Can't edit this room.\n", ERROR + NOT_HERE);
-               return;
+       /* When is a new name more than just a new name?  When the old name
+        * has a namespace prefix.
+        */
+       if (CC->quickroom.QRflags & QR_MAILBOX) {
+               sprintf(new_name, "%010ld.", atol(CC->quickroom.QRname) );
+       } else {
+               strcpy(new_name, "");
        }
-       ***/
+       extract(&new_name[strlen(new_name)], args, 0);
 
+       r = CtdlRenameRoom(CC->quickroom.QRname, new_name, new_floor);
 
-       if (num_parms(args) >= 6) {
-               fl = cgetfloor(extract_int(args, 5));
-               if ((fl->f_flags & F_INUSE) == 0) {
-                       cprintf("%d Invalid floor number.\n",
-                               ERROR + INVALID_FLOOR_OPERATION);
-                       return;
-               }
+       if (r == crr_room_not_found) {
+               cprintf("%d Internal error - room not found?\n", ERROR);
+       } else if (r == crr_already_exists) {
+               cprintf("%d '%s' already exists.\n",
+                       ERROR + ALREADY_EXISTS, new_name);
+       } else if (r == crr_noneditable) {
+               cprintf("%d Cannot edit this room.\n", ERROR);
+       } else if (r == crr_invalid_floor) {
+               cprintf("%d Target floor does not exist.\n",
+                       ERROR + INVALID_FLOOR_OPERATION);
+       } else if (r == crr_access_denied) {
+               cprintf("%d You do not have permission to edit '%s'\n",
+                       ERROR + HIGHER_ACCESS_REQUIRED,
+                       CC->quickroom.QRname);
+       } else if (r != crr_ok) {
+               cprintf("%d Error: CtdlRenameRoom() returned %d\n",
+                       ERROR, r);
+       }
+
+       if (r != crr_ok) {
+               return;
        }
+
+       getroom(&CC->quickroom, new_name);
+
+       /* Now we have to do a bunch of other stuff */
+
        if (num_parms(args) >= 7) {
                new_order = extract_int(args, 6);
                if (new_order < 1)
@@ -1043,28 +1249,27 @@ void cmd_setr(char *args)
                if (new_order > 127)
                        new_order = 127;
        }
-       lgetroom(&CC->quickroom, CC->quickroom.QRname);
 
-       /* Non-editable base rooms can't be renamed */
-       strcpy(old_name, CC->quickroom.QRname);
-       if (!ne) {
-               extract(buf, args, 0);
-               buf[ROOMNAMELEN] = 0;
-               safestrncpy(CC->quickroom.QRname, buf,
-                       sizeof CC->quickroom.QRname);
-       }
+       lgetroom(&CC->quickroom, CC->quickroom.QRname);
 
-       extract(buf, args, 1);
-       buf[10] = 0;
-       safestrncpy(CC->quickroom.QRpasswd, buf, sizeof CC->quickroom.QRpasswd);
+       /* Directory room */
        extract(buf, args, 2);
        buf[15] = 0;
        safestrncpy(CC->quickroom.QRdirname, buf,
                sizeof CC->quickroom.QRdirname);
-       CC->quickroom.QRflags = (extract_int(args, 3) | QR_INUSE);
-       if (num_parms(args) >= 7)
-               CC->quickroom.QRorder = (char) new_order;
 
+       /* Default view */
+       if (num_parms(args) >= 8) {
+               CC->quickroom.QRdefaultview = extract_int(args, 7);
+       }
+
+       /* Second set of flags */
+       if (num_parms(args) >= 9) {
+               CC->quickroom.QRflags2 = extract_int(args, 8);
+       }
+
+       /* Misc. flags */
+       CC->quickroom.QRflags = (extract_int(args, 3) | QR_INUSE);
        /* Clean up a client boo-boo: if the client set the room to
         * guess-name or passworded, ensure that the private flag is
         * also set.
@@ -1073,34 +1278,42 @@ void cmd_setr(char *args)
            || (CC->quickroom.QRflags & QR_PASSWORDED))
                CC->quickroom.QRflags |= QR_PRIVATE;
 
-       /* Kick everyone out if the client requested it (by changing the
-        * room's generation number)
-        */
-       if (extract_int(args, 4)) {
-               time(&CC->quickroom.QRgen);
+       /* Some changes can't apply to BASEROOM */
+       if (!strncasecmp(CC->quickroom.QRname, config.c_baseroom,
+                        ROOMNAMELEN)) {
+               CC->quickroom.QRorder = 0;
+               CC->quickroom.QRpasswd[0] = '\0';
+               CC->quickroom.QRflags &= ~(QR_PRIVATE & QR_PASSWORDED &
+                       QR_GUESSNAME & QR_PREFONLY & QR_MAILBOX);
+               CC->quickroom.QRflags |= QR_PERMANENT;
+       } else {        
+               /* March order (doesn't apply to AIDEROOM) */
+               if (num_parms(args) >= 7)
+                       CC->quickroom.QRorder = (char) new_order;
+               /* Room password */
+               extract(buf, args, 1);
+               buf[10] = 0;
+               safestrncpy(CC->quickroom.QRpasswd, buf,
+                           sizeof CC->quickroom.QRpasswd);
+               /* Kick everyone out if the client requested it
+                * (by changing the room's generation number)
+                */
+               if (extract_int(args, 4)) {
+                       time(&CC->quickroom.QRgen);
+               }
        }
-       old_floor = CC->quickroom.QRfloor;
-       if (num_parms(args) >= 6) {
-               CC->quickroom.QRfloor = extract_int(args, 5);
+       /* Some changes can't apply to AIDEROOM */
+       if (!strncasecmp(CC->quickroom.QRname, config.c_baseroom,
+                        ROOMNAMELEN)) {
+               CC->quickroom.QRorder = 0;
+               CC->quickroom.QRflags &= ~QR_MAILBOX;
+               CC->quickroom.QRflags |= QR_PERMANENT;
        }
+
        /* Write the room record back to disk */
        lputroom(&CC->quickroom);
 
-       /* If the room name changed, then there are now two room records,
-        * so we have to delete the old one.
-        */
-       if (strcasecmp(CC->quickroom.QRname, old_name)) {
-               b_deleteroom(old_name);
-       }
-       /* adjust the floor reference counts */
-       lgetfloor(&flbuf, old_floor);
-       --flbuf.f_ref_count;
-       lputfloor(&flbuf, old_floor);
-       lgetfloor(&flbuf, CC->quickroom.QRfloor);
-       ++flbuf.f_ref_count;
-       lputfloor(&flbuf, CC->quickroom.QRfloor);
-
-       /* create a room directory if necessary */
+       /* Create a room directory if necessary */
        if (CC->quickroom.QRflags & QR_DIRECTORY) {
                snprintf(buf, sizeof buf,
                    "mkdir ./files/%s </dev/null >/dev/null 2>/dev/null",
@@ -1123,10 +1336,6 @@ void cmd_geta(void)
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
-       if (is_noneditable(&CC->quickroom)) {
-               cprintf("%d Can't edit this room.\n", ERROR + NOT_HERE);
-               return;
-       }
        if (getuserbynumber(&usbuf, CC->quickroom.QRroomaide) == 0) {
                cprintf("%d %s\n", CIT_OK, usbuf.fullname);
        } else {
@@ -1166,8 +1375,14 @@ void cmd_seta(char *new_ra)
         * the room table, otherwise it would deadlock!
         */
        if (post_notice == 1) {
-               snprintf(buf, sizeof buf, "%s is now room aide for %s>\n",
-                       usbuf.fullname, CC->quickroom.QRname);
+               if (strlen(usbuf.fullname) > 0)
+                       snprintf(buf, sizeof buf,
+                               "%s is now room aide for %s>\n",
+                               usbuf.fullname, CC->quickroom.QRname);
+               else
+                       snprintf(buf, sizeof buf,
+                               "There is now no room aide for %s>\n",
+                               CC->quickroom.QRname);
                aide_message(buf);
        }
        cprintf("%d Ok\n", CIT_OK);
@@ -1285,12 +1500,7 @@ int CtdlDoIHavePermissionToDeleteThisRoom(struct quickroom *qr) {
        /*
         * For normal rooms, just check for aide or room aide status.
         */
-       else {
-               return(is_room_aide());
-       }
-
-       /* Should never get to this point, but to keep the compiler quiet... */
-       return(0);
+       return(is_room_aide());
 }
 
 /*
@@ -1311,7 +1521,7 @@ void cmd_kill(char *argbuf)
        if (kill_ok) {
                strcpy(deleted_room_name, CC->quickroom.QRname);
                delete_room(&CC->quickroom);    /* Do the dirty work */
-               usergoto(BASEROOM, 0, NULL, NULL); /* Return to the Lobby */
+               usergoto(config.c_baseroom, 0, 0, NULL, NULL); /* Return to the Lobby */
 
                /* tell the world what we did */
                snprintf(aaa, sizeof aaa, "%s> killed by %s\n",
@@ -1334,7 +1544,8 @@ unsigned create_room(char *new_room_name,
                     int new_room_type,
                     char *new_room_pass,
                     int new_room_floor,
-                    int really_create)
+                    int really_create,
+                    int avoid_access)
 {
 
        struct quickroom qrbuf;
@@ -1399,13 +1610,17 @@ unsigned create_room(char *new_room_name,
        flbuf.f_ref_count = flbuf.f_ref_count + 1;
        lputfloor(&flbuf, (int) qrbuf.QRfloor);
 
-       /* be sure not to kick the creator out of the room! */
-       lgetuser(&CC->usersupp, CC->curr_user);
-       CtdlGetRelationship(&vbuf, &CC->usersupp, &qrbuf);
-       vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
-       vbuf.v_flags = vbuf.v_flags | V_ACCESS;
-       CtdlSetRelationship(&vbuf, &CC->usersupp, &qrbuf);
-       lputuser(&CC->usersupp);
+       /* Grant the creator access to the room unless the avoid_access
+        * parameter was specified.
+        */
+       if (avoid_access == 0) {
+               lgetuser(&CC->usersupp, CC->curr_user);
+               CtdlGetRelationship(&vbuf, &CC->usersupp, &qrbuf);
+               vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
+               vbuf.v_flags = vbuf.v_flags | V_ACCESS;
+               CtdlSetRelationship(&vbuf, &CC->usersupp, &qrbuf);
+               lputuser(&CC->usersupp);
+       }
 
        /* resume our happy day */
        return (qrbuf.QRflags);
@@ -1425,12 +1640,14 @@ void cmd_cre8(char *args)
        char aaa[SIZ];
        unsigned newflags;
        struct floor *fl;
+       int avoid_access = 0;
 
        cre8_ok = extract_int(args, 0);
        extract(new_room_name, args, 1);
        new_room_name[ROOMNAMELEN - 1] = 0;
        new_room_type = extract_int(args, 2);
        extract(new_room_pass, args, 3);
+       avoid_access = extract_int(args, 5);
        new_room_pass[9] = 0;
        new_room_floor = 0;
 
@@ -1469,14 +1686,24 @@ void cmd_cre8(char *args)
                return;
        }
 
-       if ((new_room_type < 0) || (new_room_type > 4)) {
+       if ((new_room_type < 0) || (new_room_type > 5)) {
                cprintf("%d Invalid room type.\n", ERROR);
                return;
        }
 
+       if (new_room_type == 5) {
+               if ((config.c_aide_mailboxes == 0)
+                  || (CC->usersupp.axlevel < 6)) {
+                       cprintf("%d Higher access required\n", 
+                               ERROR+HIGHER_ACCESS_REQUIRED);
+                       return;
+               }
+       }
+
        /* Check to make sure the requested room name doesn't already exist */
        newflags = create_room(new_room_name,
-                          new_room_type, new_room_pass, new_room_floor, 0);
+                               new_room_type, new_room_pass, new_room_floor,
+                               0, avoid_access);
        if (newflags == 0) {
                cprintf("%d '%s' already exists.\n",
                        ERROR + ALREADY_EXISTS, new_room_name);
@@ -1491,7 +1718,7 @@ void cmd_cre8(char *args)
        /* If we reach this point, the room needs to be created. */
 
        newflags = create_room(new_room_name,
-                          new_room_type, new_room_pass, new_room_floor, 1);
+                          new_room_type, new_room_pass, new_room_floor, 1, 0);
 
        /* post a message in Aide> describing the new room */
        safestrncpy(aaa, new_room_name, sizeof aaa);
@@ -1592,9 +1819,14 @@ void cmd_cflr(char *argbuf)
        extract(new_floor_name, argbuf, 0);
        cflr_ok = extract_int(argbuf, 1);
 
-
        if (CtdlAccessCheck(ac_aide)) return;
 
+       if (strlen(new_floor_name) == 0) {
+               cprintf("%d Blank floor name not allowed.\n",
+                       ERROR+ILLEGAL_VALUE);
+               return;
+       }
+
        for (a = 0; a < MAXFLOORS; ++a) {
                getfloor(&flbuf, a);