From d92a32fa28d95b62170007d7fb32e2db7f3bff23 Mon Sep 17 00:00:00 2001 From: Michael Hampton Date: Sun, 16 Jun 2002 22:24:28 +0000 Subject: [PATCH] * BASEROOM and AIDEROOM are now almost completely editable. Their names are now stored in citadel.config. (Re-run setup.) --- citadel/citadel.h | 4 +- citadel/msgbase.c | 6 +- citadel/room_ops.c | 131 ++++++++++++++++++++++++----------------- citadel/serv_network.c | 4 +- citadel/serv_smtp.c | 2 +- citadel/setup.c | 4 ++ citadel/user_ops.c | 14 +++-- 7 files changed, 100 insertions(+), 65 deletions(-) diff --git a/citadel/citadel.h b/citadel/citadel.h index ac708f6da..75a1dbb3f 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -28,7 +28,7 @@ * program is run again to bring things up to date. */ #define REV_LEVEL 591 /* This version */ -#define REV_MIN 570 /* Oldest compatible version */ +#define REV_MIN 591 /* Oldest compatible version */ #define SERVER_TYPE 0 /* zero for stock Citadel/UX; other developers please obtain SERVER_TYPE codes for your implementations */ @@ -120,6 +120,8 @@ struct config { time_t c_net_freq; /* how often to run the networker */ char c_disable_newu; /* disable NEWU command */ char c_aide_mailboxes; /* give Aides access to mailboxes */ + char c_baseroom[ROOMNAMELEN]; /* Name of baseroom (Lobby) */ + char c_aideroom[ROOMNAMELEN]; /* Name of aideroom (Aide) */ }; #define NODENAME config.c_nodename diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 59f6cc0e8..391509a51 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1875,7 +1875,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ if ((!CC->internal_pgm) || (recps == NULL)) { if (CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0) != 0) { lprintf(3, "ERROR saving message pointer!\n"); - CtdlSaveMsgPointerInRoom(AIDEROOM, newmsgid, 0); + CtdlSaveMsgPointerInRoom(config.c_aideroom, newmsgid, 0); } } @@ -1916,7 +1916,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } else { lprintf(9, "No user <%s>\n", recipient); - CtdlSaveMsgPointerInRoom(AIDEROOM, newmsgid, 0); + CtdlSaveMsgPointerInRoom(config.c_aideroom, newmsgid, 0); } } @@ -2292,7 +2292,7 @@ struct recptypes *validate_recipients(char *recipients) { case MES_LOCAL: if (!strcasecmp(this_recp, "sysop")) { ++ret->num_room; - strcpy(this_recp, AIDEROOM); + strcpy(this_recp, config.c_aideroom); if (strlen(ret->recp_room) > 0) { strcat(ret->recp_room, "|"); } diff --git a/citadel/room_ops.c b/citadel/room_ops.c index b3ce16c48..70d81ab4e 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -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); } @@ -815,7 +811,7 @@ void cmd_goto(char *gargs) 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); @@ -1086,6 +1082,12 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) { 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) { @@ -1106,6 +1108,20 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) { end_critical_section(S_QUICKROOM); + 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); + /* Adjust the floor reference counts if necessary */ if (new_floor != old_floor) { lgetfloor(&flbuf, old_floor); @@ -1136,8 +1152,7 @@ void cmd_setr(char *args) if (num_parms(args) >= 6) { new_floor = extract_int(args, 5); - } - else { + } else { new_floor = (-1); /* don't change the floor */ } @@ -1146,8 +1161,7 @@ void cmd_setr(char *args) */ if (CC->quickroom.QRflags & QR_MAILBOX) { sprintf(new_name, "%010ld.", atol(CC->quickroom.QRname) ); - } - else { + } else { strcpy(new_name, ""); } extract(&new_name[strlen(new_name)], args, 0); @@ -1156,24 +1170,19 @@ void cmd_setr(char *args) if (r == crr_room_not_found) { cprintf("%d Internal error - room not found?\n", ERROR); - } - else if (r == crr_already_exists) { + } else if (r == crr_already_exists) { cprintf("%d '%s' already exists.\n", ERROR + ALREADY_EXISTS, new_name); - } - else if (r == crr_noneditable) { + } else if (r == crr_noneditable) { cprintf("%d Cannot edit this room.\n", ERROR); - } - else if (r == crr_invalid_floor) { + } else if (r == crr_invalid_floor) { cprintf("%d Target floor does not exist.\n", ERROR + INVALID_FLOOR_OPERATION); - } - else if (r == crr_access_denied) { + } 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) { + } else if (r != crr_ok) { cprintf("%d Error: CtdlRenameRoom() returned %d\n", ERROR, r); } @@ -1193,19 +1202,22 @@ void cmd_setr(char *args) if (new_order > 127) new_order = 127; } + 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); + } + + /* 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. @@ -1214,22 +1226,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); + } } - - if (num_parms(args) >= 8) { - CC->quickroom.QRdefaultview = extract_int(args, 7); + /* 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); - /* 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 2>/dev/null", @@ -1252,10 +1284,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 { @@ -1420,12 +1448,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()); } /* @@ -1446,7 +1469,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, NULL, NULL); /* Return to the Lobby */ /* tell the world what we did */ snprintf(aaa, sizeof aaa, "%s> killed by %s\n", diff --git a/citadel/serv_network.c b/citadel/serv_network.c index b8412e2d1..ae15d8324 100644 --- a/citadel/serv_network.c +++ b/citadel/serv_network.c @@ -783,13 +783,13 @@ void network_bounce(struct CtdlMessage *msg, char *reason) { valid = NULL; } if ( (valid == NULL) || (!strcasecmp(recipient, bouncesource)) ) { - strcpy(force_room, AIDEROOM); + strcpy(force_room, config.c_aideroom); } else { strcpy(force_room, ""); } if ( (valid == NULL) && (strlen(force_room) == 0) ) { - strcpy(force_room, AIDEROOM); + strcpy(force_room, config.c_aideroom); } CtdlSubmitMsg(msg, valid, force_room); diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 43896c280..2602c083d 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -1052,7 +1052,7 @@ void smtp_do_bounce(char *instr) { /* If not, post it in the Aide> room */ if (successful_bounce == 0) { - CtdlSubmitMsg(bmsg, NULL, AIDEROOM); + CtdlSubmitMsg(bmsg, NULL, config.c_aideroom); } /* Free up the memory we used */ diff --git a/citadel/setup.c b/citadel/setup.c index a83f7e1b2..1933852ac 100644 --- a/citadel/setup.c +++ b/citadel/setup.c @@ -808,6 +808,10 @@ int main(int argc, char *argv[]) strcpy(config.c_bucket_dir, "bitbucket"); if (strlen(config.c_net_password) == 0) strcpy(config.c_net_password, "netpassword"); + if (strlen(config.c_baseroom) == 0) + strcpy(config.c_baseroom, "Lobby"); + if (strlen(config.c_aideroom) == 0) + strcpy(config.c_aideroom, "Aide"); if (config.c_port_number == 0) { config.c_port_number = 504; } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index b9cef9627..e631efb79 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -410,7 +410,7 @@ void session_startup(void) create_room(SENTITEMS, 4, "", 0, 1, 0); /* Enter the lobby */ - usergoto(BASEROOM, 0, NULL, NULL); + usergoto(config.c_baseroom, 0, NULL, NULL); /* Record this login in the Citadel log */ rec_log(CL_LOGIN, CC->curr_user); @@ -1008,14 +1008,20 @@ void cmd_invt_kick(char *iuser, int op) if (is_room_aide() || (atol(CC->quickroom.QRname) == CC->usersupp.usernum) ) { /* access granted */ - } - else { + } else { /* access denied */ cprintf("%d Higher access or room ownership required.\n", ERROR + HIGHER_ACCESS_REQUIRED); return; } + if (!strncasecmp(CC->quickroom.QRname, config.c_baseroom, + ROOMNAMELEN)) { + cprintf("%d Can't add/remove users from this room.\n", + ERROR + NOT_HERE); + return; + } + if (lgetuser(&USscratch, iuser) != 0) { cprintf("%d No such user.\n", ERROR); return; @@ -1073,7 +1079,7 @@ int CtdlForgetThisRoom(void) { lputuser(&CC->usersupp); /* Return to the Lobby, so we don't end up in an undefined room */ - usergoto(BASEROOM, 0, NULL, NULL); + usergoto(config.c_baseroom, 0, NULL, NULL); return(0); } -- 2.39.2