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