diff options
Diffstat (limited to 'debian/sendmailconfig')
-rw-r--r-- | debian/sendmailconfig | 128 |
1 files changed, 94 insertions, 34 deletions
diff --git a/debian/sendmailconfig b/debian/sendmailconfig index 3d44a9e..a729607 100644 --- a/debian/sendmailconfig +++ b/debian/sendmailconfig @@ -1,11 +1,14 @@ -#!/bin/sh -e +#!/bin/sh # # Interactively configure Sendmail for Debian # -# Robert Leslie <rob@mars.org> +# Robert Leslie <rob@mars.org>, +# Rick Nelson <cowboy@debian.org> PATH="/usr/sbin:/usr/bin:/sbin:/bin" +FILE="/etc/mail/sendmail.mc" +set +e reload="yes" umask 022 @@ -80,18 +83,34 @@ input() { } testconfig() { - CONFIG=$(grep "$1" /etc/mail/sendmail.mc 2>/dev/null) + CONFIG=$(grep "$1" $FILE 2>/dev/null) +} + +testwrap() { + WRAP=$(grep "^[^#:]*sendmail[^:]*[:]" /etc/hosts.allow 2>/dev/null) +} + +updatewrap() { + echo "Updating /etc/hosts.allow, adding \"sendmail: all\"." + echo "sendmail: all" | cat - /etc/hosts.allow >/etc/hosts.allow.new + mv -f /etc/hosts.allow.new /etc/hosts.allow + /etc/init.d/netbase reload >/dev/null } makecf() { echo "Generating /etc/mail/sendmail.cf from /etc/mail/sendmail.mc ..." - m4 /usr/lib/sendmail.cf/m4/cf.m4 /etc/mail/sendmail.mc \ + m4 /usr/share/sendmail.cf/m4/cf.m4 $FILE \ >/etc/mail/sendmail.cf.new mv -f /etc/mail/sendmail.cf.new /etc/mail/sendmail.cf echo "Updating alias database ..." newaliases + testwrap + if [ "$WRAP" = "" ]; then + updatewrap + fi + if [ "$reload" ] && \ yesno "Reload the running sendmail now with the new configuration" Y then @@ -102,7 +121,7 @@ makecf() { ############################################################################### -if [ -f /etc/mail/sendmail.mc ] +if [ -f $FILE ] then if yesno "Configure sendmail with the existing /etc/mail/sendmail.mc" Y then @@ -113,8 +132,8 @@ fi ############################################################################### -exec 3>/etc/mail/sendmail.mc.new -trap "rm -f /etc/mail/sendmail.mc.new" 0 +exec 3>$FILE.new +trap "rm -f $FILE.new" 0 ############################################################################### @@ -127,7 +146,8 @@ EOT echo -n "Press [ENTER] " read REPLY -cat /usr/lib/sendmail.cf/cf/debproto.mc >&3 +cat /usr/share/sendmail.cf/cf/debproto.mc >&3 +echo "LOCAL_CONFIG" >&3 ############################################################################### @@ -145,24 +165,63 @@ echo "$mailname" >/etc/mailname ############################################################################### -descrip "Null Client" <<EOT -A special configuration known as the "null client" can be created for this -host if all mail should be forwarded to a central hub via a local SMTP-based -network. This may be a suitable configuration if you want to forward all of -your mail to your local Internet service provider (ISP) for delivery. - -To enable this option, give the name of the host to which all mail should be -forwarded. Otherwise leave the option empty or answer \`NONE' to disable it. -EOT +#descrip "Null Client" <<EOT +#A special configuration known as the "null client" can be created for this +#host if all mail should be forwarded to a central hub via a local SMTP-based +#network. This may be a suitable configuration if you want to forward all of +#your mail to your local Internet service provider (ISP) for delivery. +# +#To enable this option, give the name of the host to which all mail should be +#forwarded. Otherwise leave the option empty or answer \`NONE' to disable it. +#EOT nullclient="" ! testconfig "FEATURE(nullclient" || nullclient=$(echo -n "$CONFIG" | sed -e 's/[^,]*, *\([^)]*\).*/\1/') +# +#input "Null client forward host" nullclient NONE +# +#test -z "$nullclient" || echo "FEATURE(nullclient, $nullclient)dnl" >&3 + +if [ -n "$nullclient" ]; then + echo " " + echo " *** IMPORTANT *** " + echo " " + echo "You are using a nullclient setup. This is ill advised as it" + echo "makes your machine an open relay: If you ever connect to the" + echo "internet, anyone can forge mail and send it through your machine" + echo "to anyone else on the internet! - not a pretty picture." + echo " " + echo "I will convert this into a Smart Host config for you. A Smart Host" + echo "setup is a superset of nullclient - you lose nothing, but gain local" + echo "delivery without kluges, and, of course you're no longer an open relay" + echo " " + echo "You will need to accept your nullclient hostname below, when asked" + echo "for a smart host." + echo " " + echo "Press <Enter> to continue" + read yn + fi + +############################################################################### +descrip "Smart Host" <<EOT +A "Smart Host" is one that can deliver mail to external machines. By using +a "Smart Host", we don't need DNS, or good connectivity ourselves. This is +most likely what you want if you have a dialup link, or sit behind a firewall. + +To enable this option, give the name of the host to which all non-local mail +should be forwarded. Otherwise leave the option empty. +EOT -input "Null client forward host" nullclient NONE - -test -z "$nullclient" || echo "FEATURE(nullclient, $nullclient)dnl" >&3 +smarthost="" +if [ -n $nullclient ]; then + smarthost=$nullclient + fi +! testconfig "define(\`SMART_HOST', smtp:" || + smarthost=$(echo -n "$CONFIG" | sed -e 's/[^:]*:*\([^)]*\).*/\1/') +input "Smart Host:" smarthost "" +test -z $smarthost || echo "define(\`SMART_HOST', smtp:$smarthost)dnl" >&3 ############################################################################### descrip "Address Canonification" <<EOT @@ -201,7 +260,7 @@ it is still a good idea to enable this so local programs can use it. EOT smtp="Y" -if [ -f /etc/mail/sendmail.mc ] +if [ -f $FILE ] then testconfig "MAILER(smtp)" || smtp="N" fi @@ -216,7 +275,7 @@ If you want mail envelopes (as well as mail headers) to appear to come from EOT masqenvelope="Y" -if [ -f /etc/mail/sendmail.mc ] +if [ -f $FILE ] then testconfig "FEATURE(masquerade_envelope)" || masqenvelope="N" fi @@ -268,12 +327,13 @@ to another host. If in doubt, it is safe to leave this option enabled. EOT acceptmailname="Y" -if [ -f /etc/mail/sendmail.mc ] +if [ -f $FILE ] then testconfig "^Cw.*$mailname" || acceptmailname="N" fi yesno "Accept mail for \`$mailname'" acceptmailname || true +test "N" = "$acceptmailname" || echo "Cw$mailname" >&3 ############################################################################### @@ -350,7 +410,7 @@ need to do some additional configuration, perhaps outside of this script. EOT uucp="N" -if [ -f /etc/mail/sendmail.mc ] +if [ -f $FILE ] then testconfig "FEATURE(nouucp)" || uucp="Y" fi @@ -503,15 +563,14 @@ test "4h" = "$qw" || echo "define(\`confTO_QUEUEWARN', \`$qw')dnl" >&3 test "5d" = "$qr" || echo "define(\`confTO_QUEUERETURN', \`$qr')dnl" >&3 ############################################################################### - +echo "MAILER_DEFINITIONS" >&3 echo "MAILER(local)dnl" >&3 test "N" = "$smtp" || echo "MAILER(smtp)dnl" >&3 -test "N" = "$acceptmailname" || echo "Cw$mailname" >&3 ############################################################################### -if [ -e /etc/ifmail/config ] && [ -e /usr/lib/sendmail.cf/mailer/ifmail.m4 ]; +if [ -e /etc/ifmail/config ] && [ -e /usr/share/sendmail.cf/mailer/ifmail.m4 ]; then echo "MAILER(ifmail)dnl" >&3 fi @@ -520,15 +579,16 @@ fi fi # finished non-"null client" configuration -echo "MASQUERADE_AS($mailname)dnl" >&3 ############################################################################### echo "" >&3 +echo "LOCAL_CONFIG" >&3 +echo "MASQUERADE_AS($mailname)dnl" >&3 -if [ -f /etc/mail/sendmail.mc ] +if [ -f $FILE ] then - sed -n -e '/^## Custom/,$p' /etc/mail/sendmail.mc >&3 + sed -n -e '/^## Custom/,$p' $FILE >&3 else echo "## Custom configurations below (will be preserved)" >&3 fi @@ -542,7 +602,7 @@ file. (Local changes made at the end of /etc/mail/sendmail.mc will be preserved by \`$0'.) The m4 library files for sendmail configuration are kept in the -/usr/lib/sendmail.cf directory. You may wish to review the documentation in +/usr/share/sendmail.cf directory. You may wish to review the documentation in /usr/doc/sendmail to assist in further customization. You may wish to customize your alias database; see the aliases(5) man page @@ -553,13 +613,13 @@ EOT exec 3>&- -if [ -f /etc/mail/sendmail.mc ] +if [ -f $FILE ] then echo "Saving old /etc/mail/sendmail.mc as /etc/mail/sendmail.mc.old ..." - mv -f /etc/mail/sendmail.mc /etc/mail/sendmail.mc.old + mv -f $FILE $FILE.old fi -mv -f /etc/mail/sendmail.mc.new /etc/mail/sendmail.mc +mv -f $FILE.new $FILE trap 0 makecf |