2 * Citadel setup utility
4 * Copyright (c) 1987-2019 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #define SHOW_ME_VAPPEND_PRINTF
22 #include <sys/types.h>
31 #include <sys/socket.h>
34 #include <libcitadel.h>
38 #include "citadel_dirs.h"
46 #define _(string) gettext(string)
48 #define _(string) (string)
51 #define UI_TEXT 0 /* Default setup type -- text only */
52 #define UI_DIALOG 2 /* Use the 'whiptail' or 'dialog' program */
53 #define UI_SILENT 3 /* Silent running, for use in scripts */
55 #define SERVICE_NAME "citadel"
56 #define PROTO_NAME "tcp"
57 #define NSSCONF "/etc/nsswitch.conf"
59 typedef enum _SetupStep {
75 ///"CREATE_XINETD_ENTRY";
76 /* Environment variables, don't translate! */
77 const char *EnvNames [eMaxQuestions] = {
92 int setup_type = (-1);
97 int serv_sock = (-1) ;
99 const char *setup_titles[eMaxQuestions];
100 const char *setup_text[eMaxQuestions];
114 setlocale(LC_MESSAGES, getenv("LANG"));
116 bindtextdomain("citadel-setup", LOCALEDIR"/locale");
117 textdomain("citadel-setup");
118 bind_textdomain_codeset("citadel-setup","UTF8");
121 setup_titles[eCitadelHomeDir] = _("Citadel Home Directory");
123 setup_text[eCitadelHomeDir] = _(
124 "Enter the full pathname of the directory in which the Citadel\n"
125 "installation you are creating or updating resides. If you\n"
126 "specify a directory other than the default, you will need to\n"
127 "specify the -h flag to the server when you start it up.\n");
129 setup_text[eCitadelHomeDir] = _(
130 "Enter the subdirectory name for an alternate installation of "
131 "Citadel. To do a default installation just leave it blank."
132 "If you specify a directory other than the default, you will need to\n"
133 "specify the -h flag to the server when you start it up.\n"
134 "note that it may not have a leading /");
137 setup_titles[eSysAdminName] = _("Citadel administrator username:");
138 setup_text[eSysAdminName] = _(
139 "Please enter the name of the Citadel user account that should be granted "
140 "administrative privileges once created. If using internal authentication "
141 "this user account will be created if it does not exist. For external "
142 "authentication this user account has to exist.");
145 setup_titles[eSysAdminPW] = _("Administrator password:");
146 setup_text[eSysAdminPW] = _(
147 "Enter a password for the system administrator. When setup\n"
148 "completes it will attempt to create the administrator user\n"
149 "and set the password specified here.\n");
151 setup_titles[eUID] = _("Citadel User ID:");
152 setup_text[eUID] = _(
153 "Citadel needs to run under its own user ID. This would\n"
154 "typically be called \"citadel\", but if you are running Citadel\n"
155 "as a public site, you might also call it \"bbs\" or \"guest\".\n"
156 "The server will run under this user ID. Please specify that\n"
157 "user ID here. You may specify either a user name or a numeric\n"
160 setup_titles[eIP_ADDR] = _("Listening address for the Citadel server:");
161 setup_text[eIP_ADDR] = _(
162 "Please specify the IP address which the server should be listening to. "
163 "You can name a specific IPv4 or IPv6 address, or you can specify\n"
164 "\"*\" for \"any address\", \"::\" for \"any IPv6 address\", or \"0.0.0.0\"\n"
165 "for \"any IPv4 address\". If you leave this blank, Citadel will\n"
166 "listen on all addresses. "
167 "This can usually be left to the default unless multiple instances of Citadel "
168 "are running on the same computer.");
170 setup_titles[eCTDL_Port] = _("Server port number:");
171 setup_text[eCTDL_Port] = _(
172 "Specify the TCP port number on which your server will run.\n"
173 "Normally, this will be port 504, which is the official port\n"
174 "assigned by the IANA for Citadel servers. You will only need\n"
175 "to specify a different port number if you run multiple instances\n"
176 "of Citadel on the same computer and there is something else\n"
177 "already using port 504.\n");
179 setup_titles[eAuthType] = _("Authentication method to use:");
180 setup_text[eAuthType] = _(
181 "Please choose the user authentication mode. By default Citadel will use its "
182 "own internal user accounts database. If you choose Host, Citadel users will "
183 "have accounts on the host system, authenticated via /etc/passwd or a PAM "
184 "source. LDAP chooses an RFC 2307 compliant directory server, the last option "
185 "chooses the nonstandard MS Active Directory LDAP scheme."
187 "Do not change this option unless you are sure it is required, since changing "
188 "back requires a full reinstall of Citadel."
190 " 0. Self contained authentication\n"
191 " 1. Host system integrated authentication\n"
192 " 2. External LDAP - RFC 2307 POSIX schema\n"
193 " 3. External LDAP - MS Active Directory schema\n"
195 "For help: http://www.citadel.org/doku.php/faq:installation:authmodes\n"
197 "ANSWER \"0\" UNLESS YOU COMPLETELY UNDERSTAND THIS OPTION.\n");
199 setup_titles[eLDAP_Host] = _("LDAP host:");
200 setup_text[eLDAP_Host] = _(
201 "Please enter the host name or IP address of your LDAP server.\n");
203 setup_titles[eLDAP_Port] = _("LDAP port number:");
204 setup_text[eLDAP_Port] = _(
205 "Please enter the port number of the LDAP service (usually 389).\n");
207 setup_titles[eLDAP_Base_DN] = _("LDAP base DN:");
208 setup_text[eLDAP_Base_DN] = _(
209 "Please enter the Base DN to search for authentication\n"
210 "(for example: dc=example,dc=com)\n");
212 setup_titles[eLDAP_Bind_DN] = _("LDAP bind DN:");
213 setup_text[eLDAP_Bind_DN] = _(
214 "Please enter the DN of an account to use for binding to the LDAP server for "
215 "performing queries. The account does not require any other privileges. If "
216 "your LDAP server allows anonymous queries, you can leave this blank.\n");
218 setup_titles[eLDAP_Bind_PW] = _("LDAP bind password:");
219 setup_text[eLDAP_Bind_PW] = _(
220 "If you entered a Bind DN in the previous question, you must now enter\n"
221 "the password associated with that account. Otherwise, you can leave this\n"
225 // Debug loading of locales... Strace does a better job though.
226 printf("Message catalog directory: %s\n", bindtextdomain("citadel-setup", LOCALEDIR"/locale"));
227 printf("Text domain: %s\n", textdomain("citadel-setup"));
228 printf("Text domain Charset: %s\n", bind_textdomain_codeset("citadel-setup","UTF8"));
231 for (i = 0; i < eMaxQuestions; i++)
232 printf("%s - %s\n", setup_titles[i], _(setup_titles[i]));
240 void title(const char *text)
242 if (setup_type == UI_TEXT) {
243 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<%s>\n", text);
249 int yesno(const char *question, int default_value)
255 switch (setup_type) {
259 printf("%s\n%s [%s] --> ",
262 ( default_value ? _("Yes") : _("No") )
264 if (fgets(buf, sizeof buf, stdin))
266 answer = tolower(buf[0]);
267 if ((buf[0]==0) || (buf[0]==13) || (buf[0]==10)) {
268 answer = default_value;
270 else if (answer == 'y') {
273 else if (answer == 'n') {
277 } while ((answer < 0) || (answer > 1));
281 snprintf(buf, sizeof buf, "exec %s --backtitle '%s' %s --yesno '%s' 15 75",
282 getenv("CTDL_DIALOG"),
284 ( default_value ? "" : "--defaultno" ),
301 void important_message(const char *title, const char *msgtext)
305 switch (setup_type) {
308 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
309 printf(" %s \n\n%s\n\n", title, msgtext);
310 printf("%s", _("Press return to continue..."));
311 if (fgets(buf, sizeof buf, stdin))
316 snprintf(buf, sizeof buf, "exec %s --backtitle '%s' --msgbox '%s' 19 72",
317 getenv("CTDL_DIALOG"),
320 int rv = system(buf);
322 fprintf(stderr, _("failed to run the dialog command\n"));
326 fprintf(stderr, "%s\n", msgtext);
331 void important_msgnum(int msgnum)
333 important_message(_("Important Message"), setup_text[msgnum]);
336 void display_error(char *error_message_format, ...)
342 va_start(arg_ptr, error_message_format);
343 StrBufVAppendPrintf(Msg, error_message_format, arg_ptr);
346 important_message(_("Error"), ChrPtr(Msg));
350 void progress(char *text, long int curr, long int cmax)
352 static long dots_printed = 0L;
354 static FILE *fp = NULL;
357 switch (setup_type) {
361 printf("%s\n", text);
362 printf("....................................................");
363 printf("..........................\r");
365 } else if (curr == cmax) {
366 printf("\r%79s\n", "");
368 a = (curr * 100) / cmax;
371 while (dots_printed < a) {
381 snprintf(buf, sizeof buf, "exec %s --backtitle '%s' --gauge '%s' 7 72 0",
382 getenv("CTDL_DIALOG"),
385 fp = popen(buf, "w");
391 else if (curr == cmax) {
393 fprintf(fp, "100\n");
399 a = (curr * 100) / cmax;
401 fprintf(fp, "%ld\n", a);
410 assert(1==0); /* If we got here then the developer is a moron */
415 int uds_connectsock(char *sockpath)
418 struct sockaddr_un addr;
420 memset(&addr, 0, sizeof(addr));
421 addr.sun_family = AF_UNIX;
422 strncpy(addr.sun_path, sockpath, sizeof addr.sun_path);
424 s = socket(AF_UNIX, SOCK_STREAM, 0);
429 if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
439 * input binary data from socket
441 void serv_read(char *buf, int bytes)
446 while (len < bytes) {
447 rlen = read(serv_sock, &buf[len], bytes - len);
457 * send binary to server
459 void serv_write(char *buf, int nbytes)
461 int bytes_written = 0;
463 while (bytes_written < nbytes) {
464 retval = write(serv_sock, &buf[bytes_written], nbytes - bytes_written);
468 bytes_written = bytes_written + retval;
475 * input string from socket - implemented in terms of serv_read()
477 void serv_gets(char *buf)
481 /* Read one character at a time.
484 serv_read(&buf[i], 1);
485 if (buf[i] == '\n' || i == (SIZ-1))
489 /* If we got a long line, discard characters until the newline.
492 while (buf[i] != '\n') {
493 serv_read(&buf[i], 1);
497 /* Strip all trailing nonprintables (crlf)
504 * send line to server - implemented in terms of serv_write()
506 void serv_puts(char *buf)
508 serv_write(buf, strlen(buf));
514 * Convenience functions to get/set system configuration entries
516 void getconf_str(char *buf, char *key)
521 sprintf(cmd, "CONF GETVAL|%s", key);
525 extract_token(buf, &ret[4], 0, '|', SIZ);
532 int getconf_int(char *key)
535 getconf_str(buf, key);
539 void setconf_str(char *key, char *val)
543 sprintf(buf, "CONF PUTVAL|%s|%s", key, val);
549 void setconf_int(char *key, int val)
553 sprintf(buf, "CONF PUTVAL|%s|%d", key, val);
563 * On systems which use xinetd, see if we can offer to install Citadel as
564 * the default telnet target.
566 void check_xinetd_entry(void)
568 char *filename = "/etc/xinetd.d/telnet";
571 int already_citadel = 0;
574 fp = fopen(filename, "r+");
575 if (fp == NULL) return; /* Not there. Oh well... */
577 while (fgets(buf, sizeof buf, fp) != NULL) {
578 if (strstr(buf, "/citadel") != NULL) {
583 if (already_citadel) return; /* Already set up this way. */
585 /* Otherwise, prompt the user to create an entry. */
586 if (getenv("CREATE_XINETD_ENTRY") != NULL) {
587 if (strcasecmp(getenv("CREATE_XINETD_ENTRY"), "yes")) {
592 snprintf(buf, sizeof buf,
593 _("Setup can configure the \"xinetd\" service to automatically\n"
594 "connect incoming telnet sessions to Citadel, bypassing the\n"
595 "host system login: prompt. Would you like to do this?\n"
598 if (yesno(buf, 1) == 0) {
603 fp = fopen(filename, "w");
605 "# description: telnet service for Citadel users\n"
610 " socket_type = stream\n"
613 " server = /usr/sbin/in.telnetd\n"
614 " server_args = -h -L %s/citadel\n"
615 " log_on_failure += USERID\n"
621 /* Now try to restart the service. This will not have the intended effect on Solaris, but who the hell uses Solaris anymore? */
622 rv = system("systemctl restart xinetd >/dev/null 2>&1");
624 rv = system("service xinetd restart >/dev/null 2>&1");
627 display_error(_("failed to restart xinetd.\n"));
632 void disable_other_mtas(void)
634 if ((getenv("ACT_AS_MTA") == NULL) || (getenv("ACT_AS_MTA") && strcasecmp(getenv("ACT_AS_MTA"), "yes") == 0)) {
635 /* Offer to disable other MTA's on the system. */
636 /* FIXME this has to be rewritten to work in the new systemd-based world. */
641 void strprompt(const char *prompt_title, const char *prompt_text, char *Target, char *DefValue)
645 char dialog_result[PATH_MAX];
649 strcpy(setupmsg, "");
651 switch (setup_type) {
654 printf("\n%s\n", prompt_text);
655 printf("%s\n%s\n", _("This is currently set to:"), Target);
656 printf("%s\n", _("Enter new value or press return to leave unchanged:"));
657 if (fgets(buf, sizeof buf, stdin)) {
658 buf[strlen(buf) - 1] = 0;
660 if (!IsEmptyStr(buf))
665 CtdlMakeTempFileName(dialog_result, sizeof dialog_result);
666 snprintf(buf, sizeof buf, "exec %s --backtitle '%s' --nocancel --inputbox '%s' 19 72 '%s' 2>%s",
667 getenv("CTDL_DIALOG"),
674 fprintf(stderr, "failed to run whiptail or dialog\n");
677 fp = fopen(dialog_result, "r");
679 if (fgets(Target, sizeof buf, fp)) {
680 if (Target[strlen(Target)-1] == 10) {
681 Target[strlen(Target)-1] = 0;
685 unlink(dialog_result);
689 if (*DefValue != '\0')
690 strcpy(Target, DefValue);
695 void set_bool_val(int msgpos, int *ip, char *DefValue)
697 title(setup_titles[msgpos]);
698 *ip = yesno(setup_text[msgpos], *ip);
701 void set_str_val(int msgpos, char *Target, char *DefValue)
703 strprompt(setup_titles[msgpos],
710 /* like set_str_val() but for numeric values */
711 void set_int_val(int msgpos, int *target, char *default_value)
714 sprintf(buf, "%d", *target);
716 set_str_val(msgpos, buf, default_value);
717 } while ( (strcmp(buf, "0")) && (atoi(buf) == 0) );
722 void edit_value(int curr)
724 struct passwd *pw = NULL;
725 char ctdluidname[256];
727 char *default_value = NULL;
733 if (setup_type == UI_SILENT)
735 default_value = getenv(EnvNames[curr]);
737 if (default_value == NULL) {
744 getconf_str(admin_name, "c_sysadm");
745 set_str_val(curr, admin_name, default_value);
746 setconf_str("c_sysadm", admin_name);
750 set_str_val(curr, admin_pass, default_value);
754 ctdluid = getconf_int("c_ctdluid");
755 if (setup_type == UI_SILENT)
758 ctdluid = atoi(default_value);
764 ctdluid = 0; /* work-around for Windows */
766 pw = getpwuid(ctdluid);
768 set_int_val(curr, &ctdluid, default_value);
771 strcpy(ctdluidname, pw->pw_name);
772 set_str_val(curr, ctdluidname, default_value);
773 pw = getpwnam(ctdluidname);
775 ctdluid = pw->pw_uid;
777 else if (atoi(ctdluidname) > 0) {
778 ctdluid = atoi(ctdluidname);
783 setconf_int("c_ctdluid", ctdluid);
787 getconf_str(buf, "c_ip_addr");
788 set_str_val(curr, buf, default_value);
789 setconf_str("c_ip_addr", buf);
793 portnum = getconf_int("c_port_number");
794 set_int_val(curr, &portnum, default_value);
795 setconf_int("c_port_number", portnum);
799 auth = getconf_int("c_auth_mode");
800 if (setup_type == UI_SILENT)
802 if ( (default_value) && (!strcasecmp(default_value, "yes")) ) auth = AUTHMODE_HOST;
803 if ( (default_value) && (!strcasecmp(default_value, "host")) ) auth = AUTHMODE_HOST;
804 if ( (default_value) && (!strcasecmp(default_value, "ldap")) ) auth = AUTHMODE_LDAP;
805 if ( (default_value) && (!strcasecmp(default_value, "ldap_ad")) ) auth = AUTHMODE_LDAP_AD;
806 if ( (default_value) && (!strcasecmp(default_value, "active directory")) ) auth = AUTHMODE_LDAP_AD;
809 set_int_val(curr, &auth, default_value);
811 setconf_int("c_auth_mode", auth);
815 getconf_str(buf, "c_ldap_host");
816 if (IsEmptyStr(buf)) {
817 strcpy(buf, "localhost");
819 set_str_val(curr, buf, default_value);
820 setconf_str("c_ldap_host", buf);
824 lportnum = getconf_int("c_ldap_port");
828 set_int_val(curr, &lportnum, default_value);
829 setconf_int("c_ldap_port", lportnum);
833 getconf_str(buf, "c_ldap_base_dn");
834 set_str_val(curr, buf, default_value);
835 setconf_str("c_ldap_base_dn", buf);
839 getconf_str(buf, "c_ldap_bind_dn");
840 set_str_val(curr, buf, default_value);
841 setconf_str("c_ldap_bind_dn", buf);
845 getconf_str(buf, "c_ldap_bind_pw");
846 set_str_val(curr, buf, default_value);
847 setconf_str("c_ldap_bind_pw", buf);
855 * Figure out what type of user interface we're going to use
857 int discover_ui(void)
860 /* Use "whiptail" or "dialog" if we have it */
861 if (getenv("CTDL_DIALOG") != NULL) {
871 * Strip "db" entries out of /etc/nsswitch.conf
880 int file_changed = 0;
881 char new_filename[64];
884 fp_read = fopen(NSSCONF, "r");
885 if (fp_read == NULL) {
889 strcpy(new_filename, "/tmp/ctdl_fixnss_XXXXXX");
890 fd_write = mkstemp(new_filename);
896 while (fgets(buf, sizeof buf, fp_read) != NULL) {
898 for (i=0; buf_nc[i]; ++i) {
899 if (buf_nc[i] == '#') {
904 for (i=0; i<strlen(buf_nc); ++i) {
905 if (!strncasecmp(&buf_nc[i], "db", 2)) {
907 if ((isspace(buf_nc[i+2])) || (buf_nc[i+2]==0)) {
909 strcpy(&buf_nc[i], &buf_nc[i+2]);
910 strcpy(&buf[i], &buf[i+2]);
912 strcpy(&buf_nc[i], &buf_nc[i+1]);
913 strcpy(&buf[i], &buf[i+1]);
919 long buflen = strlen(buf);
920 if (write(fd_write, buf, buflen) != buflen) {
923 unlink(new_filename);
931 unlink(new_filename);
935 snprintf(question, sizeof question,
938 "/etc/nsswitch.conf is configured to use the 'db' module for\n"
939 "one or more services. This is not necessary on most systems,\n"
940 "and it is known to crash the Citadel server when delivering\n"
941 "mail to the Internet.\n"
943 "Do you want this module to be automatically disabled?\n"
948 if (yesno(question, 1)) {
949 snprintf(buf, sizeof buf, "/bin/mv -f %s %s", new_filename, NSSCONF);
952 fprintf(stderr, "failed to edit %s.\n", NSSCONF);
954 chmod(NSSCONF, 0644);
956 unlink(new_filename);
961 * Messages that are no longer in use.
962 * We keep them here so we don't lose the translations if we need them later.
965 important_message(_("Setup finished"),
966 _("Setup of the Citadel server is complete.\n"
967 "If you will be using WebCit, please run its\n"
968 "setup program now; otherwise, run './citadel'\n"
970 important_message(_("Setup failed"),
971 _("Setup is finished, but the Citadel server failed to start.\n"
972 "Go back and check your configuration.\n")
973 important_message(_("Setup finished"),
974 _("Setup is finished. You may now start the server."));
980 int main(int argc, char *argv[])
988 char relhome[PATH_MAX]="";
989 char ctdldir[PATH_MAX]=CTDLDIR;
992 char *activity = NULL;
994 /* Keep a mild groove on */
995 program_title = _("Citadel setup program");
997 /* set an invalid setup type */
1000 /* parse command line args */
1001 for (a = 0; a < argc; ++a) {
1002 if (!strncmp(argv[a], "-u", 2)) {
1003 strcpy(aaa, argv[a]);
1004 strcpy(aaa, &aaa[2]);
1005 setup_type = atoi(aaa);
1007 else if (!strcmp(argv[a], "-q")) {
1008 setup_type = UI_SILENT;
1010 else if (!strncmp(argv[a], "-h", 2)) {
1011 relh=argv[a][2]!='/';
1013 safestrncpy(ctdl_home_directory, &argv[a][2], sizeof ctdl_home_directory);
1015 safestrncpy(relhome, &argv[a][2], sizeof relhome);
1022 calc_dirs_n_files(relh, home, relhome, ctdldir, 0);
1025 /* If a setup type was not specified, try to determine automatically
1026 * the best one to use out of all available types.
1028 if (setup_type < 0) {
1029 setup_type = discover_ui();
1032 enable_home = ( relh | home );
1034 if (chdir(ctdl_run_dir) != 0) {
1035 display_error("%s: [%s]\n", _("The directory you specified does not exist"), ctdl_run_dir);
1041 * Connect to the running Citadel server.
1043 char *connectingmsg = _("Connecting to Citadel server");
1044 for (i=0; ((i<30) && (serv_sock < 0)) ; ++i) { /* wait for server to start up */
1045 progress(connectingmsg, i, 30);
1046 serv_sock = uds_connectsock(file_citadel_admin_socket);
1049 progress(connectingmsg, 30, 30);
1051 if (serv_sock < 0) {
1054 _("Setup could not connect to a running Citadel server."),
1055 strerror(errno), file_citadel_admin_socket
1061 * read the server greeting
1064 if (buf[0] != '2') {
1065 display_error("%s\n", buf);
1070 * Are we connected to the correct Citadel server?
1074 if (buf[0] != '1') {
1075 display_error("%s\n", buf);
1079 while (serv_gets(buf), strcmp(buf, "000")) {
1081 if (atoi(buf) != REV_LEVEL) {
1082 display_error("%s\n",
1083 _("Your setup program and Citadel server are from different versions.")
1096 if (setup_type == UI_TEXT) {
1097 printf("\n\n\n *** %s ***\n\n", program_title);
1100 if (setup_type == UI_DIALOG) {
1101 system("clear 2>/dev/null");
1104 /* Go through a series of dialogs prompting for config info */
1105 for (curr = 1; curr < eMaxQuestions; ++curr) {
1108 if ( (curr == eAuthType)
1109 && (getconf_int("c_auth_mode") != AUTHMODE_LDAP)
1110 && (getconf_int("c_auth_mode") != AUTHMODE_LDAP_AD)
1112 curr += 5; /* skip LDAP questions if we're not authenticating against LDAP */
1115 if (curr == eSysAdminName) {
1116 if (getconf_int("c_auth_mode") == AUTHMODE_NATIVE) {
1117 /* for native auth mode, fetch the admin's existing pw */
1118 snprintf(buf, sizeof buf, "AGUP %s", admin_name);
1121 if (buf[0] == '2') {
1122 extract_token(admin_pass, &buf[4], 1, '|', sizeof admin_pass);
1126 ++curr; /* skip the password question for non-native auth modes */
1131 if ((pw = getpwuid( getconf_int("c_ctdluid") )) == NULL) {
1137 if (create_run_directories(getconf_int("c_ctdluid"), gid) != 0) {
1138 display_error("%s\n", _("failed to create directories"));
1141 activity = _("Reconfiguring Citadel server");
1142 progress(activity, 0, 5);
1143 sleep(1); /* Let the message appear briefly */
1146 * Create the administrator account. It's ok if the command fails if this user already exists.
1148 if (getconf_int("c_auth_mode") == AUTHMODE_NATIVE) {
1149 progress(activity, 1, 5);
1150 snprintf(buf, sizeof buf, "CREU %s|%s", admin_name, admin_pass);
1152 progress(activity, 2, 5);
1155 progress(activity, 3, 5);
1158 * Assign the desired password and access level to the administrator account.
1160 if (getconf_int("c_auth_mode") == AUTHMODE_NATIVE) {
1161 snprintf(buf, sizeof buf, "AGUP %s", admin_name);
1163 progress(activity, 4, 5);
1165 if (buf[0] == '2') {
1166 int admin_flags = extract_int(&buf[4], 2);
1167 int admin_times_called = extract_int(&buf[4], 3);
1168 int admin_msgs_posted = extract_int(&buf[4], 4);
1169 snprintf(buf, sizeof buf, "ASUP %s|%s|%d|%d|%d|6",
1170 admin_name, admin_pass, admin_flags, admin_times_called, admin_msgs_posted
1176 progress(activity, 5, 5);
1179 check_xinetd_entry(); /* Check /etc/xinetd.d/telnet */
1180 disable_other_mtas(); /* Offer to disable other MTAs */
1181 fixnss(); /* Check for the 'db' nss and offer to disable it */
1187 activity = _("Restarting Citadel server to apply changes");
1188 progress(activity, 0, 51);
1192 long original_start_time = extract_long(&buf[4], 3);
1194 progress(activity, 1, 51);
1195 serv_puts("DOWN 1");
1196 progress(activity, 2, 51);
1198 if (buf[0] != '2') {
1199 display_error("%s\n", buf);
1206 for (i=3; i<=6; ++i) { /* wait for server to shut down */
1207 progress(activity, i, 51);
1211 for (i=7; ((i<=48) && (serv_sock < 0)) ; ++i) { /* wait for server to start up */
1212 progress(activity, i, 51);
1213 serv_sock = uds_connectsock(file_citadel_admin_socket);
1217 progress(activity, 49, 51);
1220 progress(activity, 50, 51);
1223 long new_start_time = extract_long(&buf[4], 3);
1226 progress(activity, 51, 51);
1228 if ( (original_start_time == new_start_time)
1229 || (new_start_time <= 0)
1231 display_error("%s\n", _("Setup failed to restart Citadel server. Please restart it manually."));