トップ 新規 編集 差分 一覧 ソース 検索 ヘルプ PDF RSS ログイン

qmail-ipv6

qmail-ipv6

Makefile

# New ports collection makefile for:	qmail-ipv6
# Date created:		2004-02-22
# Whom:			Masafumi Otsune <info@otsune.com>
#
# $FreeBSD$
#

PORTNAME=	qmail
PORTVERSION=	${QMAIL_VERSION}.${IPV6_PATCH_DATE}
CATEGORIES=	mail ipv6
PKGNAMESUFFIX=	-ipv6

PATCH_SITES+=	http://pyon.org/fujiwara/:ipv6 \
#		ftp://ftp.nlc.net.au/pub/unix/mail/qmail/:date822fmt
PATCHFILES+=	qmail-${QMAIL_VERSION}-v6-${IPV6_PATCH_DATE}.diff:ipv6 \
#		qmail-date-localtime.patch:date822fmt
PATCH_DIST_STRIP+=	-p1
EXTRA_PATCHES+=	${QMAIL_PORT_PATCHDIR}/patch-aa \
		${QMAIL_PORT_PATCHDIR}/patch-ab \
		${QMAIL_PORT_PATCHDIR}/patch-ac \
		${QMAIL_PORT_PATCHDIR}/patch-qmail-local.c

MAINTAINER=	info@otsune.com
COMMENT=		A secure, reliable, efficient, simple, and fast MTA with IPv6 support

CONFLICTS=	qmail \
		qmail-ldap \
		qmail-mysql \
		qmail-tls \
		qmail-smtp_auth+tls

USE_PERL5_BUILD=yes
USE_REINPLACE=	yes

# Patches from the main qmail port are not wanted
MAIN_QMAIL_PORT_WITH_OUTGOINGIP_PATCH_BARRIER=	yes
WITH_QMAILQUEUE_PATCH=yes

IPV6_PATCH_DATE=	20021006

# Using default from master port, i.e., /var/qmail
PREFIX?=	${QMAIL_PORT_PREFIX}

.if !defined(PRE_MK_INCLUDED)
.include <bsd.port.pre.mk>
.endif

#CFLAGS+=	-DINET6

QMAIL_PORT=	${PORTSDIR}/mail/qmail
QMAIL_PORT_PREFIX!=	cd ${QMAIL_PORT} && ${MAKE} -V PREFIX
QMAIL_PORT_PATCHDIR!=	cd ${QMAIL_PORT} && ${MAKE} -V PATCHDIR

slaveport-post-patch: qmail-ipv6-post-patch

qmail-ipv6-post-patch:
	${REINPLACE_CMD} -e 's/ip6.int/ip6.arpa/g' ${WRKSRC}/dns.c

# Local overrides
MASTERDIR=	${QMAIL_PORT}
PATCHDIR=	${.CURDIR}/files
PKGDIR_LOCAL=	${.CURDIR}
#DESCR=		${PKGDIR_LOCAL}/pkg-descr
#PKGMESSAGE=	${PKGDIR_LOCAL}/pkg-message
MD5_FILE=	${PKGDIR_LOCAL}/distinfo

.include "${MASTERDIR}/Makefile"

distinfo

MD5 (qmail-1.03.tar.gz) = 622f65f982e380dbe86e6574f3abcb7c
SIZE (qmail-1.03.tar.gz) = 220668
MD5 (qmail-1.03-v6-20021006.diff) = 828cfdbdc8f43dd62f518dbefc5258f3
SIZE (qmail-1.03-v6-20021006.diff) = 36418
MD5 (qmail-date-localtime.patch) = d566e8bd99b33efee0194e855b8d6995
SIZE (qmail-date-localtime.patch) = 2603
MD5 (qmail-103.patch) = 9140ad2b03017145cd7963c84bb24f16
SIZE (qmail-103.patch) = 2104
MD5 (sendmail-flagf.patch) = 4e1f2d8315e7e2a5482798c9d19fac4d
SIZE (sendmail-flagf.patch) = 863
MD5 (qmailqueue-patch) = 5a8d7a5863b0c56236af945dedd45754
SIZE (qmailqueue-patch) = 2510

files/patch-qmail-remote

--- qmail-1.03.orig/qmail-remote.8	Mon Jun 15 04:53:16 1998
+++ qmail-1.03-qmtpc+mxps/qmail-remote.8	Mon Jul  7 12:54:00 2003
@@ -1,6 +1,6 @@
 .TH qmail-remote 8
 .SH NAME
-qmail-remote \- send mail via SMTP
+qmail-remote \- send mail via SMTP or QMTP
 .SH SYNOPSIS
 .B qmail-remote
 .I host
@@ -26,7 +26,11 @@
 or to a mail exchanger for
 .I host
 listed in the Domain Name System,
-via the Simple Mail Transfer Protocol (SMTP).
+via the Simple Mail Transfer Protocol (SMTP)
+or Quick Mail Transfer Protocol (QMTP).
+Choice of protocol in this version is done only using the MXPS
+(Mail Exchanger Protocol Switch) convention; see http://cr.yp.to/im/mxps.html
+for details.
 .I host
 can be either a fully-qualified domain name:

files/patch-qmtpc-ipv6

--- orig/qmail-remote.c	Mon Nov  3 14:02:58 2003
+++ ./qmail-remote.c	Mon Nov  3 14:11:32 2003
@@@@ -1,4 +1,5 @@@@
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@@@ -14,6 +15,7 @@@@
 #include "dns.h"
 #include "alloc.h"
 #include "quote.h"
+#include "fmt.h"
 #include "ip.h"
 #include "ipalloc.h"
 #include "ipme.h"
@@@@ -31,8 +33,8 @@@@
 
 #define HUGESMTPTEXT 5000
 
-#define PORT_SMTP 25 /* silly rabbit, /etc/services is for users */
-unsigned long port = PORT_SMTP;
+unsigned long smtp_port = 25; /* silly rabbit, /etc/services is for users */
+unsigned long qmtp_port = 209;
 
 GEN_ALLOC_typedef(saa,stralloc,sa,len,a)
 GEN_ALLOC_readyplus(saa,stralloc,sa,len,a,i,n,x,10,saa_readyplus)
@@@@ -70,6 +72,8 @@@@
 Unable to switch to home directory. (#4.3.0)\n"); zerodie(); }
 void temp_control() { out("Z\
 Unable to read control files. (#4.3.0)\n"); zerodie(); }
+void temp_proto() { out("Z\
+recipient did not talk proper QMTP (#4.3.0)\n"); zerodie(); }
 void perm_partialline() { out("D\
 SMTP cannot transfer messages with partial final lines. (#5.6.2)\n"); zerodie(); }
 void perm_usage() { out("D\
@@@@ -130,9 +134,9 @@@@
   return r;
 }
 
-char inbuf[1024];
+char inbuf[1500];
 substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof inbuf);
-char smtptobuf[1024];
+char smtptobuf[1500];
 substdio smtpto = SUBSTDIO_FDBUF(safewrite,-1,smtptobuf,sizeof smtptobuf);
 char smtpfrombuf[128];
 substdio smtpfrom = SUBSTDIO_FDBUF(saferead,-1,smtpfrombuf,sizeof smtpfrombuf);
@@@@ -281,6 +285,113 @@@@
   quit("K"," accepted message");
 }
 
+int qmtp_priority(int pref)
+{
+  if (pref < 12800) return 0;
+  if (pref > 13055) return 0;
+  if (pref % 16 == 1) return 1;
+  return 0;
+}
+
+void qmtp()
+{
+  struct stat st;
+  unsigned long len;
+  int len2;
+  char *x;
+  int i;
+  int n;
+  unsigned char ch;
+  char num[FMT_ULONG];
+  int flagallok;
+
+  if (fstat(0,&st) == -1) quit("Z", " unable to fstat stdin");
+  len = st.st_size;
+
+  /* the following code was substantially taken from serialmail'ss serialqmtp.c */
+  substdio_put(&smtpto,num,fmt_ulong(num,len+1));
+  substdio_put(&smtpto,":\n",2);
+  while (len > 0) {
+    n = substdio_feed(&ssin);
+    if (n <= 0) _exit(32); /* wise guy again */
+    x = substdio_PEEK(&ssin);
+    substdio_put(&smtpto,x,n);
+    substdio_SEEK(&ssin,n);
+    len -= n;
+  }
+  substdio_put(&smtpto,",",1);
+
+  len = sender.len;
+  substdio_put(&smtpto,num,fmt_ulong(num,len));
+  substdio_put(&smtpto,":",1);
+  substdio_put(&smtpto,sender.s,sender.len);
+  substdio_put(&smtpto,",",1);
+
+  len = 0;
+  for (i = 0;i < reciplist.len;++i)
+    len += fmt_ulong(num,reciplist.sa[i].len) + 1 + reciplist.sa[i].len + 1;
+  substdio_put(&smtpto,num,fmt_ulong(num,len));
+  substdio_put(&smtpto,":",1);
+  for (i = 0;i < reciplist.len;++i) {
+    substdio_put(&smtpto,num,fmt_ulong(num,reciplist.sa[i].len));
+    substdio_put(&smtpto,":",1);
+    substdio_put(&smtpto,reciplist.sa[i].s,reciplist.sa[i].len);
+    substdio_put(&smtpto,",",1);
+  }
+  substdio_put(&smtpto,",",1);
+  substdio_flush(&smtpto);
+
+  flagallok = 1;
+
+  for (i = 0;i < reciplist.len;++i) {
+    len = 0;
+    for (;;) {
+      get(&ch);
+      if (ch == ':') break;
+      if (len > 200000000) temp_proto();
+      if (ch - '0' > 9) temp_proto();
+      len = 10 * len + (ch - '0');
+    }
+    if (!len) temp_proto();
+    get(&ch); --len;
+    if ((ch != 'Z') && (ch != 'D') && (ch != 'K')) temp_proto();
+
+    if (!stralloc_copyb(&smtptext,&ch,1)) temp_proto();
+    if (!stralloc_cats(&smtptext,"qmtp: ")) temp_nomem();
+
+    while (len > 0) {
+      get(&ch);
+      --len;
+    }
+
+    for (len = 0;len < smtptext.len;++len) {
+      ch = smtptext.s[len];
+      if ((ch < 32) || (ch > 126)) smtptext.s[len] = '?';
+    }
+    get(&ch);
+    if (ch != ',') temp_proto();
+    smtptext.s[smtptext.len-1] = '\n';
+
+    if (smtptext.s[0] == 'K') out("r");
+    else if (smtptext.s[0] == 'D') {
+      out("h");
+      flagallok = 0;
+    }
+    else { /* if (smtptext.s[0] == 'Z') */
+      out("s");
+      flagallok = 0;
+    }
+    if (substdio_put(subfdoutsmall,smtptext.s+1,smtptext.len-1) == -1) temp_noconn();
+    zero();
+  }
+  if (!flagallok) {
+    out("DGiving up on ");outhost();out("\n");
+  } else {
+    out("KAll received okay by ");outhost();out("\n");
+  }
+  zerodie();
+}
+
 stralloc canonhost = {0};
 stralloc canonbox = {0};
 
@@@@ -392,7 +503,7 @@@@
   if (relayhost) {
     i = str_chr(relayhost,':');
     if (relayhost[i]) {
-      scan_ulong(relayhost + i + 1,&port);
+      scan_ulong(relayhost + i + 1,&smtp_port);
       relayhost[i] = 0;
     }
     if (!stralloc_copys(&host,relayhost)) temp_nomem();
@@@@ -453,7 +564,17 @@@@
     smtpfd = socket(ip.ix[i].af,SOCK_STREAM,0);
     if (smtpfd == -1) temp_oserr();
  
-    if (timeoutconn46(smtpfd,&ip.ix[i],(unsigned int) port,timeoutconnect) == 0)
+    if (qmtp_priority(ip.ix[i].pref)) {
+      if (timeoutconn46(smtpfd,&ip.ix[i],(unsigned int) qmtp_port,timeoutconnect) == 0) {
+       tcpto_err(&ip.ix[i],0);
+       partner = ip.ix[i];
+       qmtp(); /* does not return */
+      }
+      close(smtpfd);
+      smtpfd = socket(AF_INET,SOCK_STREAM,0);
+      if (smtpfd == -1) temp_oserr();
+    }
+    if (timeoutconn46(smtpfd,&ip.ix[i],(unsigned int) smtp_port,timeoutconnect)== 0)
 	{
       tcpto_err(&ip.ix[i],0);
       partner = ip.ix[i];

pkg-descr

Author:
WWW:

最終更新時間:2008年04月07日 19時37分53秒