1
0

validatesender 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/rc
  2. rfork en
  3. fn usage{
  4. echo 'usage: validatesender [-n /net] plan9.bell-labs.com glenda' >[1=2]
  5. exit usage
  6. }
  7. echo $sysname $pid '$' validatesender $* >>/sys/log/smtpd.mx
  8. netroot=/net
  9. if(~ $1 -n){
  10. shift
  11. netroot=$1
  12. shift
  13. }
  14. if(! ~ $#* 2)
  15. usage
  16. dom=$1
  17. addr=$2
  18. # Cause some problems
  19. if(~ $dom swtch.com && ~ $addr glenda && ! ~ $sysname olive)
  20. exit 'deferred: always defer this one'
  21. # Sites that we have to special case
  22. # Lucent only - use external network when mail from external domains
  23. # is delivered to us internally. Assume that local domains are fine.
  24. #netroot=/net
  25. #if(~ $dom *.lucent.com lucent.com *.bell-labs.com bell-labs.com)
  26. # exit ''
  27. #if(! ~ $sysname ethel)
  28. # exit ''
  29. #if(~ $sysname ethel){
  30. # if(! test -d /net.alt/tcp)
  31. # import outside /net.alt
  32. # if(test -d /net.alt/tcp)
  33. # netroot=/net.alt
  34. #}
  35. if(x=`{upas/smtp -p $netroot/tcp!$dom /dev/null $addr >[2=1] |
  36. tee >{sed 's/^/'$sysname' '$pid' /' >> /sys/log/smtpd.mx} |
  37. tail -1})
  38. exit ''
  39. smtpstatus=$status
  40. if(~ $#x 0)
  41. x=$smtpstatus
  42. if(~ $smtpstatus *'Permanent Failure'*)
  43. exit 'rejected: smtp ping: '^$"x
  44. exit 'deferred: smtp ping: '^$"x