1 Setting up MTAs for Debbugs
2 ===========================
6 Be sure to set the $gMailer variable correctly in /etc/debbugs/config.
7 The options are (all lower case) exim, qmail and sendmail.
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).
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
23 This user needs to be able to write to /var/lib/debbugs.
25 /etc/exim4/conf.d/main/03_debbugs:
26 DEBBUGS_DOMAIN = <domain name>
27 DEBBUGS_USER = Debian-debbugs
28 DEBBUGS_GROUP = Debian-debbugs
30 /etc/exim4/conf.d/transport/30_debbugs:
32 debug_print = "T: debbugs_pipe for $local_part@$domain"
36 command = /usr/lib/debbugs/receive
39 /etc/exim4/conf.d/router/250_debbugs:
41 debug_print = "R: debbugs for $local_part@$domain"
43 transport = debbugs_pipe
44 local_parts = submit : bugs : maintonly : quiet : forwarded : \
45 done : close : request : submitter : control : ^\\d+
46 domains = DEBBUGS_DOMAIN
49 debug_print = "R: bounce_debbugs for $local_part@$domain"
52 data = :fail: Unknown user
53 domains = DEBBUGS_DOMAIN
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.
65 I've seen two types of Exim 3 set ups being used:
67 1) If the machine is dedicated and all e-mail goes to the debbugs script,
68 add this in the transport section:
72 user = <some non-root user>
73 group = <some non-root group>
74 command = /usr/lib/debbugs/receive
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
81 And AT THE TOP of the directors section, add this:
85 transport = debbugs_pipe
86 local_parts = submit:bugs:maintonly:quiet:forwarded:done:close:request:submitter:control:^\\d+
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
93 domains = <domain name>
95 Alternatively, Chad Miller <cmiller@surfsouth.com> suggests:
97 The method I discovered involved adding at the top of the routers section:
101 transport = debbugs_transport
102 route_list = "bugs.foo.bar;bugs.baz.quux"
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:
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
116 (current_directory may need to be /var/lib/debbugs/spool, depending on
119 Next, the mail domains MUST NOT be in the "local_domains" list!
120 Instead, we MUST put them in the "relay_domains" list.
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").
129 From Tommi Virtanen (tv@debian.org), amended by Daniel Ruoso
132 Here's my suggestion for safe & secure installation under qmail:
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
150 From Wichert Akkerman (wakkerma@debian.org):
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
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:
161 bugs IN 192.168.2.100
162 0 MX mailgate.mors.net
163 HINFO "PC Pentium" "Debbugs 2.0"
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
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.
174 To enable the mailertable put the following line in your sendmail.mc file:
176 FEATURE(mailertable, `text -o /etc/mail/mailertable')dnl
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:
183 FEATURE(mailertable, `hash -o /etc/mail/mailertable.db')dnl
185 You can create the database using the following command:
187 makemap hash mailertable.db < mailertable
189 Where mailertable is the textfile containing the data.
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:
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
198 Where <uid> and <gid> should be replaced with the user and group you
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:
205 bugs.your.net debbugs:yournet
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!
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!
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.
222 DNS setup: point the MX to the machine running debbugs:
224 bugs.domain.net MX 50 master.domain.net.
226 For postfix we have to do three things now:
228 1. Open postfix for any recipient address on the domain
230 2. Create a transport map to the debbugs script called
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.
236 So, create /etc/postfix/transport and insert:
238 bugs.domain.net debbugs:
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:
244 $ postmap hash:/etc/postfix/transport
246 So, create /etc/postfix/debbugs-recipients and put:
248 @bugs.domain.net ACCEPT
252 Here, we also need to make a database from that map, so
253 that postfix can use:
255 # postmap hash:/etc/postfix/debbugs-recipients
257 In /etc/postfix/main.cf we enable the transport and local recipient
258 map by inserting the following lines:
260 transport_maps = hash:/etc/postfix/transport
262 local_recipient_maps = hash:/etc/postfix/non-unix-users
263 transport_maps = hash:/etc/postfix/transport
264 debbugs_destination_recipient_limit = 1
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.
269 At last we need to teach postfix what the debbugs transport agent is. Edit
270 /etc/postfix/master.cf and add:
272 debbugs unix - n n - - pipe
273 flags=F user=debbugs argv=/usr/lib/debbugs/receive $recipient
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).
279 Finally add bugs.domain.net to mydestination in main.cf:
281 mydestination = $myhostname localhost.$mydomain bugs.domain.net
283 Now that all this is done, restart postfix and it should be working..
286 Updated+modified by Mike (20120919)
289 Procmail and SpamAssassin
290 -------------------------
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).
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:
301 |procmail -p -m /org/bugs.debian.org/mail/.procmailrc
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
310 MAILDIR=/org/bugs.debian.org/mail
311 LOGFILE=$MAILDIR/.logfile
315 SENDMAIL=/usr/sbin/sendmail
316 YEARMONTH=`/bin/date +%Y-%m`
319 Next, a safety catch (optional): we copy all incoming mail into an mbox.
320 This can easily grow quite large!
323 backup/save-all.$YEARMONTH
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:
334 spam/assassinated.$YEARMONTH
336 (The lock here is due to resource problems during mail floods. There may be
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.
344 ? test "$LOCAL_PART" = owner -o "$LOCAL_PART" = postmaster
350 !foo@example.org, bar@example.org
353 Everything else can now be saved to yet another mailbox and passed on to the
357 receive/receive.$YEARMONTH
360 |/usr/lib/debbugs/receive
362 This should be sufficient, or even overkill, for a small installation.
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.
369 * LOCAL_PART ?? control
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:"; \
377 echo "This service is unavailable.") | $SENDMAIL -oi -t
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