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