From: Wietse Venema The sender/recipient address verification feature described in this
-document is suitable only for low-traffic sites. It performs poorly
-under high load; excessive sender address verification activity may
-even cause your site to be blacklisted by some
-providers. See the "Limitations" section
-below for details. Recipient address verification may cause an increased load on
+down-stream servers in the case of a dictionary attack or a flood
+of backscatter bounces. Sender address verification may cause your
+site to be blacklisted by some providers. See also the "Limitations" section below for more. WARNING
-What Postfix address verification can do for you
@@ -35,7 +34,7 @@ until the address has been verified to be deliverable.
The technique has obvious uses to reject junk mail with an unreplyable sender address.
-The technique may also be useful to block mail for undeliverable +
The technique is also useful to block mail for undeliverable recipients, for example on a mail relay host that does not have a list of all the valid recipient addresses. This prevents undeliverable junk mail from entering the queue, so that Postfix doesn't have to @@ -86,74 +85,96 @@ always discarded.
-+
- + +Internet + + + +-> --> +probe -
+ messagePostfix +
SMTP
server-> + -<-> - ++ Postfix -
queue- Postfix +
verify
server -+ + + + Internet + +-> + + ++ Postfix -
SMTP
server<-> + <-> -Address +
- verification
database+ Postfix
verify
server +- -+ - + | -
+ v| +
- probe
messages
v+ - ^ +
delivery
- status
|<- + + +probe -
+ status+ <- + -+ + Postfix + +
delivery
agents-> + Local
-> Remote- -- - + + -+ + ^ -
|
v+ - Postfix +
queue- -> +- - Postfix +
delivery
agents- @@ -181,7 +202,8 @@ details. MTA for that address, without actually delivering mail to it. If the nearest MTA accepts the address, then Postfix assumes that the address is deliverable. In reality, mail for a remote address can -bounce AFTER the nearest MTA accepts the recipient address. +bounce AFTER the nearest MTA accepts the recipient address, or AFTER +the nearest MTA accepts the message content.+ - + + Address
verification
databaseSome sites may blacklist you when you are probing them too often (a probe is an SMTP session that does not deliver mail), @@ -200,21 +222,25 @@ mail routing and for possible limitations when you have to do this.
Postfix assumes that an address is undeliverable when the nearest MTA for the address rejects the probe, regardless of the reason for rejection (client rejected, HELO rejected, MAIL FROM -rejected, etc.). Thus, Postfix rejects mail when the sender's MTA -rejects mail from your machine. This is a good thing.
+rejected, etc.). Thus, Postfix rejects an address when the nearest +MTA for that address rejects mail from your machine for any reason. +This is not a limitation, but it is mentioned here just in case +people believe that it is a limitation. -Unfortunately, some major sites such as YAHOO do not reject +
Unfortunately, some sites do not reject unknown addresses in reply to the RCPT TO command, but report a delivery failure in response to end of DATA after a message is transferred. Postfix address verification does not work with such sites.
-By default, Postfix probe messages have "double-bounce@$myorigin" -as the sender address (with Postfix versions before 2.5, the default +
By default, Postfix probe messages have a sender address +"double-bounce@$myorigin" (with Postfix versions before 2.5, the +default is "postmaster@$myorigin"). This is SAFE because the Postfix SMTP server does not reject mail for this address.
-You can change this into the null address ("address_verify_sender +
You can change the probe sender address into the null address +("address_verify_sender ="). This is UNSAFE because address probes will fail with mis-configured sites that reject MAIL FROM: <>, while probes from "postmaster@$myorigin" would succeed.
@@ -223,7 +249,7 @@ probes from "postmaster@$myorigin" wouldRecipient address verification
-As mentioned earlier, recipient address verification may be +
As mentioned earlier, recipient address verification is useful to block mail for undeliverable recipients on a mail relay host that does not have a list of all valid recipient addresses. This can help to prevent the mail queue from filling up with @@ -237,9 +263,11 @@ However, recipient address verification probes can increase the load on down-stream MTAs when you're being flooded by backscatter bounces, or when some spammer is mounting a dictionary attack.
-By default, address verification results are not saved. To avoid -probing the same address repeatedly, you can store the result in a -persistent database as described later.
+By default, address verification results are saved in a persistent database (Postfix version 2.7 and +later; with earlier versions, specify the database in main.cf as +described later). The persistent database helps to avoid probing +the same address repeatedly.
-@@ -299,11 +327,13 @@ in forged email. # Postfix 2.6 and later. # unverified_sender_defer_code = 250 + # Default setting for Postfix 2.7 and later. # Note 1: Be sure to read the "Caching" section below! # Note 2: Avoid hash files here. Use btree instead. address_verify_map = btree:/var/lib/postfix/verify /etc/postfix/sender_access: + # Don't do this when you handle lots of email. aol.com reject_unverified_sender hotmail.com reject_unverified_sender bigfoot.com reject_unverified_sender @@ -344,6 +374,7 @@ you can see what mail would be blocked: # Postfix 2.6 and later. # unverified_sender_reject_reason = Address verification failed + # Default setting for Postfix 2.7 and later. # Note 1: Be sure to read the "Caching" section below! # Note 2: Avoid hash files here. Use btree instead. address_verify_map = btree:/var/lib/postfix/verify @@ -403,7 +434,8 @@ sender address verification probe fails with some temporary error.Address verification database
To improve performance, the Postfix verify(8) daemon can save -address verification results to a persistent database. The +address verification results to a persistent database. This is +enabled by default with Postfix 2.7 and later. The address_verify_map (NOTE: singular) configuration parameter specifies persistent storage for sender or recipient address verification results. If you specify an empty value, all address verification diff --git a/postfix/html/OVERVIEW.html b/postfix/html/OVERVIEW.html index 7a332d9c1..689b340fb 100644 --- a/postfix/html/OVERVIEW.html +++ b/postfix/html/OVERVIEW.html @@ -651,31 +651,126 @@ align="center" bgcolor="#f0f0ff"> smtp
session
cacheThe verify(8) server verifies that a sender or recipient address is deliverable before the smtpd(8) server accepts it. The -verify(8) server injects probe messages into the Postfix queue and -processes status updates from delivery agents and/or queue manager. +verify(8) server queries a cache with address verification results. +If a result is not found, the verify(8) server injects a probe +message into the Postfix queue and processes the status update from +a delivery agent or queue manager. This process is described in the ADDRESS_VERIFICATION_README document. The verify(8) service is available with Postfix version 2.1 and later.
-
+ +Network -> smtpd(8) <-> -verify(8) --> cleanup(8) - -> -qmgr(8)
Postfix
queue-> -Delivery +
agents+ + -+ + -> probe
message-> + Postfix +
queue-
-\ \ <- -<- - |
v+
- / / + + + + + +Network +-> + smtpd(8) <-> verify(8) + + ++ + + +| + +
v+ + + +<- + probe
+ status+ <- Postfix
delivery
agents +-> + Local + +
-> Network+ + + ++ + ^ + +
|
v+ + + + + + + ++ Address + +
+ verification
cache+ + The postscreen(8) server can be put "in front" of Postfix +smtpd(8) processes. Its purpose is to accept connections from the +network and to decide what SMTP clients are allowed to talk to +Postfix. According to the 2008 MessageLabs annual report, 81% of +all email was spam, and 90% of that was sent by botnets. While +postscreen(8) keeps the zombies away, more smtpd(8) processes remain +available for legitimate clients.
+ +The postscreen(8) server is still evolving, and is likely to +undergo changes that break compatibility with earlier versions. +For this reason the postscreen(8) server is not installed with the +stable Postfix release.
+ ++ +
diff --git a/postfix/html/SASL_README.html b/postfix/html/SASL_README.html index 7d314e901..b475ab3d7 100644 --- a/postfix/html/SASL_README.html +++ b/postfix/html/SASL_README.html @@ -1,8 +1,6 @@ - -+ + zombie + + \ + + zombie - + - +smtpd(8) + + \ + / + + other +--- +postscreen(8) + + / + \ + other + - + - smtpd(8) + + / + + zombie Postfix SASL Howto @@ -17,803 +15,2116 @@
-WARNING
+Warning
People who go to the trouble of installing Postfix may have the expectation that Postfix is more secure than some other mailers. -The Cyrus SASL library is a lot of code. With this, Postfix becomes -as secure as other mail systems that use the Cyrus SASL library. -Dovecot provides an alternative that may be worth considering. -
+The Cyrus SASL library contains a lot of code. With this, Postfix +becomes as secure as other mail systems that use the Cyrus SASL +library. Dovecot provides an alternative that may be worth +considering. + +How Postfix uses SASL authentication
+ +When an SMTP client connects to an SMTP server, the server needs +to decide whether that client is authorized to send mail to remote +destinations, or whether the client can send mail only to the +destinations that the server itself is responsible for. Usually, +the SMTP server will allow mail to remote destinations only if the +client's IP address is in the "same network" as the server's IP +address.
+ +Sometimes the SMTP client and server are in different networks, +but the client still needs "same network" privileges. To address +this problem, Postfix supports SASL authentication (RFC 4954, +formerly RFC 2554). With this a remote SMTP client can authenticate +to the Postfix SMTP server, and the Postfix SMTP client can +authenticate to a remote SMTP server. Once the client is authenticated +the server can give it "same network" privileges.
+ +Postfix does not implement SASL itself, but instead uses existing +implementations as building blocks. This means that some SASL-related +configuration will involve files that belong to Postfix, while other +configuration will involve files that belong to the specific SASL +implementation that Postfix will use. This document covers both the +Postfix and non-Postfix configuration.
+ +You can read more about the following topics:
-How Postfix uses SASL authentication information
+-
Postfix SASL support (RFC 4954, formerly RFC 2554) can be used -to authenticate -remote SMTP clients to the Postfix SMTP server, and to authenticate -the Postfix SMTP client to a remote SMTP server.
+- Configuring SASL authentication in the +Postfix SMTP server
-When receiving mail, the Postfix SMTP server logs the client-provided -username, -authentication method, and sender address to the maillog file, and -optionally grants mail access via the permit_sasl_authenticated -UCE restriction.
+- Configuring SASL authentication in the Postfix SMTP/LMTP client
-When sending mail, the Postfix SMTP client can look up the -remote SMTP server hostname or -destination domain (the address right-hand part) in a SASL password -table, and if a username/password is found, it will use that username -and password to authenticate to the remote SMTP server. And as of -version 2.3, -Postfix can be configured to search its SASL password table by the -sender email address.
+- Building Postfix with SASL support
-This document covers the following topics:
+- Using Cyrus SASL version 1.5.x
- -- Building Postfix with Dovecot SASL -support
+Configuring SASL authentication in the +Postfix SMTP server
-- Building the Cyrus SASL library +
As mentioned earlier, SASL is implemented separately from +Postfix. For this reason, configuring SASL authentication in the +Postfix SMTP server involves two different steps:
-- Building Postfix with Cyrus SASL -support
+-
-- Enabling SASL authentication in the -Postfix SMTP server
+- -
Configuring the SASL implementation to offer a list of +mechanisms that are suitable for SASL authentication and, depending +on the SASL implementation used, configuring authentication backends +that verify the remote SMTP client's authentication data against +the system password file or some other database.
- Dovecot SASL configuration for the Postfix -SMTP server
+- -
Configuring the Postfix SMTP server to enable SASL +authentication, and to authorize clients to relay mail or to control +what envelope sender addresses the client may use.
- Cyrus SASL configuration for the Postfix -SMTP server
+- Testing SASL authentication in the -Postfix SMTP server
+Successful authentication in the Postfix SMTP server requires +a functional SASL framework. Configuring SASL should therefore +always be the first step.
-- Trouble shooting the SASL internals +
You can read more about the following topics:
-- Enabling SASL authentication in the -Postfix SMTP client
+-
+- Supporting multiple ISP accounts -in the Postfix SMTP client
+- Which SASL Implementations are +supported?
-- Credits +
- Configuring Dovecot SASL -
-
What SASL implementations are supported
+- Postfix to Dovecot SASL +communication
-This document describes Postfix with the following SASL -implementations:
+Configuring Cyrus SASL --
+Cyrus SASL version 1 (client and server).
+- Cyrus SASL configuration file +name
-Cyrus SASL version 2 (client and server).
+- Cyrus SASL configuration +file location
-Dovecot protocol version 1 (server only, Postfix version -2.3 and later)
+- Postfix to Cyrus SASL +communication
-Postfix version 2.3 introduces a plug-in mechanism that provides -support for multiple SASL implementations. To find out what -implementations are built into Postfix, use the following commands: -
+Enabling SASL authentication and +authorization in the Postfix SMTP server - --+-% postconf -a (SASL support in the SMTP server) -% postconf -A (SASL support in the SMTP+LMTP client) ---
Needless to say, these commands are not available in earlier -Postfix versions.
+- Enabling SASL authentication in +the Postfix SMTP server
-Building Postfix with Dovecot SASL -support
+- Postfix SMTP Server +Authentication Policy
-These instructions assume that you build Postfix from source -code as described in the INSTALL document. Some modification may -be required if you build Postfix from a vendor-specific source -package.
+- Enabling SASL authorization in the Postfix +SMTP server
-Support for the Dovecot version 1 SASL protocol is available -in Postfix 2.3 and later. At the time -of writing, only server-side SASL support is available, so you can't -use it to authenticate to your network provider's server. Dovecot -uses its own daemon process for authentication. This keeps the -Postfix build process simple, because there is no need to link extra -libraries into Postfix.
+- Additional SMTP Server SASL options
-To generate the necessary Makefiles, execute the following -in the Postfix top-level directory:
+-+-% make makefiles CCARGS='-DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\"dovecot\"' --Testing SASL authentication in the Postfix +SMTP server + + -After this, proceed with "make" as described in the -INSTALL document.
-Notes:
+Which SASL Implementations are supported?
-+
+Currently the Postfix SMTP server supports the Cyrus SASL and +Dovecot SASL implementations.
-The "-DDEF_SERVER_SASL_TYPE" stuff is not necessary; it just -makes Postfix configuration a little more convenient because you -don't have to specify the SASL plug-in type in the Postfix main.cf -file.
+-If you also want support for LDAP or TLS, you will have to merge -their CCARGS and AUXLIBS into the above command line.
+Note -Before Postfix version 2.3, Postfix had support only for Cyrus +SASL. Current Postfix versions have a plug-in architecture that +can support multiple SASL implementations.
-Building the Cyrus SASL library
+Postfix appears to work with cyrus-sasl-1.5.x or cyrus-sasl-2.1.x, -which are available from:
+To find out what SASL implementations are compiled into Postfix, +use the following commands:
--ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/ +%postconf -a(SASL support in the SMTP server) +%postconf -A(SASL support in the SMTP+LMTP client)IMPORTANT: if you install the Cyrus SASL libraries as per the -default, you will have to symlink /usr/lib/sasl -> /usr/local/lib/sasl -for version 1.5.x or /usr/lib/sasl2 -> /usr/local/lib/sasl2 for -version 2.1.x.
- -Reportedly, Microsoft Outlook (Express) requires the -non-standard LOGIN authentication method. To enable this -authentication method, specify ``./configure --enable-login''.
+These commands are available only with Postfix version 2.3 and +later.
-Building Postfix with Cyrus SASL support
+Configuring Dovecot SASL
-These instructions assume that you build Postfix from source -code as described in the INSTALL document. Some modification may -be required if you build Postfix from a vendor-specific source -package.
+Dovecot is a POP/IMAP server that must be configured to +authenticate POP/IMAP clients. When the Postfix SMTP server uses +Dovecot SASL, it also reuses this configuration. Consult the Dovecot documentation for how +to configure and operate the Dovecot authentication server.
-The following -assumes that the Cyrus SASL include files are in /usr/local/include, -and that the Cyrus SASL libraries are in /usr/local/lib.
+Postfix to Dovecot SASL communication
-On some systems this generates the necessary Makefile definitions: +
Communication between the Postfix SMTP server +and Dovecot SASL happens via a UNIX-domain socket. The socket +pathname and the list of mechanisms offered to Postfix need to be +specified on the Dovecot server side in
-dovecot.conf.- -
+- (for Cyrus SASL version 1.5.x): -
- -
-% make tidy # if you have left-over files from a previous build -% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \ - -I/usr/local/include" AUXLIBS="-L/usr/local/lib -lsasl" -+The following example assumes that the Postfix queue is under +
-/var/spool/postfix/.- (for Cyrus SASL version 2.1.x): -
- +
--% make tidy # if you have left-over files from a previous build -% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \ - -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib -lsasl2" + 1 /etc/dovecot.conf: + 2 auth default { + 3 mechanisms = plain login + 4 passdb pam { + 5 } + 6 userdb passwd { + 7 } + 8 socket listen { + 9 client { +10 path = /var/spool/postfix/private/auth +11 mode = 0660 +12 user = postfix +13 group = postfix +14 } +15 } +16 }+Line 3 provides
-plainandloginas +mechanisms for the Postfix SMTP server, line 10 places the Dovecot +SASL socket in/var/spool/postfix/private/auth, and +lines 11-13 limit read+write permissions to user and group +postfixonly.On Solaris 2.x you need to specify run-time link information, -otherwise ld.so will not find the SASL shared library:
+Proceed with the section "Enabling SASL authentication and +authorization in the Postfix SMTP server" to turn on and use +SASL in the Postfix SMTP server.
-+
+Configuring Cyrus SASL
-- (for Cyrus SASL version 1.5.x): -
- -
-% make tidy # if you have left-over files from a previous build -% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \ - -I/usr/local/include" AUXLIBS="-L/usr/local/lib \ - -R/usr/local/lib -lsasl" -+The Cyrus SASL framework was supports a wide variety of +applications. Different applications may require different +configurations. As a consequence each application may have its own +configuration file.
-- (for Cyrus SASL version 2.1.x): -
- -
-% make tidy # if you have left-over files from a previous build -% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \ - -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib \ - -R/usr/local/lib -lsasl2" -+The first step configuring Cyrus SASL is to determine name and +location of a configuration file that describes how the Postfix +SMTP server will use the SASL framework.
-Cyrus SASL configuration file name
-Enabling SASL authentication in the Postfix -SMTP server
+The name of the configuration file (default:
-smtpd.conf) +is configurable. It is a concatenation from a value that the Postfix +SMTP server sends to the Cyrus SASL library, and the suffix +.conf, added by Cyrus SASL.In order to enable SASL support in the Postfix SMTP server:
+The value sent by Postfix is the name of the server component +that will use Cyrus SASL. It defaults to
smtpdand +is configured with one of the following variables:- -/etc/postfix/main.cf: - smtpd_sasl_auth_enable = yes --In order to allow mail relaying by authenticated remote SMTP -clients:
+ # Postfix 2.3 and later + smtpd_sasl_path = smtpd ----/etc/postfix/main.cf: - smtpd_recipient_restrictions = - permit_mynetworks - permit_sasl_authenticated - reject_unauth_destination + # Postfix < 2.3 + smtpd_sasl_application_name = smtpdTo report SASL login names in Received: message headers -(Postfix version 2.3 and later):
+Cyrus SASL configuration file +location
--+-/etc/postfix/main.cf: - smtpd_sasl_authenticated_header = yes --The location where Cyrus SASL searches for the named file depends +on the Cyrus SASL version and the OS/distribution used.
-Note: the SASL login names will be shared with the entire world. -
+You can read more about the following topics:
-Older Microsoft SMTP client software implements a non-standard -version of the AUTH protocol syntax, and expects that the SMTP -server replies to EHLO with "250 AUTH=mechanism-list" instead of -"250 AUTH mechanism-list". To accommodate such clients (in addition -to conformant -clients) use the following:
+-
-+-/etc/postfix/main.cf: - broken_sasl_auth_clients = yes --- -
Cyrus SASL version 2.x searches for the configuration file +in
/usr/lib/sasl2/.Dovecot SASL configuration for the -Postfix SMTP server
+- -
Cyrus SASL version 2.1.22 and newer additionally search +in
/etc/sasl2/.Dovecot SASL support is available in Postfix 2.3 and later. On -the Postfix side you need to specify the location of the -Dovecot authentication daemon socket. We use a pathname relative -to the Postfix queue directory, so that it will work whether or not -the Postfix SMTP server runs chrooted:
+- + +
Some Postfix distributions are modified and look for the +Cyrus SASL configuration file in
/etc/postfix/sasl/, +/var/lib/sasl2/etc. See the distribution-specific +documentation to determine the expected location.---/etc/postfix/main.cf: - smtpd_sasl_type = dovecot - smtpd_sasl_path = private/auth --On the Dovecot side you also need to specify the Dovecot -authentication daemon socket. In this case we specify an -absolute pathname. In the example we assume that the -Postfix queue is under /var/spool/postfix/.
+Note + +Cyrus SASL searches
-/usr/lib/sasl2/first. If it +finds the specified configuration file there, it will not examine +other locations.---/some/where/dovecot.conf: - auth default { - mechanisms = plain login - passdb pam { - } - userdb passwd { - } - socket listen { - client { - path = /var/spool/postfix/private/auth - mode = 0660 - user = postfix - group = postfix - } - } - } -See the Dovecot documentation for how to configure and operate -the Dovecot authentication server.
+Postfix to Cyrus SASL communication
-Cyrus SASL configuration for the Postfix -SMTP server
+As the Postfix SMTP server is linked with the Cyrus SASL library +
-libsasl, communication between Postfix and Cyrus SASL +takes place by calling functions in the SASL library.You need to configure how the Cyrus SASL library should -authenticate a remote SMTP client's username and password. These -settings must -be stored in a separate configuration file.
+The SASL library may use an external password verification +service, or an internal plugin to connect to authentication backends +and verify the SMTP client's authentication data against the system +password file or other databases.
-The name of the configuration file (default: smtpd.conf) will -be constructed from a value that the Postfix SMTP server sends to -the Cyrus SASL -library, which adds the suffix .conf. The value is configured using -one of the following variables:
+The following table shows typical combinations discussed in +this document:
---/etc/postfix/main.cf: - # Postfix 2.3 and later - smtpd_sasl_path = smtpd - # Postfix < 2.3 - smtpd_sasl_application_name = smtpd --Cyrus SASL searches for the configuration file in /usr/local/lib/sasl/ -(Cyrus SASL version 1.5.5) or /usr/local/lib/sasl2/ (Cyrus SASL -version 2.1.x).
+-
+ + -Note: some Postfix distributions are modified and look for -the smtpd.conf file in /etc/postfix/sasl.
+- -Note: some Cyrus SASL distributions look for the smtpd.conf -file in /etc/sasl2.
+authentication backend -+
password verification service / plugin -To authenticate against the UNIX password database, use:
+-
- (Cyrus SASL version 1.5.x) -
- -
-/usr/local/lib/sasl/smtpd.conf: - pwcheck_method: pwcheck +- + -/etc/shadow -IMPORTANT: pwcheck establishes a UNIX domain socket in /var/pwcheck -and waits for authentication requests. The Postfix SMTP server must have -read+execute permission to this directory or authentication attempts -will fail.
+saslauthd -The pwcheck daemon is contained in the cyrus-sasl source tarball.
+- (Cyrus SASL version 1.5.26) -
- -
-/usr/local/lib/sasl/smtpd.conf: - pwcheck_method: saslauthd -+- -- (Cyrus SASL version 2.1.x) -
- -
-/usr/local/lib/sasl2/smtpd.conf: - pwcheck_method: saslauthd - mech_list: PLAIN LOGIN -+PAM - +saslauthd -The saslauthd daemon is also contained in the cyrus-sasl source -tarball. It is more flexible than the pwcheck daemon, in that it -can authenticate against PAM and various other sources. To use PAM, -start saslauthd with "-a pam".
+IMPORTANT: saslauthd usually establishes a UNIX domain socket -in /var/run/saslauthd and waits for authentication requests. The Postfix -SMTP server must have read+execute permission to this directory or -authentication attempts will fail.
+- -Note: The directory where saslauthd puts the socket is configurable. -See the command-line option "-m /path/to/socket" in the saslauthd ---help listing.
+IMAP server -To authenticate against Cyrus SASL's own password database:
+saslauthd --
- (Cyrus SASL version 1.5.x) -
- -
-/usr/local/lib/sasl/smtpd.conf: - pwcheck_method: sasldb -+- (Cyrus SASL version 2.1.x) -
- -
-/usr/local/lib/sasl2/smtpd.conf: - pwcheck_method: auxprop - auxprop_plugin: sasldb - mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5 -+- + -sasldb -This will use the Cyrus SASL password file (default: /etc/sasldb in -version 1.5.x, or /etc/sasldb2 in version 2.1.x), which is maintained -with the saslpasswd or saslpasswd2 command (part of the Cyrus SASL -software). On some poorly-supported systems the saslpasswd command needs -to be run multiple times before it stops complaining. The Postfix SMTP -server needs read access to the sasldb file - you may have to play games -with group access permissions. With the OTP authentication mechanism, -the Postfix SMTP server also needs WRITE access to /etc/sasldb2 or -/etc/sasldb -(or the back end SQL database, if used).
+sasldb -IMPORTANT: To get sasldb running, make sure that you set the SASL -domain (realm) to a fully qualified domain name.
+EXAMPLE:
+- --
+- (Cyrus SASL version 1.5.x) -
- -
-% saslpasswd -c -u `postconf -h myhostname` exampleuser -+MySQL, PostgreSQL, SQLite -- (Cyrus SASL version 2.1.x) -
- -
-% saslpasswd2 -c -u `postconf -h myhostname` exampleuser -+sql -You can find out SASL's idea about the realms of the users -in sasldb with sasldblistusers (Cyrus SASL version 1.5.x) or -sasldblistusers2 (Cyrus SASL version 2.1.x).
+- -On the Postfix side, you can have only one realm per smtpd(8) -instance, and only the users belonging to that realm would be able to -authenticate. The Postfix variable smtpd_sasl_local_domain controls the -realm used by smtpd(8):
+LDAP --+-/etc/postfix/main.cf: - smtpd_sasl_local_domain = $myhostname --ldapdb - +IMPORTANT: The Cyrus SASL password verification services pwcheck -and saslauthd can only support the plaintext mechanisms PLAIN or -LOGIN. However, the Cyrus SASL library doesn't know this, and will -happily advertise other authentication mechanisms that the SASL -library implements, such as DIGEST-MD5. As a result, if a remote SMTP -client chooses any mechanism other than PLAIN or LOGIN while pwcheck -or saslauthd are used, authentication will fail. Thus you may need -to limit the list of mechanisms advertised by the Postfix SMTP -server.
++
+-With older Cyrus SASL versions you remove the corresponding -library files from the SASL plug-in directory (and again whenever -the system is updated).
+Note -With Cyrus SASL version 2.1.x or later the mech_list variable -can specify a list of authentication mechanisms that Cyrus SASL may -offer:
+Read the Cyrus SASL documentation for other backends it can +use.
----/usr/local/lib/sasl2/smtpd.conf: - mech_list: plain login -saslauthd - Cyrus SASL password verification service
-For the same reasons you might want to limit the list of plugins -used for authentication.
+Communication between the Postfix SMTP server (read: Cyrus SASL's +
-libsasl) and thesaslauthdserver takes +place over a UNIX-domain socket.+
++ +
saslauthdusually establishes the UNIX domain +socket in/var/run/saslauthd/and waits for authentication +requests. The Postfix SMTP server must have read+execute permission +to this directory or authentication attempts will fail.-+ +With Cyrus SASL version 1.5.x your only choice is to -delete the corresponding library files from the SASL plug-in -directory.
+Important -With SASL version 2.1.x:
+Some distributions require the user
+ +postfixto be +member of a special group e.g.sasl, otherwise it +will not be able to access thesaslauthdsocket +directory.The following example configures the Cyrus SASL library to +contact
saslauthdas its password verification service: +--/usr/local/lib/sasl2/smtpd.conf: - pwcheck_method: auxprop - auxprop_plugin: sql +/etc/sasl2/smtpd.conf: + pwcheck_method: saslauthd + mech_list: PLAIN LOGIN-To run software chrooted with SASL support is an interesting -exercise. It probably is not worth the trouble.
+Important -Testing SASL authentication in the Postfix -SMTP server
+Do not specify any other mechanisms in
-mech_list+thanPLAINorLOGINwhen using +saslauthd! It can only handle these two mechanisms, +and authentication will fail if clients are allowed to choose other +mechanisms.To test the server side, connect (for example, with telnet) to the -Postfix SMTP server port and you should -be able to have a conversation as shown below. Information sent by the -client (that is, you) is shown in bold font.
+---$ telnet server.example.com 25 -. . . -220 server.example.com ESMTP Postfix -EHLO client.example.com -250-server.example.com -250-PIPELINING -250-SIZE 10240000 -250-ETRN -250-AUTH DIGEST-MD5 PLAIN CRAM-MD5 -250 8BITMIME -AUTH PLAIN AHRlc3QAdGVzdHBhc3M= -235 Authentication successful --Instead of AHRlc3QAdGVzdHBhc3M=, specify the base64 encoded -form of \0username\0password (the \0 is a null byte). The -example above is for a user named `test' with password `testpass'. -
+Important -In order to generate base64 encoded authentication information -you can use one of the following commands:
+Plaintext mechanisms (
-PLAIN,LOGIN) +send credentials unencrypted. This information should be protected +by an additional security layer such as a TLS-encrypted SMTP session +(see: TLS_README).-+-% printf '\0username\0password' | mmencode -Additionally the
+saslauthdserver itself must be +configured. It must be told which authentication backend to turn +to for password verification. The backend is choosen as a command +line option whensaslauthdis started and will be shown +in the following examples.---% perl -MMIME::Base64 -e \ - 'print encode_base64("\0username\0password");' -+ +Note + +Some distributions use a configuration file to provide saslauthd +command line options to set e.g. the authentication backend. Typical +locations are
+/etc/sysconfig/saslauthdor +/etc/default/saslauthd.The mmencode command is part of the metamail software. -MIME::Base64 is available from http://www.cpan.org/.
+Using saslauthd with /etc/shadow
-Caution: when posting logs of the SASL negotiations to public -lists, -please keep in mind that username/password information is trivial -to recover from the base64-encoded form.
+Access to the
-/etc/shadowsystem password file +requiresrootprivileges. The Postfix SMTP server +(and in consequencelibsasllinked to the server) runs +with the least privilege possible. Direct access to +/etc/shadowwould not be possible without breaking the +Postfix security architecture.Trouble shooting the SASL internals
+The
-saslauthdsocket builds a safe bridge. Postfix, +running as limited userpostfix, can access the +UNIX-domain socket thatsaslauthdreceives commands +on;saslauthd, running as privileged userroot, +has the privileges required to access the shadow file.In the Cyrus SASL sources you'll find a subdirectory named -"sample". Run make there, then create a symbolic link from sample.conf -to smtpd.conf in your Cyrus SASL library directory /usr/local/lib/sasl2. -"su" to the user postfix (or whatever your mail_owner -directive is set to):
+The
saslauthdserver verifies passwords against the +authentication backend/etc/shadowif started like this:--% su postfix +%saslauthd -a shadowthen run the resulting sample Cyrus SASL server and client in -separate terminals. The sample applications send log messages to -the syslog -facility auth. Check the log to fix the problem or run strace / -ktrace / truss on the server to see what makes it unhappy. Repeat -the previous step until you can successfully authenticate with the -sample Cyrus SASL client. Only then get back to Postfix.
+See section "Testing saslauthd +authentication" for test instructions.
-Enabling SASL authentication in the -Postfix SMTP client
+Using saslauthd with PAM
-Turn on client-side SASL authentication, and specify a table -with per-host or per-destination username and password information. -The Postfix SMTP client first searches the table for an entry with -the remote SMTP server hostname; if no entry is found, then the -Postfix SMTP client searches the table for -an entry with the next-hop destination. Usually, that is the -right-hand part of an email address, but it can also be the information -that is specified with the relayhost parameter or with a transport(5) -table.
+Cyrus SASL can use the PAM framework to authenticate credentials. +
saslauthduses the PAM framework when started like +this:--/etc/postfix/main.cf: - smtp_sasl_auth_enable = yes - smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd - smtp_sasl_type = cyrus - relayhost = [mail.myisp.net] - # Alternative form: - # relayhost = [mail.myisp.net]:submission - -/etc/postfix/sasl_passwd: - [mail.myisp.net] username:password - [mail.myisp.net]:submission username:password +%saslauthd -a pamNotes:
- -+
+ --The "submission" destination port tells Postfix to send -mail via TCP network port 587, which is normally reserved for email -clients. The default is to send mail to the "smtp" destination port -(TCP port 25), which is used for receiving mail across the internet. -If you use an explicit destination port in main.cf, then you must -use the same form also in the smtp_sasl_password_maps file.
- -Postfix does not deliver mail via TCP port 465 (the obsolete -"wrappermode" protocol). See TLS_README for a solution that uses the -"stunnel" command.
- -The "[" and "]" prevent Postfix from looking up the MX -(mail exchanger) records for the enclosed name. If you use this -form in main.cf, then you must use the same form also in the -smtp_sasl_password_maps file.
- -The Postfix SMTP client opens the SASL client password -file before entering the optional chroot jail, so you can keep the -file in /etc/postfix and set permissions read / write only for root -to keep the username:password combinations away from other system -users.
- -Specify dbm instead of hash if your system -uses dbm files instead of db files. To find out what -lookup tables Postfix supports, use the command "postconf -m". -
+Note -Execute the command "postmap /etc/postfix/sasl_passwd" -whenever you change the sasl_passwd table.
+PAM configuration for the Postfix SMTP server is usually given +in
-/etc/pam.d/smtpand is beyond the scope of this +document.Workarounds:
+See section "Testing saslauthd +authentication" for test instructions.
-+
+Using saslauthd with an IMAP server
-Some remote SMTP servers support PLAIN or LOGIN authentication only. -By default, the Postfix SMTP client does not use authentication -methods that send plaintext passwords, and defers delivery with -the following error message: "Authentication failed: cannot SASL -authenticate to server". To enable plaintext authentication specify, -for example:
+
saslauthdcan verify the SMTP client credentials +by using them to log into an IMAP server. If the login succeeds, +SASL authentication also succeeds.saslauthdcontacts +an IMAP server when started like this:--/etc/postfix/main.cf: - smtp_sasl_security_options = noanonymous +%saslauthd -a rimap -O imap.example.comSome remote SMTP servers announce authentication mechanisms -that don't actually work. It is possible via the smtp_sasl_mechanism_filter -parameter to restrict the list of server mechanisms that the Postfix -SMTP client will take into consideration:
----/etc/postfix/main.cf: - smtp_sasl_mechanism_filter = !gssapi, !external, static:all -+ +Note + +The option "
+-O imap.example.com" specifies the +IMAP serversaslauthdshould contact when it verifies +credentials.In the above example, the Postfix SMTP client will decline to -use mechanisms -that require special infrastructure such as Kerberos or TLS.
+-The Postfix SMTP client is backwards compatible with SMTP -servers that use the non-standard "AUTH=method..." syntax in response -to the EHLO command; there is no Postfix client configuration needed -to work around it.
+Important --
saslauthdsends IMAP login information unencrypted. +Any IMAP session leaving the local host should be protected by an +additional security layer such as an SSL tunnel.Supporting multiple ISP accounts -in the Postfix SMTP client
+ -Postfix version 2.3 supports multiple ISP accounts. This can -be useful when one person uses the same machine for work and for -personal use, or when people with different ISP accounts share the -same Postfix server. To make this possible, Postfix 2.3 supports -per-sender SASL passwords and per-sender relay hosts. In the example -below, Postfix will search the SASL password file by sender before -it searches that same file by destination. Likewise, Postfix will -search the per-sender relayhost file, and use the default relayhost -only as a final resort.
+See section "Testing saslauthd +authentication" for test instructions.
--+ +-/etc/postfix/main.cf: - smtp_sender_dependent_authentication = yes - sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay - smtp_sasl_auth_enable = yes - smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd - relayhost = [mail.myisp.net] - # Alternative form: - # relayhost = [mail.myisp.net]:submission +Testing saslauthd authentication
-/etc/postfix/sasl_passwd: - # Per-sender authentication; see also /etc/postfix/sender_relay. - user1@example.com username2:password2 - user2@example.net username2:password2 - # Login information for the default relayhost. - [mail.myisp.net] username:password - [mail.myisp.net]:submission username:password +Cyrus SASL provides the
-/etc/postfix/sender_relay: - # Per-sender provider; see also /etc/postfix/sasl_passwd. - user1@example.com [mail.example.com]:submission - user2@example.net [mail.example.net] +testsaslauthdutility to +testsaslauthdauthentication. The username and password +are given as command line arguments. The example shows the response +when authentication is successful:+-+%testsaslauthd -u username -p password+0: OK "Success."Notes:
+--+Note -
If you are creative, then you can try to combine the two -tables into one single MySQL database, and configure different -Postfix queries to extract the appropriate information.
+Sometimes the
-testsaslauthdprogram is not distributed +with a the Cyrus SASL main package. In that case, it may be +distributed with -devel, -dev or -debug packages.Specify dbm instead of hash if your system -uses dbm files instead of db files. To find out what -lookup tables Postfix supports, use the command "postconf -m". -
+Execute the command "postmap /etc/postfix/sasl_passwd" -whenever you change the sasl_passwd table.
+Specify an additional "
--s smtp" ifsaslauthd+was configured to contact the PAM authentication framework and an +additional "-f /path/to/socketdir/mux" if +saslauthdestablishes the UNIX-domain socket in a +non-default location.Execute the command "postmap /etc/postfix/sender_relay" -whenever you change the sender_relay table.
+If authentication succeeds, proceed with the section "Enabling SASL authentication and authorization +in the Postfix SMTP server".
- +Cyrus SASL Plugins - auxiliary property +plugins
-Credits
+Cyrus SASL uses a plugin infrastructure (called
-auxprop) +to expandlibsasl's capabilities. Currently Cyrus +SASL sources provide three authentication plugins.+
+ - +-- Postfix SASL support was originally implemented by Till Franke -of SuSE Rhein/Main AG. +
-
- Wietse trimmed down the code to only the bare necessities. +
- sasldb
-- Support for Cyrus SASL version 2 was contributed by Jason Hoos. +
- -
Accounts are stored stored in a Cyrus SASL Berkeley DB +database
- Liviu Daia added smtpd_sasl_application_name, split -reject_sender_login_mismatch into -reject_authenticated_sender_login_mismatch and -reject_unauthenticated_sender_login_mismatch, and revised the docs. +
- sql
-- Wietse made another iteration through the code to add plug-in -support for multiple SASL implementations, and changed -smtpd_sasl_application_name into smtpd_sasl_path. +
- -
Accounts are stored in a SQL database
- The Dovecot SMTP server-only plug-in was originally implemented by -Timo Sirainen of Procontrol, Finland. +
- ldapdb
-- Patrick Ben Koetter revised this document for Postfix 2.4 and -made much needed updates. +
- -
Accounts are stored stored in an LDAP database
+ +Important + ++ +These three plugins support shared-secret mechanisms i.e. +CRAM-MD5, DIGEST-MD5 and NTLM. These mechanisms send credentials +encrypted but their verification process requires the password to +be available in plaintext. Consequently passwords cannot (!) be +stored in encrypted form.
+ +The sasldb plugin
+ +The sasldb auxprop plugin authenticates credentials stored in a Berkeley +DB database. The database schema is specific to Cyrus SASL. The +database is usually located at
+ +/etc/sasldb2.+ +Note + ++ +The
+ +sasldb2file contains passwords in +plaintext, and should have read+write access only to user +postfixor a group thatpostfixis member +of.The
+ +saslpasswd2command-line utility creates +and maintains the database:++ ++% saslpasswd2 -c -u example.com username +Password: +Again (for verification): ++This command creates an account +
+ +username@example.com.+ +Important + ++ +users must specify
+ +username@example.com+as login name, notusername.Run the following command to reuse the Postfix
+ +mydomain+parameter value as the login domain:++ ++% saslpasswd2 -c -u `postconf -h mydomain` username +Password: +Again (for verification): +++ +Note + ++ +Run
+ +saslpasswd2without any options for further +help on how to use the command.The
+ +sasldblistusers2command lists all existing +users in the sasldb database:++ ++% sasldblistusers2 +username1@example.com: password1 +username2@example.com: password2 ++Configure libsasl to use sasldb with the following instructions:
+ +++ ++/etc/sasl2/smtpd.conf: + pwcheck_method: auxprop + auxprop_plugin: sasldb + mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5 NTLM +++ +Note + ++ +In the above example adjust
+ +mech_listto the +mechanisms that are applicable for your environment.The sql plugin
+ +The sql auxprop plugin is a generic SQL plugin. It provides +access to credentials stored in a MySQL, a PostgreSQL or a SQLite +database.
+ ++ +Note + ++ +The shared-secret mechanisms (CRAM-MD5, etc.) require that the +SASL client passwords are stored as plaintext.
+ ++ +Tip + + + ++ +Use "saslauthd > pam > (pam database module)" to +verify encrypted passwords in an SQL database.
+ +The following example configures libsasl to use the sql plugin and connects +it to a PostgreSQL server:
+ +++ ++/etc/sasl2/smtpd.conf: + pwcheck_method: auxprop + auxprop_plugin: sql + mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5 NTLM + sql_engine: pgsql + sql_hostnames: 127.0.0.1, 192.0.2.1 sql_user: username + sql_passwd: secret + sql_database: dbname + sql_select: SELECT password FROM users WHERE user = '%u'@'%r' +++ +Note + ++ +Set appropriate permissions if
+ +smtpd.confcontains +a password. The file should be readable by thepostfix+user.+ +Note + ++ +In the above example, adjust
+ +mech_listto the +mechanisms that are applicable for your environment.The sql plugin has the following configuration options:
+ ++ ++ ++ +
+ +- sql_engine
+ +- + +
+ +Specify
+ +mysqlto connect to a MySQL server, +pgsqlfor a PostgreSQL server orsqlite+for an SQLite database- sql_hostnames
+ +- + +
+ +Specify one or more servers (hostname or hostname:port) separated +by commas.
+ ++ +Note + ++ +With MySQL servers, specify
+ +localhostto connect +over a UNIX-domain socket, and specify127.0.0.1to +connect over a TCP socket.- sql_user
+ +- + +
+ +The login name to gain access to the database.
+ +- sql_passwd
+ +- + +
+ +The password to gain access to the database.
+ +- sql_database
+ +- + +
+ +The name of the database to connect to.
+ +- sql_select
+ +- + +
+ +The SELECT statement that should retrieve the plaintext password +from a database table.
+ ++ +Important + ++ +Do not enclose the statement in quotes! Use single quotes to +escape macros!
+ +The sql plugin provides macros to build
+ +sql_select+statements. They will be replaced with arguments sent from the client. The +following macros are available:+ ++ ++ +
+ +- %u
+ +- + +
+ +The name of the user whose properties are being selected.
+ +- %p
+ +- + +
+ +The name of the property being selected. While this could technically be +anything, Cyrus SASL will try userPassword and cmusaslsecretMECHNAME (where +MECHNAME is the name of a SASL mechanism).
+ +- %r
+ +- + +
+ +The name of the realm to which the user belongs. This could be +the KERBEROS realm, the fully-qualified domain name of the computer +the SASL application is running on, or the domain after the "@" in a +username.
+ +The ldapdb plugin
+ +The ldapdb auxprop plugin provides access to credentials stored +in an OpenLDAP LDAP server. It is the only plugin that implements +proxy authorization.
+ +Proxy authorization in this context means: The ldapdb plugin +must SASL authenticate with the OpenLDAP server. The server then +decides if the ldapdb plugin should be authorized to read the +authenticating user's password. Once the ldapdb plugin has gone +through proxy authorization it may proceed and authenticate the +remote SMTP client's credentials.
+ +In a nutshell: Configuring ldapdb means authentication and +authorization must be configured twice - once in the Postfix SMTP +server to authenticate and authorize the remote SMTP client, and +once in the OpenLDAP
+ +slapdserver to authenticate and +authorize the ldapdb plugin.This example configures libsasl to use the ldapdb plugin and +the plugin to connect to an OpenLDAP server:
+ +++ ++/etc/sasl2/smtpd.conf: + pwcheck_method: auxprop + auxprop_plugin: ldapdb + mech_list: PLAIN LOGIN NTLM CRAM-MD5 DIGEST-MD5 + ldapdb_uri: ldap://localhost + ldapdb_id: proxyuser + ldapdb_pw: password + ldapdb_mech: DIGEST-MD5 +++ +Important + ++ +Set appropriate permissions if
+ +smtpd.confcontains a +password. The file should be readable by thepostfix+user.+ +Note + ++ +The shared-secret mechanisms (CRAM-MD5, etc.) require that the +SASL client passwords are stored as plaintext.
+ +The following is a summary of applicable
+ +smtpd.conf+file entries:+ ++ ++ +
+ +- auxprop_plugin
+ +- + +
Specify
ldapdbto enable the plugin.- ldapdb_uri
+ +- + +
Specify either
ldapi://for to connect over +a UNIX-domain socket,ldap://for an unencrypted TCP +connection orldaps://for an encrypted TCP connection. +- ldapdb_id
+ +- + +
The login name to authenticate the ldapdb plugin to the +LDAP server (proxy authorization).
- ldapdb_pw
+ +- + +
The password (in plaintext) to authenticate the ldapdb +plugin to the LDAP server (proxy authorization).
- ldapdb_mech
+ +- + +
The mechanism to authenticate the ldapdb plugin to the +OpenLDAP slapd server.
+ ++ +Note + ++ +Specify a mechanism here that is supported by the OpenLDAP slapd +server.
+ +- ldapdb_rc (optional)
+ +- + +
The path to a file containing individual configuration +options for the ldapdb LDAP client (libldap). This allows to specify +a TLS client certificate which in turn can be used to use the SASL +EXTERNAL mechanism.
+ ++ +Note + ++ +This mechanism supports authentication over an encrypted transport +layer, which is recommended if the plugin must connect to an OpenLDAP +server on a remote machine.
+ +- ldapdb_starttls (optional)
+ +- + +
The TLS policy for connecting to the LDAP server. Specify +either
tryordemand. If the option is +trythe plugin will attempt to establish a TLS-encrypted +connection with the LDAP server, and will fallback to an unencrypted +connection if TLS fails. If the policy isdemandand +a TLS-encrypted connection cannot be established, the connection +fails immediately.When the ldapdb plugin connects to the OpenLDAP server and +successfully authenticates, the OpenLDAP server decides if the +plugin user is authorized to read SASL account information.
+ +The following configuration gives an example of authorization configuration +in the OpenLDAP slapd server:
+ +++ ++/etc/openldap/slapd.conf: + authz-regexp + uid=(.*),cn=.*,cn=auth + ldap:///dc=example,dc=com??sub?cn=$1 + authz-policy to ++Here, the
+ +authz-regexpoption serves for authentication +of the ldapdb user. It maps its login name to a DN in the LDAP +directory tree whereslapdcan look up the SASL account +information. Theauthz-policyoptions defines the +authentication policy. In this case it grants authentication +privileges "to" the ldapdb plugin.The last configuration step is to tell the OpenLDAP
+ +slapd+server where ldapdb may search for usernames matching the one given +by the mail client. The example below adds an additional attribute +ldapdb user object (here:authzTobecause the authz-policy +is "to") and configures the scope where the login name +"proxyuser" may search:++ ++dn: cn=proxyuser,dc=example,dc=com +changetype: modify +add: authzTo +authzTo: dn.regex:uniqueIdentifier=(.*),ou=people,dc=example,dc=com ++Use the
+ +ldapmodifyorldapaddcommand +to add the above attribute.+ +Note + ++ +Read the chapter "Using SASL" in the OpenLDAP Admin Guide +for more detailed instructions to set up SASL authentication in +OpenLDAP.
+ +Enabling SASL authentication and +authorization in the Postfix SMTP server
+ +By default the Postfix SMTP server uses the Cyrus SASL +implementation. If the Dovecot SASL implementation should be used, +specify an
+ +smtpd_sasl_typevalue ofdovecot+instead ofcyrus:++ ++/etc/postfix/main.cf: + smtpd_sasl_type = dovecot ++Additionally set the path where the Postfix SMTP server can +find the Dovecot SASL socket:
+ +++ ++/etc/postfix/main.cf: + smtpd_sasl_path = private/auth +++ +Note + ++ +This example uses a pathname relative to the Postfix queue +directory, so that it will work whether or not the Postfix SMTP +server runs chrooted.
+ +Enabling SASL authentication +in the Postfix SMTP server
+ +Regardless of the SASL implementation type, enabling SMTP +authentication in the Postfix SMTP server always requires seting +the
+ +smtpd_sasl_auth_enableoption:++ ++/etc/postfix/main.cf: + smtpd_sasl_auth_enable = yes ++After a "postfix reload", SMTP clients will see the additional +capability AUTH in an SMTP session, followed by a list of +authentication mechanisms the server supports:
+ +++ ++% telnet server.example.com 25 +... +220 server.example.com ESMTP Postfix +EHLO client.example.com +250-server.example.com +250-PIPELINING +250-SIZE 10240000 +250-AUTH DIGEST-MD5 PLAIN CRAM-MD5 +... ++However not all clients recognize the AUTH capability as defined +by the SASL authentication RFC. Some historical implementations expect the +server to send an "
+ +=" as separator between the AUTH +verb and the list of mechanisms that follows it.The
+ +broken_sasl_auth_clientsconfiguration option +lets Postfix repeat the AUTH statement in a form that these broken +clients understand:++ ++/etc/postfix/main.cf: + broken_sasl_auth_clients = yes +++ +Note + ++ +Enable this option for Outlook up to and including version 2003 +and Outlook Express up to version 6. This option does not hurt other +clients.
+ +After "postfix reload", the Postfix SMTP server will propagate +the AUTH capability twice - once for compliant and once for broken +clients:
+ +++ ++% telnet server.example.com 25 +... +EHLO client.example.com +250-server.example.com +250-PIPELINING +250-SIZE 10240000 +250-AUTH DIGEST-MD5 PLAIN CRAM-MD5 +250-AUTH=DIGEST-MD5 PLAIN CRAM-MD5 +... ++Postfix SMTP Server +Authentication Policy
+ +The Postfix SMTP server provides a way to specify the properties +of SASL mechanisms that can be made available to the remote SMTP +client.
+ +Unencrypted SMTP session
+ +The default policy is to allow any mechanism in the Postfix SMTP server +except for those based on anonymous authentication:
+ +++ ++/etc/postfix/main.cf: + # Specify a list of properties separated by comma or whitespace + smtpd_sasl_security_options = noanonymous +++ +Important + ++ +Always set at least the
+ +noanonymousoption. +Otherwise, the Postfix SMTP server can give strangers the same +authorization as a properly-authenticated client.Postfix can enforce the following policies on SASL authentication +mechanisms:
+ ++ ++ ++ +
+ +- noanonymous
+ +- + +
Don't use mechanisms that permit anonymous authentication. +
- noplaintext
+ +- + +
Don't use mechanisms that transmit unencrypted username +and password information.
- nodictionary
+ +- + +
Don't use mechanisms that are vulnerable to dictionary +attacks.
+ +- forward_secrecy
+ +- + +
Use only mechanisms that support forward secrecy (Dovecot +SASL only).
+ +- mutual_auth
+ +- + +
Use only mechanisms that authenticate both the client and +the server to each other.
Encrypted SMTP session (TLS)
+ +A separate parameter controls Postfix SASL mechanism policy +during a TLS-encrypted SMTP session. The default is to copy the +settings from the unencrypted session:
+ +++ ++/etc/postfix/main.cf: + smtpd_sasl_tls_security_options = $smtpd_sasl_security_options ++A more sophisticated policy allows plaintext mechanisms, but +only over a TLS-encrypted connection:
+ +++ ++/etc/postfix/main.cf: + smtpd_sasl_security_options = noanonymous, noplaintext + smtpd_sasl_tls_security_options = noanonymous ++To offer SASL authentication only after a TLS-encrypted session has been +established specify this:
+ +++ ++/etc/postfix/main.cf: + smtpd_tls_auth_only = yes ++Enabling SASL authorization in the Postfix +SMTP server
+ +After the client has authenticated with SASL, the Postfix SMTP +server decides what the remote SMTP client will be authorized +for. Examples of possible SMTP clients authorizations are:
+ ++ +
+ +- + +
Send a message to a remote recipient.
- + +
Use a specific envelope sender in the MAIL FROM command.
These permissions are not enabled by default.
+ +Mail relay authorization
+ +The
+ +permit_sasl_authenticatedrestriction allows +SASL-authenticated SMTP clients to send mail to remote destinations. +Add it to the list ofsmtpd_recipient_restrictionsas +follows:++ ++/etc/postfix/main.cf: + smtpd_recipient_restrictions = + ... + permit_mynetworks + permit_sasl_authenticated + reject_unauth_destination + ... ++Envelope sender address authorization
+ +By default an SMTP client may specify any envelope sender address +in the MAIL FROM command. That is because the Postfix SMTP server +only knows the remte SMTP client hostname and IP address, but not +the user who controls the remote SMTP client.
+ +This changes the moment an SMTP client uses SASL authentication. +Now, the Postfix SMTP server knows who the sender is. Given a table +of envelope sender addresses and SASL login names, the Postfix SMTP +server can decide if the SASL authenticated client is allowed to +use a particular envelope sender address:
+ +++ ++/etc/postfix/main.cf: + smtpd_sender_login_maps = hash:/etc/postfix/controlled_envelope_senders + + smtpd_recipient_restrictions = + ... + reject_sender_login_mismatch + permit_sasl_authenticated + permit_mynetworks + reject_unauth_destination + ... ++The
+ +controlled_envelope_senderstable specifies +the binding between the sender envelope addresses and its their +SASL login names:++ ++/etc/postfix/controlled_envelope_senders + # envelope sender owners (SASL login names) + john@example.com john@example.com + helpdesk@example.com john@example.com, mary@example.com + postmaster admin@example.com + @example.net barney, fred, john@example.com, mary@example.com ++With this, the
+ +reject_sender_login_mismatch+restriction above will reject the sender address in the MAIL FROM +command ifsmtpd_sender_login_mapsdoes not specify +the SMTP client's login name as an owner of that address.See also
+ +reject_authenticated_sender_login_mismatchand +reject_unauthenticated_sender_login_mismatchfor additional +control over the SASL login name and the envelope sender.Additional SMTP Server SASL options
+ +Postfix provides a wide range of SASL authentication configuration +options. The next section lists a few that are discussed frequently. +See postconf(5) for a complete list.
+ +Default authentication domain
+ +Postfix can append a domain name (or any other string) to a +SASL login name that does not have a domain part, e.g. "
+ +john" +instead of "john@example.com":++ ++/etc/postfix/main.cf: + smtpd_sasl_local_domain = example.com ++This is useful as a default setting and safety net for misconfigured +clients, or during a migration to an authentication method/backend +that requires an authentication REALM or domain name, before all +SMTP clients are configured to send such information.
+ +Hiding SASL authentication from clients or +networks
+ +Some clients insist on using SASL authentication if it is offered, even +when they are not configured to send credentials - and therefore +they will always fail and disconnect.
+ +Postfix can hide the AUTH capability from these clients/networks:
+ +++ ++/etc/postfix/main.cf: + smtpd_sasl_exceptions_networks = !192.0.2.171/32, 192.0.2.0/24 ++Adding the SASL login name to mail headers
+ +To report SASL login names in Received: message headers (Postfix +version 2.3 and later):
+ +++ ++/etc/postfix/main.cf: + smtpd_sasl_authenticated_header = yes +++ +Note + ++ +The SASL login names will be shared with the entire world.
+ +Testing SASL authentication in the Postfix SMTP Server
+ +To test the server side, connect (for example, with +
+ +telnet) to the Postfix SMTP server port and you should +be able to have a conversation as shown below. Information sent by +the client (that is, you) is shown in bold font.++ ++% telnet server.example.com 25 +... +220 server.example.com ESMTP Postfix +EHLO client.example.com +250-server.example.com +250-PIPELINING +250-SIZE 10240000 +250-ETRN +250-AUTH DIGEST-MD5 PLAIN CRAM-MD5 +250 8BITMIME +AUTH PLAIN AHRlc3QAdGVzdHBhc3M= +235 Authentication successful ++Instead of
+AHRlc3QAdGVzdHBhc3M=, specify the +base64-encoded form of\0username\0password(the \0 +is a null byte). The example above is for a user named `test' +with password `testpass'.+ +Caution + ++ +When posting logs of the SASL negotiations to public lists, +please keep in mind that username/password information is trivial +to recover from the base64-encoded form.
+ +You can use one of the following commands to generate base64 +encoded authentication information:
+ +++ ++% gen-auth plain +username: username +password: ++The gen-auth Perl script was written by John +Jetmore and can be found at http://jetmore.org/john/code/gen-auth.
+ +++ ++% printf '\0username\0password' | mmencode ++The mmencode command is part of the metamail +software.
+ +++ ++% perl -MMIME::Base64 -e \ + 'print encode_base64("\0username\0password");' ++MIME::Base64 is available from http://www.cpan.org/.
+ +Configuring SASL authentication in the Postfix SMTP/LMTP client
+ +The Postfix SMTP and the LMTP client can authenticate with a +remote SMTP server via the Cyrus SASL framework. At this time, the +Dovecot SASL implementation does not provide client functionality. +
+ ++ +Note + ++ +The examples in this section discuss only the SMTP client. +Replace
+ +smtp_withlmtp_to get the +corresponding LMTP client configuration.You can read more about the following topics:
+ ++ +
+ +- Enabling SASL authentication in +the Postfix SMTP/LMTP client
+ +- Configuring sender-dependent SASL +authentication
+ +- Postfix SMTP/LMTP client +authentication policy
+ +- Filtering server mechanism names +in the Postfix SMTP/LMTP client
+ +Enabling SASL authentication in the +Postfix SMTP/LMTP client
+ +This section shows a typical scenario where the Postfix SMTP +client sends all messages via a mail gateway server that requires +SASL authentication. To make the example more readable we introduce +it in two parts.
+ +++ ++/etc/postfix/main.cf: + smtp_sasl_auth_enable = yes + relayhost = [mail.isp.example] + # Alternative form: + # relayhost = [mail.isp.example]:submission + smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd +++ +
+ +- + +
The
+smtp_sasl_auth_enablesetting enables +client-side authentication. We will configure the client's username +and password information in the second part of the example.- + +
The
relayhostsetting forces the Postfix SMTP +to send all remote messages to the specified mail server instead +of trying to deliver them directly to their destination.- + +
In the
relayhostsetting, the "[" +and "]" prevent the Postfix SMTP client from looking +up MX (mail exchanger) records for the enclosed name.- + +
The
relayhostdestination may also specify a +non-default TCP port. For example, the alternative form +[mail.isp.example]:submissiontells Postfix to connect +to TCP network port 587, which is reserved for email client +applications.- + +
The Postfix SMTP client is compatible with SMTP servers +that use the non-standard "
AUTH=method...." +syntax in response to the EHLO command; this requires no additional +Postfix client configuration.- + +
The Postfix SMTP client does not support the obsolete +"wrappermode" protocol, which uses TCP port
465on the +SMTP server. See TLS_README for a solution that uses the +stunnelcommand.With the
+ +smtp_sasl_password_mapsparameter, +we configure the Postfix SMTP client to send username and password +information to the mail gateway server. As discussed in the next +section, the Postfix SMTP client supports multiple ISP accounts. +For this reason the username and password are stored in a table +that contains one username/password combination for each mail gateway +server.++ ++/etc/postfix/sasl_passwd: + # destination credentials + [mail.isp.example] username:password + # Alternative form: + # [mail.isp.example]:submission username:password +++ +Important + ++ +Keep the SASL client password file in
+ +/etc/postfix, +and make the file read+write only forrootto protect +the username/password combinations against other users. The Postfix +SMTP client will still be able to read the SASL client passwords. +It opens the file as userrootbefore it drops privileges, +and before entering an optional chroot jail.+ +
+ +- + +
Use the
postmapcommand whenever you +change the/etc/postfix/sasl_passwdfile.- + +
If you specify the "
+[" and "]" +in therelayhostdestination, then you must use the +same form in thesmtp_sasl_password_mapsfile.- + +
If you specify a non-default TCP Port (such as +"
:submission" or ":587") in the +relayhostdestination, then you must use the same form +in thesmtp_sasl_password_mapsfile.Configuring Sender-Dependent SASL +authentication
+ +Postfix supports different ISP accounts for different sender +addresses (version 2.3 and later). This can be useful when one +person uses the same machine for work and for personal use, or when +people with different ISP accounts share the same Postfix server. +
+ +To make this possible, Postfix supports per-sender SASL passwords +and per-sender relay hosts. In the example below, the Postfix SMTP +client will search the SASL password file by sender address before +it searches that same file by destination. Likewise, the Postfix +trivial-rewrite(8) daemon will search the per-sender relayhost file, +and use the default
+ +relayhostsetting only as a final +resort.++ ++/etc/postfix/main.cf: + smtp_sender_dependent_authentication = yes + sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay + smtp_sasl_auth_enable = yes + smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd + relayhost = [mail.isp.example] + # Alternative form: + # relayhost = [mail.isp.example]:submission ++++ ++/etc/postfix/sasl_passwd: + # Per-sender authentication; see also /etc/postfix/sender_relay. + user1@example.com username2:password2 + user2@example.net username2:password2 + # Login information for the default relayhost. + [mail.isp.example] username:password + # Alternative form: + # [mail.isp.example]:submission username:password ++++ ++/etc/postfix/sender_relay: + # Per-sender provider; see also /etc/postfix/sasl_passwd. + user1@example.com [mail.example.com]:submission + user2@example.net [mail.example.net] +++ +
+ +If you are creative, then you can try to combine the two +tables into one single MySQL database, and configure different +Postfix queries to extract the appropriate information.
+ +Specify dbm instead of hash if your system uses dbm files +instead of db files. To find out what lookup tables Postfix supports, +use the command "postconf -m".
+ +Execute the command "postmap /etc/postfix/sasl_passwd" +whenever you change the sasl_passwd table.
+ +Execute the command "postmap /etc/postfix/sender_relay" +whenever you change the sender_relay table.
+ +Postfix SMTP/LMTP client authentication +policy
+ +Just like the Postfix SMTP server, the SMTP client has a policy +that determines which SASL mechanisms are acceptable and which are +not.
+ +Unencrypted SMTP session
+ +The default policy is stricter than that of the Postfix SMTP +server - plaintext mechanisms are not allowed (nor is any anonymous +mechanism):
+ +++ ++/etc/postfix/main.cf: + smtp_sasl_security_options = noplaintext, noanonymous ++Postfix can enforce the following policies on SASL authentication +mechanisms:
+ ++ ++ ++ +
+ +- noanonymous
+ +- + +
Don't use mechanisms that permit anonymous authentication. +
- noplaintext
+ +- + +
Don't use mechanisms that transmit unencrypted username +and password information.
- nodictionary
+ +- + +
Don't use mechanisms that are vulnerable to dictionary +attacks.
+ +- +
- mutual_auth
+ +- + +
Use only mechanisms that authenticate both the client and +the server to each other.
With the default policy shown above, the Postfix SMTP client +will not send its password over an unencrypted connection. This +sometimes leads to authentication failures if the remote server +only offers plaintext authentication mechanisms. In such cases the +SMTP client will log the following error message:
+ +++ ++SASL authentication failure: No worthy mechs found ++The less secure approach to deal with this is to lower the +security standards and permit plaintext authentication mechanisms: +
+ +++ ++/etc/postfix/main.cf: + smtp_sasl_security_options = noanonymous ++Needless to say, sending a username and password over an insecure +channel is undesirable.
+ +If the remote server supports TLS, you can protect the plaintext +username and password by turning on TLS in the Postfix SMTP client +(see: TLS_README), and configuring the client as discussed next. + +
Encrypted SMTP session (TLS)
+ +A separate parameter controls Postfix SASL mechanism policy +during a TLS-encrypted SMTP session. The default is to copy the +settings from the unencrypted session:
+ +++ ++/etc/postfix/main.cf: + smtp_sasl_tls_security_options = $smtp_sasl_security_options ++A more sophisticated policy allows plaintext mechanisms, but +only over a TLS-encrypted connection:
+ +++ ++/etc/postfix/main.cf: + smtpd_sasl_security_options = noanonymous, noplaintext + smtpd_sasl_tls_security_options = noanonymous ++Filtering server mechanism names in +the Postfix SMTP/LMTP client
+ +Cyrus SASL always attempts to use the most secure authentication +mechanism that the remote SMTP server offers - even if the client +side was not configured to handle it! In such cases authentication +will definitely fail.
+ +To prevent this, the Postfix SMTP client can filter the list +of authentication mechanism names from the remote SMTP server. Used +correctly, the filter hides unwanted mechanisms from the Cyrus SASL +library, forcing the library to choose from the mechanisms the +Postfix filter passes through.
+ +The following example filters out everything but the mechanisms +
+ +PLAINandLOGIN:++ ++/etc/postfix/main.cf: + smtp_sasl_mechanism_filter = plain, login +++ +Note + ++ +If the remote server does not offer any of the mechanisms on +the filter list, authentication will fail.
+ +We close this section with an example that passes every mechanism +except for
+ +GSSAPIandLOGIN:++ ++/etc/postfix/main.cf: + smtp_sasl_mechanism_filter = !gssapi, !login, static:all ++Building Postfix with SASL support
+ +As mentioned elsewhere, Postfix supports two SASL implementations: +Cyrus SASL (SMTP client and server) and Dovecot SASL (SMTP server +only). Both implementations can be built into Postfix simultaneously. +
+ + + +Building Dovecot SASL support
+ +These instructions assume that you build Postfix from source +code as described in the INSTALL document. Some modification may +be required if you build Postfix from a vendor-specific source +package.
+ +Support for the Dovecot version 1 SASL protocol is available +in Postfix 2.3 and later. At the time of writing, only server-side +SASL support is available, so you can't use it to authenticate the +Postfix SMTP client to your network provider's server.
+ +Dovecot uses its own daemon process for authentication. This +keeps the Postfix build process simple, because there is no need +to link extra libraries into Postfix.
+ +To generate the necessary Makefiles, execute the following in +the Postfix top-level directory:
+ +++ ++% make tidy # if you have left-over files from a previous build +% make makefiles CCARGS='-DUSE_SASL_AUTH \ + -DDEF_SERVER_SASL_TYPE=\"dovecot\"' ++After this, proceed with "
+ +Note + +make" as described in +the INSTALL document.+ +
+ +- + +
+ +The
+ +-DDEF_SERVER_SASL_TYPE=\"dovecot\"is not +necessary; it just makes Postfix configuration a little more +convenient because you don't have to specify the SASL plug-in type +in the Postfix main.cf file (but this may cause surprises when you +switch to a later Postfix version that is built with the default +SASL type ofsasl).- + +
+ +If you also want support for LDAP or TLS (or for Cyrus SASL), +you need to merge their
+ +CCARGSandAUXLIBS+options into the above command line; see the LDAP_README and +TLS_README for details.++ ++% make tidy # if you have left-over files from a previous build +% make makefiles CCARGS='-DUSE_SASL_AUTH \ + -DDEF_SERVER_SASL_TYPE=\"dovecot\" \ + ...CCARGS options for LDAP or TLS etc....' \ + AUXLIBS='...AUXLIBS options for LDAP or TLS etc....' ++Building Cyrus SASL support
+ +Building the Cyrus SASL library
+ +Postfix works with cyrus-sasl-1.5.x or cyrus-sasl-2.1.x, which are +available from ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/.
+ ++ +Important + ++ +If you install the Cyrus SASL libraries as per the default, you will have +to create a symlink
+ +/usr/lib/sasl-> +/usr/local/lib/saslfor version 1.5.x or +/usr/lib/sasl2->/usr/local/lib/sasl2+for version 2.1.x.Reportedly, Microsoft Outlook (Express) requires the non-standard LOGIN +and/or NTLM authentication mechanism. To enable these authentication +mechanisms, build the Cyrus SASL libraries with:
+ +++ ++% ./configure --enable-login --enable-ntlm ++Building Postfix with Cyrus SASL support
+ +These instructions assume that you build Postfix from source +code as described in the INSTALL document. Some modification may +be required if you build Postfix from a vendor-specific source +package.
+ +The following assumes that the Cyrus SASL include files are in +
+ +/usr/local/include, and that the Cyrus SASL libraries are in +/usr/local/lib.On some systems this generates the necessary
+ +Makefile+definitions:+ +
+ +- Cyrus SASL version 2.1.x
+ +- + +
+ ++% make tidy # if you have left-over files from a previous build +% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \ + -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib -lsasl2" ++ +- Cyrus SASL version 1.5.x
+ +- + +
+ ++% make tidy # if you have left-over files from a previous build +% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \ + -I/usr/local/include" AUXLIBS="-L/usr/local/lib -lsasl" ++ +On Solaris 2.x you need to specify run-time link information, +otherwise the ld.so run-time linker will not find the SASL shared +library:
+ ++ +
+ +- Cyrus SASL version 2.1.x
+ +- + +
+ ++% make tidy # remove left-over files from a previous build +% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \ + -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib \ + -R/usr/local/lib -lsasl2" ++ +- Cyrus SASL version 1.5.x
+ +- + +
+ ++% make tidy # if you have left-over files from a previous build +% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL \ + -I/usr/local/include" AUXLIBS="-L/usr/local/lib \ + -R/usr/local/lib -lsasl" ++ +Using Cyrus SASL version 1.5.x
+ +Postfix supports Cyrus SASL version 1.x, but you shouldn't use +it unless you are forced to. The makers of Cyrus SASL write:
+ +This library is being deprecated and applications +should transition to using the SASLv2 library (source: Project Cyrus: +Downloads).+ +If you still need to set it up, here's a quick rundown:
+ +Read the regular section on SMTP server configurations for the +Cyrus SASL framework. The differences are:
+ ++ +
+ +- + +
Cyrus SASL version 1.5.x searches for configuration +(
smtpd.conf) in/usr/lib/sasl/only. You +must place the configuration in that directory. Some systems may +have modified Cyrus SASL and put the files into e.g. +/var/lib/sasl/.- + +
Use the
saslpasswdcommand instead of +saslpasswd2to create users insasldb. +- + +
Use the
sasldblistuserscommand instead of +sasldblistusers2to find users insasldb. +- + +
In the
smtpd.conffile you can't use +mech_listto limit the range of mechanisms offered. +Instead, remove their libraries from/usr/lib/sasl/+(and remember remove those files again when a system update +re-installs new versions).Credits
+ ++ +
+ +- Postfix SASL support was originally implemented by Till Franke +of SuSE Rhein/Main AG.
+ +- Wietse trimmed down the code to only the bare necessities. +
+ +- Support for Cyrus SASL version 2 was contributed by Jason Hoos. +
+ +- Liviu Daia added smtpd_sasl_application_name, separated +reject_sender_login_mismatch into +reject_authenticated_sender_login_mismatch and +reject_unauthenticated_sender_login_mismatch, and revised the docs. +
+ +- Wietse made another iteration through the code to add plug-in +support for multiple SASL implementations, and for reasons that +have been lost, also changed smtpd_sasl_application_name into +smtpd_sasl_path.
+ +- The Dovecot SMTP server-only plug-in was originally implemented +by Timo Sirainen of Procontrol, Finland.
+ +- Patrick Ben Koetter revised this document for Postfix 2.4 and +made much needed updates.
+ +- Patrick Ben Koetter revised this document again for Postfix +2.7 and made much needed updates.
+ +