X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Futils%2Fsetup.c;h=326564bcd3e5d516f93fc23ab7ee03b77ea7ea10;hb=5ba959c18fdff446e9f54b3062c74e94bbf58b47;hp=311f1b28f52fff4b592c96414f0f91a5b018fc61;hpb=09d85563ff6be31ab572d10fc230cc4f04e7138f;p=citadel.git diff --git a/citadel/utils/setup.c b/citadel/utils/setup.c index 311f1b28f..326564bcd 100644 --- a/citadel/utils/setup.c +++ b/citadel/utils/setup.c @@ -1,5 +1,15 @@ /* * Citadel setup utility + * + * Copyright (c) 1987-2012 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ #define SHOW_ME_VAPPEND_PRINTF @@ -95,10 +105,6 @@ char admin_cmd[SIZ]; const char *setup_titles[eMaxQuestions]; const char *setup_text[eMaxQuestions]; -/* calculate all our path on a central place */ -/* where to keep our config */ - - void SetTitles(void) { @@ -151,7 +157,7 @@ void SetTitles(void) setup_text[eUID] = _( "Citadel needs to run under its own user ID. This would\n" "typically be called \"citadel\", but if you are running Citadel\n" -"as a public BBS, you might also call it \"bbs\" or \"guest\".\n" +"as a public site, you might also call it \"bbs\" or \"guest\".\n" "The server will run under this user ID. Please specify that\n" "user ID here. You may specify either a user name or a numeric\n" "UID.\n"); @@ -239,7 +245,7 @@ void SetTitles(void) } /* - * print the actual stack frame. + * Print the stack frame for a backtrace */ void cit_backtrace(void) { @@ -261,7 +267,6 @@ void cit_backtrace(void) } struct config config; - int direction; @@ -372,9 +377,7 @@ void display_error(char *error_message_format, ...) Msg = NewStrBuf(); va_start(arg_ptr, error_message_format); - StrBufVAppendPrintf(Msg, - error_message_format, - arg_ptr); + StrBufVAppendPrintf(Msg, error_message_format, arg_ptr); va_end(arg_ptr); important_message(_("Error"), ChrPtr(Msg)); @@ -489,11 +492,7 @@ void delete_inittab_entry(void) int rv; /* Determine the fully qualified path name of citserver */ - snprintf(looking_for, - sizeof looking_for, - "%s/citserver", - ctdl_sbin_dir - ); + snprintf(looking_for, sizeof looking_for, "%s/citserver", ctdl_sbin_dir); /* Now tweak /etc/inittab */ infp = fopen("/etc/inittab", "r"); @@ -536,9 +535,7 @@ void delete_inittab_entry(void) rv = fwrite(buf, strlen(buf), 1, outfp); if (rv == -1) { - display_error("%s %s\n", - _("failed to modify inittab"), - strerror(errno)); + display_error("%s %s\n", _("failed to modify inittab"), strerror(errno)); } } @@ -567,14 +564,17 @@ void install_init_scripts(void) char command[SIZ]; int rv; - if ((stat("/etc/init.d/", &etcinitd) == -1) && - (errno == ENOENT)) - { - if ((stat("/etc/rc.d/init.d/", &etcinitd) == -1) && - (errno == ENOENT)) + if ( (stat("/etc/init.d/", &etcinitd) == -1) + && (errno == ENOENT) + ) { + if ( (stat("/etc/rc.d/init.d/", &etcinitd) == -1) + && (errno == ENOENT) + ) { initfile = CTDLDIR"/citadel.init"; - else + } + else { initfile = "/etc/rc.d/init.d/citadel"; + } } fp = fopen(initfile, "r"); @@ -655,18 +655,21 @@ void install_init_scripts(void) /* Set up the run levels. */ rv = system("/bin/rm -f /etc/rc?.d/[SK]??citadel 2>/dev/null"); - if (rv != 0) - display_error(_("failed to remove system V init links \n")); + if (rv != 0) { + display_error(_("failed to remove system V init links\n")); + } snprintf(command, sizeof(command), "for x in 2 3 4 5 ; do [ -d /etc/rc$x.d ] && ln -s %s /etc/rc$x.d/S79citadel ; done 2>/dev/null", initfile); rv = system(command); - if (rv != 0) - display_error(_("failed to set system V init links \n")); + if (rv != 0) { + display_error(_("failed to set system V init links\n")); + } snprintf(command, sizeof(command),"for x in 0 6 S; do [ -d /etc/rc$x.d ] && ln -s %s /etc/rc$x.d/K30citadel ; done 2>/dev/null", initfile); rv = system(command); - if (rv != 0) - display_error(_("failed to set system V init links \n")); + if (rv != 0) { + display_error(_("failed to set system V init links\n")); + } } @@ -702,7 +705,8 @@ void check_xinetd_entry(void) { _("Setup can configure the \"xinetd\" service to automatically\n" "connect incoming telnet sessions to Citadel, bypassing the\n" "host system login: prompt. Would you like to do this?\n" - )); + ) + ); if (yesno(buf, 1) == 0) { return; } @@ -844,17 +848,21 @@ int test_server(char *relhomestr, int relhome) { * to the server and try to get it back. The cookie does not * have to be secret ... just unique. */ - sprintf(cookie, "--test--%d--", getpid()); + generate_uuid(cookie); - if (relhome) + if (relhome) { sprintf(cmd, "%s/sendcommand -h%s ECHO %s 2>&1", ctdl_sbin_dir, relhomestr, - cookie); - else + cookie + ); + } + else { sprintf(cmd, "%s/sendcommand ECHO %s 2>&1", ctdl_sbin_dir, - cookie); + cookie + ); + } fp = popen(cmd, "r"); if (fp == NULL) return(errno); @@ -904,8 +912,9 @@ void strprompt(const char *prompt_title, const char *prompt_text, char *Target, Target, dialog_result); rv = system(buf); - if (rv != 0) - fprintf(stderr, "failed to run Dialog.\n"); + if (rv != 0) { + fprintf(stderr, "failed to run whiptail or dialog\n"); + } fp = fopen(dialog_result, "r"); if (fp != NULL) { @@ -936,7 +945,8 @@ void set_str_val(int msgpos, char *Target, char *DefValue) strprompt(setup_titles[msgpos], setup_text[msgpos], Target, - DefValue); + DefValue + ); } void set_int_val(int msgpos, int *ip, char *DefValue) @@ -977,9 +987,9 @@ void edit_value(int curr) { Value = getenv(EnvNames[curr]); } - if (Value == NULL) + if (Value == NULL) { Value = ""; - + } switch (curr) { @@ -1001,7 +1011,7 @@ void edit_value(int curr) else { #ifdef __CYGWIN__ - config.c_ctdluid = 0; /* XXX Windows hack, prob. insecure */ + config.c_ctdluid = 0; /* work-around for Windows */ #else i = config.c_ctdluid; pw = getpwuid(i); @@ -1121,7 +1131,7 @@ void write_config_to_disk(void) int discover_ui(void) { - /* Use "dialog" if we have it */ + /* Use "whiptail" or "dialog" if we have it */ if (getenv("CTDL_DIALOG") != NULL) { return UI_DIALOG; } @@ -1131,17 +1141,6 @@ int discover_ui(void) -void migrate_old_installs(void) -{ - int rv; - rv = system("exec /bin/rm -fr ./rooms ./chatpipes ./expressmsgs ./sessions 2>/dev/null"); - if (rv != 0) - fprintf(stderr, _("failed to remove old style directories.\n")); - unlink("citadel.log"); - unlink("weekly"); -} - - /* * Strip "db" entries out of /etc/nsswitch.conf */ @@ -1565,8 +1564,7 @@ int main(int argc, char *argv[]) } - get_config (); - + get_config(); set_default_values(); /* Go through a series of dialogs prompting for config info */ @@ -1611,8 +1609,6 @@ NEW_INST: write_config_to_disk(); - migrate_old_installs(); /* Delete files and directories used by older Citadel versions */ - if ( ((setup_type == UI_SILENT) && (getenv("ALTER_ETC_SERVICES")!=NULL)) || (setup_type != UI_SILENT) @@ -1637,5 +1633,3 @@ NEW_INST: cleanup(0); return 0; } - -