aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INSTALL31
-rw-r--r--driver.c14
-rw-r--r--fetchmail.c29
-rw-r--r--fetchmail.h2
-rw-r--r--fetchmail.man15
-rw-r--r--getopt.c1
-rw-r--r--socket.c38
7 files changed, 81 insertions, 49 deletions
diff --git a/INSTALL b/INSTALL
index f90b09d3..c697c967 100644
--- a/INSTALL
+++ b/INSTALL
@@ -31,7 +31,12 @@ Next run
make
This will compile fetchmail for your system. Note that in order to
-build it, you'll need either flex at version 2.5.3 org greater, or lex.
+build it, you'll need either flex at version 2.5.3 or greater, or lex.
+
+If mxget.c fails to compile, your DNS-query support isn't compatible
+with BSD's and Linux's. Manually undefine HAVE_GETHOSTBYNAME in
+config.h and rebuild. You'll lose the multidrop-mailbox feature and
+Kerberos option, but nothing else.
3. INSTALL
@@ -59,11 +64,12 @@ at version 3.0b6 or later, do this
(cd ~; mv ~/.poprc ~/.fetchmailrc)
-in order to migrate. Be aware that some of popclient's unnecessary
+in order to migrate. Be aware that some of popclient's unnecessary
options have been removed (see the NOTES file for explanation). You
-can't deliver to a local mail file anymore, and using an MDA for delivery
-is discouraged. If you throw those options away, fetchmail will now forward
-your mail into your system's normal Internet-mail delivery path.
+can't deliver to a local mail file anymore or to standard output any
+more, and using an MDA for delivery is discouraged. If you throw
+those options away, fetchmail will now forward your mail into your
+system's normal Internet-mail delivery path.
If you use an MDA with popclient or an older version of fetchmail that
requires %s in the MDA string in order to substitute in a local
@@ -71,6 +77,19 @@ delivery address, remove it. One consequences of the internal changes
to support multi-drop mailboxes is that local delivery addresses will
be appended to the end of the command in the obvious way.
+Actually, using an MDA is now almost always the wrong thing; the MDA
+facility has been retained only for people who can't or won't run a
+sendmail-like SMTP listener on port 25. The default, SMTP forwarding
+to port 25, is better for at least two major reasons. One: it feeds
+retrieved POP and IMAP mail into your system's normal delivery path
+along with local mail and normal Internet mail. Two: because the port
+25 listener returns a positive acknowledge, fetchmail can be sure
+you're not going to lose mail to a disk-full or some other
+resource-exhaustion problem.
+
+If you used to use -mda "procmail -d <you>" or something similar, forward
+to port 25 and do "| procmail -d <you>" in your ~/.forward file.
+
5. TEST
I strongly recommend that your first fetchmail run use the -v and -k
@@ -82,7 +101,7 @@ This software is known to work with the qpop/popper series of
freeware POP3 servers; also with the imapd servers that are
distributed with Pine from the University of Washington. Other
POP3 servers have been known to give it indigestion. Test carefully!
-If you have problems, switch to imap.
+If you have problems, try to switch to IMAP.
If you're going to use multi-drop mailboxes, test with particular care.
This code was very difficult to test and should be considered experimental.
diff --git a/driver.c b/driver.c
index 38315ded..e549c5ed 100644
--- a/driver.c
+++ b/driver.c
@@ -440,17 +440,18 @@ int mboxfd; /* descriptor to which retrieved message will be written */
long len; /* length of message */
int delimited; /* does the protocol use a message delimiter? */
struct query *ctl; /* query control record */
-{
+{
char buf [MSGBUFSIZE+1];
- char *bufp, *headers, *unixfrom, *fromhdr, *tohdr, *cchdr, *bcchdr;
+ char *bufp, *headers, *fromhdr, *tohdr, *cchdr, *bcchdr;
int n, oldlen;
int inheaders,lines,sizeticker;
/* read the message content from the server */
inheaders = 1;
- headers = unixfrom = fromhdr = tohdr = cchdr = bcchdr = NULL;
+ headers = fromhdr = tohdr = cchdr = bcchdr = NULL;
lines = 0;
sizeticker = 0;
+ oldlen = 0;
while (delimited || len > 0)
{
if ((n = SockGets(socket,buf,sizeof(buf))) < 0)
@@ -517,9 +518,7 @@ struct query *ctl; /* query control record */
oldlen = newlen;
}
- if (!strncmp(bufp,"From ",5))
- unixfrom = bufp;
- else if (!strncasecmp("From:", bufp, 5))
+ if (!strncasecmp("From:", bufp, 5))
fromhdr = bufp;
else if (!strncasecmp("To:", bufp, 3))
tohdr = bufp;
@@ -539,8 +538,7 @@ struct query *ctl; /* query control record */
xmit_names = (struct idlist *)NULL;
#ifdef HAVE_GETHOSTBYNAME
/* is this a multidrop box? */
- if (ctl->localnames != (struct idlist *)NULL
- && ctl->localnames->next != (struct idlist *)NULL)
+ if (MULTIDROP(ctl))
{
/* compute the local address list */
find_server_names(tohdr, ctl, &xmit_names);
diff --git a/fetchmail.c b/fetchmail.c
index aa8dff4e..89b9d713 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -71,7 +71,7 @@ int main (argc,argv)
int argc;
char **argv;
{
- int st, bkgd, lossage;
+ int st, lossage, bkgd = FALSE;
struct query def_opts;
int parsestatus, implicitmode;
char *home, *tmpdir, tmpbuf[BUFSIZ];
@@ -202,17 +202,26 @@ char **argv;
ctl->uid = pw->pw_uid;
#ifdef HAVE_GETHOSTBYNAME
- /* compute the canonical name of the host */
- namerec = gethostbyname(ctl->servername);
- if (namerec == (struct hostent *)NULL)
+ /*
+ * Don't do DNS lookup unless we need to because we're going
+ * to use Kerberos or process a multidrop box. Some sites
+ * won't have DNS up at fetchmail initialization time but aren't
+ * using these features -- avoid hosing them unnecessarily.
+ */
+ if (ctl->authenticate == A_KERBEROS || MULTIDROP(ctl))
{
- fprintf(stderr,
- "fetchmail: can't get canonical name of host %s\n",
- ctl->servername);
- exit(PS_SYNTAX);
+ /* compute the canonical name of the host */
+ namerec = gethostbyname(ctl->servername);
+ if (namerec == (struct hostent *)NULL)
+ {
+ fprintf(stderr,
+ "fetchmail: can't get canonical name of host %s\n",
+ ctl->servername);
+ exit(PS_SYNTAX);
+ }
+ else
+ ctl->canonical_name = xstrdup((char *)namerec->h_name);
}
- else
- ctl->canonical_name = xstrdup((char *)namerec->h_name);
#else
/* can't handle multidrop mailboxes unless we can do DNS lookups */
if (ctl->localnames && ctl->localnames->next)
diff --git a/fetchmail.h b/fetchmail.h
index 352676fd..b03899d0 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -100,6 +100,8 @@ struct query
#endif /* HAVE_GETHOSTBYNAME */
};
+#define MULTIDROP(ctl) ((ctl)->localnames && (ctl)->localnames->next)
+
struct method
{
char *name; /* protocol name */
diff --git a/fetchmail.man b/fetchmail.man
index 0eb43a93..38e848af 100644
--- a/fetchmail.man
+++ b/fetchmail.man
@@ -652,13 +652,14 @@ then changed to
to reflect both the presence of IMAP support and the symmetry with sendmail
created by the new SMTP forwarding default.
.SH BACKWARD COMPATIBILITY
-If called through a link named `popclient', \fIfetchmail\fR will
-look in ~/.poprc for its run control file. As long as the file does
-not use the removed `limit' or `localfolder' options, this
-will often work. (The new run control file syntax also has to be a
-little stricter about the order of options than the old, in order to
-support multiple user desriptions per server; thus you may have to
-rearrange things a bit.)
+If called through a link named `popclient', \fIfetchmail\fR will look
+in ~/.poprc for its run control file. As long as the file does not
+use the removed `localfolder' option or `limit' (which now takes a
+maximum byte size rather than a line count), this will often work.
+(The new run control file syntax also has to be a little stricter
+about the order of options than the old, in order to support multiple
+user desriptions per server; thus you may have to rearrange things a
+bit.)
.SH FILES
.TP 5
~/.fetchmailrc
diff --git a/getopt.c b/getopt.c
index de30ec79..ecf0c34c 100644
--- a/getopt.c
+++ b/getopt.c
@@ -39,6 +39,7 @@
#endif
#include <stdio.h>
+#include <string.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
diff --git a/socket.c b/socket.c
index ba281a31..52f88e95 100644
--- a/socket.c
+++ b/socket.c
@@ -192,28 +192,30 @@ int len;
for data. */
int SockDataWaiting(int socket)
{
- int flags;
- char sbuf[INTERNAL_BUFSIZE];
- int n;
- int res;
- flags = fcntl(socket,F_GETFL,0);
+ int flags;
+ char sbuf[INTERNAL_BUFSIZE];
+ int n;
+ flags = fcntl(socket,F_GETFL,0);
- /* set it to non-block */
- if (fcntl(socket,F_SETFL,flags | O_NONBLOCK) == -1)
- return -1;
+ /* set it to non-block */
+ if (fcntl(socket,F_SETFL,flags | O_NONBLOCK) == -1)
+ return -1;
+
+ n = recv(socket,sbuf,INTERNAL_BUFSIZE,MSG_PEEK);
+
+ /* reset it to block (or, whatever it was). */
+ fcntl(socket,F_SETFL,flags);
- if ((n = recv(socket,sbuf,INTERNAL_BUFSIZE,MSG_PEEK)) == -1)
+ if (n == -1)
{
- /* No data to read. */
- if (errno == EWOULDBLOCK)
- res = 0;
+ /* No data to read. */
+ if (errno == EWOULDBLOCK)
+ return(0);
+ else
+ return(-1);
}
- else
- res = n;
-
- /* reset it to block (or, whatever it was). */
- fcntl(socket,F_SETFL,flags);
- return res;
+ else
+ return(n);
}