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"
50 * Back end processing function for cmd_bmbx
52 void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
53 static struct RoomProcList *rplist = NULL;
54 struct RoomProcList *ptr;
57 /* Lazy programming here. Call this function as a ForEachRoom backend
58 * in order to queue up the room names, or call it with a null room
59 * to make it do the processing.
62 ptr = (struct RoomProcList *)
63 malloc(sizeof (struct RoomProcList));
64 if (ptr == NULL) return;
66 safestrncpy(ptr->name, qrbuf->QRname, sizeof ptr->name);
72 while (rplist != NULL) {
74 if (lgetroom(&qr, rplist->name) == 0) {
75 lprintf(CTDL_DEBUG, "Processing <%s>...\n", rplist->name);
76 if ( (qr.QRflags & QR_MAILBOX) == 0) {
77 lprintf(CTDL_DEBUG, " -- not a mailbox\n");
81 qr.QRgen = time(NULL);
82 lprintf(CTDL_DEBUG, " -- fixed!\n");
88 rplist = rplist->next;
94 * quick fix to bump mailbox generation numbers
96 void bump_mailbox_generation_numbers(void) {
97 lprintf(CTDL_WARNING, "Applying security fix to mailbox rooms\n");
98 ForEachRoom(cmd_bmbx_backend, NULL);
99 cmd_bmbx_backend(NULL, NULL);
105 * Back end processing function for convert_ctdluid_to_minusone()
107 void cbtm_backend(struct ctdluser *usbuf, void *data) {
108 static struct UserProcList *uplist = NULL;
109 struct UserProcList *ptr;
112 /* Lazy programming here. Call this function as a ForEachUser backend
113 * in order to queue up the room names, or call it with a null user
114 * to make it do the processing.
117 ptr = (struct UserProcList *)
118 malloc(sizeof (struct UserProcList));
119 if (ptr == NULL) return;
121 safestrncpy(ptr->user, usbuf->fullname, sizeof ptr->user);
127 while (uplist != NULL) {
129 if (lgetuser(&us, uplist->user) == 0) {
130 lprintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user);
131 if (us.uid == CTDLUID) {
138 uplist = uplist->next;
144 * quick fix to change all CTDLUID users to (-1)
146 void convert_ctdluid_to_minusone(void) {
147 lprintf(CTDL_WARNING, "Applying uid changes\n");
148 ForEachUser(cbtm_backend, NULL);
149 cbtm_backend(NULL, NULL);
154 * Do various things to our configuration file
156 void update_config(void) {
159 if (CitControl.version < 606) {
160 config.c_rfc822_strict_from = 0;
163 if (CitControl.version < 609) {
164 config.c_purge_hour = 3;
167 if (CitControl.version < 615) {
168 config.c_ldap_port = 389;
171 if (CitControl.version < 623) {
172 strcpy(config.c_ip_addr, "0.0.0.0");
175 if (CitControl.version < 650) {
176 config.c_enable_fulltext = 0;
185 void check_server_upgrades(void) {
188 lprintf(CTDL_INFO, "Server-hosted upgrade level is %d.%02d\n",
189 (CitControl.version / 100),
190 (CitControl.version % 100) );
192 if (CitControl.version < REV_LEVEL) {
193 lprintf(CTDL_WARNING,
194 "Server hosted updates need to be processed at "
195 "this time. Please wait...\n");
203 if ((CitControl.version > 000) && (CitControl.version < 555)) {
205 "Your data files are from a version of Citadel\n"
206 "that is too old to be upgraded. Sorry.\n");
209 if ((CitControl.version > 000) && (CitControl.version < 591)) {
210 bump_mailbox_generation_numbers();
212 if ((CitControl.version > 000) && (CitControl.version < 608)) {
213 convert_ctdluid_to_minusone();
216 CitControl.version = REV_LEVEL;
221 char *serv_upgrade_init(void)
223 check_server_upgrades();