~ubuntu-branches/ubuntu/trusty/sendmail/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/local/update_mc

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2014-02-05 23:11:58 UTC
  • mfrom: (9.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20140205231158-gz0hae4ki4o6c6c8
Tags: 8.14.4-4.1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/examples/checksendmail/checksendmail.8,
    debian/examples/checksendmail/harker/checksendmail.8:
    + Some man page corrections.
  - debian/patches/8.14/8.14.4/conf.c-ipv6.patch:
    + Fix A-only MX CNAME interface binding issues when using IPv6.
* Dropped following patches, already applied in Debian:
  - debian/patches/8.14/8.14.4/ld_as_needed -> fix_linkage
  - debian/patches/8.14/8.14.4/raise-max-daemons.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh -e
2
 
#-----------------------------------------------------------------------------
3
 
#
4
 
# $Sendmail: update_mc,v 8.14.4 2010-11-03 22:21:32 cowboy Exp $
5
 
#
6
 
# Update Sendmail databases for Debian
7
 
#
8
 
# Copyright (c) 2000-2010 Richard Nelson.  All Rights Reserved.
9
 
#
10
 
# Notes (to all):
11
 
#       * assumes makemap dbtype /etc/mail/database < /etc/mail/database
12
 
#
13
 
# Notes (to self):
14
 
#       * changes made herein *must* be reflected in
15
 
#               parse_mc,update_mk,update_db,debian.m4
16
 
#
17
 
#-----------------------------------------------------------------------------
18
 
set -e;
19
 
 
20
 
changed=0;
21
 
 
22
 
# Path to other sendmail helpers
23
 
if [ -x ./update_sendmail ]; then
24
 
        sm_path='.';
25
 
elif [ -x $(dirname $0)/update_sendmail ]; then
26
 
        sm_path=$(dirname $0);
27
 
else
28
 
        sm_path=/usr/share/sendmail;
29
 
        fi;
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
33
 
                $sm_path/update_conf;
34
 
                fi;
35
 
        fi;
36
 
if [ -f /etc/mail/sendmail.conf ]; then
37
 
        . /etc/mail/sendmail.conf;
38
 
        fi;
39
 
if [ "$HANDS_OFF" != 'No' ]; then
40
 
        exit 0;
41
 
        fi;
42
 
 
43
 
new_mc () {
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;
47
 
        changed=1;
48
 
        };      
49
 
 
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;
56
 
                new_mc sendmail;
57
 
                fi;
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;
62
 
                changed=1;
63
 
                fi;
64
 
        fi;
65
 
 
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;
83
 
                fi;
84
 
        new_mc sendmail;
85
 
        fi;
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;
90
 
                new_mc submit;
91
 
                fi;
92
 
        fi;
93
 
 
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;
99
 
        else
100
 
                touch /etc/mail/m4/dialup.m4;
101
 
                fi;
102
 
        chown root:smmsp /etc/mail/m4/dialup.m4;
103
 
        chmod 0640 /etc/mail/m4/dialup.m4;
104
 
        fi;
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;
108
 
        else
109
 
                touch /etc/mail/m4/provider.m4;
110
 
                fi;
111
 
        chown root:smmsp /etc/mail/m4/provider.m4;
112
 
        chmod 0640 /etc/mail/m4/provider.m4;
113
 
        fi;
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;
118
 
        new_mc sendmail;
119
 
        fi;
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;
124
 
        new_mc sendmail;
125
 
        fi;
126
 
 
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;
134
 
        new_mc sendmail;
135
 
        fi;
136
 
 
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;
144
 
        new_mc sendmail;
145
 
        fi;
146
 
 
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;
154
 
        new_mc sendmail;
155
 
        fi;
156
 
 
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;
165
 
                new_mc sendmail;
166
 
                fi;
167
 
        fi;
168
 
 
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;
175
 
        new_mc sendmail;
176
 
        fi;
177
 
 
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;
184
 
        new_mc sendmail;
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;
188
 
                new_mc submit;
189
 
                fi;
190
 
        fi;
191
 
 
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
196
 
        :;
197
 
else
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\\
200
 
\1\2VERSIONID(=" \
201
 
                /etc/mail/sendmail.mc > /etc/mail/sendmail.mc.new;
202
 
        new_mc sendmail;
203
 
        fi;
204
 
 
205
 
#-----------------------------------------------------------------------------
206
 
# Add define(`_USE_ETC_MAIL_')dnl
207
 
if (grep -qEe "^[[:space:]]*\`?define\(\`?_USE_ETC_MAIL_" \
208
 
        /etc/mail/sendmail.mc); then
209
 
        :;
210
 
else
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;
214
 
        new_mc sendmail;
215
 
        fi;
216
 
 
217
 
#-----------------------------------------------------------------------------
218
 
# Check for badness
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;
223
 
                new_mc sendmail;
224
 
        fi;
225
 
 
226
 
#-----------------------------------------------------------------------------
227
 
# Add DOMAIN(debian-mta)
228
 
if (grep -qEe "^[[:space:]]*\`?DOMAIN\(\`?debian-mta'?\)" \
229
 
        /etc/mail/sendmail.mc); then
230
 
        :;
231
 
else
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;
236
 
        new_mc sendmail;
237
 
        fi;
238
 
 
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
243
 
        :;
244
 
else
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;
251
 
        new_mc sendmail;
252
 
        fi;
253
 
 
254
 
#-----------------------------------------------------------------------------
255
 
# Update items in sendmail.conf customization area
256
 
case "$DAEMON_HOSTSTATS" in
257
 
        [Nn]*)
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;
263
 
                        new_mc sendmail;
264
 
                        fi;
265
 
                ;;
266
 
        [Yy]*)
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;
272
 
                        new_mc sendmail;
273
 
                        fi;
274
 
        esac;
275
 
 
276
 
#-----------------------------------------------------------------------------
277
 
# Cleanup submit.mc
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;
282
 
        new_mc submit;
283
 
        fi;
284
 
 
285
 
exit $changed;