74. pepsi-sendmail¶
Let programs on this host send mail, through the traditional Sendmail interface.
74.1. Role¶
pepsi-sendmail is the program Debian installs as /usr/sbin/sendmail. It
reads a message on standard input and hands it to pepsi-ingress over a local
UNIX-domain socket, so that software which expects an MTA to provide that path
can send through Pepsi unchanged: cron, mail(1), git send-email,
logwatch, PHP’s mail(). Reference: pepsi-sendmail(1).
Without it, a host running Pepsi has no local submission path at all: those
programs can only reach port 25, where an unauthenticated client is not a local
origin and is refused with 550 5.7.1 Relaying denied for any recipient
outside a served domain.
74.2. How Debian arbitrates the sendmail path¶
Debian does not use update-alternatives for this. Policy §11.6 has every
mail transport agent declare:
Provides: mail-transport-agent
Conflicts: mail-transport-agent
Replaces: mail-transport-agent
so exactly one MTA can be installed at a time and it simply owns the paths. The
pepsi package declares that triple and ships the interface as symlinks to the
unified pepsi binary, which dispatches on argv[0] — the same technique
that Postfix and exim use:
Path |
Behaves as |
|---|---|
|
the submission client |
|
the same (historical path) |
|
|
|
|
|
the submission client (UUCP delivery) |
Two of those are not full implementations, deliberately. mailq prints no
queue, because Pepsi’s queue is a database table that an ordinary user may not
read. Instead it refers the caller to pepsi-queue (or
pepsi-status) and exits EX_SOFTWARE. newaliases exits 0
having done nothing, because the alias map is a text file that
pepsi-stage-aliases re-reads whenever its mtime changes, and package
scripts run it unconditionally.
A source make install deliberately does not claim these paths: they belong
to whatever MTA the system already has, and taking them over silently would stop
its mail delivery with no warning. Pass INSTALL_MTA_LINKS=yes to do it on
purpose.
74.3. Why it needs no privilege¶
Unlike the sendmail commands of Postfix, Exim and sendmail itself,
pepsi-sendmail needs no setuid or setgid program.
Postfix’s sendmail hands the message to postdrop, which is setgid
postdrop so that it may write into the maildrop spool directory.
Pepsi’s queue is a PostgreSQL table reached by
peer-authenticated roles, so the equivalent privilege would have to be setuid
rather than setgid — a much larger privilege to hand to a program that parses
attacker-influenced message headers.
Pepsi avoids the question entirely by moving the identity decision to the server.
pepsi-ingress reads the connecting process’s user id from the kernel
(SO_PEERCRED, enabled per listener with AUTH_PEERCRED), resolves it to a
login, and looks that login up in USERNAME_MAP — exactly as it maps a SASL
username arriving on the submission port. The RFC 6409 §6/§8.1 submission-identity
rules then apply unchanged.
So pepsi-sendmail is an ordinary unprivileged program (and is folded into the
shared pepsi binary like any other), while the guarantees are stronger than
a privileged implementation could offer:
A caller can only ever send as itself. The kernel supplies the identity; nothing the client says is trusted.
The socket can be world-writable, because opening it grants nothing. Deny an account by mapping it to no address in
USERNAME_MAP, not with permissions.Nothing on the network gains anything.
The full submission-identity rules are described in pepsi-ingress and
under The submission identity in Security model: every From: mailbox
is checked, the parse is strict RFC 5322, a display name naming another address
is refused, and the Sender: field is fixed up. The adversary that they
answer is A local shell user.
Local submitters are also metered, so one account cannot crowd out the others:
each uid may hold at most half of [pepsi-ingress] MAX_LOCAL_CONNECTIONS and
submit LOCAL_MESSAGES_PER_MINUTE messages (burst LOCAL_MESSAGE_BURST).
A refusal there, like queue admission control’s 452 4.3.1, is a temporary
one, which pepsi-sendmail turns into EX_TEMPFAIL so cron retries.
74.4. Compared with trusting loopback¶
The alternative is to put 127.0.0.0/8 ::1/128 in the MX listener’s
MYNETWORKS. That authenticates a network position instead of a user:
|
|
|
|---|---|---|
Who is authenticated |
anyone who can open a TCP connection |
the specific account, per the kernel |
Sender enforcement |
none — any process may send as anyone |
|
Reachable from the network |
no (loopback only), but the listener is a network listener |
no — a filesystem socket |
Self-relay loop risk |
yes: a message relayed to this host re-enters as a submission |
no |
Both are available, but they are not symmetrical choices. The socket is always
served, so pepsi-setup --wizard does not ask about it; the one question left
is whether to additionally trust loopback. Answer yes only for software that
speaks SMTP to 127.0.0.1 and cannot be pointed at the socket.
74.5. Configuration¶
The client reads [pepsi-sendmail] SOCKET (default
/run/pepsi/submission.sock), and so does the server. pepsi-ingress
serves that socket unconditionally, synthesising the listener from that one
option, so there is no listener section to write and nothing that can disagree
with anything else:
[pepsi-sendmail]
SOCKET = /run/pepsi/submission.sock
# ... and that is all. No [pepsi-ingress-listener-*] section.
A host running an MTA is expected to provide /usr/sbin/sendmail, so the
socket is not optional. SOCKET = none switches it off for the cases that
genuinely want that (a container, an appliance), and failing to bind it is fatal
rather than degraded: a server serving only some of what it was asked to serve
is a failure, not a partial success.
Under systemd the descriptor is inherited from pepsi-ingress.socket, matched
by the address it is bound to rather than by an FD_INDEX. That matters
because an index is a position among the unit’s ListenStream= entries, so it
shifts whenever a port is added or removed; asking the kernel what each passed
descriptor is bound to cannot drift out of step with anything. Off systemd, or
for a SOCKET that no unit binds, pepsi-ingress binds the path itself.
Socket activation here is about availability, not privilege, since this is not
a privileged port. When the .socket unit binds the socket, systemd creates
the node as root, and the node stays available across a service restart, so a
concurrent /usr/sbin/sendmail waits rather than failing. /run/pepsi is shared by
several services, so no unit claims it as its RuntimeDirectory=; the
package’s tmpfiles entry owns it (see No unit may claim it as a RuntimeDirectory).
The synthesised listener is MODE = plain, SUBMISSION = yes and
AUTH_PEERCRED = yes, on a socket with mode 0666; none of that is
configurable, because none of it is a choice. SUBMISSION = yes brings the RFC
6409 header fixups (a missing Date: or Message-ID: is supplied). A
UNIX-domain submission listener is exempt from the usual “submission requires
TLS” rule: a filesystem socket has no transport an attacker could observe, and
its authentication comes from the kernel rather than the wire, so a certificate
would protect nothing. For a listener that is configured with SERVE =
systemd, that exemption is checked once the descriptor is resolved rather than
at parse time, because the .socket unit sets the socket’s family.
pepsi-ingress refuses to start if it turns out to be a network socket.
To give the socket different options, such as a group, a stricter mode or no peer credentials, write a listener section for the same path; it replaces the built-in one rather than colliding with it.
Because submissions are authenticated they carry state.local_origin, so the
pepsi-stage-if entry stage of the sample and wizard-built pipelines routes
them down the outbound branch, and they are DKIM-signed as the author’s domain.
74.6. See also¶
pepsi-ingress, pepsi-queue, pepsi-stage-aliases, Getting started on a cheap VPS, pepsi-sendmail(1), pepsi.conf(5).