X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Futils%2Fsetup.c;h=86e9c1f1694974fa095939f888e68f8df12de562;hb=8740af873293443aa1b83159038ac7d1ded42ca8;hp=6a5dc6e7833d7dd8157b979ce629d858b82983ec;hpb=f3e4fc06ac73431ebad31f00a4cbba627742a809;p=citadel.git diff --git a/citadel/utils/setup.c b/citadel/utils/setup.c index 6a5dc6e78..86e9c1f16 100644 --- a/citadel/utils/setup.c +++ b/citadel/utils/setup.c @@ -102,7 +102,6 @@ const char *setup_text[eMaxQuestions]; void SetTitles(void) { - char *locale; int have_run_dir; #ifndef HAVE_RUN_DIR have_run_dir = 1; @@ -110,11 +109,13 @@ void SetTitles(void) have_run_dir = 0; #endif - locale = setlocale(LC_MESSAGES, getenv("LANG")); +#ifdef ENABLE_NLS + setlocale(LC_MESSAGES, getenv("LANG")); bindtextdomain("citadel-setup", LOCALEDIR"/locale"); textdomain("citadel-setup"); bind_textdomain_codeset("citadel-setup","UTF8"); +#endif setup_titles[eCitadelHomeDir] = _("Citadel Home Directory"); if (have_run_dir) @@ -261,8 +262,6 @@ void cit_backtrace(void) struct config config; - -struct config config; int direction; @@ -352,6 +351,8 @@ void important_message(const char *title, const char *msgtext) getenv("CTDL_DIALOG"), msgtext); rv = system(buf); + if (rv != 0) + fprintf(stderr, _("failed to run the dialog command\n")); break; case UI_SILENT: fprintf(stderr, "%s\n", msgtext); @@ -524,9 +525,21 @@ void delete_inittab_entry(void) while (fgets(buf, sizeof buf, infp) != NULL) { if (strstr(buf, looking_for) != NULL) { rv = fwrite("#", 1, 1, outfp); + if (rv == -1) + { + display_error("%s %s\n", + _("failed to modify inittab"), + strerror(errno)); + } ++changes_made; } rv = fwrite(buf, strlen(buf), 1, outfp); + if (rv == -1) + { + display_error("%s %s\n", + _("failed to modify inittab"), + strerror(errno)); + } } fclose(infp); @@ -642,11 +655,18 @@ 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")); + 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")); + 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")); } @@ -707,6 +727,8 @@ void check_xinetd_entry(void) { /* Now try to restart the service */ rv = system("/etc/init.d/xinetd restart >/dev/null 2>&1"); + if (rv != 0) + display_error(_("failed to restart xinetd.\n")); } @@ -760,8 +782,13 @@ void disable_other_mta(const char *mta) { sprintf(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); rv = system(buf); + if (rv != 0) + display_error("%s %s.\n", _("failed to disable other mta"), mta); + sprintf(buf, "/etc/init.d/%s stop >/dev/null 2>&1", mta); rv = system(buf); + if (rv != 0) + display_error(" %s.\n", _("failed to disable other mta"), mta); } const char *other_mtas[] = { @@ -877,6 +904,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"); + fp = fopen(dialog_result, "r"); if (fp != NULL) { if (fgets(Target, sizeof buf, fp)) { @@ -1071,8 +1101,13 @@ void write_config_to_disk(void) if (fp == NULL) { display_error("%s citadel.config [%s][%s]\n", _("setup: cannot open"), file_citadel_config, strerror(errno)); cleanup(1); + return; } rv = fwrite((char *) &config, sizeof(struct config), 1, fp); + + if (rv == -1) + display_error("%s citadel.config [%s][%s]\n", _("setup: cannot write"), file_citadel_config, strerror(errno)); + fclose(fp); } @@ -1099,6 +1134,8 @@ 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"); } @@ -1114,7 +1151,6 @@ void fixnss(void) { char buf_nc[256]; char question[512]; int i; - int changed = 0; int file_changed = 0; char new_filename[64]; int rv; @@ -1132,7 +1168,6 @@ void fixnss(void) { } while (fgets(buf, sizeof buf, fp_read) != NULL) { - changed = 0; strcpy(buf_nc, buf); for (i=0; i 0) { if ((isspace(buf_nc[i+2])) || (buf_nc[i+2]==0)) { - changed = 1; file_changed = 1; strcpy(&buf_nc[i], &buf_nc[i+2]); strcpy(&buf[i], &buf[i+2]); @@ -1186,6 +1220,9 @@ void fixnss(void) { if (yesno(question, 1)) { sprintf(buf, "/bin/mv -f %s %s", new_filename, NSSCONF); rv = system(buf); + if (rv != 0) + fprintf(stderr, "failed to edit %s.\n", NSSCONF); + chmod(NSSCONF, 0644); } unlink(new_filename); @@ -1207,6 +1244,8 @@ void check_init_script (char *relhome) if (!access("/etc/init.d/citadel", X_OK)) { rv = system("/etc/init.d/citadel start"); + if (rv != 0) + fprintf(stderr, "failed to call our initscript."); sleep(3); } @@ -1280,17 +1319,17 @@ void GetDefaultValChar(char *WhereTo, const char *VarName, char DefVal) *WhereTo = atoi(ch); } } -#define GetDefaultVALSTR(CFGNAME, DEFL) GetDefaultValStr((char**)&config.CFGNAME, sizeof(config.CFGNAME), "CITADEL_"#CFGNAME, DEFL) -void GetDefaultValStr(char **WhereTo, size_t nMax, const char *VarName, const char *DefVal) +#define GetDefaultVALSTR(CFGNAME, DEFL) GetDefaultValStr(&config.CFGNAME[0], sizeof(config.CFGNAME), "CITADEL_"#CFGNAME, DEFL) +void GetDefaultValStr(char *WhereTo, size_t nMax, const char *VarName, const char *DefVal) { const char *ch; - if (**WhereTo == '\0') - safestrncpy(*WhereTo, DefVal, nMax); + if (*WhereTo == '\0') + safestrncpy(WhereTo, DefVal, nMax); if ((setup_type == UI_SILENT) && (ch = getenv(VarName), ch != NULL)) { - safestrncpy(*WhereTo, ch, nMax); + safestrncpy(WhereTo, ch, nMax); } } @@ -1416,8 +1455,11 @@ void get_config (void) if (fp == NULL) { display_error("%s citadel.config [%s][%s]\n", _("setup: cannot open"), file_citadel_config, strerror(errno)); cleanup(errno); + return; } rv = fread((char *) &config, sizeof(struct config), 1, fp); + if (rv == -1) + display_error("%s citadel.config [%s][%s]\n", _("setup: cannot write"), file_citadel_config, strerror(errno)); fclose(fp); } @@ -1498,6 +1540,8 @@ int main(int argc, char *argv[]) /* Try to stop Citadel if we can */ if (!access("/etc/init.d/citadel", X_OK)) { rv = system("/etc/init.d/citadel stop"); + if (rv != 0) + fprintf(stderr, _("failed to stop us using the initscript.\n")); } /* Make sure Citadel is not running. */