/*
* This module dumps and/or loads the Citadel database in XML format.
*
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2016 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3.
char migr_tempfilename2[PATH_MAX];
FILE *migr_global_message_list;
int total_msgs = 0;
+char *ikey = NULL; // If we're importing a config key we store it here.
/******************************************************************************
******************************************************************************/
/*
- * Output a string to the client with these characters escaped: & < >
+ * Output a string to the client with these characters escaped: & < > " '
*/
void xml_strout(char *str) {
* exporting the message multiple times.)
*/
snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
- if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno);
+ if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d", errno);
snprintf(cmd, sizeof cmd, "uniq <%s >%s", migr_tempfilename2, migr_tempfilename1);
- if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno);
+ if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d", errno);
snprintf(cmd, sizeof cmd, "wc -l %s", migr_tempfilename1);
Ctx = CC;
migr_global_message_list = fopen(migr_tempfilename1, "r");
if (migr_global_message_list != NULL) {
- syslog(LOG_INFO, "Opened %s\n", migr_tempfilename1);
+ syslog(LOG_INFO, "Opened %s", migr_tempfilename1);
while ((Ctx->kill_me == 0) &&
(fgets(buf, sizeof(buf), migr_global_message_list) != NULL)) {
msgnum = atol(buf);
fclose(migr_global_message_list);
}
if (Ctx->kill_me == 0)
- syslog(LOG_INFO, "Exported %d messages.\n", count);
+ syslog(LOG_INFO, "Exported %d messages.", count);
else
- syslog(LOG_ERR, "Export aborted due to client disconnect! \n");
+ syslog(LOG_ERR, "Export aborted due to client disconnect!");
migr_export_message(-1L); /* This frees the encoding buffer */
}
}
if (citadel_migrate_data != 1) {
- syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!\n", el);
+ syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!", el);
return;
}
import_msgnum = 0;
}
else if (!strcasecmp(el, "config")) {
- syslog(LOG_DEBUG, "\033[31m IMPORT OF CONFIG START ELEMENT FIXME\033\0m");
+ if (ikey != NULL) {
+ free(ikey);
+ ikey = NULL;
+ }
+ while (*attr) {
+ if (!strcasecmp(attr[0], "key")) {
+ ikey = strdup(attr[1]);
+ }
+ attr += 2;
+ }
}
}
}
if (citadel_migrate_data != 1) {
- syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!\n", el);
+ syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!", el);
return;
}
if (!strcasecmp(el, "config"))
{
- syslog(LOG_DEBUG, "\033[31m IMPORT OF CONFIG END ELEMENT FIXME\033\0m");
- CtdlSetConfigInt("c_enable_fulltext", 0); /* always disable FIXME put this somewhere more appropriate */
+ syslog(LOG_DEBUG, "Imported config key=%s", ikey);
+
+ if (ikey != NULL) {
+ CtdlSetConfigStr(ikey, ChrPtr(migr_chardata));
+ free(ikey);
+ ikey = NULL;
+ }
+ else {
+ syslog(LOG_INFO, "Closed a <config> tag but no key name was supplied.");
+ }
}
/*** USER ***/
; /* Nothing to do anymore */
else if (!strcasecmp(el, "user")) {
CtdlPutUser(&usbuf);
- syslog(LOG_INFO, "Imported user: %s\n", usbuf.fullname);
+ syslog(LOG_INFO, "Imported user: %s", usbuf.fullname);
}
/*** OPENID ***/
memcpy(&oid_data[sizeof(long)], openid_url, strlen(openid_url) + 1);
cdb_store(CDB_OPENID, openid_url, strlen(openid_url), oid_data, oid_data_len);
free(oid_data);
- syslog(LOG_INFO, "Imported OpenID: %s (%ld)\n", openid_url, openid_usernum);
+ syslog(LOG_INFO, "Imported OpenID: %s (%ld)", openid_url, openid_usernum);
}
/*** ROOM ***/
; /* Nothing to do anymore */
else if (!strcasecmp(el, "room")) {
CtdlPutRoom(&qrbuf);
- syslog(LOG_INFO, "Imported room: %s\n", qrbuf.QRname);
+ syslog(LOG_INFO, "Imported room: %s", qrbuf.QRname);
}
/*** ROOM MESSAGE POINTERS ***/
msglist_alloc = 1000;
msglist = malloc(sizeof(long) * msglist_alloc);
- syslog(LOG_DEBUG, "Message list for: %s\n", FRname);
+ syslog(LOG_DEBUG, "Message list for: %s", FRname);
ptr = ChrPtr(migr_chardata);
while (*ptr != 0) {
free(msglist);
msglist = NULL;
msglist_alloc = 0;
- syslog(LOG_DEBUG, "Imported %d messages.\n", msgcount);
+ syslog(LOG_DEBUG, "Imported %d messages.", msgcount);
if (server_shutting_down) {
return;
}
else if (!strcasecmp(el, "floor")) {
CtdlPutFloor(&flbuf, floornum);
- syslog(LOG_INFO, "Imported floor #%d (%s)\n", floornum, flbuf.f_name);
+ syslog(LOG_INFO, "Imported floor #%d (%s)", floornum, flbuf.f_name);
}
/*** VISITS ***/
; /* Nothing to do anymore */
else if (!strcasecmp(el, "visit")) {
put_visit(&vbuf);
- syslog(LOG_INFO, "Imported visit: %ld/%ld/%ld\n", vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
+ syslog(LOG_INFO, "Imported visit: %ld/%ld/%ld", vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
}
/*** MESSAGES ***/
}
syslog(LOG_INFO,
- "%s message #%ld, size=%d, refcount=%d, bodylength=%ld, content-type: %s / %s \n",
+ "%s message #%ld, size=%d, refcount=%d, bodylength=%ld, content-type: %s / %s",
(rc!= 0)?"failed to import ":"Imported ",
import_msgnum,
StrLength(migr_MsgData),
FreeStrBuf(&migr_MsgData);
rebuild_euid_index();
rebuild_usersbynumber();
+ CtdlSetConfigInt("MM_fulltext_wordbreaker", -1); // Set an invalid wordbreaker to force re-indexing
CC->dont_term = 0;
}
cprintf("files|%s\n", ctdl_file_dir);
cprintf("userpics|%s\n", ctdl_usrpic_dir);
cprintf("messages|%s\n", ctdl_message_dir);
- cprintf("netconfigs|%s\n", ctdl_netcfg_dir);
cprintf("keys|%s\n", ctdl_key_dir);
cprintf("images|%s\n", ctdl_image_dir);
cprintf("info|%s\n", ctdl_info_dir);
syslog(LOG_INFO,
- "Setting message #%ld meta data to: refcount=%d, bodylength=%ld, content-type: %s / %s \n",
+ "Setting message #%ld meta data to: refcount=%d, bodylength=%ld, content-type: %s / %s",
smi.meta_msgnum,
smi.meta_refcount,
smi.meta_rfc822_length,
void migr_do_restore_meta(void) {
char buf[SIZ];
int failGetMessage;
- long msgnum;
+ long msgnum = 0;
int lastnum = 0;
int refcount = 0;
CitContext *Ctx;
* exporting the message multiple times.)
*/
snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
- if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno);
+ if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d", errno);
RoomNames = NewStrBuf();
Ctx = CC;
migr_global_message_list = fopen(migr_tempfilename2, "r");
if (migr_global_message_list != NULL) {
- syslog(LOG_INFO, "Opened %s\n", migr_tempfilename1);
+ syslog(LOG_INFO, "Opened %s", migr_tempfilename1);
while ((Ctx->kill_me == 0) &&
(fgets(buf, sizeof(buf), migr_global_message_list) != NULL)) {
msgnum = atol(buf);