]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
Ouch. CtdlRoomAccess() had a couple of places where it was checking 'the current...
[citadel.git] / citadel / room_ops.c
index afa6af5136ca511fcacf74a6cd2c9ed1168166a0..f450fe2539c890b3a861fb8400f45a4827dfba50 100644 (file)
@@ -52,6 +52,20 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
 {
        int retval = 0;
        visit vbuf;
+       int is_me = 0;
+
+       if (userbuf == &CC->user) {
+               is_me = 1;
+       }
+
+       /*** temporary ObviousLog(tm) -- disregard this
+       if (is_me) {
+               CtdlLogPrintf(CTDL_DEBUG, "\033[32muserbuf==CC\033[0m\n");
+       }
+       else {
+               CtdlLogPrintf(CTDL_DEBUG, "\033[31muserbuf!=CC\033[0m\n");
+       }
+       ***/
 
        /* for internal programs, always do everything */
        if (((CC->internal_pgm)) && (roombuf->QRflags & QR_INUSE)) {
@@ -61,7 +75,12 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
        }
 
        /* If guest mode is enabled, always grant access to the Lobby */
-       if ( (!CC->logged_in) && (config.c_guest_logins) && (!strcasecmp(roombuf->QRname, BASEROOM)) ) {
+       if (
+               (is_me)
+               && (!CC->logged_in)
+               && (config.c_guest_logins)
+               && (!strcasecmp(roombuf->QRname, BASEROOM))
+       ) {
                retval = (UA_KNOWN | UA_GOTOALLOWED);
                vbuf.v_view = 0;
                goto SKIP_EVERYTHING;
@@ -132,8 +151,8 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
                 * - It is a read-only room
                 */
                int post_allowed = 1;
-               if (CC->user.axlevel < AxProbU) post_allowed = 0;
-               if ((CC->user.axlevel < AxNetU) && (CC->room.QRflags & QR_NETWORK)) post_allowed = 0;
+               if (userbuf->axlevel < AxProbU) post_allowed = 0;
+               if ((userbuf->axlevel < AxNetU) && (roombuf->QRflags & QR_NETWORK)) post_allowed = 0;
                if (roombuf->QRflags & QR_READONLY) post_allowed = 0;
                if (post_allowed) {
                        retval = retval | UA_POSTALLOWED;
@@ -142,7 +161,7 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
                /* If "collaborative deletion" is active for this room, any user who can post
                 * is also allowed to delete
                 */
-               if (CC->room.QRflags2 & QR2_COLLABDEL) {
+               if (roombuf->QRflags2 & QR2_COLLABDEL) {
                        if (retval & UA_POSTALLOWED) {
                                retval = retval | UA_DELETEALLOWED;
                        }
@@ -678,7 +697,7 @@ void cmd_lrms(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
 
        if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
@@ -716,7 +735,7 @@ void cmd_lkra(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        
        if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
@@ -785,7 +804,7 @@ void cmd_lkrn(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        
        if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
@@ -824,7 +843,7 @@ void cmd_lkro(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        
        if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
@@ -863,7 +882,7 @@ void cmd_lzrm(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        
        if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
@@ -1084,7 +1103,7 @@ void cmd_goto(char *gargs)
        char password[32];
        int transiently = 0;
 
-       if ((!config.c_guest_logins) && (CtdlAccessCheck(ac_logged_in))) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
 
        extract_token(towhere, gargs, 0, '|', sizeof towhere);
        extract_token(password, gargs, 1, '|', sizeof password);