[patch] Use /etc/mailname if available
John A Meinel
john at arbash-meinel.com
Mon Dec 19 14:16:30 GMT 2005
Jeff Garrett wrote:
>>> 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?
+1 from me. If we get another +1, we'll pull it in.
Though I wonder about adding:
mailname = socket.gethostname()
if '.' not in mailname:
mailname = socket.getfqdn()
Honestly, though. The email address is only for personal use. bzr uses
it a little bit so that it can help ensure unique ids, but really the
datestamp and random number provide the uniqueness.
In the future, we will more officially support signing with gpg. And at
that point we will probably also check that the committer matches the
gpg signature user (or something like that). But at that point, you need
to setup your gpg info, which means you are far enough that you probably
can setup your email address as well.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051219/a6309869/attachment.pgp
More information about the bazaar
mailing list