X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fupgrade%2Fserv_upgrade.c;h=86e2947f440bf5e072a19756abc7a1569de49f2c;hb=f59e2e6772d87d323d065f09919ec0876bf2e0be;hp=846a693e5ca2b2ebbc19022b2cc721535c96037c;hpb=41544d6edeaaee1d6563b3e30e0ec2c29d5cca41;p=citadel.git diff --git a/citadel/modules/upgrade/serv_upgrade.c b/citadel/modules/upgrade/serv_upgrade.c index 846a693e5..86e2947f4 100644 --- a/citadel/modules/upgrade/serv_upgrade.c +++ b/citadel/modules/upgrade/serv_upgrade.c @@ -4,7 +4,7 @@ * guesses about what kind of data format changes need to be applied, and * we apply them transparently. * - * Copyright (c) 1987-2019 by the citadel.org team + * Copyright (c) 1987-2020 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. @@ -84,7 +84,7 @@ void fix_sys_user_name(void) /* Delete any "user 0" accounts */ while (CtdlGetUserByNumber(&usbuf, -1) == 0) { - makeuserkey(usernamekey, usbuf.fullname, cutusername(usbuf.fullname)); + makeuserkey(usernamekey, usbuf.fullname); cdb_delete(CDB_USERS, usernamekey, strlen(usernamekey)); } } @@ -471,6 +471,21 @@ void move_inet_addrs_from_vcards_to_user_records(void) } +/* + * Create a default administrator account so we can log in to a new installation + */ +void create_default_admin_account(void) { + struct ctdluser usbuf; + + create_user(DEFAULT_ADMIN_USERNAME, CREATE_USER_DO_NOT_BECOME_USER, (-1)); + CtdlGetUser(&usbuf, DEFAULT_ADMIN_USERNAME); + safestrncpy(usbuf.password, DEFAULT_ADMIN_PASSWORD, sizeof(usbuf.password)); + usbuf.axlevel = AxAideU; + CtdlPutUser(&usbuf); + CtdlSetConfigStr("c_sysadm", DEFAULT_ADMIN_USERNAME); +} + + /* * Based on the server version number reported by the existing database, * run in-place data format upgrades until everything is up to date. @@ -536,6 +551,13 @@ void pre_startup_upgrades(void) { CtdlSetConfigInt("c_ep_mode", EXPIRE_MANUAL); CtdlSetConfigInt("c_ep_value", 0); } + + /* + * If this is the first run on an empty database, create a default administrator + */ + if (oldver == 0) { + create_default_admin_account(); + } }