<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd"> <html> <!-- Created on September, 10 2009 by texi2html 1.78 --> <!-- Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) Karl Berry <karl@freefriends.org> Olaf Bachmann <obachman@mathematik.uni-kl.de> and many others. Maintained by: Many creative people. Send bugs and suggestions to <texi2html-bug@nongnu.org> --> <head> <title>Specification of the Exim Mail Transfer Agent: 23. Environment for running local transports</title> <meta name="description" content="Specification of the Exim Mail Transfer Agent: 23. Environment for running local transports"> <meta name="keywords" content="Specification of the Exim Mail Transfer Agent: 23. Environment for running local transports"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="texi2html 1.78"> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} pre.display {font-family: serif} pre.format {font-family: serif} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: serif; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: serif; font-size: smaller} pre.smalllisp {font-size: smaller} span.roman {font-family:serif; font-weight:normal;} span.sansserif {font-family:sans-serif; font-weight:normal;} ul.toc {list-style: none} --> </style> </head> <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> <a name="Environment-for-local-transports"></a> <a name="SEC215"></a> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="spec_22.html#SEC214" title="Previous section in reading order"> < </a>]</td> <td valign="middle" align="left">[<a href="#SEC216" title="Next section in reading order"> > </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="spec_22.html#SEC204" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Up section"> Up </a>]</td> <td valign="middle" align="left">[<a href="spec_24.html#SEC220" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[Contents]</td> <td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <h1 class="chapter"> 23. Environment for running local transports </h1> <p>Local transports handle deliveries to files and pipes. (The <code>autoreply</code> transport can be thought of as similar to a pipe.) Exim always runs transports in subprocesses, under specified uids and gids. Typical deliveries to local mailboxes run under the uid and gid of the local user. </p> <p>Exim also sets a specific current directory while running the transport; for some transports a home directory setting is also relevant. The <code>pipe</code> transport is the only one that sets up environment variables; see section <a href="spec_29.html#SEC239">Environment variables</a> for details. </p> <p>The values used for the uid, gid, and the directories may come from several different places. In many cases, the router that handles the address associates settings with that address as a result of its <code>check_local_user</code>, <code>group</code>, or <code>user</code> options. However, values may also be given in the transport's own configuration, and these override anything that comes from the router. </p> <table class="menu" border="0" cellspacing="0"> <tr><td align="left" valign="top"><a href="#SEC216">23.1 Concurrent deliveries</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top"><a href="#SEC217">23.2 Uids and gids</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top"><a href="#SEC218">23.3 Current and home directories</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top"><a href="#SEC219">23.4 Expansion variables derived from the address</a></td><td> </td><td align="left" valign="top"> </td></tr> </table> <hr size="6"> <a name="Concurrent-deliveries"></a> <a name="SEC216"></a> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="#SEC215" title="Previous section in reading order"> < </a>]</td> <td valign="middle" align="left">[<a href="#SEC217" title="Next section in reading order"> > </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="#SEC215" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="#SEC215" title="Up section"> Up </a>]</td> <td valign="middle" align="left">[<a href="spec_24.html#SEC220" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[Contents]</td> <td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <h2 class="section"> 23.1 Concurrent deliveries </h2> <p>If two different messages for the same local recipient arrive more or less simultaneously, the two delivery processes are likely to run concurrently. When the <code>appendfile</code> transport is used to write to a file, Exim applies locking rules to stop concurrent processes from writing to the same file at the same time. </p> <p>However, when you use a <code>pipe</code> transport, it is up to you to arrange any locking that is needed. Here is a silly example: </p> <table><tr><td> </td><td><pre class="example">my_transport: driver = pipe command = /bin/sh -c 'cat >>/some/file' </pre></td></tr></table> <p>This is supposed to write the message at the end of the file. However, if two messages arrive at the same time, the file will be scrambled. You can use the <code>exim_lock</code> utility program (see section <a href="spec_50.html#SEC467">Mailbox maintenance (exim_lock)</a>) to lock a file using the same algorithm that Exim itself uses. </p> <hr size="6"> <a name="Uids-and-gids"></a> <a name="SEC217"></a> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="#SEC216" title="Previous section in reading order"> < </a>]</td> <td valign="middle" align="left">[<a href="#SEC218" title="Next section in reading order"> > </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="#SEC215" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="#SEC215" title="Up section"> Up </a>]</td> <td valign="middle" align="left">[<a href="spec_24.html#SEC220" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[Contents]</td> <td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <h2 class="section"> 23.2 Uids and gids </h2> <p>All transports have the options <code>group</code> and <code>user</code>. If <code>group</code> is set, it overrides any group that the router set in the address, even if <code>user</code> is not set for the transport. This makes it possible, for example, to run local mail delivery under the uid of the recipient (set by the router), but in a special group (set by the transport). For example: </p> <table><tr><td> </td><td><pre class="example"># Routers ... # User/group are set by check_local_user in this router local_users: driver = accept check_local_user transport = group_delivery # Transports ... # This transport overrides the group group_delivery: driver = appendfile file = /var/spool/mail/$local_part group = mail </pre></td></tr></table> <p>If <code>user</code> is set for a transport, its value overrides what is set in the address by the router. If <code>user</code> is non-numeric and <code>group</code> is not set, the gid associated with the user is used. If <code>user</code> is numeric, <code>group</code> must be set. </p> <a name="IDX1966"></a> <p>When the uid is taken from the transport's configuration, the <code>initgroups()</code> function is called for the groups associated with that uid if the <code>initgroups</code> option is set for the transport. When the uid is not specified by the transport, but is associated with the address by a router, the option for calling <code>initgroups()</code> is taken from the router configuration. </p> <a name="IDX1967"></a> <p>The <code>pipe</code> transport contains the special option <code>pipe_as_creator</code>. If this is set and <code>user</code> is not set, the uid of the process that called Exim to receive the message is used, and if <code>group</code> is not set, the corresponding original gid is also used. </p> <p>This is the detailed preference order for obtaining a gid; the first of the following that is set is used: </p> <ul class="toc"> <li> A <code>group</code> setting of the transport; </li><li> A <code>group</code> setting of the router; </li><li> A gid associated with a user setting of the router, either as a result of <code>check_local_user</code> or an explicit non-numeric <code>user</code> setting; </li><li> The group associated with a non-numeric <code>user</code> setting of the transport; </li><li> In a <code>pipe</code> transport, the creator's gid if <code>deliver_as_creator</code> is set and the uid is the creator's uid; </li><li> The Exim gid if the Exim uid is being used as a default. </li></ul> <p>If, for example, the user is specified numerically on the router and there are no group settings, no gid is available. In this situation, an error occurs. This is different for the uid, for which there always is an ultimate default. The first of the following that is set is used: </p> <ul class="toc"> <li> A <code>user</code> setting of the transport; </li><li> In a <code>pipe</code> transport, the creator's uid if <code>deliver_as_creator</code> is set; </li><li> A <code>user</code> setting of the router; </li><li> A <code>check_local_user</code> setting of the router; </li><li> The Exim uid. </li></ul> <p>Of course, an error will still occur if the uid that is chosen is on the <code>never_users</code> list. </p> <hr size="6"> <a name="Current-and-home-directories"></a> <a name="SEC218"></a> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="#SEC217" title="Previous section in reading order"> < </a>]</td> <td valign="middle" align="left">[<a href="#SEC219" title="Next section in reading order"> > </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="#SEC215" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="#SEC215" title="Up section"> Up </a>]</td> <td valign="middle" align="left">[<a href="spec_24.html#SEC220" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[Contents]</td> <td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <h2 class="section"> 23.3 Current and home directories </h2> <p>Routers may set current and home directories for local transports by means of the <code>transport_current_directory</code> and <code>transport_home_directory</code> options. However, if the transport's <code>current_directory</code> or <code>home_directory</code> options are set, they override the router's values. In detail, the home directory for a local transport is taken from the first of these values that is set: </p> <ul class="toc"> <li> The <code>home_directory</code> option on the transport; </li><li> The <code>transport_home_directory</code> option on the router; </li><li> The password data if <code>check_local_user</code> is set on the router; </li><li> The <code>router_home_directory</code> option on the router. </li></ul> <p>The current directory is taken from the first of these values that is set: </p> <ul class="toc"> <li> The <code>current_directory</code> option on the transport; </li><li> The <code>transport_current_directory</code> option on the router. </li></ul> <p>If neither the router nor the transport sets a current directory, Exim uses the value of the home directory, if it is set. Otherwise it sets the current directory to ‘<tt>/</tt>’ before running a local transport. </p> <hr size="6"> <a name="Expansion-variables-derived-from-the-address"></a> <a name="SEC219"></a> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="#SEC218" title="Previous section in reading order"> < </a>]</td> <td valign="middle" align="left">[<a href="spec_24.html#SEC220" title="Next section in reading order"> > </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="#SEC215" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="#SEC215" title="Up section"> Up </a>]</td> <td valign="middle" align="left">[<a href="spec_24.html#SEC220" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[Contents]</td> <td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <h2 class="section"> 23.4 Expansion variables derived from the address </h2> <p>Normally a local delivery is handling a single address, and in that case the variables such as <code>$domain</code> and <code>$local_part</code> are set during local deliveries. However, in some circumstances more than one address may be handled at once (for example, while writing batch SMTP for onward transmission by some other means). In this case, the variables associated with the local part are never set, <code>$domain</code> is set only if all the addresses have the same domain, and <code>$original_domain</code> is never set. <a name="IDX1968"></a> <a name="IDX1969"></a> <a name="IDX1970"></a> </p> <hr size="6"> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="#SEC215" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="spec_24.html#SEC220" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[Contents]</td> <td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <p> <font size="-1"> This document was generated on <i>September, 10 2009</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.78</i></a>. </font> <br> </p> </body> </html>