From: Ituki Kirihara Date: Sun, 17 May 2015 04:05:26 +0000 (+0900) Subject: qmailからlmtp転送出来るようにするパッチ X-Git-Url: https://ituki.proj.jp/repo/?a=commitdiff_plain;h=HEAD;p=program%2Fpatch%2Fqmail%2Flmtp.git qmailからlmtp転送出来るようにするパッチ 手抜き注意 Signed-off-by: Ituki Kirihara --- 86c7e47726c33df45cb066962b4614daa39befb4 diff --git a/qmail-remote-lmtp.patch b/qmail-remote-lmtp.patch new file mode 100644 index 0000000..4d4c988 --- /dev/null +++ b/qmail-remote-lmtp.patch @@ -0,0 +1,102 @@ +--- qmail-remote.c.org Mon Jun 15 19:53:16 1998 ++++ qmail-remote.c Tue Apr 14 08:48:29 2015 +@@ -29,6 +29,11 @@ + #include "timeoutread.h" + #include "timeoutwrite.h" + ++#include ++#include ++#include ++#include ++ + #define HUGESMTPTEXT 5000 + + #define PORT_SMTP 25 /* silly rabbit, /etc/services is for users */ +@@ -44,6 +49,8 @@ + stralloc host = {0}; + stralloc sender = {0}; + ++int lmtpmode = 0; ++ + saa reciplist = {0}; + + struct ip_address partner; +@@ -86,6 +93,12 @@ + it isn't in my control/locals file, so I don't treat it as local. (#5.4.6)\n"); + zerodie(); } + ++void temp_no_lmtp_so_long() { out("ZLMTP file can't open\n"); zerodie(); } ++void temp_no_lmtp_socketopen() { out("ZLMTP socket can't open\n"); zerodie(); } ++void temp_no_lmtp_open() { out("ZLMTP file can't open\n"); zerodie(); } ++void temp_no_lmtp_non_support_multircpt() { out("Zcurrent LMTP don't support multi rcpt...\n"); zerodie(); } ++ ++ + void outhost() + { + char x[IPFMT]; +@@ -224,7 +237,11 @@ + + if (smtpcode() != 220) quit("ZConnected to "," but greeting failed"); + +- substdio_puts(&smtpto,"HELO "); ++ if (lmtpmode){ ++ substdio_puts(&smtpto,"LHLO "); ++ }else{ ++ substdio_puts(&smtpto,"HELO "); ++ } + substdio_put(&smtpto,helohost.s,helohost.len); + substdio_puts(&smtpto,"\r\n"); + substdio_flush(&smtpto); +@@ -239,6 +256,9 @@ + if (code >= 400) quit("ZConnected to "," but sender was rejected"); + + flagbother = 0; ++ if (lmtpmode && reciplist.len != 1){ ++ temp_no_lmtp_non_support_multircpt(); ++ } + for (i = 0;i < reciplist.len;++i) { + substdio_puts(&smtpto,"RCPT TO:<"); + substdio_put(&smtpto,reciplist.sa[i].s,reciplist.sa[i].len); +@@ -338,6 +358,7 @@ + int flagallaliases; + int flagalias; + char *relayhost; ++ struct sockaddr_un address; + + sig_pipeignore(); + if (argc < 4) perm_usage(); +@@ -357,7 +378,11 @@ + if (relayhost) { + i = str_chr(relayhost,':'); + if (relayhost[i]) { +- scan_ulong(relayhost + i + 1,&port); ++ if (strcmp(relayhost + i + 1,"lmtp") == 0){ ++ lmtpmode = 1; ++ }else{ ++ scan_ulong(relayhost + i + 1,&port); ++ } + relayhost[i] = 0; + } + if (!stralloc_copys(&host,relayhost)) temp_nomem(); +@@ -380,7 +405,20 @@ + ++recips; + } + +- ++ if (lmtpmode){ ++ stralloc_0(&host); ++ if (host.len >= sizeof(address.sun_path) -1) temp_no_lmtp_so_long(); ++ smtpfd = socket(AF_UNIX,SOCK_STREAM,0); ++ if (smtpfd == -1) temp_no_lmtp_socketopen(); ++ address.sun_family = AF_UNIX; ++ strcpy(address.sun_path, host.s); ++ if (connect(smtpfd,(struct sockaddr *)&address,sizeof(address)) == -1) temp_no_lmtp_open(); ++ smtp(); /* does not return */ ++ close(smtpfd); ++ temp_noconn(); ++ /* end program */ ++ } ++ + random = now() + (getpid() << 16); + switch (relayhost ? dns_ip(&ip,&host) : dns_mxip(&ip,&host,random)) { + case DNS_MEM: temp_nomem(); diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..7e9f678 --- /dev/null +++ b/readme.txt @@ -0,0 +1,20 @@ +smtproutesに以下の拡張を施す + +domain:relay:port +↓ +domain:relay:port or "lmtp" + +domain:relay:lmtp と記述することで、relay(ローカルパス)にLMTPでメールがリレーされる。 + +変更ファイル qmail-remote.c + +relayにはlmtp(dovecot)のパスを書く +パーミッションはgroup= qmail mode = 0600 user=qmailr\ +例えば + +test.proj.jp:/var/spool/dovecot-lmtp-qmail:lmtp + +と書いておけば、test.proj.jpはdovecotのlmtpを経由して送信される + + +