SA Bugzilla – Bug 2178
hostname added to report, hdrs still not quite helpful
Last modified: 2003-07-04 14:21:07 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/.
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.
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.
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.
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...
+1 looks good to me
committed.