]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/modules/upgrade/serv_upgrade.c
Blockquotes are now rendered to console as dim instead of italic
[citadel.git] / citadel / server / modules / upgrade / serv_upgrade.c
index 6db89583375cfbc3f2b8def5685a7673674c4630..4d9b176a6b331fdb8ffc84aba0c70df8c146b7c4 100644 (file)
@@ -3,7 +3,7 @@
 // guesses about what kind of data format changes need to be applied, and
 // we apply them transparently.
 //
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
 //
 // This program is open source software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License version 3.
@@ -35,6 +35,7 @@
 #include "../../control.h"
 #include "../../database.h"
 #include "../../user_ops.h"
+#include "../../makeuserkey.h"
 #include "../../msgbase.h"
 #include "serv_upgrade.h"
 #include "../../euidindex.h"
 // We keep this value around for the entire duration of the program run because we'll need it during several stages of startup.
 int oldver = 0;
 
-// Try to remove any extra users with number 0
-void fix_sys_user_name(void) {
-       struct ctdluser usbuf;
-       char usernamekey[USERNAME_SIZE];
-
-       while (CtdlGetUserByNumber(&usbuf, 0) == 0) {
-               // delete user with number 0 and no name
-               if (IsEmptyStr(usbuf.fullname)) {
-                       cdb_delete(CDB_USERS, "", 0);
-               }
-               else {
-                       // temporarily set this user to -1
-                       usbuf.usernum = -1;
-                       CtdlPutUser(&usbuf);
-               }
-       }
-
-       // Delete any "user 0" accounts
-       while (CtdlGetUserByNumber(&usbuf, -1) == 0) {
-               makeuserkey(usernamekey, usbuf.fullname);
-               cdb_delete(CDB_USERS, usernamekey, strlen(usernamekey));
-       }
-}
-
-
-// These accounts may have been created by code that ran between mid 2008 and early 2011.
-// If present they are no longer in use and may be deleted.
-void remove_thread_users(void) {
-       char *deleteusers[] = {
-               "SYS_checkpoint",
-               "SYS_extnotify",
-               "SYS_IGnet Queue",
-               "SYS_indexer",
-               "SYS_network",
-               "SYS_popclient",
-               "SYS_purger",
-               "SYS_rssclient",
-               "SYS_select_on_master",
-               "SYS_SMTP Send"
-       };
-
-       int i;
-       struct ctdluser usbuf;
-       for (i=0; i<(sizeof(deleteusers)/sizeof(char *)); ++i) {
-               if (CtdlGetUser(&usbuf, deleteusers[i]) == 0) {
-                       usbuf.axlevel = 0;
-                       strcpy(usbuf.password, "deleteme");
-                       CtdlPutUser(&usbuf);
-                       syslog(LOG_INFO,
-                               "System user account <%s> is no longer in use and will be deleted.",
-                               deleteusers[i]
-                       );
-               }
-       }
-}
-
 
 // Attempt to guess the name of the time zone currently in use
 // on the underlying host system.
@@ -282,31 +227,12 @@ void ingest_old_roominfo_and_roompic_files(void) {
 // For new installations (oldver == 0) also set default values.
 void update_config(void) {
 
-       if (oldver < 606) {
+       if (oldver < 811) {
                CtdlSetConfigInt("c_rfc822_strict_from", 0);
-       }
-
-       if (oldver < 609) {
                CtdlSetConfigInt("c_purge_hour", 3);
-       }
-
-       if (oldver < 615) {
                CtdlSetConfigInt("c_ldap_port", 389);
-       }
-
-       if (oldver < 623) {
                CtdlSetConfigStr("c_ip_addr", "*");
-       }
-
-       if (oldver < 650) {
                CtdlSetConfigInt("c_enable_fulltext", 1);
-       }
-
-       if (oldver < 652) {
-               CtdlSetConfigInt("c_auto_cull", 1);
-       }
-
-       if (oldver < 725) {
                CtdlSetConfigInt("c_xmpp_c2s_port", 5222);
                CtdlSetConfigInt("c_xmpp_s2s_port", 5269);
        }
@@ -440,6 +366,18 @@ void create_default_admin_account(void) {
 }
 
 
+void regenerate_secondary_indices(void) {
+       syslog(LOG_INFO, "regenerate_secondary_indices has been activated.");
+
+       rebuild_usersbynumber();
+       rebuild_euid_index();
+       CtdlRebuildDirectoryIndex();
+       // we also need to trigger the fulltext foo
+
+       CtdlSetConfigInt("regenerate_secondary_indices", 0);
+}
+
+
 // Based on the server version number reported by the existing database,
 // run in-place data format upgrades until everything is up to date.
 void pre_startup_upgrades(void) {
@@ -455,33 +393,25 @@ void pre_startup_upgrades(void) {
                return;
        }
 
-       if ((oldver > 000) && (oldver < 591)) {
+       // After 2026-may-06 we will do the following:
+       // 1. Set the oldest upgradable version to 902 (it will then be ten years old)
+       // 2. Remove support for upgrading from the legacy config and control file formats.
+
+       // Currently, the oldest upgradable version is 811, which was released on 2012-may-21
+
+       if ((oldver > 000) && (oldver < 811)) {
                syslog(LOG_EMERG, "This database is too old to be upgraded.  Citadel server will exit.");
                exit(EXIT_FAILURE);
        }
-       if ((oldver > 000) && (oldver < 659)) {
-               rebuild_euid_index();
-       }
-       if (oldver < 735) {
-               fix_sys_user_name();
-       }
-       if (oldver < 736) {
-               rebuild_usersbynumber();
-       }
-       if (oldver < 790) {
-               remove_thread_users();
-       }
-       if (oldver < 810) {
-               struct ctdlroom QRoom;
-               if (!CtdlGetRoom(&QRoom, SMTP_SPOOLOUT_ROOM)) {
-                       QRoom.QRdefaultview = VIEW_QUEUE;
-                       CtdlPutRoom(&QRoom);
-               }
-       }
-
        if ((oldver > 000) && (oldver < 902)) {
                ingest_old_roominfo_and_roompic_files();
        }
+       if ((oldver > 000) && (oldver < 973)) {                         // This was the old extauth table.
+               cdb_trunc(CDB_UNUSED1);                                 // We will do this better someday.
+       }
+       if ((oldver > 000) && (oldver < 975)) {                         // An unrepairable defect was found in this table.
+               cdb_trunc(CDB_USETABLE);                                // We have to discard it and start over.
+       }
 
        CtdlSetConfigInt("MM_hosted_upgrade_level", REV_LEVEL);
 
@@ -513,23 +443,19 @@ void post_startup_upgrades(void) {
 
        if (oldver < REV_LEVEL) {
                syslog(LOG_WARNING, "Running post-startup database upgrades.");
-       }
-       else {
-               return;
-       }
-
-       if ((oldver > 000) && (oldver < 912)) {
-               move_inet_addrs_from_vcards_to_user_records();
-       }
-
-       if ((oldver > 000) && (oldver < 922)) {
-               ProcessOldStyleAdjRefCountQueue();
-       }
 
-       if ((oldver > 000) && (oldver < 930)) {
-               migrate_inbox_filter_msgnums();
+               if ((oldver > 000) && (oldver < 912)) {
+                       move_inet_addrs_from_vcards_to_user_records();
+               }
+       
+               if ((oldver > 000) && (oldver < 922)) {
+                       ProcessOldStyleAdjRefCountQueue();
+               }
+       
+               if ((oldver > 000) && (oldver < 930)) {
+                       migrate_inbox_filter_msgnums();
+               }
        }
-
 }