#include "support.h"
#include "config.h"
#include "control.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
#include "database.h"
#include "room_ops.h"
#include "user_ops.h"
#include "tools.h"
#include "serv_upgrade.h"
-void do_pre555_usersupp_upgrade(void) {
- struct pre555usersupp usbuf;
- struct usersupp newus;
+void do_pre555_user_upgrade(void) {
+ struct pre555user usbuf;
+ struct ctdluser newus;
struct cdbdata *cdbus;
char tempfilename[PATH_MAX];
FILE *fp, *tp;
strcpy(tempfilename, tmpnam(NULL));
/* First, back out all old version records to a flat file */
- cdb_rewind(CDB_USERSUPP);
- while(cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
- memset(&usbuf, 0, sizeof(struct pre555usersupp));
+ cdb_rewind(CDB_USERS);
+ while(cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
+ memset(&usbuf, 0, sizeof(struct pre555user));
memcpy(&usbuf, cdbus->ptr,
- ( (cdbus->len > sizeof(struct pre555usersupp)) ?
- sizeof(struct pre555usersupp) : cdbus->len) );
+ ( (cdbus->len > sizeof(struct pre555user)) ?
+ sizeof(struct pre555user) : cdbus->len) );
cdb_free(cdbus);
- fwrite(&usbuf, sizeof(struct pre555usersupp), 1, fp);
+ fwrite(&usbuf, sizeof(struct pre555user), 1, fp);
}
/* ...and overwrite the records with new format records */
rewind(fp);
- while (fread(&usbuf, sizeof(struct pre555usersupp), 1, fp) > 0) {
+ while (fread(&usbuf, sizeof(struct pre555user), 1, fp) > 0) {
if (strlen(usbuf.fullname) > 0) {
lprintf(9, "Upgrading <%s>\n", usbuf.fullname);
- memset(&newus, 0, sizeof(struct usersupp));
+ memset(&newus, 0, sizeof(struct ctdluser));
newus.uid = usbuf.USuid;
strcpy(newus.password, usbuf.password);
newus.flags = usbuf.flags;
newus.timescalled = (long) usbuf.timescalled;
newus.posted = (long) usbuf.posted;
- newus.axlevel = (CIT_UBYTE) usbuf.axlevel;
+ newus.axlevel = (cit_uint8_t) usbuf.axlevel;
newus.usernum = (long) usbuf.usernum;
newus.lastcall = (long) usbuf.lastcall;
newus.USuserpurge = (int) usbuf.USuserpurge;
strcpy(newus.fullname, usbuf.fullname);
- newus.USscreenwidth = (CIT_UBYTE) usbuf.USscreenwidth;
- newus.USscreenheight = (CIT_UBYTE) usbuf.USscreenheight;
+ newus.USscreenwidth = (cit_uint8_t) usbuf.USscreenwidth;
+ newus.USscreenheight = (cit_uint8_t) usbuf.USscreenheight;
putuser(&newus);
-void check_server_upgrades(void) {
-
- get_control();
- lprintf(5, "Server-hosted upgrade level is %d.%02d\n",
- (CitControl.version / 100),
- (CitControl.version % 100) );
-
- if (CitControl.version < REV_LEVEL) {
- lprintf(5, "Server hosted updates need to be processed at "
- "this time. Please wait...\n");
- }
- else {
- return;
- }
-
- if (CitControl.version < 555) do_pre555_usersupp_upgrade();
-
- CitControl.version = REV_LEVEL;
- put_control();
-}
-
-
-
-
-
-
-
-
-
-
-
/*
* Back end processing function for cmd_bmbx
*/
-void cmd_bmbx_backend(struct quickroom *qrbuf, void *data) {
+void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
static struct RoomProcList *rplist = NULL;
struct RoomProcList *ptr;
- struct quickroom qr;
+ struct ctdlroom qr;
/* Lazy programming here. Call this function as a ForEachRoom backend
* in order to queue up the room names, or call it with a null room
else {
qr.QRgen = time(NULL);
- lprintf(9, " -- bumped!\n");
+ lprintf(9, " -- fixed!\n");
}
lputroom(&qr);
}
}
/*
- * quick fix command to bump mailbox generation numbers
+ * quick fix to bump mailbox generation numbers
*/
-void cmd_bmbx(char *argbuf) {
- int really_do_this = 0;
+void bump_mailbox_generation_numbers(void) {
+ lprintf(5, "Applying security fix to mailbox rooms\n");
+ ForEachRoom(cmd_bmbx_backend, NULL);
+ cmd_bmbx_backend(NULL, NULL);
+ return;
+}
- if (CtdlAccessCheck(ac_internal)) return;
- really_do_this = extract_int(argbuf, 0);
- if (really_do_this != 1) {
- cprintf("%d You didn't really want to do that.\n", OK);
+/*
+ * Back end processing function for convert_bbsuid_to_minusone()
+ */
+void cbtm_backend(struct ctdluser *usbuf, void *data) {
+ static struct UserProcList *uplist = NULL;
+ struct UserProcList *ptr;
+ struct ctdluser us;
+
+ /* Lazy programming here. Call this function as a ForEachUser backend
+ * in order to queue up the room names, or call it with a null user
+ * to make it do the processing.
+ */
+ if (usbuf != NULL) {
+ ptr = (struct UserProcList *)
+ mallok(sizeof (struct UserProcList));
+ if (ptr == NULL) return;
+
+ safestrncpy(ptr->user, usbuf->fullname, sizeof ptr->user);
+ ptr->next = uplist;
+ uplist = ptr;
return;
}
- ForEachRoom(cmd_bmbx_backend, NULL);
- cmd_bmbx_backend(NULL, NULL);
+ while (uplist != NULL) {
+
+ if (lgetuser(&us, uplist->user) == 0) {
+ lprintf(9, "Processing <%s>...\n", uplist->user);
+ if (us.uid == BBSUID) {
+ us.uid = (-1);
+ }
+ lputuser(&us);
+ }
- cprintf("%d Mailbox generation numbers bumped.\n", OK);
+ ptr = uplist;
+ uplist = uplist->next;
+ phree(ptr);
+ }
+}
+
+/*
+ * quick fix to change all BBSUID users to (-1)
+ */
+void convert_bbsuid_to_minusone(void) {
+ lprintf(5, "Applying uid changes\n");
+ ForEachUser(cbtm_backend, NULL);
+ cbtm_backend(NULL, NULL);
return;
+}
+
+/*
+ * This field was originally used for something else, so when we upgrade
+ * we have to initialize it to 0 in case there was trash in that space.
+ */
+void initialize_c_rfc822_strict_from(void) {
+ get_config();
+ config.c_rfc822_strict_from = 0;
+ put_config();
}
+void check_server_upgrades(void) {
+
+ get_control();
+ lprintf(5, "Server-hosted upgrade level is %d.%02d\n",
+ (CitControl.version / 100),
+ (CitControl.version % 100) );
+
+ if (CitControl.version < REV_LEVEL) {
+ lprintf(5, "Server hosted updates need to be processed at "
+ "this time. Please wait...\n");
+ }
+ else {
+ return;
+ }
+
+ if (CitControl.version < 555) do_pre555_user_upgrade();
+ if (CitControl.version < 591) bump_mailbox_generation_numbers();
+ if (CitControl.version < 606) initialize_c_rfc822_strict_from();
+ if (CitControl.version < 608) convert_bbsuid_to_minusone();
+
+ CitControl.version = REV_LEVEL;
+ put_control();
+}
+
+
-char *Dynamic_Module_Init(void)
+char *serv_upgrade_init(void)
{
check_server_upgrades();
- CtdlRegisterProtoHook(cmd_bmbx, "BMBX", "Bump mailboxes");
return "$Id$";
}