]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_upgrade.c
* Sysconfig commands for specifying where the LDAP server lives
[citadel.git] / citadel / serv_upgrade.c
index 3bd60e9e07c0135e7259ed22acba2edf48f6ec78..8a8c49213d7523d64bae2fa4de7c65c8d57dfe52 100644 (file)
 #include "tools.h"
 #include "serv_upgrade.h"
 
-void do_pre555_user_upgrade(void) {
-        struct pre555user usbuf;
-       struct user newus;
-        struct cdbdata *cdbus;
-       char tempfilename[PATH_MAX];
-       FILE *fp, *tp;
-       static char vcard[1024];
-
-       lprintf(5, "Upgrading user file\n");
-       fp = tmpfile();
-       if (fp == NULL) {
-               lprintf(1, "%s\n", strerror(errno));
-               exit(errno);
-       }
-       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 pre555user));
-                memcpy(&usbuf, cdbus->ptr,
-                               ( (cdbus->len > sizeof(struct pre555user)) ?
-                               sizeof(struct pre555user) : cdbus->len) );
-                cdb_free(cdbus);
-               fwrite(&usbuf, sizeof(struct pre555user), 1, fp);
-       }
-
-       /* ...and overwrite the records with new format records */
-       rewind(fp);
-       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 user));
-
-               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_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_uint8_t) usbuf.USscreenwidth;
-               newus.USscreenheight = (cit_uint8_t) usbuf.USscreenheight;
-
-               putuser(&newus);
-
-               /* write the vcard */
-               snprintf(vcard, sizeof vcard,
-                       "Content-type: text/x-vcard\n\n"
-                       "begin:vcard\n"
-                       "n:%s\n"
-                       "tel;home:%s\n"
-                       "email;internet:%s\n"
-                       "adr:;;%s;%s;%s;%s;USA\n"
-                       "end:vcard\n",
-                       usbuf.USname,
-                       usbuf.USphone,
-                       usbuf.USemail,
-                       usbuf.USaddr,
-                       usbuf.UScity,
-                       usbuf.USstate,
-                       usbuf.USzip);
-
-               tp = fopen(tempfilename, "w");
-               fwrite(vcard, strlen(vcard)+1, 1, tp);
-               fclose(tp);
-
-               CtdlWriteObject(USERCONFIGROOM, "text/x-vcard",
-                       tempfilename, &newus, 0, 1, CM_SKIP_HOOKS);
-               unlink(tempfilename);
-           }
-       }
-
-       fclose(fp);     /* this file deletes automatically */
-}
-
-
-
-
-
-
 
 
 /* 
  * Back end processing function for cmd_bmbx
  */
-void cmd_bmbx_backend(struct room *qrbuf, void *data) {
+void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
        static struct RoomProcList *rplist = NULL;
        struct RoomProcList *ptr;
-       struct room 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
@@ -188,10 +104,10 @@ void bump_mailbox_generation_numbers(void) {
 /* 
  * Back end processing function for convert_bbsuid_to_minusone()
  */
-void cbtm_backend(struct user *usbuf, void *data) {
+void cbtm_backend(struct ctdluser *usbuf, void *data) {
        static struct UserProcList *uplist = NULL;
        struct UserProcList *ptr;
-       struct user us;
+       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
@@ -234,14 +150,24 @@ void convert_bbsuid_to_minusone(void) {
        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.
+ * Do various things to our configuration file
  */
-void initialize_c_rfc822_strict_from(void) {
+void update_config(void) {
        get_config();
-       config.c_rfc822_strict_from = 0;
+
+       if (CitControl.version < 606) {
+               config.c_rfc822_strict_from = 0;
+       }
+
+       if (CitControl.version < 609) {
+               config.c_purge_hour = 3;
+       }
+
+       if (CitControl.version < 615) {
+               config.c_ldap_port = 389;
+       }
+
        put_config();
 }
 
@@ -263,25 +189,25 @@ void check_server_upgrades(void) {
                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();
+       update_config();
+
+       if ((CitControl.version > 000) && (CitControl.version < 555)) {
+               lprintf(1, "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 > 000) && (CitControl.version < 591)) {
+               bump_mailbox_generation_numbers();
+       }
+       if ((CitControl.version > 000) && (CitControl.version < 608)) {
+               convert_bbsuid_to_minusone();
+       }
 
        CitControl.version = REV_LEVEL;
        put_control();
 }
 
 
-
-
-
-
-
-
-
-
-
 char *serv_upgrade_init(void)
 {
        check_server_upgrades();