安全で高速なメールサーバーqmail

以下のテキストは、執筆時当時の情報を元に書いたものであり、 現在の情勢にそぐわないことを含む場合があるので注意されたい。 また、テキストは最終提出原稿で校正を経る前のものなので、実際にUNIXUSER 本誌に記載されたものとは異なる。誤字脱字等そのままである。

致命的な誤り以外は加筆修正等は行なわないので情報の鮮度に気をつけつつ 利用して欲しい。

目次


Part 4 qmail


qmail



DJBqmail


qmail


qmail

	* 
	* CFsendmail
	* CFcf
	* 
	* ML

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

qmail

qmail
DNSBINDDJB
djbdns

qmail

	1. DNS
	2. qmail
	3. 

Part2Part3tcpserverdjbdns





  qmail
  

			foo.ymzk.org
			foo.ymzk.org (DNS)
			venus.foo.ymzk.org (10.0.0.25)
		saturn.foo.ymzk.org (10.0.0.26)
			ns.foo.ymzk.org (10.0.0.53)

DNS

  MTADNSMX
  djbdnsMX
   foo.ymzk.org 
  
  

	@foo.ymzk.org:10.0.0.25:venus.foo.ymzk.org:0:86400
	@foo.ymzk.org:10.0.0.26:saturn.foo.ymzk.org:10:86400

  1@foo.ymzk.org preference()=0
   venus.foo.ymzk.org(10.0.0.25) 2preference=10
  saturn.foo.ymzk.org(10.0.0.26) 
  make
  

	# make

  tinydns-data 
   host tinydns
  env/IP  ns.foo.ymzk.org IP
   10.0.0.53 

	# host -t mx foo.ymzk.org 10.0.0.53
	  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	foo.ymzk.org mail is handled (pri=0) by venus.foo.ymzk.org
	foo.ymzk.org mail is handled (pri=10) by saturun.foo.ymzk.org

  


qmail

  qmail1997
  qmail-1.03
  4
  
  

  qmail-1.03 http://cr.yp.to/qmail.html 
  CD-ROMqmail-1.03
   "INSTALL" 
  

	# gzip -dc qmail-1.03.tar.gz | tar xvpf -
	# cd qmail-1.03
	# less INSTALL*

  INSTALL

	1. qmailUID/GID
	2. qmail
	3. sendmail
	4. qmail

  INSTALL
  qmail-sendSMTP
  qmail-smtpdinetd
  daemontools

  1. qmailUID/GID
  ==================================

   INSTALL.ids UID/GID

  ---[Solaris, NetBSD, OpenBSD, Linux]------------------
   # groupadd nofiles
   # useradd -g nofiles -d /var/qmail/alias alias
   # useradd -g nofiles -d /var/qmail qmaild
   # useradd -g nofiles -d /var/qmail qmaill
   # useradd -g nofiles -d /var/qmail qmailp
   # groupadd qmail
   # useradd -g qmail -d /var/qmail qmailq
   # useradd -g qmail -d /var/qmail qmailr
   # useradd -g qmail -d /var/qmail qmails
  ---[FreeBSD]------------------
   # pw groupadd nofiles
   # pw useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent
   # pw useradd qmaild -g nofiles -d /var/qmail -s /nonexistent
   # pw useradd qmaill -g nofiles -d /var/qmail -s /nonexistent
   # pw useradd qmailp -g nofiles -d /var/qmail -s /nonexistent
   # pw groupadd qmail
   # pw useradd qmailq -g qmail -d /var/qmail -s /nonexistent
   # pw useradd qmailr -g qmail -d /var/qmail -s /nonexistent
   # pw useradd qmails -g qmail -d /var/qmail -s /nonexistent

   useradd  pw 
  /etc/group 

	qmail:*:2107:
	nofiles:*:2108:

  vipw passwd 

	alias:*:7790:2108::/var/qmail/alias:/bin/true
	qmaild:*:7791:2108::/var/qmail:/bin/true
	qmaill:*:7792:2108::/var/qmail:/bin/true
	qmailp:*:7793:2108::/var/qmail:/bin/true
	qmailq:*:7794:2107::/var/qmail:/bin/true
	qmailr:*:7795:2107::/var/qmail:/bin/true
	qmails:*:7796:2107::/var/qmail:/bin/true

  GID 2107, 2108 group
  passwdGID
  

  2. qmail
  ==================================
  UID/GIDqmail
  qmail

	# mkdir /var/qmail

  

	# make setup check

  

	# ./config

  DNSconfig
  config-fast 
  
  

  

	# (cd ~alias ; \
	>  touch .qmail-postmaster .qmail-mailer-daemon .qmail-root ; \
	>  chmod 644 ~alias/.qmail* \
	>  )

   postmaster, MAILER-DAEMON, root 
  RFC2142
   .qmail-hostmaster, .qmail-abuse 
  


  3. sendmail
  =====================
   sendmail qmail
  /var/qmail/bin/sendmail /var/qmail/bin/datemail 
  (JST)
  sendmailOSPC-UNIX
   /usr/sbin, Unix /usr/lib 

       (: /usr/sbin/sendmail )
	# cd /usr/sbin
	# mv sendmail sendmail.orig
	# chmod 000 sendmail.orig
	# ln -s /var/qmail/bin/datemail sendmail

  mailer.conf(5) mailer.conf 
  

   sendmail 
  sendmail

	# kill sendmailPID

  sendmail
  

  4. qmail
  ==============

  daemontoolsqmail 
  
  

	# mkdir -p /var/qmail/svc/qmail-send/log

   run 

	# cd /var/qmail/svc/qmail-send
	# touch run
	# chmod +x run
	# vi run
	()
---[ /var/qmail/svc/qmail-send/run ]---------------------------------
#!/bin/sh
echo 'Starting qmail...'
exec env - PATH="/var/qmail/bin:$PATH" qmail-start ./Mailbox
---------------------------------------------------------------------

   qmail 

	# ./run
	status: local 0/10 remote 0/20

  status: 
  C-c log/run 
   /var/log/qmail-send/ 
  

	# touch log/run
	# chmod +x log/run
	# vi log/run
	()
---[ /var/qmail/svc/qmail-send/log/run ]-----------------------------
#!/bin/sh
exec env - \
PATH=/usr/local/daemontools/bin:/usr/local/bin:/bin:/sbin \
setuidgid qmaill multilog t s1000000 /var/log/qmail-send
---------------------------------------------------------------------

  log/run  s1000000 
  
   /var/log/qmail-send 
  
  

	# mkdir /var/log/qmail-send
	# chown qmaill /var/log/qmail-send

  qmail /service 
  qmail

	# ln -s /var/qmail/svc/qmail-send /service

  supervise5svstat

	# svstat /service/qmail-send /service/qmail-send/log
	  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	/service/qmail-send: up (pid 16877) 17 seconds
	/service/qmail-send/log: up (pid 16878) 17 seconds

  qmail(qmail-send)qmail-send
   svc 

  SMTPSMTPqmail
   qmail-smtpd daemontools
  

	# mkdir -p /var/qmail/svc/qmail-smtpd/log

   qmail-smtpd  run 

	# cd /var/qmail/svc/qmail-smtpd
	# touch run
	# chmod +x run
	# vi run
	()
---[ /var/qmail/svc/qmail-smtpd/run ]--------------------------------
#!/bin/sh
echo 'Starting qmail-smtpd...'
exec env - PATH="/var/qmail/bin:$PATH" \
envuidgid qmaild softlimit -d250000 \
tcpserver -vR -c40 -U 0 smtp qmail-smtpd 2>&1
---------------------------------------------------------------------

  SMTPlog/run 

	# touch log/run
	# chmod +x log/run
	# vi log/run
	()
---[ /var/qmail/svc/qmail-smtpd/log/run ]----------------------------
#!/bin/sh
exec env - PATH="$PATH" \
setuidgid qmaill multilog t ./main
---------------------------------------------------------------------

  run /service 
  

	# ln -s /var/qmail/svc/qmail-smtpd /service

  5svstat

	# svstat /service/qmail-smtpd /service/qmail-smtpd/log
	  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	/service/smtpd: up (pid 17443) 4 seconds
	/service/smtpd/log: up (pid 17444) 4 second

  telnetSMTP
  

	# telnet localhost 25
	  ~~~~~~~~~~~~~~~~~~~
	Trying 127.0.0.1...
	Connected to localhost.
	Escape character is '^]'.
	220 venus.foo.ymzk.org ESMTP

qmail

  qmail
  defaultdomain, locals, me, plusdomain,
  rcpthosts defaulthost  config 
  

  * me

    defaultdomain,
    defaulthost, locals, plusdomain 
    

  * locals  (qmail-send)

    
    (@) 
    locals qmail-local 
    qmail
     qmail-send  HUP daemontools 
    qmailqmail-send
     svc -h /service/qmail-send qmail-send
    HUP

		
  * rcpthosts  (qmail-smtpd)

    
    rcpthosts
    
    qmail-smtpd  RELAYCLIENT 
    rcpthosts
    LANSMTP
    

    (.)
    @foo.ymzk.org  @XXX.foo.ymzk.org
    (XXX) 

	foo.ymzk.org
	.foo.ymzk.org

    
     locals  rcpthosts 
    
    virtualdomain 

  * defaultdomain  (qmail-inject)

    
    (.)
    defaultdomain  foo.ymzk.org  
    foo@venus  foo@venus.foo.ymzk.org 
    

  * defaulthost  (qmail-inject)

    
    
    defaulthost  foo.ymzk.org  foo 
     foo@foo.ymzk.org 
     defaulthost 
    

  * plusdomain  (qmail-inject)

     + 
    plusdomain  ac.jp foo@hoge+  
    foo@hoge.ac.jp 


  6
  

	/--- 6 /var/qmail/control/*  -------------------
	| [me]
	|    venus.foo.ymzk.org
	| [locals]
	|    localhost
	|    localhost.foo.ymzk.org
	|    foo.ymzk.org
	|    .foo.ymzk.org
	| [rcpthosts]
	|    foo.ymzk.org
	|    .foo.ymzk.org
	| [defaulthost]
	|    foo.ymzk.org
	| [defaultdomain]
	|    foo.ymzk.org
	| [plusdomain]
	|    ymzk.org
	\-------------------------------------------------------------------

qmail

  daemontools qmail
  /var/log/qmail-send/current 
  (: tail -f 
  )

	# tail -f /var/log/qmail-send/current | tai64nlocal
  
  qmail
  
  
  	qmail: status: local 0/10 remote 0/20
  
  
  
	# echo to: root@foo.ymzk.org | /var/qmail/bin/qmail-inject

  
  

  starting delivery 1: msg 39334 to local root@foo.ymzk.org

   ~alias (/var/qmail/alias) 
   Mailbox mbox
  




  qmail-smtpdSMTP
  
  SMTP
  qmail-smtpd  tcpserver 
  tcpserverqmail-smtpd
  SMTP
   RELAYCILENT 
  10.0.0.0/24 

	# cd /var/qmail/svc/qmail-smtpd
	# vi smtp
	()
---[ /var/qmail/svc/qmail-smtpd/smtp ]-------------------------------
127.0.0.1:allow,RELAYCLIENT=""
10.0.0.:allow,RELAYCLIENT=""
all:allow
---------------------------------------------------------------------

  cdb Makefile
  

	# vi Makefile
	()
---[ /var/qmail/svc/qmail-smtpd/Makefile ]---------------------------
# Makefile for smtp.cdb
#
TCPRL	= /usr/local/bin/tcprule

all: smtp.cdb

smtp.cdb:       smtp
        cat smtp | ${TCPRL} $@ smtp.tmp
---------------------------------------------------------------------

  smtp

	# make

   smtp.cdb  tcpserver 
  (run)

	# vi run
	()
---[ /var/qmail/svc/qmail-smtpd/run ]--------------------------------
#!/bin/sh
echo 'Starting qmail-smtpd...'
exec env - PATH="/var/qmail/bin:$PATH" \
envuidgid qmaild softlimit -d250000 \
tcpserver -vR -c40 -U -x smtp.cdb 0 smtp qmail-smtpd 2>&1
                      ~~~~~~~~~~~
---------------------------------------------------------------------

   qmail-smtpd  run 
  

	# svc -t /service/qmail-smtpd



qmailqmail
daemontools+tcpserver
qmail
daemontools
OS
qmail



yuuji@gentei.org
Fingerprint16 = FF F9 FF CC E0 FE 5C F7 19 97 28 24 EC 5D 39 BA
HIROSE Yuuji - ASTROLOGY / BIKE / EPO / GUEST BOOK / YaTeX [Tweet]