Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 9adab841b2346eed28e146b23c25375c > files > 125

exim-doc-4.73-2.fc15.noarch.rpm

<!DOCTYPE html PUBLIC "XSLT-compat">
<html lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../../common.css">
<meta name="author" content="The Exim Project. &lt;http://www.exim.org/&gt;">
<meta name="copyright" content="Copyright ©2010 The Exim Project. All rights reserved">
<meta name="description" content="Exim is a message transfer agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the Internet.">
<meta name="keywords" content="exim,smtp,mta,email">
<meta name="robots" content="noodp,noydir,index,follow">
<meta name="viewport" content="width=device-width">
<title>23. Environment for running local transports</title>
<link rel="stylesheet" type="text/css" href="../../../../doc/chapter.css">
<link rel="canonical" href="http://www.exim.org/exim-html-current/doc/html/spec_html/ch23.html">
</head>
<body>
<h1 id="header"><a href="../../../..">Exim Internet Mailer</a></h1>
<div id="outer">
<ul id="nav_flow" class="nav">
<li><a href="../../../../index.html">Home</a></li>
<li><a href="../../../../mirrors.html">Download</a></li>
<li><a href="../../../../docs.html">Documentation</a></li>
<li><a href="../../../../maillist.html">Mailing Lists</a></li>
<li><a href="http://wiki.exim.org/">Wiki</a></li>
<li><a href="http://www.exim.org/bugzilla/">Bugs</a></li>
<li><a href="../../../../credits.html">Credits</a></li>
<li class="search"><form action="http://www.google.com/search" method="get">
<span class="search_field_container"><input type="search" name="q" placeholder="Search Docs" class="search_field"></span><input type="hidden" name="hl" value="en"><input type="hidden" name="ie" value="UTF-8"><input type="hidden" name="as_qdr" value="all"><input type="hidden" name="q" value="site:www.exim.org"><input type="hidden" name="q" value="inurl:exim-html-current">
</form></li>
</ul>
<div id="inner"><div id="content">
<a class="previous_page" href="ch22.html">&lt;-previous</a><a class="next_page" href="ch24.html">next-&gt;</a><div id="chapter" class="chapter">
<h2 id="CHAPenvironment" class="">Chapter 23 - Environment for running local transports</h2>
<p>



Local transports handle deliveries to files and pipes. (The <span class="docbook_command">autoreply</span>
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 <span class="docbook_command">pipe</span>
transport is the only one that sets up environment variables; see section
<a href="ch29.html#SECTpipeenv" title="29. The pipe transport">29.4</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 <span class="docbook_option">check_local_user</span>, <span class="docbook_option">group</span>,
or <span class="docbook_option">user</span> options. However, values may also be given in the transport’s own
configuration, and these override anything that comes from the router.
</p>
<div class="section">
<h3 id="SECID131" class="">1. Concurrent deliveries</h3>
<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 <span class="docbook_command">appendfile</span> 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 <span class="docbook_command">pipe</span> transport, it is up to you to arrange any
locking that is needed. Here is a silly example:
</p>
<div class="docbook_literallayout"><pre>
my_transport:
  driver = pipe
  command = /bin/sh -c 'cat &gt;&gt;/some/file'
</pre></div>
<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
<span class="docbook_option">exim_lock</span> utility program (see section <a href="ch50.html#SECTmailboxmaint" title="50. Exim utilities">50.15</a>) to lock a
file using the same algorithm that Exim itself uses.
</p>
</div>
<div class="section">
<h3 id="SECTenvuidgid" class="">2. Uids and gids</h3>
<p>


All transports have the options <span class="docbook_option">group</span> and <span class="docbook_option">user</span>. If <span class="docbook_option">group</span> is set, it
overrides any group that the router set in the address, even if <span class="docbook_option">user</span> 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>
<div class="docbook_literallayout"><pre>
# 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></div>
<p>
If <span class="docbook_option">user</span> is set for a transport, its value overrides what is set in the
address by the router. If <span class="docbook_option">user</span> is non-numeric and <span class="docbook_option">group</span> is not set, the
gid associated with the user is used. If <span class="docbook_option">user</span> is numeric, <span class="docbook_option">group</span> must be
set.
</p>
<p>

When the uid is taken from the transport’s configuration, the <span class="docbook_function">initgroups()</span>
function is called for the groups associated with that uid if the
<span class="docbook_option">initgroups</span> 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 <span class="docbook_function">initgroups()</span> is taken from the router configuration.
</p>
<p>

The <span class="docbook_command">pipe</span> transport contains the special option <span class="docbook_option">pipe_as_creator</span>. If this
is set and <span class="docbook_option">user</span> is not set, the uid of the process that called Exim to
receive the message is used, and if <span class="docbook_option">group</span> 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>
<li>
<p>
A <span class="docbook_option">group</span> setting of the transport;
</p>
</li>
<li>
<p>
A <span class="docbook_option">group</span> setting of the router;
</p>
</li>
<li>
<p>
A gid associated with a user setting of the router, either as a result of
<span class="docbook_option">check_local_user</span> or an explicit non-numeric <span class="docbook_option">user</span> setting;
</p>
</li>
<li>
<p>
The group associated with a non-numeric <span class="docbook_option">user</span> setting of the transport;
</p>
</li>
<li>
<p>
In a <span class="docbook_command">pipe</span> transport, the creator’s gid if <span class="docbook_option">deliver_as_creator</span> is set and
the uid is the creator’s uid;
</p>
</li>
<li>
<p>
The Exim gid if the Exim uid is being used as a default.
</p>
</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>
<li>
<p>
A <span class="docbook_option">user</span> setting of the transport;
</p>
</li>
<li>
<p>
In a <span class="docbook_command">pipe</span> transport, the creator’s uid if <span class="docbook_option">deliver_as_creator</span> is set;
</p>
</li>
<li>
<p>
A <span class="docbook_option">user</span> setting of the router;
</p>
</li>
<li>
<p>
A <span class="docbook_option">check_local_user</span> setting of the router;
</p>
</li>
<li>
<p>
The Exim uid.
</p>
</li>
</ul>
<p>
Of course, an error will still occur if the uid that is chosen is on the
<span class="docbook_option">never_users</span> list.
</p>
</div>
<div class="section">
<h3 id="SECID132" class="">3. Current and home directories</h3>
<p>




Routers may set current and home directories for local transports by means of
the <span class="docbook_option">transport_current_directory</span> and <span class="docbook_option">transport_home_directory</span> options.
However, if the transport’s <span class="docbook_option">current_directory</span> or <span class="docbook_option">home_directory</span> 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>
<li>
<p>
The <span class="docbook_option">home_directory</span> option on the transport;
</p>
</li>
<li>
<p>
The <span class="docbook_option">transport_home_directory</span> option on the router;
</p>
</li>
<li>
<p>
The password data if <span class="docbook_option">check_local_user</span> is set on the router;
</p>
</li>
<li>
<p>
The <span class="docbook_option">router_home_directory</span> option on the router.
</p>
</li>
</ul>
<p>
The current directory is taken from the first of these values that is set:
</p>
<ul>
<li>
<p>
The <span class="docbook_option">current_directory</span> option on the transport;
</p>
</li>
<li>
<p>
The <span class="docbook_option">transport_current_directory</span> option on the router.
</p>
</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 <span class="docbook_filename">/</span> before running a local transport.
</p>
</div>
<div class="section">
<h3 id="SECID133" class="">4. Expansion variables derived from the address</h3>
<p>



Normally a local delivery is handling a single address, and in that case the
variables such as $domain and $local_part 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, $domain is set only if all the addresses have the same domain,
and $original_domain is never set.



</p>
</div>
</div>
<a class="previous_page" href="ch22.html">&lt;-previous</a><a class="next_page" href="ch24.html">next-&gt;</a>
</div></div>
<iframe id="branding" name="branding" src="../../../../branding/branding.html" height="0" frameborder="no" scrolling="no"></iframe><div id="footer">Website design by <a href="https://secure.grepular.com/">Mike Cardwell</a>, of <a href="http://cardwellit.com/">Cardwell IT Ltd.</a>
</div>
<div class="left_bar"></div>
<div class="right_bar"></div>
<div id="toc">
<ul class="hidden"></ul>
<img src="../../../../doc/contents.png" width="16" height="155">
</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script><script type="text/javascript" src="../../../../common.js"></script><script type="text/javascript" src="../../../../doc/chapter.js"></script>
</body>
</html>