]> Pileus Git - ~andy/fetchmail/commitdiff
Samuel Leo's LMTP enhancement.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 6 Dec 2000 17:42:23 +0000 (17:42 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 6 Dec 2000 17:42:23 +0000 (17:42 -0000)
svn path=/trunk/; revision=2995

NEWS
fetchmail-features.html
fetchmail.man
sink.c
socket.c

diff --git a/NEWS b/NEWS
index e85f23e977c228b031f1b18cb91b8f9fac253611..6d2023cd3822d4f5fb0e6b9fe87712a983d138dd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,11 +4,12 @@
 
 * More on ETRN in the FAQ.
 * Horst Klokow's patch to make interface check the remote IP address.
-* Roger Luethi's patc to write the UIDL file when you hit a fetchlimit.
+* Roger Luethi's patch to write the UIDL file when you hit a fetchlimit.
 * Don Beusee's patch to eliminate wedging on authentication failure.
   Instead, fetchmail will now notify the user on the third failure, then
   continue polling silently until service is restored (at which time the
   user will get a notification).
+* Samuel Leo's patch to add LMTP capability to the smtphost option.
 
 ------------------------------------------------------------------------------
 fetchmail-5.6.0 (Sun Nov 26 22:11:09 EST 2000), 19625 lines:
index 474183b095d722880c176179a1c195b669f05321..ae49ebefc2ac2eb5785f0a0a0ee5398c1bdd194d 100644 (file)
@@ -10,7 +10,7 @@
 <table width="100%" cellpadding=0><tr>
 <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a>
 <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a>
-<td width="30%" align=right>$Date: 2000/12/01 09:47:53 $
+<td width="30%" align=right>$Date: 2000/12/06 17:42:20 $
 </table>
 <HR>
 
@@ -18,6 +18,8 @@
 
 <H2>Since 5.0:</H2>
 <UL>
+<LI>It's now easy to deliver mail to a local LMTP socket.<p>
+
 <LI>The interface option now checks both local and remote interface IPs.<p>
 
 <LI>
@@ -234,7 +236,7 @@ get-mail, gwpop, pimp-1.0, pop-perl5-1.2, popc, popmail-1.6 and upop.<P>
 <table width="100%" cellpadding=0><tr>
 <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a>
 <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a>
-<td width="30%" align=right>$Date: 2000/12/01 09:47:53 $
+<td width="30%" align=right>$Date: 2000/12/06 17:42:20 $
 </table>
 
 <P><ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com">&lt;esr@snark.thyrsus.com&gt;</A></ADDRESS>
index e7aead6819f3bf3c669fc125bd74dc8afe25b316..00faf901d65f49941c147e209b88361fd7c693dd 100644 (file)
@@ -316,9 +316,11 @@ preauthentication, the FQDN of the machine running fetchmail is added to
 the end of the list as an invisible default. Each hostname may have a 
 port number following the host name.  The port number is separated from
 the host name by a slash; the default port is 25 (or ``smtp'' under IPv6).
-Example:
+If you specify an absolute pathname (beginning with a /), it will be
+interpreted as the name of a UNIX socket accepting LMTP connections
+(such as is supported by the Cyrus IMAP daemon) Example:
 
-       --smtphost server1,server2/2525,server3
+       --smtphost server1,server2/2525,server3,/var/imap/socket/lmtp
 
 .TP
 .B \-D <domain>, --smtpaddress <domain>
diff --git a/sink.c b/sink.c
index b519e0d732309b04da285041e09079b396ad1dc7..11df187183b82e742d832b3911937940a4983f02 100644 (file)
--- a/sink.c
+++ b/sink.c
@@ -104,6 +104,8 @@ static int smtp_open(struct query *ctl)
            xalloca(parsed_host, char *, strlen(idp->id) + 1);
 
            ctl->smtphost = idp->id;  /* remember last host tried. */
+           if(ctl->smtphost[0]=='/')
+               ctl->listener = LMTP_MODE;
 
            strcpy(parsed_host, idp->id);
            if ((cp = strrchr(parsed_host, '/')))
@@ -116,6 +118,10 @@ static int smtp_open(struct query *ctl)
 #endif /* INET6_ENABLE */
            }
 
+           if (ctl->smtphost[0]=='/'){
+               if((ctl->smtp_socket = UnixOpen(ctl->smtphost))==-1)
+                   continue;
+           } else
            if ((ctl->smtp_socket = SockOpen(parsed_host,portnum,NULL,
                                             ctl->server.plugout)) == -1)
                continue;
@@ -159,7 +165,7 @@ static int smtp_open(struct query *ctl)
      * enforce this.  Now that we have the actual hostname,
      * compute what we should canonicalize with.
      */
-    ctl->destaddr = ctl->smtpaddress ? ctl->smtpaddress : ( ctl->smtphost ? ctl->smtphost : "localhost");
+    ctl->destaddr = ctl->smtpaddress ? ctl->smtpaddress : ( ctl->smtphost && ctl->smtphost[0] != '/' ? ctl->smtphost : "localhost");
 
     if (outlevel >= O_DEBUG && ctl->smtp_socket != -1)
        report(stdout, _("forwarding to %s\n"), ctl->smtphost);
index 3777e6d985b7d394078fae7e4ce59c04707529e3..26a46c2a66d215cfb4b0712324be189dac97e6d7 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -18,6 +18,7 @@
 #else
 #include <net/socket.h>
 #endif
+#include <sys/un.h>
 #include <netinet/in.h>
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
@@ -188,6 +189,31 @@ int SockCheckOpen(int fd)
 }
 #endif /* __UNUSED__ */
 
+int UnixOpen(const char *path)
+{
+    int sock = -1;
+    struct sockaddr_un ad;
+    memset(&ad, 0, sizeof(ad));
+    ad.sun_family = AF_UNIX;
+    strncpy(ad.sun_path, path, sizeof(ad.sun_path)-1);
+
+    sock = socket( AF_UNIX, SOCK_STREAM, 0 );
+    if (sock < 0)
+    {
+       h_errno = 0;
+       return -1;
+    }
+    if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
+    {
+       int olderr = errno;
+       fm_close(sock); /* don't use SockClose, no traffic yet */
+       h_errno = 0;
+       errno = olderr;
+       return -1;
+    }
+    return sock;
+}
+
 #if INET6_ENABLE
 int SockOpen(const char *host, const char *service, const char *options,
             const char *plugin)