From bdf8ed139a586f3ef1d11574c59813f982ca0698 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 7 Jun 2000 02:21:36 +0000 Subject: Julian Haight's changes. svn path=/trunk/; revision=2900 --- fetchmail.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'fetchmail.c') diff --git a/fetchmail.c b/fetchmail.c index bce52ae5..dd83b671 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -831,6 +831,7 @@ static void optmerge(struct query *h2, struct query *h1, int force) FLAG_MERGE(bsmtp); FLAG_MERGE(listener); FLAG_MERGE(smtpaddress); + FLAG_MERGE(smtpname); FLAG_MERGE(preconnect); FLAG_MERGE(postconnect); @@ -1143,8 +1144,40 @@ static int load_params(int argc, char **argv, int optind) ctl->server.truename=xstrdup((char *)namerec->h_name); } #endif /* HAVE_GETHOSTBYNAME */ - else - ctl->server.truename = xstrdup(ctl->server.queryname); + else { +#ifdef HAVE_GETHOSTBYNAME + struct hostent *namerec; + + /* + Get the host's IP, so we can report it like this: + + Received: from hostname [10.0.0.1] + + do we actually need to gethostbyname to find the IP? + it seems like it would be faster to do this later, when + we are actually resolving the hostname for a connection, + but I ain't that smart, so I don't know where to make + the change later.. + */ + errno = 0; + namerec = gethostbyname(ctl->server.queryname); + if (namerec == (struct hostent *)NULL) + { + report(stderr, + _("couldn't find canonical DNS name of %s\n"), + ctl->server.pollname); + exit(PS_DNS); + } + else { + ctl->server.truename=xstrdup((char *)namerec->h_name); + ctl->server.trueaddr=xmalloc(namerec->h_length); + memcpy(ctl->server.trueaddr, + namerec->h_addr_list[0], + namerec->h_length); + } +#endif /* HAVE_GETHOSTBYNAME */ + ctl->server.truename = xstrdup(ctl->server.queryname); + } /* if no folders were specified, set up the null one as default */ if (!ctl->mailboxes) -- cgit v1.2.3