diff options
author | Martin Schulze <joey@infodrom.org> | 2004-09-13 09:07:18 +0200 |
---|---|---|
committer | Andreas Beckmann <debian@abeckmann.de> | 2012-10-01 19:58:43 +0200 |
commit | ae03fe5d926a63cab418207f760d62a947957123 (patch) | |
tree | aa48cfe56ac7c47fb9b0abce4d4689033d3098d6 /debian/local | |
parent | dd994db23cb7f88732be927fad3a7039bd6301db (diff) | |
download | sendmail-debian/8.12.3-7.1.tar.gz |
Imported Debian patch 8.12.3-7.1debian/8.12.3-7.1
Diffstat (limited to 'debian/local')
34 files changed, 8057 insertions, 2752 deletions
diff --git a/debian/local/Makefile.in b/debian/local/Makefile.in new file mode 100644 index 0000000..be8f93f --- /dev/null +++ b/debian/local/Makefile.in @@ -0,0 +1,143 @@ +#!/usr/bin/make -f +#------------------------------------------------------------------------------ +# vim: syntax=make +# +# $Sendmail: Makefile,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Copyright (c) 1998-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# @configure_input@ +# +# Rules file for Sendmail @sm_version@@sm_revision@(@sm_version_math@) +# on @sm_dist_name@ @sm_dist_vers@ +# via Debhelper V@DEBIAN_DH@ +# +# Note: the .in file supports Sendmail @SM_MINVERS@ - @SM_MAXVERS@ +# on Debian slink, potato, woody, testing, sid, ... +# but the generated file is customized to the version noted above. +# +# Richard Nelson <cowboy@debian.org> @sm_date@ @sm_time@ (@sm_utc@) +#------------------------------------------------------------------------------ +#SHELL=/bin/sh -x + +# Include Debian Autoconf settings +-include ../build/autoconf.mk + +SCRIPTS := \ + parse_mc \ + Parse_mc.pm \ + sendmailconfig \ + sendmail \ + update_auth \ + update_conf \ + update_db \ + update_mc \ + update_ldap \ + update_mk \ + update_notices \ + update_sendmail \ + update_smrsh \ + update_sys \ + update_tcpd \ + update_tls \ + +all: ; + +clean: + rm -rf core *~ qtool.new; + +setup: + for file in $${SCRIPTS}; do \ + chmod ug+x $$file; \ + done; + +build-indep: setup +build-arch: setup + +install-indep: build-indep +install-arch: build-arch + # + # Debian Local additions / changes + # + # ${sysconfdir}/mail - unconditional + # + $(INSTALL) -d -o mail -g mail ${sysconfdir}/mail/peers; + $(INSTALL_DATA) -o mail -g mail provider \ + ${sysconfdir}/mail/peers/provider; + $(INSTALL_DATA) -o mail -g mail service.switch* ${sysconfdir}/mail/; + # + # ${bindir} - unconditional + # + $(INSTALL) -d ${bindir}; + ln -sf ../share/sendmail/sendmail ${bindir}/mailq; + # + # ${sbindir} - unconditional + # + $(INSTALL) -d ${sbindir}; + $(INSTALL) -d ${mandir}/man8; + ln -sf ../share/sendmail/sendmail ${sbindir}/mailstats; + ln -sf ../share/sendmail/sendmail ${sbindir}/purgestat; + ln -sf ../share/sendmail/sendmail ${sbindir}/runq; + $(INSTALL_DATA) runq.8 ${mandir}/man8; + $(INSTALL_SCRIPT) sendmailconfig ${sbindir}; + $(INSTALL_DATA) sendmailconfig.8 ${mandir}/man8; + # + # ${datadir} - conditional + # + if (grep -qEe "^#LDAP:[[:space:]]*yes" ../build/site.config.m4); then \ + $(INSTALL_SCRIPT) update_ldap ${datadir}/sendmail; \ + fi; + if (grep -qEe "^#AUTH:[[:space:]]*yes" ../build/site.config.m4); then \ + $(INSTALL_SCRIPT) update_auth ${datadir}/sendmail; \ + fi; + if (grep -qEe "^#TLS:[[:space:]]*yes" ../build/site.config.m4); then \ + $(INSTALL_SCRIPT) update_tls ${datadir}/sendmail; \ + fi; + # + # ${datadir}/sendmail - unconditional + # + $(INSTALL) -d ${datadir}/sendmail; + $(INSTALL_SCRIPT) parse_mc ${datadir}/sendmail; + $(INSTALL_SCRIPT) Parse_mc.pm ${datadir}/sendmail; + $(INSTALL_SCRIPT) sendmail ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_conf ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_db ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_mc ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_mk ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_notices ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_sendmail ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_smrsh ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_sys ${datadir}/sendmail; + $(INSTALL_SCRIPT) update_tcpd ${datadir}/sendmail; + # + # ${datadir}/sendmail - conditional + # + $(INSTALL) -d ${datadir}/sendmail; + if [ ! -f ${datadir}/sendmail/qtool.pl ]; then \ + sed -e 's?/usr/bin/env perl?/usr/bin/perl?g' \ + qtool.pl > qtool.new; \ + $(INSTALL_SCRIPT) qtool.new ${datadir}/sendmail/qtool.pl; \ + $(INSTALL_DATA) qtool.8 ${mandir}/man8; \ + fi; + # + # ${datadir}/sendmail/cf/feature - conditional + # + $(INSTALL) -d ${datadir}/sendmail/cf/feature; + if [ ! -e ${datadir}/sendmail/cf/feature/local_no_masquerade.m4 ]; then \ + $(INSTALL_DATA) local_no_masquerade.m4 \ + ${datadir}/sendmail/cf/feature; \ + fi; + +#------------- +# Below here is fairly generic really + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +build: build-indep build-arch +install: install-indep install-arch +.PHONY: all +.PHONY: setup +.PHONY: clean build build-indep build-arch +.PHONY: install install-indep install-arch +.PHONY: source diff diff --git a/debian/local/Parse_mc.pm.in b/debian/local/Parse_mc.pm.in new file mode 100644 index 0000000..a80b754 --- /dev/null +++ b/debian/local/Parse_mc.pm.in @@ -0,0 +1,933 @@ +#!/usr/bin/perl -w +#------------------------------------------------------------------------ +# +# $Sendmail: Parse_mc.pm,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Parse Sendmail config for databases +# +# Copyright (c) 2001-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes (to all): +# * for "define(xxx,...)"; "define(xxx," must be on same line, but the +# rest may be split across multiple lines +# * assumes makemap dbtype /etc/mail/database < /etc/mail/database +# +# Notes (to self): +# * changes made herein *must* be reflected in +# parse_mc,update_mk,update_db,debian.m4 +# * userdb can also have multiple databases and then a forward! +# * Cert support +# * undefine support +# * include support (also for OSTYPE, DOMAIN, SITE, etc) +# * F and K lines +# +#------------------------------------------------------------------------ +# +# Package/Module declaration +package Parse_mc; +require Exporter; +@ISA = qw(Exporter); +#@EXPORT = qw(read_mc write_dbs read_dbs); +@EXPORT_OK = qw(read_mc write_dbs read_dbs + names_dbs restart_dbs entry_dbs); +$VERSION = '2.0002'; +# +# Initialization of the perl environment +use strict; # be kosher +#use warnings; # Not needed here +use Cwd; # provide cwd() +use Env; # A few environmental references +use integer; # Peformance +use Sys::Hostname; # make sure we have a valid hostname +use Getopt::Long; # parameter handling +use FileHandle; # I/O + +# Version of this program +#($main::MYNAME = $main::0) =~ s|.*/||; +#$main::Author = "Richard Nelson"; +#$main::AuthorMail = "cowboy\@debian.org"; +#$main::Version = '$Revision: 2.00 $ '; +$Parse_mc::program_name = 'Parse_mc.pm'; +$Parse_mc::program_version = '@sm_version@'; +$Parse_mc::program_date = '@sm_date@ @sm_time@ cowboy'; + +my $interp_pgm = "$^X"; +my $interp_vrm = $]; +$interp_vrm = ("$^V" | '000') if (defined $^V); +my $current_time = scalar localtime; +my $user = getlogin || (getpwuid($<))[$[] || "Unknown!!"; +my $hostname = hostname(); +my $directory = getcwd(); + +$Parse_mc::input_files = "@sysconfdir@/mail/sendmail.mc"; +$Parse_mc::database_file = "@sysconfdir@/mail/databases"; + +my $debug; + +# +# List of FEATURE()s, and their default file names (in path ${smdb_loc}) +my %smdb_features = ( + access_db => 'access' + ,authinfo => 'authinfo' + ,bitdomain => 'bitdomain' + ,domaintable => 'domaintable' + ,genericstable => 'genericstable' + ,mailertable => 'mailertable' + ,use_cw_file => 'use_cw_file' + ,use_ct_file => 'use_ct_file' + ,uucpdomain => 'uudomain' + ,virtusertable => 'virtusertable' + ); + +# List of classes, and a flag to note if it is reasonable to parse it +my %smdb_classes = ( + '' => 1 # Default, no class + ,'-' => 1 # ditto + ,bestmx => 0 # Lookup best MX record for host + ,btree => 1 # NEWDB + ,dbm => 1 # NDBM + ,dequote => 0 # Remove quotes + ,dnsmap => 0 # DNSMAP + ,hash => 1 # NEWDB + ,hesiod => 1 # HESIOD + ,host => 0 # Internal hostname lookup + ,implicit => 0 # Search for alias database + ,ldap => 0 # LDAPMAP + ,nis => 1 # NIS + ,nisplus => 1 # NISPLUS + ,null => 0 # Always returns false + ,program => 1 # Run an external program + ,sequence => 0 # Search a series of maps + ,stab => 0 # Internal alias + ,switch => 0 # Internal alias auto-build + ,text => 1 # Lookup in flat text file + ,userdb => 1 # Lookup in userdb + ,user => 1 # lookup passwd + ,newaliases => 1 # for internal usage (of this script) + ); + +# +#------------------------------------------------------------------------------ +# Prefill entries based upon Sendmail/Debian defaults +# Yeah, this is long winded, but it needs to be said... +#------------------------------------------------------------------------------ +my $smdb_loc = "@sysconfdir@/mail/"; +my $smdb_type = 'hash'; +my %smdb_hash = ( + 'MAIL_SETTINGS_DIR' => + ['-','-',["${smdb_loc}"],'-'] + ,'DATABASE_MAP_TYPE' => + ["${smdb_type}",'-',['-'],'-'] + ,'sendmail.cf' => + ['m4','-',["${smdb_loc}sendmail.mc"],'-'] + + ,'ALIAS_FILE' => + ['newaliases','-',["${smdb_loc}aliases"],'-'] +# ,'CANONIFY_DOMAIN_FILE' => +# ['-','-',["${smdb_loc}canonify_domains"],'%[^\\#]'] +# ,'EXPOSED_USER_FILE' => +# ['-','-',["${smdb_loc}exposed_users"],'%[^\\#]'] + ,'HELP_FILE' => + ['-','-',["${smdb_loc}helpfile"],'-'] +# ,'GENERICS_DOMAIN_FILE' => +# ['-','-',["${smdb_loc}generic-domains"],'%[^\\#]'] +# ,'MASQUERADE_DOMAIN_FILE' => +# ['-,'-',["${smdb_loc}masquerade-domains"],'%[^\\#]'] + ,'MSP_STATUS_FILE' => + ['-','-',["@localstatedir@/lib/sendmail/sm-client.st"],'-'] + ,'MSP_QUEUE_DIR' => + ['-','-',["@localstatedir@/spool/mqueue-client"],'-'] + ,'QUEUE_DIR' => + ['-','-',["@localstatedir@/spool/mqueue"],'-'] +# ,'RELAY_DOMAIN_FILE' => +# ['-','-',["${smdb_loc}relay-domains"],'%[^\\#]'] + ,'STATUS_FILE' => + ['-','-',["@localstatedir@/lib/sendmail/sendmail.st"],'-'] +# ,'VIRTUSER_DOMAIN_FILE' => +# ['-','-',["${smdb_loc}virtual-domains"],'%[^\\#]'] + + ,'confCONTROL_SOCKET_NAME' => + ['-','-',["@localstatedir@/run/sendmail/smcontrol"],'-'] + ,'confCR_FILE' => + ['-','-o',["${smdb_loc}relay-domains"],'%[^\\#]'] + ,'confCT_FILE' => + ['-','-',["${smdb_loc}trusted-users"],'%[^\\#]'] + ,'confCW_FILE' => + ['-','-',["${smdb_loc}local-host-names"],'%[^\\#]'] + ,'confDEAD_LETTER_DROP' => + ['-','-',["@localstatedir@/lib/sendmail/dead.letter"],'-'] +# ,'confDEF_AUTH_INFO' => # Deprecated, use authinfo rules instead +# ['-','-',["${smdb_loc}default-auth-info"],'-'] + ,'confEBINDIR' => + ['-','-',["@libexecdir@"],'-'] +# ,'confERROR_MESSAGE' => # No default +# ['-','-',["${smdb_loc}error-header"],'-'] + ,'confHOSTS_FILE' => + ['-','-',["@sysconfdir@/hosts"],'-'] + ,'confHOST_STATUS_DIRECTORY' => + ['-','-',["@localstatedir@/lib/sendmail/host_status"],'-'] + ,'confPID_FILE' => + ['-','-',["@localstatedir@/run/sendmail/mta/sendmail.pid"],'-'] + ,'confSERVICE_SWITCH_FILE' => + ['-','-',["${smdb_loc}service.switch"],'-'] +# ,'confUSERDB_SPEC' => +# ['btree','-o',["${smdb_loc}userdb"],'-'] + ); +# +# +# Private entries +$smdb_hash{'databases'} = ['parse_mc','-',["${smdb_loc}sendmail.mc"],'-']; +$smdb_hash{'Makefile'} = ['update_mk','-',["${smdb_loc}databases"],'-']; +$smdb_hash{'crontab'} = ['update_conf','-',["${smdb_loc}sendmail.conf"],'-']; +# +# Conditional entries +if ( -s "${smdb_loc}submit.mc" ) { + $smdb_hash{'submit.cf'} = ['m4','-',["${smdb_loc}submit.mc"],'-']; + }; + +# +# Databases/files that require a sendmail restart when modified: +my %smdb_restart = ( + 'EXPOSED_USER_FILE' => 1 + ,'LOCAL_USER_FILE' => 1 + ,'CANONIFY_DOMAIN_FILE' => 1 + ,'GENERICS_DOMAIN_FILE' => 1 + ,'RELAY_DOMAIN_FILE' => 1 + ,'VIRTUSER_DOMAIN_FILE' => 1 + ,'LDAPROUTE_DOMAIN_FILE' => 1 + ,'LDAPROUTE_EQUIVALENT_FILE' => 1 + ,'MASQUERADE_DOMAIN_FILE' => 1 + ,'MASQUERADE_EXCEPTION_FILE' => 1 + ,'confCR_FILE' => 1 + ,'use_ct_file' => 1 + ,'use_cw_file' => 1 + ); + +$smdb_restart{'sendmail.cf'} = 1; +if ( -s "${smdb_loc}submit.mc" ) { + $smdb_restart{'submit.cf'} = 1; }; + +# Variables used in parsing lines +my $smdb_state_looking = 0; +my $smdb_state_start = 1; +my $smdb_state_done = 2; +my $smdb_state = $smdb_state_looking; +my $smdb_string = ''; +my @smdb_entry = (); +my $smdb_name = ''; +my $smdb_class = ''; +my @smdb_file = (); +my $smdb_flags = ''; +my $smdb_options = ''; +my $smdb_default = ''; + +#------------------------------------------------------------------------------ +# Finally, some code (almost) +#------------------------------------------------------------------------------ +1; # return (true); + +# +#------------------------------------------------------------------------------ +# Read *.mc/*.m4 files +#------------------------------------------------------------------------------ +sub read_mc { + my ($input_files) = @_; + @ARGV = split(' ', $input_files); + if ($#ARGV == -1) { + my @files = ( + '/usr/share/sendmail/cf/ostype/linux.m4' + ,'/usr/share/sendmail/cf/ostype/debian.m4' + ,'/usr/share/sendmail/cf/domain/debian-mta.m4' + ,"@sysconfdir@/mail/sendmail.mc" + ); + foreach my $file ( @files ) { + push @ARGV, $file if ( -s $file ); + }; + }; + $input_files = join(' ', @ARGV); + $Parse_mc::input_files = $input_files; + die "No input files" if ($#ARGV == -1); + $debug = $main::debug || ''; + + #------------------------------------------------------------------ + # Main loop, iterate over all input lines + #------------------------------------------------------------------ + line: while (<ARGV>) { + next line if /^#/; # skip comments + next line if /^$/; # skip empty lines + chomp; # drop tailing \n + if (s/\\$//) { + $_ .= <>; + redo unless eof(); + }; + + #-------------------------------------------------------------- + # Look for default database location + # define(MAIL_SETTINGS_DIR, @sysconfdir@/mail/)dnl # comment + #-------------------------------------------------------------- + if (/^\s*`?define\(\s*`?MAIL_SETTINGS_DIR/ .. + /[^\)]*\)/) { + &parse_string($_, 'define'); + next line if ($smdb_state != $smdb_state_done); + + &get_flags_name_opts; + $smdb_loc = $smdb_file[$[]; + $smdb_class = '-'; + + &put_entry($ARGV, 'define'); + } + + #-------------------------------------------------------------- + # Look for default database type + # define(DATABASE_MAP_TYPE, hash)dnl # comment + #-------------------------------------------------------------- + elsif (/^\s*define\(\s*`?DATABASE_MAP_TYPE/ .. + /[^\)]*\)/) { + &parse_string($_, 'define'); + next line if ($smdb_state != $smdb_state_done); + + &get_flags_name_opts; + $smdb_type = $smdb_file[$[]; + @smdb_file = ( $smdb_loc ); + $smdb_class = $smdb_type; + + &put_entry($ARGV, 'define'); + } + + # + #-------------------------------------------------------------- + # Look for define(confUSERDB specifications + # define(confUSERDB_SPEC, @sysconfdir@/mail/users.db)dnl # comment + #-------------------------------------------------------------- + elsif (/^\s*`?define\(\s*`?confUSERDB_SPEC/ .. + /[^\)]*\)/) { + &parse_string($_, 'define'); + next line if ($smdb_state != $smdb_state_done); + + &get_flags_name_opts; + $smdb_flags = '-o'; + $smdb_class = 'btree'; + + &put_entry($ARGV, 'define'); + } + + #-------------------------------------------------------------- + # Look for all define(confC._FILE specifications + # define(confCR_FILE, -o /etc/mail/relay-domains %[^\#])dnl + # define(confCT_FILE, -o /etc/mail/sendmail.ct %[^\#])dnl + # define(confCW_FILE, -o /etc/mail/sendmail.cw %[^\#])dnl + #-------------------------------------------------------------- + elsif (/^\s*`?define\(\s*`?confC[RTW]_FILE/ .. + /[^\)]*\)/) { + &parse_string($_, 'define'); + next line if ($smdb_state != $smdb_state_done); + + &get_flags_name_opts; + + &put_entry($ARGV, 'define'); + } + + #-------------------------------------------------------------- + # Look for all *_FILE( specifications + # EXPOSED_USER_FILE(/etc/mail/exposed-users %[^\#])dnl + # LOCAL_USER_FILE + # CANONIFY_DOMAIN_FILE + # GENERICS_DOMAIN_FILE(/etc/mail/generic-domains %[^\#])dnl + # RELAY_DOMAIN_FILE(/etc/mail/relay-domains %[^\#])dnl + # VIRTUSER_DOMAIN_FILE(/etc/mail/virtual-domains %[^\#])dnl + # LDAPROUTE_DOMAIN_FILE + # LDAPROUTE_EQUIVALENT_FILE + # MASQUERADE_DOMAIN_FILE(/etc/mail/masquerade-domains %[^\#])dnl + # MASQUERADE_EXCEPTION_FILE + #-------------------------------------------------------------- + elsif (/^\s*`?((EXPOSED|LOCAL)_USER|(CANONIFY|GENERICS|RELAY|VIRTUSER)_DOMAIN|LDAPROUTE_(DOMAIN|EQUIVALENT)|MASQUERADE_(DOMAIN|EXCEPTION))_FILE\(/ .. + /[^\)]*\)/) { + &parse_string($_, '('); + next line if ($smdb_state != $smdb_state_done); + + &get_flags_name_opts; + + &put_entry($ARGV, ''); + } + + # + #-------------------------------------------------------------- + # Look for all define(conf* specifications + # define(confCONTROL_SOCKET_NAME,/var/run/sendmail/smcontrol)dnl + # define(confERROR_MESSAGE, MAIL_SETTINGS_DIRerror-header)dnl + # define(confSERVICE_SWITCH_FILE,/etc/mail/service.switch)dnl + # define(confPID_FILE, /var/run/sendmail/sendmail.pid)dnl + # define(confHOSTS_FILE, /etc/hosts)dnl + # define(confDEF_AUTH_INFO, /etc/mail/auth-info)dnl + # define(confDEAD_LETTER_DROP,/var/lib/sendmail/dead.letter)dnl + # define(confHOST_STATUS_DIRECTORY,/var/lib/sendmail/host_status)dnl + #-------------------------------------------------------------- + elsif (/^\s*`?define\(\s*`?conf(CONTROL_SOCKET_NAME|ERROR_MESSAGE|(SERVICE_SWITCH|PID|HOSTS)_FILE|DEF_AUTH_INFO|DEAD_LETTER_DROP|HOST_STATUS_DIRECTORY)/ .. + /[^\)]*\)/) { + &parse_string($_, 'define'); + next line if ($smdb_state != $smdb_state_done); + + &get_flags_name_opts; + + &put_entry($ARGV, 'define'); + } + + #-------------------------------------------------------------- + # Look for all define(*_FILE specifications (No options here) + # define(ALIAS_FILE, @sysconfdir@/mail/aliases.private,...)dnl + # define(HELP_FILE, /etc/mail/helpfile)dnl + # define(STATUS_FILE, /var/lib/sendmail/sendmail.st)dnl + # define(QUEUE_DIR, /var/spool/mqueue/main*)dnl + # define(MSP_QUEUE_DIR, /var/spool/mqueue-client)dnl + #-------------------------------------------------------------- + elsif (/^\s*`?define\(\s*`?((ALIAS|HELP|STATUS)_FILE)|(MSP_)?QUEUE_DIR/ .. + /[^\)]*\)/) { + &parse_string($_, 'define'); + next line if ($smdb_state != $smdb_state_done); + + &get_flags_name_opts; + + &put_entry($ARGV, 'define'); + } + + #-------------------------------------------------------------- + # Look for all queue definition specifications + # define(QUEUE_GROUP, ...)dnl + #-------------------------------------------------------------- + elsif (/^\s*`?QUEUE_GROUP\(/ .. /[^\)]*\)/) { + &parse_string($_, '('); + next line if ($smdb_state != $smdb_state_done); + + $smdb_string =~ /\s*([\w_]+).*P[^=]*=([^\*,\)]*).*/; + $smdb_name = 'QUEUE_GROUP'; + $smdb_class = '-'; # $1 + $smdb_flags = '-'; + @smdb_file = ($2); + $smdb_options = '-'; # Pull out other options? + + &put_entry($ARGV, '', 1); + } + + # + #-------------------------------------------------------------- + # Locate all non-commented FEATURE macros + # FEATURE(name[, [type [flags] file][, ...]...])dnl #comment + #-------------------------------------------------------------- + elsif (/^\s*`?FEATURE\(/ .. /[^\)]*\)/) { + &parse_string($_, 'FEATURE'); + next line if ($smdb_state != $smdb_state_done); + + # ignore non-db features + next line if ( ! exists($smdb_features{$smdb_name}) ); + + &get_flags_name_opts; + + if ($smdb_name eq 'use_ct_file') { + &get_entry('confCT_FILE'); + } + elsif ($smdb_name eq 'use_cw_file') { + &get_entry('confCW_FILE'); + } + else { + @smdb_file = + ("${smdb_loc}$smdb_features{$smdb_name}") + if ($smdb_file[$[] eq '-' + and $smdb_class ne 'ldap'); + $smdb_class = $smdb_type + if ($smdb_class eq '-'); + }; + + &put_entry($ARGV, 'FEATURE'); + }; + }; + }; + +# +#------------------------------------------------------------------------------ +# Write out the accumulated information to a flat database file +#------------------------------------------------------------------------------ +sub write_dbs { + my ($database_file, $input_files) = @_; + my $ofh = new FileHandle; + + $database_file = $database_file || $Parse_mc::database_file; + $Parse_mc::database_file = $database_file; + my $caller = "$main::program_name" if ($main::program_name); + $caller .= " $main::program_version" if ($main::program_version); + $caller .= " $main::program_date" if ($main::program_date); + $debug = $main::debug || ''; + + $database_file = '&STDOUT' if ($database_file eq '-'); + unless ( open($ofh, ">$database_file") ) { + warn("Could not open $database_file($!), using STDOUT.\n"); + open($ofh, ">&STDOUT"); + }; + $database_file = '-' if ($database_file eq '&STDOUT'); + + print $ofh <<"EOT"; +#################################################################### +##### This file is automatically generated -- edit at your own risk +##### +##### Copyright (c) 2000-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +##### +##### file: ${database_file} +##### generated via: (${interp_pgm} ${interp_vrm}) +##### ${caller} +##### ${Parse_mc::program_name} ${Parse_mc::program_version} ${Parse_mc::program_date} +##### by: ${user}\@${hostname} +##### on: ${current_time} +##### in: ${directory} +##### input files: +EOT + foreach my $file ( split(' ', $Parse_mc::input_files) ) { + print $ofh <<"EOT"; +##### ${file} +EOT + } + print $ofh <<"EOT"; +##### +##### Used by: +##### update_{db,mk} +##### +##### The following databases are used by Debian Sendmail +##### +##### Format: +##### <df>:<map>:<flags>:<file>:<opts>: +##### Where: +##### <df> = define or FEATURE name +##### <map> = map type (-,text,btree,hash, etc.) +##### <flags> = map flags (-o for optional, etc.) +##### <file> = file name +##### <opts> = map options (%[^\\#] for sprintf, etc.) +##### +#################################################################### +EOT + + # + # delete unneeded elements + #delete $smdb_hash{"MAIL_SETTINGS_DIR"}; + #delete $smdb_hash{"DATABASE_MAP_TYPE"}; + #delete $smdb_hash{"confCT_FILE"}; + #delete $smdb_hash{"confCW_FILE"}; + + # print define(/FEATURE(/xxx( items + foreach $smdb_name (sort keys %smdb_hash) { + &get_entry($smdb_name); + foreach my $file ( @smdb_file ) { + print $ofh join(':', + $smdb_name + ,$smdb_class + ,$smdb_flags + ,$file + ,$smdb_options + ,'' + ), "\n"; + }; + }; + + close($ofh); + if ($database_file eq "@sysconfdir@/mail/databases") { + chown '0', '0', "$database_file"; + chmod 0644, "$database_file"; + }; + }; + +# +#------------------------------------------------------------------------------ +# Read in the accumulated information from a flat database file +#------------------------------------------------------------------------------ +sub read_dbs { + my ($database_file, $input_files) = @_; + my $ifh = new FileHandle; + my $name = ''; + my @entry; + + $database_file = $database_file || $Parse_mc::database_file; + $Parse_mc::database_file = $database_file; + $debug = $main::debug || ''; + + unless ( open($ifh, "<$database_file") ) { + warn("Could not open $database_file($!), creating it.\n"); + &read_mc($input_files); + &write_dbs($database_file, $input_files); + # At this point, we have the data, don't need to re-read it... + return; + }; + + #------------------------------------------------------------------ + # Main loop, iterate over all input lines + #------------------------------------------------------------------ + line: while (<$ifh>) { + next line if /^#/; # skip comments + next line if /^$/; # skip empty lines + chomp; # drop tailing \n + + @entry = split(':', $_); + + # Accumulate file names and enter when complete + if ($name eq $entry[$[]) { + push @smdb_file, $entry[3]; + } + else { + if ($name ne '') { + &put_entry('', ''); + }; + $name = $entry[$[]; + $smdb_name = $entry[$[]; + $smdb_class = $entry[1]; + $smdb_flags = $entry[2]; + @smdb_file = $entry[3]; + $smdb_options = $entry[4]; + }; + }; + + # enter any remaining data + if ($name ne '') { + &put_entry('', ''); + }; + + close($ifh); + }; + +# +#------------------------------------------------------------------------------ +# Obtain the list of names in smdb_hash (in an ordered manor) +#------------------------------------------------------------------------------ +sub names_dbs { + + # We need a partial ordering here (psuedo dependancies) + my @names; + my %dbs = (); + foreach my $entry ('databases', 'Makefile', 'crontab', 'QUEUE_GROUP', + 'sendmail.cf', 'submit.cf') { + if (exists($smdb_hash{$entry})) { + $dbs{$entry} = ''; + push @names, $entry; + }; + }; + + # Now, add any remaining databases to the list (except aliases) + foreach my $entry (sort keys %smdb_hash) { + next if ($entry eq 'ALIAS_FILE'); + push @names, $entry + if (! exists($dbs{$entry})); + $dbs{$entry} = ''; + }; + + # Finally, add aliases... + my $entry = 'ALIAS_FILE'; + if (exists($smdb_hash{$entry})) { + push @names, $entry + if (! exists($dbs{$entry})); + $dbs{$entry} = ''; + }; + + return(@names); + }; + +#------------------------------------------------------------------------------ +# Obtain the list of names that require a sendmail restart +#------------------------------------------------------------------------------ +sub restart_dbs { + return(keys %smdb_restart); + }; + +#------------------------------------------------------------------------------ +# Obtain an individual database entry (returning a copy) +#------------------------------------------------------------------------------ +sub entry_dbs { + my ($name) = @_; + $smdb_name = $name; + &get_entry($smdb_name); + + # Return a local copy - so they can't change *MY* data... + my @entry = @smdb_entry; + return (@entry); + }; + +# +#------------------------------------------------------------------------------ +# Save the results of the database entry and reset the state +#------------------------------------------------------------------------------ +sub put_entry { + my ($file, $type, $multi_file) = @_; + + # Create entry record from data pieces/parts + if ($multi_file and exists($smdb_hash{$smdb_name})) { + @smdb_entry = @{$smdb_hash{$smdb_name}}; + } + else { + @smdb_entry = ('-', '-', [], '-'); + }; + $smdb_entry[$[] = $smdb_class; + $smdb_entry[1] = $smdb_flags; + push @{$smdb_entry[2]}, @smdb_file; + $smdb_entry[3] = $smdb_options; + + # Save lastmost entry + @{$smdb_hash{$smdb_name}} = @smdb_entry; + + # Minimal debugging + if ($debug) { + print STDERR "PUT: "; + if ($type ne '') { print STDERR "$type($smdb_name)" } + else { print STDERR "$smdb_name()" }; + print STDERR " => ", join(':' + , $smdb_class + , join(',', @{$smdb_entry[2]}) + , $smdb_options + , '' + ), "\n"; + }; + + # reset state + $smdb_state = $smdb_state_looking; + }; + +# +#------------------------------------------------------------------------------ +# Retrieve a database entry +#------------------------------------------------------------------------------ +sub get_entry { + my ($name) = @_; + + if (exists($smdb_hash{$name}) ) { + @smdb_entry = @{$smdb_hash{$name}}; + } + else { + @smdb_entry = ('-', '-', ['-'], '-'); + }; + + $smdb_class = $smdb_entry[$[]; + $smdb_flags = $smdb_entry[1]; + @smdb_file = @{$smdb_entry[2]}; + $smdb_options = $smdb_entry[3]; + + # Minimal debugging + if ($debug) { + print STDERR "GET: ", + "$name", + " => ", join(':' + , $smdb_class + , join(',', @{$smdb_entry[2]}) + , $smdb_options + , '' + ), "\n"; + }; + + }; + +# +#------------------------------------------------------------------------------ +# This function does most of the work in parsing a series of lines to +# construct a database entry - it manages the state machine and assorted +# global variables +#------------------------------------------------------------------------------ +sub parse_string { + my ($str, $type) = @_; + my $count = -1; + my @entry = ''; + my $pending_state = 0; + + # Strip trailing '?\)(dnl)?.*$ from string + if ($str =~ /\s*'?\s*\)/) { + $str =~ s/\s*'?\s*\)\s*(dnl)?.*$//; + $pending_state = $smdb_state_done; + }; + + # Strip trailing 'dnl .*' from string + if ($str =~ /dnl(\s+.*)?$/) { + $str =~ s/dnl(\s+.*)?$//; + }; + + # Strip leading `?define\(\s*`? from string + if (($type eq 'define') and + ($str =~ /^\s*`?define\(/)) { + $str =~ s/^\s*`?define\(\s*`?//; + $str =~ s/,/ /; + $smdb_state = $pending_state || $smdb_state_start; + $smdb_string = ''; + $count = (@entry = split(' ', $str)); + ($smdb_name = $entry[$[]) =~ tr/'//d; + shift(@entry); + $str = join(' ', @entry); + } + + # Strip leading `?FEATURE\(\s*`? from string + elsif (($type eq 'FEATURE') and + ($str =~ /^\s*`?FEATURE\(/)) { + $str =~ s/^\s*`?FEATURE\(\s*`?//; + $str =~ s/,/ /; + $smdb_state = $pending_state || $smdb_state_start; + $smdb_string = ''; + $count = (@entry = split(' ', $str)); + ($smdb_name = $entry[$[]) =~ tr/'//d; + shift(@entry); + $str = join(' ', @entry); + } + + # Strip leading `?[\w_]+\(\s*`? from string + elsif (($type eq '(') and + ($str =~ /^\s*`?[\w_]+\(/)) { + $str =~ s/\(/ /; + $smdb_state = $pending_state || $smdb_state_start; + $smdb_string = ''; + $count = (@entry = split(' ', $str)); + ($smdb_name = $entry[$[]) =~ tr/'//d; + shift(@entry); + $str = join(' ', @entry); + } + else { + $smdb_state = $pending_state || $smdb_state; + }; + + # + # Strip quotes (` and ') from string + $str =~ tr/`'//d; + + # FEATURE( is the only one allowed to have only one argument + if ($type ne 'FEATURE' and $count == 1) { + $str = ''; + }; + + # Change imbedded MAIL_SETTINGS_DIR to $smdb_loc + if ($smdb_name ne 'MAIL_SETTINGS_DIR') { + $str =~ s/MAIL_SETTINGS_DIR/$smdb_loc/g + }; + + # Change imbedded DATABASE_MAP_TYPE to $smdb_type + if ($smdb_name ne 'DATABASE_MAP_TYPE') { + $str =~ s/DATABASE_MAP_TYPE/$smdb_type/g + }; + + # concatentate this string with any prior information + $smdb_string .= ' ' . $str unless($smdb_state == $smdb_state_looking); + + # Return + return; + }; + +# +#------------------------------------------------------------------------------ +# This function parses a line into flags (-o, etc.), name, options +#------------------------------------------------------------------------------ +sub get_flags_name_opts { + my @entry; + my $class = ''; + my $rest = ''; + my $multi_names = 0; + + $smdb_class = ''; + $smdb_flags = ''; + @smdb_file = (); + $smdb_options = ''; + + @entry = split(' ', $smdb_string); + + # Pull off any leading flags (including database type/class) + # Class specification: "[mapkey]@mapclass:mapspec" + # RELAY_DOMAIN_FILE(`@LDAP')dnl + # VIRTUSER_DOMAIN_FILE(`@ldap:-k + # (&(objectClass=virtHosts)(host=*)) -v host')dnl + # FEATURE(`genericstable', `LDAP')dnl + # FEATURE(`genericstable', `nis:realnames.by2mail')dnl + # define(`ALIAS_FILE', `ldap:')dnl + # define(`ALIAS_FILE', `ldap:-k + # (&(objectClass=mailGroup)(mail=%0)) -v mgrpRFC822MailMember')dnl + # but only if there are flags *and* a name... + if (@entry) { + ($class = lc($entry[$[])) =~ s/:.*//; + ($rest = $entry[$[]) =~ s/.*://; + $rest = '' if (lc($rest) eq 'ldap'); + if ($class =~ /^.*@/) { + $class =~ s/^.*@//; + if (exists($smdb_classes{$class})) { + $smdb_class = $class; + shift (@entry); + }; + } + elsif (exists($smdb_classes{$class})) { + $smdb_class = $class; + $rest = '' if ($rest eq $class); + shift (@entry); + @entry = split(' ', join(' ',$rest,@entry) ); + $#entry = -1 if ($smdb_class eq 'ldap'); + }; + FLAG_LOOP: while (@entry) { + if (substr($entry[$[], 0, 1) eq '-') { + if ($smdb_flags eq '') { + $smdb_flags = $entry[$[]; + } + else { + $smdb_flags .= ' ' . $entry[$[]; + }; + shift (@entry); + } + else { + last FLAG_LOOP; + }; + }; + }; +#print STDERR "$class($rest) ::= ",scalar @entry,join(' ','',@entry,''),"\n"; + $smdb_flags = $smdb_flags || '-'; + $smdb_class = $smdb_class || '-'; + + # + # A few special cases... + if ($smdb_name eq 'ALIAS_FILE' and $smdb_class eq '-') { + $smdb_class = 'newaliases'; + @entry = (join('',@entry)); + $multi_names = 1; + } + elsif ($smdb_name eq 'confUSERDB_SPEC') { + @entry = (join('',@entry)); + $multi_names = 1; + }; + + # Handle multi-files specially + if ( $multi_names == 1 ) { + @smdb_file = split(',', $entry[$[]); + $smdb_options = '-'; + } + else { + # Whats left should be a filename (or somesuch) and options + if (@entry >= 1) { # file name, possible options if /,/ + if ($smdb_classes{$smdb_class} != 1) { + @smdb_file = '-'; + } + else { + @smdb_file = $entry[$[]; + shift(@entry); + }; + if (@entry >= 1) { + $entry[$[] =~ s/^,//; + foreach my $ndx ($[ .. $#entry) { + $smdb_options .= ' ' + if ($ndx != 0 + and substr($entry[$ndx], 0, 1) ne ','); + $smdb_options .= $entry[$ndx]; + } + } + $#entry = -1; + }; + + # Check for possible options caught in the filename slot + if (@smdb_file >= 1 and index($smdb_file[$[], ',') != -1) { + @entry = split(/,/, $smdb_file[$[]); + @smdb_file = ( $entry[$[] ); + if (@entry >= 2) { + $smdb_options = join('', @entry[1..$#entry], + $smdb_options); + $#entry = -1; + }; + }; + $smdb_file[$[] = $smdb_file[$[] || '-'; + $smdb_file[$[] =~ s/\.db//; + $smdb_options = $smdb_options || '-'; + }; + + # Return + return; + }; + +__END__ diff --git a/debian/local/configure b/debian/local/configure deleted file mode 100644 index 648e260..0000000 --- a/debian/local/configure +++ /dev/null @@ -1,903 +0,0 @@ -#! /bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=configure.in - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -# -# Check for presence if NISPLUS headers -# -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:530: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 545 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:551: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 562 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:568: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext <<EOF -#line 579 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:585: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - -for ac_hdr in rpcsvc/nis.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:613: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 618 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:623: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi -done - - - -# Fini - update site.config.m4 for sendmail build -trap '' 1 2 15 -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -cat > conftest.defs <<\EOF -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g -s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g -s%\[%\\&%g -s%\]%\\&%g -s%\$%$$%g -EOF -DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` -rm -f conftest.defs - - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#! /bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir - -trap 'rm -fr `echo "site.config.m4" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS <<EOF - -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@CPP@%$CPP%g -s%@ac_cv_header_rpcsvc_nis_h@%$ac_cv_header_rpcsvc_nis_h%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <<EOF - -CONFIG_FILES=\${CONFIG_FILES-"site.config.m4"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -EOF -cat >> $CONFIG_STATUS <<EOF - -EOF -cat >> $CONFIG_STATUS <<\EOF - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - diff --git a/debian/local/configure.in b/debian/local/configure.in deleted file mode 100644 index 7099c2b..0000000 --- a/debian/local/configure.in +++ /dev/null @@ -1,10 +0,0 @@ -AC_INIT(configure.in) - -# -# Check for presence if NISPLUS headers -# -AC_CHECK_HEADERS(rpcsvc/nis.h) -AC_SUBST(ac_cv_header_rpcsvc_nis_h) - -# Fini - update site.config.m4 for sendmail build -AC_OUTPUT(site.config.m4) diff --git a/debian/local/el33t.h b/debian/local/el33t.h deleted file mode 100644 index ce7bf94..0000000 --- a/debian/local/el33t.h +++ /dev/null @@ -1,6 +0,0 @@ -#define _FFR_DSN_RRT_OPTION 1 -#define _FFR_PIDFILE_OPTION 1 -#define _FFR_WRITABLE_DIRECTORIES_ARE_FATAL_OPTION 1 -#define _FFR_DONT_PROBE_INTERFACES_OPTION 1 -#define _FFR_MAXRCPT_OPTION 1 -#define _FFR_DEADLETTERDROP_OPTION 1 diff --git a/debian/local/ip-down.d b/debian/local/ip-down.d deleted file mode 100644 index 1881437..0000000 --- a/debian/local/ip-down.d +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# -# This script is called when ppp disconnects from the network. -# -# Here is where we'll stop sendmail if needed -# -# Written By Richard Nelson <cowboy@debian.org> -# -# NOTE: The following lines (without the #) must be in /etc/mail/sendmail.mc: -# include(`/etc/mail/dialup.m4')dnl -# include(`/etc/mail/provider.m4')dnl -# -# Exit by default, check for validity before commenting out the next line: -exit 0 - -# New mail will only be queued -file="/etc/mail/dialup.m4" -if [ -f "$file" ]; then - echo "LOCAL_CONFIG" >> $file - echo "#------------------------------------------------------------" >> $file - echo "#" > $file - echo "# Dynamic updates from $0" >> $file - echo "#" >> $file - echo "# sendmail is to only queue messages until connected again" >> $file - echo "define(\`confDELIVERY_MODE', \`deferred')dnl" >> $file - echo "# Allow the queue to age without carping every four hours" >> $file - echo "define(\`confTO_QUEUEWARN',\`1d')dnl" >> $file - echo "# Don't keep host status while the network is down" >> $file - echo "define(\`confHOST_STATUS_DIRECTORY')dnl" >> $file - echo "#------------------------------------------------------------" >> $file - fi - -# Build a new sendmail.cf from sendmail.mc, including our address. -# NOTE: The following line (without the #) must be in /etc/mail/sendmail.mc: -# include(`/etc/mail/dialup.m4') -m4 /usr/share/sendmail/sendmail.cf/m4/cf.m4 /etc/mail/sendmail.mc \ - >/etc/mail/sendmail.cf.pnew -chmod 0640 /etc/mail/sendmail.cf.pnew -chown root.mail /etc/mail/sendmail.cf.pnew -mv -f /etc/mail/sendmail.cf.pnew /etc/mail/sendmail.cf - -# Stop/reload sendmail daemon as needed -/etc/init.d/sendmail reload diff --git a/debian/local/ip-up.d b/debian/local/ip-up.d deleted file mode 100644 index 9053a4e..0000000 --- a/debian/local/ip-up.d +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh -# -# This script is called when ppp connects to the network. -# -# Here is where we'll start sendmail if needed, and will -# run the queue in either case. -# -# Written By Richard Nelson <cowboy@debian.org> -# -# NOTE: The following lines (without the #) must be in /etc/mail/sendmail.mc: -# include(`/etc/mail/dialup.m4')dnl -# include(`/etc/mail/provider.m4')dnl -# -# ALSO: make sure ipparam is specified somewhere in the ppp options; -# it will be used as the name of a file in /etc/mail/peers -# -# Exit by default, check for validity before commenting out the next line: -exit 0 - -# Define our domain name (from PPP) for sendmail. - -# These variables are for the use of the scripts run by run-parts -#PPP_IFACE="$1" -#PPP_TTY="$2" -#PPP_SPEED="$3" -#PPP_LOCAL="$4" -#PPP_REMOTE="$5" -#PPP_IPPARAM="$6" - -if [ ! -z "$PPP_LOCAL" ]; then - addr=$PPP_LOCAL - provider=$PPP_IPPARAM -else - addr=$1 - provider=$2 - fi - -# Determine our fqdn from our ISP -maxloop=20 -cntr=0 -name="" -until (test ! -z "$name"); do - cntr=$(($cntr+1)) - name=$(nslookup $addr | grep '^Name:' | awk '{print $2}') - test=$(echo $name | cut -d ' ' -f 1) - if [ "$name" != "**" ]; then - break - elif (($cntr > $maxloop)); then - name="" - break - fi - done - -if [ ! -z "$name" ]; then - file="/etc/mail/dialup.m4" - echo "LOCAL_CONFIG" >> $file - echo "#------------------------------------------------------------" >> $file - echo "#" > $file - echo "# Dynamic updates from $0" >> $file - echo "#" >> $file - echo "# Define our true hostname (from our ISP) becomes \$j" >> $file - echo "define(\`confDOMAIN_NAME', \`$name')dnl" >> $file - echo "# Make sure we accept mail as this name (for bounces, etc)" >> $file - echo "Cw$name" >> $file - echo "# Add our hostname to class G for genericstable support" >> $file - echo "CG$name" >> $file - echo "#------------------------------------------------------------" >> $file - fi - -# Add smarthost information (if any)... But not if provider.m4 is a link ! -if [ -f /etc/mail/peers/$provider -a ! -L /etc/mail/provider.m4 ]; then - file="/etc/mail/provider.m4" - echo "LOCAL_CONFIG" >> $file - echo "#------------------------------------------------------------" >> $file - echo "#" > $file - echo "# Dynamic updates from $0" >> $file - echo "#" >> $file - echo "# Provider information from /etc/mail/peers/$provider" >> $file - cat /etc/mail/peers/$provider >> $file - echo "#------------------------------------------------------------" >> $file - fi - -# Build a new sendmail.cf from sendmail.mc, including our address. -# NOTE: The following lines (without the #) must be in /etc/mail/sendmail.mc: -# include(`/etc/mail/dialup.m4')dnl -# include(`/etc/mail/provider.m4')dnl -m4 /usr/share/sendmail/sendmail.cf/m4/cf.m4 /etc/mail/sendmail.mc \ - >/etc/mail/sendmail.cf.pnew -chmod 0640 /etc/mail/sendmail.cf.pnew -chown root.mail /etc/mail/sendmail.cf.pnew -mv -f /etc/mail/sendmail.cf.pnew /etc/mail/sendmail.cf - -# Purge any latent host status that might cause us to *NOT* send mail -purgestat - -# Start/reload sendmail as needed -/etc/init.d/sendmail reload # may be up, or down - -# Process the sendmail queue (background so as to not defer other ip-up work) -runq & diff --git a/debian/local/local_no_masquerade.m4 b/debian/local/local_no_masquerade.m4 new file mode 100644 index 0000000..5c8a693 --- /dev/null +++ b/debian/local/local_no_masquerade.m4 @@ -0,0 +1,25 @@ +divert(-1) +#----------------------------------------------------------------------------- +# $Sendmail: ./local_no_masquerade,v 8.9.3 1999/10/20 12:00:00 cowboy Exp $ +# +# Copyright (c) 1999-2001 Richard Nelson. All Rights Reserved. +# +# feature(local_no_masquerade) config file for building Sendmail +# +# Prevent masquerading of local senders when sending to local recipients +# used by: mailer/local.m4 +# +# Note: I originally called this `dont_masquerade_local', but have since +# changed the name to correspond with what Sendmail 8.12.0 supports. +# The local patches to cf/mailer/local.m4 remain unaltered. +# +#----------------------------------------------------------------------------- +# +divert(0) +VERSIONID(`@(#)local_no_masquerade.m4 1.0 (Debian) 1999-10-20') +divert(-1) + +ifdef(`_MAILER_local_', + `errprint(`*** FEATURE(local_no_masquerade) must occur before MAILER(local)')')dnl + +define(`_DONT_MASQUERADE_LOCAL_', 1)dnl diff --git a/debian/local/parse_mc.in b/debian/local/parse_mc.in new file mode 100644 index 0000000..569e355 --- /dev/null +++ b/debian/local/parse_mc.in @@ -0,0 +1,86 @@ +#!/usr/bin/perl -w +#------------------------------------------------------------------------ +# +# $Sendmail: parse_mc,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Parse Sendmail config for databases +# +# Copyright 2000-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes (to all): +# * for "define(xxx,...)"; "define(xxx," must be on same line, but the +# rest may be split across multiple lines +# * assumes makemap dbtype /etc/mail/database < /etc/mail/database +# +# Notes (to self): +# * +# +#------------------------------------------------------------------------ +# My first perl program (from my first awk program ;-}) +# +# Initialization of the perl environment +use strict; # be kosher +use Env; # A few environmental references +use integer; # Peformance +use Getopt::Long; # parameter handling + +# Local libraries - for Debian Sendmail Perl helper functions +# BEGIN { $main::my_path = substr($0,$[,rindex($0,'/')) }; +use lib ('.', substr($0,$[,rindex($0,'/')), "@datadir@/sendmail"); +require Parse_mc; + +# Version of this program +#($main::MYNAME = $main::0) =~ s|.*/||; +#$main::Author = "Richard Nelson"; +#$main::AuthorMail = "cowboy\@debian.org"; +#$main::Version = '$Revision: 2.00 $ '; +$main::program_name = $0; +$main::program_version = '@sm_version@'; +$main::program_date = '@sm_date@ @sm_time@ cowboy'; +$main::debug = 0; + +# +#------------------------------------------------------------------------------ +# Finally, some code (almost) +#------------------------------------------------------------------------------ +# +# Argument handling... +$main::opt_help=''; +$main::opt_output_file=''; +$main::opt_input_file=''; +$main::opt_debug=''; +my @options = qw( + help|h + output-file|output_file|o:s + input-file|input_file|i:s@ + debug! + ); +my $result = GetOptions(@options); +if ( ! $result ) { + die "Terminating due to parameter error"; + }; +if ( $main::opt_help ) { + warn "$main::program_name $main::program_version $main::program_date\n"; + warn "$0 \n"; + warn " -help\n" if $main::opt_help; + warn " -debug\n" if $main::opt_debug; + warn " -o $main::opt_output_file\n" if $main::opt_output_file; + warn " -i $main::opt_input_file\n" if $main::opt_input_file; + exit 0; + }; + +${Parse_mc::database_file} = $main::opt_output_file + if $main::opt_output_file; +my $input_files = join(' ', @main::opt_input_file); +# $main::debug is used in parse_mc ! +$main::debug = $main::opt_debug || $main::debug; + +# Let them know wtf is going on... +print STDOUT "Creating ${Parse_mc::database_file}...\n"; + +# Read the mc/m4 files +&Parse_mc::read_mc($input_files); + +# Write out the textual representation +&Parse_mc::write_dbs('', $input_files); + diff --git a/debian/local/parsemc b/debian/local/parsemc deleted file mode 100644 index 81a180e..0000000 --- a/debian/local/parsemc +++ /dev/null @@ -1,608 +0,0 @@ -#!/bin/bash -# -# Parse Sendmail config for databases -# -# Copyright (c) 1999, Richard Nelson <cowboy@debian.org>. -# Time-stamp: <1999/05/19 10:00:00 cowboy> -# -# Notes (to all): -# * assumes makemap dbtype /etc/mail/database < /etc/mail/database -# * Does *not* run with sh=ash (no echo -e support) -# -# Notes (to self): -# * changes made herein *must* be reflected in parsemc,updatedb,debian.m4 -# * remember to change gawk to awk before release (gawk is more anal) -# * multiple db options not supported -# * chmod/chown of secondary alias databases not being done - no harm... -# * userdb can also have multiple databases and then a forward! -# * need sendmail stop/start -# -# List of db features -db_features="access_db bitdomain domaintable genericstable \ - mailertable uucpdomain virtusertable use_cw_file use_ct_file"; -export db_features; -# kluge for userdb, cr, ct, and cw files support -db_files="confCR_FILE confUSERDB_SPEC ALIAS_FILE"; -db_files="sendmail.mc $db_features $db_files"; -export db_files; -# -# Variables for documentation -date=$(date) -export date -user=$USER -export user -hostname=$(hostname) -export hostname -script=$0 -export script -directory=$(pwd) -export directory - -#------------------------------------------------------------------------ -# My first awk program ;-} -pattern='BEGIN { \ - # List of db features, split into an array \ - str = ENVIRON["db_features"]; \ - split(str, db_features); \ - str = ENVIRON["db_files"]; \ - split(str, db_files); \ - # Prefill entries based upon sendmail/debian defaults \ - str = "sendmail.mc m4 - /etc/mail/sendmail.mc -"; \ - split(str, entry); \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - str = "MAIL_SETTINGS_DIR /etc/mail/ - - -"; \ - split(str, entry); \ - db_loc=entry[2]; \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - str = "DATABASE_MAP_TYPE hash - - -"; \ - split(str, entry); \ - db_type=entry[2]; \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - str = "confUSERDB_SPEC btree -o /etc/mail/users -"; \ - split(str, entry); \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - str = "confCR_FILE - -o /etc/mail/relay-domains %[^\#]"; \ - split(str, entry); \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - str = "confCT_FILE - -o /etc/mail/trusted-users %[^\#]"; \ - split(str, entry); \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - str = "confCW_FILE - -o /etc/mail/local-host-names %[^\#]"; \ - split(str, entry); \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - str = "ALIAS_FILE newaliases - /etc/mail/aliases -"; \ - split(str, entry); \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - }; \ - # Look for default database location \ - # define(MAIL_SETTINGS_DIR, /etc/mail/)dnl # comment \ - /^[:space:]*define\([:space:]*`?MAIL_SETTINGS_DIR/ { \ - str = $0; \ - # Strip garbage from string \ - sub(/define\(/, "", str); \ - sub(/\)(dnl)?.*/, "", str); \ - sub(/\,/, "", str); \ - gsub(/`/, "", str); \ - gsub(/'"'"'/, "", str); \ - split(str, entry); \ - entry[5] = "-"; \ - entry[4] = "-"; \ - entry[3] = "-"; \ - db_loc=entry[2]; \ - # Save lastmost entry \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - } \ - # Look for default database type \ - # define(DATABASE_MAP_TYPE, hash)dnl # comment \ - /^[:space:]*define\([:space:]*`?DATABASE_MAP_TYPE/ { \ - str = $0; \ - # Strip garbage from string \ - sub(/define\(/, "", str); \ - sub(/\)(dnl)?.*/, "", str); \ - sub(/\,/, "", str); \ - gsub(/`/, "", str); \ - gsub(/'"'"'/, "", str); \ - split(str, entry); \ - entry[5] = "-"; \ - entry[4] = "-"; \ - entry[3] = "-"; \ - db_type=entry[2]; \ - # Save lastmost entry \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - } \ - # Look for userdb specification \ - # define(confUSERDB_SPEC, /etc/mail/users.db)dnl # comment \ - /^[:space:]*define\([:space:]*`?confUSERDB_SPEC/ { \ - str = $0; \ - # Strip garbage from string \ - sub(/define\(/, "", str); \ - sub(/\)(dnl)?.*/, "", str); \ - sub(/\,/, "", str); \ - gsub(/`/, "", str); \ - gsub(/'"'"'/, "", str); \ - split(str, entry); \ - entry[5] = "-"; \ - entry[4] = entry[2]; \ - entry[3] = "-o"; \ - entry[2] = "btree"; \ - # Save lastmost entry \ - sub(/\.db/, "", entry[4]); \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - } \ - # Look for all confC?_FILE specifications \ - # define(confCR_FILE, -o /etc/mail/relay-domains %[^\#])dnl \ - # define(confCT_FILE, -o /etc/mail/sendmail.ct %[^\#])dnl \ - # define(confCW_FILE, -o /etc/mail/sendmail.cw %[^\#])dnl \ - /^[:space:]*define\([:space:]*`?confC[RTW]_FILE/ { \ - str = $0; \ - # Strip garbage from string \ - sub(/define\(/, "", str); \ - sub(/\)(dnl)?.*/, "", str); \ - sub(/\,/, "", str); \ - gsub(/`/, "", str); \ - gsub(/'"'"'/, "", str); \ - split(str, entry); \ - # Default elided info - format: \ - # name [ [opts] file [opts] ] \ - if (entry[2] == "-o") { \ - entry[5] = entry[4]; \ - entry[4] = entry[3]; \ - entry[3] = entry[2]; \ - } \ - else { \ - entry[5] = entry[3]; \ - entry[4] = entry[2]; \ - entry[3] = "-"; \ - entry[2] = "-"; \ - } \ - # Save lastmost entry \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - } \ - # Look for all ALIAS_FILE specifications \ - #define(ALIAS_FILE, /etc/mail/aliases.private,/etc/mail/aliases)dnl \ - /^[:space:]*define\([:space:]*`?ALIAS_FILE/ { \ - str = $0; \ - # Strip garbage from string \ - sub(/define\(/, "", str); \ - sub(/\)(dnl)?.*/, "", str); \ - gsub(/ /, "", str); \ - sub(/\,/, " ", str); \ - gsub(/`/, "", str); \ - gsub(/'"'"'/, "", str); \ - split(str, entry); \ - entry[5] = "-"; \ - entry[4] = entry[2]; \ - entry[3] = "-"; \ - entry[2] = "newaliases"; \ - # Save lastmost entry \ - dbs[entry[1]] = entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - } \ - # Locate all non-commented FEATURE macros \ - # FEATURE(name[, type [flags] file])dnl #comment \ - /^[:space:]*FEATURE\(.*\)/ { \ - str = $0; \ - # Strip garbage from string \ - sub(/FEATURE\(/, "", str); \ - sub(/\)(dnl)?.*/, "", str); \ - if (index(str, ",") != 0) { \ - sub(/\,/, "", str); \ - gsub(/`/, "", str); \ - gsub(/'"'"'/, "", str); \ - }; \ - split(str, entry); \ - # Ignore non-db features \ - for (x in db_features) { \ - if (entry[1] == db_features[x]) { \ - # Default elided info - format: \ - # name [type [opts] file] \ - if (entry[2] == "") { \ - entry[5] = "-"; \ - entry[4] = db_loc""entry[1]; \ - entry[3] = "-o"; \ - entry[2] = db_type; \ - if (entry[1] == "use_ct_file" || \ - entry[1] == "use_cw_file") { \ - if (entry[1] == "use_ct_file") \ - str = entry[1]":"dbs["confCT_FILE"]; \ - else \ - str = entry[1]":"dbs["confCW_FILE"]; \ - split(str, entry, ":"); \ - } \ - else if (entry[1] == "access_db") \ - entry[4] = db_loc"access"; \ - else if (entry[1] == "uucpdomain") \ - entry[4] = db_loc"uudomain"; \ - } \ - else if (entry[3] == "") { \ - entry[5] = "-"; \ - entry[4] = entry[2]; \ - entry[3] = "-"; \ - entry[2] = db_type; \ - } \ - else if (entry[4] == "") { \ - entry[5] = "-"; \ - entry[4] = entry[3]; \ - entry[3] = "-"; \ - }; \ - # Save lastmost entry \ - sub(/\.db/, "", entry[4]); \ - dbs[entry[1]]=entry[2]":"entry[3]":"entry[4]":"entry[5]":"; \ - }; \ - }; \ - }; \ - END { \ - # Print the found features \ - date = ENVIRON["date"]; \ - user = ENVIRON["user"]; \ - hostname = ENVIRON["hostname"]; \ - script = ENVIRON["script"]; \ - directory = ENVIRON["directory"]; \ - print "####################################################################"; \ - print "##### This file is automatically generated -- edit at your own risk"; \ - print "#####"; \ - print "##### file: /etc/mail/databases"; \ - print "##### generated via: "script; \ - print "##### by: "user"@"hostname; \ - print "##### on: "date; \ - print "##### in: "directory; \ - print "#####"; \ - print "##### The following databases are used by sendmail"; \ - print "#####"; \ - print "####################################################################"; \ - # delete unneeded elements \ - #delete dbs["MAIL_SETTINGS_DIR"]; \ - #delete dbs["DATABASE_MAP_TYPE"]; \ - #delete dbs["confCT_FILE"]; \ - #delete dbs["confCW_FILE"]; \ - for (x in dbs) \ - if (x != "ALIAS_FILE" && \ - x != "confUSERDB_SPEC") { \ - print x":"dbs[x]; \ - } \ - else { \ - split(x":"dbs[x], entry, ":"); \ - pfx = entry[1]":"entry[2]":"entry[3]; \ - str = entry[4]; \ - sfx = entry[5]":"; \ - sub(/\,/, " ", str); \ - split(str, entry); \ - for (y in entry) \ - print pfx":"entry[y]":"sfx; \ - } \ - }; \ - '; - -#------------------------------------------------------------------------ -# Make sure not using text mailertable (it doesn't work) -if (grep -q "^[[:space:]]*FEATURE(mailertable, \`text /etc/mail/mailertable')dnl" /etc/mail/sendmail.mc); then - sed "s?FEATURE(mailertable, \`text /etc/mail/mailertable')dnl?FEATURE(mailertable)dnl?g" \ - /etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new - chown root.mail /etc/mail/sendmail.mc.new - chmod 0664 /etc/mail/sendmail.mc.new - mv /etc/mail/sendmail.mc.new /etc/mail/sendmail.mc - fi; - -#------------------------------------------------------------------------ -# parse /etc/mail/sendmail.mc -echo "Scanning /etc/mail/sendmail.mc" -awk -- "$pattern" /etc/mail/sendmail.mc > /etc/mail/databases; \ -chown root.mail /etc/mail/databases -chmod 0664 /etc/mail/databases -#cat /etc/mail/databases -#exit 0 - -#------------------------------------------------------------------------ -# check for extant, non automagically generated Makefile and abort if found -CFGFILE="/etc/mail/Makefile" -HEADER="##### This file is automatically generated -- edit at your own risk" -if [ -s $CFGFILE ]; then - if ! head -3 $CFGFILE | grep -q "^$HEADER" ; then - echo "Error: the current $CFGFILE is not automatically generated." - if [ "$1" != "force" ]; then - echo "Use \"$0 force\" to force (re)generation." - exit 1 - else - echo "force specified, (re)generating file anyway." - fi; - fi; - - fi; - -#------------------------------------------------------------------------ -echo -n "Creating /etc/mail/Makefile" -makefile="/etc/mail/Makefile.new " -cat <<EOT > $makefile -#!/usr/bin/make -f -#################################################################### -##### This file is automatically generated -- edit at your own risk -##### -##### file: /etc/mail/Makefile -##### generated via: $script -##### by: $user@$hostname -##### on: $date -##### in: $directory -##### -##### Makefile for Sendmail databases -##### -#################################################################### -SHELL=/bin/sh - -# flag used to ensure only one newaliases command is run -newaliases_run=0 - -# -# all, the default target will update everything -# -all: \\ -EOT -echo -n "." -# -# create all target -# -cnt=0 -for file in $db_files; do - line=$(egrep -e "^[[:space:]]*$file" /etc/mail/databases); - while ([ "$line" != "" ]); do - str=$(echo "$line" | cut -d " -" -f 1) - line=$(echo "$line" | cut -d " -" -f 2) - # Strip line back into four pieces: feature, type, opts, name - dbfeat=$(echo "$str" | cut -d ":" -f 1) - dbtype=$(echo "$str" | cut -d ":" -f 2) - dbopts=$(echo "$str" | cut -d ":" -f 3) - dbname=$(echo "$str" | cut -d ":" -f 4) - dbregx=$(echo "$str" | cut -d ":" -f 5) - if [ $(dirname "$dbname") = "/etc/mail" ]; then - dbsname=$(basename "$dbname") - else - dbsname="$dbname" - fi; - if [ "$dbtype" != "-" ]; then - cnt=`expr $cnt + 1`; - if [ $cnt -ne 1 ]; then - echo -e " \\" >> $makefile - fi; - if [ "$dbtype" = "m4" ]; then - echo -ne "\tsendmail.cf" >> $makefile - else - echo -ne "\t$dbsname.db" >> $makefile - fi; - fi; - done; - done; - -#------------------------------------------------------------------------ -cat <<EOT >> $makefile - -# -# clean target, remove sendmail.cf and databases -# -clean: -EOT -echo -n "." -for file in $db_files; do - line=$(egrep -e "^[[:space:]]*$file" /etc/mail/databases); - while ([ "$line" != "" ]); do - str=$(echo "$line" | cut -d " -" -f 1) - line=$(echo "$line" | cut -d " -" -f 2) - - # Strip line back into four pieces: feature, type, opts, name - dbfeat=$(echo "$str" | cut -d ":" -f 1) - dbtype=$(echo "$str" | cut -d ":" -f 2) - dbopts=$(echo "$str" | cut -d ":" -f 3) - dbname=$(echo "$str" | cut -d ":" -f 4) - dbregx=$(echo "$str" | cut -d ":" -f 5) - if [ $(dirname "$dbname") = "/etc/mail" ]; then - dbsname=$(basename "$dbname") - else - dbsname="$dbname" - fi; - if [ "$dbtype" != "-" ]; then - if [ "$dbtype" = "m4" ]; then - echo -e "\trm -f sendmail.cf" >> $makefile - else - echo -e "\trm -f $dbsname.db" >> $makefile - fi; - fi; - done; - done; - -#------------------------------------------------------------------------ -cat <<EOT >> $makefile - -# -# Individual targets -# -EOT -echo -n "." -cnt=0 -for file in $db_files; do - line=$(egrep -e "^[[:space:]]*$file" /etc/mail/databases); - while ([ "$line" != "" ]); do - str=$(echo "$line" | cut -d " -" -f 1) - line=$(echo "$line" | cut -d " -" -f 2) - - # Strip line back into four pieces: feature, type, opts, name - dbfeat=$(echo "$str" | cut -d ":" -f 1) - dbtype=$(echo "$str" | cut -d ":" -f 2) - dbopts=$(echo "$str" | cut -d ":" -f 3) - dbname=$(echo "$str" | cut -d ":" -f 4) - dbregx=$(echo "$str" | cut -d ":" -f 5) - if [ $(dirname "$dbname") = "/etc/mail" ]; then - dbsname=$(basename "$dbname") - else - dbsname="$dbname" - fi; - if [ "$dbtype" != "-" ]; then - cnt=`expr $cnt + 1`; - if [ $cnt -ne 1 ]; then - echo -e " " >> $makefile - fi; - if [ "$dbtype" = "m4" ]; then - echo -ne "sendmail.cf:\t$dbsname" >> $makefile - echo -e " dialup.m4 provider.m4" >> $makefile - else - echo -e "$dbsname.db:\t$dbsname" >> $makefile - fi; - pad="\t" - sfx="" - if [ "$dbopts" = "-o" ]; then - pad="\t\t" - sfx="; \\" - echo -e "\trm -f $dbname.db" >> $makefile - echo -e "\tif [ -s $dbname ] && \\" >> $makefile - echo -e "\t " \ - "egrep -qe \"^[[:space:]]*[^\$$\#]\"" \ - "$dbname; then \\" \ - >> $makefile - fi; - case "$dbtype" in - btree) - echo -e $pad"makemap -d $dbtype" \ - "$dbname.db < $dbname"$sfx >> $makefile - echo -e $pad"chown root.mail $dbname.db"$sfx \ - >> $makefile - echo -e $pad"chmod 0664 $dbname.db"$sfx \ - >> $makefile - ;; - dbm | btree | hash) - echo -e $pad"makemap $dbtype" \ - "$dbname.db < $dbname"$sfx >> $makefile - echo -e $pad"chown root.mail $dbname.db"$sfx \ - >> $makefile - echo -e $pad"chmod 0664 $dbname.db"$sfx \ - >> $makefile - ;; - text) - true; - ;; - newaliases) - echo -ne $pad"if [ \$(newaliases_run)" \ - >> $makefile - echo -e " -eq 0 ]; then \\" \ - >> $makefile - echo -e $pad"\tnewaliases_run=1; \\" \ - >> $makefile - echo -e $pad"\tnewaliases; \\" >> $makefile - echo -e $pad"\tfi" >> $makefile - echo -e $pad"chown root.mail $dbname.db" \ - >> $makefile - echo -e $pad"chmod 0664 $dbname.db" \ - >> $makefile - ;; - m4) - cat <<EOT >> $makefile - echo "Generating /etc/mail/sendmail.cf ..." - m4 \\ - /usr/share/sendmail/sendmail.cf/m4/cf.m4 \\ - /etc/mail/sendmail.mc \\ - > /etc/mail/sendmail.cf.new \\ - 2> /etc/mail/sendmail.cf.errors - chown root.mail /etc/mail/sendmail.cf.new - chmod 0644 /etc/mail/sendmail.cf.new - if [ ! -s /etc/mail/sendmail.cf.errors ]; then \\ - rm /etc/mail/sendmail.cf.errors; \\ - else \\ - cat /etc/mail/sendmail.cf.errors; \\ - echo ""; \\ - fi; - # Can't tell if the errors are fatal or not ;-{ - mv -f /etc/mail/sendmail.cf.new /etc/mail/sendmail.cf; -EOT - ;; - *) - echo -e $pad"# $dbtype map not done herein" \ - >> $makefile - ;; - esac - if [ "$dbopts" = "-o" ]; then - echo -e "\t\tfi;" >> $makefile - fi; - fi; - done; - done; - -cat <<EOT >> $makefile -# -# Optional targets... Will be touched if they don't exist. -# -EOT -echo -n "." -cnt=0 -for file in $db_files; do - line=$(egrep -e "^[[:space:]]*$file" /etc/mail/databases); - while ([ "$line" != "" ]); do - str=$(echo "$line" | cut -d " -" -f 1) - line=$(echo "$line" | cut -d " -" -f 2) - - # Strip line back into four pieces: feature, type, opts, name - dbfeat=$(echo "$str" | cut -d ":" -f 1) - dbtype=$(echo "$str" | cut -d ":" -f 2) - dbopts=$(echo "$str" | cut -d ":" -f 3) - dbname=$(echo "$str" | cut -d ":" -f 4) - dbregx=$(echo "$str" | cut -d ":" -f 5) - if [ $(dirname "$dbname") = "/etc/mail" ]; then - dbsname=$(basename "$dbname") - else - dbsname="$dbname" - fi; - - if [ "$dbopts" = "-o" ]; then - cnt=`expr $cnt + 1`; - if [ $cnt -ne 1 ]; then - echo -e " " >> $makefile - fi; - echo -e "$dbsname:" >>$makefile - echo -e "\ttouch $dbname" >>$makefile - echo -e "\tchmod 0664 $dbname" >>$makefile - echo -e "\tchown root.mail $dbname" >>$makefile - fi; - - done; - done; - -cat <<EOT >> $makefile - -# -# A few special targets that may not exists... -# - -# dialup.m4 - created/updated by /etc/ppp/ip-up.d/sendmail -# used to provide the true, hopefully resolvable -# hostname (from the ISP nameservers) -# -# To activate, put this in /etc/mail/sendmail.mc: -# include(\`/etc/mail/dialup.m4')dnl -dialup.m4: - touch /etc/mail/dialup.m4 - chmod 0664 /etc/mail/dialup.m4 - chown root.mail /etc/mail/dialup.m4 - -# provider.m4 - created by the user, or /etc/ppp/ip-up.d/sendmail -# used to provide ISP information (masquerade_as, etc.) -# If its a link, it will *not* be overwritten -# -# To activate, put this in /etc/mail/sendmail.mc: -# include(\`/etc/mail/provider.m4')dnl -provider.m4: - touch /etc/mail/provider.m4 - chmod 0664 /etc/mail/provider.m4 - chown root.mail /etc/mail/provider.m4 - -EOT -echo -n "." - -echo " done." - -#------------------------------------------------------------------------ -chown root.mail $makefile -chmod 0770 $makefile -mv $makefile /etc/mail/Makefile -exit 0 diff --git a/debian/local/provider b/debian/local/provider index 2a5bfa4..b9bc496 100644 --- a/debian/local/provider +++ b/debian/local/provider @@ -6,5 +6,5 @@ # This is what I use when connecting to mindspring.com: # remove the leading dnl to activate LOCAL_CONFIG -dnldefine(`SMART_HOST', `mail.mindspring.com.')dnl -dnlMASQUERADE_AS(mindspring.com)dnl +dnl define(`SMART_HOST', `mail.mindspring.com.')dnl +dnl MASQUERADE_AS(mindspring.com)dnl diff --git a/debian/local/qtool.8 b/debian/local/qtool.8 new file mode 100644 index 0000000..e40644d --- /dev/null +++ b/debian/local/qtool.8 @@ -0,0 +1,213 @@ +.\" Copyright (c) 1999 Sendmail, Inc. and its suppliers. +.\" All rights reserved. +.\" +.\" By using this file, you agree to the terms and conditions set +.\" forth in the LICENSE file which can be found at the top level of +.\" the sendmail distribution. +.\" +.\" +.\" $Id: qtool.8,v 8.12 2000/12/15 19:53:35 gshapiro Exp $ +.\" +.TH QTOOL 8 "$Date: 2000/12/15 19:53:35 $" +.SH NAME +qtool +\- manipulate sendmail queues +.SH SYNOPSIS +.B qtool.pl +.RB [options] +target_directory source [source ...] +.PP +.B qtool.pl [-d|-b] +.RB [options] +source [source ...] +.SH DESCRIPTION +.B Qtool +moves the queue files used by sendmail between queues. It uses the same +locking mechanism as sendmail so can be safely used while sendmail is +running. +.PP +With no options, +.B qtool +will move any queue files as specified by \fIsource\fP into +\fItarget_directory\fP. \fISource\fP can be either an individual +queue control file, a queue file id, or a queue directory. +.PP +If the -d option is specified, qtool will delete the messages specified by +source instead of moving them. +.PP +If the -b option is specified, the selected messages will be bounced by +running sendmail with the -OTimeout.queuereturn=now option. +.SS Options +.TP +\fB\-b\fP +Bounce all of the messages specified by source. The messages will be bounced +immediately. No attempt will be made to deliver the messages. +.TP +\fB\-C\fP configfile +Specify the sendmail config file. +Defaults to /etc/mail/sendmail.cf. +.TP +\fB\-d\fP +Delete all of the messages specified by source. +.TP +\fB\-e\fP \fIperl_expression\fP +Evalute \fIperl_expression\fP for each queue file as specified +by \fIsource\fP. If \fIperl_expression\fP evaluates to true, then that +queue file is moved. See below for more detail on \fIperl_expression\fP. +.TP +\fB\-s\fP \fIseconds\fP +Move only the queue files specified by \fIsource\fP that have a +modification time older than \fIseconds\fP. +.SS Perl Expressions +You can use any valid perl expression. Inside the expression you have +access to a hash that contains many of the fields in the control file as +well as some other data about that queued message. The hash is called +\fI%msg\fP. If a field has multiple values (e.g. 'Recipient'), it will be +returned as an array, otherwise it will be returned as a scalar. Through +\fI%msg\fP, you can access the following variables: +.TP +\fBauth\fP +AUTH= parameter. +.TP +\fBbody_type\fP +Body type (\fB8BITMIME\fP, \fB7BIT\fP, or undefined). +.TP +\fBbody_last_mod_time\fP +The last time the body was modified since the epoch in seconds. +.TP +\fBbody_size\fP +The size of the body file in bytes. +.TP +\fBcharset\fP +Character set (for future use). +.TP +\fBcontent-length\fP +Content-Length: header value (Solaris sendmail only). +.TP +\fBcontrolling_user\fP +The controlling user. +.TP +\fBcontrol_last_mod_time\fP +The last time the body was modified since the epoch in seconds. +.TP +\fBcontrol_size\fP +The size of the control file in bytes. +.TP +\fBcreation_time\fP +The time when the control file was created. +.TP +\fBdata_file_name\fP +The data file name (deprecated). +.TP +\fBenvid\fP +Original envelope id form ESMTP. +.TP +\fBerror_recipient\fP +The error recipient (deprecated). +.TP +\fBflags\fP +Array of characters that can be the following values: +.PD 0 +.RS +8 +.TP 8 +w +warning message has been sent +.TP 8 +r +This is an error respone or DSN +.TP 8 +8 +has 8 bit data in body +.TP 8 +b +delete Bcc: headers +.TP 8 +d +envelope has DSN RET= parameter +.TP 8 +n +don't return body +.PD +.RE +.TP +\fBheaders\fP +This is a Perl hash where the keys are rfc822 field names and the values +are rfc822 field values. If a field has only one value it will be returned +as a string. If a field has more than one value (e.g. 'Received') it will +be returned as a list of strings. +.TP +\fBinode_number\fP +The inode number for the data (body) file. +.TP +\fBnext_delivery_time\fP +Earliest time of next delivery attempt. +.TP +\fBnum_delivery_attempts\fP +Number of delivery attempts that have been made. +.TP +\fBmacro\fP +Defined macro. +.TP +\fBmessage\fP +Envelope status message. +.TP +\fBoriginal_recipient\fP +Original recipient (ORCPT= parameter). +.TP +\fBpriority\fP +Adjusted priority of message. +.TP +\fBrecipient\fP +Array of character flags followed by colon and recipient name. Flags: +.PD 0 +.RS +8 +.TP 8 +N +Has NOTIFY= parameter. +.TP 8 +S +Success DSN requested. +.TP 8 +F +Failure DSN requested. +.TP 8 +D +Delay DSN requested. +.TP 8 +P +Primary address (not the result of alias/forward expansion). +.PD +.RE +.TP +\fBsender\fP +Sender +.TP +\fBversion\fP +Version of control file. +.SH EXAMPLES +.TP +\fBqtool.pl q2 q1\fP +Moves all of the queue files in queue q1 to queue q2. +.TP +\fBqtool.pl q2 q1/d6CLQh100847\fP +Moves the message with id d6CLQh100847 in queue q1 to queue q2. +.TP +\fBqtool.pl q2 q1/qfd6CLQh100847\fP +Moves the message with id d6CLQh100847 in queue q1 to queue q2. +.TP +\fBqtool.pl -e '$msg{num_delivery_attempts} == 3' /q2 /q1\fP +Moves all of the queue files that have had three attempted deliveries from +queue q1 to queue q2. +.SH BUGS +In sendmail 8.12, it is possible for a message's qf and df files +to be stored in different queues. +In this situation, you must give qtool the pathname of the qf file, +not of the df file. +To be safe, never feed qtool the pathname of a df file. +.SH SEE ALSO +sendmail(8) +.SH HISTORY +The +.B qtool +command appeared in +sendmail 8.10. diff --git a/debian/local/qtool.pl b/debian/local/qtool.pl new file mode 100644 index 0000000..aa25fb2 --- /dev/null +++ b/debian/local/qtool.pl @@ -0,0 +1,1234 @@ +#!/usr/bin/env perl +## +## Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. +## All rights reserved. +## +## $Id: qtool.pl,v 8.20 2000/12/05 16:10:07 dmoen Exp $ +## +use strict; +use File::Basename; +use File::Copy; +use File::Spec; +use Fcntl qw(:flock :DEFAULT); +use Getopt::Std; + +## +## QTOOL +## This program is for moving files between sendmail queues. It is +## pretty similar to just moving the files manually, but it locks the files +## the same way sendmail does to prevent problems. +## +## The syntax is the reverse of mv (ie. the target argument comes +## first). This lets you pick the files you want to move using find and +## xargs. +## +## Since you cannot delete queues while sendmail is running, QTOOL +## assumes that when you specify a directory as a source, you mean that you +## want all of the queue files within that directory moved, not the +## directory itself. +## +## There is a mechanism for adding conditionals for moving the files. +## Just create an Object with a check_move(source, dest) method and add it +## to the $conditions object. See the handling of the '-s' option for an +## example. +## + +## +## OPTION NOTES +## +## The -e option: +## The -e option takes any valid perl expression and evaluates it +## using the eval() function. Inside the expression the variable +## '$msg' is bound to the ControlFile object for the current source +## queue message. This lets you check for any value in the message +## headers or the control file. Here's an example: +## +## ./qtool.pl -e '$msg->{num_delivery_attempts} >= 2' /q1 /q2 +## +## This would move any queue files whose number of delivery attempts +## is greater than or equal to 2 from the queue 'q2' to the queue 'q1'. +## +## See the function ControlFile::parse for a list of available +## variables. +## + +my %opts; +my %sources; +my $dst_name; +my $destination; +my $source_name; +my $source; +my $result; +my $action; +my $new_condition; +my $conditions = new Compound(); + +Getopt::Std::getopts('bC:de:s:', \%opts); + +sub move_action +{ + my $source = shift; + my $destination = shift; + + $result = $destination->add($source); + if ($result) + { + print("$result.\n"); + } +} + +sub delete_action +{ + my $source = shift; + + return $source->delete(); +} + +sub bounce_action +{ + my $source = shift; + + return $source->bounce(); +} + +$action = \&move_action; +if (defined $opts{d}) +{ + $action = \&delete_action; +} +elsif (defined $opts{b}) +{ + $action = \&bounce_action; +} + +if (defined $opts{s}) +{ + $new_condition = new OlderThan($opts{s}); + $conditions->add($new_condition); +} + +if (defined $opts{e}) +{ + $new_condition = new Eval($opts{e}); + $conditions->add($new_condition); +} + +if ($action == \&move_action) +{ + $dst_name = shift(@ARGV); + if (!-d $dst_name) + { + print("The destination '$dst_name' must be an existing " . + "directory.\n"); + usage(); + exit; + } + $destination = new Queue($dst_name); +} + +# determine queue_root by reading config file +my $queue_root; +{ + my $config_file = "/etc/mail/sendmail.cf"; + if (defined $opts{C}) + { + $config_file = $opts{C}; + } + + my $line; + open(CONFIG_FILE, $config_file) or die "$config_file: $!"; + while ($line = <CONFIG_FILE>) + { + chomp $line; + if ($line =~ m/^O QueueDirectory=(.*)/) + { + $queue_root = $1; + if ($queue_root =~ m/(.*)\/[^\/]+\*$/) + { + $queue_root = $1; + } + last; + } + } + close(CONFIG_FILE); + if (!defined $queue_root) + { + die "QueueDirectory option not defined in $config_file"; + } +} + +while (@ARGV) +{ + $source_name = shift(@ARGV); + $result = add_source(\%sources, $source_name); + if ($result) + { + print("$result.\n"); + exit; + } +} + +if (keys(%sources) == 0) +{ + exit; +} + +while (($source_name, $source) = each(%sources)) +{ + $result = $conditions->check_move($source, $destination); + if ($result) + { + $result = &{$action}($source, $destination); + if ($result) + { + print("$result\n"); + } + } +} + +sub usage +{ + print("Usage: $0 [options] directory source ...\n"); + print(" $0 [-d|-b] source ...\n"); + print("options:\n"); + print(" -b Bounce the messages specified by source.\n"); + print(" -C configfile Specify sendmail config file.\n"); + print(" -d Delete the messages specified by source.\n"); + print(" -e [perl expression] Move only messages for which perl expression returns true.\n"); + print(" -s [seconds] Move only messages whose qf file is older than seconds.\n"); +} + +## +## ADD_SOURCE -- Adds a source to the source hash. +## +## Determines whether source is a file, directory, or id. Then it +## creates a QueuedMessage or Queue for that source and adds it to the +## list. +## +## Parameters: +## sources -- A hash that contains all of the sources. +## source_name -- The name of the source to add +## +## Returns: +## error_string -- Undef if ok. Error string otherwise. +## +## Notes: +## If a new source comes in with the same ID as a previous +## source, the previous source gets overwritten in the sources +## hash. This lets the user specify things like * and it still +## works nicely. +## + +sub add_source +{ + my $sources = shift; + my $source_name = shift; + my $source_base_name; + my $source_dir_name; + my $data_dir_name; + my $source_id; + my $source_prefix; + my $queued_message; + my $queue; + my $result; + + ($source_base_name, $source_dir_name) = File::Basename::fileparse($source_name); + $data_dir_name = $source_dir_name; + + $source_prefix = substr($source_base_name, 0, 2); + if (!-d $source_name && $source_prefix ne 'qf' && + $source_prefix ne 'df') + { + $source_base_name = "qf$source_base_name"; + $source_name = File::Spec->catfile("$source_dir_name", + "$source_base_name"); + } + $source_id = substr($source_base_name, 2); + + if (!-e $source_name) + { + $source_name = File::Spec->catfile("$source_dir_name", "qf", + "qf$source_id"); + if (!-e $source_name) + { + return "'$source_name' does not exist"; + } + $data_dir_name = File::Spec->catfile("$source_dir_name", "df"); + if (!-d $data_dir_name) + { + $data_dir_name = $source_dir_name; + } + $source_dir_name = File::Spec->catfile("$source_dir_name", + "qf"); + } + + if (-f $source_name) + { + $queued_message = new QueuedMessage($source_dir_name, + $source_id, + $data_dir_name); + $sources->{$source_id} = $queued_message; + return undef; + } + + if (!-d $source_name) + { + return "'$source_name' is not a plain file or a directory"; + } + + $queue = new Queue($source_name); + $result = $queue->read(); + if ($result) + { + return $result; + } + + while (($source_id, $queued_message) = each(%{$queue->{files}})) + { + $sources->{$source_id} = $queued_message; + } + + return undef; +} + +## +## LOCK_FILE -- Opens and then locks a file. +## +## Opens a file for read/write and uses flock to obtain a lock on the +## file. The flock is Perl's flock which defaults to flock on systems +## that support it. On systems without flock it falls back to fcntl +## locking. +## +## Parameters: +## file_name -- The name of the file to open and lock. +## +## Returns: +## (file_handle, error_string) -- If everything works then +## file_handle is a reference to a file handle and +## error_string is undef. If there is a problem then +## file_handle is undef and error_string is a string +## explaining the problem. +## + +sub lock_file +{ + my $file_name = shift; + my $result; + + $result = sysopen(FILE_TO_LOCK, $file_name, Fcntl::O_RDWR); + if (!$result) + { + return (undef, "Unable to open '$file_name': $!"); + } + + $result = flock(FILE_TO_LOCK, Fcntl::LOCK_EX | Fcntl::LOCK_NB); + if (!$result) + { + return (undef, "Could not obtain lock on '$file_name': $!"); + } + + return (\*FILE_TO_LOCK, undef); +} + +## +## UNLOCK_FILE -- Unlocks a file. +## +## Unlocks a file using Perl's flock. +## +## Parameters: +## file -- A file handle. +## +## Returns: +## error_string -- If undef then no problem. Otherwise it is a +## string that explains problem. +## + +sub unlock_file +{ + my $file = shift; + my $result; + + $result = flock($file, Fcntl::LOCK_UN); + if (!$result) + { + return "Unlock failed on '$result': $!"; + } + + return undef; +} + +## +## MOVE_FILE -- Moves a file. +## +## Moves a file. +## +## Parameters: +## src_name -- The name of the file to be move. +## dst_nome -- The name of the place to move it to. +## +## Returns: +## error_string -- If undef then no problem. Otherwise it is a +## string that explains problem. +## + +sub move_file +{ + my $src_name = shift; + my $dst_name = shift; + my $result; + + $result = File::Copy::move($src_name, $dst_name); + if (!$result) + { + return "File move from '$src_name' to '$dst_name' failed: $!"; + } + + return undef; +} + + +## +## CONTROL_FILE - Represents a sendmail queue control file. +## +## This object represents represents a sendmail queue control file. +## It can parse and lock its file. +## + + +package ControlFile; + +sub new +{ + my $this = shift; + my $class = ref($this) || $this; + my $self = {}; + bless $self, $class; + $self->initialize(@_); + return $self; +} + +sub initialize +{ + my $self = shift; + my $queue_dir = shift; + $self->{id} = shift; + + $self->{file_name} = $queue_dir . '/qf' . $self->{id}; + $self->{headers} = {}; +} + +## +## PARSE - Parses the control file. +## +## Parses the control file. It just sticks each entry into a hash. +## If a key has more than one entry, then it points to a list of +## entries. +## + +sub parse +{ + my $self = shift; + if ($self->{parsed}) + { + return; + } + my %parse_table = + ( + 'A' => 'auth', + 'B' => 'body_type', + 'C' => 'controlling_user', + 'D' => 'data_file_name', + 'd' => 'data_file_directory', + 'E' => 'error_recipient', + 'F' => 'flags', + 'H' => 'parse_header', + 'I' => 'inode_number', + 'K' => 'next_delivery_time', + 'L' => 'content-length', + 'M' => 'message', + 'N' => 'num_delivery_attempts', + 'P' => 'priority', + 'Q' => 'original_recipient', + 'R' => 'recipient', + 'S' => 'sender', + 'T' => 'creation_time', + 'V' => 'version', + 'X' => 'charset', + 'Z' => 'envid', + '$' => 'macro' + ); + my $line; + my $line_type; + my $line_value; + my $member_name; + my $member; + my $last_type; + + open(CONTROL_FILE, "$self->{file_name}"); + while ($line = <CONTROL_FILE>) + { + $line_type = substr($line, 0, 1); + if ($line_type eq "\t" && $last_type eq 'H') + { + $line_type = 'H'; + $line_value = $line; + } + else + { + $line_value = substr($line, 1); + } + $member_name = $parse_table{$line_type}; + $last_type = $line_type; + if (!$member_name) + { + $member_name = 'unknown'; + } + if ($self->can($member_name)) + { + $self->$member_name($line_value); + } + $member = $self->{$member_name}; + if (!$member) + { + $self->{$member_name} = $line_value; + next; + } + if (ref($member) eq 'ARRAY') + { + push(@{$member}, $line_value); + next; + } + $self->{$member_name} = [$member, $line_value]; + } + close(CONTROL_FILE); + + $self->{parsed} = 1; +} + +sub parse_header +{ + my $self = shift; + my $line = shift; + my $headers = $self->{headers}; + my $last_header = $self->{last_header}; + my $header_name; + my $header_value; + my $first_char; + + $first_char = substr($line, 0, 1); + if ($first_char eq "?") + { + $line = substr($line, 3); + } + elsif ($first_char eq "\t") + { + if (ref($headers->{$last_header}) eq 'ARRAY') + { + $headers->{$last_header}[-1] = + $headers->{$last_header}[-1] . $line; + } + else + { + $headers->{$last_header} = $headers->{$last_header} . + $line; + } + return; + } + ($header_name, $header_value) = split(/:/, $line, 2); + $self->{last_header} = $header_name; + if (exists $headers->{$header_name}) + { + $headers->{$header_name} = [$headers->{$header_name}, + $header_value]; + } + else + { + $headers->{$header_name} = $header_value; + } +} + +sub is_locked +{ + my $self = shift; + + return (defined $self->{lock_handle}); +} + +sub lock +{ + my $self = shift; + my $lock_handle; + my $result; + + if ($self->is_locked()) + { + # Already locked + return undef; + } + + ($lock_handle, $result) = ::lock_file($self->{file_name}); + if (!$lock_handle) + { + return $result; + } + + $self->{lock_handle} = $lock_handle; + + return undef; +} + +sub unlock +{ + my $self = shift; + my $result; + + if (!$self->is_locked()) + { + # Not locked + return undef; + } + + $result = ::unlock_file($self->{lock_handle}); + + $self->{lock_handle} = undef; + + return $result; +} + +sub do_stat +{ + my $self = shift; + my $result; + my @result; + + $result = open(QUEUE_FILE, $self->{file_name}); + if (!$result) + { + return "Unable to open '$self->{file_name}': $!"; + } + @result = stat(QUEUE_FILE); + if (!@result) + { + return "Unable to stat '$self->{file_name}': $!"; + } + $self->{control_size} = $result[7]; + $self->{control_last_mod_time} = $result[9]; +} + +sub DESTROY +{ + my $self = shift; + + $self->unlock(); +} + +sub delete +{ + my $self = shift; + my $result; + + $result = unlink($self->{file_name}); + if (!$result) + { + return "Unable to delete $self->{file_name}: $!"; + } + return undef; +} + + +## +## DATA_FILE - Represents a sendmail queue data file. +## +## This object represents represents a sendmail queue data file. +## It is really just a place-holder. +## + +package DataFile; + +sub new +{ + my $this = shift; + my $class = ref($this) || $this; + my $self = {}; + bless $self, $class; + $self->initialize(@_); + return $self; +} + +sub initialize +{ + my $self = shift; + my $data_dir = shift; + $self->{id} = shift; + my $control_file = shift; + + $self->{file_name} = $data_dir . '/df' . $self->{id}; + return if -e $self->{file_name}; + $control_file->parse(); + return if !defined $control_file->{data_file_directory}; + $data_dir = $queue_root . '/' . $control_file->{data_file_directory}; + chomp $data_dir; + if (-d ($data_dir . '/df')) + { + $data_dir .= '/df'; + } + $self->{file_name} = $data_dir . '/df' . $self->{id}; +} + +sub do_stat +{ + my $self = shift; + my $result; + my @result; + + $result = open(QUEUE_FILE, $self->{file_name}); + if (!$result) + { + return "Unable to open '$self->{file_name}': $!"; + } + @result = stat(QUEUE_FILE); + if (!@result) + { + return "Unable to stat '$self->{file_name}': $!"; + } + $self->{body_size} = $result[7]; + $self->{body_last_mod_time} = $result[9]; +} + +sub delete +{ + my $self = shift; + my $result; + + $result = unlink($self->{file_name}); + if (!$result) + { + return "Unable to delete $self->{file_name}: $!"; + } + return undef; +} + + +## +## QUEUED_MESSAGE - Represents a queued sendmail message. +## +## This keeps track of the files that make up a queued sendmail +## message. +## Currently it has 'control_file' and 'data_file' as members. +## +## You can tie it to a fetch only hash using tie. You need to +## pass a reference to a QueuedMessage as the third argument +## to tie. +## + +package QueuedMessage; + +sub new +{ + my $this = shift; + my $class = ref($this) || $this; + my $self = {}; + bless $self, $class; + $self->initialize(@_); + return $self; +} + +sub initialize +{ + my $self = shift; + my $queue_dir = shift; + my $id = shift; + my $data_dir = shift; + + $self->{id} = $id; + $self->{control_file} = new ControlFile($queue_dir, $id); + if (!$data_dir) + { + $data_dir = $queue_dir; + } + $self->{data_file} = new DataFile($data_dir, $id, $self->{control_file}); +} + +sub last_modified_time +{ + my $self = shift; + my @result; + @result = stat($self->{data_file}->{file_name}); + return $result[9]; +} + +sub TIEHASH +{ + my $this = shift; + my $class = ref($this) || $this; + my $self = shift; + return $self; +} + +sub FETCH +{ + my $self = shift; + my $key = shift; + + if (exists $self->{control_file}->{$key}) + { + return $self->{control_file}->{$key}; + } + if (exists $self->{data_file}->{$key}) + { + return $self->{data_file}->{$key}; + } + + return undef; +} + +sub lock +{ + my $self = shift; + + return $self->{control_file}->lock(); +} + +sub unlock +{ + my $self = shift; + + return $self->{control_file}->unlock(); +} + +sub move +{ + my $self = shift; + my $destination = shift; + my $df_dest; + my $qf_dest; + my $result; + + $result = $self->lock(); + if ($result) + { + return $result; + } + + $qf_dest = File::Spec->catfile($destination, "qf"); + if (-d $qf_dest) + { + $df_dest = File::Spec->catfile($destination, "df"); + if (!-d $df_dest) + { + $df_dest = $destination; + } + } + else + { + $qf_dest = $destination; + $df_dest = $destination; + } + + if (-e File::Spec->catfile($qf_dest, "qf$self->{id}")) + { + $result = "There is already a queued message with id '$self->{id}' in '$destination'"; + } + + if (!$result) + { + $result = ::move_file($self->{data_file}->{file_name}, + $df_dest); + } + + if (!$result) + { + $result = ::move_file($self->{control_file}->{file_name}, + $qf_dest); + } + + $self->unlock(); + + return $result; +} + +sub parse +{ + my $self = shift; + + return $self->{control_file}->parse(); +} + +sub do_stat +{ + my $self = shift; + + $self->{control_file}->do_stat(); + $self->{data_file}->do_stat(); +} + +sub setup_vars +{ + my $self = shift; + + $self->parse(); + $self->do_stat(); +} + +sub delete +{ + my $self = shift; + my $result; + + $result = $self->{control_file}->delete(); + if ($result) + { + return $result; + } + $result = $self->{data_file}->delete(); + if ($result) + { + return $result; + } + + return undef; +} + +sub bounce +{ + my $self = shift; + my $command; + + $command = "sendmail -qI$self->{id} -O Timeout.queuereturn=now"; +# print("$command\n"); + system($command); +} + +## +## QUEUE - Represents a queued sendmail queue. +## +## This manages all of the messages in a queue. +## + +package Queue; + +sub new +{ + my $this = shift; + my $class = ref($this) || $this; + my $self = {}; + bless $self, $class; + $self->initialize(@_); + return $self; +} + +sub initialize +{ + my $self = shift; + + $self->{queue_dir} = shift; + $self->{files} = {}; +} + +## +## READ - Loads the queue with all of the objects that reside in it. +## +## This reads the queue's directory and creates QueuedMessage objects +## for every file in the queue that starts with 'qf'. +## + +sub read +{ + my $self = shift; + my @control_files; + my $queued_message; + my $file_name; + my $id; + my $result; + my $control_dir; + my $data_dir; + + $control_dir = File::Spec->catfile($self->{queue_dir}, 'qf'); + + if (-e $control_dir) + { + $data_dir = File::Spec->catfile($self->{queue_dir}, 'df'); + if (!-e $data_dir) + { + $data_dir = $self->{queue_dir}; + } + } + else + { + $data_dir = $self->{queue_dir}; + $control_dir = $self->{queue_dir}; + } + + $result = opendir(QUEUE_DIR, $control_dir); + if (!$result) + { + return "Unable to open directory '$control_dir'"; + } + + @control_files = grep { /^qf.*/ && -f "$control_dir/$_" } readdir(QUEUE_DIR); + closedir(QUEUE_DIR); + foreach $file_name (@control_files) + { + $id = substr($file_name, 2); + $queued_message = new QueuedMessage($control_dir, $id, + $data_dir); + $self->{files}->{$id} = $queued_message; + } + + return undef; +} + + +## +## ADD_QUEUED_MESSAGE - Adds a QueuedMessage to this Queue. +## +## Adds the QueuedMessage object to the hash and moves the files +## associated with the QueuedMessage to this Queue's directory. +## + +sub add_queued_message +{ + my $self = shift; + my $queued_message = shift; + my $result; + + $result = $queued_message->move($self->{queue_dir}); + if ($result) + { + return $result; + } + + $self->{files}->{$queued_message->{id}} = $queued_message; + + return $result; +} + +## +## ADD_QUEUE - Adds another Queue's QueuedMessages to this Queue. +## +## Adds all of the QueuedMessage objects in the passed in queue +## to this queue. +## + +sub add_queue +{ + my $self = shift; + my $queue = shift; + my $id; + my $queued_message; + my $result; + + while (($id, $queued_message) = each %{$queue->{files}}) + { + $result = $self->add_queued_message($queued_message); + if ($result) + { + print("$result.\n"); + } + } +} + +## +## ADD - Adds an item to this queue. +## +## Adds either a Queue or a QueuedMessage to this Queue. +## + +sub add +{ + my $self = shift; + my $source = shift; + my $type_name; + my $result; + + $type_name = ref($source); + + if ($type_name eq "QueuedMessage") + { + return $self->add_queued_message($source); + } + + if ($type_name eq "Queue") + { + return $self->add_queue($source); + } + + return "Queue does not know how to add a '$type_name'" +} + +sub delete +{ + my $self = shift; + my $id; + my $queued_message; + + while (($id, $queued_message) = each %{$self->{files}}) + { + $result = $queued_message->delete(); + if ($result) + { + print("$result.\n"); + } + } +} + +sub bounce +{ + my $self = shift; + my $id; + my $queued_message; + + while (($id, $queued_message) = each %{$self->{files}}) + { + $result = $queued_message->bounce(); + if ($result) + { + print("$result.\n"); + } + } +} + +## +## Condition Class +## +## This next section is for any class that has an interface called +## check_move(source, dest). Each class represents some condition to +## check for to determine whether we should move the file from +## source to dest. +## + + +## +## OlderThan +## +## This Condition Class checks the modification time of the +## source file and returns true if the file's modification time is +## older than the number of seconds the class was initialzed with. +## + +package OlderThan; + +sub new +{ + my $this = shift; + my $class = ref($this) || $this; + my $self = {}; + bless $self, $class; + $self->initialize(@_); + return $self; +} + +sub initialize +{ + my $self = shift; + + $self->{age_in_seconds} = shift; +} + +sub check_move +{ + my $self = shift; + my $source = shift; + + if ((time() - $source->last_modified_time()) > $self->{age_in_seconds}) + { + return 1; + } + + return 0; +} + +## +## Compound +## +## Takes a list of Move Condition Classes. Check_move returns true +## if every Condition Class in the list's check_move function returns +## true. +## + +package Compound; + +sub new +{ + my $this = shift; + my $class = ref($this) || $this; + my $self = {}; + bless $self, $class; + $self->initialize(@_); + return $self; +} + +sub initialize +{ + my $self = shift; + + $self->{condition_list} = []; +} + +sub add +{ + my $self = shift; + my $new_condition = shift; + + push(@{$self->{condition_list}}, $new_condition); +} + +sub check_move +{ + my $self = shift; + my $source = shift; + my $dest = shift; + my $condition; + my $result; + + foreach $condition (@{$self->{condition_list}}) + { + if (!$condition->check_move($source, $dest)) + { + return 0; + } + } + + return 1; +} + +## +## Eval +## +## Takes a perl expression and evaluates it. The ControlFile object +## for the source QueuedMessage is avaliable through the name '$msg'. +## + +package Eval; + +sub new +{ + my $this = shift; + my $class = ref($this) || $this; + my $self = {}; + bless $self, $class; + $self->initialize(@_); + return $self; +} + +sub initialize +{ + my $self = shift; + + $self->{expression} = shift; +} + +sub check_move +{ + my $self = shift; + my $source = shift; + my $dest = shift; + my $result; + my %msg; + + $source->setup_vars(); + tie(%msg, 'QueuedMessage', $source); + $result = eval($self->{expression}); + + return $result; +} diff --git a/debian/local/runq b/debian/local/runq deleted file mode 100644 index a62522c..0000000 --- a/debian/local/runq +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -usage="Usage: $0 [OPTION]... -Run the sendmail queue (sendmail -q) - - --help display this help and exit - --version output version information and exit - -Report bugs to submit@bugs.debian.org" - -case $# in - 1 ) - case "z${1}" in - z--help ) - echo "$usage"; exit 0 ;; - z--version ) - echo -n "runq (Debian GNU/Linux) 1.00. "; - echo "Copyright (c) 1997 Johnie Ingram. >= GNU GPL 2." - exit 0 ;; - * ) ;; - esac - ;; - * ) ;; -esac - -COMMAND=/usr/sbin/sendmail -exec $COMMAND -q $* diff --git a/debian/local/runq.1 b/debian/local/runq.8 index 99f97a9..2e639e4 100644 --- a/debian/local/runq.1 +++ b/debian/local/runq.8 @@ -1,4 +1,4 @@ -.TH TRUE 1 "1997 July 20" "Debian Distribution" \" -*- nroff -*- +.TH RUNQ 8 "2000 August 29" "Debian Distribution" \" -*- nroff -*- .SH NAME runq \- run the sendmail queue .SH SYNOPSIS diff --git a/debian/local/sendmail.in b/debian/local/sendmail.in new file mode 100644 index 0000000..f1dcb61 --- /dev/null +++ b/debian/local/sendmail.in @@ -0,0 +1,1121 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# $Sendmail: sm_helper.sh,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Copyright (c) 1998-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Debian helper function script for Debian Sendmail +# Note: this file supports @SM_MINVERS@ - @SM_MAXVERS@ +# +# Notes (to all): +# * +# +# Notes (to self): +# * clean_queues fubar, esp wrt MSP +# +#----------------------------------------------------------------------------- +# +set -e; + +#------------------------------------------------------------------------------ +# Parameters for the sendmail daemon +# Do *NOT* touch these lines, instead, edit /etc/mail/sendmail.conf +# The _PARMS lines are listed in precedence order +#------------------------------------------------------------------------------ +Get_Parameters () { + + # Main configuration parameters in /etc/mail/sendmail.conf + DAEMON_MODE='Daemon'; + DAEMON_PARMS=''; + QUEUE_MODE="$DAEMON_MODE"; + QUEUE_INTERVAL='10'; + QUEUE_PARMS=''; + MSP_MODE="$QUEUE_MODE"; + MSP_INTERVAL="$QUEUE_INTERVAL"; + MSP_PARMS="$QUEUE_PARMS"; + MISC_PARMS=''; + CRON_PARMS=''; + + # Secondary (non-documented) parameters in /etc/mail/sendmail.conf + # Caveat Emptor: change these at your own risk - they impact several + # disjoint pieces parts... + SENDMAIL_ROOT='@localstatedir@/run/sendmail'; + MTA_DAEMON='@sbindir@/sendmail'; + MTA_COMMAND='@sbindir@/sendmail'; + MTA_A='-Am'; + MTAL_L='-L sm-mta'; + MTAL_L_QUEUE='-L sm-mta-queue'; + MTAL_L_RUNQ='-L sm-mta-runq'; + MTA_ROOT="${SENDMAIL_ROOT}/mta"; + MTAL_PIDFILE="${MTA_ROOT}/sendmail.pid"; + MTAQ_L='-L sm-que'; + MTAQ_L_RUNQ='-L sm-que-runq'; + MTAQ_PIDFILE="${MTA_ROOT}/queue.pid"; + MSP_DAEMON='@sbindir@/sendmail'; + MSP_COMMAND='@sbindir@/sendmail'; + MSP_A='-Ac'; + MSP_L='-L sm-msp'; + MSP_L_QUEUE='-L sm-msp-queue'; + MSP_ROOT="${SENDMAIL_ROOT}/msp"; + MSP_PIDFILE="${MSP_ROOT}/sendmail.pid"; + + # Pull in any user modified variables + if [ -f @sysconfdir@/mail/sendmail.conf ]; then + . @sysconfdir@/mail/sendmail.conf; + fi; + + # Sanitize some keyword entries + DAEMON_MODE=$(echo "$DAEMON_MODE" | tr '[:upper:]' '[:lower:]'); + QUEUE_MODE=$(echo "$QUEUE_MODE" | tr '[:upper:]' '[:lower:]'); + MSP_MODE=$(echo "$MSP_MODE" | tr '[:upper:]' '[:lower:]'); + + # These can't be user customized + SM_Get_Parameters='yes'; + PATH='/bin:/usr/bin:/sbin:/usr/sbin'; + STAMP_DIR="${SENDMAIL_ROOT}/stampdir"; + START_MTAL_CMD="start-stop-daemon \ + --pidfile $MTAL_PIDFILE \ + --exec $MTA_DAEMON \ + --startas $MTA_COMMAND \ + --start"; + STOP_MTAL_CMD="start-stop-daemon \ + --pidfile $MTAL_PIDFILE \ + --stop"; + SIGNAL_MTAL_CMD="start-stop-daemon \ + --pidfile $MTAL_PIDFILE \ + --stop"; + START_MTAQ_CMD="start-stop-daemon \ + --pidfile $MTAQ_PIDFILE \ + --make-pidfile \ + --exec $MTA_DAEMON \ + --startas $MTA_COMMAND \ + --start"; + STOP_MTAQ_CMD="start-stop-daemon \ + --pidfile $MTAQ_PIDFILE \ + --stop"; + SIGNAL_MTAQ_CMD="start-stop-daemon \ + --pidfile $MTAQ_PIDFILE \ + --stop"; + START_MSP_CMD="start-stop-daemon \ + --pidfile $MSP_PIDFILE \ + --make-pidfile \ + --exec $MSP_DAEMON \ + --startas $MSP_COMMAND \ + --chuid smmsp \ + --start"; + STOP_MSP_CMD="start-stop-daemon \ + --pidfile $MSP_PIDFILE \ + --stop"; + SIGNAL_MSP_CMD="start-stop-daemon \ + --pidfile $MSP_PIDFILE \ + --stop"; + NAME='sendmail'; + FLAGS='defaults 50'; + + # Support for coexistance with smtpd package + SMTPD='/usr/sbin/smtpd'; + + # See if we can share the listener and queue-runner daemon: + # * Both must be in daemon mode + # * They must have the same (possibly empty) parameters + if [ "$DAEMON_MODE" = "daemon" \ + -a "$QUEUE_MODE" = "daemon" \ + -a "$DAEMON_PARMS" = "$QUEUE_PARMS" ]; then + SPLIT_DAEMON=0; + else + SPLIT_DAEMON=1; + fi; + + # Version dependant support: + # 8.12.0+ M{TA,MSP}_A + if [ ! -f @datadir@/sendmail/cf/feature/msp.m4 ]; then + MTA_A=''; + MTAL_L=''; + MTAL_L_QUEUE=''; + MSP_A=''; + MSP_L=''; + MSP_L_QUEUE=''; + fi; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# enhanced sendmail startup +#------------------------------------------------------------------------------ +start_mta () { + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # If already running, don't start it... + if is_running mta; then + echo 'MTA is already running.'; + return; + fi; + # + # Check if we're going to run a daemon (and how many): + daemon_check; + # + # Mark restarted for communication betwixt here and /etc/mail/Makefile + touch $STAMP_DIR/reload; + # + # Allow Unix (local) connections betwixt MSP/MTA: + touch $MTA_ROOT/smsocket; + # + # We can only afford to clean the MTA queues if running daemon mode, + # otherwise, there is a chance that a cronjob might still be using + # the queue... Thats also why we don't clean the MSP queues herein. + clean_queues; + # + # cd to a safe place to stash core files... + cd $MTA_ROOT; + $START_MTAL_CMD -- $MTAL_PARMS & + # + # Update permissions on smsocket + sleep 2; + chown root:root $MTA_ROOT/smsocket; + chmod 0666 $MTA_ROOT/smsocket; + # + # Check for split daemon mode (separate listener/queue runner) + if [ "$SPLIT_DAEMON" -eq 1 ]; then + $START_MTAQ_CMD -- $MTAQ_PARMS & + fi; + # + # if running split service, run the client queues (just to make sure) + if check_msp; then + $MSP_COMMAND -q $MSP_A $MSP_L_QUEUE $MSP_PARMS $MISC_PARMS; + fi; + }; + +start_msp () { + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # If already running, don't start it... + if is_running msp; then + echo 'MSP is already running.'; + return; + fi; + # + # Check to see if MSP mode is indeed available + if ! check_msp; then + return; + fi; + # + # Check if we're going to run a daemon: + if [ "$MSP_MODE" != 'daemon' ]; then + return; + fi; + # + # We can only afford to clean the MSP queues if running daemon mode, + # otherwise, there is a chance that a cronjob might still be using + # the queue... Thats also why we don't clean the MTA queues herein. + #clean_queues /var/spool/mqueue-client; + # + # cd to a safe place to stash core files... + cd $MSP_ROOT; + $START_MSP_CMD -- \ + $MSP_A $MSP_L -q${MSP_INTERVAL}m $MSP_PARMS $MISC_PARMS & + }; + +start_sendmail () { + start_mta; + if check_msp; then + start_msp; + fi; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# enhanced sendmail reload +#------------------------------------------------------------------------------ +reload_mta () { + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # reload (signal -HUP) is *much* better/faster than stop/start + # + # Mark restarted for communication betwixt here and /etc/mail/Makefile + touch $STAMP_DIR/reload; + # + # If not running, just start it... + if ! is_running mta; then + start_mta; + fi; + # + # Is running, must signal it... + $SIGNAL_MTAL_CMD --signal HUP --oknodo --quiet || true; + sleep 2; + chown root:root $MTA_ROOT/smsocket; + chmod 0666 $MTA_ROOT/smsocket; + # + # Check for split daemon mode (separate listener/queue runner) + if [ "$SPLIT_DAEMON" -eq 1 ]; then + $SIGNAL_MTAQ_CMD --signal HUP --oknodo --quiet || true; + fi; + }; + +reload_msp () { + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # reload (signal -HUP) is *much* better/faster than stop/start + # + # If not running, just start it... + if ! is_running msp; then + start_msp; + fi; + # + # Is running, must signal it... + $SIGNAL_MSP_CMD --signal HUP --oknodo --quiet || true; + }; + +reload_sendmail () { + reload_mta; + if check_msp; then + reload_msp; + fi; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# enhanced sendmail shutdown +#------------------------------------------------------------------------------ +stop_mta () { + local cnt; + stopped=0; + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # If not running, don't stop it... + if ! is_running mta; then + return; + fi; + # + # Is running, must stop it... + $STOP_MTAL_CMD --signal TERM --quiet --oknodo > /dev/null; + # + # Now we have to wait until sendmail has _really_ stopped. + # + sleep 2; + if $STOP_MTAL_CMD --signal TERM --quiet > /dev/null; then + echo -n 'Waiting .'; + cnt=0; + while $STOP_MTAL_CMD --signal TERM --quiet > /dev/null; do + cnt=`expr $cnt + 1`; + if [ $cnt -gt 60 ]; then + # + # Waited 120 seconds now. Fail. + # + echo -n ' Failed '; + stopped=1; + break; + fi; + sleep 2; + echo -n '.'; + done; + echo -n ' Done '; + fi; + # Remove pidfile iff stopped + if ! $STOP_MTAL_CMD --signal TERM --quiet > /dev/null; then + rm -f "$MTAL_PIDFILE"; + fi + }; + +stop_queue () { + local cnt; + stopped=0; + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # If not running, don't stop it... + if ! is_running queue; then + return; + fi; + # + # Is running, must stop it... + $STOP_MTAQ_CMD --signal TERM --quiet --oknodo > /dev/null; + # + # Now we have to wait until sendmail has _really_ stopped. + # + sleep 2; + if $STOP_MTAQ_CMD --signal TERM --quiet > /dev/null; then + echo -n 'Waiting .'; + cnt=0; + while $STOP_MTAQ_CMD --signal TERM --quiet > /dev/null; do + cnt=`expr $cnt + 1`; + if [ $cnt -gt 60 ]; then + # + # Waited 120 seconds now. Fail. + # + echo -n ' Failed '; + stopped=1; + break; + fi; + sleep 2; + echo -n '.'; + done; + echo -n ' Done '; + fi; + # Remove pidfile iff stopped + if ! $STOP_MTAQ_CMD --signal TERM --quiet > /dev/null; then + rm -f "$MTAQ_PIDFILE"; + fi + }; + +stop_msp () { + local cnt; + stopped=0; + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # If not running, don't stop it... + if ! is_running msp; then + return; + fi; + # + # Is running, must stop it... + $STOP_MSP_CMD --signal TERM --quiet --oknodo > /dev/null; + # + # Now we have to wait until sendmail has _really_ stopped. + # + sleep 2; + if $STOP_MSP_CMD --signal TERM --quiet > /dev/null; then + echo -n 'Waiting .'; + cnt=0; + while $STOP_MSP_CMD --signal TERM --quiet > /dev/null; do + cnt=`expr $cnt + 1`; + if [ $cnt -gt 60 ]; then + # + # Waited 120 seconds now. Fail. + # + echo -n ' Failed '; + stopped=1; + break; + fi; + sleep 2; + echo -n '.'; + done; + echo -n ' Done '; + fi; + # Remove pidfile iff stopped + if ! $STOP_MSP_CMD --signal TERM --quiet > /dev/null; then + rm -f "$MSP_PIDFILE"; + fi; + }; + +stop_sendmail () { + if check_msp; then + stop_msp; + fi; + stop_mta; + stop_queue; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# Check to see if sendmail is running +#------------------------------------------------------------------------------ +is_running () { + local result; + result=1; + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # Determine proper pidfile to check + PIDFILE=$(echo "$1" | tr '[:upper:]' '[:lower:]'); + case $PIDFILE in + mta) + PIDFILE="$MTAL_PIDFILE"; + ;; + queue) + PIDFILE="$MTAQ_PIDFILE"; + ;; + msp) + PIDFILE="$MSP_PIDFILE"; + ;; + *) + PIDFILE="$1"; + ;; + esac; + # + # If no pidfile, not running + # Extract pid/command and see if still running + # Remove pidfile if app didn't + if [ -s $PIDFILE ]; then + PID=`head -n 1 $PIDFILE 2>/dev/null`; + COMMAND=`tail -n 1 $PIDFILE`; + if [ ! -z "`ps --no-heading $PID`" ]; then + result=0; + else + rm -f $PIDFILE; + fi; + fi; + return $result; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# Check to see if running split service (MTA, MSP) +# Must be at 8.12.0+ for this support +#------------------------------------------------------------------------------ +check_msp () { + local result; + result=1; + if [ ! -f @datadir@/sendmail/cf/feature/msp.m4 ]; then + result=1; + elif [ -s @sysconfdir@/mail/submit.cf \ + -a -s @sysconfdir@/mail/submit.mc ]; then + if grep -qEe "^[[:space:]]*\`?FEATURE\([[:space:]]*\`?msp" \ + @sysconfdir@/mail/submit.mc; then + result=0; + fi; + fi; + return $result; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# Miscellaneous sendmail command support for MSP/MTA split +# mailstats, mailq, runq +#------------------------------------------------------------------------------ +newaliases () { + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + $MTA_COMMAND $MTA_A -bi $*; + }; + +hoststat () { + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + $MTA_COMMAND $MTA_A -bh $*; + }; + +purgestat () { + local parms; + parms=$(echo "$1" | tr '[:upper:]' '[:lower:]'); + case $parms in + n*) # Now + parms='-O Timeout.hoststatus=1s'; + shift; + ;; + *) + parms=''; + ;; + esac; + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + $MTA_COMMAND $MTA_A -bH $parms $*; + }; + +mailstats () { + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + #if running split service, show the client status first + if check_msp; then + echo 'MSP statistics...'; + #check if we have a status file for the MSP + statusfile=$(grep -Ee '^O StatusFile=/.*' \ + @sysconfdir@/mail/submit.cf | cut -d= -f2); + if [ -n $statusfile ]; then + @libexecdir@/mailstats -C \ + @sysconfdir@/mail/submit.cf $* || true; + fi; + echo 'MTA statistics...'; + fi; + #check if we have a status file for the MTA + statusfile=$(grep -Ee '^O StatusFile=/.*' \ + @sysconfdir@/mail/sendmail.cf | cut -d= -f2); + if [ -n $statusfile ]; then + @libexecdir@/mailstats $* || true; + fi; + }; + +mailq () { + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + # if running split service, show the client queues first + if check_msp; then + echo 'MSP Queue status...'; + # + # Check to see if shared memory is in use (8.12.0+) + if grep -qEe "^[[:space:]]*\`?define\(\`?confSHAREDMEMORYKEY'?[[:space:]]*,[[:space:]]*\`?0*[1-9]+[0-9]*'?[[:space:]]*\)" \ + @sysconfdir@/mail/submit.mc; then + $MSP_COMMAND -bP || true; + fi; + $MSP_COMMAND -bp $MSP_A $MISC_PARMS $* || true; + echo 'MTA Queue status...'; + fi; + # + # Check to see if shared memory is in use (8.12.0+) + if grep -qEe "^[[:space:]]*\`?define\(\`?confSHAREDMEMORYKEY'?[[:space:]]*,[[:space:]]*\`?0*[1-9]+[0-9]*'?[[:space:]]*\)" \ + @sysconfdir@/mail/sendmail.mc; then + $MTA_COMMAND -bP || true; + fi; + $MTA_COMMAND -bp $MTA_A $MISC_PARMS $* || true; + }; + +runq () { + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + # if running split service, run the client queues first + if check_msp; then + echo 'Running the MSP queue...'; + $MSP_COMMAND -q $MSP_A \ + $MSP_L_QUEUE $MSP_PARMS $MISC_PARMS $* || true; + echo 'Running the MTA queues...'; + fi; + if [ "$SPLIT_DAEMON" -eq 0 ]; then + $MTA_COMMAND -q $MTA_A \ + $MTAL_L_RUNQ $QUEUE_PARMS $MISC_PARMS $* || true; + else + $MTA_COMMAND -q $MTA_A \ + $MTAQ_L_RUNQ $QUEUE_PARMS $MISC_PARMS $* || true; + fi; + }; + +control () { + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + local parms; + parms="$*"; + if [ -z "$parms" ]; then + parms='help'; + fi; + if is_running mta; then + @datadir@/sendmail/smcontrol.pl $parms; + else + echo 'MTA: is not running'; + fi; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# Print status of running job(s) +#------------------------------------------------------------------------------ +status () { + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + # if running split service, check the client status first + if check_msp; then + if is_running msp; then + echo "MSP: $PID $COMMAND"; + ps -fwp $PID; + if [ -S ${MSP_ROOT}/smcontrol ]; then + @datadir@/sendmail/smcontrol.pl \ + -f ${MSP_ROOT}/smcontrol status; + fi; + elif [ $MSP_MODE = 'cron' ]; then + echo 'MSP: is run via cron'; + elif [ $MSP_MODE = 'none' ]; then + echo 'MSP: is disabled'; + else + echo 'MSP: is not running'; + fi; + fi; + # + # Check MTA listener + if is_running mta; then + echo "MTA: $PID $COMMAND"; + ps -fwp $PID; + if [ -S ${MTA_ROOT}/smcontrol ]; then + @datadir@/sendmail/smcontrol.pl status; + fi; + elif [ $DAEMON_MODE = 'inetd' ]; then + echo 'MTA: is run via inetd'; + elif [ $DAEMON_MODE = 'none' ]; then + echo 'MTA: is disabled'; + else + echo 'MTA: is not running'; + fi; + # + # Check for split daemon mode (separate listener/queue runner) + if [ "$SPLIT_DAEMON" -eq 0 ]; then + echo "QUE: Same as MTA"; + elif is_running queue; then + echo "QUE: $PID $COMMAND"; + ps -fwp $PID; + elif [ $QUEUE_MODE = 'cron' ]; then + echo 'QUE: is run via cron'; + elif [ $QUEUE_MODE = 'none' ]; then + echo 'QUE: is disabled'; + else + echo 'QUE: is not running'; + fi; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# Cronjob handling +#------------------------------------------------------------------------------ +cron_mta () { + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + # If cron not needed, don't do queue running (though it wouldn't hurt) + if [ $QUEUE_MODE = 'cron' ]; then + # + # If running a split (MTA/MSP) setup, we need to make sure that + # messages not immediately accepted by the MTA get delivered. + # Only run the MSP queue if MSP_MODE=none + if check_msp; then + if [ $MSP_MODE = 'none' ]; then + # Make sure only *ONE* cronjob at a time + if [ ! -f $STAMP_DIR/cron_msp ]; then + touch $STAMP_DIR/cron_msp; + #clean_queues /var/spool/mqueue-client; + $MSP_COMMAND -q $MSP_A $MSP_L_QUEUE \ + $MSP_PARMS $MISC_PARMS \ + $CRON_PARMS || true; + rm -f $STAMP_DIR/cron_msp; + fi; + fi; + fi; + + # Make sure only *ONE* cronjob at a time + if [ ! -f $STAMP_DIR/cron_mta ]; then + touch $STAMP_DIR/cron_mta; + $MTA_COMMAND -q $MTA_A $MTAL_L_QUEUE \ + $QUEUE_PARMS $MISC_PARMS $CRON_PARMS || true; + rm -f $STAMP_DIR/cron_mta; + fi; + fi; + }; + +cron_msp () { + # + # Make sure @localstatedir@/run/sendmail/ exists + check_dirs; + # + # Obtain parameters IFF needed + if [ -z "$SM_Get_Parameters" ]; then + Get_Parameters; + fi; + # + # If cron not needed, don't do queue running (though it wouldn't hurt) + if [ $MSP_MODE = 'cron' ]; then + # + # If running a split (MTA/MSP) setup, we need to make sure that + # messages not immediately accepted by the MTA get delivered. + if check_msp; then + # Make sure only *ONE* cronjob at a time + if [ ! -f $STAMP_DIR/cron_msp ]; then + touch $STAMP_DIR/cron_msp; + #clean_queues /var/spool/mqueue-client; + $MSP_COMMAND -q $MSP_A $MSP_L_QUEUE \ + $MSP_PARMS $MISC_PARMS \ + $CRON_PARMS || true; + rm -f $STAMP_DIR/cron_msp; + fi; + fi; + fi; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# Determine how to run sendmail mta daemon +# * No daemon +# * As listener +# * As queue runner +# * As both listener and queue runner +#------------------------------------------------------------------------------ +daemon_check () { + local run_daemon; + # + # Skip daemon run for the following: + # * sendmail hasn't been configured + # * smptd, a firewall frontend for sendmail, is installed + # * DAEMON_MODE = (none | inet) & QUEUE_MODE = (none | cron) + if [ ! -s @sysconfdir@/mail/sendmail.cf ] || \ + [ ! -s @sysconfdir@/mail/sendmail.mc ]; then + echo 'sendmail has not been configured, not started.'; + echo 'To configure sendmail, type sendmailconfig'; + exit 1; + elif [ -x $SMTPD ]; then + echo 'sendmail mta daemon not needed, not started.'; + exit 0; + fi; + + MTAL_PARMS="$MTA_A $MTAL_L"; + MTAQ_PARMS="$MTA_A $MTAQ_L"; + run_daemon=3; + + case "$DAEMON_MODE" in + none* | \ + inetd*) + run_daemon=`expr $run_daemon - 1`; + ;; + + daemon* | \ + *) + MTAL_PARMS="$MTAL_PARMS -bd $DAEMON_PARMS"; + ;; + esac; + + case "$QUEUE_MODE" in + none* | \ + cron*) + run_daemon=`expr $run_daemon - 1`; + ;; + + daemon* | \ + *) + # Check for split daemon mode (separate listener/queue runner) + if [ $SPLIT_DAEMON -eq 0 ]; then + MTAL_PARMS="$MTAL_PARMS -q${QUEUE_INTERVAL}m"; + MTAL_PARMS="$MTAL_PARMS $QUEUE_PARMS"; + else + MTAQ_PARMS="$MTAQ_PARMS -q${QUEUE_INTERVAL}m"; + MTAQ_PARMS="$MTAQ_PARMS $QUEUE_PARMS"; + fi; + ;; + esac; + + # Add any miscellanous (ie debugging) parameters + MTAL_PARMS="$MTAL_PARMS $MISC_PARMS"; + MTAQ_PARMS="$MTAQ_PARMS $MISC_PARMS"; + + # Add PidFile override for MTA queue runner + MTAQ_PARMS="$MTAQ_PARMS -O PidFile=$MTAQ_PIDFILE"; + + if [ $run_daemon -lt 2 ]; then + echo 'sendmail listen/queue daemon not desired.'; + exit 0; + fi; + }; +#------------------------------------------------------------------------------ + + +#------------------------------------------------------------------------------ +# Clean sendmail queues (somewhat): does *not* support split qf/df/xf dirs. +# NOTE: This whole thing sucks with queue-groups, need to redo it!!! +# NOTE: Check for race conditions betwixt this code and queue-runners +#------------------------------------------------------------------------------ +clean_queues () { + local QUEUE_ROOT QUEUE QUIET + # Obtain queue root directory + if [ -z "$1" ]; then + QUEUE_ROOT=/var/spool/mqueue + QUEUE=/var/spool/mqueue + QUIET='' + else + QUEUE_ROOT="$1" + QUEUE="$1" + QUIET='1' + fi + # remove lock files left because of kill/crash + # rm -f $QUEUE/[lnx]f* doesn't work with a plethora of files ;-( + for i in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \ + a b c d e f g h i j k l m n o p q r s t u v w x y z; do + rm -f $QUEUE/[lnx]f${i}* + done + # remove zero length qf files + #for qffile in $QUEUE/qf*; do + for qffile in $(find $QUEUE_ROOT -type f -name 'qf*'); do + if [ -r "$qffile" -a ! -s "$qffile" ]; then + if [ ! -z "$QUIET" ]; then + echo -n "<zero: $qffile> "; fi + rm -f "$qffile" + fi + done + # rename tf files to be qf if the qf does not exist + for tffile in $QUEUE/tf*; do + qffile=`echo "$tffile" | sed 's/t/q/'` + if [ -r "$tffile" -a ! -f "$qffile" ]; then + if [ ! -z "$QUIET" ]; then + echo -n "<recovering: $tffile> "; fi + mv "$tffile" "$qffile" + elif [ -f "$tffile" ]; then + echo -n "<extra: $tffile> " + rm -f "$tffile" + fi + done + # remove df files with no corresponding qf files + for dffile in $QUEUE/df*; do + qffile=`echo "$dffile" | sed 's/d/q/'` + if [ -r "$dffile" -a ! -f "$qffile" ]; then + if [ ! -s "$dffile" ]; then + rm -f "$dffile" + else + if [ ! -z "$QUIET" ]; then + echo -n "<incomplete: $dffile> "; fi + mv "$dffile" `echo $dffile | sed 's/d/D/'` + fi + fi + done + # announce files that have been saved during disaster recovery + for xffile in $QUEUE/[A-Z]f*; do + if [ -f "$xffile" ]; then + if [ ! -z "$QUIET" ]; then + echo -n "<panic: $xffile> "; fi + fi + done + } +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# check_dirs: Make sure @localstatedir@/run/sendmail/{mta,msp,stampdir} exist +#------------------------------------------------------------------------------ +check_dirs () { + if [ ! -d "${SENDMAIL_ROOT}" ]; then + mkdir -p "${SENDMAIL_ROOT}"; + chown root:smmsp "${SENDMAIL_ROOT}"; + chmod 02750 "${SENDMAIL_ROOT}"; + fi; + if [ ! -d "${MTA_ROOT}" ]; then + mkdir -p "${MTA_ROOT}"; + chown root:smmsp "${MTA_ROOT}"; + chmod 02750 "${MTA_ROOT}"; + fi; + if [ ! -d "${MSP_ROOT}" ]; then + mkdir -p "${MSP_ROOT}"; + chown smmsp:smmsp "${MSP_ROOT}"; + chmod 02770 "${MSP_ROOT}"; + fi; + if [ ! -d "${STAMP_DIR}" ]; then + mkdir -p "${STAMP_DIR}"; + chown root:smmsp "${STAMP_DIR}"; + chmod 02770 "${STAMP_DIR}"; + fi; + } + + +#------------------------------------------------------------------------------ +# Handle being called via an alias +#------------------------------------------------------------------------------ +case $(basename $0) in + newaliases) + newaliases $*; + exit $?; + ;; + hoststat) + hoststat $*; + exit $?; + ;; + purgestat) + purgestat $*; + exit $?; + ;; + mailstats) + mailstats $*; + exit $?; + ;; + mailq) + mailq $*; + exit $?; + ;; + runq) + runq $*; + exit $?; + ;; + control|smcontrol) + control $*; + exit $?; + ;; + *) + ;; + esac; + +#------------------------------------------------------------------------------ +# Handle being called via /etc/init.d/sendmail or directly +#------------------------------------------------------------------------------ + +# Some requisite initialization +Get_Parameters; + +# Ok, why are we here... +case "$1" in + + #----------------------------------------------------------------------- + # Debian required/optional targets: + #----------------------------------------------------------------------- + start) + echo -n 'Starting Mail Transport Agent: sendmail'; + start_sendmail; + echo '.' + ;; + + stop|force-stop) + echo -n 'Stopping Mail Transport Agent: sendmail'; + stop_sendmail; + echo '.' + ;; + + restart) + echo -n 'Restarting Transport Agent: sendmail'; + # reload is equivalent (but faster) than stop/start ! + reload_sendmail; + echo '.'; + ;; + + restart-if-running) + if ! is_running mta && ! is_running msp; then + echo 'Mail Transport Agent: sendmail is not running'; + else + $0 restart; + fi; + ;; + + reload|force-reload) + echo -n 'Reloading Mail Transport Agent configuration: sendmail'; + reload_sendmail; + echo '.'; + ;; + + #----------------------------------------------------------------------- + # Local targets (sendmail commands/aliases) for MSP/MTA split support + # These targets will pass along any provided parameters + #----------------------------------------------------------------------- + newaliases) + shift; + newaliases $*; + ;; + + hoststat) + shift; + hoststat $*; + ;; + + purgestat) + shift; + purgestat $*; + ;; + + mailstats) + shift; + mailstats $*; + ;; + + mailq) + shift; + mailq $*; + ;; + + runq) + shift; + runq $*; + ;; + + control|smcontrol) + shift; + control $*; + ;; + + #----------------------------------------------------------------------- + # Local targets for extended support/debugging + #----------------------------------------------------------------------- + status) + shift; + status $*; + ;; + + debug) + # + # If not running, can't debug + if is_running msp; then + echo -n 'Dumping MSP state...'; + $SIGNAL_MSP_CMD --signal USR1; + echo 'done.'; + fi; + if is_running mta; then + echo -n 'Dumping MTA state...'; + $SIGNAL_MTAL_CMD --signal USR1; + echo 'done.'; + fi; + ;; + + clean|clean_que*|clean-que*) + # + # If running, don't clean the queues... + if is_running mta; then + echo 'MTA is running, queue cleaning ill advised...'; + else + echo -n 'Cleaning up the queues...'; + clean_queues; + echo 'done.'; + fi; + ;; + + #----------------------------------------------------------------------- + # Local targets for cronjob support + #----------------------------------------------------------------------- + cron-msp) + cron_msp; + ;; + + cron-mta) + cron_mta; + ;; + + #----------------------------------------------------------------------- + # Default target - bitch and moan + #----------------------------------------------------------------------- + *) + echo "Invalid command <$1>"; + echo "Usage: $0 <command>"; + echo ' Where <command> is one of the following'; + echo ' start|stop|restart|restart-if-running'; + echo ' reload|force-reload'; + echo ' newaliases|hoststat|purgestat|mailstats|mailq|runq|control'; + echo ' status|debug|clean'; + exit 1; + ;; + esac; + +exit 0; diff --git a/debian/local/sendmailconfig b/debian/local/sendmailconfig.in index 96e6c88..1c2cf1e 100644 --- a/debian/local/sendmailconfig +++ b/debian/local/sendmailconfig.in @@ -1,137 +1,147 @@ -#!/bin/sh +#!/bin/sh -e +#----------------------------------------------------------------------------- +# $Sendmail: sendmailconfig,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ # # Interactively configure Sendmail for Debian # +# Copyright (c) 1998-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# # Robert Leslie <rob@mars.org>, # Rick Nelson <cowboy@debian.org> +# +#----------------------------------------------------------------------------- +set -e; + +PATH='/usr/sbin:/usr/bin:/sbin:/bin'; +SENDMAIL_MC="@sysconfdir@/mail/sendmail.mc"; +SUBMIT_MC="@sysconfdir@/mail/submit.mc"; + +# Path to other sendmail helpers +if [ -x ./update_sendmail ]; then + sm_path='.'; +elif [ -x $(dirname $0)/update_sendmail ]; then + sm_path=$(dirname $0); +else + sm_path=@datadir@/sendmail; + fi; -PATH="/usr/sbin:/usr/bin:/sbin:/bin" -FILE="/etc/mail/sendmail.mc" -#FILE="/u/src/sendmail/sendmail.mc" - -set +e -reload="yes" -umask 022 +set +e; +reload="yes"; +umask 022; #------------------------------------------------------------------------------ -while [ $# -gt 0 ] -do +while [ $# -gt 0 ]; do case "$1" in - --no-reload) - reload="" - shift - ;; - - *) - echo "Usage: $0 [--no-reload]" >&2 - exit 1 - ;; - esac -done + --no-reload) + reload=""; + shift; + ;; + + *) + echo "Usage: $0 [--no-reload]" >&2; + exit 1; + ;; + esac; + done; #------------------------------------------------------------------------------ descrip() { - echo "" - echo "$1" - echo "$1" | sed -e 's/./-/g' - cat - - echo "" -} + echo ''; + echo "$1"; + echo "$1" | sed -e 's/./-/g'; + cat -; + echo ''; + }; yesno() { - local N="N" Y="Y" - local q="$1" def=$(eval "echo -n \$$2") + local N='N' Y='Y'; + local q="$1" def=$(eval "echo -n \$$2"); - while : - do - echo -n "$q? [$def] " - read REPLY - REPLY=$(echo -n "$REPLY" | sed -e "s/^\ *//" -e "s/^\t*//") - test -n "$REPLY" || REPLY="$def" + while :; do + echo -n "$q? [$def] "; + read REPLY; + REPLY=$(echo -n "$REPLY" | sed -e "s/^\ *//" -e "s/^\t*//"); + test -n "$REPLY" || REPLY="$def"; case "$REPLY" in [Yy]*) - echo yes > /dev/null - eval "$2=\"Y\"" - return 0 - ;; - + echo yes > /dev/null; + eval "$2=\"Y\""; + return 0; + ;; [Nn]*) - echo no > /dev/null - eval "$2=\"N\"" - return 1 - ;; - esac - done -} + echo no > /dev/null; + eval "$2=\"N\""; + return 1; + ;; + esac; + done; + }; input() { - local q="$1" def=$(eval "echo -n \$$2") + local q="$1" def=$(eval "echo -n \$$2"); - echo -n "$q? [$def] " + echo -n "$q? [$def] "; read REPLY - REPLY=$(echo "$REPLY" | sed -e 's/^[ ]*//' -e 's/[ ]*$//' | cat) - test -n "$REPLY" || REPLY="$def" + REPLY=$(echo "$REPLY" | sed -e 's/^[ ]*//' -e 's/[ ]*$//' | cat); + test -n "$REPLY" || REPLY="$def"; - if [ NONE = "$3" ]; then - test NONE != "$REPLY" || REPLY="" - fi + if [ "NONE" = "$3" ]; then + case "$REPLY" in + [NnOoNnEe]) + REPLY=''; + ;; + esac; + fi; - eval "$2=\"$REPLY\"" -} + eval "$2=\"$REPLY\""; + }; testconfig() { - 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 - if [ -e /etc/init.d/netbase ]; then - /etc/init.d/netbase reload >/dev/null - else - /etc/init.d/inetd reload >/dev/null - fi -} + CONFIG=$(grep -Ee "^[[:space:]]*$1" $SENDMAIL_MC 2>/dev/null); + }; makecf() { - echo "Updating sendmail databases ..." - /usr/share/sendmail/updatedb - - testwrap - if [ "$WRAP" = "" ]; then - updatewrap - fi - - if [ "$reload" ] && \ - yesno "Reload the running sendmail now with the new configuration" Y - then - echo "Reloading sendmail ..." - /etc/init.d/sendmail reload >/dev/null - fi + if [ -x $sm_path/update_sendmail ]; then + echo "Updating sendmail environment ..."; + $sm_path/update_sendmail || true; + fi; + + if [ "$reload" ] && \ + yesno \ + "Reload the running sendmail now with the new configuration" Y + then + echo "Reloading sendmail ..."; + @sysconfdir@/init.d/sendmail reload >/dev/null; + fi; } #------------------------------------------------------------------------------ -if [ -f $FILE ]; then - if yesno "Configure sendmail with the existing /etc/mail/sendmail.mc" Y +if [ -f $SENDMAIL_MC ]; then + if yesno "Configure sendmail with the existing @sysconfdir@/mail/sendmail.conf" Y + then + if ! $sm_path/update_conf; then + echo "Correct @sysconfdir@/mail/sendmail.conf before continuing."; + exit 1; + fi; + else + echo "Edit @sysconfdir@/mail/sendmail.conf and reissue $0."; + exit 0; + fi; + if yesno "Configure sendmail with the existing $SENDMAIL_MC" Y then - makecf - exit 0 - fi -fi + makecf; + exit 0; + fi; + fi; ############################################################################### -exec 3>$FILE.new -trap "rm -f $FILE.new" 0 +exec 3>$SENDMAIL_MC.new; +trap "rm -f $SENDMAIL_MC.new" 0; ############################################################################### @@ -141,11 +151,13 @@ system. Default values are determined either by your existing configuration or from common usage. EOT -echo -n "Press [ENTER] " -read REPLY +echo -n "Press [ENTER] "; +read REPLY; -cat /usr/share/sendmail/sendmail.cf/cf/debproto.mc >&3 -echo "LOCAL_CONFIG" >&3 +cat @datadir@/sendmail/cf/debian/sendmail.mc >&3; +cp -a @datadir@/sendmail/cf/debian/submit.mc \ + $SUBMIT_MC.new; +echo "LOCAL_CONFIG" >&3; ############################################################################### @@ -156,50 +168,35 @@ name will be used by other programs besides sendmail; it should be the single, full domain name (FQDN) from which mail will appear to originate. EOT -mailname=$(cat /etc/mailname 2>/dev/null || hostname --fqdn) -input "Mail name" mailname +mailname=$(cat @sysconfdir@/mailname 2>/dev/null || hostname --fqdn); +input "Mail name" mailname; -echo "$mailname" >/etc/mailname +echo "$mailname" >@sysconfdir@/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 to disable it. +To remove a prior name, use \`NONE'. +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 +! testconfig "FEATURE\(\`?nullclient" || + nullclient=$(echo -n "$CONFIG" | sed -e 's/[^,]*, *\([^)]*\).*/\1/'); + +input "Null client forward host" nullclient "" NONE; + +if [ ! -z "$nullclient" ]; then + echo "FEATURE(\`nullclient', $nullclient)dnl" >&3; + fi; + +if [ -z "$nullclient" ]; then ############################################################################### descrip "Smart Host" <<EOT @@ -209,25 +206,26 @@ 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. +To remove a prior name, use \`NONE'. EOT -smarthost="" -if [ -n "$nullclient" ]; then - smarthost="$nullclient" - fi -! testconfig "define(\`SMART_HOST'" || - smarthost=$(echo -n "$CONFIG" | sed -e 's/[^:]*:*\([^)]*\).*/\1/') -input "Smart Host:" smarthost "" - -test -z "$smarthost" || echo "define(\`SMART_HOST', \`$smarthost')dnl" >&3 -if [ -n "$nullclient" -a ! -z "$smarthost" ]; then - echo "undefine(\`ALIAS_FILE')dnl" >&3 - echo "define(\`confFORWARD_PATH', \`')dnl" >&3 - echo "define(\`MAIL_HUB', \`$smarthost')dnl" >&3 - echo "MASQUERADE_AS(\`$smarthost')dnl" >&3 - echo "FEATURE(\`allmasquerade')dnl" >&3 - echo "FEATURE(\`masquerade_envelope')dnl" >&3 - fi +smarthost=""; +#if [ -n "$nullclient" ]; then +# smarthost="$nullclient" +# fi +! testconfig "define\(\`?SMART_HOST" || + smarthost=$(echo -n "$CONFIG" | sed -e 's/[^:]*:*\([^)]*\).*/\1/'); +input "Smart Host:" smarthost "" NONE; + +test -z "$smarthost" || echo "define(\`SMART_HOST', \`$smarthost')dnl" >&3; +#if [ -n "$nullclient" -a ! -z "$smarthost" ]; then +# echo "undefine(\`ALIAS_FILE')dnl" >&3 +# echo "define(\`confFORWARD_PATH', \`')dnl" >&3 +# echo "define(\`MAIL_HUB', \`$smarthost')dnl" >&3 +# echo "MASQUERADE_AS(\`$smarthost')dnl" >&3 +# echo "FEATURE(\`allmasquerade')dnl" >&3 +# echo "FEATURE(\`masquerade_envelope')dnl" >&3 +# fi ############################################################################### descrip "Address Canonification" <<EOT @@ -246,16 +244,11 @@ rather than this host. EOT -nocanonify="N" -! testconfig "FEATURE(nocanonify)" || nocanonify="Y" - -! yesno "Disable address canonification" nocanonify || - echo "FEATURE(nocanonify)dnl" >&3 - -############################################################################### +nocanonify="N"; +! testconfig "FEATURE\(\`?nocanonify" || nocanonify="Y"; -if [ -z "$nullclient" ] -then +! yesno "Disable address canonification" nocanonify || \ + echo "FEATURE(\`nocanonify')dnl" >&3; ############################################################################### @@ -265,13 +258,12 @@ SMTP mailer. Even if you don't plan to exchange mail with other computers, it is still a good idea to enable this so local programs can use it. EOT -smtp="Y" -if [ -f $FILE ] -then - testconfig "MAILER(smtp)" || smtp="N" -fi +smtp="Y"; +if [ -f $SENDMAIL_MC ]; then + testconfig "MAILER\(\`?smtp" || smtp="N"; +fi; -yesno "Enable the SMTP mailer" smtp || true +yesno "Enable the SMTP mailer" smtp || true; ############################################################################### @@ -280,14 +272,13 @@ If you want mail envelopes (as well as mail headers) to appear to come from \`$mailname', you can enable this option. EOT -masqenvelope="Y" -if [ -f $FILE ] -then - testconfig "FEATURE(masquerade_envelope)" || masqenvelope="N" -fi +masqenvelope="Y"; +if [ -f $SENDMAIL_MC ]; then + testconfig "FEATURE\(\`?masquerade_envelope" || masqenvelope="N"; +fi; -! yesno "Masquerade envelopes" masqenvelope || - echo "FEATURE(masquerade_envelope)dnl" >&3 +! yesno "Masquerade envelopes" masqenvelope || \ + echo "FEATURE(\`masquerade_envelope')dnl" >&3; ############################################################################### @@ -303,11 +294,23 @@ the ENTIRE namespace of \`$mailname' supersets all the local entries. If in doubt, it is safe to leave this option disabled. EOT -allmasquerade="N" -! testconfig "FEATURE(allmasquerade)" || allmasquerade="Y" +allmasquerade="N"; +! testconfig "FEATURE\(\`?allmasquerade" || allmasquerade="Y"; -! yesno "All masquerade" allmasquerade || - echo "FEATURE(allmasquerade)dnl" >&3 +! yesno "All masquerade" allmasquerade || \ + echo "FEATURE(\`allmasquerade')dnl" >&3; + +############################################################################### + +descrip "Dont masquerade mail to local users" <<EOT +Send mail to local recipients without masquerading. +EOT + +local_no_masquerade="N"; +! testconfig "FEATURE\(\`?local_no_masquerade" || local_no_masquerade="Y"; + +! yesno "Dont masquerade local" local_no_masquerade || + echo "FEATURE(\`local_no_masquerade')dnl" >&3; ############################################################################### @@ -316,11 +319,11 @@ If enabled, the local host domain is included even on locally delivered mail. Normally it is not added unless it is already present. EOT -alwaysdomain="N" -! testconfig "FEATURE(always_add_domain)" || alwaysdomain="Y" +alwaysdomain="N"; +! testconfig "FEATURE\(\`?always_add_domain" || alwaysdomain="Y"; -! yesno "Always add domain" alwaysdomain || - echo "FEATURE(always_add_domain)dnl" >&3 +! yesno "Always add domain" alwaysdomain || \ + echo "FEATURE(\`always_add_domain')dnl" >&3; ############################################################################### @@ -332,14 +335,15 @@ generally requires that) mail for \`$mailname' is MXed to another host. If in doubt, it is safe to leave this option enabled. EOT -acceptmailname="Y" -if [ -f $FILE ] -then - testconfig "^Cw.*$mailname" || acceptmailname="N" -fi +acceptmailname="Y"; +if [ -f $SENDMAIL_MC ]; then + testconfig "^Cw.*$mailname" || acceptmailname="N"; +fi; -yesno "Accept mail for \`$mailname'" acceptmailname || true -test "N" = "$acceptmailname" || echo "Cw$mailname" >&3 +yesno "Accept mail for \`$mailname'" acceptmailname || true; +test "N" = "$acceptmailname" || \ + echo "LOCAL_CONFIG +Cw$mailname" >&3; ############################################################################### @@ -347,30 +351,27 @@ descrip "Alternate Names" <<EOT In addition to the canonical mail name \`$mailname', you can add any number of additional alternate names to recognize for receiving mail. If other hosts are MXed to you for local mail, this is where you should list -them. This list is saved into the file /etc/mail/sendmail.cw so it can be -changed later as needed. +them. This list is saved into the file @sysconfdir@/mail/local-host-names +so it can be changed later as needed. To answer this question, separate each alternate name with a space, or answer \`NONE' to eliminate all alternate names. EOT -if [ -f /etc/mail/local-host-names ]; then - cw_file="/etc/mail/local-host-names" -else - cw_file="/etc/mail/sendmail.cw" - fi +cw_file="@sysconfdir@/mail/local-host-names"; altnames=$(cat "$cw_file" 2>/dev/null | tr -s '\n \t' ' ' | - sed -e 's/^ *//' -e 's/ *$//') -input "Alternate names" altnames NONE + sed -e 's/^ *//' -e 's/ *$//'); +input "Alternate names" altnames NONE; -if [ -n "$altnames" ] -then - echo "$altnames" | tr -s ' \t' '\n' >$cw_file +if [ -n "$altnames" ]; then + echo "$altnames" | tr -s ' \t' '\n' >$cw_file; else - cat /dev/null >$cw_file -fi + echo "localhost" >$cw_file; +fi; + chown root:smmsp $cw_file; + chmod 0644 $cw_file; -echo "FEATURE(use_cw_file)dnl" >&3 +echo "FEATURE(\`use_cw_file')dnl" >&3; ############################################################################### @@ -380,30 +381,27 @@ using the -f option without generating a warning message. If you have software such as Majordomo installed, you will want to include the usernames from such software here. Note that "root", "daemon", and "uucp" are included automatically and do not need to be specified. This list is saved into the -file /etc/mail/sendmail.ct so it can be changed later as needed. +file @sysconfdir@/mail/trusted-users so it can be changed later as needed. To answer this question, separate each username with a space, or answer \`NONE' to eliminate all usernames. EOT -if [ -f /etc/mail/trusted-users ]; then - ct_file="/etc/mail/trusted-users" -else - ct_file="/etc/mail/sendmail.ct" - fi - +ct_file="@sysconfdir@/mail/trusted-users"; trusted=$(cat "$ct_file" 2>/dev/null | tr -s '\n \t' ' ' | - sed -e 's/^ *//' -e 's/ *$//') -input "Trusted users" trusted NONE + sed -e 's/^ *//' -e 's/ *$//'); +input "Trusted users" trusted NONE; -if [ -n "$trusted" ] -then - echo "$trusted" | tr -s ' \t' '\n' >$ct_file +if [ -n "$trusted" ]; then + echo "$trusted" | tr -s ' \t' '\n' >$ct_file; + chown root:smmsp $ct_file; + chmod 0644 $ct_file; else - cat /dev/null >$ct_file -fi + cat /dev/null >$ct_file; +fi; -echo "FEATURE(use_ct_file)dnl" >&3 +echo "FEATURE(\`use_ct_file')dnl" >&3; +echo "FEATURE(\`use_ct_file')dnl" >> $SUBMIT_MC.new; ############################################################################### @@ -413,10 +411,11 @@ If enabled, this feature will allow you to alias old names to an error but indicating the recipient's new address. EOT -redirect="N" -! testconfig "FEATURE(redirect)" || redirect="Y" +redirect="N"; +! testconfig "FEATURE\(\`?redirect" || redirect="Y"; -! yesno "Enable redirect option" redirect || echo "FEATURE(redirect)dnl" >&3 +! yesno "Enable redirect option" redirect || \ + echo "FEATURE(\`redirect')dnl" >&3; ############################################################################### @@ -425,18 +424,21 @@ Sendmail can be configured to be smart about UUCP addresses, or it can do nothing special with UUCP addresses at all. If you care about UUCP, you will need to do some additional configuration, perhaps outside of this script. -*** NOTE *** If you use a smart host, it is important that you say "Yes" +*** NOTE *** If you use a smart host or do any kind of forwarding (ie +LUSER_RELAY and LOCAL_RELAY), it is important that you say "Yes" here to prevent a multi-level relay hole - unless you know for *SURE* that your smart-host does not deal with UUCP addresses. + +(Be safe and just say Y) EOT -uucp="N" -if [ -f $FILE ] -then - testconfig "FEATURE(nouucp)" || uucp="Y" -fi +uucp="Y"; +if [ -f $SENDMAIL_MC ]; then + testconfig "FEATURE\(\`?nouucp" || uucp="Y"; +fi; -yesno "Enable UUCP addressing" uucp || echo "FEATURE(nouucp)dnl" >&3 +yesno "Enable UUCP addressing" uucp || \ + echo "FEATURE(\`nouucp', \`reject')dnl" >&3; ############################################################################### @@ -449,10 +451,11 @@ a distinct domain-wide namespace. If in doubt, it is safe to leave this option disabled. EOT -sticky="N" -! testconfig "FEATURE(stickyhost)" || sticky="Y" +sticky="N"; +! testconfig "FEATURE\(\`?stickyhost" || sticky="Y"; -! yesno "Enable sticky host option" sticky || echo "FEATURE(stickyhost)dnl" >&3 +! yesno "Enable sticky host option" sticky || \ + echo "FEATURE(\`stickyhost')dnl" >&3; ############################################################################### @@ -461,15 +464,16 @@ If you are directly connected to the Internet and have access to a domain name server, you should enable this option. EOT -dns="Y" -! testconfig "FEATURE(nodns)" || dns="N" +dns="Y"; +! testconfig "FEATURE\(\`?nodns" || dns="N"; +! testconfig "HACK\(\`?nodns" || dns="N"; -yesno "Enable DNS" dns || echo "FEATURE(nodns)dnl" >&3 +yesno "Enable DNS" dns || \ + echo "HACK(\`nodns')dnl" >&3; ############################################################################### -if [ Y = "$dns" ] -then +if [ Y = "$dns" ]; then ############################################################################### @@ -482,30 +486,30 @@ MX records. If you have a wildcard MX record that matches your domain, you cannot use this feature. EOT -bestmxlocal="N" -! testconfig "FEATURE(bestmx_is_local)" || bestmxlocal="Y" +bestmxlocal="N"; +! testconfig "FEATURE\(\`?bestmx_is_local" || bestmxlocal="Y"; -! yesno "Assume best MX is local" bestmxlocal || - echo "FEATURE(bestmx_is_local)dnl" >&3 +! yesno "Assume best MX is local" bestmxlocal || \ + echo "FEATURE(\`bestmx_is_local')dnl" >&3; ############################################################################### -fi # finished DNS configuration +fi; # finished DNS configuration ############################################################################### descrip "Mailertable" <<EOT If enabled, this option causes sendmail to read mail routing rules from -the text file /etc/mail/mailertable. This is needed for unusual mailers like -ifmail and fax programs. -More information is in /usr/share/doc/sendmail/op.txt.gz. +the text file @sysconfdir@/mail/mailertable. This is needed for unusual mailers like +ifmail and fax programs. +More information is in @docdir@/sendmail-doc/op/op.txt.gz. EOT -mailertable="N" -! testconfig "FEATURE(mailertable" || mailertable="Y" +mailertable="N"; +! testconfig "FEATURE\(\`?mailertable" || mailertable="Y"; -! yesno "Enable the mailertable feature" mailertable || - echo "FEATURE(mailertable)dnl" >&3 +! yesno "Enable the mailertable feature" mailertable || \ + echo "FEATURE(\`mailertable')dnl" >&3; ############################################################################### @@ -517,11 +521,11 @@ in a special directory can be run. If you enable this option, please carefully read the smrsh(8) man page for further information. EOT -smrsh="N" -! testconfig "FEATURE(smrsh" || smrsh="Y" +smrsh="Y"; +! testconfig "FEATURE\(\'?smrsh" || smrsh="Y"; -! yesno "Use the Sendmail Restricted Shell (smrsh)" smrsh || - echo "FEATURE(smrsh, \`/usr/lib/sm.bin/smrsh')dnl" >&3 +! yesno "Use the Sendmail Restricted Shell (smrsh)" smrsh || \ + echo "FEATURE(\`smrsh', \`@libexecdir@/smrsh')dnl" >&3; ############################################################################### @@ -531,14 +535,14 @@ Usually this is \`MAILER-DAEMON' but it would not be unreasonable to change it to something such as \`postmaster'. EOT -daemon="MAILER-DAEMON" -! testconfig "confMAILER_NAME" || - daemon=$(echo -n "$CONFIG" | sed -e 's/[^,]*, *`\([^'"'"']*\).*/\1/') +daemon="MAILER-DAEMON"; +! testconfig "define\(\`?confMAILER_NAME" || + daemon=$(echo -n "$CONFIG" | sed -e 's/[^,]*, *`\([^'"'"']*\).*/\1/'); -input "Mailer name" daemon +input "Mailer name" daemon; test "MAILER-DAEMON" = "$daemon" || - echo "define(\`confMAILER_NAME', \`$daemon')dnl" >&3 + echo "define(\`confMAILER_NAME', \`$daemon')dnl" >&3; ############################################################################### @@ -547,11 +551,11 @@ Sendmail normally excludes the sender address from group expansion. Enabling this option will cause the sender to be included. EOT -metoo="N" -! testconfig "confME_TOO.*True" || metoo="Y" +metoo="N"; +! testconfig "define\(\`?confME_TOO.*True" || metoo="Y"; ! yesno "Enable me too option" metoo || - echo "define(\`confME_TOO', True)dnl" >&3 + echo "define(\`confME_TOO', True)dnl" >&3; ############################################################################### @@ -566,68 +570,79 @@ notifications are sent. Sendmail's defaults are 4 hours and 5 days (4h/5d), respectively, but many people feel warnings after only 4 hours are premature. EOT -qw="4h" -! testconfig "confTO_QUEUEWARN" || - qw=$(echo -n "$CONFIG" | sed -e 's/[^,]*, *`\([^'"'"']*\).*/\1/') +qw="4h"; +! testconfig "define\(\`?confTO_QUEUEWARN" || + qw=$(echo -n "$CONFIG" | sed -e 's/[^,]*, *`\([^'"'"']*\).*/\1/'); -qr="5d" -! testconfig "confTO_QUEUERETURN" || - qr=$(echo -n "$CONFIG" | sed -e 's/[^,]*, *`\([^'"'"']*\).*/\1/') +qr="5d"; +! testconfig "define\(\`?confTO_QUEUERETURN" || + qr=$(echo -n "$CONFIG" | sed -e 's/[^,]*, *`\([^'"'"']*\).*/\1/'); -timeouts="$qw/$qr" +timeouts="$qw/$qr"; -input "Message timeouts" timeouts +input "Message timeouts" timeouts; -qw=$(expr "$timeouts" : '\([^/]*\)/') -qr=$(expr "$timeouts" : '[^/]*/\(.*\)') +qw=$(expr "$timeouts" : '\([^/]*\)/'); +qr=$(expr "$timeouts" : '[^/]*/\(.*\)'); -test "4h" = "$qw" || echo "define(\`confTO_QUEUEWARN', \`$qw')dnl" >&3 -test "5d" = "$qr" || echo "define(\`confTO_QUEUERETURN', \`$qr')dnl" >&3 +test "4h" = "$qw" || echo "define(\`confTO_QUEUEWARN', \`$qw')dnl" >&3; +test "5d" = "$qr" || echo "define(\`confTO_QUEUERETURN', \`$qr')dnl" >&3; + +############################################################################### +# Support dialup configuration +cat <<-EOT >&3 +dnl # +dnl # Dialup/LAN connection overrides +dnl # +include(\`@sysconfdir@/mail/dialup.m4')dnl +include(\`@sysconfdir@/mail/provider.m4')dnl +dnl # +EOT ############################################################################### echo "MAILER_DEFINITIONS" >&3 echo "MAILER(local)dnl" >&3 -test "N" = "$smtp" || echo "MAILER(smtp)dnl" >&3 +test "N" = "$smtp" || echo "MAILER(smtp)dnl" >&3; ############################################################################### if [ -e /etc/ifmail/config ] && \ - [ -e /usr/share/sendmail/sendmail.cf/mailer/ifmail.m4 ]; + [ -e @datadir@/sendmail/cf/mailer/ifmail.m4 ]; then - echo "MAILER(ifmail)dnl" >&3 -fi + echo "MAILER(ifmail)dnl" >&3; +fi; ############################################################################### -fi # finished non-"null client" configuration +fi; # finished non-"null client" configuration ############################################################################### -echo "" >&3 -echo "LOCAL_CONFIG" >&3 -if [ -z $nullclient ]; then - echo "MASQUERADE_AS($mailname)dnl" >&3 - fi +echo "" >&3; +echo "LOCAL_CONFIG" >&3; +#if [ -z $nullclient ]; then +# echo "MASQUERADE_AS($mailname)dnl" >&3 +# fi -if [ -f $FILE ]; then - sed -n -e '/^## Custom/,$p' $FILE >&3 +if [ -f $SENDMAIL_MC ]; then + sed -n -e '/^## Custom/,$p' $SENDMAIL_MC >&3; else - echo "## Custom configurations below (will be preserved)" >&3 -fi + echo "## Custom configurations below (will be preserved)" >&3; +fi; descrip "Configuration Complete" <<EOT Advanced configuration, such as alternate mailers, the use of mailertables, Bitnet domains, and UUCP domains can be accomplished by manually editing the -/etc/mail/sendmail.mc configuration file and rerunning -\`$0' to generate the appropriate /etc/mail/sendmail.cf -file. (Local changes made at the end of /etc/mail/sendmail.mc will be -preserved by \`$0'.) +$SENDMAIL_MC configuration file and rerunning +\`$0' to generate the appropriate @sysconfdir@/mail/sendmail.cf +file. (Local changes made at the end of $SENDMAIL_MC +will be preserved by \`$0'.) The m4 library files for sendmail configuration are kept in the -/usr/share/sendmail/sendmail.cf directory. You may wish to review the -documentation in /usr/share/doc/sendmail to assist in further customization. +@datadir@/sendmail/cf directory. You may wish to review the +documentation in @docdir@/sendmail to assist in further customization. You may wish to customize your alias database; see the aliases(5) man page for information on the format and use of the /etc/aliases file. @@ -635,16 +650,22 @@ EOT ############################################################################### -exec 3>&- - -if [ -f $FILE ] -then - echo "Saving old /etc/mail/sendmail.mc as /etc/mail/sendmail.mc.old ..." - mv -f $FILE $FILE.old -fi - -mv -f $FILE.new $FILE -trap 0 - -makecf -exit 0 +exec 3>&-; + +if [ -f $SENDMAIL_MC ];then + echo "Saving old $SENDMAIL_MC as $SENDMAIL_MC.old ..."; + mv -f $SENDMAIL_MC $SENDMAIL_MC.old; + fi; + +chown root:smmsp $SENDMAIL_MC.new; +chmod 0644 $SENDMAIL_MC.new; +mv -f $SENDMAIL_MC.new $SENDMAIL_MC; +if [ ! -f @datadir@/sendmail/cf/feature/msp.m4 ]; then + chown root:smmsp $SUBMIT_MC.new; + chmod 0644 $SUBMIT_MC.new; + mv -f $SUBMIT_MC.new $SUBMIT_MC; + fi; +trap 0; + +makecf; +exit 0; diff --git a/debian/local/sensible-mda.8 b/debian/local/sensible-mda.8 deleted file mode 100644 index bdb1186..0000000 --- a/debian/local/sensible-mda.8 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 1998, 1999 Richard A Nelson <cowboy@debian.org> -.\" All rights reserved. -.\" -.\" You may distribute under the terms of the GNU General Public -.\" License -.\" -.\" $Id: sendmailconfig.8,v 2.0 1999/10/21 11:30:00 cowboy Exp $ -.\" -.TH SENDMAILCONFIG 8 "October 21 1999" -.UC 4 -.SH NAME -sensible\-mda \- a generic sendmail local MDA for Debian systems -.SH SYNOPSIS -.B sensible\-mda -.IR from -.IR to -.IR detail -.IR client\-addr -.br -.SH DESCRIPTION -.B sensible\-mda -is used to simplify the installation and configuration of -.BR sendmail (8) -for use on Debian systems. With sensible\-mda, sendmail can support -a plethora of MDAs (procmail, deliver, etc.) without having pick any -.I one -of them as required. -.LP -.SH FUNCTION -.B sensible\-mda -is called by sendmail as a local mailer when the following exists in -sendmail.mc: -.br -.I define(`LOCAL_MAILER_ARGS', `sensible-mda $g $u $h ${client_addr}')dnl -.LP -sensible-mda -will look for the following MDAs (in this order), and pass the mail -on to the first SUID MDA found: -.BR procmail (1), -.BR deliver (8) -.LP -.SH OPTIONS -Available command line options are the following: -.TP -.I from -The sender of this email -(sendmail $g variable) -.TP -.I to -The recipient of this email -(sendmail $u variable) -.TP -.I detail -The detail portion of the recipient userid -(sendmail $h variable) -\- ie: -.br -cowboy\+\fIsendmail\fP@debian.org -.TP -.I client\-addr -TCP/IP address of the sender -(sendmail ${client_addr} variable) -Not used (for the nonce) -.SH FILES -.TP -.I /etc/mail/sendmail.mc -sendmail m4 input to generate sendmail.cf -.TP -.I /etc/mail/sendmail.cf -actual sendmail configuration file (treated as a binary file) -.SH "SEE ALSO" -.BR sendmail (8), -.BR procmail (1), -.BR deliver (8) -.br -.SH BUGS -None known so far. -.SH AUTHOR -Richard Nelson <cowboy@debian.org> -.SH HISTORY diff --git a/debian/local/sensible-mda.c b/debian/local/sensible-mda.c deleted file mode 100644 index d42b0cb..0000000 --- a/debian/local/sensible-mda.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * sensible-mda.c - * Copyright (c) 1998, Johnie Ingram. - * Copyright (c) 1998, Richard Nelson <cowboy@debian.org>. - * Time-stamp: <1998/08/13 10:00:00 cowboy> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <unistd.h> -#include <pwd.h> -#include <sys/types.h> - -// TODO: declare -x TCPREMOTEIP="$3" - -#define PROCMAIL "/usr/bin/procmail" -#define DELIVER "/usr/bin/deliver" -#define PROCMAILRCS "/etc/procmailrcs/" - -static void help(void); -static unsigned char program[64]; - -static struct stat MDA_stat; -static struct stat procmailrc_stat; -static int done = 1; -static struct passwd* passwd_entry; - -int -main (int argc, char *argv[]) -{ - - char *procmailrc; - - /*----------------------------------------------------------------*/ - /* Parse input to determine to whom to speak and who we are... */ - /* Must have at least three parameters unless first is ?,-?,/?. */ - /*----------------------------------------------------------------*/ - (void) strcpy(program, argv[0]); - if (argc >= 2 && - (strcmp(argv[1],"?") == 0 || strcmp(argv[1],"-?") == 0 || - strcmp(argv[1],"/?") == 0 || strcmp(argv[1],"\\?") == 0 || - strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"--help") == 0)) { - help(); - return (0); - } - if (argc < 3) { - (void)printf("%s - Required parameters elided.\n",program); - help(); - return (0); - } - - - if (!stat(PROCMAIL, &MDA_stat)) { - if (MDA_stat.st_mode & S_ISUID) { - procmailrc=malloc(strlen(PROCMAILRCS)+strlen(argv[2])+1); - sprintf(procmailrc,"%s%s",PROCMAILRCS,argv[2]); - passwd_entry=getpwnam(argv[2]); - /* - * If argv[2] is a valid user & - * /etc/procmailrcs/argv[2] exists & is owned by argv[2] - */ - if (passwd_entry && - !stat(procmailrc, &procmailrc_stat) && - procmailrc_stat.st_uid==passwd_entry->pw_uid) { - done = 0; - execl (PROCMAIL, PROCMAIL, "-t", - "-f", argv[1], "-m", procmailrc, "-a", argv[3], NULL); - } else { - done = 0; - execl (PROCMAIL, PROCMAIL, "-t", - "-f", argv[1], "-a", argv[3], "-d", argv[2], NULL); - } - } - else - fprintf(stderr, "Ack!?! %s is not setuid!\n", PROCMAIL); - } - - if (done && !stat(DELIVER, &MDA_stat)) { - if (MDA_stat.st_mode & S_ISUID) { - done = 0; - execl (DELIVER, DELIVER, "-r", argv[1], argv[2], NULL); - } - else - fprintf(stderr, "Ack!?! %s is not setuid!\n", DELIVER); - } - - fprintf (stderr, "Huh? Neither %s nor %s was found (or was suid)!\n", - PROCMAIL, DELIVER); - - return (75); -} - - -/*-------------------------------------------------------------------*/ -/* Help... */ -/*-------------------------------------------------------------------*/ -static void help(void) -{ - (void)printf("\n%s - Help information.\n" - "%s: sendmail MTA->MDA wrapper, supporting these MDAs:\n" - "\tprocmail, deliver\n" - "\n" - "Syntax: %s from to\n" - ,program, program, program - ); - return; -} - diff --git a/debian/local/site.config.m4.in b/debian/local/site.config.m4.in deleted file mode 100644 index b2eab3e..0000000 --- a/debian/local/site.config.m4.in +++ /dev/null @@ -1,59 +0,0 @@ -# -# Debian site config file for building sendmail -# -# src -APPENDDEF(`confENVDEF', `-DTCPWRAPPERS=1')dnl -APPENDDEF(`confENVDEF', `-D_PATH_VARTMP=\"/var/lib/sendmail/\"')dnl -APPENDDEF(`confENVDEF', `-DPICKY_HELO_CHECK')dnl -APPENDDEF(`confENVDEF', `-D_PATH_SENDMAILCF=\"/etc/mail/sendmail.cf\"')dnl -# src - mime header size (pine, etc. exploit) -APPENDDEF(`confENVDEF', `-D_FFR_MAX_MIME_HEADER_LENGTH=1')dnl -# src - header length DOS -APPENDDEF(`confENVDEF', `-D_FFR_MAX_HEADERS_LENGTH=1') -# src - For Future Reference... undocumented niceties -dnl APPENDDEF(`confENVDEF', `-include ../../debian/el33t.h')dnl -APPENDDEF(`confENVDEF', `-D_FFR_DSN_RRT_OPTION=1')dnl -APPENDDEF(`confENVDEF', `-D_FFR_PIDFILE_OPTION=1')dnl -APPENDDEF(`confENVDEF', `-D_FFR_DEADLETTERDROP_OPTION=1')dnl -# -# smrsh -APPENDDEF(`confENVDEF', `-DCMDDIR=\"/usr/lib/sm.bin\"')dnl -APPENDDEF(`confENVDEF', `-DPATH=\"/usr/bin:/bin\"')dnl -# -# rmail -APPENDDEF(`confENVDEF', `-D_PATH_SENDMAIL=\"/usr/sbin/sendmail\"')dnl -# -# compilation -define(`confCC', `gcc')dnl -define(`confOPTIMIZE', `-O0 -g -Wall')dnl -# -# Database maps, based upon presence of NISPLUS from autoconf -define(`ac_cv_header_rpcsvc_nis_h', `@ac_cv_header_rpcsvc_nis_h@')dnl -ifelse(ac_cv_header_rpcsvc_nis_h, `yes', - `define(`confMAPDEF', `-DNEWDB -DMAP_REGEX -DNIS -DNISPLUS')', - `define(`confMAPDEF', `-DNEWDB -DMAP_REGEX -DNIS')' - )dnl -# -# paths, owners, and modes -define(`confEBINDIR', `/usr/lib/sm.bin')dnl #mail.local,smrsh,etc. -define(`confHDIR', `/usr/lib')dnl -define(`confHFDIR', `/usr/share/sendmail')dnl -define(`confMANROOT', `/usr/share/man/man')dnl -define(`confMANOWN', `root')dnl -define(`confMANGRP', `root')dnl -define(`confMANMODE', `0744')dnl -define(`confMBINDIR', `/usr/sbin')dnl #MTA dir -define(`confSBINDIR', `/usr/sbin')dnl #root dir -define(`confSBINOWN', `root')dnl -define(`confSBINGRP', `mail')dnl -define(`confSBINMODE', `07555')dnl -define(`confSTDIR', `/var/lib/sendmail')dnl -define(`confUBINDIR', `/usr/bin')dnl #usr dir -define(`confUBINOWN', `root')dnl -define(`confUBINGRP', `mail')dnl -define(`confUBINMODE', `0755')dnl -# -# don't install man pages -define(`confNO_MAN_INSTALL', `true')dnl -# -# flags diff --git a/debian/local/socks_wrapper b/debian/local/socks_wrapper new file mode 100644 index 0000000..ad89379 --- /dev/null +++ b/debian/local/socks_wrapper @@ -0,0 +1,31 @@ +#!/bin/bash +# Richard Nelson <cowboy@debain.org> +# Socks5 support wrapper for sendmail + +DAEMON=/usr/sbin/sendmail.real +RUNSOCKS=/usr/bin/runsocks +BASENAME=$(basename $0) + +# Adjust command name based upon the presence of the socks5 wrapper +if [ -x $RUNSOCKS ]; then + COMMAND="$RUNSOCKS $DAEMON" +else + COMMAND="$DAEMON" + fi +#echo "$BASENAME command="$COMMAND + +# Exec the appropriate command +case "$BASENAME" in + # These don't need socks support, and must be called by name + "hoststat" | "mailq" | "newaliases" | "purgestat") + exec -a $BASENAME $DAEMON "$@" + ;; + # These need socks support + "sendmail") + exec -a $DAEMON $COMMAND "$@" + ;; + # Help... shouldn't be here + *) + echo "panic, $BASENAME is not a valid alias for sendmail." + ;; + esac diff --git a/debian/local/update_auth.in b/debian/local/update_auth.in new file mode 100644 index 0000000..558c8b1 --- /dev/null +++ b/debian/local/update_auth.in @@ -0,0 +1,250 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# +# $Sendmail: update_auth,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Sendmail support for SMTP AUTH (SASL) +# +# Copyright (c) 2000-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes: +# +#----------------------------------------------------------------------------- +set -e; + +NEW=0; +DEFAULT=0; +HOSTNAME=`hostname -s`; +HOSTFQDN=`hostname -f`; +DOMAINNAME=`hostname -d`; +SMUID=sendmail; +SMAID=sendmail; +SMPWD=sendmailpwd; +SMRLM=$HOSTNAME.$DOMAINNAME; + +# Check if SASL is installed +if [ -d /usr/lib/sasl2 -a @sm_version_math@ -ge 527364 ]; then + SASLDBLISTUSERS='/usr/sbin/sasldblistusers2'; + SASLPASSWD='/usr/sbin/saslpasswd2'; + SASLLIB='/usr/lib/sasl2'; + SASLSO='2'; + SASLDB='/etc/sasldb2'; + SASL_BIN='sasl2-bin'; + echo " SASL V2 not supported for the nonce, checking for SASL V1"; + fi; +if [ -d /usr/lib/sasl ]; then + SASLDBLISTUSERS='/usr/sbin/sasldblistusers'; + SASLPASSWD='/usr/sbin/saslpasswd'; + SASLLIB='/usr/lib/sasl'; + SASLSO='1'; + SASLDB='/etc/sasldb'; + SASL_BIN='sasl-bin'; +else + cat <<-EOT + + SASL not installed, not configuring sendmail support. + + To install sasl, get sasl-bin, libsasl-modules-plain, + libsasl-digestmd5-plain or libsasl-digestmd5-des. + + To enable sendmail SASL support at a later date, invoke "$0" + + EOT + exit 0; + fi; + +# Check for sasl-bin (wherein resides saslpasswd) +if [ ! -x ${SASLPASSWD} ]; then + cat <<-EOT + ${SASL_BIN} not installed, not configuring sendmail support. + + To enable sendmail SASL support at a later date, invoke "$0" + + EOT + exit 0; + fi; +#echo " "; +#echo "Creating/Updating SASL information"; + +# See if we need to rename an existing SASL info file +if [ -f @sysconfdir@/mail/auth-info -a \ + ! -f @sysconfdir@/mail/default-auth-info ]; then + mv @sysconfdir@/mail/auth-info \ + @sysconfdir@/mail/default-auth-info; + fi; + +# Create Default SASL auth information +if [ ! -f @sysconfdir@/mail/default-auth-info ]; then + cat <<-EOT > @sysconfdir@/mail/default-auth-info + $SMUID + $SMAID + $SMPWD + $SMRLM + EOT + +# Use exisisting SASL auth information +else + SMUID=$(head -n1 @sysconfdir@/mail/default-auth-info); + SMAID=$(head -n2 @sysconfdir@/mail/default-auth-info | tail -n1 -); + SMPWD=$(head -n3 @sysconfdir@/mail/default-auth-info | tail -n1 -); + SMRLM=$(head -n4 @sysconfdir@/mail/default-auth-info | tail -n1 -); + fi; + +# Check for default settings, used in later test +if [ "$SMUID" = 'sendmail' ] \ +&& [ "$SMAID" = 'sendmail' ] \ +&& [ "$SMPWD" = 'sendmailpwd' ]; then + DEFAULT=1; + fi; + +# Create any missing SASL configuration files +if [ -d ${SASLLIB} ]; then + # SASL password configuration + if [ ! -f ${SASLLIB}/saslpasswd.conf ]; then + NEW=1; + cp @datadir@/sendmail/examples/sasl/saslpasswd.conf \ + ${SASLLIB}/saslpasswd.conf; + fi; + chown root:root ${SASLLIB}/saslpasswd.conf; + chmod 0640 ${SASLLIB}/saslpasswd.conf; + + # Sendmail SASL configuration + if [ ! -L ${SASLLIB}/Sendmail.conf ]; then + if [ -f ${SASLLIB}/Sendmail.conf ]; then + mv ${SASLLIB}/Sendmail.conf @sysconfdir@/mail/sasl/Sendmail.conf; + fi; + ln -sf @sysconfdir@/mail/sasl/Sendmail.conf \ + ${SASLLIB}/Sendmail.conf; + fi; + + # Make sure libraries are properly installed... + ( cd ${SASLLIB} && \ + if [ -L libanonymous.so.${SASLSO} -a ! -L libanonymous.so ]; then \ + ln -s libanonymous.so.${SASLSO} libanonymous.so; \ + fi; \ + if [ -L libcrammd5.so.${SASLSO} -a ! -L libcrammd5.so ]; then \ + ln -s libcrammd5.so.${SASLSO} libcrammd5.so; \ + fi; \ + if [ -L libdigestmd5.so.${SASLSO} -a ! -L libdigestmd5.so ]; then \ + ln -s libdigestmd5.so.${SASLSO} libdigestmd5.so; \ + fi; \ + if [ -L libdigestmd5.so.0 -a ! -L libdigestmd5.so ]; then \ + ln -s libdigestmd5.so.0 libdigestmd5.so; \ + fi; \ + if [ -L libgssapiv2.so.${SASLSO} -a ! -L libgssapiv2.so ]; then \ + ln -s libgssapiv2.so.${SASLSO} libgssapiv2.so; \ + fi; \ + if [ -L liblogin.so.${SASLSO} -a ! -L liblogin.so ]; then \ + ln -s liblogin.so.${SASLSO} liblogin.so; \ + fi; \ + if [ -L liblogin.so.0 -a ! -L liblogin.so ]; then \ + ln -s liblogin.so.0 liblogin.so; \ + fi; \ + if [ -L libplain.so.${SASLSO} -a ! -L libplain.so ]; then \ + ln -s libplain.so.${SASLSO} libplain.so; \ + fi; ) + fi; + +# Create/update sendmail SASL files +if [ ! -f @sysconfdir@/mail/sasl/Sendmail.conf ]; then + NEW=1; + cp @datadir@/sendmail/examples/sasl/Sendmail.conf \ + @sysconfdir@/mail/sasl/Sendmail.conf; + fi; +chown root:smmsp @sysconfdir@/mail/sasl/Sendmail.conf; +chmod 0640 @sysconfdir@/mail/sasl/Sendmail.conf; + +# Recommend PAM for sendmail authorization +if ! grep -qEe "^[[:space:]]*pwcheck_method:[[:space:]]*PAM" \ + ${SASLLIB}/Sendmail.conf; then + cat <<-EOT + + It is *strongly* recommended that you use PAM as the authentication + method for sendmail via SASL. Doing so will allow *all* your shell + users (those with an /etc/passwd entry) to automagically authenticate + themselves when using a MUA with SASL support turned on. + + Do you wish to use PAM (Y|n)? + EOT + read yn; + yn=$(echo -n "$yn" | sed -e "s/^\ *//" -e "s/^\t*//"); + test -n "$yn" || yn="Y"; + case "$yn" in + [Yy]*) + if grep -qEe '^[[:space:]]*pwcheck_method:' \ + @sysconfdir@/mail/sasl/Sendmail.conf; then + sed -e \ + 's?^[[:space:]]*pwcheck_method:.*$?pwcheck_method: PAM?' \ + @sysconfdir@/mail/sasl/Sendmail.conf \ + > @sysconfdir@/mail/sasl/Sendmail.conf.new; + else + echo 'pwcheck_method: PAM' \ + | cat @sysconfdir@/mail/sasl/Sendmail.conf - \ + > @sysconfdir@/mail/sasl/Sendmail.conf.new; + fi; + if [ -f @sysconfdir@/mail/sasl/Sendmail.conf.new ]; then + chown root:smmsp @sysconfdir@/mail/sasl/Sendmail.conf.new; + chmod 0644 @sysconfdir@/mail/sasl/Sendmail.conf.new; + mv @sysconfdir@/mail/sasl/Sendmail.conf.new \ + @sysconfdir@/mail/sasl/Sendmail.conf; + fi; + ;; + esac; + fi; + +# Make sure default-auth-info is secure +if [ -f @sysconfdir@/mail/default-auth-info ]; then + chown root:smmsp @sysconfdir@/mail/default-auth-info; + chmod 0640 @sysconfdir@/mail/default-auth-info; + fi; + +# Create skeleton file, the saslpasswd command will get a failure ;-{ +if [ ! -f ${SASLDB} ]; then + NEW=1; + if [ -x ${SASLPASSWD} ]; then + ${SASLDBLISTUSERS} 1>/dev/null 2>&1 || true; + echo "$SMPWD" | ${SASLPASSWD} -p -c -u $SMRLM $SMAID \ + 1>/dev/null 2>&1 || true; + chown root:smmsp ${SASLDB}; + chmod 0660 ${SASLDB}; + else + echo "*** You do not have the sasl-bin package installed!"; + echo "*** Please install it and rerun $0"; + echo "*** Sendmail can't use SASL until this is done..."; + fi; + fi; + +# Set SMTP auth password +if [ -x ${SASLPASSWD} ]; then + if [ $DEFAULT = 0 ]; then + echo "$SMPWD" | ${SASLPASSWD} -p -c -u $SMRLM $SMAID || true; + else + ${SASLPASSWD} -d -u $SMRLM $SMAID 1>/dev/null 2>&1 || true; + fi; + fi; + +# For sendmail, /etc/sasldb must be 0600 or (0640/0660 w/dontblamesendmail) +if [ -f ${SASLDB} ]; then + find ${SASLDB} -gid 0 -print | xargs -r chown root:smmsp; + find ${SASLDB} -gid 8 -print | xargs -r chown root:smmsp; + find ${SASLDB} -group smmsp -print | xargs -r chmod g+rw; + chmod g-x,o-rwx ${SASLDB}; + fi; + +# Tell them about the new wizbang features... +if [ $NEW -eq 1 ]; then + cat <<-EOT + + SASL is now minimally setup, there are a few ways to handle users: + *) Allow only shell users (default) + You're all set, nothing else to do ! + *) Allow users other than shell + Add users via /usr/sbin/saslpasswd and make sure that the + realm you used matches what your users specify in their + netscape/outlook/mutt/etc profiles. + + If you need to authorize sendmail as a sender, also update + @sysconfdir@/mail/default-auth-info and rerun $0. + + EOT + fi; diff --git a/debian/local/update_conf.in b/debian/local/update_conf.in new file mode 100644 index 0000000..330a97a --- /dev/null +++ b/debian/local/update_conf.in @@ -0,0 +1,1140 @@ +#!/usr/bin/perl -w +#------------------------------------------------------------------------ +# +# $Sendmail: update_conf,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Parse and update /etc/mail/sendmail.conf and reflect its values in +# /etc/cron.d/sendmail and /etc/inetd.conf. +# +# Copyright (c) 2001-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +#------------------------------------------------------------------------ +# +use strict; # be kosher +use Cwd; # provide cwd() +use Env; # A few environmental references +use integer; # Peformance +use Sys::Hostname; # make sure we have a valid hostname +use Getopt::Long; # parameter handling +use FileHandle; # I/O + +# Local libraries - for Debian Sendmail Perl helper functions +# BEGIN { $main::my_path = substr($0,$[,rindex($0,'/')) }; +use lib ('.', substr($0,$[,rindex($0,'/')), "@datadir@/sendmail"); +require Parse_mc; + +$main::program_name = $0; #'update_conf'; +$main::program_version = '@sm_version@'; +$main::program_date = '@sm_date@ @sm_time@ cowboy'; +my $interp_pgm = "$^X"; +my $interp_vrm = $]; +$interp_vrm = ("$^V" | '000') if (defined $^V); +my $current_time = scalar localtime; +my $user = getlogin || (getpwuid($<))[0] || "Unknown!!"; +my $hostname = hostname(); +my $directory = cwd(); + +my $conffile = "@sysconfdir@/mail/sendmail.conf"; +my $output_file = ''; +my $ofh = new FileHandle; +my $debug = 0; +my $result; + +# +#------------------------------------------------------------------------------ +# Global variables +#------------------------------------------------------------------------------ +my %parm_def; +my %parameter; +my %parm_kw; +my %parm_bool; +my %parm_deprecated; +my %parm_hidden; + +# +#------------------------------------------------------------------------------ +# Finally, some code (almost) +#------------------------------------------------------------------------------ + +# +# Argument handling... +$main::opt_help=''; +$main::opt_output_file=''; +$main::opt_input_file=''; +$main::opt_debug=''; +my @options = qw( + help|h + output-file|output_file|o:s + input-file|input_file|i:s + debug! + ); +$result = GetOptions(@options); +if ( ! $result ) { + die "Terminating due to parameter error"; + }; +if ( $main::opt_help ) { + warn "$main::program_name $main::program_version $main::program_date\n"; + warn "$0 \n"; + warn " -help\n" if $main::opt_help; + warn " -debug\n" if $main::opt_debug; + warn " -o $main::opt_output_file\n" if $main::opt_output_file; + warn " -i $main::opt_input_file\n" if $main::opt_input_file; + exit 0; + }; + +$output_file = $main::opt_output_file if ($main::opt_output_file); +my $input_file = $main::opt_input_file || $conffile; +# $main::debug is used in Parse_mc ! +$main::debug = $main::opt_debug || ''; +$debug = $main::debug; + +# Obtain default values +&set_defaults; + +# Update defaults according to current environment +&update_defaults; + +# Read /etc/mail/sendmail.conf (if extant) +&read_config; + +# Make sure things are kosher +my $ok = &validate_config; +if (! $ok) { + die "Terminating due to configuration error."; + }; + +# [Re]write /etc/mail/sendmail.config +&write_config; +if ( $output_file eq '' ) { + chown '0', '0', $conffile; + chmod 0644, $conffile; + }; + +# Reflect settings in /etc/cron.d/sendmail +&write_crontab; +if ( $output_file eq '' ) { + chown '0', '0', "@sysconfdir@/cron.d/sendmail"; + chmod 0644, "@sysconfdir@/cron.d/sendmail"; + }; + +# Reflect settings in /etc/inetd.conf +&update_inetd; + +# Create/Delete files +&update_files; + +exit (0); + +# +#------------------------------------------------------------------------ +# Set global values +#------------------------------------------------------------------------ +sub set_defaults { + + %parm_def = ( + 'DAEMON_MODE' => 'Daemon' + ,'DAEMON_PARMS' => '' + ,'DAEMON_HOSTSTATS' => 'No' + ,'DAEMON_MAILSTATS' => 'No' + ,'QUEUE_MODE' => '${DAEMON_MODE}' + ,'QUEUE_INTERVAL' => '10' + ,'QUEUE_PARMS' => '' + ,'MSP_MODE' => 'Cron' + ,'MSP_INTERVAL' => '${QUEUE_INTERVAL}' + ,'MSP_PARMS' => '${QUEUE_PARMS}' + ,'MSP_MAILSTATS' => '${DAEMON_MAILSTATS}' + ,'MISC_PARMS' => '' + ,'CRON_MAILTO' => 'root' + ,'CRON_PARMS' => '' + ,'AGE_DATA' => '' + ); + + %parameter = %parm_def; + + %parm_kw = ( + 'DAEMON_MODE' => ['daemon', 'inetd'] + ,'QUEUE_MODE' => ['daemon', 'cron'] + ,'MSP_MODE' => ['daemon', 'cron', 'none'] + ); + + %parm_bool = ( + 'DAEMON_HOSTSTATS' => 1 + ,'DAEMON_MAILSTATS' => 1 + ,'MSP_MAILSTATS' => 1 + ); + + %parm_deprecated = ( + 'DAEMON_STATS' => 'DAEMON_MAILSTATS' + ,'MSP_STATS' => 'MSP_MAILSTATS' + ); + + %parm_hidden = ( + 'prefix' => 1 + ,'exec_prefix' => 1 + ,'bindir' => 1 + ,'sbindir' => 1 + ,'libexecdir' => 1 + ,'datadir' => 1 + ,'sysconfdir' => 1 + ,'sharedstatedir' => 1 + ,'localstatedir' => 1 + ,'libdir' => 1 + ,'MTA_DAEMON' => 1 + ,'MTA_COMMAND' => 1 + ,'MTA_L' => 1 + ,'MTA_L_QUEUE' => 1 + ,'MTA_ROOT' => 1 + ,'MTA_PIDFILE' => 1 + ,'MSP_DAEMON' => 1 + ,'MSP_COMMAND' => 1 + ,'MSP_L' => 1 + ,'MSP_L_QUEUE' => 1 + ,'MSP_ROOT' => 1 + ,'MSP_PIDFILE' => 1 + ); + + }; + +# +#------------------------------------------------------------------------ +# Update default settings according to current environment +#------------------------------------------------------------------------ +sub update_defaults { + my ($class, $flags, $files, $options); + my ($ok, $stats); + my $file; + + # Obtain entry for HOST_STATUS_DIRECTORY + ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs('confHOST_STATUS_DIRECTORY'); + $file = @{$files}[0]; + if ( $file ne '-' and -d $file ) { + $parameter{'DAEMON_HOSTSTATS'} = 'Yes'; + } + else { + $parameter{'DAEMON_HOSTSTATS'} = 'No'; + }; + + # Obtain entry for STATUS_FILE + ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs('STATUS_FILE'); + $file = @{$files}[0]; + if ( $file ne '-' and -e $file ) { + $parameter{'DAEMON_MAILSTATS'} = 'Yes'; + } + else { + $parameter{'DAEMON_MAILSTATS'} = 'No'; + }; + + # Obtain entry for MSP_STATUS_FILE + ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs('MSP_STATUS_FILE'); + $file = @{$files}[0]; + if ( $file ne '-' and -e $file ) { + $parameter{'MSP_MAILSTATS'} = 'Yes'; + } + else { + $parameter{'MSP_MAILSTATS'} = 'No'; + }; + + }; + +# +#------------------------------------------------------------------------ +# Obtain parameter name +#------------------------------------------------------------------------ +sub get_name { + my ($name, $quiet) = @_; + + # Handle deprecated/renamed variables + if ( exists($parm_deprecated{$name}) ) { + print STDERR "$name is deprecated." + if ($debug and ! $quiet); + if ( $parm_deprecated{$name} ) { + print STDERR " Please use $parm_deprecated{$name} instead.\n" + if ($debug and ! $quiet); + $name = $parm_deprecated{$name}; + } + else { + print STDERR " It will be ignored.\n" + if ($debug and ! $quiet); + }; + }; + + return $name; + }; +# +#------------------------------------------------------------------------ +# Obtain value directly, or indirectly +#------------------------------------------------------------------------ +sub get_value { + my ($name) = get_name(@_, ''); + my $value = $parameter{$name}; + + my $tval = $value; + $tval =~ s/^\s*//; + my $ok = 1; + my $default = 0; + + # Dereference loop... keep original value if we get any errors... + Dereference:; + if ($tval =~ /^\$/) { + my @ref_stack = ($name); + my %ref_hash = ($name => 1); + while ($tval =~ /^\$/ and $ok) { + my $start = 1; + my $del = 1; + my $char = substr($tval, 1, 1); + if ( $char eq '{' or $char eq '(' ) { + $start += 1; $del += 2; + }; + my $ref = get_name(substr($tval, $start, + length($tval)-$del), ''); + push @ref_stack, $ref; + if (exists($ref_hash{$ref})) { + print STDERR "Go directly to jail; do not pass go, ", + "do not collect \$200\n"; + print STDERR " Reference loop: ", + join('->', @ref_stack, '...'),"\n"; + $ok = 0; + } + else { + $ref_hash{$ref} = 1; + if (lc $ref eq 'default') { + $tval = $parm_def{$name}; + print STDERR + "Setting $name to default value: ", + "$parm_def{$name}.\n" + if ($debug); + } + elsif (exists($parameter{$ref})) { + $tval = $parameter{$ref}; + print STDERR + "Setting $name to value of $ref: $tval.\n" + if ($debug); + } + else { + print STDERR + "Can't deference $ref, doesn't exist.\n"; + $ok = 0; + }; + }; + }; + }; + + if ( $ok ) { + # Check keyword parms for valid values + if (exists $parm_kw{$name}) { + my @ltval = split(/\s/,$tval); + my $ltval = lc @ltval[$[]; + my $found = ""; + foreach my $value (@{$parm_kw{$name}}) { + if ($value eq $ltval) { + $found = 1; $tval = $ltval; }; + }; + if ( ! $found ) { + $default += 1; + if ( $default > 1 ) { + print STDERR + "Can't resolve $name, value=$value.\n"; + $ok = 0; + } + else { + print STDERR "Illegal value($tval) for $name.\n", + " Valid values are: ", + join(', ', @{$parm_kw{$name}}), + "\n", + " Set to default: $parm_def{$name}.\n"; + $tval = $parm_def{$name}; + goto Dereference; + }; + }; + } + + # Check boolean parms for valid values + elsif (exists $parm_bool{$name}) { + my @ltval = split(/\s/,$tval); + my $ltval = lc @ltval[$[]; + $ltval =~ s/^[ty1].*/1/; + $ltval =~ s/^[fn0].*/0/; + if ($ltval eq '0' or $ltval eq '1') { + $tval = $ltval; } + else { + $default += 1; + if ( $default > 1 ) { + print STDERR + "Can't resolve $name, value=$value.\n"; + $ok = 0; + } + else { + print STDERR "Illegal value($tval) for $name.\n", + " Valid values are: T[rue],Y[es],1,", + " F[alse],N[o],0\n", + " Set to default: $parm_def{$name}.\n"; + $tval = $parm_def{$name}; + goto Dereference; + }; + }; + }; + }; + + $value = $tval if $ok; + + print STDERR "get_value : $name => $value\n" + if ($debug); + + return ($ok, $value); + }; + +# +#------------------------------------------------------------------------ +# Check for nullclient mode in /etc/mail/sendmail.mc +#------------------------------------------------------------------------ +sub check_nullclient { + my $nullclient = 0; + my $in_file = "@sysconfdir@/mail/sendmail.mc"; + if ( -r $in_file ) { + my $ifh; + unless ( open($ifh, "<$in_file") ) { + warn("Could not open $in_file($!), ignoring it.\n"); + }; + + line: while (<$ifh>) { + next line if /^$/; # skip empty lines + next line if /^#/; # skip comments + next line if /^dnl /; # skip comments + chomp; # drop tailing \n + + if (/^\s*FEATURE\(\s*`?nullclient/) { + $nullclient = 1; + last line; + }; + }; + }; + return $nullclient; + }; + +# +#------------------------------------------------------------------------ +# Read input configuration file (if no input, just use defaults) +#------------------------------------------------------------------------ +sub read_config { + @ARGV = split(' ', $input_file); + return if (! -r $input_file); + + my $savename = ''; + my $parmname = ''; + my $parmval = ''; + my $parmref = ''; + my $defname = ''; + my $defval = ''; + my $tmpval = ''; + + print STDOUT "Reading configuration from ", join(',',@ARGV), ".\n"; + + line: while (<ARGV>) { + next line if /^$/; # skip empty lines + chomp; # drop tailing \n + if (s/\\$//) { + $_ .= <>; + redo unless eof(); + }; + + # check commented lines for default parameter values + # a bit of a kluge, but it works out nicely + if (/^#\s*([\w_]+)="([^"]*)"/) { + $defname = get_name($1, 1); + $defval = $2; + print STDERR "Default: $defname => $defval.\n" + if ($debug); + next line; + }; + # Skip any comments + next line if /^#/; # skip comments + + # Process assignment statements + if (/^\s*([\w_]+)="([^"]*)"/) { + $savename = $1; + $parmname = get_name($savename, ''); + $parmval = $2; + print STDERR "Value : $savename => $parmval.\n" + if ($debug); + + # Do we know about this parameter? + # NOTE: keep, even if we don't know about it to prevent + # problems with up/down grades (not loose anything) + if ( ! exists($parm_def{$parmname}) and + ! exists($parm_hidden{$parmname}) ) { + print STDERR "$parmname is a user defined parameter.\n" + if ($debug); + }; + + # Note if value is default, if so, we'll change it to + # the current default - maybe counterintuitive, oh well + # it does help with migration + if ($parmname eq $defname and $parmval eq $defval) { + print STDERR "$parmname is the default value: $defval.\n" + if ($debug); + $parmval = $parm_def{$parmname}; + }; + + # Finally, assign value + if ($savename eq $parmname) { + $parameter{$parmname} = $parmval; + } + else { + $parameter{$savename} = $parmval; + }; + }; + }; + }; + +# +#------------------------------------------------------------------------ +# Validate current configuration +#------------------------------------------------------------------------ +sub validate_config { + + my $valid = 1; + + print STDOUT "Validating configuration.\n"; + + # Really, we only care about the some of the variables - those + # that have defaults... the rest, well, so what ! + foreach my $val (sort keys %parm_def) { + my ($ok, $value) = &get_value($val, 1); + if (! $ok) { $valid = 0; }; + }; + + if (! $valid ) { + print STDERR "\nOne or more errors were encountered!\n\n"; + }; + + return ($valid); + }; + +# +#------------------------------------------------------------------------ +# Write updated configuration file +#------------------------------------------------------------------------ +sub write_config { + my $out_file = $output_file || $conffile; + print STDOUT "Writing configuration to $out_file.\n"; + $out_file = '&STDOUT' if ($out_file eq '-'); + unless ( open($ofh, ">$out_file") ) { + warn("Could not open $out_file($!), using STDOUT\n"); + open($ofh, ">&STDOUT"); + }; + $out_file = '-' if ($out_file eq '&STDOUT'); + +# print $ofh <<"EOT"; +#################################################################### +##### This file is automagically generated -- edit at your own risk +##### +##### file: ${out_file} +##### generated via: (${interp_pgm} ${interp_vrm}) +##### ${main::program_name} +##### version: ${main::program_version} ${main::program_date} +##### by: ${user}\@${hostname} +##### on: ${current_time} +##### in: ${directory} +##### input files: +#EOT +# foreach my $file ( split(' ', $input_file) ) { +# print $ofh <<"EOT"; +##### ${file} +#EOT +# }; +# print $ofh <<"EOT"; +##### +#################################################################### + print $ofh <<"EOT"; +#------------------------------------------------------------------------------ +# +# $out_file +# +# Copyright (c) 2001-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# Version: ${main::program_version} +# Time-stamp: <${main::program_date}> +# +# Parameter file for sendmail (sourced by /usr/share/sendmail/sendmail) +# Make all changes herein, instead of altering /etc/init.d/sendmail. +# +# After making changes here, you'll need to run /usr/sbin/sendmailconfig +# or ${main::program_name} to have the changes take effect - +# If you change DAEMON_MODE, QUEUE_MODE, or QUEUE_INTERVAL, you'll also +# need to run /etc/init.d/sendmail restart. +# +# Changes made herein will be kept across upgrades - except for comments! +# Some comment lines have special significance ... +# +# **** **** **** **** DO NOT EDIT THE COMMENTS **** **** **** **** +# +# Supported parameters (and defaults) are listed herein. +# +# Notes: +# * This setup allows sendmail to run in several modes: +# - listener and queue runner..DAEMON_MODE="daemon".QUEUE_MODE="daemon" +# - listener only..............DAEMON_MODE="daemon".QUEUE_MODE="none" +# - queue runner only..........DAEMON_MODE="none"...QUEUE_MODE="daemon" +# - *NOTHING* ?!?..............DAEMON_MODE="none"...QUEUE_MODE="none" +# +# * You can also run the listener from inetd: +# - listener and queue runner..DAEMON_MODE="inetd"..QUEUE_MODE="daemon" +# - listener only..............DAEMON_MODE="inetd"..QUEUE_MODE="none" +# +# * You can also run the queue runner from cron: +# - listener and queue runner..DAEMON_MODE="....."..QUEUE_MODE="cron" +# - queue runner only..........DAEMON_MODE="none"...QUEUE_MODE="cron" +# +# * _PARMS entries herein are shown in precedence order, any later _PARMS +# field will, if applicable, override any previous _PARMS fields. +# +# * Values *MUST* be surrounded with double quotes ("), single quotes +# will *NOT* work ! +# +#------------------------------------------------------------------------------ +# SMTP Listener Configuration +# +# DAEMON_MODE="$parm_def{'DAEMON_MODE'}"; Keyword SMTP listener +# daemon: Run as standalone daemon +# inetd: Run from inet supervisor (forks for each mail) +# none: No listener (ie, nullclient/smarthost) +# +# NOTE: for the nonce, DAEMON_MODE="none" is *NOT* supported !!! +# +DAEMON_MODE="$parameter{'DAEMON_MODE'}"; +# +# DAEMON_PARMS="$parm_def{'DAEMON_PARMS'}"; String Listener parms +# Any parameters here will be ignored when run from cron. +# Note that MISC_PARMS and CRON_PARMS, if applicable, will override +# anything declared herein. +# +DAEMON_PARMS="$parameter{'DAEMON_PARMS'}"; +# +# DAEMON_HOSTSTATS="$parm_def{'DAEMON_HOSTSTATS'}"; Boolean Listener stats +# This parameter determines whether or not host stats are collected +# and available for the \`hoststat\` command to display. There will +# be a (minor) performance hit, as files will be created/updated for each +# sendmail delivery attempt. The files are fixed in size, and small, +# but there can be many of them. +# +DAEMON_HOSTSTATS="$parameter{'DAEMON_HOSTSTATS'}"; +# +# DAEMON_MAILSTATS="$parm_def{'DAEMON_MAILSTATS'}"; Boolean Listener stats +# This parameter determines whether or not mailer stats are collected +# and available for the \`mailstats\` command to display. There will +# be a (minor) performance hit, as this file will be updated for each +# item coming into, or out of, sendmail. The file is fixed in size, +# and small, so there's no need to rotate it. +# +DAEMON_MAILSTATS="$parameter{'DAEMON_MAILSTATS'}"; +# +#------------------------------------------------------------------------------ +# SMTP MTA Queue Runner Configuration +# +# QUEUE_MODE="$parm_def{'QUEUE_MODE'}"; Keyword SMTP queue runner +# daemon: Run as standalone daemon +# cron: Run from crontab +# none: No queue runner (ie, nullclient/smarthost) +# +# NOTE: for the nonce, QUEUE_MODE="none" is *NOT* supported !!! +# +QUEUE_MODE="$parameter{'QUEUE_MODE'}"; +# +# QUEUE_INTERVAL="$parm_def{'QUEUE_INTERVAL'}"; Integer in minutes +# Interval at which to run the MTA queues. What interval should you use? +# The amount of time that is acceptable before retrying delivery on +# mail that couldn't be delivered in one run, or how long an item can +# set in the queue before having the first delivery attempt done. +# +QUEUE_INTERVAL="$parameter{'QUEUE_INTERVAL'}"; +# +# QUEUE_PARMS="$parm_def{'QUEUE_PARMS'}"; String queue parameters +# Any parameters here are also used when run from cron. +# Note that MISC_PARMS and CRON_PARMS, if applicable, will override +# anything declared herein. +# +QUEUE_PARMS="$parameter{'QUEUE_PARMS'}"; +# +#------------------------------------------------------------------------------ +# SMTP - MSP Queue Runner Configuration +# +# MSP_MODE="$parm_def{'MSP_MODE'}"; Keyword MSP queue runner mode +# daemon: Run as standalone daemon +# cron: Run from crontab +# none: No queue runner (ie, nullclient/smarthost) +# +# NOTE: If QUEUE_MODE="cron" & MSP_MODE="none", the MSP queue will +# be run as part of the MTA queue running process. +# +MSP_MODE="$parameter{'MSP_MODE'}"; +# +# MSP_INTERVAL="$parm_def{'MSP_INTERVAL'}"; Integer in minutes +# Interval at which to run the MSP queues. What interval should you use? +# The amount of time that is acceptable before retrying delivery on +# mail that couldn't be accepted by the MTA, and was therefore left +# in the message submission queue. Probably should be the same as the +# whats used in QUEUE_INTERVAL. +# +MSP_INTERVAL="$parameter{'MSP_INTERVAL'}"; +# +# MSP_PARMS="$parm_def{'MSP_PARMS'}"; String queue parameters +# Any parameters here are also used when run from cron. +# Note that MISC_PARMS and CRON_PARMS, if applicable, will override +# anything declared herein. +# +MSP_PARMS="$parameter{'MSP_PARMS'}"; +# +# MSP_MAILSTATS="$parm_def{'MSP_MAILSTATS'}"; Boolean Listener stats +# This parameter determines whether or not mailer stats are collected +# and available for the \`mailstats\` command to display. There will +# be a (minor) performance hit, as this file will be updated for each +# item coming into, or out of, sendmail. The file is fixed in size, +# and small, so there's no need to rotate it. +# +MSP_MAILSTATS="$parameter{'MSP_MAILSTATS'}"; +# +#------------------------------------------------------------------------------ +# Miscellaneous Confguration +# +# MISC_PARMS="$parm_def{'MISC_PARMS'}"; String miscellaneous parameters +# Miscellaneous parameters - applied to any sendmail invocation. +# Any parameters here are also used when run from cron. +# Applied after {DAEMON,QUEUE}_PARMS, and can therefore override them +# if need be (in which case why did use them?) +# Note that CRON_PARMS, if applicable, will override anything +# declared herein. +# +# Here is where'd you setup and debugging or special parms that you +# want shared betwixt the possibly separate listener/queue-runner +# processes. +# +MISC_PARMS="$parameter{'MISC_PARMS'}"; +# +#------------------------------------------------------------------------------ +# Cron Job Configuration +# +# CRON_MAILTO="$parm_def{'CRON_MAILTO'}"; String cronjob output +# Recipient of *rare* cronjob output. Some cronjobs will be running +# under user `mail`, so any problems encountered would probably be missed +# so define a user who actually (hopefully) checks email now and again. +# +CRON_MAILTO="$parameter{'CRON_MAILTO'}"; +# +# CRON_PARMS="$parm_def{'CRON_PARMS'}"; String cron specific parmeters +# Cron parameters - applied *only* when sendmail queue running is done +# via a cronjob. Applied after QUEUE_PARMS and MISC_PARMS, and can +# therefore override them if need be. +# +CRON_PARMS="$parameter{'CRON_PARMS'}"; +# +#------------------------------------------------------------------------------ +# Queue Aging Configuration +# +# Why would you want to age your queues? On every queue-run interval, +# sendmail will try *every* file in the queue... If a site is down +# for a while, considerable time can be wasted each interval in retrying +# it. The scheme supported allows aging by time, and can move the older +# files to another (less frequently run queue), thereby reducing overal +# system impact - and providing better mail throughput. +# +# Note that this support is completely separate from QUEUE_MODE=cron, +# you can age queues even if you're running QUEUE_MODE=daemon. +# +# There are four parts to the queue aging support, and these parts +# may be repeated, to operate on multiple queues. +# +# 1. Interval at which to age the queues (in minutes). +# What interval should you use? Roughly twice the normal queue +# interval, so that messages are tried twice in each successively +# slower queue. +# +# 2. Criteria (optional and defaults to interval). This is the +# specification of which files to move. It defaults moving +# files whose age in the queues exceeds the interval. +# This field, if specified can be very complex - supporting +# aging by just about anything! see qtool(8) for details. +# +# 3. To queue. This is the queue to which files will be moved. +# It may be fully qualified, or relative to /var/spool/mqueue. +# +# 4. From queue. This is the queue from which files will be moved. +# It may be fully qualified, or relative to /var/spool/mqueue. +# +# Samples: +# AGE_DATA="[['25', '', 'hourly', 'main']]"; +# Every 25 minutes, move any file older than 25 minutes from +# /var/spool/mqueue/main to /var/spool/mqueue/hourly +# +# AGE_DATA="[['25', '', 'hourly', 'main'],\\ +# ['125', '', 'daily', 'hourly']]"; +# Same as the above, but also move files from the hourly queue +# to the daily queue after 125 minutes in the hourly queue. +# +# AGE_DATA="[['25',\\ +# '-e \\'\$msg{message}[0] == /Deferred: 452 4.2.2 Over quota/\\'',\\ +# 'overquota', 'main']]"; +# Every 25 minutes, move all files deferred because of quota +# violations from /var/spool/mqueue/main to +# /var/spool/mqueue/overquota where they can be processed on +# a different interval, or by some other means. +# +# If the above samples suggest Perl arrays, well, they are... +# +# AGE_DATA="$parm_def{'AGE_DATA'}"; Perl array Queue aging data +# +EOT + my ($ok, $var) = &get_value('AGE_DATA'); + my $tmpval = eval $var; + if ($@) { + warn $@; + } + else { + $var = $tmpval; + }; + if (not defined $var) { + print $ofh 'AGE_DATA="";',"\n"; + } + elsif (not ref $var) { + print $ofh 'AGE_DATA="',$var,'";',"\n"; + } + elsif (@{$var} == 0) { + print $ofh 'AGE_DATA="";',"\n"; + } + else { + print $ofh 'AGE_DATA="[\\',"\n"; + foreach my $entry (@{$var}) { + foreach my $ndx ($[ .. $#{@{$entry}}) { + @{$entry}[$ndx] =~ s/'/\\'/g; + }; + print $ofh "['",join("', '",@{$entry}),"'],\\\n"; + }; + print $ofh ']";',"\n"; + }; + print $ofh <<"EOT"; +# +#------------------------------------------------------------------------------ +# Hidden variables (the blood be upon your hands) +# +EOT + foreach my $key (sort keys %parm_hidden) { + my ($ok, $value); + # Don't evaluate value, just stuff it... + next if ( ! $parameter{$key} ); + ($ok, $value) = (1, $parameter{$key}); + print $ofh "$key=",'"',$value,'";',"\n"; + }; + print $ofh <<"EOT"; +# +#------------------------------------------------------------------------------ +# Deprecated variables (kept for reference) +# +EOT + foreach my $key (sort keys %parm_deprecated) { + my ($ok, $value); + # Don't evaluate value, just stuff it... + if ( $parm_deprecated{$key} ) { + ($ok, $value) = (1, join('','${', $parm_deprecated{$key}, '}')); + } + elsif ( $parameter{$key} ) { + ($ok, $value) = (1, $parameter{$key}); + }; + print $ofh "$key=",'"',$value,'";',"\n"; + }; + print $ofh <<"EOT"; +# +#------------------------------------------------------------------------------ +# Unknown variables (kept for reference) +# +EOT + foreach my $key (sort keys %parameter) { + if (! exists($parm_def{$key}) and + ! exists($parm_deprecated{$key})) { + # Don't evaluate value, just stuff it... + my ($ok, $value) = (1, $parameter{$key}); + print $ofh "$key=",'"',$value,'";',"\n"; + }; + }; + print $ofh <<"EOT"; +#------------------------------------------------------------------------------ +# + +EOT + + close($ofh); + }; + +# +#------------------------------------------------------------------------ +# Write updated cron file +#------------------------------------------------------------------------ +sub write_crontab { + my $var; + my $interval = ''; + my $test = "test -x @datadir@/sendmail/sendmail"; + my $command = ''; + my $ok = ''; + my $mailto = ''; + my $mmode = ''; + my $qmode = ''; + my $msp_line = ''; + my $mta_line = ''; + my $age_line = ''; + + ($ok, $mailto) = &get_value('CRON_MAILTO'); + if ( ! $ok ) { + return; + }; + + my $out_file = $output_file || "@sysconfdir@/cron.d/sendmail"; + print STDOUT "Writing $out_file.\n"; + $out_file = '&STDOUT' if ($out_file eq '-'); + unless ( open($ofh, ">$out_file") ) { + warn("Could not open $out_file($!), using STDOUT\n"); + open($ofh, ">&STDOUT"); + }; + $out_file = '-' if ($out_file eq '&STDOUT'); + + print $ofh <<"EOT"; +#################################################################### +##### This file is automagically generated -- edit at your own risk +##### +##### file: ${out_file} +##### generated via: (${interp_pgm} ${interp_vrm}) +##### ${main::program_name} +##### version: ${main::program_version} ${main::program_date} +##### by: ${user}\@${hostname} +##### on: ${current_time} +##### in: ${directory} +##### input files: +EOT + foreach my $file ( split(' ', $input_file) ) { + print $ofh <<"EOT"; +##### ${file} +EOT + }; + print $ofh <<"EOT"; +##### +#################################################################### +#------------------------------------------------------------------------------ +# +# $out_file +# +# Copyright (c) 2001-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# Version: ${main::program_version} +# Time-stamp: <${main::program_date}> +# +# Sendmail crontab - Call sendmail at various times to do the following: +# 1) Age queues - move undelivered mail to a slower queue +# 2) Retry any mail queued by the message submission process +# 3) run the queues (deliver mail) if a standalone daemon is not desired +# +# Each processes is independant and guided by /etc/mail/sendmail.conf and +# {sendmail,submit}.mc files. +# +# There isn't anything here that should need touching. +# +# Any requisite queue/misc parameters must be set in /etc/mail/sendmail.conf +# and reflected herein via /usr/sbin/sendmailconfig (or more directly via +# ${main::program_name}). +# +#------------------------------------------------------------------------------ +# +# use default path, shell, home +#SHELL=/bin/sh +#PATH= +#HOME= +# send mail to this user, as `mail/smmsp` isn't real. +MAILTO=$mailto +# +# format of entries: +# m h dom mon dow user command +# +#------------------------------------------------------------------------------ +# Every so often, give sendmail a chance to run the MSP queues. +# +EOT + ($ok, $interval) = &get_value('MSP_INTERVAL'); + $interval = join('', '*/', $interval); + $command = "$test && @datadir@/sendmail/sendmail cron-msp"; + ($ok, $mmode) = &get_value('MSP_MODE'); + ($ok, $qmode) = &get_value('QUEUE_MODE'); + if ($mmode eq 'cron' + #or ($mmode eq 'none' and $qmode eq 'cron') + ) { + $msp_line = + "$interval * * * *\t\tsmmsp\t$command"; + } + else { + $msp_line = + "#$interval * * * *\t\tsmmsp\t$command"; + }; + print $ofh "$msp_line\n"; + + print $ofh <<"EOT"; +# +#------------------------------------------------------------------------------ +# Every so often, give sendmail a chance to run the MTA queues. +# Will also run MSP queues if enabled +# +EOT + ($ok, $interval) = &get_value('QUEUE_INTERVAL'); + $interval = join('','*/',$interval); + $command = "$test && @datadir@/sendmail/sendmail cron-mta"; + if ($qmode eq 'cron') { + $mta_line = + "$interval * * * *\t\troot\t$command"; + } + else { + $mta_line = + "#$interval * * * *\t\troot\t$command"; + }; + print $ofh "$mta_line\n"; + + print $ofh <<"EOT"; +# +#------------------------------------------------------------------------------ +# Every so often, give sendmail a chance to age the queues. +# +EOT + ($ok, $var) = &get_value('AGE_DATA'); + my $tmpval = eval $var; + if ($@) { + warn $@; + } + else { + $var = $tmpval; + }; + if (not ref $var) { + print $ofh "# No queue aging\n"; + } + elsif (@{$var} == 0) { + print $ofh "# No queue aging\n"; + } + else { + foreach my $entry (@{$var}) { + $interval = "*/@$entry[0]"; + my $criteria = @$entry[1] || join('','-s ',60*@$entry[0]); + my $to = @$entry[2]; + my $from = @$entry[3]; + $command = "$test && @datadir@/sendmail/qtool.pl"; + $from = "@localstatedir@/spool/mqueue/$from" + if ($from !~ /^\//); + $to = "@localstatedir@/spool/mqueue/$to" + if ($to !~ /^\//); + $age_line = + "$interval * * * *\t\troot\t$command $criteria $to $from"; + print $ofh "$age_line >/dev/null\n"; + }; + }; + print $ofh <<"EOT"; +# +EOT + + close($ofh); + }; + +# +#------------------------------------------------------------------------ +# Update /etc/inetd.conf file +#------------------------------------------------------------------------ +sub update_inetd { + + # Don't try to write if we're debugging + if ($output_file ne '') { + return; + }; + + my ($ok, $mode) = &get_value('DAEMON_MODE'); + if ( $ok ) { + if ( $mode eq 'inetd' ) { + system 'update-inetd --group MAIL --enable smtp,smtps,587' + } + else { + system 'update-inetd --group MAIL --disable smtp,smtps,587' + }; + }; + + }; + +# +#------------------------------------------------------------------------ +# Update mail statistics information (create/delete files) +#------------------------------------------------------------------------ +sub update_files { + + # Don't try to write if we're debugging + if ($output_file ne '') { + return; + }; + + my ($class, $flags, $files, $options); + my ($ok, $stats); + my $file; + + # + # Read the mc/m4 files + &Parse_mc::read_dbs('', ''); + + # Obtain entry for HOST_STATUS_DIRECTORY + ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs('confHOST_STATUS_DIRECTORY'); + $file = @{$files}[0]; + ($ok, $stats) = &get_value('DAEMON_HOSTSTATS'); + if ( $ok and $file ne '-' ) { + if ( $stats and ! -d $file) { + print STDOUT "Enabling HOST statistics file($file).\n"; + system "mkdir ${file}"; + my $gid = getgrnam('smmsp'); + chown '0', $gid, $file; + chmod 02750, $file; + } + elsif ( ! $stats and -d $file ) { + print STDOUT "Disabling HOST statistics file($file).\n"; + system "rm -rf ${file}"; + }; + }; + + # Obtain entry for STATUS_FILE + ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs('STATUS_FILE'); + $file = @{$files}[0]; + ($ok, $stats) = &get_value('DAEMON_MAILSTATS'); + if ( $ok and $file ne '-' ) { + if ( $stats and ! -e $file) { + print STDOUT "Enabling MTA statistics file($file).\n"; + open 'STATS', ">$file"; + close 'STATS'; + my $gid = getgrnam('smmsp'); + chown '0', $gid, $file; + chmod 0640, $file; + } + elsif ( ! $stats and -e $file ) { + print STDOUT "Disabling MTA statistics file($file).\n"; + unlink $file; + }; + }; + + # Obtain entry for MSP_STATUS_FILE + ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs('MSP_STATUS_FILE'); + $file = @{$files}[0]; + ($ok, $stats) = &get_value('MSP_MAILSTATS'); + if ( $ok and $file ne '-') { + if ( $stats and ! -e $file ) { + print STDOUT "Enabling MSP statistics file($file).\n"; + open 'STATS', ">$file"; + close 'STATS'; + my $gid = getgrnam('smmsp'); + chown '0', $gid, $file; + chmod 0660, $file; + } + elsif ( ! $stats and -e $file ) { + print STDOUT "Disabling MSP statistics file($file).\n"; + unlink $file; + }; + }; + + }; + diff --git a/debian/local/update_db.in b/debian/local/update_db.in new file mode 100644 index 0000000..72ee337 --- /dev/null +++ b/debian/local/update_db.in @@ -0,0 +1,591 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# +# $Sendmail: update_db,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Update Sendmail databases for Debian +# +# Copyright (c) 1998-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes (to all): +# * assumes makemap dbtype /etc/mail/database < /etc/mail/database +# +# Notes (to self): +# * changes made herein *must* be reflected in +# parse_mc,update_mk,update_db,debian.m4 +# * multiple db options not supported +# * userdb can also have multiple databases and then a forward! +# * need sendmail stop/start +# +#----------------------------------------------------------------------------- +set -e; + +# List of db files/features/etc +db_files="databases Makefile crontab QUEUE_GROUP sendmail.cf submit.cf \ + confCR_FILE confCT_FILE confCW_FILE confUSERDB_SPEC \ + access_db authinfo bitdomain domaintable \ + genericstable mailertable uucpdomain \ + use_cw_file use_ct_file virtusertable ALIAS_FILE"; + +# Path to other sendmail helpers +if [ -x ./update_sendmail ]; then + sm_path='.'; +elif [ -x $(dirname $0)/update_sendmail ]; then + sm_path=$(dirname $0); +else + sm_path=@datadir@/sendmail; + fi; + +# control amount of output +verbosity=0; + +# flag used to ensure only one newaliases command is run +newaliases_run=0; + +# flag used to indicate a dataset has been moved, may need another update +changed=0; + +# max return code +max_rc=0; +missing_rqd=0; +missing_opt=0; +missing_cre=0; +m4_errors=0; + +#------------------------------------------------------------- +# Initial update of sendmail.mc/databases +#------------------------------------------------------------- +initial () { + if [ $verbosity -gt 1 ]; then + echo "initial()"; + fi; + # Sigh... I wish this was in Perl... + $sm_path/parse_mc || true; + }; + +#------------------------------------------------------------- +# Handle found databases +#------------------------------------------------------------- +is_found () { + if [ $verbosity -gt 1 ]; then + echo "is_found: $dbfeat - $dbname"; + fi; + process=1; + + case "$dbfeat" in + ALIAS_FILE) + if [ -f @sysconfdir@/mail/aliases -a ! -f /etc/aliases ]; then + echo "Moving @sysconfdir@/mail/aliases to /etc/aliases"; + mv @sysconfdir@/mail/aliases /etc/aliases; + ln -sf ../aliases @sysconfdir@/mail/aliases; + fi; + ;; + submit.cf) + if [ ! -f @datadir@/sendmail/cf/feature/msp.m4 ]; then + rm -f @sysconfdir@/mail/submit.cf 2>/dev/null; + rm -f @sysconfdir@/mail/submit.cf.errors 2>/dev/null; + process=0; + fi; + ;; + *) + ;; + esac; + }; + +#------------------------------------------------------------- +# Handle missing databases: +# moving /etc/xxx to /etc/mail/xxx +# rename /etc/mail/xxx to /etc/mail/yyy +#------------------------------------------------------------- +move_file () { + if [ -f $1 ]; then + if [ ! -L $1 ]; then + echo "Moving $1 to $dbname."; + mv $1 $dbname; + chown root:smmsp $dbname; + chmod 0644 $dbname; + if [ -f $1.db ]; then + mv -f /etc/$1.db $dbname.db; + fi; + if [ -f $1.pag ]; then + mv -f /etc/$1.pag $dbname.pag; + fi; + if [ -f $1.dir ]; then + mv -f /etc/$1.dir $dbname.dir; + fi; + changed=1; + process=1; + else + echo "$1 is a link, move it to $dbname"; + if [ "$dbopts" = "-o" ]; then + missing_opt=`expr $missing_opt + 1`; + else + missing_rqd=`expr $missing_rqd + 1`; + fi; + fi; + true; + else + false; + fi; + }; + +rename_file () { + if [ -f @sysconfdir@/mail/$1 ]; then + echo "Renaming @sysconfdir@/mail/$1 to $dbname."; + mv @sysconfdir@/mail/$1 $dbname; + chown root:smmsp $dbname; + chmod 0644 $dbname; + changed=1; + process=1; + true; + else + false; + fi; + }; + +is_not_found () { + if [ $verbosity -gt 1 ]; then + echo "is_not_found: $dbfeat - $dbname"; + fi; + + case "$dbfeat" in + databases|Makefile) + :; + ;; + use_cw_file|confCW_FILE) + if move_file /etc/local-host-names; then + :; + elif rename_file sendmail.cw; then + :; + elif move_file /etc/sendmail.cw; then + :; + else + missing_cre=`expr $missing_cre + 1`; + echo "Warning: $dbfeat source" \ + "file not found: $dbname"; + echo " it was created"; + echo "localhost" > $dbname; + echo `hostname -f` >> $dbname; + chown root:smmsp $dbname; + chmod 0644 $dbname; + fi; + ;; + use_ct_file|confCT_FILE) + if move_file /etc/trusted-users; then + :; + elif rename_file sendmail.ct; then + :; + elif move_file /etc/sendmail.ct; then + :; + else + missing_cre=`expr $missing_cre + 1`; + echo "Warning: $dbfeat source" \ + "file not found: $dbname"; + echo " it was created"; + touch $dbname; + chown root:smmsp $dbname; + chmod 0644 $dbname; + fi; + ;; + HELP_FILE) + if move_file /etc/sendmail.hf; then + :; + elif rename_file sendmail.hf; then + :; + else + echo "Error: $dbfeat source file not found: $dbname"; + missing_rqd=`expr $missing_rqd + 1`; + process=0; + fi; + ;; + ALIAS_FILE) + if [ -e /etc/$dbsname ]; then + echo "Linking /etc/$dbsname to $dbname"; + ln -sf ../$dbsname $dbname; + if [ -f /etc/$dbsname.db ]; then + mv /etc/$dbsname.db @sysconfdir@/mail; + fi; + if [ -f /etc/$dbsname.pag ]; then + mv /etc/$dbsname.pag @sysconfdir@/mail; + fi; + if [ -f /etc/$dbsname.dir ]; then + mv /etc/$dbsname.dir @sysconfdir@/mail; + fi; + elif [ "$dbopts" = "-o" ]; then + echo "Informational: $dbfeat source" \ + "file not found: $dbname"; + missing_opt=`expr $missing_opt + 1`; + process=0; + else + echo "Error: $dbfeat source file not found: $dbname"; + missing_rqd=`expr $missing_rqd + 1`; + process=0; + fi; + ;; + *.cf) + mcfile=$(echo "$dbsname" | sed -e 's/\..*//') + if move_file /etc/$dbsname; then + if [ -f @sysconfdir@/${mcfile}.cf ]; then + mv -f @sysconfdir@/${mcfile}.cf @sysconfdir@/mail/; + fi; + elif [ "$mcfile" = "sendmail" ]; then + cp @datadir@/sendmail/cf/debian/sendmail.mc \ + $dbname; + chown root:smmsp $dbname; + chmod 0644 $dbname; + elif [ "$mcfile" = "submit" ]; then + cp @datadir@/sendmail/cf/debian/submit.mc \ + $dbname; + chown root:smmsp $dbname; + chmod 0644 $dbname; + elif [ "$dbopts" = "-o" ]; then + echo "Informational: $dbfeat source" \ + "file not found: $dbname"; + missing_opt=`expr $missing_opt + 1`; + process=0; + else + echo "Error: $dbfeat source file not found: $dbname"; + missing_rqd=`expr $missing_rqd + 1`; + process=0; + fi; + ;; + QUEUE_GROUP) + echo "Warning: $dbfeat source" \ + "file not found: $dbname"; + echo " it was created"; + mkdir -p $dbname; + chown root:smmsp $dbname; + chmod 02750 $dbname; + ;; + crontab) + if [ -x $sm_path/update_conf ]; then + $sm_path/update_conf; + fi; + ;; + *) + if move_file /etc/$dbsname; then + :; + elif [ "$dbopts" = "-o" ]; then + :; + else + missing_cre=`expr $missing_cre + 1`; + echo "Warning: $dbfeat source" \ + "file not found: $dbname"; + echo " it was created"; + touch $dbname; + chown root:smmsp $dbname; + chmod 0644 $dbname; + fi; + ;; + esac; + }; + +#------------------------------------------------------------- +# Handle empty databases +#------------------------------------------------------------- +is_empty () { + if [ $verbosity -gt 1 ]; then + echo "is_empty: $dbfeat - $dbname"; + fi; + if [ $process -eq 1 ]; then + if [ "$dbtype" != "-" ]; then + rm -f $dbname.db; + rm -f $dbname.pag; + rm -f $dbname.dir; + fi; + case "$dbfeat" in + databases|Makefile) + :; + ;; + *) + echo "Informational: $dbfeat file empty: $dbname"; + if [ "$dbopts" = "-o" ]; then + process=0; + fi; + ;; + esac; + fi; + }; + +#------------------------------------------------------------- +# Handle no data (exists, but is only comments) databases +#------------------------------------------------------------- +is_comments () { + if [ $verbosity -gt 1 ]; then + echo "is_comments: $dbfeat - $dbname"; + fi; + if [ $process -eq 1 -a -s "$dbname" ]; then + if [ "$dbtype" != "-" ]; then + rm -f $dbname.db; + rm -f $dbname.pag; + rm -f $dbname.dir; + fi; + case "$dbfeat" in + databases|Makefile) + :; + ;; + *) + echo "Informational: $dbfeat no data: $dbname"; + if [ "$dbopts" = "-o" ]; then + process=0; + fi; + ;; + esac; + fi; + }; + +#------------------------------------------------------------- +# Handle normal databases (exists, has data) +#------------------------------------------------------------- +is_normal () { + if [ $verbosity -gt 1 ]; then + echo "is_normal: $dbfeat - $dbname"; + fi; + + # Make sure sensitive databases are *not* generally readable + if [ "$dbsname" = "authinfo" \ + -o "$dbsname" = "access" ]; then + chmod go-rwx $dbname; + fi; + + if [ $process -eq 1 -a $max_rc -eq 0 ]; then + case "$dbtype" in + '-'|text|ldap) + :; + ;; + parse_mc) + $sm_path/parse_mc || true; + ;; + update_conf) + $sm_path/update_conf || true; + ;; + update_mk) + $sm_path/update_mk || true; + ;; + btree) + echo "Updating $dbname..."; + @sbindir@/makemap -d $dbtype $dbname.new.db < $dbname; + chown root:smmsp $dbname.new.db; + chmod 0644 $dbname.new.db; + mv -f $dbname.new.db $dbname.db; + ;; + dbm | btree | hash) + echo "Updating $dbname..."; + @sbindir@/makemap $dbtype $dbname.new.db < $dbname; + chown root:smmsp $dbname.new.db; + if [ "$dbsname" = "authinfo" \ + -o "$dbsname" = "access" ]; then + chmod 0640 $dbname.new.db; + else + chmod 0644 $dbname.new.db; + fi; + mv -f $dbname.new.db $dbname.db; + ;; + newaliases) + echo "Updating $dbname..."; + if [ $newaliases_run -eq 0 ]; then + newaliases_run=1; + @sbindir@/sendmail -bi || true; + fi; + if [ -f $dbname.db ]; then + chown root:smmsp $dbname.db; + chmod 0644 $dbname.db; + fi; + ;; + m4) + mcfile=$(echo "$dbsname" | sed -e 's/\..*//'); + echo "Creating @sysconfdir@/mail/${mcfile}.cf..."; + rm -f @sysconfdir@/mail/${mcfile}.cf.errors; + m4 @sysconfdir@/mail/${mcfile}.mc \ + > @sysconfdir@/mail/${mcfile}.cf.new \ + 2> @sysconfdir@/mail/${mcfile}.cf.errors || true; + chown root:smmsp @sysconfdir@/mail/${mcfile}.cf.new; + chmod 0644 @sysconfdir@/mail/${mcfile}.cf.new; + if [ ! -s @sysconfdir@/mail/${mcfile}.cf.errors ]; then + rm -f @sysconfdir@/mail/${mcfile}.cf.errors; + else + chown root:smmsp @sysconfdir@/mail/${mcfile}.cf.errors; + cat @sysconfdir@/mail/${mcfile}.cf.errors; + echo " "; + m4_errors=1; + fi; + # Can't tell if the errors are fatal or not ;-{ + mv -f @sysconfdir@/mail/${mcfile}.cf.new \ + @sysconfdir@/mail/${mcfile}.cf; + ;; + *) + echo "$dbtype map not done herein"; + ;; + esac; + fi; + }; + +#------------------------------------------------------------- +# Handle completion +#------------------------------------------------------------- +final () { + if [ $verbosity -gt 1 ]; then + echo "final()"; + fi; + }; + + +# status report if not for single database +if [ -z "$1" ]; then + echo "Checking {sendmail,submit}.mc and related databases..."; +else + db_files="$1"; + fi; + +initial; + +for file in $db_files; do \ + line=$(grep -Ee "^[[:space:]]*$file" \ + @sysconfdir@/mail/databases || true); + while ([ "$line" != "" ]); do + str=$(echo "$line" | cut -d " +" -f 1); + line=$(echo "$line" | cut -d " +" -f 2-); + + # Strip line back into four pieces: feature, type, opts, name + dbfeat=$(echo "$str" | cut -d ":" -f 1); + dbtype=$(echo "$str" | cut -d ":" -f 2); + dbopts=$(echo "$str" | cut -d ":" -f 3); + dbname=$(echo "$str" | cut -d ":" -f 4); + dbregx=$(echo "$str" | cut -d ":" -f 5); + if [ $(dirname "$dbname") = "@sysconfdir@/mail" ]; then + dbsname=$(basename "$dbname"); + elif [ $(dirname "$dbname") = "@sysconfdir@" ]; then + dbsname=$(basename "$dbname"); + else + dbsname="$dbname"; + fi; + if [ "$dbopts" = "-" ]; then + dbopts=""; + fi; + if [ "$dbregx" = "-" ]; then + dbregx=""; + fi; + + # Check to see if we're doing one, or all + if [ ! -z "$1" ]; then + if [ "$1" = "$dbfeat" -o \ + "$1" = "$dbname" -o \ + "$1" = "$dbsname" ]; then + :; + else + continue; + fi; + fi; + + # Check for special database types + case "$dbtype" in + ldap) + if [ $verbosity -gt 0 ]; then + echo "Skipping $dbname..."; + fi; + continue + ;; + *) + ;; + esac; + + # Kluge for aliases... + if [ "$dbname" = "ldap" ]; then + continue; + fi; + + process=1; + if [ $verbosity -gt 0 ]; then + echo "Processing $dbname..."; + fi; + + # Check for database existance + if [ -f "$dbname" -o -d "$dbname" ]; then + is_found; + else + is_not_found; + fi; + + # Skip the rest for directories + if [ ! -d "$dbname" ]; then + + # Check for something in database + if [ ! -s "$dbname" ]; then + is_empty; + fi; + + # Check for real data (not just comments) + if [ $process -eq 1 ]; then + if ! grep -qEe "^[[:space:]]*[^$\#]" $dbname; then + is_comments; + fi; + fi; + + # Finally, assume a normal file... + is_normal; + fi; + + done; + done; + +final; + +# Final notices... +if [ $changed -ne 0 ]; then + echo " "; + echo "Informational: Some changes were made to file locations"; + echo " Make sure sendmail.cf is rebuilt"; + if [ $max_rc -lt 1 ]; then + max_rc=1; + fi; + fi; +if [ $missing_opt -ne 0 ]; then + echo " "; + echo "Informational: $missing_opt optional database(s) sources"; + echo " were not found, please investigate."; + fi; +if [ $missing_cre -ne 0 ]; then + echo " "; + echo "Warning: $missing_cre database(s) sources"; + echo " were not found, (but were created)"; + echo " please investigate."; + fi; +if [ $missing_rqd -ne 0 ]; then + echo " "; + echo "Error: $missing_rqd required database(s) sources"; + echo " were not found, correct this before starting sendmail!"; + if [ $max_rc -lt 2 ]; then + max_rc=2; + fi; + fi; +if [ $missing_opt -ne 0 -o $missing_rqd -ne 0 ]; then + echo " "; + echo "$0 assumes that databases, and their source datasets"; + echo "have the same base name (not counting the .db). If this is not"; + echo "true, $0 can not rebuild your databases to make sure"; + echo "they will work with the newer sendmail. You will have to do this"; + echo "yourself - before starting sendmail."; + echo " "; + fi; +if [ $m4_errors -ne 0 ]; then + echo " "; + echo "Warning: These messages were issued while creating sendmail.cf"; + echo " make sure they are benign before starting sendmail!"; + echo " "; + if [ -f @sysconfdir@/mail/sendmail.cf.errors ]; then + echo "Errors in generating sendmail.cf"; + cat @sysconfdir@/mail/sendmail.cf.errors; + fi; + if [ -f @sysconfdir@/mail/submit.cf.errors ]; then + echo "Errors in generating submit.cf"; + cat @sysconfdir@/mail/submit.cf.errors; + fi; + echo " " + if [ $max_rc -lt 2 ]; then + max_rc=2; + fi; + fi; +exit $max_rc; + diff --git a/debian/local/update_ldap.in b/debian/local/update_ldap.in new file mode 100644 index 0000000..5daca95 --- /dev/null +++ b/debian/local/update_ldap.in @@ -0,0 +1,118 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# +# $Sendmail: update_ldap,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Sendmail support for LDAP +# +# Copyright (c) 2000-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes: supports local umich-ldap and openldap v1/v2 servers +# +#----------------------------------------------------------------------------- +set -e + +# +# Flag to determine if this is an install or update +NEW=0; + +# +# Flag to determine if any local LDAP server was found +FOUND=0; + +# +# Path to LDAP server schema directory +LDAP_PATH=; +SCHEMA_PATH=; +SCHEMA_NAME=; +LDAP_VERSION=; + +install_schema () { +# +# Install sendmail.schema in the appropriate place +# +if [ ! -z "$SCHEMA_PATH" ]; then + if [ -f "${LDAP_PATH}/slapd.conf" ]; then + FOUND=1; + if [ ! -e "${SCHEMA_PATH}/sendmail.schema" ]; then + NEW=1; + fi; + cp -p @datadir@/sendmail/examples/ldap/$SCHEMA_NAME \ + $SCHEMA_PATH/sendmail.schema; + chmod 0644 $SCHEMA_PATH/sendmail.schema; + chown root:root $SCHEMA_PATH/sendmail.schema; + fi; + fi; + }; + +# +# Check if OpenLDAP (2.0.x) is installed +if [ -d /etc/ldap ]; then + LDAP_VERSION="$LDAP_VERSION OpenLDAP V2"; + LDAP_PATH='/etc/ldap'; + SCHEMA_PATH="${LDAP_PATH}/schema"; + SCHEMA_NAME=sendmail.schema.v2; + install_schema; + fi; + +# +# Check if OpenLDAP (1.x.x) is installed +if [ -d /etc/openldap ]; then + LDAP_VERSION="$LDAP_VERSION OpenLDAP V1"; + LDAP_PATH='/etc/openldap'; + SCHEMA_PATH="${LDAP_PATH}"; + SCHEMA_NAME=sendmail.schema.v1; + install_schema; + fi; + +# +# Check if UMich-LDAP (3.3) is installed +if [ -d /etc/umich-ldap ]; then + LDAP_VERSION="$LDAP_VERSION UMich-LDAP V3"; + LDAP_PATH='/etc/umich-ldap'; + SCHEMA_PATH="${LDAP_PATH}"; + SCHEMA_NAME=sendmail.schema.v1; + install_schema; + fi; + +# +# Tell them about the new wizbang features... +if [ $NEW -eq 0 ]; then + :; +else + echo " "; + echo "Creating/Updating $LDAP_VERSION information..."; + echo " "; + echo "$SCHEMA_PATH/sendmail.schema has been installed"; + fi; + +if [ $FOUND -eq 0 -a $NEW -eq 1 ]; then + cat <<-EOT + + No local LDAP server was located (tried openldap v2/v1, umich-ldap). + + If you wish to use sendmail and LDAP, you'll need to make sure your + server has the requisite schema setup. + + You can find the schema (old and new) in the following places: + * $SCHEMA_PATH/sendmail.schema for the version of LDAP you + currently have installed (if any) + * @datadir@/sendmail/examples/ldap/sendmail.schema.<v> + where <v> is + <v1> for older schema (sendmail.{o,a}t.conf) format + <v2> for newer schema (sendmail.schema) format + + If you later install a local LDAP server, be sure to re-run $0. + EOT +elif [ $FOUND -eq 1 -a $NEW -eq 1 ]; then + cat <<-EOT + + You have a local $LDAP_VERSION server! Depending upon how (and if) + you wish to use LDAP with sendmail, you'll want to check your + slapd.conf file and possibly include these files: + * $SCHEMA_PATH/sendmail.schema <- alias and other map support + * $SCHEMA_PATH/misc.schema <- OpenLDAP V2 ldap-mail-routing + + If you later change your local LDAP server, be sure to re-run $0. + EOT + fi; diff --git a/debian/local/update_mc.in b/debian/local/update_mc.in new file mode 100644 index 0000000..b157b6a --- /dev/null +++ b/debian/local/update_mc.in @@ -0,0 +1,212 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# +# $Sendmail: update_mc,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Update Sendmail databases for Debian +# +# Copyright (c) 2000-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes (to all): +# * assumes makemap dbtype /etc/mail/database < /etc/mail/database +# +# Notes (to self): +# * changes made herein *must* be reflected in +# parse_mc,update_mk,update_db,debian.m4 +# +#----------------------------------------------------------------------------- +set -e; + +changed=0; + +#----------------------------------------------------------------------------- +# Move sendmail.{mc,cf} from /etc/ to /etc/mail +if [ ! -f @sysconfdir@/mail/sendmail.mc ]; then + if [ -f /etc/sendmail.mc ]; then + echo "Moving /etc/sendmail.* to /etc/mail/"; + mv /etc/sendmail.mc @sysconfdir@/mail/sendmail.mc; + chown root:smmsp @sysconfdir@/mail/sendmail.mc; + chmod 0644 @sysconfdir@/mail/sendmail.mc; + changed=1; + fi; + if [ -f /etc/sendmail.cf ]; then + mv /etc/sendmail.cf @sysconfdir@/mail/sendmail.cf; + chown root:smmsp @sysconfdir@/mail/sendmail.cf; + chmod 0644 @sysconfdir@/mail/sendmail.cf; + changed=1; + fi; + fi; + +#----------------------------------------------------------------------------- +# Install prototype submit.mc +if [ ! -f @sysconfdir@/mail/submit.mc ]; then + cp -p @datadir@/sendmail/cf/debian/submit.mc \ + @sysconfdir@/mail/submit.mc; + chown root:smmsp @sysconfdir@/mail/submit.mc; + chmod 0644 @sysconfdir@/mail/submit.mc; + fi; + +#----------------------------------------------------------------------------- +# Make sure dialup support m4 files are extant +if [ ! -f @sysconfdir@/mail/dialup.m4 ]; then + touch @sysconfdir@/mail/dialup.m4; + chown root:smmsp @sysconfdir@/mail/dialup.m4; + chmod 0640 @sysconfdir@/mail/dialup.m4; + fi; +if [ ! -f @sysconfdir@/mail/provider.m4 ]; then + touch @sysconfdir@/mail/provider.m4; + chown root:smmsp @sysconfdir@/mail/provider.m4; + chmod 0640 @sysconfdir@/mail/provider.m4; + fi; + +#----------------------------------------------------------------------------- +# Make sure not using text mailertable (it doesn't work) +if (grep -qEe "^[[:space:]]*FEATURE\(\`?mailertable'?, \`text /etc/mail/mailertable'\)" @sysconfdir@/mail/sendmail.mc); then + changed=1; + echo "Correcting FEATURE(mailertable) in /etc/mail/sendmail.mc"; + sed -e "s=^\([[:space:]]*\)\(\`\?\)FEATURE(\`\?mailertable'\?, \`text /etc/mail/mailertable')\(dnl\)\?=\1\2FEATURE(\`mailertable')dnl=g" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + +#----------------------------------------------------------------------------- +# Make sure smrsh points to the correct location +if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?smrsh'?[[:space:]]*,.*\)" \ + @sysconfdir@/mail/sendmail.mc); then + changed=1; + echo "Correcting FEATURE(smrsh) in /etc/mail/sendmail.mc"; + sed -e "s=\([[:space:]]*\)\(\`\?\)FEATURE(\`\?smrsh'\?[[:space:]]*,.*)\(dnl\)\?=\1\2FEATURE(\`smrsh')dnl=g" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + +#----------------------------------------------------------------------------- +# Convert FEATURE(nouucp) to FEATURE(nouucp,reject) +if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?nouucp'?\)" \ + @sysconfdir@/mail/sendmail.mc); then + changed=1; + echo "Correcting FEATURE(nouucp) in /etc/mail/sendmail.mc"; + sed -e "s=^\([[:space:]]*\)\(\`\?\)FEATURE(\`\?nouucp'\?)\(dnl\)\?=\1\2FEATURE(\`nouucp', \`reject')dnl=g" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + +#----------------------------------------------------------------------------- +# Convert FEATURE(rbl) to FEATURE(dnsbl,rbl.maps.vix.com) +if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?rbl'?\)" \ + @sysconfdir@/mail/sendmail.mc); then + changed=1; + echo "Correcting FEATURE(rbl) in /etc/mail/sendmail.mc"; + sed -e "s=^\([[:space:]]*\)\(\`\?\)FEATURE(\`\?rbl'\?)\(dnl\)\?=\1\2FEATURE(\`dnsbl', \`rbl.maps.vix.com')dnl=g" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + +#----------------------------------------------------------------------------- +# Convert FEATURE(dont_masquerade_local) to FEATURE(local_no_masquerade) +if [ -e @datadir@/sendmail/cf/feature/local_no_masquerade.m4 ]; then + if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?dont_masquerade_local'?\)" \ + @sysconfdir@/mail/sendmail.mc); then + changed=1; + echo "Correcting FEATURE(dont_masquerade_local) in /etc/mail/sendmail.mc"; + sed -e "s=^\([[:space:]]*\)\(\`\?\)FEATURE(\`\?dont_masquerade_local'\?)\(dnl\)\?=\1\2FEATURE(\`local_no_masquerade')dnl=g" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + fi; + +#----------------------------------------------------------------------------- +# Convert FEATURE(access_db,...) to FEATURE(access_db) +if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?access_db'?[[:space:]]*,.*\)" \ + @sysconfdir@/mail/sendmail.mc); then + changed=1; + sed -e "s=^\([[:space:]]*\)\(\`\?\)FEATURE(\`\?access_db'\?[[:space:]]*,[[:space:]]*\`\?hash[[:space:]]*\(-o\)\?[[:space:]]*/etc/mail/access.db'\?[[:space:]]*)\(dnl\)\?=\1\2FEATURE(\`access_db')dnl=g" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + +#----------------------------------------------------------------------------- +# change include(/usr/share/sendmail/sendmail.cf/m4/cf.m4) +if (grep -qEe "^[[:space:]]*\`?include\(\`?@datadir@/sendmail/sendmail.cf/m4/cf.m4'?\)" \ + @sysconfdir@/mail/sendmail.mc); then + sed -e "s=sendmail/sendmail.cf=sendmail/cf=g" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + sed -e "s=sendmail/sendmail.cf=sendmail/cf=g" \ + @sysconfdir@/mail/submit.mc > @sysconfdir@/mail/submit.mc.new; + chown root:smmsp @sysconfdir@/mail/submit.mc.new; + chmod 0644 @sysconfdir@/mail/submit.mc.new; + mv @sysconfdir@/mail/submit.mc.new @sysconfdir@/mail/submit.mc; + fi; + +#----------------------------------------------------------------------------- +# Add include(/usr/share/sendmail/cf/m4/cf.m4) +if (grep -qEe "^[[:space:]]*\`?include\(\`?@datadir@/sendmail/cf/m4/cf.m4'?\)" \ + @sysconfdir@/mail/sendmail.mc); then + true; +else + changed=1; + echo "Adding include(.../cf.m4) to /etc/mail/sendmail.mc"; + sed -e "s=^\([[:space:]]*\)\(\`\?\)VERSIONID(=\1\2include(\`@datadir@/sendmail/cf/m4/cf.m4')dnl\\ +\1\2VERSIONID(=" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + +#----------------------------------------------------------------------------- +# Add define(`_USE_ETC_MAIL_')dnl +if (grep -qEe "^[[:space:]]*\`?define\(\`?_USE_ETC_MAIL_" \ + @sysconfdir@/mail/sendmail.mc); then + true; +else + changed=1; + sed -e "s=^\([[:space:]]*\)\(\`\?\)include(\`\?@datadir@/sendmail/cf/m4/cf.m4'\?)\(dnl\)\?=\1\2define(\`_USE_ETC_MAIL_')dnl\\ +include(\`@datadir@/sendmail/cf/m4/cf.m4')dnl=" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + +#----------------------------------------------------------------------------- +# Add DOMAIN(debian-mta) +if (grep -qEe "^[[:space:]]*\`?DOMAIN\(\`?debian-mta'?\)" \ + @sysconfdir@/mail/sendmail.mc); then + true; +else + changed=1; + echo "Adding DOMAIN(debian-mta) to /etc/mail/sendmail.mc"; + sed -e "s=^\([[:space:]]*\)\(\`\?\)OSTYPE(\`\?debian'\?)\(dnl\)\?=\1\2OSTYPE(\`debian')dnl\\ +\1\2DOMAIN(\`debian-mta')dnl=" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv /etc/mail/sendmail.mc.new /etc/mail/sendmail.mc + fi; + +#----------------------------------------------------------------------------- +# Cleanup submit.mc +sed -e "/^define(\`\?confRUN_AS_USER.*$/d" \ + -e "/^define(\`\?confTRUSTED_USER.*$/d" \ + @sysconfdir@/mail/submit.mc > @sysconfdir@/mail/submit.mc.new; + chown root:smmsp @sysconfdir@/mail/submit.mc.new; + chmod 0644 @sysconfdir@/mail/submit.mc.new; + mv /etc/mail/submit.mc.new /etc/mail/submit.mc + +exit $changed; diff --git a/debian/local/update_mk.in b/debian/local/update_mk.in new file mode 100644 index 0000000..02376ec --- /dev/null +++ b/debian/local/update_mk.in @@ -0,0 +1,661 @@ +#!/usr/bin/perl -w +#------------------------------------------------------------------------ +# +# $Sendmail: update_mk,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Create /etc/mail/Makefile for Debian Sendmail databases +# +# Copyright 1998-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes (to all): +# * +# +# Notes (to self): +# * Should actually put data in some files (local-host-names, etc) +# +#------------------------------------------------------------------------ +# +# Initialization of the perl environment +use strict; # be kosher +use Cwd; # provide cwd() +use Env; # A few environmental references +use integer; # Peformance +use Sys::Hostname; # make sure we have a valid hostname +use Getopt::Long; # parameter handling + +# Local libraries - for Debian Sendmail Perl helper functions +# BEGIN { $main::my_path = substr($0,$[,rindex($0,'/')) }; +use lib ('.', substr($0,$[,rindex($0,'/')), "@datadir@/sendmail"); +require Parse_mc; + +# Version of this program +#($main::MYNAME = $main::0) =~ s|.*/||; +#$main::Author = "Richard Nelson"; +#$main::AuthorMail = "cowboy\@debian.org"; +#$main::Version = '$Revision: 2.00 $ '; +$main::program_name = $0; +$main::program_version = '@sm_version@'; +$main::program_date = '@sm_date@ @sm_time@ cowboy'; +$main::debug = 0; + +my $interp_pgm = "$^X"; +my $interp_vrm = $]; +$interp_vrm = ("$^V" | '000') if (defined $^V); +my $current_time = scalar localtime; +my $user = getlogin || (getpwuid($<))[0] || "Unknown!!"; +my $hostname = hostname(); +my $directory = getcwd(); + +my $Makefile_def = "@sysconfdir@/mail/Makefile"; +# List of database entries that will be created if not found +my %created_dbs; +my @created_dbs; +# A few files (like exposed-users) can be listed >1 times ! +my %created_files = (); +my $reload_stamp = "@localstatedir@/run/sendmail/stampdir/reload"; + +# +#------------------------------------------------------------------------------ +# Finally, some code (almost) +#------------------------------------------------------------------------------ +# +# Argument handling... +$main::opt_help=''; +$main::opt_output_file=''; +$main::opt_input_file=''; +$main::opt_debug=''; +my @options = qw( + help|h + output-file|output_file|o:s + input-file|input_file|i:s + debug! + ); +my $result = GetOptions(@options); +if ( ! $result ) { + die "Terminating due to parameter error"; + }; +if ( $main::opt_help ) { + warn "$main::program_name $main::program_version $main::program_date\n"; + warn "$0 \n"; + warn " -help\n" if $main::opt_help; + warn " -debug\n" if $main::opt_debug; + warn " -o $main::opt_output_file\n" if $main::opt_output_file; + warn " -i $main::opt_input_file\n" if $main::opt_input_file; + exit 0; + }; + +my $Makefile = $main::opt_output_file || $Makefile_def; +${Parse_mc::database_file} = $main::opt_input_file + if $main::opt_input_file; +# $main::debug is used in Parse_mc ! +$main::debug = $main::opt_debug || $main::debug; + +# Let them know wtf is going on... +print STDOUT "Creating ${Makefile}...\n"; + +# Read the mc/m4 files +&Parse_mc::read_dbs($Parse_mc::database_file, ''); + +# Determine names with which we shall work +my @databases = &get_names(); + +# Write out the textual representation +&write_make; + +# +#------------------------------------------------------------------------------ +# Obtain list of candidate databases from sendmail.mc +#------------------------------------------------------------------------------ +sub get_names { + my @names; + + # Database types we know how to handle + my %make_types = ( + 'btree' => 1 + ,'dbm' => 1 + ,'hash' => 1 + ,'m4' => 1 + ,'newaliases' => 1 + ,'parse_mc' => 1 + ,'update_conf' => 1 + ,'update_mk' => 1 + ,'QUEUE_GROUP' => 1 + ); + + # Add any qualified databases to the list + foreach my $entry (&Parse_mc::names_dbs()) { + my ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs($entry); + if ( (exists($make_types{$entry}) or + exists($make_types{$class})) + and @{$files}[0] ne '-' + and ! exists($created_dbs{$entry})) { + push @names, $entry; + push @created_dbs, $entry; + $created_dbs{$entry} = ''; + }; + }; + + return @names; + }; + +# +#------------------------------------------------------------------------------ +# Create Makefile +#------------------------------------------------------------------------------ +sub write_make { + my $ofh = new FileHandle; + + $Makefile = '&STDOUT' if ($Makefile eq '-'); + unless ( open($ofh, ">$Makefile") ) { + warn("Could not open $Makefile($!), using STDOUT.\n"); + open($ofh, ">&STDOUT"); + }; + $Makefile = '-' if ($Makefile eq '&STDOUT'); + + &write_header($ofh); + &write_target_clean($ofh); + &write_target_restart($ofh); + &write_target_sendmail($ofh); + &write_targets($ofh); + &write_files($ofh); + &write_footer($ofh); + + close $ofh; + if ($Makefile eq $Makefile_def) { + my $gid = getgrnam('smmsp'); + chown '0', $gid, $Makefile; + chmod 0754, $Makefile; + }; + }; + +# +#------------------------------------------------------------------------------ +# Write Makefile header +#------------------------------------------------------------------------------ +sub write_header { + my ($ofh) = @_; + + print $ofh <<"EOT"; +#!/usr/bin/make -f +#################################################################### +##### This file is automagically generated -- edit at your own risk +##### +##### Copyright (c) 1998-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +##### +##### file: ${Makefile} Makefile for Sendmail databases +##### generated via: (${interp_pgm} ${interp_vrm}) +##### ${main::program_name} +##### version: ${main::program_version} ${main::program_date} +##### by: ${user}\@${hostname} +##### on: ${current_time} +##### in: ${directory} +##### input files: ${Parse_mc::database_file} +##### +##### Usage: +##### 1) Make all targets upto date - use one of the following: +##### A) \`(cd @sysconfdir@/mail && make)\` +##### B) \`make -f ${Makefile}\` +##### C) \`${Makefile}\` +##### 2) Force update of <target> - Add <target> to one of the +##### prior commands ie, \`${Makefile} access\`. Most +##### any reasonable <target> value is accepted. +##### +#################################################################### +SHELL=/bin/sh + +.SUFFIXES: +.PRECIOUS: $Makefile + +# +# all, the default target, will update everything +# +.PHONY: all +all: sendmail $reload_stamp +EOT + }; + +# +#------------------------------------------------------------------------------ +# Write Makefile 'CLEAN' target +#------------------------------------------------------------------------------ +sub write_target_clean { + my ($ofh) = @_; + my @names; + + %created_files = (); + foreach my $entry (@databases) { + next if ($entry eq 'QUEUE_GROUP' or $entry eq 'Makefile'); + my ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs($entry); + foreach my $file (@{$files}) { + next if ( $file eq '-' + or exists($created_files{$file}) ); + $created_files{$file} = ''; + my $dbname; + if ($class eq 'parse_mc' or $class eq 'update_mk' + or $class eq 'm4') { + $dbname = "@sysconfdir@/mail/$entry"; + } + elsif ($class eq 'update_conf') { + $dbname = "@sysconfdir@/cron.d/sendmail"; + } + elsif ($class eq 'btree' or $class eq 'hash' + or $class eq 'newaliases') { + $dbname = "$file.db"; + } + else { + $dbname = $file; + }; + push @names, $dbname; + }; + }; + + print $ofh <<"EOT"; + +# +# clean target, remove {sendmail,submit}.cf and generated databases +# +EOT + print $ofh + ".PHONY: clean\n", + "clean: FORCE\n", + "\trm -f ",join(";\n\trm -f ", @names),";\n"; + }; + +# +#------------------------------------------------------------------------------ +# Write Makefile 'RESTART' target +#------------------------------------------------------------------------------ +sub write_target_restart { + my ($ofh) = @_; + my $file; + + print $ofh <<"EOT"; + +# +# restart target, check to see if sendmail needs to be restarted +# +.PHONY: noreload norestart +noreload norestart: FORCE + \@touch $reload_stamp; + +.PHONY: reload restart +reload restart: FORCE + \@rm -f $reload_stamp; + \@\$(MAKE) -sf $Makefile $reload_stamp; + +EOT + + # Spew secondary target of actual restart + %created_files = (); + my @right; + foreach my $entry (sort &Parse_mc::restart_dbs()) { + if (! exists($created_dbs{$entry})) { + push @created_dbs, $entry; + $created_dbs{$entry} = ''; + }; + my ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs($entry); + foreach my $file (@{$files}) { + next if ( $file eq '-' + or exists($created_files{$file}) ); + $created_files{$file} = ''; + my $dbname = $file; + $dbname =~ s/\.mc$/\.cf/; + push @right, "$dbname"; + }; + }; + + print $ofh "$reload_stamp: \\\n\t", + join(" \\\n\t", @right), "\n", + "\t\@if [ ! -f \$\@ ]; then \\\n", + "\t\techo 'A forced reload...'; \\\n", + "\telse \\\n", + "\t\techo 'The following file(s) have changed:'; \\\n", + "\t\techo ' \$?'; \\\n", + "\t\tfi;\n", + "\t\@echo '** ** You should issue ", + "\`@sysconfdir@/init.d/sendmail reload\` ** **';\n"; + }; + +# +#------------------------------------------------------------------------------ +# Write Sendmail dependancies +#------------------------------------------------------------------------------ +sub write_target_sendmail { + my ($ofh) = @_; + + print $ofh <<"EOT"; + +# +# sendmail targets, depend upon *ALL* relevant files/databases +# +.PHONY: sendmail +sendmail: sendmail_files sendmail_dbs + +EOT + my (@smfiles, @smdbs); + + %created_files = (); + foreach my $entry (@created_dbs) { + my ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs($entry); + foreach my $file (@{$files}) { + next if $file eq '-'; + next if $file eq 'ldap'; # ALIAS hack + if ($class eq 'parse_mc' or $class eq 'update_mk' + or $class eq 'm4') { + push @smfiles, "$file" + if (!exists($created_files{$file})); + $created_files{$file} = ''; + push @smdbs, "@sysconfdir@/mail/$entry"; + } + elsif ($class eq 'update_conf') { + push @smdbs, "@sysconfdir@/cron.d/sendmail"; + } + elsif ($class eq 'btree' or $class eq 'hash' + or $class eq 'newaliases') { + push @smfiles, "$file" + if (!exists($created_files{$file})); + $created_files{$file} = ''; + push @smdbs, "$file.db"; + } + else { + push @smfiles, "$file" + if (!exists($created_files{$file})); + $created_files{$file} = ''; + }; + }; + }; + + print $ofh ".PHONY: sendmail_files\n", + "sendmail_files: \\\n\t", + join(" \\\n\t", @smfiles), "\n\n"; + print $ofh ".PHONY: sendmail_dbs\n", + "sendmail_dbs: \\\n\t", + join(" \\\n\t", @smdbs), "\n"; + }; + +# +#------------------------------------------------------------------------------ +# Write Makefile individual targets +#------------------------------------------------------------------------------ +sub write_targets { + my ($ofh) = @_; + my $file; + + print $ofh <<"EOT"; + +# +# Individual database targets +# + +# +# Default db type is hash (Must be in /etc/mail, or +# fully qualify the dataset for this target to work) +# +%.db: % FORCE + \@echo 'Updating \$\@...'; + \@@sbindir@/makemap hash \$\@.new.db < \$<; + \@chown root:smmsp \$\@.new.db; + \@chmod 0644 \$\@.new.db + \@mv -f \$\@.new.db \$\@; +EOT + + # Spew primary target of <target> + foreach my $entry (@databases) { + my ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs($entry); + my @names; + my $left = ''; + my $right = ''; + my $sleft = ''; + my $dbname = ''; + print $ofh "\n"; + + # Create short name(s) for database entries + $sleft .= "$entry "; + if ($class eq 'newaliases' or $class eq 'parse_mc' + or $class eq 'update_mk' or $class eq 'update_conf') { + $sleft = 'makefile make ' if ($class eq 'update_mk'); + $sleft .= 'cron ' if ($class eq 'update_conf'); + $sleft .= "$class "; + }; + + foreach my $file (@{$files}) { + next if $file eq '-'; + next if $file eq 'ldap'; # ALIAS hack + if ($entry eq 'QUEUE_GROUP') { + $dbname = ''; + $left = $entry; + } + elsif ($class eq 'parse_mc' or $class eq 'update_mk' + or $class eq 'm4') { + $dbname = "@sysconfdir@/mail/$entry"; + } + elsif ($class eq 'update_conf') { + $dbname = "@sysconfdir@/cron.d/sendmail"; + } + elsif ($class eq 'btree' or $class eq 'hash' + or $class eq 'newaliases') { + $dbname = "$file.db"; + } + else { + $dbname = $file; + }; + $left .= "$dbname "; + $right .= " $file"; + + # Create short name(s) for database entries + if ($class ne 'parse_mc' and $class ne 'update_mk' + and $class ne 'update_conf' + and $entry ne 'QUEUE_GROUP' + ) { + my $dbsname = "$dbname"; + $dbsname =~ s/\/etc\/mail\///; + $sleft .= "$dbsname " if ($entry ne $dbsname); + if ($file ne $dbname) { + $dbsname =~ s/\.db//; + $sleft .= "$dbsname " if ($entry ne $dbsname); + }; + }; + }; + + # Spew out a phony entry suitable for FORCE + print $ofh '.PHONY: ', $sleft, "\n"; + print $ofh $sleft,':', $right, " FORCE\n" + if ($entry ne 'QUEUE_GROUP'); + if ($class eq 'update_mk') { + print $ofh "\t\@touch $right;\n", + "\t\@\$(MAKE) -sf $Makefile $left;\n"; + } + elsif ($entry ne 'QUEUE_GROUP') { + print $ofh "\t\@rm -f $left;\n", + "\t\@\$(MAKE) -sf $Makefile $left;\n"; + }; + + # + # Spew out the whole enchilada for this database + # Hidden dependancies (need to parse includes) + $right .= join(''," @sysconfdir@/mail/dialup.m4", + " @sysconfdir@/mail/provider.m4") + if ($entry eq 'sendmail.cf'); + print $ofh $left, ':', $right, "\n"; + next if ($entry eq 'QUEUE_GROUP'); + print $ofh "\t\@echo 'Updating $entry ...';\n"; + print $ofh "\t\@@sbindir@/sendmail -bi || true;\n" + if ($class eq 'newaliases'); + print $ofh "\t\@@datadir@/sendmail/parse_mc || true;\n" + if ($class eq 'parse_mc'); + print $ofh "\t\@@datadir@/sendmail/update_mk || true;\n" + if ($class eq 'update_mk'); + print $ofh "\t\@@datadir@/sendmail/update_conf || true;\n" + if ($class eq 'update_conf'); + foreach my $file (@{$files}) { + next if ( $file eq 'ldap' ); # ALIAS hack + my $dbname = $file; + my $newname = $file; + my $mode = '0644'; + $mode = '0640' if ($entry eq 'authinfo' + or $entry eq 'access_db'); + $mode = '0644' if ($class eq 'm4'); + $mode = '0754' if ($class eq 'update_mk'); + $mode = '02750' if ($entry eq 'QUEUE_GROUP'); + if ($class eq 'btree' or $class eq 'hash') { + $dbname .= '.db'; + $newname .= '.new.db'; + if (index($flags, '-o') == -1) { + print $ofh "\t\@@sbindir@/makemap $class $newname \\\n", + "\t\t< $file;\n", + "\t\@chown root:smmsp $newname;\n", + "\t\@chmod $mode $newname;\n", + "\t\@mv -f $newname $dbname;\n"; + } + else { + print $ofh + "\t\@if [ -s $file ]; then \\\n", + "\t\t@sbindir@/makemap $class $newname \\\n", + "\t\t\t< $file;\\\n", + "\t\tchown root:smmsp $newname;\\\n", + "\t\tchmod $mode $newname;\\\n", + "\t\tmv -f $newname $dbname;\\\n", + "\t\tfi;\n"; + }; + } + elsif ($class eq 'newaliases') { + $newname .= '.db'; + print $ofh "\t\@if [ -f $newname ]; then \\\n", + "\t\tchown root:smmsp $newname; \\\n", + "\t\tchmod $mode $newname; \\\n", + "\t\tfi;\n"; + } + elsif ($class eq 'parse_mc' or $class eq 'update_mk') { + $newname = "@sysconfdir@/mail/$entry"; + print $ofh "\t\@chown root:smmsp $newname;\n", + "\t\@chmod $mode $newname;\n"; + } + elsif ($class eq 'm4') { + $dbname =~ s/\.mc$/\.cf/; + $newname =~ s/\.mc$/\.cf\.new/; + my $lead = "\t"; + my $leadh = "\t\@"; + my $lead2 = "\t\t"; + my $trail = ""; + if ($entry eq 'submit.cf') { + $lead = "\t\t"; + $leadh = "\t\t"; + $lead2 = "\t\t\t"; + $trail = "\\"; + }; + print $ofh + "\t\@rm -f ${dbname}.errors\n"; + print $ofh + "\t\@if [ -f @datadir@/sendmail/cf/feature/msp.m4 ]; ", + "then \\\n" if ($entry eq 'submit.cf'); + print $ofh + "${leadh}m4 $file > $newname \\\n", + "${lead2}2> ${dbname}.errors || true; $trail\n", + "${leadh}chown root:smmsp $newname; $trail\n", + "${leadh}chmod $mode $newname; $trail\n", + "${leadh}mv -f $newname $dbname; $trail\n", + "${leadh}if [ -s ${dbname}.errors ]; then \\\n", + "${lead2}chown root:smmsp ${dbname}.errors; \\\n", + "${lead2}cat ${dbname}.errors; \\\n", + "${lead}else \\\n", + "${lead2}rm -f ${dbname}.errors; \\\n", + "${lead2}fi; $trail\n"; + print $ofh + "${lead}fi;\n" if ($entry eq 'submit.cf'); + }; + }; + }; + }; + +# +#------------------------------------------------------------------------------ +# Write Makefile file targets (create any missing files) +#------------------------------------------------------------------------------ +sub write_files { + my ($ofh) = @_; + + print $ofh <<"EOT"; + +# +# Individual file targets - create any requisite files +# +EOT + + %created_files = (); + foreach my $entry (@created_dbs) { + my ($class, $flags, $files, $options) = + &Parse_mc::entry_dbs($entry); + + # These are done above... + next if ($entry eq 'databases' + or $entry eq 'Makefile'); + + foreach my $file (@{$files}) { + next if ( $file eq '-' + or exists($created_files{$file}) ); + $created_files{$file} = ''; + my $mode = '0644'; + $mode = '0640' if ($entry eq 'authinfo' + or $entry eq 'access_db'); + $mode = '0644' if ($class eq 'm4'); + $mode = '0754' if ($class eq 'update_mk'); + $mode = '02750' if ($entry eq 'QUEUE_GROUP'); + print $ofh "\n$file:\n", + "\t\@echo 'Creating $file';\n"; + if ($entry eq 'QUEUE_GROUP') { + print $ofh "\t\@install -d", + " -o root -g smmsp -m $mode $file;\n", + "\t\@chown root:smmsp $file;\n", + "\t\@chmod $mode $file;\n"; + } + elsif ($entry eq 'sendmail.cf') { + print $ofh "\t\@@sbindir@/sendmailconfig", + " --no-reload;\n"; + } + elsif ($entry eq 'submit.cf') { + print $ofh "\t\@cp @datadir@/sendmail/", + "cf/debian/submit.mc \\\n", + "\t\t$file;\n", + "\t\@chown root:smmsp $file;\n", + "\t\@chmod $mode $file;\n"; + } + elsif ($entry eq 'crontab') { + print $ofh "\t\@@datadir@/sendmail/update_conf;\n"; + } + # FIXME: come back and create real data + # where needed (local-host-names, etc) + elsif (index($flags, '-o') == -1) { + print $ofh "\t\@touch $file;\n", + "\t\@chown root:smmsp $file;\n", + "\t\@chmod $mode $file;\n"; + } + elsif (index($flags, '-o') != -1) { + print $ofh "\t# Optional file...\n"; + }; + }; + }; + }; + +# +#------------------------------------------------------------------------------ +# Write Makefile footer +#------------------------------------------------------------------------------ +sub write_footer { + my ($ofh) = @_; + +print $ofh <<"EOT"; + +# +# FORCE target, allow one to override dependancies +# +.PHONY: FORCE +FORCE: ; + +EOT + }; + diff --git a/debian/local/update_notices b/debian/local/update_notices new file mode 100644 index 0000000..522c1ef --- /dev/null +++ b/debian/local/update_notices @@ -0,0 +1,177 @@ +#!/bin/sh +#----------------------------------------------------------------------------- +# +# Update Notices for Debian Sendmail +# +# Copyright (c) 2001-2002 Richard Nelson. All Rights Reserved. +# Time-stamp: <2001/08/15 15:00:00 cowboy> +# +# Notes (to all): +# * +# +# Notes (to self): +# * +# +#----------------------------------------------------------------------------- +set -e; +notices=0; +version=$1; +export LANG=C; # for the comparison of mail version... + +#----------------------------------------------------------------------------- +# Notice Item +#----------------------------------------------------------------------------- +Notice_Item () { + if [ $notices -eq "0" ]; then + if [ -z $version ]; then + echo ' +*** WELCOME ***.................*** WELCOME ***.................*** WELCOME *** +'; + else + echo ' +*** IMPORTANT ***..............*** IMPORTANT ***..............*** IMPORTANT *** +'; + fi; + fi; + notices=`expr $notices + 1`; + echo ''; + echo "${notices}: ....................................................."; + cat -; + }; + +#----------------------------------------------------------------------------- +if [ -z "$version" ]; then + Notice_Item <<-EOT; + Sendmail is a powerful MTA, and you may find the sendmail-doc package + useful in the configuration phase. You should find even the few files + in /usr/share/doc/sendmail useful - they note recent Sendmail and Debian + changes, along with information on the features present in this package. + EOT + fi; + +#----------------------------------------------------------------------------- +if test ! -z "$version" && \ + (dpkg --compare-versions "$version" lt "00.00.00-00"); then + Notice_Item <<-EOT; + EOT + fi; + +#----------------------------------------------------------------------------- +if test ! -z "$version" && \ + (dpkg --compare-versions "$version" lt "8.12.6-5"); then + Notice_Item <<-EOT; + + The group smmsp may have been created within the user, not + system range. To correct this issue, the group will be deleted + and recreated. + + For this to work, you will need to let sendmailconfig run, or + manually run /usr/share/sendmail/update_sendmail immediately + after saying 'no' to the sendmailconfig questions. + EOT + fi; + +#----------------------------------------------------------------------------- +if test ! -z "$version" && \ + (dpkg --compare-versions "$version" lt "8.12.2-1"); then + Notice_Item <<-EOT; + smrsh functionality has moved from /usr/lib/sm.bin to /etc/mail/smrsh. + + Sendmail will populate the directory with some of the more common MDAs + (procmail,maildrop,deliver,etc.) that are installed, but doesn't know + about listserver type programs (majordomo, mailman, etc.) So you'll + need to place links to those binaries in /etc/mail/smrsh. + + Also, if you add a new MDA, you'll need to rerun sendmailconfig to + make sure the MDA is available for smrsh processing! + EOT + Notice_Item <<-EOT; + Sendmail has changed to use the standard uid/gid smmsp for the MSP. + If you've not changed queue directories, you'll be all set. + + However, if you've moved queue directories, you'll need to make sure + that all of them are 0750 root:smmsp + EOT + fi; + +#----------------------------------------------------------------------------- +if test ! -z "$version" && \ + (dpkg --compare-versions "$version" lt "8.12.0-1"); then + Notice_Item <<-EOT; + The automatic virtual-host changes have been removed because + they caused problems for some people... + + If you need to do ip based virtual hosting, add HACK(\`virthost_by_ip')dnl + to your sendmail.mc and read /usr/share/doc/sendmail/op/op.{ps,txt}.gz + for the 'b' modifier to DAEMON_OPTIONS. + EOT + Notice_Item <<-EOT; + If you'd like to support MSP->MTA and/or MTA->MTA authentication, you + can get a good start by using HACK(\`debian_auth')dnl. + EOT + Notice_Item <<-EOT; + The commands 'mailq' and 'hoststat' are now useable by normal users. + EOT + Notice_Item <<-EOT; + Sendmail now defaults to being uid=mail (instead of daemon) when + calling the MDA to deliver mail. This means that if you have files + that are written to by the MDA, they need to be writable by uid=mail! + EOT + fi; + +#----------------------------------------------------------------------------- +if test ! -z "$version" && \ + (dpkg --compare-versions "$version" lt "8.11.6+8.12.0.Beta19-1"); then + Notice_Item <<-EOT; + You can now control the collection of host statistics via settings in + /etc/mail/sendmail.conf, please edit the file to your needs. + EOT + fi; + +#----------------------------------------------------------------------------- +if test ! -z "$version" && \ + (dpkg --compare-versions "$version" lt "8.11.5+8.12.0.Beta17-1"); then + Notice_Item <<-EOT; + You can now control the collection of mailer statistics via settings in + /etc/mail/sendmail.conf, please edit the file to your needs. + EOT + fi; + +#----------------------------------------------------------------------------- +if test ! -z "$version" && \ + (dpkg --compare-versions "$version" lt "8.11.3+8.12.0.Beta7-4"); then + Notice_Item <<-EOT; + Sendmail has extended control over queue management, and these changes + can cause a performance drop if you don't change your local + configuration. + + Old: + MaxDaemonChildren controlled number of listener *and* queue runners + + Sendmail would fork as many children as needed to run the queues + + New: + MaxDaemonChildren still works as a total limit + MaxQueueChildren limits *only* the number of total queue runners + MaxRunnersPerQueue limits the number of runners per individual + queue (in 8.11+, you can have multiple queues) -- *AND* you + can override this global limit on per queue basis! + MaxQueueRunSize limits the number of messages processed per queue run + + Sendmail only forks upto MaxRunnersPerQueue for each queue per run + + The gotcha here is that MaxRunnersPerQueue defaults to one ! + + I've changed the default MaxRunnersPerQueue to 5, so deliveries aren't + single threaded, but you may want to have more or less than 5. + EOT + fi; + +#----------------------------------------------------------------------------- +if [ "$notices" -ne "0" ]; then + echo ''; + echo -n 'Press [ENTER] to continue'; + read yn; + fi; +#----------------------------------------------------------------------------- + diff --git a/debian/local/update_sendmail b/debian/local/update_sendmail new file mode 100644 index 0000000..e7c5fe1 --- /dev/null +++ b/debian/local/update_sendmail @@ -0,0 +1,77 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# +# Update Sendmail environment for Debian +# +# Copyright (c) 2001-2001 Richard Nelson. All Rights Reserved. +# Time-stamp: <2001/01/17 10:00:00 cowboy> +# +# Notes (to all): +# * +# +# Notes (to self): +# * +# +#----------------------------------------------------------------------------- +set -e; + +# Path to other sendmail helpers +sm_path=$(dirname $0); + +# control amount of output +verbosity=0; + +# flag used to indicate a dataset has been moved, may need another update +changed=0; + +#------------------------------------------------------------- +# Make sure the system is setup +if [ -x $sm_path/update_sys ]; then + $sm_path/update_sys || changed=1; + fi; + +#------------------------------------------------------------- +# update smrsh/sensible-mda information if possible +if [ -x $sm_path/update_smrsh ]; then + $sm_path/update_smrsh || true; + fi; + +#------------------------------------------------------------- +# update LDAP information if possible +if [ -x $sm_path/update_ldap ]; then + $sm_path/update_ldap || true; + fi; + +#------------------------------------------------------------- +# update SMTP AUTH (SASL) information if possible +if [ -x $sm_path/update_auth ]; then + $sm_path/update_auth || true; + fi; + +#------------------------------------------------------------- +# update TLS(SSL) information if possible +if [ -x $sm_path/update_tls ]; then + $sm_path/update_tls || true; + fi; + +#------------------------------------------------------------- +# Check and update (if needed) /etc/hosts.allow +if [ -x $sm_path/update_tcpd ]; then + $sm_path/update_tcpd || true; + fi; + +#------------------------------------------------------------- +# Perform some [safe] updates to an existing sendmail.mc to make +# sure it is compatible with the current executables. +if [ -x $sm_path/update_mc ]; then + $sm_path/update_mc || changed=1; + fi; + +#------------------------------------------------------------- +# Make sure the databases are in the expected locations +if [ -x $sm_path/update_db ]; then + $sm_path/update_db || changed=1; + fi; + +#------------------------------------------------------------- +exit $changed diff --git a/debian/local/update_smrsh.in b/debian/local/update_smrsh.in new file mode 100644 index 0000000..8a27d6d --- /dev/null +++ b/debian/local/update_smrsh.in @@ -0,0 +1,73 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# +# $Sendmail: update_smrsh,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Update MDA programs used by Sendmail for Debian +# +# Copyright (c) 2002-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes (to all): +# * The entries in /etc/mail/smrsh are used by the feature(smrsh) and +# sensible-mda. +# +# Notes (to self): +# * +# +#----------------------------------------------------------------------------- +set -e; + +# flag used to indicate a dataset has been moved, may need another update +changed=0; +new=1; + +def_progs="\ + @libexecdir@/mail.local \ + @libexecdir@/sensible-mda \ + /usr/bin/vacation \ + /usr/bin/procmail \ + /usr/bin/maildrop \ + /usr/bin/deliver \ + "; + +echo " "; +echo "Checking for installed MDAs..."; + +#------------------------------------------------------------------------------ +# /etc/mail/smrsh is where the links to MDAs and authorized forwarding progs +if [ ! -e @sysconfdir@/mail/smrsh ]; then + changed=1; + new=1; + fi; +chown root:root @sysconfdir@/mail/smrsh; +chmod 02755 @sysconfdir@/mail/smrsh; + +#------------------------------------------------------------------------------ +# Iterate over the default list of programs and create any missing items +for file in $def_progs; do + ppath=$(dirname "$file"); + pname=$(basename "$file"); + + # the file doesn't exist, see if we can remove its link + if [ ! -e $file ]; then + + # let have there own version eh? + if [ -e @sysconfdir@/mail/smrsh/$pname ]; then + true; + + # no, if its a danglink symlink, drop it + elif [ -L @sysconfdir@/mail/smrsh/$pname ]; then + echo "Removing link for no longer extant program ($pname)"; + rm @sysconfdir@/mail/smrsh/$pname; + fi; + + # the file exists, see if we need to add its link + elif [ ! -e @sysconfdir@/mail/smrsh/$pname ]; then + echo "Adding link for newly extant program ($pname)"; + ln -sf $file @sysconfdir@/mail/smrsh/$pname; + changed=1; + fi; + done; + +#------------------------------------------------------------------------------ +exit $changed; diff --git a/debian/local/update_sys.in b/debian/local/update_sys.in new file mode 100644 index 0000000..89cad19 --- /dev/null +++ b/debian/local/update_sys.in @@ -0,0 +1,282 @@ +#!/bin/sh +#----------------------------------------------------------------------------- +# +# $Sendmail: update_sys,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Update system files used by Sendmail for Debian +# +# Copyright (c) 2001-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes (to all): +# * Several directories/files have their permissions forced... +# This is done to allow the MSP/MTA split +# * This exec runs 'set +e' to ignore errors!!! this is done to +# support those running NFS (or similiar) systems, where the +# chmod/chown may fail - If this happens, you'll need to update +# those items by hand ! +# +# Notes (to self): +# * +# +#----------------------------------------------------------------------------- +set +e; + +# flag used to indicate a dataset has been moved, may need another update +changed=0; + +#------------------------------------------------------------------------------ +# Create any needed directories, and move any prior data to its new home + +#------------------------------------------------------------------------------ +# /etc/aliases should exist, though not owned by sendmail, we'll create one +if [ ! -e @sysconfdir@/aliases ]; then + changed=1; + if [ -f @datadir@/doc/sendmail/examples/db/aliases ]; then + echo "Creating @sysconfdir@/aliases (not found)"; + cp @datadir@/sendmail/examples/db/aliases \ + @sysconfdir@/aliases; + else + touch @sysconfdir@/aliases; + fi; + chown root:root @sysconfdir@/aliases; + chmod 0644 @sysconfdir@/aliases; + fi; + +#------------------------------------------------------------------------------ +# /var/mail is the FHS user mail location, /var/spool/mail is older +# Note: we set the sticky bit to prevent a sgid exploit from erasing files +if [ ! -e @localstatedir@/mail ]; then + changed=1; + if [ -L @localstatedir@/spool/mail ]; then + ln -sf spool/mail @localstatedir@/mail; + elif [ -d @localstatedir@/spool/mail ]; then + mv @localstatedir@/spool/mail @localstatedir@/mail; + chown root:root @localstatedir@/mail; + chmod 03775 @localstatedir@/mail; + else + mkdir @localstatedir@/mail; + chown root:root @localstatedir@/mail; + chmod 03775 @localstatedir@/mail; + fi; + fi; +# +# Make sure the sticky bit is set in pre-existing directories +if [ -d @localstatedir@/mail -a ! -k @localstatedir@/mail ]; then + chmod a+t @localstatedir@/mail; + fi; +if [ -d @localstatedir@/spool/mail -a ! -k @localstatedir@/spool/mail ]; then + chmod a+t @localstatedir@/spool/mail; + fi; +if [ ! -d @localstatedir@/spool/mail -a ! -L @localstatedir@/spool/mail ]; then + ln -sf ../mail @localstatedir@/spool/mail; + #mkdir @localstatedir@/spool/mail; + #chown root:root @localstatedir@/spool/mail; + #chmod 03775 @localstatedir@/spool/mail; + fi; + +#------------------------------------------------------------------------------ +# /etc/mail is where the Sendmail config files live +if [ ! -d @sysconfdir@/mail ]; then + changed=1; + mkdir @sysconfdir@/mail; + fi; +chown root:smmsp @sysconfdir@/mail; +chmod 02755 @sysconfdir@/mail; +# +# With the MSP/MTA split, we don't want any g=w files or directories +# to save us from potential sgid attacks +find @sysconfdir@/mail -perm +g=w \( -type f -o -type d \) -print \ + | xargs -r chmod g-w,o-w; + +#------------------------------------------------------------------------------ +# /var/run/sendmail is where we store pid files, control sockets, stamps, etc +if [ ! -d @localstatedir@/run/sendmail ]; then + changed=1; + mkdir @localstatedir@/run/sendmail; + fi; +chown root:smmsp @localstatedir@/run/sendmail; +chmod 02750 @localstatedir@/run/sendmail; +if [ ! -d @localstatedir@/run/sendmail/mta ]; then + mkdir @localstatedir@/run/sendmail/mta; + fi; +chown root:smmsp @localstatedir@/run/sendmail/mta; +chmod 02750 @localstatedir@/run/sendmail/mta; +if [ ! -d @localstatedir@/run/sendmail/msp ]; then + mkdir @localstatedir@/run/sendmail/msp; + fi; +chown smmsp:smmsp @localstatedir@/run/sendmail/msp; +chmod 02770 @localstatedir@/run/sendmail/msp; +if [ ! -d @localstatedir@/run/sendmail/stampdir ]; then + mkdir @localstatedir@/run/sendmail/stampdir; + fi; +chown root:smmsp @localstatedir@/run/sendmail/stampdir; +chmod 02770 @localstatedir@/run/sendmail/stampdir; +# +# Remove older files +rm -f /var/run/sendmail.pid; +rm -f /var/run/sendmail/sendmail.pid; +rm -f /var/run/sendmail/smcontrol; + +#------------------------------------------------------------------------------ +# /var/lib/sendmail is where we stuff host status and sendmail.st +# instead of the mail queue and /etc/ (respectively) +if [ ! -d @localstatedir@/lib/sendmail ]; then + changed=1; + mkdir @localstatedir@/lib/sendmail; + fi; +chown root:smmsp @localstatedir@/lib/sendmail; +chmod 02750 @localstatedir@/lib/sendmail; +if [ -d /var/state/sendmail/host_status ]; then + changed=1; + echo "Moving /var/state/sendmail/host_status to /var/lib/sendmail/"; + mv -f /var/state/sendmail/host_status \ + @localstatedir@/lib/sendmail/host_status; + fi; +if [ -d /var/sendmail/host_status ]; then + changed=1; + echo "Moving /var/sendmail/host_status to /var/lib/sendmail/"; + mv -f /var/sendmail/host_status \ + @localstatedir@/lib/sendmail/host_status; + fi; +if [ ! -d @localstatedir@/lib/sendmail/host_status ]; then + mkdir @localstatedir@/lib/sendmail/host_status; + fi; +chown root:smmsp @localstatedir@/lib/sendmail/host_status; +chmod 02750 @localstatedir@/lib/sendmail/host_status; +find @localstatedir@/lib/sendmail/host_status -type d -print \ + | xargs -r chown root:smmsp; +find @localstatedir@/lib/sendmail/host_status -type d -print \ + | xargs -r chmod 02750; +# +# if sendmail.st doesn't exist, don't create it ! +if [ -f /var/log/sendmail.st ]; then + changed=1; + echo "Moving /var/log/sendmail.st to /var/lib/sendmail/"; + mv /var/log/sendmail.st \ + @localstatedir@/lib/sendmail/sendmail.st; + fi; +if [ -f /var/sendmail/sendmail.st ]; then + changed=1; + echo "Moving /var/sendmail/sendmail.st to /var/lib/sendmail/"; + mv /var/sendmail/sendmail.st \ + @localstatedir@/lib/sendmail/sendmail.st; + fi; +if [ -f @localstatedir@/lib/sendmail/sendmail.st ]; then + chown root:smmsp @localstatedir@/lib/sendmail/sendmail.st; + chmod 0640 @localstatedir@/lib/sendmail/sendmail.st; + if [ ! -f @localstatedir@/lib/sendmail/sm-client.st ]; then + touch @localstatedir@/lib/sendmail/sm-client.st; + fi; + fi; +if [ -f @localstatedir@/lib/sendmail/sm-client.st ]; then + chown smmsp:smmsp @localstatedir@/lib/sendmail/sm-client.st; + chmod 0660 @localstatedir@/lib/sendmail/sm-client.st; + fi; +if [ ! -f @localstatedir@/lib/sendmail/dead.letter ]; then + touch @localstatedir@/lib/sendmail/dead.letter; + fi; +chown root:smmsp @localstatedir@/lib/sendmail/dead.letter; +chmod 0660 @localstatedir@/lib/sendmail/dead.letter; +# +# Remove older files +rm -rf /var/sendmail; +rm -rf /var/state/sendmail; + +#------------------------------------------------------------------------------ +# /var/spool/mqueue is the MTA mail queue directory +if [ ! -d @localstatedir@/spool/mqueue ]; then + changed=1; + mkdir @localstatedir@/spool/mqueue; + fi; +chown root:smmsp @localstatedir@/spool/mqueue; +chmod 02750 @localstatedir@/spool/mqueue; +# +# With the MSP/MTA split, we *DO* need g=r, gid=smmsp queue directories and +# files mailq to work... +find @localstatedir@/spool/mqueue -print \ + | xargs -r chown root:smmsp; +find @localstatedir@/spool/mqueue -type d -print \ + | xargs -r chmod g+rxs-w,o-rwx; +find @localstatedir@/spool/mqueue -type f -print \ + | xargs -r chmod g+r-wx,o-rwx; + +#------------------------------------------------------------------------------ +# /var/spool/mqueue-client is the MSP mail queue directory +if [ ! -d @localstatedir@/spool/mqueue-client ]; then + mkdir @localstatedir@/spool/mqueue-client; + fi; +chown smmsp:smmsp @localstatedir@/spool/mqueue-client; +chmod 02770 @localstatedir@/spool/mqueue-client; +find @localstatedir@/spool/mqueue-client -perm +o=r -print \ + | xargs -r chmod o-rwx; + +#------------------------------------------------------------------------------ +# /var/log/mail is where we keep our log crap (via syslog) +# Try to fixup syslog, syslog-ng, etc... +if [ ! -d @localstatedir@/log/mail -a \ + ! -f /var/log/mail ]; then + echo "Moving /var/log/mail.* to /var/log/mail/mail.*"; + echo "You will need to adjust any log reading scripts accordingly"; + mkdir @localstatedir@/log/mail; + chown root:smmsp @localstatedir@/log/mail; + chmod 02770 @localstatedir@/log/mail; + mv -f /var/log/mail.log @localstatedir@/log/mail/ \ + 1>/dev/null 2>&1; + mv -f /var/log/mail.log.[0-9]* @localstatedir@/log/mail/ \ + 1>/dev/null 2>&1; + mv -f /var/log/mail.err @localstatedir@/log/mail/\ + 1>/dev/null 2>&1; + mv -f /var/log/mail.err.[0-9]* @localstatedir@/log/mail/ \ + 1>/dev/null 2>&1; + mv -f /var/log/mail.info @localstatedir@/log/mail/ \ + 1>/dev/null 2>&1; + mv -f /var/log/mail.info.[0-9]* @localstatedir@/log/mail/ \ + 1>/dev/null 2>&1; + mv -f /var/log/mail.warn @localstatedir@/log/mail/ \ + 1>/dev/null 2>&1; + mv -f /var/log/mail.warn.[0-9]* @localstatedir@/log/mail/ \ + 1>/dev/null 2>&1; + # Create link for compatility with logscan package + ln -sf @localstatedir@/log/mail/mail.log /var/log/mail.log; + fi; +# +# Support for sysklogd package +if [ -f /etc/syslog.conf ]; then + sed -e "s?/var/log/mail.log?@localstatedir@/log/mail/mail.log?g" \ + -e "s?/var/log/mail.err?@localstatedir@/log/mail/mail.err?g" \ + -e "s?/var/log/mail.info?@localstatedir@/log/mail/mail.info?g" \ + -e "s?/var/log/mail.warn?@localstatedir@/log/mail/mail.warn?g" \ + /etc/syslog.conf > /etc/syslog.conf.new; + chown root:root /etc/syslog.conf.new; + chmod 0644 /etc/syslog.conf.new; + mv /etc/syslog.conf.new /etc/syslog.conf; + /etc/init.d/sysklogd reload; + fi; +# +# Support for syslog-ng package +if [ -f /etc/syslog-ng/syslog-ng.conf ]; then + sed -e "s?/var/log/mail.log?@localstatedir@/log/mail/mail.log?g" \ + -e "s?/var/log/mail.err?@localstatedir@/log/mail/mail.err?g" \ + -e "s?/var/log/mail.info?@localstatedir@/log/mail/mail.info?g" \ + -e "s?/var/log/mail.warn?@localstatedir@/log/mail/mail.warn?g" \ + /etc/syslog-ng/syslog-ng.conf > \ + /etc/syslog-ng/syslog-ng.conf.new; + chown root:root /etc/syslog-ng/syslog-ng.conf.new; + chmod 0644 /etc/syslog-ng/syslog-ng.conf.new; + mv /etc/syslog-ng/syslog-ng.conf.new \ + /etc/syslog-ng/syslog-ng.conf; + /etc/init.d/syslog-ng reload; + if [ -f /etc/logrotate.d/syslog-ng ]; then + sed -e '/\/var\/log\/mail\..*/{:a;N;/}\n/!ba;d;}' \ + /etc/logrotate.d/syslog-ng > \ + /etc/logrotate.d/syslog-ng.new; + chown root:root /etc/logrotate.d/syslog-ng.new; + chmod 0644 /etc/logrotate.d/syslog-ng.new; + mv /etc/logrotate.d/syslog-ng.new \ + /etc/logrotate.d/syslog-ng; + true; + fi; + fi; + +#------------------------------------------------------------------------------ +exit $changed; diff --git a/debian/local/update_tcpd b/debian/local/update_tcpd new file mode 100644 index 0000000..e3b430a --- /dev/null +++ b/debian/local/update_tcpd @@ -0,0 +1,53 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# +# Update TCPD environment (TCP Wrappers) for sendmail +# +# Copyright (c) 2001-2001 Richard Nelson. All Rights Reserved. +# Time-stamp: <2001/01/17 10:00:00 cowboy> +# +# Notes (to all): +# +# Notes (to self): +# +#----------------------------------------------------------------------------- +set -e + +#------------------------------------------------------------------------------ +# Check to see if sendmail is mentioned in /etc/hosts.allow +# Note: This check is far from perfect - it requires sendmail and : be +# on the same line. If you've got a better approach, I'd love to +# see it (Maybe awk/perl)! + +if grep -qEe "^[^#:]*sendmail[^:]*[:]" /etc/hosts.allow 2>/dev/null; then + need_tcpd=0 +else + need_tcpd=1 + fi + +if [ ! -e /etc/hosts.allow ]; then + need_tcpd=0 + fi + +if [ $need_tcpd -eq 1 ]; then + cat <<-EOT + + Updating /etc/hosts.allow, adding "sendmail: all". + + Please edit /etc/hosts.allow and check the rules location to + make sure your security measures have not been overridden - + it is common to move the sendmail:all line to the *end* of + the file, so your more selective rules take precedence. +EOT + + echo "sendmail: all" | cat - /etc/hosts.allow >/etc/hosts.allow.new + mv -f /etc/hosts.allow.new /etc/hosts.allow + + if [ -e /etc/init.d/netbase ]; then + /etc/init.d/netbase reload >/dev/null + elif [ -e /etc/init.d/inetd ]; then + /etc/init.d/inetd reload >/dev/null + fi + fi + +exit 0 diff --git a/debian/local/update_tls.in b/debian/local/update_tls.in new file mode 100644 index 0000000..7d833fe --- /dev/null +++ b/debian/local/update_tls.in @@ -0,0 +1,305 @@ +#!/bin/sh -e +#----------------------------------------------------------------------------- +# +# $Sendmail: update_tls,v @sm_version@ @sm_date@ @sm_time@ cowboy Exp $ +# +# Sendmail support for TLS +# +# Copyright (c) 2000-@SM_CPYRT@ Richard Nelson. All Rights Reserved. +# +# Notes: +# +#----------------------------------------------------------------------------- +set -e; + +#------------------------------------------------------------------------------ +# Local variables +#--------------------------------------------------------------------------- +HOSTNAME=`hostname -s`; +DOMAINNAME=`hostname -d`; +SSL_FQDN=`hostname -f`; +SSL_EMAIL="admin@${SSL_FQDN}"; +export SSL_FQDN SSL_EMAIL; +PROGRAM='sendmail'; +CERT_DIR="@sysconfdir@/ssl/certs"; +COM_PRM="@sysconfdir@/mail/tls/$PROGRAM-common.prm"; +COM_KEY="@sysconfdir@/mail/tls/$PROGRAM-common.key"; +MTA_CFG="@sysconfdir@/mail/tls/$PROGRAM-server.cfg"; +MTA_CSR="@sysconfdir@/mail/tls/$PROGRAM-server.csr"; +MTA_CRT="@sysconfdir@/mail/tls/$PROGRAM-server.crt"; +MSP_CFG="@sysconfdir@/mail/tls/$PROGRAM-client.cfg"; +MSP_CSR="@sysconfdir@/mail/tls/$PROGRAM-client.csr"; +MSP_CRT="@sysconfdir@/mail/tls/$PROGRAM-client.crt"; +NEW=0; +REFD=0; + +#--------------------------------------------------------------------------- +# create_config: Function to create openssl configuration file +#--------------------------------------------------------------------------- +create_config () { +cat >$MTA_CFG <<EOT +[ ca ] +default_days = 365 +x509_extensions = X509v3 +[ req ] +default_bits = 1024 +distinguished_name = req_DN +[ req_DN ] +countryName = "1. Country Name (2 letter code)" +countryName_min = 2 +countryName_max = 2 +countryName_default = +stateOrProvinceName = "2. State or Province Name (full name) " +stateOrProvinceName_default = +localityName = "3. Locality Name (eg, city) " +localityName_default = +0.organizationName = "4. Organization Name (eg, company) " +0.organizationName_default = Sendmail +organizationalUnitName = "5. Organizational Unit Name (eg, section) " +organizationalUnitName_default = Sendmail Server +commonName = "6. Common Name (MUST==FQDN) " +commonName_max = 64 +commonName_default = \$ENV::SSL_FQDN +emailAddress = "7. Email Address (eg, name@FQDN)" +emailAddress_max = 40 +emailAddress_default = \$ENV::SSL_EMAIL +[ x509v3 ] +subjectAltName = email:copy +issuerAltName = issuer:copy +basicConstraints = CA:false +nsComment = "Sendmail generated custom certificate" +nsCertType = server +nsSslServerName = \$ENV::SSL_FQDN +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer:always +EOT +}; + + +#--------------------------------------------------------------------------- +# Check if OpenSSL is installed +if [ ! -d "$CERT_DIR" ]; then + cat <<-EOT + + OpenSSL is not installed, will not configure sendmail support for it. + + to install openssl, get openssl. + + To enable sendmail TLS support at a later date, invoke "$0" + + EOT + exit 0; + fi; + +echo ' '; +echo 'Creating/Updating SSL(for TLS) information'; + + +#--------------------------------------------------------------------------- +# Process arguments +#--------------------------------------------------------------------------- +case "$1" in + [Nn][Ee][Ww]*) + echo 'Removing any pre-existing sendmail certificates.'; + if [ -x @bindir@/openssl ]; then + if [ -f $MTA_CRT ]; then + LINK="$CERT_DIR/"$(openssl x509 -noout -hash < $MTA_CRT)".0"; + rm -f $LINK 2>/dev/null; + fi; + if [ -f $MSP_CRT ]; then + LINK="$CERT_DIR/"$(openssl x509 -noout -hash < $MSP_CRT)".0"; + rm -f $LINK 2>/dev/null; + fi; + fi; + rm -f $MTA_CSR $MTA_CRT 2>/dev/null; + rm -f $MSP_CSR $MSP_CRT 2>/dev/null; + rm -f $COM_PRM $COM_KEY 2>/dev/null; + ;; + esac + +#--------------------------------------------------------------------------- +# Make sure sendmail.mc points to proper /etc/mail/tls/starttls.m4 +if [ -f @sysconfdir@/mail/sendmail.mc ]; then + if (grep -qEe "^[[:space:]]*include\(\`?@sysconfdir@/mail/starttls.m4" \ + @sysconfdir@/mail/sendmail.mc); then + sed -e "s=^\([[:space:]]*\)\(\`\?\)include(\`\?@sysconfdir@/mail/starttls.m4'\?)\(dnl\)\?=\1\2include(\`@sysconfdir@/mail/tls/starttls.m4')dnl=g" \ + @sysconfdir@/mail/sendmail.mc > @sysconfdir@/mail/sendmail.mc.new; + chown root:smmsp @sysconfdir@/mail/sendmail.mc.new; + chmod 0644 @sysconfdir@/mail/sendmail.mc.new; + mv @sysconfdir@/mail/sendmail.mc.new @sysconfdir@/mail/sendmail.mc; + fi; + fi; +if [ -f @sysconfdir@/mail/submit.mc ]; then + if (grep -qEe "^[[:space:]]*include\(\`?@sysconfdir@/mail/starttls.m4" \ + @sysconfdir@/mail/submit.mc); then + sed -e "s=^\([[:space:]]*\)\(\`\?\)include(\`\?@sysconfdir@/mail/starttls.m4'\?)\(dnl\)\?=\1\2include(\`@sysconfdir@/mail/tls/starttls.m4')dnl=g" \ + @sysconfdir@/mail/submit.mc > @sysconfdir@/mail/submit.mc.new; + chown root:smmsp @sysconfdir@/mail/submit.mc.new; + chmod 0644 @sysconfdir@/mail/submit.mc.new; + mv @sysconfdir@/mail/submit.mc.new @sysconfdir@/mail/submit.mc; + fi; + fi; + +#--------------------------------------------------------------------------- +# check for references to starttls.m4 in sendmail.mc +if [ -f @sysconfdir@/mail/sendmail.mc ]; then + if grep -qEe "^[[:space:]]*include\(\`?@sysconfdir@/mail/tls/starttls.m4" \ + @sysconfdir@/mail/sendmail.mc; then + REFD=1; + fi; + fi; + +#--------------------------------------------------------------------------- +# Make sure prototype /etc/mail/tls/starttls.m4 exists +if [ -L @sysconfdir@/mail/starttls.m4 ]; then + rm @sysconfdir@/mail/starttls.m4; + fi; +if [ -f @sysconfdir@/mail/starttls.m4 ]; then + mv @sysconfdir@/mail/starttls.m4 @sysconfdir@/mail/tls/starttls.m4; + fi; +if [ ! -f @sysconfdir@/mail/tls/starttls.m4 ]; then + NEW=1; + cp -a @datadir@/sendmail/cf/debian/starttls.m4 \ + @sysconfdir@/mail/tls/starttls.m4; + echo ' '; + echo 'Created template file @sysconfdir@/mail/tls/starttls.m4'; + echo 'Edit this file if you wish to change the default tls setup.'; + fi; + +#--------------------------------------------------------------------------- +# check for SSL +if [ -d "$CERT_DIR" ]; then + if [ -f $MTA_CRT -a -f $MSP_CRT ]; then + echo 'You already have sendmail certificates'; + echo ' '; + chown root:smmsp $COM_KEY; + chown root:smmsp $MTA_CRT; + chown root:smmsp $MSP_CRT; + else + if [ -x @bindir@/openssl ]; then + yn="Y"; + else + cat <<-EOT + $PROGRAM needs openssl (not installed) to create a + certificate to validate users + + If you don't need a certificate, say No + If you want a certificate, install openssl and say Yes + + Do you wish to create a certificate? + EOT + read yn; + yn=$(echo -n "$yn" | sed -e "s/^\ *//" -e "s/^\t*//"); + test -n "$yn" || yn="N"; + fi; + + # Create new (self-signed) certificate + case "$yn" in + [Yy]*) + echo "Creating SSL certificates for sendmail."; + # Create prompt file + if [ ! -f @sysconfdir@/mail/tls/no_prompt ]; then + cat >@sysconfdir@/mail/tls/no_prompt <<-EOT + + + + + + + + EOT + fi; + + # Create config files + if [ ! -f $MTA_CFG ]; then + create_config; + chmod 0600 $MTA_CFG; + fi; + if [ ! -f $MSP_CFG ]; then + sed -e "s/Sendmail Server/Sendmail Client/" \ + $MTA_CFG > $MSP_CFG; + chmod 0600 $MSP_CFG; + fi; + # Create shared DSA/DH password parameters + # Skip this for now... + if [ ! -f $COM_PRM ]; then + #openssl dsaparam 1024 -out $COM_PRM; + #openssl dhparam -dsaparam -in $COM_PRM >> $COM_PRM; + touch $COM_PRM; + chmod 0600 $COM_PRM; + fi; + # Create shared DSA/RSA key (RSA preferred for browser support) + if [ ! -f $COM_KEY ]; then + openssl genrsa -out $COM_KEY 1024; + #openssl gendsa -out $COM_KEY $COM_PRM; + chown root:smmsp $COM_KEY; + chmod 0640 $COM_KEY; + fi; + # sendmail requires that CN=fqdn + # Prompts: 1) Country Name (2 letter code) + # 2) State or Province Name + # 3) Locality Name (eg, city) + # 4) Organization Name (eg, company) + # 5) Organizational Unit Name (eg, section) + # 6) Common Name (eg, YOUR name) + # 7) Email Address + if [ ! -f $MTA_CRT ]; then + openssl req -new -config $MTA_CFG -key $COM_KEY \ + -out $MTA_CSR \ + <@sysconfdir@/mail/tls/no_prompt >/dev/null 2>&1; + chmod 0600 $MTA_CSR; + openssl x509 -req -extfile $MTA_CFG \ + -signkey $COM_KEY -in $MTA_CSR \ + -out $MTA_CRT -days 365 \ + >/dev/null 2>&1; + chown root:smmsp $MTA_CRT; + chmod 0644 $MTA_CRT; + fi; + if [ ! -f $MSP_CRT ]; then + openssl req -new -config $MSP_CFG -key $COM_KEY \ + -out $MSP_CSR \ + <@sysconfdir@/mail/tls/no_prompt >/dev/null 2>&1; + chmod 0600 $MSP_CSR; + openssl x509 -req -extfile $MSP_CFG \ + -signkey $COM_KEY -in $MSP_CSR \ + -out $MSP_CRT -days 365 \ + >/dev/null 2>&1; + chown root:smmsp $MSP_CRT; + chmod 0644 $MSP_CRT; + fi; + esac; + fi; + + # Create hash link for new certificate (must do msp last!) + if [ -f $MTA_CRT ]; then + LINK="$CERT_DIR/"$(openssl x509 -noout -hash < $MTA_CRT)".0"; + if [ ! -f $LINK ]; then + ln -sf $MTA_CRT $LINK; + fi; + fi; + if [ -f $MSP_CRT ]; then + LINK="$CERT_DIR/"$(openssl x509 -noout -hash < $MSP_CRT)".0"; + if [ ! -f $LINK ]; then + ln -sf $MSP_CRT $LINK; + fi; + fi; + fi; + +if [ $REFD -eq 0 ]; then + cat <<-EOT + + *** *** *** WARNING *** WARNING *** WARNING *** WARNING *** *** *** + + Everything you need to support STARTTLS (encrypted mail transmission + and user authentication via certificates) is installed and configured + but *IS* not being used. + + To enable sendmail to use STARTTLS, you need to: + 1) Add this line to @sysconfdir@/mail/sendmail.mc and optionally + to @sysconfdir@/mail/submit.mc: + include(\`@sysconfdir@/mail/tls/starttls.m4')dnl + 2) Run sendmailconfig + 3) Restart sendmail + + EOT + fi; diff --git a/debian/local/updatedb b/debian/local/updatedb deleted file mode 100644 index 389af5a..0000000 --- a/debian/local/updatedb +++ /dev/null @@ -1,481 +0,0 @@ -#!/bin/sh -e -# -# Update Sendmail databases for Debian -# -# Copyright (c) 1999, Richard Nelson <cowboy@debian.org>. -# Time-stamp: <1999/05/19 10:00:00 cowboy> -# -# Notes (to all): -# * assumes makemap dbtype /etc/mail/database < /etc/mail/database -# -# Notes (to self): -# * changes made herein *must* be reflected in parsemc,updatedb,debian.m4 -# * multiple db options not supported -# * userdb can also have multiple databases and then a forward! -# * need sendmail stop/start -# -set -e - -# List of db features -db_features="access_db bitdomain domaintable genericstable \ - mailertable uucpdomain virtusertable use_ct_file use_cw_file"; -export db_features; -# kluge for userdb, cr,ct,and cw files support -db_files="confCR_FILE confUSERDB_SPEC ALIAS_FILE"; -db_files="sendmail.mc $db_features $db_files"; -export db_files; - -# control amount of output -verbosity=0; - -# flag used to ensure only one newaliases command is run -newaliases_run=0; - -# flag used to indicate a dataset has been moved, may need another update -changed=0; - -# max return code -max_rc=0; -missing_rqd=0; -missing_opt=0; -m4_errors=0; - -#------------------------------------------------------------- -# Initial update of sendmail.mc/databases -#------------------------------------------------------------- -initial () { - if [ $verbosity -gt 1 ]; then - echo "initial()"; - fi; - - # Make sure not using text mailertable (it doesn't work) - if (grep -q "^[[:space:]]*FEATURE(mailertable, \`text /etc/mail/mailertable')dnl" /etc/mail/sendmail.mc); then - sed "s?FEATURE(mailertable, \`text /etc/mail/mailertable')dnl?FEATURE(mailertable)dnl?g" \ - /etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new - chown root.mail /etc/mail/sendmail.mc.new - chmod 0664 /etc/mail/sendmail.mc.new - mv /etc/mail/sendmail.mc.new /etc/mail/sendmail.mc - fi; - - # Make sure the data file is current using the version of - # parsemc that corresponds to this version of updatedb - $(dirname $0)/parsemc || true - } - -#------------------------------------------------------------- -# Handle found databases -#------------------------------------------------------------- -is_found () { - if [ $verbosity -gt 1 ]; then - echo "is_found()"; - fi; - process=1; - - case "$dbfeat" in - ALIAS_FILE) - if [ ! -f /etc/aliases -a -f /etc/mail/aliases ]; then - echo "Linking /etc/aliases to /etc/mail/aliases" - ln -sf mail/aliases /etc/aliases - fi - ;; - esac - } - -#------------------------------------------------------------- -# Handle missing databases: -# moving /etc/xxx to /etc/mail/xxx -# rename /etc/mail/xxx to /etc/mail/yyy -#------------------------------------------------------------- -is_not_found () { - if [ $verbosity -gt 1 ]; then - echo "is_not_found()"; - fi; - process=0; - - case "$dbfeat" in - use_cw_file) - if [ -f /etc/local-host-names ]; then - if [ ! -L /etc/local-host-names ]; then - echo "Moving /etc/local-host-names to /etc/mail/." - mv /etc/local-host-names /etc/mail/ - process=1; - else - echo "/etc/local-host-names is a link," \ - "move it to /etc/mail/local-host-names" - missing_rqd=`expr $missing_rqd + 1`; - fi; - elif [ -f /etc/mail/sendmail.cw ]; then - echo "Renaming sendmail.cw to local-host-names." - mv /etc/mail/sendmail.cw /etc/mail/local-host-names - process=1; - elif [ -f /etc/sendmail.cw ]; then - if [ ! -L /etc/sendmail.cw ]; then - echo "Moving /etc/sendmail.cw to /etc/mail/" - mv /etc/sendmail.cw /etc/mail/local-host-names - process=1; - else - echo "/etc/sendmail.cw is a link," \ - "move it to /etc/mail/local-host-names" - missing_rqd=`expr $missing_rqd + 1`; - fi - elif [ "$dbopts" = "-o" ]; then - echo "Informational: $dbfeat source" \ - "file not found: $dbname" - missing_opt=`expr $missing_opt + 1`; - else - echo "Error: $dbfeat source file not found: $dbname" - missing_rqd=`expr $missing_rqd + 1`; - fi - ;; - use_ct_file) - if [ -f /etc/trusted-users ]; then - if [ ! -L /etc/trusted-users ]; then - echo "Moving /etc/trusted-users to /etc/mail/." - mv /etc/trusted-users /etc/mail/ - process=1; - else - echo "/etc/trusted-users is a link," \ - "move it to /etc/mail/trusted-users" - missing_rqd=`expr $missing_rqd + 1`; - fi; - elif [ -f /etc/mail/sendmail.ct ]; then - echo "Renaming sendmail.ct to trusted-users." - mv /etc/mail/sendmail.ct /etc/mail/trusted-users - process=1; - elif [ -f /etc/sendmail.ct ]; then - if [ ! -L /etc/sendmail.ct ]; then - echo "Moving /etc/sendmail.ct to /etc/mail/" - mv /etc/sendmail.ct /etc/mail/trusted-users - process=1; - else - echo "/etc/sendmail.ct is a link," \ - "move it to /etc/mail/trusted-users" - missing_rqd=`expr $missing_rqd + 1`; - fi - elif [ "$dbopts" = "-o" ]; then - echo "Informational: $dbfeat source" \ - "file not found: $dbname" - missing_opt=`expr $missing_opt + 1`; - else - echo "Error: $dbfeat source file not found: $dbname" - missing_rqd=`expr $missing_rqd + 1`; - fi - ;; - ALIAS_FILE) - if [ -f /etc/$dbsname ]; then - if [ ! -L /etc/$dbsname ]; then - echo "Moving /etc/aliases to /etc/mail/aliases " - echo "and linking /etc/aliases to /etc/mail/aliases" - echo "This preserves current function/abilities" - mv -f /etc/$dbsname /etc/mail/ - ln -sf mail/aliases /etc/aliases - #ln -sf /etc/mail/aliases /etc/aliases - if [ -f /etc/$dbsname.db ]; then - mv -f /etc/$dbsname.db /etc/mail/ - fi - if [ -f /etc/$dbsname.pag ]; then - mv -f /etc/$dbsname.pag /etc/mail/ - fi - if [ -f /etc/$dbsname.dir ]; then - mv -f /etc/$dbsname.dir /etc/mail/ - fi - process=1; - changed=1; - else - echo "/etc/$dbsname is a link, move it to $dbname" - missing_rqd=`expr $missing_rqd + 1`; - fi; - elif [ "$dbopts" = "-o" ]; then - echo "Informational: $dbfeat source" \ - "file not found: $dbname" - missing_opt=`expr $missing_opt + 1`; - else - echo "Error: $dbfeat source file not found: $dbname" - missing_rqd=`expr $missing_rqd + 1`; - fi; - ;; - m4) - if [ -f /etc/$dbsname ]; then - if [ ! -L /etc/$dbsname ]; then - echo "Moving /etc/sendmail.{mc,cf} to /etc/mail/"; - mv -f /etc/sendmail.mc /etc/mail/ - if [ -f /etc/sendmail.cf ]; then - mv -f /etc/sendmail.cf /etc/mail/ - fi - process=1; - else - echo "/etc/$dbsname is a link, move it to $dbname" - missing_rqd=`expr $missing_rqd + 1`; - fi; - elif [ "$dbopts" = "-o" ]; then - echo "Informational: $dbfeat source" \ - "file not found: $dbname" - missing_opt=`expr $missing_opt + 1`; - else - echo "Error: $dbfeat source file not found: $dbname" - missing_rqd=`expr $missing_rqd + 1`; - fi; - ;; - *) - if [ -f /etc/$dbsname ]; then - if [ ! -L /etc/$dbsname ]; then - echo "Moving /etc/$dbsname{,.*} to $dbname"; - mv -f /etc/$dbsname /etc/mail/ - if [ -f /etc/$dbsname.db ]; then - mv -f /etc/$dbsname.db /etc/mail/ - fi - if [ -f /etc/$dbsname.pag ]; then - mv -f /etc/$dbsname.pag /etc/mail/ - fi - if [ -f /etc/$dbsname.dir ]; then - mv -f /etc/$dbsname.dir /etc/mail/ - fi - process=1; - else - echo "/etc/$dbsname is a link, move it to $dbname" - missing_rqd=`expr $missing_rqd + 1`; - fi; - elif [ "$dbopts" = "-o" ]; then - echo "Informational: $dbfeat source" \ - "file not found: $dbname" - missing_opt=`expr $missing_opt + 1`; - else - echo "Error: $dbfeat source file not found: $dbname" - missing_rqd=`expr $missing_rqd + 1`; - fi; - ;; - esac - } - -#------------------------------------------------------------- -# Handle empty databases -#------------------------------------------------------------- -is_empty () { - if [ $verbosity -gt 1 ]; then - echo "is_empty()"; - fi; - if [ $process -eq 1 ]; then - if [ "$dbtype" != "-" ]; then - rm -f $dbname.db - rm -f $dbname.pag - rm -f $dbname.dir - fi - case "$dbfeat" in - *) - echo "Informational: $dbfeat file empty: $dbname" - if [ "$dbopts" = "-o" ]; then - process=0; - fi; - ;; - esac - fi - } - -#------------------------------------------------------------- -# Handle no data (exists, but is only comments) databases -#------------------------------------------------------------- -is_comments () { - if [ $verbosity -gt 1 ]; then - echo "is_comments()"; - fi; - if [ $process -eq 1 ]; then - if [ "$dbtype" != "-" ]; then - rm -f $dbname.db - rm -f $dbname.pag - rm -f $dbname.dir - fi - case "$dbfeat" in - *) - echo "Informational: $dbfeat no data: $dbname" - if [ "$dbopts" = "-o" ]; then - process=0; - fi; - ;; - esac - fi - } - -#------------------------------------------------------------- -# Handle normal databases (exists, has data) -#------------------------------------------------------------- -is_normal () { - if [ $verbosity -gt 1 ]; then - echo "is_normal()"; - fi; - if [ $process -eq 1 -a $max_rc -eq 0 ]; then - if [ "$dbtype" != "-" ]; then - case "$dbtype" in - btree) - makemap -d $dbtype $dbname.db < $dbname - chown root.mail $dbname.db - chmod 0664 $dbname.db - ;; - dbm | btree | hash) - makemap $dbtype $dbname.db < $dbname - chown root.mail $dbname.db - chmod 0664 $dbname.db - ;; - text) - true; - ;; - newaliases) - if [ $newaliases_run -eq 0 -o \ - $changed -eq 1 ]; then - newaliases_run=1 - newaliases - fi - chown root.mail $dbname.db - chmod 0664 $dbname.db - ;; - m4) - echo "Generating /etc/mail/sendmail.cf ..." - m4 \ - /usr/share/sendmail/sendmail.cf/m4/cf.m4 \ - /etc/mail/sendmail.mc \ - > /etc/mail/sendmail.cf.new \ - 2> /etc/mail/sendmail.cf.errors - chown root.mail /etc/mail/sendmail.cf.new - chmod 0644 /etc/mail/sendmail.cf.new - if [ ! -s /etc/mail/sendmail.cf.errors ]; then - rm /etc/mail/sendmail.cf.errors; - else - cat /etc/mail/sendmail.cf.errors; - echo " "; - m4_errors=1; - fi; - # Can't tell if the errors are fatal or not ;-{ - mv -f /etc/mail/sendmail.cf.new \ - /etc/mail/sendmail.cf - ;; - *) - echo "$dbtype map not done herein" - ;; - esac - fi; - fi; - } - -#------------------------------------------------------------- -# Handle completion -#------------------------------------------------------------- -final () { - if [ $verbosity -gt 1 ]; then - echo "final()"; - fi; - } - - -# status report if not for single database -if [ -z "$1" ]; then - echo "Checking sendmail.cf and databases." - fi; - -initial - -for file in $db_files; do \ - line=$(egrep -e "^[[:space:]]*$file" /etc/mail/databases || true); - while ([ "$line" != "" ]); do - str=$(echo "$line" | cut -d " -" -f 1) - line=$(echo "$line" | cut -d " -" -f 2) - - # Strip line back into four pieces: feature, type, opts, name - dbfeat=$(echo "$str" | cut -d ":" -f 1) - dbtype=$(echo "$str" | cut -d ":" -f 2) - dbopts=$(echo "$str" | cut -d ":" -f 3) - dbname=$(echo "$str" | cut -d ":" -f 4) - dbregx=$(echo "$str" | cut -d ":" -f 5) - if [ $(dirname "$dbname") = "/etc/mail" ]; then - dbsname=$(basename "$dbname") - elif [ $(dirname "$dbname") = "/etc/" ]; then - dbsname=$(basename "$dbname") - else - dbsname="$dbname" - fi; - if [ "$dbopts" = "-" ]; then - dbopts=""; - fi; - if [ "$dbregx" = "-" ]; then - dbregx=""; - fi; - - # Check to see if we're doing one, or all - if [ ! -z "$1" ]; then - if [ "$1" = "$dbfeat" -o \ - "$1" = "$dbname" -o \ - "$1" = "$dbsname" ]; then - true; - else - continue; - fi; - fi; - - changed=0; - if [ $verbosity -gt 0 ]; then - echo "Processing $dbname..."; - fi; - - - # Check for database existance - if [ -f "$dbname" ]; then - is_found - else - is_not_found - fi; - - # Check for something in database - if [ ! -s "$dbname" ]; then - is_empty - fi; - - # Check for real data (not just comments) - if [ $process -eq 1 ]; then - if ! egrep -q -e "^[[:space:]]*[^$\#]" $dbname; then - is_comments - fi; - fi; - - # Finally, assume a normal file... - is_normal - - done; - done; - -final - -# Final notices... -if [ $missing_opt -ne 0 ]; then - echo " " - echo "Informational: $missing_opt optional database(s) sources" - echo " were not found, please investigate." - fi; -if [ $missing_rqd -ne 0 ]; then - echo " " - echo "Error: $missing_rqd required database(s) sources" - echo " were not found, correct this before starting sendmail!" - if [ $max_rc -lt 2 ]; then - max_rc=2; - fi; - fi; -if [ $missing_opt -ne 0 -o $missing_rqd -ne 0 ]; then - echo " " - echo "$0 assumes that databases, and their source datasets" - echo "have the same base name (not counting the .db). If this is not" - echo "true, $0 can not rebuild your databases to make sure" - echo "they will work with the newer sendmail. You will have to do this" - echo "yourself - before starting sendmail." - echo " " - fi; -if [ $m4_errors -ne 0 ]; then - echo " " - echo "Warning: These messages were issued while creating sendmail.cf" - echo " make sure they are benign before starting sendmail!" - echo " " - cat /etc/mail/sendmail.cf.errors; - echo " " - if [ $max_rc -lt 2 ]; then - max_rc=2; - fi; - fi; -exit $max_rc |