The Child
The child is the copy of sendmail that will transform into the delivery agent. Before the child can transform, it must perform a few more necessary steps.
If sendmail was compiled with HASSETUSERCONTEXT defined (HAS... on page 114), it calls setusercontext(3) like this:
setusercontext(NULL, pwd, user-id, LOGIN_SETRESOURCES|LOGIN_SETPRIORITY);
Here, pwd
is a pointer to a
structure of type passwd for
the user whose user-id is
user-id
. The
user-id
is that of the
controlling user (Delivery to Files on page 466) or the recipient (F=o on page 777).
The sendmail program next sets
its group-id as appropriate. If
the DontInitGroups
option (DontInitGroups on page 1023) is false,
sendmail calls
initgroups(3). The group
identity used is that described under the DefaultUser
option
(DefaultUser on page
1000).
If the /=
delivery
agent equate (/=(forward slash) on page 737) has a non-NULL value,
sendmail calls
chroot(8) to change its
topmost directory into a private directory
tree.
If the N=
delivery
agent equate (N= on page
748) has a nonzero value,
sendmail calls
nice(3) to “re-nice” the
delivery agent to that value.
The sendmail program then sets
its user-id. The user identity
used is chosen by the mailer F=S
and U=
equates and the
DefaultUser
option, as detailed in DefaultUser
on page 1000.
The sendmail program then
attempts to chdir(2) into one
of the directories listed in the D=
delivery agent equate
(D= on page 741).
Next, sendmail dup(2)s the pipes created in the previous section.
Finally, ...
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.