]> Pileus Git - ~andy/fetchmail/commitdiff
Add parameter to host_fqdn() to state if the domain name is required, i. e.
authorMatthias Andree <matthias.andree@gmx.de>
Sun, 30 Oct 2005 21:27:25 +0000 (21:27 -0000)
committerMatthias Andree <matthias.andree@gmx.de>
Sun, 30 Oct 2005 21:27:25 +0000 (21:27 -0000)
if fetchmail should exit if it cannot resolve (canonicalize) its own hostname.

svn path=/trunk/; revision=4381

env.c
fetchmail.h

diff --git a/env.c b/env.c
index b3d27164f4171edf77c149d5449a80e05480b543..b1f055612c28af39725e17f3e3c7ab9c6a0b2af7 100644 (file)
--- a/env.c
+++ b/env.c
@@ -132,7 +132,7 @@ void envquery(int argc, char **argv)
     strcat(rcfile, RCFILE_NAME);
 }
 
-char *host_fqdn(void)
+char *host_fqdn(int required /** barf if the name cannot be resolved */)
 /* get the FQDN of the machine we're running */
 {
     char tmpbuf[HOSTLEN+1];
@@ -163,7 +163,13 @@ char *host_fqdn(void)
            fprintf(stderr,
                    GT_("gethostbyname failed for %s\n"), tmpbuf);
            fprintf(stderr, "%s", gai_strerror(e));
-           exit(PS_DNS);
+           fprintf(stderr, GT_("Cannot find my own host in hosts database to qualify it!\n"));
+           if (required)
+               exit(PS_DNS);
+           else {
+               fprintf(stderr, GT_("Trying to continue with unqualified hostname.\nDO NOT report broken Received: headers, HELO/EHLO lines or similar problems!\nDO repair your /etc/hosts, DNS, NIS or LDAP instead.\n"));
+               return 0;
+           }
        }
 
        result = xstrdup(res->ai_canonname);
index c75d07b0d6da17c44f65779803a459a0c2e2f3d7..257d84cda73cc22e476724a46fc90a61129436a8 100644 (file)
@@ -647,7 +647,7 @@ char *visbuf(const char *);
 const char *showproto(int);
 void dump_config(struct runctl *runp, struct query *querylist);
 int is_host_alias(const char *, struct query *);
-char *host_fqdn(void);
+char *host_fqdn(int required);
 char *rfc822timestamp(void);
 flag is_a_file(int);
 char *rfc2047e(const char*, const char *);