2
#-----------------------------------------------------------------------------
4
# $Sendmail: update_mc,v 8.14.4 2010-11-03 22:21:32 cowboy Exp $
6
# Update Sendmail databases for Debian
8
# Copyright (c) 2000-2010 Richard Nelson. All Rights Reserved.
11
# * assumes makemap dbtype /etc/mail/database < /etc/mail/database
14
# * changes made herein *must* be reflected in
15
# parse_mc,update_mk,update_db,debian.m4
17
#-----------------------------------------------------------------------------
22
# Path to other sendmail helpers
23
if [ -x ./update_sendmail ]; then
25
elif [ -x $(dirname $0)/update_sendmail ]; then
26
sm_path=$(dirname $0);
28
sm_path=/usr/share/sendmail;
30
# Bring in sendmail.conf for the network definitions
31
if [ ! -f /etc/mail/sendmail.conf ]; then
32
if [ -x $sm_path/update_conf ]; then
36
if [ -f /etc/mail/sendmail.conf ]; then
37
. /etc/mail/sendmail.conf;
39
if [ "$HANDS_OFF" != 'No' ]; then
44
chown root:smmsp /etc/mail/"$1".mc.new;
45
chmod 0644 /etc/mail/"$1".mc.new;
46
mv /etc/mail/"$1".mc.new /etc/mail/"$1".mc;
50
#-----------------------------------------------------------------------------
51
# Move sendmail.{mc,cf} from /etc/ to /etc/mail
52
if [ ! -f /etc/mail/sendmail.mc ]; then
53
if [ -f /etc/sendmail.mc ]; then
54
echo "Moving /etc/sendmail.* to /etc/mail/";
55
mv /etc/sendmail.mc /etc/mail/sendmail.mc.new;
58
if [ -f /etc/sendmail.cf ]; then
59
mv /etc/sendmail.cf /etc/mail/sendmail.cf;
60
chown root:smmsp /etc/mail/sendmail.cf;
61
chmod 0644 /etc/mail/sendmail.cf;
66
#-----------------------------------------------------------------------------
67
# Create {submit,sendmail}.mc if needed
68
if [ ! -f /etc/mail/sendmail.mc ]; then
69
cp -p /usr/share/sendmail/cf/debian/sendmail.mc \
70
/etc/mail/sendmail.mc.new;
71
if [ -f /etc/mailname ] && [ ! -z /etc/mailname ]; then
72
masq=$(cat /etc/mailname);
73
echo "dnl # Masquerading options" \
74
>> /etc/mail/sendmail.mc.new;
75
echo "FEATURE(\`always_add_domain')dnl" \
76
>> /etc/mail/sendmail.mc.new;
77
echo "MASQUERADE_AS(\`${masq}')dnl" \
78
>> /etc/mail/sendmail.mc.new;
79
echo "FEATURE(\`allmasquerade')dnl" \
80
>> /etc/mail/sendmail.mc.new;
81
echo "FEATURE(\`masquerade_envelope')dnl" \
82
>> /etc/mail/sendmail.mc.new;
86
if [ ! -f /etc/mail/submit.mc ]; then
87
if [ -f /usr/share/sendmail/cf/debian/submit.mc ]; then
88
cp -p /usr/share/sendmail/cf/debian/submit.mc \
89
/etc/mail/submit.mc.new;
94
#-----------------------------------------------------------------------------
95
# Make sure dialup support m4 files are extant
96
if [ ! -f /etc/mail/m4/dialup.m4 ]; then
97
if [ -f /etc/mail/dialup.m4 ]; then
98
mv /etc/mail/dialup.m4 /etc/mail/m4/dialup.m4;
100
touch /etc/mail/m4/dialup.m4;
102
chown root:smmsp /etc/mail/m4/dialup.m4;
103
chmod 0640 /etc/mail/m4/dialup.m4;
105
if [ ! -f /etc/mail/m4/provider.m4 ]; then
106
if [ -f /etc/mail/provider.m4 ]; then
107
mv /etc/mail/provider.m4 /etc/mail/m4/provider.m4;
109
touch /etc/mail/m4/provider.m4;
111
chown root:smmsp /etc/mail/m4/provider.m4;
112
chmod 0640 /etc/mail/m4/provider.m4;
114
if (grep -qEe "^[[:space:]]*include\(\`?/etc/mail/dialup.m4" \
115
/etc/mail/sendmail.mc); then
116
sed -e "s=^\([[:space:]]*\)include(\`\?/etc/mail/dialup\.m4.*$=include(\`/etc/mail/m4/dialup\.m4')dnl=" \
117
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
120
if (grep -qEe "^[[:space:]]*include\(\`?/etc/mail/provider.m4" \
121
/etc/mail/sendmail.mc); then
122
sed -e "s=^\([[:space:]]*\)include(\`\?/etc/mail/provider\.m4.*$=include(\`/etc/mail/m4/provider\.m4')dnl=" \
123
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
127
#-----------------------------------------------------------------------------
128
# Make sure not using text mailertable (it doesn't work)
129
if (grep -qEe "^[[:space:]]*FEATURE\(\`?mailertable'?, \`text /etc/mail/mailertable'\)" \
130
/etc/mail/sendmail.mc); then
131
echo "Correcting FEATURE(mailertable) in /etc/mail/sendmail.mc";
132
sed -e "s=^\([[:space:]]*\)\(\`\?\)FEATURE(\`\?mailertable'\?, \`text /etc/mail/mailertable')\(dnl\)\?=\1\2FEATURE(\`mailertable')dnl=g" \
133
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
137
#-----------------------------------------------------------------------------
138
# Make sure smrsh points to the correct location
139
if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?smrsh'?[[:space:]]*,.*\)" \
140
/etc/mail/sendmail.mc); then
141
echo "Correcting FEATURE(smrsh) in /etc/mail/sendmail.mc";
142
sed -e "s=\([[:space:]]*\)\(\`\?\)FEATURE(\`\?smrsh'\?[[:space:]]*,.*)\(dnl\)\?=\1\2FEATURE(\`smrsh')dnl=g" \
143
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
147
#-----------------------------------------------------------------------------
148
# Convert FEATURE(nouucp) to FEATURE(nouucp,reject)
149
if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?nouucp'?\)" \
150
/etc/mail/sendmail.mc); then
151
echo "Correcting FEATURE(nouucp) in /etc/mail/sendmail.mc";
152
sed -e "s=^\([[:space:]]*\)\(\`\?\)FEATURE(\`\?nouucp'\?)\(dnl\)\?=\1\2FEATURE(\`nouucp', \`reject')dnl=g" \
153
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
157
#-----------------------------------------------------------------------------
158
# Convert FEATURE(dont_masquerade_local) to FEATURE(local_no_masquerade)
159
if [ -e /usr/share/sendmail/cf/feature/local_no_masquerade.m4 ]; then
160
if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?dont_masquerade_local'?\)" \
161
/etc/mail/sendmail.mc); then
162
echo "Correcting FEATURE(dont_masquerade_local) in /etc/mail/sendmail.mc";
163
sed -e "s=^\([[:space:]]*\)\(\`\?\)FEATURE(\`\?dont_masquerade_local'\?)\(dnl\)\?=\1\2FEATURE(\`local_no_masquerade')dnl=g" \
164
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
169
#-----------------------------------------------------------------------------
170
# Convert FEATURE(access_db,...) to FEATURE(access_db)
171
if (grep -qEe "^[[:space:]]*\`?FEATURE\(\`?access_db'?[[:space:]]*,.*\)" \
172
/etc/mail/sendmail.mc); then
173
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" \
174
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
178
#-----------------------------------------------------------------------------
179
# change include(/usr/share/sendmail/sendmail.cf/m4/cf.m4)
180
if (grep -qEe "^[[:space:]]*\`?include\(\`?/usr/share/sendmail/sendmail.cf/m4/cf.m4'?\)" \
181
/etc/mail/sendmail.mc); then
182
sed -e "s=sendmail/sendmail.cf=sendmail/cf=g" \
183
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
185
if [ -f /etc/mail/submit.mc ]; then
186
sed -e "s=sendmail/sendmail.cf=sendmail/cf=g" \
187
/etc/mail/submit.mc > /etc/mail/submit.mc.new;
192
#-----------------------------------------------------------------------------
193
# Add include(/usr/share/sendmail/cf/m4/cf.m4)
194
if (grep -qEe "^[[:space:]]*\`?include\(\`?/usr/share/sendmail/cf/m4/cf.m4'?\)" \
195
/etc/mail/sendmail.mc); then
198
echo "Adding include(.../cf.m4) to /etc/mail/sendmail.mc";
199
sed -e "s=^\([[:space:]]*\)\(\`\?\)VERSIONID(=\1\2include(\`/usr/share/sendmail/cf/m4/cf.m4')dnl\\
201
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
205
#-----------------------------------------------------------------------------
206
# Add define(`_USE_ETC_MAIL_')dnl
207
if (grep -qEe "^[[:space:]]*\`?define\(\`?_USE_ETC_MAIL_" \
208
/etc/mail/sendmail.mc); then
211
sed -e "s=^\([[:space:]]*\)\(\`\?\)include(\`\?/usr/share/sendmail/cf/m4/cf.m4'\?)\(dnl\)\?=\1\2define(\`_USE_ETC_MAIL_')dnl\\
212
include(\`/usr/share/sendmail/cf/m4/cf.m4')dnl=" \
213
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
217
#-----------------------------------------------------------------------------
219
if (grep -qEe "^[[:space:]]*\`?OSTYPE\(\`?linux'?\)" \
220
/etc/mail/sendmail.mc); then
221
sed -e "s=^\([[:space:]]*\)\(\`\?\)OSTYPE(\`\?linux'\?)\(dnl\)\?=\1\2OSTYPE(\`debian')dnl=" \
222
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
226
#-----------------------------------------------------------------------------
227
# Add DOMAIN(debian-mta)
228
if (grep -qEe "^[[:space:]]*\`?DOMAIN\(\`?debian-mta'?\)" \
229
/etc/mail/sendmail.mc); then
232
echo "Adding DOMAIN(debian-mta) to /etc/mail/sendmail.mc";
233
sed -e "s=^\([[:space:]]*\)\(\`\?\)OSTYPE(\`\?debian'\?)\(dnl\)\?=\1\2OSTYPE(\`debian')dnl\\
234
\1\2DOMAIN(\`debian-mta')dnl=" \
235
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
239
#-----------------------------------------------------------------------------
240
# Add sendmail.conf customization area
241
if (grep -qEe "^dnl # Items controlled by /etc/mail/sendmail.conf" \
242
/etc/mail/sendmail.mc); then
245
echo "Adding sendmail.conf customization area to /etc/mail/sendmail.mc";
246
sed -e "s=^\([[:space:]]*\)\(\`\?\)DOMAIN(\`\?debian-mta'\?)\(dnl\)\?=\1\2DOMAIN(\`debian-mta')dnl\\
247
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE \\
248
dnl undefine(\`confHOST_STATUS_DIRECTORY')dnl #DAEMON_HOSTSTATS \\
249
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE=" \
250
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
254
#-----------------------------------------------------------------------------
255
# Update items in sendmail.conf customization area
256
case "$DAEMON_HOSTSTATS" in
258
if (grep -qEe "^dnl undefine\(\`confHOST_STATUS_DIRECTORY'\)dnl" \
259
/etc/mail/sendmail.mc); then
260
echo "Turning off Host Status collection";
261
sed -e "s=^dnl undefine(\`confHOST_STATUS_DIRECTORY')dnl=undefine(\`confHOST_STATUS_DIRECTORY')dnl=" \
262
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
267
if (grep -qEe "^undefine\(\`confHOST_STATUS_DIRECTORY'\)dnl" \
268
/etc/mail/sendmail.mc); then
269
echo "Turning on Host Status collection";
270
sed -e "s=^undefine(\`confHOST_STATUS_DIRECTORY')dnl=dnl undefine(\`confHOST_STATUS_DIRECTORY')dnl=" \
271
/etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
276
#-----------------------------------------------------------------------------
278
if [ -f /etc/mail/submit.mc ]; then
279
sed -e "/^define(\`\?confRUN_AS_USER'\?,.*$/d" \
280
-e "/^define(\`\?confTRUSTED_USER'\?,.*$/d" \
281
/etc/mail/submit.mc > /etc/mail/submit.mc.new;