There were four chunks to this work.
Configuration build infrastructure
Sendmail configuration files (
/etc/mail/sendmail.cf
) are normally built by building a simpler configuration file (sendmail.mc
) that uses a vast range of macros provided as part of Sendmail, in conjunction with m4(1), to generate the final file.This is exactly the sort of thing that you'd use make(1) for. I've done this numerous times over the last decade or so. This time, rather than reinvent the wheel by writing my own I've taken the one that ships with FreeBSD, and made a few local modifications.
These were commits 1100, 1101, and 1103.
Since this Makefile originally came from FreeBSD it includes Berkeley Make syntax. I've got bmake(1) installed as part of the pkgsrc bootstrap, so that's not a problem.
As well as supporting targets to rebuild the configuration files it also includes handy
start
, stop
, and restart
targets, which reduce the amount of typing that's needed.Using my Sendmail with the SMF
I took a straightforward approach to configuring the SMF to run my Sendmail build. I'd used
svccfg
to determine the name of the SMTP service's start/stop script:% svccfg -s sendmail listprop start/exec
start/exec astring "/lib/svc/method/smtp-sendmail start"
% svccfg -s sendmail listprop stop/exec
stop/exec astring "/lib/svc/method/smtp-sendmail stop %{restarter/contract}"
So I've taken a copy of
/lib/svc/method/smtp-sendmail
, imported it in to the repository, and then adjusted it to use my build of Sendmail.That's commits 1098 and 1102.
Adjusting the SMF to use my script was a matter of:
# svccfg -s sendmail setprop start/exec = \
'("/export/home/nik/svn/dtrace4sendmail/trunk/zones/smtp-sendmail start")'
# svccfg -s sendmail setprop stop/exec = \
'("/export/home/nik/svn/dtrace4sendmail/trunk/zones/smtp-sendmail stop %{restarter/contract}")'
# svccfg -s sendmail setprop refresh/exec = \
'("/export/home/nik/svn/dtrace4sendmail/trunk/zones/smtp-sendmail refresh")'
Having made those changes the service information must be refreshed.
# svcadm refresh sendmail
Those commands must be run in each zone.
Configuring Sendmail
For the purposes of demonstration I knocked together a quick Sendmail configuration for the external-relay zone, along with the requisite
submit.mc
. Commits 1104 and 1105.Starting and testing
With that done, installing the new configuration was a matter of stopping the existing service:
# bmake stop
Creating and installing the
.cf
files.# bmake install
Finally, restarting the service:
# bmake start
Then, from another host (i.e., outside the zone) I connected to port 25 to verify that it's Sendmail 8.13.7 running.
% telnet external-zone smtp
Connected to external-zone.nothing-going-on.org.
Escape character is '^]'.
220 external-zone.nothing-going-on.org ESMTP Sendmail 8.13.7/8.13.7; Sat, 29 Jul 2006 22:36:02 +0100 (BST)
quit
221 2.0.0 external-zone.nothing-going-on.org closing connection
Connection to external-zone.nothing-going-on.org closed by foreign host.
Perfect.
[...] I’ve previously documented running Sendmail in a zone. One of the things that I need for testing Sendmail is a source of messages, and an easy mechanism to get them to Sendmail over SMTP. [...]
ReplyDelete[...] I’ve (finally) got Sendmail built, zones configured, DTrace working for functions declared static, and a mechanism for creating test SMTP sessions. [...]
ReplyDelete