diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1999-11-06 21:55:19 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1999-11-06 21:55:19 +0000 |
commit | 6a75e16b6942cb3be87298fd9ca0c7d65d81f952 (patch) | |
tree | 3bceb1ca26a94beff0ec40edca7034beff408560 | |
parent | dfff00af0a435d1a1646051f712240295997efb6 (diff) | |
download | fetchmail-6a75e16b6942cb3be87298fd9ca0c7d65d81f952.tar.gz fetchmail-6a75e16b6942cb3be87298fd9ca0c7d65d81f952.tar.bz2 fetchmail-6a75e16b6942cb3be87298fd9ca0c7d65d81f952.zip |
Ready to send this to Mike.
svn path=/trunk/; revision=2649
-rw-r--r-- | Makefile.in | 4 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | acconfig.h | 4 | ||||
-rw-r--r-- | conf.c | 16 | ||||
-rw-r--r-- | configure.in | 44 | ||||
-rw-r--r-- | driver.c | 20 | ||||
-rw-r--r-- | etrn.c | 6 | ||||
-rw-r--r-- | fetchmail.c | 38 | ||||
-rw-r--r-- | fetchmail.h | 18 | ||||
-rwxr-xr-x | fetchmailconf | 8 | ||||
-rw-r--r-- | imap.c | 37 | ||||
-rw-r--r-- | interface.c | 4 | ||||
-rw-r--r-- | options.c | 26 | ||||
-rw-r--r-- | pop2.c | 6 | ||||
-rw-r--r-- | pop3.c | 26 | ||||
-rw-r--r-- | rcfile_y.y | 26 | ||||
-rw-r--r-- | sink.c | 8 | ||||
-rw-r--r-- | socket.c | 51 | ||||
-rw-r--r-- | socket.h | 6 |
19 files changed, 193 insertions, 160 deletions
diff --git a/Makefile.in b/Makefile.in index e94fb983..f7aa141a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -186,6 +186,8 @@ realclean: distclean mostlyclean: clean # These magic rules are copied from the autoconf documentation +# except that Harry McGavran says the autoheader call in the third +# one below is unnecessary and causes problems with cross-platform builds. ${srcdir}/configure: configure.in aclocal.m4 cd ${srcdir} && autoconf @@ -194,7 +196,7 @@ ${srcdir}/configure: configure.in aclocal.m4 ${srcdir}/config.h.in: stamp-h.in ${srcdir}/stamp-h.in: configure.in aclocal.m4 acconfig.h # config.h.top config.h.bot - cd ${srcdir} && autoheader + cd ${srcdir} # && autoheader echo timestamp> ${srcdir}/stamp-h.in config.h: stamp-h @@ -9,6 +9,11 @@ a Certifying Authority we recognize?). (The `lines' figures total .c, .h, .l, and .y files under version control.) +* Duplicate suppression now happens only when there is exactly one recipient. +* Mike Pearce's patch to fix a compile-time error recently introduced into + the socket code when HAVE_INET_ATON is off. +* Added warning to fetchmailconf autoprobe about a flaky Netscape IMAP server. + fetchmail-5.1.3 (Sun Oct 31 12:19:52 EST 1999), 18290 lines: * Grant Edwards's patch to correct NTLM behavior. * James Brister's fix for IP-address hostnames. @@ -104,10 +104,10 @@ #undef SSL_ENABLE /* Define if you want OPIE support compiled in */ -#undef OPIE +#undef OPIE_ENABLE /* Define if you want IPv6 support compiled in */ -#undef INET6 +#undef INET6_ENABLE /* Define if you want network security support compiled in */ #undef NET_SECURITY @@ -172,12 +172,12 @@ void dump_config(struct runctl *runp, struct query *querylist) #ifdef SSL_ENABLE printf("'ssl',"); #endif /* SSL_ENABLE */ -#if OPIE +#if OPIE_ENABLE printf("'opie',"); -#endif /* OPIE */ -#if INET6 +#endif /* OPIE_ENABLE */ +#if INET6_ENABLE printf("'inet6',"); -#endif /* INET6 */ +#endif /* INET6_ENABLE */ #if NET_SECURITY printf("'netsec',"); #endif /* NET_SECURITY */ @@ -237,7 +237,7 @@ void dump_config(struct runctl *runp, struct query *querylist) using_kpop = (ctl->server.protocol == P_POP3 && -#if !INET6 +#if !INET6_ENABLE ctl->server.port == KPOP_PORT && #else 0 == strcmp( ctl->server.service, KPOP_PORT ) && @@ -249,7 +249,7 @@ void dump_config(struct runctl *runp, struct query *querylist) stringdump("via", ctl->server.via); stringdump("protocol", using_kpop ? "KPOP" : showproto(ctl->server.protocol)); -#if !INET6 +#if !INET6_ENABLE numdump("port", ctl->server.port); #else stringdump("service", ctl->server.service); @@ -336,9 +336,9 @@ void dump_config(struct runctl *runp, struct query *querylist) else fputs("'lmtp':FALSE,\n", stdout); -#ifdef INET6 +#ifdef INET6_ENABLE stringdump("netsec", ctl->server.netsec); -#endif /* INET6 */ +#endif /* INET6_ENABLE */ stringdump("preconnect", ctl->preconnect); stringdump("postconnect", ctl->postconnect); numdump("limit", ctl->limit); diff --git a/configure.in b/configure.in index 8c117434..88093cbe 100644 --- a/configure.in +++ b/configure.in @@ -281,31 +281,41 @@ AC_ARG_ENABLE(opie, [ --enable-opie support OTP through the OPIE library], [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1]) AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1]) - AC_DEFINE(OPIE,1) ], + with_opie=$enableval], [with_opie=no]) +test "$with_opie" = "yes" && AC_DEFINE(OPIE_ENABLE) AC_ARG_ENABLE(inet6, [ --enable-inet6 support IPv6 (requires the inet6-apps library)], - [ unset ac_cv_lib_inet6_getaddrinfo; AC_CHECK_LIB(inet6, getaddrinfo,, - [ unset ac_cv_lib_inet6_getaddrinfo; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, getaddrinfo,, - [ echo 'configure: cannot find libinet6, which is required for IPv6 support.'; exit 1]) ]) - AC_DEFINE(INET6, 1) ]) + [ unset ac_cv_lib_inet6_getaddrinfo; AC_CHECK_LIB(inet6,getaddrinfo,, + [ unset ac_cv_lib_inet6_getaddrinfo; + LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; + AC_CHECK_LIB(inet6, getaddrinfo,, + [ echo 'configure: cannot find libinet6, which is required for IPv6 support.'; + exit 1]) ]) ] + [with_inet6=no]) +test "$with_inet6" = "yes" && AC_DEFINE(INET6_ENABLE) AC_ARG_ENABLE(netsec, [ --enable-netsec support network security (requires inet6-apps library)], [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,, - [ unset ac_cv_lib_inet6_net_security_strtorequest; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, net_security_strtorequest,, - [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required'; - echo ' for network security support. Either it does not exist, or it was'; - echo ' not built with network security support enabled.'; - exit 1]) ]) - unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,, - [ unset ac_cv_header_net_security_h; CPPFLAGS="$CPPFLAGS -I/usr/inet6/include"; CFLAGS="$CFLAGS -I/usr/inet6/include"; AC_CHECK_HEADER(net/security.h,, - [ echo 'configure: cannot find <net/security.h>, which is required for network security'; - echo ' support.'; - exit 1]) ]) - AC_DEFINE(NET_SECURITY, 1) ]) - + [ unset ac_cv_lib_inet6_net_security_strtorequest; + LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; + AC_CHECK_LIB(inet6, net_security_strtorequest,, + [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required'; + echo ' for network security support. Either it does not exist, or it was'; + echo ' not built with network security support enabled.'; + exit 1]) ]) + unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,, + [ unset ac_cv_header_net_security_h; + CPPFLAGS="$CPPFLAGS -I/usr/inet6/include"; + CFLAGS="$CFLAGS -I/usr/inet6/include"; AC_CHECK_HEADER(net/security.h,, + [ echo 'configure: cannot find <net/security.h>, which is required'; + echo ' for network security support.'; + exit 1]) ]) ] + [with_netsec=no]) +test "$with_netsec" = "yes" && AC_DEFINE(NET_SECURITY) + ### use option --with-kerberos5=DIR to point at a Kerberos 5 directory AC_ARG_WITH(kerberos5, [ --with-kerberos5=DIR point fetchmail compilation at a Kerberos 5 directory]) @@ -1535,11 +1535,11 @@ const int maxfetch; /* maximum number of messages to fetch */ { char buf[POPBUFSIZE+1], *realhost; int len, num, count, new, bytes, deletions = 0, *msgsizes = NULL; -#if INET6 +#if INET6_ENABLE int fetches, dispatches, oldphase; -#else /* INET6 */ +#else /* INET6_ENABLE */ int port, fetches, dispatches, oldphase; -#endif /* INET6 */ +#endif /* INET6_ENABLE */ struct idlist *idp; /* execute pre-initialization command, if any */ @@ -1555,27 +1555,27 @@ const int maxfetch; /* maximum number of messages to fetch */ oldphase = phase; phase = OPEN_WAIT; set_timeout(mytimeout); -#if !INET6 +#if !INET6_ENABLE #ifdef SSL_ENABLE port = ctl->server.port ? ctl->server.port : ( ctl->use_ssl ? protocol->sslport : protocol->port ); #else port = ctl->server.port ? ctl->server.port : protocol->port; #endif -#endif /* !INET6 */ +#endif /* !INET6_ENABLE */ realhost = ctl->server.via ? ctl->server.via : ctl->server.pollname; /* allow time for the port to be set up if we have a plugin */ if (ctl->server.plugin) (void)sleep(1); -#if INET6 +#if INET6_ENABLE if ((mailserver_socket = SockOpen(realhost, ctl->server.service ? ctl->server.service : protocol->service, ctl->server.netsec, ctl->server.plugin)) == -1) -#else /* INET6 */ +#else /* INET6_ENABLE */ if ((mailserver_socket = SockOpen(realhost, port, NULL, ctl->server.plugin)) == -1) -#endif /* INET6 */ +#endif /* INET6_ENABLE */ { -#if !INET6 +#if !INET6_ENABLE int err_no = errno; #ifdef HAVE_RES_SEARCH if (err_no != 0 && h_errno != 0) @@ -1610,7 +1610,7 @@ const int maxfetch; /* maximum number of messages to fetch */ report_complete(stderr, ": %s\n", strerror(err_no)); ehostunreach: -#endif /* INET6 */ +#endif /* INET6_ENABLE */ ok = PS_SOCKET; set_timeout(0); phase = oldphase; @@ -117,13 +117,13 @@ static int etrn_logout(int sock, struct query *ctl) const static struct method etrn = { "ETRN", /* ESMTP ETRN extension */ -#if INET6 +#if INET6_ENABLE "smtp", /* standard SMTP port */ "smtps", /* ssl SMTP port */ -#else /* INET6 */ +#else /* INET6_ENABLE */ 25, /* standard SMTP port */ 465, /* ssl SMTP port */ -#endif /* INET6 */ +#endif /* INET6_ENABLE */ FALSE, /* this is not a tagged protocol */ FALSE, /* this does not use a message delimiter */ etrn_ok, /* parse command response */ diff --git a/fetchmail.c b/fetchmail.c index 5477d032..578c7d2a 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -223,12 +223,12 @@ int main(int argc, char **argv) #ifdef SSL_ENABLE printf("+SSL"); #endif -#if OPIE +#if OPIE_ENABLE printf("+OPIE"); -#endif /* OPIE */ -#if INET6 +#endif /* OPIE_ENABLE */ +#if INET6_ENABLE printf("+INET6"); -#endif /* INET6 */ +#endif /* INET6_ENABLE */ #if NET_SECURITY printf("+NETSEC"); #endif /* NET_SECURITY */ @@ -594,11 +594,11 @@ int main(int argc, char **argv) } } -#if (defined(linux) && !INET6) || defined(__FreeBSD__) +#if (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) /* interface_approve() does its own error logging */ if (!interface_approve(&ctl->server)) continue; -#endif /* (defined(linux) && !INET6) || defined(__FreeBSD__) */ +#endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */ querystatus = query_host(ctl); @@ -623,7 +623,7 @@ int main(int argc, char **argv) ((querystatus!=PS_NOMAIL) || (outlevel==O_DEBUG))) report(stdout, _("Query status=%d\n"), querystatus); -#if (defined(linux) && !INET6) || defined (__FreeBSD__) +#if (defined(linux) && !INET6_ENABLE) || defined (__FreeBSD__) if (ctl->server.monitor) { /* @@ -634,7 +634,7 @@ int main(int argc, char **argv) sleep(3); interface_note_activity(&ctl->server); } -#endif /* (defined(linux) && !INET6) || defined(__FreeBSD__) */ +#endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */ } } @@ -834,12 +834,12 @@ static void optmerge(struct query *h2, struct query *h1, int force) #define FLAG_MERGE(fld) if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld FLAG_MERGE(server.via); FLAG_MERGE(server.protocol); -#if INET6 +#if INET6_ENABLE FLAG_MERGE(server.service); FLAG_MERGE(server.netsec); -#else /* INET6 */ +#else /* INET6_ENABLE */ FLAG_MERGE(server.port); -#endif /* INET6 */ +#endif /* INET6_ENABLE */ FLAG_MERGE(server.interval); FLAG_MERGE(server.preauthenticate); FLAG_MERGE(server.timeout); @@ -1151,7 +1151,7 @@ static int load_params(int argc, char **argv, int optind) if (ctl->server.timeout == -1) ctl->server.timeout = CLIENT_TIMEOUT; -#if !INET6 +#if !INET6_ENABLE /* sanity checks */ if (ctl->server.port < 0) { @@ -1185,7 +1185,7 @@ static int load_params(int argc, char **argv, int optind) } } } -#endif /* !INET6 */ +#endif /* !INET6_ENABLE */ /* * "I beg to you, have mercy on the week minds like myself." @@ -1458,26 +1458,26 @@ static void dump_params (struct runctl *runp, } if (ctl->server.protocol == P_POP3 -#if INET6 +#if INET6_ENABLE && !strcmp(ctl->server.service, KPOP_PORT) -#else /* INET6 */ +#else /* INET6_ENABLE */ && ctl->server.port == KPOP_PORT -#endif /* INET6 */ +#endif /* INET6_ENABLE */ && (ctl->server.preauthenticate == A_KERBEROS_V4 || ctl->server.preauthenticate == A_KERBEROS_V5)) printf(_(" Protocol is KPOP with Kerberos %s authentication"), ctl->server.preauthenticate == A_KERBEROS_V5 ? "V" : "IV"); else printf(_(" Protocol is %s"), showproto(ctl->server.protocol)); -#if INET6 +#if INET6_ENABLE if (ctl->server.service) printf(_(" (using service %s)"), ctl->server.service); if (ctl->server.netsec) printf(_(" (using network security options %s)"), ctl->server.netsec); -#else /* INET6 */ +#else /* INET6_ENABLE */ if (ctl->server.port) printf(_(" (using port %d)"), ctl->server.port); -#endif /* INET6 */ +#endif /* INET6_ENABLE */ else if (outlevel >= O_VERBOSE) printf(_(" (using default port)")); if (ctl->server.uidl && (ctl->server.protocol != P_ETRN)) diff --git a/fetchmail.h b/fetchmail.h index 6694cf79..69e7b838 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -18,13 +18,13 @@ #define P_IMAP_LOGIN 10 #define P_ETRN 11 -#if INET6 +#if INET6_ENABLE #define SMTP_PORT "smtp" #define KPOP_PORT "kpop" -#else /* INET6 */ +#else /* INET6_ENABLE */ #define SMTP_PORT 25 #define KPOP_PORT 1109 -#endif /* INET6 */ +#endif /* INET6_ENABLE */ #ifdef SSL_ENABLE #define SIMAP_PORT 993 @@ -144,13 +144,13 @@ struct query; struct method /* describe methods for protocol state machine */ { const char *name; /* protocol name */ -#if INET6 +#if INET6_ENABLE const char *service; const char *sslservice; -#else /* INET6 */ +#else /* INET6_ENABLE */ int port; /* service port */ int sslport; /* service port for ssl */ -#endif /* INET6 */ +#endif /* INET6_ENABLE */ flag tagged; /* if true, generate & expect command tags */ flag delimited; /* if true, accept "." message delimiter */ int (*parse_response)(int, char *); @@ -186,12 +186,12 @@ struct hostdata /* shared among all user connections to given server */ struct idlist *akalist; /* server name first, then akas */ struct idlist *localdomains; /* list of pass-through domains */ int protocol; /* protocol type */ -#if INET6 +#if INET6_ENABLE char *service; /* IPv6 service name */ void *netsec; /* IPv6 security request */ -#else /* INET6 */ +#else /* INET6_ENABLE */ int port; /* TCP/IP service port number */ -#endif /* INET6 */ +#endif /* INET6_ENABLE */ int interval; /* # cycles to skip between polls */ int preauthenticate; /* preauthentication mode to try */ int timeout; /* inactivity timout in seconds */ diff --git a/fetchmailconf b/fetchmailconf index 05a961a1..bc6117f2 100755 --- a/fetchmailconf +++ b/fetchmailconf @@ -1240,6 +1240,14 @@ mail will be retrieved next time around. Some server that uses this greeting line has been observed to choke on TOP %d 99999999. Use the fetchall option. if necessary, to force RETR. """ + + if string.find(greetline, "Netscape IMAP4rev1 Service 3.6") > 0: + warnings = warnings + """ +This server violates the RFC2060 requirement that a BODY[TEXT] fetch should +set the messages's Seen flag. As a result, if you use the keep option the +same messages will be downloaded over and over. +""" + if string.find(greetline, "IMAP4rev1") > 0: warnings = warnings + """ I see an IMAP4rev1 server. Excellent. This is (a) the best kind of @@ -49,9 +49,9 @@ #include "md5.h" -#if OPIE +#if OPIE_ENABLE #include <opie.h> -#endif /* OPIE */ +#endif /* OPIE_ENABLE */ #ifndef strstr /* glibc-2.1 declares this as a macro */ extern char *strstr(); /* needed on sysV68 R3V7.1. */ @@ -148,7 +148,7 @@ int imap_ok(int sock, char *argbuf) } } -#if OPIE +#if OPIE_ENABLE static int do_otp(int sock, struct query *ctl) { int i, rval; @@ -211,7 +211,7 @@ static int do_otp(int sock, struct query *ctl) else return PS_AUTHFAIL; }; -#endif /* OPIE */ +#endif /* OPIE_ENABLE */ #ifdef KERBEROS_V4 #if SIZEOF_INT == 4 @@ -890,7 +890,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) if (preauth) return(PS_SUCCESS); -#if OPIE +#if OPIE_ENABLE if ((ctl->server.protocol == P_IMAP) && strstr(capabilities, "AUTH=X-OTP")) { if (outlevel >= O_DEBUG) @@ -898,7 +898,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) if (do_otp(sock, ctl) == PS_SUCCESS) return(PS_SUCCESS); }; -#endif /* OPIE */ +#endif /* OPIE_ENABLE */ #ifdef GSSAPI if (strstr(capabilities, "AUTH=GSSAPI")) @@ -1139,7 +1139,7 @@ static int imap_fetch_headers(int sock, struct query *ctl,int number,int *lenp) number -= expunged; /* - * This is blessed by RFC 1176, RFC1730, RFC2060. + * This is blessed by RFC1176, RFC1730, RFC2060. * According to the RFCs, it should *not* set the \Seen flag. */ gen_send(sock, "FETCH %d RFC822.HEADER", number); @@ -1176,7 +1176,8 @@ static int imap_fetch_body(int sock, struct query *ctl, int number, int *lenp) * * However...*don't* do this if we're using keep to suppress deletion! * In that case, marking the seen flag is the only way to prevent the - * message from being re-fetched on subsequent runs. + * message from being re-fetched on subsequent runs (and according + * to RFC2060 p.43 this fetch should set Seen as a side effect). */ switch (imap_version) { @@ -1244,12 +1245,14 @@ static int imap_trail(int sock, struct query *ctl, int number) #ifdef __UNUSED__ /* - * We've had a report of one POP3 server (not yet identified) that - * fails to set SEEN on a message fetch. This becomes an issue when - * keep is on, because seen messages aren't deleted and get - * refetched on each poll. As a workaround, if keep is on - * we could set the Seen flag explicitly. This code isn't used yet - * because we don't know of any IMAP servers broken in this way. + * Any IMAP server that fails to set Seen on a BODY[TEXT] + * fetch violates RFC2060 p.43 (top). This becomes an issue + * when keep is on, because seen messages aren't deleted and + * get refetched on each poll. As a workaround, if keep is on + * we can set the Seen flag explicitly. + * + * This code isn't used yet because we don't know of any IMAP + * servers broken in this way. */ if (ctl->keep) if ((ok = gen_transact(sock, @@ -1316,13 +1319,13 @@ static int imap_logout(int sock, struct query *ctl) const static struct method imap = { "IMAP", /* Internet Message Access Protocol */ -#if INET6 +#if INET6_ENABLE "imap", "imaps", -#else /* INET6 */ +#else /* INET6_ENABLE */ 143, /* standard IMAP2bis/IMAP4 port */ 993, /* ssl IMAP2bis/IMAP4 port */ -#endif /* INET6 */ +#endif /* INET6_ENABLE */ TRUE, /* this is a tagged protocol */ FALSE, /* no message delimiter */ imap_ok, /* parse command response */ diff --git a/interface.c b/interface.c index 794bb980..f1958cdd 100644 --- a/interface.c +++ b/interface.c @@ -16,7 +16,7 @@ #include <sys/types.h> #include <sys/param.h> -#if (defined(linux) && !defined(INET6)) || defined(__FreeBSD__) +#if (defined(linux) && !defined(INET6_ENABLE)) || defined(__FreeBSD__) #include "config.h" #include <stdio.h> @@ -505,4 +505,4 @@ int interface_approve(struct hostdata *hp) return(TRUE); } -#endif /* (defined(linux) && !defined(INET6)) || defined(__FreeBSD__) */ +#endif /* (defined(linux) && !defined(INET6_ENABLE)) || defined(__FreeBSD__) */ @@ -132,9 +132,9 @@ static const struct option longoptions[] = { {"bsmtp", required_argument, (int *) 0, LA_BSMTP }, {"lmtp", no_argument, (int *) 0, LA_LMTP }, -#ifdef INET6 +#ifdef INET6_ENABLE {"netsec", required_argument, (int *) 0, LA_NETSEC }, -#endif /* INET6 */ +#endif /* INET6_ENABLE */ #ifdef SSL_ENABLE {"ssl", no_argument, (int *) 0, LA_SSL }, @@ -142,10 +142,10 @@ static const struct option longoptions[] = { {"sslcert", required_argument, (int *) 0, LA_SSLCERT }, #endif -#if (defined(linux) && !INET6) || defined(__FreeBSD__) +#if (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) {"interface", required_argument, (int *) 0, LA_INTERFACE }, {"monitor", required_argument, (int *) 0, LA_MONITOR }, -#endif /* (defined(linux) && !INET6) || defined(__FreeBSD__) */ +#endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */ {"plugin", required_argument, (int *) 0, LA_PLUGIN }, {"plugout", required_argument, (int *) 0, LA_PLUGOUT }, @@ -337,11 +337,11 @@ struct query *ctl; /* option record to be initialized */ else if (strcasecmp(optarg,"kpop") == 0) { ctl->server.protocol = P_POP3; -#if INET6 +#if INET6_ENABLE ctl->server.service = KPOP_PORT; -#else /* INET6 */ +#else /* INET6_ENABLE */ ctl->server.port = KPOP_PORT; -#endif /* INET6 */ +#endif /* INET6_ENABLE */ #ifdef KERBEROS_V5 ctl->server.preauthenticate = A_KERBEROS_V5; #else @@ -375,11 +375,11 @@ struct query *ctl; /* option record to be initialized */ break; case 'P': case LA_PORT: -#if INET6 +#if INET6_ENABLE ctl->server.service = optarg; -#else /* INET6 */ +#else /* INET6_ENABLE */ ctl->server.port = xatoi(optarg, &errflag); -#endif /* INET6 */ +#endif /* INET6_ENABLE */ break; case LA_PREAUTH: if (strcmp(optarg, "password") == 0) @@ -518,7 +518,7 @@ struct query *ctl; /* option record to be initialized */ #endif /* NET_SECURITY */ break; -#if (defined(linux) && !INET6) || defined(__FreeBSD__) +#if (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) case 'I': case LA_INTERFACE: interface_parse(optarg, &ctl->server); @@ -527,7 +527,7 @@ struct query *ctl; /* option record to be initialized */ case LA_MONITOR: ctl->server.monitor = xstrdup(optarg); break; -#endif /* (defined(linux) && !INET6) || defined(__FreeBSD__) */ +#endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */ case LA_PLUGIN: ctl->server.plugin = xstrdup(optarg); break; @@ -600,7 +600,7 @@ struct query *ctl; /* option record to be initialized */ P(_(" -i, --idfile specify alternate UIDs file\n")); P(_(" --postmaster specify recipient of last resort\n")); P(_(" --nobounce redirect bounces from user to postmaster.\n")); -#if (defined(linux) && !INET6) || defined(__FreeBSD__) +#if (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) P(_(" -I, --interface interface required specification\n")); P(_(" -M, --monitor monitor interface for activity\n")); #endif @@ -124,13 +124,13 @@ static int pop2_logout(int sock, struct query *ctl) const static struct method pop2 = { "POP2", /* Post Office Protocol v2 */ -#if INET6 +#if INET6_ENABLE "pop2", /* standard POP2 port */ "pop2", /* ssl POP2 port */ -#else /* INET6 */ +#else /* INET6_ENABLE */ 109, /* standard POP2 port */ 109, /* ssl POP2 port - not */ -#endif /* INET6 */ +#endif /* INET6_ENABLE */ FALSE, /* this is not a tagged protocol */ FALSE, /* does not use message delimiter */ pop2_ok, /* parse command response */ @@ -21,9 +21,9 @@ #include "socket.h" #include "i18n.h" -#if OPIE +#if OPIE_ENABLE #include <opie.h> -#endif /* OPIE */ +#endif /* OPIE_ENABLE */ #ifndef strstr /* glibc-2.1 declares this as a macro */ extern char *strstr(); /* needed on sysV68 R3V7.1. */ @@ -41,9 +41,9 @@ char *sdps_envfrom; char *sdps_envto; #endif /* SDPS_ENABLE */ -#if OPIE +#if OPIE_ENABLE static char lastok[POPBUFSIZE+1]; -#endif /* OPIE */ +#endif /* OPIE_ENABLE */ int pop3_ok (int sock, char *argbuf) /* parse command response */ @@ -68,9 +68,9 @@ int pop3_ok (int sock, char *argbuf) if (strcmp(buf,"+OK") == 0) { -#if OPIE +#if OPIE_ENABLE strcpy(lastok, bufp); -#endif /* OPIE */ +#endif /* OPIE_ENABLE */ ok = 0; } else if (strncmp(buf,"-ERR", 4) == 0) @@ -122,9 +122,9 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting) int ok; char *start,*end; char *msg; -#if OPIE +#if OPIE_ENABLE char *challenge; -#endif /* OPIE */ +#endif /* OPIE_ENABLE */ pop3_phase = PHASE_GETAUTH; @@ -168,7 +168,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting) #endif /* RPA_ENABLE */ ok = gen_transact(sock, "USER %s", ctl->remotename); -#if OPIE +#if OPIE_ENABLE /* see RFC1938: A One-Time Password System */ if (challenge = strstr(lastok, "otp-")) { char response[OPIE_RESPONSE_MAX+1]; @@ -191,7 +191,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting) ok = gen_transact(sock, "PASS %s", response); break; } -#endif /* OPIE */ +#endif /* OPIE_ENABLE */ /* ordinary validation, no one-time password or RPA */ ok = gen_transact(sock, "PASS %s", ctl->password); @@ -643,13 +643,13 @@ static int pop3_logout(int sock, struct query *ctl) const static struct method pop3 = { "POP3", /* Post Office Protocol v3 */ -#if INET6 +#if INET6_ENABLE "pop3", /* standard POP3 port */ "pop3s", /* ssl POP3 port */ -#else /* INET6 */ +#else /* INET6_ENABLE */ 110, /* standard POP3 port */ 995, /* ssl POP3 port */ -#endif /* INET6 */ +#endif /* INET6_ENABLE */ FALSE, /* this is not a tagged protocol */ TRUE, /* this uses a message delimiter */ pop3_ok, /* parse command response */ @@ -138,11 +138,11 @@ serv_option : AKA alias_list #else current.server.preauthenticate = A_KERBEROS_V4; #endif /* KERBEROS_V5 */ -#if INET6 +#if INET6_ENABLE current.server.service = KPOP_PORT; -#else /* INET6 */ +#else /* INET6_ENABLE */ current.server.port = KPOP_PORT; -#endif /* INET6 */ +#endif /* INET6_ENABLE */ } | PROTOCOL SDPS { #ifdef SDPS_ENABLE @@ -157,14 +157,14 @@ serv_option : AKA alias_list | CHECKALIAS {current.server.checkalias = FLAG_TRUE;} | NO CHECKALIAS {current.server.checkalias = FLAG_FALSE;} | SERVICE STRING { -#if INET6 +#if INET6_ENABLE current.server.service = $2; -#endif /* INET6 */ +#endif /* INET6_ENABLE */ } | PORT NUMBER { -#if !INET6 +#if !INET6_ENABLE current.server.port = $2; -#endif /* !INET6 */ +#endif /* !INET6_ENABLE */ } | INTERVAL NUMBER {current.server.interval = $2;} | PREAUTHENTICATE PASSWORD {current.server.preauthenticate = A_PASSWORD;} @@ -209,18 +209,18 @@ serv_option : AKA alias_list #endif /* NET_SECURITY */ } | INTERFACE STRING { -#if (defined(linux) && !defined(INET6)) || defined(__FreeBSD__) +#if (defined(linux) && !defined(INET6_ENABLE)) || defined(__FreeBSD__) interface_parse($2, ¤t.server); -#else /* (defined(linux) && !defined(INET6)) || defined(__FreeBSD__) */ +#else /* (defined(linux) && !defined(INET6_ENABLE)) || defined(__FreeBSD__) */ fprintf(stderr, "fetchmail: interface option is only supported under Linux and FreeBSD\n"); -#endif /* (defined(linux) && !defined(INET6)) || defined(__FreeBSD__) */ +#endif /* (defined(linux) && !defined(INET6_ENABLE)) || defined(__FreeBSD__) */ } | MONITOR STRING { -#if (defined(linux) && !defined(INET6)) || defined(__FreeBSD__) +#if (defined(linux) && !defined(INET6_ENABLE)) || defined(__FreeBSD__) current.server.monitor = xstrdup($2); -#else /* (defined(linux) && !defined(INET6)) || defined(__FreeBSD__) */ +#else /* (defined(linux) && !defined(INET6_ENABLE)) || defined(__FreeBSD__) */ fprintf(stderr, "fetchmail: monitor option is only supported under Linux\n"); -#endif /* (defined(linux) && !defined(INET6) || defined(__FreeBSD__)) */ +#endif /* (defined(linux) && !defined(INET6_ENABLE) || defined(__FreeBSD__)) */ } | PLUGIN STRING { current.server.plugin = xstrdup($2); } | PLUGOUT STRING { current.server.plugout = xstrdup($2); } @@ -95,11 +95,11 @@ static int smtp_open(struct query *ctl) for (idp = ctl->smtphunt; idp; idp = idp->next) { char *cp, *parsed_host; -#ifdef INET6 +#ifdef INET6_ENABLE char *portnum = SMTP_PORT; #else int portnum = SMTP_PORT; -#endif /* INET6 */ +#endif /* INET6_ENABLE */ xalloca(parsed_host, char *, strlen(idp->id) + 1); @@ -109,11 +109,11 @@ static int smtp_open(struct query *ctl) if ((cp = strrchr(parsed_host, '/'))) { *cp++ = 0; -#ifdef INET6 +#ifdef INET6_ENABLE portnum = cp; #else portnum = atoi(cp); -#endif /* INET6 */ +#endif /* INET6_ENABLE */ } if ((ctl->smtp_socket = SockOpen(parsed_host,portnum,NULL, @@ -117,7 +117,7 @@ int SockCheckOpen(int fd) } #endif /* __UNUSED__ */ -#if INET6 +#if INET6_ENABLE int SockOpen(const char *host, const char *service, const char *options, const char *plugin) { @@ -159,7 +159,7 @@ int SockOpen(const char *host, const char *service, const char *options, return i; }; -#else /* INET6 */ +#else /* INET6_ENABLE */ #ifndef HAVE_INET_ATON #ifndef INADDR_NONE #ifdef INADDR_BROADCAST @@ -195,12 +195,34 @@ int SockOpen(const char *host, int clientPort, const char *options, #ifndef HAVE_INET_ATON inaddr = inet_addr(host); if (inaddr != INADDR_NONE) + { memcpy(&ad.sin_addr, &inaddr, sizeof(inaddr)); - else #else - if (!inet_aton(host, &ad.sin_addr)) -#endif /* HAVE_INET_ATON */ + if (inet_aton(host, &ad.sin_addr)) { +#endif /* HAVE_INET_ATON */ + ad.sin_port = htons(clientPort); + + sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock < 0) + { + h_errno = 0; + return -1; + } + if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0) + { + int olderr = errno; + close(sock); + h_errno = 0; + errno = olderr; + return -1; + } +#ifndef HAVE_INET_ATON + } +#else + } +#endif /* HAVE_INET_ATON */ + else { hp = gethostbyname(host); if (hp == NULL) @@ -248,27 +270,10 @@ int SockOpen(const char *host, int clientPort, const char *options, errno = olderr; return -1; } - } else { - ad.sin_port = htons(clientPort); - - sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - h_errno = 0; - return -1; - } - if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0) - { - int olderr = errno; - close(sock); - h_errno = 0; - errno = olderr; - return -1; - } } return(sock); } -#endif /* INET6 */ +#endif /* INET6_ENABLE */ #if defined(HAVE_STDARG_H) @@ -8,13 +8,13 @@ #define SOCKET__ /* Create a new client socket; returns (FILE *)NULL on error */ -#if INET6 +#if INET6_ENABLE int SockOpen(const char *host, const char *service, const char *options, const char *plugin); -#else /* INET6 */ +#else /* INET6_ENABLE */ int SockOpen(const char *host, int clientPort, const char *options, const char *plugin); -#endif /* INET6 */ +#endif /* INET6_ENABLE */ /* Returns 1 if this socket is OK, 0 if it isn't select()able * on - probably because it's been closed. You should |