migrated all the code that used them to use "struct visit" instead.
+Fri Oct 2 00:04:31 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * Finally removed all three usersupp.foo[MAXROOMS] elements, and
+ migrated all the code that used them to use "struct visit" instead.
+
Thu Oct 1 23:02:20 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Rewrote [l][get|put]room() functions to use room names rather than
room index numbers. Temporarily prepended a "n" to these four
struct usersupp { /* User record */
int USuid; /* userid (==BBSUID for bbs only) */
char password[20]; /* password (for BBS-only users) */
- long lastseen[MAXROOMS]; /* deprecated */
- long generation[MAXROOMS]; /* deprecated */
- long forget[MAXROOMS]; /* deprecated */
unsigned flags; /* See US_ flags below */
int timescalled; /* Total number of logins */
int posted; /* Number of messages posted (ever) */
*/
lgetuser(&CC->usersupp,CC->curr_user);
CC->usersupp.posted = CC->usersupp.posted + 1;
- if (CC->curr_rm==twitroom) {
- CC->usersupp.generation[twitroom] = CC->quickroom.QRgen;
- }
+ /* FIX if user is twit, grant access to twitroom here */
lputuser(&CC->usersupp, CC->curr_user);
/* If mail, there's still more to do, if not, skip it. */
lgetuser(&CC->usersupp,CC->curr_user);
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
- /* old method - remove when we're ready */
- CC->usersupp.forget[CC->curr_rm]=(-1);
- CC->usersupp.generation[CC->curr_rm]=CC->quickroom.QRgen;
-
- /* new method */
vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
vbuf.v_flags = vbuf.v_flags | V_ACCESS;
{
struct quickroom QRscratch;
int a,c;
- int ok;
+ int ok, ra;
char bbb[20],towhere[32],password[20];
if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
return;
}
- /* normal clients have to pass through security */
- if (
- (strcasecmp(bbb,towhere)==0)
- && ((QRscratch.QRflags&QR_INUSE)!=0)
-
- && ( ((QRscratch.QRflags&QR_PREFONLY)==0)
- || (CC->usersupp.axlevel>=5)
- )
+ if (!strcasecmp(bbb, towhere)) {
- && ( (a!=2) || (CC->usersupp.axlevel>=6) )
-
- && ( ((QRscratch.QRflags&QR_PRIVATE)==0)
- || (QRscratch.QRflags&QR_GUESSNAME)
- || (CC->usersupp.axlevel>=6)
- || (QRscratch.QRflags&QR_PASSWORDED)
- || (QRscratch.QRgen==CC->usersupp.generation[a])
- )
+ /* See if there is an existing user/room relationship */
+ ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
- ) ok = 1;
-
-
- if (ok==1) {
-
- if ( (QRscratch.QRflags&QR_PASSWORDED) &&
- (CC->usersupp.axlevel<6) &&
- (QRscratch.QRgen!=CC->usersupp.generation[a]) &&
- (strcasecmp(QRscratch.QRpasswd,password))
- ) {
- cprintf("%d wrong or missing passwd\n",
- ERROR+PASSWORD_REQUIRED);
+ /* normal clients have to pass through security */
+ if (ra & UA_GOTOALLOWED) ok = 1;
+
+ if (ok==1) {
+ if ( (QRscratch.QRflags&QR_PASSWORDED) &&
+ ((ra & UA_KNOWN) == 0) &&
+ (strcasecmp(QRscratch.QRpasswd,password))
+ ) {
+ cprintf("%d wrong or missing passwd\n",
+ ERROR+PASSWORD_REQUIRED);
+ return;
+ }
+ else {
+ usergoto(a,1);
return;
}
-
- usergoto(a,1);
- return;
+ }
}
-
}
+
cprintf("%d room '%s' not found\n",ERROR+ROOM_NOT_FOUND,towhere);
}
bzero(&temp, sizeof(struct usersupp));
memcpy(&temp, cdbus->ptr, cdbus->len);
cdb_free(cdbus);
- if ((CC->quickroom.QRflags & QR_INUSE)
- && ( (CC->curr_rm!=2) || (temp.axlevel>=6) )
- && (CC->quickroom.QRgen != (temp.forget[CC->curr_rm]) )
-
- && ( ((CC->quickroom.QRflags&QR_PREFONLY)==0)
- || (temp.axlevel>=5)
- )
-
- && ( ((CC->quickroom.QRflags&QR_PRIVATE)==0)
- || (temp.axlevel>=6)
- || (CC->quickroom.QRgen==(temp.generation[CC->curr_rm]))
- )
-
- && (strncmp(temp.fullname,"000",3))
- ) cprintf("%s\n",temp.fullname);
+ if ( (CC->quickroom.QRflags & QR_INUSE)
+ && (CtdlRoomAccess(&CC->quickroom, &temp) & UA_KNOWN)
+ ) cprintf("%s\n",temp.fullname);
}
cprintf("000\n");
}
/* be sure not to kick the creator out of the room! */
lgetuser(&CC->usersupp,CC->curr_user);
CtdlGetRelationship(&vbuf, &CC->usersupp, &qrbuf);
- /* (old method) */
- CC->usersupp.generation[free_slot] = qrbuf.QRgen;
- CC->usersupp.forget[free_slot] = (-1);
- /* (new method) */
vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
vbuf.v_flags = vbuf.v_flags | V_ACCESS;
CtdlSetRelationship(&vbuf, &CC->usersupp, &qrbuf);
#define EVT_PURGEUSER 100 /* Deleting a user */
#define EVT_OUTPUTMSG 101 /* Outputting a message */
+
+
+
+ FUNCTIONS WHICH MANIPULATE USER/ROOM RELATIONSHIPS
+
+ void CtdlGetRelationship(struct visit *vbuf,
+ struct usersupp *rel_user,
+ struct quickroom *rel_room);
+ void CtdlSetRelationship(struct visit *newvisit,
+ struct usersupp *rel_user,
+ struct quickroom *rel_room);
+
+ These functions get/set a "struct visit" structure which may contain
+information about the relationship between a user and a room. Specifically:
+
+struct visit {
+ char v_roomname[20];
+ long v_generation;
+ long v_lastseen;
+ unsigned int v_flags;
+ };
+
+#define V_FORGET 1 /* User has zapped this room */
+#define V_LOCKOUT 2 /* User is locked out of this room */
+#define V_ACCESS 4 /* Access is granted to this room */
+
+ Don't change v_roomname or v_generation; they're used to identify the room
+being referred to. A room is unique to the system by its combination of room
+name and generation number. If a new room is created with the same name as
+a recently deleted room, it will have a new generation number, and therefore
+stale "visit" records will not be applied (and will eventually be purged).
+
+ v_lastseen contains the number of the newest message the user has read in
+this room. Any existing messages higher than this number can be considered
+as "new messages."
+
+ v_flags contains information regarding access to the room.
+
+
+
+ int CtdlRoomAccess(struct quickroom *roombuf, struct usersupp *userbuf)
+
+ This is a convenience function which uses CtdlGetRelationship() to determine
+whether a user has access to a room. It returns a bucket of bits which may
+contain:
+
+#define UA_INUSE 1 /* Room exists */
+#define UA_KNOWN 2 /* Room is in user's Known list */
+#define UA_GOTOALLOWED 4 /* User may <.G>oto this room */
+#define UA_HASNEWMSGS 8 /* Room contains new messages */
+#define UA_ZAPPED 16 /* User has forgotten this room */
* session startup code which is common to both cmd_pass() and cmd_newu()
*/
void session_startup(void) {
- int a;
- struct quickroom qr;
-
syslog(LOG_NOTICE,"user <%s> logged in",CC->curr_user);
lgetuser(&CC->usersupp,CC->curr_user);
CC->usersupp.axlevel = 6;
}
- /******************************************************************************/
- /* FIX It is safe to remove this segment during the cutover */
- for (a=0; a<MAXROOMS; ++a) {
- getroom(&qr,a);
- if (CC->usersupp.generation[a] != qr.QRgen)
- CC->usersupp.generation[a]=(-1);
- if (CC->usersupp.forget[a] != qr.QRgen)
- CC->usersupp.forget[a]=(-1);
- }
- /******************************************************************************/
-
lputuser(&CC->usersupp,CC->curr_user);
/* Run any cleanup routines registered by loadable modules */
strcpy(CC->usersupp.password,"");
(CC->logged_in) = 1;
- /********************************************************/
- /* FIX this can safely be removed during the cutover... */
- for (a=0; a<MAXROOMS; ++a) {
- CC->usersupp.generation[a]=(-1);
- CC->usersupp.forget[a]=(-1);
- }
- /********************************************************/
-
/* These are the default flags on new accounts */
CC->usersupp.flags =
US_NEEDVALID|US_LASTOLD|US_DISAPPEAR|US_PAGINATOR|US_FLOORS;
lgetuser(&CC->usersupp, CC->curr_user);
- /* old method - remove */
- CC->usersupp.lastseen[CC->curr_rm] = newlr;
-
- /* new method */
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
vbuf.v_lastseen = newlr;
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
CtdlGetRelationship(&vbuf, &USscratch, &CC->quickroom);
if (op==1) {
- /* old method -- FIX remove this when we're ready */
- USscratch.generation[CC->curr_rm]=CC->quickroom.QRgen;
- USscratch.forget[CC->curr_rm]=(-1);
-
- /* new method */
vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
vbuf.v_flags = vbuf.v_flags | V_ACCESS;
}
if (op==0) {
- /* old method -- FIX remove this when we're ready */
- USscratch.generation[CC->curr_rm]=(-1);
- USscratch.forget[CC->curr_rm]=CC->quickroom.QRgen;
-
- /* new method */
vbuf.v_flags = vbuf.v_flags & ~V_ACCESS;
vbuf.v_flags = vbuf.v_flags | V_FORGET | V_LOCKOUT;
}
lgetuser(&CC->usersupp,CC->curr_user);
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
- /* old method -- FIX remove this when we're ready */
- CC->usersupp.forget[CC->curr_rm] = CC->quickroom.QRgen;
- CC->usersupp.generation[CC->curr_rm] = (-1);
-
- /* new method */
vbuf.v_flags = vbuf.v_flags | V_FORGET;
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
num_mails = cdbmb->len / sizeof(long);
mailbox = (long *) cdbmb->ptr;
if (num_mails > 0) for (a=0; a<num_mails; ++a) {
- if (mailbox[a] > (CC->usersupp.lastseen[1]))
+ /*
+ if (message is new FIX FIX FIX)
++num_newmsgs;
+ */
}
cdb_free(cdbmb);
}