[patch] Use /etc/mailname if available
Jeff Garrett
jeff at jgarrett.org
Mon Dec 19 10:28:00 GMT 2005
> > In many cases, /etc/mailname will contain the correct domain name for
> > e-mail addresses. Hopefully, this should obviate the configuration step
> > for some users. Attached is a short patch to this effect.
> Is there a way to check if socket.gethostname() returns something
> reasonable? I know I've never heard of /etc/mailname before. I couldn't
> find it in man pages, though I believe I understand how it should work.
Man pages exist for it at least on Debian and Ubuntu. It is I think
specific to Debian-related distributions. I hadn't heard of it myself
until recently, but it does solve this problem well. It is similar in
to the hostname file in /etc.
As for checking the output of socket.gethostname(), it should almost
always return the short hostname of the machine. This should be good
enough for a dummy e-mail address, but it has little chance of being
valid.
That being said, the computers in the lab I've used in the recent past
have hostname(1) (and thus probably also socket.gethostname()) return
the FQDN of the machine. So, bzr should work without config there,
*because* of the badly configured DNS. :)
If the name returned contained a '.', then I believe it would be the
same name returned by socket.getfqdn() and thus a good choice. This
shouldn't happen most of the time though (in my opinion).
Another option, which I didn't suggest originally because it is more
controversial is to try socket.getfqdn() except on platforms (e.g. OS/X)
where bad DNS setups are known to be common. The reason for the delay
on OS/X was because the hostname is not included in /etc/hosts. This
*should* be rare on other POSIX platforms...
> I can understand trusting /etc/mailname before gethostname(), since if
> someone sets it up, I assume that means they intended it to be the
> official mail address.
It also has the value of aliasing. Instead of the email address being
jeff at howard.jgarrett.org (the FQDN of this machine) in my case, I get
jeff at jgarrett.org.
> I would like to check that mailname is not empty, though.
> Something more like:
...
Fair enough. How about the revised patch?
> John
> =:->
--
Jeff
JID: jeff at jgarrett.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bzr.patch
Type: text/x-patch
Size: 567 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051219/770ae436/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051219/770ae436/attachment.pgp
More information about the bazaar
mailing list