simon@einode.UUCP (Simon Kenyon) (11/24/86)
# To unbundle, sh this file echo README 1>&2 cat >README <<'End of README' This is my little package to work out what is going on inside sendmail. It consists of a sendmail configuration file and a shell script. The sendmail configuration file was created with ease (see previous messages in net.mail about ease - i think it's due in mod.sources). The ease source is included. What this is all about: I was having difficulty creating a sendmail.cf. So, I wrote a sendmail.cf whose sole function was to tag an address as it went through the ruleset. I coupled this with a little shell script, called args, which snarfs it's arguments (and stdin) and write them to a log file (/tmp/log is what I have used - you can alter it to taste, bearing in mind that it will probably have to suid to write to your directory :-() What do you do: Unpack all this junk. You should have test.mc, test.cf, args and README. Put args in your search path. Create a dummy mail message. It helps to know how you mailer calls sendmail. I used args to find out. (I briefly replaced /usr/lib/sendmail with args and sent some mail). Call sendmail with the dummy mail item as stdin. ie: /usr/lib/sendmail -Ctest.cf foobar <<eof To: foobar Subject: test test mail eof then have a look at what is in /tmp/log Thats all there is folks. I also use args with real configuration files, so that I can test them without disrupting the mail service through my machine. If you have any problems with this stuff, mail me and I'll try and help. Simon Kenyon The National Software Centre, 28 Enterprise Centre, Pearse Street, Dublin 2 IRELAND +353 1 716255 simon@einode.UUCP End of README echo args 1>&2 cat >args <<'End of args' #!/bin/sh # # little shell script to snarf it's arguments and stdin and put them # in a log file. this way you can see what is being given to the various # mailers and also what is being done to addresses. # it's a real hack, but it works for me # # Simon Kenyon, The NSC, Dublin, IRELAND. 24th Nov 86 # echo '-------------'`date`'------------------' >>/tmp/log echo -n "Command line: " >>/tmp/log for i in "$@" do echo -n "$i " >>/tmp/log done echo >>/tmp/log while read foo do echo $foo >>/tmp/log done End of args echo test.cf 1>&2 cat >test.cf <<'End of test.cf' ################################################### ## ## ## WARNING: THIS FILE IS TO BE MODIFIED BY ## ## THE EASE TRANSLATOR (ET) ONLY. ## ## ## ## ALL OTHER MODIFICATIONS WILL ## ## DISAPPEAR THE NEXT TIME ET IS RUN. ## ## ## ## MAKE MODIFICATIONS TO THE EASE ## ## SOURCE ONLY. ## ## ## ################################################### DAmy_domain DBruleset tester V1.0 Dwwhatever Dj$w.$A DnMAILER-DAEMON DlFrom $g $d Do.:%@!^=/[]{} Dq$?x$x <$g>$|$g$. De$j Sendmail $v/$B ready at $b OA/usr/lib/aliases Odb Ou1 OS/usr/lib/sendmail.st OH/usr/lib/sendmail.hf Og1 Oo OQ/usr/spool/mqueue OT3d Os OL9 OtWET OF0644 Orr2h OW* Pfirst-class=0 Pspecial-delivery=100 Pjunk=-100 Troot daemon uucp network Tsimon Ha: The origination date in Arpanet format = $a Hb: The current date in Arpanet format = $b Hc: The hop count = $c Hd: The date in UNIX (ctime) format = $d He: The SMTP entry message = $e Hf: The sender (from) address = $f Hg: The sender address relative to the recipient = $g Hh: The recipient host = $h Hi: The queue id = $i Hj: The official domain name for this site = $j Hl: The format of the UNIX from line = $l Hn: The name of the daemon (for error messages) = $n Ho: The set of operators in addresses = $o Hp: Sendmail's pid = $p Hq: The default format of sender address = $q Hr: Protocol used = $r Hs: Sender's host name = $s Ht: A numeric representation of the current time = $t Hu: The recipient user = $u Hv: The version number of sendmail = $v Hw: The hostname of this site = $w Hx: The full name of the sender = $x Hy: The id of the sender's tty = $y Hz: The home directory of the recipient = $z S3 R$+ $:{3}$1 S0 R$+@$+ $#uucp$@{0_uucp}$2$:{0_uucp}$1 R$+!$+ $#uucp$@{0_uucp}$1$:{0_uucp}$2 R$+ $#local$:{0_local}$1 S1 R$+ $@{1}$1 S2 R$+ $@{2}$1 S4 R$+ $@{4}$1 S10 R$+ $@{S_local}$1 S20 R$+ $@{R_local}$1 S11 R$+ $@{S_uucp}$1 S21 R$+ $@{R_uucp}$1 Mlocal, P=/usr/src/local/EUnet/ease/test/args, F=DFlMmnrs, S=10, R=20, A=args mail -d $u Mprog, P=/usr/src/local/EUnet/ease/test/args, F=DeFlMns, S=10, R=20, A=args sh -c $u Muucp, P=/usr/src/local/EUnet/ease/test/args, F=DFMsUhu, S=11, R=21, M=65535, A=args uumail -h -oc -gA -f$g $h!$u End of test.cf echo test.mc 1>&2 cat >test.mc <<'End of test.mc' /* * Sendmail configuration file for test rulesets * * Simon Kenyon November 20th, 1986 */ bind EnvelopeTo = ruleset 0; From = ruleset 1; HeaderTo = ruleset 2; Canonicalize = ruleset 3; Externalize = ruleset 4; LocalHeaderFrom = ruleset 10; UucpHeaderFrom = ruleset 11; LocalHeaderTo = ruleset 20; UucpHeaderTo = ruleset 21; macro Domain = "my_domain"; Version = "ruleset tester V1.0"; m_sitename = "whatever"; m_oname = "${m_sitename}.${Domain}"; m_daemon = "MAILER-DAEMON"; /*m_ufrom = "From ${m_sreladdr} ${m_udate} remote from ${m_sitename}";*/ m_ufrom = "From ${m_sreladdr} ${m_udate}"; m_addrops = ".:%@!^=/[]{}"; m_defaddr = concat ( ifset (m_sname, "${m_sname} <${m_sreladdr}>", "${m_sreladdr}"), "" ); m_smtp = "${m_oname} Sendmail ${m_version}/${Version} ready at ${m_adate}"; options o_alias = "/usr/lib/aliases"; o_delivery = d_background; o_dmuid = "1"; o_flog = "/usr/lib/sendmail.st"; o_fsmtp = "/usr/lib/sendmail.hf"; o_gid = "1"; o_hformat = ""; o_qdir = "/usr/spool/mqueue"; o_qtimeout = "3d"; o_safe = ""; o_slog = "9"; o_timezone = "WET"; o_tmode = "0644"; o_tread = "r2h"; o_wizpass = "*"; precedence first-class = 0; special-delivery = 100; junk = -100; trusted {root, daemon, uucp, network}; {simon}; header define ("a:", "The origination date in Arpanet format = ${m_odate}"); define ("b:", "The current date in Arpanet format = ${m_adate}"); define ("c:", "The hop count = ${m_hops}"); define ("d:", "The date in UNIX (ctime) format = ${m_udate}"); define ("e:", "The SMTP entry message = ${m_smtp}"); define ("f:", "The sender (from) address = ${m_saddr}"); define ("g:", "The sender address relative to the recipient = ${m_sreladdr}"); define ("h:", "The recipient host = ${m_rhost}"); define ("i:", "The queue id = ${m_qid}"); define ("j:", "The official domain name for this site = ${m_oname}"); define ("l:", "The format of the UNIX from line = ${m_ufrom}"); define ("n:", "The name of the daemon (for error messages) = ${m_daemon}"); define ("o:", "The set of operators in addresses = ${m_addrops}"); define ("p:", "Sendmail's pid = ${m_pid}"); define ("q:", "The default format of sender address = ${m_defaddr}"); define ("r:", "Protocol used = ${m_protocol}"); define ("s:", "Sender's host name = ${m_shostname}"); define ("t:", "A numeric representation of the current time = ${m_ctime}"); define ("u:", "The recipient user = ${m_ruser}"); define ("v:", "The version number of sendmail = ${m_version}"); define ("w:", "The hostname of this site = ${m_sitename}"); define ("x:", "The full name of the sender = ${m_sname}"); define ("y:", "The id of the sender's tty = ${m_stty}"); define ("z:", "The home directory of the recipient = ${m_rhdir}"); field path : match (1*); ruleset Canonicalize { if (path) next ("{3}" $1); } ruleset EnvelopeTo { if (path @ path) resolve (mailer (uucp), host ("{0_uucp}" $2), user ("{0_uucp}" $1)); if (path ! path) resolve (mailer (uucp), host ("{0_uucp}" $1), user ("{0_uucp}" $2)); if (path) resolve (mailer (local), user ("{0_local}" $1)); } ruleset From { if (path) return ("{1}" $1); } ruleset HeaderTo { if (path) return ("{2}" $1); } ruleset Externalize { if (path) return ("{4}" $1); } ruleset LocalHeaderFrom { if (path) return ("{S_local}" $1); } ruleset LocalHeaderTo { if (path) return ("{R_local}" $1); } ruleset UucpHeaderFrom { if (path) return ("{S_uucp}" $1); } ruleset UucpHeaderTo { if (path) return ("{R_uucp}" $1); } mailer local { Path = "/usr/src/local/EUnet/ease/test/args", Flags = {f_date, f_from, f_locm, f_mesg, f_mult, f_noufrom, f_rfrom, f_strip}, Sender = LocalHeaderFrom, Recipient = LocalHeaderTo, Argv = "args mail -d ${m_ruser}" }; prog { Path = "/usr/src/local/EUnet/ease/test/args", Flags = {f_date, f_expensive, f_from, f_locm, f_mesg, f_noufrom, f_strip}, Sender = LocalHeaderFrom, Recipient = LocalHeaderTo, Argv = "args sh -c ${m_ruser}" }; uucp { Path = "/usr/src/local/EUnet/ease/test/args", Flags = {f_date, f_from, f_mesg, f_strip, f_ufrom, f_upperh, f_upperu}, Sender = UucpHeaderFrom, Recipient = UucpHeaderTo, Maxsize = "65535", Argv = "args uumail -h -oc -gA -f${m_sreladdr} ${m_rhost}!${m_ruser}" }; End of test.mc -- Simon Kenyon EUnet: simon@einode.UUCP Smail: The National Software Centre, Dublin, IRELAND Phone: +353-1-716255 EUnet is a registered trademark of the EUUG