expn.in (82794) | expn.in (119679) |
---|---|
1#!@PERL@ 2'di '; 3'ds 00 \\"'; 4'ig 00 '; 5# 6# THIS PROGRAM IS ITS OWN MANUAL PAGE. INSTALL IN man & bin. 7# 8 9# hardcoded constants, should work fine for BSD-based systems 10#require 'sys/socket.ph'; # perl 4 11use Socket; # perl 5 12$AF_INET = &AF_INET; 13$SOCK_STREAM = &SOCK_STREAM; 14 15# system requirements: 16# must have 'nslookup' and 'hostname' programs. 17 | 1#!@PERL@ 2'di '; 3'ds 00 \\"'; 4'ig 00 '; 5# 6# THIS PROGRAM IS ITS OWN MANUAL PAGE. INSTALL IN man & bin. 7# 8 9# hardcoded constants, should work fine for BSD-based systems 10#require 'sys/socket.ph'; # perl 4 11use Socket; # perl 5 12$AF_INET = &AF_INET; 13$SOCK_STREAM = &SOCK_STREAM; 14 15# system requirements: 16# must have 'nslookup' and 'hostname' programs. 17 |
18# $Header: /proj/bank/cvsroot/am-utils/scripts/expn.in,v 1.2.2.1 2000/06/14 01:58:48 ionut Exp $ | 18# $Header: /proj/bank/cvsroot/am-utils/scripts/expn.in,v 1.2.2.2 2002/07/11 14:27:02 ezk Exp $ |
19 20# TODO: 21# less magic should apply to command-line addresses 22# less magic should apply to local addresses 23# add magic to deal with cross-domain cnames 24 25# Checklist: (hard addresses) 26# 250 Kimmo Suominen <"|/usr/local/mh/lib/slocal -user kim"@grendel.tac.nyc.ny.us> --- 27 unchanged lines hidden (view full) --- 54# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60# SUCH DAMAGE. 61# | 19 20# TODO: 21# less magic should apply to command-line addresses 22# less magic should apply to local addresses 23# add magic to deal with cross-domain cnames 24 25# Checklist: (hard addresses) 26# 250 Kimmo Suominen <"|/usr/local/mh/lib/slocal -user kim"@grendel.tac.nyc.ny.us> --- 27 unchanged lines hidden (view full) --- 54# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60# SUCH DAMAGE. 61# |
62# This copyright notice derrived from material copyrighted by the Regents | 62# This copyright notice derived from material copyrighted by the Regents |
63# of the University of California. 64# 65# Contributions accepted. 66# 67############################################################################# 68 69# overall structure: 70# in an effort to not trace each address individually, but rather --- 181 unchanged lines hidden (view full) --- 252 253 print &compact($u,$server)." ->\n" if ($verbose && ! $valid); 254 if ($valid) { 255 # 256 # when running with -a, we delay taking any action 257 # on the results of our query until we have looked 258 # at the complete output. @toFinal stores expansions 259 # that will be final if we take them. @toExpn stores | 63# of the University of California. 64# 65# Contributions accepted. 66# 67############################################################################# 68 69# overall structure: 70# in an effort to not trace each address individually, but rather --- 181 unchanged lines hidden (view full) --- 252 253 print &compact($u,$server)." ->\n" if ($verbose && ! $valid); 254 if ($valid) { 255 # 256 # when running with -a, we delay taking any action 257 # on the results of our query until we have looked 258 # at the complete output. @toFinal stores expansions 259 # that will be final if we take them. @toExpn stores |
260 # expnansions that are not final. @isValid keeps | 260 # expansions that are not final. @isValid keeps |
261 # track of our ability to send mail to each of the 262 # expansions. 263 # 264 @isValid = (); 265 @toFinal = (); 266 @toExpn = (); 267 } 268 --- 509 unchanged lines hidden (view full) --- 778 # 779 # domain host isn't, keep $host whatever it is 780 # 781 print "domainify($host,$domain_host) = $host\n" if $debug; 782 return $host; 783 } 784 785 # | 261 # track of our ability to send mail to each of the 262 # expansions. 263 # 264 @isValid = (); 265 @toFinal = (); 266 @toExpn = (); 267 } 268 --- 509 unchanged lines hidden (view full) --- 778 # 779 # domain host isn't, keep $host whatever it is 780 # 781 print "domainify($host,$domain_host) = $host\n" if $debug; 782 return $host; 783 } 784 785 # |
786 # There are several weird situtations that need to be | 786 # There are several weird situations that need to be |
787 # accounted for. They have to do with domain relay hosts. 788 # 789 # Examples: 790 # host server "right answer" 791 # 792 # shiva.cs cs.berkeley.edu shiva.cs.berkeley.edu 793 # shiva cs.berkeley.edu shiva.cs.berekley.edu 794 # cumulus reed.edu @reed.edu:cumulus.uucp --- 154 unchanged lines hidden (view full) --- 949 return $nserver; 950 } else { 951 return undef; 952 } 953 } 954 return undef; 955} 956# follow mx records, return a hostname | 787 # accounted for. They have to do with domain relay hosts. 788 # 789 # Examples: 790 # host server "right answer" 791 # 792 # shiva.cs cs.berkeley.edu shiva.cs.berkeley.edu 793 # shiva cs.berkeley.edu shiva.cs.berekley.edu 794 # cumulus reed.edu @reed.edu:cumulus.uucp --- 154 unchanged lines hidden (view full) --- 949 return $nserver; 950 } else { 951 return undef; 952 } 953 } 954 return undef; 955} 956# follow mx records, return a hostname |
957# also follow temporary redirections comming from &domainify and | 957# also follow temporary redirections coming from &domainify and |
958# &mxlookup 959sub mx 960{ 961 local($h,$u) = @_; 962 963 for (;;) { 964 if (defined $mx{&trhost($h)} && $h ne $mx{&trhost($h)}) { 965 $0 = "$av0 - mx expand $h"; --- 61 unchanged lines hidden (view full) --- 1027 $cpref = $pref; 1028 } elsif ($pref) { 1029 $fallback{$pref} .= " $nh"; 1030 } 1031 } 1032 } 1033 if (/Non-existent domain/) { 1034 # | 958# &mxlookup 959sub mx 960{ 961 local($h,$u) = @_; 962 963 for (;;) { 964 if (defined $mx{&trhost($h)} && $h ne $mx{&trhost($h)}) { 965 $0 = "$av0 - mx expand $h"; --- 61 unchanged lines hidden (view full) --- 1027 $cpref = $pref; 1028 } elsif ($pref) { 1029 $fallback{$pref} .= " $nh"; 1030 } 1031 } 1032 } 1033 if (/Non-existent domain/) { 1034 # |
1035 # These addresss are hosed. Kaput! Dead! | 1035 # These addresses are hosed. Kaput! Dead! |
1036 # However, if we created the address in the 1037 # first place then there is a chance of 1038 # salvation. 1039 # 1040 1 while(<NSLOOKUP>); 1041 close(NSLOOKUP); 1042 return 0 unless $lastchance; 1043 &giveup('domainify',"$server: Non-existent domain",undef,1); --- 42 unchanged lines hidden (view full) --- 1086# this is only used by &final 1087sub mxunroll 1088{ 1089 local(*host,*addr) = @_; 1090 local($r) = 0; 1091 print "looking for mxbacktrace{$addr *** $host}\n" 1092 if ($debug > 1); 1093 while (defined $mxbacktrace{"$addr *** $host"}) { | 1036 # However, if we created the address in the 1037 # first place then there is a chance of 1038 # salvation. 1039 # 1040 1 while(<NSLOOKUP>); 1041 close(NSLOOKUP); 1042 return 0 unless $lastchance; 1043 &giveup('domainify',"$server: Non-existent domain",undef,1); --- 42 unchanged lines hidden (view full) --- 1086# this is only used by &final 1087sub mxunroll 1088{ 1089 local(*host,*addr) = @_; 1090 local($r) = 0; 1091 print "looking for mxbacktrace{$addr *** $host}\n" 1092 if ($debug > 1); 1093 while (defined $mxbacktrace{"$addr *** $host"}) { |
1094 print "Unrolling MX expnasion: \@$host:$addr -> " | 1094 print "Unrolling MX expansion: \@$host:$addr -> " |
1095 if ($debug || $verbose); 1096 $host = $mxbacktrace{"$addr *** $host"}; 1097 print "\@$host:$addr\n" 1098 if ($debug || $verbose); 1099 $r = 1; 1100 } 1101 return 1 if $r; 1102 $addr = "\@$host:$addr" 1103 if ($host =~ /\./); 1104 return 0; 1105} | 1095 if ($debug || $verbose); 1096 $host = $mxbacktrace{"$addr *** $host"}; 1097 print "\@$host:$addr\n" 1098 if ($debug || $verbose); 1099 $r = 1; 1100 } 1101 return 1 if $r; 1102 $addr = "\@$host:$addr" 1103 if ($host =~ /\./); 1104 return 0; 1105} |
1106# register a completed expnasion. Make the final address as | 1106# register a completed expansion. Make the final address as |
1107# simple as possible. 1108sub final 1109{ 1110 local($addr,$host,$name,$error) = @_; 1111 local($he); 1112 local($hb,$hr); 1113 local($au,$ah); 1114 --- 195 unchanged lines hidden (view full) --- 1310watch, flag will cause 1311.B expn 1312to show you its conversations with the mail daemons. 1313Finally, the 1314.IR -d , 1315debug, flag will expose many of the inner workings so that 1316it is possible to eliminate bugs. 1317.SH ENVIRONMENT | 1107# simple as possible. 1108sub final 1109{ 1110 local($addr,$host,$name,$error) = @_; 1111 local($he); 1112 local($hb,$hr); 1113 local($au,$ah); 1114 --- 195 unchanged lines hidden (view full) --- 1310watch, flag will cause 1311.B expn 1312to show you its conversations with the mail daemons. 1313Finally, the 1314.IR -d , 1315debug, flag will expose many of the inner workings so that 1316it is possible to eliminate bugs. 1317.SH ENVIRONMENT |
1318No enviroment variables are used. | 1318No environment variables are used. |
1319.SH FILES 1320.PD 0 1321.B /tmp/expn$$ 1322.B temporary file used as input to 1323.BR nslookup . 1324.SH SEE ALSO 1325.BR aliases (5), 1326.BR sendmail (8), --- 43 unchanged lines hidden --- | 1319.SH FILES 1320.PD 0 1321.B /tmp/expn$$ 1322.B temporary file used as input to 1323.BR nslookup . 1324.SH SEE ALSO 1325.BR aliases (5), 1326.BR sendmail (8), --- 43 unchanged lines hidden --- |