		MTA tips

------------------------------------------------------------
I	Sendmail

1	sendmail ͭΤϤʤ
1.1	owner-ml: xxx@yyy.co.jp ϾäƤǤ?

II	Postfix

2	Postfix
2.1	postfix ΰ

3	POP before SMTP with Postfix
3.1	install postfix
3.2	install DRAC (Dynamic Relay Authorization Control)
3.3	qpopperβ¤

Appendix A	C Wrapper
Appendix A.1	C wrapper (:include: Ȥʤ)
Appendix A.2	C wrapper program fml on 4.3BSD

Appendix B	:include: ե (fml.plθƤϤ)
Appendix B.1	:include: ե (fml.plθƤϤ)
------------------------------------------------------------


I	Sendmail
1	sendmail ͭΤϤʤ

1.1	owner-ml: xxx@yyy.co.jp ϾäƤǤ?

äʤǤsendmail ξˡ٥פԾν
"owner-"ꤷȤǵޤ

II	Postfix
2	Postfix

	http://www.postfix.org/

2.1	postfix ΰ

To suspend smtp delivery:

    postconf -e defer_transports=smtp; postfix reload

To enable smtp delivery:

    postconf -e defer_transports=; postfix reload; postfix flush

ǡŪߤ뤳ȤǤޤ
Τˤ SMTP Ȥӥ defer ⡼ɤѹ
Ȥ̣Ǥ
ϥ륢å³ʤɤ queue  flush ޤǤ
塼ɤꤷǽǤ 

3	POP before SMTP with Postfix

postfix Ǥ pop before smtp ˤĤ

3.1	install postfix

3.2	install DRAC (Dynamic Relay Authorization Control)

	http://mail.cc.umanitoba.ca/drac/index.html

[drac ΤĤ꤫]
INSTALLɤǡOSˤ碌Makefileľ
  : -DREQ_HASH ˺줺

   INSTALL = install
   EBIN = /usr/local/sbin
   MAN = /usr/local/man/man
   DEFS = -DSOCK_RPC -DFCNTL_LOCK -DGETHOST -DDASH_C -DREQ_HASH
   CC = cc
   RANLIB = ranlib
   CFLAGS = $(DEFS) -g -I/usr/include
   LDLIBS = 
   TSTLIBS = -L. -ldrac
   RPCGENFLAGS = -C
   MANLIB = 3
   MANADM = 8

3.3	qpopperβ¤

INSTALLˤ pop_pass.c ؤΥѥå򤢤Ƥ롣
  ɬפʤǤƤ

qpopper compileȤ libdrac.a ɬפʤΤŬʾˤ
  Makefile򤽤ˤ碌ƽ

    *** pop_pass.c-nodrac	Sat Jun 27 10:56:00 1998
    --- pop_pass.c	Wed Jul 22 22:54:04 1998
    ***************
    *** 19,24 ****
    --- 19,28 ----
    
      #include <pwd.h>
      #include "popper.h"
    + #ifdef DRAC_AUTH
    + #include <netinet/in.h>
    + #include <arpa/inet.h>
    + #endif /* DRAC_AUTH */
    
      /* This error message is vague on purpose to help reduce help improve
    ***************
    *** 502,507 ****
    --- 506,519 ----
    
          /*  Initialize the last-message-accessed number */
          p->last_msg = 0;
    + 
    + #ifdef DRAC_AUTH
    +     {
    + 	char *err;
    + 	if (dracauth("localhost", inet_addr(p->ipaddr), &err) != 0)
    + 	  pop_log(p,POP_PRIORITY,err);
    +     }
    + #endif /* DRAC_AUTH */
    
          /*  Authorization completed successfully */
          return (pop_msg (p,POP_SUCCESS,
    
3. modify postfix /etc/postfix/main.cf.

        smtpd_recipient_restrictions =
            permit_mynetworks
            check_client_access hash:/etc/mail/dracd
            check_relay_domains
            reject

4. mkdir /etc/mail. 

dracd users the directory "/etc/mail".

5. run "rpc.dracd" as a daemon.

[]

¤η popper POPǧڤľ dracd RPC(Remote
Procedure Call)ǤΥǡϤ褦ˤʤ롣dracdϤ򤦤 
/etc/mail/dracd.db Ȥե

   IPɥ쥹   ޤǤΥɥ쥹SMTPͭ(unix time)

Υϥåơ֥롣ǥեȤǤ30ʬͭ

RPCȤdracdƱۥȾưƤʤƤ⹽ʤĤޤ pop 
Ф MTAƱۥȤǤɬפʤΤʤ櫓ɡդ
RPCطְ㤨RPCޤ꤬ˢȤФ夬
Ȥ⤤ƵĤʤȤʤ

postfix check_client_access maptype:mapname 

   Search the named access database for the client hostname, parent
   domains, client IP address, or networks obtained by stripping least
   significant octets. Reject the request if the result is REJECT or
   "[45]XX text".  Permit the request if the result is OK or RELAY or
   all-numerical. Otherwise, treat the result as another list of UCE
   restrictions. The access_map_reject_code parameter specifies the
   response code for REJECT results (default: 554).

Τ褦ˤʤäƤ뤿ᡢϥåơ֥ͤʤOKȤʤ롣

Appendix A	C Wrapper

Appendix A.1	C wrapper (:include: Ȥʤ)

:include: ʸȤʤ OS ⤷ϸŤ sendmail ξ C wrapper 
Ȥɬפޤ
C wrapper  setuid ƻȤޤsetuid 줿 program ΰfml.pl 
ϤȤȤϤƤϤޤ
Ȥ򤹤볰ΥեȤ褦ǤĲͤƤ

makefml newml ȸܤ fmlwrapper.c äƤƤΤǤ 
compile ơfml-wrapper ޤ($DIRmake) fml-ctl-wrapper  
listname-ctl ѤǤ
fmlwrapper.c ϴĶʻѹƤޤǧϤƤߤƤ
fmlwrapper.c ˤϼ¹ԤƤ hard coding ƤΤɬפʤľ edit 
Ʋ

Example:

	% cd /var/spool/ml/elena
	% make fml
	cc  -o fml fmlwrapper.c
	chmod 4755 fml
	cc  -DCTLADDR -o fml-ctl fmlwrapper.c
	chmod 4755 fml-ctl

(It is preferable to do "chmod 4555")

 fml, fml-ctl root 񤱤ʤإ󥹥ȡ롣

[]

fmlwrapper.c Ƥ

	fml.plξ   config.phΤ   饤֥ξ

 exec  C  program ȤΤΤǤ褦 include ե
Ǥ뤳ȤƱȤ񤭤ޤΤ setuid() 򤹤Τ 
sendmail ǤϤʤ fmlwrapper.c Ǥ뤳ȤǤ

㡧 fmlwrapper.c

execl("/usr/local/fml/fml.pl", /*  fml.pl Ϥɤ */
      "(fml)", 
      "/var/spool/ml/Elena",   /* config.ph  ɤ */
      "/usr/local/fml",        /* fml package  library Ϥɤ */
      NULL);

fml-ctl-wrapper Ǥ
execl("/usr/local/fml/fml.pl", /*  fml.pl Ϥɤ */
      "(fml)", 
      "/var/spool/ml/Elena",   /* config.ph  ɤ */
      "/usr/local/fml",        /* fml package  library Ϥɤ */
      "--ctladdr",             /* --ctladdr == ޥɥ⡼ */
      NULL);

ˤʤޤlistname-ctl ˤ fml-ctl ꤷޤ

Appendix A.2	C wrapper program fml on 4.3BSD

:include: ʸȤʤϡsetuid 줿 fml Ȥ C  wrapper
program ͳ

	/usr/local/fml/fml.pl $DIR $LIBDIR

¹ԤȤ򤷤ޤmakefml Ȥгƥ᡼󥰥ꥹȤȤ
Ѥ fmlwrapper.c Ƥޤ directory 

	% make fml 

ȤȺޤfmlwrapper.c  fml.pl directory ... ȤǸƤ
褦ˤʤäƤޤ

Appendix B	:include: ե (fml.plθƤϤ)

Appendix B.1	:include: ե (fml.plθƤϤ)
See also: fml-uid 

fml εưλ

	fml.pl $DIR $LIBDIR

	$DIR	config.ph Τ directory MLHOME
	$LIBDIR	library  path (ɬפʤ)

ηǤΥޥɤư STDIN ᡼ͤùǲ
Ĥޤ(PIPE)

	| fml.pl $DIR $LIBDIR

ȤȤǤ sendmail ˤ餻뤿ˤ /etc/aliases ˼
Τ褦˽񤭤ޤʽޤ줬ư
 sendmail  version ˰¸Ǥ
: Elena ᡼󥰥ꥹȤξ

   [/etc/aliases]

	Elena: :include:/var/spool/ml/Elena/include
	owner-Elena: fukachan
	Elena-request: fukachan
	Elena-admin: fukachan

   [/var/spool/ml/Elena/include]

	"|/usr/local/fml/fml.pl /var/spool/ml/elena "

$DIR  "/var/spool/ml/elena"  $LIBDIR ä˻ꤷʤǤ
ξ include ե νͭԤID fml.pl ư졢sendmail 
 Υץ(fml.pl)(STDIN)MLΥ᡼Ϥޤ/etc/aliases 
ɤ /var/spool/ml/Elena/include ɤ߹ΤꡢΥե
Ȥ "|/usr/local/fml/fml.pl /var/spool/ml/elena " ư줳
ΥץSTDIN˥᡼Ϥޤ

ʤñˤǤϤǤޤʤɬפOS⤤ޤ
OS ˤfml.plθƤΰ㤤ϼξϤ򸫤Ʋ
See also: troubleshoot 10 


		INDEX

:include: ե                         ...   Appendix B.1 
fml                                        ...   Appendix A.1 Appendix A.2 
fmlwrapper.c                               ...   Appendix A.1 Appendix A.2 
