]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_upgrade.c
* Renamed "struct user" to "struct ctdluser"
[citadel.git] / citadel / serv_upgrade.c
index b620e0417971bf18293dda874e7334f9562ab9a4..d206176b6a441ccf5c094f7c26d36788c103566d 100644 (file)
@@ -36,7 +36,7 @@
 #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"
@@ -44,9 +44,9 @@
 #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;
@@ -61,22 +61,22 @@ void do_pre555_usersupp_upgrade(void) {
        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);
@@ -133,10 +133,10 @@ void do_pre555_usersupp_upgrade(void) {
 /* 
  * 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
@@ -185,6 +185,65 @@ void bump_mailbox_generation_numbers(void) {
 }
 
 
+/* 
+ * 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;
+       }
+
+       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);
+               }
+
+               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();
+}
 
 
 
@@ -204,8 +263,10 @@ void check_server_upgrades(void) {
                return;
        }
 
-       if (CitControl.version < 555) do_pre555_usersupp_upgrade();
+       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();