30.6 How ExecutedFor safety and efficiency, sendmail undertakes a complicated series of steps to run (execute) a delivery agent. [14] Some (such as setting the environment) are intended to improve security. Others (such as forking) are intended to improve efficiency by creating parallel actions. Here, we discuss those steps in the order in which they are taken by sendmail .
30.6.1 ForkWhen sendmail performs delivery, it cannot simply replace itself with the delivery agent program. Instead, it must fork (2), and the child will replace itself. If sendmail is running in verbose mode (see Section 34.8.76, Verbose ), it shows that it is about to start this process:
Connecting to delivery agent
If a traffic-logging file was specified with
pid === EXEC the expanded A= here
Here, the
Next
sendmail
creates a
pipe
so that it
will be able to print the email message to the
delivery agent and so that it can read errors
emitted by the delivery agent. See the If all has gone well, sendmail fork (2)s a copy of itself. The parent then pipes the email message to the child. 30.6.2 The ChildThe child is the copy of sendmail that will transform into the delivery agent. But before the child can transform, it must perform a few more necessary steps. If sendmail was compiled with HASSETUSERCONTEXT defined (see Section 18.8.9, HAS... ), it calls setusercontext (3) like this:
setusercontext(NULL,
Here,
If the
The
sendmail
program next sets its
uid
and
gid
as appropriate. If the
Next
sendmail
attempts to
chdir
(2) into one of
the directories listed in the Finally, sendmail calls setsid (2) to become a process-group leader and execve (2) to become the delivery agent. That latter call looks like this:
execve(
Here, |
|