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