aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--driver.c6
-rw-r--r--env.c34
-rw-r--r--fetchmail.c75
-rw-r--r--fetchmail.h2
5 files changed, 73 insertions, 47 deletions
diff --git a/NEWS b/NEWS
index 96f91d86..77408da5 100644
--- a/NEWS
+++ b/NEWS
@@ -3,8 +3,9 @@
fetchmail-4.5.7 (Tue Aug 25 00:29:44 EDT 1998):
* Fixed SDPS support (thanks to Chris Brooks).
* One more fix for the snakebit postmaster option.
+* Compute FQDN from localhost when we're using Kerberos.
-There are 253 people on fetchmail-friends and 272 on fetchmail-announce.
+There are 249 people on fetchmail-friends and 273 on fetchmail-announce.
fetchmail-4.5.6 (Tue Aug 25 00:29:44 EDT 1998):
* SDPS support, experimental version 2. Requires configure --enable-SDPS.
diff --git a/driver.c b/driver.c
index 11537d5b..e48dcc83 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 : "localhost";
+ char *id_me = run.invisible ? ctl->server.truename : fetchmailhost;
int oldphase = phase;
errno = 0;
@@ -890,8 +890,8 @@ int num; /* index of message */
#else
sprintf(buf,
#endif /* HAVE_SNPRINTF */
- "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);
+ "From: FETCHMAIL-DAEMON\r\nTo: %s@%s\r\nSubject: Headerless mail from %s's mailbox on %s\r\n",
+ user, fetchmailhost, ctl->remotename, ctl->server.truename);
headers = xstrdup(buf);
}
diff --git a/env.c b/env.c
index 3e86ac45..16254ddd 100644
--- a/env.c
+++ b/env.c
@@ -67,6 +67,40 @@ void envquery(int argc, char **argv)
strcat(rcfile, RCFILE_NAME);
}
+char *host_fqdn(void)
+/* get the FQDN of the machine we're running */
+{
+ char tmpbuf[HOSTLEN+1];
+
+ 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);
+ }
+ return(xstrdup(hp->h_name));
+ }
+ else
+#endif /* HAVE_GETHOSTBYNAME */
+ return(xstrdup(tmpbuf));
+}
+
+
char *showproto(int proto)
/* protocol index to protocol name mapping */
{
diff --git a/fetchmail.c b/fetchmail.c
index 2e08a2aa..a5256c02 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -69,6 +69,7 @@ char *user; /* the name of the invoking user */
char *home; /* invoking user's home directory */
char *program_name; /* the name to prefix error messages with */
flag configdump; /* dump control blocks for configurator */
+char *fetchmailhost; /* either `localhost' or the host FQDN */
#if NET_SECURITY
void *request = NULL;
@@ -849,6 +850,9 @@ static int load_params(int argc, char **argv, int optind)
if (ctl != querylist && strcmp(ctl->server.pollname, "defaults") == 0)
exit(PS_SYNTAX);
+ /* use localhost if we never fetch the FQDN of this host */
+ fetchmailhost = "localhost";
+
/* merge in wired defaults, do sanity checks and prepare internal fields */
for (ctl = querylist; ctl; ctl = ctl->next)
{
@@ -860,52 +864,37 @@ static int load_params(int argc, char **argv, int optind)
/* force command-line options */
optmerge(ctl, &cmd_opts, TRUE);
- /* make sure we have a nonempty host list to forward to */
- if (!ctl->smtphunt)
- {
- 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)
+ /*
+ * DNS support is required for some protocols.
+ *
+ * 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 we're using Kerberos for authentication, we need
+ * the FQDN in order to generate capability keys.
+ */
+ if ((ctl->server.protocol == P_ETRN
+ || ctl->server.preauthenticate == A_KERBEROS_V4
+ || ctl->server.preauthenticate == A_KERBEROS_V5))
+ if (ctl->server.dns)
{
- 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);
+ if (strcmp(fetchmailhost, "localhost") == 0)
+ fetchmailhost = host_fqdn();
}
else
- save_str(&ctl->smtphunt, "localhost", FALSE);
- }
+ {
+ fprintf(stderr, "DNS is required for %s protocol",
+ showproto(ctl->server.protocol));
+ exit(PS_DNS);
+ }
+
+ /*
+ * Make sure we have a nonempty host list to forward to.
+ */
+ if (!ctl->smtphunt)
+ save_str(&ctl->smtphunt, fetchmailhost, FALSE);
/* keep lusers from shooting themselves in the foot :-) */
if (run.poll_interval && ctl->limit)
diff --git a/fetchmail.h b/fetchmail.h
index aa1c1215..d7bd4142 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -281,6 +281,7 @@ extern char *user; /* name of invoking user */
extern char *home; /* home directory of invoking user */
extern int pass; /* number of re-polling pass */
extern flag configdump; /* dump control blocks as Python dictionary */
+extern char *fetchmailhost; /* either "localhost" or an FQDN */
/* prototypes for globally callable functions */
@@ -384,6 +385,7 @@ char *visbuf(const char *);
char *showproto(int);
void dump_config(struct runctl *runp, struct query *querylist);
int is_host_alias(const char *, struct query *);
+char *host_fqdn(void);
#ifdef SDPS_ENABLE
char *sdps_envto;
#endif /* SDPS_ENABLE */