diff options
Diffstat (limited to 'usr.sbin/sade/config.c')
-rw-r--r-- | usr.sbin/sade/config.c | 190 |
1 files changed, 185 insertions, 5 deletions
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index 29e7cfe..8709798 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -373,23 +373,58 @@ configRC(dialogMenuItem *unused) return DITEM_SUCCESS; } +/* + * Write out rc.conf + * + * rc.conf is sorted if running as init and the needed utilities are + * present + * + * If rc.conf is sorted, all variables in rc.conf which conflict with + * the variables in the environment are removed from the original + * rc.conf + */ void configRC_conf(void) { - FILE *rcSite; + char line[256]; + FILE *rcSite, *rcOld; Variable *v; int write_header; time_t t_loc; char *cp; static int did_marker = 0; + int do_sort; + int do_merge; time_t tp; configTtys(); write_header = !file_readable("/etc/rc.conf"); - rcSite = fopen("/etc/rc.conf", "a"); - if (!rcSite) + do_sort = RunningAsInit && file_readable("/usr/bin/sort") && + file_readable("/usr/bin/uniq"); + do_merge = do_sort && file_readable("/etc/rc.conf"); + + if(do_merge) { + rcSite = fopen("/etc/rc.conf.new", "w"); + } else + rcSite = fopen("/etc/rc.conf", "a"); + if (rcSite == NULL) { + msgError("Error opening new rc.conf for writing: %s (%u)", strerror(errno), errno); return; - if (write_header) { + } + + if (do_merge) { + /* "Copy" the old rc.conf */ + rcOld = fopen("/etc/rc.conf", "r"); + if(!rcOld) { + msgError("Error opening rc.conf for reading: %s (%u)", strerror(errno), errno); + return; + } + while(fgets(line, sizeof(line), rcOld)) { + if(line[0] == '#' || variable_check2(line) != 0) + fprintf(rcSite, "%s", line); + } + fclose(rcOld); + } else { fprintf(rcSite, "# This file now contains just the overrides from /etc/defaults/rc.conf.\n"); fprintf(rcSite, "# Please make all changes to this file, not to /etc/defaults/rc.conf.\n\n"); fprintf(rcSite, "# Enable network daemons for user convenience.\n"); @@ -411,10 +446,19 @@ configRC_conf(void) } } fclose(rcSite); + + if(do_merge) { + if(rename("/etc/rc.conf.new", "/etc/rc.conf") != 0) { + msgError("Error renaming temporary rc.conf: %s (%u)", strerror(errno), errno); + return; + } + } + /* Tidy up the resulting file if it's late enough in the installation for sort and uniq to be available */ - if (RunningAsInit && file_readable("/usr/bin/sort") && file_readable("/usr/bin/uniq")) + if (do_sort) { (void)vsystem("sort /etc/rc.conf | uniq > /etc/rc.conf.new && mv /etc/rc.conf.new /etc/rc.conf"); + } } int @@ -1091,3 +1135,139 @@ configLoaderACPI(int disable) return DITEM_SUCCESS; } #endif + +int +configMTAPostfix(dialogMenuItem *self) +{ + int ret; + FILE *perconf; + + if(setenv("POSTFIX_DEFAULT_MTA", "YES", 1) != 0) + msgError("Error setting the enviroment variable POSTFIX_DEFAULT_MTA: %s (%u)", + strerror(errno), errno); + + ret = package_add("postfix"); + unsetenv("POSTFIX_DEFAULT_MTA"); + + if(DITEM_STATUS(ret) == DITEM_FAILURE) { + msgConfirm("An error occurred while adding the postfix package\n" + "Please change installation media and try again."); + return ret; + } + + variable_set2(VAR_SENDMAIL_ENABLE, "YES", 1); + variable_set2("sendmail_flags", "-bd", 1); + variable_set2("sendmail_outbound_enable", "NO", 1); + variable_set2("sendmail_submit_enable", "NO", 1); + variable_set2("sendmail_msp_queue_enable", "NO", 1); + + perconf = fopen("/etc/periodic.conf", "a"); + if (perconf == NULL) { + msgConfirm("Unable to open /etc/periodic.conf.\n" + "The daily cleanup scripts might generate errors when\n" + "trying to run some sendmail only cleanup scripts.\n" + "Please consult the documentation for the postfix port on how to\n" + "fix this."); + + /* Not really a serious problem, so we return success */ + return DITEM_SUCCESS; + } + + fprintf(perconf, "# --- Generated by sysinstall ---\n"); + fprintf(perconf, "daily_clean_hoststat_enable=\"NO\"\n"); + fprintf(perconf, "daily_status_mail_rejects_enable=\"NO\"\n"); + fprintf(perconf, "daily_status_include_submit_mailq=\"NO\"\n"); + fprintf(perconf, "daily_submit_queuerun=\"NO\"\n"); + fclose(perconf); + + msgConfirm("Postfix is now installed and enabled as the default MTA.\n" + "Please check that the configuration works as expected.\n" + "See the Postfix documentation for more information.\n" + "The documentation can be found in /usr/local/share/doc/postfix/\n" + "or on the Postfix website at http://www.postfix.org/."); + + return DITEM_SUCCESS; +} + +int +configMTAExim(dialogMenuItem *self) +{ + int ret; + FILE *perconf, *mailerconf, *newsyslogconf; + + ret = package_add("exim"); + + if(DITEM_STATUS(ret) == DITEM_FAILURE) { + msgConfirm("An error occurred while adding the exim package\n" + "Please change installation media and try again."); + return ret; + } + + variable_set2(VAR_SENDMAIL_ENABLE, "NONE", 1); + + if(file_readable("/usr/local/etc/exim/configure.default") && + !file_readable("/usr/local/etc/exim/configure")) { + if(vsystem("cp /usr/local/etc/exim/configure.default /usr/local/etc/exim/configure")) + msgConfirm("An error occurred while coping the exim configuration file.\n" + "Please check if exim is working after you have completed this\n" + "installation.\n"); + } + + /* Update periodic.conf */ + perconf = fopen("/etc/periodic.conf", "a"); + if (perconf == NULL) { + /* Not really a serious problem, so we do not abort */ + msgConfirm("Unable to open /etc/periodic.conf.\n" + "The daily cleanup scripts might generate errors when\n" + "trying to run some sendmail only cleanup scripts.\n" + "Please consult the documentation for the postfix port on how to\n" + "fix this."); + } else { + fprintf(perconf, "# --- Generated by sysinstall ---\n"); + fprintf(perconf, "daily_status_include_submit_mailq=\"NO\"\n"); + fclose(perconf); + } + + /* Update mailer.conf */ + vsystem("mv -f /etc/mail/mailer.conf /etc/mail/mailer.conf.old"); + mailerconf = fopen("/etc/mail/mailer.conf", "w"); + if (mailerconf == NULL) { + /* Not really a serious problem, so we do not abort */ + msgConfirm("Unable to open /etc/mailer.conf.\n" + "Some programs which use the sendmail wrappers may not work.\n" + "Please consult the documentation for the exim port on how\n" + "to correct this."); + } else { + fprintf(mailerconf, "# --- Generated by sysinstall ---\n"); + fprintf(mailerconf, "# Execute exim instead of sendmail\n"); + fprintf(mailerconf, "#\n"); + fprintf(mailerconf, "sendmail /usr/local/sbin/exim\n"); + fprintf(mailerconf, "send-mail /usr/local/sbin/exim\n"); + fprintf(mailerconf, "mailq /usr/local/sbin/exim -bp\n"); + fprintf(mailerconf, "newaliases /usr/bin/true\n"); + fclose(mailerconf); + } + + /* Make newsyslog rotate exim logfiles */ + newsyslogconf = fopen("/etc/newsyslog.conf", "a"); + if (newsyslogconf == NULL) { + /* Not really a serious problem, so we do not abort */ + msgConfirm("Unable to open /etc/newsyslog.conf.\n" + "The exim logfiles will not be rotated.\n" + "Please consult the documentation for the exim port on how to\n" + "rotate the logfiles."); + } else { + fprintf(newsyslogconf, "# --- Generated by sysinstall ---\n"); + fprintf(newsyslogconf, "/var/log/exim/mainlog mailnull:mail 640 7 * @T00 Z\n"); + fprintf(newsyslogconf, "/var/log/exim/rejectlog mailnull:mail 640 7 * @T00 Z\n"); + fclose(newsyslogconf); + } + + msgConfirm("Exim is now installed and enabled as the default MTA.\n" + "Please check that the configuration works as expected.\n" + "See the Exim documentation for more information.\n" + "The documentation can be found in /usr/local/share/doc/exim/\n" + "or on the Exim website at http://www.exim.org/."); + + return DITEM_SUCCESS; +} |