geoff@utfraser.UUCP (01/27/87)
The fix I found to prevent sendmail bashing hell out of the From: header (other than replacing sendmail with upas) was to modify sendmail.cf to leave the sender address (and thus From: header) alone (with a few exceptions due to weird gatewaying problems, alas) and invoke a shell script (uuxfrom) which replaces the From line instead of invoking uux directly. Here are /usr/lib/mail/uuxfrom and some code fragments from the sources to sendmail.cf. Ruleset 1 (sender address digesting) and ruleset 2 (recipient address digesting) are null. Ruleset 3 (address digesting in general) and ruleset 4 (address reconstruction and excretion) use .uux internally to denote an address that was in bang notation before sendmail clubbed it into RFC-normal-form; this is preferable to using .uucp internally since some machines generate return addresses containing .uucp. ---/usr/lib/mail/uuxfrom--- #! /bin/sh # uuxfrom - thishost sender date tohost touser... - relay uucp mail via uux # assumes honey danber uucp (BNU); else alter $UUX invocation below PATH=/bin:/usr/bin; export PATH : ${UUX=uux} host="$1" sender="$2" date="$3" tohost="$4" shift; shift; shift; shift # bug in v7 sh: shift n doesn't work? # uux options: return stdin if rmail fails (to sender), grade A (echo "From $sender $date remote from $host"; sed 1d) | $UUX -b -a"$sender" -gA - $tohost!rmail "$@" ---uucpm.m4--- S5 Muucp, P=/usr/lib/mail/uuxfrom, F=sDFhu, S=13, R=23, M=1000000, A=uuxfrom $w $f $d $h ($u) # as above, but $h!rmail can take multiple arguments Muucpm, P=/usr/lib/mail/uuxfrom, F=sDFhum, S=13, R=23, M=1000000, A=uuxfrom $w $f $d $h ($u) S13 R$*<@$+>$* $@$1<@$2>$3 already ok R$+ $@$1<@$J> tack on our hostname (re-write sender addr!) # next: s4 S23 # next: s4 ---smailm.m4--- Muuxrt, P=/usr/bin/smail, F=sShum, S=17, R=27, A=smail -vkH$j $u Mdom, P=/usr/bin/smail, F=sShum, S=17, R=27, A=smail -vH$j $u S17 R$*<$*.$=E>$* $@$1<$2.$3.$D>$4 externalize R$*<$*>$* $@$1<$2>$3 already ok # R$+ $@$1<@$j> tack on our name # next: s4 S27 # next: s4 ---etherm.m4--- # next line is for the Toronto/Michigan standalone SMTP code Mether, P=/usr/lib/mail/smtp, F=SsDFuCX, S=11, R=21, A=smtp $h $g $u # next line is only if you still use the old built-in SMTP code # Mether, P=[IPC], F=msDFuCX, S=11, R=21, A=IPC $h S11 # The next lines are mostly to make strict SMTP servers happy by giving # them RFC 822 return addresses, even for uucp addresses (u@h.uux), # but also corrects some previously dubious return addresses. # N.B.: These re-write sender addresses! R$-<@$+.$=D.uux> $@$1<@$2.$D> d.{uucp,uux,local}!u => u@d.mydom R$-<@$-.uux> $@$1<@$2.$D> host!u => u@host.mydom R$+<@$+.uux> $@<@$j>:$2!$1@$w d.arpa!r => @thishost.mydom:d.arpa!r@thishost R$*<@$+>$* $@$1<@$2>$3 already ok R$+ $@$1<@$J> tack on our hostname (re-write sender addr!) # next: s4 S21 # next: s4 ---ethermbitm.m4--- ##### Ethernet to Bitnet Mailer specification # next line is for the Toronto/Michigan standalone SMTP code Metherbit, P=/usr/lib/mail/smtp, F=SsDFuCX, S=14, R=21, A=smtp $h $g $u # next line is only if you still use the old built-in SMTP code # Metherbit, P=[IPC], F=msDFuCX, S=14, R=21, A=IPC $h S14 # The next lines are mostly to make strict SMTP servers happy by giving # them RFC 822 return addresses, even for uucp addresses (u@h.uux), # but also corrects some previously dubious return addresses. # N.B.: These re-write sender addresses! # N.B.: These assume that this host does uucp routing. # N.B.: other sites will need to change .utoronto to their local Bitnet "domain" R$-<@$+.$=D.uux> $@$1<@$2.utoronto> d.{uucp,uux,local}!u => u@d.mydom R$-<@$-.uux> $@$1<@$2.utoronto> host!u => u@host.mydom R$+<@$+.uux> $2!$1.uux b!u@a.uux => a!b!u R$+!$+!$+.uux $2!$3.uux a!b!c => b!c; strip hosts R$+!$+.uux $@$2<@$1.utoronto> h!u => u@h.utoronto R$*<@$+>$* $@$1<@$2>$3 already ok R$+ $@$1<@$j> tack on our hostname (re-write sender addr!) # next: s4 ---base.m4--- S1 # next: S= ruleset S2 # next: R= ruleset S4 R@ $@ handle <> error addr # externalize local domain info R$*<$*LOCAL>$* $1<$2$D>$3 change local info # uux must always be presented in ! notation R$+<@$+.uux> $2!$1 u@dom.uux => dom!u R$*<$+>$* $1$2$3 defocus R@$+:$+:$+ $@@$1,$2:$3 <route-addr> canonical # next: done; address is now in the message # start address munging here S3 # handle "from:<>" special case R<> $@@ turn into magic token # basic textual canonicalization R$*<$+>$* $2 basic RFC821/822 parsing R$+ at $+ $1@$2 "at" -> "@" for RFC 822 R$*<$*>$* $1$2$3 in case recursive # make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later R@$+,$+ @$1:$2 change all "," to ":" # localize and dispose of domain-based addresses R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> # more miscellaneous cleanup R$+ $:$>8$1 host dependent cleanup R$+:$*;@$+ $@$1:$2;@$3 list syntax # These heuristics are to make people at csri happy. # Normally @ has precedence to make them happy, but neighbour! gets precedence. # recognise @$=w.$=D too? R$+@$=w $@$>6$1<@$2> precedence to right @thishost # a!b!...!u@h.uux is a kludgey way to make @ take precedence over ! # R$+^$+ $1!$2 convert ^ to ! # .uux indicates the original address was in ! notation R$*!$*@$+.uux $1^$2@$3.uux a!b@c.uux => a^b@c.uux R!$+ $@$>6$1<@$U.uux> give !addr precedence R$=w!$+ $@$>6$2<@$1.uux> give thishost! precedence R$=E!$+ $@$>6$2<@$1.uux> give etherhost! precedence R$=U!$+ $@$>6$2<@$1.uux> give uuhost! precedence R$*^$*@$+.uux $1!$2@$3.uux a^b@c.uux => a!b@c.uux # can give ! precedence over @ by recognising ! here R$+@$+ $:$1<@$2> focus on domain R$+<$+@$+> $1$2<@$3> move gaze right R$+<@$+> $@$>6$1<@$2> already canonical # convert old-style addresses to a domain-based address # next line is original; three lines after are Ray Essick's version of same # R$+%$+ $@$>6$1<@$2> user%host R$+%$+ $:$1<@$2> user%host R$+<@$+%$+> $1%$2<@$3> fix user%host%host2 R$+<@$+> $@$>6$1<@$2> get outta here # can give @ precedence over ! by recognising ! here # R$+^$+ $1!$2 convert ^ to ! # a!b!...!u@h.uux is a kludgey way to make @ take precedence over ! # R$*!$*@$+.uux $1^$2@$3.uux a!b@c.uux => a^b@c.uux # .uux indicates the original address was in ! notation # next two lines are all that's needed for sendmail to accept domain!address R$+.!$+ $:$1!$2 dom.!route => dom!route R$+!$+ $@$>6$2<@$1.uux> resolve domain!route # R$*^$*@$+.uux $1!$2@$3.uux a^b@c.uux => a!b@c.uux R$-=$+ $@$>6$2<@$1.rscs> resolve rscs names # next: s0 to deliver the message or # s1 or s2 to munge the sender or recipient addresses in the message --- -- Geoff Collyer utcsri!utfraser!geoff, geoff@utfraser.toronto.{cdn,edu}