]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_upgrade.c
mk_module_init.sh now tests to see if echo supports -e and -E
[citadel.git] / citadel / serv_upgrade.c
index 9e4c9324b1907d66a91e738f560cc95d05f910fa..2956e79a088382d9f1ed178b6374b011a348d552 100644 (file)
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
 #include "control.h"
-#include "serv_extensions.h"
 #include "database.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "msgbase.h"
 #include "tools.h"
 #include "serv_upgrade.h"
+#include "euidindex.h"
 
 
+#include "ctdl_module.h"
+
 
 /* 
  * Back end processing function for cmd_bmbx
@@ -60,7 +61,7 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
         */
        if (qrbuf != NULL) {
                ptr = (struct RoomProcList *)
-                       mallok(sizeof (struct RoomProcList));
+                       malloc(sizeof (struct RoomProcList));
                if (ptr == NULL) return;
 
                safestrncpy(ptr->name, qrbuf->QRname, sizeof ptr->name);
@@ -72,21 +73,21 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
        while (rplist != NULL) {
 
                if (lgetroom(&qr, rplist->name) == 0) {
-                       lprintf(9, "Processing <%s>...\n", rplist->name);
+                       lprintf(CTDL_DEBUG, "Processing <%s>...\n", rplist->name);
                        if ( (qr.QRflags & QR_MAILBOX) == 0) {
-                               lprintf(9, "  -- not a mailbox\n");
+                               lprintf(CTDL_DEBUG, "  -- not a mailbox\n");
                        }
                        else {
 
                                qr.QRgen = time(NULL);
-                               lprintf(9, "  -- fixed!\n");
+                               lprintf(CTDL_DEBUG, "  -- fixed!\n");
                        }
                        lputroom(&qr);
                }
 
                ptr = rplist;
                rplist = rplist->next;
-               phree(ptr);
+               free(ptr);
        }
 }
 
@@ -94,7 +95,7 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
  * quick fix to bump mailbox generation numbers
  */
 void bump_mailbox_generation_numbers(void) {
-       lprintf(5, "Applying security fix to mailbox rooms\n");
+       lprintf(CTDL_WARNING, "Applying security fix to mailbox rooms\n");
        ForEachRoom(cmd_bmbx_backend, NULL);
        cmd_bmbx_backend(NULL, NULL);
        return;
@@ -102,7 +103,7 @@ void bump_mailbox_generation_numbers(void) {
 
 
 /* 
- * Back end processing function for convert_bbsuid_to_minusone()
+ * Back end processing function for convert_ctdluid_to_minusone()
  */
 void cbtm_backend(struct ctdluser *usbuf, void *data) {
        static struct UserProcList *uplist = NULL;
@@ -115,7 +116,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) {
         */
        if (usbuf != NULL) {
                ptr = (struct UserProcList *)
-                       mallok(sizeof (struct UserProcList));
+                       malloc(sizeof (struct UserProcList));
                if (ptr == NULL) return;
 
                safestrncpy(ptr->user, usbuf->fullname, sizeof ptr->user);
@@ -127,8 +128,8 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) {
        while (uplist != NULL) {
 
                if (lgetuser(&us, uplist->user) == 0) {
-                       lprintf(9, "Processing <%s>...\n", uplist->user);
-                       if (us.uid == BBSUID) {
+                       lprintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user);
+                       if (us.uid == CTDLUID) {
                                us.uid = (-1);
                        }
                        lputuser(&us);
@@ -136,15 +137,15 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) {
 
                ptr = uplist;
                uplist = uplist->next;
-               phree(ptr);
+               free(ptr);
        }
 }
 
 /*
- * quick fix to change all BBSUID users to (-1)
+ * quick fix to change all CTDLUID users to (-1)
  */
-void convert_bbsuid_to_minusone(void) {
-       lprintf(5, "Applying uid changes\n");
+void convert_ctdluid_to_minusone(void) {
+       lprintf(CTDL_WARNING, "Applying uid changes\n");
        ForEachUser(cbtm_backend, NULL);
        cbtm_backend(NULL, NULL);
        return;
@@ -164,6 +165,22 @@ void update_config(void) {
                config.c_purge_hour = 3;
        }
 
+       if (CitControl.version < 615) {
+               config.c_ldap_port = 389;
+       }
+
+       if (CitControl.version < 623) {
+               strcpy(config.c_ip_addr, "0.0.0.0");
+       }
+
+       if (CitControl.version < 650) {
+               config.c_enable_fulltext = 0;
+       }
+
+       if (CitControl.version < 652) {
+               config.c_auto_cull = 1;
+       }
+
        put_config();
 }
 
@@ -173,13 +190,14 @@ void update_config(void) {
 void check_server_upgrades(void) {
 
        get_control();
-       lprintf(5, "Server-hosted upgrade level is %d.%02d\n",
+       lprintf(CTDL_INFO, "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");
+               lprintf(CTDL_WARNING,
+                       "Server hosted updates need to be processed at "
+                       "this time.  Please wait...\n");
        }
        else {
                return;
@@ -187,22 +205,31 @@ void check_server_upgrades(void) {
 
        update_config();
 
-       if (CitControl.version < 555) {
-               lprintf(1, "Your data files are from a version of Citadel\n"
+       if ((CitControl.version > 000) && (CitControl.version < 555)) {
+               lprintf(CTDL_EMERG,
+                       "Your data files are from a version of Citadel\n"
                        "that is too old to be upgraded.  Sorry.\n");
                exit(EXIT_FAILURE);
        }
-
-       if (CitControl.version < 591) bump_mailbox_generation_numbers();
-       if (CitControl.version < 608) convert_bbsuid_to_minusone();
+       if ((CitControl.version > 000) && (CitControl.version < 591)) {
+               bump_mailbox_generation_numbers();
+       }
+       if ((CitControl.version > 000) && (CitControl.version < 608)) {
+               convert_ctdluid_to_minusone();
+       }
+       if ((CitControl.version > 000) && (CitControl.version < 659)) {
+               rebuild_euid_index();
+       }
 
        CitControl.version = REV_LEVEL;
        put_control();
 }
 
 
-char *serv_upgrade_init(void)
+CTDL_MODULE_INIT(upgrade)
 {
        check_server_upgrades();
+
+       /* return our Subversion id for the Log */
        return "$Id$";
 }