]> git.donarmstrong.com Git - debbugs.git/blob - debian/README.mail
use scalar IO::InnerFile::getline to work around an InnerFile bug
[debbugs.git] / debian / README.mail
1 Setting up MTAs for Debbugs
2 ===========================
3
4 Config
5 ------
6 Be sure to set the $gMailer variable correctly in /etc/debbugs/config.
7 The options are (all lower case) exim, qmail and sendmail.
8
9
10 Exim 4
11 ------
12 The exim 4 setup supports virtual domains. This doesn't hurt on a
13 dedicated system. File names are for systems that use exim4's split
14 config scheme. If you use something else, you'll need to put the
15 configuration options in yourself at the appropriate place (most
16 likely /etc/exim4/exim4.conf or /etc/exim4/exim4.conf.template).
17
18 Create a non-root user with a non-root group as its primary group.
19 We'll use Debian-debbugs as the user and group:
20  # adduser --system --group --home /var/lib/debbugs \
21    --no-create-home --disabled-login --force-badname Debian-debbugs
22
23 This user needs to be able to write to /var/lib/debbugs.
24
25 /etc/exim4/conf.d/main/03_debbugs:
26 DEBBUGS_DOMAIN = <domain name>
27 DEBBUGS_USER = Debian-debbugs
28 DEBBUGS_GROUP = Debian-debbugs
29
30 /etc/exim4/conf.d/transport/30_debbugs:
31 debbugs_pipe:
32   debug_print = "T: debbugs_pipe for $local_part@$domain"
33   driver = pipe
34   user = DEBBUGS_USER
35   group = DEBBUGS_GROUP
36   command = /usr/lib/debbugs/receive
37   return_output
38
39 /etc/exim4/conf.d/router/250_debbugs:
40 debbugs:
41   debug_print = "R: debbugs for $local_part@$domain"
42   driver = accept
43   transport = debbugs_pipe
44   local_parts = submit : bugs : maintonly : quiet : forwarded : \
45                 done : close : request : submitter : control : ^\\d+
46   domains = DEBBUGS_DOMAIN
47
48 bounce_debbugs:
49   debug_print = "R: bounce_debbugs for $local_part@$domain"
50   driver = redirect
51   allow_fail
52   data = :fail: Unknown user
53   domains = DEBBUGS_DOMAIN
54
55 The bounce_debbugs router bounces all mail for the DEBBUGS_DOMAIN that
56 hasn't been picked up by the debbugs router. If you want addresses
57 from that domain that do not belong to debbugs to be handled normally,
58 simply omit that router. However, since the pattern on deb debbugs
59 router match a significant subset of the domain's local parts, it is
60 strongly recommended to use a dedicated domain for debbugs.
61
62
63 Exim 3
64 ----
65 I've seen two types of Exim 3 set ups being used:
66
67  1) If the machine is dedicated and all e-mail goes to the debbugs script,
68     add this in the transport section:
69
70 debbugs_pipe:
71   driver = pipe
72   user = <some non-root user>
73   group = <some non-root group>
74   command = /usr/lib/debbugs/receive
75   return_output
76
77     Do not use root user/group, it is very unsafe. You could even add a new
78     (locked) account "debbugs", and use that. Either user or group needs
79     write access.
80
81     And AT THE TOP of the directors section, add this:
82
83 debbugs:
84   driver = smartuser
85   transport = debbugs_pipe
86   local_parts = submit:bugs:maintonly:quiet:forwarded:done:close:request:submitter:control:^\\d+
87
88  2) If the domain is a virtual host on a machine that needs it, there are
89     many ways of handling it.  I think the neatest was to use the above
90     transport and director, except to add the following line to the
91     director's options:
92
93   domains = <domain name>
94
95     Alternatively, Chad Miller <cmiller@surfsouth.com> suggests:
96
97     The method I discovered involved adding at the top of the routers section:
98
99 debbugs_router:
100   driver = domainlist
101   transport = debbugs_transport
102   route_list = "bugs.foo.bar;bugs.baz.quux"
103
104     where bugs.foo.bar and bugs.baz.quux are mail-domains for which I want to
105     receive bug requests only.
106     Next, add anywhere in the transports section:
107
108 debbugs_transport:
109   driver = pipe
110   command = /usr/lib/debbugs/receive
111   user = <some non-root user>
112   group = <some non-root group>
113   current_directory = /etc/debbugs
114   home_directory = /var/lib/debbugs/spool
115
116     (current_directory may need to be /var/lib/debbugs/spool, depending on
117     your setup.)
118
119     Next, the mail domains MUST NOT be in the "local_domains" list!
120     Instead, we MUST put them in the "relay_domains" list.
121
122     Essentially, this tells exim that we agree ("relay_domains") to relay
123     mail for those zones ("debbugs_router") and "send" the mail using a pipe
124     ("debbugs_transport").
125
126
127 Qmail
128 -----
129 From Tommi Virtanen (tv@debian.org), amended by Daniel Ruoso
130 (daniel@ruoso.com):
131
132 Here's my suggestion for safe & secure installation under qmail:
133         
134 Create a separate user for the debbugs system.
135         # adduser --system --group --home /home/misc/debbugs debbugs
136 Give control of a virtual domain to that user
137         # echo bugs.example.com:debbugs >>/etc/qmail/virtualdomains
138 Give the user access to the bug databases
139         # chown -R debbugs:debbugs /var/lib/debbugs/*
140 Set the BTS owner address
141         # echo '&me@my.example.com' >~debbugs/.qmail-owner
142 Make the BTS handle it's mail
143         # echo '|/usr/lib/debbugs/receive' >~debbugs/.qmail-default
144 Reload the virtualdomains config file
145         # /etc/init.d/qmail reload
146 That's it!
147         
148 Sendmail
149 --------
150 From Wichert Akkerman (wakkerma@debian.org):
151
152 First of all make sure that debbugs is configured for sendmail: look
153 at /etc/debbugs/config for the $gMailer variable and make sure it is
154 set to 'sendmail'.
155
156 Next make sure that your DNS is configured properly. For sendmail
157 this means you cannot use a CNAME for the debbugs-domain, since that
158 gets remapped to the canonical name and thus bypasses the mailertable
159 we need. This is an example of a working DNS entry:
160
161         bugs            IN      192.168.2.100
162                                 0 MX mailgate.mors.net
163                                 HINFO "PC Pentium" "Debbugs 2.0"
164
165 Now that that is finished it is time to configure sendmail itself. First
166 make sure that sendmail does not consider the debbugs-domain as local by
167 making sure it is not listed in /etc/mail/sendmail.cw . Now start your
168 favourite editor and load /etc/mail/sendmail.mc . We need to make two
169 changes
170 there: add a mailertable and define the debbugs delivery agent.  The
171 mailertable is needed to tell sendmail to use the debbugs to deliver mail
172 destined for your debbugs server.
173
174 To enable the mailertable put the following line in your sendmail.mc file:
175
176         FEATURE(mailertable, `text -o /etc/mail/mailertable')dnl
177
178 This tells sendmail to use the textfile /etc/mail/mailertable as the
179 database containing the table. You can also use a db database if you
180 want to add a lot of entries in there since that is faster. If you
181 want to do that use the following line instead:
182
183         FEATURE(mailertable, `hash -o /etc/mail/mailertable.db')dnl
184
185 You can create the database using the following command:
186
187         makemap hash mailertable.db < mailertable
188
189 Where mailertable is the textfile containing the data.
190
191 The next thing we need to do is tell sendmail about the debbugs delivery
192 agent. To do this add the following two lines to your sendmail.mc file,
193 preferably just after the MAILER commands:
194
195 Mdebbugs,       P=/usr/lib/debbugs/receive, F=SDFMlhudb80, U=<uid>:<gid>,
196                 S=10/30, R=20/30, D=/tmp, T=DNS/RFC822/X-Unix, A=receive $u
197
198 Where <uid> and <gid> should be replaced with the user and group you
199 use for debbugs.
200
201 Okay, we are now done with sendmail.mc and are ready to add the entry
202 in your mailertable. Save sendmail.mc and load /etc/mail/mailertable in
203 your editor. Put a single line in there just like this one:
204
205         bugs.your.net           debbugs:yournet
206
207 (please note there are tabs between those words). This tells sendmail that
208 mail destined for the host bugs.your.net should be handled by the debbugs
209 delivery agent using yournet as the hostname. If you decided to use a db
210 database instead of the plain textfile don't forget to run makemap now!
211
212 Now the final step: run sendmailconfig to regenerate sendmail.cf and
213 restart sendmail with the new configuration. Your system should now
214 be up and running. Congratulations!
215
216
217 Postfix
218 -------
219 Let's assume that you are going to install bugs.domain.net, and you
220 are going to run it on the machine master.domain.net.
221
222 DNS setup: point the MX to the machine running debbugs:
223
224         bugs.domain.net         MX      50      master.domain.net.
225
226 For postfix we have to do three things now:
227
228  1. Open postfix for any recipient address on the domain
229     bugs.domain.net
230  2. Create a transport map to the debbugs script called
231     ,,receive''.
232  3. Make sure that mails are handed individually into the
233     debbugs pipe. The receive script can only process mails
234     with _one_ recipient.
235
236 So, create /etc/postfix/transport and insert:
237
238         bugs.domain.net        debbugs:
239
240 This tells postfix to use the debbugs transport agent to deliver any
241 mail send to bugs.domain.net. Now we need to make a database from that
242 map, so that postfix can use:
243
244         $ postmap hash:/etc/postfix/transport
245
246 So, create /etc/postfix/debbugs-recipients and put:
247
248         @bugs.domain.net          ACCEPT
249
250 into it.
251
252 Here, we also need to make a database from that map, so
253 that postfix can use:
254
255         # postmap hash:/etc/postfix/debbugs-recipients
256
257 In /etc/postfix/main.cf we enable the transport and local recipient
258 map by inserting the following lines:
259
260         transport_maps = hash:/etc/postfix/transport
261         # debbugs transport
262         local_recipient_maps = hash:/etc/postfix/non-unix-users
263         transport_maps = hash:/etc/postfix/transport
264         debbugs_destination_recipient_limit = 1
265
266 The last line in the block above assures that mails pour into
267 the debbugs receive scripts on a one by one recipient basis.
268
269 At last we need to teach postfix what the debbugs transport agent is. Edit
270 /etc/postfix/master.cf and add:
271
272         debbugs   unix  -       n       n       -       -       pipe
273                 flags=F user=debbugs argv=/usr/lib/debbugs/receive $recipient
274
275 This assumes that you are running debbugs with uid debbugs (the package
276 doesn't do that by default, but I generally chown /var/lib/debbugs/*
277 to a new debbugs account just to be safe).
278
279 Finally add bugs.domain.net to mydestination in main.cf:
280
281         mydestination = $myhostname localhost.$mydomain bugs.domain.net
282
283 Now that all this is done, restart postfix and it should be working..
284
285 Wichert
286 Updated+modified by Mike (20120919)
287
288
289 Procmail and SpamAssassin
290 -------------------------
291
292 Publicly-accessible debbugs installations have been known to receive a lot
293 of spam. To combat this, some sites may find it useful to deliver mail to
294 debbugs via procmail and filter everything through a spam detector like
295 SpamAssassin. Here's a quick sketch of how to set this up (with Exim, but
296 other MTAs should be similar).
297
298 Arrange for mail to be delivered to procmail somehow. At the time of
299 writing, bugs.debian.org uses a .forward file like this:
300
301         |procmail -p -m /org/bugs.debian.org/mail/.procmailrc
302
303 The first thing to do in .procmailrc is to set up various variables used
304 either implicitly or explicitly later on. Obviously, substitute
305 /org/bugs.debian.org and so on with details of your own installation, and
306 make sure any directories mentioned in mailbox names exist with appropriate
307 permissions under $MAILDIR. Many of these variables are documented in
308 procmailrc(5).
309
310         MAILDIR=/org/bugs.debian.org/mail
311         LOGFILE=$MAILDIR/.logfile
312         COMSAT=no
313         UMASK=003
314         SPAMC=/usr/bin/spamc
315         SENDMAIL=/usr/sbin/sendmail
316         YEARMONTH=`/bin/date +%Y-%m`
317         YEAR=`/bin/date +%Y`
318
319 Next, a safety catch (optional): we copy all incoming mail into an mbox.
320 This can easily grow quite large!
321
322         :0c:
323         backup/save-all.$YEARMONTH
324
325 At this point you can insert customized rules for your site that drop or
326 bounce particular types of mail. Then, filter through SpamAssassin and file
327 matches off into a separate mailbox:
328
329         :0fw:spamc.lock
330         | $SPAMC
331
332         :0:
333         * ^X-Spam-Flag: yes
334         spam/assassinated.$YEARMONTH
335
336 (The lock here is due to resource problems during mail floods. There may be
337 better solutions.)
338
339 Now arrange for owner@bugs mail to be copied to another mailbox and sent on
340 to the right people. $LOCAL_PART is Exim-specific. Some people may prefer
341 this to come before the SpamAssassin check.
342
343         :0
344         ? test "$LOCAL_PART" = owner -o "$LOCAL_PART" = postmaster
345         {
346           :0c:
347           owner/owner.$YEAR
348
349           :0
350           !foo@example.org, bar@example.org
351         }
352
353 Everything else can now be saved to yet another mailbox and passed on to the
354 receive script:
355
356         :0c:
357         receive/receive.$YEARMONTH
358
359         :0
360         |/usr/lib/debbugs/receive
361
362 This should be sufficient, or even overkill, for a small installation.
363
364 Some sites need to block particular abusers from using particular services,
365 such as control@bugs, but don't want to ban them altogether. In this case an
366 autoreply approach may be useful.
367
368         :0h
369         * LOCAL_PART ?? control
370         * !^FROM_DAEMON
371         * !^X-Loop: owner@bugs\.example\.org
372         * ^(From|Reply-To):.*(abuser1@example\.org|abuser2@example\.org)
373         | (formail -r -I"From: owner@bugs.example.org" -I"Precedence: junk" \
374                       -A"X-Loop: owner@bugs.example.org"; \
375            echo "Processing commands for control@bugs.example.org:"; \
376            echo; \
377            echo "This service is unavailable.") | $SENDMAIL -oi -t
378
379 Although not documented here, similar autoreply tricks should be possible
380 without procmail. For instance, I would be surprised if Exim filters weren't
381 up to the task.