xref: /netbsd-src/external/ibm-public/postfix/dist/html/SASL_README.html (revision b7b7574d3bf8eeb51a1fa3977b59142ec6434a55)
1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
2        "http://www.w3.org/TR/html4/loose.dtd">
3
4<head>
5
6<title>Postfix SASL Howto</title>
7
8<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
9
10</head>
11
12<body>
13
14<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix SASL Howto</h1>
15
16<hr>
17
18<h2>Warning</h2>
19
20<p> People who go to the trouble of installing Postfix may have the
21expectation that Postfix is more secure than some other mailers.
22The Cyrus SASL library contains a lot of code. With this, Postfix
23becomes as secure as other mail systems that use the Cyrus SASL
24library.  Dovecot provides an alternative that may be worth
25considering. </p>
26
27<h2><a name="intro">How Postfix uses SASL authentication</a></h2>
28
29<p> SMTP servers need to decide whether an SMTP client is authorized
30to send mail to remote destinations, or only to destinations that
31the server itself is responsible for.  Usually, SMTP servers accept
32mail to remote destinations when the client's IP address is in the
33"same network" as the server's IP address.  </p>
34
35<p> SMTP clients outside the SMTP server's network need a different
36way to get "same network" privileges.  To address this need, Postfix
37supports SASL authentication (<a href="http://tools.ietf.org/html/rfc4954">RFC 4954</a>, formerly RFC 2554).  With
38this a remote SMTP client can authenticate to the Postfix SMTP
39server, and the Postfix SMTP client can authenticate to a remote
40SMTP server.  Once a client is authenticated, a server can give it
41"same network" privileges.  </p>
42
43<p> Postfix does not implement SASL itself, but instead uses existing
44implementations as building blocks.  This means that some SASL-related
45configuration files will belong to Postfix, while other
46configuration files belong to the specific SASL
47implementation that Postfix will use. This document covers both the
48Postfix and non-Postfix configuration.  </p>
49
50<p> You can read more about the following topics: </p>
51
52<ul>
53
54<li><a href="#server_sasl">Configuring SASL authentication in the
55Postfix SMTP server</a></li>
56
57<li><a href="#client_sasl">Configuring SASL authentication in the Postfix SMTP/LMTP client</a></li>
58
59<li><a href="#postfix_build">Building Postfix with SASL support</a></li>
60
61<li><a href="#cyrus_legacy">Using Cyrus SASL version 1.5.x</a></li>
62
63<li><a href="#credits">Credits</a></li>
64
65</ul>
66
67<h2><a name="server_sasl">Configuring SASL authentication in the
68Postfix SMTP server</a></h2>
69
70<p> As mentioned earlier, SASL is implemented separately from
71Postfix. For this reason, configuring SASL authentication in the
72Postfix SMTP server involves two different steps: </p>
73
74<ul>
75
76<li> <p> Configuring the SASL implementation to offer a list of
77mechanisms that are suitable for SASL authentication and, depending
78on the SASL implementation used, configuring authentication backends
79that verify the remote SMTP client's authentication data against
80the system password file or some other database.  </p> </li>
81
82<li> <p> Configuring the Postfix SMTP server to enable SASL
83authentication, and to authorize clients to relay mail or to control
84what envelope sender addresses the client may use. </p> </li>
85
86</ul>
87
88<p> Successful authentication in the Postfix SMTP server requires
89a functional SASL framework. Configuring SASL should therefore
90always be the first step, before configuring Postfix. </p>
91
92<p> You can read more about the following topics: </p>
93
94<ul>
95
96<li><a href="#server_which">Which SASL Implementations are
97supported?</a></li>
98
99<li><a href="#server_dovecot">Configuring Dovecot SASL</a>
100
101<ul>
102
103<li><a href="#server_dovecot_comm">Postfix to Dovecot SASL
104communication</a></li>
105
106</ul> </li>
107
108<li><a href="#server_cyrus">Configuring Cyrus SASL</a>
109
110<ul>
111
112<li><a href="#server_cyrus_name">Cyrus SASL configuration file
113name</a></li>
114
115<li><a href="#server_cyrus_location">Cyrus SASL configuration
116file location</a></li>
117
118<li><a href="#server_cyrus_comm">Postfix to Cyrus SASL
119communication</a></li>
120
121</ul> </li>
122
123<li><a href="#server_sasl_enable">Enabling SASL authentication and
124authorization in the Postfix SMTP server</a>
125
126<ul>
127
128<li><a href="#server_sasl_authc">Enabling SASL authentication in
129the Postfix SMTP server</a></li>
130
131<li><a href="#smtpd_sasl_security_options">Postfix SMTP Server
132policy - SASL mechanism properties</a></li>
133
134<li><a href="#server_sasl_authz">Enabling SASL authorization in the
135Postfix SMTP server</a></li>
136
137<li><a href="#server_sasl_other">Additional SMTP Server SASL
138options</a></li>
139
140</ul></li>
141
142<li><a href="#server_test">Testing SASL authentication in the Postfix
143SMTP server</a></li>
144
145</ul>
146
147
148<h3><a name="server_which">Which SASL Implementations are
149supported?</a></h3>
150
151<p> Currently the Postfix SMTP server supports the Cyrus SASL and
152Dovecot SASL implementations. </p>
153
154<blockquote>
155
156<strong>Note</strong>
157
158<p> Current Postfix versions have a plug-in architecture that can
159support multiple SASL implementations. Before Postfix version 2.3,
160Postfix had support only for Cyrus SASL.  </p>
161
162</blockquote>
163
164<p> To find out what SASL implementations are compiled into Postfix,
165use the following commands: </p>
166
167<blockquote>
168<pre>
169% <strong><code>postconf -a</code></strong> (SASL support in the SMTP server)
170% <strong><code>postconf -A</code></strong> (SASL support in the SMTP+LMTP client)
171</pre>
172</blockquote>
173
174<p> These commands are available only with Postfix version 2.3 and
175later. </p>
176
177<h3><a name="server_dovecot">Configuring Dovecot SASL</a></h3>
178
179<p> Dovecot is a POP/IMAP server that has its own configuration to
180authenticate POP/IMAP clients. When the Postfix SMTP server uses
181Dovecot SASL, it reuses parts of this configuration.  Consult the
182<a href="http://wiki.dovecot.org">Dovecot documentation</a> for how
183to configure and operate the Dovecot authentication server.  </p>
184
185<h4><a name="server_dovecot_comm">Postfix to Dovecot SASL communication</a></h4>
186
187<p> Communication between the Postfix SMTP server and Dovecot SASL
188happens over a UNIX-domain socket or over a TCP socket.  Dovecot 1
189supports UNIX-domain socket communication only. </p>
190
191<h5>UNIX-domain socket communication</h5>
192
193<p> The socket
194pathname and the list of mechanisms offered to Postfix need to be
195specified on the Dovecot server side in <code>dovecot.conf</code>.
196</p>
197
198<p> The following example assumes that the Postfix queue is under
199<code>/var/spool/postfix/</code>. </p>
200
201<blockquote>
202<pre>
203 1 /etc/dovecot.conf:
204 2     auth default {
205 3       mechanisms = plain login
206 4         passdb pam {
207 5         }
208 6         userdb passwd {
209 7         }
210 8         socket listen {
211 9         client {
21210           path = /var/spool/postfix/private/auth
21311           mode = 0660
21412           user = postfix
21513           group = postfix
21614         }
21715       }
21816     }
219</pre>
220</blockquote>
221
222<p> Line 3 provides <code>plain</code> and <code>login</code> as
223mechanisms for the Postfix SMTP server, line 10 places the Dovecot
224SASL socket in <code>/var/spool/postfix/private/auth</code>, and
225lines 11-13 limit read+write permissions to user and group
226<code>postfix</code> only. </p>
227
228<p> Proceed with the section "<a href="#server_sasl_enable">Enabling
229SASL authentication and authorization in the Postfix SMTP server</a>"
230to turn on and use SASL in the Postfix SMTP server.  </p>
231
232<h5>TCP socket communication</h5>
233
234<p> The TCP port and the list of mechanisms offered to Postfix need
235to be specified on the Dovecot server side in <code>10-auth.conf</code>
236and <code>10-master.conf</code>. </p>
237
238<p> The following examples assume that Postfix should communicate
239with Dovecot on TCP port 12345. </p>
240
241<blockquote>
242<pre>
2431 /etc/dovecot/conf.d/10-auth.conf:
2442     auth_mechanisms = plain login
245</pre>
246</blockquote>
247
248<p> Line 2 provides plain and login as mechanisms for the Postfix
249SMTP server. </p>
250
251<blockquote>
252<pre>
2531 /etc/dovecot/conf.d/10-master.conf:
2542     service auth {
2553       unix_listener auth-userdb {
2564       }
2575       inet_listener {
2586         port = 12345
2597       }
2608     }
261</pre>
262</blockquote>
263
264<p> Line 5 creates a new TCP socket and line 6 specifies port 12345
265where Dovecot SASL should wait for Postfix authentication requests.
266</p>
267
268<p> Proceed with the section "<a href="#server_sasl_enable">Enabling
269SASL authentication and authorization in the Postfix SMTP server</a>"
270to turn on and use SASL in the Postfix SMTP server.  </p>
271
272<h3><a name="server_cyrus">Configuring Cyrus SASL</a></h3>
273
274<p> The Cyrus SASL framework supports a wide variety of applications
275(POP, IMAP, SMTP, etc.).  Different applications may require different
276configurations. As a consequence each application may have its own
277configuration file.  </p>
278
279<p> The first step configuring Cyrus SASL is to determine name and
280location of a configuration file that describes how the Postfix
281SMTP server will use the SASL framework. </p>
282
283<h4><a name="server_cyrus_name">Cyrus SASL configuration file name</a></h4>
284
285<p> The name of the configuration file (default: <code>smtpd.conf</code>)
286is configurable. It is a concatenation from a value that the Postfix
287SMTP server sends to the Cyrus SASL library, and the suffix
288<code>.conf</code>, added by Cyrus SASL. </p>
289
290<p> The value sent by Postfix is the name of the server component
291that will use Cyrus SASL. It defaults to <code>smtpd</code> and
292is configured with one of the following variables: </p>
293
294<blockquote>
295<pre>
296/etc/postfix/<a href="postconf.5.html">main.cf</a>:
297    # Postfix 2.3 and later
298    <a href="postconf.5.html#smtpd_sasl_path">smtpd_sasl_path</a> = smtpd
299
300    # Postfix &lt; 2.3
301    <a href="postconf.5.html#smtpd_sasl_application_name">smtpd_sasl_application_name</a> = smtpd
302</pre>
303</blockquote>
304
305<h4><a name="server_cyrus_location">Cyrus SASL configuration file
306location</a></h4>
307
308<p> The location where Cyrus SASL searches for the named file depends
309on the Cyrus SASL version and the OS/distribution used. </p>
310
311<p> You can read more about the following topics: </p>
312
313<ul>
314
315<li> <p> Cyrus SASL version 2.x searches for the configuration file
316in <code>/usr/lib/sasl2/</code>. </p> </li>
317
318<li> <p> Cyrus SASL version 2.1.22 and newer additionally search
319in <code>/etc/sasl2/</code>. </p> </li>
320
321<li> <p> Some Postfix distributions are modified and look for the
322Cyrus SASL configuration file in <code>/etc/postfix/sasl/</code>,
323<code>/var/lib/sasl2/</code> etc. See the distribution-specific
324documentation to determine the expected location. </p> </li>
325
326</ul>
327
328<blockquote>
329
330<strong>Note</strong>
331
332<p> Cyrus SASL searches <code>/usr/lib/sasl2/</code> first. If it
333finds the specified configuration file there, it will not examine
334other locations. </p>
335
336</blockquote>
337
338<h4><a name="server_cyrus_comm">Postfix to Cyrus SASL communication</a></h4>
339
340<p> As the Postfix SMTP server is linked with the Cyrus SASL library
341<code>libsasl</code>, communication between Postfix and Cyrus SASL
342takes place by calling functions in the SASL library. </p>
343
344<p> The SASL library may use an external password verification
345service, or an internal plugin to connect to authentication backends
346and verify the SMTP client's authentication data against the system
347password file or other databases. </p>
348
349<p> The following table shows typical combinations discussed in
350this document: </p>
351
352<blockquote>
353
354<table border="1">
355
356<tr>
357
358<th align="center">authentication backend</th>
359
360<th align="center">password verification service / plugin</th>
361
362</tr>
363
364<tr>
365
366<td>/etc/shadow</td>
367
368<td><a href="#saslauthd">saslauthd</a></td>
369
370</tr>
371
372<tr>
373
374<td>PAM</td>
375
376<td><a href="#saslauthd">saslauthd</a></td>
377
378</tr>
379
380<tr>
381
382<td>IMAP server</td>
383
384<td><a href="#saslauthd">saslauthd</a></td>
385
386</tr>
387
388<tr>
389
390<td>sasldb</td>
391
392<td><a href="#auxprop_sasldb">sasldb</a></td>
393
394</tr>
395
396<tr>
397
398<td>MySQL, PostgreSQL, SQLite</td>
399
400<td><a href="#auxprop_sql">sql</a></td>
401
402</tr>
403
404<tr>
405
406<td>LDAP</td>
407
408<td><a href="#auxprop_ldapdb">ldapdb</a></td>
409
410</tr>
411
412</table>
413
414</blockquote>
415
416<blockquote>
417
418<strong>Note</strong>
419
420<p> Read the Cyrus SASL documentation for other backends it can
421use. </p>
422
423</blockquote>
424
425<h4><a name="saslauthd">saslauthd - Cyrus SASL password verification service</a></h4>
426
427<p> Communication between the Postfix SMTP server (read: Cyrus SASL's
428<code>libsasl</code>) and the <code>saslauthd</code> server takes
429place over a UNIX-domain socket. </p>
430
431<p> <code>saslauthd</code> usually establishes the UNIX domain
432socket in <code>/var/run/saslauthd/</code> and waits for authentication
433requests. The Postfix SMTP server must have read+execute permission
434to this directory or authentication attempts will fail. </p>
435
436<blockquote>
437
438<strong>Important</strong>
439
440<p> Some distributions require the user <code>postfix</code> to be
441member of a special group e.g.  <code>sasl</code>, otherwise it
442will not be able to access the <code>saslauthd</code> socket
443directory.  </p>
444
445</blockquote>
446
447<p> The following example configures the Cyrus SASL library to
448contact <code>saslauthd</code> as its password verification service:
449</p>
450
451<blockquote>
452<pre>
453/etc/sasl2/smtpd.conf:
454    pwcheck_method: saslauthd
455    mech_list: PLAIN LOGIN
456</pre>
457</blockquote>
458
459<blockquote>
460
461<strong>Important</strong>
462
463<p> Do not specify any other mechanisms in <code>mech_list</code>
464than <code>PLAIN</code> or <code>LOGIN</code> when using
465<code>saslauthd</code>!  It can only handle these two mechanisms,
466and authentication will fail if clients are allowed to choose other
467mechanisms. </p>
468
469</blockquote>
470
471<blockquote>
472
473<strong>Important</strong>
474
475<p> Plaintext mechanisms (<code>PLAIN</code>, <code>LOGIN</code>)
476send credentials unencrypted. This information should be protected
477by an additional security layer such as a TLS-encrypted SMTP session
478(see: <a href="TLS_README.html">TLS_README</a>). </p>
479
480</blockquote>
481
482<p> Additionally the <code>saslauthd</code> server itself must be
483configured. It must be told which authentication backend to turn
484to for password verification. The backend is selected with a
485<code>saslauthd</code> command-line option and will be shown in the
486following examples. </p>
487
488<blockquote>
489
490<strong>Note</strong>
491
492<p> Some distributions use a configuration file to provide saslauthd
493command line options to set e.g. the authentication backend. Typical
494locations are <code>/etc/sysconfig/saslauthd</code> or
495<code>/etc/default/saslauthd</code>. </p>
496
497</blockquote>
498
499<h4><a name="saslauthd_shadow">Using saslauthd with /etc/shadow</a></h4>
500
501<p> Access to the <code>/etc/shadow</code> system password file
502requires <code>root</code> privileges.  The Postfix SMTP server
503(and in consequence <code>libsasl</code> linked to the server) runs
504with the least privilege possible. Direct access to
505<code>/etc/shadow</code> would not be possible without breaking the
506Postfix security architecture.  </p>
507
508<p> The <code>saslauthd</code> socket builds a safe bridge. Postfix,
509running as limited user <code>postfix</code>, can access the
510UNIX-domain socket that <code>saslauthd</code> receives commands
511on; <code>saslauthd</code>, running as privileged user <code>root</code>,
512has the privileges required to access the shadow file. </p>
513
514<p> The <code>saslauthd</code> server verifies passwords against the
515authentication backend <code>/etc/shadow</code> if started like this: </p>
516
517<blockquote>
518<pre>
519% <strong><code>saslauthd -a shadow</code></strong>
520</pre>
521</blockquote>
522
523<p> See section "<a href="#testing_saslauthd">Testing saslauthd
524authentication</a>" for test instructions. </p>
525
526<h4><a name="saslauthd_pam">Using saslauthd with PAM</a></h4>
527
528<p> Cyrus SASL can use the PAM framework to authenticate credentials.
529<code>saslauthd</code> uses the PAM framework when started like
530this: </p>
531
532<blockquote>
533<pre>
534% <strong><code>saslauthd -a pam</code></strong>
535</pre>
536</blockquote>
537
538<blockquote>
539
540<strong>Note</strong>
541
542<p> PAM configuration for the Postfix SMTP server is usually given
543in <code>/etc/pam.d/smtp</code> and is beyond the scope of this
544document. </p>
545
546</blockquote>
547
548<p> See section "<a href="#testing_saslauthd">Testing saslauthd
549authentication</a>" for test instructions. </p>
550
551<h4><a name="saslauthd_imap">Using saslauthd with an IMAP server</a></h4>
552
553<p> <code>saslauthd</code> can verify the SMTP client credentials
554by using them to log into an IMAP server.  If the login succeeds,
555SASL authentication also succeeds. <code>saslauthd</code> contacts
556an IMAP server when started like this: </p>
557
558<blockquote>
559<pre>
560% <strong><code>saslauthd -a rimap -O imap.example.com</code></strong>
561</pre>
562</blockquote>
563
564<blockquote>
565
566<strong>Note</strong>
567
568<p> The option "<code>-O imap.example.com</code>" specifies the
569IMAP server <code>saslauthd</code> should contact when it verifies
570credentials. </p>
571
572</blockquote>
573
574<blockquote>
575
576<strong>Important</strong>
577
578<p> <code>saslauthd</code> sends IMAP login information unencrypted.
579Any IMAP session leaving the local host should be protected by an
580additional security layer such as an SSL tunnel. </p>
581
582</blockquote>
583
584<p> See section "<a href="#testing_saslauthd">Testing saslauthd
585authentication</a>" for test instructions. </p>
586
587<h4><a name="testing_saslauthd">Testing saslauthd authentication</a></h4>
588
589<p> Cyrus SASL provides the <code>testsaslauthd</code> utility to
590test <code>saslauthd</code> authentication. The username and password
591are given as command line arguments. The example shows the response
592when authentication is successful: </p>
593
594<blockquote>
595<pre>
596% <strong><code>testsaslauthd -u <em>username</em> -p <em>password</em></code></strong>
5970: OK "Success."
598</pre>
599</blockquote>
600
601<blockquote>
602
603<strong>Note</strong>
604
605<p> Sometimes the <code>testsaslauthd</code> program is not distributed
606with a the Cyrus SASL main package.  In that case, it may be
607distributed with <code>-devel</code>, <code>-dev</code> or
608<code>-debug</code> packages. </p>
609
610</blockquote>
611
612<p> Specify an additional "<code>-s smtp</code>" if <code>saslauthd</code>
613was configured to contact the PAM authentication framework, and
614specify an additional "<code>-f <em>/path/to/socketdir/mux</em></code>"
615if <code>saslauthd</code> establishes the UNIX-domain socket in a
616non-default location. </p>
617
618<p> If authentication succeeds, proceed with the section "<a
619href="#server_sasl_enable">Enabling SASL authentication and authorization
620in the Postfix SMTP server</a>". </p>
621
622<h4><a name="auxprop">Cyrus SASL Plugins - auxiliary property
623plugins</a></h4>
624
625<p> Cyrus SASL uses a plugin infrastructure (called <code>auxprop</code>)
626to expand <code>libsasl</code>'s capabilities.  Currently Cyrus
627SASL sources provide three authentication plugins. </p>
628
629<blockquote>
630
631<table border="1">
632
633<tr> <th>Plugin </th> <th>Description </th> </tr>
634
635<tr> <td><a href="#auxprop_sasldb">sasldb</a></td> <td> Accounts
636are stored stored in a Cyrus SASL Berkeley DB database </td> </tr>
637
638<tr> <td><a href="#auxprop_sql">sql</a></td> <td> Accounts are
639stored in a SQL database </td> </tr>
640
641<tr> <td><a href="#auxprop_ldapdb">ldapdb</a></td> <td> Accounts
642are stored stored in an LDAP database </td> </tr>
643
644</table>
645
646</blockquote>
647
648<blockquote>
649
650<strong>Important</strong>
651
652<p> These three plugins support shared-secret mechanisms i.e.
653CRAM-MD5, DIGEST-MD5 and NTLM. These mechanisms send credentials
654encrypted but their verification process requires the password to
655be available in plaintext.  Consequently passwords cannot (!) be
656stored in encrypted form. </p>
657
658</blockquote>
659
660<h4><a name="auxprop_sasldb">The sasldb plugin</a></h4>
661
662<p> The sasldb auxprop plugin authenticates SASL clients against
663credentials that are stored in a Berkeley DB database. The database
664schema is specific to Cyrus SASL.  The database is usually located
665at <code>/etc/sasldb2</code>. </p>
666
667<blockquote>
668
669<strong>Note</strong>
670
671<p> The <code>sasldb2</code> file contains passwords in
672plaintext, and should have read+write access only to user
673<code>postfix</code> or a group that <code>postfix</code> is member
674of. </p>
675
676</blockquote>
677
678<p> The <code>saslpasswd2</code> command-line utility creates
679and maintains the database: </p>
680
681<blockquote>
682<pre>
683% <strong>saslpasswd2 -c -u <em>example.com</em> <em>username</em></strong>
684Password:
685Again (for verification):
686</pre>
687</blockquote>
688
689<p> This command creates an account
690<code><em>username@example.com</em></code>.  </p>
691
692<blockquote>
693
694<strong>Important</strong>
695
696<p> users must specify <code><em>username@example.com</em></code>
697as login name, not <code><em>username</em></code>. </p>
698
699</blockquote>
700
701<p> Run the following command to reuse the Postfix <code><a href="postconf.5.html#mydomain">mydomain</a></code>
702parameter value as the login domain: </p>
703
704<blockquote>
705<pre>
706% <strong>saslpasswd2 -c -u `postconf -h <a href="postconf.5.html#mydomain">mydomain</a>` <em>username</em></strong>
707Password:
708Again (for verification):
709</pre>
710</blockquote>
711
712<blockquote>
713
714<strong>Note</strong>
715
716<p> Run <code>saslpasswd2</code> without any options for further
717help on how to use the command. </p>
718
719</blockquote>
720
721<p> The <code>sasldblistusers2</code> command lists all existing
722users in the sasldb database: </p>
723
724<blockquote>
725<pre>
726% <strong>sasldblistusers2</strong>
727username1@example.com: password1
728username2@example.com: password2
729</pre>
730</blockquote>
731
732<p> Configure libsasl to use sasldb with the following instructions: </p>
733
734<blockquote>
735<pre>
736/etc/sasl2/smtpd.conf:
737    pwcheck_method: auxprop
738    auxprop_plugin: sasldb
739    mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5 NTLM
740</pre>
741</blockquote>
742
743<blockquote>
744
745<strong>Note</strong>
746
747<p> In the above example adjust <code>mech_list</code> to the
748mechanisms that are applicable for your environment. </p>
749
750</blockquote>
751
752<h4><a name="auxprop_sql">The sql plugin</a></h4>
753
754<p> The sql auxprop plugin is a generic SQL plugin. It provides
755access to credentials stored in a MySQL, PostgreSQL or SQLite
756database. This plugin requires that SASL client passwords are
757stored as plaintext. </p>
758
759<blockquote>
760
761<strong>Tip</strong>
762
763<p> If you must store encrypted passwords, you cannot use the sql
764auxprop plugin. Instead, see section "<a href="#saslauthd_pam">Using
765saslauthd with PAM</a>", and configure PAM to look up the encrypted
766passwords with, for example, the <code>pam_mysql</code> module.
767You will not be able to use any of the methods that require access
768to plaintext passwords, such as the shared-secret methods CRAM-MD5
769and DIGEST-MD5.  </p>
770
771</blockquote>
772
773<p> The following example configures libsasl to use the sql plugin
774and connects it to a PostgreSQL server: </p>
775
776<blockquote>
777<pre>
778/etc/sasl2/smtpd.conf:
779    pwcheck_method: auxprop
780    auxprop_plugin: sql
781    mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5 NTLM
782    sql_engine: pgsql
783    sql_hostnames: 127.0.0.1, 192.0.2.1
784    sql_user: username
785    sql_passwd: secret
786    sql_database: dbname
787    sql_select: SELECT password FROM users WHERE user = '%u@%r'
788</pre>
789</blockquote>
790
791<blockquote>
792
793<strong>Note</strong>
794
795<p> Set appropriate permissions if <code>smtpd.conf</code> contains
796a password. The file should be readable by the <code>postfix</code>
797user. </p>
798
799</blockquote>
800
801<blockquote>
802
803<strong>Note</strong>
804
805<p> In the above example, adjust <code>mech_list</code> to the
806mechanisms that are applicable for your environment. </p>
807
808</blockquote>
809
810<p> The sql plugin has the following configuration options: </p>
811
812<blockquote>
813
814<dl>
815
816<dt>sql_engine</dt>
817
818<dd>
819
820<p> Specify <code>mysql</code> to connect to a MySQL server,
821<code>pgsql</code> for a PostgreSQL server or <code>sqlite</code>
822for an SQLite database </p>
823
824</dd>
825
826<dt>sql_hostnames</dt>
827
828<dd>
829
830<p> Specify one or more servers (hostname or hostname:port) separated
831by commas. </p>
832
833<blockquote>
834
835<strong>Note</strong>
836
837<p> With MySQL servers, specify <code>localhost</code> to connect
838over a UNIX-domain socket, and specify <code>127.0.0.1</code> to
839connect over a TCP socket.  </p>
840
841</blockquote>
842
843</dd>
844
845<dt>sql_user</dt>
846
847<dd>
848
849<p> The login name to gain access to the database. </p>
850
851</dd>
852
853<dt>sql_passwd</dt>
854
855<dd>
856
857<p> The password to gain access to the database. </p>
858
859</dd>
860
861<dt>sql_database</dt>
862
863<dd>
864
865<p> The name of the database to connect to. </p>
866
867</dd>
868
869<dt>sql_select</dt>
870
871<dd>
872
873<p> The SELECT statement that should retrieve the plaintext password
874from a database table. </p>
875
876<blockquote>
877
878<strong>Important</strong>
879
880<p> Do not enclose the statement in quotes! Use single quotes to
881escape macros! </p>
882
883</blockquote>
884
885</dd>
886
887</dl>
888
889</blockquote>
890
891<p> The sql plugin provides macros to build <code>sql_select</code>
892statements. They will be replaced with arguments sent from the client. The
893following macros are available: </p>
894
895<blockquote>
896
897<dl>
898
899<dt>%u</dt>
900
901<dd>
902
903<p> The name of the user whose properties are being selected. </p>
904
905</dd>
906
907<dt>%p</dt>
908
909<dd>
910
911<p> The name of the property being selected. While this could technically be
912anything, Cyrus SASL will try userPassword and cmusaslsecretMECHNAME (where
913MECHNAME is the name of a SASL mechanism). </p>
914
915</dd>
916
917<dt>%r</dt>
918
919<dd>
920
921<p> The name of the realm to which the user belongs. This could be
922the KERBEROS realm, the fully-qualified domain name of the computer
923the SASL application is running on, or the domain after the "@" in a
924username. </p>
925
926</dd>
927
928</dl>
929
930</blockquote>
931
932<h4><a name="auxprop_ldapdb">The ldapdb plugin</a></h4>
933
934<p> The ldapdb auxprop plugin provides access to credentials stored
935in an LDAP server. This plugin requires that SASL client passwords are
936stored as plaintext. </p>
937
938<blockquote>
939
940<strong>Tip</strong>
941
942<p> If you must store encrypted passwords, you cannot use the ldapdb
943auxprop plugin. Instead, you can use "<code>saslauthd -a ldap</code>"
944to query the LDAP database directly, with appropriate configuration
945in <code>saslauthd.conf</code>. This may be documented in a later
946version of this document.  You will not be able to use any of the
947methods that require access to plaintext passwords, such as the
948shared-secret methods CRAM-MD5 and DIGEST-MD5.  </p>
949
950</blockquote>
951
952<p> The ldapdb plugin implements proxy authorization. This means
953that the ldapdb plugin uses its own username and password to
954authenticate with the LDAP server, before it asks the LDAP server
955for the remote SMTP client's password.  The LDAP server then decides
956if the ldapdb plugin is authorized to read the remote SMTP client's
957password.  </p>
958
959<p> In a nutshell: Configuring ldapdb means authentication and
960authorization must be configured twice - once in the Postfix SMTP
961server to authenticate and authorize the remote SMTP client, and
962once in the LDAP server to authenticate and authorize the ldapdb
963plugin. </p>
964
965<p> This example configures libsasl to use the ldapdb plugin and
966the plugin to connect to an LDAP server: </p>
967
968<blockquote>
969<pre>
970/etc/sasl2/smtpd.conf:
971    pwcheck_method: auxprop
972    auxprop_plugin: ldapdb
973    mech_list: PLAIN LOGIN NTLM CRAM-MD5 DIGEST-MD5
974    ldapdb_uri: <a href="ldap_table.5.html">ldap</a>://localhost
975    ldapdb_id: proxyuser
976    ldapdb_pw: password
977    ldapdb_mech: DIGEST-MD5
978</pre>
979</blockquote>
980
981<blockquote>
982
983<strong>Important</strong>
984
985<p> Set appropriate permissions if <code>smtpd.conf</code> contains a
986password. The file should be readable by the <code>postfix</code>
987user. </p>
988
989</blockquote>
990
991<blockquote>
992
993<strong>Note</strong>
994
995<p> The shared-secret mechanisms (CRAM-MD5, etc.) require that the
996SASL client passwords are stored as plaintext.  </p>
997
998</blockquote>
999
1000<p> The following is a summary of applicable <code>smtpd.conf</code>
1001file entries: </p>
1002
1003<blockquote>
1004
1005<dl>
1006
1007<dt>auxprop_plugin</dt>
1008
1009<dd> <p> Specify <code>ldapdb</code> to enable the plugin. </p> </dd>
1010
1011<dt>ldapdb_uri</dt>
1012
1013<dd> <p> Specify either <code>ldapi://</code> for to connect over
1014a UNIX-domain socket, <code><a href="ldap_table.5.html">ldap</a>://</code> for an unencrypted TCP
1015connection or <code>ldaps://</code> for an encrypted TCP connection.
1016</p> </dd>
1017
1018<dt>ldapdb_id</dt>
1019
1020<dd> <p> The login name to authenticate the ldapdb plugin to the
1021LDAP server (proxy authorization). </p> </dd>
1022
1023<dt>ldapdb_pw</dt>
1024
1025<dd> <p> The password (in plaintext) to authenticate the ldapdb
1026plugin to the LDAP server (proxy authorization). </p> </dd>
1027
1028<dt>ldapdb_mech</dt>
1029
1030<dd> <p> The mechanism to authenticate the ldapdb plugin to the
1031LDAP server. </p>
1032
1033<blockquote>
1034
1035<strong>Note</strong>
1036
1037<p> Specify a mechanism here that is supported by the LDAP server.
1038</p>
1039
1040</blockquote>
1041
1042</dd>
1043
1044<dt>ldapdb_rc (optional)</dt>
1045
1046<dd> <p> The path to a file containing individual configuration
1047options for the ldapdb LDAP client (libldap).  This allows to specify
1048a TLS client certificate which in turn can be used to use the SASL
1049EXTERNAL mechanism. </p>
1050
1051<blockquote>
1052
1053<strong>Note</strong>
1054
1055<p> This mechanism supports authentication over an encrypted transport
1056layer, which is recommended if the plugin must connect to an OpenLDAP
1057server on a remote machine. </p>
1058
1059</blockquote>
1060
1061</dd>
1062
1063<dt>ldapdb_starttls (optional)</dt>
1064
1065<dd> <p> The TLS policy for connecting to the LDAP server. Specify
1066either <code>try</code> or <code>demand</code>. If the option is
1067<code>try</code> the plugin will attempt to establish a TLS-encrypted
1068connection with the LDAP server, and will fallback to an unencrypted
1069connection if TLS fails. If the policy is <code>demand</code> and
1070a TLS-encrypted connection cannot be established, the connection
1071fails immediately.  </p> </dd>
1072
1073</dl>
1074
1075</blockquote>
1076
1077<p> When the ldapdb plugin connects to the OpenLDAP server and
1078successfully authenticates, the OpenLDAP server decides if the
1079plugin user is authorized to read SASL account information.  </p>
1080
1081<p> The following configuration gives an example of authorization configuration
1082in the OpenLDAP slapd server: </p>
1083
1084<blockquote>
1085<pre>
1086/etc/openldap/slapd.conf:
1087    authz-regexp
1088    uid=(.*),cn=.*,cn=auth
1089    <a href="ldap_table.5.html">ldap</a>:///dc=example,dc=com??sub?cn=$1
1090    authz-policy to
1091</pre>
1092</blockquote>
1093
1094<p> Here, the <code>authz-regexp</code> option serves for authentication
1095of the ldapdb user. It maps its login name to a DN in the LDAP
1096directory tree where <code>slapd</code> can look up the SASL account
1097information. The <code>authz-policy</code> options defines the
1098authentication policy. In this case it grants authentication
1099privileges "<code>to</code>" the ldapdb plugin. </p>
1100
1101<p> The last configuration step is to tell the OpenLDAP <code>slapd</code>
1102server where ldapdb may search for usernames matching the one given
1103by the mail client. The example below adds an additional attribute
1104ldapdb user object (here: <code>authzTo</code> because the authz-policy
1105is "<code>to</code>") and configures the scope where the login name
1106"proxyuser" may search: </p>
1107
1108<blockquote>
1109<pre>
1110dn: cn=proxyuser,dc=example,dc=com
1111changetype: modify
1112add: authzTo
1113authzTo: dn.regex:uniqueIdentifier=(.*),ou=people,dc=example,dc=com
1114</pre>
1115</blockquote>
1116
1117<p> Use the <code>ldapmodify</code> or <code>ldapadd</code> command
1118to add the above attribute. </p>
1119
1120<blockquote>
1121
1122<strong>Note</strong>
1123
1124<p> Read the chapter "Using SASL" in the <a
1125href="http://www.openldap.org/doc/admin">OpenLDAP Admin Guide</a>
1126for more detailed instructions to set up SASL authentication in
1127OpenLDAP. </p>
1128
1129</blockquote>
1130
1131<h3><a name="server_sasl_enable">Enabling SASL authentication and
1132authorization in the Postfix SMTP server</a></h3>
1133
1134<p> By default the Postfix SMTP server uses the Cyrus SASL
1135implementation.  If the Dovecot SASL implementation should be used,
1136specify an <code><a href="postconf.5.html#smtpd_sasl_type">smtpd_sasl_type</a></code> value of <code>dovecot</code>
1137instead of <code>cyrus</code>: </p>
1138
1139<blockquote>
1140<pre>
1141/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1142    <a href="postconf.5.html#smtpd_sasl_type">smtpd_sasl_type</a> = dovecot
1143</pre>
1144</blockquote>
1145
1146<p> Additionally specify how Postfix SMTP server can find the Dovecot
1147authentication server. This depends on the settings that you have
1148selected in the section "<a href="#server_dovecot_comm">Postfix to
1149Dovecot SASL communication</a>". </p>
1150
1151<ul>
1152
1153<li> <p> If you configured Dovecot for UNIX-domain socket communication,
1154configure Postfix as follows: </p>
1155
1156<pre>
1157/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1158    <a href="postconf.5.html#smtpd_sasl_path">smtpd_sasl_path</a> = private/auth
1159</pre>
1160
1161<strong>Note</strong>
1162
1163<p> This example uses a pathname relative to the Postfix queue
1164directory, so that it will work whether or not the Postfix SMTP
1165server runs chrooted. </p>
1166
1167<li> <p> If you configured Dovecot for TCP socket communication,
1168configure Postfix as follows. If Dovecot runs on a different machine,
1169replace 127.0.0.1 by that machine's IP address. </p>
1170
1171<pre>
1172/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1173    <a href="postconf.5.html#smtpd_sasl_path">smtpd_sasl_path</a> = inet:127.0.0.1:12345
1174</pre>
1175
1176<strong>Note</strong>
1177
1178<p> If you specify a remote IP address, information
1179will be sent as plaintext over the network. </p>
1180
1181</ul>
1182
1183<h4><a name="server_sasl_authc">Enabling SASL authentication
1184in the Postfix SMTP server</a></h4>
1185
1186<p> Regardless of the SASL implementation type, enabling SMTP
1187authentication in the Postfix SMTP server always requires setting
1188the <code><a href="postconf.5.html#smtpd_sasl_auth_enable">smtpd_sasl_auth_enable</a></code> option: </p>
1189
1190<blockquote>
1191<pre>
1192/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1193    <a href="postconf.5.html#smtpd_sasl_auth_enable">smtpd_sasl_auth_enable</a> = yes
1194</pre>
1195</blockquote>
1196
1197<p> After a "postfix reload", SMTP clients will see the additional
1198capability AUTH in an SMTP session, followed by a list of
1199authentication mechanisms the server supports: </p>
1200
1201<blockquote>
1202<pre>
1203% <strong>telnet server.example.com 25</strong>
1204...
1205220 server.example.com ESMTP Postfix
1206<strong>EHLO client.example.com</strong>
1207250-server.example.com
1208250-PIPELINING
1209250-SIZE 10240000
1210250-AUTH DIGEST-MD5 PLAIN CRAM-MD5
1211...
1212</pre>
1213</blockquote>
1214
1215<p> However not all clients recognize the AUTH capability as defined
1216by the SASL authentication RFC. Some historical implementations expect the
1217server to send an "<code>=</code>" as separator between the AUTH
1218verb and the list of mechanisms that follows it.  </p>
1219
1220<p> The <code><a href="postconf.5.html#broken_sasl_auth_clients">broken_sasl_auth_clients</a></code> configuration option
1221lets Postfix repeat the AUTH statement in a form that these broken
1222clients understand: </p>
1223
1224<blockquote>
1225<pre>
1226/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1227    <a href="postconf.5.html#broken_sasl_auth_clients">broken_sasl_auth_clients</a> = yes
1228</pre>
1229</blockquote>
1230
1231<blockquote>
1232
1233<strong>Note</strong>
1234
1235<p> Enable this option for Outlook up to and including version 2003
1236and Outlook Express up to version 6. This option does not hurt other
1237clients. </p>
1238
1239</blockquote>
1240
1241<p> After "postfix reload", the Postfix SMTP server will propagate
1242the AUTH capability twice - once for compliant and once for broken
1243clients: </p>
1244
1245<blockquote>
1246<pre>
1247% <strong>telnet server.example.com 25</strong>
1248...
1249220 server.example.com ESMTP Postfix
1250<strong>EHLO client.example.com</strong>
1251250-server.example.com
1252250-PIPELINING
1253250-SIZE 10240000
1254250-AUTH DIGEST-MD5 PLAIN CRAM-MD5
1255250-AUTH=DIGEST-MD5 PLAIN CRAM-MD5
1256...
1257</pre>
1258</blockquote>
1259
1260<h4><a name="smtpd_sasl_security_options">Postfix SMTP Server policy
1261- SASL mechanism properties</a></h4>
1262
1263<p> The Postfix SMTP server supports policies that limit the SASL
1264mechanisms that it makes available to clients, based on the properties
1265of those mechanisms.  The next two sections give examples of how
1266these policies are used. </p>
1267
1268<blockquote>
1269
1270<table border="1">
1271
1272<tr> <th>Property</th> <th>Description</th> </tr>
1273
1274<tr> <td>noanonymous</td> <td> Don't use mechanisms that permit
1275anonymous authentication.  </td> </tr>
1276
1277<tr> <td>noplaintext</td> <td> Don't use mechanisms that transmit
1278unencrypted username and password information.  </td> </tr>
1279
1280<tr> <td>nodictionary</td> <td> Don't use mechanisms that are
1281vulnerable to dictionary attacks. </td> </tr>
1282
1283<tr> <td>forward_secrecy</td> <td> Require forward secrecy between
1284sessions (breaking one session does not break earlier sessions).
1285</td> </tr>
1286
1287<tr> <td>mutual_auth</td> <td> Use only mechanisms that authenticate
1288both the client and the server to each other. </td> </tr>
1289
1290</table>
1291
1292</blockquote>
1293
1294<h4><a name="id396877">Unencrypted SMTP session</a></h4>
1295
1296<p> The default policy is to allow any mechanism in the Postfix SMTP server
1297except for those based on anonymous authentication: </p>
1298
1299<blockquote>
1300<pre>
1301/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1302    # Specify a list of properties separated by comma or whitespace
1303    <a href="postconf.5.html#smtpd_sasl_security_options">smtpd_sasl_security_options</a> = noanonymous
1304</pre>
1305</blockquote>
1306
1307<blockquote>
1308
1309<strong>Important</strong>
1310
1311<p> Always set at least the <code>noanonymous</code> option.
1312Otherwise, the Postfix SMTP server can give strangers the same
1313authorization as a properly-authenticated client. </p>
1314
1315</blockquote>
1316
1317<h4><a name="id396969">Encrypted SMTP session (TLS)</a></h4>
1318
1319<p> A separate parameter controls Postfix SASL mechanism policy
1320during a TLS-encrypted SMTP session. The default is to copy the
1321settings from the unencrypted session: </p>
1322
1323<blockquote>
1324<pre>
1325/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1326    <a href="postconf.5.html#smtpd_sasl_tls_security_options">smtpd_sasl_tls_security_options</a> = $<a href="postconf.5.html#smtpd_sasl_security_options">smtpd_sasl_security_options</a>
1327</pre>
1328</blockquote>
1329
1330<p> A more sophisticated policy allows plaintext mechanisms, but
1331only over a TLS-encrypted connection: </p>
1332
1333<blockquote>
1334<pre>
1335/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1336    <a href="postconf.5.html#smtpd_sasl_security_options">smtpd_sasl_security_options</a> = noanonymous, noplaintext
1337    <a href="postconf.5.html#smtpd_sasl_tls_security_options">smtpd_sasl_tls_security_options</a> = noanonymous
1338</pre>
1339</blockquote>
1340
1341<p> To offer SASL authentication only after a TLS-encrypted session has been
1342established specify this: </p>
1343
1344<blockquote>
1345<pre>
1346/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1347    <a href="postconf.5.html#smtpd_tls_auth_only">smtpd_tls_auth_only</a> = yes
1348</pre>
1349</blockquote>
1350
1351<h4><a name="server_sasl_authz">Enabling SASL authorization in the Postfix
1352SMTP server</a></h4>
1353
1354<p> After the client has authenticated with SASL, the Postfix SMTP
1355server decides what the remote SMTP client will be authorized
1356for. Examples of possible SMTP clients authorizations are: </p>
1357
1358<ul>
1359
1360<li> <p> Send a message to a remote recipient. </p> </li>
1361
1362<li> <p> Use a specific envelope sender in the MAIL FROM command. </p> </li>
1363
1364</ul>
1365
1366<p> These permissions are not enabled by default. </p>
1367
1368<h4><a name="server_sasl_authz_relay">Mail relay authorization</a></h4>
1369
1370<p> With <code><a href="postconf.5.html#permit_sasl_authenticated">permit_sasl_authenticated</a></code> the Postfix SMTP
1371server can allow
1372SASL-authenticated SMTP clients to send mail to remote destinations.
1373Examples:
1374</p>
1375
1376<blockquote>
1377<pre>
1378# With Postfix 2.10 and later, the mail relay policy is
1379# preferably specified under <a href="postconf.5.html#smtpd_relay_restrictions">smtpd_relay_restrictions</a>.
1380/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1381    <a href="postconf.5.html#smtpd_relay_restrictions">smtpd_relay_restrictions</a> =
1382	<a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a>
1383	<strong><a href="postconf.5.html#permit_sasl_authenticated">permit_sasl_authenticated</a></strong>
1384	<a href="postconf.5.html#reject_unauth_destination">reject_unauth_destination</a>
1385</pre>
1386
1387<pre>
1388# Older configurations combine relay control and spam control under
1389# <a href="postconf.5.html#smtpd_recipient_restrictions">smtpd_recipient_restrictions</a>. To use this example with Postfix &ge;
1390# 2.10 specify "<a href="postconf.5.html#smtpd_relay_restrictions">smtpd_relay_restrictions</a>=".
1391/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1392    <a href="postconf.5.html#smtpd_recipient_restrictions">smtpd_recipient_restrictions</a> =
1393	<a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a>
1394	<strong><a href="postconf.5.html#permit_sasl_authenticated">permit_sasl_authenticated</a></strong>
1395	<a href="postconf.5.html#reject_unauth_destination">reject_unauth_destination</a>
1396	...other rules...
1397</pre>
1398</blockquote>
1399
1400<h4><a name="server_sasl_authz_envelope">Envelope sender address
1401authorization</a></h4>
1402
1403<p> By default an SMTP client may specify any envelope sender address
1404in the MAIL FROM command.  That is because the Postfix SMTP server
1405only knows the remote SMTP client hostname and IP address, but not
1406the user who controls the remote SMTP client.  </p>
1407
1408<p> This changes the moment an SMTP client uses SASL authentication.
1409Now, the Postfix SMTP server knows who the sender is. Given a table
1410of envelope sender addresses and SASL login names, the Postfix SMTP
1411server can decide if the SASL authenticated client is allowed to
1412use a particular envelope sender address: </p>
1413
1414<blockquote>
1415<pre>
1416/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1417    <strong><a href="postconf.5.html#smtpd_sender_login_maps">smtpd_sender_login_maps</a> = hash:/etc/postfix/controlled_envelope_senders</strong>
1418
1419    <a href="postconf.5.html#smtpd_recipient_restrictions">smtpd_recipient_restrictions</a> =
1420        ...
1421        <strong><a href="postconf.5.html#reject_sender_login_mismatch">reject_sender_login_mismatch</a></strong>
1422	<a href="postconf.5.html#permit_sasl_authenticated">permit_sasl_authenticated</a>
1423        ...
1424</pre>
1425</blockquote>
1426
1427<p> The <code>controlled_envelope_senders</code> table specifies
1428the binding between a sender envelope address and the SASL login
1429names that own that address: </p>
1430
1431<blockquote>
1432<pre>
1433/etc/postfix/controlled_envelope_senders
1434    # envelope sender           owners (SASL login names)
1435    john@example.com            john@example.com
1436    helpdesk@example.com        john@example.com, mary@example.com
1437    postmaster                  admin@example.com
1438    @example.net                barney, fred, john@example.com, mary@example.com
1439</pre>
1440</blockquote>
1441
1442<p> With this, the <code><a href="postconf.5.html#reject_sender_login_mismatch">reject_sender_login_mismatch</a></code>
1443restriction above will reject the sender address in the MAIL FROM
1444command if <code><a href="postconf.5.html#smtpd_sender_login_maps">smtpd_sender_login_maps</a></code> does not specify
1445the SMTP client's login name as an owner of that address. </p>
1446
1447<p> See also <code><a href="postconf.5.html#reject_authenticated_sender_login_mismatch">reject_authenticated_sender_login_mismatch</a></code> and
1448<code><a href="postconf.5.html#reject_unauthenticated_sender_login_mismatch">reject_unauthenticated_sender_login_mismatch</a></code> for additional
1449control over the SASL login name and the envelope sender. </p>
1450
1451<h4><a name="server_sasl_other">Additional SMTP Server SASL options</a></h4>
1452
1453<p> Postfix provides a wide range of SASL authentication configuration
1454options.  The next section lists a few that are discussed frequently.
1455See <a href="postconf.5.html">postconf(5)</a> for a complete list. </p>
1456
1457<h4><a name="id397172">Default  authentication domain</a></h4>
1458
1459<p> Postfix can append a domain name (or any other string) to a
1460SASL login name that does not have a domain part, e.g.  "<code>john</code>"
1461instead of "<code>john@example.com</code>": </p>
1462
1463<blockquote>
1464<pre>
1465/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1466    <a href="postconf.5.html#smtpd_sasl_local_domain">smtpd_sasl_local_domain</a> = example.com
1467</pre>
1468</blockquote>
1469
1470<p> This is useful as a default setting and safety net for misconfigured
1471clients, or during a migration to an authentication method/backend
1472that requires an authentication REALM or domain name, before all
1473SMTP clients are configured to send such information. </p>
1474
1475<h4><a name="id397205">Hiding SASL authentication from clients or
1476networks</a></h4>
1477
1478<p> Some clients insist on using SASL authentication if it is offered, even
1479when they are not configured to send credentials - and therefore
1480they will always fail and disconnect.  </p>
1481
1482<p> Postfix can hide the AUTH capability from these clients/networks: </p>
1483
1484<blockquote>
1485<pre>
1486/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1487    <a href="postconf.5.html#smtpd_sasl_exceptions_networks">smtpd_sasl_exceptions_networks</a> = !192.0.2.171/32, 192.0.2.0/24
1488</pre>
1489</blockquote>
1490
1491<h4><a name="id397226">Adding the SASL login name to mail headers</a></h4>
1492
1493<p> To report SASL login names in Received: message headers (Postfix
1494version 2.3 and later): </p>
1495
1496<blockquote>
1497<pre>
1498/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1499    <a href="postconf.5.html#smtpd_sasl_authenticated_header">smtpd_sasl_authenticated_header</a> = yes
1500</pre>
1501</blockquote>
1502
1503<blockquote>
1504
1505<strong>Note</strong>
1506
1507<p> The SASL login names will be shared with the entire world. </p>
1508
1509</blockquote>
1510
1511<h3><a name="server_test">Testing SASL authentication in the Postfix SMTP Server</a></h3>
1512
1513<p> To test the server side, connect (for example, with
1514<code>telnet</code>) to the Postfix SMTP server port and you should
1515be able to have a conversation as shown below. Information sent by
1516the client (that is, you) is shown in <strong>bold</strong> font.
1517</p>
1518
1519<blockquote>
1520<pre>
1521% <strong>telnet server.example.com 25</strong>
1522...
1523220 server.example.com ESMTP Postfix
1524<strong>EHLO client.example.com</strong>
1525250-server.example.com
1526250-PIPELINING
1527250-SIZE 10240000
1528250-ETRN
1529250-AUTH DIGEST-MD5 PLAIN CRAM-MD5
1530250 8BITMIME
1531<strong>AUTH PLAIN AHRlc3QAdGVzdHBhc3M=</strong>
1532235 Authentication successful
1533</pre>
1534</blockquote>
1535
1536<p> To test this over a connection that is encrypted with TLS, use
1537<code>openssl s_client</code> instead of <code>telnet</code>:
1538
1539<blockquote>
1540<pre>
1541% <strong>openssl s_client -connect server.example.com:25 -starttls smtp</strong>
1542...
1543220 server.example.com ESMTP Postfix
1544<strong>EHLO client.example.com</strong>
1545...see above example for more...
1546</pre>
1547</blockquote>
1548
1549<p> Instead of <code>AHRlc3QAdGVzdHBhc3M=</code>, specify the
1550base64-encoded form of <code>\0username\0password</code> (the \0
1551is a null byte). The example above is for a user named `<code>test</code>'
1552with password `<code>testpass</code>'. </p>
1553<blockquote>
1554
1555<strong>Caution</strong>
1556
1557<p> When posting logs of the SASL negotiations to public lists,
1558please keep in mind that username/password information is trivial
1559to recover from the base64-encoded form. </p>
1560
1561</blockquote>
1562
1563<p> You can use one of the following commands to generate base64
1564encoded authentication information: </p>
1565
1566<ul>
1567
1568<li> <p> Using a recent version of the <b>bash</b> shell: </p>
1569
1570<blockquote>
1571<pre>
1572% <strong>echo -ne '\000username\000password' | openssl base64</strong>
1573</pre>
1574</blockquote>
1575
1576<p> Some other shells support similar syntax. </p>
1577
1578<li> <p> Using the <b>printf</b> command: </p>
1579
1580<blockquote>
1581<pre>
1582% <strong>printf '\0%s\0%s' '<em>username</em>' '<em>password</em>' | openssl base64</strong>
1583% <strong>printf '\0%s\0%s' '<em>username</em>' '<em>password</em>' | mmencode</strong>
1584</pre>
1585</blockquote>
1586
1587<p> The <strong>mmencode</strong> command is part of the metamail
1588software. </p>
1589
1590<li> <p> Using Perl <b>MIME::Base64</b>: </p>
1591
1592<blockquote>
1593<pre>
1594% <strong>perl -MMIME::Base64 -e \
1595    'print encode_base64("\0<em>username</em>\0<em>password</em>");'</strong>
1596</pre>
1597</blockquote>
1598
1599<p> MIME::Base64 is available from <a href="http://www.cpan.org/">http://www.cpan.org/</a>. </p>
1600
1601<li> <p> Using the <b>gen-auth</b> script: </p>
1602
1603<blockquote>
1604<pre>
1605% <strong>gen-auth plain</strong>
1606username: <strong><em>username</em></strong>
1607password:
1608</pre>
1609</blockquote>
1610
1611<p> The <strong>gen-auth</strong> Perl script was written by John
1612Jetmore and can be found at <a href="http://jetmore.org/john/code/gen-auth">http://jetmore.org/john/code/gen-auth</a>. </p>
1613
1614</ul>
1615
1616<h2><a name="client_sasl">Configuring SASL authentication in the Postfix SMTP/LMTP client</a></h2>
1617
1618<p> The Postfix SMTP and the LMTP client can authenticate with a
1619remote SMTP server via the Cyrus SASL framework. At this time, the
1620Dovecot SASL implementation does not provide client functionality.
1621</p>
1622
1623<blockquote>
1624
1625<strong>Note</strong>
1626
1627<p> The examples in this section discuss only the SMTP client.
1628Replace <code>smtp_</code> with <code>lmtp_</code> to get the
1629corresponding LMTP client configuration. </p>
1630
1631</blockquote>
1632
1633<p> You can read more about the following topics: </p>
1634
1635<ul>
1636
1637<li><a href="#client_sasl_enable">Enabling SASL authentication in
1638the Postfix SMTP/LMTP client</a></li>
1639
1640<li><a href="#client_sasl_sender">Configuring sender-dependent SASL
1641authentication</a></li>
1642
1643<li><a href="#client_sasl_policy">Postfix SMTP/LMTP client policy
1644- SASL mechanism <em>properties</em></a></li>
1645
1646<li><a href="#client_sasl_filter">Postfix SMTP/LMTP client policy
1647- SASL mechanism <em>names</em></a></li>
1648
1649</ul>
1650
1651<h3><a name="client_sasl_enable">Enabling SASL authentication in the
1652Postfix SMTP/LMTP client</a></h3>
1653
1654<p> This section shows a typical scenario where the Postfix SMTP
1655client sends all messages via a mail gateway server that requires
1656SASL authentication. </p>
1657
1658<blockquote>
1659
1660<strong> Trouble solving tips: </strong>
1661
1662<ul>
1663
1664<li> <p> If your SASL logins fail with "SASL authentication failure:
1665No worthy mechs found" in the mail logfile, then see the section
1666"<a href="SASL_README.html#client_sasl_policy">Postfix SMTP/LMTP
1667client policy - SASL mechanism <em>properties</em></a>".
1668
1669<li> <p> For a solution to a more obscure class of SASL authentication
1670failures, see "<a href="SASL_README.html#client_sasl_filter">Postfix
1671SMTP/LMTP client policy - SASL mechanism <em>names</em></a>".
1672
1673</ul>
1674
1675</blockquote>
1676
1677<p> To make the example more readable we introduce it in two parts.
1678The first part takes care of the basic configuration, while the
1679second part sets up the username/password information.  </p>
1680
1681<blockquote>
1682<pre>
1683/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1684    <a href="postconf.5.html#smtp_sasl_auth_enable">smtp_sasl_auth_enable</a> = yes
1685    <a href="postconf.5.html#relayhost">relayhost</a> = [mail.isp.example]
1686    # Alternative form:
1687    # <a href="postconf.5.html#relayhost">relayhost</a> = [mail.isp.example]:submission
1688    <a href="postconf.5.html#smtp_sasl_password_maps">smtp_sasl_password_maps</a> = hash:/etc/postfix/sasl_passwd
1689</pre>
1690</blockquote>
1691
1692<ul>
1693
1694<li> <p> The <code><a href="postconf.5.html#smtp_sasl_auth_enable">smtp_sasl_auth_enable</a></code> setting enables
1695client-side authentication. We will configure the client's username
1696and password information in the second part of the example. </p>
1697</li>
1698
1699<li> <p> The <code><a href="postconf.5.html#relayhost">relayhost</a></code> setting forces the Postfix SMTP
1700to send all remote messages to the specified mail server instead
1701of trying to deliver them directly to their destination. </p> </li>
1702
1703<li> <p> In the <code><a href="postconf.5.html#relayhost">relayhost</a></code> setting, the "<code>[</code>"
1704and "<code>]</code>" prevent the Postfix SMTP client from looking
1705up MX (mail exchanger) records for the enclosed name.  </p> </li>
1706
1707<li> <p> The <code><a href="postconf.5.html#relayhost">relayhost</a></code> destination may also specify a
1708non-default TCP port. For example, the alternative form
1709<code>[mail.isp.example]:submission</code> tells Postfix to connect
1710to TCP network port 587, which is reserved for email client
1711applications.  </p> </li>
1712
1713<li> <p> The Postfix SMTP client is compatible with SMTP servers
1714that use the non-standard "<code>AUTH=<em>method.</em>...</code>"
1715syntax in response to the EHLO command; this requires no additional
1716Postfix client configuration. </p> </li>
1717
1718<li> <p> The Postfix SMTP client does not support the obsolete
1719"wrappermode" protocol, which uses TCP port <code>465</code> on the
1720SMTP server.  See <a href="TLS_README.html">TLS_README</a> for a solution that uses the
1721<code>stunnel</code> command.  </p> </li>
1722
1723<li> <p> With the <code><a href="postconf.5.html#smtp_sasl_password_maps">smtp_sasl_password_maps</a></code> parameter,
1724we configure the Postfix SMTP client to send username and password
1725information to the mail gateway server. As discussed in the next
1726section, the Postfix SMTP client supports multiple ISP accounts.
1727For this reason the username and password are stored in a table
1728that contains one username/password combination for each mail gateway
1729server.  </p>
1730
1731</ul>
1732
1733<blockquote>
1734<pre>
1735/etc/postfix/sasl_passwd:
1736    # destination                   credentials
1737    [mail.isp.example]              username:password
1738    # Alternative form:
1739    # [mail.isp.example]:submission username:password
1740</pre>
1741</blockquote>
1742
1743<blockquote>
1744
1745<strong>Important</strong>
1746
1747<p> Keep the SASL client password file in <code>/etc/postfix</code>,
1748and make the file read+write only for <code>root</code> to protect
1749the username/password combinations against other users. The Postfix
1750SMTP client will still be able to read the SASL client passwords.
1751It opens the file as user <code>root</code> before it drops privileges,
1752and before entering an optional chroot jail. </p>
1753
1754</blockquote>
1755
1756<ul>
1757
1758<li> <p> Use the <code>postmap</code> command whenever you
1759change the <code>/etc/postfix/sasl_passwd</code> file. </p> </li>
1760
1761<li> <p> If you specify the "<code>[</code>" and "<code>]</code>"
1762in the <code><a href="postconf.5.html#relayhost">relayhost</a></code> destination, then you must use the
1763same form in the <code><a href="postconf.5.html#smtp_sasl_password_maps">smtp_sasl_password_maps</a></code> file.  </p>
1764</li>
1765
1766<li> <p> If you specify a non-default TCP Port (such as
1767"<code>:submission</code>" or "<code>:587</code>") in the
1768<code><a href="postconf.5.html#relayhost">relayhost</a></code> destination, then you must use the same form
1769in the <code><a href="postconf.5.html#smtp_sasl_password_maps">smtp_sasl_password_maps</a></code> file.  </p> </li>
1770
1771</ul>
1772
1773<h3><a name="client_sasl_sender">Configuring Sender-Dependent SASL
1774authentication</a></h3>
1775
1776<p> Postfix supports different ISP accounts for different sender
1777addresses (version 2.3 and later).  This can be useful when one
1778person uses the same machine for work and for personal use, or when
1779people with different ISP accounts share the same Postfix server.
1780</p>
1781
1782<p> To make this possible, Postfix supports per-sender SASL passwords
1783and per-sender relay hosts. In the example below, the Postfix SMTP
1784client will search the SASL password file by sender address before
1785it searches that same file by destination.  Likewise, the Postfix
1786<a href="trivial-rewrite.8.html">trivial-rewrite(8)</a> daemon will search the per-sender <a href="postconf.5.html#relayhost">relayhost</a> file,
1787and use the default <code><a href="postconf.5.html#relayhost">relayhost</a></code> setting only as a final
1788resort.  </p>
1789
1790<blockquote>
1791<pre>
1792/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1793    <a href="postconf.5.html#smtp_sender_dependent_authentication">smtp_sender_dependent_authentication</a> = yes
1794    <a href="postconf.5.html#sender_dependent_relayhost_maps">sender_dependent_relayhost_maps</a> = hash:/etc/postfix/sender_relay
1795    <a href="postconf.5.html#smtp_sasl_auth_enable">smtp_sasl_auth_enable</a> = yes
1796    <a href="postconf.5.html#smtp_sasl_password_maps">smtp_sasl_password_maps</a> = hash:/etc/postfix/sasl_passwd
1797    <a href="postconf.5.html#relayhost">relayhost</a> = [mail.isp.example]
1798    # Alternative form:
1799    # <a href="postconf.5.html#relayhost">relayhost</a> = [mail.isp.example]:submission
1800</pre>
1801</blockquote>
1802
1803<blockquote>
1804<pre>
1805/etc/postfix/sasl_passwd:
1806    # Per-sender authentication; see also /etc/postfix/sender_relay.
1807    user1@example.com               username2:password2
1808    user2@example.net               username2:password2
1809    # Login information for the default <a href="postconf.5.html#relayhost">relayhost</a>.
1810    [mail.isp.example]              username:password
1811    # Alternative form:
1812    # [mail.isp.example]:submission username:password
1813</pre>
1814</blockquote>
1815
1816<blockquote>
1817<pre>
1818/etc/postfix/sender_relay:
1819    # Per-sender provider; see also /etc/postfix/sasl_passwd.
1820    user1@example.com               [mail.example.com]:submission
1821    user2@example.net               [mail.example.net]
1822</pre>
1823</blockquote>
1824
1825<ul>
1826
1827<li> <p> If you are creative, then you can try to combine the two
1828tables into one single MySQL database, and configure different
1829Postfix queries to extract the appropriate information. </p>
1830
1831<li> <p> Specify dbm instead of hash if your system uses dbm files
1832instead of db files. To find out what lookup tables Postfix supports,
1833use the command "postconf -m". </p>
1834
1835<li> <p> Execute the command "postmap /etc/postfix/sasl_passwd"
1836whenever you change the sasl_passwd table. </p>
1837
1838<li> <p> Execute the command "postmap /etc/postfix/sender_relay"
1839whenever you change the sender_relay table. </p>
1840
1841</ul>
1842
1843<h3><a name="client_sasl_policy">Postfix SMTP/LMTP client policy -
1844SASL mechanism <em>properties</em></a></h3>
1845
1846<p> Just like the Postfix SMTP server, the SMTP client has a policy
1847that determines which SASL mechanisms are acceptable, based on their
1848properties. The next two sections give examples of how these policies
1849are used.  </p>
1850
1851<blockquote>
1852
1853<table border="1">
1854
1855<tr> <th>Property</th> <th>Description</th> </tr>
1856
1857<tr> <td>noanonymous</td> <td> Don't use mechanisms that permit
1858anonymous authentication.  </td> </tr>
1859
1860<tr> <td>noplaintext</td> <td> Don't use mechanisms that transmit
1861unencrypted username and password information.  </td> </tr>
1862
1863<tr> <td>nodictionary</td> <td> Don't use mechanisms that are
1864vulnerable to dictionary attacks. </td> </tr>
1865
1866<tr> <td>mutual_auth</td> <td> Use only mechanisms that authenticate
1867both the client and the server to each other. </td> </tr>
1868
1869</table>
1870
1871</blockquote>
1872
1873<h4>Unencrypted SMTP session</h4>
1874
1875<p> The default policy is stricter than that of the Postfix SMTP
1876server - plaintext mechanisms are not allowed (nor is any anonymous
1877mechanism): </p>
1878
1879<blockquote>
1880<pre>
1881/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1882    <a href="postconf.5.html#smtp_sasl_security_options">smtp_sasl_security_options</a> = noplaintext, noanonymous
1883</pre>
1884</blockquote>
1885
1886<p> This default policy, which allows no plaintext passwords, leads
1887to authentication failures if the remote server only offers plaintext
1888authentication mechanisms (the SMTP server announces "<code>AUTH
1889PLAIN LOGIN</code>").  In such cases the SMTP client will log the
1890following error message: </p>
1891
1892<blockquote>
1893<pre>
1894SASL authentication failure: No worthy mechs found
1895</pre>
1896</blockquote>
1897
1898<blockquote>
1899
1900<strong>Note</strong>
1901
1902<p> This same error message will also be logged when the
1903<code>libplain.so</code> or <code>liblogin.so</code> modules are
1904not installed in the <code>/usr/lib/sasl2</code> directory. </p>
1905
1906</blockquote>
1907
1908<p> The insecure approach is to lower the security standards and
1909permit plaintext authentication mechanisms: </p>
1910
1911<blockquote>
1912<pre>
1913/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1914    <a href="postconf.5.html#smtp_sasl_security_options">smtp_sasl_security_options</a> = noanonymous
1915</pre>
1916</blockquote>
1917
1918<p> The more secure approach is to protect the plaintext username
1919and password with TLS session encryption. To find out if the remote
1920SMTP server supports TLS, connect to the server and see if it
1921announces STARTTLS support as shown in the example.  Information
1922sent by the client (that is, you) is shown in <strong>bold</strong>
1923font.  </p>
1924
1925<blockquote>
1926<pre>
1927% <strong>telnet server.example.com 25</strong>
1928...
1929220 server.example.com ESMTP Postfix
1930<strong>EHLO client.example.com</strong>
1931250-server.example.com
1932250-PIPELINING
1933250-SIZE 10240000
1934250-STARTTLS
1935...
1936</pre>
1937</blockquote>
1938
1939<p> Instead of port 25 (smtp), specify port 587 (submission) where
1940appropriate. </p>
1941
1942<h4>Encrypted SMTP session (TLS)</h4>
1943
1944<p> To turn on TLS in the Postfix SMTP client, see <a href="TLS_README.html">TLS_README</a> for
1945configuration details. </p>
1946
1947<p> The <a href="postconf.5.html#smtp_sasl_tls_security_options">smtp_sasl_tls_security_options</a> parameter controls Postfix
1948SASL mechanism policy during a TLS-encrypted SMTP session. The
1949default is to copy the settings from the unencrypted session: </p>
1950
1951<blockquote>
1952<pre>
1953/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1954    <a href="postconf.5.html#smtp_sasl_tls_security_options">smtp_sasl_tls_security_options</a> = $<a href="postconf.5.html#smtp_sasl_security_options">smtp_sasl_security_options</a>
1955</pre>
1956</blockquote>
1957
1958<p> A more sophisticated policy allows plaintext mechanisms, but
1959only over a TLS-encrypted connection: </p>
1960
1961<blockquote>
1962<pre>
1963/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1964    <a href="postconf.5.html#smtp_sasl_security_options">smtp_sasl_security_options</a> = noanonymous, noplaintext
1965    <a href="postconf.5.html#smtp_sasl_tls_security_options">smtp_sasl_tls_security_options</a> = noanonymous
1966</pre>
1967</blockquote>
1968
1969<h3><a name="client_sasl_filter">Postfix SMTP/LMTP client policy -
1970SASL mechanism <em>names</em></a></h3>
1971
1972<p> Given the SASL security options of the previous section, the
1973Cyrus SASL library will choose the most secure authentication
1974mechanism that both the SMTP client and server implement.  Unfortunately,
1975that authentication mechanism may fail because the client or server
1976is not configured to use that mechanism.</p>
1977
1978<p> To prevent this, the Postfix SMTP client can filter the names
1979of the authentication mechanisms from the remote SMTP server.  Used
1980correctly, the filter hides unwanted mechanisms from the Cyrus SASL
1981library, forcing the library to choose from the mechanisms the
1982Postfix SMTP client filter passes through.  </p>
1983
1984<p> The following example filters out everything but the mechanisms
1985<code>PLAIN</code> and <code>LOGIN</code>: </p>
1986
1987<blockquote>
1988<pre>
1989/etc/postfix/<a href="postconf.5.html">main.cf</a>:
1990    <a href="postconf.5.html#smtp_sasl_mechanism_filter">smtp_sasl_mechanism_filter</a> = plain, login
1991</pre>
1992</blockquote>
1993
1994<blockquote>
1995
1996<strong>Note</strong>
1997
1998<p> If the remote server does not offer any of the mechanisms on
1999the filter list, authentication will fail. </p>
2000
2001</blockquote>
2002
2003<p> We close this section with an example that passes every mechanism
2004except for <code>GSSAPI</code> and <code>LOGIN</code>: </p>
2005
2006<blockquote>
2007<pre>
2008/etc/postfix/<a href="postconf.5.html">main.cf</a>:
2009    <a href="postconf.5.html#smtp_sasl_mechanism_filter">smtp_sasl_mechanism_filter</a> = !gssapi, !login, <a href="DATABASE_README.html#types">static</a>:all
2010</pre>
2011</blockquote>
2012
2013<h2><a name="postfix_build">Building Postfix with SASL support</a></h2>
2014
2015<p> As mentioned elsewhere, Postfix supports two SASL implementations:
2016Cyrus SASL (SMTP client and server) and Dovecot SASL (SMTP server
2017only). Both implementations can be built into Postfix simultaneously.
2018</p>
2019
2020<ul>
2021
2022<li><a href="#build_dovecot">Building Dovecot SASL support</a></li>
2023
2024<li><a href="#sasl_support">Building Cyrus SASL support</a></li>
2025
2026</ul>
2027
2028<h3><a name="build_dovecot">Building Dovecot SASL support</a></h3>
2029
2030<p> These instructions assume that you build Postfix from source
2031code as described in the <a href="INSTALL.html">INSTALL</a> document. Some modification may
2032be required if you build Postfix from a vendor-specific source
2033package. </p>
2034
2035<p> Support for the Dovecot version 1 SASL protocol is available
2036in Postfix 2.3 and later. At the time of writing, only server-side
2037SASL support is available, so you can't use it to authenticate the
2038Postfix SMTP client to your network provider's server. </p>
2039
2040<p> Dovecot uses its own daemon process for authentication. This
2041keeps the Postfix build process simple, because there is no need
2042to link extra libraries into Postfix. </p>
2043
2044<p> To generate the necessary Makefiles, execute the following in
2045the Postfix top-level directory: </p>
2046
2047<blockquote>
2048<pre>
2049% <strong>make tidy</strong> # if you have left-over files from a previous build
2050% <strong>make makefiles CCARGS='-DUSE_SASL_AUTH \
2051    -DDEF_SERVER_SASL_TYPE=\"dovecot\"'</strong>
2052</pre>
2053</blockquote>
2054
2055<p> After this, proceed with "<code>make</code>" as described in
2056the <a href="INSTALL.html">INSTALL</a> document. </p>
2057
2058<strong>Note</strong>
2059
2060<ul>
2061
2062<li>
2063
2064<p> The <code>-DDEF_SERVER_SASL_TYPE=\"dovecot\"</code> is not
2065necessary; it just makes Postfix configuration a little more
2066convenient because you don't have to specify the SASL plug-in type
2067in the Postfix <a href="postconf.5.html">main.cf</a> file (but this may cause surprises when you
2068switch to a later Postfix version that is built with the default
2069SASL type of <code>sasl</code>). </p>
2070
2071</li>
2072
2073<li>
2074
2075<p> If you also want support for LDAP or TLS (or for Cyrus SASL),
2076you need to merge their <code>CCARGS</code> and <code>AUXLIBS</code>
2077options into the above command line; see the <a href="LDAP_README.html">LDAP_README</a> and
2078<a href="TLS_README.html">TLS_README</a> for details.  </p>
2079
2080<blockquote>
2081<pre>
2082% <strong>make tidy</strong> # if you have left-over files from a previous build
2083% <strong>make makefiles CCARGS='-DUSE_SASL_AUTH \
2084    -DDEF_SERVER_SASL_TYPE=\"dovecot\" \
2085    ...<i>CCARGS options for LDAP or TLS etc.</i>...' \
2086   AUXLIBS='...<i>AUXLIBS options for LDAP or TLS etc.</i>...'</strong>
2087</pre>
2088</blockquote>
2089
2090</li>
2091
2092</ul>
2093
2094<h3><a name="sasl_support">Building Cyrus SASL support</a></h3>
2095
2096<h4><a name="build_sasl">Building the Cyrus SASL library</a></h4>
2097
2098<p> Postfix works with cyrus-sasl-1.5.x or cyrus-sasl-2.1.x, which are
2099available from <a href="ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/">ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/</a>. </p>
2100
2101<blockquote>
2102
2103<strong>Important</strong>
2104
2105<p> If you install the Cyrus SASL libraries as per the default, you will have
2106to create a symlink <code>/usr/lib/sasl</code> -&gt;
2107<code>/usr/local/lib/sasl</code> for version 1.5.x or
2108<code>/usr/lib/sasl2</code> -&gt; <code>/usr/local/lib/sasl2</code>
2109for version 2.1.x. </p>
2110
2111</blockquote>
2112
2113<p> Reportedly, Microsoft Outlook (Express) requires the non-standard LOGIN
2114and/or NTLM authentication mechanism. To enable these authentication
2115mechanisms, build the Cyrus SASL libraries with: </p>
2116
2117<blockquote>
2118<pre>
2119% <strong>./configure --enable-login --enable-ntlm</strong>
2120</pre>
2121</blockquote>
2122
2123<h4><a name="build_postfix">Building Postfix with Cyrus SASL support</a></h4>
2124
2125<p> These instructions assume that you build Postfix from source
2126code as described in the <a href="INSTALL.html">INSTALL</a> document. Some modification may
2127be required if you build Postfix from a vendor-specific source
2128package. </p>
2129
2130<p> The following assumes that the Cyrus SASL include files are in
2131<code>/usr/local/include</code>, and that the Cyrus SASL libraries are in
2132<code>/usr/local/lib</code>. </p>
2133
2134<p> On some systems this generates the necessary <code>Makefile</code>
2135definitions: </p>
2136
2137<dl>
2138
2139<dt>Cyrus SASL version 2.1.x</dt>
2140
2141<dd>
2142
2143<pre>
2144% <strong>make tidy</strong> # if you have left-over files from a previous build
2145% <strong>make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
2146    -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib -lsasl2"</strong>
2147</pre>
2148
2149</dd>
2150
2151<dt>Cyrus SASL version 1.5.x</dt>
2152
2153<dd>
2154
2155<pre>
2156% <strong>make tidy</strong> # if you have left-over files from a previous build
2157% <strong>make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
2158    -I/usr/local/include" AUXLIBS="-L/usr/local/lib -lsasl"</strong>
2159</pre>
2160
2161</dd>
2162
2163</dl>
2164
2165<p> On Solaris 2.x you need to specify run-time link information,
2166otherwise the ld.so run-time linker will not find the SASL shared
2167library: </p>
2168
2169<dl>
2170
2171<dt>Cyrus SASL version 2.1.x</dt>
2172
2173<dd>
2174
2175<pre>
2176% <strong>make tidy</strong> # remove left-over files from a previous build
2177% <strong>make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
2178    -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib \
2179    -R/usr/local/lib -lsasl2"</strong>
2180</pre>
2181
2182</dd>
2183
2184<dt>Cyrus SASL version 1.5.x</dt>
2185
2186<dd>
2187
2188<pre>
2189% <strong>make tidy</strong> # if you have left-over files from a previous build
2190% <strong>make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
2191    -I/usr/local/include" AUXLIBS="-L/usr/local/lib \
2192    -R/usr/local/lib -lsasl"</strong>
2193</pre>
2194
2195</dd>
2196
2197</dl>
2198
2199<h2><a name="cyrus_legacy">Using Cyrus SASL version 1.5.x</a></h2>
2200
2201<p> Postfix supports Cyrus SASL version 1.x, but you shouldn't use
2202it unless you are forced to. The makers of Cyrus SASL write: </p>
2203
2204<blockquote> <i> This library is being deprecated and applications
2205should transition to using the SASLv2 library</i> (source: <a
2206href="http://cyrusimap.web.cmu.edu/downloads.html">Project Cyrus:
2207Downloads</a>). </blockquote>
2208
2209<p> If you still need to set it up, here's a quick rundown: </p>
2210
2211<p> Read the regular section on SMTP server configurations for the
2212Cyrus SASL framework. The differences are: </p>
2213
2214<ul>
2215
2216<li> <p> Cyrus SASL version 1.5.x searches for configuration
2217(<code>smtpd.conf</code>) in <code>/usr/lib/sasl/</code> only. You
2218must place the configuration in that directory. Some systems may
2219have modified Cyrus SASL and put the files into e.g.
2220<code>/var/lib/sasl/</code>. </p> </li>
2221
2222<li> <p> Use the <code>saslpasswd</code> command instead of
2223<code>saslpasswd2</code> to create users in <code>sasldb</code>.
2224</p> </li>
2225
2226<li> <p> Use the <code>sasldblistusers</code> command instead of
2227<code>sasldblistusers2</code> to find users in <code>sasldb</code>.
2228</p> </li>
2229
2230<li> <p> In the <code>smtpd.conf</code> file you can't use
2231<code>mech_list</code> to limit the range of mechanisms offered.
2232Instead, remove their libraries from <code>/usr/lib/sasl/</code>
2233(and remember remove those files again when a system update
2234re-installs new versions).  </p> </li>
2235
2236</ul>
2237
2238<h2><a name="credits">Credits</a></h2>
2239
2240<ul>
2241
2242<li> Postfix SASL support was originally implemented by Till Franke
2243of SuSE Rhein/Main AG. </li>
2244
2245<li> Wietse trimmed down the code to only the bare necessities.
2246 </li>
2247
2248<li> Support for Cyrus SASL version 2 was contributed by Jason Hoos.
2249</li>
2250
2251<li> Liviu Daia added <a href="postconf.5.html#smtpd_sasl_application_name">smtpd_sasl_application_name</a>, separated
2252<a href="postconf.5.html#reject_sender_login_mismatch">reject_sender_login_mismatch</a> into
2253<a href="postconf.5.html#reject_authenticated_sender_login_mismatch">reject_authenticated_sender_login_mismatch</a> and
2254<a href="postconf.5.html#reject_unauthenticated_sender_login_mismatch">reject_unauthenticated_sender_login_mismatch</a>, and revised the docs.
2255 </li>
2256
2257<li> Wietse made another iteration through the code to add plug-in
2258support for multiple SASL implementations, and for reasons that
2259have been lost, also changed <a href="postconf.5.html#smtpd_sasl_application_name">smtpd_sasl_application_name</a> into
2260<a href="postconf.5.html#smtpd_sasl_path">smtpd_sasl_path</a>. </li>
2261
2262<li> The Dovecot SMTP server-only plug-in was originally implemented
2263by Timo Sirainen of Procontrol, Finland. </li>
2264
2265<li> Patrick Ben Koetter revised this document for Postfix 2.4 and
2266made much needed updates. </li>
2267
2268<li> Patrick Ben Koetter revised this document again for Postfix
22692.7 and made much needed updates. </li>
2270
2271</ul>
2272
2273</body>
2274
2275</html>
2276
2277