]> 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 baf2b4bf64ad53fa263a91df2ed8870a0bcebeb4..f450fe2539c890b3a861fb8400f45a4827dfba50 100644 (file)
@@ -1,6 +1,4 @@
 /* 
- * $Id$
- * 
  * Server functions which perform operations on room objects.
  *
  */
@@ -35,7 +33,6 @@
 #include "room_ops.h"
 #include "sysdep_decls.h"
 #include "support.h"
-#include "user_ops.h"
 #include "msgbase.h"
 #include "citserver.h"
 #include "control.h"
@@ -43,6 +40,7 @@
 #include "threads.h"
 
 #include "ctdl_module.h"
+#include "user_ops.h"
 
 struct floor *floorcache[MAXFLOORS];
 
@@ -53,7 +51,21 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
                int *result, int *view)
 {
        int retval = 0;
-       struct visit vbuf;
+       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)) {
@@ -62,6 +74,18 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
                goto SKIP_EVERYTHING;
        }
 
+       /* If guest mode is enabled, always grant access to the Lobby */
+       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;
+       }
+
        /* Locate any applicable user/room relationships */
        CtdlGetRelationship(&vbuf, userbuf, roombuf);
 
@@ -127,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;
@@ -137,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;
                        }
@@ -673,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);
@@ -711,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);
@@ -780,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);
@@ -819,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);
@@ -858,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);
@@ -887,7 +911,7 @@ void CtdlUserGoto(char *where, int display_result, int transiently,
        int rmailflag;
        int raideflag;
        int newmailcount = 0;
-       struct visit vbuf;
+       visit vbuf;
        char truncated_roomname[ROOMNAMELEN];
         struct cdbdata *cdbfr;
        long *msglist = NULL;
@@ -1079,7 +1103,7 @@ void cmd_goto(char *gargs)
        char password[32];
        int transiently = 0;
 
-       if (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);
@@ -1834,7 +1858,7 @@ unsigned CtdlCreateRoom(char *new_room_name,
 
        struct ctdlroom qrbuf;
        struct floor flbuf;
-       struct visit vbuf;
+       visit vbuf;
 
        CtdlLogPrintf(CTDL_DEBUG, "CtdlCreateRoom(name=%s, type=%d, view=%d)\n",
                new_room_name, new_room_type, new_room_view);
@@ -2264,5 +2288,5 @@ CTDL_MODULE_INIT(room_ops)
                CtdlRegisterProtoHook(cmd_eflr, "EFLR", "Autoconverted. TODO: document me.");
        }
         /* return our Subversion id for the Log */
-       return "$Id$";
+       return "room_ops";
 }