~ubuntu-branches/ubuntu/trusty/postfix/trusty-updates

« back to all changes in this revision

Viewing changes to html/SASL_README.html

Tags: upstream-2.3.1
ImportĀ upstreamĀ versionĀ 2.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
<h2>WARNING</h2>
21
21
 
22
 
<p> People who go to the trouble of installing Postfix may have
23
 
the expectation that Postfix is more secure than some other mailers.
24
 
The Cyrus SASL library is a lot of code. With SASL authentication
25
 
enabled in the Postfix SMTP client and SMTP server, Postfix becomes
 
22
<p> People who go to the trouble of installing Postfix may have the
 
23
expectation that Postfix is more secure than some other mailers.
 
24
The Cyrus SASL library is a lot of code. With this, Postfix becomes
26
25
as secure as other mail systems that use the Cyrus SASL library.
 
26
Dovecot provides an alternative that may be worth considering.
27
27
</p>
28
28
 
29
29
<h2><a name="intro">How Postfix uses SASL authentication information</a></h2>
37
37
optionally grants mail access via the <a href="postconf.5.html#permit_sasl_authenticated">permit_sasl_authenticated</a>
38
38
UCE restriction. </p>
39
39
 
40
 
<p> Postfix does not record the client's SASL authentication
41
 
information in message headers, and does not pass it on via SMTP
42
 
commands when forwarding mail, because it is no-one else's business
43
 
to know the client username and authentication method.  People who
44
 
need to know can find the information in the local Postfix maillog
45
 
file.  Some day, Postfix message headers will be configurable and
46
 
then one can record the SASL username without having to edit C
47
 
code.  </p>
 
40
<p> When sending mail, Postfix can look up the server hostname or
 
41
destination domain (the address right-hand part) in a Postfix SASL password
 
42
table, and if a username/password is found, it will use that username
 
43
and password to authenticate to the server.  And as of version 2.3,
 
44
Postfix can be configured to search its SASL password table by the
 
45
sender email address. </p>
48
46
 
49
47
<p>This document covers the following topics: </p>
50
48
 
51
49
<ul>
52
50
 
53
 
<li><a href="#versions">What SASL versions are supported</a>
54
 
 
55
 
<li><a href="#build_sasl">Building the SASL library</a>
56
 
 
57
 
<li><a href="#build_postfix">Building Postfix with SASL authentication
 
51
<li><a href="#versions">What SASL implementations are supported</a>
 
52
 
 
53
<li><a href="#build_dovecot">Building Postfix with Dovecot SASL
 
54
support</a></li>
 
55
 
 
56
<li><a href="#build_sasl">Building the Cyrus SASL library</a>
 
57
 
 
58
<li><a href="#build_postfix">Building Postfix with Cyrus SASL
58
59
support</a></li>
59
60
 
60
61
<li><a href="#server_sasl">Enabling SASL authentication in the
61
62
Postfix SMTP server</a></li>
62
63
 
 
64
<li><a href="#server_dovecot">Dovecot SASL configuration for the Postfix
 
65
SMTP server</a></li>
 
66
 
 
67
<li><a href="#server_cyrus">Cyrus SASL configuration for the Postfix
 
68
SMTP server</a></li>
 
69
 
63
70
<li><a href="#server_test">Testing SASL authentication in the
64
71
Postfix SMTP server</a></li>
65
72
 
72
79
 
73
80
</ul>
74
81
 
75
 
<p> When sending mail, Postfix can look up the server hostname or
76
 
destination domain (the address right-hand part) in a table, and if a
77
 
username/password is found, it will use that username and password
78
 
to authenticate to the server. </p>
79
 
 
80
 
<h2><a name="versions">What SASL versions are supported</a></h2>
81
 
 
82
 
<p> Postfix+SASL 1.5.5 was seen working on RedHat 6.1 (pwcheck_method
83
 
set to shadow or sasldb), Solaris 2.7 (pwcheck_method set to shadow
84
 
or sasldb), and FreeBSD 3.4 (pwcheck_method set to sasldb).  On
85
 
RedHat 6.1, SASL 1.5.5 insisted on write access to /etc/sasldb.
86
 
Note that this seems to be related to the auto_transition switch
87
 
in SASL. Note also that the Cyrus SASL documentation says that it
88
 
is pointless to enable that if you use "sasldb" for "pwcheck_method".
89
 
Later versions of the SASL 1.5.x series should also work. </p>
90
 
 
91
 
<p> Postfix+SASL 2.1.1 appears to work on Mandrake Linux 8.1
92
 
(pwcheck_method set to saslauthd or auxprop).  Note that the
93
 
'auxprop' pwcheck_method replaces the 'sasldb' method from SASL
94
 
1.5.x.  Postfix may need write access to /etc/sasldb2 if you use
95
 
the auto_transition feature, or if you use an authentication
96
 
mechanism such as OTP (one-time passwords) that needs to update
97
 
secrets in the database. </p>
98
 
 
99
 
<h2><a name="build_sasl">Building the SASL library</a></h2>
 
82
<h2><a name="versions">What SASL implementations are supported</a></h2>
 
83
 
 
84
<p> This document describes Postfix with the following SASL
 
85
implementations: </p>
 
86
 
 
87
<ul>
 
88
 
 
89
<li> <p> Cyrus SASL version 1 (client and server). </p>
 
90
 
 
91
<li> <p> Cyrus SASL version 2 (client and server). </p>
 
92
 
 
93
<li> <p> Dovecot protocol version 1 (server only, Postfix version
 
94
2.3 and later) </p>
 
95
 
 
96
</ul>
 
97
 
 
98
<p> Postfix version 2.3 introduces a plug-in mechanism that provides
 
99
support for multiple SASL implementations.  To find out what
 
100
implementations are built into Postfix, use the following commands:
 
101
</p>
 
102
 
 
103
<blockquote>
 
104
<pre>
 
105
% postconf -a (SASL support in the SMTP server)
 
106
% postconf -A (SASL support in the SMTP+LMTP client)
 
107
</pre>
 
108
</blockquote>
 
109
 
 
110
<p> Needless to say, these commands are not available in earlier
 
111
Postfix versions. </p>
 
112
 
 
113
<h2><a name="build_dovecot">Building Postfix with Dovecot SASL
 
114
support</a></h2>
 
115
 
 
116
<p> Dovecot SASL support is available in Postfix 2.3 and later. The
 
117
Dovecot source code is available via <a href="http://www.dovecot.org/">http://www.dovecot.org/</a>. At
 
118
the time
 
119
of writing, only server-side SASL support is available, so you can't
 
120
use it to authenticate to your network provider's server. Dovecot
 
121
uses its own daemon process for authentication. This keeps the
 
122
Postfix build process simple, because there is no need to link extra
 
123
libraries into Postfix. </p>
 
124
 
 
125
<p> To generate the necessary Makefiles, execute the following
 
126
in the Postfix top-level directory: </p>
 
127
 
 
128
<blockquote>
 
129
<pre>
 
130
% make makefiles CCARGS='-DUSE_SASL_AUTH -DDEF_SASL_SERVER_TYPE=\"dovecot\"'
 
131
</pre>
 
132
</blockquote>
 
133
 
 
134
<p> After this, proceed with "<tt>make</tt>" as described in the
 
135
<a href="INSTALL.html">INSTALL</a> document. </p>
 
136
 
 
137
<p> Notes: </p>
 
138
 
 
139
<ul>
 
140
 
 
141
<li> <p> The "-DDEF_SASL_SERVER_TYPE" stuff is not necessary; it just
 
142
makes Postfix configuration a little more convenient because you
 
143
don't have to specify the SASL plug-in type in the Postfix <a href="postconf.5.html">main.cf</a>
 
144
file.  </p>
 
145
 
 
146
<li> <p> If you also want support for LDAP or TLS, you will have to merge
 
147
their CCARGS and AUXLIBS into the above command line. </p>
 
148
 
 
149
</ul>
 
150
 
 
151
<h2><a name="build_sasl">Building the Cyrus SASL library</a></h2>
100
152
 
101
153
<p> Postfix appears to work with cyrus-sasl-1.5.5 or cyrus-sasl-2.1.1, 
102
154
which are available from: </p>
103
155
 
104
156
<blockquote>
105
157
<pre>
106
 
<a href="ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/">ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/</a>.
 
158
<a href="ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/">ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/</a>
107
159
</pre>
108
160
</blockquote>
109
161
 
116
168
non-standard SASL LOGIN authentication method. To enable this
117
169
authentication method, specify ``./configure --enable-login''. </p>
118
170
 
119
 
<h2><a name="build_postfix">Building Postfix with SASL authentication
120
 
support</a></h2>
 
171
<h2><a name="build_postfix">Building Postfix with Cyrus SASL support</a></h2>
121
172
 
122
 
<p> To build Postfix with SASL authentication support, the following
 
173
<p> The following
123
174
assumes that the Cyrus SASL include files are in /usr/local/include,
124
175
and that the Cyrus SASL libraries are in /usr/local/lib. </p>
125
176
 
128
179
 
129
180
<dl>
130
181
 
131
 
<dt> (for SASL version 1.5.5):
 
182
<dt> (for Cyrus SASL version 1.5.5):
132
183
<dd>
133
184
<pre>
134
185
% make tidy # if you have left-over files from a previous build
135
 
% make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include" \
136
 
    AUXLIBS="-L/usr/local/lib -lsasl"
 
186
% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
 
187
    -I/usr/local/include" AUXLIBS="-L/usr/local/lib -lsasl"
137
188
</pre>
138
189
 
139
 
<dt> (for SASL version 2.1.1):
 
190
<dt> (for Cyrus SASL version 2.1.1):
140
191
<dd>
141
192
<pre>
142
193
% make tidy # if you have left-over files from a previous build
143
 
% make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include/sasl" \
144
 
    AUXLIBS="-L/usr/local/lib -lsasl2"
 
194
% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
 
195
    -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib -lsasl2"
145
196
</pre>
146
197
 
147
198
</dl>
151
202
 
152
203
<dl>
153
204
 
154
 
<dt> (for SASL version 1.5.5):
 
205
<dt> (for Cyrus SASL version 1.5.5):
155
206
<dd>
156
207
<pre>
157
208
% make tidy # if you have left-over files from a previous build
158
 
% make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include" \
159
 
    AUXLIBS="-L/usr/local/lib -R/usr/local/lib -lsasl"
 
209
% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
 
210
    -I/usr/local/include" AUXLIBS="-L/usr/local/lib \
 
211
    -R/usr/local/lib -lsasl"
160
212
</pre>
161
213
 
162
 
<dt> (for SASL version 2.1.1):
 
214
<dt> (for Cyrus SASL version 2.1.1):
163
215
<dd>
164
216
<pre>
165
217
% make tidy # if you have left-over files from a previous build
166
 
% make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include/sasl" \
167
 
    AUXLIBS="-L/usr/local/lib -R/usr/local/lib -lsasl2"
 
218
% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
 
219
    -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib \
 
220
    -R/usr/local/lib -lsasl2"
168
221
</pre>
169
222
 
170
223
</dl>
176
229
 
177
230
<blockquote>
178
231
<pre>
179
 
/etc/postfix/main.cf:
 
232
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
180
233
    <a href="postconf.5.html#smtpd_sasl_auth_enable">smtpd_sasl_auth_enable</a> = yes
181
234
</pre>
182
235
</blockquote>
185
238
 
186
239
<blockquote>
187
240
<pre>
188
 
/etc/postfix/main.cf:
 
241
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
189
242
    <a href="postconf.5.html#smtpd_recipient_restrictions">smtpd_recipient_restrictions</a> = 
190
243
        <a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a> <a href="postconf.5.html#permit_sasl_authenticated">permit_sasl_authenticated</a> ...
191
244
</pre>
192
245
</blockquote>
193
246
 
194
 
<p> In /usr/local/lib/sasl/smtpd.conf (SASL version 1.5.5) or
195
 
/usr/local/lib/sasl2/smtpd.conf (SASL version 2.1.1) you need to
 
247
<p> To report SASL login names in Received: message headers
 
248
(Postfix version 2.3 and later): </p>
 
249
 
 
250
<blockquote>
 
251
<pre>
 
252
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
253
    <a href="postconf.5.html#smtpd_sasl_authenticated_header">smtpd_sasl_authenticated_header</a> = yes
 
254
</pre>
 
255
</blockquote>
 
256
 
 
257
<p> Note: the SASL login names will be shared with the entire world.
 
258
</p>
 
259
 
 
260
<p> Older Microsoft SMTP client software implements a non-standard
 
261
version of the AUTH protocol syntax, and expects that the SMTP
 
262
server replies to EHLO with "250 AUTH=stuff" instead of "250 AUTH
 
263
stuff".  To accommodate such clients (in addition to conformant
 
264
clients) use the following: </p>
 
265
 
 
266
<blockquote>
 
267
<pre>
 
268
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
269
    <a href="postconf.5.html#broken_sasl_auth_clients">broken_sasl_auth_clients</a> = yes
 
270
</pre>
 
271
</blockquote>
 
272
 
 
273
<h2><a name="server_dovecot">Dovecot SASL configuration for the
 
274
Postfix SMTP server</a></h2>
 
275
 
 
276
<p> Dovecot SASL support is available in Postfix 2.3 and later.  On
 
277
the Postfix side you need to specify the location of the
 
278
Dovecot authentication daemon socket. We use a pathname relative
 
279
to the Postfix queue directory, so that it will work whether or not
 
280
Postfix runs chrooted: </p>
 
281
 
 
282
<blockquote>
 
283
<pre>
 
284
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
285
    <a href="postconf.5.html#smtpd_sasl_type">smtpd_sasl_type</a> = dovecot
 
286
    <a href="postconf.5.html#smtpd_sasl_path">smtpd_sasl_path</a> = private/auth
 
287
</pre>
 
288
</blockquote>
 
289
 
 
290
<p> On the Dovecot side you also need to specify the Dovecot
 
291
authentication daemon socket. In this case we specify an
 
292
absolute pathname. In the example we assume that the 
 
293
Postfix queue is under /var/spool/postfix/. </p>
 
294
 
 
295
<blockquote>
 
296
<pre>
 
297
/some/where/dovecot.conf:
 
298
    auth default {
 
299
      mechanisms = plain login
 
300
      passdb pam {
 
301
      }
 
302
      userdb passwd {
 
303
      }
 
304
      socket listen {
 
305
        client {
 
306
          path = /var/spool/postfix/private/auth
 
307
          mode = 0660
 
308
          user = postfix
 
309
          group = postfix
 
310
        }
 
311
      }
 
312
    }
 
313
</pre>
 
314
</blockquote>
 
315
 
 
316
<p> See the Dovecot documentation for how to configure and operate
 
317
the Dovecot authentication server. </p>
 
318
 
 
319
<h2><a name="server_cyrus">Cyrus SASL configuration for the Postfix
 
320
SMTP server</a></h2>
 
321
 
 
322
<p> In /usr/local/lib/sasl/smtpd.conf (Cyrus SASL version 1.5.5) or
 
323
/usr/local/lib/sasl2/smtpd.conf (Cyrus SASL version 2.1.1) you need to
196
324
specify how the server should validate client passwords. </p>
197
325
 
198
 
<p> In order to authenticate against the UNIX password database, try: </p>
 
326
<p> Note: some Postfix distributions are modified and look for 
 
327
the smtpd.conf file in /etc/postfix. </p>
 
328
 
 
329
<p> Note: some Cyrus SASL distributions look for the smtpd.conf
 
330
file in /etc/sasl2. </p>
 
331
 
 
332
<ul>
 
333
 
 
334
<li> <p> To authenticate against the UNIX password database, try: </p>
199
335
 
200
336
<dl>
201
 
<dt> (SASL version 1.5.5)
 
337
<dt> (Cyrus SASL version 1.5.5)
202
338
<dd>
203
339
<pre>
204
340
/usr/local/lib/sasl/smtpd.conf:
206
342
 
207
343
</pre>
208
344
 
209
 
<dt> (SASL version 2.1.1)
 
345
<dt> (Cyrus SASL version 2.1.1)
210
346
<dd>
211
347
<pre>
212
348
/usr/local/lib/sasl2/smtpd.conf:
215
351
 
216
352
</dl>
217
353
 
218
 
<p> The name of the file in /usr/local/lib/sasl (SASL version 1.5.5)
219
 
or /usr/local/lib/sasl2 (SASL version 2.1.1) used by the SASL
 
354
<p> The name of the file in /usr/local/lib/sasl (Cyrus SASL version
 
355
1.5.5) or /usr/local/lib/sasl2 (Cyrus SASL version 2.1.1) used by
 
356
the SASL
220
357
library for configuration can be set with: </p>
221
358
 
222
359
<blockquote>
223
360
<pre>
224
 
/etc/postfix/main.cf:
225
 
    <a href="postconf.5.html#smtpd_sasl_application_name">smtpd_sasl_application_name</a> = smtpd
 
361
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
362
    smtpd_sasl_application_name = smtpd (Postfix &lt; 2.3)
 
363
    <a href="postconf.5.html#smtpd_sasl_path">smtpd_sasl_path</a> = smtpd (Postfix 2.3 and later)
226
364
</pre>
227
365
</blockquote>
228
366
 
232
370
permission for the /var/pwcheck directory, otherwise authentication
233
371
attempts will fail. </p>
234
372
 
235
 
<p> Alternately, in SASL 1.5.26 and later (including 2.1.1), try: </p>
 
373
<li> <p> Alternately, in Cyrus SASL 1.5.26 and later (including
 
374
2.1.1), try: </p>
236
375
 
237
376
<dl>
238
377
 
239
 
<dt> (SASL version 1.5.26)
 
378
<dt> (Cyrus SASL version 1.5.26)
240
379
<dd>
241
380
<pre>
242
381
/usr/local/lib/sasl/smtpd.conf:
243
382
    pwcheck_method: saslauthd
244
383
</pre>
245
384
 
246
 
<dt> (SASL version 2.1.1)
 
385
<dt> (Cyrus SASL version 2.1.1)
247
386
<dd>
248
387
<pre>
249
388
/usr/local/lib/sasl2/smtpd.conf:
257
396
can authenticate against PAM and various other sources. To use PAM,
258
397
start saslauthd with "-a pam". </p>
259
398
 
260
 
<p> In order to authenticate against SASL's own password database: </p>
 
399
<li> <p> To authenticate against Cyrus SASL's own password database: </p>
261
400
 
262
401
<dl>
263
 
<dt> (SASL version 1.5.5)
 
402
<dt> (Cyrus SASL version 1.5.5)
264
403
<dd>
265
404
<pre>
266
405
/usr/local/lib/sasl/smtpd.conf:
267
406
    pwcheck_method:  sasldb
268
407
</pre>
269
408
 
270
 
<dt> (SASL version 2.1.1)
 
409
<dt> (Cyrus SASL version 2.1.1)
271
410
<dd>
272
411
<pre>
273
412
/usr/local/lib/sasl2/smtpd.conf:
276
415
 
277
416
</dl>
278
417
 
279
 
<p> This will use the SASL password file (default: /etc/sasldb in
 
418
<p> This will use the Cyrus SASL password file (default: /etc/sasldb in
280
419
version 1.5.5, or /etc/sasldb2 in version 2.1.1), which is maintained
281
420
with the saslpasswd or saslpasswd2 command (part of the Cyrus SASL
282
421
software). On some poorly-supported systems the saslpasswd command needs
283
422
to be run multiple times before it stops complaining.  The Postfix SMTP
284
423
server needs read access to the sasldb file - you may have to play games
285
424
with group access permissions.  With the OTP authentication mechanism,
286
 
the SMTP server also needs write access to /etc/sasldb2 or /etc/sasldb
 
425
the SMTP server also needs WRITE access to /etc/sasldb2 or /etc/sasldb
287
426
(or the back end SQL database, if used). </p>
288
427
 
 
428
<p> IMPORTANT: To get sasldb running, make sure that you set the SASL
 
429
domain (realm) to a fully qualified domain name. </p>
 
430
 
 
431
<p> EXAMPLE: </p>
 
432
 
 
433
<dl>
 
434
<dt> (Cyrus SASL version 1.5.5)
 
435
<dd>
 
436
<pre>
 
437
% saslpasswd -c -u `postconf -h <a href="postconf.5.html#myhostname">myhostname</a>` exampleuser
 
438
</pre>
 
439
 
 
440
<dt> (Cyrus SASL version 2.1.1)
 
441
<dd>
 
442
<pre>
 
443
% saslpasswd2 -c -u `postconf -h <a href="postconf.5.html#myhostname">myhostname</a>` exampleuser
 
444
</pre>
 
445
 
 
446
</dl>
 
447
 
 
448
<p> You can find out SASL's idea about the realms of the users
 
449
in sasldb with <i>sasldblistusers</i> (Cyrus SASL version 1.5.5) or
 
450
<i>sasldblistusers2</i> (Cyrus SASL version 2.1.1). </p>
 
451
 
 
452
<p> On the Postfix side, you can have only one realm per smtpd
 
453
instance, and only the users belonging to that realm would be able to
 
454
authenticate.  The Postfix variable <a href="postconf.5.html#smtpd_sasl_local_domain">smtpd_sasl_local_domain</a> controls the
 
455
realm used by smtpd: </p>
 
456
 
 
457
<blockquote>
 
458
<pre>
 
459
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
460
    <a href="postconf.5.html#smtpd_sasl_local_domain">smtpd_sasl_local_domain</a> = $<a href="postconf.5.html#myhostname">myhostname</a>
 
461
</pre>
 
462
</blockquote>
 
463
 
 
464
</ul>
 
465
 
289
466
<p> IMPORTANT: all users must be able to authenticate using ALL
290
467
authentication mechanisms advertised by Postfix, otherwise the
291
468
negotiation might end up with an unsupported mechanism, and
297
474
those mechanisms are made available by other plugins, and the SASL
298
475
library have no way to know that your only valid authentication source
299
476
is PAM.  Thus you might need to limit the list of mechanisms advertised
300
 
by Postfix.  This is only possible with SASL version 2.1.1 or later:
301
 
</p>
 
477
by Postfix. </p>
 
478
 
 
479
<ul> 
 
480
 
 
481
<li> <p> With older Cyrus SASL versions you remove the corresponding
 
482
library files from the SASL plug-in directory (and again whenever
 
483
the system is updated). </p>
 
484
 
 
485
<li> <p> With Cyrus SASL version 2.1.1 or later: </p>
302
486
 
303
487
<blockquote>
304
488
<pre>
307
491
</pre>
308
492
</blockquote>
309
493
 
 
494
</ul>
 
495
 
310
496
<p> For the same reasons you might want to limit the list of plugins
311
 
used for authentication.  With SASL version 1.5.5 your only choice is to
312
 
delete the corresponding libraries from /usr/local/lib/sasl.  With SASL
313
 
version 2.1.1: </p>
 
497
used for authentication. </p>
 
498
 
 
499
<ul>
 
500
 
 
501
<li> <p> With Cyrus SASL version 1.5.5 your only choice is to
 
502
delete the corresponding library files from the SASL plug-in 
 
503
directory. </p>
 
504
 
 
505
<li> <p> With SASL version 2.1.1: </p>
314
506
 
315
507
<blockquote>
316
508
<pre>
320
512
</pre>
321
513
</blockquote>
322
514
 
323
 
<p> IMPORTANT: To get sasldb running, make sure that you set the SASL
324
 
domain (realm) to a fully qualified domain name. </p>
325
 
 
326
 
<p> EXAMPLE: </p>
327
 
 
328
 
<dl>
329
 
<dt> (SASL version 1.5.5)
330
 
<dd>
331
 
<pre>
332
 
% saslpasswd -c -u `postconf -h <a href="postconf.5.html#myhostname">myhostname</a>` exampleuser
333
 
</pre>
334
 
 
335
 
<dt> (SASL version 2.1.1)
336
 
<dd>
337
 
<pre>
338
 
% saslpasswd2 -c -u `postconf -h <a href="postconf.5.html#myhostname">myhostname</a>` exampleuser
339
 
</pre>
340
 
 
341
 
</dl>
342
 
 
343
 
<p> You can find out SASL's idea about the realms of the users
344
 
in sasldb with <i>sasldblistusers</i> (SASL version 1.5.5) or
345
 
<i>sasldblistusers2</i> (SASL version 2.1.1). </p>
346
 
 
347
 
<p> On the Postfix side, you can have only one realm per smtpd
348
 
instance, and only the users belonging to that realm would be able to
349
 
authenticate.  The Postfix variable <a href="postconf.5.html#smtpd_sasl_local_domain">smtpd_sasl_local_domain</a> controls the
350
 
realm used by smtpd: </p>
351
 
 
352
 
<blockquote>
353
 
<pre>
354
 
/etc/postfix/main.cf:
355
 
    <a href="postconf.5.html#smtpd_sasl_local_domain">smtpd_sasl_local_domain</a> = $<a href="postconf.5.html#myhostname">myhostname</a>
356
 
</pre>
357
 
</blockquote>
 
515
</ul>
358
516
 
359
517
<p> To run software chrooted with SASL support is an interesting
360
518
exercise.  It probably is not worth the trouble. </p>
361
519
 
362
 
<p> Older Microsoft SMTP client software implements a non-standard
363
 
version of the AUTH protocol syntax, and expects that the SMTP
364
 
server replies to EHLO with "250 AUTH=stuff" instead of "250 AUTH
365
 
stuff".  To accommodate such clients in addition to conformant
366
 
clients, set "<a href="postconf.5.html#broken_sasl_auth_clients">broken_sasl_auth_clients</a> = yes" in the main.cf file.
367
 
</p>
368
 
 
369
520
<h2><a name="server_test">Testing SASL authentication in the Postfix
370
521
SMTP server</a></h2>
371
522
 
375
526
 
376
527
<blockquote>
377
528
<pre>
378
 
220 server.host.tld ESMTP Postfix
379
 
<b>EHLO client.host.tld</b>
380
 
250-server.host.tld
 
529
220 server.example.com ESMTP Postfix
 
530
<b>EHLO client.example.com</b>
 
531
250-server.example.com
381
532
250-PIPELINING
382
533
250-SIZE 10240000
383
534
250-ETRN
412
563
<p> The mmencode command is part of the metamail software.
413
564
MIME::Base64 is available from <a href="http://www.cpan.org/">http://www.cpan.org/</a>. </p>
414
565
 
415
 
<p> When posting logs of the SASL negotiations to public lists,
 
566
<p> Caution: when posting logs of the SASL negotiations to public
 
567
lists,
416
568
please keep in mind that username/password information is trivial
417
569
to recover from the base64-encoded form. </p>
418
570
 
437
589
<h2><a name="client_sasl">Enabling SASL authentication in the
438
590
Postfix SMTP client</a></h2>
439
591
 
440
 
<p> Turn on client-side SASL authentication, and specify a table with
441
 
per-host or per-destination username and password information.
442
 
Postfix first looks up the server hostname; if no entry is found,
443
 
then Postfix looks up the destination domain name (usually, the
444
 
right-hand part of an email address). </p>
445
 
 
446
 
<blockquote>
447
 
<pre>
448
 
/etc/postfix/main.cf:
449
 
    <a href="postconf.5.html#smtp_sasl_auth_enable">smtp_sasl_auth_enable</a> = yes
450
 
    <a href="postconf.5.html#smtp_sasl_password_maps">smtp_sasl_password_maps</a> = hash:/etc/postfix/sasl_passwd
451
 
 
452
 
/etc/postfix/sasl_passwd:
453
 
    foo.com             username:password
454
 
    bar.com             username
 
592
<p> Turn on client-side SASL authentication, and specify a table
 
593
with per-host or per-destination username and password information.
 
594
Postfix first searches the table for an entry with the server
 
595
hostname; if no entry is found, then Postfix searches the table for
 
596
an entry with the next-hop destination.  Usually, that is the
 
597
right-hand part of an email address, but it can also be the information
 
598
that is specified with the <a href="postconf.5.html#relayhost">relayhost</a> parameter or with a <a href="transport.5.html">transport(5)</a>
 
599
table. </p>
 
600
 
 
601
<blockquote>
 
602
<pre>
 
603
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
604
    <a href="postconf.5.html#smtp_sasl_auth_enable">smtp_sasl_auth_enable</a> = yes
 
605
    <a href="postconf.5.html#smtp_sasl_password_maps">smtp_sasl_password_maps</a> = hash:/etc/postfix/sasl_passwd
 
606
    <a href="postconf.5.html#smtp_sasl_type">smtp_sasl_type</a> = cyrus
 
607
 
 
608
/etc/postfix/sasl_passwd:
 
609
    foo.com                     username:password
 
610
    bar.com                     username
 
611
    [mail.myisp.net]            username:password
 
612
    [mail.myisp.net]:submission username:password
 
613
</pre>
 
614
</blockquote>
 
615
 
 
616
<p> Postfix version 2.3 supports-per-sender SASL password
 
617
information. To search the Postfix SASL password by sender 
 
618
before it searches by destination, specify: </p>
 
619
 
 
620
<blockquote>
 
621
<pre>
 
622
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
623
    <a href="postconf.5.html#smtp_sender_dependent_authentication">smtp_sender_dependent_authentication</a> = yes
 
624
    <a href="postconf.5.html#smtp_sasl_auth_enable">smtp_sasl_auth_enable</a> = yes
 
625
    <a href="postconf.5.html#smtp_sasl_password_maps">smtp_sasl_password_maps</a> = hash:/etc/postfix/sasl_passwd
 
626
 
 
627
/etc/postfix/sasl_passwd:
 
628
    user@example.com            username:password
 
629
    bar.com                     username
 
630
    [mail.myisp.net]            username:password
 
631
    [mail.myisp.net]:submission username:password
455
632
</pre>
456
633
</blockquote>
457
634
 
464
641
 
465
642
<blockquote>
466
643
<pre>
467
 
/etc/postfix/main.cf:
468
 
    <a href="postconf.5.html#smtp_sasl_security_options">smtp_sasl_security_options</a> = 
 
644
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
645
    <a href="postconf.5.html#smtp_sasl_security_options">smtp_sasl_security_options</a> = noanonymous
469
646
</pre>
470
647
</blockquote>
471
648
 
472
 
<p> The SASL client password file is opened before the SMTP server
 
649
<p> The Postfix SASL client password file is opened before the SMTP server
473
650
enters the optional chroot jail, so you can keep the file in
474
651
/etc/postfix. </p>
475
652
 
478
655
possess the appropriate credentials to authenticate to the server. It
479
656
is possible via the <a href="postconf.5.html#smtp_sasl_mechanism_filter">smtp_sasl_mechanism_filter</a> parameter to further
480
657
restrict the list of server mechanisms that the <a href="smtp.8.html">smtp(8)</a> client will take
481
 
into consideration.  </p>
 
658
into consideration:  </p>
 
659
 
 
660
<blockquote>
 
661
<pre>
 
662
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
 
663
    <a href="postconf.5.html#smtp_sasl_mechanism_filter">smtp_sasl_mechanism_filter</a> = !gssapi, !external, static:all
 
664
</pre>
 
665
</blockquote>
 
666
 
 
667
<p> In the above example, Postfix will decline to use mechanisms
 
668
that require special infrastructure such as Kerberos. </p>
482
669
 
483
670
<p> The Postfix SMTP client is backwards compatible with SMTP
484
671
servers that use the non-standard "AUTH=method..." syntax in response
494
681
 
495
682
<li> Wietse trimmed down the code to only the bare necessities.
496
683
 
497
 
<li> Support for SASL version 2 was contributed by Jason Hoos.
 
684
<li> Support for Cyrus SASL version 2 was contributed by Jason Hoos.
498
685
 
499
 
<li> Liviu Daia added <a href="postconf.5.html#smtpd_sasl_application_name">smtpd_sasl_application_name</a>, split
 
686
<li> Liviu Daia added smtpd_sasl_application_name, split
500
687
<a href="postconf.5.html#reject_sender_login_mismatch">reject_sender_login_mismatch</a> into
501
688
<a href="postconf.5.html#reject_authenticated_sender_login_mismatch">reject_authenticated_sender_login_mismatch</a> and
502
689
<a href="postconf.5.html#reject_unauthenticated_sender_login_mismatch">reject_unauthenticated_sender_login_mismatch</a>, and revised the docs.
503
690
 
 
691
<li> Wietse made another iteration through the code to add plug-in
 
692
support for multiple SASL implementations, and changed
 
693
smtpd_sasl_application_name into <a href="postconf.5.html#smtpd_sasl_path">smtpd_sasl_path</a>.
 
694
 
 
695
<li> The Dovecot SMTP server-only plug-in was originally implemented by
 
696
Timo Sirainen of Procontrol, Finland.
 
697
 
504
698
</ul>
505
699
 
506
700
</body>