4 * Transparently handle the upgrading of server data formats.
16 #include <sys/types.h>
18 #if TIME_WITH_SYS_TIME
19 # include <sys/time.h>
23 # include <sys/time.h>
34 #include "sysdep_decls.h"
35 #include "citserver.h"
39 #include "serv_extensions.h"
45 #include "serv_upgrade.h"
46 #include "euidindex.h"
51 * Back end processing function for cmd_bmbx
53 void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
54 static struct RoomProcList *rplist = NULL;
55 struct RoomProcList *ptr;
58 /* Lazy programming here. Call this function as a ForEachRoom backend
59 * in order to queue up the room names, or call it with a null room
60 * to make it do the processing.
63 ptr = (struct RoomProcList *)
64 malloc(sizeof (struct RoomProcList));
65 if (ptr == NULL) return;
67 safestrncpy(ptr->name, qrbuf->QRname, sizeof ptr->name);
73 while (rplist != NULL) {
75 if (lgetroom(&qr, rplist->name) == 0) {
76 lprintf(CTDL_DEBUG, "Processing <%s>...\n", rplist->name);
77 if ( (qr.QRflags & QR_MAILBOX) == 0) {
78 lprintf(CTDL_DEBUG, " -- not a mailbox\n");
82 qr.QRgen = time(NULL);
83 lprintf(CTDL_DEBUG, " -- fixed!\n");
89 rplist = rplist->next;
95 * quick fix to bump mailbox generation numbers
97 void bump_mailbox_generation_numbers(void) {
98 lprintf(CTDL_WARNING, "Applying security fix to mailbox rooms\n");
99 ForEachRoom(cmd_bmbx_backend, NULL);
100 cmd_bmbx_backend(NULL, NULL);
106 * Back end processing function for convert_ctdluid_to_minusone()
108 void cbtm_backend(struct ctdluser *usbuf, void *data) {
109 static struct UserProcList *uplist = NULL;
110 struct UserProcList *ptr;
113 /* Lazy programming here. Call this function as a ForEachUser backend
114 * in order to queue up the room names, or call it with a null user
115 * to make it do the processing.
118 ptr = (struct UserProcList *)
119 malloc(sizeof (struct UserProcList));
120 if (ptr == NULL) return;
122 safestrncpy(ptr->user, usbuf->fullname, sizeof ptr->user);
128 while (uplist != NULL) {
130 if (lgetuser(&us, uplist->user) == 0) {
131 lprintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user);
132 if (us.uid == CTDLUID) {
139 uplist = uplist->next;
145 * quick fix to change all CTDLUID users to (-1)
147 void convert_ctdluid_to_minusone(void) {
148 lprintf(CTDL_WARNING, "Applying uid changes\n");
149 ForEachUser(cbtm_backend, NULL);
150 cbtm_backend(NULL, NULL);
155 * Do various things to our configuration file
157 void update_config(void) {
160 if (CitControl.version < 606) {
161 config.c_rfc822_strict_from = 0;
164 if (CitControl.version < 609) {
165 config.c_purge_hour = 3;
168 if (CitControl.version < 615) {
169 config.c_ldap_port = 389;
172 if (CitControl.version < 623) {
173 strcpy(config.c_ip_addr, "0.0.0.0");
176 if (CitControl.version < 650) {
177 config.c_enable_fulltext = 0;
180 if (CitControl.version < 652) {
181 config.c_auto_cull = 1;
190 void check_server_upgrades(void) {
193 lprintf(CTDL_INFO, "Server-hosted upgrade level is %d.%02d\n",
194 (CitControl.version / 100),
195 (CitControl.version % 100) );
197 if (CitControl.version < REV_LEVEL) {
198 lprintf(CTDL_WARNING,
199 "Server hosted updates need to be processed at "
200 "this time. Please wait...\n");
208 if ((CitControl.version > 000) && (CitControl.version < 555)) {
210 "Your data files are from a version of Citadel\n"
211 "that is too old to be upgraded. Sorry.\n");
214 if ((CitControl.version > 000) && (CitControl.version < 591)) {
215 bump_mailbox_generation_numbers();
217 if ((CitControl.version > 000) && (CitControl.version < 608)) {
218 convert_ctdluid_to_minusone();
220 if ((CitControl.version > 000) && (CitControl.version < 659)) {
221 rebuild_euid_index();
224 CitControl.version = REV_LEVEL;
229 char *serv_upgrade_init(void)
231 check_server_upgrades();
233 /* return our Subversion id for the Log */