home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume1 / uk-1.1 / part1 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  42.4 KB

  1. Date: Mon, 13 May 85 21:59:59 BST
  2. From: decvax!mcvax!jimc@ukc.ac.uk
  3. Subject: UK-1.1 Sendmail Configuration Package. Part 1 of 3
  4.  
  5.  
  6. #    This is a shell archive.
  7. #    Remove everything above and including the cut line.
  8. #    Then run the rest of the file through sh.
  9. -----cut here-----cut here-----cut here-----cut here-----
  10. #!/bin/sh
  11. # shar:    Shell Archiver
  12. #    Run the following text with /bin/sh to create:
  13. #    README
  14. #    MAKE
  15. #    Mailers.a
  16. #    Rules.a
  17. #    Support
  18. # This archive created: Mon May 13 18:37:37 1985
  19. echo shar: extracting README '(6249 characters)'
  20. cat << \SHAR_EOF > README
  21. Scenario
  22. --------
  23. This configuration file is designed to handle three basic scenarios:
  24.  
  25. 1.   A single-host site
  26. 2.   A multi-host site with one central host, and a number of satellites
  27. 3.   A multi-host site which is fully distributed, i.e. no central host
  28.  
  29. As an example, consider a site called "ucs", whose domain name is "ucs.ac.uk".
  30.  
  31. In case 1, the host name is the same as the site name - "ucs".
  32.  
  33. In case 2, the central host is called "ucs", and its domain name is
  34.        "ucs.ac.uk". Satellite hosts will be subdomains of "ucs" so,
  35.        for example, a satellite host whose hostname is "vax1" will
  36.        have domain name "vax1.ucs.ac.uk"
  37.        Mail sent to user@ucs would always be sent to the central machine
  38.        (where it may be aliased to be delivered at a satellite).
  39.  
  40. In case 3, All hosts are like satellites in that they are all subdomains
  41.        of "ucs" (there is no host called "ucs").
  42.        Mail to user@ucs will be either aliased to a specific host or
  43.        delivered locally. (The same alias file can be distributed
  44.        to all machines.)
  45.        From the outside, all hosts will appear as one host - "ucs".
  46.  
  47. Mailers
  48. -------
  49. The following mailers are supported:
  50.  
  51.     local        the standard unix local mailer
  52.     ether        mail over the ethernet
  53.     luucp        local uucp mail (uses domain addressing)
  54.     uucp        external uucp mail
  55.     janet        janet mail, using hhcp
  56.     bitnet        bitnet mail, using rscs
  57.  
  58.  
  59. Addresses
  60. ---------
  61. This configuration file accepts addresses in any of the standard forms:
  62.  
  63.     RFC822 style:        @domain1,@domain2:user@domain3
  64.     Percent style:        user%domain3%domain2@domain1
  65.     UUCP style:        domain1!domain2!domain3!user
  66.  
  67. (If you define the Janet mailer then JNT style with big-endian domain name
  68.  ordering is also understood).
  69.  
  70. Mixed addresses are handled by using the precedence order '@' > '%' > '!'
  71. e.g.    domc!user%domb@doma => user%domc%domb@doma <=> doma!domb!domc!user
  72.  
  73.  
  74. Configuration Overview
  75. ----------------------
  76. These address forms are converted in ruleset 3 to one internal form - which
  77. is Percent style. The rulesets 5 and 6 are then called which expands
  78. incomplete domain names and aliases into full domain names.
  79.  
  80. The routing rule, ruleset 9, called from ruleset 0, converts this domain form
  81. to an <address>host.network triple from which the appropriate mailer is
  82. selected in ruleset 0.
  83.  
  84. Meanwhile the mailer specific rulesets convert the header addresses returned
  85. by ruleset 3 into the appropriate form for the mailer.
  86.  
  87.  
  88. Files
  89. -----
  90. The configuration file is generated from a set of m4 files:
  91. Site independent:
  92.     base.m4        Defines special macros, options and headers etc.
  93.     version.m4    Gives the version number and history
  94.     rules.m4    Defines the standard rulesets
  95.     rules1.m4    Defines rulesets to do address conversions
  96.     <mailer>m.m4    Mailer specifications - one for each of the above
  97.             mailers
  98.  
  99. Site dependent:
  100.     <site>.dom    Defines the domain tables for the site
  101.  
  102. Host dependent:
  103.     <host>.mc    This defines some macros and reads everything else in.
  104.     <host>.chn    This specifies all the routing information for
  105.             non-local mail
  106.  
  107.  
  108. Installation
  109. ------------
  110. 1.  Decide what your host, site and domain names are for this host.
  111.  
  112. 2.  Then run "MAKE".  
  113.  
  114.     This creates a directory containing all the rules and mailer m4 files
  115.     required for this configuration and creates the <host>.mc file.
  116.  
  117.     MAKE will first ask for your host, site and domain names. If the host
  118.     and site names are the same then MAKE assumes that this is either a
  119.     single host site (case 1) or the central machine of multi-host site
  120.     (case 2);  if they are different then MAKE asks if there is a central
  121.     host for this site (case 2); if there isn't it assumes this a distributed
  122.     multi-host site (case 3).
  123.  
  124.     MAKE will then prompt for the mailers to include in the configuration,
  125.     and then it creates all the files. 
  126.  
  127. 3.  "cd" to directory dom.
  128.     Here you must setup the domain tables from which the <site>.dom file
  129.     is generated.
  130.  
  131.     There is only one of these per site, so if you have already done this
  132.     on another host, just copy the tables to this host.
  133.  
  134.     More details are found in the README contained in the "dom" directory.
  135.  
  136. 4.  "cd" to directory chn
  137.     Here you must setup the channel tables which give all the routing
  138.     information from which the <host>.chn file is generated.
  139.  
  140.     More details are found in the README contained in the "chn" directory.
  141.  
  142. 5.  "cd" to the <host> directory.
  143.     Run "make" to produce the <host>.cf file.
  144.     This can be tested by using "sendmail -bt -C<host>.cf" - if you haven't
  145.     used this before then see the sendmail documentation for details.
  146.  
  147.     Also check that the mailer specification files have the correct
  148.     pathnames and options to the mailers, particularly the local mailer!
  149.  
  150. 6.  As superuser, run "make install" to install this. If you have a
  151.     sendmail daemon running (typically: /usr/lib/sendmail -bd -q1h),
  152.     then kill it and start a new one.
  153.  
  154.  
  155. Running shared configuration files
  156. ----------------------------------
  157. In the case where (satellite) hosts have the same routing information
  158. and mailers to mail to other hosts, they can use the same configuration
  159. file.  To to this, run "MAKE" for one host, then edit the "DOMAIN"
  160. definition in the resulting ".mc" file replacing the hostname with "$w".
  161. e.g.
  162.     define(`DOMAIN',`$w.usc.ac.uk')
  163.  
  164. Run make and copy the resulting configuration file to all appropriate hosts.
  165.  
  166.  
  167. Support programs
  168. ----------------
  169. The Support directory contains programs that interface with sendmail.
  170. More details are found in the README in the "Support" directory.
  171.  
  172.  
  173. Aliases
  174. -------
  175. A type 3 site can use a common aliases file on all hosts containing
  176. a list of users and the host addresses to which they wish their mail
  177. to be delivered to, e.g.
  178.  
  179.     jim:    jim@vax1
  180.     fred:    fred@vax2
  181.  
  182. Addresses of the form "user", "user@host" and "user@site" are all subject
  183. to possible aliasing.  In the "usc" example, "jim@vax2" will be sent to vax2.
  184. If the aliases file on vax2 contains the above entries then the mail will
  185. be delivered on vax1 (or aliased again).
  186.  
  187. Aliasing can be overridden by prepending a '~' to the user, so "~jim@vax2"
  188. will be delivered on vax2.
  189.  
  190.  
  191.  
  192. --------
  193. Mail bugs and comments to:  jim@hwcs.uucp  (hwcs!jim)
  194.            soon to be:  jim@cs.hw.ac.uk
  195.  
  196. -Jim Crammond            22.4.85
  197. SHAR_EOF
  198. if test 6249 -ne "`wc -c README`"
  199. then
  200. echo shar: error transmitting README '(should have been 6249 characters)'
  201. fi
  202. echo shar: extracting MAKE '(3263 characters)'
  203. cat << \SHAR_EOF > MAKE
  204. #!/bin/sh
  205.  
  206. echo 'Sendmail initial configuration program  UK-1.1
  207. '
  208.  
  209. ether=
  210. uucp=
  211. janet=
  212. bitnet=
  213.  
  214. #
  215. #  site dependant information information about names and mailers
  216. #
  217. host=`(hostname) 2> /dev/null || (uuname -l) 2> /dev/null`
  218. site=$host
  219.  
  220. echo -n "Enter name of host ($host): "
  221. read reply
  222. if [ "$reply" != "" ]
  223. then
  224.     host=$reply
  225. fi
  226.  
  227. echo -n "Enter name of site ($site): "
  228.  
  229. read reply
  230. if [ "$reply" != "" ]
  231. then
  232.     site=$reply
  233. fi
  234.  
  235. if [ $site = $host ]
  236. then
  237.     echo -n "Complete host domain name: $host."
  238.     read domain
  239.     domain=$host.$domain
  240. else
  241.     echo -n "Complete host domain name: $host.$site."
  242.     read domain
  243.     domain=$site.$domain
  244.     echo -n "Is there a host \"$site\" in domain \"$domain\"? (y|n) "
  245.     read reply
  246.     if [ "$reply" != 'y' ]
  247.     then
  248.         multihost=true
  249.     else
  250.         domain=$host.$domain
  251.     fi
  252. fi
  253.  
  254. echo -n "
  255. Site name = $site, Host name = $host, Domain name = $domain
  256. confirm? (y|n) "
  257.  
  258. read reply
  259. if [ "$reply" != 'y' ]
  260. then
  261.     echo 'Start again'
  262.     exit 1
  263. fi
  264.  
  265. echo "
  266. A list of available mailer configurations  will follow
  267. type 'y' at the prompt to include the specified mailer.
  268. "
  269.  
  270. echo -n "ethernet? "
  271. read reply
  272. if [ "$reply" = 'y' ]; then ether=etherm.m4; fi
  273.  
  274. echo -n "uucp? "
  275. read reply
  276. if [ "$reply" = 'y' ]
  277. then
  278.     uucp="luucpm.m4 uucpm.m4";
  279.     uucpname=`uuname -l`
  280.     echo -n "Enter uucp name ($uucpname): "
  281.     read reply
  282.     if [ -n "$reply" ]
  283.     then
  284.         uucpname=$reply
  285.     fi
  286. fi
  287.  
  288. echo -n "janet? "
  289. read reply
  290. if [ "$reply" = 'y' ]; then janet=hhcpm.m4; fi
  291.  
  292. echo -n "bitnet? "
  293. read reply
  294. if [ "$reply" = 'y' ]; then bitnet=bitnetm.m4; fi
  295.  
  296. #
  297. #  now start creating the files
  298. #
  299. echo -n "
  300. Making directory $host... "
  301. if mkdir $host
  302. then
  303.     cd $host
  304. else
  305.     echo mkdir failed, aborted
  306.     exit 1
  307. fi
  308.  
  309. echo -n '
  310. creating rules... '
  311. ar x ../Rules.a
  312. echo -n '
  313. creating mailers... '
  314. ar x ../Mailers.a localm.m4 $ether $uucp $janet $bitnet
  315.  
  316. echo -n '
  317. creating Makefile... '
  318. cat >Makefile <<EOF
  319. #######################################################################
  320. #
  321. #    Makefile for Sendmail configuration files
  322. #
  323. #    @(#)Makefile    UK-1.1 sendmail configuartion        22/4/85
  324. #
  325. #######################################################################
  326. HOST=$host
  327. SITE=$site
  328. RULES=base.m4 rules.m4 rules1.m4 version.m4
  329. MAILERS=localm.m4 $ether $uucp $janet $bitnet
  330.  
  331. EOF
  332.  
  333. cat >>Makefile <<'EOF'
  334. .SUFFIXES: .mc .cf
  335.  
  336. .mc.cf:
  337.     m4 $*.mc > $*.cf
  338.  
  339. $(HOST).cf:    $(RULES) $(MAILERS) $(SITE).dom $(HOST).chn
  340.  
  341. $(SITE).dom:    ../dom/$(SITE).dom
  342.         cp ../dom/$(SITE).dom $(SITE).dom
  343.  
  344. $(HOST).chn:    ../chn/$(HOST).chn
  345.         cp ../chn/$(HOST).chn $(HOST).chn
  346.  
  347. install:    $(HOST).cf
  348.     sed -e '/^#/d' -e '/^$$/d' $(HOST).cf > /usr/lib/sendmail.cf
  349.     -if [ -f /usr/lib/sendmail.fc ]; then /usr/lib/sendmail -bz; fi
  350. EOF
  351.  
  352. echo -n "
  353. creating $host.mc... "
  354. cat >$host.mc <<EOF
  355. define(\`HOST',\`$host')
  356. define(\`SITE',\`$site')
  357. define(\`DOMAIN',\`$domain')
  358. EOF
  359.  
  360. if [ -n "$multihost" ]
  361. then
  362.     echo "define(\`MULTIHOST')" >> $host.mc
  363. fi
  364.  
  365. if [ -n "$ether" ]
  366. then
  367.     echo "define(\`ETHER')" >> $host.mc
  368. fi
  369.  
  370. if [ -n "$uucp" ]
  371. then
  372.     echo "define(\`UUCPNAME',\`$uucpname')" >> $host.mc
  373. fi
  374.  
  375. if [ -n "$janet" ]
  376. then
  377.     echo "define(\`JANET')" >> $host.mc
  378. fi
  379.  
  380. if [ -n "$bitnet" ]
  381. then
  382.     echo "define(\`BITNET')" >> $host.mc
  383. fi
  384.  
  385. echo 'include(base.m4)' >> $host.mc
  386.  
  387. echo "
  388. Initial configuration complete.
  389.  
  390. You now have to make the $site.dom and $host.chn files.
  391. "
  392.  
  393. exit
  394. SHAR_EOF
  395. if test 3263 -ne "`wc -c MAKE`"
  396. then
  397. echo shar: error transmitting MAKE '(should have been 3263 characters)'
  398. fi
  399. echo shar: extracting Mailers.a '(5816 characters)'
  400. cat << \SHAR_EOF > Mailers.a
  401. !<arch>
  402. bitnetm.m4      483046164   217   10    100644  1384      `
  403. ###############################################################################
  404. ###############################################################################
  405. #####
  406. #####        Bitnet Mailer specification
  407. #####
  408. #####    @(#)bitnetm.m4    UK-1.1 sendmail configuration        22/4/85
  409. #####
  410. ###############################################################################
  411. ###############################################################################
  412.  
  413. Mbitnet,    P=/usr/bin/vmcopy, F=SnsFDMR, S=22, R=22,
  414.     A=vmcopy $u@$h class=M fname=MAILER ftype=MAIL width=80 device=PUNCH
  415.  
  416. S22
  417.  
  418. #
  419. #  Bitnet can only cope with user@host.bitnet i.e. no subdomains
  420. #  therefore strip off any that exist
  421. #
  422.  
  423. R$+@$=A.$j        $@$1@$j            strip off any local hostname
  424. R$+@$+            $@$1@$2            return user@domain
  425. R$+            $@$1@$j            add local domain name
  426.  
  427.  
  428. ##################################################################
  429. #####
  430. #####    Arpa Mail Via Batched Simple Mail Transfer Protocol
  431. #####
  432. ##################################################################
  433.  
  434. Mbarpa,    P=/usr/lib/rscs/bsmtp, F=SnsFDMRX, S=22, R=22,
  435.     A=bsmtp%mail $j $g $u $h
  436.  
  437.  
  438. ##################################################################
  439. #####
  440. #####    Uucp Mail Via Batched Simple Mail Transfer Protocol
  441. #####
  442. ##################################################################
  443.  
  444. Mbuucp,    P=/usr/lib/rscs/bsmtp, F=SnsFDMRuhX, S=22, R=22, M=100000,
  445.     A=bsmtp%mail $j $g $u $h
  446. etherm.m4       483046164   217   10    100644  557       `
  447. ###############################################################################
  448. ###############################################################################
  449. #####
  450. #####        Ethernet Mailer specification
  451. #####
  452. #####    @(#)etherm.m4    UK-1.1 sendmail configuration        22/4/85
  453. #####
  454. ###############################################################################
  455. ###############################################################################
  456.  
  457. Mether,    P=[IPC], F=nsmFDMRuXC, S=17, R=15, A=IPC $h
  458.  
  459. S17
  460. R$+@$+            $@$1@$2            address ok
  461. R$+            $@$1@$w            add local hostname
  462.  
  463. hhcpm.m4        483046164   217   10    100644  703       `
  464. ###############################################################################
  465. ###############################################################################
  466. #####
  467. #####        Janet Mailer specification
  468. #####
  469. #####    @(#)hhcpm.m4    UK-1.1 sendmail configuration        22/4/85
  470. #####
  471. ###############################################################################
  472. ###############################################################################
  473.  
  474. Mhhcp, P=/usr/lib/x25/hhsend, F=nsmFDMxVh, S=21, R=21, M=100000,
  475.     A=hhsend $h $u
  476.  
  477. S21
  478. ifdef(`MULTIHOST',
  479. `R$+@$=A.$j        $1@$j            strip local hostname')
  480. R$+@$+            $@$>14$1@$2        RFC822 -> NRS style
  481.  
  482. R$+            $:$1@$j            user -> user@mydomain
  483. R$+@$+            $@$>14$1@$2        RFC822 -> NRS style
  484.  
  485. localm.m4       483046164   217   10    100644  1155      `
  486. ###############################################################################
  487. ###############################################################################
  488. #####
  489. #####        Local and Program Mailer specification
  490. #####
  491. #####    @(#)localm.m4    UK-1.1 sendmail configuration        22/4/85
  492. #####
  493. ###############################################################################
  494. ###############################################################################
  495.  
  496. Mlocal,      P=/bin/mail, F=rnlsmFDMR, S=16, R=16, A=mail -d $u
  497. Mbinmail, P=/bin/mail, F=rnlsmFDMR, S=16, R=16, A=mail -d $u
  498. Mprog,      P=/bin/sh,   F=nlsFDMR,   S=16, R=16, A=sh -c $u
  499.  
  500. #
  501. #  The important thing here is to keep a valid reply path!
  502. #  Apparent uucp addresses are converted back to old style so that
  503. #  ucb-mail can cope with replies. Otherwise the domain is just stripped.
  504. #
  505. S16
  506.  
  507. R@            MAILER-DAEMON        errors to mailer-daemon
  508. R~$+            $1            remove '~' in To: line
  509.  
  510. R$+@$+            $:$>7$1@$2        strip domain addresses
  511.  
  512. # we assume an address is a uucp address if it contains more than two
  513. # hostnames (as opposed to domain names).  This is not always right..
  514. R$+%$-%$-@$+        $@$>13$1%$2%$3@$4    convert to uucp address
  515.  
  516. luucpm.m4       483046164   217   10    100644  588       `
  517. ###############################################################################
  518. ###############################################################################
  519. #####
  520. #####        Local UUCP Mailer specification
  521. #####
  522. #####    @(#)luucpm.m4    UK-1.1 sendmail configuration        22/4/85
  523. #####
  524. ###############################################################################
  525. ###############################################################################
  526.  
  527. Mluucp,    P=/usr/bin/uux, F=smFDMRuh, S=18, R=18, M=100000,
  528.     A=uux - $h!rmail ($u)
  529.  
  530. S18
  531. R$+@$+            $@$1@$2            address ok
  532. R$+            $@$1@$w            add local hostname
  533. uucpm.m4        483046164   217   10    100644  1057      `
  534. ###############################################################################
  535. ###############################################################################
  536. #####
  537. #####        UUCP Mailer specification
  538. #####
  539. #####    @(#)uucpm.m4    UK-1.1 sendmail configuration        22/4/85
  540. #####
  541. ###############################################################################
  542. ###############################################################################
  543.  
  544. Muucp,    P=/usr/bin/uux, F=sFDMRuh, S=19, R=20, M=100000,
  545.     A=uux - -r -gA $h!rmail ($u)
  546.  
  547. #
  548. #  Addresses are converted back to uucp style.
  549. #  We need to do this to generate a valid Unix From line.
  550. #  However this invalidates the From: line in the header, which should be
  551. #  in 822 format - strictly speaking.  Sendmail won't let you do this!
  552. #
  553. S19
  554. R$+@$+            $:$>13$1@$2        convert to uucp style
  555. ifdef(`MULTIHOST',
  556. `R$=A.$j!$+        $2            strip local hostnames')
  557. R$+!$+            $@$1!$2            address ok
  558. R$+            $@$j!$1            add local domain name
  559.  
  560. #
  561. #  To: line is handled normally
  562. #
  563. S20
  564. R$+@$+            $@$1@$2            address ok
  565. R$+            $@$1@$j            add local domain name
  566.  
  567. SHAR_EOF
  568. if test 5816 -ne "`wc -c Mailers.a`"
  569. then
  570. echo shar: error transmitting Mailers.a '(should have been 5816 characters)'
  571. fi
  572. echo shar: extracting Rules.a '(11204 characters)'
  573. cat << \SHAR_EOF > Rules.a
  574. !<arch>
  575. base.m4         483183564   217   10    100644  2953      `
  576. ##################################################################
  577. ##################################################################
  578. #####
  579. #####        SENDMAIL CONFIGURATION FILE  UK-1.1
  580. #####
  581. #####   Copyright Jim Crammond, Heriot-Watt University. Apr. 1985.
  582. #####
  583. #####    This configuration file maybe be freely distributed,
  584. #####    provided no profit is gained by doing so.
  585. #####
  586. ##################################################################
  587. ##################################################################
  588.  
  589. ##################################################################
  590. `###'    HOST configuration file
  591. ##################################################################
  592.  
  593. # domain name
  594. Dj`'DOMAIN
  595.  
  596. # uucp hostname
  597. ifdef(`UUCPNAME',DU`'UUCPNAME)
  598.  
  599. ############################################################
  600. #
  601. #    General configuration information
  602. #
  603. ############################################################
  604.  
  605. include(version.m4)
  606.  
  607. ##########################
  608. ###   Special macros   ###
  609. ##########################
  610.  
  611. # my name
  612. DnMAILER-DAEMON
  613. # UNIX header format
  614. DlFrom $g $d remote from $U
  615. # delimiter (operator) characters (note '~' has been added)
  616. Do.:%@!^=/[]~
  617. # format of a total name
  618. Dq$?x$x $.<$g>
  619. # SMTP login message
  620. ifdef(`MULTIHOST',
  621. `De$w.$j Sendmail $v/$V ready at $b',`De$j Sendmail $v/$V ready at $b')
  622.  
  623. ###################
  624. ###   Options   ###
  625. ###################
  626.  
  627. # location of alias file
  628. OA/usr/lib/aliases
  629. # default delivery mode (deliver in background)
  630. Odbackground
  631. # (don't) connect to "expensive" mailers
  632. #Oc
  633. # temporary file mode
  634. OF0644
  635. # default GID
  636. Og1
  637. # location of help file
  638. OH/usr/lib/sendmail.hf
  639. # log level
  640. OL9
  641. # default messages to old style
  642. Oo
  643. # queue directory
  644. OQ/usr/spool/mqueue
  645. # read timeout -- violates protocols
  646. Or2h
  647. # status file
  648. OS/usr/lib/sendmail.st
  649. # queue up everything before starting transmission
  650. # Os
  651. # default timeout interval
  652. OT3d
  653. # time zone names (V6 only)
  654. # OtGMT,BST
  655. # default UID
  656. Ou1
  657. # wizard's password
  658. OWz3GvK.dPUxieQ
  659.  
  660. ###############################
  661. ###   Message precedences   ###
  662. ###############################
  663.  
  664. Pfirst-class=0
  665. Pspecial-delivery=100
  666. Pjunk=-100
  667.  
  668. #########################
  669. ###   Trusted users   ###
  670. #########################
  671.  
  672. Troot
  673. Tdaemon
  674. Tuucp
  675. Tjim
  676.  
  677. #############################
  678. ###   Format of headers   ###
  679. #############################
  680.  
  681. H?F?From: $q
  682. H?D?Date: $a
  683. H?F?Resent-From: $q
  684. H?D?Resent-Date: $a
  685. HSubject:
  686. ifdef(`MULTIHOST',
  687. `H?R?Received: $?sfrom $s by $w.$j; $b$.',`H?R?Received: $?sfrom $s by $j; $b$.')
  688. H?V?Via: $?s$s; $b$.
  689.  
  690.  
  691. ##########################
  692. ###    The Rulesets    ###
  693. ##########################
  694. include(rules.m4)
  695. include(rules1.m4)
  696. include(SITE.dom)
  697. include(HOST.chn)
  698.  
  699. #########################
  700. ###    The Mailers    ###
  701. #########################
  702. include(localm.m4)
  703. ifdef(`ETHER',`include(etherm.m4)')
  704. ifdef(`UUCPNAME',`include(luucpm.m4)')
  705. ifdef(`UUCPNAME',`include(uucpm.m4)')
  706. ifdef(`JANET',`include(hhcpm.m4)')
  707. ifdef(`BITNET',`include(bitnetm.m4)')
  708.  
  709. rules.m4        484580248   217   10    100644  3178      `
  710. ###############################################################################
  711. ###############################################################################
  712. #####
  713. #####    @(#)rules.m4    UK-1.1 sendmail configuration        22/4/85
  714. #####
  715. #####    The rulesets
  716. #####
  717. ###############################################################################
  718. ###############################################################################
  719.  
  720. ###############################################
  721. #  Ruleset 0  --  Select mailer to be used    #
  722. ###############################################
  723. S0
  724.  
  725. # local domain - redo with local part of address
  726. R$+@$j            $>3$1
  727. ifdef(`MULTIHOST',`R$+@$w.$j        $>3$1')
  728.  
  729. # local mail
  730. R$-            $#local$:$1        local mail - maybe aliased
  731. R~$-            $#binmail$:$1        local mail - no aliasing
  732.  
  733. #
  734. # convert domain address into "<address>host.network" triple
  735. #
  736. R$+@$+.$=T        $:$>9$1@$2.$3        routing and address conversion
  737.  
  738. # select mailer
  739. ifdef(`ETHER',`
  740. R<$+>$-.ether        $#ether$@$2$:$1        local ethernet mail
  741. ')
  742. ifdef(`UUCPNAME',`
  743. R<~$+>$+.luucp        <\\~$1>$2.luucp        band-aid for uuxqt
  744. R<~$+>$+.uucp        <\\~$1>$2.uucp        band-aid for uuxqt
  745. R<$+>$-.luucp        $#luucp$@$2$:$1        local uucp mail
  746. R<$+>$-.uucp        $#uucp$@$2$:$1        external uucp mail
  747. ')
  748. ifdef(`JANET',`
  749. R<$+>$+.janet        $#hhcp$@$2$:$1        janet mail
  750. ')
  751. ifdef(`BITNET',`
  752. R<$+>$-.bitnet        $#bitnet$@$2$:$1    bitnet mail
  753. R<$+>$+.barpa        $#barpa$@$2$:$1        arpa mail via bitnet
  754. R<$+>$+.buucp        $#buucp$@$2$:$1        uucp mail via bitnet
  755. ')
  756.  
  757. # anything else with an '@' in is an error
  758. R$+@$+            $#error$:Domain Unknown
  759.  
  760. # anything else - e.g. filenames, pipes etc goes to local mailer
  761. R$+            $#local$:$1        local
  762.  
  763.  
  764. ###############################################
  765. #  Ruleset 1  --  Sender Field Pre-rewriting  #
  766. ###############################################
  767. S1
  768.  
  769.  
  770. ##################################################
  771. #  Ruleset 2  --  Recipient Field Pre-rewriting  #
  772. ##################################################
  773. S2
  774.  
  775.  
  776. ##########################################
  777. #  Ruleset 3  --  Name Canonicalisation  #
  778. ##########################################
  779. S3
  780.  
  781. #  handle special cases
  782. R$-            $@$1            return "user"
  783. R~$-            $@~$1            return "~ user"
  784. R<>            $@@            turn null into magic token
  785.  
  786. #  basic textual canonicalisation
  787. R$*<$*>$*        $2            basic RFC 822 parsing
  788. R$+ at $+        $1@$2            " at " -> "@" for RFC 822
  789. R$+%$+            $1@$2            convert '%'s to '@'s
  790. R$+@$+@$+        $1%$2@$3        then reduce to only one '@'
  791.  
  792. #  Address conversions. See rules1.m4 for the gory details
  793. R@$+:$+            $:$>10@$1:$2        RFC822 to Percent form
  794. R$+!$+            $:$>12$1!$2        uucp to Percent form
  795.  
  796. ifdef(`JANET',`
  797. R$+@$+.$+        $:$>8$1@$2.$3        NRS ordering to 822 ordering
  798. ')
  799.  
  800. `#'  Domain name expansion. See SITE`'.dom for the details
  801. R$+@$+            $:$>5$1@$2        do domain name aliases
  802. R$+@$+            $:$>6$1@$2        expand incomplete domain names
  803.  
  804.  
  805. ###############################################
  806. #  Ruleset 4  --  Final Output Post-rewriting #
  807. ###############################################
  808.  
  809. #  header rewriting is done in the per-mailer rulesets.
  810.  
  811. S4
  812. R@            $@            handle <> error addr
  813. R$+@$+            $@$1@$2            already ok
  814.  
  815. #  this ensures that $u has at least one '@' in (if percent style)
  816. R$+%$+            $1@$2            convert '%'s to '@'s
  817. R$+@$+@$+        $1%$2@$3        then reduce to only one '@'
  818. rules1.m4       484852372   217   10    100644  3357      `
  819. ###############################################################################
  820. ###############################################################################
  821. #####
  822. #####    @(#)rules1.m4    UK-1.1 sendmail configuration        22/4/85
  823. #####
  824. #####    The rulesets
  825. #####
  826. ###############################################################################
  827. ###############################################################################
  828.  
  829.  
  830. #########################################################
  831. #  Ruleset 10  --  RFC source routing -> Percent style  #
  832. #########################################################
  833.  
  834. #
  835. #  convert a routed address in RFC822 form to Percent form
  836. #  e.g. @ucl-cs.arpa,@kcl-cs.uucp:jim@hwcs.uucp  ->
  837. #                    jim%hwcs.uucp%kcl-cs.uucp@ucl-cs.arpa
  838. #
  839. S10
  840.  
  841. R$+,$+            $1:$2            @a,@b,@c:u%d -> @a:@b:@c:u%d
  842. R$*@$*            $1%$2            @a:@b:@c:u@d -> %a:%b:%c:u%d
  843.  
  844. R%$+:$+            $:$2@$1            %a:%b:%c:u%d -> %b:%c:u%d@a
  845. R%$+:$+@$+        $2@$1@$3        %b:%c:u%d@a  -> u%d@c@b@a
  846. R$+@$+@$+        $1%$2@$3        u%d@c@b@a    -> u%d%c%b@a
  847.  
  848. ###############################################################
  849. #  Ruleset 11  --  Percent style source routing -> RFC style  #
  850. ###############################################################
  851.  
  852. #
  853. #  convert a routed address in the Percent form to RFC822 form
  854. #  e.g.    jim%hwcs.uucp%kcl-cs.uucp@ucl-cs.arpa  ->
  855. #                <@ucl-cs.arpa,@kcl-cs.uucp:jim@hwcs.uucp>
  856. #
  857. S11
  858.  
  859. R$+@$+            $1%$2            u%d%c%b@a    -> u%d%c%b%a
  860. R$+%$+%$+        $:@$3:$1@$2        u%d%c%b%a    -> @c%b%a:u@d
  861. R$+%$+:$+        @$2:$1:$3        @c%b%a:u%d   -> @a:@b:@c:u@d
  862. R$+:$+:$+        $1,$2:$3        @a:@b:@c:u@d -> @a,@b,@c:u@d
  863. R@$+            $@<@$1>            @a,@b,@c:u@d -> <@a,@b,@c:u@d>
  864.  
  865. ################################################################
  866. #  Ruleset 12  --  uucp style source routing -> Percent style  #
  867. ################################################################
  868.  
  869. #
  870. #  convert an address in uucp form to Percent form
  871. #  e.g. kcl-cs.uucp!hwcs.uucp!jim -> jim%hwcs.uucp@kcl-cs.uucp
  872. #
  873. #  also converts mixed addresses, giving '@' and '%' priority over '!'
  874. #  e.g. hwcs!jim%kcl-cs.uucp@ucl-cs.arpa -> jim%hwcs%kcl-cs.uucp@ucl-cs.arpa
  875. #
  876. S12
  877.  
  878. # handle mixed addresses (with '!'s, '@'s and maybe '%'s in)
  879. R$+!$+%$+        $1!$2@$3        c!d!u%b@a -> c!d!u@b@a
  880. R$+!$+@$+        $2@$1@$3        c!d!u@b@a -> u@d@c@b@a
  881.  
  882. # handle pure uucp addresses
  883. R$+!$+            $:$2@$1            a!b!c!d!u -> b!c!d!u@a
  884. R$+!$+@$+        $2@$1@$3        b!c!d!u@a -> u@d@c@b@a
  885.  
  886. R$+@$+@$+        $1%$2@$3        u@d@c@b@a -> u%d%c%b@a
  887.  
  888. ################################################################
  889. #  Ruleset 13  --  Percent style to uucp style source routing  #
  890. ################################################################
  891.  
  892. #
  893. #  convert a Percent style address to uucp (domain1!domain2!user) form
  894. #  e.g. jim%hwcs.uucp@kcl-cs.uucp -> kcl-cs.uucp!hwcs.uucp!jim
  895. #
  896. S13
  897.  
  898. R$+%$+            $1@$2            u%d%c%b@a -> u@d@c@b@a
  899. R$+@$+            $:$2!$1            u@d@c@b@a -> d@c@b@a!u
  900. R$+@$+!$+        $2!$1!$3        d@c@b@a!u -> a!b!c!d!u
  901.  
  902. ifdef(`JANET',`
  903. ######################################################
  904. #  Ruleset 14  --  NRS <-> RFC822 domain conversion  #
  905. ######################################################
  906.  
  907. #
  908. # swap the order of the sub-domains around.
  909. # e.g. steve@uk.ac.ucl-cs.44d => steve@44d.ucl-cs.ac.uk
  910. #
  911. # this assumes that no colons will appear in the rhs of the domain address
  912. #
  913. S14
  914.  
  915. R$*@$+.$+        $1@$2:$3        u@a.b.c.d -> u@a:b:c:d
  916. R$*@$-:$+        $:$1@$3.$2        u@a:b:c:d -> u@b:c:d.a
  917. R$*@$-:$+.$+        $1@$3.$2.$4        u@b:c:d.a -> u@d.c.b.a
  918. ')
  919.  
  920. version.m4      484578324   217   10    100644  1466      `
  921. #
  922. #    @(#)version.m4    UK-1.1 sendmail configuration        22/4/85
  923. #
  924.  
  925. DVUK-1.1
  926.  
  927. #
  928. #    UK-1.1    22/4/85        jim
  929. #    COMMENTS:
  930. #    Changed janet rules in ruleset 3 to cope properly with domain expansion.
  931. #    Changed output of ruleset 9 (channel ruleset) so that ruleset 0
  932. #    can parse multiple-token hostnames.  Support files for janet added.
  933. #    Renamed janet mailer to "hhcp". Added 'n' mailer flag to prog mailer.
  934. #    Added ruleset 8 to detect and convert NRS style domains to 822 style.
  935. #
  936. #    UK-1.0    26/3/85        jim
  937. #    COMMENTS:
  938. #    Some rearranging. Removed ruleset 8 (path optimisation) as it
  939. #    optimised munged addresses away completely! 
  940. #    Ruleset 4 ensures an '@' in Percent style address.
  941. #    Uucp ruleset rewritten to get as close to the uucp transmission
  942. #    standard as sendmail allows.
  943. #
  944. #    HW-5.1    1/3/85        jim
  945. #    COMMENTS:
  946. #    Fixed bug with mailing to filenames. Other cleanup for
  947. #    distribution version.
  948. #
  949. #    HW-5.0    26/2/85        jim
  950. #    COMMENTS:
  951. #    major restructuring: rewrote ruleset 3 which now converts
  952. #    all addresses to one style. Added bitnet mailer and ether mailer
  953. #    Rewrote all the mailer specs. Various other cleanups.
  954. #
  955. #
  956. #    HW-4.3    10/1/85        jim
  957. #    COMMENTS:
  958. #    Cope with rfc822 style routing and renumber some rulesets
  959. #
  960. #    HW-4.2    4/1/85        jim
  961. #    COMMENTS:
  962. #    Put in janet mailer definitions and rules
  963. #
  964. #    HW-4.1    17/12/84    jim
  965. #    COMMENTS:
  966. #    Some modifications and cleanup for distribution
  967. #
  968. #    HW-4.0    5/12/84        jim
  969. #    COMMENTS:
  970. #    This is a complete rewrite based on some ideas borrowed from
  971. #    mmdf.
  972. #
  973. SHAR_EOF
  974. if test 11204 -ne "`wc -c Rules.a`"
  975. then
  976. echo shar: error transmitting Rules.a '(should have been 11204 characters)'
  977. fi
  978. echo shar: creating directory Support
  979. mkdir Support
  980. chdir Support
  981. echo shar: extracting rmail.c '(3690 characters)'
  982. cat << \SHAR_EOF > rmail.c
  983. #ifndef lint
  984. static char sccsid[] =    "@(#)rmail.c    4.4 (Berkeley) 8/11/83";
  985. #endif
  986.  
  987. /*
  988. **  RMAIL -- UUCP mail server.
  989. **
  990. **    This program reads the >From ... remote from ... lines that
  991. **    UUCP is so fond of and turns them into something reasonable.
  992. **    It calls sendmail giving it a -f option built from these
  993. **    lines.
  994. **
  995. **    Modified to set the sender's hostname (deduced from first
  996. **    "remote from host" line) and convert the final "user" part
  997. **    from an address with '@' and '%' (which mmdf is so fond of)
  998. **    in to a 'pure' uucp address.    -Jim Crammond, (hwcs!jim) 29/11/84
  999. */
  1000.  
  1001. # include <stdio.h>
  1002. # include <sysexits.h>
  1003.  
  1004. typedef char    bool;
  1005. #define TRUE    1
  1006. #define FALSE    0
  1007.  
  1008. extern FILE    *popen();
  1009. extern char    *index();
  1010. extern char    *rindex();
  1011. char    *conv_at();
  1012.  
  1013. bool    Debug;
  1014.  
  1015. # define MAILER    "/usr/lib/sendmail"
  1016.  
  1017. main(argc, argv)
  1018.     char **argv;
  1019. {
  1020.     FILE *out;    /* output to sendmail */
  1021.     char lbuf[512];    /* one line of the message */
  1022.     char from[512];    /* accumulated path of sender */
  1023.     char ufrom[64];    /* user on remote system */
  1024.     char sys[64];    /* a system in path */
  1025.     char sysname[64]; /* system received from */
  1026.     char cmd[2000];
  1027.     register char *cp;
  1028.     register char *uf;    /* ptr into ufrom */
  1029.     int firstline = 1;
  1030.     int i;
  1031.  
  1032. # ifdef DEBUG
  1033.     if (argc > 1 && strcmp(argv[1], "-T") == 0)
  1034.     {
  1035.         Debug = TRUE;
  1036.         argc--;
  1037.         argv++;
  1038.     }
  1039. # endif DEBUG
  1040.  
  1041.     if (argc < 2)
  1042.     {
  1043.         fprintf(stderr, "Usage: rmail user ...\n");
  1044.         exit(EX_USAGE);
  1045.     }
  1046.  
  1047.     (void) strcpy(from, "");
  1048.     (void) strcpy(sysname, "");
  1049.     (void) strcpy(ufrom, "/dev/null");
  1050.  
  1051.     while (fgets(lbuf, sizeof lbuf, stdin) != NULL)
  1052.     {
  1053.         if (strncmp(lbuf, "From ", 5) != 0 && strncmp(lbuf, ">From ", 6) != 0)
  1054.             break;
  1055.         (void) sscanf(lbuf, "%*s %s", ufrom);
  1056.         cp = lbuf;
  1057.         uf = ufrom;
  1058.  
  1059.         while ((cp = index(cp, 'r')) != NULL)
  1060.         {
  1061. #ifdef DEBUG
  1062.             if (Debug)
  1063.                 printf("cp='%s'\n", cp);
  1064. #endif
  1065.             if (sscanf(cp, "remote from %s", sys) == 1)
  1066.             {    (void) strcat(from, sys);
  1067.                 (void) strcat(from, "!");
  1068.                 if (firstline)
  1069.                     (void) strcpy(sysname, sys);
  1070.                 break;
  1071.             }
  1072.             cp++;
  1073.         }
  1074. #ifdef DEBUG
  1075.         if (Debug)
  1076.             printf("ufrom='%s', sys='%s', from now '%s'\n", uf, sys, from);
  1077. #endif
  1078.         firstline = 0;
  1079.     }
  1080.     (void) strcat(from, conv_at(uf));
  1081.  
  1082.     (void) sprintf(cmd, "%s -em -f%s", MAILER, from);
  1083.     if (*sysname != '\0')
  1084.     {    (void) strcat(cmd, " -oMs");
  1085.         (void) strcat(cmd, sysname);
  1086.     }
  1087.  
  1088.     while (*++argv != NULL)
  1089.     {
  1090.         (void) strcat(cmd, " '");
  1091.         if (**argv == '(')
  1092.             (void) strncat(cmd, *argv + 1, strlen(*argv) - 2);
  1093.         else
  1094.             (void) strcat(cmd, *argv);
  1095.         (void) strcat(cmd, "'");
  1096.     }
  1097. #ifdef DEBUG
  1098.     if (Debug)
  1099.         printf("cmd='%s'\n", cmd);
  1100. #endif
  1101.     out = popen(cmd, "w");
  1102.     fputs(lbuf, out);
  1103.     while (fgets(lbuf, sizeof lbuf, stdin))
  1104.         fputs(lbuf, out);
  1105.     i = pclose(out);
  1106.     if ((i & 0377) != 0)
  1107.     {
  1108.         fprintf(stderr, "pclose: status 0%o\n", i);
  1109.         exit(EX_OSERR);
  1110.     }
  1111.  
  1112.     exit((i >> 8) & 0377);
  1113. }
  1114.  
  1115. /*
  1116. **  CONV_AT  --  converts an address with 'at' symbols in to uucp style
  1117. **
  1118. **    This converts addresses such as a%b%c@d to d!c!b!a style
  1119. **    so that when the path deduced from the "remote from" lines is
  1120. **    prepended, the address might still be valid.
  1121. **    If a domain contains ".uucp" or ".UUCP" this gets stripped.
  1122. **    e.g.  c!user%b.uucp@a.uucp -> a!b!c!user
  1123. **          user%d.dec%c.arpa%b.uucp@a.uucp -> a!b!c.arpa!d.dec!user
  1124. */    
  1125. char    *
  1126. conv_at(addr)
  1127. char    *addr;
  1128. {
  1129.     char    buf[512];
  1130.     char    *bp = buf;
  1131.     char    *p;
  1132.  
  1133. #ifdef DEBUG
  1134.     if (Debug)
  1135.         printf("conv_at(%s) ", addr);
  1136. #endif
  1137.     while ((p = rindex(addr,'@')) != NULL || (p = rindex(addr,'%')) != NULL)
  1138.     {
  1139.         *p++ = '\0';
  1140.         while (*p)
  1141.         {
  1142.             if (strcmp(p, ".uucp") == 0 || strcmp(p, ".UUCP") == 0)
  1143.                 break;
  1144.  
  1145.             *bp++ = *p++;
  1146.         }
  1147.         *bp++ = '!';
  1148.     }
  1149.  
  1150.     strcpy(bp, addr);
  1151. #ifdef DEBUG
  1152.     if (Debug)
  1153.         printf("returns %s\n", buf);
  1154. #endif
  1155.     return(buf);
  1156. }
  1157. SHAR_EOF
  1158. if test 3690 -ne "`wc -c rmail.c`"
  1159. then
  1160. echo shar: error transmitting rmail.c '(should have been 3690 characters)'
  1161. fi
  1162. echo shar: extracting damail.c '(3233 characters)'
  1163. cat << \SHAR_EOF > damail.c
  1164. /*
  1165.  * rscs to sendmail mail interface
  1166.  * invoked by the rscs master control daemon when a file with filetype MAIL
  1167.  * is received over BITNET.
  1168.  *
  1169.  * The syntax is
  1170.  *     damail <mailfile> <fromsys> <fromuser> <tosys> <touser>
  1171.  *
  1172.  * 
  1173.  * Bill Nesheim
  1174.  * Cornell U Dept of Computer Science
  1175.  * August, 1983
  1176.  *
  1177.  * Rewritten by Jim Crammond
  1178.  * Weizmann Institute
  1179.  * Feb 1985
  1180.  */
  1181.  
  1182. #include <stdio.h>
  1183. #include <sys/file.h>
  1184. #include <sys/wait.h>
  1185. #include <sysexits.h>
  1186. #include "../common/rscs.h"
  1187. #include "../common/daemon.h"
  1188.  
  1189. #define MAILLOG "/usr/lib/rscs/maillog"
  1190.  
  1191. main(ac,av)
  1192. int ac;
  1193. char **av;
  1194. {
  1195.     FILE *mail, *outfile, *log;
  1196.     char line[BUFSIZ], From[BUFSIZ], To[BUFSIZ];
  1197.     char sender[20];
  1198.     char *actime, *err;
  1199.     long tm, time();
  1200.     int loc, smpid, ppe[2];
  1201.     union wait status;
  1202.  
  1203.     if(ac < 2) {
  1204.         logerror("DAMAIL: No Mail File??");
  1205.         return(TRUE);
  1206.     }
  1207.  
  1208.     if((log = fopen(MAILLOG, "a")) == (FILE *)NULL) {
  1209.         logerror("Can't open mail log file!");
  1210.         return(FALSE);
  1211.     }
  1212.  
  1213.     if((mail = fopen(av[1],"r")) == (FILE *)NULL) {
  1214.         sprintf(line,"MTU: Can't open %s", av[1]);
  1215.         logerror(line);
  1216.         return(FALSE);
  1217.     }                                   
  1218.  
  1219.     /* apparent source */
  1220.     sprintf(From,"%s@%s.BITNET", av[3], av[2]);
  1221.     /* apparent destination */
  1222.     sprintf(To,"%s@%s.BITNET", av[5], av[4]);
  1223.  
  1224.     /* sender flag to sendmail */
  1225.     convlower(av[2]);
  1226.     sprintf(sender,"-oMs%s.bitnet", av[2]);
  1227.  
  1228.     /* try to find real destination and source */
  1229.     while (fgets(line, BUFSIZ, mail) !=  NULL) 
  1230.     {    
  1231.         if (strncmp(line, "From:", 3) == 0) {
  1232.             register char *p, *e;
  1233.             char *index();
  1234.             char *addr;
  1235.  
  1236.             p = line + 5;
  1237.  
  1238.             while (*p == ' ')
  1239.                 p++;
  1240.  
  1241.             addr = p;
  1242.  
  1243.             if ( (p=index(addr, '<')) && (e=index(p, '>')) )
  1244.             {    /*
  1245.                  *  address of the form:  comment <address>
  1246.                  */
  1247.                 addr = ++p;
  1248.                 *e = '\0';
  1249.             }
  1250.             else if ( (e=index(addr, '(')) )
  1251.             {    /*
  1252.                  *  address of the form:  address (comment) 
  1253.                  */
  1254.                 while (*--e == ' ')
  1255.                     ;
  1256.                 *++e = '\0';
  1257.             }
  1258.             else if ( (e=index(addr, '\n')) )
  1259.                 *++e = '\0';
  1260.  
  1261.             strcpy(From, addr);
  1262.             break;
  1263.         }
  1264.     }
  1265.  
  1266.     rewind(mail);
  1267.     tm = time(0L); 
  1268.     actime = (char *)ctime(&tm);
  1269.     actime[19] = '\000';
  1270.  
  1271.     /* open pipe to sendmail */
  1272.     pipe(ppe);
  1273.     if((smpid=vfork()) == 0) {
  1274.         close(0);
  1275.         dup(ppe[0], 0);
  1276.         execl("/usr/lib/sendmail", "sendmail",
  1277.                 sender, "-odi", "-oem", "-f", From, To, 0);
  1278.  
  1279.         logerror("MTU: exec failed");
  1280.         perror("reason");
  1281.         _exit(1);
  1282.     }
  1283.  
  1284.     if((outfile = fdopen(ppe[1], "w")) == (FILE *)NULL) {
  1285.         logerror("MTU: pipe fdopen failure!");
  1286.         return(FALSE);
  1287.     }
  1288.  
  1289.     loc = 1;
  1290.  
  1291.     while (fgets(line, BUFSIZ, mail) !=  NULL) {
  1292.         if (loc == 1) {
  1293.             loc++;
  1294.             if(strncmp(line, ":READ", 5) == 0)
  1295.                 continue;
  1296.         }
  1297.  
  1298.         fputs(line, outfile);
  1299.     }
  1300.  
  1301.     fclose(outfile);
  1302.     fclose(mail);
  1303.     wait(&status);
  1304.     switch(status.w_retcode) {
  1305.     case EX_OK:
  1306.         err="sent";
  1307.         break;
  1308.     case EX_NOUSER:
  1309.         err="no such user";
  1310.         break;
  1311.     case EX_NOHOST:
  1312.         err="host unknown";
  1313.         break;
  1314.     case EX_UNAVAILABLE:
  1315.         err="service unavailable";
  1316.         break;
  1317.     default:
  1318.         err="other";
  1319.     }
  1320.  
  1321.     fprintf(log,"%s Received mail from %s %s (tag %s %s) \n",
  1322.         actime, av[2], av[3], av[4], av[5]);
  1323.     fprintf(log,"\t%s (%d) %s (%d) from %s to %s\n",
  1324.         status.w_retcode ? "NOT SENT" : "Sent" , smpid, err, status.w_retcode, From, To);
  1325.     fclose(log);
  1326.  
  1327.     unlink(av[1]);
  1328.     return(status.w_retcode);
  1329. }
  1330. SHAR_EOF
  1331. if test 3233 -ne "`wc -c damail.c`"
  1332. then
  1333. echo shar: error transmitting damail.c '(should have been 3233 characters)'
  1334. fi
  1335. echo shar: extracting Makefile '(673 characters)'
  1336. cat << \SHAR_EOF > Makefile
  1337. #
  1338. #  Makefile for assorted programs related to Sendmail.
  1339. #
  1340. #    @(#)Makefile    UK-1.1 sendmail configuartion        22/4/85
  1341. #
  1342. CFLAGS=-O
  1343. #CFLAGS=-O -Dvoid=int   # some pdp11's need this
  1344. X25FLAGS=-I/usr/src/local/x25/usr/src/
  1345.  
  1346. uucp:    rmail
  1347.     cp rmail /bin/rmail
  1348.  
  1349. bitnet:    damail
  1350.     cp rmail /usr/lib/rscs/damail
  1351.  
  1352. rmail:    rmail.c
  1353.     cc $(CFLAGS) -o rmail
  1354.  
  1355. damail: damail.c
  1356.     cc $(CFLAGS) -o damail
  1357.  
  1358.  
  1359. janet:    mailer hhsend
  1360.     cp mailer /usr/lib/x25
  1361.     chown root /usr/lib/x25/mailer
  1362.     chmod 755 /usr/lib/x25/mailer
  1363.     cp hhsend /usr/lib/x25
  1364.     chown root /usr/lib/x25/hhsend
  1365.     chmod 4755 /usr/lib/x25/hhsend
  1366.  
  1367. mailer: mailer.c
  1368.     cc $(CFLAGS) mailer.c -lx25
  1369.  
  1370. hhsend: hhsend.c
  1371.     cc $(CFLAGS) $(X25FLAGS) hhsend.c
  1372. SHAR_EOF
  1373. if test 673 -ne "`wc -c Makefile`"
  1374. then
  1375. echo shar: error transmitting Makefile '(should have been 673 characters)'
  1376. fi
  1377. echo shar: extracting README '(1249 characters)'
  1378. cat << \SHAR_EOF > README
  1379. This directory contains some sendmail interface programs.
  1380.  
  1381. Interfaces
  1382. ----------
  1383. rmail.c:
  1384.     This is a rewrite of the standard uucp -> sendmail interface program
  1385.     which just a better job of deducing the From path from the
  1386.     uucp from line(s), and also sets sendmail's $s macro.
  1387.  
  1388.     This replaces /bin/rmail supplied with BSD4.2.
  1389.  
  1390. damail.c:
  1391.     This is a rewrite of the bitnet -> sendmail interface program
  1392.     supplied with the Cornell version of the RSCS emulation package.
  1393.     This reads the from person from the From: line and sets
  1394.     sendmail's $s macro.
  1395.  
  1396.     This replaces /usr/lib/rscs/damail supplied with the RSCS software.
  1397.  
  1398. mailer.c:
  1399.     This is a janet -> sendmail interface program. This reads a
  1400.     message in JNT mail format and converts it into a form suitable
  1401.     for calling sendmail. This also sets sendmail's $s macro.
  1402.  
  1403.     This replaces /usr/lib/x25/mailer supplied with the York X25 software.
  1404.  
  1405. hhsend.c:
  1406.     This is a sendmail -> janet interface program. This reads a
  1407.     message processed by sendmail and converts it into JNT mail format,
  1408.     then calls mhhcp to send it.
  1409.  
  1410.     This effectively replaces the /usr/lib/x25/hhmail supplied with the
  1411.     York X25 software; the standard mail user interfaces together with
  1412.     sendmail perform the other functions provided by hhmail.
  1413. SHAR_EOF
  1414. if test 1249 -ne "`wc -c README`"
  1415. then
  1416. echo shar: error transmitting README '(should have been 1249 characters)'
  1417. fi
  1418. echo shar: extracting hhsend.c '(2613 characters)'
  1419. cat << \SHAR_EOF > hhsend.c
  1420. /*
  1421.  *  hhsend  -  Sendmail -> JNT mailer interface.
  1422.  *
  1423.  *    This program takes a hostname and a list of users to send to as
  1424.  *    arguments and a mail message as standard input and creates a file
  1425.  *    containing a Janet header followed by the mail message, then
  1426.  *    calls mhhcp to send it over the network.
  1427.  *
  1428.  *    Written by Jim Crammond.    jim@hwcs    4/85
  1429.  */    
  1430. #include <stdio.h>
  1431. #include <signal.h>
  1432. #include <sysexits.h>
  1433. #include <sys/wait.h>
  1434. #include "local.h"
  1435.  
  1436. #define    MAILMODE    (0660)        /* mode of created spool file */
  1437.  
  1438. #ifdef DEBUG
  1439. #undef  SPOOLD
  1440. #define SPOOLD "."
  1441. #endif DEBUG
  1442.  
  1443. FILE    *mailf = NULL;
  1444. char    sfile[ sizeof(SPOOLD) + 14 ];
  1445. int    delete();
  1446. char    *index();
  1447.  
  1448. main(argc, argv)
  1449. int    argc;
  1450. char    *argv[];
  1451. {
  1452.     char    *myname;
  1453.     char    *host;
  1454.     char    **users;
  1455.     int    nusers;
  1456.  
  1457.     myname = argv[0];
  1458.  
  1459.     if (argc < 3)
  1460.     {    fprintf("usage: %s host users...\n", myname);
  1461.         exit(EX_USAGE);
  1462.     }
  1463.  
  1464.     host = argv[1];
  1465.     users = &argv[2];
  1466.     nusers = argc - 2;
  1467.  
  1468.     /*  catch signals  */
  1469.     signal(SIGHUP, delete);
  1470.     signal(SIGINT, delete);
  1471.     signal(SIGQUIT, delete);
  1472.     signal(SIGTERM, delete);
  1473.  
  1474.     /*  send the mail  */
  1475.     sendmail(host, users, nusers);
  1476.  
  1477.     /*  NOTREACHED  */
  1478. }
  1479.  
  1480. /*
  1481.  *  sendmail  -  creates a mail file for mhhcp and exec mhhcp.
  1482.  */
  1483. sendmail(host, users, nusers)
  1484. char    *host;
  1485. char    *users[];
  1486. int    nusers;
  1487. {
  1488.     register char    *auser, *p;
  1489.     char    line[BUFSIZ];
  1490.     union    wait status;
  1491.  
  1492.     /*  create spool file  */
  1493.     sprintf(sfile, "%s/M%06d", SPOOLD, getpid() );
  1494.  
  1495.     mailf = fopen(sfile, "w");
  1496.     if (mailf == NULL)
  1497.     {    fprintf(stderr, "cannot create mail spool file %s\n", sfile);
  1498.         exit(EX_CANTCREAT);
  1499.     }
  1500.     chmod(sfile, MAILMODE);
  1501.  
  1502.  
  1503.     /*  write out JNT-header  */
  1504.     while (nusers > 1)
  1505.     {    auser = users[ --nusers ];
  1506.         /* convert any '@'s in user part to '%'s */
  1507.         while ((p = index(auser, '@')) != NULL)
  1508.             *p = '%';
  1509.  
  1510.         fprintf(mailf, "%s@%s,\n", auser, host);
  1511.     }
  1512.     auser = users[0];
  1513.     /* convert any '@'s in user part to '%'s */
  1514.     while ((p = index(auser, '@')) != NULL)
  1515.         *p = '%';
  1516.  
  1517.     fprintf(mailf, "%s@%s\n\n", auser, host);
  1518.  
  1519.  
  1520.     /*  write out header + message from stdin (supplied by sendmail)  */
  1521.     while (fgets(line, sizeof(line), stdin) != NULL)
  1522.         fputs(line, mailf);
  1523.     
  1524.     fclose(mailf);
  1525.  
  1526. #ifdef DEBUG
  1527.     fprintf(stderr,"spool file is %s\n", sfile);
  1528.     exit(0);
  1529. #endif
  1530.  
  1531.     switch (fork())
  1532.     {    case -1:
  1533.             exit(EX_TEMPFAIL);
  1534.         case 0:
  1535.             execl(MHHCPPATH, MHHCP, sfile, host, 0);
  1536.             exit(EX_UNAVAILABLE);
  1537.         default:
  1538.             wait(&status);
  1539.             if (status.w_retcode == 1)
  1540.                 exit(EX_OK);
  1541.             else
  1542.                 exit(EX_NOHOST);
  1543.     }
  1544. }
  1545.  
  1546.  
  1547. /*
  1548.  *  delete  -  delete mail file and exit.  Called on any interrupt.
  1549.  */
  1550. delete()
  1551. {    
  1552.     if (mailf != NULL)
  1553.     {    fclose(mailf);
  1554.         unlink(sfile);
  1555.     }
  1556.     exit(EX_TEMPFAIL);
  1557. }
  1558. SHAR_EOF
  1559. if test 2613 -ne "`wc -c hhsend.c`"
  1560. then
  1561. echo shar: error transmitting hhsend.c '(should have been 2613 characters)'
  1562. fi
  1563. echo shar: extracting mailer.c '(2736 characters)'
  1564. cat << \SHAR_EOF > mailer.c
  1565. /*
  1566.  *  mailer  -  JNT -> Sendmail interface.
  1567.  *
  1568.  *    This program takes a mail file in JNT format and converts the
  1569.  *    Janet header into an argument and then calls sendmail giving the
  1570.  *    message part of the mail file as standard input.
  1571.  *
  1572.  *    Written by Jim Crammond.    jim@hwcs    4/85
  1573.  */    
  1574. #include <stdio.h>
  1575. #include <time.h>
  1576. #include <pwd.h>
  1577. #include <tdir.h>
  1578. #include <sysexits.h>
  1579. #include "local.h"
  1580.  
  1581. struct    tdirent    *gettdnam(), *td;
  1582.  
  1583. #define    CMDSIZ        5000            /*  command line size  */
  1584. #define SENDMAIL    "/usr/lib/sendmail"    /*  sendmail rah rah  */
  1585. #define DEADLETTER    "/tmp/dead.letter"    /* somewhere for trashed mail */
  1586.  
  1587. char    cmd[CMDSIZ];
  1588. char    line[BUFSIZ];
  1589. char    *file, *via;
  1590. FILE    *fopen(), *popen();
  1591. FILE    *fp, *outp, *logfd, *dlp;
  1592. long    iop, time();
  1593. char    *ctime();
  1594. char    *rindex();
  1595. int    LOGGING;
  1596.  
  1597. main(argc, argv)
  1598. int    argc;
  1599. char    *argv[];
  1600. {
  1601.     register char    *usersp, *c, *n;
  1602.     char    *f;
  1603.     int    ret;
  1604.  
  1605. #ifndef DEBUG
  1606.     chdir(SPOOLD);        /* somewhere to dump core */
  1607. #endif
  1608.     if ((logfd = fopen(MAIL_LOG, "a")) == NULL)
  1609.         LOGGING = 0;
  1610.     else
  1611.         LOGGING = 1;
  1612.     chmod(MAIL_LOG, 0666);
  1613.     time(&iop);
  1614.     LOG("\n\nMail server started %s", ctime(&iop));
  1615.  
  1616.     file = argv[1];
  1617.     via = argv[2];
  1618.  
  1619.     if ((fp = fopen(file, "r")) == NULL)
  1620.     {    LOG("could not open file\n");
  1621.         done();
  1622.     }
  1623.  
  1624.     /*
  1625.      *  find out where this came from
  1626.      */
  1627.     for (f = via; *f; f++)
  1628.         if (*f == '/')
  1629.         {    *f = '\0';
  1630.             break;
  1631.         }
  1632.     if ((td = gettdnam(via, 0)) != 0)
  1633.         via = td->td_name;
  1634.  
  1635.     /*
  1636.      *  initialise command sendmail command line
  1637.      */
  1638.     sprintf(cmd, "%s -oMs%s", SENDMAIL, via);
  1639.     usersp = cmd;
  1640.     while (*usersp != '\0')
  1641.         usersp++;
  1642.  
  1643.     /*
  1644.      *  get list of addresses to send to in JNT-header form and
  1645.      *  convert to a list of command line arguments.
  1646.      */
  1647.     while (fgets(line, BUFSIZ, fp) != NULL)
  1648.     {    c = line;
  1649.         while (*c == ' ' || *c == '\t')
  1650.             c++;
  1651.  
  1652.         if (*c == '\n')
  1653.             break;
  1654.  
  1655.         *usersp++ = ' ';
  1656.  
  1657.         while (*c != '\0' && *c != '\n')
  1658.         {    if (*c == ',')
  1659.             {    *usersp++ = ' ';
  1660.                 c++;
  1661.             }
  1662.             else
  1663.                 *usersp++ = *c++;
  1664.         }
  1665.     }
  1666.     *usersp = '\0';
  1667.  
  1668.     /* call sendmail */
  1669. #ifdef DEBUG
  1670.     fprintf(stderr, "call: %s\n", cmd);
  1671.     done();
  1672. #endif DEBUG
  1673.     LOG("%s\n", cmd);
  1674.     outp = popen(cmd, "w");
  1675.     while (fgets(line, sizeof(line), fp) != NULL)
  1676.         fputs(line, outp);
  1677.     ret = pclose(outp);
  1678.  
  1679.     if (ret & 0377)
  1680.     {    /* sendmail failed - drop letter into "dead.letter" */
  1681.         LOG("%s failed, returning status %d\n", cmd, ret);
  1682.         if ((dlp = fopen(DEADLETTER, "a")) != NULL)
  1683.         {    fprintf(dlp, "%s failed, message body follows:\n", cmd);
  1684.             while (fgets(line, sizeof(line), fp) != NULL)
  1685.                 fputs(line, dlp);
  1686.         }
  1687.         exit(EX_OSERR);
  1688.     }
  1689.     LOG("exit status %d\n", ret >> 8);
  1690.     done();
  1691. }
  1692.  
  1693. /* VARARGS1 */
  1694. LOG(fmt, args)
  1695. char    *fmt;
  1696. {
  1697.     if (LOGGING)
  1698.     {    fprintf(logfd, fmt, args);
  1699.         fflush(logfd);
  1700.     }
  1701.     return;
  1702. }
  1703.  
  1704. done()
  1705. {
  1706.     unlink(file);
  1707.     exit(EX_OK);
  1708. }
  1709. SHAR_EOF
  1710. if test 2736 -ne "`wc -c mailer.c`"
  1711. then
  1712. echo shar: error transmitting mailer.c '(should have been 2736 characters)'
  1713. fi
  1714. echo shar: done with directory Support
  1715. chdir ..
  1716. #    End of shell archive
  1717. exit 0
  1718.  
  1719.