Bug 2178 - hostname added to report, hdrs still not quite helpful
Summary: hostname added to report, hdrs still not quite helpful
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Libraries (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: Other other
: P2 normal
Target Milestone: 2.60
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-01 14:50 UTC by Justin Mason
Modified: 2003-07-04 14:21 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status
patch to implement this, thx Theo patch None Justin Mason [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Mason 2003-07-01 14:50:48 UTC
After dogfooding this for a while, I note most hosts still just use the
short hostname, e.g. "dogma" instead of "dogma.slashnull.org".   This
won't help us deal with one of the main problem cases -- if SA is running
on a third-party host, where it shouldn't necessarily, we need to be able to
figure this out.

So I suggest we need to grab the domain name somehow, and add that to what's
used for _HOST_, if available.

It should be relatively easy to do; we get the hostname, then call
gethostbyname(hname), and check all the aliases until we find one with a "."
in it that doesn't =~ /localhost/.
Comment 1 Theo Van Dinter 2003-07-01 15:07:11 UTC
Subject: Re: [SAdev]  New: hostname added to report, hdrs still not quite helpful

On Tue, Jul 01, 2003 at 02:52:59PM -0700, bugzilla-daemon@bugzilla.spamassassin.org wrote:
> It should be relatively easy to do; we get the hostname, then call
> gethostbyname(hname), and check all the aliases until we find one with a "."
> in it that doesn't =~ /localhost/.

Well, instead of ignoring localhost, you'd want to match /^hname\./i ...
I can have a host with 8 interfaces, but I'd only want the actual hostname
of the machine to be listed.  Since the actual hostname doesn't have to
be a real name anyway, we could try the loop and fail back to hname if
we can't find anything.

So something like:

if ( $hname !~ /\./ ) {
  my @names = grep(/^$hname\./o, map { split } (gethostbyname($hname))[0..1]);
  $hname = $names[0] if ($#names > -1);;
}

Ideally, we'd want to calculate this once, then use that everywhere
else in the code.  Right now, I think we call hostname() each time,
but I could be wrong.

Comment 2 Justin Mason 2003-07-01 15:25:33 UTC
Subject: Re:  hostname added to report, hdrs still not quite helpful 


>Ideally, we'd want to calculate this once, then use that everywhere
>else in the code.  Right now, I think we call hostname() each time,
>but I could be wrong.

yeah, good point -- that's probably pretty inefficient anyway.  I bet that
code calls /bin/hostname each time...

--j.

Comment 3 Daniel Quinlan 2003-07-02 00:44:22 UTC
I think plain old hostname should be enough.  It can't be *that* hard to
figure out the machine using Received: headers plus the hostname.
Comment 4 Justin Mason 2003-07-03 18:20:17 UTC
Created attachment 1132 [details]
patch to implement this, thx Theo

OK, here's a patch that does this.   it'll use the fully-qualified hostname
where possible, and removes calls to Sys::Hostname elsewhere in the code,
replacing them with a call to the new Mail::SA::Util method.   Since it's
cleaner and adds a little more functionality, I think it's worth it...
Comment 5 Theo Van Dinter 2003-07-03 21:06:10 UTC
+1 looks good to me
Comment 6 Theo Van Dinter 2003-07-04 22:21:07 UTC
committed.