aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-08-02 18:43:17 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-08-02 18:43:17 +0000
commit56f2f5e7a800ec59ae8d027a6c551ebf84fbda94 (patch)
tree5ad8b388e06b8fee5d73de1f7573e2418a92b8a0
parent1587e4153763fab493acf2deee9028e24e1da57f (diff)
downloadfetchmail-56f2f5e7a800ec59ae8d027a6c551ebf84fbda94.tar.gz
fetchmail-56f2f5e7a800ec59ae8d027a6c551ebf84fbda94.tar.bz2
fetchmail-56f2f5e7a800ec59ae8d027a6c551ebf84fbda94.zip
Eliminate agethostbyname call in non-ETRN modes.
svn path=/trunk/; revision=2033
-rw-r--r--NEWS6
-rw-r--r--driver.c9
-rw-r--r--env.c26
-rw-r--r--fetchmail.c46
-rw-r--r--fetchmail.h1
-rw-r--r--fetchmail.man9
6 files changed, 55 insertions, 42 deletions
diff --git a/NEWS b/NEWS
index 8e9a1040..5824e43e 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,12 @@ fetchmail-4.5.5 ():
* Fixed the spam-block code that I broke in 4.5.3 :-(.
* Updated the entry on setting up sendmail spam blocks.
* Added setrlimit call to inhibit core dumps unless debugging is on.
+* The default of smtplist has been changed; the undocumented feature that
+ it always included the fetchmail host's FQDN is gone (this is now
+ true for ETRN mode only).
+* Modes other than ETRN no longer need to know the fetchmail host's FQDN.
+ This eliminates a gethostbyname() call and makes fetchmail more independent
+ of local DNS configuration quirks.
There are 257 people on fetchmail-friends and 255 on fetchmail-announce.
diff --git a/driver.c b/driver.c
index 2ed48634..efff0bb2 100644
--- a/driver.c
+++ b/driver.c
@@ -364,7 +364,7 @@ static int smtp_open(struct query *ctl)
* What it will affect is the listener's logging.
*/
struct idlist *idp;
- char *id_me = run.invisible ? ctl->server.truename : fetchmailhost;
+ char *id_me = run.invisible ? ctl->server.truename : "localhost";
int oldphase = phase;
errno = 0;
@@ -890,8 +890,8 @@ int num; /* index of message */
#else
sprintf(buf,
#endif /* HAVE_SNPRINTF */
- "From: <FETCHMAIL-DAEMON@%s>\r\nTo: %s@localhost\r\nSubject: Headerless mail from %s's mailbox on %s\r\n",
- fetchmailhost, user, ctl->remotename, ctl->server.truename);
+ "From: FETCHMAIL-DAEMON\r\nTo: %s@localhost\r\nSubject: Headerless mail from %s's mailbox on %s\r\n",
+ user, ctl->remotename, ctl->server.truename);
headers = xstrdup(buf);
}
@@ -1360,8 +1360,7 @@ int num; /* index of message */
* but this can be secure information that would be bad
* to reveal.
*/
- sprintf(buf, "\tby %s (fetchmail-%s %s)\n",
- fetchmailhost,
+ sprintf(buf, "\tby fetchmail-%s %s\n",
RELEASE_ID,
protocol->name);
n = stuffline(ctl, buf);
diff --git a/env.c b/env.c
index 453e1449..67679d19 100644
--- a/env.c
+++ b/env.c
@@ -55,32 +55,6 @@ void envquery(int argc, char **argv)
}
}
- /* we'll need this for the SMTP forwarding target and error messages */
- if (gethostname(tmpbuf, sizeof(tmpbuf)))
- {
- fprintf(stderr, "%s: can't determine your host!", program_name);
- exit(PS_IOERR);
- }
-#ifdef HAVE_GETHOSTBYNAME
- /* if we got a . in the hostname assume it is a FQDN */
- if (strchr(tmpbuf, '.') == NULL)
- {
- struct hostent *hp;
-
- /* in case we got a basename (as we do in Linux) make a FQDN of it */
- hp = gethostbyname(tmpbuf);
- if (hp == (struct hostent *) NULL)
- {
- /* exit with error message */
- fprintf(stderr, "gethostbyname failed for %s\n", tmpbuf);
- exit(PS_DNS);
- }
- fetchmailhost = xstrdup(hp->h_name);
- }
- else
-#endif /* HAVE_GETHOSTBYNAME */
- fetchmailhost = xstrdup(tmpbuf);
-
#define RCFILE_NAME ".fetchmailrc"
rcfile = (char *) xmalloc(strlen(home)+strlen(RCFILE_NAME)+2);
/* avoid //.fetchmailrc */
diff --git a/fetchmail.c b/fetchmail.c
index bc841b28..912fdb7b 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -67,7 +67,6 @@ flag check_only; /* if --probe was set */
flag versioninfo; /* emit only version info */
char *user; /* the name of the invoking user */
char *home; /* invoking user's home directory */
-char *fetchmailhost; /* the name of the host running fetchmail */
char *program_name; /* the name to prefix error messages with */
flag configdump; /* dump control blocks for configurator */
@@ -839,13 +838,48 @@ static int load_params(int argc, char **argv, int optind)
/* make sure we have a nonempty host list to forward to */
if (!ctl->smtphunt)
{
- save_str(&ctl->smtphunt, fetchmailhost, FALSE);
- /* for non ETRN try to deliver mails to localhost if
- * fetchmailhost fails
+ char tmpbuf[HOSTLEN+1];
+ /*
+ * If we're using ETRN, the smtp hunt list is the list of
+ * systems we're polling on behalf of; these have to be
+ * fully-qualified domain names. The default for this list
+ * should be the FQDN of localhost.
*/
- if (ctl->server.protocol != P_ETRN) {
- save_str(&ctl->smtphunt, "localhost", FALSE);
+ if (ctl->server.protocol == P_ETRN)
+ {
+ char *fetchmailhost;
+
+ if (gethostname(tmpbuf, sizeof(tmpbuf)))
+ {
+ fprintf(stderr, "%s: can't determine your host!",
+ program_name);
+ exit(PS_DNS);
+ }
+#ifdef HAVE_GETHOSTBYNAME
+ /* if we got a . in the hostname assume it is a FQDN */
+ if (strchr(tmpbuf, '.') == NULL)
+ {
+ struct hostent *hp;
+
+ /* if we got a basename (as we do in Linux) make a FQDN of it */
+ hp = gethostbyname(tmpbuf);
+ if (hp == (struct hostent *) NULL)
+ {
+ /* exit with error message */
+ fprintf(stderr,
+ "gethostbyname failed for %s\n", tmpbuf);
+ exit(PS_DNS);
+ }
+ fetchmailhost = xstrdup(hp->h_name);
+ }
+ else
+#endif /* HAVE_GETHOSTBYNAME */
+ fetchmailhost = xstrdup(tmpbuf);
+
+ save_str(&ctl->smtphunt, fetchmailhost, FALSE);
}
+ else
+ save_str(&ctl->smtphunt, "localhost", FALSE);
}
/* keep lusers from shooting themselves in the foot :-) */
diff --git a/fetchmail.h b/fetchmail.h
index c4ce591d..21de95d4 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -276,7 +276,6 @@ extern int linelimit; /* limit # lines retrieved per site */
extern flag versioninfo; /* emit only version info */
extern char *user; /* name of invoking user */
extern char *home; /* home directory of invoking user */
-extern char *fetchmailhost; /* the name of the host running fetchmail */
extern int pass; /* number of re-polling pass */
extern flag configdump; /* dump control blocks as Python dictionary */
diff --git a/fetchmail.man b/fetchmail.man
index 32d58e1d..bb9abd54 100644
--- a/fetchmail.man
+++ b/fetchmail.man
@@ -220,10 +220,11 @@ Specify a hunt list of hosts to forward mail to (one or more
hostnames, comma-separated). In ETRN mode, set the host that the
mailserver is asked to ship mail to. Hosts are tried in list order;
the first one that is up becomes the forwarding or ETRN target for the
-current run. In all modes except ETRN, `localhost' is added to the
-end of the list as an invisible default. Each hostname may have a
-'/'-delimited suffix specifying a port or service to forward to; the
-default is 25 (or "smtp" under IPv6).
+current run. In ETRN mode, the FQDN of the machine running fetchmail
+is added to the end of the list as an invisible default; in all other
+modes `localhost' is added to the end of the list as an invisible
+default. Each hostname may have a '/'-delimited suffix specifying a
+port or service to forward to; the default is 25 (or "smtp" under IPv6).
.TP
.B \-D domain, --smtpaddress domain
(Keyword: smtpaddress)