]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_upgrade.c
* Renamed "dynloader" to "serv_extensions" globally. We don't want people
[citadel.git] / citadel / serv_upgrade.c
index 51d0e430f25baa4093cc18945c745627d15798c1..55840f88a89317c89affa9d8268c53ff89c1f178 100644 (file)
 #include <pwd.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include <sys/wait.h>
 #include <string.h>
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include <time.h>
 #include "sysdep_decls.h"
 #include "citserver.h"
 #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 "msgbase.h"
+#include "tools.h"
 #include "serv_upgrade.h"
 
 void do_pre555_usersupp_upgrade(void) {
@@ -49,7 +61,6 @@ void do_pre555_usersupp_upgrade(void) {
        strcpy(tempfilename, tmpnam(NULL));
 
        /* First, back out all old version records to a flat file */
-       cdb_begin_transaction();
         cdb_rewind(CDB_USERSUPP);
         while(cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
                 memset(&usbuf, 0, sizeof(struct pre555usersupp));
@@ -59,7 +70,6 @@ void do_pre555_usersupp_upgrade(void) {
                 cdb_free(cdbus);
                fwrite(&usbuf, sizeof(struct pre555usersupp), 1, fp);
        }
-       cdb_end_transaction();
 
        /* ...and overwrite the records with new format records */
        rewind(fp);
@@ -73,18 +83,18 @@ void do_pre555_usersupp_upgrade(void) {
                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);
 
                /* write the vcard */
-               sprintf(vcard,
+               snprintf(vcard, sizeof vcard,
                        "Content-type: text/x-vcard\n\n"
                        "begin:vcard\n"
                        "n:%s\n"
@@ -120,6 +130,65 @@ void do_pre555_usersupp_upgrade(void) {
 
 
 
+/* 
+ * Back end processing function for cmd_bmbx
+ */
+void cmd_bmbx_backend(struct quickroom *qrbuf, void *data) {
+       static struct RoomProcList *rplist = NULL;
+       struct RoomProcList *ptr;
+       struct quickroom 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
+        * to make it do the processing.
+        */
+       if (qrbuf != NULL) {
+               ptr = (struct RoomProcList *)
+                       mallok(sizeof (struct RoomProcList));
+               if (ptr == NULL) return;
+
+               safestrncpy(ptr->name, qrbuf->QRname, sizeof ptr->name);
+               ptr->next = rplist;
+               rplist = ptr;
+               return;
+       }
+
+       while (rplist != NULL) {
+
+               if (lgetroom(&qr, rplist->name) == 0) {
+                       lprintf(9, "Processing <%s>...\n", rplist->name);
+                       if ( (qr.QRflags & QR_MAILBOX) == 0) {
+                               lprintf(9, "  -- not a mailbox\n");
+                       }
+                       else {
+
+                               qr.QRgen = time(NULL);
+                               lprintf(9, "  -- fixed!\n");
+                       }
+                       lputroom(&qr);
+               }
+
+               ptr = rplist;
+               rplist = rplist->next;
+               phree(ptr);
+       }
+}
+
+/*
+ * quick fix to bump mailbox generation numbers
+ */
+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;
+}
+
+
+
+
+
+
 void check_server_upgrades(void) {
 
        get_control();
@@ -136,6 +205,7 @@ void check_server_upgrades(void) {
        }
 
        if (CitControl.version < 555) do_pre555_usersupp_upgrade();
+       if (CitControl.version < 591) bump_mailbox_generation_numbers();
 
        CitControl.version = REV_LEVEL;
        put_control();
@@ -144,7 +214,14 @@ void check_server_upgrades(void) {
 
 
 
-char *Dynamic_Module_Init(void)
+
+
+
+
+
+
+
+char *serv_upgrade_init(void)
 {
        check_server_upgrades();
        return "$Id$";