2 * Citadel setup utility
4 * Copyright (c) 1987-2017 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"
49 #define _(string) gettext(string)
51 #define _(string) (string)
54 #define UI_TEXT 0 /* Default setup type -- text only */
55 #define UI_DIALOG 2 /* Use the 'whiptail' or 'dialog' program */
56 #define UI_SILENT 3 /* Silent running, for use in scripts */
58 #define SERVICE_NAME "citadel"
59 #define PROTO_NAME "tcp"
60 #define NSSCONF "/etc/nsswitch.conf"
62 typedef enum _SetupStep {
78 ///"CREATE_XINETD_ENTRY";
79 /* Environment variables, don't translate! */
80 const char *EnvNames [eMaxQuestions] = {
95 int setup_type = (-1);
100 int serv_sock = (-1) ;
102 const char *setup_titles[eMaxQuestions];
103 const char *setup_text[eMaxQuestions];
117 setlocale(LC_MESSAGES, getenv("LANG"));
119 bindtextdomain("citadel-setup", LOCALEDIR"/locale");
120 textdomain("citadel-setup");
121 bind_textdomain_codeset("citadel-setup","UTF8");
124 setup_titles[eCitadelHomeDir] = _("Citadel Home Directory");
126 setup_text[eCitadelHomeDir] = _(
127 "Enter the full pathname of the directory in which the Citadel\n"
128 "installation you are creating or updating resides. If you\n"
129 "specify a directory other than the default, you will need to\n"
130 "specify the -h flag to the server when you start it up.\n");
132 setup_text[eCitadelHomeDir] = _(
133 "Enter the subdirectory name for an alternate installation of "
134 "Citadel. To do a default installation just leave it blank."
135 "If you specify a directory other than the default, you will need to\n"
136 "specify the -h flag to the server when you start it up.\n"
137 "note that it may not have a leading /");
140 setup_titles[eSysAdminName] = _("Citadel administrator username:");
141 setup_text[eSysAdminName] = _(
142 "Please enter the name of the Citadel user account that should be granted "
143 "administrative privileges once created. If using internal authentication "
144 "this user account will be created if it does not exist. For external "
145 "authentication this user account has to exist.");
148 setup_titles[eSysAdminPW] = _("Administrator password:");
149 setup_text[eSysAdminPW] = _(
150 "Enter a password for the system administrator. When setup\n"
151 "completes it will attempt to create the administrator user\n"
152 "and set the password specified here.\n");
154 setup_titles[eUID] = _("Citadel User ID:");
155 setup_text[eUID] = _(
156 "Citadel needs to run under its own user ID. This would\n"
157 "typically be called \"citadel\", but if you are running Citadel\n"
158 "as a public site, you might also call it \"bbs\" or \"guest\".\n"
159 "The server will run under this user ID. Please specify that\n"
160 "user ID here. You may specify either a user name or a numeric\n"
163 setup_titles[eIP_ADDR] = _("Listening address for the Citadel server:");
164 setup_text[eIP_ADDR] = _(
165 "Please specify the IP address which the server should be listening to. "
166 "You can name a specific IPv4 or IPv6 address, or you can specify\n"
167 "\"*\" for \"any address\", \"::\" for \"any IPv6 address\", or \"0.0.0.0\"\n"
168 "for \"any IPv4 address\". If you leave this blank, Citadel will\n"
169 "listen on all addresses. "
170 "This can usually be left to the default unless multiple instances of Citadel "
171 "are running on the same computer.");
173 setup_titles[eCTDL_Port] = _("Server port number:");
174 setup_text[eCTDL_Port] = _(
175 "Specify the TCP port number on which your server will run.\n"
176 "Normally, this will be port 504, which is the official port\n"
177 "assigned by the IANA for Citadel servers. You will only need\n"
178 "to specify a different port number if you run multiple instances\n"
179 "of Citadel on the same computer and there is something else\n"
180 "already using port 504.\n");
182 setup_titles[eAuthType] = _("Authentication method to use:");
183 setup_text[eAuthType] = _(
184 "Please choose the user authentication mode. By default Citadel will use its "
185 "own internal user accounts database. If you choose Host, Citadel users will "
186 "have accounts on the host system, authenticated via /etc/passwd or a PAM "
187 "source. LDAP chooses an RFC 2307 compliant directory server, the last option "
188 "chooses the nonstandard MS Active Directory LDAP scheme."
190 "Do not change this option unless you are sure it is required, since changing "
191 "back requires a full reinstall of Citadel."
193 " 0. Self contained authentication\n"
194 " 1. Host system integrated authentication\n"
195 " 2. External LDAP - RFC 2307 POSIX schema\n"
196 " 3. External LDAP - MS Active Directory schema\n"
198 "For help: http://www.citadel.org/doku.php/faq:installation:authmodes\n"
200 "ANSWER \"0\" UNLESS YOU COMPLETELY UNDERSTAND THIS OPTION.\n");
202 setup_titles[eLDAP_Host] = _("LDAP host:");
203 setup_text[eLDAP_Host] = _(
204 "Please enter the host name or IP address of your LDAP server.\n");
206 setup_titles[eLDAP_Port] = _("LDAP port number:");
207 setup_text[eLDAP_Port] = _(
208 "Please enter the port number of the LDAP service (usually 389).\n");
210 setup_titles[eLDAP_Base_DN] = _("LDAP base DN:");
211 setup_text[eLDAP_Base_DN] = _(
212 "Please enter the Base DN to search for authentication\n"
213 "(for example: dc=example,dc=com)\n");
215 setup_titles[eLDAP_Bind_DN] = _("LDAP bind DN:");
216 setup_text[eLDAP_Bind_DN] = _(
217 "Please enter the DN of an account to use for binding to the LDAP server for "
218 "performing queries. The account does not require any other privileges. If "
219 "your LDAP server allows anonymous queries, you can leave this blank.\n");
221 setup_titles[eLDAP_Bind_PW] = _("LDAP bind password:");
222 setup_text[eLDAP_Bind_PW] = _(
223 "If you entered a Bind DN in the previous question, you must now enter\n"
224 "the password associated with that account. Otherwise, you can leave this\n"
228 // Debug loading of locales... Strace does a better job though.
229 printf("Message catalog directory: %s\n", bindtextdomain("citadel-setup", LOCALEDIR"/locale"));
230 printf("Text domain: %s\n", textdomain("citadel-setup"));
231 printf("Text domain Charset: %s\n", bind_textdomain_codeset("citadel-setup","UTF8"));
234 for (i = 0; i < eMaxQuestions; i++)
235 printf("%s - %s\n", setup_titles[i], _(setup_titles[i]));
243 void title(const char *text)
245 if (setup_type == UI_TEXT) {
246 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<%s>\n", text);
252 int yesno(const char *question, int default_value)
258 switch (setup_type) {
262 printf("%s\n%s [%s] --> ",
265 ( default_value ? _("Yes") : _("No") )
267 if (fgets(buf, sizeof buf, stdin))
269 answer = tolower(buf[0]);
270 if ((buf[0]==0) || (buf[0]==13) || (buf[0]==10)) {
271 answer = default_value;
273 else if (answer == 'y') {
276 else if (answer == 'n') {
280 } while ((answer < 0) || (answer > 1));
284 snprintf(buf, sizeof buf, "exec %s --backtitle '%s' %s --yesno '%s' 15 75",
285 getenv("CTDL_DIALOG"),
287 ( default_value ? "" : "--defaultno" ),
304 void important_message(const char *title, const char *msgtext)
308 switch (setup_type) {
311 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");
312 printf(" %s \n\n%s\n\n", title, msgtext);
313 printf("%s", _("Press return to continue..."));
314 if (fgets(buf, sizeof buf, stdin))
319 snprintf(buf, sizeof buf, "exec %s --backtitle '%s' --msgbox '%s' 19 72",
320 getenv("CTDL_DIALOG"),
323 int rv = system(buf);
325 fprintf(stderr, _("failed to run the dialog command\n"));
329 fprintf(stderr, "%s\n", msgtext);
334 void important_msgnum(int msgnum)
336 important_message(_("Important Message"), setup_text[msgnum]);
339 void display_error(char *error_message_format, ...)
345 va_start(arg_ptr, error_message_format);
346 StrBufVAppendPrintf(Msg, error_message_format, arg_ptr);
349 important_message(_("Error"), ChrPtr(Msg));
353 void progress(char *text, long int curr, long int cmax)
355 static long dots_printed = 0L;
357 static FILE *fp = NULL;
360 switch (setup_type) {
364 printf("%s\n", text);
365 printf("....................................................");
366 printf("..........................\r");
368 } else if (curr == cmax) {
369 printf("\r%79s\n", "");
371 a = (curr * 100) / cmax;
374 while (dots_printed < a) {
384 snprintf(buf, sizeof buf, "exec %s --backtitle '%s' --gauge '%s' 7 72 0",
385 getenv("CTDL_DIALOG"),
388 fp = popen(buf, "w");
394 else if (curr == cmax) {
396 fprintf(fp, "100\n");
402 a = (curr * 100) / cmax;
404 fprintf(fp, "%ld\n", a);
413 assert(1==0); /* If we got here then the developer is a moron */
418 int uds_connectsock(char *sockpath)
421 struct sockaddr_un addr;
423 memset(&addr, 0, sizeof(addr));
424 addr.sun_family = AF_UNIX;
425 strncpy(addr.sun_path, sockpath, sizeof addr.sun_path);
427 s = socket(AF_UNIX, SOCK_STREAM, 0);
432 if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
442 * input binary data from socket
444 void serv_read(char *buf, int bytes)
449 while (len < bytes) {
450 rlen = read(serv_sock, &buf[len], bytes - len);
460 * send binary to server
462 void serv_write(char *buf, int nbytes)
464 int bytes_written = 0;
466 while (bytes_written < nbytes) {
467 retval = write(serv_sock, &buf[bytes_written], nbytes - bytes_written);
471 bytes_written = bytes_written + retval;
478 * input string from socket - implemented in terms of serv_read()
480 void serv_gets(char *buf)
484 /* Read one character at a time.
487 serv_read(&buf[i], 1);
488 if (buf[i] == '\n' || i == (SIZ-1))
492 /* If we got a long line, discard characters until the newline.
495 while (buf[i] != '\n') {
496 serv_read(&buf[i], 1);
500 /* Strip all trailing nonprintables (crlf)
507 * send line to server - implemented in terms of serv_write()
509 void serv_puts(char *buf)
511 serv_write(buf, strlen(buf));
517 * Convenience functions to get/set system configuration entries
519 void getconf_str(char *buf, char *key)
524 sprintf(cmd, "CONF GETVAL|%s", key);
528 extract_token(buf, &ret[4], 0, '|', SIZ);
535 int getconf_int(char *key)
538 getconf_str(buf, key);
542 void setconf_str(char *key, char *val)
546 sprintf(buf, "CONF PUTVAL|%s|%s", key, val);
552 void setconf_int(char *key, int val)
556 sprintf(buf, "CONF PUTVAL|%s|%d", key, val);
566 * On systems which use xinetd, see if we can offer to install Citadel as
567 * the default telnet target.
569 void check_xinetd_entry(void)
571 char *filename = "/etc/xinetd.d/telnet";
574 int already_citadel = 0;
577 fp = fopen(filename, "r+");
578 if (fp == NULL) return; /* Not there. Oh well... */
580 while (fgets(buf, sizeof buf, fp) != NULL) {
581 if (strstr(buf, "/citadel") != NULL) {
586 if (already_citadel) return; /* Already set up this way. */
588 /* Otherwise, prompt the user to create an entry. */
589 if (getenv("CREATE_XINETD_ENTRY") != NULL) {
590 if (strcasecmp(getenv("CREATE_XINETD_ENTRY"), "yes")) {
595 snprintf(buf, sizeof buf,
596 _("Setup can configure the \"xinetd\" service to automatically\n"
597 "connect incoming telnet sessions to Citadel, bypassing the\n"
598 "host system login: prompt. Would you like to do this?\n"
601 if (yesno(buf, 1) == 0) {
606 fp = fopen(filename, "w");
608 "# description: telnet service for Citadel users\n"
613 " socket_type = stream\n"
616 " server = /usr/sbin/in.telnetd\n"
617 " server_args = -h -L %s/citadel\n"
618 " log_on_failure += USERID\n"
624 /* Now try to restart the service. This will not have the intended effect on Solaris, but who the hell uses Solaris anymore? */
625 rv = system("systemctl restart xinetd >/dev/null 2>&1");
627 rv = system("service xinetd restart >/dev/null 2>&1");
630 display_error(_("failed to restart xinetd.\n"));
636 * Offer to disable other MTA's
638 void disable_other_mta(const char *mta) {
644 snprintf(buf, sizeof buf,
645 "/bin/ls -l /etc/rc*.d/S*%s 2>/dev/null; "
646 "/bin/ls -l /etc/rc.d/rc*.d/S*%s 2>/dev/null",
649 fp = popen(buf, "r");
650 if (fp == NULL) return;
652 while (fgets(buf, sizeof buf, fp) != NULL) {
656 if (lines == 0) return; /* Nothing to do. */
658 /* Offer to replace other MTA with the vastly superior Citadel :) */
660 snprintf(buf, sizeof buf,
661 "%s \"%s\" %s%s%s%s%s%s%s",
662 _("You appear to have the "),
665 "running on your system. If you want Citadel mail\n"
668 _(" you will have to manually integrate\n"
669 "them. It is preferable to disable "),
671 _(", and use Citadel's\n"
672 "SMTP, POP3, and IMAP services.\n\n"
675 _("so that Citadel has access to ports\n"
676 "25, 110, and 143?\n")
678 if (yesno(buf, 1) == 0) {
683 snprintf(buf, sizeof buf, "for x in /etc/rc*.d/S*%s; do mv $x `echo $x |sed s/S/K/g`; done >/dev/null 2>&1", mta);
686 display_error("%s %s.\n", _("failed to disable other mta"), mta);
688 snprintf(buf, sizeof buf, "/etc/init.d/%s stop >/dev/null 2>&1", mta);
691 display_error(" %s.\n", _("failed to disable other mta"), mta);
694 const char *other_mtas[] = {
695 "courier-authdaemon",
718 void disable_other_mtas(void)
721 if ((getenv("ACT_AS_MTA") == NULL) ||
722 (getenv("ACT_AS_MTA") &&
723 strcasecmp(getenv("ACT_AS_MTA"), "yes") == 0)) {
724 /* Offer to disable other MTA's on the system. */
725 while (!IsEmptyStr(other_mtas[i]))
727 disable_other_mta(other_mtas[i]);
733 void strprompt(const char *prompt_title, const char *prompt_text, char *Target, char *DefValue)
737 char dialog_result[PATH_MAX];
741 strcpy(setupmsg, "");
743 switch (setup_type) {
746 printf("\n%s\n", prompt_text);
747 printf("%s\n%s\n", _("This is currently set to:"), Target);
748 printf("%s\n", _("Enter new value or press return to leave unchanged:"));
749 if (fgets(buf, sizeof buf, stdin)) {
750 buf[strlen(buf) - 1] = 0;
752 if (!IsEmptyStr(buf))
757 CtdlMakeTempFileName(dialog_result, sizeof dialog_result);
758 snprintf(buf, sizeof buf, "exec %s --backtitle '%s' --nocancel --inputbox '%s' 19 72 '%s' 2>%s",
759 getenv("CTDL_DIALOG"),
766 fprintf(stderr, "failed to run whiptail or dialog\n");
769 fp = fopen(dialog_result, "r");
771 if (fgets(Target, sizeof buf, fp)) {
772 if (Target[strlen(Target)-1] == 10) {
773 Target[strlen(Target)-1] = 0;
777 unlink(dialog_result);
781 if (*DefValue != '\0')
782 strcpy(Target, DefValue);
787 void set_bool_val(int msgpos, int *ip, char *DefValue)
789 title(setup_titles[msgpos]);
790 *ip = yesno(setup_text[msgpos], *ip);
793 void set_str_val(int msgpos, char *Target, char *DefValue)
795 strprompt(setup_titles[msgpos],
802 /* like set_str_val() but for numeric values */
803 void set_int_val(int msgpos, int *target, char *default_value)
806 sprintf(buf, "%d", *target);
808 set_str_val(msgpos, buf, default_value);
809 } while ( (strcmp(buf, "0")) && (atoi(buf) == 0) );
814 void edit_value(int curr)
816 struct passwd *pw = NULL;
817 char ctdluidname[256];
819 char *default_value = NULL;
825 if (setup_type == UI_SILENT)
827 default_value = getenv(EnvNames[curr]);
829 if (default_value == NULL) {
836 getconf_str(admin_name, "c_sysadm");
837 set_str_val(curr, admin_name, default_value);
838 setconf_str("c_sysadm", admin_name);
842 set_str_val(curr, admin_pass, default_value);
846 ctdluid = getconf_int("c_ctdluid");
847 if (setup_type == UI_SILENT)
850 ctdluid = atoi(default_value);
856 ctdluid = 0; /* work-around for Windows */
858 pw = getpwuid(ctdluid);
860 set_int_val(curr, &ctdluid, default_value);
863 strcpy(ctdluidname, pw->pw_name);
864 set_str_val(curr, ctdluidname, default_value);
865 pw = getpwnam(ctdluidname);
867 ctdluid = pw->pw_uid;
869 else if (atoi(ctdluidname) > 0) {
870 ctdluid = atoi(ctdluidname);
875 setconf_int("c_ctdluid", ctdluid);
879 getconf_str(buf, "c_ip_addr");
880 set_str_val(curr, buf, default_value);
881 setconf_str("c_ip_addr", buf);
885 portnum = getconf_int("c_port_number");
886 set_int_val(curr, &portnum, default_value);
887 setconf_int("c_port_number", portnum);
891 auth = getconf_int("c_auth_mode");
892 if (setup_type == UI_SILENT)
894 if ( (default_value) && (!strcasecmp(default_value, "yes")) ) auth = AUTHMODE_HOST;
895 if ( (default_value) && (!strcasecmp(default_value, "host")) ) auth = AUTHMODE_HOST;
896 if ( (default_value) && (!strcasecmp(default_value, "ldap")) ) auth = AUTHMODE_LDAP;
897 if ( (default_value) && (!strcasecmp(default_value, "ldap_ad")) ) auth = AUTHMODE_LDAP_AD;
898 if ( (default_value) && (!strcasecmp(default_value, "active directory")) ) auth = AUTHMODE_LDAP_AD;
901 set_int_val(curr, &auth, default_value);
903 setconf_int("c_auth_mode", auth);
907 getconf_str(buf, "c_ldap_host");
908 if (IsEmptyStr(buf)) {
909 strcpy(buf, "localhost");
911 set_str_val(curr, buf, default_value);
912 setconf_str("c_ldap_host", buf);
916 lportnum = getconf_int("c_ldap_port");
920 set_int_val(curr, &lportnum, default_value);
921 setconf_int("c_ldap_port", lportnum);
925 getconf_str(buf, "c_ldap_base_dn");
926 set_str_val(curr, buf, default_value);
927 setconf_str("c_ldap_base_dn", buf);
931 getconf_str(buf, "c_ldap_bind_dn");
932 set_str_val(curr, buf, default_value);
933 setconf_str("c_ldap_bind_dn", buf);
937 getconf_str(buf, "c_ldap_bind_pw");
938 set_str_val(curr, buf, default_value);
939 setconf_str("c_ldap_bind_pw", buf);
947 * Figure out what type of user interface we're going to use
949 int discover_ui(void)
952 /* Use "whiptail" or "dialog" if we have it */
953 if (getenv("CTDL_DIALOG") != NULL) {
963 * Strip "db" entries out of /etc/nsswitch.conf
972 int file_changed = 0;
973 char new_filename[64];
976 fp_read = fopen(NSSCONF, "r");
977 if (fp_read == NULL) {
981 strcpy(new_filename, "/tmp/ctdl_fixnss_XXXXXX");
982 fd_write = mkstemp(new_filename);
988 while (fgets(buf, sizeof buf, fp_read) != NULL) {
990 for (i=0; buf_nc[i]; ++i) {
991 if (buf_nc[i] == '#') {
996 for (i=0; i<strlen(buf_nc); ++i) {
997 if (!strncasecmp(&buf_nc[i], "db", 2)) {
999 if ((isspace(buf_nc[i+2])) || (buf_nc[i+2]==0)) {
1001 strcpy(&buf_nc[i], &buf_nc[i+2]);
1002 strcpy(&buf[i], &buf[i+2]);
1004 strcpy(&buf_nc[i], &buf_nc[i+1]);
1005 strcpy(&buf[i], &buf[i+1]);
1011 long buflen = strlen(buf);
1012 if (write(fd_write, buf, buflen) != buflen) {
1015 unlink(new_filename);
1022 if (!file_changed) {
1023 unlink(new_filename);
1027 snprintf(question, sizeof question,
1030 "/etc/nsswitch.conf is configured to use the 'db' module for\n"
1031 "one or more services. This is not necessary on most systems,\n"
1032 "and it is known to crash the Citadel server when delivering\n"
1033 "mail to the Internet.\n"
1035 "Do you want this module to be automatically disabled?\n"
1040 if (yesno(question, 1)) {
1041 snprintf(buf, sizeof buf, "/bin/mv -f %s %s", new_filename, NSSCONF);
1044 fprintf(stderr, "failed to edit %s.\n", NSSCONF);
1046 chmod(NSSCONF, 0644);
1048 unlink(new_filename);
1053 * Messages that are no longer in use.
1054 * We keep them here so we don't lose the translations if we need them later.
1057 important_message(_("Setup finished"),
1058 _("Setup of the Citadel server is complete.\n"
1059 "If you will be using WebCit, please run its\n"
1060 "setup program now; otherwise, run './citadel'\n"
1062 important_message(_("Setup failed"),
1063 _("Setup is finished, but the Citadel server failed to start.\n"
1064 "Go back and check your configuration.\n")
1065 important_message(_("Setup finished"),
1066 _("Setup is finished. You may now start the server."));
1072 int main(int argc, char *argv[])
1080 char relhome[PATH_MAX]="";
1081 char ctdldir[PATH_MAX]=CTDLDIR;
1084 char *activity = NULL;
1086 /* Keep a mild groove on */
1087 program_title = _("Citadel setup program");
1089 /* set an invalid setup type */
1092 /* parse command line args */
1093 for (a = 0; a < argc; ++a) {
1094 if (!strncmp(argv[a], "-u", 2)) {
1095 strcpy(aaa, argv[a]);
1096 strcpy(aaa, &aaa[2]);
1097 setup_type = atoi(aaa);
1099 else if (!strcmp(argv[a], "-q")) {
1100 setup_type = UI_SILENT;
1102 else if (!strncmp(argv[a], "-h", 2)) {
1103 relh=argv[a][2]!='/';
1105 safestrncpy(ctdl_home_directory, &argv[a][2], sizeof ctdl_home_directory);
1107 safestrncpy(relhome, &argv[a][2], sizeof relhome);
1114 calc_dirs_n_files(relh, home, relhome, ctdldir, 0);
1117 /* If a setup type was not specified, try to determine automatically
1118 * the best one to use out of all available types.
1120 if (setup_type < 0) {
1121 setup_type = discover_ui();
1124 enable_home = ( relh | home );
1126 if (chdir(ctdl_run_dir) != 0) {
1127 display_error("%s: [%s]\n", _("The directory you specified does not exist"), ctdl_run_dir);
1133 * Connect to the running Citadel server.
1135 char *connectingmsg = _("Connecting to Citadel server");
1136 for (i=0; ((i<30) && (serv_sock < 0)) ; ++i) { /* wait for server to start up */
1137 progress(connectingmsg, i, 30);
1138 serv_sock = uds_connectsock(file_citadel_admin_socket);
1141 progress(connectingmsg, 30, 30);
1143 if (serv_sock < 0) {
1146 _("Setup could not connect to a running Citadel server."),
1147 strerror(errno), file_citadel_admin_socket
1153 * read the server greeting
1156 if (buf[0] != '2') {
1157 display_error("%s\n", buf);
1162 * Are we connected to the correct Citadel server?
1166 if (buf[0] != '1') {
1167 display_error("%s\n", buf);
1171 while (serv_gets(buf), strcmp(buf, "000")) {
1173 if (atoi(buf) != REV_LEVEL) {
1174 display_error("%s\n",
1175 _("Your setup program and Citadel server are from different versions.")
1188 if (setup_type == UI_TEXT) {
1189 printf("\n\n\n *** %s ***\n\n", program_title);
1192 if (setup_type == UI_DIALOG) {
1193 system("clear 2>/dev/null");
1196 /* Go through a series of dialogs prompting for config info */
1197 for (curr = 1; curr < eMaxQuestions; ++curr) {
1200 if ( (curr == eAuthType)
1201 && (getconf_int("c_auth_mode") != AUTHMODE_LDAP)
1202 && (getconf_int("c_auth_mode") != AUTHMODE_LDAP_AD)
1204 curr += 5; /* skip LDAP questions if we're not authenticating against LDAP */
1207 if (curr == eSysAdminName) {
1208 if (getconf_int("c_auth_mode") == AUTHMODE_NATIVE) {
1209 /* for native auth mode, fetch the admin's existing pw */
1210 snprintf(buf, sizeof buf, "AGUP %s", admin_name);
1213 if (buf[0] == '2') {
1214 extract_token(admin_pass, &buf[4], 1, '|', sizeof admin_pass);
1218 ++curr; /* skip the password question for non-native auth modes */
1223 if ((pw = getpwuid( getconf_int("c_ctdluid") )) == NULL) {
1229 if (create_run_directories(getconf_int("c_ctdluid"), gid) != 0) {
1230 display_error("%s\n", _("failed to create directories"));
1233 activity = _("Reconfiguring Citadel server");
1234 progress(activity, 0, 5);
1235 sleep(1); /* Let the message appear briefly */
1238 * Create the administrator account. It's ok if the command fails if this user already exists.
1240 if (getconf_int("c_auth_mode") == AUTHMODE_NATIVE) {
1241 progress(activity, 1, 5);
1242 snprintf(buf, sizeof buf, "CREU %s|%s", admin_name, admin_pass);
1244 progress(activity, 2, 5);
1247 progress(activity, 3, 5);
1250 * Assign the desired password and access level to the administrator account.
1252 if (getconf_int("c_auth_mode") == AUTHMODE_NATIVE) {
1253 snprintf(buf, sizeof buf, "AGUP %s", admin_name);
1255 progress(activity, 4, 5);
1257 if (buf[0] == '2') {
1258 int admin_flags = extract_int(&buf[4], 2);
1259 int admin_times_called = extract_int(&buf[4], 3);
1260 int admin_msgs_posted = extract_int(&buf[4], 4);
1261 snprintf(buf, sizeof buf, "ASUP %s|%s|%d|%d|%d|6",
1262 admin_name, admin_pass, admin_flags, admin_times_called, admin_msgs_posted
1268 progress(activity, 5, 5);
1271 check_xinetd_entry(); /* Check /etc/xinetd.d/telnet */
1272 disable_other_mtas(); /* Offer to disable other MTAs */
1273 fixnss(); /* Check for the 'db' nss and offer to disable it */
1279 activity = _("Restarting Citadel server to apply changes");
1280 progress(activity, 0, 51);
1284 long original_start_time = extract_long(&buf[4], 3);
1286 progress(activity, 1, 51);
1287 serv_puts("DOWN 1");
1288 progress(activity, 2, 51);
1290 if (buf[0] != '2') {
1291 display_error("%s\n", buf);
1298 for (i=3; i<=6; ++i) { /* wait for server to shut down */
1299 progress(activity, i, 51);
1303 for (i=7; ((i<=48) && (serv_sock < 0)) ; ++i) { /* wait for server to start up */
1304 progress(activity, i, 51);
1305 serv_sock = uds_connectsock(file_citadel_admin_socket);
1309 progress(activity, 49, 51);
1312 progress(activity, 50, 51);
1315 long new_start_time = extract_long(&buf[4], 3);
1318 progress(activity, 51, 51);
1320 if ( (original_start_time == new_start_time)
1321 || (new_start_time <= 0)
1323 display_error("%s\n", _("Setup failed to restart Citadel server. Please restart it manually."));