#include <stdio.h>
#include <sys/stat.h>
#include <string.h>
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
#include <limits.h>
#include <errno.h>
#include "citadel.h"
}
NEWMSG: /* By the way, we also check for the presence of new messages */
- if ((roombuf->QRhighest) > (vbuf.v_lastseen)) {
+ if (is_msg_in_mset(vbuf.v_seen, roombuf->QRhighest) == 0) {
retval = retval | UA_HASNEWMSGS;
}
return (retval);
if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) {
if (msglist[a] > 0L) {
++total_messages;
- if (msglist[a] > vbuf.v_lastseen) {
+ if (is_msg_in_mset(vbuf.v_seen, msglist[a]) == 0) {
++new_messages;
}
}
if (ok == 1) {
if ((QRscratch.QRflags & QR_PASSWORDED) &&
((ra & UA_KNOWN) == 0) &&
- (strcasecmp(QRscratch.QRpasswd, password))
+ (strcasecmp(QRscratch.QRpasswd, password)) &&
+ (CC->usersupp.axlevel < 6)
) {
cprintf("%d wrong or missing passwd\n",
ERROR + PASSWORD_REQUIRED);
} else if ((QRscratch.QRflags & QR_PRIVATE) &&
((QRscratch.QRflags & QR_PASSWORDED) == 0) &&
((QRscratch.QRflags & QR_GUESSNAME) == 0) &&
- ((ra & UA_KNOWN) == 0)) {
+ ((ra & UA_KNOWN) == 0) &&
+ (CC->usersupp.axlevel < 6)
+ ) {
goto NOPE;
} else {
usergoto(towhere, 1, NULL, NULL);
}
+
+/*
+ * Check access control for deleting a room
+ */
+int CtdlDoIHavePermissionToDeleteThisRoom(struct quickroom *qr) {
+
+ if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
+ return(0);
+ }
+
+ if (is_noneditable(qr)) {
+ return(0);
+ }
+
+ /*
+ * For mailboxes, check stuff
+ */
+ if (qr->QRflags & QR_MAILBOX) {
+
+ if (strlen(qr->QRname) < 12) return(0); /* bad name */
+
+ if (atol(qr->QRname) != CC->usersupp.usernum) {
+ return(0); /* not my room */
+ }
+
+ /* Can't delete your Mail> room */
+ if (!strcasecmp(&qr->QRname[12], MAILROOM)) return(0);
+
+ /* Otherwise it's ok */
+ return(1);
+ }
+
+ /*
+ * 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);
+}
+
/*
* aide command: kill the current room
*/
kill_ok = extract_int(argbuf, 0);
- if (CtdlAccessCheck(ac_room_aide)) return;
-
- if (is_noneditable(&CC->quickroom)) {
- cprintf("%d Can't edit this room.\n", ERROR + NOT_HERE);
+ if (CtdlDoIHavePermissionToDeleteThisRoom(&CC->quickroom) == 0) {
+ cprintf("%d Can't delete this room.\n", ERROR + NOT_HERE);
return;
}
if (kill_ok) {
*/
if (!really_create) return (qrbuf.QRflags);
- cdb_begin_transaction();
+ /* cdb_begin_transaction(); commented out because a transaction
+ is already open when creating __CtdlSMTPspoolout__ while
+ initializing serv_smtp.c
+ */
+
qrbuf.QRnumber = get_new_room_number();
qrbuf.QRhighest = 0L; /* No messages in this room yet */
time(&qrbuf.QRgen); /* Use a timestamp as the generation number */
lputuser(&CC->usersupp);
/* resume our happy day */
- cdb_end_transaction();
+ /* cdb_end_transaction(); */
return (qrbuf.QRflags);
}
{ /* enter info file for current room */
FILE *fp;
char infofilename[SIZ];
- char *ibuf;
+ char buf[SIZ];
if (CtdlAccessCheck(ac_room_aide)) return;
cprintf("%d Send info...\n", SEND_LISTING);
do {
- client_gets(&ibuf);
- if (strcmp(ibuf, "000"))
- fprintf(fp, "%s\n", ibuf);
- } while (strcmp(ibuf, "000"));
+ client_gets(buf);
+ if (strcmp(buf, "000"))
+ fprintf(fp, "%s\n", buf);
+ } while (strcmp(buf, "000"));
fclose(fp);
/* now update the room index so people will see our new info */