#include <sys/wait.h>
#include <string.h>
#include <limits.h>
+#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "room_ops.h"
#include "user_ops.h"
#include "msgbase.h"
-#include "tools.h"
#include "serv_upgrade.h"
#include "euidindex.h"
#include "ctdl_module.h"
+
+/*
+ * Fix up the name for Citadel user 0 and try to remove any extra users with number 0
+ */
+void fix_sys_user_name(void)
+{
+ struct ctdluser usbuf;
+ char usernamekey[USERNAME_SIZE];
+
+ /** If we have a user called Citadel rename them to SYS_Citadel */
+ if (getuser(&usbuf, "Citadel") == 0)
+ {
+ rename_user("Citadel", "SYS_Citadel");
+ }
+
+ while (getuserbynumber(&usbuf, 0) == 0)
+ {
+ /* delete user with number 0 and no name */
+ if (IsEmptyStr(usbuf.fullname))
+ cdb_delete(CDB_USERS, "", 0);
+ else
+ { /* temporarily set this user to -1 */
+ usbuf.usernum = -1;
+ putuser(&usbuf);
+ }
+ }
+
+ /** Make sure user SYS_* is user 0 */
+ while (getuserbynumber(&usbuf, -1) == 0)
+ {
+ if (strncmp(usbuf.fullname, "SYS_", 4))
+ { /** Delete any user 0 that doesn't start with SYS_ */
+ makeuserkey(usernamekey, usbuf.fullname);
+ cdb_delete(CDB_USERS, usernamekey, strlen(usernamekey));
+ }
+ else
+ {
+ usbuf.usernum = 0;
+ putuser(&usbuf);
+ }
+ }
+}
+
+
/*
* Back end processing function for cmd_bmbx
*/
while (rplist != NULL) {
if (lgetroom(&qr, rplist->name) == 0) {
- lprintf(CTDL_DEBUG, "Processing <%s>...\n", rplist->name);
+ CtdlLogPrintf(CTDL_DEBUG, "Processing <%s>...\n", rplist->name);
if ( (qr.QRflags & QR_MAILBOX) == 0) {
- lprintf(CTDL_DEBUG, " -- not a mailbox\n");
+ CtdlLogPrintf(CTDL_DEBUG, " -- not a mailbox\n");
}
else {
qr.QRgen = time(NULL);
- lprintf(CTDL_DEBUG, " -- fixed!\n");
+ CtdlLogPrintf(CTDL_DEBUG, " -- fixed!\n");
}
lputroom(&qr);
}
* quick fix to bump mailbox generation numbers
*/
void bump_mailbox_generation_numbers(void) {
- lprintf(CTDL_WARNING, "Applying security fix to mailbox rooms\n");
+ CtdlLogPrintf(CTDL_WARNING, "Applying security fix to mailbox rooms\n");
ForEachRoom(cmd_bmbx_backend, NULL);
cmd_bmbx_backend(NULL, NULL);
return;
while (uplist != NULL) {
if (lgetuser(&us, uplist->user) == 0) {
- lprintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user);
+ CtdlLogPrintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user);
if (us.uid == CTDLUID) {
us.uid = (-1);
}
* quick fix to change all CTDLUID users to (-1)
*/
void convert_ctdluid_to_minusone(void) {
- lprintf(CTDL_WARNING, "Applying uid changes\n");
+ CtdlLogPrintf(CTDL_WARNING, "Applying uid changes\n");
ForEachUser(cbtm_backend, NULL);
cbtm_backend(NULL, NULL);
return;
config.c_auto_cull = 1;
}
+ if (CitControl.version < 725) {
+ config.c_xmpp_c2s_port = 5222;
+ config.c_xmpp_s2s_port = 5269;
+ }
+
put_config();
}
void check_server_upgrades(void) {
get_control();
- lprintf(CTDL_INFO, "Server-hosted upgrade level is %d.%02d\n",
+ CtdlLogPrintf(CTDL_INFO, "Server-hosted upgrade level is %d.%02d\n",
(CitControl.version / 100),
(CitControl.version % 100) );
if (CitControl.version < REV_LEVEL) {
- lprintf(CTDL_WARNING,
+ CtdlLogPrintf(CTDL_WARNING,
"Server hosted updates need to be processed at "
"this time. Please wait...\n");
}
update_config();
if ((CitControl.version > 000) && (CitControl.version < 555)) {
- lprintf(CTDL_EMERG,
+ CtdlLogPrintf(CTDL_EMERG,
"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 < 659)) {
rebuild_euid_index();
}
-
+ if (CitControl.version > 734) {
+ fix_sys_user_name();
+ }
CitControl.version = REV_LEVEL;
put_control();
}
-CTDL_MODULE_INIT(upgrade)
+CTDL_MODULE_UPGRADE(upgrade)
{
check_server_upgrades();
-
+
/* return our Subversion id for the Log */
return "$Id$";
}