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