summaryrefslogtreecommitdiff
path: root/debian/debconf.gamla/debconf_eximconfig
diff options
context:
space:
mode:
Diffstat (limited to 'debian/debconf.gamla/debconf_eximconfig')
-rw-r--r--debian/debconf.gamla/debconf_eximconfig628
1 files changed, 628 insertions, 0 deletions
diff --git a/debian/debconf.gamla/debconf_eximconfig b/debian/debconf.gamla/debconf_eximconfig
new file mode 100644
index 0000000..5b888bd
--- /dev/null
+++ b/debian/debconf.gamla/debconf_eximconfig
@@ -0,0 +1,628 @@
+#!/usr/bin/perl -w
+
+require 5;
+use strict;
+use Debconf::Client::ConfModule ':all';
+use Carp;
+
+sub get_value($) {
+ my $key = shift;
+ my($code,$text) = get($key);
+ return $text if ($code == 0);
+ croak("Unable to fetch value for \"$key\" (debconf code $code)\n");
+}
+
+version('2.0');
+#my $capb = capb('backup multiselect');
+
+######################################################################
+# Get data, mainly from Debconf
+
+my $syshostname;
+chomp($syshostname = `hostname --fqdn`);
+my $configtype = get_value("exim/eximconfig/configtype");
+my $visiblename;
+if ($configtype eq 'satellite') {
+ $visiblename = get_value("exim/eximconfig/satellite_hostname");
+}
+elsif ($configtype eq 'local') {
+ $visiblename = $syshostname;
+}
+elsif ($configtype eq 'none') {
+ # leave their configuration alone
+ exit(0);
+}
+else {
+ $visiblename = get_value("exim/eximconfig/visible_hostname");
+}
+
+my @local_domains = ($visiblename, "localhost");
+my @relay_domains = ();
+my @relay_nets = ('127.0.0.1', '::::1');
+if ($configtype eq 'satellite' || $configtype eq 'internet' || $configtype eq 'smarthost') {
+ push @local_domains, split(/[ ,]+/, get_value("exim/eximconfig/other_hostnames"));
+ push @relay_domains, split(/[ ,]+/, get_value("exim/eximconfig/relay_domains"));
+ push @relay_nets, split(/[ ,]+/, get_value("exim/eximconfig/relay_nets"));
+}
+
+my $readhost;
+if ($configtype eq 'satellite') {
+ $readhost = get_value("exim/eximconfig/readhost");
+}
+
+my $smarthost;
+if ($configtype eq 'smarthost' || $configtype eq 'satellite') {
+ $smarthost = get_value("exim/eximconfig/smarthost");
+}
+
+my $overwrite_aliases = get_value("exim/eximconfig/overwrite_aliases") eq 'true';
+
+my @postmasters = split(/[ ,]+/, get_value("exim/eximconfig/postmaster"));
+
+my $mailbox_format = get_value("exim/eximconfig/mailbox_format");
+my $local_delivery;
+if ($mailbox_format eq 'spool') {
+ $local_delivery = 'mail_spool';
+}
+elsif ($mailbox_format eq 'maildir') {
+ $local_delivery = 'maildir_home';
+}
+else {
+ die "Unrecognised mailbox format \"$mailbox_format\"\n";
+}
+
+my $use_maildrop = ($mailbox_format eq 'maildir') && (get_value("exim/eximconfig/auto_maildrop") eq 'true');
+my $use_procmail = ($mailbox_format eq 'spool') && (get_value("exim/eximconfig/auto_procmail") eq 'true');
+
+# Read password file and find users that need redirection
+my @redirusers = ('nobody', 'hostmaster', 'usenet', 'news', 'webmaster', 'www', 'ftp', 'abuse', 'noc', 'security');
+while (my @a = getpwent) {
+ next unless ($a[2] < 1000);
+ next if ($a[0] eq 'root');
+ push @redirusers, $a[0];
+}
+
+######################################################################
+# Show summary on stderr
+
+sub say {
+ my @words = map { split(/\s+/, $_) } @_;
+ my $out = '';
+ while (@words) {
+ my $word = shift @words;
+ if (length($out)+length($word)+1 > 70) {
+ print STDERR "$out\n";
+ $out = '';
+ }
+ $out .= "$word ";
+ }
+ print STDERR "$out\n" if ($out);
+ print STDERR "\n";
+}
+
+say("Now using your answers to debconf questions to configure Exim 4. \
+ Use \"dpkg-reconfigure exim\" to change your configuration, or \
+ to disable automatic rebuilding of your configuration on each \
+ and every upgrade.");
+
+say("Mail generated on this system will have \
+ '".($configtype eq 'satellite' ? $readhost : $visiblename)."' used \
+ as the domain part (after the \@) in the From: field and similar places.");
+
+say("The following domain(s) will be recognised as referring to this system: ", @local_domains);
+
+if (@relay_domains) {
+ say("Messages for the following domains will be relayed: ", @relay_domains);
+}
+
+say("Mail for postmaster, root etc. will be sent to: ", @postmasters);
+
+if ($configtype ne 'satellite') {
+ if ($mailbox_format eq 'spool') {
+ say("Local mail is delivered to /var/spool/mail/\$USER mailboxes.", $use_procmail ? ".procmail files will automatically be used by procmail if found" : "");
+ }
+ elsif ($mailbox_format eq 'maildir') {
+ say("Local mail is delivered to \$HOME/Maildir directories.", $use_procmail ? ".mailfilter files will automatically be used by maildrop if found" : "");
+ }
+}
+
+if ($configtype eq 'internet') {
+ say("Outbound remote mail is lookup up in the Internet DNS, and delivered using that data if any is found; otherwise such messages are bounced.");
+}
+elsif ($configtype eq 'smarthost') {
+ say("Outbound remote mail is sent via $smarthost");
+}
+elsif ($configtype eq 'satellite') {
+ say("All mail is being routed and delivered via $smarthost");
+}
+elsif ($configtype eq 'local') {
+ say("Any mail destined for remote addresses is bounced.");
+}
+
+say("Note that you can set email addresses used for outgoing mail by editing /etc/email-addresses.");
+
+######################################################################
+# Write $visiblename into /etc/mailname
+
+if (open(MAILNAME, ">/etc/mailname")) {
+ print STDERR "Writing /etc/mailname...\n";
+ print MAILNAME "$visiblename\n";
+ close(MAILNAME);
+}
+else {
+ warn "Unable to write /etc/mailname: $!\n";
+}
+
+######################################################################
+# This subroutine autodetects whether a file was generated ourselves
+
+sub autogenerated($) {
+ my $filename = shift;
+ open(FILE, $filename) or die "Unable to read $filename: $!\n";
+ my $top = <FILE>;
+ close FILE;
+ return ($top eq "# AUTOGENERATED\n");
+}
+
+######################################################################
+# Write /etc/aliases
+if ($overwrite_aliases) {
+ if (open(ALIASES, ">/etc/aliases.exim-pkg-new.$$")) {
+ print STDERR "Writing /etc/aliases...\n";
+ print ALIASES <<EOF
+# AUTOGENERATED
+#
+# This is the aliases file - it says who gets mail for whom.
+#
+# This file automatically generated. You must reconfigure Exim to stop
+# regenerating this file before you make changes yourself, or your
+# changes will be lost when you upgrade Exim.
+# (use: dpkg-reconfigure exim)
+#
+
+EOF
+;
+ print ALIASES "root: ".join(', ', map { "real-$_" } @postmasters)."\n";
+ print ALIASES "postmaster: root\n";
+ print ALIASES "mailer-daemon: postmaster\n";
+ foreach my $redir (@redirusers) {
+ print ALIASES "$redir: root\n";
+ }
+
+ close(ALIASES);
+ if (-f "/etc/aliases" && !autogenerated("/etc/aliases")) {
+ print "Backing up old /etc/aliases to /etc/aliases.O...\n";
+ unlink("/etc/aliases.O");
+ rename("/etc/aliases", "/etc/aliases.O")
+ or die "Unable to rename /etc/aliases to /etc/aliases.O: $!\n";
+ }
+ rename("/etc/aliases.exim-pkg-new.$$", "/etc/aliases")
+ or die "Unable to rename /etc/aliases.exim-pkg-new.$$ to /etc/aliases: $!\n";
+ }
+ else {
+ warn "Unable to write /etc/aliases.exim-pkg-new.$$: $!\n";
+ }
+}
+else {
+ print STDERR "Not writing /etc/aliases by user request\n";
+}
+
+######################################################################
+# Write /etc/exim4/exim4.conf
+
+unless (open(EXIMCONF, ">/etc/exim4/exim4.conf.exim-pkg-new.$$")) {
+ die "Unable to write /etc/exim4/exim4.conf.exim-pkg-new.$$: $!\n";
+}
+
+print STDERR "Writing /etc/exim4/exim4.conf...\n";
+
+my $local_domains = join(' : ', '@', @local_domains);
+my $relay_domains = join(' : ', @relay_domains);
+my $relay_nets = join(' : ', @relay_nets);
+
+my $now = localtime(time);
+
+print EXIMCONF <<EOF;
+# AUTOGENERATED
+
+# Runtime configuration file for Exim
+# This file generated by debconf_eximconfig, $now
+
+# THIS FILE WILL BE REGENERATED EVERY TIME THE EXIM PACKAGE IS UPGRADED
+# UNLESS YOU RUN
+# dpkg-reconfigure exim
+# AND CHOOSE "NONE" AS THE CONFIGURATION TYPE.
+
+# (you can check what the configuration type is currently set to using
+# the command
+# debconf-show exim | grep configtype
+# )
+
+# Main configuration settings
+
+# Let Exim autodetct this; we autodetected $syshostname at run-time
+# primary_hostname =
+EOF
+
+print EXIMCONF "domainlist local_domains = $local_domains\n";
+print EXIMCONF "domainlist relay_to_domains = $relay_domains\n";
+print EXIMCONF "hostlist relay_from_hosts = $relay_nets\n\n";
+print EXIMCONF "qualify_domain = $visiblename\n\n";
+
+print EXIMCONF <<EOF;
+acl_smtp_rcpt = acl_check_rcpt
+
+# qualify_recipient =
+
+# allow_domain_literals
+
+never_users = root
+
+host_lookup = *
+
+rfc1413_hosts = *
+rfc1413_query_timeout = 30s
+
+# sender_unqualified_hosts =
+# recipient_unqualified_hosts =
+
+# percent_hack_domains =
+
+ignore_bounce_errors_after = 2d
+
+timeout_frozen_after = 7d
+
+freeze_tell = postmaster
+
+received_header_text = "Received: \\
+ \${if def:sender_rcvhost {from \${sender_rcvhost}\\n\\t}\\
+ {\${if def:sender_ident {from \${sender_ident} }}\\
+ \${if def:sender_helo_name {(helo=\${sender_helo_name})\\n\\t}}}}\\
+ by \${primary_hostname} \\
+ \${if def:received_protocol {with \${received_protocol}}} \\
+ (Exim \${version_number} #\${compile_number} (Debian) [+araqnid])\\n\\t\\
+ id \${message_id}\\
+ \${if def:received_for {\\n\\tfor <\$received_for>}}"
+
+begin acl
+
+acl_check_rcpt:
+ accept hosts = :
+ deny local_parts = ^.[\@\%!/|] : ^\\\\.
+ accept local_parts = postmaster
+ domains = +local_domains
+ require verify = sender
+
+ # deny message = rejected because \$sender_host_address is in a black list at \$dnslist_domain\\n\$dnslist_text
+ # dnslists = black.list.example.com
+
+ # warn message = X-Warning: \$sender_host_address is in a black list at \$dnslist_domain
+ # dnslists = black.list.example.com
+
+ accept domains = +local_domains
+ endpass
+ message = unknown user
+ verify = recipient
+
+ accept domains = +relay_to_domains
+ endpass
+ message = unrouteable address
+ verify = recipient
+
+ accept hosts = +relay_from_hosts
+
+ accept authenticated = *
+
+ deny message = relay not permitted
+
+begin routers
+
+EOF
+ ;
+
+if ($configtype eq 'internet') {
+ print EXIMCONF <<EOF;
+dnslookup:
+ driver = dnslookup
+ domains = ! +local_domains
+ transport = remote_smtp
+ ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
+ no_more
+
+EOF
+}
+elsif ($configtype eq 'smarthost' || $configtype eq 'satellite') {
+ print EXIMCONF <<EOF;
+smarthost:
+ driver = manualroute
+ domains = ! +local_domains
+ transport = remote_smtp
+ route_list = * $smarthost
+ no_more
+
+EOF
+}
+else {
+ print EXIMCONF <<EOF;
+# Stand-alone system, so generate an error for amil to a non-local domain
+nonlocal:
+ driver = redirect
+ allow_fail
+ data = :fail: Mailing to remote domains not supported
+ no_more
+ domains = ! +local_domains
+
+EOF
+}
+
+print EXIMCONF <<EOF;
+# The "no_more" above means that all routers below here are for
+# domains in the local_domains list, i.e. just like Exim 3 directors.
+
+real_local:
+ driver = accept
+ local_part_prefix = real-
+ check_local_user
+ transport = $local_delivery
+
+system_aliases:
+ driver = redirect
+ allow_fail
+ allow_defer
+ data = \${lookup{\$local_part}lsearch{/etc/aliases}}
+ file_transport = address_file
+ pipe_transport = address_pipe
+
+EOF
+ ;
+
+if ($configtype eq 'satellite') {
+ print EXIMCONF <<EOF;
+hub_user:
+ driver = redirect
+ data = \${local_part}\@$readhost
+ check_local_user
+
+EOF
+ ;
+}
+
+print EXIMCONF <<EOF;
+userforward:
+ driver = redirect
+ check_local_user
+ file = \$home/.forward
+ no_verify
+ no_expn
+ check_ancestor
+# allow_filter
+ file_transport = address_file
+ pipe_transport = address_pipe
+ reply_transport = address_reply
+
+EOF
+
+if ($use_procmail) {
+ print EXIMCONF <<EOF;
+procmail:
+ driver = accept
+ check_local_user
+ transport = procmail_pipe
+ require_files = \${local_part}:\${home}/.procmailrc:+/usr/bin/procmail
+ no_verify
+ no_expn
+
+EOF
+}
+
+if ($use_maildrop) {
+ print EXIMCONF <<EOF;
+maildrop:
+ driver = accept
+ check_local_user
+ transport = maildrop_pipe
+ require_files = \${local_part}:\${home}/.mailfilter:+/usr/bin/maildrop
+ no_verify
+ no_expn
+
+EOF
+}
+
+ print EXIMCONF <<EOF;
+local_user:
+ driver = accept
+ check_local_user
+ transport = $local_delivery
+
+begin transports
+
+EOF
+ ;
+if ($configtype ne 'local') {
+ print EXIMCONF <<EOF;
+remote_smtp:
+ driver = smtp
+
+EOF
+;
+}
+
+if ($mailbox_format eq 'spool') {
+ print EXIMCONF <<EOF;
+mail_spool:
+ driver = appendfile
+ file = /var/spool/mail/\$local_part
+ delivery_date_add
+ envelope_to_add
+ return_path_add
+ group = mail
+ mode = 0660
+
+EOF
+}
+
+if ($mailbox_format eq 'maildir') {
+ print EXIMCONF <<EOF;
+maildir_home:
+ driver = appendfile
+ directory = \$home/Maildir
+ maildir_format
+ mode = 0600
+
+EOF
+}
+
+print EXIMCONF <<EOF;
+address_pipe:
+ driver = pipe
+ return_output
+
+address_file:
+ driver = appendfile
+ delivery_date_add
+ envelope_to_add
+ return_path_add
+
+address_reply:
+ driver = autoreply
+
+EOF
+
+if ($use_maildrop) {
+ print EXIMCONF <<EOF;
+maildrop_pipe:
+ driver = pipe
+ path = "/bin:/usr/bin:/usr/local/bin"
+ command = "/usr/bin/maildrop"
+ return_path_add
+ delivery_date_add
+ envelope_to_add
+
+EOF
+}
+
+if ($use_procmail) {
+ print EXIMCONF <<EOF;
+procmail_pipe:
+ driver = pipe
+ path = "/bin:/usr/bin:/usr/local/bin"
+ command = "/usr/bin/procmail"
+ return_path_add
+ delivery_date_add
+ envelope_to_add
+
+EOF
+}
+
+print EXIMCONF <<EOF;
+begin retry
+
+# Domain Error Retries
+# ------ ----- -------
+
+* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
+
+begin rewrite
+
+EOF
+ ;
+
+print EXIMCONF <<EOF;
+# This rewriting rule is particularly useful for dialup users who
+# don't have their own domain, but could be useful for anyone.
+# It looks up the real address of all local users in a file
+
+EOF
+ ;
+
+for my $domain (@local_domains) {
+ print EXIMCONF "*\@$domain \${lookup{\${local_part}}lsearch{/etc/email-addresses}{\$value}fail} Ffrs\n";
+}
+
+if ($configtype eq 'satellite') {
+ print EXIMCONF <<EOF
+# These rewriters make sure the mail messages appear to have originated
+# from the real mail-reading host.
+
+EOF
+;
+
+ my $fuser = $postmasters[0];
+ for my $domain (@local_domains) {
+ print EXIMCONF "^(?i)(root|postmaster|mailer-daemon)\@$domain \$\{local_part\}\@in.limbo Ffr\n"
+ if (@postmasters);
+ print EXIMCONF "*\@$domain \$\{local_part\}\@$readhost Ffr\n";
+ }
+ print EXIMCONF "*\@in.limbo $fuser\@$readhost Ffr\n"
+ if (@postmasters);
+}
+
+print EXIMCONF <<'EOF';
+
+begin authenticators
+
+# The examples below are for server side authentication; they allow two
+# styles of plain-text authentication against an /etc/exim4/passwd file
+# which should have user IDs in the first column and crypted passwords
+# in the second.
+
+# plain:
+# driver = plaintext
+# public_name = PLAIN
+# server_condition = "${if crypteq{$2}{${extract{1}{:}{${lookup{$1}lsearch{/etc/exim4/passwd}{$value}{*:*}}}}}{1}{0}}"
+# server_set_id = $1
+#
+# login:
+# driver = plaintext
+# public_name = LOGIN
+# server_prompts = "Username:: : Password::"
+# server_condition = "${if crypteq{$3}{${extract{1}{:}{${lookup{$2}lsearch{/etc/exim4/passwd}{$value}{*:*}}}}}{1}{0}}"
+# server_set_id = $3
+#
+# cram_md5:
+# driver = cram_md5
+# public_name = CRAM-MD5
+# server_condition = "${if crypteq{$2}{${extract{1}{:}{${lookup{$1}lsearch{/etc/exim4/passwd}{$value}{*:*}}}}}{1}{0}}"
+# server_set_id = $1
+
+# Here is an example of CRAM-MD5 authentication against PostgreSQL:
+#
+# psqldb_auth:
+# driver = cram_md5
+# public_name = CRAM-MD5
+# server_condition = "${if crypteq{$2}{${lookup pgsql{SELECT pw FROM users WHERE username = '${quote_pgsql:$1}'}{$value}fail}{1}{0}}"
+# server_set_id = $1
+
+# These examples below are the equivalent for client side authentication.
+# They assume that you only use client side authentication to connect to
+# one host (such as a smarthost at your ISP), or else use the same user
+# name and password everywhere
+
+# plain:
+# driver = plaintext
+# public_name = PLAIN
+# client_send = "^username^password"
+#
+# login:
+# driver = plaintext
+# public_name = LOGIN
+# client_send = ": username : password"
+#
+# cram_md5:
+# driver = cram_md5
+# public_name = CRAM-MD5
+# client_name = username
+# client_secret = password
+
+EOF
+;
+
+close(EXIMCONF);
+
+unlink("/etc/exim4/exim4.conf.O");
+if (-f "/etc/exim4/exim4.conf") {
+ rename("/etc/exim4/exim4.conf", "/etc/exim4/exim4.conf.O")
+ or die "Unable to move /etc/exim4/exim4.conf to /etc/exim4/exim4.conf.O: $!\n";
+}
+rename("/etc/exim4/exim4.conf.exim-pkg-new.$$", "/etc/exim4/exim4.conf")
+ or die "Unable to move /etc/exim4/exim4.conf.exim-pkg-new.$$ to /etc/exim4/exim4.conf: $!\n";